diff options
author | Andrey Smirnov <andrew.smirnov@gmail.com> | 2017-01-10 07:09:03 -0800 |
---|---|---|
committer | Sascha Hauer <s.hauer@pengutronix.de> | 2017-01-12 07:40:01 +0100 |
commit | b2282c18a4bcbd54f5b88e889b89db7104abba4e (patch) | |
tree | 4d93244989ea1427ff221797565b05ab261f606e | |
parent | 21921f7f419dfaabcd385595ada24f0352310f1a (diff) | |
download | barebox-b2282c18a4bcbd54f5b88e889b89db7104abba4e.tar.gz barebox-b2282c18a4bcbd54f5b88e889b89db7104abba4e.tar.xz |
i.MX: iomuxv3: Add low-level pad code to headers
Add a basic low-level pad configuration function that can be used to
implement early boot pin configuration code as well as shared with
various iomuxv3 and vf610 drivers.
Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
-rw-r--r-- | arch/arm/mach-imx/include/mach/iomux-v3.h | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/arch/arm/mach-imx/include/mach/iomux-v3.h b/arch/arm/mach-imx/include/mach/iomux-v3.h index b8cc9af68a..3bf457f212 100644 --- a/arch/arm/mach-imx/include/mach/iomux-v3.h +++ b/arch/arm/mach-imx/include/mach/iomux-v3.h @@ -16,6 +16,8 @@ #ifndef __MACH_IOMUX_V3_H__ #define __MACH_IOMUX_V3_H__ +#include <io.h> + /* * build IOMUX_PAD structure * @@ -104,6 +106,32 @@ typedef u64 iomux_v3_cfg_t; #define IOMUX_CONFIG_SION (0x1 << 4) +#define SHARE_MUX_CONF_REG 0x1 +#define ZERO_OFFSET_VALID 0x2 + +static inline void iomux_v3_setup_pad(void __iomem *iomux, unsigned int flags, + u32 mux_reg, u32 conf_reg, u32 input_reg, + u32 mux_val, u32 conf_val, u32 input_val) +{ + const bool mux_ok = !!mux_reg || (flags & ZERO_OFFSET_VALID); + const bool conf_ok = !!conf_reg; + const bool input_ok = !!input_reg; + + if (flags & SHARE_MUX_CONF_REG) { + mux_val |= conf_val; + } else { + if (conf_ok) + writel(conf_val, iomux + conf_reg); + } + + if (mux_ok) + writel(mux_val, iomux + mux_reg); + + if (input_ok) + writel(input_val, iomux + input_reg); +} + + /* * setups a single pad in the iomuxer */ |