From patchwork Tue Oct 18 14:22:55 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?q?=C5=81ukasz_Majewski?= X-Patchwork-Id: 120432 X-Patchwork-Delegate: marek.vasut@gmail.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from theia.denx.de (theia.denx.de [85.214.87.163]) by ozlabs.org (Postfix) with ESMTP id 8592BB71B9 for ; Wed, 19 Oct 2011 01:23:40 +1100 (EST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 85945290F0; Tue, 18 Oct 2011 16:23:34 +0200 (CEST) X-Virus-Scanned: Debian amavisd-new at theia.denx.de Received: from theia.denx.de ([127.0.0.1]) by localhost (theia.denx.de [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id TSa7p-KR4SgR; Tue, 18 Oct 2011 16:23:34 +0200 (CEST) Received: from theia.denx.de (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 37D0E2907C; Tue, 18 Oct 2011 16:23:19 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 373CF28DF4 for ; Tue, 18 Oct 2011 16:23:12 +0200 (CEST) X-Virus-Scanned: Debian amavisd-new at theia.denx.de Received: from theia.denx.de ([127.0.0.1]) by localhost (theia.denx.de [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id ZcBkacBQqNpF for ; Tue, 18 Oct 2011 16:23:08 +0200 (CEST) X-policyd-weight: NOT_IN_SBL_XBL_SPAMHAUS=-1.5 NOT_IN_SPAMCOP=-1.5 NOT_IN_BL_NJABL=-1.5 (only DNSBL check requested) Received: from mailout3.w1.samsung.com (mailout3.w1.samsung.com [210.118.77.13]) by theia.denx.de (Postfix) with ESMTP id 10AC42907C for ; Tue, 18 Oct 2011 16:23:03 +0200 (CEST) MIME-version: 1.0 Received: from euspt2 ([210.118.77.13]) by mailout3.w1.samsung.com (Sun Java(tm) System Messaging Server 6.3-8.04 (built Jul 29 2009; 32bit)) with ESMTP id <0LT9008PDMMCP060@mailout3.w1.samsung.com> for u-boot@lists.denx.de; Tue, 18 Oct 2011 15:23:00 +0100 (BST) Received: from linux.samsung.com ([106.116.38.10]) by spt2.w1.samsung.com (iPlanet Messaging Server 5.2 Patch 2 (built Jul 14 2004)) with ESMTPA id <0LT9001WNMMC0O@spt2.w1.samsung.com> for u-boot@lists.denx.de; Tue, 18 Oct 2011 15:23:00 +0100 (BST) Received: from mcdsrvbld02.digital.local (unknown [106.116.37.23]) by linux.samsung.com (Postfix) with ESMTP id 5366327004D; Tue, 18 Oct 2011 16:27:19 +0200 (CEST) Date: Tue, 18 Oct 2011 16:22:55 +0200 From: Lukasz Majewski In-reply-to: <1318947775-14146-1-git-send-email-l.majewski@samsung.com> To: u-boot@lists.denx.de Message-id: <1318947775-14146-4-git-send-email-l.majewski@samsung.com> X-Mailer: git-send-email 1.7.6.3 References: <1318947775-14146-1-git-send-email-l.majewski@samsung.com> Cc: Minkyu Kang , Kyungmin Park , m.szyprowski@samsung.com Subject: [U-Boot] [PATCH v2 3/3] usb:gadget:s5p Support for USB Mass Storage Gadget at GONI X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.9 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: u-boot-bounces@lists.denx.de Errors-To: u-boot-bounces@lists.denx.de This patch adds support for USB Mass Storage Gadget on the Samsung's GONI reference target Signed-off-by: Lukasz Majewski Signed-off-by: Kyungmin Park Cc: Remy Bohmer Cc: Minkyu Kang Acked-by: Minkyu Kang --- Changes for v2: - #include added for fixing build warning --- board/samsung/goni/goni.c | 69 ++++++++++++++++++++++++++++++++++++++++++++ include/configs/s5p_goni.h | 6 ++++ 2 files changed, 75 insertions(+), 0 deletions(-) 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 #include #include +#include +#include + 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 */