Changeset 1344
- Timestamp:
- 04/02/02 03:54:05 (11 years ago)
- Files:
-
- 1 modified
-
lm-sensors/trunk/kernel/busses/i2c-savage4.c (modified) (16 diffs)
Legend:
- Unmodified
- Added
- Removed
-
lm-sensors/trunk/kernel/busses/i2c-savage4.c
r1343 r1344 1 1 /* 2 voodoo3.c - Part of lm_sensors, Linux kernel modules for hardware2 i2c-savage4.c - Part of lm_sensors, Linux kernel modules for hardware 3 3 monitoring 4 4 Copyright (c) 1998, 1999 Frodo Looijaard <frodol@dds.nl>, … … 25 25 */ 26 26 27 /* This interfaces to the I2C bus of the Voodoo3 to gain access to 28 the BT869 and possibly other I2C devices. */ 27 /* This interfaces to the I2C bus of the Savage4 to gain access to 28 the BT869 and possibly other I2C devices. The DDC bus is not 29 yet supported because its register is not memory-mapped. 30 However we leave the DDC code here, commented out, to make 31 it easier to add later. */ 29 32 30 33 #include <linux/version.h> … … 84 87 extern 85 88 #endif 86 int __init i2c_ voodoo3_init(void);87 static int __init voodoo3_cleanup(void);88 static int voodoo3_setup(void);89 static void config_ v3(struct pci_dev *dev);90 static void voodoo3_inc(struct i2c_adapter *adapter);91 static void voodoo3_dec(struct i2c_adapter *adapter);89 int __init i2c_savage4_init(void); 90 static int __init savage4_cleanup(void); 91 static int savage4_setup(void); 92 static void config_s4(struct pci_dev *dev); 93 static void savage4_inc(struct i2c_adapter *adapter); 94 static void savage4_dec(struct i2c_adapter *adapter); 92 95 93 96 #ifdef MODULE … … 97 100 98 101 99 static int __initdata voodoo3_initialized;102 static int __initdata savage4_initialized; 100 103 static unsigned char *mem; 101 104 … … 110 113 } 111 114 112 /* The vooGPIO registers don't have individual masks for each bit115 /* The sav GPIO registers don't have individual masks for each bit 113 116 so we always have to read before writing. */ 114 117 115 static void bit_ vooi2c_setscl(void *data, int val)118 static void bit_savi2c_setscl(void *data, int val) 116 119 { 117 120 unsigned int r; … … 124 127 } 125 128 126 static void bit_ vooi2c_setsda(void *data, int val)129 static void bit_savi2c_setsda(void *data, int val) 127 130 { 128 131 unsigned int r; … … 139 142 reading the input from other chips. */ 140 143 141 static int bit_ vooi2c_getscl(void *data)144 static int bit_savi2c_getscl(void *data) 142 145 { 143 146 return (0 != (readlong() & I2C_SCL_IN)); 144 147 } 145 148 146 static int bit_ vooi2c_getsda(void *data)149 static int bit_savi2c_getsda(void *data) 147 150 { 148 151 return (0 != (readlong() & I2C_SDA_IN)); 149 152 } 150 153 151 /*static void bit_ vooddc_setscl(void *data, int val)154 /*static void bit_savddc_setscl(void *data, int val) 152 155 { 153 156 unsigned int r; … … 160 163 } 161 164 162 static void bit_ vooddc_setsda(void *data, int val)165 static void bit_savddc_setsda(void *data, int val) 163 166 { 164 167 unsigned int r; … … 171 174 } 172 175 173 static int bit_ vooddc_getscl(void *data)176 static int bit_savddc_getscl(void *data) 174 177 { 175 178 return (0 != (readlong() & DDC_SCL_IN)); 176 179 } 177 180 178 static int bit_ vooddc_getsda(void *data)181 static int bit_savddc_getsda(void *data) 179 182 { 180 183 return (0 != (readlong() & DDC_SDA_IN)); 181 184 } 182 185 */ 183 static struct i2c_algo_bit_data voo_i2c_bit_data = {184 NULL, 185 bit_ vooi2c_setsda,186 bit_ vooi2c_setscl,187 bit_ vooi2c_getsda,188 bit_ vooi2c_getscl,186 static struct i2c_algo_bit_data sav_i2c_bit_data = { 187 NULL, 188 bit_savi2c_setsda, 189 bit_savi2c_setscl, 190 bit_savi2c_getsda, 191 bit_savi2c_getscl, 189 192 CYCLE_DELAY, CYCLE_DELAY, TIMEOUT 190 193 }; 191 194 192 static struct i2c_adapter voodoo3_i2c_adapter = {193 "I2C Voodoo3/Bansheeadapter",195 static struct i2c_adapter savage4_i2c_adapter = { 196 "I2C Savage4 adapter", 194 197 I2C_HW_B_VOO, 195 198 NULL, 196 & voo_i2c_bit_data,197 voodoo3_inc,198 voodoo3_dec,199 &sav_i2c_bit_data, 200 savage4_inc, 201 savage4_dec, 199 202 NULL, 200 203 NULL, 201 204 }; 202 205 /* 203 static struct i2c_algo_bit_data voo_ddc_bit_data = {204 NULL, 205 bit_ vooddc_setsda,206 bit_ vooddc_setscl,207 bit_ vooddc_getsda,208 bit_ vooddc_getscl,206 static struct i2c_algo_bit_data sav_ddc_bit_data = { 207 NULL, 208 bit_savddc_setsda, 209 bit_savddc_setscl, 210 bit_savddc_getsda, 211 bit_savddc_getscl, 209 212 CYCLE_DELAY, CYCLE_DELAY, TIMEOUT 210 213 }; 211 214 212 static struct i2c_adapter voodoo3_ddc_adapter = {215 static struct i2c_adapter savage4_ddc_adapter = { 213 216 "DDC Voodoo3/Banshee adapter", 214 217 I2C_HW_B_VOO, 215 218 NULL, 216 & voo_ddc_bit_data,217 voodoo3_inc,218 voodoo3_dec,219 &sav_ddc_bit_data, 220 savage4_inc, 221 savage4_dec, 219 222 NULL, 220 223 NULL, … … 223 226 /* Configures the chip */ 224 227 225 void config_ v3(struct pci_dev *dev)228 void config_s4(struct pci_dev *dev) 226 229 { 227 230 unsigned int cadr; 228 231 229 /* map Voodoo3memory */232 /* map memory */ 230 233 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,3,13) 231 234 cadr = dev->resource[0].start; … … 238 241 // *((unsigned int *) (mem + REG2)) = 0x8160; 239 242 *((unsigned int *) (mem + REG)) = 0x00000020; 240 printk("i2c-voodoo3: Using Banshee/Voodoo3 at 0x%p\n", mem); 241 } 242 243 /* Detect whether a Voodoo3 or a Banshee can be found, 244 and initialize it. */ 245 static int voodoo3_setup(void) 243 printk("i2c-savage4: Using Savage4 at 0x%p\n", mem); 244 } 245 246 /* Detect chip and initialize it. */ 247 static int savage4_setup(void) 246 248 { 247 249 struct pci_dev *dev; 248 int v3_num;249 250 v3_num = 0;250 int s4_num; 251 252 s4_num = 0; 251 253 252 254 dev = NULL; … … 255 257 PCI_CHIP_SAVAGE4, 256 258 dev))) { 257 if (! v3_num)258 config_ v3(dev);259 v3_num++;259 if (!s4_num) 260 config_s4(dev); 261 s4_num++; 260 262 } 261 263 } while (dev); … … 266 268 PCI_CHIP_SAVAGE2000, 267 269 dev))) { 268 if (! v3_num)269 config_ v3(dev);270 v3_num++;270 if (!s4_num) 271 config_s4(dev); 272 s4_num++; 271 273 } 272 274 } while (dev); 273 275 274 if ( v3_num > 0) {275 printk("i2c- voodoo3: %d Banshee/Voodoo3 found.\n", v3_num);276 if ( v3_num > 1)277 printk("i2c- voodoo3: warning: only 1 supported.\n");276 if (s4_num > 0) { 277 printk("i2c-savage4: %d Savage4 found.\n", s4_num); 278 if (s4_num > 1) 279 printk("i2c-savage4: warning: only 1 supported.\n"); 278 280 return 0; 279 281 } else { 280 printk("i2c- voodoo3: No Voodoo3found.\n");282 printk("i2c-savage4: No Savage4 found.\n"); 281 283 return -ENODEV; 282 284 } 283 285 } 284 286 285 void voodoo3_inc(struct i2c_adapter *adapter)287 void savage4_inc(struct i2c_adapter *adapter) 286 288 { 287 289 MOD_INC_USE_COUNT; 288 290 } 289 291 290 void voodoo3_dec(struct i2c_adapter *adapter)292 void savage4_dec(struct i2c_adapter *adapter) 291 293 { 292 294 MOD_DEC_USE_COUNT; 293 295 } 294 296 295 int __init i2c_ voodoo3_init(void)297 int __init i2c_savage4_init(void) 296 298 { 297 299 int res; 298 printk("i2c- voodoo3.o version %s (%s)\n", LM_VERSION, LM_DATE);299 voodoo3_initialized = 0;300 if ((res = voodoo3_setup())) {300 printk("i2c-savage4.o version %s (%s)\n", LM_VERSION, LM_DATE); 301 savage4_initialized = 0; 302 if ((res = savage4_setup())) { 301 303 printk 302 ("i2c- voodoo3.o: Voodoo3not detected, module not inserted.\n");303 voodoo3_cleanup();304 ("i2c-savage4.o: Savage4 not detected, module not inserted.\n"); 305 savage4_cleanup(); 304 306 return res; 305 307 } 306 if ((res = i2c_bit_add_bus(& voodoo3_i2c_adapter))) {307 printk("i2c- voodoo3.o: I2C adapter registration failed\n");308 if ((res = i2c_bit_add_bus(&savage4_i2c_adapter))) { 309 printk("i2c-savage4.o: I2C adapter registration failed\n"); 308 310 } else { 309 printk("i2c- voodoo3.o: I2C bus initialized\n");310 voodoo3_initialized |= INIT2;311 printk("i2c-savage4.o: I2C bus initialized\n"); 312 savage4_initialized |= INIT2; 311 313 } 312 314 /* 313 if ((res = i2c_bit_add_bus(& voodoo3_ddc_adapter))) {314 printk("i2c- voodoo3.o: DDC adapter registration failed\n");315 if ((res = i2c_bit_add_bus(&savage4_ddc_adapter))) { 316 printk("i2c-savage4.o: DDC adapter registration failed\n"); 315 317 } else { 316 printk("i2c- voodoo3.o: DDC bus initialized\n");317 voodoo3_initialized |= INIT3;318 } 319 */ 320 if(!( voodoo3_initialized & (INIT2 /* | INIT3 */ ))) {321 printk("i2c- voodoo3.o: Both registrations failed, module not inserted\n");322 voodoo3_cleanup();318 printk("i2c-savage4.o: DDC bus initialized\n"); 319 savage4_initialized |= INIT3; 320 } 321 */ 322 if(!(savage4_initialized & (INIT2 /* | INIT3 */ ))) { 323 printk("i2c-savage4.o: Both registrations failed, module not inserted\n"); 324 savage4_cleanup(); 323 325 return res; 324 326 } … … 326 328 } 327 329 328 int __init voodoo3_cleanup(void)330 int __init savage4_cleanup(void) 329 331 { 330 332 int res; … … 332 334 iounmap(mem); 333 335 /* 334 if ( voodoo3_initialized & INIT3) {335 if ((res = i2c_bit_del_bus(& voodoo3_ddc_adapter))) {336 if (savage4_initialized & INIT3) { 337 if ((res = i2c_bit_del_bus(&savage4_ddc_adapter))) { 336 338 printk 337 ("i2c- voodoo3.o: i2c_bit_del_bus failed, module not removed\n");339 ("i2c-savage4.o: i2c_bit_del_bus failed, module not removed\n"); 338 340 return res; 339 341 } 340 342 } 341 343 */ 342 if ( voodoo3_initialized & INIT2) {343 if ((res = i2c_bit_del_bus(& voodoo3_i2c_adapter))) {344 if (savage4_initialized & INIT2) { 345 if ((res = i2c_bit_del_bus(&savage4_i2c_adapter))) { 344 346 printk 345 ("i2c- voodoo3.o: i2c_bit_del_bus failed, module not removed\n");347 ("i2c-savage4.o: i2c_bit_del_bus failed, module not removed\n"); 346 348 return res; 347 349 } … … 356 358 MODULE_AUTHOR 357 359 ("Frodo Looijaard <frodol@dds.nl>, Philip Edelbrock <phil@netroedge.com>, Ralph Metzler <rjkm@thp.uni-koeln.de>, and Mark D. Studebaker <mdsxyz123@yahoo.com>"); 358 MODULE_DESCRIPTION(" Voodoo3I2C/SMBus driver");360 MODULE_DESCRIPTION("Savage4 I2C/SMBus driver"); 359 361 360 362 361 363 int init_module(void) 362 364 { 363 return i2c_ voodoo3_init();365 return i2c_savage4_init(); 364 366 } 365 367 366 368 int cleanup_module(void) 367 369 { 368 return voodoo3_cleanup();370 return savage4_cleanup(); 369 371 } 370 372
