diff mbox

[6/6] ARM: sa1100/neponset: convert serial to use gpiod APIs

Message ID E1beLKT-0001U1-HK@rmk-PC.armlinux.org.uk (mailing list archive)
State New, archived
Headers show

Commit Message

Russell King (Oracle) Aug. 29, 2016, 12:06 p.m. UTC
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(-)

Comments

Russell King (Oracle) Aug. 30, 2016, 10:51 a.m. UTC | #1
This mini-series (which follows several other series on which it
depends) gets rid of the Assabet/Neponset hack in the smc91x driver.

In order to do that, we need to get several pieces in place first:
* gpiolib support throughout SA11x0/Assabet/Neponset so that we can
  represent control signals through gpiolib
* CCF support, so we can re-use the code in drivers/clk to implement
  the external crystal oscillator attached to the SMC91x.  This
  external crystal oscillator is enabled via a control signal.

This series:
- performs the SA11x0 CCF conversion
- adds an optional clock to SMC91x to cater for an external crystal
  oscillator
- switches the Neponset code to provide a 'struct clk' representing
  this oscillator
- removes the SMC91x hack to assert the enable signal

This results in the platform specific includes being removed from the
SMC91x driver.

Please ack these changes; due to the dependencies, I wish to merge
them through my tree.  Thanks.

 arch/arm/Kconfig                   |   1 +
 arch/arm/mach-sa1100/clock.c       | 191 +++++++++++++++++--------------------
 arch/arm/mach-sa1100/neponset.c    |  42 ++++++++
 drivers/net/ethernet/smsc/smc91x.c |  47 ++++++---
 drivers/net/ethernet/smsc/smc91x.h |   1 +
 5 files changed, 166 insertions(+), 116 deletions(-)
Russell King (Oracle) Aug. 30, 2016, 10:59 a.m. UTC | #2
This last part of the series is predominantly a set of cleanup patches
removing definitions and files that aren't required, and moving some
files out of public view.  The ucb1x00 patch could arguably have
been sent in the first set, something that I'll arrange for the next
iteration.

Further conversions are possible - eg, mainstone could have its platform
register converted to the gpio-reg code, and then pxaficp and other
drivers could be further adapted to use gpiolib.  However, that would
make this series even larger than it already is, and I'm already
concerned that it's very much on the big side.  Given that it already
takes a long time to post this series in a sane manner, I'd like to
prevent it growing any further.

The only reason PXA got touched is becaues of the PCMCIA changes which
needed lubbock's MISC write register to be accessible for the MAX1600
code.

 arch/arm/mach-pxa/include/mach/lubbock.h           |   4 -
 arch/arm/mach-pxa/lubbock.c                        |   3 +-
 arch/arm/mach-sa1100/cerf.c                        |   3 +-
 arch/arm/mach-sa1100/{include/mach => }/cerf.h     |   9 +-
 arch/arm/mach-sa1100/include/mach/SA-1101.h        | 925 ---------------------
 arch/arm/mach-sa1100/include/mach/hardware.h       |   4 -
 arch/arm/mach-sa1100/include/mach/neponset.h       |  30 -
 arch/arm/mach-sa1100/nanoengine.c                  |   2 +-
 .../mach-sa1100/{include/mach => }/nanoengine.h    |  11 -
 arch/arm/mach-sa1100/neponset.c                    |  14 +-
 arch/arm/mach-sa1100/pci-nanoengine.c              |   3 +-
 drivers/mfd/ucb1x00-core.c                         |   4 -
 12 files changed, 8 insertions(+), 1004 deletions(-)
 rename arch/arm/mach-sa1100/{include/mach => }/cerf.h (66%)
 delete mode 100644 arch/arm/mach-sa1100/include/mach/SA-1101.h
 delete mode 100644 arch/arm/mach-sa1100/include/mach/neponset.h
 rename arch/arm/mach-sa1100/{include/mach => }/nanoengine.h (69%)
Nicolas Pitre Aug. 30, 2016, 3:31 p.m. UTC | #3
On Tue, 30 Aug 2016, Russell King - ARM Linux wrote:

> This mini-series (which follows several other series on which it
> depends) gets rid of the Assabet/Neponset hack in the smc91x driver.
> 
> In order to do that, we need to get several pieces in place first:
> * gpiolib support throughout SA11x0/Assabet/Neponset so that we can
>   represent control signals through gpiolib
> * CCF support, so we can re-use the code in drivers/clk to implement
>   the external crystal oscillator attached to the SMC91x.  This
>   external crystal oscillator is enabled via a control signal.
> 
> This series:
> - performs the SA11x0 CCF conversion
> - adds an optional clock to SMC91x to cater for an external crystal
>   oscillator
> - switches the Neponset code to provide a 'struct clk' representing
>   this oscillator
> - removes the SMC91x hack to assert the enable signal
> 
> This results in the platform specific includes being removed from the
> SMC91x driver.
> 
> Please ack these changes; due to the dependencies, I wish to merge
> them through my tree.  Thanks.

Looks nice to me.

Acked-by: Nicolas Pitre <nico@linaro.org>

>  arch/arm/Kconfig                   |   1 +
>  arch/arm/mach-sa1100/clock.c       | 191 +++++++++++++++++--------------------
>  arch/arm/mach-sa1100/neponset.c    |  42 ++++++++
>  drivers/net/ethernet/smsc/smc91x.c |  47 ++++++---
>  drivers/net/ethernet/smsc/smc91x.h |   1 +
>  5 files changed, 166 insertions(+), 116 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.
> 
> _______________________________________________
> linux-arm-kernel mailing list
> linux-arm-kernel@lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
>
David Miller Sept. 1, 2016, 11:32 p.m. UTC | #4
From: Russell King - ARM Linux <linux@armlinux.org.uk>
Date: Tue, 30 Aug 2016 11:51:17 +0100

> Please ack these changes; due to the dependencies, I wish to merge
> them through my tree.  Thanks.

Acked-by: David S. Miller <davem@davemloft.net>
Russell King (Oracle) Sept. 2, 2016, 6:59 p.m. UTC | #5
On Thu, Sep 01, 2016 at 04:32:41PM -0700, David Miller wrote:
> From: Russell King - ARM Linux <linux@armlinux.org.uk>
> Date: Tue, 30 Aug 2016 11:51:17 +0100
> 
> > Please ack these changes; due to the dependencies, I wish to merge
> > them through my tree.  Thanks.
> 
> Acked-by: David S. Miller <davem@davemloft.net>

Many thanks David, I'll add that only to the two SMC91x patches.
diff mbox

Patch

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);