Commit 8a02fcf8 authored by Stephen Boyd's avatar Stephen Boyd

Merge tag 'sunxi-clk-for-4.13' of...

Merge tag 'sunxi-clk-for-4.13' of https://git.kernel.org/pub/scm/linux/kernel/git/sunxi/linux into clk-next

Pull Allwinner clock patches from Maxime Ripard:

Some new clock units are supported, for the display clocks unsed in the
newer SoCs, and the A83T PRCM.

There is also a bunch of minor fixes for clocks that are not used by
anyone, and reworks needed by drivers that will land in 4.13.

* tag 'sunxi-clk-for-4.13' of https://git.kernel.org/pub/scm/linux/kernel/git/sunxi/linux: (21 commits)
  clk: sunxi-ng: Move all clock types to a library
  clk: sunxi-ng: a83t: Add support for A83T's PRCM
  dt-bindings: clock: sunxi-ccu: Add compatible string for A83T PRCM
  clk: sunxi-ng: select SUNXI_CCU_MULT for sun8i-a83t
  clk: sunxi-ng: a83t: Fix audio PLL divider offset
  clk: sunxi-ng: a83t: Fix PLL lock status register offset
  clk: sunxi-ng: Add driver for A83T CCU
  clk: sunxi-ng: Support multiple variable pre-dividers
  dt-bindings: clock: sunxi-ccu: Add compatible string for A83T CCU
  clk: sunxi-ng: de2: fix wrong pointer passed to PTR_ERR()
  clk: sunxi-ng: sun5i: Export video PLLs
  clk: sunxi-ng: mux: Re-adjust parent rate
  clk: sunxi-ng: mux: Change pre-divider application function prototype
  clk: sunxi-ng: mux: split out the pre-divider computation code
  clk: sunxi-ng: mux: Don't just rely on the parent for CLK_SET_RATE_PARENT
  clk: sunxi-ng: div: Switch to divider_round_rate
  clk: sunxi-ng: Pass the parent and a pointer to the clocks round rate
  clk: divider: Make divider_round_rate take the parent clock
  clk: sunxi-ng: explicitly include linux/spinlock.h
  clk: sunxi-ng: add support for DE2 CCU
  ...
parents 9c861f33 06e226c7
Allwinner Display Engine 2.0 Clock Control Binding
--------------------------------------------------
Required properties :
- compatible: must contain one of the following compatibles:
- "allwinner,sun8i-a83t-de2-clk"
- "allwinner,sun8i-v3s-de2-clk"
- "allwinner,sun50i-h5-de2-clk"
- reg: Must contain the registers base address and length
- clocks: phandle to the clocks feeding the display engine subsystem.
Three are needed:
- "mod": the display engine module clock
- "bus": the bus clock for the whole display engine subsystem
- clock-names: Must contain the clock names described just above
- resets: phandle to the reset control for the display engine subsystem.
- #clock-cells : must contain 1
- #reset-cells : must contain 1
Example:
de2_clocks: clock@1000000 {
compatible = "allwinner,sun8i-a83t-de2-clk";
reg = <0x01000000 0x100000>;
clocks = <&ccu CLK_BUS_DE>,
<&ccu CLK_DE>;
clock-names = "bus",
"mod";
resets = <&ccu RST_BUS_DE>;
#clock-cells = <1>;
#reset-cells = <1>;
};
...@@ -6,6 +6,8 @@ Required properties : ...@@ -6,6 +6,8 @@ Required properties :
- "allwinner,sun6i-a31-ccu" - "allwinner,sun6i-a31-ccu"
- "allwinner,sun8i-a23-ccu" - "allwinner,sun8i-a23-ccu"
- "allwinner,sun8i-a33-ccu" - "allwinner,sun8i-a33-ccu"
- "allwinner,sun8i-a83t-ccu"
- "allwinner,sun8i-a83t-r-ccu"
- "allwinner,sun8i-h3-ccu" - "allwinner,sun8i-h3-ccu"
- "allwinner,sun8i-h3-r-ccu" - "allwinner,sun8i-h3-r-ccu"
- "allwinner,sun8i-v3s-ccu" - "allwinner,sun8i-v3s-ccu"
...@@ -18,11 +20,12 @@ Required properties : ...@@ -18,11 +20,12 @@ Required properties :
- clocks: phandle to the oscillators feeding the CCU. Two are needed: - clocks: phandle to the oscillators feeding the CCU. Two are needed:
- "hosc": the high frequency oscillator (usually at 24MHz) - "hosc": the high frequency oscillator (usually at 24MHz)
- "losc": the low frequency oscillator (usually at 32kHz) - "losc": the low frequency oscillator (usually at 32kHz)
On the A83T, this is the internal 16MHz oscillator divided by 512
- clock-names: Must contain the clock names described just above - clock-names: Must contain the clock names described just above
- #clock-cells : must contain 1 - #clock-cells : must contain 1
- #reset-cells : must contain 1 - #reset-cells : must contain 1
For the PRCM CCUs on H3/A64, two more clocks are needed: For the PRCM CCUs on A83T/H3/A64, two more clocks are needed:
- "pll-periph": the SoC's peripheral PLL from the main CCU - "pll-periph": the SoC's peripheral PLL from the main CCU
- "iosc": the SoC's internal frequency oscillator - "iosc": the SoC's internal frequency oscillator
......
...@@ -275,7 +275,8 @@ static int _next_div(const struct clk_div_table *table, int div, ...@@ -275,7 +275,8 @@ static int _next_div(const struct clk_div_table *table, int div,
return div; return div;
} }
static int clk_divider_bestdiv(struct clk_hw *hw, unsigned long rate, static int clk_divider_bestdiv(struct clk_hw *hw, struct clk_hw *parent,
unsigned long rate,
unsigned long *best_parent_rate, unsigned long *best_parent_rate,
const struct clk_div_table *table, u8 width, const struct clk_div_table *table, u8 width,
unsigned long flags) unsigned long flags)
...@@ -314,8 +315,7 @@ static int clk_divider_bestdiv(struct clk_hw *hw, unsigned long rate, ...@@ -314,8 +315,7 @@ static int clk_divider_bestdiv(struct clk_hw *hw, unsigned long rate,
*best_parent_rate = parent_rate_saved; *best_parent_rate = parent_rate_saved;
return i; return i;
} }
parent_rate = clk_hw_round_rate(clk_hw_get_parent(hw), parent_rate = clk_hw_round_rate(parent, rate * i);
rate * i);
now = DIV_ROUND_UP_ULL((u64)parent_rate, i); now = DIV_ROUND_UP_ULL((u64)parent_rate, i);
if (_is_best_div(rate, now, best, flags)) { if (_is_best_div(rate, now, best, flags)) {
bestdiv = i; bestdiv = i;
...@@ -326,23 +326,24 @@ static int clk_divider_bestdiv(struct clk_hw *hw, unsigned long rate, ...@@ -326,23 +326,24 @@ static int clk_divider_bestdiv(struct clk_hw *hw, unsigned long rate,
if (!bestdiv) { if (!bestdiv) {
bestdiv = _get_maxdiv(table, width, flags); bestdiv = _get_maxdiv(table, width, flags);
*best_parent_rate = clk_hw_round_rate(clk_hw_get_parent(hw), 1); *best_parent_rate = clk_hw_round_rate(parent, 1);
} }
return bestdiv; return bestdiv;
} }
long divider_round_rate(struct clk_hw *hw, unsigned long rate, long divider_round_rate_parent(struct clk_hw *hw, struct clk_hw *parent,
unsigned long *prate, const struct clk_div_table *table, unsigned long rate, unsigned long *prate,
u8 width, unsigned long flags) const struct clk_div_table *table,
u8 width, unsigned long flags)
{ {
int div; int div;
div = clk_divider_bestdiv(hw, rate, prate, table, width, flags); div = clk_divider_bestdiv(hw, parent, rate, prate, table, width, flags);
return DIV_ROUND_UP_ULL((u64)*prate, div); return DIV_ROUND_UP_ULL((u64)*prate, div);
} }
EXPORT_SYMBOL_GPL(divider_round_rate); EXPORT_SYMBOL_GPL(divider_round_rate_parent);
static long clk_divider_round_rate(struct clk_hw *hw, unsigned long rate, static long clk_divider_round_rate(struct clk_hw *hw, unsigned long rate,
unsigned long *prate) unsigned long *prate)
......
...@@ -6,157 +6,55 @@ config SUNXI_CCU ...@@ -6,157 +6,55 @@ config SUNXI_CCU
if SUNXI_CCU if SUNXI_CCU
# Base clock types
config SUNXI_CCU_DIV
bool
select SUNXI_CCU_MUX
config SUNXI_CCU_FRAC
bool
config SUNXI_CCU_GATE
def_bool y
config SUNXI_CCU_MUX
bool
config SUNXI_CCU_MULT
bool
select SUNXI_CCU_MUX
config SUNXI_CCU_PHASE
bool
# Multi-factor clocks
config SUNXI_CCU_NK
bool
select SUNXI_CCU_GATE
config SUNXI_CCU_NKM
bool
select SUNXI_CCU_GATE
config SUNXI_CCU_NKMP
bool
select SUNXI_CCU_GATE
config SUNXI_CCU_NM
bool
select SUNXI_CCU_FRAC
select SUNXI_CCU_GATE
config SUNXI_CCU_MP
bool
select SUNXI_CCU_GATE
select SUNXI_CCU_MUX
# SoC Drivers
config SUN50I_A64_CCU config SUN50I_A64_CCU
bool "Support for the Allwinner A64 CCU" bool "Support for the Allwinner A64 CCU"
select SUNXI_CCU_DIV
select SUNXI_CCU_NK
select SUNXI_CCU_NKM
select SUNXI_CCU_NKMP
select SUNXI_CCU_NM
select SUNXI_CCU_MP
select SUNXI_CCU_PHASE
default ARM64 && ARCH_SUNXI default ARM64 && ARCH_SUNXI
depends on (ARM64 && ARCH_SUNXI) || COMPILE_TEST depends on (ARM64 && ARCH_SUNXI) || COMPILE_TEST
config SUN5I_CCU config SUN5I_CCU
bool "Support for the Allwinner sun5i family CCM" bool "Support for the Allwinner sun5i family CCM"
select SUNXI_CCU_DIV
select SUNXI_CCU_MULT
select SUNXI_CCU_NK
select SUNXI_CCU_NKM
select SUNXI_CCU_NM
select SUNXI_CCU_MP
select SUNXI_CCU_PHASE
default MACH_SUN5I default MACH_SUN5I
depends on MACH_SUN5I || COMPILE_TEST depends on MACH_SUN5I || COMPILE_TEST
config SUN6I_A31_CCU config SUN6I_A31_CCU
bool "Support for the Allwinner A31/A31s CCU" bool "Support for the Allwinner A31/A31s CCU"
select SUNXI_CCU_DIV
select SUNXI_CCU_NK
select SUNXI_CCU_NKM
select SUNXI_CCU_NKMP
select SUNXI_CCU_NM
select SUNXI_CCU_MP
select SUNXI_CCU_PHASE
default MACH_SUN6I default MACH_SUN6I
depends on MACH_SUN6I || COMPILE_TEST depends on MACH_SUN6I || COMPILE_TEST
config SUN8I_A23_CCU config SUN8I_A23_CCU
bool "Support for the Allwinner A23 CCU" bool "Support for the Allwinner A23 CCU"
select SUNXI_CCU_DIV
select SUNXI_CCU_MULT
select SUNXI_CCU_NK
select SUNXI_CCU_NKM
select SUNXI_CCU_NKMP
select SUNXI_CCU_NM
select SUNXI_CCU_MP
select SUNXI_CCU_PHASE
default MACH_SUN8I default MACH_SUN8I
depends on MACH_SUN8I || COMPILE_TEST depends on MACH_SUN8I || COMPILE_TEST
config SUN8I_A33_CCU config SUN8I_A33_CCU
bool "Support for the Allwinner A33 CCU" bool "Support for the Allwinner A33 CCU"
select SUNXI_CCU_DIV
select SUNXI_CCU_MULT
select SUNXI_CCU_NK
select SUNXI_CCU_NKM
select SUNXI_CCU_NKMP
select SUNXI_CCU_NM
select SUNXI_CCU_MP
select SUNXI_CCU_PHASE
default MACH_SUN8I default MACH_SUN8I
depends on MACH_SUN8I || COMPILE_TEST depends on MACH_SUN8I || COMPILE_TEST
config SUN8I_A83T_CCU
bool "Support for the Allwinner A83T CCU"
default MACH_SUN8I
config SUN8I_H3_CCU config SUN8I_H3_CCU
bool "Support for the Allwinner H3 CCU" bool "Support for the Allwinner H3 CCU"
select SUNXI_CCU_DIV
select SUNXI_CCU_NK
select SUNXI_CCU_NKM
select SUNXI_CCU_NKMP
select SUNXI_CCU_NM
select SUNXI_CCU_MP
select SUNXI_CCU_PHASE
default MACH_SUN8I || (ARM64 && ARCH_SUNXI) default MACH_SUN8I || (ARM64 && ARCH_SUNXI)
depends on MACH_SUN8I || (ARM64 && ARCH_SUNXI) || COMPILE_TEST depends on MACH_SUN8I || (ARM64 && ARCH_SUNXI) || COMPILE_TEST
config SUN8I_V3S_CCU config SUN8I_V3S_CCU
bool "Support for the Allwinner V3s CCU" bool "Support for the Allwinner V3s CCU"
select SUNXI_CCU_DIV
select SUNXI_CCU_NK
select SUNXI_CCU_NKM
select SUNXI_CCU_NKMP
select SUNXI_CCU_NM
select SUNXI_CCU_MP
select SUNXI_CCU_PHASE
default MACH_SUN8I default MACH_SUN8I
depends on MACH_SUN8I || COMPILE_TEST depends on MACH_SUN8I || COMPILE_TEST
config SUN8I_DE2_CCU
bool "Support for the Allwinner SoCs DE2 CCU"
config SUN9I_A80_CCU config SUN9I_A80_CCU
bool "Support for the Allwinner A80 CCU" bool "Support for the Allwinner A80 CCU"
select SUNXI_CCU_DIV
select SUNXI_CCU_MULT
select SUNXI_CCU_GATE
select SUNXI_CCU_NKMP
select SUNXI_CCU_NM
select SUNXI_CCU_MP
select SUNXI_CCU_PHASE
default MACH_SUN9I default MACH_SUN9I
depends on MACH_SUN9I || COMPILE_TEST depends on MACH_SUN9I || COMPILE_TEST
config SUN8I_R_CCU config SUN8I_R_CCU
bool "Support for Allwinner SoCs' PRCM CCUs" bool "Support for Allwinner SoCs' PRCM CCUs"
select SUNXI_CCU_DIV
select SUNXI_CCU_GATE
select SUNXI_CCU_MP
default MACH_SUN8I || (ARCH_SUNXI && ARM64) default MACH_SUN8I || (ARCH_SUNXI && ARM64)
endif endif
# Common objects # Common objects
obj-$(CONFIG_SUNXI_CCU) += ccu_common.o lib-$(CONFIG_SUNXI_CCU) += ccu_common.o
obj-$(CONFIG_SUNXI_CCU) += ccu_reset.o lib-$(CONFIG_SUNXI_CCU) += ccu_reset.o
# Base clock types # Base clock types
obj-$(CONFIG_SUNXI_CCU_DIV) += ccu_div.o lib-$(CONFIG_SUNXI_CCU) += ccu_div.o
obj-$(CONFIG_SUNXI_CCU_FRAC) += ccu_frac.o lib-$(CONFIG_SUNXI_CCU) += ccu_frac.o
obj-$(CONFIG_SUNXI_CCU_GATE) += ccu_gate.o lib-$(CONFIG_SUNXI_CCU) += ccu_gate.o
obj-$(CONFIG_SUNXI_CCU_MUX) += ccu_mux.o lib-$(CONFIG_SUNXI_CCU) += ccu_mux.o
obj-$(CONFIG_SUNXI_CCU_MULT) += ccu_mult.o lib-$(CONFIG_SUNXI_CCU) += ccu_mult.o
obj-$(CONFIG_SUNXI_CCU_PHASE) += ccu_phase.o lib-$(CONFIG_SUNXI_CCU) += ccu_phase.o
# Multi-factor clocks # Multi-factor clocks
obj-$(CONFIG_SUNXI_CCU_NK) += ccu_nk.o lib-$(CONFIG_SUNXI_CCU) += ccu_nk.o
obj-$(CONFIG_SUNXI_CCU_NKM) += ccu_nkm.o lib-$(CONFIG_SUNXI_CCU) += ccu_nkm.o
obj-$(CONFIG_SUNXI_CCU_NKMP) += ccu_nkmp.o lib-$(CONFIG_SUNXI_CCU) += ccu_nkmp.o
obj-$(CONFIG_SUNXI_CCU_NM) += ccu_nm.o lib-$(CONFIG_SUNXI_CCU) += ccu_nm.o
obj-$(CONFIG_SUNXI_CCU_MP) += ccu_mp.o lib-$(CONFIG_SUNXI_CCU) += ccu_mp.o
# SoC support # SoC support
obj-$(CONFIG_SUN50I_A64_CCU) += ccu-sun50i-a64.o obj-$(CONFIG_SUN50I_A64_CCU) += ccu-sun50i-a64.o
...@@ -23,9 +23,20 @@ obj-$(CONFIG_SUN5I_CCU) += ccu-sun5i.o ...@@ -23,9 +23,20 @@ obj-$(CONFIG_SUN5I_CCU) += ccu-sun5i.o
obj-$(CONFIG_SUN6I_A31_CCU) += ccu-sun6i-a31.o obj-$(CONFIG_SUN6I_A31_CCU) += ccu-sun6i-a31.o
obj-$(CONFIG_SUN8I_A23_CCU) += ccu-sun8i-a23.o obj-$(CONFIG_SUN8I_A23_CCU) += ccu-sun8i-a23.o
obj-$(CONFIG_SUN8I_A33_CCU) += ccu-sun8i-a33.o obj-$(CONFIG_SUN8I_A33_CCU) += ccu-sun8i-a33.o
obj-$(CONFIG_SUN8I_A83T_CCU) += ccu-sun8i-a83t.o
obj-$(CONFIG_SUN8I_H3_CCU) += ccu-sun8i-h3.o obj-$(CONFIG_SUN8I_H3_CCU) += ccu-sun8i-h3.o
obj-$(CONFIG_SUN8I_V3S_CCU) += ccu-sun8i-v3s.o obj-$(CONFIG_SUN8I_V3S_CCU) += ccu-sun8i-v3s.o
obj-$(CONFIG_SUN8I_DE2_CCU) += ccu-sun8i-de2.o
obj-$(CONFIG_SUN8I_R_CCU) += ccu-sun8i-r.o obj-$(CONFIG_SUN8I_R_CCU) += ccu-sun8i-r.o
obj-$(CONFIG_SUN9I_A80_CCU) += ccu-sun9i-a80.o obj-$(CONFIG_SUN9I_A80_CCU) += ccu-sun9i-a80.o
obj-$(CONFIG_SUN9I_A80_CCU) += ccu-sun9i-a80-de.o obj-$(CONFIG_SUN9I_A80_CCU) += ccu-sun9i-a80-de.o
obj-$(CONFIG_SUN9I_A80_CCU) += ccu-sun9i-a80-usb.o obj-$(CONFIG_SUN9I_A80_CCU) += ccu-sun9i-a80-usb.o
# The lib-y file goals is supposed to work only in arch/*/lib or lib/. In our
# case, we want to use that goal, but even though lib.a will be properly
# generated, it will not be linked in, eventually resulting in a linker error
# for missing symbols.
#
# We can work around that by explicitly adding lib.a to the obj-y goal. This is
# an undocumented behaviour, but works well for now.
obj-$(CONFIG_SUNXI_CCU) += lib.a
...@@ -211,6 +211,9 @@ static SUNXI_CCU_M(axi_clk, "axi", "cpux", 0x050, 0, 2, 0); ...@@ -211,6 +211,9 @@ static SUNXI_CCU_M(axi_clk, "axi", "cpux", 0x050, 0, 2, 0);
static const char * const ahb1_parents[] = { "osc32k", "osc24M", static const char * const ahb1_parents[] = { "osc32k", "osc24M",
"axi", "pll-periph0" }; "axi", "pll-periph0" };
static const struct ccu_mux_var_prediv ahb1_predivs[] = {
{ .index = 3, .shift = 6, .width = 2 },
};
static struct ccu_div ahb1_clk = { static struct ccu_div ahb1_clk = {
.div = _SUNXI_CCU_DIV_FLAGS(4, 2, CLK_DIVIDER_POWER_OF_TWO), .div = _SUNXI_CCU_DIV_FLAGS(4, 2, CLK_DIVIDER_POWER_OF_TWO),
...@@ -218,11 +221,8 @@ static struct ccu_div ahb1_clk = { ...@@ -218,11 +221,8 @@ static struct ccu_div ahb1_clk = {
.shift = 12, .shift = 12,
.width = 2, .width = 2,
.variable_prediv = { .var_predivs = ahb1_predivs,
.index = 3, .n_var_predivs = ARRAY_SIZE(ahb1_predivs),
.shift = 6,
.width = 2,
},
}, },
.common = { .common = {
......
...@@ -28,15 +28,17 @@ ...@@ -28,15 +28,17 @@
#define CLK_PLL_AUDIO_4X 6 #define CLK_PLL_AUDIO_4X 6
#define CLK_PLL_AUDIO_8X 7 #define CLK_PLL_AUDIO_8X 7
#define CLK_PLL_VIDEO0 8 #define CLK_PLL_VIDEO0 8
#define CLK_PLL_VIDEO0_2X 9
/* The PLL_VIDEO0_2X is exported for HDMI */
#define CLK_PLL_VE 10 #define CLK_PLL_VE 10
#define CLK_PLL_DDR_BASE 11 #define CLK_PLL_DDR_BASE 11
#define CLK_PLL_DDR 12 #define CLK_PLL_DDR 12
#define CLK_PLL_DDR_OTHER 13 #define CLK_PLL_DDR_OTHER 13
#define CLK_PLL_PERIPH 14 #define CLK_PLL_PERIPH 14
#define CLK_PLL_VIDEO1 15 #define CLK_PLL_VIDEO1 15
#define CLK_PLL_VIDEO1_2X 16
/* The PLL_VIDEO1_2X is exported for HDMI */
/* The CPU clock is exported */ /* The CPU clock is exported */
#define CLK_AXI 18 #define CLK_AXI 18
......
...@@ -195,6 +195,9 @@ static SUNXI_CCU_DIV_TABLE(axi_clk, "axi", "cpu", ...@@ -195,6 +195,9 @@ static SUNXI_CCU_DIV_TABLE(axi_clk, "axi", "cpu",
static const char * const ahb1_parents[] = { "osc32k", "osc24M", static const char * const ahb1_parents[] = { "osc32k", "osc24M",
"axi", "pll-periph" }; "axi", "pll-periph" };
static const struct ccu_mux_var_prediv ahb1_predivs[] = {
{ .index = 3, .shift = 6, .width = 2 },
};
static struct ccu_div ahb1_clk = { static struct ccu_div ahb1_clk = {
.div = _SUNXI_CCU_DIV_FLAGS(4, 2, CLK_DIVIDER_POWER_OF_TWO), .div = _SUNXI_CCU_DIV_FLAGS(4, 2, CLK_DIVIDER_POWER_OF_TWO),
...@@ -203,11 +206,8 @@ static struct ccu_div ahb1_clk = { ...@@ -203,11 +206,8 @@ static struct ccu_div ahb1_clk = {
.shift = 12, .shift = 12,
.width = 2, .width = 2,
.variable_prediv = { .var_predivs = ahb1_predivs,
.index = 3, .n_var_predivs = ARRAY_SIZE(ahb1_predivs),
.shift = 6,
.width = 2,
},
}, },
.common = { .common = {
......
...@@ -169,6 +169,9 @@ static SUNXI_CCU_M(axi_clk, "axi", "cpux", 0x050, 0, 2, 0); ...@@ -169,6 +169,9 @@ static SUNXI_CCU_M(axi_clk, "axi", "cpux", 0x050, 0, 2, 0);
static const char * const ahb1_parents[] = { "osc32k", "osc24M", static const char * const ahb1_parents[] = { "osc32k", "osc24M",
"axi" , "pll-periph" }; "axi" , "pll-periph" };
static const struct ccu_mux_var_prediv ahb1_predivs[] = {
{ .index = 3, .shift = 6, .width = 2 },
};
static struct ccu_div ahb1_clk = { static struct ccu_div ahb1_clk = {
.div = _SUNXI_CCU_DIV_FLAGS(4, 2, CLK_DIVIDER_POWER_OF_TWO), .div = _SUNXI_CCU_DIV_FLAGS(4, 2, CLK_DIVIDER_POWER_OF_TWO),
...@@ -176,11 +179,8 @@ static struct ccu_div ahb1_clk = { ...@@ -176,11 +179,8 @@ static struct ccu_div ahb1_clk = {
.shift = 12, .shift = 12,
.width = 2, .width = 2,
.variable_prediv = { .var_predivs = ahb1_predivs,
.index = 3, .n_var_predivs = ARRAY_SIZE(ahb1_predivs),
.shift = 6,
.width = 2,
},
}, },
.common = { .common = {
......
...@@ -180,6 +180,9 @@ static SUNXI_CCU_M(axi_clk, "axi", "cpux", 0x050, 0, 2, 0); ...@@ -180,6 +180,9 @@ static SUNXI_CCU_M(axi_clk, "axi", "cpux", 0x050, 0, 2, 0);
static const char * const ahb1_parents[] = { "osc32k", "osc24M", static const char * const ahb1_parents[] = { "osc32k", "osc24M",
"axi" , "pll-periph" }; "axi" , "pll-periph" };
static const struct ccu_mux_var_prediv ahb1_predivs[] = {
{ .index = 3, .shift = 6, .width = 2 },
};
static struct ccu_div ahb1_clk = { static struct ccu_div ahb1_clk = {
.div = _SUNXI_CCU_DIV_FLAGS(4, 2, CLK_DIVIDER_POWER_OF_TWO), .div = _SUNXI_CCU_DIV_FLAGS(4, 2, CLK_DIVIDER_POWER_OF_TWO),
...@@ -187,11 +190,8 @@ static struct ccu_div ahb1_clk = { ...@@ -187,11 +190,8 @@ static struct ccu_div ahb1_clk = {
.shift = 12, .shift = 12,
.width = 2, .width = 2,
.variable_prediv = { .var_predivs = ahb1_predivs,
.index = 3, .n_var_predivs = ARRAY_SIZE(ahb1_predivs),
.shift = 6,
.width = 2,
},
}, },
.common = { .common = {
......
This diff is collapsed.
/*
* Copyright 2016 Chen-Yu Tsai
*
* Chen-Yu Tsai <wens@csie.org>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*/
#ifndef _CCU_SUN8I_A83T_H_
#define _CCU_SUN8I_A83T_H_
#include <dt-bindings/clock/sun8i-a83t-ccu.h>
#include <dt-bindings/reset/sun8i-a83t-ccu.h>
#define CLK_PLL_C0CPUX 0
#define CLK_PLL_C1CPUX 1
#define CLK_PLL_AUDIO 2
#define CLK_PLL_VIDEO0 3
#define CLK_PLL_VE 4
#define CLK_PLL_DDR 5
/* pll-periph is exported to the PRCM block */
#define CLK_PLL_GPU 7
#define CLK_PLL_HSIC 8
/* pll-de is exported for the display engine */
#define CLK_PLL_VIDEO1 10
/* The CPUX clocks are exported */
#define CLK_AXI0 13
#define CLK_AXI1 14
#define CLK_AHB1 15
#define CLK_AHB2 16
#define CLK_APB1 17
#define CLK_APB2 18
/* bus gates exported */
#define CLK_CCI400 58
/* module and usb clocks exported */
#define CLK_DRAM 82
/* dram gates and more module clocks exported */
#define CLK_MBUS 95
/* more module clocks exported */
#define CLK_NUMBER (CLK_GPU_HYD + 1)
#endif /* _CCU_SUN8I_A83T_H_ */
/*
* Copyright (c) 2017 Icenowy Zheng <icenowy@aosc.io>
*
* This software is licensed under the terms of the GNU General Public
* License version 2, as published by the Free Software Foundation, and
* may be copied, distributed, and modified under those terms.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*/
#include <linux/clk.h>
#include <linux/clk-provider.h>
#include <linux/of_address.h>
#include <linux/of_platform.h>
#include <linux/platform_device.h>
#include <linux/reset.h>
#include "ccu_common.h"
#include "ccu_div.h"
#include "ccu_gate.h"
#include "ccu_reset.h"
#include "ccu-sun8i-de2.h"
static SUNXI_CCU_GATE(bus_mixer0_clk, "bus-mixer0", "bus-de",
0x04, BIT(0), 0);
static SUNXI_CCU_GATE(bus_mixer1_clk, "bus-mixer1", "bus-de",
0x04, BIT(1), 0);
static SUNXI_CCU_GATE(bus_wb_clk, "bus-wb", "bus-de",
0x04, BIT(2), 0);
static SUNXI_CCU_GATE(mixer0_clk, "mixer0", "mixer0-div",
0x00, BIT(0), CLK_SET_RATE_PARENT);
static SUNXI_CCU_GATE(mixer1_clk, "mixer1", "mixer1-div",
0x00, BIT(1), CLK_SET_RATE_PARENT);
static SUNXI_CCU_GATE(wb_clk, "wb", "wb-div",
0x00, BIT(2), CLK_SET_RATE_PARENT);
static SUNXI_CCU_M(mixer0_div_clk, "mixer0-div", "de", 0x0c, 0, 4,
CLK_SET_RATE_PARENT);
static SUNXI_CCU_M(mixer1_div_clk, "mixer1-div", "de", 0x0c, 4, 4,
CLK_SET_RATE_PARENT);
static SUNXI_CCU_M(wb_div_clk, "wb-div", "de", 0x0c, 8, 4,
CLK_SET_RATE_PARENT);
static struct ccu_common *sun8i_a83t_de2_clks[] = {
&mixer0_clk.common,
&mixer1_clk.common,
&wb_clk.common,
&bus_mixer0_clk.common,
&bus_mixer1_clk.common,
&bus_wb_clk.common,
&mixer0_div_clk.common,
&mixer1_div_clk.common,
&wb_div_clk.common,
};
static struct ccu_common *sun8i_v3s_de2_clks[] = {
&mixer0_clk.common,
&wb_clk.common,
&bus_mixer0_clk.common,
&bus_wb_clk.common,
&mixer0_div_clk.common,
&wb_div_clk.common,
};
static struct clk_hw_onecell_data sun8i_a83t_de2_hw_clks = {
.hws = {
[CLK_MIXER0] = &mixer0_clk.common.hw,
[CLK_MIXER1] = &mixer1_clk.common.hw,
[CLK_WB] = &wb_clk.common.hw,
[CLK_BUS_MIXER0] = &bus_mixer0_clk.common.hw,
[CLK_BUS_MIXER1] = &bus_mixer1_clk.common.hw,
[CLK_BUS_WB] = &bus_wb_clk.common.hw,
[CLK_MIXER0_DIV] = &mixer0_div_clk.common.hw,
[CLK_MIXER1_DIV] = &mixer1_div_clk.common.hw,
[CLK_WB_DIV] = &wb_div_clk.common.hw,
},
.num = CLK_NUMBER,
};
static struct clk_hw_onecell_data sun8i_v3s_de2_hw_clks = {
.hws = {
[CLK_MIXER0] = &mixer0_clk.common.hw,
[CLK_WB] = &wb_clk.common.hw,
[CLK_BUS_MIXER0] = &bus_mixer0_clk.common.hw,
[CLK_BUS_WB] = &bus_wb_clk.common.hw,
[CLK_MIXER0_DIV] = &mixer0_div_clk.common.hw,
[CLK_WB_DIV] = &wb_div_clk.common.hw,
},
.num = CLK_NUMBER,
};
static struct ccu_reset_map sun8i_a83t_de2_resets[] = {
[RST_MIXER0] = { 0x08, BIT(0) },
/*
* For A83T, H3 and R40, mixer1 reset line is shared with wb, so
* only RST_WB is exported here.
* For V3s there's just no mixer1, so it also shares this struct.
*/
[RST_WB] = { 0x08, BIT(2) },
};
static struct ccu_reset_map sun50i_a64_de2_resets[] = {
[RST_MIXER0] = { 0x08, BIT(0) },
[RST_MIXER1] = { 0x08, BIT(1) },
[RST_WB] = { 0x08, BIT(2) },
};
static const struct sunxi_ccu_desc sun8i_a83t_de2_clk_desc = {
.ccu_clks = sun8i_a83t_de2_clks,
.num_ccu_clks = ARRAY_SIZE(sun8i_a83t_de2_clks),
.hw_clks = &sun8i_a83t_de2_hw_clks,
.resets = sun8i_a83t_de2_resets,
.num_resets = ARRAY_SIZE(sun8i_a83t_de2_resets),
};
static const struct sunxi_ccu_desc sun50i_a64_de2_clk_desc = {
.ccu_clks = sun8i_a83t_de2_clks,
.num_ccu_clks = ARRAY_SIZE(sun8i_a83t_de2_clks),
.hw_clks = &sun8i_a83t_de2_hw_clks,
.resets = sun50i_a64_de2_resets,
.num_resets = ARRAY_SIZE(sun50i_a64_de2_resets),
};
static const struct sunxi_ccu_desc sun8i_v3s_de2_clk_desc = {
.ccu_clks = sun8i_v3s_de2_clks,
.num_ccu_clks = ARRAY_SIZE(sun8i_v3s_de2_clks),
.hw_clks = &sun8i_v3s_de2_hw_clks,
.resets = sun8i_a83t_de2_resets,
.num_resets = ARRAY_SIZE(sun8i_a83t_de2_resets),
};
static int sunxi_de2_clk_probe(struct platform_device *pdev)
{
struct resource *res;
struct clk *bus_clk, *mod_clk;
struct reset_control *rstc;
void __iomem *reg;
const struct sunxi_ccu_desc *ccu_desc;
int ret;
ccu_desc = of_device_get_match_data(&pdev->dev);
if (!ccu_desc)
return -EINVAL;
res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
reg = devm_ioremap_resource(&pdev->dev, res);
if (IS_ERR(reg))
return PTR_ERR(reg);
bus_clk = devm_clk_get(&pdev->dev, "bus");
if (IS_ERR(bus_clk)) {
ret = PTR_ERR(bus_clk);
if (ret != -EPROBE_DEFER)
dev_err(&pdev->dev, "Couldn't get bus clk: %d\n", ret);
return ret;
}
mod_clk = devm_clk_get(&pdev->dev, "mod");
if (IS_ERR(mod_clk)) {
ret = PTR_ERR(mod_clk);
if (ret != -EPROBE_DEFER)
dev_err(&pdev->dev, "Couldn't get mod clk: %d\n", ret);
return ret;
}
rstc = devm_reset_control_get_exclusive(&pdev->dev, NULL);
if (IS_ERR(rstc)) {
ret = PTR_ERR(rstc);
if (ret != -EPROBE_DEFER)
dev_err(&pdev->dev,
"Couldn't get reset control: %d\n", ret);
return ret;
}
/* The clocks need to be enabled for us to access the registers */
ret = clk_prepare_enable(bus_clk);
if (ret) {
dev_err(&pdev->dev, "Couldn't enable bus clk: %d\n", ret);
return ret;
}
ret = clk_prepare_enable(mod_clk);
if (ret) {
dev_err(&pdev->dev, "Couldn't enable mod clk: %d\n", ret);
goto err_disable_bus_clk;
}
/* The reset control needs to be asserted for the controls to work */
ret = reset_control_deassert(rstc);
if (ret) {
dev_err(&pdev->dev,
"Couldn't deassert reset control: %d\n", ret);
goto err_disable_mod_clk;
}
ret = sunxi_ccu_probe(pdev->dev.of_node, reg, ccu_desc);
if (ret)
goto err_assert_reset;
return 0;
err_assert_reset:
reset_control_assert(rstc);
err_disable_mod_clk:
clk_disable_unprepare(mod_clk);
err_disable_bus_clk:
clk_disable_unprepare(bus_clk);
return ret;
}
static const struct of_device_id sunxi_de2_clk_ids[] = {
{
.compatible = "allwinner,sun8i-a83t-de2-clk",
.data = &sun8i_a83t_de2_clk_desc,
},
{
.compatible = "allwinner,sun8i-v3s-de2-clk",
.data = &sun8i_v3s_de2_clk_desc,
},
{
.compatible = "allwinner,sun50i-h5-de2-clk",
.data = &sun50i_a64_de2_clk_desc,
},
/*
* The Allwinner A64 SoC needs some bit to be poke in syscon to make
* DE2 really working.
* So there's currently no A64 compatible here.
* H5 shares the same reset line with A64, so here H5 is using the
* clock description of A64.
*/
{ }
};
static struct platform_driver sunxi_de2_clk_driver = {
.probe = sunxi_de2_clk_probe,
.driver = {
.name = "sunxi-de2-clks",
.of_match_table = sunxi_de2_clk_ids,
},
};
builtin_platform_driver(sunxi_de2_clk_driver);
/*
* Copyright 2016 Icenowy Zheng <icenowy@aosc.io>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*/
#ifndef _CCU_SUN8I_DE2_H_
#define _CCU_SUN8I_DE2_H_
#include <dt-bindings/clock/sun8i-de2.h>
#include <dt-bindings/reset/sun8i-de2.h>
/* Intermediary clock dividers are not exported */
#define CLK_MIXER0_DIV 3
#define CLK_MIXER1_DIV 4
#define CLK_WB_DIV 5
#define CLK_NUMBER (CLK_WB + 1)
#endif /* _CCU_SUN8I_DE2_H_ */
...@@ -141,6 +141,9 @@ static SUNXI_CCU_M(axi_clk, "axi", "cpux", 0x050, 0, 2, 0); ...@@ -141,6 +141,9 @@ static SUNXI_CCU_M(axi_clk, "axi", "cpux", 0x050, 0, 2, 0);
static const char * const ahb1_parents[] = { "osc32k", "osc24M", static const char * const ahb1_parents[] = { "osc32k", "osc24M",
"axi" , "pll-periph0" }; "axi" , "pll-periph0" };
static const struct ccu_mux_var_prediv ahb1_predivs[] = {
{ .index = 3, .shift = 6, .width = 2 },
};
static struct ccu_div ahb1_clk = { static struct ccu_div ahb1_clk = {
.div = _SUNXI_CCU_DIV_FLAGS(4, 2, CLK_DIVIDER_POWER_OF_TWO), .div = _SUNXI_CCU_DIV_FLAGS(4, 2, CLK_DIVIDER_POWER_OF_TWO),
...@@ -148,11 +151,8 @@ static struct ccu_div ahb1_clk = { ...@@ -148,11 +151,8 @@ static struct ccu_div ahb1_clk = {
.shift = 12, .shift = 12,
.width = 2, .width = 2,
.variable_prediv = { .var_predivs = ahb1_predivs,
.index = 3, .n_var_predivs = ARRAY_SIZE(ahb1_predivs),
.shift = 6,
.width = 2,
},
}, },
.common = { .common = {
......
...@@ -27,6 +27,11 @@ ...@@ -27,6 +27,11 @@
static const char * const ar100_parents[] = { "osc32k", "osc24M", static const char * const ar100_parents[] = { "osc32k", "osc24M",
"pll-periph0", "iosc" }; "pll-periph0", "iosc" };
static const char * const a83t_ar100_parents[] = { "osc16M-d512", "osc24M",
"pll-periph0", "iosc" };
static const struct ccu_mux_var_prediv ar100_predivs[] = {
{ .index = 2, .shift = 8, .width = 5 },
};
static struct ccu_div ar100_clk = { static struct ccu_div ar100_clk = {
.div = _SUNXI_CCU_DIV_FLAGS(4, 2, CLK_DIVIDER_POWER_OF_TWO), .div = _SUNXI_CCU_DIV_FLAGS(4, 2, CLK_DIVIDER_POWER_OF_TWO),
...@@ -35,11 +40,8 @@ static struct ccu_div ar100_clk = { ...@@ -35,11 +40,8 @@ static struct ccu_div ar100_clk = {
.shift = 16, .shift = 16,
.width = 2, .width = 2,
.variable_prediv = { .var_predivs = ar100_predivs,
.index = 2, .n_var_predivs = ARRAY_SIZE(ar100_predivs),
.shift = 8,
.width = 5,
},
}, },
.common = { .common = {
...@@ -52,6 +54,27 @@ static struct ccu_div ar100_clk = { ...@@ -52,6 +54,27 @@ static struct ccu_div ar100_clk = {
}, },
}; };
static struct ccu_div a83t_ar100_clk = {
.div = _SUNXI_CCU_DIV_FLAGS(4, 2, CLK_DIVIDER_POWER_OF_TWO),
.mux = {
.shift = 16,
.width = 2,
.var_predivs = ar100_predivs,
.n_var_predivs = ARRAY_SIZE(ar100_predivs),
},
.common = {
.reg = 0x00,
.features = CCU_FEATURE_VARIABLE_PREDIV,
.hw.init = CLK_HW_INIT_PARENTS("ar100",
a83t_ar100_parents,
&ccu_div_ops,
0),
},
};
static CLK_FIXED_FACTOR(ahb0_clk, "ahb0", "ar100", 1, 1, 0); static CLK_FIXED_FACTOR(ahb0_clk, "ahb0", "ar100", 1, 1, 0);
static struct ccu_div apb0_clk = { static struct ccu_div apb0_clk = {
...@@ -66,6 +89,8 @@ static struct ccu_div apb0_clk = { ...@@ -66,6 +89,8 @@ static struct ccu_div apb0_clk = {
}, },
}; };
static SUNXI_CCU_M(a83t_apb0_clk, "apb0", "ahb0", 0x0c, 0, 2, 0);
static SUNXI_CCU_GATE(apb0_pio_clk, "apb0-pio", "apb0", static SUNXI_CCU_GATE(apb0_pio_clk, "apb0-pio", "apb0",
0x28, BIT(0), 0); 0x28, BIT(0), 0);
static SUNXI_CCU_GATE(apb0_ir_clk, "apb0-ir", "apb0", static SUNXI_CCU_GATE(apb0_ir_clk, "apb0-ir", "apb0",
...@@ -90,6 +115,46 @@ static SUNXI_CCU_MP_WITH_MUX_GATE(ir_clk, "ir", ...@@ -90,6 +115,46 @@ static SUNXI_CCU_MP_WITH_MUX_GATE(ir_clk, "ir",
BIT(31), /* gate */ BIT(31), /* gate */
0); 0);
static const char *const a83t_r_mod0_parents[] = { "osc16M", "osc24M" };
static const struct ccu_mux_fixed_prediv a83t_ir_predivs[] = {
{ .index = 0, .div = 16 },
};
static struct ccu_mp a83t_ir_clk = {
.enable = BIT(31),
.m = _SUNXI_CCU_DIV(0, 4),
.p = _SUNXI_CCU_DIV(16, 2),
.mux = {
.shift = 24,
.width = 2,
.fixed_predivs = a83t_ir_predivs,
.n_predivs = ARRAY_SIZE(a83t_ir_predivs),
},
.common = {
.reg = 0x54,
.features = CCU_FEATURE_VARIABLE_PREDIV,
.hw.init = CLK_HW_INIT_PARENTS("ir",
a83t_r_mod0_parents,
&ccu_mp_ops,
0),
},
};
static struct ccu_common *sun8i_a83t_r_ccu_clks[] = {
&a83t_ar100_clk.common,
&a83t_apb0_clk.common,
&apb0_pio_clk.common,
&apb0_ir_clk.common,
&apb0_timer_clk.common,
&apb0_rsb_clk.common,
&apb0_uart_clk.common,
&apb0_i2c_clk.common,
&apb0_twd_clk.common,
&a83t_ir_clk.common,
};
static struct ccu_common *sun8i_h3_r_ccu_clks[] = { static struct ccu_common *sun8i_h3_r_ccu_clks[] = {
&ar100_clk.common, &ar100_clk.common,
&apb0_clk.common, &apb0_clk.common,
...@@ -115,6 +180,23 @@ static struct ccu_common *sun50i_a64_r_ccu_clks[] = { ...@@ -115,6 +180,23 @@ static struct ccu_common *sun50i_a64_r_ccu_clks[] = {
&ir_clk.common, &ir_clk.common,
}; };
static struct clk_hw_onecell_data sun8i_a83t_r_hw_clks = {
.hws = {
[CLK_AR100] = &a83t_ar100_clk.common.hw,
[CLK_AHB0] = &ahb0_clk.hw,
[CLK_APB0] = &a83t_apb0_clk.common.hw,
[CLK_APB0_PIO] = &apb0_pio_clk.common.hw,
[CLK_APB0_IR] = &apb0_ir_clk.common.hw,
[CLK_APB0_TIMER] = &apb0_timer_clk.common.hw,
[CLK_APB0_RSB] = &apb0_rsb_clk.common.hw,
[CLK_APB0_UART] = &apb0_uart_clk.common.hw,
[CLK_APB0_I2C] = &apb0_i2c_clk.common.hw,
[CLK_APB0_TWD] = &apb0_twd_clk.common.hw,
[CLK_IR] = &a83t_ir_clk.common.hw,
},
.num = CLK_NUMBER,
};
static struct clk_hw_onecell_data sun8i_h3_r_hw_clks = { static struct clk_hw_onecell_data sun8i_h3_r_hw_clks = {
.hws = { .hws = {
[CLK_AR100] = &ar100_clk.common.hw, [CLK_AR100] = &ar100_clk.common.hw,
...@@ -148,6 +230,14 @@ static struct clk_hw_onecell_data sun50i_a64_r_hw_clks = { ...@@ -148,6 +230,14 @@ static struct clk_hw_onecell_data sun50i_a64_r_hw_clks = {
.num = CLK_NUMBER, .num = CLK_NUMBER,
}; };
static struct ccu_reset_map sun8i_a83t_r_ccu_resets[] = {
[RST_APB0_IR] = { 0xb0, BIT(1) },
[RST_APB0_TIMER] = { 0xb0, BIT(2) },
[RST_APB0_RSB] = { 0xb0, BIT(3) },
[RST_APB0_UART] = { 0xb0, BIT(4) },
[RST_APB0_I2C] = { 0xb0, BIT(6) },
};
static struct ccu_reset_map sun8i_h3_r_ccu_resets[] = { static struct ccu_reset_map sun8i_h3_r_ccu_resets[] = {
[RST_APB0_IR] = { 0xb0, BIT(1) }, [RST_APB0_IR] = { 0xb0, BIT(1) },
[RST_APB0_TIMER] = { 0xb0, BIT(2) }, [RST_APB0_TIMER] = { 0xb0, BIT(2) },
...@@ -163,6 +253,16 @@ static struct ccu_reset_map sun50i_a64_r_ccu_resets[] = { ...@@ -163,6 +253,16 @@ static struct ccu_reset_map sun50i_a64_r_ccu_resets[] = {
[RST_APB0_I2C] = { 0xb0, BIT(6) }, [RST_APB0_I2C] = { 0xb0, BIT(6) },
}; };
static const struct sunxi_ccu_desc sun8i_a83t_r_ccu_desc = {
.ccu_clks = sun8i_a83t_r_ccu_clks,
.num_ccu_clks = ARRAY_SIZE(sun8i_a83t_r_ccu_clks),
.hw_clks = &sun8i_a83t_r_hw_clks,
.resets = sun8i_a83t_r_ccu_resets,
.num_resets = ARRAY_SIZE(sun8i_a83t_r_ccu_resets),
};
static const struct sunxi_ccu_desc sun8i_h3_r_ccu_desc = { static const struct sunxi_ccu_desc sun8i_h3_r_ccu_desc = {
.ccu_clks = sun8i_h3_r_ccu_clks, .ccu_clks = sun8i_h3_r_ccu_clks,
.num_ccu_clks = ARRAY_SIZE(sun8i_h3_r_ccu_clks), .num_ccu_clks = ARRAY_SIZE(sun8i_h3_r_ccu_clks),
...@@ -198,6 +298,13 @@ static void __init sunxi_r_ccu_init(struct device_node *node, ...@@ -198,6 +298,13 @@ static void __init sunxi_r_ccu_init(struct device_node *node,
sunxi_ccu_probe(node, reg, desc); sunxi_ccu_probe(node, reg, desc);
} }
static void __init sun8i_a83t_r_ccu_setup(struct device_node *node)
{
sunxi_r_ccu_init(node, &sun8i_a83t_r_ccu_desc);
}
CLK_OF_DECLARE(sun8i_a83t_r_ccu, "allwinner,sun8i-a83t-r-ccu",
sun8i_a83t_r_ccu_setup);
static void __init sun8i_h3_r_ccu_setup(struct device_node *node) static void __init sun8i_h3_r_ccu_setup(struct device_node *node)
{ {
sunxi_r_ccu_init(node, &sun8i_h3_r_ccu_desc); sunxi_r_ccu_init(node, &sun8i_h3_r_ccu_desc);
......
...@@ -132,6 +132,9 @@ static SUNXI_CCU_M(axi_clk, "axi", "cpu", 0x050, 0, 2, 0); ...@@ -132,6 +132,9 @@ static SUNXI_CCU_M(axi_clk, "axi", "cpu", 0x050, 0, 2, 0);
static const char * const ahb1_parents[] = { "osc32k", "osc24M", static const char * const ahb1_parents[] = { "osc32k", "osc24M",
"axi", "pll-periph0" }; "axi", "pll-periph0" };
static const struct ccu_mux_var_prediv ahb1_predivs[] = {
{ .index = 3, .shift = 6, .width = 2 },
};
static struct ccu_div ahb1_clk = { static struct ccu_div ahb1_clk = {
.div = _SUNXI_CCU_DIV_FLAGS(4, 2, CLK_DIVIDER_POWER_OF_TWO), .div = _SUNXI_CCU_DIV_FLAGS(4, 2, CLK_DIVIDER_POWER_OF_TWO),
...@@ -139,11 +142,8 @@ static struct ccu_div ahb1_clk = { ...@@ -139,11 +142,8 @@ static struct ccu_div ahb1_clk = {
.shift = 12, .shift = 12,
.width = 2, .width = 2,
.variable_prediv = { .var_predivs = ahb1_predivs,
.index = 3, .n_var_predivs = ARRAY_SIZE(ahb1_predivs),
.shift = 6,
.width = 2,
},
}, },
.common = { .common = {
......
...@@ -14,23 +14,17 @@ ...@@ -14,23 +14,17 @@
#include "ccu_div.h" #include "ccu_div.h"
static unsigned long ccu_div_round_rate(struct ccu_mux_internal *mux, static unsigned long ccu_div_round_rate(struct ccu_mux_internal *mux,
unsigned long parent_rate, struct clk_hw *parent,
unsigned long *parent_rate,
unsigned long rate, unsigned long rate,
void *data) void *data)
{ {
struct ccu_div *cd = data; struct ccu_div *cd = data;
unsigned long val;
/*
* We can't use divider_round_rate that assumes that there's
* several parents, while we might be called to evaluate
* several different parents.
*/
val = divider_get_val(rate, parent_rate, cd->div.table, cd->div.width,
cd->div.flags);
return divider_recalc_rate(&cd->common.hw, parent_rate, val, return divider_round_rate_parent(&cd->common.hw, parent,
cd->div.table, cd->div.flags); rate, parent_rate,
cd->div.table, cd->div.width,
cd->div.flags);
} }
static void ccu_div_disable(struct clk_hw *hw) static void ccu_div_disable(struct clk_hw *hw)
...@@ -65,8 +59,8 @@ static unsigned long ccu_div_recalc_rate(struct clk_hw *hw, ...@@ -65,8 +59,8 @@ static unsigned long ccu_div_recalc_rate(struct clk_hw *hw,
val = reg >> cd->div.shift; val = reg >> cd->div.shift;
val &= (1 << cd->div.width) - 1; val &= (1 << cd->div.width) - 1;
ccu_mux_helper_adjust_parent_for_prediv(&cd->common, &cd->mux, -1, parent_rate = ccu_mux_helper_apply_prediv(&cd->common, &cd->mux, -1,
&parent_rate); parent_rate);
return divider_recalc_rate(hw, parent_rate, val, cd->div.table, return divider_recalc_rate(hw, parent_rate, val, cd->div.table,
cd->div.flags); cd->div.flags);
...@@ -77,18 +71,6 @@ static int ccu_div_determine_rate(struct clk_hw *hw, ...@@ -77,18 +71,6 @@ static int ccu_div_determine_rate(struct clk_hw *hw,
{ {
struct ccu_div *cd = hw_to_ccu_div(hw); struct ccu_div *cd = hw_to_ccu_div(hw);
if (clk_hw_get_num_parents(hw) == 1) {
req->rate = divider_round_rate(hw, req->rate,
&req->best_parent_rate,
cd->div.table,
cd->div.width,
cd->div.flags);
req->best_parent_hw = clk_hw_get_parent(hw);
return 0;
}
return ccu_mux_helper_determine_rate(&cd->common, &cd->mux, return ccu_mux_helper_determine_rate(&cd->common, &cd->mux,
req, ccu_div_round_rate, cd); req, ccu_div_round_rate, cd);
} }
...@@ -101,8 +83,8 @@ static int ccu_div_set_rate(struct clk_hw *hw, unsigned long rate, ...@@ -101,8 +83,8 @@ static int ccu_div_set_rate(struct clk_hw *hw, unsigned long rate,
unsigned long val; unsigned long val;
u32 reg; u32 reg;
ccu_mux_helper_adjust_parent_for_prediv(&cd->common, &cd->mux, -1, parent_rate = ccu_mux_helper_apply_prediv(&cd->common, &cd->mux, -1,
&parent_rate); parent_rate);
val = divider_get_val(rate, parent_rate, cd->div.table, cd->div.width, val = divider_get_val(rate, parent_rate, cd->div.table, cd->div.width,
cd->div.flags); cd->div.flags);
......
...@@ -41,7 +41,8 @@ static void ccu_mp_find_best(unsigned long parent, unsigned long rate, ...@@ -41,7 +41,8 @@ static void ccu_mp_find_best(unsigned long parent, unsigned long rate,
} }
static unsigned long ccu_mp_round_rate(struct ccu_mux_internal *mux, static unsigned long ccu_mp_round_rate(struct ccu_mux_internal *mux,
unsigned long parent_rate, struct clk_hw *hw,
unsigned long *parent_rate,
unsigned long rate, unsigned long rate,
void *data) void *data)
{ {
...@@ -52,9 +53,9 @@ static unsigned long ccu_mp_round_rate(struct ccu_mux_internal *mux, ...@@ -52,9 +53,9 @@ static unsigned long ccu_mp_round_rate(struct ccu_mux_internal *mux,
max_m = cmp->m.max ?: 1 << cmp->m.width; max_m = cmp->m.max ?: 1 << cmp->m.width;
max_p = cmp->p.max ?: 1 << ((1 << cmp->p.width) - 1); max_p = cmp->p.max ?: 1 << ((1 << cmp->p.width) - 1);
ccu_mp_find_best(parent_rate, rate, max_m, max_p, &m, &p); ccu_mp_find_best(*parent_rate, rate, max_m, max_p, &m, &p);
return parent_rate / p / m; return *parent_rate / p / m;
} }
static void ccu_mp_disable(struct clk_hw *hw) static void ccu_mp_disable(struct clk_hw *hw)
...@@ -86,8 +87,8 @@ static unsigned long ccu_mp_recalc_rate(struct clk_hw *hw, ...@@ -86,8 +87,8 @@ static unsigned long ccu_mp_recalc_rate(struct clk_hw *hw,
u32 reg; u32 reg;
/* Adjust parent_rate according to pre-dividers */ /* Adjust parent_rate according to pre-dividers */
ccu_mux_helper_adjust_parent_for_prediv(&cmp->common, &cmp->mux, parent_rate = ccu_mux_helper_apply_prediv(&cmp->common, &cmp->mux, -1,
-1, &parent_rate); parent_rate);
reg = readl(cmp->common.base + cmp->common.reg); reg = readl(cmp->common.base + cmp->common.reg);
...@@ -122,8 +123,8 @@ static int ccu_mp_set_rate(struct clk_hw *hw, unsigned long rate, ...@@ -122,8 +123,8 @@ static int ccu_mp_set_rate(struct clk_hw *hw, unsigned long rate,
u32 reg; u32 reg;
/* Adjust parent_rate according to pre-dividers */ /* Adjust parent_rate according to pre-dividers */
ccu_mux_helper_adjust_parent_for_prediv(&cmp->common, &cmp->mux, parent_rate = ccu_mux_helper_apply_prediv(&cmp->common, &cmp->mux, -1,
-1, &parent_rate); parent_rate);
max_m = cmp->m.max ?: 1 << cmp->m.width; max_m = cmp->m.max ?: 1 << cmp->m.width;
max_p = cmp->p.max ?: 1 << ((1 << cmp->p.width) - 1); max_p = cmp->p.max ?: 1 << ((1 << cmp->p.width) - 1);
......
...@@ -33,9 +33,10 @@ static void ccu_mult_find_best(unsigned long parent, unsigned long rate, ...@@ -33,9 +33,10 @@ static void ccu_mult_find_best(unsigned long parent, unsigned long rate,
} }
static unsigned long ccu_mult_round_rate(struct ccu_mux_internal *mux, static unsigned long ccu_mult_round_rate(struct ccu_mux_internal *mux,
unsigned long parent_rate, struct clk_hw *parent,
unsigned long rate, unsigned long *parent_rate,
void *data) unsigned long rate,
void *data)
{ {
struct ccu_mult *cm = data; struct ccu_mult *cm = data;
struct _ccu_mult _cm; struct _ccu_mult _cm;
...@@ -47,9 +48,9 @@ static unsigned long ccu_mult_round_rate(struct ccu_mux_internal *mux, ...@@ -47,9 +48,9 @@ static unsigned long ccu_mult_round_rate(struct ccu_mux_internal *mux,
else else
_cm.max = (1 << cm->mult.width) + cm->mult.offset - 1; _cm.max = (1 << cm->mult.width) + cm->mult.offset - 1;
ccu_mult_find_best(parent_rate, rate, &_cm); ccu_mult_find_best(*parent_rate, rate, &_cm);
return parent_rate * _cm.mult; return *parent_rate * _cm.mult;
} }
static void ccu_mult_disable(struct clk_hw *hw) static void ccu_mult_disable(struct clk_hw *hw)
...@@ -87,8 +88,8 @@ static unsigned long ccu_mult_recalc_rate(struct clk_hw *hw, ...@@ -87,8 +88,8 @@ static unsigned long ccu_mult_recalc_rate(struct clk_hw *hw,
val = reg >> cm->mult.shift; val = reg >> cm->mult.shift;
val &= (1 << cm->mult.width) - 1; val &= (1 << cm->mult.width) - 1;
ccu_mux_helper_adjust_parent_for_prediv(&cm->common, &cm->mux, -1, parent_rate = ccu_mux_helper_apply_prediv(&cm->common, &cm->mux, -1,
&parent_rate); parent_rate);
return parent_rate * (val + cm->mult.offset); return parent_rate * (val + cm->mult.offset);
} }
...@@ -115,8 +116,8 @@ static int ccu_mult_set_rate(struct clk_hw *hw, unsigned long rate, ...@@ -115,8 +116,8 @@ static int ccu_mult_set_rate(struct clk_hw *hw, unsigned long rate,
else else
ccu_frac_helper_disable(&cm->common, &cm->frac); ccu_frac_helper_disable(&cm->common, &cm->frac);
ccu_mux_helper_adjust_parent_for_prediv(&cm->common, &cm->mux, -1, parent_rate = ccu_mux_helper_apply_prediv(&cm->common, &cm->mux, -1,
&parent_rate); parent_rate);
_cm.min = cm->mult.min; _cm.min = cm->mult.min;
......
...@@ -15,24 +15,20 @@ ...@@ -15,24 +15,20 @@
#include "ccu_gate.h" #include "ccu_gate.h"
#include "ccu_mux.h" #include "ccu_mux.h"
void ccu_mux_helper_adjust_parent_for_prediv(struct ccu_common *common, static u16 ccu_mux_get_prediv(struct ccu_common *common,
struct ccu_mux_internal *cm, struct ccu_mux_internal *cm,
int parent_index, int parent_index)
unsigned long *parent_rate)
{ {
u16 prediv = 1; u16 prediv = 1;
u32 reg; u32 reg;
int i;
if (!((common->features & CCU_FEATURE_FIXED_PREDIV) || if (!((common->features & CCU_FEATURE_FIXED_PREDIV) ||
(common->features & CCU_FEATURE_VARIABLE_PREDIV) || (common->features & CCU_FEATURE_VARIABLE_PREDIV) ||
(common->features & CCU_FEATURE_ALL_PREDIV))) (common->features & CCU_FEATURE_ALL_PREDIV)))
return; return 1;
if (common->features & CCU_FEATURE_ALL_PREDIV) { if (common->features & CCU_FEATURE_ALL_PREDIV)
*parent_rate = *parent_rate / common->prediv; return common->prediv;
return;
}
reg = readl(common->base + common->reg); reg = readl(common->base + common->reg);
if (parent_index < 0) { if (parent_index < 0) {
...@@ -40,28 +36,52 @@ void ccu_mux_helper_adjust_parent_for_prediv(struct ccu_common *common, ...@@ -40,28 +36,52 @@ void ccu_mux_helper_adjust_parent_for_prediv(struct ccu_common *common,
parent_index &= (1 << cm->width) - 1; parent_index &= (1 << cm->width) - 1;
} }
if (common->features & CCU_FEATURE_FIXED_PREDIV) if (common->features & CCU_FEATURE_FIXED_PREDIV) {
int i;
for (i = 0; i < cm->n_predivs; i++) for (i = 0; i < cm->n_predivs; i++)
if (parent_index == cm->fixed_predivs[i].index) if (parent_index == cm->fixed_predivs[i].index)
prediv = cm->fixed_predivs[i].div; prediv = cm->fixed_predivs[i].div;
}
if (common->features & CCU_FEATURE_VARIABLE_PREDIV) if (common->features & CCU_FEATURE_VARIABLE_PREDIV) {
if (parent_index == cm->variable_prediv.index) { int i;
u8 div;
div = reg >> cm->variable_prediv.shift; for (i = 0; i < cm->n_var_predivs; i++)
div &= (1 << cm->variable_prediv.width) - 1; if (parent_index == cm->var_predivs[i].index) {
prediv = div + 1; u8 div;
}
div = reg >> cm->var_predivs[i].shift;
div &= (1 << cm->var_predivs[i].width) - 1;
prediv = div + 1;
}
}
return prediv;
}
*parent_rate = *parent_rate / prediv; unsigned long ccu_mux_helper_apply_prediv(struct ccu_common *common,
struct ccu_mux_internal *cm,
int parent_index,
unsigned long parent_rate)
{
return parent_rate / ccu_mux_get_prediv(common, cm, parent_index);
}
unsigned long ccu_mux_helper_unapply_prediv(struct ccu_common *common,
struct ccu_mux_internal *cm,
int parent_index,
unsigned long parent_rate)
{
return parent_rate * ccu_mux_get_prediv(common, cm, parent_index);
} }
int ccu_mux_helper_determine_rate(struct ccu_common *common, int ccu_mux_helper_determine_rate(struct ccu_common *common,
struct ccu_mux_internal *cm, struct ccu_mux_internal *cm,
struct clk_rate_request *req, struct clk_rate_request *req,
unsigned long (*round)(struct ccu_mux_internal *, unsigned long (*round)(struct ccu_mux_internal *,
unsigned long, struct clk_hw *,
unsigned long *,
unsigned long, unsigned long,
void *), void *),
void *data) void *data)
...@@ -75,41 +95,43 @@ int ccu_mux_helper_determine_rate(struct ccu_common *common, ...@@ -75,41 +95,43 @@ int ccu_mux_helper_determine_rate(struct ccu_common *common,
best_parent = clk_hw_get_parent(hw); best_parent = clk_hw_get_parent(hw);
best_parent_rate = clk_hw_get_rate(best_parent); best_parent_rate = clk_hw_get_rate(best_parent);
adj_parent_rate = ccu_mux_helper_apply_prediv(common, cm, -1,
best_parent_rate);
adj_parent_rate = best_parent_rate; best_rate = round(cm, best_parent, &adj_parent_rate,
ccu_mux_helper_adjust_parent_for_prediv(common, cm, -1, req->rate, data);
&adj_parent_rate);
best_rate = round(cm, adj_parent_rate, req->rate, data); /*
* adj_parent_rate might have been modified by our clock.
* Unapply the pre-divider if there's one, and give
* the actual frequency the parent needs to run at.
*/
best_parent_rate = ccu_mux_helper_unapply_prediv(common, cm, -1,
adj_parent_rate);
goto out; goto out;
} }
for (i = 0; i < clk_hw_get_num_parents(hw); i++) { for (i = 0; i < clk_hw_get_num_parents(hw); i++) {
unsigned long tmp_rate, parent_rate, adj_parent_rate; unsigned long tmp_rate, parent_rate;
struct clk_hw *parent; struct clk_hw *parent;
parent = clk_hw_get_parent_by_index(hw, i); parent = clk_hw_get_parent_by_index(hw, i);
if (!parent) if (!parent)
continue; continue;
if (clk_hw_get_flags(hw) & CLK_SET_RATE_PARENT) { parent_rate = ccu_mux_helper_apply_prediv(common, cm, i,
struct clk_rate_request parent_req = *req; clk_hw_get_rate(parent));
int ret = __clk_determine_rate(parent, &parent_req);
if (ret)
continue;
parent_rate = parent_req.rate; tmp_rate = round(cm, parent, &parent_rate, req->rate, data);
} else {
parent_rate = clk_hw_get_rate(parent);
}
adj_parent_rate = parent_rate; /*
ccu_mux_helper_adjust_parent_for_prediv(common, cm, i, * parent_rate might have been modified by our clock.
&adj_parent_rate); * Unapply the pre-divider if there's one, and give
* the actual frequency the parent needs to run at.
tmp_rate = round(cm, adj_parent_rate, req->rate, data); */
parent_rate = ccu_mux_helper_unapply_prediv(common, cm, i,
parent_rate);
if (tmp_rate == req->rate) { if (tmp_rate == req->rate) {
best_parent = parent; best_parent = parent;
best_parent_rate = parent_rate; best_parent_rate = parent_rate;
...@@ -217,10 +239,8 @@ static unsigned long ccu_mux_recalc_rate(struct clk_hw *hw, ...@@ -217,10 +239,8 @@ static unsigned long ccu_mux_recalc_rate(struct clk_hw *hw,
{ {
struct ccu_mux *cm = hw_to_ccu_mux(hw); struct ccu_mux *cm = hw_to_ccu_mux(hw);
ccu_mux_helper_adjust_parent_for_prediv(&cm->common, &cm->mux, -1, return ccu_mux_helper_apply_prediv(&cm->common, &cm->mux, -1,
&parent_rate); parent_rate);
return parent_rate;
} }
const struct clk_ops ccu_mux_ops = { const struct clk_ops ccu_mux_ops = {
......
...@@ -10,6 +10,12 @@ struct ccu_mux_fixed_prediv { ...@@ -10,6 +10,12 @@ struct ccu_mux_fixed_prediv {
u16 div; u16 div;
}; };
struct ccu_mux_var_prediv {
u8 index;
u8 shift;
u8 width;
};
struct ccu_mux_internal { struct ccu_mux_internal {
u8 shift; u8 shift;
u8 width; u8 width;
...@@ -18,11 +24,8 @@ struct ccu_mux_internal { ...@@ -18,11 +24,8 @@ struct ccu_mux_internal {
const struct ccu_mux_fixed_prediv *fixed_predivs; const struct ccu_mux_fixed_prediv *fixed_predivs;
u8 n_predivs; u8 n_predivs;
struct { const struct ccu_mux_var_prediv *var_predivs;
u8 index; u8 n_var_predivs;
u8 shift;
u8 width;
} variable_prediv;
}; };
#define _SUNXI_CCU_MUX_TABLE(_shift, _width, _table) \ #define _SUNXI_CCU_MUX_TABLE(_shift, _width, _table) \
...@@ -78,15 +81,16 @@ static inline struct ccu_mux *hw_to_ccu_mux(struct clk_hw *hw) ...@@ -78,15 +81,16 @@ static inline struct ccu_mux *hw_to_ccu_mux(struct clk_hw *hw)
extern const struct clk_ops ccu_mux_ops; extern const struct clk_ops ccu_mux_ops;
void ccu_mux_helper_adjust_parent_for_prediv(struct ccu_common *common, unsigned long ccu_mux_helper_apply_prediv(struct ccu_common *common,
struct ccu_mux_internal *cm, struct ccu_mux_internal *cm,
int parent_index, int parent_index,
unsigned long *parent_rate); unsigned long parent_rate);
int ccu_mux_helper_determine_rate(struct ccu_common *common, int ccu_mux_helper_determine_rate(struct ccu_common *common,
struct ccu_mux_internal *cm, struct ccu_mux_internal *cm,
struct clk_rate_request *req, struct clk_rate_request *req,
unsigned long (*round)(struct ccu_mux_internal *, unsigned long (*round)(struct ccu_mux_internal *,
unsigned long, struct clk_hw *,
unsigned long *,
unsigned long, unsigned long,
void *), void *),
void *data); void *data);
......
...@@ -102,7 +102,8 @@ static unsigned long ccu_nkm_recalc_rate(struct clk_hw *hw, ...@@ -102,7 +102,8 @@ static unsigned long ccu_nkm_recalc_rate(struct clk_hw *hw,
} }
static unsigned long ccu_nkm_round_rate(struct ccu_mux_internal *mux, static unsigned long ccu_nkm_round_rate(struct ccu_mux_internal *mux,
unsigned long parent_rate, struct clk_hw *hw,
unsigned long *parent_rate,
unsigned long rate, unsigned long rate,
void *data) void *data)
{ {
...@@ -116,9 +117,9 @@ static unsigned long ccu_nkm_round_rate(struct ccu_mux_internal *mux, ...@@ -116,9 +117,9 @@ static unsigned long ccu_nkm_round_rate(struct ccu_mux_internal *mux,
_nkm.min_m = 1; _nkm.min_m = 1;
_nkm.max_m = nkm->m.max ?: 1 << nkm->m.width; _nkm.max_m = nkm->m.max ?: 1 << nkm->m.width;
ccu_nkm_find_best(parent_rate, rate, &_nkm); ccu_nkm_find_best(*parent_rate, rate, &_nkm);
return parent_rate * _nkm.n * _nkm.k / _nkm.m; return *parent_rate * _nkm.n * _nkm.k / _nkm.m;
} }
static int ccu_nkm_determine_rate(struct clk_hw *hw, static int ccu_nkm_determine_rate(struct clk_hw *hw,
......
...@@ -15,6 +15,7 @@ ...@@ -15,6 +15,7 @@
#define _CCU_RESET_H_ #define _CCU_RESET_H_
#include <linux/reset-controller.h> #include <linux/reset-controller.h>
#include <linux/spinlock.h>
struct ccu_reset_map { struct ccu_reset_map {
u16 reg; u16 reg;
......
...@@ -19,6 +19,9 @@ ...@@ -19,6 +19,9 @@
#define CLK_HOSC 1 #define CLK_HOSC 1
#define CLK_PLL_VIDEO0_2X 9
#define CLK_PLL_VIDEO1_2X 16
#define CLK_CPU 17 #define CLK_CPU 17
#define CLK_AHB_OTG 23 #define CLK_AHB_OTG 23
......
/*
* Copyright (C) 2017 Chen-Yu Tsai <wens@csie.org>
*
* This file is dual-licensed: you can use it either under the terms
* of the GPL or the X11 license, at your option. Note that this dual
* licensing only applies to this file, and not this project as a
* whole.
*
* a) This file 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 file 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.
*
* Or, alternatively,
*
* b) Permission is hereby granted, free of charge, to any person
* obtaining a copy of this software and associated documentation
* files (the "Software"), to deal in the Software without
* restriction, including without limitation the rights to use,
* copy, modify, merge, publish, distribute, sublicense, and/or
* sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following
* conditions:
*
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
* OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
* OTHER DEALINGS IN THE SOFTWARE.
*/
#ifndef _DT_BINDINGS_CLOCK_SUN8I_A83T_CCU_H_
#define _DT_BINDINGS_CLOCK_SUN8I_A83T_CCU_H_
#define CLK_PLL_PERIPH 6
#define CLK_PLL_DE 9
#define CLK_C0CPUX 11
#define CLK_C1CPUX 12
#define CLK_BUS_MIPI_DSI 19
#define CLK_BUS_SS 20
#define CLK_BUS_DMA 21
#define CLK_BUS_MMC0 22
#define CLK_BUS_MMC1 23
#define CLK_BUS_MMC2 24
#define CLK_BUS_NAND 25
#define CLK_BUS_DRAM 26
#define CLK_BUS_EMAC 27
#define CLK_BUS_HSTIMER 28
#define CLK_BUS_SPI0 29
#define CLK_BUS_SPI1 30
#define CLK_BUS_OTG 31
#define CLK_BUS_EHCI0 32
#define CLK_BUS_EHCI1 33
#define CLK_BUS_OHCI0 34
#define CLK_BUS_VE 35
#define CLK_BUS_TCON0 36
#define CLK_BUS_TCON1 37
#define CLK_BUS_CSI 38
#define CLK_BUS_HDMI 39
#define CLK_BUS_DE 40
#define CLK_BUS_GPU 41
#define CLK_BUS_MSGBOX 42
#define CLK_BUS_SPINLOCK 43
#define CLK_BUS_SPDIF 44
#define CLK_BUS_PIO 45
#define CLK_BUS_I2S0 46
#define CLK_BUS_I2S1 47
#define CLK_BUS_I2S2 48
#define CLK_BUS_TDM 49
#define CLK_BUS_I2C0 50
#define CLK_BUS_I2C1 51
#define CLK_BUS_I2C2 52
#define CLK_BUS_UART0 53
#define CLK_BUS_UART1 54
#define CLK_BUS_UART2 55
#define CLK_BUS_UART3 56
#define CLK_BUS_UART4 57
#define CLK_NAND 59
#define CLK_MMC0 60
#define CLK_MMC0_SAMPLE 61
#define CLK_MMC0_OUTPUT 62
#define CLK_MMC1 63
#define CLK_MMC1_SAMPLE 64
#define CLK_MMC1_OUTPUT 65
#define CLK_MMC2 66
#define CLK_MMC2_SAMPLE 67
#define CLK_MMC2_OUTPUT 68
#define CLK_SS 69
#define CLK_SPI0 70
#define CLK_SPI1 71
#define CLK_I2S0 72
#define CLK_I2S1 73
#define CLK_I2S2 74
#define CLK_TDM 75
#define CLK_SPDIF 76
#define CLK_USB_PHY0 77
#define CLK_USB_PHY1 78
#define CLK_USB_HSIC 79
#define CLK_USB_HSIC_12M 80
#define CLK_USB_OHCI0 81
#define CLK_DRAM_VE 83
#define CLK_DRAM_CSI 84
#define CLK_TCON0 85
#define CLK_TCON1 86
#define CLK_CSI_MISC 87
#define CLK_MIPI_CSI 88
#define CLK_CSI_MCLK 89
#define CLK_CSI_SCLK 90
#define CLK_VE 91
#define CLK_AVS 92
#define CLK_HDMI 93
#define CLK_HDMI_SLOW 94
#define CLK_MIPI_DSI0 96
#define CLK_MIPI_DSI1 97
#define CLK_GPU_CORE 98
#define CLK_GPU_MEMORY 99
#define CLK_GPU_HYD 100
#endif /* _DT_BINDINGS_CLOCK_SUN8I_A83T_CCU_H_ */
/*
* Copyright (C) 2016 Icenowy Zheng <icenowy@aosc.io>
*
* SPDX-License-Identifier: (GPL-2.0+ OR MIT)
*/
#ifndef _DT_BINDINGS_CLOCK_SUN8I_DE2_H_
#define _DT_BINDINGS_CLOCK_SUN8I_DE2_H_
#define CLK_BUS_MIXER0 0
#define CLK_BUS_MIXER1 1
#define CLK_BUS_WB 2
#define CLK_MIXER0 6
#define CLK_MIXER1 7
#define CLK_WB 8
#endif /* _DT_BINDINGS_CLOCK_SUN8I_DE2_H_ */
/*
* Copyright (C) 2017 Chen-Yu Tsai <wens@csie.org>
*
* This file is dual-licensed: you can use it either under the terms
* of the GPL or the X11 license, at your option. Note that this dual
* licensing only applies to this file, and not this project as a
* whole.
*
* a) This file 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 file 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.
*
* Or, alternatively,
*
* b) Permission is hereby granted, free of charge, to any person
* obtaining a copy of this software and associated documentation
* files (the "Software"), to deal in the Software without
* restriction, including without limitation the rights to use,
* copy, modify, merge, publish, distribute, sublicense, and/or
* sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following
* conditions:
*
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
* OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
* OTHER DEALINGS IN THE SOFTWARE.
*/
#ifndef _DT_BINDINGS_RESET_SUN8I_A83T_CCU_H_
#define _DT_BINDINGS_RESET_SUN8I_A83T_CCU_H_
#define RST_USB_PHY0 0
#define RST_USB_PHY1 1
#define RST_USB_HSIC 2
#define RST_DRAM 3
#define RST_MBUS 4
#define RST_BUS_MIPI_DSI 5
#define RST_BUS_SS 6
#define RST_BUS_DMA 7
#define RST_BUS_MMC0 8
#define RST_BUS_MMC1 9
#define RST_BUS_MMC2 10
#define RST_BUS_NAND 11
#define RST_BUS_DRAM 12
#define RST_BUS_EMAC 13
#define RST_BUS_HSTIMER 14
#define RST_BUS_SPI0 15
#define RST_BUS_SPI1 16
#define RST_BUS_OTG 17
#define RST_BUS_EHCI0 18
#define RST_BUS_EHCI1 19
#define RST_BUS_OHCI0 20
#define RST_BUS_VE 21
#define RST_BUS_TCON0 22
#define RST_BUS_TCON1 23
#define RST_BUS_CSI 24
#define RST_BUS_HDMI0 25
#define RST_BUS_HDMI1 26
#define RST_BUS_DE 27
#define RST_BUS_GPU 28
#define RST_BUS_MSGBOX 29
#define RST_BUS_SPINLOCK 30
#define RST_BUS_LVDS 31
#define RST_BUS_SPDIF 32
#define RST_BUS_I2S0 33
#define RST_BUS_I2S1 34
#define RST_BUS_I2S2 35
#define RST_BUS_TDM 36
#define RST_BUS_I2C0 37
#define RST_BUS_I2C1 38
#define RST_BUS_I2C2 39
#define RST_BUS_UART0 40
#define RST_BUS_UART1 41
#define RST_BUS_UART2 42
#define RST_BUS_UART3 43
#define RST_BUS_UART4 44
#endif /* _DT_BINDINGS_RESET_SUN8I_A83T_CCU_H_ */
/*
* Copyright (C) 2016 Icenowy Zheng <icenowy@aosc.io>
*
* SPDX-License-Identifier: (GPL-2.0+ OR MIT)
*/
#ifndef _DT_BINDINGS_RESET_SUN8I_DE2_H_
#define _DT_BINDINGS_RESET_SUN8I_DE2_H_
#define RST_MIXER0 0
#define RST_MIXER1 1
#define RST_WB 2
#endif /* _DT_BINDINGS_RESET_SUN8I_DE2_H_ */
...@@ -412,9 +412,10 @@ extern const struct clk_ops clk_divider_ro_ops; ...@@ -412,9 +412,10 @@ extern const struct clk_ops clk_divider_ro_ops;
unsigned long divider_recalc_rate(struct clk_hw *hw, unsigned long parent_rate, unsigned long divider_recalc_rate(struct clk_hw *hw, unsigned long parent_rate,
unsigned int val, const struct clk_div_table *table, unsigned int val, const struct clk_div_table *table,
unsigned long flags); unsigned long flags);
long divider_round_rate(struct clk_hw *hw, unsigned long rate, long divider_round_rate_parent(struct clk_hw *hw, struct clk_hw *parent,
unsigned long *prate, const struct clk_div_table *table, unsigned long rate, unsigned long *prate,
u8 width, unsigned long flags); const struct clk_div_table *table,
u8 width, unsigned long flags);
int divider_get_val(unsigned long rate, unsigned long parent_rate, int divider_get_val(unsigned long rate, unsigned long parent_rate,
const struct clk_div_table *table, u8 width, const struct clk_div_table *table, u8 width,
unsigned long flags); unsigned long flags);
...@@ -757,6 +758,15 @@ static inline void __clk_hw_set_clk(struct clk_hw *dst, struct clk_hw *src) ...@@ -757,6 +758,15 @@ static inline void __clk_hw_set_clk(struct clk_hw *dst, struct clk_hw *src)
dst->core = src->core; dst->core = src->core;
} }
static inline long divider_round_rate(struct clk_hw *hw, unsigned long rate,
unsigned long *prate,
const struct clk_div_table *table,
u8 width, unsigned long flags)
{
return divider_round_rate_parent(hw, clk_hw_get_parent(hw),
rate, prate, table, width, flags);
}
/* /*
* FIXME clock api without lock protection * FIXME clock api without lock protection
*/ */
......
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