cancel
Showing results for 
Search instead for 
Did you mean: 

How to enable PWR_USB_SW in STPMIC?

bimorqt
Associate III

Hello,

I am working on a custom board based on stm32mp157 and I have the need to enable the PWR_USB_SW through the ST PMIC. So far, I identified the bit VBUSOTG_ON in register BST_SW_CR (0x40) but I had no success in configuring it via devicetree or via I2C from userland (ST PMIC resource is busy and I cannot disable the interrupt controller using it). Could you please provide details on how to drive that bit? Could you please confirm that the modifiying the register of the ST PMIC via devicetree is the proper way to configure the peripheral? I had a look at the bindings here, but there is nothing referring to PWR_USB_SW.

Thanks in advance, any help is appreciated!

Have a nice day! 

9 REPLIES 9
Jean-Marc S
ST Employee

Setting the VBUSOTG_ON bit should be done via I2C as stated in the STPMIC1 datasheet:

"– PWR_USB_SW can be enabled in POWER_ON state by I2C setting of VBUSOTG_ON bit"

I am not sure about your configuration, but on some design the I2C used to control the PMIC is a secure I2C so maybe from your userland you do not have the correct access right ? do you see signals toggling on the I2C ?

bimorqt
Associate III

I can write the register from userland using the command

i2cset -f -y 0 0x33 0x40 0x23

but I would like to set it via devicetree. Is it something possibile or I am misunderstanding it?

Jean-Marc S
ST Employee

My understanding is that device tree may be used to configure the board interface (ex: which I2C pin used to connect PMIC). However the actual programming of the PMIC register shall be done either in the OPTEE or in the kernel using specific commands.

Jean-Marc S
ST Employee

sorry probably not true.. I am checking further how to also inform this in DT..

Jean-Marc S
ST Employee

It is indeed possible to activate in the device tree

it is in the node:

bst_out: boost {

               regulator-name = "bst_out";

               interrupts = <IT_OCP_BOOST 0>;

           };

need to enable with " regulator-always-on;" statement

also you may look at Wiki:

PMIC hardware components - stm32mpu

et linux-stm32/Documentation/devicetree/bindings/mfd/st,stpmic1.yaml

JM

I defined interrupts = <IT_OCP_BOOST 0> both in the dts files of u-boot and kernel contexts with the statement "regulator-always-on", but could not see the value of register 0x40 changing. What am I missing? This is kinda necessary, otherwise I have to force the register value from userland using I2C everytime I boot the board.

Thanks!

Jean-Marc S
ST Employee

We have been able to reproduce a pb on mp15 DK board that is probably similar to your description.

We suspect an issue in the driver of pmic.. but will need more analysis.

I will try to ask development team and will inform about this (may take some time :( for a fix )

bimorqt
Associate III

Hello Jean-Marc,

thank you for taking the time to reproduce my issue, I will check future release notes addressing the pmic drivers. In the meantime, could you please suggest a way to permanently set the pmic register to the desired value? I can only come up with an initialization script, called at boot time, invoking the i2cset command above, but I don't really like this approach. Patching the kernel driver to force the value could be a solution?

Thank you again for the prompt response, have a nice day! :)

Jean-Marc S
ST Employee

not sure patching kernel will work since we have seen some "over current" interrupt not well handled by the driver but the trial was a bit different. so I cannot say for sure

I have raised a ticket to the people in charge to analyze further and hopefully correct