Commit 65a2d74b authored by corentin.labbe's avatar corentin.labbe Committed by Jean Delvare

i2c-ali1535: enable SPARC support

The i2c-ali1535 driver doesn't work on SPARC, because it assumes that
ioport address are 16-bit wide (address stored in an unsigned short).
But on SPARC arch, ioports are mapped in memory and so must be stored
in an unsigned long.

Use pci_resource_start for getting IOMEM base address, then read the
SMBBA of the i2c bus and use these together for I/O access.

I would like to thank Jean DELVARE for reviewing my patch.
Signed-off-by: default avatarLABBE Corentin <corentin.labbe@geomatys.fr>
Signed-off-by: default avatarJean Delvare <khali@linux-fr.org>
parent 7c1f59c9
...@@ -132,7 +132,8 @@ ...@@ -132,7 +132,8 @@
#define ALI1535_SMBIO_EN 0x04 /* SMB I/O Space enable */ #define ALI1535_SMBIO_EN 0x04 /* SMB I/O Space enable */
static struct pci_driver ali1535_driver; static struct pci_driver ali1535_driver;
static unsigned short ali1535_smba; static unsigned long ali1535_smba;
static unsigned short ali1535_offset;
/* Detect whether a ALI1535 can be found, and initialize it, where necessary. /* Detect whether a ALI1535 can be found, and initialize it, where necessary.
Note the differences between kernels with the old PCI BIOS interface and 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,16 +150,28 @@ static int __devinit ali1535_setup(struct pci_dev *dev)
- We can use the addresses - We can use the addresses
*/ */
retval = pci_enable_device(dev);
if (retval) {
dev_err(&dev->dev, "ALI1535_smb can't enable device\n");
goto exit;
}
/* Determine the address of the SMBus area */ /* Determine the address of the SMBus area */
pci_read_config_word(dev, SMBBA, &ali1535_smba); pci_read_config_word(dev, SMBBA, &ali1535_offset);
ali1535_smba &= (0xffff & ~(ALI1535_SMB_IOSIZE - 1)); dev_dbg(&dev->dev, "ALI1535_smb is at offset 0x%04x\n", ali1535_offset);
if (ali1535_smba == 0) { ali1535_offset &= (0xffff & ~(ALI1535_SMB_IOSIZE - 1));
if (ali1535_offset == 0) {
dev_warn(&dev->dev, dev_warn(&dev->dev,
"ALI1535_smb region uninitialized - upgrade BIOS?\n"); "ALI1535_smb region uninitialized - upgrade BIOS?\n");
retval = -ENODEV; retval = -ENODEV;
goto exit; goto exit;
} }
if (pci_resource_flags(dev, 0) & IORESOURCE_IO)
ali1535_smba = pci_resource_start(dev, 0) + ali1535_offset;
else
ali1535_smba = ali1535_offset;
retval = acpi_check_region(ali1535_smba, ALI1535_SMB_IOSIZE, retval = acpi_check_region(ali1535_smba, ALI1535_SMB_IOSIZE,
ali1535_driver.name); ali1535_driver.name);
if (retval) if (retval)
...@@ -166,7 +179,7 @@ static int __devinit ali1535_setup(struct pci_dev *dev) ...@@ -166,7 +179,7 @@ static int __devinit ali1535_setup(struct pci_dev *dev)
if (!request_region(ali1535_smba, ALI1535_SMB_IOSIZE, if (!request_region(ali1535_smba, ALI1535_SMB_IOSIZE,
ali1535_driver.name)) { ali1535_driver.name)) {
dev_err(&dev->dev, "ALI1535_smb region 0x%x already in use!\n", dev_err(&dev->dev, "ALI1535_smb region 0x%lx already in use!\n",
ali1535_smba); ali1535_smba);
retval = -EBUSY; retval = -EBUSY;
goto exit; goto exit;
...@@ -200,7 +213,7 @@ static int __devinit ali1535_setup(struct pci_dev *dev) ...@@ -200,7 +213,7 @@ static int __devinit ali1535_setup(struct pci_dev *dev)
*/ */
pci_read_config_byte(dev, SMBREV, &temp); pci_read_config_byte(dev, SMBREV, &temp);
dev_dbg(&dev->dev, "SMBREV = 0x%X\n", temp); dev_dbg(&dev->dev, "SMBREV = 0x%X\n", temp);
dev_dbg(&dev->dev, "ALI1535_smba = 0x%X\n", ali1535_smba); dev_dbg(&dev->dev, "ALI1535_smba = 0x%lx\n", ali1535_smba);
return 0; return 0;
...@@ -501,7 +514,7 @@ static int __devinit ali1535_probe(struct pci_dev *dev, const struct pci_device_ ...@@ -501,7 +514,7 @@ static int __devinit ali1535_probe(struct pci_dev *dev, const struct pci_device_
ali1535_adapter.dev.parent = &dev->dev; ali1535_adapter.dev.parent = &dev->dev;
snprintf(ali1535_adapter.name, sizeof(ali1535_adapter.name), snprintf(ali1535_adapter.name, sizeof(ali1535_adapter.name),
"SMBus ALI1535 adapter at %04x", ali1535_smba); "SMBus ALI1535 adapter at %04x", ali1535_offset);
return i2c_add_adapter(&ali1535_adapter); return i2c_add_adapter(&ali1535_adapter);
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment