aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
Diffstat (limited to 'drivers')
-rw-r--r--drivers/mmc/Kconfig2
-rw-r--r--drivers/mmc/wbsd.c716
-rw-r--r--drivers/mmc/wbsd.h12
-rw-r--r--drivers/serial/21285.c14
-rw-r--r--drivers/serial/8250.c15
-rw-r--r--drivers/serial/amba-pl010.c14
-rw-r--r--drivers/serial/amba-pl011.c14
-rw-r--r--drivers/serial/clps711x.c5
-rw-r--r--drivers/serial/pxa.c16
-rw-r--r--drivers/serial/s3c2410.c15
-rw-r--r--drivers/serial/sa1100.c5
-rw-r--r--drivers/serial/serial_lh7a40x.c13
-rw-r--r--drivers/serial/serial_txx9.c15
-rw-r--r--drivers/serial/vr41xx_siu.c6
14 files changed, 566 insertions, 296 deletions
diff --git a/drivers/mmc/Kconfig b/drivers/mmc/Kconfig
index 2e70d74fbdee..4991bbd054f3 100644
--- a/drivers/mmc/Kconfig
+++ b/drivers/mmc/Kconfig
@@ -51,7 +51,7 @@ config MMC_PXA
51 51
52config MMC_WBSD 52config MMC_WBSD
53 tristate "Winbond W83L51xD SD/MMC Card Interface support" 53 tristate "Winbond W83L51xD SD/MMC Card Interface support"
54 depends on MMC && ISA && ISA_DMA_API 54 depends on MMC && ISA_DMA_API
55 help 55 help
56 This selects the Winbond(R) W83L51xD Secure digital and 56 This selects the Winbond(R) W83L51xD Secure digital and
57 Multimedia card Interface. 57 Multimedia card Interface.
diff --git a/drivers/mmc/wbsd.c b/drivers/mmc/wbsd.c
index 39747526c719..b7fbd30b49a0 100644
--- a/drivers/mmc/wbsd.c
+++ b/drivers/mmc/wbsd.c
@@ -28,7 +28,9 @@
28#include <linux/ioport.h> 28#include <linux/ioport.h>
29#include <linux/device.h> 29#include <linux/device.h>
30#include <linux/interrupt.h> 30#include <linux/interrupt.h>
31#include <linux/dma-mapping.h>
31#include <linux/delay.h> 32#include <linux/delay.h>
33#include <linux/pnp.h>
32#include <linux/highmem.h> 34#include <linux/highmem.h>
33#include <linux/mmc/host.h> 35#include <linux/mmc/host.h>
34#include <linux/mmc/protocol.h> 36#include <linux/mmc/protocol.h>
@@ -40,7 +42,7 @@
40#include "wbsd.h" 42#include "wbsd.h"
41 43
42#define DRIVER_NAME "wbsd" 44#define DRIVER_NAME "wbsd"
43#define DRIVER_VERSION "1.1" 45#define DRIVER_VERSION "1.2"
44 46
45#ifdef CONFIG_MMC_DEBUG 47#ifdef CONFIG_MMC_DEBUG
46#define DBG(x...) \ 48#define DBG(x...) \
@@ -52,10 +54,6 @@
52#define DBGF(x...) do { } while (0) 54#define DBGF(x...) do { } while (0)
53#endif 55#endif
54 56
55static unsigned int io = 0x248;
56static unsigned int irq = 6;
57static int dma = 2;
58
59#ifdef CONFIG_MMC_DEBUG 57#ifdef CONFIG_MMC_DEBUG
60void DBG_REG(int reg, u8 value) 58void DBG_REG(int reg, u8 value)
61{ 59{
@@ -79,28 +77,61 @@ void DBG_REG(int reg, u8 value)
79#endif 77#endif
80 78
81/* 79/*
80 * Device resources
81 */
82
83#ifdef CONFIG_PNP
84
85static const struct pnp_device_id pnp_dev_table[] = {
86 { "WEC0517", 0 },
87 { "WEC0518", 0 },
88 { "", 0 },
89};
90
91MODULE_DEVICE_TABLE(pnp, pnp_dev_table);
92
93#endif /* CONFIG_PNP */
94
95#ifdef CONFIG_PNP
96static unsigned int nopnp = 0;
97#else
98static const unsigned int nopnp = 1;
99#endif
100static unsigned int io = 0x248;
101static unsigned int irq = 6;
102static int dma = 2;
103
104/*
82 * Basic functions 105 * Basic functions
83 */ 106 */
84 107
85static inline void wbsd_unlock_config(struct wbsd_host* host) 108static inline void wbsd_unlock_config(struct wbsd_host* host)
86{ 109{
110 BUG_ON(host->config == 0);
111
87 outb(host->unlock_code, host->config); 112 outb(host->unlock_code, host->config);
88 outb(host->unlock_code, host->config); 113 outb(host->unlock_code, host->config);
89} 114}
90 115
91static inline void wbsd_lock_config(struct wbsd_host* host) 116static inline void wbsd_lock_config(struct wbsd_host* host)
92{ 117{
118 BUG_ON(host->config == 0);
119
93 outb(LOCK_CODE, host->config); 120 outb(LOCK_CODE, host->config);
94} 121}
95 122
96static inline void wbsd_write_config(struct wbsd_host* host, u8 reg, u8 value) 123static inline void wbsd_write_config(struct wbsd_host* host, u8 reg, u8 value)
97{ 124{
125 BUG_ON(host->config == 0);
126
98 outb(reg, host->config); 127 outb(reg, host->config);
99 outb(value, host->config + 1); 128 outb(value, host->config + 1);
100} 129}
101 130
102static inline u8 wbsd_read_config(struct wbsd_host* host, u8 reg) 131static inline u8 wbsd_read_config(struct wbsd_host* host, u8 reg)
103{ 132{
133 BUG_ON(host->config == 0);
134
104 outb(reg, host->config); 135 outb(reg, host->config);
105 return inb(host->config + 1); 136 return inb(host->config + 1);
106} 137}
@@ -133,6 +164,13 @@ static void wbsd_init_device(struct wbsd_host* host)
133 wbsd_write_index(host, WBSD_IDX_SETUP, setup); 164 wbsd_write_index(host, WBSD_IDX_SETUP, setup);
134 165
135 /* 166 /*
167 * Set DAT3 to input
168 */
169 setup &= ~WBSD_DAT3_H;
170 wbsd_write_index(host, WBSD_IDX_SETUP, setup);
171 host->flags &= ~WBSD_FIGNORE_DETECT;
172
173 /*
136 * Read back default clock. 174 * Read back default clock.
137 */ 175 */
138 host->clk = wbsd_read_index(host, WBSD_IDX_CLK); 176 host->clk = wbsd_read_index(host, WBSD_IDX_CLK);
@@ -148,6 +186,14 @@ static void wbsd_init_device(struct wbsd_host* host)
148 wbsd_write_index(host, WBSD_IDX_TAAC, 0x7F); 186 wbsd_write_index(host, WBSD_IDX_TAAC, 0x7F);
149 187
150 /* 188 /*
189 * Test for card presence
190 */
191 if (inb(host->base + WBSD_CSR) & WBSD_CARDPRESENT)
192 host->flags |= WBSD_FCARD_PRESENT;
193 else
194 host->flags &= ~WBSD_FCARD_PRESENT;
195
196 /*
151 * Enable interesting interrupts. 197 * Enable interesting interrupts.
152 */ 198 */
153 ier = 0; 199 ier = 0;
@@ -407,8 +453,6 @@ static inline void wbsd_get_long_reply(struct wbsd_host* host,
407 } 453 }
408} 454}
409 455
410static irqreturn_t wbsd_irq(int irq, void *dev_id, struct pt_regs *regs);
411
412static void wbsd_send_command(struct wbsd_host* host, struct mmc_command* cmd) 456static void wbsd_send_command(struct wbsd_host* host, struct mmc_command* cmd)
413{ 457{
414 int i; 458 int i;
@@ -646,6 +690,13 @@ static void wbsd_fill_fifo(struct wbsd_host* host)
646 } 690 }
647 691
648 wbsd_kunmap_sg(host); 692 wbsd_kunmap_sg(host);
693
694 /*
695 * The controller stops sending interrupts for
696 * 'FIFO empty' under certain conditions. So we
697 * need to be a bit more pro-active.
698 */
699 tasklet_schedule(&host->fifo_tasklet);
649} 700}
650 701
651static void wbsd_prepare_data(struct wbsd_host* host, struct mmc_data* data) 702static void wbsd_prepare_data(struct wbsd_host* host, struct mmc_data* data)
@@ -850,9 +901,11 @@ static void wbsd_finish_data(struct wbsd_host* host, struct mmc_data* data)
850 wbsd_request_end(host, host->mrq); 901 wbsd_request_end(host, host->mrq);
851} 902}
852 903
853/* 904/*****************************************************************************\
854 * MMC Callbacks 905 * *
855 */ 906 * MMC layer callbacks *
907 * *
908\*****************************************************************************/
856 909
857static void wbsd_request(struct mmc_host* mmc, struct mmc_request* mrq) 910static void wbsd_request(struct mmc_host* mmc, struct mmc_request* mrq)
858{ 911{
@@ -874,7 +927,7 @@ static void wbsd_request(struct mmc_host* mmc, struct mmc_request* mrq)
874 * If there is no card in the slot then 927 * If there is no card in the slot then
875 * timeout immediatly. 928 * timeout immediatly.
876 */ 929 */
877 if (!(inb(host->base + WBSD_CSR) & WBSD_CARDPRESENT)) 930 if (!(host->flags & WBSD_FCARD_PRESENT))
878 { 931 {
879 cmd->error = MMC_ERR_TIMEOUT; 932 cmd->error = MMC_ERR_TIMEOUT;
880 goto done; 933 goto done;
@@ -953,33 +1006,50 @@ static void wbsd_set_ios(struct mmc_host* mmc, struct mmc_ios* ios)
953 host->clk = clk; 1006 host->clk = clk;
954 } 1007 }
955 1008
1009 /*
1010 * Power up card.
1011 */
956 if (ios->power_mode != MMC_POWER_OFF) 1012 if (ios->power_mode != MMC_POWER_OFF)
957 { 1013 {
958 /*
959 * Power up card.
960 */
961 pwr = inb(host->base + WBSD_CSR); 1014 pwr = inb(host->base + WBSD_CSR);
962 pwr &= ~WBSD_POWER_N; 1015 pwr &= ~WBSD_POWER_N;
963 outb(pwr, host->base + WBSD_CSR); 1016 outb(pwr, host->base + WBSD_CSR);
964
965 /*
966 * This behaviour is stolen from the
967 * Windows driver. Don't know why, but
968 * it is needed.
969 */
970 setup = wbsd_read_index(host, WBSD_IDX_SETUP);
971 if (ios->bus_mode == MMC_BUSMODE_OPENDRAIN)
972 setup |= WBSD_DAT3_H;
973 else
974 setup &= ~WBSD_DAT3_H;
975 wbsd_write_index(host, WBSD_IDX_SETUP, setup);
976
977 mdelay(1);
978 } 1017 }
979 1018
1019 /*
1020 * MMC cards need to have pin 1 high during init.
1021 * Init time corresponds rather nicely with the bus mode.
1022 * It wreaks havoc with the card detection though so
1023 * that needs to be disabed.
1024 */
1025 setup = wbsd_read_index(host, WBSD_IDX_SETUP);
1026 if ((ios->power_mode == MMC_POWER_ON) &&
1027 (ios->bus_mode == MMC_BUSMODE_OPENDRAIN))
1028 {
1029 setup |= WBSD_DAT3_H;
1030 host->flags |= WBSD_FIGNORE_DETECT;
1031 }
1032 else
1033 {
1034 setup &= ~WBSD_DAT3_H;
1035 host->flags &= ~WBSD_FIGNORE_DETECT;
1036 }
1037 wbsd_write_index(host, WBSD_IDX_SETUP, setup);
1038
980 spin_unlock_bh(&host->lock); 1039 spin_unlock_bh(&host->lock);
981} 1040}
982 1041
1042static struct mmc_host_ops wbsd_ops = {
1043 .request = wbsd_request,
1044 .set_ios = wbsd_set_ios,
1045};
1046
1047/*****************************************************************************\
1048 * *
1049 * Interrupt handling *
1050 * *
1051\*****************************************************************************/
1052
983/* 1053/*
984 * Tasklets 1054 * Tasklets
985 */ 1055 */
@@ -1005,17 +1075,33 @@ static void wbsd_tasklet_card(unsigned long param)
1005{ 1075{
1006 struct wbsd_host* host = (struct wbsd_host*)param; 1076 struct wbsd_host* host = (struct wbsd_host*)param;
1007 u8 csr; 1077 u8 csr;
1078 int change = 0;
1008 1079
1009 spin_lock(&host->lock); 1080 spin_lock(&host->lock);
1010 1081
1082 if (host->flags & WBSD_FIGNORE_DETECT)
1083 {
1084 spin_unlock(&host->lock);
1085 return;
1086 }
1087
1011 csr = inb(host->base + WBSD_CSR); 1088 csr = inb(host->base + WBSD_CSR);
1012 WARN_ON(csr == 0xff); 1089 WARN_ON(csr == 0xff);
1013 1090
1014 if (csr & WBSD_CARDPRESENT) 1091 if (csr & WBSD_CARDPRESENT)
1015 DBG("Card inserted\n"); 1092 {
1016 else 1093 if (!(host->flags & WBSD_FCARD_PRESENT))
1094 {
1095 DBG("Card inserted\n");
1096 host->flags |= WBSD_FCARD_PRESENT;
1097 change = 1;
1098 }
1099 }
1100 else if (host->flags & WBSD_FCARD_PRESENT)
1017 { 1101 {
1018 DBG("Card removed\n"); 1102 DBG("Card removed\n");
1103 host->flags &= ~WBSD_FCARD_PRESENT;
1104 change = 1;
1019 1105
1020 if (host->mrq) 1106 if (host->mrq)
1021 { 1107 {
@@ -1033,7 +1119,8 @@ static void wbsd_tasklet_card(unsigned long param)
1033 */ 1119 */
1034 spin_unlock(&host->lock); 1120 spin_unlock(&host->lock);
1035 1121
1036 mmc_detect_change(host->mmc); 1122 if (change)
1123 mmc_detect_change(host->mmc);
1037} 1124}
1038 1125
1039static void wbsd_tasklet_fifo(unsigned long param) 1126static void wbsd_tasklet_fifo(unsigned long param)
@@ -1200,11 +1287,85 @@ static irqreturn_t wbsd_irq(int irq, void *dev_id, struct pt_regs *regs)
1200 return IRQ_HANDLED; 1287 return IRQ_HANDLED;
1201} 1288}
1202 1289
1290/*****************************************************************************\
1291 * *
1292 * Device initialisation and shutdown *
1293 * *
1294\*****************************************************************************/
1295
1203/* 1296/*
1204 * Support functions for probe 1297 * Allocate/free MMC structure.
1205 */ 1298 */
1206 1299
1207static int wbsd_scan(struct wbsd_host* host) 1300static int __devinit wbsd_alloc_mmc(struct device* dev)
1301{
1302 struct mmc_host* mmc;
1303 struct wbsd_host* host;
1304
1305 /*
1306 * Allocate MMC structure.
1307 */
1308 mmc = mmc_alloc_host(sizeof(struct wbsd_host), dev);
1309 if (!mmc)
1310 return -ENOMEM;
1311
1312 host = mmc_priv(mmc);
1313 host->mmc = mmc;
1314
1315 host->dma = -1;
1316
1317 /*
1318 * Set host parameters.
1319 */
1320 mmc->ops = &wbsd_ops;
1321 mmc->f_min = 375000;
1322 mmc->f_max = 24000000;
1323 mmc->ocr_avail = MMC_VDD_32_33|MMC_VDD_33_34;
1324
1325 spin_lock_init(&host->lock);
1326
1327 /*
1328 * Maximum number of segments. Worst case is one sector per segment
1329 * so this will be 64kB/512.
1330 */
1331 mmc->max_hw_segs = 128;
1332 mmc->max_phys_segs = 128;
1333
1334 /*
1335 * Maximum number of sectors in one transfer. Also limited by 64kB
1336 * buffer.
1337 */
1338 mmc->max_sectors = 128;
1339
1340 /*
1341 * Maximum segment size. Could be one segment with the maximum number
1342 * of segments.
1343 */
1344 mmc->max_seg_size = mmc->max_sectors * 512;
1345
1346 dev_set_drvdata(dev, mmc);
1347
1348 return 0;
1349}
1350
1351static void __devexit wbsd_free_mmc(struct device* dev)
1352{
1353 struct mmc_host* mmc;
1354
1355 mmc = dev_get_drvdata(dev);
1356 if (!mmc)
1357 return;
1358
1359 mmc_free_host(mmc);
1360
1361 dev_set_drvdata(dev, NULL);
1362}
1363
1364/*
1365 * Scan for known chip id:s
1366 */
1367
1368static int __devinit wbsd_scan(struct wbsd_host* host)
1208{ 1369{
1209 int i, j, k; 1370 int i, j, k;
1210 int id; 1371 int id;
@@ -1258,12 +1419,16 @@ static int wbsd_scan(struct wbsd_host* host)
1258 return -ENODEV; 1419 return -ENODEV;
1259} 1420}
1260 1421
1261static int wbsd_request_regions(struct wbsd_host* host) 1422/*
1423 * Allocate/free io port ranges
1424 */
1425
1426static int __devinit wbsd_request_region(struct wbsd_host* host, int base)
1262{ 1427{
1263 if (io & 0x7) 1428 if (io & 0x7)
1264 return -EINVAL; 1429 return -EINVAL;
1265 1430
1266 if (!request_region(io, 8, DRIVER_NAME)) 1431 if (!request_region(base, 8, DRIVER_NAME))
1267 return -EIO; 1432 return -EIO;
1268 1433
1269 host->base = io; 1434 host->base = io;
@@ -1271,19 +1436,25 @@ static int wbsd_request_regions(struct wbsd_host* host)
1271 return 0; 1436 return 0;
1272} 1437}
1273 1438
1274static void wbsd_release_regions(struct wbsd_host* host) 1439static void __devexit wbsd_release_regions(struct wbsd_host* host)
1275{ 1440{
1276 if (host->base) 1441 if (host->base)
1277 release_region(host->base, 8); 1442 release_region(host->base, 8);
1443
1444 host->base = 0;
1278 1445
1279 if (host->config) 1446 if (host->config)
1280 release_region(host->config, 2); 1447 release_region(host->config, 2);
1448
1449 host->config = 0;
1281} 1450}
1282 1451
1283static void wbsd_init_dma(struct wbsd_host* host) 1452/*
1453 * Allocate/free DMA port and buffer
1454 */
1455
1456static void __devinit wbsd_request_dma(struct wbsd_host* host, int dma)
1284{ 1457{
1285 host->dma = -1;
1286
1287 if (dma < 0) 1458 if (dma < 0)
1288 return; 1459 return;
1289 1460
@@ -1294,7 +1465,7 @@ static void wbsd_init_dma(struct wbsd_host* host)
1294 * We need to allocate a special buffer in 1465 * We need to allocate a special buffer in
1295 * order for ISA to be able to DMA to it. 1466 * order for ISA to be able to DMA to it.
1296 */ 1467 */
1297 host->dma_buffer = kmalloc(65536, 1468 host->dma_buffer = kmalloc(WBSD_DMA_SIZE,
1298 GFP_NOIO | GFP_DMA | __GFP_REPEAT | __GFP_NOWARN); 1469 GFP_NOIO | GFP_DMA | __GFP_REPEAT | __GFP_NOWARN);
1299 if (!host->dma_buffer) 1470 if (!host->dma_buffer)
1300 goto free; 1471 goto free;
@@ -1302,7 +1473,8 @@ static void wbsd_init_dma(struct wbsd_host* host)
1302 /* 1473 /*
1303 * Translate the address to a physical address. 1474 * Translate the address to a physical address.
1304 */ 1475 */
1305 host->dma_addr = isa_virt_to_bus(host->dma_buffer); 1476 host->dma_addr = dma_map_single(host->mmc->dev, host->dma_buffer,
1477 WBSD_DMA_SIZE, DMA_BIDIRECTIONAL);
1306 1478
1307 /* 1479 /*
1308 * ISA DMA must be aligned on a 64k basis. 1480 * ISA DMA must be aligned on a 64k basis.
@@ -1325,6 +1497,10 @@ kfree:
1325 */ 1497 */
1326 BUG_ON(1); 1498 BUG_ON(1);
1327 1499
1500 dma_unmap_single(host->mmc->dev, host->dma_addr, WBSD_DMA_SIZE,
1501 DMA_BIDIRECTIONAL);
1502 host->dma_addr = (dma_addr_t)NULL;
1503
1328 kfree(host->dma_buffer); 1504 kfree(host->dma_buffer);
1329 host->dma_buffer = NULL; 1505 host->dma_buffer = NULL;
1330 1506
@@ -1336,60 +1512,122 @@ err:
1336 "Falling back on FIFO.\n", dma); 1512 "Falling back on FIFO.\n", dma);
1337} 1513}
1338 1514
1339static struct mmc_host_ops wbsd_ops = { 1515static void __devexit wbsd_release_dma(struct wbsd_host* host)
1340 .request = wbsd_request, 1516{
1341 .set_ios = wbsd_set_ios, 1517 if (host->dma_addr)
1342}; 1518 dma_unmap_single(host->mmc->dev, host->dma_addr, WBSD_DMA_SIZE,
1519 DMA_BIDIRECTIONAL);
1520 if (host->dma_buffer)
1521 kfree(host->dma_buffer);
1522 if (host->dma >= 0)
1523 free_dma(host->dma);
1524
1525 host->dma = -1;
1526 host->dma_buffer = NULL;
1527 host->dma_addr = (dma_addr_t)NULL;
1528}
1343 1529
1344/* 1530/*
1345 * Device probe 1531 * Allocate/free IRQ.
1346 */ 1532 */
1347 1533
1348static int wbsd_probe(struct device* dev) 1534static int __devinit wbsd_request_irq(struct wbsd_host* host, int irq)
1349{ 1535{
1350 struct wbsd_host* host = NULL;
1351 struct mmc_host* mmc = NULL;
1352 int ret; 1536 int ret;
1353 1537
1354 /* 1538 /*
1355 * Allocate MMC structure. 1539 * Allocate interrupt.
1356 */ 1540 */
1357 mmc = mmc_alloc_host(sizeof(struct wbsd_host), dev); 1541
1358 if (!mmc) 1542 ret = request_irq(irq, wbsd_irq, SA_SHIRQ, DRIVER_NAME, host);
1359 return -ENOMEM; 1543 if (ret)
1360 1544 return ret;
1361 host = mmc_priv(mmc);
1362 host->mmc = mmc;
1363 1545
1546 host->irq = irq;
1547
1364 /* 1548 /*
1365 * Scan for hardware. 1549 * Set up tasklets.
1366 */ 1550 */
1367 ret = wbsd_scan(host); 1551 tasklet_init(&host->card_tasklet, wbsd_tasklet_card, (unsigned long)host);
1368 if (ret) 1552 tasklet_init(&host->fifo_tasklet, wbsd_tasklet_fifo, (unsigned long)host);
1369 goto freemmc; 1553 tasklet_init(&host->crc_tasklet, wbsd_tasklet_crc, (unsigned long)host);
1554 tasklet_init(&host->timeout_tasklet, wbsd_tasklet_timeout, (unsigned long)host);
1555 tasklet_init(&host->finish_tasklet, wbsd_tasklet_finish, (unsigned long)host);
1556 tasklet_init(&host->block_tasklet, wbsd_tasklet_block, (unsigned long)host);
1557
1558 return 0;
1559}
1370 1560
1371 /* 1561static void __devexit wbsd_release_irq(struct wbsd_host* host)
1372 * Reset the chip. 1562{
1373 */ 1563 if (!host->irq)
1374 wbsd_write_config(host, WBSD_CONF_SWRST, 1); 1564 return;
1375 wbsd_write_config(host, WBSD_CONF_SWRST, 0);
1376 1565
1566 free_irq(host->irq, host);
1567
1568 host->irq = 0;
1569
1570 tasklet_kill(&host->card_tasklet);
1571 tasklet_kill(&host->fifo_tasklet);
1572 tasklet_kill(&host->crc_tasklet);
1573 tasklet_kill(&host->timeout_tasklet);
1574 tasklet_kill(&host->finish_tasklet);
1575 tasklet_kill(&host->block_tasklet);
1576}
1577
1578/*
1579 * Allocate all resources for the host.
1580 */
1581
1582static int __devinit wbsd_request_resources(struct wbsd_host* host,
1583 int base, int irq, int dma)
1584{
1585 int ret;
1586
1377 /* 1587 /*
1378 * Allocate I/O ports. 1588 * Allocate I/O ports.
1379 */ 1589 */
1380 ret = wbsd_request_regions(host); 1590 ret = wbsd_request_region(host, base);
1381 if (ret) 1591 if (ret)
1382 goto release; 1592 return ret;
1383 1593
1384 /* 1594 /*
1385 * Set host parameters. 1595 * Allocate interrupt.
1386 */ 1596 */
1387 mmc->ops = &wbsd_ops; 1597 ret = wbsd_request_irq(host, irq);
1388 mmc->f_min = 375000; 1598 if (ret)
1389 mmc->f_max = 24000000; 1599 return ret;
1390 mmc->ocr_avail = MMC_VDD_32_33|MMC_VDD_33_34; 1600
1601 /*
1602 * Allocate DMA.
1603 */
1604 wbsd_request_dma(host, dma);
1391 1605
1392 spin_lock_init(&host->lock); 1606 return 0;
1607}
1608
1609/*
1610 * Release all resources for the host.
1611 */
1612
1613static void __devexit wbsd_release_resources(struct wbsd_host* host)
1614{
1615 wbsd_release_dma(host);
1616 wbsd_release_irq(host);
1617 wbsd_release_regions(host);
1618}
1619
1620/*
1621 * Configure the resources the chip should use.
1622 */
1623
1624static void __devinit wbsd_chip_config(struct wbsd_host* host)
1625{
1626 /*
1627 * Reset the chip.
1628 */
1629 wbsd_write_config(host, WBSD_CONF_SWRST, 1);
1630 wbsd_write_config(host, WBSD_CONF_SWRST, 0);
1393 1631
1394 /* 1632 /*
1395 * Select SD/MMC function. 1633 * Select SD/MMC function.
@@ -1399,165 +1637,241 @@ static int wbsd_probe(struct device* dev)
1399 /* 1637 /*
1400 * Set up card detection. 1638 * Set up card detection.
1401 */ 1639 */
1402 wbsd_write_config(host, WBSD_CONF_PINS, 0x02); 1640 wbsd_write_config(host, WBSD_CONF_PINS, WBSD_PINS_DETECT_GP11);
1403 1641
1404 /* 1642 /*
1405 * Configure I/O port. 1643 * Configure chip
1406 */ 1644 */
1407 wbsd_write_config(host, WBSD_CONF_PORT_HI, host->base >> 8); 1645 wbsd_write_config(host, WBSD_CONF_PORT_HI, host->base >> 8);
1408 wbsd_write_config(host, WBSD_CONF_PORT_LO, host->base & 0xff); 1646 wbsd_write_config(host, WBSD_CONF_PORT_LO, host->base & 0xff);
1409
1410 /*
1411 * Allocate interrupt.
1412 */
1413 ret = request_irq(irq, wbsd_irq, SA_SHIRQ, DRIVER_NAME, host);
1414 if (ret)
1415 goto release;
1416 1647
1417 host->irq = irq; 1648 wbsd_write_config(host, WBSD_CONF_IRQ, host->irq);
1418 1649
1419 /* 1650 if (host->dma >= 0)
1420 * Set up tasklets. 1651 wbsd_write_config(host, WBSD_CONF_DRQ, host->dma);
1421 */
1422 tasklet_init(&host->card_tasklet, wbsd_tasklet_card, (unsigned long)host);
1423 tasklet_init(&host->fifo_tasklet, wbsd_tasklet_fifo, (unsigned long)host);
1424 tasklet_init(&host->crc_tasklet, wbsd_tasklet_crc, (unsigned long)host);
1425 tasklet_init(&host->timeout_tasklet, wbsd_tasklet_timeout, (unsigned long)host);
1426 tasklet_init(&host->finish_tasklet, wbsd_tasklet_finish, (unsigned long)host);
1427 tasklet_init(&host->block_tasklet, wbsd_tasklet_block, (unsigned long)host);
1428 1652
1429 /* 1653 /*
1430 * Configure interrupt. 1654 * Enable and power up chip.
1431 */ 1655 */
1432 wbsd_write_config(host, WBSD_CONF_IRQ, host->irq); 1656 wbsd_write_config(host, WBSD_CONF_ENABLE, 1);
1657 wbsd_write_config(host, WBSD_CONF_POWER, 0x20);
1658}
1659
1660/*
1661 * Check that configured resources are correct.
1662 */
1663
1664static int __devinit wbsd_chip_validate(struct wbsd_host* host)
1665{
1666 int base, irq, dma;
1433 1667
1434 /* 1668 /*
1435 * Allocate DMA. 1669 * Select SD/MMC function.
1436 */ 1670 */
1437 wbsd_init_dma(host); 1671 wbsd_write_config(host, WBSD_CONF_DEVICE, DEVICE_SD);
1438 1672
1439 /* 1673 /*
1440 * If all went well, then configure DMA. 1674 * Read configuration.
1441 */ 1675 */
1442 if (host->dma >= 0) 1676 base = wbsd_read_config(host, WBSD_CONF_PORT_HI) << 8;
1443 wbsd_write_config(host, WBSD_CONF_DRQ, host->dma); 1677 base |= wbsd_read_config(host, WBSD_CONF_PORT_LO);
1444 1678
1445 /* 1679 irq = wbsd_read_config(host, WBSD_CONF_IRQ);
1446 * Maximum number of segments. Worst case is one sector per segment 1680
1447 * so this will be 64kB/512. 1681 dma = wbsd_read_config(host, WBSD_CONF_DRQ);
1448 */
1449 mmc->max_hw_segs = 128;
1450 mmc->max_phys_segs = 128;
1451 1682
1452 /* 1683 /*
1453 * Maximum number of sectors in one transfer. Also limited by 64kB 1684 * Validate against given configuration.
1454 * buffer.
1455 */ 1685 */
1456 mmc->max_sectors = 128; 1686 if (base != host->base)
1687 return 0;
1688 if (irq != host->irq)
1689 return 0;
1690 if ((dma != host->dma) && (host->dma != -1))
1691 return 0;
1692
1693 return 1;
1694}
1695
1696/*****************************************************************************\
1697 * *
1698 * Devices setup and shutdown *
1699 * *
1700\*****************************************************************************/
1701
1702static int __devinit wbsd_init(struct device* dev, int base, int irq, int dma,
1703 int pnp)
1704{
1705 struct wbsd_host* host = NULL;
1706 struct mmc_host* mmc = NULL;
1707 int ret;
1708
1709 ret = wbsd_alloc_mmc(dev);
1710 if (ret)
1711 return ret;
1712
1713 mmc = dev_get_drvdata(dev);
1714 host = mmc_priv(mmc);
1457 1715
1458 /* 1716 /*
1459 * Maximum segment size. Could be one segment with the maximum number 1717 * Scan for hardware.
1460 * of segments.
1461 */ 1718 */
1462 mmc->max_seg_size = mmc->max_sectors * 512; 1719 ret = wbsd_scan(host);
1720 if (ret)
1721 {
1722 if (pnp && (ret == -ENODEV))
1723 {
1724 printk(KERN_WARNING DRIVER_NAME
1725 ": Unable to confirm device presence. You may "
1726 "experience lock-ups.\n");
1727 }
1728 else
1729 {
1730 wbsd_free_mmc(dev);
1731 return ret;
1732 }
1733 }
1463 1734
1464 /* 1735 /*
1465 * Enable chip. 1736 * Request resources.
1466 */ 1737 */
1467 wbsd_write_config(host, WBSD_CONF_ENABLE, 1); 1738 ret = wbsd_request_resources(host, io, irq, dma);
1739 if (ret)
1740 {
1741 wbsd_release_resources(host);
1742 wbsd_free_mmc(dev);
1743 return ret;
1744 }
1468 1745
1469 /* 1746 /*
1470 * Power up chip. 1747 * See if chip needs to be configured.
1471 */ 1748 */
1472 wbsd_write_config(host, WBSD_CONF_POWER, 0x20); 1749 if (pnp && (host->config != 0))
1750 {
1751 if (!wbsd_chip_validate(host))
1752 {
1753 printk(KERN_WARNING DRIVER_NAME
1754 ": PnP active but chip not configured! "
1755 "You probably have a buggy BIOS. "
1756 "Configuring chip manually.\n");
1757 wbsd_chip_config(host);
1758 }
1759 }
1760 else
1761 wbsd_chip_config(host);
1473 1762
1474 /* 1763 /*
1475 * Power Management stuff. No idea how this works. 1764 * Power Management stuff. No idea how this works.
1476 * Not tested. 1765 * Not tested.
1477 */ 1766 */
1478#ifdef CONFIG_PM 1767#ifdef CONFIG_PM
1479 wbsd_write_config(host, WBSD_CONF_PME, 0xA0); 1768 if (host->config)
1769 wbsd_write_config(host, WBSD_CONF_PME, 0xA0);
1480#endif 1770#endif
1771 /*
1772 * Allow device to initialise itself properly.
1773 */
1774 mdelay(5);
1481 1775
1482 /* 1776 /*
1483 * Reset the chip into a known state. 1777 * Reset the chip into a known state.
1484 */ 1778 */
1485 wbsd_init_device(host); 1779 wbsd_init_device(host);
1486 1780
1487 dev_set_drvdata(dev, mmc);
1488
1489 /*
1490 * Add host to MMC layer.
1491 */
1492 mmc_add_host(mmc); 1781 mmc_add_host(mmc);
1493 1782
1494 printk(KERN_INFO "%s: W83L51xD id %x at 0x%x irq %d dma %d\n", 1783 printk(KERN_INFO "%s: W83L51xD", mmc->host_name);
1495 mmc->host_name, (int)host->chip_id, (int)host->base, 1784 if (host->chip_id != 0)
1496 (int)host->irq, (int)host->dma); 1785 printk(" id %x", (int)host->chip_id);
1786 printk(" at 0x%x irq %d", (int)host->base, (int)host->irq);
1787 if (host->dma >= 0)
1788 printk(" dma %d", (int)host->dma);
1789 else
1790 printk(" FIFO");
1791 if (pnp)
1792 printk(" PnP");
1793 printk("\n");
1497 1794
1498 return 0; 1795 return 0;
1499
1500release:
1501 wbsd_release_regions(host);
1502
1503freemmc:
1504 mmc_free_host(mmc);
1505
1506 return ret;
1507} 1796}
1508 1797
1509/* 1798static void __devexit wbsd_shutdown(struct device* dev, int pnp)
1510 * Device remove
1511 */
1512
1513static int wbsd_remove(struct device* dev)
1514{ 1799{
1515 struct mmc_host* mmc = dev_get_drvdata(dev); 1800 struct mmc_host* mmc = dev_get_drvdata(dev);
1516 struct wbsd_host* host; 1801 struct wbsd_host* host;
1517 1802
1518 if (!mmc) 1803 if (!mmc)
1519 return 0; 1804 return;
1520 1805
1521 host = mmc_priv(mmc); 1806 host = mmc_priv(mmc);
1522 1807
1523 /*
1524 * Unregister host with MMC layer.
1525 */
1526 mmc_remove_host(mmc); 1808 mmc_remove_host(mmc);
1527 1809
1528 /* 1810 if (!pnp)
1529 * Power down the SD/MMC function. 1811 {
1530 */ 1812 /*
1531 wbsd_unlock_config(host); 1813 * Power down the SD/MMC function.
1532 wbsd_write_config(host, WBSD_CONF_DEVICE, DEVICE_SD); 1814 */
1533 wbsd_write_config(host, WBSD_CONF_ENABLE, 0); 1815 wbsd_unlock_config(host);
1534 wbsd_lock_config(host); 1816 wbsd_write_config(host, WBSD_CONF_DEVICE, DEVICE_SD);
1817 wbsd_write_config(host, WBSD_CONF_ENABLE, 0);
1818 wbsd_lock_config(host);
1819 }
1535 1820
1536 /* 1821 wbsd_release_resources(host);
1537 * Free resources.
1538 */
1539 if (host->dma_buffer)
1540 kfree(host->dma_buffer);
1541 1822
1542 if (host->dma >= 0) 1823 wbsd_free_mmc(dev);
1543 free_dma(host->dma); 1824}
1544 1825
1545 free_irq(host->irq, host); 1826/*
1827 * Non-PnP
1828 */
1829
1830static int __devinit wbsd_probe(struct device* dev)
1831{
1832 return wbsd_init(dev, io, irq, dma, 0);
1833}
1834
1835static int __devexit wbsd_remove(struct device* dev)
1836{
1837 wbsd_shutdown(dev, 0);
1838
1839 return 0;
1840}
1841
1842/*
1843 * PnP
1844 */
1845
1846#ifdef CONFIG_PNP
1847
1848static int __devinit
1849wbsd_pnp_probe(struct pnp_dev * pnpdev, const struct pnp_device_id *dev_id)
1850{
1851 int io, irq, dma;
1546 1852
1547 tasklet_kill(&host->card_tasklet); 1853 /*
1548 tasklet_kill(&host->fifo_tasklet); 1854 * Get resources from PnP layer.
1549 tasklet_kill(&host->crc_tasklet); 1855 */
1550 tasklet_kill(&host->timeout_tasklet); 1856 io = pnp_port_start(pnpdev, 0);
1551 tasklet_kill(&host->finish_tasklet); 1857 irq = pnp_irq(pnpdev, 0);
1552 tasklet_kill(&host->block_tasklet); 1858 if (pnp_dma_valid(pnpdev, 0))
1859 dma = pnp_dma(pnpdev, 0);
1860 else
1861 dma = -1;
1553 1862
1554 wbsd_release_regions(host); 1863 DBGF("PnP resources: port %3x irq %d dma %d\n", io, irq, dma);
1555 1864
1556 mmc_free_host(mmc); 1865 return wbsd_init(&pnpdev->dev, io, irq, dma, 1);
1866}
1557 1867
1558 return 0; 1868static void __devexit wbsd_pnp_remove(struct pnp_dev * dev)
1869{
1870 wbsd_shutdown(&dev->dev, 1);
1559} 1871}
1560 1872
1873#endif /* CONFIG_PNP */
1874
1561/* 1875/*
1562 * Power management 1876 * Power management
1563 */ 1877 */
@@ -1581,17 +1895,7 @@ static int wbsd_resume(struct device *dev, u32 level)
1581#define wbsd_resume NULL 1895#define wbsd_resume NULL
1582#endif 1896#endif
1583 1897
1584static void wbsd_release(struct device *dev) 1898static struct platform_device *wbsd_device;
1585{
1586}
1587
1588static struct platform_device wbsd_device = {
1589 .name = DRIVER_NAME,
1590 .id = -1,
1591 .dev = {
1592 .release = wbsd_release,
1593 },
1594};
1595 1899
1596static struct device_driver wbsd_driver = { 1900static struct device_driver wbsd_driver = {
1597 .name = DRIVER_NAME, 1901 .name = DRIVER_NAME,
@@ -1603,6 +1907,17 @@ static struct device_driver wbsd_driver = {
1603 .resume = wbsd_resume, 1907 .resume = wbsd_resume,
1604}; 1908};
1605 1909
1910#ifdef CONFIG_PNP
1911
1912static struct pnp_driver wbsd_pnp_driver = {
1913 .name = DRIVER_NAME,
1914 .id_table = pnp_dev_table,
1915 .probe = wbsd_pnp_probe,
1916 .remove = wbsd_pnp_remove,
1917};
1918
1919#endif /* CONFIG_PNP */
1920
1606/* 1921/*
1607 * Module loading/unloading 1922 * Module loading/unloading
1608 */ 1923 */
@@ -1615,29 +1930,57 @@ static int __init wbsd_drv_init(void)
1615 ": Winbond W83L51xD SD/MMC card interface driver, " 1930 ": Winbond W83L51xD SD/MMC card interface driver, "
1616 DRIVER_VERSION "\n"); 1931 DRIVER_VERSION "\n");
1617 printk(KERN_INFO DRIVER_NAME ": Copyright(c) Pierre Ossman\n"); 1932 printk(KERN_INFO DRIVER_NAME ": Copyright(c) Pierre Ossman\n");
1618
1619 result = driver_register(&wbsd_driver);
1620 if (result < 0)
1621 return result;
1622 1933
1623 result = platform_device_register(&wbsd_device); 1934#ifdef CONFIG_PNP
1624 if (result < 0) 1935
1625 return result; 1936 if (!nopnp)
1937 {
1938 result = pnp_register_driver(&wbsd_pnp_driver);
1939 if (result < 0)
1940 return result;
1941 }
1942
1943#endif /* CONFIG_PNP */
1944
1945 if (nopnp)
1946 {
1947 result = driver_register(&wbsd_driver);
1948 if (result < 0)
1949 return result;
1950
1951 wbsd_device = platform_device_register_simple(DRIVER_NAME, -1,
1952 NULL, 0);
1953 if (IS_ERR(wbsd_device))
1954 return PTR_ERR(wbsd_device);
1955 }
1626 1956
1627 return 0; 1957 return 0;
1628} 1958}
1629 1959
1630static void __exit wbsd_drv_exit(void) 1960static void __exit wbsd_drv_exit(void)
1631{ 1961{
1632 platform_device_unregister(&wbsd_device); 1962#ifdef CONFIG_PNP
1963
1964 if (!nopnp)
1965 pnp_unregister_driver(&wbsd_pnp_driver);
1633 1966
1634 driver_unregister(&wbsd_driver); 1967#endif /* CONFIG_PNP */
1968
1969 if (nopnp)
1970 {
1971 platform_device_unregister(wbsd_device);
1972
1973 driver_unregister(&wbsd_driver);
1974 }
1635 1975
1636 DBG("unloaded\n"); 1976 DBG("unloaded\n");
1637} 1977}
1638 1978
1639module_init(wbsd_drv_init); 1979module_init(wbsd_drv_init);
1640module_exit(wbsd_drv_exit); 1980module_exit(wbsd_drv_exit);
1981#ifdef CONFIG_PNP
1982module_param(nopnp, uint, 0444);
1983#endif
1641module_param(io, uint, 0444); 1984module_param(io, uint, 0444);
1642module_param(irq, uint, 0444); 1985module_param(irq, uint, 0444);
1643module_param(dma, int, 0444); 1986module_param(dma, int, 0444);
@@ -1646,6 +1989,9 @@ MODULE_LICENSE("GPL");
1646MODULE_DESCRIPTION("Winbond W83L51xD SD/MMC card interface driver"); 1989MODULE_DESCRIPTION("Winbond W83L51xD SD/MMC card interface driver");
1647MODULE_VERSION(DRIVER_VERSION); 1990MODULE_VERSION(DRIVER_VERSION);
1648 1991
1992#ifdef CONFIG_PNP
1993MODULE_PARM_DESC(nopnp, "Scan for device instead of relying on PNP. (default 0)");
1994#endif
1649MODULE_PARM_DESC(io, "I/O base to allocate. Must be 8 byte aligned. (default 0x248)"); 1995MODULE_PARM_DESC(io, "I/O base to allocate. Must be 8 byte aligned. (default 0x248)");
1650MODULE_PARM_DESC(irq, "IRQ to allocate. (default 6)"); 1996MODULE_PARM_DESC(irq, "IRQ to allocate. (default 6)");
1651MODULE_PARM_DESC(dma, "DMA channel to allocate. -1 for no DMA. (default 2)"); 1997MODULE_PARM_DESC(dma, "DMA channel to allocate. -1 for no DMA. (default 2)");
diff --git a/drivers/mmc/wbsd.h b/drivers/mmc/wbsd.h
index fdc03b56a81f..864f30828d01 100644
--- a/drivers/mmc/wbsd.h
+++ b/drivers/mmc/wbsd.h
@@ -35,6 +35,12 @@ const int valid_ids[] = {
35 35
36#define DEVICE_SD 0x03 36#define DEVICE_SD 0x03
37 37
38#define WBSD_PINS_DAT3_HI 0x20
39#define WBSD_PINS_DAT3_OUT 0x10
40#define WBSD_PINS_GP11_HI 0x04
41#define WBSD_PINS_DETECT_GP11 0x02
42#define WBSD_PINS_DETECT_DAT3 0x01
43
38#define WBSD_CMDR 0x00 44#define WBSD_CMDR 0x00
39#define WBSD_DFR 0x01 45#define WBSD_DFR 0x01
40#define WBSD_EIR 0x02 46#define WBSD_EIR 0x02
@@ -133,6 +139,7 @@ const int valid_ids[] = {
133#define WBSD_CRC_OK 0x05 /* S010E (00101) */ 139#define WBSD_CRC_OK 0x05 /* S010E (00101) */
134#define WBSD_CRC_FAIL 0x0B /* S101E (01011) */ 140#define WBSD_CRC_FAIL 0x0B /* S101E (01011) */
135 141
142#define WBSD_DMA_SIZE 65536
136 143
137struct wbsd_host 144struct wbsd_host
138{ 145{
@@ -140,6 +147,11 @@ struct wbsd_host
140 147
141 spinlock_t lock; /* Mutex */ 148 spinlock_t lock; /* Mutex */
142 149
150 int flags; /* Driver states */
151
152#define WBSD_FCARD_PRESENT (1<<0) /* Card is present */
153#define WBSD_FIGNORE_DETECT (1<<1) /* Ignore card detection */
154
143 struct mmc_request* mrq; /* Current request */ 155 struct mmc_request* mrq; /* Current request */
144 156
145 u8 isr; /* Accumulated ISR */ 157 u8 isr; /* Accumulated ISR */
diff --git a/drivers/serial/21285.c b/drivers/serial/21285.c
index 33fbda79f350..0b10169961eb 100644
--- a/drivers/serial/21285.c
+++ b/drivers/serial/21285.c
@@ -126,18 +126,8 @@ static irqreturn_t serial21285_rx_chars(int irq, void *dev_id, struct pt_regs *r
126 flag = TTY_FRAME; 126 flag = TTY_FRAME;
127 } 127 }
128 128
129 if ((rxs & port->ignore_status_mask) == 0) { 129 uart_insert_char(port, rxs, RXSTAT_OVERRUN, ch, flag);
130 tty_insert_flip_char(tty, ch, flag); 130
131 }
132 if ((rxs & RXSTAT_OVERRUN) &&
133 tty->flip.count < TTY_FLIPBUF_SIZE) {
134 /*
135 * Overrun is special, since it's reported
136 * immediately, and doesn't affect the current
137 * character.
138 */
139 tty_insert_flip_char(tty, 0, TTY_OVERRUN);
140 }
141 status = *CSR_UARTFLG; 131 status = *CSR_UARTFLG;
142 } 132 }
143 tty_flip_buffer_push(tty); 133 tty_flip_buffer_push(tty);
diff --git a/drivers/serial/8250.c b/drivers/serial/8250.c
index 0d9358608fdf..3bbf0cc6e53f 100644
--- a/drivers/serial/8250.c
+++ b/drivers/serial/8250.c
@@ -1122,18 +1122,9 @@ receive_chars(struct uart_8250_port *up, int *status, struct pt_regs *regs)
1122 } 1122 }
1123 if (uart_handle_sysrq_char(&up->port, ch, regs)) 1123 if (uart_handle_sysrq_char(&up->port, ch, regs))
1124 goto ignore_char; 1124 goto ignore_char;
1125 if ((lsr & up->port.ignore_status_mask) == 0) { 1125
1126 tty_insert_flip_char(tty, ch, flag); 1126 uart_insert_char(&up->port, lsr, UART_LSR_OE, ch, flag);
1127 } 1127
1128 if ((lsr & UART_LSR_OE) &&
1129 tty->flip.count < TTY_FLIPBUF_SIZE) {
1130 /*
1131 * Overrun is special, since it's reported
1132 * immediately, and doesn't affect the current
1133 * character.
1134 */
1135 tty_insert_flip_char(tty, 0, TTY_OVERRUN);
1136 }
1137 ignore_char: 1128 ignore_char:
1138 lsr = serial_inp(up, UART_LSR); 1129 lsr = serial_inp(up, UART_LSR);
1139 } while ((lsr & UART_LSR_DR) && (max_count-- > 0)); 1130 } while ((lsr & UART_LSR_DR) && (max_count-- > 0));
diff --git a/drivers/serial/amba-pl010.c b/drivers/serial/amba-pl010.c
index f2a5e2933c47..2884b310e54d 100644
--- a/drivers/serial/amba-pl010.c
+++ b/drivers/serial/amba-pl010.c
@@ -198,18 +198,8 @@ pl010_rx_chars(struct uart_port *port)
198 if (uart_handle_sysrq_char(port, ch, regs)) 198 if (uart_handle_sysrq_char(port, ch, regs))
199 goto ignore_char; 199 goto ignore_char;
200 200
201 if ((rsr & port->ignore_status_mask) == 0) { 201 uart_insert_char(port, rsr, UART01x_RSR_OE, ch, flag);
202 tty_insert_flip_char(tty, ch, flag); 202
203 }
204 if ((rsr & UART01x_RSR_OE) &&
205 tty->flip.count < TTY_FLIPBUF_SIZE) {
206 /*
207 * Overrun is special, since it's reported
208 * immediately, and doesn't affect the current
209 * character
210 */
211 tty_insert_flip_char(tty, 0, TTY_OVERRUN);
212 }
213 ignore_char: 203 ignore_char:
214 status = UART_GET_FR(port); 204 status = UART_GET_FR(port);
215 } 205 }
diff --git a/drivers/serial/amba-pl011.c b/drivers/serial/amba-pl011.c
index d5cbef3fe8b6..7db88ee18f75 100644
--- a/drivers/serial/amba-pl011.c
+++ b/drivers/serial/amba-pl011.c
@@ -163,18 +163,8 @@ pl011_rx_chars(struct uart_amba_port *uap)
163 if (uart_handle_sysrq_char(&uap->port, ch, regs)) 163 if (uart_handle_sysrq_char(&uap->port, ch, regs))
164 goto ignore_char; 164 goto ignore_char;
165 165
166 if ((rsr & uap->port.ignore_status_mask) == 0) { 166 uart_insert_char(&uap->port, rsr, UART01x_RSR_OE, ch, flag);
167 tty_insert_flip_char(tty, ch, flag); 167
168 }
169 if ((rsr & UART01x_RSR_OE) &&
170 tty->flip.count < TTY_FLIPBUF_SIZE) {
171 /*
172 * Overrun is special, since it's reported
173 * immediately, and doesn't affect the current
174 * character
175 */
176 tty_insert_flip_char(tty, 0, TTY_OVERRUN);
177 }
178 ignore_char: 168 ignore_char:
179 status = readw(uap->port.membase + UART01x_FR); 169 status = readw(uap->port.membase + UART01x_FR);
180 } 170 }
diff --git a/drivers/serial/clps711x.c b/drivers/serial/clps711x.c
index 6242f3090a96..e92522b33c48 100644
--- a/drivers/serial/clps711x.c
+++ b/drivers/serial/clps711x.c
@@ -143,10 +143,7 @@ static irqreturn_t clps711xuart_int_rx(int irq, void *dev_id, struct pt_regs *re
143 * CHECK: does overrun affect the current character? 143 * CHECK: does overrun affect the current character?
144 * ASSUMPTION: it does not. 144 * ASSUMPTION: it does not.
145 */ 145 */
146 if ((ch & port->ignore_status_mask & ~RXSTAT_OVERRUN) == 0) 146 uart_insert_char(port, ch, UARTDR_OVERR, ch, flg);
147 tty_insert_flip_char(tty, ch, flg);
148 if ((ch & ~port->ignore_status_mask & RXSTAT_OVERRUN) == 0)
149 tty_insert_flip_char(tty, 0, TTY_OVERRUN);
150 147
151 ignore_char: 148 ignore_char:
152 status = clps_readl(SYSFLG(port)); 149 status = clps_readl(SYSFLG(port));
diff --git a/drivers/serial/pxa.c b/drivers/serial/pxa.c
index 51d8a49f4477..9dc151d8fa61 100644
--- a/drivers/serial/pxa.c
+++ b/drivers/serial/pxa.c
@@ -161,20 +161,12 @@ receive_chars(struct uart_pxa_port *up, int *status, struct pt_regs *regs)
161 else if (*status & UART_LSR_FE) 161 else if (*status & UART_LSR_FE)
162 flag = TTY_FRAME; 162 flag = TTY_FRAME;
163 } 163 }
164
164 if (uart_handle_sysrq_char(&up->port, ch, regs)) 165 if (uart_handle_sysrq_char(&up->port, ch, regs))
165 goto ignore_char; 166 goto ignore_char;
166 if ((*status & up->port.ignore_status_mask) == 0) { 167
167 tty_insert_flip_char(tty, ch, flag); 168 uart_insert_char(&up->port, *status, UART_LSR_OE, ch, flag);
168 } 169
169 if ((*status & UART_LSR_OE) &&
170 tty->flip.count < TTY_FLIPBUF_SIZE) {
171 /*
172 * Overrun is special, since it's reported
173 * immediately, and doesn't affect the current
174 * character.
175 */
176 tty_insert_flip_char(tty, 0, TTY_OVERRUN);
177 }
178 ignore_char: 170 ignore_char:
179 *status = serial_in(up, UART_LSR); 171 *status = serial_in(up, UART_LSR);
180 } while ((*status & UART_LSR_DR) && (max_count-- > 0)); 172 } while ((*status & UART_LSR_DR) && (max_count-- > 0));
diff --git a/drivers/serial/s3c2410.c b/drivers/serial/s3c2410.c
index 435750d40a47..2a9f7ade2c9d 100644
--- a/drivers/serial/s3c2410.c
+++ b/drivers/serial/s3c2410.c
@@ -394,20 +394,7 @@ s3c24xx_serial_rx_chars(int irq, void *dev_id, struct pt_regs *regs)
394 if (uart_handle_sysrq_char(port, ch, regs)) 394 if (uart_handle_sysrq_char(port, ch, regs))
395 goto ignore_char; 395 goto ignore_char;
396 396
397 if ((uerstat & port->ignore_status_mask) == 0) { 397 uart_insert_char(port, uerstat, S3C2410_UERSTAT_OVERRUN, ch, flag);
398 tty_insert_flip_char(tty, ch, flag);
399 }
400
401 if ((uerstat & S3C2410_UERSTAT_OVERRUN) &&
402 tty->flip.count < TTY_FLIPBUF_SIZE) {
403 /*
404 * Overrun is special, since it's reported
405 * immediately, and doesn't affect the current
406 * character.
407 */
408
409 tty_insert_flip_char(tty, 0, TTY_OVERRUN);
410 }
411 398
412 ignore_char: 399 ignore_char:
413 continue; 400 continue;
diff --git a/drivers/serial/sa1100.c b/drivers/serial/sa1100.c
index 157218bc6c6f..22565a67a57c 100644
--- a/drivers/serial/sa1100.c
+++ b/drivers/serial/sa1100.c
@@ -237,10 +237,7 @@ sa1100_rx_chars(struct sa1100_port *sport, struct pt_regs *regs)
237 if (uart_handle_sysrq_char(&sport->port, ch, regs)) 237 if (uart_handle_sysrq_char(&sport->port, ch, regs))
238 goto ignore_char; 238 goto ignore_char;
239 239
240 if ((status & port->ignore_status_mask & ~UTSR1_TO_SM(UTSR1_ROR)) == 0) 240 uart_insert_char(&sport->port, status, UTSR1_TO_SM(UTSR1_ROR), ch, flg);
241 tty_insert_flip_char(tty, ch, flg);
242 if (status & ~port->ignore_status_mask & UTSR1_TO_SM(UTSR1_ROR))
243 tty_insert_flip_char(tty, 0, TTY_OVERRUN);
244 241
245 ignore_char: 242 ignore_char:
246 status = UTSR1_TO_SM(UART_GET_UTSR1(sport)) | 243 status = UTSR1_TO_SM(UART_GET_UTSR1(sport)) |
diff --git a/drivers/serial/serial_lh7a40x.c b/drivers/serial/serial_lh7a40x.c
index 85cfa08d3bad..56f269b6bfb1 100644
--- a/drivers/serial/serial_lh7a40x.c
+++ b/drivers/serial/serial_lh7a40x.c
@@ -190,18 +190,7 @@ lh7a40xuart_rx_chars (struct uart_port* port)
190 if (uart_handle_sysrq_char (port, (unsigned char) data, regs)) 190 if (uart_handle_sysrq_char (port, (unsigned char) data, regs))
191 continue; 191 continue;
192 192
193 if ((data & port->ignore_status_mask) == 0) { 193 uart_insert_char(port, data, RxOverrunError, data, flag);
194 tty_insert_flip_char(tty, data, flag);
195 }
196 if ((data & RxOverrunError)
197 && tty->flip.count < TTY_FLIPBUF_SIZE) {
198 /*
199 * Overrun is special, since it's reported
200 * immediately, and doesn't affect the current
201 * character
202 */
203 tty_insert_flip_char(tty, 0, TTY_OVERRUN);
204 }
205 } 194 }
206 tty_flip_buffer_push (tty); 195 tty_flip_buffer_push (tty);
207 return; 196 return;
diff --git a/drivers/serial/serial_txx9.c b/drivers/serial/serial_txx9.c
index 37b2ef297cbe..3f1051a4a13f 100644
--- a/drivers/serial/serial_txx9.c
+++ b/drivers/serial/serial_txx9.c
@@ -350,18 +350,9 @@ receive_chars(struct uart_txx9_port *up, unsigned int *status, struct pt_regs *r
350 } 350 }
351 if (uart_handle_sysrq_char(&up->port, ch, regs)) 351 if (uart_handle_sysrq_char(&up->port, ch, regs))
352 goto ignore_char; 352 goto ignore_char;
353 if ((disr & up->port.ignore_status_mask) == 0) { 353
354 tty_insert_flip_char(tty, ch, flag); 354 uart_insert_char(&up->port, disr, TXX9_SIDISR_UOER, ch, flag);
355 } 355
356 if ((disr & TXX9_SIDISR_UOER) &&
357 tty->flip.count < TTY_FLIPBUF_SIZE) {
358 /*
359 * Overrun is special, since it's reported
360 * immediately, and doesn't affect the current
361 * character.
362 */
363 tty_insert_flip_char(tty, 0, TTY_OVERRUN);
364 }
365 ignore_char: 356 ignore_char:
366 disr = sio_in(up, TXX9_SIDISR); 357 disr = sio_in(up, TXX9_SIDISR);
367 } while (!(disr & TXX9_SIDISR_UVALID) && (max_count-- > 0)); 358 } while (!(disr & TXX9_SIDISR_UVALID) && (max_count-- > 0));
diff --git a/drivers/serial/vr41xx_siu.c b/drivers/serial/vr41xx_siu.c
index 307886199f2f..5d2ceb623e6f 100644
--- a/drivers/serial/vr41xx_siu.c
+++ b/drivers/serial/vr41xx_siu.c
@@ -412,10 +412,8 @@ static inline void receive_chars(struct uart_port *port, uint8_t *status,
412 412
413 if (uart_handle_sysrq_char(port, ch, regs)) 413 if (uart_handle_sysrq_char(port, ch, regs))
414 goto ignore_char; 414 goto ignore_char;
415 if ((lsr & port->ignore_status_mask) == 0) 415
416 tty_insert_flip_char(tty, ch, flag); 416 uart_insert_char(port, lsr, UART_LSR_OE, ch, flag);
417 if ((lsr & UART_LSR_OE) && (tty->flip.count < TTY_FLIPBUF_SIZE))
418 tty_insert_flip_char(tty, 0, TTY_OVERRUN);
419 417
420 ignore_char: 418 ignore_char:
421 lsr = siu_read(port, UART_LSR); 419 lsr = siu_read(port, UART_LSR);