Release 4.7 drivers/regulator/max8925-regulator.c
/*
* Regulators driver for Maxim max8925
*
* Copyright (C) 2009 Marvell International Ltd.
* Haojian Zhuang <haojian.zhuang@marvell.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation.
*/
#include <linux/kernel.h>
#include <linux/module.h>
#include <linux/init.h>
#include <linux/err.h>
#include <linux/i2c.h>
#include <linux/platform_device.h>
#include <linux/regulator/driver.h>
#include <linux/regulator/machine.h>
#include <linux/mfd/max8925.h>
#include <linux/of.h>
#include <linux/regulator/of_regulator.h>
#define SD1_DVM_VMIN 850000
#define SD1_DVM_VMAX 1000000
#define SD1_DVM_STEP 50000
#define SD1_DVM_SHIFT 5
/* SDCTL1 bit5 */
#define SD1_DVM_EN 6
/* SDV1 bit 6 */
/* bit definitions in LDO control registers */
#define LDO_SEQ_I2C 0x7
/* Power U/D by i2c */
#define LDO_SEQ_MASK 0x7
/* Power U/D sequence mask */
#define LDO_SEQ_SHIFT 2
/* Power U/D sequence offset */
#define LDO_I2C_EN 0x1
/* Enable by i2c */
#define LDO_I2C_EN_MASK 0x1
/* Enable mask by i2c */
#define LDO_I2C_EN_SHIFT 0
/* Enable offset by i2c */
struct max8925_regulator_info {
struct regulator_desc desc;
struct i2c_client *i2c;
int vol_reg;
int enable_reg;
};
static int max8925_set_voltage_sel(struct regulator_dev *rdev,
unsigned int selector)
{
struct max8925_regulator_info *info = rdev_get_drvdata(rdev);
unsigned char mask = rdev->desc->n_voltages - 1;
return max8925_set_bits(info->i2c, info->vol_reg, mask, selector);
}
Contributors
| Person | Tokens | Prop | Commits | CommitProp |
haojian zhuang | haojian zhuang | 42 | 79.25% | 1 | 25.00% |
axel lin | axel lin | 8 | 15.09% | 2 | 50.00% |
mark brown | mark brown | 3 | 5.66% | 1 | 25.00% |
| Total | 53 | 100.00% | 4 | 100.00% |
static int max8925_get_voltage_sel(struct regulator_dev *rdev)
{
struct max8925_regulator_info *info = rdev_get_drvdata(rdev);
unsigned char data, mask;
int ret;
ret = max8925_reg_read(info->i2c, info->vol_reg);
if (ret < 0)
return ret;
mask = rdev->desc->n_voltages - 1;
data = ret & mask;
return data;
}
Contributors
| Person | Tokens | Prop | Commits | CommitProp |
haojian zhuang | haojian zhuang | 66 | 92.96% | 1 | 33.33% |
axel lin | axel lin | 5 | 7.04% | 2 | 66.67% |
| Total | 71 | 100.00% | 3 | 100.00% |
static int max8925_enable(struct regulator_dev *rdev)
{
struct max8925_regulator_info *info = rdev_get_drvdata(rdev);
return max8925_set_bits(info->i2c, info->enable_reg,
LDO_SEQ_MASK << LDO_SEQ_SHIFT |
LDO_I2C_EN_MASK << LDO_I2C_EN_SHIFT,
LDO_SEQ_I2C << LDO_SEQ_SHIFT |
LDO_I2C_EN << LDO_I2C_EN_SHIFT);
}
Contributors
| Person | Tokens | Prop | Commits | CommitProp |
haojian zhuang | haojian zhuang | 37 | 75.51% | 1 | 50.00% |
kevin liu | kevin liu | 12 | 24.49% | 1 | 50.00% |
| Total | 49 | 100.00% | 2 | 100.00% |
static int max8925_disable(struct regulator_dev *rdev)
{
struct max8925_regulator_info *info = rdev_get_drvdata(rdev);
return max8925_set_bits(info->i2c, info->enable_reg,
LDO_SEQ_MASK << LDO_SEQ_SHIFT |
LDO_I2C_EN_MASK << LDO_I2C_EN_SHIFT,
LDO_SEQ_I2C << LDO_SEQ_SHIFT);
}
Contributors
| Person | Tokens | Prop | Commits | CommitProp |
haojian zhuang | haojian zhuang | 37 | 82.22% | 2 | 66.67% |
kevin liu | kevin liu | 8 | 17.78% | 1 | 33.33% |
| Total | 45 | 100.00% | 3 | 100.00% |
static int max8925_is_enabled(struct regulator_dev *rdev)
{
struct max8925_regulator_info *info = rdev_get_drvdata(rdev);
int ldo_seq, ret;
ret = max8925_reg_read(info->i2c, info->enable_reg);
if (ret < 0)
return ret;
ldo_seq = (ret >> LDO_SEQ_SHIFT) & LDO_SEQ_MASK;
if (ldo_seq != LDO_SEQ_I2C)
return 1;
else
return ret & (LDO_I2C_EN_MASK << LDO_I2C_EN_SHIFT);
}
Contributors
| Person | Tokens | Prop | Commits | CommitProp |
haojian zhuang | haojian zhuang | 53 | 68.83% | 2 | 66.67% |
kevin liu | kevin liu | 24 | 31.17% | 1 | 33.33% |
| Total | 77 | 100.00% | 3 | 100.00% |
static int max8925_set_dvm_voltage(struct regulator_dev *rdev, int uV)
{
struct max8925_regulator_info *info = rdev_get_drvdata(rdev);
unsigned char data, mask;
if (uV < SD1_DVM_VMIN || uV > SD1_DVM_VMAX)
return -EINVAL;
data = DIV_ROUND_UP(uV - SD1_DVM_VMIN, SD1_DVM_STEP);
data <<= SD1_DVM_SHIFT;
mask = 3 << SD1_DVM_SHIFT;
return max8925_set_bits(info->i2c, info->enable_reg, mask, data);
}
Contributors
| Person | Tokens | Prop | Commits | CommitProp |
haojian zhuang | haojian zhuang | 77 | 95.06% | 1 | 50.00% |
axel lin | axel lin | 4 | 4.94% | 1 | 50.00% |
| Total | 81 | 100.00% | 2 | 100.00% |
static int max8925_set_dvm_enable(struct regulator_dev *rdev)
{
struct max8925_regulator_info *info = rdev_get_drvdata(rdev);
return max8925_set_bits(info->i2c, info->vol_reg, 1 << SD1_DVM_EN,
1 << SD1_DVM_EN);
}
Contributors
| Person | Tokens | Prop | Commits | CommitProp |
haojian zhuang | haojian zhuang | 41 | 100.00% | 1 | 100.00% |
| Total | 41 | 100.00% | 1 | 100.00% |
static int max8925_set_dvm_disable(struct regulator_dev *rdev)
{
struct max8925_regulator_info *info = rdev_get_drvdata(rdev);
return max8925_set_bits(info->i2c, info->vol_reg, 1 << SD1_DVM_EN, 0);
}
Contributors
| Person | Tokens | Prop | Commits | CommitProp |
haojian zhuang | haojian zhuang | 39 | 100.00% | 1 | 100.00% |
| Total | 39 | 100.00% | 1 | 100.00% |
static struct regulator_ops max8925_regulator_sdv_ops = {
.map_voltage = regulator_map_voltage_linear,
.list_voltage = regulator_list_voltage_linear,
.set_voltage_sel = max8925_set_voltage_sel,
.get_voltage_sel = max8925_get_voltage_sel,
.enable = max8925_enable,
.disable = max8925_disable,
.is_enabled = max8925_is_enabled,
.set_suspend_voltage = max8925_set_dvm_voltage,
.set_suspend_enable = max8925_set_dvm_enable,
.set_suspend_disable = max8925_set_dvm_disable,
};
static struct regulator_ops max8925_regulator_ldo_ops = {
.map_voltage = regulator_map_voltage_linear,
.list_voltage = regulator_list_voltage_linear,
.set_voltage_sel = max8925_set_voltage_sel,
.get_voltage_sel = max8925_get_voltage_sel,
.enable = max8925_enable,
.disable = max8925_disable,
.is_enabled = max8925_is_enabled,
};
#define MAX8925_SDV(_id, min, max, step) \
{ \
.desc = { \
.name = "SDV" #_id, \
.ops = &max8925_regulator_sdv_ops, \
.type = REGULATOR_VOLTAGE, \
.id = MAX8925_ID_SD##_id, \
.owner = THIS_MODULE, \
.n_voltages = 64, \
.min_uV = min * 1000, \
.uV_step = step * 1000, \
}, \
.vol_reg = MAX8925_SDV##_id, \
.enable_reg = MAX8925_SDCTL##_id, \
}
#define MAX8925_LDO(_id, min, max, step) \
{ \
.desc = { \
.name = "LDO" #_id, \
.ops = &max8925_regulator_ldo_ops, \
.type = REGULATOR_VOLTAGE, \
.id = MAX8925_ID_LDO##_id, \
.owner = THIS_MODULE, \
.n_voltages = 64, \
.min_uV = min * 1000, \
.uV_step = step * 1000, \
}, \
.vol_reg = MAX8925_LDOVOUT##_id, \
.enable_reg = MAX8925_LDOCTL##_id, \
}
#ifdef CONFIG_OF
static struct of_regulator_match max8925_regulator_matches[] = {
{ .name = "SDV1",},
{ .name = "SDV2",},
{ .name = "SDV3",},
{ .name = "LDO1",},
{ .name = "LDO2",},
{ .name = "LDO3",},
{ .name = "LDO4",},
{ .name = "LDO5",},
{ .name = "LDO6",},
{ .name = "LDO7",},
{ .name = "LDO8",},
{ .name = "LDO9",},
{ .name = "LDO10",},
{ .name = "LDO11",},
{ .name = "LDO12",},
{ .name = "LDO13",},
{ .name = "LDO14",},
{ .name = "LDO15",},
{ .name = "LDO16",},
{ .name = "LDO17",},
{ .name = "LDO18",},
{ .name = "LDO19",},
{ .name = "LDO20",},
};
#endif
static struct max8925_regulator_info max8925_regulator_info[] = {
MAX8925_SDV(1, 637.5, 1425, 12.5),
MAX8925_SDV(2, 650, 2225, 25),
MAX8925_SDV(3, 750, 3900, 50),
MAX8925_LDO(1, 750, 3900, 50),
MAX8925_LDO(2, 650, 2250, 25),
MAX8925_LDO(3, 650, 2250, 25),
MAX8925_LDO(4, 750, 3900, 50),
MAX8925_LDO(5, 750, 3900, 50),
MAX8925_LDO(6, 750, 3900, 50),
MAX8925_LDO(7, 750, 3900, 50),
MAX8925_LDO(8, 750, 3900, 50),
MAX8925_LDO(9, 750, 3900, 50),
MAX8925_LDO(10, 750, 3900, 50),
MAX8925_LDO(11, 750, 3900, 50),
MAX8925_LDO(12, 750, 3900, 50),
MAX8925_LDO(13, 750, 3900, 50),
MAX8925_LDO(14, 750, 3900, 50),
MAX8925_LDO(15, 750, 3900, 50),
MAX8925_LDO(16, 750, 3900, 50),
MAX8925_LDO(17, 650, 2250, 25),
MAX8925_LDO(18, 650, 2250, 25),
MAX8925_LDO(19, 750, 3900, 50),
MAX8925_LDO(20, 750, 3900, 50),
};
#ifdef CONFIG_OF
static int max8925_regulator_dt_init(struct platform_device *pdev,
struct regulator_config *config,
int ridx)
{
struct device_node *nproot, *np;
int rcount;
nproot = pdev->dev.parent->of_node;
if (!nproot)
return -ENODEV;
np = of_get_child_by_name(nproot, "regulators");
if (!np) {
dev_err(&pdev->dev, "failed to find regulators node\n");
return -ENODEV;
}
rcount = of_regulator_match(&pdev->dev, np,
&max8925_regulator_matches[ridx], 1);
of_node_put(np);
if (rcount < 0)
return rcount;
config->init_data = max8925_regulator_matches[ridx].init_data;
config->of_node = max8925_regulator_matches[ridx].of_node;
return 0;
}
Contributors
| Person | Tokens | Prop | Commits | CommitProp |
qing xu | qing xu | 131 | 94.93% | 1 | 25.00% |
axel lin | axel lin | 5 | 3.62% | 1 | 25.00% |
sachin kamat | sachin kamat | 2 | 1.45% | 2 | 50.00% |
| Total | 138 | 100.00% | 4 | 100.00% |
#else
#define max8925_regulator_dt_init(x, y, z) (-1)
#endif
static int max8925_regulator_probe(struct platform_device *pdev)
{
struct max8925_chip *chip = dev_get_drvdata(pdev->dev.parent);
struct regulator_init_data *pdata = dev_get_platdata(&pdev->dev);
struct regulator_config config = { };
struct max8925_regulator_info *ri;
struct resource *res;
struct regulator_dev *rdev;
int i, regulator_idx;
res = platform_get_resource(pdev, IORESOURCE_REG, 0);
if (!res) {
dev_err(&pdev->dev, "No REG resource!\n");
return -EINVAL;
}
for (i = 0; i < ARRAY_SIZE(max8925_regulator_info); i++) {
ri = &max8925_regulator_info[i];
if (ri->vol_reg == res->start) {
regulator_idx = i;
break;
}
}
if (i == ARRAY_SIZE(max8925_regulator_info)) {
dev_err(&pdev->dev, "Failed to find regulator %llu\n",
(unsigned long long)res->start);
return -EINVAL;
}
ri->i2c = chip->i2c;
config.dev = &pdev->dev;
config.driver_data = ri;
if (max8925_regulator_dt_init(pdev, &config, regulator_idx))
if (pdata)
config.init_data = pdata;
rdev = devm_regulator_register(&pdev->dev, &ri->desc, &config);
if (IS_ERR(rdev)) {
dev_err(&pdev->dev, "failed to register regulator %s\n",
ri->desc.name);
return PTR_ERR(rdev);
}
platform_set_drvdata(pdev, rdev);
return 0;
}
Contributors
| Person | Tokens | Prop | Commits | CommitProp |
haojian zhuang | haojian zhuang | 212 | 76.53% | 2 | 28.57% |
qing xu | qing xu | 28 | 10.11% | 1 | 14.29% |
mark brown | mark brown | 26 | 9.39% | 1 | 14.29% |
jingoo han | jingoo han | 10 | 3.61% | 2 | 28.57% |
rajendra nayak | rajendra nayak | 1 | 0.36% | 1 | 14.29% |
| Total | 277 | 100.00% | 7 | 100.00% |
static struct platform_driver max8925_regulator_driver = {
.driver = {
.name = "max8925-regulator",
},
.probe = max8925_regulator_probe,
};
static int __init max8925_regulator_init(void)
{
return platform_driver_register(&max8925_regulator_driver);
}
Contributors
| Person | Tokens | Prop | Commits | CommitProp |
haojian zhuang | haojian zhuang | 16 | 100.00% | 1 | 100.00% |
| Total | 16 | 100.00% | 1 | 100.00% |
subsys_initcall(max8925_regulator_init);
static void __exit max8925_regulator_exit(void)
{
platform_driver_unregister(&max8925_regulator_driver);
}
Contributors
| Person | Tokens | Prop | Commits | CommitProp |
haojian zhuang | haojian zhuang | 15 | 100.00% | 1 | 100.00% |
| Total | 15 | 100.00% | 1 | 100.00% |
module_exit(max8925_regulator_exit);
MODULE_LICENSE("GPL");
MODULE_AUTHOR("Haojian Zhuang <haojian.zhuang@marvell.com>");
MODULE_DESCRIPTION("Regulator Driver for Maxim 8925 PMIC");
MODULE_ALIAS("platform:max8925-regulator");
Overall Contributors
| Person | Tokens | Prop | Commits | CommitProp |
haojian zhuang | haojian zhuang | 1116 | 68.01% | 4 | 18.18% |
qing xu | qing xu | 357 | 21.76% | 1 | 4.55% |
kevin liu | kevin liu | 71 | 4.33% | 1 | 4.55% |
axel lin | axel lin | 52 | 3.17% | 8 | 36.36% |
mark brown | mark brown | 29 | 1.77% | 2 | 9.09% |
jingoo han | jingoo han | 10 | 0.61% | 2 | 9.09% |
paul gortmaker | paul gortmaker | 3 | 0.18% | 1 | 4.55% |
sachin kamat | sachin kamat | 2 | 0.12% | 2 | 9.09% |
rajendra nayak | rajendra nayak | 1 | 0.06% | 1 | 4.55% |
| Total | 1641 | 100.00% | 22 | 100.00% |
Information contained on this website is for historical information purposes only and does not indicate or represent copyright ownership.