mirror of
https://github.com/BobTheBlinker/android_kernel_motorola_sm6375.git
synced 2026-10-10 22:40:54 -04:00
Rhode4G: Implement different ldo compatibility.
Below it is the compatible ldo information. a.wl2868c. b.et5907. c.fan53870. Change-Id: I6bf57bc4420eded96410568323a720c2caafa8e2 Signed-off-by: chenzc2 <chenzc2@lenovo.com> Reviewed-on: https://gerrit.mot.com/2123413 SLTApproved: Slta Waiver SME-Granted: SME Approvals Granted Tested-by: Jira Key Reviewed-by: PengFei Qiao <qiaopf1@motorola.com> Reviewed-by: Zhuoran Xu <xuzr3@motorola.com> Reviewed-by: Jian Luan <jamesluan@motorola.com> Reviewed-by: Long Cheng <chengl1@motorola.com> Reviewed-by: Guobin Zhang <zhanggb@motorola.com> Submit-Approved: Jira Key
This commit is contained in:
parent
c1f6eacfa9
commit
400a7f952b
2 changed files with 230 additions and 143 deletions
|
|
@ -20,63 +20,64 @@
|
|||
#include <linux/regulator/machine.h>
|
||||
#include <linux/regulator/of_regulator.h>
|
||||
#include "wl2868c-regulator.h"
|
||||
//static int ldo_chipid = -1;
|
||||
|
||||
static int ldo_chipid = -1;
|
||||
enum slg51000_regulators {
|
||||
wl2868c_REGULATOR_LDO1 = 0,
|
||||
wl2868c_REGULATOR_LDO2,
|
||||
wl2868c_REGULATOR_LDO3,
|
||||
wl2868c_REGULATOR_LDO4,
|
||||
wl2868c_REGULATOR_LDO5,
|
||||
wl2868c_REGULATOR_LDO6,
|
||||
wl2868c_REGULATOR_LDO7,
|
||||
wl2868c_MAX_REGULATORS,
|
||||
WL2868C_REGULATOR_LDO1 = 0,
|
||||
WL2868C_REGULATOR_LDO2,
|
||||
WL2868C_REGULATOR_LDO3,
|
||||
WL2868C_REGULATOR_LDO4,
|
||||
WL2868C_REGULATOR_LDO5,
|
||||
WL2868C_REGULATOR_LDO6,
|
||||
WL2868C_REGULATOR_LDO7,
|
||||
WL2868C_MAX_REGULATORS,
|
||||
};
|
||||
|
||||
struct wl2868c {
|
||||
struct device *dev;
|
||||
struct regmap *regmap;
|
||||
struct regulator_desc *rdesc[wl2868c_MAX_REGULATORS];
|
||||
struct regulator_dev *rdev[wl2868c_MAX_REGULATORS];
|
||||
// int chip_irq;
|
||||
struct regulator_desc *rdesc[WL2868C_MAX_REGULATORS];
|
||||
struct regulator_dev *rdev[WL2868C_MAX_REGULATORS];
|
||||
int chip_cs_pin;
|
||||
};
|
||||
|
||||
struct wl2868c_evt_sta {
|
||||
unsigned int sreg;
|
||||
};
|
||||
|
||||
static const struct wl2868c_evt_sta wl2868c_status_reg = { wl2868c_LDO_EN };
|
||||
/*
|
||||
* struct wl2868c_evt_sta {
|
||||
* unsigned int sreg;
|
||||
* };
|
||||
*
|
||||
* static const struct wl2868c_evt_sta wl2868c_status_reg = { WL2868C_LDO_EN };
|
||||
*/
|
||||
|
||||
static unsigned int wl2868c_status_reg = WL2868C_LDO_EN;
|
||||
static const struct regmap_range wl2868c_writeable_ranges[] = {
|
||||
regmap_reg_range(wl2868c_CURRENT_LIMITSEL, wl2868c_SEQ_STATUS),
|
||||
/* Do not let useless register writeable */
|
||||
// regmap_reg_range(wl2868c_CURRENT_LIMITSEL, wl2868c_CURRENT_LIMITSEL),
|
||||
// regmap_reg_range(wl2868c_LDO1_VOUT, wl2868c_LDO7_VOUT),
|
||||
// regmap_reg_range(wl2868c_LDO_EN, wl2868c_LDO_EN),
|
||||
regmap_reg_range(WL2868C_CURRENT_LIMITSEL, WL2868C_SEQ_STATUS),
|
||||
/* Do not let useless register writeable */
|
||||
// regmap_reg_range(WL2868C_CURRENT_LIMITSEL, WL2868C_CURRENT_LIMITSEL),
|
||||
// regmap_reg_range(WL2868C_LDO1_VOUT, WL2868C_LDO7_VOUT),
|
||||
// regmap_reg_range(WL2868C_LDO_EN, WL2868C_LDO_EN),
|
||||
};
|
||||
|
||||
static const struct regmap_range wl2868c_readable_ranges[] = {
|
||||
regmap_reg_range(wl2868c_CHIP_REV, wl2868c_SEQ_STATUS),
|
||||
regmap_reg_range(WL2868C_CHIP_REV, WL2868C_SEQ_STATUS),
|
||||
};
|
||||
|
||||
static const struct regmap_range wl2868c_volatile_ranges[] = {
|
||||
regmap_reg_range(wl2868c_CURRENT_LIMITSEL, wl2868c_SEQ_STATUS),
|
||||
regmap_reg_range(WL2868C_CURRENT_LIMITSEL, WL2868C_SEQ_STATUS),
|
||||
};
|
||||
|
||||
static const struct regmap_access_table wl2868c_writeable_table = {
|
||||
.yes_ranges = wl2868c_writeable_ranges,
|
||||
.n_yes_ranges = ARRAY_SIZE(wl2868c_writeable_ranges),
|
||||
.yes_ranges = wl2868c_writeable_ranges,
|
||||
.n_yes_ranges = ARRAY_SIZE(wl2868c_writeable_ranges),
|
||||
};
|
||||
|
||||
static const struct regmap_access_table wl2868c_readable_table = {
|
||||
.yes_ranges = wl2868c_readable_ranges,
|
||||
.n_yes_ranges = ARRAY_SIZE(wl2868c_readable_ranges),
|
||||
.yes_ranges = wl2868c_readable_ranges,
|
||||
.n_yes_ranges = ARRAY_SIZE(wl2868c_readable_ranges),
|
||||
};
|
||||
|
||||
static const struct regmap_access_table wl2868c_volatile_table = {
|
||||
.yes_ranges = wl2868c_volatile_ranges,
|
||||
.n_yes_ranges = ARRAY_SIZE(wl2868c_volatile_ranges),
|
||||
.yes_ranges = wl2868c_volatile_ranges,
|
||||
.n_yes_ranges = ARRAY_SIZE(wl2868c_volatile_ranges),
|
||||
};
|
||||
|
||||
static const struct regmap_config wl2868c_regmap_config = {
|
||||
|
|
@ -91,7 +92,7 @@ static const struct regmap_config wl2868c_regmap_config = {
|
|||
static int wl2868c_get_error_flags(struct regulator_dev *rdev, unsigned int *flags)
|
||||
{
|
||||
struct wl2868c *chip = rdev_get_drvdata(rdev);
|
||||
uint8_t reg_dump[wl2868c_REG_NUM];
|
||||
uint8_t reg_dump[WL2868C_REG_NUM];
|
||||
uint8_t reg_idx;
|
||||
unsigned int val = 0;
|
||||
|
||||
|
|
@ -101,7 +102,7 @@ static int wl2868c_get_error_flags(struct regulator_dev *rdev, unsigned int *fla
|
|||
dev_err(chip->dev, "register 0x03~0x09: LDO1~LDO7 OUT Voltage\n");
|
||||
dev_err(chip->dev, "register 0x0e: Bit[6:0] LDO7~LDO1 EN\n");
|
||||
|
||||
for (reg_idx = 0; reg_idx < wl2868c_REG_NUM; reg_idx++) {
|
||||
for (reg_idx = 0; reg_idx < WL2868C_REG_NUM; reg_idx++) {
|
||||
regmap_read(chip->regmap, reg_idx, &val);
|
||||
reg_dump[reg_idx] = val;
|
||||
dev_err(chip->dev, "Reg[0x%02x] = 0x%x", reg_idx, reg_dump[reg_idx]);
|
||||
|
|
@ -123,8 +124,7 @@ static int wl2868c_get_status(struct regulator_dev *rdev)
|
|||
|
||||
ret = regulator_is_enabled_regmap(rdev);
|
||||
if (ret < 0) {
|
||||
dev_err(chip->dev, "Failed to read enable register(%d)\n",
|
||||
ret);
|
||||
dev_err(chip->dev, "Failed to read enable register(%d)\n", ret);
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
|
@ -132,13 +132,16 @@ static int wl2868c_get_status(struct regulator_dev *rdev)
|
|||
return REGULATOR_STATUS_OFF;
|
||||
|
||||
wl2868c_get_error_flags(rdev, NULL);
|
||||
|
||||
ret = regmap_read(chip->regmap, wl2868c_status_reg.sreg, &status);
|
||||
if ((ldo_chipid == 0x01) || (ldo_chipid == 0x00))
|
||||
{
|
||||
wl2868c_status_reg = fan53870_LDO_EN;
|
||||
}
|
||||
ret = regmap_read(chip->regmap, wl2868c_status_reg, &status);
|
||||
if (ret < 0) {
|
||||
dev_err(chip->dev, "Failed to read status register(%d)\n",
|
||||
ret);
|
||||
dev_err(chip->dev, "Failed to read status register(%d)\n", ret);
|
||||
return ret;
|
||||
}
|
||||
|
||||
if (status & (0x01ul << id)) {
|
||||
return REGULATOR_STATUS_ON;
|
||||
} else {
|
||||
|
|
@ -147,20 +150,22 @@ static int wl2868c_get_status(struct regulator_dev *rdev)
|
|||
}
|
||||
|
||||
static const struct regulator_ops wl2868c_regl_ops = {
|
||||
.enable = regulator_enable_regmap,
|
||||
.enable = regulator_enable_regmap,
|
||||
.disable = regulator_disable_regmap,
|
||||
|
||||
.is_enabled = regulator_is_enabled_regmap,
|
||||
|
||||
.list_voltage = regulator_list_voltage_linear,
|
||||
.map_voltage = regulator_map_voltage_linear,
|
||||
.map_voltage = regulator_map_voltage_linear,
|
||||
|
||||
.get_voltage_sel = regulator_get_voltage_sel_regmap,
|
||||
.set_voltage_sel = regulator_set_voltage_sel_regmap,
|
||||
|
||||
.get_status = wl2868c_get_status,
|
||||
.get_error_flags = wl2868c_get_error_flags,
|
||||
};
|
||||
|
||||
static int wl2868c_of_parse_cb(struct device_node *np,
|
||||
const struct regulator_desc *desc,
|
||||
struct regulator_config *config)
|
||||
static int wl2868c_of_parse_cb(struct device_node *np, const struct regulator_desc *desc, struct regulator_config *config)
|
||||
{
|
||||
int ena_gpio;
|
||||
|
||||
|
|
@ -171,11 +176,11 @@ static int wl2868c_of_parse_cb(struct device_node *np,
|
|||
return 0;
|
||||
}
|
||||
|
||||
#define wl2868c_REGL_DESC(_id, _name, _s_name, _min, _step) \
|
||||
[wl2868c_REGULATOR_##_id] = { \
|
||||
#define WL2868C_REGL_DESC(_id, _name, _s_name, _min, _step) \
|
||||
[WL2868C_REGULATOR_##_id] = { \
|
||||
.name = #_name, \
|
||||
.supply_name = _s_name, \
|
||||
.id = wl2868c_REGULATOR_##_id, \
|
||||
.id = WL2868C_REGULATOR_##_id, \
|
||||
.of_match = of_match_ptr(#_name), \
|
||||
.of_parse_cb = wl2868c_of_parse_cb, \
|
||||
.ops = &wl2868c_regl_ops, \
|
||||
|
|
@ -184,22 +189,22 @@ static int wl2868c_of_parse_cb(struct device_node *np,
|
|||
.min_uV = _min, \
|
||||
.uV_step = _step, \
|
||||
.linear_min_sel = 0, \
|
||||
.vsel_mask = wl2868c_VSEL_MASK, \
|
||||
.vsel_reg = wl2868c_##_id##_VSEL, \
|
||||
.enable_reg = wl2868c_LDO_EN, \
|
||||
.enable_mask = BIT(wl2868c_REGULATOR_##_id)|0x80, \
|
||||
.vsel_mask = WL2868C_VSEL_MASK, \
|
||||
.vsel_reg = WL2868C_##_id##_VSEL, \
|
||||
.enable_reg = WL2868C_LDO_EN, \
|
||||
.enable_mask = BIT(WL2868C_REGULATOR_##_id), \
|
||||
.type = REGULATOR_VOLTAGE, \
|
||||
.owner = THIS_MODULE, \
|
||||
}
|
||||
|
||||
static struct regulator_desc wl2868c_regls_desc[wl2868c_MAX_REGULATORS] = {
|
||||
wl2868c_REGL_DESC(LDO1, ldo1, "vin1", 496000, 8000),
|
||||
wl2868c_REGL_DESC(LDO2, ldo2, "vin1", 496000, 8000),
|
||||
wl2868c_REGL_DESC(LDO3, ldo3, "vin2", 1504000, 8000),
|
||||
wl2868c_REGL_DESC(LDO4, ldo4, "vin2", 1504000, 8000),
|
||||
wl2868c_REGL_DESC(LDO5, ldo5, "vin2", 1504000, 8000),
|
||||
wl2868c_REGL_DESC(LDO6, ldo6, "vin2", 1504000, 8000),
|
||||
wl2868c_REGL_DESC(LDO7, ldo7, "vin2", 1504000, 8000),
|
||||
static struct regulator_desc wl2868c_regls_desc[WL2868C_MAX_REGULATORS] = {
|
||||
WL2868C_REGL_DESC(LDO1, ldo1, "vin1", 496000, 8000),
|
||||
WL2868C_REGL_DESC(LDO2, ldo2, "vin1", 496000, 8000),
|
||||
WL2868C_REGL_DESC(LDO3, ldo3, "vin2", 1504000, 8000),
|
||||
WL2868C_REGL_DESC(LDO4, ldo4, "vin2", 1504000, 8000),
|
||||
WL2868C_REGL_DESC(LDO5, ldo5, "vin2", 1504000, 8000),
|
||||
WL2868C_REGL_DESC(LDO6, ldo6, "vin2", 1504000, 8000),
|
||||
WL2868C_REGL_DESC(LDO7, ldo7, "vin2", 1504000, 8000),
|
||||
};
|
||||
|
||||
static int wl2868c_regulator_init(struct wl2868c *chip)
|
||||
|
|
@ -209,17 +214,17 @@ static int wl2868c_regulator_init(struct wl2868c *chip)
|
|||
u8 vsel_range[1];
|
||||
int id, ret = 0;
|
||||
|
||||
const unsigned int ldo_regs[wl2868c_MAX_REGULATORS] = {
|
||||
wl2868c_LDO1_VOUT,
|
||||
wl2868c_LDO2_VOUT,
|
||||
wl2868c_LDO3_VOUT,
|
||||
wl2868c_LDO4_VOUT,
|
||||
wl2868c_LDO5_VOUT,
|
||||
wl2868c_LDO6_VOUT,
|
||||
wl2868c_LDO7_VOUT,
|
||||
unsigned int ldo_regs[WL2868C_MAX_REGULATORS] = {
|
||||
WL2868C_LDO1_VOUT,
|
||||
WL2868C_LDO2_VOUT,
|
||||
WL2868C_LDO3_VOUT,
|
||||
WL2868C_LDO4_VOUT,
|
||||
WL2868C_LDO5_VOUT,
|
||||
WL2868C_LDO6_VOUT,
|
||||
WL2868C_LDO7_VOUT,
|
||||
};
|
||||
|
||||
const unsigned int initial_voltage[wl2868c_MAX_REGULATORS] = {
|
||||
unsigned int initial_voltage[WL2868C_MAX_REGULATORS] = {
|
||||
0x24,//LDO1 1.05V
|
||||
0x30,//LDO2 1.2V
|
||||
0x80,//LDO3 2.8V
|
||||
|
|
@ -230,43 +235,90 @@ static int wl2868c_regulator_init(struct wl2868c *chip)
|
|||
};
|
||||
|
||||
/*Disable all ldo output by default*/
|
||||
ret = regmap_write(chip->regmap, wl2868c_LDO_EN, 0);
|
||||
if (ldo_chipid == 0x33)
|
||||
{
|
||||
ret = regmap_write(chip->regmap, WL2868C_LDO_EN, 0x80);
|
||||
}
|
||||
else if((ldo_chipid == 0x01) ||(ldo_chipid == 0x00))
|
||||
{
|
||||
ret = regmap_write(chip->regmap, fan53870_LDO_EN, 0);
|
||||
}
|
||||
|
||||
if (ret < 0) {
|
||||
dev_err(chip->dev,
|
||||
"Disable all LDO output failed!!!\n");
|
||||
dev_err(chip->dev, "Disable all LDO output failed!!!\n");
|
||||
return ret;
|
||||
}
|
||||
|
||||
for (id = 0; id < wl2868c_MAX_REGULATORS; id++) {
|
||||
//ET5907 chipid is 0x00,Fan53870 chipid is 0x01.for change min_uV and step by chip
|
||||
if (0x01 == ldo_chipid)
|
||||
{
|
||||
wl2868c_regls_desc[WL2868C_REGULATOR_LDO1].min_uV = 8000;
|
||||
wl2868c_regls_desc[WL2868C_REGULATOR_LDO1].uV_step = 8000;
|
||||
wl2868c_regls_desc[WL2868C_REGULATOR_LDO2].min_uV = 8000;
|
||||
wl2868c_regls_desc[WL2868C_REGULATOR_LDO2].uV_step = 8000;
|
||||
wl2868c_regls_desc[WL2868C_REGULATOR_LDO3].min_uV = 1372000;
|
||||
wl2868c_regls_desc[WL2868C_REGULATOR_LDO3].uV_step = 8000;
|
||||
wl2868c_regls_desc[WL2868C_REGULATOR_LDO4].min_uV = 1372000;
|
||||
wl2868c_regls_desc[WL2868C_REGULATOR_LDO4].uV_step = 8000;
|
||||
wl2868c_regls_desc[WL2868C_REGULATOR_LDO5].min_uV = 1372000;
|
||||
wl2868c_regls_desc[WL2868C_REGULATOR_LDO5].uV_step = 8000;
|
||||
wl2868c_regls_desc[WL2868C_REGULATOR_LDO6].min_uV = 1372000;
|
||||
wl2868c_regls_desc[WL2868C_REGULATOR_LDO6].uV_step = 8000;
|
||||
wl2868c_regls_desc[WL2868C_REGULATOR_LDO7].min_uV = 1372000;
|
||||
wl2868c_regls_desc[WL2868C_REGULATOR_LDO7].uV_step = 8000;
|
||||
}
|
||||
else if (0x00 == ldo_chipid)
|
||||
{
|
||||
wl2868c_regls_desc[WL2868C_REGULATOR_LDO1].min_uV = 600000;
|
||||
wl2868c_regls_desc[WL2868C_REGULATOR_LDO1].uV_step = 6000;
|
||||
wl2868c_regls_desc[WL2868C_REGULATOR_LDO2].min_uV = 600000;
|
||||
wl2868c_regls_desc[WL2868C_REGULATOR_LDO2].uV_step = 6000;
|
||||
wl2868c_regls_desc[WL2868C_REGULATOR_LDO3].min_uV = 1200000;
|
||||
wl2868c_regls_desc[WL2868C_REGULATOR_LDO3].uV_step = 10000;
|
||||
wl2868c_regls_desc[WL2868C_REGULATOR_LDO4].min_uV = 1200000;
|
||||
wl2868c_regls_desc[WL2868C_REGULATOR_LDO4].uV_step = 10000;
|
||||
wl2868c_regls_desc[WL2868C_REGULATOR_LDO5].min_uV = 1200000;
|
||||
wl2868c_regls_desc[WL2868C_REGULATOR_LDO5].uV_step = 10000;
|
||||
wl2868c_regls_desc[WL2868C_REGULATOR_LDO6].min_uV = 1200000;
|
||||
wl2868c_regls_desc[WL2868C_REGULATOR_LDO6].uV_step = 10000;
|
||||
wl2868c_regls_desc[WL2868C_REGULATOR_LDO7].min_uV = 1200000;
|
||||
wl2868c_regls_desc[WL2868C_REGULATOR_LDO7].uV_step = 10000;
|
||||
}
|
||||
|
||||
for (id = 0; id < WL2868C_MAX_REGULATORS; id++)
|
||||
{
|
||||
if ((0x01 == ldo_chipid) || (0x00 == ldo_chipid))
|
||||
{
|
||||
wl2868c_regls_desc[id].enable_reg = fan53870_LDO_EN;
|
||||
wl2868c_regls_desc[id].enable_mask = BIT(id);
|
||||
wl2868c_regls_desc[id].vsel_reg += fan53870_LDO_OFFSET;
|
||||
}
|
||||
chip->rdesc[id] = &wl2868c_regls_desc[id];
|
||||
rdesc = chip->rdesc[id];
|
||||
config.regmap = chip->regmap;
|
||||
config.dev = chip->dev;
|
||||
rdesc = chip->rdesc[id];
|
||||
config.regmap = chip->regmap;
|
||||
config.dev = chip->dev;
|
||||
config.driver_data = chip;
|
||||
|
||||
ret = regmap_bulk_read(chip->regmap, ldo_regs[id],
|
||||
vsel_range, 1);
|
||||
pr_err("wl2868c_regulator_init: LDO%d, default value:0x%x", (id+1), vsel_range[0]);
|
||||
ret = regmap_bulk_read(chip->regmap, ldo_regs[id], vsel_range, 1);
|
||||
pr_err("wl2868c_regulator_init: LDO%d, ldo_regs=0x%x default value:0x%x", (id+1),ldo_regs[id],vsel_range[0]);
|
||||
if (ret < 0) {
|
||||
dev_err(chip->dev,
|
||||
"Failed to read the ldo register\n");
|
||||
dev_err(chip->dev, "Failed to read the ldo register\n");
|
||||
return ret;
|
||||
}
|
||||
|
||||
pr_err("wl2868c_regulator_init: enable_reg0x%x, enable_mask:0x%x", wl2868c_regls_desc[id].enable_reg, wl2868c_regls_desc[id].enable_mask);
|
||||
|
||||
ret = regmap_write(chip->regmap, ldo_regs[id], initial_voltage[id]);
|
||||
if (ret < 0) {
|
||||
dev_err(chip->dev,
|
||||
"Failed to write inital voltage register\n");
|
||||
dev_err(chip->dev, "Failed to write inital voltage register\n");
|
||||
return ret;
|
||||
}
|
||||
pr_err("wl2868c_regulator_init: LDO%d, initial value:0x%x", (id+1), initial_voltage[id]);
|
||||
chip->rdev[id] = devm_regulator_register(chip->dev, rdesc,
|
||||
&config);
|
||||
|
||||
chip->rdev[id] = devm_regulator_register(chip->dev, rdesc, &config);
|
||||
if (IS_ERR(chip->rdev[id])) {
|
||||
ret = PTR_ERR(chip->rdev[id]);
|
||||
dev_err(chip->dev,
|
||||
"Failed to register regulator(%s):%d\n",
|
||||
chip->rdesc[id]->name, ret);
|
||||
dev_err(chip->dev, "Failed to register regulator(%s):%d\n", chip->rdesc[id]->name, ret);
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
|
|
@ -274,23 +326,11 @@ static int wl2868c_regulator_init(struct wl2868c *chip)
|
|||
return 0;
|
||||
}
|
||||
|
||||
static int wl2868c_i2c_probe(struct i2c_client *client,
|
||||
const struct i2c_device_id *id)
|
||||
static int wl2868c_i2c_probe(struct i2c_client *client, const struct i2c_device_id *id)
|
||||
{
|
||||
struct device *dev = &client->dev;
|
||||
struct wl2868c *chip;
|
||||
int error, cs_gpio, ret;
|
||||
|
||||
#if 0//del by zhangle
|
||||
unsigned int status = 0;
|
||||
|
||||
ldo_chipid = regmap_read(chip->regmap, wl2868c_CHIP_REV, &status);
|
||||
if (ldo_chipid != 0x82)
|
||||
{
|
||||
dev_info(chip->dev, "wl2868c_i2c addr error:%d\n", ldo_chipid);
|
||||
return -ENOMEM;
|
||||
}
|
||||
#endif
|
||||
chip = devm_kzalloc(dev, sizeof(struct wl2868c), GFP_KERNEL);
|
||||
if (!chip) {
|
||||
dev_err(chip->dev, "wl2868c_i2c_probe Memory error...\n");
|
||||
|
|
@ -298,6 +338,7 @@ static int wl2868c_i2c_probe(struct i2c_client *client,
|
|||
}
|
||||
|
||||
dev_info(chip->dev, "wl2868c_i2c_probe Enter...\n");
|
||||
|
||||
cs_gpio = of_get_named_gpio(dev->of_node, "semi,cs-gpios", 0);
|
||||
if (cs_gpio > 0) {
|
||||
if (!gpio_is_valid(cs_gpio)) {
|
||||
|
|
@ -305,11 +346,9 @@ static int wl2868c_i2c_probe(struct i2c_client *client,
|
|||
return -EPERM;
|
||||
}
|
||||
|
||||
ret = devm_gpio_request_one(dev, cs_gpio, GPIOF_OUT_INIT_HIGH,
|
||||
"wl2868c_cs_pin");
|
||||
ret = devm_gpio_request_one(dev, cs_gpio, GPIOF_OUT_INIT_HIGH, "wl2868c_cs_pin");
|
||||
if (ret) {
|
||||
dev_err(dev, "GPIO(%d) request failed(%d)\n",
|
||||
cs_gpio, ret);
|
||||
dev_err(dev, "GPIO(%d) request failed(%d)\n", cs_gpio, ret);
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
|
@ -317,16 +356,49 @@ static int wl2868c_i2c_probe(struct i2c_client *client,
|
|||
}
|
||||
|
||||
dev_info(chip->dev, "wl2868c_i2c_probe cs_gpio:%d...\n", cs_gpio);
|
||||
|
||||
mdelay(10);
|
||||
|
||||
i2c_set_clientdata(client, chip);
|
||||
chip->dev = dev;
|
||||
chip->dev = dev;
|
||||
chip->regmap = devm_regmap_init_i2c(client, &wl2868c_regmap_config);
|
||||
if (IS_ERR(chip->regmap)) {
|
||||
|
||||
regmap_read(chip->regmap, WL2868C_CHIP_REV, &ldo_chipid);
|
||||
dev_info(chip->dev, "IIC addr= 0x%x chipid=:0x%x\n", client->addr,ldo_chipid);
|
||||
//if regmap fail use a new iic addr try again.
|
||||
if ((ldo_chipid != 0x33)&&(ldo_chipid != 0x01)&& (ldo_chipid != 0x00)) {
|
||||
error = PTR_ERR(chip->regmap);
|
||||
dev_err(dev, "Failed to allocate register map: %d\n",
|
||||
dev_info(chip->dev, "retry iic init\n");
|
||||
client->addr = fan53870_ET5907_ADDR;
|
||||
i2c_set_clientdata(client, chip);
|
||||
chip->dev = dev;
|
||||
chip->regmap = devm_regmap_init_i2c(client, &wl2868c_regmap_config);
|
||||
regmap_read(chip->regmap, WL2868C_CHIP_REV, &ldo_chipid);
|
||||
if (IS_ERR(chip->regmap)) {
|
||||
error = PTR_ERR(chip->regmap);
|
||||
dev_err(dev, "Failed to allocate register map: %d\n",
|
||||
error);
|
||||
return error;
|
||||
return error;
|
||||
}
|
||||
}
|
||||
|
||||
ret = regmap_read(chip->regmap, WL2868C_CHIP_REV, &ldo_chipid);
|
||||
if (0x33 == ldo_chipid)
|
||||
{
|
||||
dev_info(chip->dev, "wl2868c chipid=:0x%x\n", ldo_chipid);
|
||||
}
|
||||
else if (0x01 == ldo_chipid)
|
||||
{
|
||||
dev_info(chip->dev, "fan53870 chipid=:0x%x\n", ldo_chipid);
|
||||
}
|
||||
else if (0x00 == ldo_chipid)
|
||||
{
|
||||
dev_info(chip->dev, "et5907 chipid=:0x%x\n", ldo_chipid);
|
||||
}
|
||||
else
|
||||
{
|
||||
dev_err(chip->dev, "ldo read chipid error...chipid=:0x%x\n",ldo_chipid);
|
||||
return -ENOMEM;
|
||||
}
|
||||
|
||||
{
|
||||
|
|
|
|||
|
|
@ -6,42 +6,57 @@
|
|||
* Author: ChengLong, Motorola Mobility LLC,
|
||||
*/
|
||||
|
||||
#ifndef __wl2868c_REGISTERS_H__
|
||||
#define __wl2868c_REGISTERS_H__
|
||||
#ifndef __WL2868C_REGISTERS_H__
|
||||
#define __WL2868C_REGISTERS_H__
|
||||
|
||||
/* Registers */
|
||||
#define wl2868c_REG_NUM (wl2868c_SEQ_STATUS - wl2868c_CHIP_REV + 1)
|
||||
#define WL2868C_REG_NUM (WL2868C_SEQ_STATUS - WL2868C_CHIP_REV + 1)
|
||||
|
||||
#define wl2868c_CHIP_REV 0x00
|
||||
#define wl2868c_CURRENT_LIMITSEL 0x01
|
||||
#define wl2868c_DISCHARGE_RESISTORS 0x02
|
||||
#define wl2868c_LDO1_VOUT 0x03
|
||||
#define wl2868c_LDO2_VOUT 0x04
|
||||
#define wl2868c_LDO3_VOUT 0x05
|
||||
#define wl2868c_LDO4_VOUT 0x06
|
||||
#define wl2868c_LDO5_VOUT 0x07
|
||||
#define wl2868c_LDO6_VOUT 0x08
|
||||
#define wl2868c_LDO7_VOUT 0x09
|
||||
#define wl2868c_LDO1_LDO2_SEQ 0x0a
|
||||
#define wl2868c_LDO3_LDO4_SEQ 0x0b
|
||||
#define wl2868c_LDO5_LDO6_SEQ 0x0c
|
||||
#define wl2868c_LDO7_SEQ 0x0d
|
||||
#define wl2868c_LDO_EN 0x0e
|
||||
#define wl2868c_SEQ_STATUS 0x0f
|
||||
#define WL2868C_CHIP_REV 0x01
|
||||
#define WL2868C_CURRENT_LIMITSEL 0x01
|
||||
#define WL2868C_DISCHARGE_RESISTORS 0x02
|
||||
|
||||
#define WL2868C_LDO1_VOUT 0x03
|
||||
#define WL2868C_LDO2_VOUT 0x04
|
||||
#define WL2868C_LDO3_VOUT 0x05
|
||||
#define WL2868C_LDO4_VOUT 0x06
|
||||
#define WL2868C_LDO5_VOUT 0x07
|
||||
#define WL2868C_LDO6_VOUT 0x08
|
||||
#define WL2868C_LDO7_VOUT 0x09
|
||||
|
||||
#define WL2868C_LDO1_LDO2_SEQ 0x0a
|
||||
#define WL2868C_LDO3_LDO4_SEQ 0x0b
|
||||
#define WL2868C_LDO5_LDO6_SEQ 0x0c
|
||||
#define WL2868C_LDO7_SEQ 0x0d
|
||||
#define WL2868C_LDO_EN 0x0e
|
||||
|
||||
#define WL2868C_SEQ_STATUS 0x0f
|
||||
|
||||
|
||||
/* wl2868c_LDO1_VSEL ~ wl2868c_LDO7_VSEL =
|
||||
#define fan53870_LDO1_VOUT 0x04
|
||||
#define fan53870_LDO2_VOUT 0x05
|
||||
#define fan53870_LDO3_VOUT 0x06
|
||||
#define fan53870_LDO4_VOUT 0x07
|
||||
#define fan53870_LDO5_VOUT 0x08
|
||||
#define fan53870_LDO6_VOUT 0x09
|
||||
#define fan53870_LDO7_VOUT 0x0a
|
||||
|
||||
#define fan53870_LDO_EN 0x03
|
||||
#define fan53870_LDO_OFFSET 0x01
|
||||
#define fan53870_ET5907_ADDR 0x35
|
||||
|
||||
/* WL2868C_LDO1_VSEL ~ WL2868C_LDO7_VSEL =
|
||||
* 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09
|
||||
*/
|
||||
#define wl2868c_LDO1_VSEL wl2868c_LDO1_VOUT
|
||||
#define wl2868c_LDO2_VSEL wl2868c_LDO2_VOUT
|
||||
#define wl2868c_LDO3_VSEL wl2868c_LDO3_VOUT
|
||||
#define wl2868c_LDO4_VSEL wl2868c_LDO4_VOUT
|
||||
#define wl2868c_LDO5_VSEL wl2868c_LDO5_VOUT
|
||||
#define wl2868c_LDO6_VSEL wl2868c_LDO6_VOUT
|
||||
#define wl2868c_LDO7_VSEL wl2868c_LDO7_VOUT
|
||||
#define WL2868C_LDO1_VSEL WL2868C_LDO1_VOUT
|
||||
#define WL2868C_LDO2_VSEL WL2868C_LDO2_VOUT
|
||||
#define WL2868C_LDO3_VSEL WL2868C_LDO3_VOUT
|
||||
#define WL2868C_LDO4_VSEL WL2868C_LDO4_VOUT
|
||||
#define WL2868C_LDO5_VSEL WL2868C_LDO5_VOUT
|
||||
#define WL2868C_LDO6_VSEL WL2868C_LDO6_VOUT
|
||||
#define WL2868C_LDO7_VSEL WL2868C_LDO7_VOUT
|
||||
|
||||
#define wl2868c_VSEL_SHIFT 0
|
||||
#define wl2868c_VSEL_MASK (0xff << 0)
|
||||
#define WL2868C_VSEL_SHIFT 0
|
||||
#define WL2868C_VSEL_MASK (0xff << 0)
|
||||
|
||||
#endif /* __wl2868c_REGISTERS_H__ */
|
||||
#endif /* __WL2868C_REGISTERS_H__ */
|
||||
|
|
|
|||
Loading…
Reference in a new issue