* [PATCH] omap: mux: Add api to retrieve padconf offset based on muxname
@ 2010-06-14 14:13 Govindraj.R
2010-07-01 12:15 ` Tony Lindgren
0 siblings, 1 reply; 2+ messages in thread
From: Govindraj.R @ 2010-06-14 14:13 UTC (permalink / raw)
To: linux-omap; +Cc: Tony Lindgren
Adds a padconf offset retrieval api which will
get us the padconf offset based on muxname provided
which can be later used with omap_ctrl_writew,
omap_ctrl_readw calls for remuxing signals.
Cc: Tony Lindgren <tony@atomide.com>
Signed-off-by: Govindraj.R <govindraj.raja@ti.com>
---
Patch is based on earlier discussion with Tony
http://marc.info/?l=linux-omap&m=127609369220618&w=2
arch/arm/mach-omap2/mux.c | 17 +++++++++++++++++
arch/arm/mach-omap2/mux.h | 6 ++++++
2 files changed, 23 insertions(+), 0 deletions(-)
diff --git a/arch/arm/mach-omap2/mux.c b/arch/arm/mach-omap2/mux.c
index 8b3d269..afe45ce 100644
--- a/arch/arm/mach-omap2/mux.c
+++ b/arch/arm/mach-omap2/mux.c
@@ -882,6 +882,23 @@ free:
#endif /* CONFIG_OMAP_MUX */
+u16 omap_mux_request_signal(char *muxname)
+{
+ struct omap_mux_entry *e;
+ u16 offset = -EINVAL;
+
+ list_for_each_entry(e, &muxmodes, node) {
+ struct omap_mux *m = &e->mux;
+ char *m0_entry = m->muxnames[0];
+
+ if (!strcmp(muxname, m0_entry)) {
+ offset = m->reg_offset + OMAP_MUX_BASE_OFFSET;
+ break;
+ }
+ }
+ return offset;
+}
+
static u16 omap_mux_get_by_gpio(int gpio)
{
struct omap_mux_entry *e;
diff --git a/arch/arm/mach-omap2/mux.h b/arch/arm/mach-omap2/mux.h
index 480abc5..dc5e121 100644
--- a/arch/arm/mach-omap2/mux.h
+++ b/arch/arm/mach-omap2/mux.h
@@ -132,6 +132,12 @@ static inline int omap_mux_init_signal(char *muxname, int val)
#endif
/**
+ * omap_mux_request_signal - get mux register offset based on mux name
+ * @muxname: Mux name in mode0_name.signal_name format
+ */
+u16 omap_mux_request_signal(char *muxname);
+
+/**
* omap_mux_get_gpio() - get mux register value based on GPIO number
* @gpio: GPIO number
*
--
1.6.3.3
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] omap: mux: Add api to retrieve padconf offset based on muxname
2010-06-14 14:13 [PATCH] omap: mux: Add api to retrieve padconf offset based on muxname Govindraj.R
@ 2010-07-01 12:15 ` Tony Lindgren
0 siblings, 0 replies; 2+ messages in thread
From: Tony Lindgren @ 2010-07-01 12:15 UTC (permalink / raw)
To: Govindraj.R; +Cc: linux-omap
* Govindraj.R <govindraj.raja@ti.com> [100614 17:07]:
> Adds a padconf offset retrieval api which will
> get us the padconf offset based on muxname provided
> which can be later used with omap_ctrl_writew,
> omap_ctrl_readw calls for remuxing signals.
>
> Cc: Tony Lindgren <tony@atomide.com>
> Signed-off-by: Govindraj.R <govindraj.raja@ti.com>
> ---
> Patch is based on earlier discussion with Tony
> http://marc.info/?l=linux-omap&m=127609369220618&w=2
>
> arch/arm/mach-omap2/mux.c | 17 +++++++++++++++++
> arch/arm/mach-omap2/mux.h | 6 ++++++
> 2 files changed, 23 insertions(+), 0 deletions(-)
>
> diff --git a/arch/arm/mach-omap2/mux.c b/arch/arm/mach-omap2/mux.c
> index 8b3d269..afe45ce 100644
> --- a/arch/arm/mach-omap2/mux.c
> +++ b/arch/arm/mach-omap2/mux.c
> @@ -882,6 +882,23 @@ free:
>
> #endif /* CONFIG_OMAP_MUX */
>
> +u16 omap_mux_request_signal(char *muxname)
> +{
> + struct omap_mux_entry *e;
> + u16 offset = -EINVAL;
> +
> + list_for_each_entry(e, &muxmodes, node) {
> + struct omap_mux *m = &e->mux;
> + char *m0_entry = m->muxnames[0];
> +
> + if (!strcmp(muxname, m0_entry)) {
> + offset = m->reg_offset + OMAP_MUX_BASE_OFFSET;
> + break;
> + }
> + }
> + return offset;
> +}
You need to consider few more things..
Note that omap_mux_late_init frees the memory for all pins except
for GPIO pins unless CONFIG_DEBUG_FS is set.
This means that omap_mux_request_signal needs to be __init function
and accessible only in the board-*.c files. Then the board-*.c file
can then implement it's pin muxing functions and pass the function
pointers along to a driver via platform data as needed. Then the
driver can call the board specific function if implemented.
Then you need to also consider full pin names such as
mcbsp2_clkx.gpio_12. Relying on the mode0 name is not enough
as there can be multiple pinouts. Also from user point of view
it is confusing to have to look up the mode0 name when
omap_mux_request_signal can do the work.
Then you probably want to add a comment about using omap_mux_read/write
on the returned offset to avoid accidentally modifying other
registers :)
Anyways, please also make sure you code does the right thing
with CONFIG_OMAP_MUX set and not set, and CONFIG_DEBUG_FS
set and not set.
Regards,
Tony
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2010-07-01 12:15 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-06-14 14:13 [PATCH] omap: mux: Add api to retrieve padconf offset based on muxname Govindraj.R
2010-07-01 12:15 ` Tony Lindgren
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.