OpenRD: Enable SD/UART selection for serial port 1
Subsystems (2)
PATCH v2 1/1 OpenRD: Enable SD/UART selection for serial port 1
This patch enables user to use serial port 1 of the OpenRD device for SDIO or UART(RS232/RS485). The selection can be done through kernel parameter.
By default the port would be used for SDIO. To select RS232 or RS485 mode, pass string "uart=232" or "uart=485" respectively in the kernel parameters. "uart=485" is ignored on OpenRD-Base as it doesn't have RS485 port.
--- arch/arm/mach-kirkwood/openrd-setup.c | 92 ++++++++++++++++++++++++++++++++- 1 files changed, 91 insertions(+), 1 deletions(-)
arch/arm/mach-kirkwood/openrd-setup.c +91 -1
@@ -19,6 +19,7 @@#include <asm/mach-types.h> #include <asm/mach/arch.h> #include <mach/kirkwood.h> +#include <mach/gpio.h> #include <plat/mvsdio.h> #include "common.h" #include "mpp.h"
@@ -57,7 +58,15 @@ static struct mvsdio_platform_data openrd_mvsdio_data = { };static unsigned int openrd_mpp_config[]__initdata = { +MPP12_SD_CLK , +MPP13_SD_CMD , +MPP14_SD_D0 , +MPP15_SD_D1 , +MPP16_SD_D2 , +MPP17_SD_D3 , +MPP28_GPIO ,MPP29_GPIO , +MPP34_GPIO ,0 };
@@ -67,6 +76,71 @@ static struct i2c_board_info i2c_board_info[] __initdata = { }, }; +static int __initdata uart1; + +static int __init sd_uart_selection (char *str) +{ +/* Default is SD. Change if required, for UART */ +if (!str) +return 0 ; + +if (!strncmp (str,"232" ,3 )) { + uart1 =232 ; + }else if (!strncmp (str,"485" ,3 )) { +/* OpenRD-Base doesn't have RS485. Treat is as an +* unknown argument & just have default setting - +* which is SD */ +if (machine_is_openrd_base ()) +return 1 ; + + uart1 =485 ; + } +return 1 ; +} +/* Parse boot_command_line string uart=232/485 */ +__setup ("uart=" , sd_uart_selection); + +static int __init uart1_mpp_config (void ) +{ +/* Configure MPP for UART1 */ +unsigned int uart1_mpp_config[] = { +MPP13_UART1_TXD , +MPP14_UART1_RXD , +0 + }; + +kirkwood_mpp_conf (uart1_mpp_config); + +if (gpio_request (34 ,"SD_UART1_SEL" )) { +printk (KERN_ERR "GPIO request failed for SD/UART1 selection" +", gpio: 34\n" ); +return -EIO ; + } + +if (gpio_request (28 ,"RS232_RS485_SEL" )) { +printk (KERN_ERR "GPIO request failed for RS232/RS485 selection" +", gpio# 28\n" ); +gpio_free (34 ); +return -EIO ; + } + +/* Select UART1 +* Pin # 34: 0 => UART1, 1 => SD */ +gpio_direction_output (34 ,0 ); + +/* Select RS232 OR RS485 +* Pin # 28: 0 => RS232, 1 => RS485 */ +if (uart1 ==232 ) +gpio_direction_output (28 ,0 ); +else +gpio_direction_output (28 ,1 ); + +gpio_free (34 ); +gpio_free (28 ); + +return 0 ; +} +static void __init openrd_init (void ) {/*
@@ -90,7 +164,6 @@ static void __init openrd_init(void)kirkwood_ge01_init (&openrd_ge01_data);kirkwood_sata_init (&openrd_sata_data); -kirkwood_sdio_init (&openrd_mvsdio_data);kirkwood_i2c_init ();
@@ -99,6 +172,23 @@ static void __init openrd_init(void) ARRAY_SIZE(i2c_board_info));kirkwood_audio_init (); } + +if (!uart1) { +/* Select SD +* Pin # 34: 0 => UART1, 1 => SD */ +if (gpio_request (34 ,"SD_UART1_SEL" )) { +printk (KERN_ERR "GPIO request failed for SD/UART1 " +"selection, gpio: 34\n" ); + }else { + +gpio_direction_output (34 ,1 ); +gpio_free (34 ); +kirkwood_sdio_init (&openrd_mvsdio_data); + } + }else { +if (!uart1_mpp_config ()) +kirkwood_uart1_init (); + } }static int __init openrd_pci_init (void )
Signature · 1 line
1.6.6.1
PATCH v2 1/1 OpenRD: Enable SD/UART selection for serial port 1
Hi,
Comments inline.
Quoted 53 lines · Tanmay Upadhyay
This patch enables user to use serial port 1 of the OpenRD device for SDIO or UART(RS232/RS485). The selection can be done through kernel parameter.
By default the port would be used for SDIO. To select RS232 or RS485 mode, pass string "uart=232" or "uart=485" respectively in the kernel parameters. "uart=485" is ignored on OpenRD-Base as it doesn't have RS485 port.
Signed-off-by Tanmay Upadhyay <[email protected]>--- arch/arm/mach-kirkwood/openrd-setup.c | 92 ++++++++++++++++++++++++++++++++- 1 files changed, 91 insertions(+), 1 deletions(-)arch/arm/mach-kirkwood/openrd-setup.c +17
-0@@ -19,6 +19,7 @@#include <asm/mach-types.h> #include <asm/mach/arch.h> #include <mach/kirkwood.h> +#include <mach/gpio.h> #include <plat/mvsdio.h> #include "common.h" #include "mpp.h" @@ -57,7 +58,15 @@ static struct mvsdio_platform_data openrd_mvsdio_data = { };static unsigned int openrd_mpp_config[]__initdata = { +MPP12_SD_CLK , +MPP13_SD_CMD , +MPP14_SD_D0 , +MPP15_SD_D1 , +MPP16_SD_D2 , +MPP17_SD_D3 , +MPP28_GPIO ,MPP29_GPIO , +MPP34_GPIO ,0 };@@ -67,6 +76,71 @@ static struct i2c_board_info i2c_board_info[] __initdata = { }, }; +static int __initdata uart1; + +static int __init sd_uart_selection (char *str) +{ +/* Default is SD. Change if required, for UART */ +if (!str) +return 0 ; +
arch/arm/mach-kirkwood/openrd-setup.c static struct i2c_board_info i2c_board_info[] __initdata = { · line 96
Quoted 10 lines
arch/arm/mach-kirkwood/openrd-setup.c +9
-0+if (!strncmp (str,"232" ,3 )) { + uart1 =232 ; + }else if (!strncmp (str,"485" ,3 )) { +/* OpenRD-Base doesn't have RS485. Treat is as an +* unknown argument & just have default setting - +* which is SD */ +if (machine_is_openrd_base ()) +return 1 ; +
uart1 = -ENODEV;
return 1;
arch/arm/mach-kirkwood/openrd-setup.c static struct i2c_board_info i2c_board_info[] __initdata = {
Quoted 4 lines
arch/arm/mach-kirkwood/openrd-setup.c +3
-0+ uart1 =485 ; + } +return 1 ;
uart1 = -EINVAL;
return 1;
arch/arm/mach-kirkwood/openrd-setup.c static struct i2c_board_info i2c_board_info[] __initdata = {
Quoted 5 lines
arch/arm/mach-kirkwood/openrd-setup.c +4
-0+} +/* Parse boot_command_line string uart=232/485 */ +__setup ("uart=" , sd_uart_selection); +
'kirkwood_init_uart1' instead maybe, only going to annoy someone otherwise I'm guessing.
Quoted 61 lines
arch/arm/mach-kirkwood/openrd-setup.c +41
-0+static int __init uart1_mpp_config (void ) +{ +/* Configure MPP for UART1 */ +unsigned int uart1_mpp_config[] = { +MPP13_UART1_TXD , +MPP14_UART1_RXD , +0 + }; + +kirkwood_mpp_conf (uart1_mpp_config); + +if (gpio_request (34 ,"SD_UART1_SEL" )) { +printk (KERN_ERR "GPIO request failed for SD/UART1 selection" +", gpio: 34\n" ); +return -EIO ; + } + +if (gpio_request (28 ,"RS232_RS485_SEL" )) { +printk (KERN_ERR "GPIO request failed for RS232/RS485 selection" +", gpio# 28\n" ); +gpio_free (34 ); +return -EIO ; + } + +/* Select UART1 +* Pin # 34: 0 => UART1, 1 => SD */ +gpio_direction_output (34 ,0 ); + +/* Select RS232 OR RS485 +* Pin # 28: 0 => RS232, 1 => RS485 */ +if (uart1 ==232 ) +gpio_direction_output (28 ,0 ); +else +gpio_direction_output (28 ,1 ); + +gpio_free (34 ); +gpio_free (28 ); + +return 0 ; +} +static void
__initopenrd_init(void)
{arch/arm/mach-kirkwood/openrd-setup.c +5
-1/* @@ -90,7 +164,6 @@ static void __init openrd_init(void)kirkwood_ge01_init (&openrd_ge01_data);kirkwood_sata_init (&openrd_sata_data); -kirkwood_sdio_init (&openrd_mvsdio_data);kirkwood_i2c_init ();@@ -99,6 +172,23 @@ static void __init openrd_init(void) ARRAY_SIZE(i2c_board_info));kirkwood_audio_init (); } + +if (!uart1) { +/* Select SD +* Pin # 34: 0 => UART1, 1 => SD */ +if (gpio_request (34 ,"SD_UART1_SEL" )) {
arch/arm/mach-kirkwood/openrd-setup.c static void __init openrd_init(void) · line 189
Quoted 10 lines
arch/arm/mach-kirkwood/openrd-setup.c +9
-0+printk (KERN_ERR "GPIO request failed for SD/UART1 " +"selection, gpio: 34\n" ); + }else { + +gpio_direction_output (34 ,1 ); +gpio_free (34 ); +kirkwood_sdio_init (&openrd_mvsdio_data); + } + }else {
} else if (uart1 < 0) {
prink(KERN_WARNING, "<grumble>, uart1 init issue, "
"defaulting to SD: %d\n", uart1);
} else {Quoted 8 lines
arch/arm/mach-kirkwood/openrd-setup.c +3
-0+if (!uart1_mpp_config ()) +kirkwood_uart1_init (); + } }static int
__initopenrd_pci_init(void)Signature · 1 line
1.6.6.1
Afterwards, remember to run it through ./scripts/checkpatch.pl.
Cheers
Signature · 2 lines
Alexander Clouter .sigmonster says: Old MacDonald had an agricultural real estate tax abatement.
PATCH v2 1/1 OpenRD: Enable SD/UART selection for serial port 1
Hi,
Just a quick amendment;
Quoted 43 lines · Alexander Clouter
Quoted 41 lines · Tanmay Upadhyay
This patch enables user to use serial port 1 of the OpenRD device for SDIO or UART(RS232/RS485). The selection can be done through kernel parameter.
By default the port would be used for SDIO. To select RS232 or RS485 mode, pass string "uart=232" or "uart=485" respectively in the kernel parameters. "uart=485" is ignored on OpenRD-Base as it doesn't have RS485 port.
Signed-off-by Tanmay Upadhyay <[email protected]>--- arch/arm/mach-kirkwood/openrd-setup.c | 92 ++++++++++++++++++++++++++++++++- 1 files changed, 91 insertions(+), 1 deletions(-)arch/arm/mach-kirkwood/openrd-setup.c +9
-0@@ -19,6 +19,7 @@#include <asm/mach-types.h> #include <asm/mach/arch.h> #include <mach/kirkwood.h> +#include <mach/gpio.h> #include <plat/mvsdio.h> #include "common.h" #include "mpp.h" @@ -57,7 +58,15 @@ static struct mvsdio_platform_data openrd_mvsdio_data = { };static unsigned int openrd_mpp_config[]__initdata = { +MPP12_SD_CLK , +MPP13_SD_CMD , +MPP14_SD_D0 , +MPP15_SD_D1 , +MPP16_SD_D2 , +MPP17_SD_D3 , +MPP28_GPIO ,MPP29_GPIO , +MPP34_GPIO ,0 };
Quoted 6 lines
arch/arm/mach-kirkwood/openrd-setup.c static struct i2c_board_info i2c_board_info[] __initdata = { · line 79
Quoted 5 lines
arch/arm/mach-kirkwood/openrd-setup.c +1
-0@@ -67,6 +76,71 @@ static struct i2c_board_info i2c_board_info[] __initdata = { }, }; +static int __initdata uart1;
static int __initdata uart1 = -EINVAL;
Quoted 20 lines
Quoted 7 lines
arch/arm/mach-kirkwood/openrd-setup.c +7
-0+ +static int __init sd_uart_selection (char *str) +{ +/* Default is SD. Change if required, for UART */ +if (!str) +return 0 ; +arch/arm/mach-kirkwood/openrd-setup.c static struct i2c_board_info i2c_board_info[] __initdata = {
Quoted 10 lines
arch/arm/mach-kirkwood/openrd-setup.c +9
-0+if (!strncmp (str,"232" ,3 )) { + uart1 =232 ; + }else if (!strncmp (str,"485" ,3 )) { +/* OpenRD-Base doesn't have RS485. Treat is as an +* unknown argument & just have default setting - +* which is SD */ +if (machine_is_openrd_base ()) +return 1 ; +uart1 =
-ENODEV;
return 1;
Quoted 7 lines
arch/arm/mach-kirkwood/openrd-setup.c static struct i2c_board_info i2c_board_info[] __initdata = {
Quoted 4 lines
arch/arm/mach-kirkwood/openrd-setup.c +3
-0+ uart1 =485 ; + } +return 1 ;uart1 =
-EINVAL;
return 1;
Drop this suggested amendment.
Cheers
Signature · 2 lines
Alexander Clouter .sigmonster says: What I need is a MATURE RELATIONSHIP with a FLOPPY DISK ...
PATCH v2 1/1 OpenRD: Enable SD/UART selection for serial port 1
Quoted 89 lines · Alexander Clouter
Hi,
Just a quick amendment;
Quoted 42 lines · Alexander Clouter
Quoted 40 lines · Tanmay Upadhyay
This patch enables user to use serial port 1 of the OpenRD device for SDIO or UART(RS232/RS485). The selection can be done through kernel parameter.
By default the port would be used for SDIO. To select RS232 or RS485 mode, pass string "uart=232" or "uart=485" respectively in the kernel parameters. "uart=485" is ignored on OpenRD-Base as it doesn't have RS485 port.
Signed-off-by Tanmay Upadhyay<[email protected]>--- arch/arm/mach-kirkwood/openrd-setup.c | 92 ++++++++++++++++++++++++++++++++- 1 files changed, 91 insertions(+), 1 deletions(-)arch/arm/mach-kirkwood/openrd-setup.c +9
-0@@ -19,6 +19,7 @@#include <asm/mach-types.h> #include <asm/mach/arch.h> #include <mach/kirkwood.h> +#include <mach/gpio.h> #include <plat/mvsdio.h> #include "common.h" #include "mpp.h" @@ -57,7 +58,15 @@ static struct mvsdio_platform_data openrd_mvsdio_data = { };static unsigned int openrd_mpp_config[]__initdata = { +MPP12_SD_CLK , +MPP13_SD_CMD , +MPP14_SD_D0 , +MPP15_SD_D1 , +MPP16_SD_D2 , +MPP17_SD_D3 , +MPP28_GPIO ,MPP29_GPIO , +MPP34_GPIO ,0 };Quoted 7 lines
arch/arm/mach-kirkwood/openrd-setup.c static struct i2c_board_info i2c_board_info[] __initdata = { · line 80
Quoted 6 lines
arch/arm/mach-kirkwood/openrd-setup.c +1
-0@@ -67,6 +76,71 @@ static struct i2c_board_info i2c_board_info[] __initdata = { }, }; +static int __initdata uart1;static int
__initdatauart1 =-EINVAL;Quoted 22 lines
Quoted 8 lines
arch/arm/mach-kirkwood/openrd-setup.c +8
-0+ +static int __init sd_uart_selection (char *str) +{ +/* Default is SD. Change if required, for UART */ +if (!str) +return 0 ; + +if (!strncmp (str,"232" ,3 )) {arch/arm/mach-kirkwood/openrd-setup.c static struct i2c_board_info i2c_board_info[] __initdata = {
Quoted 10 lines
arch/arm/mach-kirkwood/openrd-setup.c +8
-0+ uart1 =232 ; + }else if (!strncmp (str,"485" ,3 )) { +/* OpenRD-Base doesn't have RS485. Treat is as an +* unknown argument& just have default setting - +* which is SD */ +if (machine_is_openrd_base ()) +return 1 ; +uart1 =
-ENODEV;
return 1;Quoted 9 lines
arch/arm/mach-kirkwood/openrd-setup.c static struct i2c_board_info i2c_board_info[] __initdata = { · line 98
Quoted 5 lines
arch/arm/mach-kirkwood/openrd-setup.c +3
-0+ uart1 =485 ; + } +return 1 ;uart1 =
-EINVAL;
return 1;
Quoted 5 lines
Drop this suggested amendment.
Cheers
Intention here is to provide SD support by default. It will be switched to UART mode only if someone asks to do so via kernel parameter. If someone doesn't give OR gives improper kernel parameter, he/she won't get UART1. It will simply fall-back to the default setting - which is SD support.
Does this make sense? Please suggest.
Thanks,
Tanmay
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20100810/d3ec9071/attachment-0001.html>
PATCH v2 1/1 OpenRD: Enable SD/UART selection for serial port 1
Hi,
Quoted 7 lines · Tanmay Upadhyay
Intention here is to provide SD support by default. It will be switched to UART mode only if someone asks to do so via kernel parameter. If someone doesn't give OR gives improper kernel parameter, he/she won't get UART1. It will simply fall-back to the default setting - which is SD support.
My mis-type, I forgot to put a 'kirkwood_sdio_init(&openrd_mvsdio_data);' after my added printk().
Cheers
Signature · 3 lines
Alexander Clouter
.sigmonster says: BOFH excuse #367:
Webmasters kidnapped by evil cult.PATCH v2 1/1 OpenRD: Enable SD/UART selection for serial port 1
Quoted 11 lines · Alexander Clouter
Hi,
Quoted 7 lines · Tanmay Upadhyay
Intention here is to provide SD support by default. It will be switched to UART mode only if someone asks to do so via kernel parameter. If someone doesn't give OR gives improper kernel parameter, he/she won't get UART1. It will simply fall-back to the default setting - which is SD support.
Quoted 6 lines
My mis-type, I forgot to put a '
kirkwood_sdio_init(&openrd_mvsdio_data);' after my addedprintk().Cheers
If I understood correctly, intention behind this is to inform user that he/she made a mistake while passing the kernel parameters. Is this correct?
Thanks,
Tanmay
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20100810/5e2bfe4c/attachment-0001.html>
PATCH v2 1/1 OpenRD: Enable SD/UART selection for serial port 1
Hi,
Quoted 11 lines · Tanmay Upadhyay
Quoted 9 lines · Alexander Clouter
Quoted 5 lines · Tanmay Upadhyay
Intention here is to provide SD support by default. It will be switched to UART mode only if someone asks to do so via kernel parameter. If someone doesn't give OR gives improper kernel parameter, he/she won't get UART1. It will simply fall-back to the default setting - which is SD support.
Quoted 7 lines
Quoted 3 lines
My mis-type, I forgot to put a '
kirkwood_sdio_init(&openrd_mvsdio_data);' after my addedprintk().If I understood correctly, intention behind this is to inform user that he/she made a mistake while passing the kernel parameters. Is this correct?
Exactly, and there is no harm turning on the SD slot rather than UART1 at the same time.
Cheers
Signature · 3 lines
Alexander Clouter
.sigmonster says: tax office, n.:
Den of inequity.PATCH v2 1/1 OpenRD: Enable SD/UART selection for serial port 1
Quoted 24 lines · Alexander Clouter
Hi,
Quoted 11 lines · Tanmay Upadhyay
Quoted 9 lines · Alexander Clouter
Quoted 6 lines · Tanmay Upadhyay
Intention here is to provide SD support by default. It will be switched to UART mode only if someone asks to do so via kernel parameter. If someone doesn't give OR gives improper kernel parameter, he/she won't get UART1. It will simply fall-back to the default setting - which is SD support.
Quoted 9 lines
Quoted 4 lines
My mis-type, I forgot to put a '
kirkwood_sdio_init(&openrd_mvsdio_data);' after my addedprintk().If I understood correctly, intention behind this is to inform user that he/she made a mistake while passing the kernel parameters. Is this correct?
Quoted 6 lines
Exactly, and there is no harm turning on the SD slot rather than UART1 at the same time.
Cheers
Sent version 3 to the list.
-- Tanmay
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20100811/844218f3/attachment-0001.html>