Sangbeom Kim | 0f5f707 | 2011-12-23 17:28:08 +0900 | [diff] [blame] | 1 | /* |
Sangbeom Kim | 63063bf | 2012-07-11 21:06:55 +0900 | [diff] [blame] | 2 | * sec-core.c |
Sangbeom Kim | 0f5f707 | 2011-12-23 17:28:08 +0900 | [diff] [blame] | 3 | * |
Sangbeom Kim | 63063bf | 2012-07-11 21:06:55 +0900 | [diff] [blame] | 4 | * Copyright (c) 2012 Samsung Electronics Co., Ltd |
Sangbeom Kim | 0f5f707 | 2011-12-23 17:28:08 +0900 | [diff] [blame] | 5 | * http://www.samsung.com |
| 6 | * |
| 7 | * This program is free software; you can redistribute it and/or modify it |
| 8 | * under the terms of the GNU General Public License as published by the |
| 9 | * Free Software Foundation; either version 2 of the License, or (at your |
| 10 | * option) any later version. |
| 11 | * |
| 12 | */ |
| 13 | |
| 14 | #include <linux/module.h> |
| 15 | #include <linux/moduleparam.h> |
| 16 | #include <linux/init.h> |
| 17 | #include <linux/err.h> |
| 18 | #include <linux/slab.h> |
| 19 | #include <linux/i2c.h> |
Amit Daniel Kachhap | 26aec009 | 2013-02-03 15:49:47 -0800 | [diff] [blame] | 20 | #include <linux/of_irq.h> |
Sangbeom Kim | 0f5f707 | 2011-12-23 17:28:08 +0900 | [diff] [blame] | 21 | #include <linux/interrupt.h> |
| 22 | #include <linux/pm_runtime.h> |
| 23 | #include <linux/mutex.h> |
| 24 | #include <linux/mfd/core.h> |
Sangbeom Kim | 54227bc | 2012-07-11 21:07:16 +0900 | [diff] [blame] | 25 | #include <linux/mfd/samsung/core.h> |
| 26 | #include <linux/mfd/samsung/irq.h> |
| 27 | #include <linux/mfd/samsung/rtc.h> |
Mark Brown | 25f311f | 2013-07-01 23:02:19 +0100 | [diff] [blame] | 28 | #include <linux/mfd/samsung/s2mps11.h> |
| 29 | #include <linux/mfd/samsung/s5m8763.h> |
| 30 | #include <linux/mfd/samsung/s5m8767.h> |
Sangbeom Kim | 0f5f707 | 2011-12-23 17:28:08 +0900 | [diff] [blame] | 31 | #include <linux/regmap.h> |
| 32 | |
Sangbeom Kim | 88a1cfd | 2012-01-20 16:09:12 +0900 | [diff] [blame] | 33 | static struct mfd_cell s5m8751_devs[] = { |
| 34 | { |
| 35 | .name = "s5m8751-pmic", |
| 36 | }, { |
| 37 | .name = "s5m-charger", |
| 38 | }, { |
| 39 | .name = "s5m8751-codec", |
| 40 | }, |
| 41 | }; |
| 42 | |
| 43 | static struct mfd_cell s5m8763_devs[] = { |
| 44 | { |
| 45 | .name = "s5m8763-pmic", |
| 46 | }, { |
| 47 | .name = "s5m-rtc", |
| 48 | }, { |
| 49 | .name = "s5m-charger", |
| 50 | }, |
| 51 | }; |
| 52 | |
| 53 | static struct mfd_cell s5m8767_devs[] = { |
Sangbeom Kim | 0f5f707 | 2011-12-23 17:28:08 +0900 | [diff] [blame] | 54 | { |
| 55 | .name = "s5m8767-pmic", |
| 56 | }, { |
| 57 | .name = "s5m-rtc", |
| 58 | }, |
| 59 | }; |
| 60 | |
Sangbeom Kim | 9b6d134 | 2012-07-11 21:07:55 +0900 | [diff] [blame] | 61 | static struct mfd_cell s2mps11_devs[] = { |
| 62 | { |
| 63 | .name = "s2mps11-pmic", |
Yadwinder Singh Brar | 3134bca | 2013-07-07 17:14:21 +0530 | [diff] [blame] | 64 | }, { |
| 65 | .name = "s2mps11-clk", |
| 66 | } |
Sangbeom Kim | 9b6d134 | 2012-07-11 21:07:55 +0900 | [diff] [blame] | 67 | }; |
| 68 | |
Amit Daniel Kachhap | 26aec009 | 2013-02-03 15:49:47 -0800 | [diff] [blame] | 69 | #ifdef CONFIG_OF |
| 70 | static struct of_device_id sec_dt_match[] = { |
| 71 | { .compatible = "samsung,s5m8767-pmic", |
| 72 | .data = (void *)S5M8767X, |
| 73 | }, |
Yadwinder Singh Brar | aa32aca | 2013-06-29 18:21:20 +0530 | [diff] [blame] | 74 | { .compatible = "samsung,s2mps11-pmic", |
| 75 | .data = (void *)S2MPS11X, |
| 76 | }, |
Amit Daniel Kachhap | 26aec009 | 2013-02-03 15:49:47 -0800 | [diff] [blame] | 77 | {}, |
| 78 | }; |
| 79 | #endif |
| 80 | |
Sangbeom Kim | 63063bf | 2012-07-11 21:06:55 +0900 | [diff] [blame] | 81 | int sec_reg_read(struct sec_pmic_dev *sec_pmic, u8 reg, void *dest) |
Sangbeom Kim | 0f5f707 | 2011-12-23 17:28:08 +0900 | [diff] [blame] | 82 | { |
Sangbeom Kim | 63063bf | 2012-07-11 21:06:55 +0900 | [diff] [blame] | 83 | return regmap_read(sec_pmic->regmap, reg, dest); |
Sangbeom Kim | 0f5f707 | 2011-12-23 17:28:08 +0900 | [diff] [blame] | 84 | } |
Sangbeom Kim | 63063bf | 2012-07-11 21:06:55 +0900 | [diff] [blame] | 85 | EXPORT_SYMBOL_GPL(sec_reg_read); |
Sangbeom Kim | 0f5f707 | 2011-12-23 17:28:08 +0900 | [diff] [blame] | 86 | |
Sangbeom Kim | 63063bf | 2012-07-11 21:06:55 +0900 | [diff] [blame] | 87 | int sec_bulk_read(struct sec_pmic_dev *sec_pmic, u8 reg, int count, u8 *buf) |
Sangbeom Kim | 0f5f707 | 2011-12-23 17:28:08 +0900 | [diff] [blame] | 88 | { |
Sangbeom Kim | 63063bf | 2012-07-11 21:06:55 +0900 | [diff] [blame] | 89 | return regmap_bulk_read(sec_pmic->regmap, reg, buf, count); |
Sangbeom Kim | 0f5f707 | 2011-12-23 17:28:08 +0900 | [diff] [blame] | 90 | } |
Sangbeom Kim | 63063bf | 2012-07-11 21:06:55 +0900 | [diff] [blame] | 91 | EXPORT_SYMBOL_GPL(sec_bulk_read); |
Sangbeom Kim | 0f5f707 | 2011-12-23 17:28:08 +0900 | [diff] [blame] | 92 | |
Sangbeom Kim | 63063bf | 2012-07-11 21:06:55 +0900 | [diff] [blame] | 93 | int sec_reg_write(struct sec_pmic_dev *sec_pmic, u8 reg, u8 value) |
Sangbeom Kim | 0f5f707 | 2011-12-23 17:28:08 +0900 | [diff] [blame] | 94 | { |
Sangbeom Kim | 63063bf | 2012-07-11 21:06:55 +0900 | [diff] [blame] | 95 | return regmap_write(sec_pmic->regmap, reg, value); |
Sangbeom Kim | 0f5f707 | 2011-12-23 17:28:08 +0900 | [diff] [blame] | 96 | } |
Sangbeom Kim | 63063bf | 2012-07-11 21:06:55 +0900 | [diff] [blame] | 97 | EXPORT_SYMBOL_GPL(sec_reg_write); |
Sangbeom Kim | 0f5f707 | 2011-12-23 17:28:08 +0900 | [diff] [blame] | 98 | |
Sangbeom Kim | 63063bf | 2012-07-11 21:06:55 +0900 | [diff] [blame] | 99 | int sec_bulk_write(struct sec_pmic_dev *sec_pmic, u8 reg, int count, u8 *buf) |
Sangbeom Kim | 0f5f707 | 2011-12-23 17:28:08 +0900 | [diff] [blame] | 100 | { |
Sangbeom Kim | 63063bf | 2012-07-11 21:06:55 +0900 | [diff] [blame] | 101 | return regmap_raw_write(sec_pmic->regmap, reg, buf, count); |
Sangbeom Kim | 0f5f707 | 2011-12-23 17:28:08 +0900 | [diff] [blame] | 102 | } |
Sangbeom Kim | 63063bf | 2012-07-11 21:06:55 +0900 | [diff] [blame] | 103 | EXPORT_SYMBOL_GPL(sec_bulk_write); |
Sangbeom Kim | 0f5f707 | 2011-12-23 17:28:08 +0900 | [diff] [blame] | 104 | |
Sangbeom Kim | 63063bf | 2012-07-11 21:06:55 +0900 | [diff] [blame] | 105 | int sec_reg_update(struct sec_pmic_dev *sec_pmic, u8 reg, u8 val, u8 mask) |
Sangbeom Kim | 0f5f707 | 2011-12-23 17:28:08 +0900 | [diff] [blame] | 106 | { |
Sangbeom Kim | 63063bf | 2012-07-11 21:06:55 +0900 | [diff] [blame] | 107 | return regmap_update_bits(sec_pmic->regmap, reg, mask, val); |
Sangbeom Kim | 0f5f707 | 2011-12-23 17:28:08 +0900 | [diff] [blame] | 108 | } |
Sangbeom Kim | 63063bf | 2012-07-11 21:06:55 +0900 | [diff] [blame] | 109 | EXPORT_SYMBOL_GPL(sec_reg_update); |
Sangbeom Kim | 0f5f707 | 2011-12-23 17:28:08 +0900 | [diff] [blame] | 110 | |
Mark Brown | 6b845ba | 2013-07-02 18:51:16 +0100 | [diff] [blame] | 111 | static bool s2mps11_volatile(struct device *dev, unsigned int reg) |
| 112 | { |
| 113 | switch (reg) { |
| 114 | case S2MPS11_REG_INT1M: |
| 115 | case S2MPS11_REG_INT2M: |
| 116 | case S2MPS11_REG_INT3M: |
| 117 | return false; |
| 118 | default: |
| 119 | return true; |
| 120 | } |
| 121 | } |
| 122 | |
| 123 | static bool s5m8763_volatile(struct device *dev, unsigned int reg) |
| 124 | { |
| 125 | switch (reg) { |
| 126 | case S5M8763_REG_IRQM1: |
| 127 | case S5M8763_REG_IRQM2: |
| 128 | case S5M8763_REG_IRQM3: |
| 129 | case S5M8763_REG_IRQM4: |
| 130 | return false; |
| 131 | default: |
| 132 | return true; |
| 133 | } |
| 134 | } |
| 135 | |
Sangbeom Kim | 63063bf | 2012-07-11 21:06:55 +0900 | [diff] [blame] | 136 | static struct regmap_config sec_regmap_config = { |
Sangbeom Kim | 0f5f707 | 2011-12-23 17:28:08 +0900 | [diff] [blame] | 137 | .reg_bits = 8, |
| 138 | .val_bits = 8, |
| 139 | }; |
| 140 | |
Mark Brown | 25f311f | 2013-07-01 23:02:19 +0100 | [diff] [blame] | 141 | static struct regmap_config s2mps11_regmap_config = { |
| 142 | .reg_bits = 8, |
| 143 | .val_bits = 8, |
| 144 | |
| 145 | .max_register = S2MPS11_REG_L38CTRL, |
Mark Brown | 6b845ba | 2013-07-02 18:51:16 +0100 | [diff] [blame] | 146 | .volatile_reg = s2mps11_volatile, |
| 147 | .cache_type = REGCACHE_FLAT, |
Mark Brown | 25f311f | 2013-07-01 23:02:19 +0100 | [diff] [blame] | 148 | }; |
| 149 | |
| 150 | static struct regmap_config s5m8763_regmap_config = { |
| 151 | .reg_bits = 8, |
| 152 | .val_bits = 8, |
| 153 | |
| 154 | .max_register = S5M8763_REG_LBCNFG2, |
Mark Brown | 6b845ba | 2013-07-02 18:51:16 +0100 | [diff] [blame] | 155 | .volatile_reg = s5m8763_volatile, |
| 156 | .cache_type = REGCACHE_FLAT, |
Mark Brown | 25f311f | 2013-07-01 23:02:19 +0100 | [diff] [blame] | 157 | }; |
| 158 | |
| 159 | static struct regmap_config s5m8767_regmap_config = { |
| 160 | .reg_bits = 8, |
| 161 | .val_bits = 8, |
| 162 | |
| 163 | .max_register = S5M8767_REG_LDO28CTRL, |
Mark Brown | 6b845ba | 2013-07-02 18:51:16 +0100 | [diff] [blame] | 164 | .volatile_reg = s2mps11_volatile, |
| 165 | .cache_type = REGCACHE_FLAT, |
Mark Brown | 25f311f | 2013-07-01 23:02:19 +0100 | [diff] [blame] | 166 | }; |
Amit Daniel Kachhap | 26aec009 | 2013-02-03 15:49:47 -0800 | [diff] [blame] | 167 | |
| 168 | #ifdef CONFIG_OF |
| 169 | /* |
| 170 | * Only the common platform data elements for s5m8767 are parsed here from the |
| 171 | * device tree. Other sub-modules of s5m8767 such as pmic, rtc , charger and |
| 172 | * others have to parse their own platform data elements from device tree. |
| 173 | * |
| 174 | * The s5m8767 platform data structure is instantiated here and the drivers for |
| 175 | * the sub-modules need not instantiate another instance while parsing their |
| 176 | * platform data. |
| 177 | */ |
| 178 | static struct sec_platform_data *sec_pmic_i2c_parse_dt_pdata( |
| 179 | struct device *dev) |
| 180 | { |
| 181 | struct sec_platform_data *pd; |
| 182 | |
| 183 | pd = devm_kzalloc(dev, sizeof(*pd), GFP_KERNEL); |
| 184 | if (!pd) { |
| 185 | dev_err(dev, "could not allocate memory for pdata\n"); |
| 186 | return ERR_PTR(-ENOMEM); |
| 187 | } |
| 188 | |
| 189 | /* |
| 190 | * ToDo: the 'wakeup' member in the platform data is more of a linux |
| 191 | * specfic information. Hence, there is no binding for that yet and |
| 192 | * not parsed here. |
| 193 | */ |
| 194 | |
| 195 | return pd; |
| 196 | } |
| 197 | #else |
Mark Brown | 197bf85 | 2013-02-04 18:31:25 +0000 | [diff] [blame] | 198 | static struct sec_platform_data *sec_pmic_i2c_parse_dt_pdata( |
Amit Daniel Kachhap | 26aec009 | 2013-02-03 15:49:47 -0800 | [diff] [blame] | 199 | struct device *dev) |
| 200 | { |
| 201 | return 0; |
| 202 | } |
| 203 | #endif |
| 204 | |
| 205 | static inline int sec_i2c_get_driver_data(struct i2c_client *i2c, |
| 206 | const struct i2c_device_id *id) |
| 207 | { |
| 208 | #ifdef CONFIG_OF |
| 209 | if (i2c->dev.of_node) { |
| 210 | const struct of_device_id *match; |
| 211 | match = of_match_node(sec_dt_match, i2c->dev.of_node); |
| 212 | return (int)match->data; |
| 213 | } |
| 214 | #endif |
| 215 | return (int)id->driver_data; |
| 216 | } |
| 217 | |
Sangbeom Kim | 63063bf | 2012-07-11 21:06:55 +0900 | [diff] [blame] | 218 | static int sec_pmic_probe(struct i2c_client *i2c, |
Sangbeom Kim | 0f5f707 | 2011-12-23 17:28:08 +0900 | [diff] [blame] | 219 | const struct i2c_device_id *id) |
| 220 | { |
Jingoo Han | 334a41c | 2013-07-30 17:10:05 +0900 | [diff] [blame] | 221 | struct sec_platform_data *pdata = dev_get_platdata(&i2c->dev); |
Mark Brown | 25f311f | 2013-07-01 23:02:19 +0100 | [diff] [blame] | 222 | const struct regmap_config *regmap; |
Sangbeom Kim | 63063bf | 2012-07-11 21:06:55 +0900 | [diff] [blame] | 223 | struct sec_pmic_dev *sec_pmic; |
Axel Lin | 61a2af3 | 2012-02-28 14:23:55 +0800 | [diff] [blame] | 224 | int ret; |
Sangbeom Kim | 0f5f707 | 2011-12-23 17:28:08 +0900 | [diff] [blame] | 225 | |
Sangbeom Kim | 63063bf | 2012-07-11 21:06:55 +0900 | [diff] [blame] | 226 | sec_pmic = devm_kzalloc(&i2c->dev, sizeof(struct sec_pmic_dev), |
Sangbeom Kim | 621210e | 2012-01-20 16:09:11 +0900 | [diff] [blame] | 227 | GFP_KERNEL); |
Sangbeom Kim | 63063bf | 2012-07-11 21:06:55 +0900 | [diff] [blame] | 228 | if (sec_pmic == NULL) |
Sangbeom Kim | 0f5f707 | 2011-12-23 17:28:08 +0900 | [diff] [blame] | 229 | return -ENOMEM; |
| 230 | |
Sangbeom Kim | 63063bf | 2012-07-11 21:06:55 +0900 | [diff] [blame] | 231 | i2c_set_clientdata(i2c, sec_pmic); |
| 232 | sec_pmic->dev = &i2c->dev; |
| 233 | sec_pmic->i2c = i2c; |
| 234 | sec_pmic->irq = i2c->irq; |
Amit Daniel Kachhap | 26aec009 | 2013-02-03 15:49:47 -0800 | [diff] [blame] | 235 | sec_pmic->type = sec_i2c_get_driver_data(i2c, id); |
Sangbeom Kim | 0f5f707 | 2011-12-23 17:28:08 +0900 | [diff] [blame] | 236 | |
Amit Daniel Kachhap | 26aec009 | 2013-02-03 15:49:47 -0800 | [diff] [blame] | 237 | if (sec_pmic->dev->of_node) { |
| 238 | pdata = sec_pmic_i2c_parse_dt_pdata(sec_pmic->dev); |
| 239 | if (IS_ERR(pdata)) { |
| 240 | ret = PTR_ERR(pdata); |
| 241 | return ret; |
| 242 | } |
| 243 | pdata->device_type = sec_pmic->type; |
| 244 | } |
Sangbeom Kim | 0f5f707 | 2011-12-23 17:28:08 +0900 | [diff] [blame] | 245 | if (pdata) { |
Sangbeom Kim | 63063bf | 2012-07-11 21:06:55 +0900 | [diff] [blame] | 246 | sec_pmic->device_type = pdata->device_type; |
| 247 | sec_pmic->ono = pdata->ono; |
| 248 | sec_pmic->irq_base = pdata->irq_base; |
| 249 | sec_pmic->wakeup = pdata->wakeup; |
Amit Daniel Kachhap | 26aec009 | 2013-02-03 15:49:47 -0800 | [diff] [blame] | 250 | sec_pmic->pdata = pdata; |
Sangbeom Kim | 0f5f707 | 2011-12-23 17:28:08 +0900 | [diff] [blame] | 251 | } |
| 252 | |
Mark Brown | 25f311f | 2013-07-01 23:02:19 +0100 | [diff] [blame] | 253 | switch (sec_pmic->device_type) { |
| 254 | case S2MPS11X: |
| 255 | regmap = &s2mps11_regmap_config; |
| 256 | break; |
| 257 | case S5M8763X: |
| 258 | regmap = &s5m8763_regmap_config; |
| 259 | break; |
| 260 | case S5M8767X: |
| 261 | regmap = &s5m8767_regmap_config; |
| 262 | break; |
| 263 | default: |
| 264 | regmap = &sec_regmap_config; |
| 265 | break; |
| 266 | } |
| 267 | |
| 268 | sec_pmic->regmap = devm_regmap_init_i2c(i2c, regmap); |
Sangbeom Kim | 63063bf | 2012-07-11 21:06:55 +0900 | [diff] [blame] | 269 | if (IS_ERR(sec_pmic->regmap)) { |
| 270 | ret = PTR_ERR(sec_pmic->regmap); |
Sangbeom Kim | 0f5f707 | 2011-12-23 17:28:08 +0900 | [diff] [blame] | 271 | dev_err(&i2c->dev, "Failed to allocate register map: %d\n", |
Axel Lin | 61a2af3 | 2012-02-28 14:23:55 +0800 | [diff] [blame] | 272 | ret); |
Axel Lin | 1092e1c | 2012-04-25 10:03:44 +0800 | [diff] [blame] | 273 | return ret; |
Sangbeom Kim | 0f5f707 | 2011-12-23 17:28:08 +0900 | [diff] [blame] | 274 | } |
| 275 | |
Sangbeom Kim | 63063bf | 2012-07-11 21:06:55 +0900 | [diff] [blame] | 276 | sec_pmic->rtc = i2c_new_dummy(i2c->adapter, RTC_I2C_ADDR); |
| 277 | i2c_set_clientdata(sec_pmic->rtc, sec_pmic); |
Sangbeom Kim | 0f5f707 | 2011-12-23 17:28:08 +0900 | [diff] [blame] | 278 | |
Jonghwan Choi | c3ebb30 | 2012-01-16 09:08:42 +0900 | [diff] [blame] | 279 | if (pdata && pdata->cfg_pmic_irq) |
Sangbeom Kim | 0f5f707 | 2011-12-23 17:28:08 +0900 | [diff] [blame] | 280 | pdata->cfg_pmic_irq(); |
| 281 | |
Sangbeom Kim | 63063bf | 2012-07-11 21:06:55 +0900 | [diff] [blame] | 282 | sec_irq_init(sec_pmic); |
Sangbeom Kim | 0f5f707 | 2011-12-23 17:28:08 +0900 | [diff] [blame] | 283 | |
Sangbeom Kim | 63063bf | 2012-07-11 21:06:55 +0900 | [diff] [blame] | 284 | pm_runtime_set_active(sec_pmic->dev); |
Sangbeom Kim | 0f5f707 | 2011-12-23 17:28:08 +0900 | [diff] [blame] | 285 | |
Sangbeom Kim | 63063bf | 2012-07-11 21:06:55 +0900 | [diff] [blame] | 286 | switch (sec_pmic->device_type) { |
Sangbeom Kim | 88a1cfd | 2012-01-20 16:09:12 +0900 | [diff] [blame] | 287 | case S5M8751X: |
Sangbeom Kim | 63063bf | 2012-07-11 21:06:55 +0900 | [diff] [blame] | 288 | ret = mfd_add_devices(sec_pmic->dev, -1, s5m8751_devs, |
Mark Brown | 0848c94 | 2012-09-11 15:16:36 +0800 | [diff] [blame] | 289 | ARRAY_SIZE(s5m8751_devs), NULL, 0, NULL); |
Sangbeom Kim | 88a1cfd | 2012-01-20 16:09:12 +0900 | [diff] [blame] | 290 | break; |
| 291 | case S5M8763X: |
Sangbeom Kim | 63063bf | 2012-07-11 21:06:55 +0900 | [diff] [blame] | 292 | ret = mfd_add_devices(sec_pmic->dev, -1, s5m8763_devs, |
Mark Brown | 0848c94 | 2012-09-11 15:16:36 +0800 | [diff] [blame] | 293 | ARRAY_SIZE(s5m8763_devs), NULL, 0, NULL); |
Sangbeom Kim | 88a1cfd | 2012-01-20 16:09:12 +0900 | [diff] [blame] | 294 | break; |
| 295 | case S5M8767X: |
Sangbeom Kim | 63063bf | 2012-07-11 21:06:55 +0900 | [diff] [blame] | 296 | ret = mfd_add_devices(sec_pmic->dev, -1, s5m8767_devs, |
Mark Brown | 0848c94 | 2012-09-11 15:16:36 +0800 | [diff] [blame] | 297 | ARRAY_SIZE(s5m8767_devs), NULL, 0, NULL); |
Sangbeom Kim | 88a1cfd | 2012-01-20 16:09:12 +0900 | [diff] [blame] | 298 | break; |
Sangbeom Kim | 9b6d134 | 2012-07-11 21:07:55 +0900 | [diff] [blame] | 299 | case S2MPS11X: |
| 300 | ret = mfd_add_devices(sec_pmic->dev, -1, s2mps11_devs, |
Mark Brown | 0848c94 | 2012-09-11 15:16:36 +0800 | [diff] [blame] | 301 | ARRAY_SIZE(s2mps11_devs), NULL, 0, NULL); |
Sangbeom Kim | 9b6d134 | 2012-07-11 21:07:55 +0900 | [diff] [blame] | 302 | break; |
Sangbeom Kim | 88a1cfd | 2012-01-20 16:09:12 +0900 | [diff] [blame] | 303 | default: |
| 304 | /* If this happens the probe function is problem */ |
| 305 | BUG(); |
| 306 | } |
Sangbeom Kim | 0f5f707 | 2011-12-23 17:28:08 +0900 | [diff] [blame] | 307 | |
Leon Romanovsky | 15447a46 | 2013-05-15 18:00:48 +0300 | [diff] [blame] | 308 | if (ret) |
Sangbeom Kim | 0f5f707 | 2011-12-23 17:28:08 +0900 | [diff] [blame] | 309 | goto err; |
| 310 | |
| 311 | return ret; |
| 312 | |
| 313 | err: |
Sangbeom Kim | 63063bf | 2012-07-11 21:06:55 +0900 | [diff] [blame] | 314 | sec_irq_exit(sec_pmic); |
| 315 | i2c_unregister_device(sec_pmic->rtc); |
Sangbeom Kim | 0f5f707 | 2011-12-23 17:28:08 +0900 | [diff] [blame] | 316 | return ret; |
| 317 | } |
| 318 | |
Sangbeom Kim | 63063bf | 2012-07-11 21:06:55 +0900 | [diff] [blame] | 319 | static int sec_pmic_remove(struct i2c_client *i2c) |
Sangbeom Kim | 0f5f707 | 2011-12-23 17:28:08 +0900 | [diff] [blame] | 320 | { |
Sangbeom Kim | 63063bf | 2012-07-11 21:06:55 +0900 | [diff] [blame] | 321 | struct sec_pmic_dev *sec_pmic = i2c_get_clientdata(i2c); |
Sangbeom Kim | 0f5f707 | 2011-12-23 17:28:08 +0900 | [diff] [blame] | 322 | |
Sangbeom Kim | 63063bf | 2012-07-11 21:06:55 +0900 | [diff] [blame] | 323 | mfd_remove_devices(sec_pmic->dev); |
| 324 | sec_irq_exit(sec_pmic); |
| 325 | i2c_unregister_device(sec_pmic->rtc); |
Sangbeom Kim | 0f5f707 | 2011-12-23 17:28:08 +0900 | [diff] [blame] | 326 | return 0; |
| 327 | } |
| 328 | |
Sangbeom Kim | 63063bf | 2012-07-11 21:06:55 +0900 | [diff] [blame] | 329 | static const struct i2c_device_id sec_pmic_id[] = { |
| 330 | { "sec_pmic", 0 }, |
Sangbeom Kim | 0f5f707 | 2011-12-23 17:28:08 +0900 | [diff] [blame] | 331 | { } |
| 332 | }; |
Sangbeom Kim | 63063bf | 2012-07-11 21:06:55 +0900 | [diff] [blame] | 333 | MODULE_DEVICE_TABLE(i2c, sec_pmic_id); |
Sangbeom Kim | 0f5f707 | 2011-12-23 17:28:08 +0900 | [diff] [blame] | 334 | |
Sangbeom Kim | 63063bf | 2012-07-11 21:06:55 +0900 | [diff] [blame] | 335 | static struct i2c_driver sec_pmic_driver = { |
Sangbeom Kim | 0f5f707 | 2011-12-23 17:28:08 +0900 | [diff] [blame] | 336 | .driver = { |
Sangbeom Kim | 63063bf | 2012-07-11 21:06:55 +0900 | [diff] [blame] | 337 | .name = "sec_pmic", |
Sangbeom Kim | 0f5f707 | 2011-12-23 17:28:08 +0900 | [diff] [blame] | 338 | .owner = THIS_MODULE, |
Amit Daniel Kachhap | 26aec009 | 2013-02-03 15:49:47 -0800 | [diff] [blame] | 339 | .of_match_table = of_match_ptr(sec_dt_match), |
Sangbeom Kim | 0f5f707 | 2011-12-23 17:28:08 +0900 | [diff] [blame] | 340 | }, |
Sangbeom Kim | 63063bf | 2012-07-11 21:06:55 +0900 | [diff] [blame] | 341 | .probe = sec_pmic_probe, |
| 342 | .remove = sec_pmic_remove, |
| 343 | .id_table = sec_pmic_id, |
Sangbeom Kim | 0f5f707 | 2011-12-23 17:28:08 +0900 | [diff] [blame] | 344 | }; |
| 345 | |
Sangbeom Kim | 63063bf | 2012-07-11 21:06:55 +0900 | [diff] [blame] | 346 | static int __init sec_pmic_init(void) |
Sangbeom Kim | 0f5f707 | 2011-12-23 17:28:08 +0900 | [diff] [blame] | 347 | { |
Sangbeom Kim | 63063bf | 2012-07-11 21:06:55 +0900 | [diff] [blame] | 348 | return i2c_add_driver(&sec_pmic_driver); |
Sangbeom Kim | 0f5f707 | 2011-12-23 17:28:08 +0900 | [diff] [blame] | 349 | } |
| 350 | |
Sangbeom Kim | 63063bf | 2012-07-11 21:06:55 +0900 | [diff] [blame] | 351 | subsys_initcall(sec_pmic_init); |
Sangbeom Kim | 0f5f707 | 2011-12-23 17:28:08 +0900 | [diff] [blame] | 352 | |
Sangbeom Kim | 63063bf | 2012-07-11 21:06:55 +0900 | [diff] [blame] | 353 | static void __exit sec_pmic_exit(void) |
Sangbeom Kim | 0f5f707 | 2011-12-23 17:28:08 +0900 | [diff] [blame] | 354 | { |
Sangbeom Kim | 63063bf | 2012-07-11 21:06:55 +0900 | [diff] [blame] | 355 | i2c_del_driver(&sec_pmic_driver); |
Sangbeom Kim | 0f5f707 | 2011-12-23 17:28:08 +0900 | [diff] [blame] | 356 | } |
Sangbeom Kim | 63063bf | 2012-07-11 21:06:55 +0900 | [diff] [blame] | 357 | module_exit(sec_pmic_exit); |
Sangbeom Kim | 0f5f707 | 2011-12-23 17:28:08 +0900 | [diff] [blame] | 358 | |
| 359 | MODULE_AUTHOR("Sangbeom Kim <sbkim73@samsung.com>"); |
| 360 | MODULE_DESCRIPTION("Core support for the S5M MFD"); |
| 361 | MODULE_LICENSE("GPL"); |