Commit 0eff4589 authored by Linus Torvalds's avatar Linus Torvalds

Merge tag 'clk-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/clk/linux

Pull clk updates from Stephen Boyd:
 "It's the usual big pile of driver updates and additions, but we do
  have a couple core changes in here as well.

  Core:

   - CLK_IS_CRITICAL support has been added.  This should allow drivers
     to properly express that a certain clk should stay on even if their
     prepare/enable count drops to 0 (and in turn the parents of these
     clks should stay enabled).

   - A clk registration API has been added, clk_hw_register(), and an OF
     clk provider API has been added, of_clk_add_hw_provider().  These
     APIs have been put in place to further split clk providers from clk
     consumers, with the goal being to have clk providers never deal
     with struct clk pointers at all.  Conversion of provider drivers is
     on going.  clkdev has also gained support for registering clk_hw
     pointers directly so we can convert drivers that don't use
     devicetree.

  New Drivers:

   - Marvell ap806 and cp110 system controllers (with clks inside!)
   - Hisilicon Hi3519 clock and reset controller
   - Axis ARTPEC-6 clock controllers
   - Oxford Semiconductor OXNAS clock controllers
   - AXS10X I2S PLL
   - Rockchip RK3399 clock and reset controller

  Updates:

   - MMC2 and UART2 clks on Samsung Exynos 3250, ACLK on Samsung Exynos
     542x SoCs, and some more clk ID exporting for bus frequency scaling
   - Proper BCM2835 PCM clk support and various other clks
   - i.MX clk updates for i.MX6SX, i.MX7, and VF610
   - Renesas updates for R-Car H3
   - Tegra210 got updates for DisplayPort and HDMI 2.0
   - Rockchip driver refactorings and fixes due to adding RK3399 support"

* tag 'clk-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/clk/linux: (139 commits)
  clk: fix critical clock locking
  clk: qcom: mmcc-8996: Remove clocks that should be controlled by RPM
  clk: ingenic: Allow divider value to be divided
  clk: sunxi: Add display and TCON0 clocks driver
  clk: rockchip: drop old_rate calculation on pll rate changes
  clk: rockchip: simplify GRF handling in pll clocks
  clk: rockchip: lookup General Register Files in rockchip_clk_init
  clk: rockchip: fix the rk3399 sdmmc sample / drv name
  clk: mvebu: new driver for Armada CP110 system controller
  dt-bindings: arm: add DT binding for Marvell CP110 system controller
  clk: mvebu: new driver for Armada AP806 system controller
  clk: hisilicon: add CRG driver for hi3519 soc
  clk: hisilicon: export some hisilicon APIs to modules
  reset: hisilicon: add reset controller driver for hisilicon SOCs
  clk: bcm/kona: Do not use sizeof on pointer type
  clk: qcom: msm8916: Fix crypto clock flags
  clk: nxp: lpc18xx: Initialize clk_init_data::flags to 0
  clk/axs10x: Add I2S PLL clock driver
  clk: imx7d: fix ahb clock mux 1
  clk: fix comment of devm_clk_hw_register()
  ...
parents 087afe8a ef56b79b
Marvell Armada AP806 System Controller
======================================
The AP806 is one of the two core HW blocks of the Marvell Armada 7K/8K
SoCs. It contains a system controller, which provides a number
registers giving access to numerous features: clocks, pin-muxing and
many other SoC configuration items. This DT binding allows to describe
this system controller.
The Device Tree node representing the AP806 system controller provides
a number of clocks:
- 0: clock of CPU cluster 0
- 1: clock of CPU cluster 1
- 2: fixed PLL at 1200 Mhz
- 3: MSS clock, derived from the fixed PLL
Required properties:
- compatible: must be:
"marvell,ap806-system-controller", "syscon"
- reg: register area of the AP806 system controller
- #clock-cells: must be set to 1
- clock-output-names: must be defined to:
"ap-cpu-cluster-0", "ap-cpu-cluster-1", "ap-fixed", "ap-mss"
Example:
syscon: system-controller@6f4000 {
compatible = "marvell,ap806-system-controller", "syscon";
#clock-cells = <1>;
clock-output-names = "ap-cpu-cluster-0", "ap-cpu-cluster-1",
"ap-fixed", "ap-mss";
reg = <0x6f4000 0x1000>;
};
Marvell Armada CP110 System Controller 0
========================================
The CP110 is one of the two core HW blocks of the Marvell Armada 7K/8K
SoCs. It contains two sets of system control registers, System
Controller 0 and System Controller 1. This Device Tree binding allows
to describe the first system controller, which provides registers to
configure various aspects of the SoC.
The Device Tree node representing this System Controller 0 provides a
number of clocks:
- a set of core clocks
- a set of gatable clocks
Those clocks can be referenced by other Device Tree nodes using two
cells:
- The first cell must be 0 or 1. 0 for the core clocks and 1 for the
gatable clocks.
- The second cell identifies the particular core clock or gatable
clocks.
The following clocks are available:
- Core clocks
- 0 0 APLL
- 0 1 PPv2 core
- 0 2 EIP
- 0 3 Core
- 0 4 NAND core
- Gatable clocks
- 1 0 Audio
- 1 1 Comm Unit
- 1 2 NAND
- 1 3 PPv2
- 1 4 SDIO
- 1 5 MG Domain
- 1 6 MG Core
- 1 7 XOR1
- 1 8 XOR0
- 1 9 GOP DP
- 1 11 PCIe x1 0
- 1 12 PCIe x1 1
- 1 13 PCIe x4
- 1 14 PCIe / XOR
- 1 15 SATA
- 1 16 SATA USB
- 1 17 Main
- 1 18 SD/MMC
- 1 21 Slow IO (SPI, NOR, BootROM, I2C, UART)
- 1 22 USB3H0
- 1 23 USB3H1
- 1 24 USB3 Device
- 1 25 EIP150
- 1 26 EIP197
Required properties:
- compatible: must be:
"marvell,cp110-system-controller0", "syscon";
- reg: register area of the CP110 system controller 0
- #clock-cells: must be set to 2
- core-clock-output-names must be set to:
"cpm-apll", "cpm-ppv2-core", "cpm-eip", "cpm-core", "cpm-nand-core"
- gate-clock-output-names must be set to:
"cpm-audio", "cpm-communit", "cpm-nand", "cpm-ppv2", "cpm-sdio",
"cpm-mg-domain", "cpm-mg-core", "cpm-xor1", "cpm-xor0", "cpm-gop-dp", "none",
"cpm-pcie_x10", "cpm-pcie_x11", "cpm-pcie_x4", "cpm-pcie-xor", "cpm-sata",
"cpm-sata-usb", "cpm-main", "cpm-sd-mmc", "none", "none", "cpm-slow-io",
"cpm-usb3h0", "cpm-usb3h1", "cpm-usb3dev", "cpm-eip150", "cpm-eip197";
Example:
cpm_syscon0: system-controller@440000 {
compatible = "marvell,cp110-system-controller0", "syscon";
reg = <0x440000 0x1000>;
#clock-cells = <2>;
core-clock-output-names = "cpm-apll", "cpm-ppv2-core", "cpm-eip", "cpm-core", "cpm-nand-core";
gate-clock-output-names = "cpm-audio", "cpm-communit", "cpm-nand", "cpm-ppv2", "cpm-sdio",
"cpm-mg-domain", "cpm-mg-core", "cpm-xor1", "cpm-xor0", "cpm-gop-dp", "none",
"cpm-pcie_x10", "cpm-pcie_x11", "cpm-pcie_x4", "cpm-pcie-xor", "cpm-sata",
"cpm-sata-usb", "cpm-main", "cpm-sd-mmc", "none", "none", "cpm-slow-io",
"cpm-usb3h0", "cpm-usb3h1", "cpm-usb3dev", "cpm-eip150", "cpm-eip197";
};
* Clock bindings for Axis ARTPEC-6 chip
The bindings are based on the clock provider binding in
Documentation/devicetree/bindings/clock/clock-bindings.txt
External clocks:
----------------
There are two external inputs to the main clock controller which should be
provided using the common clock bindings.
- "sys_refclk": External 50 Mhz oscillator (required)
- "i2s_refclk": Alternate audio reference clock (optional).
Main clock controller
---------------------
Required properties:
- #clock-cells: Should be <1>
See dt-bindings/clock/axis,artpec6-clkctrl.h for the list of valid identifiers.
- compatible: Should be "axis,artpec6-clkctrl"
- reg: Must contain the base address and length of the system controller
- clocks: Must contain a phandle entry for each clock in clock-names
- clock-names: Must include the external oscillator ("sys_refclk"). Optional
ones are the audio reference clock ("i2s_refclk") and the audio fractional
dividers ("frac_clk0" and "frac_clk1").
Examples:
ext_clk: ext_clk {
#clock-cells = <0>;
compatible = "fixed-clock";
clock-frequency = <50000000>;
};
clkctrl: clkctrl@f8000000 {
#clock-cells = <1>;
compatible = "axis,artpec6-clkctrl";
reg = <0xf8000000 0x48>;
clocks = <&ext_clk>;
clock-names = "sys_refclk";
};
Binding for the AXS10X I2S PLL clock
This binding uses the common clock binding[1].
[1] Documentation/devicetree/bindings/clock/clock-bindings.txt
Required properties:
- compatible: shall be "snps,axs10x-i2s-pll-clock"
- reg : address and length of the I2S PLL register set.
- clocks: shall be the input parent clock phandle for the PLL.
- #clock-cells: from common clock binding; Should always be set to 0.
Example:
pll_clock: pll_clock {
compatible = "fixed-clock";
clock-frequency = <27000000>;
#clock-cells = <0>;
};
i2s_clock@100a0 {
compatible = "snps,axs10x-i2s-pll-clock";
reg = <0x100a0 0x10>;
clocks = <&pll_clock>;
#clock-cells = <0>;
};
* Hisilicon Hi3519 Clock and Reset Generator(CRG)
The Hi3519 CRG module provides clock and reset signals to various
controllers within the SoC.
This binding uses the following bindings:
Documentation/devicetree/bindings/clock/clock-bindings.txt
Documentation/devicetree/bindings/reset/reset.txt
Required Properties:
- compatible: should be one of the following.
- "hisilicon,hi3519-crg" - controller compatible with Hi3519 SoC.
- reg: physical base address of the controller and length of memory mapped
region.
- #clock-cells: should be 1.
Each clock is assigned an identifier and client nodes use this identifier
to specify the clock which they consume.
All these identifier could be found in <dt-bindings/clock/hi3519-clock.h>.
- #reset-cells: should be 2.
A reset signal can be controlled by writing a bit register in the CRG module.
The reset specifier consists of two cells. The first cell represents the
register offset relative to the base address. The second cell represents the
bit index in the register.
Example: CRG nodes
CRG: clock-reset-controller@12010000 {
compatible = "hisilicon,hi3519-crg";
reg = <0x12010000 0x10000>;
#clock-cells = <1>;
#reset-cells = <2>;
};
Example: consumer nodes
i2c0: i2c@12110000 {
compatible = "hisilicon,hi3519-i2c";
reg = <0x12110000 0x1000>;
clocks = <&CRG HI3519_I2C0_RST>;
resets = <&CRG 0xe4 0>;
};
...@@ -94,6 +94,7 @@ clocks and IDs. ...@@ -94,6 +94,7 @@ clocks and IDs.
csi_sel 79 csi_sel 79
iim_gate 80 iim_gate 80
gpu2d_gate 81 gpu2d_gate 81
ckli_gate 82
Examples: Examples:
......
Oxford Semiconductor OXNAS SoC Family Standard Clocks
================================================
Please also refer to clock-bindings.txt in this directory for common clock
bindings usage.
Required properties:
- compatible: Should be "oxsemi,ox810se-stdclk"
- #clock-cells: 1, see below
Parent node should have the following properties :
- compatible: Should be "oxsemi,ox810se-sys-ctrl", "syscon", "simple-mfd"
For OX810SE, the clock indices are :
- 0: LEON
- 1: DMA_SGDMA
- 2: CIPHER
- 3: SATA
- 4: AUDIO
- 5: USBMPH
- 6: ETHA
- 7: PCIA
- 8: NAND
example:
sys: sys-ctrl@000000 {
compatible = "oxsemi,ox810se-sys-ctrl", "syscon", "simple-mfd";
reg = <0x000000 0x100000>;
stdclk: stdclk {
compatible = "oxsemi,ox810se-stdclk";
#clock-cells = <1>;
};
};
* Rockchip RK3399 Clock and Reset Unit
The RK3399 clock controller generates and supplies clock to various
controllers within the SoC and also implements a reset controller for SoC
peripherals.
Required Properties:
- compatible: PMU for CRU should be "rockchip,rk3399-pmucru"
- compatible: CRU should be "rockchip,rk3399-cru"
- reg: physical base address of the controller and length of memory mapped
region.
- #clock-cells: should be 1.
- #reset-cells: should be 1.
Each clock is assigned an identifier and client nodes can use this identifier
to specify the clock which they consume. All available clocks are defined as
preprocessor macros in the dt-bindings/clock/rk3399-cru.h headers and can be
used in device tree sources. Similar macros exist for the reset sources in
these files.
External clocks:
There are several clocks that are generated outside the SoC. It is expected
that they are defined using standard clock bindings with following
clock-output-names:
- "xin24m" - crystal input - required,
- "xin32k" - rtc clock - optional,
- "clkin_gmac" - external GMAC clock - optional,
- "clkin_i2s" - external I2S clock - optional,
- "pclkin_cif" - external ISP clock - optional,
- "clk_usbphy0_480m" - output clock of the pll in the usbphy0
- "clk_usbphy1_480m" - output clock of the pll in the usbphy1
Example: Clock controller node:
pmucru: pmu-clock-controller@ff750000 {
compatible = "rockchip,rk3399-pmucru";
reg = <0x0 0xff750000 0x0 0x1000>;
#clock-cells = <1>;
#reset-cells = <1>;
};
cru: clock-controller@ff760000 {
compatible = "rockchip,rk3399-cru";
reg = <0x0 0xff760000 0x0 0x1000>;
#clock-cells = <1>;
#reset-cells = <1>;
};
Example: UART controller node that consumes the clock generated by the clock
controller:
uart0: serial@ff1a0000 {
compatible = "rockchip,rk3399-uart", "snps,dw-apb-uart";
reg = <0x0 0xff180000 0x0 0x100>;
clocks = <&cru SCLK_UART0>, <&cru PCLK_UART0>;
clock-names = "baudclk", "apb_pclk";
interrupts = <GIC_SPI 99 IRQ_TYPE_LEVEL_HIGH>;
reg-shift = <2>;
reg-io-width = <4>;
};
...@@ -10,6 +10,7 @@ Required properties: ...@@ -10,6 +10,7 @@ Required properties:
"allwinner,sun4i-a10-pll1-clk" - for the main PLL clock and PLL4 "allwinner,sun4i-a10-pll1-clk" - for the main PLL clock and PLL4
"allwinner,sun6i-a31-pll1-clk" - for the main PLL clock on A31 "allwinner,sun6i-a31-pll1-clk" - for the main PLL clock on A31
"allwinner,sun8i-a23-pll1-clk" - for the main PLL clock on A23 "allwinner,sun8i-a23-pll1-clk" - for the main PLL clock on A23
"allwinner,sun4i-a10-pll3-clk" - for the video PLL clock on A10
"allwinner,sun9i-a80-pll4-clk" - for the peripheral PLLs on A80 "allwinner,sun9i-a80-pll4-clk" - for the peripheral PLLs on A80
"allwinner,sun4i-a10-pll5-clk" - for the PLL5 clock "allwinner,sun4i-a10-pll5-clk" - for the PLL5 clock
"allwinner,sun4i-a10-pll6-clk" - for the PLL6 clock "allwinner,sun4i-a10-pll6-clk" - for the PLL6 clock
...@@ -63,7 +64,9 @@ Required properties: ...@@ -63,7 +64,9 @@ Required properties:
"allwinner,sun8i-a83t-bus-gates-clk" - for the bus gates on A83T "allwinner,sun8i-a83t-bus-gates-clk" - for the bus gates on A83T
"allwinner,sun8i-h3-bus-gates-clk" - for the bus gates on H3 "allwinner,sun8i-h3-bus-gates-clk" - for the bus gates on H3
"allwinner,sun9i-a80-apbs-gates-clk" - for the APBS gates on A80 "allwinner,sun9i-a80-apbs-gates-clk" - for the APBS gates on A80
"allwinner,sun4i-a10-display-clk" - for the display clocks on the A10
"allwinner,sun4i-a10-dram-gates-clk" - for the DRAM gates on A10 "allwinner,sun4i-a10-dram-gates-clk" - for the DRAM gates on A10
"allwinner,sun5i-a13-dram-gates-clk" - for the DRAM gates on A13
"allwinner,sun5i-a13-mbus-clk" - for the MBUS clock on A13 "allwinner,sun5i-a13-mbus-clk" - for the MBUS clock on A13
"allwinner,sun4i-a10-mmc-clk" - for the MMC clock "allwinner,sun4i-a10-mmc-clk" - for the MMC clock
"allwinner,sun9i-a80-mmc-clk" - for mmc module clocks on A80 "allwinner,sun9i-a80-mmc-clk" - for mmc module clocks on A80
...@@ -73,6 +76,8 @@ Required properties: ...@@ -73,6 +76,8 @@ Required properties:
"allwinner,sun8i-a23-mbus-clk" - for the MBUS clock on A23 "allwinner,sun8i-a23-mbus-clk" - for the MBUS clock on A23
"allwinner,sun7i-a20-out-clk" - for the external output clocks "allwinner,sun7i-a20-out-clk" - for the external output clocks
"allwinner,sun7i-a20-gmac-clk" - for the GMAC clock module on A20/A31 "allwinner,sun7i-a20-gmac-clk" - for the GMAC clock module on A20/A31
"allwinner,sun4i-a10-tcon-ch0-clk" - for the TCON channel 0 clock on the A10
"allwinner,sun4i-a10-tcon-ch1-clk" - for the TCON channel 1 clock on the A10
"allwinner,sun4i-a10-usb-clk" - for usb gates + resets on A10 / A20 "allwinner,sun4i-a10-usb-clk" - for usb gates + resets on A10 / A20
"allwinner,sun5i-a13-usb-clk" - for usb gates + resets on A13 "allwinner,sun5i-a13-usb-clk" - for usb gates + resets on A13
"allwinner,sun6i-a31-usb-clk" - for usb gates + resets on A31 "allwinner,sun6i-a31-usb-clk" - for usb gates + resets on A31
...@@ -81,6 +86,7 @@ Required properties: ...@@ -81,6 +86,7 @@ Required properties:
"allwinner,sun9i-a80-usb-mod-clk" - for usb gates + resets on A80 "allwinner,sun9i-a80-usb-mod-clk" - for usb gates + resets on A80
"allwinner,sun9i-a80-usb-phy-clk" - for usb phy gates + resets on A80 "allwinner,sun9i-a80-usb-phy-clk" - for usb phy gates + resets on A80
"allwinner,sun4i-a10-ve-clk" - for the Video Engine clock "allwinner,sun4i-a10-ve-clk" - for the Video Engine clock
"allwinner,sun6i-a31-display-clk" - for the display clocks
Required properties for all clocks: Required properties for all clocks:
- reg : shall be the control register address for the clock. - reg : shall be the control register address for the clock.
......
...@@ -236,6 +236,7 @@ certainly invest a bit more effort into libata core layer). ...@@ -236,6 +236,7 @@ certainly invest a bit more effort into libata core layer).
CLOCK CLOCK
devm_clk_get() devm_clk_get()
devm_clk_put() devm_clk_put()
devm_clk_hw_register()
DMA DMA
dmam_alloc_coherent() dmam_alloc_coherent()
......
...@@ -977,7 +977,7 @@ S: Maintained ...@@ -977,7 +977,7 @@ S: Maintained
L: linux-arm-kernel@axis.com L: linux-arm-kernel@axis.com
F: arch/arm/mach-artpec F: arch/arm/mach-artpec
F: arch/arm/boot/dts/artpec6* F: arch/arm/boot/dts/artpec6*
F: drivers/clk/clk-artpec6.c F: drivers/clk/axis
ARM/ASPEED MACHINE SUPPORT ARM/ASPEED MACHINE SUPPORT
M: Joel Stanley <joel@jms.id.au> M: Joel Stanley <joel@jms.id.au>
......
...@@ -200,6 +200,12 @@ config COMMON_CLK_PXA ...@@ -200,6 +200,12 @@ config COMMON_CLK_PXA
config COMMON_CLK_PIC32 config COMMON_CLK_PIC32
def_bool COMMON_CLK && MACH_PIC32 def_bool COMMON_CLK && MACH_PIC32
config COMMON_CLK_OXNAS
bool "Clock driver for the OXNAS SoC Family"
select MFD_SYSCON
---help---
Support for the OXNAS SoC Family clocks.
source "drivers/clk/bcm/Kconfig" source "drivers/clk/bcm/Kconfig"
source "drivers/clk/hisilicon/Kconfig" source "drivers/clk/hisilicon/Kconfig"
source "drivers/clk/mvebu/Kconfig" source "drivers/clk/mvebu/Kconfig"
......
...@@ -33,6 +33,7 @@ obj-$(CONFIG_ARCH_MB86S7X) += clk-mb86s7x.o ...@@ -33,6 +33,7 @@ obj-$(CONFIG_ARCH_MB86S7X) += clk-mb86s7x.o
obj-$(CONFIG_ARCH_MOXART) += clk-moxart.o obj-$(CONFIG_ARCH_MOXART) += clk-moxart.o
obj-$(CONFIG_ARCH_NOMADIK) += clk-nomadik.o obj-$(CONFIG_ARCH_NOMADIK) += clk-nomadik.o
obj-$(CONFIG_ARCH_NSPIRE) += clk-nspire.o obj-$(CONFIG_ARCH_NSPIRE) += clk-nspire.o
obj-$(CONFIG_COMMON_CLK_OXNAS) += clk-oxnas.o
obj-$(CONFIG_COMMON_CLK_PALMAS) += clk-palmas.o obj-$(CONFIG_COMMON_CLK_PALMAS) += clk-palmas.o
obj-$(CONFIG_CLK_QORIQ) += clk-qoriq.o obj-$(CONFIG_CLK_QORIQ) += clk-qoriq.o
obj-$(CONFIG_COMMON_CLK_RK808) += clk-rk808.o obj-$(CONFIG_COMMON_CLK_RK808) += clk-rk808.o
...@@ -51,6 +52,7 @@ obj-$(CONFIG_COMMON_CLK_WM831X) += clk-wm831x.o ...@@ -51,6 +52,7 @@ obj-$(CONFIG_COMMON_CLK_WM831X) += clk-wm831x.o
obj-$(CONFIG_COMMON_CLK_XGENE) += clk-xgene.o obj-$(CONFIG_COMMON_CLK_XGENE) += clk-xgene.o
obj-$(CONFIG_COMMON_CLK_PWM) += clk-pwm.o obj-$(CONFIG_COMMON_CLK_PWM) += clk-pwm.o
obj-$(CONFIG_COMMON_CLK_AT91) += at91/ obj-$(CONFIG_COMMON_CLK_AT91) += at91/
obj-$(CONFIG_ARCH_ARTPEC) += axis/
obj-y += bcm/ obj-y += bcm/
obj-$(CONFIG_ARCH_BERLIN) += berlin/ obj-$(CONFIG_ARCH_BERLIN) += berlin/
obj-$(CONFIG_ARCH_HISI) += hisilicon/ obj-$(CONFIG_ARCH_HISI) += hisilicon/
...@@ -62,7 +64,7 @@ obj-$(CONFIG_MACH_PIC32) += microchip/ ...@@ -62,7 +64,7 @@ obj-$(CONFIG_MACH_PIC32) += microchip/
ifeq ($(CONFIG_COMMON_CLK), y) ifeq ($(CONFIG_COMMON_CLK), y)
obj-$(CONFIG_ARCH_MMP) += mmp/ obj-$(CONFIG_ARCH_MMP) += mmp/
endif endif
obj-$(CONFIG_PLAT_ORION) += mvebu/ obj-y += mvebu/
obj-$(CONFIG_ARCH_MESON) += meson/ obj-$(CONFIG_ARCH_MESON) += meson/
obj-$(CONFIG_ARCH_MXS) += mxs/ obj-$(CONFIG_ARCH_MXS) += mxs/
obj-$(CONFIG_MACH_PISTACHIO) += pistachio/ obj-$(CONFIG_MACH_PISTACHIO) += pistachio/
...@@ -85,3 +87,4 @@ obj-$(CONFIG_X86) += x86/ ...@@ -85,3 +87,4 @@ obj-$(CONFIG_X86) += x86/
obj-$(CONFIG_ARCH_ZX) += zte/ obj-$(CONFIG_ARCH_ZX) += zte/
obj-$(CONFIG_ARCH_ZYNQ) += zynq/ obj-$(CONFIG_ARCH_ZYNQ) += zynq/
obj-$(CONFIG_H8300) += h8300/ obj-$(CONFIG_H8300) += h8300/
obj-$(CONFIG_ARC_PLAT_AXS10X) += axs10x/
...@@ -114,7 +114,7 @@ static void __init of_sama5d4_clk_h32mx_setup(struct device_node *np) ...@@ -114,7 +114,7 @@ static void __init of_sama5d4_clk_h32mx_setup(struct device_node *np)
h32mxclk->regmap = regmap; h32mxclk->regmap = regmap;
clk = clk_register(NULL, &h32mxclk->hw); clk = clk_register(NULL, &h32mxclk->hw);
if (!clk) { if (IS_ERR(clk)) {
kfree(h32mxclk); kfree(h32mxclk);
return; return;
} }
......
obj-$(CONFIG_MACH_ARTPEC6) += clk-artpec6.o
/*
* ARTPEC-6 clock initialization
*
* Copyright 2015-2016 Axis Comunications AB.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation.
*/
#include <linux/clk-provider.h>
#include <linux/device.h>
#include <linux/io.h>
#include <linux/of.h>
#include <linux/of_address.h>
#include <linux/platform_device.h>
#include <linux/slab.h>
#include <dt-bindings/clock/axis,artpec6-clkctrl.h>
#define NUM_I2S_CLOCKS 2
struct artpec6_clkctrl_drvdata {
struct clk *clk_table[ARTPEC6_CLK_NUMCLOCKS];
void __iomem *syscon_base;
struct clk_onecell_data clk_data;
spinlock_t i2scfg_lock;
};
static struct artpec6_clkctrl_drvdata *clkdata;
static const char *const i2s_clk_names[NUM_I2S_CLOCKS] = {
"i2s0",
"i2s1",
};
static const int i2s_clk_indexes[NUM_I2S_CLOCKS] = {
ARTPEC6_CLK_I2S0_CLK,
ARTPEC6_CLK_I2S1_CLK,
};
static void of_artpec6_clkctrl_setup(struct device_node *np)
{
int i;
const char *sys_refclk_name;
u32 pll_mode, pll_m, pll_n;
struct clk **clks;
/* Mandatory parent clock. */
i = of_property_match_string(np, "clock-names", "sys_refclk");
if (i < 0)
return;
sys_refclk_name = of_clk_get_parent_name(np, i);
clkdata = kzalloc(sizeof(*clkdata), GFP_KERNEL);
if (!clkdata)
return;
clks = clkdata->clk_table;
for (i = 0; i < ARTPEC6_CLK_NUMCLOCKS; ++i)
clks[i] = ERR_PTR(-EPROBE_DEFER);
clkdata->syscon_base = of_iomap(np, 0);
BUG_ON(clkdata->syscon_base == NULL);
/* Read PLL1 factors configured by boot strap pins. */
pll_mode = (readl(clkdata->syscon_base) >> 6) & 3;
switch (pll_mode) {
case 0: /* DDR3-2133 mode */
pll_m = 4;
pll_n = 85;
break;
case 1: /* DDR3-1866 mode */
pll_m = 6;
pll_n = 112;
break;
case 2: /* DDR3-1600 mode */
pll_m = 4;
pll_n = 64;
break;
case 3: /* DDR3-1333 mode */
pll_m = 8;
pll_n = 106;
break;
}
clks[ARTPEC6_CLK_CPU] =
clk_register_fixed_factor(NULL, "cpu", sys_refclk_name, 0, pll_n,
pll_m);
clks[ARTPEC6_CLK_CPU_PERIPH] =
clk_register_fixed_factor(NULL, "cpu_periph", "cpu", 0, 1, 2);
/* EPROBE_DEFER on the apb_clock is not handled in amba devices. */
clks[ARTPEC6_CLK_UART_PCLK] =
clk_register_fixed_factor(NULL, "uart_pclk", "cpu", 0, 1, 8);
clks[ARTPEC6_CLK_UART_REFCLK] =
clk_register_fixed_rate(NULL, "uart_ref", sys_refclk_name, 0,
50000000);
clks[ARTPEC6_CLK_SPI_PCLK] =
clk_register_fixed_factor(NULL, "spi_pclk", "cpu", 0, 1, 8);
clks[ARTPEC6_CLK_SPI_SSPCLK] =
clk_register_fixed_rate(NULL, "spi_sspclk", sys_refclk_name, 0,
50000000);
clks[ARTPEC6_CLK_DBG_PCLK] =
clk_register_fixed_factor(NULL, "dbg_pclk", "cpu", 0, 1, 8);
clkdata->clk_data.clks = clkdata->clk_table;
clkdata->clk_data.clk_num = ARTPEC6_CLK_NUMCLOCKS;
of_clk_add_provider(np, of_clk_src_onecell_get, &clkdata->clk_data);
}
CLK_OF_DECLARE(artpec6_clkctrl, "axis,artpec6-clkctrl",
of_artpec6_clkctrl_setup);
static int artpec6_clkctrl_probe(struct platform_device *pdev)
{
int propidx;
struct device_node *np = pdev->dev.of_node;
struct device *dev = &pdev->dev;
struct clk **clks = clkdata->clk_table;
const char *sys_refclk_name;
const char *i2s_refclk_name = NULL;
const char *frac_clk_name[2] = { NULL, NULL };
const char *i2s_mux_parents[2];
u32 muxreg;
int i;
int err = 0;
/* Mandatory parent clock. */
propidx = of_property_match_string(np, "clock-names", "sys_refclk");
if (propidx < 0)
return -EINVAL;
sys_refclk_name = of_clk_get_parent_name(np, propidx);
/* Find clock names of optional parent clocks. */
propidx = of_property_match_string(np, "clock-names", "i2s_refclk");
if (propidx >= 0)
i2s_refclk_name = of_clk_get_parent_name(np, propidx);
propidx = of_property_match_string(np, "clock-names", "frac_clk0");
if (propidx >= 0)
frac_clk_name[0] = of_clk_get_parent_name(np, propidx);
propidx = of_property_match_string(np, "clock-names", "frac_clk1");
if (propidx >= 0)
frac_clk_name[1] = of_clk_get_parent_name(np, propidx);
spin_lock_init(&clkdata->i2scfg_lock);
clks[ARTPEC6_CLK_NAND_CLKA] =
clk_register_fixed_factor(dev, "nand_clka", "cpu", 0, 1, 8);
clks[ARTPEC6_CLK_NAND_CLKB] =
clk_register_fixed_rate(dev, "nand_clkb", sys_refclk_name, 0,
100000000);
clks[ARTPEC6_CLK_ETH_ACLK] =
clk_register_fixed_factor(dev, "eth_aclk", "cpu", 0, 1, 4);
clks[ARTPEC6_CLK_DMA_ACLK] =
clk_register_fixed_factor(dev, "dma_aclk", "cpu", 0, 1, 4);
clks[ARTPEC6_CLK_PTP_REF] =
clk_register_fixed_rate(dev, "ptp_ref", sys_refclk_name, 0,
100000000);
clks[ARTPEC6_CLK_SD_PCLK] =
clk_register_fixed_rate(dev, "sd_pclk", sys_refclk_name, 0,
100000000);
clks[ARTPEC6_CLK_SD_IMCLK] =
clk_register_fixed_rate(dev, "sd_imclk", sys_refclk_name, 0,
100000000);
clks[ARTPEC6_CLK_I2S_HST] =
clk_register_fixed_factor(dev, "i2s_hst", "cpu", 0, 1, 8);
for (i = 0; i < NUM_I2S_CLOCKS; ++i) {
if (i2s_refclk_name && frac_clk_name[i]) {
i2s_mux_parents[0] = frac_clk_name[i];
i2s_mux_parents[1] = i2s_refclk_name;
clks[i2s_clk_indexes[i]] =
clk_register_mux(dev, i2s_clk_names[i],
i2s_mux_parents, 2,
CLK_SET_RATE_NO_REPARENT |
CLK_SET_RATE_PARENT,
clkdata->syscon_base + 0x14, i, 1,
0, &clkdata->i2scfg_lock);
} else if (frac_clk_name[i]) {
/* Lock the mux for internal clock reference. */
muxreg = readl(clkdata->syscon_base + 0x14);
muxreg &= ~BIT(i);
writel(muxreg, clkdata->syscon_base + 0x14);
clks[i2s_clk_indexes[i]] =
clk_register_fixed_factor(dev, i2s_clk_names[i],
frac_clk_name[i], 0, 1,
1);
} else if (i2s_refclk_name) {
/* Lock the mux for external clock reference. */
muxreg = readl(clkdata->syscon_base + 0x14);
muxreg |= BIT(i);
writel(muxreg, clkdata->syscon_base + 0x14);
clks[i2s_clk_indexes[i]] =
clk_register_fixed_factor(dev, i2s_clk_names[i],
i2s_refclk_name, 0, 1, 1);
}
}
clks[ARTPEC6_CLK_I2C] =
clk_register_fixed_rate(dev, "i2c", sys_refclk_name, 0, 100000000);
clks[ARTPEC6_CLK_SYS_TIMER] =
clk_register_fixed_rate(dev, "timer", sys_refclk_name, 0,
100000000);
clks[ARTPEC6_CLK_FRACDIV_IN] =
clk_register_fixed_rate(dev, "fracdiv_in", sys_refclk_name, 0,
600000000);
for (i = 0; i < ARTPEC6_CLK_NUMCLOCKS; ++i) {
if (IS_ERR(clks[i]) && PTR_ERR(clks[i]) != -EPROBE_DEFER) {
dev_err(dev,
"Failed to register clock at index %d err=%ld\n",
i, PTR_ERR(clks[i]));
err = PTR_ERR(clks[i]);
}
}
return err;
}
static const struct of_device_id artpec_clkctrl_of_match[] = {
{ .compatible = "axis,artpec6-clkctrl" },
{}
};
static struct platform_driver artpec6_clkctrl_driver = {
.probe = artpec6_clkctrl_probe,
.driver = {
.name = "artpec6_clkctrl",
.of_match_table = artpec_clkctrl_of_match,
},
};
builtin_platform_driver(artpec6_clkctrl_driver);
obj-y += i2s_pll_clock.o
/*
* Synopsys AXS10X SDP I2S PLL clock driver
*
* Copyright (C) 2016 Synopsys
*
* This file is licensed under the terms of the GNU General Public
* License version 2. This program is licensed "as is" without any
* warranty of any kind, whether express or implied.
*/
#include <linux/platform_device.h>
#include <linux/module.h>
#include <linux/clk-provider.h>
#include <linux/err.h>
#include <linux/device.h>
#include <linux/of_address.h>
#include <linux/slab.h>
#include <linux/of.h>
/* PLL registers addresses */
#define PLL_IDIV_REG 0x0
#define PLL_FBDIV_REG 0x4
#define PLL_ODIV0_REG 0x8
#define PLL_ODIV1_REG 0xC
struct i2s_pll_cfg {
unsigned int rate;
unsigned int idiv;
unsigned int fbdiv;
unsigned int odiv0;
unsigned int odiv1;
};
static const struct i2s_pll_cfg i2s_pll_cfg_27m[] = {
/* 27 Mhz */
{ 1024000, 0x104, 0x451, 0x10E38, 0x2000 },
{ 1411200, 0x104, 0x596, 0x10D35, 0x2000 },
{ 1536000, 0x208, 0xA28, 0x10B2C, 0x2000 },
{ 2048000, 0x82, 0x451, 0x10E38, 0x2000 },
{ 2822400, 0x82, 0x596, 0x10D35, 0x2000 },
{ 3072000, 0x104, 0xA28, 0x10B2C, 0x2000 },
{ 2116800, 0x82, 0x3CF, 0x10C30, 0x2000 },
{ 2304000, 0x104, 0x79E, 0x10B2C, 0x2000 },
{ 0, 0, 0, 0, 0 },
};
static const struct i2s_pll_cfg i2s_pll_cfg_28m[] = {
/* 28.224 Mhz */
{ 1024000, 0x82, 0x105, 0x107DF, 0x2000 },
{ 1411200, 0x28A, 0x1, 0x10001, 0x2000 },
{ 1536000, 0xA28, 0x187, 0x10042, 0x2000 },
{ 2048000, 0x41, 0x105, 0x107DF, 0x2000 },
{ 2822400, 0x145, 0x1, 0x10001, 0x2000 },
{ 3072000, 0x514, 0x187, 0x10042, 0x2000 },
{ 2116800, 0x514, 0x42, 0x10001, 0x2000 },
{ 2304000, 0x619, 0x82, 0x10001, 0x2000 },
{ 0, 0, 0, 0, 0 },
};
struct i2s_pll_clk {
void __iomem *base;
struct clk_hw hw;
struct device *dev;
};
static inline void i2s_pll_write(struct i2s_pll_clk *clk, unsigned int reg,
unsigned int val)
{
writel_relaxed(val, clk->base + reg);
}
static inline unsigned int i2s_pll_read(struct i2s_pll_clk *clk,
unsigned int reg)
{
return readl_relaxed(clk->base + reg);
}
static inline struct i2s_pll_clk *to_i2s_pll_clk(struct clk_hw *hw)
{
return container_of(hw, struct i2s_pll_clk, hw);
}
static inline unsigned int i2s_pll_get_value(unsigned int val)
{
return (val & 0x3F) + ((val >> 6) & 0x3F);
}
static const struct i2s_pll_cfg *i2s_pll_get_cfg(unsigned long prate)
{
switch (prate) {
case 27000000:
return i2s_pll_cfg_27m;
case 28224000:
return i2s_pll_cfg_28m;
default:
return NULL;
}
}
static unsigned long i2s_pll_recalc_rate(struct clk_hw *hw,
unsigned long parent_rate)
{
struct i2s_pll_clk *clk = to_i2s_pll_clk(hw);
unsigned int idiv, fbdiv, odiv;
idiv = i2s_pll_get_value(i2s_pll_read(clk, PLL_IDIV_REG));
fbdiv = i2s_pll_get_value(i2s_pll_read(clk, PLL_FBDIV_REG));
odiv = i2s_pll_get_value(i2s_pll_read(clk, PLL_ODIV0_REG));
return ((parent_rate / idiv) * fbdiv) / odiv;
}
static long i2s_pll_round_rate(struct clk_hw *hw, unsigned long rate,
unsigned long *prate)
{
struct i2s_pll_clk *clk = to_i2s_pll_clk(hw);
const struct i2s_pll_cfg *pll_cfg = i2s_pll_get_cfg(*prate);
int i;
if (!pll_cfg) {
dev_err(clk->dev, "invalid parent rate=%ld\n", *prate);
return -EINVAL;
}
for (i = 0; pll_cfg[i].rate != 0; i++)
if (pll_cfg[i].rate == rate)
return rate;
return -EINVAL;
}
static int i2s_pll_set_rate(struct clk_hw *hw, unsigned long rate,
unsigned long parent_rate)
{
struct i2s_pll_clk *clk = to_i2s_pll_clk(hw);
const struct i2s_pll_cfg *pll_cfg = i2s_pll_get_cfg(parent_rate);
int i;
if (!pll_cfg) {
dev_err(clk->dev, "invalid parent rate=%ld\n", parent_rate);
return -EINVAL;
}
for (i = 0; pll_cfg[i].rate != 0; i++) {
if (pll_cfg[i].rate == rate) {
i2s_pll_write(clk, PLL_IDIV_REG, pll_cfg[i].idiv);
i2s_pll_write(clk, PLL_FBDIV_REG, pll_cfg[i].fbdiv);
i2s_pll_write(clk, PLL_ODIV0_REG, pll_cfg[i].odiv0);
i2s_pll_write(clk, PLL_ODIV1_REG, pll_cfg[i].odiv1);
return 0;
}
}
dev_err(clk->dev, "invalid rate=%ld, parent_rate=%ld\n", rate,
parent_rate);
return -EINVAL;
}
static const struct clk_ops i2s_pll_ops = {
.recalc_rate = i2s_pll_recalc_rate,
.round_rate = i2s_pll_round_rate,
.set_rate = i2s_pll_set_rate,
};
static int i2s_pll_clk_probe(struct platform_device *pdev)
{
struct device *dev = &pdev->dev;
struct device_node *node = dev->of_node;
const char *clk_name;
const char *parent_name;
struct clk *clk;
struct i2s_pll_clk *pll_clk;
struct clk_init_data init;
struct resource *mem;
pll_clk = devm_kzalloc(dev, sizeof(*pll_clk), GFP_KERNEL);
if (!pll_clk)
return -ENOMEM;
mem = platform_get_resource(pdev, IORESOURCE_MEM, 0);
pll_clk->base = devm_ioremap_resource(dev, mem);
if (IS_ERR(pll_clk->base))
return PTR_ERR(pll_clk->base);
clk_name = node->name;
init.name = clk_name;
init.ops = &i2s_pll_ops;
parent_name = of_clk_get_parent_name(node, 0);
init.parent_names = &parent_name;
init.num_parents = 1;
pll_clk->hw.init = &init;
pll_clk->dev = dev;
clk = devm_clk_register(dev, &pll_clk->hw);
if (IS_ERR(clk)) {
dev_err(dev, "failed to register %s clock (%ld)\n",
clk_name, PTR_ERR(clk));
return PTR_ERR(clk);
}
return of_clk_add_provider(node, of_clk_src_simple_get, clk);
}
static int i2s_pll_clk_remove(struct platform_device *pdev)
{
of_clk_del_provider(pdev->dev.of_node);
return 0;
}
static const struct of_device_id i2s_pll_clk_id[] = {
{ .compatible = "snps,axs10x-i2s-pll-clock", },
{ },
};
MODULE_DEVICE_TABLE(of, i2s_pll_clk_id);
static struct platform_driver i2s_pll_clk_driver = {
.driver = {
.name = "axs10x-i2s-pll-clock",
.of_match_table = i2s_pll_clk_id,
},
.probe = i2s_pll_clk_probe,
.remove = i2s_pll_clk_remove,
};
module_platform_driver(i2s_pll_clk_driver);
MODULE_AUTHOR("Jose Abreu <joabreu@synopsys.com>");
MODULE_DESCRIPTION("Synopsys AXS10X SDP I2S PLL Clock Driver");
MODULE_LICENSE("GPL v2");
This diff is collapsed.
...@@ -577,7 +577,8 @@ static u32 *parent_process(const char *clocks[], ...@@ -577,7 +577,8 @@ static u32 *parent_process(const char *clocks[],
* selector is not required, but we allocate space for the * selector is not required, but we allocate space for the
* array anyway to keep things simple. * array anyway to keep things simple.
*/ */
parent_names = kmalloc(parent_count * sizeof(parent_names), GFP_KERNEL); parent_names = kmalloc_array(parent_count, sizeof(*parent_names),
GFP_KERNEL);
if (!parent_names) { if (!parent_names) {
pr_err("%s: error allocating %u parent names\n", __func__, pr_err("%s: error allocating %u parent names\n", __func__,
parent_count); parent_count);
......
...@@ -107,16 +107,15 @@ static struct clps711x_clk * __init _clps711x_clk_init(void __iomem *base, ...@@ -107,16 +107,15 @@ static struct clps711x_clk * __init _clps711x_clk_init(void __iomem *base,
writel(tmp, base + CLPS711X_SYSCON1); writel(tmp, base + CLPS711X_SYSCON1);
clps711x_clk->clks[CLPS711X_CLK_DUMMY] = clps711x_clk->clks[CLPS711X_CLK_DUMMY] =
clk_register_fixed_rate(NULL, "dummy", NULL, CLK_IS_ROOT, 0); clk_register_fixed_rate(NULL, "dummy", NULL, 0, 0);
clps711x_clk->clks[CLPS711X_CLK_CPU] = clps711x_clk->clks[CLPS711X_CLK_CPU] =
clk_register_fixed_rate(NULL, "cpu", NULL, CLK_IS_ROOT, f_cpu); clk_register_fixed_rate(NULL, "cpu", NULL, 0, f_cpu);
clps711x_clk->clks[CLPS711X_CLK_BUS] = clps711x_clk->clks[CLPS711X_CLK_BUS] =
clk_register_fixed_rate(NULL, "bus", NULL, CLK_IS_ROOT, f_bus); clk_register_fixed_rate(NULL, "bus", NULL, 0, f_bus);
clps711x_clk->clks[CLPS711X_CLK_PLL] = clps711x_clk->clks[CLPS711X_CLK_PLL] =
clk_register_fixed_rate(NULL, "pll", NULL, CLK_IS_ROOT, f_pll); clk_register_fixed_rate(NULL, "pll", NULL, 0, f_pll);
clps711x_clk->clks[CLPS711X_CLK_TIMERREF] = clps711x_clk->clks[CLPS711X_CLK_TIMERREF] =
clk_register_fixed_rate(NULL, "timer_ref", NULL, CLK_IS_ROOT, clk_register_fixed_rate(NULL, "timer_ref", NULL, 0, f_tim);
f_tim);
clps711x_clk->clks[CLPS711X_CLK_TIMER1] = clps711x_clk->clks[CLPS711X_CLK_TIMER1] =
clk_register_divider_table(NULL, "timer1", "timer_ref", 0, clk_register_divider_table(NULL, "timer1", "timer_ref", 0,
base + CLPS711X_SYSCON1, 5, 1, 0, base + CLPS711X_SYSCON1, 5, 1, 0,
...@@ -126,10 +125,9 @@ static struct clps711x_clk * __init _clps711x_clk_init(void __iomem *base, ...@@ -126,10 +125,9 @@ static struct clps711x_clk * __init _clps711x_clk_init(void __iomem *base,
base + CLPS711X_SYSCON1, 7, 1, 0, base + CLPS711X_SYSCON1, 7, 1, 0,
timer_div_table, &clps711x_clk->lock); timer_div_table, &clps711x_clk->lock);
clps711x_clk->clks[CLPS711X_CLK_PWM] = clps711x_clk->clks[CLPS711X_CLK_PWM] =
clk_register_fixed_rate(NULL, "pwm", NULL, CLK_IS_ROOT, f_pwm); clk_register_fixed_rate(NULL, "pwm", NULL, 0, f_pwm);
clps711x_clk->clks[CLPS711X_CLK_SPIREF] = clps711x_clk->clks[CLPS711X_CLK_SPIREF] =
clk_register_fixed_rate(NULL, "spi_ref", NULL, CLK_IS_ROOT, clk_register_fixed_rate(NULL, "spi_ref", NULL, 0, f_spi);
f_spi);
clps711x_clk->clks[CLPS711X_CLK_SPI] = clps711x_clk->clks[CLPS711X_CLK_SPI] =
clk_register_divider_table(NULL, "spi", "spi_ref", 0, clk_register_divider_table(NULL, "spi", "spi_ref", 0,
base + CLPS711X_SYSCON1, 16, 2, 0, base + CLPS711X_SYSCON1, 16, 2, 0,
...@@ -137,8 +135,7 @@ static struct clps711x_clk * __init _clps711x_clk_init(void __iomem *base, ...@@ -137,8 +135,7 @@ static struct clps711x_clk * __init _clps711x_clk_init(void __iomem *base,
clps711x_clk->clks[CLPS711X_CLK_UART] = clps711x_clk->clks[CLPS711X_CLK_UART] =
clk_register_fixed_factor(NULL, "uart", "bus", 0, 1, 10); clk_register_fixed_factor(NULL, "uart", "bus", 0, 1, 10);
clps711x_clk->clks[CLPS711X_CLK_TICK] = clps711x_clk->clks[CLPS711X_CLK_TICK] =
clk_register_fixed_rate(NULL, "tick", NULL, CLK_IS_ROOT, 64); clk_register_fixed_rate(NULL, "tick", NULL, 0, 64);
for (i = 0; i < CLPS711X_CLK_MAX; i++) for (i = 0; i < CLPS711X_CLK_MAX; i++)
if (IS_ERR(clps711x_clk->clks[i])) if (IS_ERR(clps711x_clk->clks[i]))
pr_err("clk %i: register failed with %ld\n", pr_err("clk %i: register failed with %ld\n",
......
...@@ -151,6 +151,33 @@ static int clk_composite_set_rate(struct clk_hw *hw, unsigned long rate, ...@@ -151,6 +151,33 @@ static int clk_composite_set_rate(struct clk_hw *hw, unsigned long rate,
return rate_ops->set_rate(rate_hw, rate, parent_rate); return rate_ops->set_rate(rate_hw, rate, parent_rate);
} }
static int clk_composite_set_rate_and_parent(struct clk_hw *hw,
unsigned long rate,
unsigned long parent_rate,
u8 index)
{
struct clk_composite *composite = to_clk_composite(hw);
const struct clk_ops *rate_ops = composite->rate_ops;
const struct clk_ops *mux_ops = composite->mux_ops;
struct clk_hw *rate_hw = composite->rate_hw;
struct clk_hw *mux_hw = composite->mux_hw;
unsigned long temp_rate;
__clk_hw_set_clk(rate_hw, hw);
__clk_hw_set_clk(mux_hw, hw);
temp_rate = rate_ops->recalc_rate(rate_hw, parent_rate);
if (temp_rate > rate) {
rate_ops->set_rate(rate_hw, rate, parent_rate);
mux_ops->set_parent(mux_hw, index);
} else {
mux_ops->set_parent(mux_hw, index);
rate_ops->set_rate(rate_hw, rate, parent_rate);
}
return 0;
}
static int clk_composite_is_enabled(struct clk_hw *hw) static int clk_composite_is_enabled(struct clk_hw *hw)
{ {
struct clk_composite *composite = to_clk_composite(hw); struct clk_composite *composite = to_clk_composite(hw);
...@@ -184,17 +211,18 @@ static void clk_composite_disable(struct clk_hw *hw) ...@@ -184,17 +211,18 @@ static void clk_composite_disable(struct clk_hw *hw)
gate_ops->disable(gate_hw); gate_ops->disable(gate_hw);
} }
struct clk *clk_register_composite(struct device *dev, const char *name, struct clk_hw *clk_hw_register_composite(struct device *dev, const char *name,
const char * const *parent_names, int num_parents, const char * const *parent_names, int num_parents,
struct clk_hw *mux_hw, const struct clk_ops *mux_ops, struct clk_hw *mux_hw, const struct clk_ops *mux_ops,
struct clk_hw *rate_hw, const struct clk_ops *rate_ops, struct clk_hw *rate_hw, const struct clk_ops *rate_ops,
struct clk_hw *gate_hw, const struct clk_ops *gate_ops, struct clk_hw *gate_hw, const struct clk_ops *gate_ops,
unsigned long flags) unsigned long flags)
{ {
struct clk *clk; struct clk_hw *hw;
struct clk_init_data init; struct clk_init_data init;
struct clk_composite *composite; struct clk_composite *composite;
struct clk_ops *clk_composite_ops; struct clk_ops *clk_composite_ops;
int ret;
composite = kzalloc(sizeof(*composite), GFP_KERNEL); composite = kzalloc(sizeof(*composite), GFP_KERNEL);
if (!composite) if (!composite)
...@@ -204,12 +232,13 @@ struct clk *clk_register_composite(struct device *dev, const char *name, ...@@ -204,12 +232,13 @@ struct clk *clk_register_composite(struct device *dev, const char *name,
init.flags = flags | CLK_IS_BASIC; init.flags = flags | CLK_IS_BASIC;
init.parent_names = parent_names; init.parent_names = parent_names;
init.num_parents = num_parents; init.num_parents = num_parents;
hw = &composite->hw;
clk_composite_ops = &composite->ops; clk_composite_ops = &composite->ops;
if (mux_hw && mux_ops) { if (mux_hw && mux_ops) {
if (!mux_ops->get_parent) { if (!mux_ops->get_parent) {
clk = ERR_PTR(-EINVAL); hw = ERR_PTR(-EINVAL);
goto err; goto err;
} }
...@@ -224,7 +253,7 @@ struct clk *clk_register_composite(struct device *dev, const char *name, ...@@ -224,7 +253,7 @@ struct clk *clk_register_composite(struct device *dev, const char *name,
if (rate_hw && rate_ops) { if (rate_hw && rate_ops) {
if (!rate_ops->recalc_rate) { if (!rate_ops->recalc_rate) {
clk = ERR_PTR(-EINVAL); hw = ERR_PTR(-EINVAL);
goto err; goto err;
} }
clk_composite_ops->recalc_rate = clk_composite_recalc_rate; clk_composite_ops->recalc_rate = clk_composite_recalc_rate;
...@@ -250,10 +279,16 @@ struct clk *clk_register_composite(struct device *dev, const char *name, ...@@ -250,10 +279,16 @@ struct clk *clk_register_composite(struct device *dev, const char *name,
composite->rate_ops = rate_ops; composite->rate_ops = rate_ops;
} }
if (mux_hw && mux_ops && rate_hw && rate_ops) {
if (mux_ops->set_parent && rate_ops->set_rate)
clk_composite_ops->set_rate_and_parent =
clk_composite_set_rate_and_parent;
}
if (gate_hw && gate_ops) { if (gate_hw && gate_ops) {
if (!gate_ops->is_enabled || !gate_ops->enable || if (!gate_ops->is_enabled || !gate_ops->enable ||
!gate_ops->disable) { !gate_ops->disable) {
clk = ERR_PTR(-EINVAL); hw = ERR_PTR(-EINVAL);
goto err; goto err;
} }
...@@ -267,22 +302,56 @@ struct clk *clk_register_composite(struct device *dev, const char *name, ...@@ -267,22 +302,56 @@ struct clk *clk_register_composite(struct device *dev, const char *name,
init.ops = clk_composite_ops; init.ops = clk_composite_ops;
composite->hw.init = &init; composite->hw.init = &init;
clk = clk_register(dev, &composite->hw); ret = clk_hw_register(dev, hw);
if (IS_ERR(clk)) if (ret) {
hw = ERR_PTR(ret);
goto err; goto err;
}
if (composite->mux_hw) if (composite->mux_hw)
composite->mux_hw->clk = clk; composite->mux_hw->clk = hw->clk;
if (composite->rate_hw) if (composite->rate_hw)
composite->rate_hw->clk = clk; composite->rate_hw->clk = hw->clk;
if (composite->gate_hw) if (composite->gate_hw)
composite->gate_hw->clk = clk; composite->gate_hw->clk = hw->clk;
return clk; return hw;
err: err:
kfree(composite); kfree(composite);
return clk; return hw;
}
struct clk *clk_register_composite(struct device *dev, const char *name,
const char * const *parent_names, int num_parents,
struct clk_hw *mux_hw, const struct clk_ops *mux_ops,
struct clk_hw *rate_hw, const struct clk_ops *rate_ops,
struct clk_hw *gate_hw, const struct clk_ops *gate_ops,
unsigned long flags)
{
struct clk_hw *hw;
hw = clk_hw_register_composite(dev, name, parent_names, num_parents,
mux_hw, mux_ops, rate_hw, rate_ops, gate_hw, gate_ops,
flags);
if (IS_ERR(hw))
return ERR_CAST(hw);
return hw->clk;
}
void clk_unregister_composite(struct clk *clk)
{
struct clk_composite *composite;
struct clk_hw *hw;
hw = __clk_get_hw(clk);
if (!hw)
return;
composite = to_clk_composite(hw);
clk_unregister(clk);
kfree(composite);
} }
...@@ -426,15 +426,16 @@ const struct clk_ops clk_divider_ro_ops = { ...@@ -426,15 +426,16 @@ const struct clk_ops clk_divider_ro_ops = {
}; };
EXPORT_SYMBOL_GPL(clk_divider_ro_ops); EXPORT_SYMBOL_GPL(clk_divider_ro_ops);
static struct clk *_register_divider(struct device *dev, const char *name, static struct clk_hw *_register_divider(struct device *dev, const char *name,
const char *parent_name, unsigned long flags, const char *parent_name, unsigned long flags,
void __iomem *reg, u8 shift, u8 width, void __iomem *reg, u8 shift, u8 width,
u8 clk_divider_flags, const struct clk_div_table *table, u8 clk_divider_flags, const struct clk_div_table *table,
spinlock_t *lock) spinlock_t *lock)
{ {
struct clk_divider *div; struct clk_divider *div;
struct clk *clk; struct clk_hw *hw;
struct clk_init_data init; struct clk_init_data init;
int ret;
if (clk_divider_flags & CLK_DIVIDER_HIWORD_MASK) { if (clk_divider_flags & CLK_DIVIDER_HIWORD_MASK) {
if (width + shift > 16) { if (width + shift > 16) {
...@@ -467,12 +468,14 @@ static struct clk *_register_divider(struct device *dev, const char *name, ...@@ -467,12 +468,14 @@ static struct clk *_register_divider(struct device *dev, const char *name,
div->table = table; div->table = table;
/* register the clock */ /* register the clock */
clk = clk_register(dev, &div->hw); hw = &div->hw;
ret = clk_hw_register(dev, hw);
if (IS_ERR(clk)) if (ret) {
kfree(div); kfree(div);
hw = ERR_PTR(ret);
}
return clk; return hw;
} }
/** /**
...@@ -492,11 +495,38 @@ struct clk *clk_register_divider(struct device *dev, const char *name, ...@@ -492,11 +495,38 @@ struct clk *clk_register_divider(struct device *dev, const char *name,
void __iomem *reg, u8 shift, u8 width, void __iomem *reg, u8 shift, u8 width,
u8 clk_divider_flags, spinlock_t *lock) u8 clk_divider_flags, spinlock_t *lock)
{ {
return _register_divider(dev, name, parent_name, flags, reg, shift, struct clk_hw *hw;
hw = _register_divider(dev, name, parent_name, flags, reg, shift,
width, clk_divider_flags, NULL, lock); width, clk_divider_flags, NULL, lock);
if (IS_ERR(hw))
return ERR_CAST(hw);
return hw->clk;
} }
EXPORT_SYMBOL_GPL(clk_register_divider); EXPORT_SYMBOL_GPL(clk_register_divider);
/**
* clk_hw_register_divider - register a divider clock with the clock framework
* @dev: device registering this clock
* @name: name of this clock
* @parent_name: name of clock's parent
* @flags: framework-specific flags
* @reg: register address to adjust divider
* @shift: number of bits to shift the bitfield
* @width: width of the bitfield
* @clk_divider_flags: divider-specific flags for this clock
* @lock: shared register lock for this clock
*/
struct clk_hw *clk_hw_register_divider(struct device *dev, const char *name,
const char *parent_name, unsigned long flags,
void __iomem *reg, u8 shift, u8 width,
u8 clk_divider_flags, spinlock_t *lock)
{
return _register_divider(dev, name, parent_name, flags, reg, shift,
width, clk_divider_flags, NULL, lock);
}
EXPORT_SYMBOL_GPL(clk_hw_register_divider);
/** /**
* clk_register_divider_table - register a table based divider clock with * clk_register_divider_table - register a table based divider clock with
* the clock framework * the clock framework
...@@ -517,11 +547,41 @@ struct clk *clk_register_divider_table(struct device *dev, const char *name, ...@@ -517,11 +547,41 @@ struct clk *clk_register_divider_table(struct device *dev, const char *name,
u8 clk_divider_flags, const struct clk_div_table *table, u8 clk_divider_flags, const struct clk_div_table *table,
spinlock_t *lock) spinlock_t *lock)
{ {
return _register_divider(dev, name, parent_name, flags, reg, shift, struct clk_hw *hw;
hw = _register_divider(dev, name, parent_name, flags, reg, shift,
width, clk_divider_flags, table, lock); width, clk_divider_flags, table, lock);
if (IS_ERR(hw))
return ERR_CAST(hw);
return hw->clk;
} }
EXPORT_SYMBOL_GPL(clk_register_divider_table); EXPORT_SYMBOL_GPL(clk_register_divider_table);
/**
* clk_hw_register_divider_table - register a table based divider clock with
* the clock framework
* @dev: device registering this clock
* @name: name of this clock
* @parent_name: name of clock's parent
* @flags: framework-specific flags
* @reg: register address to adjust divider
* @shift: number of bits to shift the bitfield
* @width: width of the bitfield
* @clk_divider_flags: divider-specific flags for this clock
* @table: array of divider/value pairs ending with a div set to 0
* @lock: shared register lock for this clock
*/
struct clk_hw *clk_hw_register_divider_table(struct device *dev,
const char *name, const char *parent_name, unsigned long flags,
void __iomem *reg, u8 shift, u8 width,
u8 clk_divider_flags, const struct clk_div_table *table,
spinlock_t *lock)
{
return _register_divider(dev, name, parent_name, flags, reg, shift,
width, clk_divider_flags, table, lock);
}
EXPORT_SYMBOL_GPL(clk_hw_register_divider_table);
void clk_unregister_divider(struct clk *clk) void clk_unregister_divider(struct clk *clk)
{ {
struct clk_divider *div; struct clk_divider *div;
...@@ -537,3 +597,18 @@ void clk_unregister_divider(struct clk *clk) ...@@ -537,3 +597,18 @@ void clk_unregister_divider(struct clk *clk)
kfree(div); kfree(div);
} }
EXPORT_SYMBOL_GPL(clk_unregister_divider); EXPORT_SYMBOL_GPL(clk_unregister_divider);
/**
* clk_hw_unregister_divider - unregister a clk divider
* @hw: hardware-specific clock data to unregister
*/
void clk_hw_unregister_divider(struct clk_hw *hw)
{
struct clk_divider *div;
div = to_clk_divider(hw);
clk_hw_unregister(hw);
kfree(div);
}
EXPORT_SYMBOL_GPL(clk_hw_unregister_divider);
...@@ -68,13 +68,14 @@ const struct clk_ops clk_fixed_factor_ops = { ...@@ -68,13 +68,14 @@ const struct clk_ops clk_fixed_factor_ops = {
}; };
EXPORT_SYMBOL_GPL(clk_fixed_factor_ops); EXPORT_SYMBOL_GPL(clk_fixed_factor_ops);
struct clk *clk_register_fixed_factor(struct device *dev, const char *name, struct clk_hw *clk_hw_register_fixed_factor(struct device *dev,
const char *parent_name, unsigned long flags, const char *name, const char *parent_name, unsigned long flags,
unsigned int mult, unsigned int div) unsigned int mult, unsigned int div)
{ {
struct clk_fixed_factor *fix; struct clk_fixed_factor *fix;
struct clk_init_data init; struct clk_init_data init;
struct clk *clk; struct clk_hw *hw;
int ret;
fix = kmalloc(sizeof(*fix), GFP_KERNEL); fix = kmalloc(sizeof(*fix), GFP_KERNEL);
if (!fix) if (!fix)
...@@ -91,12 +92,28 @@ struct clk *clk_register_fixed_factor(struct device *dev, const char *name, ...@@ -91,12 +92,28 @@ struct clk *clk_register_fixed_factor(struct device *dev, const char *name,
init.parent_names = &parent_name; init.parent_names = &parent_name;
init.num_parents = 1; init.num_parents = 1;
clk = clk_register(dev, &fix->hw); hw = &fix->hw;
ret = clk_hw_register(dev, hw);
if (IS_ERR(clk)) if (ret) {
kfree(fix); kfree(fix);
hw = ERR_PTR(ret);
}
return clk; return hw;
}
EXPORT_SYMBOL_GPL(clk_hw_register_fixed_factor);
struct clk *clk_register_fixed_factor(struct device *dev, const char *name,
const char *parent_name, unsigned long flags,
unsigned int mult, unsigned int div)
{
struct clk_hw *hw;
hw = clk_hw_register_fixed_factor(dev, name, parent_name, flags, mult,
div);
if (IS_ERR(hw))
return ERR_CAST(hw);
return hw->clk;
} }
EXPORT_SYMBOL_GPL(clk_register_fixed_factor); EXPORT_SYMBOL_GPL(clk_register_fixed_factor);
...@@ -113,6 +130,17 @@ void clk_unregister_fixed_factor(struct clk *clk) ...@@ -113,6 +130,17 @@ void clk_unregister_fixed_factor(struct clk *clk)
} }
EXPORT_SYMBOL_GPL(clk_unregister_fixed_factor); EXPORT_SYMBOL_GPL(clk_unregister_fixed_factor);
void clk_hw_unregister_fixed_factor(struct clk_hw *hw)
{
struct clk_fixed_factor *fix;
fix = to_clk_fixed_factor(hw);
clk_hw_unregister(hw);
kfree(fix);
}
EXPORT_SYMBOL_GPL(clk_hw_unregister_fixed_factor);
#ifdef CONFIG_OF #ifdef CONFIG_OF
/** /**
* of_fixed_factor_clk_setup() - Setup function for simple fixed factor clock * of_fixed_factor_clk_setup() - Setup function for simple fixed factor clock
......
...@@ -45,8 +45,8 @@ const struct clk_ops clk_fixed_rate_ops = { ...@@ -45,8 +45,8 @@ const struct clk_ops clk_fixed_rate_ops = {
EXPORT_SYMBOL_GPL(clk_fixed_rate_ops); EXPORT_SYMBOL_GPL(clk_fixed_rate_ops);
/** /**
* clk_register_fixed_rate_with_accuracy - register fixed-rate clock with the * clk_hw_register_fixed_rate_with_accuracy - register fixed-rate clock with
* clock framework * the clock framework
* @dev: device that is registering this clock * @dev: device that is registering this clock
* @name: name of this clock * @name: name of this clock
* @parent_name: name of clock's parent * @parent_name: name of clock's parent
...@@ -54,13 +54,14 @@ EXPORT_SYMBOL_GPL(clk_fixed_rate_ops); ...@@ -54,13 +54,14 @@ EXPORT_SYMBOL_GPL(clk_fixed_rate_ops);
* @fixed_rate: non-adjustable clock rate * @fixed_rate: non-adjustable clock rate
* @fixed_accuracy: non-adjustable clock rate * @fixed_accuracy: non-adjustable clock rate
*/ */
struct clk *clk_register_fixed_rate_with_accuracy(struct device *dev, struct clk_hw *clk_hw_register_fixed_rate_with_accuracy(struct device *dev,
const char *name, const char *parent_name, unsigned long flags, const char *name, const char *parent_name, unsigned long flags,
unsigned long fixed_rate, unsigned long fixed_accuracy) unsigned long fixed_rate, unsigned long fixed_accuracy)
{ {
struct clk_fixed_rate *fixed; struct clk_fixed_rate *fixed;
struct clk *clk; struct clk_hw *hw;
struct clk_init_data init; struct clk_init_data init;
int ret;
/* allocate fixed-rate clock */ /* allocate fixed-rate clock */
fixed = kzalloc(sizeof(*fixed), GFP_KERNEL); fixed = kzalloc(sizeof(*fixed), GFP_KERNEL);
...@@ -79,22 +80,49 @@ struct clk *clk_register_fixed_rate_with_accuracy(struct device *dev, ...@@ -79,22 +80,49 @@ struct clk *clk_register_fixed_rate_with_accuracy(struct device *dev,
fixed->hw.init = &init; fixed->hw.init = &init;
/* register the clock */ /* register the clock */
clk = clk_register(dev, &fixed->hw); hw = &fixed->hw;
if (IS_ERR(clk)) ret = clk_hw_register(dev, hw);
if (ret) {
kfree(fixed); kfree(fixed);
hw = ERR_PTR(ret);
}
return clk; return hw;
}
EXPORT_SYMBOL_GPL(clk_hw_register_fixed_rate_with_accuracy);
struct clk *clk_register_fixed_rate_with_accuracy(struct device *dev,
const char *name, const char *parent_name, unsigned long flags,
unsigned long fixed_rate, unsigned long fixed_accuracy)
{
struct clk_hw *hw;
hw = clk_hw_register_fixed_rate_with_accuracy(dev, name, parent_name,
flags, fixed_rate, fixed_accuracy);
if (IS_ERR(hw))
return ERR_CAST(hw);
return hw->clk;
} }
EXPORT_SYMBOL_GPL(clk_register_fixed_rate_with_accuracy); EXPORT_SYMBOL_GPL(clk_register_fixed_rate_with_accuracy);
/** /**
* clk_register_fixed_rate - register fixed-rate clock with the clock framework * clk_hw_register_fixed_rate - register fixed-rate clock with the clock
* framework
* @dev: device that is registering this clock * @dev: device that is registering this clock
* @name: name of this clock * @name: name of this clock
* @parent_name: name of clock's parent * @parent_name: name of clock's parent
* @flags: framework-specific flags * @flags: framework-specific flags
* @fixed_rate: non-adjustable clock rate * @fixed_rate: non-adjustable clock rate
*/ */
struct clk_hw *clk_hw_register_fixed_rate(struct device *dev, const char *name,
const char *parent_name, unsigned long flags,
unsigned long fixed_rate)
{
return clk_hw_register_fixed_rate_with_accuracy(dev, name, parent_name,
flags, fixed_rate, 0);
}
EXPORT_SYMBOL_GPL(clk_hw_register_fixed_rate);
struct clk *clk_register_fixed_rate(struct device *dev, const char *name, struct clk *clk_register_fixed_rate(struct device *dev, const char *name,
const char *parent_name, unsigned long flags, const char *parent_name, unsigned long flags,
unsigned long fixed_rate) unsigned long fixed_rate)
......
...@@ -116,14 +116,15 @@ const struct clk_ops clk_fractional_divider_ops = { ...@@ -116,14 +116,15 @@ const struct clk_ops clk_fractional_divider_ops = {
}; };
EXPORT_SYMBOL_GPL(clk_fractional_divider_ops); EXPORT_SYMBOL_GPL(clk_fractional_divider_ops);
struct clk *clk_register_fractional_divider(struct device *dev, struct clk_hw *clk_hw_register_fractional_divider(struct device *dev,
const char *name, const char *parent_name, unsigned long flags, const char *name, const char *parent_name, unsigned long flags,
void __iomem *reg, u8 mshift, u8 mwidth, u8 nshift, u8 nwidth, void __iomem *reg, u8 mshift, u8 mwidth, u8 nshift, u8 nwidth,
u8 clk_divider_flags, spinlock_t *lock) u8 clk_divider_flags, spinlock_t *lock)
{ {
struct clk_fractional_divider *fd; struct clk_fractional_divider *fd;
struct clk_init_data init; struct clk_init_data init;
struct clk *clk; struct clk_hw *hw;
int ret;
fd = kzalloc(sizeof(*fd), GFP_KERNEL); fd = kzalloc(sizeof(*fd), GFP_KERNEL);
if (!fd) if (!fd)
...@@ -146,10 +147,39 @@ struct clk *clk_register_fractional_divider(struct device *dev, ...@@ -146,10 +147,39 @@ struct clk *clk_register_fractional_divider(struct device *dev,
fd->lock = lock; fd->lock = lock;
fd->hw.init = &init; fd->hw.init = &init;
clk = clk_register(dev, &fd->hw); hw = &fd->hw;
if (IS_ERR(clk)) ret = clk_hw_register(dev, hw);
if (ret) {
kfree(fd); kfree(fd);
hw = ERR_PTR(ret);
}
return hw;
}
EXPORT_SYMBOL_GPL(clk_hw_register_fractional_divider);
return clk; struct clk *clk_register_fractional_divider(struct device *dev,
const char *name, const char *parent_name, unsigned long flags,
void __iomem *reg, u8 mshift, u8 mwidth, u8 nshift, u8 nwidth,
u8 clk_divider_flags, spinlock_t *lock)
{
struct clk_hw *hw;
hw = clk_hw_register_fractional_divider(dev, name, parent_name, flags,
reg, mshift, mwidth, nshift, nwidth, clk_divider_flags,
lock);
if (IS_ERR(hw))
return ERR_CAST(hw);
return hw->clk;
} }
EXPORT_SYMBOL_GPL(clk_register_fractional_divider); EXPORT_SYMBOL_GPL(clk_register_fractional_divider);
void clk_hw_unregister_fractional_divider(struct clk_hw *hw)
{
struct clk_fractional_divider *fd;
fd = to_clk_fd(hw);
clk_hw_unregister(hw);
kfree(fd);
}
...@@ -110,7 +110,7 @@ const struct clk_ops clk_gate_ops = { ...@@ -110,7 +110,7 @@ const struct clk_ops clk_gate_ops = {
EXPORT_SYMBOL_GPL(clk_gate_ops); EXPORT_SYMBOL_GPL(clk_gate_ops);
/** /**
* clk_register_gate - register a gate clock with the clock framework * clk_hw_register_gate - register a gate clock with the clock framework
* @dev: device that is registering this clock * @dev: device that is registering this clock
* @name: name of this clock * @name: name of this clock
* @parent_name: name of this clock's parent * @parent_name: name of this clock's parent
...@@ -120,14 +120,15 @@ EXPORT_SYMBOL_GPL(clk_gate_ops); ...@@ -120,14 +120,15 @@ EXPORT_SYMBOL_GPL(clk_gate_ops);
* @clk_gate_flags: gate-specific flags for this clock * @clk_gate_flags: gate-specific flags for this clock
* @lock: shared register lock for this clock * @lock: shared register lock for this clock
*/ */
struct clk *clk_register_gate(struct device *dev, const char *name, struct clk_hw *clk_hw_register_gate(struct device *dev, const char *name,
const char *parent_name, unsigned long flags, const char *parent_name, unsigned long flags,
void __iomem *reg, u8 bit_idx, void __iomem *reg, u8 bit_idx,
u8 clk_gate_flags, spinlock_t *lock) u8 clk_gate_flags, spinlock_t *lock)
{ {
struct clk_gate *gate; struct clk_gate *gate;
struct clk *clk; struct clk_hw *hw;
struct clk_init_data init; struct clk_init_data init;
int ret;
if (clk_gate_flags & CLK_GATE_HIWORD_MASK) { if (clk_gate_flags & CLK_GATE_HIWORD_MASK) {
if (bit_idx > 15) { if (bit_idx > 15) {
...@@ -154,12 +155,29 @@ struct clk *clk_register_gate(struct device *dev, const char *name, ...@@ -154,12 +155,29 @@ struct clk *clk_register_gate(struct device *dev, const char *name,
gate->lock = lock; gate->lock = lock;
gate->hw.init = &init; gate->hw.init = &init;
clk = clk_register(dev, &gate->hw); hw = &gate->hw;
ret = clk_hw_register(dev, hw);
if (IS_ERR(clk)) if (ret) {
kfree(gate); kfree(gate);
hw = ERR_PTR(ret);
}
return clk; return hw;
}
EXPORT_SYMBOL_GPL(clk_hw_register_gate);
struct clk *clk_register_gate(struct device *dev, const char *name,
const char *parent_name, unsigned long flags,
void __iomem *reg, u8 bit_idx,
u8 clk_gate_flags, spinlock_t *lock)
{
struct clk_hw *hw;
hw = clk_hw_register_gate(dev, name, parent_name, flags, reg,
bit_idx, clk_gate_flags, lock);
if (IS_ERR(hw))
return ERR_CAST(hw);
return hw->clk;
} }
EXPORT_SYMBOL_GPL(clk_register_gate); EXPORT_SYMBOL_GPL(clk_register_gate);
...@@ -178,3 +196,14 @@ void clk_unregister_gate(struct clk *clk) ...@@ -178,3 +196,14 @@ void clk_unregister_gate(struct clk *clk)
kfree(gate); kfree(gate);
} }
EXPORT_SYMBOL_GPL(clk_unregister_gate); EXPORT_SYMBOL_GPL(clk_unregister_gate);
void clk_hw_unregister_gate(struct clk_hw *hw)
{
struct clk_gate *gate;
gate = to_clk_gate(hw);
clk_hw_unregister(hw);
kfree(gate);
}
EXPORT_SYMBOL_GPL(clk_hw_unregister_gate);
...@@ -94,13 +94,13 @@ const struct clk_ops clk_gpio_mux_ops = { ...@@ -94,13 +94,13 @@ const struct clk_ops clk_gpio_mux_ops = {
}; };
EXPORT_SYMBOL_GPL(clk_gpio_mux_ops); EXPORT_SYMBOL_GPL(clk_gpio_mux_ops);
static struct clk *clk_register_gpio(struct device *dev, const char *name, static struct clk_hw *clk_register_gpio(struct device *dev, const char *name,
const char * const *parent_names, u8 num_parents, unsigned gpio, const char * const *parent_names, u8 num_parents, unsigned gpio,
bool active_low, unsigned long flags, bool active_low, unsigned long flags,
const struct clk_ops *clk_gpio_ops) const struct clk_ops *clk_gpio_ops)
{ {
struct clk_gpio *clk_gpio; struct clk_gpio *clk_gpio;
struct clk *clk; struct clk_hw *hw;
struct clk_init_data init = {}; struct clk_init_data init = {};
unsigned long gpio_flags; unsigned long gpio_flags;
int err; int err;
...@@ -141,24 +141,26 @@ static struct clk *clk_register_gpio(struct device *dev, const char *name, ...@@ -141,24 +141,26 @@ static struct clk *clk_register_gpio(struct device *dev, const char *name,
clk_gpio->gpiod = gpio_to_desc(gpio); clk_gpio->gpiod = gpio_to_desc(gpio);
clk_gpio->hw.init = &init; clk_gpio->hw.init = &init;
hw = &clk_gpio->hw;
if (dev) if (dev)
clk = devm_clk_register(dev, &clk_gpio->hw); err = devm_clk_hw_register(dev, hw);
else else
clk = clk_register(NULL, &clk_gpio->hw); err = clk_hw_register(NULL, hw);
if (!IS_ERR(clk)) if (!err)
return clk; return hw;
if (!dev) { if (!dev) {
gpiod_put(clk_gpio->gpiod); gpiod_put(clk_gpio->gpiod);
kfree(clk_gpio); kfree(clk_gpio);
} }
return clk; return ERR_PTR(err);
} }
/** /**
* clk_register_gpio_gate - register a gpio clock gate with the clock framework * clk_hw_register_gpio_gate - register a gpio clock gate with the clock
* framework
* @dev: device that is registering this clock * @dev: device that is registering this clock
* @name: name of this clock * @name: name of this clock
* @parent_name: name of this clock's parent * @parent_name: name of this clock's parent
...@@ -166,7 +168,7 @@ static struct clk *clk_register_gpio(struct device *dev, const char *name, ...@@ -166,7 +168,7 @@ static struct clk *clk_register_gpio(struct device *dev, const char *name,
* @active_low: true if gpio should be set to 0 to enable clock * @active_low: true if gpio should be set to 0 to enable clock
* @flags: clock flags * @flags: clock flags
*/ */
struct clk *clk_register_gpio_gate(struct device *dev, const char *name, struct clk_hw *clk_hw_register_gpio_gate(struct device *dev, const char *name,
const char *parent_name, unsigned gpio, bool active_low, const char *parent_name, unsigned gpio, bool active_low,
unsigned long flags) unsigned long flags)
{ {
...@@ -175,10 +177,24 @@ struct clk *clk_register_gpio_gate(struct device *dev, const char *name, ...@@ -175,10 +177,24 @@ struct clk *clk_register_gpio_gate(struct device *dev, const char *name,
(parent_name ? 1 : 0), gpio, active_low, flags, (parent_name ? 1 : 0), gpio, active_low, flags,
&clk_gpio_gate_ops); &clk_gpio_gate_ops);
} }
EXPORT_SYMBOL_GPL(clk_hw_register_gpio_gate);
struct clk *clk_register_gpio_gate(struct device *dev, const char *name,
const char *parent_name, unsigned gpio, bool active_low,
unsigned long flags)
{
struct clk_hw *hw;
hw = clk_hw_register_gpio_gate(dev, name, parent_name, gpio, active_low,
flags);
if (IS_ERR(hw))
return ERR_CAST(hw);
return hw->clk;
}
EXPORT_SYMBOL_GPL(clk_register_gpio_gate); EXPORT_SYMBOL_GPL(clk_register_gpio_gate);
/** /**
* clk_register_gpio_mux - register a gpio clock mux with the clock framework * clk_hw_register_gpio_mux - register a gpio clock mux with the clock framework
* @dev: device that is registering this clock * @dev: device that is registering this clock
* @name: name of this clock * @name: name of this clock
* @parent_names: names of this clock's parents * @parent_names: names of this clock's parents
...@@ -187,7 +203,7 @@ EXPORT_SYMBOL_GPL(clk_register_gpio_gate); ...@@ -187,7 +203,7 @@ EXPORT_SYMBOL_GPL(clk_register_gpio_gate);
* @active_low: true if gpio should be set to 0 to enable clock * @active_low: true if gpio should be set to 0 to enable clock
* @flags: clock flags * @flags: clock flags
*/ */
struct clk *clk_register_gpio_mux(struct device *dev, const char *name, struct clk_hw *clk_hw_register_gpio_mux(struct device *dev, const char *name,
const char * const *parent_names, u8 num_parents, unsigned gpio, const char * const *parent_names, u8 num_parents, unsigned gpio,
bool active_low, unsigned long flags) bool active_low, unsigned long flags)
{ {
...@@ -199,6 +215,20 @@ struct clk *clk_register_gpio_mux(struct device *dev, const char *name, ...@@ -199,6 +215,20 @@ struct clk *clk_register_gpio_mux(struct device *dev, const char *name,
return clk_register_gpio(dev, name, parent_names, num_parents, return clk_register_gpio(dev, name, parent_names, num_parents,
gpio, active_low, flags, &clk_gpio_mux_ops); gpio, active_low, flags, &clk_gpio_mux_ops);
} }
EXPORT_SYMBOL_GPL(clk_hw_register_gpio_mux);
struct clk *clk_register_gpio_mux(struct device *dev, const char *name,
const char * const *parent_names, u8 num_parents, unsigned gpio,
bool active_low, unsigned long flags)
{
struct clk_hw *hw;
hw = clk_hw_register_gpio_mux(dev, name, parent_names, num_parents,
gpio, active_low, flags);
if (IS_ERR(hw))
return ERR_CAST(hw);
return hw->clk;
}
EXPORT_SYMBOL_GPL(clk_register_gpio_mux); EXPORT_SYMBOL_GPL(clk_register_gpio_mux);
static int gpio_clk_driver_probe(struct platform_device *pdev) static int gpio_clk_driver_probe(struct platform_device *pdev)
......
...@@ -88,8 +88,7 @@ void __init ls1x_clk_init(void) ...@@ -88,8 +88,7 @@ void __init ls1x_clk_init(void)
{ {
struct clk *clk; struct clk *clk;
clk = clk_register_fixed_rate(NULL, "osc_33m_clk", NULL, CLK_IS_ROOT, clk = clk_register_fixed_rate(NULL, "osc_33m_clk", NULL, 0, OSC);
OSC);
clk_register_clkdev(clk, "osc_33m_clk", NULL); clk_register_clkdev(clk, "osc_33m_clk", NULL);
/* clock derived from 33 MHz OSC clk */ /* clock derived from 33 MHz OSC clk */
......
...@@ -113,16 +113,17 @@ const struct clk_ops clk_mux_ro_ops = { ...@@ -113,16 +113,17 @@ const struct clk_ops clk_mux_ro_ops = {
}; };
EXPORT_SYMBOL_GPL(clk_mux_ro_ops); EXPORT_SYMBOL_GPL(clk_mux_ro_ops);
struct clk *clk_register_mux_table(struct device *dev, const char *name, struct clk_hw *clk_hw_register_mux_table(struct device *dev, const char *name,
const char * const *parent_names, u8 num_parents, const char * const *parent_names, u8 num_parents,
unsigned long flags, unsigned long flags,
void __iomem *reg, u8 shift, u32 mask, void __iomem *reg, u8 shift, u32 mask,
u8 clk_mux_flags, u32 *table, spinlock_t *lock) u8 clk_mux_flags, u32 *table, spinlock_t *lock)
{ {
struct clk_mux *mux; struct clk_mux *mux;
struct clk *clk; struct clk_hw *hw;
struct clk_init_data init; struct clk_init_data init;
u8 width = 0; u8 width = 0;
int ret;
if (clk_mux_flags & CLK_MUX_HIWORD_MASK) { if (clk_mux_flags & CLK_MUX_HIWORD_MASK) {
width = fls(mask) - ffs(mask) + 1; width = fls(mask) - ffs(mask) + 1;
...@@ -157,12 +158,31 @@ struct clk *clk_register_mux_table(struct device *dev, const char *name, ...@@ -157,12 +158,31 @@ struct clk *clk_register_mux_table(struct device *dev, const char *name,
mux->table = table; mux->table = table;
mux->hw.init = &init; mux->hw.init = &init;
clk = clk_register(dev, &mux->hw); hw = &mux->hw;
ret = clk_hw_register(dev, hw);
if (IS_ERR(clk)) if (ret) {
kfree(mux); kfree(mux);
hw = ERR_PTR(ret);
}
return clk; return hw;
}
EXPORT_SYMBOL_GPL(clk_hw_register_mux_table);
struct clk *clk_register_mux_table(struct device *dev, const char *name,
const char * const *parent_names, u8 num_parents,
unsigned long flags,
void __iomem *reg, u8 shift, u32 mask,
u8 clk_mux_flags, u32 *table, spinlock_t *lock)
{
struct clk_hw *hw;
hw = clk_hw_register_mux_table(dev, name, parent_names, num_parents,
flags, reg, shift, mask, clk_mux_flags,
table, lock);
if (IS_ERR(hw))
return ERR_CAST(hw);
return hw->clk;
} }
EXPORT_SYMBOL_GPL(clk_register_mux_table); EXPORT_SYMBOL_GPL(clk_register_mux_table);
...@@ -180,6 +200,20 @@ struct clk *clk_register_mux(struct device *dev, const char *name, ...@@ -180,6 +200,20 @@ struct clk *clk_register_mux(struct device *dev, const char *name,
} }
EXPORT_SYMBOL_GPL(clk_register_mux); EXPORT_SYMBOL_GPL(clk_register_mux);
struct clk_hw *clk_hw_register_mux(struct device *dev, const char *name,
const char * const *parent_names, u8 num_parents,
unsigned long flags,
void __iomem *reg, u8 shift, u8 width,
u8 clk_mux_flags, spinlock_t *lock)
{
u32 mask = BIT(width) - 1;
return clk_hw_register_mux_table(dev, name, parent_names, num_parents,
flags, reg, shift, mask, clk_mux_flags,
NULL, lock);
}
EXPORT_SYMBOL_GPL(clk_hw_register_mux);
void clk_unregister_mux(struct clk *clk) void clk_unregister_mux(struct clk *clk)
{ {
struct clk_mux *mux; struct clk_mux *mux;
...@@ -195,3 +229,14 @@ void clk_unregister_mux(struct clk *clk) ...@@ -195,3 +229,14 @@ void clk_unregister_mux(struct clk *clk)
kfree(mux); kfree(mux);
} }
EXPORT_SYMBOL_GPL(clk_unregister_mux); EXPORT_SYMBOL_GPL(clk_unregister_mux);
void clk_hw_unregister_mux(struct clk_hw *hw)
{
struct clk_mux *mux;
mux = to_clk_mux(hw);
clk_hw_unregister(hw);
kfree(mux);
}
EXPORT_SYMBOL_GPL(clk_hw_unregister_mux);
...@@ -125,8 +125,7 @@ static void __init nspire_clk_setup(struct device_node *node, ...@@ -125,8 +125,7 @@ static void __init nspire_clk_setup(struct device_node *node,
of_property_read_string(node, "clock-output-names", &clk_name); of_property_read_string(node, "clock-output-names", &clk_name);
clk = clk_register_fixed_rate(NULL, clk_name, NULL, CLK_IS_ROOT, clk = clk_register_fixed_rate(NULL, clk_name, NULL, 0, info.base_clock);
info.base_clock);
if (!IS_ERR(clk)) if (!IS_ERR(clk))
of_clk_add_provider(node, of_clk_src_simple_get, clk); of_clk_add_provider(node, of_clk_src_simple_get, clk);
else else
......
/*
* Copyright (C) 2010 Broadcom
* Copyright (C) 2012 Stephen Warren
* Copyright (C) 2016 Neil Armstrong <narmstrong@baylibre.com>
*
* 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-provider.h>
#include <linux/kernel.h>
#include <linux/module.h>
#include <linux/of.h>
#include <linux/platform_device.h>
#include <linux/stringify.h>
#include <linux/regmap.h>
#include <linux/mfd/syscon.h>
/* Standard regmap gate clocks */
struct clk_oxnas {
struct clk_hw hw;
signed char bit;
struct regmap *regmap;
};
/* Regmap offsets */
#define CLK_STAT_REGOFFSET 0x24
#define CLK_SET_REGOFFSET 0x2c
#define CLK_CLR_REGOFFSET 0x30
static inline struct clk_oxnas *to_clk_oxnas(struct clk_hw *hw)
{
return container_of(hw, struct clk_oxnas, hw);
}
static int oxnas_clk_is_enabled(struct clk_hw *hw)
{
struct clk_oxnas *std = to_clk_oxnas(hw);
int ret;
unsigned int val;
ret = regmap_read(std->regmap, CLK_STAT_REGOFFSET, &val);
if (ret < 0)
return ret;
return val & BIT(std->bit);
}
static int oxnas_clk_enable(struct clk_hw *hw)
{
struct clk_oxnas *std = to_clk_oxnas(hw);
regmap_write(std->regmap, CLK_SET_REGOFFSET, BIT(std->bit));
return 0;
}
static void oxnas_clk_disable(struct clk_hw *hw)
{
struct clk_oxnas *std = to_clk_oxnas(hw);
regmap_write(std->regmap, CLK_CLR_REGOFFSET, BIT(std->bit));
}
static const struct clk_ops oxnas_clk_ops = {
.enable = oxnas_clk_enable,
.disable = oxnas_clk_disable,
.is_enabled = oxnas_clk_is_enabled,
};
static const char *const oxnas_clk_parents[] = {
"oscillator",
};
static const char *const eth_parents[] = {
"gmacclk",
};
#define DECLARE_STD_CLKP(__clk, __parent) \
static const struct clk_init_data clk_##__clk##_init = { \
.name = __stringify(__clk), \
.ops = &oxnas_clk_ops, \
.parent_names = __parent, \
.num_parents = ARRAY_SIZE(__parent), \
}
#define DECLARE_STD_CLK(__clk) DECLARE_STD_CLKP(__clk, oxnas_clk_parents)
/* Hardware Bit - Clock association */
struct clk_oxnas_init_data {
unsigned long bit;
const struct clk_init_data *clk_init;
};
/* Clk init data declaration */
DECLARE_STD_CLK(leon);
DECLARE_STD_CLK(dma_sgdma);
DECLARE_STD_CLK(cipher);
DECLARE_STD_CLK(sata);
DECLARE_STD_CLK(audio);
DECLARE_STD_CLK(usbmph);
DECLARE_STD_CLKP(etha, eth_parents);
DECLARE_STD_CLK(pciea);
DECLARE_STD_CLK(nand);
/* Table index is clock indice */
static const struct clk_oxnas_init_data clk_oxnas_init[] = {
[0] = {0, &clk_leon_init},
[1] = {1, &clk_dma_sgdma_init},
[2] = {2, &clk_cipher_init},
/* Skip & Do not touch to DDR clock */
[3] = {4, &clk_sata_init},
[4] = {5, &clk_audio_init},
[5] = {6, &clk_usbmph_init},
[6] = {7, &clk_etha_init},
[7] = {8, &clk_pciea_init},
[8] = {9, &clk_nand_init},
};
struct clk_oxnas_data {
struct clk_oxnas clk_oxnas[ARRAY_SIZE(clk_oxnas_init)];
struct clk_onecell_data onecell_data[ARRAY_SIZE(clk_oxnas_init)];
struct clk *clks[ARRAY_SIZE(clk_oxnas_init)];
};
static int oxnas_stdclk_probe(struct platform_device *pdev)
{
struct device_node *np = pdev->dev.of_node;
struct clk_oxnas_data *clk_oxnas;
struct regmap *regmap;
int i;
clk_oxnas = devm_kzalloc(&pdev->dev, sizeof(*clk_oxnas), GFP_KERNEL);
if (!clk_oxnas)
return -ENOMEM;
regmap = syscon_node_to_regmap(of_get_parent(np));
if (!regmap) {
dev_err(&pdev->dev, "failed to have parent regmap\n");
return -EINVAL;
}
for (i = 0; i < ARRAY_SIZE(clk_oxnas_init); i++) {
struct clk_oxnas *_clk;
_clk = &clk_oxnas->clk_oxnas[i];
_clk->bit = clk_oxnas_init[i].bit;
_clk->hw.init = clk_oxnas_init[i].clk_init;
_clk->regmap = regmap;
clk_oxnas->clks[i] =
devm_clk_register(&pdev->dev, &_clk->hw);
if (WARN_ON(IS_ERR(clk_oxnas->clks[i])))
return PTR_ERR(clk_oxnas->clks[i]);
}
clk_oxnas->onecell_data->clks = clk_oxnas->clks;
clk_oxnas->onecell_data->clk_num = ARRAY_SIZE(clk_oxnas_init);
return of_clk_add_provider(np, of_clk_src_onecell_get,
clk_oxnas->onecell_data);
}
static int oxnas_stdclk_remove(struct platform_device *pdev)
{
of_clk_del_provider(pdev->dev.of_node);
return 0;
}
static const struct of_device_id oxnas_stdclk_dt_ids[] = {
{ .compatible = "oxsemi,ox810se-stdclk" },
{ }
};
MODULE_DEVICE_TABLE(of, oxnas_stdclk_dt_ids);
static struct platform_driver oxnas_stdclk_driver = {
.probe = oxnas_stdclk_probe,
.remove = oxnas_stdclk_remove,
.driver = {
.name = "oxnas-stdclk",
.of_match_table = oxnas_stdclk_dt_ids,
},
};
module_platform_driver(oxnas_stdclk_driver);
...@@ -132,7 +132,7 @@ static const struct palmas_clks_of_match_data palmas_of_clk32kg = { ...@@ -132,7 +132,7 @@ static const struct palmas_clks_of_match_data palmas_of_clk32kg = {
.init = { .init = {
.name = "clk32kg", .name = "clk32kg",
.ops = &palmas_clks_ops, .ops = &palmas_clks_ops,
.flags = CLK_IS_ROOT | CLK_IGNORE_UNUSED, .flags = CLK_IGNORE_UNUSED,
}, },
.desc = { .desc = {
.clk_name = "clk32kg", .clk_name = "clk32kg",
...@@ -148,7 +148,7 @@ static const struct palmas_clks_of_match_data palmas_of_clk32kgaudio = { ...@@ -148,7 +148,7 @@ static const struct palmas_clks_of_match_data palmas_of_clk32kgaudio = {
.init = { .init = {
.name = "clk32kgaudio", .name = "clk32kgaudio",
.ops = &palmas_clks_ops, .ops = &palmas_clks_ops,
.flags = CLK_IS_ROOT | CLK_IGNORE_UNUSED, .flags = CLK_IGNORE_UNUSED,
}, },
.desc = { .desc = {
.clk_name = "clk32kgaudio", .clk_name = "clk32kgaudio",
......
...@@ -869,14 +869,15 @@ static void __init core_mux_init(struct device_node *np) ...@@ -869,14 +869,15 @@ static void __init core_mux_init(struct device_node *np)
} }
} }
static struct clk *sysclk_from_fixed(struct device_node *node, const char *name) static struct clk __init
*sysclk_from_fixed(struct device_node *node, const char *name)
{ {
u32 rate; u32 rate;
if (of_property_read_u32(node, "clock-frequency", &rate)) if (of_property_read_u32(node, "clock-frequency", &rate))
return ERR_PTR(-ENODEV); return ERR_PTR(-ENODEV);
return clk_register_fixed_rate(NULL, name, NULL, CLK_IS_ROOT, rate); return clk_register_fixed_rate(NULL, name, NULL, 0, rate);
} }
static struct clk *sysclk_from_parent(const char *name) static struct clk *sysclk_from_parent(const char *name)
......
...@@ -106,7 +106,6 @@ static int rk808_clkout_probe(struct platform_device *pdev) ...@@ -106,7 +106,6 @@ static int rk808_clkout_probe(struct platform_device *pdev)
if (!clk_table) if (!clk_table)
return -ENOMEM; return -ENOMEM;
init.flags = CLK_IS_ROOT;
init.parent_names = NULL; init.parent_names = NULL;
init.num_parents = 0; init.num_parents = 0;
init.name = "rk808-clkout1"; init.name = "rk808-clkout1";
......
...@@ -4,17 +4,19 @@ ...@@ -4,17 +4,19 @@
#include <linux/init.h> #include <linux/init.h>
#include <linux/io.h> #include <linux/io.h>
static struct clk *out[2]; #define CLK_COUNT 4 /* cpu_clk, sys_clk, usb_clk, sdio_clk */
static struct clk_onecell_data clk_data = { out, 2 }; static struct clk *clks[CLK_COUNT];
static struct clk_onecell_data clk_data = { clks, CLK_COUNT };
#define SYSCLK_CTRL 0x20 #define SYSCLK_DIV 0x20
#define CPUCLK_CTRL 0x24 #define CPUCLK_DIV 0x24
#define LEGACY_DIV 0x3c #define DIV_BYPASS BIT(23)
#define PLL_N(val) (((val) >> 0) & 0x7f) /*** CLKGEN_PLL ***/
#define PLL_K(val) (((val) >> 13) & 0x7) #define extract_pll_n(val) ((val >> 0) & ((1u << 7) - 1))
#define PLL_M(val) (((val) >> 16) & 0x7) #define extract_pll_k(val) ((val >> 13) & ((1u << 3) - 1))
#define DIV_INDEX(val) (((val) >> 8) & 0xf) #define extract_pll_m(val) ((val >> 16) & ((1u << 3) - 1))
#define extract_pll_isel(val) ((val >> 24) & ((1u << 3) - 1))
static void __init make_pll(int idx, const char *parent, void __iomem *base) static void __init make_pll(int idx, const char *parent, void __iomem *base)
{ {
...@@ -22,40 +24,61 @@ static void __init make_pll(int idx, const char *parent, void __iomem *base) ...@@ -22,40 +24,61 @@ static void __init make_pll(int idx, const char *parent, void __iomem *base)
u32 val, mul, div; u32 val, mul, div;
sprintf(name, "pll%d", idx); sprintf(name, "pll%d", idx);
val = readl_relaxed(base + idx*8); val = readl(base + idx * 8);
mul = PLL_N(val) + 1; mul = extract_pll_n(val) + 1;
div = (PLL_M(val) + 1) << PLL_K(val); div = (extract_pll_m(val) + 1) << extract_pll_k(val);
clk_register_fixed_factor(NULL, name, parent, 0, mul, div); clk_register_fixed_factor(NULL, name, parent, 0, mul, div);
if (extract_pll_isel(val) != 1)
panic("%s: input not set to XTAL_IN\n", name);
} }
static int __init get_div(void __iomem *base) static void __init make_cd(int idx, void __iomem *base)
{ {
u8 sysclk_tab[16] = { 2, 4, 3, 3, 3, 3, 3, 3, 4, 4, 4, 4 }; char name[8];
int idx = DIV_INDEX(readl_relaxed(base + LEGACY_DIV)); u32 val, mul, div;
return sysclk_tab[idx]; sprintf(name, "cd%d", idx);
val = readl(base + idx * 8);
mul = 1 << 27;
div = (2 << 27) + val;
clk_register_fixed_factor(NULL, name, "pll2", 0, mul, div);
if (val > 0xf0000000)
panic("%s: unsupported divider %x\n", name, val);
} }
static void __init tango4_clkgen_setup(struct device_node *np) static void __init tango4_clkgen_setup(struct device_node *np)
{ {
int div, ret; struct clk **pp = clk_data.clks;
void __iomem *base = of_iomap(np, 0); void __iomem *base = of_iomap(np, 0);
const char *parent = of_clk_get_parent_name(np, 0); const char *parent = of_clk_get_parent_name(np, 0);
if (!base) if (!base)
panic("%s: invalid address\n", np->full_name); panic("%s: invalid address\n", np->name);
if (readl(base + CPUCLK_DIV) & DIV_BYPASS)
panic("%s: unsupported cpuclk setup\n", np->name);
if (readl(base + SYSCLK_DIV) & DIV_BYPASS)
panic("%s: unsupported sysclk setup\n", np->name);
writel(0x100, base + CPUCLK_DIV); /* disable frequency ramping */
make_pll(0, parent, base); make_pll(0, parent, base);
make_pll(1, parent, base); make_pll(1, parent, base);
make_pll(2, parent, base);
make_cd(2, base + 0x80);
make_cd(6, base + 0x80);
out[0] = clk_register_divider(NULL, "cpuclk", "pll0", 0, pp[0] = clk_register_divider(NULL, "cpu_clk", "pll0", 0,
base + CPUCLK_CTRL, 8, 8, CLK_DIVIDER_ONE_BASED, NULL); base + CPUCLK_DIV, 8, 8, CLK_DIVIDER_ONE_BASED, NULL);
pp[1] = clk_register_fixed_factor(NULL, "sys_clk", "pll1", 0, 1, 4);
pp[2] = clk_register_fixed_factor(NULL, "usb_clk", "cd2", 0, 1, 2);
pp[3] = clk_register_fixed_factor(NULL, "sdio_clk", "cd6", 0, 1, 2);
div = readl_relaxed(base + SYSCLK_CTRL) & BIT(23) ? get_div(base) : 4; if (IS_ERR(pp[0]) || IS_ERR(pp[1]) || IS_ERR(pp[2]) || IS_ERR(pp[3]))
out[1] = clk_register_fixed_factor(NULL, "sysclk", "pll1", 0, 1, div); panic("%s: clk registration failed\n", np->name);
ret = of_clk_add_provider(np, of_clk_src_onecell_get, &clk_data); if (of_clk_add_provider(np, of_clk_src_onecell_get, &clk_data))
if (IS_ERR(out[0]) || IS_ERR(out[1]) || ret < 0) panic("%s: clk provider registration failed\n", np->name);
panic("%s: clk registration failed\n", np->full_name);
} }
CLK_OF_DECLARE(tango4_clkgen, "sigma,tango4-clkgen", tango4_clkgen_setup); CLK_OF_DECLARE(tango4_clkgen, "sigma,tango4-clkgen", tango4_clkgen_setup);
...@@ -74,7 +74,6 @@ static const struct clk_ops twl6040_mcpdm_ops = { ...@@ -74,7 +74,6 @@ static const struct clk_ops twl6040_mcpdm_ops = {
static struct clk_init_data wm831x_clkout_init = { static struct clk_init_data wm831x_clkout_init = {
.name = "mcpdm_fclk", .name = "mcpdm_fclk",
.ops = &twl6040_mcpdm_ops, .ops = &twl6040_mcpdm_ops,
.flags = CLK_IS_ROOT,
}; };
static int twl6040_clk_probe(struct platform_device *pdev) static int twl6040_clk_probe(struct platform_device *pdev)
......
...@@ -58,7 +58,6 @@ static const struct clk_ops wm831x_xtal_ops = { ...@@ -58,7 +58,6 @@ static const struct clk_ops wm831x_xtal_ops = {
static struct clk_init_data wm831x_xtal_init = { static struct clk_init_data wm831x_xtal_init = {
.name = "xtal", .name = "xtal",
.ops = &wm831x_xtal_ops, .ops = &wm831x_xtal_ops,
.flags = CLK_IS_ROOT,
}; };
static const unsigned long wm831x_fll_auto_rates[] = { static const unsigned long wm831x_fll_auto_rates[] = {
......
...@@ -198,7 +198,7 @@ static void xgene_pllclk_init(struct device_node *np, enum xgene_pll_type pll_ty ...@@ -198,7 +198,7 @@ static void xgene_pllclk_init(struct device_node *np, enum xgene_pll_type pll_ty
of_property_read_string(np, "clock-output-names", &clk_name); of_property_read_string(np, "clock-output-names", &clk_name);
clk = xgene_register_clk_pll(NULL, clk = xgene_register_clk_pll(NULL,
clk_name, of_clk_get_parent_name(np, 0), clk_name, of_clk_get_parent_name(np, 0),
CLK_IS_ROOT, reg, 0, pll_type, &clk_lock, 0, reg, 0, pll_type, &clk_lock,
version); version);
if (!IS_ERR(clk)) { if (!IS_ERR(clk)) {
of_clk_add_provider(np, of_clk_src_simple_get, clk); of_clk_add_provider(np, of_clk_src_simple_get, clk);
......
...@@ -574,6 +574,9 @@ static void clk_core_unprepare(struct clk_core *core) ...@@ -574,6 +574,9 @@ static void clk_core_unprepare(struct clk_core *core)
if (WARN_ON(core->prepare_count == 0)) if (WARN_ON(core->prepare_count == 0))
return; return;
if (WARN_ON(core->prepare_count == 1 && core->flags & CLK_IS_CRITICAL))
return;
if (--core->prepare_count > 0) if (--core->prepare_count > 0)
return; return;
...@@ -679,6 +682,9 @@ static void clk_core_disable(struct clk_core *core) ...@@ -679,6 +682,9 @@ static void clk_core_disable(struct clk_core *core)
if (WARN_ON(core->enable_count == 0)) if (WARN_ON(core->enable_count == 0))
return; return;
if (WARN_ON(core->enable_count == 1 && core->flags & CLK_IS_CRITICAL))
return;
if (--core->enable_count > 0) if (--core->enable_count > 0)
return; return;
...@@ -2397,6 +2403,16 @@ static int __clk_core_init(struct clk_core *core) ...@@ -2397,6 +2403,16 @@ static int __clk_core_init(struct clk_core *core)
if (core->ops->init) if (core->ops->init)
core->ops->init(core->hw); core->ops->init(core->hw);
if (core->flags & CLK_IS_CRITICAL) {
unsigned long flags;
clk_core_prepare(core);
flags = clk_enable_lock();
clk_core_enable(core);
clk_enable_unlock(flags);
}
kref_init(&core->ref); kref_init(&core->ref);
out: out:
clk_prepare_unlock(); clk_prepare_unlock();
...@@ -2536,6 +2552,22 @@ struct clk *clk_register(struct device *dev, struct clk_hw *hw) ...@@ -2536,6 +2552,22 @@ struct clk *clk_register(struct device *dev, struct clk_hw *hw)
} }
EXPORT_SYMBOL_GPL(clk_register); EXPORT_SYMBOL_GPL(clk_register);
/**
* clk_hw_register - register a clk_hw and return an error code
* @dev: device that is registering this clock
* @hw: link to hardware-specific clock data
*
* clk_hw_register is the primary interface for populating the clock tree with
* new clock nodes. It returns an integer equal to zero indicating success or
* less than zero indicating failure. Drivers must test for an error code after
* calling clk_hw_register().
*/
int clk_hw_register(struct device *dev, struct clk_hw *hw)
{
return PTR_ERR_OR_ZERO(clk_register(dev, hw));
}
EXPORT_SYMBOL_GPL(clk_hw_register);
/* Free memory allocated for a clock. */ /* Free memory allocated for a clock. */
static void __clk_release(struct kref *ref) static void __clk_release(struct kref *ref)
{ {
...@@ -2637,11 +2669,26 @@ void clk_unregister(struct clk *clk) ...@@ -2637,11 +2669,26 @@ void clk_unregister(struct clk *clk)
} }
EXPORT_SYMBOL_GPL(clk_unregister); EXPORT_SYMBOL_GPL(clk_unregister);
/**
* clk_hw_unregister - unregister a currently registered clk_hw
* @hw: hardware-specific clock data to unregister
*/
void clk_hw_unregister(struct clk_hw *hw)
{
clk_unregister(hw->clk);
}
EXPORT_SYMBOL_GPL(clk_hw_unregister);
static void devm_clk_release(struct device *dev, void *res) static void devm_clk_release(struct device *dev, void *res)
{ {
clk_unregister(*(struct clk **)res); clk_unregister(*(struct clk **)res);
} }
static void devm_clk_hw_release(struct device *dev, void *res)
{
clk_hw_unregister(*(struct clk_hw **)res);
}
/** /**
* devm_clk_register - resource managed clk_register() * devm_clk_register - resource managed clk_register()
* @dev: device that is registering this clock * @dev: device that is registering this clock
...@@ -2672,6 +2719,36 @@ struct clk *devm_clk_register(struct device *dev, struct clk_hw *hw) ...@@ -2672,6 +2719,36 @@ struct clk *devm_clk_register(struct device *dev, struct clk_hw *hw)
} }
EXPORT_SYMBOL_GPL(devm_clk_register); EXPORT_SYMBOL_GPL(devm_clk_register);
/**
* devm_clk_hw_register - resource managed clk_hw_register()
* @dev: device that is registering this clock
* @hw: link to hardware-specific clock data
*
* Managed clk_hw_register(). Clocks registered by this function are
* automatically clk_hw_unregister()ed on driver detach. See clk_hw_register()
* for more information.
*/
int devm_clk_hw_register(struct device *dev, struct clk_hw *hw)
{
struct clk_hw **hwp;
int ret;
hwp = devres_alloc(devm_clk_hw_release, sizeof(*hwp), GFP_KERNEL);
if (!hwp)
return -ENOMEM;
ret = clk_hw_register(dev, hw);
if (!ret) {
*hwp = hw;
devres_add(dev, hwp);
} else {
devres_free(hwp);
}
return ret;
}
EXPORT_SYMBOL_GPL(devm_clk_hw_register);
static int devm_clk_match(struct device *dev, void *res, void *data) static int devm_clk_match(struct device *dev, void *res, void *data)
{ {
struct clk *c = res; struct clk *c = res;
...@@ -2680,6 +2757,15 @@ static int devm_clk_match(struct device *dev, void *res, void *data) ...@@ -2680,6 +2757,15 @@ static int devm_clk_match(struct device *dev, void *res, void *data)
return c == data; return c == data;
} }
static int devm_clk_hw_match(struct device *dev, void *res, void *data)
{
struct clk_hw *hw = res;
if (WARN_ON(!hw))
return 0;
return hw == data;
}
/** /**
* devm_clk_unregister - resource managed clk_unregister() * devm_clk_unregister - resource managed clk_unregister()
* @clk: clock to unregister * @clk: clock to unregister
...@@ -2694,6 +2780,22 @@ void devm_clk_unregister(struct device *dev, struct clk *clk) ...@@ -2694,6 +2780,22 @@ void devm_clk_unregister(struct device *dev, struct clk *clk)
} }
EXPORT_SYMBOL_GPL(devm_clk_unregister); EXPORT_SYMBOL_GPL(devm_clk_unregister);
/**
* devm_clk_hw_unregister - resource managed clk_hw_unregister()
* @dev: device that is unregistering the hardware-specific clock data
* @hw: link to hardware-specific clock data
*
* Unregister a clk_hw registered with devm_clk_hw_register(). Normally
* this function will not need to be called and the resource management
* code will ensure that the resource is freed.
*/
void devm_clk_hw_unregister(struct device *dev, struct clk_hw *hw)
{
WARN_ON(devres_release(dev, devm_clk_hw_release, devm_clk_hw_match,
hw));
}
EXPORT_SYMBOL_GPL(devm_clk_hw_unregister);
/* /*
* clkdev helpers * clkdev helpers
*/ */
...@@ -2855,6 +2957,7 @@ struct of_clk_provider { ...@@ -2855,6 +2957,7 @@ struct of_clk_provider {
struct device_node *node; struct device_node *node;
struct clk *(*get)(struct of_phandle_args *clkspec, void *data); struct clk *(*get)(struct of_phandle_args *clkspec, void *data);
struct clk_hw *(*get_hw)(struct of_phandle_args *clkspec, void *data);
void *data; void *data;
}; };
...@@ -2871,6 +2974,12 @@ struct clk *of_clk_src_simple_get(struct of_phandle_args *clkspec, ...@@ -2871,6 +2974,12 @@ struct clk *of_clk_src_simple_get(struct of_phandle_args *clkspec,
} }
EXPORT_SYMBOL_GPL(of_clk_src_simple_get); EXPORT_SYMBOL_GPL(of_clk_src_simple_get);
struct clk_hw *of_clk_hw_simple_get(struct of_phandle_args *clkspec, void *data)
{
return data;
}
EXPORT_SYMBOL_GPL(of_clk_hw_simple_get);
struct clk *of_clk_src_onecell_get(struct of_phandle_args *clkspec, void *data) struct clk *of_clk_src_onecell_get(struct of_phandle_args *clkspec, void *data)
{ {
struct clk_onecell_data *clk_data = data; struct clk_onecell_data *clk_data = data;
...@@ -2885,6 +2994,21 @@ struct clk *of_clk_src_onecell_get(struct of_phandle_args *clkspec, void *data) ...@@ -2885,6 +2994,21 @@ struct clk *of_clk_src_onecell_get(struct of_phandle_args *clkspec, void *data)
} }
EXPORT_SYMBOL_GPL(of_clk_src_onecell_get); EXPORT_SYMBOL_GPL(of_clk_src_onecell_get);
struct clk_hw *
of_clk_hw_onecell_get(struct of_phandle_args *clkspec, void *data)
{
struct clk_hw_onecell_data *hw_data = data;
unsigned int idx = clkspec->args[0];
if (idx >= hw_data->num) {
pr_err("%s: invalid index %u\n", __func__, idx);
return ERR_PTR(-EINVAL);
}
return hw_data->hws[idx];
}
EXPORT_SYMBOL_GPL(of_clk_hw_onecell_get);
/** /**
* of_clk_add_provider() - Register a clock provider for a node * of_clk_add_provider() - Register a clock provider for a node
* @np: Device node pointer associated with clock provider * @np: Device node pointer associated with clock provider
...@@ -2920,6 +3044,41 @@ int of_clk_add_provider(struct device_node *np, ...@@ -2920,6 +3044,41 @@ int of_clk_add_provider(struct device_node *np,
} }
EXPORT_SYMBOL_GPL(of_clk_add_provider); EXPORT_SYMBOL_GPL(of_clk_add_provider);
/**
* of_clk_add_hw_provider() - Register a clock provider for a node
* @np: Device node pointer associated with clock provider
* @get: callback for decoding clk_hw
* @data: context pointer for @get callback.
*/
int of_clk_add_hw_provider(struct device_node *np,
struct clk_hw *(*get)(struct of_phandle_args *clkspec,
void *data),
void *data)
{
struct of_clk_provider *cp;
int ret;
cp = kzalloc(sizeof(*cp), GFP_KERNEL);
if (!cp)
return -ENOMEM;
cp->node = of_node_get(np);
cp->data = data;
cp->get_hw = get;
mutex_lock(&of_clk_mutex);
list_add(&cp->link, &of_clk_providers);
mutex_unlock(&of_clk_mutex);
pr_debug("Added clk_hw provider from %s\n", np->full_name);
ret = of_clk_set_defaults(np, true);
if (ret < 0)
of_clk_del_provider(np);
return ret;
}
EXPORT_SYMBOL_GPL(of_clk_add_hw_provider);
/** /**
* of_clk_del_provider() - Remove a previously registered clock provider * of_clk_del_provider() - Remove a previously registered clock provider
* @np: Device node pointer associated with clock provider * @np: Device node pointer associated with clock provider
...@@ -2941,11 +3100,32 @@ void of_clk_del_provider(struct device_node *np) ...@@ -2941,11 +3100,32 @@ void of_clk_del_provider(struct device_node *np)
} }
EXPORT_SYMBOL_GPL(of_clk_del_provider); EXPORT_SYMBOL_GPL(of_clk_del_provider);
static struct clk_hw *
__of_clk_get_hw_from_provider(struct of_clk_provider *provider,
struct of_phandle_args *clkspec)
{
struct clk *clk;
struct clk_hw *hw = ERR_PTR(-EPROBE_DEFER);
if (provider->get_hw) {
hw = provider->get_hw(clkspec, provider->data);
} else if (provider->get) {
clk = provider->get(clkspec, provider->data);
if (!IS_ERR(clk))
hw = __clk_get_hw(clk);
else
hw = ERR_CAST(clk);
}
return hw;
}
struct clk *__of_clk_get_from_provider(struct of_phandle_args *clkspec, struct clk *__of_clk_get_from_provider(struct of_phandle_args *clkspec,
const char *dev_id, const char *con_id) const char *dev_id, const char *con_id)
{ {
struct of_clk_provider *provider; struct of_clk_provider *provider;
struct clk *clk = ERR_PTR(-EPROBE_DEFER); struct clk *clk = ERR_PTR(-EPROBE_DEFER);
struct clk_hw *hw = ERR_PTR(-EPROBE_DEFER);
if (!clkspec) if (!clkspec)
return ERR_PTR(-EINVAL); return ERR_PTR(-EINVAL);
...@@ -2954,10 +3134,9 @@ struct clk *__of_clk_get_from_provider(struct of_phandle_args *clkspec, ...@@ -2954,10 +3134,9 @@ struct clk *__of_clk_get_from_provider(struct of_phandle_args *clkspec,
mutex_lock(&of_clk_mutex); mutex_lock(&of_clk_mutex);
list_for_each_entry(provider, &of_clk_providers, link) { list_for_each_entry(provider, &of_clk_providers, link) {
if (provider->node == clkspec->np) if (provider->node == clkspec->np)
clk = provider->get(clkspec, provider->data); hw = __of_clk_get_hw_from_provider(provider, clkspec);
if (!IS_ERR(clk)) { if (!IS_ERR(hw)) {
clk = __clk_create_clk(__clk_get_hw(clk), dev_id, clk = __clk_create_clk(hw, dev_id, con_id);
con_id);
if (!IS_ERR(clk) && !__clk_get(clk)) { if (!IS_ERR(clk) && !__clk_get(clk)) {
__clk_free_clk(clk); __clk_free_clk(clk);
...@@ -3126,6 +3305,41 @@ static int parent_ready(struct device_node *np) ...@@ -3126,6 +3305,41 @@ static int parent_ready(struct device_node *np)
} }
} }
/**
* of_clk_detect_critical() - set CLK_IS_CRITICAL flag from Device Tree
* @np: Device node pointer associated with clock provider
* @index: clock index
* @flags: pointer to clk_core->flags
*
* Detects if the clock-critical property exists and, if so, sets the
* corresponding CLK_IS_CRITICAL flag.
*
* Do not use this function. It exists only for legacy Device Tree
* bindings, such as the one-clock-per-node style that are outdated.
* Those bindings typically put all clock data into .dts and the Linux
* driver has no clock data, thus making it impossible to set this flag
* correctly from the driver. Only those drivers may call
* of_clk_detect_critical from their setup functions.
*
* Return: error code or zero on success
*/
int of_clk_detect_critical(struct device_node *np,
int index, unsigned long *flags)
{
struct property *prop;
const __be32 *cur;
uint32_t idx;
if (!np || !flags)
return -EINVAL;
of_property_for_each_u32(np, "clock-critical", prop, cur, idx)
if (index == idx)
*flags |= CLK_IS_CRITICAL;
return 0;
}
/** /**
* of_clk_init() - Scan and init clock providers from the DT * of_clk_init() - Scan and init clock providers from the DT
* @matches: array of compatible values and init functions for providers. * @matches: array of compatible values and init functions for providers.
......
...@@ -301,6 +301,20 @@ clkdev_alloc(struct clk *clk, const char *con_id, const char *dev_fmt, ...) ...@@ -301,6 +301,20 @@ clkdev_alloc(struct clk *clk, const char *con_id, const char *dev_fmt, ...)
} }
EXPORT_SYMBOL(clkdev_alloc); EXPORT_SYMBOL(clkdev_alloc);
struct clk_lookup *
clkdev_hw_alloc(struct clk_hw *hw, const char *con_id, const char *dev_fmt, ...)
{
struct clk_lookup *cl;
va_list ap;
va_start(ap, dev_fmt);
cl = vclkdev_alloc(hw, con_id, dev_fmt, ap);
va_end(ap);
return cl;
}
EXPORT_SYMBOL(clkdev_hw_alloc);
/** /**
* clkdev_create - allocate and add a clkdev lookup structure * clkdev_create - allocate and add a clkdev lookup structure
* @clk: struct clk to associate with all clk_lookups * @clk: struct clk to associate with all clk_lookups
...@@ -324,6 +338,29 @@ struct clk_lookup *clkdev_create(struct clk *clk, const char *con_id, ...@@ -324,6 +338,29 @@ struct clk_lookup *clkdev_create(struct clk *clk, const char *con_id,
} }
EXPORT_SYMBOL_GPL(clkdev_create); EXPORT_SYMBOL_GPL(clkdev_create);
/**
* clkdev_hw_create - allocate and add a clkdev lookup structure
* @hw: struct clk_hw to associate with all clk_lookups
* @con_id: connection ID string on device
* @dev_fmt: format string describing device name
*
* Returns a clk_lookup structure, which can be later unregistered and
* freed.
*/
struct clk_lookup *clkdev_hw_create(struct clk_hw *hw, const char *con_id,
const char *dev_fmt, ...)
{
struct clk_lookup *cl;
va_list ap;
va_start(ap, dev_fmt);
cl = vclkdev_create(hw, con_id, dev_fmt, ap);
va_end(ap);
return cl;
}
EXPORT_SYMBOL_GPL(clkdev_hw_create);
int clk_add_alias(const char *alias, const char *alias_dev_name, int clk_add_alias(const char *alias, const char *alias_dev_name,
const char *con_id, struct device *dev) const char *con_id, struct device *dev)
{ {
...@@ -404,28 +441,28 @@ int clk_register_clkdev(struct clk *clk, const char *con_id, ...@@ -404,28 +441,28 @@ int clk_register_clkdev(struct clk *clk, const char *con_id,
EXPORT_SYMBOL(clk_register_clkdev); EXPORT_SYMBOL(clk_register_clkdev);
/** /**
* clk_register_clkdevs - register a set of clk_lookup for a struct clk * clk_hw_register_clkdev - register one clock lookup for a struct clk_hw
* @clk: struct clk to associate with all clk_lookups * @hw: struct clk_hw to associate with all clk_lookups
* @cl: array of clk_lookup structures with con_id and dev_id pre-initialized * @con_id: connection ID string on device
* @num: number of clk_lookup structures to register * @dev_id: format string describing device name
* *
* To make things easier for mass registration, we detect error clks * con_id or dev_id may be NULL as a wildcard, just as in the rest of
* from a previous clk_register() call, and return the error code for * clkdev.
* those. This is to permit this function to be called immediately
* after clk_register().
*/ */
int clk_register_clkdevs(struct clk *clk, struct clk_lookup *cl, size_t num) int clk_hw_register_clkdev(struct clk_hw *hw, const char *con_id,
const char *dev_id)
{ {
unsigned i; struct clk_lookup *cl;
if (IS_ERR(clk))
return PTR_ERR(clk);
for (i = 0; i < num; i++, cl++) { /*
cl->clk_hw = __clk_get_hw(clk); * Since dev_id can be NULL, and NULL is handled specially, we must
__clkdev_add(cl); * pass it as either a NULL format string, or with "%s".
} */
if (dev_id)
cl = __clk_register_clkdev(hw, con_id, "%s", dev_id);
else
cl = __clk_register_clkdev(hw, con_id, NULL);
return 0; return cl ? 0 : -ENOMEM;
} }
EXPORT_SYMBOL(clk_register_clkdevs); EXPORT_SYMBOL(clk_hw_register_clkdev);
config COMMON_CLK_HI3519
tristate "Hi3519 Clock Driver"
depends on ARCH_HISI || COMPILE_TEST
select RESET_HISI
default ARCH_HISI
help
Build the clock driver for hi3519.
config COMMON_CLK_HI6220 config COMMON_CLK_HI6220
bool "Hi6220 Clock Driver" bool "Hi6220 Clock Driver"
depends on ARCH_HISI || COMPILE_TEST depends on ARCH_HISI || COMPILE_TEST
...@@ -5,6 +13,13 @@ config COMMON_CLK_HI6220 ...@@ -5,6 +13,13 @@ config COMMON_CLK_HI6220
help help
Build the Hisilicon Hi6220 clock driver based on the common clock framework. Build the Hisilicon Hi6220 clock driver based on the common clock framework.
config RESET_HISI
bool "HiSilicon Reset Controller Driver"
depends on ARCH_HISI || COMPILE_TEST
select RESET_CONTROLLER
help
Build reset controller driver for HiSilicon device chipsets.
config STUB_CLK_HI6220 config STUB_CLK_HI6220
bool "Hi6220 Stub Clock Driver" bool "Hi6220 Stub Clock Driver"
depends on COMMON_CLK_HI6220 && MAILBOX depends on COMMON_CLK_HI6220 && MAILBOX
......
...@@ -7,5 +7,7 @@ obj-y += clk.o clkgate-separated.o clkdivider-hi6220.o ...@@ -7,5 +7,7 @@ obj-y += clk.o clkgate-separated.o clkdivider-hi6220.o
obj-$(CONFIG_ARCH_HI3xxx) += clk-hi3620.o obj-$(CONFIG_ARCH_HI3xxx) += clk-hi3620.o
obj-$(CONFIG_ARCH_HIP04) += clk-hip04.o obj-$(CONFIG_ARCH_HIP04) += clk-hip04.o
obj-$(CONFIG_ARCH_HIX5HD2) += clk-hix5hd2.o obj-$(CONFIG_ARCH_HIX5HD2) += clk-hix5hd2.o
obj-$(CONFIG_COMMON_CLK_HI3519) += clk-hi3519.o
obj-$(CONFIG_COMMON_CLK_HI6220) += clk-hi6220.o obj-$(CONFIG_COMMON_CLK_HI6220) += clk-hi6220.o
obj-$(CONFIG_RESET_HISI) += reset.o
obj-$(CONFIG_STUB_CLK_HI6220) += clk-hi6220-stub.o obj-$(CONFIG_STUB_CLK_HI6220) += clk-hi6220-stub.o
/*
* Hi3519 Clock Driver
*
* Copyright (c) 2015-2016 HiSilicon Technologies Co., Ltd.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* 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 <dt-bindings/clock/hi3519-clock.h>
#include <linux/clk-provider.h>
#include <linux/module.h>
#include <linux/platform_device.h>
#include "clk.h"
#include "reset.h"
#define HI3519_INNER_CLK_OFFSET 64
#define HI3519_FIXED_24M 65
#define HI3519_FIXED_50M 66
#define HI3519_FIXED_75M 67
#define HI3519_FIXED_125M 68
#define HI3519_FIXED_150M 69
#define HI3519_FIXED_200M 70
#define HI3519_FIXED_250M 71
#define HI3519_FIXED_300M 72
#define HI3519_FIXED_400M 73
#define HI3519_FMC_MUX 74
#define HI3519_NR_CLKS 128
static const struct hisi_fixed_rate_clock hi3519_fixed_rate_clks[] = {
{ HI3519_FIXED_24M, "24m", NULL, 0, 24000000, },
{ HI3519_FIXED_50M, "50m", NULL, 0, 50000000, },
{ HI3519_FIXED_75M, "75m", NULL, 0, 75000000, },
{ HI3519_FIXED_125M, "125m", NULL, 0, 125000000, },
{ HI3519_FIXED_150M, "150m", NULL, 0, 150000000, },
{ HI3519_FIXED_200M, "200m", NULL, 0, 200000000, },
{ HI3519_FIXED_250M, "250m", NULL, 0, 250000000, },
{ HI3519_FIXED_300M, "300m", NULL, 0, 300000000, },
{ HI3519_FIXED_400M, "400m", NULL, 0, 400000000, },
};
static const char *const fmc_mux_p[] = {
"24m", "75m", "125m", "150m", "200m", "250m", "300m", "400m", };
static u32 fmc_mux_table[] = {0, 1, 2, 3, 4, 5, 6, 7};
static const struct hisi_mux_clock hi3519_mux_clks[] = {
{ HI3519_FMC_MUX, "fmc_mux", fmc_mux_p, ARRAY_SIZE(fmc_mux_p),
CLK_SET_RATE_PARENT, 0xc0, 2, 3, 0, fmc_mux_table, },
};
static const struct hisi_gate_clock hi3519_gate_clks[] = {
{ HI3519_FMC_CLK, "clk_fmc", "fmc_mux",
CLK_SET_RATE_PARENT, 0xc0, 1, 0, },
{ HI3519_UART0_CLK, "clk_uart0", "24m",
CLK_SET_RATE_PARENT, 0xe4, 20, 0, },
{ HI3519_UART1_CLK, "clk_uart1", "24m",
CLK_SET_RATE_PARENT, 0xe4, 21, 0, },
{ HI3519_UART2_CLK, "clk_uart2", "24m",
CLK_SET_RATE_PARENT, 0xe4, 22, 0, },
{ HI3519_UART3_CLK, "clk_uart3", "24m",
CLK_SET_RATE_PARENT, 0xe4, 23, 0, },
{ HI3519_UART4_CLK, "clk_uart4", "24m",
CLK_SET_RATE_PARENT, 0xe4, 24, 0, },
{ HI3519_SPI0_CLK, "clk_spi0", "50m",
CLK_SET_RATE_PARENT, 0xe4, 16, 0, },
{ HI3519_SPI1_CLK, "clk_spi1", "50m",
CLK_SET_RATE_PARENT, 0xe4, 17, 0, },
{ HI3519_SPI2_CLK, "clk_spi2", "50m",
CLK_SET_RATE_PARENT, 0xe4, 18, 0, },
};
static int hi3519_clk_probe(struct platform_device *pdev)
{
struct device_node *np = pdev->dev.of_node;
struct hisi_clock_data *clk_data;
struct hisi_reset_controller *rstc;
rstc = hisi_reset_init(np);
if (!rstc)
return -ENOMEM;
clk_data = hisi_clk_init(np, HI3519_NR_CLKS);
if (!clk_data) {
hisi_reset_exit(rstc);
return -ENODEV;
}
hisi_clk_register_fixed_rate(hi3519_fixed_rate_clks,
ARRAY_SIZE(hi3519_fixed_rate_clks),
clk_data);
hisi_clk_register_mux(hi3519_mux_clks, ARRAY_SIZE(hi3519_mux_clks),
clk_data);
hisi_clk_register_gate(hi3519_gate_clks,
ARRAY_SIZE(hi3519_gate_clks), clk_data);
return 0;
}
static const struct of_device_id hi3519_clk_match_table[] = {
{ .compatible = "hisilicon,hi3519-crg" },
{ }
};
MODULE_DEVICE_TABLE(of, hi3519_clk_match_table);
static struct platform_driver hi3519_clk_driver = {
.probe = hi3519_clk_probe,
.driver = {
.name = "hi3519-clk",
.of_match_table = hi3519_clk_match_table,
},
};
static int __init hi3519_clk_init(void)
{
return platform_driver_register(&hi3519_clk_driver);
}
core_initcall(hi3519_clk_init);
MODULE_LICENSE("GPL v2");
MODULE_DESCRIPTION("HiSilicon Hi3519 Clock Driver");
...@@ -37,7 +37,7 @@ ...@@ -37,7 +37,7 @@
static DEFINE_SPINLOCK(hisi_clk_lock); static DEFINE_SPINLOCK(hisi_clk_lock);
struct hisi_clock_data __init *hisi_clk_init(struct device_node *np, struct hisi_clock_data *hisi_clk_init(struct device_node *np,
int nr_clks) int nr_clks)
{ {
struct hisi_clock_data *clk_data; struct hisi_clock_data *clk_data;
...@@ -71,8 +71,9 @@ struct hisi_clock_data __init *hisi_clk_init(struct device_node *np, ...@@ -71,8 +71,9 @@ struct hisi_clock_data __init *hisi_clk_init(struct device_node *np,
err: err:
return NULL; return NULL;
} }
EXPORT_SYMBOL_GPL(hisi_clk_init);
void __init hisi_clk_register_fixed_rate(struct hisi_fixed_rate_clock *clks, void hisi_clk_register_fixed_rate(const struct hisi_fixed_rate_clock *clks,
int nums, struct hisi_clock_data *data) int nums, struct hisi_clock_data *data)
{ {
struct clk *clk; struct clk *clk;
...@@ -91,8 +92,9 @@ void __init hisi_clk_register_fixed_rate(struct hisi_fixed_rate_clock *clks, ...@@ -91,8 +92,9 @@ void __init hisi_clk_register_fixed_rate(struct hisi_fixed_rate_clock *clks,
data->clk_data.clks[clks[i].id] = clk; data->clk_data.clks[clks[i].id] = clk;
} }
} }
EXPORT_SYMBOL_GPL(hisi_clk_register_fixed_rate);
void __init hisi_clk_register_fixed_factor(struct hisi_fixed_factor_clock *clks, void hisi_clk_register_fixed_factor(const struct hisi_fixed_factor_clock *clks,
int nums, int nums,
struct hisi_clock_data *data) struct hisi_clock_data *data)
{ {
...@@ -112,8 +114,9 @@ void __init hisi_clk_register_fixed_factor(struct hisi_fixed_factor_clock *clks, ...@@ -112,8 +114,9 @@ void __init hisi_clk_register_fixed_factor(struct hisi_fixed_factor_clock *clks,
data->clk_data.clks[clks[i].id] = clk; data->clk_data.clks[clks[i].id] = clk;
} }
} }
EXPORT_SYMBOL_GPL(hisi_clk_register_fixed_factor);
void __init hisi_clk_register_mux(struct hisi_mux_clock *clks, void hisi_clk_register_mux(const struct hisi_mux_clock *clks,
int nums, struct hisi_clock_data *data) int nums, struct hisi_clock_data *data)
{ {
struct clk *clk; struct clk *clk;
...@@ -141,8 +144,9 @@ void __init hisi_clk_register_mux(struct hisi_mux_clock *clks, ...@@ -141,8 +144,9 @@ void __init hisi_clk_register_mux(struct hisi_mux_clock *clks,
data->clk_data.clks[clks[i].id] = clk; data->clk_data.clks[clks[i].id] = clk;
} }
} }
EXPORT_SYMBOL_GPL(hisi_clk_register_mux);
void __init hisi_clk_register_divider(struct hisi_divider_clock *clks, void hisi_clk_register_divider(const struct hisi_divider_clock *clks,
int nums, struct hisi_clock_data *data) int nums, struct hisi_clock_data *data)
{ {
struct clk *clk; struct clk *clk;
...@@ -170,8 +174,9 @@ void __init hisi_clk_register_divider(struct hisi_divider_clock *clks, ...@@ -170,8 +174,9 @@ void __init hisi_clk_register_divider(struct hisi_divider_clock *clks,
data->clk_data.clks[clks[i].id] = clk; data->clk_data.clks[clks[i].id] = clk;
} }
} }
EXPORT_SYMBOL_GPL(hisi_clk_register_divider);
void __init hisi_clk_register_gate(struct hisi_gate_clock *clks, void hisi_clk_register_gate(const struct hisi_gate_clock *clks,
int nums, struct hisi_clock_data *data) int nums, struct hisi_clock_data *data)
{ {
struct clk *clk; struct clk *clk;
...@@ -198,8 +203,9 @@ void __init hisi_clk_register_gate(struct hisi_gate_clock *clks, ...@@ -198,8 +203,9 @@ void __init hisi_clk_register_gate(struct hisi_gate_clock *clks,
data->clk_data.clks[clks[i].id] = clk; data->clk_data.clks[clks[i].id] = clk;
} }
} }
EXPORT_SYMBOL_GPL(hisi_clk_register_gate);
void __init hisi_clk_register_gate_sep(struct hisi_gate_clock *clks, void hisi_clk_register_gate_sep(const struct hisi_gate_clock *clks,
int nums, struct hisi_clock_data *data) int nums, struct hisi_clock_data *data)
{ {
struct clk *clk; struct clk *clk;
...@@ -226,8 +232,9 @@ void __init hisi_clk_register_gate_sep(struct hisi_gate_clock *clks, ...@@ -226,8 +232,9 @@ void __init hisi_clk_register_gate_sep(struct hisi_gate_clock *clks,
data->clk_data.clks[clks[i].id] = clk; data->clk_data.clks[clks[i].id] = clk;
} }
} }
EXPORT_SYMBOL_GPL(hisi_clk_register_gate_sep);
void __init hi6220_clk_register_divider(struct hi6220_divider_clock *clks, void __init hi6220_clk_register_divider(const struct hi6220_divider_clock *clks,
int nums, struct hisi_clock_data *data) int nums, struct hisi_clock_data *data)
{ {
struct clk *clk; struct clk *clk;
......
...@@ -111,18 +111,18 @@ struct clk *hi6220_register_clkdiv(struct device *dev, const char *name, ...@@ -111,18 +111,18 @@ struct clk *hi6220_register_clkdiv(struct device *dev, const char *name,
u8 shift, u8 width, u32 mask_bit, spinlock_t *lock); u8 shift, u8 width, u32 mask_bit, spinlock_t *lock);
struct hisi_clock_data *hisi_clk_init(struct device_node *, int); struct hisi_clock_data *hisi_clk_init(struct device_node *, int);
void hisi_clk_register_fixed_rate(struct hisi_fixed_rate_clock *, void hisi_clk_register_fixed_rate(const struct hisi_fixed_rate_clock *,
int, struct hisi_clock_data *); int, struct hisi_clock_data *);
void hisi_clk_register_fixed_factor(struct hisi_fixed_factor_clock *, void hisi_clk_register_fixed_factor(const struct hisi_fixed_factor_clock *,
int, struct hisi_clock_data *); int, struct hisi_clock_data *);
void hisi_clk_register_mux(struct hisi_mux_clock *, int, void hisi_clk_register_mux(const struct hisi_mux_clock *, int,
struct hisi_clock_data *); struct hisi_clock_data *);
void hisi_clk_register_divider(struct hisi_divider_clock *, void hisi_clk_register_divider(const struct hisi_divider_clock *,
int, struct hisi_clock_data *); int, struct hisi_clock_data *);
void hisi_clk_register_gate(struct hisi_gate_clock *, void hisi_clk_register_gate(const struct hisi_gate_clock *,
int, struct hisi_clock_data *); int, struct hisi_clock_data *);
void hisi_clk_register_gate_sep(struct hisi_gate_clock *, void hisi_clk_register_gate_sep(const struct hisi_gate_clock *,
int, struct hisi_clock_data *); int, struct hisi_clock_data *);
void hi6220_clk_register_divider(struct hi6220_divider_clock *, void hi6220_clk_register_divider(const struct hi6220_divider_clock *,
int, struct hisi_clock_data *); int, struct hisi_clock_data *);
#endif /* __HISI_CLK_H */ #endif /* __HISI_CLK_H */
/*
* Hisilicon Reset Controller Driver
*
* Copyright (c) 2015-2016 HiSilicon Technologies Co., Ltd.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* 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/io.h>
#include <linux/of_address.h>
#include <linux/reset-controller.h>
#include <linux/slab.h>
#include <linux/spinlock.h>
#include "reset.h"
#define HISI_RESET_BIT_MASK 0x1f
#define HISI_RESET_OFFSET_SHIFT 8
#define HISI_RESET_OFFSET_MASK 0xffff00
struct hisi_reset_controller {
spinlock_t lock;
void __iomem *membase;
struct reset_controller_dev rcdev;
};
#define to_hisi_reset_controller(rcdev) \
container_of(rcdev, struct hisi_reset_controller, rcdev)
static int hisi_reset_of_xlate(struct reset_controller_dev *rcdev,
const struct of_phandle_args *reset_spec)
{
u32 offset;
u8 bit;
offset = (reset_spec->args[0] << HISI_RESET_OFFSET_SHIFT)
& HISI_RESET_OFFSET_MASK;
bit = reset_spec->args[1] & HISI_RESET_BIT_MASK;
return (offset | bit);
}
static int hisi_reset_assert(struct reset_controller_dev *rcdev,
unsigned long id)
{
struct hisi_reset_controller *rstc = to_hisi_reset_controller(rcdev);
unsigned long flags;
u32 offset, reg;
u8 bit;
offset = (id & HISI_RESET_OFFSET_MASK) >> HISI_RESET_OFFSET_SHIFT;
bit = id & HISI_RESET_BIT_MASK;
spin_lock_irqsave(&rstc->lock, flags);
reg = readl(rstc->membase + offset);
writel(reg | BIT(bit), rstc->membase + offset);
spin_unlock_irqrestore(&rstc->lock, flags);
return 0;
}
static int hisi_reset_deassert(struct reset_controller_dev *rcdev,
unsigned long id)
{
struct hisi_reset_controller *rstc = to_hisi_reset_controller(rcdev);
unsigned long flags;
u32 offset, reg;
u8 bit;
offset = (id & HISI_RESET_OFFSET_MASK) >> HISI_RESET_OFFSET_SHIFT;
bit = id & HISI_RESET_BIT_MASK;
spin_lock_irqsave(&rstc->lock, flags);
reg = readl(rstc->membase + offset);
writel(reg & ~BIT(bit), rstc->membase + offset);
spin_unlock_irqrestore(&rstc->lock, flags);
return 0;
}
static const struct reset_control_ops hisi_reset_ops = {
.assert = hisi_reset_assert,
.deassert = hisi_reset_deassert,
};
struct hisi_reset_controller *hisi_reset_init(struct device_node *np)
{
struct hisi_reset_controller *rstc;
rstc = kzalloc(sizeof(*rstc), GFP_KERNEL);
if (!rstc)
return NULL;
rstc->membase = of_iomap(np, 0);
if (!rstc->membase) {
kfree(rstc);
return NULL;
}
spin_lock_init(&rstc->lock);
rstc->rcdev.owner = THIS_MODULE;
rstc->rcdev.ops = &hisi_reset_ops;
rstc->rcdev.of_node = np;
rstc->rcdev.of_reset_n_cells = 2;
rstc->rcdev.of_xlate = hisi_reset_of_xlate;
reset_controller_register(&rstc->rcdev);
return rstc;
}
EXPORT_SYMBOL_GPL(hisi_reset_init);
void hisi_reset_exit(struct hisi_reset_controller *rstc)
{
reset_controller_unregister(&rstc->rcdev);
iounmap(rstc->membase);
kfree(rstc);
}
EXPORT_SYMBOL_GPL(hisi_reset_exit);
/*
* Copyright (c) 2015 HiSilicon Technologies Co., Ltd.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* 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 __HISI_RESET_H
#define __HISI_RESET_H
struct device_node;
struct hisi_reset_controller;
#ifdef CONFIG_RESET_CONTROLLER
struct hisi_reset_controller *hisi_reset_init(struct device_node *np);
void hisi_reset_exit(struct hisi_reset_controller *rstc);
#else
static inline hisi_reset_controller *hisi_reset_init(struct device_node *np)
{
return 0;
}
static inline void hisi_reset_exit(struct hisi_reset_controller *rstc)
{}
#endif
#endif /* __HISI_RESET_H */
...@@ -31,6 +31,7 @@ struct clk_gate2 { ...@@ -31,6 +31,7 @@ struct clk_gate2 {
struct clk_hw hw; struct clk_hw hw;
void __iomem *reg; void __iomem *reg;
u8 bit_idx; u8 bit_idx;
u8 cgr_val;
u8 flags; u8 flags;
spinlock_t *lock; spinlock_t *lock;
unsigned int *share_count; unsigned int *share_count;
...@@ -50,7 +51,8 @@ static int clk_gate2_enable(struct clk_hw *hw) ...@@ -50,7 +51,8 @@ static int clk_gate2_enable(struct clk_hw *hw)
goto out; goto out;
reg = readl(gate->reg); reg = readl(gate->reg);
reg |= 3 << gate->bit_idx; reg &= ~(3 << gate->bit_idx);
reg |= gate->cgr_val << gate->bit_idx;
writel(reg, gate->reg); writel(reg, gate->reg);
out: out:
...@@ -125,7 +127,7 @@ static struct clk_ops clk_gate2_ops = { ...@@ -125,7 +127,7 @@ static struct clk_ops clk_gate2_ops = {
struct clk *clk_register_gate2(struct device *dev, const char *name, struct clk *clk_register_gate2(struct device *dev, const char *name,
const char *parent_name, unsigned long flags, const char *parent_name, unsigned long flags,
void __iomem *reg, u8 bit_idx, void __iomem *reg, u8 bit_idx, u8 cgr_val,
u8 clk_gate2_flags, spinlock_t *lock, u8 clk_gate2_flags, spinlock_t *lock,
unsigned int *share_count) unsigned int *share_count)
{ {
...@@ -140,6 +142,7 @@ struct clk *clk_register_gate2(struct device *dev, const char *name, ...@@ -140,6 +142,7 @@ struct clk *clk_register_gate2(struct device *dev, const char *name,
/* struct clk_gate2 assignments */ /* struct clk_gate2 assignments */
gate->reg = reg; gate->reg = reg;
gate->bit_idx = bit_idx; gate->bit_idx = bit_idx;
gate->cgr_val = cgr_val;
gate->flags = clk_gate2_flags; gate->flags = clk_gate2_flags;
gate->lock = lock; gate->lock = lock;
gate->share_count = share_count; gate->share_count = share_count;
......
...@@ -66,7 +66,7 @@ static const char *std_sel[] = {"ppll", "arm"}; ...@@ -66,7 +66,7 @@ static const char *std_sel[] = {"ppll", "arm"};
static const char *ipg_per_sel[] = {"ahb_per_div", "arm_per_div"}; static const char *ipg_per_sel[] = {"ahb_per_div", "arm_per_div"};
enum mx35_clks { enum mx35_clks {
ckih, ckil, mpll, ppll, mpll_075, arm, hsp, hsp_div, hsp_sel, ahb, ipg, ckih, mpll, ppll, mpll_075, arm, hsp, hsp_div, hsp_sel, ahb, ipg,
arm_per_div, ahb_per_div, ipg_per, uart_sel, uart_div, esdhc_sel, arm_per_div, ahb_per_div, ipg_per, uart_sel, uart_div, esdhc_sel,
esdhc1_div, esdhc2_div, esdhc3_div, spdif_sel, spdif_div_pre, esdhc1_div, esdhc2_div, esdhc3_div, spdif_sel, spdif_div_pre,
spdif_div_post, ssi_sel, ssi1_div_pre, ssi1_div_post, ssi2_div_pre, spdif_div_post, ssi_sel, ssi1_div_pre, ssi1_div_post, ssi2_div_pre,
...@@ -79,7 +79,7 @@ enum mx35_clks { ...@@ -79,7 +79,7 @@ enum mx35_clks {
rtc_gate, rtic_gate, scc_gate, sdma_gate, spba_gate, spdif_gate, rtc_gate, rtic_gate, scc_gate, sdma_gate, spba_gate, spdif_gate,
ssi1_gate, ssi2_gate, uart1_gate, uart2_gate, uart3_gate, usbotg_gate, ssi1_gate, ssi2_gate, uart1_gate, uart2_gate, uart3_gate, usbotg_gate,
wdog_gate, max_gate, admux_gate, csi_gate, csi_div, csi_sel, iim_gate, wdog_gate, max_gate, admux_gate, csi_gate, csi_div, csi_sel, iim_gate,
gpu2d_gate, clk_max gpu2d_gate, ckil, clk_max
}; };
static struct clk *clk[clk_max]; static struct clk *clk[clk_max];
......
...@@ -134,6 +134,8 @@ static u32 share_count_esai; ...@@ -134,6 +134,8 @@ static u32 share_count_esai;
static u32 share_count_ssi1; static u32 share_count_ssi1;
static u32 share_count_ssi2; static u32 share_count_ssi2;
static u32 share_count_ssi3; static u32 share_count_ssi3;
static u32 share_count_sai1;
static u32 share_count_sai2;
static struct clk ** const uart_clks[] __initconst = { static struct clk ** const uart_clks[] __initconst = {
&clks[IMX6SX_CLK_UART_IPG], &clks[IMX6SX_CLK_UART_IPG],
...@@ -469,10 +471,10 @@ static void __init imx6sx_clocks_init(struct device_node *ccm_node) ...@@ -469,10 +471,10 @@ static void __init imx6sx_clocks_init(struct device_node *ccm_node)
clks[IMX6SX_CLK_SSI3] = imx_clk_gate2_shared("ssi3", "ssi3_podf", base + 0x7c, 22, &share_count_ssi3); clks[IMX6SX_CLK_SSI3] = imx_clk_gate2_shared("ssi3", "ssi3_podf", base + 0x7c, 22, &share_count_ssi3);
clks[IMX6SX_CLK_UART_IPG] = imx_clk_gate2("uart_ipg", "ipg", base + 0x7c, 24); clks[IMX6SX_CLK_UART_IPG] = imx_clk_gate2("uart_ipg", "ipg", base + 0x7c, 24);
clks[IMX6SX_CLK_UART_SERIAL] = imx_clk_gate2("uart_serial", "uart_podf", base + 0x7c, 26); clks[IMX6SX_CLK_UART_SERIAL] = imx_clk_gate2("uart_serial", "uart_podf", base + 0x7c, 26);
clks[IMX6SX_CLK_SAI1_IPG] = imx_clk_gate2("sai1_ipg", "ipg", base + 0x7c, 28); clks[IMX6SX_CLK_SAI1_IPG] = imx_clk_gate2_shared("sai1_ipg", "ipg", base + 0x7c, 28, &share_count_sai1);
clks[IMX6SX_CLK_SAI2_IPG] = imx_clk_gate2("sai2_ipg", "ipg", base + 0x7c, 30); clks[IMX6SX_CLK_SAI2_IPG] = imx_clk_gate2_shared("sai2_ipg", "ipg", base + 0x7c, 30, &share_count_sai2);
clks[IMX6SX_CLK_SAI1] = imx_clk_gate2("sai1", "ssi1_podf", base + 0x7c, 28); clks[IMX6SX_CLK_SAI1] = imx_clk_gate2_shared("sai1", "ssi1_podf", base + 0x7c, 28, &share_count_sai1);
clks[IMX6SX_CLK_SAI2] = imx_clk_gate2("sai2", "ssi2_podf", base + 0x7c, 30); clks[IMX6SX_CLK_SAI2] = imx_clk_gate2_shared("sai2", "ssi2_podf", base + 0x7c, 30, &share_count_sai2);
/* CCGR6 */ /* CCGR6 */
clks[IMX6SX_CLK_USBOH3] = imx_clk_gate2("usboh3", "ipg", base + 0x80, 0); clks[IMX6SX_CLK_USBOH3] = imx_clk_gate2("usboh3", "ipg", base + 0x80, 0);
......
...@@ -56,7 +56,7 @@ static const char *nand_usdhc_bus_sel[] = { "osc", "pll_sys_pfd2_270m_clk", ...@@ -56,7 +56,7 @@ static const char *nand_usdhc_bus_sel[] = { "osc", "pll_sys_pfd2_270m_clk",
"pll_sys_pfd2_135m_clk", "pll_sys_pfd6_clk", "pll_enet_250m_clk", "pll_sys_pfd2_135m_clk", "pll_sys_pfd6_clk", "pll_enet_250m_clk",
"pll_audio_main_clk", }; "pll_audio_main_clk", };
static const char *ahb_channel_sel[] = { "osc", "pll_sys_pfd2_135m_clk", static const char *ahb_channel_sel[] = { "osc", "pll_sys_pfd2_270m_clk",
"pll_dram_533m_clk", "pll_sys_pfd0_392m_clk", "pll_dram_533m_clk", "pll_sys_pfd0_392m_clk",
"pll_enet_125m_clk", "pll_usb_main_clk", "pll_audio_main_clk", "pll_enet_125m_clk", "pll_usb_main_clk", "pll_audio_main_clk",
"pll_video_main_clk", }; "pll_video_main_clk", };
...@@ -342,7 +342,7 @@ static const char *clko1_sel[] = { "osc", "pll_sys_main_clk", ...@@ -342,7 +342,7 @@ static const char *clko1_sel[] = { "osc", "pll_sys_main_clk",
static const char *clko2_sel[] = { "osc", "pll_sys_main_240m_clk", static const char *clko2_sel[] = { "osc", "pll_sys_main_240m_clk",
"pll_sys_pfd0_392m_clk", "pll_sys_pfd1_166m_clk", "pll_sys_pfd4_clk", "pll_sys_pfd0_392m_clk", "pll_sys_pfd1_166m_clk", "pll_sys_pfd4_clk",
"pll_audio_main_clk", "pll_video_main_clk", "osc_32k_clk", }; "pll_audio_main_clk", "pll_video_main_clk", "ckil", };
static const char *lvds1_sel[] = { "pll_arm_main_clk", static const char *lvds1_sel[] = { "pll_arm_main_clk",
"pll_sys_main_clk", "pll_sys_pfd0_392m_clk", "pll_sys_pfd1_332m_clk", "pll_sys_main_clk", "pll_sys_pfd0_392m_clk", "pll_sys_pfd1_332m_clk",
...@@ -382,6 +382,7 @@ static void __init imx7d_clocks_init(struct device_node *ccm_node) ...@@ -382,6 +382,7 @@ static void __init imx7d_clocks_init(struct device_node *ccm_node)
clks[IMX7D_CLK_DUMMY] = imx_clk_fixed("dummy", 0); clks[IMX7D_CLK_DUMMY] = imx_clk_fixed("dummy", 0);
clks[IMX7D_OSC_24M_CLK] = of_clk_get_by_name(ccm_node, "osc"); clks[IMX7D_OSC_24M_CLK] = of_clk_get_by_name(ccm_node, "osc");
clks[IMX7D_CKIL] = of_clk_get_by_name(ccm_node, "ckil");
np = of_find_compatible_node(NULL, NULL, "fsl,imx7d-anatop"); np = of_find_compatible_node(NULL, NULL, "fsl,imx7d-anatop");
base = of_iomap(np, 0); base = of_iomap(np, 0);
......
...@@ -44,6 +44,7 @@ struct clk_pllv3 { ...@@ -44,6 +44,7 @@ struct clk_pllv3 {
u32 powerdown; u32 powerdown;
u32 div_mask; u32 div_mask;
u32 div_shift; u32 div_shift;
unsigned long ref_clock;
}; };
#define to_clk_pllv3(_hw) container_of(_hw, struct clk_pllv3, hw) #define to_clk_pllv3(_hw) container_of(_hw, struct clk_pllv3, hw)
...@@ -286,7 +287,9 @@ static const struct clk_ops clk_pllv3_av_ops = { ...@@ -286,7 +287,9 @@ static const struct clk_ops clk_pllv3_av_ops = {
static unsigned long clk_pllv3_enet_recalc_rate(struct clk_hw *hw, static unsigned long clk_pllv3_enet_recalc_rate(struct clk_hw *hw,
unsigned long parent_rate) unsigned long parent_rate)
{ {
return 500000000; struct clk_pllv3 *pll = to_clk_pllv3(hw);
return pll->ref_clock;
} }
static const struct clk_ops clk_pllv3_enet_ops = { static const struct clk_ops clk_pllv3_enet_ops = {
...@@ -326,7 +329,11 @@ struct clk *imx_clk_pllv3(enum imx_pllv3_type type, const char *name, ...@@ -326,7 +329,11 @@ struct clk *imx_clk_pllv3(enum imx_pllv3_type type, const char *name,
break; break;
case IMX_PLLV3_ENET_IMX7: case IMX_PLLV3_ENET_IMX7:
pll->powerdown = IMX7_ENET_PLL_POWER; pll->powerdown = IMX7_ENET_PLL_POWER;
pll->ref_clock = 1000000000;
ops = &clk_pllv3_enet_ops;
break;
case IMX_PLLV3_ENET: case IMX_PLLV3_ENET:
pll->ref_clock = 500000000;
ops = &clk_pllv3_enet_ops; ops = &clk_pllv3_enet_ops;
break; break;
default: default:
......
...@@ -10,6 +10,7 @@ ...@@ -10,6 +10,7 @@
#include <linux/of_address.h> #include <linux/of_address.h>
#include <linux/clk.h> #include <linux/clk.h>
#include <linux/syscore_ops.h>
#include <dt-bindings/clock/vf610-clock.h> #include <dt-bindings/clock/vf610-clock.h>
#include "clk.h" #include "clk.h"
...@@ -40,6 +41,7 @@ ...@@ -40,6 +41,7 @@
#define CCM_CCGR9 (ccm_base + 0x64) #define CCM_CCGR9 (ccm_base + 0x64)
#define CCM_CCGR10 (ccm_base + 0x68) #define CCM_CCGR10 (ccm_base + 0x68)
#define CCM_CCGR11 (ccm_base + 0x6c) #define CCM_CCGR11 (ccm_base + 0x6c)
#define CCM_CCGRx(x) (CCM_CCGR0 + (x) * 4)
#define CCM_CMEOR0 (ccm_base + 0x70) #define CCM_CMEOR0 (ccm_base + 0x70)
#define CCM_CMEOR1 (ccm_base + 0x74) #define CCM_CMEOR1 (ccm_base + 0x74)
#define CCM_CMEOR2 (ccm_base + 0x78) #define CCM_CMEOR2 (ccm_base + 0x78)
...@@ -115,10 +117,19 @@ static struct clk_div_table pll4_audio_div_table[] = { ...@@ -115,10 +117,19 @@ static struct clk_div_table pll4_audio_div_table[] = {
static struct clk *clk[VF610_CLK_END]; static struct clk *clk[VF610_CLK_END];
static struct clk_onecell_data clk_data; static struct clk_onecell_data clk_data;
static u32 cscmr1;
static u32 cscmr2;
static u32 cscdr1;
static u32 cscdr2;
static u32 cscdr3;
static u32 ccgr[12];
static unsigned int const clks_init_on[] __initconst = { static unsigned int const clks_init_on[] __initconst = {
VF610_CLK_SYS_BUS, VF610_CLK_SYS_BUS,
VF610_CLK_DDR_SEL, VF610_CLK_DDR_SEL,
VF610_CLK_DAP, VF610_CLK_DAP,
VF610_CLK_DDRMC,
VF610_CLK_WKPU,
}; };
static struct clk * __init vf610_get_fixed_clock( static struct clk * __init vf610_get_fixed_clock(
...@@ -132,6 +143,43 @@ static struct clk * __init vf610_get_fixed_clock( ...@@ -132,6 +143,43 @@ static struct clk * __init vf610_get_fixed_clock(
return clk; return clk;
}; };
static int vf610_clk_suspend(void)
{
int i;
cscmr1 = readl_relaxed(CCM_CSCMR1);
cscmr2 = readl_relaxed(CCM_CSCMR2);
cscdr1 = readl_relaxed(CCM_CSCDR1);
cscdr2 = readl_relaxed(CCM_CSCDR2);
cscdr3 = readl_relaxed(CCM_CSCDR3);
for (i = 0; i < 12; i++)
ccgr[i] = readl_relaxed(CCM_CCGRx(i));
return 0;
}
static void vf610_clk_resume(void)
{
int i;
writel_relaxed(cscmr1, CCM_CSCMR1);
writel_relaxed(cscmr2, CCM_CSCMR2);
writel_relaxed(cscdr1, CCM_CSCDR1);
writel_relaxed(cscdr2, CCM_CSCDR2);
writel_relaxed(cscdr3, CCM_CSCDR3);
for (i = 0; i < 12; i++)
writel_relaxed(ccgr[i], CCM_CCGRx(i));
}
static struct syscore_ops vf610_clk_syscore_ops = {
.suspend = vf610_clk_suspend,
.resume = vf610_clk_resume,
};
static void __init vf610_clocks_init(struct device_node *ccm_node) static void __init vf610_clocks_init(struct device_node *ccm_node)
{ {
struct device_node *np; struct device_node *np;
...@@ -233,6 +281,9 @@ static void __init vf610_clocks_init(struct device_node *ccm_node) ...@@ -233,6 +281,9 @@ static void __init vf610_clocks_init(struct device_node *ccm_node)
clk[VF610_CLK_PLL4_MAIN_DIV] = clk_register_divider_table(NULL, "pll4_audio_div", "pll4_audio", 0, CCM_CACRR, 6, 3, 0, pll4_audio_div_table, &imx_ccm_lock); clk[VF610_CLK_PLL4_MAIN_DIV] = clk_register_divider_table(NULL, "pll4_audio_div", "pll4_audio", 0, CCM_CACRR, 6, 3, 0, pll4_audio_div_table, &imx_ccm_lock);
clk[VF610_CLK_PLL6_MAIN_DIV] = imx_clk_divider("pll6_video_div", "pll6_video", CCM_CACRR, 21, 1); clk[VF610_CLK_PLL6_MAIN_DIV] = imx_clk_divider("pll6_video_div", "pll6_video", CCM_CACRR, 21, 1);
clk[VF610_CLK_DDRMC] = imx_clk_gate2_cgr("ddrmc", "ddr_sel", CCM_CCGR6, CCM_CCGRx_CGn(14), 0x2);
clk[VF610_CLK_WKPU] = imx_clk_gate2_cgr("wkpu", "ipg_bus", CCM_CCGR4, CCM_CCGRx_CGn(10), 0x2);
clk[VF610_CLK_USBPHY0] = imx_clk_gate("usbphy0", "pll3_usb_otg", PLL3_CTRL, 6); clk[VF610_CLK_USBPHY0] = imx_clk_gate("usbphy0", "pll3_usb_otg", PLL3_CTRL, 6);
clk[VF610_CLK_USBPHY1] = imx_clk_gate("usbphy1", "pll7_usb_host", PLL7_CTRL, 6); clk[VF610_CLK_USBPHY1] = imx_clk_gate("usbphy1", "pll7_usb_host", PLL7_CTRL, 6);
...@@ -321,11 +372,14 @@ static void __init vf610_clocks_init(struct device_node *ccm_node) ...@@ -321,11 +372,14 @@ static void __init vf610_clocks_init(struct device_node *ccm_node)
clk[VF610_CLK_DCU0_SEL] = imx_clk_mux("dcu0_sel", CCM_CSCMR1, 28, 1, dcu_sels, 2); clk[VF610_CLK_DCU0_SEL] = imx_clk_mux("dcu0_sel", CCM_CSCMR1, 28, 1, dcu_sels, 2);
clk[VF610_CLK_DCU0_EN] = imx_clk_gate("dcu0_en", "dcu0_sel", CCM_CSCDR3, 19); clk[VF610_CLK_DCU0_EN] = imx_clk_gate("dcu0_en", "dcu0_sel", CCM_CSCDR3, 19);
clk[VF610_CLK_DCU0_DIV] = imx_clk_divider("dcu0_div", "dcu0_en", CCM_CSCDR3, 16, 3); clk[VF610_CLK_DCU0_DIV] = imx_clk_divider("dcu0_div", "dcu0_en", CCM_CSCDR3, 16, 3);
clk[VF610_CLK_DCU0] = imx_clk_gate2("dcu0", "dcu0_div", CCM_CCGR3, CCM_CCGRx_CGn(8)); clk[VF610_CLK_DCU0] = imx_clk_gate2("dcu0", "ipg_bus", CCM_CCGR3, CCM_CCGRx_CGn(8));
clk[VF610_CLK_DCU1_SEL] = imx_clk_mux("dcu1_sel", CCM_CSCMR1, 29, 1, dcu_sels, 2); clk[VF610_CLK_DCU1_SEL] = imx_clk_mux("dcu1_sel", CCM_CSCMR1, 29, 1, dcu_sels, 2);
clk[VF610_CLK_DCU1_EN] = imx_clk_gate("dcu1_en", "dcu1_sel", CCM_CSCDR3, 23); clk[VF610_CLK_DCU1_EN] = imx_clk_gate("dcu1_en", "dcu1_sel", CCM_CSCDR3, 23);
clk[VF610_CLK_DCU1_DIV] = imx_clk_divider("dcu1_div", "dcu1_en", CCM_CSCDR3, 20, 3); clk[VF610_CLK_DCU1_DIV] = imx_clk_divider("dcu1_div", "dcu1_en", CCM_CSCDR3, 20, 3);
clk[VF610_CLK_DCU1] = imx_clk_gate2("dcu1", "dcu1_div", CCM_CCGR9, CCM_CCGRx_CGn(8)); clk[VF610_CLK_DCU1] = imx_clk_gate2("dcu1", "ipg_bus", CCM_CCGR9, CCM_CCGRx_CGn(8));
clk[VF610_CLK_TCON0] = imx_clk_gate2("tcon0", "platform_bus", CCM_CCGR1, CCM_CCGRx_CGn(13));
clk[VF610_CLK_TCON1] = imx_clk_gate2("tcon1", "platform_bus", CCM_CCGR7, CCM_CCGRx_CGn(13));
clk[VF610_CLK_ESAI_SEL] = imx_clk_mux("esai_sel", CCM_CSCMR1, 20, 2, esai_sels, 4); clk[VF610_CLK_ESAI_SEL] = imx_clk_mux("esai_sel", CCM_CSCMR1, 20, 2, esai_sels, 4);
clk[VF610_CLK_ESAI_EN] = imx_clk_gate("esai_en", "esai_sel", CCM_CSCDR2, 30); clk[VF610_CLK_ESAI_EN] = imx_clk_gate("esai_en", "esai_sel", CCM_CSCDR2, 30);
...@@ -409,6 +463,8 @@ static void __init vf610_clocks_init(struct device_node *ccm_node) ...@@ -409,6 +463,8 @@ static void __init vf610_clocks_init(struct device_node *ccm_node)
for (i = 0; i < ARRAY_SIZE(clks_init_on); i++) for (i = 0; i < ARRAY_SIZE(clks_init_on); i++)
clk_prepare_enable(clk[clks_init_on[i]]); clk_prepare_enable(clk[clks_init_on[i]]);
register_syscore_ops(&vf610_clk_syscore_ops);
/* Add the clocks to provider list */ /* Add the clocks to provider list */
clk_data.clks = clk; clk_data.clks = clk;
clk_data.clk_num = ARRAY_SIZE(clk); clk_data.clk_num = ARRAY_SIZE(clk);
......
...@@ -41,7 +41,7 @@ struct clk *imx_clk_pllv3(enum imx_pllv3_type type, const char *name, ...@@ -41,7 +41,7 @@ struct clk *imx_clk_pllv3(enum imx_pllv3_type type, const char *name,
struct clk *clk_register_gate2(struct device *dev, const char *name, struct clk *clk_register_gate2(struct device *dev, const char *name,
const char *parent_name, unsigned long flags, const char *parent_name, unsigned long flags,
void __iomem *reg, u8 bit_idx, void __iomem *reg, u8 bit_idx, u8 cgr_val,
u8 clk_gate_flags, spinlock_t *lock, u8 clk_gate_flags, spinlock_t *lock,
unsigned int *share_count); unsigned int *share_count);
...@@ -55,7 +55,7 @@ static inline struct clk *imx_clk_gate2(const char *name, const char *parent, ...@@ -55,7 +55,7 @@ static inline struct clk *imx_clk_gate2(const char *name, const char *parent,
void __iomem *reg, u8 shift) void __iomem *reg, u8 shift)
{ {
return clk_register_gate2(NULL, name, parent, CLK_SET_RATE_PARENT, reg, return clk_register_gate2(NULL, name, parent, CLK_SET_RATE_PARENT, reg,
shift, 0, &imx_ccm_lock, NULL); shift, 0x3, 0, &imx_ccm_lock, NULL);
} }
static inline struct clk *imx_clk_gate2_shared(const char *name, static inline struct clk *imx_clk_gate2_shared(const char *name,
...@@ -63,7 +63,14 @@ static inline struct clk *imx_clk_gate2_shared(const char *name, ...@@ -63,7 +63,14 @@ static inline struct clk *imx_clk_gate2_shared(const char *name,
unsigned int *share_count) unsigned int *share_count)
{ {
return clk_register_gate2(NULL, name, parent, CLK_SET_RATE_PARENT, reg, return clk_register_gate2(NULL, name, parent, CLK_SET_RATE_PARENT, reg,
shift, 0, &imx_ccm_lock, share_count); shift, 0x3, 0, &imx_ccm_lock, share_count);
}
static inline struct clk *imx_clk_gate2_cgr(const char *name, const char *parent,
void __iomem *reg, u8 shift, u8 cgr_val)
{
return clk_register_gate2(NULL, name, parent, CLK_SET_RATE_PARENT, reg,
shift, cgr_val, 0, &imx_ccm_lock, NULL);
} }
struct clk *imx_clk_pfd(const char *name, const char *parent_name, struct clk *imx_clk_pfd(const char *name, const char *parent_name,
......
...@@ -325,6 +325,7 @@ ingenic_clk_recalc_rate(struct clk_hw *hw, unsigned long parent_rate) ...@@ -325,6 +325,7 @@ ingenic_clk_recalc_rate(struct clk_hw *hw, unsigned long parent_rate)
div = (div_reg >> clk_info->div.shift) & div = (div_reg >> clk_info->div.shift) &
GENMASK(clk_info->div.bits - 1, 0); GENMASK(clk_info->div.bits - 1, 0);
div += 1; div += 1;
div *= clk_info->div.div;
rate /= div; rate /= div;
} }
...@@ -345,6 +346,14 @@ ingenic_clk_calc_div(const struct ingenic_cgu_clk_info *clk_info, ...@@ -345,6 +346,14 @@ ingenic_clk_calc_div(const struct ingenic_cgu_clk_info *clk_info,
div = min_t(unsigned, div, 1 << clk_info->div.bits); div = min_t(unsigned, div, 1 << clk_info->div.bits);
div = max_t(unsigned, div, 1); div = max_t(unsigned, div, 1);
/*
* If the divider value itself must be divided before being written to
* the divider register, we must ensure we don't have any bits set that
* would be lost as a result of doing so.
*/
div /= clk_info->div.div;
div *= clk_info->div.div;
return div; return div;
} }
...@@ -395,7 +404,7 @@ ingenic_clk_set_rate(struct clk_hw *hw, unsigned long req_rate, ...@@ -395,7 +404,7 @@ ingenic_clk_set_rate(struct clk_hw *hw, unsigned long req_rate,
/* update the divide */ /* update the divide */
mask = GENMASK(clk_info->div.bits - 1, 0); mask = GENMASK(clk_info->div.bits - 1, 0);
reg &= ~(mask << clk_info->div.shift); reg &= ~(mask << clk_info->div.shift);
reg |= (div - 1) << clk_info->div.shift; reg |= ((div / clk_info->div.div) - 1) << clk_info->div.shift;
/* clear the stop bit */ /* clear the stop bit */
if (clk_info->div.stop_bit != -1) if (clk_info->div.stop_bit != -1)
......
...@@ -76,8 +76,11 @@ struct ingenic_cgu_mux_info { ...@@ -76,8 +76,11 @@ struct ingenic_cgu_mux_info {
/** /**
* struct ingenic_cgu_div_info - information about a divider * struct ingenic_cgu_div_info - information about a divider
* @reg: offset of the divider control register within the CGU * @reg: offset of the divider control register within the CGU
* @shift: number of bits to shift the divide value by (ie. the index of * @shift: number of bits to left shift the divide value by (ie. the index of
* the lowest bit of the divide value within its control register) * the lowest bit of the divide value within its control register)
* @div: number of bits to divide the divider value by (i.e. if the
* effective divider value is the value written to the register
* multiplied by some constant)
* @bits: the size of the divide value in bits * @bits: the size of the divide value in bits
* @ce_bit: the index of the change enable bit within reg, or -1 if there * @ce_bit: the index of the change enable bit within reg, or -1 if there
* isn't one * isn't one
...@@ -87,6 +90,7 @@ struct ingenic_cgu_mux_info { ...@@ -87,6 +90,7 @@ struct ingenic_cgu_mux_info {
struct ingenic_cgu_div_info { struct ingenic_cgu_div_info {
unsigned reg; unsigned reg;
u8 shift; u8 shift;
u8 div;
u8 bits; u8 bits;
s8 ce_bit; s8 ce_bit;
s8 busy_bit; s8 busy_bit;
......
...@@ -90,51 +90,51 @@ static const struct ingenic_cgu_clk_info jz4740_cgu_clocks[] = { ...@@ -90,51 +90,51 @@ static const struct ingenic_cgu_clk_info jz4740_cgu_clocks[] = {
[JZ4740_CLK_PLL_HALF] = { [JZ4740_CLK_PLL_HALF] = {
"pll half", CGU_CLK_DIV, "pll half", CGU_CLK_DIV,
.parents = { JZ4740_CLK_PLL, -1, -1, -1 }, .parents = { JZ4740_CLK_PLL, -1, -1, -1 },
.div = { CGU_REG_CPCCR, 21, 1, -1, -1, -1 }, .div = { CGU_REG_CPCCR, 21, 1, 1, -1, -1, -1 },
}, },
[JZ4740_CLK_CCLK] = { [JZ4740_CLK_CCLK] = {
"cclk", CGU_CLK_DIV, "cclk", CGU_CLK_DIV,
.parents = { JZ4740_CLK_PLL, -1, -1, -1 }, .parents = { JZ4740_CLK_PLL, -1, -1, -1 },
.div = { CGU_REG_CPCCR, 0, 4, 22, -1, -1 }, .div = { CGU_REG_CPCCR, 0, 1, 4, 22, -1, -1 },
}, },
[JZ4740_CLK_HCLK] = { [JZ4740_CLK_HCLK] = {
"hclk", CGU_CLK_DIV, "hclk", CGU_CLK_DIV,
.parents = { JZ4740_CLK_PLL, -1, -1, -1 }, .parents = { JZ4740_CLK_PLL, -1, -1, -1 },
.div = { CGU_REG_CPCCR, 4, 4, 22, -1, -1 }, .div = { CGU_REG_CPCCR, 4, 1, 4, 22, -1, -1 },
}, },
[JZ4740_CLK_PCLK] = { [JZ4740_CLK_PCLK] = {
"pclk", CGU_CLK_DIV, "pclk", CGU_CLK_DIV,
.parents = { JZ4740_CLK_PLL, -1, -1, -1 }, .parents = { JZ4740_CLK_PLL, -1, -1, -1 },
.div = { CGU_REG_CPCCR, 8, 4, 22, -1, -1 }, .div = { CGU_REG_CPCCR, 8, 1, 4, 22, -1, -1 },
}, },
[JZ4740_CLK_MCLK] = { [JZ4740_CLK_MCLK] = {
"mclk", CGU_CLK_DIV, "mclk", CGU_CLK_DIV,
.parents = { JZ4740_CLK_PLL, -1, -1, -1 }, .parents = { JZ4740_CLK_PLL, -1, -1, -1 },
.div = { CGU_REG_CPCCR, 12, 4, 22, -1, -1 }, .div = { CGU_REG_CPCCR, 12, 1, 4, 22, -1, -1 },
}, },
[JZ4740_CLK_LCD] = { [JZ4740_CLK_LCD] = {
"lcd", CGU_CLK_DIV | CGU_CLK_GATE, "lcd", CGU_CLK_DIV | CGU_CLK_GATE,
.parents = { JZ4740_CLK_PLL_HALF, -1, -1, -1 }, .parents = { JZ4740_CLK_PLL_HALF, -1, -1, -1 },
.div = { CGU_REG_CPCCR, 16, 5, 22, -1, -1 }, .div = { CGU_REG_CPCCR, 16, 1, 5, 22, -1, -1 },
.gate = { CGU_REG_CLKGR, 10 }, .gate = { CGU_REG_CLKGR, 10 },
}, },
[JZ4740_CLK_LCD_PCLK] = { [JZ4740_CLK_LCD_PCLK] = {
"lcd_pclk", CGU_CLK_DIV, "lcd_pclk", CGU_CLK_DIV,
.parents = { JZ4740_CLK_PLL_HALF, -1, -1, -1 }, .parents = { JZ4740_CLK_PLL_HALF, -1, -1, -1 },
.div = { CGU_REG_LPCDR, 0, 11, -1, -1, -1 }, .div = { CGU_REG_LPCDR, 0, 1, 11, -1, -1, -1 },
}, },
[JZ4740_CLK_I2S] = { [JZ4740_CLK_I2S] = {
"i2s", CGU_CLK_MUX | CGU_CLK_DIV | CGU_CLK_GATE, "i2s", CGU_CLK_MUX | CGU_CLK_DIV | CGU_CLK_GATE,
.parents = { JZ4740_CLK_EXT, JZ4740_CLK_PLL_HALF, -1, -1 }, .parents = { JZ4740_CLK_EXT, JZ4740_CLK_PLL_HALF, -1, -1 },
.mux = { CGU_REG_CPCCR, 31, 1 }, .mux = { CGU_REG_CPCCR, 31, 1 },
.div = { CGU_REG_I2SCDR, 0, 8, -1, -1, -1 }, .div = { CGU_REG_I2SCDR, 0, 1, 8, -1, -1, -1 },
.gate = { CGU_REG_CLKGR, 6 }, .gate = { CGU_REG_CLKGR, 6 },
}, },
...@@ -142,21 +142,21 @@ static const struct ingenic_cgu_clk_info jz4740_cgu_clocks[] = { ...@@ -142,21 +142,21 @@ static const struct ingenic_cgu_clk_info jz4740_cgu_clocks[] = {
"spi", CGU_CLK_MUX | CGU_CLK_DIV | CGU_CLK_GATE, "spi", CGU_CLK_MUX | CGU_CLK_DIV | CGU_CLK_GATE,
.parents = { JZ4740_CLK_EXT, JZ4740_CLK_PLL, -1, -1 }, .parents = { JZ4740_CLK_EXT, JZ4740_CLK_PLL, -1, -1 },
.mux = { CGU_REG_SSICDR, 31, 1 }, .mux = { CGU_REG_SSICDR, 31, 1 },
.div = { CGU_REG_SSICDR, 0, 4, -1, -1, -1 }, .div = { CGU_REG_SSICDR, 0, 1, 4, -1, -1, -1 },
.gate = { CGU_REG_CLKGR, 4 }, .gate = { CGU_REG_CLKGR, 4 },
}, },
[JZ4740_CLK_MMC] = { [JZ4740_CLK_MMC] = {
"mmc", CGU_CLK_DIV | CGU_CLK_GATE, "mmc", CGU_CLK_DIV | CGU_CLK_GATE,
.parents = { JZ4740_CLK_PLL_HALF, -1, -1, -1 }, .parents = { JZ4740_CLK_PLL_HALF, -1, -1, -1 },
.div = { CGU_REG_MSCCDR, 0, 5, -1, -1, -1 }, .div = { CGU_REG_MSCCDR, 0, 1, 5, -1, -1, -1 },
.gate = { CGU_REG_CLKGR, 7 }, .gate = { CGU_REG_CLKGR, 7 },
}, },
[JZ4740_CLK_UHC] = { [JZ4740_CLK_UHC] = {
"uhc", CGU_CLK_DIV | CGU_CLK_GATE, "uhc", CGU_CLK_DIV | CGU_CLK_GATE,
.parents = { JZ4740_CLK_PLL_HALF, -1, -1, -1 }, .parents = { JZ4740_CLK_PLL_HALF, -1, -1, -1 },
.div = { CGU_REG_UHCCDR, 0, 4, -1, -1, -1 }, .div = { CGU_REG_UHCCDR, 0, 1, 4, -1, -1, -1 },
.gate = { CGU_REG_CLKGR, 14 }, .gate = { CGU_REG_CLKGR, 14 },
}, },
...@@ -164,7 +164,7 @@ static const struct ingenic_cgu_clk_info jz4740_cgu_clocks[] = { ...@@ -164,7 +164,7 @@ static const struct ingenic_cgu_clk_info jz4740_cgu_clocks[] = {
"udc", CGU_CLK_MUX | CGU_CLK_DIV, "udc", CGU_CLK_MUX | CGU_CLK_DIV,
.parents = { JZ4740_CLK_EXT, JZ4740_CLK_PLL_HALF, -1, -1 }, .parents = { JZ4740_CLK_EXT, JZ4740_CLK_PLL_HALF, -1, -1 },
.mux = { CGU_REG_CPCCR, 29, 1 }, .mux = { CGU_REG_CPCCR, 29, 1 },
.div = { CGU_REG_CPCCR, 23, 6, -1, -1, -1 }, .div = { CGU_REG_CPCCR, 23, 1, 6, -1, -1, -1 },
.gate = { CGU_REG_SCR, 6 }, .gate = { CGU_REG_SCR, 6 },
}, },
......
...@@ -296,13 +296,13 @@ static const struct ingenic_cgu_clk_info jz4780_cgu_clocks[] = { ...@@ -296,13 +296,13 @@ static const struct ingenic_cgu_clk_info jz4780_cgu_clocks[] = {
[JZ4780_CLK_CPU] = { [JZ4780_CLK_CPU] = {
"cpu", CGU_CLK_DIV, "cpu", CGU_CLK_DIV,
.parents = { JZ4780_CLK_CPUMUX, -1, -1, -1 }, .parents = { JZ4780_CLK_CPUMUX, -1, -1, -1 },
.div = { CGU_REG_CLOCKCONTROL, 0, 4, 22, -1, -1 }, .div = { CGU_REG_CLOCKCONTROL, 0, 1, 4, 22, -1, -1 },
}, },
[JZ4780_CLK_L2CACHE] = { [JZ4780_CLK_L2CACHE] = {
"l2cache", CGU_CLK_DIV, "l2cache", CGU_CLK_DIV,
.parents = { JZ4780_CLK_CPUMUX, -1, -1, -1 }, .parents = { JZ4780_CLK_CPUMUX, -1, -1, -1 },
.div = { CGU_REG_CLOCKCONTROL, 4, 4, -1, -1, -1 }, .div = { CGU_REG_CLOCKCONTROL, 4, 1, 4, -1, -1, -1 },
}, },
[JZ4780_CLK_AHB0] = { [JZ4780_CLK_AHB0] = {
...@@ -310,7 +310,7 @@ static const struct ingenic_cgu_clk_info jz4780_cgu_clocks[] = { ...@@ -310,7 +310,7 @@ static const struct ingenic_cgu_clk_info jz4780_cgu_clocks[] = {
.parents = { -1, JZ4780_CLK_SCLKA, JZ4780_CLK_MPLL, .parents = { -1, JZ4780_CLK_SCLKA, JZ4780_CLK_MPLL,
JZ4780_CLK_EPLL }, JZ4780_CLK_EPLL },
.mux = { CGU_REG_CLOCKCONTROL, 26, 2 }, .mux = { CGU_REG_CLOCKCONTROL, 26, 2 },
.div = { CGU_REG_CLOCKCONTROL, 8, 4, 21, -1, -1 }, .div = { CGU_REG_CLOCKCONTROL, 8, 1, 4, 21, -1, -1 },
}, },
[JZ4780_CLK_AHB2PMUX] = { [JZ4780_CLK_AHB2PMUX] = {
...@@ -323,20 +323,20 @@ static const struct ingenic_cgu_clk_info jz4780_cgu_clocks[] = { ...@@ -323,20 +323,20 @@ static const struct ingenic_cgu_clk_info jz4780_cgu_clocks[] = {
[JZ4780_CLK_AHB2] = { [JZ4780_CLK_AHB2] = {
"ahb2", CGU_CLK_DIV, "ahb2", CGU_CLK_DIV,
.parents = { JZ4780_CLK_AHB2PMUX, -1, -1, -1 }, .parents = { JZ4780_CLK_AHB2PMUX, -1, -1, -1 },
.div = { CGU_REG_CLOCKCONTROL, 12, 4, 20, -1, -1 }, .div = { CGU_REG_CLOCKCONTROL, 12, 1, 4, 20, -1, -1 },
}, },
[JZ4780_CLK_PCLK] = { [JZ4780_CLK_PCLK] = {
"pclk", CGU_CLK_DIV, "pclk", CGU_CLK_DIV,
.parents = { JZ4780_CLK_AHB2PMUX, -1, -1, -1 }, .parents = { JZ4780_CLK_AHB2PMUX, -1, -1, -1 },
.div = { CGU_REG_CLOCKCONTROL, 16, 4, 20, -1, -1 }, .div = { CGU_REG_CLOCKCONTROL, 16, 1, 4, 20, -1, -1 },
}, },
[JZ4780_CLK_DDR] = { [JZ4780_CLK_DDR] = {
"ddr", CGU_CLK_MUX | CGU_CLK_DIV, "ddr", CGU_CLK_MUX | CGU_CLK_DIV,
.parents = { -1, JZ4780_CLK_SCLKA, JZ4780_CLK_MPLL, -1 }, .parents = { -1, JZ4780_CLK_SCLKA, JZ4780_CLK_MPLL, -1 },
.mux = { CGU_REG_DDRCDR, 30, 2 }, .mux = { CGU_REG_DDRCDR, 30, 2 },
.div = { CGU_REG_DDRCDR, 0, 4, 29, 28, 27 }, .div = { CGU_REG_DDRCDR, 0, 1, 4, 29, 28, 27 },
}, },
[JZ4780_CLK_VPU] = { [JZ4780_CLK_VPU] = {
...@@ -344,7 +344,7 @@ static const struct ingenic_cgu_clk_info jz4780_cgu_clocks[] = { ...@@ -344,7 +344,7 @@ static const struct ingenic_cgu_clk_info jz4780_cgu_clocks[] = {
.parents = { JZ4780_CLK_SCLKA, JZ4780_CLK_MPLL, .parents = { JZ4780_CLK_SCLKA, JZ4780_CLK_MPLL,
JZ4780_CLK_EPLL, -1 }, JZ4780_CLK_EPLL, -1 },
.mux = { CGU_REG_VPUCDR, 30, 2 }, .mux = { CGU_REG_VPUCDR, 30, 2 },
.div = { CGU_REG_VPUCDR, 0, 4, 29, 28, 27 }, .div = { CGU_REG_VPUCDR, 0, 1, 4, 29, 28, 27 },
.gate = { CGU_REG_CLKGR1, 2 }, .gate = { CGU_REG_CLKGR1, 2 },
}, },
...@@ -352,7 +352,7 @@ static const struct ingenic_cgu_clk_info jz4780_cgu_clocks[] = { ...@@ -352,7 +352,7 @@ static const struct ingenic_cgu_clk_info jz4780_cgu_clocks[] = {
"i2s_pll", CGU_CLK_MUX | CGU_CLK_DIV, "i2s_pll", CGU_CLK_MUX | CGU_CLK_DIV,
.parents = { JZ4780_CLK_SCLKA, JZ4780_CLK_EPLL, -1, -1 }, .parents = { JZ4780_CLK_SCLKA, JZ4780_CLK_EPLL, -1, -1 },
.mux = { CGU_REG_I2SCDR, 30, 1 }, .mux = { CGU_REG_I2SCDR, 30, 1 },
.div = { CGU_REG_I2SCDR, 0, 8, 29, 28, 27 }, .div = { CGU_REG_I2SCDR, 0, 1, 8, 29, 28, 27 },
}, },
[JZ4780_CLK_I2S] = { [JZ4780_CLK_I2S] = {
...@@ -366,7 +366,7 @@ static const struct ingenic_cgu_clk_info jz4780_cgu_clocks[] = { ...@@ -366,7 +366,7 @@ static const struct ingenic_cgu_clk_info jz4780_cgu_clocks[] = {
.parents = { JZ4780_CLK_SCLKA, JZ4780_CLK_MPLL, .parents = { JZ4780_CLK_SCLKA, JZ4780_CLK_MPLL,
JZ4780_CLK_VPLL, -1 }, JZ4780_CLK_VPLL, -1 },
.mux = { CGU_REG_LP0CDR, 30, 2 }, .mux = { CGU_REG_LP0CDR, 30, 2 },
.div = { CGU_REG_LP0CDR, 0, 8, 28, 27, 26 }, .div = { CGU_REG_LP0CDR, 0, 1, 8, 28, 27, 26 },
}, },
[JZ4780_CLK_LCD1PIXCLK] = { [JZ4780_CLK_LCD1PIXCLK] = {
...@@ -374,7 +374,7 @@ static const struct ingenic_cgu_clk_info jz4780_cgu_clocks[] = { ...@@ -374,7 +374,7 @@ static const struct ingenic_cgu_clk_info jz4780_cgu_clocks[] = {
.parents = { JZ4780_CLK_SCLKA, JZ4780_CLK_MPLL, .parents = { JZ4780_CLK_SCLKA, JZ4780_CLK_MPLL,
JZ4780_CLK_VPLL, -1 }, JZ4780_CLK_VPLL, -1 },
.mux = { CGU_REG_LP1CDR, 30, 2 }, .mux = { CGU_REG_LP1CDR, 30, 2 },
.div = { CGU_REG_LP1CDR, 0, 8, 28, 27, 26 }, .div = { CGU_REG_LP1CDR, 0, 1, 8, 28, 27, 26 },
}, },
[JZ4780_CLK_MSCMUX] = { [JZ4780_CLK_MSCMUX] = {
...@@ -386,21 +386,21 @@ static const struct ingenic_cgu_clk_info jz4780_cgu_clocks[] = { ...@@ -386,21 +386,21 @@ static const struct ingenic_cgu_clk_info jz4780_cgu_clocks[] = {
[JZ4780_CLK_MSC0] = { [JZ4780_CLK_MSC0] = {
"msc0", CGU_CLK_DIV | CGU_CLK_GATE, "msc0", CGU_CLK_DIV | CGU_CLK_GATE,
.parents = { JZ4780_CLK_MSCMUX, -1, -1, -1 }, .parents = { JZ4780_CLK_MSCMUX, -1, -1, -1 },
.div = { CGU_REG_MSC0CDR, 0, 8, 29, 28, 27 }, .div = { CGU_REG_MSC0CDR, 0, 2, 8, 29, 28, 27 },
.gate = { CGU_REG_CLKGR0, 3 }, .gate = { CGU_REG_CLKGR0, 3 },
}, },
[JZ4780_CLK_MSC1] = { [JZ4780_CLK_MSC1] = {
"msc1", CGU_CLK_DIV | CGU_CLK_GATE, "msc1", CGU_CLK_DIV | CGU_CLK_GATE,
.parents = { JZ4780_CLK_MSCMUX, -1, -1, -1 }, .parents = { JZ4780_CLK_MSCMUX, -1, -1, -1 },
.div = { CGU_REG_MSC1CDR, 0, 8, 29, 28, 27 }, .div = { CGU_REG_MSC1CDR, 0, 2, 8, 29, 28, 27 },
.gate = { CGU_REG_CLKGR0, 11 }, .gate = { CGU_REG_CLKGR0, 11 },
}, },
[JZ4780_CLK_MSC2] = { [JZ4780_CLK_MSC2] = {
"msc2", CGU_CLK_DIV | CGU_CLK_GATE, "msc2", CGU_CLK_DIV | CGU_CLK_GATE,
.parents = { JZ4780_CLK_MSCMUX, -1, -1, -1 }, .parents = { JZ4780_CLK_MSCMUX, -1, -1, -1 },
.div = { CGU_REG_MSC2CDR, 0, 8, 29, 28, 27 }, .div = { CGU_REG_MSC2CDR, 0, 2, 8, 29, 28, 27 },
.gate = { CGU_REG_CLKGR0, 12 }, .gate = { CGU_REG_CLKGR0, 12 },
}, },
...@@ -409,7 +409,7 @@ static const struct ingenic_cgu_clk_info jz4780_cgu_clocks[] = { ...@@ -409,7 +409,7 @@ static const struct ingenic_cgu_clk_info jz4780_cgu_clocks[] = {
.parents = { JZ4780_CLK_SCLKA, JZ4780_CLK_MPLL, .parents = { JZ4780_CLK_SCLKA, JZ4780_CLK_MPLL,
JZ4780_CLK_EPLL, JZ4780_CLK_OTGPHY }, JZ4780_CLK_EPLL, JZ4780_CLK_OTGPHY },
.mux = { CGU_REG_UHCCDR, 30, 2 }, .mux = { CGU_REG_UHCCDR, 30, 2 },
.div = { CGU_REG_UHCCDR, 0, 8, 29, 28, 27 }, .div = { CGU_REG_UHCCDR, 0, 1, 8, 29, 28, 27 },
.gate = { CGU_REG_CLKGR0, 24 }, .gate = { CGU_REG_CLKGR0, 24 },
}, },
...@@ -417,7 +417,7 @@ static const struct ingenic_cgu_clk_info jz4780_cgu_clocks[] = { ...@@ -417,7 +417,7 @@ static const struct ingenic_cgu_clk_info jz4780_cgu_clocks[] = {
"ssi_pll", CGU_CLK_MUX | CGU_CLK_DIV, "ssi_pll", CGU_CLK_MUX | CGU_CLK_DIV,
.parents = { JZ4780_CLK_SCLKA, JZ4780_CLK_MPLL, -1, -1 }, .parents = { JZ4780_CLK_SCLKA, JZ4780_CLK_MPLL, -1, -1 },
.mux = { CGU_REG_SSICDR, 30, 1 }, .mux = { CGU_REG_SSICDR, 30, 1 },
.div = { CGU_REG_SSICDR, 0, 8, 29, 28, 27 }, .div = { CGU_REG_SSICDR, 0, 1, 8, 29, 28, 27 },
}, },
[JZ4780_CLK_SSI] = { [JZ4780_CLK_SSI] = {
...@@ -430,7 +430,7 @@ static const struct ingenic_cgu_clk_info jz4780_cgu_clocks[] = { ...@@ -430,7 +430,7 @@ static const struct ingenic_cgu_clk_info jz4780_cgu_clocks[] = {
"cim_mclk", CGU_CLK_MUX | CGU_CLK_DIV, "cim_mclk", CGU_CLK_MUX | CGU_CLK_DIV,
.parents = { JZ4780_CLK_SCLKA, JZ4780_CLK_MPLL, -1, -1 }, .parents = { JZ4780_CLK_SCLKA, JZ4780_CLK_MPLL, -1, -1 },
.mux = { CGU_REG_CIMCDR, 31, 1 }, .mux = { CGU_REG_CIMCDR, 31, 1 },
.div = { CGU_REG_CIMCDR, 0, 8, 30, 29, 28 }, .div = { CGU_REG_CIMCDR, 0, 1, 8, 30, 29, 28 },
}, },
[JZ4780_CLK_PCMPLL] = { [JZ4780_CLK_PCMPLL] = {
...@@ -438,7 +438,7 @@ static const struct ingenic_cgu_clk_info jz4780_cgu_clocks[] = { ...@@ -438,7 +438,7 @@ static const struct ingenic_cgu_clk_info jz4780_cgu_clocks[] = {
.parents = { JZ4780_CLK_SCLKA, JZ4780_CLK_MPLL, .parents = { JZ4780_CLK_SCLKA, JZ4780_CLK_MPLL,
JZ4780_CLK_EPLL, JZ4780_CLK_VPLL }, JZ4780_CLK_EPLL, JZ4780_CLK_VPLL },
.mux = { CGU_REG_PCMCDR, 29, 2 }, .mux = { CGU_REG_PCMCDR, 29, 2 },
.div = { CGU_REG_PCMCDR, 0, 8, 28, 27, 26 }, .div = { CGU_REG_PCMCDR, 0, 1, 8, 28, 27, 26 },
}, },
[JZ4780_CLK_PCM] = { [JZ4780_CLK_PCM] = {
...@@ -453,7 +453,7 @@ static const struct ingenic_cgu_clk_info jz4780_cgu_clocks[] = { ...@@ -453,7 +453,7 @@ static const struct ingenic_cgu_clk_info jz4780_cgu_clocks[] = {
.parents = { -1, JZ4780_CLK_SCLKA, JZ4780_CLK_MPLL, .parents = { -1, JZ4780_CLK_SCLKA, JZ4780_CLK_MPLL,
JZ4780_CLK_EPLL }, JZ4780_CLK_EPLL },
.mux = { CGU_REG_GPUCDR, 30, 2 }, .mux = { CGU_REG_GPUCDR, 30, 2 },
.div = { CGU_REG_GPUCDR, 0, 4, 29, 28, 27 }, .div = { CGU_REG_GPUCDR, 0, 1, 4, 29, 28, 27 },
.gate = { CGU_REG_CLKGR1, 4 }, .gate = { CGU_REG_CLKGR1, 4 },
}, },
...@@ -462,7 +462,7 @@ static const struct ingenic_cgu_clk_info jz4780_cgu_clocks[] = { ...@@ -462,7 +462,7 @@ static const struct ingenic_cgu_clk_info jz4780_cgu_clocks[] = {
.parents = { JZ4780_CLK_SCLKA, JZ4780_CLK_MPLL, .parents = { JZ4780_CLK_SCLKA, JZ4780_CLK_MPLL,
JZ4780_CLK_VPLL, -1 }, JZ4780_CLK_VPLL, -1 },
.mux = { CGU_REG_HDMICDR, 30, 2 }, .mux = { CGU_REG_HDMICDR, 30, 2 },
.div = { CGU_REG_HDMICDR, 0, 8, 29, 28, 26 }, .div = { CGU_REG_HDMICDR, 0, 1, 8, 29, 28, 26 },
.gate = { CGU_REG_CLKGR1, 9 }, .gate = { CGU_REG_CLKGR1, 9 },
}, },
...@@ -471,7 +471,7 @@ static const struct ingenic_cgu_clk_info jz4780_cgu_clocks[] = { ...@@ -471,7 +471,7 @@ static const struct ingenic_cgu_clk_info jz4780_cgu_clocks[] = {
.parents = { -1, JZ4780_CLK_SCLKA, JZ4780_CLK_MPLL, .parents = { -1, JZ4780_CLK_SCLKA, JZ4780_CLK_MPLL,
JZ4780_CLK_EPLL }, JZ4780_CLK_EPLL },
.mux = { CGU_REG_BCHCDR, 30, 2 }, .mux = { CGU_REG_BCHCDR, 30, 2 },
.div = { CGU_REG_BCHCDR, 0, 4, 29, 28, 27 }, .div = { CGU_REG_BCHCDR, 0, 1, 4, 29, 28, 27 },
.gate = { CGU_REG_CLKGR0, 1 }, .gate = { CGU_REG_CLKGR0, 1 },
}, },
......
...@@ -141,11 +141,11 @@ static const struct composite_conf mali_conf __initconst = { ...@@ -141,11 +141,11 @@ static const struct composite_conf mali_conf __initconst = {
}; };
static const struct clk_conf meson8b_xtal_conf __initconst = static const struct clk_conf meson8b_xtal_conf __initconst =
FIXED_RATE_P(MESON8B_REG_CTL0_ADDR, CLKID_XTAL, "xtal", FIXED_RATE_P(MESON8B_REG_CTL0_ADDR, CLKID_XTAL, "xtal", 0,
CLK_IS_ROOT, PARM(0x00, 4, 7)); PARM(0x00, 4, 7));
static const struct clk_conf meson8b_clk_confs[] __initconst = { static const struct clk_conf meson8b_clk_confs[] __initconst = {
FIXED_RATE(CLKID_ZERO, "zero", CLK_IS_ROOT, 0), FIXED_RATE(CLKID_ZERO, "zero", 0, 0),
PLL(MESON8B_REG_PLL_FIXED, CLKID_PLL_FIXED, "fixed_pll", PLL(MESON8B_REG_PLL_FIXED, CLKID_PLL_FIXED, "fixed_pll",
p_xtal, 0, &pll_confs), p_xtal, 0, &pll_confs),
PLL(MESON8B_REG_PLL_VID, CLKID_PLL_VID, "vid_pll", PLL(MESON8B_REG_PLL_VID, CLKID_PLL_VID, "vid_pll",
......
This diff is collapsed.
...@@ -63,11 +63,11 @@ struct mmp2_clk_unit { ...@@ -63,11 +63,11 @@ struct mmp2_clk_unit {
}; };
static struct mmp_param_fixed_rate_clk fixed_rate_clks[] = { static struct mmp_param_fixed_rate_clk fixed_rate_clks[] = {
{MMP2_CLK_CLK32, "clk32", NULL, CLK_IS_ROOT, 32768}, {MMP2_CLK_CLK32, "clk32", NULL, 0, 32768},
{MMP2_CLK_VCTCXO, "vctcxo", NULL, CLK_IS_ROOT, 26000000}, {MMP2_CLK_VCTCXO, "vctcxo", NULL, 0, 26000000},
{MMP2_CLK_PLL1, "pll1", NULL, CLK_IS_ROOT, 800000000}, {MMP2_CLK_PLL1, "pll1", NULL, 0, 800000000},
{MMP2_CLK_PLL2, "pll2", NULL, CLK_IS_ROOT, 960000000}, {MMP2_CLK_PLL2, "pll2", NULL, 0, 960000000},
{MMP2_CLK_USB_PLL, "usb_pll", NULL, CLK_IS_ROOT, 480000000}, {MMP2_CLK_USB_PLL, "usb_pll", NULL, 0, 480000000},
}; };
static struct mmp_param_fixed_factor_clk fixed_factor_clks[] = { static struct mmp_param_fixed_factor_clk fixed_factor_clks[] = {
......
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
...@@ -15,3 +15,4 @@ obj-y += clk-rk3188.o ...@@ -15,3 +15,4 @@ obj-y += clk-rk3188.o
obj-y += clk-rk3228.o obj-y += clk-rk3228.o
obj-y += clk-rk3288.o obj-y += clk-rk3288.o
obj-y += clk-rk3368.o obj-y += clk-rk3368.o
obj-y += clk-rk3399.o
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment