From 07a2d42cd4964168b98c895dd2bb9c0c8275992d Mon Sep 17 00:00:00 2001 From: Mateusz Zalega Date: Wed, 30 Apr 2014 13:04:15 +0200 Subject: mmc: mmc header fix Structure definition used type block_dev_desc_t, defined in part.h, which wasn't included in mmc.h. It worked only in circumstances when common.h, or another header using part.h was incuded in implementation files. Change-Id: I5b203928b689887e3e78beb00a378955e0553eb7 Signed-off-by: Mateusz Zalega Acked-by: Pantelis Antoniou Cc: Minkyu Kang --- include/mmc.h | 1 + 1 file changed, 1 insertion(+) (limited to 'include') diff --git a/include/mmc.h b/include/mmc.h index 42d01251b59..bc11f45a6fc 100644 --- a/include/mmc.h +++ b/include/mmc.h @@ -12,6 +12,7 @@ #include #include +#include #define SD_VERSION_SD 0x20000 #define SD_VERSION_3 (SD_VERSION_SD | 0x300) -- cgit v1.2.3 From 6b423b752b24bf69962821754314418621fc71cc Mon Sep 17 00:00:00 2001 From: Mateusz Zalega Date: Mon, 28 Apr 2014 21:13:22 +0200 Subject: part: header fix Implementation made use of types defined in common.h, even though it wasn't #included. It worked in circumstances when .c files included every needed header (all). Signed-off-by: Mateusz Zalega Cc: Tom Rini Cc: Minkyu Kang --- include/part.h | 1 + 1 file changed, 1 insertion(+) (limited to 'include') diff --git a/include/part.h b/include/part.h index 4beb6db89b1..53532dcd612 100644 --- a/include/part.h +++ b/include/part.h @@ -8,6 +8,7 @@ #define _PART_H #include +#include typedef struct block_dev_desc { int if_type; /* type of the interface */ -- cgit v1.2.3 From 75504e9592745021006cb8905b5ff5a51d9d1cb3 Mon Sep 17 00:00:00 2001 From: Mateusz Zalega Date: Wed, 30 Apr 2014 13:07:48 +0200 Subject: usb: dfu: fix boards wo USB cable detection Former usb_cable_connected() patch broke compilation of boards which do not support this feature. I've renamed usb_cable_connected() to g_dnl_usb_cable_connected() and added its default implementation to gadget downloader driver code. There's only one driver of this kind and it's unlikely there'll be another, so there's no point in keeping it in /common. Previously this function was declared in usb.h. I've moved it, since it's more appropriate to keep it in g_dnl.h - usb.h seems to be intended for USB host implementation. Existing code, confronted with default -EOPNOTSUPP return value, continues as if the cable was connected. CONFIG_USB_CABLE_CHECK was removed. Change-Id: Ib9198621adee2811b391c64512f14646cefd0369 Signed-off-by: Mateusz Zalega Acked-by: Marek Vasut Acked-by: Lukasz Majewski --- include/configs/exynos4-dt.h | 1 - include/g_dnl.h | 1 + include/usb.h | 10 ---------- 3 files changed, 1 insertion(+), 11 deletions(-) (limited to 'include') diff --git a/include/configs/exynos4-dt.h b/include/configs/exynos4-dt.h index 2040bf7784d..cbd2d204cf9 100644 --- a/include/configs/exynos4-dt.h +++ b/include/configs/exynos4-dt.h @@ -127,7 +127,6 @@ #define CONFIG_USB_GADGET_S3C_UDC_OTG #define CONFIG_USB_GADGET_DUALSPEED #define CONFIG_USB_GADGET_VBUS_DRAW 2 -#define CONFIG_USB_CABLE_CHECK #define CONFIG_CMD_USB_MASS_STORAGE #define CONFIG_USB_GADGET_MASS_STORAGE diff --git a/include/g_dnl.h b/include/g_dnl.h index 8f813c21ee6..f4e8d1089e6 100644 --- a/include/g_dnl.h +++ b/include/g_dnl.h @@ -11,6 +11,7 @@ #include #include int g_dnl_bind_fixup(struct usb_device_descriptor *, const char *); +int g_dnl_board_usb_cable_connected(void); int g_dnl_register(const char *s); void g_dnl_unregister(void); void g_dnl_set_serialnumber(char *); diff --git a/include/usb.h b/include/usb.h index 736730e8964..d9fedeeff7d 100644 --- a/include/usb.h +++ b/include/usb.h @@ -197,16 +197,6 @@ int board_usb_init(int index, enum usb_init_type init); */ int board_usb_cleanup(int index, enum usb_init_type init); -/* - * If CONFIG_USB_CABLE_CHECK is set then this function - * should be defined in board file. - * - * @return 1 if cable is connected and 0 otherwise. - */ -#ifdef CONFIG_USB_CABLE_CHECK -int usb_cable_connected(void); -#endif - #ifdef CONFIG_USB_STORAGE #define USB_MAX_STOR_DEV 5 -- cgit v1.2.3 From 711b931f90e44ff1248cd73c15f64485470d86ff Mon Sep 17 00:00:00 2001 From: Mateusz Zalega Date: Mon, 28 Apr 2014 21:13:24 +0200 Subject: dfu: mmc: raw data write fix When user attempted to perform a raw write using DFU (vide dfu_fill_entity_mmc) with MMC interface not initialized before, get_mmc_blk_size() reported invalid (zero) block size - it wasn't possible to write ie. a new u-boot image. This commit fixes that by initializing MMC device before use in dfu_fill_entity_mmc(). While fixing initialization sequence, I had to change about half of dfu_fill_entity_mmc's body, so I refactored it on the way to make it, IMHO, considerably more comprehensible. Being left as dead code, get_mmc_blk_size() was removed. Tested on Samsung Goni. Signed-off-by: Mateusz Zalega Signed-off-by: Kyungmin Park Acked-by: Lukasz Majewski Acked-by: Tom Rini Cc: Minkyu Kang --- include/dfu.h | 5 ----- 1 file changed, 5 deletions(-) (limited to 'include') diff --git a/include/dfu.h b/include/dfu.h index 6c71ecbe355..dcd3215d06b 100644 --- a/include/dfu.h +++ b/include/dfu.h @@ -64,11 +64,6 @@ struct ram_internal_data { unsigned int size; }; -static inline unsigned int get_mmc_blk_size(int dev) -{ - return find_mmc_device(dev)->read_bl_len; -} - #define DFU_NAME_SIZE 32 #define DFU_CMD_BUF_SIZE 128 #ifndef CONFIG_SYS_DFU_DATA_BUF_SIZE -- cgit v1.2.3 From b7d4259af298402b7d65c876d8e39e5b9e6c8934 Mon Sep 17 00:00:00 2001 From: Mateusz Zalega Date: Mon, 28 Apr 2014 21:13:25 +0200 Subject: dfu: mmc: change offset base handling Previously offsets handled by dfu_fill_entity_mmc(), defined in boards' CONFIG_DFU_ALT were treated as hexadecimal regardless of their prefix, which sometimes led to confusion. This patch forces usage of explicit numerical base prefixes. Signed-off-by: Mateusz Zalega Acked-by: Lukasz Majewski Cc: Tom Rini Cc: Minkyu Kang --- include/configs/am335x_evm.h | 8 ++++---- include/configs/trats.h | 4 ++-- include/configs/trats2.h | 4 ++-- 3 files changed, 8 insertions(+), 8 deletions(-) (limited to 'include') diff --git a/include/configs/am335x_evm.h b/include/configs/am335x_evm.h index ea9e758a696..4147f9f3691 100644 --- a/include/configs/am335x_evm.h +++ b/include/configs/am335x_evm.h @@ -320,10 +320,10 @@ "boot part 0 1;" \ "rootfs part 0 2;" \ "MLO fat 0 1;" \ - "MLO.raw mmc 100 100;" \ - "u-boot.img.raw mmc 300 400;" \ - "spl-os-args.raw mmc 80 80;" \ - "spl-os-image.raw mmc 900 2000;" \ + "MLO.raw mmc 0x100 0x100;" \ + "u-boot.img.raw mmc 0x300 0x400;" \ + "spl-os-args.raw mmc 0x80 0x80;" \ + "spl-os-image.raw mmc 0x900 0x2000;" \ "spl-os-args fat 0 1;" \ "spl-os-image fat 0 1;" \ "u-boot.img fat 0 1;" \ diff --git a/include/configs/trats.h b/include/configs/trats.h index 5d8bd605836..c4afecf3dab 100644 --- a/include/configs/trats.h +++ b/include/configs/trats.h @@ -101,7 +101,7 @@ "name="PARTS_UMS",size=-,uuid=${uuid_gpt_"PARTS_UMS"}\0" \ #define CONFIG_DFU_ALT \ - "u-boot mmc 80 400;" \ + "u-boot raw 0x80 0x400;" \ "uImage ext4 0 2;" \ "modem.bin ext4 0 2;" \ "exynos4210-trats.dtb ext4 0 2;" \ @@ -112,7 +112,7 @@ ""PARTS_ROOT" part 0 5;" \ ""PARTS_DATA" part 0 6;" \ ""PARTS_UMS" part 0 7;" \ - "params.bin mmc 0x38 0x8\0" + "params.bin raw 0x38 0x8\0" #define CONFIG_EXTRA_ENV_SETTINGS \ "bootk=" \ diff --git a/include/configs/trats2.h b/include/configs/trats2.h index 53d449c291a..14def7d16e8 100644 --- a/include/configs/trats2.h +++ b/include/configs/trats2.h @@ -91,7 +91,7 @@ "name="PARTS_UMS",size=-,uuid=${uuid_gpt_"PARTS_UMS"}\0" \ #define CONFIG_DFU_ALT \ - "u-boot mmc 80 800;" \ + "u-boot raw 0x80 0x800;" \ "uImage ext4 0 2;" \ "modem.bin ext4 0 2;" \ "exynos4412-trats2.dtb ext4 0 2;" \ @@ -102,7 +102,7 @@ ""PARTS_ROOT" part 0 5;" \ ""PARTS_DATA" part 0 6;" \ ""PARTS_UMS" part 0 7;" \ - "params.bin mmc 0x38 0x8\0" + "params.bin raw 0x38 0x8\0" #define CONFIG_EXTRA_ENV_SETTINGS \ "bootk=" \ -- cgit v1.2.3 From fad8edf0f72b8aba8885d2d137ebb58b3428806a Mon Sep 17 00:00:00 2001 From: Mateusz Zalega Date: Mon, 28 Apr 2014 21:13:27 +0200 Subject: am335x: dfu: disable DFU in am335x_evm SPL build Future patches will make DFU too large to fit in this board's SPL build. Signed-off-by: Mateusz Zalega Acked-by: Tom Rini Reviewed-by: Lukasz Majewski --- include/configs/am335x_evm.h | 2 ++ 1 file changed, 2 insertions(+) (limited to 'include') diff --git a/include/configs/am335x_evm.h b/include/configs/am335x_evm.h index 4147f9f3691..670e3f19e37 100644 --- a/include/configs/am335x_evm.h +++ b/include/configs/am335x_evm.h @@ -312,6 +312,7 @@ #endif /* USB Device Firmware Update support */ +#ifndef CONFIG_SPL_BUILD #define CONFIG_DFU_FUNCTION #define CONFIG_DFU_MMC #define CONFIG_CMD_DFU @@ -354,6 +355,7 @@ DFU_ALT_INFO_MMC \ DFU_ALT_INFO_RAM \ DFU_ALT_INFO_NAND +#endif /* * Default to using SPI for environment, etc. -- cgit v1.2.3 From c4d0e856047f2689278ffea63a562c4f22a35ee3 Mon Sep 17 00:00:00 2001 From: Mateusz Zalega Date: Mon, 28 Apr 2014 21:13:28 +0200 Subject: USB: gadget: added a saner gadget downloader registration API Preprocessor definitions and hardcoded implementation selection in g_dnl core were replaced by a linker list made of (usb_function_name, bind_callback) pairs. Signed-off-by: Mateusz Zalega Acked-by: Lukasz Majewski Acked-by: Marek Vasut --- include/dfu.h | 7 ------- include/g_dnl.h | 23 +++++++++++++++++++++++ include/thor.h | 8 -------- include/usb_mass_storage.h | 8 -------- 4 files changed, 23 insertions(+), 23 deletions(-) (limited to 'include') diff --git a/include/dfu.h b/include/dfu.h index dcd3215d06b..240916854a1 100644 --- a/include/dfu.h +++ b/include/dfu.h @@ -168,12 +168,5 @@ static inline int dfu_fill_entity_ram(struct dfu_entity *dfu, char *s) } #endif -#ifdef CONFIG_DFU_FUNCTION int dfu_add(struct usb_configuration *c); -#else -int dfu_add(struct usb_configuration *c) -{ - return 0; -} -#endif #endif /* __DFU_ENTITY_H_ */ diff --git a/include/g_dnl.h b/include/g_dnl.h index f4e8d1089e6..1b1b35e0e1c 100644 --- a/include/g_dnl.h +++ b/include/g_dnl.h @@ -10,6 +10,29 @@ #include #include +#include +#include + +/* + * @usb_fname: unescaped USB function name + * @callback_ptr: bind callback, one per function name + */ +#define DECLARE_GADGET_BIND_CALLBACK(usb_fname, callback_ptr) \ + ll_entry_declare(struct g_dnl_bind_callback, \ + __usb_function_name_##usb_fname, \ + g_dnl_bind_callbacks) = { \ + .usb_function_name = #usb_fname, \ + .fptr = callback_ptr \ + } + +typedef int (*g_dnl_bind_callback_f)(struct usb_configuration *); + +/* used in Gadget downloader callback linker list */ +struct g_dnl_bind_callback { + const char *usb_function_name; + g_dnl_bind_callback_f fptr; +}; + int g_dnl_bind_fixup(struct usb_device_descriptor *, const char *); int g_dnl_board_usb_cable_connected(void); int g_dnl_register(const char *s); diff --git a/include/thor.h b/include/thor.h index afeade45646..5051be714bd 100644 --- a/include/thor.h +++ b/include/thor.h @@ -15,13 +15,5 @@ int thor_handle(void); int thor_init(void); - -#ifdef CONFIG_THOR_FUNCTION int thor_add(struct usb_configuration *c); -#else -int thor_add(struct usb_configuration *c) -{ - return 0; -} -#endif #endif /* __THOR_H_ */ diff --git a/include/usb_mass_storage.h b/include/usb_mass_storage.h index 058dcf11740..ed460644c1f 100644 --- a/include/usb_mass_storage.h +++ b/include/usb_mass_storage.h @@ -40,13 +40,5 @@ int fsg_init(struct ums *); void fsg_cleanup(void); struct ums *ums_init(unsigned int); int fsg_main_thread(void *); - -#ifdef CONFIG_USB_GADGET_MASS_STORAGE int fsg_add(struct usb_configuration *c); -#else -int fsg_add(struct usb_configuration *c) -{ - return 0; -} -#endif #endif /* __USB_MASS_STORAGE_H__ */ -- cgit v1.2.3 From af41d6b4cb1602abebaaa9c8774a9b0ece564796 Mon Sep 17 00:00:00 2001 From: Mateusz Zalega Date: Tue, 29 Apr 2014 20:14:22 +0200 Subject: common: fixed linker-list example Last argument shouldn't be there. Signed-off-by: Mateusz Zalega Acked-by: Marek Vasut Cc: Tom Rini --- include/linker_lists.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'include') diff --git a/include/linker_lists.h b/include/linker_lists.h index 997d149b71d..557e6273adb 100644 --- a/include/linker_lists.h +++ b/include/linker_lists.h @@ -228,7 +228,7 @@ * and it's name. * * Example: - * ll_entry_declare(struct my_sub_cmd, my_sub_cmd, cmd_sub, cmd.sub) = { + * ll_entry_declare(struct my_sub_cmd, my_sub_cmd, cmd_sub) = { * .x = 3, * .y = 4, * }; -- cgit v1.2.3