Patchwork [U-Boot,v4,2/2] arm:goni:dfu Add support for DFU at GONI target

login
register
mail settings
Submitter Mateusz Zalega
Date Oct. 14, 2013, 4:56 p.m.
Message ID <1381769774-10975-2-git-send-email-m.zalega@samsung.com>
Download mbox | patch
Permalink /patch/283354/
State Changes Requested
Delegated to: Minkyu Kang
Headers show

Comments

Mateusz Zalega - Oct. 14, 2013, 4:56 p.m.
From: Arkadiusz Wlodarczyk <a.wlodarczyk@samsung.com>

Proper adjustment for supporting DFU at GONI target has been made.
The s5p_goni.h file has been updated. Moreover the code for low level
USB initialization has been added to GONI board code.

The malloc pool has been enlarged in order to support larger buffer
sizes needed by DFU implementation.

Change-Id: I1b4953368176e8a7588abb0da37de6321f835698
Signed-off-by: Arkadiusz Wlodarczyk <a.wlodarczyk@samsung.com>
Signed-off-by: Kyungmin Park <kyungmin.park@samsung.com>
Signed-off-by: Mateusz Zalega <m.zalega@samsung.com>
Tested-by: Arkadiusz Wlodarczyk <a.wlodarczyk@samsung.com>
Tested-by: Mateusz Zalega <m.zalega@samsung.com>
Cc: Minkyu Kang <mk7.kang@samsung.com>
---
Changes since v3:
- adjusted to match recently accepted USB patches
---
 board/samsung/goni/goni.c  | 80 ++++++++++++++++++++++++++++++++++++++++++++++
 include/configs/s5p_goni.h | 69 ++++++++++++++++++++++++++-------------
 2 files changed, 127 insertions(+), 22 deletions(-)
Przemyslaw Marczak - Oct. 15, 2013, 7:23 p.m.
Hello Mateusz,

On 10/14/2013 06:56 PM, Mateusz Zalega wrote:
> From: Arkadiusz Wlodarczyk <a.wlodarczyk@samsung.com>
>
> Proper adjustment for supporting DFU at GONI target has been made.
> The s5p_goni.h file has been updated. Moreover the code for low level
> USB initialization has been added to GONI board code.
>
> The malloc pool has been enlarged in order to support larger buffer
> sizes needed by DFU implementation.
>
> Change-Id: I1b4953368176e8a7588abb0da37de6321f835698
> Signed-off-by: Arkadiusz Wlodarczyk <a.wlodarczyk@samsung.com>
> Signed-off-by: Kyungmin Park <kyungmin.park@samsung.com>
> Signed-off-by: Mateusz Zalega <m.zalega@samsung.com>
> Tested-by: Arkadiusz Wlodarczyk <a.wlodarczyk@samsung.com>
> Tested-by: Mateusz Zalega <m.zalega@samsung.com>
> Cc: Minkyu Kang <mk7.kang@samsung.com>
> ---
> Changes since v3:
> - adjusted to match recently accepted USB patches
> ---


> +int board_usb_init(int index, enum board_usb_init_type init)
> +{
> +	debug("USB_udc_probe\n");
> +	s3c_udc_probe(&s5pc110_otg_data);
> +	return 0;
> +}
> +#endif
> +

----- starting from this line of your patch

> +#ifdef CONFIG_USB_GADGET_MASS_STORAGE
> +static int ums_read_sector(struct ums_device *ums_dev,
> +				ulong start, lbaint_t blkcnt, void *buf)


----- with all these lines inside...


> +	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

----- end this line

Will be not needed, because I would like to move ums initialization code 
to Samsung common directory.
Could you wait with this patch please or just don't enable this feature 
on goni at this time? Other way I have to remove those lines in my patch 
set which I'm gonna send tomorrow.


After my ums refactoring patch set this two below lines will be enought 
to enable UMS on goni without ums init code and only with board usb init.

> +#define CONFIG_CMD_USB_MASS_STORAGE
> +#define CONFIG_USB_GADGET_MASS_STORAGE
>
>   #endif	/* __CONFIG_H */
>

Thank you,

Patch

diff --git a/board/samsung/goni/goni.c b/board/samsung/goni/goni.c
index 366f648..3a2f686 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;
@@ -172,4 +175,81 @@  struct s3c_plat_otg_data s5pc110_otg_data = {
 	.regs_otg = S5PC110_OTG_BASE,
 	.usb_phy_ctrl = S5PC110_USB_PHY_CONTROL,
 };
+
+int board_usb_init(int index, enum board_usb_init_type 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 fd441c8..218cf3d 100644
--- a/include/configs/s5p_goni.h
+++ b/include/configs/s5p_goni.h
@@ -41,7 +41,7 @@ 
  * Size of malloc() pool
  * 1MB = 0x100000, 0x100000 = 1024 * 1024
  */
-#define CONFIG_SYS_MALLOC_LEN		(CONFIG_ENV_SIZE + (1 << 20))
+#define CONFIG_SYS_MALLOC_LEN		(CONFIG_ENV_SIZE + (16 << 20))
 /*
  * select serial console configuration
  */
@@ -71,28 +71,46 @@ 
 #define CONFIG_CMD_CACHE
 #define CONFIG_CMD_REGINFO
 #define CONFIG_CMD_ONENAND
-#define CONFIG_CMD_MTDPARTS
 #define CONFIG_CMD_MMC
+#define CONFIG_CMD_DFU
+#define CONFIG_CMD_GPT
 
-#define CONFIG_BOOTDELAY		1
-#define CONFIG_ZERO_BOOTDELAY_CHECK
+/* USB Composite download gadget - g_dnl */
+#define CONFIG_USBDOWNLOAD_GADGET
+#define CONFIG_DFU_FUNCTION
+#define CONFIG_DFU_MMC
 
-#define CONFIG_MTD_DEVICE
-#define CONFIG_MTD_PARTITIONS
+/* USB Samsung's IDs */
+#define CONFIG_G_DNL_VENDOR_NUM 0x04E8
+#define CONFIG_G_DNL_PRODUCT_NUM 0x6601
+#define CONFIG_G_DNL_MANUFACTURER "Samsung"
 
-/* Actual modem binary size is 16MiB. Add 2MiB for bad block handling */
-#define MTDIDS_DEFAULT		"onenand0=samsung-onenand"
-#define MTDPARTS_DEFAULT	"mtdparts=samsung-onenand:1m(bootloader)"\
-				",256k(params)"\
-				",2816k(config)"\
-				",8m(csa)"\
-				",7m(kernel)"\
-				",1m(log)"\
-				",12m(modem)"\
-				",60m(qboot)"\
-				",-(UBI)\0"
+#define CONFIG_BOOTDELAY		1
+#define CONFIG_ZERO_BOOTDELAY_CHECK
 
-#define NORMAL_MTDPARTS_DEFAULT MTDPARTS_DEFAULT
+#define CONFIG_DFU_ALT \
+	"u-boot mmc 80 400;" \
+	"uImage fat 0 2\0" \
+
+/* partitions definitions */
+#define PARTS_CSA			"csa-mmc"
+#define PARTS_BOOTLOADER	"u-boot"
+#define PARTS_BOOT			"boot"
+#define PARTS_ROOT			"platform"
+#define PARTS_DATA			"data"
+#define PARTS_CSC			"csc"
+#define PARTS_UMS			"ums"
+
+#define PARTS_DEFAULT \
+	"uuid_disk=${uuid_gpt_disk};" \
+	"name="PARTS_CSA",size=8MiB,uuid=${uuid_gpt_"PARTS_CSA"};" \
+	"name="PARTS_BOOTLOADER",size=60MiB," \
+	"uuid=${uuid_gpt_"PARTS_BOOTLOADER"};" \
+	"name="PARTS_BOOT",size=100MiB,uuid=${uuid_gpt_"PARTS_BOOT"};" \
+	"name="PARTS_ROOT",size=1GiB,uuid=${uuid_gpt_"PARTS_ROOT"};" \
+	"name="PARTS_DATA",size=3GiB,uuid=${uuid_gpt_"PARTS_DATA"};" \
+	"name="PARTS_CSC",size=150MiB,uuid=${uuid_gpt_"PARTS_CSC"};" \
+	"name="PARTS_UMS",size=-,uuid=${uuid_gpt_"PARTS_UMS"}\0" \
 
 #define CONFIG_BOOTCOMMAND	"run mmcboot"
 
@@ -104,7 +122,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"
@@ -152,19 +170,19 @@ 
 	"verify=n\0" \
 	"rootfstype=ext4\0" \
 	"console=" CONFIG_DEFAULT_CONSOLE \
-	"mtdparts=" MTDPARTS_DEFAULT \
 	"meminfo=mem=80M mem=256M@0x40000000 mem=128M@0x50000000\0" \
 	"loaduimage=fatload mmc ${mmcdev}:${mmcbootpart} 0x30007FC0 uImage\0" \
 	"mmcdev=0\0" \
 	"mmcbootpart=2\0" \
 	"mmcrootpart=5\0" \
+	"partitions=" PARTS_DEFAULT \
 	"mmcblk=/dev/mmcblk1p1\0" \
 	"bootblock=9\0" \
 	"ubiblock=8\0" \
 	"ubi=enabled\0" \
-	"opts=always_resume=1"
+	"opts=always_resume=1\0" \
+	"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 # "
@@ -208,6 +226,10 @@ 
 #define CONFIG_CMD_EXT4
 #define CONFIG_FAT_WRITE
 
+/* GPT */
+#define CONFIG_EFI_PARTITION
+#define CONFIG_PARTITION_UUIDS
+
 #define CONFIG_SYS_INIT_SP_ADDR	(CONFIG_SYS_LOAD_ADDR - 0x1000000)
 
 #define CONFIG_SYS_CACHELINE_SIZE       64
@@ -232,5 +254,8 @@ 
 #define CONFIG_USB_GADGET
 #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 */