ARM :OMAP2+: UART: Remove some of uart default pads
Subsystems (3)
PATCH RESEND 1/1 ARM :OMAP2+: UART: Remove some of uart default pads
From: "Govindraj.R" <[email protected]>
The following commit:
(7496ba3 ARM: OMAP2+: UART: Add default mux for all uarts) added default pads for all uarts. But not all boards tend to use all uarts and most of unused uart pins are muxed for other purpose. This commit breaks the modules which where trying to use unused uart pins on their boards.
So remove all default pads except uart1/3 as most boards tend to use either uart1/3 as console port and use only tx/rx lines, declare only those pads for uart1/3.
If any boards tend to use any other uart other uart1/3 the mux data should to passed from board file and init individual uart port using omap_serial_init_port api.
These pads are needed not only for muxing but are also used to specify pad wakeup capability for console uart, prior to commit specified we used to do raw_write to mux pin to enable wakeup capability to uart1/2/3 now with runtime changes we are using the hwmod/mux framework.
---
Based on Linux 3.3
Tested on Beagle XM and Zoom3 board.
arch/arm/mach-omap2/serial.c | 78 ------------------------------------------ 1 files changed, 0 insertions(+), 78 deletions(-)
arch/arm/mach-omap2/serial.c +0 -78
@@ -124,14 +124,6 @@ static void omap_uart_set_smartidle(struct platform_device *pdev) {}#ifdef CONFIG_OMAP_MUX static struct omap_device_pad default_uart1_pads[]__initdata = { { - .name ="uart1_cts.uart1_cts" , - .enable =OMAP_PIN_INPUT_PULLUP |OMAP_MUX_MODE0 , - }, - { - .name ="uart1_rts.uart1_rts" , - .enable =OMAP_PIN_OUTPUT |OMAP_MUX_MODE0 , - }, - { .name ="uart1_tx.uart1_tx" , .enable =OMAP_PIN_OUTPUT |OMAP_MUX_MODE0 , },
@@ -143,37 +135,8 @@ static struct omap_device_pad default_uart1_pads[] __initdata = { }, }; -static struct omap_device_pad default_uart2_pads[]__initdata = { - { - .name ="uart2_cts.uart2_cts" , - .enable =OMAP_PIN_INPUT_PULLUP |OMAP_MUX_MODE0 , - }, - { - .name ="uart2_rts.uart2_rts" , - .enable =OMAP_PIN_OUTPUT |OMAP_MUX_MODE0 , - }, - { - .name ="uart2_tx.uart2_tx" , - .enable =OMAP_PIN_OUTPUT |OMAP_MUX_MODE0 , - }, - { - .name ="uart2_rx.uart2_rx" , - .flags =OMAP_DEVICE_PAD_REMUX |OMAP_DEVICE_PAD_WAKEUP , - .enable =OMAP_PIN_INPUT_PULLUP |OMAP_MUX_MODE0 , - .idle =OMAP_PIN_INPUT_PULLUP |OMAP_MUX_MODE0 , - }, -}; -static struct omap_device_pad default_uart3_pads[]__initdata = { { - .name ="uart3_cts_rctx.uart3_cts_rctx" , - .enable =OMAP_PIN_INPUT_PULLUP |OMAP_MUX_MODE0 , - }, - { - .name ="uart3_rts_sd.uart3_rts_sd" , - .enable =OMAP_PIN_OUTPUT |OMAP_MUX_MODE0 , - }, - { .name ="uart3_tx_irtx.uart3_tx_irtx" , .enable =OMAP_PIN_OUTPUT |OMAP_MUX_MODE0 , },
@@ -185,32 +148,6 @@ static struct omap_device_pad default_uart3_pads[] __initdata = { }, }; -static struct omap_device_pad default_omap36xx_uart4_pads[]__initdata = { - { - .name ="gpmc_wait2.uart4_tx" , - .enable =OMAP_PIN_OUTPUT |OMAP_MUX_MODE0 , - }, - { - .name ="gpmc_wait3.uart4_rx" , - .flags =OMAP_DEVICE_PAD_REMUX |OMAP_DEVICE_PAD_WAKEUP , - .enable =OMAP_PIN_INPUT |OMAP_MUX_MODE2 , - .idle =OMAP_PIN_INPUT |OMAP_MUX_MODE2 , - }, -}; - -static struct omap_device_pad default_omap4_uart4_pads[]__initdata = { - { - .name ="uart4_tx.uart4_tx" , - .enable =OMAP_PIN_OUTPUT |OMAP_MUX_MODE0 , - }, - { - .name ="uart4_rx.uart4_rx" , - .flags =OMAP_DEVICE_PAD_REMUX |OMAP_DEVICE_PAD_WAKEUP , - .enable =OMAP_PIN_INPUT |OMAP_MUX_MODE0 , - .idle =OMAP_PIN_INPUT |OMAP_MUX_MODE0 , - }, -}; -static void omap_serial_fill_default_pads (struct omap_board_data *bdata) {switch (bdata->id) {
@@ -218,25 +155,10 @@ static void omap_serial_fill_default_pads(struct omap_board_data *bdata) bdata->pads = default_uart1_pads; bdata->pads_cnt =ARRAY_SIZE (default_uart1_pads);break ; -case 1 : - bdata->pads = default_uart2_pads; - bdata->pads_cnt =ARRAY_SIZE (default_uart2_pads); -break ;case 2 : bdata->pads = default_uart3_pads; bdata->pads_cnt =ARRAY_SIZE (default_uart3_pads);break ; -case 3 : -if (cpu_is_omap44xx ()) { - bdata->pads = default_omap4_uart4_pads; - bdata->pads_cnt = -ARRAY_SIZE (default_omap4_uart4_pads); - }else if (cpu_is_omap3630 ()) { - bdata->pads = default_omap36xx_uart4_pads; - bdata->pads_cnt = -ARRAY_SIZE (default_omap36xx_uart4_pads); - } -break ;default :break ; }
Signature · 1 line
1.7.5.4
Tony Lindgren
maintainerPATCH RESEND 1/1 ARM :OMAP2+: UART: Remove some of uart default pads
Quoted 9 lines · Govindraj.R
From: "Govindraj.R" <[email protected]>
The following commit:
(7496ba3 ARM: OMAP2+: UART: Add default mux for all uarts) added default pads for all uarts. But not all boards tend to use all uarts and most of unused uart pins are muxed for other purpose. This commit breaks the modules which where trying to use unused uart pins on their boards.
Quoted 6 lines
So remove all default pads except uart1/3 as most boards tend to use either uart1/3 as console port and use only tx/rx lines, declare only those pads for uart1/3.
If any boards tend to use any other uart other uart1/3 the mux data should to passed from board file and init individual uart port usingomap_serial_init_portapi.
This is still wrong. We can't mux any serial pins unless specifically requested from the board-*.c files. So please do a fix to get back to v3.2 behaviour where you basically revert 7496ba3.
Tony
PATCH RESEND 1/1 ARM :OMAP2+: UART: Remove some of uart default pads
Quoted 17 lines · Tony Lindgren
Quoted 9 lines · Govindraj.R
From: "Govindraj.R" <[email protected]>
The following commit:
(7496ba3 ?ARM: OMAP2+: UART: Add default mux for all uarts) added default pads for all uarts. But not all boards tend to use all uarts and most of unused uart pins are muxed for other purpose. This commit breaks the modules which where trying to use unused uart pins on their boards.Quoted 6 lines
So remove all default pads except uart1/3 as most boards tend to use either uart1/3 as console port and use only tx/rx lines, declare only those pads for uart1/3.
If any boards tend to use any other uart other uart1/3 the mux data should to passed from board file and init individual uart port usingomap_serial_init_portapi.
Quoted 3 lines
This is still wrong. We can't mux any serial pins unless specifically requested from the board-*.c files. So please do a fix to get back to v3.2 behaviour where you basically revert 7496ba3.
How to do we fix the rx pin wakeup capability? The mux data has the info about the rx pin wakeup
Without rx pin wakeup PM will be broken.
Fix all board files with duplicated data for uart3 or uart1 having rx pin marked as wakeup capable?
Behavior in v3.2 was raw_write to all uarts rx_pin to enable wakeup enable bit.
--
Thanks,
Govindraj.R
Tony Lindgren
maintainerPATCH RESEND 1/1 ARM :OMAP2+: UART: Remove some of uart default pads
Quoted 18 lines · Raja, Govindraj
Quoted 17 lines · Tony Lindgren
Quoted 15 lines · Govindraj.R
From: "Govindraj.R" <[email protected]>
The following commit:
(7496ba3 ?ARM: OMAP2+: UART: Add default mux for all uarts) added default pads for all uarts. But not all boards tend to use all uarts and most of unused uart pins are muxed for other purpose. This commit breaks the modules which where trying to use unused uart pins on their boards.So remove all default pads except uart1/3 as most boards tend to use either uart1/3 as console port and use only tx/rx lines, declare only those pads for uart1/3.
If any boards tend to use any other uart other uart1/3 the mux data should to passed from board file and init individual uart port usingomap_serial_init_portapi.
Quoted 8 lines
Quoted 3 lines
This is still wrong. We can't mux any serial pins unless specifically requested from the board-*.c files. So please do a fix to get back to v3.2 behaviour where you basically revert 7496ba3.
How to do we fix the rx pin wakeup capability?
The mux data has the info about the rx pin wakeupWithout rx pin wakeup PM will be broken.
Let's first make things work reliably before even getting started about PM being broken.
Quoted 2 lines
Fix all board files with duplicated data for uart3 or uart1 having rx pin marked as wakeup capable?
And how do you know which pins to mux? You don't, unless you look at the schematics for all the boards.
The only safe option without looking at the schematics is to make omap_serial_init not do any muxing. If you want muxing and PM wake-up events, then use omap_serial_init_port for those ports with board specific pins.
Quoted 2 lines
Behavior in v3.2 was
raw_writeto all uartsrx_pinto enable wakeup enable bit.
Hmm I don't think any muxing was done automatically unless omap_serial_init_port was being called with pins.
Regards,
Tony
Tony Lindgren
maintainerPATCH RESEND 1/1 ARM :OMAP2+: UART: Remove some of uart default pads
Quoted 34 lines · Tony Lindgren
Quoted 18 lines · Raja, Govindraj
Quoted 17 lines · Tony Lindgren
Quoted 15 lines · Govindraj.R
From: "Govindraj.R" <[email protected]>
The following commit:
(7496ba3 ?ARM: OMAP2+: UART: Add default mux for all uarts) added default pads for all uarts. But not all boards tend to use all uarts and most of unused uart pins are muxed for other purpose. This commit breaks the modules which where trying to use unused uart pins on their boards.So remove all default pads except uart1/3 as most boards tend to use either uart1/3 as console port and use only tx/rx lines, declare only those pads for uart1/3.
If any boards tend to use any other uart other uart1/3 the mux data should to passed from board file and init individual uart port usingomap_serial_init_portapi.Quoted 8 lines
Quoted 3 lines
This is still wrong. We can't mux any serial pins unless specifically requested from the board-*.c files. So please do a fix to get back to v3.2 behaviour where you basically revert 7496ba3.
How to do we fix the rx pin wakeup capability?
The mux data has the info about the rx pin wakeupWithout rx pin wakeup PM will be broken.
Let's first make things work reliably before even getting started about PM being broken.
Quoted 2 lines
Fix all board files with duplicated data for uart3 or uart1 having rx pin marked as wakeup capable?
Quoted 7 lines
And how do you know which pins to mux? You don't, unless you look at the schematics for all the boards.
The only safe option without looking at the schematics is to make
omap_serial_initnot do any muxing. If you want muxing and PM wake-up events, then useomap_serial_init_portfor those ports with board specific pins.
Something that might be doable is to read the pin settings for the uart in question in omap_serial_init. And then bail out for that port if the rx or tx pin is not already muxed to uart in question. Only if the rx and tx pin is muxed for uart, then you can enable the wake-up events.
So basically doing remuxing in serial.c is only safe when omap_serial_init_port with mux data is being used.
Regards,
Tony
PATCH RESEND 1/1 ARM :OMAP2+: UART: Remove some of uart default pads
In reply to Tony LindgrenQuoted 23 lines · Tony Lindgren
Quoted 22 lines · Raja, Govindraj
Quoted 20 lines · Tony Lindgren
Quoted 9 lines · Govindraj.R
From: "Govindraj.R" <[email protected]>
The following commit:
(7496ba3 ?ARM: OMAP2+: UART: Add default mux for all uarts) added default pads for all uarts. But not all boards tend to use all uarts and most of unused uart pins are muxed for other purpose. This commit breaks the modules which where trying to use unused uart pins on their boards.Quoted 6 lines
So remove all default pads except uart1/3 as most boards tend to use either uart1/3 as console port and use only tx/rx lines, declare only those pads for uart1/3.
If any boards tend to use any other uart other uart1/3 the mux data should to passed from board file and init individual uart port usingomap_serial_init_portapi.This is still wrong. We can't mux any serial pins unless specifically requested from the board-*.c files. So please do a fix to get back to v3.2 behaviour where you basically revert 7496ba3.
Quoted 8 lines
Quoted 4 lines
How to do we fix the rx pin wakeup capability?
The mux data has the info about the rx pin wakeupWithout rx pin wakeup PM will be broken.
Let's first make things work reliably before even getting started about PM being broken.
okay.
Quoted 6 lines
Quoted 2 lines
Fix all board files with duplicated data for uart3 or uart1 having rx pin marked as wakeup capable?
And how do you know which pins to mux? You don't, unless you look at the schematics for all the boards.
agree even I am not sure of uarts used for console on all boards
Quoted 4 lines
The only safe option without looking at the schematics is to make
omap_serial_initnot do any muxing. If you want muxing and PM wake-up events, then useomap_serial_init_portfor those ports with board specific pins.
okay.
Quoted 6 lines
Quoted 3 lines
Behavior in v3.2 was
raw_writeto all uartsrx_pinto enable wakeup enable bit.Hmm I don't think any muxing was done automatically unless
omap_serial_init_portwas being called with pins.
Muxing was happening even if we don't call omap_serial_init_port rx pin was muxed for wakeup capability for all uart pins
omap_uart_idle_init => was populating padconf offset value for ech uart which was used in omap_uart_enable/disable_wakeup functions. This mechanism was keeping PM happening for all boards.
--
Thanks,
Govindraj.R
Tony Lindgren
maintainerPATCH RESEND 1/1 ARM :OMAP2+: UART: Remove some of uart default pads
Quoted 7 lines · Raja, Govindraj
Quoted 3 lines · Tony Lindgren
Hmm I don't think any muxing was done automatically unless
omap_serial_init_portwas being called with pins.Muxing was happening even if we don't call
omap_serial_init_portrx pin was muxed for wakeup capability for all uart pins
OK, but that was only for the wake-up muxing? That sounds risky too for some boards as the board may be using alternative uart pins instead of the default ones.
Quoted 3 lines
omap_uart_idle_init=> was populating padconf offset value for ech uart which was used in omap_uart_enable/disable_wakeup functions. This mechanism was keeping PM happening for all boards.
OK, that's safe if we also bail out for the cases where the default uart pins are not muxed to serial functionality to start with.
So to summarize, the right fix is to:
1. Only do muxing of uarts from other modes to uart mode if omap_serial_init_port is being called with the board specific mux options for the port in question.
2. Bail out early in omap_serial_init for each port that does not have it's default uart pins already muxed to uart functionality.
3. For the uart ports configured in #1 or #2 above, allow dynamic remuxing of the wake-up capability but don't touch the others.
Regards,
Tony
PATCH RESEND 1/1 ARM :OMAP2+: UART: Remove some of uart default pads
Hi Tony,
Quoted 26 lines · Tony Lindgren
Quoted 7 lines · Raja, Govindraj
Quoted 3 lines · Tony Lindgren
Hmm I don't think any muxing was done automatically unless
omap_serial_init_portwas being called with pins.Muxing was happening even if we don't call
omap_serial_init_portrx pin was muxed for wakeup capability for all uart pinsOK, but that was only for the wake-up muxing? That sounds risky too for some boards as the board may be using alternative uart pins instead of the default ones.
Quoted 3 lines
omap_uart_idle_init=> was populating padconf offset value for ech uart which was used in omap_uart_enable/disable_wakeup functions. This mechanism was keeping PM happening for all boards.OK, that's safe if we also bail out for the cases where the default uart pins are not muxed to serial functionality to start with.
So to summarize, the right fix is to:
1. Only do muxing of uarts from other modes to uart mode if ?
omap_serial_init_portis being called with the board specific ? mux options for the port in question.
Quoted 6 lines
2. Bail out early in
omap_serial_initfor each port that does not ? have it's default uart pins already muxed to uart functionality.3. For the uart ports configured in #1 or #2 above, allow dynamic ? remuxing of the wake-up capability but don't touch the others.
Thanks for the review and suggestions, here is the patch [1] to do the same.
I tested this patch on beagle-xm where uart pin mux was causing clash with usb ehci hub gpio nrest pin, now with this patch smsc hub + ethernet get enumerated.
--
Thanks,
Govindraj.R
[1]:
Quoted 1 line
From
37850b9e80fc4dac050bff5b6dbb67c245be43ccMon Sep 17 00:00:00 2001
From: "Govindraj.R" <[email protected]>
Date: Mon, 9 Apr 2012 15:16:52 +0530
Subject: [PATCH] ARM: OMAP2+: UART: Fix usage of default uart pads.
The following commit:
(7496ba3 ARM: OMAP2+: UART: Add default mux for all uarts) added default pads for all uarts. But not all boards tend to use all uarts and most of unused uart pins are muxed for other purpose. This commit breaks the modules which where trying to use unused uart pins on their boards.
So check for the availability of uart pins before filling the pads if both tx and rx are available as uart pins then use them for filling as default pads where rx pin is muxed dynamically for rx wakeup capability.
However the board file owners can use omap_serial_init_port and pass mux data part of board data for board specific use cases.
--- arch/arm/mach-omap2/mux.c | 2 +- arch/arm/mach-omap2/mux.h | 10 +++ arch/arm/mach-omap2/serial.c | 158 ++++++++++++------------------------------ 3 files changed, 56 insertions(+), 114 deletions(-)
arch/arm/mach-omap2/mux.c +0 -0
@@ -217,7 +217,7 @@ static int __init _omap_mux_get_by_name(struct
omap_mux_partition *partition,
return -ENODEV;
}
-static int __init
+int __init
omap_mux_get_by_name(const char *muxname,
struct omap_mux_partition **found_partition, struct omap_mux **found_mux)
arch/arm/mach-omap2/mux.h +0 -0
@@ -225,8 +225,18 @@ omap_hwmod_mux_init(struct omap_device_pad
*bpads, int nr_pads);
*/
void omap_hwmod_mux(struct omap_hwmod_mux_info *hmux, u8 state);
+int omap_mux_get_by_name(const char *muxname,
+ struct omap_mux_partition **found_partition,
+ struct omap_mux **found_mux);
#else
+static inline int omap_mux_get_by_name(const char *muxname,
+ struct omap_mux_partition **found_partition,
+ struct omap_mux **found_mux)
+{
+ return 0;
+}
+
static inline int omap_mux_init_gpio(int gpio, int val) {
return 0;
arch/arm/mach-omap2/serial.c +0 -0
@@ -120,127 +120,59 @@ static void omap_uart_set_smartidle(struct
platform_device *pdev) {}
#endif /* CONFIG_PM */
#ifdef CONFIG_OMAP_MUX
-static struct omap_device_pad default_uart1_pads[] __initdata = {
- {
- .name = "uart1_cts.uart1_cts",
- .enable = OMAP_PIN_INPUT_PULLUP | OMAP_MUX_MODE0,
- },
- {
- .name = "uart1_rts.uart1_rts",
- .enable = OMAP_PIN_OUTPUT | OMAP_MUX_MODE0,
- },
- {
- .name = "uart1_tx.uart1_tx",
- .enable = OMAP_PIN_OUTPUT | OMAP_MUX_MODE0,
- },
- {
- .name = "uart1_rx.uart1_rx",
- .flags = OMAP_DEVICE_PAD_REMUX | OMAP_DEVICE_PAD_WAKEUP,
- .enable = OMAP_PIN_INPUT_PULLUP | OMAP_MUX_MODE0,
- .idle = OMAP_PIN_INPUT_PULLUP | OMAP_MUX_MODE0,
- },
-};
-static struct omap_device_pad default_uart2_pads[] __initdata = {
- {
- .name = "uart2_cts.uart2_cts",
- .enable = OMAP_PIN_INPUT_PULLUP | OMAP_MUX_MODE0,
- },
- {
- .name = "uart2_rts.uart2_rts",
- .enable = OMAP_PIN_OUTPUT | OMAP_MUX_MODE0,
- },
- {
- .name = "uart2_tx.uart2_tx",
- .enable = OMAP_PIN_OUTPUT | OMAP_MUX_MODE0,
- },
- {
- .name = "uart2_rx.uart2_rx",
- .flags = OMAP_DEVICE_PAD_REMUX | OMAP_DEVICE_PAD_WAKEUP,
- .enable = OMAP_PIN_INPUT_PULLUP | OMAP_MUX_MODE0,
- .idle = OMAP_PIN_INPUT_PULLUP | OMAP_MUX_MODE0,
- },
-};
-
-static struct omap_device_pad default_uart3_pads[] __initdata = {
- {
- .name = "uart3_cts_rctx.uart3_cts_rctx",
- .enable = OMAP_PIN_INPUT_PULLUP | OMAP_MUX_MODE0,
- },
- {
- .name = "uart3_rts_sd.uart3_rts_sd",
- .enable = OMAP_PIN_OUTPUT | OMAP_MUX_MODE0,
- },
- {
- .name = "uart3_tx_irtx.uart3_tx_irtx",
- .enable = OMAP_PIN_OUTPUT | OMAP_MUX_MODE0,
- },
- {
- .name = "uart3_rx_irrx.uart3_rx_irrx",
- .flags = OMAP_DEVICE_PAD_REMUX | OMAP_DEVICE_PAD_WAKEUP,
- .enable = OMAP_PIN_INPUT | OMAP_MUX_MODE0,
- .idle = OMAP_PIN_INPUT | OMAP_MUX_MODE0,
- },
-};
+#define OMAP_UART_DEFAULT_PAD_NAME_LEN 28
+static char __initdata rx_pad_name[OMAP_UART_DEFAULT_PAD_NAME_LEN],
+ tx_pad_name[OMAP_UART_DEFAULT_PAD_NAME_LEN];
-static struct omap_device_pad default_omap36xx_uart4_pads[] __initdata = {
- {
- .name = "gpmc_wait2.uart4_tx",
- .enable = OMAP_PIN_OUTPUT | OMAP_MUX_MODE0,
- },
- {
- .name = "gpmc_wait3.uart4_rx",
- .flags = OMAP_DEVICE_PAD_REMUX | OMAP_DEVICE_PAD_WAKEUP,
- .enable = OMAP_PIN_INPUT | OMAP_MUX_MODE2,
- .idle = OMAP_PIN_INPUT | OMAP_MUX_MODE2,
- },
-};
+static void __init omap_serial_fill_default_pads(struct omap_board_data *bdata)
+{
+ struct omap_mux_partition *tx_partition = NULL, *rx_partition = NULL;
+ struct omap_mux *rx_mux = NULL, *tx_mux = NULL;
+ struct omap_device_pad default_omap_uart_pads[2];
+
+ if (bdata->id != 2) {
+ snprintf(rx_pad_name, OMAP_UART_DEFAULT_PAD_NAME_LEN,
+ "uart%d_rx.uart%d_rx", bdata->id + 1, bdata->id + 1);
+ snprintf(tx_pad_name, OMAP_UART_DEFAULT_PAD_NAME_LEN,
+ "uart%d_tx.uart%d_tx", bdata->id + 1, bdata->id + 1);
+ } else {
+ snprintf(rx_pad_name, OMAP_UART_DEFAULT_PAD_NAME_LEN,
+ "uart%d_rx_irrx.uart%d_rx_irrx", bdata->id + 1,
+ bdata->id + 1);
+ snprintf(tx_pad_name, OMAP_UART_DEFAULT_PAD_NAME_LEN,
+ "uart%d_tx_irtx.uart%d_tx_irtx", bdata->id + 1,
+ bdata->id + 1);
+ }
-static struct omap_device_pad default_omap4_uart4_pads[] __initdata = {
- {
- .name = "uart4_tx.uart4_tx",
- .enable = OMAP_PIN_OUTPUT | OMAP_MUX_MODE0,
- },
+ if (omap_mux_get_by_name(rx_pad_name, &rx_partition, &rx_mux) >= 0 &&
+ omap_mux_get_by_name(tx_pad_name, &tx_partition, &tx_mux) >= 0)
{
- .name = "uart4_rx.uart4_rx",
- .flags = OMAP_DEVICE_PAD_REMUX | OMAP_DEVICE_PAD_WAKEUP,
- .enable = OMAP_PIN_INPUT | OMAP_MUX_MODE0,
- .idle = OMAP_PIN_INPUT | OMAP_MUX_MODE0,
- },
-};
-
-static void omap_serial_fill_default_pads(struct omap_board_data *bdata) -{
- switch (bdata->id) {
- case 0:
- bdata->pads = default_uart1_pads;
- bdata->pads_cnt = ARRAY_SIZE(default_uart1_pads);
- break;
- case 1:
- bdata->pads = default_uart2_pads;
- bdata->pads_cnt = ARRAY_SIZE(default_uart2_pads);
- break;
- case 2:
- bdata->pads = default_uart3_pads;
- bdata->pads_cnt = ARRAY_SIZE(default_uart3_pads);
- break;
- case 3:
- if (cpu_is_omap44xx()) {
- bdata->pads = default_omap4_uart4_pads;
- bdata->pads_cnt =
- ARRAY_SIZE(default_omap4_uart4_pads);
- } else if (cpu_is_omap3630()) {
- bdata->pads = default_omap36xx_uart4_pads;
- bdata->pads_cnt =
- ARRAY_SIZE(default_omap36xx_uart4_pads);
+ u16 tx_mode, rx_mode;
+
+ tx_mode = omap_mux_read(tx_partition, tx_mux->reg_offset);
+ rx_mode = omap_mux_read(rx_partition, rx_mux->reg_offset);
+
+ if (!(rx_mode & 0x07) && !(tx_mode & 0x07)) {
+ default_omap_uart_pads[0].name = rx_pad_name;
+ default_omap_uart_pads[0].flags =
+ OMAP_DEVICE_PAD_REMUX | OMAP_DEVICE_PAD_WAKEUP;
+ default_omap_uart_pads[0].enable = OMAP_PIN_INPUT |
+ OMAP_MUX_MODE0;
+ default_omap_uart_pads[0].idle = OMAP_PIN_INPUT |
+ OMAP_MUX_MODE0;
+
+ default_omap_uart_pads[1].name = tx_pad_name;
+ default_omap_uart_pads[1].enable = OMAP_PIN_OUTPUT |
+ OMAP_MUX_MODE0;
+ bdata->pads = default_omap_uart_pads;
+ bdata->pads_cnt = ARRAY_SIZE(default_omap_uart_pads);
}
- break;
- default:
- break;
}
}
#else
-static void omap_serial_fill_default_pads(struct omap_board_data *bdata) {} +static void __init omap_serial_fill_default_pads(struct omap_board_data *bdata) +{}
#endif
char *cmdline_find_option(char *str)
Signature · 1 line
1.7.9
PATCH RESEND 1/1 ARM :OMAP2+: UART: Remove some of uart default pads
Quoted 5 lines
Thanks for the review and suggestions, here is the patch [1] to do the same.
I tested this patch on beagle-xm where uart pin mux was causing clash with usb ehci hub gpio nrest pin, now with this patch smsc hub + ethernet get enumerated.
Morning. I tested this patch on both next and master on the xM and it does work, however, I have some comments.
Quoted 35 lines
From
37850b9e80fc4dac050bff5b6dbb67c245be43ccMon Sep 17 00:00:00 2001
From: "Govindraj.R" <[email protected]>
Date: Mon, 9 Apr 2012 15:16:52 +0530
Subject: [PATCH] ARM: OMAP2+: UART: Fix usage of default uart pads.The following commit:
(7496ba3 ?ARM: OMAP2+: UART: Add default mux for all uarts) added default pads for all uarts. But not all boards tend to use all uarts and most of unused uart pins are muxed for other purpose. This commit breaks the modules which where trying to use unused uart pins on their boards.So check for the availability of uart pins before filling the pads if both tx and rx are available as uart pins then use them for filling as default pads where rx pin is muxed dynamically for rx wakeup capability.
However the board file owners can use
omap_serial_init_portand pass mux data part of board data for board specific use cases.Cc Felipe Balbi <[email protected]>Cc Kevin Hilman <[email protected]>Reported-by Tony Lindgren <[email protected]>Signed-off-by Govindraj.R <[email protected]>---
?arch/arm/mach-omap2/mux.c ? ?| ? ?2 +- ?arch/arm/mach-omap2/mux.h ? ?| ? 10 +++ ?arch/arm/mach-omap2/serial.c | ?158 ++++++++++++------------------------------?3 files changed, 56 insertions(+), 114 deletions(-)
arch/arm/mach-omap2/mux.c +0
-0
arch/arm/mach-omap2/mux.c static int __init _omap_mux_get_by_name(struct · line 217
Quoted 1 line
arch/arm/mach-omap2/mux.c +0
-0@@ -217,7 +217,7 @@ static int __init _omap_mux_get_by_name(struct omap_mux_partition *partition,
It seems your mailer might be eating your patches....What mailer are you using?
Quoted 187 lines
arch/arm/mach-omap2/mux.c +1
-1? ? ? ?return -ENODEV; ?} -static int __init +int __init ?omap_mux_get_by_name(const char *muxname, ? ? ? ? ? ? ? ? ? ? ? ?struct omap_mux_partition **found_partition,? ? ? ? ? ? ? ? ? ? ? ?struct
omap_mux**found_mux)arch/arm/mach-omap2/mux.h +0
-0@@ -225,8 +225,18 @@ omap_hwmod_mux_init(struct omap_device_pad *bpads, int nr_pads);?*/
?voidomap_hwmod_mux(struct omap_hwmod_mux_info *hmux, u8 state);+int omap_mux_get_by_name(const char *muxname,
+ ? ? ? ? ? ? ? ? ? ? ? ?structomap_mux_partition**found_partition,
+ ? ? ? ? ? ? ? ? ? ? ? ?structomap_mux**found_mux); ?#elsearch/arm/mach-omap2/mux.h +7
-0+static inline int omap_mux_get_by_name (const char *muxname, + ? ? ? ? ? ? ? ? ? ? ? ?struct omap_mux_partition **found_partition, + ? ? ? ? ? ? ? ? ? ? ? ?struct omap_mux **found_mux) +{ + ? ? ? return 0; +} +?static inline int
omap_mux_init_gpio(int gpio, int val)?{
? ? ? ?return 0;arch/arm/mach-omap2/serial.c +0
-0@@ -120,127 +120,59 @@ static void omap_uart_set_smartidle(struct platform_device *pdev) {}?#endif /*
CONFIG_PM*/?#ifdef
CONFIG_OMAP_MUXarch/arm/mach-omap2/serial.c +4
-73-static struct omap_device_pad default_uart1_pads[]__initdata = { - ? ? ? { - ? ? ? ? ? ? ? .name ? = "uart1_cts.uart1_cts", - ? ? ? ? ? ? ? .enable = OMAP_PIN_INPUT_PULLUP | OMAP_MUX_MODE0, - ? ? ? }, - ? ? ? { - ? ? ? ? ? ? ? .name ? = "uart1_rts.uart1_rts", - ? ? ? ? ? ? ? .enable = OMAP_PIN_OUTPUT | OMAP_MUX_MODE0, - ? ? ? }, - ? ? ? { - ? ? ? ? ? ? ? .name ? = "uart1_tx.uart1_tx", - ? ? ? ? ? ? ? .enable = OMAP_PIN_OUTPUT | OMAP_MUX_MODE0, - ? ? ? }, - ? ? ? { - ? ? ? ? ? ? ? .name ? = "uart1_rx.uart1_rx", - ? ? ? ? ? ? ? .flags ?= OMAP_DEVICE_PAD_REMUX | OMAP_DEVICE_PAD_WAKEUP, - ? ? ? ? ? ? ? .enable = OMAP_PIN_INPUT_PULLUP | OMAP_MUX_MODE0, - ? ? ? ? ? ? ? .idle ? = OMAP_PIN_INPUT_PULLUP | OMAP_MUX_MODE0, - ? ? ? }, -}; -static struct omap_device_pad default_uart2_pads[]__initdata = { - ? ? ? { - ? ? ? ? ? ? ? .name ? = "uart2_cts.uart2_cts", - ? ? ? ? ? ? ? .enable = OMAP_PIN_INPUT_PULLUP | OMAP_MUX_MODE0, - ? ? ? }, - ? ? ? { - ? ? ? ? ? ? ? .name ? = "uart2_rts.uart2_rts", - ? ? ? ? ? ? ? .enable = OMAP_PIN_OUTPUT | OMAP_MUX_MODE0, - ? ? ? }, - ? ? ? { - ? ? ? ? ? ? ? .name ? = "uart2_tx.uart2_tx", - ? ? ? ? ? ? ? .enable = OMAP_PIN_OUTPUT | OMAP_MUX_MODE0, - ? ? ? }, - ? ? ? { - ? ? ? ? ? ? ? .name ? = "uart2_rx.uart2_rx", - ? ? ? ? ? ? ? .flags ?= OMAP_DEVICE_PAD_REMUX | OMAP_DEVICE_PAD_WAKEUP, - ? ? ? ? ? ? ? .enable = OMAP_PIN_INPUT_PULLUP | OMAP_MUX_MODE0, - ? ? ? ? ? ? ? .idle ? = OMAP_PIN_INPUT_PULLUP | OMAP_MUX_MODE0, - ? ? ? }, -}; - -static struct omap_device_pad default_uart3_pads[]__initdata = { - ? ? ? { - ? ? ? ? ? ? ? .name ? = "uart3_cts_rctx.uart3_cts_rctx", - ? ? ? ? ? ? ? .enable = OMAP_PIN_INPUT_PULLUP | OMAP_MUX_MODE0, - ? ? ? }, - ? ? ? { - ? ? ? ? ? ? ? .name ? = "uart3_rts_sd.uart3_rts_sd", - ? ? ? ? ? ? ? .enable = OMAP_PIN_OUTPUT | OMAP_MUX_MODE0, - ? ? ? }, - ? ? ? { - ? ? ? ? ? ? ? .name ? = "uart3_tx_irtx.uart3_tx_irtx", - ? ? ? ? ? ? ? .enable = OMAP_PIN_OUTPUT | OMAP_MUX_MODE0, - ? ? ? }, - ? ? ? { - ? ? ? ? ? ? ? .name ? = "uart3_rx_irrx.uart3_rx_irrx", - ? ? ? ? ? ? ? .flags ?= OMAP_DEVICE_PAD_REMUX | OMAP_DEVICE_PAD_WAKEUP, - ? ? ? ? ? ? ? .enable = OMAP_PIN_INPUT | OMAP_MUX_MODE0, - ? ? ? ? ? ? ? .idle ? = OMAP_PIN_INPUT | OMAP_MUX_MODE0, - ? ? ? }, -}; +#define OMAP_UART_DEFAULT_PAD_NAME_LEN 28 +static char __initdata rx_pad_name[OMAP_UART_DEFAULT_PAD_NAME_LEN ], + ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? tx_pad_name[OMAP_UART_DEFAULT_PAD_NAME_LEN]; -static struct omap_device_pad default_omap36xx_uart4_pads[]__initdata = { - ? ? ? { - ? ? ? ? ? ? ? .name ? = "gpmc_wait2.uart4_tx", - ? ? ? ? ? ? ? .enable = OMAP_PIN_OUTPUT | OMAP_MUX_MODE0, - ? ? ? }, - ? ? ? { - ? ? ? ? ? ? ? .name ? = "gpmc_wait3.uart4_rx", - ? ? ? ? ? ? ? .flags ?= OMAP_DEVICE_PAD_REMUX | OMAP_DEVICE_PAD_WAKEUP, - ? ? ? ? ? ? ? .enable = OMAP_PIN_INPUT | OMAP_MUX_MODE2, - ? ? ? ? ? ? ? .idle ? = OMAP_PIN_INPUT | OMAP_MUX_MODE2, - ? ? ? }, -}; +static void ?__init omap_serial_fill_default_pads(struct
omap_board_data*bdata)arch/arm/mach-omap2/serial.c +20
-5+{ + ? ? ? struct omap_mux_partition *tx_partition = NULL, *rx_partition = NULL; + ? ? ? struct omap_mux *rx_mux = NULL, *tx_mux = NULL; + ? ? ? struct omap_device_pad default_omap_uart_pads[2]; + + ? ? ? if (bdata->id != 2) { + ? ? ? ? ? ? ? snprintf(rx_pad_name, OMAP_UART_DEFAULT_PAD_NAME_LEN, + ? ? ? ? ? ? ? ? ? ? ? ?"uart%d_rx.uart%d_rx", bdata->id + 1, bdata->id + 1); + ? ? ? ? ? ? ? snprintf(tx_pad_name, OMAP_UART_DEFAULT_PAD_NAME_LEN, + ? ? ? ? ? ? ? ? ? ? ? ?"uart%d_tx.uart%d_tx", bdata->id + 1, bdata->id + 1); + ? ? ? } else { + ? ? ? ? ? ? ? snprintf(rx_pad_name, OMAP_UART_DEFAULT_PAD_NAME_LEN, + ? ? ? ? ? ? ? ? ? ? ? "uart%d_rx_irrx.uart%d_rx_irrx", bdata->id + 1, + ? ? ? ? ? ? ? ? ? ? ? bdata->id + 1); + ? ? ? ? ? ? ? snprintf(tx_pad_name, OMAP_UART_DEFAULT_PAD_NAME_LEN, + ? ? ? ? ? ? ? ? ? ? ? "uart%d_tx_irtx.uart%d_tx_irtx", bdata->id + 1, + ? ? ? ? ? ? ? ? ? ? ? bdata->id + 1); + ? ? ? } -static struct omap_device_pad default_omap4_uart4_pads[]__initdata = { - ? ? ? { - ? ? ? ? ? ? ? .name ? = "uart4_tx.uart4_tx", - ? ? ? ? ? ? ? .enable = OMAP_PIN_OUTPUT | OMAP_MUX_MODE0, - ? ? ? }, + ? ? ? if (omap_mux_get_by_name(rx_pad_name, &rx_partition, &rx_mux) >= 0 && + ? ? ? ? ? ? ? omap_mux_get_by_name(tx_pad_name, &tx_partition, &tx_mux) >= 0)? ? ? ?{
- ? ? ? ? ? ? ? .name ? = "uart4_rx.uart4_rx",
- ? ? ? ? ? ? ? .flags ?=OMAP_DEVICE_PAD_REMUX|OMAP_DEVICE_PAD_WAKEUP,
- ? ? ? ? ? ? ? .enable =OMAP_PIN_INPUT|OMAP_MUX_MODE0,
- ? ? ? ? ? ? ? .idle ? =OMAP_PIN_INPUT|OMAP_MUX_MODE0,
- ? ? ? },arch/arm/mach-omap2/serial.c +8
-26-}; - -static void omap_serial_fill_default_pads (struct omap_board_data *bdata) -{ - ? ? ? switch (bdata->id) { - ? ? ? case 0: - ? ? ? ? ? ? ? bdata->pads = default_uart1_pads; - ? ? ? ? ? ? ? bdata->pads_cnt = ARRAY_SIZE(default_uart1_pads); - ? ? ? ? ? ? ? break; - ? ? ? case 1: - ? ? ? ? ? ? ? bdata->pads = default_uart2_pads; - ? ? ? ? ? ? ? bdata->pads_cnt = ARRAY_SIZE(default_uart2_pads); - ? ? ? ? ? ? ? break; - ? ? ? case 2: - ? ? ? ? ? ? ? bdata->pads = default_uart3_pads; - ? ? ? ? ? ? ? bdata->pads_cnt = ARRAY_SIZE(default_uart3_pads); - ? ? ? ? ? ? ? break; - ? ? ? case 3: - ? ? ? ? ? ? ? if (cpu_is_omap44xx()) { - ? ? ? ? ? ? ? ? ? ? ? bdata->pads = default_omap4_uart4_pads; - ? ? ? ? ? ? ? ? ? ? ? bdata->pads_cnt = - ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ARRAY_SIZE(default_omap4_uart4_pads); - ? ? ? ? ? ? ? } else if (cpu_is_omap3630()) { - ? ? ? ? ? ? ? ? ? ? ? bdata->pads = default_omap36xx_uart4_pads; - ? ? ? ? ? ? ? ? ? ? ? bdata->pads_cnt = - ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ARRAY_SIZE(default_omap36xx_uart4_pads); + ? ? ? ? ? ? ? u16 tx_mode, rx_mode; + + ? ? ? ? ? ? ? tx_mode = omap_mux_read(tx_partition, tx_mux->reg_offset); + ? ? ? ? ? ? ? rx_mode = omap_mux_read(rx_partition, rx_mux->reg_offset); + + ? ? ? ? ? ? ? if (!(rx_mode & 0x07) && !(tx_mode & 0x07)) { + ? ? ? ? ? ? ? ? ? ? ? default_omap_uart_pads[0].name = rx_pad_name; + ? ? ? ? ? ? ? ? ? ? ? default_omap_uart_pads[0].flags ?=
arch/arm/mach-omap2/serial.c
Quoted 10 lines
arch/arm/mach-omap2/serial.c +10
-0+ ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? OMAP_DEVICE_PAD_REMUX | OMAP_DEVICE_PAD_WAKEUP; + ? ? ? ? ? ? ? ? ? ? ? default_omap_uart_pads[0].enable = OMAP_PIN_INPUT | + ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? OMAP_MUX_MODE0; + ? ? ? ? ? ? ? ? ? ? ? default_omap_uart_pads[0].idle = OMAP_PIN_INPUT | + ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? OMAP_MUX_MODE0; + + ? ? ? ? ? ? ? ? ? ? ? default_omap_uart_pads[1].name = tx_pad_name; + ? ? ? ? ? ? ? ? ? ? ? default_omap_uart_pads[1].enable = OMAP_PIN_OUTPUT | + ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? OMAP_MUX_MODE0; + ? ? ? ? ? ? ? ? ? ? ? bdata->pads = default_omap_uart_pads;
You are assigning this variable to a structure on the stack.
Quoted 20 lines
+ ? ? ? ? ? ? ? ? ? ? ?
bdata->pads_cnt=ARRAY_SIZE(default_omap_uart_pads); ? ? ? ? ? ? ? ?}
- ? ? ? ? ? ? ? break;
- ? ? ? default:
- ? ? ? ? ? ? ? break;
? ? ? ?}
?}
?#elsearch/arm/mach-omap2/serial.c +2
-1-static void omap_serial_fill_default_pads (struct omap_board_data *bdata) {} +static void __init omap_serial_fill_default_pads (struct omap_board_data *bdata) +{}?#endif
?char *cmdline_find_option(char *str)
--
1.7.9
--
To unsubscribe from this list: send the line "unsubscribe linux-omap" in the body of a message to majordomo at vger.kernel.org
More majordomo info at ?http://vger.kernel.org/majordomo-info.html
Tony Lindgren
maintainerPATCH RESEND 1/1 ARM :OMAP2+: UART: Remove some of uart default pads
Quoted 9 lines · Russ Dill
Quoted 9 lines
From: "Govindraj.R" <[email protected]>
Date: Mon, 9 Apr 2012 15:16:52 +0530
Subject: [PATCH] ARM: OMAP2+: UART: Fix usage of default uart pads.(quoted diff) +1
-1-static int __init +int __init?omap_mux_get_by_name(const char *muxname,
? ? ? ? ? ? ? ? ? ? ? ?structomap_mux_partition**found_partition, ? ? ? ? ? ? ? ? ? ? ? ?structomap_mux**found_mux)
This can now be one one line:
int __init omap_mux_get_by_name(const char *muxname,
...
Quoted 12 lines
Quoted 12 lines
+ ? ? ? ? ? ? ? u16
tx_mode,rx_mode;(quoted diff) +11
-0+ + ? ? ? ? ? ? ? tx_mode = omap_mux_read(tx_partition, tx_mux->reg_offset); + ? ? ? ? ? ? ? rx_mode = omap_mux_read(rx_partition, rx_mux->reg_offset); + + ? ? ? ? ? ? ? if (!(rx_mode & 0x07) && !(tx_mode & 0x07)) { + ? ? ? ? ? ? ? ? ? ? ? default_omap_uart_pads[0].name = rx_pad_name; + ? ? ? ? ? ? ? ? ? ? ? default_omap_uart_pads[0].flags ?= + ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? OMAP_DEVICE_PAD_REMUX | OMAP_DEVICE_PAD_WAKEUP; + ? ? ? ? ? ? ? ? ? ? ? default_omap_uart_pads[0].enable = OMAP_PIN_INPUT | + ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? OMAP_MUX_MODE0; + ? ? ? ? ? ? ? ? ? ? ? default_omap_uart_pads[0].idle = OMAP_PIN_INPUT |
Quoted 10 lines
Quoted 6 lines
+ ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?
OMAP_MUX_MODE0; +
+ ? ? ? ? ? ? ? ? ? ? ? default_omap_uart_pads[1].name =tx_pad_name;
+ ? ? ? ? ? ? ? ? ? ? ? default_omap_uart_pads[1].enable =OMAP_PIN_OUTPUT|
+ ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?OMAP_MUX_MODE0;
+ ? ? ? ? ? ? ? ? ? ? ?bdata->pads=default_omap_uart_pads;You are assigning this variable to a structure on the stack.
Quoted 1 line
+ ? ? ? ? ? ? ? ? ? ? ?
bdata->pads_cnt=ARRAY_SIZE(default_omap_uart_pads);
Also, maybe make that into a separate function with comments added that we check that the default pins are muxed to uart rx and tx mode to start with. Otherwise it's a bit hard to figure out what's going on here.
Then please split it into two patches: First one removes all the unsafe muxing, then the second one enables wake-up events for the ports already in uart rx/tx mode.
Regards,
Tony