Configuring pin as PWM for LCD backlight

Hi,
@danielt, @bamse, @architt, @Loic
I’m using Debian kernel 4.14 and TPS61165 driver for controlling the the LCD backlight. I’m facing issue in configuring the gpio pin as PWM pin for LCD panel.
The driver is getting initiated successfully, but there is no effect/change in the brightness even after changing the brightness entries in driver and sysfs.

So, I would require help on configuring the GPIO pin as PWM and on changing the duty cycle for brightness control.

Thanks in Advance.
Naveena.M

Hi Naveena,

Can you describe what you’ve hooked up to the CTRL pin of the TPS61165 and how you have configured the relevant GPIO pin?

Regards,
Bjorn

Hi @bamse,
I have configured the GPIO 5 in device tree as below:

    pinctrl-names = "default";
    pinctrl-0 = <&ls_exp_gpio_f>;

    ls_exp_gpio_f: pm8994_gpio5 {
     pinconf {
                    pins = "gpio5";
                    function = PMIC_GPIO_FUNC_NORMAL;
                    output-high;
                    qcom,dtest = <1>;
                    power-source = <PM8994_GPIO_S4>; // 1.8V
                    qcom,drive-strength = <3>;
                    bias-pull-down; 
                }; 
          };

     backlight {
                    compatible = "ti,tps61165_bl";
                    rfa_en = <1>;
                    en_gpio_num = <&pm8994_gpios 5 GPIO_ACTIVE_HIGH>;
         };

How to configure the pin as PWM to control the backlight?

Regards,
Naveena.M

AFAIU, TPS61165 can work in ‘EasyScale one-wire’ mode, which allows to control dimming via a simple gpio. This seems to be what the tps61165_bl driver is doing. So you don’t have to configure the pin in PWM mode but to keep in GPIO mode and let the driver manage it.

I suggest keeping pinconf with ‘output-low’ (initial shutdown state) and removing ‘qcom,dtest’ property.

Then probe the pin and check that there is some activity at init.

Also check I/O level compatibility. I understand control pin I/O level should be the same as VIN, which shoudl be 3V (min). DB820C I/O level is 1.8V by default (not sure we can change that via power-source here), so you may need a level shifter.

I made the pinconf as ‘output-low’ and removed the ‘qcom,dtest’ and booted the board.
The backlight was switched off. When probed, no voltage passed to the control pin.
But when the pinconf was kept as ‘output-high’, the voltage to the control pin was 3.3V.

The driver is getting initiated successfully but there is no effect/change in the brightness even after changing the brightness entries in driver and sysfs.

[ 12.496868] tps611xx_bl soc:backlight: [tps61165]based on EasyScale is initialized

root@root:/sys/class/backlight/tps611xx_bl# ls
actual_brightness  brightness  enable          power      type
bl_power           device      max_brightness  subsystem  uevent

I would like to know how to control the backlight brightness by using GPIO. Should anything else be configured to control dimming?

Regards,
Naveena.M

well, I’m not sure wich driver you are using since there is no tps611xx_bl driver upstream, but if you’re trying to use tps611xx_bl.c « backlight « video « drivers - mlp-open-source/kernel - Linux/Android device drivers development project for the products of MLP/SVA., the way the gpio is retrieved is probably wrong, you can’t specify a global gpio number in the devicetree since it’s allocated at runtime.

I would suggest to rename en_gpio_num in the devicetree with enable-gpios:

enable-gpios = <&pm8994_gpios 5 GPIO_ACTIVE_HIGH>;

And then adapt the driver tps611xx_backlight_parse_dt function to correctly retrieve the gpio with something like:

struct gpiod_desc *enable_gpio_desc;
enable_gpio_desc = devm_gpiod_get(dev, "enable", GPIOD_OUT_LOW);
pchip->en_gpio = desc_to_gpio(enable_gpio_desc);

Where is the 3.3v coming from? How exactly do you have the CTRL pin connected to the gpio?

Your configuration of gpio5 being output-high and “enable gpio” seems to match the fact that your backlight turns on and stays on, and output-low means it’s off.

What you’re looking for is to have a PWM signal from the LPG block act as control signal for the GPIO pin, rather than a normal software controlled GPIO. The typical way to do this is to have the LPG output its signal on a dtest line and have the GPIO be wired up to the same line.

There are some restrictions in how this can be routed and I’m not able to find my notes on the subject at this time. But does perhaps the fact that you have a qcom,dtest in your gpio5 node indicate that you have found this somewhere with an lpg node as well?

Regards,
Bjorn

A level shifter is used to shift the voltage from default 1.8V to 3.3V. So the voltage to the control pin, when probed is 3.3V.

The PMIC gpio is connected to the connector pin of LCD panel which goes to the control pin of the TPS61165.

@Loic,
I’ll try updating the driver and update the status.

Regards,
Naveena.M

I couldn’t find way to have LPG out it signal on dtest line. Configuring this part is the problem I’m facing currently.

I took PM8916 as reference for the dtest. I’m not pretty sure with the dtest line.
I would like to know how to make LPG out through dtest line and wiring it up with GPIO5?

Regards,
Naveena.M

Any hint to move forward…?

Regards,
Naveena.M

Well any update on this?

Hi,

I tried editing the driver file as mentioned above. Now I’m getting this error in probing while assigning GPIO.

[ 3.495363] tps611xx_bl soc:backlight: failed : get gpio 22

The GPIO that I’m trying to configure is PMIC gpio 5, but here gpio22 is used even though I have assigned gpio value as 5 in the device tree.
Whereas if we directly assign the gpio as per the tps611xx-backlight.txt

en_gpio_num = <5>;

the gpio value is taken correctly as 5. But how will the driver know whether to use pmic or msm gpio?
What is the thing I’m missing here?

Regards,
Naveena.M

[ 3.495363] tps611xx_bl soc:backlight: failed : get gpio 22

Is there any error code, is the gpio used for anything else in your device tree?

The GPIO that I’m trying to configure is PMIC gpio 5, but here gpio22 is used even though I have assigned gpio value as 5 in the device tree.

22 is just a global gpio number assigned by Linux, which should correctly point to the gpio 5 of the pmic.

Whereas if we directly assign the gpio as per the tps611xx-backlight.txt

This is not the correct way to do.