From 094820a63bfd304827f00b6c853d792e7e1bebe7 Mon Sep 17 00:00:00 2001 From: Andrey Smirnov Date: Tue, 10 Jan 2017 07:09:07 -0800 Subject: i.MX: iomuxv3: Use helper functions in iomux-v3.h Avoid code duplication by using helper functions from iomux-v3.h Signed-off-by: Andrey Smirnov Signed-off-by: Sascha Hauer --- drivers/pinctrl/imx-iomux-v3.c | 38 ++++---------------------------------- 1 file changed, 4 insertions(+), 34 deletions(-) (limited to 'drivers/pinctrl/imx-iomux-v3.c') diff --git a/drivers/pinctrl/imx-iomux-v3.c b/drivers/pinctrl/imx-iomux-v3.c index 4b3f033894..bc93140830 100644 --- a/drivers/pinctrl/imx-iomux-v3.c +++ b/drivers/pinctrl/imx-iomux-v3.c @@ -31,46 +31,17 @@ struct imx_iomux_v3 { }; static void __iomem *iomuxv3_base; -static struct device_d *iomuxv3_dev; -static void imx_iomuxv3_setup_single(void __iomem *base, struct device_d *dev, - u32 mux_reg, u32 conf_reg, u32 input_reg, - u32 mux_val, u32 conf_val, u32 input_val) -{ - dev_dbg(dev, - "mux: 0x%08x -> 0x%04x, conf: 0x%08x -> 0x%04x input: 0x%08x -> 0x%04x\n", - mux_val, mux_reg, conf_val, conf_reg, input_val, input_reg); - - if (mux_reg) - writel(mux_val, base + mux_reg); - if (conf_reg) - writel(conf_val, base + conf_reg); - if (input_reg) - writel(input_val, base + input_reg); -} /* * configures a single pad in the iomuxer */ int mxc_iomux_v3_setup_pad(iomux_v3_cfg_t pad) { - u32 mux_reg = (pad & MUX_CTRL_OFS_MASK) >> MUX_CTRL_OFS_SHIFT; - u32 mux_val = (pad & MUX_MODE_MASK) >> MUX_MODE_SHIFT; - u32 input_reg = (pad & MUX_SEL_INPUT_OFS_MASK) >> MUX_SEL_INPUT_OFS_SHIFT; - u32 input_val = (pad & MUX_SEL_INPUT_MASK) >> MUX_SEL_INPUT_SHIFT; - u32 conf_reg = (pad & MUX_PAD_CTRL_OFS_MASK) >> MUX_PAD_CTRL_OFS_SHIFT; - u32 conf_val = (pad & MUX_PAD_CTRL_MASK) >> MUX_PAD_CTRL_SHIFT; - if (!iomuxv3_base) return -EINVAL; - if (conf_val & NO_PAD_CTRL) - conf_reg = 0; - - imx_iomuxv3_setup_single(iomuxv3_base, iomuxv3_dev, - mux_reg, conf_reg, input_reg, - mux_val, conf_val, input_val); - + imx_setup_pad(iomuxv3_base, pad); return 0; } EXPORT_SYMBOL(mxc_iomux_v3_setup_pad); @@ -140,9 +111,9 @@ static int imx_iomux_v3_set_state(struct pinctrl_device *pdev, struct device_nod if (conf_val & IMX_DT_NO_PAD_CTL) conf_reg = 0; - imx_iomuxv3_setup_single(iomux->base, iomux->pinctrl.dev, - mux_reg, conf_reg, input_reg, - mux_val, conf_val, input_val); + iomux_v3_setup_pad(iomux->base, 0, + mux_reg, conf_reg, input_reg, + mux_val, conf_val, input_val); } return 0; @@ -183,7 +154,6 @@ static int imx_iomux_v3_probe(struct device_d *dev) if (IS_ERR(iores)) return PTR_ERR(iores); iomuxv3_base = IOMEM(iores->start); - iomuxv3_dev = dev; if (IS_ENABLED(CONFIG_PINCTRL) && dev->device_node) ret = imx_pinctrl_dt(dev, iomuxv3_base); -- cgit v1.2.3 From 99a464413e1552b0d0f6d4d504d35f66d6ef903d Mon Sep 17 00:00:00 2001 From: Juergen Borleis Date: Tue, 6 Dec 2016 15:28:57 +0100 Subject: pinmmux: i.MX: add pin mux support for i.MX7 Signed-off-by Juergen Borleis Signed-off-by: Sascha Hauer --- drivers/pinctrl/imx-iomux-v3.c | 40 ++++++++++++++++++++++++++++++++-------- 1 file changed, 32 insertions(+), 8 deletions(-) (limited to 'drivers/pinctrl/imx-iomux-v3.c') diff --git a/drivers/pinctrl/imx-iomux-v3.c b/drivers/pinctrl/imx-iomux-v3.c index bc93140830..b5fa23560f 100644 --- a/drivers/pinctrl/imx-iomux-v3.c +++ b/drivers/pinctrl/imx-iomux-v3.c @@ -24,14 +24,19 @@ #include #include #include +#include struct imx_iomux_v3 { void __iomem *base; struct pinctrl_device pinctrl; + unsigned int flags; }; -static void __iomem *iomuxv3_base; +struct imx_iomux_v3_data { + unsigned int flags; +}; +static void __iomem *iomuxv3_base; /* * configures a single pad in the iomuxer @@ -111,7 +116,7 @@ static int imx_iomux_v3_set_state(struct pinctrl_device *pdev, struct device_nod if (conf_val & IMX_DT_NO_PAD_CTL) conf_reg = 0; - iomux_v3_setup_pad(iomux->base, 0, + iomux_v3_setup_pad(iomux->base, iomux->flags, mux_reg, conf_reg, input_reg, mux_val, conf_val, input_val); } @@ -126,14 +131,18 @@ static struct pinctrl_ops imx_iomux_v3_ops = { static int imx_pinctrl_dt(struct device_d *dev, void __iomem *base) { struct imx_iomux_v3 *iomux; + struct imx_iomux_v3_data *drvdata = NULL; int ret; + dev_get_drvdata(dev, (const void **)&drvdata); iomux = xzalloc(sizeof(*iomux)); iomux->base = base; iomux->pinctrl.dev = dev; iomux->pinctrl.ops = &imx_iomux_v3_ops; + if (drvdata) + iomux->flags = drvdata->flags; ret = pinctrl_register(&iomux->pinctrl); if (ret) @@ -144,23 +153,33 @@ static int imx_pinctrl_dt(struct device_d *dev, void __iomem *base) static int imx_iomux_v3_probe(struct device_d *dev) { + void __iomem *base; struct resource *iores; int ret = 0; - if (iomuxv3_base) - return -EBUSY; - iores = dev_request_mem_resource(dev, 0); if (IS_ERR(iores)) return PTR_ERR(iores); - iomuxv3_base = IOMEM(iores->start); + base = IOMEM(iores->start); + + if (!iomuxv3_base) + /* + * Uh, this works only for the older controllers, not for + * i.MX7 which has two iomux controllers. i.MX7 based boards + * should not use mxc_iomux_v3_setup_pad anyway. + */ + iomuxv3_base = base; if (IS_ENABLED(CONFIG_PINCTRL) && dev->device_node) - ret = imx_pinctrl_dt(dev, iomuxv3_base); + ret = imx_pinctrl_dt(dev, base); return ret; } +static struct imx_iomux_v3_data imx_iomux_imx7_lpsr_data = { + .flags = ZERO_OFFSET_VALID, +}; + static __maybe_unused struct of_device_id imx_iomux_v3_dt_ids[] = { { .compatible = "fsl,imx25-iomuxc", @@ -172,12 +191,17 @@ static __maybe_unused struct of_device_id imx_iomux_v3_dt_ids[] = { .compatible = "fsl,imx53-iomuxc", }, { .compatible = "fsl,imx6q-iomuxc", - }, { + }, { .compatible = "fsl,imx6dl-iomuxc", }, { .compatible = "fsl,imx6sx-iomuxc", }, { .compatible = "fsl,imx6ul-iomuxc", + }, { + .compatible = "fsl,imx7d-iomuxc", + }, { + .compatible = "fsl,imx7d-iomuxc-lpsr", + .data = &imx_iomux_imx7_lpsr_data, }, { /* sentinel */ } -- cgit v1.2.3 From 4cb70c729f2e3563a4a626616aa2ca0c82dd9fff Mon Sep 17 00:00:00 2001 From: Alexander Kurz Date: Mon, 30 Jan 2017 23:50:58 +0100 Subject: ARM i.MX: Add i.MX6SL support Most i.MX6SL infrastructure is already covered in barebox by general i.MX6 support. Missing infrastructure provided in separate commits are * SoC type detection * Clock infrastructure Add the missing fsl,imx6sl-mmdc, so it will not be catched by fsl,imx6q-mmdc and the remaining bits and pieces to provide barebox i.MX6SL SoC support. Signed-off-by: Alexander Kurz Signed-off-by: Sascha Hauer --- arch/arm/mach-imx/esdctl.c | 3 +++ arch/arm/mach-imx/imx.c | 2 ++ drivers/clk/imx/Makefile | 1 + drivers/pinctrl/imx-iomux-v3.c | 2 ++ 4 files changed, 8 insertions(+) (limited to 'drivers/pinctrl/imx-iomux-v3.c') diff --git a/arch/arm/mach-imx/esdctl.c b/arch/arm/mach-imx/esdctl.c index ffe708f385..1eebc77b63 100644 --- a/arch/arm/mach-imx/esdctl.c +++ b/arch/arm/mach-imx/esdctl.c @@ -432,6 +432,9 @@ static struct platform_device_id imx_esdctl_ids[] = { static __maybe_unused struct of_device_id imx_esdctl_dt_ids[] = { { + .compatible = "fsl,imx6sl-mmdc", + .data = &imx6ul_data + }, { .compatible = "fsl,imx6ul-mmdc", .data = &imx6ul_data }, { diff --git a/arch/arm/mach-imx/imx.c b/arch/arm/mach-imx/imx.c index 907340fc5d..19907397f9 100644 --- a/arch/arm/mach-imx/imx.c +++ b/arch/arm/mach-imx/imx.c @@ -61,6 +61,8 @@ static int imx_soc_from_dt(void) return IMX_CPU_IMX6; if (of_machine_is_compatible("fsl,imx6sx")) return IMX_CPU_IMX6; + if (of_machine_is_compatible("fsl,imx6sl")) + return IMX_CPU_IMX6; if (of_machine_is_compatible("fsl,imx6qp")) return IMX_CPU_IMX6; if (of_machine_is_compatible("fsl,imx6ul")) diff --git a/drivers/clk/imx/Makefile b/drivers/clk/imx/Makefile index 32d5038795..b864b4f321 100644 --- a/drivers/clk/imx/Makefile +++ b/drivers/clk/imx/Makefile @@ -19,6 +19,7 @@ obj-$(CONFIG_ARCH_IMX51) += clk-imx5.o obj-$(CONFIG_ARCH_IMX53) += clk-imx5.o obj-$(CONFIG_ARCH_IMX6) += clk-imx6.o obj-$(CONFIG_ARCH_IMX6SX) += clk-imx6sx.o +obj-$(CONFIG_ARCH_IMX6SL) += clk-imx6sl.o obj-$(CONFIG_ARCH_IMX6UL) += clk-imx6ul.o obj-$(CONFIG_ARCH_IMX7) += clk-imx7.o obj-$(CONFIG_ARCH_VF610) += clk-vf610.o diff --git a/drivers/pinctrl/imx-iomux-v3.c b/drivers/pinctrl/imx-iomux-v3.c index b5fa23560f..dea4324643 100644 --- a/drivers/pinctrl/imx-iomux-v3.c +++ b/drivers/pinctrl/imx-iomux-v3.c @@ -197,6 +197,8 @@ static __maybe_unused struct of_device_id imx_iomux_v3_dt_ids[] = { .compatible = "fsl,imx6sx-iomuxc", }, { .compatible = "fsl,imx6ul-iomuxc", + }, { + .compatible = "fsl,imx6sl-iomuxc", }, { .compatible = "fsl,imx7d-iomuxc", }, { -- cgit v1.2.3 From ad200f0dc31c1dc89e36e0d2f71707c51e2bc0a1 Mon Sep 17 00:00:00 2001 From: Sascha Hauer Date: Wed, 1 Feb 2017 08:19:43 +0100 Subject: pinctrl: i.MX7: Fix LPSR sel_imput setting The i.MX7 has two pinmux controllers, the regular and the LPSR controller. The LPSR pinmux controller doesn't have any sel_input registers, instead they can be found in the regular pinmux controller. This means whenever we want to apply the the sel_input setting for the LPSR controller, we have to apply them to the regular controller instead. In barebox take the easy way out and just add the difference of the two base addresses to the register offset. The same issue is present in the Kernel aswell, but when the bootloader already configured the pins correctly nobody notices when the Kernel sel_input setup effectively is a no-op. Signed-off-by: Sascha Hauer --- arch/arm/mach-imx/include/mach/iomux-v3.h | 8 ++++++++ drivers/pinctrl/imx-iomux-v3.c | 2 +- 2 files changed, 9 insertions(+), 1 deletion(-) (limited to 'drivers/pinctrl/imx-iomux-v3.c') diff --git a/arch/arm/mach-imx/include/mach/iomux-v3.h b/arch/arm/mach-imx/include/mach/iomux-v3.h index f877aad89b..271fe94a00 100644 --- a/arch/arm/mach-imx/include/mach/iomux-v3.h +++ b/arch/arm/mach-imx/include/mach/iomux-v3.h @@ -116,6 +116,7 @@ typedef u64 iomux_v3_cfg_t; #define SHARE_MUX_CONF_REG 0x1 #define ZERO_OFFSET_VALID 0x2 +#define IMX7_PINMUX_LPSR 0x4 static inline void iomux_v3_setup_pad(void __iomem *iomux, unsigned int flags, u32 mux_reg, u32 conf_reg, u32 input_reg, @@ -125,6 +126,13 @@ static inline void iomux_v3_setup_pad(void __iomem *iomux, unsigned int flags, const bool conf_ok = !!conf_reg; const bool input_ok = !!input_reg; + /* + * The sel_input registers for the LPSR controller pins are in the regular pinmux + * controller, so bend the register offset over to the other controller. + */ + if (flags & IMX7_PINMUX_LPSR) + input_reg += 0x70000; + if (flags & SHARE_MUX_CONF_REG) { mux_val |= conf_val; } else { diff --git a/drivers/pinctrl/imx-iomux-v3.c b/drivers/pinctrl/imx-iomux-v3.c index dea4324643..50d7177367 100644 --- a/drivers/pinctrl/imx-iomux-v3.c +++ b/drivers/pinctrl/imx-iomux-v3.c @@ -177,7 +177,7 @@ static int imx_iomux_v3_probe(struct device_d *dev) } static struct imx_iomux_v3_data imx_iomux_imx7_lpsr_data = { - .flags = ZERO_OFFSET_VALID, + .flags = ZERO_OFFSET_VALID | IMX7_PINMUX_LPSR, }; static __maybe_unused struct of_device_id imx_iomux_v3_dt_ids[] = { -- cgit v1.2.3