[U-Boot] [PATCH RESEND 3/5] arm:goni: Add support for USB mass storage
Mateusz Zalega
m.zalega at samsung.com
Tue Aug 6 12:50:55 CEST 2013
From: Arkadiusz Wlodarczyk <a.wlodarczyk at samsung.com>
This commit enables support for USB mass storage composite function.
It defines platform code and enables it at config file.
Signed-off-by: Arkadiusz Wlodarczyk <a.wlodarczyk at samsung.com>
Signed-off-by: Kyungmin Park <kyungmin.park at samsung.com>
Signed-off-by: Mateusz Zalega <m.zalega at samsung.com>
Tested-by: Arkadiusz Wlodarczyk <a.wlodarczyk at samsung.com>
Tested-by: Mateusz Zalega <m.zalega at samsung.com>
Cc: Minkyu Kang <mk7.kang at samsung.com>
---
board/samsung/goni/goni.c | 76 +++++++++++++++++++++++++++++++++++++++++++++-
include/configs/s5p_goni.h | 10 +++---
2 files changed, 80 insertions(+), 6 deletions(-)
diff --git a/board/samsung/goni/goni.c b/board/samsung/goni/goni.c
index c605bf5..28fedb3 100644
--- a/board/samsung/goni/goni.c
+++ b/board/samsung/goni/goni.c
@@ -13,6 +13,9 @@
#include <usb/s3c_udc.h>
#include <asm/arch/cpu.h>
#include <power/max8998_pmic.h>
+#include <usb.h>
+#include <usb_mass_storage.h>
+
DECLARE_GLOBAL_DATA_PTR;
static struct s5pc110_gpio *s5pc110_gpio;
@@ -140,10 +143,81 @@ struct s3c_plat_otg_data s5pc110_otg_data = {
.usb_phy_ctrl = S5PC110_USB_PHY_CONTROL,
};
-void board_usb_init(void)
+int board_usb_init(enum board_usb_init_type what_to_init)
{
debug("USB_udc_probe\n");
s3c_udc_probe(&s5pc110_otg_data);
+ return 0;
+}
+
+#endif
+
+#ifdef CONFIG_USB_GADGET_MASS_STORAGE
+static int ums_read_sector(struct ums_device *ums_dev,
+ ulong start, lbaint_t blkcnt, void *buf)
+{
+ if (ums_dev->mmc->block_dev.block_read(ums_dev->dev_num,
+ start + ums_dev->offset,
+ blkcnt, buf) != blkcnt)
+ return -1;
+
+ return 0;
+}
+
+static int ums_write_sector(struct ums_device *ums_dev,
+ ulong start, lbaint_t blkcnt, const void *buf)
+{
+ if (ums_dev->mmc->block_dev.block_write(ums_dev->dev_num,
+ start + ums_dev->offset,
+ blkcnt, buf) != blkcnt)
+ return -1;
+
+ return 0;
+}
+
+static void ums_get_capacity(struct ums_device *ums_dev,
+ long long int *capacity)
+{
+ long long int tmp_capacity;
+
+ tmp_capacity = (long long int) ((ums_dev->offset + ums_dev->part_size)
+ * SECTOR_SIZE);
+ *capacity = ums_dev->mmc->capacity - tmp_capacity;
+}
+
+static struct ums_board_info ums_board = {
+ .read_sector = ums_read_sector,
+ .write_sector = ums_write_sector,
+ .get_capacity = ums_get_capacity,
+ .name = "GONI UMS disk",
+ .ums_dev = {
+ .mmc = NULL,
+ .dev_num = 0,
+ .offset = 0,
+ .part_size = 0.
+ },
+};
+
+struct ums_board_info *board_ums_init(unsigned int dev_num, unsigned int offset,
+ unsigned int part_size)
+{
+ struct mmc *mmc;
+
+ mmc = find_mmc_device(dev_num);
+ /*
+ * mmc initialization is necessary prior to the ums command usage
+ * due to fact that on goni target environment is read from oneNand
+ * memory, so the mmc remains uninitialized when u-boot prompt appears
+ */
+ if (!mmc || mmc_init(mmc))
+ return NULL;
+
+ ums_board.ums_dev.mmc = mmc;
+ ums_board.ums_dev.dev_num = dev_num;
+ ums_board.ums_dev.offset = offset;
+ ums_board.ums_dev.part_size = part_size;
+
+ return &ums_board;
}
#endif
diff --git a/include/configs/s5p_goni.h b/include/configs/s5p_goni.h
index 192acaa..8014958 100644
--- a/include/configs/s5p_goni.h
+++ b/include/configs/s5p_goni.h
@@ -116,7 +116,7 @@
#define CONFIG_COMMON_BOOT "${console} ${meminfo} ${mtdparts}"
#define CONFIG_BOOTARGS "root=/dev/mtdblock8 ubi.mtd=8 ubi.mtd=3 ubi.mtd=6" \
- " rootfstype=cramfs " CONFIG_COMMON_BOOT
+ " rootfstype=cramfs rootwait " CONFIG_COMMON_BOOT
#define CONFIG_UPDATEB "updateb=onenand erase 0x0 0x100000;" \
" onenand write 0x32008000 0x0 0x100000\0"
@@ -170,15 +170,13 @@
"mmcdev=0\0" \
"mmcbootpart=2\0" \
"mmcrootpart=5\0" \
- "mmcblk=/dev/mmcblk1p1\0" \
+ "partitions=" PARTS_DEFAULT \
"bootblock=9\0" \
"ubiblock=8\0" \
"ubi=enabled\0" \
"opts=always_resume=1\0" \
- "dfu_alt_info=" CONFIG_DFU_ALT
+ "dfu_alt_info=" CONFIG_DFU_ALT "\0"
-
-/* Miscellaneous configurable options */
#define CONFIG_SYS_LONGHELP /* undef to save memory */
#define CONFIG_SYS_HUSH_PARSER /* use "hush" command parser */
#define CONFIG_SYS_PROMPT "Goni # "
@@ -246,5 +244,7 @@
#define CONFIG_USB_GADGET_S3C_UDC_OTG
#define CONFIG_USB_GADGET_DUALSPEED
#define CONFIG_USB_GADGET_VBUS_DRAW 2
+#define CONFIG_CMD_USB_MASS_STORAGE
+#define CONFIG_USB_GADGET_MASS_STORAGE
#endif /* __CONFIG_H */
--
1.8.2.1
More information about the U-Boot
mailing list