]> git.kernelconcepts.de Git - karo-tx-uboot.git/blobdiff - include/common.h
dm: fdt: Remove the old GPIO functions
[karo-tx-uboot.git] / include / common.h
index d5020c8c45d1afc515e02433ea2513ab6b99d28e..97c8f79fc7375706c07af06c752c424e196a083d 100644 (file)
@@ -23,6 +23,7 @@ typedef volatile unsigned char        vu_char;
 #include <linux/stringify.h>
 #include <asm/ptrace.h>
 #include <stdarg.h>
+#include <linux/kernel.h>
 #if defined(CONFIG_PCI) && defined(CONFIG_4xx)
 #include <pci.h>
 #endif
@@ -69,12 +70,6 @@ typedef volatile unsigned char       vu_char;
 #ifdef CONFIG_4xx
 #include <asm/ppc4xx.h>
 #endif
-#ifdef CONFIG_HYMOD
-#include <board/hymod/hymod.h>
-#endif
-#ifdef CONFIG_ARM
-#define asmlinkage     /* nothing */
-#endif
 #ifdef CONFIG_BLACKFIN
 #include <asm/blackfin.h>
 #endif
@@ -86,6 +81,9 @@ typedef volatile unsigned char        vu_char;
 #include <flash.h>
 #include <image.h>
 
+/* Bring in printf format macros if inttypes.h is included */
+#define __STDC_FORMAT_MACROS
+
 #ifdef __LP64__
 #define CONFIG_SYS_SUPPORT_64BIT_DATA
 #endif
@@ -96,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...)                    \
@@ -126,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)
 
@@ -168,58 +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 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); })
-
-/*
- * 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) || \
@@ -230,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
  */
@@ -253,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);
 
@@ -277,12 +228,13 @@ int run_command_list(const char *cmd, int len, int flag);
 extern char console_buffer[];
 
 /* arch/$(ARCH)/lib/board.c */
-void   board_init_f(ulong);
-void   board_init_r  (gd_t *, ulong) __attribute__ ((noreturn));
-int    checkboard    (void);
-int    checkflash    (void);
-int    checkdram     (void);
-int    last_stage_init(void);
+void board_init_f(ulong);
+void board_init_r(gd_t *, ulong) __attribute__ ((noreturn));
+int checkboard(void);
+int show_board_info(void);
+int checkflash(void);
+int checkdram(void);
+int last_stage_init(void);
 extern ulong monitor_flash_len;
 int mac_read_from_eeprom(void);
 extern u8 __dtb_dt_begin[];    /* embedded device tree blob */
@@ -464,10 +416,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
@@ -488,18 +436,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);
@@ -544,10 +480,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)
@@ -636,13 +568,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);
@@ -773,7 +698,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 */
@@ -942,31 +867,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
@@ -1048,7 +949,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