24
24
#define LPG_PATTERN_CONFIG_REG 0x40
25
25
#define LPG_SIZE_CLK_REG 0x41
26
26
#define PWM_CLK_SELECT_MASK GENMASK(1, 0)
27
+ #define PWM_SIZE_SELECT_MASK BIT(2)
27
28
#define PWM_CLK_SELECT_HI_RES_MASK GENMASK(2, 0)
28
29
#define PWM_SIZE_HI_RES_MASK GENMASK(6, 4)
29
30
#define LPG_PREDIV_CLK_REG 0x42
@@ -412,8 +413,8 @@ static int lpg_lut_sync(struct lpg *lpg, unsigned int mask)
412
413
static const unsigned int lpg_clk_rates [] = {0 , 1024 , 32768 , 19200000 };
413
414
static const unsigned int lpg_clk_rates_hi_res [] = {0 , 1024 , 32768 , 19200000 , 76800000 };
414
415
static const unsigned int lpg_pre_divs [] = {1 , 3 , 5 , 6 };
415
- static const unsigned int lpg_pwm_resolution [] = { 9 };
416
- static const unsigned int lpg_pwm_resolution_hi_res [] = {8 , 9 , 10 , 11 , 12 , 13 , 14 , 15 };
416
+ static const unsigned int lpg_pwm_resolution [] = { 6 , 9 };
417
+ static const unsigned int lpg_pwm_resolution_hi_res [] = {8 , 9 , 10 , 11 , 12 , 13 , 14 , 15 };
417
418
418
419
static int lpg_calc_freq (struct lpg_channel * chan , uint64_t period )
419
420
{
@@ -436,12 +437,12 @@ static int lpg_calc_freq(struct lpg_channel *chan, uint64_t period)
436
437
* period = --------------------------
437
438
* refclk
438
439
*
439
- * Resolution = 2^9 bits for PWM or
440
+ * Resolution = 2^{6 or 9} bits for PWM or
440
441
* 2^{8, 9, 10, 11, 12, 13, 14, 15} bits for high resolution PWM
441
442
* pre_div = {1, 3, 5, 6} and
442
443
* M = [0..7].
443
444
*
444
- * This allows for periods between 27uS and 384s for PWM channels and periods between
445
+ * This allows for periods between 3uS and 384s for PWM channels and periods between
445
446
* 3uS and 24576s for high resolution PWMs.
446
447
* The PWM framework wants a period of equal or lower length than requested,
447
448
* reject anything below minimum period.
@@ -558,7 +559,7 @@ static void lpg_apply_freq(struct lpg_channel *chan)
558
559
val |= GENMASK (5 , 4 );
559
560
break ;
560
561
case LPG_SUBTYPE_PWM :
561
- val |= BIT ( 2 );
562
+ val |= FIELD_PREP ( PWM_SIZE_SELECT_MASK , chan -> pwm_resolution_sel );
562
563
break ;
563
564
case LPG_SUBTYPE_HI_RES_PWM :
564
565
val |= FIELD_PREP (PWM_SIZE_HI_RES_MASK , chan -> pwm_resolution_sel );
@@ -1276,7 +1277,7 @@ static int lpg_pwm_get_state(struct pwm_chip *chip, struct pwm_device *pwm,
1276
1277
resolution = lpg_pwm_resolution_hi_res [FIELD_GET (PWM_SIZE_HI_RES_MASK , val )];
1277
1278
} else {
1278
1279
refclk = lpg_clk_rates [FIELD_GET (PWM_CLK_SELECT_MASK , val )];
1279
- resolution = 9 ;
1280
+ resolution = lpg_pwm_resolution [ FIELD_GET ( PWM_SIZE_SELECT_MASK , val )] ;
1280
1281
}
1281
1282
1282
1283
if (refclk ) {
0 commit comments