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

Configure Feed

Select the types of activity you want to include in your feed.

pwm: meson: Add support for Amlogic S4 PWM

Add support for Amlogic S4 PWM.

Signed-off-by: Junyi Zhao <junyi.zhao@amlogic.com>
Signed-off-by: Kelvin Zhang <kelvin.zhang@amlogic.com>
Reviewed-by: George Stark <gnstark@salutedevices.com>
Link: https://lore.kernel.org/r/20240613-s4-pwm-v8-1-b5bd0a768282@amlogic.com
Signed-off-by: Uwe Kleine-König <ukleinek@kernel.org>

authored by

Junyi Zhao and committed by
Uwe Kleine-König
2ed3284f 7f61257c

+39
+39
drivers/pwm/pwm-meson.c
··· 460 460 return meson_pwm_init_clocks_meson8b(chip, mux_parent_data); 461 461 } 462 462 463 + static void meson_pwm_s4_put_clk(void *data) 464 + { 465 + struct clk *clk = data; 466 + 467 + clk_put(clk); 468 + } 469 + 470 + static int meson_pwm_init_channels_s4(struct pwm_chip *chip) 471 + { 472 + struct device *dev = pwmchip_parent(chip); 473 + struct device_node *np = dev->of_node; 474 + struct meson_pwm *meson = to_meson_pwm(chip); 475 + int i, ret; 476 + 477 + for (i = 0; i < MESON_NUM_PWMS; i++) { 478 + meson->channels[i].clk = of_clk_get(np, i); 479 + if (IS_ERR(meson->channels[i].clk)) 480 + return dev_err_probe(dev, 481 + PTR_ERR(meson->channels[i].clk), 482 + "Failed to get clk\n"); 483 + 484 + ret = devm_add_action_or_reset(dev, meson_pwm_s4_put_clk, 485 + meson->channels[i].clk); 486 + if (ret) 487 + return dev_err_probe(dev, ret, 488 + "Failed to add clk_put action\n"); 489 + } 490 + 491 + return 0; 492 + } 493 + 463 494 static const struct meson_pwm_data pwm_meson8b_data = { 464 495 .parent_names = { "xtal", NULL, "fclk_div4", "fclk_div3" }, 465 496 .channels_init = meson_pwm_init_channels_meson8b_legacy, ··· 527 496 528 497 static const struct meson_pwm_data pwm_meson8_v2_data = { 529 498 .channels_init = meson_pwm_init_channels_meson8b_v2, 499 + }; 500 + 501 + static const struct meson_pwm_data pwm_s4_data = { 502 + .channels_init = meson_pwm_init_channels_s4, 530 503 }; 531 504 532 505 static const struct of_device_id meson_pwm_matches[] = { ··· 570 535 { 571 536 .compatible = "amlogic,meson-g12a-ao-pwm-cd", 572 537 .data = &pwm_g12a_ao_cd_data 538 + }, 539 + { 540 + .compatible = "amlogic,meson-s4-pwm", 541 + .data = &pwm_s4_data 573 542 }, 574 543 {}, 575 544 };