vf610: add a clock driver, ehci-vf takes its clocks from it
Subsystems (6)
PATCH v2 1/8 clk: imx: pllv3: add the PLL types of the VF610
In reply to Mehmet FideFrom: Mehmet Fide <[email protected]>
PLL1 and PLL2 of the VF610 are fractional PLLs, and PLL3 and PLL7 work as the USB PLL of the i.MX6. Add both types, as the Linux driver does.
--- drivers/clk/imx/clk-pllv3.c | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+)
drivers/clk/imx/clk-pllv3.c +37 -0
@@ -22,9 +22,12 @@#define UBOOT_DM_CLK_IMX_PLLV3_AV "imx_clk_pllv3_av"#define UBOOT_DM_CLK_IMX_PLLV3_ENET "imx_clk_pllv3_enet"#define UBOOT_DM_CLK_IMX_PLLV3_GENV2 "imx_clk_pllv3_genericv2" +#define UBOOT_DM_CLK_IMX_PLLV3_SYS_VF610 "imx_clk_pllv3_sys_vf610"#define PLL_NUM_OFFSET 0x10#define PLL_DENOM_OFFSET 0x20 +#define PLL_VF610_NUM_OFFSET 0x20 +#define PLL_VF610_DENOM_OFFSET 0x30#define BM_PLL_POWER (0x1 << 12)#define BM_PLL_POWER_V2 (0x1 << 21)
@@ -271,6 +274,27 @@ static const struct clk_ops clk_pllv3_av_ops = { .set_rate = clk_pllv3_av_set_rate, }; +static ulong clk_pllv3_vf610_get_rate (struct clk *clk) +{ +struct clk_pllv3 *pll =to_clk_pllv3 (dev_get_clk_ptr (clk->dev)); +unsigned long parent_rate =clk_get_parent_rate (clk); +u32 mfn =readl (pll->base +PLL_VF610_NUM_OFFSET ); +u32 mfd =readl (pll->base +PLL_VF610_DENOM_OFFSET ); +u32 mfi = (readl (pll->base) & pll->div_mask) ?22 :20 ; +u64 temp64 = parent_rate; + + temp64 *= mfn; +do_div (temp64, mfd); + +return parent_rate * mfi + temp64; +} + +static const struct clk_ops clk_pllv3_vf610_ops = { + .enable = clk_pllv3_generic_enable, + .disable = clk_pllv3_generic_disable, + .get_rate = clk_pllv3_vf610_get_rate, +}; +static ulong clk_pllv3_enet_get_rate (struct clk *clk) {struct clk_pllv3 *pll =to_clk_pllv3 (clk);
@@ -333,6 +357,12 @@ struct clk *imx_clk_pllv3(struct udevice *dev, enum imx_pllv3_type type, pll->div_shift =0 ; pll->powerup_set = false;break ; +case IMX_PLLV3_SYS_VF610 : + drv_name =UBOOT_DM_CLK_IMX_PLLV3_SYS_VF610 ; + pll->div_shift =0 ; + pll->powerup_set = false; +break ; +case IMX_PLLV3_USB_VF610 :case IMX_PLLV3_USB : drv_name =UBOOT_DM_CLK_IMX_PLLV3_USB ; pll->div_shift =1 ;
@@ -389,6 +419,13 @@ U_BOOT_DRIVER(clk_pllv3_sys) = { .flags = DM_FLAG_PRE_RELOC, }; +U_BOOT_DRIVER (clk_pllv3_sys_vf610) = { + .name =UBOOT_DM_CLK_IMX_PLLV3_SYS_VF610 , + .id =UCLASS_CLK , + .ops = &clk_pllv3_vf610_ops, + .flags =DM_FLAG_PRE_RELOC , +}; +U_BOOT_DRIVER (clk_pllv3_usb) = { .name =UBOOT_DM_CLK_IMX_PLLV3_USB , .id =UCLASS_CLK ,
Signature · 1 line
2.56.0
v2 cover vf610: add a clock driver, ehci-vf takes its clocks from it
From: Mehmet Fide <[email protected]>
The Vybrid gets a clock driver, ported from Linux to the common clock framework, and ehci-vf takes its clocks from it instead of setting the PLL bits of its port by hand, as agreed in the ehci-vf review [1].
Tested on a Colibri VF50 and a VF61, booted from NAND and over serial
download: console, SD, NAND/UBI, USB host, DFU and UMS, FEC, booting Linux, 10 power cycles and 10 resets each. The clock rates and the Linux clock tree are the same as without the series. Outside the Vybrid only patch 1 reaches other boards (PLLv3, about 210 bytes on i.MX6 and i.MX RT); buildman builds the 58 affected boards without new warnings.
v2:
- 2/8: macro for the PLL count, calls up to 100 columns (Peng)
- 2/8: headers kept in the codingstyle.rst groups (Peng, question open)
- 5/8: comment at clk_get_by_index_nodev() (Marek)
- Reviewed-by from Peng on 3/8 and 4/8, from Marek on 6/8
- rebased on next, object code unchanged
[1] https://lore.kernel.org/u-boot/[email protected]/
Mehmet Fide (8):
clk: imx: pllv3: add the PLL types of the VF610
clk: imx: add a clock driver for the VF610
serial: lpuart: take the ipg clock on the VF610
colibri_vf: use the VF610 clock driver
usb: ehci-vf: enable the PHY clock through the clock driver
usb: ehci-vf: drop the port number
usb: ehci-vf: enable the controller clock
colibri_vf: leave the USB clocks to the drivers
.../arm/dts/vf610-colibri-eval-v3-u-boot.dtsi | 13 + board/toradex/colibri_vf/colibri_vf.c | 14 - configs/colibri_vf_defconfig | 2 + drivers/clk/imx/Kconfig | 9 + drivers/clk/imx/Makefile | 1 + drivers/clk/imx/clk-pllv3.c | 37 ++ drivers/clk/imx/clk-vf610.c | 400 ++++++++++++++++++ drivers/serial/serial_lpuart.c | 2 +- drivers/usb/host/Kconfig | 2 +- drivers/usb/host/ehci-vf.c | 78 +--- 10 files changed, 479 insertions(+), 79 deletions(-) create mode 100644 drivers/clk/imx/clk-vf610.c
base-commit: 42680af8d15bb49201b298ab5f62058051c13083
Signature · 1 line
2.56.0
PATCH v2 3/8 serial: lpuart: take the ipg clock on the VF610
From: Mehmet Fide <[email protected]>
The VF610 device tree names the LPUART clock "ipg", not "per", so with CONFIG_CLK the baud rate is never set. Use "ipg" on the VF610 as well.
--- drivers/serial/serial_lpuart.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/serial/serial_lpuart.c +1 -1
@@ -111,7 +111,7 @@ static int get_lpuart_clk_rate(struct udevice *dev, u32 *clk_rate)int ret;char *name; -if (plat->devtype ==DEV_MX7ULP ) +if (plat->devtype ==DEV_MX7ULP || plat->devtype ==DEV_VF610 ) name ="ipg" ;else name ="per" ;
Signature · 1 line
2.56.0
PATCH v2 2/8 clk: imx: add a clock driver for the VF610
In reply to Mehmet FideFrom: Mehmet Fide <[email protected]>
The Vybrid has no clock driver. Add one after the Linux driver, with the clocks of the devices U-Boot drives. Like Linux, it takes the PLLs out of bypass.
--- drivers/clk/imx/Kconfig | 9 + drivers/clk/imx/Makefile | 1 + drivers/clk/imx/clk-vf610.c | 400 ++++++++++++++++++++++++++++++++++++ 3 files changed, 410 insertions(+) create mode 100644 drivers/clk/imx/clk-vf610.c
drivers/clk/imx/Kconfig +9 -0
@@ -29,6 +29,15 @@ config CLK_IMX8 help This enables support clock driver for i.MX8 platforms. +config CLK_VF610 + bool "Clock support for Vybrid VF610" + depends on ARCH_VF610 + select CLK + select CLK_CCF + help + This enables the clock driver of the Vybrid VF5xx/VF6xx, with the + PLLs, the bus clocks and the clocks of the devices U-Boot drives. + config SPL_CLK_IMX8MM bool "SPL clock support for i.MX8MM" depends on ARCH_IMX8M && SPL
drivers/clk/imx/Makefile +1 -0
@@ -26,3 +26,4 @@ obj-$(CONFIG_$(PHASE_)CLK_IMXRT1020) += clk-imxrt1020.o obj-$(CONFIG_$(PHASE_)CLK_IMXRT1050) += clk-imxrt1050.o obj-$(CONFIG_$(PHASE_)CLK_IMXRT1170) += clk-imxrt1170.o obj-$(CONFIG_CLK_IMX95_BLKCTRL) += clk-imx95-blkctrl.o +obj-$(CONFIG_$(PHASE_)CLK_VF610) += clk-vf610.o
drivers/clk/imx/clk-vf610.c new file +400 -0
400 lines not on this page · raw message
Signature · 1 line
2.56.0
PATCH v2 4/8 colibri_vf: use the VF610 clock driver
In reply to Mehmet FideFrom: Mehmet Fide <[email protected]>
Enable the clock driver, also before relocation, where the console asks it for its rate, and give the early malloc area room for the clock tree.
Drop the 50 MHz NFC rate of the device tree, the VF61 one, so that the board code keeps setting it per module. The other assigned clocks now apply as in Linux, which moves the FEC timestamp clock to the 50 MHz ENET clock.
--- arch/arm/dts/vf610-colibri-eval-v3-u-boot.dtsi | 13 +++++++++++++ configs/colibri_vf_defconfig | 2 ++ 2 files changed, 15 insertions(+)
arch/arm/dts/vf610-colibri-eval-v3-u-boot.dtsi +13 -0
@@ -19,10 +19,23 @@ bootph-all; }; +&clks { + bootph-all; +}; + &dcu0 { bootph-all; }; +/* + * The same device tree runs the VF50 and the VF61, whose NAND controllers + * take different clock rates; the board code sets the one of the module. + */ +&nfc { + /delete-property/ assigned-clocks; + /delete-property/ assigned-clock-rates; +}; + &iomuxc { pinctrl-names = "default"; pinctrl-0 = <&pinctrl_ddr>;
configs/colibri_vf_defconfig +2 -0
@@ -4,6 +4,7 @@ CONFIG_SYS_THUMB_BUILD=y CONFIG_ARCH_VF610=y CONFIG_TEXT_BASE=0x87800000 CONFIG_SYS_MALLOC_LEN=0x0220000 +CONFIG_SYS_MALLOC_F_LEN=0x10000 CONFIG_NR_DRAM_BANKS=1 CONFIG_ENV_SIZE=0x20000 CONFIG_ENV_OFFSET=0x180000
@@ -69,6 +70,7 @@ CONFIG_NETMASK="255.255.255.0" CONFIG_USE_SERVERIP=y CONFIG_SERVERIP="192.168.10.1" CONFIG_NET_RANDOM_ETHADDR=y +CONFIG_CLK_VF610=y CONFIG_DFU_NAND=y CONFIG_SYS_DFU_DATA_BUF_SIZE=0x100000 CONFIG_VYBRID_GPIO=y
Signature · 1 line
2.56.0
PATCH v2 5/8 usb: ehci-vf: enable the PHY clock through the clock driver
In reply to Mehmet FideFrom: Mehmet Fide <[email protected]>
Enable the clock of the PHY instead of powering PLL3 or PLL7 up through the anatop registers, and drop the anatop lookup.
--- drivers/usb/host/Kconfig | 2 +- drivers/usb/host/ehci-vf.c | 54 +++++++------------------------------- 2 files changed, 11 insertions(+), 45 deletions(-)
drivers/usb/host/Kconfig +1 -1
@@ -246,7 +246,7 @@ config USB_EHCI_OMAP config USB_EHCI_VF bool "Support for Vybrid on-chip EHCI USB controller" - depends on ARCH_VF610 + depends on ARCH_VF610 && CLK_VF610 default y help Enables support for the on-chip EHCI controller on Vybrid SoCs.
drivers/usb/host/ehci-vf.c +10 -44
115 lines not on this page · raw message
Signature · 1 line
2.56.0
PATCH v2 6/8 usb: ehci-vf: drop the port number
In reply to Mehmet FideFrom: Mehmet Fide <[email protected]>
The port number is left only to pass to board_ehci_hcd_init(), which no Vybrid board implements. Drop both.
--- drivers/usb/host/ehci-vf.c | 23 ----------------------- 1 file changed, 23 deletions(-)
drivers/usb/host/ehci-vf.c +0 -23
@@ -18,7 +18,6 @@#include <asm/mach-imx/iomux-v3.h> #include <asm/mach-imx/regs-usbphy.h> #include <dm/device_compat.h> -#include <dt-bindings/clock/vf610-clock.h> #include <linux/compiler.h> #include <linux/delay.h> #include <linux/usb/otg.h>
@@ -45,7 +44,6 @@ struct ehci_vf_priv_data {struct udevice *dev;struct udevice *vbus_supply;struct clk phy_clk; -u32 portnr; };static void usb_internal_phy_clock_gate (struct ehci_vf_priv_data *priv)
@@ -93,20 +91,10 @@ static void usb_oc_config(struct ehci_vf_priv_data *priv)setbits_le32 (priv->misc_addr,UCTRL_OVER_CUR_DIS ); } -int __weak board_ehci_hcd_init (int port) -{ -return 0 ; -} -static int ehci_vf_common_init (struct ehci_vf_priv_data *priv) {int ret; -/* Do board specific initialisation */ - ret =board_ehci_hcd_init (priv->portnr); -if (ret) -return ret; - ret =clk_enable (&priv->phy_clk);if (ret)return ret;
@@ -139,17 +127,6 @@ static int vf_parse_dt_addrs(struct udevice *dev)if (ret)return ret; -switch (priv->phy_clk.id) { -case VF610_CLK_USBPHY0 : - priv->portnr =0 ; -break ; -case VF610_CLK_USBPHY1 : - priv->portnr =1 ; -break ; -default : -return -EINVAL ; - } - addr =ofnode_get_addr (phy.node);if (addr ==FDT_ADDR_T_NONE )return -EINVAL ;
Signature · 1 line
2.56.0
PATCH v2 7/8 usb: ehci-vf: enable the controller clock
In reply to Mehmet FideFrom: Mehmet Fide <[email protected]>
The controller clock is on only because the board code ungates it. Enable it in the driver, before the controller is touched.
--- drivers/usb/host/ehci-vf.c | 9 +++++++++ 1 file changed, 9 insertions(+)
drivers/usb/host/ehci-vf.c +9 -0
@@ -43,6 +43,7 @@ struct ehci_vf_priv_data {void __iomem *misc_addr;struct udevice *dev;struct udevice *vbus_supply; +struct clk clk;struct clk phy_clk; };
@@ -95,6 +96,10 @@ static int ehci_vf_common_init(struct ehci_vf_priv_data *priv) {int ret; + ret =clk_enable (&priv->clk); +if (ret) +return ret; + ret =clk_enable (&priv->phy_clk);if (ret)return ret;
@@ -149,6 +154,10 @@ static int vf_usb_of_to_plat(struct udevice *dev)if (ret)return ret; + ret =clk_get_by_index (dev,0 , &priv->clk); +if (ret) +return ret; + priv->ehci =dev_read_addr_ptr (dev); priv->dr_mode =usb_get_dr_mode (dev_ofnode (dev));/* Handle legacy DTs without dr_mode property, fall back to host */
Signature · 1 line
2.56.0
PATCH v2 8/8 colibri_vf: leave the USB clocks to the drivers
In reply to Mehmet FideFrom: Mehmet Fide <[email protected]>
The drivers enable the USB clocks now, so drop the USB part of clock_init(). It also powered down PLL3, which the boot ROM leaves running (bit 12, named POWERDOWN here, powers the PLL up).
--- board/toradex/colibri_vf/colibri_vf.c | 14 -------------- 1 file changed, 14 deletions(-)
board/toradex/colibri_vf/colibri_vf.c +0 -14
@@ -132,20 +132,6 @@ static void clock_init(void)clrsetbits_le32 (&ccm->ccgr10,CCM_REG_CTRL_MASK ,CCM_CCGR10_NFC_CTRL_MASK ); -#ifdef CONFIG_USB_EHCI_VF -setbits_le32 (&ccm->ccgr1,CCM_CCGR1_USBC0_CTRL_MASK ); -setbits_le32 (&ccm->ccgr7,CCM_CCGR7_USBC1_CTRL_MASK ); - -clrsetbits_le32 (&anadig->pll3_ctrl,ANADIG_PLL3_CTRL_BYPASS | -ANADIG_PLL3_CTRL_POWERDOWN | -ANADIG_PLL3_CTRL_DIV_SELECT , -ANADIG_PLL3_CTRL_ENABLE ); -clrsetbits_le32 (&anadig->pll7_ctrl,ANADIG_PLL7_CTRL_BYPASS | -ANADIG_PLL7_CTRL_POWERDOWN | -ANADIG_PLL7_CTRL_DIV_SELECT , -ANADIG_PLL7_CTRL_ENABLE ); -#endif -clrsetbits_le32 (&anadig->pll5_ctrl,ANADIG_PLL5_CTRL_BYPASS |ANADIG_PLL5_CTRL_POWERDOWN ,ANADIG_PLL5_CTRL_ENABLE |ANADIG_PLL5_CTRL_DIV_SELECT );
Signature · 1 line
2.56.0