[U-Boot] [PATCH 3/3] at91, taurus, smartweb: add dfu support

Lukasz Majewski l.majewski at samsung.com
Tue Jul 21 09:02:48 CEST 2015


Hi Heiko,

> [root at pollux dfu-util]# ./src/dfu-util -l
> dfu-util 0.8
> 
> Copyright 2005-2009 Weston Schmidt, Harald Welte and OpenMoko Inc.
> Copyright 2010-2014 Tormod Volden and Stefan Schmidt
> This program is Free Software and has ABSOLUTELY NO WARRANTY
> Please report bugs to dfu-util at lists.gnumonks.org
> 
> Found DFU: [0908:02d2] ver=0212, devnum=119, cfg=1, intf=0, alt=0,
> name="Linux", serial="UNKNOWN" [root at pollux dfu-util]#
> 
> Signed-off-by: Heiko Schocher <hs at denx.de>
> ---
> 
>  board/siemens/smartweb/smartweb.c | 29 +++++++++++++++++++++++++++++
>  board/siemens/taurus/taurus.c     | 27 +++++++++++++++++++++++++++
>  include/configs/smartweb.h        | 34
> ++++++++++++++++++++++++++++++---- include/configs/taurus.h
> | 28 +++++++++++++++++++++++++++- 4 files changed, 113 insertions(+),
> 5 deletions(-)
> 
> diff --git a/board/siemens/smartweb/smartweb.c
> b/board/siemens/smartweb/smartweb.c index cf8a7f5..2d42488 100644
> --- a/board/siemens/smartweb/smartweb.c
> +++ b/board/siemens/smartweb/smartweb.c
> @@ -25,6 +25,7 @@
>  #include <asm/arch/at91_pmc.h>
>  #include <asm/arch/at91_spi.h>
>  #include <spi.h>
> +#include <asm/arch/clk.h>
>  #include <asm/arch/gpio.h>
>  #include <watchdog.h>
>  #ifdef CONFIG_MACB
> @@ -108,6 +109,29 @@ static void smartweb_macb_hw_init(void)
>  }
>  #endif /* CONFIG_MACB */
>  
> +#ifdef CONFIG_USB_GADGET_AT91
> +#include <linux/usb/at91_udc.h>
> +
> +void at91_udp_hw_init(void)
> +{
> +	at91_pmc_t *pmc = (at91_pmc_t *)ATMEL_BASE_PMC;
> +
> +	/* Enable PLLB */
> +	writel(get_pllb_init(), &pmc->pllbr);
> +	while ((readl(&pmc->sr) & AT91_PMC_LOCKB) != AT91_PMC_LOCKB)
> +		;
> +
> +	/* Enable UDPCK clock, MCK is enabled in at91_clock_init() */
> +	at91_periph_clk_enable(ATMEL_ID_UDP);
> +
> +	writel(AT91SAM926x_PMC_UDP, &pmc->scer);
> +}
> +
> +struct at91_udc_data board_udc_data  = {
> +	.baseaddr = ATMEL_BASE_UDP0,
> +};
> +#endif
> +
>  int board_early_init_f(void)
>  {
>  	/* enable this here, as we have SPL without serial support */
> @@ -134,6 +158,11 @@ int board_init(void)
>  	at91_set_gpio_output(AT91_PIN_PC10, 0);
>  	at91_set_gpio_output(AT91_PIN_PC11, 1);
>  
> +#ifdef CONFIG_USB_GADGET_AT91
> +	at91_udp_hw_init();
> +	at91_udc_probe(&board_udc_data);
> +#endif
> +
>  	return 0;
>  }
>  
> diff --git a/board/siemens/taurus/taurus.c
> b/board/siemens/taurus/taurus.c index d10411c..54f67da 100644
> --- a/board/siemens/taurus/taurus.c
> +++ b/board/siemens/taurus/taurus.c
> @@ -272,6 +272,29 @@ void spi_cs_deactivate(struct spi_slave *slave)
>  	at91_set_gpio_value(TAURUS_SPI_CS_PIN, 1);
>  }
>  
> +#ifdef CONFIG_USB_GADGET_AT91
> +#include <linux/usb/at91_udc.h>
> +
> +void at91_udp_hw_init(void)
> +{
> +	at91_pmc_t *pmc = (at91_pmc_t *)ATMEL_BASE_PMC;
> +
> +	/* Enable PLLB */
> +	writel(get_pllb_init(), &pmc->pllbr);
> +	while ((readl(&pmc->sr) & AT91_PMC_LOCKB) != AT91_PMC_LOCKB)
> +		;
> +
> +	/* Enable UDPCK clock, MCK is enabled in at91_clock_init() */
> +	at91_periph_clk_enable(ATMEL_ID_UDP);
> +
> +	writel(AT91SAM926x_PMC_UDP, &pmc->scer);
> +}
> +
> +struct at91_udc_data board_udc_data  = {
> +	.baseaddr = ATMEL_BASE_UDP0,
> +};
> +#endif
> +
>  int board_init(void)
>  {
>  	/* adress of boot parameters */
> @@ -284,6 +307,10 @@ int board_init(void)
>  	taurus_macb_hw_init();
>  #endif
>  	at91_spi0_hw_init(TAURUS_SPI_MASK);
> +#ifdef CONFIG_USB_GADGET_AT91
> +	at91_udp_hw_init();
> +	at91_udc_probe(&board_udc_data);
> +#endif
>  
>  	return 0;
>  }
> diff --git a/include/configs/smartweb.h b/include/configs/smartweb.h
> index 9f22139..baec73b 100644
> --- a/include/configs/smartweb.h
> +++ b/include/configs/smartweb.h
> @@ -75,7 +75,7 @@
>  
>  /* Size of malloc() pool */
>  #define CONFIG_SYS_MALLOC_LEN \
> -	ROUND(3 * CONFIG_ENV_SIZE + (128 << 10), 0x1000)
> +	ROUND(3 * CONFIG_ENV_SIZE + 4*1024*1024, 0x1000)
>  
>  /* NAND flash settings */
>  #define CONFIG_NAND_ATMEL
> @@ -140,15 +140,42 @@
>  
>  #if !defined(CONFIG_SPL_BUILD)
>  /* USB configuration */
> +#define CONFIG_CMD_USB
>  #define CONFIG_USB_ATMEL
>  #define CONFIG_USB_ATMEL_CLK_SEL_PLLB
>  #define CONFIG_USB_OHCI_NEW
> -#define CONFIG_USB_STORAGE
> -#define CONFIG_DOS_PARTITION
>  #define CONFIG_SYS_USB_OHCI_CPU_INIT
>  #define CONFIG_SYS_USB_OHCI_REGS_BASE	ATMEL_UHP_BASE
>  #define CONFIG_SYS_USB_OHCI_SLOT_NAME	"at91sam9260"
>  #define CONFIG_SYS_USB_OHCI_MAX_ROOT_PORTS	2
> +
> +#define CONFIG_USB_HOST_ETHER
> +#define CONFIG_USB_ETHER_ASIX
> +#define CONFIG_USB_ETHER_MCS7830
> +
> +/* USB DFU support */
> +#define CONFIG_CMD_MTDPARTS
> +#define CONFIG_MTD_DEVICE
> +#define CONFIG_MTD_PARTITIONS
> +
> +#define CONFIG_USB_GADGET
> +#define CONFIG_USB_GADGET_AT91
> +
> +/* DFU class support */
> +#define CONFIG_CMD_DFU
> +#define CONFIG_DFU_FUNCTION
> +#define CONFIG_DFU_NAND
> +#define CONFIG_USBDOWNLOAD_GADGET
> +#define CONFIG_USB_GADGET_VBUS_DRAW	2
> +#define CONFIG_SYS_DFU_DATA_BUF_SIZE	(1 << 20)
> +#define DFU_MANIFEST_POLL_TIMEOUT	25000
> +
> +/* USB DFU IDs */
> +#define CONFIG_G_DNL_VENDOR_NUM 0x0908
> +#define CONFIG_G_DNL_PRODUCT_NUM 0x02d2
> +#define CONFIG_G_DNL_MANUFACTURER "Siemens AG"
> +
> +#define CONFIG_SYS_CACHELINE_SIZE	0x2000
>  #endif
>  
>  /* General Boot Parameter */
> @@ -195,7 +222,6 @@
>  #undef CONFIG_CMD_LOADS
>  
>  #define CONFIG_CMD_NAND
> -#define CONFIG_CMD_USB
>  #define CONFIG_CMD_FAT
>  
>  #ifdef CONFIG_MACB
> diff --git a/include/configs/taurus.h b/include/configs/taurus.h
> index dd35a8f..99cf302 100644
> --- a/include/configs/taurus.h
> +++ b/include/configs/taurus.h
> @@ -128,12 +128,38 @@
>  /* USB */
>  #if defined(CONFIG_BOARD_TAURUS)
>  #define CONFIG_USB_ATMEL
> +#define CONFIG_USB_ATMEL_CLK_SEL_PLLB
>  #define CONFIG_USB_OHCI_NEW
>  #define CONFIG_SYS_USB_OHCI_CPU_INIT
>  #define CONFIG_SYS_USB_OHCI_REGS_BASE		0x00500000
>  #define CONFIG_SYS_USB_OHCI_SLOT_NAME		"at91sam9260"
>  #define CONFIG_SYS_USB_OHCI_MAX_ROOT_PORTS	2
>  #define CONFIG_USB_STORAGE
> +
> +/* USB DFU support */
> +#define CONFIG_CMD_MTDPARTS
> +#define CONFIG_MTD_DEVICE
> +#define CONFIG_MTD_PARTITIONS
> +
> +#define CONFIG_USB_GADGET
> +#define CONFIG_USB_GADGET_AT91
> +
> +/* DFU class support */
> +#define CONFIG_CMD_USB
> +#define CONFIG_CMD_DFU
> +#define CONFIG_DFU_FUNCTION
> +#define CONFIG_DFU_NAND
> +#define CONFIG_USBDOWNLOAD_GADGET
> +#define CONFIG_USB_GADGET_VBUS_DRAW	2
> +#define CONFIG_SYS_DFU_DATA_BUF_SIZE	(1 << 20)
					^^^^^^^^^ Here you can use SZ_1M
Please correct other places where you can replace (1 << X) with
SZ_X.	

> +#define DFU_MANIFEST_POLL_TIMEOUT	25000
> +
> +/* USB DFU IDs */
> +#define CONFIG_G_DNL_VENDOR_NUM 0x0908
> +#define CONFIG_G_DNL_PRODUCT_NUM 0x02d2
> +#define CONFIG_G_DNL_MANUFACTURER "Siemens AG"
> +
> +#define CONFIG_SYS_CACHELINE_SIZE	0x2000
>  #endif
>  
>  /* SPI EEPROM */
> @@ -251,7 +277,7 @@
>   * Size of malloc() pool
>   */
>  #define CONFIG_SYS_MALLOC_LEN \
> -	ROUND(3 * CONFIG_ENV_SIZE + 128*1024, 0x1000)
> +	ROUND(3 * CONFIG_ENV_SIZE + 4*1024*1024, 0x1000)
>  
>  /* Defines for SPL */
>  #define CONFIG_SPL_FRAMEWORK



-- 
Best regards,

Lukasz Majewski

Samsung R&D Institute Poland (SRPOL) | Linux Platform Group


More information about the U-Boot mailing list