Skip to content

Commit 229de61

Browse files
vapierdavem330
authored andcommitted
net/irda: convert bfin_sir to common Blackfin UART header
No need to duplicate these defines now that the common Blackfin code has unified these for all UART devices. Signed-off-by: Mike Frysinger <[email protected]> Cc: Samuel Ortiz <[email protected]> Cc: David Miller <[email protected]> Signed-off-by: Andrew Morton <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 6ac3f66 commit 229de61

File tree

2 files changed

+33
-89
lines changed

2 files changed

+33
-89
lines changed

drivers/net/irda/bfin_sir.c

Lines changed: 29 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -67,27 +67,27 @@ static void bfin_sir_stop_tx(struct bfin_sir_port *port)
6767
disable_dma(port->tx_dma_channel);
6868
#endif
6969

70-
while (!(SIR_UART_GET_LSR(port) & THRE)) {
70+
while (!(UART_GET_LSR(port) & THRE)) {
7171
cpu_relax();
7272
continue;
7373
}
7474

75-
SIR_UART_STOP_TX(port);
75+
UART_CLEAR_IER(port, ETBEI);
7676
}
7777

7878
static void bfin_sir_enable_tx(struct bfin_sir_port *port)
7979
{
80-
SIR_UART_ENABLE_TX(port);
80+
UART_SET_IER(port, ETBEI);
8181
}
8282

8383
static void bfin_sir_stop_rx(struct bfin_sir_port *port)
8484
{
85-
SIR_UART_STOP_RX(port);
85+
UART_CLEAR_IER(port, ERBFI);
8686
}
8787

8888
static void bfin_sir_enable_rx(struct bfin_sir_port *port)
8989
{
90-
SIR_UART_ENABLE_RX(port);
90+
UART_SET_IER(port, ERBFI);
9191
}
9292

9393
static int bfin_sir_set_speed(struct bfin_sir_port *port, int speed)
@@ -116,7 +116,7 @@ static int bfin_sir_set_speed(struct bfin_sir_port *port, int speed)
116116

117117
do {
118118
udelay(utime);
119-
lsr = SIR_UART_GET_LSR(port);
119+
lsr = UART_GET_LSR(port);
120120
} while (!(lsr & TEMT) && count--);
121121

122122
/* The useconds for 1 bits to transmit */
@@ -125,27 +125,27 @@ static int bfin_sir_set_speed(struct bfin_sir_port *port, int speed)
125125
/* Clear UCEN bit to reset the UART state machine
126126
* and control registers
127127
*/
128-
val = SIR_UART_GET_GCTL(port);
128+
val = UART_GET_GCTL(port);
129129
val &= ~UCEN;
130-
SIR_UART_PUT_GCTL(port, val);
130+
UART_PUT_GCTL(port, val);
131131

132132
/* Set DLAB in LCR to Access THR RBR IER */
133-
SIR_UART_SET_DLAB(port);
133+
UART_SET_DLAB(port);
134134
SSYNC();
135135

136-
SIR_UART_PUT_DLL(port, quot & 0xFF);
137-
SIR_UART_PUT_DLH(port, (quot >> 8) & 0xFF);
136+
UART_PUT_DLL(port, quot & 0xFF);
137+
UART_PUT_DLH(port, (quot >> 8) & 0xFF);
138138
SSYNC();
139139

140140
/* Clear DLAB in LCR */
141-
SIR_UART_CLEAR_DLAB(port);
141+
UART_CLEAR_DLAB(port);
142142
SSYNC();
143143

144-
SIR_UART_PUT_LCR(port, lcr);
144+
UART_PUT_LCR(port, lcr);
145145

146-
val = SIR_UART_GET_GCTL(port);
146+
val = UART_GET_GCTL(port);
147147
val |= UCEN;
148-
SIR_UART_PUT_GCTL(port, val);
148+
UART_PUT_GCTL(port, val);
149149

150150
ret = 0;
151151
break;
@@ -154,12 +154,12 @@ static int bfin_sir_set_speed(struct bfin_sir_port *port, int speed)
154154
break;
155155
}
156156

157-
val = SIR_UART_GET_GCTL(port);
157+
val = UART_GET_GCTL(port);
158158
/* If not add the 'RPOLC', we can't catch the receive interrupt.
159159
* It's related with the HW layout and the IR transiver.
160160
*/
161161
val |= IREN | RPOLC;
162-
SIR_UART_PUT_GCTL(port, val);
162+
UART_PUT_GCTL(port, val);
163163
return ret;
164164
}
165165

@@ -168,7 +168,7 @@ static int bfin_sir_is_receiving(struct net_device *dev)
168168
struct bfin_sir_self *self = netdev_priv(dev);
169169
struct bfin_sir_port *port = self->sir_port;
170170

171-
if (!(SIR_UART_GET_IER(port) & ERBFI))
171+
if (!(UART_GET_IER(port) & ERBFI))
172172
return 0;
173173
return self->rx_buff.state != OUTSIDE_FRAME;
174174
}
@@ -182,7 +182,7 @@ static void bfin_sir_tx_chars(struct net_device *dev)
182182

183183
if (self->tx_buff.len != 0) {
184184
chr = *(self->tx_buff.data);
185-
SIR_UART_PUT_CHAR(port, chr);
185+
UART_PUT_CHAR(port, chr);
186186
self->tx_buff.data++;
187187
self->tx_buff.len--;
188188
} else {
@@ -206,8 +206,8 @@ static void bfin_sir_rx_chars(struct net_device *dev)
206206
struct bfin_sir_port *port = self->sir_port;
207207
unsigned char ch;
208208

209-
SIR_UART_CLEAR_LSR(port);
210-
ch = SIR_UART_GET_CHAR(port);
209+
UART_CLEAR_LSR(port);
210+
ch = UART_GET_CHAR(port);
211211
async_unwrap_char(dev, &self->stats, &self->rx_buff, ch);
212212
dev->last_rx = jiffies;
213213
}
@@ -219,7 +219,7 @@ static irqreturn_t bfin_sir_rx_int(int irq, void *dev_id)
219219
struct bfin_sir_port *port = self->sir_port;
220220

221221
spin_lock(&self->lock);
222-
while ((SIR_UART_GET_LSR(port) & DR))
222+
while ((UART_GET_LSR(port) & DR))
223223
bfin_sir_rx_chars(dev);
224224
spin_unlock(&self->lock);
225225

@@ -233,7 +233,7 @@ static irqreturn_t bfin_sir_tx_int(int irq, void *dev_id)
233233
struct bfin_sir_port *port = self->sir_port;
234234

235235
spin_lock(&self->lock);
236-
if (SIR_UART_GET_LSR(port) & THRE)
236+
if (UART_GET_LSR(port) & THRE)
237237
bfin_sir_tx_chars(dev);
238238
spin_unlock(&self->lock);
239239

@@ -312,7 +312,7 @@ static void bfin_sir_dma_rx_chars(struct net_device *dev)
312312
struct bfin_sir_port *port = self->sir_port;
313313
int i;
314314

315-
SIR_UART_CLEAR_LSR(port);
315+
UART_CLEAR_LSR(port);
316316

317317
for (i = port->rx_dma_buf.head; i < port->rx_dma_buf.tail; i++)
318318
async_unwrap_char(dev, &self->stats, &self->rx_buff, port->rx_dma_buf.buf[i]);
@@ -430,11 +430,10 @@ static void bfin_sir_shutdown(struct bfin_sir_port *port, struct net_device *dev
430430
unsigned short val;
431431

432432
bfin_sir_stop_rx(port);
433-
SIR_UART_DISABLE_INTS(port);
434433

435-
val = SIR_UART_GET_GCTL(port);
434+
val = UART_GET_GCTL(port);
436435
val &= ~(UCEN | IREN | RPOLC);
437-
SIR_UART_PUT_GCTL(port, val);
436+
UART_PUT_GCTL(port, val);
438437

439438
#ifdef CONFIG_SIR_BFIN_DMA
440439
disable_dma(port->tx_dma_channel);
@@ -518,12 +517,12 @@ static void bfin_sir_send_work(struct work_struct *work)
518517
* sending data. We also can set the speed, which will
519518
* reset all the UART.
520519
*/
521-
val = SIR_UART_GET_GCTL(port);
520+
val = UART_GET_GCTL(port);
522521
val &= ~(IREN | RPOLC);
523-
SIR_UART_PUT_GCTL(port, val);
522+
UART_PUT_GCTL(port, val);
524523
SSYNC();
525524
val |= IREN | RPOLC;
526-
SIR_UART_PUT_GCTL(port, val);
525+
UART_PUT_GCTL(port, val);
527526
SSYNC();
528527
/* bfin_sir_set_speed(port, self->speed); */
529528

drivers/net/irda/bfin_sir.h

Lines changed: 4 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@
2626
#include <asm/cacheflush.h>
2727
#include <asm/dma.h>
2828
#include <asm/portmux.h>
29-
#include <mach/bfin_serial_5xx.h>
3029
#undef DRIVER_NAME
3130

3231
#ifdef CONFIG_SIR_BFIN_DMA
@@ -83,64 +82,10 @@ struct bfin_sir_self {
8382

8483
#define DRIVER_NAME "bfin_sir"
8584

86-
#define SIR_UART_GET_CHAR(port) bfin_read16((port)->membase + OFFSET_RBR)
87-
#define SIR_UART_GET_DLL(port) bfin_read16((port)->membase + OFFSET_DLL)
88-
#define SIR_UART_GET_DLH(port) bfin_read16((port)->membase + OFFSET_DLH)
89-
#define SIR_UART_GET_LCR(port) bfin_read16((port)->membase + OFFSET_LCR)
90-
#define SIR_UART_GET_GCTL(port) bfin_read16((port)->membase + OFFSET_GCTL)
91-
92-
#define SIR_UART_PUT_CHAR(port, v) bfin_write16(((port)->membase + OFFSET_THR), v)
93-
#define SIR_UART_PUT_DLL(port, v) bfin_write16(((port)->membase + OFFSET_DLL), v)
94-
#define SIR_UART_PUT_DLH(port, v) bfin_write16(((port)->membase + OFFSET_DLH), v)
95-
#define SIR_UART_PUT_LCR(port, v) bfin_write16(((port)->membase + OFFSET_LCR), v)
96-
#define SIR_UART_PUT_GCTL(port, v) bfin_write16(((port)->membase + OFFSET_GCTL), v)
97-
98-
#ifdef CONFIG_BF54x
99-
#define SIR_UART_GET_LSR(port) bfin_read16((port)->membase + OFFSET_LSR)
100-
#define SIR_UART_GET_IER(port) bfin_read16((port)->membase + OFFSET_IER_SET)
101-
#define SIR_UART_SET_IER(port, v) bfin_write16(((port)->membase + OFFSET_IER_SET), v)
102-
#define SIR_UART_CLEAR_IER(port, v) bfin_write16(((port)->membase + OFFSET_IER_CLEAR), v)
103-
#define SIR_UART_PUT_LSR(port, v) bfin_write16(((port)->membase + OFFSET_LSR), v)
104-
#define SIR_UART_CLEAR_LSR(port) bfin_write16(((port)->membase + OFFSET_LSR), -1)
105-
106-
#define SIR_UART_SET_DLAB(port)
107-
#define SIR_UART_CLEAR_DLAB(port)
108-
109-
#define SIR_UART_ENABLE_INTS(port, v) SIR_UART_SET_IER(port, v)
110-
#define SIR_UART_DISABLE_INTS(port) SIR_UART_CLEAR_IER(port, 0xF)
111-
#define SIR_UART_STOP_TX(port) do { SIR_UART_PUT_LSR(port, TFI); SIR_UART_CLEAR_IER(port, ETBEI); } while (0)
112-
#define SIR_UART_ENABLE_TX(port) do { SIR_UART_SET_IER(port, ETBEI); } while (0)
113-
#define SIR_UART_STOP_RX(port) do { SIR_UART_CLEAR_IER(port, ERBFI); } while (0)
114-
#define SIR_UART_ENABLE_RX(port) do { SIR_UART_SET_IER(port, ERBFI); } while (0)
115-
#else
116-
117-
#define SIR_UART_GET_IIR(port) bfin_read16((port)->membase + OFFSET_IIR)
118-
#define SIR_UART_GET_IER(port) bfin_read16((port)->membase + OFFSET_IER)
119-
#define SIR_UART_PUT_IER(port, v) bfin_write16(((port)->membase + OFFSET_IER), v)
120-
121-
#define SIR_UART_SET_DLAB(port) do { SIR_UART_PUT_LCR(port, SIR_UART_GET_LCR(port) | DLAB); } while (0)
122-
#define SIR_UART_CLEAR_DLAB(port) do { SIR_UART_PUT_LCR(port, SIR_UART_GET_LCR(port) & ~DLAB); } while (0)
123-
124-
#define SIR_UART_ENABLE_INTS(port, v) SIR_UART_PUT_IER(port, v)
125-
#define SIR_UART_DISABLE_INTS(port) SIR_UART_PUT_IER(port, 0)
126-
#define SIR_UART_STOP_TX(port) do { SIR_UART_PUT_IER(port, SIR_UART_GET_IER(port) & ~ETBEI); } while (0)
127-
#define SIR_UART_ENABLE_TX(port) do { SIR_UART_PUT_IER(port, SIR_UART_GET_IER(port) | ETBEI); } while (0)
128-
#define SIR_UART_STOP_RX(port) do { SIR_UART_PUT_IER(port, SIR_UART_GET_IER(port) & ~ERBFI); } while (0)
129-
#define SIR_UART_ENABLE_RX(port) do { SIR_UART_PUT_IER(port, SIR_UART_GET_IER(port) | ERBFI); } while (0)
130-
131-
static inline unsigned int SIR_UART_GET_LSR(struct bfin_sir_port *port)
132-
{
133-
unsigned int lsr = bfin_read16(port->membase + OFFSET_LSR);
134-
port->lsr |= (lsr & (BI|FE|PE|OE));
135-
return lsr | port->lsr;
136-
}
137-
138-
static inline void SIR_UART_CLEAR_LSR(struct bfin_sir_port *port)
139-
{
140-
port->lsr = 0;
141-
bfin_read16(port->membase + OFFSET_LSR);
142-
}
143-
#endif
85+
#define port_membase(port) (((struct bfin_sir_port *)(port))->membase)
86+
#define get_lsr_cache(port) (((struct bfin_sir_port *)(port))->lsr)
87+
#define put_lsr_cache(port, v) (((struct bfin_sir_port *)(port))->lsr = (v))
88+
#include <asm/bfin_serial.h>
14489

14590
static const unsigned short per[][4] = {
14691
/* rx pin tx pin NULL uart_number */

0 commit comments

Comments
 (0)