45 #include <linux/module.h>
47 #include <linux/sched.h>
49 #include <linux/errno.h>
52 #include <linux/kernel.h>
53 #include <linux/slab.h>
55 #include <linux/pci.h>
58 #include <linux/sysctl.h>
64 #include <linux/parport.h>
67 #include <asm/parport.h>
69 #define PARPORT_PC_MAX_PORTS PARPORT_MAX
71 #ifdef CONFIG_ISA_DMA_API
84 #define ECR_MODE_MASK 0xe0
85 #define ECR_WRITE(p, v) frob_econtrol((p), 0xff, (v))
90 #define DPRINTK printk
92 #define DPRINTK(stuff...)
97 static struct superio_struct {
103 static int user_specified;
104 #if defined(CONFIG_PARPORT_PC_SUPERIO) || \
105 (defined(CONFIG_PARPORT_1284) && defined(CONFIG_PARPORT_PC_FIFO))
106 static int verbose_probing;
108 static int pci_registered_parport;
109 static int pnp_registered_parport;
112 static void frob_econtrol(
struct parport *pb,
unsigned char m,
115 unsigned char ectr = 0;
121 m, v, ectr, (ectr & ~m) ^ v);
126 static inline void frob_set_mode(
struct parport *
p,
int mode)
131 #ifdef CONFIG_PARPORT_PC_FIFO
138 static int change_mode(
struct parport *
p,
int m)
153 mode = (oecr >> 5) & 0x7;
157 if (mode >= 2 && !(priv->
ctr & 0x20)) {
166 for (counter = 0; counter < 40; counter++) {
187 if (mode >= 2 && m >= 2) {
207 static int clear_epp_timeout(
struct parport *pb)
211 if (!(parport_pc_read_status(pb) & 0x01))
215 parport_pc_read_status(pb);
216 r = parport_pc_read_status(pb);
219 r = parport_pc_read_status(pb);
232 static void parport_pc_init_state(
struct pardevice *
dev,
253 static void parport_pc_restore_state(
struct parport *p,
264 #ifdef CONFIG_PARPORT_1284
265 static size_t parport_pc_epp_read_data(
struct parport *
port,
void *
buf,
280 while (!(status & 0x08) && got < length) {
281 if (left >= 16 && (status & 0x20) && !(status & 0x08)) {
283 if (!((
long)buf & 0x03))
301 "%s: EPP timeout occurred while talking to w91284pic (should not have done)\n", port->
name);
302 clear_epp_timeout(port);
308 if (!(((
long)buf | length) & 0x03))
313 clear_epp_timeout(port);
318 for (; got <
length; got++) {
323 clear_epp_timeout(port);
331 static size_t parport_pc_epp_write_data(
struct parport *port,
const void *buf,
332 size_t length,
int flags)
336 if ((flags & PARPORT_EPP_FAST) && (length > 1)) {
337 if (!(((
long)buf | length) & 0x03))
342 clear_epp_timeout(port);
347 for (; written <
length; written++) {
351 clear_epp_timeout(port);
359 static size_t parport_pc_epp_read_addr(
struct parport *port,
void *buf,
360 size_t length,
int flags)
364 if ((flags & PARPORT_EPP_FAST) && (length > 1)) {
367 clear_epp_timeout(port);
372 for (; got <
length; got++) {
376 clear_epp_timeout(port);
384 static size_t parport_pc_epp_write_addr(
struct parport *port,
385 const void *buf,
size_t length,
390 if ((flags & PARPORT_EPP_FAST) && (length > 1)) {
393 clear_epp_timeout(port);
398 for (; written <
length; written++) {
402 clear_epp_timeout(port);
410 static size_t parport_pc_ecpepp_read_data(
struct parport *port,
void *buf,
411 size_t length,
int flags)
416 parport_pc_data_reverse(port);
417 parport_pc_write_control(port, 0x4);
418 got = parport_pc_epp_read_data(port, buf, length, flags);
424 static size_t parport_pc_ecpepp_write_data(
struct parport *port,
425 const void *buf,
size_t length,
431 parport_pc_write_control(port, 0x4);
432 parport_pc_data_forward(port);
433 written = parport_pc_epp_write_data(port, buf, length, flags);
439 static size_t parport_pc_ecpepp_read_addr(
struct parport *port,
void *buf,
440 size_t length,
int flags)
445 parport_pc_data_reverse(port);
446 parport_pc_write_control(port, 0x4);
447 got = parport_pc_epp_read_addr(port, buf, length, flags);
453 static size_t parport_pc_ecpepp_write_addr(
struct parport *port,
454 const void *buf,
size_t length,
460 parport_pc_write_control(port, 0x4);
461 parport_pc_data_forward(port);
462 written = parport_pc_epp_write_addr(port, buf, length, flags);
469 #ifdef CONFIG_PARPORT_PC_FIFO
470 static size_t parport_pc_fifo_write_block_pio(
struct parport *port,
471 const void *buf,
size_t length)
474 const unsigned char *bufp =
buf;
485 parport_pc_disable_irq(port);
487 frob_econtrol(port, (1<<4) | (1<<2), (1<<4) | (1<<2));
490 parport_pc_data_forward(port);
497 if (need_resched() &&
time_before(jiffies, expire))
523 if (!(ecrval & (1<<2))) {
524 if (need_resched() &&
543 const int n = left < fifo_depth ? left :
fifo_depth;
544 outsb(fifo, bufp, n);
549 if (i < (poll_for - 2))
552 }
else if (i++ < poll_for) {
564 return length -
left;
568 static size_t parport_pc_fifo_write_block_dma(
struct parport *port,
569 const void *buf,
size_t length)
572 unsigned long dmaflag;
577 size_t maxlen = 0x10000;
578 unsigned long start = (
unsigned long) buf;
579 unsigned long end = (
unsigned long) buf + length - 1;
584 if ((start ^ end) & ~0xffffUL)
585 maxlen = 0x10000 - (start & 0xffff);
600 parport_pc_disable_irq(port);
602 frob_econtrol(port, (1<<4) | (1<<2), (1<<4) | (1<<2));
605 parport_pc_data_forward(port);
620 clear_dma_ff(port->
dma);
622 set_dma_addr(port->
dma, dma_addr);
626 frob_econtrol(port, 1<<3, 1<<3);
629 frob_econtrol(port, 1<<2, 0);
660 clear_dma_ff(port->
dma);
682 clear_dma_ff(port->
dma);
687 frob_econtrol(port, 1<<3, 0);
693 return length -
left;
697 static inline size_t parport_pc_fifo_write_block(
struct parport *port,
698 const void *buf,
size_t length)
702 return parport_pc_fifo_write_block_dma(port, buf, length);
704 return parport_pc_fifo_write_block_pio(port, buf, length);
708 static size_t parport_pc_compat_write_block_pio(
struct parport *port,
709 const void *buf,
size_t length,
714 unsigned long expire;
724 parport_pc_data_forward(port);
726 r = change_mode(port,
ECR_PPF);
734 written = parport_pc_fifo_write_block(port, buf, length);
744 r = change_mode(port,
ECR_PS2);
756 for (written -= priv->
fifo_depth; ; written++) {
773 "%s: BUSY timeout (%d) in compat_write_block_pio\n",
782 #ifdef CONFIG_PARPORT_1284
783 static size_t parport_pc_ecp_write_block_pio(
struct parport *port,
784 const void *buf,
size_t length,
789 unsigned long expire;
813 "in ecp_write_block_pio\n", port->
name, r);
818 parport_pc_data_forward(port);
819 parport_pc_frob_control(port,
823 r = change_mode(port,
ECR_ECP);
830 written = parport_pc_fifo_write_block(port, buf, length);
840 r = change_mode(port,
ECR_PS2);
852 for (written -= priv->
fifo_depth; ; written++) {
864 parport_pc_data_reverse(port);
870 "in ecp_write_block_pio\n", port->
name, r);
880 "in ecp_write_block_pio\n", port->
name, r);
888 "%s: BUSY timeout (%d) in ecp_write_block_pio\n",
908 .write_data = parport_pc_write_data,
909 .read_data = parport_pc_read_data,
911 .write_control = parport_pc_write_control,
912 .read_control = parport_pc_read_control,
913 .frob_control = parport_pc_frob_control,
915 .read_status = parport_pc_read_status,
917 .enable_irq = parport_pc_enable_irq,
918 .disable_irq = parport_pc_disable_irq,
920 .data_forward = parport_pc_data_forward,
921 .data_reverse = parport_pc_data_reverse,
923 .init_state = parport_pc_init_state,
924 .save_state = parport_pc_save_state,
925 .restore_state = parport_pc_restore_state,
943 #ifdef CONFIG_PARPORT_PC_SUPERIO
945 static struct superio_struct *find_free_superio(
void)
949 if (superios[i].
io == 0)
958 int cr1,
cr4, cra, cr23, cr26, cr27;
959 struct superio_struct *
s;
961 static const char *
const modes[] = {
962 "SPP and Bidirectional (PS/2)",
983 if (verbose_probing) {
985 "SMSC 37c669 LPT Config: cr_1=0x%02x, 4=0x%02x, "
986 "A=0x%2x, 23=0x%02x, 26=0x%02x, 27=0x%02x\n",
987 cr1, cr4, cra, cr23, cr26, cr27);
993 "SMSC LPT Config: io=0x%04x, irq=%c, dma=%c, fifo threshold=%d\n",
995 (cr27 & 0x0f) ?
'A' - 1 + (cr27 & 0x0f) :
'-',
996 (cr26 & 0x0f) ?
'A' - 1 + (cr26 & 0x0f) :
'-',
999 (cr23 * 4 >= 0x100) ?
"yes" :
"no",
1000 (cr1 & 4) ?
"yes" :
"no");
1002 "SMSC LPT Config: Port mode=%s, EPP version =%s\n",
1003 (cr1 & 0x08) ?
"Standard mode only (SPP)"
1004 : modes[cr4 & 0x03],
1005 (cr4 & 0x40) ?
"1.7" :
"1.9");
1012 if (cr23 * 4 >= 0x100) {
1013 s = find_free_superio();
1032 if (d == 1 || d == 3)
1041 static void __devinit show_parconfig_winbond(
int io,
int key)
1043 int cr30, cr60, cr61, cr70, cr74, crf0;
1044 struct superio_struct *
s;
1045 static const char *
const modes[] = {
1046 "Standard (SPP) and Bidirectional(PS/2)",
1053 "ECP and EPP-1.7" };
1054 static char *
const irqtypes[] = {
1055 "pulsed low, high-Z",
1079 if (verbose_probing) {
1081 "Winbond LPT Config: cr_30=%02x 60,61=%02x%02x 70=%02x 74=%02x, f0=%02x\n",
1082 cr30, cr60, cr61, cr70, cr74, crf0);
1083 printk(
KERN_INFO "Winbond LPT Config: active=%s, io=0x%02x%02x irq=%d, ",
1084 (cr30 & 0x01) ?
"yes" :
"no", cr60, cr61, cr70 & 0x0f);
1085 if ((cr74 & 0x07) > 3)
1088 printk(
"dma=%d\n", cr74 & 0x07);
1090 "Winbond LPT Config: irqtype=%s, ECP fifo threshold=%d\n",
1091 irqtypes[crf0>>7], (crf0>>3)&0x0f);
1093 modes[crf0 & 0x07]);
1097 s = find_free_superio();
1101 s->io = (cr60 << 8) | cr61;
1102 s->irq = cr70 & 0x0f;
1103 s->dma = (((cr74 & 0x07) > 3) ?
1110 int devrev,
int oldid)
1112 const char *
type =
"unknown";
1115 if (devid == devrev)
1120 id = (devid << 8) | devrev;
1126 else if (
id == 0x9773)
1127 type =
"83977TF / SMSC 97w33x/97w34x";
1128 else if (
id == 0x9774)
1130 else if ((
id & ~0x0f) == 0x5270)
1131 type =
"83977CTF / SMSC 97w36x";
1132 else if ((
id & ~0x0f) == 0x52f0)
1133 type =
"83977EF / SMSC 97w35x";
1134 else if ((
id & ~0x0f) == 0x5210)
1136 else if ((
id & ~0x0f) == 0x6010)
1138 else if ((oldid & 0x0f) == 0x0a) {
1141 }
else if ((oldid & 0x0f) == 0x0b) {
1144 }
else if ((oldid & 0x0f) == 0x0c) {
1147 }
else if ((oldid & 0x0f) == 0x0d) {
1153 if (verbose_probing)
1155 "devid=%02x devrev=%02x oldid=%02x type=%s\n",
1156 efer, key, devid, devrev, oldid, type);
1159 show_parconfig_winbond(efer, key);
1162 static void __devinit decode_smsc(
int efer,
int key,
int devid,
int devrev)
1164 const char *type =
"unknown";
1168 if (devid == devrev)
1174 id = (devid << 8) | devrev;
1178 func = show_parconfig_smsc37c669;
1179 }
else if (
id == 0x6582)
1181 else if (devid == 0x65)
1183 else if (devid == 0x66)
1186 if (verbose_probing)
1188 "key=0x%02x devid=%02x devrev=%02x type=%s\n",
1189 efer, key, devid, devrev, type);
1196 static void __devinit winbond_check(
int io,
int key)
1198 int origval,
devid, devrev, oldid, x_devid, x_devrev, x_oldid;
1207 x_devid =
inb(io + 1);
1209 x_devrev =
inb(io + 1);
1211 x_oldid =
inb(io + 1);
1217 devid =
inb(io + 1);
1219 devrev =
inb(io + 1);
1221 oldid =
inb(io + 1);
1226 if ((x_devid == devid) && (x_devrev == devrev) && (x_oldid == oldid))
1229 decode_winbond(io, key, devid, devrev, oldid);
1234 static void __devinit winbond_check2(
int io,
int key)
1236 int origval[3],
devid, devrev, oldid, x_devid, x_devrev, x_oldid;
1241 origval[0] =
inb(io);
1242 origval[1] =
inb(io + 1);
1243 origval[2] =
inb(io + 2);
1247 x_devid =
inb(io + 2);
1249 x_devrev =
inb(io + 2);
1251 x_oldid =
inb(io + 2);
1256 devid =
inb(io + 2);
1258 devrev =
inb(io + 2);
1260 oldid =
inb(io + 2);
1263 outb(origval[0], io);
1264 outb(origval[1], io + 1);
1265 outb(origval[2], io + 2);
1267 if (x_devid == devid && x_devrev == devrev && x_oldid == oldid)
1270 decode_winbond(io, key, devid, devrev, oldid);
1275 static void __devinit smsc_check(
int io,
int key)
1277 int origval,
id,
rev, oldid, oldrev, x_id, x_rev, x_oldid, x_oldrev;
1286 x_oldid =
inb(io + 1);
1288 x_oldrev =
inb(io + 1);
1292 x_rev =
inb(io + 1);
1298 oldid =
inb(io + 1);
1300 oldrev =
inb(io + 1);
1309 if (x_id ==
id && x_oldrev == oldrev &&
1310 x_oldid == oldid && x_rev == rev)
1313 decode_smsc(io, key, oldid, oldrev);
1319 static void __devinit detect_and_report_winbond(
void)
1321 if (verbose_probing)
1322 printk(
KERN_DEBUG "Winbond Super-IO detection, now testing ports 3F0,370,250,4E,2E ...\n");
1323 winbond_check(0x3f0, 0x87);
1324 winbond_check(0x370, 0x87);
1325 winbond_check(0x2e , 0x87);
1326 winbond_check(0x4e , 0x87);
1327 winbond_check(0x3f0, 0
x86);
1328 winbond_check2(0x250, 0x88);
1329 winbond_check2(0x250, 0x89);
1332 static void __devinit detect_and_report_smsc(
void)
1334 if (verbose_probing)
1335 printk(
KERN_DEBUG "SMSC Super-IO detection, now testing Ports 2F0, 370 ...\n");
1336 smsc_check(0x3f0, 0x55);
1337 smsc_check(0x370, 0x55);
1338 smsc_check(0x3f0, 0x44);
1339 smsc_check(0x370, 0x44);
1342 static void __devinit detect_and_report_it87(
void)
1346 if (verbose_probing)
1350 origval =
inb(0x2e);
1356 dev =
inb(0x2f) << 8;
1359 if (dev == 0x8712 || dev == 0x8705 || dev == 0x8715 ||
1360 dev == 0x8716 || dev == 0x8718 || dev == 0x8726) {
1371 outb(origval, 0x2e);
1377 static struct superio_struct *find_superio(
struct parport *p)
1381 if (superios[i].io != p->
base)
1382 return &superios[
i];
1386 static int get_superio_dma(
struct parport *p)
1388 struct superio_struct *s = find_superio(p);
1394 static int get_superio_irq(
struct parport *p)
1396 struct superio_struct *s = find_superio(p);
1414 static int parport_SPP_supported(
struct parport *pb)
1424 clear_epp_timeout(pb);
1436 if ((r & 0xf) == w) {
1449 "wrote 0x%02x, read 0x%02x\n", pb->
base, w, r);
1454 parport_pc_write_data(pb, w);
1455 r = parport_pc_read_data(pb);
1458 parport_pc_write_data(pb, w);
1459 r = parport_pc_read_data(pb);
1464 if (user_specified) {
1468 "wrote 0x%02x, read 0x%02x\n", pb->
base, w, r);
1470 "but there is probably no parallel port there!\n",
1495 static int parport_ECR_present(
struct parport *pb)
1498 unsigned char r = 0xc;
1529 #ifdef CONFIG_PARPORT_1284
1547 static int parport_PS2_supported(
struct parport *pb)
1551 clear_epp_timeout(pb);
1554 parport_pc_data_reverse(pb);
1556 parport_pc_write_data(pb, 0x55);
1557 if (parport_pc_read_data(pb) != 0x55)
1560 parport_pc_write_data(pb, 0xaa);
1561 if (parport_pc_read_data(pb) != 0xaa)
1565 parport_pc_data_forward(pb);
1577 #ifdef CONFIG_PARPORT_PC_FIFO
1578 static int parport_ECP_supported(
struct parport *pb)
1585 static const int intrline[] = { 0, 7, 9, 10, 11, 14, 15, 5 };
1594 for (i = 0; i < 1024 && !(
inb(
ECONTROL(pb)) & 0x02); i++)
1607 if (verbose_probing)
1611 frob_econtrol(pb, 1<<2, 1<<2);
1612 frob_econtrol(pb, 1<<2, 0);
1620 if (i <= priv->fifo_depth) {
1621 if (verbose_probing)
1633 parport_pc_data_reverse(pb);
1635 frob_econtrol(pb, 1<<2, 1<<2);
1636 frob_econtrol(pb, 1<<2, 0);
1643 if (i <= priv->fifo_depth) {
1644 if (verbose_probing)
1656 pword = (config >> 4) & 0x7;
1677 if (verbose_probing) {
1679 pb->
base, 8 * pword);
1682 config & 0x80 ?
"Level" :
"Pulses");
1686 pb->
base, config, configb);
1688 if ((configb >> 3) & 0x07)
1689 printk(
"%d", intrline[(configb >> 3) & 0x07]);
1691 printk(
"<none or set by other means>");
1693 if ((configb & 0x03) == 0x00)
1694 printk(
"<none or set by other means>\n");
1696 printk(
"%d\n", configb & 0x07);
1706 static int parport_ECPPS2_supported(
struct parport *pb)
1717 result = parport_PS2_supported(pb);
1724 static int parport_EPP_supported(
struct parport *pb)
1742 if (!clear_epp_timeout(pb))
1748 for (i = 0x00; i < 0x80; i += 0x20) {
1750 if (clear_epp_timeout(pb)) {
1760 pb->
ops->epp_read_data = parport_pc_epp_read_data;
1761 pb->
ops->epp_write_data = parport_pc_epp_write_data;
1762 pb->
ops->epp_read_addr = parport_pc_epp_read_addr;
1763 pb->
ops->epp_write_addr = parport_pc_epp_write_addr;
1768 static int parport_ECPEPP_supported(
struct parport *pb)
1781 result = parport_EPP_supported(pb);
1787 pb->
ops->epp_read_data = parport_pc_ecpepp_read_data;
1788 pb->
ops->epp_write_data = parport_pc_ecpepp_write_data;
1789 pb->
ops->epp_read_addr = parport_pc_ecpepp_read_addr;
1790 pb->
ops->epp_write_addr = parport_pc_ecpepp_write_addr;
1799 static int __devinit parport_PS2_supported(
struct parport *pb) {
return 0; }
1800 #ifdef CONFIG_PARPORT_PC_FIFO
1801 static int parport_ECP_supported(
struct parport *pb)
1826 static int programmable_irq_support(
struct parport *pb)
1830 static const int lookup[8] = {
1837 irq = lookup[intrLine];
1843 static int irq_probe_ECP(
struct parport *pb)
1855 for (i = 0; i < 1024 && !(
inb(
ECONTROL(pb)) & 0x02) ; i++)
1871 static int irq_probe_EPP(
struct parport *pb)
1873 #ifndef ADVANCED_DETECT
1879 if (pb->
modes & PARPORT_MODE_PCECR)
1884 if (pb->
modes & PARPORT_MODE_PCECR)
1885 frob_econtrol(pb, 0x10, 0x10);
1887 clear_epp_timeout(pb);
1888 parport_pc_frob_control(pb, 0x20, 0x20);
1889 parport_pc_frob_control(pb, 0x10, 0x10);
1890 clear_epp_timeout(pb);
1895 parport_pc_read_epp(pb);
1899 if (pb->
modes & PARPORT_MODE_PCECR)
1901 parport_pc_write_control(pb, 0
xc);
1910 static int irq_probe_SPP(
struct parport *pb)
1923 static int parport_irq_probe(
struct parport *pb)
1928 pb->
irq = programmable_irq_support(pb);
1931 pb->
irq = irq_probe_ECP(pb);
1936 pb->
irq = irq_probe_EPP(pb);
1938 clear_epp_timeout(pb);
1941 pb->
irq = irq_probe_EPP(pb);
1943 clear_epp_timeout(pb);
1946 pb->
irq = irq_probe_SPP(pb);
1949 pb->
irq = get_superio_irq(pb);
1957 static int programmable_dma_support(
struct parport *p)
1967 if ((dma & 0x03) == 0)
1974 static int parport_dma_probe(
struct parport *p)
1978 p->
dma = programmable_dma_support(p);
1983 p->
dma = get_superio_dma(p);
2012 pdev = platform_device_register_simple(
"parport_pc",
2046 INIT_LIST_HEAD(&priv->
list);
2057 parport_ECR_present(p);
2060 if (base != 0x3bc) {
2063 if (!parport_EPP_supported(p))
2064 parport_ECPEPP_supported(p);
2066 if (!parport_SPP_supported(p))
2070 parport_ECPPS2_supported(p);
2072 parport_PS2_supported(p);
2081 parport_irq_probe(p);
2084 parport_irq_probe(p);
2094 parport_dma_probe(p);
2101 #ifdef CONFIG_PARPORT_PC_FIFO
2102 if (parport_ECP_supported(p) &&
2106 p->
ops->compat_write_data = parport_pc_compat_write_block_pio;
2107 #ifdef CONFIG_PARPORT_1284
2108 p->
ops->ecp_write_data = parport_pc_ecp_write_block_pio;
2124 #define printmode(x) \
2126 if (p->modes & PARPORT_MODE_##x) {\
2127 printk(KERN_CONT "%s%s", f ? "," : "", #x);\
2142 #ifndef CONFIG_PARPORT_1284
2161 irqflags, p->
name, p)) {
2163 "resorting to polled operation\n",
2169 #ifdef CONFIG_PARPORT_PC_FIFO
2174 "resorting to PIO operation\n",
2185 "cannot get buffer for DMA, "
2186 "resorting to PIO operation\n",
2205 parport_pc_write_data(p, 0);
2206 parport_pc_data_forward(p);
2211 spin_lock(&ports_lock);
2212 list_add(&priv->
list, &ports_list);
2213 spin_unlock(&ports_lock);
2243 spin_lock(&ports_lock);
2244 list_del_init(&priv->
list);
2245 spin_unlock(&ports_lock);
2246 #if defined(CONFIG_PARPORT_PC_FIFO) && defined(HAS_DMA)
2257 #if defined(CONFIG_PARPORT_PC_FIFO) && defined(HAS_DMA)
2276 short inta_addr[6] = { 0x2A0, 0x2C0, 0x220, 0x240, 0x1E0 };
2278 u32 ite8872_lpt, ite8872_lpthi;
2286 for (i = 0; i < 5; i++) {
2289 pci_write_config_dword(pdev, 0x60,
2290 0xe5000000 | inta_addr[i]);
2291 pci_write_config_dword(pdev, 0x78,
2292 0x00000000 | inta_addr[i]);
2293 test =
inb(inta_addr[i]);
2304 type =
inb(inta_addr[i] + 0x18);
2310 ite8872set = 0x64200000;
2314 ite8872set = 0x64200000;
2318 ite8872set = 0x64e00000;
2336 pci_read_config_byte(pdev, 0x3c, &ite8872_irq);
2337 pci_read_config_dword(pdev, 0x1c, &ite8872_lpt);
2338 ite8872_lpt &= 0x0000ff00;
2339 pci_read_config_dword(pdev, 0x20, &ite8872_lpthi);
2340 ite8872_lpthi &= 0x0000ff00;
2341 pci_write_config_dword(pdev, 0x6c, 0xe3000000 | ite8872_lpt);
2342 pci_write_config_dword(pdev, 0x70, 0xe3000000 | ite8872_lpthi);
2343 pci_write_config_dword(pdev, 0x80, (ite8872_lpthi<<16) | ite8872_lpt);
2346 pci_write_config_dword(pdev, 0x9c,
2347 ite8872set | (ite8872_irq * 0x11111));
2367 "parport_pc: ITE 8872 parallel port: io=0x%X",
2406 u8 tmp, tmp2, siofunc;
2409 unsigned port1, port2;
2410 unsigned have_epp = 0;
2414 switch (parport_init_mode) {
2443 "parport_pc: probing current configuration\n");
2480 if (port1 == 0x3BC && have_epp) {
2484 "parport_pc: Parallel port base changed to 0x378\n");
2523 port2 = 0x7bc;
break;
2525 port2 = 0x778;
break;
2527 port2 = 0x678;
break;
2530 "parport_pc: Weird VIA parport base 0x%X, ignoring\n",
2551 "parport_pc: VIA parallel port: io=0x%X", port1);
2560 printk(
KERN_WARNING "parport_pc: Strange, can't probe VIA parallel port: io=0x%X, irq=%d, dma=%d\n",
2566 enum parport_pc_sio_types {
2574 static struct parport_pc_superio {
2575 int (*probe) (
struct pci_dev *pdev,
int autoirq,
int autodma,
2578 } parport_pc_superio_info[] __devinitdata = {
2579 { sio_via_probe, &via_686a_data, },
2580 { sio_via_probe, &via_8231_data, },
2581 { sio_ite_8872_probe,
NULL, },
2585 siig_1p_10x = last_sio,
2590 lava_parallel_dual_a,
2591 lava_parallel_dual_b,
2643 { 1, { { 2, 3 }, } },
2644 { 2, { { 2, 3 }, { 4, 5 }, } },
2645 { 1, { { 0, 1 }, } },
2646 { 2, { { 0, 1 }, { 2, 3 }, } },
2647 { 1, { { 0, -1 }, } },
2648 { 1, { { 0, -1 }, } },
2649 { 1, { { 0, -1 }, } },
2650 { 1, { { 0, -1 }, } },
2651 { 2, { { 4, -1 }, { 5, -1 }, } },
2652 { 1, { { 0, -1 }, } },
2653 { 2, { { 0, -1 }, { 2, -1 }, } },
2654 { 1, { { 0, 1 }, } },
2655 { 2, { { 0, 1 }, { 2, 3 }, } },
2656 { 2, { { 0, 1 }, { 2, 3 }, } },
2659 { 2, { { 0, 0x078 }, { 0, 0x178 }, } },
2660 { 1, { { 0, 0x078 }, } },
2661 { 1, { { 3, -1 }, } },
2662 { 1, { { 0, 1 }, } },
2663 { 2, { { 0, 1 }, { 2, 3 }, } },
2664 { 1, { { 0, 1}, } },
2665 { 2, { { 0, 1}, { 2, 3 },} },
2668 { 1, { { 0, 1 }, } },
2669 { 1, { { 0, -1 }, } },
2670 { 1, { { 0, 1 }, } },
2671 { 1, { { 0, 1 }, } },
2672 { 1, { { 0, -1 }, } },
2673 { 1, { { 0, 1 }, } },
2676 { 1, { { 0, -1 }, } },
2677 { 2, { { 0, 1 }, { 2, 3 },} },
2678 { 2, { { 0, 1 }, { 2, 3 },} },
2679 { 1, { { 0, -1 }, } },
2680 { 2, { { 0, -1 }, { 2, -1 }, } },
2681 { 1, { { 0, -1 }, } },
2682 { 1, { { 0, -1 }, } },
2683 { 1, { { 0, 1 }, } },
2713 { 0x1409, 0x7268, 0x1409, 0x0101, 0, 0, timedia_4006a },
2714 { 0x1409, 0x7268, 0x1409, 0x0102, 0, 0, timedia_4014 },
2715 { 0x1409, 0x7268, 0x1409, 0x0103, 0, 0, timedia_4008a },
2716 { 0x1409, 0x7268, 0x1409, 0x0104, 0, 0, timedia_4018 },
2717 { 0x1409, 0x7268, 0x1409, 0x9018, 0, 0, timedia_9018a },
2724 { 0x9710, 0x9805, 0x1000, 0x0010, 0, 0, titan_1284p1 },
2725 { 0x9710, 0x9815, 0x1000, 0x0020, 0, 0, titan_1284p2 },
2767 0xA000, 0x2000, 0, 0, netmos_9901 },
2769 0xA000, 0x1000, 0, 0, netmos_9865 },
2771 0xA000, 0x2000, 0, 0, netmos_9865 },
2779 struct pci_parport_data {
2784 static int parport_pc_pci_probe(
struct pci_dev *dev,
2788 struct pci_parport_data *
data;
2805 if (cards[i].preinit_hook &&
2811 for (n = 0; n <
cards[
i].numports; n++) {
2815 unsigned long io_lo, io_hi;
2818 if ((hi >= 0) && (hi <= 6))
2828 "PCI parallel port detected: %04x:%04x, I/O at %#lx(%#lx)\n",
2829 parport_pc_pci_tbl[i + last_sio].
vendor,
2830 parport_pc_pci_tbl[i + last_sio].
device,
2835 "PCI parallel port detected: %04x:%04x, I/O at %#lx(%#lx), IRQ %d\n",
2836 parport_pc_pci_tbl[i + last_sio].
vendor,
2837 parport_pc_pci_tbl[i + last_sio].
device,
2840 data->ports[
count] =
2844 if (data->ports[count])
2850 if (cards[i].postinit_hook)
2851 cards[
i].postinit_hook(dev, count == 0);
2854 pci_set_drvdata(dev, data);
2865 struct pci_parport_data *data = pci_get_drvdata(dev);
2868 pci_set_drvdata(dev,
NULL);
2871 for (i = data->num - 1; i >= 0; i--)
2878 static struct pci_driver parport_pc_pci_driver = {
2879 .name =
"parport_pc",
2880 .id_table = parport_pc_pci_tbl,
2881 .probe = parport_pc_pci_probe,
2885 static int __init parport_pc_init_superio(
int autoirq,
int autodma)
2896 if (parport_pc_superio_info[id->
driver_data].probe(
2897 pdev, autoirq, autodma,
2906 static struct pci_driver parport_pc_pci_driver;
2907 static int __init parport_pc_init_superio(
int autoirq,
int autodma)
2917 {.
id =
"PNP0400", .driver_data = 0},
2919 {.id =
"PNP0401", .driver_data = 0},
2925 static int parport_pc_pnp_probe(
struct pnp_dev *dev,
2929 unsigned long io_lo, io_hi;
2932 if (pnp_port_valid(dev, 0) &&
2934 io_lo = pnp_port_start(dev, 0);
2938 if (pnp_port_valid(dev, 1) &&
2940 io_hi = pnp_port_start(dev, 1);
2944 if (pnp_irq_valid(dev, 0) &&
2950 if (pnp_dma_valid(dev, 0) &&
2961 pnp_set_drvdata(dev, pdata);
2965 static void parport_pc_pnp_remove(
struct pnp_dev *dev)
2975 static struct pnp_driver parport_pc_pnp_driver = {
2976 .name =
"parport_pc",
2977 .id_table = parport_pc_pnp_tbl,
2978 .probe = parport_pc_pnp_probe,
2979 .remove = parport_pc_pnp_remove,
2983 static struct pnp_driver parport_pc_pnp_driver;
2996 .name =
"parport_pc",
2998 .probe = parport_pc_platform_probe,
3003 parport_pc_find_isa_ports(
int autoirq,
int autodma)
3027 static void __init parport_pc_find_ports(
int autoirq,
int autodma)
3031 #ifdef CONFIG_PARPORT_PC_SUPERIO
3032 detect_and_report_it87();
3033 detect_and_report_winbond();
3034 detect_and_report_smsc();
3038 count += parport_pc_init_superio(autoirq, autodma);
3044 pnp_registered_parport = 1;
3048 parport_pc_find_nonpci_ports(autoirq, autodma);
3050 err = pci_register_driver(&parport_pc_pci_driver);
3052 pci_registered_parport = 1;
3074 static int __init parport_parse_param(
const char *s,
int *
val,
3081 else if (!
strncmp(s,
"none", 4))
3083 else if (nofifo && !
strncmp(s,
"nofifo", 6))
3098 static int __init parport_parse_irq(
const char *irqstr,
int *val)
3104 static int __init parport_parse_dma(
const char *dmastr,
int *val)
3111 static int __init parport_init_mode_setup(
char *
str)
3114 "parport_pc.c: Specified parameter parport_init_mode=%s\n", str);
3117 parport_init_mode = 1;
3119 parport_init_mode = 2;
3121 parport_init_mode = 3;
3123 parport_init_mode = 4;
3124 if (!
strcmp(str,
"ecpepp"))
3125 parport_init_mode = 5;
3142 #if defined(CONFIG_PARPORT_PC_SUPERIO) || \
3143 (defined(CONFIG_PARPORT_1284) && defined(CONFIG_PARPORT_PC_FIFO))
3148 static char *init_mode;
3150 "Initialise mode for VIA VT8231 port (spp, ps2, epp, ecp or ecpepp)");
3154 static int __init parse_parport_params(
void)
3161 parport_init_mode_setup(init_mode);
3165 if (parport_parse_irq(irq[i], &val))
3168 if (parport_parse_dma(dma[i], &val))
3174 if (irq[0] && !parport_parse_irq(irq[0], &val))
3182 "parport_pc: irq specified "
3183 "without base address. Use 'io=' "
3184 "to specify one\n");
3187 if (dma[0] && !parport_parse_dma(dma[0], &val))
3195 "parport_pc: dma specified "
3196 "without base address. Use 'io=' "
3197 "to specify one\n");
3216 static int __init parport_setup(
char *str)
3222 if (!str || !*str || (*str ==
'0' && !*(str+1))) {
3228 if (!
strncmp(str,
"auto", 4)) {
3235 if (endptr == str) {
3245 io[parport_setup_ptr] =
val;
3251 if (parport_parse_irq(sep, &val))
3253 irqval[parport_setup_ptr] =
val;
3256 if (parport_parse_dma(sep, &val))
3258 dmaval[parport_setup_ptr] =
val;
3261 parport_setup_ptr++;
3265 static int __init parse_parport_params(
void)
3270 __setup(
"parport=", parport_setup);
3278 __setup(
"parport_init_mode=", parport_init_mode_setup);
3284 static int __init parport_pc_init(
void)
3288 if (parse_parport_params())
3303 io_hi[
i] = 0x400 + io[
i];
3305 irqval[i], dmaval[i],
NULL, 0);
3308 parport_pc_find_ports(irqval[0], dmaval[0]);
3313 static void __exit parport_pc_exit(
void)
3315 if (pci_registered_parport)
3317 if (pnp_registered_parport)
3321 while (!list_empty(&ports_list)) {