Skip to content

Commit 483f364

Browse files
Nicolas Frattarolibebarino
authored andcommitted
clk: mediatek: Refactor pllfh registration to pass device
After refactoring all of PLL to pass the device, it's now fairly easy to refactor pllfh and its users, as pllfh registration wraps PLL registration. Do this refactor and move all of the pllfh users to pass the device as well. Reviewed-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com> Signed-off-by: Nicolas Frattaroli <nicolas.frattaroli@collabora.com> Signed-off-by: Stephen Boyd <sboyd@kernel.org>
1 parent ecffd05 commit 483f364

7 files changed

Lines changed: 20 additions & 17 deletions

File tree

drivers/clk/mediatek/clk-mt6795-apmixedsys.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,7 @@ static int clk_mt6795_apmixed_probe(struct platform_device *pdev)
152152
return -ENOMEM;
153153

154154
fhctl_parse_dt(fhctl_node, pllfhs, ARRAY_SIZE(pllfhs));
155-
ret = mtk_clk_register_pllfhs(node, plls, ARRAY_SIZE(plls),
155+
ret = mtk_clk_register_pllfhs(dev, plls, ARRAY_SIZE(plls),
156156
pllfhs, ARRAY_SIZE(pllfhs), clk_data);
157157
if (ret)
158158
goto free_clk_data;

drivers/clk/mediatek/clk-mt8173-apmixedsys.c

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -140,13 +140,13 @@ MODULE_DEVICE_TABLE(of, of_match_clk_mt8173_apmixed);
140140
static int clk_mt8173_apmixed_probe(struct platform_device *pdev)
141141
{
142142
const u8 *fhctl_node = "mediatek,mt8173-fhctl";
143-
struct device_node *node = pdev->dev.of_node;
144143
struct clk_hw_onecell_data *clk_data;
144+
struct device *dev = &pdev->dev;
145145
void __iomem *base;
146146
struct clk_hw *hw;
147147
int r;
148148

149-
base = of_iomap(node, 0);
149+
base = of_iomap(dev->of_node, 0);
150150
if (!base)
151151
return -ENOMEM;
152152

@@ -157,25 +157,25 @@ static int clk_mt8173_apmixed_probe(struct platform_device *pdev)
157157
}
158158

159159
fhctl_parse_dt(fhctl_node, pllfhs, ARRAY_SIZE(pllfhs));
160-
r = mtk_clk_register_pllfhs(node, plls, ARRAY_SIZE(plls),
161-
pllfhs, ARRAY_SIZE(pllfhs), clk_data);
160+
r = mtk_clk_register_pllfhs(dev, plls, ARRAY_SIZE(plls), pllfhs,
161+
ARRAY_SIZE(pllfhs), clk_data);
162162
if (r)
163163
goto free_clk_data;
164164

165165
hw = mtk_clk_register_ref2usb_tx("ref2usb_tx", "clk26m", base + REGOFF_REF2USB);
166166
if (IS_ERR(hw)) {
167167
r = PTR_ERR(hw);
168-
dev_err(&pdev->dev, "Failed to register ref2usb_tx: %d\n", r);
168+
dev_err(dev, "Failed to register ref2usb_tx: %d\n", r);
169169
goto unregister_plls;
170170
}
171171
clk_data->hws[CLK_APMIXED_REF2USB_TX] = hw;
172172

173-
hw = devm_clk_hw_register_divider(&pdev->dev, "hdmi_ref", "tvdpll_594m", 0,
173+
hw = devm_clk_hw_register_divider(dev, "hdmi_ref", "tvdpll_594m", 0,
174174
base + REGOFF_HDMI_REF, 16, 3,
175175
CLK_DIVIDER_POWER_OF_TWO, NULL);
176176
clk_data->hws[CLK_APMIXED_HDMI_REF] = hw;
177177

178-
r = of_clk_add_hw_provider(node, of_clk_hw_onecell_get, clk_data);
178+
r = of_clk_add_hw_provider(dev->of_node, of_clk_hw_onecell_get, clk_data);
179179
if (r)
180180
goto unregister_ref2usb;
181181

drivers/clk/mediatek/clk-mt8186-apmixedsys.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,7 @@ static int clk_mt8186_apmixed_probe(struct platform_device *pdev)
151151

152152
fhctl_parse_dt(fhctl_node, pllfhs, ARRAY_SIZE(pllfhs));
153153

154-
r = mtk_clk_register_pllfhs(node, plls, ARRAY_SIZE(plls),
154+
r = mtk_clk_register_pllfhs(&pdev->dev, plls, ARRAY_SIZE(plls),
155155
pllfhs, ARRAY_SIZE(pllfhs), clk_data);
156156
if (r)
157157
goto free_apmixed_data;

drivers/clk/mediatek/clk-mt8192-apmixedsys.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,7 @@ static int clk_mt8192_apmixed_probe(struct platform_device *pdev)
162162

163163
fhctl_parse_dt(fhctl_node, pllfhs, ARRAY_SIZE(pllfhs));
164164

165-
r = mtk_clk_register_pllfhs(node, plls, ARRAY_SIZE(plls),
165+
r = mtk_clk_register_pllfhs(&pdev->dev, plls, ARRAY_SIZE(plls),
166166
pllfhs, ARRAY_SIZE(pllfhs), clk_data);
167167
if (r)
168168
goto free_clk_data;

drivers/clk/mediatek/clk-mt8195-apmixedsys.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,7 @@ static int clk_mt8195_apmixed_probe(struct platform_device *pdev)
181181

182182
fhctl_parse_dt(fhctl_node, pllfhs, ARRAY_SIZE(pllfhs));
183183

184-
r = mtk_clk_register_pllfhs(node, plls, ARRAY_SIZE(plls),
184+
r = mtk_clk_register_pllfhs(&pdev->dev, plls, ARRAY_SIZE(plls),
185185
pllfhs, ARRAY_SIZE(pllfhs), clk_data);
186186
if (r)
187187
goto free_apmixed_data;

drivers/clk/mediatek/clk-pllfh.c

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
#include <linux/slab.h>
1111
#include <linux/clkdev.h>
1212
#include <linux/delay.h>
13+
#include <linux/device.h>
1314

1415
#include "clk-mtk.h"
1516
#include "clk-pllfh.h"
@@ -149,7 +150,7 @@ static bool fhctl_is_supported_and_enabled(const struct mtk_pllfh_data *pllfh)
149150
}
150151

151152
static struct clk_hw *
152-
mtk_clk_register_pllfh(const struct mtk_pll_data *pll_data,
153+
mtk_clk_register_pllfh(struct device *dev, const struct mtk_pll_data *pll_data,
153154
struct mtk_pllfh_data *pllfh_data, void __iomem *base)
154155
{
155156
struct clk_hw *hw;
@@ -166,6 +167,8 @@ mtk_clk_register_pllfh(const struct mtk_pll_data *pll_data,
166167
goto out;
167168
}
168169

170+
fh->clk_pll.dev = dev;
171+
169172
hw = mtk_clk_register_pll_ops(&fh->clk_pll, pll_data, base,
170173
&mtk_pllfh_ops);
171174

@@ -194,7 +197,7 @@ static void mtk_clk_unregister_pllfh(struct clk_hw *hw)
194197
kfree(fh);
195198
}
196199

197-
int mtk_clk_register_pllfhs(struct device_node *node,
200+
int mtk_clk_register_pllfhs(struct device *dev,
198201
const struct mtk_pll_data *plls, int num_plls,
199202
struct mtk_pllfh_data *pllfhs, int num_fhs,
200203
struct clk_hw_onecell_data *clk_data)
@@ -203,7 +206,7 @@ int mtk_clk_register_pllfhs(struct device_node *node,
203206
int i;
204207
struct clk_hw *hw;
205208

206-
base = of_iomap(node, 0);
209+
base = of_iomap(dev->of_node, 0);
207210
if (!base) {
208211
pr_err("%s(): ioremap failed\n", __func__);
209212
return -EINVAL;
@@ -218,9 +221,9 @@ int mtk_clk_register_pllfhs(struct device_node *node,
218221
use_fhctl = fhctl_is_supported_and_enabled(pllfh);
219222

220223
if (use_fhctl)
221-
hw = mtk_clk_register_pllfh(pll, pllfh, base);
224+
hw = mtk_clk_register_pllfh(dev, pll, pllfh, base);
222225
else
223-
hw = mtk_clk_register_pll(NULL, pll, base);
226+
hw = mtk_clk_register_pll(dev, pll, base);
224227

225228
if (IS_ERR(hw)) {
226229
pr_err("Failed to register %s clk %s: %ld\n",

drivers/clk/mediatek/clk-pllfh.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ struct fh_operation {
6868
int (*ssc_enable)(struct mtk_fh *fh, u32 rate);
6969
};
7070

71-
int mtk_clk_register_pllfhs(struct device_node *node,
71+
int mtk_clk_register_pllfhs(struct device *dev,
7272
const struct mtk_pll_data *plls, int num_plls,
7373
struct mtk_pllfh_data *pllfhs, int num_pllfhs,
7474
struct clk_hw_onecell_data *clk_data);

0 commit comments

Comments
 (0)