Skip to contentSkip to conversation

Add fastboot support for MediaTek mt8518

PATCH New mingming lee 2 participants 13 messages Jan 16, 2020 – Jan 25, 2020

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

v2 cover Add fastboot support for MediaTek mt8518

This patch series adds basic fastboot support for MediaTek MT8518 EMMC boards, including musb-new structure for gadget driver and fastboot related configs.

---
Changes for v2:
- Limit the config in this patch depends on ARCH_MEDIATEK.
- config all the added function,avoid affect other IC config.
- fixed the build error for other defconfig,such as dra7xx_evm_defconfig.

mingming lee (6):
usb: musb-new: mt85xx: add musb-new gadget driver.
ARM: Mediatek: Add board_late_init to init usb gadget driver
configs: mt8518: set global variables for fastboot
configs: mt8518: enable usb gadget driver
configs: mt8518: Enable fastboot related configs
fastboot: mt85xx: add command to flash/erase emmc hwpart

 arch/arm/dts/mt8518.dtsi           |  13 +
 board/mediatek/mt8518/mt8518_ap1.c |  18 ++
 configs/mt8518_ap1_emmc_defconfig  |  22 ++
 drivers/fastboot/Kconfig           |  30 +++
 drivers/fastboot/fb_mmc.c          | 102 +++++++
 drivers/usb/musb-new/Kconfig       |  11 +-
 drivers/usb/musb-new/Makefile      |   1 +
 drivers/usb/musb-new/mt85xx.c      | 417 +++++++++++++++++++++++++++++
 include/configs/mt8518.h           |  10 +-
 9 files changed, 619 insertions(+), 5 deletions(-)
 create mode 100644 drivers/usb/musb-new/mt85xx.c
Signature · 1 line
2.24.1
#1 lore raw

PATCH v2 1/6 usb: musb-new: mt85xx: add musb-new gadget driver.

Using musb-new structure for mt85xx gadget driver. Add gadget driver dts for mt8518 SoCs.

---
 arch/arm/dts/mt8518.dtsi      |  13 ++
 drivers/usb/musb-new/Kconfig  |  11 +-
 drivers/usb/musb-new/Makefile |   1 +
 drivers/usb/musb-new/mt85xx.c | 417 ++++++++++++++++++++++++++++++++++
 4 files changed, 441 insertions(+), 1 deletion(-)
 create mode 100644 drivers/usb/musb-new/mt85xx.c
arch/arm/dts/mt8518.dtsi +13 -0
index c2d17fda4a..56da91a9fe 100644
@@ -74,6 +74,19 @@
 		};
 	};
 
+	usb0: usb at 11100000 {
+		compatible = "mediatek,mt8518-musb";
+		reg = <0x11100000 0x1000>;
+		reg-names = "control";
+		clocks = <&topckgen CLK_TOP_USB20_48M>,
+			 <&topckgen CLK_TOP_USBIF>,
+			 <&topckgen CLK_TOP_USB>;
+		clock-names = "usbpll", "usbmcu", "usb";
+		interrupts = <GIC_SPI 72 IRQ_TYPE_LEVEL_LOW>;
+		interrupt-names = "mc";
+		status = "okay";
+	};
+
 	mmc0: mmc at 11120000 {
 		compatible = "mediatek,mt8516-mmc";
 		reg = <0x11120000 0x1000>;
drivers/usb/musb-new/Kconfig +10 -1
index 79ad14ef66..6cf8a2b60b 100644
@@ -47,6 +47,15 @@ config USB_MUSB_DSPS
 	bool "TI DSPS platforms"
 
 if USB_MUSB_HOST || USB_MUSB_GADGET
+config USB_MUSB_MT85XX
+	bool "Enable Mediatek MT85XX DRC USB controller"
+	depends on DM_USB && ARCH_MEDIATEK
+	default n
+	help
+	  Say y to enable Mediatek MT85XX USB DRC controller support
+	  if it is available on your Mediatek MUSB IP based platform.
+	  DMA controllers are ignored. This driver follow musb-new
+	  driver and usb gadget framework.
 
 config USB_MUSB_PIC32
 	bool "Enable Microchip PIC32 DRC USB controller"
@@ -76,7 +85,7 @@ endif
 
 config USB_MUSB_PIO_ONLY
 	bool "Disable DMA (always use PIO)"
-	default y if USB_MUSB_AM35X || USB_MUSB_PIC32 || USB_MUSB_OMAP2PLUS || USB_MUSB_DSPS || USB_MUSB_SUNXI
+	default y if USB_MUSB_AM35X || USB_MUSB_PIC32 || USB_MUSB_OMAP2PLUS || USB_MUSB_DSPS || USB_MUSB_SUNXI || USB_MUSB_MT85XX
 	help
 	  All data is copied between memory and FIFO by the CPU.
 	  DMA controllers are ignored.
drivers/usb/musb-new/Makefile +1 -0
index ec7852ce94..6355eb12dd 100644
@@ -8,6 +8,7 @@ obj-$(CONFIG_USB_MUSB_HOST) += musb_host.o musb_core.o musb_uboot.o
 obj-$(CONFIG_USB_MUSB_DSPS) += musb_dsps.o
 obj-$(CONFIG_USB_MUSB_DA8XX)	+= da8xx.o
 obj-$(CONFIG_USB_MUSB_AM35X) += am35x.o
+obj-$(CONFIG_USB_MUSB_MT85XX) += mt85xx.o
 obj-$(CONFIG_USB_MUSB_OMAP2PLUS) += omap2430.o
 obj-$(CONFIG_USB_MUSB_PIC32) += pic32.o
 obj-$(CONFIG_USB_MUSB_SUNXI) += sunxi.o
drivers/usb/musb-new/mt85xx.c new file +417 -0

417 lines not on this page · raw message

Signature · 1 line
2.24.1
#3 lore raw

PATCH v2 2/6 ARM: Mediatek: Add board_late_init to init usb gadget driver

In reply to mingming lee

Add board_late_init function to init usb gadget driver for mt8518

---
 board/mediatek/mt8518/mt8518_ap1.c | 18 ++++++++++++++++++
 1 file changed, 18 insertions(+)
board/mediatek/mt8518/mt8518_ap1.c +18 -0
index 9710907fe2..2ac7c6cd18 100644
@@ -16,3 +16,21 @@ int board_init(void)
 	debug("gd->fdt_blob is %p\n", gd->fdt_blob);
 	return 0;
 }
+
+int board_late_init(void)
+{
+#ifdef CONFIG_USB_GADGET
+	struct udevice *dev;
+	int ret;
+#endif
+
+#ifdef CONFIG_USB_GADGET
+	ret = uclass_get_device(UCLASS_USB_GADGET_GENERIC, 0, &dev);
+	if (ret) {
+		pr_err("%s: Cannot find USB device\n", __func__);
+		return ret;
+	}
+#endif
+
+	return 0;
+}
Signature · 1 line
2.24.1
#5 lore raw

PATCH v2 3/6 configs: mt8518: set global variables for fastboot

In reply to mingming lee

set common fastboot variables for mt8518

---
 include/configs/mt8518.h | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)
include/configs/mt8518.h +6 -4
index 8906245a62..9bc9c04e66 100644
@@ -11,9 +11,6 @@
 
 #include <linux/sizes.h>
 
-#define CONFIG_ENV_SIZE				SZ_4K
-
-/* Machine ID */
 #define CONFIG_SYS_NONCACHED_MEMORY		SZ_1M
 
 #define CONFIG_CPU_ARMV8
@@ -39,7 +36,7 @@
 /* ENV Setting */
 #if defined(CONFIG_MMC_MTK)
 #define CONFIG_SYS_MMC_ENV_DEV			0
-#define CONFIG_ENV_OFFSET			0x4E60000
+
 #define CONFIG_ENV_OVERWRITE
 
 /* MMC offset in block unit,and block size is 0x200 */
@@ -58,10 +55,15 @@
 #define ENV_BOOT_CMD \
 	"mtk_boot=run boot_rd_img;bootm;\0"
 
+#define ENV_FASTBOOT \
+	"serial#=1234567890ABCDEF\0" \
+	"board=mt8518\0"
+
 #define CONFIG_EXTRA_ENV_SETTINGS \
 	"fdt_high=0x6c000000\0" \
 	ENV_DEVICE_SETTINGS \
 	ENV_BOOT_READ_IMAGE \
+	ENV_FASTBOOT \
 	ENV_BOOT_CMD \
 	"bootcmd=run mtk_boot;\0" \
 
Signature · 1 line
2.24.1
#7 lore raw

PATCH v2 4/6 configs: mt8518: enable usb gadget driver

In reply to mingming lee

Enable board_late_init and usb gadget for mt8518

---
 configs/mt8518_ap1_emmc_defconfig | 10 ++++++++++
 1 file changed, 10 insertions(+)
configs/mt8518_ap1_emmc_defconfig +10 -0
index dd42076f4d..9857b7b776 100644
@@ -39,3 +39,13 @@ CONFIG_DM_MMC=y
 CONFIG_MMC_MTK=y
 CONFIG_MMC_HS200_SUPPORT=y
 # CONFIG_ENV_IS_IN_MMC is not set
+CONFIG_BOARD_LATE_INIT=y
+CONFIG_USB=y
+CONFIG_USB_GADGET=y
+CONFIG_DM_USB=y
+CONFIG_USB_MUSB_GADGET=y
+CONFIG_USB_MUSB_MT85XX=y
+CONFIG_USB_GADGET_DOWNLOAD=y
+CONFIG_USB_GADGET_VENDOR_NUM=0x0bb4
+CONFIG_USB_GADGET_PRODUCT_NUM=0x0c01
+CONFIG_USB_GADGET_MANUFACTURER="Mediatek."
\ No newline at end of file
Signature · 1 line
2.24.1
#9 lore raw

PATCH v2 5/6 configs: mt8518: Enable fastboot related configs

In reply to mingming lee

Enable EFI module.
Enable fastboot.

---
 configs/mt8518_ap1_emmc_defconfig | 13 ++++++++++++-
 1 file changed, 12 insertions(+), 1 deletion(-)
configs/mt8518_ap1_emmc_defconfig +12 -1
index 9857b7b776..714fd8e087 100644
@@ -34,6 +34,7 @@ CONFIG_WDT_MTK=y
 CONFIG_CLK=y
 CONFIG_TIMER=y
 CONFIG_MTK_TIMER=y
+CONFIG_MMC=y
 CONFIG_CMD_MMC=y
 CONFIG_DM_MMC=y
 CONFIG_MMC_MTK=y
@@ -48,4 +49,14 @@ CONFIG_USB_MUSB_MT85XX=y
 CONFIG_USB_GADGET_DOWNLOAD=y
 CONFIG_USB_GADGET_VENDOR_NUM=0x0bb4
 CONFIG_USB_GADGET_PRODUCT_NUM=0x0c01
-CONFIG_USB_GADGET_MANUFACTURER="Mediatek."
\ No newline at end of file
+CONFIG_USB_GADGET_MANUFACTURER="Mediatek."
+CONFIG_EFI_PARTITION=y
+CONFIG_FASTBOOT_GPT_NAME=GPT
+CONFIG_USB_FUNCTION_FASTBOOT=y
+CONFIG_FASTBOOT=y
+CONFIG_CMD_FASTBOOT=y
+CONFIG_FASTBOOT_FLASH=y
+CONFIG_FASTBOOT_FLASH_MMC=y
+CONFIG_FASTBOOT_FLASH_MMC_DEV=0
+CONFIG_FASTBOOT_BUF_ADDR=0x56000000
+CONFIG_FASTBOOT_BUF_SIZE=0x1E00000
Signature · 1 line
2.24.1
#11 lore raw

PATCH v2 6/6 fastboot: mt85xx: add command to flash/erase emmc hwpart

In reply to mingming lee

This patch includes the following:
1. Add fastboot command to erase the whole EMMC_USER
2. Add fastboot command to flash image at EMMC_BOOT1
3. Add fastboot command to erase the whole EMMC_BOOT1
4. Enale CONFIG_FASTBOOT_MMC_BOOT1_SUPPORT for mt8518

---
Changes for v2:
- Limit the config in this patch depends on ARCH_MEDIATEK
- config include all the added function,avoid affect other IC config

---
 configs/mt8518_ap1_emmc_defconfig |   1 +
 drivers/fastboot/Kconfig          |  30 +++++++++
 drivers/fastboot/fb_mmc.c         | 102 ++++++++++++++++++++++++++++++
 3 files changed, 133 insertions(+)
configs/mt8518_ap1_emmc_defconfig +1 -0
index 714fd8e087..e929d40d75 100644
@@ -60,3 +60,4 @@ CONFIG_FASTBOOT_FLASH_MMC=y
 CONFIG_FASTBOOT_FLASH_MMC_DEV=0
 CONFIG_FASTBOOT_BUF_ADDR=0x56000000
 CONFIG_FASTBOOT_BUF_SIZE=0x1E00000
+CONFIG_FASTBOOT_MMC_BOOT1_SUPPORT=y
\ No newline at end of file
drivers/fastboot/Kconfig +30 -0
index 433ea0dc3b..aab8288930 100644
@@ -104,6 +104,36 @@ config FASTBOOT_FLASH_NAND_TRIMFFS
 	  When flashing NAND enable the DROP_FFS flag to drop trailing all-0xff
 	  pages.
 
+config FASTBOOT_MMC_BOOT1_SUPPORT
+	bool "Enable EMMC_BOOT1 flash/erase"
+	depends on FASTBOOT_FLASH_MMC && EFI_PARTITION && ARCH_MEDIATEK
+	help
+	  The fastboot "flash" and "erase" commands normally does operations
+	  on EMMC userdata. Define this to enable the special commands to
+	  flash/erase EMMC_BOOT1.
+	  The default target name for updating EMMC_BOOT1 is "mmc0boot0".
+
+config FASTBOOT_MMC_BOOT1_NAME
+	string "Target name for updating EMMC_BOOT1"
+	depends on FASTBOOT_MMC_BOOT1_SUPPORT
+	default "mmc0boot0"
+	help
+	  The fastboot "flash" and "erase" commands support operations on
+	  EMMC_BOOT1. This occurs when the specified "EMMC_BOOT1 name" on
+	  the "fastboot flash" and "fastboot erase" commands match the value
+	  defined here.
+	  The default target name for updating EMMC_BOOT1 is "mmc0boot0".
+
+config FASTBOOT_MMC_USER_NAME
+	string "Target name for erasing EMMC_USER"
+	depends on FASTBOOT_FLASH_MMC && EFI_PARTITION && ARCH_MEDIATEK
+	default "mmc0"
+	help
+	  The fastboot "erase" command supports erasing EMMC_USER. This occurs
+	  when the specified "EMMC_USER name" on the "fastboot erase" commands
+	  match the value defined here.
+	  The default target name for erasing EMMC_USER is "mmc0".
+
 config FASTBOOT_GPT_NAME
 	string "Target name for updating GPT"
 	depends on FASTBOOT_FLASH_MMC && EFI_PARTITION
drivers/fastboot/fb_mmc.c +102 -0

122 lines not on this page · raw message

Signature · 1 line
2.24.1
#2 lore raw

PATCH v2 1/6 usb: musb-new: mt85xx: add musb-new gadget driver.

In reply to mingming lee
Quoted 4 lines · mingming lee

Using musb-new structure for mt85xx gadget driver. Add gadget driver dts for mt8518 SoCs.

Applied to u-boot/master, thanks!

Signature · 8 lines
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: not available
URL: <https://lists.denx.de/pipermail/u-boot/attachments/20200125/d0008f52/attachment.sig>
#4 lore raw

PATCH v2 2/6 ARM: Mediatek: Add board_late_init to init usb gadget driver

In reply to mingming lee
Quoted 3 lines · mingming lee

Add board_late_init function to init usb gadget driver for mt8518

Applied to u-boot/master, thanks!

Signature · 8 lines
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: not available
URL: <https://lists.denx.de/pipermail/u-boot/attachments/20200125/e2241796/attachment.sig>
#6 lore raw

PATCH v2 3/6 configs: mt8518: set global variables for fastboot

In reply to mingming lee
Quoted 3 lines · mingming lee

set common fastboot variables for mt8518

Applied to u-boot/master, thanks!

Signature · 8 lines
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: not available
URL: <https://lists.denx.de/pipermail/u-boot/attachments/20200125/1241764e/attachment.sig>
#8 lore raw

PATCH v2 4/6 configs: mt8518: enable usb gadget driver

In reply to mingming lee
Quoted 3 lines · mingming lee

Enable board_late_init and usb gadget for mt8518

Applied to u-boot/master, thanks!

Signature · 8 lines
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: not available
URL: <https://lists.denx.de/pipermail/u-boot/attachments/20200125/d6d66c4e/attachment.sig>
#10 lore raw

PATCH v2 5/6 configs: mt8518: Enable fastboot related configs

In reply to mingming lee
Quoted 4 lines · mingming lee

Enable EFI module.
Enable fastboot.

Applied to u-boot/master, thanks!

Signature · 8 lines
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: not available
URL: <https://lists.denx.de/pipermail/u-boot/attachments/20200125/7d777934/attachment.sig>
#12 lore raw

PATCH v2 6/6 fastboot: mt85xx: add command to flash/erase emmc hwpart

In reply to mingming lee
Quoted 7 lines · mingming lee

This patch includes the following:
1. Add fastboot command to erase the whole EMMC_USER
2. Add fastboot command to flash image at EMMC_BOOT1
3. Add fastboot command to erase the whole EMMC_BOOT1
4. Enale CONFIG_FASTBOOT_MMC_BOOT1_SUPPORT for mt8518

Applied to u-boot/master, thanks!

Signature · 8 lines
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: not available
URL: <https://lists.denx.de/pipermail/u-boot/attachments/20200125/9fbca673/attachment.sig>