da9052-regulator.c (b87d07b13c779c42e4929e590003c9eb8c2f06fa) da9052-regulator.c (1e369bcd032e3fb76e232be9c5642b0833ba62f4)
1/*
2* da9052-regulator.c: Regulator driver for DA9052
3*
4* Copyright(c) 2011 Dialog Semiconductor Ltd.
5*
6* Author: David Dajun Chen <dchen@diasemi.com>
7*
8* This program is free software; you can redistribute it and/or modify

--- 115 unchanged lines hidden (view full) ---

124 int i, row = 2;
125
126 /* Select the appropriate current limit range */
127 if (regulator->da9052->chip_id == DA9052)
128 row = 0;
129 else if (offset == 0)
130 row = 1;
131
1/*
2* da9052-regulator.c: Regulator driver for DA9052
3*
4* Copyright(c) 2011 Dialog Semiconductor Ltd.
5*
6* Author: David Dajun Chen <dchen@diasemi.com>
7*
8* This program is free software; you can redistribute it and/or modify

--- 115 unchanged lines hidden (view full) ---

124 int i, row = 2;
125
126 /* Select the appropriate current limit range */
127 if (regulator->da9052->chip_id == DA9052)
128 row = 0;
129 else if (offset == 0)
130 row = 1;
131
132 if (min_uA > da9052_current_limits[row][DA9052_MAX_UA] ||
133 max_uA < da9052_current_limits[row][DA9052_MIN_UA])
134 return -EINVAL;
135
136 for (i = DA9052_CURRENT_RANGE - 1; i >= 0; i--) {
132 for (i = DA9052_CURRENT_RANGE - 1; i >= 0; i--) {
137 if (da9052_current_limits[row][i] <= max_uA) {
133 if ((min_uA <= da9052_current_limits[row][i]) &&
134 (da9052_current_limits[row][i] <= max_uA)) {
138 reg_val = i;
139 break;
140 }
141 }
142
135 reg_val = i;
136 break;
137 }
138 }
139
140 if (i < 0)
141 return -EINVAL;
142
143 /* Determine the even or odd position of the buck current limit
144 * register field
145 */
146 if (offset % 2 == 0)
147 return da9052_reg_update(regulator->da9052,
148 DA9052_BUCKA_REG + offset/2,
149 DA9052_BUCK_ILIM_MASK_EVEN,
150 reg_val << 2);

--- 209 unchanged lines hidden (view full) ---

360 return info;
361 }
362 break;
363 }
364
365 return NULL;
366}
367
143 /* Determine the even or odd position of the buck current limit
144 * register field
145 */
146 if (offset % 2 == 0)
147 return da9052_reg_update(regulator->da9052,
148 DA9052_BUCKA_REG + offset/2,
149 DA9052_BUCK_ILIM_MASK_EVEN,
150 reg_val << 2);

--- 209 unchanged lines hidden (view full) ---

360 return info;
361 }
362 break;
363 }
364
365 return NULL;
366}
367
368static int da9052_regulator_probe(struct platform_device *pdev)
368static int __devinit da9052_regulator_probe(struct platform_device *pdev)
369{
370 struct regulator_config config = { };
371 struct da9052_regulator *regulator;
372 struct da9052 *da9052;
373 struct da9052_pdata *pdata;
374
375 regulator = devm_kzalloc(&pdev->dev, sizeof(struct da9052_regulator),
376 GFP_KERNEL);

--- 48 unchanged lines hidden (view full) ---

425 return PTR_ERR(regulator->rdev);
426 }
427
428 platform_set_drvdata(pdev, regulator);
429
430 return 0;
431}
432
369{
370 struct regulator_config config = { };
371 struct da9052_regulator *regulator;
372 struct da9052 *da9052;
373 struct da9052_pdata *pdata;
374
375 regulator = devm_kzalloc(&pdev->dev, sizeof(struct da9052_regulator),
376 GFP_KERNEL);

--- 48 unchanged lines hidden (view full) ---

425 return PTR_ERR(regulator->rdev);
426 }
427
428 platform_set_drvdata(pdev, regulator);
429
430 return 0;
431}
432
433static int da9052_regulator_remove(struct platform_device *pdev)
433static int __devexit da9052_regulator_remove(struct platform_device *pdev)
434{
435 struct da9052_regulator *regulator = platform_get_drvdata(pdev);
436
437 regulator_unregister(regulator->rdev);
438 return 0;
439}
440
441static struct platform_driver da9052_regulator_driver = {
442 .probe = da9052_regulator_probe,
434{
435 struct da9052_regulator *regulator = platform_get_drvdata(pdev);
436
437 regulator_unregister(regulator->rdev);
438 return 0;
439}
440
441static struct platform_driver da9052_regulator_driver = {
442 .probe = da9052_regulator_probe,
443 .remove = da9052_regulator_remove,
443 .remove = __devexit_p(da9052_regulator_remove),
444 .driver = {
445 .name = "da9052-regulator",
446 .owner = THIS_MODULE,
447 },
448};
449
450static int __init da9052_regulator_init(void)
451{

--- 14 unchanged lines hidden ---
444 .driver = {
445 .name = "da9052-regulator",
446 .owner = THIS_MODULE,
447 },
448};
449
450static int __init da9052_regulator_init(void)
451{

--- 14 unchanged lines hidden ---