All of lore.kernel.org
 help / color / mirror / Atom feed
From: Lukasz Majewski <l.majewski@samsung.com>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH v2 5/5] usb:gadget:s5p Support for USB Mass Storage Gadget on GONI
Date: Wed, 13 Jul 2011 16:29:52 +0200	[thread overview]
Message-ID: <1310567392-29082-6-git-send-email-l.majewski@samsung.com> (raw)
In-Reply-To: <1310567392-29082-1-git-send-email-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>
---
 board/samsung/goni/goni.c  |   68 ++++++++++++++++++++++++++++++++++++++++++++
 include/configs/s5p_goni.h |    6 ++++
 2 files changed, 74 insertions(+), 0 deletions(-)

diff --git a/board/samsung/goni/goni.c b/board/samsung/goni/goni.c
index 2935bd7..469b1e8 100644
--- a/board/samsung/goni/goni.c
+++ b/board/samsung/goni/goni.c
@@ -29,6 +29,8 @@
 #include <asm/arch/hs_otg.h>
 #include <asm/arch/cpu.h>
 
+#include <usb_mass_storage.h>
+
 DECLARE_GLOBAL_DATA_PTR;
 
 static struct s5pc110_gpio *s5pc110_gpio;
@@ -220,3 +222,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 a47d0b4..8a7bed3 100644
--- a/include/configs/s5p_goni.h
+++ b/include/configs/s5p_goni.h
@@ -91,6 +91,8 @@
 #define CONFIG_CMD_MTDPARTS
 #define CONFIG_CMD_MMC
 
+#define CONFIG_CMD_USB_MASS_STORAGE
+
 #define CONFIG_BOOTDELAY		1
 #define CONFIG_ZERO_BOOTDELAY_CHECK
 
@@ -241,4 +243,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 */
-- 
1.7.2.3

      parent reply	other threads:[~2011-07-13 14:29 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-07-13 14:29 [U-Boot] [PATCH v2 0/5] usb:gadget USB Gadget support Lukasz Majewski
2011-07-13 14:29 ` [U-Boot] [PATCH v2 1/5] usb:gadget:s5p USB Device Controller (UDC) implementation Lukasz Majewski
2011-07-13 14:43   ` Vitaly Kuzmichev
2011-07-14  8:14   ` [U-Boot] [RESEND PATCH " Lukasz Majewski
2011-10-06 22:10   ` [U-Boot] [PATCH " Wolfgang Denk
2011-10-07  7:39     ` Lukasz Majewski
2011-10-09 19:43       ` Wolfgang Denk
2011-10-10 20:00         ` Scott Wood
2011-10-10 20:38           ` Wolfgang Denk
2011-10-10 20:55             ` Scott Wood
2011-10-10 21:54               ` Wolfgang Denk
2011-10-10 22:00                 ` Scott Wood
2011-07-13 14:29 ` [U-Boot] [PATCH v2 2/5] usb:gadget:s5p Enabling the USB Gadget framework at GONI Lukasz Majewski
2011-07-13 14:29 ` [U-Boot] [PATCH v2 3/5] usb:gadget: USB Mass Storage - files from Linux kernel Lukasz Majewski
2011-10-06 22:10   ` Wolfgang Denk
2011-10-07  7:28     ` Lukasz Majewski
2011-10-07  8:25       ` Wolfgang Denk
2011-07-13 14:29 ` [U-Boot] [PATCH v2 4/5] usb:gadget: USB Mass Storage Gadget support Lukasz Majewski
2011-07-13 14:29 ` Lukasz Majewski [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1310567392-29082-6-git-send-email-l.majewski@samsung.com \
    --to=l.majewski@samsung.com \
    --cc=u-boot@lists.denx.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.