k1x:pmic: refactoring code to support new dcdc
support sy8810l pmic ic Change-Id: I8709bf5b9af4def2da06788f4bcac7eb31b8f76e
This commit is contained in:
@@ -106,12 +106,6 @@ enum PM853_reg {
|
||||
|
||||
#define SPACEMIT_PM853_MAX_REG 0xf1
|
||||
|
||||
#define PM853_CHIP_ID_REG \
|
||||
static const struct chip_id_reg pm853_id_reg = { \
|
||||
.reg_num = 1, \
|
||||
.device_id_reg = 0x0, \
|
||||
};
|
||||
|
||||
#define PM853_MFD_CELL \
|
||||
static const struct mfd_cell pm853[] = { \
|
||||
{ \
|
||||
@@ -316,4 +310,19 @@ static const struct regulator_desc pm853_reg[] = { \
|
||||
PM853_DESC_SWITCH(PM853_ID_LDO5_SW, "SWITCH_REG1", "vcc_sys", PM853_LDO_BUCK_EN_REG3, PM853_SW_EN_MSK), \
|
||||
};
|
||||
|
||||
#define PM853_MFD_MATCH_DATA \
|
||||
static struct mfd_match_data pm853_mfd_match_data = { \
|
||||
.regmap_cfg = &pm853_regmap_config, \
|
||||
.mfd_cells = pm853, \
|
||||
.nr_cells = ARRAY_SIZE(pm853), \
|
||||
.name = "pm853", \
|
||||
};
|
||||
|
||||
#define PM853_REGULATOR_MATCH_DATA \
|
||||
static struct regulator_match_data pm853_regulator_match_data = { \
|
||||
.desc = pm853_reg, \
|
||||
.nr_desc = ARRAY_SIZE(pm853_reg), \
|
||||
.name = "pm853", \
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
@@ -17,10 +17,8 @@ struct spacemit_pmic {
|
||||
struct i2c_client *i2c;
|
||||
struct regmap_irq_chip_data *irq_data;
|
||||
struct regmap *regmap;
|
||||
unsigned int variant;
|
||||
const struct regmap_config *regmap_cfg;
|
||||
const struct regmap_irq_chip *regmap_irq_chip;
|
||||
|
||||
/**
|
||||
* this is only used for pm853
|
||||
*/
|
||||
@@ -169,17 +167,32 @@ struct rtc_regdesc {
|
||||
} rtc_ctl;
|
||||
};
|
||||
|
||||
/* chip id */
|
||||
struct chip_id_reg {
|
||||
unsigned char device_id_reg;
|
||||
unsigned char version_id_reg;
|
||||
unsigned char user_id_reg;
|
||||
unsigned char reg_num;
|
||||
/* mfd: match data */
|
||||
struct mfd_match_data {
|
||||
const struct regmap_config *regmap_cfg;
|
||||
const struct regmap_irq_chip *regmap_irq_chip;
|
||||
const struct mfd_cell *mfd_cells;
|
||||
int nr_cells;
|
||||
const char *name;
|
||||
};
|
||||
|
||||
/* pmic ID configuration */
|
||||
#define SPM8821_ID 0x0
|
||||
#define PM853_ID 0x50
|
||||
/* regulator: match data */
|
||||
struct regulator_match_data {
|
||||
int nr_desc;
|
||||
const struct regulator_desc *desc;
|
||||
const char *name;
|
||||
};
|
||||
|
||||
/* pinctrl: match data */
|
||||
struct pinctrl_match_data {
|
||||
int nr_pin_mux;
|
||||
const char **pinmux_funcs;
|
||||
int nr_pin_fuc_desc;
|
||||
const struct pin_func_desc *pinfunc_desc;
|
||||
int nr_pin_conf_desc;
|
||||
const struct pin_config_desc *pinconf_desc;
|
||||
const char *name;
|
||||
};
|
||||
|
||||
/* common regulator defination */
|
||||
#define SPM8XX_DESC_COMMON(_id, _match, _supply, _nv, _vr, _vm, _er, _em, _lr, _ops) \
|
||||
@@ -269,5 +282,6 @@ struct chip_id_reg {
|
||||
|
||||
#include "spm8821.h"
|
||||
#include "pm853.h"
|
||||
#include "sy8810l.h"
|
||||
|
||||
#endif /* __SPACEMIT_PMIC_H__ */
|
||||
|
||||
@@ -76,14 +76,6 @@ enum SPM8821_reg {
|
||||
#define SPM8821_SWITCH_CTRL_REG 0x59
|
||||
#define SPM8821_SWTICH_EN_MASK 0x1
|
||||
|
||||
#define SPM8821_CHIP_ID_REG \
|
||||
static const struct chip_id_reg spm8821_id_reg = { \
|
||||
.reg_num = 3, \
|
||||
.device_id_reg = 0xa0, \
|
||||
.version_id_reg = 0xa1, \
|
||||
.user_id_reg = 0xa2, \
|
||||
};
|
||||
|
||||
#define SPM8821_REGMAP_CONFIG \
|
||||
static const struct regmap_config spm8821_regmap_config = { \
|
||||
.reg_bits = 8, \
|
||||
@@ -754,4 +746,31 @@ static const struct rtc_regdesc spm8821_regdesc = { \
|
||||
}, \
|
||||
};
|
||||
|
||||
#define SPM8821_MFD_MATCH_DATA \
|
||||
static struct mfd_match_data spm8821_mfd_match_data = { \
|
||||
.regmap_cfg = &spm8821_regmap_config, \
|
||||
.regmap_irq_chip = &spm8821_irq_chip, \
|
||||
.mfd_cells = spm8821, \
|
||||
.nr_cells = ARRAY_SIZE(spm8821), \
|
||||
.name = "spm8821", \
|
||||
};
|
||||
|
||||
#define SPM8821_PINCTRL_MATCH_DATA \
|
||||
static struct pinctrl_match_data spm8821_pinctrl_match_data = { \
|
||||
.nr_pin_mux = ARRAY_SIZE(spm8821_pinmux_functions), \
|
||||
.pinmux_funcs = spm8821_pinmux_functions, \
|
||||
.nr_pin_fuc_desc = ARRAY_SIZE(spm8821_pinfunc_desc), \
|
||||
.pinfunc_desc = spm8821_pinfunc_desc, \
|
||||
.nr_pin_conf_desc = ARRAY_SIZE(spm8821_pinconfig_desc), \
|
||||
.pinconf_desc = spm8821_pinconfig_desc, \
|
||||
.name = "spm8821", \
|
||||
};
|
||||
|
||||
#define SPM8821_REGULATOR_MATCH_DATA \
|
||||
static struct regulator_match_data spm8821_regulator_match_data = { \
|
||||
.nr_desc = ARRAY_SIZE(spm8821_reg), \
|
||||
.desc = spm8821_reg, \
|
||||
.name = "spm8821", \
|
||||
};
|
||||
|
||||
#endif /* __SPM8821_H__ */
|
||||
|
||||
67
include/linux/mfd/spacemit/sy8810l.h
Normal file
67
include/linux/mfd/spacemit/sy8810l.h
Normal file
@@ -0,0 +1,67 @@
|
||||
#ifndef __SY8810L_H__
|
||||
#define __SY8810L_H__
|
||||
|
||||
enum SY8810L_reg {
|
||||
SY8810L_ID_DCDC1,
|
||||
};
|
||||
|
||||
#define SPACEMIT_SY8810L_MAX_REG 0x2
|
||||
|
||||
#define SY8810L_BUCK_VSEL_MASK 0x3f
|
||||
#define SY8810L_BUCK_EN_MASK 0x80
|
||||
|
||||
#define SY8810L_BUCK_CTRL_REG 0x1
|
||||
#define SY8810L_BUCK_VSEL_REG 0x0
|
||||
|
||||
#define SY8810L_REGMAP_CONFIG \
|
||||
static const struct regmap_config sy8810l_regmap_config = { \
|
||||
.reg_bits = 8, \
|
||||
.val_bits = 8, \
|
||||
.max_register = SPACEMIT_SY8810L_MAX_REG, \
|
||||
.cache_type = REGCACHE_RBTREE, \
|
||||
};
|
||||
|
||||
/* regulator configuration */
|
||||
#define SY8810L_DESC(_id, _match, _supply, _nv, _vr, _vm, _er, _em, _lr) \
|
||||
SPM8XX_DESC_COMMON(_id, _match, _supply, _nv, _vr, _vm, _er, _em, _lr, \
|
||||
&pmic_dcdc_ldo_ops)
|
||||
|
||||
#define SY8810L_BUCK_LINER_RANGE \
|
||||
static const struct linear_range sy8810l_buck_ranges[] = { \
|
||||
REGULATOR_LINEAR_RANGE(600000, 0x0, 0x5a, 10000), \
|
||||
};
|
||||
|
||||
#define SY8810L_REGULATOR_DESC \
|
||||
static const struct regulator_desc sy8810l_reg[] = { \
|
||||
/* BUCK */ \
|
||||
SY8810L_DESC(SY8810L_ID_DCDC1, "EDCDC_REG1", "dcdc1", \
|
||||
91, SY8810L_BUCK_VSEL_REG, SY8810L_BUCK_VSEL_MASK, \
|
||||
SY8810L_BUCK_CTRL_REG, SY8810L_BUCK_EN_MASK, \
|
||||
sy8810l_buck_ranges), \
|
||||
};
|
||||
|
||||
/* mfd configuration */
|
||||
#define SY8810L_MFD_CELL \
|
||||
static const struct mfd_cell sy8810l[] = { \
|
||||
{ \
|
||||
.name = "spacemit-regulator@sy8810l", \
|
||||
.of_compatible = "pmic,regulator,sy8810l", \
|
||||
}, \
|
||||
};
|
||||
|
||||
#define SY8810L_MFD_MATCH_DATA \
|
||||
static struct mfd_match_data sy8810l_mfd_match_data = { \
|
||||
.regmap_cfg = &sy8810l_regmap_config, \
|
||||
.mfd_cells = sy8810l, \
|
||||
.nr_cells = ARRAY_SIZE(sy8810l), \
|
||||
.name = "sy8810l", \
|
||||
};
|
||||
|
||||
#define SY8810L_REGULATOR_MATCH_DATA \
|
||||
static struct regulator_match_data sy8810l_regulator_match_data = { \
|
||||
.nr_desc = ARRAY_SIZE(sy8810l_reg), \
|
||||
.desc = sy8810l_reg, \
|
||||
.name = "sy8810l", \
|
||||
};
|
||||
|
||||
#endif
|
||||
Reference in New Issue
Block a user