Skip to content

Commit 457e746

Browse files
LorenzoBianconibebarino
authored andcommitted
clk: en7523: Add en_clk_soc_data data structure
Introduce en_clk_soc_data data structure in order to define multiple clk_ops for each supported SoC. This is a preliminary patch to introduce EN7581 clock support. Tested-by: Zhengping Zhang <[email protected]> Signed-off-by: Lorenzo Bianconi <[email protected]> Link: https://lore.kernel.org/r/562a0da8d7874a02a324687c152c87a1549924bd.1712399981.git.lorenzo@kernel.org Signed-off-by: Stephen Boyd <[email protected]>
1 parent 0a382be commit 457e746

File tree

1 file changed

+21
-13
lines changed

1 file changed

+21
-13
lines changed

drivers/clk/clk-en7523.c

Lines changed: 21 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33
#include <linux/delay.h>
44
#include <linux/clk-provider.h>
55
#include <linux/io.h>
6-
#include <linux/of.h>
76
#include <linux/platform_device.h>
7+
#include <linux/property.h>
88
#include <dt-bindings/clock/en7523-clk.h>
99

1010
#define REG_PCI_CONTROL 0x88
@@ -47,6 +47,10 @@ struct en_clk_gate {
4747
struct clk_hw hw;
4848
};
4949

50+
struct en_clk_soc_data {
51+
const struct clk_ops pcie_ops;
52+
};
53+
5054
static const u32 gsw_base[] = { 400000000, 500000000 };
5155
static const u32 emi_base[] = { 333000000, 400000000 };
5256
static const u32 bus_base[] = { 500000000, 540000000 };
@@ -145,11 +149,6 @@ static const struct en_clk_desc en7523_base_clks[] = {
145149
}
146150
};
147151

148-
static const struct of_device_id of_match_clk_en7523[] = {
149-
{ .compatible = "airoha,en7523-scu", },
150-
{ /* sentinel */ }
151-
};
152-
153152
static unsigned int en7523_get_base_rate(void __iomem *base, unsigned int i)
154153
{
155154
const struct en_clk_desc *desc = &en7523_base_clks[i];
@@ -247,14 +246,10 @@ static void en7523_pci_unprepare(struct clk_hw *hw)
247246
static struct clk_hw *en7523_register_pcie_clk(struct device *dev,
248247
void __iomem *np_base)
249248
{
250-
static const struct clk_ops pcie_gate_ops = {
251-
.is_enabled = en7523_pci_is_enabled,
252-
.prepare = en7523_pci_prepare,
253-
.unprepare = en7523_pci_unprepare,
254-
};
249+
const struct en_clk_soc_data *soc_data = device_get_match_data(dev);
255250
struct clk_init_data init = {
256251
.name = "pcie",
257-
.ops = &pcie_gate_ops,
252+
.ops = &soc_data->pcie_ops,
258253
};
259254
struct en_clk_gate *cg;
260255

@@ -264,7 +259,7 @@ static struct clk_hw *en7523_register_pcie_clk(struct device *dev,
264259

265260
cg->base = np_base;
266261
cg->hw.init = &init;
267-
en7523_pci_unprepare(&cg->hw);
262+
init.ops->unprepare(&cg->hw);
268263

269264
if (clk_hw_register(dev, &cg->hw))
270265
return NULL;
@@ -333,6 +328,19 @@ static int en7523_clk_probe(struct platform_device *pdev)
333328
return r;
334329
}
335330

331+
static const struct en_clk_soc_data en7523_data = {
332+
.pcie_ops = {
333+
.is_enabled = en7523_pci_is_enabled,
334+
.prepare = en7523_pci_prepare,
335+
.unprepare = en7523_pci_unprepare,
336+
},
337+
};
338+
339+
static const struct of_device_id of_match_clk_en7523[] = {
340+
{ .compatible = "airoha,en7523-scu", .data = &en7523_data },
341+
{ /* sentinel */ }
342+
};
343+
336344
static struct platform_driver clk_en7523_drv = {
337345
.probe = en7523_clk_probe,
338346
.driver = {

0 commit comments

Comments
 (0)