All of lore.kernel.org
 help / color / mirror / Atom feed
From: Peng Fan <peng.fan@nxp.com>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH V2 20/32] imx8: add iomux configuration api
Date: Wed, 18 Jul 2018 09:35:50 +0800	[thread overview]
Message-ID: <20180718013602.26574-21-peng.fan@nxp.com> (raw)
In-Reply-To: <20180718013602.26574-1-peng.fan@nxp.com>

Add iomux configuration api.

Signed-off-by: Peng Fan <peng.fan@nxp.com>
---
 arch/arm/include/asm/arch-imx8/iomux.h | 40 +++++++++++++++++++++++++++++++
 arch/arm/mach-imx/imx8/Makefile        |  2 +-
 arch/arm/mach-imx/imx8/iomux.c         | 43 ++++++++++++++++++++++++++++++++++
 3 files changed, 84 insertions(+), 1 deletion(-)
 create mode 100644 arch/arm/include/asm/arch-imx8/iomux.h
 create mode 100644 arch/arm/mach-imx/imx8/iomux.c

diff --git a/arch/arm/include/asm/arch-imx8/iomux.h b/arch/arm/include/asm/arch-imx8/iomux.h
new file mode 100644
index 0000000000..bedd01bfd8
--- /dev/null
+++ b/arch/arm/include/asm/arch-imx8/iomux.h
@@ -0,0 +1,40 @@
+/* SPDX-License-Identifier: GPL-2.0+ */
+/*
+ * Copyright 2018 NXP
+ */
+
+#ifndef __ASM_ARCH_IMX8_IOMUX_H__
+#define __ASM_ARCH_IMX8_IOMUX_H__
+
+/*
+ * We use 64bits value for iomux settings.
+ * High 32bits are used for padring register value,
+ * low 16bits are used for pin index.
+ */
+typedef u64 iomux_cfg_t;
+
+#define PADRING_IFMUX_EN_SHIFT		31
+#define PADRING_IFMUX_EN_MASK		BIT(31)
+#define PADRING_GP_EN_SHIFT		30
+#define PADRING_GP_EN_MASK		BIT(30)
+#define PADRING_IFMUX_SHIFT		27
+#define PADRING_IFMUX_MASK		GENMASK(29, 27)
+#define PADRING_CONFIG_SHIFT		25
+#define PADRING_LPCONFIG_SHIFT		23
+#define PADRING_PULL_SHIFT		5
+#define PADRING_DSE_SHIFT		0
+
+#define MUX_PAD_CTRL_SHIFT	32
+#define MUX_PAD_CTRL_MASK	((iomux_cfg_t)0xFFFFFFFF << MUX_PAD_CTRL_SHIFT)
+#define MUX_PAD_CTRL(x)		((iomux_cfg_t)(x) << MUX_PAD_CTRL_SHIFT)
+#define MUX_MODE_SHIFT		(PADRING_IFMUX_SHIFT + MUX_PAD_CTRL_SHIFT)
+#define MUX_MODE_MASK		((iomux_cfg_t)0x7 << MUX_MODE_SHIFT)
+#define PIN_ID_MASK		((iomux_cfg_t)0xFFFF)
+
+/* Valid mux alt0 to alt7 */
+#define MUX_MODE_ALT(x)		(((iomux_cfg_t)(x) << MUX_MODE_SHIFT) & \
+				 MUX_MODE_MASK)
+
+void imx8_iomux_setup_pad(iomux_cfg_t pad);
+void imx8_iomux_setup_multiple_pads(iomux_cfg_t const *pad_list, u32 count);
+#endif	/* __ASM_ARCH_IMX8_IOMUX_H__ */
diff --git a/arch/arm/mach-imx/imx8/Makefile b/arch/arm/mach-imx/imx8/Makefile
index 57876139a1..31ad169ccf 100644
--- a/arch/arm/mach-imx/imx8/Makefile
+++ b/arch/arm/mach-imx/imx8/Makefile
@@ -4,4 +4,4 @@
 # SPDX-License-Identifier:	GPL-2.0+
 #
 
-obj-y += cpu.o
+obj-y += cpu.o iomux.o
diff --git a/arch/arm/mach-imx/imx8/iomux.c b/arch/arm/mach-imx/imx8/iomux.c
new file mode 100644
index 0000000000..0ade85fb8f
--- /dev/null
+++ b/arch/arm/mach-imx/imx8/iomux.c
@@ -0,0 +1,43 @@
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ * Copyright 2018 NXP
+ */
+
+#include <common.h>
+#include <asm/io.h>
+#include <asm/arch/iomux.h>
+#include <asm/arch/sci/sci.h>
+
+DECLARE_GLOBAL_DATA_PTR;
+
+/*
+ * configures a single pad in the iomuxer
+ */
+void imx8_iomux_setup_pad(iomux_cfg_t pad)
+{
+	sc_pad_t pin_id = pad & PIN_ID_MASK;
+	int ret;
+
+	u32 val = (u32)((pad & MUX_PAD_CTRL_MASK) >> MUX_PAD_CTRL_SHIFT);
+
+	val |= PADRING_IFMUX_EN_MASK;
+	val |= PADRING_GP_EN_MASK;
+
+	ret = sc_pad_set(-1, pin_id, val);
+	if (ret)
+		printf("sc_pad_set failed!, pin: %u, val: 0x%x\n", pin_id, val);
+
+	debug("iomux: pin %d, val = 0x%x\n", pin_id, val);
+}
+
+/* configures a list of pads within declared with IOMUX_PADS macro */
+void imx8_iomux_setup_multiple_pads(iomux_cfg_t const *pad_list, u32 count)
+{
+	iomux_cfg_t const *p = pad_list;
+	int i;
+
+	for (i = 0; i < count; i++) {
+		imx8_iomux_setup_pad(*p);
+		p++;
+	}
+}
-- 
2.14.1

  parent reply	other threads:[~2018-07-18  1:35 UTC|newest]

Thread overview: 60+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-07-18  1:35 [U-Boot] [PATCH V2 00/32] i.MX: Add i.MX8QXP support Peng Fan
2018-07-18  1:35 ` [U-Boot] [PATCH V2 01/32] dt-bindings: pinctrl: add i.MX8QXP pads definition Peng Fan
2018-07-18  1:35 ` [U-Boot] [PATCH V2 02/32] dt-bindings: clock: dt-bindings: pinctrl: add i.MX8QXP clocks definition Peng Fan
2018-07-18  1:35 ` [U-Boot] [PATCH V2 03/32] dt-bindings: soc: add i.MX8QXP pm and rsrc definition Peng Fan
2018-07-18  1:35 ` [U-Boot] [PATCH V2 04/32] imx8: add scfw macro definition Peng Fan
2018-07-18  1:35 ` [U-Boot] [PATCH V2 05/32] imx: add Kconfig entry for i.MX8QXP Peng Fan
2018-07-18  1:35 ` [U-Boot] [PATCH V2 06/32] arm: build mach-imx for i.MX8 Peng Fan
2018-07-18  1:35 ` [U-Boot] [PATCH V2 07/32] misc: add i.MX8 misc driver Peng Fan
2018-07-18  8:37   ` Lokesh Vutla
2018-07-18  8:52     ` Peng Fan
2018-07-18  9:04       ` Lokesh Vutla
2018-07-18  9:15         ` Peng Fan
2018-07-18  1:35 ` [U-Boot] [PATCH V2 08/32] misc: imx8: add scfw api impementation Peng Fan
2018-07-18  8:54   ` Lokesh Vutla
2018-07-18  9:08     ` Peng Fan
2018-07-18  1:35 ` [U-Boot] [PATCH V2 09/32] arm: global_data: add scu_dev for i.MX8 Peng Fan
2018-07-18  1:35 ` [U-Boot] [PATCH V2 10/32] imx: boot_mode: Add FLEXSPI boot entry Peng Fan
2018-07-18  1:35 ` [U-Boot] [PATCH V2 11/32] imx8: add imx-regs header file Peng Fan
2018-07-18  1:35 ` [U-Boot] [PATCH V2 12/32] imx8: pins: include i.MX8QXP pin header when CONFIG_IMX8QXP defined Peng Fan
2018-07-18  1:35 ` [U-Boot] [PATCH V2 13/32] imx: add i.MX8 cpu type Peng Fan
2018-07-18  1:35 ` [U-Boot] [PATCH V2 14/32] armv8: add cpu core helper functions Peng Fan
2018-07-19 13:58   ` Fabio Estevam
2018-07-18  1:35 ` [U-Boot] [PATCH V2 15/32] imx8: add basic cpu support Peng Fan
2018-07-18  1:35 ` [U-Boot] [PATCH V2 16/32] imx8: add boot device detection Peng Fan
2018-07-18  1:35 ` [U-Boot] [PATCH V2 17/32] imx8: implement mmc_get_env_dev Peng Fan
2018-07-18  1:35 ` [U-Boot] [PATCH V2 18/32] imx8: add mmu and dram related functiions Peng Fan
2018-07-18  1:35 ` [U-Boot] [PATCH V2 19/32] imx8: add arch_cpu_init arch_cpu_init_dm Peng Fan
2018-07-18  1:35 ` Peng Fan [this message]
2018-07-18  1:35 ` [U-Boot] [PATCH V2 21/32] imx8: add dummy clock Peng Fan
2018-07-18  1:35 ` [U-Boot] [PATCH V2 22/32] gpio: mxc_gpio: add support for i.MX8 Peng Fan
2018-07-18  1:35 ` [U-Boot] [PATCH V2 23/32] pinctrl: Add pinctrl driver " Peng Fan
2018-07-18  1:35 ` [U-Boot] [PATCH V2 24/32] power: Add power domain " Peng Fan
2018-07-18  1:35 ` [U-Boot] [PATCH V2 25/32] clk: imx: add clk driver for i.MX8QXP Peng Fan
2018-07-18  1:35 ` [U-Boot] [PATCH V2 26/32] serial_lpuart: Update lpuart driver to support i.MX8 Peng Fan
2018-07-19 14:03   ` Fabio Estevam
2018-07-18  1:35 ` [U-Boot] [PATCH V2 27/32] serial: lpuart: Enable RX and TX FIFO Peng Fan
2018-07-18  1:35 ` [U-Boot] [PATCH V2 28/32] serial: lpuart: support uclass clk api Peng Fan
2018-07-18  1:35 ` [U-Boot] [PATCH V2 29/32] fsl_esdhc: Update usdhc driver to support i.MX8 Peng Fan
2018-07-19 14:01   ` Fabio Estevam
2018-07-19 14:04     ` Peng Fan
2018-07-23 19:26       ` Fabio Estevam
2018-07-24  0:45         ` Peng Fan
2018-07-24  0:51           ` Fabio Estevam
2018-07-24 18:27             ` Troy Kisky
2018-07-24 18:28               ` Fabio Estevam
2018-07-25  0:06               ` Peng Fan
2018-07-18  1:36 ` [U-Boot] [PATCH V2 30/32] mmc: fsl_esdhc: add uclass clk support Peng Fan
2018-07-18  1:36 ` [U-Boot] [PATCH V2 31/32] arm: dts: introduce dtsi for i.MX8QXP Peng Fan
2018-07-18  1:36 ` [U-Boot] [PATCH V2 32/32] imx: add i.MX8QXP MEK board support Peng Fan
2018-07-18  8:29 ` [U-Boot] [PATCH V2 00/32] i.MX: Add i.MX8QXP support Lokesh Vutla
2018-07-18 12:05   ` Peng Fan
2018-07-18 12:43     ` Peter Robinson
2018-07-18 12:47       ` Peng Fan
2018-07-19 13:41 ` Fabio Estevam
2018-07-19 14:02   ` Peng Fan
2018-07-19 14:15     ` Fabio Estevam
2018-07-19 14:28     ` Anatolij Gustschin
2018-07-27  7:54 ` Peng Fan
2018-07-27 17:58   ` Troy Kisky
2018-07-28  2:43     ` Peng Fan

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=20180718013602.26574-21-peng.fan@nxp.com \
    --to=peng.fan@nxp.com \
    --cc=u-boot@lists.denx.de \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.