Commit bedd8403f77f790e9876578885eab1200ba2f8d8
Committed by
Wolfgang Denk
1 parent
81813cb01f
Exists in
master
and in
54 other branches
export SPI functions to standalone apps
While we're here, fix the broken #ifdef handling in _exports.h. Signed-off-by: Mike Frysinger <vapier@gentoo.org>
Showing 3 changed files with 20 additions and 5 deletions Inline Diff
common/exports.c
1 | #include <common.h> | 1 | #include <common.h> |
2 | #include <exports.h> | 2 | #include <exports.h> |
3 | 3 | ||
4 | DECLARE_GLOBAL_DATA_PTR; | 4 | DECLARE_GLOBAL_DATA_PTR; |
5 | 5 | ||
6 | static void dummy(void) | 6 | static void dummy(void) |
7 | { | 7 | { |
8 | } | 8 | } |
9 | 9 | ||
10 | unsigned long get_version(void) | 10 | unsigned long get_version(void) |
11 | { | 11 | { |
12 | return XF_VERSION; | 12 | return XF_VERSION; |
13 | } | 13 | } |
14 | 14 | ||
15 | void jumptable_init (void) | 15 | void jumptable_init (void) |
16 | { | 16 | { |
17 | int i; | 17 | int i; |
18 | 18 | ||
19 | gd->jt = (void **) malloc (XF_MAX * sizeof (void *)); | 19 | gd->jt = (void **) malloc (XF_MAX * sizeof (void *)); |
20 | for (i = 0; i < XF_MAX; i++) | 20 | for (i = 0; i < XF_MAX; i++) |
21 | gd->jt[i] = (void *) dummy; | 21 | gd->jt[i] = (void *) dummy; |
22 | 22 | ||
23 | gd->jt[XF_get_version] = (void *) get_version; | 23 | gd->jt[XF_get_version] = (void *) get_version; |
24 | gd->jt[XF_malloc] = (void *) malloc; | 24 | gd->jt[XF_malloc] = (void *) malloc; |
25 | gd->jt[XF_free] = (void *) free; | 25 | gd->jt[XF_free] = (void *) free; |
26 | gd->jt[XF_getenv] = (void *) getenv; | 26 | gd->jt[XF_getenv] = (void *) getenv; |
27 | gd->jt[XF_setenv] = (void *) setenv; | 27 | gd->jt[XF_setenv] = (void *) setenv; |
28 | gd->jt[XF_get_timer] = (void *) get_timer; | 28 | gd->jt[XF_get_timer] = (void *) get_timer; |
29 | gd->jt[XF_simple_strtoul] = (void *) simple_strtoul; | 29 | gd->jt[XF_simple_strtoul] = (void *) simple_strtoul; |
30 | gd->jt[XF_udelay] = (void *) udelay; | 30 | gd->jt[XF_udelay] = (void *) udelay; |
31 | gd->jt[XF_simple_strtol] = (void *) simple_strtol; | 31 | gd->jt[XF_simple_strtol] = (void *) simple_strtol; |
32 | gd->jt[XF_strcmp] = (void *) strcmp; | 32 | gd->jt[XF_strcmp] = (void *) strcmp; |
33 | #if defined(CONFIG_I386) || defined(CONFIG_PPC) | 33 | #if defined(CONFIG_I386) || defined(CONFIG_PPC) |
34 | gd->jt[XF_install_hdlr] = (void *) irq_install_handler; | 34 | gd->jt[XF_install_hdlr] = (void *) irq_install_handler; |
35 | gd->jt[XF_free_hdlr] = (void *) irq_free_handler; | 35 | gd->jt[XF_free_hdlr] = (void *) irq_free_handler; |
36 | #endif /* I386 || PPC */ | 36 | #endif /* I386 || PPC */ |
37 | #if defined(CONFIG_CMD_I2C) | 37 | #if defined(CONFIG_CMD_I2C) |
38 | gd->jt[XF_i2c_write] = (void *) i2c_write; | 38 | gd->jt[XF_i2c_write] = (void *) i2c_write; |
39 | gd->jt[XF_i2c_read] = (void *) i2c_read; | 39 | gd->jt[XF_i2c_read] = (void *) i2c_read; |
40 | #endif | 40 | #endif |
41 | #ifdef CONFIG_CMD_SPI | ||
42 | gd->jt[XF_spi_init] = (void *) spi_init; | ||
43 | gd->jt[XF_spi_setup_slave] = (void *) spi_setup_slave; | ||
44 | gd->jt[XF_spi_free_slave] = (void *) spi_free_slave; | ||
45 | gd->jt[XF_spi_claim_bus] = (void *) spi_claim_bus; | ||
46 | gd->jt[XF_spi_release_bus] = (void *) spi_release_bus; | ||
47 | gd->jt[XF_spi_xfer] = (void *) spi_xfer; | ||
48 | #endif | ||
41 | } | 49 | } |
42 | 50 |
include/_exports.h
1 | /* | ||
2 | * You do not need to use #ifdef around functions that may not exist | ||
3 | * in the final configuration (such as i2c). | ||
4 | */ | ||
1 | EXPORT_FUNC(get_version) | 5 | EXPORT_FUNC(get_version) |
2 | EXPORT_FUNC(getc) | 6 | EXPORT_FUNC(getc) |
3 | EXPORT_FUNC(tstc) | 7 | EXPORT_FUNC(tstc) |
4 | EXPORT_FUNC(putc) | 8 | EXPORT_FUNC(putc) |
5 | EXPORT_FUNC(puts) | 9 | EXPORT_FUNC(puts) |
6 | EXPORT_FUNC(printf) | 10 | EXPORT_FUNC(printf) |
7 | EXPORT_FUNC(install_hdlr) | 11 | EXPORT_FUNC(install_hdlr) |
8 | EXPORT_FUNC(free_hdlr) | 12 | EXPORT_FUNC(free_hdlr) |
9 | EXPORT_FUNC(malloc) | 13 | EXPORT_FUNC(malloc) |
10 | EXPORT_FUNC(free) | 14 | EXPORT_FUNC(free) |
11 | EXPORT_FUNC(udelay) | 15 | EXPORT_FUNC(udelay) |
12 | EXPORT_FUNC(get_timer) | 16 | EXPORT_FUNC(get_timer) |
13 | EXPORT_FUNC(vprintf) | 17 | EXPORT_FUNC(vprintf) |
14 | EXPORT_FUNC(do_reset) | 18 | EXPORT_FUNC(do_reset) |
15 | EXPORT_FUNC(getenv) | 19 | EXPORT_FUNC(getenv) |
16 | EXPORT_FUNC(setenv) | 20 | EXPORT_FUNC(setenv) |
17 | #ifdef CONFIG_HAS_UID | ||
18 | EXPORT_FUNC(forceenv) | 21 | EXPORT_FUNC(forceenv) |
19 | #endif | ||
20 | EXPORT_FUNC(simple_strtoul) | 22 | EXPORT_FUNC(simple_strtoul) |
21 | EXPORT_FUNC(simple_strtol) | 23 | EXPORT_FUNC(simple_strtol) |
22 | EXPORT_FUNC(strcmp) | 24 | EXPORT_FUNC(strcmp) |
23 | #if defined(CONFIG_CMD_I2C) | ||
24 | EXPORT_FUNC(i2c_write) | 25 | EXPORT_FUNC(i2c_write) |
25 | EXPORT_FUNC(i2c_read) | 26 | EXPORT_FUNC(i2c_read) |
26 | #endif | 27 | EXPORT_FUNC(spi_init) |
28 | EXPORT_FUNC(spi_setup_slave) | ||
29 | EXPORT_FUNC(spi_free_slave) | ||
30 | EXPORT_FUNC(spi_claim_bus) |
include/exports.h
1 | #ifndef __EXPORTS_H__ | 1 | #ifndef __EXPORTS_H__ |
2 | #define __EXPORTS_H__ | 2 | #define __EXPORTS_H__ |
3 | 3 | ||
4 | #ifndef __ASSEMBLY__ | 4 | #ifndef __ASSEMBLY__ |
5 | 5 | ||
6 | #include <common.h> | 6 | #include <common.h> |
7 | 7 | ||
8 | /* These are declarations of exported functions available in C code */ | 8 | /* These are declarations of exported functions available in C code */ |
9 | unsigned long get_version(void); | 9 | unsigned long get_version(void); |
10 | int getc(void); | 10 | int getc(void); |
11 | int tstc(void); | 11 | int tstc(void); |
12 | void putc(const char); | 12 | void putc(const char); |
13 | void puts(const char*); | 13 | void puts(const char*); |
14 | void printf(const char* fmt, ...); | 14 | void printf(const char* fmt, ...); |
15 | void install_hdlr(int, interrupt_handler_t*, void*); | 15 | void install_hdlr(int, interrupt_handler_t*, void*); |
16 | void free_hdlr(int); | 16 | void free_hdlr(int); |
17 | void *malloc(size_t); | 17 | void *malloc(size_t); |
18 | void free(void*); | 18 | void free(void*); |
19 | void udelay(unsigned long); | 19 | void udelay(unsigned long); |
20 | unsigned long get_timer(unsigned long); | 20 | unsigned long get_timer(unsigned long); |
21 | void vprintf(const char *, va_list); | 21 | void vprintf(const char *, va_list); |
22 | void do_reset (void); | 22 | void do_reset (void); |
23 | unsigned long simple_strtoul(const char *cp,char **endp,unsigned int base); | 23 | unsigned long simple_strtoul(const char *cp,char **endp,unsigned int base); |
24 | char *getenv (char *name); | 24 | char *getenv (char *name); |
25 | int setenv (char *varname, char *varvalue); | 25 | int setenv (char *varname, char *varvalue); |
26 | long simple_strtol(const char *cp,char **endp,unsigned int base); | 26 | long simple_strtol(const char *cp,char **endp,unsigned int base); |
27 | int strcmp(const char * cs,const char * ct); | 27 | int strcmp(const char * cs,const char * ct); |
28 | int ustrtoul(const char *cp, char **endp, unsigned int base); | 28 | int ustrtoul(const char *cp, char **endp, unsigned int base); |
29 | #ifdef CONFIG_HAS_UID | 29 | #ifdef CONFIG_HAS_UID |
30 | void forceenv (char *varname, char *varvalue); | 30 | void forceenv (char *varname, char *varvalue); |
31 | #endif | 31 | #endif |
32 | #if defined(CONFIG_CMD_I2C) | 32 | #if defined(CONFIG_CMD_I2C) |
33 | int i2c_write (uchar, uint, int , uchar* , int); | 33 | int i2c_write (uchar, uint, int , uchar* , int); |
34 | int i2c_read (uchar, uint, int , uchar* , int); | 34 | int i2c_read (uchar, uint, int , uchar* , int); |
35 | #endif | 35 | #endif |
36 | #include <spi.h> | ||
36 | 37 | ||
37 | void app_startup(char **); | 38 | void app_startup(char **); |
38 | 39 | ||
39 | #endif /* ifndef __ASSEMBLY__ */ | 40 | #endif /* ifndef __ASSEMBLY__ */ |
40 | 41 | ||
41 | enum { | 42 | enum { |
42 | #define EXPORT_FUNC(x) XF_ ## x , | 43 | #define EXPORT_FUNC(x) XF_ ## x , |
43 | #include <_exports.h> | 44 | #include <_exports.h> |
44 | #undef EXPORT_FUNC | 45 | #undef EXPORT_FUNC |
45 | 46 | ||
46 | XF_MAX | 47 | XF_MAX |
47 | }; | 48 | }; |
48 | 49 | ||
49 | #define XF_VERSION 4 | 50 | #define XF_VERSION 5 |
50 | 51 | ||
51 | #if defined(CONFIG_I386) | 52 | #if defined(CONFIG_I386) |
52 | extern gd_t *global_data; | 53 | extern gd_t *global_data; |
53 | #endif | 54 | #endif |
54 | 55 | ||
55 | #endif /* __EXPORTS_H__ */ | 56 | #endif /* __EXPORTS_H__ */ |
56 | 57 |