[PATCH v3 5/6] pinctrl: amd: Add amd_get_iomux_res function

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Presently there is no way to change pinmux configuration run time.
Hence add a function to get IOMUX resource which can be used to
configure IOMUX GPIO pins run time.

Signed-off-by: Basavaraj Natikar <Basavaraj.Natikar@xxxxxxx>
---
 drivers/pinctrl/pinctrl-amd.c | 33 +++++++++++++++++++++++++++++++++
 drivers/pinctrl/pinctrl-amd.h |  1 +
 2 files changed, 34 insertions(+)

diff --git a/drivers/pinctrl/pinctrl-amd.c b/drivers/pinctrl/pinctrl-amd.c
index 0645c2c24f50..59927d4bf0d1 100644
--- a/drivers/pinctrl/pinctrl-amd.c
+++ b/drivers/pinctrl/pinctrl-amd.c
@@ -963,6 +963,38 @@ static struct pinctrl_desc amd_pinctrl_desc = {
 	.owner = THIS_MODULE,
 };
 
+static void amd_get_iomux_res(struct amd_gpio *gpio_dev)
+{
+	struct acpi_device *adev = ACPI_COMPANION(&gpio_dev->pdev->dev);
+	struct pinctrl_desc *desc = gpio_dev->pctrl->desc;
+	struct resource *res;
+	int index;
+
+	if (!adev)
+		return;
+
+	index = fwnode_property_match_string(acpi_fwnode_handle(adev),
+					     "pinctrl-resource-names",  "iomux");
+	if (index > 0) {
+		res = platform_get_resource(gpio_dev->pdev, IORESOURCE_MEM, index);
+		if (!res) {
+			dev_warn(&gpio_dev->pdev->dev, "Failed to get iomux %d io resource\n",
+				 index);
+			return;
+		}
+
+		gpio_dev->iomux_base = devm_ioremap(&gpio_dev->pdev->dev, res->start,
+						    resource_size(res));
+		if (!gpio_dev->iomux_base) {
+			desc->pmxops = NULL;
+			dev_warn(&gpio_dev->pdev->dev, "failed to devm_ioremap() iomux_base\n");
+		}
+	} else {
+		desc->pmxops = NULL;
+		dev_warn(&gpio_dev->pdev->dev, "failed to get iomux index\n");
+	}
+}
+
 static int amd_gpio_probe(struct platform_device *pdev)
 {
 	int ret = 0;
@@ -1057,6 +1089,7 @@ static int amd_gpio_probe(struct platform_device *pdev)
 
 	platform_set_drvdata(pdev, gpio_dev);
 	acpi_register_wakeup_handler(gpio_dev->irq, amd_gpio_check_wake, gpio_dev);
+	amd_get_iomux_res(gpio_dev);
 
 	dev_dbg(&pdev->dev, "amd gpio driver loaded\n");
 	return ret;
diff --git a/drivers/pinctrl/pinctrl-amd.h b/drivers/pinctrl/pinctrl-amd.h
index 5443a4a38eec..0f9fbae6d2f4 100644
--- a/drivers/pinctrl/pinctrl-amd.h
+++ b/drivers/pinctrl/pinctrl-amd.h
@@ -83,6 +83,7 @@ struct amd_function {
 struct amd_gpio {
 	raw_spinlock_t          lock;
 	void __iomem            *base;
+	void __iomem            *iomux_base;
 
 	const struct pingroup *groups;
 	u32 ngroups;
-- 
2.25.1




[Index of Archives]     [Linux SPI]     [Linux Kernel]     [Linux ARM (vger)]     [Linux ARM MSM]     [Linux Omap]     [Linux Arm]     [Linux Tegra]     [Fedora ARM]     [Linux for Samsung SOC]     [eCos]     [Linux Fastboot]     [Gcc Help]     [Git]     [DCCP]     [IETF Announce]     [Security]     [Linux MIPS]     [Yosemite Campsites]

  Powered by Linux