Skip to contentSkip to conversation

da8xx USB clocks

PATCH Superseded David Lechner 7 participants 42 messages Mar 24, 2016 – Apr 14, 2016

Subsystems (9)

v3 of 5 Superseded Latest is v5 →

lore
Share & tools
lore
#0 lore raw

v3 cover da8xx USB clocks

This is a reworking of the v2 series based of feedback and review. There were very many suggestions, so hopefully I didn't miss any. Here are the highlights...

New stuff:

* 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.

Changed:

* 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.

David Lechner (16):
dt: davinci: use proper address after @
mfd: da8xx-cfgchip: New header file for CFGCHIP registers.
ARM: davinici: da8xx: move usb code to new file
ARM: davinci: Move clock init after ioremap.
ARM: davinci: add set_parent callback for mux clocks
ARM: davinci: da850: use clk->set_parent for async3
ARM: davinci: da8xx: add usb phy clocks
dt-bindings: Add bindings for phy-da8xx-usb
phy: da8xx-usb: new driver for DA8xx SoC USB PHY
ARM: davinci: da8xx: Add CFGCHIPn syscon platform declaration.
ARM: davinci: da8xx: Add USB PHY platform declaration
ARM: dt: da850: Add cfgchip syscon node
ARM: dt: da850: Add usb phy node
usb: ohci-da8xx: Remove code that references mach
usb: musb: da8xx: Use devm in probe
usb: musb: da8xx: Remove mach code

 .../devicetree/bindings/phy/phy-da8xx-usb.txt      |  40 +++
 arch/arm/boot/dts/da850-enbw-cmc.dts               |   8 +-
 arch/arm/boot/dts/da850-evm.dts                    |  26 +-
 arch/arm/boot/dts/da850.dtsi                       |  61 ++--
 arch/arm/mach-davinci/Makefile                     |   4 +-
 arch/arm/mach-davinci/board-da830-evm.c            |  52 ++-
 arch/arm/mach-davinci/board-da850-evm.c            |   4 +
 arch/arm/mach-davinci/board-mityomapl138.c         |   4 +
 arch/arm/mach-davinci/board-omapl138-hawk.c        |  23 +-
 arch/arm/mach-davinci/clock.c                      |  21 +-
 arch/arm/mach-davinci/clock.h                      |   8 +-
 arch/arm/mach-davinci/common.c                     |   6 -
 arch/arm/mach-davinci/da830.c                      |   2 +
 arch/arm/mach-davinci/da850.c                      |  84 +++--
 arch/arm/mach-davinci/devices-da8xx.c              |  28 ++
 arch/arm/mach-davinci/dm355.c                      |   1 +
 arch/arm/mach-davinci/dm365.c                      |   1 +
 arch/arm/mach-davinci/dm644x.c                     |   1 +
 arch/arm/mach-davinci/dm646x.c                     |   1 +
 arch/arm/mach-davinci/include/mach/da8xx.h         |   6 +
 arch/arm/mach-davinci/usb-da8xx.c                  | 351 +++++++++++++++++++++
 arch/arm/mach-davinci/usb.c                        |  74 +----
 drivers/phy/Kconfig                                |  10 +
 drivers/phy/Makefile                               |   1 +
 drivers/phy/phy-da8xx-usb.c                        | 249 +++++++++++++++
 drivers/usb/host/Kconfig                           |   1 +
 drivers/usb/host/ohci-da8xx.c                      | 102 +++---
 drivers/usb/musb/Kconfig                           |   2 +-
 drivers/usb/musb/da8xx.c                           | 160 +++-------
 include/linux/mfd/da8xx-cfgchip.h                  | 160 ++++++++++
 include/linux/phy/phy-da8xx-usb.h                  |  19 ++
 include/linux/platform_data/usb-davinci.h          |  23 --
 32 files changed, 1137 insertions(+), 396 deletions(-)
 create mode 100644 Documentation/devicetree/bindings/phy/phy-da8xx-usb.txt
 create mode 100644 arch/arm/mach-davinci/usb-da8xx.c
 create mode 100644 drivers/phy/phy-da8xx-usb.c
 create mode 100644 include/linux/mfd/da8xx-cfgchip.h
 create mode 100644 include/linux/phy/phy-da8xx-usb.h
Signature · 1 line
1.9.1
#1 lore raw

PATCH v3 1/16 dt: davinci: use proper address after @

TI has been using the physical address in DT after the @ in device nodes. The device tree convention is to use the same address that is used for the reg property. This updates all davinci DT files to use the proper convention.

---

v3 changes: This is a new patch.

 arch/arm/boot/dts/da850-enbw-cmc.dts |  8 +++---
 arch/arm/boot/dts/da850-evm.dts      | 26 +++++++++---------
 arch/arm/boot/dts/da850.dtsi         | 52 ++++++++++++++++++------------------
 3 files changed, 43 insertions(+), 43 deletions(-)
arch/arm/boot/dts/da850-enbw-cmc.dts +4 -4
index 645549e..101d1a1 100644
@@ -16,14 +16,14 @@
 	compatible = "enbw,cmc", "ti,da850";
 	model = "EnBW CMC";
 
-	soc {
-		serial0: serial at 1c42000 {
+	soc at 1c00000 {
+		serial0: serial at 42000 {
 			status = "okay";
 		};
-		serial1: serial at 1d0c000 {
+		serial1: serial at 10c000 {
 			status = "okay";
 		};
-		serial2: serial at 1d0d000 {
+		serial2: serial at 10d000 {
 			status = "okay";
 		};
 	};
arch/arm/boot/dts/da850-evm.dts +13 -13
index ef061e9..1a15db8 100644
@@ -14,8 +14,8 @@
 	compatible = "ti,da850-evm", "ti,da850";
 	model = "DA850/AM1808/OMAP-L138 EVM";
 
-	soc {
-		pmx_core: pinmux at 1c14120 {
+	soc at 1c00000 {
+		pmx_core: pinmux at 14120 {
 			status = "okay";
 
 			mcasp0_pins: pinmux_mcasp0_pins {
@@ -30,19 +30,19 @@
 				>;
 			};
 		};
-		serial0: serial at 1c42000 {
+		serial0: serial at 42000 {
 			status = "okay";
 		};
-		serial1: serial at 1d0c000 {
+		serial1: serial at 10c000 {
 			status = "okay";
 		};
-		serial2: serial at 1d0d000 {
+		serial2: serial at 10d000 {
 			status = "okay";
 		};
-		rtc0: rtc at 1c23000 {
+		rtc0: rtc at 23000 {
 			status = "okay";
 		};
-		i2c0: i2c at 1c22000 {
+		i2c0: i2c at 22000 {
 			status = "okay";
 			clock-frequency = <100000>;
 			pinctrl-names = "default";
@@ -66,17 +66,17 @@
 			};
 
 		};
-		wdt: wdt at 1c21000 {
+		wdt: wdt at 21000 {
 			status = "okay";
 		};
-		mmc0: mmc at 1c40000 {
+		mmc0: mmc at 40000 {
 			max-frequency = <50000000>;
 			bus-width = <4>;
 			status = "okay";
 			pinctrl-names = "default";
 			pinctrl-0 = <&mmc0_pins>;
 		};
-		spi1: spi at 1f0e000 {
+		spi1: spi at 30e000 {
 			status = "okay";
 			pinctrl-names = "default";
 			pinctrl-0 = <&spi1_pins &spi1_cs0_pin>;
@@ -116,18 +116,18 @@
 				};
 			};
 		};
-		mdio: mdio at 1e24000 {
+		mdio: mdio at 224000 {
 			status = "okay";
 			pinctrl-names = "default";
 			pinctrl-0 = <&mdio_pins>;
 			bus_freq = <2200000>;
 		};
-		eth0: ethernet at 1e20000 {
+		eth0: ethernet at 220000 {
 			status = "okay";
 			pinctrl-names = "default";
 			pinctrl-0 = <&mii_pins>;
 		};
-		gpio: gpio at 1e26000 {
+		gpio: gpio at 226000 {
 			status = "okay";
 		};
 	};
arch/arm/boot/dts/da850.dtsi +26 -26

197 lines not on this page · raw message

Signature · 1 line
1.9.1
#2 lore raw

Re: [PATCH v3 01/16] dt: davinci: use proper address after @

Hello.

Quoted 6 lines · David Lechner

TI has been using the physical address in DT after the @ in device nodes. The device tree convention is to use the same address that is used for the reg property. This updates all davinci DT files to use the proper convention.

[...]

Quoted 14 lines
arch/arm/boot/dts/da850.dtsi +1 -1
index 226cda7..4294849 100644
@@ -15,7 +15,7 @@
  		#address-cells = <1>;
  		#size-cells = <1>;
  		ranges;
-		intc: interrupt-controller {
+		intc: interrupt-controller at fffee000 {
  			compatible = "ti,cp-intc";
  			interrupt-controller;
  			#interrupt-cells = <1>;

arch/arm/boot/dts/da850.dtsi line 26

Quoted 5 lines
arch/arm/boot/dts/da850.dtsi +1 -1
@@ -23,7 +23,7 @@
  			reg = <0xfffee000 0x2000>;
  		};
  	};
-	soc {
+	soc at 1c00000 {

This node doesn't have the "reg" prop.

[...]

MBR, Sergei

#3 lore raw

Re: [PATCH v3 01/16] dt: davinci: use proper address after @

Quoted 27 lines · Sergei Shtylyov

Hello.

Quoted 6 lines · David Lechner

TI has been using the physical address in DT after the @ in device nodes. The device tree convention is to use the same address that is used for the reg property. This updates all davinci DT files to use the proper convention.

[...]

Quoted 14 lines
arch/arm/boot/dts/da850.dtsi +1 -1
index 226cda7..4294849 100644
@@ -15,7 +15,7 @@
                #address-cells = <1>;
                #size-cells = <1>;
                ranges;
-               intc: interrupt-controller {
+               intc: interrupt-controller at fffee000 {
                        compatible = "ti,cp-intc";
                        interrupt-controller;
                        #interrupt-cells = <1>;
@@ -23,7 +23,7 @@
Quoted 8 lines

arch/arm/boot/dts/da850.dtsi line 26

Quoted 5 lines
arch/arm/boot/dts/da850.dtsi +1 -1
                        reg = <0xfffee000 0x2000>;
                };
        };
-       soc {
+       soc at 1c00000 {

This node doesn't have the "reg" prop.

But probably has a ranges property which is correct.

Rob

#4 lore raw

Re: [PATCH v3 01/16] dt: davinci: use proper address after @

Hello.

Quoted 32 lines · Rob Herring
Quoted 23 lines
Quoted 6 lines

TI has been using the physical address in DT after the @ in device nodes. The device tree convention is to use the same address that is used for the reg property. This updates all davinci DT files to use the proper convention.

[...]

Quoted 14 lines
arch/arm/boot/dts/da850.dtsi +1 -1
index 226cda7..4294849 100644
@@ -15,7 +15,7 @@
                 #address-cells = <1>;
                 #size-cells = <1>;
                 ranges;
-               intc: interrupt-controller {
+               intc: interrupt-controller at fffee000 {
                         compatible = "ti,cp-intc";
                         interrupt-controller;
                         #interrupt-cells = <1>;
@@ -23,7 +23,7 @@
Quoted 8 lines

arch/arm/boot/dts/da850.dtsi line 26

Quoted 5 lines
arch/arm/boot/dts/da850.dtsi +1 -1
                         reg = <0xfffee000 0x2000>;
                 };
         };
-       soc {
+       soc at 1c00000 {

This node doesn't have the "reg" prop.

Quoted 1 line

But probably has a ranges property which is correct.

Yes, it does. Didn't know that "ranges" can be used that way, thanks...

Quoted 1 line

Rob

MBR, Sergei

Acked-by on v3 1/16
#5 lore raw

Re: [PATCH v3 01/16] dt: davinci: use proper address after @

In reply to David Lechner
Quoted 8 lines · David Lechner

TI has been using the physical address in DT after the @ in device nodes. The device tree convention is to use the same address that is used for the reg property. This updates all davinci DT files to use the proper convention.

---

Quoted 7 lines

v3 changes: This is a new patch.

 arch/arm/boot/dts/da850-enbw-cmc.dts |  8 +++---
 arch/arm/boot/dts/da850-evm.dts      | 26 +++++++++---------
 arch/arm/boot/dts/da850.dtsi         | 52 ++++++++++++++++++------------------
 3 files changed, 43 insertions(+), 43 deletions(-)

Thanks for fixing.

#6 lore raw

Re: [PATCH v3 01/16] dt: davinci: use proper address after @

In reply to David Lechner
Quoted 9 lines · David Lechner

TI has been using the physical address in DT after the @ in device nodes. The device tree convention is to use the same address that is used for the reg property. This updates all davinci DT files to use the proper convention.

---

v3 changes: This is a new patch.

Applied through a copy of this patch posted by Petr in thread "ARM: DTS:
da850: add node for i2c1"

Thanks,
Sekhar

#7 lore raw

PATCH v3 2/16 mfd: da8xx-cfgchip: New header file for CFGCHIP registers.

In reply to David Lechner

We will be using a generic syscon device for the TI DA8XX SoC CFGCHIPx retisters. This will be used by a number of planned drivers including a new USB PHY driver and common clock framework drivers.

The same defines are removed from the platform_data header file since they are now redundant and they didn't really belong there anyway.

---

v3 changes: This is a new patch. It replaces the previous patch that just added some missing CFGCHIP2 registers to the platform_data/usb-davinci.h file. I took David Laight's advice and included all of the possible registers.

Many of these registers will be used for clocks - hopefully in the near future.

include/linux/mfd/da8xx-cfgchip.h | 160 ++++++++++++++++++++++++++++++

 include/linux/platform_data/usb-davinci.h |  23 -----
 2 files changed, 160 insertions(+), 23 deletions(-)
 create mode 100644 include/linux/mfd/da8xx-cfgchip.h
include/linux/mfd/da8xx-cfgchip.h new file +160 -0
new file mode 100644
index 0000000..6940cf9
@@ -0,0 +1,160 @@
+/*
+ * TI DaVinci DA8xx CHIPCFGx registers for syscon consumers.
+ *
+ * Copyright (C) 2016 David Lechner <[email protected]>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ */
+
+#ifndef __LINUX_MFD_DA8XX_CFGCHIP_H
+#define __LINUX_MFD_DA8XX_CFGCHIP_H
+
+#include <linux/bitops.h>
+
+/* register offsets */
+#define CFGCHIP_REG(n)				(n * 4)
+#define CFGCHIP0_REG				CFGCHIP_REG(0)
+#define CFGCHIP1_REG				CFGCHIP_REG(1)
+#define CFGCHIP2_REG				CFGCHIP_REG(2)
+#define CFGCHIP3_REG				CFGCHIP_REG(3)
+#define CFGCHIP4_REG				CFGCHIP_REG(4)
+
+/* CFGCHIP0 (PLL0/EDMA3_0) register bits */
+#define CFGCHIP0_PLL_MASTER_LOCK		BIT(4)
+#define CFGCHIP0_EDMA30TC1DBS(n)		(n << 2)
+#define CFGCHIP0_EDMA30TC1DBS_MASK		CFGCHIP0_EDMA30TC1DBS(0x3)
+#define CFGCHIP0_EDMA30TC1DBS_16		CFGCHIP0_EDMA30TC1DBS(0x0)
+#define CFGCHIP0_EDMA30TC1DBS_32		CFGCHIP0_EDMA30TC1DBS(0x1)
+#define CFGCHIP0_EDMA30TC1DBS_64		CFGCHIP0_EDMA30TC1DBS(0x2)
+#define CFGCHIP0_EDMA30TC0DBS(n)		(n << 0)
+#define CFGCHIP0_EDMA30TC0DBS_MASK		CFGCHIP0_EDMA30TC0DBS(0x3)
+#define CFGCHIP0_EDMA30TC0DBS_16		CFGCHIP0_EDMA30TC0DBS(0x0)
+#define CFGCHIP0_EDMA30TC0DBS_32		CFGCHIP0_EDMA30TC0DBS(0x1)
+#define CFGCHIP0_EDMA30TC0DBS_64		CFGCHIP0_EDMA30TC0DBS(0x2)
+
+/* CFGCHIP1 (eCAP/HPI/EDMA3_1/eHRPWM TBCLK/McASP0 AMUTEIN) register bits */
+#define CFGCHIP1_CAP2SRC(n)			(n << 27)
+#define CFGCHIP1_CAP2SRC_MASK			CFGCHIP1_CAP2SRC(0x1f)
+#define CFGCHIP1_CAP2SRC_ECAP_PIN		CFGCHIP1_CAP2SRC(0x0)
+#define CFGCHIP1_CAP2SRC_MCASP0_TX		CFGCHIP1_CAP2SRC(0x1)
+#define CFGCHIP1_CAP2SRC_MCASP0_RX		CFGCHIP1_CAP2SRC(0x2)
+#define CFGCHIP1_CAP2SRC_EMAC_C0_RX_THRESHOLD	CFGCHIP1_CAP2SRC(0x7)
+#define CFGCHIP1_CAP2SRC_EMAC_C0_RX		CFGCHIP1_CAP2SRC(0x8)
+#define CFGCHIP1_CAP2SRC_EMAC_C0_TX		CFGCHIP1_CAP2SRC(0x9)
+#define CFGCHIP1_CAP2SRC_EMAC_C0_MISC		CFGCHIP1_CAP2SRC(0xa)
+#define CFGCHIP1_CAP2SRC_EMAC_C1_RX_THRESHOLD	CFGCHIP1_CAP2SRC(0xb)
+#define CFGCHIP1_CAP2SRC_EMAC_C1_RX		CFGCHIP1_CAP2SRC(0xc)
+#define CFGCHIP1_CAP2SRC_EMAC_C1_TX		CFGCHIP1_CAP2SRC(0xd)
+#define CFGCHIP1_CAP2SRC_EMAC_C1_MISC		CFGCHIP1_CAP2SRC(0xe)
+#define CFGCHIP1_CAP2SRC_EMAC_C2_RX_THRESHOLD	CFGCHIP1_CAP2SRC(0xf)
+#define CFGCHIP1_CAP2SRC_EMAC_C2_RX		CFGCHIP1_CAP2SRC(0x10)
+#define CFGCHIP1_CAP2SRC_EMAC_C2_TX		CFGCHIP1_CAP2SRC(0x11)
+#define CFGCHIP1_CAP2SRC_EMAC_C2_MISC		CFGCHIP1_CAP2SRC(0x12)
+#define CFGCHIP1_CAP1SRC(n)			(n << 22)
+#define CFGCHIP1_CAP1SRC_MASK			CFGCHIP1_CAP1SRC(0x1f)
+#define CFGCHIP1_CAP1SRC_ECAP_PIN		CFGCHIP1_CAP1SRC(0x0)
+#define CFGCHIP1_CAP1SRC_MCASP0_TX		CFGCHIP1_CAP1SRC(0x1)
+#define CFGCHIP1_CAP1SRC_MCASP0_RX		CFGCHIP1_CAP1SRC(0x2)
+#define CFGCHIP1_CAP1SRC_EMAC_C0_RX_THRESHOLD	CFGCHIP1_CAP1SRC(0x7)
+#define CFGCHIP1_CAP1SRC_EMAC_C0_RX		CFGCHIP1_CAP1SRC(0x8)
+#define CFGCHIP1_CAP1SRC_EMAC_C0_TX		CFGCHIP1_CAP1SRC(0x9)
+#define CFGCHIP1_CAP1SRC_EMAC_C0_MISC		CFGCHIP1_CAP1SRC(0xa)
+#define CFGCHIP1_CAP1SRC_EMAC_C1_RX_THRESHOLD	CFGCHIP1_CAP1SRC(0xb)
+#define CFGCHIP1_CAP1SRC_EMAC_C1_RX		CFGCHIP1_CAP1SRC(0xc)
+#define CFGCHIP1_CAP1SRC_EMAC_C1_TX		CFGCHIP1_CAP1SRC(0xd)
+#define CFGCHIP1_CAP1SRC_EMAC_C1_MISC		CFGCHIP1_CAP1SRC(0xe)
+#define CFGCHIP1_CAP1SRC_EMAC_C2_RX_THRESHOLD	CFGCHIP1_CAP1SRC(0xf)
+#define CFGCHIP1_CAP1SRC_EMAC_C2_RX		CFGCHIP1_CAP1SRC(0x10)
+#define CFGCHIP1_CAP1SRC_EMAC_C2_TX		CFGCHIP1_CAP1SRC(0x11)
+#define CFGCHIP1_CAP1SRC_EMAC_C2_MISC		CFGCHIP1_CAP1SRC(0x12)
+#define CFGCHIP1_CAP0SRC(n)			(n << 17)
+#define CFGCHIP1_CAP0SRC_MASK			CFGCHIP1_CAP0SRC(0x1f)
+#define CFGCHIP1_CAP0SRC_ECAP_PIN		CFGCHIP1_CAP0SRC(0x0)
+#define CFGCHIP1_CAP0SRC_MCASP0_TX		CFGCHIP1_CAP0SRC(0x1)
+#define CFGCHIP1_CAP0SRC_MCASP0_RX		CFGCHIP1_CAP0SRC(0x2)
+#define CFGCHIP1_CAP0SRC_EMAC_C0_RX_THRESHOLD	CFGCHIP1_CAP0SRC(0x7)
+#define CFGCHIP1_CAP0SRC_EMAC_C0_RX		CFGCHIP1_CAP0SRC(0x8)
+#define CFGCHIP1_CAP0SRC_EMAC_C0_TX		CFGCHIP1_CAP0SRC(0x9)
+#define CFGCHIP1_CAP0SRC_EMAC_C0_MISC		CFGCHIP1_CAP0SRC(0xa)
+#define CFGCHIP1_CAP0SRC_EMAC_C1_RX_THRESHOLD	CFGCHIP1_CAP0SRC(0xb)
+#define CFGCHIP1_CAP0SRC_EMAC_C1_RX		CFGCHIP1_CAP0SRC(0xc)
+#define CFGCHIP1_CAP0SRC_EMAC_C1_TX		CFGCHIP1_CAP0SRC(0xd)
+#define CFGCHIP1_CAP0SRC_EMAC_C1_MISC		CFGCHIP1_CAP0SRC(0xe)
+#define CFGCHIP1_CAP0SRC_EMAC_C2_RX_THRESHOLD	CFGCHIP1_CAP0SRC(0xf)
+#define CFGCHIP1_CAP0SRC_EMAC_C2_RX		CFGCHIP1_CAP0SRC(0x10)
+#define CFGCHIP1_CAP0SRC_EMAC_C2_TX		CFGCHIP1_CAP0SRC(0x11)
+#define CFGCHIP1_CAP0SRC_EMAC_C2_MISC		CFGCHIP1_CAP0SRC(0x12)
+#define CFGCHIP1_HPIBYTEAD			BIT(16)
+#define CFGCHIP1_HPIENA				BIT(15)
+#define CFGCHIP0_EDMA31TC0DBS(n)		(n << 13)
+#define CFGCHIP0_EDMA31TC0DBS_MASK		CFGCHIP0_EDMA31TC0DBS(0x3)
+#define CFGCHIP0_EDMA31TC0DBS_16		CFGCHIP0_EDMA31TC0DBS(0x0)
+#define CFGCHIP0_EDMA31TC0DBS_32		CFGCHIP0_EDMA31TC0DBS(0x1)
+#define CFGCHIP0_EDMA31TC0DBS_64		CFGCHIP0_EDMA31TC0DBS(0x2)
+#define CFGCHIP1_TBCLKSYNC			BIT(12)
+#define CFGCHIP1_AMUTESEL0(n)			(n << 0)
+#define CFGCHIP1_AMUTESEL0_MASK			CFGCHIP1_AMUTESEL0(0xf)
+#define CFGCHIP1_AMUTESEL0_LOW			CFGCHIP1_AMUTESEL0(0x0)
+#define CFGCHIP1_AMUTESEL0_BANK_0		CFGCHIP1_AMUTESEL0(0x1)
+#define CFGCHIP1_AMUTESEL0_BANK_1		CFGCHIP1_AMUTESEL0(0x2)
+#define CFGCHIP1_AMUTESEL0_BANK_2		CFGCHIP1_AMUTESEL0(0x3)
+#define CFGCHIP1_AMUTESEL0_BANK_3		CFGCHIP1_AMUTESEL0(0x4)
+#define CFGCHIP1_AMUTESEL0_BANK_4		CFGCHIP1_AMUTESEL0(0x5)
+#define CFGCHIP1_AMUTESEL0_BANK_5		CFGCHIP1_AMUTESEL0(0x6)
+#define CFGCHIP1_AMUTESEL0_BANK_6		CFGCHIP1_AMUTESEL0(0x7)
+#define CFGCHIP1_AMUTESEL0_BANK_7		CFGCHIP1_AMUTESEL0(0x8)
+
+/* CFGCHIP2 (USB PHY) register bits */
+#define CFGCHIP2_PHYCLKGD			BIT(17)
+#define CFGCHIP2_VBUSSENSE			BIT(16)
+#define CFGCHIP2_RESET				BIT(15)
+#define CFGCHIP2_OTGMODE(n)			(n << 13)
+#define CFGCHIP2_OTGMODE_MASK			CFGCHIP2_OTGMODE(0x3)
+#define CFGCHIP2_OTGMODE_NO_OVERRIDE		CFGCHIP2_OTGMODE(0x0)
+#define CFGCHIP2_OTGMODE_FORCE_HOST		CFGCHIP2_OTGMODE(0x1)
+#define CFGCHIP2_OTGMODE_FORCE_DEVICE		CFGCHIP2_OTGMODE(0x2)
+#define CFGCHIP2_OTGMODE_FORCE_HOST_VBUS_LOW	CFGCHIP2_OTGMODE(0x3)
+#define CFGCHIP2_USB1PHYCLKMUX			BIT(12)
+#define CFGCHIP2_USB2PHYCLKMUX			BIT(11)
+#define CFGCHIP2_PHYPWRDN			BIT(10)
+#define CFGCHIP2_OTGPWRDN			BIT(9)
+#define CFGCHIP2_DATPOL				BIT(8)
+#define CFGCHIP2_USB1SUSPENDM			BIT(7)
+#define CFGCHIP2_PHY_PLLON			BIT(6)
+#define CFGCHIP2_SESENDEN			BIT(5)
+#define CFGCHIP2_VBDTCTEN			BIT(4)
+#define CFGCHIP2_REFFREQ(n)			(n << 0)
+#define CFGCHIP2_REFFREQ_MASK			CFGCHIP2_REFFREQ(0xf)
+#define CFGCHIP2_REFFREQ_12MHZ			CFGCHIP2_REFFREQ(0x1)
+#define CFGCHIP2_REFFREQ_24MHZ			CFGCHIP2_REFFREQ(0x2)
+#define CFGCHIP2_REFFREQ_48MHZ			CFGCHIP2_REFFREQ(0x3)
+#define CFGCHIP2_REFFREQ_19_2MHZ		CFGCHIP2_REFFREQ(0x4)
+#define CFGCHIP2_REFFREQ_38_4MHZ		CFGCHIP2_REFFREQ(0x5)
+#define CFGCHIP2_REFFREQ_13MHZ			CFGCHIP2_REFFREQ(0x6)
+#define CFGCHIP2_REFFREQ_26MHZ			CFGCHIP2_REFFREQ(0x7)
+#define CFGCHIP2_REFFREQ_20MHZ			CFGCHIP2_REFFREQ(0x8)
+#define CFGCHIP2_REFFREQ_40MHZ			CFGCHIP2_REFFREQ(0x9)
+
+/* CFGCHIP3 (EMAC/uPP/PLL1/ASYNC3/PRU/DIV4.5/EMIFA) register bits */
+
+#define CFGCHIP3_RMII_SEL			BIT(8)
+#define CFGCHIP3_UPP_TX_CLKSRC			BIT(6)
+#define CFGCHIP3_PLL1_MASTER_LOCK		BIT(5)
+#define CFGCHIP3_ASYNC3_CLKSRC			BIT(4)
+#define CFGCHIP3_PRUEVTSEL			BIT(3)
+#define CFGCHIP3_DIV45PENA			BIT(2)
+#define CFGCHIP3_EMA_CLKSRC			BIT(1)
+
+/* CFGCHIP4 (McASP0 AMUNTEIN) register bits */
+
+#define CFGCHIP4_AMUTECLR0			BIT(0)
+
+#endif /* __LINUX_MFD_DA8XX_CFGCHIP_H */
include/linux/platform_data/usb-davinci.h +0 -23
index e0bc4ab..7c6ce24 100644
@@ -11,28 +11,6 @@
 #ifndef __ASM_ARCH_USB_H
 #define __ASM_ARCH_USB_H
 
-/* DA8xx CFGCHIP2 (USB 2.0 PHY Control) register bits */
-#define CFGCHIP2_PHYCLKGD	(1 << 17)
-#define CFGCHIP2_VBUSSENSE	(1 << 16)
-#define CFGCHIP2_RESET		(1 << 15)
-#define CFGCHIP2_OTGMODE	(3 << 13)
-#define CFGCHIP2_NO_OVERRIDE	(0 << 13)
-#define CFGCHIP2_FORCE_HOST	(1 << 13)
-#define CFGCHIP2_FORCE_DEVICE 	(2 << 13)
-#define CFGCHIP2_FORCE_HOST_VBUS_LOW (3 << 13)
-#define CFGCHIP2_USB1PHYCLKMUX	(1 << 12)
-#define CFGCHIP2_USB2PHYCLKMUX	(1 << 11)
-#define CFGCHIP2_PHYPWRDN	(1 << 10)
-#define CFGCHIP2_OTGPWRDN	(1 << 9)
-#define CFGCHIP2_DATPOL 	(1 << 8)
-#define CFGCHIP2_USB1SUSPENDM	(1 << 7)
-#define CFGCHIP2_PHY_PLLON	(1 << 6)	/* override PLL suspend */
-#define CFGCHIP2_SESENDEN	(1 << 5)	/* Vsess_end comparator */
-#define CFGCHIP2_VBDTCTEN	(1 << 4)	/* Vbus comparator */
-#define CFGCHIP2_REFFREQ	(0xf << 0)
-#define CFGCHIP2_REFFREQ_12MHZ	(1 << 0)
-#define CFGCHIP2_REFFREQ_24MHZ	(2 << 0)
-#define CFGCHIP2_REFFREQ_48MHZ	(3 << 0)
 
 struct	da8xx_ohci_root_hub;
 
@@ -53,7 +31,6 @@ struct	da8xx_ohci_root_hub {
 	/* Time from power on to power good (in 2 ms units) */
 	u8	potpgt;
 };
-
 void davinci_setup_usb(unsigned mA, unsigned potpgt_ms);
 
 #endif	/* ifndef __ASM_ARCH_USB_H */
Signature · 1 line
1.9.1
#8 lore raw

Re: [PATCH v3 02/16] mfd: da8xx-cfgchip: New header file for CFGCHIP registers.

Quoted 28 lines · David Lechner

We will be using a generic syscon device for the TI DA8XX SoC CFGCHIPx retisters. This will be used by a number of planned drivers including a new USB PHY driver and common clock framework drivers.

The same defines are removed from the platform_data header file since they are now redundant and they didn't really belong there anyway.

---

v3 changes: This is a new patch. It replaces the previous patch that just added some missing CFGCHIP2 registers to the platform_data/usb-davinci.h file. I took David Laight's advice and included all of the possible registers.

Many of these registers will be used for clocks - hopefully in the near future.

include/linux/mfd/da8xx-cfgchip.h | 160 ++++++++++++++++++++++++++++++

  include/linux/platform_data/usb-davinci.h |  23 -----
  2 files changed, 160 insertions(+), 23 deletions(-)

create mode 100644 include/linux/mfd/da8xx-cfgchip.h

include/linux/mfd/da8xx-cfgchip.h new file +0 -0
new file mode 100644
index 0000000..6940cf9
@@ -0,0 +1,160 @@

[...]

include/linux/mfd/da8xx-cfgchip.h line 28

Quoted 7 lines
include/linux/mfd/da8xx-cfgchip.h new file +7 -0
+/* register offsets */
+#define CFGCHIP_REG(n)				(n * 4)
+#define CFGCHIP0_REG				CFGCHIP_REG(0)
+#define CFGCHIP1_REG				CFGCHIP_REG(1)
+#define CFGCHIP2_REG				CFGCHIP_REG(2)
+#define CFGCHIP3_REG				CFGCHIP_REG(3)
+#define CFGCHIP4_REG				CFGCHIP_REG(4)

Why not just use CFGCHIP_REG(n) directly?

[...]

Quoted 4 lines
include/linux/platform_data/usb-davinci.h +0 -0
index e0bc4ab..7c6ce24 100644

[...]

include/linux/platform_data/usb-davinci.h struct da8xx_ohci_root_hub { · line 56

Quoted 5 lines
include/linux/platform_data/usb-davinci.h +0 -1
@@ -53,7 +31,6 @@ struct	da8xx_ohci_root_hub {
  	/* Time from power on to power good (in 2 ms units) */
  	u8	potpgt;
  };
-

Why?

include/linux/platform_data/usb-davinci.h struct da8xx_ohci_root_hub { · line 36

Quoted 3 lines
include/linux/platform_data/usb-davinci.h +0 -0
  void davinci_setup_usb(unsigned mA, unsigned potpgt_ms);
 
  #endif	/* ifndef __ASM_ARCH_USB_H */

MBR, Sergei

#9 lore raw

Re: [PATCH v3 02/16] mfd: da8xx-cfgchip: New header file for CFGCHIP registers.

Quoted 10 lines · Sergei Shtylyov

include/linux/mfd/da8xx-cfgchip.h line 28

Quoted 7 lines · David Lechner
include/linux/mfd/da8xx-cfgchip.h new file +7 -0
+/* register offsets */
+#define CFGCHIP_REG(n)                (n * 4)
+#define CFGCHIP0_REG                CFGCHIP_REG(0)
+#define CFGCHIP1_REG                CFGCHIP_REG(1)
+#define CFGCHIP2_REG                CFGCHIP_REG(2)
+#define CFGCHIP3_REG                CFGCHIP_REG(3)
+#define CFGCHIP4_REG                CFGCHIP_REG(4)

Why not just use CFGCHIP_REG(n) directly?

I considered that, but I went this way because A) the TRM uses, for example, "CFGCHIP2", so I wanted to keep "CFGCHIP" and "2" together and
B) this tells you how many CFGCHIP registers there are, i.e. there is no CFGCHIP5_REG.

Quoted 7 lines

include/linux/platform_data/usb-davinci.h struct da8xx_ohci_root_hub { · line 56

Quoted 5 lines
include/linux/platform_data/usb-davinci.h +0 -1
@@ -53,7 +31,6 @@ struct    da8xx_ohci_root_hub {
      /* Time from power on to power good (in 2 ms units) */
      u8    potpgt;
  };
-

Why?

Unintentional. Must have sneaked in through rebasing or something.

#10 lore raw

Re: [PATCH v3 02/16] mfd: da8xx-cfgchip: New header file for CFGCHIP registers.

Hello.

Quoted 10 lines · David Lechner
Quoted 9 lines

include/linux/mfd/da8xx-cfgchip.h line 28

Quoted 7 lines
include/linux/mfd/da8xx-cfgchip.h new file +7 -0
+/* register offsets */
+#define CFGCHIP_REG(n)                (n * 4)
+#define CFGCHIP0_REG                CFGCHIP_REG(0)
+#define CFGCHIP1_REG                CFGCHIP_REG(1)
+#define CFGCHIP2_REG                CFGCHIP_REG(2)
+#define CFGCHIP3_REG                CFGCHIP_REG(3)
+#define CFGCHIP4_REG                CFGCHIP_REG(4)

Why not just use CFGCHIP_REG(n) directly?

Quoted 2 lines

I considered that, but I went this way because A) the TRM uses, for example, "CFGCHIP2", so I wanted to keep "CFGCHIP" and "2" together

I'd just drop the _REG suffix.

Quoted 2 lines

and B) this tells
you how many CFGCHIP registers there are, i.e. there is no CFGCHIP5_REG.

You can tell that in a comment. Having a parametrized macro and using it
to just #define more macros doesn't appeal to me at all...

MBR, Sergei

#11 lore raw

Re: [PATCH v3 02/16] mfd: da8xx-cfgchip: New header file for CFGCHIP registers.

Quoted 17 lines · Sergei Shtylyov

Hello.

Quoted 13 lines · David Lechner
Quoted 9 lines

include/linux/mfd/da8xx-cfgchip.h line 28

Quoted 7 lines
include/linux/mfd/da8xx-cfgchip.h new file +7 -0
+/* register offsets */
+#define CFGCHIP_REG(n)                (n * 4)
+#define CFGCHIP0_REG                CFGCHIP_REG(0)
+#define CFGCHIP1_REG                CFGCHIP_REG(1)
+#define CFGCHIP2_REG                CFGCHIP_REG(2)
+#define CFGCHIP3_REG                CFGCHIP_REG(3)
+#define CFGCHIP4_REG                CFGCHIP_REG(4)

Why not just use CFGCHIP_REG(n) directly?

I considered that, but I went this way because A) the TRM uses, for example,
"CFGCHIP2", so I wanted to keep "CFGCHIP" and "2" together

IMO, this is not that big of an issue. Anyone reading should be able to make out that CFGCHIP_REG(0) is same as CFGCHIP0 referred to in the TRM.

Quoted 8 lines

I'd just drop the _REG suffix.

Quoted 2 lines

and B) this tells
you how many CFGCHIP registers there are, i.e. there is no CFGCHIP5_REG.

You can tell that in a comment. Having a parametrized macro and using
it to just #define more macros doesn't appeal to me at all...

Agree with Sergei, I don't prefer the additional #defines as well.

Regards,
Sekhar

#12 lore raw

PATCH v3 3/16 ARM: davinici: da8xx: move usb code to new file

In reply to David Lechner

We will be adding more da8xx-specific code for phy and clocks, so it will be better to have this in a separate file. This way we don't have a bunch of #ifdefs for all of the da8xx stuff.

---

v3 changes: this is a new patch. The diff in git looked much nicer. Instead of a whole new file, usb-da8xx.c is diffed to usb.c.

 arch/arm/mach-davinci/Makefile    |   4 +-
 arch/arm/mach-davinci/usb-da8xx.c | 124 ++++++++++++++++++++++++++++++++++++++
 arch/arm/mach-davinci/usb.c       |  74 +----------------------
 3 files changed, 127 insertions(+), 75 deletions(-)
 create mode 100644 arch/arm/mach-davinci/usb-da8xx.c
arch/arm/mach-davinci/Makefile +2 -2
index 2e3464b..da4c336 100644
@@ -14,8 +14,8 @@ obj-$(CONFIG_ARCH_DAVINCI_DM644x)       += dm644x.o devices.o
 obj-$(CONFIG_ARCH_DAVINCI_DM355)        += dm355.o devices.o
 obj-$(CONFIG_ARCH_DAVINCI_DM646x)       += dm646x.o devices.o
 obj-$(CONFIG_ARCH_DAVINCI_DM365)	+= dm365.o devices.o
-obj-$(CONFIG_ARCH_DAVINCI_DA830)        += da830.o devices-da8xx.o
-obj-$(CONFIG_ARCH_DAVINCI_DA850)        += da850.o devices-da8xx.o
+obj-$(CONFIG_ARCH_DAVINCI_DA830)	+= da830.o devices-da8xx.o usb-da8xx.o
+obj-$(CONFIG_ARCH_DAVINCI_DA850)	+= da850.o devices-da8xx.o usb-da8xx.o
 
 obj-$(CONFIG_AINTC)			+= irq.o
 obj-$(CONFIG_CP_INTC)			+= cp_intc.o
arch/arm/mach-davinci/usb-da8xx.c new file +124 -0

124 lines not on this page · raw message

arch/arm/mach-davinci/usb.c +1 -73

95 lines not on this page · raw message

Signature · 1 line
1.9.1
#13 lore raw

Re: [PATCH v3 03/16] ARM: davinici: da8xx: move usb code to new file

Quoted 5 lines · David Lechner

We will be adding more da8xx-specific code for phy and clocks, so it will be better to have this in a separate file. This way we don't have a bunch of #ifdefs for all of the da8xx stuff.

Applied this patch with a couple of local changes.

1) The subject line has a typo: s/davinici/davinci
2) There are checkpatch warnings in new code that are coming from old code. Even though this is just code movement, I prefer new code is free of checkpatch warnings.

Here is the updated patch.

Thanks,
Sekhar

---8<---
From: David Lechner <[email protected]>
Date: Thu, 24 Mar 2016 18:51:28 -0500
Subject: [PATCH] ARM: davinci: da8xx: move usb code to new file

We will be adding more da8xx-specific code for phy and clocks, so it will be better to have this in a separate file. This way we don't have a bunch of #ifdefs for all of the da8xx stuff.

While at it, fix some checkpatch warnings coming from existing code.

[nsekhar at ti.com: typo and checkpatch fixes]
---
 arch/arm/mach-davinci/Makefile    |   4 +-
 arch/arm/mach-davinci/usb-da8xx.c | 124 ++++++++++++++++++++++++++++++++++++++
 arch/arm/mach-davinci/usb.c       |  74 +----------------------
 3 files changed, 127 insertions(+), 75 deletions(-)
 create mode 100644 arch/arm/mach-davinci/usb-da8xx.c
arch/arm/mach-davinci/Makefile +2 -2
index 2e3464b8bab4..da4c336b4637 100644
@@ -14,8 +14,8 @@ obj-$(CONFIG_ARCH_DAVINCI_DM644x)       += dm644x.o devices.o
 obj-$(CONFIG_ARCH_DAVINCI_DM355)        += dm355.o devices.o
 obj-$(CONFIG_ARCH_DAVINCI_DM646x)       += dm646x.o devices.o
 obj-$(CONFIG_ARCH_DAVINCI_DM365)	+= dm365.o devices.o
-obj-$(CONFIG_ARCH_DAVINCI_DA830)        += da830.o devices-da8xx.o
-obj-$(CONFIG_ARCH_DAVINCI_DA850)        += da850.o devices-da8xx.o
+obj-$(CONFIG_ARCH_DAVINCI_DA830)	+= da830.o devices-da8xx.o usb-da8xx.o
+obj-$(CONFIG_ARCH_DAVINCI_DA850)	+= da850.o devices-da8xx.o usb-da8xx.o
 
 obj-$(CONFIG_AINTC)			+= irq.o
 obj-$(CONFIG_CP_INTC)			+= cp_intc.o
arch/arm/mach-davinci/usb-da8xx.c new file +124 -0

124 lines not on this page · raw message

arch/arm/mach-davinci/usb.c +1 -73

95 lines not on this page · raw message

Signature · 1 line
2.6.3
#14 lore raw

PATCH v3 4/16 ARM: davinci: Move clock init after ioremap.

In reply to David Lechner

Some clocks (such as the USB PHY clocks in DA8xx) will need to use iomem. The davinci_common_init() function must be called before the ioremap, so the clock init is now split out as separate function.

---

v3 changes: This is a new patch. It takes care of the issue of unwanted ioremap in clock set_parent functions.

 arch/arm/mach-davinci/clock.c  | 4 ++--
 arch/arm/mach-davinci/clock.h  | 7 ++++++-
 arch/arm/mach-davinci/common.c | 6 ------
 arch/arm/mach-davinci/da830.c  | 2 ++
 arch/arm/mach-davinci/da850.c  | 2 ++
 arch/arm/mach-davinci/dm355.c  | 1 +
 arch/arm/mach-davinci/dm365.c  | 1 +
 arch/arm/mach-davinci/dm644x.c | 1 +
 arch/arm/mach-davinci/dm646x.c | 1 +
 9 files changed, 16 insertions(+), 9 deletions(-)
arch/arm/mach-davinci/clock.c +2 -2
index 3424eac6..a5c2629 100644
@@ -560,7 +560,7 @@ EXPORT_SYMBOL(davinci_set_pllrate);
  * than that used by default in <soc>.c file. The reference clock rate
  * should be updated early in the boot process; ideally soon after the
  * clock tree has been initialized once with the default reference clock
- * rate (davinci_common_init()).
+ * rate (davinci_clk_init()).
  *
  * Returns 0 on success, error otherwise.
  */
@@ -581,7 +581,7 @@ int davinci_set_refclk_rate(unsigned long rate)
 	return 0;
 }
 
-int __init davinci_clk_init(struct clk_lookup *clocks)
+int __init _davinci_clk_init(struct clk_lookup *clocks)
 {
 	struct clk_lookup *c;
 	struct clk *clk;
arch/arm/mach-davinci/clock.h +6 -1
index 1e4e836..8b0fbbe 100644
@@ -124,7 +124,12 @@ struct clk {
 		.clk = ck,	\
 	}			\
 
-int davinci_clk_init(struct clk_lookup *clocks);
+int _davinci_clk_init(struct clk_lookup *clocks);
+static inline void davinci_clk_init(struct davinci_soc_info *soc_info)
+{
+	if (soc_info->cpu_clks && _davinci_clk_init(soc_info->cpu_clks))
+		panic("davinci_clk_init: Failed to init clocks.\n");
+}
 int davinci_set_pllrate(struct pll_data *pll, unsigned int prediv,
 				unsigned int mult, unsigned int postdiv);
 int davinci_set_sysclk_rate(struct clk *clk, unsigned long rate);
arch/arm/mach-davinci/common.c +0 -6
index f55ef2e..6bc8c22 100644
@@ -103,12 +103,6 @@ void __init davinci_common_init(struct davinci_soc_info *soc_info)
 	if (ret < 0)
 		goto err;
 
-	if (davinci_soc_info.cpu_clks) {
-		ret = davinci_clk_init(davinci_soc_info.cpu_clks);
-
-		if (ret != 0)
-			goto err;
-	}
 
 	return;
 
arch/arm/mach-davinci/da830.c +2 -0
index 7187e7f..79d5fc3 100644
@@ -1214,4 +1214,6 @@ void __init da830_init(void)
 
 	da8xx_syscfg0_base = ioremap(DA8XX_SYSCFG0_BASE, SZ_4K);
 	WARN(!da8xx_syscfg0_base, "Unable to map syscfg0 module");
+
+	davinci_clk_init(&davinci_soc_info_da830);
 }
arch/arm/mach-davinci/da850.c +2 -0
index 97d8779..9f46706 100644
@@ -1346,4 +1346,6 @@ void __init da850_init(void)
 	v = __raw_readl(DA8XX_SYSCFG0_VIRT(DA8XX_CFGCHIP3_REG));
 	v &= ~CFGCHIP3_PLL1_MASTER_LOCK;
 	__raw_writel(v, DA8XX_SYSCFG0_VIRT(DA8XX_CFGCHIP3_REG));
+
+	davinci_clk_init(&davinci_soc_info_da850);
 }
arch/arm/mach-davinci/dm355.c +1 -0
index a0ecf49..b311b84 100644
@@ -1052,6 +1052,7 @@ void __init dm355_init(void)
 {
 	davinci_common_init(&davinci_soc_info_dm355);
 	davinci_map_sysmod();
+	davinci_clk_init(&davinci_soc_info_dm355);
 }
 
 int __init dm355_init_video(struct vpfe_config *vpfe_cfg,
arch/arm/mach-davinci/dm365.c +1 -0
index 384d367..2338875 100644
@@ -1176,6 +1176,7 @@ void __init dm365_init(void)
 {
 	davinci_common_init(&davinci_soc_info_dm365);
 	davinci_map_sysmod();
+	davinci_clk_init(&davinci_soc_info_dm365);
 }
 
 static struct resource dm365_vpss_resources[] = {
arch/arm/mach-davinci/dm644x.c +1 -0
index b4b3a8b..5e672ed 100644
@@ -932,6 +932,7 @@ void __init dm644x_init(void)
 {
 	davinci_common_init(&davinci_soc_info_dm644x);
 	davinci_map_sysmod();
+	davinci_clk_init(&davinci_soc_info_dm644x);
 }
 
 int __init dm644x_init_video(struct vpfe_config *vpfe_cfg,
arch/arm/mach-davinci/dm646x.c +1 -0
index a43db0f..2840263 100644
@@ -956,6 +956,7 @@ void __init dm646x_init(void)
 {
 	davinci_common_init(&davinci_soc_info_dm646x);
 	davinci_map_sysmod();
+	davinci_clk_init(&davinci_soc_info_dm646x);
 }
 
 static int __init dm646x_init_devices(void)
Signature · 1 line
1.9.1
#15 lore raw

Re: [PATCH v3 04/16] ARM: davinci: Move clock init after ioremap.

Quoted 49 lines · David Lechner

Some clocks (such as the USB PHY clocks in DA8xx) will need to use iomem. The davinci_common_init() function must be called before the ioremap, so the clock init is now split out as separate function.

---

v3 changes: This is a new patch. It takes care of the issue of unwanted ioremap in clock set_parent functions.

 arch/arm/mach-davinci/clock.c  | 4 ++--
 arch/arm/mach-davinci/clock.h  | 7 ++++++-
 arch/arm/mach-davinci/common.c | 6 ------
 arch/arm/mach-davinci/da830.c  | 2 ++
 arch/arm/mach-davinci/da850.c  | 2 ++
 arch/arm/mach-davinci/dm355.c  | 1 +
 arch/arm/mach-davinci/dm365.c  | 1 +
 arch/arm/mach-davinci/dm644x.c | 1 +
 arch/arm/mach-davinci/dm646x.c | 1 +
 9 files changed, 16 insertions(+), 9 deletions(-)
arch/arm/mach-davinci/clock.c +2 -2
index 3424eac6..a5c2629 100644
@@ -560,7 +560,7 @@ EXPORT_SYMBOL(davinci_set_pllrate);
  * than that used by default in <soc>.c file. The reference clock rate
  * should be updated early in the boot process; ideally soon after the
  * clock tree has been initialized once with the default reference clock
- * rate (davinci_common_init()).
+ * rate (davinci_clk_init()).
  *
  * Returns 0 on success, error otherwise.
  */
@@ -581,7 +581,7 @@ int davinci_set_refclk_rate(unsigned long rate)
 	return 0;
 }
 
-int __init davinci_clk_init(struct clk_lookup *clocks)
+int __init _davinci_clk_init(struct clk_lookup *clocks)
 {
 	struct clk_lookup *c;
 	struct clk *clk;
arch/arm/mach-davinci/clock.h +0 -0
index 1e4e836..8b0fbbe 100644

arch/arm/mach-davinci/clock.h struct clk { · line 132

Quoted 10 lines
arch/arm/mach-davinci/clock.h +6 -1
@@ -124,7 +124,12 @@ struct clk {
 		.clk = ck,	\
 	}			\
 
-int davinci_clk_init(struct clk_lookup *clocks);
+int _davinci_clk_init(struct clk_lookup *clocks);
+static inline void davinci_clk_init(struct davinci_soc_info *soc_info)
+{
+	if (soc_info->cpu_clks && _davinci_clk_init(soc_info->cpu_clks))
+		panic("davinci_clk_init: Failed to init clocks.\n");
+}

I am not sure about the need for an additional API (_davinci_clk_init) especially when you end up exposing both through clock.h. Just make make calls from SoC files like:

	davinci_clk_init(davinci_soc_info_da830.cpu_clks);

I would ignore the panic() call too since davinci_clk_init() does not really return an error (never has).

Thanks,
Sekhar

#16 lore raw

PATCH v3 5/16 ARM: davinci: add set_parent callback for mux clocks

In reply to David Lechner

Introduce a set_parent callback that will be used for mux clocks, such as the USB PHY muxes and the async3 clock domain mux.

---

v3 changes: none.

 arch/arm/mach-davinci/clock.c | 17 ++++++++++++++++-
 arch/arm/mach-davinci/clock.h |  1 +
 2 files changed, 17 insertions(+), 1 deletion(-)
arch/arm/mach-davinci/clock.c +16 -1
index a5c2629..dfc2eb3 100644
@@ -195,6 +195,13 @@ int clk_set_parent(struct clk *clk, struct clk *parent)
 		return -EINVAL;
 
 	mutex_lock(&clocks_mutex);
+	if (clk->set_parent) {
+		int ret = clk->set_parent(clk, parent);
+		if (ret) {
+			mutex_unlock(&clocks_mutex);
+			return ret;
+		}
+	}
 	clk->parent = parent;
 	list_del_init(&clk->childnode);
 	list_add(&clk->childnode, &clk->parent->children);
@@ -224,8 +231,16 @@ int clk_register(struct clk *clk)
 
 	mutex_lock(&clocks_mutex);
 	list_add_tail(&clk->node, &clocks);
-	if (clk->parent)
+	if (clk->parent) {
+		if (clk->set_parent) {
+			int ret = clk->set_parent(clk, clk->parent);
+			if (ret) {
+				mutex_unlock(&clocks_mutex);
+				return ret;
+			}
+		}
 		list_add_tail(&clk->childnode, &clk->parent->children);
+	}
 	mutex_unlock(&clocks_mutex);
 
 	/* If rate is already set, use it */
arch/arm/mach-davinci/clock.h +1 -0
index 8b0fbbe..96a591f 100644
@@ -106,6 +106,7 @@ struct clk {
 	int (*reset) (struct clk *clk, bool reset);
 	void (*clk_enable) (struct clk *clk);
 	void (*clk_disable) (struct clk *clk);
+	int (*set_parent) (struct clk *clk, struct clk *parent);
 };
 
 /* Clock flags: SoC-specific flags start at BIT(16) */
Signature · 1 line
1.9.1
#17 lore raw

Re: [PATCH v3 05/16] ARM: davinci: add set_parent callback for mux clocks

Quoted 18 lines · David Lechner

Introduce a set_parent callback that will be used for mux clocks, such as the USB PHY muxes and the async3 clock domain mux.

---

v3 changes: none.

 arch/arm/mach-davinci/clock.c | 17 ++++++++++++++++-
 arch/arm/mach-davinci/clock.h |  1 +
 2 files changed, 17 insertions(+), 1 deletion(-)
arch/arm/mach-davinci/clock.c +0 -0
index a5c2629..dfc2eb3 100644

arch/arm/mach-davinci/clock.c int clk_set_parent(struct clk *clk, struct clk *parent) · line 199

Quoted 5 lines
arch/arm/mach-davinci/clock.c +2 -0
@@ -195,6 +195,13 @@ int clk_set_parent(struct clk *clk, struct clk *parent)
 		return -EINVAL;
 
 	mutex_lock(&clocks_mutex);
+	if (clk->set_parent) {
+		int ret = clk->set_parent(clk, parent);

Need empty line here.

Quoted 9 lines
arch/arm/mach-davinci/clock.c +5 -0
+		if (ret) {
+			mutex_unlock(&clocks_mutex);
+			return ret;
+		}
+	}
 	clk->parent = parent;
 	list_del_init(&clk->childnode);
 	list_add(&clk->childnode, &clk->parent->children);

arch/arm/mach-davinci/clock.c int clk_register(struct clk *clk) · line 236

Quoted 7 lines
arch/arm/mach-davinci/clock.c +3 -1
@@ -224,8 +231,16 @@ int clk_register(struct clk *clk)
 
 	mutex_lock(&clocks_mutex);
 	list_add_tail(&clk->node, &clocks);
-	if (clk->parent)
+	if (clk->parent) {
+		if (clk->set_parent) {
+			int ret = clk->set_parent(clk, clk->parent);

Here too. Applying this patch with these local changes.

BTW, checkpatch complained about these. Please try to address all warnings unless there is a good reason not to fix one.

Thanks,
Sekhar

#18 lore raw

PATCH v3 6/16 ARM: davinci: da850: use clk->set_parent for async3

In reply to David Lechner

The da850 family of processors has an async3 clock domain that can be muxed to either pll0_sysclk2 or pll1_sysclk2. Now that the davinci clocks have a set_parent callback, we can use this to control the async3 mux instead of a stand-alone function.

This adds a new async3_clk and sets the appropriate child clocks. The default is use to pll1_sysclk2 since it is not affected by processor frequency scaling.

---

v3 changes:

* Does not use ioremap in da850_async3_set_parent(). This works now becuase the clock init has been moved.
* Fixed copy/paste error in a comment.

 arch/arm/mach-davinci/da850.c | 82 ++++++++++++++++++-------------------------
 1 file changed, 34 insertions(+), 48 deletions(-)
arch/arm/mach-davinci/da850.c +34 -48
index 9f46706..10bfbed 100644
@@ -34,9 +34,6 @@
 #include "clock.h"
 #include "mux.h"
 
-/* SoC specific clock flags */
-#define DA850_CLK_ASYNC3	BIT(16)
-
 #define DA850_PLL1_BASE		0x01e1a000
 #define DA850_TIMER64P2_BASE	0x01f0c000
 #define DA850_TIMER64P3_BASE	0x01f0d000
@@ -161,6 +158,33 @@ static struct clk pll1_sysclk3 = {
 	.div_reg	= PLLDIV3,
 };
 
+static int da850_async3_set_parent(struct clk *clk, struct clk *parent)
+{
+	u32 val;
+
+	val = readl(DA8XX_SYSCFG0_VIRT(DA8XX_CFGCHIP3_REG));
+
+	/* Set the Async3 clock domain mux based on the parent clock. */
+	if (parent == &pll0_sysclk2)
+		val &= ~CFGCHIP3_ASYNC3_CLKSRC;
+	else if (parent == &pll1_sysclk2)
+		val |= CFGCHIP3_ASYNC3_CLKSRC;
+	else {
+		pr_err("Bad parent on async3 clock mux.\n");
+		return -EINVAL;
+	}
+
+	writel(val, DA8XX_SYSCFG0_VIRT(DA8XX_CFGCHIP3_REG));
+
+	return 0;
+}
+
+static struct clk async3_clk = {
+	.name		= "async3",
+	.parent		= &pll1_sysclk2,
+	.set_parent	= da850_async3_set_parent,
+};
+
 static struct clk i2c0_clk = {
 	.name		= "i2c0",
 	.parent		= &pll0_aux_clk,
@@ -234,18 +258,16 @@ static struct clk uart0_clk = {
 
 static struct clk uart1_clk = {
 	.name		= "uart1",
-	.parent		= &pll0_sysclk2,
+	.parent		= &async3_clk,
 	.lpsc		= DA8XX_LPSC1_UART1,
 	.gpsc		= 1,
-	.flags		= DA850_CLK_ASYNC3,
 };
 
 static struct clk uart2_clk = {
 	.name		= "uart2",
-	.parent		= &pll0_sysclk2,
+	.parent		= &async3_clk,
 	.lpsc		= DA8XX_LPSC1_UART2,
 	.gpsc		= 1,
-	.flags		= DA850_CLK_ASYNC3,
 };
 
 static struct clk aintc_clk = {
@@ -300,10 +322,9 @@ static struct clk emac_clk = {
 
 static struct clk mcasp_clk = {
 	.name		= "mcasp",
-	.parent		= &pll0_sysclk2,
+	.parent		= &async3_clk,
 	.lpsc		= DA8XX_LPSC1_McASP0,
 	.gpsc		= 1,
-	.flags		= DA850_CLK_ASYNC3,
 };
 
 static struct clk lcdc_clk = {
@@ -355,10 +376,9 @@ static struct clk spi0_clk = {
 
 static struct clk spi1_clk = {
 	.name		= "spi1",
-	.parent		= &pll0_sysclk2,
+	.parent		= &async3_clk,
 	.lpsc		= DA8XX_LPSC1_SPI1,
 	.gpsc		= 1,
-	.flags		= DA850_CLK_ASYNC3,
 };
 
 static struct clk vpif_clk = {
@@ -386,10 +406,9 @@ static struct clk dsp_clk = {
 
 static struct clk ehrpwm_clk = {
 	.name		= "ehrpwm",
-	.parent		= &pll0_sysclk2,
+	.parent		= &async3_clk,
 	.lpsc		= DA8XX_LPSC1_PWM,
 	.gpsc		= 1,
-	.flags		= DA850_CLK_ASYNC3,
 };
 
 #define DA8XX_EHRPWM_TBCLKSYNC	BIT(12)
@@ -421,10 +440,9 @@ static struct clk ehrpwm_tbclk = {
 
 static struct clk ecap_clk = {
 	.name		= "ecap",
-	.parent		= &pll0_sysclk2,
+	.parent		= &async3_clk,
 	.lpsc		= DA8XX_LPSC1_ECAP,
 	.gpsc		= 1,
-	.flags		= DA850_CLK_ASYNC3,
 };
 
 static struct clk_lookup da850_clks[] = {
@@ -442,6 +460,7 @@ static struct clk_lookup da850_clks[] = {
 	CLK(NULL,		"pll1_aux",	&pll1_aux_clk),
 	CLK(NULL,		"pll1_sysclk2",	&pll1_sysclk2),
 	CLK(NULL,		"pll1_sysclk3",	&pll1_sysclk3),
+	CLK(NULL,		"async3",	&async3_clk),
 	CLK("i2c_davinci.1",	NULL,		&i2c0_clk),
 	CLK(NULL,		"timer0",	&timerp64_0_clk),
 	CLK("davinci-wdt",	NULL,		&timerp64_1_clk),
@@ -909,30 +928,6 @@ static struct davinci_timer_info da850_timer_info = {
 	.clocksource_id	= T0_TOP,
 };
 
-static void da850_set_async3_src(int pllnum)
-{
-	struct clk *clk, *newparent = pllnum ? &pll1_sysclk2 : &pll0_sysclk2;
-	struct clk_lookup *c;
-	unsigned int v;
-	int ret;
-
-	for (c = da850_clks; c->clk; c++) {
-		clk = c->clk;
-		if (clk->flags & DA850_CLK_ASYNC3) {
-			ret = clk_set_parent(clk, newparent);
-			WARN(ret, "DA850: unable to re-parent clock %s",
-								clk->name);
-		}
-       }
-
-	v = __raw_readl(DA8XX_SYSCFG0_VIRT(DA8XX_CFGCHIP3_REG));
-	if (pllnum)
-		v |= CFGCHIP3_ASYNC3_CLKSRC;
-	else
-		v &= ~CFGCHIP3_ASYNC3_CLKSRC;
-	__raw_writel(v, DA8XX_SYSCFG0_VIRT(DA8XX_CFGCHIP3_REG));
-}
-
 #ifdef CONFIG_CPU_FREQ
 /*
  * Notes:
@@ -1328,15 +1323,6 @@ void __init da850_init(void)
 	if (WARN(!da8xx_syscfg1_base, "Unable to map syscfg1 module"))
 		return;
 
-	/*
-	 * Move the clock source of Async3 domain to PLL1 SYSCLK2.
-	 * This helps keeping the peripherals on this domain insulated
-	 * from CPU frequency changes caused by DVFS. The firmware sets
-	 * both PLL0 and PLL1 to the same frequency so, there should not
-	 * be any noticeable change even in non-DVFS use cases.
-	 */
-	da850_set_async3_src(1);
-
 	/* Unlock writing to PLL0 registers */
 	v = __raw_readl(DA8XX_SYSCFG0_VIRT(DA8XX_CFGCHIP0_REG));
 	v &= ~CFGCHIP0_PLL_MASTER_LOCK;
Signature · 1 line
1.9.1
#19 lore raw

Re: [PATCH v3 06/16] ARM: davinci: da850: use clk->set_parent for async3

Quoted 16 lines · David Lechner

The da850 family of processors has an async3 clock domain that can be muxed to either pll0_sysclk2 or pll1_sysclk2. Now that the davinci clocks have a set_parent callback, we can use this to control the async3 mux instead of a stand-alone function.

This adds a new async3_clk and sets the appropriate child clocks. The default is use to pll1_sysclk2 since it is not affected by processor frequency scaling.

arch/arm/mach-davinci/da850.c +5 -0
+static int da850_async3_set_parent(struct clk *clk, struct clk *parent)
+{
+	u32 val;
+
+	val = readl(DA8XX_SYSCFG0_VIRT(DA8XX_CFGCHIP3_REG));

arch/arm/mach-davinci/da850.c static struct clk pll1_sysclk3 = { · line 175

Quoted 10 lines
arch/arm/mach-davinci/da850.c +10 -0
+
+	/* Set the Async3 clock domain mux based on the parent clock. */
+	if (parent == &pll0_sysclk2)
+		val &= ~CFGCHIP3_ASYNC3_CLKSRC;
+	else if (parent == &pll1_sysclk2)
+		val |= CFGCHIP3_ASYNC3_CLKSRC;
+	else {
+		pr_err("Bad parent on async3 clock mux.\n");
+		return -EINVAL;
+	}

Since else has braces, need braces on all arm of the if-else construct.

Applied this patch with this fixed locally. checkpatch complains about this too when --strict option is passed.

Thanks,
Sekhar

#20 lore raw

PATCH v3 7/16 ARM: davinci: da8xx: add usb phy clocks

In reply to 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_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.

---

v3 changes:

* Clocks are now in usb-da8xx.c instead of having duplicated code in da830.c and da850.c.
* No longer calling ioremap in set_parent() functions.
* Added timeout while waiting for PLL to lock.
* Renamed USB reference clock to usb_refclkin.
* Clocks are now dynamically registered.
* usb_refclkin rate is specified when registered, so it no longer has a default value of 48MHz. It does not have to be registered if it is not used.
* Parent clock for clock muxes are set when clock is registered.
* Board files that use da8xx usb are updated to call the new register functions.

 arch/arm/mach-davinci/board-da830-evm.c     |  22 ++-
 arch/arm/mach-davinci/board-omapl138-hawk.c |  16 +-
 arch/arm/mach-davinci/include/mach/da8xx.h  |   3 +
 arch/arm/mach-davinci/usb-da8xx.c           | 218 +++++++++++++++++++++++++++-
 4 files changed, 239 insertions(+), 20 deletions(-)
arch/arm/mach-davinci/board-da830-evm.c +10 -12
index 3d8cf8c..605d444 100644
@@ -115,18 +115,6 @@ static __init void da830_evm_usb_init(void)
 	 */
 	cfgchip2 = __raw_readl(DA8XX_SYSCFG0_VIRT(DA8XX_CFGCHIP2_REG));
 
-	/* USB2.0 PHY reference clock is 24 MHz */
-	cfgchip2 &= ~CFGCHIP2_REFFREQ;
-	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;
-
 	/*
 	 * We have to override VBUS/ID signals when MUSB is configured into the
 	 * host-only mode -- ID pin will float if no cable is connected, so the
@@ -143,6 +131,16 @@ static __init void da830_evm_usb_init(void)
 	__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 = davinci_cfg_reg(DA830_USB0_DRVVBUS);
 	if (ret)
 		pr_warn("%s: USB 2.0 PinMux setup failed: %d\n", __func__, ret);
arch/arm/mach-davinci/board-omapl138-hawk.c +9 -7
index ee62486..d4930b6 100644
@@ -243,7 +243,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) {
@@ -251,12 +250,15 @@ static __init void omapl138_hawk_usb_init(void)
 		return;
 	}
 
-	/* Setup the Ref. clock frequency for the HAWK at 24 MHz. */
-
-	cfgchip2 = __raw_readl(DA8XX_SYSCFG0_VIRT(DA8XX_CFGCHIP2_REG));
-	cfgchip2 &= ~CFGCHIP2_REFFREQ;
-	cfgchip2 |=  CFGCHIP2_REFFREQ_24MHZ;
-	__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 = gpio_request_one(DA850_USB1_VBUS_PIN,
 			GPIOF_DIR_OUT, "USB1 VBUS");
arch/arm/mach-davinci/include/mach/da8xx.h +3 -0
index f9f9713..c367530 100644
@@ -88,6 +88,9 @@ int da850_register_edma(struct edma_rsv_info *rsv[2]);
 int da8xx_register_i2c(int instance, struct davinci_i2c_platform_data *pdata);
 int da8xx_register_spi_bus(int instance, unsigned num_chipselect);
 int da8xx_register_watchdog(void);
+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_usb20(unsigned mA, unsigned potpgt);
 int da8xx_register_usb11(struct da8xx_ohci_root_hub *pdata);
 int da8xx_register_emac(void);
arch/arm/mach-davinci/usb-da8xx.c +217 -1

237 lines not on this page · raw message

Signature · 1 line
1.9.1
#21 lore raw

PATCH v3 8/16 dt-bindings: Add bindings for phy-da8xx-usb

In reply to David Lechner

Device tree binding for new phy-da8xx-usb driver.

---

v3 changes:

* added cfgchip info and example
* correct usage of "DA8xx"
* correct address after @
* dropped 11 before @ in usb@

 .../devicetree/bindings/phy/phy-da8xx-usb.txt      | 40 ++++++++++++++++++++++
 1 file changed, 40 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/phy/phy-da8xx-usb.txt
Documentation/devicetree/bindings/phy/phy-da8xx-usb.txt new file +40 -0
new file mode 100644
index 0000000..684c548
@@ -0,0 +1,40 @@
+TI DaVinci DA8xx USB PHY
+
+Required properties:
+ - compatible: must be "ti,da830-usbphy".
+ - #phy-cells: must be 1.
+
+This device controls the PHY for both the USB 1.1 OHCI and USB 2.0 OTG
+controllers on DA8xx SoCs. Consumers of this device should use index 1 for
+the USB 1.1 phy device and index 2 for the USB 2.0 phy device.
+
+It also requires a "syscon" node with compatible = "ti,da830-cfgchip", "syscon"
+to access the CFGCHIP2 register.
+
+Example:
+
+	cfgchip: cfgchip at 1417c {
+		compatible = "ti,da830-cfgchip", "syscon";
+		reg = <0x1417c 0x14>;
+	};
+
+	usbphy: usbphy {
+		compatible = "ti,da830-usbphy";
+		#phy-cells = <1>;
+	};
+
+	usb11: usb at 225000 {
+		compatible = "ti,da830-ohci";
+		reg = <0x225000 0x1000>;
+		interrupts = <59>;
+		phys = <&usbphy 1>;
+		phy-names = "usbphy";
+	};
+
+	usb20: usb at 200000 {
+		compatible = "ti,da830-musb";
+		reg = <0x200000 0x1000>;
+		interrupts = <58>;
+		phys = <&usbphy 2>;
+		phy-names = "usbphy";
+	};
Signature · 1 line
1.9.1
maintainer Acked-by on v3 8/16
#22 lore raw

Re: [PATCH v3 08/16] dt-bindings: Add bindings for phy-da8xx-usb

Quoted 13 lines · David Lechner

Device tree binding for new phy-da8xx-usb driver.

---

v3 changes:

* added cfgchip info and example
* correct usage of "DA8xx"
* correct address after @
* dropped 11 before @ in usb@

Quoted 3 lines
 .../devicetree/bindings/phy/phy-da8xx-usb.txt      | 40 ++++++++++++++++++++++
 1 file changed, 40 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/phy/phy-da8xx-usb.txt
#23 lore raw

PATCH v3 9/16 phy: da8xx-usb: new driver for DA8xx SoC USB PHY

In reply to David Lechner

This is a new phy driver for the SoC USB controllers on the TI DA8xx family of microcontrollers. The USB 1.1 PHY is just a simple on/off. The USB 2.0 PHY also allows overriding the VBUS and ID pins.

---

v3 changes:

* Uses syscon device for CFGCHIP2 instead of using it directly.
* Got rid of nop inline funtions
* Correct suffix on funtions to match ops.*
* Added header file for extern method.

 drivers/phy/Kconfig               |  10 ++
 drivers/phy/Makefile              |   1 +
 drivers/phy/phy-da8xx-usb.c       | 249 ++++++++++++++++++++++++++++++++++++++
 include/linux/phy/phy-da8xx-usb.h |  19 +++
 4 files changed, 279 insertions(+)
 create mode 100644 drivers/phy/phy-da8xx-usb.c
 create mode 100644 include/linux/phy/phy-da8xx-usb.h
drivers/phy/Kconfig +10 -0
index 26566db..c1d315f 100644
@@ -35,6 +35,16 @@ config ARMADA375_USBCLUSTER_PHY
 	depends on OF && HAS_IOMEM
 	select GENERIC_PHY
 
+config PHY_DA8XX_USB
+	tristate "TI DA8xx USB PHY Driver"
+	depends on ARCH_DAVINCI_DA8XX
+	select GENERIC_PHY
+	select MFD_SYSCON
+	help
+	  Enable this to support the USB PHY on DA8xx SoCs.
+
+	  This driver controls both the USB 1.1 PHY and the USB 2.0 PHY.
+
 config PHY_DM816X_USB
 	tristate "TI dm816x USB PHY driver"
 	depends on ARCH_OMAP2PLUS
drivers/phy/Makefile +1 -0
index 24596a9..722e01c 100644
@@ -5,6 +5,7 @@
 obj-$(CONFIG_GENERIC_PHY)		+= phy-core.o
 obj-$(CONFIG_PHY_BERLIN_USB)		+= phy-berlin-usb.o
 obj-$(CONFIG_PHY_BERLIN_SATA)		+= phy-berlin-sata.o
+obj-$(CONFIG_PHY_DA8XX_USB)		+= phy-da8xx-usb.o
 obj-$(CONFIG_PHY_DM816X_USB)		+= phy-dm816x-usb.o
 obj-$(CONFIG_ARMADA375_USBCLUSTER_PHY)	+= phy-armada375-usb2.o
 obj-$(CONFIG_BCM_KONA_USB2_PHY)		+= phy-bcm-kona-usb2.o
drivers/phy/phy-da8xx-usb.c new file +249 -0

249 lines not on this page · raw message

include/linux/phy/phy-da8xx-usb.h new file +19 -0
new file mode 100644
index 0000000..5d1b39e
@@ -0,0 +1,19 @@
+/*
+ * phy-da8xx-usb.h - TI DA8xx USB PHY driver
+ *
+ * Copyright (C) 2016 David Lechner <[email protected]>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ */
+
+#ifndef __PHY_DA8XX_USB_H
+#define __PHY_DA8XX_USB_H
+
+#include <linux/usb/musb.h>
+
+extern int da8xx_usb20_phy_set_mode(struct phy *phy, enum musb_mode mode);
+
+#endif /* __PHY_DA8XX_USB_H */
Signature · 1 line
1.9.1
#24 lore raw

PATCH 1/1 phy: da8xx-usb: new driver for DA8xx SoC USB PHY

This is a new phy driver for the SoC USB controllers on the TI DA8xx family of microcontrollers. The USB 1.1 PHY is just a simple on/off. The USB 2.0 PHY also allows overriding the VBUS and ID pins.

---

I made a last minute change and some renames slipped through the crack. This is the corrected patch.

 drivers/phy/Kconfig               |  10 ++
 drivers/phy/Makefile              |   1 +
 drivers/phy/phy-da8xx-usb.c       | 249 ++++++++++++++++++++++++++++++++++++++
 include/linux/phy/phy-da8xx-usb.h |  19 +++
 4 files changed, 279 insertions(+)
 create mode 100644 drivers/phy/phy-da8xx-usb.c
 create mode 100644 include/linux/phy/phy-da8xx-usb.h
drivers/phy/Kconfig +10 -0
index 26566db..c1d315f 100644
@@ -35,6 +35,16 @@ config ARMADA375_USBCLUSTER_PHY
 	depends on OF && HAS_IOMEM
 	select GENERIC_PHY
 
+config PHY_DA8XX_USB
+	tristate "TI DA8xx USB PHY Driver"
+	depends on ARCH_DAVINCI_DA8XX
+	select GENERIC_PHY
+	select MFD_SYSCON
+	help
+	  Enable this to support the USB PHY on DA8xx SoCs.
+
+	  This driver controls both the USB 1.1 PHY and the USB 2.0 PHY.
+
 config PHY_DM816X_USB
 	tristate "TI dm816x USB PHY driver"
 	depends on ARCH_OMAP2PLUS
drivers/phy/Makefile +1 -0
index 24596a9..722e01c 100644
@@ -5,6 +5,7 @@
 obj-$(CONFIG_GENERIC_PHY)		+= phy-core.o
 obj-$(CONFIG_PHY_BERLIN_USB)		+= phy-berlin-usb.o
 obj-$(CONFIG_PHY_BERLIN_SATA)		+= phy-berlin-sata.o
+obj-$(CONFIG_PHY_DA8XX_USB)		+= phy-da8xx-usb.o
 obj-$(CONFIG_PHY_DM816X_USB)		+= phy-dm816x-usb.o
 obj-$(CONFIG_ARMADA375_USBCLUSTER_PHY)	+= phy-armada375-usb2.o
 obj-$(CONFIG_BCM_KONA_USB2_PHY)		+= phy-bcm-kona-usb2.o
drivers/phy/phy-da8xx-usb.c new file +249 -0

249 lines not on this page · raw message

include/linux/phy/phy-da8xx-usb.h new file +19 -0
new file mode 100644
index 0000000..5d1b39e
@@ -0,0 +1,19 @@
+/*
+ * phy-da8xx-usb.h - TI DA8xx USB PHY driver
+ *
+ * Copyright (C) 2016 David Lechner <[email protected]>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ */
+
+#ifndef __PHY_DA8XX_USB_H
+#define __PHY_DA8XX_USB_H
+
+#include <linux/usb/musb.h>
+
+extern int da8xx_usb20_phy_set_mode(struct phy *phy, enum musb_mode mode);
+
+#endif /* __PHY_DA8XX_USB_H */
Signature · 1 line
1.9.1
#25 lore raw

Re: [PATCH] phy: da8xx-usb: new driver for DA8xx SoC USB PHY

Hello.

Quoted 5 lines · David Lechner

This is a new phy driver for the SoC USB controllers on the TI DA8xx family of microcontrollers. The USB 1.1 PHY is just a simple on/off. The USB 2.0 PHY also allows overriding the VBUS and ID pins.

[...]

Just some nit-picking.

Quoted 6 lines
drivers/phy/phy-da8xx-usb.c new file +0 -0
new file mode 100644
index 0000000..ecfd607
@@ -0,0 +1,249 @@

[...]

Quoted 1 line

+static int da8xx_usbphy_probe(struct platform_device *pdev)

[...]

drivers/phy/phy-da8xx-usb.c line 208

Quoted 13 lines
drivers/phy/phy-da8xx-usb.c new file +13 -0
+	if (node) {
+		d_phy->phy_provider = devm_of_phy_provider_register(dev,
+							da8xx_usbphy_of_xlate);
+		if (IS_ERR(d_phy->phy_provider)) {
+			dev_err(dev, "Failed to create phy provider.\n");
+			return PTR_ERR(d_phy->phy_provider);
+		}
+	} else {
+		int ret;
+
+		ret = phy_create_lookup(d_phy->usb11_phy, "usbphy", "ohci.0");
+		if (ret)
+			dev_warn(dev, "Failed to create usb11 phy lookup .\n");

Space before period? I'd omit the periods altogether...

drivers/phy/phy-da8xx-usb.c line 211

Quoted 3 lines
drivers/phy/phy-da8xx-usb.c new file +3 -0
+		ret = phy_create_lookup(d_phy->usb20_phy, "usbphy", "musb-da8xx");
+		if (ret)
+			dev_warn(dev, "Failed to create usb20 phy lookup .\n");

Likewise.

[...]

MBR, Sergei

#26 lore raw

Re: [PATCH v3 09/16] phy: da8xx-usb: new driver for DA8xx SoC USB PHY

In reply to David Lechner

Hi,

Quoted 180 lines · David Lechner

This is a new phy driver for the SoC USB controllers on the TI DA8xx family of microcontrollers. The USB 1.1 PHY is just a simple on/off. The USB 2.0 PHY also allows overriding the VBUS and ID pins.

---

v3 changes:

* Uses syscon device for CFGCHIP2 instead of using it directly.
* Got rid of nop inline funtions
* Correct suffix on funtions to match ops.*
* Added header file for extern method.

 drivers/phy/Kconfig               |  10 ++
 drivers/phy/Makefile              |   1 +
 drivers/phy/phy-da8xx-usb.c       | 249 ++++++++++++++++++++++++++++++++++++++
 include/linux/phy/phy-da8xx-usb.h |  19 +++
 4 files changed, 279 insertions(+)
 create mode 100644 drivers/phy/phy-da8xx-usb.c
 create mode 100644 include/linux/phy/phy-da8xx-usb.h
drivers/phy/Kconfig +10 -0
index 26566db..c1d315f 100644
@@ -35,6 +35,16 @@ config ARMADA375_USBCLUSTER_PHY
 	depends on OF && HAS_IOMEM
 	select GENERIC_PHY
 
+config PHY_DA8XX_USB
+	tristate "TI DA8xx USB PHY Driver"
+	depends on ARCH_DAVINCI_DA8XX
+	select GENERIC_PHY
+	select MFD_SYSCON
+	help
+	  Enable this to support the USB PHY on DA8xx SoCs.
+
+	  This driver controls both the USB 1.1 PHY and the USB 2.0 PHY.
+
 config PHY_DM816X_USB
 	tristate "TI dm816x USB PHY driver"
 	depends on ARCH_OMAP2PLUS
drivers/phy/Makefile +1 -0
index 24596a9..722e01c 100644
@@ -5,6 +5,7 @@
 obj-$(CONFIG_GENERIC_PHY)		+= phy-core.o
 obj-$(CONFIG_PHY_BERLIN_USB)		+= phy-berlin-usb.o
 obj-$(CONFIG_PHY_BERLIN_SATA)		+= phy-berlin-sata.o
+obj-$(CONFIG_PHY_DA8XX_USB)		+= phy-da8xx-usb.o
 obj-$(CONFIG_PHY_DM816X_USB)		+= phy-dm816x-usb.o
 obj-$(CONFIG_ARMADA375_USBCLUSTER_PHY)	+= phy-armada375-usb2.o
 obj-$(CONFIG_BCM_KONA_USB2_PHY)		+= phy-bcm-kona-usb2.o
drivers/phy/phy-da8xx-usb.c new file +118 -0
new file mode 100644
index 0000000..687d9a0
@@ -0,0 +1,249 @@
+/*
+ * phy-da8xx-usb - TI DaVinci DA8xx USB PHY driver
+ *
+ * Copyright (C) 2016 David Lechner <[email protected]>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ */
+
+#include <linux/clk.h>
+#include <linux/io.h>
+#include <linux/of.h>
+#include <linux/mfd/da8xx-cfgchip.h>
+#include <linux/mfd/syscon.h>
+#include <linux/module.h>
+#include <linux/phy/phy.h>
+#include <linux/phy/phy-da8xx-usb.h>
+#include <linux/platform_device.h>
+#include <linux/regmap.h>
+#include <linux/usb/gadget.h>
+#include <linux/usb/otg.h>
+
+struct da8xx_usbphy {
+	struct phy_provider	*phy_provider;
+	struct phy		*usb11_phy;
+	struct phy		*usb20_phy;
+	struct clk		*usb11_clk;
+	struct clk		*usb20_clk;
+	struct regmap		*regmap;
+};
+
+static int da8xx_usb11_phy_power_on(struct phy *phy)
+{
+	struct da8xx_usbphy *d_phy = phy_get_drvdata(phy);
+	int ret;
+
+	ret = clk_prepare_enable(d_phy->usb11_clk);
+	if (ret)
+		return ret;
+
+	regmap_write_bits(d_phy->regmap, CFGCHIP2_REG, CFGCHIP2_USB1SUSPENDM,
+			  CFGCHIP2_USB1SUSPENDM);
+
+	return 0;
+}
+
+static int da8xx_usb11_phy_power_off(struct phy *phy)
+{
+	struct da8xx_usbphy *d_phy = phy_get_drvdata(phy);
+
+	regmap_write_bits(d_phy->regmap, CFGCHIP2_REG, CFGCHIP2_USB1SUSPENDM, 0);
+
+	clk_disable_unprepare(d_phy->usb11_clk);
+
+	return 0;
+}
+
+static const struct phy_ops da8xx_usb11_phy_ops = {
+	.power_on	= da8xx_usb11_phy_power_on,
+	.power_off	= da8xx_usb11_phy_power_off,
+	.owner		= THIS_MODULE,
+};
+
+static int da8xx_usb20_phy_init(struct phy *phy)
+{
+	struct da8xx_usbphy *d_phy = phy_get_drvdata(phy);
+	int ret;
+
+	ret = clk_prepare_enable(d_phy->usb20_clk);
+	if (ret)
+		return ret;
+
+	regmap_write_bits(d_phy->regmap, CFGCHIP2_REG, CFGCHIP2_OTGPWRDN, 0);
+
+	return 0;
+}
+
+static int da8xx_usb20_phy_shutdown(struct phy *phy)
+{
+	struct da8xx_usbphy *d_phy = phy_get_drvdata(phy);
+
+	regmap_write_bits(d_phy->regmap, CFGCHIP2_REG, CFGCHIP2_OTGPWRDN,
+			  CFGCHIP2_OTGPWRDN);
+
+	clk_disable_unprepare(d_phy->usb20_clk);
+
+	return 0;
+}
+
+static const struct phy_ops da8xx_usb20_phy_ops = {
+	.power_on	= da8xx_usb20_phy_init,
+	.power_off	= da8xx_usb20_phy_shutdown,
+	.owner		= THIS_MODULE,
+};
+
+int da8xx_usb20_phy_set_mode(struct phy *phy, enum musb_mode mode)
+{
+	struct da8xx_usbphy *d_phy = phy_get_drvdata(phy);
+	u32 val;
+
+	switch (mode) {
+	case MUSB_HOST:		/* Force VBUS valid, ID = 0 */
+		val = CFGCHIP2_FORCE_HOST;
+		break;
+	case MUSB_PERIPHERAL:	/* Force VBUS valid, ID = 1 */
+		val = CFGCHIP2_FORCE_DEVICE;
+		break;
+	case MUSB_OTG:		/* Don't override the VBUS/ID comparators */
+		val = CFGCHIP2_NO_OVERRIDE;
+		break;

drivers/phy/phy-da8xx-usb.c line 128

Quoted 10 lines
drivers/phy/phy-da8xx-usb.c new file +10 -0
+	default:
+		return -EINVAL;
+	}
+
+	regmap_write_bits(d_phy->regmap, CFGCHIP2_REG, CFGCHIP2_OTGMODE_MASK,
+			  val);
+
+	return 0;
+}
+EXPORT_SYMBOL_GPL(da8xx_usb20_phy_set_mode);

Don't prefer export symbols from PHY driver. That'll create unnecessary dependencies between the controller and the PHY.

To see how to fix it, please see my comment for the previous version of your patch.

Thanks
Kishon

#27 lore raw

Re: [PATCH v3 09/16] phy: da8xx-usb: new driver for DA8xx SoC USB PHY

Quoted 9 lines · Kishon Vijay Abraham I

Don't prefer export symbols from PHY driver. That'll create unnecessary dependencies between the controller and the PHY.

To see how to fix it, please see my comment for the previous version of your patch.

Thanks
Kishon

What is the proper way to give you credit for the changes you suggested?

#28 lore raw

Re: [PATCH v3 09/16] phy: da8xx-usb: new driver for DA8xx SoC USB PHY

Hi,

Quoted 8 lines · David Lechner
Quoted 7 lines · Kishon Vijay Abraham I

Don't prefer export symbols from PHY driver. That'll create unnecessary dependencies between the controller and the PHY.

To see how to fix it, please see my comment for the previous version of your patch.

Quoted 6 lines
Quoted 3 lines

Thanks
Kishon

What is the proper way to give you credit for the changes you suggested?

Suggested-by: is commonly used. But if this patch goes via linux-phy tree, I'll also add my Signed-off-by ;-)

Thanks
Kishon

#29 lore raw

PATCH v3 10/16 ARM: davinci: da8xx: Add CFGCHIPn syscon platform declaration.

In reply to David Lechner

The CFGCHIPn registers are used by a number of devices, so using a syscon device to share them. The first consumer of this will by the phy-da8xx-usb driver.

---

v3 changes: This is a new patch. There is one syscon device for all CFGCHIP registers.

 arch/arm/mach-davinci/board-da830-evm.c     |  4 ++++
 arch/arm/mach-davinci/board-da850-evm.c     |  4 ++++
 arch/arm/mach-davinci/board-mityomapl138.c  |  4 ++++
 arch/arm/mach-davinci/board-omapl138-hawk.c |  4 ++++
 arch/arm/mach-davinci/devices-da8xx.c       | 28 ++++++++++++++++++++++++++++
 arch/arm/mach-davinci/include/mach/da8xx.h  |  2 ++
 6 files changed, 46 insertions(+)
arch/arm/mach-davinci/board-da830-evm.c +4 -0
index 605d444..3051cb6 100644
@@ -586,6 +586,10 @@ static __init void da830_evm_init(void)
 	struct davinci_soc_info *soc_info = &davinci_soc_info;
 	int ret;
 
+	ret = da8xx_register_cfgchip();
+	if (ret)
+		pr_warn("%s: CFGCHIP registration failed: %d\n", __func__, ret);
+
 	ret = da830_register_gpio();
 	if (ret)
 		pr_warn("%s: GPIO init failed: %d\n", __func__, ret);
arch/arm/mach-davinci/board-da850-evm.c +4 -0
index 8e4539f..ec5cb10 100644
@@ -1345,6 +1345,10 @@ static __init void da850_evm_init(void)
 {
 	int ret;
 
+	ret = da8xx_register_cfgchip();
+	if (ret)
+		pr_warn("%s: CFGCHIP registration failed: %d\n", __func__, ret);
+
 	ret = da850_register_gpio();
 	if (ret)
 		pr_warn("%s: GPIO init failed: %d\n", __func__, ret);
arch/arm/mach-davinci/board-mityomapl138.c +4 -0
index d97c588..c04b45d 100644
@@ -509,6 +509,10 @@ static void __init mityomapl138_init(void)
 {
 	int ret;
 
+	ret = da8xx_register_cfgchip();
+	if (ret)
+		pr_warn("%s: CFGCHIP registration failed: %d\n", __func__, ret);
+
 	/* for now, no special EDMA channels are reserved */
 	ret = da850_register_edma(NULL);
 	if (ret)
arch/arm/mach-davinci/board-omapl138-hawk.c +4 -0
index d4930b6..8691a25 100644
@@ -294,6 +294,10 @@ static __init void omapl138_hawk_init(void)
 {
 	int ret;
 
+	ret = da8xx_register_cfgchip();
+	if (ret)
+		pr_warn("%s: CFGCHIP registration failed: %d\n", __func__, ret);
+
 	ret = da850_register_gpio();
 	if (ret)
 		pr_warn("%s: GPIO init failed: %d\n", __func__, ret);
arch/arm/mach-davinci/devices-da8xx.c +28 -0
index 725e693..69d11a1 100644
@@ -11,6 +11,7 @@
  * (at your option) any later version.
  */
 #include <linux/init.h>
+#include <linux/platform_data/syscon.h>
 #include <linux/platform_device.h>
 #include <linux/dma-contiguous.h>
 #include <linux/serial_8250.h>
@@ -1109,3 +1110,30 @@ int __init da850_register_sata(unsigned long refclkpn)
 	return platform_device_register(&da850_sata_device);
 }
 #endif
+
+static struct syscon_platform_data da8xx_cfgchip_platform_data = {
+	.label	= "cfgchip",
+};
+
+static struct resource da8xx_cfgchip_resources[] = {
+	{
+		.start	= DA8XX_SYSCFG0_BASE + DA8XX_CFGCHIP0_REG,
+		.end	= DA8XX_SYSCFG0_BASE + DA8XX_CFGCHIP4_REG + 3,
+		.flags	= IORESOURCE_MEM,
+	},
+};
+
+static struct platform_device da8xx_cfgchip_device = {
+	.name	= "syscon",
+	.id	= 0,
+	.dev	= {
+		.platform_data	= &da8xx_cfgchip_platform_data,
+	},
+	.num_resources	= ARRAY_SIZE(da8xx_cfgchip_resources),
+	.resource	= da8xx_cfgchip_resources,
+};
+
+int __init da8xx_register_cfgchip(void)
+{
+	return platform_device_register(&da8xx_cfgchip_device);
+}
arch/arm/mach-davinci/include/mach/da8xx.h +2 -0
index c367530..c32444b 100644
@@ -61,6 +61,7 @@ extern unsigned int da850_max_speed;
 #define DA8XX_CFGCHIP1_REG	0x180
 #define DA8XX_CFGCHIP2_REG	0x184
 #define DA8XX_CFGCHIP3_REG	0x188
+#define DA8XX_CFGCHIP4_REG	0x18c
 
 #define DA8XX_SYSCFG1_BASE	(IO_PHYS + 0x22C000)
 #define DA8XX_SYSCFG1_VIRT(x)	(da8xx_syscfg1_base + (x))
@@ -116,6 +117,7 @@ void da8xx_rproc_reserve_cma(void);
 int da8xx_register_rproc(void);
 int da850_register_gpio(void);
 int da830_register_gpio(void);
+int da8xx_register_cfgchip(void);
 
 extern struct platform_device da8xx_serial_device[];
 extern struct emac_platform_data da8xx_emac_pdata;
Signature · 1 line
1.9.1
#30 lore raw

PATCH v3 11/16 ARM: davinci: da8xx: Add USB PHY platform declaration

In reply to David Lechner

There is now a proper phy driver for the DA8xx SoC USB PHY. This adds the platform device declarations needed to use it.

---

v3 changes:

* The declaration is now in the new usb-da8xx.c file.

 arch/arm/mach-davinci/board-da830-evm.c     | 28 +++++-----------------------
 arch/arm/mach-davinci/board-omapl138-hawk.c |  5 +++++
 arch/arm/mach-davinci/include/mach/da8xx.h  |  1 +
 arch/arm/mach-davinci/usb-da8xx.c           | 11 +++++++++++
 4 files changed, 22 insertions(+), 23 deletions(-)
arch/arm/mach-davinci/board-da830-evm.c +5 -23
index 3051cb6..6421cfe 100644
@@ -26,7 +26,6 @@
 #include <linux/platform_data/mtd-davinci.h>
 #include <linux/platform_data/mtd-davinci-aemif.h>
 #include <linux/platform_data/spi-davinci.h>
-#include <linux/platform_data/usb-davinci.h>
 
 #include <asm/mach-types.h>
 #include <asm/mach/arch.h>
@@ -106,30 +105,8 @@ 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/mode in the CFGCHIP2 register.
-	 * FYI:  CFGCHIP2 is 0x0000ef00 initially.
-	 */
-	cfgchip2 = __raw_readl(DA8XX_SYSCFG0_VIRT(DA8XX_CFGCHIP2_REG));
-
-	/*
-	 * We have to override VBUS/ID signals when MUSB is configured into the
-	 * host-only mode -- ID pin will float if no cable is connected, so the
-	 * controller won't be able to drive VBUS thinking that it's a B-device.
-	 * Otherwise, we want to use the OTG mode and enable VBUS comparators.
-	 */
-	cfgchip2 &= ~CFGCHIP2_OTGMODE;
-#ifdef	CONFIG_USB_MUSB_HOST
-	cfgchip2 |=  CFGCHIP2_FORCE_HOST;
-#else
-	cfgchip2 |=  CFGCHIP2_SESENDEN | CFGCHIP2_VBDTCTEN;
-#endif
-
-	__raw_writel(cfgchip2, DA8XX_SYSCFG0_VIRT(DA8XX_CFGCHIP2_REG));
-
 	/* USB_REFCLKIN is not used. */
 	ret = da8xx_register_usb20_phy_clk(false);
 	if (ret)
@@ -141,6 +118,11 @@ static __init void da830_evm_usb_init(void)
 		pr_warn("%s: USB 1.1 PHY CLK registration failed: %d\n",
 			__func__, ret);
 
+	ret = da8xx_register_usbphy();
+	if (ret)
+		pr_warn("%s: USB PHY registration failed: %d\n",
+			__func__, ret);
+
 	ret = davinci_cfg_reg(DA830_USB0_DRVVBUS);
 	if (ret)
 		pr_warn("%s: USB 2.0 PinMux setup failed: %d\n", __func__, ret);
arch/arm/mach-davinci/board-omapl138-hawk.c +5 -0
index 8691a25..79aaa84 100644
@@ -260,6 +260,11 @@ static __init void omapl138_hawk_usb_init(void)
 		pr_warn("%s: USB 1.1 PHY CLK registration failed: %d\n",
 			__func__, ret);
 
+	ret = da8xx_register_usbphy();
+	if (ret)
+		pr_warn("%s: USB PHY registration failed: %d\n",
+			__func__, ret);
+
 	ret = gpio_request_one(DA850_USB1_VBUS_PIN,
 			GPIOF_DIR_OUT, "USB1 VBUS");
 	if (ret < 0) {
arch/arm/mach-davinci/include/mach/da8xx.h +1 -0
index c32444b..44ab55e 100644
@@ -92,6 +92,7 @@ int da8xx_register_watchdog(void);
 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_usbphy(void);
 int da8xx_register_usb20(unsigned mA, unsigned potpgt);
 int da8xx_register_usb11(struct da8xx_ohci_root_hub *pdata);
 int da8xx_register_emac(void);
arch/arm/mach-davinci/usb-da8xx.c +11 -0
index aca5867..6bd0009 100644
@@ -6,6 +6,7 @@
 #include <linux/platform_device.h>
 #include <linux/dma-mapping.h>
 #include <linux/mfd/da8xx-cfgchip.h>
+#include <linux/phy/phy.h>
 #include <linux/usb/musb.h>
 
 #include <asm/delay.h>
@@ -231,6 +232,16 @@ int __init da8xx_register_usb11_phy_clk(bool use_usb_refclkin)
 	return ret;
 }
 
+static struct platform_device da8xx_usbphy = {
+	.name		= "da8xx-usbphy",
+	.id		= 0,
+};
+
+int __init da8xx_register_usbphy(void)
+{
+	return platform_device_register(&da8xx_usbphy);
+}
+
 #if IS_ENABLED(CONFIG_USB_MUSB_HDRC)
 
 static struct musb_hdrc_eps_bits musb_eps[] = {
Signature · 1 line
1.9.1
#31 lore raw

PATCH v3 12/16 ARM: dt: da850: Add cfgchip syscon node

In reply to David Lechner

Add a syscon node for the SoC CFGCHIPn registers. This is needed for the new usb phy driver.

---

v3 changes: This is a new patch.

 arch/arm/boot/dts/da850.dtsi | 4 ++++
 1 file changed, 4 insertions(+)
arch/arm/boot/dts/da850.dtsi +4 -0
index 4294849..a360713 100644
@@ -150,6 +150,10 @@
 			};
 
 		};
+		cfgchip: cfgchip at 1417c {
+			compatible = "ti,da830-cfgchip", "syscon";
+			reg = <0x1417c 0x14>;
+		};
 		edma0: edma at 0 {
 			compatible = "ti,edma3-tpcc";
 			/* eDMA3 CC0: 0x01c0 0000 - 0x01c0 7fff */
Signature · 1 line
1.9.1
#32 lore raw

PATCH v3 13/16 ARM: dt: da850: Add usb phy node

In reply to David Lechner

Add a node for the new usb phy driver.

---

v3 changes:

* No longer needs reg property since we are now using syscon instead.

 arch/arm/boot/dts/da850.dtsi | 5 +++++
 1 file changed, 5 insertions(+)
arch/arm/boot/dts/da850.dtsi +5 -0
index a360713..83ea8f6 100644
@@ -313,6 +313,11 @@
 					36
 					>;
 		};
+		usbphy: usbphy {
+			compatible = "ti,da830-usbphy";
+			#phy-cells = <1>;
+			status = "disabled";
+		};
 		gpio: gpio at 226000 {
 			compatible = "ti,dm6441-gpio";
 			gpio-controller;
Signature · 1 line
1.9.1
#33 lore raw

PATCH v3 14/16 usb: ohci-da8xx: Remove code that references mach

In reply to David Lechner

Including mach/* is frowned upon in device drivers, so get rid of it.

This replaces usb20_clk and code that pokes CFGCHIP2 with a proper phy driver.

---

v3 changes:

* add phy_init and phy_exit calls for completness (they are nops for this particular phy driver).
* add select PHY_DA8XX_USB to Kconfig

 drivers/usb/host/Kconfig      |   1 +
 drivers/usb/host/ohci-da8xx.c | 102 +++++++++++++++++++++++-------------------
 2 files changed, 56 insertions(+), 47 deletions(-)
drivers/usb/host/Kconfig +1 -0
index 3050b18..e4432c6 100644
@@ -472,6 +472,7 @@ config USB_OHCI_HCD_DAVINCI
 	bool "OHCI support for TI DaVinci DA8xx"
 	depends on ARCH_DAVINCI_DA8XX
 	depends on USB_OHCI_HCD=y
+	select PHY_DA8XX_USB
 	default y
 	help
 	  Enables support for the DaVinci DA8xx integrated OHCI
drivers/usb/host/ohci-da8xx.c +55 -47

174 lines not on this page · raw message

Signature · 1 line
1.9.1
#34 lore raw

PATCH v3 15/16 usb: musb: da8xx: Use devm in probe

In reply to David Lechner

Simplify things a bit by using devm functions where possible.

---

v3 changes:

* Kept clk variable to minimize noise.

 drivers/usb/musb/da8xx.c | 19 +++++--------------
 1 file changed, 5 insertions(+), 14 deletions(-)
drivers/usb/musb/da8xx.c +5 -14
index b03d3b8..0c1997c 100644
@@ -490,20 +490,18 @@ static int da8xx_probe(struct platform_device *pdev)
 	struct da8xx_glue		*glue;
 	struct platform_device_info	pinfo;
 	struct clk			*clk;
+	int				ret;
 
-	int				ret = -ENOMEM;
-
-	glue = kzalloc(sizeof(*glue), GFP_KERNEL);
+	glue = devm_kzalloc(&pdev->dev, sizeof(*glue), GFP_KERNEL);
 	if (!glue) {
 		dev_err(&pdev->dev, "failed to allocate glue context\n");
-		goto err0;
+		return -ENOMEM;
 	}
 
-	clk = clk_get(&pdev->dev, "usb20");
+	clk = devm_clk_get(&pdev->dev, "usb20");
 	if (IS_ERR(clk)) {
 		dev_err(&pdev->dev, "failed to get clock\n");
-		ret = PTR_ERR(clk);
-		goto err3;
+		return PTR_ERR(clk);
 	}
 
 	ret = clk_enable(clk);
@@ -560,12 +558,7 @@ err5:
 	clk_disable(clk);
 
 err4:
-	clk_put(clk);
-
-err3:
-	kfree(glue);
 
-err0:
 	return ret;
 }
 
@@ -576,8 +569,6 @@ static int da8xx_remove(struct platform_device *pdev)
 	platform_device_unregister(glue->musb);
 	usb_phy_generic_unregister(glue->phy);
 	clk_disable(glue->clk);
-	clk_put(glue->clk);
-	kfree(glue);
 
 	return 0;
 }
Signature · 1 line
1.9.1
maintainer
#35 lore raw

Re: [PATCH v3 15/16] usb: musb: da8xx: Use devm in probe

Hi,

Quoted 30 lines · David Lechner

Simplify things a bit by using devm functions where possible.

---

v3 changes:

* Kept clk variable to minimize noise.

 drivers/usb/musb/da8xx.c | 19 +++++--------------
 1 file changed, 5 insertions(+), 14 deletions(-)
drivers/usb/musb/da8xx.c +2 -4
index b03d3b8..0c1997c 100644
@@ -490,20 +490,18 @@ static int da8xx_probe(struct platform_device *pdev)
 	struct da8xx_glue		*glue;
 	struct platform_device_info	pinfo;
 	struct clk			*clk;
+	int				ret;
 
-	int				ret = -ENOMEM;
-
-	glue = kzalloc(sizeof(*glue), GFP_KERNEL);
+	glue = devm_kzalloc(&pdev->dev, sizeof(*glue), GFP_KERNEL);
 	if (!glue) {
 		dev_err(&pdev->dev, "failed to allocate glue context\n");
-		goto err0;

drivers/usb/musb/da8xx.c static int da8xx_probe(struct platform_device *pdev) · line 504

Quoted 10 lines
drivers/usb/musb/da8xx.c +3 -3
+		return -ENOMEM;
 	}
 
-	clk = clk_get(&pdev->dev, "usb20");
+	clk = devm_clk_get(&pdev->dev, "usb20");
 	if (IS_ERR(clk)) {
 		dev_err(&pdev->dev, "failed to get clock\n");
-		ret = PTR_ERR(clk);
-		goto err3;
+		return PTR_ERR(clk);

memory leak due to not kfree(glue).

Quoted 17 lines
drivers/usb/musb/da8xx.c +0 -5
 	}
 
 	ret = clk_enable(clk);
@@ -560,12 +558,7 @@ err5:
 	clk_disable(clk);
 
 err4:
-	clk_put(clk);
-
-err3:
-	kfree(glue);
 
-err0:
 	return ret;
 }
 

drivers/usb/musb/da8xx.c static int da8xx_remove(struct platform_device *pdev) · line 580

Quoted 5 lines
drivers/usb/musb/da8xx.c +0 -2
@@ -576,8 +569,6 @@ static int da8xx_remove(struct platform_device *pdev)
 	platform_device_unregister(glue->musb);
 	usb_phy_generic_unregister(glue->phy);
 	clk_disable(glue->clk);
-	clk_put(glue->clk);
-	kfree(glue);

Doesn't match with $subject, I'd put them into a seperate patch.

Regards,
-Bin.

#36 lore raw

Re: [PATCH v3 15/16] usb: musb: da8xx: Use devm in probe

Quoted 8 lines · Bin Liu
Quoted 8 lines
drivers/usb/musb/da8xx.c +2 -2
-	glue = kzalloc(sizeof(*glue), GFP_KERNEL);
+	glue = devm_kzalloc(&pdev->dev, sizeof(*glue), GFP_KERNEL);
  	if (!glue) {
  		dev_err(&pdev->dev, "failed to allocate glue context\n");
-		goto err0;
+		return -ENOMEM;
  	}
Quoted 9 lines

drivers/usb/musb/da8xx.c static int da8xx_probe(struct platform_device *pdev) · line 504

Quoted 7 lines
drivers/usb/musb/da8xx.c +2 -3
-	clk = clk_get(&pdev->dev, "usb20");
+	clk = devm_clk_get(&pdev->dev, "usb20");
  	if (IS_ERR(clk)) {
  		dev_err(&pdev->dev, "failed to get clock\n");
-		ret = PTR_ERR(clk);
-		goto err3;
+		return PTR_ERR(clk);

memory leak due to not kfree(glue).

It is my understanding that since glue is allocated with devm_kzalloc(), that if the probe function returns and error, glue and everything else allocated with devm_* will be automatically freed.

If this is not the case, wouldn't devm_kfree() be the appropriate function instead?

Quoted 8 lines

drivers/usb/musb/da8xx.c static int da8xx_remove(struct platform_device *pdev) · line 580

Quoted 6 lines
drivers/usb/musb/da8xx.c +0 -2
@@ -576,8 +569,6 @@ static int da8xx_remove(struct platform_device *pdev)
  	platform_device_unregister(glue->musb);
  	usb_phy_generic_unregister(glue->phy);
  	clk_disable(glue->clk);
-	clk_put(glue->clk);
-	kfree(glue);

Doesn't match with $subject, I'd put them into a seperate patch.

I disagree. Since these are now automatically freed because of changes in the probe function, these changes belong in the same patch.

maintainer
#37 lore raw

Re: [PATCH v3 15/16] usb: musb: da8xx: Use devm in probe

Hi,

Quoted 20 lines · David Lechner
Quoted 8 lines · Bin Liu
Quoted 8 lines
drivers/usb/musb/da8xx.c +2 -2
-	glue = kzalloc(sizeof(*glue), GFP_KERNEL);
+	glue = devm_kzalloc(&pdev->dev, sizeof(*glue), GFP_KERNEL);
 	if (!glue) {
 		dev_err(&pdev->dev, "failed to allocate glue context\n");
-		goto err0;
+		return -ENOMEM;
 	}
Quoted 9 lines

drivers/usb/musb/da8xx.c static int da8xx_probe(struct platform_device *pdev) · line 504

Quoted 7 lines
drivers/usb/musb/da8xx.c +2 -3
-	clk = clk_get(&pdev->dev, "usb20");
+	clk = devm_clk_get(&pdev->dev, "usb20");
 	if (IS_ERR(clk)) {
 		dev_err(&pdev->dev, "failed to get clock\n");
-		ret = PTR_ERR(clk);
-		goto err3;
+		return PTR_ERR(clk);

memory leak due to not kfree(glue).

Quoted 4 lines

It is my understanding that since glue is allocated with devm_kzalloc(), that if the probe function returns and error, glue and everything else allocated with devm_* will be automatically freed.

Ah, right.

Quoted 15 lines

If this is not the case, wouldn't devm_kfree() be the appropriate function instead?

Quoted 8 lines

drivers/usb/musb/da8xx.c static int da8xx_remove(struct platform_device *pdev) · line 580

Quoted 6 lines
drivers/usb/musb/da8xx.c +0 -2
@@ -576,8 +569,6 @@ static int da8xx_remove(struct platform_device *pdev)
 	platform_device_unregister(glue->musb);
 	usb_phy_generic_unregister(glue->phy);
 	clk_disable(glue->clk);
-	clk_put(glue->clk);
-	kfree(glue);

Doesn't match with $subject, I'd put them into a seperate patch.

Quoted 4 lines

I disagree. Since these are now automatically freed because of changes in the probe function, these changes belong in the same patch.

Ok.

Regards,
-Bin.

#38 lore raw

Re: [PATCH v3 15/16] usb: musb: da8xx: Use devm in probe

In reply to Bin Liu

Hello.

Quoted 33 lines · Bin Liu
Quoted 33 lines

Simplify things a bit by using devm functions where possible.

---

v3 changes:

* Kept clk variable to minimize noise.

  drivers/usb/musb/da8xx.c | 19 +++++--------------
  1 file changed, 5 insertions(+), 14 deletions(-)
drivers/usb/musb/da8xx.c +3 -4
index b03d3b8..0c1997c 100644
@@ -490,20 +490,18 @@ static int da8xx_probe(struct platform_device *pdev)
  	struct da8xx_glue		*glue;
  	struct platform_device_info	pinfo;
  	struct clk			*clk;
+	int				ret;
 
-	int				ret = -ENOMEM;
-
-	glue = kzalloc(sizeof(*glue), GFP_KERNEL);
+	glue = devm_kzalloc(&pdev->dev, sizeof(*glue), GFP_KERNEL);
  	if (!glue) {
  		dev_err(&pdev->dev, "failed to allocate glue context\n");
-		goto err0;
+		return -ENOMEM;
  	}
 
Quoted 9 lines

drivers/usb/musb/da8xx.c static int da8xx_probe(struct platform_device *pdev) · line 504

Quoted 7 lines
drivers/usb/musb/da8xx.c +2 -3
-	clk = clk_get(&pdev->dev, "usb20");
+	clk = devm_clk_get(&pdev->dev, "usb20");
  	if (IS_ERR(clk)) {
  		dev_err(&pdev->dev, "failed to get clock\n");
-		ret = PTR_ERR(clk);
-		goto err3;
+		return PTR_ERR(clk);

memory leak due to not kfree(glue).

No, since devm_kzalloc() was used, the memory will be automatically freed
on returning error by da8xx_probe().

Quoted 16 lines
Quoted 16 lines
drivers/usb/musb/da8xx.c +0 -5
  	}
 
  	ret = clk_enable(clk);
@@ -560,12 +558,7 @@ err5:
  	clk_disable(clk);
 
  err4:
-	clk_put(clk);
-
-err3:
-	kfree(glue);
 
-err0:
  	return ret;
  }
 
Quoted 8 lines

drivers/usb/musb/da8xx.c static int da8xx_remove(struct platform_device *pdev) · line 580

Quoted 6 lines
drivers/usb/musb/da8xx.c +0 -2
@@ -576,8 +569,6 @@ static int da8xx_remove(struct platform_device *pdev)
  	platform_device_unregister(glue->musb);
  	usb_phy_generic_unregister(glue->phy);
  	clk_disable(glue->clk);
-	clk_put(glue->clk);
-	kfree(glue);

Doesn't match with $subject, I'd put them into a seperate patch.

Again, these are now done automatically.

Quoted 2 lines

Regards,
-Bin.

MBR, Sergei

#39 lore raw

PATCH v3 16/16 usb: musb: da8xx: Remove mach code

In reply to David Lechner

Use the new phy-da8xx-usb driver to take the place of the mach code that pokes CFGCHIP2 in the da8xx musb glue driver. This unbreaks the driver.

---

v3 changes:

* removed depends on BROKEN and added select PHY_DA8XX_USB to Kconfig
* Added calls to phy_init and phy_exit

 drivers/usb/musb/Kconfig |   2 +-
 drivers/usb/musb/da8xx.c | 141 ++++++++++++++++-------------------------------
 2 files changed, 47 insertions(+), 96 deletions(-)
drivers/usb/musb/Kconfig +1 -1
index 886526b..c73221a 100644
@@ -82,7 +82,7 @@ config USB_MUSB_DA8XX
 	tristate "DA8xx/OMAP-L1x"
 	depends on ARCH_DAVINCI_DA8XX
 	depends on NOP_USB_XCEIV
-	depends on BROKEN
+	select PHY_DA8XX_USB
 
 config USB_MUSB_TUSB6010
 	tristate "TUSB6010"
drivers/usb/musb/da8xx.c +46 -95

231 lines not on this page · raw message

Signature · 1 line
1.9.1
#40 lore raw
In reply to David Lechner
Quoted 27 lines · David Lechner

This is a reworking of the v2 series based of feedback and review. There were very many suggestions, so hopefully I didn't miss any. Here are the highlights...

New stuff:

* 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.

Changed:

* 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.

David Lechner (16):
dt: davinci: use proper address after @
mfd: da8xx-cfgchip: New header file for CFGCHIP registers.
ARM: davinici: da8xx: move usb code to new file
ARM: davinci: Move clock init after ioremap.
ARM: davinci: add set_parent callback for mux clocks
ARM: davinci: da850: use clk->set_parent for async3
ARM: davinci: da8xx: add usb phy clocks
dt-bindings: Add bindings for phy-da8xx-usb

Quoted 9 lines

phy: da8xx-usb: new driver for DA8xx SoC USB PHY
ARM: davinci: da8xx: Add CFGCHIPn syscon platform declaration.
ARM: davinci: da8xx: Add USB PHY platform declaration
ARM: dt: da850: Add cfgchip syscon node
ARM: dt: da850: Add usb phy node
usb: ohci-da8xx: Remove code that references mach
usb: musb: da8xx: Use devm in probe
usb: musb: da8xx: Remove mach code

Any further comments before I submit a v4 patchset? Particularly on patches 3 and 4 which are new in this v3 submission and have not been commented on yet.

#41 lore raw

Hi David,

Quoted 3 lines · David Lechner

Any further comments before I submit a v4 patchset? Particularly on patches 3 and 4 which are new in this v3 submission and have not been commented on yet.

I applied some patches which could be applied independently without driver dependency. I have pushed those to my for-testing[1] branch where they will get tested a little more before I send my pull request to ARM-SoC.

For your future submissions, you can drop the patches already applied to the branch above.

Also, I think it will help if you divide the series into driver and platform changes. You should keep all maintainers copied in both places. But dividing the series this way should help concentrate review. This is a complex series with multiple maintainers involved so it will take some co-ordination. Hopefully it can still all go into the upcoming merge window.

Regards,
Sekhar

[1]
http://git.kernel.org/cgit/linux/kernel/git/nsekhar/linux-davinci.git/log/?h=for-testing