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 12/16] i.MX: vf610: Add low-level pin configuration helper
Date: Mon,  5 Dec 2016 06:54:40 -0800	[thread overview]
Message-ID: <1480949684-18520-13-git-send-email-andrew.smirnov@gmail.com> (raw)
In-Reply-To: <1480949684-18520-1-git-send-email-andrew.smirnov@gmail.com>

Add low-level pin configuration helper for early boot code, and convert
pinctrl driver to use that code as well.

Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com>
---
 arch/arm/mach-imx/include/mach/iomux-vf610.h | 16 ++++++++++++++++
 drivers/pinctrl/pinctrl-vf610.c              | 11 ++++++-----
 2 files changed, 22 insertions(+), 5 deletions(-)

diff --git a/arch/arm/mach-imx/include/mach/iomux-vf610.h b/arch/arm/mach-imx/include/mach/iomux-vf610.h
index 1535628..087d6f2 100644
--- a/arch/arm/mach-imx/include/mach/iomux-vf610.h
+++ b/arch/arm/mach-imx/include/mach/iomux-vf610.h
@@ -223,4 +223,20 @@ enum {
 	VF610_PAD_DDR_ODT0__DDR_ODT_1	= IOMUX_PAD(0x02d8, 0x02d8, 0, __NA_, 0, VF610_DDR_PAD_CTRL),
 };
 
+#define PINCTRL_VF610_MUX_SHIFT 20
+
+
+static inline void vf610_setup_pad(void __iomem *iomux, iomux_v3_cfg_t __pad)
+{
+	union iomux_v3_pad pad = { .raw = __pad };
+
+	iomux_v3_setup_pad(iomux, SHARE_MUX_CONF_REG | ZERO_OFFSET_VALID,
+			   pad.cfg.mux_ctrl_ofs,
+			   pad.cfg.pad_ctrl_ofs,
+			   pad.cfg.sel_input_ofs,
+			   pad.cfg.mux_mode << PINCTRL_VF610_MUX_SHIFT,
+			   pad.cfg.pad_ctrl, pad.cfg.sel_inp);
+}
+
+
 #endif	/* __IOMUX_VF610_H__ */
diff --git a/drivers/pinctrl/pinctrl-vf610.c b/drivers/pinctrl/pinctrl-vf610.c
index b479bf2..4234263 100644
--- a/drivers/pinctrl/pinctrl-vf610.c
+++ b/drivers/pinctrl/pinctrl-vf610.c
@@ -24,9 +24,10 @@
 #include <malloc.h>
 #include <gpio.h>
 
+#include <mach/iomux-vf610.h>
+
 enum {
 	PINCTRL_VF610_MUX_LINE_SIZE = 20,
-	PINCTRL_VF610_MUX_SHIFT = 20,
 
 	PINCTRL_VF610_IBE = 1 << 0,
 	PINCTRL_VF610_OBE = 1 << 1,
@@ -60,17 +61,17 @@ static int pinctrl_vf610_set_state(struct pinctrl_device *pdev,
 	npins = size / PINCTRL_VF610_MUX_LINE_SIZE;
 
 	for (i = 0; i < npins; i++) {
+		iomux_v3_cfg_t pad;
 		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);
+		pad = IOMUX_PAD(mux_reg, mux_reg, mux_val,
+				input_reg, input_val, conf_val);
 
-		if (input_reg)
-			writel(input_val, iomux->base + input_reg);
+		vf610_setup_pad(iomux->base, pad);
 	}
 
 	return 0;
-- 
2.5.5


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

  parent reply	other threads:[~2016-12-05 14:55 UTC|newest]

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-12-05 14:54 [PATCH 00/16] Vybrid related patches Andrey Smirnov
2016-12-05 14:54 ` [PATCH 01/16] i.MX: esdhc: Enable host->clk during initialization Andrey Smirnov
2016-12-05 14:54 ` [PATCH 02/16] i.MX: ocotp: Add provisions for storing multiple MAC addresses Andrey Smirnov
2016-12-05 15:14   ` Stefan Lengfeld
2016-12-06 14:48     ` Andrey Smirnov
2016-12-07  8:51       ` Stefan Lengfeld
2016-12-07 19:13         ` Sascha Hauer
2016-12-07 19:36           ` Andrey Smirnov
2016-12-07 20:57             ` Sascha Hauer
2016-12-07 19:32         ` Andrey Smirnov
2016-12-05 14:54 ` [PATCH 03/16] i.MX: ocotp: Initialize OCOTP as early as possible Andrey Smirnov
2016-12-05 14:54 ` [PATCH 04/16] i.MX: ocotp: Initialize 'sense_enable' to true on Vybrid Andrey Smirnov
2016-12-05 14:54 ` [PATCH 05/16] i.MX: clk: Add IMX_PLLV3_SYS_VF610 subtype Andrey Smirnov
2016-12-05 14:54 ` [PATCH 06/16] i.MX: vf610: Ramp CPU clock to maximum frequency Andrey Smirnov
2016-12-07 19:27   ` Sascha Hauer
2016-12-12  5:24     ` Andrey Smirnov
2016-12-05 14:54 ` [PATCH 07/16] i.MX: iomuxv3: Add low-level pad code to headers Andrey Smirnov
2016-12-05 14:54 ` [PATCH 08/16] i.MX: iomuxv3: Add helper type to deconstruct iomux_v3_cfg_t values Andrey Smirnov
2016-12-05 14:54 ` [PATCH 09/16] i.MX: iomuxv3: Add low-level pad configuration routine Andrey Smirnov
2016-12-05 14:54 ` [PATCH 10/16] i.MX6: sabresd: Remove magic numbers in setup_uart Andrey Smirnov
2016-12-05 14:54 ` [PATCH 11/16] i.MX: iomuxv3: Use helper functions in iomux-v3.h Andrey Smirnov
2016-12-05 14:54 ` Andrey Smirnov [this message]
2016-12-05 14:54 ` [PATCH 13/16] i.MX: iomux-vf610: Add missing pad definitions Andrey Smirnov
2016-12-05 14:54 ` [PATCH 14/16] i.MX: imx-usb-phy: Add VF610 OF compatiblity string Andrey Smirnov
2016-12-05 14:54 ` [PATCH 15/16] i.MX: Default CONFI_USB_IMX_PHY to 'y' on Vybrid Andrey Smirnov
2016-12-05 14:54 ` [PATCH 16/16] i.MX: imx-usb-misc: Add Vybrid support 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=1480949684-18520-13-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