diff options
-rw-r--r-- | drivers/i2c/busses/i2c-ali1535.c | 27 |
1 files changed, 20 insertions, 7 deletions
diff --git a/drivers/i2c/busses/i2c-ali1535.c b/drivers/i2c/busses/i2c-ali1535.c index 5b667e53a813..e66d248fc126 100644 --- a/drivers/i2c/busses/i2c-ali1535.c +++ b/drivers/i2c/busses/i2c-ali1535.c | |||
@@ -132,7 +132,8 @@ | |||
132 | #define ALI1535_SMBIO_EN 0x04 /* SMB I/O Space enable */ | 132 | #define ALI1535_SMBIO_EN 0x04 /* SMB I/O Space enable */ |
133 | 133 | ||
134 | static struct pci_driver ali1535_driver; | 134 | static struct pci_driver ali1535_driver; |
135 | static unsigned short ali1535_smba; | 135 | static unsigned long ali1535_smba; |
136 | static unsigned short ali1535_offset; | ||
136 | 137 | ||
137 | /* Detect whether a ALI1535 can be found, and initialize it, where necessary. | 138 | /* Detect whether a ALI1535 can be found, and initialize it, where necessary. |
138 | Note the differences between kernels with the old PCI BIOS interface and | 139 | Note the differences between kernels with the old PCI BIOS interface and |
@@ -149,16 +150,28 @@ static int __devinit ali1535_setup(struct pci_dev *dev) | |||
149 | - We can use the addresses | 150 | - We can use the addresses |
150 | */ | 151 | */ |
151 | 152 | ||
153 | retval = pci_enable_device(dev); | ||
154 | if (retval) { | ||
155 | dev_err(&dev->dev, "ALI1535_smb can't enable device\n"); | ||
156 | goto exit; | ||
157 | } | ||
158 | |||
152 | /* Determine the address of the SMBus area */ | 159 | /* Determine the address of the SMBus area */ |
153 | pci_read_config_word(dev, SMBBA, &ali1535_smba); | 160 | pci_read_config_word(dev, SMBBA, &ali1535_offset); |
154 | ali1535_smba &= (0xffff & ~(ALI1535_SMB_IOSIZE - 1)); | 161 | dev_dbg(&dev->dev, "ALI1535_smb is at offset 0x%04x\n", ali1535_offset); |
155 | if (ali1535_smba == 0) { | 162 | ali1535_offset &= (0xffff & ~(ALI1535_SMB_IOSIZE - 1)); |
163 | if (ali1535_offset == 0) { | ||
156 | dev_warn(&dev->dev, | 164 | dev_warn(&dev->dev, |
157 | "ALI1535_smb region uninitialized - upgrade BIOS?\n"); | 165 | "ALI1535_smb region uninitialized - upgrade BIOS?\n"); |
158 | retval = -ENODEV; | 166 | retval = -ENODEV; |
159 | goto exit; | 167 | goto exit; |
160 | } | 168 | } |
161 | 169 | ||
170 | if (pci_resource_flags(dev, 0) & IORESOURCE_IO) | ||
171 | ali1535_smba = pci_resource_start(dev, 0) + ali1535_offset; | ||
172 | else | ||
173 | ali1535_smba = ali1535_offset; | ||
174 | |||
162 | retval = acpi_check_region(ali1535_smba, ALI1535_SMB_IOSIZE, | 175 | retval = acpi_check_region(ali1535_smba, ALI1535_SMB_IOSIZE, |
163 | ali1535_driver.name); | 176 | ali1535_driver.name); |
164 | if (retval) | 177 | if (retval) |
@@ -166,7 +179,7 @@ static int __devinit ali1535_setup(struct pci_dev *dev) | |||
166 | 179 | ||
167 | if (!request_region(ali1535_smba, ALI1535_SMB_IOSIZE, | 180 | if (!request_region(ali1535_smba, ALI1535_SMB_IOSIZE, |
168 | ali1535_driver.name)) { | 181 | ali1535_driver.name)) { |
169 | dev_err(&dev->dev, "ALI1535_smb region 0x%x already in use!\n", | 182 | dev_err(&dev->dev, "ALI1535_smb region 0x%lx already in use!\n", |
170 | ali1535_smba); | 183 | ali1535_smba); |
171 | retval = -EBUSY; | 184 | retval = -EBUSY; |
172 | goto exit; | 185 | goto exit; |
@@ -200,7 +213,7 @@ static int __devinit ali1535_setup(struct pci_dev *dev) | |||
200 | */ | 213 | */ |
201 | pci_read_config_byte(dev, SMBREV, &temp); | 214 | pci_read_config_byte(dev, SMBREV, &temp); |
202 | dev_dbg(&dev->dev, "SMBREV = 0x%X\n", temp); | 215 | dev_dbg(&dev->dev, "SMBREV = 0x%X\n", temp); |
203 | dev_dbg(&dev->dev, "ALI1535_smba = 0x%X\n", ali1535_smba); | 216 | dev_dbg(&dev->dev, "ALI1535_smba = 0x%lx\n", ali1535_smba); |
204 | 217 | ||
205 | return 0; | 218 | return 0; |
206 | 219 | ||
@@ -501,7 +514,7 @@ static int __devinit ali1535_probe(struct pci_dev *dev, const struct pci_device_ | |||
501 | ali1535_adapter.dev.parent = &dev->dev; | 514 | ali1535_adapter.dev.parent = &dev->dev; |
502 | 515 | ||
503 | snprintf(ali1535_adapter.name, sizeof(ali1535_adapter.name), | 516 | snprintf(ali1535_adapter.name, sizeof(ali1535_adapter.name), |
504 | "SMBus ALI1535 adapter at %04x", ali1535_smba); | 517 | "SMBus ALI1535 adapter at %04x", ali1535_offset); |
505 | return i2c_add_adapter(&ali1535_adapter); | 518 | return i2c_add_adapter(&ali1535_adapter); |
506 | } | 519 | } |
507 | 520 | ||