diff options
author | Jean Delvare <khali@linux-fr.org> | 2008-10-17 11:51:12 -0400 |
---|---|---|
committer | Jean Delvare <khali@mahadeva.delvare> | 2008-10-17 11:51:12 -0400 |
commit | 810ad7b62c0f075dc44ecc781b24c7f6ba388da5 (patch) | |
tree | 3ed66cd5359928823ba18eba05f575fd8c28a75e /drivers/i2c/busses/i2c-powermac.c | |
parent | 47064d645bc55863c7887a7c96cde39c9a37ee5f (diff) |
hwmon: (ams) Convert to a new-style i2c driver
The legacy i2c binding model is phasing out, so the ams driver needs
to be converted to a new-style i2c driver. Here is a naive approach of
this conversion. Basically it is moving the i2c device creation from
the ams driver to the i2c-powermac driver. This should work, but I
suspect we could come up with something cleaner by declaring the i2c
device as part of the platform setup. This could be done later by
someone more familiar with openfirmware-based platforms than I am
myself.
One nice thing brought by this conversion is that the ams driver
should be loaded automatically on systems where is is needed (at
least when the I2C interface to the chip is used) providing
coldplug-aware user-space environment.
Signed-off-by: Jean Delvare <khali@linux-fr.org>
Acked-by: Johannes Berg <johannes@sipsolutions.net>
Cc: Stelian Pop <stelian@popies.net>
Cc: Michael Hanselmann <linux-kernel@hansmi.ch>
Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Diffstat (limited to 'drivers/i2c/busses/i2c-powermac.c')
-rw-r--r-- | drivers/i2c/busses/i2c-powermac.c | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/drivers/i2c/busses/i2c-powermac.c b/drivers/i2c/busses/i2c-powermac.c index 0e7b1c6724aa..60ca91745e55 100644 --- a/drivers/i2c/busses/i2c-powermac.c +++ b/drivers/i2c/busses/i2c-powermac.c | |||
@@ -259,6 +259,35 @@ static int __devinit i2c_powermac_probe(struct platform_device *dev) | |||
259 | } | 259 | } |
260 | 260 | ||
261 | printk(KERN_INFO "PowerMac i2c bus %s registered\n", name); | 261 | printk(KERN_INFO "PowerMac i2c bus %s registered\n", name); |
262 | |||
263 | if (!strncmp(basename, "uni-n", 5)) { | ||
264 | struct device_node *np; | ||
265 | const u32 *prop; | ||
266 | struct i2c_board_info info; | ||
267 | |||
268 | /* Instantiate I2C motion sensor if present */ | ||
269 | np = of_find_node_by_name(NULL, "accelerometer"); | ||
270 | if (np && of_device_is_compatible(np, "AAPL,accelerometer_1") && | ||
271 | (prop = of_get_property(np, "reg", NULL))) { | ||
272 | int i2c_bus; | ||
273 | const char *tmp_bus; | ||
274 | |||
275 | /* look for bus either using "reg" or by path */ | ||
276 | tmp_bus = strstr(np->full_name, "/i2c-bus@"); | ||
277 | if (tmp_bus) | ||
278 | i2c_bus = *(tmp_bus + 9) - '0'; | ||
279 | else | ||
280 | i2c_bus = ((*prop) >> 8) & 0x0f; | ||
281 | |||
282 | if (pmac_i2c_get_channel(bus) == i2c_bus) { | ||
283 | memset(&info, 0, sizeof(struct i2c_board_info)); | ||
284 | info.addr = ((*prop) & 0xff) >> 1; | ||
285 | strlcpy(info.type, "ams", I2C_NAME_SIZE); | ||
286 | i2c_new_device(adapter, &info); | ||
287 | } | ||
288 | } | ||
289 | } | ||
290 | |||
262 | return rc; | 291 | return rc; |
263 | } | 292 | } |
264 | 293 | ||