Commit 96f3e256 authored by Lothar Waßmann's avatar Lothar Waßmann Committed by Sascha Hauer

MXC IOMUX-V3 replace struct pad_desc with bitmapped cookie (step 2)

This patch actually replaces the 'struct pad_desc' with a u64 cookie
to facilitate adding platform specific pad_ctrl settings to an
existing pad definition.

So, instead of:
	iomux_v3_cfg_t power_key = MX51_PAD_EIM_A27__GPIO_2_21;
	power_key.pad_ctrl = MX51_GPIO_PAD_CTRL_2;
	mxc_iomux_v3_setup_pad(&power_key);
one can write:
	mxc_iomux_v3_setup_pad((MX51_PAD_EIM_A27__GPIO_2_21 & ~MUX_PAD_CTRL_MASK) | MX51_GPIO_PAD_CTRL_2);

Patch applies to branch 'imx-for-2.6.38' of git://git.pengutronix.de/git/imx/linux-2.6Signed-Off-By: default avatarLothar Waßmann <LW@KARO-electronics.de>
Signed-off-by: default avatarSascha Hauer <s.hauer@pengutronix.de>
parent 28a4f908
...@@ -237,7 +237,7 @@ static void pcm043_ac97_warm_reset(struct snd_ac97 *ac97) ...@@ -237,7 +237,7 @@ static void pcm043_ac97_warm_reset(struct snd_ac97 *ac97)
return; return;
} }
mxc_iomux_v3_setup_pad(&txfs_gpio); mxc_iomux_v3_setup_pad(txfs_gpio);
/* warm reset */ /* warm reset */
gpio_direction_output(AC97_GPIO_TXFS, 1); gpio_direction_output(AC97_GPIO_TXFS, 1);
...@@ -245,7 +245,7 @@ static void pcm043_ac97_warm_reset(struct snd_ac97 *ac97) ...@@ -245,7 +245,7 @@ static void pcm043_ac97_warm_reset(struct snd_ac97 *ac97)
gpio_set_value(AC97_GPIO_TXFS, 0); gpio_set_value(AC97_GPIO_TXFS, 0);
gpio_free(AC97_GPIO_TXFS); gpio_free(AC97_GPIO_TXFS);
mxc_iomux_v3_setup_pad(&txfs); mxc_iomux_v3_setup_pad(txfs);
} }
static void pcm043_ac97_cold_reset(struct snd_ac97 *ac97) static void pcm043_ac97_cold_reset(struct snd_ac97 *ac97)
...@@ -269,9 +269,9 @@ static void pcm043_ac97_cold_reset(struct snd_ac97 *ac97) ...@@ -269,9 +269,9 @@ static void pcm043_ac97_cold_reset(struct snd_ac97 *ac97)
if (ret) if (ret)
goto err3; goto err3;
mxc_iomux_v3_setup_pad(&txfs_gpio); mxc_iomux_v3_setup_pad(txfs_gpio);
mxc_iomux_v3_setup_pad(&txd_gpio); mxc_iomux_v3_setup_pad(txd_gpio);
mxc_iomux_v3_setup_pad(&reset_gpio); mxc_iomux_v3_setup_pad(reset_gpio);
gpio_direction_output(AC97_GPIO_TXFS, 0); gpio_direction_output(AC97_GPIO_TXFS, 0);
gpio_direction_output(AC97_GPIO_TXD, 0); gpio_direction_output(AC97_GPIO_TXD, 0);
...@@ -281,8 +281,8 @@ static void pcm043_ac97_cold_reset(struct snd_ac97 *ac97) ...@@ -281,8 +281,8 @@ static void pcm043_ac97_cold_reset(struct snd_ac97 *ac97)
udelay(10); udelay(10);
gpio_direction_output(AC97_GPIO_RESET, 1); gpio_direction_output(AC97_GPIO_RESET, 1);
mxc_iomux_v3_setup_pad(&txd); mxc_iomux_v3_setup_pad(txd);
mxc_iomux_v3_setup_pad(&txfs); mxc_iomux_v3_setup_pad(txfs);
gpio_free(AC97_GPIO_RESET); gpio_free(AC97_GPIO_RESET);
err3: err3:
......
...@@ -193,7 +193,7 @@ static int gpio_usbh1_active(void) ...@@ -193,7 +193,7 @@ static int gpio_usbh1_active(void)
int ret; int ret;
/* Set USBH1_STP to GPIO and toggle it */ /* Set USBH1_STP to GPIO and toggle it */
mxc_iomux_v3_setup_pad(&usbh1stp_gpio); mxc_iomux_v3_setup_pad(usbh1stp_gpio);
ret = gpio_request(BABBAGE_USBH1_STP, "usbh1_stp"); ret = gpio_request(BABBAGE_USBH1_STP, "usbh1_stp");
if (ret) { if (ret) {
...@@ -206,7 +206,7 @@ static int gpio_usbh1_active(void) ...@@ -206,7 +206,7 @@ static int gpio_usbh1_active(void)
gpio_free(BABBAGE_USBH1_STP); gpio_free(BABBAGE_USBH1_STP);
/* De-assert USB PHY RESETB */ /* De-assert USB PHY RESETB */
mxc_iomux_v3_setup_pad(&phyreset_gpio); mxc_iomux_v3_setup_pad(phyreset_gpio);
ret = gpio_request(BABBAGE_PHY_RESET, "phy_reset"); ret = gpio_request(BABBAGE_PHY_RESET, "phy_reset");
if (ret) { if (ret) {
...@@ -352,7 +352,8 @@ static const struct spi_imx_master mx51_babbage_spi_pdata __initconst = { ...@@ -352,7 +352,8 @@ static const struct spi_imx_master mx51_babbage_spi_pdata __initconst = {
static void __init mxc_board_init(void) static void __init mxc_board_init(void)
{ {
iomux_v3_cfg_t usbh1stp = MX51_PAD_USBH1_STP__USBH1_STP; iomux_v3_cfg_t usbh1stp = MX51_PAD_USBH1_STP__USBH1_STP;
iomux_v3_cfg_t power_key = MX51_PAD_EIM_A27__GPIO_2_21; iomux_v3_cfg_t power_key = (MX51_PAD_EIM_A27__GPIO_2_21 &
~MUX_PAD_CTRL_MASK) | MX51_GPIO_PAD_CTRL_2;
#if defined(CONFIG_CPU_FREQ_IMX) #if defined(CONFIG_CPU_FREQ_IMX)
get_cpu_op = mx51_get_cpu_op; get_cpu_op = mx51_get_cpu_op;
...@@ -364,8 +365,7 @@ static void __init mxc_board_init(void) ...@@ -364,8 +365,7 @@ static void __init mxc_board_init(void)
imx51_add_fec(NULL); imx51_add_fec(NULL);
/* Set the PAD settings for the pwr key. */ /* Set the PAD settings for the pwr key. */
power_key.pad_ctrl = MX51_GPIO_PAD_CTRL_2; mxc_iomux_v3_setup_pad(power_key);
mxc_iomux_v3_setup_pad(&power_key);
imx51_add_gpio_keys(&imx_button_data); imx51_add_gpio_keys(&imx_button_data);
imx51_add_imx_i2c(0, &babbage_i2c_data); imx51_add_imx_i2c(0, &babbage_i2c_data);
...@@ -382,7 +382,7 @@ static void __init mxc_board_init(void) ...@@ -382,7 +382,7 @@ static void __init mxc_board_init(void)
gpio_usbh1_active(); gpio_usbh1_active();
mxc_register_device(&mxc_usbh1_device, &usbh1_config); mxc_register_device(&mxc_usbh1_device, &usbh1_config);
/* setback USBH1_STP to be function */ /* setback USBH1_STP to be function */
mxc_iomux_v3_setup_pad(&usbh1stp); mxc_iomux_v3_setup_pad(usbh1stp);
babbage_usbhub_reset(); babbage_usbhub_reset();
imx51_add_sdhci_esdhc_imx(0, NULL); imx51_add_sdhci_esdhc_imx(0, NULL);
......
...@@ -42,58 +42,42 @@ ...@@ -42,58 +42,42 @@
* If <padname> or <padmode> refers to a GPIO, it is named * If <padname> or <padmode> refers to a GPIO, it is named
* GPIO_<unit>_<num> * GPIO_<unit>_<num>
* *
*/ * IOMUX/PAD Bit field definitions
*
typedef struct deprecated_pad_desc { * MUX_CTRL_OFS: 0..11 (12)
unsigned mux_ctrl_ofs:12; /* IOMUXC_SW_MUX_CTL_PAD offset */ * PAD_CTRL_OFS: 12..23 (12)
unsigned mux_mode:8; * SEL_INPUT_OFS: 24..35 (12)
unsigned pad_ctrl_ofs:12; /* IOMUXC_SW_PAD_CTRL offset */ * MUX_MODE + SION: 36..40 (5)
#define NO_PAD_CTRL (1 << 16) * PAD_CTRL + NO_PAD_CTRL: 41..57 (17)
unsigned pad_ctrl:17; * SEL_INP: 58..61 (4)
unsigned select_input_ofs:12; /* IOMUXC_SELECT_INPUT offset */ * reserved: 63 (1)
unsigned select_input:3; */
} iomux_v3_cfg_t;
typedef u64 iomux_v3_cfg_t;
static inline unsigned int MUX_CTRL_OFS(iomux_v3_cfg_t *pad)
{ #define MUX_CTRL_OFS_SHIFT 0
return pad->mux_ctrl_ofs; #define MUX_CTRL_OFS_MASK ((iomux_v3_cfg_t)0xfff << MUX_CTRL_OFS_SHIFT)
} #define MUX_PAD_CTRL_OFS_SHIFT 12
#define MUX_PAD_CTRL_OFS_MASK ((iomux_v3_cfg_t)0xfff << MUX_PAD_CTRL_OFS_SHIFT)
static inline unsigned int MUX_MODE(iomux_v3_cfg_t *pad) #define MUX_SEL_INPUT_OFS_SHIFT 24
{ #define MUX_SEL_INPUT_OFS_MASK ((iomux_v3_cfg_t)0xfff << MUX_SEL_INPUT_OFS_SHIFT)
return pad->mux_mode;
} #define MUX_MODE_SHIFT 36
#define MUX_MODE_MASK ((iomux_v3_cfg_t)0x1f << MUX_MODE_SHIFT)
static inline unsigned int MUX_SELECT_INPUT_OFS(iomux_v3_cfg_t *pad) #define MUX_PAD_CTRL_SHIFT 41
{ #define MUX_PAD_CTRL_MASK ((iomux_v3_cfg_t)0x1ffff << MUX_PAD_CTRL_SHIFT)
return pad->select_input_ofs; #define NO_PAD_CTRL ((iomux_v3_cfg_t)1 << (MUX_PAD_CTRL_SHIFT + 16))
} #define MUX_SEL_INPUT_SHIFT 58
#define MUX_SEL_INPUT_MASK ((iomux_v3_cfg_t)0xf << MUX_SEL_INPUT_SHIFT)
static inline unsigned int MUX_SELECT_INPUT(iomux_v3_cfg_t *pad)
{ #define IOMUX_PAD(_pad_ctrl_ofs, _mux_ctrl_ofs, _mux_mode, _sel_input_ofs, \
return pad->select_input; _sel_input, _pad_ctrl) \
} (((iomux_v3_cfg_t)(_mux_ctrl_ofs) << MUX_CTRL_OFS_SHIFT) | \
((iomux_v3_cfg_t)(_mux_mode) << MUX_MODE_SHIFT) | \
static inline unsigned int MUX_PAD_CTRL_OFS(iomux_v3_cfg_t *pad) ((iomux_v3_cfg_t)(_pad_ctrl_ofs) << MUX_PAD_CTRL_OFS_SHIFT) | \
{ ((iomux_v3_cfg_t)(_pad_ctrl) << MUX_PAD_CTRL_SHIFT) | \
return pad->pad_ctrl_ofs; ((iomux_v3_cfg_t)(_sel_input_ofs) << MUX_SEL_INPUT_OFS_SHIFT) | \
} ((iomux_v3_cfg_t)(_sel_input) << MUX_SEL_INPUT_SHIFT))
static inline unsigned int MUX_PAD_CTRL(iomux_v3_cfg_t *pad)
{
return pad->pad_ctrl;
}
#define IOMUX_PAD(_pad_ctrl_ofs, _mux_ctrl_ofs, _mux_mode, _select_input_ofs, \
_select_input, _pad_ctrl) \
{ \
.mux_ctrl_ofs = _mux_ctrl_ofs, \
.mux_mode = _mux_mode, \
.pad_ctrl_ofs = _pad_ctrl_ofs, \
.pad_ctrl = _pad_ctrl, \
.select_input_ofs = _select_input_ofs, \
.select_input = _select_input, \
}
/* /*
* Use to set PAD control * Use to set PAD control
...@@ -137,7 +121,7 @@ static inline unsigned int MUX_PAD_CTRL(iomux_v3_cfg_t *pad) ...@@ -137,7 +121,7 @@ static inline unsigned int MUX_PAD_CTRL(iomux_v3_cfg_t *pad)
/* /*
* setups a single pad in the iomuxer * setups a single pad in the iomuxer
*/ */
int mxc_iomux_v3_setup_pad(iomux_v3_cfg_t *pad); int mxc_iomux_v3_setup_pad(iomux_v3_cfg_t pad);
/* /*
* setups mutliple pads * setups mutliple pads
......
...@@ -34,17 +34,24 @@ static void __iomem *base; ...@@ -34,17 +34,24 @@ static void __iomem *base;
/* /*
* configures a single pad in the iomuxer * configures a single pad in the iomuxer
*/ */
int mxc_iomux_v3_setup_pad(iomux_v3_cfg_t *pad) int mxc_iomux_v3_setup_pad(iomux_v3_cfg_t pad)
{ {
if (MUX_CTRL_OFS(pad)) u32 mux_ctrl_ofs = (pad & MUX_CTRL_OFS_MASK) >> MUX_CTRL_OFS_SHIFT;
__raw_writel(MUX_MODE(pad), base + MUX_CTRL_OFS(pad)); u32 mux_mode = (pad & MUX_MODE_MASK) >> MUX_MODE_SHIFT;
u32 sel_input_ofs = (pad & MUX_SEL_INPUT_OFS_MASK) >> MUX_SEL_INPUT_OFS_SHIFT;
u32 sel_input = (pad & MUX_SEL_INPUT_MASK) >> MUX_SEL_INPUT_SHIFT;
u32 pad_ctrl_ofs = (pad & MUX_PAD_CTRL_OFS_MASK) >> MUX_PAD_CTRL_OFS_SHIFT;
u32 pad_ctrl = (pad & MUX_PAD_CTRL_MASK) >> MUX_PAD_CTRL_SHIFT;
if (MUX_SELECT_INPUT_OFS(pad)) if (mux_ctrl_ofs)
__raw_writel(MUX_SELECT_INPUT(pad), __raw_writel(mux_mode, base + mux_ctrl_ofs);
base + MUX_SELECT_INPUT_OFS(pad));
if (sel_input_ofs)
__raw_writel(sel_input, base + sel_input_ofs);
if (!(pad_ctrl & NO_PAD_CTRL) && pad_ctrl_ofs)
__raw_writel(pad_ctrl, base + pad_ctrl_ofs);
if (!(MUX_PAD_CTRL(pad) & NO_PAD_CTRL) && MUX_PAD_CTRL_OFS(pad))
__raw_writel(MUX_PAD_CTRL(pad), base + MUX_PAD_CTRL_OFS(pad));
return 0; return 0;
} }
EXPORT_SYMBOL(mxc_iomux_v3_setup_pad); EXPORT_SYMBOL(mxc_iomux_v3_setup_pad);
...@@ -56,7 +63,7 @@ int mxc_iomux_v3_setup_multiple_pads(iomux_v3_cfg_t *pad_list, unsigned count) ...@@ -56,7 +63,7 @@ int mxc_iomux_v3_setup_multiple_pads(iomux_v3_cfg_t *pad_list, unsigned count)
int ret; int ret;
for (i = 0; i < count; i++) { for (i = 0; i < count; i++) {
ret = mxc_iomux_v3_setup_pad(p); ret = mxc_iomux_v3_setup_pad(*p);
if (ret) if (ret)
return ret; return ret;
p++; p++;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment