Skip to content

Commit 5880e28

Browse files
claudiubezneanoglitch
authored andcommitted
drivers: pwm: pwm-atmel-tcb: skip 1st divider if gck supported
If GCK is supported (as in case of SAMA5D2) the 1st divider used by pwm-atmel-tcb is the gck selector. Skip it if that is the case. Signed-off-by: Claudiu Beznea <claudiu.beznea@microchip.com>
1 parent 111e415 commit 5880e28

2 files changed

Lines changed: 12 additions & 2 deletions

File tree

drivers/misc/atmel_tclib.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,13 +89,21 @@ static struct atmel_tcb_config tcb_sam9x5_config = {
8989
.counter_width = 32,
9090
};
9191

92+
static struct atmel_tcb_config tcb_sama5d2_config = {
93+
.counter_width = 32,
94+
.has_gclk = 1,
95+
};
96+
9297
static const struct of_device_id atmel_tcb_dt_ids[] = {
9398
{
9499
.compatible = "atmel,at91rm9200-tcb",
95100
.data = &tcb_rm9200_config,
96101
}, {
97102
.compatible = "atmel,at91sam9x5-tcb",
98103
.data = &tcb_sam9x5_config,
104+
}, {
105+
.compatible = "atmel,sama5d2-tcb",
106+
.data = &tcb_sama5d2_config,
99107
}, {
100108
/* sentinel */
101109
}

drivers/pwm/pwm-atmel-tcb.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -289,7 +289,7 @@ static int atmel_tcb_pwm_config(struct pwm_chip *chip, struct pwm_device *pwm,
289289
unsigned index = pwm->hwpwm % 2;
290290
struct atmel_tcb_pwm_device *atcbpwm = NULL;
291291
struct atmel_tc *tc = tcbpwmc->tc;
292-
int i;
292+
int i = 0;
293293
int slowclk = 0;
294294
unsigned period;
295295
unsigned duty;
@@ -301,7 +301,9 @@ static int atmel_tcb_pwm_config(struct pwm_chip *chip, struct pwm_device *pwm,
301301
* Find best clk divisor:
302302
* the smallest divisor which can fulfill the period_ns requirements.
303303
*/
304-
for (i = 0; i < 5; ++i) {
304+
if (tc->tcb_config->has_gclk)
305+
i = 1;
306+
for ( ; i < 5; ++i) {
305307
if (atmel_tc_divisors[i] == 0) {
306308
slowclk = i;
307309
continue;

0 commit comments

Comments
 (0)