Access/Control MPP2 of PMIC from other character driver

Hi,

We are using 410C based custom board and we are using android 5.1.1 OS.
We have connected an LED on MPP_2 (pad# K4) of PMIC PM8916. We want to access (On/Off)
it from other charecter driver.

Is there a way to control MPP_2 of PM8916 from a character driver ?

Regards,
Dev

Hi Dev,

Before you start, make sure you have appropriately used pinctrl (or the custom equivalent if you’re on an older kernel) to configure the electrical properties of the MPP.

The MPPs are exposed through the GPIO framework. So if you’re writing a driver you can use the gpiolib API to acquire a handle and toggle this pin.

If you don’t have a custom device driver of your own and just want to toggle the MPP from userspace then you can use the gpio sysfs interface; enable CONFIG_GPIO_SYSFS=y in your kernel.

With this compiled in you can “export” access to gpios by writing to the “export” and “unexport” files in /sys/class/gpio. The expected input to these files are the global id of your gpio; e.g. MPP2 in my current kernel is 509, so I would execute “echo 509 > /sys/class/gpio/export”.

This will create a directory called /sys/class/gpio/gpio509, in which you can find accessors to the direction, value etc.

To figure out the global id for your MPP2, look in /sys/class/gpio to find all the registered gpiochips as individual directories, identify the MPP gpiochip (e.g. by looking in the “label” file) and cat the “base” file in that directory; this will be the global id for MPP1, so add 1 to this.

Regards,
Bjorn

Hi Bamse,

Thanks for the reply.

I have to access mpp2 only from custom driver, not from user space.

  1. As you said,

" The MPPs are exposed through the GPIO framework. So if you’re writing a driver you can use the gpiolib API to acquire a handle and toggle this pin."

Can you provide a reference/example of this ?

  1. In my custom driver, I will be receiving an interrupt on processor’s GPIO (lets say on GPIO 115 ) and on receiving the interrupt I have to On the LED on mpp2 for specific time duration only and then again the LED should be Off.

Instead of doing this manually, can I configure property “linux,default-trigger” to my require interrupt and can I set any time out value for it without using any addition GPIOs of PMIC or processor ?

Regards,
Dev