power/avs: rockchip-io-domain: dump power supply-map when probe

Tested on RK3568-evb2 with io-domain node as following:
    pmuio2-supply = <&vcc3v3_pmu>;
    vccio1-supply = <&vccio_acodec>;
    vccio3-supply = <&vccio_sd>;
    vccio4-supply = <&vcc_3v3>;
    vccio5-supply = <&vcc_3v3>;
    vccio6-supply = <&vcc_3v3>;
    vccio7-supply = <&vcc_3v3>;

With this patch, the system bootup log shows:
[    0.773089] rockchip-iodomain fdc20000.syscon:io-domains: pmuio2(3300000 uV) supplied by vcc3v3_pmu
[    0.773247] rockchip-iodomain fdc20000.syscon:io-domains: vccio1(3300000 uV) supplied by vccio_acodec
[    0.773426] rockchip-iodomain fdc20000.syscon:io-domains: vccio3(3300000 uV) supplied by vccio_sd
[    0.773603] rockchip-iodomain fdc20000.syscon:io-domains: vccio4(3300000 uV) supplied by vcc_3v3
[    0.773721] rockchip-iodomain fdc20000.syscon:io-domains: vccio5(3300000 uV) supplied by vcc_3v3
[    0.773839] rockchip-iodomain fdc20000.syscon:io-domains: vccio6(3300000 uV) supplied by vcc_3v3
[    0.773989] rockchip-iodomain fdc20000.syscon:io-domains: vccio7(3300000 uV) supplied by vcc_3v3

Change-Id: Ib4bcb78bf932b07beb03b3b39a0224ecb6699a54
Signed-off-by: Jianqun Xu <jay.xu@rock-chips.com>
This commit is contained in:
Jianqun Xu
2021-05-28 16:45:40 +08:00
committed by Tao Huang
parent 7ada44e48b
commit 12557ec00c

View File

@@ -23,6 +23,12 @@
#include <linux/platform_device.h>
#include <linux/regmap.h>
#include <linux/regulator/consumer.h>
#include <linux/of.h>
#include <linux/of_device.h>
#include <linux/regulator/of_regulator.h>
#include <linux/regulator/driver.h>
#include <linux/regulator/machine.h>
#include "../../regulator/internal.h"
#define MAX_SUPPLIES 16
@@ -644,6 +650,77 @@ static const struct file_operations rockchip_iodomain_vol_fops = {
static const struct file_operations rockchip_iodomain_vol_fops = { };
#endif
static const char *rdev_get_name(struct regulator_dev *rdev)
{
if (rdev->constraints && rdev->constraints->name)
return rdev->constraints->name;
else if (rdev->desc->name)
return rdev->desc->name;
else
return "";
}
static struct device_node *of_get_child_regulator(struct device_node *parent,
const char *prop_name)
{
struct device_node *regnode = NULL;
struct device_node *child = NULL;
for_each_child_of_node(parent, child) {
regnode = of_parse_phandle(child, prop_name, 0);
if (!regnode) {
regnode = of_get_child_regulator(child, prop_name);
if (regnode)
return regnode;
} else {
return regnode;
}
}
return NULL;
}
static struct device_node *of_get_regulator(struct device *dev, const char *supply)
{
struct device_node *regnode = NULL;
char prop_name[256];
dev_dbg(dev, "Looking up %s-supply from device tree\n", supply);
snprintf(prop_name, sizeof(prop_name), "%s-supply", supply);
regnode = of_parse_phandle(dev->of_node, prop_name, 0);
if (!regnode) {
regnode = of_get_child_regulator(dev->of_node, prop_name);
if (regnode)
return regnode;
dev_dbg(dev, "Looking up %s property in node %pOF failed\n",
prop_name, dev->of_node);
return NULL;
}
return regnode;
}
static void rockchip_iodomain_dump(const struct platform_device *pdev,
struct rockchip_iodomain_supply *supply)
{
struct rockchip_iodomain *iod = supply->iod;
const char *name = iod->soc_data->supply_names[supply->idx];
struct device *dev = iod->dev;
struct device_node *node;
struct regulator_dev *r = NULL;
node = of_get_regulator(dev, name);
if (node) {
r = of_find_regulator_by_node(node);
if (!IS_ERR_OR_NULL(r))
dev_info(&pdev->dev, "%s(%d uV) supplied by %s\n",
name, regulator_get_voltage(supply->reg),
rdev_get_name(r));
}
}
static int rockchip_iodomain_probe(struct platform_device *pdev)
{
struct device_node *np = pdev->dev.of_node;
@@ -748,6 +825,7 @@ static int rockchip_iodomain_probe(struct platform_device *pdev)
goto unreg_notify;
}
rockchip_iodomain_dump(pdev, supply);
debugfs_supply = debugfs_create_dir(supply_name, debugfs_root);
debugfs_create_file("voltage", 0444, debugfs_supply,
(void *)supply,