da8xx USB PHY platform devices and clocks
v8 cover da8xx USB PHY platform devices and clocks
I reworked the "[PATCH v6 4/5] ARM: DTS: da850: Add cfgchip syscon node" and "[PATCH v6 5/5] ARM: DTS: da850: Add usb phy node" patches that were dropped from linux-davinci into the new "ARM: dts: da850: Add cfgchip syscon node" patch. This should be OK unless it is decided that the BayLibre guys should rework it so that the entire SYSCFG0 is a single syscon device. I don't see any compelling reason to do that though.
v8 changes:
* Dropped v7 patches that have been accepted into linux-davinci already
* New patch for CFGCHIP syscon/USB PHY DT node
* Rebased other patches
v7 changes:
* Dropped v6 patches that have been accepted into linux-davinci already
* New patch for adding device names to clock lookup tables
* Picked up related patch from Axel Haslam for registering USB PHY clocks on device tree boards and added error checking to to that patch
* Rebased on latest linux-davinci + linux-next
* Added devices instead of NULL in clk_get() where appropriate usb-da8xx.c
* Re-ordered patches so that they apply/build cleanly
v6 changes:
* Combine "ARM: davinci: da8xx: Enable the usb20 "per" clk on phy_clk_enable" from the "[PATCH/RFT v2 00/17] Add DT support for ohci-da8xx" series with the "ARM: davinci: da8xx: add usb phy clocks" patch in this series.
* Change the syscon and da8xx-usb-phy device ids to -1.
v5 changes: renamed "usbphy" to "usb_phy" or "usb-phy" as appropriate
v4 changes: fix strict checkpatch complaint
v3 changes:
* Fixed the davinci device tree declarations to use the preferred DT address convention so that the items I have added can be correct too.
* Moved that davinci clock init so that we don't have to call ioremap in the clock mux functions.
* Added a new "syscon" device for the CFGCHIP registers. This is used by the USB PHY driver and will be used in the future in common clock framework drivers.
* USB clocks are moved to a common file instead of having duplicated code.
* PHY driver uses syscon for CFGCHIP registers instead of using them directly.
Axel Haslam (1):
ARM: davinci: da8xx: register USB PHY clocks in the DT file
David Lechner (2):
ARM: dts: da850: Add cfgchip syscon node
ARM: davinci: da8xx: add usb phy clocks
arch/arm/boot/dts/da850.dtsi | 10 ++ arch/arm/mach-davinci/board-da830-evm.c | 31 +--- arch/arm/mach-davinci/board-omapl138-hawk.c | 15 +- arch/arm/mach-davinci/da8xx-dt.c | 12 ++ arch/arm/mach-davinci/include/mach/da8xx.h | 3 + arch/arm/mach-davinci/usb-da8xx.c | 267 ++++++++++++++++++++++++++-- 6 files changed, 296 insertions(+), 42 deletions(-)
Signature · 1 line
2.7.4
PATCH v8 1/3 ARM: dts: da850: Add cfgchip syscon node
Add a syscon node for the SoC CFGCHIPn registers. It includes a child node for the USB PHY that is part of this range of registers.
Also have to add OF_DEV_AUXDATA() entry so that clock lookup will work for the the USB PHY driver.
--- arch/arm/boot/dts/da850.dtsi | 10 ++++++++++ arch/arm/mach-davinci/da8xx-dt.c | 1 + 2 files changed, 11 insertions(+)
arch/arm/boot/dts/da850.dtsi +10 -0
@@ -209,6 +209,16 @@ }; }; + cfgchip: chip-controller at 1417c { + compatible = "ti,da830-cfgchip", "syscon", "simple-mfd"; + reg = <0x1417c 0x14>; + + usb_phy: usb-phy { + compatible = "ti,da830-usb-phy"; + #phy-cells = <1>; + status = "disabled"; + }; + }; edma0: edma at 0 { compatible = "ti,edma3-tpcc"; /* eDMA3 CC0: 0x01c0 0000 - 0x01c0 7fff */
arch/arm/mach-davinci/da8xx-dt.c +1 -0
@@ -41,6 +41,7 @@ static struct of_dev_auxdata da850_auxdata_lookup[] __initdata = {OF_DEV_AUXDATA ("ti,da850-tilcdc" ,0x01e13000 ,"da8xx_lcdc.0" ,NULL ),OF_DEV_AUXDATA ("ti,da830-ohci" ,0x01e25000 ,"ohci" ,NULL ),OF_DEV_AUXDATA ("ti,da830-musb" ,0x01e00000 ,"musb-da8xx" ,NULL ), + OF_DEV_AUXDATA("ti,da830-usb-phy", 0x01c1417c, "da8xx-usb-phy", NULL), {} };
Signature · 1 line
2.7.4
Re: [PATCH v8 1/3] ARM: dts: da850: Add cfgchip syscon node
Hi David,
Quoted 7 lines · David Lechner
Add a syscon node for the SoC CFGCHIPn registers. It includes a child node for the USB PHY that is part of this range of registers.
Also have to add
OF_DEV_AUXDATA()entry so that clock lookup will work for the the USB PHY driver.Signed-off-by David Lechner <[email protected]>
For future, please do not combine device-tree addition and other C code into a single patch. I have applied this patch while splitting it into two as attached.
Thanks,
Sekhar
---8<---
From: David Lechner <[email protected]>
Date: Mon, 31 Oct 2016 15:47:19 -0500
Subject: [PATCH] ARM: dts: da850: Add cfgchip syscon node
Add a syscon node for the SoC CFGCHIPn registers. It includes a child node for the USB PHY that is part of this range of registers.
--- arch/arm/boot/dts/da850.dtsi | 10 ++++++++++ 1 file changed, 10 insertions(+)
arch/arm/boot/dts/da850.dtsi +10 -0
@@ -209,6 +209,16 @@ }; }; + cfgchip: chip-controller at 1417c { + compatible = "ti,da830-cfgchip", "syscon", "simple-mfd"; + reg = <0x1417c 0x14>; + + usb_phy: usb-phy { + compatible = "ti,da830-usb-phy"; + #phy-cells = <1>; + status = "disabled"; + }; + }; edma0: edma at 0 { compatible = "ti,edma3-tpcc"; /* eDMA3 CC0: 0x01c0 0000 - 0x01c0 7fff */
Signature · 15 lines
2.9.0 ---8<--- From: David Lechner <[email protected]> Date: Mon, 31 Oct 2016 15:47:19 -0500 Subject: [PATCH] ARM: davinci: da8xx-dt: add OF_DEV_AUXDATA entry for USB phy Add OF_DEV_AUXDATA() entry for USB phy. This is required for so that clock lookup will work for the USB PHY driver. Signed-off-by: David Lechner <[email protected]> Signed-off-by: Sekhar Nori <[email protected]> --- arch/arm/mach-davinci/da8xx-dt.c | 1 + 1 file changed, 1 insertion(+)
arch/arm/mach-davinci/da8xx-dt.c +1 -0
@@ -41,6 +41,7 @@ static struct of_dev_auxdata da850_auxdata_lookup[] __initdata = {OF_DEV_AUXDATA ("ti,da850-tilcdc" ,0x01e13000 ,"da8xx_lcdc.0" ,NULL ),OF_DEV_AUXDATA ("ti,da830-ohci" ,0x01e25000 ,"ohci" ,NULL ),OF_DEV_AUXDATA ("ti,da830-musb" ,0x01e00000 ,"musb-da8xx" ,NULL ), + OF_DEV_AUXDATA("ti,da830-usb-phy", 0x01c1417c, "da8xx-usb-phy", NULL), {} };
Signature · 1 line
2.9.0
Re: [PATCH v8 1/3] ARM: dts: da850: Add cfgchip syscon node
Quoted 6 lines · Sekhar Nori
Hi David,
Quoted 3 lines · David Lechner
Add a syscon node for the SoC CFGCHIPn registers. It includes a child node for the USB PHY that is part of this range of registers.
Quoted 9 lines
Quoted 4 lines
Also have to add
OF_DEV_AUXDATA()entry so that clock lookup will work for the the USB PHY driver.Signed-off-by David Lechner <[email protected]>For future, please do not combine device-tree addition and other C code into a single patch. I have applied this patch while splitting it into two as attached.
Sorry. I should know that by now. :-/
Thank you for fixing it for me.
PATCH v8 2/3 ARM: davinci: da8xx: add usb phy clocks
In reply to David LechnerUp to this point, the USB phy clock configuration was handled manually in the board files and in the usb drivers. This adds proper clocks so that the usb drivers can use clk_get and clk_enable and not have to worry about the details. Also, the related code is removed from the board files and replaced with the new clock registration functions.
This also removes the #if IS_ENABLED(CONFIG_USB_MUSB_HDRC) around the musb declaration and renames the musb platform device so that we can reference it from the usb20 clock even if the musb device is not used.
--- arch/arm/mach-davinci/board-da830-evm.c | 31 +--- arch/arm/mach-davinci/board-omapl138-hawk.c | 15 +- arch/arm/mach-davinci/include/mach/da8xx.h | 3 + arch/arm/mach-davinci/usb-da8xx.c | 267 ++++++++++++++++++++++++++-- 4 files changed, 274 insertions(+), 42 deletions(-)
arch/arm/mach-davinci/board-da830-evm.c +9 -22
@@ -18,7 +18,6 @@#include <linux/i2c.h> #include <linux/i2c/pcf857x.h> #include <linux/platform_data/at24.h> -#include <linux/mfd/da8xx-cfgchip.h> #include <linux/mtd/mtd.h> #include <linux/mtd/partitions.h> #include <linux/spi/spi.h>
@@ -108,30 +107,18 @@ static irqreturn_t da830_evm_usb_ocic_irq(int irq, void *dev_id)static __init void da830_evm_usb_init (void ) { -u32 cfgchip2;int ret; -/* -* Set up USB clock in the CFGCHIP2 register. -* FYI: CFGCHIP2 is 0x0000ef00 initially. -*/ - cfgchip2 =__raw_readl (DA8XX_SYSCFG0_VIRT (DA8XX_CFGCHIP2_REG )); - -/* USB2.0 PHY reference clock is 24 MHz */ - cfgchip2 &= ~CFGCHIP2_REFFREQ_MASK ; - cfgchip2 |=CFGCHIP2_REFFREQ_24MHZ ; - -/* -* Select internal reference clock for USB 2.0 PHY -* and use it as a clock source for USB 1.1 PHY -* (this is the default setting anyway). -*/ - cfgchip2 &= ~CFGCHIP2_USB1PHYCLKMUX ; - cfgchip2 |=CFGCHIP2_USB2PHYCLKMUX ; - -__raw_writel (cfgchip2,DA8XX_SYSCFG0_VIRT (DA8XX_CFGCHIP2_REG )); -/* USB_REFCLKIN is not used. */ + ret =da8xx_register_usb20_phy_clk (false); +if (ret) +pr_warn ("%s: USB 2.0 PHY CLK registration failed: %d\n" , + __func__, ret); + + ret =da8xx_register_usb11_phy_clk (false); +if (ret) +pr_warn ("%s: USB 1.1 PHY CLK registration failed: %d\n" , + __func__, ret); ret =da8xx_register_usb_phy ();if (ret)
arch/arm/mach-davinci/board-omapl138-hawk.c +8 -7
@@ -13,7 +13,6 @@#include <linux/init.h> #include <linux/console.h> #include <linux/gpio.h> -#include <linux/mfd/da8xx-cfgchip.h> #include <linux/platform_data/gpio-davinci.h> #include <linux/regulator/machine.h>
@@ -245,7 +244,6 @@ static irqreturn_t omapl138_hawk_usb_ocic_irq(int irq, void *dev_id)static __init void omapl138_hawk_usb_init (void ) {int ret; -u32 cfgchip2; ret =davinci_cfg_reg_list (da850_hawk_usb11_pins);if (ret) {
@@ -253,12 +251,15 @@ static __init void omapl138_hawk_usb_init(void)return ; } -/* Setup the Ref. clock frequency for the HAWK at 24 MHz. */ + ret =da8xx_register_usb20_phy_clk (false); +if (ret) +pr_warn ("%s: USB 2.0 PHY CLK registration failed: %d\n" , + __func__, ret); - cfgchip2 =__raw_readl (DA8XX_SYSCFG0_VIRT (DA8XX_CFGCHIP2_REG )); - cfgchip2 &= ~CFGCHIP2_REFFREQ_MASK ; - cfgchip2 |=CFGCHIP2_REFFREQ_24MHZ ; -__raw_writel (cfgchip2,DA8XX_SYSCFG0_VIRT (DA8XX_CFGCHIP2_REG )); + ret =da8xx_register_usb11_phy_clk (false); +if (ret) +pr_warn ("%s: USB 1.1 PHY CLK registration failed: %d\n" , + __func__, ret); ret =da8xx_register_usb_phy ();if (ret)
arch/arm/mach-davinci/include/mach/da8xx.h +3 -0
@@ -92,6 +92,9 @@ int da8xx_register_watchdog(void);int da8xx_register_usb_phy (void );int da8xx_register_usb20 (unsigned mA,unsigned potpgt);int da8xx_register_usb11 (struct da8xx_ohci_root_hub *pdata); +int da8xx_register_usb_refclkin (int rate); +int da8xx_register_usb20_phy_clk (bool use_usb_refclkin); +int da8xx_register_usb11_phy_clk (bool use_usb_refclkin);int da8xx_register_emac (void );int da8xx_register_uio_pruss (void );int da8xx_register_lcdc (struct da8xx_lcdc_platform_data *pdata);
arch/arm/mach-davinci/usb-da8xx.c +254 -13
317 lines not on this page · raw message
Signature · 1 line
2.7.4
Sekhar Nori
AppliedRe: [PATCH v8 2/3] ARM: davinci: da8xx: add usb phy clocks
Quoted 6 lines · David Lechner
Up to this point, the USB phy clock configuration was handled manually in the board files and in the usb drivers. This adds proper clocks so that the usb drivers can use
clk_getandclk_enableand not have to worry about the details. Also, the related code is removed from the board files and replaced with the new clock registration functions.
Quoted 6 lines
This also removes the #if
IS_ENABLED(CONFIG_USB_MUSB_HDRC)around the musb declaration and renames the musb platform device so that we can reference it from the usb20 clock even if the musb device is not used.Signed-off-by David Lechner <[email protected]>Signed-off-by Axel Haslam <[email protected]>
Applied to v4.10/soc
Thanks,
Sekhar
PATCH v8 3/3 ARM: davinci: da8xx: register USB PHY clocks in the DT file
In reply to David LechnerFrom: Axel Haslam <[email protected]>
The usb20_phy clock needs to be registered for the driver to be able to get and enable a clock. Currently the usb phy clocks are registered form board files, which will not be called during a device tree based boot.
To be able to probe correctly usb form a device tree boot, register the usb phy clocks form the DT specific init.
Unfourtunatly, davinci does not have proper clock support on device tree yet, so by registering the clock form de DT specific file we are forced to hardcode the parent clock, and cannot select refclkin as parent for any of the phy clocks of the da850 family.
As none of the current da850 based boards currently in mainline use refclkin as source. I guess we can live with this limitation until clocks are correctly represented through CCF/device tree.
--- arch/arm/mach-davinci/da8xx-dt.c | 11 +++++++++++ 1 file changed, 11 insertions(+)
arch/arm/mach-davinci/da8xx-dt.c +11 -0
@@ -49,6 +49,17 @@ static struct of_dev_auxdata da850_auxdata_lookup[] __initdata = {static void __init da850_init_machine (void ) { +int ret; + + ret =da8xx_register_usb20_phy_clk (false); +if (ret) +pr_warn ("%s: registering USB 2.0 PHY clock failed: %d" , + __func__, ret); + ret =da8xx_register_usb11_phy_clk (false); +if (ret) +pr_warn ("%s: registering USB 1.1 PHY clock failed: %d" , + __func__, ret); +of_platform_default_populate (NULL , da850_auxdata_lookup,NULL ); }
Signature · 1 line
2.7.4
Sekhar Nori
AppliedRe: [PATCH v8 3/3] ARM: davinci: da8xx: register USB PHY clocks in the DT file
Quoted 15 lines · David Lechner
From: Axel Haslam <[email protected]>
The
usb20_phyclock needs to be registered for the driver to be able to get and enable a clock. Currently the usb phy clocks are registered form board files, which will not be called during a device tree based boot.To be able to probe correctly usb form a device tree boot, register the usb phy clocks form the DT specific init.
Unfourtunatly, davinci does not have proper clock support on device tree yet, so by registering the clock form de DT specific file we are forced to hardcode the parent clock, and cannot select refclkin as parent for any of the phy clocks of the da850 family.
Quoted 7 lines
As none of the current da850 based boards currently in mainline use refclkin as source. I guess we can live with this limitation until clocks are correctly represented through CCF/device tree.
Signed-off-by Axel Haslam <[email protected]>[Added error checking]Signed-off-by David Lechner <[email protected]>
Applied to v4.10/soc with some typo fixes.
s/form/from
s/Unfourtunatly/Unfortunately
s/de/the
Thanks,
Sekhar