diff options
author | Lee Jones <lee.jones@linaro.org> | 2012-05-17 09:45:13 -0400 |
---|---|---|
committer | Samuel Ortiz <sameo@linux.intel.com> | 2012-05-20 11:27:10 -0400 |
commit | 6bc4a568414caab05424b702165a732177daccd0 (patch) | |
tree | f51384e3f360be98d6e09885e2323c4a1df6b619 /drivers | |
parent | d28f1db8187dd1ddc1fa6f380ff0402cf8e4d44d (diff) |
mfd: Enable Device Tree for ab8500-core driver
This patch will allow the ab8500-core driver to be probed and set up
when booting when Device Tree is enabled. This includes platform ID
look-up which identifies the machine it is currently running on. If
we are undergoing a DT enabled boot, we will refuse to setup each of
the other ab8500-* devices, as they will be probed individually by DT.
Signed-off-by: Lee Jones <lee.jones@linaro.org>
Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/mfd/ab8500-core.c | 71 |
1 files changed, 50 insertions, 21 deletions
diff --git a/drivers/mfd/ab8500-core.c b/drivers/mfd/ab8500-core.c index fb807ab8a2c7..dac0e2998603 100644 --- a/drivers/mfd/ab8500-core.c +++ b/drivers/mfd/ab8500-core.c | |||
@@ -20,6 +20,8 @@ | |||
20 | #include <linux/mfd/abx500/ab8500.h> | 20 | #include <linux/mfd/abx500/ab8500.h> |
21 | #include <linux/mfd/dbx500-prcmu.h> | 21 | #include <linux/mfd/dbx500-prcmu.h> |
22 | #include <linux/regulator/ab8500.h> | 22 | #include <linux/regulator/ab8500.h> |
23 | #include <linux/of.h> | ||
24 | #include <linux/of_device.h> | ||
23 | 25 | ||
24 | /* | 26 | /* |
25 | * Interrupt register offsets | 27 | * Interrupt register offsets |
@@ -1205,11 +1207,20 @@ static struct attribute_group ab9540_attr_group = { | |||
1205 | .attrs = ab9540_sysfs_entries, | 1207 | .attrs = ab9540_sysfs_entries, |
1206 | }; | 1208 | }; |
1207 | 1209 | ||
1210 | static const struct of_device_id ab8500_match[] = { | ||
1211 | { | ||
1212 | .compatible = "stericsson,ab8500", | ||
1213 | .data = (void *)AB8500_VERSION_AB8500, | ||
1214 | }, | ||
1215 | {}, | ||
1216 | }; | ||
1217 | |||
1208 | static int __devinit ab8500_probe(struct platform_device *pdev) | 1218 | static int __devinit ab8500_probe(struct platform_device *pdev) |
1209 | { | 1219 | { |
1210 | struct ab8500_platform_data *plat = dev_get_platdata(&pdev->dev); | 1220 | struct ab8500_platform_data *plat = dev_get_platdata(&pdev->dev); |
1211 | const struct platform_device_id *platid = platform_get_device_id(pdev); | 1221 | const struct platform_device_id *platid = platform_get_device_id(pdev); |
1212 | enum ab8500_version version = platid->driver_data; | 1222 | enum ab8500_version version = AB8500_VERSION_UNDEFINED; |
1223 | struct device_node *np = pdev->dev.of_node; | ||
1213 | struct ab8500 *ab8500; | 1224 | struct ab8500 *ab8500; |
1214 | struct resource *resource; | 1225 | struct resource *resource; |
1215 | int ret; | 1226 | int ret; |
@@ -1222,6 +1233,14 @@ static int __devinit ab8500_probe(struct platform_device *pdev) | |||
1222 | 1233 | ||
1223 | if (plat) | 1234 | if (plat) |
1224 | ab8500->irq_base = plat->irq_base; | 1235 | ab8500->irq_base = plat->irq_base; |
1236 | else if (np) | ||
1237 | ret = of_property_read_u32(np, "stericsson,irq-base", &ab8500->irq_base); | ||
1238 | |||
1239 | if (!ab8500->irq_base) { | ||
1240 | dev_info(&pdev->dev, "couldn't find irq-base\n"); | ||
1241 | ret = -EINVAL; | ||
1242 | goto out_free_ab8500; | ||
1243 | } | ||
1225 | 1244 | ||
1226 | ab8500->dev = &pdev->dev; | 1245 | ab8500->dev = &pdev->dev; |
1227 | 1246 | ||
@@ -1243,6 +1262,12 @@ static int __devinit ab8500_probe(struct platform_device *pdev) | |||
1243 | 1262 | ||
1244 | platform_set_drvdata(pdev, ab8500); | 1263 | platform_set_drvdata(pdev, ab8500); |
1245 | 1264 | ||
1265 | if (platid) | ||
1266 | version = platid->driver_data; | ||
1267 | else if (np) | ||
1268 | version = (unsigned int) | ||
1269 | of_match_device(ab8500_match, &pdev->dev)->data; | ||
1270 | |||
1246 | if (version != AB8500_VERSION_UNDEFINED) | 1271 | if (version != AB8500_VERSION_UNDEFINED) |
1247 | ab8500->version = version; | 1272 | ab8500->version = version; |
1248 | else { | 1273 | else { |
@@ -1348,29 +1373,32 @@ static int __devinit ab8500_probe(struct platform_device *pdev) | |||
1348 | goto out_removeirq; | 1373 | goto out_removeirq; |
1349 | } | 1374 | } |
1350 | 1375 | ||
1351 | ret = mfd_add_devices(ab8500->dev, 0, abx500_common_devs, | 1376 | if (!np) { |
1352 | ARRAY_SIZE(abx500_common_devs), NULL, | 1377 | ret = mfd_add_devices(ab8500->dev, 0, abx500_common_devs, |
1353 | ab8500->irq_base); | 1378 | ARRAY_SIZE(abx500_common_devs), NULL, |
1354 | 1379 | ab8500->irq_base); | |
1355 | if (ret) | ||
1356 | goto out_freeirq; | ||
1357 | 1380 | ||
1358 | if (is_ab9540(ab8500)) | 1381 | if (ret) |
1359 | ret = mfd_add_devices(ab8500->dev, 0, ab9540_devs, | 1382 | goto out_freeirq; |
1360 | ARRAY_SIZE(ab9540_devs), NULL, | ||
1361 | ab8500->irq_base); | ||
1362 | else | ||
1363 | ret = mfd_add_devices(ab8500->dev, 0, ab8500_devs, | ||
1364 | ARRAY_SIZE(ab8500_devs), NULL, | ||
1365 | ab8500->irq_base); | ||
1366 | 1383 | ||
1367 | if (is_ab9540(ab8500) || is_ab8505(ab8500)) | 1384 | if (is_ab9540(ab8500)) |
1368 | ret = mfd_add_devices(ab8500->dev, 0, ab9540_ab8505_devs, | 1385 | ret = mfd_add_devices(ab8500->dev, 0, ab9540_devs, |
1369 | ARRAY_SIZE(ab9540_ab8505_devs), NULL, | 1386 | ARRAY_SIZE(ab9540_devs), NULL, |
1370 | ab8500->irq_base); | 1387 | ab8500->irq_base); |
1388 | else | ||
1389 | ret = mfd_add_devices(ab8500->dev, 0, ab8500_devs, | ||
1390 | ARRAY_SIZE(ab8500_devs), NULL, | ||
1391 | ab8500->irq_base); | ||
1392 | if (ret) | ||
1393 | goto out_freeirq; | ||
1371 | 1394 | ||
1372 | if (ret) | 1395 | if (is_ab9540(ab8500) || is_ab8505(ab8500)) |
1373 | goto out_freeirq; | 1396 | ret = mfd_add_devices(ab8500->dev, 0, ab9540_ab8505_devs, |
1397 | ARRAY_SIZE(ab9540_ab8505_devs), NULL, | ||
1398 | ab8500->irq_base); | ||
1399 | if (ret) | ||
1400 | goto out_freeirq; | ||
1401 | } | ||
1374 | 1402 | ||
1375 | if (!no_bm) { | 1403 | if (!no_bm) { |
1376 | /* Add battery management devices */ | 1404 | /* Add battery management devices */ |
@@ -1440,6 +1468,7 @@ static struct platform_driver ab8500_core_driver = { | |||
1440 | .driver = { | 1468 | .driver = { |
1441 | .name = "ab8500-core", | 1469 | .name = "ab8500-core", |
1442 | .owner = THIS_MODULE, | 1470 | .owner = THIS_MODULE, |
1471 | .of_match_table = ab8500_match, | ||
1443 | }, | 1472 | }, |
1444 | .probe = ab8500_probe, | 1473 | .probe = ab8500_probe, |
1445 | .remove = __devexit_p(ab8500_remove), | 1474 | .remove = __devexit_p(ab8500_remove), |