From patchwork Tue Aug 6 10:50:55 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mateusz Zalega X-Patchwork-Id: 265015 X-Patchwork-Delegate: promsoft@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 D843E2C0084 for ; Tue, 6 Aug 2013 21:08:29 +1000 (EST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id CB0BB4A094; Tue, 6 Aug 2013 13:06:59 +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 aB-5FiwDehPG; Tue, 6 Aug 2013 13:06:59 +0200 (CEST) Received: from theia.denx.de (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id E3A804A124; Tue, 6 Aug 2013 13:04:27 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 1F9764A01B for ; Tue, 6 Aug 2013 13:02: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 htFBp2lHWqNL for ; Tue, 6 Aug 2013 13:02:07 +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 mailout2.w1.samsung.com (mailout2.w1.samsung.com [210.118.77.12]) by theia.denx.de (Postfix) with ESMTP id D9DF34A01C for ; Tue, 6 Aug 2013 13:01:52 +0200 (CEST) Received: from eucpsbgm1.samsung.com (unknown [203.254.199.244]) by mailout2.w1.samsung.com (Oracle Communications Messaging Server 7u4-24.01(7.0.4.24.0) 64bit (built Nov 17 2011)) with ESMTP id <0MR300M2CVEJSG70@mailout2.w1.samsung.com> for u-boot@lists.denx.de; Tue, 06 Aug 2013 11:51:40 +0100 (BST) X-AuditID: cbfec7f4-b7f5f6d000000ff6-a1-5200d53c6baf Received: from eusync2.samsung.com ( [203.254.199.212]) by eucpsbgm1.samsung.com (EUCPMTA) with SMTP id 31.E1.04086.C35D0025; Tue, 06 Aug 2013 11:51:40 +0100 (BST) Received: from kernelpanic.DIGITAL.local ([106.120.53.14]) by eusync2.samsung.com (Oracle Communications Messaging Server 7u4-23.01(7.0.4.23.0) 64bit (built Aug 10 2011)) with ESMTPA id <0MR3007NVVI2HX60@eusync2.samsung.com>; Tue, 06 Aug 2013 11:51:40 +0100 (BST) From: Mateusz Zalega To: u-boot@lists.denx.de Date: Tue, 06 Aug 2013 12:50:55 +0200 Message-id: <1375786257-11781-4-git-send-email-m.zalega@samsung.com> X-Mailer: git-send-email 1.8.2.1 In-reply-to: <1375786257-11781-1-git-send-email-m.zalega@samsung.com> References: <1375786257-11781-1-git-send-email-m.zalega@samsung.com> X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFrrDJMWRmVeSWpSXmKPExsVy+t/xK7o2VxmCDJo/M1rc+9fPZHG26Q27 xdx3U5gsOo60MFq83dvJ7sDqcfbODkaPvi2rGAOYorhsUlJzMstSi/TtErgyps56zFJwU7li /a7X7A2MB2W7GDk5JARMJJpmn2CHsMUkLtxbzwZiCwksZZTYutYYwu5nkmj6bAZiswloS9zY Ox+sXkRAQuJX/1XGLkYuDmaBtYwSjdOvgTULC7hJ7Lq4HSjBwcEioCpxbb8fSJhXwEXi3pUm JohdChLHt29jBLE5BVwljp3pY4TY5SIx4/4CxgmMvAsYGVYxiqaWJhcUJ6XnGuoVJ+YWl+al 6yXn525ihITIlx2Mi49ZHWIU4GBU4uFNuPo/UIg1say4MvcQowQHs5IIr8pOhiAh3pTEyqrU ovz4otKc1OJDjEwcnFINjEvO21x97GjFX7tM7t2mma6/3v4OqCww+r3cN7ryJAvPlqWsBxZ8 iLzKZuH+J/uqgsdJ0YoTdyJur1FyyFkUeCFmcncVk+cWuQmTvh9s11lp4ls0c/nsiVLPA2Rv f57meKSu437tY2/GyCdSHQ8XXj2SnSNdstRhhs5Hh5mH93vVy7F942KauFiJpTgj0VCLuag4 EQCIPlDt7wEAAA== X-Mailman-Approved-At: Tue, 06 Aug 2013 13:04:03 +0200 Cc: Arkadiusz Wlodarczyk , Kyungmin Park , Mateusz Zalega Subject: [U-Boot] [PATCH RESEND 3/5] arm:goni: Add support for USB mass storage X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.11 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: u-boot-bounces@lists.denx.de Errors-To: u-boot-bounces@lists.denx.de From: Arkadiusz Wlodarczyk 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 Signed-off-by: Kyungmin Park Signed-off-by: Mateusz Zalega Tested-by: Arkadiusz Wlodarczyk Tested-by: Mateusz Zalega Cc: Minkyu Kang --- 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 #include #include +#include +#include + 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 */