X-Git-Url: https://git.sur5r.net/?a=blobdiff_plain;f=include%2Fcommon.h;h=4b3e0d3bbd75adb6fe1a78e3ff1710de5df08297;hb=d928664f4101e24128c879956d1aa7c76509ea6a;hp=a75fc25c5f6aeefeba4d46800c8eb7377086178b;hpb=f2c8d7f591e28d3437155c7a6eae8c8d9e3fe552;p=u-boot diff --git a/include/common.h b/include/common.h index a75fc25c5f..4b3e0d3bbd 100644 --- a/include/common.h +++ b/include/common.h @@ -23,6 +23,7 @@ typedef volatile unsigned char vu_char; #include #include #include +#include #if defined(CONFIG_PCI) && defined(CONFIG_4xx) #include #endif @@ -32,10 +33,7 @@ typedef volatile unsigned char vu_char; defined(CONFIG_MPC866) || \ defined(CONFIG_MPC866P) # define CONFIG_MPC866_FAMILY 1 -#elif defined(CONFIG_MPC870) \ - || defined(CONFIG_MPC875) \ - || defined(CONFIG_MPC880) \ - || defined(CONFIG_MPC885) +#elif defined(CONFIG_MPC885) # define CONFIG_MPC885_FAMILY 1 #endif #if defined(CONFIG_MPC860) \ @@ -72,12 +70,6 @@ typedef volatile unsigned char vu_char; #ifdef CONFIG_4xx #include #endif -#ifdef CONFIG_HYMOD -#include -#endif -#ifdef CONFIG_ARM -#define asmlinkage /* nothing */ -#endif #ifdef CONFIG_BLACKFIN #include #endif @@ -89,6 +81,9 @@ typedef volatile unsigned char vu_char; #include #include +/* Bring in printf format macros if inttypes.h is included */ +#define __STDC_FORMAT_MACROS + #ifdef __LP64__ #define CONFIG_SYS_SUPPORT_64BIT_DATA #endif @@ -99,15 +94,19 @@ typedef volatile unsigned char vu_char; #define _DEBUG 0 #endif +#ifndef pr_fmt +#define pr_fmt(fmt) fmt +#endif + /* * Output a debug text when condition "cond" is met. The "cond" should be * computed by a preprocessor in the best case, allowing for the best * optimization. */ -#define debug_cond(cond, fmt, args...) \ - do { \ - if (cond) \ - printf(fmt, ##args); \ +#define debug_cond(cond, fmt, args...) \ + do { \ + if (cond) \ + printf(pr_fmt(fmt), ##args); \ } while (0) #define debug(fmt, args...) \ @@ -129,7 +128,7 @@ void __assert_fail(const char *assertion, const char *file, unsigned line, __assert_fail(#x, __FILE__, __LINE__, __func__); }) #define error(fmt, args...) do { \ - printf("ERROR: " fmt "\nat %s:%d/%s()\n", \ + printf("ERROR: " pr_fmt(fmt) "\nat %s:%d/%s()\n", \ ##args, __FILE__, __LINE__, __func__); \ } while (0) @@ -171,64 +170,6 @@ typedef void (interrupt_handler_t)(void *); # endif #endif -/* - * General Purpose Utilities - */ -#define min(X, Y) \ - ({ typeof(X) __x = (X); \ - typeof(Y) __y = (Y); \ - (__x < __y) ? __x : __y; }) - -#define max(X, Y) \ - ({ typeof(X) __x = (X); \ - typeof(Y) __y = (Y); \ - (__x > __y) ? __x : __y; }) - -#define MIN(x, y) min(x, y) -#define MAX(x, y) max(x, y) - -#define min3(X, Y, Z) \ - ({ typeof(X) __x = (X); \ - typeof(Y) __y = (Y); \ - typeof(Z) __z = (Z); \ - __x < __y ? (__x < __z ? __x : __z) : \ - (__y < __z ? __y : __z); }) - -#define max3(X, Y, Z) \ - ({ typeof(X) __x = (X); \ - typeof(Y) __y = (Y); \ - typeof(Z) __z = (Z); \ - __x > __y ? (__x > __z ? __x : __z) : \ - (__y > __z ? __y : __z); }) - -#define MIN3(x, y, z) min3(x, y, z) -#define MAX3(x, y, z) max3(x, y, z) - -/* - * Return the absolute value of a number. - * - * This handles unsigned and signed longs, ints, shorts and chars. For all - * input types abs() returns a signed long. - * - * For 64-bit types, use abs64() - */ -#define abs(x) ({ \ - long ret; \ - if (sizeof(x) == sizeof(long)) { \ - long __x = (x); \ - ret = (__x < 0) ? -__x : __x; \ - } else { \ - int __x = (x); \ - ret = (__x < 0) ? -__x : __x; \ - } \ - ret; \ - }) - -#define abs64(x) ({ \ - s64 __x = (x); \ - (__x < 0) ? -__x : __x; \ - }) - #if defined(CONFIG_ENV_IS_EMBEDDED) #define TOTAL_MALLOC_LEN CONFIG_SYS_MALLOC_LEN #elif ( ((CONFIG_ENV_ADDR+CONFIG_ENV_SIZE) < CONFIG_SYS_MONITOR_BASE) || \ @@ -239,17 +180,6 @@ typedef void (interrupt_handler_t)(void *); #define TOTAL_MALLOC_LEN CONFIG_SYS_MALLOC_LEN #endif -/** - * container_of - cast a member of a structure out to the containing structure - * @ptr: the pointer to the member. - * @type: the type of the container struct this is embedded in. - * @member: the name of the member within the struct. - * - */ -#define container_of(ptr, type, member) ({ \ - const typeof( ((type *)0)->member ) *__mptr = (ptr); \ - (type *)( (char *)__mptr - offsetof(type,member) );}) - /* * Function Prototypes */ @@ -262,7 +192,19 @@ int cpu_init(void); /* */ phys_size_t initdram (int); int display_options (void); -void print_size(unsigned long long, const char *); + +/** + * print_size() - Print a size with a suffic + * + * print sizes as "xxx KiB", "xxx.y KiB", "xxx MiB", "xxx.y MiB", + * xxx GiB, xxx.y GiB, etc as needed; allow for optional trailing string + * (like "\n") + * + * @size: Size to print + * @suffix String to print after the size + */ +void print_size(uint64_t size, const char *suffix); + int print_buffer(ulong addr, const void *data, uint width, uint count, uint linelen); @@ -318,14 +260,14 @@ int arch_early_init_r(void); void board_show_dram(ulong size); /** - * arch_fixup_memory_node() - Write arch-specific memory information to fdt + * arch_fixup_fdt() - Write arch-specific information to fdt * - * Defined in arch/$(ARCH)/lib/bootm.c + * Defined in arch/$(ARCH)/lib/bootm-fdt.c * * @blob: FDT blob to write to * @return 0 if ok, or -ve FDT_ERR_... on failure */ -int arch_fixup_memory_node(void *blob); +int arch_fixup_fdt(void *blob); /* common/flash.c */ void flash_perror (int); @@ -473,10 +415,6 @@ int eeprom_probe (unsigned dev_addr, unsigned offset); #endif int eeprom_read (unsigned dev_addr, unsigned offset, uchar *buffer, unsigned cnt); int eeprom_write (unsigned dev_addr, unsigned offset, uchar *buffer, unsigned cnt); -#ifdef CONFIG_LWMON -extern uchar pic_read (uchar reg); -extern void pic_write (uchar reg, uchar val); -#endif /* * Set this up regardless of board @@ -497,18 +435,6 @@ extern ssize_t spi_read (uchar *, int, uchar *, int); extern ssize_t spi_write (uchar *, int, uchar *, int); #endif -#ifdef CONFIG_HERMES -/* $(BOARD)/hermes.c */ -void hermes_start_lxt980 (int speed); -#endif - -#ifdef CONFIG_EVB64260 -void evb64260_init(void); -void debug_led(int, int); -void display_mem_map(void); -void perform_soft_reset(void); -#endif - /* $(BOARD)/$(BOARD).c */ int board_early_init_f (void); int board_late_init (void); @@ -553,10 +479,6 @@ ulong get_endaddr (void); void trap_init (ulong); #if defined (CONFIG_4xx) || \ defined (CONFIG_MPC5xxx) || \ - defined (CONFIG_74xx_7xx) || \ - defined (CONFIG_74x) || \ - defined (CONFIG_75x) || \ - defined (CONFIG_74xx) || \ defined (CONFIG_MPC85xx) || \ defined (CONFIG_MPC86xx) || \ defined (CONFIG_MPC83xx) @@ -619,6 +541,7 @@ int checkicache (void); int checkdcache (void); void upmconfig (unsigned int, unsigned int *, unsigned int); ulong get_tbclk (void); +void reset_misc (void); void reset_cpu (ulong addr); #if defined (CONFIG_OF_LIBFDT) && defined (CONFIG_OF_BOARD_SETUP) void ft_cpu_setup(void *blob, bd_t *bd); @@ -644,13 +567,6 @@ struct stdio_dev; int serial_stub_getc(struct stdio_dev *sdev); int serial_stub_tstc(struct stdio_dev *sdev); -void _serial_setbrg (const int); -void _serial_putc (const char, const int); -void _serial_putc_raw(const char, const int); -void _serial_puts (const char *, const int); -int _serial_getc (const int); -int _serial_tstc (const int); - /* $(CPU)/speed.c */ int get_clocks (void); int get_clocks_866 (void); @@ -781,7 +697,7 @@ void invalidate_dcache_all(void); void invalidate_icache_all(void); /* arch/$(ARCH)/lib/ticks.S */ -unsigned long long get_ticks(void); +uint64_t get_ticks(void); void wait_ticks (unsigned long); /* arch/$(ARCH)/lib/time.c */ @@ -950,31 +866,7 @@ static inline phys_addr_t map_to_sysmem(const void *ptr) #error Read section CONFIG_SKIP_LOWLEVEL_INIT in README. #endif -#define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0])) - #define ROUND(a,b) (((a) + (b) - 1) & ~((b) - 1)) -#define DIV_ROUND(n,d) (((n) + ((d)/2)) / (d)) -#define DIV_ROUND_UP(n,d) (((n) + (d) - 1) / (d)) -#define roundup(x, y) ((((x) + ((y) - 1)) / (y)) * (y)) - -/* - * Divide positive or negative dividend by positive divisor and round - * to closest integer. Result is undefined for negative divisors and - * for negative dividends if the divisor variable type is unsigned. - */ -#define DIV_ROUND_CLOSEST(x, divisor)( \ -{ \ - typeof(x) __x = x; \ - typeof(divisor) __d = divisor; \ - (((typeof(x))-1) > 0 || \ - ((typeof(divisor))-1) > 0 || (__x) > 0) ? \ - (((__x) + ((__d) / 2)) / (__d)) : \ - (((__x) - ((__d) / 2)) / (__d)); \ -} \ -) - -#define ALIGN(x,a) __ALIGN_MASK((x),(typeof(x))(a)-1) -#define __ALIGN_MASK(x,mask) (((x)+(mask))&~(mask)) /* * ARCH_DMA_MINALIGN is defined in asm/cache.h for each architecture. It @@ -1056,7 +948,7 @@ static inline phys_addr_t map_to_sysmem(const void *ptr) * Usage of this macro shall be avoided or used with extreme care! */ #define DEFINE_ALIGN_BUFFER(type, name, size, align) \ - static char __##name[roundup(size * sizeof(type), align)] \ + static char __##name[ALIGN(size * sizeof(type), align)] \ __aligned(align); \ \ static type *name = (type *)__##name