Haojian Zhuang | a71b797 | 2010-01-25 10:24:09 -0500 | [diff] [blame] | 1 | /* |
| 2 | * Regulators driver for Maxim max8649 |
| 3 | * |
| 4 | * Copyright (C) 2009-2010 Marvell International Ltd. |
| 5 | * Haojian Zhuang <haojian.zhuang@marvell.com> |
| 6 | * |
| 7 | * This program is free software; you can redistribute it and/or modify |
| 8 | * it under the terms of the GNU General Public License version 2 as |
| 9 | * published by the Free Software Foundation. |
| 10 | */ |
| 11 | #include <linux/kernel.h> |
| 12 | #include <linux/module.h> |
| 13 | #include <linux/err.h> |
| 14 | #include <linux/i2c.h> |
| 15 | #include <linux/platform_device.h> |
| 16 | #include <linux/regulator/driver.h> |
Tejun Heo | 5a0e3ad | 2010-03-24 17:04:11 +0900 | [diff] [blame] | 17 | #include <linux/slab.h> |
Haojian Zhuang | a71b797 | 2010-01-25 10:24:09 -0500 | [diff] [blame] | 18 | #include <linux/regulator/max8649.h> |
Jonghwan Choi | c5b68d47 | 2011-10-24 22:26:26 +0900 | [diff] [blame] | 19 | #include <linux/regmap.h> |
Haojian Zhuang | a71b797 | 2010-01-25 10:24:09 -0500 | [diff] [blame] | 20 | |
| 21 | #define MAX8649_DCDC_VMIN 750000 /* uV */ |
| 22 | #define MAX8649_DCDC_VMAX 1380000 /* uV */ |
| 23 | #define MAX8649_DCDC_STEP 10000 /* uV */ |
| 24 | #define MAX8649_VOL_MASK 0x3f |
| 25 | |
| 26 | /* Registers */ |
| 27 | #define MAX8649_MODE0 0x00 |
| 28 | #define MAX8649_MODE1 0x01 |
| 29 | #define MAX8649_MODE2 0x02 |
| 30 | #define MAX8649_MODE3 0x03 |
| 31 | #define MAX8649_CONTROL 0x04 |
| 32 | #define MAX8649_SYNC 0x05 |
| 33 | #define MAX8649_RAMP 0x06 |
| 34 | #define MAX8649_CHIP_ID1 0x08 |
| 35 | #define MAX8649_CHIP_ID2 0x09 |
| 36 | |
| 37 | /* Bits */ |
| 38 | #define MAX8649_EN_PD (1 << 7) |
| 39 | #define MAX8649_VID0_PD (1 << 6) |
| 40 | #define MAX8649_VID1_PD (1 << 5) |
| 41 | #define MAX8649_VID_MASK (3 << 5) |
| 42 | |
| 43 | #define MAX8649_FORCE_PWM (1 << 7) |
| 44 | #define MAX8649_SYNC_EXTCLK (1 << 6) |
| 45 | |
| 46 | #define MAX8649_EXT_MASK (3 << 6) |
| 47 | |
| 48 | #define MAX8649_RAMP_MASK (7 << 5) |
| 49 | #define MAX8649_RAMP_DOWN (1 << 1) |
| 50 | |
| 51 | struct max8649_regulator_info { |
| 52 | struct regulator_dev *regulator; |
Haojian Zhuang | a71b797 | 2010-01-25 10:24:09 -0500 | [diff] [blame] | 53 | struct device *dev; |
Jonghwan Choi | c5b68d47 | 2011-10-24 22:26:26 +0900 | [diff] [blame] | 54 | struct regmap *regmap; |
Haojian Zhuang | a71b797 | 2010-01-25 10:24:09 -0500 | [diff] [blame] | 55 | |
Haojian Zhuang | a71b797 | 2010-01-25 10:24:09 -0500 | [diff] [blame] | 56 | unsigned mode:2; /* bit[1:0] = VID1, VID0 */ |
| 57 | unsigned extclk_freq:2; |
| 58 | unsigned extclk:1; |
| 59 | unsigned ramp_timing:3; |
| 60 | unsigned ramp_down:1; |
| 61 | }; |
| 62 | |
| 63 | /* I2C operations */ |
| 64 | |
Haojian Zhuang | a71b797 | 2010-01-25 10:24:09 -0500 | [diff] [blame] | 65 | static inline int check_range(int min_uV, int max_uV) |
| 66 | { |
| 67 | if ((min_uV < MAX8649_DCDC_VMIN) || (max_uV > MAX8649_DCDC_VMAX) |
| 68 | || (min_uV > max_uV)) |
| 69 | return -EINVAL; |
| 70 | return 0; |
| 71 | } |
| 72 | |
| 73 | static int max8649_list_voltage(struct regulator_dev *rdev, unsigned index) |
| 74 | { |
| 75 | return (MAX8649_DCDC_VMIN + index * MAX8649_DCDC_STEP); |
| 76 | } |
| 77 | |
Haojian Zhuang | a71b797 | 2010-01-25 10:24:09 -0500 | [diff] [blame] | 78 | static int max8649_set_voltage(struct regulator_dev *rdev, |
Mark Brown | 3a93f2a | 2010-11-10 14:38:29 +0000 | [diff] [blame] | 79 | int min_uV, int max_uV, unsigned *selector) |
Haojian Zhuang | a71b797 | 2010-01-25 10:24:09 -0500 | [diff] [blame] | 80 | { |
| 81 | struct max8649_regulator_info *info = rdev_get_drvdata(rdev); |
| 82 | unsigned char data, mask; |
| 83 | |
| 84 | if (check_range(min_uV, max_uV)) { |
| 85 | dev_err(info->dev, "invalid voltage range (%d, %d) uV\n", |
| 86 | min_uV, max_uV); |
| 87 | return -EINVAL; |
| 88 | } |
Axel Lin | 21c9e5f | 2012-03-08 10:05:24 +0800 | [diff] [blame] | 89 | data = DIV_ROUND_UP(min_uV - MAX8649_DCDC_VMIN, MAX8649_DCDC_STEP); |
Haojian Zhuang | a71b797 | 2010-01-25 10:24:09 -0500 | [diff] [blame] | 90 | mask = MAX8649_VOL_MASK; |
Mark Brown | 3a93f2a | 2010-11-10 14:38:29 +0000 | [diff] [blame] | 91 | *selector = data & mask; |
Haojian Zhuang | a71b797 | 2010-01-25 10:24:09 -0500 | [diff] [blame] | 92 | |
Axel Lin | 817d8c2 | 2012-05-15 00:13:10 +0800 | [diff] [blame^] | 93 | return regmap_update_bits(info->regmap, rdev->desc->vsel_reg, mask, |
| 94 | data); |
Haojian Zhuang | a71b797 | 2010-01-25 10:24:09 -0500 | [diff] [blame] | 95 | } |
| 96 | |
| 97 | /* EN_PD means pulldown on EN input */ |
| 98 | static int max8649_enable(struct regulator_dev *rdev) |
| 99 | { |
| 100 | struct max8649_regulator_info *info = rdev_get_drvdata(rdev); |
Jonghwan Choi | c5b68d47 | 2011-10-24 22:26:26 +0900 | [diff] [blame] | 101 | return regmap_update_bits(info->regmap, MAX8649_CONTROL, MAX8649_EN_PD, 0); |
Haojian Zhuang | a71b797 | 2010-01-25 10:24:09 -0500 | [diff] [blame] | 102 | } |
| 103 | |
| 104 | /* |
| 105 | * Applied internal pulldown resistor on EN input pin. |
| 106 | * If pulldown EN pin outside, it would be better. |
| 107 | */ |
| 108 | static int max8649_disable(struct regulator_dev *rdev) |
| 109 | { |
| 110 | struct max8649_regulator_info *info = rdev_get_drvdata(rdev); |
Jonghwan Choi | c5b68d47 | 2011-10-24 22:26:26 +0900 | [diff] [blame] | 111 | return regmap_update_bits(info->regmap, MAX8649_CONTROL, MAX8649_EN_PD, |
Haojian Zhuang | a71b797 | 2010-01-25 10:24:09 -0500 | [diff] [blame] | 112 | MAX8649_EN_PD); |
| 113 | } |
| 114 | |
| 115 | static int max8649_is_enabled(struct regulator_dev *rdev) |
| 116 | { |
| 117 | struct max8649_regulator_info *info = rdev_get_drvdata(rdev); |
Jonghwan Choi | c5b68d47 | 2011-10-24 22:26:26 +0900 | [diff] [blame] | 118 | unsigned int val; |
Haojian Zhuang | a71b797 | 2010-01-25 10:24:09 -0500 | [diff] [blame] | 119 | int ret; |
| 120 | |
Jonghwan Choi | c5b68d47 | 2011-10-24 22:26:26 +0900 | [diff] [blame] | 121 | ret = regmap_read(info->regmap, MAX8649_CONTROL, &val); |
| 122 | if (ret != 0) |
Haojian Zhuang | a71b797 | 2010-01-25 10:24:09 -0500 | [diff] [blame] | 123 | return ret; |
Jonghwan Choi | c5b68d47 | 2011-10-24 22:26:26 +0900 | [diff] [blame] | 124 | return !((unsigned char)val & MAX8649_EN_PD); |
Haojian Zhuang | a71b797 | 2010-01-25 10:24:09 -0500 | [diff] [blame] | 125 | } |
| 126 | |
| 127 | static int max8649_enable_time(struct regulator_dev *rdev) |
| 128 | { |
| 129 | struct max8649_regulator_info *info = rdev_get_drvdata(rdev); |
| 130 | int voltage, rate, ret; |
Jonghwan Choi | c5b68d47 | 2011-10-24 22:26:26 +0900 | [diff] [blame] | 131 | unsigned int val; |
Haojian Zhuang | a71b797 | 2010-01-25 10:24:09 -0500 | [diff] [blame] | 132 | |
| 133 | /* get voltage */ |
Axel Lin | 817d8c2 | 2012-05-15 00:13:10 +0800 | [diff] [blame^] | 134 | ret = regmap_read(info->regmap, rdev->desc->vsel_reg, &val); |
Jonghwan Choi | c5b68d47 | 2011-10-24 22:26:26 +0900 | [diff] [blame] | 135 | if (ret != 0) |
Haojian Zhuang | a71b797 | 2010-01-25 10:24:09 -0500 | [diff] [blame] | 136 | return ret; |
Jonghwan Choi | c5b68d47 | 2011-10-24 22:26:26 +0900 | [diff] [blame] | 137 | val &= MAX8649_VOL_MASK; |
Axel Lin | 9fc886a | 2012-02-07 11:12:55 +0800 | [diff] [blame] | 138 | voltage = max8649_list_voltage(rdev, (unsigned char)val); /* uV */ |
Haojian Zhuang | a71b797 | 2010-01-25 10:24:09 -0500 | [diff] [blame] | 139 | |
| 140 | /* get rate */ |
Jonghwan Choi | c5b68d47 | 2011-10-24 22:26:26 +0900 | [diff] [blame] | 141 | ret = regmap_read(info->regmap, MAX8649_RAMP, &val); |
| 142 | if (ret != 0) |
Haojian Zhuang | a71b797 | 2010-01-25 10:24:09 -0500 | [diff] [blame] | 143 | return ret; |
Jonghwan Choi | c5b68d47 | 2011-10-24 22:26:26 +0900 | [diff] [blame] | 144 | ret = (val & MAX8649_RAMP_MASK) >> 5; |
Haojian Zhuang | a71b797 | 2010-01-25 10:24:09 -0500 | [diff] [blame] | 145 | rate = (32 * 1000) >> ret; /* uV/uS */ |
| 146 | |
Axel Lin | e69c499 | 2011-08-02 12:54:56 +0800 | [diff] [blame] | 147 | return DIV_ROUND_UP(voltage, rate); |
Haojian Zhuang | a71b797 | 2010-01-25 10:24:09 -0500 | [diff] [blame] | 148 | } |
| 149 | |
| 150 | static int max8649_set_mode(struct regulator_dev *rdev, unsigned int mode) |
| 151 | { |
| 152 | struct max8649_regulator_info *info = rdev_get_drvdata(rdev); |
| 153 | |
| 154 | switch (mode) { |
| 155 | case REGULATOR_MODE_FAST: |
Axel Lin | 817d8c2 | 2012-05-15 00:13:10 +0800 | [diff] [blame^] | 156 | regmap_update_bits(info->regmap, rdev->desc->vsel_reg, |
| 157 | MAX8649_FORCE_PWM, MAX8649_FORCE_PWM); |
Haojian Zhuang | a71b797 | 2010-01-25 10:24:09 -0500 | [diff] [blame] | 158 | break; |
| 159 | case REGULATOR_MODE_NORMAL: |
Axel Lin | 817d8c2 | 2012-05-15 00:13:10 +0800 | [diff] [blame^] | 160 | regmap_update_bits(info->regmap, rdev->desc->vsel_reg, |
Jonghwan Choi | c5b68d47 | 2011-10-24 22:26:26 +0900 | [diff] [blame] | 161 | MAX8649_FORCE_PWM, 0); |
Haojian Zhuang | a71b797 | 2010-01-25 10:24:09 -0500 | [diff] [blame] | 162 | break; |
| 163 | default: |
| 164 | return -EINVAL; |
| 165 | } |
| 166 | return 0; |
| 167 | } |
| 168 | |
| 169 | static unsigned int max8649_get_mode(struct regulator_dev *rdev) |
| 170 | { |
| 171 | struct max8649_regulator_info *info = rdev_get_drvdata(rdev); |
Jonghwan Choi | c5b68d47 | 2011-10-24 22:26:26 +0900 | [diff] [blame] | 172 | unsigned int val; |
Haojian Zhuang | a71b797 | 2010-01-25 10:24:09 -0500 | [diff] [blame] | 173 | int ret; |
| 174 | |
Axel Lin | 817d8c2 | 2012-05-15 00:13:10 +0800 | [diff] [blame^] | 175 | ret = regmap_read(info->regmap, rdev->desc->vsel_reg, &val); |
Jonghwan Choi | c5b68d47 | 2011-10-24 22:26:26 +0900 | [diff] [blame] | 176 | if (ret != 0) |
| 177 | return ret; |
| 178 | if (val & MAX8649_FORCE_PWM) |
Haojian Zhuang | a71b797 | 2010-01-25 10:24:09 -0500 | [diff] [blame] | 179 | return REGULATOR_MODE_FAST; |
| 180 | return REGULATOR_MODE_NORMAL; |
| 181 | } |
| 182 | |
| 183 | static struct regulator_ops max8649_dcdc_ops = { |
| 184 | .set_voltage = max8649_set_voltage, |
Axel Lin | 817d8c2 | 2012-05-15 00:13:10 +0800 | [diff] [blame^] | 185 | .get_voltage_sel = regulator_get_voltage_sel_regmap, |
Haojian Zhuang | a71b797 | 2010-01-25 10:24:09 -0500 | [diff] [blame] | 186 | .list_voltage = max8649_list_voltage, |
| 187 | .enable = max8649_enable, |
| 188 | .disable = max8649_disable, |
| 189 | .is_enabled = max8649_is_enabled, |
| 190 | .enable_time = max8649_enable_time, |
| 191 | .set_mode = max8649_set_mode, |
| 192 | .get_mode = max8649_get_mode, |
| 193 | |
| 194 | }; |
| 195 | |
Axel Lin | 817d8c2 | 2012-05-15 00:13:10 +0800 | [diff] [blame^] | 196 | static struct regulator_desc dcdc_desc = { |
Haojian Zhuang | a71b797 | 2010-01-25 10:24:09 -0500 | [diff] [blame] | 197 | .name = "max8649", |
| 198 | .ops = &max8649_dcdc_ops, |
| 199 | .type = REGULATOR_VOLTAGE, |
| 200 | .n_voltages = 1 << 6, |
| 201 | .owner = THIS_MODULE, |
Axel Lin | 817d8c2 | 2012-05-15 00:13:10 +0800 | [diff] [blame^] | 202 | .vsel_mask = MAX8649_VOL_MASK, |
Haojian Zhuang | a71b797 | 2010-01-25 10:24:09 -0500 | [diff] [blame] | 203 | }; |
| 204 | |
Jonghwan Choi | c5b68d47 | 2011-10-24 22:26:26 +0900 | [diff] [blame] | 205 | static struct regmap_config max8649_regmap_config = { |
| 206 | .reg_bits = 8, |
| 207 | .val_bits = 8, |
| 208 | }; |
| 209 | |
Haojian Zhuang | a71b797 | 2010-01-25 10:24:09 -0500 | [diff] [blame] | 210 | static int __devinit max8649_regulator_probe(struct i2c_client *client, |
| 211 | const struct i2c_device_id *id) |
| 212 | { |
| 213 | struct max8649_platform_data *pdata = client->dev.platform_data; |
| 214 | struct max8649_regulator_info *info = NULL; |
Mark Brown | c172708d | 2012-04-04 00:50:22 +0100 | [diff] [blame] | 215 | struct regulator_config config = { }; |
Jonghwan Choi | c5b68d47 | 2011-10-24 22:26:26 +0900 | [diff] [blame] | 216 | unsigned int val; |
Haojian Zhuang | a71b797 | 2010-01-25 10:24:09 -0500 | [diff] [blame] | 217 | unsigned char data; |
| 218 | int ret; |
| 219 | |
Axel Lin | dc553a7 | 2012-04-07 23:28:28 +0800 | [diff] [blame] | 220 | info = devm_kzalloc(&client->dev, sizeof(struct max8649_regulator_info), |
| 221 | GFP_KERNEL); |
Haojian Zhuang | a71b797 | 2010-01-25 10:24:09 -0500 | [diff] [blame] | 222 | if (!info) { |
| 223 | dev_err(&client->dev, "No enough memory\n"); |
| 224 | return -ENOMEM; |
| 225 | } |
| 226 | |
Axel Lin | dc553a7 | 2012-04-07 23:28:28 +0800 | [diff] [blame] | 227 | info->regmap = devm_regmap_init_i2c(client, &max8649_regmap_config); |
Jonghwan Choi | c5b68d47 | 2011-10-24 22:26:26 +0900 | [diff] [blame] | 228 | if (IS_ERR(info->regmap)) { |
| 229 | ret = PTR_ERR(info->regmap); |
| 230 | dev_err(&client->dev, "Failed to allocate register map: %d\n", ret); |
Axel Lin | dc553a7 | 2012-04-07 23:28:28 +0800 | [diff] [blame] | 231 | return ret; |
Jonghwan Choi | c5b68d47 | 2011-10-24 22:26:26 +0900 | [diff] [blame] | 232 | } |
| 233 | |
Haojian Zhuang | a71b797 | 2010-01-25 10:24:09 -0500 | [diff] [blame] | 234 | info->dev = &client->dev; |
Haojian Zhuang | a71b797 | 2010-01-25 10:24:09 -0500 | [diff] [blame] | 235 | i2c_set_clientdata(client, info); |
| 236 | |
| 237 | info->mode = pdata->mode; |
| 238 | switch (info->mode) { |
| 239 | case 0: |
Axel Lin | 817d8c2 | 2012-05-15 00:13:10 +0800 | [diff] [blame^] | 240 | dcdc_desc.vsel_reg = MAX8649_MODE0; |
Haojian Zhuang | a71b797 | 2010-01-25 10:24:09 -0500 | [diff] [blame] | 241 | break; |
| 242 | case 1: |
Axel Lin | 817d8c2 | 2012-05-15 00:13:10 +0800 | [diff] [blame^] | 243 | dcdc_desc.vsel_reg = MAX8649_MODE1; |
Haojian Zhuang | a71b797 | 2010-01-25 10:24:09 -0500 | [diff] [blame] | 244 | break; |
| 245 | case 2: |
Axel Lin | 817d8c2 | 2012-05-15 00:13:10 +0800 | [diff] [blame^] | 246 | dcdc_desc.vsel_reg = MAX8649_MODE2; |
Haojian Zhuang | a71b797 | 2010-01-25 10:24:09 -0500 | [diff] [blame] | 247 | break; |
| 248 | case 3: |
Axel Lin | 817d8c2 | 2012-05-15 00:13:10 +0800 | [diff] [blame^] | 249 | dcdc_desc.vsel_reg = MAX8649_MODE3; |
Haojian Zhuang | a71b797 | 2010-01-25 10:24:09 -0500 | [diff] [blame] | 250 | break; |
| 251 | default: |
| 252 | break; |
| 253 | } |
| 254 | |
Jonghwan Choi | c5b68d47 | 2011-10-24 22:26:26 +0900 | [diff] [blame] | 255 | ret = regmap_read(info->regmap, MAX8649_CHIP_ID1, &val); |
| 256 | if (ret != 0) { |
Haojian Zhuang | a71b797 | 2010-01-25 10:24:09 -0500 | [diff] [blame] | 257 | dev_err(info->dev, "Failed to detect ID of MAX8649:%d\n", |
| 258 | ret); |
Axel Lin | dc553a7 | 2012-04-07 23:28:28 +0800 | [diff] [blame] | 259 | return ret; |
Haojian Zhuang | a71b797 | 2010-01-25 10:24:09 -0500 | [diff] [blame] | 260 | } |
Axel Lin | da7de6a | 2012-02-06 20:37:46 +0800 | [diff] [blame] | 261 | dev_info(info->dev, "Detected MAX8649 (ID:%x)\n", val); |
Haojian Zhuang | a71b797 | 2010-01-25 10:24:09 -0500 | [diff] [blame] | 262 | |
| 263 | /* enable VID0 & VID1 */ |
Jonghwan Choi | c5b68d47 | 2011-10-24 22:26:26 +0900 | [diff] [blame] | 264 | regmap_update_bits(info->regmap, MAX8649_CONTROL, MAX8649_VID_MASK, 0); |
Haojian Zhuang | a71b797 | 2010-01-25 10:24:09 -0500 | [diff] [blame] | 265 | |
| 266 | /* enable/disable external clock synchronization */ |
| 267 | info->extclk = pdata->extclk; |
| 268 | data = (info->extclk) ? MAX8649_SYNC_EXTCLK : 0; |
Axel Lin | 817d8c2 | 2012-05-15 00:13:10 +0800 | [diff] [blame^] | 269 | regmap_update_bits(info->regmap, dcdc_desc.vsel_reg, |
| 270 | MAX8649_SYNC_EXTCLK, data); |
Haojian Zhuang | a71b797 | 2010-01-25 10:24:09 -0500 | [diff] [blame] | 271 | if (info->extclk) { |
| 272 | /* set external clock frequency */ |
| 273 | info->extclk_freq = pdata->extclk_freq; |
Jonghwan Choi | c5b68d47 | 2011-10-24 22:26:26 +0900 | [diff] [blame] | 274 | regmap_update_bits(info->regmap, MAX8649_SYNC, MAX8649_EXT_MASK, |
| 275 | info->extclk_freq << 6); |
Haojian Zhuang | a71b797 | 2010-01-25 10:24:09 -0500 | [diff] [blame] | 276 | } |
| 277 | |
| 278 | if (pdata->ramp_timing) { |
| 279 | info->ramp_timing = pdata->ramp_timing; |
Jonghwan Choi | c5b68d47 | 2011-10-24 22:26:26 +0900 | [diff] [blame] | 280 | regmap_update_bits(info->regmap, MAX8649_RAMP, MAX8649_RAMP_MASK, |
| 281 | info->ramp_timing << 5); |
Haojian Zhuang | a71b797 | 2010-01-25 10:24:09 -0500 | [diff] [blame] | 282 | } |
| 283 | |
| 284 | info->ramp_down = pdata->ramp_down; |
| 285 | if (info->ramp_down) { |
Jonghwan Choi | c5b68d47 | 2011-10-24 22:26:26 +0900 | [diff] [blame] | 286 | regmap_update_bits(info->regmap, MAX8649_RAMP, MAX8649_RAMP_DOWN, |
| 287 | MAX8649_RAMP_DOWN); |
Haojian Zhuang | a71b797 | 2010-01-25 10:24:09 -0500 | [diff] [blame] | 288 | } |
| 289 | |
Mark Brown | c172708d | 2012-04-04 00:50:22 +0100 | [diff] [blame] | 290 | config.dev = &client->dev; |
| 291 | config.init_data = pdata->regulator; |
| 292 | config.driver_data = info; |
| 293 | |
| 294 | info->regulator = regulator_register(&dcdc_desc, &config); |
Haojian Zhuang | a71b797 | 2010-01-25 10:24:09 -0500 | [diff] [blame] | 295 | if (IS_ERR(info->regulator)) { |
| 296 | dev_err(info->dev, "failed to register regulator %s\n", |
| 297 | dcdc_desc.name); |
Axel Lin | dc553a7 | 2012-04-07 23:28:28 +0800 | [diff] [blame] | 298 | return PTR_ERR(info->regulator); |
Haojian Zhuang | a71b797 | 2010-01-25 10:24:09 -0500 | [diff] [blame] | 299 | } |
| 300 | |
Haojian Zhuang | a71b797 | 2010-01-25 10:24:09 -0500 | [diff] [blame] | 301 | return 0; |
Haojian Zhuang | a71b797 | 2010-01-25 10:24:09 -0500 | [diff] [blame] | 302 | } |
| 303 | |
| 304 | static int __devexit max8649_regulator_remove(struct i2c_client *client) |
| 305 | { |
| 306 | struct max8649_regulator_info *info = i2c_get_clientdata(client); |
| 307 | |
| 308 | if (info) { |
| 309 | if (info->regulator) |
| 310 | regulator_unregister(info->regulator); |
Haojian Zhuang | a71b797 | 2010-01-25 10:24:09 -0500 | [diff] [blame] | 311 | } |
Haojian Zhuang | a71b797 | 2010-01-25 10:24:09 -0500 | [diff] [blame] | 312 | |
| 313 | return 0; |
| 314 | } |
| 315 | |
| 316 | static const struct i2c_device_id max8649_id[] = { |
| 317 | { "max8649", 0 }, |
| 318 | { } |
| 319 | }; |
| 320 | MODULE_DEVICE_TABLE(i2c, max8649_id); |
| 321 | |
| 322 | static struct i2c_driver max8649_driver = { |
| 323 | .probe = max8649_regulator_probe, |
| 324 | .remove = __devexit_p(max8649_regulator_remove), |
| 325 | .driver = { |
| 326 | .name = "max8649", |
| 327 | }, |
| 328 | .id_table = max8649_id, |
| 329 | }; |
| 330 | |
| 331 | static int __init max8649_init(void) |
| 332 | { |
| 333 | return i2c_add_driver(&max8649_driver); |
| 334 | } |
| 335 | subsys_initcall(max8649_init); |
| 336 | |
| 337 | static void __exit max8649_exit(void) |
| 338 | { |
| 339 | i2c_del_driver(&max8649_driver); |
| 340 | } |
| 341 | module_exit(max8649_exit); |
| 342 | |
| 343 | /* Module information */ |
| 344 | MODULE_DESCRIPTION("MAXIM 8649 voltage regulator driver"); |
| 345 | MODULE_AUTHOR("Haojian Zhuang <haojian.zhuang@marvell.com>"); |
| 346 | MODULE_LICENSE("GPL"); |