* Re: [PATCH 0/6] SA11x0 serial updates
[not found] ` <20160829112540.GF1041@n2100.armlinux.org.uk>
@ 2016-08-29 12:05 ` Russell King - ARM Linux
2016-08-29 12:05 ` [PATCH 1/6] serial: sa1100: add support for mctrl gpios Russell King
` (6 more replies)
0 siblings, 7 replies; 12+ messages in thread
From: Russell King - ARM Linux @ 2016-08-29 12:05 UTC (permalink / raw)
To: linux-arm-kernel, linux-serial; +Cc: Greg Kroah-Hartman, Jiri Slaby
This series converts SA11x0 serial to make use of the mctrl helpers
where appropriate. This allows us to remove several board-specific
callbacks.
As serial is critical for console output, we report but otherwise
ignore any error except probe deferral from mctrl initialisation.
Obviously, as this is part of a larger series (and has dependencies
on the previous series) this can not be applied to individual
subsystem maintainer trees. Please ack.
arch/arm/mach-sa1100/assabet.c | 91 +++++++++++----------------------
arch/arm/mach-sa1100/badge4.c | 2 -
arch/arm/mach-sa1100/h3xxx.c | 64 ++++-------------------
arch/arm/mach-sa1100/hackkit.c | 48 ------------------
arch/arm/mach-sa1100/neponset.c | 109 +++++++++++-----------------------------
drivers/tty/serial/Kconfig | 1 +
drivers/tty/serial/sa1100.c | 42 ++++++++++++++--
7 files changed, 106 insertions(+), 251 deletions(-)
--
RMK's Patch system: http://www.armlinux.org.uk/developer/patches/
FTTC broadband for 0.8mile line: currently at 9.6Mbps down 400kbps up
according to speedtest.net.
^ permalink raw reply [flat|nested] 12+ messages in thread
* [PATCH 1/6] serial: sa1100: add support for mctrl gpios
2016-08-29 12:05 ` [PATCH 0/6] SA11x0 serial updates Russell King - ARM Linux
@ 2016-08-29 12:05 ` Russell King
2016-08-31 13:25 ` Greg Kroah-Hartman
2016-08-29 12:05 ` [PATCH 2/6] ARM: sa1100/assabet: convert serial to gpiod APIs Russell King
` (5 subsequent siblings)
6 siblings, 1 reply; 12+ messages in thread
From: Russell King @ 2016-08-29 12:05 UTC (permalink / raw)
To: linux-arm-kernel, linux-serial; +Cc: Greg Kroah-Hartman, Jiri Slaby
Add support for the generic mctrl gpio helper. This will allow us to
convert several board files to use the gpiod tables to assign GPIOs to
serial ports, rather than needing to have private function callbacks.
If the generic mctrl gpio helper fails, ignore the mctrl gpios rather
than preventing the (possibly console) serial port from being created.
Signed-off-by: Russell King <rmk+kernel@armlinux.org.uk>
---
drivers/tty/serial/Kconfig | 1 +
drivers/tty/serial/sa1100.c | 42 ++++++++++++++++++++++++++++++++++++++----
2 files changed, 39 insertions(+), 4 deletions(-)
diff --git a/drivers/tty/serial/Kconfig b/drivers/tty/serial/Kconfig
index 518db24a5b36..528d2ea3c7e7 100644
--- a/drivers/tty/serial/Kconfig
+++ b/drivers/tty/serial/Kconfig
@@ -464,6 +464,7 @@ config SERIAL_SA1100
bool "SA1100 serial port support"
depends on ARCH_SA1100
select SERIAL_CORE
+ select SERIAL_MCTRL_GPIO if GPIOLIB
help
If you have a machine based on a SA1100/SA1110 StrongARM(R) CPU you
can enable its onboard serial port by enabling this option.
diff --git a/drivers/tty/serial/sa1100.c b/drivers/tty/serial/sa1100.c
index fd3d1329d48c..ce1f9a3fb36d 100644
--- a/drivers/tty/serial/sa1100.c
+++ b/drivers/tty/serial/sa1100.c
@@ -41,6 +41,8 @@
#include <mach/hardware.h>
#include <mach/irqs.h>
+#include "serial_mctrl_gpio.h"
+
/* We've been assigned a range on the "Low-density serial ports" major */
#define SERIAL_SA1100_MAJOR 204
#define MINOR_START 5
@@ -90,6 +92,7 @@ struct sa1100_port {
struct uart_port port;
struct timer_list timer;
unsigned int old_status;
+ struct mctrl_gpios *gpios;
};
/*
@@ -187,6 +190,8 @@ static void sa1100_enable_ms(struct uart_port *port)
container_of(port, struct sa1100_port, port);
mod_timer(&sport->timer, jiffies);
+
+ mctrl_gpio_enable_ms(sport->gpios);
}
static void
@@ -335,11 +340,21 @@ static unsigned int sa1100_tx_empty(struct uart_port *port)
static unsigned int sa1100_get_mctrl(struct uart_port *port)
{
- return TIOCM_CTS | TIOCM_DSR | TIOCM_CAR;
+ struct sa1100_port *sport =
+ container_of(port, struct sa1100_port, port);
+ int ret = TIOCM_CTS | TIOCM_DSR | TIOCM_CAR;
+
+ mctrl_gpio_get(sport->gpios, &ret);
+
+ return ret;
}
static void sa1100_set_mctrl(struct uart_port *port, unsigned int mctrl)
{
+ struct sa1100_port *sport =
+ container_of(port, struct sa1100_port, port);
+
+ mctrl_gpio_set(sport->gpios, mctrl);
}
/*
@@ -857,6 +872,27 @@ static int sa1100_serial_resume(struct platform_device *dev)
return 0;
}
+static int sa1100_serial_add_one_port(struct sa1100_port *sport, struct platform_device *dev)
+{
+ sport->port.dev = &dev->dev;
+ sport->gpios = mctrl_gpio_init_noauto(sport->port.dev, 0);
+ if (IS_ERR(sport->gpios)) {
+ int err = PTR_ERR(sport->gpios);
+
+ dev_err(sport->port.dev, "failed to get mctrl gpios: %d\n",
+ err);
+
+ if (err == -EPROBE_DEFER)
+ return err;
+
+ sport->gpios = NULL;
+ }
+
+ platform_set_drvdata(dev, sport);
+
+ return uart_add_one_port(&sa1100_reg, &sport->port);
+}
+
static int sa1100_serial_probe(struct platform_device *dev)
{
struct resource *res = dev->resource;
@@ -871,9 +907,7 @@ static int sa1100_serial_probe(struct platform_device *dev)
if (sa1100_ports[i].port.mapbase != res->start)
continue;
- sa1100_ports[i].port.dev = &dev->dev;
- uart_add_one_port(&sa1100_reg, &sa1100_ports[i].port);
- platform_set_drvdata(dev, &sa1100_ports[i]);
+ sa1100_serial_add_one_port(&sa1100_ports[i], dev);
break;
}
}
--
2.1.0
^ permalink raw reply related [flat|nested] 12+ messages in thread
* [PATCH 2/6] ARM: sa1100/assabet: convert serial to gpiod APIs
2016-08-29 12:05 ` [PATCH 0/6] SA11x0 serial updates Russell King - ARM Linux
2016-08-29 12:05 ` [PATCH 1/6] serial: sa1100: add support for mctrl gpios Russell King
@ 2016-08-29 12:05 ` Russell King
2016-08-29 12:06 ` [PATCH 3/6] ARM: sa1100/h3xxx: " Russell King
` (4 subsequent siblings)
6 siblings, 0 replies; 12+ messages in thread
From: Russell King @ 2016-08-29 12:05 UTC (permalink / raw)
To: linux-arm-kernel, linux-serial; +Cc: Greg Kroah-Hartman, Jiri Slaby
Convert the Assabet serial modem control signals to use the gpiod APIs
rather than custom callbacks into platform code.
Signed-off-by: Russell King <rmk+kernel@armlinux.org.uk>
---
arch/arm/mach-sa1100/assabet.c | 91 +++++++++++++-----------------------------
1 file changed, 28 insertions(+), 63 deletions(-)
diff --git a/arch/arm/mach-sa1100/assabet.c b/arch/arm/mach-sa1100/assabet.c
index 14a75735e9d0..a841f6845701 100644
--- a/arch/arm/mach-sa1100/assabet.c
+++ b/arch/arm/mach-sa1100/assabet.c
@@ -515,6 +515,29 @@ static const struct gpio_keys_platform_data assabet_keys_pdata = {
.rep = 0,
};
+static struct gpiod_lookup_table assabet_uart1_gpio_table = {
+ .dev_id = "sa11x0-uart.1",
+ .table = {
+ GPIO_LOOKUP("assabet", 16, "dtr", GPIO_ACTIVE_LOW),
+ GPIO_LOOKUP("assabet", 17, "rts", GPIO_ACTIVE_LOW),
+ GPIO_LOOKUP("assabet", 25, "dcd", GPIO_ACTIVE_LOW),
+ GPIO_LOOKUP("assabet", 26, "cts", GPIO_ACTIVE_LOW),
+ GPIO_LOOKUP("assabet", 27, "dsr", GPIO_ACTIVE_LOW),
+ { },
+ },
+};
+
+static struct gpiod_lookup_table assabet_uart3_gpio_table = {
+ .dev_id = "sa11x0-uart.3",
+ .table = {
+ GPIO_LOOKUP("assabet", 28, "cts", GPIO_ACTIVE_LOW),
+ GPIO_LOOKUP("assabet", 29, "dsr", GPIO_ACTIVE_LOW),
+ GPIO_LOOKUP("assabet", 30, "dcd", GPIO_ACTIVE_LOW),
+ GPIO_LOOKUP("assabet", 31, "rng", GPIO_ACTIVE_LOW),
+ { },
+ },
+};
+
static void __init assabet_init(void)
{
gpiod_add_lookup_table(&assabet_irda_gpio_table);
@@ -568,6 +591,9 @@ static void __init assabet_init(void)
&assabet_keys_pdata,
sizeof(assabet_keys_pdata));
+ gpiod_add_lookup_table(&assabet_uart1_gpio_table);
+ gpiod_add_lookup_table(&assabet_uart3_gpio_table);
+
assabet_register_fixed_regulator(0, &assabet_cf_vcc_pdata,
assabet_cf_vcc_consumers,
ARRAY_SIZE(assabet_cf_vcc_consumers));
@@ -650,74 +676,13 @@ static void assabet_uart_pm(struct uart_port *port, u_int state, u_int oldstate)
{
if (port->mapbase == _Ser1UTCR0) {
if (state)
- ASSABET_BCR_clear(ASSABET_BCR_RS232EN |
- ASSABET_BCR_COM_RTS |
- ASSABET_BCR_COM_DTR);
- else
- ASSABET_BCR_set(ASSABET_BCR_RS232EN |
- ASSABET_BCR_COM_RTS |
- ASSABET_BCR_COM_DTR);
- }
-}
-
-/*
- * Assabet uses COM_RTS and COM_DTR for both UART1 (com port)
- * and UART3 (radio module). We only handle them for UART1 here.
- */
-static void assabet_set_mctrl(struct uart_port *port, u_int mctrl)
-{
- if (port->mapbase == _Ser1UTCR0) {
- u_int set = 0, clear = 0;
-
- if (mctrl & TIOCM_RTS)
- clear |= ASSABET_BCR_COM_RTS;
+ ASSABET_BCR_clear(ASSABET_BCR_RS232EN);
else
- set |= ASSABET_BCR_COM_RTS;
-
- if (mctrl & TIOCM_DTR)
- clear |= ASSABET_BCR_COM_DTR;
- else
- set |= ASSABET_BCR_COM_DTR;
-
- ASSABET_BCR_clear(clear);
- ASSABET_BCR_set(set);
- }
-}
-
-static u_int assabet_get_mctrl(struct uart_port *port)
-{
- u_int ret = 0;
- u_int bsr = ASSABET_BSR;
-
- /* need 2 reads to read current value */
- bsr = ASSABET_BSR;
-
- if (port->mapbase == _Ser1UTCR0) {
- if (bsr & ASSABET_BSR_COM_DCD)
- ret |= TIOCM_CD;
- if (bsr & ASSABET_BSR_COM_CTS)
- ret |= TIOCM_CTS;
- if (bsr & ASSABET_BSR_COM_DSR)
- ret |= TIOCM_DSR;
- } else if (port->mapbase == _Ser3UTCR0) {
- if (bsr & ASSABET_BSR_RAD_DCD)
- ret |= TIOCM_CD;
- if (bsr & ASSABET_BSR_RAD_CTS)
- ret |= TIOCM_CTS;
- if (bsr & ASSABET_BSR_RAD_DSR)
- ret |= TIOCM_DSR;
- if (bsr & ASSABET_BSR_RAD_RI)
- ret |= TIOCM_RI;
- } else {
- ret = TIOCM_CD | TIOCM_CTS | TIOCM_DSR;
+ ASSABET_BCR_set(ASSABET_BCR_RS232EN);
}
-
- return ret;
}
static struct sa1100_port_fns assabet_port_fns __initdata = {
- .set_mctrl = assabet_set_mctrl,
- .get_mctrl = assabet_get_mctrl,
.pm = assabet_uart_pm,
};
--
2.1.0
^ permalink raw reply related [flat|nested] 12+ messages in thread
* [PATCH 3/6] ARM: sa1100/h3xxx: convert serial to gpiod APIs
2016-08-29 12:05 ` [PATCH 0/6] SA11x0 serial updates Russell King - ARM Linux
2016-08-29 12:05 ` [PATCH 1/6] serial: sa1100: add support for mctrl gpios Russell King
2016-08-29 12:05 ` [PATCH 2/6] ARM: sa1100/assabet: convert serial to gpiod APIs Russell King
@ 2016-08-29 12:06 ` Russell King
2016-08-29 12:06 ` [PATCH 4/6] ARM: sa1100/badge4: remove commented out modem control initialisers Russell King
` (3 subsequent siblings)
6 siblings, 0 replies; 12+ messages in thread
From: Russell King @ 2016-08-29 12:06 UTC (permalink / raw)
To: linux-arm-kernel, linux-serial; +Cc: Greg Kroah-Hartman, Jiri Slaby
Convert the iPAQ H3xxx serial modem control signals to use the gpiod
APIs rather than custom callbacks into platform code.
Signed-off-by: Russell King <rmk+kernel@armlinux.org.uk>
---
arch/arm/mach-sa1100/h3xxx.c | 64 ++++++++------------------------------------
1 file changed, 11 insertions(+), 53 deletions(-)
diff --git a/arch/arm/mach-sa1100/h3xxx.c b/arch/arm/mach-sa1100/h3xxx.c
index 31035ab3c095..d127cc190fb3 100644
--- a/arch/arm/mach-sa1100/h3xxx.c
+++ b/arch/arm/mach-sa1100/h3xxx.c
@@ -87,57 +87,6 @@ static struct resource h3xxx_flash_resource =
/*
* H3xxx uart support
*/
-static struct gpio h3xxx_uart_gpio[] = {
- { H3XXX_GPIO_COM_DCD, GPIOF_IN, "COM DCD" },
- { H3XXX_GPIO_COM_CTS, GPIOF_IN, "COM CTS" },
- { H3XXX_GPIO_COM_RTS, GPIOF_OUT_INIT_LOW, "COM RTS" },
-};
-
-static bool h3xxx_uart_request_gpios(void)
-{
- static bool h3xxx_uart_gpio_ok;
- int rc;
-
- if (h3xxx_uart_gpio_ok)
- return true;
-
- rc = gpio_request_array(h3xxx_uart_gpio, ARRAY_SIZE(h3xxx_uart_gpio));
- if (rc)
- pr_err("h3xxx_uart_request_gpios: error %d\n", rc);
- else
- h3xxx_uart_gpio_ok = true;
-
- return h3xxx_uart_gpio_ok;
-}
-
-static void h3xxx_uart_set_mctrl(struct uart_port *port, u_int mctrl)
-{
- if (port->mapbase == _Ser3UTCR0) {
- if (!h3xxx_uart_request_gpios())
- return;
- gpio_set_value(H3XXX_GPIO_COM_RTS, !(mctrl & TIOCM_RTS));
- }
-}
-
-static u_int h3xxx_uart_get_mctrl(struct uart_port *port)
-{
- u_int ret = TIOCM_CD | TIOCM_CTS | TIOCM_DSR;
-
- if (port->mapbase == _Ser3UTCR0) {
- if (!h3xxx_uart_request_gpios())
- return ret;
- /*
- * DCD and CTS bits are inverted in GPLR by RS232 transceiver
- */
- if (gpio_get_value(H3XXX_GPIO_COM_DCD))
- ret &= ~TIOCM_CD;
- if (gpio_get_value(H3XXX_GPIO_COM_CTS))
- ret &= ~TIOCM_CTS;
- }
-
- return ret;
-}
-
static void h3xxx_uart_pm(struct uart_port *port, u_int state, u_int oldstate)
{
if (port->mapbase == _Ser3UTCR0) {
@@ -170,12 +119,20 @@ static int h3xxx_uart_set_wake(struct uart_port *port, u_int enable)
}
static struct sa1100_port_fns h3xxx_port_fns __initdata = {
- .set_mctrl = h3xxx_uart_set_mctrl,
- .get_mctrl = h3xxx_uart_get_mctrl,
.pm = h3xxx_uart_pm,
.set_wake = h3xxx_uart_set_wake,
};
+static struct gpiod_lookup_table h3xxx_uart3_gpio_table = {
+ .dev_id = "sa11x0-uart.3",
+ .table = {
+ GPIO_LOOKUP("gpio", H3XXX_GPIO_COM_DCD, "dcd", GPIO_ACTIVE_LOW),
+ GPIO_LOOKUP("gpio", H3XXX_GPIO_COM_CTS, "cts", GPIO_ACTIVE_LOW),
+ GPIO_LOOKUP("gpio", H3XXX_GPIO_COM_RTS, "rts", GPIO_ACTIVE_LOW),
+ { },
+ },
+};
+
/*
* EGPIO
*/
@@ -283,6 +240,7 @@ static struct gpiod_lookup_table h3xxx_pcmcia_gpio_table = {
void __init h3xxx_mach_init(void)
{
gpiod_add_lookup_table(&h3xxx_pcmcia_gpio_table);
+ gpiod_add_lookup_table(&h3xxx_uart3_gpio_table);
sa1100_register_uart_fns(&h3xxx_port_fns);
sa11x0_register_mtd(&h3xxx_flash_data, &h3xxx_flash_resource, 1);
platform_add_devices(h3xxx_devices, ARRAY_SIZE(h3xxx_devices));
--
2.1.0
^ permalink raw reply related [flat|nested] 12+ messages in thread
* [PATCH 4/6] ARM: sa1100/badge4: remove commented out modem control initialisers
2016-08-29 12:05 ` [PATCH 0/6] SA11x0 serial updates Russell King - ARM Linux
` (2 preceding siblings ...)
2016-08-29 12:06 ` [PATCH 3/6] ARM: sa1100/h3xxx: " Russell King
@ 2016-08-29 12:06 ` Russell King
2016-08-29 12:06 ` [PATCH 5/6] ARM: sa1100/hackkit: remove empty serial mctrl functions Russell King
` (2 subsequent siblings)
6 siblings, 0 replies; 12+ messages in thread
From: Russell King @ 2016-08-29 12:06 UTC (permalink / raw)
To: linux-arm-kernel, linux-serial; +Cc: Greg Kroah-Hartman, Jiri Slaby
Remove the commented out modem control initialisers. These are doing
nothing useful.
Signed-off-by: Russell King <rmk+kernel@armlinux.org.uk>
---
arch/arm/mach-sa1100/badge4.c | 2 --
1 file changed, 2 deletions(-)
diff --git a/arch/arm/mach-sa1100/badge4.c b/arch/arm/mach-sa1100/badge4.c
index 63361b6d04e9..17d28b4dab5e 100644
--- a/arch/arm/mach-sa1100/badge4.c
+++ b/arch/arm/mach-sa1100/badge4.c
@@ -315,8 +315,6 @@ badge4_uart_pm(struct uart_port *port, u_int state, u_int oldstate)
}
static struct sa1100_port_fns badge4_port_fns __initdata = {
- //.get_mctrl = badge4_get_mctrl,
- //.set_mctrl = badge4_set_mctrl,
.pm = badge4_uart_pm,
};
--
2.1.0
^ permalink raw reply related [flat|nested] 12+ messages in thread
* [PATCH 5/6] ARM: sa1100/hackkit: remove empty serial mctrl functions
2016-08-29 12:05 ` [PATCH 0/6] SA11x0 serial updates Russell King - ARM Linux
` (3 preceding siblings ...)
2016-08-29 12:06 ` [PATCH 4/6] ARM: sa1100/badge4: remove commented out modem control initialisers Russell King
@ 2016-08-29 12:06 ` Russell King
2016-08-29 12:06 ` [PATCH 6/6] ARM: sa1100/neponset: convert serial to use gpiod APIs Russell King
2016-09-05 9:09 ` [PATCH 0/6] SA11x0 serial updates Linus Walleij
6 siblings, 0 replies; 12+ messages in thread
From: Russell King @ 2016-08-29 12:06 UTC (permalink / raw)
To: linux-arm-kernel, linux-serial; +Cc: Greg Kroah-Hartman, Jiri Slaby
Remove the empty serial modem control signal functions from hackkit
as these are unnecessary - the core code can copes fine without
these.
Signed-off-by: Russell King <rmk+kernel@armlinux.org.uk>
---
arch/arm/mach-sa1100/hackkit.c | 48 ------------------------------------------
1 file changed, 48 deletions(-)
diff --git a/arch/arm/mach-sa1100/hackkit.c b/arch/arm/mach-sa1100/hackkit.c
index 643d5f2d9af9..9faf602666cf 100644
--- a/arch/arm/mach-sa1100/hackkit.c
+++ b/arch/arm/mach-sa1100/hackkit.c
@@ -49,8 +49,6 @@
/* init funcs */
static void __init hackkit_map_io(void);
-static u_int hackkit_get_mctrl(struct uart_port *port);
-static void hackkit_set_mctrl(struct uart_port *port, u_int mctrl);
static void hackkit_uart_pm(struct uart_port *port, u_int state, u_int oldstate);
/**********************************************************************
@@ -71,8 +69,6 @@ static struct map_desc hackkit_io_desc[] __initdata = {
};
static struct sa1100_port_fns hackkit_port_fns __initdata = {
- .set_mctrl = hackkit_set_mctrl,
- .get_mctrl = hackkit_get_mctrl,
.pm = hackkit_uart_pm,
};
@@ -105,50 +101,6 @@ static void hackkit_uart_pm(struct uart_port *port, u_int state, u_int oldstate)
/* TODO: switch on/off uart in powersave mode */
}
-/*
- * Note! this can be called from IRQ context.
- * FIXME: No modem ctrl lines yet.
- */
-static void hackkit_set_mctrl(struct uart_port *port, u_int mctrl)
-{
-#if 0
- if (port->mapbase == _Ser1UTCR0) {
- u_int set = 0, clear = 0;
-
- if (mctrl & TIOCM_RTS)
- set |= PT_CTRL2_RS1_RTS;
- else
- clear |= PT_CTRL2_RS1_RTS;
-
- if (mctrl & TIOCM_DTR)
- set |= PT_CTRL2_RS1_DTR;
- else
- clear |= PT_CTRL2_RS1_DTR;
-
- PTCTRL2_clear(clear);
- PTCTRL2_set(set);
- }
-#endif
-}
-
-static u_int hackkit_get_mctrl(struct uart_port *port)
-{
- u_int ret = 0;
-#if 0
- u_int irqsr = PT_IRQSR;
-
- /* need 2 reads to read current value */
- irqsr = PT_IRQSR;
-
- /* TODO: check IRQ source register for modem/com
- status lines and set them correctly. */
-#endif
-
- ret = TIOCM_CD | TIOCM_CTS | TIOCM_DSR;
-
- return ret;
-}
-
static struct mtd_partition hackkit_partitions[] = {
{
.name = "BLOB",
--
2.1.0
^ permalink raw reply related [flat|nested] 12+ messages in thread
* [PATCH 6/6] ARM: sa1100/neponset: convert serial to use gpiod APIs
2016-08-29 12:05 ` [PATCH 0/6] SA11x0 serial updates Russell King - ARM Linux
` (4 preceding siblings ...)
2016-08-29 12:06 ` [PATCH 5/6] ARM: sa1100/hackkit: remove empty serial mctrl functions Russell King
@ 2016-08-29 12:06 ` Russell King
2016-09-05 9:09 ` [PATCH 0/6] SA11x0 serial updates Linus Walleij
6 siblings, 0 replies; 12+ messages in thread
From: Russell King @ 2016-08-29 12:06 UTC (permalink / raw)
To: linux-arm-kernel, linux-serial; +Cc: Greg Kroah-Hartman, Jiri Slaby
Convert the serial modem control signals to use the gpiod APIs rather
than the private platform callbacks.
Signed-off-by: Russell King <rmk+kernel@armlinux.org.uk>
---
arch/arm/mach-sa1100/neponset.c | 109 +++++++++++-----------------------------
1 file changed, 28 insertions(+), 81 deletions(-)
diff --git a/arch/arm/mach-sa1100/neponset.c b/arch/arm/mach-sa1100/neponset.c
index 790d8da233da..bff6efdfaeaf 100644
--- a/arch/arm/mach-sa1100/neponset.c
+++ b/arch/arm/mach-sa1100/neponset.c
@@ -10,7 +10,6 @@
#include <linux/irq.h>
#include <linux/kernel.h>
#include <linux/module.h>
-#include <linux/platform_data/sa11x0-serial.h>
#include <linux/platform_device.h>
#include <linux/pm.h>
#include <linux/serial_core.h>
@@ -48,23 +47,8 @@
#define IRR_SA1111 (1 << 2)
#define NCR_NGPIO 7
-
-#define MDM_CTL0_RTS1 (1 << 0)
-#define MDM_CTL0_DTR1 (1 << 1)
-#define MDM_CTL0_RTS2 (1 << 2)
-#define MDM_CTL0_DTR2 (1 << 3)
#define MDM_CTL0_NGPIO 4
-
-#define MDM_CTL1_CTS1 (1 << 0)
-#define MDM_CTL1_DSR1 (1 << 1)
-#define MDM_CTL1_DCD1 (1 << 2)
-#define MDM_CTL1_CTS2 (1 << 3)
-#define MDM_CTL1_DSR2 (1 << 4)
-#define MDM_CTL1_DCD2 (1 << 5)
#define MDM_CTL1_NGPIO 6
-
-#define AUD_SEL_1341 (1 << 0)
-#define AUD_MUTE_1341 (1 << 1)
#define AUD_NGPIO 2
extern void sa1110_mb_disable(void);
@@ -96,6 +80,30 @@ struct neponset_drvdata {
struct gpio_chip *gpio[4];
};
+static struct gpiod_lookup_table neponset_uart1_gpio_table = {
+ .dev_id = "sa11x0-uart.1",
+ .table = {
+ GPIO_LOOKUP("neponset-mdm-ctl0", 2, "rts", GPIO_ACTIVE_LOW),
+ GPIO_LOOKUP("neponset-mdm-ctl0", 3, "dtr", GPIO_ACTIVE_LOW),
+ GPIO_LOOKUP("neponset-mdm-ctl1", 3, "cts", GPIO_ACTIVE_LOW),
+ GPIO_LOOKUP("neponset-mdm-ctl1", 4, "dsr", GPIO_ACTIVE_LOW),
+ GPIO_LOOKUP("neponset-mdm-ctl1", 5, "dcd", GPIO_ACTIVE_LOW),
+ { },
+ },
+};
+
+static struct gpiod_lookup_table neponset_uart3_gpio_table = {
+ .dev_id = "sa11x0-uart.3",
+ .table = {
+ GPIO_LOOKUP("neponset-mdm-ctl0", 0, "rts", GPIO_ACTIVE_LOW),
+ GPIO_LOOKUP("neponset-mdm-ctl0", 1, "dtr", GPIO_ACTIVE_LOW),
+ GPIO_LOOKUP("neponset-mdm-ctl1", 0, "cts", GPIO_ACTIVE_LOW),
+ GPIO_LOOKUP("neponset-mdm-ctl1", 1, "dsr", GPIO_ACTIVE_LOW),
+ GPIO_LOOKUP("neponset-mdm-ctl1", 2, "dcd", GPIO_ACTIVE_LOW),
+ { },
+ },
+};
+
static struct gpiod_lookup_table neponset_pcmcia_table = {
.dev_id = "1800",
.table = {
@@ -123,69 +131,6 @@ void neponset_ncr_frob(unsigned int mask, unsigned int val)
}
EXPORT_SYMBOL(neponset_ncr_frob);
-static void neponset_set_mctrl(struct uart_port *port, u_int mctrl)
-{
- struct neponset_drvdata *n = nep;
- unsigned long mask, val = 0;
-
- if (!n)
- return;
-
- if (port->mapbase == _Ser1UTCR0) {
- mask = MDM_CTL0_RTS2 | MDM_CTL0_DTR2;
-
- if (!(mctrl & TIOCM_RTS))
- val |= MDM_CTL0_RTS2;
-
- if (!(mctrl & TIOCM_DTR))
- val |= MDM_CTL0_DTR2;
- } else if (port->mapbase == _Ser3UTCR0) {
- mask = MDM_CTL0_RTS1 | MDM_CTL0_DTR1;
-
- if (!(mctrl & TIOCM_RTS))
- val |= MDM_CTL0_RTS1;
-
- if (!(mctrl & TIOCM_DTR))
- val |= MDM_CTL0_DTR1;
- }
-
- n->gpio[1]->set_multiple(n->gpio[1], &mask, &val);
-}
-
-static u_int neponset_get_mctrl(struct uart_port *port)
-{
- void __iomem *base = nep->base;
- u_int ret = TIOCM_CD | TIOCM_CTS | TIOCM_DSR;
- u_int mdm_ctl1;
-
- if (!base)
- return ret;
-
- mdm_ctl1 = readb_relaxed(base + MDM_CTL_1);
- if (port->mapbase == _Ser1UTCR0) {
- if (mdm_ctl1 & MDM_CTL1_DCD2)
- ret &= ~TIOCM_CD;
- if (mdm_ctl1 & MDM_CTL1_CTS2)
- ret &= ~TIOCM_CTS;
- if (mdm_ctl1 & MDM_CTL1_DSR2)
- ret &= ~TIOCM_DSR;
- } else if (port->mapbase == _Ser3UTCR0) {
- if (mdm_ctl1 & MDM_CTL1_DCD1)
- ret &= ~TIOCM_CD;
- if (mdm_ctl1 & MDM_CTL1_CTS1)
- ret &= ~TIOCM_CTS;
- if (mdm_ctl1 & MDM_CTL1_DSR1)
- ret &= ~TIOCM_DSR;
- }
-
- return ret;
-}
-
-static struct sa1100_port_fns neponset_port_fns = {
- .set_mctrl = neponset_set_mctrl,
- .get_mctrl = neponset_get_mctrl,
-};
-
/*
* Install handler for Neponset IRQ. Note that we have to loop here
* since the ETHERNET and USAR IRQs are level based, and we need to
@@ -384,6 +329,8 @@ static int neponset_probe(struct platform_device *dev)
d->base + AUD_CTL, AUD_NGPIO, false,
neponset_aud_names);
+ gpiod_add_lookup_table(&neponset_uart1_gpio_table);
+ gpiod_add_lookup_table(&neponset_uart3_gpio_table);
gpiod_add_lookup_table(&neponset_pcmcia_table);
/*
@@ -398,8 +345,6 @@ static int neponset_probe(struct platform_device *dev)
d->irq_base, d->irq_base + NEP_IRQ_NR - 1);
nep = d;
- sa1100_register_uart_fns(&neponset_port_fns);
-
/* Ensure that the memory bus request/grant signals are setup */
sa1110_mb_disable();
@@ -441,6 +386,8 @@ static int neponset_remove(struct platform_device *dev)
platform_device_unregister(d->smc91x);
gpiod_remove_lookup_table(&neponset_pcmcia_table);
+ gpiod_remove_lookup_table(&neponset_uart3_gpio_table);
+ gpiod_remove_lookup_table(&neponset_uart1_gpio_table);
irq_set_chained_handler(irq, NULL);
irq_free_descs(d->irq_base, NEP_IRQ_NR);
--
2.1.0
^ permalink raw reply related [flat|nested] 12+ messages in thread
* Re: [PATCH 1/6] serial: sa1100: add support for mctrl gpios
2016-08-29 12:05 ` [PATCH 1/6] serial: sa1100: add support for mctrl gpios Russell King
@ 2016-08-31 13:25 ` Greg Kroah-Hartman
0 siblings, 0 replies; 12+ messages in thread
From: Greg Kroah-Hartman @ 2016-08-31 13:25 UTC (permalink / raw)
To: Russell King; +Cc: linux-serial, linux-arm-kernel, Jiri Slaby
On Mon, Aug 29, 2016 at 01:05:51PM +0100, Russell King wrote:
> Add support for the generic mctrl gpio helper. This will allow us to
> convert several board files to use the gpiod tables to assign GPIOs to
> serial ports, rather than needing to have private function callbacks.
>
> If the generic mctrl gpio helper fails, ignore the mctrl gpios rather
> than preventing the (possibly console) serial port from being created.
>
> Signed-off-by: Russell King <rmk+kernel@armlinux.org.uk>
> ---
> drivers/tty/serial/Kconfig | 1 +
> drivers/tty/serial/sa1100.c | 42 ++++++++++++++++++++++++++++++++++++++----
> 2 files changed, 39 insertions(+), 4 deletions(-)
Acked-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCH 0/6] SA11x0 serial updates
2016-08-29 12:05 ` [PATCH 0/6] SA11x0 serial updates Russell King - ARM Linux
` (5 preceding siblings ...)
2016-08-29 12:06 ` [PATCH 6/6] ARM: sa1100/neponset: convert serial to use gpiod APIs Russell King
@ 2016-09-05 9:09 ` Linus Walleij
2016-09-05 12:28 ` Russell King - ARM Linux
6 siblings, 1 reply; 12+ messages in thread
From: Linus Walleij @ 2016-09-05 9:09 UTC (permalink / raw)
To: Russell King - ARM Linux
Cc: Greg Kroah-Hartman, linux-serial@vger.kernel.org,
linux-arm-kernel@lists.infradead.org, Jiri Slaby
On Mon, Aug 29, 2016 at 2:05 PM, Russell King - ARM Linux
<linux@armlinux.org.uk> wrote:
> This series converts SA11x0 serial to make use of the mctrl helpers
> where appropriate. This allows us to remove several board-specific
> callbacks.
>From GPIO and H3600 point of view:
Acked-by: Linus Walleij <linus.walleij@linaro.org>
Yours,
Linus Walleij
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCH 0/6] SA11x0 serial updates
2016-09-05 9:09 ` [PATCH 0/6] SA11x0 serial updates Linus Walleij
@ 2016-09-05 12:28 ` Russell King - ARM Linux
2016-09-07 22:28 ` Linus Walleij
2016-09-08 13:23 ` Linus Walleij
0 siblings, 2 replies; 12+ messages in thread
From: Russell King - ARM Linux @ 2016-09-05 12:28 UTC (permalink / raw)
To: Linus Walleij
Cc: Greg Kroah-Hartman, linux-serial@vger.kernel.org,
linux-arm-kernel@lists.infradead.org, Jiri Slaby
On Mon, Sep 05, 2016 at 11:09:38AM +0200, Linus Walleij wrote:
> On Mon, Aug 29, 2016 at 2:05 PM, Russell King - ARM Linux
> <linux@armlinux.org.uk> wrote:
>
> > This series converts SA11x0 serial to make use of the mctrl helpers
> > where appropriate. This allows us to remove several board-specific
> > callbacks.
>
> >From GPIO and H3600 point of view:
> Acked-by: Linus Walleij <linus.walleij@linaro.org>
Thanks - did you check that the appropriate GPIOs were claimed for
serial in gpio's debugfs?
--
RMK's Patch system: http://www.armlinux.org.uk/developer/patches/
FTTC broadband for 0.8mile line: currently at 9.6Mbps down 400kbps up
according to speedtest.net.
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCH 0/6] SA11x0 serial updates
2016-09-05 12:28 ` Russell King - ARM Linux
@ 2016-09-07 22:28 ` Linus Walleij
2016-09-08 13:23 ` Linus Walleij
1 sibling, 0 replies; 12+ messages in thread
From: Linus Walleij @ 2016-09-07 22:28 UTC (permalink / raw)
To: Russell King - ARM Linux
Cc: Greg Kroah-Hartman, linux-serial@vger.kernel.org,
linux-arm-kernel@lists.infradead.org, Jiri Slaby
On Mon, Sep 5, 2016 at 2:28 PM, Russell King - ARM Linux
<linux@armlinux.org.uk> wrote:
> On Mon, Sep 05, 2016 at 11:09:38AM +0200, Linus Walleij wrote:
>> On Mon, Aug 29, 2016 at 2:05 PM, Russell King - ARM Linux
>> <linux@armlinux.org.uk> wrote:
>>
>> > This series converts SA11x0 serial to make use of the mctrl helpers
>> > where appropriate. This allows us to remove several board-specific
>> > callbacks.
>>
>> >From GPIO and H3600 point of view:
>> Acked-by: Linus Walleij <linus.walleij@linaro.org>
>
> Thanks - did you check that the appropriate GPIOs were claimed for
> serial in gpio's debugfs?
Getting to it tomorrow (didn't forget about it).
I was working from home the last two days and back to the office where
I have all the hardware tomorrow. Will test it and report back. Will also
try to investigate the PCMCIA probe bounce with -2.
Yours,
Linus Walleij
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCH 0/6] SA11x0 serial updates
2016-09-05 12:28 ` Russell King - ARM Linux
2016-09-07 22:28 ` Linus Walleij
@ 2016-09-08 13:23 ` Linus Walleij
1 sibling, 0 replies; 12+ messages in thread
From: Linus Walleij @ 2016-09-08 13:23 UTC (permalink / raw)
To: Russell King - ARM Linux
Cc: Greg Kroah-Hartman, linux-serial@vger.kernel.org,
linux-arm-kernel@lists.infradead.org, Jiri Slaby
On Mon, Sep 5, 2016 at 2:28 PM, Russell King - ARM Linux
<linux@armlinux.org.uk> wrote:
> On Mon, Sep 05, 2016 at 11:09:38AM +0200, Linus Walleij wrote:
>> On Mon, Aug 29, 2016 at 2:05 PM, Russell King - ARM Linux
>> <linux@armlinux.org.uk> wrote:
>>
>> > This series converts SA11x0 serial to make use of the mctrl helpers
>> > where appropriate. This allows us to remove several board-specific
>> > callbacks.
>>
>> >From GPIO and H3600 point of view:
>> Acked-by: Linus Walleij <linus.walleij@linaro.org>
>
> Thanks - did you check that the appropriate GPIOs were claimed for
> serial in gpio's debugfs?
Yes that works like a charm. I have some problems with the
PCMCIA GPIOs as it turns out but that is all.
GPIO before (v4.8-rc3):
cat gpio
gpiochip0: GPIOs 0-27, gpio:
gpio-0 ( |Power Button ) in hi
gpio-10 ( |PCMCIA CD1 ) in hi
gpio-11 ( |PCMCIA IRQ1 ) in hi
gpio-17 ( |PCMCIA CD0 ) in hi
gpio-18 ( |Action button ) in hi
gpio-21 ( |PCMCIA IRQ0 ) in hi
gpio-23 ( |COM DCD ) in hi
gpio-25 ( |COM CTS ) in lo
gpio-26 ( |COM RTS ) out lo
gpiochip1: GPIOs 28-43, parent: platform/htc-egpio, htc-egpio:
gpio-28 ( |Flash Vpp ) out lo
gpio-29 ( |PCMCIA CARD RESET ) out lo
gpio-30 ( |OPT RESET ) out lo
gpio-32 ( |OPT NVRAM ON ) out lo
gpio-33 ( |OPT ON ) out lo
gpio-34 ( |LCD power ) out lo
gpio-36 ( |LCD control ) out lo
gpio-42 ( |LCD 5v ) out lo
gpio-43 ( |LCD 9v/-6.5v ) out lo
After:
cat gpio
gpiochip0: GPIOs 0-27, gpio:
gpio-0 ( |Power Button ) in hi
gpio-18 ( |Action button ) in hi
gpio-23 ( |dcd ) in hi
gpio-25 ( |cts ) in lo
gpio-26 ( |rts ) out lo
gpiochip1: GPIOs 28-43, parent: platform/htc-egpio, htc-egpio:
gpio-28 ( |Flash Vpp ) out lo
gpio-34 ( |LCD power ) out lo
gpio-36 ( |LCD control ) out lo
gpio-42 ( |LCD 5v ) out lo
gpio-43 ( |LCD 9v/-6.5v ) out lo
As you can see all but the PCMCIA GPIOs are playing well
with the new setup.
Once this stuff is upstream I can attempt to convert the rest of
GPIOs on the h3xxx to use descriptors.
Yours,
Linus Walleij
^ permalink raw reply [flat|nested] 12+ messages in thread
end of thread, other threads:[~2016-09-08 13:23 UTC | newest]
Thread overview: 12+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
[not found] <20160829100232.GC1041@n2100.armlinux.org.uk>
[not found] ` <20160829102328.GA28796@n2100.armlinux.org.uk>
[not found] ` <20160829110157.GE1041@n2100.armlinux.org.uk>
[not found] ` <20160829112540.GF1041@n2100.armlinux.org.uk>
2016-08-29 12:05 ` [PATCH 0/6] SA11x0 serial updates Russell King - ARM Linux
2016-08-29 12:05 ` [PATCH 1/6] serial: sa1100: add support for mctrl gpios Russell King
2016-08-31 13:25 ` Greg Kroah-Hartman
2016-08-29 12:05 ` [PATCH 2/6] ARM: sa1100/assabet: convert serial to gpiod APIs Russell King
2016-08-29 12:06 ` [PATCH 3/6] ARM: sa1100/h3xxx: " Russell King
2016-08-29 12:06 ` [PATCH 4/6] ARM: sa1100/badge4: remove commented out modem control initialisers Russell King
2016-08-29 12:06 ` [PATCH 5/6] ARM: sa1100/hackkit: remove empty serial mctrl functions Russell King
2016-08-29 12:06 ` [PATCH 6/6] ARM: sa1100/neponset: convert serial to use gpiod APIs Russell King
2016-09-05 9:09 ` [PATCH 0/6] SA11x0 serial updates Linus Walleij
2016-09-05 12:28 ` Russell King - ARM Linux
2016-09-07 22:28 ` Linus Walleij
2016-09-08 13:23 ` Linus Walleij
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).