Patchwork [U-Boot,v2,3/3] usb:gadget:s5p Support for USB Mass Storage Gadget at GONI

login
register
mail settings
Submitter Łukasz Majewski
Date Oct. 18, 2011, 2:22 p.m.
Message ID <1318947775-14146-4-git-send-email-l.majewski@samsung.com>
Download mbox | patch
Permalink /patch/120432/
State Superseded
Delegated to: Marek Vasut
Headers show

Comments

Łukasz Majewski - Oct. 18, 2011, 2:22 p.m.
This patch adds support for USB Mass Storage Gadget on the
Samsung's GONI reference target

Signed-off-by: Lukasz Majewski <l.majewski@samsung.com>
Signed-off-by: Kyungmin Park <kyungmin.park@samsung.com>
Cc: Remy Bohmer <linux@bohmer.net>
Cc: Minkyu Kang <mk7.kang@samsung.com>
---
Changes for v2:
	- #include <usb/s3c_udc.h> added for fixing build warning
---
 board/samsung/goni/goni.c  |   69 ++++++++++++++++++++++++++++++++++++++++++++
 include/configs/s5p_goni.h |    6 ++++
 2 files changed, 75 insertions(+), 0 deletions(-)
Remy Bohmer - Nov. 26, 2011, 11:10 p.m.
Hi,

2011/10/18 Lukasz Majewski <l.majewski@samsung.com>:
> This patch adds support for USB Mass Storage Gadget on the
> Samsung's GONI reference target
>
> Signed-off-by: Lukasz Majewski <l.majewski@samsung.com>
> Signed-off-by: Kyungmin Park <kyungmin.park@samsung.com>
> Cc: Remy Bohmer <linux@bohmer.net>
> Cc: Minkyu Kang <mk7.kang@samsung.com>
> ---
> Changes for v2:
>        - #include <usb/s3c_udc.h> added for fixing build warning

Patch does not apply (anymore?) on u-boot-usb. Furthermore, the board
maintainer should ACK this patch.

Kind regards,

Remy
Minkyu Kang - Nov. 28, 2011, 2:13 a.m.
Dear Remy Bohmer,

On 27 November 2011 08:10, Remy Bohmer <linux@bohmer.net> wrote:
> Hi,
>
> 2011/10/18 Lukasz Majewski <l.majewski@samsung.com>:
>> This patch adds support for USB Mass Storage Gadget on the
>> Samsung's GONI reference target
>>
>> Signed-off-by: Lukasz Majewski <l.majewski@samsung.com>
>> Signed-off-by: Kyungmin Park <kyungmin.park@samsung.com>
>> Cc: Remy Bohmer <linux@bohmer.net>
>> Cc: Minkyu Kang <mk7.kang@samsung.com>
>> ---
>> Changes for v2:
>>        - #include <usb/s3c_udc.h> added for fixing build warning
>
> Patch does not apply (anymore?) on u-boot-usb. Furthermore, the board
> maintainer should ACK this patch.
>

Acked-by: Minkyu Kang <mk7.kang@samsung.com>

Thanks

Patch

diff --git a/board/samsung/goni/goni.c b/board/samsung/goni/goni.c
index c4fc3e9..cba4219 100644
--- a/board/samsung/goni/goni.c
+++ b/board/samsung/goni/goni.c
@@ -29,6 +29,9 @@ 
 #include <asm/arch/hs_otg.h>
 #include <asm/arch/cpu.h>
 #include <max8998_pmic.h>
+#include <usb_mass_storage.h>
+#include <usb/s3c_udc.h>
+
 DECLARE_GLOBAL_DATA_PTR;
 
 static struct s5pc110_gpio *s5pc110_gpio;
@@ -145,3 +148,69 @@  struct s3c_plat_otg_data s5pc110_otg_data = {
 	.regs_otg = S5PC110_OTG_BASE,
 };
 #endif
+
+#ifdef CONFIG_USB_GADGET_MASS_STORAGE
+static int ums_read_sector(struct ums_device *ums_dev,
+			   unsigned int n, void *buf)
+{
+	if (ums_dev->mmc->block_dev.block_read(ums_dev->dev_num,
+					      n + ums_dev->offset, 1, buf) != 1)
+		return -1;
+
+	return 0;
+}
+
+static int ums_write_sector(struct ums_device *ums_dev,
+			    unsigned int n, void *buf)
+{
+	if (ums_dev->mmc->block_dev.block_write(ums_dev->dev_num,
+					      n + ums_dev->offset, 1, buf) != 1)
+		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);
+	if (!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;
+
+	/* Init MMC */
+	mmc_init(mmc);
+
+	s3c_udc_probe(&s5pc110_otg_data);
+	return &ums_board;
+}
+#endif
diff --git a/include/configs/s5p_goni.h b/include/configs/s5p_goni.h
index 969e060..53bd79f 100644
--- a/include/configs/s5p_goni.h
+++ b/include/configs/s5p_goni.h
@@ -90,6 +90,8 @@ 
 #define CONFIG_CMD_MTDPARTS
 #define CONFIG_CMD_MMC
 
+#define CONFIG_CMD_USB_MASS_STORAGE
+
 #define CONFIG_BOOTDELAY		1
 #define CONFIG_ZERO_BOOTDELAY_CHECK
 
@@ -244,4 +246,8 @@ 
 #define CONFIG_USB_GADGET_S3C_UDC_OTG	1
 #define CONFIG_USB_GADGET_DUALSPEED	1
 
+#if defined(CONFIG_CMD_USB_MASS_STORAGE)
+#define CONFIG_USB_GADGET_MASS_STORAGE
+#endif
+
 #endif	/* __CONFIG_H */