Skip to content

Commit 702a582

Browse files
committed
Merge branches 'clk-doc', 'clk-amlogic', 'clk-mediatek', 'clk-twl' and 'clk-imx' into clk-next
- Add clock driver for TWL6032 * clk-doc: clk: linux/clk-provider.h: fix kernel-doc warnings and typos * clk-amlogic: clk: meson: S4: select CONFIG_COMMON_CLK_MESON_CLKC_UTILS clk: meson: S4: add support for Amlogic S4 SoC peripheral clock controller clk: meson: S4: add support for Amlogic S4 SoC PLL clock driver dt-bindings: clock: document Amlogic S4 SoC peripherals clock controller dt-bindings: clock: document Amlogic S4 SoC PLL clock controller * clk-mediatek: clk: mediatek: fix double free in mtk_clk_register_pllfh() clk: mediatek: clk-mt2701: Add check for mtk_alloc_clk_data clk: mediatek: clk-mt7629: Add check for mtk_alloc_clk_data clk: mediatek: clk-mt7629-eth: Add check for mtk_alloc_clk_data clk: mediatek: clk-mt6797: Add check for mtk_alloc_clk_data clk: mediatek: clk-mt6779: Add check for mtk_alloc_clk_data clk: mediatek: clk-mt6765: Add check for mtk_alloc_clk_data * clk-twl: clk: twl: add clock driver for TWL6032 * clk-imx: clk: imx: imx8qm/qxp: add more resources to whitelist clk: imx: scu: ignore clks not owned by Cortex-A partition clk: imx8: remove MLB support clk: imx: imx8qm-rsrc: drop VPU_UART/VPUCORE clk: imx: imx8qxp: correct the enet clocks for i.MX8DXL clk: imx: imx8qxp: Fix elcdif_pll clock clk: imx: imx8dxl-rsrc: keep sorted in the ascending order clk: imx: imx6sx: Allow a different LCDIF1 clock parent clk: imx: imx8mq: correct error handling path clk: imx8mp: Remove non-existent IMX8MP_CLK_AUDIOMIX_PDM_ROOT clk: imx: imx8: Simplify clk_imx_acm_detach_pm_domains() clk: imx: imx8: Add a message in case of devm_clk_hw_register_mux_parent_data_table() error clk: imx: imx8: Fix an error handling path in imx8_acm_clk_probe() clk: imx: imx8: Fix an error handling path if devm_clk_hw_register_mux_parent_data_table() fails clk: imx: imx8: Fix an error handling path in clk_imx_acm_attach_pm_domains() clk: imx: Select MXC_CLK for CLK_IMX8QXP
6 parents 790437b + 84aefaf + b79a08a + bd54ccc + 4eb15b0 + 701d105 commit 702a582

32 files changed

+5553
-46
lines changed
Lines changed: 96 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,96 @@
1+
# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
2+
# Copyright (C) 2022-2023 Amlogic, Inc. All rights reserved
3+
%YAML 1.2
4+
---
5+
$id: http://devicetree.org/schemas/clock/amlogic,s4-peripherals-clkc.yaml#
6+
$schema: http://devicetree.org/meta-schemas/core.yaml#
7+
8+
title: Amlogic S4 Peripherals Clock Controller
9+
10+
maintainers:
11+
12+
13+
properties:
14+
compatible:
15+
const: amlogic,s4-peripherals-clkc
16+
17+
reg:
18+
maxItems: 1
19+
20+
clocks:
21+
minItems: 14
22+
items:
23+
- description: input fixed pll div2
24+
- description: input fixed pll div2p5
25+
- description: input fixed pll div3
26+
- description: input fixed pll div4
27+
- description: input fixed pll div5
28+
- description: input fixed pll div7
29+
- description: input hifi pll
30+
- description: input gp0 pll
31+
- description: input mpll0
32+
- description: input mpll1
33+
- description: input mpll2
34+
- description: input mpll3
35+
- description: input hdmi pll
36+
- description: input oscillator (usually at 24MHz)
37+
- description: input external 32kHz reference (optional)
38+
39+
clock-names:
40+
minItems: 14
41+
items:
42+
- const: fclk_div2
43+
- const: fclk_div2p5
44+
- const: fclk_div3
45+
- const: fclk_div4
46+
- const: fclk_div5
47+
- const: fclk_div7
48+
- const: hifi_pll
49+
- const: gp0_pll
50+
- const: mpll0
51+
- const: mpll1
52+
- const: mpll2
53+
- const: mpll3
54+
- const: hdmi_pll
55+
- const: xtal
56+
- const: ext_32k
57+
58+
"#clock-cells":
59+
const: 1
60+
61+
required:
62+
- compatible
63+
- reg
64+
- clocks
65+
- clock-names
66+
- "#clock-cells"
67+
68+
additionalProperties: false
69+
70+
examples:
71+
- |
72+
#include <dt-bindings/clock/amlogic,s4-peripherals-clkc.h>
73+
74+
clkc_periphs: clock-controller@fe000000 {
75+
compatible = "amlogic,s4-peripherals-clkc";
76+
reg = <0xfe000000 0x49c>;
77+
clocks = <&clkc_pll 3>,
78+
<&clkc_pll 13>,
79+
<&clkc_pll 5>,
80+
<&clkc_pll 7>,
81+
<&clkc_pll 9>,
82+
<&clkc_pll 11>,
83+
<&clkc_pll 17>,
84+
<&clkc_pll 15>,
85+
<&clkc_pll 25>,
86+
<&clkc_pll 27>,
87+
<&clkc_pll 29>,
88+
<&clkc_pll 31>,
89+
<&clkc_pll 20>,
90+
<&xtal>;
91+
clock-names = "fclk_div2", "fclk_div2p5", "fclk_div3", "fclk_div4",
92+
"fclk_div5", "fclk_div7", "hifi_pll", "gp0_pll",
93+
"mpll0", "mpll1", "mpll2", "mpll3", "hdmi_pll", "xtal";
94+
#clock-cells = <1>;
95+
};
96+
...
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
2+
# Copyright (C) 2022-2023 Amlogic, Inc. All rights reserved
3+
%YAML 1.2
4+
---
5+
$id: http://devicetree.org/schemas/clock/amlogic,s4-pll-clkc.yaml#
6+
$schema: http://devicetree.org/meta-schemas/core.yaml#
7+
8+
title: Amlogic S4 PLL Clock Controller
9+
10+
maintainers:
11+
12+
13+
properties:
14+
compatible:
15+
const: amlogic,s4-pll-clkc
16+
17+
reg:
18+
maxItems: 1
19+
20+
clocks:
21+
maxItems: 1
22+
23+
clock-names:
24+
items:
25+
- const: xtal
26+
27+
"#clock-cells":
28+
const: 1
29+
30+
required:
31+
- compatible
32+
- reg
33+
- clocks
34+
- clock-names
35+
- "#clock-cells"
36+
37+
additionalProperties: false
38+
39+
examples:
40+
- |
41+
clkc_pll: clock-controller@fe008000 {
42+
compatible = "amlogic,s4-pll-clkc";
43+
reg = <0xfe008000 0x1e8>;
44+
clocks = <&xtal>;
45+
clock-names = "xtal";
46+
#clock-cells = <1>;
47+
};
48+
49+
...

drivers/clk/Kconfig

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -277,6 +277,15 @@ config COMMON_CLK_S2MPS11
277277
clock. These multi-function devices have two (S2MPS14) or three
278278
(S2MPS11, S5M8767) fixed-rate oscillators, clocked at 32KHz each.
279279

280+
config CLK_TWL
281+
tristate "Clock driver for the TWL PMIC family"
282+
depends on TWL4030_CORE
283+
help
284+
Enable support for controlling the clock resources on TWL family
285+
PMICs. These devices have some 32K clock outputs which can be
286+
controlled by software. For now, only the TWL6032 clocks are
287+
supported.
288+
280289
config CLK_TWL6040
281290
tristate "External McPDM functional clock from twl6040"
282291
depends on TWL6040_CORE

drivers/clk/Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,7 @@ obj-$(CONFIG_COMMON_CLK_STM32H7) += clk-stm32h7.o
7272
obj-$(CONFIG_COMMON_CLK_STM32MP157) += clk-stm32mp1.o
7373
obj-$(CONFIG_COMMON_CLK_TPS68470) += clk-tps68470.o
7474
obj-$(CONFIG_CLK_TWL6040) += clk-twl6040.o
75+
obj-$(CONFIG_CLK_TWL) += clk-twl.o
7576
obj-$(CONFIG_ARCH_VT8500) += clk-vt8500.o
7677
obj-$(CONFIG_COMMON_CLK_RS9_PCIE) += clk-renesas-pcie.o
7778
obj-$(CONFIG_COMMON_CLK_SI521XX) += clk-si521xx.o

drivers/clk/clk-twl.c

Lines changed: 197 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,197 @@
1+
// SPDX-License-Identifier: GPL-2.0
2+
/*
3+
* Clock driver for twl device.
4+
*
5+
* inspired by the driver for the Palmas device
6+
*/
7+
8+
#include <linux/clk-provider.h>
9+
#include <linux/mfd/twl.h>
10+
#include <linux/module.h>
11+
#include <linux/platform_device.h>
12+
#include <linux/slab.h>
13+
14+
#define VREG_STATE 2
15+
#define TWL6030_CFG_STATE_OFF 0x00
16+
#define TWL6030_CFG_STATE_ON 0x01
17+
#define TWL6030_CFG_STATE_MASK 0x03
18+
19+
struct twl_clock_info {
20+
struct device *dev;
21+
u8 base;
22+
struct clk_hw hw;
23+
};
24+
25+
static inline int
26+
twlclk_read(struct twl_clock_info *info, unsigned int slave_subgp,
27+
unsigned int offset)
28+
{
29+
u8 value;
30+
int status;
31+
32+
status = twl_i2c_read_u8(slave_subgp, &value,
33+
info->base + offset);
34+
return (status < 0) ? status : value;
35+
}
36+
37+
static inline int
38+
twlclk_write(struct twl_clock_info *info, unsigned int slave_subgp,
39+
unsigned int offset, u8 value)
40+
{
41+
return twl_i2c_write_u8(slave_subgp, value,
42+
info->base + offset);
43+
}
44+
45+
static inline struct twl_clock_info *to_twl_clks_info(struct clk_hw *hw)
46+
{
47+
return container_of(hw, struct twl_clock_info, hw);
48+
}
49+
50+
static unsigned long twl_clks_recalc_rate(struct clk_hw *hw,
51+
unsigned long parent_rate)
52+
{
53+
return 32768;
54+
}
55+
56+
static int twl6032_clks_prepare(struct clk_hw *hw)
57+
{
58+
struct twl_clock_info *cinfo = to_twl_clks_info(hw);
59+
int ret;
60+
61+
ret = twlclk_write(cinfo, TWL_MODULE_PM_RECEIVER, VREG_STATE,
62+
TWL6030_CFG_STATE_ON);
63+
if (ret < 0)
64+
dev_err(cinfo->dev, "clk prepare failed\n");
65+
66+
return ret;
67+
}
68+
69+
static void twl6032_clks_unprepare(struct clk_hw *hw)
70+
{
71+
struct twl_clock_info *cinfo = to_twl_clks_info(hw);
72+
int ret;
73+
74+
ret = twlclk_write(cinfo, TWL_MODULE_PM_RECEIVER, VREG_STATE,
75+
TWL6030_CFG_STATE_OFF);
76+
if (ret < 0)
77+
dev_err(cinfo->dev, "clk unprepare failed\n");
78+
}
79+
80+
static int twl6032_clks_is_prepared(struct clk_hw *hw)
81+
{
82+
struct twl_clock_info *cinfo = to_twl_clks_info(hw);
83+
int val;
84+
85+
val = twlclk_read(cinfo, TWL_MODULE_PM_RECEIVER, VREG_STATE);
86+
if (val < 0) {
87+
dev_err(cinfo->dev, "clk read failed\n");
88+
return val;
89+
}
90+
91+
val &= TWL6030_CFG_STATE_MASK;
92+
93+
return val == TWL6030_CFG_STATE_ON;
94+
}
95+
96+
static const struct clk_ops twl6032_clks_ops = {
97+
.prepare = twl6032_clks_prepare,
98+
.unprepare = twl6032_clks_unprepare,
99+
.is_prepared = twl6032_clks_is_prepared,
100+
.recalc_rate = twl_clks_recalc_rate,
101+
};
102+
103+
struct twl_clks_data {
104+
struct clk_init_data init;
105+
u8 base;
106+
};
107+
108+
static const struct twl_clks_data twl6032_clks[] = {
109+
{
110+
.init = {
111+
.name = "clk32kg",
112+
.ops = &twl6032_clks_ops,
113+
.flags = CLK_IGNORE_UNUSED,
114+
},
115+
.base = 0x8C,
116+
},
117+
{
118+
.init = {
119+
.name = "clk32kaudio",
120+
.ops = &twl6032_clks_ops,
121+
.flags = CLK_IGNORE_UNUSED,
122+
},
123+
.base = 0x8F,
124+
},
125+
{
126+
/* sentinel */
127+
}
128+
};
129+
130+
static int twl_clks_probe(struct platform_device *pdev)
131+
{
132+
struct clk_hw_onecell_data *clk_data;
133+
const struct twl_clks_data *hw_data;
134+
135+
struct twl_clock_info *cinfo;
136+
int ret;
137+
int i;
138+
int count;
139+
140+
hw_data = twl6032_clks;
141+
for (count = 0; hw_data[count].init.name; count++)
142+
;
143+
144+
clk_data = devm_kzalloc(&pdev->dev,
145+
struct_size(clk_data, hws, count),
146+
GFP_KERNEL);
147+
if (!clk_data)
148+
return -ENOMEM;
149+
150+
clk_data->num = count;
151+
cinfo = devm_kcalloc(&pdev->dev, count, sizeof(*cinfo), GFP_KERNEL);
152+
if (!cinfo)
153+
return -ENOMEM;
154+
155+
for (i = 0; i < count; i++) {
156+
cinfo[i].base = hw_data[i].base;
157+
cinfo[i].dev = &pdev->dev;
158+
cinfo[i].hw.init = &hw_data[i].init;
159+
ret = devm_clk_hw_register(&pdev->dev, &cinfo[i].hw);
160+
if (ret) {
161+
return dev_err_probe(&pdev->dev, ret,
162+
"Fail to register clock %s\n",
163+
hw_data[i].init.name);
164+
}
165+
clk_data->hws[i] = &cinfo[i].hw;
166+
}
167+
168+
ret = devm_of_clk_add_hw_provider(&pdev->dev,
169+
of_clk_hw_onecell_get, clk_data);
170+
if (ret < 0)
171+
return dev_err_probe(&pdev->dev, ret,
172+
"Fail to add clock driver\n");
173+
174+
return 0;
175+
}
176+
177+
static const struct platform_device_id twl_clks_id[] = {
178+
{
179+
.name = "twl6032-clk",
180+
}, {
181+
/* sentinel */
182+
}
183+
};
184+
MODULE_DEVICE_TABLE(platform, twl_clks_id);
185+
186+
static struct platform_driver twl_clks_driver = {
187+
.driver = {
188+
.name = "twl-clk",
189+
},
190+
.probe = twl_clks_probe,
191+
.id_table = twl_clks_id,
192+
};
193+
194+
module_platform_driver(twl_clks_driver);
195+
196+
MODULE_DESCRIPTION("Clock driver for TWL Series Devices");
197+
MODULE_LICENSE("GPL");

drivers/clk/imx/Kconfig

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,7 @@ config CLK_IMX8QXP
9696
depends on (ARCH_MXC && ARM64) || COMPILE_TEST
9797
depends on IMX_SCU && HAVE_ARM_SMCCC
9898
select MXC_CLK_SCU
99+
select MXC_CLK
99100
help
100101
Build the driver for IMX8QXP SCU based clocks.
101102

0 commit comments

Comments
 (0)