Hello everybody,
I am working with a PMIC PFUZE3000 and we are using the imx6ul processor. The question is that I do not know how to interact with the driver in order to enable/disable the outputs of the PFUZE. I am only able to read the state of some of his settings through "/sys/class/regulator/ as it is shown in the next picture:
As you can see I have only read permissions and I do not know how to change the "state", for example.
I have already define the Devicetree following this one PFUZE Device tree example. Also I saw that I have to define a "consumer" of this driver, overview regulator. How to define a consumer is given at the final of this documentation, Consumer description.
My questions are:
Firstly, it is not given enough documentation of how to define the costumer. Therefore, anyone has documentation about this.
Secondly, I have read something about loading the "select virtual regulator consumer" and "userspace regulator consumer as module".
Linux Kernel Configuration Device Drivers ---> [*] Voltage and Current Regulator Support ---> <M> Virtual regulator consumer support <M> Userspace regulator consumer support <*> Analog Devices AD5398/AD5821 regulator
But, I do not know if it is the best way of it is necessary to do it in order to interact with the driver. Any suggestions?
Thanks for the support,
Regards.
Hi everybody,
Finally I achieved it. I want to explain you how we have to configure the system in order to change the states of each PIN of PFUZE3000 (sw1a,sw1b,sw2,sw3,vldo1...)
First of all, as it is defined the PMIC and his drivers in the original version of Linux kernel. It has only read access, you can check it in this other post of NXP (Device Tree Created Regulator Enable - Write Error).
Therefore, if we want to change the status once it is running the system we have only one option, and it is to use a consumer-driver in order to interact with the PMIC.
At last you have only to compile the kernel, enabling this module in your menuconfig (CONFIG_REGULATOR_USERSPACE_CONSUMER).
Afterwards, you can find the sysfs here (in my case, it may be different in your case):
and, if you only want to check the status or monitoring task, you can do it here:
Thanks everybody,
Regards,
Javier.
Hi Javier
Thanks for useful post!
I too want to change the state of the PMIC. I am working on IMX6sx sabresd with PFUZE200. I followed steps you mentioned in the post, however, I did not end up with the sysfs like yours. Could you elaborate on third step, I mean adding a new device tree node "regulator-consumer".
Hi adelantesey,
Do you still have this problem?? This is my regulator-consumer node:
userspace-consumer {
compatible = "reg-userspace-consumer";
regulator-name = "pfuze-consumer";
regulator-boot-on;
regulator-supplies = "sw1a", "sw1b", "sw2", "sw3",
"swbst", "vsnvs", "vrefddr", "vldo1",
"vldo2", "vccsd", "v33", "vldo3", "vldo4";
sw1a-supply = <&sw1a_reg>;
sw1b-supply = <&sw1c_reg>;
sw2-supply = <&sw2_reg>;
sw3-supply = <&sw3a_reg>;
swbst-supply = <&swbst_reg>;
vsnvs-supply = <&snvs_reg>;
vrefddr-supply = <&vref_reg>;
vldo1-supply = <&vgen1_reg>;
vldo2-supply = <&vgen2_reg>;
vccsd-supply = <&vgen3_reg>;
v33-supply = <&vgen4_reg>;
vldo3-supply = <&vgen5_reg>;
vldo4-supply = <&vgen6_reg>;
};
Do you want to add other one or difference to mine??
Regards,
Javi
Hi Javier,
Thanks for your post. I have followed the instructions provided by you, however still not able to get the user space sysfs interface for consumer drivers. I have checked the sysfs interface under "/sys/class/regulator/regulator.X/ & "/sys/devices/platform/soc/..".
Note: I am using IMX7d-Sabre board with Yocto build.
1. Defining the Device Tree PMIC node as it is defined in the Linux Documentation.
Entry for "pmic: pfuze3000@8 { " is available. (DT file attached below)
2. Changing the driver "/driver/regulator/userspace-consumer.c", following this patch.
Applied the patch.
3. Adding a new Device Tree node "regulator-consumer" (for example), you can follow this other patch.
---------------------
file name: arch/arm/boot/dts/imx7d-sdb.dts
&i2c1 {
clock-frequency = <100000>;
pinctrl-names = "default";
pinctrl-0 = <&pinctrl_i2c1>;
status = "okay";
userspace-consumer {
compatible = "reg-userspace-consumer";
regulator-name = "pfuze-consumer";
regulator-boot-on;
regulator-supplies = "sw1a", "sw1b", "sw2", "sw3",
"swbst", "vsnvs", "vrefddr", "vldo1",
"vldo2", "vccsd", "v33", "vldo3", "vldo4";
sw1a-supply = <&sw1a_reg>;
sw1b-supply = <&sw1c_reg>;
sw2-supply = <&sw2_reg>;
sw3-supply = <&sw3a_reg>;
swbst-supply = <&swbst_reg>;
vsnvs-supply = <&snvs_reg>;
vrefddr-supply = <&vref_reg>;
vldo1-supply = <&vgen1_reg>;
vldo2-supply = <&vgen2_reg>;
vccsd-supply = <&vgen3_reg>;
v33-supply = <&vgen4_reg>;
vldo3-supply = <&vgen5_reg>;
vldo4-supply = <&vgen6_reg>;
};
pmic: pfuze3000@08 {
compatible = "fsl,pfuze3000";
reg = <0x08>;
regulators {
sw1a_reg: sw1a {
regulator-min-microvolt = <700000>;
regulator-max-microvolt = <3300000>;
regulator-boot-on;
regulator-always-on;
regulator-ramp-delay = <6250>;
};
-------
4. CONFIG_REGULATOR_USERSPACE_CONSUMER is also enabled.
below is my .config file options.
CONFIG_REGULATOR=y
# CONFIG_REGULATOR_DEBUG is not set
CONFIG_REGULATOR_FIXED_VOLTAGE=y
# CONFIG_REGULATOR_VIRTUAL_CONSUMER is not set
CONFIG_REGULATOR_USERSPACE_CONSUMER=y
# CONFIG_REGULATOR_ACT8865 is not set
# CONFIG_REGULATOR_AD5398 is not set
Could you please point out, do i still missing something.
Regards, Sudhesh
Hi Sudhesh,
Did you solve the problem?
Could you attach the Kernel log? for example if you make a "dmesg". By this way we can check if it is well loaded every kernel module related to the regulator and PMIC.
Regards,
Javi
Hi,
Please check the attached document, specifically in chapter 23 you can find more information about how to interface with the PMIC driver.
Section 23.3.1 you can find the unified API calls needed to interface with the PMIC, and you can find more APIs and details in the regulator core source code inside the Linux
kernel at: <Yocto_BuildDir>/linux/drivers/regulator/core.c.
Have a great day,
Jose
-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------
Hi Jose Alberto,
First of all thanks for your reply, I was checking this documentation and I think that it is how is defined the interface, they do not say nothing about how to use it. In the "core.c" file, for example, it is defined all the functions that we can use, or better, the functions that the "sys" interface uses. However, I do not find how to use to "sys" interface for the PMIC.
Do you know how can I use the API that you said me??
Have a great day too,
Javier
Hi Javier,
What I know is that we only exposed those interface of accessing PMIC via I2C to sys fs interface.
It should be easy to create a HAL to access these sys fs interface, but I don't know how to do that.
Have a great day,
Jose
-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------
Hi Jose Alberto,
Thank you for your information. I am able to access using the sys interface, as it is shown in the first picture. However, I am only read permissions... I cannot change the state of the regulator... Therefore, I dont know if I am missing something in my DeviceTree, if I have to create a "consumer", I have not found so much information about that.
What do you want to mean with HAL?? I read that HAL is discontinued by udev. At last, I do not know how to use udev here neither HAL.
Thanks for your reply! Kind regards,
Javier
Hi Javier,
You can see an example on how you can interact here.
Have a great day,
Jose
-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------
Hi Jose Alberto,
I am sorry but I cannot see how I can apply this example to my project... I check the drivers of the PFUZE and I do not see anything like "enable_ldo_mode". If I write "ldo_active=on" in the command line, nothing happens..
Thanks for your help.
Javier
Hello Javier,
As you can see from the comment from reyes, In the https://git.congatec.com/arm/qmx6_kernel/commit/868d21a7fce9dc90808837e06b0d5e71e38b3b1b
ENGR00233366-1 Anatop PFUZE: LDO bypass can be configed by cmdline (868d21a7) · Commits · ARM / qmx6... . This is an example how to interact with the API of the PFUZE, but you need to create your own application, this is an example on how and where you need to do it. In this example configured by cmdline bypass the LDO. So if you want to use to change the LDOs then you need to implement somehting very similar.
There is only the Suspend Command available. If you try right now to modify the PFUZE in the cmdLine. Hope this clarifies.
saludos,
Jaime Hueso