Skip to contentSkip to conversation

ARM: davinci: convert to common clock framework​

PATCH Superseded David Lechner 5 participants 61 messages Feb 19, 2018 – Mar 19, 2018

Subsystems (6)

v7 of 11 Superseded Latest is v11 →

lore
Share & tools
lore

David Lechner

author maintainer
#0 lore raw

v7 cover ARM: davinci: convert to common clock framework​

This series converts mach-davinci to use the common clock framework.

The series works like this, the first 19 patches create new clock drivers using the common clock framework. There are basically 3 groups of clocks - PLL, PSC and CFGCHIP (syscon). There are six different SoCs that each have unique init data, which is the reason for so many patches.

Then, starting with "ARM: davinci: pass clock as parameter to davinci_timer_init()", we get the mach code ready for the switch by adding the code needed for the new clock drivers and adding #ifndef CONFIG_COMMON_CLK around the legacy clocks so that we can switch easily between the old and the new.

"ARM: davinci: switch to common clock framework" actually flips the switch to start using the new clock drivers. Then the next 8 patches remove all of the old clock code.

The final three patches add device tree clock support to the one SoC that supports it.

---

The change to make all of the clocks platform devices in v7 was a pretty major change, so unfortunately I had to drop quite a few Reviewed-bys and this series will need more close review and testing again.

v7 changes (also see individual patches for details):
- Rebased on linux-davinci/master (v4.16-rc)
- Convert clock drivers to platform devices
- New patch "ARM: davinci: pass clock as parameter to davinci_timer_init()"
- Fix issues with lcdk and aemif clock lookups and power domains
- Fixed other minor issues brought up in v6 review

v6 changes (also see individual patches for details):
- All of the device tree bindings are changed
- All of the clock drivers are changed significantly
- Fixed issues brought up during review of v5
- "ARM: davinci: move davinci_clk_init() to init_time" is removed from this series and submitted separately

v5 changes:
- Basically, this is an entirely new series
- Patches are broken up into bite-sized pieces
- Converted PSC clock driver to use regmap
- Restored "force" flag for certain DA850 clocks
- Added device tree bindings
- Moved more of the clock init to drivers/clk
- Fixed frequency scaling (maybe*)

* I have frequency scaling using cpufreq-dt, so I know the clocks are doing what they need to do to make this work, but I haven't figured out how to test davinci-cpufreq driver yet. (Patches to make cpufreq-dt work will be sent separately after this series has landed.)

Dependencies:

Most of the dependencies have landed in mainline already in v4.16-rc1 or are in linux-davinci/master.

There are no build dependencies any more, but you will need to pickup a couple of patches to get CPU frequency scaling working because of a divider clock bug.

- https://patchwork.kernel.org/patch/10218941/
- https://patchwork.kernel.org/patch/10218927/

You can find a working branch with everything included in the "common-clk-v7" branch of https://github.com/dlech/ev3dev-kernel.git.

Testing/debugging for the uninitiated:

I only have one device to test with, which is based on da850, so I will have to rely on others to do some testing here. Since we are dealing with clocks, if something isn't working, you most likely won't see output on the serial port. To figure out what is going on, you need to enable...

CONFIG_DEBUG_LL=y
CONFIG_EARLY_PRINTK=y

and add "earlyprintk clk_ignore_unused" to the kernel command line options. You may need to select a different UART for this depending on your board. I think UART1 is the default in the kernel configuration.

On da850 devices comment out the lines:

	else
		clk_set_parent(clk, parent->clk);

in da850.c or, if using device tree, comment out the lines:

	assigned-clocks = <&async3_clk>;
	assigned-clock-parents = <&pll1_sysclk 2>;

in da850.dtsi when doing earlyprintk, otherwise the UART1 and UART2 clock source will change during boot and cause garbled output after a point.

David Lechner (42):
dt-bindings: clock: Add new bindings for TI Davinci PLL clocks
clk: davinci: New driver for davinci PLL clocks
clk: davinci: Add platform information for TI DA830 PLL
clk: davinci: Add platform information for TI DA850 PLL
clk: davinci: Add platform information for TI DM355 PLL
clk: davinci: Add platform information for TI DM365 PLL
clk: davinci: Add platform information for TI DM644x PLL
clk: davinci: Add platform information for TI DM646x PLL
dt-bindings: clock: New bindings for TI Davinci PSC
clk: davinci: New driver for davinci PSC clocks
clk: davinci: Add platform information for TI DA830 PSC
clk: davinci: Add platform information for TI DA850 PSC
clk: davinci: Add platform information for TI DM355 PSC
clk: davinci: Add platform information for TI DM365 PSC
clk: davinci: Add platform information for TI DM644x PSC
clk: davinci: Add platform information for TI DM646x PSC
dt-bindings: clock: Add bindings for DA8XX CFGCHIP clocks
clk: davinci: New driver for TI DA8XX CFGCHIP clocks
clk: davinci: cfgchip: Add TI DA8XX USB PHY clocks
ARM: davinci: pass clock as parameter to davinci_timer_init()
ARM: davinci: da830: add new clock init using common clock framework
ARM: davinci: da850: add new clock init using common clock framework
ARM: davinci: dm355: add new clock init using common clock framework
ARM: davinci: dm365: add new clock init using common clock framework
ARM: davinci: dm644x: add new clock init using common clock framework
ARM: davinci: dm646x: add new clock init using common clock framework
ARM: davinci: da8xx: add new USB PHY clock init using common clock
framework
ARM: davinci: da8xx: add new sata_refclk init using common clock
framework
ARM: davinci: remove CONFIG_DAVINCI_RESET_CLOCKS
ARM: davinci_all_defconfig: remove CONFIG_DAVINCI_RESET_CLOCKS
ARM: davinci: switch to common clock framework
ARM: davinci: da830: Remove legacy clock init
ARM: davinci: da850: Remove legacy clock init
ARM: davinci: dm355: Remove legacy clock init
ARM: davinci: dm365: Remove legacy clock init
ARM: davinci: dm644x: Remove legacy clock init
ARM: davinci: dm646x: Remove legacy clock init
ARM: davinci: da8xx: Remove legacy USB and SATA clock init
ARM: davinci: remove legacy clocks
ARM: davinci: add device tree support to timer
ARM: davinci: da8xx-dt: switch to device tree clocks
ARM: dts: da850: Add clocks

 .../bindings/clock/ti/davinci/da8xx-cfgchip.txt    |  93 +++
 .../devicetree/bindings/clock/ti/davinci/pll.txt   |  96 +++
 .../devicetree/bindings/clock/ti/davinci/psc.txt   |  71 ++
 MAINTAINERS                                        |   7 +
 arch/arm/Kconfig                                   |   5 +-
 arch/arm/boot/dts/da850-enbw-cmc.dts               |   4 +
 arch/arm/boot/dts/da850-evm.dts                    |   4 +
 arch/arm/boot/dts/da850-lcdk.dts                   |   9 +
 arch/arm/boot/dts/da850-lego-ev3.dts               |   4 +
 arch/arm/boot/dts/da850.dtsi                       | 159 ++++
 arch/arm/configs/davinci_all_defconfig             |   1 -
 arch/arm/mach-davinci/Kconfig                      |  13 +-
 arch/arm/mach-davinci/Makefile                     |   4 +-
 arch/arm/mach-davinci/board-da830-evm.c            |  12 +-
 arch/arm/mach-davinci/board-da850-evm.c            |   2 +
 arch/arm/mach-davinci/board-dm355-evm.c            |   2 +
 arch/arm/mach-davinci/board-dm355-leopard.c        |   2 +
 arch/arm/mach-davinci/board-dm365-evm.c            |   2 +
 arch/arm/mach-davinci/board-dm644x-evm.c           |   2 +
 arch/arm/mach-davinci/board-dm646x-evm.c           |   2 +
 arch/arm/mach-davinci/board-mityomapl138.c         |   2 +
 arch/arm/mach-davinci/board-neuros-osd2.c          |   2 +
 arch/arm/mach-davinci/board-omapl138-hawk.c        |  11 +-
 arch/arm/mach-davinci/board-sffsdr.c               |   2 +
 arch/arm/mach-davinci/clock.c                      | 745 -----------------
 arch/arm/mach-davinci/clock.h                      |  76 --
 arch/arm/mach-davinci/common.c                     |   3 -
 arch/arm/mach-davinci/da830.c                      | 469 ++---------
 arch/arm/mach-davinci/da850.c                      | 766 +++---------------
 arch/arm/mach-davinci/da8xx-dt.c                   |  60 --
 arch/arm/mach-davinci/davinci.h                    |   8 +
 arch/arm/mach-davinci/devices-da8xx.c              |  43 +-
 arch/arm/mach-davinci/devices.c                    |   1 -
 arch/arm/mach-davinci/dm355.c                      | 425 ++--------
 arch/arm/mach-davinci/dm365.c                      | 517 ++----------
 arch/arm/mach-davinci/dm644x.c                     | 363 ++-------
 arch/arm/mach-davinci/dm646x.c                     | 391 ++-------
 arch/arm/mach-davinci/include/mach/clock.h         |   3 -
 arch/arm/mach-davinci/include/mach/common.h        |  11 +-
 arch/arm/mach-davinci/include/mach/da8xx.h         |   6 +-
 arch/arm/mach-davinci/pm_domain.c                  |   5 +
 arch/arm/mach-davinci/psc.c                        | 137 ----
 arch/arm/mach-davinci/psc.h                        |  12 -
 arch/arm/mach-davinci/time.c                       |  46 +-
 arch/arm/mach-davinci/usb-da8xx.c                  | 250 +-----
 drivers/clk/Makefile                               |   1 +
 drivers/clk/davinci/Makefile                       |  21 +
 drivers/clk/davinci/da8xx-cfgchip.c                | 786 ++++++++++++++++++
 drivers/clk/davinci/pll-da830.c                    |  58 ++
 drivers/clk/davinci/pll-da850.c                    | 178 +++++
 drivers/clk/davinci/pll-dm355.c                    |  75 ++
 drivers/clk/davinci/pll-dm365.c                    | 119 +++
 drivers/clk/davinci/pll-dm644x.c                   |  76 ++
 drivers/clk/davinci/pll-dm646x.c                   |  78 ++
 drivers/clk/davinci/pll.c                          | 877 +++++++++++++++++++++
 drivers/clk/davinci/pll.h                          | 141 ++++
 drivers/clk/davinci/psc-da830.c                    |  89 +++
 drivers/clk/davinci/psc-da850.c                    | 109 +++
 drivers/clk/davinci/psc-dm355.c                    |  72 ++
 drivers/clk/davinci/psc-dm365.c                    |  77 ++
 drivers/clk/davinci/psc-dm644x.c                   |  67 ++
 drivers/clk/davinci/psc-dm646x.c                   |  62 ++
 drivers/clk/davinci/psc.c                          | 505 ++++++++++++
 drivers/clk/davinci/psc.h                          | 101 +++
 include/linux/platform_data/clk-da8xx-cfgchip.h    |  21 +
 65 files changed, 4515 insertions(+), 3846 deletions(-)
 create mode 100644 Documentation/devicetree/bindings/clock/ti/davinci/da8xx-cfgchip.txt
 create mode 100644 Documentation/devicetree/bindings/clock/ti/davinci/pll.txt
 create mode 100644 Documentation/devicetree/bindings/clock/ti/davinci/psc.txt
 delete mode 100644 arch/arm/mach-davinci/clock.c
 delete mode 100644 arch/arm/mach-davinci/psc.c
 create mode 100644 drivers/clk/davinci/Makefile
 create mode 100644 drivers/clk/davinci/da8xx-cfgchip.c
 create mode 100644 drivers/clk/davinci/pll-da830.c
 create mode 100644 drivers/clk/davinci/pll-da850.c
 create mode 100644 drivers/clk/davinci/pll-dm355.c
 create mode 100644 drivers/clk/davinci/pll-dm365.c
 create mode 100644 drivers/clk/davinci/pll-dm644x.c
 create mode 100644 drivers/clk/davinci/pll-dm646x.c
 create mode 100644 drivers/clk/davinci/pll.c
 create mode 100644 drivers/clk/davinci/pll.h
 create mode 100644 drivers/clk/davinci/psc-da830.c
 create mode 100644 drivers/clk/davinci/psc-da850.c
 create mode 100644 drivers/clk/davinci/psc-dm355.c
 create mode 100644 drivers/clk/davinci/psc-dm365.c
 create mode 100644 drivers/clk/davinci/psc-dm644x.c
 create mode 100644 drivers/clk/davinci/psc-dm646x.c
 create mode 100644 drivers/clk/davinci/psc.c
 create mode 100644 drivers/clk/davinci/psc.h
 create mode 100644 include/linux/platform_data/clk-da8xx-cfgchip.h
Signature · 1 line
2.7.4
author maintainer
#1 lore raw

PATCH v7 1/42 dt-bindings: clock: Add new bindings for TI Davinci PLL clocks

This adds a new binding for the PLL IP blocks in the mach-davinci family of processors. Currently, only da850 has device tree support but these bindings can also work for other SoCs in this family just by adding new compatible strings.

Note: Although these PLL controllers are very similar to the TI Keystone SoCs, we are not re-using those bindings. The Keystone bindings use a legacy one-node-per-clock binding. Furthermore, the mach-davinici SoCs have a slightly different PLL register layout and a number of quirks that can't be handled by the existing bindings, so the keystone bindings could not be used as-is anyway.

---

v7 changes:
- None (there was some debate about having child nodes, but the consensus was that this is "good enough" as it is)

v6 changes:
- Added clock-names property
- Added ti,clkmode-square-wave property
- Added pllout child node
- Added obsclk child node
- Expanded examples

 .../devicetree/bindings/clock/ti/davinci/pll.txt   | 96 ++++++++++++++++++++++
 1 file changed, 96 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/clock/ti/davinci/pll.txt
Documentation/devicetree/bindings/clock/ti/davinci/pll.txt new file +96 -0
new file mode 100644
index 0000000..36998e1
@@ -0,0 +1,96 @@
+Binding for TI DaVinci PLL Controllers
+
+The PLL provides clocks to most of the components on the SoC. In addition
+to the PLL itself, this controller also contains bypasses, gates, dividers,
+an multiplexers for various clock signals.
+
+Required properties:
+- compatible: shall be one of:
+	- "ti,da850-pll0" for PLL0 on DA850/OMAP-L138/AM18XX
+	- "ti,da850-pll1" for PLL1 on DA850/OMAP-L138/AM18XX
+- reg: physical base address and size of the controller's register area.
+- clocks: phandles corresponding to the clock names
+- clock-names: names of the clock sources - depends on compatible string
+	- for "ti,da850-pll0", shall be "clksrc", "extclksrc"
+	- for "ti,da850-pll1", shall be "clksrc"
+
+Optional properties:
+- ti,clkmode-square-wave: Indicates that the the board is supplying a square
+	wave input on the OSCIN pin instead of using a crystal oscillator.
+	This property is only valid when compatible = "ti,da850-pll0".
+
+
+Optional child nodes:
+
+pllout
+	Describes the main PLL clock output (before POSTDIV). The node name must
+	be "pllout".
+
+	Required properties:
+	- #clock-cells: shall be 0
+
+sysclk
+	Describes the PLLDIVn divider clocks that provide the SYSCLKn clock
+	domains. The node name must be "sysclk". Consumers of this node should
+	use "n" in "SYSCLKn" as the index parameter for the clock cell.
+
+	Required properties:
+	- #clock-cells: shall be 1
+
+auxclk
+	Describes the AUXCLK output of the PLL. The node name must be "auxclk".
+	This child node is only valid when compatible = "ti,da850-pll0".
+
+	Required properties:
+	- #clock-cells: shall be 0
+
+obsclk
+	Describes the OBSCLK output of the PLL. The node name must be "obsclk".
+
+	Required properties:
+	- #clock-cells: shall be 0
+
+
+Examples:
+
+	pll0: clock-controller at 11000 {
+		compatible = "ti,da850-pll0";
+		reg = <0x11000 0x1000>;
+		clocks = <&ref_clk>, <&pll1_sysclk 3>;
+		clock-names = "clksrc", "extclksrc";
+		ti,clkmode-square-wave;
+
+		pll0_pllout: pllout {
+			#clock-cells = <0>;
+		};
+
+		pll0_sysclk: sysclk {
+			#clock-cells = <1>;
+		};
+
+		pll0_auxclk: auxclk {
+			#clock-cells = <0>;
+		};
+
+		pll0_obsclk: obsclk {
+			#clock-cells = <0>;
+		};
+	};
+
+	pll1: clock-controller at 21a000 {
+		compatible = "ti,da850-pll1";
+		reg = <0x21a000 0x1000>;
+		clocks = <&ref_clk>;
+		clock-names = "clksrc";
+
+		pll0_sysclk: sysclk {
+			#clock-cells = <1>;
+		};
+
+		pll0_obsclk: obsclk {
+			#clock-cells = <0>;
+		};
+	};
+
+Also see:
+- Documentation/devicetree/bindings/clock/clock-bindings.txt
Signature · 1 line
2.7.4
maintainer Reviewed-by on v7 1/42
#2 lore raw

Re: [PATCH v7 01/42] dt-bindings: clock: Add new bindings for TI Davinci PLL clocks

Quoted 27 lines · David Lechner

This adds a new binding for the PLL IP blocks in the mach-davinci family of processors. Currently, only da850 has device tree support but these bindings can also work for other SoCs in this family just by adding new compatible strings.

Note: Although these PLL controllers are very similar to the TI Keystone SoCs, we are not re-using those bindings. The Keystone bindings use a legacy one-node-per-clock binding. Furthermore, the mach-davinici SoCs have a slightly different PLL register layout and a number of quirks that can't be handled by the existing bindings, so the keystone bindings could not be used as-is anyway.

---

v7 changes:
- None (there was some debate about having child nodes, but the consensus was that this is "good enough" as it is)

v6 changes:
- Added clock-names property
- Added ti,clkmode-square-wave property
- Added pllout child node
- Added obsclk child node
- Expanded examples

Quoted 3 lines
 .../devicetree/bindings/clock/ti/davinci/pll.txt   | 96 ++++++++++++++++++++++
 1 file changed, 96 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/clock/ti/davinci/pll.txt
author maintainer
#3 lore raw

PATCH v7 2/42 clk: davinci: New driver for davinci PLL clocks

In reply to David Lechner

This adds a new driver for mach-davinci PLL clocks. This is porting the code from arch/arm/mach-davinci/clock.c to the common clock framework. Additionally, it adds device tree support for these clocks.

The ifeq ($(CONFIG_COMMON_CLK), y) in the Makefile is needed to prevent compile errors until the clock code in arch/arm/mach-davinci is removed.

Note: although there are similar clocks for TI Keystone we are not able to share the code for a few reasons. The keystone clocks are device tree only and use legacy one-node-per-clock bindings. Also the register layouts are a bit different, which would add even more if/else mess to the keystone clocks. And the keystone PLL driver doesn't support setting clock rates.

---

v7 changes:
- convert to platform device driver
- rename PLL_HAS_OSCIN to PLL_HAS_CLKMODE
- add comments to clarify which clock domain "oscin" is

v6 changes:
- Added R: Sekhar Nori <[email protected]> to MAINTAINERS
- Split main PLL clock into oscdiv, prediv, pllout, postdiv and pllen clocks
- Added min/max rate checking for pllout in set_rate
- Added min/max PLLM value checking for pllout in set_rate
- Fixed sysclk set_rate (checking GOSTAT and setting GOSET)
- Added *_clk_info structs for passing controller-specific info
- Added quirks for optional PREDIV and POSTDIV registers
- Added quirk for DM355 broken PREDIV register
- Added quirk for DM365 2x PLLM register
- Handle unlocking PLL registers via CFGCHIP
- Use pr_fmt macro

 MAINTAINERS                  |   7 +
 drivers/clk/Makefile         |   1 +
 drivers/clk/davinci/Makefile |   5 +
 drivers/clk/davinci/pll.c    | 864 +++++++++++++++++++++++++++++++++++++++++++
 drivers/clk/davinci/pll.h    | 120 ++++++
 5 files changed, 997 insertions(+)
 create mode 100644 drivers/clk/davinci/Makefile
 create mode 100644 drivers/clk/davinci/pll.c
 create mode 100644 drivers/clk/davinci/pll.h
MAINTAINERS +7 -0
index 9a7f76e..7d5c129 100644
@@ -13794,6 +13794,13 @@ F:	arch/arm/mach-davinci/
 F:	drivers/i2c/busses/i2c-davinci.c
 F:	arch/arm/boot/dts/da850*
 
+TI DAVINCI SERIES CLOCK DRIVER
+M:	David Lechner <[email protected]>
+R:	Sekhar Nori <[email protected]>
+S:	Maintained
+F:	Documentation/devicetree/bindings/clock/ti/davinci/
+F:	drivers/clk/davinci/
+
 TI DAVINCI SERIES GPIO DRIVER
 M:	Keerthy <[email protected]>
 L:	linux-gpio at vger.kernel.org
drivers/clk/Makefile +1 -0
index 71ec41e..07ac0fdb 100644
@@ -61,6 +61,7 @@ obj-$(CONFIG_ARCH_ARTPEC)		+= axis/
 obj-$(CONFIG_ARC_PLAT_AXS10X)		+= axs10x/
 obj-y					+= bcm/
 obj-$(CONFIG_ARCH_BERLIN)		+= berlin/
+obj-$(CONFIG_ARCH_DAVINCI)		+= davinci/
 obj-$(CONFIG_H8300)			+= h8300/
 obj-$(CONFIG_ARCH_HISI)			+= hisilicon/
 obj-y					+= imgtec/
drivers/clk/davinci/Makefile new file +5 -0
new file mode 100644
index 0000000..d9673bd
@@ -0,0 +1,5 @@
+# SPDX-License-Identifier: GPL-2.0
+
+ifeq ($(CONFIG_COMMON_CLK), y)
+obj-y += pll.o
+endif
drivers/clk/davinci/pll.c new file +864 -0

864 lines not on this page · raw message

drivers/clk/davinci/pll.h new file +120 -0

120 lines not on this page · raw message

Signature · 1 line
2.7.4
author maintainer
#4 lore raw

PATCH v7 3/42 clk: davinci: Add platform information for TI DA830 PLL

In reply to David Lechner

This adds platform-specific declarations for the PLL clocks on TI DA830/ OMAP-L137/AM17XX SoCs.

---

v7 changes:
- include clkdev lookup registration here instead of in mach-davinci
- Add platform_device_id lookup

v6 changes:
- Added da830_pll_info with controller-specific information
- Add empty lines between function calls

 drivers/clk/davinci/Makefile    |  1 +
 drivers/clk/davinci/pll-da830.c | 58 +++++++++++++++++++++++++++++++++++++++++
 drivers/clk/davinci/pll.c       |  1 +
 drivers/clk/davinci/pll.h       |  4 +++
 4 files changed, 64 insertions(+)
 create mode 100644 drivers/clk/davinci/pll-da830.c
drivers/clk/davinci/Makefile +1 -0
index d9673bd..9061e19 100644
@@ -2,4 +2,5 @@
 
 ifeq ($(CONFIG_COMMON_CLK), y)
 obj-y += pll.o
+obj-$(CONFIG_ARCH_DAVINCI_DA830)	+= pll-da830.o
 endif
drivers/clk/davinci/pll-da830.c new file +58 -0

58 lines not on this page · raw message

drivers/clk/davinci/pll.c +1 -0
index e4f3e5f..9a22511 100644
@@ -751,6 +751,7 @@ static const struct of_device_id davinci_pll_of_match[] = {
 };
 
 static const struct platform_device_id davinci_pll_id_table[] = {
+	{ .name = "da830-pll",   .driver_data = (kernel_ulong_t)da830_pll_init   },
 	{ }
 };
 
drivers/clk/davinci/pll.h +4 -0
index 50fe429..5c4c5c8 100644
@@ -117,4 +117,8 @@ int of_davinci_pll_init(struct device *dev,
 			u8 max_sysclk_id,
 			void __iomem *base);
 
+/* Platform-specific callbacks */
+
+int da830_pll_init(struct device *dev, void __iomem *base);
+
 #endif /* __CLK_DAVINCI_PLL_H___ */
Signature · 1 line
2.7.4
author maintainer
#5 lore raw

PATCH v7 4/42 clk: davinci: Add platform information for TI DA850 PLL

In reply to David Lechner

This adds platform-specific declarations for the PLL clocks on TI DA850/ OMAP-L138/AM18XX SoCs.

---

v7 changes:
- include clkdev lookup registration here instead of in mach-davinci
- split registration functions for each PLL
- Add platform_device_id lookup

v6 changes:
- Added da850_pll{0,1}_info with controller-specific information
- Added OBSCLK data
- Add empty lines between function calls

 drivers/clk/davinci/Makefile    |   1 +
 drivers/clk/davinci/pll-da850.c | 178 ++++++++++++++++++++++++++++++++++++++++
 drivers/clk/davinci/pll.c       |   4 +
 drivers/clk/davinci/pll.h       |   5 ++
 4 files changed, 188 insertions(+)
 create mode 100644 drivers/clk/davinci/pll-da850.c
drivers/clk/davinci/Makefile +1 -0
index 9061e19..13049d4 100644
@@ -3,4 +3,5 @@
 ifeq ($(CONFIG_COMMON_CLK), y)
 obj-y += pll.o
 obj-$(CONFIG_ARCH_DAVINCI_DA830)	+= pll-da830.o
+obj-$(CONFIG_ARCH_DAVINCI_DA850)	+= pll-da850.o
 endif
drivers/clk/davinci/pll-da850.c new file +178 -0

178 lines not on this page · raw message

drivers/clk/davinci/pll.c +4 -0
index 9a22511..7c56397 100644
@@ -747,11 +747,15 @@ int of_davinci_pll_init(struct device *dev,
 }
 
 static const struct of_device_id davinci_pll_of_match[] = {
+	{ .compatible = "ti,da850-pll0", .data = of_da850_pll0_init },
+	{ .compatible = "ti,da850-pll1", .data = of_da850_pll1_init },
 	{ }
 };
 
 static const struct platform_device_id davinci_pll_id_table[] = {
 	{ .name = "da830-pll",   .driver_data = (kernel_ulong_t)da830_pll_init   },
+	{ .name = "da850-pll0",  .driver_data = (kernel_ulong_t)da850_pll0_init  },
+	{ .name = "da850-pll1",  .driver_data = (kernel_ulong_t)da850_pll1_init  },
 	{ }
 };
 
drivers/clk/davinci/pll.h +5 -0
index 5c4c5c8..545a156 100644
@@ -121,4 +121,9 @@ int of_davinci_pll_init(struct device *dev,
 
 int da830_pll_init(struct device *dev, void __iomem *base);
 
+int da850_pll0_init(struct device *dev, void __iomem *base);
+int da850_pll1_init(struct device *dev, void __iomem *base);
+int of_da850_pll0_init(struct device *dev, void __iomem *base);
+int of_da850_pll1_init(struct device *dev, void __iomem *base);
+
 #endif /* __CLK_DAVINCI_PLL_H___ */
Signature · 1 line
2.7.4
author maintainer
#6 lore raw

PATCH v7 5/42 clk: davinci: Add platform information for TI DM355 PLL

In reply to David Lechner

This adds platform-specific declarations for the PLL clocks on TI DM355 based systems.

---

v7 changes:
- split registration functions for each PLL
- Add platform_device_id lookup

v6 changes:
- Added dm355_pll{1,2}_info with controller-specific information
- Add empty lines between function calls

 drivers/clk/davinci/Makefile    |  1 +
 drivers/clk/davinci/pll-dm355.c | 75 +++++++++++++++++++++++++++++++++++++++++
 drivers/clk/davinci/pll.c       |  2 ++
 drivers/clk/davinci/pll.h       |  3 ++
 4 files changed, 81 insertions(+)
 create mode 100644 drivers/clk/davinci/pll-dm355.c
drivers/clk/davinci/Makefile +1 -0
index 13049d4..6720bd0 100644
@@ -4,4 +4,5 @@ ifeq ($(CONFIG_COMMON_CLK), y)
 obj-y += pll.o
 obj-$(CONFIG_ARCH_DAVINCI_DA830)	+= pll-da830.o
 obj-$(CONFIG_ARCH_DAVINCI_DA850)	+= pll-da850.o
+obj-$(CONFIG_ARCH_DAVINCI_DM355)	+= pll-dm355.o
 endif
drivers/clk/davinci/pll-dm355.c new file +75 -0

75 lines not on this page · raw message

drivers/clk/davinci/pll.c +2 -0
index 7c56397..f72ea30 100644
@@ -756,6 +756,8 @@ static const struct platform_device_id davinci_pll_id_table[] = {
 	{ .name = "da830-pll",   .driver_data = (kernel_ulong_t)da830_pll_init   },
 	{ .name = "da850-pll0",  .driver_data = (kernel_ulong_t)da850_pll0_init  },
 	{ .name = "da850-pll1",  .driver_data = (kernel_ulong_t)da850_pll1_init  },
+	{ .name = "dm355-pll1",  .driver_data = (kernel_ulong_t)dm355_pll1_init  },
+	{ .name = "dm355-pll2",  .driver_data = (kernel_ulong_t)dm355_pll2_init  },
 	{ }
 };
 
drivers/clk/davinci/pll.h +3 -0
index 545a156..6bd73d7 100644
@@ -126,4 +126,7 @@ int da850_pll1_init(struct device *dev, void __iomem *base);
 int of_da850_pll0_init(struct device *dev, void __iomem *base);
 int of_da850_pll1_init(struct device *dev, void __iomem *base);
 
+int dm355_pll1_init(struct device *dev, void __iomem *base);
+int dm355_pll2_init(struct device *dev, void __iomem *base);
+
 #endif /* __CLK_DAVINCI_PLL_H___ */
Signature · 1 line
2.7.4
author maintainer
#7 lore raw

PATCH v7 6/42 clk: davinci: Add platform information for TI DM365 PLL

In reply to David Lechner

This adds platform-specific declarations for the PLL clocks on TI DM365 based systems.

---

v7 changes:
- split registration functions for each PLL
- Add platform_device_id lookup

v6 changes:
- Added dm365_pll{1,2}_info with controller-specific information
- Changed OBSCLK data
- Add empty lines between function calls

 drivers/clk/davinci/Makefile    |   1 +
 drivers/clk/davinci/pll-dm365.c | 119 ++++++++++++++++++++++++++++++++++++++++
 drivers/clk/davinci/pll.c       |   2 +
 drivers/clk/davinci/pll.h       |   3 +
 4 files changed, 125 insertions(+)
 create mode 100644 drivers/clk/davinci/pll-dm365.c
drivers/clk/davinci/Makefile +1 -0
index 6720bd0..353aa02 100644
@@ -5,4 +5,5 @@ obj-y += pll.o
 obj-$(CONFIG_ARCH_DAVINCI_DA830)	+= pll-da830.o
 obj-$(CONFIG_ARCH_DAVINCI_DA850)	+= pll-da850.o
 obj-$(CONFIG_ARCH_DAVINCI_DM355)	+= pll-dm355.o
+obj-$(CONFIG_ARCH_DAVINCI_DM365)	+= pll-dm365.o
 endif
drivers/clk/davinci/pll-dm365.c new file +119 -0

119 lines not on this page · raw message

drivers/clk/davinci/pll.c +2 -0
index f72ea30..c8dd3fa 100644
@@ -758,6 +758,8 @@ static const struct platform_device_id davinci_pll_id_table[] = {
 	{ .name = "da850-pll1",  .driver_data = (kernel_ulong_t)da850_pll1_init  },
 	{ .name = "dm355-pll1",  .driver_data = (kernel_ulong_t)dm355_pll1_init  },
 	{ .name = "dm355-pll2",  .driver_data = (kernel_ulong_t)dm355_pll2_init  },
+	{ .name = "dm365-pll1",  .driver_data = (kernel_ulong_t)dm365_pll1_init  },
+	{ .name = "dm365-pll2",  .driver_data = (kernel_ulong_t)dm365_pll2_init  },
 	{ }
 };
 
drivers/clk/davinci/pll.h +3 -0
index 6bd73d7..b911c8a 100644
@@ -129,4 +129,7 @@ int of_da850_pll1_init(struct device *dev, void __iomem *base);
 int dm355_pll1_init(struct device *dev, void __iomem *base);
 int dm355_pll2_init(struct device *dev, void __iomem *base);
 
+int dm365_pll1_init(struct device *dev, void __iomem *base);
+int dm365_pll2_init(struct device *dev, void __iomem *base);
+
 #endif /* __CLK_DAVINCI_PLL_H___ */
Signature · 1 line
2.7.4
author maintainer
#8 lore raw

PATCH v7 7/42 clk: davinci: Add platform information for TI DM644x PLL

In reply to David Lechner

This adds platform-specific declarations for the PLL clocks on TI DM644x based systems.

---

v7 changes:
- split registration functions for each PLL
- Add platform_device_id lookup

v6 changes:
- Added dm644x_pll{1,2}_info with controller-specific information
- Add empty lines between function calls

 drivers/clk/davinci/Makefile     |  1 +
 drivers/clk/davinci/pll-dm644x.c | 76 ++++++++++++++++++++++++++++++++++++++++
 drivers/clk/davinci/pll.c        |  2 ++
 drivers/clk/davinci/pll.h        |  3 ++
 4 files changed, 82 insertions(+)
 create mode 100644 drivers/clk/davinci/pll-dm644x.c
drivers/clk/davinci/Makefile +1 -0
index 353aa02..59d8ab6 100644
@@ -6,4 +6,5 @@ obj-$(CONFIG_ARCH_DAVINCI_DA830)	+= pll-da830.o
 obj-$(CONFIG_ARCH_DAVINCI_DA850)	+= pll-da850.o
 obj-$(CONFIG_ARCH_DAVINCI_DM355)	+= pll-dm355.o
 obj-$(CONFIG_ARCH_DAVINCI_DM365)	+= pll-dm365.o
+obj-$(CONFIG_ARCH_DAVINCI_DM644x)	+= pll-dm644x.o
 endif
drivers/clk/davinci/pll-dm644x.c new file +76 -0

76 lines not on this page · raw message

drivers/clk/davinci/pll.c +2 -0
index c8dd3fa..613ec24 100644
@@ -760,6 +760,8 @@ static const struct platform_device_id davinci_pll_id_table[] = {
 	{ .name = "dm355-pll2",  .driver_data = (kernel_ulong_t)dm355_pll2_init  },
 	{ .name = "dm365-pll1",  .driver_data = (kernel_ulong_t)dm365_pll1_init  },
 	{ .name = "dm365-pll2",  .driver_data = (kernel_ulong_t)dm365_pll2_init  },
+	{ .name = "dm644x-pll1", .driver_data = (kernel_ulong_t)dm644x_pll1_init },
+	{ .name = "dm644x-pll2", .driver_data = (kernel_ulong_t)dm644x_pll2_init },
 	{ }
 };
 
drivers/clk/davinci/pll.h +3 -0
index b911c8a..df977a6 100644
@@ -132,4 +132,7 @@ int dm355_pll2_init(struct device *dev, void __iomem *base);
 int dm365_pll1_init(struct device *dev, void __iomem *base);
 int dm365_pll2_init(struct device *dev, void __iomem *base);
 
+int dm644x_pll1_init(struct device *dev, void __iomem *base);
+int dm644x_pll2_init(struct device *dev, void __iomem *base);
+
 #endif /* __CLK_DAVINCI_PLL_H___ */
Signature · 1 line
2.7.4
author maintainer
#9 lore raw

PATCH v7 8/42 clk: davinci: Add platform information for TI DM646x PLL

In reply to David Lechner

This adds platform-specific declarations for the PLL clocks on TI DM646x based systems.

---

v7 changes:
- split registration functions for each PLL
- Add platform_device_id lookup

Note: I meant to drop the fixed factor clock for timer2 and use pll1_sysclk3 directly in the lookup but noticed it too late. Will fix in the next rev.

v6 changes:
- Added dm646x_pll{1,2}_info with controller-specific information
- Add empty lines between function calls

 drivers/clk/davinci/Makefile     |  1 +
 drivers/clk/davinci/pll-dm646x.c | 78 ++++++++++++++++++++++++++++++++++++++++
 drivers/clk/davinci/pll.c        |  2 ++
 drivers/clk/davinci/pll.h        |  3 ++
 4 files changed, 84 insertions(+)
 create mode 100644 drivers/clk/davinci/pll-dm646x.c
drivers/clk/davinci/Makefile +1 -0
index 59d8ab6..d471386 100644
@@ -7,4 +7,5 @@ obj-$(CONFIG_ARCH_DAVINCI_DA850)	+= pll-da850.o
 obj-$(CONFIG_ARCH_DAVINCI_DM355)	+= pll-dm355.o
 obj-$(CONFIG_ARCH_DAVINCI_DM365)	+= pll-dm365.o
 obj-$(CONFIG_ARCH_DAVINCI_DM644x)	+= pll-dm644x.o
+obj-$(CONFIG_ARCH_DAVINCI_DM646x)	+= pll-dm646x.o
 endif
drivers/clk/davinci/pll-dm646x.c new file +78 -0

78 lines not on this page · raw message

drivers/clk/davinci/pll.c +2 -0
index 613ec24..8fad491 100644
@@ -762,6 +762,8 @@ static const struct platform_device_id davinci_pll_id_table[] = {
 	{ .name = "dm365-pll2",  .driver_data = (kernel_ulong_t)dm365_pll2_init  },
 	{ .name = "dm644x-pll1", .driver_data = (kernel_ulong_t)dm644x_pll1_init },
 	{ .name = "dm644x-pll2", .driver_data = (kernel_ulong_t)dm644x_pll2_init },
+	{ .name = "dm646x-pll1", .driver_data = (kernel_ulong_t)dm646x_pll1_init },
+	{ .name = "dm646x-pll2", .driver_data = (kernel_ulong_t)dm646x_pll2_init },
 	{ }
 };
 
drivers/clk/davinci/pll.h +3 -0
index df977a6..5977be0 100644
@@ -135,4 +135,7 @@ int dm365_pll2_init(struct device *dev, void __iomem *base);
 int dm644x_pll1_init(struct device *dev, void __iomem *base);
 int dm644x_pll2_init(struct device *dev, void __iomem *base);
 
+int dm646x_pll1_init(struct device *dev, void __iomem *base);
+int dm646x_pll2_init(struct device *dev, void __iomem *base);
+
 #endif /* __CLK_DAVINCI_PLL_H___ */
Signature · 1 line
2.7.4
author maintainer
#10 lore raw

PATCH v7 9/42 dt-bindings: clock: New bindings for TI Davinci PSC

In reply to David Lechner

This adds a new binding for the Power Sleep Controller (PSC) for the mach-davinci family of processors.

Note: Although TI Keystone has a very similar PSC, we are not using the existing bindings. Keystone is using a legacy one-node-per-clock binding (actually two nodes if you count the separate reset binding for the same IP block). Also, some davinci LPSCs have quirks that aren't handled by the keystone bindings, so we would be adding one compatible string per clock with quirks instead of just a new compatible string for each controller.

---

v7 changes:
- Fixed clock-names property typo
- Added #power-domain-cells property

v6 changes:
- added clocks and clock-names properties
- expanded examples

 .../devicetree/bindings/clock/ti/davinci/psc.txt   | 71 ++++++++++++++++++++++
 1 file changed, 71 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/clock/ti/davinci/psc.txt
Documentation/devicetree/bindings/clock/ti/davinci/psc.txt new file +71 -0
new file mode 100644
index 0000000..dae4ad8
@@ -0,0 +1,71 @@
+Binding for TI DaVinci Power Sleep Controller (PSC)
+
+The PSC provides power management, clock gating and reset functionality. It is
+primarily used for clocking.
+
+Required properties:
+- compatible: shall be one of:
+	- "ti,da850-psc0" for PSC0 on DA850/OMAP-L138/AM18XX
+	- "ti,da850-psc1" for PSC1 on DA850/OMAP-L138/AM18XX
+- reg: physical base address and size of the controller's register area
+- #clock-cells: from common clock binding; shall be set to 1
+- #power-domain-cells: from generic power domain binding; shall be set to 1.
+- clocks: phandles to clocks corresponding to the clock-names property
+- clock-names: list of parent clock names - depends on compatible value
+	- for "ti,da850-psc0", shall be "pll0_sysclk1", "pll0_sysclk2",
+	  "pll0_sysclk4", "pll0_sysclk6", "async1"
+	- for "ti,da850-psc1", shall be "pll0_sysclk2", "pll0_sysclk4", "async3"
+
+Optional properties:
+- #reset-cells: from reset binding; shall be set to 1 - only applicable when
+  at least one local domain provides a local reset.
+
+Consumers:
+
+	Clock, power domain and reset consumers shall use the local power domain
+	module ID (LPSC) as the index corresponding to the clock cell. Refer to
+	the device-specific datasheet to find these numbers. NB: Most local
+	domains	only provide a clock/power domain and not a reset.
+
+Examples:
+
+	psc0: clock-controller at 10000 {
+		compatible = "ti,da850-psc0";
+		reg = <0x10000 0x1000>;
+		#clock-cells = <1>;
+		#power-domain-cells = <1>;
+		#reset-cells = <1>;
+		clocks = <&pll0_sysclk 1>, <&pll0_sysclk 2>,
+			 <&pll0_sysclk 4>, <&pll0_sysclk 6>, <&async1_clk>;
+		clock_names = "pll0_sysclk1", "pll0_sysclk2",
+			      "pll0_sysclk4", "pll0_sysclk6", "async1";
+	};
+	psc1: clock-controller at 227000 {
+		compatible = "ti,da850-psc1";
+		reg = <0x227000 0x1000>;
+		#clock-cells = <1>;
+		#power-domain-cells = <1>;
+		clocks = <&pll0_sysclk 2>, <&pll0_sysclk 4>, <&async3_clk>;
+		clock_names = "pll0_sysclk2", "pll0_sysclk4", "async3";
+	};
+
+	/* consumer */
+	dsp: dsp at 11800000 {
+		compatible = "ti,da850-dsp";
+		reg = <0x11800000 0x40000>,
+		      <0x11e00000 0x8000>,
+		      <0x11f00000 0x8000>,
+		      <0x01c14044 0x4>,
+		      <0x01c14174 0x8>;
+		reg-names = "l2sram", "l1pram", "l1dram", "host1cfg", "chipsig";
+		interrupt-parent = <&intc>;
+		interrupts = <28>;
+		clocks = <&psc0 15>;
+		power-domains = <&psc0 15>;
+		resets = <&psc0 15>;
+	};
+
+Also see:
+- Documentation/devicetree/bindings/clock/clock-bindings.txt
+- Documentation/devicetree/bindings/power/power_domain.txt
+- Documentation/devicetree/bindings/reset/reset.txt
Signature · 1 line
2.7.4
maintainer Reviewed-by on v7 9/42
#11 lore raw

Re: [PATCH v7 09/42] dt-bindings: clock: New bindings for TI Davinci PSC

Quoted 18 lines · David Lechner

This adds a new binding for the Power Sleep Controller (PSC) for the mach-davinci family of processors.

Note: Although TI Keystone has a very similar PSC, we are not using the existing bindings. Keystone is using a legacy one-node-per-clock binding (actually two nodes if you count the separate reset binding for the same IP block). Also, some davinci LPSCs have quirks that aren't handled by the keystone bindings, so we would be adding one compatible string per clock with quirks instead of just a new compatible string for each controller.

---

v7 changes:
- Fixed clock-names property typo
- Added #power-domain-cells property

Quoted 8 lines

v6 changes:
- added clocks and clock-names properties
- expanded examples

 .../devicetree/bindings/clock/ti/davinci/psc.txt   | 71 ++++++++++++++++++++++
 1 file changed, 71 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/clock/ti/davinci/psc.txt
author maintainer
#12 lore raw

PATCH v7 10/42 clk: davinci: New driver for davinci PSC clocks

In reply to David Lechner

This adds a new driver for mach-davinci PSC clocks. This is porting the code from arch/arm/mach-davinci/psc.c to the common clock framework and is converting it to use regmap to simplify the code. Additionally, it adds device tree support for these clocks.

Note: although there are similar clocks for TI Keystone we are not able to share the code for a few reasons. The keystone clocks are device tree only and use legacy one-node-per-clock bindings. Also the keystone driver makes the assumption that there is only one PSC per SoC and uses global variables, but here we have two controllers per SoC.

---

v7 changes:
- convert to platform device
- rename lpsc field to md
- rename PSC to LPSC where appropriate
- rename LPSC_ARM_RATE to LPSC_SET_RATE_PARENT
- add genpd provider
- add reset provider

v6 changes:
- use GENMASK
- add quirk flag for FORCE bit
- add quirk flag for propagating set_rate
- fix writing to PDSTAT instead of PDCTL
- remove unused doc comment parameter
- change davinci_psc_register_clocks() to handle registering clkdev entries

 drivers/clk/davinci/Makefile |   2 +
 drivers/clk/davinci/psc.c    | 495 +++++++++++++++++++++++++++++++++++++++++++
 drivers/clk/davinci/psc.h    |  89 ++++++++
 3 files changed, 586 insertions(+)
 create mode 100644 drivers/clk/davinci/psc.c
 create mode 100644 drivers/clk/davinci/psc.h
drivers/clk/davinci/Makefile +2 -0
index d471386..cd1bf2c 100644
@@ -8,4 +8,6 @@ obj-$(CONFIG_ARCH_DAVINCI_DM355)	+= pll-dm355.o
 obj-$(CONFIG_ARCH_DAVINCI_DM365)	+= pll-dm365.o
 obj-$(CONFIG_ARCH_DAVINCI_DM644x)	+= pll-dm644x.o
 obj-$(CONFIG_ARCH_DAVINCI_DM646x)	+= pll-dm646x.o
+
+obj-y += psc.o
 endif
drivers/clk/davinci/psc.c new file +495 -0

495 lines not on this page · raw message

drivers/clk/davinci/psc.h new file +89 -0

89 lines not on this page · raw message

Signature · 1 line
2.7.4
#13 lore raw

Re: [PATCH v7 10/42] clk: davinci: New driver for davinci PSC clocks

2018-02-19 21:21 GMT+01:00 David Lechner <[email protected]>:

Quoted 208 lines

This adds a new driver for mach-davinci PSC clocks. This is porting the code from arch/arm/mach-davinci/psc.c to the common clock framework and is converting it to use regmap to simplify the code. Additionally, it adds device tree support for these clocks.

Note: although there are similar clocks for TI Keystone we are not able to share the code for a few reasons. The keystone clocks are device tree only and use legacy one-node-per-clock bindings. Also the keystone driver makes the assumption that there is only one PSC per SoC and uses global variables, but here we have two controllers per SoC.

---

v7 changes:
- convert to platform device
- rename lpsc field to md
- rename PSC to LPSC where appropriate
- rename LPSC_ARM_RATE to LPSC_SET_RATE_PARENT
- add genpd provider
- add reset provider

v6 changes:
- use GENMASK
- add quirk flag for FORCE bit
- add quirk flag for propagating set_rate
- fix writing to PDSTAT instead of PDCTL
- remove unused doc comment parameter
- change davinci_psc_register_clocks() to handle registering clkdev entries

 drivers/clk/davinci/Makefile |   2 +
 drivers/clk/davinci/psc.c    | 495 +++++++++++++++++++++++++++++++++++++++++++
 drivers/clk/davinci/psc.h    |  89 ++++++++
 3 files changed, 586 insertions(+)
 create mode 100644 drivers/clk/davinci/psc.c
 create mode 100644 drivers/clk/davinci/psc.h
drivers/clk/davinci/Makefile +2 -0
index d471386..cd1bf2c 100644
@@ -8,4 +8,6 @@ obj-$(CONFIG_ARCH_DAVINCI_DM355)        += pll-dm355.o
 obj-$(CONFIG_ARCH_DAVINCI_DM365)       += pll-dm365.o
 obj-$(CONFIG_ARCH_DAVINCI_DM644x)      += pll-dm644x.o
 obj-$(CONFIG_ARCH_DAVINCI_DM646x)      += pll-dm646x.o
+
+obj-y += psc.o
 endif
drivers/clk/davinci/psc.c new file +153 -0
new file mode 100644
index 0000000..8e08ac8
@@ -0,0 +1,495 @@
+// SPDX-License-Identifier: GPL-2.0
+/*
+ * Clock driver for TI Davinci PSC controllers
+ *
+ * Copyright (C) 2017 David Lechner <[email protected]>
+ *
+ * Based on: drivers/clk/keystone/gate.c
+ * Copyright (C) 2013 Texas Instruments.
+ *     Murali Karicheri <[email protected]>
+ *     Santosh Shilimkar <[email protected]>
+ *
+ * And: arch/arm/mach-davinci/psc.c
+ * Copyright (C) 2006 Texas Instruments.
+ */
+
+#include <linux/clk-provider.h>
+#include <linux/clk.h>
+#include <linux/clkdev.h>
+#include <linux/err.h>
+#include <linux/of_address.h>
+#include <linux/of_device.h>
+#include <linux/of.h>
+#include <linux/platform_device.h>
+#include <linux/pm_clock.h>
+#include <linux/pm_domain.h>
+#include <linux/regmap.h>
+#include <linux/reset-controller.h>
+#include <linux/slab.h>
+#include <linux/types.h>
+
+#include "psc.h"
+
+/* PSC register offsets */
+#define EPCPR                  0x070
+#define PTCMD                  0x120
+#define PTSTAT                 0x128
+#define PDSTAT(n)              (0x200 + 4 * (n))
+#define PDCTL(n)               (0x300 + 4 * (n))
+#define MDSTAT(n)              (0x800 + 4 * (n))
+#define MDCTL(n)               (0xa00 + 4 * (n))
+
+/* PSC module states */
+enum davinci_lpsc_state {
+       LPSC_STATE_SWRSTDISABLE = 0,
+       LPSC_STATE_SYNCRST      = 1,
+       LPSC_STATE_DISABLE      = 2,
+       LPSC_STATE_ENABLE       = 3,
+};
+
+#define MDSTAT_STATE_MASK      GENMASK(5, 0)
+#define MDSTAT_MCKOUT          BIT(12)
+#define PDSTAT_STATE_MASK      GENMASK(4, 0)
+#define MDCTL_FORCE            BIT(31)
+#define MDCTL_LRESET           BIT(8)
+#define PDCTL_EPCGOOD          BIT(8)
+#define PDCTL_NEXT             BIT(0)
+
+struct davinci_psc_data {
+       struct clk_onecell_data clk_data;
+       struct genpd_onecell_data pm_data;
+       struct reset_controller_dev rcdev;
+};
+
+/**
+ * struct davinci_lpsc_clk - LPSC clock structure
+ * @hw: clk_hw for the LPSC
+ * @pm_domain: power domain for the LPSC
+ * @regmap: PSC MMIO region
+ * @md: Module domain (LPSC module id)
+ * @pd: Power domain
+ * @flags: LPSC_* quirk flags
+ */
+struct davinci_lpsc_clk {
+       struct clk_hw hw;
+       struct generic_pm_domain pm_domain;
+       struct regmap *regmap;
+       u32 md;
+       u32 pd;
+       u32 flags;
+};
+
+#define to_davinci_psc_data(x) container_of(x, struct davinci_psc_data, x)
+#define to_davinci_lpsc_clk(x) container_of(x, struct davinci_lpsc_clk, x)
+
+static void davinci_lpsc_config(struct davinci_lpsc_clk *lpsc,
+                               enum davinci_lpsc_state next_state)
+{
+       u32 epcpr, pdstat, mdstat, ptstat;
+
+       regmap_write_bits(lpsc->regmap, MDCTL(lpsc->md), MDSTAT_STATE_MASK,
+                         next_state);
+
+       if (lpsc->flags & LPSC_FORCE)
+               regmap_write_bits(lpsc->regmap, MDCTL(lpsc->md), MDCTL_FORCE,
+                                 MDCTL_FORCE);
+
+       regmap_read(lpsc->regmap, PDSTAT(lpsc->pd), &pdstat);
+       if ((pdstat & PDSTAT_STATE_MASK) == 0) {
+               regmap_write_bits(lpsc->regmap, PDCTL(lpsc->pd), PDCTL_NEXT,
+                                 PDCTL_NEXT);
+
+               regmap_write(lpsc->regmap, PTCMD, BIT(lpsc->pd));
+
+               regmap_read_poll_timeout(lpsc->regmap, EPCPR, epcpr,
+                                        epcpr & BIT(lpsc->pd), 0, 0);
+
+               regmap_write_bits(lpsc->regmap, PDCTL(lpsc->pd), PDCTL_EPCGOOD,
+                                 PDCTL_EPCGOOD);
+       } else {
+               regmap_write(lpsc->regmap, PTCMD, BIT(lpsc->pd));
+       }
+
+       regmap_read_poll_timeout(lpsc->regmap, PTSTAT, ptstat,
+                                !(ptstat & BIT(lpsc->pd)), 0, 0);
+
+       regmap_read_poll_timeout(lpsc->regmap, MDSTAT(lpsc->md), mdstat,
+                                (mdstat & MDSTAT_STATE_MASK) == next_state,
+                                0, 0);
+}
+
+static int davinci_lpsc_clk_enable(struct clk_hw *hw)
+{
+       struct davinci_lpsc_clk *lpsc = to_davinci_lpsc_clk(hw);
+
+       davinci_lpsc_config(lpsc, LPSC_STATE_ENABLE);
+
+       return 0;
+}
+
+static void davinci_lpsc_clk_disable(struct clk_hw *hw)
+{
+       struct davinci_lpsc_clk *lpsc = to_davinci_lpsc_clk(hw);
+
+       davinci_lpsc_config(lpsc, LPSC_STATE_DISABLE);
+}
+
+static int davinci_lpsc_clk_is_enabled(struct clk_hw *hw)
+{
+       struct davinci_lpsc_clk *lpsc = to_davinci_lpsc_clk(hw);
+       u32 mdstat;
+
+       regmap_read(lpsc->regmap, MDSTAT(lpsc->md), &mdstat);
+
+       return (mdstat & MDSTAT_MCKOUT) ? 1 : 0;
+}
+
+static const struct clk_ops davinci_lpsc_clk_ops = {
+       .enable         = davinci_lpsc_clk_enable,
+       .disable        = davinci_lpsc_clk_disable,
+       .is_enabled     = davinci_lpsc_clk_is_enabled,
+};
+
+static int davinci_psc_genpd_attach_dev(struct generic_pm_domain *pm_domain,

drivers/clk/davinci/psc.c line 163

Quoted 10 lines
drivers/clk/davinci/psc.c new file +10 -0
+                                       struct device *dev)
+{
+       struct davinci_lpsc_clk *lpsc = to_davinci_lpsc_clk(pm_domain);
+       struct clk *clk = lpsc->hw.clk;
+       int ret;
+
+       ret = pm_clk_create(dev);
+       if (ret < 0)
+               return ret;
+

Hi David,

I think I found the reason for the strange crashes we were experiencing (emac core->name being NULL) thanks to Sekhar who pointed me in the right direction.

The mdio driver fails to probe with v7 due to the supplied clock rate being wrong. Before failing we register the emac clock with pm_clk_add_clk(). When clock_ops puts the clock, it decreases the reference count of the clock, but we never actually increased it in the first place in the line above. The core clock code then destroys the associated clk_core structure. When the next user comes around (in our case the clk debug functions) the system crashes.

I believe there to be two issues: one is with v7 - we need to increase the clock reference count in davinci_psc_genpd_attach_dev().

Second is the error path in the clock framework - we should remove the destroyed clk_core from the debug list, which is not being done now.

Why we even need to track the refcount of clk_core is a mistery for me though. Stephen, Mike?

Best regards,
Bartosz Golaszewski

Quoted 430 lines
drivers/clk/davinci/psc.c new file +332 -0
+       ret = pm_clk_add_clk(dev, clk);
+       if (ret < 0) {
+               pm_clk_destroy(dev);
+               return ret;
+       }
+
+       return 0;
+}
+
+static void davinci_psc_genpd_detach_dev(struct generic_pm_domain *pm_domain,
+                                        struct device *dev)
+{
+       struct davinci_lpsc_clk *lpsc = to_davinci_lpsc_clk(pm_domain);
+       struct clk *clk = lpsc->hw.clk;
+
+       pm_clk_remove_clk(dev, clk);
+       pm_clk_destroy(dev);
+}
+
+/**
+ * davinci_lpsc_clk_register - register LPSC clock
+ * @name: name of this clock
+ * @parent_name: name of clock's parent
+ * @regmap: PSC MMIO region
+ * @md: local PSC number
+ * @pd: power domain
+ * @flags: LPSC_* flags
+ */
+static struct davinci_lpsc_clk *
+davinci_lpsc_clk_register(struct device *dev, const char *name,
+                         const char *parent_name, struct regmap *regmap,
+                         u32 md, u32 pd, u32 flags)
+{
+       struct clk_init_data init;
+       struct davinci_lpsc_clk *lpsc;
+       int ret;
+       bool is_on;
+
+       lpsc = devm_kzalloc(dev, sizeof(*lpsc), GFP_KERNEL);
+       if (!lpsc)
+               return ERR_PTR(-ENOMEM);
+
+       init.name = name;
+       init.ops = &davinci_lpsc_clk_ops;
+       init.parent_names = (parent_name ? &parent_name : NULL);
+       init.num_parents = (parent_name ? 1 : 0);
+       init.flags = 0;
+
+       if (flags & LPSC_ALWAYS_ENABLED)
+               init.flags |= CLK_IS_CRITICAL;
+
+       if (flags & LPSC_SET_RATE_PARENT)
+               init.flags |= CLK_SET_RATE_PARENT;
+
+       lpsc->regmap = regmap;
+       lpsc->hw.init = &init;
+       lpsc->md = md;
+       lpsc->pd = pd;
+       lpsc->flags = flags;
+
+       ret = devm_clk_hw_register(dev, &lpsc->hw);
+       if (ret < 0)
+               return ERR_PTR(ret);
+
+       lpsc->pm_domain.name = devm_kasprintf(dev, GFP_KERNEL, "%s: %s",
+                                             dev_name(dev), name);
+       lpsc->pm_domain.attach_dev = davinci_psc_genpd_attach_dev;
+       lpsc->pm_domain.detach_dev = davinci_psc_genpd_detach_dev;
+       lpsc->pm_domain.flags = GENPD_FLAG_PM_CLK;
+
+       is_on = davinci_lpsc_clk_is_enabled(&lpsc->hw);
+       pm_genpd_init(&lpsc->pm_domain, NULL, is_on);
+
+       return lpsc;
+}
+
+static int davinci_lpsc_clk_reset(struct clk *clk, bool reset)
+{
+       struct clk_hw *hw = __clk_get_hw(clk);
+       struct davinci_lpsc_clk *lpsc = to_davinci_lpsc_clk(hw);
+       u32 mdctl;
+
+       if (IS_ERR_OR_NULL(lpsc))
+               return -EINVAL;
+
+       mdctl = reset ? 0 : MDCTL_LRESET;
+       regmap_write_bits(lpsc->regmap, MDCTL(lpsc->md), MDCTL_LRESET, mdctl);
+
+       return 0;
+}
+
+/*
+ * REVISIT: These exported functions can be removed after a non-DT lookup is
+ * added to the reset controller framework and the davinci-rproc driver is
+ * updated to use the generic reset controller framework.
+ */
+
+int davinci_clk_reset_assert(struct clk *clk)
+{
+       return davinci_lpsc_clk_reset(clk, true);
+}
+EXPORT_SYMBOL(davinci_clk_reset_assert);
+
+int davinci_clk_reset_deassert(struct clk *clk)
+{
+       return davinci_lpsc_clk_reset(clk, false);
+}
+EXPORT_SYMBOL(davinci_clk_reset_deassert);
+
+static int davinci_psc_reset_assert(struct reset_controller_dev *rcdev,
+                                   unsigned long id)
+{
+       struct davinci_psc_data *psc = to_davinci_psc_data(rcdev);
+       struct clk *clk = psc->clk_data.clks[id];
+
+       return davinci_lpsc_clk_reset(clk, true);
+}
+
+static int davinci_psc_reset_deassert(struct reset_controller_dev *rcdev,
+                                     unsigned long id)
+{
+       struct davinci_psc_data *psc = to_davinci_psc_data(rcdev);
+       struct clk *clk = psc->clk_data.clks[id];
+
+       return davinci_lpsc_clk_reset(clk, false);
+}
+
+static const struct reset_control_ops davinci_psc_reset_ops = {
+       .assert         = davinci_psc_reset_assert,
+       .deassert       = davinci_psc_reset_deassert,
+};
+
+static int davinci_psc_reset_of_xlate(struct reset_controller_dev *rcdev,
+                                     const struct of_phandle_args *reset_spec)
+{
+       struct of_phandle_args clkspec = *reset_spec; /* discard const qualifier */
+       struct clk *clk;
+       struct clk_hw *hw;
+       struct davinci_lpsc_clk *lpsc;
+
+       /* the clock node is the same as the reset node */
+       clk = of_clk_get_from_provider(&clkspec);
+       if (IS_ERR(clk))
+               return PTR_ERR(clk);
+
+       hw = __clk_get_hw(clk);
+       lpsc = to_davinci_lpsc_clk(hw);
+       clk_put(clk);
+
+       /* not all modules support local reset */
+       if (!(lpsc->flags & LPSC_LOCAL_RESET))
+               return -EINVAL;
+
+       return lpsc->md;
+}
+
+static const struct regmap_config davinci_psc_regmap_config = {
+       .reg_bits       = 32,
+       .reg_stride     = 4,
+       .val_bits       = 32,
+};
+
+static struct davinci_psc_data *
+__davinci_psc_register_clocks(struct device *dev,
+                             const struct davinci_lpsc_clk_info *info,
+                             int num_clks,
+                             void __iomem *base)
+{
+       struct davinci_psc_data *psc;
+       struct clk **clks;
+       struct generic_pm_domain **pm_domains;
+       struct regmap *regmap;
+       int i, ret;
+
+       psc = devm_kzalloc(dev, sizeof(*psc), GFP_KERNEL);
+       if (!psc)
+               return ERR_PTR(-ENOMEM);
+
+       clks = devm_kmalloc_array(dev, num_clks, sizeof(*clks), GFP_KERNEL);
+       if (!clks)
+               return ERR_PTR(-ENOMEM);
+
+       psc->clk_data.clks = clks;
+       psc->clk_data.clk_num = num_clks;
+
+       /*
+        * init array with error so that of_clk_src_onecell_get() doesn't
+        * return NULL for gaps in the sparse array
+        */
+       for (i = 0; i < num_clks; i++)
+               clks[i] = ERR_PTR(-ENOENT);
+
+       pm_domains = devm_kcalloc(dev, num_clks, sizeof(*pm_domains), GFP_KERNEL);
+       if (!pm_domains)
+               return ERR_PTR(-ENOMEM);
+
+       psc->pm_data.domains = pm_domains;
+       psc->pm_data.num_domains = num_clks;
+
+       regmap = devm_regmap_init_mmio(dev, base, &davinci_psc_regmap_config);
+       if (IS_ERR(regmap))
+               return ERR_CAST(regmap);
+
+       for (; info->name; info++) {
+               struct davinci_lpsc_clk *lpsc;
+
+               lpsc = davinci_lpsc_clk_register(dev, info->name, info->parent,
+                                                regmap, info->md, info->pd,
+                                                info->flags);
+               if (IS_ERR(lpsc)) {
+                       dev_warn(dev, "Failed to register %s (%ld)\n",
+                                info->name, PTR_ERR(lpsc));
+                       continue;
+               }
+
+               clks[info->md] = lpsc->hw.clk;
+               pm_domains[info->md] = &lpsc->pm_domain;
+       }
+
+       psc->rcdev.ops = &davinci_psc_reset_ops;
+       psc->rcdev.owner = THIS_MODULE;
+       psc->rcdev.of_node = dev->of_node;
+       psc->rcdev.of_reset_n_cells = 1;
+       psc->rcdev.of_xlate = davinci_psc_reset_of_xlate;
+       psc->rcdev.nr_resets = num_clks;
+
+       ret = devm_reset_controller_register(dev, &psc->rcdev);
+       if (ret < 0)
+               dev_warn(dev, "Failed to register reset controller (%d)\n", ret);
+
+       return psc;
+}
+
+int davinci_psc_register_clocks(struct device *dev,
+                               const struct davinci_lpsc_clk_info *info,
+                               u8 num_clks,
+                               void __iomem *base)
+{
+       struct davinci_psc_data *psc;
+
+       psc = __davinci_psc_register_clocks(dev, info, num_clks, base);
+       if (IS_ERR(psc))
+               return PTR_ERR(psc);
+
+       for (; info->name; info++) {
+               const struct davinci_lpsc_clkdev_info *cdevs = info->cdevs;
+               struct clk *clk = psc->clk_data.clks[info->md];
+
+               if (!cdevs || IS_ERR_OR_NULL(clk))
+                       continue;
+
+               for (; cdevs->con_id || cdevs->dev_id; cdevs++)
+                       clk_register_clkdev(clk, cdevs->con_id, cdevs->dev_id);
+       }
+
+       return 0;
+}
+
+int of_davinci_psc_clk_init(struct device *dev,
+                           const struct davinci_lpsc_clk_info *info,
+                           u8 num_clks,
+                           void __iomem *base)
+{
+       struct device_node *node = dev->of_node;
+       struct davinci_psc_data *psc;
+
+       psc = __davinci_psc_register_clocks(dev, info, num_clks, base);
+       if (IS_ERR(psc))
+               return PTR_ERR(psc);
+
+       of_genpd_add_provider_onecell(node, &psc->pm_data);
+
+       of_clk_add_provider(node, of_clk_src_onecell_get, &psc->clk_data);
+
+       return 0;
+}
+
+static const struct of_device_id davinci_psc_of_match[] = {
+       { }
+};
+
+static const struct platform_device_id davinci_psc_id_table[] = {
+       { }
+};
+
+typedef int (*davinci_psc_init)(struct device *dev, void __iomem *base);
+
+static int davinci_psc_probe(struct platform_device *pdev)
+{
+       struct device *dev = &pdev->dev;
+       const struct of_device_id *of_id;
+       davinci_psc_init psc_init = NULL;
+       struct resource *res;
+       void __iomem *base;
+
+       of_id = of_match_device(davinci_psc_of_match, dev);
+       if (of_id)
+               psc_init = of_id->data;
+       else if (pdev->id_entry)
+               psc_init = (void *)pdev->id_entry->driver_data;
+
+       if (!psc_init) {
+               dev_err(dev, "unable to find driver data\n");
+               return -EINVAL;
+       }
+
+       res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
+       base = devm_ioremap_resource(dev, res);
+       if (IS_ERR(base)) {
+               dev_err(dev, "ioremap failed\n");
+               return PTR_ERR(base);
+       }
+
+       return psc_init(dev, base);
+}
+
+static struct platform_driver davinci_psc_driver = {
+       .probe          = davinci_psc_probe,
+       .driver         = {
+               .name           = "davinci-psc-clk",
+               .of_match_table = davinci_psc_of_match,
+       },
+       .id_table       = davinci_psc_id_table,
+};
+
+static int __init davinci_psc_driver_init(void)
+{
+       return platform_driver_register(&davinci_psc_driver);
+}
+
+/* has to be postcore_initcall because davinci_gpio depend on PSC clocks */
+postcore_initcall(davinci_psc_driver_init);
drivers/clk/davinci/psc.h new file +89 -1
new file mode 100644
index 0000000..c342d54
@@ -0,0 +1,89 @@
+// SPDX-License-Identifier: GPL-2.0
+/*
+ * Clock driver for TI Davinci PSC controllers
+ *
+ * Copyright (C) 2018 David Lechner <[email protected]>
+ */
+
+#ifndef __CLK_DAVINCI_PSC_H__
+#define __CLK_DAVINCI_PSC_H__
+
+#include <linux/clk-provider.h>
+#include <linux/types.h>
+
+/* PSC quirk flags */
+#define LPSC_ALWAYS_ENABLED    BIT(0) /* never disable this clock */
+#define LPSC_SET_RATE_PARENT   BIT(1) /* propagate set_rate to parent clock */
+#define LPSC_FORCE             BIT(2) /* requires MDCTL FORCE bit */
+#define LPSC_LOCAL_RESET       BIT(3) /* acts as reset provider */
+
+struct davinci_lpsc_clkdev_info {
+       const char *con_id;
+       const char *dev_id;
+};
+
+#define LPSC_CLKDEV(c, d) {    \
+       .con_id = (c),          \
+       .dev_id = (d)           \
+}
+
+#define LPSC_CLKDEV1(n, c, d) \
+static const struct davinci_lpsc_clkdev_info n[] __initconst = {       \
+       LPSC_CLKDEV((c), (d)),                                          \
+       { }                                                             \
+}
+
+#define LPSC_CLKDEV2(n, c1, d1, c2, d2) \
+static const struct davinci_lpsc_clkdev_info n[] __initconst = {       \
+       LPSC_CLKDEV((c1), (d1)),                                        \
+       LPSC_CLKDEV((c2), (d2)),                                        \
+       { }                                                             \
+}
+
+#define LPSC_CLKDEV3(n, c1, d1, c2, d2, c3, d3) \
+static const struct davinci_lpsc_clkdev_info n[] __initconst = {       \
+       LPSC_CLKDEV((c1), (d1)),                                        \
+       LPSC_CLKDEV((c2), (d2)),                                        \
+       LPSC_CLKDEV((c3), (d3)),                                        \
+       { }                                                             \
+}
+
+/**
+ * davinci_lpsc_clk_info - LPSC module-specific clock information
+ * @name: the clock name
+ * @parent: the parent clock name
+ * @cdevs: optional array of clkdev lookup table info
+ * @md: the local module domain (LPSC id)
+ * @pd: the power domain id
+ * @flags: bitmask of LPSC_* flags
+ */
+struct davinci_lpsc_clk_info {
+       const char *name;
+       const char *parent;
+       const struct davinci_lpsc_clkdev_info *cdevs;
+       u32 md;
+       u32 pd;
+       unsigned long flags;
+};
+
+#define LPSC(m, d, n, p, c, f) \
+{                              \
+       .name   = #n,           \
+       .parent = #p,           \
+       .cdevs  = (c),          \
+       .md     = (m),          \
+       .pd     = (d),          \
+       .flags  = (f),          \
+}
+
+int davinci_psc_register_clocks(struct device *dev,
+                               const struct davinci_lpsc_clk_info *info,
+                               u8 num_clks,
+                               void __iomem *base);
+
+int of_davinci_psc_clk_init(struct device *dev,
+                           const struct davinci_lpsc_clk_info *info,
+                           u8 num_clks,
+                           void __iomem *base);
+
+#endif /* __CLK_DAVINCI_PSC_H__ */
--

2.7.4

author maintainer
#14 lore raw

Re: [PATCH v7 10/42] clk: davinci: New driver for davinci PSC clocks

Quoted 16 lines · Bartosz Golaszewski

I think I found the reason for the strange crashes we were experiencing (emac core->name being NULL) thanks to Sekhar who pointed me in the right direction.

The mdio driver fails to probe with v7 due to the supplied clock rate being wrong. Before failing we register the emac clock with pm_clk_add_clk(). When clock_ops puts the clock, it decreases the reference count of the clock, but we never actually increased it in the first place in the line above. The core clock code then destroys the associated clk_core structure. When the next user comes around (in our case the clk debug functions) the system crashes.

I believe there to be two issues: one is with v7 - we need to increase the clock reference count in davinci_psc_genpd_attach_dev().

Quoted 8 lines

Second is the error path in the clock framework - we should remove the destroyed clk_core from the debug list, which is not being done now.

Why we even need to track the refcount of clk_core is a mistery for me though. Stephen, Mike?

Best regards,
Bartosz Golaszewski

Great find. I figured it had to be something like this, but I wasn't able to reproduce the problem yet.

I suppose it is time to spin up a v8 with some fixes.

#15 lore raw

Re: [PATCH v7 10/42] clk: davinci: New driver for davinci PSC clocks

2018-02-28 22:40 GMT+01:00 David Lechner <[email protected]>:

Quoted 24 lines · Bartosz Golaszewski
Quoted 23 lines

I think I found the reason for the strange crashes we were experiencing (emac core->name being NULL) thanks to Sekhar who pointed me in the right direction.

The mdio driver fails to probe with v7 due to the supplied clock rate being wrong. Before failing we register the emac clock with pm_clk_add_clk(). When clock_ops puts the clock, it decreases the reference count of the clock, but we never actually increased it in the first place in the line above. The core clock code then destroys the associated clk_core structure. When the next user comes around (in our case the clk debug functions) the system crashes.

I believe there to be two issues: one is with v7 - we need to increase the clock reference count in davinci_psc_genpd_attach_dev().

Second is the error path in the clock framework - we should remove the destroyed clk_core from the debug list, which is not being done now.

Why we even need to track the refcount of clk_core is a mistery for me though. Stephen, Mike?

Quoted 8 lines
Quoted 2 lines

Best regards,
Bartosz Golaszewski

Great find. I figured it had to be something like this, but I wasn't able to reproduce the problem yet.

I suppose it is time to spin up a v8 with some fixes.

I still don't know why the mdio clock rate is much lower than in mainline though. Any ideas?

Thanks,
Bart

author maintainer
#16 lore raw

Re: [PATCH v7 10/42] clk: davinci: New driver for davinci PSC clocks

Quoted 32 lines · Bartosz Golaszewski

2018-02-28 22:40 GMT+01:00 David Lechner <[email protected]>:

Quoted 31 lines · Bartosz Golaszewski
Quoted 17 lines

I think I found the reason for the strange crashes we were experiencing (emac core->name being NULL) thanks to Sekhar who pointed me in the right direction.

The mdio driver fails to probe with v7 due to the supplied clock rate being wrong. Before failing we register the emac clock with pm_clk_add_clk(). When clock_ops puts the clock, it decreases the reference count of the clock, but we never actually increased it in the first place in the line above. The core clock code then destroys the associated clk_core structure. When the next user comes around (in our case the clk debug functions) the system crashes.

I believe there to be two issues: one is with v7 - we need to increase the clock reference count in davinci_psc_genpd_attach_dev().

Quoted 8 lines

Second is the error path in the clock framework - we should remove the destroyed clk_core from the debug list, which is not being done now.

Why we even need to track the refcount of clk_core is a mistery for me though. Stephen, Mike?

Best regards,
Bartosz Golaszewski

Great find. I figured it had to be something like this, but I wasn't able to reproduce the problem yet.

Quoted 8 lines
Quoted 1 line

I suppose it is time to spin up a v8 with some fixes.

I still don't know why the mdio clock rate is much lower than in mainline though. Any ideas?

Thanks,
Bart

Now that you have fixed the crash, can you answer the questions I have asked earlier?

Quoted 1 line

Can you post the output of this command so that I can see how your

clocks are setup:

cat /sys/kernel/debug/clk/clk_summary

Quoted 1 line

Using your workaround, can you run:

cat /sys/kernel/debug/pm_genpd/pm_genpd_summary

If you see:
1e27000.clock-controller: emac off-0

then genpd is not working like it is supposed to. You should see something like this for device that are working:

          1e27000.clock-controller: uart2  on
    /devices/platform/soc@1c00000/1d0d000.serial        active
#17 lore raw

Re: [PATCH v7 10/42] clk: davinci: New driver for davinci PSC clocks

2018-03-01 17:44 GMT+01:00 David Lechner <[email protected]>:

Quoted 61 lines · Bartosz Golaszewski
Quoted 36 lines

2018-02-28 22:40 GMT+01:00 David Lechner <[email protected]>:

Quoted 34 lines · Bartosz Golaszewski
Quoted 18 lines

I think I found the reason for the strange crashes we were experiencing (emac core->name being NULL) thanks to Sekhar who pointed me in the right direction.

The mdio driver fails to probe with v7 due to the supplied clock rate being wrong. Before failing we register the emac clock with pm_clk_add_clk(). When clock_ops puts the clock, it decreases the reference count of the clock, but we never actually increased it in the first place in the line above. The core clock code then destroys the associated clk_core structure. When the next user comes around (in our case the clk debug functions) the system crashes.

I believe there to be two issues: one is with v7 - we need to increase the clock reference count in davinci_psc_genpd_attach_dev().

Quoted 8 lines

Second is the error path in the clock framework - we should remove the destroyed clk_core from the debug list, which is not being done now.

Why we even need to track the refcount of clk_core is a mistery for me though. Stephen, Mike?

Best regards,
Bartosz Golaszewski

Great find. I figured it had to be something like this, but I wasn't able to reproduce the problem yet.

Quoted 9 lines
Quoted 1 line

I suppose it is time to spin up a v8 with some fixes.

I still don't know why the mdio clock rate is much lower than in mainline though. Any ideas?

Thanks,
Bart

Now that you have fixed the crash, can you answer the questions I have asked earlier?

Quoted 1 line

Can you post the output of this command so that I can see how your

clocks are setup:

cat /sys/kernel/debug/clk/clk_summary

Quoted 1 line

Using your workaround, can you run:

cat /sys/kernel/debug/pm_genpd/pm_genpd_summary

Quoted 7 lines

If you see:
1e27000.clock-controller: emac off-0

then genpd is not working like it is supposed to. You should see something like this for device that are working:

          1e27000.clock-controller: uart2  on
    /devices/platform/soc at 1c00000/1d0d000.serial        active

I used of_clk_get() in the genpd attach callback so the crash no longer happens, but I still can't boot it over NFS due to mdio failing. Do you have any idea why the clock rate differs between v7 and mainline?

Quoted 1 line

From the logs I can see that genpd domains are correctly registered,

and the provider is added (you should probably skip setting up the domains in legacy mode though), the pm clocks are enabled (after being disabled by mdio after its failed probe()) but the boot process gets stuck after the kernel gets an IP address over DHCP (which is strange because apparently it had some kind of network connection).

On Monday I'll prepare a small ramfs and boot over tftp only and see from there.

Best regards,
Bartosz

#18 lore raw

Re: [PATCH v7 10/42] clk: davinci: New driver for davinci PSC clocks

In reply to David Lechner

2018-03-01 17:44 GMT+01:00 David Lechner <[email protected]>:

Quoted 61 lines · Bartosz Golaszewski
Quoted 36 lines

2018-02-28 22:40 GMT+01:00 David Lechner <[email protected]>:

Quoted 34 lines · Bartosz Golaszewski
Quoted 18 lines

I think I found the reason for the strange crashes we were experiencing (emac core->name being NULL) thanks to Sekhar who pointed me in the right direction.

The mdio driver fails to probe with v7 due to the supplied clock rate being wrong. Before failing we register the emac clock with pm_clk_add_clk(). When clock_ops puts the clock, it decreases the reference count of the clock, but we never actually increased it in the first place in the line above. The core clock code then destroys the associated clk_core structure. When the next user comes around (in our case the clk debug functions) the system crashes.

I believe there to be two issues: one is with v7 - we need to increase the clock reference count in davinci_psc_genpd_attach_dev().

Quoted 8 lines

Second is the error path in the clock framework - we should remove the destroyed clk_core from the debug list, which is not being done now.

Why we even need to track the refcount of clk_core is a mistery for me though. Stephen, Mike?

Best regards,
Bartosz Golaszewski

Great find. I figured it had to be something like this, but I wasn't able to reproduce the problem yet.

Quoted 9 lines
Quoted 1 line

I suppose it is time to spin up a v8 with some fixes.

I still don't know why the mdio clock rate is much lower than in mainline though. Any ideas?

Thanks,
Bart

Now that you have fixed the crash, can you answer the questions I have asked earlier?

Quoted 1 line

Can you post the output of this command so that I can see how your

clocks are setup:

cat /sys/kernel/debug/clk/clk_summary

Quoted 1 line

Using your workaround, can you run:

cat /sys/kernel/debug/pm_genpd/pm_genpd_summary

Quoted 7 lines

If you see:
1e27000.clock-controller: emac off-0

then genpd is not working like it is supposed to. You should see something like this for device that are working:

          1e27000.clock-controller: uart2  on
    /devices/platform/soc at 1c00000/1d0d000.serial        active

Hi David, Sekhar,

I tried booting the board today over tftp but didn't succeed. I then switched to a normal boot from SD card and the boot process froze at the same moment (right after the DHCP config, or after rtc config if I disabled DHCP in bootargs). I then realized that the emac clock can't be the culprit. After some digging I found out that the late_initcall to clk_disable_unused() disables sysclk6 - the parent of the arm clock, which of course freezes the device.

If I remove the call to clk_disable_unused(), I can boot just fine.

The following other clocks are disabled before pll0_sysclk6:
pll1_sysclk3
pll0_obsclk
pll0_sysclk7

davinci_lpsc_clk_enable() is never called for these clocks - in fact it's not called for any parent that's not explicitly defined in psc-da850.c - I believe this may be one of the reasons. I will get back to debugging it tomorrow.

Best regards,
Bartosz Golaszewski

author maintainer
#19 lore raw

Re: [PATCH v7 10/42] clk: davinci: New driver for davinci PSC clocks

Quoted 87 lines · Bartosz Golaszewski

2018-03-01 17:44 GMT+01:00 David Lechner <[email protected]>:

Quoted 61 lines · Bartosz Golaszewski
Quoted 36 lines

2018-02-28 22:40 GMT+01:00 David Lechner <[email protected]>:

Quoted 34 lines · Bartosz Golaszewski
Quoted 18 lines

I think I found the reason for the strange crashes we were experiencing (emac core->name being NULL) thanks to Sekhar who pointed me in the right direction.

The mdio driver fails to probe with v7 due to the supplied clock rate being wrong. Before failing we register the emac clock with pm_clk_add_clk(). When clock_ops puts the clock, it decreases the reference count of the clock, but we never actually increased it in the first place in the line above. The core clock code then destroys the associated clk_core structure. When the next user comes around (in our case the clk debug functions) the system crashes.

I believe there to be two issues: one is with v7 - we need to increase the clock reference count in davinci_psc_genpd_attach_dev().

Quoted 8 lines

Second is the error path in the clock framework - we should remove the destroyed clk_core from the debug list, which is not being done now.

Why we even need to track the refcount of clk_core is a mistery for me though. Stephen, Mike?

Best regards,
Bartosz Golaszewski

Great find. I figured it had to be something like this, but I wasn't able to reproduce the problem yet.

Quoted 9 lines
Quoted 1 line

I suppose it is time to spin up a v8 with some fixes.

I still don't know why the mdio clock rate is much lower than in mainline though. Any ideas?

Thanks,
Bart

Now that you have fixed the crash, can you answer the questions I have asked earlier?

Quoted 1 line

Can you post the output of this command so that I can see how your

clocks are setup:

cat /sys/kernel/debug/clk/clk_summary

Quoted 1 line

Using your workaround, can you run:

cat /sys/kernel/debug/pm_genpd/pm_genpd_summary

Quoted 7 lines

If you see:

   1e27000.clock-controller: emac  off-0

then genpd is not working like it is supposed to. You should see something like this for device that are working:

           1e27000.clock-controller: uart2  on
     /devices/platform/soc@1c00000/1d0d000.serial        active

Hi David, Sekhar,

I tried booting the board today over tftp but didn't succeed. I then switched to a normal boot from SD card and the boot process froze at the same moment (right after the DHCP config, or after rtc config if I disabled DHCP in bootargs). I then realized that the emac clock can't be the culprit. After some digging I found out that the late_initcall to clk_disable_unused() disables sysclk6 - the parent of the arm clock, which of course freezes the device.

If I remove the call to clk_disable_unused(), I can boot just fine.

The following other clocks are disabled before pll0_sysclk6:
pll1_sysclk3
pll0_obsclk
pll0_sysclk7

Quoted 8 lines

davinci_lpsc_clk_enable() is never called for these clocks - in fact it's not called for any parent that's not explicitly defined in psc-da850.c - I believe this may be one of the reasons. I will get back to debugging it tomorrow.

Best regards,
Bartosz Golaszewski

Thanks for continuing to dig into this. I think I know what needs to be done now. I think I don't have the dependencies quite right where the PSC clocks are being registered before the PLL clocks, in which case they aren't getting the correct parent clock.

author maintainer
#20 lore raw

Re: [PATCH v7 10/42] clk: davinci: New driver for davinci PSC clocks

Quoted 93 lines · David Lechner
Quoted 92 lines · Bartosz Golaszewski

2018-03-01 17:44 GMT+01:00 David Lechner <[email protected]>:

Quoted 61 lines · Bartosz Golaszewski
Quoted 36 lines

2018-02-28 22:40 GMT+01:00 David Lechner <[email protected]>:

Quoted 34 lines · Bartosz Golaszewski
Quoted 18 lines

I think I found the reason for the strange crashes we were experiencing (emac core->name being NULL) thanks to Sekhar who pointed me in the right direction.

The mdio driver fails to probe with v7 due to the supplied clock rate being wrong. Before failing we register the emac clock with pm_clk_add_clk(). When clock_ops puts the clock, it decreases the reference count of the clock, but we never actually increased it in the first place in the line above. The core clock code then destroys the associated clk_core structure. When the next user comes around (in our case the clk debug functions) the system crashes.

I believe there to be two issues: one is with v7 - we need to increase the clock reference count in davinci_psc_genpd_attach_dev().

Quoted 8 lines

Second is the error path in the clock framework - we should remove the destroyed clk_core from the debug list, which is not being done now.

Why we even need to track the refcount of clk_core is a mistery for me though. Stephen, Mike?

Best regards,
Bartosz Golaszewski

Great find. I figured it had to be something like this, but I wasn't able to reproduce the problem yet.

Quoted 9 lines
Quoted 1 line

I suppose it is time to spin up a v8 with some fixes.

I still don't know why the mdio clock rate is much lower than in mainline though. Any ideas?

Thanks,
Bart

Now that you have fixed the crash, can you answer the questions I have asked earlier?

Quoted 1 line

Can you post the output of this command so that I can see how your

clocks are setup:

cat /sys/kernel/debug/clk/clk_summary

Quoted 1 line

Using your workaround, can you run:

cat /sys/kernel/debug/pm_genpd/pm_genpd_summary

Quoted 7 lines

If you see:
   1e27000.clock-controller: emac  off-0

then genpd is not working like it is supposed to. You should see something like this for device that are working:
           1e27000.clock-controller: uart2  on /devices/platform/soc@1c00000/1d0d000.serial        active

Hi David, Sekhar,

I tried booting the board today over tftp but didn't succeed. I then switched to a normal boot from SD card and the boot process froze at the same moment (right after the DHCP config, or after rtc config if I disabled DHCP in bootargs). I then realized that the emac clock can't be the culprit. After some digging I found out that the late_initcall to clk_disable_unused() disables sysclk6 - the parent of the arm clock, which of course freezes the device.

If I remove the call to clk_disable_unused(), I can boot just fine.

The following other clocks are disabled before pll0_sysclk6:
pll1_sysclk3
pll0_obsclk
pll0_sysclk7

davinci_lpsc_clk_enable() is never called for these clocks - in fact it's not called for any parent that's not explicitly defined in psc-da850.c - I believe this may be one of the reasons. I will get back to debugging it tomorrow.

Quoted 9 lines
Quoted 3 lines

Best regards,
Bartosz Golaszewski

Thanks for continuing to dig into this. I think I know what needs to be done now. I think I don't have the dependencies quite right where the PSC clocks are being registered before the PLL clocks, in which case they aren't getting the correct parent clock.

Bartosz,

One more thing to check: I think I had some typos in da850.dtsi where I wrote clock_names instead of clock-names. Please make sure this is fixed in your working branch.

maintainer
#21 lore raw

Re: [PATCH v7 10/42] clk: davinci: New driver for davinci PSC clocks

In reply to Bartosz Golaszewski

Quoting Bartosz Golaszewski (2018-02-28 04:38:38)

Quoted 11 lines

2018-02-19 21:21 GMT+01:00 David Lechner <[email protected]>:

I believe there to be two issues: one is with v7 - we need to increase the clock reference count in davinci_psc_genpd_attach_dev().

Second is the error path in the clock framework - we should remove the destroyed clk_core from the debug list, which is not being done now.

Why we even need to track the refcount of clk_core is a mistery for me though. Stephen, Mike?

Which part of the code are we talking about? I see that __clk_core_init() calls clk_debug_register() when ret == 0 and that looks fine. I do wonder why clk_debug_register() even returns a value though because we ignore it.

#22 lore raw

Re: [PATCH v7 10/42] clk: davinci: New driver for davinci PSC clocks

2018-03-16 18:55 GMT+01:00 Stephen Boyd <[email protected]>:

Quoted 9 lines

Quoting Bartosz Golaszewski (2018-02-28 04:38:38)

Quoted 8 lines

2018-02-19 21:21 GMT+01:00 David Lechner <[email protected]>:

I believe there to be two issues: one is with v7 - we need to increase the clock reference count in davinci_psc_genpd_attach_dev().

Second is the error path in the clock framework - we should remove the destroyed clk_core from the debug list, which is not being done now.

Quoted 8 lines
Quoted 3 lines

Why we even need to track the refcount of clk_core is a mistery for me though. Stephen, Mike?

Which part of the code are we talking about? I see that __clk_core_init() calls clk_debug_register() when ret == 0 and that looks fine. I do wonder why clk_debug_register() even returns a value though because we ignore it.

Hi Stephen,

invalid usage of clock pm ops was the culprit here. I just had not understood why we count references in the CCF - now I get it so nevermind this mail.

Thanks,
Bart

author maintainer
#23 lore raw

PATCH v7 11/42 clk: davinci: Add platform information for TI DA830 PSC

In reply to David Lechner

This adds platform-specific declarations for the PSC clocks on TI DA830/ OMAP-L137/AM17XX SoCs.

---

v7 changes:
- split registration function into two, one for each PSC
- add platform_device_id table

v6 changes:
- change how clkdev lookups are declared

 drivers/clk/davinci/Makefile    |  1 +
 drivers/clk/davinci/psc-da830.c | 89 +++++++++++++++++++++++++++++++++++++++++
 drivers/clk/davinci/psc.c       |  2 +
 drivers/clk/davinci/psc.h       |  4 ++
 4 files changed, 96 insertions(+)
 create mode 100644 drivers/clk/davinci/psc-da830.c
drivers/clk/davinci/Makefile +1 -0
index cd1bf2c..fb14c8c 100644
@@ -10,4 +10,5 @@ obj-$(CONFIG_ARCH_DAVINCI_DM644x)	+= pll-dm644x.o
 obj-$(CONFIG_ARCH_DAVINCI_DM646x)	+= pll-dm646x.o
 
 obj-y += psc.o
+obj-$(CONFIG_ARCH_DAVINCI_DA830)	+= psc-da830.o
 endif
drivers/clk/davinci/psc-da830.c new file +89 -0

89 lines not on this page · raw message

drivers/clk/davinci/psc.c +2 -0
index 8e08ac8..c4310af 100644
@@ -443,6 +443,8 @@ static const struct of_device_id davinci_psc_of_match[] = {
 };
 
 static const struct platform_device_id davinci_psc_id_table[] = {
+	{ .name = "da830-psc0", .driver_data = (kernel_ulong_t)da830_psc0_init },
+	{ .name = "da830-psc1", .driver_data = (kernel_ulong_t)da830_psc1_init },
 	{ }
 };
 
drivers/clk/davinci/psc.h +4 -0
index c342d54..c165cee 100644
@@ -86,4 +86,8 @@ int of_davinci_psc_clk_init(struct device *dev,
 			    u8 num_clks,
 			    void __iomem *base);
 
+/* Device-specific callbacks */
+int da830_psc0_init(struct device *dev, void __iomem *base);
+int da830_psc1_init(struct device *dev, void __iomem *base);
+
 #endif /* __CLK_DAVINCI_PSC_H__ */
Signature · 1 line
2.7.4
author maintainer
#24 lore raw

PATCH v7 12/42 clk: davinci: Add platform information for TI DA850 PSC

In reply to David Lechner

This adds platform-specific declarations for the PSC clocks on TI DA850/ OMAP-L138/AM18XX SoCs.

---

v7 changes:
- split registration function into two, one for each PSC
- add platform_device_id table
- add additional clkdev lookups for clock platform devices
- add LPSC_SET_RATE_PARENT flag to LCDC clock
- fix davinci_nand device name

v6 changes:
- change how clkdev lookups are declared

 drivers/clk/davinci/Makefile    |   1 +
 drivers/clk/davinci/psc-da850.c | 109 ++++++++++++++++++++++++++++++++++++++++
 drivers/clk/davinci/psc.c       |   4 ++
 drivers/clk/davinci/psc.h       |   4 ++
 4 files changed, 118 insertions(+)
 create mode 100644 drivers/clk/davinci/psc-da850.c
drivers/clk/davinci/Makefile +1 -0
index fb14c8c..aef0390 100644
@@ -11,4 +11,5 @@ obj-$(CONFIG_ARCH_DAVINCI_DM646x)	+= pll-dm646x.o
 
 obj-y += psc.o
 obj-$(CONFIG_ARCH_DAVINCI_DA830)	+= psc-da830.o
+obj-$(CONFIG_ARCH_DAVINCI_DA850)	+= psc-da850.o
 endif
drivers/clk/davinci/psc-da850.c new file +109 -0

109 lines not on this page · raw message

drivers/clk/davinci/psc.c +4 -0
index c4310af..0f53ec2 100644
@@ -439,12 +439,16 @@ int of_davinci_psc_clk_init(struct device *dev,
 }
 
 static const struct of_device_id davinci_psc_of_match[] = {
+	{ .compatible = "ti,da850-psc0", .data = of_da850_psc0_init },
+	{ .compatible = "ti,da850-psc1", .data = of_da850_psc1_init },
 	{ }
 };
 
 static const struct platform_device_id davinci_psc_id_table[] = {
 	{ .name = "da830-psc0", .driver_data = (kernel_ulong_t)da830_psc0_init },
 	{ .name = "da830-psc1", .driver_data = (kernel_ulong_t)da830_psc1_init },
+	{ .name = "da850-psc0", .driver_data = (kernel_ulong_t)da850_psc0_init },
+	{ .name = "da850-psc1", .driver_data = (kernel_ulong_t)da850_psc1_init },
 	{ }
 };
 
drivers/clk/davinci/psc.h +4 -0
index c165cee..b50b2ea 100644
@@ -89,5 +89,9 @@ int of_davinci_psc_clk_init(struct device *dev,
 /* Device-specific callbacks */
 int da830_psc0_init(struct device *dev, void __iomem *base);
 int da830_psc1_init(struct device *dev, void __iomem *base);
+int da850_psc0_init(struct device *dev, void __iomem *base);
+int da850_psc1_init(struct device *dev, void __iomem *base);
+int of_da850_psc0_init(struct device *dev, void __iomem *base);
+int of_da850_psc1_init(struct device *dev, void __iomem *base);
 
 #endif /* __CLK_DAVINCI_PSC_H__ */
Signature · 1 line
2.7.4
author maintainer
#25 lore raw

PATCH v7 13/42 clk: davinci: Add platform information for TI DM355 PSC

In reply to David Lechner

This adds platform-specific declarations for the PSC clocks on TI DM355 based systems.

---

v7 changes:
- split registration function into two, one for each PSC
- add platform_device_id table
- don't wrap lines for readability
- add LPSC_ALWAYS_ENABLED flag to timer0 clock

v6 changes:
- change how clkdev lookups are declared

 drivers/clk/davinci/Makefile    |  1 +
 drivers/clk/davinci/psc-dm355.c | 72 +++++++++++++++++++++++++++++++++++++++++
 drivers/clk/davinci/psc.c       |  1 +
 drivers/clk/davinci/psc.h       |  1 +
 4 files changed, 75 insertions(+)
 create mode 100644 drivers/clk/davinci/psc-dm355.c
drivers/clk/davinci/Makefile +1 -0
index aef0390..e0da5c3 100644
@@ -12,4 +12,5 @@ obj-$(CONFIG_ARCH_DAVINCI_DM646x)	+= pll-dm646x.o
 obj-y += psc.o
 obj-$(CONFIG_ARCH_DAVINCI_DA830)	+= psc-da830.o
 obj-$(CONFIG_ARCH_DAVINCI_DA850)	+= psc-da850.o
+obj-$(CONFIG_ARCH_DAVINCI_DM355)	+= psc-dm355.o
 endif
drivers/clk/davinci/psc-dm355.c new file +72 -0

72 lines not on this page · raw message

drivers/clk/davinci/psc.c +1 -0
index 0f53ec2..a2a46a2 100644
@@ -449,6 +449,7 @@ static const struct platform_device_id davinci_psc_id_table[] = {
 	{ .name = "da830-psc1", .driver_data = (kernel_ulong_t)da830_psc1_init },
 	{ .name = "da850-psc0", .driver_data = (kernel_ulong_t)da850_psc0_init },
 	{ .name = "da850-psc1", .driver_data = (kernel_ulong_t)da850_psc1_init },
+	{ .name = "dm355-psc",  .driver_data = (kernel_ulong_t)dm355_psc_init  },
 	{ }
 };
 
drivers/clk/davinci/psc.h +1 -0
index b50b2ea..ade6e01 100644
@@ -93,5 +93,6 @@ int da850_psc0_init(struct device *dev, void __iomem *base);
 int da850_psc1_init(struct device *dev, void __iomem *base);
 int of_da850_psc0_init(struct device *dev, void __iomem *base);
 int of_da850_psc1_init(struct device *dev, void __iomem *base);
+int dm355_psc_init(struct device *dev, void __iomem *base);
 
 #endif /* __CLK_DAVINCI_PSC_H__ */
Signature · 1 line
2.7.4
author maintainer
#26 lore raw

PATCH v7 14/42 clk: davinci: Add platform information for TI DM365 PSC

In reply to David Lechner

This adds platform-specific declarations for the PSC clocks on TI DM365 based systems.

---

v7 changes:
- split registration function into two, one for each PSC
- add platform_device_id table
- don't wrap lines for readability
- add LPSC_ALWAYS_ENABLED flag to timer0 clock

v6 changes:
- change how clkdev lookups are declared

 drivers/clk/davinci/Makefile    |  1 +
 drivers/clk/davinci/psc-dm365.c | 77 +++++++++++++++++++++++++++++++++++++++++
 drivers/clk/davinci/psc.c       |  1 +
 drivers/clk/davinci/psc.h       |  1 +
 4 files changed, 80 insertions(+)
 create mode 100644 drivers/clk/davinci/psc-dm365.c
drivers/clk/davinci/Makefile +1 -0
index e0da5c3..78dc1eb 100644
@@ -13,4 +13,5 @@ obj-y += psc.o
 obj-$(CONFIG_ARCH_DAVINCI_DA830)	+= psc-da830.o
 obj-$(CONFIG_ARCH_DAVINCI_DA850)	+= psc-da850.o
 obj-$(CONFIG_ARCH_DAVINCI_DM355)	+= psc-dm355.o
+obj-$(CONFIG_ARCH_DAVINCI_DM365)	+= psc-dm365.o
 endif
drivers/clk/davinci/psc-dm365.c new file +77 -0

77 lines not on this page · raw message

drivers/clk/davinci/psc.c +1 -0
index a2a46a2..5f5fc10 100644
@@ -450,6 +450,7 @@ static const struct platform_device_id davinci_psc_id_table[] = {
 	{ .name = "da850-psc0", .driver_data = (kernel_ulong_t)da850_psc0_init },
 	{ .name = "da850-psc1", .driver_data = (kernel_ulong_t)da850_psc1_init },
 	{ .name = "dm355-psc",  .driver_data = (kernel_ulong_t)dm355_psc_init  },
+	{ .name = "dm365-psc",  .driver_data = (kernel_ulong_t)dm365_psc_init  },
 	{ }
 };
 
drivers/clk/davinci/psc.h +1 -0
index ade6e01..14caccf 100644
@@ -94,5 +94,6 @@ int da850_psc1_init(struct device *dev, void __iomem *base);
 int of_da850_psc0_init(struct device *dev, void __iomem *base);
 int of_da850_psc1_init(struct device *dev, void __iomem *base);
 int dm355_psc_init(struct device *dev, void __iomem *base);
+int dm365_psc_init(struct device *dev, void __iomem *base);
 
 #endif /* __CLK_DAVINCI_PSC_H__ */
Signature · 1 line
2.7.4
author maintainer
#27 lore raw

PATCH v7 15/42 clk: davinci: Add platform information for TI DM644x PSC

In reply to David Lechner

This adds platform-specific declarations for the PSC clocks on TI DM644x based systems.

---

v7 changes:
- add platform_device_id table
- don't wrap lines for readability
- add LPSC_ALWAYS_ENABLED flag to timer0 clock

v6 changes:
- change how clkdev lookups are declared

 drivers/clk/davinci/Makefile     |  1 +
 drivers/clk/davinci/psc-dm644x.c | 67 ++++++++++++++++++++++++++++++++++++++++
 drivers/clk/davinci/psc.c        |  1 +
 drivers/clk/davinci/psc.h        |  1 +
 4 files changed, 70 insertions(+)
 create mode 100644 drivers/clk/davinci/psc-dm644x.c
drivers/clk/davinci/Makefile +1 -0
index 78dc1eb..a20e379 100644
@@ -14,4 +14,5 @@ obj-$(CONFIG_ARCH_DAVINCI_DA830)	+= psc-da830.o
 obj-$(CONFIG_ARCH_DAVINCI_DA850)	+= psc-da850.o
 obj-$(CONFIG_ARCH_DAVINCI_DM355)	+= psc-dm355.o
 obj-$(CONFIG_ARCH_DAVINCI_DM365)	+= psc-dm365.o
+obj-$(CONFIG_ARCH_DAVINCI_DM644x)	+= psc-dm644x.o
 endif
drivers/clk/davinci/psc-dm644x.c new file +67 -0

67 lines not on this page · raw message

drivers/clk/davinci/psc.c +1 -0
index 5f5fc10..29422d6 100644
@@ -451,6 +451,7 @@ static const struct platform_device_id davinci_psc_id_table[] = {
 	{ .name = "da850-psc1", .driver_data = (kernel_ulong_t)da850_psc1_init },
 	{ .name = "dm355-psc",  .driver_data = (kernel_ulong_t)dm355_psc_init  },
 	{ .name = "dm365-psc",  .driver_data = (kernel_ulong_t)dm365_psc_init  },
+	{ .name = "dm644x-psc", .driver_data = (kernel_ulong_t)dm644x_psc_init },
 	{ }
 };
 
drivers/clk/davinci/psc.h +1 -0
index 14caccf..41266af5b 100644
@@ -95,5 +95,6 @@ int of_da850_psc0_init(struct device *dev, void __iomem *base);
 int of_da850_psc1_init(struct device *dev, void __iomem *base);
 int dm355_psc_init(struct device *dev, void __iomem *base);
 int dm365_psc_init(struct device *dev, void __iomem *base);
+int dm644x_psc_init(struct device *dev, void __iomem *base);
 
 #endif /* __CLK_DAVINCI_PSC_H__ */
Signature · 1 line
2.7.4
author maintainer
#28 lore raw

PATCH v7 16/42 clk: davinci: Add platform information for TI DM646x PSC

In reply to David Lechner

This adds platform-specific declarations for the PSC clocks on TI DM646x based systems.

---

v7 changes:
- add platform_device_id table
- don't wrap lines for readability
- add LPSC_ALWAYS_ENABLED flag to timer0 clock

v6 changes:
- change how clkdev lookups are declared

 drivers/clk/davinci/Makefile     |  1 +
 drivers/clk/davinci/psc-dm646x.c | 62 ++++++++++++++++++++++++++++++++++++++++
 drivers/clk/davinci/psc.c        |  1 +
 drivers/clk/davinci/psc.h        |  1 +
 4 files changed, 65 insertions(+)
 create mode 100644 drivers/clk/davinci/psc-dm646x.c
drivers/clk/davinci/Makefile +1 -0
index a20e379..6c388d4 100644
@@ -15,4 +15,5 @@ obj-$(CONFIG_ARCH_DAVINCI_DA850)	+= psc-da850.o
 obj-$(CONFIG_ARCH_DAVINCI_DM355)	+= psc-dm355.o
 obj-$(CONFIG_ARCH_DAVINCI_DM365)	+= psc-dm365.o
 obj-$(CONFIG_ARCH_DAVINCI_DM644x)	+= psc-dm644x.o
+obj-$(CONFIG_ARCH_DAVINCI_DM646x)	+= psc-dm646x.o
 endif
drivers/clk/davinci/psc-dm646x.c new file +62 -0

62 lines not on this page · raw message

drivers/clk/davinci/psc.c +1 -0
index 29422d6..553804d 100644
@@ -452,6 +452,7 @@ static const struct platform_device_id davinci_psc_id_table[] = {
 	{ .name = "dm355-psc",  .driver_data = (kernel_ulong_t)dm355_psc_init  },
 	{ .name = "dm365-psc",  .driver_data = (kernel_ulong_t)dm365_psc_init  },
 	{ .name = "dm644x-psc", .driver_data = (kernel_ulong_t)dm644x_psc_init },
+	{ .name = "dm646x-psc", .driver_data = (kernel_ulong_t)dm646x_psc_init },
 	{ }
 };
 
drivers/clk/davinci/psc.h +1 -0
index 41266af5b..1c03869 100644
@@ -96,5 +96,6 @@ int of_da850_psc1_init(struct device *dev, void __iomem *base);
 int dm355_psc_init(struct device *dev, void __iomem *base);
 int dm365_psc_init(struct device *dev, void __iomem *base);
 int dm644x_psc_init(struct device *dev, void __iomem *base);
+int dm646x_psc_init(struct device *dev, void __iomem *base);
 
 #endif /* __CLK_DAVINCI_PSC_H__ */
Signature · 1 line
2.7.4
author maintainer
#29 lore raw

PATCH v7 17/42 dt-bindings: clock: Add bindings for DA8XX CFGCHIP clocks

In reply to David Lechner

This adds a new binding for the clocks present in the CFGCHIP syscon registers in TI DA8XX SoCs.

---

v7 changes:
- none

v6 changes:
- combine "dt-bindings: clock: Add bindings for DA8XX CFGCHIP gate clocks", "dt-bindings: clock: Add binding for TI DA8XX CFGCHIP mux clocks" and "dt-bindings: clock: Add bindings for TI DA8XX USB PHY clocks" into a single file containing all CFGCHIP clocks bindings
- added compatible = "ti,da830-div4p5ena"
- added compatible = "ti,da850-async1-clksrc"
- renamed other compatible strings
- changed and added some clk-names strings
- USB PHY clocks are combined into a single node with #clock-cells = <1>

 .../bindings/clock/ti/davinci/da8xx-cfgchip.txt    | 93 ++++++++++++++++++++++
 1 file changed, 93 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/clock/ti/davinci/da8xx-cfgchip.txt
Documentation/devicetree/bindings/clock/ti/davinci/da8xx-cfgchip.txt new file +93 -0
new file mode 100644
index 0000000..1e03dce
@@ -0,0 +1,93 @@
+Binding for TI DA8XX/OMAP-L13X/AM17XX/AM18XX CFGCHIP clocks
+
+TI DA8XX/OMAP-L13X/AM17XX/AM18XX SoCs contain a general purpose set of
+registers call CFGCHIPn. Some of these registers function as clock
+gates. This document describes the bindings for those clocks.
+
+All of the clock nodes described below must be child nodes of a CFGCHIP node
+(compatible = "ti,da830-cfgchip").
+
+USB PHY clocks
+--------------
+Required properties:
+- compatible: shall be "ti,da830-usb-phy-clocks".
+- #clock-cells: from common clock binding; shall be set to 1.
+- clocks: phandles to the parent clocks corresponding to clock-names
+- clock-names: shall be "fck", "usb_refclkin", "auxclk"
+
+This node provides two clocks. The clock at index 0 is the USB 2.0 PHY 48MHz
+clock and the clock at index 1 is the USB 1.1 PHY 48MHz clock.
+
+eHRPWM Time Base Clock (TBCLK)
+------------------------------
+Required properties:
+- compatible: shall be "ti,da830-tbclksync".
+- #clock-cells: from common clock binding; shall be set to 0.
+- clocks: phandle to the parent clock
+- clock-names: shall be "fck"
+
+PLL DIV4.5 divider
+------------------
+Required properties:
+- compatible: shall be "ti,da830-div4p5ena".
+- #clock-cells: from common clock binding; shall be set to 0.
+- clocks: phandle to the parent clock
+- clock-names: shall be "pll0_pllout"
+
+EMIFA clock source (ASYNC1)
+---------------------------
+Required properties:
+- compatible: shall be "ti,da850-async1-clksrc".
+- #clock-cells: from common clock binding; shall be set to 0.
+- clocks: phandles to the parent clocks corresponding to clock-names
+- clock-names: shall be "pll0_sysclk3", "div4.5"
+
+ASYNC3 clock source
+-------------------
+Required properties:
+- compatible: shall be "ti,da850-async3-clksrc".
+- #clock-cells: from common clock binding; shall be set to 0.
+- clocks: phandles to the parent clocks corresponding to clock-names
+- clock-names: shall be "pll0_sysclk2", "pll1_sysclk2"
+
+Examples:
+
+	cfgchip: syscon at 1417c {
+		compatible = "ti,da830-cfgchip", "syscon", "simple-mfd";
+		reg = <0x1417c 0x14>;
+
+		usb_phy_clk: usb-phy-clocks {
+			compatible = "ti,da830-usb-phy-clocks";
+			#clock-cells = <1>;
+			clocks = <&psc1 1>, <&usb_refclkin>, <&pll0_auxclk>;
+			clock-names = "fck", "usb_refclkin", "auxclk";
+		};
+		ehrpwm_tbclk: ehrpwm_tbclk {
+			compatible = "ti,da830-tbclksync";
+			#clock-cells = <0>;
+			clocks = <&psc1 17>;
+			clock-names = "fck";
+		};
+		div4p5_clk: div4.5 {
+			compatible = "ti,da830-div4p5ena";
+			#clock-cells = <0>;
+			clocks = <&pll0_pllout>;
+			clock-names = "pll0_pllout";
+		};
+		async1_clk: async1 {
+			compatible = "ti,da850-async1-clksrc";
+			#clock-cells = <0>;
+			clocks = <&pll0_sysclk 3>, <&div4p5_clk>;
+			clock-names = "pll0_sysclk3", "div4.5";
+		};
+		async3_clk: async3 {
+			compatible = "ti,da850-async3-clksrc";
+			#clock-cells = <0>;
+			clocks = <&pll0_sysclk 2>, <&pll1_sysclk 2>;
+			clock-names = "pll0_sysclk2", "pll1_sysclk2";
+		};
+	};
+
+Also see:
+- Documentation/devicetree/bindings/clock/clock-bindings.txt
+
Signature · 1 line
2.7.4
author maintainer
#30 lore raw

PATCH v7 18/42 clk: davinci: New driver for TI DA8XX CFGCHIP clocks

In reply to David Lechner

This adds a new driver for the gate and multiplexer clocks in the CFGCHIPn syscon registers on TI DA8XX-type SoCs.

---

v7 changes:
- convert to platform device

v6 changes:
- added DIV4.5 and ASYNC1 clocks
- refactored code to be more generic
- added functions for registering clocks from board files (no longer device tree only)
- use pr_fmt macro

 drivers/clk/davinci/Makefile                    |   2 +
 drivers/clk/davinci/da8xx-cfgchip.c             | 435 ++++++++++++++++++++++++
 include/linux/platform_data/clk-da8xx-cfgchip.h |  21 ++
 3 files changed, 458 insertions(+)
 create mode 100644 drivers/clk/davinci/da8xx-cfgchip.c
 create mode 100644 include/linux/platform_data/clk-da8xx-cfgchip.h
drivers/clk/davinci/Makefile +2 -0
index 6c388d4..11178b7 100644
@@ -1,6 +1,8 @@
 # SPDX-License-Identifier: GPL-2.0
 
 ifeq ($(CONFIG_COMMON_CLK), y)
+obj-$(CONFIG_ARCH_DAVINCI_DA8XX)	+= da8xx-cfgchip.o
+
 obj-y += pll.o
 obj-$(CONFIG_ARCH_DAVINCI_DA830)	+= pll-da830.o
 obj-$(CONFIG_ARCH_DAVINCI_DA850)	+= pll-da850.o
drivers/clk/davinci/da8xx-cfgchip.c new file +435 -0

435 lines not on this page · raw message

include/linux/platform_data/clk-da8xx-cfgchip.h new file +21 -0
new file mode 100644
index 0000000..de0f77d
@@ -0,0 +1,21 @@
+// SPDX-License-Identifier: GPL-2.0
+/*
+ * clk-da8xx-cfgchip - TI DaVinci DA8xx CFGCHIP clock driver
+ *
+ * Copyright (C) 2018 David Lechner <[email protected]>
+ */
+
+#ifndef __LINUX_PLATFORM_DATA_CLK_DA8XX_CFGCHIP_H__
+#define __LINUX_PLATFORM_DATA_CLK_DA8XX_CFGCHIP_H__
+
+#include <linux/regmap.h>
+
+/**
+ * da8xx_cfgchip_clk_platform_data
+ * @cfgchip: CFGCHIP syscon regmap
+ */
+struct da8xx_cfgchip_clk_platform_data {
+	struct regmap *cfgchip;
+};
+
+#endif /* __LINUX_PLATFORM_DATA_CLK_DA8XX_CFGCHIP_H__ */
Signature · 1 line
2.7.4
author maintainer
#31 lore raw

PATCH v7 19/42 clk: davinci: cfgchip: Add TI DA8XX USB PHY clocks

In reply to David Lechner

This adds a new driver for the USB PHY clocks in the CFGCHIP2 syscon register on TI DA8XX-type SoCs.

The USB0 (USB 2.0) PHY clock is an interesting case because it calls clk_enable() in a reentrant way. The USB 2.0 PSC only has to be enabled temporarily while we are locking the PLL, which takes place during the clk_enable() callback.

---

v7 changes:
- convert to platform device
- rename clk local variable to usb0/usb1
- put code in da8xx-cfgchip.c instead of creating a new file

v6 changes:
- rename clocks to usb{0,1}_clk48
- rename USB 2.0 PSC clock to "fck"
- simplify {s,g}et_parent implementations
- use pr_fmt macro

 drivers/clk/davinci/da8xx-cfgchip.c | 351 ++++++++++++++++++++++++++++++++++++
 1 file changed, 351 insertions(+)
drivers/clk/davinci/da8xx-cfgchip.c +351 -0
index 386da99..7d5cf16 100644
@@ -339,6 +339,349 @@ static int __init of_da850_async3_init(struct device *dev, struct regmap *regmap
 	return of_da8xx_cfgchip_init_mux_clock(dev, &da850_async3_info, regmap);
 }
 
+/* --- USB 2.0 PHY clock --- */
+
+struct da8xx_usb0_clk48 {
+	struct clk_hw hw;
+	struct clk *fck;
+	struct regmap *regmap;
+};
+
+#define to_da8xx_usb0_clk48(_hw) \
+	container_of((_hw), struct da8xx_usb0_clk48, hw)
+
+static int da8xx_usb0_clk48_prepare(struct clk_hw *hw)
+{
+	struct da8xx_usb0_clk48 *usb0 = to_da8xx_usb0_clk48(hw);
+
+	/* The USB 2.0 PSC clock is only needed temporarily during the USB 2.0
+	 * PHY clock enable, but since clk_prepare() can't be called in an
+	 * atomic context (i.e. in clk_enable()), we have to prepare it here.
+	 */
+	return clk_prepare(usb0->fck);
+}
+
+static void da8xx_usb0_clk48_unprepare(struct clk_hw *hw)
+{
+	struct da8xx_usb0_clk48 *usb0 = to_da8xx_usb0_clk48(hw);
+
+	clk_unprepare(usb0->fck);
+}
+
+static int da8xx_usb0_clk48_enable(struct clk_hw *hw)
+{
+	struct da8xx_usb0_clk48 *usb0 = to_da8xx_usb0_clk48(hw);
+	unsigned int mask, val;
+	int ret;
+
+	/* Locking the USB 2.O PLL requires that the USB 2.O PSC is enabled
+	 * temporaily. It can be turned back off once the PLL is locked.
+	 */
+	clk_enable(usb0->fck);
+
+	/* Turn on the USB 2.0 PHY, but just the PLL, and not OTG. The USB 1.1
+	 * PHY may use the USB 2.0 PLL clock without USB 2.0 OTG being used.
+	 */
+	mask = CFGCHIP2_RESET | CFGCHIP2_PHYPWRDN | CFGCHIP2_PHY_PLLON;
+	val = CFGCHIP2_PHY_PLLON;
+
+	regmap_write_bits(usb0->regmap, CFGCHIP(2), mask, val);
+	ret = regmap_read_poll_timeout(usb0->regmap, CFGCHIP(2), val,
+				       val & CFGCHIP2_PHYCLKGD, 0, 500000);
+
+	clk_disable(usb0->fck);
+
+	return ret;
+}
+
+static void da8xx_usb0_clk48_disable(struct clk_hw *hw)
+{
+	struct da8xx_usb0_clk48 *usb0 = to_da8xx_usb0_clk48(hw);
+	unsigned int val;
+
+	val = CFGCHIP2_PHYPWRDN;
+	regmap_write_bits(usb0->regmap, CFGCHIP(2), val, val);
+}
+
+static int da8xx_usb0_clk48_is_enabled(struct clk_hw *hw)
+{
+	struct da8xx_usb0_clk48 *usb0 = to_da8xx_usb0_clk48(hw);
+	unsigned int val;
+
+	regmap_read(usb0->regmap, CFGCHIP(2), &val);
+
+	return !!(val & CFGCHIP2_PHYCLKGD);
+}
+
+static unsigned long da8xx_usb0_clk48_recalc_rate(struct clk_hw *hw,
+						  unsigned long parent_rate)
+{
+	struct da8xx_usb0_clk48 *usb0 = to_da8xx_usb0_clk48(hw);
+	unsigned int mask, val;
+
+	/* The parent clock rate must be one of the following */
+	mask = CFGCHIP2_REFFREQ_MASK;
+	switch (parent_rate) {
+	case 12000000:
+		val = CFGCHIP2_REFFREQ_12MHZ;
+		break;
+	case 13000000:
+		val = CFGCHIP2_REFFREQ_13MHZ;
+		break;
+	case 19200000:
+		val = CFGCHIP2_REFFREQ_19_2MHZ;
+		break;
+	case 20000000:
+		val = CFGCHIP2_REFFREQ_20MHZ;
+		break;
+	case 24000000:
+		val = CFGCHIP2_REFFREQ_24MHZ;
+		break;
+	case 26000000:
+		val = CFGCHIP2_REFFREQ_26MHZ;
+		break;
+	case 38400000:
+		val = CFGCHIP2_REFFREQ_38_4MHZ;
+		break;
+	case 40000000:
+		val = CFGCHIP2_REFFREQ_40MHZ;
+		break;
+	case 48000000:
+		val = CFGCHIP2_REFFREQ_48MHZ;
+		break;
+	default:
+		return 0;
+	}
+
+	regmap_write_bits(usb0->regmap, CFGCHIP(2), mask, val);
+
+	/* USB 2.0 PLL always supplies 48MHz */
+	return 48000000;
+}
+
+static long da8xx_usb0_clk48_round_rate(struct clk_hw *hw, unsigned long rate,
+					unsigned long *parent_rate)
+{
+	return 48000000;
+}
+
+static int da8xx_usb0_clk48_set_parent(struct clk_hw *hw, u8 index)
+{
+	struct da8xx_usb0_clk48 *usb0 = to_da8xx_usb0_clk48(hw);
+
+	return regmap_write_bits(usb0->regmap, CFGCHIP(2),
+				 CFGCHIP2_USB2PHYCLKMUX,
+				 index ? CFGCHIP2_USB2PHYCLKMUX : 0);
+}
+
+static u8 da8xx_usb0_clk48_get_parent(struct clk_hw *hw)
+{
+	struct da8xx_usb0_clk48 *usb0 = to_da8xx_usb0_clk48(hw);
+	unsigned int val;
+
+	regmap_read(usb0->regmap, CFGCHIP(2), &val);
+
+	return (val & CFGCHIP2_USB2PHYCLKMUX) ? 1 : 0;
+}
+
+static const struct clk_ops da8xx_usb0_clk48_ops = {
+	.prepare	= da8xx_usb0_clk48_prepare,
+	.unprepare	= da8xx_usb0_clk48_unprepare,
+	.enable		= da8xx_usb0_clk48_enable,
+	.disable	= da8xx_usb0_clk48_disable,
+	.is_enabled	= da8xx_usb0_clk48_is_enabled,
+	.recalc_rate	= da8xx_usb0_clk48_recalc_rate,
+	.round_rate	= da8xx_usb0_clk48_round_rate,
+	.set_parent	= da8xx_usb0_clk48_set_parent,
+	.get_parent	= da8xx_usb0_clk48_get_parent,
+};
+
+static struct da8xx_usb0_clk48 *
+da8xx_cfgchip_register_usb0_clk48(struct device *dev,
+				  struct regmap *regmap)
+{
+	const char * const parent_names[] = { "usb_refclkin", "pll0_auxclk" };
+	struct clk *fck_clk;
+	struct da8xx_usb0_clk48 *usb0;
+	struct clk_init_data init;
+	int ret;
+
+	fck_clk = devm_clk_get(dev, "fck");
+	if (IS_ERR(fck_clk)) {
+		if (PTR_ERR(fck_clk) != -EPROBE_DEFER)
+			dev_err(dev, "Missing fck clock\n");
+		return ERR_CAST(fck_clk);
+	}
+
+	usb0 = devm_kzalloc(dev, sizeof(*usb0), GFP_KERNEL);
+	if (!usb0)
+		return ERR_PTR(-ENOMEM);
+
+	init.name = "usb0_clk48";
+	init.ops = &da8xx_usb0_clk48_ops;
+	init.parent_names = parent_names;
+	init.num_parents = 2;
+
+	usb0->hw.init = &init;
+	usb0->fck = fck_clk;
+	usb0->regmap = regmap;
+
+	ret = devm_clk_hw_register(dev, &usb0->hw);
+	if (ret < 0)
+		return ERR_PTR(ret);
+
+	return usb0;
+}
+
+/* --- USB 1.1 PHY clock --- */
+
+struct da8xx_usb1_clk48 {
+	struct clk_hw hw;
+	struct regmap *regmap;
+};
+
+#define to_da8xx_usb1_clk48(_hw) \
+	container_of((_hw), struct da8xx_usb1_clk48, hw)
+
+static int da8xx_usb1_clk48_set_parent(struct clk_hw *hw, u8 index)
+{
+	struct da8xx_usb1_clk48 *usb1 = to_da8xx_usb1_clk48(hw);
+
+	return regmap_write_bits(usb1->regmap, CFGCHIP(2),
+				 CFGCHIP2_USB1PHYCLKMUX,
+				 index ? CFGCHIP2_USB1PHYCLKMUX : 0);
+}
+
+static u8 da8xx_usb1_clk48_get_parent(struct clk_hw *hw)
+{
+	struct da8xx_usb1_clk48 *usb1 = to_da8xx_usb1_clk48(hw);
+	unsigned int val;
+
+	regmap_read(usb1->regmap, CFGCHIP(2), &val);
+
+	return (val & CFGCHIP2_USB1PHYCLKMUX) ? 1 : 0;
+}
+
+static const struct clk_ops da8xx_usb1_clk48_ops = {
+	.set_parent	= da8xx_usb1_clk48_set_parent,
+	.get_parent	= da8xx_usb1_clk48_get_parent,
+};
+
+/**
+ * da8xx_cfgchip_register_usb1_clk48 - Register a new USB 1.1 PHY clock
+ * @regmap: The CFGCHIP regmap
+ */
+static struct da8xx_usb1_clk48 *
+da8xx_cfgchip_register_usb1_clk48(struct device *dev,
+				  struct regmap *regmap)
+{
+	const char * const parent_names[] = { "usb0_clk48", "usb_refclkin" };
+	struct da8xx_usb1_clk48 *usb1;
+	struct clk_init_data init;
+	int ret;
+
+	usb1 = devm_kzalloc(dev, sizeof(*usb1), GFP_KERNEL);
+	if (!usb1)
+		return ERR_PTR(-ENOMEM);
+
+	init.name = "usb1_clk48";
+	init.ops = &da8xx_usb1_clk48_ops;
+	init.parent_names = parent_names;
+	init.num_parents = 2;
+
+	usb1->hw.init = &init;
+	usb1->regmap = regmap;
+
+	ret = devm_clk_hw_register(dev, &usb1->hw);
+	if (ret < 0)
+		return ERR_PTR(ret);
+
+	return usb1;
+}
+
+static int da8xx_cfgchip_register_usb_phy_clk(struct device *dev,
+					      struct regmap *regmap)
+{
+	struct da8xx_usb0_clk48 *usb0;
+	struct da8xx_usb1_clk48 *usb1;
+	struct clk_hw *parent;
+
+	usb0 = da8xx_cfgchip_register_usb0_clk48(dev, regmap);
+	if (IS_ERR(usb0))
+		return PTR_ERR(usb0);
+
+	/*
+	 * All existing boards use pll0_auxclk as the parent and new boards
+	 * should use device tree, so hard-coding the value (1) here.
+	 */
+	parent = clk_hw_get_parent_by_index(&usb0->hw, 1);
+	if (parent)
+		clk_set_parent(usb0->hw.clk, parent->clk);
+	else
+		dev_warn(dev, "Failed to find usb0 parent clock\n");
+
+	usb1 = da8xx_cfgchip_register_usb1_clk48(dev, regmap);
+	if (IS_ERR(usb1))
+		return PTR_ERR(usb1);
+
+	/*
+	 * All existing boards use usb0_clk48 as the parent and new boards
+	 * should use device tree, so hard-coding the value (0) here.
+	 */
+	parent = clk_hw_get_parent_by_index(&usb1->hw, 0);
+	if (parent)
+		clk_set_parent(usb1->hw.clk, parent->clk);
+	else
+		dev_warn(dev, "Failed to find usb1 parent clock\n");
+
+	clk_hw_register_clkdev(&usb0->hw, "usb0_clk48", "da8xx-usb-phy");
+	clk_hw_register_clkdev(&usb1->hw, "usb1_clk48", "da8xx-usb-phy");
+
+	return 0;
+}
+
+static int of_da8xx_usb_phy_clk_init(struct device *dev, struct regmap *regmap)
+{
+	struct clk_hw_onecell_data *clk_data;
+	struct da8xx_usb0_clk48 *usb0;
+	struct da8xx_usb1_clk48 *usb1;
+
+	clk_data = devm_kzalloc(dev, sizeof(*clk_data) + 2 *
+				sizeof(*clk_data->hws), GFP_KERNEL);
+	if (!clk_data)
+		return -ENOMEM;
+
+	clk_data->num = 2;
+
+	usb0 = da8xx_cfgchip_register_usb0_clk48(dev, regmap);
+	if (IS_ERR(usb0)) {
+		if (PTR_ERR(usb0) == -EPROBE_DEFER)
+			return -EPROBE_DEFER;
+
+		dev_warn(dev, "Failed to register usb0_clk48 (%ld)\n",
+			 PTR_ERR(usb0));
+
+		clk_data->hws[0] = ERR_PTR(-ENOENT);
+	} else {
+		clk_data->hws[0] = &usb0->hw;
+	}
+
+	usb1 = da8xx_cfgchip_register_usb1_clk48(dev, regmap);
+	if (IS_ERR(usb1)) {
+		if (PTR_ERR(usb0) == -EPROBE_DEFER)
+			return -EPROBE_DEFER;
+
+		dev_warn(dev, "Failed to register usb1_clk48 (%ld)\n",
+			 PTR_ERR(usb1));
+
+		clk_data->hws[1] = ERR_PTR(-ENOENT);
+	} else {
+		clk_data->hws[1] = &usb1->hw;
+	}
+
+	return devm_of_clk_add_hw_provider(dev, of_clk_hw_onecell_get, clk_data);
+}
+
 /* --- platform device --- */
 
 static const struct of_device_id da8xx_cfgchip_of_match[] = {
@@ -358,6 +701,10 @@ static const struct of_device_id da8xx_cfgchip_of_match[] = {
 		.compatible = "ti,da850-async3-clksrc",
 		.data = of_da850_async3_init,
 	},
+	{
+		.compatible = "ti,da830-usb-phy-clocks",
+		.data = of_da8xx_usb_phy_clk_init,
+	},
 	{ }
 };
 
@@ -378,6 +725,10 @@ static const struct platform_device_id da8xx_cfgchip_id_table[] = {
 		.name = "da850-async3-clksrc",
 		.driver_data = (kernel_ulong_t)da850_cfgchip_register_async3,
 	},
+	{
+		.name = "da830-usb-phy-clks",
+		.driver_data = (kernel_ulong_t)da8xx_cfgchip_register_usb_phy_clk,
+	},
 	{ }
 };
 
Signature · 1 line
2.7.4
author maintainer
#32 lore raw

PATCH v7 20/42 ARM: davinci: pass clock as parameter to davinci_timer_init()

In reply to David Lechner

This changes davinci_timer_init() so that we pass the clock as a parameter instead of using clk_get(). This is done in preparation for converting to the common clock framework.

It removes the requirement that we have to have a clock with con_id of "timer0", which will be good for DT bindings since clock-names = "timer0" doesn't really make sense.

Additionally, when we convert to the common clock framework, most of the clocks will be platform devices, which will not be available at this point during the boot process, so we will need to pass a clock that is available (i.e. ref_clk) instead of the "timer0" clock.

NB: The comment added in time.c is not entirely true when this patch is applied, but it will be correct once the conversion to the common clock framework is complete in subsequent patches.

Also, drop use of extern in header file since we are touching the definition.

---

v7 changes:
- new in v7

 arch/arm/mach-davinci/da830.c               |  2 +-
 arch/arm/mach-davinci/da850.c               |  2 +-
 arch/arm/mach-davinci/dm355.c               |  2 +-
 arch/arm/mach-davinci/dm365.c               |  2 +-
 arch/arm/mach-davinci/dm644x.c              |  2 +-
 arch/arm/mach-davinci/dm646x.c              |  2 +-
 arch/arm/mach-davinci/include/mach/common.h |  3 ++-
 arch/arm/mach-davinci/time.c                | 13 +++++++++----
 8 files changed, 17 insertions(+), 11 deletions(-)
arch/arm/mach-davinci/da830.c +1 -1
index 350d767..0b17e5a 100644
@@ -1224,5 +1224,5 @@ void __init da830_init(void)
 void __init da830_init_time(void)
 {
 	davinci_clk_init(da830_clks);
-	davinci_timer_init();
+	davinci_timer_init(&timerp64_0_clk);
 }
arch/arm/mach-davinci/da850.c +1 -1
index 34117e61..1dbf01c 100644
@@ -1396,5 +1396,5 @@ void __init da850_init(void)
 void __init da850_init_time(void)
 {
 	davinci_clk_init(da850_clks);
-	davinci_timer_init();
+	davinci_timer_init(&timerp64_0_clk);
 }
arch/arm/mach-davinci/dm355.c +1 -1
index f294804..0da7516 100644
@@ -1047,7 +1047,7 @@ void __init dm355_init(void)
 void __init dm355_init_time(void)
 {
 	davinci_clk_init(dm355_clks);
-	davinci_timer_init();
+	davinci_timer_init(&timer0_clk);
 }
 
 int __init dm355_init_video(struct vpfe_config *vpfe_cfg,
arch/arm/mach-davinci/dm365.c +1 -1
index 1e3df9d..871372a 100644
@@ -1172,7 +1172,7 @@ void __init dm365_init(void)
 void __init dm365_init_time(void)
 {
 	davinci_clk_init(dm365_clks);
-	davinci_timer_init();
+	davinci_timer_init(&timer0_clk);
 }
 
 static struct resource dm365_vpss_resources[] = {
arch/arm/mach-davinci/dm644x.c +1 -1
index b409801..71a16fc 100644
@@ -935,7 +935,7 @@ void __init dm644x_init(void)
 void __init dm644x_init_time(void)
 {
 	davinci_clk_init(dm644x_clks);
-	davinci_timer_init();
+	davinci_timer_init(&timer0_clk);
 }
 
 int __init dm644x_init_video(struct vpfe_config *vpfe_cfg,
arch/arm/mach-davinci/dm646x.c +1 -1
index 109ab1f..e1d6e92 100644
@@ -956,7 +956,7 @@ void __init dm646x_init_time(unsigned long ref_clk_rate,
 	ref_clk.rate = ref_clk_rate;
 	aux_clkin.rate = aux_clkin_rate;
 	davinci_clk_init(dm646x_clks);
-	davinci_timer_init();
+	davinci_timer_init(&timer0_clk);
 }
 
 static int __init dm646x_init_devices(void)
arch/arm/mach-davinci/include/mach/common.h +2 -1
index f0d5e858..5f45d0a 100644
@@ -12,11 +12,12 @@
 #ifndef __ARCH_ARM_MACH_DAVINCI_COMMON_H
 #define __ARCH_ARM_MACH_DAVINCI_COMMON_H
 
+#include <linux/clk.h>
 #include <linux/compiler.h>
 #include <linux/types.h>
 #include <linux/reboot.h>
 
-extern void davinci_timer_init(void);
+void davinci_timer_init(struct clk *clk);
 
 extern void davinci_irq_init(void);
 extern void __iomem *davinci_intc_base;
arch/arm/mach-davinci/time.c +9 -4
index 1bb991a..2521333 100644
@@ -334,10 +334,8 @@ static struct clock_event_device clockevent_davinci = {
 	.set_state_oneshot	= davinci_set_oneshot,
 };
 
-
-void __init davinci_timer_init(void)
+void __init davinci_timer_init(struct clk *timer_clk)
 {
-	struct clk *timer_clk;
 	struct davinci_soc_info *soc_info = &davinci_soc_info;
 	unsigned int clockevent_id;
 	unsigned int clocksource_id;
@@ -373,7 +371,14 @@ void __init davinci_timer_init(void)
 		}
 	}
 
-	timer_clk = clk_get(NULL, "timer0");
+	/*
+	 * REVISIT: Currently, timer_clk will be "ref_clk". However, the actual
+	 * clock for this device comes from a PLL AUXCLK or a PSC clock
+	 * (depending on the SoC). The PLL and PSC clocks are not registered
+	 * until later in boot because they are platform devices. We should try
+	 * again later to get the real clock so that the real clock is not
+	 * turned off when disabling unused clocks, which would stop the timer.
+	 */
 	BUG_ON(IS_ERR(timer_clk));
 	clk_prepare_enable(timer_clk);
 
Signature · 1 line
2.7.4
author maintainer
#33 lore raw

PATCH v7 21/42 ARM: davinci: da830: add new clock init using common clock framework

In reply to David Lechner

This adds the new board-specific clock init in mach-davinci/da830.c using the new common clock framework drivers.

The #ifdefs are needed to prevent compile errors until the entire ARCH_DAVINCI is converted.

Also clean up the #includes since we are adding some here.

---

v7 changes:
- add clock platform device declarations
- register platform devices instead of registering clocks directly
- clkdev lookup is moved to drivers/clk
- add davinci prefix to commit description

v6 changes:
- add blank lines between function calls
- include da8xx_register_cfgchip()

 arch/arm/mach-davinci/board-da830-evm.c    |  2 +
 arch/arm/mach-davinci/da830.c              | 77 +++++++++++++++++++++++++++---
 arch/arm/mach-davinci/include/mach/da8xx.h |  1 +
 3 files changed, 74 insertions(+), 6 deletions(-)
arch/arm/mach-davinci/board-da830-evm.c +2 -0
index 004f9c8..3973124 100644
@@ -551,6 +551,8 @@ static __init void da830_evm_init(void)
 	struct davinci_soc_info *soc_info = &davinci_soc_info;
 	int ret;
 
+	da830_register_clocks();
+
 	ret = da830_register_gpio();
 	if (ret)
 		pr_warn("%s: GPIO init failed: %d\n", __func__, ret);
arch/arm/mach-davinci/da830.c +71 -6

112 lines not on this page · raw message

arch/arm/mach-davinci/include/mach/da8xx.h +1 -0
index 9fd6d01..64861ac 100644
@@ -89,6 +89,7 @@ extern unsigned int da850_max_speed;
 
 void da830_init(void);
 void da830_init_time(void);
+void da830_register_clocks(void);
 
 void da850_init(void);
 void da850_init_time(void);
Signature · 1 line
2.7.4
author maintainer
#34 lore raw

PATCH v7 22/42 ARM: davinci: da850: add new clock init using common clock framework

In reply to David Lechner

This adds the new board-specific clock init in mach-davinci/da850.c using the new common clock framework drivers.

The #ifdefs are needed to prevent compile errors until the entire ARCH_DAVINCI is converted.

Also clean up the #includes since we are adding some here.

Some CFGCHIP macros were removed because we are now including linux/mfd/da8xx-cfgchip.h which defines the same values.

---

v7 changes:
- add clock platform device declarations
- register platform devices instead of registering clocks directly
- clkdev lookup is moved to drivers/clk
- add davinci prefix to commit description

v6 changes:
- add blank lines between function calls
- include da8xx_register_cfgchip()
- add async1 and async2 clock domains

 arch/arm/mach-davinci/board-da850-evm.c     |   2 +
 arch/arm/mach-davinci/board-mityomapl138.c  |   2 +
 arch/arm/mach-davinci/board-omapl138-hawk.c |   2 +
 arch/arm/mach-davinci/da850.c               | 143 +++++++++++++++++++++++++---
 arch/arm/mach-davinci/da8xx-dt.c            |   2 +
 arch/arm/mach-davinci/include/mach/da8xx.h  |   1 +
 6 files changed, 139 insertions(+), 13 deletions(-)
arch/arm/mach-davinci/board-da850-evm.c +2 -0
index 3063478..78a670a 100644
@@ -1334,6 +1334,8 @@ static __init void da850_evm_init(void)
 {
 	int ret;
 
+	da850_register_clocks();
+
 	ret = da850_register_gpio();
 	if (ret)
 		pr_warn("%s: GPIO init failed: %d\n", __func__, ret);
arch/arm/mach-davinci/board-mityomapl138.c +2 -0
index d1c8548..f442784 100644
@@ -502,6 +502,8 @@ static void __init mityomapl138_init(void)
 {
 	int ret;
 
+	da850_register_clocks();
+
 	/* for now, no special EDMA channels are reserved */
 	ret = da850_register_edma(NULL);
 	if (ret)
arch/arm/mach-davinci/board-omapl138-hawk.c +2 -0
index e2ba9da..6a4e486 100644
@@ -281,6 +281,8 @@ static __init void omapl138_hawk_init(void)
 {
 	int ret;
 
+	da850_register_clocks();
+
 	ret = da850_register_gpio();
 	if (ret)
 		pr_warn("%s: GPIO init failed: %d\n", __func__, ret);
arch/arm/mach-davinci/da850.c +130 -13

205 lines not on this page · raw message

arch/arm/mach-davinci/da8xx-dt.c +2 -0
index ab199f4..91dd9cb 100644
@@ -67,6 +67,8 @@ static void __init da850_init_machine(void)
 
 	int ret;
 
+	da850_register_clocks();
+
 	ret = da8xx_register_usb20_phy_clk(false);
 	if (ret)
 		pr_warn("%s: registering USB 2.0 PHY clock failed: %d",
arch/arm/mach-davinci/include/mach/da8xx.h +1 -0
index 64861ac..612e454 100644
@@ -93,6 +93,7 @@ void da830_register_clocks(void);
 
 void da850_init(void);
 void da850_init_time(void);
+void da850_register_clocks(void);
 
 int da830_register_edma(struct edma_rsv_info *rsv);
 int da850_register_edma(struct edma_rsv_info *rsv[2]);
Signature · 1 line
2.7.4
author maintainer
#35 lore raw

PATCH v7 23/42 ARM: davinci: dm355: add new clock init using common clock framework

In reply to David Lechner

This adds the new board-specific clock init in mach-davinci/dm355.c using the new common clock framework drivers.

The #ifdefs are needed to prevent compile errors until the entire ARCH_DAVINCI is converted.

Also clean up the #includes since we are adding some here.

---

v7 changes:
- add clock platform device declarations
- register platform devices instead of registering clocks directly
- add davinci prefix to commit description

v6 changes:
- add blank lines between function calls

 arch/arm/mach-davinci/board-dm355-evm.c     |  2 +
 arch/arm/mach-davinci/board-dm355-leopard.c |  2 +
 arch/arm/mach-davinci/davinci.h             |  1 +
 arch/arm/mach-davinci/dm355.c               | 88 +++++++++++++++++++++++++----
 4 files changed, 81 insertions(+), 12 deletions(-)
arch/arm/mach-davinci/board-dm355-evm.c +2 -0
index 9ef24513..711f723 100644
@@ -384,6 +384,8 @@ static __init void dm355_evm_init(void)
 	struct clk *aemif;
 	int ret;
 
+	dm355_register_clocks();
+
 	ret = dm355_gpio_register();
 	if (ret)
 		pr_warn("%s: GPIO init failed: %d\n", __func__, ret);
arch/arm/mach-davinci/board-dm355-leopard.c +2 -0
index 3ebc89d..f46b185 100644
@@ -233,6 +233,8 @@ static __init void dm355_leopard_init(void)
 	struct clk *aemif;
 	int ret;
 
+	dm355_register_clocks();
+
 	ret = dm355_gpio_register();
 	if (ret)
 		pr_warn("%s: GPIO init failed: %d\n", __func__, ret);
arch/arm/mach-davinci/davinci.h +1 -0
index 270cef8..6b6abf0a 100644
@@ -84,6 +84,7 @@ int davinci_init_wdt(void);
 /* DM355 function declarations */
 void dm355_init(void);
 void dm355_init_time(void);
+void dm355_register_clocks(void);
 void dm355_init_spi0(unsigned chipselect_mask,
 		const struct spi_board_info *info, unsigned len);
 void dm355_init_asp1(u32 evt_enable);
arch/arm/mach-davinci/dm355.c +76 -12

128 lines not on this page · raw message

Signature · 1 line
2.7.4
author maintainer
#36 lore raw

PATCH v7 24/42 ARM: davinci: dm365: add new clock init using common clock framework

In reply to David Lechner

This adds the new board-specific clock init in mach-davinci/dm365.c using the new common clock framework drivers.

The #ifdefs are needed to prevent compile errors until the entire ARCH_DAVINCI is converted.

Also clean up the #includes since we are adding some here.

---

v7 changes:
- add clock platform device declarations
- register platform devices instead of registering clocks directly
- add davinci prefix to commit description

v6 changes:
- add blank lines between function calls

 arch/arm/mach-davinci/board-dm365-evm.c |  2 +
 arch/arm/mach-davinci/davinci.h         |  1 +
 arch/arm/mach-davinci/dm365.c           | 88 ++++++++++++++++++++++++++++-----
 3 files changed, 79 insertions(+), 12 deletions(-)
arch/arm/mach-davinci/board-dm365-evm.c +2 -0
index 3daeac7..67339b42 100644
@@ -741,6 +741,8 @@ static __init void dm365_evm_init(void)
 {
 	int ret;
 
+	dm365_register_clocks();
+
 	ret = dm365_gpio_register();
 	if (ret)
 		pr_warn("%s: GPIO init failed: %d\n", __func__, ret);
arch/arm/mach-davinci/davinci.h +1 -0
index 6b6abf0a..c865226 100644
@@ -94,6 +94,7 @@ int dm355_gpio_register(void);
 /* DM365 function declarations */
 void dm365_init(void);
 void dm365_init_time(void);
+void dm365_register_clocks(void);
 void dm365_init_asp(void);
 void dm365_init_vc(void);
 void dm365_init_ks(struct davinci_ks_platform_data *pdata);
arch/arm/mach-davinci/dm365.c +76 -12

129 lines not on this page · raw message

Signature · 1 line
2.7.4
author maintainer
#37 lore raw

PATCH v7 25/42 ARM: davinci: dm644x: add new clock init using common clock framework

In reply to David Lechner

This adds the new board-specific clock init in mach-davinci/dm644x.c using the new common clock framework drivers.

The #ifdefs are needed to prevent compile errors until the entire ARCH_DAVINCI is converted.

Also clean up the #includes since we are adding some here.

---

v7 changes:
- add clock platform device declarations
- register platform devices instead of registering clocks directly
- add davinci prefix to commit description

v6 changes:
- add blank lines between function calls

 arch/arm/mach-davinci/board-dm644x-evm.c  |  2 +
 arch/arm/mach-davinci/board-neuros-osd2.c |  2 +
 arch/arm/mach-davinci/board-sffsdr.c      |  2 +
 arch/arm/mach-davinci/davinci.h           |  1 +
 arch/arm/mach-davinci/dm644x.c            | 83 +++++++++++++++++++++++++++----
 5 files changed, 81 insertions(+), 9 deletions(-)
arch/arm/mach-davinci/board-dm644x-evm.c +2 -0
index 95b55aa..91c7525 100644
@@ -768,6 +768,8 @@ static __init void davinci_evm_init(void)
 	struct clk *aemif_clk;
 	struct davinci_soc_info *soc_info = &davinci_soc_info;
 
+	dm644x_register_clocks();
+
 	ret = dm644x_gpio_register();
 	if (ret)
 		pr_warn("%s: GPIO init failed: %d\n", __func__, ret);
arch/arm/mach-davinci/board-neuros-osd2.c +2 -0
index f287577..ae17d3e 100644
@@ -174,6 +174,8 @@ static __init void davinci_ntosd2_init(void)
 	struct clk *aemif_clk;
 	struct davinci_soc_info *soc_info = &davinci_soc_info;
 
+	dm644x_register_clocks();
+
 	ret = dm644x_gpio_register();
 	if (ret)
 		pr_warn("%s: GPIO init failed: %d\n", __func__, ret);
arch/arm/mach-davinci/board-sffsdr.c +2 -0
index 2922da9..933cc08 100644
@@ -134,6 +134,8 @@ static __init void davinci_sffsdr_init(void)
 {
 	struct davinci_soc_info *soc_info = &davinci_soc_info;
 
+	dm644x_register_clocks();
+
 	platform_add_devices(davinci_sffsdr_devices,
 			     ARRAY_SIZE(davinci_sffsdr_devices));
 	sffsdr_init_i2c();
arch/arm/mach-davinci/davinci.h +1 -0
index c865226..2861a6f 100644
@@ -107,6 +107,7 @@ int dm365_gpio_register(void);
 /* DM644x function declarations */
 void dm644x_init(void);
 void dm644x_init_time(void);
+void dm644x_register_clocks(void);
 void dm644x_init_asp(void);
 int dm644x_init_video(struct vpfe_config *, struct vpbe_config *);
 int dm644x_gpio_register(void);
arch/arm/mach-davinci/dm644x.c +74 -9

122 lines not on this page · raw message

Signature · 1 line
2.7.4
author maintainer
#38 lore raw

PATCH v7 26/42 ARM: davinci: dm646x: add new clock init using common clock framework

In reply to David Lechner

This adds the new board-specific clock init in mach-davinci/dm646x.c using the new common clock framework drivers.

The #ifdefs are needed to prevent compile errors until the entire ARCH_DAVINCI is converted.

Also clean up the #includes since we are adding some here.

---

v7 changes:
- add clock platform device declarations
- register platform devices instead of registering clocks directly
- add davinci prefix to commit description

v6 changes:
- add blank lines between function calls

 arch/arm/mach-davinci/board-dm646x-evm.c |  2 +
 arch/arm/mach-davinci/davinci.h          |  1 +
 arch/arm/mach-davinci/dm646x.c           | 82 ++++++++++++++++++++++++++++----
 3 files changed, 77 insertions(+), 8 deletions(-)
arch/arm/mach-davinci/board-dm646x-evm.c +2 -0
index 2d37f5b..d672804 100644
@@ -772,6 +772,8 @@ static __init void evm_init(void)
 	int ret;
 	struct davinci_soc_info *soc_info = &davinci_soc_info;
 
+	dm646x_register_clocks();
+
 	ret = dm646x_gpio_register();
 	if (ret)
 		pr_warn("%s: GPIO init failed: %d\n", __func__, ret);
arch/arm/mach-davinci/davinci.h +1 -0
index 2861a6f..a200977 100644
@@ -115,6 +115,7 @@ int dm644x_gpio_register(void);
 /* DM646x function declarations */
 void dm646x_init(void);
 void dm646x_init_time(unsigned long ref_clk_rate, unsigned long aux_clkin_rate);
+void dm646x_register_clocks(void);
 void dm646x_init_mcasp0(struct snd_platform_data *pdata);
 void dm646x_init_mcasp1(struct snd_platform_data *pdata);
 int dm646x_init_edma(struct edma_rsv_info *rsv);
arch/arm/mach-davinci/dm646x.c +74 -8

125 lines not on this page · raw message

Signature · 1 line
2.7.4
author maintainer
#39 lore raw

PATCH v7 27/42 ARM: davinci: da8xx: add new USB PHY clock init using common clock framework

In reply to David Lechner

This adds the new USB PHY clock init in mach-davinci/usb-da8xx.c using the new common clock framework drivers.

The #ifdefs are needed to prevent compile errors until the entire ARCH_DAVINCI is converted.

---

v7 changes:
- register platform device instead of registering clocks directly
- USB PHY clocks now treated as single device instead of registering them separately

v6 changes:
- rename stuff to match changes in "clk: davinci: New driver for TI DA8XX USB PHY clocks"
- take advantage of syscon lookup changes in "mfd: syscon: Add syscon_register() function"

 arch/arm/mach-davinci/board-da830-evm.c     |  8 +++++++-
 arch/arm/mach-davinci/board-omapl138-hawk.c |  9 +++++++--
 arch/arm/mach-davinci/da8xx-dt.c            |  8 +++++++-
 arch/arm/mach-davinci/include/mach/da8xx.h  |  1 +
 arch/arm/mach-davinci/usb-da8xx.c           | 26 ++++++++++++++++++++++++--
 5 files changed, 46 insertions(+), 6 deletions(-)
arch/arm/mach-davinci/board-da830-evm.c +7 -1
index 3973124..6e77c45 100644
@@ -110,6 +110,12 @@ static __init void da830_evm_usb_init(void)
 {
 	int ret;
 
+#ifdef CONFIG_COMMON_CLK
+	ret = da8xx_register_usb_phy_clocks();
+	if (ret)
+		pr_warn("%s: USB PHY CLK registration failed: %d\n",
+			__func__, ret);
+#else
 	/* USB_REFCLKIN is not used. */
 	ret = da8xx_register_usb20_phy_clk(false);
 	if (ret)
@@ -120,7 +126,7 @@ static __init void da830_evm_usb_init(void)
 	if (ret)
 		pr_warn("%s: USB 1.1 PHY CLK registration failed: %d\n",
 			__func__, ret);
-
+#endif
 	ret = da8xx_register_usb_phy();
 	if (ret)
 		pr_warn("%s: USB PHY registration failed: %d\n",
arch/arm/mach-davinci/board-omapl138-hawk.c +7 -2
index 6a4e486..2a10cd8 100644
@@ -231,7 +231,12 @@ static __init void omapl138_hawk_usb_init(void)
 		pr_warn("%s: USB 1.1 PinMux setup failed: %d\n", __func__, ret);
 		return;
 	}
-
+#ifdef CONFIG_COMMON_CLK
+	ret = da8xx_register_usb_phy_clocks();
+	if (ret)
+		pr_warn("%s: USB PHY CLK registration failed: %d\n",
+			__func__, ret);
+#else
 	ret = da8xx_register_usb20_phy_clk(false);
 	if (ret)
 		pr_warn("%s: USB 2.0 PHY CLK registration failed: %d\n",
@@ -241,7 +246,7 @@ static __init void omapl138_hawk_usb_init(void)
 	if (ret)
 		pr_warn("%s: USB 1.1 PHY CLK registration failed: %d\n",
 			__func__, ret);
-
+#endif
 	ret = da8xx_register_usb_phy();
 	if (ret)
 		pr_warn("%s: USB PHY registration failed: %d\n",
arch/arm/mach-davinci/da8xx-dt.c +7 -1
index 91dd9cb..c4edf05 100644
@@ -69,6 +69,12 @@ static void __init da850_init_machine(void)
 
 	da850_register_clocks();
 
+#ifdef CONFIG_COMMON_CLK
+	ret = da8xx_register_usb_phy_clocks();
+	if (ret)
+		pr_warn("%s: USB PHY CLK registration failed: %d\n",
+			__func__, ret);
+#else
 	ret = da8xx_register_usb20_phy_clk(false);
 	if (ret)
 		pr_warn("%s: registering USB 2.0 PHY clock failed: %d",
@@ -77,7 +83,7 @@ static void __init da850_init_machine(void)
 	if (ret)
 		pr_warn("%s: registering USB 1.1 PHY clock failed: %d",
 			__func__, ret);
-
+#endif
 	ret = da850_register_sata_refclk(sata_refclkpn);
 	if (ret)
 		pr_warn("%s: registering SATA REFCLK failed: %d",
arch/arm/mach-davinci/include/mach/da8xx.h +1 -0
index 612e454..5d7b1de 100644
@@ -106,6 +106,7 @@ 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_usb_phy_clocks(void);
 int da850_register_sata_refclk(int rate);
 int da8xx_register_emac(void);
 int da8xx_register_uio_pruss(void);
arch/arm/mach-davinci/usb-da8xx.c +24 -2
index 4d89d86..d8cc63c 100644
@@ -2,29 +2,35 @@
 /*
  * DA8xx USB
  */
-#include <linux/clk.h>
+#include <linux/clk-provider.h>
 #include <linux/delay.h>
 #include <linux/dma-mapping.h>
 #include <linux/init.h>
 #include <linux/mfd/da8xx-cfgchip.h>
+#include <linux/mfd/syscon.h>
 #include <linux/phy/phy.h>
+#include <linux/platform_data/clk-da8xx-cfgchip.h>
 #include <linux/platform_data/phy-da8xx-usb.h>
 #include <linux/platform_data/usb-davinci.h>
 #include <linux/platform_device.h>
 #include <linux/usb/musb.h>
 
-#include <mach/clock.h>
 #include <mach/common.h>
 #include <mach/cputype.h>
 #include <mach/da8xx.h>
 #include <mach/irqs.h>
 
+#ifndef CONFIG_COMMON_CLK
+#include <mach/clock.h>
 #include "clock.h"
+#endif
 
 #define DA8XX_USB0_BASE		0x01e00000
 #define DA8XX_USB1_BASE		0x01e25000
 
+#ifndef CONFIG_COMMON_CLK
 static struct clk *usb20_clk;
+#endif
 
 static struct platform_device da8xx_usb_phy = {
 	.name		= "da8xx-usb-phy",
@@ -134,6 +140,7 @@ int __init da8xx_register_usb11(struct da8xx_ohci_root_hub *pdata)
 	return platform_device_register(&da8xx_usb11_device);
 }
 
+#ifndef CONFIG_COMMON_CLK
 static struct clk usb_refclkin = {
 	.name		= "usb_refclkin",
 	.set_rate	= davinci_simple_set_rate,
@@ -360,3 +367,18 @@ int __init da8xx_register_usb11_phy_clk(bool use_usb_refclkin)
 
 	return ret;
 }
+#endif
+static struct platform_device da8xx_usb_phy_clks_device = {
+	.name		= "da830-usb-phy-clks",
+	.id		= -1,
+};
+
+int __init da8xx_register_usb_phy_clocks(void)
+{
+	struct da8xx_cfgchip_clk_platform_data pdata;
+
+	pdata.cfgchip = da8xx_get_cfgchip();
+	da8xx_usb_phy_clks_device.dev.platform_data = &pdata;
+
+	return platform_device_register(&da8xx_usb_phy_clks_device);
+}
Signature · 1 line
2.7.4
author maintainer
#40 lore raw

PATCH v7 28/42 ARM: davinci: da8xx: add new sata_refclk init using common clock framework

In reply to David Lechner

This adds the new SATA REFCLK clock init in mach-davinci/devices-da8xx.c using the new common clock framework drivers.

The #ifdefs are needed to prevent compile errors until the entire ARCH_DAVINCI is converted.

Also, the #includes are sorted since we are adding some here.

---

v7 changes:
- sorting of include files seems to have been messed up by rebasing - will fix in later revision

v6 changes:
- none

 arch/arm/mach-davinci/devices-da8xx.c | 36 ++++++++++++++++++++++++++---------
 1 file changed, 27 insertions(+), 9 deletions(-)
arch/arm/mach-davinci/devices-da8xx.c +27 -9
index 24422ba..c7ec60b 100644
@@ -10,25 +10,30 @@
  * the Free Software Foundation; either version 2 of the License, or
  * (at your option) any later version.
  */
-#include <linux/init.h>
-#include <linux/platform_device.h>
-#include <linux/dma-contiguous.h>
-#include <linux/serial_8250.h>
 #include <linux/ahci_platform.h>
+#include <linux/clk-provider.h>
 #include <linux/clk.h>
-#include <linux/reboot.h>
+#include <linux/clkdev.h>
+#include <linux/dma-contiguous.h>
 #include <linux/dmaengine.h>
+#include <linux/init.h>
+#include <linux/platform_device.h>
+#include <linux/reboot.h>
+#include <linux/serial_8250.h>
 
-#include <mach/cputype.h>
 #include <mach/common.h>
-#include <mach/time.h>
+#include <mach/cputype.h>
 #include <mach/da8xx.h>
-#include <mach/clock.h>
+#include <mach/time.h>
+
+#include "asp.h"
 #include "cpuidle.h"
 #include "sram.h"
 
+#ifndef CONFIG_COMMON_CLK
+#include <mach/clock.h>
 #include "clock.h"
-#include "asp.h"
+#endif
 
 #define DA8XX_TPCC_BASE			0x01c00000
 #define DA8XX_TPTC0_BASE		0x01c08000
@@ -1040,6 +1045,7 @@ int __init da8xx_register_spi_bus(int instance, unsigned num_chipselect)
 }
 
 #ifdef CONFIG_ARCH_DAVINCI_DA850
+#ifndef CONFIG_COMMON_CLK
 static struct clk sata_refclk = {
 	.name		= "sata_refclk",
 	.set_rate	= davinci_simple_set_rate,
@@ -1061,6 +1067,18 @@ int __init da850_register_sata_refclk(int rate)
 
 	return 0;
 }
+#else
+int __init da850_register_sata_refclk(int rate)
+{
+	struct clk *clk;
+
+	clk = clk_register_fixed_rate(NULL, "sata_refclk", NULL, 0, rate);
+	if (IS_ERR(clk))
+		return PTR_ERR(clk);
+
+	return clk_register_clkdev(clk, "refclk", "ahci_da850");
+}
+#endif
 
 static struct resource da850_sata_resources[] = {
 	{
Signature · 1 line
2.7.4
author maintainer
#41 lore raw

PATCH v7 29/42 ARM: davinci: remove CONFIG_DAVINCI_RESET_CLOCKS

In reply to David Lechner

The common clock framework will take care of disabling unused clocks when we switch from the legacy davinci clocks and having this enabled will cause compile errors after we switch, so remove it now.

---

v7 changes:
- none

v6 changes:
- none

 arch/arm/mach-davinci/Kconfig               | 12 ------------
 arch/arm/mach-davinci/common.c              |  1 -
 arch/arm/mach-davinci/include/mach/common.h |  6 ------
 3 files changed, 19 deletions(-)
arch/arm/mach-davinci/Kconfig +0 -12
index 05c3eecf..ba9912b 100644
@@ -231,18 +231,6 @@ config DAVINCI_MUX_WARNINGS
 	  to change the pin multiplexing setup. When there are no warnings
 	  printed, it's safe to deselect DAVINCI_MUX for your product.
 
-config DAVINCI_RESET_CLOCKS
-	bool "Reset unused clocks during boot"
-	depends on ARCH_DAVINCI
-	help
-	  Say Y if you want to reset unused clocks during boot.
-	  This option saves power, but assumes all drivers are
-	  using the clock framework. Broken drivers that do not
-	  yet use clock framework may not work with this option.
-	  If you are booting from another operating system, you
-	  probably do not want this option enabled until your
-	  device drivers work properly.
-
 endmenu
 
 endif
arch/arm/mach-davinci/common.c +0 -1
index bcb6a7b..e03f95c 100644
@@ -118,5 +118,4 @@ void __init davinci_common_init(const struct davinci_soc_info *soc_info)
 void __init davinci_init_late(void)
 {
 	davinci_cpufreq_init();
-	davinci_clk_disable_unused();
 }
arch/arm/mach-davinci/include/mach/common.h +0 -6
index 5f45d0a..ded8f5f 100644
@@ -83,12 +83,6 @@ extern void davinci_common_init(const struct davinci_soc_info *soc_info);
 extern void davinci_init_ide(void);
 void davinci_init_late(void);
 
-#ifdef CONFIG_DAVINCI_RESET_CLOCKS
-int davinci_clk_disable_unused(void);
-#else
-static inline int davinci_clk_disable_unused(void) { return 0; }
-#endif
-
 #ifdef CONFIG_CPU_FREQ
 int davinci_cpufreq_init(void);
 #else
Signature · 1 line
2.7.4
author maintainer
#42 lore raw

PATCH v7 30/42 ARM: davinci_all_defconfig: remove CONFIG_DAVINCI_RESET_CLOCKS

In reply to David Lechner

This removes CONFIG_DAVINCI_RESET_CLOCKS. The option has been removed from the kernel.

---

v7 changes:
- none

v6 changes:
- none

 arch/arm/configs/davinci_all_defconfig | 1 -
 1 file changed, 1 deletion(-)
arch/arm/configs/davinci_all_defconfig +0 -1
index 026154c..94d8946 100644
@@ -31,7 +31,6 @@ CONFIG_MACH_MITYOMAPL138=y
 CONFIG_MACH_OMAPL138_HAWKBOARD=y
 CONFIG_DAVINCI_MUX_DEBUG=y
 CONFIG_DAVINCI_MUX_WARNINGS=y
-CONFIG_DAVINCI_RESET_CLOCKS=y
 CONFIG_PREEMPT=y
 CONFIG_AEABI=y
 CONFIG_CMA=y
Signature · 1 line
2.7.4
author maintainer
#43 lore raw

PATCH v7 31/42 ARM: davinci: switch to common clock framework

In reply to David Lechner

This switches ARCH_DAVINCI to use the common clock framework. The legacy clock code in arch/arm/mach-davinci/ is no longer used. New drivers in drivers/clk/davinci/ are used instead.

A few macros had to be moved to prevent compilation errors.

---

v7 changes:
- s/compile/compilation and space instead of tab
- add PM_GENERIC_DOMAINS dependencies

v6 changes:
- clean up indent on Common objects section

 arch/arm/Kconfig                | 5 ++++-
 arch/arm/mach-davinci/Makefile  | 4 ++--
 arch/arm/mach-davinci/clock.h   | 4 ----
 arch/arm/mach-davinci/davinci.h | 4 ++++
 arch/arm/mach-davinci/psc.h     | 2 --
 5 files changed, 10 insertions(+), 9 deletions(-)
arch/arm/Kconfig +4 -1
index 7e3d535..563fade 100644
@@ -608,13 +608,16 @@ config ARCH_S3C24XX
 config ARCH_DAVINCI
 	bool "TI DaVinci"
 	select ARCH_HAS_HOLES_MEMORYMODEL
-	select CLKDEV_LOOKUP
+	select COMMON_CLK
 	select CPU_ARM926T
 	select GENERIC_ALLOCATOR
 	select GENERIC_CLOCKEVENTS
 	select GENERIC_IRQ_CHIP
 	select GPIOLIB
 	select HAVE_IDE
+	select PM_GENERIC_DOMAINS if PM
+	select PM_GENERIC_DOMAINS_OF if PM && OF
+	select RESET_CONTROLLER
 	select USE_OF
 	select ZONE_DMA
 	help
arch/arm/mach-davinci/Makefile +2 -2
index 4e81780..8725d8b 100644
@@ -5,8 +5,8 @@
 #
 
 # Common objects
-obj-y 			:= time.o clock.o serial.o psc.o \
-			   usb.o common.o sram.o aemif.o
+obj-y 					:= time.o serial.o usb.o \
+					   common.o sram.o aemif.o
 
 obj-$(CONFIG_DAVINCI_MUX)		+= mux.o
 
arch/arm/mach-davinci/clock.h +0 -4
index d7894d5..2d05856 100644
@@ -12,10 +12,6 @@
 #ifndef __ARCH_ARM_DAVINCI_CLOCK_H
 #define __ARCH_ARM_DAVINCI_CLOCK_H
 
-#define DAVINCI_PLL1_BASE 0x01c40800
-#define DAVINCI_PLL2_BASE 0x01c40c00
-#define MAX_PLL 2
-
 /* PLL/Reset register offsets */
 #define PLLCTL          0x100
 #define PLLCTL_PLLEN    BIT(0)
arch/arm/mach-davinci/davinci.h +4 -0
index a200977..a227f80 100644
@@ -35,6 +35,10 @@
 #include <media/davinci/vpbe.h>
 #include <media/davinci/vpbe_osd.h>
 
+#define DAVINCI_PLL1_BASE		0x01c40800
+#define DAVINCI_PLL2_BASE		0x01c40c00
+#define DAVINCI_PWR_SLEEP_CNTRL_BASE	0x01c41000
+
 #define DAVINCI_SYSTEM_MODULE_BASE	0x01c40000
 #define SYSMOD_VDAC_CONFIG		0x2c
 #define SYSMOD_VIDCLKCTL		0x38
arch/arm/mach-davinci/psc.h +0 -2
index 8af9f09..b58707c 100644
@@ -27,8 +27,6 @@
 #ifndef __ASM_ARCH_PSC_H
 #define __ASM_ARCH_PSC_H
 
-#define	DAVINCI_PWR_SLEEP_CNTRL_BASE	0x01C41000
-
 /* Power and Sleep Controller (PSC) Domains */
 #define DAVINCI_GPSC_ARMDOMAIN		0
 #define DAVINCI_GPSC_DSPDOMAIN		1
Signature · 1 line
2.7.4
author maintainer
#44 lore raw

PATCH v7 32/42 ARM: davinci: da830: Remove legacy clock init

In reply to David Lechner

This removes the unused legacy clock init code from arch/arm/mach-davinci/da830.c.

---

v7 changes:
- rebased
- add davinci prefix to commit message

v6 changes:
- rebased

 arch/arm/mach-davinci/board-da830-evm.c |  12 -
 arch/arm/mach-davinci/da830.c           | 412 --------------------------------
 2 files changed, 424 deletions(-)
arch/arm/mach-davinci/board-da830-evm.c +0 -12
index 6e77c45..d283fae 100644
@@ -110,23 +110,11 @@ static __init void da830_evm_usb_init(void)
 {
 	int ret;
 
-#ifdef CONFIG_COMMON_CLK
 	ret = da8xx_register_usb_phy_clocks();
 	if (ret)
 		pr_warn("%s: USB PHY CLK registration failed: %d\n",
 			__func__, ret);
-#else
-	/* 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);
-#endif
 	ret = da8xx_register_usb_phy();
 	if (ret)
 		pr_warn("%s: USB PHY registration failed: %d\n",
arch/arm/mach-davinci/da830.c +0 -412

447 lines not on this page · raw message

Signature · 1 line
2.7.4
author maintainer
#45 lore raw

PATCH v7 33/42 ARM: davinci: da850: Remove legacy clock init

In reply to David Lechner

This removes the unused legacy clock init code from arch/arm/mach-davinci/da850.c.

---

v7 changes:
- rebased
- add davinci prefix to commit message

v6 changes:
- rebased

 arch/arm/mach-davinci/board-omapl138-hawk.c |  12 +-
 arch/arm/mach-davinci/da850.c               | 653 +---------------------------
 arch/arm/mach-davinci/da8xx-dt.c            |  12 +-
 3 files changed, 3 insertions(+), 674 deletions(-)
arch/arm/mach-davinci/board-omapl138-hawk.c +1 -11
index 2a10cd8..e372dcf 100644
@@ -231,22 +231,12 @@ static __init void omapl138_hawk_usb_init(void)
 		pr_warn("%s: USB 1.1 PinMux setup failed: %d\n", __func__, ret);
 		return;
 	}
-#ifdef CONFIG_COMMON_CLK
+
 	ret = da8xx_register_usb_phy_clocks();
 	if (ret)
 		pr_warn("%s: USB PHY CLK registration failed: %d\n",
 			__func__, ret);
-#else
-	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);
-#endif
 	ret = da8xx_register_usb_phy();
 	if (ret)
 		pr_warn("%s: USB PHY registration failed: %d\n",
arch/arm/mach-davinci/da850.c +1 -652

709 lines not on this page · raw message

arch/arm/mach-davinci/da8xx-dt.c +1 -11
index c4edf05..088bc5c 100644
@@ -69,21 +69,11 @@ static void __init da850_init_machine(void)
 
 	da850_register_clocks();
 
-#ifdef CONFIG_COMMON_CLK
 	ret = da8xx_register_usb_phy_clocks();
 	if (ret)
 		pr_warn("%s: USB PHY CLK registration failed: %d\n",
 			__func__, ret);
-#else
-	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);
-#endif
+
 	ret = da850_register_sata_refclk(sata_refclkpn);
 	if (ret)
 		pr_warn("%s: registering SATA REFCLK failed: %d",
Signature · 1 line
2.7.4
author maintainer
#46 lore raw

PATCH v7 34/42 ARM: davinci: dm355: Remove legacy clock init

In reply to David Lechner

This removes the unused legacy clock init code from arch/arm/mach-davinci/dm355.c.

---

v7 changes:
- rebased
- add davinci prefix to commit message

v6 changes:
- rebased

 arch/arm/mach-davinci/dm355.c | 357 ------------------------------------------
 1 file changed, 357 deletions(-)
arch/arm/mach-davinci/dm355.c +0 -357
index f53e07a..a2d1246 100644
@@ -32,11 +32,6 @@
 #include "davinci.h"
 #include "mux.h"
 
-#ifndef CONFIG_COMMON_CLK
-#include "clock.h"
-#include "psc.h"
-#endif
-
 #define DM355_UART2_BASE	(IO_PHYS + 0x206000)
 #define DM355_OSD_BASE		(IO_PHYS + 0x70200)
 #define DM355_VENC_BASE		(IO_PHYS + 0x70400)
@@ -46,349 +41,6 @@
  */
 #define DM355_REF_FREQ		24000000	/* 24 or 36 MHz */
 
-#ifndef CONFIG_COMMON_CLK
-static struct pll_data pll1_data = {
-	.num       = 1,
-	.phys_base = DAVINCI_PLL1_BASE,
-	.flags     = PLL_HAS_PREDIV | PLL_HAS_POSTDIV,
-};
-
-static struct pll_data pll2_data = {
-	.num       = 2,
-	.phys_base = DAVINCI_PLL2_BASE,
-	.flags     = PLL_HAS_PREDIV,
-};
-
-static struct clk ref_clk = {
-	.name = "ref_clk",
-	/* FIXME -- crystal rate is board-specific */
-	.rate = DM355_REF_FREQ,
-};
-
-static struct clk pll1_clk = {
-	.name = "pll1",
-	.parent = &ref_clk,
-	.flags = CLK_PLL,
-	.pll_data = &pll1_data,
-};
-
-static struct clk pll1_aux_clk = {
-	.name = "pll1_aux_clk",
-	.parent = &pll1_clk,
-	.flags = CLK_PLL | PRE_PLL,
-};
-
-static struct clk pll1_sysclk1 = {
-	.name = "pll1_sysclk1",
-	.parent = &pll1_clk,
-	.flags = CLK_PLL,
-	.div_reg = PLLDIV1,
-};
-
-static struct clk pll1_sysclk2 = {
-	.name = "pll1_sysclk2",
-	.parent = &pll1_clk,
-	.flags = CLK_PLL,
-	.div_reg = PLLDIV2,
-};
-
-static struct clk pll1_sysclk3 = {
-	.name = "pll1_sysclk3",
-	.parent = &pll1_clk,
-	.flags = CLK_PLL,
-	.div_reg = PLLDIV3,
-};
-
-static struct clk pll1_sysclk4 = {
-	.name = "pll1_sysclk4",
-	.parent = &pll1_clk,
-	.flags = CLK_PLL,
-	.div_reg = PLLDIV4,
-};
-
-static struct clk pll1_sysclkbp = {
-	.name = "pll1_sysclkbp",
-	.parent = &pll1_clk,
-	.flags = CLK_PLL | PRE_PLL,
-	.div_reg = BPDIV
-};
-
-static struct clk vpss_dac_clk = {
-	.name = "vpss_dac",
-	.parent = &pll1_sysclk3,
-	.lpsc = DM355_LPSC_VPSS_DAC,
-};
-
-static struct clk vpss_master_clk = {
-	.name = "vpss_master",
-	.parent = &pll1_sysclk4,
-	.lpsc = DAVINCI_LPSC_VPSSMSTR,
-	.flags = CLK_PSC,
-};
-
-static struct clk vpss_slave_clk = {
-	.name = "vpss_slave",
-	.parent = &pll1_sysclk4,
-	.lpsc = DAVINCI_LPSC_VPSSSLV,
-};
-
-static struct clk clkout1_clk = {
-	.name = "clkout1",
-	.parent = &pll1_aux_clk,
-	/* NOTE:  clkout1 can be externally gated by muxing GPIO-18 */
-};
-
-static struct clk clkout2_clk = {
-	.name = "clkout2",
-	.parent = &pll1_sysclkbp,
-};
-
-static struct clk pll2_clk = {
-	.name = "pll2",
-	.parent = &ref_clk,
-	.flags = CLK_PLL,
-	.pll_data = &pll2_data,
-};
-
-static struct clk pll2_sysclk1 = {
-	.name = "pll2_sysclk1",
-	.parent = &pll2_clk,
-	.flags = CLK_PLL,
-	.div_reg = PLLDIV1,
-};
-
-static struct clk pll2_sysclkbp = {
-	.name = "pll2_sysclkbp",
-	.parent = &pll2_clk,
-	.flags = CLK_PLL | PRE_PLL,
-	.div_reg = BPDIV
-};
-
-static struct clk clkout3_clk = {
-	.name = "clkout3",
-	.parent = &pll2_sysclkbp,
-	/* NOTE:  clkout3 can be externally gated by muxing GPIO-16 */
-};
-
-static struct clk arm_clk = {
-	.name = "arm_clk",
-	.parent = &pll1_sysclk1,
-	.lpsc = DAVINCI_LPSC_ARM,
-	.flags = ALWAYS_ENABLED,
-};
-
-/*
- * NOT LISTED below, and not touched by Linux
- *   - in SyncReset state by default
- *	.lpsc = DAVINCI_LPSC_TPCC,
- *	.lpsc = DAVINCI_LPSC_TPTC0,
- *	.lpsc = DAVINCI_LPSC_TPTC1,
- *	.lpsc = DAVINCI_LPSC_DDR_EMIF, .parent = &sysclk2_clk,
- *	.lpsc = DAVINCI_LPSC_MEMSTICK,
- *   - in Enabled state by default
- *	.lpsc = DAVINCI_LPSC_SYSTEM_SUBSYS,
- *	.lpsc = DAVINCI_LPSC_SCR2,	// "bus"
- *	.lpsc = DAVINCI_LPSC_SCR3,	// "bus"
- *	.lpsc = DAVINCI_LPSC_SCR4,	// "bus"
- *	.lpsc = DAVINCI_LPSC_CROSSBAR,	// "emulation"
- *	.lpsc = DAVINCI_LPSC_CFG27,	// "test"
- *	.lpsc = DAVINCI_LPSC_CFG3,	// "test"
- *	.lpsc = DAVINCI_LPSC_CFG5,	// "test"
- */
-
-static struct clk mjcp_clk = {
-	.name = "mjcp",
-	.parent = &pll1_sysclk1,
-	.lpsc = DAVINCI_LPSC_IMCOP,
-};
-
-static struct clk uart0_clk = {
-	.name = "uart0",
-	.parent = &pll1_aux_clk,
-	.lpsc = DAVINCI_LPSC_UART0,
-};
-
-static struct clk uart1_clk = {
-	.name = "uart1",
-	.parent = &pll1_aux_clk,
-	.lpsc = DAVINCI_LPSC_UART1,
-};
-
-static struct clk uart2_clk = {
-	.name = "uart2",
-	.parent = &pll1_sysclk2,
-	.lpsc = DAVINCI_LPSC_UART2,
-};
-
-static struct clk i2c_clk = {
-	.name = "i2c",
-	.parent = &pll1_aux_clk,
-	.lpsc = DAVINCI_LPSC_I2C,
-};
-
-static struct clk asp0_clk = {
-	.name = "asp0",
-	.parent = &pll1_sysclk2,
-	.lpsc = DAVINCI_LPSC_McBSP,
-};
-
-static struct clk asp1_clk = {
-	.name = "asp1",
-	.parent = &pll1_sysclk2,
-	.lpsc = DM355_LPSC_McBSP1,
-};
-
-static struct clk mmcsd0_clk = {
-	.name = "mmcsd0",
-	.parent = &pll1_sysclk2,
-	.lpsc = DAVINCI_LPSC_MMC_SD,
-};
-
-static struct clk mmcsd1_clk = {
-	.name = "mmcsd1",
-	.parent = &pll1_sysclk2,
-	.lpsc = DM355_LPSC_MMC_SD1,
-};
-
-static struct clk spi0_clk = {
-	.name = "spi0",
-	.parent = &pll1_sysclk2,
-	.lpsc = DAVINCI_LPSC_SPI,
-};
-
-static struct clk spi1_clk = {
-	.name = "spi1",
-	.parent = &pll1_sysclk2,
-	.lpsc = DM355_LPSC_SPI1,
-};
-
-static struct clk spi2_clk = {
-	.name = "spi2",
-	.parent = &pll1_sysclk2,
-	.lpsc = DM355_LPSC_SPI2,
-};
-
-static struct clk gpio_clk = {
-	.name = "gpio",
-	.parent = &pll1_sysclk2,
-	.lpsc = DAVINCI_LPSC_GPIO,
-};
-
-static struct clk aemif_clk = {
-	.name = "aemif",
-	.parent = &pll1_sysclk2,
-	.lpsc = DAVINCI_LPSC_AEMIF,
-};
-
-static struct clk pwm0_clk = {
-	.name = "pwm0",
-	.parent = &pll1_aux_clk,
-	.lpsc = DAVINCI_LPSC_PWM0,
-};
-
-static struct clk pwm1_clk = {
-	.name = "pwm1",
-	.parent = &pll1_aux_clk,
-	.lpsc = DAVINCI_LPSC_PWM1,
-};
-
-static struct clk pwm2_clk = {
-	.name = "pwm2",
-	.parent = &pll1_aux_clk,
-	.lpsc = DAVINCI_LPSC_PWM2,
-};
-
-static struct clk pwm3_clk = {
-	.name = "pwm3",
-	.parent = &pll1_aux_clk,
-	.lpsc = DM355_LPSC_PWM3,
-};
-
-static struct clk timer0_clk = {
-	.name = "timer0",
-	.parent = &pll1_aux_clk,
-	.lpsc = DAVINCI_LPSC_TIMER0,
-};
-
-static struct clk timer1_clk = {
-	.name = "timer1",
-	.parent = &pll1_aux_clk,
-	.lpsc = DAVINCI_LPSC_TIMER1,
-};
-
-static struct clk timer2_clk = {
-	.name = "timer2",
-	.parent = &pll1_aux_clk,
-	.lpsc = DAVINCI_LPSC_TIMER2,
-	.usecount = 1,              /* REVISIT: why can't this be disabled? */
-};
-
-static struct clk timer3_clk = {
-	.name = "timer3",
-	.parent = &pll1_aux_clk,
-	.lpsc = DM355_LPSC_TIMER3,
-};
-
-static struct clk rto_clk = {
-	.name = "rto",
-	.parent = &pll1_aux_clk,
-	.lpsc = DM355_LPSC_RTO,
-};
-
-static struct clk usb_clk = {
-	.name = "usb",
-	.parent = &pll1_sysclk2,
-	.lpsc = DAVINCI_LPSC_USB,
-};
-
-static struct clk_lookup dm355_clks[] = {
-	CLK(NULL, "ref", &ref_clk),
-	CLK(NULL, "pll1", &pll1_clk),
-	CLK(NULL, "pll1_sysclk1", &pll1_sysclk1),
-	CLK(NULL, "pll1_sysclk2", &pll1_sysclk2),
-	CLK(NULL, "pll1_sysclk3", &pll1_sysclk3),
-	CLK(NULL, "pll1_sysclk4", &pll1_sysclk4),
-	CLK(NULL, "pll1_aux", &pll1_aux_clk),
-	CLK(NULL, "pll1_sysclkbp", &pll1_sysclkbp),
-	CLK(NULL, "vpss_dac", &vpss_dac_clk),
-	CLK("vpss", "master", &vpss_master_clk),
-	CLK("vpss", "slave", &vpss_slave_clk),
-	CLK(NULL, "clkout1", &clkout1_clk),
-	CLK(NULL, "clkout2", &clkout2_clk),
-	CLK(NULL, "pll2", &pll2_clk),
-	CLK(NULL, "pll2_sysclk1", &pll2_sysclk1),
-	CLK(NULL, "pll2_sysclkbp", &pll2_sysclkbp),
-	CLK(NULL, "clkout3", &clkout3_clk),
-	CLK(NULL, "arm", &arm_clk),
-	CLK(NULL, "mjcp", &mjcp_clk),
-	CLK("serial8250.0", NULL, &uart0_clk),
-	CLK("serial8250.1", NULL, &uart1_clk),
-	CLK("serial8250.2", NULL, &uart2_clk),
-	CLK("i2c_davinci.1", NULL, &i2c_clk),
-	CLK("davinci-mcbsp.0", NULL, &asp0_clk),
-	CLK("davinci-mcbsp.1", NULL, &asp1_clk),
-	CLK("dm6441-mmc.0", NULL, &mmcsd0_clk),
-	CLK("dm6441-mmc.1", NULL, &mmcsd1_clk),
-	CLK("spi_davinci.0", NULL, &spi0_clk),
-	CLK("spi_davinci.1", NULL, &spi1_clk),
-	CLK("spi_davinci.2", NULL, &spi2_clk),
-	CLK(NULL, "gpio", &gpio_clk),
-	CLK(NULL, "aemif", &aemif_clk),
-	CLK(NULL, "pwm0", &pwm0_clk),
-	CLK(NULL, "pwm1", &pwm1_clk),
-	CLK(NULL, "pwm2", &pwm2_clk),
-	CLK(NULL, "pwm3", &pwm3_clk),
-	CLK(NULL, "timer0", &timer0_clk),
-	CLK(NULL, "timer1", &timer1_clk),
-	CLK("davinci-wdt", NULL, &timer2_clk),
-	CLK(NULL, "timer3", &timer3_clk),
-	CLK(NULL, "rto", &rto_clk),
-	CLK(NULL, "usb", &usb_clk),
-	CLK(NULL, NULL, NULL),
-};
-#endif
-/*----------------------------------------------------------------------*/
-
 static u64 dm355_spi0_dma_mask = DMA_BIT_MASK(32);
 
 static struct resource dm355_spi0_resources[] = {
@@ -930,8 +582,6 @@ static struct davinci_id dm355_ids[] = {
 	},
 };
 
-static u32 dm355_psc_bases[] = { DAVINCI_PWR_SLEEP_CNTRL_BASE };
-
 /*
  * T0_BOT: Timer 0, bottom:  clockevent source for hrtimers
  * T0_TOP: Timer 0, top   :  clocksource for generic timekeeping
@@ -1016,8 +666,6 @@ static const struct davinci_soc_info davinci_soc_info_dm355 = {
 	.jtag_id_reg		= 0x01c40028,
 	.ids			= dm355_ids,
 	.ids_num		= ARRAY_SIZE(dm355_ids),
-	.psc_bases		= dm355_psc_bases,
-	.psc_bases_num		= ARRAY_SIZE(dm355_psc_bases),
 	.pinmux_base		= DAVINCI_SYSTEM_MODULE_BASE,
 	.pinmux_pins		= dm355_pins,
 	.pinmux_pins_num	= ARRAY_SIZE(dm355_pins),
@@ -1050,16 +698,11 @@ void __init dm355_init(void)
 
 void __init dm355_init_time(void)
 {
-#ifdef CONFIG_COMMON_CLK
 	struct clk *clk;
 
 	clk = clk_register_fixed_rate(NULL, "ref_clk", NULL, 0, DM355_REF_FREQ);
 
 	davinci_timer_init(clk);
-#else
-	davinci_clk_init(dm355_clks);
-	davinci_timer_init(&timer0_clk);
-#endif
 }
 
 static struct resource dm355_pll1_resources[] = {
Signature · 1 line
2.7.4
author maintainer
#47 lore raw

PATCH v7 35/42 ARM: davinci: dm365: Remove legacy clock init

In reply to David Lechner

This removes the unused legacy clock init code from arch/arm/mach-davinci/dm365.c.

---

v7 changes:
- rebased
- add davinci prefix to commit message

v6 changes:
- rebased

 arch/arm/mach-davinci/dm365.c | 449 ------------------------------------------
 1 file changed, 449 deletions(-)
arch/arm/mach-davinci/dm365.c +0 -449
index 93067e1..aa458a9 100644
@@ -37,11 +37,6 @@
 #include "davinci.h"
 #include "mux.h"
 
-#ifndef CONFIG_COMMON_CLK
-#include "clock.h"
-#include "psc.h"
-#endif
-
 #define DM365_REF_FREQ		24000000	/* 24 MHz on the DM365 EVM */
 #define DM365_RTC_BASE			0x01c69000
 #define DM365_KEYSCAN_BASE		0x01c69400
@@ -57,441 +52,6 @@
 #define DM365_EMAC_CNTRL_RAM_OFFSET	0x1000
 #define DM365_EMAC_CNTRL_RAM_SIZE	0x2000
 
-#ifndef CONFIG_COMMON_CLK
-static struct pll_data pll1_data = {
-	.num		= 1,
-	.phys_base	= DAVINCI_PLL1_BASE,
-	.flags		= PLL_HAS_POSTDIV | PLL_HAS_PREDIV,
-};
-
-static struct pll_data pll2_data = {
-	.num		= 2,
-	.phys_base	= DAVINCI_PLL2_BASE,
-	.flags		= PLL_HAS_POSTDIV | PLL_HAS_PREDIV,
-};
-
-static struct clk ref_clk = {
-	.name		= "ref_clk",
-	.rate		= DM365_REF_FREQ,
-};
-
-static struct clk pll1_clk = {
-	.name		= "pll1",
-	.parent		= &ref_clk,
-	.flags		= CLK_PLL,
-	.pll_data	= &pll1_data,
-};
-
-static struct clk pll1_aux_clk = {
-	.name		= "pll1_aux_clk",
-	.parent		= &pll1_clk,
-	.flags		= CLK_PLL | PRE_PLL,
-};
-
-static struct clk pll1_sysclkbp = {
-	.name		= "pll1_sysclkbp",
-	.parent		= &pll1_clk,
-	.flags 		= CLK_PLL | PRE_PLL,
-	.div_reg	= BPDIV
-};
-
-static struct clk clkout0_clk = {
-	.name		= "clkout0",
-	.parent		= &pll1_clk,
-	.flags		= CLK_PLL | PRE_PLL,
-};
-
-static struct clk pll1_sysclk1 = {
-	.name		= "pll1_sysclk1",
-	.parent		= &pll1_clk,
-	.flags		= CLK_PLL,
-	.div_reg	= PLLDIV1,
-};
-
-static struct clk pll1_sysclk2 = {
-	.name		= "pll1_sysclk2",
-	.parent		= &pll1_clk,
-	.flags		= CLK_PLL,
-	.div_reg	= PLLDIV2,
-};
-
-static struct clk pll1_sysclk3 = {
-	.name		= "pll1_sysclk3",
-	.parent		= &pll1_clk,
-	.flags		= CLK_PLL,
-	.div_reg	= PLLDIV3,
-};
-
-static struct clk pll1_sysclk4 = {
-	.name		= "pll1_sysclk4",
-	.parent		= &pll1_clk,
-	.flags		= CLK_PLL,
-	.div_reg	= PLLDIV4,
-};
-
-static struct clk pll1_sysclk5 = {
-	.name		= "pll1_sysclk5",
-	.parent		= &pll1_clk,
-	.flags		= CLK_PLL,
-	.div_reg	= PLLDIV5,
-};
-
-static struct clk pll1_sysclk6 = {
-	.name		= "pll1_sysclk6",
-	.parent		= &pll1_clk,
-	.flags		= CLK_PLL,
-	.div_reg	= PLLDIV6,
-};
-
-static struct clk pll1_sysclk7 = {
-	.name		= "pll1_sysclk7",
-	.parent		= &pll1_clk,
-	.flags		= CLK_PLL,
-	.div_reg	= PLLDIV7,
-};
-
-static struct clk pll1_sysclk8 = {
-	.name		= "pll1_sysclk8",
-	.parent		= &pll1_clk,
-	.flags		= CLK_PLL,
-	.div_reg	= PLLDIV8,
-};
-
-static struct clk pll1_sysclk9 = {
-	.name		= "pll1_sysclk9",
-	.parent		= &pll1_clk,
-	.flags		= CLK_PLL,
-	.div_reg	= PLLDIV9,
-};
-
-static struct clk pll2_clk = {
-	.name		= "pll2",
-	.parent		= &ref_clk,
-	.flags		= CLK_PLL,
-	.pll_data	= &pll2_data,
-};
-
-static struct clk pll2_aux_clk = {
-	.name		= "pll2_aux_clk",
-	.parent		= &pll2_clk,
-	.flags		= CLK_PLL | PRE_PLL,
-};
-
-static struct clk clkout1_clk = {
-	.name		= "clkout1",
-	.parent		= &pll2_clk,
-	.flags		= CLK_PLL | PRE_PLL,
-};
-
-static struct clk pll2_sysclk1 = {
-	.name		= "pll2_sysclk1",
-	.parent		= &pll2_clk,
-	.flags		= CLK_PLL,
-	.div_reg	= PLLDIV1,
-};
-
-static struct clk pll2_sysclk2 = {
-	.name		= "pll2_sysclk2",
-	.parent		= &pll2_clk,
-	.flags		= CLK_PLL,
-	.div_reg	= PLLDIV2,
-};
-
-static struct clk pll2_sysclk3 = {
-	.name		= "pll2_sysclk3",
-	.parent		= &pll2_clk,
-	.flags		= CLK_PLL,
-	.div_reg	= PLLDIV3,
-};
-
-static struct clk pll2_sysclk4 = {
-	.name		= "pll2_sysclk4",
-	.parent		= &pll2_clk,
-	.flags		= CLK_PLL,
-	.div_reg	= PLLDIV4,
-};
-
-static struct clk pll2_sysclk5 = {
-	.name		= "pll2_sysclk5",
-	.parent		= &pll2_clk,
-	.flags		= CLK_PLL,
-	.div_reg	= PLLDIV5,
-};
-
-static struct clk pll2_sysclk6 = {
-	.name		= "pll2_sysclk6",
-	.parent		= &pll2_clk,
-	.flags		= CLK_PLL,
-	.div_reg	= PLLDIV6,
-};
-
-static struct clk pll2_sysclk7 = {
-	.name		= "pll2_sysclk7",
-	.parent		= &pll2_clk,
-	.flags		= CLK_PLL,
-	.div_reg	= PLLDIV7,
-};
-
-static struct clk pll2_sysclk8 = {
-	.name		= "pll2_sysclk8",
-	.parent		= &pll2_clk,
-	.flags		= CLK_PLL,
-	.div_reg	= PLLDIV8,
-};
-
-static struct clk pll2_sysclk9 = {
-	.name		= "pll2_sysclk9",
-	.parent		= &pll2_clk,
-	.flags		= CLK_PLL,
-	.div_reg	= PLLDIV9,
-};
-
-static struct clk vpss_dac_clk = {
-	.name		= "vpss_dac",
-	.parent		= &pll1_sysclk3,
-	.lpsc		= DM365_LPSC_DAC_CLK,
-};
-
-static struct clk vpss_master_clk = {
-	.name		= "vpss_master",
-	.parent		= &pll1_sysclk5,
-	.lpsc		= DM365_LPSC_VPSSMSTR,
-	.flags		= CLK_PSC,
-};
-
-static struct clk vpss_slave_clk = {
-	.name		= "vpss_slave",
-	.parent		= &pll1_sysclk5,
-	.lpsc		= DAVINCI_LPSC_VPSSSLV,
-};
-
-static struct clk arm_clk = {
-	.name		= "arm_clk",
-	.parent		= &pll2_sysclk2,
-	.lpsc		= DAVINCI_LPSC_ARM,
-	.flags		= ALWAYS_ENABLED,
-};
-
-static struct clk uart0_clk = {
-	.name		= "uart0",
-	.parent		= &pll1_aux_clk,
-	.lpsc		= DAVINCI_LPSC_UART0,
-};
-
-static struct clk uart1_clk = {
-	.name		= "uart1",
-	.parent		= &pll1_sysclk4,
-	.lpsc		= DAVINCI_LPSC_UART1,
-};
-
-static struct clk i2c_clk = {
-	.name		= "i2c",
-	.parent		= &pll1_aux_clk,
-	.lpsc		= DAVINCI_LPSC_I2C,
-};
-
-static struct clk mmcsd0_clk = {
-	.name		= "mmcsd0",
-	.parent		= &pll1_sysclk8,
-	.lpsc		= DAVINCI_LPSC_MMC_SD,
-};
-
-static struct clk mmcsd1_clk = {
-	.name		= "mmcsd1",
-	.parent		= &pll1_sysclk4,
-	.lpsc		= DM365_LPSC_MMC_SD1,
-};
-
-static struct clk spi0_clk = {
-	.name		= "spi0",
-	.parent		= &pll1_sysclk4,
-	.lpsc		= DAVINCI_LPSC_SPI,
-};
-
-static struct clk spi1_clk = {
-	.name		= "spi1",
-	.parent		= &pll1_sysclk4,
-	.lpsc		= DM365_LPSC_SPI1,
-};
-
-static struct clk spi2_clk = {
-	.name		= "spi2",
-	.parent		= &pll1_sysclk4,
-	.lpsc		= DM365_LPSC_SPI2,
-};
-
-static struct clk spi3_clk = {
-	.name		= "spi3",
-	.parent		= &pll1_sysclk4,
-	.lpsc		= DM365_LPSC_SPI3,
-};
-
-static struct clk spi4_clk = {
-	.name		= "spi4",
-	.parent		= &pll1_aux_clk,
-	.lpsc		= DM365_LPSC_SPI4,
-};
-
-static struct clk gpio_clk = {
-	.name		= "gpio",
-	.parent		= &pll1_sysclk4,
-	.lpsc		= DAVINCI_LPSC_GPIO,
-};
-
-static struct clk aemif_clk = {
-	.name		= "aemif",
-	.parent		= &pll1_sysclk4,
-	.lpsc		= DAVINCI_LPSC_AEMIF,
-};
-
-static struct clk pwm0_clk = {
-	.name		= "pwm0",
-	.parent		= &pll1_aux_clk,
-	.lpsc		= DAVINCI_LPSC_PWM0,
-};
-
-static struct clk pwm1_clk = {
-	.name		= "pwm1",
-	.parent		= &pll1_aux_clk,
-	.lpsc		= DAVINCI_LPSC_PWM1,
-};
-
-static struct clk pwm2_clk = {
-	.name		= "pwm2",
-	.parent		= &pll1_aux_clk,
-	.lpsc		= DAVINCI_LPSC_PWM2,
-};
-
-static struct clk pwm3_clk = {
-	.name		= "pwm3",
-	.parent		= &ref_clk,
-	.lpsc		= DM365_LPSC_PWM3,
-};
-
-static struct clk timer0_clk = {
-	.name		= "timer0",
-	.parent		= &pll1_aux_clk,
-	.lpsc		= DAVINCI_LPSC_TIMER0,
-};
-
-static struct clk timer1_clk = {
-	.name		= "timer1",
-	.parent		= &pll1_aux_clk,
-	.lpsc		= DAVINCI_LPSC_TIMER1,
-};
-
-static struct clk timer2_clk = {
-	.name		= "timer2",
-	.parent		= &pll1_aux_clk,
-	.lpsc		= DAVINCI_LPSC_TIMER2,
-	.usecount	= 1,
-};
-
-static struct clk timer3_clk = {
-	.name		= "timer3",
-	.parent		= &pll1_aux_clk,
-	.lpsc		= DM365_LPSC_TIMER3,
-};
-
-static struct clk usb_clk = {
-	.name		= "usb",
-	.parent		= &pll1_aux_clk,
-	.lpsc		= DAVINCI_LPSC_USB,
-};
-
-static struct clk emac_clk = {
-	.name		= "emac",
-	.parent		= &pll1_sysclk4,
-	.lpsc		= DM365_LPSC_EMAC,
-};
-
-static struct clk voicecodec_clk = {
-	.name		= "voice_codec",
-	.parent		= &pll2_sysclk4,
-	.lpsc		= DM365_LPSC_VOICE_CODEC,
-};
-
-static struct clk asp0_clk = {
-	.name		= "asp0",
-	.parent		= &pll1_sysclk4,
-	.lpsc		= DM365_LPSC_McBSP1,
-};
-
-static struct clk rto_clk = {
-	.name		= "rto",
-	.parent		= &pll1_sysclk4,
-	.lpsc		= DM365_LPSC_RTO,
-};
-
-static struct clk mjcp_clk = {
-	.name		= "mjcp",
-	.parent		= &pll1_sysclk3,
-	.lpsc		= DM365_LPSC_MJCP,
-};
-
-static struct clk_lookup dm365_clks[] = {
-	CLK(NULL, "ref", &ref_clk),
-	CLK(NULL, "pll1", &pll1_clk),
-	CLK(NULL, "pll1_aux", &pll1_aux_clk),
-	CLK(NULL, "pll1_sysclkbp", &pll1_sysclkbp),
-	CLK(NULL, "clkout0", &clkout0_clk),
-	CLK(NULL, "pll1_sysclk1", &pll1_sysclk1),
-	CLK(NULL, "pll1_sysclk2", &pll1_sysclk2),
-	CLK(NULL, "pll1_sysclk3", &pll1_sysclk3),
-	CLK(NULL, "pll1_sysclk4", &pll1_sysclk4),
-	CLK(NULL, "pll1_sysclk5", &pll1_sysclk5),
-	CLK(NULL, "pll1_sysclk6", &pll1_sysclk6),
-	CLK(NULL, "pll1_sysclk7", &pll1_sysclk7),
-	CLK(NULL, "pll1_sysclk8", &pll1_sysclk8),
-	CLK(NULL, "pll1_sysclk9", &pll1_sysclk9),
-	CLK(NULL, "pll2", &pll2_clk),
-	CLK(NULL, "pll2_aux", &pll2_aux_clk),
-	CLK(NULL, "clkout1", &clkout1_clk),
-	CLK(NULL, "pll2_sysclk1", &pll2_sysclk1),
-	CLK(NULL, "pll2_sysclk2", &pll2_sysclk2),
-	CLK(NULL, "pll2_sysclk3", &pll2_sysclk3),
-	CLK(NULL, "pll2_sysclk4", &pll2_sysclk4),
-	CLK(NULL, "pll2_sysclk5", &pll2_sysclk5),
-	CLK(NULL, "pll2_sysclk6", &pll2_sysclk6),
-	CLK(NULL, "pll2_sysclk7", &pll2_sysclk7),
-	CLK(NULL, "pll2_sysclk8", &pll2_sysclk8),
-	CLK(NULL, "pll2_sysclk9", &pll2_sysclk9),
-	CLK(NULL, "vpss_dac", &vpss_dac_clk),
-	CLK("vpss", "master", &vpss_master_clk),
-	CLK("vpss", "slave", &vpss_slave_clk),
-	CLK(NULL, "arm", &arm_clk),
-	CLK("serial8250.0", NULL, &uart0_clk),
-	CLK("serial8250.1", NULL, &uart1_clk),
-	CLK("i2c_davinci.1", NULL, &i2c_clk),
-	CLK("da830-mmc.0", NULL, &mmcsd0_clk),
-	CLK("da830-mmc.1", NULL, &mmcsd1_clk),
-	CLK("spi_davinci.0", NULL, &spi0_clk),
-	CLK("spi_davinci.1", NULL, &spi1_clk),
-	CLK("spi_davinci.2", NULL, &spi2_clk),
-	CLK("spi_davinci.3", NULL, &spi3_clk),
-	CLK("spi_davinci.4", NULL, &spi4_clk),
-	CLK(NULL, "gpio", &gpio_clk),
-	CLK(NULL, "aemif", &aemif_clk),
-	CLK(NULL, "pwm0", &pwm0_clk),
-	CLK(NULL, "pwm1", &pwm1_clk),
-	CLK(NULL, "pwm2", &pwm2_clk),
-	CLK(NULL, "pwm3", &pwm3_clk),
-	CLK(NULL, "timer0", &timer0_clk),
-	CLK(NULL, "timer1", &timer1_clk),
-	CLK("davinci-wdt", NULL, &timer2_clk),
-	CLK(NULL, "timer3", &timer3_clk),
-	CLK(NULL, "usb", &usb_clk),
-	CLK("davinci_emac.1", NULL, &emac_clk),
-	CLK("davinci_mdio.0", "fck", &emac_clk),
-	CLK("davinci_voicecodec", NULL, &voicecodec_clk),
-	CLK("davinci-mcbsp", NULL, &asp0_clk),
-	CLK(NULL, "rto", &rto_clk),
-	CLK(NULL, "mjcp", &mjcp_clk),
-	CLK(NULL, NULL, NULL),
-};
-#endif
-/*----------------------------------------------------------------------*/
-
 #define INTMUX		0x18
 #define EVTMUX		0x1c
 
@@ -1058,8 +618,6 @@ static struct davinci_id dm365_ids[] = {
 	},
 };
 
-static u32 dm365_psc_bases[] = { DAVINCI_PWR_SLEEP_CNTRL_BASE };
-
 static struct davinci_timer_info dm365_timer_info = {
 	.timers		= davinci_timer_instance,
 	.clockevent_id	= T0_BOT,
@@ -1120,8 +678,6 @@ static const struct davinci_soc_info davinci_soc_info_dm365 = {
 	.jtag_id_reg		= 0x01c40028,
 	.ids			= dm365_ids,
 	.ids_num		= ARRAY_SIZE(dm365_ids),
-	.psc_bases		= dm365_psc_bases,
-	.psc_bases_num		= ARRAY_SIZE(dm365_psc_bases),
 	.pinmux_base		= DAVINCI_SYSTEM_MODULE_BASE,
 	.pinmux_pins		= dm365_pins,
 	.pinmux_pins_num	= ARRAY_SIZE(dm365_pins),
@@ -1175,16 +731,11 @@ void __init dm365_init(void)
 
 void __init dm365_init_time(void)
 {
-#ifdef CONFIG_COMMON_CLK
 	struct clk *clk;
 
 	clk = clk_register_fixed_rate(NULL, "ref_clk", NULL, 0, DM365_REF_FREQ);
 
 	davinci_timer_init(clk);
-#else
-	davinci_clk_init(dm365_clks);
-	davinci_timer_init(&timer0_clk);
-#endif
 }
 
 static struct resource dm365_pll1_resources[] = {
Signature · 1 line
2.7.4
author maintainer
#48 lore raw

PATCH v7 36/42 ARM: davinci: dm644x: Remove legacy clock init

In reply to David Lechner

This removes the unused legacy clock init code from arch/arm/mach-davinci/dm644x.c.

---

v7 changes:
- rebased
- add davinci prefix to commit message

v6 changes:
- rebased

 arch/arm/mach-davinci/dm644x.c | 300 -----------------------------------------
 1 file changed, 300 deletions(-)
arch/arm/mach-davinci/dm644x.c +0 -300
index 64f5193..6d3a0e8 100644
@@ -29,11 +29,6 @@
 #include "davinci.h"
 #include "mux.h"
 
-#ifndef CONFIG_COMMON_CLK
-#include "clock.h"
-#include "psc.h"
-#endif
-
 /*
  * Device specific clocks
  */
@@ -46,292 +41,6 @@
 #define DM644X_EMAC_CNTRL_RAM_OFFSET	0x2000
 #define DM644X_EMAC_CNTRL_RAM_SIZE	0x2000
 
-#ifndef CONFIG_COMMON_CLK
-static struct pll_data pll1_data = {
-	.num       = 1,
-	.phys_base = DAVINCI_PLL1_BASE,
-};
-
-static struct pll_data pll2_data = {
-	.num       = 2,
-	.phys_base = DAVINCI_PLL2_BASE,
-};
-
-static struct clk ref_clk = {
-	.name = "ref_clk",
-	.rate = DM644X_REF_FREQ,
-};
-
-static struct clk pll1_clk = {
-	.name = "pll1",
-	.parent = &ref_clk,
-	.pll_data = &pll1_data,
-	.flags = CLK_PLL,
-};
-
-static struct clk pll1_sysclk1 = {
-	.name = "pll1_sysclk1",
-	.parent = &pll1_clk,
-	.flags = CLK_PLL,
-	.div_reg = PLLDIV1,
-};
-
-static struct clk pll1_sysclk2 = {
-	.name = "pll1_sysclk2",
-	.parent = &pll1_clk,
-	.flags = CLK_PLL,
-	.div_reg = PLLDIV2,
-};
-
-static struct clk pll1_sysclk3 = {
-	.name = "pll1_sysclk3",
-	.parent = &pll1_clk,
-	.flags = CLK_PLL,
-	.div_reg = PLLDIV3,
-};
-
-static struct clk pll1_sysclk5 = {
-	.name = "pll1_sysclk5",
-	.parent = &pll1_clk,
-	.flags = CLK_PLL,
-	.div_reg = PLLDIV5,
-};
-
-static struct clk pll1_aux_clk = {
-	.name = "pll1_aux_clk",
-	.parent = &pll1_clk,
-	.flags = CLK_PLL | PRE_PLL,
-};
-
-static struct clk pll1_sysclkbp = {
-	.name = "pll1_sysclkbp",
-	.parent = &pll1_clk,
-	.flags = CLK_PLL | PRE_PLL,
-	.div_reg = BPDIV
-};
-
-static struct clk pll2_clk = {
-	.name = "pll2",
-	.parent = &ref_clk,
-	.pll_data = &pll2_data,
-	.flags = CLK_PLL,
-};
-
-static struct clk pll2_sysclk1 = {
-	.name = "pll2_sysclk1",
-	.parent = &pll2_clk,
-	.flags = CLK_PLL,
-	.div_reg = PLLDIV1,
-};
-
-static struct clk pll2_sysclk2 = {
-	.name = "pll2_sysclk2",
-	.parent = &pll2_clk,
-	.flags = CLK_PLL,
-	.div_reg = PLLDIV2,
-};
-
-static struct clk pll2_sysclkbp = {
-	.name = "pll2_sysclkbp",
-	.parent = &pll2_clk,
-	.flags = CLK_PLL | PRE_PLL,
-	.div_reg = BPDIV
-};
-
-static struct clk dsp_clk = {
-	.name = "dsp",
-	.parent = &pll1_sysclk1,
-	.lpsc = DAVINCI_LPSC_GEM,
-	.domain = DAVINCI_GPSC_DSPDOMAIN,
-	.usecount = 1,			/* REVISIT how to disable? */
-};
-
-static struct clk arm_clk = {
-	.name = "arm",
-	.parent = &pll1_sysclk2,
-	.lpsc = DAVINCI_LPSC_ARM,
-	.flags = ALWAYS_ENABLED,
-};
-
-static struct clk vicp_clk = {
-	.name = "vicp",
-	.parent = &pll1_sysclk2,
-	.lpsc = DAVINCI_LPSC_IMCOP,
-	.domain = DAVINCI_GPSC_DSPDOMAIN,
-	.usecount = 1,			/* REVISIT how to disable? */
-};
-
-static struct clk vpss_master_clk = {
-	.name = "vpss_master",
-	.parent = &pll1_sysclk3,
-	.lpsc = DAVINCI_LPSC_VPSSMSTR,
-	.flags = CLK_PSC,
-};
-
-static struct clk vpss_slave_clk = {
-	.name = "vpss_slave",
-	.parent = &pll1_sysclk3,
-	.lpsc = DAVINCI_LPSC_VPSSSLV,
-};
-
-static struct clk uart0_clk = {
-	.name = "uart0",
-	.parent = &pll1_aux_clk,
-	.lpsc = DAVINCI_LPSC_UART0,
-};
-
-static struct clk uart1_clk = {
-	.name = "uart1",
-	.parent = &pll1_aux_clk,
-	.lpsc = DAVINCI_LPSC_UART1,
-};
-
-static struct clk uart2_clk = {
-	.name = "uart2",
-	.parent = &pll1_aux_clk,
-	.lpsc = DAVINCI_LPSC_UART2,
-};
-
-static struct clk emac_clk = {
-	.name = "emac",
-	.parent = &pll1_sysclk5,
-	.lpsc = DAVINCI_LPSC_EMAC_WRAPPER,
-};
-
-static struct clk i2c_clk = {
-	.name = "i2c",
-	.parent = &pll1_aux_clk,
-	.lpsc = DAVINCI_LPSC_I2C,
-};
-
-static struct clk ide_clk = {
-	.name = "ide",
-	.parent = &pll1_sysclk5,
-	.lpsc = DAVINCI_LPSC_ATA,
-};
-
-static struct clk asp_clk = {
-	.name = "asp0",
-	.parent = &pll1_sysclk5,
-	.lpsc = DAVINCI_LPSC_McBSP,
-};
-
-static struct clk mmcsd_clk = {
-	.name = "mmcsd",
-	.parent = &pll1_sysclk5,
-	.lpsc = DAVINCI_LPSC_MMC_SD,
-};
-
-static struct clk spi_clk = {
-	.name = "spi",
-	.parent = &pll1_sysclk5,
-	.lpsc = DAVINCI_LPSC_SPI,
-};
-
-static struct clk gpio_clk = {
-	.name = "gpio",
-	.parent = &pll1_sysclk5,
-	.lpsc = DAVINCI_LPSC_GPIO,
-};
-
-static struct clk usb_clk = {
-	.name = "usb",
-	.parent = &pll1_sysclk5,
-	.lpsc = DAVINCI_LPSC_USB,
-};
-
-static struct clk vlynq_clk = {
-	.name = "vlynq",
-	.parent = &pll1_sysclk5,
-	.lpsc = DAVINCI_LPSC_VLYNQ,
-};
-
-static struct clk aemif_clk = {
-	.name = "aemif",
-	.parent = &pll1_sysclk5,
-	.lpsc = DAVINCI_LPSC_AEMIF,
-};
-
-static struct clk pwm0_clk = {
-	.name = "pwm0",
-	.parent = &pll1_aux_clk,
-	.lpsc = DAVINCI_LPSC_PWM0,
-};
-
-static struct clk pwm1_clk = {
-	.name = "pwm1",
-	.parent = &pll1_aux_clk,
-	.lpsc = DAVINCI_LPSC_PWM1,
-};
-
-static struct clk pwm2_clk = {
-	.name = "pwm2",
-	.parent = &pll1_aux_clk,
-	.lpsc = DAVINCI_LPSC_PWM2,
-};
-
-static struct clk timer0_clk = {
-	.name = "timer0",
-	.parent = &pll1_aux_clk,
-	.lpsc = DAVINCI_LPSC_TIMER0,
-};
-
-static struct clk timer1_clk = {
-	.name = "timer1",
-	.parent = &pll1_aux_clk,
-	.lpsc = DAVINCI_LPSC_TIMER1,
-};
-
-static struct clk timer2_clk = {
-	.name = "timer2",
-	.parent = &pll1_aux_clk,
-	.lpsc = DAVINCI_LPSC_TIMER2,
-	.usecount = 1,              /* REVISIT: why can't this be disabled? */
-};
-
-static struct clk_lookup dm644x_clks[] = {
-	CLK(NULL, "ref", &ref_clk),
-	CLK(NULL, "pll1", &pll1_clk),
-	CLK(NULL, "pll1_sysclk1", &pll1_sysclk1),
-	CLK(NULL, "pll1_sysclk2", &pll1_sysclk2),
-	CLK(NULL, "pll1_sysclk3", &pll1_sysclk3),
-	CLK(NULL, "pll1_sysclk5", &pll1_sysclk5),
-	CLK(NULL, "pll1_aux", &pll1_aux_clk),
-	CLK(NULL, "pll1_sysclkbp", &pll1_sysclkbp),
-	CLK(NULL, "pll2", &pll2_clk),
-	CLK(NULL, "pll2_sysclk1", &pll2_sysclk1),
-	CLK(NULL, "pll2_sysclk2", &pll2_sysclk2),
-	CLK(NULL, "pll2_sysclkbp", &pll2_sysclkbp),
-	CLK(NULL, "dsp", &dsp_clk),
-	CLK(NULL, "arm", &arm_clk),
-	CLK(NULL, "vicp", &vicp_clk),
-	CLK("vpss", "master", &vpss_master_clk),
-	CLK("vpss", "slave", &vpss_slave_clk),
-	CLK(NULL, "arm", &arm_clk),
-	CLK("serial8250.0", NULL, &uart0_clk),
-	CLK("serial8250.1", NULL, &uart1_clk),
-	CLK("serial8250.2", NULL, &uart2_clk),
-	CLK("davinci_emac.1", NULL, &emac_clk),
-	CLK("davinci_mdio.0", "fck", &emac_clk),
-	CLK("i2c_davinci.1", NULL, &i2c_clk),
-	CLK("palm_bk3710", NULL, &ide_clk),
-	CLK("davinci-mcbsp", NULL, &asp_clk),
-	CLK("dm6441-mmc.0", NULL, &mmcsd_clk),
-	CLK(NULL, "spi", &spi_clk),
-	CLK(NULL, "gpio", &gpio_clk),
-	CLK(NULL, "usb", &usb_clk),
-	CLK(NULL, "vlynq", &vlynq_clk),
-	CLK(NULL, "aemif", &aemif_clk),
-	CLK(NULL, "pwm0", &pwm0_clk),
-	CLK(NULL, "pwm1", &pwm1_clk),
-	CLK(NULL, "pwm2", &pwm2_clk),
-	CLK(NULL, "timer0", &timer0_clk),
-	CLK(NULL, "timer1", &timer1_clk),
-	CLK("davinci-wdt", NULL, &timer2_clk),
-	CLK(NULL, NULL, NULL),
-};
-#endif
-
 static struct emac_platform_data dm644x_emac_pdata = {
 	.ctrl_reg_offset	= DM644X_EMAC_CNTRL_OFFSET,
 	.ctrl_mod_reg_offset	= DM644X_EMAC_CNTRL_MOD_OFFSET,
@@ -824,8 +533,6 @@ static struct davinci_id dm644x_ids[] = {
 	},
 };
 
-static u32 dm644x_psc_bases[] = { DAVINCI_PWR_SLEEP_CNTRL_BASE };
-
 /*
  * T0_BOT: Timer 0, bottom:  clockevent source for hrtimers
  * T0_TOP: Timer 0, top   :  clocksource for generic timekeeping
@@ -910,8 +617,6 @@ static const struct davinci_soc_info davinci_soc_info_dm644x = {
 	.jtag_id_reg		= 0x01c40028,
 	.ids			= dm644x_ids,
 	.ids_num		= ARRAY_SIZE(dm644x_ids),
-	.psc_bases		= dm644x_psc_bases,
-	.psc_bases_num		= ARRAY_SIZE(dm644x_psc_bases),
 	.pinmux_base		= DAVINCI_SYSTEM_MODULE_BASE,
 	.pinmux_pins		= dm644x_pins,
 	.pinmux_pins_num	= ARRAY_SIZE(dm644x_pins),
@@ -939,16 +644,11 @@ void __init dm644x_init(void)
 
 void __init dm644x_init_time(void)
 {
-#ifdef CONFIG_COMMON_CLK
 	struct clk *clk;
 
 	clk = clk_register_fixed_rate(NULL, "ref_clk", NULL, 0, DM644X_REF_FREQ);
 
 	davinci_timer_init(clk);
-#else
-	davinci_clk_init(dm644x_clks);
-	davinci_timer_init(&timer0_clk);
-#endif
 }
 
 static struct resource dm644x_pll1_resources[] = {
Signature · 1 line
2.7.4
author maintainer
#49 lore raw

PATCH v7 37/42 ARM: davinci: dm646x: Remove legacy clock init

In reply to David Lechner

This removes the unused legacy clock init code from arch/arm/mach-davinci/dm646x.c.

---

v7 changes:
- rebased
- add davinci prefix to commit message

v6 changes:
- rebased

 arch/arm/mach-davinci/dm646x.c | 329 -----------------------------------------
 1 file changed, 329 deletions(-)
arch/arm/mach-davinci/dm646x.c +0 -329
index 22e8dda..0cf0ab9 100644
@@ -30,11 +30,6 @@
 #include "davinci.h"
 #include "mux.h"
 
-#ifndef CONFIG_COMMON_CLK
-#include "clock.h"
-#include "psc.h"
-#endif
-
 #define DAVINCI_VPIF_BASE       (0x01C12000)
 
 #define VDD3P3V_VID_MASK	(BIT_MASK(3) | BIT_MASK(2) | BIT_MASK(1) |\
@@ -49,319 +44,6 @@
 #define DM646X_EMAC_CNTRL_RAM_OFFSET	0x2000
 #define DM646X_EMAC_CNTRL_RAM_SIZE	0x2000
 
-#ifndef CONFIG_COMMON_CLK
-static struct pll_data pll1_data = {
-	.num       = 1,
-	.phys_base = DAVINCI_PLL1_BASE,
-};
-
-static struct pll_data pll2_data = {
-	.num       = 2,
-	.phys_base = DAVINCI_PLL2_BASE,
-};
-
-static struct clk ref_clk = {
-	.name = "ref_clk",
-	/* rate is initialized in dm646x_init_time() */
-};
-
-static struct clk aux_clkin = {
-	.name = "aux_clkin",
-	/* rate is initialized in dm646x_init_time() */
-};
-
-static struct clk pll1_clk = {
-	.name = "pll1",
-	.parent = &ref_clk,
-	.pll_data = &pll1_data,
-	.flags = CLK_PLL,
-};
-
-static struct clk pll1_sysclk1 = {
-	.name = "pll1_sysclk1",
-	.parent = &pll1_clk,
-	.flags = CLK_PLL,
-	.div_reg = PLLDIV1,
-};
-
-static struct clk pll1_sysclk2 = {
-	.name = "pll1_sysclk2",
-	.parent = &pll1_clk,
-	.flags = CLK_PLL,
-	.div_reg = PLLDIV2,
-};
-
-static struct clk pll1_sysclk3 = {
-	.name = "pll1_sysclk3",
-	.parent = &pll1_clk,
-	.flags = CLK_PLL,
-	.div_reg = PLLDIV3,
-};
-
-static struct clk pll1_sysclk4 = {
-	.name = "pll1_sysclk4",
-	.parent = &pll1_clk,
-	.flags = CLK_PLL,
-	.div_reg = PLLDIV4,
-};
-
-static struct clk pll1_sysclk5 = {
-	.name = "pll1_sysclk5",
-	.parent = &pll1_clk,
-	.flags = CLK_PLL,
-	.div_reg = PLLDIV5,
-};
-
-static struct clk pll1_sysclk6 = {
-	.name = "pll1_sysclk6",
-	.parent = &pll1_clk,
-	.flags = CLK_PLL,
-	.div_reg = PLLDIV6,
-};
-
-static struct clk pll1_sysclk8 = {
-	.name = "pll1_sysclk8",
-	.parent = &pll1_clk,
-	.flags = CLK_PLL,
-	.div_reg = PLLDIV8,
-};
-
-static struct clk pll1_sysclk9 = {
-	.name = "pll1_sysclk9",
-	.parent = &pll1_clk,
-	.flags = CLK_PLL,
-	.div_reg = PLLDIV9,
-};
-
-static struct clk pll1_sysclkbp = {
-	.name = "pll1_sysclkbp",
-	.parent = &pll1_clk,
-	.flags = CLK_PLL | PRE_PLL,
-	.div_reg = BPDIV,
-};
-
-static struct clk pll1_aux_clk = {
-	.name = "pll1_aux_clk",
-	.parent = &pll1_clk,
-	.flags = CLK_PLL | PRE_PLL,
-};
-
-static struct clk pll2_clk = {
-	.name = "pll2_clk",
-	.parent = &ref_clk,
-	.pll_data = &pll2_data,
-	.flags = CLK_PLL,
-};
-
-static struct clk pll2_sysclk1 = {
-	.name = "pll2_sysclk1",
-	.parent = &pll2_clk,
-	.flags = CLK_PLL,
-	.div_reg = PLLDIV1,
-};
-
-static struct clk dsp_clk = {
-	.name = "dsp",
-	.parent = &pll1_sysclk1,
-	.lpsc = DM646X_LPSC_C64X_CPU,
-	.usecount = 1,			/* REVISIT how to disable? */
-};
-
-static struct clk arm_clk = {
-	.name = "arm",
-	.parent = &pll1_sysclk2,
-	.lpsc = DM646X_LPSC_ARM,
-	.flags = ALWAYS_ENABLED,
-};
-
-static struct clk edma_cc_clk = {
-	.name = "edma_cc",
-	.parent = &pll1_sysclk2,
-	.lpsc = DM646X_LPSC_TPCC,
-	.flags = ALWAYS_ENABLED,
-};
-
-static struct clk edma_tc0_clk = {
-	.name = "edma_tc0",
-	.parent = &pll1_sysclk2,
-	.lpsc = DM646X_LPSC_TPTC0,
-	.flags = ALWAYS_ENABLED,
-};
-
-static struct clk edma_tc1_clk = {
-	.name = "edma_tc1",
-	.parent = &pll1_sysclk2,
-	.lpsc = DM646X_LPSC_TPTC1,
-	.flags = ALWAYS_ENABLED,
-};
-
-static struct clk edma_tc2_clk = {
-	.name = "edma_tc2",
-	.parent = &pll1_sysclk2,
-	.lpsc = DM646X_LPSC_TPTC2,
-	.flags = ALWAYS_ENABLED,
-};
-
-static struct clk edma_tc3_clk = {
-	.name = "edma_tc3",
-	.parent = &pll1_sysclk2,
-	.lpsc = DM646X_LPSC_TPTC3,
-	.flags = ALWAYS_ENABLED,
-};
-
-static struct clk uart0_clk = {
-	.name = "uart0",
-	.parent = &aux_clkin,
-	.lpsc = DM646X_LPSC_UART0,
-};
-
-static struct clk uart1_clk = {
-	.name = "uart1",
-	.parent = &aux_clkin,
-	.lpsc = DM646X_LPSC_UART1,
-};
-
-static struct clk uart2_clk = {
-	.name = "uart2",
-	.parent = &aux_clkin,
-	.lpsc = DM646X_LPSC_UART2,
-};
-
-static struct clk i2c_clk = {
-	.name = "I2CCLK",
-	.parent = &pll1_sysclk3,
-	.lpsc = DM646X_LPSC_I2C,
-};
-
-static struct clk gpio_clk = {
-	.name = "gpio",
-	.parent = &pll1_sysclk3,
-	.lpsc = DM646X_LPSC_GPIO,
-};
-
-static struct clk mcasp0_clk = {
-	.name = "mcasp0",
-	.parent = &pll1_sysclk3,
-	.lpsc = DM646X_LPSC_McASP0,
-};
-
-static struct clk mcasp1_clk = {
-	.name = "mcasp1",
-	.parent = &pll1_sysclk3,
-	.lpsc = DM646X_LPSC_McASP1,
-};
-
-static struct clk aemif_clk = {
-	.name = "aemif",
-	.parent = &pll1_sysclk3,
-	.lpsc = DM646X_LPSC_AEMIF,
-	.flags = ALWAYS_ENABLED,
-};
-
-static struct clk emac_clk = {
-	.name = "emac",
-	.parent = &pll1_sysclk3,
-	.lpsc = DM646X_LPSC_EMAC,
-};
-
-static struct clk pwm0_clk = {
-	.name = "pwm0",
-	.parent = &pll1_sysclk3,
-	.lpsc = DM646X_LPSC_PWM0,
-	.usecount = 1,            /* REVIST: disabling hangs system */
-};
-
-static struct clk pwm1_clk = {
-	.name = "pwm1",
-	.parent = &pll1_sysclk3,
-	.lpsc = DM646X_LPSC_PWM1,
-	.usecount = 1,            /* REVIST: disabling hangs system */
-};
-
-static struct clk timer0_clk = {
-	.name = "timer0",
-	.parent = &pll1_sysclk3,
-	.lpsc = DM646X_LPSC_TIMER0,
-};
-
-static struct clk timer1_clk = {
-	.name = "timer1",
-	.parent = &pll1_sysclk3,
-	.lpsc = DM646X_LPSC_TIMER1,
-};
-
-static struct clk timer2_clk = {
-	.name = "timer2",
-	.parent = &pll1_sysclk3,
-	.flags = ALWAYS_ENABLED, /* no LPSC, always enabled; c.f. spruep9a */
-};
-
-
-static struct clk ide_clk = {
-	.name = "ide",
-	.parent = &pll1_sysclk4,
-	.lpsc = DAVINCI_LPSC_ATA,
-};
-
-static struct clk vpif0_clk = {
-	.name = "vpif0",
-	.parent = &ref_clk,
-	.lpsc = DM646X_LPSC_VPSSMSTR,
-	.flags = ALWAYS_ENABLED,
-};
-
-static struct clk vpif1_clk = {
-	.name = "vpif1",
-	.parent = &ref_clk,
-	.lpsc = DM646X_LPSC_VPSSSLV,
-	.flags = ALWAYS_ENABLED,
-};
-
-static struct clk_lookup dm646x_clks[] = {
-	CLK(NULL, "ref", &ref_clk),
-	CLK(NULL, "aux", &aux_clkin),
-	CLK(NULL, "pll1", &pll1_clk),
-	CLK(NULL, "pll1_sysclk", &pll1_sysclk1),
-	CLK(NULL, "pll1_sysclk", &pll1_sysclk2),
-	CLK(NULL, "pll1_sysclk", &pll1_sysclk3),
-	CLK(NULL, "pll1_sysclk", &pll1_sysclk4),
-	CLK(NULL, "pll1_sysclk", &pll1_sysclk5),
-	CLK(NULL, "pll1_sysclk", &pll1_sysclk6),
-	CLK(NULL, "pll1_sysclk", &pll1_sysclk8),
-	CLK(NULL, "pll1_sysclk", &pll1_sysclk9),
-	CLK(NULL, "pll1_sysclk", &pll1_sysclkbp),
-	CLK(NULL, "pll1_aux", &pll1_aux_clk),
-	CLK(NULL, "pll2", &pll2_clk),
-	CLK(NULL, "pll2_sysclk1", &pll2_sysclk1),
-	CLK(NULL, "dsp", &dsp_clk),
-	CLK(NULL, "arm", &arm_clk),
-	CLK(NULL, "edma_cc", &edma_cc_clk),
-	CLK(NULL, "edma_tc0", &edma_tc0_clk),
-	CLK(NULL, "edma_tc1", &edma_tc1_clk),
-	CLK(NULL, "edma_tc2", &edma_tc2_clk),
-	CLK(NULL, "edma_tc3", &edma_tc3_clk),
-	CLK("serial8250.0", NULL, &uart0_clk),
-	CLK("serial8250.1", NULL, &uart1_clk),
-	CLK("serial8250.2", NULL, &uart2_clk),
-	CLK("i2c_davinci.1", NULL, &i2c_clk),
-	CLK(NULL, "gpio", &gpio_clk),
-	CLK("davinci-mcasp.0", NULL, &mcasp0_clk),
-	CLK("davinci-mcasp.1", NULL, &mcasp1_clk),
-	CLK(NULL, "aemif", &aemif_clk),
-	CLK("davinci_emac.1", NULL, &emac_clk),
-	CLK("davinci_mdio.0", "fck", &emac_clk),
-	CLK(NULL, "pwm0", &pwm0_clk),
-	CLK(NULL, "pwm1", &pwm1_clk),
-	CLK(NULL, "timer0", &timer0_clk),
-	CLK(NULL, "timer1", &timer1_clk),
-	CLK("davinci-wdt", NULL, &timer2_clk),
-	CLK("palm_bk3710", NULL, &ide_clk),
-	CLK(NULL, "vpif0", &vpif0_clk),
-	CLK(NULL, "vpif1", &vpif1_clk),
-	CLK(NULL, NULL, NULL),
-};
-#endif
-
 static struct emac_platform_data dm646x_emac_pdata = {
 	.ctrl_reg_offset	= DM646X_EMAC_CNTRL_OFFSET,
 	.ctrl_mod_reg_offset	= DM646X_EMAC_CNTRL_MOD_OFFSET,
@@ -800,8 +482,6 @@ static struct davinci_id dm646x_ids[] = {
 	},
 };
 
-static u32 dm646x_psc_bases[] = { DAVINCI_PWR_SLEEP_CNTRL_BASE };
-
 /*
  * T0_BOT: Timer 0, bottom:  clockevent source for hrtimers
  * T0_TOP: Timer 0, top   :  clocksource for generic timekeeping
@@ -886,8 +566,6 @@ static const struct davinci_soc_info davinci_soc_info_dm646x = {
 	.jtag_id_reg		= 0x01c40028,
 	.ids			= dm646x_ids,
 	.ids_num		= ARRAY_SIZE(dm646x_ids),
-	.psc_bases		= dm646x_psc_bases,
-	.psc_bases_num		= ARRAY_SIZE(dm646x_psc_bases),
 	.pinmux_base		= DAVINCI_SYSTEM_MODULE_BASE,
 	.pinmux_pins		= dm646x_pins,
 	.pinmux_pins_num	= ARRAY_SIZE(dm646x_pins),
@@ -958,19 +636,12 @@ void __init dm646x_init(void)
 void __init dm646x_init_time(unsigned long ref_clk_rate,
 			     unsigned long aux_clkin_rate)
 {
-#ifdef CONFIG_COMMON_CLK
 	struct clk *clk;
 
 	clk = clk_register_fixed_rate(NULL, "ref_clk", NULL, 0, ref_clk_rate);
 	clk_register_fixed_rate(NULL, "aux_clkin", NULL, 0, aux_clkin_rate);
 
 	davinci_timer_init(clk);
-#else
-	ref_clk.rate = ref_clk_rate;
-	aux_clkin.rate = aux_clkin_rate;
-	davinci_clk_init(dm646x_clks);
-	davinci_timer_init(&timer0_clk);
-#endif
 }
 
 static struct resource dm646x_pll1_resources[] = {
Signature · 1 line
2.7.4
author maintainer
#50 lore raw

PATCH v7 38/42 ARM: davinci: da8xx: Remove legacy USB and SATA clock init

In reply to David Lechner

This removes the unused legacy USB and SATA clock init code from arch/arm/mach-davinci/{devices,usb}-da8xx}.c.

---

v7 changes:
- rebased
- add davinci prefix to commit message
- mention SATA and USB in commit message

v6 changes:
- rebased

 arch/arm/mach-davinci/devices-da8xx.c      |  29 ----
 arch/arm/mach-davinci/include/mach/da8xx.h |   3 -
 arch/arm/mach-davinci/usb-da8xx.c          | 250 -----------------------------
 3 files changed, 282 deletions(-)
arch/arm/mach-davinci/devices-da8xx.c +0 -29
index c7ec60b..273b6c2 100644
@@ -30,11 +30,6 @@
 #include "cpuidle.h"
 #include "sram.h"
 
-#ifndef CONFIG_COMMON_CLK
-#include <mach/clock.h>
-#include "clock.h"
-#endif
-
 #define DA8XX_TPCC_BASE			0x01c00000
 #define DA8XX_TPTC0_BASE		0x01c08000
 #define DA8XX_TPTC1_BASE		0x01c08400
@@ -1045,29 +1040,6 @@ int __init da8xx_register_spi_bus(int instance, unsigned num_chipselect)
 }
 
 #ifdef CONFIG_ARCH_DAVINCI_DA850
-#ifndef CONFIG_COMMON_CLK
-static struct clk sata_refclk = {
-	.name		= "sata_refclk",
-	.set_rate	= davinci_simple_set_rate,
-};
-
-static struct clk_lookup sata_refclk_lookup =
-		CLK("ahci_da850", "refclk", &sata_refclk);
-
-int __init da850_register_sata_refclk(int rate)
-{
-	int ret;
-
-	sata_refclk.rate = rate;
-	ret = clk_register(&sata_refclk);
-	if (ret)
-		return ret;
-
-	clkdev_add(&sata_refclk_lookup);
-
-	return 0;
-}
-#else
 int __init da850_register_sata_refclk(int rate)
 {
 	struct clk *clk;
@@ -1078,7 +1050,6 @@ int __init da850_register_sata_refclk(int rate)
 
 	return clk_register_clkdev(clk, "refclk", "ahci_da850");
 }
-#endif
 
 static struct resource da850_sata_resources[] = {
 	{
arch/arm/mach-davinci/include/mach/da8xx.h +0 -3
index 5d7b1de..ab4a57f 100644
@@ -103,9 +103,6 @@ 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_usb_phy_clocks(void);
 int da850_register_sata_refclk(int rate);
 int da8xx_register_emac(void);
arch/arm/mach-davinci/usb-da8xx.c +0 -250

274 lines not on this page · raw message

Signature · 1 line
2.7.4
author maintainer
#51 lore raw

PATCH v7 39/42 ARM: davinci: remove legacy clocks

In reply to David Lechner

This removes the unused legacy clock code from arch/arm/mach-davinci/.

---

v7 changes:
- none

v6 changes:
- none

 arch/arm/mach-davinci/clock.c               | 745 ----------------------------
 arch/arm/mach-davinci/clock.h               |  72 ---
 arch/arm/mach-davinci/common.c              |   2 -
 arch/arm/mach-davinci/devices.c             |   1 -
 arch/arm/mach-davinci/include/mach/clock.h  |   3 -
 arch/arm/mach-davinci/include/mach/common.h |   2 -
 arch/arm/mach-davinci/psc.c                 | 137 -----
 arch/arm/mach-davinci/psc.h                 |  10 -
 arch/arm/mach-davinci/time.c                |   2 -
 9 files changed, 974 deletions(-)
 delete mode 100644 arch/arm/mach-davinci/clock.c
 delete mode 100644 arch/arm/mach-davinci/psc.c
arch/arm/mach-davinci/clock.c deleted +0 -745
deleted file mode 100644
index f77a4f7..0000000
@@ -1,745 +0,0 @@
-/*
- * Clock and PLL control for DaVinci devices
- *
- * Copyright (C) 2006-2007 Texas Instruments.
- * Copyright (C) 2008-2009 Deep Root Systems, LLC
- *
- * 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.
- */
-
-#include <linux/module.h>
-#include <linux/kernel.h>
-#include <linux/init.h>
-#include <linux/errno.h>
-#include <linux/clk.h>
-#include <linux/err.h>
-#include <linux/mutex.h>
-#include <linux/io.h>
-#include <linux/delay.h>
-
-#include <mach/hardware.h>
-
-#include <mach/clock.h>
-#include "psc.h"
-#include <mach/cputype.h>
-#include "clock.h"
-
-static LIST_HEAD(clocks);
-static DEFINE_MUTEX(clocks_mutex);
-static DEFINE_SPINLOCK(clockfw_lock);
-
-void davinci_clk_enable(struct clk *clk)
-{
-	if (clk->parent)
-		davinci_clk_enable(clk->parent);
-	if (clk->usecount++ == 0) {
-		if (clk->flags & CLK_PSC)
-			davinci_psc_config(clk->domain, clk->gpsc, clk->lpsc,
-					   true, clk->flags);
-		else if (clk->clk_enable)
-			clk->clk_enable(clk);
-	}
-}
-
-void davinci_clk_disable(struct clk *clk)
-{
-	if (WARN_ON(clk->usecount == 0))
-		return;
-	if (--clk->usecount == 0) {
-		if (!(clk->flags & CLK_PLL) && (clk->flags & CLK_PSC))
-			davinci_psc_config(clk->domain, clk->gpsc, clk->lpsc,
-					   false, clk->flags);
-		else if (clk->clk_disable)
-			clk->clk_disable(clk);
-	}
-	if (clk->parent)
-		davinci_clk_disable(clk->parent);
-}
-
-int davinci_clk_reset(struct clk *clk, bool reset)
-{
-	unsigned long flags;
-
-	if (clk == NULL || IS_ERR(clk))
-		return -EINVAL;
-
-	spin_lock_irqsave(&clockfw_lock, flags);
-	if (clk->flags & CLK_PSC)
-		davinci_psc_reset(clk->gpsc, clk->lpsc, reset);
-	spin_unlock_irqrestore(&clockfw_lock, flags);
-
-	return 0;
-}
-EXPORT_SYMBOL(davinci_clk_reset);
-
-int davinci_clk_reset_assert(struct clk *clk)
-{
-	if (clk == NULL || IS_ERR(clk) || !clk->reset)
-		return -EINVAL;
-
-	return clk->reset(clk, true);
-}
-EXPORT_SYMBOL(davinci_clk_reset_assert);
-
-int davinci_clk_reset_deassert(struct clk *clk)
-{
-	if (clk == NULL || IS_ERR(clk) || !clk->reset)
-		return -EINVAL;
-
-	return clk->reset(clk, false);
-}
-EXPORT_SYMBOL(davinci_clk_reset_deassert);
-
-int clk_enable(struct clk *clk)
-{
-	unsigned long flags;
-
-	if (!clk)
-		return 0;
-	else if (IS_ERR(clk))
-		return -EINVAL;
-
-	spin_lock_irqsave(&clockfw_lock, flags);
-	davinci_clk_enable(clk);
-	spin_unlock_irqrestore(&clockfw_lock, flags);
-
-	return 0;
-}
-EXPORT_SYMBOL(clk_enable);
-
-void clk_disable(struct clk *clk)
-{
-	unsigned long flags;
-
-	if (clk == NULL || IS_ERR(clk))
-		return;
-
-	spin_lock_irqsave(&clockfw_lock, flags);
-	davinci_clk_disable(clk);
-	spin_unlock_irqrestore(&clockfw_lock, flags);
-}
-EXPORT_SYMBOL(clk_disable);
-
-unsigned long clk_get_rate(struct clk *clk)
-{
-	if (clk == NULL || IS_ERR(clk))
-		return 0;
-
-	return clk->rate;
-}
-EXPORT_SYMBOL(clk_get_rate);
-
-long clk_round_rate(struct clk *clk, unsigned long rate)
-{
-	if (clk == NULL || IS_ERR(clk))
-		return 0;
-
-	if (clk->round_rate)
-		return clk->round_rate(clk, rate);
-
-	return clk->rate;
-}
-EXPORT_SYMBOL(clk_round_rate);
-
-/* Propagate rate to children */
-static void propagate_rate(struct clk *root)
-{
-	struct clk *clk;
-
-	list_for_each_entry(clk, &root->children, childnode) {
-		if (clk->recalc)
-			clk->rate = clk->recalc(clk);
-		propagate_rate(clk);
-	}
-}
-
-int clk_set_rate(struct clk *clk, unsigned long rate)
-{
-	unsigned long flags;
-	int ret = -EINVAL;
-
-	if (!clk)
-		return 0;
-	else if (IS_ERR(clk))
-		return -EINVAL;
-
-	if (clk->set_rate)
-		ret = clk->set_rate(clk, rate);
-
-	spin_lock_irqsave(&clockfw_lock, flags);
-	if (ret == 0) {
-		if (clk->recalc)
-			clk->rate = clk->recalc(clk);
-		propagate_rate(clk);
-	}
-	spin_unlock_irqrestore(&clockfw_lock, flags);
-
-	return ret;
-}
-EXPORT_SYMBOL(clk_set_rate);
-
-int clk_set_parent(struct clk *clk, struct clk *parent)
-{
-	unsigned long flags;
-
-	if (!clk)
-		return 0;
-	else if (IS_ERR(clk))
-		return -EINVAL;
-
-	/* Cannot change parent on enabled clock */
-	if (WARN_ON(clk->usecount))
-		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);
-	mutex_unlock(&clocks_mutex);
-
-	spin_lock_irqsave(&clockfw_lock, flags);
-	if (clk->recalc)
-		clk->rate = clk->recalc(clk);
-	propagate_rate(clk);
-	spin_unlock_irqrestore(&clockfw_lock, flags);
-
-	return 0;
-}
-EXPORT_SYMBOL(clk_set_parent);
-
-struct clk *clk_get_parent(struct clk *clk)
-{
-	if (!clk)
-		return NULL;
-
-	return clk->parent;
-}
-EXPORT_SYMBOL(clk_get_parent);
-
-int clk_register(struct clk *clk)
-{
-	if (clk == NULL || IS_ERR(clk))
-		return -EINVAL;
-
-	if (WARN(clk->parent && !clk->parent->rate,
-			"CLK: %s parent %s has no rate!\n",
-			clk->name, clk->parent->name))
-		return -EINVAL;
-
-	INIT_LIST_HEAD(&clk->children);
-
-	mutex_lock(&clocks_mutex);
-	list_add_tail(&clk->node, &clocks);
-	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 */
-	if (clk->rate)
-		return 0;
-
-	/* Else, see if there is a way to calculate it */
-	if (clk->recalc)
-		clk->rate = clk->recalc(clk);
-
-	/* Otherwise, default to parent rate */
-	else if (clk->parent)
-		clk->rate = clk->parent->rate;
-
-	return 0;
-}
-EXPORT_SYMBOL(clk_register);
-
-void clk_unregister(struct clk *clk)
-{
-	if (clk == NULL || IS_ERR(clk))
-		return;
-
-	mutex_lock(&clocks_mutex);
-	list_del(&clk->node);
-	list_del(&clk->childnode);
-	mutex_unlock(&clocks_mutex);
-}
-EXPORT_SYMBOL(clk_unregister);
-
-#ifdef CONFIG_DAVINCI_RESET_CLOCKS
-/*
- * Disable any unused clocks left on by the bootloader
- */
-int __init davinci_clk_disable_unused(void)
-{
-	struct clk *ck;
-
-	spin_lock_irq(&clockfw_lock);
-	list_for_each_entry(ck, &clocks, node) {
-		if (ck->usecount > 0)
-			continue;
-		if (!(ck->flags & CLK_PSC))
-			continue;
-
-		/* ignore if in Disabled or SwRstDisable states */
-		if (!davinci_psc_is_clk_active(ck->gpsc, ck->lpsc))
-			continue;
-
-		pr_debug("Clocks: disable unused %s\n", ck->name);
-
-		davinci_psc_config(ck->domain, ck->gpsc, ck->lpsc,
-				false, ck->flags);
-	}
-	spin_unlock_irq(&clockfw_lock);
-
-	return 0;
-}
-#endif
-
-static unsigned long clk_sysclk_recalc(struct clk *clk)
-{
-	u32 v, plldiv;
-	struct pll_data *pll;
-	unsigned long rate = clk->rate;
-
-	/* If this is the PLL base clock, no more calculations needed */
-	if (clk->pll_data)
-		return rate;
-
-	if (WARN_ON(!clk->parent))
-		return rate;
-
-	rate = clk->parent->rate;
-
-	/* Otherwise, the parent must be a PLL */
-	if (WARN_ON(!clk->parent->pll_data))
-		return rate;
-
-	pll = clk->parent->pll_data;
-
-	/* If pre-PLL, source clock is before the multiplier and divider(s) */
-	if (clk->flags & PRE_PLL)
-		rate = pll->input_rate;
-
-	if (!clk->div_reg)
-		return rate;
-
-	v = __raw_readl(pll->base + clk->div_reg);
-	if (v & PLLDIV_EN) {
-		plldiv = (v & pll->div_ratio_mask) + 1;
-		if (plldiv)
-			rate /= plldiv;
-	}
-
-	return rate;
-}
-
-int davinci_set_sysclk_rate(struct clk *clk, unsigned long rate)
-{
-	unsigned v;
-	struct pll_data *pll;
-	unsigned long input;
-	unsigned ratio = 0;
-
-	/* If this is the PLL base clock, wrong function to call */
-	if (clk->pll_data)
-		return -EINVAL;
-
-	/* There must be a parent... */
-	if (WARN_ON(!clk->parent))
-		return -EINVAL;
-
-	/* ... the parent must be a PLL... */
-	if (WARN_ON(!clk->parent->pll_data))
-		return -EINVAL;
-
-	/* ... and this clock must have a divider. */
-	if (WARN_ON(!clk->div_reg))
-		return -EINVAL;
-
-	pll = clk->parent->pll_data;
-
-	input = clk->parent->rate;
-
-	/* If pre-PLL, source clock is before the multiplier and divider(s) */
-	if (clk->flags & PRE_PLL)
-		input = pll->input_rate;
-
-	if (input > rate) {
-		/*
-		 * Can afford to provide an output little higher than requested
-		 * only if maximum rate supported by hardware on this sysclk
-		 * is known.
-		 */
-		if (clk->maxrate) {
-			ratio = DIV_ROUND_CLOSEST(input, rate);
-			if (input / ratio > clk->maxrate)
-				ratio = 0;
-		}
-
-		if (ratio == 0)
-			ratio = DIV_ROUND_UP(input, rate);
-
-		ratio--;
-	}
-
-	if (ratio > pll->div_ratio_mask)
-		return -EINVAL;
-
-	do {
-		v = __raw_readl(pll->base + PLLSTAT);
-	} while (v & PLLSTAT_GOSTAT);
-
-	v = __raw_readl(pll->base + clk->div_reg);
-	v &= ~pll->div_ratio_mask;
-	v |= ratio | PLLDIV_EN;
-	__raw_writel(v, pll->base + clk->div_reg);
-
-	v = __raw_readl(pll->base + PLLCMD);
-	v |= PLLCMD_GOSET;
-	__raw_writel(v, pll->base + PLLCMD);
-
-	do {
-		v = __raw_readl(pll->base + PLLSTAT);
-	} while (v & PLLSTAT_GOSTAT);
-
-	return 0;
-}
-EXPORT_SYMBOL(davinci_set_sysclk_rate);
-
-static unsigned long clk_leafclk_recalc(struct clk *clk)
-{
-	if (WARN_ON(!clk->parent))
-		return clk->rate;
-
-	return clk->parent->rate;
-}
-
-int davinci_simple_set_rate(struct clk *clk, unsigned long rate)
-{
-	clk->rate = rate;
-	return 0;
-}
-
-static unsigned long clk_pllclk_recalc(struct clk *clk)
-{
-	u32 ctrl, mult = 1, prediv = 1, postdiv = 1;
-	u8 bypass;
-	struct pll_data *pll = clk->pll_data;
-	unsigned long rate = clk->rate;
-
-	ctrl = __raw_readl(pll->base + PLLCTL);
-	rate = pll->input_rate = clk->parent->rate;
-
-	if (ctrl & PLLCTL_PLLEN) {
-		bypass = 0;
-		mult = __raw_readl(pll->base + PLLM);
-		if (cpu_is_davinci_dm365())
-			mult = 2 * (mult & PLLM_PLLM_MASK);
-		else
-			mult = (mult & PLLM_PLLM_MASK) + 1;
-	} else
-		bypass = 1;
-
-	if (pll->flags & PLL_HAS_PREDIV) {
-		prediv = __raw_readl(pll->base + PREDIV);
-		if (prediv & PLLDIV_EN)
-			prediv = (prediv & pll->div_ratio_mask) + 1;
-		else
-			prediv = 1;
-	}
-
-	/* pre-divider is fixed, but (some?) chips won't report that */
-	if (cpu_is_davinci_dm355() && pll->num == 1)
-		prediv = 8;
-
-	if (pll->flags & PLL_HAS_POSTDIV) {
-		postdiv = __raw_readl(pll->base + POSTDIV);
-		if (postdiv & PLLDIV_EN)
-			postdiv = (postdiv & pll->div_ratio_mask) + 1;
-		else
-			postdiv = 1;
-	}
-
-	if (!bypass) {
-		rate /= prediv;
-		rate *= mult;
-		rate /= postdiv;
-	}
-
-	pr_debug("PLL%d: input = %lu MHz [ ",
-		 pll->num, clk->parent->rate / 1000000);
-	if (bypass)
-		pr_debug("bypass ");
-	if (prediv > 1)
-		pr_debug("/ %d ", prediv);
-	if (mult > 1)
-		pr_debug("* %d ", mult);
-	if (postdiv > 1)
-		pr_debug("/ %d ", postdiv);
-	pr_debug("] --> %lu MHz output.\n", rate / 1000000);
-
-	return rate;
-}
-
-/**
- * davinci_set_pllrate - set the output rate of a given PLL.
- *
- * Note: Currently tested to work with OMAP-L138 only.
- *
- * @pll: pll whose rate needs to be changed.
- * @prediv: The pre divider value. Passing 0 disables the pre-divider.
- * @pllm: The multiplier value. Passing 0 leads to multiply-by-one.
- * @postdiv: The post divider value. Passing 0 disables the post-divider.
- */
-int davinci_set_pllrate(struct pll_data *pll, unsigned int prediv,
-					unsigned int mult, unsigned int postdiv)
-{
-	u32 ctrl;
-	unsigned int locktime;
-	unsigned long flags;
-
-	if (pll->base == NULL)
-		return -EINVAL;
-
-	/*
-	 *  PLL lock time required per OMAP-L138 datasheet is
-	 * (2000 * prediv)/sqrt(pllm) OSCIN cycles. We approximate sqrt(pllm)
-	 * as 4 and OSCIN cycle as 25 MHz.
-	 */
-	if (prediv) {
-		locktime = ((2000 * prediv) / 100);
-		prediv = (prediv - 1) | PLLDIV_EN;
-	} else {
-		locktime = PLL_LOCK_TIME;
-	}
-	if (postdiv)
-		postdiv = (postdiv - 1) | PLLDIV_EN;
-	if (mult)
-		mult = mult - 1;
-
-	/* Protect against simultaneous calls to PLL setting seqeunce */
-	spin_lock_irqsave(&clockfw_lock, flags);
-
-	ctrl = __raw_readl(pll->base + PLLCTL);
-
-	/* Switch the PLL to bypass mode */
-	ctrl &= ~(PLLCTL_PLLENSRC | PLLCTL_PLLEN);
-	__raw_writel(ctrl, pll->base + PLLCTL);
-
-	udelay(PLL_BYPASS_TIME);
-
-	/* Reset and enable PLL */
-	ctrl &= ~(PLLCTL_PLLRST | PLLCTL_PLLDIS);
-	__raw_writel(ctrl, pll->base + PLLCTL);
-
-	if (pll->flags & PLL_HAS_PREDIV)
-		__raw_writel(prediv, pll->base + PREDIV);
-
-	__raw_writel(mult, pll->base + PLLM);
-
-	if (pll->flags & PLL_HAS_POSTDIV)
-		__raw_writel(postdiv, pll->base + POSTDIV);
-
-	udelay(PLL_RESET_TIME);
-
-	/* Bring PLL out of reset */
-	ctrl |= PLLCTL_PLLRST;
-	__raw_writel(ctrl, pll->base + PLLCTL);
-
-	udelay(locktime);
-
-	/* Remove PLL from bypass mode */
-	ctrl |= PLLCTL_PLLEN;
-	__raw_writel(ctrl, pll->base + PLLCTL);
-
-	spin_unlock_irqrestore(&clockfw_lock, flags);
-
-	return 0;
-}
-EXPORT_SYMBOL(davinci_set_pllrate);
-
-/**
- * davinci_set_refclk_rate() - Set the reference clock rate
- * @rate:	The new rate.
- *
- * Sets the reference clock rate to a given value. This will most likely
- * result in the entire clock tree getting updated.
- *
- * This is used to support boards which use a reference clock different
- * 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_clk_init()).
- *
- * Returns 0 on success, error otherwise.
- */
-int davinci_set_refclk_rate(unsigned long rate)
-{
-	struct clk *refclk;
-
-	refclk = clk_get(NULL, "ref");
-	if (IS_ERR(refclk)) {
-		pr_err("%s: failed to get reference clock\n", __func__);
-		return PTR_ERR(refclk);
-	}
-
-	clk_set_rate(refclk, rate);
-
-	clk_put(refclk);
-
-	return 0;
-}
-
-int __init davinci_clk_init(struct clk_lookup *clocks)
-{
-	struct clk_lookup *c;
-	struct clk *clk;
-	size_t num_clocks = 0;
-
-	for (c = clocks; c->clk; c++) {
-		clk = c->clk;
-
-		if (!clk->recalc) {
-
-			/* Check if clock is a PLL */
-			if (clk->pll_data)
-				clk->recalc = clk_pllclk_recalc;
-
-			/* Else, if it is a PLL-derived clock */
-			else if (clk->flags & CLK_PLL)
-				clk->recalc = clk_sysclk_recalc;
-
-			/* Otherwise, it is a leaf clock (PSC clock) */
-			else if (clk->parent)
-				clk->recalc = clk_leafclk_recalc;
-		}
-
-		if (clk->pll_data) {
-			struct pll_data *pll = clk->pll_data;
-
-			if (!pll->div_ratio_mask)
-				pll->div_ratio_mask = PLLDIV_RATIO_MASK;
-
-			if (pll->phys_base && !pll->base) {
-				pll->base = ioremap(pll->phys_base, SZ_4K);
-				WARN_ON(!pll->base);
-			}
-		}
-
-		if (clk->recalc)
-			clk->rate = clk->recalc(clk);
-
-		if (clk->lpsc)
-			clk->flags |= CLK_PSC;
-
-		if (clk->flags & PSC_LRST)
-			clk->reset = davinci_clk_reset;
-
-		clk_register(clk);
-		num_clocks++;
-
-		/* Turn on clocks that Linux doesn't otherwise manage */
-		if (clk->flags & ALWAYS_ENABLED)
-			clk_enable(clk);
-	}
-
-	clkdev_add_table(clocks, num_clocks);
-
-	return 0;
-}
-
-#ifdef CONFIG_DEBUG_FS
-
-#include <linux/debugfs.h>
-#include <linux/seq_file.h>
-
-#define CLKNAME_MAX	10		/* longest clock name */
-#define NEST_DELTA	2
-#define NEST_MAX	4
-
-static void
-dump_clock(struct seq_file *s, unsigned nest, struct clk *parent)
-{
-	char		*state;
-	char		buf[CLKNAME_MAX + NEST_DELTA * NEST_MAX];
-	struct clk	*clk;
-	unsigned	i;
-
-	if (parent->flags & CLK_PLL)
-		state = "pll";
-	else if (parent->flags & CLK_PSC)
-		state = "psc";
-	else
-		state = "";
-
-	/* <nest spaces> name <pad to end> */
-	memset(buf, ' ', sizeof(buf) - 1);
-	buf[sizeof(buf) - 1] = 0;
-	i = strlen(parent->name);
-	memcpy(buf + nest, parent->name,
-			min(i, (unsigned)(sizeof(buf) - 1 - nest)));
-
-	seq_printf(s, "%s users=%2d %-3s %9ld Hz\n",
-		   buf, parent->usecount, state, clk_get_rate(parent));
-	/* REVISIT show device associations too */
-
-	/* cost is now small, but not linear... */
-	list_for_each_entry(clk, &parent->children, childnode) {
-		dump_clock(s, nest + NEST_DELTA, clk);
-	}
-}
-
-static int davinci_ck_show(struct seq_file *m, void *v)
-{
-	struct clk *clk;
-
-	/*
-	 * Show clock tree; We trust nonzero usecounts equate to PSC enables...
-	 */
-	mutex_lock(&clocks_mutex);
-	list_for_each_entry(clk, &clocks, node)
-		if (!clk->parent)
-			dump_clock(m, 0, clk);
-	mutex_unlock(&clocks_mutex);
-
-	return 0;
-}
-
-static int davinci_ck_open(struct inode *inode, struct file *file)
-{
-	return single_open(file, davinci_ck_show, NULL);
-}
-
-static const struct file_operations davinci_ck_operations = {
-	.open		= davinci_ck_open,
-	.read		= seq_read,
-	.llseek		= seq_lseek,
-	.release	= single_release,
-};
-
-static int __init davinci_clk_debugfs_init(void)
-{
-	debugfs_create_file("davinci_clocks", S_IFREG | S_IRUGO, NULL, NULL,
-						&davinci_ck_operations);
-	return 0;
-
-}
-device_initcall(davinci_clk_debugfs_init);
-#endif /* CONFIG_DEBUG_FS */
arch/arm/mach-davinci/clock.h +0 -72

76 lines not on this page · raw message

arch/arm/mach-davinci/common.c +0 -2
index e03f95c..e1d0f0d 100644
@@ -20,8 +20,6 @@
 #include <mach/common.h>
 #include <mach/cputype.h>
 
-#include "clock.h"
-
 struct davinci_soc_info davinci_soc_info;
 EXPORT_SYMBOL(davinci_soc_info);
 
arch/arm/mach-davinci/devices.c +0 -1
index 0edda40..e8dbbb7 100644
@@ -26,7 +26,6 @@
 
 
 #include "davinci.h"
-#include "clock.h"
 
 #define DAVINCI_I2C_BASE	     0x01C21000
 #define DAVINCI_ATA_BASE	     0x01C66000
arch/arm/mach-davinci/include/mach/clock.h +0 -3
index 3e8af6a..42ed4f2 100644
@@ -15,9 +15,6 @@
 
 struct clk;
 
-extern int clk_register(struct clk *clk);
-extern void clk_unregister(struct clk *clk);
-
 int davinci_clk_reset_assert(struct clk *c);
 int davinci_clk_reset_deassert(struct clk *c);
 
arch/arm/mach-davinci/include/mach/common.h +0 -2
index ded8f5f..b577e13 100644
@@ -54,8 +54,6 @@ struct davinci_soc_info {
 	u32				jtag_id_reg;
 	struct davinci_id		*ids;
 	unsigned long			ids_num;
-	u32				*psc_bases;
-	unsigned long			psc_bases_num;
 	u32				pinmux_base;
 	const struct mux_config		*pinmux_pins;
 	unsigned long			pinmux_pins_num;
arch/arm/mach-davinci/psc.c deleted +0 -137

137 lines not on this page · raw message

arch/arm/mach-davinci/psc.h +0 -10
index b58707c..68cd9d3 100644
@@ -204,14 +204,4 @@
 #define PDCTL_NEXT		BIT(0)
 #define PDCTL_EPCGOOD		BIT(8)
 
-#ifndef __ASSEMBLER__
-
-extern int davinci_psc_is_clk_active(unsigned int ctlr, unsigned int id);
-extern void davinci_psc_reset(unsigned int ctlr, unsigned int id,
-		bool reset);
-extern void davinci_psc_config(unsigned int domain, unsigned int ctlr,
-		unsigned int id, bool enable, u32 flags);
-
-#endif
-
 #endif /* __ASM_ARCH_PSC_H */
arch/arm/mach-davinci/time.c +0 -2
index 2521333..d6a78f7 100644
@@ -27,8 +27,6 @@
 #include <mach/hardware.h>
 #include <mach/time.h>
 
-#include "clock.h"
-
 static struct clock_event_device clockevent_davinci;
 static unsigned int davinci_clock_tick_rate;
 
Signature · 1 line
2.7.4
author maintainer
#52 lore raw

PATCH v7 40/42 ARM: davinci: add device tree support to timer

In reply to David Lechner

This adds device tree support to the davinci timer so that when clocks are moved to device tree, the timer will still work.

---

v7 changes:
- add workaround for platform devices not available in early boot

v6 changes:
- none

 arch/arm/mach-davinci/Kconfig |  1 +
 arch/arm/mach-davinci/time.c  | 31 +++++++++++++++++++++++++++++++
 2 files changed, 32 insertions(+)
arch/arm/mach-davinci/Kconfig +1 -0
index ba9912b..da8a039 100644
@@ -59,6 +59,7 @@ config MACH_DA8XX_DT
 	default y
 	depends on ARCH_DAVINCI_DA850
 	select PINCTRL
+	select TIMER_OF
 	help
 	  Say y here to include support for TI DaVinci DA850 based using
 	  Flattened Device Tree. More information at Documentation/devicetree
arch/arm/mach-davinci/time.c +31 -0
index d6a78f7..590b118 100644
@@ -17,6 +17,7 @@
 #include <linux/io.h>
 #include <linux/clk.h>
 #include <linux/err.h>
+#include <linux/of.h>
 #include <linux/platform_device.h>
 #include <linux/sched_clock.h>
 
@@ -405,3 +406,33 @@ void __init davinci_timer_init(struct clk *timer_clk)
 	for (i=0; i< ARRAY_SIZE(timers); i++)
 		timer32_config(&timers[i]);
 }
+
+static int __init of_davinci_timer_init(struct device_node *np)
+{
+	struct clk *clk;
+
+	clk = of_clk_get(np, 0);
+	if (IS_ERR(clk)) {
+		struct of_phandle_args clkspec;
+
+		/*
+		 * Fall back to using ref_clk if the actual clock is not
+		 * available. This currently always happens because platform
+		 * clocks (i.e PLLs and PSCs) are registered as platform
+		 * devices and therefore are not available@this point in
+		 * the boot process.
+		 */
+		clkspec.np = of_find_node_by_name(NULL, "ref_clk");
+		if (IS_ERR(clkspec.np)) {
+			pr_err("%s: No clock available for timer!\n", __func__);
+			return PTR_ERR(clkspec.np);
+		}
+		clk = of_clk_get_from_provider(&clkspec);
+		of_node_put(clkspec.np);
+	}
+
+	davinci_timer_init(clk);
+
+	return 0;
+}
+TIMER_OF_DECLARE(davinci_timer, "ti,davinci-timer", of_davinci_timer_init);
Signature · 1 line
2.7.4
author maintainer
#53 lore raw

PATCH v7 41/42 ARM: davinci: da8xx-dt: switch to device tree clocks

In reply to David Lechner

This removes all of the clock init code from da8xx-dt.c. This includes all of the OF_DEV_AUXDATA that was just used for looking up clocks.

---

v7 changes:
- rebased
- drop of_platform_default_populate(NULL, NULL, NULL)
- add change in pm_domain.c

Note: I didn't see this until it was too late, but Bartosz has an interesting alternative for the legacy PM domain stuff at
https://github.com/brgl/linux/commit/0197b11512e44206708f4bd320c369a2a163e82d

v6 changes:
- removed misleading statement from commit message

 arch/arm/mach-davinci/da8xx-dt.c  | 58 ---------------------------------------
 arch/arm/mach-davinci/pm_domain.c |  5 ++++
 2 files changed, 5 insertions(+), 58 deletions(-)
arch/arm/mach-davinci/da8xx-dt.c +0 -58
index 088bc5c..23ac410 100644
@@ -19,67 +19,10 @@
 #include "cp_intc.h"
 #include <mach/da8xx.h>
 
-static struct of_dev_auxdata da850_aemif_auxdata_lookup[] = {
-	OF_DEV_AUXDATA("ti,davinci-nand", 0x62000000, "davinci-nand.0", NULL),
-	{}
-};
-
-static struct aemif_platform_data aemif_data = {
-	.dev_lookup = da850_aemif_auxdata_lookup,
-};
-
-static struct of_dev_auxdata da850_auxdata_lookup[] __initdata = {
-	OF_DEV_AUXDATA("ti,davinci-i2c", 0x01c22000, "i2c_davinci.1", NULL),
-	OF_DEV_AUXDATA("ti,davinci-i2c", 0x01e28000, "i2c_davinci.2", NULL),
-	OF_DEV_AUXDATA("ti,davinci-wdt", 0x01c21000, "davinci-wdt", NULL),
-	OF_DEV_AUXDATA("ti,da830-mmc", 0x01c40000, "da830-mmc.0", NULL),
-	OF_DEV_AUXDATA("ti,da850-ehrpwm", 0x01f00000, "ehrpwm.0", NULL),
-	OF_DEV_AUXDATA("ti,da850-ehrpwm", 0x01f02000, "ehrpwm.1", NULL),
-	OF_DEV_AUXDATA("ti,da850-ecap", 0x01f06000, "ecap.0", NULL),
-	OF_DEV_AUXDATA("ti,da850-ecap", 0x01f07000, "ecap.1", NULL),
-	OF_DEV_AUXDATA("ti,da850-ecap", 0x01f08000, "ecap.2", NULL),
-	OF_DEV_AUXDATA("ti,da830-spi", 0x01c41000, "spi_davinci.0", NULL),
-	OF_DEV_AUXDATA("ti,da830-spi", 0x01f0e000, "spi_davinci.1", NULL),
-	OF_DEV_AUXDATA("ns16550a", 0x01c42000, "serial8250.0", NULL),
-	OF_DEV_AUXDATA("ns16550a", 0x01d0c000, "serial8250.1", NULL),
-	OF_DEV_AUXDATA("ns16550a", 0x01d0d000, "serial8250.2", NULL),
-	OF_DEV_AUXDATA("ti,davinci_mdio", 0x01e24000, "davinci_mdio.0", NULL),
-	OF_DEV_AUXDATA("ti,davinci-dm6467-emac", 0x01e20000, "davinci_emac.1",
-		       NULL),
-	OF_DEV_AUXDATA("ti,da830-mcasp-audio", 0x01d00000, "davinci-mcasp.0", NULL),
-	OF_DEV_AUXDATA("ti,da850-aemif", 0x68000000, "ti-aemif", &aemif_data),
-	OF_DEV_AUXDATA("ti,da850-tilcdc", 0x01e13000, "da8xx_lcdc.0", NULL),
-	OF_DEV_AUXDATA("ti,da830-ohci", 0x01e25000, "ohci-da8xx", NULL),
-	OF_DEV_AUXDATA("ti,da830-musb", 0x01e00000, "musb-da8xx", NULL),
-	OF_DEV_AUXDATA("ti,da830-usb-phy", 0x01c1417c, "da8xx-usb-phy", NULL),
-	OF_DEV_AUXDATA("ti,da850-ahci", 0x01e18000, "ahci_da850", NULL),
-	OF_DEV_AUXDATA("ti,da850-vpif", 0x01e17000, "vpif", NULL),
-	OF_DEV_AUXDATA("ti,da850-dsp", 0x11800000, "davinci-rproc.0", NULL),
-	{}
-};
-
 #ifdef CONFIG_ARCH_DAVINCI_DA850
 
 static void __init da850_init_machine(void)
 {
-	/* All existing boards use 100MHz SATA refclkpn */
-	static const unsigned long sata_refclkpn = 100 * 1000 * 1000;
-
-	int ret;
-
-	da850_register_clocks();
-
-	ret = da8xx_register_usb_phy_clocks();
-	if (ret)
-		pr_warn("%s: USB PHY CLK registration failed: %d\n",
-			__func__, ret);
-
-	ret = da850_register_sata_refclk(sata_refclkpn);
-	if (ret)
-		pr_warn("%s: registering SATA REFCLK failed: %d",
-			__func__, ret);
-
-	of_platform_default_populate(NULL, da850_auxdata_lookup, NULL);
 	davinci_pm_init();
 	pdata_quirks_init();
 }
@@ -94,7 +37,6 @@ static const char *const da850_boards_compat[] __initconst = {
 
 DT_MACHINE_START(DA850_DT, "Generic DA850/OMAP-L138/AM18x")
 	.map_io		= da850_init,
-	.init_time	= da850_init_time,
 	.init_machine	= da850_init_machine,
 	.dt_compat	= da850_boards_compat,
 	.init_late	= davinci_init_late,
arch/arm/mach-davinci/pm_domain.c +5 -0
index 78eac2c..e251fd5 100644
@@ -13,6 +13,7 @@
 #include <linux/pm_runtime.h>
 #include <linux/pm_clock.h>
 #include <linux/platform_device.h>
+#include <linux/of.h>
 
 static struct dev_pm_domain davinci_pm_domain = {
 	.ops = {
@@ -28,6 +29,10 @@ static struct pm_clk_notifier_block platform_bus_notifier = {
 
 static int __init davinci_pm_runtime_init(void)
 {
+	if (of_have_populated_dt())
+		return 0;
+
+	/* Use pm_clk as fallback if we're not using genpd. */
 	pm_clk_add_notifier(&platform_bus_type, &platform_bus_notifier);
 
 	return 0;
Signature · 1 line
2.7.4
author maintainer
#54 lore raw

PATCH v7 42/42 ARM: dts: da850: Add clocks

In reply to David Lechner

This adds clock provider nodes for da850 and wires them up to all of the devices.

---

v7 changes:
- move ref_clk frequency to board-specific DT files
- enable sata_refclk in da850-lcdk.dts
- drop async2 fixed factor clock
- add power-domains for devices that use them
- fix USB PHY clock-names property
- move assigned-clocks to PSC device node
- drop clocks property from devices that don't use it (e.g. EDMA)
- add clock to RTC node
- add clock-ranges to usb0 and aemif nodes
- add clock-names property to aemif node
- fix typo in psc1 clock-names

v6 changes:
- updated for device tree bindings changes earlier in this series
- use single async2 clock instead of duplicate fixed factor clocks
- add clock-names property to mdio node

 arch/arm/boot/dts/da850-enbw-cmc.dts |   4 +
 arch/arm/boot/dts/da850-evm.dts      |   4 +
 arch/arm/boot/dts/da850-lcdk.dts     |   9 ++
 arch/arm/boot/dts/da850-lego-ev3.dts |   4 +
 arch/arm/boot/dts/da850.dtsi         | 159 +++++++++++++++++++++++++++++++++++
 5 files changed, 180 insertions(+)
arch/arm/boot/dts/da850-enbw-cmc.dts +4 -0
index 14dff3e..0102ffc 100644
@@ -35,6 +35,10 @@
 	};
 };
 
+&ref_clk {
+	clock-frequency = <24000000>;
+};
+
 &edma0 {
 	ti,edma-reserved-slot-ranges = <32 50>;
 };
arch/arm/boot/dts/da850-evm.dts +4 -0
index a86a8a1..6e13613 100644
@@ -195,6 +195,10 @@
 	};
 };
 
+&ref_clk {
+	clock-frequency = <24000000>;
+};
+
 /include/ "tps6507x.dtsi"
 
 &tps {
arch/arm/boot/dts/da850-lcdk.dts +9 -0
index a1f4d6d..90b917c 100644
@@ -123,6 +123,10 @@
 	};
 };
 
+&ref_clk {
+	clock-frequency = <24000000>;
+};
+
 &pmx_core {
 	status = "okay";
 
@@ -175,6 +179,11 @@
 	status = "okay";
 };
 
+&sata_refclk {
+	status = "okay";
+	clock-frequency = <100000000>;
+};
+
 &sata {
 	status = "okay";
 };
arch/arm/boot/dts/da850-lego-ev3.dts +4 -0
index 81942ae..dd3bf93 100644
@@ -186,6 +186,10 @@
 	};
 };
 
+&ref_clk {
+	clock-frequency = <24000000>;
+};
+
 &pmx_core {
 	status = "okay";
 
arch/arm/boot/dts/da850.dtsi +159 -0

341 lines not on this page · raw message

Signature · 1 line
2.7.4
#55 lore raw
In reply to David Lechner

2018-02-19 21:21 GMT+01:00 David Lechner <[email protected]>:

Quoted 234 lines

This series converts mach-davinci to use the common clock framework.

The series works like this, the first 19 patches create new clock drivers using the common clock framework. There are basically 3 groups of clocks - PLL, PSC and CFGCHIP (syscon). There are six different SoCs that each have unique init data, which is the reason for so many patches.

Then, starting with "ARM: davinci: pass clock as parameter to davinci_timer_init()", we get the mach code ready for the switch by adding the code needed for the new clock drivers and adding #ifndef CONFIG_COMMON_CLK around the legacy clocks so that we can switch easily between the old and the new.

"ARM: davinci: switch to common clock framework" actually flips the switch to start using the new clock drivers. Then the next 8 patches remove all of the old clock code.

The final three patches add device tree clock support to the one SoC that supports it.

---

The change to make all of the clocks platform devices in v7 was a pretty major change, so unfortunately I had to drop quite a few Reviewed-bys and this series will need more close review and testing again.

v7 changes (also see individual patches for details):
- Rebased on linux-davinci/master (v4.16-rc)
- Convert clock drivers to platform devices
- New patch "ARM: davinci: pass clock as parameter to davinci_timer_init()"
- Fix issues with lcdk and aemif clock lookups and power domains
- Fixed other minor issues brought up in v6 review

v6 changes (also see individual patches for details):
- All of the device tree bindings are changed
- All of the clock drivers are changed significantly
- Fixed issues brought up during review of v5
- "ARM: davinci: move davinci_clk_init() to init_time" is removed from this series and submitted separately

v5 changes:
- Basically, this is an entirely new series
- Patches are broken up into bite-sized pieces
- Converted PSC clock driver to use regmap
- Restored "force" flag for certain DA850 clocks
- Added device tree bindings
- Moved more of the clock init to drivers/clk
- Fixed frequency scaling (maybe*)

* I have frequency scaling using cpufreq-dt, so I know the clocks are doing what they need to do to make this work, but I haven't figured out how to test davinci-cpufreq driver yet. (Patches to make cpufreq-dt work will be sent separately after this series has landed.)

Dependencies:

Most of the dependencies have landed in mainline already in v4.16-rc1 or are in linux-davinci/master.

There are no build dependencies any more, but you will need to pickup a couple of patches to get CPU frequency scaling working because of a divider clock bug.

- https://patchwork.kernel.org/patch/10218941/
- https://patchwork.kernel.org/patch/10218927/

You can find a working branch with everything included in the "common-clk-v7" branch of https://github.com/dlech/ev3dev-kernel.git.

Testing/debugging for the uninitiated:

I only have one device to test with, which is based on da850, so I will have to rely on others to do some testing here. Since we are dealing with clocks, if something isn't working, you most likely won't see output on the serial port. To figure out what is going on, you need to enable...

CONFIG_DEBUG_LL=y
CONFIG_EARLY_PRINTK=y

and add "earlyprintk clk_ignore_unused" to the kernel command line options. You may need to select a different UART for this depending on your board. I think UART1 is the default in the kernel configuration.

On da850 devices comment out the lines:

        else
                clk_set_parent(clk, parent->clk);

in da850.c or, if using device tree, comment out the lines:

        assigned-clocks = <&async3_clk>;
        assigned-clock-parents = <&pll1_sysclk 2>;

in da850.dtsi when doing earlyprintk, otherwise the UART1 and UART2 clock source will change during boot and cause garbled output after a point.

David Lechner (42):
dt-bindings: clock: Add new bindings for TI Davinci PLL clocks
clk: davinci: New driver for davinci PLL clocks
clk: davinci: Add platform information for TI DA830 PLL
clk: davinci: Add platform information for TI DA850 PLL
clk: davinci: Add platform information for TI DM355 PLL
clk: davinci: Add platform information for TI DM365 PLL
clk: davinci: Add platform information for TI DM644x PLL
clk: davinci: Add platform information for TI DM646x PLL
dt-bindings: clock: New bindings for TI Davinci PSC
clk: davinci: New driver for davinci PSC clocks
clk: davinci: Add platform information for TI DA830 PSC
clk: davinci: Add platform information for TI DA850 PSC
clk: davinci: Add platform information for TI DM355 PSC
clk: davinci: Add platform information for TI DM365 PSC
clk: davinci: Add platform information for TI DM644x PSC
clk: davinci: Add platform information for TI DM646x PSC
dt-bindings: clock: Add bindings for DA8XX CFGCHIP clocks
clk: davinci: New driver for TI DA8XX CFGCHIP clocks
clk: davinci: cfgchip: Add TI DA8XX USB PHY clocks
ARM: davinci: pass clock as parameter to davinci_timer_init()
ARM: davinci: da830: add new clock init using common clock framework
ARM: davinci: da850: add new clock init using common clock framework
ARM: davinci: dm355: add new clock init using common clock framework
ARM: davinci: dm365: add new clock init using common clock framework
ARM: davinci: dm644x: add new clock init using common clock framework
ARM: davinci: dm646x: add new clock init using common clock framework
ARM: davinci: da8xx: add new USB PHY clock init using common clock
framework
ARM: davinci: da8xx: add new sata_refclk init using common clock
framework
ARM: davinci: remove CONFIG_DAVINCI_RESET_CLOCKS
ARM: davinci_all_defconfig: remove CONFIG_DAVINCI_RESET_CLOCKS
ARM: davinci: switch to common clock framework
ARM: davinci: da830: Remove legacy clock init
ARM: davinci: da850: Remove legacy clock init
ARM: davinci: dm355: Remove legacy clock init
ARM: davinci: dm365: Remove legacy clock init
ARM: davinci: dm644x: Remove legacy clock init
ARM: davinci: dm646x: Remove legacy clock init
ARM: davinci: da8xx: Remove legacy USB and SATA clock init
ARM: davinci: remove legacy clocks
ARM: davinci: add device tree support to timer
ARM: davinci: da8xx-dt: switch to device tree clocks
ARM: dts: da850: Add clocks

 .../bindings/clock/ti/davinci/da8xx-cfgchip.txt    |  93 +++
 .../devicetree/bindings/clock/ti/davinci/pll.txt   |  96 +++
 .../devicetree/bindings/clock/ti/davinci/psc.txt   |  71 ++
 MAINTAINERS                                        |   7 +
 arch/arm/Kconfig                                   |   5 +-
 arch/arm/boot/dts/da850-enbw-cmc.dts               |   4 +
 arch/arm/boot/dts/da850-evm.dts                    |   4 +
 arch/arm/boot/dts/da850-lcdk.dts                   |   9 +
 arch/arm/boot/dts/da850-lego-ev3.dts               |   4 +
 arch/arm/boot/dts/da850.dtsi                       | 159 ++++
 arch/arm/configs/davinci_all_defconfig             |   1 -
 arch/arm/mach-davinci/Kconfig                      |  13 +-
 arch/arm/mach-davinci/Makefile                     |   4 +-
 arch/arm/mach-davinci/board-da830-evm.c            |  12 +-
 arch/arm/mach-davinci/board-da850-evm.c            |   2 +
 arch/arm/mach-davinci/board-dm355-evm.c            |   2 +
 arch/arm/mach-davinci/board-dm355-leopard.c        |   2 +
 arch/arm/mach-davinci/board-dm365-evm.c            |   2 +
 arch/arm/mach-davinci/board-dm644x-evm.c           |   2 +
 arch/arm/mach-davinci/board-dm646x-evm.c           |   2 +
 arch/arm/mach-davinci/board-mityomapl138.c         |   2 +
 arch/arm/mach-davinci/board-neuros-osd2.c          |   2 +
 arch/arm/mach-davinci/board-omapl138-hawk.c        |  11 +-
 arch/arm/mach-davinci/board-sffsdr.c               |   2 +
 arch/arm/mach-davinci/clock.c                      | 745 -----------------
 arch/arm/mach-davinci/clock.h                      |  76 --
 arch/arm/mach-davinci/common.c                     |   3 -
 arch/arm/mach-davinci/da830.c                      | 469 ++---------
 arch/arm/mach-davinci/da850.c                      | 766 +++---------------
 arch/arm/mach-davinci/da8xx-dt.c                   |  60 --
 arch/arm/mach-davinci/davinci.h                    |   8 +
 arch/arm/mach-davinci/devices-da8xx.c              |  43 +-
 arch/arm/mach-davinci/devices.c                    |   1 -
 arch/arm/mach-davinci/dm355.c                      | 425 ++--------
 arch/arm/mach-davinci/dm365.c                      | 517 ++----------
 arch/arm/mach-davinci/dm644x.c                     | 363 ++-------
 arch/arm/mach-davinci/dm646x.c                     | 391 ++-------
 arch/arm/mach-davinci/include/mach/clock.h         |   3 -
 arch/arm/mach-davinci/include/mach/common.h        |  11 +-
 arch/arm/mach-davinci/include/mach/da8xx.h         |   6 +-
 arch/arm/mach-davinci/pm_domain.c                  |   5 +
 arch/arm/mach-davinci/psc.c                        | 137 ----
 arch/arm/mach-davinci/psc.h                        |  12 -
 arch/arm/mach-davinci/time.c                       |  46 +-
 arch/arm/mach-davinci/usb-da8xx.c                  | 250 +-----
 drivers/clk/Makefile                               |   1 +
 drivers/clk/davinci/Makefile                       |  21 +
 drivers/clk/davinci/da8xx-cfgchip.c                | 786 ++++++++++++++++++
 drivers/clk/davinci/pll-da830.c                    |  58 ++
 drivers/clk/davinci/pll-da850.c                    | 178 +++++
 drivers/clk/davinci/pll-dm355.c                    |  75 ++
 drivers/clk/davinci/pll-dm365.c                    | 119 +++
 drivers/clk/davinci/pll-dm644x.c                   |  76 ++
 drivers/clk/davinci/pll-dm646x.c                   |  78 ++
 drivers/clk/davinci/pll.c                          | 877 +++++++++++++++++++++
 drivers/clk/davinci/pll.h                          | 141 ++++
 drivers/clk/davinci/psc-da830.c                    |  89 +++
 drivers/clk/davinci/psc-da850.c                    | 109 +++
 drivers/clk/davinci/psc-dm355.c                    |  72 ++
 drivers/clk/davinci/psc-dm365.c                    |  77 ++
 drivers/clk/davinci/psc-dm644x.c                   |  67 ++
 drivers/clk/davinci/psc-dm646x.c                   |  62 ++
 drivers/clk/davinci/psc.c                          | 505 ++++++++++++
 drivers/clk/davinci/psc.h                          | 101 +++
 include/linux/platform_data/clk-da8xx-cfgchip.h    |  21 +
 65 files changed, 4515 insertions(+), 3846 deletions(-)
 create mode 100644 Documentation/devicetree/bindings/clock/ti/davinci/da8xx-cfgchip.txt
 create mode 100644 Documentation/devicetree/bindings/clock/ti/davinci/pll.txt
 create mode 100644 Documentation/devicetree/bindings/clock/ti/davinci/psc.txt
 delete mode 100644 arch/arm/mach-davinci/clock.c
 delete mode 100644 arch/arm/mach-davinci/psc.c
 create mode 100644 drivers/clk/davinci/Makefile
 create mode 100644 drivers/clk/davinci/da8xx-cfgchip.c
 create mode 100644 drivers/clk/davinci/pll-da830.c
 create mode 100644 drivers/clk/davinci/pll-da850.c
 create mode 100644 drivers/clk/davinci/pll-dm355.c
 create mode 100644 drivers/clk/davinci/pll-dm365.c
 create mode 100644 drivers/clk/davinci/pll-dm644x.c
 create mode 100644 drivers/clk/davinci/pll-dm646x.c
 create mode 100644 drivers/clk/davinci/pll.c
 create mode 100644 drivers/clk/davinci/pll.h
 create mode 100644 drivers/clk/davinci/psc-da830.c
 create mode 100644 drivers/clk/davinci/psc-da850.c
 create mode 100644 drivers/clk/davinci/psc-dm355.c
 create mode 100644 drivers/clk/davinci/psc-dm365.c
 create mode 100644 drivers/clk/davinci/psc-dm644x.c
 create mode 100644 drivers/clk/davinci/psc-dm646x.c
 create mode 100644 drivers/clk/davinci/psc.c
 create mode 100644 drivers/clk/davinci/psc.h
 create mode 100644 include/linux/platform_data/clk-da8xx-cfgchip.h
Quoted 3 lines

--
2.7.4

Hi David,

just some quick results from today's playing with v7.

I started out with da850-lcdk with my standard rootfs over NFS. I was not able to boot to console so far. The first problem is that mdio fails to probe:

libphy: Fixed MDIO Bus: probed
davinci_mdio 1e24000.mdio: davinci mdio revision 1.5, bus freq 2200000 davinci_mdio 1e24000.mdio: no live phy, scanning all
davinci_mdio: probe of 1e24000.mdio failed with error -5

After some digging I noticed that the supplied clock rate differs between mainline (114000000Hz) vs common-clock-v7 (18000000). Since we're not setting the rate in mdio, using LPSC_SET_RATE_PARENT would not help like with lcdc.

After that, the boot just hangs without ever getting to emac's probe.

Once I set the emac clock to always enabled (a workaround that was necessary with v6, but could be dropped with my first genpd-in-a-separate-driver attempt), I'm getting a rather strange NULL pointer dereference:

Backtrace:
[<c049d464>] (strlen) from [<c01f32a8>] (start_creating+0x58/0xc0)
[<c01f3250>] (start_creating) from [<c01f34c8>] (debugfs_create_dir+0x14/0xd8)
 r7:c04dadbc r6:c0567480 r5:c0656274 r4:c68a9300

[<c01f34b4>] (debugfs_create_dir) from [<c0296838>] (clk_debug_create_one+0x28/0x1d0)
r5:c0656274 r4:c68a9300
[<c0296810>] (clk_debug_create_one) from [<c05cdf84>] (clk_debug_init+0x100/0x15c)
r5:c0656274 r4:c68a9300
[<c05cde84>] (clk_debug_init) from [<c000a54c>] (do_one_initcall+0x50/0x19c)
r7:c05e3834 r6:ffffe000 r5:c05f7008 r4:c05cde84
[<c000a4fc>] (do_one_initcall) from [<c05b6eb4>] (kernel_init_freeable+0x110/0x1cc)
r9:c05b4584 r8:c05b6614 r7:c05e3834 r6:c063cc80 r5:00000073 r4:c05f2354
[<c05b6da4>] (kernel_init_freeable) from [<c04a2ce4>] (kernel_init+0x10/0xfc)
r10:00000000 r9:00000000 r8:00000000 r7:00000000 r6:00000000 r5:c04a2cd4 r4:00000000
[<c04a2cd4>] (kernel_init) from [<c00090e0>] (ret_from_fork+0x14/0x34)

It turns out that the emac clock is correctly registered in __davinci_psc_register_clocks() and a corresponding clk_core structure is added to the list and core->name is correctly assigned, but then later when clk_debug_init() is called, the name in emac clk_core is NULL. This is the direct reason for the panic. Interestingly other members of clk_core seem to be fine.

I'll continue on debugging it. Let me know if you have any ideas.

Best regards,
Bartosz Golaszewski

author maintainer
#56 lore raw
Quoted 13 lines · Bartosz Golaszewski

2018-02-19 21:21 GMT+01:00 David Lechner <[email protected]>:

Quoted 3 lines

This series converts mach-davinci to use the common clock framework.

Hi David,

just some quick results from today's playing with v7.

I started out with da850-lcdk with my standard rootfs over NFS. I was not able to boot to console so far. The first problem is that mdio fails to probe:

Quoted 7 lines

libphy: Fixed MDIO Bus: probed
davinci_mdio 1e24000.mdio: davinci mdio revision 1.5, bus freq 2200000
davinci_mdio 1e24000.mdio: no live phy, scanning all
davinci_mdio: probe of 1e24000.mdio failed with error -5> After some digging I noticed that the supplied clock rate differs between mainline (114000000Hz) vs common-clock-v7 (18000000). Since
we're not setting the rate in mdio, using LPSC_SET_RATE_PARENT would
not help like with lcdc.

Can you post the output of this command so that I can see how your clocks are setup:

cat /sys/kernel/debug/clk/clk_summary

Quoted 2 lines

After that, the boot just hangs without ever getting to emac's probe.

Using your workaround, can you run:

cat /sys/kernel/debug/pm_genpd/pm_genpd_summary

If you see:

1e27000.clock-controller: emac off-0

then genpd is not working like it is supposed to. You should see something like this for device that are working:

1e27000.clock-controller: uart2 on

    /devices/platform/soc@1c00000/1d0d000.serial        active
Quoted 5 lines

Once I set the emac clock to always enabled (a workaround that was necessary with v6, but could be dropped with my first genpd-in-a-separate-driver attempt), I'm getting a rather strange NULL pointer dereference:

I noticed this too when adding the power-domains property to some device tree nodes. This is part of the reason why I didn't add it everywhere. I wasn't able to figure out the cause of this yet. As a work around though, please try removing the power-domains property from the emac and mdio nodes and use your previous workaround of having an always enabled clock.

Quoted 33 lines
Backtrace:
[<c049d464>] (strlen) from [<c01f32a8>] (start_creating+0x58/0xc0)
[<c01f3250>] (start_creating) from [<c01f34c8>] (debugfs_create_dir+0x14/0xd8)
  r7:c04dadbc r6:c0567480 r5:c0656274 r4:c68a9300

[<c01f34b4>] (debugfs_create_dir) from [<c0296838>] (clk_debug_create_one+0x28/0x1d0)
r5:c0656274 r4:c68a9300
[<c0296810>] (clk_debug_create_one) from [<c05cdf84>] (clk_debug_init+0x100/0x15c)
r5:c0656274 r4:c68a9300
[<c05cde84>] (clk_debug_init) from [<c000a54c>] (do_one_initcall+0x50/0x19c)
r7:c05e3834 r6:ffffe000 r5:c05f7008 r4:c05cde84
[<c000a4fc>] (do_one_initcall) from [<c05b6eb4>] (kernel_init_freeable+0x110/0x1cc)
r9:c05b4584 r8:c05b6614 r7:c05e3834 r6:c063cc80 r5:00000073 r4:c05f2354
[<c05b6da4>] (kernel_init_freeable) from [<c04a2ce4>] (kernel_init+0x10/0xfc)
r10:00000000 r9:00000000 r8:00000000 r7:00000000 r6:00000000 r5:c04a2cd4 r4:00000000
[<c04a2cd4>] (kernel_init) from [<c00090e0>] (ret_from_fork+0x14/0x34)

It turns out that the emac clock is correctly registered in __davinci_psc_register_clocks() and a corresponding clk_core structure is added to the list and core->name is correctly assigned, but then later when clk_debug_init() is called, the name in emac clk_core is NULL. This is the direct reason for the panic. Interestingly other members of clk_core seem to be fine.

I'll continue on debugging it. Let me know if you have any ideas.

Best regards,
Bartosz Golaszewski

#57 lore raw

2018-02-20 19:39 GMT+01:00 David Lechner <[email protected]>:

Quoted 56 lines · Bartosz Golaszewski
Quoted 15 lines

2018-02-19 21:21 GMT+01:00 David Lechner <[email protected]>:

Quoted 4 lines

This series converts mach-davinci to use the common clock framework.

Hi David,

just some quick results from today's playing with v7.

I started out with da850-lcdk with my standard rootfs over NFS. I was not able to boot to console so far. The first problem is that mdio fails to probe:

Quoted 8 lines

libphy: Fixed MDIO Bus: probed
davinci_mdio 1e24000.mdio: davinci mdio revision 1.5, bus freq 2200000 davinci_mdio 1e24000.mdio: no live phy, scanning all
davinci_mdio: probe of 1e24000.mdio failed with error -5> After some digging I noticed that the supplied clock rate differs between mainline (114000000Hz) vs common-clock-v7 (18000000). Since we're not setting the rate in mdio, using LPSC_SET_RATE_PARENT would not help like with lcdc.

Can you post the output of this command so that I can see how your clocks are setup:

cat /sys/kernel/debug/clk/clk_summary

Quoted 2 lines

After that, the boot just hangs without ever getting to emac's probe.

Using your workaround, can you run:

cat /sys/kernel/debug/pm_genpd/pm_genpd_summary

If you see:
1e27000.clock-controller: emac off-0

then genpd is not working like it is supposed to. You should see something like this for device that are working:

          1e27000.clock-controller: uart2  on
    /devices/platform/soc at 1c00000/1d0d000.serial        active
Quoted 5 lines

Once I set the emac clock to always enabled (a workaround that was necessary with v6, but could be dropped with my first genpd-in-a-separate-driver attempt), I'm getting a rather strange NULL pointer dereference:

Quoted 8 lines

I noticed this too when adding the power-domains property to some device tree nodes. This is part of the reason why I didn't add it everywhere. I wasn't able to figure out the cause of this yet. As a work around though, please try removing the power-domains property from the emac and mdio nodes and use your previous workaround of having an always enabled clock.

When I use any of the workarounds I just keep getting more problems (e.g. [1] from blk and pinctrl). I only had a couple hours today to play with it but it seems to me we have some memory corruption somewhere. I'll check the initialization order of all the frameworks involved tomorrow.

Best regards,
Bartosz

[1] https://pastebin.com/75mkkuJL

author maintainer
#58 lore raw
Quoted 72 lines · Bartosz Golaszewski

2018-02-20 19:39 GMT+01:00 David Lechner <[email protected]>:

Quoted 56 lines · Bartosz Golaszewski
Quoted 15 lines

2018-02-19 21:21 GMT+01:00 David Lechner <[email protected]>:

Quoted 4 lines

This series converts mach-davinci to use the common clock framework.

Hi David,

just some quick results from today's playing with v7.

I started out with da850-lcdk with my standard rootfs over NFS. I was not able to boot to console so far. The first problem is that mdio fails to probe:

Quoted 8 lines

libphy: Fixed MDIO Bus: probed
davinci_mdio 1e24000.mdio: davinci mdio revision 1.5, bus freq 2200000 davinci_mdio 1e24000.mdio: no live phy, scanning all
davinci_mdio: probe of 1e24000.mdio failed with error -5> After some digging I noticed that the supplied clock rate differs between mainline (114000000Hz) vs common-clock-v7 (18000000). Since we're not setting the rate in mdio, using LPSC_SET_RATE_PARENT would not help like with lcdc.

Can you post the output of this command so that I can see how your clocks are setup:

cat /sys/kernel/debug/clk/clk_summary

Quoted 2 lines

After that, the boot just hangs without ever getting to emac's probe.

Using your workaround, can you run:

cat /sys/kernel/debug/pm_genpd/pm_genpd_summary

If you see:

   1e27000.clock-controller: emac  off-0

then genpd is not working like it is supposed to. You should see something like this for device that are working:

           1e27000.clock-controller: uart2  on
     /devices/platform/soc@1c00000/1d0d000.serial        active
Quoted 5 lines

Once I set the emac clock to always enabled (a workaround that was necessary with v6, but could be dropped with my first genpd-in-a-separate-driver attempt), I'm getting a rather strange NULL pointer dereference:

Quoted 8 lines

I noticed this too when adding the power-domains property to some device tree nodes. This is part of the reason why I didn't add it everywhere. I wasn't able to figure out the cause of this yet. As a work around though, please try removing the power-domains property from the emac and mdio nodes and use your previous workaround of having an always enabled clock.

When I use any of the workarounds I just keep getting more problems (e.g. [1] from blk and pinctrl). I only had a couple hours today to play with it but it seems to me we have some memory corruption somewhere. I'll check the initialization order of all the frameworks involved tomorrow.

Quoted 5 lines

Best regards,
Bartosz

[1] https://pastebin.com/75mkkuJL

I wonder if we need to delete all of the __init and __initconst attributes now that this has been converted to platform devices.

#59 lore raw

2018-02-21 18:05 GMT+01:00 David Lechner <[email protected]>:

Quoted 81 lines · Bartosz Golaszewski
Quoted 80 lines

2018-02-20 19:39 GMT+01:00 David Lechner <[email protected]>:

Quoted 63 lines · Bartosz Golaszewski
Quoted 17 lines

2018-02-19 21:21 GMT+01:00 David Lechner <[email protected]>:

Quoted 5 lines

This series converts mach-davinci to use the common clock framework.

Hi David,

just some quick results from today's playing with v7.

I started out with da850-lcdk with my standard rootfs over NFS. I was not able to boot to console so far. The first problem is that mdio fails to probe:

Quoted 8 lines

libphy: Fixed MDIO Bus: probed
davinci_mdio 1e24000.mdio: davinci mdio revision 1.5, bus freq 2200000 davinci_mdio 1e24000.mdio: no live phy, scanning all
davinci_mdio: probe of 1e24000.mdio failed with error -5> After some digging I noticed that the supplied clock rate differs between mainline (114000000Hz) vs common-clock-v7 (18000000). Since we're not setting the rate in mdio, using LPSC_SET_RATE_PARENT would not help like with lcdc.

Can you post the output of this command so that I can see how your clocks are setup:

cat /sys/kernel/debug/clk/clk_summary

Quoted 2 lines

After that, the boot just hangs without ever getting to emac's probe.

Using your workaround, can you run:

cat /sys/kernel/debug/pm_genpd/pm_genpd_summary

If you see:

   1e27000.clock-controller: emac  off-0

then genpd is not working like it is supposed to. You should see something
like this for device that are working:

           1e27000.clock-controller: uart2  on
     /devices/platform/soc at 1c00000/1d0d000.serial        active
Quoted 5 lines

Once I set the emac clock to always enabled (a workaround that was necessary with v6, but could be dropped with my first genpd-in-a-separate-driver attempt), I'm getting a rather strange NULL pointer dereference:

Quoted 8 lines

I noticed this too when adding the power-domains property to some device tree nodes. This is part of the reason why I didn't add it everywhere. I wasn't able to figure out the cause of this yet. As a work around though, please try removing the power-domains property from the emac and mdio nodes and use your previous workaround of having an always enabled clock.

When I use any of the workarounds I just keep getting more problems (e.g. [1] from blk and pinctrl). I only had a couple hours today to play with it but it seems to me we have some memory corruption somewhere. I'll check the initialization order of all the frameworks involved tomorrow.

Quoted 9 lines
Quoted 5 lines

Best regards,
Bartosz

[1] https://pastebin.com/75mkkuJL

I wonder if we need to delete all of the __init and __initconst attributes now that this has been converted to platform devices.

Duh... Of course we do. IIRC everything in the init section gets removed after late_initcall. I'll test that tomorrow.

Bart

#60 lore raw

2018-02-21 18:46 GMT+01:00 Bartosz Golaszewski <[email protected]>:

Quoted 88 lines

2018-02-21 18:05 GMT+01:00 David Lechner <[email protected]>:

Quoted 87 lines · Bartosz Golaszewski
Quoted 85 lines

2018-02-20 19:39 GMT+01:00 David Lechner <[email protected]>:

Quoted 63 lines · Bartosz Golaszewski
Quoted 17 lines

2018-02-19 21:21 GMT+01:00 David Lechner <[email protected]>:

Quoted 5 lines

This series converts mach-davinci to use the common clock framework.

Hi David,

just some quick results from today's playing with v7.

I started out with da850-lcdk with my standard rootfs over NFS. I was not able to boot to console so far. The first problem is that mdio fails to probe:

Quoted 8 lines

libphy: Fixed MDIO Bus: probed
davinci_mdio 1e24000.mdio: davinci mdio revision 1.5, bus freq 2200000 davinci_mdio 1e24000.mdio: no live phy, scanning all
davinci_mdio: probe of 1e24000.mdio failed with error -5> After some digging I noticed that the supplied clock rate differs between mainline (114000000Hz) vs common-clock-v7 (18000000). Since we're not setting the rate in mdio, using LPSC_SET_RATE_PARENT would not help like with lcdc.

Can you post the output of this command so that I can see how your clocks are setup:

cat /sys/kernel/debug/clk/clk_summary

Quoted 2 lines

After that, the boot just hangs without ever getting to emac's probe.

Using your workaround, can you run:

cat /sys/kernel/debug/pm_genpd/pm_genpd_summary

If you see:

   1e27000.clock-controller: emac  off-0

then genpd is not working like it is supposed to. You should see something
like this for device that are working:

           1e27000.clock-controller: uart2  on
     /devices/platform/soc at 1c00000/1d0d000.serial        active
Quoted 5 lines

Once I set the emac clock to always enabled (a workaround that was necessary with v6, but could be dropped with my first genpd-in-a-separate-driver attempt), I'm getting a rather strange NULL pointer dereference:

Quoted 8 lines

I noticed this too when adding the power-domains property to some device tree nodes. This is part of the reason why I didn't add it everywhere. I wasn't able to figure out the cause of this yet. As a work around though, please try removing the power-domains property from the emac and mdio nodes and use your previous workaround of having an always enabled clock.

When I use any of the workarounds I just keep getting more problems (e.g. [1] from blk and pinctrl). I only had a couple hours today to play with it but it seems to me we have some memory corruption somewhere. I'll check the initialization order of all the frameworks involved tomorrow.

Best regards,
Bartosz

[1] https://pastebin.com/75mkkuJL

Quoted 8 lines
Quoted 3 lines

I wonder if we need to delete all of the __init and __initconst attributes now that this has been converted to platform devices.

Duh... Of course we do. IIRC everything in the init section gets removed after late_initcall. I'll test that tomorrow.

Bart

It's not that. Not only anyway as it doesn't fix anything, I'm getting the exact same panics. I tried to play with various settings, like initializing the platform driver later in the boot sequence etc. but haven't yet figured out what's going on.

Bart