aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--drivers/i2c/busses/i2c-ali1563.c41
1 files changed, 18 insertions, 23 deletions
diff --git a/drivers/i2c/busses/i2c-ali1563.c b/drivers/i2c/busses/i2c-ali1563.c
index 3b0e79b1e871..55ebbef41e97 100644
--- a/drivers/i2c/busses/i2c-ali1563.c
+++ b/drivers/i2c/busses/i2c-ali1563.c
@@ -314,35 +314,12 @@ static u32 ali1563_func(struct i2c_adapter * a)
314} 314}
315 315
316 316
317static void ali1563_enable(struct pci_dev * dev)
318{
319 u16 ctrl;
320
321 pci_read_config_word(dev,ALI1563_SMBBA,&ctrl);
322 ctrl |= 0x7;
323 pci_write_config_word(dev,ALI1563_SMBBA,ctrl);
324}
325
326static int __devinit ali1563_setup(struct pci_dev * dev) 317static int __devinit ali1563_setup(struct pci_dev * dev)
327{ 318{
328 u16 ctrl; 319 u16 ctrl;
329 320
330 pci_read_config_word(dev,ALI1563_SMBBA,&ctrl); 321 pci_read_config_word(dev,ALI1563_SMBBA,&ctrl);
331 322
332 /* Check if device is even enabled first */
333 if (!(ctrl & ALI1563_SMB_IOEN)) {
334 dev_warn(&dev->dev,"I/O space not enabled, trying manually\n");
335 ali1563_enable(dev);
336 }
337 if (!(ctrl & ALI1563_SMB_IOEN)) {
338 dev_warn(&dev->dev,"I/O space still not enabled, giving up\n");
339 goto Err;
340 }
341 if (!(ctrl & ALI1563_SMB_HOSTEN)) {
342 dev_warn(&dev->dev,"Host Controller not enabled\n");
343 goto Err;
344 }
345
346 /* SMB I/O Base in high 12 bits and must be aligned with the 323 /* SMB I/O Base in high 12 bits and must be aligned with the
347 * size of the I/O space. */ 324 * size of the I/O space. */
348 ali1563_smba = ctrl & ~(ALI1563_SMB_IOSIZE - 1); 325 ali1563_smba = ctrl & ~(ALI1563_SMB_IOSIZE - 1);
@@ -350,6 +327,24 @@ static int __devinit ali1563_setup(struct pci_dev * dev)
350 dev_warn(&dev->dev,"ali1563_smba Uninitialized\n"); 327 dev_warn(&dev->dev,"ali1563_smba Uninitialized\n");
351 goto Err; 328 goto Err;
352 } 329 }
330
331 /* Check if device is enabled */
332 if (!(ctrl & ALI1563_SMB_HOSTEN)) {
333 dev_warn(&dev->dev, "Host Controller not enabled\n");
334 goto Err;
335 }
336 if (!(ctrl & ALI1563_SMB_IOEN)) {
337 dev_warn(&dev->dev, "I/O space not enabled, trying manually\n");
338 pci_write_config_word(dev, ALI1563_SMBBA,
339 ctrl | ALI1563_SMB_IOEN);
340 pci_read_config_word(dev, ALI1563_SMBBA, &ctrl);
341 if (!(ctrl & ALI1563_SMB_IOEN)) {
342 dev_err(&dev->dev, "I/O space still not enabled, "
343 "giving up\n");
344 goto Err;
345 }
346 }
347
353 if (!request_region(ali1563_smba, ALI1563_SMB_IOSIZE, 348 if (!request_region(ali1563_smba, ALI1563_SMB_IOSIZE,
354 ali1563_pci_driver.name)) { 349 ali1563_pci_driver.name)) {
355 dev_err(&dev->dev, "Could not allocate I/O space at 0x%04x\n", 350 dev_err(&dev->dev, "Could not allocate I/O space at 0x%04x\n",