ARM: i.MX IOMUX-V3 replace struct pad_desc with bitmapped cookie
authorLothar Waßmann <LW@KARO-electronics.de>
Tue, 26 Oct 2010 12:28:31 +0000 (14:28 +0200)
committerSascha Hauer <s.hauer@pengutronix.de>
Wed, 24 Nov 2010 08:56:58 +0000 (09:56 +0100)
The following patch is a first step to convert the 'struct pad_desc'
to a bitmapped cookie to facilitate adding platform specific pullup or
drive strength definitions to existing pad definitions without need to
rewrite the complete pad def.

The patch wraps 'struct pad_desc' in an opaque data type and
introduces macros to access the individual members.
This patch does not constitute any functional change!

Signed-off-by: Lothar Waßmann <LW@KARO-electronics.de>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
16 files changed:
arch/arm/mach-imx/eukrea_mbimxsd25-baseboard.c
arch/arm/mach-imx/mach-eukrea_cpuimx25.c
arch/arm/mach-imx/mach-mx25_3ds.c
arch/arm/mach-mx3/eukrea_mbimxsd-baseboard.c
arch/arm/mach-mx3/mach-cpuimx35.c
arch/arm/mach-mx3/mach-mx35_3ds.c
arch/arm/mach-mx3/mach-pcm043.c
arch/arm/mach-mx5/board-cpuimx51.c
arch/arm/mach-mx5/board-cpuimx51sd.c
arch/arm/mach-mx5/board-mx51_3ds.c
arch/arm/mach-mx5/board-mx51_babbage.c
arch/arm/mach-mx5/board-mx51_efikamx.c
arch/arm/mach-mx5/eukrea_mbimx51-baseboard.c
arch/arm/mach-mx5/eukrea_mbimxsd-baseboard.c
arch/arm/plat-mxc/include/mach/iomux-v3.h
arch/arm/plat-mxc/iomux-v3.c

index 7cab720519ee362382d5aeb14d2bf9a720e3463f..cb705c28de025c689d2e90370245e42968c97e7c 100644 (file)
@@ -37,7 +37,7 @@
 
 #include "devices-imx25.h"
 
-static struct pad_desc eukrea_mbimxsd_pads[] = {
+static iomux_v3_cfg_t eukrea_mbimxsd_pads[] = {
        /* LCD */
        MX25_PAD_LD0__LD0,
        MX25_PAD_LD1__LD1,
index 67a7d55ad1915ac5dc5db2242d2710212cce0346..eb395aba9237535b6f9402e6defdfce3fbf94f3f 100644 (file)
@@ -46,7 +46,7 @@ static const struct imxuart_platform_data uart_pdata __initconst = {
        .flags = IMXUART_HAVE_RTSCTS,
 };
 
-static struct pad_desc eukrea_cpuimx25_pads[] = {
+static iomux_v3_cfg_t eukrea_cpuimx25_pads[] = {
        /* FEC - RMII */
        MX25_PAD_FEC_MDC__FEC_MDC,
        MX25_PAD_FEC_MDIO__FEC_MDIO,
index 52b4d9b3717d650d2421452695f0b766269c80f0..8b8e75b9300011c357f9508f9a8dbf5d5a86a7d1 100644 (file)
@@ -47,7 +47,7 @@ static const struct imxuart_platform_data uart_pdata __initconst = {
        .flags = IMXUART_HAVE_RTSCTS,
 };
 
-static struct pad_desc mx25pdk_pads[] = {
+static iomux_v3_cfg_t mx25pdk_pads[] = {
        MX25_PAD_FEC_MDC__FEC_MDC,
        MX25_PAD_FEC_MDIO__FEC_MDIO,
        MX25_PAD_FEC_TDATA0__FEC_TDATA0,
index 950dbb13b19b3032c493e195dbd8af2f608b22c8..14a5ffc939ad96a78ded2c34ebb3f7fd8dffe59b 100644 (file)
@@ -111,7 +111,7 @@ static struct mx3fb_platform_data mx3fb_pdata = {
        .num_modes      = ARRAY_SIZE(fb_modedb),
 };
 
-static struct pad_desc eukrea_mbimxsd_pads[] = {
+static iomux_v3_cfg_t eukrea_mbimxsd_pads[] = {
        /* LCD */
        MX35_PAD_LD0__IPU_DISPB_DAT_0,
        MX35_PAD_LD1__IPU_DISPB_DAT_1,
index dda19883ffe2f0b2ed612fc1966119f92e86422d..26ae90f02582a1010225ad994c20e37aaa1432b2 100644 (file)
@@ -72,7 +72,7 @@ static struct i2c_board_info eukrea_cpuimx35_i2c_devices[] = {
        },
 };
 
-static struct pad_desc eukrea_cpuimx35_pads[] = {
+static iomux_v3_cfg_t eukrea_cpuimx35_pads[] = {
        /* UART1 */
        MX35_PAD_CTS1__UART1_CTS,
        MX35_PAD_RTS1__UART1_RTS,
index 7e73153b2b6b72a44a612cd247ecd3133222c7c8..8bd8992ffaa5c12bc8961b9cf316d91a08b52e42 100644 (file)
@@ -79,7 +79,7 @@ static struct platform_device *devices[] __initdata = {
        &mx35pdk_flash,
 };
 
-static struct pad_desc mx35pdk_pads[] = {
+static iomux_v3_cfg_t mx35pdk_pads[] = {
        /* UART1 */
        MX35_PAD_CTS1__UART1_CTS,
        MX35_PAD_RTS1__UART1_RTS,
index 826c6dc2f4c8184893c55b231c35aae3e89e56a5..e229a7476f0a60132506cbb0c25af6703b99c9db 100644 (file)
@@ -140,7 +140,7 @@ static struct platform_device *devices[] __initdata = {
        &pcm043_flash,
 };
 
-static struct pad_desc pcm043_pads[] = {
+static iomux_v3_cfg_t pcm043_pads[] = {
        /* UART1 */
        MX35_PAD_CTS1__UART1_CTS,
        MX35_PAD_RTS1__UART1_RTS,
@@ -227,8 +227,8 @@ static struct pad_desc pcm043_pads[] = {
 
 static void pcm043_ac97_warm_reset(struct snd_ac97 *ac97)
 {
-       struct pad_desc txfs_gpio = MX35_PAD_STXFS4__GPIO2_31;
-       struct pad_desc txfs = MX35_PAD_STXFS4__AUDMUX_AUD4_TXFS;
+       iomux_v3_cfg_t txfs_gpio = MX35_PAD_STXFS4__GPIO2_31;
+       iomux_v3_cfg_t txfs = MX35_PAD_STXFS4__AUDMUX_AUD4_TXFS;
        int ret;
 
        ret = gpio_request(AC97_GPIO_TXFS, "SSI");
@@ -250,11 +250,11 @@ static void pcm043_ac97_warm_reset(struct snd_ac97 *ac97)
 
 static void pcm043_ac97_cold_reset(struct snd_ac97 *ac97)
 {
-       struct pad_desc txfs_gpio = MX35_PAD_STXFS4__GPIO2_31;
-       struct pad_desc txfs = MX35_PAD_STXFS4__AUDMUX_AUD4_TXFS;
-       struct pad_desc txd_gpio = MX35_PAD_STXD4__GPIO2_28;
-       struct pad_desc txd = MX35_PAD_STXD4__AUDMUX_AUD4_TXD;
-       struct pad_desc reset_gpio = MX35_PAD_SD2_CMD__GPIO2_0;
+       iomux_v3_cfg_t txfs_gpio = MX35_PAD_STXFS4__GPIO2_31;
+       iomux_v3_cfg_t txfs = MX35_PAD_STXFS4__AUDMUX_AUD4_TXFS;
+       iomux_v3_cfg_t txd_gpio = MX35_PAD_STXD4__GPIO2_28;
+       iomux_v3_cfg_t txd = MX35_PAD_STXD4__AUDMUX_AUD4_TXD;
+       iomux_v3_cfg_t reset_gpio = MX35_PAD_SD2_CMD__GPIO2_0;
        int ret;
 
        ret = gpio_request(AC97_GPIO_TXFS, "SSI");
index 6a9792fd0a763ed6b2d281e98b5cfc3bf3d67562..bfbc14af589ec54859210a8fd0b7ed4c5412450f 100644 (file)
@@ -113,7 +113,7 @@ static struct platform_device *devices[] __initdata = {
 #endif
 };
 
-static struct pad_desc eukrea_cpuimx51_pads[] = {
+static iomux_v3_cfg_t eukrea_cpuimx51_pads[] = {
        /* UART1 */
        MX51_PAD_UART1_RXD__UART1_RXD,
        MX51_PAD_UART1_TXD__UART1_TXD,
index 4b3a6119c5fb0d6a81b3539b4dcc86f07926b1fe..e6807e36e436166785dd5f45f6bd78ca55740973 100644 (file)
@@ -68,7 +68,7 @@
 #define CPUIMX51SD_GPIO_3_12 IOMUX_PAD(0x57C, 0x194, 3, 0x0, 0, \
                                MX51_PAD_CTRL_1 | PAD_CTL_PUS_22K_UP)
 
-static struct pad_desc eukrea_cpuimx51sd_pads[] = {
+static iomux_v3_cfg_t eukrea_cpuimx51sd_pads[] = {
        /* UART1 */
        MX51_PAD_UART1_RXD__UART1_RXD,
        MX51_PAD_UART1_TXD__UART1_TXD,
index 79ce8dcf3cda5bd26829be57a7b647c032b3ecad..ba5805f33adfb77d4d4cba126aed1e51d9fad584 100644 (file)
@@ -30,7 +30,7 @@
 #define EXPIO_PARENT_INT       (MXC_INTERNAL_IRQS + GPIO_PORTA + 6)
 #define MX51_3DS_ECSPI2_CS     (GPIO_PORTC + 28)
 
-static struct pad_desc mx51_3ds_pads[] = {
+static iomux_v3_cfg_t mx51_3ds_pads[] = {
        /* UART1 */
        MX51_PAD_UART1_RXD__UART1_RXD,
        MX51_PAD_UART1_TXD__UART1_TXD,
index 542f2b147dcc131653f139537f51cf074e110fde..0df50d214db8a37072a4851877ef729221b96af1 100644 (file)
@@ -65,7 +65,7 @@ static const struct gpio_keys_platform_data imx_button_data __initconst = {
        .nbuttons       = ARRAY_SIZE(babbage_buttons),
 };
 
-static struct pad_desc mx51babbage_pads[] = {
+static iomux_v3_cfg_t mx51babbage_pads[] = {
        /* UART1 */
        MX51_PAD_UART1_RXD__UART1_RXD,
        MX51_PAD_UART1_TXD__UART1_TXD,
@@ -177,8 +177,8 @@ static struct imxi2c_platform_data babbage_hsi2c_data = {
 
 static int gpio_usbh1_active(void)
 {
-       struct pad_desc usbh1stp_gpio = MX51_PAD_USBH1_STP__GPIO_1_27;
-       struct pad_desc phyreset_gpio = MX51_PAD_EIM_D21__GPIO_2_5;
+       iomux_v3_cfg_t usbh1stp_gpio = MX51_PAD_USBH1_STP__GPIO_1_27;
+       iomux_v3_cfg_t phyreset_gpio = MX51_PAD_EIM_D21__GPIO_2_5;
        int ret;
 
        /* Set USBH1_STP to GPIO and toggle it */
@@ -315,8 +315,8 @@ __setup("otg_mode=", babbage_otg_mode);
  */
 static void __init mxc_board_init(void)
 {
-       struct pad_desc usbh1stp = MX51_PAD_USBH1_STP__USBH1_STP;
-       struct pad_desc power_key = MX51_PAD_EIM_A27__GPIO_2_21;
+       iomux_v3_cfg_t usbh1stp = MX51_PAD_USBH1_STP__USBH1_STP;
+       iomux_v3_cfg_t power_key = MX51_PAD_EIM_A27__GPIO_2_21;
 
 #if defined(CONFIG_CPU_FREQ_IMX)
        get_cpu_op = mx51_get_cpu_op;
index 6e623bda3ee7c24cdd5ed4322160305019e314ea..1b1d4f14d486e8ae7e0e185ad7e938c0c698958b 100644 (file)
@@ -39,7 +39,7 @@
 
 #define        MX51_USB_PLL_DIV_24_MHZ 0x01
 
-static struct pad_desc mx51efikamx_pads[] = {
+static iomux_v3_cfg_t mx51efikamx_pads[] = {
        /* UART1 */
        MX51_PAD_UART1_RXD__UART1_RXD,
        MX51_PAD_UART1_TXD__UART1_TXD,
index 4e74b9907b7ceb9671d47a877653969551fcd793..b830967f4bec1298d81bea9c82cf48ffdfbc42e4 100644 (file)
@@ -84,7 +84,7 @@ static struct platform_device *devices[] __initdata = {
        &mbimx51_leds_gpio,
 };
 
-static struct pad_desc mbimx51_pads[] = {
+static iomux_v3_cfg_t mbimx51_pads[] = {
        /* UART2 */
        MX51_PAD_UART2_RXD__UART2_RXD,
        MX51_PAD_UART2_TXD__UART2_TXD,
index 038d8c94f79efa3b5cffed06ac241d7d50e3d964..2751b11ead896ce346c453f7fd9a02392c89d4f9 100644 (file)
@@ -48,7 +48,7 @@
 #define MBIMXSD_GPIO_3_31 IOMUX_PAD(0x554, 0x16C, 3, 0x0, 0, \
                                MX51_PAD_CTRL_1 | PAD_CTL_PUS_22K_UP)
 
-static struct pad_desc eukrea_mbimxsd_pads[] = {
+static iomux_v3_cfg_t eukrea_mbimxsd_pads[] = {
        /* LED */
        MX51_PAD_NANDF_D10__GPIO_3_30,
        /* SWITCH */
index 0880a4a1aed1e91c397653515dca3d979cf9b804..811716fbfbe61f6fd90f681c9fe5a397427d9cc2 100644 (file)
@@ -44,7 +44,7 @@
  *
  */
 
-struct pad_desc {
+typedef struct deprecated_pad_desc {
        unsigned mux_ctrl_ofs:12; /* IOMUXC_SW_MUX_CTL_PAD offset */
        unsigned mux_mode:8;
        unsigned pad_ctrl_ofs:12; /* IOMUXC_SW_PAD_CTRL offset */
@@ -52,7 +52,37 @@ struct pad_desc {
        unsigned pad_ctrl:17;
        unsigned select_input_ofs:12; /* IOMUXC_SELECT_INPUT offset */
        unsigned select_input:3;
-};
+} iomux_v3_cfg_t;
+
+static inline unsigned int MUX_CTRL_OFS(iomux_v3_cfg_t *pad)
+{
+       return pad->mux_ctrl_ofs;
+}
+
+static inline unsigned int MUX_MODE(iomux_v3_cfg_t *pad)
+{
+       return pad->mux_mode;
+}
+
+static inline unsigned int MUX_SELECT_INPUT_OFS(iomux_v3_cfg_t *pad)
+{
+       return pad->select_input_ofs;
+}
+
+static inline unsigned int MUX_SELECT_INPUT(iomux_v3_cfg_t *pad)
+{
+       return pad->select_input;
+}
+
+static inline unsigned int MUX_PAD_CTRL_OFS(iomux_v3_cfg_t *pad)
+{
+       return pad->pad_ctrl_ofs;
+}
+
+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)                               \
@@ -107,13 +137,13 @@ struct pad_desc {
 /*
  * setups a single pad in the iomuxer
  */
-int mxc_iomux_v3_setup_pad(struct pad_desc *pad);
+int mxc_iomux_v3_setup_pad(iomux_v3_cfg_t *pad);
 
 /*
  * setups mutliple pads
  * convenient way to call the above function with tables
  */
-int mxc_iomux_v3_setup_multiple_pads(struct pad_desc *pad_list, unsigned count);
+int mxc_iomux_v3_setup_multiple_pads(iomux_v3_cfg_t *pad_list, unsigned count);
 
 /*
  * Initialise the iomux controller
index b318c6a222d50a990a689f67764e56682d05bd68..975ca7cdf9adf22c278b65bcf1dbf6063855a286 100644 (file)
 static void __iomem *base;
 
 /*
- * setups a single pad in the iomuxer
+ * configures a single pad in the iomuxer
  */
-int mxc_iomux_v3_setup_pad(struct pad_desc *pad)
+int mxc_iomux_v3_setup_pad(iomux_v3_cfg_t *pad)
 {
-       if (pad->mux_ctrl_ofs)
-               __raw_writel(pad->mux_mode, base + pad->mux_ctrl_ofs);
+       if (MUX_CTRL_OFS(pad))
+               __raw_writel(MUX_MODE(pad), base + MUX_CTRL_OFS(pad));
 
-       if (pad->select_input_ofs)
-               __raw_writel(pad->select_input,
-                               base + pad->select_input_ofs);
+       if (MUX_SELECT_INPUT_OFS(pad))
+               __raw_writel(MUX_SELECT_INPUT(pad),
+                       base + MUX_SELECT_INPUT(pad));
 
-       if (!(pad->pad_ctrl & NO_PAD_CTRL) && pad->pad_ctrl_ofs)
-               __raw_writel(pad->pad_ctrl, base + pad->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;
 }
 EXPORT_SYMBOL(mxc_iomux_v3_setup_pad);
 
-int mxc_iomux_v3_setup_multiple_pads(struct pad_desc *pad_list, unsigned count)
+int mxc_iomux_v3_setup_multiple_pads(iomux_v3_cfg_t *pad_list, unsigned count)
 {
-       struct pad_desc *p = pad_list;
+       iomux_v3_cfg_t *p = pad_list;
        int i;
        int ret;