diff options
-rw-r--r-- | drivers/mfd/Kconfig | 12 | ||||
-rw-r--r-- | drivers/mfd/Makefile | 1 | ||||
-rw-r--r-- | drivers/mfd/ab3100-core.c | 95 | ||||
-rw-r--r-- | drivers/mfd/ab3100-otp.c | 11 | ||||
-rw-r--r-- | drivers/mfd/abx500-core.c | 157 | ||||
-rw-r--r-- | drivers/regulator/ab3100.c | 33 | ||||
-rw-r--r-- | drivers/rtc/rtc-ab3100.c | 39 | ||||
-rw-r--r-- | include/linux/mfd/abx500.h | 134 |
8 files changed, 390 insertions, 92 deletions
diff --git a/drivers/mfd/Kconfig b/drivers/mfd/Kconfig index 614fa7b8a054..1c3d737ec406 100644 --- a/drivers/mfd/Kconfig +++ b/drivers/mfd/Kconfig | |||
@@ -374,9 +374,19 @@ config PCF50633_GPIO | |||
374 | Say yes here if you want to include support GPIO for pins on | 374 | Say yes here if you want to include support GPIO for pins on |
375 | the PCF50633 chip. | 375 | the PCF50633 chip. |
376 | 376 | ||
377 | config ABX500_CORE | ||
378 | bool "ST-Ericsson ABX500 Mixed Signal Circuit register functions" | ||
379 | default y if ARCH_U300 | ||
380 | help | ||
381 | Say yes here if you have the ABX500 Mixed Signal IC family | ||
382 | chips. This core driver expose register access functions. | ||
383 | Functionality specific drivers using these functions can | ||
384 | remain unchanged when IC changes. Binding of the functions to | ||
385 | actual register access is done by the IC core driver. | ||
386 | |||
377 | config AB3100_CORE | 387 | config AB3100_CORE |
378 | bool "ST-Ericsson AB3100 Mixed Signal Circuit core functions" | 388 | bool "ST-Ericsson AB3100 Mixed Signal Circuit core functions" |
379 | depends on I2C=y | 389 | depends on I2C=y && ABX500_CORE |
380 | default y if ARCH_U300 | 390 | default y if ARCH_U300 |
381 | help | 391 | help |
382 | Select this to enable the AB3100 Mixed Signal IC core | 392 | Select this to enable the AB3100 Mixed Signal IC core |
diff --git a/drivers/mfd/Makefile b/drivers/mfd/Makefile index 5eb79794d5a5..4b8ad04ff8e2 100644 --- a/drivers/mfd/Makefile +++ b/drivers/mfd/Makefile | |||
@@ -60,6 +60,7 @@ obj-$(CONFIG_MFD_MAX8925) += max8925.o | |||
60 | obj-$(CONFIG_MFD_PCF50633) += pcf50633-core.o | 60 | obj-$(CONFIG_MFD_PCF50633) += pcf50633-core.o |
61 | obj-$(CONFIG_PCF50633_ADC) += pcf50633-adc.o | 61 | obj-$(CONFIG_PCF50633_ADC) += pcf50633-adc.o |
62 | obj-$(CONFIG_PCF50633_GPIO) += pcf50633-gpio.o | 62 | obj-$(CONFIG_PCF50633_GPIO) += pcf50633-gpio.o |
63 | obj-$(CONFIG_ABX500_CORE) += abx500-core.o | ||
63 | obj-$(CONFIG_AB3100_CORE) += ab3100-core.o | 64 | obj-$(CONFIG_AB3100_CORE) += ab3100-core.o |
64 | obj-$(CONFIG_AB3100_OTP) += ab3100-otp.o | 65 | obj-$(CONFIG_AB3100_OTP) += ab3100-otp.o |
65 | obj-$(CONFIG_AB4500_CORE) += ab4500-core.o | 66 | obj-$(CONFIG_AB4500_CORE) += ab4500-core.o |
diff --git a/drivers/mfd/ab3100-core.c b/drivers/mfd/ab3100-core.c index f8c4a333ff1c..53ebfee548fa 100644 --- a/drivers/mfd/ab3100-core.c +++ b/drivers/mfd/ab3100-core.c | |||
@@ -59,24 +59,15 @@ | |||
59 | * The AB3100 is usually assigned address 0x48 (7-bit) | 59 | * The AB3100 is usually assigned address 0x48 (7-bit) |
60 | * The chip is defined in the platform i2c_board_data section. | 60 | * The chip is defined in the platform i2c_board_data section. |
61 | */ | 61 | */ |
62 | 62 | static int ab3100_get_chip_id(struct device *dev) | |
63 | u8 ab3100_get_chip_type(struct ab3100 *ab3100) | ||
64 | { | 63 | { |
65 | u8 chip = ABUNKNOWN; | 64 | struct ab3100 *ab3100 = dev_get_drvdata(dev->parent); |
66 | 65 | ||
67 | switch (ab3100->chip_id & 0xf0) { | 66 | return (int)ab3100->chip_id; |
68 | case 0xa0: | ||
69 | chip = AB3000; | ||
70 | break; | ||
71 | case 0xc0: | ||
72 | chip = AB3100; | ||
73 | break; | ||
74 | } | ||
75 | return chip; | ||
76 | } | 67 | } |
77 | EXPORT_SYMBOL(ab3100_get_chip_type); | ||
78 | 68 | ||
79 | int ab3100_set_register_interruptible(struct ab3100 *ab3100, u8 reg, u8 regval) | 69 | static int ab3100_set_register_interruptible(struct ab3100 *ab3100, |
70 | u8 reg, u8 regval) | ||
80 | { | 71 | { |
81 | u8 regandval[2] = {reg, regval}; | 72 | u8 regandval[2] = {reg, regval}; |
82 | int err; | 73 | int err; |
@@ -108,8 +99,14 @@ int ab3100_set_register_interruptible(struct ab3100 *ab3100, u8 reg, u8 regval) | |||
108 | mutex_unlock(&ab3100->access_mutex); | 99 | mutex_unlock(&ab3100->access_mutex); |
109 | return err; | 100 | return err; |
110 | } | 101 | } |
111 | EXPORT_SYMBOL(ab3100_set_register_interruptible); | ||
112 | 102 | ||
103 | static int set_register_interruptible(struct device *dev, | ||
104 | u8 bank, u8 reg, u8 value) | ||
105 | { | ||
106 | struct ab3100 *ab3100 = dev_get_drvdata(dev->parent); | ||
107 | |||
108 | return ab3100_set_register_interruptible(ab3100, reg, value); | ||
109 | } | ||
113 | 110 | ||
114 | /* | 111 | /* |
115 | * The test registers exist at an I2C bus address up one | 112 | * The test registers exist at an I2C bus address up one |
@@ -148,8 +145,8 @@ static int ab3100_set_test_register_interruptible(struct ab3100 *ab3100, | |||
148 | return err; | 145 | return err; |
149 | } | 146 | } |
150 | 147 | ||
151 | 148 | static int ab3100_get_register_interruptible(struct ab3100 *ab3100, | |
152 | int ab3100_get_register_interruptible(struct ab3100 *ab3100, u8 reg, u8 *regval) | 149 | u8 reg, u8 *regval) |
153 | { | 150 | { |
154 | int err; | 151 | int err; |
155 | 152 | ||
@@ -203,10 +200,16 @@ int ab3100_get_register_interruptible(struct ab3100 *ab3100, u8 reg, u8 *regval) | |||
203 | mutex_unlock(&ab3100->access_mutex); | 200 | mutex_unlock(&ab3100->access_mutex); |
204 | return err; | 201 | return err; |
205 | } | 202 | } |
206 | EXPORT_SYMBOL(ab3100_get_register_interruptible); | ||
207 | 203 | ||
204 | static int get_register_interruptible(struct device *dev, u8 bank, u8 reg, | ||
205 | u8 *value) | ||
206 | { | ||
207 | struct ab3100 *ab3100 = dev_get_drvdata(dev->parent); | ||
208 | |||
209 | return ab3100_get_register_interruptible(ab3100, reg, value); | ||
210 | } | ||
208 | 211 | ||
209 | int ab3100_get_register_page_interruptible(struct ab3100 *ab3100, | 212 | static int ab3100_get_register_page_interruptible(struct ab3100 *ab3100, |
210 | u8 first_reg, u8 *regvals, u8 numregs) | 213 | u8 first_reg, u8 *regvals, u8 numregs) |
211 | { | 214 | { |
212 | int err; | 215 | int err; |
@@ -260,10 +263,17 @@ int ab3100_get_register_page_interruptible(struct ab3100 *ab3100, | |||
260 | mutex_unlock(&ab3100->access_mutex); | 263 | mutex_unlock(&ab3100->access_mutex); |
261 | return err; | 264 | return err; |
262 | } | 265 | } |
263 | EXPORT_SYMBOL(ab3100_get_register_page_interruptible); | ||
264 | 266 | ||
267 | static int get_register_page_interruptible(struct device *dev, u8 bank, | ||
268 | u8 first_reg, u8 *regvals, u8 numregs) | ||
269 | { | ||
270 | struct ab3100 *ab3100 = dev_get_drvdata(dev->parent); | ||
271 | |||
272 | return ab3100_get_register_page_interruptible(ab3100, | ||
273 | first_reg, regvals, numregs); | ||
274 | } | ||
265 | 275 | ||
266 | int ab3100_mask_and_set_register_interruptible(struct ab3100 *ab3100, | 276 | static int ab3100_mask_and_set_register_interruptible(struct ab3100 *ab3100, |
267 | u8 reg, u8 andmask, u8 ormask) | 277 | u8 reg, u8 andmask, u8 ormask) |
268 | { | 278 | { |
269 | u8 regandval[2] = {reg, 0}; | 279 | u8 regandval[2] = {reg, 0}; |
@@ -331,8 +341,15 @@ int ab3100_mask_and_set_register_interruptible(struct ab3100 *ab3100, | |||
331 | mutex_unlock(&ab3100->access_mutex); | 341 | mutex_unlock(&ab3100->access_mutex); |
332 | return err; | 342 | return err; |
333 | } | 343 | } |
334 | EXPORT_SYMBOL(ab3100_mask_and_set_register_interruptible); | ||
335 | 344 | ||
345 | static int mask_and_set_register_interruptible(struct device *dev, u8 bank, | ||
346 | u8 reg, u8 bitmask, u8 bitvalues) | ||
347 | { | ||
348 | struct ab3100 *ab3100 = dev_get_drvdata(dev->parent); | ||
349 | |||
350 | return ab3100_mask_and_set_register_interruptible(ab3100, | ||
351 | reg, bitmask, (bitmask & bitvalues)); | ||
352 | } | ||
336 | 353 | ||
337 | /* | 354 | /* |
338 | * Register a simple callback for handling any AB3100 events. | 355 | * Register a simple callback for handling any AB3100 events. |
@@ -357,15 +374,27 @@ int ab3100_event_unregister(struct ab3100 *ab3100, | |||
357 | EXPORT_SYMBOL(ab3100_event_unregister); | 374 | EXPORT_SYMBOL(ab3100_event_unregister); |
358 | 375 | ||
359 | 376 | ||
360 | int ab3100_event_registers_startup_state_get(struct ab3100 *ab3100, | 377 | static int ab3100_event_registers_startup_state_get(struct device *dev, |
361 | u32 *fatevent) | 378 | u8 *event) |
362 | { | 379 | { |
380 | struct ab3100 *ab3100 = dev_get_drvdata(dev->parent); | ||
363 | if (!ab3100->startup_events_read) | 381 | if (!ab3100->startup_events_read) |
364 | return -EAGAIN; /* Try again later */ | 382 | return -EAGAIN; /* Try again later */ |
365 | *fatevent = ab3100->startup_events; | 383 | memcpy(event, ab3100->startup_events, 3); |
366 | return 0; | 384 | return 0; |
367 | } | 385 | } |
368 | EXPORT_SYMBOL(ab3100_event_registers_startup_state_get); | 386 | |
387 | static struct abx500_ops ab3100_ops = { | ||
388 | .get_chip_id = ab3100_get_chip_id, | ||
389 | .set_register = set_register_interruptible, | ||
390 | .get_register = get_register_interruptible, | ||
391 | .get_register_page = get_register_page_interruptible, | ||
392 | .set_register_page = NULL, | ||
393 | .mask_and_set_register = mask_and_set_register_interruptible, | ||
394 | .event_registers_startup_state_get = | ||
395 | ab3100_event_registers_startup_state_get, | ||
396 | .startup_irq_enabled = NULL, | ||
397 | }; | ||
369 | 398 | ||
370 | /* | 399 | /* |
371 | * This is a threaded interrupt handler so we can make some | 400 | * This is a threaded interrupt handler so we can make some |
@@ -390,7 +419,9 @@ static irqreturn_t ab3100_irq_handler(int irq, void *data) | |||
390 | event_regs[2]; | 419 | event_regs[2]; |
391 | 420 | ||
392 | if (!ab3100->startup_events_read) { | 421 | if (!ab3100->startup_events_read) { |
393 | ab3100->startup_events = fatevent; | 422 | ab3100->startup_events[0] = event_regs[0]; |
423 | ab3100->startup_events[1] = event_regs[1]; | ||
424 | ab3100->startup_events[2] = event_regs[2]; | ||
394 | ab3100->startup_events_read = true; | 425 | ab3100->startup_events_read = true; |
395 | } | 426 | } |
396 | /* | 427 | /* |
@@ -703,7 +734,8 @@ static int __init ab3100_setup(struct ab3100 *ab3100) | |||
703 | dev_warn(ab3100->dev, | 734 | dev_warn(ab3100->dev, |
704 | "AB3100 P1E variant detected, " | 735 | "AB3100 P1E variant detected, " |
705 | "forcing chip to 32KHz\n"); | 736 | "forcing chip to 32KHz\n"); |
706 | err = ab3100_set_test_register_interruptible(ab3100, 0x02, 0x08); | 737 | err = ab3100_set_test_register_interruptible(ab3100, |
738 | 0x02, 0x08); | ||
707 | } | 739 | } |
708 | 740 | ||
709 | exit_no_setup: | 741 | exit_no_setup: |
@@ -898,6 +930,10 @@ static int __init ab3100_probe(struct i2c_client *client, | |||
898 | if (err) | 930 | if (err) |
899 | goto exit_no_irq; | 931 | goto exit_no_irq; |
900 | 932 | ||
933 | err = abx500_register_ops(&client->dev, &ab3100_ops); | ||
934 | if (err) | ||
935 | goto exit_no_ops; | ||
936 | |||
901 | /* Set parent and a pointer back to the container in device data */ | 937 | /* Set parent and a pointer back to the container in device data */ |
902 | for (i = 0; i < ARRAY_SIZE(ab3100_platform_devs); i++) { | 938 | for (i = 0; i < ARRAY_SIZE(ab3100_platform_devs); i++) { |
903 | ab3100_platform_devs[i]->dev.parent = | 939 | ab3100_platform_devs[i]->dev.parent = |
@@ -915,6 +951,7 @@ static int __init ab3100_probe(struct i2c_client *client, | |||
915 | 951 | ||
916 | return 0; | 952 | return 0; |
917 | 953 | ||
954 | exit_no_ops: | ||
918 | exit_no_irq: | 955 | exit_no_irq: |
919 | exit_no_setup: | 956 | exit_no_setup: |
920 | i2c_unregister_device(ab3100->testreg_client); | 957 | i2c_unregister_device(ab3100->testreg_client); |
diff --git a/drivers/mfd/ab3100-otp.c b/drivers/mfd/ab3100-otp.c index 7093f1aef1e5..63d2b727ddbb 100644 --- a/drivers/mfd/ab3100-otp.c +++ b/drivers/mfd/ab3100-otp.c | |||
@@ -30,7 +30,6 @@ | |||
30 | /** | 30 | /** |
31 | * struct ab3100_otp | 31 | * struct ab3100_otp |
32 | * @dev containing device | 32 | * @dev containing device |
33 | * @ab3100 a pointer to the parent ab3100 device struct | ||
34 | * @locked whether the OTP is locked, after locking, no more bits | 33 | * @locked whether the OTP is locked, after locking, no more bits |
35 | * can be changed but before locking it is still possible | 34 | * can be changed but before locking it is still possible |
36 | * to change bits from 1->0. | 35 | * to change bits from 1->0. |
@@ -49,7 +48,6 @@ | |||
49 | */ | 48 | */ |
50 | struct ab3100_otp { | 49 | struct ab3100_otp { |
51 | struct device *dev; | 50 | struct device *dev; |
52 | struct ab3100 *ab3100; | ||
53 | bool locked; | 51 | bool locked; |
54 | u32 freq; | 52 | u32 freq; |
55 | bool paf; | 53 | bool paf; |
@@ -63,19 +61,19 @@ struct ab3100_otp { | |||
63 | 61 | ||
64 | static int __init ab3100_otp_read(struct ab3100_otp *otp) | 62 | static int __init ab3100_otp_read(struct ab3100_otp *otp) |
65 | { | 63 | { |
66 | struct ab3100 *ab = otp->ab3100; | ||
67 | u8 otpval[8]; | 64 | u8 otpval[8]; |
68 | u8 otpp; | 65 | u8 otpp; |
69 | int err; | 66 | int err; |
70 | 67 | ||
71 | err = ab3100_get_register_interruptible(ab, AB3100_OTPP, &otpp); | 68 | err = abx500_get_register_interruptible(otp->dev, 0, |
69 | AB3100_OTPP, &otpp); | ||
72 | if (err) { | 70 | if (err) { |
73 | dev_err(otp->dev, "unable to read OTPP register\n"); | 71 | dev_err(otp->dev, "unable to read OTPP register\n"); |
74 | return err; | 72 | return err; |
75 | } | 73 | } |
76 | 74 | ||
77 | err = ab3100_get_register_page_interruptible(ab, AB3100_OTP0, | 75 | err = abx500_get_register_page_interruptible(otp->dev, 0, |
78 | otpval, 8); | 76 | AB3100_OTP0, otpval, 8); |
79 | if (err) { | 77 | if (err) { |
80 | dev_err(otp->dev, "unable to read OTP register page\n"); | 78 | dev_err(otp->dev, "unable to read OTP register page\n"); |
81 | return err; | 79 | return err; |
@@ -197,7 +195,6 @@ static int __init ab3100_otp_probe(struct platform_device *pdev) | |||
197 | otp->dev = &pdev->dev; | 195 | otp->dev = &pdev->dev; |
198 | 196 | ||
199 | /* Replace platform data coming in with a local struct */ | 197 | /* Replace platform data coming in with a local struct */ |
200 | otp->ab3100 = platform_get_drvdata(pdev); | ||
201 | platform_set_drvdata(pdev, otp); | 198 | platform_set_drvdata(pdev, otp); |
202 | 199 | ||
203 | err = ab3100_otp_read(otp); | 200 | err = ab3100_otp_read(otp); |
diff --git a/drivers/mfd/abx500-core.c b/drivers/mfd/abx500-core.c new file mode 100644 index 000000000000..3b3b97ec32a7 --- /dev/null +++ b/drivers/mfd/abx500-core.c | |||
@@ -0,0 +1,157 @@ | |||
1 | /* | ||
2 | * Copyright (C) 2007-2010 ST-Ericsson | ||
3 | * License terms: GNU General Public License (GPL) version 2 | ||
4 | * Register access functions for the ABX500 Mixed Signal IC family. | ||
5 | * Author: Mattias Wallin <mattias.wallin@stericsson.com> | ||
6 | */ | ||
7 | |||
8 | #include <linux/list.h> | ||
9 | #include <linux/slab.h> | ||
10 | #include <linux/err.h> | ||
11 | #include <linux/mfd/abx500.h> | ||
12 | |||
13 | static LIST_HEAD(abx500_list); | ||
14 | |||
15 | struct abx500_device_entry { | ||
16 | struct list_head list; | ||
17 | struct abx500_ops ops; | ||
18 | struct device *dev; | ||
19 | }; | ||
20 | |||
21 | static void lookup_ops(struct device *dev, struct abx500_ops **ops) | ||
22 | { | ||
23 | struct abx500_device_entry *dev_entry; | ||
24 | |||
25 | *ops = NULL; | ||
26 | list_for_each_entry(dev_entry, &abx500_list, list) { | ||
27 | if (dev_entry->dev == dev) { | ||
28 | *ops = &dev_entry->ops; | ||
29 | return; | ||
30 | } | ||
31 | } | ||
32 | } | ||
33 | |||
34 | int abx500_register_ops(struct device *dev, struct abx500_ops *ops) | ||
35 | { | ||
36 | struct abx500_device_entry *dev_entry; | ||
37 | |||
38 | dev_entry = kzalloc(sizeof(struct abx500_device_entry), GFP_KERNEL); | ||
39 | if (IS_ERR(dev_entry)) { | ||
40 | dev_err(dev, "register_ops kzalloc failed"); | ||
41 | return -ENOMEM; | ||
42 | } | ||
43 | dev_entry->dev = dev; | ||
44 | memcpy(&dev_entry->ops, ops, sizeof(struct abx500_ops)); | ||
45 | |||
46 | list_add_tail(&dev_entry->list, &abx500_list); | ||
47 | return 0; | ||
48 | } | ||
49 | EXPORT_SYMBOL(abx500_register_ops); | ||
50 | |||
51 | void abx500_remove_ops(struct device *dev) | ||
52 | { | ||
53 | struct abx500_device_entry *dev_entry, *tmp; | ||
54 | |||
55 | list_for_each_entry_safe(dev_entry, tmp, &abx500_list, list) | ||
56 | { | ||
57 | if (dev_entry->dev == dev) { | ||
58 | list_del(&dev_entry->list); | ||
59 | kfree(dev_entry); | ||
60 | } | ||
61 | } | ||
62 | } | ||
63 | EXPORT_SYMBOL(abx500_remove_ops); | ||
64 | |||
65 | int abx500_set_register_interruptible(struct device *dev, u8 bank, u8 reg, | ||
66 | u8 value) | ||
67 | { | ||
68 | struct abx500_ops *ops; | ||
69 | |||
70 | lookup_ops(dev->parent, &ops); | ||
71 | if ((ops != NULL) && (ops->set_register != NULL)) | ||
72 | return ops->set_register(dev, bank, reg, value); | ||
73 | else | ||
74 | return -ENOTSUPP; | ||
75 | } | ||
76 | EXPORT_SYMBOL(abx500_set_register_interruptible); | ||
77 | |||
78 | int abx500_get_register_interruptible(struct device *dev, u8 bank, u8 reg, | ||
79 | u8 *value) | ||
80 | { | ||
81 | struct abx500_ops *ops; | ||
82 | |||
83 | lookup_ops(dev->parent, &ops); | ||
84 | if ((ops != NULL) && (ops->get_register != NULL)) | ||
85 | return ops->get_register(dev, bank, reg, value); | ||
86 | else | ||
87 | return -ENOTSUPP; | ||
88 | } | ||
89 | EXPORT_SYMBOL(abx500_get_register_interruptible); | ||
90 | |||
91 | int abx500_get_register_page_interruptible(struct device *dev, u8 bank, | ||
92 | u8 first_reg, u8 *regvals, u8 numregs) | ||
93 | { | ||
94 | struct abx500_ops *ops; | ||
95 | |||
96 | lookup_ops(dev->parent, &ops); | ||
97 | if ((ops != NULL) && (ops->get_register_page != NULL)) | ||
98 | return ops->get_register_page(dev, bank, | ||
99 | first_reg, regvals, numregs); | ||
100 | else | ||
101 | return -ENOTSUPP; | ||
102 | } | ||
103 | EXPORT_SYMBOL(abx500_get_register_page_interruptible); | ||
104 | |||
105 | int abx500_mask_and_set_register_interruptible(struct device *dev, u8 bank, | ||
106 | u8 reg, u8 bitmask, u8 bitvalues) | ||
107 | { | ||
108 | struct abx500_ops *ops; | ||
109 | |||
110 | lookup_ops(dev->parent, &ops); | ||
111 | if ((ops != NULL) && (ops->mask_and_set_register != NULL)) | ||
112 | return ops->mask_and_set_register(dev, bank, | ||
113 | reg, bitmask, bitvalues); | ||
114 | else | ||
115 | return -ENOTSUPP; | ||
116 | } | ||
117 | EXPORT_SYMBOL(abx500_mask_and_set_register_interruptible); | ||
118 | |||
119 | int abx500_get_chip_id(struct device *dev) | ||
120 | { | ||
121 | struct abx500_ops *ops; | ||
122 | |||
123 | lookup_ops(dev->parent, &ops); | ||
124 | if ((ops != NULL) && (ops->get_chip_id != NULL)) | ||
125 | return ops->get_chip_id(dev); | ||
126 | else | ||
127 | return -ENOTSUPP; | ||
128 | } | ||
129 | EXPORT_SYMBOL(abx500_get_chip_id); | ||
130 | |||
131 | int abx500_event_registers_startup_state_get(struct device *dev, u8 *event) | ||
132 | { | ||
133 | struct abx500_ops *ops; | ||
134 | |||
135 | lookup_ops(dev->parent, &ops); | ||
136 | if ((ops != NULL) && (ops->event_registers_startup_state_get != NULL)) | ||
137 | return ops->event_registers_startup_state_get(dev, event); | ||
138 | else | ||
139 | return -ENOTSUPP; | ||
140 | } | ||
141 | EXPORT_SYMBOL(abx500_event_registers_startup_state_get); | ||
142 | |||
143 | int abx500_startup_irq_enabled(struct device *dev, unsigned int irq) | ||
144 | { | ||
145 | struct abx500_ops *ops; | ||
146 | |||
147 | lookup_ops(dev->parent, &ops); | ||
148 | if ((ops != NULL) && (ops->startup_irq_enabled != NULL)) | ||
149 | return ops->startup_irq_enabled(dev, irq); | ||
150 | else | ||
151 | return -ENOTSUPP; | ||
152 | } | ||
153 | EXPORT_SYMBOL(abx500_startup_irq_enabled); | ||
154 | |||
155 | MODULE_AUTHOR("Mattias Wallin <mattias.wallin@stericsson.com>"); | ||
156 | MODULE_DESCRIPTION("ABX500 core driver"); | ||
157 | MODULE_LICENSE("GPL"); | ||
diff --git a/drivers/regulator/ab3100.c b/drivers/regulator/ab3100.c index 04ca7f62c57e..7b14a67bdca2 100644 --- a/drivers/regulator/ab3100.c +++ b/drivers/regulator/ab3100.c | |||
@@ -41,7 +41,7 @@ | |||
41 | * struct ab3100_regulator | 41 | * struct ab3100_regulator |
42 | * A struct passed around the individual regulator functions | 42 | * A struct passed around the individual regulator functions |
43 | * @platform_device: platform device holding this regulator | 43 | * @platform_device: platform device holding this regulator |
44 | * @ab3100: handle to the AB3100 parent chip | 44 | * @dev: handle to the device |
45 | * @plfdata: AB3100 platform data passed in at probe time | 45 | * @plfdata: AB3100 platform data passed in at probe time |
46 | * @regreg: regulator register number in the AB3100 | 46 | * @regreg: regulator register number in the AB3100 |
47 | * @fixed_voltage: a fixed voltage for this regulator, if this | 47 | * @fixed_voltage: a fixed voltage for this regulator, if this |
@@ -52,7 +52,7 @@ | |||
52 | */ | 52 | */ |
53 | struct ab3100_regulator { | 53 | struct ab3100_regulator { |
54 | struct regulator_dev *rdev; | 54 | struct regulator_dev *rdev; |
55 | struct ab3100 *ab3100; | 55 | struct device *dev; |
56 | struct ab3100_platform_data *plfdata; | 56 | struct ab3100_platform_data *plfdata; |
57 | u8 regreg; | 57 | u8 regreg; |
58 | int fixed_voltage; | 58 | int fixed_voltage; |
@@ -183,7 +183,7 @@ static int ab3100_enable_regulator(struct regulator_dev *reg) | |||
183 | int err; | 183 | int err; |
184 | u8 regval; | 184 | u8 regval; |
185 | 185 | ||
186 | err = ab3100_get_register_interruptible(abreg->ab3100, abreg->regreg, | 186 | err = abx500_get_register_interruptible(abreg->dev, 0, abreg->regreg, |
187 | ®val); | 187 | ®val); |
188 | if (err) { | 188 | if (err) { |
189 | dev_warn(®->dev, "failed to get regid %d value\n", | 189 | dev_warn(®->dev, "failed to get regid %d value\n", |
@@ -197,7 +197,7 @@ static int ab3100_enable_regulator(struct regulator_dev *reg) | |||
197 | 197 | ||
198 | regval |= AB3100_REG_ON_MASK; | 198 | regval |= AB3100_REG_ON_MASK; |
199 | 199 | ||
200 | err = ab3100_set_register_interruptible(abreg->ab3100, abreg->regreg, | 200 | err = abx500_set_register_interruptible(abreg->dev, 0, abreg->regreg, |
201 | regval); | 201 | regval); |
202 | if (err) { | 202 | if (err) { |
203 | dev_warn(®->dev, "failed to set regid %d value\n", | 203 | dev_warn(®->dev, "failed to set regid %d value\n", |
@@ -245,14 +245,14 @@ static int ab3100_disable_regulator(struct regulator_dev *reg) | |||
245 | if (abreg->regreg == AB3100_LDO_D) { | 245 | if (abreg->regreg == AB3100_LDO_D) { |
246 | dev_info(®->dev, "disabling LDO D - shut down system\n"); | 246 | dev_info(®->dev, "disabling LDO D - shut down system\n"); |
247 | /* Setting LDO D to 0x00 cuts the power to the SoC */ | 247 | /* Setting LDO D to 0x00 cuts the power to the SoC */ |
248 | return ab3100_set_register_interruptible(abreg->ab3100, | 248 | return abx500_set_register_interruptible(abreg->dev, 0, |
249 | AB3100_LDO_D, 0x00U); | 249 | AB3100_LDO_D, 0x00U); |
250 | } | 250 | } |
251 | 251 | ||
252 | /* | 252 | /* |
253 | * All other regulators are handled here | 253 | * All other regulators are handled here |
254 | */ | 254 | */ |
255 | err = ab3100_get_register_interruptible(abreg->ab3100, abreg->regreg, | 255 | err = abx500_get_register_interruptible(abreg->dev, 0, abreg->regreg, |
256 | ®val); | 256 | ®val); |
257 | if (err) { | 257 | if (err) { |
258 | dev_err(®->dev, "unable to get register 0x%x\n", | 258 | dev_err(®->dev, "unable to get register 0x%x\n", |
@@ -260,7 +260,7 @@ static int ab3100_disable_regulator(struct regulator_dev *reg) | |||
260 | return err; | 260 | return err; |
261 | } | 261 | } |
262 | regval &= ~AB3100_REG_ON_MASK; | 262 | regval &= ~AB3100_REG_ON_MASK; |
263 | return ab3100_set_register_interruptible(abreg->ab3100, abreg->regreg, | 263 | return abx500_set_register_interruptible(abreg->dev, 0, abreg->regreg, |
264 | regval); | 264 | regval); |
265 | } | 265 | } |
266 | 266 | ||
@@ -270,7 +270,7 @@ static int ab3100_is_enabled_regulator(struct regulator_dev *reg) | |||
270 | u8 regval; | 270 | u8 regval; |
271 | int err; | 271 | int err; |
272 | 272 | ||
273 | err = ab3100_get_register_interruptible(abreg->ab3100, abreg->regreg, | 273 | err = abx500_get_register_interruptible(abreg->dev, 0, abreg->regreg, |
274 | ®val); | 274 | ®val); |
275 | if (err) { | 275 | if (err) { |
276 | dev_err(®->dev, "unable to get register 0x%x\n", | 276 | dev_err(®->dev, "unable to get register 0x%x\n", |
@@ -305,7 +305,7 @@ static int ab3100_get_voltage_regulator(struct regulator_dev *reg) | |||
305 | * For variable types, read out setting and index into | 305 | * For variable types, read out setting and index into |
306 | * supplied voltage list. | 306 | * supplied voltage list. |
307 | */ | 307 | */ |
308 | err = ab3100_get_register_interruptible(abreg->ab3100, | 308 | err = abx500_get_register_interruptible(abreg->dev, 0, |
309 | abreg->regreg, ®val); | 309 | abreg->regreg, ®val); |
310 | if (err) { | 310 | if (err) { |
311 | dev_warn(®->dev, | 311 | dev_warn(®->dev, |
@@ -373,7 +373,7 @@ static int ab3100_set_voltage_regulator(struct regulator_dev *reg, | |||
373 | if (bestindex < 0) | 373 | if (bestindex < 0) |
374 | return bestindex; | 374 | return bestindex; |
375 | 375 | ||
376 | err = ab3100_get_register_interruptible(abreg->ab3100, | 376 | err = abx500_get_register_interruptible(abreg->dev, 0, |
377 | abreg->regreg, ®val); | 377 | abreg->regreg, ®val); |
378 | if (err) { | 378 | if (err) { |
379 | dev_warn(®->dev, | 379 | dev_warn(®->dev, |
@@ -386,7 +386,7 @@ static int ab3100_set_voltage_regulator(struct regulator_dev *reg, | |||
386 | regval &= ~0xE0; | 386 | regval &= ~0xE0; |
387 | regval |= (bestindex << 5); | 387 | regval |= (bestindex << 5); |
388 | 388 | ||
389 | err = ab3100_set_register_interruptible(abreg->ab3100, | 389 | err = abx500_set_register_interruptible(abreg->dev, 0, |
390 | abreg->regreg, regval); | 390 | abreg->regreg, regval); |
391 | if (err) | 391 | if (err) |
392 | dev_warn(®->dev, "failed to set regulator register %02x\n", | 392 | dev_warn(®->dev, "failed to set regulator register %02x\n", |
@@ -414,7 +414,7 @@ static int ab3100_set_suspend_voltage_regulator(struct regulator_dev *reg, | |||
414 | /* LDO E and BUCK have special suspend voltages you can set */ | 414 | /* LDO E and BUCK have special suspend voltages you can set */ |
415 | bestindex = ab3100_get_best_voltage_index(reg, uV, uV); | 415 | bestindex = ab3100_get_best_voltage_index(reg, uV, uV); |
416 | 416 | ||
417 | err = ab3100_get_register_interruptible(abreg->ab3100, | 417 | err = abx500_get_register_interruptible(abreg->dev, 0, |
418 | targetreg, ®val); | 418 | targetreg, ®val); |
419 | if (err) { | 419 | if (err) { |
420 | dev_warn(®->dev, | 420 | dev_warn(®->dev, |
@@ -427,7 +427,7 @@ static int ab3100_set_suspend_voltage_regulator(struct regulator_dev *reg, | |||
427 | regval &= ~0xE0; | 427 | regval &= ~0xE0; |
428 | regval |= (bestindex << 5); | 428 | regval |= (bestindex << 5); |
429 | 429 | ||
430 | err = ab3100_set_register_interruptible(abreg->ab3100, | 430 | err = abx500_set_register_interruptible(abreg->dev, 0, |
431 | targetreg, regval); | 431 | targetreg, regval); |
432 | if (err) | 432 | if (err) |
433 | dev_warn(®->dev, "failed to set regulator register %02x\n", | 433 | dev_warn(®->dev, "failed to set regulator register %02x\n", |
@@ -574,13 +574,12 @@ ab3100_regulator_desc[AB3100_NUM_REGULATORS] = { | |||
574 | static int __devinit ab3100_regulators_probe(struct platform_device *pdev) | 574 | static int __devinit ab3100_regulators_probe(struct platform_device *pdev) |
575 | { | 575 | { |
576 | struct ab3100_platform_data *plfdata = pdev->dev.platform_data; | 576 | struct ab3100_platform_data *plfdata = pdev->dev.platform_data; |
577 | struct ab3100 *ab3100 = platform_get_drvdata(pdev); | ||
578 | int err = 0; | 577 | int err = 0; |
579 | u8 data; | 578 | u8 data; |
580 | int i; | 579 | int i; |
581 | 580 | ||
582 | /* Check chip state */ | 581 | /* Check chip state */ |
583 | err = ab3100_get_register_interruptible(ab3100, | 582 | err = abx500_get_register_interruptible(&pdev->dev, 0, |
584 | AB3100_LDO_D, &data); | 583 | AB3100_LDO_D, &data); |
585 | if (err) { | 584 | if (err) { |
586 | dev_err(&pdev->dev, "could not read initial status of LDO_D\n"); | 585 | dev_err(&pdev->dev, "could not read initial status of LDO_D\n"); |
@@ -595,7 +594,7 @@ static int __devinit ab3100_regulators_probe(struct platform_device *pdev) | |||
595 | 594 | ||
596 | /* Set up regulators */ | 595 | /* Set up regulators */ |
597 | for (i = 0; i < ARRAY_SIZE(ab3100_reg_init_order); i++) { | 596 | for (i = 0; i < ARRAY_SIZE(ab3100_reg_init_order); i++) { |
598 | err = ab3100_set_register_interruptible(ab3100, | 597 | err = abx500_set_register_interruptible(&pdev->dev, 0, |
599 | ab3100_reg_init_order[i], | 598 | ab3100_reg_init_order[i], |
600 | plfdata->reg_initvals[i]); | 599 | plfdata->reg_initvals[i]); |
601 | if (err) { | 600 | if (err) { |
@@ -617,7 +616,7 @@ static int __devinit ab3100_regulators_probe(struct platform_device *pdev) | |||
617 | * see what it looks like for a certain machine, go | 616 | * see what it looks like for a certain machine, go |
618 | * into the machine I2C setup. | 617 | * into the machine I2C setup. |
619 | */ | 618 | */ |
620 | reg->ab3100 = ab3100; | 619 | reg->dev = &pdev->dev; |
621 | reg->plfdata = plfdata; | 620 | reg->plfdata = plfdata; |
622 | 621 | ||
623 | /* | 622 | /* |
diff --git a/drivers/rtc/rtc-ab3100.c b/drivers/rtc/rtc-ab3100.c index b46b85d581b0..d26780ea254b 100644 --- a/drivers/rtc/rtc-ab3100.c +++ b/drivers/rtc/rtc-ab3100.c | |||
@@ -45,7 +45,6 @@ | |||
45 | */ | 45 | */ |
46 | static int ab3100_rtc_set_mmss(struct device *dev, unsigned long secs) | 46 | static int ab3100_rtc_set_mmss(struct device *dev, unsigned long secs) |
47 | { | 47 | { |
48 | struct ab3100 *ab3100_data = dev_get_drvdata(dev); | ||
49 | u8 regs[] = {AB3100_TI0, AB3100_TI1, AB3100_TI2, | 48 | u8 regs[] = {AB3100_TI0, AB3100_TI1, AB3100_TI2, |
50 | AB3100_TI3, AB3100_TI4, AB3100_TI5}; | 49 | AB3100_TI3, AB3100_TI4, AB3100_TI5}; |
51 | unsigned char buf[6]; | 50 | unsigned char buf[6]; |
@@ -61,27 +60,26 @@ static int ab3100_rtc_set_mmss(struct device *dev, unsigned long secs) | |||
61 | buf[5] = (fat_time >> 40) & 0xFF; | 60 | buf[5] = (fat_time >> 40) & 0xFF; |
62 | 61 | ||
63 | for (i = 0; i < 6; i++) { | 62 | for (i = 0; i < 6; i++) { |
64 | err = ab3100_set_register_interruptible(ab3100_data, | 63 | err = abx500_set_register_interruptible(dev, 0, |
65 | regs[i], buf[i]); | 64 | regs[i], buf[i]); |
66 | if (err) | 65 | if (err) |
67 | return err; | 66 | return err; |
68 | } | 67 | } |
69 | 68 | ||
70 | /* Set the flag to mark that the clock is now set */ | 69 | /* Set the flag to mark that the clock is now set */ |
71 | return ab3100_mask_and_set_register_interruptible(ab3100_data, | 70 | return abx500_mask_and_set_register_interruptible(dev, 0, |
72 | AB3100_RTC, | 71 | AB3100_RTC, |
73 | 0xFE, 0x01); | 72 | 0x01, 0x01); |
74 | 73 | ||
75 | } | 74 | } |
76 | 75 | ||
77 | static int ab3100_rtc_read_time(struct device *dev, struct rtc_time *tm) | 76 | static int ab3100_rtc_read_time(struct device *dev, struct rtc_time *tm) |
78 | { | 77 | { |
79 | struct ab3100 *ab3100_data = dev_get_drvdata(dev); | ||
80 | unsigned long time; | 78 | unsigned long time; |
81 | u8 rtcval; | 79 | u8 rtcval; |
82 | int err; | 80 | int err; |
83 | 81 | ||
84 | err = ab3100_get_register_interruptible(ab3100_data, | 82 | err = abx500_get_register_interruptible(dev, 0, |
85 | AB3100_RTC, &rtcval); | 83 | AB3100_RTC, &rtcval); |
86 | if (err) | 84 | if (err) |
87 | return err; | 85 | return err; |
@@ -94,7 +92,7 @@ static int ab3100_rtc_read_time(struct device *dev, struct rtc_time *tm) | |||
94 | u8 buf[6]; | 92 | u8 buf[6]; |
95 | 93 | ||
96 | /* Read out time registers */ | 94 | /* Read out time registers */ |
97 | err = ab3100_get_register_page_interruptible(ab3100_data, | 95 | err = abx500_get_register_page_interruptible(dev, 0, |
98 | AB3100_TI0, | 96 | AB3100_TI0, |
99 | buf, 6); | 97 | buf, 6); |
100 | if (err != 0) | 98 | if (err != 0) |
@@ -114,7 +112,6 @@ static int ab3100_rtc_read_time(struct device *dev, struct rtc_time *tm) | |||
114 | 112 | ||
115 | static int ab3100_rtc_read_alarm(struct device *dev, struct rtc_wkalrm *alarm) | 113 | static int ab3100_rtc_read_alarm(struct device *dev, struct rtc_wkalrm *alarm) |
116 | { | 114 | { |
117 | struct ab3100 *ab3100_data = dev_get_drvdata(dev); | ||
118 | unsigned long time; | 115 | unsigned long time; |
119 | u64 fat_time; | 116 | u64 fat_time; |
120 | u8 buf[6]; | 117 | u8 buf[6]; |
@@ -122,7 +119,7 @@ static int ab3100_rtc_read_alarm(struct device *dev, struct rtc_wkalrm *alarm) | |||
122 | int err; | 119 | int err; |
123 | 120 | ||
124 | /* Figure out if alarm is enabled or not */ | 121 | /* Figure out if alarm is enabled or not */ |
125 | err = ab3100_get_register_interruptible(ab3100_data, | 122 | err = abx500_get_register_interruptible(dev, 0, |
126 | AB3100_RTC, &rtcval); | 123 | AB3100_RTC, &rtcval); |
127 | if (err) | 124 | if (err) |
128 | return err; | 125 | return err; |
@@ -133,7 +130,7 @@ static int ab3100_rtc_read_alarm(struct device *dev, struct rtc_wkalrm *alarm) | |||
133 | /* No idea how this could be represented */ | 130 | /* No idea how this could be represented */ |
134 | alarm->pending = 0; | 131 | alarm->pending = 0; |
135 | /* Read out alarm registers, only 4 bytes */ | 132 | /* Read out alarm registers, only 4 bytes */ |
136 | err = ab3100_get_register_page_interruptible(ab3100_data, | 133 | err = abx500_get_register_page_interruptible(dev, 0, |
137 | AB3100_AL0, buf, 4); | 134 | AB3100_AL0, buf, 4); |
138 | if (err) | 135 | if (err) |
139 | return err; | 136 | return err; |
@@ -148,7 +145,6 @@ static int ab3100_rtc_read_alarm(struct device *dev, struct rtc_wkalrm *alarm) | |||
148 | 145 | ||
149 | static int ab3100_rtc_set_alarm(struct device *dev, struct rtc_wkalrm *alarm) | 146 | static int ab3100_rtc_set_alarm(struct device *dev, struct rtc_wkalrm *alarm) |
150 | { | 147 | { |
151 | struct ab3100 *ab3100_data = dev_get_drvdata(dev); | ||
152 | u8 regs[] = {AB3100_AL0, AB3100_AL1, AB3100_AL2, AB3100_AL3}; | 148 | u8 regs[] = {AB3100_AL0, AB3100_AL1, AB3100_AL2, AB3100_AL3}; |
153 | unsigned char buf[4]; | 149 | unsigned char buf[4]; |
154 | unsigned long secs; | 150 | unsigned long secs; |
@@ -165,21 +161,19 @@ static int ab3100_rtc_set_alarm(struct device *dev, struct rtc_wkalrm *alarm) | |||
165 | 161 | ||
166 | /* Set the alarm */ | 162 | /* Set the alarm */ |
167 | for (i = 0; i < 4; i++) { | 163 | for (i = 0; i < 4; i++) { |
168 | err = ab3100_set_register_interruptible(ab3100_data, | 164 | err = abx500_set_register_interruptible(dev, 0, |
169 | regs[i], buf[i]); | 165 | regs[i], buf[i]); |
170 | if (err) | 166 | if (err) |
171 | return err; | 167 | return err; |
172 | } | 168 | } |
173 | /* Then enable the alarm */ | 169 | /* Then enable the alarm */ |
174 | return ab3100_mask_and_set_register_interruptible(ab3100_data, | 170 | return abx500_mask_and_set_register_interruptible(dev, 0, |
175 | AB3100_RTC, ~(1 << 2), | 171 | AB3100_RTC, (1 << 2), |
176 | alarm->enabled << 2); | 172 | alarm->enabled << 2); |
177 | } | 173 | } |
178 | 174 | ||
179 | static int ab3100_rtc_irq_enable(struct device *dev, unsigned int enabled) | 175 | static int ab3100_rtc_irq_enable(struct device *dev, unsigned int enabled) |
180 | { | 176 | { |
181 | struct ab3100 *ab3100_data = dev_get_drvdata(dev); | ||
182 | |||
183 | /* | 177 | /* |
184 | * It's not possible to enable/disable the alarm IRQ for this RTC. | 178 | * It's not possible to enable/disable the alarm IRQ for this RTC. |
185 | * It does not actually trigger any IRQ: instead its only function is | 179 | * It does not actually trigger any IRQ: instead its only function is |
@@ -188,12 +182,12 @@ static int ab3100_rtc_irq_enable(struct device *dev, unsigned int enabled) | |||
188 | * and need to be handled there instead. | 182 | * and need to be handled there instead. |
189 | */ | 183 | */ |
190 | if (enabled) | 184 | if (enabled) |
191 | return ab3100_mask_and_set_register_interruptible(ab3100_data, | 185 | return abx500_mask_and_set_register_interruptible(dev, 0, |
192 | AB3100_RTC, ~(1 << 2), | 186 | AB3100_RTC, (1 << 2), |
193 | 1 << 2); | 187 | 1 << 2); |
194 | else | 188 | else |
195 | return ab3100_mask_and_set_register_interruptible(ab3100_data, | 189 | return abx500_mask_and_set_register_interruptible(dev, 0, |
196 | AB3100_RTC, ~(1 << 2), | 190 | AB3100_RTC, (1 << 2), |
197 | 0); | 191 | 0); |
198 | } | 192 | } |
199 | 193 | ||
@@ -210,10 +204,9 @@ static int __init ab3100_rtc_probe(struct platform_device *pdev) | |||
210 | int err; | 204 | int err; |
211 | u8 regval; | 205 | u8 regval; |
212 | struct rtc_device *rtc; | 206 | struct rtc_device *rtc; |
213 | struct ab3100 *ab3100_data = platform_get_drvdata(pdev); | ||
214 | 207 | ||
215 | /* The first RTC register needs special treatment */ | 208 | /* The first RTC register needs special treatment */ |
216 | err = ab3100_get_register_interruptible(ab3100_data, | 209 | err = abx500_get_register_interruptible(&pdev->dev, 0, |
217 | AB3100_RTC, ®val); | 210 | AB3100_RTC, ®val); |
218 | if (err) { | 211 | if (err) { |
219 | dev_err(&pdev->dev, "unable to read RTC register\n"); | 212 | dev_err(&pdev->dev, "unable to read RTC register\n"); |
@@ -231,7 +224,7 @@ static int __init ab3100_rtc_probe(struct platform_device *pdev) | |||
231 | * This bit remains until RTC power is lost. | 224 | * This bit remains until RTC power is lost. |
232 | */ | 225 | */ |
233 | regval = 1 | RTC_SETTING; | 226 | regval = 1 | RTC_SETTING; |
234 | err = ab3100_set_register_interruptible(ab3100_data, | 227 | err = abx500_set_register_interruptible(&pdev->dev, 0, |
235 | AB3100_RTC, regval); | 228 | AB3100_RTC, regval); |
236 | /* Ignore any error on this write */ | 229 | /* Ignore any error on this write */ |
237 | } | 230 | } |
diff --git a/include/linux/mfd/abx500.h b/include/linux/mfd/abx500.h index 9a881c305a50..390726fcbcb1 100644 --- a/include/linux/mfd/abx500.h +++ b/include/linux/mfd/abx500.h | |||
@@ -3,17 +3,37 @@ | |||
3 | * License terms: GNU General Public License (GPL) version 2 | 3 | * License terms: GNU General Public License (GPL) version 2 |
4 | * AB3100 core access functions | 4 | * AB3100 core access functions |
5 | * Author: Linus Walleij <linus.walleij@stericsson.com> | 5 | * Author: Linus Walleij <linus.walleij@stericsson.com> |
6 | * | ||
7 | * ABX500 core access functions. | ||
8 | * The abx500 interface is used for the Analog Baseband chip | ||
9 | * ab3100, ab3550, ab5500 and possibly comming. It is not used for | ||
10 | * ab4500 and ab8500 since they are another family of chip. | ||
11 | * | ||
12 | * Author: Mattias Wallin <mattias.wallin@stericsson.com> | ||
13 | * Author: Mattias Nilsson <mattias.i.nilsson@stericsson.com> | ||
14 | * Author: Bengt Jonsson <bengt.g.jonsson@stericsson.com> | ||
15 | * Author: Rickard Andersson <rickard.andersson@stericsson.com> | ||
6 | */ | 16 | */ |
7 | 17 | ||
8 | #include <linux/device.h> | 18 | #include <linux/device.h> |
9 | #include <linux/regulator/machine.h> | 19 | #include <linux/regulator/machine.h> |
10 | 20 | ||
11 | #ifndef MFD_AB3100_H | 21 | #ifndef MFD_ABX500_H |
12 | #define MFD_AB3100_H | 22 | #define MFD_ABX500_H |
13 | 23 | ||
14 | #define ABUNKNOWN 0 | 24 | #define AB3100_P1A 0xc0 |
15 | #define AB3000 1 | 25 | #define AB3100_P1B 0xc1 |
16 | #define AB3100 2 | 26 | #define AB3100_P1C 0xc2 |
27 | #define AB3100_P1D 0xc3 | ||
28 | #define AB3100_P1E 0xc4 | ||
29 | #define AB3100_P1F 0xc5 | ||
30 | #define AB3100_P1G 0xc6 | ||
31 | #define AB3100_R2A 0xc7 | ||
32 | #define AB3100_R2B 0xc8 | ||
33 | #define AB3550_P1A 0x10 | ||
34 | #define AB5500_1_0 0x20 | ||
35 | #define AB5500_2_0 0x21 | ||
36 | #define AB5500_2_1 0x22 | ||
17 | 37 | ||
18 | /* | 38 | /* |
19 | * AB3100, EVENTA1, A2 and A3 event register flags | 39 | * AB3100, EVENTA1, A2 and A3 event register flags |
@@ -89,7 +109,7 @@ struct ab3100 { | |||
89 | char chip_name[32]; | 109 | char chip_name[32]; |
90 | u8 chip_id; | 110 | u8 chip_id; |
91 | struct blocking_notifier_head event_subscribers; | 111 | struct blocking_notifier_head event_subscribers; |
92 | u32 startup_events; | 112 | u8 startup_events[3]; |
93 | bool startup_events_read; | 113 | bool startup_events_read; |
94 | }; | 114 | }; |
95 | 115 | ||
@@ -112,18 +132,102 @@ struct ab3100_platform_data { | |||
112 | int external_voltage; | 132 | int external_voltage; |
113 | }; | 133 | }; |
114 | 134 | ||
115 | int ab3100_set_register_interruptible(struct ab3100 *ab3100, u8 reg, u8 regval); | ||
116 | int ab3100_get_register_interruptible(struct ab3100 *ab3100, u8 reg, u8 *regval); | ||
117 | int ab3100_get_register_page_interruptible(struct ab3100 *ab3100, | ||
118 | u8 first_reg, u8 *regvals, u8 numregs); | ||
119 | int ab3100_mask_and_set_register_interruptible(struct ab3100 *ab3100, | ||
120 | u8 reg, u8 andmask, u8 ormask); | ||
121 | u8 ab3100_get_chip_type(struct ab3100 *ab3100); | ||
122 | int ab3100_event_register(struct ab3100 *ab3100, | 135 | int ab3100_event_register(struct ab3100 *ab3100, |
123 | struct notifier_block *nb); | 136 | struct notifier_block *nb); |
124 | int ab3100_event_unregister(struct ab3100 *ab3100, | 137 | int ab3100_event_unregister(struct ab3100 *ab3100, |
125 | struct notifier_block *nb); | 138 | struct notifier_block *nb); |
126 | int ab3100_event_registers_startup_state_get(struct ab3100 *ab3100, | ||
127 | u32 *fatevent); | ||
128 | 139 | ||
140 | /* AB3550, STR register flags */ | ||
141 | #define AB3550_STR_ONSWA (0x01) | ||
142 | #define AB3550_STR_ONSWB (0x02) | ||
143 | #define AB3550_STR_ONSWC (0x04) | ||
144 | #define AB3550_STR_DCIO (0x08) | ||
145 | #define AB3550_STR_BOOT_MODE (0x10) | ||
146 | #define AB3550_STR_SIM_OFF (0x20) | ||
147 | #define AB3550_STR_BATT_REMOVAL (0x40) | ||
148 | #define AB3550_STR_VBUS (0x80) | ||
149 | |||
150 | /* Interrupt mask registers */ | ||
151 | #define AB3550_IMR1 0x29 | ||
152 | #define AB3550_IMR2 0x2a | ||
153 | #define AB3550_IMR3 0x2b | ||
154 | #define AB3550_IMR4 0x2c | ||
155 | #define AB3550_IMR5 0x2d | ||
156 | |||
157 | enum ab3550_devid { | ||
158 | AB3550_DEVID_ADC, | ||
159 | AB3550_DEVID_DAC, | ||
160 | AB3550_DEVID_LEDS, | ||
161 | AB3550_DEVID_POWER, | ||
162 | AB3550_DEVID_REGULATORS, | ||
163 | AB3550_DEVID_SIM, | ||
164 | AB3550_DEVID_UART, | ||
165 | AB3550_DEVID_RTC, | ||
166 | AB3550_DEVID_CHARGER, | ||
167 | AB3550_DEVID_FUELGAUGE, | ||
168 | AB3550_DEVID_VIBRATOR, | ||
169 | AB3550_DEVID_CODEC, | ||
170 | AB3550_NUM_DEVICES, | ||
171 | }; | ||
172 | |||
173 | /** | ||
174 | * struct abx500_init_setting | ||
175 | * Initial value of the registers for driver to use during setup. | ||
176 | */ | ||
177 | struct abx500_init_settings { | ||
178 | u8 bank; | ||
179 | u8 reg; | ||
180 | u8 setting; | ||
181 | }; | ||
182 | |||
183 | /** | ||
184 | * struct ab3550_platform_data | ||
185 | * Data supplied to initialize board connections to the AB3550 | ||
186 | */ | ||
187 | struct ab3550_platform_data { | ||
188 | struct {unsigned int base; unsigned int count; } irq; | ||
189 | void *dev_data[AB3550_NUM_DEVICES]; | ||
190 | size_t dev_data_sz[AB3550_NUM_DEVICES]; | ||
191 | struct abx500_init_settings *init_settings; | ||
192 | unsigned int init_settings_sz; | ||
193 | }; | ||
194 | |||
195 | int abx500_set_register_interruptible(struct device *dev, u8 bank, u8 reg, | ||
196 | u8 value); | ||
197 | int abx500_get_register_interruptible(struct device *dev, u8 bank, u8 reg, | ||
198 | u8 *value); | ||
199 | int abx500_get_register_page_interruptible(struct device *dev, u8 bank, | ||
200 | u8 first_reg, u8 *regvals, u8 numregs); | ||
201 | int abx500_set_register_page_interruptible(struct device *dev, u8 bank, | ||
202 | u8 first_reg, u8 *regvals, u8 numregs); | ||
203 | /** | ||
204 | * abx500_mask_and_set_register_inerruptible() - Modifies selected bits of a | ||
205 | * target register | ||
206 | * | ||
207 | * @dev: The AB sub device. | ||
208 | * @bank: The i2c bank number. | ||
209 | * @bitmask: The bit mask to use. | ||
210 | * @bitvalues: The new bit values. | ||
211 | * | ||
212 | * Updates the value of an AB register: | ||
213 | * value -> ((value & ~bitmask) | (bitvalues & bitmask)) | ||
214 | */ | ||
215 | int abx500_mask_and_set_register_interruptible(struct device *dev, u8 bank, | ||
216 | u8 reg, u8 bitmask, u8 bitvalues); | ||
217 | int abx500_get_chip_id(struct device *dev); | ||
218 | int abx500_event_registers_startup_state_get(struct device *dev, u8 *event); | ||
219 | int abx500_startup_irq_enabled(struct device *dev, unsigned int irq); | ||
220 | |||
221 | struct abx500_ops { | ||
222 | int (*get_chip_id) (struct device *); | ||
223 | int (*get_register) (struct device *, u8, u8, u8 *); | ||
224 | int (*set_register) (struct device *, u8, u8, u8); | ||
225 | int (*get_register_page) (struct device *, u8, u8, u8 *, u8); | ||
226 | int (*set_register_page) (struct device *, u8, u8, u8 *, u8); | ||
227 | int (*mask_and_set_register) (struct device *, u8, u8, u8, u8); | ||
228 | int (*event_registers_startup_state_get) (struct device *, u8 *); | ||
229 | int (*startup_irq_enabled) (struct device *, unsigned int); | ||
230 | }; | ||
231 | |||
232 | int abx500_register_ops(struct device *core_dev, struct abx500_ops *ops); | ||
129 | #endif | 233 | #endif |