Skip to content

Commit f2cea1d

Browse files
jbrun3tUwe Kleine-König
authored andcommitted
pwm: meson: generalize 4 inputs clock on meson8 pwm type
Meson8 pwm type always has 4 input clocks. Some inputs may be grounded, like in the AO domain of some SoCs. Drop the parent number parameter and make this is constant. This is also done to make the addition of generic meson8 compatible easier. Signed-off-by: Jerome Brunet <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Uwe Kleine-König <[email protected]>
1 parent 5fd61cc commit f2cea1d

File tree

1 file changed

+11
-42
lines changed

1 file changed

+11
-42
lines changed

drivers/pwm/pwm-meson.c

Lines changed: 11 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@
6060
#define MISC_A_EN BIT(0)
6161

6262
#define MESON_NUM_PWMS 2
63-
#define MESON_MAX_MUX_PARENTS 4
63+
#define MESON_NUM_MUX_PARENTS 4
6464

6565
static struct meson_pwm_channel_data {
6666
u8 reg_offset;
@@ -97,8 +97,7 @@ struct meson_pwm_channel {
9797
};
9898

9999
struct meson_pwm_data {
100-
const char * const *parent_names;
101-
unsigned int num_parents;
100+
const char *const parent_names[MESON_NUM_MUX_PARENTS];
102101
};
103102

104103
struct meson_pwm {
@@ -339,62 +338,32 @@ static const struct pwm_ops meson_pwm_ops = {
339338
.get_state = meson_pwm_get_state,
340339
};
341340

342-
static const char * const pwm_meson8b_parent_names[] = {
343-
"xtal", NULL, "fclk_div4", "fclk_div3"
344-
};
345-
346341
static const struct meson_pwm_data pwm_meson8b_data = {
347-
.parent_names = pwm_meson8b_parent_names,
348-
.num_parents = ARRAY_SIZE(pwm_meson8b_parent_names),
342+
.parent_names = { "xtal", NULL, "fclk_div4", "fclk_div3" },
349343
};
350344

351345
/*
352346
* Only the 2 first inputs of the GXBB AO PWMs are valid
353347
* The last 2 are grounded
354348
*/
355-
static const char * const pwm_gxbb_ao_parent_names[] = {
356-
"xtal", "clk81"
357-
};
358-
359349
static const struct meson_pwm_data pwm_gxbb_ao_data = {
360-
.parent_names = pwm_gxbb_ao_parent_names,
361-
.num_parents = ARRAY_SIZE(pwm_gxbb_ao_parent_names),
362-
};
363-
364-
static const char * const pwm_axg_ee_parent_names[] = {
365-
"xtal", "fclk_div5", "fclk_div4", "fclk_div3"
350+
.parent_names = { "xtal", "clk81", NULL, NULL },
366351
};
367352

368353
static const struct meson_pwm_data pwm_axg_ee_data = {
369-
.parent_names = pwm_axg_ee_parent_names,
370-
.num_parents = ARRAY_SIZE(pwm_axg_ee_parent_names),
371-
};
372-
373-
static const char * const pwm_axg_ao_parent_names[] = {
374-
"xtal", "axg_ao_clk81", "fclk_div4", "fclk_div5"
354+
.parent_names = { "xtal", "fclk_div5", "fclk_div4", "fclk_div3" },
375355
};
376356

377357
static const struct meson_pwm_data pwm_axg_ao_data = {
378-
.parent_names = pwm_axg_ao_parent_names,
379-
.num_parents = ARRAY_SIZE(pwm_axg_ao_parent_names),
380-
};
381-
382-
static const char * const pwm_g12a_ao_ab_parent_names[] = {
383-
"xtal", "g12a_ao_clk81", "fclk_div4", "fclk_div5"
358+
.parent_names = { "xtal", "axg_ao_clk81", "fclk_div4", "fclk_div5" },
384359
};
385360

386361
static const struct meson_pwm_data pwm_g12a_ao_ab_data = {
387-
.parent_names = pwm_g12a_ao_ab_parent_names,
388-
.num_parents = ARRAY_SIZE(pwm_g12a_ao_ab_parent_names),
389-
};
390-
391-
static const char * const pwm_g12a_ao_cd_parent_names[] = {
392-
"xtal", "g12a_ao_clk81",
362+
.parent_names = { "xtal", "g12a_ao_clk81", "fclk_div4", "fclk_div5" },
393363
};
394364

395365
static const struct meson_pwm_data pwm_g12a_ao_cd_data = {
396-
.parent_names = pwm_g12a_ao_cd_parent_names,
397-
.num_parents = ARRAY_SIZE(pwm_g12a_ao_cd_parent_names),
366+
.parent_names = { "xtal", "g12a_ao_clk81", NULL, NULL },
398367
};
399368

400369
static const struct of_device_id meson_pwm_matches[] = {
@@ -437,13 +406,13 @@ MODULE_DEVICE_TABLE(of, meson_pwm_matches);
437406
static int meson_pwm_init_channels(struct pwm_chip *chip)
438407
{
439408
struct meson_pwm *meson = to_meson_pwm(chip);
440-
struct clk_parent_data mux_parent_data[MESON_MAX_MUX_PARENTS] = {};
409+
struct clk_parent_data mux_parent_data[MESON_NUM_MUX_PARENTS] = {};
441410
struct device *dev = pwmchip_parent(chip);
442411
unsigned int i;
443412
char name[255];
444413
int err;
445414

446-
for (i = 0; i < meson->data->num_parents; i++) {
415+
for (i = 0; i < MESON_NUM_MUX_PARENTS; i++) {
447416
mux_parent_data[i].index = -1;
448417
mux_parent_data[i].name = meson->data->parent_names[i];
449418
}
@@ -459,7 +428,7 @@ static int meson_pwm_init_channels(struct pwm_chip *chip)
459428
init.ops = &clk_mux_ops;
460429
init.flags = 0;
461430
init.parent_data = mux_parent_data;
462-
init.num_parents = meson->data->num_parents;
431+
init.num_parents = MESON_NUM_MUX_PARENTS;
463432

464433
channel->mux.reg = meson->base + REG_MISC_AB;
465434
channel->mux.shift =

0 commit comments

Comments
 (0)