Skip to content

Commit 7a33504

Browse files
Anjelique Melendezlag-linaro
authored andcommitted
leds: rgb: leds-qcom-lpg: Add support for 6-bit PWM resolution
Currently, driver only allows for PWM modules to use 9-bit resolution. However, PWM modules can support 6-bit and 9-bit resolution. Add support for 6-bit resolution. Suggested-by: Zejiong Huang <[email protected]> Signed-off-by: Anjelique Melendez <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Lee Jones <[email protected]>
1 parent 2c70953 commit 7a33504

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

drivers/leds/rgb/leds-qcom-lpg.c

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
#define LPG_PATTERN_CONFIG_REG 0x40
2525
#define LPG_SIZE_CLK_REG 0x41
2626
#define PWM_CLK_SELECT_MASK GENMASK(1, 0)
27+
#define PWM_SIZE_SELECT_MASK BIT(2)
2728
#define PWM_CLK_SELECT_HI_RES_MASK GENMASK(2, 0)
2829
#define PWM_SIZE_HI_RES_MASK GENMASK(6, 4)
2930
#define LPG_PREDIV_CLK_REG 0x42
@@ -412,8 +413,8 @@ static int lpg_lut_sync(struct lpg *lpg, unsigned int mask)
412413
static const unsigned int lpg_clk_rates[] = {0, 1024, 32768, 19200000};
413414
static const unsigned int lpg_clk_rates_hi_res[] = {0, 1024, 32768, 19200000, 76800000};
414415
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};
417418

418419
static int lpg_calc_freq(struct lpg_channel *chan, uint64_t period)
419420
{
@@ -436,12 +437,12 @@ static int lpg_calc_freq(struct lpg_channel *chan, uint64_t period)
436437
* period = --------------------------
437438
* refclk
438439
*
439-
* Resolution = 2^9 bits for PWM or
440+
* Resolution = 2^{6 or 9} bits for PWM or
440441
* 2^{8, 9, 10, 11, 12, 13, 14, 15} bits for high resolution PWM
441442
* pre_div = {1, 3, 5, 6} and
442443
* M = [0..7].
443444
*
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
445446
* 3uS and 24576s for high resolution PWMs.
446447
* The PWM framework wants a period of equal or lower length than requested,
447448
* reject anything below minimum period.
@@ -558,7 +559,7 @@ static void lpg_apply_freq(struct lpg_channel *chan)
558559
val |= GENMASK(5, 4);
559560
break;
560561
case LPG_SUBTYPE_PWM:
561-
val |= BIT(2);
562+
val |= FIELD_PREP(PWM_SIZE_SELECT_MASK, chan->pwm_resolution_sel);
562563
break;
563564
case LPG_SUBTYPE_HI_RES_PWM:
564565
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,
12761277
resolution = lpg_pwm_resolution_hi_res[FIELD_GET(PWM_SIZE_HI_RES_MASK, val)];
12771278
} else {
12781279
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)];
12801281
}
12811282

12821283
if (refclk) {

0 commit comments

Comments
 (0)