mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Andrey Smirnov <andrew.smirnov@gmail.com>
To: barebox@lists.infradead.org
Cc: Andrey Smirnov <andrew.smirnov@gmail.com>
Subject: [PATCH 05/20] i.MX: Add pinctrl driver for VF610
Date: Mon,  3 Oct 2016 07:40:42 -0700	[thread overview]
Message-ID: <1475505657-898-6-git-send-email-andrew.smirnov@gmail.com> (raw)
In-Reply-To: <1475505657-898-1-git-send-email-andrew.smirnov@gmail.com>

Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com>
---
 drivers/pinctrl/Kconfig         |   5 ++
 drivers/pinctrl/Makefile        |   1 +
 drivers/pinctrl/pinctrl-vf610.c | 118 ++++++++++++++++++++++++++++++++++++++++
 3 files changed, 124 insertions(+)
 create mode 100644 drivers/pinctrl/pinctrl-vf610.c

diff --git a/drivers/pinctrl/Kconfig b/drivers/pinctrl/Kconfig
index 5c69928..12fff4f 100644
--- a/drivers/pinctrl/Kconfig
+++ b/drivers/pinctrl/Kconfig
@@ -77,4 +77,9 @@ config PINCTRL_TEGRA_XUSB
 
 source drivers/pinctrl/mvebu/Kconfig
 
+config PINCTRL_VF610
+	bool
+	default y if ARCH_VF610
+	help
+	  Pinmux controller found on Vybrid VF610 family of SoCs
 endif
diff --git a/drivers/pinctrl/Makefile b/drivers/pinctrl/Makefile
index af9b30d..9450dbb 100644
--- a/drivers/pinctrl/Makefile
+++ b/drivers/pinctrl/Makefile
@@ -9,5 +9,6 @@ obj-$(CONFIG_PINCTRL_SINGLE) += pinctrl-single.o
 obj-$(CONFIG_PINCTRL_TEGRA20) += pinctrl-tegra20.o
 obj-$(CONFIG_PINCTRL_TEGRA30) += pinctrl-tegra30.o
 obj-$(CONFIG_PINCTRL_TEGRA_XUSB) += pinctrl-tegra-xusb.o
+obj-$(CONFIG_PINCTRL_VF610) += pinctrl-vf610.o
 
 obj-$(CONFIG_ARCH_MVEBU) += mvebu/
diff --git a/drivers/pinctrl/pinctrl-vf610.c b/drivers/pinctrl/pinctrl-vf610.c
new file mode 100644
index 0000000..e1d59e9
--- /dev/null
+++ b/drivers/pinctrl/pinctrl-vf610.c
@@ -0,0 +1,118 @@
+/*
+ * Copyright (c) 2016 Zodiac Inflight Innovation
+ * Author: Andrey Smirnov <andrew.smirnov@gmail.com>
+ *
+ * See file CREDITS for list of people who contributed to this
+ * project.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2
+ * as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ */
+
+#include <common.h>
+#include <init.h>
+#include <io.h>
+#include <of.h>
+#include <pinctrl.h>
+#include <malloc.h>
+
+enum {
+	PINCTRL_VF610_MUX_LINE_SIZE = 20,
+	PINCTRL_VF610_MUX_SHIFT = 20,
+};
+
+struct pinctrl_vf610 {
+	void __iomem *base;
+	struct pinctrl_device pinctrl;
+};
+
+static int pinctrl_vf610_set_state(struct pinctrl_device *pdev,
+				   struct device_node *np)
+{
+	const __be32 *list;
+	int npins, size, i;
+
+	struct pinctrl_vf610 *iomux =
+		container_of(pdev, struct pinctrl_vf610, pinctrl);
+
+	dev_dbg(pdev->dev, "%s: %s\n", __func__, np->full_name);
+
+	list = of_get_property(np, "fsl,pins", &size);
+	if (!list)
+		return -EINVAL;
+
+	if (!size || size % PINCTRL_VF610_MUX_LINE_SIZE) {
+		dev_err(pdev->dev, "Invalid fsl,pins property in %s\n",
+			np->full_name);
+		return -EINVAL;
+	}
+
+	npins = size / PINCTRL_VF610_MUX_LINE_SIZE;
+
+	for (i = 0; i < npins; i++) {
+		u32 mux_reg   = be32_to_cpu(*list++);
+		u32 input_reg = be32_to_cpu(*list++);
+		u32 mux_val   = be32_to_cpu(*list++);
+		u32 input_val = be32_to_cpu(*list++);
+		u32 conf_val  = be32_to_cpu(*list++);
+
+		writel(mux_val << PINCTRL_VF610_MUX_SHIFT | conf_val,
+		       iomux->base + mux_reg);
+
+		if (input_reg)
+			writel(input_val, iomux->base + input_reg);
+	}
+
+	return 0;
+}
+
+static struct pinctrl_ops pinctrl_vf610_ops = {
+	.set_state = pinctrl_vf610_set_state,
+};
+
+static int pinctrl_vf610_probe(struct device_d *dev)
+{
+	int ret;
+	struct resource *io;
+	struct pinctrl_vf610 *iomux;
+
+	iomux = xzalloc(sizeof(*iomux));
+
+	io = dev_request_mem_resource(dev, 0);
+	if (IS_ERR(io))
+		return PTR_ERR(io);
+
+	iomux->base = IOMEM(io->start);
+	iomux->pinctrl.dev = dev;
+	iomux->pinctrl.ops = &pinctrl_vf610_ops;
+
+	ret = pinctrl_register(&iomux->pinctrl);
+	if (ret)
+		free(iomux);
+
+	return ret;
+}
+
+static __maybe_unused struct of_device_id pinctrl_vf610_dt_ids[] = {
+	{ .compatible = "fsl,vf610-iomuxc", },
+	{ /* sentinel */ }
+};
+
+static struct driver_d pinctrl_vf610_driver = {
+	.name		= "vf610-pinctrl",
+	.probe		= pinctrl_vf610_probe,
+	.of_compatible	= DRV_OF_COMPAT(pinctrl_vf610_dt_ids),
+};
+
+static int pinctrl_vf610_init(void)
+{
+	return platform_driver_register(&pinctrl_vf610_driver);
+}
+postcore_initcall(pinctrl_vf610_init);
-- 
2.5.5


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

  parent reply	other threads:[~2016-10-03 14:41 UTC|newest]

Thread overview: 38+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-10-03 14:40 [PATCH 00/20] Vybrid support in Barebox Andrey Smirnov
2016-10-03 14:40 ` [PATCH 01/20] i.MX: Add primitive functions for VF610 family Andrey Smirnov
2016-10-03 14:40 ` [PATCH 02/20] i.MX: Add DEBUG_LL hooks for VF610 Andrey Smirnov
2016-10-04  6:24   ` Sascha Hauer
2016-10-04 13:27     ` Andrey Smirnov
2016-10-03 14:40 ` [PATCH 03/20] i.MX: scripts: Add "vf610" soc to imx-image Andrey Smirnov
2016-10-03 14:40 ` [PATCH 04/20] i.MX: Add support for VF610 Tower board Andrey Smirnov
2016-10-04  6:32   ` Sascha Hauer
2016-10-04 13:34     ` Andrey Smirnov
2016-10-07  7:56       ` Sascha Hauer
2016-10-03 14:40 ` Andrey Smirnov [this message]
2016-10-03 14:40 ` [PATCH 06/20] clk: Port clock dependency resolution code Andrey Smirnov
2016-10-03 14:40 ` [PATCH 07/20] clk: Port of_clk_set_defautls() Andrey Smirnov
2016-10-04  6:38   ` Sascha Hauer
2016-10-04 13:36     ` Andrey Smirnov
2016-10-03 14:40 ` [PATCH 08/20] i.MX: clk: Port imx_clk_gate2_cgr() Andrey Smirnov
2016-10-03 14:40 ` [PATCH 09/20] i.MX: clk: Add IMX_PLLV3_USB_VF610 support Andrey Smirnov
2016-10-03 14:40 ` [PATCH 10/20] i.MX: clk: Port imx_check_clocks() and imx_obtain_fixed_clock() Andrey Smirnov
2016-10-04  6:49   ` Sascha Hauer
2016-10-04 13:43     ` Andrey Smirnov
2016-10-04 19:28       ` Sascha Hauer
2016-10-03 14:40 ` [PATCH 11/20] i.MX: Add VF610 clock tree initialization code Andrey Smirnov
2016-10-04  6:58   ` Sascha Hauer
2016-10-04 13:44     ` Andrey Smirnov
2016-10-03 14:40 ` [PATCH 12/20] vf610: Give enet_osc explicit "enet_ext" name Andrey Smirnov
2016-10-03 14:40 ` [PATCH 13/20] i.MX: Add 'lpuart' serial driver Andrey Smirnov
2016-10-04  7:13   ` Sascha Hauer
2016-10-04 13:56     ` Andrey Smirnov
2016-10-04 19:25       ` Sascha Hauer
2016-10-03 14:40 ` [PATCH 14/20] i.MX: i2c-imx: Add Vybrid support Andrey Smirnov
2016-10-04  7:20   ` Sascha Hauer
2016-10-04 13:57     ` Andrey Smirnov
2016-10-03 14:40 ` [PATCH 15/20] i.MX: esdhc: Do not rely on CPU type for quirks Andrey Smirnov
2016-10-03 14:40 ` [PATCH 16/20] i.MX: Kconfig: Enable OCOTP on Vybrid Andrey Smirnov
2016-10-03 14:40 ` [PATCH 17/20] i.MX: ocotp: Remove unused #define Andrey Smirnov
2016-10-03 14:40 ` [PATCH 18/20] i.MX: ocotp: Account for shadow memory gaps Andrey Smirnov
2016-10-03 14:40 ` [PATCH 19/20] i.MX: ocotp: Add Vybrid support Andrey Smirnov
2016-10-03 14:40 ` [PATCH 20/20] imx-esdhc: Request "per" clock explicitly Andrey Smirnov

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1475505657-898-6-git-send-email-andrew.smirnov@gmail.com \
    --to=andrew.smirnov@gmail.com \
    --cc=barebox@lists.infradead.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox