summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorQuentin Schulz <quentin.schulz@theobroma-systems.com>2022-08-02 11:52:52 +0200
committerQuentin Schulz <quentin.schulz@theobroma-systems.com>2023-02-02 10:49:12 +0100
commitb0a0bec8891964dc8e5af20f3ce4e47349e709b8 (patch)
treeec3b8818df2086fab26434ccb6121327ccd89927
parent5127d7807fdde946d722aa414b040fa75ecc9203 (diff)
FROMLIST: pinctrl: rockchip: add support for per-pinmux io-domain dependency
On some Rockchip SoCs, some SoC pins are split in what are called IO domains. An IO domain is supplied power externally, by regulators from a PMIC for example. This external power supply is then used by the IO domain as "supply" for the IO pins if they are outputs. Each IO domain can configure which voltage the IO pins will be operating on (1.8V or 3.3V). There already exists an IO domain driver for Rockchip SoCs[1]. This driver allows to explicit the relationship between the external power supplies and IO domains[2]. This makes sure the regulators are enabled by the Linux kernel so the IO domains are supplied with power and correctly configured as per the supplied voltage. This driver is a regulator consumer and does not offer any other interface for device dependency. However, IO pins belonging to an IO domain need to have this IO domain correctly configured before they are being used otherwise they do not operate correctly (in our case, a pin configured as output clock was oscillating between 0 and 150mV instead of the expected 1V8). In order to make this dependency transparent to the consumer of those pins and not add Rockchip-specific code to third party drivers (a camera driver in our case), it is hooked into the pinctrl driver which is Rockchip-specific obviously. [1] drivers/soc/rockchip/io-domain.c [2] Documentation/devicetree/bindings/power/rockchip-io-domain.yaml Signed-off-by: Quentin Schulz <quentin.schulz@theobroma-systems.com> Link: https://lore.kernel.org/r/20220802095252.2486591-2-foss+kernel@0leil.net Signed-off-by: Quentin Schulz <quentin.schulz@theobroma-systems.com>
-rw-r--r--drivers/pinctrl/pinctrl-rockchip.c19
-rw-r--r--drivers/pinctrl/pinctrl-rockchip.h1
2 files changed, 20 insertions, 0 deletions
diff --git a/drivers/pinctrl/pinctrl-rockchip.c b/drivers/pinctrl/pinctrl-rockchip.c
index c84bd0e1ce5a..866969ab30f7 100644
--- a/drivers/pinctrl/pinctrl-rockchip.c
+++ b/drivers/pinctrl/pinctrl-rockchip.c
@@ -24,6 +24,8 @@
#include <linux/of_address.h>
#include <linux/of_device.h>
#include <linux/of_irq.h>
+#include <linux/of_platform.h>
+#include <linux/platform_device.h>
#include <linux/pinctrl/machine.h>
#include <linux/pinctrl/pinconf.h>
#include <linux/pinctrl/pinctrl.h>
@@ -2370,6 +2372,12 @@ static int rockchip_pmx_set(struct pinctrl_dev *pctldev, unsigned selector,
dev_dbg(dev, "enable function %s group %s\n",
info->functions[selector].name, info->groups[group].name);
+ if (info->groups[group].io_domain &&
+ !platform_get_drvdata(info->groups[group].io_domain)) {
+ dev_err(info->dev, "IO domain device is required but not probed yet, deferring...");
+ return -EPROBE_DEFER;
+ }
+
/*
* for each pin in the pin group selected, program the corresponding
* pin function number in the config register.
@@ -2676,6 +2684,7 @@ static int rockchip_pinctrl_parse_groups(struct device_node *np,
{
struct device *dev = info->dev;
struct rockchip_pin_bank *bank;
+ struct device_node *node;
int size;
const __be32 *list;
int num;
@@ -2697,6 +2706,16 @@ static int rockchip_pinctrl_parse_groups(struct device_node *np,
if (!size || size % 4)
return dev_err_probe(dev, -EINVAL, "wrong pins number or pins and configs should be by 4\n");
+ node = of_parse_phandle(np, "rockchip,io-domains", 0);
+ if (node) {
+ grp->io_domain = of_find_device_by_node(node);
+ of_node_put(node);
+ if (!grp->io_domain) {
+ dev_err(info->dev, "couldn't find IO domain device\n");
+ return -ENODEV;
+ }
+ }
+
grp->npins = size / 4;
grp->pins = devm_kcalloc(dev, grp->npins, sizeof(*grp->pins), GFP_KERNEL);
diff --git a/drivers/pinctrl/pinctrl-rockchip.h b/drivers/pinctrl/pinctrl-rockchip.h
index ec46f8815ac9..56bc008eb7df 100644
--- a/drivers/pinctrl/pinctrl-rockchip.h
+++ b/drivers/pinctrl/pinctrl-rockchip.h
@@ -434,6 +434,7 @@ struct rockchip_pin_group {
unsigned int npins;
unsigned int *pins;
struct rockchip_pin_config *data;
+ struct platform_device *io_domain;
};
/**