Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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>

authored by

John Crispin and committed by
Thierry Reding
8cdc43af 935be8e0

+19 -2
+1 -1
drivers/pwm/Kconfig
··· 286 286 287 287 config PWM_MEDIATEK 288 288 tristate "MediaTek PWM support" 289 - depends on ARCH_MEDIATEK || COMPILE_TEST 289 + depends on ARCH_MEDIATEK || RALINK || COMPILE_TEST 290 290 help 291 291 Generic PWM framework driver for Mediatek ARM SoC. 292 292
+18 -1
drivers/pwm/pwm-mediatek.c
··· 57 57 struct mtk_pwm_platform_data { 58 58 unsigned int num_pwms; 59 59 bool pwm45_fixup; 60 + bool has_clks; 60 61 }; 61 62 62 63 /** ··· 87 86 struct mtk_pwm_chip *pc = to_mtk_pwm_chip(chip); 88 87 int ret; 89 88 89 + if (!pc->soc->has_clks) 90 + return 0; 91 + 90 92 ret = clk_prepare_enable(pc->clks[MTK_CLK_TOP]); 91 93 if (ret < 0) 92 94 return ret; ··· 115 111 static void mtk_pwm_clk_disable(struct pwm_chip *chip, struct pwm_device *pwm) 116 112 { 117 113 struct mtk_pwm_chip *pc = to_mtk_pwm_chip(chip); 114 + 115 + if (!pc->soc->has_clks) 116 + return; 118 117 119 118 clk_disable_unprepare(pc->clks[MTK_CLK_PWM1 + pwm->hwpwm]); 120 119 clk_disable_unprepare(pc->clks[MTK_CLK_MAIN]); ··· 246 239 if (IS_ERR(pc->regs)) 247 240 return PTR_ERR(pc->regs); 248 241 249 - for (i = 0; i < data->num_pwms + 2; i++) { 242 + for (i = 0; i < data->num_pwms + 2 && pc->soc->has_clks; i++) { 250 243 pc->clks[i] = devm_clk_get(&pdev->dev, mtk_pwm_clk_name[i]); 251 244 if (IS_ERR(pc->clks[i])) { 252 245 dev_err(&pdev->dev, "clock: %s fail: %ld\n", ··· 281 274 static const struct mtk_pwm_platform_data mt2712_pwm_data = { 282 275 .num_pwms = 8, 283 276 .pwm45_fixup = false, 277 + .has_clks = true, 284 278 }; 285 279 286 280 static const struct mtk_pwm_platform_data mt7622_pwm_data = { 287 281 .num_pwms = 6, 288 282 .pwm45_fixup = false, 283 + .has_clks = true, 289 284 }; 290 285 291 286 static const struct mtk_pwm_platform_data mt7623_pwm_data = { 292 287 .num_pwms = 5, 293 288 .pwm45_fixup = true, 289 + .has_clks = true, 290 + }; 291 + 292 + static const struct mtk_pwm_platform_data mt7628_pwm_data = { 293 + .num_pwms = 4, 294 + .pwm45_fixup = true, 295 + .has_clks = false, 294 296 }; 295 297 296 298 static const struct of_device_id mtk_pwm_of_match[] = { 297 299 { .compatible = "mediatek,mt2712-pwm", .data = &mt2712_pwm_data }, 298 300 { .compatible = "mediatek,mt7622-pwm", .data = &mt7622_pwm_data }, 299 301 { .compatible = "mediatek,mt7623-pwm", .data = &mt7623_pwm_data }, 302 + { .compatible = "mediatek,mt7628-pwm", .data = &mt7628_pwm_data }, 300 303 { }, 301 304 }; 302 305 MODULE_DEVICE_TABLE(of, mtk_pwm_of_match);