Commit 112485e9 authored by Benoit Cousson's avatar Benoit Cousson

OMAP: mux: Add support for control module split in several partitions

Starting on OMAP4, the pin mux configuration is located in two
different partitions of the control module (CODE_PAD and WKUP_PAD).
The first one is inside the core power domain whereas the second
one is inside the wakeup.
- Add the capability to add any number of partition during board init
time depending of Soc partitioning.
- Add some init flags as well in order to avoid explicit Soc version
check inside the mux core code.
- Add a comment with mux0 mode on top of omap_mux/board/<partition>
if the current mux mode is not the default one.

Thanks to Tony Lindgren <tony@atomide.com> for the following improvements:
- Add omap_mux_get for getting the partition data so platform level
device code can use it.
- Fix the rx51 board code to use the new API.
- Do not store the partition for each mux entry. Look up the partition
for debugfs instead.

Thanks to Dan Murphy <dmurphy@ti.com> for testing on OMAP4 and reporting
a couple of bugs.
Thanks to Anand Gadiyar <gadiyar@ti.com> for testing on OMAP3 zoom and
bug report.
Signed-off-by: default avatarBenoit Cousson <b-cousson@ti.com>
Signed-off-by: default avatarTony Lindgren <tony@atomide.com>
Tested-by: default avatarMurphy Dan <dmurphy@ti.com>
Cc: Paul Walmsley <paul@pwsan.com>
Cc: Kevin Hilman <khilman@deeprootsystems.com>
Cc: Santosh Shilimkar <santosh.shilimkar@ti.com>
Cc: Anand Gadiyar <gadiyar@ti.com>
parent 1cbb3a9a
...@@ -293,6 +293,8 @@ static struct omap_board_mux rx51_mmc2_off_mux[] = { ...@@ -293,6 +293,8 @@ static struct omap_board_mux rx51_mmc2_off_mux[] = {
{ .reg_offset = OMAP_MUX_TERMINATOR }, { .reg_offset = OMAP_MUX_TERMINATOR },
}; };
static struct omap_mux_partition *partition;
/* /*
* Current flows to eMMC when eMMC is off and the data lines are pulled up, * Current flows to eMMC when eMMC is off and the data lines are pulled up,
* so pull them down. N.B. we pull 8 lines because we are using 8 lines. * so pull them down. N.B. we pull 8 lines because we are using 8 lines.
...@@ -300,9 +302,9 @@ static struct omap_board_mux rx51_mmc2_off_mux[] = { ...@@ -300,9 +302,9 @@ static struct omap_board_mux rx51_mmc2_off_mux[] = {
static void rx51_mmc2_remux(struct device *dev, int slot, int power_on) static void rx51_mmc2_remux(struct device *dev, int slot, int power_on)
{ {
if (power_on) if (power_on)
omap_mux_write_array(rx51_mmc2_on_mux); omap_mux_write_array(partition, rx51_mmc2_on_mux);
else else
omap_mux_write_array(rx51_mmc2_off_mux); omap_mux_write_array(partition, rx51_mmc2_off_mux);
} }
static struct omap2_hsmmc_info mmc[] __initdata = { static struct omap2_hsmmc_info mmc[] __initdata = {
...@@ -922,7 +924,11 @@ void __init rx51_peripherals_init(void) ...@@ -922,7 +924,11 @@ void __init rx51_peripherals_init(void)
rx51_init_wl1251(); rx51_init_wl1251();
spi_register_board_info(rx51_peripherals_spi_board_info, spi_register_board_info(rx51_peripherals_spi_board_info,
ARRAY_SIZE(rx51_peripherals_spi_board_info)); ARRAY_SIZE(rx51_peripherals_spi_board_info));
partition = omap_mux_get("core");
if (partition)
omap2_hsmmc_init(mmc); omap2_hsmmc_init(mmc);
platform_device_register(&rx51_charger_device); platform_device_register(&rx51_charger_device);
} }
This diff is collapsed.
/* /*
* Copyright (C) 2009 Nokia * Copyright (C) 2009 Nokia
* Copyright (C) 2009 Texas Instruments * Copyright (C) 2009-2010 Texas Instruments
* *
* This program is free software; you can redistribute it and/or modify * This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as * it under the terms of the GNU General Public License version 2 as
...@@ -56,7 +56,7 @@ ...@@ -56,7 +56,7 @@
#define OMAP_MODE_GPIO(x) (((x) & OMAP_MUX_MODE7) == OMAP_MUX_MODE4) #define OMAP_MODE_GPIO(x) (((x) & OMAP_MUX_MODE7) == OMAP_MUX_MODE4)
/* Flags for omap_mux_init */ /* Flags for omapX_mux_init */
#define OMAP_PACKAGE_MASK 0xffff #define OMAP_PACKAGE_MASK 0xffff
#define OMAP_PACKAGE_CBP 6 /* 515-pin 0.40 0.50 */ #define OMAP_PACKAGE_CBP 6 /* 515-pin 0.40 0.50 */
#define OMAP_PACKAGE_CUS 5 /* 423-pin 0.65 */ #define OMAP_PACKAGE_CUS 5 /* 423-pin 0.65 */
...@@ -69,11 +69,44 @@ ...@@ -69,11 +69,44 @@
#define OMAP_MUX_NR_MODES 8 /* Available modes */ #define OMAP_MUX_NR_MODES 8 /* Available modes */
#define OMAP_MUX_NR_SIDES 2 /* Bottom & top */ #define OMAP_MUX_NR_SIDES 2 /* Bottom & top */
/*
* omap_mux_init flags definition:
*
* OMAP_MUX_REG_8BIT: Ensure that access to padconf is done in 8 bits.
* The default value is 16 bits.
* OMAP_MUX_GPIO_IN_MODE3: The GPIO is selected in mode3.
* The default is mode4.
*/
#define OMAP_MUX_REG_8BIT (1 << 0)
#define OMAP_MUX_GPIO_IN_MODE3 (1 << 1)
/**
* struct mux_partition - contain partition related information
* @name: name of the current partition
* @flags: flags specific to this partition
* @phys: physical address
* @size: partition size
* @base: virtual address after ioremap
* @muxmodes: list of nodes that belong to a partition
* @node: list node for the partitions linked list
*/
struct omap_mux_partition {
const char *name;
u32 flags;
u32 phys;
u32 size;
void __iomem *base;
struct list_head muxmodes;
struct list_head node;
};
/** /**
* struct omap_mux - data for omap mux register offset and it's value * struct omap_mux - data for omap mux register offset and it's value
* @reg_offset: mux register offset from the mux base * @reg_offset: mux register offset from the mux base
* @gpio: GPIO number * @gpio: GPIO number
* @muxnames: available signal modes for a ball * @muxnames: available signal modes for a ball
* @balls: available balls on the package
* @partition: mux partition
*/ */
struct omap_mux { struct omap_mux {
u16 reg_offset; u16 reg_offset;
...@@ -150,29 +183,40 @@ u16 omap_mux_get_gpio(int gpio); ...@@ -150,29 +183,40 @@ u16 omap_mux_get_gpio(int gpio);
*/ */
void omap_mux_set_gpio(u16 val, int gpio); void omap_mux_set_gpio(u16 val, int gpio);
/**
* omap_mux_get() - get a mux partition by name
* @name: Name of the mux partition
*
*/
struct omap_mux_partition *omap_mux_get(const char *name);
/** /**
* omap_mux_read() - read mux register * omap_mux_read() - read mux register
* @partition: Mux partition
* @mux_offset: Offset of the mux register * @mux_offset: Offset of the mux register
* *
*/ */
u16 omap_mux_read(u16 mux_offset); u16 omap_mux_read(struct omap_mux_partition *p, u16 mux_offset);
/** /**
* omap_mux_write() - write mux register * omap_mux_write() - write mux register
* @partition: Mux partition
* @val: New mux register value * @val: New mux register value
* @mux_offset: Offset of the mux register * @mux_offset: Offset of the mux register
* *
* This should be only needed for dynamic remuxing of non-gpio signals. * This should be only needed for dynamic remuxing of non-gpio signals.
*/ */
void omap_mux_write(u16 val, u16 mux_offset); void omap_mux_write(struct omap_mux_partition *p, u16 val, u16 mux_offset);
/** /**
* omap_mux_write_array() - write an array of mux registers * omap_mux_write_array() - write an array of mux registers
* @partition: Mux partition
* @board_mux: Array of mux registers terminated by MAP_MUX_TERMINATOR * @board_mux: Array of mux registers terminated by MAP_MUX_TERMINATOR
* *
* This should be only needed for dynamic remuxing of non-gpio signals. * This should be only needed for dynamic remuxing of non-gpio signals.
*/ */
void omap_mux_write_array(struct omap_board_mux *board_mux); void omap_mux_write_array(struct omap_mux_partition *p,
struct omap_board_mux *board_mux);
/** /**
* omap2420_mux_init() - initialize mux system with board specific set * omap2420_mux_init() - initialize mux system with board specific set
...@@ -198,8 +242,10 @@ int omap3_mux_init(struct omap_board_mux *board_mux, int flags); ...@@ -198,8 +242,10 @@ int omap3_mux_init(struct omap_board_mux *board_mux, int flags);
/** /**
* omap_mux_init - private mux init function, do not call * omap_mux_init - private mux init function, do not call
*/ */
int omap_mux_init(u32 mux_pbase, u32 mux_size, int omap_mux_init(const char *name, u32 flags,
u32 mux_pbase, u32 mux_size,
struct omap_mux *superset, struct omap_mux *superset,
struct omap_mux *package_subset, struct omap_mux *package_subset,
struct omap_board_mux *board_mux, struct omap_board_mux *board_mux,
struct omap_ball *package_balls); struct omap_ball *package_balls);
...@@ -681,7 +681,8 @@ int __init omap2420_mux_init(struct omap_board_mux *board_subset, int flags) ...@@ -681,7 +681,8 @@ int __init omap2420_mux_init(struct omap_board_mux *board_subset, int flags)
pr_warning("mux: No ball data available for omap2420 package\n"); pr_warning("mux: No ball data available for omap2420 package\n");
} }
return omap_mux_init(OMAP2420_CONTROL_PADCONF_MUX_PBASE, return omap_mux_init("core", OMAP_MUX_REG_8BIT | OMAP_MUX_GPIO_IN_MODE3,
OMAP2420_CONTROL_PADCONF_MUX_PBASE,
OMAP2420_CONTROL_PADCONF_MUX_SIZE, OMAP2420_CONTROL_PADCONF_MUX_SIZE,
omap2420_muxmodes, NULL, board_subset, omap2420_muxmodes, NULL, board_subset,
package_balls); package_balls);
......
...@@ -784,7 +784,8 @@ int __init omap2430_mux_init(struct omap_board_mux *board_subset, int flags) ...@@ -784,7 +784,8 @@ int __init omap2430_mux_init(struct omap_board_mux *board_subset, int flags)
pr_warning("mux: No ball data available for omap2420 package\n"); pr_warning("mux: No ball data available for omap2420 package\n");
} }
return omap_mux_init(OMAP2430_CONTROL_PADCONF_MUX_PBASE, return omap_mux_init("core", OMAP_MUX_REG_8BIT | OMAP_MUX_GPIO_IN_MODE3,
OMAP2430_CONTROL_PADCONF_MUX_PBASE,
OMAP2430_CONTROL_PADCONF_MUX_SIZE, OMAP2430_CONTROL_PADCONF_MUX_SIZE,
omap2430_muxmodes, NULL, board_subset, omap2430_muxmodes, NULL, board_subset,
package_balls); package_balls);
......
...@@ -2053,7 +2053,8 @@ int __init omap3_mux_init(struct omap_board_mux *board_subset, int flags) ...@@ -2053,7 +2053,8 @@ int __init omap3_mux_init(struct omap_board_mux *board_subset, int flags)
return -EINVAL; return -EINVAL;
} }
return omap_mux_init(OMAP3_CONTROL_PADCONF_MUX_PBASE, return omap_mux_init("core", 0,
OMAP3_CONTROL_PADCONF_MUX_PBASE,
OMAP3_CONTROL_PADCONF_MUX_SIZE, OMAP3_CONTROL_PADCONF_MUX_SIZE,
omap3_muxmodes, package_subset, board_subset, omap3_muxmodes, package_subset, board_subset,
package_balls); package_balls);
......
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