66
66
#define SYSLOCK_SLEEP_TIMEOUT 100
67
67
#define SYSLOCK_RETRY_CNT 1000
68
68
69
+ #define UART_RX_BYTE_FIFO 0x00
70
+ #define UART_FIFO_CTL 0x02
71
+
69
72
#define UART_ACTV_REG 0x11
70
73
#define UART_BLOCK_SET_ACTIVE BIT(0)
71
74
96
99
#define UART_RESET_REG 0x94
97
100
#define UART_RESET_D3_RESET_DISABLE BIT(16)
98
101
102
+ #define UART_BURST_STATUS_REG 0x9C
103
+ #define UART_RX_BURST_FIFO 0xA4
104
+
99
105
#define MAX_PORTS 4
100
106
#define PORT_OFFSET 0x100
107
+ #define RX_BUF_SIZE 512
108
+ #define UART_BYTE_SIZE 1
109
+ #define UART_BURST_SIZE 4
110
+
111
+ #define UART_BST_STAT_RX_COUNT_MASK 0x00FF
112
+ #define UART_BST_STAT_IIR_INT_PEND 0x100000
113
+ #define UART_LSR_OVERRUN_ERR_CLR 0x43
114
+ #define UART_BST_STAT_LSR_RX_MASK 0x9F000000
115
+ #define UART_BST_STAT_LSR_RX_ERR_MASK 0x9E000000
116
+ #define UART_BST_STAT_LSR_OVERRUN_ERR 0x2000000
117
+ #define UART_BST_STAT_LSR_PARITY_ERR 0x4000000
118
+ #define UART_BST_STAT_LSR_FRAME_ERR 0x8000000
101
119
102
120
struct pci1xxxx_8250 {
103
121
unsigned int nr ;
@@ -249,6 +267,103 @@ static int pci1xxxx_rs485_config(struct uart_port *port,
249
267
return 0 ;
250
268
}
251
269
270
+ static u32 pci1xxxx_read_burst_status (struct uart_port * port )
271
+ {
272
+ u32 status ;
273
+
274
+ status = readl (port -> membase + UART_BURST_STATUS_REG );
275
+ if (status & UART_BST_STAT_LSR_RX_ERR_MASK ) {
276
+ if (status & UART_BST_STAT_LSR_OVERRUN_ERR ) {
277
+ writeb (UART_LSR_OVERRUN_ERR_CLR ,
278
+ port -> membase + UART_FIFO_CTL );
279
+ port -> icount .overrun ++ ;
280
+ }
281
+
282
+ if (status & UART_BST_STAT_LSR_FRAME_ERR )
283
+ port -> icount .frame ++ ;
284
+
285
+ if (status & UART_BST_STAT_LSR_PARITY_ERR )
286
+ port -> icount .parity ++ ;
287
+ }
288
+ return status ;
289
+ }
290
+
291
+ static void pci1xxxx_process_read_data (struct uart_port * port ,
292
+ unsigned char * rx_buff , u32 * buff_index ,
293
+ u32 * valid_byte_count )
294
+ {
295
+ u32 valid_burst_count = * valid_byte_count / UART_BURST_SIZE ;
296
+ u32 * burst_buf ;
297
+
298
+ /*
299
+ * Depending on the RX Trigger Level the number of bytes that can be
300
+ * stored in RX FIFO at a time varies. Each transaction reads data
301
+ * in DWORDs. If there are less than four remaining valid_byte_count
302
+ * to read, the data is received one byte at a time.
303
+ */
304
+ while (valid_burst_count -- ) {
305
+ if (* buff_index > (RX_BUF_SIZE - UART_BURST_SIZE ))
306
+ break ;
307
+ burst_buf = (u32 * )& rx_buff [* buff_index ];
308
+ * burst_buf = readl (port -> membase + UART_RX_BURST_FIFO );
309
+ * buff_index += UART_BURST_SIZE ;
310
+ * valid_byte_count -= UART_BURST_SIZE ;
311
+ }
312
+
313
+ while (* valid_byte_count ) {
314
+ if (* buff_index > RX_BUF_SIZE )
315
+ break ;
316
+ rx_buff [* buff_index ] = readb (port -> membase +
317
+ UART_RX_BYTE_FIFO );
318
+ * buff_index += UART_BYTE_SIZE ;
319
+ * valid_byte_count -= UART_BYTE_SIZE ;
320
+ }
321
+ }
322
+
323
+ static void pci1xxxx_rx_burst (struct uart_port * port , u32 uart_status )
324
+ {
325
+ u32 valid_byte_count = uart_status & UART_BST_STAT_RX_COUNT_MASK ;
326
+ struct tty_port * tty_port = & port -> state -> port ;
327
+ unsigned char rx_buff [RX_BUF_SIZE ];
328
+ u32 buff_index = 0 ;
329
+ u32 copied_len ;
330
+
331
+ if (valid_byte_count != 0 &&
332
+ valid_byte_count < RX_BUF_SIZE ) {
333
+ pci1xxxx_process_read_data (port , rx_buff , & buff_index ,
334
+ & valid_byte_count );
335
+
336
+ copied_len = (u32 )tty_insert_flip_string (tty_port , rx_buff ,
337
+ buff_index );
338
+
339
+ if (copied_len != buff_index )
340
+ port -> icount .overrun += buff_index - copied_len ;
341
+
342
+ port -> icount .rx += buff_index ;
343
+ tty_flip_buffer_push (tty_port );
344
+ }
345
+ }
346
+
347
+ static int pci1xxxx_handle_irq (struct uart_port * port )
348
+ {
349
+ unsigned long flags ;
350
+ u32 status ;
351
+
352
+ status = pci1xxxx_read_burst_status (port );
353
+
354
+ if (status & UART_BST_STAT_IIR_INT_PEND )
355
+ return 0 ;
356
+
357
+ spin_lock_irqsave (& port -> lock , flags );
358
+
359
+ if (status & UART_BST_STAT_LSR_RX_MASK )
360
+ pci1xxxx_rx_burst (port , status );
361
+
362
+ spin_unlock_irqrestore (& port -> lock , flags );
363
+
364
+ return 1 ;
365
+ }
366
+
252
367
static bool pci1xxxx_port_suspend (int line )
253
368
{
254
369
struct uart_8250_port * up = serial8250_get_port (line );
@@ -360,7 +475,7 @@ static int pci1xxxx_resume(struct device *dev)
360
475
}
361
476
362
477
static int pci1xxxx_setup (struct pci_dev * pdev ,
363
- struct uart_8250_port * port , int port_idx )
478
+ struct uart_8250_port * port , int port_idx , int rev )
364
479
{
365
480
int ret ;
366
481
@@ -372,6 +487,10 @@ static int pci1xxxx_setup(struct pci_dev *pdev,
372
487
port -> port .rs485_config = pci1xxxx_rs485_config ;
373
488
port -> port .rs485_supported = pci1xxxx_rs485_supported ;
374
489
490
+ /* From C0 rev Burst operation is supported */
491
+ if (rev >= 0xC0 )
492
+ port -> port .handle_irq = pci1xxxx_handle_irq ;
493
+
375
494
ret = serial8250_pci_setup_port (pdev , port , 0 , PORT_OFFSET * port_idx , 0 );
376
495
if (ret < 0 )
377
496
return ret ;
@@ -491,7 +610,7 @@ static int pci1xxxx_serial_probe(struct pci_dev *pdev,
491
610
else
492
611
uart .port .irq = pci_irq_vector (pdev , 0 );
493
612
494
- rc = pci1xxxx_setup (pdev , & uart , port_idx );
613
+ rc = pci1xxxx_setup (pdev , & uart , port_idx , priv -> dev_rev );
495
614
if (rc ) {
496
615
dev_warn (dev , "Failed to setup port %u\n" , i );
497
616
continue ;
0 commit comments