diff options
author | Mattias Wallin <mattias.wallin@stericsson.com> | 2010-09-15 07:12:03 -0400 |
---|---|---|
committer | Samuel Ortiz <sameo@linux.intel.com> | 2010-10-28 18:29:26 -0400 |
commit | 39368eda96c0a54ea0b3c6066b08e46b37f7905f (patch) | |
tree | 5fdae9213f8a3dbce2ea78f8176bcac07aced621 | |
parent | 5814fc35e1837e30b82c3d57f41310d4c4c52824 (diff) |
mfd: AB8500 register access via PRCMU I2C
This patch adds the choice of accessing the AB8500 registers
via prcmu I2C. Access either via SPI or I2C is supported.
Signed-off-by: Mattias Wallin <mattias.wallin@stericsson.com>
Acked-by: Linus Walleij <linus.walleij@stericsson.com>
Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
-rw-r--r-- | drivers/mfd/Kconfig | 17 | ||||
-rw-r--r-- | drivers/mfd/Makefile | 1 | ||||
-rw-r--r-- | drivers/mfd/ab8500-i2c.c | 105 | ||||
-rw-r--r-- | drivers/mfd/ab8500-spi.c | 2 |
4 files changed, 121 insertions, 4 deletions
diff --git a/drivers/mfd/Kconfig b/drivers/mfd/Kconfig index e310cb26f520..01c928bca099 100644 --- a/drivers/mfd/Kconfig +++ b/drivers/mfd/Kconfig | |||
@@ -475,14 +475,25 @@ config EZX_PCAP | |||
475 | 475 | ||
476 | config AB8500_CORE | 476 | config AB8500_CORE |
477 | bool "ST-Ericsson AB8500 Mixed Signal Power Management chip" | 477 | bool "ST-Ericsson AB8500 Mixed Signal Power Management chip" |
478 | depends on SPI=y && GENERIC_HARDIRQS && ABX500_CORE | 478 | depends on GENERIC_HARDIRQS && ABX500_CORE && SPI_MASTER |
479 | select MFD_CORE | 479 | select MFD_CORE |
480 | help | 480 | help |
481 | Select this option to enable access to AB8500 power management | 481 | Select this option to enable access to AB8500 power management |
482 | chip. This connects to U8500 on the SSP/SPI bus and exports | 482 | chip. This connects to U8500 either on the SSP/SPI bus |
483 | read/write functions for the devices to get access to this chip. | 483 | or the I2C bus via PRCMU. It also adds the irq_chip |
484 | parts for handling the Mixed Signal chip events. | ||
484 | This chip embeds various other multimedia funtionalities as well. | 485 | This chip embeds various other multimedia funtionalities as well. |
485 | 486 | ||
487 | config AB8500_I2C_CORE | ||
488 | bool "AB8500 register access via PRCMU I2C" | ||
489 | depends on AB8500_CORE && UX500_SOC_DB8500 | ||
490 | default y | ||
491 | help | ||
492 | This enables register access to the AB8500 chip via PRCMU I2C. | ||
493 | The AB8500 chip can be accessed via SPI or I2C. On DB8500 hardware | ||
494 | the I2C bus is connected to the Power Reset | ||
495 | and Mangagement Unit, PRCMU. | ||
496 | |||
486 | config AB8500_DEBUG | 497 | config AB8500_DEBUG |
487 | bool "Enable debug info via debugfs" | 498 | bool "Enable debug info via debugfs" |
488 | depends on AB8500_CORE && DEBUG_FS | 499 | depends on AB8500_CORE && DEBUG_FS |
diff --git a/drivers/mfd/Makefile b/drivers/mfd/Makefile index f771c52c40db..d5968cd93048 100644 --- a/drivers/mfd/Makefile +++ b/drivers/mfd/Makefile | |||
@@ -69,6 +69,7 @@ obj-$(CONFIG_AB3100_CORE) += ab3100-core.o | |||
69 | obj-$(CONFIG_AB3100_OTP) += ab3100-otp.o | 69 | obj-$(CONFIG_AB3100_OTP) += ab3100-otp.o |
70 | obj-$(CONFIG_AB3550_CORE) += ab3550-core.o | 70 | obj-$(CONFIG_AB3550_CORE) += ab3550-core.o |
71 | obj-$(CONFIG_AB8500_CORE) += ab8500-core.o ab8500-spi.o | 71 | obj-$(CONFIG_AB8500_CORE) += ab8500-core.o ab8500-spi.o |
72 | obj-$(CONFIG_AB8500_I2C_CORE) += ab8500-i2c.o | ||
72 | obj-$(CONFIG_AB8500_DEBUG) += ab8500-debugfs.o | 73 | obj-$(CONFIG_AB8500_DEBUG) += ab8500-debugfs.o |
73 | obj-$(CONFIG_MFD_TIMBERDALE) += timberdale.o | 74 | obj-$(CONFIG_MFD_TIMBERDALE) += timberdale.o |
74 | obj-$(CONFIG_PMIC_ADP5520) += adp5520.o | 75 | obj-$(CONFIG_PMIC_ADP5520) += adp5520.o |
diff --git a/drivers/mfd/ab8500-i2c.c b/drivers/mfd/ab8500-i2c.c new file mode 100644 index 000000000000..6820327adf4a --- /dev/null +++ b/drivers/mfd/ab8500-i2c.c | |||
@@ -0,0 +1,105 @@ | |||
1 | /* | ||
2 | * Copyright (C) ST-Ericsson SA 2010 | ||
3 | * Author: Mattias Wallin <mattias.wallin@stericsson.com> for ST-Ericsson. | ||
4 | * License Terms: GNU General Public License v2 | ||
5 | * This file was based on drivers/mfd/ab8500-spi.c | ||
6 | */ | ||
7 | |||
8 | #include <linux/kernel.h> | ||
9 | #include <linux/slab.h> | ||
10 | #include <linux/init.h> | ||
11 | #include <linux/module.h> | ||
12 | #include <linux/platform_device.h> | ||
13 | #include <linux/mfd/ab8500.h> | ||
14 | |||
15 | #include <mach/prcmu.h> | ||
16 | |||
17 | static int ab8500_i2c_write(struct ab8500 *ab8500, u16 addr, u8 data) | ||
18 | { | ||
19 | int ret; | ||
20 | |||
21 | ret = prcmu_abb_write((u8)(addr >> 8), (u8)(addr & 0xFF), &data, 1); | ||
22 | if (ret < 0) | ||
23 | dev_err(ab8500->dev, "prcmu i2c error %d\n", ret); | ||
24 | return ret; | ||
25 | } | ||
26 | |||
27 | static int ab8500_i2c_read(struct ab8500 *ab8500, u16 addr) | ||
28 | { | ||
29 | int ret; | ||
30 | u8 data; | ||
31 | |||
32 | ret = prcmu_abb_read((u8)(addr >> 8), (u8)(addr & 0xFF), &data, 1); | ||
33 | if (ret < 0) { | ||
34 | dev_err(ab8500->dev, "prcmu i2c error %d\n", ret); | ||
35 | return ret; | ||
36 | } | ||
37 | return (int)data; | ||
38 | } | ||
39 | |||
40 | static int __devinit ab8500_i2c_probe(struct platform_device *plf) | ||
41 | { | ||
42 | struct ab8500 *ab8500; | ||
43 | struct resource *resource; | ||
44 | int ret; | ||
45 | |||
46 | ab8500 = kzalloc(sizeof *ab8500, GFP_KERNEL); | ||
47 | if (!ab8500) | ||
48 | return -ENOMEM; | ||
49 | |||
50 | ab8500->dev = &plf->dev; | ||
51 | |||
52 | resource = platform_get_resource(plf, IORESOURCE_IRQ, 0); | ||
53 | if (!resource) { | ||
54 | kfree(ab8500); | ||
55 | return -ENODEV; | ||
56 | } | ||
57 | |||
58 | ab8500->irq = resource->start; | ||
59 | |||
60 | ab8500->read = ab8500_i2c_read; | ||
61 | ab8500->write = ab8500_i2c_write; | ||
62 | |||
63 | platform_set_drvdata(plf, ab8500); | ||
64 | |||
65 | ret = ab8500_init(ab8500); | ||
66 | if (ret) | ||
67 | kfree(ab8500); | ||
68 | |||
69 | return ret; | ||
70 | } | ||
71 | |||
72 | static int __devexit ab8500_i2c_remove(struct platform_device *plf) | ||
73 | { | ||
74 | struct ab8500 *ab8500 = platform_get_drvdata(plf); | ||
75 | |||
76 | ab8500_exit(ab8500); | ||
77 | kfree(ab8500); | ||
78 | |||
79 | return 0; | ||
80 | } | ||
81 | |||
82 | static struct platform_driver ab8500_i2c_driver = { | ||
83 | .driver = { | ||
84 | .name = "ab8500-i2c", | ||
85 | .owner = THIS_MODULE, | ||
86 | }, | ||
87 | .probe = ab8500_i2c_probe, | ||
88 | .remove = __devexit_p(ab8500_i2c_remove) | ||
89 | }; | ||
90 | |||
91 | static int __init ab8500_i2c_init(void) | ||
92 | { | ||
93 | return platform_driver_register(&ab8500_i2c_driver); | ||
94 | } | ||
95 | |||
96 | static void __exit ab8500_i2c_exit(void) | ||
97 | { | ||
98 | platform_driver_unregister(&ab8500_i2c_driver); | ||
99 | } | ||
100 | subsys_initcall(ab8500_i2c_init); | ||
101 | module_exit(ab8500_i2c_exit); | ||
102 | |||
103 | MODULE_AUTHOR("Mattias WALLIN <mattias.wallin@stericsson.com"); | ||
104 | MODULE_DESCRIPTION("AB8500 Core access via PRCMU I2C"); | ||
105 | MODULE_LICENSE("GPL v2"); | ||
diff --git a/drivers/mfd/ab8500-spi.c b/drivers/mfd/ab8500-spi.c index 01b6d584442c..b1653421edb5 100644 --- a/drivers/mfd/ab8500-spi.c +++ b/drivers/mfd/ab8500-spi.c | |||
@@ -119,7 +119,7 @@ static int __devexit ab8500_spi_remove(struct spi_device *spi) | |||
119 | 119 | ||
120 | static struct spi_driver ab8500_spi_driver = { | 120 | static struct spi_driver ab8500_spi_driver = { |
121 | .driver = { | 121 | .driver = { |
122 | .name = "ab8500", | 122 | .name = "ab8500-spi", |
123 | .owner = THIS_MODULE, | 123 | .owner = THIS_MODULE, |
124 | }, | 124 | }, |
125 | .probe = ab8500_spi_probe, | 125 | .probe = ab8500_spi_probe, |