Changeset 3917
- Timestamp:
- 07/18/04 21:32:35 (4 years ago)
- Files:
-
- i2c/trunk/CHANGES (modified) (1 diff)
- i2c/trunk/kernel/i2c-pport.c (modified) (8 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
i2c/trunk/CHANGES
r3916 r3917 20 20 2.8.8 (???) 21 21 Makefile: Do not export i2c-dev.h 22 i2c-pport.c: Code cleanups 23 Do not test lines, i2c-algo-bit already does 22 24 23 25 2.8.7 (20040611) i2c/trunk/kernel/i2c-pport.c
r3885 r3917 24 24 25 25 Cut & paste :-) based on Velleman K8000 driver by Simon G. Vogl 26 27 Note that SDA is hardware inverted. 26 28 */ 27 29 … … 40 42 41 43 #define DEFAULT_BASE 0x378 42 static int base =0;44 static int base = DEFAULT_BASE; 43 45 static unsigned char PortData = 0; 44 46 … … 55 57 #define CTRL (BASE+2) /* Centronics control port */ 56 58 57 /* we will use SDA - Auto Linefeed(14) bit 1 POUT*/58 /* we will use SCL - Initialize printer(16) BUSY bit 2*/59 /* we will use SDA - Auto Linefeed(14) POUT (ctrl bit 1) */ 60 /* we will use SCL - Initialize printer(16) BUSY (ctrl bit 2) */ 59 61 60 62 #define SET_SCL | 0x04 61 63 #define CLR_SCL & 0xFB 62 64 63 64 65 66 #define SET_SDA & 0x04 65 #define SET_SDA & 0xFD 67 66 #define CLR_SDA | 0x02 68 67 … … 74 73 { 75 74 if (state) { 76 //high77 75 PortData = PortData SET_SCL; 78 76 } else { 79 //low80 77 PortData = PortData CLR_SCL; 81 78 } … … 86 83 { 87 84 if (state) { 88 89 85 PortData = PortData SET_SDA; 90 86 } else { 91 92 87 PortData = PortData CLR_SDA; 93 88 } … … 97 92 static int bit_pport_getscl(void *data) 98 93 { 99 100 94 return ( 4 == ( (inb_p(CTRL)) & 0x04 ) ); 101 95 } … … 110 104 if (!request_region((base+2),1, "i2c (PPORT adapter)")) { 111 105 return -ENODEV; 112 } else { 113 /* test for PPORT adap. */ 114 106 } 115 107 116 PortData=inb(base+2);117 PortData= (PortData SET_SDA) SET_SCL;118 outb(PortData,base+2);108 PortData = inb(base+2); 109 bit_pport_setsda((void*)base, 1); 110 bit_pport_setscl((void*)base, 1); 119 111 120 if (!(inb(base+2) | 0x06)) { /* SDA and SCL will be high */121 DEBINIT(printk("i2c-pport.o: SDA and SCL was low.\n"));122 return -ENODEV;123 } else {124 125 /*SCL high and SDA low*/126 PortData = PortData SET_SCL CLR_SDA;127 outb(PortData,base+2);128 schedule_timeout(400);129 if ( !(inb(base+2) | 0x4) ) {130 //outb(0x04,base+2);131 DEBINIT(printk("i2c-port.o: SDA was high.\n"));132 return -ENODEV;133 }134 }135 bit_pport_setsda((void*)base,1);136 bit_pport_setscl((void*)base,1);137 }138 112 return 0; 139 113 } … … 165 139 printk("i2c-pport.o: i2c Primitive parallel port adapter module version %s (%s)\n", I2C_VERSION, I2C_DATE); 166 140 167 if (base==0) { 168 /* probe some values */ 169 base=DEFAULT_BASE; 170 bit_pport_data.data=(void*)DEFAULT_BASE; 171 if (bit_pport_init()==0) { 172 if(i2c_bit_add_bus(&bit_pport_ops) < 0) 173 return -ENODEV; 174 } else { 175 return -ENODEV; 176 } 177 } else { 178 bit_pport_data.data=(void*)base; 179 if (bit_pport_init()==0) { 180 if(i2c_bit_add_bus(&bit_pport_ops) < 0) 181 return -ENODEV; 182 } else { 183 return -ENODEV; 184 } 141 bit_pport_data.data = (void*)base; 142 if (bit_pport_init() < 0) 143 return -ENODEV; 144 145 if (i2c_bit_add_bus(&bit_pport_ops) < 0) { 146 release_region(base+2, 1); 147 return -ENODEV; 185 148 } 149 186 150 printk("i2c-pport.o: found device at %#x.\n",base); 187 151 return 0;
