From: "corentin.labbe" <corentin.labbe@geomatys.fr>
To: sparclinux@vger.kernel.org
Subject: patch for i2c_ali1535 working on SPARC
Date: Mon, 06 Jun 2011 08:01:31 +0000 [thread overview]
Message-ID: <4DEC895B.30101@geomatys.fr> (raw)
[-- Attachment #1: Type: text/plain, Size: 2603 bytes --]
Hello
I have a sun blade 100 and I want to get the sensors working with
lm_sensors, but in current state, it doesn't work.
After some research, i have found that all smbus driver and the i2c_ali1535 particularly cant work.
It assumes that ioport address are 16bits wide (address stored with an unsigned short).
But on SPARC arch, ioports are mapped in memory and so are stored with an unsigned long.
So I write a patch for i2c_ali1535 for supporting SPARC architecture.
With this patch, the driver i2c_ali1535 loads and works successfully.
# sensors
adm1023-i2c-0-18
Adapter: SMBus ALI1535 adapter at 0x1fe02000620
temp1: +31.0 C (low = -55.0 C, high = +127.0 C)
temp2: +61.6 C (low = -55.0 C, high = +127.0 C)
But this patch is bad because the base address for ioport is hard-coded (0x1fe02000000).
I have tried to understand how works all SPARC drivers but I cant find how to get that.
Perhaps i can get some usefull infos with all of_* functions but i dont know what exaclty means infos printed by prtconf (assigned-addresses and reg specifically).
Node 0xf0083f44
.node: f0083f44
assigned-addresses: 81001810.00000000.00000000.00000000.00000010
name: 'pmu'
ranges: 00000000.00000000.00001800.00000000.00000000.00000100.00000001.00000000.81001810.00000000.00000600.00000100.00000002.00000000.81001814.00000000.00000000.00000100
reg: 00001800.00000000.00000000.00000000.00000000.81001810.00000000.00000600.00000000.00000010
compatible: 70636931.3062392c.37313031.2e300070.63693130.62392c37.31303100.70636963.6c617373.2c303030.30303000.70636963.6c617373.2c303030.3000
#address-cells: 00000002
#size-cells: 00000001
devsel-speed: 00000001
class-code: 00000000
latency-timer: 00000000
cache-line-size: 00000000
max-latency: 00000000
min-grant: 00000000
revision-id: 00000000
device-id: 00007101
vendor-id: 000010b9
Node 0xf00849c4
.node: f00849c4
reg: 00000000.00000000.00000100.00000001.00000000.00000100
#address-cells: 00000002
#size-cells: 00000000
interrupts: 00000001
compatible: 'i2c-smbus'
name: 'i2c'
Node 0xf008505c
.node: f008505c
compatible: 'i2c-max1617'
name: 'temperature'
reg: 00000000.00000030
Best regards
[-- Attachment #2: i2c-ali1535-sparc.patch --]
[-- Type: text/x-patch, Size: 2443 bytes --]
--- drivers/i2c/busses/i2c-ali1535.c.old 2011-03-15 02:20:32.000000000 +0100
+++ drivers/i2c/busses/i2c-ali1535.c 2011-06-06 09:49:29.000000000 +0200
@@ -132,7 +132,11 @@
#define ALI1535_SMBIO_EN 0x04 /* SMB I/O Space enable */
static struct pci_driver ali1535_driver;
+#ifdef CONFIG_SPARC
+static unsigned long ali1535_smba;
+#else
static unsigned short ali1535_smba;
+#endif
/* Detect whether a ALI1535 can be found, and initialize it, where necessary.
Note the differences between kernels with the old PCI BIOS interface and
@@ -142,6 +146,7 @@
{
int retval = -ENODEV;
unsigned char temp;
+ unsigned short offset;
/* Check the following things:
- SMB I/O address is initialized
@@ -150,13 +155,19 @@
*/
/* Determine the address of the SMBus area */
- pci_read_config_word(dev, SMBBA, &ali1535_smba);
- ali1535_smba &= (0xffff & ~(ALI1535_SMB_IOSIZE - 1));
- if (ali1535_smba == 0) {
+ pci_read_config_word(dev, SMBBA, &offset);
+ dev_info(&dev->dev, "ALI1535_smb is at offset %04x", offset);
+ offset &= (0xffff & ~(ALI1535_SMB_IOSIZE - 1));
+ if (offset == 0) {
dev_warn(&dev->dev,
"ALI1535_smb region uninitialized - upgrade BIOS?\n");
goto exit;
}
+ #ifdef CONFIG_SPARC
+ ali1535_smba = 0x1fe02000000 + offset;
+ #else
+ ali1535_smba = offset;
+ #endif
retval = acpi_check_region(ali1535_smba, ALI1535_SMB_IOSIZE,
ali1535_driver.name);
@@ -165,8 +176,8 @@
if (!request_region(ali1535_smba, ALI1535_SMB_IOSIZE,
ali1535_driver.name)) {
- dev_err(&dev->dev, "ALI1535_smb region 0x%x already in use!\n",
- ali1535_smba);
+ dev_err(&dev->dev, "ALI1535_smb region 0x%04x already in use!\n",
+ offset);
goto exit;
}
@@ -196,7 +207,7 @@
*/
pci_read_config_byte(dev, SMBREV, &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%04x\n", offset);
retval = 0;
exit:
@@ -498,8 +509,13 @@
/* set up the sysfs linkage to our parent device */
ali1535_adapter.dev.parent = &dev->dev;
+ #ifdef CONFIG_SPARC
snprintf(ali1535_adapter.name, sizeof(ali1535_adapter.name),
- "SMBus ALI1535 adapter at %04x", ali1535_smba);
+ "SMBus ALI1535 adapter at 0x%0lx", ali1535_smba);
+ #else
+ snprintf(ali1535_adapter.name, sizeof(ali1535_adapter.name),
+ "SMBus ALI1535 adapter at 0x%04x", ali1535_smba);
+ #endif
return i2c_add_adapter(&ali1535_adapter);
}
next reply other threads:[~2011-06-06 8:01 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-06-06 8:01 corentin.labbe [this message]
2011-06-09 11:37 ` patch for i2c_ali1535 working on SPARC corentin.labbe
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=4DEC895B.30101@geomatys.fr \
--to=corentin.labbe@geomatys.fr \
--cc=sparclinux@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.