Skip to content

Commit 5c9e4d8

Browse files
author
Russell King
committed
ARM: sa1100/neponset: convert serial to use gpiod APIs
Convert the serial modem control signals to use the gpiod APIs rather than the private platform callbacks. Signed-off-by: Russell King <[email protected]>
1 parent cf56ffa commit 5c9e4d8

File tree

1 file changed

+28
-81
lines changed

1 file changed

+28
-81
lines changed

arch/arm/mach-sa1100/neponset.c

Lines changed: 28 additions & 81 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111
#include <linux/irq.h>
1212
#include <linux/kernel.h>
1313
#include <linux/module.h>
14-
#include <linux/platform_data/sa11x0-serial.h>
1514
#include <linux/platform_device.h>
1615
#include <linux/pm.h>
1716
#include <linux/serial_core.h>
@@ -49,23 +48,8 @@
4948
#define IRR_SA1111 (1 << 2)
5049

5150
#define NCR_NGPIO 7
52-
53-
#define MDM_CTL0_RTS1 (1 << 0)
54-
#define MDM_CTL0_DTR1 (1 << 1)
55-
#define MDM_CTL0_RTS2 (1 << 2)
56-
#define MDM_CTL0_DTR2 (1 << 3)
5751
#define MDM_CTL0_NGPIO 4
58-
59-
#define MDM_CTL1_CTS1 (1 << 0)
60-
#define MDM_CTL1_DSR1 (1 << 1)
61-
#define MDM_CTL1_DCD1 (1 << 2)
62-
#define MDM_CTL1_CTS2 (1 << 3)
63-
#define MDM_CTL1_DSR2 (1 << 4)
64-
#define MDM_CTL1_DCD2 (1 << 5)
6552
#define MDM_CTL1_NGPIO 6
66-
67-
#define AUD_SEL_1341 (1 << 0)
68-
#define AUD_MUTE_1341 (1 << 1)
6953
#define AUD_NGPIO 2
7054

7155
extern void sa1110_mb_disable(void);
@@ -97,6 +81,30 @@ struct neponset_drvdata {
9781
struct gpio_chip *gpio[4];
9882
};
9983

84+
static struct gpiod_lookup_table neponset_uart1_gpio_table = {
85+
.dev_id = "sa11x0-uart.1",
86+
.table = {
87+
GPIO_LOOKUP("neponset-mdm-ctl0", 2, "rts", GPIO_ACTIVE_LOW),
88+
GPIO_LOOKUP("neponset-mdm-ctl0", 3, "dtr", GPIO_ACTIVE_LOW),
89+
GPIO_LOOKUP("neponset-mdm-ctl1", 3, "cts", GPIO_ACTIVE_LOW),
90+
GPIO_LOOKUP("neponset-mdm-ctl1", 4, "dsr", GPIO_ACTIVE_LOW),
91+
GPIO_LOOKUP("neponset-mdm-ctl1", 5, "dcd", GPIO_ACTIVE_LOW),
92+
{ },
93+
},
94+
};
95+
96+
static struct gpiod_lookup_table neponset_uart3_gpio_table = {
97+
.dev_id = "sa11x0-uart.3",
98+
.table = {
99+
GPIO_LOOKUP("neponset-mdm-ctl0", 0, "rts", GPIO_ACTIVE_LOW),
100+
GPIO_LOOKUP("neponset-mdm-ctl0", 1, "dtr", GPIO_ACTIVE_LOW),
101+
GPIO_LOOKUP("neponset-mdm-ctl1", 0, "cts", GPIO_ACTIVE_LOW),
102+
GPIO_LOOKUP("neponset-mdm-ctl1", 1, "dsr", GPIO_ACTIVE_LOW),
103+
GPIO_LOOKUP("neponset-mdm-ctl1", 2, "dcd", GPIO_ACTIVE_LOW),
104+
{ },
105+
},
106+
};
107+
100108
static struct gpiod_lookup_table neponset_pcmcia_table = {
101109
.dev_id = "1800",
102110
.table = {
@@ -124,69 +132,6 @@ void neponset_ncr_frob(unsigned int mask, unsigned int val)
124132
}
125133
EXPORT_SYMBOL(neponset_ncr_frob);
126134

127-
static void neponset_set_mctrl(struct uart_port *port, u_int mctrl)
128-
{
129-
struct neponset_drvdata *n = nep;
130-
unsigned long mask, val = 0;
131-
132-
if (!n)
133-
return;
134-
135-
if (port->mapbase == _Ser1UTCR0) {
136-
mask = MDM_CTL0_RTS2 | MDM_CTL0_DTR2;
137-
138-
if (!(mctrl & TIOCM_RTS))
139-
val |= MDM_CTL0_RTS2;
140-
141-
if (!(mctrl & TIOCM_DTR))
142-
val |= MDM_CTL0_DTR2;
143-
} else if (port->mapbase == _Ser3UTCR0) {
144-
mask = MDM_CTL0_RTS1 | MDM_CTL0_DTR1;
145-
146-
if (!(mctrl & TIOCM_RTS))
147-
val |= MDM_CTL0_RTS1;
148-
149-
if (!(mctrl & TIOCM_DTR))
150-
val |= MDM_CTL0_DTR1;
151-
}
152-
153-
n->gpio[1]->set_multiple(n->gpio[1], &mask, &val);
154-
}
155-
156-
static u_int neponset_get_mctrl(struct uart_port *port)
157-
{
158-
void __iomem *base = nep->base;
159-
u_int ret = TIOCM_CD | TIOCM_CTS | TIOCM_DSR;
160-
u_int mdm_ctl1;
161-
162-
if (!base)
163-
return ret;
164-
165-
mdm_ctl1 = readb_relaxed(base + MDM_CTL_1);
166-
if (port->mapbase == _Ser1UTCR0) {
167-
if (mdm_ctl1 & MDM_CTL1_DCD2)
168-
ret &= ~TIOCM_CD;
169-
if (mdm_ctl1 & MDM_CTL1_CTS2)
170-
ret &= ~TIOCM_CTS;
171-
if (mdm_ctl1 & MDM_CTL1_DSR2)
172-
ret &= ~TIOCM_DSR;
173-
} else if (port->mapbase == _Ser3UTCR0) {
174-
if (mdm_ctl1 & MDM_CTL1_DCD1)
175-
ret &= ~TIOCM_CD;
176-
if (mdm_ctl1 & MDM_CTL1_CTS1)
177-
ret &= ~TIOCM_CTS;
178-
if (mdm_ctl1 & MDM_CTL1_DSR1)
179-
ret &= ~TIOCM_DSR;
180-
}
181-
182-
return ret;
183-
}
184-
185-
static struct sa1100_port_fns neponset_port_fns = {
186-
.set_mctrl = neponset_set_mctrl,
187-
.get_mctrl = neponset_get_mctrl,
188-
};
189-
190135
/*
191136
* Install handler for Neponset IRQ. Note that we have to loop here
192137
* since the ETHERNET and USAR IRQs are level based, and we need to
@@ -388,6 +333,8 @@ static int neponset_probe(struct platform_device *dev)
388333
d->base + AUD_CTL, AUD_NGPIO, false,
389334
neponset_aud_names);
390335

336+
gpiod_add_lookup_table(&neponset_uart1_gpio_table);
337+
gpiod_add_lookup_table(&neponset_uart3_gpio_table);
391338
gpiod_add_lookup_table(&neponset_pcmcia_table);
392339

393340
/*
@@ -402,8 +349,6 @@ static int neponset_probe(struct platform_device *dev)
402349
d->irq_base, d->irq_base + NEP_IRQ_NR - 1);
403350
nep = d;
404351

405-
sa1100_register_uart_fns(&neponset_port_fns);
406-
407352
/* Ensure that the memory bus request/grant signals are setup */
408353
sa1110_mb_disable();
409354

@@ -442,6 +387,8 @@ static int neponset_remove(struct platform_device *dev)
442387
platform_device_unregister(d->smc91x);
443388

444389
gpiod_remove_lookup_table(&neponset_pcmcia_table);
390+
gpiod_remove_lookup_table(&neponset_uart3_gpio_table);
391+
gpiod_remove_lookup_table(&neponset_uart1_gpio_table);
445392

446393
irq_set_chained_handler(irq, NULL);
447394
irq_free_descs(d->irq_base, NEP_IRQ_NR);

0 commit comments

Comments
 (0)