[U-Boot] [PATCH 0/4] rockchip: rk3288: add fastboot support

Hi,
This short series add the fastboot support for rk3288, and I have tested on firefly-rk3288 board.
I encounter an odd issue while debugging usb-otg ep2out-bulk data transfer. The buffer was always zero which mapped to DMA buffer, even though driver call invalidate_dcache_range() to make sure the cpu read memroy data directly. IMHO, dcache was abnormal after something initialization code. Everything work fine without CONFIG_EFI_LOADER. Moreover, invalidate_icache_all cause the issue. I'm not able to figure out why and explain it. But I think there is no need to enable EFI applications on rk3288 platform.
Ziyuan Xu (4): usb: phy: implement usb-otg phy control for rk3288 usb: dwc2-otg: redefine fifo-size for rk3288 rockchip: rk3288: add fastboot support rockchip: firefly-rk3288: undef CONFIG_EFI_LOADER
arch/arm/mach-rockchip/board.c | 20 ++++++++++++++++++++ configs/firefly-rk3288_defconfig | 1 + drivers/usb/gadget/dwc2_udc_otg_regs.h | 6 ++++++ drivers/usb/phy/Makefile | 1 + drivers/usb/phy/rk3288_usb_phy.c | 29 +++++++++++++++++++++++++++++ include/configs/rk3288_common.h | 25 +++++++++++++++++++++++++ 6 files changed, 82 insertions(+) create mode 100644 drivers/usb/phy/rk3288_usb_phy.c

Apply dwc2 usb driver framework to implement phy_init and phy_off, and enable it with CONFIG_RK3288_USB_PHY.
Signed-off-by: Ziyuan Xu xzy.xu@rock-chips.com ---
drivers/usb/phy/Makefile | 1 + drivers/usb/phy/rk3288_usb_phy.c | 29 +++++++++++++++++++++++++++++ 2 files changed, 30 insertions(+) create mode 100644 drivers/usb/phy/rk3288_usb_phy.c
diff --git a/drivers/usb/phy/Makefile b/drivers/usb/phy/Makefile index 93d147e..d52c42a 100644 --- a/drivers/usb/phy/Makefile +++ b/drivers/usb/phy/Makefile @@ -7,3 +7,4 @@
obj-$(CONFIG_TWL4030_USB) += twl4030.o obj-$(CONFIG_OMAP_USB_PHY) += omap_usb_phy.o +obj-$(CONFIG_RK3288_USB_PHY) += rk3288_usb_phy.o diff --git a/drivers/usb/phy/rk3288_usb_phy.c b/drivers/usb/phy/rk3288_usb_phy.c new file mode 100644 index 0000000..de05d4e --- /dev/null +++ b/drivers/usb/phy/rk3288_usb_phy.c @@ -0,0 +1,29 @@ +/* + * Copyright 2016 Rockchip Electronics Co., Ltd + * + * SPDX-License-Identifier: GPL-2.0+ + */ + +#include <common.h> +#include <asm/io.h> + +#include "../gadget/dwc2_udc_otg_priv.h" + +#define GRF_UOC0_CON0 0x320 +#define SIDDQ_WRITE_ENA BIT(29) +#define SIDDQ_ON BIT(13) +#define SIDDQ_OFF (0 << 13) + +void otg_phy_init(struct dwc2_udc *dev) +{ + /* power up usb phy analog blocks by set siddq 0 */ + writel(SIDDQ_WRITE_ENA | SIDDQ_OFF, + dev->pdata->regs_phy + GRF_UOC0_CON0); +} + +void otg_phy_off(struct dwc2_udc *dev) +{ + /* power down usb phy analog blocks by set siddq 1 */ + writel(SIDDQ_WRITE_ENA | SIDDQ_ON, + dev->pdata->regs_phy + GRF_UOC0_CON0); +}

+Marek
On 30 June 2016 at 00:21, Ziyuan Xu xzy.xu@rock-chips.com wrote:
Apply dwc2 usb driver framework to implement phy_init and phy_off, and enable it with CONFIG_RK3288_USB_PHY.
Signed-off-by: Ziyuan Xu xzy.xu@rock-chips.com
drivers/usb/phy/Makefile | 1 + drivers/usb/phy/rk3288_usb_phy.c | 29 +++++++++++++++++++++++++++++ 2 files changed, 30 insertions(+) create mode 100644 drivers/usb/phy/rk3288_usb_phy.c
Reviewed-by: Simon Glass sjg@chromium.org

Redefine RX FIFO size & TX FIFO size for rk3288.
Signed-off-by: Ziyuan Xu xzy.xu@rock-chips.com ---
drivers/usb/gadget/dwc2_udc_otg_regs.h | 6 ++++++ 1 file changed, 6 insertions(+)
diff --git a/drivers/usb/gadget/dwc2_udc_otg_regs.h b/drivers/usb/gadget/dwc2_udc_otg_regs.h index 78ec90e..a0617c8 100644 --- a/drivers/usb/gadget/dwc2_udc_otg_regs.h +++ b/drivers/usb/gadget/dwc2_udc_otg_regs.h @@ -130,8 +130,14 @@ struct dwc2_usbotg_reg { #define HIGH_SPEED_CONTROL_PKT_SIZE 64 #define HIGH_SPEED_BULK_PKT_SIZE 512
+#ifdef CONFIG_ROCKCHIP_RK3288 +#define RX_FIFO_SIZE (275*4) +#define NPTX_FIFO_SIZE (16*4) +#else #define RX_FIFO_SIZE (1024*4) #define NPTX_FIFO_SIZE (1024*4) +#endif + #define PTX_FIFO_SIZE (1536*1)
#define DEPCTL_TXFNUM_0 (0x0<<22)

Hi Ziyuan,
On 30 June 2016 at 00:21, Ziyuan Xu xzy.xu@rock-chips.com wrote:
Redefine RX FIFO size & TX FIFO size for rk3288.
Signed-off-by: Ziyuan Xu xzy.xu@rock-chips.com
drivers/usb/gadget/dwc2_udc_otg_regs.h | 6 ++++++ 1 file changed, 6 insertions(+)
diff --git a/drivers/usb/gadget/dwc2_udc_otg_regs.h b/drivers/usb/gadget/dwc2_udc_otg_regs.h index 78ec90e..a0617c8 100644 --- a/drivers/usb/gadget/dwc2_udc_otg_regs.h +++ b/drivers/usb/gadget/dwc2_udc_otg_regs.h @@ -130,8 +130,14 @@ struct dwc2_usbotg_reg { #define HIGH_SPEED_CONTROL_PKT_SIZE 64 #define HIGH_SPEED_BULK_PKT_SIZE 512
+#ifdef CONFIG_ROCKCHIP_RK3288 +#define RX_FIFO_SIZE (275*4) +#define NPTX_FIFO_SIZE (16*4) +#else #define RX_FIFO_SIZE (1024*4) #define NPTX_FIFO_SIZE (1024*4) +#endif
I cannot see where this is used. Can you explain? Also can you add a reason for the change in your commit message?
#define PTX_FIFO_SIZE (1536*1)
#define DEPCTL_TXFNUM_0 (0x0<<22)
1.9.1
Regards, Simon

hi simon,
On 2016年06月30日 23:23, Simon Glass wrote:
Hi Ziyuan,
On 30 June 2016 at 00:21, Ziyuan Xu xzy.xu@rock-chips.com wrote:
Redefine RX FIFO size & TX FIFO size for rk3288.
Signed-off-by: Ziyuan Xu xzy.xu@rock-chips.com
drivers/usb/gadget/dwc2_udc_otg_regs.h | 6 ++++++ 1 file changed, 6 insertions(+)
diff --git a/drivers/usb/gadget/dwc2_udc_otg_regs.h b/drivers/usb/gadget/dwc2_udc_otg_regs.h index 78ec90e..a0617c8 100644 --- a/drivers/usb/gadget/dwc2_udc_otg_regs.h +++ b/drivers/usb/gadget/dwc2_udc_otg_regs.h @@ -130,8 +130,14 @@ struct dwc2_usbotg_reg { #define HIGH_SPEED_CONTROL_PKT_SIZE 64 #define HIGH_SPEED_BULK_PKT_SIZE 512
+#ifdef CONFIG_ROCKCHIP_RK3288 +#define RX_FIFO_SIZE (275*4) +#define NPTX_FIFO_SIZE (16*4) +#else #define RX_FIFO_SIZE (1024*4) #define NPTX_FIFO_SIZE (1024*4) +#endif
I cannot see where this is used. Can you explain? Also can you add a reason for the change in your commit message?
Both RX_FIFO_SIZE and NPTX_FIFO_SIZE are used in dwc2_udc_otg.c::reconfig_usbd() for fifo configuration. We need to redefine properly for rk3288 soc.
#define PTX_FIFO_SIZE (1536*1)
#define DEPCTL_TXFNUM_0 (0x0<<22)
-- 1.9.1
Regards, Simon

Hi Simon,
On 2016年06月30日 23:23, Simon Glass wrote:
Hi Ziyuan,
On 30 June 2016 at 00:21, Ziyuan Xu xzy.xu@rock-chips.com wrote:
Redefine RX FIFO size & TX FIFO size for rk3288.
Signed-off-by: Ziyuan Xu xzy.xu@rock-chips.com
drivers/usb/gadget/dwc2_udc_otg_regs.h | 6 ++++++ 1 file changed, 6 insertions(+)
diff --git a/drivers/usb/gadget/dwc2_udc_otg_regs.h b/drivers/usb/gadget/dwc2_udc_otg_regs.h index 78ec90e..a0617c8 100644 --- a/drivers/usb/gadget/dwc2_udc_otg_regs.h +++ b/drivers/usb/gadget/dwc2_udc_otg_regs.h @@ -130,8 +130,14 @@ struct dwc2_usbotg_reg { #define HIGH_SPEED_CONTROL_PKT_SIZE 64 #define HIGH_SPEED_BULK_PKT_SIZE 512
+#ifdef CONFIG_ROCKCHIP_RK3288 +#define RX_FIFO_SIZE (275*4) +#define NPTX_FIFO_SIZE (16*4) +#else #define RX_FIFO_SIZE (1024*4) #define NPTX_FIFO_SIZE (1024*4) +#endif
I cannot see where this is used. Can you explain? Also can you add a reason for the change in your commit message?
The total FIFO size of dwc2 on Rockchip SoCs is shorter than the existent, so redefined them to fit Rockchip SoCs.
#define PTX_FIFO_SIZE (1536*1)
#define DEPCTL_TXFNUM_0 (0x0<<22)
-- 1.9.1
Regards, Simon

Hi,
On 30 June 2016 at 23:00, Ziyuan Xu xzy.xu@rock-chips.com wrote:
Hi Simon,
On 2016年06月30日 23:23, Simon Glass wrote:
Hi Ziyuan,
On 30 June 2016 at 00:21, Ziyuan Xu xzy.xu@rock-chips.com wrote:
Redefine RX FIFO size & TX FIFO size for rk3288.
Signed-off-by: Ziyuan Xu xzy.xu@rock-chips.com
drivers/usb/gadget/dwc2_udc_otg_regs.h | 6 ++++++ 1 file changed, 6 insertions(+)
diff --git a/drivers/usb/gadget/dwc2_udc_otg_regs.h b/drivers/usb/gadget/dwc2_udc_otg_regs.h index 78ec90e..a0617c8 100644 --- a/drivers/usb/gadget/dwc2_udc_otg_regs.h +++ b/drivers/usb/gadget/dwc2_udc_otg_regs.h @@ -130,8 +130,14 @@ struct dwc2_usbotg_reg { #define HIGH_SPEED_CONTROL_PKT_SIZE 64 #define HIGH_SPEED_BULK_PKT_SIZE 512
+#ifdef CONFIG_ROCKCHIP_RK3288 +#define RX_FIFO_SIZE (275*4) +#define NPTX_FIFO_SIZE (16*4) +#else #define RX_FIFO_SIZE (1024*4) #define NPTX_FIFO_SIZE (1024*4) +#endif
I cannot see where this is used. Can you explain? Also can you add a reason for the change in your commit message?
The total FIFO size of dwc2 on Rockchip SoCs is shorter than the existent, so redefined them to fit Rockchip SoCs.
$ git grep RX_FIFO_SIZE drivers/i2c/kona_i2c.c:#define MAX_RX_FIFO_SIZE 64U /* bytes */ drivers/i2c/kona_i2c.c: unsigned int bytes_to_read = MAX_RX_FIFO_SIZE; drivers/i2c/kona_i2c.c: if (msg->len - bytes_read <= MAX_RX_FIFO_SIZE) { drivers/usb/gadget/dwc2_udc_otg.c: writel(RX_FIFO_SIZE >> 2, ®->grxfsiz); drivers/usb/gadget/dwc2_udc_otg.c: writel((NPTX_FIFO_SIZE >> 2) << 16 | ((RX_FIFO_SIZE >> 2)) << 0, drivers/usb/gadget/dwc2_udc_otg.c: ((RX_FIFO_SIZE + NPTX_FIFO_SIZE + drivers/usb/gadget/dwc2_udc_otg_regs.h:#define RX_FIFO_SIZE (1024*4) drivers/usb/host/dwc2.c: writel(CONFIG_DWC2_HOST_RX_FIFO_SIZE, ®s->grxfsiz); drivers/usb/host/dwc2.c: nptxfifosize |= CONFIG_DWC2_HOST_RX_FIFO_SIZE << drivers/usb/host/dwc2.c: ptxfifosize |= (CONFIG_DWC2_HOST_RX_FIFO_SIZE + drivers/usb/host/dwc2.h:#define CONFIG_DWC2_HOST_RX_FIFO_SIZE (516 + CONFIG_DWC2_MAX_CHANNELS)
If we need a Rockchip-specific value for this then it should go in Kconfig or device tree.
#define PTX_FIFO_SIZE (1536*1)
#define DEPCTL_TXFNUM_0 (0x0<<22)
-- 1.9.1
Regards, Simon

Hi Simon,
On 2016年07月01日 23:15, Simon Glass wrote:
Hi,
On 30 June 2016 at 23:00, Ziyuan Xu xzy.xu@rock-chips.com wrote:
Hi Simon,
On 2016年06月30日 23:23, Simon Glass wrote:
Hi Ziyuan,
On 30 June 2016 at 00:21, Ziyuan Xu xzy.xu@rock-chips.com wrote:
Redefine RX FIFO size & TX FIFO size for rk3288.
Signed-off-by: Ziyuan Xu xzy.xu@rock-chips.com
drivers/usb/gadget/dwc2_udc_otg_regs.h | 6 ++++++ 1 file changed, 6 insertions(+)
diff --git a/drivers/usb/gadget/dwc2_udc_otg_regs.h b/drivers/usb/gadget/dwc2_udc_otg_regs.h index 78ec90e..a0617c8 100644 --- a/drivers/usb/gadget/dwc2_udc_otg_regs.h +++ b/drivers/usb/gadget/dwc2_udc_otg_regs.h @@ -130,8 +130,14 @@ struct dwc2_usbotg_reg { #define HIGH_SPEED_CONTROL_PKT_SIZE 64 #define HIGH_SPEED_BULK_PKT_SIZE 512
+#ifdef CONFIG_ROCKCHIP_RK3288 +#define RX_FIFO_SIZE (275*4) +#define NPTX_FIFO_SIZE (16*4) +#else #define RX_FIFO_SIZE (1024*4) #define NPTX_FIFO_SIZE (1024*4) +#endif
I cannot see where this is used. Can you explain? Also can you add a reason for the change in your commit message?
The total FIFO size of dwc2 on Rockchip SoCs is shorter than the existent, so redefined them to fit Rockchip SoCs.
$ git grep RX_FIFO_SIZE drivers/i2c/kona_i2c.c:#define MAX_RX_FIFO_SIZE 64U /* bytes */ drivers/i2c/kona_i2c.c: unsigned int bytes_to_read = MAX_RX_FIFO_SIZE; drivers/i2c/kona_i2c.c: if (msg->len - bytes_read <= MAX_RX_FIFO_SIZE) { drivers/usb/gadget/dwc2_udc_otg.c: writel(RX_FIFO_SIZE >> 2, ®->grxfsiz); drivers/usb/gadget/dwc2_udc_otg.c: writel((NPTX_FIFO_SIZE >> 2) << 16 | ((RX_FIFO_SIZE >> 2)) << 0, drivers/usb/gadget/dwc2_udc_otg.c: ((RX_FIFO_SIZE + NPTX_FIFO_SIZE + drivers/usb/gadget/dwc2_udc_otg_regs.h:#define RX_FIFO_SIZE (1024*4) drivers/usb/host/dwc2.c: writel(CONFIG_DWC2_HOST_RX_FIFO_SIZE, ®s->grxfsiz); drivers/usb/host/dwc2.c: nptxfifosize |= CONFIG_DWC2_HOST_RX_FIFO_SIZE << drivers/usb/host/dwc2.c: ptxfifosize |= (CONFIG_DWC2_HOST_RX_FIFO_SIZE + drivers/usb/host/dwc2.h:#define CONFIG_DWC2_HOST_RX_FIFO_SIZE (516 + CONFIG_DWC2_MAX_CHANNELS)
If we need a Rockchip-specific value for this then it should go in Kconfig or device tree.
The macros are only used for dwc2 controller. It seems improper to rename to be CONFIG_xxxx(ie. CONFIG_RX_FIFO_SIZE) if we move them to Kconfig. Besides, usb driver doesn't support device tree, I can't rework it to dt.
#define PTX_FIFO_SIZE (1536*1)
#define DEPCTL_TXFNUM_0 (0x0<<22)
-- 1.9.1
Regards, Simon

Enable fastboot feature on rk3288.
This path doesn't support the fastboot flash function command entirely. We will hit "cannot find partition" assertion without specified partition environment. Define gpt partition layout in specified board such as firefly-rk3288, then enjoy it!
Signed-off-by: Ziyuan Xu xzy.xu@rock-chips.com ---
arch/arm/mach-rockchip/board.c | 20 ++++++++++++++++++++ include/configs/rk3288_common.h | 25 +++++++++++++++++++++++++ 2 files changed, 45 insertions(+)
diff --git a/arch/arm/mach-rockchip/board.c b/arch/arm/mach-rockchip/board.c index 816540e..9766ba0 100644 --- a/arch/arm/mach-rockchip/board.c +++ b/arch/arm/mach-rockchip/board.c @@ -52,6 +52,26 @@ void lowlevel_init(void) { }
+#if defined(CONFIG_USB_GADGET) && defined(CONFIG_USB_GADGET_DWC2_OTG) +#include <usb.h> +#include <usb/dwc2_udc.h> + +static struct dwc2_plat_otg_data rk3288_otg_data = { + .regs_phy = 0xff770000, + .regs_otg = 0xff580000, +}; + +int board_usb_init(int index, enum usb_init_type init) +{ + return dwc2_udc_probe(&rk3288_otg_data); +} + +int board_usb_cleanup(int index, enum usb_init_type init) +{ + return 0; +} +#endif + static int do_clock(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) { diff --git a/include/configs/rk3288_common.h b/include/configs/rk3288_common.h index 9d50d83..f8a6c98 100644 --- a/include/configs/rk3288_common.h +++ b/include/configs/rk3288_common.h @@ -80,6 +80,31 @@ #define CONFIG_SPI #define CONFIG_SF_DEFAULT_SPEED 20000000
+/* usb otg */ +#define CONFIG_USB_GADGET +#define CONFIG_USB_GADGET_DUALSPEED +#define CONFIG_USB_GADGET_DWC2_OTG +#define CONFIG_RK3288_USB_PHY +#define CONFIG_USB_GADGET_VBUS_DRAW 0 + +/* fastboot */ +#define CONFIG_CMD_FASTBOOT +#define CONFIG_USB_FUNCTION_FASTBOOT +#define CONFIG_FASTBOOT_FLASH +#define CONFIG_FASTBOOT_FLASH_MMC_DEV 1 /* eMMC */ +#define CONFIG_FASTBOOT_BUF_ADDR (CONFIG_SYS_SDRAM_BASE \ + + SDRAM_BANK_SIZE) +#define CONFIG_FASTBOOT_BUF_SIZE 0x08000000 + +#define CONFIG_USB_GADGET_DOWNLOAD +#define CONFIG_G_DNL_MANUFACTURER "Rockchip" +#define CONFIG_G_DNL_VENDOR_NUM 0x2207 +#define CONFIG_G_DNL_PRODUCT_NUM 0x320a + +/* Enable gpt partition table */ +#define CONFIG_CMD_GPT +#define CONFIG_EFI_PARTITION + #ifndef CONFIG_SPL_BUILD #include <config_distro_defaults.h>

Hi Ziyuan,
On 30 June 2016 at 00:22, Ziyuan Xu xzy.xu@rock-chips.com wrote:
Enable fastboot feature on rk3288.
This path doesn't support the fastboot flash function command entirely. We will hit "cannot find partition" assertion without specified partition environment. Define gpt partition layout in specified board such as firefly-rk3288, then enjoy it!
Signed-off-by: Ziyuan Xu xzy.xu@rock-chips.com
arch/arm/mach-rockchip/board.c | 20 ++++++++++++++++++++ include/configs/rk3288_common.h | 25 +++++++++++++++++++++++++ 2 files changed, 45 insertions(+)
diff --git a/arch/arm/mach-rockchip/board.c b/arch/arm/mach-rockchip/board.c index 816540e..9766ba0 100644 --- a/arch/arm/mach-rockchip/board.c +++ b/arch/arm/mach-rockchip/board.c @@ -52,6 +52,26 @@ void lowlevel_init(void) { }
+#if defined(CONFIG_USB_GADGET) && defined(CONFIG_USB_GADGET_DWC2_OTG) +#include <usb.h> +#include <usb/dwc2_udc.h>
+static struct dwc2_plat_otg_data rk3288_otg_data = {
.regs_phy = 0xff770000,
.regs_otg = 0xff580000,
Shouldn't these come from the device tree?
+};
+int board_usb_init(int index, enum usb_init_type init) +{
return dwc2_udc_probe(&rk3288_otg_data);
+}
+int board_usb_cleanup(int index, enum usb_init_type init) +{
return 0;
+} +#endif
static int do_clock(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) { diff --git a/include/configs/rk3288_common.h b/include/configs/rk3288_common.h index 9d50d83..f8a6c98 100644 --- a/include/configs/rk3288_common.h +++ b/include/configs/rk3288_common.h @@ -80,6 +80,31 @@ #define CONFIG_SPI #define CONFIG_SF_DEFAULT_SPEED 20000000
+/* usb otg */ +#define CONFIG_USB_GADGET +#define CONFIG_USB_GADGET_DUALSPEED +#define CONFIG_USB_GADGET_DWC2_OTG +#define CONFIG_RK3288_USB_PHY +#define CONFIG_USB_GADGET_VBUS_DRAW 0
+/* fastboot */ +#define CONFIG_CMD_FASTBOOT +#define CONFIG_USB_FUNCTION_FASTBOOT +#define CONFIG_FASTBOOT_FLASH +#define CONFIG_FASTBOOT_FLASH_MMC_DEV 1 /* eMMC */ +#define CONFIG_FASTBOOT_BUF_ADDR (CONFIG_SYS_SDRAM_BASE \
+ SDRAM_BANK_SIZE)
Can you add a comment as to why the buffer is placed here?
+#define CONFIG_FASTBOOT_BUF_SIZE 0x08000000
+#define CONFIG_USB_GADGET_DOWNLOAD +#define CONFIG_G_DNL_MANUFACTURER "Rockchip" +#define CONFIG_G_DNL_VENDOR_NUM 0x2207 +#define CONFIG_G_DNL_PRODUCT_NUM 0x320a
+/* Enable gpt partition table */ +#define CONFIG_CMD_GPT +#define CONFIG_EFI_PARTITION
#ifndef CONFIG_SPL_BUILD #include <config_distro_defaults.h>
-- 1.9.1
Regards, Simon

Hi Ziyuan,
On Thu, Jun 30, 2016 at 8:23 AM, Simon Glass sjg@chromium.org wrote:
Hi Ziyuan,
On 30 June 2016 at 00:22, Ziyuan Xu xzy.xu@rock-chips.com wrote:
Enable fastboot feature on rk3288.
This path doesn't support the fastboot flash function command entirely. We will hit "cannot find partition" assertion without specified partition environment. Define gpt partition layout in specified board such as firefly-rk3288, then enjoy it!
s/path/patch/ Are you trying to resolve this in this patch or in a subsequent patch? Thanks, Steve
Signed-off-by: Ziyuan Xu xzy.xu@rock-chips.com
arch/arm/mach-rockchip/board.c | 20 ++++++++++++++++++++ include/configs/rk3288_common.h | 25 +++++++++++++++++++++++++ 2 files changed, 45 insertions(+)
diff --git a/arch/arm/mach-rockchip/board.c b/arch/arm/mach-rockchip/board.c index 816540e..9766ba0 100644 --- a/arch/arm/mach-rockchip/board.c +++ b/arch/arm/mach-rockchip/board.c @@ -52,6 +52,26 @@ void lowlevel_init(void) { }
+#if defined(CONFIG_USB_GADGET) && defined(CONFIG_USB_GADGET_DWC2_OTG) +#include <usb.h> +#include <usb/dwc2_udc.h>
+static struct dwc2_plat_otg_data rk3288_otg_data = {
.regs_phy = 0xff770000,
.regs_otg = 0xff580000,
Shouldn't these come from the device tree?
+};
+int board_usb_init(int index, enum usb_init_type init) +{
return dwc2_udc_probe(&rk3288_otg_data);
+}
+int board_usb_cleanup(int index, enum usb_init_type init) +{
return 0;
+} +#endif
static int do_clock(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) { diff --git a/include/configs/rk3288_common.h b/include/configs/rk3288_common.h index 9d50d83..f8a6c98 100644 --- a/include/configs/rk3288_common.h +++ b/include/configs/rk3288_common.h @@ -80,6 +80,31 @@ #define CONFIG_SPI #define CONFIG_SF_DEFAULT_SPEED 20000000
+/* usb otg */ +#define CONFIG_USB_GADGET +#define CONFIG_USB_GADGET_DUALSPEED +#define CONFIG_USB_GADGET_DWC2_OTG +#define CONFIG_RK3288_USB_PHY +#define CONFIG_USB_GADGET_VBUS_DRAW 0
+/* fastboot */ +#define CONFIG_CMD_FASTBOOT +#define CONFIG_USB_FUNCTION_FASTBOOT +#define CONFIG_FASTBOOT_FLASH +#define CONFIG_FASTBOOT_FLASH_MMC_DEV 1 /* eMMC */ +#define CONFIG_FASTBOOT_BUF_ADDR (CONFIG_SYS_SDRAM_BASE \
+ SDRAM_BANK_SIZE)
Can you add a comment as to why the buffer is placed here?
+#define CONFIG_FASTBOOT_BUF_SIZE 0x08000000
+#define CONFIG_USB_GADGET_DOWNLOAD +#define CONFIG_G_DNL_MANUFACTURER "Rockchip" +#define CONFIG_G_DNL_VENDOR_NUM 0x2207 +#define CONFIG_G_DNL_PRODUCT_NUM 0x320a
+/* Enable gpt partition table */ +#define CONFIG_CMD_GPT +#define CONFIG_EFI_PARTITION
#ifndef CONFIG_SPL_BUILD #include <config_distro_defaults.h>
-- 1.9.1
Regards, Simon _______________________________________________ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot

Hi Steve,
On 2016年07月01日 05:55, Steve Rae wrote:
Hi Ziyuan,
On Thu, Jun 30, 2016 at 8:23 AM, Simon Glass sjg@chromium.org wrote:
Hi Ziyuan,
On 30 June 2016 at 00:22, Ziyuan Xu xzy.xu@rock-chips.com wrote:
Enable fastboot feature on rk3288.
This path doesn't support the fastboot flash function command entirely. We will hit "cannot find partition" assertion without specified partition environment. Define gpt partition layout in specified board such as firefly-rk3288, then enjoy it!
s/path/patch/ Are you trying to resolve this in this patch or in a subsequent patch? Thanks, Steve
By that I mean this path series support fastboot function on rk3288, so far, host only has the ability push image to device. We need further configuration for partition so that the image could flash to the mmc device. Each of 3288 boards(firefly-rk3288, rock2) has a different partition setting, that's why I add the GPT partition on rk3288_common.h, and didn't add the partition setting to ENV. If someone would like to use fastboot function on rk3288 board(ie. firefly-rk3288), he shall configure partition in firefly-rk3288.h. like: #define PARTS_DEFAULT \ "uuid_disk=${uuid_gpt_disk};" \ "name=loader,start=32K,size=4000K,uuid=${uuid_gpt_loader};" \ "name=reserved,size=64K,uuid=${uuid_gpt_reserved};" \ "name=misc,size=4M,uuid=${uuid_gpt_misc};" \ "name=recovery,size=32M,uuid=${uuid_gpt_recovery};" \ "name=boot_a,size=32M,uuid=${uuid_gpt_boot_a};" \ "name=boot_b,size=32M,uuid=${uuid_gpt_boot_b};" \ "name=system_a,size=818M,uuid=${uuid_gpt_system_a};" \ "name=system_b,size=818M,uuid=${uuid_gpt_system_b};" \ "name=vendor_a,size=50M,uuid=${uuid_gpt_vendor_a};" \ "name=vendor_b,size=50M,uuid=${uuid_gpt_vendor_b};" \ "name=cache,size=100M,uuid=${uuid_gpt_cache};" \ "name=metadata,size=16M,uuid=${uuid_gpt_metadata};" \ "name=persist,size=4M,uuid=${uuid_gpt_persist};" \ "name=userdata,size=-,uuid=${uuid_gpt_userdata};\0" \
#undef CONFIG_EXTRA_ENV_SETTINGS #define CONFIG_EXTRA_ENV_SETTINGS \ "partitions=" PARTS_DEFAULT \
In short, I don't think "cannot find partition" is an issue. Does it make sense to you?
Signed-off-by: Ziyuan Xu xzy.xu@rock-chips.com
arch/arm/mach-rockchip/board.c | 20 ++++++++++++++++++++ include/configs/rk3288_common.h | 25 +++++++++++++++++++++++++ 2 files changed, 45 insertions(+)
diff --git a/arch/arm/mach-rockchip/board.c b/arch/arm/mach-rockchip/board.c index 816540e..9766ba0 100644 --- a/arch/arm/mach-rockchip/board.c +++ b/arch/arm/mach-rockchip/board.c @@ -52,6 +52,26 @@ void lowlevel_init(void) { }
+#if defined(CONFIG_USB_GADGET) && defined(CONFIG_USB_GADGET_DWC2_OTG) +#include <usb.h> +#include <usb/dwc2_udc.h>
+static struct dwc2_plat_otg_data rk3288_otg_data = {
.regs_phy = 0xff770000,
.regs_otg = 0xff580000,
Shouldn't these come from the device tree?
+};
+int board_usb_init(int index, enum usb_init_type init) +{
return dwc2_udc_probe(&rk3288_otg_data);
+}
+int board_usb_cleanup(int index, enum usb_init_type init) +{
return 0;
+} +#endif
- static int do_clock(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) {
diff --git a/include/configs/rk3288_common.h b/include/configs/rk3288_common.h index 9d50d83..f8a6c98 100644 --- a/include/configs/rk3288_common.h +++ b/include/configs/rk3288_common.h @@ -80,6 +80,31 @@ #define CONFIG_SPI #define CONFIG_SF_DEFAULT_SPEED 20000000
+/* usb otg */ +#define CONFIG_USB_GADGET +#define CONFIG_USB_GADGET_DUALSPEED +#define CONFIG_USB_GADGET_DWC2_OTG +#define CONFIG_RK3288_USB_PHY +#define CONFIG_USB_GADGET_VBUS_DRAW 0
+/* fastboot */ +#define CONFIG_CMD_FASTBOOT +#define CONFIG_USB_FUNCTION_FASTBOOT +#define CONFIG_FASTBOOT_FLASH +#define CONFIG_FASTBOOT_FLASH_MMC_DEV 1 /* eMMC */ +#define CONFIG_FASTBOOT_BUF_ADDR (CONFIG_SYS_SDRAM_BASE \
+ SDRAM_BANK_SIZE)
Can you add a comment as to why the buffer is placed here?
+#define CONFIG_FASTBOOT_BUF_SIZE 0x08000000
+#define CONFIG_USB_GADGET_DOWNLOAD +#define CONFIG_G_DNL_MANUFACTURER "Rockchip" +#define CONFIG_G_DNL_VENDOR_NUM 0x2207 +#define CONFIG_G_DNL_PRODUCT_NUM 0x320a
+/* Enable gpt partition table */ +#define CONFIG_CMD_GPT +#define CONFIG_EFI_PARTITION
- #ifndef CONFIG_SPL_BUILD #include <config_distro_defaults.h>
-- 1.9.1
Regards, Simon _______________________________________________ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot

On 2016年06月30日 23:23, Simon Glass wrote:
Hi Ziyuan,
On 30 June 2016 at 00:22, Ziyuan Xu xzy.xu@rock-chips.com wrote:
Enable fastboot feature on rk3288.
This path doesn't support the fastboot flash function command entirely. We will hit "cannot find partition" assertion without specified partition environment. Define gpt partition layout in specified board such as firefly-rk3288, then enjoy it!
Signed-off-by: Ziyuan Xu xzy.xu@rock-chips.com
arch/arm/mach-rockchip/board.c | 20 ++++++++++++++++++++ include/configs/rk3288_common.h | 25 +++++++++++++++++++++++++ 2 files changed, 45 insertions(+)
diff --git a/arch/arm/mach-rockchip/board.c b/arch/arm/mach-rockchip/board.c index 816540e..9766ba0 100644 --- a/arch/arm/mach-rockchip/board.c +++ b/arch/arm/mach-rockchip/board.c @@ -52,6 +52,26 @@ void lowlevel_init(void) { }
+#if defined(CONFIG_USB_GADGET) && defined(CONFIG_USB_GADGET_DWC2_OTG) +#include <usb.h> +#include <usb/dwc2_udc.h>
+static struct dwc2_plat_otg_data rk3288_otg_data = {
.regs_phy = 0xff770000,
.regs_otg = 0xff580000,
Shouldn't these come from the device tree?
Done, fix in v2.
+};
+int board_usb_init(int index, enum usb_init_type init) +{
return dwc2_udc_probe(&rk3288_otg_data);
+}
+int board_usb_cleanup(int index, enum usb_init_type init) +{
return 0;
+} +#endif
- static int do_clock(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) {
diff --git a/include/configs/rk3288_common.h b/include/configs/rk3288_common.h index 9d50d83..f8a6c98 100644 --- a/include/configs/rk3288_common.h +++ b/include/configs/rk3288_common.h @@ -80,6 +80,31 @@ #define CONFIG_SPI #define CONFIG_SF_DEFAULT_SPEED 20000000
+/* usb otg */ +#define CONFIG_USB_GADGET +#define CONFIG_USB_GADGET_DUALSPEED +#define CONFIG_USB_GADGET_DWC2_OTG +#define CONFIG_RK3288_USB_PHY +#define CONFIG_USB_GADGET_VBUS_DRAW 0
+/* fastboot */ +#define CONFIG_CMD_FASTBOOT +#define CONFIG_USB_FUNCTION_FASTBOOT +#define CONFIG_FASTBOOT_FLASH +#define CONFIG_FASTBOOT_FLASH_MMC_DEV 1 /* eMMC */ +#define CONFIG_FASTBOOT_BUF_ADDR (CONFIG_SYS_SDRAM_BASE \
+ SDRAM_BANK_SIZE)
Can you add a comment as to why the buffer is placed here?
okay, fix in v2.
+#define CONFIG_FASTBOOT_BUF_SIZE 0x08000000
+#define CONFIG_USB_GADGET_DOWNLOAD +#define CONFIG_G_DNL_MANUFACTURER "Rockchip" +#define CONFIG_G_DNL_VENDOR_NUM 0x2207 +#define CONFIG_G_DNL_PRODUCT_NUM 0x320a
+/* Enable gpt partition table */ +#define CONFIG_CMD_GPT +#define CONFIG_EFI_PARTITION
- #ifndef CONFIG_SPL_BUILD #include <config_distro_defaults.h>
-- 1.9.1
Regards, Simon

Disable EFI applications feature.
Signed-off-by: Ziyuan Xu xzy.xu@rock-chips.com ---
configs/firefly-rk3288_defconfig | 1 + 1 file changed, 1 insertion(+)
diff --git a/configs/firefly-rk3288_defconfig b/configs/firefly-rk3288_defconfig index 4af9120..8855409 100644 --- a/configs/firefly-rk3288_defconfig +++ b/configs/firefly-rk3288_defconfig @@ -9,6 +9,7 @@ CONFIG_SPL_STACK_R=y CONFIG_SPL_STACK_R_MALLOC_SIMPLE_LEN=0x2000 CONFIG_HUSH_PARSER=y CONFIG_CMD_BOOTZ=y +CONFIG_EFI_LOADER=n # CONFIG_CMD_IMLS is not set CONFIG_CMD_MMC=y CONFIG_CMD_SF=y

On 30.06.16 09:21, Ziyuan Xu wrote:
Hi,
This short series add the fastboot support for rk3288, and I have tested on firefly-rk3288 board.
I encounter an odd issue while debugging usb-otg ep2out-bulk data transfer. The buffer was always zero which mapped to DMA buffer, even though driver call invalidate_dcache_range() to make sure the cpu read memroy data directly. IMHO, dcache was abnormal after something initialization code. Everything work fine without CONFIG_EFI_LOADER. Moreover, invalidate_icache_all cause the issue. I'm not able to figure out why and explain it. But I think there is no need to enable EFI applications on rk3288 platform.
I disagree. Rk3288 (and especially the firefly) is actually a very interesting platform for EFI applications like grub2.
If a full icache invalidate causes breakage, maybe in the non-efi case you're just getting lucky because you code that got overwritten is still in the cache.
Please keep debugging to figure out what is causing the invalid data to go into your icache. Maybe just disable icache altogether for verification and run checksums on the text section after every dma?
Alex
participants (4)
-
Alexander Graf
-
Simon Glass
-
Steve Rae
-
Ziyuan Xu