Message ID | 20201012062354.3743-6-peng.fan@nxp.com |
---|---|
State | New |
Headers | show |
Series | i.MX8MM: add host/gadget support | expand |
On 10/12/20 8:23 AM, Peng Fan wrote: > 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
> Subject: Re: [PATCH 5/8] imx8m: enable usb power domain > > On 10/12/20 8:23 AM, Peng Fan wrote: > > 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. 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. > > 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
On 10/12/20 11:20 AM, Peng Fan wrote: >> Subject: Re: [PATCH 5/8] imx8m: enable usb power domain >> >> On 10/12/20 8:23 AM, Peng Fan wrote: >>> 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. > > 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. > 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 . [...]
diff --git a/arch/arm/include/asm/arch-imx8m/sys_proto.h b/arch/arm/include/asm/arch-imx8m/sys_proto.h index d328542ece..3e54f9b676 100644 --- a/arch/arm/include/asm/arch-imx8m/sys_proto.h +++ b/arch/arm/include/asm/arch-imx8m/sys_proto.h @@ -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); diff --git a/arch/arm/mach-imx/imx8m/soc.c b/arch/arm/mach-imx/imx8m/soc.c index 9bca5bf972..830d1ac901 100644 --- a/arch/arm/mach-imx/imx8m/soc.c +++ b/arch/arm/mach-imx/imx8m/soc.c @@ -1112,3 +1112,58 @@ long long env_get_offset(long long defautl_offset) } #endif #endif + +#ifdef CONFIG_SPL_BUILD +static uint32_t gpc_pu_m_core_offset[11] = { + 0xc00, 0xc40, 0xc80, 0xcc0, + 0xdc0, 0xe00, 0xe40, 0xe80, + 0xec0, 0xf00, 0xf40, +}; + +#define PGC_PCR 0 + +void imx_gpc_set_m_core_pgc(unsigned int offset, bool pdn) +{ + uint32_t val; + uintptr_t reg = GPC_BASE_ADDR + offset; + + val = readl(reg); + val &= ~(0x1 << PGC_PCR); + + if(pdn) + val |= 0x1 << PGC_PCR; + writel(val, reg); +} + +void imx8m_usb_power_domain(uint32_t domain_id, bool on) +{ + uint32_t val; + uintptr_t reg; + + imx_gpc_set_m_core_pgc(gpc_pu_m_core_offset[domain_id], true); + + reg = GPC_BASE_ADDR + (on ? 0xf8 : 0x104); + val = 1 << (domain_id > 3 ? (domain_id + 3) : domain_id); + writel(val, reg); + while (readl(reg) & val) + ; + imx_gpc_set_m_core_pgc(gpc_pu_m_core_offset[domain_id], false); +} +#endif + +int imx8m_usb_power(int usb_id, bool on) +{ + if (usb_id > 1) + return -EINVAL; + +#ifdef CONFIG_SPL_BUILD + imx8m_usb_power_domain(2 + usb_id, on); +#else + struct arm_smccc_res res; + + /* Get ARM Trusted Firmware commit id */ + arm_smccc_smc(IMX_SIP_GPC, IMX_SIP_GPC_PM_DOMAIN, 2 + usb_id, on, 0, 0, 0, 0, &res); +#endif + + return 0; +}
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. Signed-off-by: Peng Fan <peng.fan@nxp.com> --- arch/arm/include/asm/arch-imx8m/sys_proto.h | 1 + arch/arm/mach-imx/imx8m/soc.c | 55 +++++++++++++++++++++ 2 files changed, 56 insertions(+) -- 2.28.0