The maximal prescale value is 10 for all supported variants. So drop the
member in the variant description and introduce a global constant
instead.
This reduces the size of the variant descriptions and the .apply()
callback can be compiled a bit more effectively.
Acked-by: Claudiu Beznea <claudiu.beznea@microchip.com>
Signed-off-by: Uwe Kleine-König <uwe@kleine-koenig.org>
Signed-off-by: Thierry Reding <thierry.reding@gmail.com>
#define PWMV2_CPRD 0x0C
#define PWMV2_CPRDUPD 0x10
+#define PWM_MAX_PRES 10
+
struct atmel_pwm_registers {
u8 period;
u8 period_upd;
struct atmel_pwm_config {
u32 max_period;
- u32 max_pres;
};
struct atmel_pwm_data {
for (*pres = 0; cycles > atmel_pwm->data->cfg.max_period; cycles >>= 1)
(*pres)++;
- if (*pres > atmel_pwm->data->cfg.max_pres) {
+ if (*pres > PWM_MAX_PRES) {
dev_err(chip->dev, "pres exceeds the maximum value\n");
return -EINVAL;
}
.cfg = {
/* 16 bits to keep period and duty. */
.max_period = 0xffff,
- .max_pres = 10,
},
};
.cfg = {
/* 16 bits to keep period and duty. */
.max_period = 0xffff,
- .max_pres = 10,
},
};
.cfg = {
/* 32 bits to keep period and duty. */
.max_period = 0xffffffff,
- .max_pres = 10,
},
};