summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJohn Crispin <john@phrozen.org>2018-07-25 05:52:09 -0400
committerThierry Reding <thierry.reding@gmail.com>2018-08-20 05:36:07 -0400
commit8cdc43afbb2cb58692c49fab0b13e2d9439c0642 (patch)
treeffdf3335ba19d2f12ba5f404d6117f82dd7ce612
parent935be8e08a73e090ee8a9e252242c089f81a4ce4 (diff)
pwm: mediatek: Add MT7628 support
Add support for MT7628. The SoC is legacy MIPS and hence has no complex clock tree. This patch add an extra flag to the SoC specific data indicating, that no clocks are present. Signed-off-by: John Crispin <john@phrozen.org> Reviewed-by: Matthias Brugger <matthias.bgg@gmail.com> Signed-off-by: Thierry Reding <thierry.reding@gmail.com>
-rw-r--r--drivers/pwm/Kconfig2
-rw-r--r--drivers/pwm/pwm-mediatek.c19
2 files changed, 19 insertions, 2 deletions
diff --git a/drivers/pwm/Kconfig b/drivers/pwm/Kconfig
index a4d262db9945..504d252716f2 100644
--- a/drivers/pwm/Kconfig
+++ b/drivers/pwm/Kconfig
@@ -286,7 +286,7 @@ config PWM_MTK_DISP
286 286
287config PWM_MEDIATEK 287config PWM_MEDIATEK
288 tristate "MediaTek PWM support" 288 tristate "MediaTek PWM support"
289 depends on ARCH_MEDIATEK || COMPILE_TEST 289 depends on ARCH_MEDIATEK || RALINK || COMPILE_TEST
290 help 290 help
291 Generic PWM framework driver for Mediatek ARM SoC. 291 Generic PWM framework driver for Mediatek ARM SoC.
292 292
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] = {
57struct mtk_pwm_platform_data { 57struct 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)
274static const struct mtk_pwm_platform_data mt2712_pwm_data = { 281static 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
279static const struct mtk_pwm_platform_data mt7622_pwm_data = { 287static 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
284static const struct mtk_pwm_platform_data mt7623_pwm_data = { 293static 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
299static 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
289static const struct of_device_id mtk_pwm_of_match[] = { 305static 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};
295MODULE_DEVICE_TABLE(of, mtk_pwm_of_match); 312MODULE_DEVICE_TABLE(of, mtk_pwm_of_match);