Commit 933448e8 authored by Mark Brown's avatar Mark Brown

Add compatible support for RT5733

Merge series from cy_huang@richtek.com:

This series is to add the compatible support for rt5733 based on rt5739.
parents 4d8cd4d2 6f5e2858
...@@ -21,6 +21,7 @@ allOf: ...@@ -21,6 +21,7 @@ allOf:
properties: properties:
compatible: compatible:
enum: enum:
- richtek,rt5733
- richtek,rt5739 - richtek,rt5739
reg: reg:
......
...@@ -31,10 +31,17 @@ ...@@ -31,10 +31,17 @@
#define RT5739_MODEVSEL1_MASK BIT(1) #define RT5739_MODEVSEL1_MASK BIT(1)
#define RT5739_MODEVSEL0_MASK BIT(0) #define RT5739_MODEVSEL0_MASK BIT(0)
#define RT5739_VID_MASK GENMASK(7, 5) #define RT5739_VID_MASK GENMASK(7, 5)
#define RT5739_DID_MASK GENMASK(3, 0)
#define RT5739_ACTD_MASK BIT(7) #define RT5739_ACTD_MASK BIT(7)
#define RT5739_ENVSEL1_MASK BIT(1) #define RT5739_ENVSEL1_MASK BIT(1)
#define RT5739_ENVSEL0_MASK BIT(0) #define RT5739_ENVSEL0_MASK BIT(0)
#define RT5733_CHIPDIE_ID 0x1
#define RT5733_VOLT_MINUV 270000
#define RT5733_VOLT_MAXUV 1401250
#define RT5733_VOLT_STPUV 6250
#define RT5733_N_VOLTS 182
#define RT5739_VOLT_MINUV 300000 #define RT5739_VOLT_MINUV 300000
#define RT5739_VOLT_MAXUV 1300000 #define RT5739_VOLT_MAXUV 1300000
#define RT5739_VOLT_STPUV 5000 #define RT5739_VOLT_STPUV 5000
...@@ -93,8 +100,11 @@ static int rt5739_set_suspend_voltage(struct regulator_dev *rdev, int uV) ...@@ -93,8 +100,11 @@ static int rt5739_set_suspend_voltage(struct regulator_dev *rdev, int uV)
const struct regulator_desc *desc = rdev->desc; const struct regulator_desc *desc = rdev->desc;
struct regmap *regmap = rdev_get_regmap(rdev); struct regmap *regmap = rdev_get_regmap(rdev);
unsigned int reg, vsel; unsigned int reg, vsel;
int max_uV;
max_uV = desc->min_uV + desc->uV_step * (desc->n_voltages - 1);
if (uV < RT5739_VOLT_MINUV || uV > RT5739_VOLT_MAXUV) if (uV < desc->min_uV || uV > max_uV)
return -EINVAL; return -EINVAL;
if (desc->vsel_reg == RT5739_REG_NSEL0) if (desc->vsel_reg == RT5739_REG_NSEL0)
...@@ -102,7 +112,7 @@ static int rt5739_set_suspend_voltage(struct regulator_dev *rdev, int uV) ...@@ -102,7 +112,7 @@ static int rt5739_set_suspend_voltage(struct regulator_dev *rdev, int uV)
else else
reg = RT5739_REG_NSEL0; reg = RT5739_REG_NSEL0;
vsel = (uV - RT5739_VOLT_MINUV) / RT5739_VOLT_STPUV; vsel = (uV - desc->min_uV) / desc->uV_step;
return regmap_write(regmap, reg, vsel); return regmap_write(regmap, reg, vsel);
} }
...@@ -189,15 +199,12 @@ static unsigned int rt5739_of_map_mode(unsigned int mode) ...@@ -189,15 +199,12 @@ static unsigned int rt5739_of_map_mode(unsigned int mode)
} }
static void rt5739_init_regulator_desc(struct regulator_desc *desc, static void rt5739_init_regulator_desc(struct regulator_desc *desc,
bool vsel_active_high) bool vsel_active_high, u8 did)
{ {
/* Fixed */ /* Fixed */
desc->name = "rt5739-regulator"; desc->name = "rt5739-regulator";
desc->owner = THIS_MODULE; desc->owner = THIS_MODULE;
desc->ops = &rt5739_regulator_ops; desc->ops = &rt5739_regulator_ops;
desc->n_voltages = RT5739_N_VOLTS;
desc->min_uV = RT5739_VOLT_MINUV;
desc->uV_step = RT5739_VOLT_STPUV;
desc->vsel_mask = RT5739_VSEL_MASK; desc->vsel_mask = RT5739_VSEL_MASK;
desc->enable_reg = RT5739_REG_CNTL2; desc->enable_reg = RT5739_REG_CNTL2;
desc->active_discharge_reg = RT5739_REG_CNTL1; desc->active_discharge_reg = RT5739_REG_CNTL1;
...@@ -213,6 +220,20 @@ static void rt5739_init_regulator_desc(struct regulator_desc *desc, ...@@ -213,6 +220,20 @@ static void rt5739_init_regulator_desc(struct regulator_desc *desc,
desc->vsel_reg = RT5739_REG_NSEL0; desc->vsel_reg = RT5739_REG_NSEL0;
desc->enable_mask = RT5739_ENVSEL0_MASK; desc->enable_mask = RT5739_ENVSEL0_MASK;
} }
/* Assigned by CHIPDIE ID */
switch (did) {
case RT5733_CHIPDIE_ID:
desc->n_voltages = RT5733_N_VOLTS;
desc->min_uV = RT5733_VOLT_MINUV;
desc->uV_step = RT5733_VOLT_STPUV;
break;
default:
desc->n_voltages = RT5739_N_VOLTS;
desc->min_uV = RT5739_VOLT_MINUV;
desc->uV_step = RT5739_VOLT_STPUV;
break;
}
} }
static const struct regmap_config rt5739_regmap_config = { static const struct regmap_config rt5739_regmap_config = {
...@@ -258,7 +279,7 @@ static int rt5739_probe(struct i2c_client *i2c) ...@@ -258,7 +279,7 @@ static int rt5739_probe(struct i2c_client *i2c)
vsel_acth = device_property_read_bool(dev, "richtek,vsel-active-high"); vsel_acth = device_property_read_bool(dev, "richtek,vsel-active-high");
rt5739_init_regulator_desc(desc, vsel_acth); rt5739_init_regulator_desc(desc, vsel_acth, vid & RT5739_DID_MASK);
cfg.dev = dev; cfg.dev = dev;
cfg.of_node = dev_of_node(dev); cfg.of_node = dev_of_node(dev);
...@@ -271,6 +292,7 @@ static int rt5739_probe(struct i2c_client *i2c) ...@@ -271,6 +292,7 @@ static int rt5739_probe(struct i2c_client *i2c)
} }
static const struct of_device_id rt5739_device_table[] = { static const struct of_device_id rt5739_device_table[] = {
{ .compatible = "richtek,rt5733" },
{ .compatible = "richtek,rt5739" }, { .compatible = "richtek,rt5739" },
{ /* sentinel */ } { /* sentinel */ }
}; };
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment