diff options
Diffstat (limited to 'drivers/pwm/pwm-mediatek.c')
-rw-r--r-- | drivers/pwm/pwm-mediatek.c | 19 |
1 files changed, 18 insertions, 1 deletions
diff --git a/drivers/pwm/pwm-mediatek.c b/drivers/pwm/pwm-mediatek.c index 328c124773b2..eb6674ce995f 100644 --- a/drivers/pwm/pwm-mediatek.c +++ b/drivers/pwm/pwm-mediatek.c | |||
@@ -57,6 +57,7 @@ static const char * const mtk_pwm_clk_name[MTK_CLK_MAX] = { | |||
57 | struct mtk_pwm_platform_data { | 57 | struct mtk_pwm_platform_data { |
58 | unsigned int num_pwms; | 58 | unsigned int num_pwms; |
59 | bool pwm45_fixup; | 59 | bool pwm45_fixup; |
60 | bool has_clks; | ||
60 | }; | 61 | }; |
61 | 62 | ||
62 | /** | 63 | /** |
@@ -86,6 +87,9 @@ static int mtk_pwm_clk_enable(struct pwm_chip *chip, struct pwm_device *pwm) | |||
86 | struct mtk_pwm_chip *pc = to_mtk_pwm_chip(chip); | 87 | struct mtk_pwm_chip *pc = to_mtk_pwm_chip(chip); |
87 | int ret; | 88 | int ret; |
88 | 89 | ||
90 | if (!pc->soc->has_clks) | ||
91 | return 0; | ||
92 | |||
89 | ret = clk_prepare_enable(pc->clks[MTK_CLK_TOP]); | 93 | ret = clk_prepare_enable(pc->clks[MTK_CLK_TOP]); |
90 | if (ret < 0) | 94 | if (ret < 0) |
91 | return ret; | 95 | return ret; |
@@ -112,6 +116,9 @@ static void mtk_pwm_clk_disable(struct pwm_chip *chip, struct pwm_device *pwm) | |||
112 | { | 116 | { |
113 | struct mtk_pwm_chip *pc = to_mtk_pwm_chip(chip); | 117 | struct mtk_pwm_chip *pc = to_mtk_pwm_chip(chip); |
114 | 118 | ||
119 | if (!pc->soc->has_clks) | ||
120 | return; | ||
121 | |||
115 | clk_disable_unprepare(pc->clks[MTK_CLK_PWM1 + pwm->hwpwm]); | 122 | clk_disable_unprepare(pc->clks[MTK_CLK_PWM1 + pwm->hwpwm]); |
116 | clk_disable_unprepare(pc->clks[MTK_CLK_MAIN]); | 123 | clk_disable_unprepare(pc->clks[MTK_CLK_MAIN]); |
117 | clk_disable_unprepare(pc->clks[MTK_CLK_TOP]); | 124 | clk_disable_unprepare(pc->clks[MTK_CLK_TOP]); |
@@ -239,7 +246,7 @@ static int mtk_pwm_probe(struct platform_device *pdev) | |||
239 | if (IS_ERR(pc->regs)) | 246 | if (IS_ERR(pc->regs)) |
240 | return PTR_ERR(pc->regs); | 247 | return PTR_ERR(pc->regs); |
241 | 248 | ||
242 | for (i = 0; i < data->num_pwms + 2; i++) { | 249 | for (i = 0; i < data->num_pwms + 2 && pc->soc->has_clks; i++) { |
243 | pc->clks[i] = devm_clk_get(&pdev->dev, mtk_pwm_clk_name[i]); | 250 | pc->clks[i] = devm_clk_get(&pdev->dev, mtk_pwm_clk_name[i]); |
244 | if (IS_ERR(pc->clks[i])) { | 251 | if (IS_ERR(pc->clks[i])) { |
245 | dev_err(&pdev->dev, "clock: %s fail: %ld\n", | 252 | dev_err(&pdev->dev, "clock: %s fail: %ld\n", |
@@ -274,22 +281,32 @@ static int mtk_pwm_remove(struct platform_device *pdev) | |||
274 | static const struct mtk_pwm_platform_data mt2712_pwm_data = { | 281 | static const struct mtk_pwm_platform_data mt2712_pwm_data = { |
275 | .num_pwms = 8, | 282 | .num_pwms = 8, |
276 | .pwm45_fixup = false, | 283 | .pwm45_fixup = false, |
284 | .has_clks = true, | ||
277 | }; | 285 | }; |
278 | 286 | ||
279 | static const struct mtk_pwm_platform_data mt7622_pwm_data = { | 287 | static const struct mtk_pwm_platform_data mt7622_pwm_data = { |
280 | .num_pwms = 6, | 288 | .num_pwms = 6, |
281 | .pwm45_fixup = false, | 289 | .pwm45_fixup = false, |
290 | .has_clks = true, | ||
282 | }; | 291 | }; |
283 | 292 | ||
284 | static const struct mtk_pwm_platform_data mt7623_pwm_data = { | 293 | static const struct mtk_pwm_platform_data mt7623_pwm_data = { |
285 | .num_pwms = 5, | 294 | .num_pwms = 5, |
286 | .pwm45_fixup = true, | 295 | .pwm45_fixup = true, |
296 | .has_clks = true, | ||
297 | }; | ||
298 | |||
299 | static const struct mtk_pwm_platform_data mt7628_pwm_data = { | ||
300 | .num_pwms = 4, | ||
301 | .pwm45_fixup = true, | ||
302 | .has_clks = false, | ||
287 | }; | 303 | }; |
288 | 304 | ||
289 | static const struct of_device_id mtk_pwm_of_match[] = { | 305 | static const struct of_device_id mtk_pwm_of_match[] = { |
290 | { .compatible = "mediatek,mt2712-pwm", .data = &mt2712_pwm_data }, | 306 | { .compatible = "mediatek,mt2712-pwm", .data = &mt2712_pwm_data }, |
291 | { .compatible = "mediatek,mt7622-pwm", .data = &mt7622_pwm_data }, | 307 | { .compatible = "mediatek,mt7622-pwm", .data = &mt7622_pwm_data }, |
292 | { .compatible = "mediatek,mt7623-pwm", .data = &mt7623_pwm_data }, | 308 | { .compatible = "mediatek,mt7623-pwm", .data = &mt7623_pwm_data }, |
309 | { .compatible = "mediatek,mt7628-pwm", .data = &mt7628_pwm_data }, | ||
293 | { }, | 310 | { }, |
294 | }; | 311 | }; |
295 | MODULE_DEVICE_TABLE(of, mtk_pwm_of_match); | 312 | MODULE_DEVICE_TABLE(of, mtk_pwm_of_match); |