@@ -460,6 +460,37 @@ static int meson_pwm_init_channels_meson8b_v2(struct pwm_chip *chip)
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 ,
@@ -498,6 +529,10 @@ static const struct meson_pwm_data pwm_meson8_v2_data = {
498
529
.channels_init = meson_pwm_init_channels_meson8b_v2 ,
499
530
};
500
531
532
+ static const struct meson_pwm_data pwm_s4_data = {
533
+ .channels_init = meson_pwm_init_channels_s4 ,
534
+ };
535
+
501
536
static const struct of_device_id meson_pwm_matches [] = {
502
537
{
503
538
.compatible = "amlogic,meson8-pwm-v2" ,
@@ -536,6 +571,10 @@ static const struct of_device_id meson_pwm_matches[] = {
536
571
.compatible = "amlogic,meson-g12a-ao-pwm-cd" ,
537
572
.data = & pwm_g12a_ao_cd_data
538
573
},
574
+ {
575
+ .compatible = "amlogic,meson-s4-pwm" ,
576
+ .data = & pwm_s4_data
577
+ },
539
578
{},
540
579
};
541
580
MODULE_DEVICE_TABLE (of , meson_pwm_matches );
0 commit comments