Skip to content

Commit 9d0af68

Browse files
committed
Merge tag 'clk-microchip-6.13' of https://git.kernel.org/pub/scm/linux/kernel/git/at91/linux into clk-microchip
Pull Microchip clk driver updates from Claudiu Beznea: - Support for the Microchip LAN969X SoC * tag 'clk-microchip-6.13' of https://git.kernel.org/pub/scm/linux/kernel/git/at91/linux: clk: lan966x: add support for lan969x SoC clock driver clk: lan966x: prepare driver for lan969x support clk: lan966x: make clk_names const char * const dt-bindings: clock: add support for lan969x
2 parents 9852d85 + 47d072b commit 9d0af68

File tree

2 files changed

+74
-17
lines changed

2 files changed

+74
-17
lines changed

Documentation/devicetree/bindings/clock/microchip,lan966x-gck.yaml

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,18 @@ description: |
1616
1717
properties:
1818
compatible:
19-
const: microchip,lan966x-gck
19+
oneOf:
20+
- enum:
21+
- microchip,lan966x-gck
22+
- microchip,lan9691-gck
23+
- items:
24+
- enum:
25+
- microchip,lan9698-gck
26+
- microchip,lan9696-gck
27+
- microchip,lan9694-gck
28+
- microchip,lan9693-gck
29+
- microchip,lan9692-gck
30+
- const: microchip,lan9691-gck
2031

2132
reg:
2233
minItems: 1

drivers/clk/clk-lan966x.c

Lines changed: 62 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -24,13 +24,20 @@
2424

2525
#define DIV_MAX 255
2626

27-
static const char *clk_names[N_CLOCKS] = {
27+
static const char * const lan966x_clk_names[] = {
2828
"qspi0", "qspi1", "qspi2", "sdmmc0",
2929
"pi", "mcan0", "mcan1", "flexcom0",
3030
"flexcom1", "flexcom2", "flexcom3",
3131
"flexcom4", "timer1", "usb_refclk",
3232
};
3333

34+
static const char * const lan969x_clk_names[] = {
35+
"qspi0", "qspi2", "sdmmc0", "sdmmc1",
36+
"mcan0", "mcan1", "flexcom0",
37+
"flexcom1", "flexcom2", "flexcom3",
38+
"timer1", "usb_refclk",
39+
};
40+
3441
struct lan966x_gck {
3542
struct clk_hw hw;
3643
void __iomem *reg;
@@ -53,14 +60,45 @@ struct clk_gate_soc_desc {
5360
int bit_idx;
5461
};
5562

56-
static const struct clk_gate_soc_desc clk_gate_desc[] = {
63+
static const struct clk_gate_soc_desc lan966x_clk_gate_desc[] = {
5764
{ "uhphs", 11 },
5865
{ "udphs", 10 },
5966
{ "mcramc", 9 },
6067
{ "hmatrix", 8 },
6168
{ }
6269
};
6370

71+
static const struct clk_gate_soc_desc lan969x_clk_gate_desc[] = {
72+
{ "usb_drd", 10 },
73+
{ "mcramc", 9 },
74+
{ "hmatrix", 8 },
75+
{ }
76+
};
77+
78+
struct lan966x_match_data {
79+
char *name;
80+
const char * const *clk_name;
81+
const struct clk_gate_soc_desc *clk_gate_desc;
82+
u8 num_generic_clks;
83+
u8 num_total_clks;
84+
};
85+
86+
static struct lan966x_match_data lan966x_desc = {
87+
.name = "lan966x",
88+
.clk_name = lan966x_clk_names,
89+
.clk_gate_desc = lan966x_clk_gate_desc,
90+
.num_total_clks = 18,
91+
.num_generic_clks = 14,
92+
};
93+
94+
static struct lan966x_match_data lan969x_desc = {
95+
.name = "lan969x",
96+
.clk_name = lan969x_clk_names,
97+
.clk_gate_desc = lan969x_clk_gate_desc,
98+
.num_total_clks = 15,
99+
.num_generic_clks = 12,
100+
};
101+
64102
static DEFINE_SPINLOCK(clk_gate_lock);
65103
static void __iomem *base;
66104

@@ -186,38 +224,45 @@ static struct clk_hw *lan966x_gck_clk_register(struct device *dev, int i)
186224
};
187225

188226
static int lan966x_gate_clk_register(struct device *dev,
227+
const struct lan966x_match_data *data,
189228
struct clk_hw_onecell_data *hw_data,
190229
void __iomem *gate_base)
191230
{
192-
int i;
231+
for (int i = data->num_generic_clks; i < data->num_total_clks; ++i) {
232+
int idx = i - data->num_generic_clks;
233+
const struct clk_gate_soc_desc *desc;
193234

194-
for (i = GCK_GATE_UHPHS; i < N_CLOCKS; ++i) {
195-
int idx = i - GCK_GATE_UHPHS;
235+
desc = &data->clk_gate_desc[idx];
196236

197237
hw_data->hws[i] =
198-
devm_clk_hw_register_gate(dev, clk_gate_desc[idx].name,
199-
"lan966x", 0, gate_base,
200-
clk_gate_desc[idx].bit_idx,
238+
devm_clk_hw_register_gate(dev, desc->name,
239+
data->name, 0, gate_base,
240+
desc->bit_idx,
201241
0, &clk_gate_lock);
202242

203243
if (IS_ERR(hw_data->hws[i]))
204244
return dev_err_probe(dev, PTR_ERR(hw_data->hws[i]),
205245
"failed to register %s clock\n",
206-
clk_gate_desc[idx].name);
246+
desc->name);
207247
}
208248

209249
return 0;
210250
}
211251

212252
static int lan966x_clk_probe(struct platform_device *pdev)
213253
{
254+
const struct lan966x_match_data *data;
214255
struct clk_hw_onecell_data *hw_data;
215256
struct device *dev = &pdev->dev;
216257
void __iomem *gate_base;
217258
struct resource *res;
218259
int i, ret;
219260

220-
hw_data = devm_kzalloc(dev, struct_size(hw_data, hws, N_CLOCKS),
261+
data = device_get_match_data(dev);
262+
if (!data)
263+
return -EINVAL;
264+
265+
hw_data = devm_kzalloc(dev, struct_size(hw_data, hws, data->num_total_clks),
221266
GFP_KERNEL);
222267
if (!hw_data)
223268
return -ENOMEM;
@@ -228,10 +273,10 @@ static int lan966x_clk_probe(struct platform_device *pdev)
228273

229274
init.ops = &lan966x_gck_ops;
230275

231-
hw_data->num = GCK_GATE_UHPHS;
276+
hw_data->num = data->num_generic_clks;
232277

233-
for (i = 0; i < GCK_GATE_UHPHS; i++) {
234-
init.name = clk_names[i];
278+
for (i = 0; i < data->num_generic_clks; i++) {
279+
init.name = data->clk_name[i];
235280
hw_data->hws[i] = lan966x_gck_clk_register(dev, i);
236281
if (IS_ERR(hw_data->hws[i])) {
237282
dev_err(dev, "failed to register %s clock\n",
@@ -246,9 +291,9 @@ static int lan966x_clk_probe(struct platform_device *pdev)
246291
if (IS_ERR(gate_base))
247292
return PTR_ERR(gate_base);
248293

249-
hw_data->num = N_CLOCKS;
294+
hw_data->num = data->num_total_clks;
250295

251-
ret = lan966x_gate_clk_register(dev, hw_data, gate_base);
296+
ret = lan966x_gate_clk_register(dev, data, hw_data, gate_base);
252297
if (ret)
253298
return ret;
254299
}
@@ -257,7 +302,8 @@ static int lan966x_clk_probe(struct platform_device *pdev)
257302
}
258303

259304
static const struct of_device_id lan966x_clk_dt_ids[] = {
260-
{ .compatible = "microchip,lan966x-gck", },
305+
{ .compatible = "microchip,lan966x-gck", .data = &lan966x_desc },
306+
{ .compatible = "microchip,lan9691-gck", .data = &lan969x_desc },
261307
{ }
262308
};
263309
MODULE_DEVICE_TABLE(of, lan966x_clk_dt_ids);

0 commit comments

Comments
 (0)