Skip to content

Commit caca6ad

Browse files
committed
Merge branches 'clk-xilinx', 'clk-broadcom' and 'clk-platform' into clk-next
- BCM63268 timer clock and reset controller - Convert platform clk drivers to remove_new * clk-xilinx: clocking-wizard: Support higher frequency accuracy clk: zynqmp: pll: Remove the limit * clk-broadcom: clk: bcm: Add BCM63268 timer clock and reset driver dt-bindings: clock: Add BCM63268 timer binding dt-bindings: reset: add BCM63268 timer reset definitions dt-bindings: clk: add BCM63268 timer clock definitions * clk-platform: (25 commits) clk: xilinx: Convert to platform remove callback returning void clk: x86: Convert to platform remove callback returning void clk: uniphier: Convert to platform remove callback returning void clk: ti: Convert to platform remove callback returning void clk: tegra: Convert to platform remove callback returning void clk: stm32: Convert to platform remove callback returning void clk: mvebu: Convert to platform remove callback returning void clk: mmp: Convert to platform remove callback returning void clk: keystone: Convert to platform remove callback returning void clk: hisilicon: Convert to platform remove callback returning void clk: stm32mp1: Convert to platform remove callback returning void clk: scpi: Convert to platform remove callback returning void clk: s2mps11: Convert to platform remove callback returning void clk: pwm: Convert to platform remove callback returning void clk: palmas: Convert to platform remove callback returning void clk: hsdk-pll: Convert to platform remove callback returning void clk: fixed-rate: Convert to platform remove callback returning void clk: fixed-mmio: Convert to platform remove callback returning void clk: fixed-factor: Convert to platform remove callback returning void clk: axm5516: Convert to platform remove callback returning void ...
4 parents 6f7478e + 595c88c + ba7c8d2 + ce1c5f8 commit caca6ad

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

41 files changed

+564
-155
lines changed
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
2+
%YAML 1.2
3+
---
4+
$id: http://devicetree.org/schemas/clock/brcm,bcm63268-timer-clocks.yaml#
5+
$schema: http://devicetree.org/meta-schemas/core.yaml#
6+
7+
title: Broadcom BCM63268 Timer Clock and Reset Device Tree Bindings
8+
9+
maintainers:
10+
- Álvaro Fernández Rojas <noltari@gmail.com>
11+
12+
properties:
13+
compatible:
14+
const: brcm,bcm63268-timer-clocks
15+
16+
reg:
17+
maxItems: 1
18+
19+
"#clock-cells":
20+
const: 1
21+
22+
"#reset-cells":
23+
const: 1
24+
25+
required:
26+
- compatible
27+
- reg
28+
- "#clock-cells"
29+
- "#reset-cells"
30+
31+
additionalProperties: false
32+
33+
examples:
34+
- |
35+
timer_clk: clock-controller@100000ac {
36+
compatible = "brcm,bcm63268-timer-clocks";
37+
reg = <0x100000ac 0x4>;
38+
#clock-cells = <1>;
39+
#reset-cells = <1>;
40+
};

drivers/clk/axs10x/i2s_pll_clock.c

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -198,10 +198,9 @@ static int i2s_pll_clk_probe(struct platform_device *pdev)
198198
return of_clk_add_provider(node, of_clk_src_simple_get, clk);
199199
}
200200

201-
static int i2s_pll_clk_remove(struct platform_device *pdev)
201+
static void i2s_pll_clk_remove(struct platform_device *pdev)
202202
{
203203
of_clk_del_provider(pdev->dev.of_node);
204-
return 0;
205204
}
206205

207206
static const struct of_device_id i2s_pll_clk_id[] = {
@@ -216,7 +215,7 @@ static struct platform_driver i2s_pll_clk_driver = {
216215
.of_match_table = i2s_pll_clk_id,
217216
},
218217
.probe = i2s_pll_clk_probe,
219-
.remove = i2s_pll_clk_remove,
218+
.remove_new = i2s_pll_clk_remove,
220219
};
221220
module_platform_driver(i2s_pll_clk_driver);
222221

drivers/clk/axs10x/pll_clock.c

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -257,10 +257,9 @@ static int axs10x_pll_clk_probe(struct platform_device *pdev)
257257
&pll_clk->hw);
258258
}
259259

260-
static int axs10x_pll_clk_remove(struct platform_device *pdev)
260+
static void axs10x_pll_clk_remove(struct platform_device *pdev)
261261
{
262262
of_clk_del_provider(pdev->dev.of_node);
263-
return 0;
264263
}
265264

266265
static void __init of_axs10x_pll_clk_setup(struct device_node *node)
@@ -332,7 +331,7 @@ static struct platform_driver axs10x_pll_clk_driver = {
332331
.of_match_table = axs10x_pll_clk_id,
333332
},
334333
.probe = axs10x_pll_clk_probe,
335-
.remove = axs10x_pll_clk_remove,
334+
.remove_new = axs10x_pll_clk_remove,
336335
};
337336
builtin_platform_driver(axs10x_pll_clk_driver);
338337

drivers/clk/bcm/Kconfig

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,15 @@ config CLK_BCM_63XX_GATE
3737
Enable common clock framework support for Broadcom BCM63xx DSL SoCs
3838
based on the MIPS architecture
3939

40+
config CLK_BCM63268_TIMER
41+
bool "Broadcom BCM63268 timer clock and reset support"
42+
depends on BMIPS_GENERIC || COMPILE_TEST
43+
default BMIPS_GENERIC
44+
select RESET_CONTROLLER
45+
help
46+
Enable timer clock and reset support for Broadcom BCM63268 DSL SoCs
47+
based on the MIPS architecture.
48+
4049
config CLK_BCM_KONA
4150
bool "Broadcom Kona CCU clock support"
4251
depends on ARCH_BCM_MOBILE || COMPILE_TEST

drivers/clk/bcm/Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
# SPDX-License-Identifier: GPL-2.0
22
obj-$(CONFIG_CLK_BCM_63XX) += clk-bcm63xx.o
33
obj-$(CONFIG_CLK_BCM_63XX_GATE) += clk-bcm63xx-gate.o
4+
obj-$(CONFIG_CLK_BCM63268_TIMER) += clk-bcm63268-timer.o
45
obj-$(CONFIG_CLK_BCM_KONA) += clk-kona.o
56
obj-$(CONFIG_CLK_BCM_KONA) += clk-kona-setup.o
67
obj-$(CONFIG_CLK_BCM_KONA) += clk-bcm281xx.o

drivers/clk/bcm/clk-bcm2711-dvp.c

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -92,15 +92,13 @@ static int clk_dvp_probe(struct platform_device *pdev)
9292
return ret;
9393
};
9494

95-
static int clk_dvp_remove(struct platform_device *pdev)
95+
static void clk_dvp_remove(struct platform_device *pdev)
9696
{
9797
struct clk_dvp *dvp = platform_get_drvdata(pdev);
9898
struct clk_hw_onecell_data *data = dvp->data;
9999

100100
clk_hw_unregister_gate(data->hws[1]);
101101
clk_hw_unregister_gate(data->hws[0]);
102-
103-
return 0;
104102
}
105103

106104
static const struct of_device_id clk_dvp_dt_ids[] = {
@@ -111,7 +109,7 @@ MODULE_DEVICE_TABLE(of, clk_dvp_dt_ids);
111109

112110
static struct platform_driver clk_dvp_driver = {
113111
.probe = clk_dvp_probe,
114-
.remove = clk_dvp_remove,
112+
.remove_new = clk_dvp_remove,
115113
.driver = {
116114
.name = "brcm2711-dvp",
117115
.of_match_table = clk_dvp_dt_ids,

drivers/clk/bcm/clk-bcm63268-timer.c

Lines changed: 216 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,216 @@
1+
// SPDX-License-Identifier: GPL-2.0
2+
/*
3+
* BCM63268 Timer Clock and Reset Controller Driver
4+
*
5+
* Copyright (C) 2023 Álvaro Fernández Rojas <noltari@gmail.com>
6+
*/
7+
8+
#include <linux/clk-provider.h>
9+
#include <linux/container_of.h>
10+
#include <linux/delay.h>
11+
#include <linux/device.h>
12+
#include <linux/io.h>
13+
#include <linux/platform_device.h>
14+
#include <linux/reset-controller.h>
15+
#include <linux/spinlock.h>
16+
17+
#include <dt-bindings/clock/bcm63268-clock.h>
18+
19+
#define BCM63268_TIMER_RESET_SLEEP_MIN_US 10000
20+
#define BCM63268_TIMER_RESET_SLEEP_MAX_US 20000
21+
22+
struct bcm63268_tclkrst_hw {
23+
void __iomem *regs;
24+
spinlock_t lock;
25+
26+
struct reset_controller_dev rcdev;
27+
struct clk_hw_onecell_data data;
28+
};
29+
30+
struct bcm63268_tclk_table_entry {
31+
const char * const name;
32+
u8 bit;
33+
};
34+
35+
static const struct bcm63268_tclk_table_entry bcm63268_timer_clocks[] = {
36+
{
37+
.name = "ephy1",
38+
.bit = BCM63268_TCLK_EPHY1,
39+
}, {
40+
.name = "ephy2",
41+
.bit = BCM63268_TCLK_EPHY2,
42+
}, {
43+
.name = "ephy3",
44+
.bit = BCM63268_TCLK_EPHY3,
45+
}, {
46+
.name = "gphy1",
47+
.bit = BCM63268_TCLK_GPHY1,
48+
}, {
49+
.name = "dsl",
50+
.bit = BCM63268_TCLK_DSL,
51+
}, {
52+
.name = "wakeon_ephy",
53+
.bit = BCM63268_TCLK_WAKEON_EPHY,
54+
}, {
55+
.name = "wakeon_dsl",
56+
.bit = BCM63268_TCLK_WAKEON_DSL,
57+
}, {
58+
.name = "fap1_pll",
59+
.bit = BCM63268_TCLK_FAP1,
60+
}, {
61+
.name = "fap2_pll",
62+
.bit = BCM63268_TCLK_FAP2,
63+
}, {
64+
.name = "uto_50",
65+
.bit = BCM63268_TCLK_UTO_50,
66+
}, {
67+
.name = "uto_extin",
68+
.bit = BCM63268_TCLK_UTO_EXTIN,
69+
}, {
70+
.name = "usb_ref",
71+
.bit = BCM63268_TCLK_USB_REF,
72+
}, {
73+
/* sentinel */
74+
}
75+
};
76+
77+
static inline struct bcm63268_tclkrst_hw *
78+
to_bcm63268_timer_reset(struct reset_controller_dev *rcdev)
79+
{
80+
return container_of(rcdev, struct bcm63268_tclkrst_hw, rcdev);
81+
}
82+
83+
static int bcm63268_timer_reset_update(struct reset_controller_dev *rcdev,
84+
unsigned long id, bool assert)
85+
{
86+
struct bcm63268_tclkrst_hw *reset = to_bcm63268_timer_reset(rcdev);
87+
unsigned long flags;
88+
uint32_t val;
89+
90+
spin_lock_irqsave(&reset->lock, flags);
91+
val = __raw_readl(reset->regs);
92+
if (assert)
93+
val &= ~BIT(id);
94+
else
95+
val |= BIT(id);
96+
__raw_writel(val, reset->regs);
97+
spin_unlock_irqrestore(&reset->lock, flags);
98+
99+
return 0;
100+
}
101+
102+
static int bcm63268_timer_reset_assert(struct reset_controller_dev *rcdev,
103+
unsigned long id)
104+
{
105+
return bcm63268_timer_reset_update(rcdev, id, true);
106+
}
107+
108+
static int bcm63268_timer_reset_deassert(struct reset_controller_dev *rcdev,
109+
unsigned long id)
110+
{
111+
return bcm63268_timer_reset_update(rcdev, id, false);
112+
}
113+
114+
static int bcm63268_timer_reset_reset(struct reset_controller_dev *rcdev,
115+
unsigned long id)
116+
{
117+
bcm63268_timer_reset_update(rcdev, id, true);
118+
usleep_range(BCM63268_TIMER_RESET_SLEEP_MIN_US,
119+
BCM63268_TIMER_RESET_SLEEP_MAX_US);
120+
121+
bcm63268_timer_reset_update(rcdev, id, false);
122+
/*
123+
* Ensure component is taken out reset state by sleeping also after
124+
* deasserting the reset. Otherwise, the component may not be ready
125+
* for operation.
126+
*/
127+
usleep_range(BCM63268_TIMER_RESET_SLEEP_MIN_US,
128+
BCM63268_TIMER_RESET_SLEEP_MAX_US);
129+
130+
return 0;
131+
}
132+
133+
static int bcm63268_timer_reset_status(struct reset_controller_dev *rcdev,
134+
unsigned long id)
135+
{
136+
struct bcm63268_tclkrst_hw *reset = to_bcm63268_timer_reset(rcdev);
137+
138+
return !(__raw_readl(reset->regs) & BIT(id));
139+
}
140+
141+
static const struct reset_control_ops bcm63268_timer_reset_ops = {
142+
.assert = bcm63268_timer_reset_assert,
143+
.deassert = bcm63268_timer_reset_deassert,
144+
.reset = bcm63268_timer_reset_reset,
145+
.status = bcm63268_timer_reset_status,
146+
};
147+
148+
static int bcm63268_tclk_probe(struct platform_device *pdev)
149+
{
150+
struct device *dev = &pdev->dev;
151+
const struct bcm63268_tclk_table_entry *entry;
152+
struct bcm63268_tclkrst_hw *hw;
153+
struct clk_hw *clk;
154+
u8 maxbit = 0;
155+
int i, ret;
156+
157+
for (entry = bcm63268_timer_clocks; entry->name; entry++)
158+
maxbit = max(maxbit, entry->bit);
159+
maxbit++;
160+
161+
hw = devm_kzalloc(&pdev->dev, struct_size(hw, data.hws, maxbit),
162+
GFP_KERNEL);
163+
if (!hw)
164+
return -ENOMEM;
165+
166+
platform_set_drvdata(pdev, hw);
167+
168+
spin_lock_init(&hw->lock);
169+
170+
hw->data.num = maxbit;
171+
for (i = 0; i < maxbit; i++)
172+
hw->data.hws[i] = ERR_PTR(-ENODEV);
173+
174+
hw->regs = devm_platform_ioremap_resource(pdev, 0);
175+
if (IS_ERR(hw->regs))
176+
return PTR_ERR(hw->regs);
177+
178+
for (entry = bcm63268_timer_clocks; entry->name; entry++) {
179+
clk = devm_clk_hw_register_gate(dev, entry->name, NULL, 0,
180+
hw->regs, entry->bit,
181+
CLK_GATE_BIG_ENDIAN,
182+
&hw->lock);
183+
if (IS_ERR(clk))
184+
return PTR_ERR(clk);
185+
186+
hw->data.hws[entry->bit] = clk;
187+
}
188+
189+
ret = devm_of_clk_add_hw_provider(dev, of_clk_hw_onecell_get,
190+
&hw->data);
191+
if (ret)
192+
return ret;
193+
194+
hw->rcdev.of_node = dev->of_node;
195+
hw->rcdev.ops = &bcm63268_timer_reset_ops;
196+
197+
ret = devm_reset_controller_register(dev, &hw->rcdev);
198+
if (ret)
199+
dev_err(dev, "Failed to register reset controller\n");
200+
201+
return 0;
202+
}
203+
204+
static const struct of_device_id bcm63268_tclk_dt_ids[] = {
205+
{ .compatible = "brcm,bcm63268-timer-clocks" },
206+
{ /* sentinel */ }
207+
};
208+
209+
static struct platform_driver bcm63268_tclk = {
210+
.probe = bcm63268_tclk_probe,
211+
.driver = {
212+
.name = "bcm63268-timer-clock",
213+
.of_match_table = bcm63268_tclk_dt_ids,
214+
},
215+
};
216+
builtin_platform_driver(bcm63268_tclk);

drivers/clk/bcm/clk-bcm63xx-gate.c

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -541,7 +541,7 @@ static int clk_bcm63xx_probe(struct platform_device *pdev)
541541
return ret;
542542
}
543543

544-
static int clk_bcm63xx_remove(struct platform_device *pdev)
544+
static void clk_bcm63xx_remove(struct platform_device *pdev)
545545
{
546546
struct clk_bcm63xx_hw *hw = platform_get_drvdata(pdev);
547547
int i;
@@ -552,8 +552,6 @@ static int clk_bcm63xx_remove(struct platform_device *pdev)
552552
if (!IS_ERR(hw->data.hws[i]))
553553
clk_hw_unregister_gate(hw->data.hws[i]);
554554
}
555-
556-
return 0;
557555
}
558556

559557
static const struct of_device_id clk_bcm63xx_dt_ids[] = {
@@ -570,7 +568,7 @@ static const struct of_device_id clk_bcm63xx_dt_ids[] = {
570568

571569
static struct platform_driver clk_bcm63xx = {
572570
.probe = clk_bcm63xx_probe,
573-
.remove = clk_bcm63xx_remove,
571+
.remove_new = clk_bcm63xx_remove,
574572
.driver = {
575573
.name = "bcm63xx-clock",
576574
.of_match_table = clk_bcm63xx_dt_ids,

0 commit comments

Comments
 (0)