Haojian Zhuang | bbd51b1 | 2010-01-06 17:04:18 -0500 | [diff] [blame] | 1 | /* |
| 2 | * Base driver for Marvell 88PM8607 |
| 3 | * |
| 4 | * Copyright (C) 2009 Marvell International Ltd. |
Lee Jones | 2e57848 | 2014-05-08 12:28:37 +0100 | [diff] [blame] | 5 | * |
| 6 | * Author: Haojian Zhuang <haojian.zhuang@marvell.com> |
Haojian Zhuang | bbd51b1 | 2010-01-06 17:04:18 -0500 | [diff] [blame] | 7 | * |
| 8 | * This program is free software; you can redistribute it and/or modify |
| 9 | * it under the terms of the GNU General Public License version 2 as |
| 10 | * published by the Free Software Foundation. |
| 11 | */ |
| 12 | |
| 13 | #include <linux/kernel.h> |
| 14 | #include <linux/module.h> |
Haojian Zhuang | f2f218c | 2012-09-17 12:19:08 +0800 | [diff] [blame] | 15 | #include <linux/err.h> |
Haojian Zhuang | 5c42e8c | 2009-12-15 16:01:47 -0500 | [diff] [blame] | 16 | #include <linux/i2c.h> |
Haojian Zhuang | 2afa62e | 2010-02-08 05:02:00 -0500 | [diff] [blame] | 17 | #include <linux/irq.h> |
Haojian Zhuang | bbd51b1 | 2010-01-06 17:04:18 -0500 | [diff] [blame] | 18 | #include <linux/interrupt.h> |
Haojian Zhuang | 837c829 | 2012-10-02 10:23:20 +0800 | [diff] [blame] | 19 | #include <linux/irqdomain.h> |
Haojian Zhuang | 2e57d56 | 2012-09-21 18:06:52 +0800 | [diff] [blame] | 20 | #include <linux/of.h> |
| 21 | #include <linux/of_platform.h> |
Haojian Zhuang | bbd51b1 | 2010-01-06 17:04:18 -0500 | [diff] [blame] | 22 | #include <linux/platform_device.h> |
Haojian Zhuang | f2f218c | 2012-09-17 12:19:08 +0800 | [diff] [blame] | 23 | #include <linux/regmap.h> |
| 24 | #include <linux/slab.h> |
Haojian Zhuang | bbd51b1 | 2010-01-06 17:04:18 -0500 | [diff] [blame] | 25 | #include <linux/mfd/core.h> |
Haojian Zhuang | 53dbab7 | 2010-01-08 06:01:24 -0500 | [diff] [blame] | 26 | #include <linux/mfd/88pm860x.h> |
Haojian Zhuang | 22aad00 | 2011-03-07 23:43:11 +0800 | [diff] [blame] | 27 | #include <linux/regulator/machine.h> |
Jett.Zhou | a830d28 | 2012-07-27 16:27:16 +0800 | [diff] [blame] | 28 | #include <linux/power/charger-manager.h> |
Haojian Zhuang | bbd51b1 | 2010-01-06 17:04:18 -0500 | [diff] [blame] | 29 | |
Haojian Zhuang | 2afa62e | 2010-02-08 05:02:00 -0500 | [diff] [blame] | 30 | #define INT_STATUS_NUM 3 |
| 31 | |
Bill Pemberton | a9e9ce4 | 2012-11-19 13:24:21 -0500 | [diff] [blame] | 32 | static struct resource bk0_resources[] = { |
Haojian Zhuang | a6ccdcd | 2012-08-08 23:17:26 +0800 | [diff] [blame] | 33 | {2, 2, "duty cycle", IORESOURCE_REG, }, |
| 34 | {3, 3, "always on", IORESOURCE_REG, }, |
| 35 | {3, 3, "current", IORESOURCE_REG, }, |
| 36 | }; |
Bill Pemberton | a9e9ce4 | 2012-11-19 13:24:21 -0500 | [diff] [blame] | 37 | static struct resource bk1_resources[] = { |
Haojian Zhuang | a6ccdcd | 2012-08-08 23:17:26 +0800 | [diff] [blame] | 38 | {4, 4, "duty cycle", IORESOURCE_REG, }, |
| 39 | {5, 5, "always on", IORESOURCE_REG, }, |
| 40 | {5, 5, "current", IORESOURCE_REG, }, |
| 41 | }; |
Bill Pemberton | a9e9ce4 | 2012-11-19 13:24:21 -0500 | [diff] [blame] | 42 | static struct resource bk2_resources[] = { |
Haojian Zhuang | a6ccdcd | 2012-08-08 23:17:26 +0800 | [diff] [blame] | 43 | {6, 6, "duty cycle", IORESOURCE_REG, }, |
| 44 | {7, 7, "always on", IORESOURCE_REG, }, |
| 45 | {5, 5, "current", IORESOURCE_REG, }, |
Haojian Zhuang | a16122b | 2009-12-15 16:04:36 -0500 | [diff] [blame] | 46 | }; |
Haojian Zhuang | adb7048 | 2011-03-07 23:43:09 +0800 | [diff] [blame] | 47 | |
Bill Pemberton | a9e9ce4 | 2012-11-19 13:24:21 -0500 | [diff] [blame] | 48 | static struct resource led0_resources[] = { |
Haojian Zhuang | 894fc8f | 2012-08-08 23:17:27 +0800 | [diff] [blame] | 49 | /* RGB1 Red LED */ |
| 50 | {0xd, 0xd, "control", IORESOURCE_REG, }, |
| 51 | {0xc, 0xc, "blink", IORESOURCE_REG, }, |
| 52 | }; |
Bill Pemberton | a9e9ce4 | 2012-11-19 13:24:21 -0500 | [diff] [blame] | 53 | static struct resource led1_resources[] = { |
Haojian Zhuang | 894fc8f | 2012-08-08 23:17:27 +0800 | [diff] [blame] | 54 | /* RGB1 Green LED */ |
| 55 | {0xe, 0xe, "control", IORESOURCE_REG, }, |
| 56 | {0xc, 0xc, "blink", IORESOURCE_REG, }, |
| 57 | }; |
Bill Pemberton | a9e9ce4 | 2012-11-19 13:24:21 -0500 | [diff] [blame] | 58 | static struct resource led2_resources[] = { |
Haojian Zhuang | 894fc8f | 2012-08-08 23:17:27 +0800 | [diff] [blame] | 59 | /* RGB1 Blue LED */ |
| 60 | {0xf, 0xf, "control", IORESOURCE_REG, }, |
| 61 | {0xc, 0xc, "blink", IORESOURCE_REG, }, |
| 62 | }; |
Bill Pemberton | a9e9ce4 | 2012-11-19 13:24:21 -0500 | [diff] [blame] | 63 | static struct resource led3_resources[] = { |
Haojian Zhuang | 894fc8f | 2012-08-08 23:17:27 +0800 | [diff] [blame] | 64 | /* RGB2 Red LED */ |
| 65 | {0x9, 0x9, "control", IORESOURCE_REG, }, |
| 66 | {0x8, 0x8, "blink", IORESOURCE_REG, }, |
| 67 | }; |
Bill Pemberton | a9e9ce4 | 2012-11-19 13:24:21 -0500 | [diff] [blame] | 68 | static struct resource led4_resources[] = { |
Haojian Zhuang | 894fc8f | 2012-08-08 23:17:27 +0800 | [diff] [blame] | 69 | /* RGB2 Green LED */ |
| 70 | {0xa, 0xa, "control", IORESOURCE_REG, }, |
| 71 | {0x8, 0x8, "blink", IORESOURCE_REG, }, |
| 72 | }; |
Bill Pemberton | a9e9ce4 | 2012-11-19 13:24:21 -0500 | [diff] [blame] | 73 | static struct resource led5_resources[] = { |
Haojian Zhuang | 894fc8f | 2012-08-08 23:17:27 +0800 | [diff] [blame] | 74 | /* RGB2 Blue LED */ |
| 75 | {0xb, 0xb, "control", IORESOURCE_REG, }, |
| 76 | {0x8, 0x8, "blink", IORESOURCE_REG, }, |
Haojian Zhuang | 3154c34 | 2011-03-07 23:43:10 +0800 | [diff] [blame] | 77 | }; |
| 78 | |
Bill Pemberton | a9e9ce4 | 2012-11-19 13:24:21 -0500 | [diff] [blame] | 79 | static struct resource buck1_resources[] = { |
Haojian Zhuang | a70abac | 2012-08-08 23:17:28 +0800 | [diff] [blame] | 80 | {0x24, 0x24, "buck set", IORESOURCE_REG, }, |
| 81 | }; |
Bill Pemberton | a9e9ce4 | 2012-11-19 13:24:21 -0500 | [diff] [blame] | 82 | static struct resource buck2_resources[] = { |
Haojian Zhuang | a70abac | 2012-08-08 23:17:28 +0800 | [diff] [blame] | 83 | {0x25, 0x25, "buck set", IORESOURCE_REG, }, |
| 84 | }; |
Bill Pemberton | a9e9ce4 | 2012-11-19 13:24:21 -0500 | [diff] [blame] | 85 | static struct resource buck3_resources[] = { |
Haojian Zhuang | a70abac | 2012-08-08 23:17:28 +0800 | [diff] [blame] | 86 | {0x26, 0x26, "buck set", IORESOURCE_REG, }, |
| 87 | }; |
Bill Pemberton | a9e9ce4 | 2012-11-19 13:24:21 -0500 | [diff] [blame] | 88 | static struct resource ldo1_resources[] = { |
Haojian Zhuang | a70abac | 2012-08-08 23:17:28 +0800 | [diff] [blame] | 89 | {0x10, 0x10, "ldo set", IORESOURCE_REG, }, |
| 90 | }; |
Bill Pemberton | a9e9ce4 | 2012-11-19 13:24:21 -0500 | [diff] [blame] | 91 | static struct resource ldo2_resources[] = { |
Haojian Zhuang | a70abac | 2012-08-08 23:17:28 +0800 | [diff] [blame] | 92 | {0x11, 0x11, "ldo set", IORESOURCE_REG, }, |
| 93 | }; |
Bill Pemberton | a9e9ce4 | 2012-11-19 13:24:21 -0500 | [diff] [blame] | 94 | static struct resource ldo3_resources[] = { |
Haojian Zhuang | a70abac | 2012-08-08 23:17:28 +0800 | [diff] [blame] | 95 | {0x12, 0x12, "ldo set", IORESOURCE_REG, }, |
| 96 | }; |
Bill Pemberton | a9e9ce4 | 2012-11-19 13:24:21 -0500 | [diff] [blame] | 97 | static struct resource ldo4_resources[] = { |
Haojian Zhuang | a70abac | 2012-08-08 23:17:28 +0800 | [diff] [blame] | 98 | {0x13, 0x13, "ldo set", IORESOURCE_REG, }, |
| 99 | }; |
Bill Pemberton | a9e9ce4 | 2012-11-19 13:24:21 -0500 | [diff] [blame] | 100 | static struct resource ldo5_resources[] = { |
Haojian Zhuang | a70abac | 2012-08-08 23:17:28 +0800 | [diff] [blame] | 101 | {0x14, 0x14, "ldo set", IORESOURCE_REG, }, |
| 102 | }; |
Bill Pemberton | a9e9ce4 | 2012-11-19 13:24:21 -0500 | [diff] [blame] | 103 | static struct resource ldo6_resources[] = { |
Haojian Zhuang | a70abac | 2012-08-08 23:17:28 +0800 | [diff] [blame] | 104 | {0x15, 0x15, "ldo set", IORESOURCE_REG, }, |
| 105 | }; |
Bill Pemberton | a9e9ce4 | 2012-11-19 13:24:21 -0500 | [diff] [blame] | 106 | static struct resource ldo7_resources[] = { |
Haojian Zhuang | a70abac | 2012-08-08 23:17:28 +0800 | [diff] [blame] | 107 | {0x16, 0x16, "ldo set", IORESOURCE_REG, }, |
| 108 | }; |
Bill Pemberton | a9e9ce4 | 2012-11-19 13:24:21 -0500 | [diff] [blame] | 109 | static struct resource ldo8_resources[] = { |
Haojian Zhuang | a70abac | 2012-08-08 23:17:28 +0800 | [diff] [blame] | 110 | {0x17, 0x17, "ldo set", IORESOURCE_REG, }, |
| 111 | }; |
Bill Pemberton | a9e9ce4 | 2012-11-19 13:24:21 -0500 | [diff] [blame] | 112 | static struct resource ldo9_resources[] = { |
Haojian Zhuang | a70abac | 2012-08-08 23:17:28 +0800 | [diff] [blame] | 113 | {0x18, 0x18, "ldo set", IORESOURCE_REG, }, |
| 114 | }; |
Bill Pemberton | a9e9ce4 | 2012-11-19 13:24:21 -0500 | [diff] [blame] | 115 | static struct resource ldo10_resources[] = { |
Haojian Zhuang | a70abac | 2012-08-08 23:17:28 +0800 | [diff] [blame] | 116 | {0x19, 0x19, "ldo set", IORESOURCE_REG, }, |
| 117 | }; |
Bill Pemberton | a9e9ce4 | 2012-11-19 13:24:21 -0500 | [diff] [blame] | 118 | static struct resource ldo12_resources[] = { |
Haojian Zhuang | a70abac | 2012-08-08 23:17:28 +0800 | [diff] [blame] | 119 | {0x1a, 0x1a, "ldo set", IORESOURCE_REG, }, |
| 120 | }; |
Bill Pemberton | a9e9ce4 | 2012-11-19 13:24:21 -0500 | [diff] [blame] | 121 | static struct resource ldo_vibrator_resources[] = { |
Haojian Zhuang | a70abac | 2012-08-08 23:17:28 +0800 | [diff] [blame] | 122 | {0x28, 0x28, "ldo set", IORESOURCE_REG, }, |
| 123 | }; |
Bill Pemberton | a9e9ce4 | 2012-11-19 13:24:21 -0500 | [diff] [blame] | 124 | static struct resource ldo14_resources[] = { |
Haojian Zhuang | a70abac | 2012-08-08 23:17:28 +0800 | [diff] [blame] | 125 | {0x1b, 0x1b, "ldo set", IORESOURCE_REG, }, |
Haojian Zhuang | 22aad00 | 2011-03-07 23:43:11 +0800 | [diff] [blame] | 126 | }; |
| 127 | |
Bill Pemberton | a9e9ce4 | 2012-11-19 13:24:21 -0500 | [diff] [blame] | 128 | static struct resource touch_resources[] = { |
Haojian Zhuang | c9f560b | 2011-03-07 23:43:12 +0800 | [diff] [blame] | 129 | {PM8607_IRQ_PEN, PM8607_IRQ_PEN, "touch", IORESOURCE_IRQ,}, |
| 130 | }; |
| 131 | |
Bill Pemberton | a9e9ce4 | 2012-11-19 13:24:21 -0500 | [diff] [blame] | 132 | static struct resource onkey_resources[] = { |
Haojian Zhuang | c9f560b | 2011-03-07 23:43:12 +0800 | [diff] [blame] | 133 | {PM8607_IRQ_ONKEY, PM8607_IRQ_ONKEY, "onkey", IORESOURCE_IRQ,}, |
| 134 | }; |
| 135 | |
Bill Pemberton | a9e9ce4 | 2012-11-19 13:24:21 -0500 | [diff] [blame] | 136 | static struct resource codec_resources[] = { |
Haojian Zhuang | c9f560b | 2011-03-07 23:43:12 +0800 | [diff] [blame] | 137 | /* Headset microphone insertion or removal */ |
| 138 | {PM8607_IRQ_MICIN, PM8607_IRQ_MICIN, "micin", IORESOURCE_IRQ,}, |
| 139 | /* Hook-switch press or release */ |
| 140 | {PM8607_IRQ_HOOK, PM8607_IRQ_HOOK, "hook", IORESOURCE_IRQ,}, |
| 141 | /* Headset insertion or removal */ |
| 142 | {PM8607_IRQ_HEADSET, PM8607_IRQ_HEADSET, "headset", IORESOURCE_IRQ,}, |
| 143 | /* Audio short */ |
Lee Jones | 2e57848 | 2014-05-08 12:28:37 +0100 | [diff] [blame] | 144 | {PM8607_IRQ_AUDIO_SHORT, PM8607_IRQ_AUDIO_SHORT, "audio-short", |
| 145 | IORESOURCE_IRQ,}, |
Haojian Zhuang | c9f560b | 2011-03-07 23:43:12 +0800 | [diff] [blame] | 146 | }; |
| 147 | |
Bill Pemberton | a9e9ce4 | 2012-11-19 13:24:21 -0500 | [diff] [blame] | 148 | static struct resource battery_resources[] = { |
Haojian Zhuang | c9f560b | 2011-03-07 23:43:12 +0800 | [diff] [blame] | 149 | {PM8607_IRQ_CC, PM8607_IRQ_CC, "columb counter", IORESOURCE_IRQ,}, |
| 150 | {PM8607_IRQ_BAT, PM8607_IRQ_BAT, "battery", IORESOURCE_IRQ,}, |
| 151 | }; |
| 152 | |
Bill Pemberton | a9e9ce4 | 2012-11-19 13:24:21 -0500 | [diff] [blame] | 153 | static struct resource charger_resources[] = { |
Haojian Zhuang | c9f560b | 2011-03-07 23:43:12 +0800 | [diff] [blame] | 154 | {PM8607_IRQ_CHG, PM8607_IRQ_CHG, "charger detect", IORESOURCE_IRQ,}, |
Lee Jones | 2e57848 | 2014-05-08 12:28:37 +0100 | [diff] [blame] | 155 | {PM8607_IRQ_CHG_DONE, PM8607_IRQ_CHG_DONE, "charging done", |
| 156 | IORESOURCE_IRQ,}, |
| 157 | {PM8607_IRQ_CHG_FAIL, PM8607_IRQ_CHG_FAIL, "charging timeout", |
| 158 | IORESOURCE_IRQ,}, |
| 159 | {PM8607_IRQ_CHG_FAULT, PM8607_IRQ_CHG_FAULT, "charging fault", |
| 160 | IORESOURCE_IRQ,}, |
| 161 | {PM8607_IRQ_GPADC1, PM8607_IRQ_GPADC1, "battery temperature", |
| 162 | IORESOURCE_IRQ,}, |
Haojian Zhuang | c9f560b | 2011-03-07 23:43:12 +0800 | [diff] [blame] | 163 | {PM8607_IRQ_VBAT, PM8607_IRQ_VBAT, "battery voltage", IORESOURCE_IRQ,}, |
| 164 | {PM8607_IRQ_VCHG, PM8607_IRQ_VCHG, "vchg voltage", IORESOURCE_IRQ,}, |
| 165 | }; |
| 166 | |
Bill Pemberton | a9e9ce4 | 2012-11-19 13:24:21 -0500 | [diff] [blame] | 167 | static struct resource rtc_resources[] = { |
Mark Brown | 0236702 | 2012-08-07 19:42:48 +0100 | [diff] [blame] | 168 | {PM8607_IRQ_RTC, PM8607_IRQ_RTC, "rtc", IORESOURCE_IRQ,}, |
Haojian Zhuang | 008b304 | 2011-05-06 17:21:20 +0800 | [diff] [blame] | 169 | }; |
| 170 | |
Bill Pemberton | a9e9ce4 | 2012-11-19 13:24:21 -0500 | [diff] [blame] | 171 | static struct mfd_cell bk_devs[] = { |
Haojian Zhuang | a6ccdcd | 2012-08-08 23:17:26 +0800 | [diff] [blame] | 172 | { |
| 173 | .name = "88pm860x-backlight", |
| 174 | .id = 0, |
| 175 | .num_resources = ARRAY_SIZE(bk0_resources), |
| 176 | .resources = bk0_resources, |
| 177 | }, { |
| 178 | .name = "88pm860x-backlight", |
| 179 | .id = 1, |
| 180 | .num_resources = ARRAY_SIZE(bk1_resources), |
| 181 | .resources = bk1_resources, |
| 182 | }, { |
| 183 | .name = "88pm860x-backlight", |
| 184 | .id = 2, |
| 185 | .num_resources = ARRAY_SIZE(bk2_resources), |
| 186 | .resources = bk2_resources, |
| 187 | }, |
Haojian Zhuang | adb7048 | 2011-03-07 23:43:09 +0800 | [diff] [blame] | 188 | }; |
| 189 | |
Bill Pemberton | a9e9ce4 | 2012-11-19 13:24:21 -0500 | [diff] [blame] | 190 | static struct mfd_cell led_devs[] = { |
Haojian Zhuang | 894fc8f | 2012-08-08 23:17:27 +0800 | [diff] [blame] | 191 | { |
| 192 | .name = "88pm860x-led", |
| 193 | .id = 0, |
| 194 | .num_resources = ARRAY_SIZE(led0_resources), |
| 195 | .resources = led0_resources, |
| 196 | }, { |
| 197 | .name = "88pm860x-led", |
| 198 | .id = 1, |
| 199 | .num_resources = ARRAY_SIZE(led1_resources), |
| 200 | .resources = led1_resources, |
| 201 | }, { |
| 202 | .name = "88pm860x-led", |
| 203 | .id = 2, |
| 204 | .num_resources = ARRAY_SIZE(led2_resources), |
| 205 | .resources = led2_resources, |
| 206 | }, { |
| 207 | .name = "88pm860x-led", |
| 208 | .id = 3, |
| 209 | .num_resources = ARRAY_SIZE(led3_resources), |
| 210 | .resources = led3_resources, |
| 211 | }, { |
| 212 | .name = "88pm860x-led", |
| 213 | .id = 4, |
| 214 | .num_resources = ARRAY_SIZE(led4_resources), |
| 215 | .resources = led4_resources, |
| 216 | }, { |
| 217 | .name = "88pm860x-led", |
| 218 | .id = 5, |
| 219 | .num_resources = ARRAY_SIZE(led5_resources), |
| 220 | .resources = led5_resources, |
| 221 | }, |
Haojian Zhuang | 3154c34 | 2011-03-07 23:43:10 +0800 | [diff] [blame] | 222 | }; |
| 223 | |
Bill Pemberton | a9e9ce4 | 2012-11-19 13:24:21 -0500 | [diff] [blame] | 224 | static struct mfd_cell reg_devs[] = { |
Haojian Zhuang | a70abac | 2012-08-08 23:17:28 +0800 | [diff] [blame] | 225 | { |
| 226 | .name = "88pm860x-regulator", |
| 227 | .id = 0, |
| 228 | .num_resources = ARRAY_SIZE(buck1_resources), |
| 229 | .resources = buck1_resources, |
| 230 | }, { |
| 231 | .name = "88pm860x-regulator", |
| 232 | .id = 1, |
| 233 | .num_resources = ARRAY_SIZE(buck2_resources), |
| 234 | .resources = buck2_resources, |
| 235 | }, { |
| 236 | .name = "88pm860x-regulator", |
| 237 | .id = 2, |
| 238 | .num_resources = ARRAY_SIZE(buck3_resources), |
| 239 | .resources = buck3_resources, |
| 240 | }, { |
| 241 | .name = "88pm860x-regulator", |
| 242 | .id = 3, |
| 243 | .num_resources = ARRAY_SIZE(ldo1_resources), |
| 244 | .resources = ldo1_resources, |
| 245 | }, { |
| 246 | .name = "88pm860x-regulator", |
| 247 | .id = 4, |
| 248 | .num_resources = ARRAY_SIZE(ldo2_resources), |
| 249 | .resources = ldo2_resources, |
| 250 | }, { |
| 251 | .name = "88pm860x-regulator", |
| 252 | .id = 5, |
| 253 | .num_resources = ARRAY_SIZE(ldo3_resources), |
| 254 | .resources = ldo3_resources, |
| 255 | }, { |
| 256 | .name = "88pm860x-regulator", |
| 257 | .id = 6, |
| 258 | .num_resources = ARRAY_SIZE(ldo4_resources), |
| 259 | .resources = ldo4_resources, |
| 260 | }, { |
| 261 | .name = "88pm860x-regulator", |
| 262 | .id = 7, |
| 263 | .num_resources = ARRAY_SIZE(ldo5_resources), |
| 264 | .resources = ldo5_resources, |
| 265 | }, { |
| 266 | .name = "88pm860x-regulator", |
| 267 | .id = 8, |
| 268 | .num_resources = ARRAY_SIZE(ldo6_resources), |
| 269 | .resources = ldo6_resources, |
| 270 | }, { |
| 271 | .name = "88pm860x-regulator", |
| 272 | .id = 9, |
| 273 | .num_resources = ARRAY_SIZE(ldo7_resources), |
| 274 | .resources = ldo7_resources, |
| 275 | }, { |
| 276 | .name = "88pm860x-regulator", |
| 277 | .id = 10, |
| 278 | .num_resources = ARRAY_SIZE(ldo8_resources), |
| 279 | .resources = ldo8_resources, |
| 280 | }, { |
| 281 | .name = "88pm860x-regulator", |
| 282 | .id = 11, |
| 283 | .num_resources = ARRAY_SIZE(ldo9_resources), |
| 284 | .resources = ldo9_resources, |
| 285 | }, { |
| 286 | .name = "88pm860x-regulator", |
| 287 | .id = 12, |
| 288 | .num_resources = ARRAY_SIZE(ldo10_resources), |
| 289 | .resources = ldo10_resources, |
| 290 | }, { |
| 291 | .name = "88pm860x-regulator", |
| 292 | .id = 13, |
| 293 | .num_resources = ARRAY_SIZE(ldo12_resources), |
| 294 | .resources = ldo12_resources, |
| 295 | }, { |
| 296 | .name = "88pm860x-regulator", |
| 297 | .id = 14, |
| 298 | .num_resources = ARRAY_SIZE(ldo_vibrator_resources), |
| 299 | .resources = ldo_vibrator_resources, |
| 300 | }, { |
| 301 | .name = "88pm860x-regulator", |
| 302 | .id = 15, |
| 303 | .num_resources = ARRAY_SIZE(ldo14_resources), |
| 304 | .resources = ldo14_resources, |
| 305 | }, |
Haojian Zhuang | 22aad00 | 2011-03-07 23:43:11 +0800 | [diff] [blame] | 306 | }; |
| 307 | |
Haojian Zhuang | a5156f1 | 2011-04-26 11:06:22 +0200 | [diff] [blame] | 308 | static struct mfd_cell touch_devs[] = { |
Haojian Zhuang | c9f560b | 2011-03-07 23:43:12 +0800 | [diff] [blame] | 309 | {"88pm860x-touch", -1,}, |
Haojian Zhuang | a16122b | 2009-12-15 16:04:36 -0500 | [diff] [blame] | 310 | }; |
| 311 | |
Haojian Zhuang | a5156f1 | 2011-04-26 11:06:22 +0200 | [diff] [blame] | 312 | static struct mfd_cell onkey_devs[] = { |
Haojian Zhuang | c9f560b | 2011-03-07 23:43:12 +0800 | [diff] [blame] | 313 | {"88pm860x-onkey", -1,}, |
Haojian Zhuang | a16122b | 2009-12-15 16:04:36 -0500 | [diff] [blame] | 314 | }; |
Haojian Zhuang | bbd51b1 | 2010-01-06 17:04:18 -0500 | [diff] [blame] | 315 | |
Haojian Zhuang | a5156f1 | 2011-04-26 11:06:22 +0200 | [diff] [blame] | 316 | static struct mfd_cell codec_devs[] = { |
Haojian Zhuang | c9f560b | 2011-03-07 23:43:12 +0800 | [diff] [blame] | 317 | {"88pm860x-codec", -1,}, |
Haojian Zhuang | 2afa62e | 2010-02-08 05:02:00 -0500 | [diff] [blame] | 318 | }; |
| 319 | |
Jett.Zhou | 2573f6d | 2012-07-06 10:59:58 +0800 | [diff] [blame] | 320 | static struct regulator_consumer_supply preg_supply[] = { |
| 321 | REGULATOR_SUPPLY("preg", "charger-manager"), |
| 322 | }; |
| 323 | |
| 324 | static struct regulator_init_data preg_init_data = { |
| 325 | .num_consumer_supplies = ARRAY_SIZE(preg_supply), |
| 326 | .consumer_supplies = &preg_supply[0], |
| 327 | }; |
| 328 | |
Anton Vorontsov | f1ade35 | 2012-08-22 20:31:33 -0700 | [diff] [blame] | 329 | static struct charger_regulator chg_desc_regulator_data[] = { |
| 330 | { .regulator_name = "preg", }, |
Jett.Zhou | a830d28 | 2012-07-27 16:27:16 +0800 | [diff] [blame] | 331 | }; |
| 332 | |
Haojian Zhuang | 2afa62e | 2010-02-08 05:02:00 -0500 | [diff] [blame] | 333 | static struct mfd_cell power_devs[] = { |
Haojian Zhuang | c9f560b | 2011-03-07 23:43:12 +0800 | [diff] [blame] | 334 | {"88pm860x-battery", -1,}, |
| 335 | {"88pm860x-charger", -1,}, |
Jett.Zhou | 2573f6d | 2012-07-06 10:59:58 +0800 | [diff] [blame] | 336 | {"88pm860x-preg", -1,}, |
Jett.Zhou | a830d28 | 2012-07-27 16:27:16 +0800 | [diff] [blame] | 337 | {"charger-manager", -1,}, |
Haojian Zhuang | 2afa62e | 2010-02-08 05:02:00 -0500 | [diff] [blame] | 338 | }; |
| 339 | |
Haojian Zhuang | 008b304 | 2011-05-06 17:21:20 +0800 | [diff] [blame] | 340 | static struct mfd_cell rtc_devs[] = { |
| 341 | {"88pm860x-rtc", -1,}, |
| 342 | }; |
| 343 | |
Haojian Zhuang | 2c36af7 | 2010-08-12 11:59:33 +0800 | [diff] [blame] | 344 | |
Haojian Zhuang | 2afa62e | 2010-02-08 05:02:00 -0500 | [diff] [blame] | 345 | struct pm860x_irq_data { |
| 346 | int reg; |
| 347 | int mask_reg; |
| 348 | int enable; /* enable or not */ |
| 349 | int offs; /* bit offset in mask register */ |
| 350 | }; |
Haojian Zhuang | 5c42e8c | 2009-12-15 16:01:47 -0500 | [diff] [blame] | 351 | |
Haojian Zhuang | 2afa62e | 2010-02-08 05:02:00 -0500 | [diff] [blame] | 352 | static struct pm860x_irq_data pm860x_irqs[] = { |
| 353 | [PM8607_IRQ_ONKEY] = { |
| 354 | .reg = PM8607_INT_STATUS1, |
| 355 | .mask_reg = PM8607_INT_MASK_1, |
| 356 | .offs = 1 << 0, |
| 357 | }, |
| 358 | [PM8607_IRQ_EXTON] = { |
| 359 | .reg = PM8607_INT_STATUS1, |
| 360 | .mask_reg = PM8607_INT_MASK_1, |
| 361 | .offs = 1 << 1, |
| 362 | }, |
| 363 | [PM8607_IRQ_CHG] = { |
| 364 | .reg = PM8607_INT_STATUS1, |
| 365 | .mask_reg = PM8607_INT_MASK_1, |
| 366 | .offs = 1 << 2, |
| 367 | }, |
| 368 | [PM8607_IRQ_BAT] = { |
| 369 | .reg = PM8607_INT_STATUS1, |
| 370 | .mask_reg = PM8607_INT_MASK_1, |
| 371 | .offs = 1 << 3, |
| 372 | }, |
| 373 | [PM8607_IRQ_RTC] = { |
| 374 | .reg = PM8607_INT_STATUS1, |
| 375 | .mask_reg = PM8607_INT_MASK_1, |
| 376 | .offs = 1 << 4, |
| 377 | }, |
| 378 | [PM8607_IRQ_CC] = { |
| 379 | .reg = PM8607_INT_STATUS1, |
| 380 | .mask_reg = PM8607_INT_MASK_1, |
| 381 | .offs = 1 << 5, |
| 382 | }, |
| 383 | [PM8607_IRQ_VBAT] = { |
| 384 | .reg = PM8607_INT_STATUS2, |
| 385 | .mask_reg = PM8607_INT_MASK_2, |
| 386 | .offs = 1 << 0, |
| 387 | }, |
| 388 | [PM8607_IRQ_VCHG] = { |
| 389 | .reg = PM8607_INT_STATUS2, |
| 390 | .mask_reg = PM8607_INT_MASK_2, |
| 391 | .offs = 1 << 1, |
| 392 | }, |
| 393 | [PM8607_IRQ_VSYS] = { |
| 394 | .reg = PM8607_INT_STATUS2, |
| 395 | .mask_reg = PM8607_INT_MASK_2, |
| 396 | .offs = 1 << 2, |
| 397 | }, |
| 398 | [PM8607_IRQ_TINT] = { |
| 399 | .reg = PM8607_INT_STATUS2, |
| 400 | .mask_reg = PM8607_INT_MASK_2, |
| 401 | .offs = 1 << 3, |
| 402 | }, |
| 403 | [PM8607_IRQ_GPADC0] = { |
| 404 | .reg = PM8607_INT_STATUS2, |
| 405 | .mask_reg = PM8607_INT_MASK_2, |
| 406 | .offs = 1 << 4, |
| 407 | }, |
| 408 | [PM8607_IRQ_GPADC1] = { |
| 409 | .reg = PM8607_INT_STATUS2, |
| 410 | .mask_reg = PM8607_INT_MASK_2, |
| 411 | .offs = 1 << 5, |
| 412 | }, |
| 413 | [PM8607_IRQ_GPADC2] = { |
| 414 | .reg = PM8607_INT_STATUS2, |
| 415 | .mask_reg = PM8607_INT_MASK_2, |
| 416 | .offs = 1 << 6, |
| 417 | }, |
| 418 | [PM8607_IRQ_GPADC3] = { |
| 419 | .reg = PM8607_INT_STATUS2, |
| 420 | .mask_reg = PM8607_INT_MASK_2, |
| 421 | .offs = 1 << 7, |
| 422 | }, |
| 423 | [PM8607_IRQ_AUDIO_SHORT] = { |
| 424 | .reg = PM8607_INT_STATUS3, |
| 425 | .mask_reg = PM8607_INT_MASK_3, |
| 426 | .offs = 1 << 0, |
| 427 | }, |
| 428 | [PM8607_IRQ_PEN] = { |
| 429 | .reg = PM8607_INT_STATUS3, |
| 430 | .mask_reg = PM8607_INT_MASK_3, |
| 431 | .offs = 1 << 1, |
| 432 | }, |
| 433 | [PM8607_IRQ_HEADSET] = { |
| 434 | .reg = PM8607_INT_STATUS3, |
| 435 | .mask_reg = PM8607_INT_MASK_3, |
| 436 | .offs = 1 << 2, |
| 437 | }, |
| 438 | [PM8607_IRQ_HOOK] = { |
| 439 | .reg = PM8607_INT_STATUS3, |
| 440 | .mask_reg = PM8607_INT_MASK_3, |
| 441 | .offs = 1 << 3, |
| 442 | }, |
| 443 | [PM8607_IRQ_MICIN] = { |
| 444 | .reg = PM8607_INT_STATUS3, |
| 445 | .mask_reg = PM8607_INT_MASK_3, |
| 446 | .offs = 1 << 4, |
| 447 | }, |
| 448 | [PM8607_IRQ_CHG_FAIL] = { |
| 449 | .reg = PM8607_INT_STATUS3, |
| 450 | .mask_reg = PM8607_INT_MASK_3, |
| 451 | .offs = 1 << 5, |
| 452 | }, |
| 453 | [PM8607_IRQ_CHG_DONE] = { |
| 454 | .reg = PM8607_INT_STATUS3, |
| 455 | .mask_reg = PM8607_INT_MASK_3, |
| 456 | .offs = 1 << 6, |
| 457 | }, |
| 458 | [PM8607_IRQ_CHG_FAULT] = { |
| 459 | .reg = PM8607_INT_STATUS3, |
| 460 | .mask_reg = PM8607_INT_MASK_3, |
| 461 | .offs = 1 << 7, |
| 462 | }, |
| 463 | }; |
| 464 | |
Haojian Zhuang | 2afa62e | 2010-02-08 05:02:00 -0500 | [diff] [blame] | 465 | static irqreturn_t pm860x_irq(int irq, void *data) |
Haojian Zhuang | 5c42e8c | 2009-12-15 16:01:47 -0500 | [diff] [blame] | 466 | { |
Haojian Zhuang | 5c42e8c | 2009-12-15 16:01:47 -0500 | [diff] [blame] | 467 | struct pm860x_chip *chip = data; |
Haojian Zhuang | 2afa62e | 2010-02-08 05:02:00 -0500 | [diff] [blame] | 468 | struct pm860x_irq_data *irq_data; |
| 469 | struct i2c_client *i2c; |
| 470 | int read_reg = -1, value = 0; |
| 471 | int i; |
Haojian Zhuang | 5c42e8c | 2009-12-15 16:01:47 -0500 | [diff] [blame] | 472 | |
Haojian Zhuang | 2afa62e | 2010-02-08 05:02:00 -0500 | [diff] [blame] | 473 | i2c = (chip->id == CHIP_PM8607) ? chip->client : chip->companion; |
| 474 | for (i = 0; i < ARRAY_SIZE(pm860x_irqs); i++) { |
| 475 | irq_data = &pm860x_irqs[i]; |
| 476 | if (read_reg != irq_data->reg) { |
| 477 | read_reg = irq_data->reg; |
| 478 | value = pm860x_reg_read(i2c, irq_data->reg); |
Haojian Zhuang | 5c42e8c | 2009-12-15 16:01:47 -0500 | [diff] [blame] | 479 | } |
Haojian Zhuang | 2afa62e | 2010-02-08 05:02:00 -0500 | [diff] [blame] | 480 | if (value & irq_data->enable) |
| 481 | handle_nested_irq(chip->irq_base + i); |
Haojian Zhuang | 5c42e8c | 2009-12-15 16:01:47 -0500 | [diff] [blame] | 482 | } |
Haojian Zhuang | 5c42e8c | 2009-12-15 16:01:47 -0500 | [diff] [blame] | 483 | return IRQ_HANDLED; |
| 484 | } |
| 485 | |
Mark Brown | 49f89d9 | 2010-12-11 12:31:31 +0000 | [diff] [blame] | 486 | static void pm860x_irq_lock(struct irq_data *data) |
Haojian Zhuang | 5c42e8c | 2009-12-15 16:01:47 -0500 | [diff] [blame] | 487 | { |
Mark Brown | 49f89d9 | 2010-12-11 12:31:31 +0000 | [diff] [blame] | 488 | struct pm860x_chip *chip = irq_data_get_irq_chip_data(data); |
Haojian Zhuang | 5c42e8c | 2009-12-15 16:01:47 -0500 | [diff] [blame] | 489 | |
| 490 | mutex_lock(&chip->irq_lock); |
Haojian Zhuang | 5c42e8c | 2009-12-15 16:01:47 -0500 | [diff] [blame] | 491 | } |
Haojian Zhuang | 5c42e8c | 2009-12-15 16:01:47 -0500 | [diff] [blame] | 492 | |
Mark Brown | 49f89d9 | 2010-12-11 12:31:31 +0000 | [diff] [blame] | 493 | static void pm860x_irq_sync_unlock(struct irq_data *data) |
Haojian Zhuang | 5c42e8c | 2009-12-15 16:01:47 -0500 | [diff] [blame] | 494 | { |
Mark Brown | 49f89d9 | 2010-12-11 12:31:31 +0000 | [diff] [blame] | 495 | struct pm860x_chip *chip = irq_data_get_irq_chip_data(data); |
Haojian Zhuang | 2afa62e | 2010-02-08 05:02:00 -0500 | [diff] [blame] | 496 | struct pm860x_irq_data *irq_data; |
| 497 | struct i2c_client *i2c; |
| 498 | static unsigned char cached[3] = {0x0, 0x0, 0x0}; |
| 499 | unsigned char mask[3]; |
| 500 | int i; |
Haojian Zhuang | 5c42e8c | 2009-12-15 16:01:47 -0500 | [diff] [blame] | 501 | |
Haojian Zhuang | 2afa62e | 2010-02-08 05:02:00 -0500 | [diff] [blame] | 502 | i2c = (chip->id == CHIP_PM8607) ? chip->client : chip->companion; |
| 503 | /* Load cached value. In initial, all IRQs are masked */ |
| 504 | for (i = 0; i < 3; i++) |
| 505 | mask[i] = cached[i]; |
| 506 | for (i = 0; i < ARRAY_SIZE(pm860x_irqs); i++) { |
| 507 | irq_data = &pm860x_irqs[i]; |
| 508 | switch (irq_data->mask_reg) { |
| 509 | case PM8607_INT_MASK_1: |
| 510 | mask[0] &= ~irq_data->offs; |
| 511 | mask[0] |= irq_data->enable; |
| 512 | break; |
| 513 | case PM8607_INT_MASK_2: |
| 514 | mask[1] &= ~irq_data->offs; |
| 515 | mask[1] |= irq_data->enable; |
| 516 | break; |
| 517 | case PM8607_INT_MASK_3: |
| 518 | mask[2] &= ~irq_data->offs; |
| 519 | mask[2] |= irq_data->enable; |
| 520 | break; |
| 521 | default: |
| 522 | dev_err(chip->dev, "wrong IRQ\n"); |
| 523 | break; |
| 524 | } |
| 525 | } |
| 526 | /* update mask into registers */ |
| 527 | for (i = 0; i < 3; i++) { |
| 528 | if (mask[i] != cached[i]) { |
| 529 | cached[i] = mask[i]; |
| 530 | pm860x_reg_write(i2c, PM8607_INT_MASK_1 + i, mask[i]); |
| 531 | } |
| 532 | } |
| 533 | |
Haojian Zhuang | 5c42e8c | 2009-12-15 16:01:47 -0500 | [diff] [blame] | 534 | mutex_unlock(&chip->irq_lock); |
Haojian Zhuang | 5c42e8c | 2009-12-15 16:01:47 -0500 | [diff] [blame] | 535 | } |
Haojian Zhuang | 2afa62e | 2010-02-08 05:02:00 -0500 | [diff] [blame] | 536 | |
Mark Brown | 49f89d9 | 2010-12-11 12:31:31 +0000 | [diff] [blame] | 537 | static void pm860x_irq_enable(struct irq_data *data) |
Haojian Zhuang | 2afa62e | 2010-02-08 05:02:00 -0500 | [diff] [blame] | 538 | { |
Haojian Zhuang | 837c829 | 2012-10-02 10:23:20 +0800 | [diff] [blame] | 539 | pm860x_irqs[data->hwirq].enable = pm860x_irqs[data->hwirq].offs; |
Haojian Zhuang | 2afa62e | 2010-02-08 05:02:00 -0500 | [diff] [blame] | 540 | } |
| 541 | |
Mark Brown | 49f89d9 | 2010-12-11 12:31:31 +0000 | [diff] [blame] | 542 | static void pm860x_irq_disable(struct irq_data *data) |
Haojian Zhuang | 2afa62e | 2010-02-08 05:02:00 -0500 | [diff] [blame] | 543 | { |
Haojian Zhuang | 837c829 | 2012-10-02 10:23:20 +0800 | [diff] [blame] | 544 | pm860x_irqs[data->hwirq].enable = 0; |
Haojian Zhuang | 2afa62e | 2010-02-08 05:02:00 -0500 | [diff] [blame] | 545 | } |
| 546 | |
| 547 | static struct irq_chip pm860x_irq_chip = { |
| 548 | .name = "88pm860x", |
Mark Brown | 49f89d9 | 2010-12-11 12:31:31 +0000 | [diff] [blame] | 549 | .irq_bus_lock = pm860x_irq_lock, |
| 550 | .irq_bus_sync_unlock = pm860x_irq_sync_unlock, |
| 551 | .irq_enable = pm860x_irq_enable, |
| 552 | .irq_disable = pm860x_irq_disable, |
Haojian Zhuang | 2afa62e | 2010-02-08 05:02:00 -0500 | [diff] [blame] | 553 | }; |
Haojian Zhuang | 5c42e8c | 2009-12-15 16:01:47 -0500 | [diff] [blame] | 554 | |
Haojian Zhuang | 837c829 | 2012-10-02 10:23:20 +0800 | [diff] [blame] | 555 | static int pm860x_irq_domain_map(struct irq_domain *d, unsigned int virq, |
| 556 | irq_hw_number_t hw) |
| 557 | { |
| 558 | irq_set_chip_data(virq, d->host_data); |
| 559 | irq_set_chip_and_handler(virq, &pm860x_irq_chip, handle_edge_irq); |
| 560 | irq_set_nested_thread(virq, 1); |
| 561 | #ifdef CONFIG_ARM |
| 562 | set_irq_flags(virq, IRQF_VALID); |
| 563 | #else |
| 564 | irq_set_noprobe(virq); |
| 565 | #endif |
| 566 | return 0; |
| 567 | } |
| 568 | |
Krzysztof Kozlowski | 7ce7b26 | 2015-04-27 21:54:13 +0900 | [diff] [blame] | 569 | static const struct irq_domain_ops pm860x_irq_domain_ops = { |
Haojian Zhuang | 837c829 | 2012-10-02 10:23:20 +0800 | [diff] [blame] | 570 | .map = pm860x_irq_domain_map, |
| 571 | .xlate = irq_domain_xlate_onetwocell, |
| 572 | }; |
| 573 | |
Bill Pemberton | f791be4 | 2012-11-19 13:23:04 -0500 | [diff] [blame] | 574 | static int device_irq_init(struct pm860x_chip *chip, |
Haojian Zhuang | 5c42e8c | 2009-12-15 16:01:47 -0500 | [diff] [blame] | 575 | struct pm860x_platform_data *pdata) |
| 576 | { |
Lee Jones | 2e57848 | 2014-05-08 12:28:37 +0100 | [diff] [blame] | 577 | struct i2c_client *i2c = (chip->id == CHIP_PM8607) ? |
| 578 | chip->client : chip->companion; |
Haojian Zhuang | 5c42e8c | 2009-12-15 16:01:47 -0500 | [diff] [blame] | 579 | unsigned char status_buf[INT_STATUS_NUM]; |
Haojian Zhuang | 2afa62e | 2010-02-08 05:02:00 -0500 | [diff] [blame] | 580 | unsigned long flags = IRQF_TRIGGER_FALLING | IRQF_ONESHOT; |
Haojian Zhuang | 837c829 | 2012-10-02 10:23:20 +0800 | [diff] [blame] | 581 | int data, mask, ret = -EINVAL; |
| 582 | int nr_irqs, irq_base = -1; |
| 583 | struct device_node *node = i2c->dev.of_node; |
Haojian Zhuang | 5c42e8c | 2009-12-15 16:01:47 -0500 | [diff] [blame] | 584 | |
| 585 | mask = PM8607_B0_MISC1_INV_INT | PM8607_B0_MISC1_INT_CLEAR |
| 586 | | PM8607_B0_MISC1_INT_MASK; |
| 587 | data = 0; |
| 588 | chip->irq_mode = 0; |
| 589 | if (pdata && pdata->irq_mode) { |
| 590 | /* |
| 591 | * irq_mode defines the way of clearing interrupt. If it's 1, |
| 592 | * clear IRQ by write. Otherwise, clear it by read. |
| 593 | * This control bit is valid from 88PM8607 B0 steping. |
| 594 | */ |
| 595 | data |= PM8607_B0_MISC1_INT_CLEAR; |
| 596 | chip->irq_mode = 1; |
| 597 | } |
| 598 | ret = pm860x_set_bits(i2c, PM8607_B0_MISC1, mask, data); |
| 599 | if (ret < 0) |
| 600 | goto out; |
| 601 | |
| 602 | /* mask all IRQs */ |
| 603 | memset(status_buf, 0, INT_STATUS_NUM); |
| 604 | ret = pm860x_bulk_write(i2c, PM8607_INT_MASK_1, |
| 605 | INT_STATUS_NUM, status_buf); |
| 606 | if (ret < 0) |
| 607 | goto out; |
| 608 | |
| 609 | if (chip->irq_mode) { |
| 610 | /* clear interrupt status by write */ |
| 611 | memset(status_buf, 0xFF, INT_STATUS_NUM); |
| 612 | ret = pm860x_bulk_write(i2c, PM8607_INT_STATUS1, |
| 613 | INT_STATUS_NUM, status_buf); |
| 614 | } else { |
| 615 | /* clear interrupt status by read */ |
| 616 | ret = pm860x_bulk_read(i2c, PM8607_INT_STATUS1, |
| 617 | INT_STATUS_NUM, status_buf); |
| 618 | } |
| 619 | if (ret < 0) |
| 620 | goto out; |
| 621 | |
Haojian Zhuang | 2afa62e | 2010-02-08 05:02:00 -0500 | [diff] [blame] | 622 | mutex_init(&chip->irq_lock); |
Haojian Zhuang | 837c829 | 2012-10-02 10:23:20 +0800 | [diff] [blame] | 623 | |
| 624 | if (pdata && pdata->irq_base) |
| 625 | irq_base = pdata->irq_base; |
| 626 | nr_irqs = ARRAY_SIZE(pm860x_irqs); |
| 627 | chip->irq_base = irq_alloc_descs(irq_base, 0, nr_irqs, 0); |
| 628 | if (chip->irq_base < 0) { |
| 629 | dev_err(&i2c->dev, "Failed to allocate interrupts, ret:%d\n", |
| 630 | chip->irq_base); |
| 631 | ret = -EBUSY; |
| 632 | goto out; |
| 633 | } |
| 634 | irq_domain_add_legacy(node, nr_irqs, chip->irq_base, 0, |
| 635 | &pm860x_irq_domain_ops, chip); |
Haojian Zhuang | 2afa62e | 2010-02-08 05:02:00 -0500 | [diff] [blame] | 636 | chip->core_irq = i2c->irq; |
| 637 | if (!chip->core_irq) |
Haojian Zhuang | 5c42e8c | 2009-12-15 16:01:47 -0500 | [diff] [blame] | 638 | goto out; |
Haojian Zhuang | 2afa62e | 2010-02-08 05:02:00 -0500 | [diff] [blame] | 639 | |
Lee Jones | 2e57848 | 2014-05-08 12:28:37 +0100 | [diff] [blame] | 640 | ret = request_threaded_irq(chip->core_irq, NULL, pm860x_irq, |
| 641 | flags | IRQF_ONESHOT, "88pm860x", chip); |
Haojian Zhuang | 2afa62e | 2010-02-08 05:02:00 -0500 | [diff] [blame] | 642 | if (ret) { |
| 643 | dev_err(chip->dev, "Failed to request IRQ: %d\n", ret); |
| 644 | chip->core_irq = 0; |
| 645 | } |
| 646 | |
Haojian Zhuang | 5c42e8c | 2009-12-15 16:01:47 -0500 | [diff] [blame] | 647 | return 0; |
| 648 | out: |
Haojian Zhuang | 2afa62e | 2010-02-08 05:02:00 -0500 | [diff] [blame] | 649 | chip->core_irq = 0; |
Haojian Zhuang | 5c42e8c | 2009-12-15 16:01:47 -0500 | [diff] [blame] | 650 | return ret; |
| 651 | } |
| 652 | |
Henrik Kretzschmar | 872c1b1 | 2010-03-26 02:40:13 +0100 | [diff] [blame] | 653 | static void device_irq_exit(struct pm860x_chip *chip) |
Haojian Zhuang | 5c42e8c | 2009-12-15 16:01:47 -0500 | [diff] [blame] | 654 | { |
Haojian Zhuang | 2afa62e | 2010-02-08 05:02:00 -0500 | [diff] [blame] | 655 | if (chip->core_irq) |
| 656 | free_irq(chip->core_irq, chip); |
Haojian Zhuang | 5c42e8c | 2009-12-15 16:01:47 -0500 | [diff] [blame] | 657 | } |
| 658 | |
Jett.Zhou | 23de435 | 2012-03-01 11:59:19 +0100 | [diff] [blame] | 659 | int pm8606_osc_enable(struct pm860x_chip *chip, unsigned short client) |
| 660 | { |
| 661 | int ret = -EIO; |
| 662 | struct i2c_client *i2c = (chip->id == CHIP_PM8606) ? |
| 663 | chip->client : chip->companion; |
| 664 | |
| 665 | dev_dbg(chip->dev, "%s(B): client=0x%x\n", __func__, client); |
| 666 | dev_dbg(chip->dev, "%s(B): vote=0x%x status=%d\n", |
| 667 | __func__, chip->osc_vote, |
| 668 | chip->osc_status); |
| 669 | |
| 670 | mutex_lock(&chip->osc_lock); |
| 671 | /* Update voting status */ |
| 672 | chip->osc_vote |= client; |
| 673 | /* If reference group is off - turn on*/ |
| 674 | if (chip->osc_status != PM8606_REF_GP_OSC_ON) { |
| 675 | chip->osc_status = PM8606_REF_GP_OSC_UNKNOWN; |
| 676 | /* Enable Reference group Vsys */ |
| 677 | if (pm860x_set_bits(i2c, PM8606_VSYS, |
| 678 | PM8606_VSYS_EN, PM8606_VSYS_EN)) |
| 679 | goto out; |
| 680 | |
| 681 | /*Enable Internal Oscillator */ |
| 682 | if (pm860x_set_bits(i2c, PM8606_MISC, |
| 683 | PM8606_MISC_OSC_EN, PM8606_MISC_OSC_EN)) |
| 684 | goto out; |
| 685 | /* Update status (only if writes succeed) */ |
| 686 | chip->osc_status = PM8606_REF_GP_OSC_ON; |
| 687 | } |
| 688 | mutex_unlock(&chip->osc_lock); |
| 689 | |
| 690 | dev_dbg(chip->dev, "%s(A): vote=0x%x status=%d ret=%d\n", |
| 691 | __func__, chip->osc_vote, |
| 692 | chip->osc_status, ret); |
| 693 | return 0; |
| 694 | out: |
| 695 | mutex_unlock(&chip->osc_lock); |
| 696 | return ret; |
| 697 | } |
Samuel Ortiz | 2f5f89b | 2012-03-06 08:06:14 +0100 | [diff] [blame] | 698 | EXPORT_SYMBOL(pm8606_osc_enable); |
Jett.Zhou | 23de435 | 2012-03-01 11:59:19 +0100 | [diff] [blame] | 699 | |
| 700 | int pm8606_osc_disable(struct pm860x_chip *chip, unsigned short client) |
| 701 | { |
| 702 | int ret = -EIO; |
| 703 | struct i2c_client *i2c = (chip->id == CHIP_PM8606) ? |
| 704 | chip->client : chip->companion; |
| 705 | |
| 706 | dev_dbg(chip->dev, "%s(B): client=0x%x\n", __func__, client); |
| 707 | dev_dbg(chip->dev, "%s(B): vote=0x%x status=%d\n", |
| 708 | __func__, chip->osc_vote, |
| 709 | chip->osc_status); |
| 710 | |
| 711 | mutex_lock(&chip->osc_lock); |
| 712 | /*Update voting status */ |
| 713 | chip->osc_vote &= ~(client); |
| 714 | /* If reference group is off and this is the last client to release |
| 715 | * - turn off */ |
| 716 | if ((chip->osc_status != PM8606_REF_GP_OSC_OFF) && |
| 717 | (chip->osc_vote == REF_GP_NO_CLIENTS)) { |
| 718 | chip->osc_status = PM8606_REF_GP_OSC_UNKNOWN; |
| 719 | /* Disable Reference group Vsys */ |
| 720 | if (pm860x_set_bits(i2c, PM8606_VSYS, PM8606_VSYS_EN, 0)) |
| 721 | goto out; |
| 722 | /* Disable Internal Oscillator */ |
| 723 | if (pm860x_set_bits(i2c, PM8606_MISC, PM8606_MISC_OSC_EN, 0)) |
| 724 | goto out; |
| 725 | chip->osc_status = PM8606_REF_GP_OSC_OFF; |
| 726 | } |
| 727 | mutex_unlock(&chip->osc_lock); |
| 728 | |
| 729 | dev_dbg(chip->dev, "%s(A): vote=0x%x status=%d ret=%d\n", |
| 730 | __func__, chip->osc_vote, |
| 731 | chip->osc_status, ret); |
| 732 | return 0; |
| 733 | out: |
| 734 | mutex_unlock(&chip->osc_lock); |
| 735 | return ret; |
| 736 | } |
Samuel Ortiz | 2f5f89b | 2012-03-06 08:06:14 +0100 | [diff] [blame] | 737 | EXPORT_SYMBOL(pm8606_osc_disable); |
Jett.Zhou | 23de435 | 2012-03-01 11:59:19 +0100 | [diff] [blame] | 738 | |
Bill Pemberton | f791be4 | 2012-11-19 13:23:04 -0500 | [diff] [blame] | 739 | static void device_osc_init(struct i2c_client *i2c) |
Jett.Zhou | 23de435 | 2012-03-01 11:59:19 +0100 | [diff] [blame] | 740 | { |
| 741 | struct pm860x_chip *chip = i2c_get_clientdata(i2c); |
| 742 | |
| 743 | mutex_init(&chip->osc_lock); |
| 744 | /* init portofino reference group voting and status */ |
| 745 | /* Disable Reference group Vsys */ |
| 746 | pm860x_set_bits(i2c, PM8606_VSYS, PM8606_VSYS_EN, 0); |
| 747 | /* Disable Internal Oscillator */ |
| 748 | pm860x_set_bits(i2c, PM8606_MISC, PM8606_MISC_OSC_EN, 0); |
| 749 | |
| 750 | chip->osc_vote = REF_GP_NO_CLIENTS; |
| 751 | chip->osc_status = PM8606_REF_GP_OSC_OFF; |
| 752 | } |
| 753 | |
Bill Pemberton | f791be4 | 2012-11-19 13:23:04 -0500 | [diff] [blame] | 754 | static void device_bk_init(struct pm860x_chip *chip, |
Haojian Zhuang | adb7048 | 2011-03-07 23:43:09 +0800 | [diff] [blame] | 755 | struct pm860x_platform_data *pdata) |
| 756 | { |
Haojian Zhuang | a6ccdcd | 2012-08-08 23:17:26 +0800 | [diff] [blame] | 757 | int ret, i; |
Haojian Zhuang | adb7048 | 2011-03-07 23:43:09 +0800 | [diff] [blame] | 758 | |
Haojian Zhuang | a6ccdcd | 2012-08-08 23:17:26 +0800 | [diff] [blame] | 759 | if (pdata && pdata->backlight) { |
| 760 | if (pdata->num_backlights > ARRAY_SIZE(bk_devs)) |
| 761 | pdata->num_backlights = ARRAY_SIZE(bk_devs); |
| 762 | for (i = 0; i < pdata->num_backlights; i++) { |
| 763 | bk_devs[i].platform_data = &pdata->backlight[i]; |
| 764 | bk_devs[i].pdata_size = |
| 765 | sizeof(struct pm860x_backlight_pdata); |
Haojian Zhuang | adb7048 | 2011-03-07 23:43:09 +0800 | [diff] [blame] | 766 | } |
| 767 | } |
Haojian Zhuang | a6ccdcd | 2012-08-08 23:17:26 +0800 | [diff] [blame] | 768 | ret = mfd_add_devices(chip->dev, 0, bk_devs, |
Mark Brown | 55692af | 2012-09-11 15:16:36 +0800 | [diff] [blame] | 769 | ARRAY_SIZE(bk_devs), NULL, 0, NULL); |
Haojian Zhuang | a6ccdcd | 2012-08-08 23:17:26 +0800 | [diff] [blame] | 770 | if (ret < 0) |
| 771 | dev_err(chip->dev, "Failed to add backlight subdev\n"); |
Haojian Zhuang | adb7048 | 2011-03-07 23:43:09 +0800 | [diff] [blame] | 772 | } |
| 773 | |
Bill Pemberton | f791be4 | 2012-11-19 13:23:04 -0500 | [diff] [blame] | 774 | static void device_led_init(struct pm860x_chip *chip, |
Haojian Zhuang | 3154c34 | 2011-03-07 23:43:10 +0800 | [diff] [blame] | 775 | struct pm860x_platform_data *pdata) |
Haojian Zhuang | 53dbab7 | 2010-01-08 06:01:24 -0500 | [diff] [blame] | 776 | { |
Haojian Zhuang | 894fc8f | 2012-08-08 23:17:27 +0800 | [diff] [blame] | 777 | int ret, i; |
Haojian Zhuang | a16122b | 2009-12-15 16:04:36 -0500 | [diff] [blame] | 778 | |
Haojian Zhuang | 894fc8f | 2012-08-08 23:17:27 +0800 | [diff] [blame] | 779 | if (pdata && pdata->led) { |
| 780 | if (pdata->num_leds > ARRAY_SIZE(led_devs)) |
| 781 | pdata->num_leds = ARRAY_SIZE(led_devs); |
| 782 | for (i = 0; i < pdata->num_leds; i++) { |
| 783 | led_devs[i].platform_data = &pdata->led[i]; |
| 784 | led_devs[i].pdata_size = |
| 785 | sizeof(struct pm860x_led_pdata); |
Haojian Zhuang | a16122b | 2009-12-15 16:04:36 -0500 | [diff] [blame] | 786 | } |
| 787 | } |
Haojian Zhuang | 894fc8f | 2012-08-08 23:17:27 +0800 | [diff] [blame] | 788 | ret = mfd_add_devices(chip->dev, 0, led_devs, |
Mark Brown | 55692af | 2012-09-11 15:16:36 +0800 | [diff] [blame] | 789 | ARRAY_SIZE(led_devs), NULL, 0, NULL); |
Haojian Zhuang | 894fc8f | 2012-08-08 23:17:27 +0800 | [diff] [blame] | 790 | if (ret < 0) { |
| 791 | dev_err(chip->dev, "Failed to add led subdev\n"); |
| 792 | return; |
| 793 | } |
Haojian Zhuang | 53dbab7 | 2010-01-08 06:01:24 -0500 | [diff] [blame] | 794 | } |
| 795 | |
Bill Pemberton | f791be4 | 2012-11-19 13:23:04 -0500 | [diff] [blame] | 796 | static void device_regulator_init(struct pm860x_chip *chip, |
Haojian Zhuang | 22aad00 | 2011-03-07 23:43:11 +0800 | [diff] [blame] | 797 | struct pm860x_platform_data *pdata) |
| 798 | { |
Haojian Zhuang | 22aad00 | 2011-03-07 23:43:11 +0800 | [diff] [blame] | 799 | int ret; |
Haojian Zhuang | 22aad00 | 2011-03-07 23:43:11 +0800 | [diff] [blame] | 800 | |
Haojian Zhuang | a70abac | 2012-08-08 23:17:28 +0800 | [diff] [blame] | 801 | if (pdata == NULL) |
Haojian Zhuang | 22aad00 | 2011-03-07 23:43:11 +0800 | [diff] [blame] | 802 | return; |
Haojian Zhuang | a70abac | 2012-08-08 23:17:28 +0800 | [diff] [blame] | 803 | if (pdata->buck1) { |
| 804 | reg_devs[0].platform_data = pdata->buck1; |
| 805 | reg_devs[0].pdata_size = sizeof(struct regulator_init_data); |
Haojian Zhuang | 22aad00 | 2011-03-07 23:43:11 +0800 | [diff] [blame] | 806 | } |
Haojian Zhuang | a70abac | 2012-08-08 23:17:28 +0800 | [diff] [blame] | 807 | if (pdata->buck2) { |
| 808 | reg_devs[1].platform_data = pdata->buck2; |
| 809 | reg_devs[1].pdata_size = sizeof(struct regulator_init_data); |
| 810 | } |
| 811 | if (pdata->buck3) { |
| 812 | reg_devs[2].platform_data = pdata->buck3; |
| 813 | reg_devs[2].pdata_size = sizeof(struct regulator_init_data); |
| 814 | } |
| 815 | if (pdata->ldo1) { |
| 816 | reg_devs[3].platform_data = pdata->ldo1; |
| 817 | reg_devs[3].pdata_size = sizeof(struct regulator_init_data); |
| 818 | } |
| 819 | if (pdata->ldo2) { |
| 820 | reg_devs[4].platform_data = pdata->ldo2; |
| 821 | reg_devs[4].pdata_size = sizeof(struct regulator_init_data); |
| 822 | } |
| 823 | if (pdata->ldo3) { |
| 824 | reg_devs[5].platform_data = pdata->ldo3; |
| 825 | reg_devs[5].pdata_size = sizeof(struct regulator_init_data); |
| 826 | } |
| 827 | if (pdata->ldo4) { |
| 828 | reg_devs[6].platform_data = pdata->ldo4; |
| 829 | reg_devs[6].pdata_size = sizeof(struct regulator_init_data); |
| 830 | } |
| 831 | if (pdata->ldo5) { |
| 832 | reg_devs[7].platform_data = pdata->ldo5; |
| 833 | reg_devs[7].pdata_size = sizeof(struct regulator_init_data); |
| 834 | } |
| 835 | if (pdata->ldo6) { |
| 836 | reg_devs[8].platform_data = pdata->ldo6; |
| 837 | reg_devs[8].pdata_size = sizeof(struct regulator_init_data); |
| 838 | } |
| 839 | if (pdata->ldo7) { |
| 840 | reg_devs[9].platform_data = pdata->ldo7; |
| 841 | reg_devs[9].pdata_size = sizeof(struct regulator_init_data); |
| 842 | } |
| 843 | if (pdata->ldo8) { |
| 844 | reg_devs[10].platform_data = pdata->ldo8; |
| 845 | reg_devs[10].pdata_size = sizeof(struct regulator_init_data); |
| 846 | } |
| 847 | if (pdata->ldo9) { |
| 848 | reg_devs[11].platform_data = pdata->ldo9; |
| 849 | reg_devs[11].pdata_size = sizeof(struct regulator_init_data); |
| 850 | } |
| 851 | if (pdata->ldo10) { |
| 852 | reg_devs[12].platform_data = pdata->ldo10; |
| 853 | reg_devs[12].pdata_size = sizeof(struct regulator_init_data); |
| 854 | } |
| 855 | if (pdata->ldo12) { |
| 856 | reg_devs[13].platform_data = pdata->ldo12; |
| 857 | reg_devs[13].pdata_size = sizeof(struct regulator_init_data); |
| 858 | } |
| 859 | if (pdata->ldo_vibrator) { |
| 860 | reg_devs[14].platform_data = pdata->ldo_vibrator; |
| 861 | reg_devs[14].pdata_size = sizeof(struct regulator_init_data); |
| 862 | } |
| 863 | if (pdata->ldo14) { |
| 864 | reg_devs[15].platform_data = pdata->ldo14; |
| 865 | reg_devs[15].pdata_size = sizeof(struct regulator_init_data); |
| 866 | } |
| 867 | ret = mfd_add_devices(chip->dev, 0, reg_devs, |
Mark Brown | 55692af | 2012-09-11 15:16:36 +0800 | [diff] [blame] | 868 | ARRAY_SIZE(reg_devs), NULL, 0, NULL); |
Haojian Zhuang | a70abac | 2012-08-08 23:17:28 +0800 | [diff] [blame] | 869 | if (ret < 0) { |
| 870 | dev_err(chip->dev, "Failed to add regulator subdev\n"); |
| 871 | return; |
| 872 | } |
Haojian Zhuang | 22aad00 | 2011-03-07 23:43:11 +0800 | [diff] [blame] | 873 | } |
| 874 | |
Bill Pemberton | f791be4 | 2012-11-19 13:23:04 -0500 | [diff] [blame] | 875 | static void device_rtc_init(struct pm860x_chip *chip, |
Haojian Zhuang | 008b304 | 2011-05-06 17:21:20 +0800 | [diff] [blame] | 876 | struct pm860x_platform_data *pdata) |
| 877 | { |
| 878 | int ret; |
| 879 | |
Lee Jones | 2e57848 | 2014-05-08 12:28:37 +0100 | [diff] [blame] | 880 | if (!pdata) |
Haojian Zhuang | 008b304 | 2011-05-06 17:21:20 +0800 | [diff] [blame] | 881 | return; |
| 882 | |
| 883 | rtc_devs[0].platform_data = pdata->rtc; |
| 884 | rtc_devs[0].pdata_size = sizeof(struct pm860x_rtc_pdata); |
| 885 | rtc_devs[0].num_resources = ARRAY_SIZE(rtc_resources); |
| 886 | rtc_devs[0].resources = &rtc_resources[0]; |
| 887 | ret = mfd_add_devices(chip->dev, 0, &rtc_devs[0], |
| 888 | ARRAY_SIZE(rtc_devs), &rtc_resources[0], |
Mark Brown | 55692af | 2012-09-11 15:16:36 +0800 | [diff] [blame] | 889 | chip->irq_base, NULL); |
Haojian Zhuang | 008b304 | 2011-05-06 17:21:20 +0800 | [diff] [blame] | 890 | if (ret < 0) |
| 891 | dev_err(chip->dev, "Failed to add rtc subdev\n"); |
| 892 | } |
| 893 | |
Bill Pemberton | f791be4 | 2012-11-19 13:23:04 -0500 | [diff] [blame] | 894 | static void device_touch_init(struct pm860x_chip *chip, |
Haojian Zhuang | c9f560b | 2011-03-07 23:43:12 +0800 | [diff] [blame] | 895 | struct pm860x_platform_data *pdata) |
| 896 | { |
| 897 | int ret; |
| 898 | |
Haojian Zhuang | f5fb758 | 2011-05-06 17:21:21 +0800 | [diff] [blame] | 899 | if (pdata == NULL) |
Haojian Zhuang | c9f560b | 2011-03-07 23:43:12 +0800 | [diff] [blame] | 900 | return; |
| 901 | |
Haojian Zhuang | f5fb758 | 2011-05-06 17:21:21 +0800 | [diff] [blame] | 902 | touch_devs[0].platform_data = pdata->touch; |
| 903 | touch_devs[0].pdata_size = sizeof(struct pm860x_touch_pdata); |
Haojian Zhuang | c9f560b | 2011-03-07 23:43:12 +0800 | [diff] [blame] | 904 | touch_devs[0].num_resources = ARRAY_SIZE(touch_resources); |
| 905 | touch_devs[0].resources = &touch_resources[0]; |
| 906 | ret = mfd_add_devices(chip->dev, 0, &touch_devs[0], |
| 907 | ARRAY_SIZE(touch_devs), &touch_resources[0], |
Mark Brown | 55692af | 2012-09-11 15:16:36 +0800 | [diff] [blame] | 908 | chip->irq_base, NULL); |
Haojian Zhuang | c9f560b | 2011-03-07 23:43:12 +0800 | [diff] [blame] | 909 | if (ret < 0) |
| 910 | dev_err(chip->dev, "Failed to add touch subdev\n"); |
| 911 | } |
| 912 | |
Bill Pemberton | f791be4 | 2012-11-19 13:23:04 -0500 | [diff] [blame] | 913 | static void device_power_init(struct pm860x_chip *chip, |
Haojian Zhuang | c9f560b | 2011-03-07 23:43:12 +0800 | [diff] [blame] | 914 | struct pm860x_platform_data *pdata) |
| 915 | { |
| 916 | int ret; |
| 917 | |
Haojian Zhuang | f5fb758 | 2011-05-06 17:21:21 +0800 | [diff] [blame] | 918 | if (pdata == NULL) |
Haojian Zhuang | c9f560b | 2011-03-07 23:43:12 +0800 | [diff] [blame] | 919 | return; |
| 920 | |
Haojian Zhuang | f5fb758 | 2011-05-06 17:21:21 +0800 | [diff] [blame] | 921 | power_devs[0].platform_data = pdata->power; |
| 922 | power_devs[0].pdata_size = sizeof(struct pm860x_power_pdata); |
Haojian Zhuang | c9f560b | 2011-03-07 23:43:12 +0800 | [diff] [blame] | 923 | power_devs[0].num_resources = ARRAY_SIZE(battery_resources); |
| 924 | power_devs[0].resources = &battery_resources[0], |
| 925 | ret = mfd_add_devices(chip->dev, 0, &power_devs[0], 1, |
Mark Brown | 55692af | 2012-09-11 15:16:36 +0800 | [diff] [blame] | 926 | &battery_resources[0], chip->irq_base, NULL); |
Haojian Zhuang | c9f560b | 2011-03-07 23:43:12 +0800 | [diff] [blame] | 927 | if (ret < 0) |
| 928 | dev_err(chip->dev, "Failed to add battery subdev\n"); |
| 929 | |
Haojian Zhuang | f5fb758 | 2011-05-06 17:21:21 +0800 | [diff] [blame] | 930 | power_devs[1].platform_data = pdata->power; |
| 931 | power_devs[1].pdata_size = sizeof(struct pm860x_power_pdata); |
Haojian Zhuang | c9f560b | 2011-03-07 23:43:12 +0800 | [diff] [blame] | 932 | power_devs[1].num_resources = ARRAY_SIZE(charger_resources); |
| 933 | power_devs[1].resources = &charger_resources[0], |
| 934 | ret = mfd_add_devices(chip->dev, 0, &power_devs[1], 1, |
Mark Brown | 55692af | 2012-09-11 15:16:36 +0800 | [diff] [blame] | 935 | &charger_resources[0], chip->irq_base, NULL); |
Haojian Zhuang | c9f560b | 2011-03-07 23:43:12 +0800 | [diff] [blame] | 936 | if (ret < 0) |
| 937 | dev_err(chip->dev, "Failed to add charger subdev\n"); |
Jett.Zhou | 2573f6d | 2012-07-06 10:59:58 +0800 | [diff] [blame] | 938 | |
| 939 | power_devs[2].platform_data = &preg_init_data; |
| 940 | power_devs[2].pdata_size = sizeof(struct regulator_init_data); |
Jett.Zhou | 2573f6d | 2012-07-06 10:59:58 +0800 | [diff] [blame] | 941 | ret = mfd_add_devices(chip->dev, 0, &power_devs[2], 1, |
Haojian Zhuang | ff13e9e | 2012-09-17 12:19:07 +0800 | [diff] [blame] | 942 | NULL, chip->irq_base, NULL); |
Jett.Zhou | 2573f6d | 2012-07-06 10:59:58 +0800 | [diff] [blame] | 943 | if (ret < 0) |
| 944 | dev_err(chip->dev, "Failed to add preg subdev\n"); |
Jett.Zhou | a830d28 | 2012-07-27 16:27:16 +0800 | [diff] [blame] | 945 | |
| 946 | if (pdata->chg_desc) { |
| 947 | pdata->chg_desc->charger_regulators = |
| 948 | &chg_desc_regulator_data[0]; |
| 949 | pdata->chg_desc->num_charger_regulators = |
| 950 | ARRAY_SIZE(chg_desc_regulator_data), |
| 951 | power_devs[3].platform_data = pdata->chg_desc; |
| 952 | power_devs[3].pdata_size = sizeof(*pdata->chg_desc); |
| 953 | ret = mfd_add_devices(chip->dev, 0, &power_devs[3], 1, |
Anton Vorontsov | 18766f0 | 2012-09-24 19:10:08 -0700 | [diff] [blame] | 954 | NULL, chip->irq_base, NULL); |
Jett.Zhou | a830d28 | 2012-07-27 16:27:16 +0800 | [diff] [blame] | 955 | if (ret < 0) |
| 956 | dev_err(chip->dev, "Failed to add chg-manager subdev\n"); |
| 957 | } |
Haojian Zhuang | c9f560b | 2011-03-07 23:43:12 +0800 | [diff] [blame] | 958 | } |
| 959 | |
Bill Pemberton | f791be4 | 2012-11-19 13:23:04 -0500 | [diff] [blame] | 960 | static void device_onkey_init(struct pm860x_chip *chip, |
Haojian Zhuang | c9f560b | 2011-03-07 23:43:12 +0800 | [diff] [blame] | 961 | struct pm860x_platform_data *pdata) |
| 962 | { |
| 963 | int ret; |
| 964 | |
| 965 | onkey_devs[0].num_resources = ARRAY_SIZE(onkey_resources); |
| 966 | onkey_devs[0].resources = &onkey_resources[0], |
| 967 | ret = mfd_add_devices(chip->dev, 0, &onkey_devs[0], |
| 968 | ARRAY_SIZE(onkey_devs), &onkey_resources[0], |
Mark Brown | 55692af | 2012-09-11 15:16:36 +0800 | [diff] [blame] | 969 | chip->irq_base, NULL); |
Haojian Zhuang | c9f560b | 2011-03-07 23:43:12 +0800 | [diff] [blame] | 970 | if (ret < 0) |
| 971 | dev_err(chip->dev, "Failed to add onkey subdev\n"); |
| 972 | } |
| 973 | |
Bill Pemberton | f791be4 | 2012-11-19 13:23:04 -0500 | [diff] [blame] | 974 | static void device_codec_init(struct pm860x_chip *chip, |
Haojian Zhuang | c9f560b | 2011-03-07 23:43:12 +0800 | [diff] [blame] | 975 | struct pm860x_platform_data *pdata) |
| 976 | { |
| 977 | int ret; |
| 978 | |
| 979 | codec_devs[0].num_resources = ARRAY_SIZE(codec_resources); |
| 980 | codec_devs[0].resources = &codec_resources[0], |
| 981 | ret = mfd_add_devices(chip->dev, 0, &codec_devs[0], |
Mark Brown | 55692af | 2012-09-11 15:16:36 +0800 | [diff] [blame] | 982 | ARRAY_SIZE(codec_devs), &codec_resources[0], 0, |
| 983 | NULL); |
Haojian Zhuang | c9f560b | 2011-03-07 23:43:12 +0800 | [diff] [blame] | 984 | if (ret < 0) |
| 985 | dev_err(chip->dev, "Failed to add codec subdev\n"); |
| 986 | } |
| 987 | |
Bill Pemberton | f791be4 | 2012-11-19 13:23:04 -0500 | [diff] [blame] | 988 | static void device_8607_init(struct pm860x_chip *chip, |
Haojian Zhuang | 5c42e8c | 2009-12-15 16:01:47 -0500 | [diff] [blame] | 989 | struct i2c_client *i2c, |
| 990 | struct pm860x_platform_data *pdata) |
Haojian Zhuang | bbd51b1 | 2010-01-06 17:04:18 -0500 | [diff] [blame] | 991 | { |
Haojian Zhuang | a16122b | 2009-12-15 16:04:36 -0500 | [diff] [blame] | 992 | int data, ret; |
Haojian Zhuang | bbd51b1 | 2010-01-06 17:04:18 -0500 | [diff] [blame] | 993 | |
Haojian Zhuang | 53dbab7 | 2010-01-08 06:01:24 -0500 | [diff] [blame] | 994 | ret = pm860x_reg_read(i2c, PM8607_CHIP_ID); |
Haojian Zhuang | bbd51b1 | 2010-01-06 17:04:18 -0500 | [diff] [blame] | 995 | if (ret < 0) { |
| 996 | dev_err(chip->dev, "Failed to read CHIP ID: %d\n", ret); |
| 997 | goto out; |
| 998 | } |
Haojian Zhuang | 38b34052 | 2010-09-08 09:44:34 -0400 | [diff] [blame] | 999 | switch (ret & PM8607_VERSION_MASK) { |
| 1000 | case 0x40: |
| 1001 | case 0x50: |
Haojian Zhuang | bbd51b1 | 2010-01-06 17:04:18 -0500 | [diff] [blame] | 1002 | dev_info(chip->dev, "Marvell 88PM8607 (ID: %02x) detected\n", |
| 1003 | ret); |
Haojian Zhuang | 38b34052 | 2010-09-08 09:44:34 -0400 | [diff] [blame] | 1004 | break; |
| 1005 | default: |
Lee Jones | 2e57848 | 2014-05-08 12:28:37 +0100 | [diff] [blame] | 1006 | dev_err(chip->dev, |
| 1007 | "Failed to detect Marvell 88PM8607. Chip ID: %02x\n", |
| 1008 | ret); |
Haojian Zhuang | bbd51b1 | 2010-01-06 17:04:18 -0500 | [diff] [blame] | 1009 | goto out; |
| 1010 | } |
Haojian Zhuang | bbd51b1 | 2010-01-06 17:04:18 -0500 | [diff] [blame] | 1011 | |
Haojian Zhuang | 53dbab7 | 2010-01-08 06:01:24 -0500 | [diff] [blame] | 1012 | ret = pm860x_reg_read(i2c, PM8607_BUCK3); |
Haojian Zhuang | bbd51b1 | 2010-01-06 17:04:18 -0500 | [diff] [blame] | 1013 | if (ret < 0) { |
| 1014 | dev_err(chip->dev, "Failed to read BUCK3 register: %d\n", ret); |
| 1015 | goto out; |
| 1016 | } |
| 1017 | if (ret & PM8607_BUCK3_DOUBLE) |
| 1018 | chip->buck3_double = 1; |
| 1019 | |
Haojian Zhuang | 5c42e8c | 2009-12-15 16:01:47 -0500 | [diff] [blame] | 1020 | ret = pm860x_reg_read(i2c, PM8607_B0_MISC1); |
Haojian Zhuang | bbd51b1 | 2010-01-06 17:04:18 -0500 | [diff] [blame] | 1021 | if (ret < 0) { |
| 1022 | dev_err(chip->dev, "Failed to read MISC1 register: %d\n", ret); |
| 1023 | goto out; |
| 1024 | } |
Haojian Zhuang | bbd51b1 | 2010-01-06 17:04:18 -0500 | [diff] [blame] | 1025 | |
Haojian Zhuang | 5c42e8c | 2009-12-15 16:01:47 -0500 | [diff] [blame] | 1026 | if (pdata && (pdata->i2c_port == PI2C_PORT)) |
| 1027 | data = PM8607_B0_MISC1_PI2C; |
| 1028 | else |
| 1029 | data = 0; |
| 1030 | ret = pm860x_set_bits(i2c, PM8607_B0_MISC1, PM8607_B0_MISC1_PI2C, data); |
| 1031 | if (ret < 0) { |
| 1032 | dev_err(chip->dev, "Failed to access MISC1:%d\n", ret); |
| 1033 | goto out; |
| 1034 | } |
| 1035 | |
| 1036 | ret = device_irq_init(chip, pdata); |
| 1037 | if (ret < 0) |
| 1038 | goto out; |
| 1039 | |
Haojian Zhuang | cea438d | 2011-05-06 17:21:24 +0800 | [diff] [blame] | 1040 | device_regulator_init(chip, pdata); |
| 1041 | device_rtc_init(chip, pdata); |
| 1042 | device_onkey_init(chip, pdata); |
| 1043 | device_touch_init(chip, pdata); |
| 1044 | device_power_init(chip, pdata); |
| 1045 | device_codec_init(chip, pdata); |
Haojian Zhuang | bbd51b1 | 2010-01-06 17:04:18 -0500 | [diff] [blame] | 1046 | out: |
Haojian Zhuang | 53dbab7 | 2010-01-08 06:01:24 -0500 | [diff] [blame] | 1047 | return; |
Haojian Zhuang | bbd51b1 | 2010-01-06 17:04:18 -0500 | [diff] [blame] | 1048 | } |
| 1049 | |
Bill Pemberton | f791be4 | 2012-11-19 13:23:04 -0500 | [diff] [blame] | 1050 | static void device_8606_init(struct pm860x_chip *chip, |
Jett.Zhou | 7825806 | 2012-02-28 10:58:42 +0800 | [diff] [blame] | 1051 | struct i2c_client *i2c, |
| 1052 | struct pm860x_platform_data *pdata) |
| 1053 | { |
| 1054 | device_osc_init(i2c); |
| 1055 | device_bk_init(chip, pdata); |
| 1056 | device_led_init(chip, pdata); |
| 1057 | } |
| 1058 | |
Bill Pemberton | f791be4 | 2012-11-19 13:23:04 -0500 | [diff] [blame] | 1059 | static int pm860x_device_init(struct pm860x_chip *chip, |
Haojian Zhuang | f2f218c | 2012-09-17 12:19:08 +0800 | [diff] [blame] | 1060 | struct pm860x_platform_data *pdata) |
Haojian Zhuang | 53dbab7 | 2010-01-08 06:01:24 -0500 | [diff] [blame] | 1061 | { |
Haojian Zhuang | 2afa62e | 2010-02-08 05:02:00 -0500 | [diff] [blame] | 1062 | chip->core_irq = 0; |
Haojian Zhuang | 5c42e8c | 2009-12-15 16:01:47 -0500 | [diff] [blame] | 1063 | |
Haojian Zhuang | 53dbab7 | 2010-01-08 06:01:24 -0500 | [diff] [blame] | 1064 | switch (chip->id) { |
| 1065 | case CHIP_PM8606: |
Jett.Zhou | 7825806 | 2012-02-28 10:58:42 +0800 | [diff] [blame] | 1066 | device_8606_init(chip, chip->client, pdata); |
Haojian Zhuang | 53dbab7 | 2010-01-08 06:01:24 -0500 | [diff] [blame] | 1067 | break; |
| 1068 | case CHIP_PM8607: |
| 1069 | device_8607_init(chip, chip->client, pdata); |
| 1070 | break; |
| 1071 | } |
| 1072 | |
| 1073 | if (chip->companion) { |
| 1074 | switch (chip->id) { |
| 1075 | case CHIP_PM8607: |
Jett.Zhou | 7825806 | 2012-02-28 10:58:42 +0800 | [diff] [blame] | 1076 | device_8606_init(chip, chip->companion, pdata); |
Haojian Zhuang | 53dbab7 | 2010-01-08 06:01:24 -0500 | [diff] [blame] | 1077 | break; |
| 1078 | case CHIP_PM8606: |
| 1079 | device_8607_init(chip, chip->companion, pdata); |
| 1080 | break; |
| 1081 | } |
| 1082 | } |
Haojian Zhuang | 5c42e8c | 2009-12-15 16:01:47 -0500 | [diff] [blame] | 1083 | |
Haojian Zhuang | 53dbab7 | 2010-01-08 06:01:24 -0500 | [diff] [blame] | 1084 | return 0; |
| 1085 | } |
| 1086 | |
Bill Pemberton | 4740f73 | 2012-11-19 13:26:01 -0500 | [diff] [blame] | 1087 | static void pm860x_device_exit(struct pm860x_chip *chip) |
Haojian Zhuang | bbd51b1 | 2010-01-06 17:04:18 -0500 | [diff] [blame] | 1088 | { |
Haojian Zhuang | 5c42e8c | 2009-12-15 16:01:47 -0500 | [diff] [blame] | 1089 | device_irq_exit(chip); |
Haojian Zhuang | bbd51b1 | 2010-01-06 17:04:18 -0500 | [diff] [blame] | 1090 | mfd_remove_devices(chip->dev); |
| 1091 | } |
| 1092 | |
Haojian Zhuang | f2f218c | 2012-09-17 12:19:08 +0800 | [diff] [blame] | 1093 | static int verify_addr(struct i2c_client *i2c) |
| 1094 | { |
| 1095 | unsigned short addr_8607[] = {0x30, 0x34}; |
| 1096 | unsigned short addr_8606[] = {0x10, 0x11}; |
| 1097 | int size, i; |
| 1098 | |
| 1099 | if (i2c == NULL) |
| 1100 | return 0; |
| 1101 | size = ARRAY_SIZE(addr_8606); |
| 1102 | for (i = 0; i < size; i++) { |
| 1103 | if (i2c->addr == *(addr_8606 + i)) |
| 1104 | return CHIP_PM8606; |
| 1105 | } |
| 1106 | size = ARRAY_SIZE(addr_8607); |
| 1107 | for (i = 0; i < size; i++) { |
| 1108 | if (i2c->addr == *(addr_8607 + i)) |
| 1109 | return CHIP_PM8607; |
| 1110 | } |
| 1111 | return 0; |
| 1112 | } |
| 1113 | |
Krzysztof Kozlowski | 8da90cc | 2015-01-05 10:01:20 +0100 | [diff] [blame] | 1114 | static const struct regmap_config pm860x_regmap_config = { |
Haojian Zhuang | f2f218c | 2012-09-17 12:19:08 +0800 | [diff] [blame] | 1115 | .reg_bits = 8, |
| 1116 | .val_bits = 8, |
| 1117 | }; |
| 1118 | |
Bill Pemberton | f791be4 | 2012-11-19 13:23:04 -0500 | [diff] [blame] | 1119 | static int pm860x_dt_init(struct device_node *np, |
Haojian Zhuang | 2e57d56 | 2012-09-21 18:06:52 +0800 | [diff] [blame] | 1120 | struct device *dev, |
| 1121 | struct pm860x_platform_data *pdata) |
| 1122 | { |
| 1123 | int ret; |
| 1124 | |
| 1125 | if (of_get_property(np, "marvell,88pm860x-irq-read-clr", NULL)) |
| 1126 | pdata->irq_mode = 1; |
| 1127 | ret = of_property_read_u32(np, "marvell,88pm860x-slave-addr", |
| 1128 | &pdata->companion_addr); |
| 1129 | if (ret) { |
Lee Jones | 2e57848 | 2014-05-08 12:28:37 +0100 | [diff] [blame] | 1130 | dev_err(dev, |
| 1131 | "Not found \"marvell,88pm860x-slave-addr\" property\n"); |
Haojian Zhuang | 2e57d56 | 2012-09-21 18:06:52 +0800 | [diff] [blame] | 1132 | pdata->companion_addr = 0; |
| 1133 | } |
| 1134 | return 0; |
| 1135 | } |
| 1136 | |
Bill Pemberton | f791be4 | 2012-11-19 13:23:04 -0500 | [diff] [blame] | 1137 | static int pm860x_probe(struct i2c_client *client, |
Haojian Zhuang | f2f218c | 2012-09-17 12:19:08 +0800 | [diff] [blame] | 1138 | const struct i2c_device_id *id) |
| 1139 | { |
Jingoo Han | 334a41c | 2013-07-30 17:10:05 +0900 | [diff] [blame] | 1140 | struct pm860x_platform_data *pdata = dev_get_platdata(&client->dev); |
Haojian Zhuang | 2e57d56 | 2012-09-21 18:06:52 +0800 | [diff] [blame] | 1141 | struct device_node *node = client->dev.of_node; |
Haojian Zhuang | f2f218c | 2012-09-17 12:19:08 +0800 | [diff] [blame] | 1142 | struct pm860x_chip *chip; |
| 1143 | int ret; |
| 1144 | |
Haojian Zhuang | 2e57d56 | 2012-09-21 18:06:52 +0800 | [diff] [blame] | 1145 | if (node && !pdata) { |
| 1146 | /* parse DT to get platform data */ |
| 1147 | pdata = devm_kzalloc(&client->dev, |
| 1148 | sizeof(struct pm860x_platform_data), |
| 1149 | GFP_KERNEL); |
| 1150 | if (!pdata) |
| 1151 | return -ENOMEM; |
| 1152 | ret = pm860x_dt_init(node, &client->dev, pdata); |
| 1153 | if (ret) |
Jingoo Han | 8552957 | 2013-02-20 18:27:21 +0900 | [diff] [blame] | 1154 | return ret; |
Haojian Zhuang | 2e57d56 | 2012-09-21 18:06:52 +0800 | [diff] [blame] | 1155 | } else if (!pdata) { |
Haojian Zhuang | f2f218c | 2012-09-17 12:19:08 +0800 | [diff] [blame] | 1156 | pr_info("No platform data in %s!\n", __func__); |
| 1157 | return -EINVAL; |
| 1158 | } |
| 1159 | |
Lee Jones | a1ace0a | 2013-05-23 16:25:03 +0100 | [diff] [blame] | 1160 | chip = devm_kzalloc(&client->dev, |
| 1161 | sizeof(struct pm860x_chip), GFP_KERNEL); |
Jingoo Han | 8552957 | 2013-02-20 18:27:21 +0900 | [diff] [blame] | 1162 | if (chip == NULL) |
| 1163 | return -ENOMEM; |
Haojian Zhuang | f2f218c | 2012-09-17 12:19:08 +0800 | [diff] [blame] | 1164 | |
| 1165 | chip->id = verify_addr(client); |
Sachin Kamat | aaaab42 | 2013-06-12 13:55:43 +0530 | [diff] [blame] | 1166 | chip->regmap = devm_regmap_init_i2c(client, &pm860x_regmap_config); |
Haojian Zhuang | f2f218c | 2012-09-17 12:19:08 +0800 | [diff] [blame] | 1167 | if (IS_ERR(chip->regmap)) { |
| 1168 | ret = PTR_ERR(chip->regmap); |
| 1169 | dev_err(&client->dev, "Failed to allocate register map: %d\n", |
| 1170 | ret); |
Haojian Zhuang | f2f218c | 2012-09-17 12:19:08 +0800 | [diff] [blame] | 1171 | return ret; |
| 1172 | } |
| 1173 | chip->client = client; |
| 1174 | i2c_set_clientdata(client, chip); |
| 1175 | chip->dev = &client->dev; |
| 1176 | dev_set_drvdata(chip->dev, chip); |
| 1177 | |
| 1178 | /* |
| 1179 | * Both client and companion client shares same platform driver. |
| 1180 | * Driver distinguishes them by pdata->companion_addr. |
| 1181 | * pdata->companion_addr is only assigned if companion chip exists. |
| 1182 | * At the same time, the companion_addr shouldn't equal to client |
| 1183 | * address. |
| 1184 | */ |
| 1185 | if (pdata->companion_addr && (pdata->companion_addr != client->addr)) { |
| 1186 | chip->companion_addr = pdata->companion_addr; |
| 1187 | chip->companion = i2c_new_dummy(chip->client->adapter, |
| 1188 | chip->companion_addr); |
Krzysztof Kozlowski | 159ce52 | 2014-02-11 11:03:29 +0100 | [diff] [blame] | 1189 | if (!chip->companion) { |
| 1190 | dev_err(&client->dev, |
| 1191 | "Failed to allocate I2C companion device\n"); |
| 1192 | return -ENODEV; |
| 1193 | } |
Haojian Zhuang | f2f218c | 2012-09-17 12:19:08 +0800 | [diff] [blame] | 1194 | chip->regmap_companion = regmap_init_i2c(chip->companion, |
| 1195 | &pm860x_regmap_config); |
| 1196 | if (IS_ERR(chip->regmap_companion)) { |
| 1197 | ret = PTR_ERR(chip->regmap_companion); |
| 1198 | dev_err(&chip->companion->dev, |
| 1199 | "Failed to allocate register map: %d\n", ret); |
Krzysztof Kozlowski | a7ab1c8 | 2014-02-11 11:03:30 +0100 | [diff] [blame] | 1200 | i2c_unregister_device(chip->companion); |
Haojian Zhuang | f2f218c | 2012-09-17 12:19:08 +0800 | [diff] [blame] | 1201 | return ret; |
| 1202 | } |
| 1203 | i2c_set_clientdata(chip->companion, chip); |
| 1204 | } |
| 1205 | |
| 1206 | pm860x_device_init(chip, pdata); |
| 1207 | return 0; |
| 1208 | } |
| 1209 | |
Bill Pemberton | 4740f73 | 2012-11-19 13:26:01 -0500 | [diff] [blame] | 1210 | static int pm860x_remove(struct i2c_client *client) |
Haojian Zhuang | f2f218c | 2012-09-17 12:19:08 +0800 | [diff] [blame] | 1211 | { |
| 1212 | struct pm860x_chip *chip = i2c_get_clientdata(client); |
| 1213 | |
| 1214 | pm860x_device_exit(chip); |
| 1215 | if (chip->companion) { |
| 1216 | regmap_exit(chip->regmap_companion); |
| 1217 | i2c_unregister_device(chip->companion); |
| 1218 | } |
Haojian Zhuang | f2f218c | 2012-09-17 12:19:08 +0800 | [diff] [blame] | 1219 | return 0; |
| 1220 | } |
| 1221 | |
| 1222 | #ifdef CONFIG_PM_SLEEP |
| 1223 | static int pm860x_suspend(struct device *dev) |
| 1224 | { |
| 1225 | struct i2c_client *client = container_of(dev, struct i2c_client, dev); |
| 1226 | struct pm860x_chip *chip = i2c_get_clientdata(client); |
| 1227 | |
| 1228 | if (device_may_wakeup(dev) && chip->wakeup_flag) |
| 1229 | enable_irq_wake(chip->core_irq); |
| 1230 | return 0; |
| 1231 | } |
| 1232 | |
| 1233 | static int pm860x_resume(struct device *dev) |
| 1234 | { |
| 1235 | struct i2c_client *client = container_of(dev, struct i2c_client, dev); |
| 1236 | struct pm860x_chip *chip = i2c_get_clientdata(client); |
| 1237 | |
| 1238 | if (device_may_wakeup(dev) && chip->wakeup_flag) |
| 1239 | disable_irq_wake(chip->core_irq); |
| 1240 | return 0; |
| 1241 | } |
| 1242 | #endif |
| 1243 | |
| 1244 | static SIMPLE_DEV_PM_OPS(pm860x_pm_ops, pm860x_suspend, pm860x_resume); |
| 1245 | |
Haojian Zhuang | 2e57d56 | 2012-09-21 18:06:52 +0800 | [diff] [blame] | 1246 | static const struct i2c_device_id pm860x_id_table[] = { |
| 1247 | { "88PM860x", 0 }, |
| 1248 | {} |
| 1249 | }; |
| 1250 | MODULE_DEVICE_TABLE(i2c, pm860x_id_table); |
| 1251 | |
| 1252 | static const struct of_device_id pm860x_dt_ids[] = { |
| 1253 | { .compatible = "marvell,88pm860x", }, |
| 1254 | {}, |
| 1255 | }; |
| 1256 | MODULE_DEVICE_TABLE(of, pm860x_dt_ids); |
| 1257 | |
Haojian Zhuang | f2f218c | 2012-09-17 12:19:08 +0800 | [diff] [blame] | 1258 | static struct i2c_driver pm860x_driver = { |
| 1259 | .driver = { |
| 1260 | .name = "88PM860x", |
| 1261 | .owner = THIS_MODULE, |
| 1262 | .pm = &pm860x_pm_ops, |
Sachin Kamat | cd2a553 | 2013-10-15 09:18:48 +0530 | [diff] [blame] | 1263 | .of_match_table = pm860x_dt_ids, |
Haojian Zhuang | f2f218c | 2012-09-17 12:19:08 +0800 | [diff] [blame] | 1264 | }, |
| 1265 | .probe = pm860x_probe, |
Bill Pemberton | 8444921 | 2012-11-19 13:20:24 -0500 | [diff] [blame] | 1266 | .remove = pm860x_remove, |
Haojian Zhuang | f2f218c | 2012-09-17 12:19:08 +0800 | [diff] [blame] | 1267 | .id_table = pm860x_id_table, |
| 1268 | }; |
| 1269 | |
| 1270 | static int __init pm860x_i2c_init(void) |
| 1271 | { |
| 1272 | int ret; |
| 1273 | ret = i2c_add_driver(&pm860x_driver); |
| 1274 | if (ret != 0) |
| 1275 | pr_err("Failed to register 88PM860x I2C driver: %d\n", ret); |
| 1276 | return ret; |
| 1277 | } |
| 1278 | subsys_initcall(pm860x_i2c_init); |
| 1279 | |
| 1280 | static void __exit pm860x_i2c_exit(void) |
| 1281 | { |
| 1282 | i2c_del_driver(&pm860x_driver); |
| 1283 | } |
| 1284 | module_exit(pm860x_i2c_exit); |
| 1285 | |
Haojian Zhuang | 53dbab7 | 2010-01-08 06:01:24 -0500 | [diff] [blame] | 1286 | MODULE_DESCRIPTION("PMIC Driver for Marvell 88PM860x"); |
Haojian Zhuang | bbd51b1 | 2010-01-06 17:04:18 -0500 | [diff] [blame] | 1287 | MODULE_AUTHOR("Haojian Zhuang <haojian.zhuang@marvell.com>"); |
| 1288 | MODULE_LICENSE("GPL"); |