[PATCH] regulator: rpi-panel-v2: Convert to new PWM waveform ops

Marek Vasut marek.vasut at mailbox.org
Tue Jun 17 02:38:50 PDT 2025


On 6/17/25 10:14 AM, Uwe Kleine-König wrote:

Hi,

[...]

> /* The actual value isn't known, so this is made up. */
> #define RPI_PANEL_V2_FIXED_PERIOD_NS 100000
> 
> 
> static int rpi_panel_v2_pwm_round_waveform_tohw(...)
> {
> 	...
> 
> 	if (wf->duty_length_ns > RPI_PANEL_V2_FIXED_PERIOD_NS)
> 		*wfhw = 100;
> 	else
> 		*wfhw = mul_u64_u64_div_u64(wf->duty_length_ns * 100, RPI_PANEL_V2_FIXED_PERIOD_NS);
> 
> 	return 0;
> }

This fixed period specified in driver has one problem -- what if the 
period is also specified in DT by the consumer, e.g. pwm-backlight pwms 
property, and it does not match RPI_PANEL_V2_FIXED_PERIOD_NS ?

This is easy to solve for this tohw function, but what about the fromhw 
which assigns period_ns ?

>> +static int rpi_panel_v2_pwm_write_waveform(struct pwm_chip *chip,
>> +					   struct pwm_device *pwm,
>> +					   const void *_wfhw)
>> +{
>> +	struct regmap *regmap = pwmchip_get_drvdata(chip);
>> +	const u8 *wfhw = _wfhw;
>>   
>> -	duty = pwm_get_relative_duty_cycle(state, PWM_BL_MASK);
>> -	return regmap_write(regmap, REG_PWM, duty | PWM_BL_ENABLE);
>> +	return regmap_write(regmap, REG_PWM, *wfhw | (*wfhw ? PWM_BL_ENABLE : 0));
> 
> How does the PWM behave without PWM_BL_ENABLE set?
The display stays dark.



More information about the linux-arm-kernel mailing list