Skip to content

Commit 2ed3284

Browse files
Junyi ZhaoUwe Kleine-König
authored andcommitted
pwm: meson: Add support for Amlogic S4 PWM
Add support for Amlogic S4 PWM. Signed-off-by: Junyi Zhao <[email protected]> Signed-off-by: Kelvin Zhang <[email protected]> Reviewed-by: George Stark <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Uwe Kleine-König <[email protected]>
1 parent 7f61257 commit 2ed3284

File tree

1 file changed

+39
-0
lines changed

1 file changed

+39
-0
lines changed

drivers/pwm/pwm-meson.c

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -460,6 +460,37 @@ static int meson_pwm_init_channels_meson8b_v2(struct pwm_chip *chip)
460460
return meson_pwm_init_clocks_meson8b(chip, mux_parent_data);
461461
}
462462

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+
463494
static const struct meson_pwm_data pwm_meson8b_data = {
464495
.parent_names = { "xtal", NULL, "fclk_div4", "fclk_div3" },
465496
.channels_init = meson_pwm_init_channels_meson8b_legacy,
@@ -498,6 +529,10 @@ static const struct meson_pwm_data pwm_meson8_v2_data = {
498529
.channels_init = meson_pwm_init_channels_meson8b_v2,
499530
};
500531

532+
static const struct meson_pwm_data pwm_s4_data = {
533+
.channels_init = meson_pwm_init_channels_s4,
534+
};
535+
501536
static const struct of_device_id meson_pwm_matches[] = {
502537
{
503538
.compatible = "amlogic,meson8-pwm-v2",
@@ -536,6 +571,10 @@ static const struct of_device_id meson_pwm_matches[] = {
536571
.compatible = "amlogic,meson-g12a-ao-pwm-cd",
537572
.data = &pwm_g12a_ao_cd_data
538573
},
574+
{
575+
.compatible = "amlogic,meson-s4-pwm",
576+
.data = &pwm_s4_data
577+
},
539578
{},
540579
};
541580
MODULE_DEVICE_TABLE(of, meson_pwm_matches);

0 commit comments

Comments
 (0)