diff options
Diffstat (limited to 'drivers/i2c/busses/i2c-ali1563.c')
-rw-r--r-- | drivers/i2c/busses/i2c-ali1563.c | 58 |
1 files changed, 30 insertions, 28 deletions
diff --git a/drivers/i2c/busses/i2c-ali1563.c b/drivers/i2c/busses/i2c-ali1563.c index 8e1e3f8e40a4..6b68074e518a 100644 --- a/drivers/i2c/busses/i2c-ali1563.c +++ b/drivers/i2c/busses/i2c-ali1563.c | |||
@@ -314,35 +314,11 @@ static u32 ali1563_func(struct i2c_adapter * a) | |||
314 | } | 314 | } |
315 | 315 | ||
316 | 316 | ||
317 | static 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 | |||
326 | static int __devinit ali1563_setup(struct pci_dev * dev) | 317 | static 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 | printk("ali1563: SMBus control = %04x\n",ctrl); | ||
332 | |||
333 | /* Check if device is even enabled first */ | ||
334 | if (!(ctrl & ALI1563_SMB_IOEN)) { | ||
335 | dev_warn(&dev->dev,"I/O space not enabled, trying manually\n"); | ||
336 | ali1563_enable(dev); | ||
337 | } | ||
338 | if (!(ctrl & ALI1563_SMB_IOEN)) { | ||
339 | dev_warn(&dev->dev,"I/O space still not enabled, giving up\n"); | ||
340 | goto Err; | ||
341 | } | ||
342 | if (!(ctrl & ALI1563_SMB_HOSTEN)) { | ||
343 | dev_warn(&dev->dev,"Host Controller not enabled\n"); | ||
344 | goto Err; | ||
345 | } | ||
346 | 322 | ||
347 | /* 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 |
348 | * size of the I/O space. */ | 324 | * size of the I/O space. */ |
@@ -351,11 +327,31 @@ static int __devinit ali1563_setup(struct pci_dev * dev) | |||
351 | dev_warn(&dev->dev,"ali1563_smba Uninitialized\n"); | 327 | dev_warn(&dev->dev,"ali1563_smba Uninitialized\n"); |
352 | goto Err; | 328 | goto Err; |
353 | } | 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 | |||
354 | if (!request_region(ali1563_smba, ALI1563_SMB_IOSIZE, | 348 | if (!request_region(ali1563_smba, ALI1563_SMB_IOSIZE, |
355 | ali1563_pci_driver.name)) { | 349 | ali1563_pci_driver.name)) { |
356 | dev_warn(&dev->dev,"Could not allocate I/O space"); | 350 | dev_err(&dev->dev, "Could not allocate I/O space at 0x%04x\n", |
351 | ali1563_smba); | ||
357 | goto Err; | 352 | goto Err; |
358 | } | 353 | } |
354 | dev_info(&dev->dev, "Found ALi1563 SMBus at 0x%04x\n", ali1563_smba); | ||
359 | 355 | ||
360 | return 0; | 356 | return 0; |
361 | Err: | 357 | Err: |
@@ -374,6 +370,7 @@ static const struct i2c_algorithm ali1563_algorithm = { | |||
374 | 370 | ||
375 | static struct i2c_adapter ali1563_adapter = { | 371 | static struct i2c_adapter ali1563_adapter = { |
376 | .owner = THIS_MODULE, | 372 | .owner = THIS_MODULE, |
373 | .id = I2C_HW_SMBUS_ALI1563, | ||
377 | .class = I2C_CLASS_HWMON, | 374 | .class = I2C_CLASS_HWMON, |
378 | .algo = &ali1563_algorithm, | 375 | .algo = &ali1563_algorithm, |
379 | }; | 376 | }; |
@@ -384,13 +381,18 @@ static int __devinit ali1563_probe(struct pci_dev * dev, | |||
384 | int error; | 381 | int error; |
385 | 382 | ||
386 | if ((error = ali1563_setup(dev))) | 383 | if ((error = ali1563_setup(dev))) |
387 | return error; | 384 | goto exit; |
388 | ali1563_adapter.dev.parent = &dev->dev; | 385 | ali1563_adapter.dev.parent = &dev->dev; |
389 | sprintf(ali1563_adapter.name,"SMBus ALi 1563 Adapter @ %04x", | 386 | sprintf(ali1563_adapter.name,"SMBus ALi 1563 Adapter @ %04x", |
390 | ali1563_smba); | 387 | ali1563_smba); |
391 | if ((error = i2c_add_adapter(&ali1563_adapter))) | 388 | if ((error = i2c_add_adapter(&ali1563_adapter))) |
392 | ali1563_shutdown(dev); | 389 | goto exit_shutdown; |
393 | printk("%s: Returning %d\n",__FUNCTION__,error); | 390 | return 0; |
391 | |||
392 | exit_shutdown: | ||
393 | ali1563_shutdown(dev); | ||
394 | exit: | ||
395 | dev_warn(&dev->dev, "ALi1563 SMBus probe failed (%d)\n", error); | ||
394 | return error; | 396 | return error; |
395 | } | 397 | } |
396 | 398 | ||