diff options
Diffstat (limited to 'include')
-rw-r--r-- | include/asm-generic/bug.h | 37 | ||||
-rw-r--r-- | include/common.h | 121 | ||||
-rw-r--r-- | include/console.h | 1 | ||||
-rw-r--r-- | include/debug_ll.h | 4 | ||||
-rw-r--r-- | include/linux/bug.h | 30 | ||||
-rw-r--r-- | include/linux/kernel.h | 88 | ||||
-rw-r--r-- | include/linux/mtd/nand_mxs.h | 37 | ||||
-rw-r--r-- | include/net/smc91111.h | 4 | ||||
-rw-r--r-- | include/platform_data/mtd-nand-mrvl.h | 79 | ||||
-rw-r--r-- | include/usb/usb.h | 4 |
10 files changed, 278 insertions, 127 deletions
diff --git a/include/asm-generic/bug.h b/include/asm-generic/bug.h new file mode 100644 index 0000000000..8583d2425f --- /dev/null +++ b/include/asm-generic/bug.h @@ -0,0 +1,37 @@ +#ifndef _ASM_GENERIC_BUG_H +#define _ASM_GENERIC_BUG_H + +#include <linux/compiler.h> + +#define BUG() do { \ + printf("BUG: failure at %s:%d/%s()!\n", __FILE__, __LINE__, __FUNCTION__); \ + panic("BUG!"); \ +} while (0) +#define BUG_ON(condition) do { if (unlikely((condition)!=0)) BUG(); } while(0) + + +#define __WARN() do { \ + printf("WARNING: at %s:%d/%s()!\n", __FILE__, __LINE__, __FUNCTION__); \ +} while (0) + +#ifndef WARN_ON +#define WARN_ON(condition) ({ \ + int __ret_warn_on = !!(condition); \ + if (unlikely(__ret_warn_on)) \ + __WARN(); \ + unlikely(__ret_warn_on); \ +}) +#endif + +#ifndef WARN +#define WARN(condition, format...) ({ \ + int __ret_warn_on = !!(condition); \ + if (unlikely(__ret_warn_on)) { \ + __WARN(); \ + puts("WARNING: "); \ + printf(format); \ + } \ + unlikely(__ret_warn_on); \ +}) +#endif +#endif diff --git a/include/common.h b/include/common.h index fca9798bbb..eef371c4bf 100644 --- a/include/common.h +++ b/include/common.h @@ -49,38 +49,6 @@ #error "None of __LITTLE_ENDIAN and __BIG_ENDIAN are defined" #endif -#define BUG() do { \ - printf("BUG: failure at %s:%d/%s()!\n", __FILE__, __LINE__, __FUNCTION__); \ - panic("BUG!"); \ -} while (0) -#define BUG_ON(condition) do { if (unlikely((condition)!=0)) BUG(); } while(0) - - -#define __WARN() do { \ - printf("WARNING: at %s:%d/%s()!\n", __FILE__, __LINE__, __FUNCTION__); \ -} while (0) - -#ifndef WARN_ON -#define WARN_ON(condition) ({ \ - int __ret_warn_on = !!(condition); \ - if (unlikely(__ret_warn_on)) \ - __WARN(); \ - unlikely(__ret_warn_on); \ -}) -#endif - -#ifndef WARN -#define WARN(condition, format...) ({ \ - int __ret_warn_on = !!(condition); \ - if (unlikely(__ret_warn_on)) { \ - __WARN(); \ - puts("WARNING: "); \ - printf(format); \ - } \ - unlikely(__ret_warn_on); \ -}) -#endif - #include <asm/barebox.h> /* boot information for Linux kernel */ /* @@ -89,7 +57,6 @@ void reginfo(void); void __noreturn hang (void); -void __noreturn panic(const char *fmt, ...); char *size_human_readable(unsigned long long size); @@ -107,11 +74,6 @@ void __noreturn poweroff(void); void udelay (unsigned long); void mdelay (unsigned long); -/* lib_generic/vsprintf.c */ -ulong simple_strtoul(const char *cp,char **endp,unsigned int base); -unsigned long long simple_strtoull(const char *cp,char **endp,unsigned int base); -long simple_strtol(const char *cp,char **endp,unsigned int base); - /* lib_generic/crc32.c */ uint32_t crc32(uint32_t, const void*, unsigned int); uint32_t crc32_no_comp(uint32_t, const void*, unsigned int); @@ -175,32 +137,8 @@ static inline char *shell_expand(char *str) } #endif -/* Force a compilation error if condition is true */ -#define BUILD_BUG_ON(condition) ((void)BUILD_BUG_ON_ZERO(condition)) - -/* Force a compilation error if condition is constant and true */ -#define MAYBE_BUILD_BUG_ON(cond) ((void)sizeof(char[1 - 2 * !!(cond)])) - -/* Force a compilation error if a constant expression is not a power of 2 */ -#define BUILD_BUG_ON_NOT_POWER_OF_2(n) \ - BUILD_BUG_ON((n) == 0 || (((n) & ((n) - 1)) != 0)) - -/* - * Force a compilation error if condition is true, but also produce a - * result (of value 0 and type size_t), so the expression can be used - * e.g. in a structure initializer (or where-ever else comma - * expressions aren't permitted). - */ -#define BUILD_BUG_ON_ZERO(e) (sizeof(struct { int:-!!(e); })) -#define BUILD_BUG_ON_NULL(e) ((void *)sizeof(struct { int:-!!(e); })) - -#define ALIGN(x, a) __ALIGN_MASK(x, (typeof(x))(a) - 1) -#define __ALIGN_MASK(x, mask) (((x) + (mask)) & ~(mask)) #define ALIGN_DOWN(x, a) ((x) & ~((typeof(x))(a) - 1)) -#define PTR_ALIGN(p, a) ((typeof(p))ALIGN((unsigned long)(p), (a))) -#define IS_ALIGNED(x, a) (((x) & ((typeof(x))(a) - 1)) == 0) -#define ARRAY_SIZE(arr) (sizeof(arr) / sizeof((arr)[0]) + __must_be_array(arr)) #define ARRAY_AND_SIZE(x) (x), ARRAY_SIZE(x) /* @@ -214,30 +152,6 @@ static inline char *shell_expand(char *str) char __##name[sizeof(type) * (size) + (align) - 1]; \ type *name = (type *)ALIGN((uintptr_t)__##name, align) -/** - * 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) );}) - -#define USHORT_MAX ((u16)(~0U)) -#define SHORT_MAX ((s16)(USHORT_MAX>>1)) -#define SHORT_MIN (-SHORT_MAX - 1) -#define INT_MAX ((int)(~0U>>1)) -#define INT_MIN (-INT_MAX - 1) -#define UINT_MAX (~0U) -#define LONG_MAX ((long)(~0UL>>1)) -#define LONG_MIN (-LONG_MAX - 1) -#define ULONG_MAX (~0UL) -#define LLONG_MAX ((long long)(~0ULL>>1)) -#define LLONG_MIN (-LLONG_MAX - 1) -#define ULLONG_MAX (~0ULL) - #define PAGE_SIZE 4096 #define PAGE_SHIFT 12 #define PAGE_ALIGN(s) (((s) + PAGE_SIZE - 1) & ~(PAGE_SIZE - 1)) @@ -279,41 +193,6 @@ void barebox_set_hostname(const char *); #define IOMEM(addr) ((void __force __iomem *)(addr)) #endif -#define DIV_ROUND_UP(n,d) (((n) + (d) - 1) / (d)) - -#define DIV_ROUND_CLOSEST(x, divisor)( \ -{ \ - typeof(divisor) __divisor = divisor; \ - (((x) + ((__divisor) / 2)) / (__divisor)); \ -} \ -) - -/** - * upper_32_bits - return bits 32-63 of a number - * @n: the number we're accessing - * - * A basic shift-right of a 64- or 32-bit quantity. Use this to suppress - * the "right shift count >= width of type" warning when that quantity is - * 32-bits. - */ -#define upper_32_bits(n) ((u32)(((n) >> 16) >> 16)) - -/** - * lower_32_bits - return bits 0-31 of a number - * @n: the number we're accessing - */ -#define lower_32_bits(n) ((u32)(n)) - -#define abs(x) ({ \ - long __x = (x); \ - (__x < 0) ? -__x : __x; \ - }) - -#define abs64(x) ({ \ - s64 __x = (x); \ - (__x < 0) ? -__x : __x; \ - }) - /* * Check if two regions overlap. returns true if they do, false otherwise */ diff --git a/include/console.h b/include/console.h index beafb4d778..72b4a440e7 100644 --- a/include/console.h +++ b/include/console.h @@ -47,6 +47,7 @@ struct console_device { int (*set_active)(struct console_device *cdev, unsigned active); char *devname; + int devid; struct list_head list; diff --git a/include/debug_ll.h b/include/debug_ll.h index 288aa256e5..b0eb7cd7d9 100644 --- a/include/debug_ll.h +++ b/include/debug_ll.h @@ -33,7 +33,7 @@ #if defined (CONFIG_DEBUG_LL) -static inline void putc_ll(unsigned char value) +static inline void putc_ll(char value) { PUTC_LL(value); } @@ -67,7 +67,7 @@ static inline void puts_ll(const char * str) #else -static inline void putc_ll(unsigned char value) +static inline void putc_ll(char value) { } diff --git a/include/linux/bug.h b/include/linux/bug.h new file mode 100644 index 0000000000..7295618c98 --- /dev/null +++ b/include/linux/bug.h @@ -0,0 +1,30 @@ +#ifndef _LINUX_BUG_H +#define _LINUX_BUG_H + +#include <asm-generic/bug.h> + +#ifdef __CHECKER__ +#define BUILD_BUG_ON_NOT_POWER_OF_2(n) (0) +#define BUILD_BUG_ON_ZERO(e) (0) +#define BUILD_BUG_ON_NULL(e) ((void*)0) +#define BUILD_BUG_ON(condition) (0) +#else /* __CHECKER__ */ + +/* Force a compilation error if a constant expression is not a power of 2 */ +#define BUILD_BUG_ON_NOT_POWER_OF_2(n) \ + BUILD_BUG_ON((n) == 0 || (((n) & ((n) - 1)) != 0)) + +/* Force a compilation error if condition is true, but also produce a + result (of value 0 and type size_t), so the expression can be used + e.g. in a structure initializer (or where-ever else comma expressions + aren't permitted). */ +#define BUILD_BUG_ON_ZERO(e) (sizeof(struct { int:-!!(e); })) +#define BUILD_BUG_ON_NULL(e) ((void *)sizeof(struct { int:-!!(e); })) + +/* Force a compilation error if condition is true */ +#define BUILD_BUG_ON(condition) ((void)BUILD_BUG_ON_ZERO(condition)) + +#endif + + +#endif /* _LINUX_BUG_H */ diff --git a/include/linux/kernel.h b/include/linux/kernel.h index 98f12e1b93..3f2644cf65 100644 --- a/include/linux/kernel.h +++ b/include/linux/kernel.h @@ -2,8 +2,43 @@ #define _LINUX_KERNEL_H #include <linux/compiler.h> +#include <linux/bug.h> #include <linux/barebox-wrapper.h> +#define USHRT_MAX ((u16)(~0U)) +#define SHRT_MAX ((s16)(USHRT_MAX>>1)) +#define SHRT_MIN ((s16)(-SHRT_MAX - 1)) +#define INT_MAX ((int)(~0U>>1)) +#define INT_MIN (-INT_MAX - 1) +#define UINT_MAX (~0U) +#define LONG_MAX ((long)(~0UL>>1)) +#define LONG_MIN (-LONG_MAX - 1) +#define ULONG_MAX (~0UL) +#define LLONG_MAX ((long long)(~0ULL>>1)) +#define LLONG_MIN (-LLONG_MAX - 1) +#define ULLONG_MAX (~0ULL) +#define SIZE_MAX (~(size_t)0) + +#define U8_MAX ((u8)~0U) +#define S8_MAX ((s8)(U8_MAX>>1)) +#define S8_MIN ((s8)(-S8_MAX - 1)) +#define U16_MAX ((u16)~0U) +#define S16_MAX ((s16)(U16_MAX>>1)) +#define S16_MIN ((s16)(-S16_MAX - 1)) +#define U32_MAX ((u32)~0U) +#define S32_MAX ((s32)(U32_MAX>>1)) +#define S32_MIN ((s32)(-S32_MAX - 1)) +#define U64_MAX ((u64)~0ULL) +#define S64_MAX ((s64)(U64_MAX>>1)) +#define S64_MIN ((s64)(-S64_MAX - 1)) + +#define ALIGN(x, a) __ALIGN_MASK(x, (typeof(x))(a) - 1) +#define __ALIGN_MASK(x, mask) (((x) + (mask)) & ~(mask)) +#define PTR_ALIGN(p, a) ((typeof(p))ALIGN((unsigned long)(p), (a))) +#define IS_ALIGNED(x, a) (((x) & ((typeof(x))(a) - 1)) == 0) + +#define ARRAY_SIZE(arr) (sizeof(arr) / sizeof((arr)[0]) + __must_be_array(arr)) + /* * This looks more complex than it should be. But we need to * get the type for the ~ right in round_down (it needs to be @@ -17,6 +52,47 @@ #define round_up(x, y) ((((x)-1) | __round_mask(x, y))+1) #define round_down(x, y) ((x) & ~__round_mask(x, y)) +#define DIV_ROUND_UP(n,d) (((n) + (d) - 1) / (d)) + +#define DIV_ROUND_CLOSEST(x, divisor)( \ +{ \ + typeof(divisor) __divisor = divisor; \ + (((x) + ((__divisor) / 2)) / (__divisor)); \ +} \ +) + +/** + * upper_32_bits - return bits 32-63 of a number + * @n: the number we're accessing + * + * A basic shift-right of a 64- or 32-bit quantity. Use this to suppress + * the "right shift count >= width of type" warning when that quantity is + * 32-bits. + */ +#define upper_32_bits(n) ((u32)(((n) >> 16) >> 16)) + +/** + * lower_32_bits - return bits 0-31 of a number + * @n: the number we're accessing + */ +#define lower_32_bits(n) ((u32)(n)) + +#define abs(x) ({ \ + long __x = (x); \ + (__x < 0) ? -__x : __x; \ + }) + +#define abs64(x) ({ \ + s64 __x = (x); \ + (__x < 0) ? -__x : __x; \ + }) + +void __noreturn panic(const char *fmt, ...); + +extern unsigned long simple_strtoul(const char *,char **,unsigned int); +extern long simple_strtol(const char *,char **,unsigned int); +extern unsigned long long simple_strtoull(const char *,char **,unsigned int); + /* * min()/max()/clamp() macros that also do * strict type-checking.. See the @@ -170,4 +246,16 @@ static inline char *hex_byte_pack_upper(char *buf, u8 byte) return buf; } +/** + * 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) );}) + + #endif /* _LINUX_KERNEL_H */ diff --git a/include/linux/mtd/nand_mxs.h b/include/linux/mtd/nand_mxs.h new file mode 100644 index 0000000000..eca31777f5 --- /dev/null +++ b/include/linux/mtd/nand_mxs.h @@ -0,0 +1,37 @@ +/* + * Copyright (C) 2015 PHYTEC Messtechnik GmbH, + * Author: Stefan Christ <s.christ@phytec.de> + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License as + * published by the Free Software Foundation; either version 2 of + * the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + */ + +#ifndef __NAND_MXS_H +#define __NAND_MXS_H + +/* + * Functions are definied in drivers/mtd/nand/nand_mxs.c. They are used to + * calculate the ECC Strength, BadBlockMarkerByte and BadBlockMarkerStartBit + * which are placed into the FCB structure. The i.MX6 ROM needs these + * parameters to read the firmware from NAND. + * + * The parameters depends on the pagesize and oobsize of NAND chips and are + * different for each combination. To avoid placing hardcoded values in the bbu + * update handler code, the generic calculation from the driver code is used. + */ + +uint32_t mxs_nand_get_ecc_strength(uint32_t page_data_size, + uint32_t page_oob_size); + +uint32_t mxs_nand_mark_byte_offset(struct mtd_info *mtd); + +uint32_t mxs_nand_mark_bit_offset(struct mtd_info *mtd); + +#endif /* __NAND_MXS_H */ diff --git a/include/net/smc91111.h b/include/net/smc91111.h index 0b2d49bb19..ba9da0b8dd 100644 --- a/include/net/smc91111.h +++ b/include/net/smc91111.h @@ -9,6 +9,10 @@ struct smc91c111_pdata { int qemu_fixup; + int addr_shift; + int bus_width; + int config_setup; + int control_setup; }; #endif /* __SMC91111_H__ */ diff --git a/include/platform_data/mtd-nand-mrvl.h b/include/platform_data/mtd-nand-mrvl.h new file mode 100644 index 0000000000..c8ef6a1eea --- /dev/null +++ b/include/platform_data/mtd-nand-mrvl.h @@ -0,0 +1,79 @@ +/* + * Copyright (C) 2014 Robert Jarzmik + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation. + * + * Taken from linux kernel mostly. + */ +#ifndef __MRVL_NAND_H +#define __MRVL_NAND_H + +struct mrvl_nand_timing { + uint16_t id; /* NAND id code (READID) */ + unsigned int tCH; /* Enable signal hold time */ + unsigned int tCS; /* Enable signal setup time */ + unsigned int tWH; /* ND_nWE high duration */ + unsigned int tWP; /* ND_nWE pulse time */ + unsigned int tRH; /* ND_nRE high duration */ + unsigned int tRP; /* ND_nRE pulse width */ + unsigned int tR; /* ND_nWE high to ND_nRE low for read */ + unsigned int tWHR; /* ND_nWE high to ND_nRE low for status read */ + unsigned int tAR; /* ND_ALE low to ND_nRE low delay */ +}; + +struct mrvl_nand_flash { + char *name; + uint32_t chip_id; + unsigned int page_per_block; /* Pages per block (PG_PER_BLK) */ + unsigned int page_size; /* Page size in bytes (PAGE_SZ) */ + unsigned int flash_width; /* Flash memory width (DWIDTH_M) */ + unsigned int dfc_width; /* Flash controller width (DWIDTH_C) */ + unsigned int num_blocks; /* Number of physical blocks in Flash */ + + struct mrvl_nand_timing *timing; /* NAND Flash timing */ +}; + +/* + * Current pxa3xx_nand controller has two chip select which + * both be workable. + * + * Notice should be taken that: + * When you want to use this feature, you should not enable the + * keep configuration feature, for two chip select could be + * attached with different nand chip. The different page size + * and timing requirement make the keep configuration impossible. + */ + +/* The max num of chip select current support */ +#define NUM_CHIP_SELECT (2) +struct mrvl_nand_platform_data { + /* the data flash bus is shared between the Static Memory + * Controller and the Data Flash Controller, the arbiter + * controls the ownership of the bus + */ + int dwidth_c; + int dwidth_m; + + /* allow platform code to keep OBM/bootloader defined NFC config */ + int keep_config; + + /* indicate how many chip selects will be used */ + int num_cs; + + /* use an flash-based bad block table */ + bool flash_bbt; + + /* requested ECC strength and ECC step size */ + int ecc_strength, ecc_step_size; + + const struct mtd_partition *parts[NUM_CHIP_SELECT]; + unsigned int nr_parts[NUM_CHIP_SELECT]; + + const struct mrvl_nand_flash *flash; + size_t num_flash; +}; + +extern void mrvl_set_nand_info(struct mrvl_nand_platform_data *info); +#endif /* __MRVL_NAND_H */ diff --git a/include/usb/usb.h b/include/usb/usb.h index f02f1fbb57..991f3d7dd1 100644 --- a/include/usb/usb.h +++ b/include/usb/usb.h @@ -171,10 +171,6 @@ int usb_submit_int_msg(struct usb_device *dev, unsigned long pipe, void *buffer, int transfer_len, int interval); void usb_disable_asynch(int disable); int usb_maxpacket(struct usb_device *dev, unsigned long pipe); -static inline void wait_ms(unsigned long ms) -{ - mdelay(ms); -}; int usb_get_configuration_no(struct usb_device *dev, unsigned char *buffer, int cfgno); int usb_get_report(struct usb_device *dev, int ifnum, unsigned char type, |