Marvell Berlin full clock support
Subsystems (2)
v2 cover Marvell Berlin full clock support
Mike,
this is v2 of the Berlin SoC clock driver [1] but with a reworked DT binding as requested [2]. We decided to not even try to split up the chip control registers that deal with pinmux, padmux, clock, reset, and evil stuff we haven't even looked at. Instead we keep a single node that clock driver will remap early, while proper platform_drivers use a regmap instead. Although clock and other drivers share the same register range, they use individual registers exclusively.
There are some functional fixes in the single clock drivers, I noticed while retesting each individial driver. There will be more to fixup but without any drivers actually using the clocks, it is hard to tell what isn't working now.
Anyway, the current binding should match what you requested and having a clock driver for v3.16 will really be a huge benefit for us to work on more driver support.
If you are fine with it, please take patches 2-7 and I'll pick up 1,8-10 in berlin branch.
Sebastian
[1] https://lkml.kernel.org/r/1399839881-29895-1-git-send-email-sebastian.hesselbarth at gmail.com
[2] https://lkml.kernel.org/r/20140515044106.19795.57249 at quantum
Alexandre Belloni (4):
clk: berlin: add driver for BG2x simple PLLs
clk: berlin: add driver for BG2x complex divider cells
clk: berlin: add core clock driver for BG2Q
ARM: dts: berlin: convert BG2Q to DT clock nodes
Sebastian Hesselbarth (6):
dt-binding: ARM: add clock binding docs for Marvell Berlin2 SoCs
clk: berlin: add binding include for Berlin SoC clock ids
clk: berlin: add driver for BG2x audio/video PLL
clk: berlin: add core clock driver for BG2/BG2CD
ARM: dts: berlin: convert BG2CD to DT clock nodes
ARM: dts: berlin: convert BG2 to DT clock nodes
.../devicetree/bindings/arm/marvell,berlin.txt | 47 ++ arch/arm/boot/dts/berlin2.dtsi | 56 +- arch/arm/boot/dts/berlin2cd.dtsi | 53 +- arch/arm/boot/dts/berlin2q.dtsi | 54 +- drivers/clk/Makefile | 1 + drivers/clk/berlin/Makefile | 4 + drivers/clk/berlin/berlin2-avpll.c | 393 ++++++++++++ drivers/clk/berlin/berlin2-avpll.h | 36 ++ drivers/clk/berlin/berlin2-div.c | 265 ++++++++ drivers/clk/berlin/berlin2-div.h | 89 +++ drivers/clk/berlin/berlin2-pll.c | 117 ++++ drivers/clk/berlin/berlin2-pll.h | 37 ++ drivers/clk/berlin/bg2.c | 691 +++++++++++++++++++++ drivers/clk/berlin/bg2q.c | 389 ++++++++++++ drivers/clk/berlin/common.h | 29 + include/dt-bindings/clock/berlin2.h | 45 ++ include/dt-bindings/clock/berlin2q.h | 31 + 17 files changed, 2240 insertions(+), 97 deletions(-) create mode 100644 drivers/clk/berlin/Makefile create mode 100644 drivers/clk/berlin/berlin2-avpll.c create mode 100644 drivers/clk/berlin/berlin2-avpll.h create mode 100644 drivers/clk/berlin/berlin2-div.c create mode 100644 drivers/clk/berlin/berlin2-div.h create mode 100644 drivers/clk/berlin/berlin2-pll.c create mode 100644 drivers/clk/berlin/berlin2-pll.h create mode 100644 drivers/clk/berlin/bg2.c create mode 100644 drivers/clk/berlin/bg2q.c create mode 100644 drivers/clk/berlin/common.h create mode 100644 include/dt-bindings/clock/berlin2.h create mode 100644 include/dt-bindings/clock/berlin2q.h
---
Cc: Rob Herring <[email protected]>
Cc: Pawel Moll <[email protected]>
Cc: Mark Rutland <[email protected]>
Cc: Ian Campbell <[email protected]>
Cc: Kumar Gala <[email protected]>
Cc: Randy Dunlap <[email protected]>
Cc: Mike Turquette <[email protected]>
Cc: Alexandre Belloni <[email protected]>
Cc: Jisheng Zhang <[email protected]>
Cc: devicetree at vger.kernel.org
Cc: linux-doc at vger.kernel.org
Cc: linux-arm-kernel at lists.infradead.org
Cc: linux-kernel at vger.kernel.org
Signature · 1 line
1.9.1
PATCH v2 1/10 dt-binding: ARM: add clock binding docs for Marvell Berlin2 SoCs
This adds mandatory device tree binding documentation for the clock related IP found on Marvell Berlin2 (BG2, BG2CD, and BG2Q) SoCs to the Berlin SoC binding documentation.
---
Changelog:v1->v2:
- typo fixed (Reported by Alexandre Belloni)
- reworked binding to not represent individual clocks but chip control IP/registers instead (Suggested by Mike Turquette)
- dropped clock indices, refer to the include instead (Requested by Mike Turquette)
- moved the documentation from bindings/clock to Marvell Berlin SoC binding, as there will be more functions (e.g. pinctrl) to describe
--- .../devicetree/bindings/arm/marvell,berlin.txt | 47 ++++++++++++++++++++++ 1 file changed, 47 insertions(+)
Documentation/devicetree/bindings/arm/marvell,berlin.txt +47 -0
@@ -23,3 +23,50 @@ SoC and board used. Currently known SoC compatibles are: ... } + +* Marvell Berlin2 chip control binding + +Marvell Berlin SoCs have a chip control register set providing several +individual registers dealing with pinmux, padmux, clock, reset, and secondary +CPU boot address. Unfortunately, the individual registers are spread among the +chip control registers, so there should be a single DT node only providing the +different functions which are described below. + +Required properties: +- compatible: shall be one of + "marvell,berlin2-chip-ctrl" for BG2 + "marvell,berlin2cd-chip-ctrl" for BG2CD + "marvell,berlin2q-chip-ctrl" for BG2Q +- reg: address and length of following register sets for + BG2/BG2CD: chip control register set + BG2Q: chip control register set and cpu pll registers + +* Clock provider binding + +As clock related registers are spread among the chip control registers, the +chip control node also provides the clocks. Marvell Berlin2 (BG2, BG2CD, BG2Q) +SoCs share the same IP for PLLs and clocks, with some minor differences in +features and register layout. + +Required properties: +- #clock-cells: shall be set to 1 +- clocks: clock specifiers referencing the core clock input clocks +- clock-names: array of strings describing the input clock specifiers above. + Allowed clock-names for the reference clocks are + "refclk" for the SoCs osciallator input on all SoCs, + and SoC-specific input clocks for + BG2/BG2CD: "video_ext0" for the external video clock input + +Clocks provided by core clocks shall be referenced by a clock specifier +indexing one of the provided clocks. Refer to dt-bindings/clock/berlin<soc>.h +for the corresponding index mapping. + +Example: + +chip: chip-control at ea0000 { + compatible = "marvell,berlin2-chip-ctrl"; + #clock-cells = <1>; + reg = <0xea0000 0x400>; + clocks = <&refclk>, <&externaldev 0>; + clock-names = "refclk", "video_ext0"; +};
Signature · 1 line
1.9.1
Re: [PATCH v2 01/10] dt-binding: ARM: add clock binding docs for Marvell Berlin2 SoCs
Quoted 5 lines · Sebastian Hesselbarth
This adds mandatory device tree binding documentation for the clock related IP found on Marvell Berlin2 (BG2, BG2CD, and BG2Q) SoCs to the Berlin SoC binding documentation.
Signed-off-by Sebastian Hesselbarth <[email protected]>
Quoted 86 lines
---
Changelog:v1->v2:
- typo fixed (Reported by Alexandre Belloni)
- reworked binding to not represent individual clocks but chip control IP/registers instead (Suggested by Mike Turquette)
- dropped clock indices, refer to the include instead (Requested by Mike Turquette)
- moved the documentation from bindings/clock to Marvell Berlin SoC binding, as there will be more functions (e.g. pinctrl) to describeCc Rob Herring <[email protected]>Cc Pawel Moll <[email protected]>Cc Mark Rutland <[email protected]>Cc Ian Campbell <[email protected]>Cc Kumar Gala <[email protected]>Cc Randy Dunlap <[email protected]>Cc Mike Turquette <[email protected]>Cc Alexandre Belloni <[email protected]>Cc Jisheng Zhang <[email protected]>Cc devicetree at vger.kernel.orgCc linux-doc at vger.kernel.orgCc linux-arm-kernel at lists.infradead.orgCc linux-kernel at vger.kernel.org--- .../devicetree/bindings/arm/marvell,berlin.txt | 47 ++++++++++++++++++++++ 1 file changed, 47 insertions(+)Documentation/devicetree/bindings/arm/marvell,berlin.txt +47
-0@@ -23,3 +23,50 @@ SoC and board used. Currently known SoC compatibles are: } + +* Marvell Berlin2 chip control binding + +Marvell Berlin SoCs have a chip control register set providing several +individual registers dealing with pinmux, padmux, clock, reset, and secondary +CPU boot address. Unfortunately, the individual registers are spread among the +chip control registers, so there should be a single DT node only providing the +different functions which are described below. + +Required properties: +- compatible: shall be one of + "marvell,berlin2-chip-ctrl" for BG2 + "marvell,berlin2cd-chip-ctrl" for BG2CD + "marvell,berlin2q-chip-ctrl" for BG2Q +- reg: address and length of following register sets for + BG2/BG2CD: chip control register set + BG2Q: chip control register set and cpu pll registers + +* Clock provider binding + +As clock related registers are spread among the chip control registers, the +chip control node also provides the clocks. Marvell Berlin2 (BG2, BG2CD, BG2Q) +SoCs share the same IP for PLLs and clocks, with some minor differences in +features and register layout. + +Required properties: +- #clock-cells: shall be set to 1 +- clocks: clock specifiers referencing the core clock input clocks +- clock-names: array of strings describing the input clock specifiers above. + Allowed clock-names for the reference clocks are + "refclk" for the SoCs osciallator input on all SoCs, + and SoC-specific input clocks for + BG2/BG2CD: "video_ext0" for the external video clock input + +Clocks provided by core clocks shall be referenced by a clock specifier +indexing one of the provided clocks. Refer to dt-bindings/clock/berlin<soc>.h +for the corresponding index mapping. + +Example: + +chip: chip-control at ea0000 { + compatible = "marvell,berlin2-chip-ctrl"; + #clock-cells = <1>; + reg = <0xea0000 0x400>; + clocks = <&refclk>, <&externaldev 0>; + clock-names = "refclk", "video_ext0"; +};Signature · 1 line
1.9.1
Signature · 3 lines
Alexandre Belloni, Free Electrons Embedded Linux, Kernel and Android engineering http://free-electrons.com
PATCH v2 2/10 clk: berlin: add binding include for Berlin SoC clock ids
In reply to Sebastian HesselbarthThis adds a dt-binding include for Marvell Berlin BG2/BG2CD and BG2Q core clock IDs.
---
Changelog:v1->v2:
- separate patch to allow to use it in the driver (Suggested by Alexandre Belloni)
--- include/dt-bindings/clock/berlin2.h | 45 ++++++++++++++++++++++++++++++++++++ include/dt-bindings/clock/berlin2q.h | 31 +++++++++++++++++++++++++ 2 files changed, 76 insertions(+) create mode 100644 include/dt-bindings/clock/berlin2.h create mode 100644 include/dt-bindings/clock/berlin2q.h
include/dt-bindings/clock/berlin2.h new file +45 -0
@@ -0,0 +1,45 @@ +/* +* Berlin2 BG2/BG2CD clock tree IDs +*/ + +#define CLKID_SYS 0 +#define CLKID_CPU 1 +#define CLKID_DRMFIGO 2 +#define CLKID_CFG 3 +#define CLKID_GFX 4 +#define CLKID_ZSP 5 +#define CLKID_PERIF 6 +#define CLKID_PCUBE 7 +#define CLKID_VSCOPE 8 +#define CLKID_NFC_ECC 9 +#define CLKID_VPP 10 +#define CLKID_APP 11 +#define CLKID_AUDIO0 12 +#define CLKID_AUDIO2 13 +#define CLKID_AUDIO3 14 +#define CLKID_AUDIO1 15 +#define CLKID_GFX3D_CORE 16 +#define CLKID_GFX3D_SYS 17 +#define CLKID_ARC 18 +#define CLKID_VIP 19 +#define CLKID_SDIO0XIN 20 +#define CLKID_SDIO1XIN 21 +#define CLKID_GFX3D_EXTRA 22 +#define CLKID_GC360 23 +#define CLKID_SDIO_DLLMST 24 +#define CLKID_GETH0 25 +#define CLKID_GETH1 26 +#define CLKID_SATA 27 +#define CLKID_AHBAPB 28 +#define CLKID_USB0 29 +#define CLKID_USB1 30 +#define CLKID_PBRIDGE 31 +#define CLKID_SDIO0 32 +#define CLKID_SDIO1 33 +#define CLKID_NFC 34 +#define CLKID_SMEMC 35 +#define CLKID_AUDIOHD 36 +#define CLKID_VIDEO0 37 +#define CLKID_VIDEO1 38 +#define CLKID_VIDEO2 39 +#define CLKID_TWD 40
include/dt-bindings/clock/berlin2q.h new file +31 -0
@@ -0,0 +1,31 @@ +/* +* Berlin2 BG2Q clock tree IDs +*/ + +#define CLKID_SYS 0 +#define CLKID_DRMFIGO 1 +#define CLKID_CFG 2 +#define CLKID_GFX2D 3 +#define CLKID_ZSP 4 +#define CLKID_PERIF 5 +#define CLKID_PCUBE 6 +#define CLKID_VSCOPE 7 +#define CLKID_NFC_ECC 8 +#define CLKID_VPP 9 +#define CLKID_APP 10 +#define CLKID_SDIO0XIN 11 +#define CLKID_SDIO1XIN 12 +#define CLKID_GFX2DAXI 13 +#define CLKID_GETH0 14 +#define CLKID_SATA 15 +#define CLKID_AHBAPB 16 +#define CLKID_USB0 17 +#define CLKID_USB1 18 +#define CLKID_USB2 19 +#define CLKID_USB3 20 +#define CLKID_PBRIDGE 21 +#define CLKID_SDIO 22 +#define CLKID_NFC 23 +#define CLKID_SMEMC 24 +#define CLKID_PCIE 25 +#define CLKID_TWD 26
Signature · 1 line
1.9.1
PATCH v2 3/10 clk: berlin: add driver for BG2x audio/video PLL
In reply to Sebastian HesselbarthThis is a driver for the AVPLLs built upon a VCO with 8 channels each found on Marvell Berlin2 SoCs. While both VCOs found on BG2/BG2CD share the same register set, sometimes registers shifts for one of the VCOs are a bit off. Nothing serious that should require a separate driver, so deal with both VCOs in a single driver instead.
---
Changelog:v1->v2:
- separate include for AVPLL driver
- split single clock driver for both VCO and 8 channels into separate drivers for VCO and each channel. BG2Q will be different to BG2/BG2CD and it allows us to shove in CCF flags for each of the channels. (Suggested by Alexandre Belloni, Mike Turquette)
--- drivers/clk/Makefile | 1 + drivers/clk/berlin/Makefile | 1 + drivers/clk/berlin/berlin2-avpll.c | 393 +++++++++++++++++++++++++++++++++++++ drivers/clk/berlin/berlin2-avpll.h | 36 ++++ 4 files changed, 431 insertions(+) create mode 100644 drivers/clk/berlin/Makefile create mode 100644 drivers/clk/berlin/berlin2-avpll.c create mode 100644 drivers/clk/berlin/berlin2-avpll.h
drivers/clk/Makefile +1 -0
@@ -31,6 +31,7 @@ obj-$(CONFIG_COMMON_CLK_WM831X) += clk-wm831x.o obj-$(CONFIG_COMMON_CLK_XGENE) += clk-xgene.o obj-$(CONFIG_COMMON_CLK_AT91) += at91/ obj-$(CONFIG_ARCH_BCM_MOBILE) += bcm/ +obj-$(CONFIG_ARCH_BERLIN) += berlin/ obj-$(CONFIG_ARCH_HI3xxx) += hisilicon/ obj-$(CONFIG_ARCH_HIP04) += hisilicon/ obj-$(CONFIG_COMMON_CLK_KEYSTONE) += keystone/
drivers/clk/berlin/Makefile new file +1 -0
@@ -0,0 +1 @@ +obj-y += berlin2-avpll.o
drivers/clk/berlin/berlin2-avpll.c new file +393 -0
393 lines not on this page · raw message
drivers/clk/berlin/berlin2-avpll.h new file +36 -0
@@ -0,0 +1,36 @@ +/* +* Copyright (c) 2014 Marvell Technology Group Ltd. +* +* Sebastian Hesselbarth <[email protected]> +* Alexandre Belloni <[email protected]> +* +* This program is free software; you can redistribute it and/or modify it +* under the terms and conditions of the GNU General Public License, +* version 2, as published by the Free Software Foundation. +* +* This program is distributed in the hope it will be useful, but WITHOUT +* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for +* more details. +* +* You should have received a copy of the GNU General Public License along with +* this program. If not, see <http://www.gnu.org/licenses/>. +*/ +#ifndef __BERLIN2_AVPLL_H +#define __BERLIN2_AVPLL_H + +struct clk ; + +#define BERLIN2_AVPLL_BIT_QUIRK BIT(0) +#define BERLIN2_AVPLL_SCRAMBLE_QUIRK BIT(1) + +struct clk *__init +berlin2_avpll_vco_register (void __iomem *base,const char *name, +const char *parent_name,u8 vco_flags,unsigned long flags); + +struct clk *__init +berlin2_avpll_channel_register (void __iomem *base,const char *name, +u8 index,const char *parent_name,u8 ch_flags, +unsigned long flags); + +#endif /* __BERLIN2_AVPLL_H */
Signature · 1 line
1.9.1
PATCH v2 4/10 clk: berlin: add driver for BG2x simple PLLs
In reply to Sebastian HesselbarthFrom: Alexandre Belloni <[email protected]>
This is a clock driver for the simple PLLs found on Berlin SoCs. With repect to PLL registers and features, BG2/BG2CD and BG2Q are slightly different, e.g. different allowed VCO dividers and bit shifts.
---
Changelog:v1->v2:
- separate include for the PLL driver
--- drivers/clk/berlin/Makefile | 2 +- drivers/clk/berlin/berlin2-pll.c | 117 +++++++++++++++++++++++++++++++++++++++ drivers/clk/berlin/berlin2-pll.h | 37 +++++++++++++ 3 files changed, 155 insertions(+), 1 deletion(-) create mode 100644 drivers/clk/berlin/berlin2-pll.c create mode 100644 drivers/clk/berlin/berlin2-pll.h
drivers/clk/berlin/Makefile +1 -1
@@ -1 +1 @@ -obj-y += berlin2-avpll.o +obj-y += berlin2-avpll.o berlin2-pll.o
drivers/clk/berlin/berlin2-pll.c new file +117 -0
117 lines not on this page · raw message
drivers/clk/berlin/berlin2-pll.h new file +37 -0
@@ -0,0 +1,37 @@ +/* +* Copyright (c) 2014 Marvell Technology Group Ltd. +* +* Alexandre Belloni <[email protected]> +* Sebastian Hesselbarth <[email protected]> +* +* This program is free software; you can redistribute it and/or modify it +* under the terms and conditions of the GNU General Public License, +* version 2, as published by the Free Software Foundation. +* +* This program is distributed in the hope it will be useful, but WITHOUT +* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for +* more details. +* +* You should have received a copy of the GNU General Public License along with +* this program. If not, see <http://www.gnu.org/licenses/>. +*/ +#ifndef __BERLIN2_PLL_H +#define __BERLIN2_PLL_H + +struct clk ; + +struct berlin2_pll_map { +const u8 vcodiv[16 ]; +u8 mult; +u8 fbdiv_shift; +u8 rfdiv_shift; +u8 divsel_shift; +}; + +struct clk *__init +berlin2_pll_register (const struct berlin2_pll_map *map, +void __iomem *base,const char *name, +const char *parent_name,unsigned long flags); + +#endif /* __BERLIN2_PLL_H */
Signature · 1 line
1.9.1
PATCH v2 5/10 clk: berlin: add driver for BG2x complex divider cells
In reply to Sebastian HesselbarthFrom: Alexandre Belloni <[email protected]>
This is a driver for the complex divider cells found on Marvell Berlin2 SoCs. The cells come in two flavors: single register cells and shared register cells.
---
Changelog:v1->v2:
- separate include for the DIV cell driver
--- drivers/clk/berlin/Makefile | 2 +- drivers/clk/berlin/berlin2-div.c | 265 +++++++++++++++++++++++++++++++++++++++ drivers/clk/berlin/berlin2-div.h | 89 +++++++++++++ 3 files changed, 355 insertions(+), 1 deletion(-) create mode 100644 drivers/clk/berlin/berlin2-div.c create mode 100644 drivers/clk/berlin/berlin2-div.h
drivers/clk/berlin/Makefile +1 -1
@@ -1 +1 @@ -obj-y += berlin2-avpll.o berlin2-pll.o +obj-y += berlin2-avpll.o berlin2-pll.o berlin2-div.o
drivers/clk/berlin/berlin2-div.c new file +265 -0
265 lines not on this page · raw message
drivers/clk/berlin/berlin2-div.h new file +89 -0
89 lines not on this page · raw message
Signature · 1 line
1.9.1
PATCH v2 6/10 clk: berlin: add core clock driver for BG2/BG2CD
In reply to Sebastian HesselbarthThis driver deals with the core clocks found on Marvell Berlin BG2 and BG2CD. For the shared register dividers, make use of the corresponding driver and add some single clock muxes and gates for the rest.
---
Changelog:v1->v2:
- adapt to new single chip control node and compatible
- swallow twd clock node
--- drivers/clk/berlin/Makefile | 2 + drivers/clk/berlin/bg2.c | 691 ++++++++++++++++++++++++++++++++++++++++++++ drivers/clk/berlin/common.h | 29 ++ 3 files changed, 722 insertions(+) create mode 100644 drivers/clk/berlin/bg2.c create mode 100644 drivers/clk/berlin/common.h
drivers/clk/berlin/Makefile +2 -0
@@ -1 +1,3 @@ obj-y += berlin2-avpll.o berlin2-pll.o berlin2-div.o +obj-$(CONFIG_MACH_BERLIN_BG2) += bg2.o +obj-$(CONFIG_MACH_BERLIN_BG2CD) += bg2.o
drivers/clk/berlin/bg2.c new file +691 -0
691 lines not on this page · raw message
drivers/clk/berlin/common.h new file +29 -0
@@ -0,0 +1,29 @@ +/* +* Copyright (c) 2014 Marvell Technology Group Ltd. +* +* Sebastian Hesselbarth <[email protected]> +* Alexandre Belloni <[email protected]> +* +* This program is free software; you can redistribute it and/or modify it +* under the terms and conditions of the GNU General Public License, +* version 2, as published by the Free Software Foundation. +* +* This program is distributed in the hope it will be useful, but WITHOUT +* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for +* more details. +* +* You should have received a copy of the GNU General Public License along with +* this program. If not, see <http://www.gnu.org/licenses/>. +*/ +#ifndef __BERLIN2_COMMON_H +#define __BERLIN2_COMMON_H + +struct berlin2_gate_data { +const char *name; +const char *parent_name; +u8 bit_idx; +unsigned long flags; +}; + +#endif /* BERLIN2_COMMON_H */
Signature · 1 line
1.9.1
Re: [PATCH v2 06/10] clk: berlin: add core clock driver for BG2/BG2CD
Quoted 6 lines · Sebastian Hesselbarth
This driver deals with the core clocks found on Marvell Berlin BG2 and BG2CD. For the shared register dividers, make use of the corresponding driver and add some single clock muxes and gates for the rest.
Signed-off-by Sebastian Hesselbarth <[email protected]>
Quoted 762 lines
---
Changelog:v1->v2:
- adapt to new single chip control node and compatible
- swallow twd clock nodeCc Mike Turquette <[email protected]>Cc Alexandre Belloni <[email protected]>Cc Jisheng Zhang <[email protected]>Cc linux-arm-kernel at lists.infradead.orgCc linux-kernel at vger.kernel.org--- drivers/clk/berlin/Makefile | 2 + drivers/clk/berlin/bg2.c | 691 ++++++++++++++++++++++++++++++++++++++++++++ drivers/clk/berlin/common.h | 29 ++ 3 files changed, 722 insertions(+) create mode 100644 drivers/clk/berlin/bg2.c create mode 100644 drivers/clk/berlin/common.hdrivers/clk/berlin/Makefile +2
-0@@ -1 +1,3 @@ obj-y += berlin2-avpll.o berlin2-pll.o berlin2-div.o +obj-$(CONFIG_MACH_BERLIN_BG2) += bg2.o +obj-$(CONFIG_MACH_BERLIN_BG2CD) += bg2.odrivers/clk/berlin/bg2.c new file +691
-0@@ -0,0 +1,691 @@ +/* +* Copyright (c) 2014 Marvell Technology Group Ltd. +* +* Sebastian Hesselbarth <[email protected]> +* Alexandre Belloni <[email protected]> +* +* This program is free software; you can redistribute it and/or modify it +* under the terms and conditions of the GNU General Public License, +* version 2, as published by the Free Software Foundation. +* +* This program is distributed in the hope it will be useful, but WITHOUT +* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for +* more details. +* +* You should have received a copy of the GNU General Public License along with +* this program. If not, see <http://www.gnu.org/licenses/>. +*/ + +#include <linux/clk.h> +#include <linux/clk-provider.h> +#include <linux/kernel.h> +#include <linux/of.h> +#include <linux/of_address.h> +#include <linux/slab.h> + +#include <dt-bindings/clock/berlin2.h> + +#include "berlin2-avpll.h" +#include "berlin2-div.h" +#include "berlin2-pll.h" +#include "common.h" + +#define REG_PINMUX0 0x0000 +#define REG_PINMUX1 0x0004 +#define REG_SYSPLLCTL0 0x0014 +#define REG_SYSPLLCTL4 0x0024 +#define REG_MEMPLLCTL0 0x0028 +#define REG_MEMPLLCTL4 0x0038 +#define REG_CPUPLLCTL0 0x003c +#define REG_CPUPLLCTL4 0x004c +#define REG_AVPLLCTL0 0x0050 +#define REG_AVPLLCTL31 0x00cc +#define REG_AVPLLCTL62 0x0148 +#define REG_PLLSTATUS 0x014c +#define REG_CLKENABLE 0x0150 +#define REG_CLKSELECT0 0x0154 +#define REG_CLKSELECT1 0x0158 +#define REG_CLKSELECT2 0x015c +#define REG_CLKSELECT3 0x0160 +#define REG_CLKSWITCH0 0x0164 +#define REG_CLKSWITCH1 0x0168 +#define REG_RESET_TRIGGER 0x0178 +#define REG_RESET_STATUS0 0x017c +#define REG_RESET_STATUS1 0x0180 +#define REG_SW_GENERIC0 0x0184 +#define REG_SW_GENERIC3 0x0190 +#define REG_PRODUCTID 0x01cc +#define REG_PRODUCTID_EXT 0x01d0 +#define REG_GFX3DCORE_CLKCTL 0x022c +#define REG_GFX3DSYS_CLKCTL 0x0230 +#define REG_ARC_CLKCTL 0x0234 +#define REG_VIP_CLKCTL 0x0238 +#define REG_SDIO0XIN_CLKCTL 0x023c +#define REG_SDIO1XIN_CLKCTL 0x0240 +#define REG_GFX3DEXTRA_CLKCTL 0x0244 +#define REG_GFX3D_RESET 0x0248 +#define REG_GC360_CLKCTL 0x024c +#define REG_SDIO_DLLMST_CLKCTL 0x0250 + +/* +* BG2/BG2CD SoCs have the following audio/video I/O units: +* +* audiohd: HDMI TX audio +* audio0: 7.1ch TX +* audio1: 2ch TX +* audio2: 2ch RX +* audio3: SPDIF TX +* video0: HDMI video +* video1: Secondary video +* video2: SD auxiliary video +* +* There are no external audio clocks (ACLKI0, ACLKI1) and +* only one external video clock (VCLKI0). +* +* Currently missing bits and pieces: +* - audio_fast_pll is unknown +* - audiohd_pll is unknown +* - video0_pll is unknown +* - audio[023], audiohd parent pll is assumed to be audio_fast_pll +* +*/ + +#define MAX_CLKS 41 +static struct clk *clks[MAX_CLKS ]; +static struct clk_onecell_data clk_data; +static DEFINE_SPINLOCK (lock); +static void __iomem *gbase; + +enum { +REFCLK ,VIDEO_EXT0 , +SYSPLL ,MEMPLL ,CPUPLL , +AVPLL_A1 ,AVPLL_A2 ,AVPLL_A3 ,AVPLL_A4 , +AVPLL_A5 ,AVPLL_A6 ,AVPLL_A7 ,AVPLL_A8 , +AVPLL_B1 ,AVPLL_B2 ,AVPLL_B3 ,AVPLL_B4 , +AVPLL_B5 ,AVPLL_B6 ,AVPLL_B7 ,AVPLL_B8 , +AUDIO1_PLL ,AUDIO_FAST_PLL , +VIDEO0_PLL ,VIDEO0_IN , +VIDEO1_PLL ,VIDEO1_IN , +VIDEO2_PLL ,VIDEO2_IN , +}; + +static const char *clk_names[] = { + [REFCLK ] ="refclk" , + [VIDEO_EXT0 ] ="video_ext0" , + [SYSPLL ] ="syspll" , + [MEMPLL ] ="mempll" , + [CPUPLL ] ="cpupll" , + [AVPLL_A1 ] ="avpll_a1" , + [AVPLL_A2 ] ="avpll_a2" , + [AVPLL_A3 ] ="avpll_a3" , + [AVPLL_A4 ] ="avpll_a4" , + [AVPLL_A5 ] ="avpll_a5" , + [AVPLL_A6 ] ="avpll_a6" , + [AVPLL_A7 ] ="avpll_a7" , + [AVPLL_A8 ] ="avpll_a8" , + [AVPLL_B1 ] ="avpll_b1" , + [AVPLL_B2 ] ="avpll_b2" , + [AVPLL_B3 ] ="avpll_b3" , + [AVPLL_B4 ] ="avpll_b4" , + [AVPLL_B5 ] ="avpll_b5" , + [AVPLL_B6 ] ="avpll_b6" , + [AVPLL_B7 ] ="avpll_b7" , + [AVPLL_B8 ] ="avpll_b8" , + [AUDIO1_PLL ] ="audio1_pll" , + [AUDIO_FAST_PLL ] ="audio_fast_pll" , + [VIDEO0_PLL ] ="video0_pll" , + [VIDEO0_IN ] ="video0_in" , + [VIDEO1_PLL ] ="video1_pll" , + [VIDEO1_IN ] ="video1_in" , + [VIDEO2_PLL ] ="video2_pll" , + [VIDEO2_IN ] ="video2_in" , +}; + +static const struct berlin2_pll_map bg2_pll_map__initconst = { + .vcodiv = {10 ,15 ,20 ,25 ,30 ,40 ,50 ,60 ,80 }, + .mult =10 , + .fbdiv_shift =6 , + .rfdiv_shift =1 , + .divsel_shift =7 , +}; + +static const u8 default_parent_ids[] = { +SYSPLL ,AVPLL_B4 ,AVPLL_A5 ,AVPLL_B6 ,AVPLL_B7 ,SYSPLL +}; + +static const struct berlin2_div_data bg2_divs[]__initconst = { + { + .name ="sys" , + .parent_ids = (const u8 []){ +SYSPLL ,AVPLL_B4 ,AVPLL_B5 ,AVPLL_B6 ,AVPLL_B7 ,SYSPLL + }, + .num_parents =6 , + .map = { +BERLIN2_DIV_GATE (REG_CLKENABLE ,0 ), +BERLIN2_PLL_SELECT (REG_CLKSELECT0 ,0 ), +BERLIN2_DIV_SELECT (REG_CLKSELECT0 ,3 ), +BERLIN2_PLL_SWITCH (REG_CLKSWITCH0 ,3 ), +BERLIN2_DIV_SWITCH (REG_CLKSWITCH0 ,4 ), +BERLIN2_DIV_D3SWITCH (REG_CLKSWITCH0 ,5 ), + }, + .div_flags =BERLIN2_DIV_HAS_GATE |BERLIN2_DIV_HAS_MUX , + .flags =CLK_IGNORE_UNUSED , + }, + { + .name ="cpu" , + .parent_ids = (const u8 []){ +CPUPLL ,MEMPLL ,MEMPLL ,MEMPLL ,MEMPLL + }, + .num_parents =5 , + .map = { +BERLIN2_PLL_SELECT (REG_CLKSELECT0 ,6 ), +BERLIN2_DIV_SELECT (REG_CLKSELECT0 ,9 ), +BERLIN2_PLL_SWITCH (REG_CLKSWITCH0 ,6 ), +BERLIN2_DIV_SWITCH (REG_CLKSWITCH0 ,7 ), +BERLIN2_DIV_D3SWITCH (REG_CLKSWITCH0 ,8 ), + }, + .div_flags =BERLIN2_DIV_HAS_MUX , + .flags =0 , + }, + { + .name ="drmfigo" , + .parent_ids = default_parent_ids, + .num_parents =ARRAY_SIZE (default_parent_ids), + .map = { +BERLIN2_DIV_GATE (REG_CLKENABLE ,16 ), +BERLIN2_PLL_SELECT (REG_CLKSELECT0 ,17 ), +BERLIN2_DIV_SELECT (REG_CLKSELECT0 ,20 ), +BERLIN2_PLL_SWITCH (REG_CLKSWITCH0 ,12 ), +BERLIN2_DIV_SWITCH (REG_CLKSWITCH0 ,13 ), +BERLIN2_DIV_D3SWITCH (REG_CLKSWITCH0 ,14 ), + }, + .div_flags =BERLIN2_DIV_HAS_GATE |BERLIN2_DIV_HAS_MUX , + .flags =0 , + }, + { + .name ="cfg" , + .parent_ids = default_parent_ids, + .num_parents =ARRAY_SIZE (default_parent_ids), + .map = { +BERLIN2_DIV_GATE (REG_CLKENABLE ,1 ), +BERLIN2_PLL_SELECT (REG_CLKSELECT0 ,23 ), +BERLIN2_DIV_SELECT (REG_CLKSELECT0 ,26 ), +BERLIN2_PLL_SWITCH (REG_CLKSWITCH0 ,15 ), +BERLIN2_DIV_SWITCH (REG_CLKSWITCH0 ,16 ), +BERLIN2_DIV_D3SWITCH (REG_CLKSWITCH0 ,17 ), + }, + .div_flags =BERLIN2_DIV_HAS_GATE |BERLIN2_DIV_HAS_MUX , + .flags =0 , + }, + { + .name ="gfx" , + .parent_ids = default_parent_ids, + .num_parents =ARRAY_SIZE (default_parent_ids), + .map = { +BERLIN2_DIV_GATE (REG_CLKENABLE ,4 ), +BERLIN2_PLL_SELECT (REG_CLKSELECT0 ,29 ), +BERLIN2_DIV_SELECT (REG_CLKSELECT1 ,0 ), +BERLIN2_PLL_SWITCH (REG_CLKSWITCH0 ,18 ), +BERLIN2_DIV_SWITCH (REG_CLKSWITCH0 ,19 ), +BERLIN2_DIV_D3SWITCH (REG_CLKSWITCH0 ,20 ), + }, + .div_flags =BERLIN2_DIV_HAS_GATE |BERLIN2_DIV_HAS_MUX , + .flags =0 , + }, + { + .name ="zsp" , + .parent_ids = default_parent_ids, + .num_parents =ARRAY_SIZE (default_parent_ids), + .map = { +BERLIN2_DIV_GATE (REG_CLKENABLE ,5 ), +BERLIN2_PLL_SELECT (REG_CLKSELECT1 ,3 ), +BERLIN2_DIV_SELECT (REG_CLKSELECT1 ,6 ), +BERLIN2_PLL_SWITCH (REG_CLKSWITCH0 ,21 ), +BERLIN2_DIV_SWITCH (REG_CLKSWITCH0 ,22 ), +BERLIN2_DIV_D3SWITCH (REG_CLKSWITCH0 ,23 ), + }, + .div_flags =BERLIN2_DIV_HAS_GATE |BERLIN2_DIV_HAS_MUX , + .flags =0 , + }, + { + .name ="perif" , + .parent_ids = default_parent_ids, + .num_parents =ARRAY_SIZE (default_parent_ids), + .map = { +BERLIN2_DIV_GATE (REG_CLKENABLE ,6 ), +BERLIN2_PLL_SELECT (REG_CLKSELECT1 ,9 ), +BERLIN2_DIV_SELECT (REG_CLKSELECT1 ,12 ), +BERLIN2_PLL_SWITCH (REG_CLKSWITCH0 ,24 ), +BERLIN2_DIV_SWITCH (REG_CLKSWITCH0 ,25 ), +BERLIN2_DIV_D3SWITCH (REG_CLKSWITCH0 ,26 ), + }, + .div_flags =BERLIN2_DIV_HAS_GATE |BERLIN2_DIV_HAS_MUX , + .flags =CLK_IGNORE_UNUSED , + }, + { + .name ="pcube" , + .parent_ids = default_parent_ids, + .num_parents =ARRAY_SIZE (default_parent_ids), + .map = { +BERLIN2_DIV_GATE (REG_CLKENABLE ,2 ), +BERLIN2_PLL_SELECT (REG_CLKSELECT1 ,15 ), +BERLIN2_DIV_SELECT (REG_CLKSELECT1 ,18 ), +BERLIN2_PLL_SWITCH (REG_CLKSWITCH0 ,27 ), +BERLIN2_DIV_SWITCH (REG_CLKSWITCH0 ,28 ), +BERLIN2_DIV_D3SWITCH (REG_CLKSWITCH0 ,29 ), + }, + .div_flags =BERLIN2_DIV_HAS_GATE |BERLIN2_DIV_HAS_MUX , + .flags =0 , + }, + { + .name ="vscope" , + .parent_ids = default_parent_ids, + .num_parents =ARRAY_SIZE (default_parent_ids), + .map = { +BERLIN2_DIV_GATE (REG_CLKENABLE ,3 ), +BERLIN2_PLL_SELECT (REG_CLKSELECT1 ,21 ), +BERLIN2_DIV_SELECT (REG_CLKSELECT1 ,24 ), +BERLIN2_PLL_SWITCH (REG_CLKSWITCH0 ,30 ), +BERLIN2_DIV_SWITCH (REG_CLKSWITCH0 ,31 ), +BERLIN2_DIV_D3SWITCH (REG_CLKSWITCH1 ,0 ), + }, + .div_flags =BERLIN2_DIV_HAS_GATE |BERLIN2_DIV_HAS_MUX , + .flags =0 , + }, + { + .name ="nfc_ecc" , + .parent_ids = default_parent_ids, + .num_parents =ARRAY_SIZE (default_parent_ids), + .map = { +BERLIN2_DIV_GATE (REG_CLKENABLE ,18 ), +BERLIN2_PLL_SELECT (REG_CLKSELECT1 ,27 ), +BERLIN2_DIV_SELECT (REG_CLKSELECT2 ,0 ), +BERLIN2_PLL_SWITCH (REG_CLKSWITCH1 ,1 ), +BERLIN2_DIV_SWITCH (REG_CLKSWITCH1 ,2 ), +BERLIN2_DIV_D3SWITCH (REG_CLKSWITCH1 ,3 ), + }, + .div_flags =BERLIN2_DIV_HAS_GATE |BERLIN2_DIV_HAS_MUX , + .flags =0 , + }, + { + .name ="vpp" , + .parent_ids = default_parent_ids, + .num_parents =ARRAY_SIZE (default_parent_ids), + .map = { +BERLIN2_DIV_GATE (REG_CLKENABLE ,21 ), +BERLIN2_PLL_SELECT (REG_CLKSELECT2 ,3 ), +BERLIN2_DIV_SELECT (REG_CLKSELECT2 ,6 ), +BERLIN2_PLL_SWITCH (REG_CLKSWITCH1 ,4 ), +BERLIN2_DIV_SWITCH (REG_CLKSWITCH1 ,5 ), +BERLIN2_DIV_D3SWITCH (REG_CLKSWITCH1 ,6 ), + }, + .div_flags =BERLIN2_DIV_HAS_GATE |BERLIN2_DIV_HAS_MUX , + .flags =0 , + }, + { + .name ="app" , + .parent_ids = default_parent_ids, + .num_parents =ARRAY_SIZE (default_parent_ids), + .map = { +BERLIN2_DIV_GATE (REG_CLKENABLE ,20 ), +BERLIN2_PLL_SELECT (REG_CLKSELECT2 ,9 ), +BERLIN2_DIV_SELECT (REG_CLKSELECT2 ,12 ), +BERLIN2_PLL_SWITCH (REG_CLKSWITCH1 ,7 ), +BERLIN2_DIV_SWITCH (REG_CLKSWITCH1 ,8 ), +BERLIN2_DIV_D3SWITCH (REG_CLKSWITCH1 ,9 ), + }, + .div_flags =BERLIN2_DIV_HAS_GATE |BERLIN2_DIV_HAS_MUX , + .flags =0 , + }, + { + .name ="audio0" , + .parent_ids = (const u8 []){AUDIO_FAST_PLL }, + .num_parents =1 , + .map = { +BERLIN2_DIV_GATE (REG_CLKENABLE ,22 ), +BERLIN2_DIV_SELECT (REG_CLKSELECT2 ,17 ), +BERLIN2_DIV_SWITCH (REG_CLKSWITCH1 ,10 ), +BERLIN2_DIV_D3SWITCH (REG_CLKSWITCH1 ,11 ), + }, + .div_flags =BERLIN2_DIV_HAS_GATE , + .flags =0 , + }, + { + .name ="audio2" , + .parent_ids = (const u8 []){AUDIO_FAST_PLL }, + .num_parents =1 , + .map = { +BERLIN2_DIV_GATE (REG_CLKENABLE ,24 ), +BERLIN2_DIV_SELECT (REG_CLKSELECT2 ,20 ), +BERLIN2_DIV_SWITCH (REG_CLKSWITCH1 ,14 ), +BERLIN2_DIV_D3SWITCH (REG_CLKSWITCH1 ,15 ), + }, + .div_flags =BERLIN2_DIV_HAS_GATE , + .flags =0 , + }, + { + .name ="audio3" , + .parent_ids = (const u8 []){AUDIO_FAST_PLL }, + .num_parents =1 , + .map = { +BERLIN2_DIV_GATE (REG_CLKENABLE ,25 ), +BERLIN2_DIV_SELECT (REG_CLKSELECT2 ,23 ), +BERLIN2_DIV_SWITCH (REG_CLKSWITCH1 ,16 ), +BERLIN2_DIV_D3SWITCH (REG_CLKSWITCH1 ,17 ), + }, + .div_flags =BERLIN2_DIV_HAS_GATE , + .flags =0 , + }, + { + .name ="audio1" , + .parent_ids = (const u8 []){AUDIO1_PLL }, + .num_parents =1 , + .map = { +BERLIN2_DIV_GATE (REG_CLKENABLE ,23 ), +BERLIN2_DIV_SELECT (REG_CLKSELECT3 ,0 ), +BERLIN2_DIV_SWITCH (REG_CLKSWITCH1 ,12 ), +BERLIN2_DIV_D3SWITCH (REG_CLKSWITCH1 ,13 ), + }, + .div_flags =BERLIN2_DIV_HAS_GATE , + .flags =0 , + }, + { + .name ="gfx3d_core" , + .parent_ids = default_parent_ids, + .num_parents =ARRAY_SIZE (default_parent_ids), + .map = { +BERLIN2_SINGLE_DIV (REG_GFX3DCORE_CLKCTL ), + }, + .div_flags =BERLIN2_DIV_HAS_GATE |BERLIN2_DIV_HAS_MUX , + .flags =0 , + }, + { + .name ="gfx3d_sys" , + .parent_ids = default_parent_ids, + .num_parents =ARRAY_SIZE (default_parent_ids), + .map = { +BERLIN2_SINGLE_DIV (REG_GFX3DSYS_CLKCTL ), + }, + .div_flags =BERLIN2_DIV_HAS_GATE |BERLIN2_DIV_HAS_MUX , + .flags =0 , + }, + { + .name ="arc" , + .parent_ids = default_parent_ids, + .num_parents =ARRAY_SIZE (default_parent_ids), + .map = { +BERLIN2_SINGLE_DIV (REG_ARC_CLKCTL ), + }, + .div_flags =BERLIN2_DIV_HAS_GATE |BERLIN2_DIV_HAS_MUX , + .flags =0 , + }, + { + .name ="vip" , + .parent_ids = default_parent_ids, + .num_parents =ARRAY_SIZE (default_parent_ids), + .map = { +BERLIN2_SINGLE_DIV (REG_VIP_CLKCTL ), + }, + .div_flags =BERLIN2_DIV_HAS_GATE |BERLIN2_DIV_HAS_MUX , + .flags =0 , + }, + { + .name ="sdio0xin" , + .parent_ids = default_parent_ids, + .num_parents =ARRAY_SIZE (default_parent_ids), + .map = { +BERLIN2_SINGLE_DIV (REG_SDIO0XIN_CLKCTL ), + }, + .div_flags =BERLIN2_DIV_HAS_GATE |BERLIN2_DIV_HAS_MUX , + .flags =0 , + }, + { + .name ="sdio1xin" , + .parent_ids = default_parent_ids, + .num_parents =ARRAY_SIZE (default_parent_ids), + .map = { +BERLIN2_SINGLE_DIV (REG_SDIO1XIN_CLKCTL ), + }, + .div_flags =BERLIN2_DIV_HAS_GATE |BERLIN2_DIV_HAS_MUX , + .flags =0 , + }, + { + .name ="gfx3d_extra" , + .parent_ids = default_parent_ids, + .num_parents =ARRAY_SIZE (default_parent_ids), + .map = { +BERLIN2_SINGLE_DIV (REG_GFX3DEXTRA_CLKCTL ), + }, + .div_flags =BERLIN2_DIV_HAS_GATE |BERLIN2_DIV_HAS_MUX , + .flags =0 , + }, + { + .name ="gc360" , + .parent_ids = default_parent_ids, + .num_parents =ARRAY_SIZE (default_parent_ids), + .map = { +BERLIN2_SINGLE_DIV (REG_GC360_CLKCTL ), + }, + .div_flags =BERLIN2_DIV_HAS_GATE |BERLIN2_DIV_HAS_MUX , + .flags =0 , + }, + { + .name ="sdio_dllmst" , + .parent_ids = default_parent_ids, + .num_parents =ARRAY_SIZE (default_parent_ids), + .map = { +BERLIN2_SINGLE_DIV (REG_SDIO_DLLMST_CLKCTL ), + }, + .div_flags =BERLIN2_DIV_HAS_GATE |BERLIN2_DIV_HAS_MUX , + .flags =0 , + }, +}; + +static const struct berlin2_gate_data bg2_gates[]__initconst = { + {"geth0" ,"perif" ,7 }, + {"geth1" ,"perif" ,8 }, + {"sata" ,"perif" ,9 }, + {"ahbapb" ,"perif" ,10 ,CLK_IGNORE_UNUSED }, + {"usb0" ,"perif" ,11 }, + {"usb1" ,"perif" ,12 }, + {"pbridge" ,"perif" ,13 ,CLK_IGNORE_UNUSED }, + {"sdio0" ,"perif" ,14 ,CLK_IGNORE_UNUSED }, + {"sdio1" ,"perif" ,15 ,CLK_IGNORE_UNUSED }, + {"nfc" ,"perif" ,17 }, + {"smemc" ,"perif" ,19 }, + {"audiohd" ,"audiohd_pll" ,26 }, + {"video0" ,"video0_in" ,27 }, + {"video1" ,"video1_in" ,28 }, + {"video2" ,"video2_in" ,29 }, +}; + +static void __init berlin2_clock_setup (struct device_node *np) +{ +const char *parent_names[9 ]; +struct clk *clk; +u8 avpll_flags =0 ; +int n; + + gbase =of_iomap (np,0 ); +if (!gbase) +return ; + +/* overwrite default clock names with DT provided ones */ + clk =of_clk_get_by_name (np, clk_names[REFCLK ]); +if (!IS_ERR (clk)) { + clk_names[REFCLK ] =__clk_get_name (clk); +clk_put (clk); + } + + clk =of_clk_get_by_name (np, clk_names[VIDEO_EXT0 ]); +if (!IS_ERR (clk)) { + clk_names[VIDEO_EXT0 ] =__clk_get_name (clk); +clk_put (clk); + } + +/* simple register PLLs */ + clk =berlin2_pll_register (&bg2_pll_map, gbase +REG_SYSPLLCTL0 , + clk_names[SYSPLL ], clk_names[REFCLK ],0 ); +if (IS_ERR (clk)) + goto bg2_fail; + + clk =berlin2_pll_register (&bg2_pll_map, gbase +REG_MEMPLLCTL0 , + clk_names[MEMPLL ], clk_names[REFCLK ],0 ); +if (IS_ERR (clk)) + goto bg2_fail; + + clk =berlin2_pll_register (&bg2_pll_map, gbase +REG_CPUPLLCTL0 , + clk_names[CPUPLL ], clk_names[REFCLK ],0 ); +if (IS_ERR (clk)) + goto bg2_fail; + +if (of_device_is_compatible (np,"marvell,berlin2-global-register" )) + avpll_flags |=BERLIN2_AVPLL_SCRAMBLE_QUIRK ; + +/* audio/video VCOs */ + clk =berlin2_avpll_vco_register (gbase +REG_AVPLLCTL0 ,"avpll_vcoA" , + clk_names[REFCLK ], avpll_flags,0 ); +if (IS_ERR (clk)) + goto bg2_fail; + +for (n =0 ; n <8 ; n++) { + clk =berlin2_avpll_channel_register (gbase +REG_AVPLLCTL0 , + clk_names[AVPLL_A1 + n], n,"avpll_vcoA" , + avpll_flags,0 ); +if (IS_ERR (clk)) + goto bg2_fail; + } + + clk =berlin2_avpll_vco_register (gbase +REG_AVPLLCTL31 ,"avpll_vcoB" , + clk_names[REFCLK ],BERLIN2_AVPLL_BIT_QUIRK | + avpll_flags,0 ); +if (IS_ERR (clk)) + goto bg2_fail; + +for (n =0 ; n <8 ; n++) { + clk =berlin2_avpll_channel_register (gbase +REG_AVPLLCTL31 , + clk_names[AVPLL_B1 + n], n,"avpll_vcoB" , +BERLIN2_AVPLL_BIT_QUIRK | avpll_flags,0 ); +if (IS_ERR (clk)) + goto bg2_fail; + } + +/* reference clock bypass switches */ + parent_names[0 ] = clk_names[SYSPLL ]; + parent_names[1 ] = clk_names[REFCLK ]; + clk =clk_register_mux (NULL ,"syspll_byp" , parent_names,2 , +0 , gbase +REG_CLKSWITCH0 ,0 ,1 ,0 , &lock); +if (IS_ERR (clk)) + goto bg2_fail; + clk_names[SYSPLL ] =__clk_get_name (clk); + + parent_names[0 ] = clk_names[MEMPLL ]; + parent_names[1 ] = clk_names[REFCLK ]; + clk =clk_register_mux (NULL ,"mempll_byp" , parent_names,2 , +0 , gbase +REG_CLKSWITCH0 ,1 ,1 ,0 , &lock); +if (IS_ERR (clk)) + goto bg2_fail; + clk_names[MEMPLL ] =__clk_get_name (clk); + + parent_names[0 ] = clk_names[CPUPLL ]; + parent_names[1 ] = clk_names[REFCLK ]; + clk =clk_register_mux (NULL ,"cpupll_byp" , parent_names,2 , +0 , gbase +REG_CLKSWITCH0 ,2 ,1 ,0 , &lock); +if (IS_ERR (clk)) + goto bg2_fail; + clk_names[CPUPLL ] =__clk_get_name (clk); + +/* clock muxes */ + parent_names[0 ] = clk_names[AVPLL_B3 ]; + parent_names[1 ] = clk_names[AVPLL_A3 ]; + clk =clk_register_mux (NULL , clk_names[AUDIO1_PLL ], parent_names,2 , +0 , gbase +REG_CLKSELECT2 ,29 ,1 ,0 , &lock); +if (IS_ERR (clk)) + goto bg2_fail; + + parent_names[0 ] = clk_names[VIDEO0_PLL ]; + parent_names[1 ] = clk_names[VIDEO_EXT0 ]; + clk =clk_register_mux (NULL , clk_names[VIDEO0_IN ], parent_names,2 , +0 , gbase +REG_CLKSELECT3 ,4 ,1 ,0 , &lock); +if (IS_ERR (clk)) + goto bg2_fail; + + parent_names[0 ] = clk_names[VIDEO1_PLL ]; + parent_names[1 ] = clk_names[VIDEO_EXT0 ]; + clk =clk_register_mux (NULL , clk_names[VIDEO1_IN ], parent_names,2 , +0 , gbase +REG_CLKSELECT3 ,6 ,1 ,0 , &lock); +if (IS_ERR (clk)) + goto bg2_fail; + + parent_names[0 ] = clk_names[AVPLL_A2 ]; + parent_names[1 ] = clk_names[AVPLL_B2 ]; + clk =clk_register_mux (NULL , clk_names[VIDEO1_PLL ], parent_names,2 , +0 , gbase +REG_CLKSELECT3 ,7 ,1 ,0 , &lock); +if (IS_ERR (clk)) + goto bg2_fail; + + parent_names[0 ] = clk_names[VIDEO2_PLL ]; + parent_names[1 ] = clk_names[VIDEO_EXT0 ]; + clk =clk_register_mux (NULL , clk_names[VIDEO2_IN ], parent_names,2 , +0 , gbase +REG_CLKSELECT3 ,9 ,1 ,0 , &lock); +if (IS_ERR (clk)) + goto bg2_fail; + + parent_names[0 ] = clk_names[AVPLL_B1 ]; + parent_names[1 ] = clk_names[AVPLL_A5 ]; + clk =clk_register_mux (NULL , clk_names[VIDEO2_PLL ], parent_names,2 , +0 , gbase +REG_CLKSELECT3 ,10 ,1 ,0 , &lock); +if (IS_ERR (clk)) + goto bg2_fail; + +/* clock divider cells */ +for (n =0 ; n <ARRAY_SIZE (bg2_divs); n++) { +const struct berlin2_div_data *dd = &bg2_divs[n]; +int k; + +for (k =0 ; k < dd->num_parents; k++) + parent_names[k] = clk_names[dd->parent_ids[k]]; + + clks[CLKID_SYS + n] =berlin2_div_register (&dd->map, gbase, + dd->name, dd->div_flags, parent_names, + dd->num_parents, dd->flags, &lock); + } + +/* clock gate cells */ +for (n =0 ; n <ARRAY_SIZE (bg2_gates); n++) { +const struct berlin2_gate_data *gd = &bg2_gates[n]; + + clks[CLKID_GETH0 + n] =clk_register_gate (NULL , gd->name, + gd->parent_name, gd->flags, gbase +REG_CLKENABLE , + gd->bit_idx,0 , &lock); + } + +/* twdclk is derived from cpu/3 */ + clks[CLKID_TWD ] = +clk_register_fixed_factor (NULL ,"twd" ,"cpu" ,0 ,1 ,3 ); + +/* check for errors on leaf clocks */ +for (n =0 ; n <MAX_CLKS ; n++) { +if (!IS_ERR (clks[n])) +continue ; + +pr_err ("%s: Unable to register leaf clock %d\n" , + np->full_name, n); + goto bg2_fail; + } + +/* register clk-provider */ + clk_data.clks = clks; + clk_data.clk_num =MAX_CLKS ; +of_clk_add_provider (np, of_clk_src_onecell_get, &clk_data); + +return ; + +bg2_fail: +iounmap (gbase); +} +CLK_OF_DECLARE (berlin2_clock,"marvell,berlin2-chip-ctrl" , + berlin2_clock_setup); +CLK_OF_DECLARE (berlin2cd_clock,"marvell,berlin2cd-chip-ctrl" , + berlin2_clock_setup);drivers/clk/berlin/common.h new file +29
-0@@ -0,0 +1,29 @@ +/* +* Copyright (c) 2014 Marvell Technology Group Ltd. +* +* Sebastian Hesselbarth <[email protected]> +* Alexandre Belloni <[email protected]> +* +* This program is free software; you can redistribute it and/or modify it +* under the terms and conditions of the GNU General Public License, +* version 2, as published by the Free Software Foundation. +* +* This program is distributed in the hope it will be useful, but WITHOUT +* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for +* more details. +* +* You should have received a copy of the GNU General Public License along with +* this program. If not, see <http://www.gnu.org/licenses/>. +*/ +#ifndef __BERLIN2_COMMON_H +#define __BERLIN2_COMMON_H + +struct berlin2_gate_data { +const char *name; +const char *parent_name; +u8 bit_idx; +unsigned long flags; +}; + +#endif /* BERLIN2_COMMON_H */ Signature · 1 line
1.9.1
Signature · 3 lines
Alexandre Belloni, Free Electrons Embedded Linux, Kernel and Android engineering http://free-electrons.com
PATCH v2 7/10 clk: berlin: add core clock driver for BG2Q
In reply to Sebastian HesselbarthFrom: Alexandre Belloni <[email protected]>
This driver deals with the core clocks found on Marvell Berlin BG2Q. For the shared register dividers, make use of the corresponding driver and add some single clock muxes and gates for the rest.
---
Changelog:v1->v2:
- adapt to new single chip control node and compatible
- swallow twd clock node
--- drivers/clk/berlin/Makefile | 1 + drivers/clk/berlin/bg2q.c | 389 ++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 390 insertions(+) create mode 100644 drivers/clk/berlin/bg2q.c
drivers/clk/berlin/Makefile +1 -0
@@ -1,3 +1,4 @@ obj-y += berlin2-avpll.o berlin2-pll.o berlin2-div.o obj-$(CONFIG_MACH_BERLIN_BG2) += bg2.o obj-$(CONFIG_MACH_BERLIN_BG2CD) += bg2.o +obj-$(CONFIG_MACH_BERLIN_BG2Q) += bg2q.o
drivers/clk/berlin/bg2q.c new file +389 -0
389 lines not on this page · raw message
Signature · 1 line
1.9.1
PATCH v2 8/10 ARM: dts: berlin: convert BG2CD to DT clock nodes
In reply to Sebastian HesselbarthThis converts Berlin BG2CD SoC dtsi to make use of the new DT clock nodes for Berlin SoCs. Also add a binding include to ease core clock references.
---
Changelog:v1->v2:
- adapt to new single chip control node and compatible
--- arch/arm/boot/dts/berlin2cd.dtsi | 53 ++++++++++++++++++---------------------- 1 file changed, 24 insertions(+), 29 deletions(-)
arch/arm/boot/dts/berlin2cd.dtsi +24 -29
@@ -12,6 +12,7 @@ */ #include "skeleton.dtsi" +#include <dt-bindings/clock/berlin2.h> #include <dt-bindings/interrupt-controller/arm-gic.h> / {
@@ -30,24 +31,10 @@ }; }; - clocks { - smclk: sysmgr-clock { - compatible = "fixed-clock"; - #clock-cells = <0>; - clock-frequency = <25000000>; - }; - - cfgclk: cfg-clock { - compatible = "fixed-clock"; - #clock-cells = <0>; - clock-frequency = <75000000>; - }; - - sysclk: system-clock { - compatible = "fixed-clock"; - #clock-cells = <0>; - clock-frequency = <300000000>; - }; + refclk: oscillator { + compatible = "fixed-clock"; + #clock-cells = <0>; + clock-frequency = <25000000>; }; soc {
@@ -76,7 +63,7 @@ compatible = "arm,cortex-a9-twd-timer"; reg = <0xad0600 0x20>; interrupts = <GIC_PPI 13 IRQ_TYPE_LEVEL_HIGH>; - clocks = <&sysclk>; + clocks = <&chip CLKID_TWD>; }; apb at e80000 {
@@ -163,7 +150,7 @@ compatible = "snps,dw-apb-timer"; reg = <0x2c00 0x14>; interrupts = <8>; - clocks = <&cfgclk>; + clocks = <&chip CLKID_CFG>; clock-names = "timer"; status = "okay"; };
@@ -172,7 +159,7 @@ compatible = "snps,dw-apb-timer"; reg = <0x2c14 0x14>; interrupts = <9>; - clocks = <&cfgclk>; + clocks = <&chip CLKID_CFG>; clock-names = "timer"; status = "okay"; };
@@ -181,7 +168,7 @@ compatible = "snps,dw-apb-timer"; reg = <0x2c28 0x14>; interrupts = <10>; - clocks = <&cfgclk>; + clocks = <&chip CLKID_CFG>; clock-names = "timer"; status = "disabled"; };
@@ -190,7 +177,7 @@ compatible = "snps,dw-apb-timer"; reg = <0x2c3c 0x14>; interrupts = <11>; - clocks = <&cfgclk>; + clocks = <&chip CLKID_CFG>; clock-names = "timer"; status = "disabled"; };
@@ -199,7 +186,7 @@ compatible = "snps,dw-apb-timer"; reg = <0x2c50 0x14>; interrupts = <12>; - clocks = <&cfgclk>; + clocks = <&chip CLKID_CFG>; clock-names = "timer"; status = "disabled"; };
@@ -208,7 +195,7 @@ compatible = "snps,dw-apb-timer"; reg = <0x2c64 0x14>; interrupts = <13>; - clocks = <&cfgclk>; + clocks = <&chip CLKID_CFG>; clock-names = "timer"; status = "disabled"; };
@@ -217,7 +204,7 @@ compatible = "snps,dw-apb-timer"; reg = <0x2c78 0x14>; interrupts = <14>; - clocks = <&cfgclk>; + clocks = <&chip CLKID_CFG>; clock-names = "timer"; status = "disabled"; };
@@ -226,7 +213,7 @@ compatible = "snps,dw-apb-timer"; reg = <0x2c8c 0x14>; interrupts = <15>; - clocks = <&cfgclk>; + clocks = <&chip CLKID_CFG>; clock-names = "timer"; status = "disabled"; };
@@ -241,6 +228,14 @@ }; }; + chip: chip-control at ea0000 { + compatible = "marvell,berlin2cd-chip-ctrl"; + #clock-cells = <1>; + reg = <0xea0000 0x400>; + clocks = <&refclk>; + clock-names = "refclk"; + }; + apb at fc0000 { compatible = "simple-bus"; #address-cells = <1>;
@@ -285,7 +280,7 @@ reg-shift = <2>; reg-io-width = <1>; interrupts = <8>; - clocks = <&smclk>; + clocks = <&refclk>; status = "disabled"; };
@@ -295,7 +290,7 @@ reg-shift = <2>; reg-io-width = <1>; interrupts = <9>; - clocks = <&smclk>; + clocks = <&refclk>; status = "disabled"; };
Signature · 1 line
1.9.1
Re: [PATCH v2 08/10] ARM: dts: berlin: convert BG2CD to DT clock nodes
Quoted 5 lines · Sebastian Hesselbarth
This converts Berlin BG2CD SoC dtsi to make use of the new DT clock nodes for Berlin SoCs. Also add a binding include to ease core clock references.
Signed-off-by Sebastian Hesselbarth <[email protected]>
Quoted 172 lines
---
Changelog:v1->v2:
- adapt to new single chip control node and compatibleCc Mike Turquette <[email protected]>Cc Alexandre Belloni <[email protected]>Cc Jisheng Zhang <[email protected]>Cc linux-arm-kernel at lists.infradead.orgCc linux-kernel at vger.kernel.org--- arch/arm/boot/dts/berlin2cd.dtsi | 53 ++++++++++++++++++---------------------- 1 file changed, 24 insertions(+), 29 deletions(-)arch/arm/boot/dts/berlin2cd.dtsi +24
-29@@ -12,6 +12,7 @@ */ #include "skeleton.dtsi" +#include <dt-bindings/clock/berlin2.h> #include <dt-bindings/interrupt-controller/arm-gic.h> / {@@ -30,24 +31,10 @@ }; }; - clocks { - smclk: sysmgr-clock { - compatible = "fixed-clock"; - #clock-cells = <0>; - clock-frequency = <25000000>; - }; - - cfgclk: cfg-clock { - compatible = "fixed-clock"; - #clock-cells = <0>; - clock-frequency = <75000000>; - }; - - sysclk: system-clock { - compatible = "fixed-clock"; - #clock-cells = <0>; - clock-frequency = <300000000>; - }; + refclk: oscillator { + compatible = "fixed-clock"; + #clock-cells = <0>; + clock-frequency = <25000000>; }; soc {@@ -76,7 +63,7 @@ compatible = "arm,cortex-a9-twd-timer"; reg = <0xad0600 0x20>; interrupts = <GIC_PPI 13 IRQ_TYPE_LEVEL_HIGH>; - clocks = <&sysclk>; + clocks = <&chip CLKID_TWD>; }; apb at e80000 {@@ -163,7 +150,7 @@ compatible = "snps,dw-apb-timer"; reg = <0x2c00 0x14>; interrupts = <8>; - clocks = <&cfgclk>; + clocks = <&chip CLKID_CFG>; clock-names = "timer"; status = "okay"; };@@ -172,7 +159,7 @@ compatible = "snps,dw-apb-timer"; reg = <0x2c14 0x14>; interrupts = <9>; - clocks = <&cfgclk>; + clocks = <&chip CLKID_CFG>; clock-names = "timer"; status = "okay"; };@@ -181,7 +168,7 @@ compatible = "snps,dw-apb-timer"; reg = <0x2c28 0x14>; interrupts = <10>; - clocks = <&cfgclk>; + clocks = <&chip CLKID_CFG>; clock-names = "timer"; status = "disabled"; };@@ -190,7 +177,7 @@ compatible = "snps,dw-apb-timer"; reg = <0x2c3c 0x14>; interrupts = <11>; - clocks = <&cfgclk>; + clocks = <&chip CLKID_CFG>; clock-names = "timer"; status = "disabled"; };@@ -199,7 +186,7 @@ compatible = "snps,dw-apb-timer"; reg = <0x2c50 0x14>; interrupts = <12>; - clocks = <&cfgclk>; + clocks = <&chip CLKID_CFG>; clock-names = "timer"; status = "disabled"; };@@ -208,7 +195,7 @@ compatible = "snps,dw-apb-timer"; reg = <0x2c64 0x14>; interrupts = <13>; - clocks = <&cfgclk>; + clocks = <&chip CLKID_CFG>; clock-names = "timer"; status = "disabled"; };@@ -217,7 +204,7 @@ compatible = "snps,dw-apb-timer"; reg = <0x2c78 0x14>; interrupts = <14>; - clocks = <&cfgclk>; + clocks = <&chip CLKID_CFG>; clock-names = "timer"; status = "disabled"; };@@ -226,7 +213,7 @@ compatible = "snps,dw-apb-timer"; reg = <0x2c8c 0x14>; interrupts = <15>; - clocks = <&cfgclk>; + clocks = <&chip CLKID_CFG>; clock-names = "timer"; status = "disabled"; };@@ -241,6 +228,14 @@ }; }; + chip: chip-control at ea0000 { + compatible = "marvell,berlin2cd-chip-ctrl"; + #clock-cells = <1>; + reg = <0xea0000 0x400>; + clocks = <&refclk>; + clock-names = "refclk"; + }; + apb at fc0000 { compatible = "simple-bus"; #address-cells = <1>;@@ -285,7 +280,7 @@ reg-shift = <2>; reg-io-width = <1>; interrupts = <8>; - clocks = <&smclk>; + clocks = <&refclk>; status = "disabled"; };@@ -295,7 +290,7 @@ reg-shift = <2>; reg-io-width = <1>; interrupts = <9>; - clocks = <&smclk>; + clocks = <&refclk>; status = "disabled"; };Signature · 1 line
1.9.1
Signature · 3 lines
Alexandre Belloni, Free Electrons Embedded Linux, Kernel and Android engineering http://free-electrons.com
PATCH v2 9/10 ARM: dts: berlin: convert BG2 to DT clock nodes
In reply to Sebastian HesselbarthThis converts Berlin BG2 SoC dtsi to make use of the new DT clock nodes for Berlin SoCs. While at it, also fix up twdclk which is running at cpuclk/3 instead of sysclk.
---
Changelog:v1->v2:
- adapt to new single chip control node and compatible
--- arch/arm/boot/dts/berlin2.dtsi | 56 +++++++++++++++++------------------------- 1 file changed, 23 insertions(+), 33 deletions(-)
arch/arm/boot/dts/berlin2.dtsi +23 -33
@@ -12,6 +12,7 @@ */ #include "skeleton.dtsi" +#include <dt-bindings/clock/berlin2.h> #include <dt-bindings/interrupt-controller/arm-gic.h> / {
@@ -37,24 +38,10 @@ }; }; - clocks { - smclk: sysmgr-clock { - compatible = "fixed-clock"; - #clock-cells = <0>; - clock-frequency = <25000000>; - }; - - cfgclk: cfg-clock { - compatible = "fixed-clock"; - #clock-cells = <0>; - clock-frequency = <100000000>; - }; - - sysclk: system-clock { - compatible = "fixed-clock"; - #clock-cells = <0>; - clock-frequency = <400000000>; - }; + refclk: oscillator { + compatible = "fixed-clock"; + #clock-cells = <0>; + clock-frequency = <25000000>; }; soc {
@@ -88,7 +75,7 @@ compatible = "arm,cortex-a9-twd-timer"; reg = <0xad0600 0x20>; interrupts = <GIC_PPI 13 IRQ_TYPE_LEVEL_HIGH>; - clocks = <&sysclk>; + clocks = <&chip CLKID_TWD>; }; apb at e80000 {
@@ -175,7 +162,7 @@ compatible = "snps,dw-apb-timer"; reg = <0x2c00 0x14>; interrupts = <8>; - clocks = <&cfgclk>; + clocks = <&chip CLKID_CFG>; clock-names = "timer"; status = "okay"; };
@@ -184,7 +171,7 @@ compatible = "snps,dw-apb-timer"; reg = <0x2c14 0x14>; interrupts = <9>; - clocks = <&cfgclk>; + clocks = <&chip CLKID_CFG>; clock-names = "timer"; status = "okay"; };
@@ -193,7 +180,7 @@ compatible = "snps,dw-apb-timer"; reg = <0x2c28 0x14>; interrupts = <10>; - clocks = <&cfgclk>; + clocks = <&chip CLKID_CFG>; clock-names = "timer"; status = "disabled"; };
@@ -202,7 +189,7 @@ compatible = "snps,dw-apb-timer"; reg = <0x2c3c 0x14>; interrupts = <11>; - clocks = <&cfgclk>; + clocks = <&chip CLKID_CFG>; clock-names = "timer"; status = "disabled"; };
@@ -211,7 +198,7 @@ compatible = "snps,dw-apb-timer"; reg = <0x2c50 0x14>; interrupts = <12>; - clocks = <&cfgclk>; + clocks = <&chip CLKID_CFG>; clock-names = "timer"; status = "disabled"; };
@@ -220,7 +207,7 @@ compatible = "snps,dw-apb-timer"; reg = <0x2c64 0x14>; interrupts = <13>; - clocks = <&cfgclk>; + clocks = <&chip CLKID_CFG>; clock-names = "timer"; status = "disabled"; };
@@ -229,7 +216,7 @@ compatible = "snps,dw-apb-timer"; reg = <0x2c78 0x14>; interrupts = <14>; - clocks = <&cfgclk>; + clocks = <&chip CLKID_CFG>; clock-names = "timer"; status = "disabled"; };
@@ -238,7 +225,7 @@ compatible = "snps,dw-apb-timer"; reg = <0x2c8c 0x14>; interrupts = <15>; - clocks = <&cfgclk>; + clocks = <&chip CLKID_CFG>; clock-names = "timer"; status = "disabled"; };
@@ -253,9 +240,12 @@ }; }; - generic-regs at ea0184 { - compatible = "marvell,berlin-generic-regs", "syscon"; - reg = <0xea0184 0x10>; + chip: chip-control at ea0000 { + compatible = "marvell,berlin2-chip-ctrl"; + #clock-cells = <1>; + reg = <0xea0000 0x400>; + clocks = <&refclk>; + clock-names = "refclk"; }; apb at fc0000 {
@@ -305,7 +295,7 @@ reg-shift = <2>; reg-io-width = <1>; interrupts = <8>; - clocks = <&smclk>; + clocks = <&refclk>; status = "disabled"; };
@@ -315,7 +305,7 @@ reg-shift = <2>; reg-io-width = <1>; interrupts = <9>; - clocks = <&smclk>; + clocks = <&refclk>; status = "disabled"; };
@@ -325,7 +315,7 @@ reg-shift = <2>; reg-io-width = <1>; interrupts = <10>; - clocks = <&smclk>; + clocks = <&refclk>; status = "disabled"; };
Signature · 1 line
1.9.1
Re: [PATCH v2 09/10] ARM: dts: berlin: convert BG2 to DT clock nodes
Quoted 5 lines · Sebastian Hesselbarth
This converts Berlin BG2 SoC dtsi to make use of the new DT clock nodes for Berlin SoCs. While at it, also fix up twdclk which is running at cpuclk/3 instead of sysclk.
Signed-off-by Sebastian Hesselbarth <[email protected]>
Quoted 182 lines
---
Changelog:v1->v2:
- adapt to new single chip control node and compatibleCc Mike Turquette <[email protected]>Cc Alexandre Belloni <[email protected]>Cc Jisheng Zhang <[email protected]>Cc linux-arm-kernel at lists.infradead.orgCc linux-kernel at vger.kernel.org--- arch/arm/boot/dts/berlin2.dtsi | 56 +++++++++++++++++------------------------- 1 file changed, 23 insertions(+), 33 deletions(-)arch/arm/boot/dts/berlin2.dtsi +23
-33@@ -12,6 +12,7 @@ */ #include "skeleton.dtsi" +#include <dt-bindings/clock/berlin2.h> #include <dt-bindings/interrupt-controller/arm-gic.h> / {@@ -37,24 +38,10 @@ }; }; - clocks { - smclk: sysmgr-clock { - compatible = "fixed-clock"; - #clock-cells = <0>; - clock-frequency = <25000000>; - }; - - cfgclk: cfg-clock { - compatible = "fixed-clock"; - #clock-cells = <0>; - clock-frequency = <100000000>; - }; - - sysclk: system-clock { - compatible = "fixed-clock"; - #clock-cells = <0>; - clock-frequency = <400000000>; - }; + refclk: oscillator { + compatible = "fixed-clock"; + #clock-cells = <0>; + clock-frequency = <25000000>; }; soc {@@ -88,7 +75,7 @@ compatible = "arm,cortex-a9-twd-timer"; reg = <0xad0600 0x20>; interrupts = <GIC_PPI 13 IRQ_TYPE_LEVEL_HIGH>; - clocks = <&sysclk>; + clocks = <&chip CLKID_TWD>; }; apb at e80000 {@@ -175,7 +162,7 @@ compatible = "snps,dw-apb-timer"; reg = <0x2c00 0x14>; interrupts = <8>; - clocks = <&cfgclk>; + clocks = <&chip CLKID_CFG>; clock-names = "timer"; status = "okay"; };@@ -184,7 +171,7 @@ compatible = "snps,dw-apb-timer"; reg = <0x2c14 0x14>; interrupts = <9>; - clocks = <&cfgclk>; + clocks = <&chip CLKID_CFG>; clock-names = "timer"; status = "okay"; };@@ -193,7 +180,7 @@ compatible = "snps,dw-apb-timer"; reg = <0x2c28 0x14>; interrupts = <10>; - clocks = <&cfgclk>; + clocks = <&chip CLKID_CFG>; clock-names = "timer"; status = "disabled"; };@@ -202,7 +189,7 @@ compatible = "snps,dw-apb-timer"; reg = <0x2c3c 0x14>; interrupts = <11>; - clocks = <&cfgclk>; + clocks = <&chip CLKID_CFG>; clock-names = "timer"; status = "disabled"; };@@ -211,7 +198,7 @@ compatible = "snps,dw-apb-timer"; reg = <0x2c50 0x14>; interrupts = <12>; - clocks = <&cfgclk>; + clocks = <&chip CLKID_CFG>; clock-names = "timer"; status = "disabled"; };@@ -220,7 +207,7 @@ compatible = "snps,dw-apb-timer"; reg = <0x2c64 0x14>; interrupts = <13>; - clocks = <&cfgclk>; + clocks = <&chip CLKID_CFG>; clock-names = "timer"; status = "disabled"; };@@ -229,7 +216,7 @@ compatible = "snps,dw-apb-timer"; reg = <0x2c78 0x14>; interrupts = <14>; - clocks = <&cfgclk>; + clocks = <&chip CLKID_CFG>; clock-names = "timer"; status = "disabled"; };@@ -238,7 +225,7 @@ compatible = "snps,dw-apb-timer"; reg = <0x2c8c 0x14>; interrupts = <15>; - clocks = <&cfgclk>; + clocks = <&chip CLKID_CFG>; clock-names = "timer"; status = "disabled"; };@@ -253,9 +240,12 @@ }; }; - generic-regs at ea0184 { - compatible = "marvell,berlin-generic-regs", "syscon"; - reg = <0xea0184 0x10>; + chip: chip-control at ea0000 { + compatible = "marvell,berlin2-chip-ctrl"; + #clock-cells = <1>; + reg = <0xea0000 0x400>; + clocks = <&refclk>; + clock-names = "refclk"; }; apb at fc0000 {@@ -305,7 +295,7 @@ reg-shift = <2>; reg-io-width = <1>; interrupts = <8>; - clocks = <&smclk>; + clocks = <&refclk>; status = "disabled"; };@@ -315,7 +305,7 @@ reg-shift = <2>; reg-io-width = <1>; interrupts = <9>; - clocks = <&smclk>; + clocks = <&refclk>; status = "disabled"; };@@ -325,7 +315,7 @@ reg-shift = <2>; reg-io-width = <1>; interrupts = <10>; - clocks = <&smclk>; + clocks = <&refclk>; status = "disabled"; };Signature · 1 line
1.9.1
Signature · 3 lines
Alexandre Belloni, Free Electrons Embedded Linux, Kernel and Android engineering http://free-electrons.com
PATCH v2 10/10 ARM: dts: berlin: convert BG2Q to DT clock nodes
In reply to Sebastian HesselbarthFrom: Alexandre Belloni <[email protected]>
This converts Berlin BG2Q SoC dtsi to make use of the new DT clock nodes for Berlin SoCs.
---
Changelog:v1->v2:
- adapt to new single chip control node and compatible
--- arch/arm/boot/dts/berlin2q.dtsi | 54 +++++++++++++++-------------------------- 1 file changed, 19 insertions(+), 35 deletions(-)
arch/arm/boot/dts/berlin2q.dtsi +19 -35
@@ -6,6 +6,7 @@ * warranty of any kind, whether express or implied. */ +#include <dt-bindings/clock/berlin2q.h> #include <dt-bindings/interrupt-controller/arm-gic.h> #include "skeleton.dtsi"
@@ -47,32 +48,12 @@ }; }; - smclk: sysmgr-clock { + refclk: oscillator { compatible = "fixed-clock"; #clock-cells = <0>; clock-frequency = <25000000>; }; - cfgclk: config-clock { - compatible = "fixed-clock"; - #clock-cells = <0>; - clock-frequency = <100000000>; - }; - - cpuclk: cpu-clock { - compatible = "fixed-clock"; - #clock-cells = <0>; - clock-frequency = <1200000000>; - }; - - twdclk: twdclk { - compatible = "fixed-factor-clock"; - #clock-cells = <0>; - clocks = <&cpuclk>; - clock-mult = <1>; - clock-div = <3>; - }; - soc { compatible = "simple-bus"; #address-cells = <1>;
@@ -95,7 +76,7 @@ local-timer at ad0600 { compatible = "arm,cortex-a9-twd-timer"; reg = <0xad0600 0x20>; - clocks = <&twdclk>; + clocks = <&chip CLKID_TWD>; interrupts = <GIC_PPI 13 IRQ_TYPE_LEVEL_HIGH>; };
@@ -189,7 +170,7 @@ timer0: timer at 2c00 { compatible = "snps,dw-apb-timer"; reg = <0x2c00 0x14>; - clocks = <&cfgclk>; + clocks = <&chip CLKID_CFG>; clock-names = "timer"; interrupts = <8>; };
@@ -197,7 +178,7 @@ timer1: timer at 2c14 { compatible = "snps,dw-apb-timer"; reg = <0x2c14 0x14>; - clocks = <&cfgclk>; + clocks = <&chip CLKID_CFG>; clock-names = "timer"; status = "disabled"; };
@@ -205,7 +186,7 @@ timer2: timer at 2c28 { compatible = "snps,dw-apb-timer"; reg = <0x2c28 0x14>; - clocks = <&cfgclk>; + clocks = <&chip CLKID_CFG>; clock-names = "timer"; status = "disabled"; };
@@ -213,7 +194,7 @@ timer3: timer at 2c3c { compatible = "snps,dw-apb-timer"; reg = <0x2c3c 0x14>; - clocks = <&cfgclk>; + clocks = <&chip CLKID_CFG>; clock-names = "timer"; status = "disabled"; };
@@ -221,7 +202,7 @@ timer4: timer at 2c50 { compatible = "snps,dw-apb-timer"; reg = <0x2c50 0x14>; - clocks = <&cfgclk>; + clocks = <&chip CLKID_CFG>; clock-names = "timer"; status = "disabled"; };
@@ -229,7 +210,7 @@ timer5: timer at 2c64 { compatible = "snps,dw-apb-timer"; reg = <0x2c64 0x14>; - clocks = <&cfgclk>; + clocks = <&chip CLKID_CFG>; clock-names = "timer"; status = "disabled"; };
@@ -237,7 +218,7 @@ timer6: timer at 2c78 { compatible = "snps,dw-apb-timer"; reg = <0x2c78 0x14>; - clocks = <&cfgclk>; + clocks = <&chip CLKID_CFG>; clock-names = "timer"; status = "disabled"; };
@@ -245,7 +226,7 @@ timer7: timer at 2c8c { compatible = "snps,dw-apb-timer"; reg = <0x2c8c 0x14>; - clocks = <&cfgclk>; + clocks = <&chip CLKID_CFG>; clock-names = "timer"; status = "disabled"; };
@@ -290,9 +271,12 @@ }; }; - generic-regs at ea0110 { - compatible = "marvell,berlin-generic-regs", "syscon"; - reg = <0xea0110 0x10>; + chip: chip-control at ea0000 { + compatible = "marvell,berlin2q-chip-ctrl"; + #clock-cells = <1>; + reg = <0xea0000 0x400>, <0xdd0170 0x10>; + clocks = <&refclk>; + clock-names = "refclk"; }; apb at fc0000 {
@@ -308,7 +292,7 @@ reg = <0x9000 0x100>; interrupt-parent = <&sic>; interrupts = <8>; - clocks = <&smclk>; + clocks = <&refclk>; reg-shift = <2>; status = "disabled"; };
@@ -318,7 +302,7 @@ reg = <0xa000 0x100>; interrupt-parent = <&sic>; interrupts = <9>; - clocks = <&smclk>; + clocks = <&refclk>; reg-shift = <2>; status = "disabled"; };
Signature · 1 line
1.9.1
Quoted 15 lines · Sebastian Hesselbarth
Mike,
this is v2 of the Berlin SoC clock driver [1] but with a reworked DT binding as requested [2]. We decided to not even try to split up the chip control registers that deal with pinmux, padmux, clock, reset, and evil stuff we haven't even looked at. Instead we keep a single node that clock driver will remap early, while proper
platform_driversuse a regmap instead. Although clock and other drivers share the same register range, they use individual registers exclusively.There are some functional fixes in the single clock drivers, I noticed while retesting each individial driver. There will be more to fixup but without any drivers actually using the clocks, it is hard to tell what isn't working now.
Quoted 6 lines
Anyway, the current binding should match what you requested and having a clock driver for v3.16 will really be a huge benefit for us to work on more driver support.
If you are fine with it, please take patches 2-7 and I'll pick up 1,8-10 in berlin branch.
nit: I also take patch 2 as it is the required DT include. Makes 3-7 to pick up for you.
Sebastian
Quoted 63 lines
[1] https://lkml.kernel.org/r/1399839881-29895-1-git-send-email-sebastian.hesselbarth at gmail.com
[2] https://lkml.kernel.org/r/20140515044106.19795.57249 at quantumAlexandre Belloni (4):
clk: berlin: add driver for BG2x simple PLLs
clk: berlin: add driver for BG2x complex divider cells
clk: berlin: add core clock driver for BG2Q
ARM: dts: berlin: convert BG2Q to DT clock nodesSebastian Hesselbarth (6):
dt-binding: ARM: add clock binding docs for Marvell Berlin2 SoCs
clk: berlin: add binding include for Berlin SoC clock ids
clk: berlin: add driver for BG2x audio/video PLL
clk: berlin: add core clock driver for BG2/BG2CD
ARM: dts: berlin: convert BG2CD to DT clock nodes
ARM: dts: berlin: convert BG2 to DT clock nodes.../devicetree/bindings/arm/marvell,berlin.txt | 47 ++ arch/arm/boot/dts/berlin2.dtsi | 56 +- arch/arm/boot/dts/berlin2cd.dtsi | 53 +- arch/arm/boot/dts/berlin2q.dtsi | 54 +- drivers/clk/Makefile | 1 + drivers/clk/berlin/Makefile | 4 + drivers/clk/berlin/berlin2-avpll.c | 393 ++++++++++++ drivers/clk/berlin/berlin2-avpll.h | 36 ++ drivers/clk/berlin/berlin2-div.c | 265 ++++++++ drivers/clk/berlin/berlin2-div.h | 89 +++ drivers/clk/berlin/berlin2-pll.c | 117 ++++ drivers/clk/berlin/berlin2-pll.h | 37 ++ drivers/clk/berlin/bg2.c | 691 +++++++++++++++++++++ drivers/clk/berlin/bg2q.c | 389 ++++++++++++ drivers/clk/berlin/common.h | 29 + include/dt-bindings/clock/berlin2.h | 45 ++ include/dt-bindings/clock/berlin2q.h | 31 + 17 files changed, 2240 insertions(+), 97 deletions(-) create mode 100644 drivers/clk/berlin/Makefile create mode 100644 drivers/clk/berlin/berlin2-avpll.c create mode 100644 drivers/clk/berlin/berlin2-avpll.h create mode 100644 drivers/clk/berlin/berlin2-div.c create mode 100644 drivers/clk/berlin/berlin2-div.h create mode 100644 drivers/clk/berlin/berlin2-pll.c create mode 100644 drivers/clk/berlin/berlin2-pll.h create mode 100644 drivers/clk/berlin/bg2.c create mode 100644 drivers/clk/berlin/bg2q.c create mode 100644 drivers/clk/berlin/common.h create mode 100644 include/dt-bindings/clock/berlin2.h create mode 100644 include/dt-bindings/clock/berlin2q.h---
Cc: Rob Herring <[email protected]>
Cc: Pawel Moll <[email protected]>
Cc: Mark Rutland <[email protected]>
Cc: Ian Campbell <[email protected]>
Cc: Kumar Gala <[email protected]>
Cc: Randy Dunlap <[email protected]>
Cc: Mike Turquette <[email protected]>
Cc: Alexandre Belloni <[email protected]>
Cc: Jisheng Zhang <[email protected]>
Cc: devicetree at vger.kernel.org
Cc: linux-doc at vger.kernel.org
Cc: linux-arm-kernel at lists.infradead.org
Cc: linux-kernel at vger.kernel.org
Quoting Sebastian Hesselbarth (2014-05-19 09:43:21)
Quoted 15 lines
Mike,
this is v2 of the Berlin SoC clock driver [1] but with a reworked DT binding as requested [2]. We decided to not even try to split up the chip control registers that deal with pinmux, padmux, clock, reset, and evil stuff we haven't even looked at. Instead we keep a single node that clock driver will remap early, while proper
platform_driversuse a regmap instead. Although clock and other drivers share the same register range, they use individual registers exclusively.There are some functional fixes in the single clock drivers, I noticed while retesting each individial driver. There will be more to fixup but without any drivers actually using the clocks, it is hard to tell what isn't working now.
Quoted 6 lines
Anyway, the current binding should match what you requested and having a clock driver for v3.16 will really be a huge benefit for us to work on more driver support.
If you are fine with it, please take patches 2-7 and I'll pick up 1,8-10 in berlin branch.
Patches #2-7 applied to clk-next.
Thanks!
Mike
Quoted 68 lines
Sebastian
[1] https://lkml.kernel.org/r/1399839881-29895-1-git-send-email-sebastian.hesselbarth at gmail.com
[2] https://lkml.kernel.org/r/20140515044106.19795.57249 at quantumAlexandre Belloni (4):
clk: berlin: add driver for BG2x simple PLLs
clk: berlin: add driver for BG2x complex divider cells
clk: berlin: add core clock driver for BG2Q
ARM: dts: berlin: convert BG2Q to DT clock nodesSebastian Hesselbarth (6):
dt-binding: ARM: add clock binding docs for Marvell Berlin2 SoCs
clk: berlin: add binding include for Berlin SoC clock ids
clk: berlin: add driver for BG2x audio/video PLL
clk: berlin: add core clock driver for BG2/BG2CD
ARM: dts: berlin: convert BG2CD to DT clock nodes
ARM: dts: berlin: convert BG2 to DT clock nodes.../devicetree/bindings/arm/marvell,berlin.txt | 47 ++ arch/arm/boot/dts/berlin2.dtsi | 56 +- arch/arm/boot/dts/berlin2cd.dtsi | 53 +- arch/arm/boot/dts/berlin2q.dtsi | 54 +- drivers/clk/Makefile | 1 + drivers/clk/berlin/Makefile | 4 + drivers/clk/berlin/berlin2-avpll.c | 393 ++++++++++++ drivers/clk/berlin/berlin2-avpll.h | 36 ++ drivers/clk/berlin/berlin2-div.c | 265 ++++++++ drivers/clk/berlin/berlin2-div.h | 89 +++ drivers/clk/berlin/berlin2-pll.c | 117 ++++ drivers/clk/berlin/berlin2-pll.h | 37 ++ drivers/clk/berlin/bg2.c | 691 +++++++++++++++++++++ drivers/clk/berlin/bg2q.c | 389 ++++++++++++ drivers/clk/berlin/common.h | 29 + include/dt-bindings/clock/berlin2.h | 45 ++ include/dt-bindings/clock/berlin2q.h | 31 + 17 files changed, 2240 insertions(+), 97 deletions(-) create mode 100644 drivers/clk/berlin/Makefile create mode 100644 drivers/clk/berlin/berlin2-avpll.c create mode 100644 drivers/clk/berlin/berlin2-avpll.h create mode 100644 drivers/clk/berlin/berlin2-div.c create mode 100644 drivers/clk/berlin/berlin2-div.h create mode 100644 drivers/clk/berlin/berlin2-pll.c create mode 100644 drivers/clk/berlin/berlin2-pll.h create mode 100644 drivers/clk/berlin/bg2.c create mode 100644 drivers/clk/berlin/bg2q.c create mode 100644 drivers/clk/berlin/common.h create mode 100644 include/dt-bindings/clock/berlin2.h create mode 100644 include/dt-bindings/clock/berlin2q.h---
Cc: Rob Herring <[email protected]>
Cc: Pawel Moll <[email protected]>
Cc: Mark Rutland <[email protected]>
Cc: Ian Campbell <[email protected]>
Cc: Kumar Gala <[email protected]>
Cc: Randy Dunlap <[email protected]>
Cc: Mike Turquette <[email protected]>
Cc: Alexandre Belloni <[email protected]>
Cc: Jisheng Zhang <[email protected]>
Cc: devicetree at vger.kernel.org
Cc: linux-doc at vger.kernel.org
Cc: linux-arm-kernel at lists.infradead.org
Cc: linux-kernel at vger.kernel.orgSignature · 1 line
1.9.1
Quoted 16 lines · Mike Turquette
Quoting Sebastian Hesselbarth (2014-05-19 09:43:21)
Quoted 15 lines
Mike,
this is v2 of the Berlin SoC clock driver [1] but with a reworked DT binding as requested [2]. We decided to not even try to split up the chip control registers that deal with pinmux, padmux, clock, reset, and evil stuff we haven't even looked at. Instead we keep a single node that clock driver will remap early, while proper
platform_driversuse a regmap instead. Although clock and other drivers share the same register range, they use individual registers exclusively.There are some functional fixes in the single clock drivers, I noticed while retesting each individial driver. There will be more to fixup but without any drivers actually using the clocks, it is hard to tell what isn't working now.
Quoted 8 lines
Quoted 6 lines
Anyway, the current binding should match what you requested and having a clock driver for v3.16 will really be a huge benefit for us to work on more driver support.
If you are fine with it, please take patches 2-7 and I'll pick up 1,8-10 in berlin branch.
Patches #2-7 applied to clk-next.
Thanks Mike, but please drop patch #2
("clk: berlin: add binding include for Berlin SoC clock ids")
before you push your clk-next branch, it already went through arm-soc.
Sorry,
Sebastian
v2 cover Marvell Berlin full clock support
Quoting Sebastian Hesselbarth (2014-05-29 02:20:03)
Quoted 21 lines · Mike Turquette
Quoted 20 lines
Quoting Sebastian Hesselbarth (2014-05-19 09:43:21)
Quoted 19 lines
Mike,
this is v2 of the Berlin SoC clock driver [1] but with a reworked DT binding as requested [2]. We decided to not even try to split up the chip control registers that deal with pinmux, padmux, clock, reset, and evil stuff we haven't even looked at. Instead we keep a single node that clock driver will remap early, while proper
platform_driversuse a regmap instead. Although clock and other drivers share the same register range, they use individual registers exclusively.There are some functional fixes in the single clock drivers, I noticed while retesting each individial driver. There will be more to fixup but without any drivers actually using the clocks, it is hard to tell what isn't working now.
Anyway, the current binding should match what you requested and having a clock driver for v3.16 will really be a huge benefit for us to work on more driver support.
Quoted 8 lines
Quoted 4 lines
Quoted 2 lines
If you are fine with it, please take patches 2-7 and I'll pick up 1,8-10 in berlin branch.
Patches #2-7 applied to clk-next.
Thanks Mike, but please drop patch #2
("clk: berlin: add binding include for Berlin SoC clock ids")
before you push your clk-next branch, it already went through arm-soc.
Thanks for the heads-up. I've dropped the patch.
Regards,
Mike
Quoted 3 lines
Sorry,
Sebastian