i.MX8MM: add host/gadget support
Subsystems (7)
cover i.MX8MM: add host/gadget support
This patchset is based on
https://patchwork.ozlabs.org/project/uboot/list/?series=202112
https://patchwork.ozlabs.org/project/uboot/list/?series=202117
In this patchset, A new pure DM USB driver was added to driver/use/imx which will be used to hold i.MX DM USB stuff, the ehci-mx6.c will retire step by step after more code moved.
It also includes the DM GADGET part of ci udc, my future idea is to add gadget support in driver/usb/imx/ and use one driver to handle host and gadget support.
The i.MX8MM EVK board has a typec devices, so need to setup the typec, this piece code was added in board/freescale/common.
Stefano:
This might not be good to merge the patches into one patchset,
but to make people could easy to setup test, so send in a whole.
Marek:
Please see whether you are fine moving the code to drivers/usb/imx/
Peng Fan (6):
power: regulator: add dummy helper
phy: nop-phy: add optional clk
usb: imx: add i.MX usb ehci driver
imx8m: enable usb power domain
imx8mm_evk: add usbotg1 host support
imx8mm_evk: add fastboot support
Sherry Sun (1):
usb: ci_udc: Convert driver to DM_USB_GADGET
Ye Li (1):
tcpc: Add driver for USB typec port controller (TCPC)
Makefile | 1 + arch/arm/dts/imx8mm-evk-u-boot.dtsi | 43 + arch/arm/include/asm/arch-imx8m/sys_proto.h | 1 + arch/arm/include/asm/mach-imx/regs-usbphy.h | 5 + arch/arm/include/asm/mach-imx/sys_proto.h | 2 + arch/arm/mach-imx/imx8m/soc.c | 55 + board/freescale/common/Kconfig | 6 + board/freescale/common/Makefile | 4 + board/freescale/common/tcpc.c | 1018 +++++++++++++++++++ board/freescale/common/tcpc.h | 469 +++++++++ board/freescale/imx8mm_evk/Kconfig | 1 + board/freescale/imx8mm_evk/imx8mm_evk.c | 181 ++++ configs/imx8mm_evk_defconfig | 23 + drivers/Makefile | 1 + drivers/phy/nop-phy.c | 34 + drivers/usb/Kconfig | 2 + drivers/usb/gadget/ci_udc.c | 305 +++++- drivers/usb/host/ehci-mx6.c | 15 +- drivers/usb/imx/Kconfig | 10 + drivers/usb/imx/Makefile | 5 + drivers/usb/imx/ehci-imx.c | 406 ++++++++ drivers/usb/imx/imx-usb-misc.c | 47 + include/configs/imx8mm_evk.h | 17 + include/power/regulator.h | 114 +++ include/usb/ci_udc.h | 3 + 25 files changed, 2750 insertions(+), 18 deletions(-) create mode 100644 board/freescale/common/tcpc.c create mode 100644 board/freescale/common/tcpc.h create mode 100644 drivers/usb/imx/Kconfig create mode 100644 drivers/usb/imx/Makefile create mode 100644 drivers/usb/imx/ehci-imx.c create mode 100644 drivers/usb/imx/imx-usb-misc.c
Signature · 1 line
2.28.0
PATCH 1/8 tcpc: Add driver for USB typec port controller (TCPC)
From: Ye Li <[email protected]>
The functionalities in this driver include:
1. USB power delivery support at dead battery
2. Support configure to UFP or DFP mode
3. Support callback to setup external PD switch. When PD process is enabled, we call this function only when SINK_VBUS is enabled to avoid system power shut down.
--- board/freescale/common/Kconfig | 6 + board/freescale/common/Makefile | 4 + board/freescale/common/tcpc.c | 1018 +++++++++++++++++++++++++++++++ board/freescale/common/tcpc.h | 469 ++++++++++++++ 4 files changed, 1497 insertions(+) create mode 100644 board/freescale/common/tcpc.c create mode 100644 board/freescale/common/tcpc.h
board/freescale/common/Kconfig +6 -0
@@ -36,3 +36,9 @@ config VOL_MONITOR_LTC3882_SET help This option enables LTC3882 voltage monitor set functionality. It is used by common VID driver. + +config USB_TCPC + bool "USB Typec port controller simple driver" + default n + help + Enable USB type-c port controller (TCPC) driver
board/freescale/common/Makefile +4 -0
@@ -79,4 +79,8 @@ obj-$(CONFIG_CMD_ESBC_VALIDATE) += fsl_validate.o cmd_esbc_validate.o endif obj-$(CONFIG_CHAIN_OF_TRUST) += fsl_chain_of_trust.o +ifndef CONFIG_SPL_BUILD +obj-$(CONFIG_USB_TCPC) += tcpc.o +endif + endif
board/freescale/common/tcpc.c new file +1018 -0
1,018 lines not on this page · raw message
board/freescale/common/tcpc.h new file +469 -0
469 lines not on this page · raw message
Signature · 1 line
2.28.0
PATCH 1/8 tcpc: Add driver for USB typec port controller (TCPC)
On 10/12/20 8:23 AM, Peng Fan wrote:
[...]
Quoted 7 lines
board/freescale/common/Kconfig | 6 + board/freescale/common/Makefile | 4 + board/freescale/common/tcpc.c | 1018 +++++++++++++++++++++++++++++++ board/freescale/common/tcpc.h | 469 ++++++++++++++ 4 files changed, 1497 insertions(+) create mode 100644 board/freescale/common/tcpc.c create mode 100644 board/freescale/common/tcpc.h
Shouldn't driver be in drivers/ ?
[...]
Quoted 6 lines
board/freescale/common/tcpc.c new file +0
-0@@ -0,0 +1,1018 @@
[...]
board/freescale/common/tcpc.c line 16
Quoted 5 lines
board/freescale/common/tcpc.c new file +5
-0+#ifdef DEBUG +#define tcpc_debug_log(port, fmt, args...) tcpc_log(port, fmt, ##args) +#else +#define tcpc_debug_log(port, fmt, args...) +#endif
Use dev_dbg() or pr_debug() or just debug() ?
[...]
PATCH 1/8 tcpc: Add driver for USB typec port controller (TCPC)
Quoted 7 lines
Subject: Re: [PATCH 1/8] tcpc: Add driver for USB typec port controller (TCPC)
On 10/12/20 8:23 AM, Peng Fan wrote:
[...]Quoted 3 lines
board/freescale/common/Kconfig | 6 + board/freescale/common/Makefile | 4 + board/freescale/common/tcpc.c | 1018
Quoted 8 lines
+++++++++++++++++++++++++++++++
Quoted 3 lines
board/freescale/common/tcpc.h | 469 ++++++++++++++ 4 files changed, 1497 insertions(+) create mode 100644 board/freescale/common/tcpc.c create mode100644
Quoted 1 line
board/freescale/common/tcpc.hShouldn't driver be in
drivers/?
You mean drivers/usb/typec as kernel? There is no common framework now.
Regards,
Peng.
Quoted 19 lines
[...]
Quoted 6 lines
(quoted diff) +0
-0
b/board/freescale/common/tcpc.cnew file mode 100644 index 0000000000..fb532a3d87board/freescale/common/tcpc.c new file +0
-0@@ -0,0 +1,1018 @@[...]
board/freescale/common/tcpc.c
Quoted 3 lines
board/freescale/common/tcpc.c new file +3
-0+#ifdef DEBUG +#define tcpc_debug_log(port, fmt, args...) tcpc_log(port, fmt, +##args) #else #define tcpc_debug_log(port, fmt, args...) #endifUse
dev_dbg()orpr_debug()or justdebug()?[...]
PATCH 1/8 tcpc: Add driver for USB typec port controller (TCPC)
Quoted 11 lines · Peng Fan
Quoted 11 lines
Subject: Re: [PATCH 1/8] tcpc: Add driver for USB typec port controller (TCPC)
On 10/12/20 8:23 AM, Peng Fan wrote:
[...]Quoted 3 lines
board/freescale/common/Kconfig | 6 + board/freescale/common/Makefile | 4 + board/freescale/common/tcpc.c | 1018+++++++++++++++++++++++++++++++
Quoted 3 lines
board/freescale/common/tcpc.h | 469 ++++++++++++++ 4 files changed, 1497 insertions(+) create mode 100644 board/freescale/common/tcpc.c create mode
Quoted 6 lines
Quoted 4 lines
100644
Quoted 1 line
board/freescale/common/tcpc.hShouldn't driver be in
drivers/?You mean
drivers/usb/typecas kernel?
Yes, looks much better than putting drivers into board/ , right ?
Quoted 1 line
There is no common framework now.
What can we do about that ?
PATCH 1/8 tcpc: Add driver for USB typec port controller (TCPC)
Quoted 20 lines
Subject: Re: [PATCH 1/8] tcpc: Add driver for USB typec port controller (TCPC)
Quoted 17 lines · Peng Fan
Quoted 16 lines
Subject: Re: [PATCH 1/8] tcpc: Add driver for USB typec port controller (TCPC)
On 10/12/20 8:23 AM, Peng Fan wrote:
[...]Quoted 3 lines
board/freescale/common/Kconfig | 6 + board/freescale/common/Makefile | 4 + board/freescale/common/tcpc.c | 1018+++++++++++++++++++++++++++++++
Quoted 3 lines
board/freescale/common/tcpc.h | 469 ++++++++++++++ 4 files changed, 1497 insertions(+) create mode 100644
board/freescale/common/tcpc.ccreate mode100644
Quoted 1 line
board/freescale/common/tcpc.hShouldn't driver be in
drivers/?
Quoted 7 lines
Quoted 1 line
You mean
drivers/usb/typecas kernel?Yes, looks much better than putting drivers into board/ , right ?
Quoted 1 line
There is no common framework now.
What can we do about that ?
I have no bandwidth to study the new typec area currently. I'll leave this to Jun and Ye.
BTW: are you ok to take the ehci-mx6 patches?
https://patchwork.ozlabs.org/project/uboot/list/?series=202112
Thanks,
Peng.
PATCH 1/8 tcpc: Add driver for USB typec port controller (TCPC)
Quoted 26 lines · Peng Fan
Quoted 26 lines
Subject: Re: [PATCH 1/8] tcpc: Add driver for USB typec port controller (TCPC)
Quoted 12 lines · Peng Fan
Quoted 12 lines
Subject: Re: [PATCH 1/8] tcpc: Add driver for USB typec port controller (TCPC)
On 10/12/20 8:23 AM, Peng Fan wrote:
[...]Quoted 3 lines
board/freescale/common/Kconfig | 6 + board/freescale/common/Makefile | 4 + board/freescale/common/tcpc.c | 1018+++++++++++++++++++++++++++++++
Quoted 3 lines
board/freescale/common/tcpc.h | 469 ++++++++++++++ 4 files changed, 1497 insertions(+) create mode 100644
board/freescale/common/tcpc.ccreate modeQuoted 6 lines
Quoted 4 lines
100644
Quoted 1 line
board/freescale/common/tcpc.hShouldn't driver be in
drivers/?You mean
drivers/usb/typecas kernel?Yes, looks much better than putting drivers into board/ , right ?
Quoted 1 line
There is no common framework now.
Quoted 7 lines
Quoted 1 line
What can we do about that ?
I have no bandwidth to study the new typec area currently. I'll leave this to Jun and Ye.
BTW: are you ok to take the ehci-mx6 patches?
https://patchwork.ozlabs.org/project/uboot/list/?series=202112
Sure, I am waiting for the cleanup patchset:
https://patchwork.ozlabs.org/project/uboot/patch/20200916125705.4341-14-peng.fan at nxp.com/
PATCH 1/8 tcpc: Add driver for USB typec port controller (TCPC)
Quoted 44 lines
Subject: Re: [PATCH 1/8] tcpc: Add driver for USB typec port controller (TCPC)
Quoted 27 lines · Peng Fan
Quoted 27 lines
Subject: Re: [PATCH 1/8] tcpc: Add driver for USB typec port controller (TCPC)
Quoted 12 lines · Peng Fan
Quoted 12 lines
Subject: Re: [PATCH 1/8] tcpc: Add driver for USB typec port controller (TCPC)
On 10/12/20 8:23 AM, Peng Fan wrote:
[...]Quoted 3 lines
board/freescale/common/Kconfig | 6 + board/freescale/common/Makefile | 4 + board/freescale/common/tcpc.c | 1018+++++++++++++++++++++++++++++++
Quoted 3 lines
board/freescale/common/tcpc.h | 469 ++++++++++++++ 4 files changed, 1497 insertions(+) create mode 100644
board/freescale/common/tcpc.ccreate modeQuoted 6 lines
Quoted 4 lines
100644
Quoted 1 line
board/freescale/common/tcpc.hShouldn't driver be in
drivers/?You mean
drivers/usb/typecas kernel?Yes, looks much better than putting drivers into board/ , right ?
Quoted 1 line
There is no common framework now.
Quoted 8 lines
Quoted 1 line
What can we do about that ?
I have no bandwidth to study the new typec area currently. I'll leave this to Jun and Ye.
BTW: are you ok to take the ehci-mx6 patches?
https://eur01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fpatchwork.ozlabs.org%2Fproject%2Fuboot%2Flist%2F%3Fseries%3D202112& ;dat
Quoted 1 line
a=02%7C01%7Cpeng.fan%40nxp.com%7C9b1ed52ddbf848fff1e408d86f5ddd 1e%7C68
Quoted 1 line
Quoted 7 lines
6ea1d3bc2b4c6fa92cd99c5c301635%7C0%7C0%7C637381796212195230&a mp;sdata=
Quoted 1 line
BHlWLIhiVEEcRfKVXAQP9ldcyveozTCjpxo%2FrBMLD%2F4%3D&reserved =0
Sure, I am waiting for the cleanup patchset:
With alias set in dtsi, we could remove bind function here to calculate req_seq. So I would send the dtsi patch to Linux/uboot community, and remove the find function.
Do you agree?
Thanks,
Peng.
Quoted 7 lines
https://eur01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fpatch
work.ozlabs.org%2Fproject%2Fuboot%2Fpatch%2F20200916125705.4341-14 -peng.fan%40nxp.com%2F&data=02%7C01%7Cpeng.fan%40nxp.com%7 C9b1ed52ddbf848fff1e408d86f5ddd1e%7C686ea1d3bc2b4c6fa92cd99c5c30 1635%7C0%7C0%7C637381796212195230&sdata=Ofqu3wsb2CmStzt0V dMbotuTeIJyYeQIaCcb%2Bx9sY5Y%3D&reserved=0
PATCH 1/8 tcpc: Add driver for USB typec port controller (TCPC)
Quoted 50 lines · Peng Fan
Quoted 50 lines
Subject: Re: [PATCH 1/8] tcpc: Add driver for USB typec port controller (TCPC)
Quoted 27 lines · Peng Fan
Quoted 27 lines
Subject: Re: [PATCH 1/8] tcpc: Add driver for USB typec port controller (TCPC)
Quoted 12 lines · Peng Fan
Quoted 12 lines
Subject: Re: [PATCH 1/8] tcpc: Add driver for USB typec port controller (TCPC)
On 10/12/20 8:23 AM, Peng Fan wrote:
[...]Quoted 3 lines
board/freescale/common/Kconfig | 6 + board/freescale/common/Makefile | 4 + board/freescale/common/tcpc.c | 1018+++++++++++++++++++++++++++++++
Quoted 3 lines
board/freescale/common/tcpc.h | 469 ++++++++++++++ 4 files changed, 1497 insertions(+) create mode 100644
board/freescale/common/tcpc.ccreate modeQuoted 6 lines
Quoted 4 lines
100644
Quoted 1 line
board/freescale/common/tcpc.hShouldn't driver be in
drivers/?You mean
drivers/usb/typecas kernel?Yes, looks much better than putting drivers into board/ , right ?
Quoted 1 line
There is no common framework now.
Quoted 8 lines
Quoted 1 line
What can we do about that ?
I have no bandwidth to study the new typec area currently. I'll leave this to Jun and Ye.
BTW: are you ok to take the ehci-mx6 patches?
https://eur01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fpatchwork.ozlabs.org%2Fproject%2Fuboot%2Flist%2F%3Fseries%3D202112& ;dat
Quoted 1 line
a=02%7C01%7Cpeng.fan%40nxp.com%7C9b1ed52ddbf848fff1e408d86f5ddd 1e%7C68
Quoted 1 line
6ea1d3bc2b4c6fa92cd99c5c301635%7C0%7C0%7C637381796212195230&a mp;sdata=
Quoted 1 line
BHlWLIhiVEEcRfKVXAQP9ldcyveozTCjpxo%2FrBMLD%2F4%3D&reserved =0
Quoted 7 lines
Quoted 1 line
Sure, I am waiting for the cleanup patchset:
With alias set in dtsi, we could remove bind function here to calculate
req_seq. So I would send the dtsi patch to Linux/uboot community, and remove the find function.Do you agree?
I'm not quite sure what this means, so please send a patch and lets see.
PATCH 2/8 power: regulator: add dummy helper
In reply to Peng FanAdd dummy helper to enabling the header could be included when DM REGULATOR not enabled.
--- include/power/regulator.h | 114 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 114 insertions(+)
include/power/regulator.h +114 -0
@@ -264,6 +264,7 @@ struct dm_regulator_ops {int (*set_mode)(struct udevice *dev,int mode_id); }; +#if CONFIG_IS_ENABLED (DM_REGULATOR )/** * regulator_mode: returns a pointer to the array of regulator mode info *
@@ -524,5 +525,118 @@ int regulator_get_by_platname(const char *platname, struct udevice **devp);*/ int device_get_supply_regulator (struct udevice *dev,const char *supply_name,struct udevice **devp); +#else +static inline int regulator_mode (struct udevice *dev,struct dm_regulator_mode **modep) +{ +return -ENOSYS ; +} + +static inline int regulator_get_value (struct udevice *dev) +{ +return -ENOSYS ; +} + +static inline int regulator_set_value (struct udevice *dev,int uV) +{ +return -ENOSYS ; +} + +static inline int regulator_set_suspend_value (struct udevice *dev,int uV) +{ +return -ENOSYS ; +} + +static inline int regulator_get_suspend_value (struct udevice *dev) +{ +return -ENOSYS ; +} + +static inline int regulator_set_value_force (struct udevice *dev,int uV) +{ +return -ENOSYS ; +} + +static inline int regulator_get_current (struct udevice *dev) +{ +return -ENOSYS ; +} + +static inline int regulator_set_current (struct udevice *dev,int uA) +{ +return -ENOSYS ; +} + +static inline int regulator_get_enable (struct udevice *dev) +{ +return -ENOSYS ; +} + +static inline int regulator_set_enable (struct udevice *dev,bool enable) +{ +return -ENOSYS ; +} + +static inline int regulator_set_enable_if_allowed (struct udevice *dev,bool enable) +{ +return -ENOSYS ; +} + +static inline int regulator_set_suspend_enable (struct udevice *dev,bool enable) +{ +return -ENOSYS ; +} + +static inline int regulator_get_suspend_enable (struct udevice *dev) +{ +return -ENOSYS ; +} + +static inline int regulator_get_mode (struct udevice *dev) +{ +return -ENOSYS ; +} + +static inline int regulator_set_mode (struct udevice *dev,int mode_id) +{ +return -ENOSYS ; +} + +static inline int regulators_enable_boot_on (bool verbose) +{ +return -ENOSYS ; +} + +static inline int regulator_autoset (struct udevice *dev) +{ +return -ENOSYS ; +} + +static inline int regulator_autoset_by_name (const char *platname,struct udevice **devp) +{ +return -ENOSYS ; +} + +static inline int regulator_list_autoset (const char *list_platname[],struct udevice *list_devp[], +bool verbose) +{ +return -ENOSYS ; +} + +static inline int regulator_get_by_devname (const char *devname,struct udevice **devp) +{ +return -ENOSYS ; +} + +static inline int regulator_get_by_platname (const char *platname,struct udevice **devp) +{ +return -ENOSYS ; +} + +static inline int device_get_supply_regulator (struct udevice *dev,const char *supply_name, +struct udevice **devp) +{ +return -ENOSYS ; +} +#endif #endif /* _INCLUDE_REGULATOR_H_ */
Signature · 1 line
2.28.0
PATCH 3/8 phy: nop-phy: add optional clk
In reply to Peng FanAdd optional clk for nop phy
--- drivers/phy/nop-phy.c | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+)
drivers/phy/nop-phy.c +34 -0
@@ -4,17 +4,49 @@* Written by Jean-Jacques Hiblot <[email protected]> */ +#include <clk.h> #include <common.h> #include <dm.h> #include <dm/device.h> #include <generic-phy.h> +struct nop_phy_priv { +struct clk nop_clk; +}; + +static int nop_phy_init (struct phy *phy) +{ +struct nop_phy_priv *priv =dev_get_priv (phy->dev); + +if (!clk_valid (&priv->nop_clk)) +return 0 ; + +return clk_enable (&priv->nop_clk); +} + +static int nop_phy_probe (struct udevice *dev) +{ +struct nop_phy_priv *priv =dev_get_priv (dev); +int ret; + +if (CONFIG_IS_ENABLED (CLK )) { + ret =clk_get_by_name (dev,"main_clk" , &priv->nop_clk); +if (ret <0 && ret != -ENODATA ) { +dev_err (dev,"Failed to get main_clk: %d\n" , ret); +return ret; + } + } + +return 0 ; +} +static const struct udevice_id nop_phy_ids[] = { { .compatible ="nop-phy" }, { } };static struct phy_ops nop_phy_ops = { + .init = nop_phy_init, };U_BOOT_DRIVER (nop_phy) = {
@@ -22,4 +54,6 @@ U_BOOT_DRIVER(nop_phy) = { .id = UCLASS_PHY, .of_match = nop_phy_ids, .ops = &nop_phy_ops, + .probe = nop_phy_probe, + .priv_auto_alloc_size = sizeof(struct nop_phy_priv), };
Signature · 1 line
2.28.0
PATCH 3/8 phy: nop-phy: add optional clk
On 10/12/20 8:23 AM, Peng Fan wrote:
[...]
drivers/phy/nop-phy.c line 33
Quoted 7 lines
drivers/phy/nop-phy.c +7
-0+static int nop_phy_probe (struct udevice *dev) +{ +struct nop_phy_priv *priv =dev_get_priv (dev); +int ret; + +if (CONFIG_IS_ENABLED (CLK )) { + ret =clk_get_by_name (dev,"main_clk" , &priv->nop_clk);
So is this main_clk or nop_clk ?
Wouldn't it be better if the NOP PHY used the clk_bulk and enabled all clock described in DT ?
PATCH 3/8 phy: nop-phy: add optional clk
Quoted 13 lines
Subject: Re: [PATCH 3/8] phy: nop-phy: add optional clk
On 10/12/20 8:23 AM, Peng Fan wrote:
[...]drivers/phy/nop-phy.c line 33
Quoted 6 lines
drivers/phy/nop-phy.c +6
-0+static int nop_phy_probe (struct udevice *dev) { +struct nop_phy_priv *priv =dev_get_priv (dev); +int ret; + +if (CONFIG_IS_ENABLED (CLK )) { + ret =clk_get_by_name (dev,"main_clk" , &priv->nop_clk);So is this
main_clkornop_clk?
Quoted 2 lines
Wouldn't it be better if the NOP PHY used the
clk_bulkand enabled all clock described in DT ?
Bulk seems better.
Thanks,
Peng.
PATCH 4/8 usb: imx: add i.MX usb ehci driver
In reply to Peng FanThis driver is a modifed and cleaned-up version of drivers/usb/host/ehci-mx6.c, it is to replace the original ehci-mx6.c driver.
It dropped the hardcoding code and only support driver model with phy/clk/regulator/etc enabled.
The usbmisc code is handling "fsl,usbmisc" related driver code, similar with Linux Kernel.
--- Makefile | 1 + arch/arm/include/asm/mach-imx/regs-usbphy.h | 5 + arch/arm/include/asm/mach-imx/sys_proto.h | 2 + drivers/Makefile | 1 + drivers/usb/Kconfig | 2 + drivers/usb/imx/Kconfig | 10 + drivers/usb/imx/Makefile | 5 + drivers/usb/imx/ehci-imx.c | 406 ++++++++++++++++++++ drivers/usb/imx/imx-usb-misc.c | 47 +++ 9 files changed, 479 insertions(+) create mode 100644 drivers/usb/imx/Kconfig create mode 100644 drivers/usb/imx/Makefile create mode 100644 drivers/usb/imx/ehci-imx.c create mode 100644 drivers/usb/imx/imx-usb-misc.c
Makefile +1 -0
@@ -799,6 +799,7 @@ libs-y += drivers/usb/musb/ libs-y += drivers/usb/musb-new/ libs-y += drivers/usb/phy/ libs-y += drivers/usb/ulpi/ +libs-y += drivers/usb/imx/ libs-y += cmd/ libs-y += common/ libs-y += env/
arch/arm/include/asm/mach-imx/regs-usbphy.h +5 -0
@@ -7,6 +7,8 @@#ifndef __REGS_USBPHY_H__#define __REGS_USBPHY_H__ +#include <linux/bitops.h> +#define USBPHY_CTRL 0x00000030#define USBPHY_CTRL_SET 0x00000034#define USBPHY_CTRL_CLR 0x00000038
@@ -22,4 +24,7 @@#define USBPHY_CTRL_CLKGATE (1 << 30)#define USBPHY_CTRL_SFTRST (1 << 31) +#define USBNC_PHY_STATUS_OFFSET 0x23C +#define USBNC_PHYSTATUS_ID_DIG BIT(4) +#endif /* __REGS_USBPHY_H__ */
arch/arm/include/asm/mach-imx/sys_proto.h +2 -0
@@ -212,4 +212,6 @@ unsigned long call_imx_sip_ret2(unsigned long id, unsigned long reg0, unsigned long reg3);void imx_get_mac_from_fuse (int dev_id,unsigned char *mac); + +int usbmisc_init (void __iomem *addr,int index);#endif
drivers/Makefile +1 -0
@@ -58,6 +58,7 @@ obj-$(CONFIG_SPL_USB_GADGET) += usb/common/ obj-$(CONFIG_SPL_USB_GADGET) += usb/gadget/udc/ obj-$(CONFIG_SPL_WATCHDOG_SUPPORT) += watchdog/ obj-$(CONFIG_SPL_USB_HOST_SUPPORT) += usb/host/ +obj-$(CONFIG_SPL_USB_HOST_SUPPORT) += usb/imx/ obj-$(CONFIG_OMAP_USB_PHY) += usb/phy/ obj-$(CONFIG_SPL_SATA_SUPPORT) += ata/ scsi/ obj-$(CONFIG_HAVE_BLOCK_DEVICE) += block/
drivers/usb/Kconfig +2 -0
@@ -68,6 +68,8 @@ config SPL_DM_USB_GADGET source "drivers/usb/host/Kconfig" +source "drivers/usb/imx/Kconfig" + source "drivers/usb/cdns3/Kconfig" source "drivers/usb/dwc3/Kconfig"
drivers/usb/imx/Kconfig new file +10 -0
@@ -0,0 +1,10 @@ +if USB_EHCI_HCD + +config USB_EHCI_IMX + bool "Support for i.MX on-chip EHCI USB controller" + depends on IMX8MM || IMX8MN + ---help--- + Enables support for the on-chip EHCI controller on i.MX SoCs. + This is to replace ehci-mx6.c + +endif
drivers/usb/imx/Makefile new file +5 -0
@@ -0,0 +1,5 @@ +# SPDX-License-Identifier: GPL-2.0+ +# +# Copyright 2020 NXP + +obj-$(CONFIG_USB_EHCI_IMX) += ehci-imx.o imx-usb-misc.o
drivers/usb/imx/ehci-imx.c new file +406 -0
406 lines not on this page · raw message
drivers/usb/imx/imx-usb-misc.c new file +47 -0
47 lines not on this page · raw message
Signature · 1 line
2.28.0
PATCH 4/8 usb: imx: add i.MX usb ehci driver
Quoted 5 lines · Peng Fan
This driver is a modifed and cleaned-up version of
drivers/usb/host/ehci-mx6.c, it is to replace the originalehci-mx6.cdriver.It dropped the hardcoding code and only support driver model with phy/clk/regulator/etc enabled.
So now we end up with two drivers ?
Can we rather do like Linux does and have drivers/usb/chipidea , since this controller is chipidea-hdrc and the i.MX extras can then be in ci_hdrc_imx.c or so.
[...]
PATCH 4/8 usb: imx: add i.MX usb ehci driver
Quoted 6 lines
Subject: Re: [PATCH 4/8] usb: imx: add i.MX usb ehci driver
Quoted 3 lines · Peng Fan
This driver is a modifed and cleaned-up version of
drivers/usb/host/ehci-mx6.c, it is to replace the originalehci-mx6.cdriver.
Quoted 8 lines
Quoted 2 lines
It dropped the hardcoding code and only support driver model with phy/clk/regulator/etc enabled.
So now we end up with two drivers ?
Can we rather do like Linux does and have
drivers/usb/chipidea, since this controller is chipidea-hdrc and the i.MX extras can then be inci_hdrc_imx.cor so.
Ah. It is not only ci_hdrc_imx.c, it has core.c, host.c and etc.
Regards,
Peng.
Quoted 2 lines
[...]
PATCH 5/8 imx8m: enable usb power domain
In reply to Peng FanEnable usb power domain, we are not using a power domain driver now. Currently NXP use a ARM SIP based power domain driver, but this has been rejected by Linux Kernel, so we are thinking SCMI, however kernel stuff still not settle down, to make uboot feature work, we directly use SIP call for U-Boot and MMIO for SPL.
--- arch/arm/include/asm/arch-imx8m/sys_proto.h | 1 + arch/arm/mach-imx/imx8m/soc.c | 55 +++++++++++++++++++++ 2 files changed, 56 insertions(+)
arch/arm/include/asm/arch-imx8m/sys_proto.h +1 -0
@@ -11,6 +11,7 @@void set_wdog_reset (struct wdog_regs *wdog);void enable_tzc380 (void );void restore_boot_params (void ); +int imx8m_usb_power (int usb_id,bool on);extern unsigned long rom_pointer[];enum boot_device get_boot_device (void );bool is_usb_boot (void );
arch/arm/mach-imx/imx8m/soc.c +55 -0
58 lines not on this page · raw message
Signature · 1 line
2.28.0
PATCH 5/8 imx8m: enable usb power domain
Quoted 5 lines · Peng Fan
Enable usb power domain, we are not using a power domain driver now. Currently NXP use a ARM SIP based power domain driver, but this has been rejected by Linux Kernel, so we are thinking SCMI, however kernel stuff still not settle down, to make uboot feature work, we directly use SIP call for U-Boot and MMIO for SPL.
The i.MX8M power domain support was already submitted to mainline Linux [1], and it is much nicer to let the OS (or in this case, U-Boot) do that rather than hiding it into ATF.
https://patchwork.kernel.org/project/linux-arm-kernel/list/?series=357903
PATCH 5/8 imx8m: enable usb power domain
Quoted 9 lines
Subject: Re: [PATCH 5/8] imx8m: enable usb power domain
Quoted 5 lines · Peng Fan
Enable usb power domain, we are not using a power domain driver now. Currently NXP use a ARM SIP based power domain driver, but this has been rejected by Linux Kernel, so we are thinking SCMI, however kernel stuff still not settle down, to make uboot feature work, we directly use SIP call for U-Boot and MMIO for SPL.
Quoted 3 lines
The i.MX8M power domain support was already submitted to mainline Linux [1], and it is much nicer to let the OS (or in this case, U-Boot) do that rather than hiding it into ATF.
oh.. that will conflict with NXP release. I not think NXP will use that in a short time.
We wanna use SCMI to hide the complex gpc stuff from Linux side and make us easy support QNX/Windows/Linux.
Regards,
Peng.
Quoted 7 lines
https://eur01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fpatch
work.kernel.org%2Fproject%2Flinux-arm-kernel%2Flist%2F%3Fseries%3D357 903&data=02%7C01%7Cpeng.fan%40nxp.com%7C99fbfc009ea443756b a708d86e8d7387%7C686ea1d3bc2b4c6fa92cd99c5c301635%7C0%7C0%7C6 37380901087950322&sdata=hSo8i19rPKknPY1bSdO64drzgpbpq9zejPFr7 OcAL10%3D&reserved=0
PATCH 5/8 imx8m: enable usb power domain
Quoted 9 lines · Peng Fan
Quoted 9 lines
Subject: Re: [PATCH 5/8] imx8m: enable usb power domain
Quoted 5 lines · Peng Fan
Enable usb power domain, we are not using a power domain driver now. Currently NXP use a ARM SIP based power domain driver, but this has been rejected by Linux Kernel, so we are thinking SCMI, however kernel stuff still not settle down, to make uboot feature work, we directly use SIP call for U-Boot and MMIO for SPL.
Quoted 5 lines
Quoted 3 lines
The i.MX8M power domain support was already submitted to mainline Linux [1], and it is much nicer to let the OS (or in this case, U-Boot) do that rather than hiding it into ATF.
oh.. that will conflict with NXP release. I not think NXP will use that in a short time.
How does it conflict with NXP release ?
Note that I agree with Lucas that power management should be done completely in the OS, the OS knows best what it needs from the hardware. Splitting it between the OS and firmware will only lead to problems, and you often cannot fix those easily as you cannot update the firmware, so that makes it particularly hard for upstream to keep the platform well supported, the OS would have to support all the various firmware versions and its bugs and workarounds for those.
Quoted 2 lines
We wanna use SCMI to hide the complex gpc stuff from Linux side and make us easy support QNX/Windows/Linux.
I think you want to check the argument between Lucas and Jacky, and you might want to discuss it there in fact, so we don't have to duplicate that discussion here .
[...]
PATCH 6/8 imx8mm_evk: add usbotg1 host support
In reply to Peng FanAdd tcpc port and pd switch code board code
Add U-Boot specific dtsi property, we use nop-phy driver for the phy Add relevant config options
Test:
u-boot=> usb start
starting USB...
Bus usb at 32e40000: USB EHCI 1.00
scanning bus usb at 32e40000 for devices... 2 USB Device(s) found
scanning usb for storage devices... 1 Storage Device(s) found
u-boot=> usb tree
USB device tree:
1 Hub (480 Mb/s, 0mA)
| u-boot EHCI Host Controller
|
+-2 Mass Storage (480 Mb/s, 300mA)
Kingston DataTraveler 2.0 50E54951344CB04199CA8CE6
--- arch/arm/dts/imx8mm-evk-u-boot.dtsi | 26 ++++ board/freescale/imx8mm_evk/Kconfig | 1 + board/freescale/imx8mm_evk/imx8mm_evk.c | 181 ++++++++++++++++++++++++ configs/imx8mm_evk_defconfig | 12 ++ include/configs/imx8mm_evk.h | 3 + 5 files changed, 223 insertions(+)
arch/arm/dts/imx8mm-evk-u-boot.dtsi +26 -0
@@ -4,6 +4,12 @@ */ / { + + aliases { + usb0 = &usbotg1; + usb1 = &usbotg2; + }; + wdt-reboot { compatible = "wdt-reboot"; wdt = <&wdog1>;
@@ -129,3 +135,23 @@ &wdog1 { u-boot,dm-spl; }; + +&usbotg1 { + extcon = "tcpc"; + phys = <&usbphynop1>; +}; + +&usbphynop1 { + compatible = "nop-phy"; + #phy-cells = <0>; +}; + +&usbotg2 { + extcon = "tcpc"; + phys = <&usbphynop2>; +}; + +&usbphynop2 { + compatible = "nop-phy"; + #phy-cells = <0>; +};
board/freescale/imx8mm_evk/Kconfig +1 -0
@@ -9,4 +9,5 @@ config SYS_VENDOR config SYS_CONFIG_NAME default "imx8mm_evk" +source "board/freescale/common/Kconfig" endif
board/freescale/imx8mm_evk/imx8mm_evk.c +181 -0
200 lines not on this page · raw message
configs/imx8mm_evk_defconfig +12 -0
@@ -12,12 +12,14 @@ CONFIG_SYS_I2C_MXC_I2C2=y CONFIG_SYS_I2C_MXC_I2C3=y CONFIG_DM_GPIO=y CONFIG_SPL_TEXT_BASE=0x7E1000 +CONFIG_USB_TCPC=y CONFIG_TARGET_IMX8MM_EVK=y CONFIG_SPL_MMC_SUPPORT=y CONFIG_SPL_SERIAL_SUPPORT=y CONFIG_SPL_DRIVERS_MISC_SUPPORT=y CONFIG_SPL=y CONFIG_DEFAULT_DEVICE_TREE="imx8mm-evk" +CONFIG_ANDROID_BOOT_IMAGE=y CONFIG_FIT=y CONFIG_FIT_EXTERNAL_OFFSET=0x3000 CONFIG_SPL_LOAD_FIT=y
@@ -40,6 +42,7 @@ CONFIG_CMD_FUSE=y CONFIG_CMD_GPIO=y CONFIG_CMD_I2C=y CONFIG_CMD_MMC=y +CONFIG_CMD_USB=y CONFIG_CMD_DHCP=y CONFIG_CMD_MII=y CONFIG_CMD_PING=y
@@ -73,6 +76,8 @@ CONFIG_DM_ETH=y CONFIG_PHY_GIGE=y CONFIG_FEC_MXC=y CONFIG_MII=y +CONFIG_PHY=y +CONFIG_NOP_PHY=y CONFIG_PINCTRL=y CONFIG_SPL_PINCTRL=y CONFIG_PINCTRL_IMX8M=y
@@ -87,4 +92,11 @@ CONFIG_SPL_SYSRESET=y CONFIG_SYSRESET_PSCI=y CONFIG_SYSRESET_WATCHDOG=y CONFIG_DM_THERMAL=y +CONFIG_USB=y +CONFIG_DM_USB=y +# CONFIG_SPL_DM_USB is not set +CONFIG_USB_EHCI_HCD=y +# CONFIG_USB_EHCI_MX7 is not set +CONFIG_USB_EHCI_IMX=y +CONFIG_USB_STORAGE=y CONFIG_IMX_WATCHDOG=y
include/configs/imx8mm_evk.h +3 -0
@@ -145,4 +145,7 @@#define IMX_FEC_BASE 0x30BE0000 +#define CONFIG_MXC_USB_PORTSC (PORT_PTS_UTMI | PORT_PTS_PTW) +#define CONFIG_USB_MAX_CONTROLLER_COUNT 2 +#endif
Signature · 1 line
2.28.0
PATCH 7/8 usb: ci_udc: Convert driver to DM_USB_GADGET
In reply to Peng FanFrom: Sherry Sun <[email protected]>
Convert the ci_udc driver to driver model by using the uclass UCLASS_USB_GADGET_GENERIC. The clk and power of USB controller and USB PHY both are initialized by parsing the device tree nodes.
If CONFIG_DM_USB_GADGET is defined, we use the ci_udc driver in DM way, if it does not defined, we can use ci_udc driver in its original Non-DM way.
--- drivers/usb/gadget/ci_udc.c | 305 +++++++++++++++++++++++++++++++++++- drivers/usb/host/ehci-mx6.c | 15 +- include/usb/ci_udc.h | 3 + 3 files changed, 305 insertions(+), 18 deletions(-)
drivers/usb/gadget/ci_udc.c +301 -4
@@ -13,16 +13,25 @@#include <cpu_func.h> #include <net.h> #include <malloc.h> +#include <dm.h> +#include <clk.h> +#include <power-domain.h> #include <asm/byteorder.h> #include <asm/cache.h> #include <linux/delay.h> #include <linux/errno.h> #include <asm/io.h> #include <asm/unaligned.h> +#include <asm/arch/sys_proto.h> +#include <asm/arch/clock.h> +#include <asm/mach-imx/regs-usbphy.h> #include <linux/types.h> #include <linux/usb/ch9.h> #include <linux/usb/gadget.h> +#include <linux/usb/otg.h> +#include <dm/pinctrl.h> #include <usb/ci_udc.h> +#include <usb/ehci-ci.h> #include "../host/ehci.h" #include "ci_udc.h"
@@ -93,9 +102,18 @@ static int ci_ep_dequeue(struct usb_ep *ep, struct usb_request *req);static struct usb_request *ci_ep_alloc_request (struct usb_ep *ep,unsigned int gfp_flags);static void ci_ep_free_request (struct usb_ep *ep,struct usb_request *_req); +#if CONFIG_IS_ENABLED (DM_USB_GADGET ) +static int ci_udc_gadget_start (struct usb_gadget *g, +struct usb_gadget_driver *driver); +static int ci_udc_gadget_stop (struct usb_gadget *g); +#endif static struct usb_gadget_ops ci_udc_ops = { .pullup = ci_pullup, +#if CONFIG_IS_ENABLED(DM_USB_GADGET) + .udc_start = ci_udc_gadget_start, + .udc_stop = ci_udc_gadget_stop, +#endif };static struct usb_ep_ops ci_ep_ops = {
@@ -866,7 +884,7 @@ void udc_irq(void) } } -int usb_gadget_handle_interrupts (int index) +int ci_udc_handle_interrupts (void ) {u32 value;struct ci_udc *udc = (struct ci_udc *)controller.ctrl->hcor;
@@ -1010,6 +1028,19 @@ static int ci_udc_probe(void)return 0 ; } +bool dfu_usb_get_reset (void ) +{ +struct ci_udc *udc = (struct ci_udc *)controller.ctrl->hcor; + +return !!(readl (&udc->usbsts) &STS_URI ); +} + +#if !CONFIG_IS_ENABLED (DM_USB_GADGET ) +int usb_gadget_handle_interrupts (int index) +{ +return ci_udc_handle_interrupts (); +} +int usb_gadget_register_driver (struct usb_gadget_driver *driver) {int ret;
@@ -1063,10 +1094,276 @@ int usb_gadget_unregister_driver(struct usb_gadget_driver *driver)return 0 ; } +#else /* !CONFIG_IS_ENABLED(DM_USB_GADGET) */ -bool dfu_usb_get_reset (void ) +static int ci_udc_gadget_start (struct usb_gadget *g, +struct usb_gadget_driver *driver) { -struct ci_udc *udc = (struct ci_udc *)controller.ctrl->hcor; +if (!driver) +return -EINVAL ; +if (!driver->bind || !driver->setup || !driver->disconnect) +return -EINVAL ; -return !!(readl (&udc->usbsts) &STS_URI ); + controller.driver = driver; +return 0 ; +} + +static int ci_udc_gadget_stop (struct usb_gadget *g) +{ + controller.driver =NULL ; + +ci_ep_free_request (&controller.ep[0 ].ep, &controller.ep0_req->req); +free (controller.items_mem); +free (controller.epts); +return 0 ; +} + +struct ci_udc_priv_data { +struct ehci_ctrl ctrl; +struct udevice otgdev; +struct clk_bulk clks; +int phy_off; +struct power_domain otg_pd; +struct clk phy_clk; +struct power_domain phy_pd; +}; + +int dm_usb_gadget_handle_interrupts (struct udevice *dev) +{ +return ci_udc_handle_interrupts (); +} + +static int ci_udc_phy_setup (struct udevice *dev,struct ci_udc_priv_data *priv) +{ +struct udevice __maybe_unused phy_dev; + priv->phy_off =fdtdec_lookup_phandle (gd->fdt_blob, +dev_of_offset (dev), +"fsl,usbphy" ); +if (priv->phy_off <0 ) +return -EINVAL ; + + phy_dev.node =offset_to_ofnode (priv->phy_off); + +#if CONFIG_IS_ENABLED (POWER_DOMAIN ) +/* Need to power on the PHY before access it */ +if (!power_domain_get (&phy_dev, &priv->phy_pd)) { +if (power_domain_on (&priv->phy_pd)) +return -EINVAL ; + } +#endif + +#if CONFIG_IS_ENABLED (CLK ) +int ret; + + ret =clk_get_by_index (&phy_dev,0 , &priv->phy_clk); +if (ret) { +printf ("Failed to get phy_clk\n" ); +return ret; + } + + ret =clk_enable (&priv->phy_clk); +if (ret) { +printf ("Failed to enable phy_clk\n" ); +return ret; + } +#endif + +return 0 ; +} + +static int ci_udc_phy_shutdown (struct ci_udc_priv_data *priv) +{ +int ret =0 ; + +#if CONFIG_IS_ENABLED (CLK ) +if (priv->phy_clk.dev) { + ret =clk_disable (&priv->phy_clk); +if (ret) +return ret; + + ret =clk_free (&priv->phy_clk); +if (ret) +return ret; + } +#endif + +#if CONFIG_IS_ENABLED (POWER_DOMAIN ) + ret =power_domain_off (&priv->phy_pd); +if (ret) +printf ("Power down USB PHY failed! (error = %d)\n" , ret); +#endif +return ret; +} + +static int ci_udc_otg_clk_init (struct udevice *dev, +struct clk_bulk *clks) +{ +int ret; + + ret =clk_get_bulk (dev, clks); +if (ret == -ENOSYS ) +return 0 ; + +if (ret) +return ret; + +#if CONFIG_IS_ENABLED (CLK ) + ret =clk_enable_bulk (clks); +if (ret) { +clk_release_bulk (clks); +return ret; + } +#endif + +return 0 ; +} + +static int ci_udc_otg_phy_mode (struct udevice *dev) +{ +struct ci_udc_priv_data *priv =dev_get_priv (dev); + +void *__iomem phy_ctrl, *__iomem phy_status; +void *__iomem phy_base = (void *__iomem )devfdt_get_addr (&priv->otgdev); +u32 val; + +if (is_mx6 () ||is_mx7ulp () ||is_imx8 ()) { + phy_base = (void __iomem *)fdtdec_get_addr (gd->fdt_blob, + priv->phy_off, +"reg" ); +if ((fdt_addr_t )phy_base ==FDT_ADDR_T_NONE ) +return -EINVAL ; + + phy_ctrl = (void __iomem *)(phy_base +USBPHY_CTRL ); + val =readl (phy_ctrl); +if (val &USBPHY_CTRL_OTG_ID ) +return USB_INIT_DEVICE ; +else +return USB_INIT_HOST ; + }else if (is_mx7 () ||is_imx8mm () ||is_imx8mn ()) { + phy_status = (void __iomem *)(phy_base + +USBNC_PHY_STATUS_OFFSET ); + val =readl (phy_status); +if (val &USBNC_PHYSTATUS_ID_DIG ) +return USB_INIT_DEVICE ; +else +return USB_INIT_HOST ; + }else { +return -EINVAL ; + } +} + +static int ci_udc_otg_ofdata_to_platdata (struct udevice *dev) +{ +struct ci_udc_priv_data *priv =dev_get_priv (dev); +int node =dev_of_offset (dev); +int usbotg_off; + +if (usb_get_dr_mode (dev_ofnode (dev)) !=USB_DR_MODE_PERIPHERAL ) { +dev_dbg (dev,"Invalid mode\n" ); +return -ENODEV ; + } + + usbotg_off =fdtdec_lookup_phandle (gd->fdt_blob, + node, +"chipidea,usb" ); +if (usbotg_off <0 ) +return -EINVAL ; + priv->otgdev.node =offset_to_ofnode (usbotg_off); + priv->otgdev.parent = dev->parent; + +return 0 ; +} + +static int ci_udc_otg_probe (struct udevice *dev) +{ +struct ci_udc_priv_data *priv =dev_get_priv (dev); +struct usb_ehci *ehci; +int ret; + + ehci = (struct usb_ehci *)devfdt_get_addr (&priv->otgdev); + +pinctrl_select_state (&priv->otgdev,"default" ); + +#if defined(CONFIG_MX6 ) +if (mx6_usb_fused ((u32 )ehci)) { +printf ("USB at 0x%x is fused, disable it\n" , (u32 )ehci); +return -ENODEV ; + } +#endif + + ret =board_usb_init (dev->seq,USB_INIT_DEVICE ); +if (ret) { +printf ("Failed to initialize board for USB\n" ); +return ret; + } + +#if CONFIG_IS_ENABLED (POWER_DOMAIN ) +if (!power_domain_get (&priv->otgdev, &priv->otg_pd)) { +if (power_domain_on (&priv->otg_pd)) +return -EINVAL ; + } +#endif + + ret =ci_udc_phy_setup (&priv->otgdev, priv); +if (ret) +return ret; + + ret =ci_udc_otg_clk_init (&priv->otgdev, &priv->clks); +if (ret) +return ret; + +if (ci_udc_otg_phy_mode (dev) !=USB_INIT_DEVICE ) +return -ENODEV ; + + priv->ctrl.hccr = (struct ehci_hccr *)((ulong)&ehci->caplength); + priv->ctrl.hcor = (struct ehci_hcor *)((ulong )priv->ctrl.hccr + +HC_LENGTH (ehci_readl (&(priv->ctrl.hccr)->cr_capbase))); + controller.ctrl = &priv->ctrl; + + ret =ci_udc_probe (); +if (ret) { +DBG ("udc probe failed, returned %d\n" , ret); +return ret; + } + + ret =usb_add_gadget_udc ((struct device *)dev, &controller.gadget); + +return ret; +} + +static int ci_udc_otg_remove (struct udevice *dev) +{ +struct ci_udc_priv_data *priv =dev_get_priv (dev); + +usb_del_gadget_udc (&controller.gadget); + +clk_release_bulk (&priv->clks); +ci_udc_phy_shutdown (priv); +#if CONFIG_IS_ENABLED (POWER_DOMAIN ) +if (power_domain_off (&priv->otg_pd)) { +printf ("Power down USB controller failed!\n" ); +return -EINVAL ; + } +#endif +board_usb_cleanup (dev->seq,USB_INIT_DEVICE ); + + controller.ctrl =NULL ; +return 0 ; } + +static const struct udevice_id ci_udc_otg_ids[] = { + { .compatible ="fsl,imx27-usb-gadget" }, + { } +}; + +U_BOOT_DRIVER (ci_udc_otg) = { + .name ="ci-udc-otg" , + .id =UCLASS_USB_GADGET_GENERIC , + .of_match = ci_udc_otg_ids, + .ofdata_to_platdata = ci_udc_otg_ofdata_to_platdata, + .probe = ci_udc_otg_probe, + .remove = ci_udc_otg_remove, + .priv_auto_alloc_size =sizeof (struct ci_udc_priv_data ), +}; + +#endif /* !CONFIG_IS_ENABLED(DM_USB_GADGET) */
drivers/usb/host/ehci-mx6.c +1 -14
@@ -17,6 +17,7 @@#include <asm/arch/imx-regs.h> #include <asm/arch/clock.h> #include <asm/mach-imx/iomux-v3.h> +#include <asm/mach-imx/regs-usbphy.h> #include <asm/mach-imx/sys_proto.h> #include <dm.h> #include <asm/mach-types.h>
@@ -37,18 +38,6 @@ DECLARE_GLOBAL_DATA_PTR;#define USB_H1_CTRL_OFFSET 0x04 -#define USBPHY_CTRL 0x00000030 -#define USBPHY_CTRL_SET 0x00000034 -#define USBPHY_CTRL_CLR 0x00000038 -#define USBPHY_CTRL_TOG 0x0000003c - -#define USBPHY_PWD 0x00000000 -#define USBPHY_CTRL_SFTRST 0x80000000 -#define USBPHY_CTRL_CLKGATE 0x40000000 -#define USBPHY_CTRL_ENUTMILEVEL3 0x00008000 -#define USBPHY_CTRL_ENUTMILEVEL2 0x00004000 -#define USBPHY_CTRL_OTG_ID 0x08000000 -#define ANADIG_USB2_CHRG_DETECT_EN_B 0x00100000#define ANADIG_USB2_CHRG_DETECT_CHK_CHRG_B 0x00080000
@@ -58,8 +47,6 @@ DECLARE_GLOBAL_DATA_PTR;#define ANADIG_USB2_PLL_480_CTRL_EN_USB_CLKS 0x00000040#define USBNC_OFFSET 0x200 -#define USBNC_PHY_STATUS_OFFSET 0x23C -#define USBNC_PHYSTATUS_ID_DIG (1 << 4)/* otg_id status */ #define USBNC_PHYCFG2_ACAENB (1 << 4)/* otg_id detection enable */ #define UCTRL_PWR_POL (1 << 9)/* OTG Polarity of Power Pin */ #define UCTRL_OVER_CUR_POL (1 << 8)/* OTG Polarity of Overcurrent */
include/usb/ci_udc.h +3 -0
@@ -7,7 +7,10 @@#ifndef __CI_UDC_H__#define __CI_UDC_H__ +#include <usb/ehci-ci.h> #define EP_MAX_PACKET_SIZE 0x200#define EP0_MAX_PACKET_SIZE 64 + +int ehci_mx6_common_init (struct usb_ehci *ehci,int index);#endif /* __CI_UDC_H__ */
Signature · 1 line
2.28.0
PATCH 7/8 usb: ci_udc: Convert driver to DM_USB_GADGET
Dear Peng Fan,
Quoted 4 lines · In message <[email protected]> you wrote:
Convert the
ci_udcdriver to driver model by using the uclassUCLASS_USB_GADGET_GENERIC. The clk and power of USB controller and USB PHY both are initialized by parsing the device tree nodes.
...
drivers/usb/gadget/ci_udc.c int usb_gadget_unregister_driver(struct usb_gadget_driver *driver) · line 1357
Quoted 4 lines
drivers/usb/gadget/ci_udc.c +4
-0+static const struct udevice_id ci_udc_otg_ids[] = { + { .compatible ="fsl,imx27-usb-gadget" }, + { } +};
What is imx27-usb-gadget ?
Best regards,
Wolfgang Denk
Signature · 5 lines
DENX Software Engineering GmbH, Managing Director: Wolfgang Denk HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de There are no data that cannot be plotted on a straight line if the axis are chosen correctly.
PATCH 7/8 usb: ci_udc: Convert driver to DM_USB_GADGET
Quoted 9 lines
Subject: Re: [PATCH 7/8] usb:
ci_udc: Convert driver toDM_USB_GADGETDear Peng Fan,
Quoted 3 lines · In message <[email protected]> you wrote:
Convert the
ci_udcdriver to driver model by using the uclassUCLASS_USB_GADGET_GENERIC. The clk and power of USB controller andUSB
Quoted 8 lines
Quoted 1 line
PHY both are initialized by parsing the device tree nodes.
...
drivers/usb/gadget/ci_udc.c int usb_gadget_unregister_driver(struct usb_gadget_driver *driver) · line 1357
Quoted 4 lines
drivers/usb/gadget/ci_udc.c +4
-0+static const struct udevice_id ci_udc_otg_ids[] = { + { .compatible ="fsl,imx27-usb-gadget" }, + { } +};What is imx27-usb-gadget ?
This U-Boot specific compatible string. I have no better idea what we need use here to make DM driver work.
Thanks,
Peng.
Quoted 12 lines
Best regards,
Wolfgang Denk
--
DENX Software Engineering GmbH, Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de There are no data that cannot be plotted on a straight line if the axis are chosen correctly.
PATCH 7/8 usb: ci_udc: Convert driver to DM_USB_GADGET
Dear Peng Fan,
Quoted 10 lines · In message <DB6PR0402MB2760A2A57D48AED93592962488160@DB6PR0402MB2760.eurprd04.p…
Quoted 7 lines
drivers/usb/gadget/ci_udc.c int usb_gadget_unregister_driver(struct usb_gadget_driver *driver) · line 1357
Quoted 5 lines
drivers/usb/gadget/ci_udc.c +4
-0+static const struct udevice_id ci_udc_otg_ids[] = { + { .compatible ="fsl,imx27-usb-gadget" }, + { } +};What is imx27-usb-gadget ?
This U-Boot specific compatible string. I have no better idea what we need use here to make DM driver work.
But what is "imx27" ? This is a i.MX8M family platform, right?
Not ancient i.MX27 ?
Best regards,
Wolfgang Denk
Signature · 5 lines
DENX Software Engineering GmbH, Managing Director: Wolfgang Denk HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de "Well I don't see why I have to make one man miserable when I can make so many men happy." - Ellyn Mustard, about marriage
PATCH 7/8 usb: ci_udc: Convert driver to DM_USB_GADGET
Quoted 15 lines
Subject: Re: [PATCH 7/8] usb:
ci_udc: Convert driver toDM_USB_GADGETDear Peng Fan,
In message <DB6PR0402MB2760A2A57D48AED93592962488160@DB6PR0402MB2760.
Quoted 8 lines · eurprd04.prod.outlook.com> you wrote:
Quoted 7 lines
drivers/usb/gadget/ci_udc.c int usb_gadget_unregister_driver(struct usb_gadget_driver *driver) · line 1357
Quoted 5 lines
drivers/usb/gadget/ci_udc.c +4
-0+static const struct udevice_id ci_udc_otg_ids[] = { + { .compatible ="fsl,imx27-usb-gadget" }, + { } +};What is imx27-usb-gadget ?
Quoted 5 lines
Quoted 2 lines
This U-Boot specific compatible string. I have no better idea what we need use here to make DM driver work.
But what is "imx27" ? This is a i.MX8M family platform, right?
Not ancient i.MX27 ?
This is just a compatible string means all controllers compatible with i.MX27 USB could use this driver.
Yes this is for i.MX8MM, but the usb gadget feature could reuse the i.MX27 code.
Thanks,
Peng.
Quoted 11 lines
Best regards,
Wolfgang Denk
--
DENX Software Engineering GmbH, Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de "Well I don't see why I have to make one man miserable when I can
make so many men happy." - Ellyn Mustard, about marriage
PATCH 7/8 usb: ci_udc: Convert driver to DM_USB_GADGET
Dear Peng Fan,
Quoted 11 lines · In message <DB6PR0402MB2760ECB86DD133520449792C88160@DB6PR0402MB2760.eurprd04.p…
Quoted 11 lines
Quoted 10 lines
Quoted 7 lines
drivers/usb/gadget/ci_udc.c int usb_gadget_unregister_driver(struct usb_gadget_driver *driver) · line 1357
Quoted 5 lines
drivers/usb/gadget/ci_udc.c +4
-0+static const struct udevice_id ci_udc_otg_ids[] = { + { .compatible ="fsl,imx27-usb-gadget" }, + { } +};What is imx27-usb-gadget ?
This U-Boot specific compatible string. I have no better idea what we need use here to make DM driver work.
Quoted 8 lines
Quoted 2 lines
But what is "imx27" ? This is a i.MX8M family platform, right?
Not ancient i.MX27 ?This is just a compatible string means all controllers compatible with i.MX27 USB could use this driver.
Yes this is for i.MX8MM, but the usb gadget feature could reuse the i.MX27 code.
Maybe I'm missing something, but I cannot find imx27-usb-gadget being used anywhere - not in U-Boot nor in Linux mainline ?
And if we introduce this completely new - then why imx27 ?
Best regards,
Wolfgang Denk
Signature · 5 lines
DENX Software Engineering GmbH, Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de
If you think the problem is bad now, just wait until we've solved it.
Epstein's LawPATCH 7/8 usb: ci_udc: Convert driver to DM_USB_GADGET
Quoted 24 lines
Subject: Re: [PATCH 7/8] usb:
ci_udc: Convert driver toDM_USB_GADGETDear Peng Fan,
In message <DB6PR0402MB2760ECB86DD133520449792C88160@DB6PR0402MB2760.
Quoted 17 lines · eurprd04.prod.outlook.com> you wrote:
Quoted 8 lines
Quoted 8 lines
Quoted 7 lines
drivers/usb/gadget/ci_udc.c int usb_gadget_unregister_driver(struct usb_gadget_driver *driver) · line 1357
Quoted 5 lines
drivers/usb/gadget/ci_udc.c +4
-0+static const struct udevice_id ci_udc_otg_ids[] = { + { .compatible ="fsl,imx27-usb-gadget" }, + { } +};What is imx27-usb-gadget ?
Quoted 5 lines
Quoted 2 lines
This U-Boot specific compatible string. I have no better idea what we need use here to make DM driver work.
But what is "imx27" ? This is a i.MX8M family platform, right?
Not ancient i.MX27 ?This is just a compatible string means all controllers compatible with i.MX27 USB could use this driver.
Quoted 7 lines
Quoted 2 lines
Yes this is for i.MX8MM, but the usb gadget feature could reuse the i.MX27 code.
Maybe I'm missing something, but I cannot find imx27-usb-gadget being used anywhere - not in U-Boot nor in Linux mainline ?
And if we introduce this completely new - then why imx27 ?
ci udc driver is an driver long exist there.
This is just switch to driver module support. Not completely new.
I could use imx6-usb-gadget, but that means need add one more for i.MX5 if need.
Thanks,
Peng.
Quoted 12 lines
Best regards,
Wolfgang Denk
--
DENX Software Engineering GmbH, Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de If you think the problem is bad now, just wait until we've solved it.Epstein's Law
PATCH 7/8 usb: ci_udc: Convert driver to DM_USB_GADGET
Dear Peng Fan,
Quoted 5 lines · In message <DB6PR0402MB2760CF94CA69EACD95DE978588160@DB6PR0402MB2760.eurprd04.p…
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
(quoted diff) +4
-0+static const struct udevice_id ci_udc_otg_ids[] = { + { .compatible = "fsl,imx27-usb-gadget" }, + { } +};
...
Quoted 6 lines
Quoted 4 lines
Maybe I'm missing something, but I cannot find imx27-usb-gadget being used anywhere - not in U-Boot nor in Linux mainline ?
And if we introduce this completely new - then why imx27 ?
ci udc driver is an driver long exist there.
Agreed. But as far as I can see, no parts of the driver code contain any references to imx27 (or even imx in general) at all.
Quoted 1 line
This is just switch to driver module support. Not completely new.
The compatible string "fsl,imx27-usb-gadget" is completely new.
We have all kinds of "fsl,imx27-usb" in U-Boot and Linux, but I wonder what the rationale is there as well. I cannot find it documented anywhere.
All I can see is a comment
"fsl,imx23-usbphy" is still a fallback for other strings
in Documentation/devicetree/bindings/phy/mxs-usb-phy.txt, but this is for the USB PHY.
Yes, "fsl,imx27-usb" is being used a lot, but there are things which look inconsistent to me; we have for example:
- "fsl,imx6ul-usb" in Linux arch/arm/boot/dts/imx7ulp.dtsi , but "fsl,imx27-usb" in U-Boot arch/arm/dts/imx7ulp.dtsi And actually arch/arm/boot/dts/imx6ul.dtsi then uses compatible = "fsl,imx6ul-usb", "fsl,imx27-usb";
- "fsl,imx7d-usb" in Linux arch/arm64/boot/dts/freescale/imx8mn.dtsi and the same in U-Boot arch/arm/dts/imx8mn.dtsi
- "fsl,imx7d-usb" in Linux arch/arm64/boot/dts/freescale/imx8mm.dtsi and the same in U-Boot arch/arm/dts/imx8mm.dtsi
Quoted 2 lines
I could use imx6-usb-gadget, but that means need add one more for i.MX5 if need.
If you use "fsl,imx7d-usb" on the imx8mm, then would it not be logical to use ""fsl,imx7d-usb-gadget"?
I'm trying to make sense from all these compatible strings, but it looks pretty much random to me, so if we add to this we should at least not increase the confusion.
Best regards,
Wolfgang Denk
Signature · 6 lines
DENX Software Engineering GmbH, Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de
That said, there may be good reasons for what you did beyond obsequi-
ous sycophantic parody. Perhaps you might be so kind as to elucidate.
-- Tom Christiansen in <[email protected]>PATCH 8/8 imx8mm_evk: add fastboot support
In reply to Peng FanAdd fastboot support for U-Boot proper
--- arch/arm/dts/imx8mm-evk-u-boot.dtsi | 17 +++++++++++++++++ configs/imx8mm_evk_defconfig | 13 ++++++++++++- include/configs/imx8mm_evk.h | 14 ++++++++++++++ 3 files changed, 43 insertions(+), 1 deletion(-)
arch/arm/dts/imx8mm-evk-u-boot.dtsi +17 -0
@@ -6,6 +6,8 @@ / { aliases { + usbgadget0 = &usbg1; + usbgadget1 = &usbg2; usb0 = &usbotg1; usb1 = &usbotg2; };
@@ -15,6 +17,21 @@ wdt = <&wdog1>; u-boot,dm-spl; }; + + usbg1: usbg1 { + compatible = "fsl,imx27-usb-gadget"; + dr_mode = "peripheral"; + chipidea,usb = <&usbotg1>; + status = "okay"; + }; + + usbg2: usbg2 { + compatible = "fsl,imx27-usb-gadget"; + dr_mode = "peripheral"; + chipidea,usb = <&usbotg2>; + status = "okay"; + }; + }; &{/soc at 0} {
configs/imx8mm_evk_defconfig +12 -1
@@ -19,7 +19,6 @@ CONFIG_SPL_SERIAL_SUPPORT=y CONFIG_SPL_DRIVERS_MISC_SUPPORT=y CONFIG_SPL=y CONFIG_DEFAULT_DEVICE_TREE="imx8mm-evk" -CONFIG_ANDROID_BOOT_IMAGE=y CONFIG_FIT=y CONFIG_FIT_EXTERNAL_OFFSET=0x3000 CONFIG_SPL_LOAD_FIT=y
@@ -64,6 +63,11 @@ CONFIG_SPL_CLK_COMPOSITE_CCF=y CONFIG_CLK_COMPOSITE_CCF=y CONFIG_SPL_CLK_IMX8MM=y CONFIG_CLK_IMX8MM=y +CONFIG_USB_FUNCTION_FASTBOOT=y +CONFIG_FASTBOOT_BUF_ADDR=0x42800000 +CONFIG_FASTBOOT_BUF_SIZE=0x40000000 +CONFIG_FASTBOOT_FLASH=y +CONFIG_FASTBOOT_FLASH_MMC_DEV=1 CONFIG_MXC_GPIO=y CONFIG_DM_I2C=y CONFIG_SYS_I2C_MXC=y
@@ -95,8 +99,15 @@ CONFIG_DM_THERMAL=y CONFIG_USB=y CONFIG_DM_USB=y # CONFIG_SPL_DM_USB is not set +CONFIG_DM_USB_GADGET=y CONFIG_USB_EHCI_HCD=y # CONFIG_USB_EHCI_MX7 is not set CONFIG_USB_EHCI_IMX=y CONFIG_USB_STORAGE=y +CONFIG_USB_GADGET=y +CONFIG_USB_GADGET_MANUFACTURER="FSL" +CONFIG_USB_GADGET_VENDOR_NUM=0x0525 +CONFIG_USB_GADGET_PRODUCT_NUM=0xa4a5 +CONFIG_CI_UDC=y +CONFIG_SDP_LOADADDR=0x40400000 CONFIG_IMX_WATCHDOG=y
include/configs/imx8mm_evk.h +14 -0
@@ -148,4 +148,18 @@#define CONFIG_MXC_USB_PORTSC (PORT_PTS_UTMI | PORT_PTS_PTW)#define CONFIG_USB_MAX_CONTROLLER_COUNT 2 +#define CONFIG_FASTBOOT_USB_DEV 0 + +/* USB configs */ +#ifndef CONFIG_SPL_BUILD +#define CONFIG_USBD_HS + +#define CONFIG_CMD_USB_MASS_STORAGE +#define CONFIG_USB_GADGET_MASS_STORAGE +#define CONFIG_USB_FUNCTION_MASS_STORAGE + +#endif + +#define CONFIG_USB_GADGET_VBUS_DRAW 2 +#endif
Signature · 1 line
2.28.0
PATCH 8/8 imx8mm_evk: add fastboot support
Dear Peng Fan,
Quoted 1 line · In message <[email protected]> you wrote:
Add fastboot support for U-Boot proper
...
arch/arm/dts/imx8mm-evk-u-boot.dtsi line 33
Quoted 13 lines
arch/arm/dts/imx8mm-evk-u-boot.dtsi +13
-0+ usbg1: usbg1 { + compatible = "fsl,imx27-usb-gadget"; + dr_mode = "peripheral"; + chipidea,usb = <&usbotg1>; + status = "okay"; + }; + + usbg2: usbg2 { + compatible = "fsl,imx27-usb-gadget"; + dr_mode = "peripheral"; + chipidea,usb = <&usbotg2>; + status = "okay"; + };
What is imx27-usb-gadget ?
Best regards,
Wolfgang Denk
Signature · 5 lines
DENX Software Engineering GmbH, Managing Director: Wolfgang Denk HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de "The algorithm to do that is extremely nasty. You might want to mug someone with it." - M. Devine, Computer Science 340
PATCH 8/8 imx8mm_evk: add fastboot support
Quoted 9 lines
Subject: Re: [PATCH 8/8]
imx8mm_evk: add fastboot supportDear Peng Fan,
Quoted 1 line · In message <[email protected]> you wrote:
Add fastboot support for U-Boot proper
...
Quoted 15 lines
arch/arm/dts/imx8mm-evk-u-boot.dtsi line 33
Quoted 13 lines
arch/arm/dts/imx8mm-evk-u-boot.dtsi +13
-0+ usbg1: usbg1 { + compatible = "fsl,imx27-usb-gadget"; + dr_mode = "peripheral"; + chipidea,usb = <&usbotg1>; + status = "okay"; + }; + + usbg2: usbg2 { + compatible = "fsl,imx27-usb-gadget"; + dr_mode = "peripheral"; + chipidea,usb = <&usbotg2>; + status = "okay"; + };What is imx27-usb-gadget ?
This is U-Boot specific compatible to let theci_udc driver could match the node.
Thanks,
Peng.
Quoted 13 lines
Best regards,
Wolfgang Denk
--
DENX Software Engineering GmbH, Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de "The algorithm to do that is extremely nasty. You might want to mug
someone with it." - M. Devine, Computer Science 340