Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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: LABBE Corentin <corentin.labbe@geomatys.fr>
Signed-off-by: Jean Delvare <khali@linux-fr.org>

authored by

corentin.labbe and committed by
Jean Delvare
65a2d74b 7c1f59c9

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