#include <linux/delay.h>
#include <linux/err.h>
#include <linux/interrupt.h>
#include <linux/kernel.h>
#include <linux/mfd/rohm-bd718x7.h>
#include <linux/module.h>
#include <linux/of.h>
#include <linux/platform_device.h>
#include <linux/regulator/driver.h>
#include <linux/regulator/machine.h>
#include <linux/regulator/of_regulator.h>
#include <linux/slab.h>
#define BD71847_BUCK1_STARTUP_TIME …
#define BD71847_BUCK2_STARTUP_TIME …
#define BD71847_BUCK3_STARTUP_TIME …
#define BD71847_BUCK4_STARTUP_TIME …
#define BD71847_BUCK5_STARTUP_TIME …
#define BD71847_BUCK6_STARTUP_TIME …
#define BD71847_LDO1_STARTUP_TIME …
#define BD71847_LDO2_STARTUP_TIME …
#define BD71847_LDO3_STARTUP_TIME …
#define BD71847_LDO4_STARTUP_TIME …
#define BD71847_LDO5_STARTUP_TIME …
#define BD71847_LDO6_STARTUP_TIME …
#define BD71837_BUCK1_STARTUP_TIME …
#define BD71837_BUCK2_STARTUP_TIME …
#define BD71837_BUCK3_STARTUP_TIME …
#define BD71837_BUCK4_STARTUP_TIME …
#define BD71837_BUCK5_STARTUP_TIME …
#define BD71837_BUCK6_STARTUP_TIME …
#define BD71837_BUCK7_STARTUP_TIME …
#define BD71837_BUCK8_STARTUP_TIME …
#define BD71837_LDO1_STARTUP_TIME …
#define BD71837_LDO2_STARTUP_TIME …
#define BD71837_LDO3_STARTUP_TIME …
#define BD71837_LDO4_STARTUP_TIME …
#define BD71837_LDO5_STARTUP_TIME …
#define BD71837_LDO6_STARTUP_TIME …
#define BD71837_LDO7_STARTUP_TIME …
#define BD718XX_HWOPNAME(swopname) …
#define BD718XX_OPS(name, _list_voltage, _map_voltage, _set_voltage_sel, \
_get_voltage_sel, _set_voltage_time_sel, _set_ramp_delay, \
_set_uvp, _set_ovp) … \
static const unsigned int bd718xx_ramp_delay[] = …;
static int always_enabled_by_hwstate(struct regulator_dev *rdev)
{ … }
static int never_enabled_by_hwstate(struct regulator_dev *rdev)
{ … }
static int bd71837_get_buck34_enable_hwctrl(struct regulator_dev *rdev)
{ … }
static void voltage_change_done(struct regulator_dev *rdev, unsigned int sel,
unsigned int *mask)
{ … }
static int voltage_change_prepare(struct regulator_dev *rdev, unsigned int sel,
unsigned int *mask)
{ … }
static int bd718xx_set_voltage_sel_restricted(struct regulator_dev *rdev,
unsigned int sel)
{ … }
static int bd718xx_set_voltage_sel_pickable_restricted(
struct regulator_dev *rdev, unsigned int sel)
{ … }
static int bd71837_set_voltage_sel_pickable_restricted(
struct regulator_dev *rdev, unsigned int sel)
{ … }
static const struct linear_range bd718xx_dvs_buck_volts[] = …;
static const struct linear_range bd71837_buck5_volts[] = …;
static const unsigned int bd71837_buck5_volt_range_sel[] = …;
static const struct linear_range bd71847_buck3_volts[] = …;
static const unsigned int bd71847_buck3_volt_range_sel[] = …;
static const struct linear_range bd71847_buck4_volts[] = …;
static const unsigned int bd71847_buck4_volt_range_sel[] = …;
static const struct linear_range bd71837_buck6_volts[] = …;
static const unsigned int bd718xx_3rd_nodvs_buck_volts[] = …;
static const struct linear_range bd718xx_4th_nodvs_buck_volts[] = …;
static const struct linear_range bd718xx_ldo1_volts[] = …;
static const unsigned int bd718xx_ldo1_volt_range_sel[] = …;
static const unsigned int ldo_2_volts[] = …;
static const struct linear_range bd718xx_ldo3_volts[] = …;
static const struct linear_range bd718xx_ldo4_volts[] = …;
static const struct linear_range bd71837_ldo5_volts[] = …;
static const struct linear_range bd71847_ldo5_volts[] = …;
static const unsigned int bd71847_ldo5_volt_range_sel[] = …;
static const struct linear_range bd718xx_ldo6_volts[] = …;
static const struct linear_range bd71837_ldo7_volts[] = …;
struct reg_init { … };
struct bd718xx_regulator_data { … };
static int bd718x7_xvp_sanity_check(struct regulator_dev *rdev, int lim_uV,
int severity)
{ … }
static int bd718x7_set_ldo_uvp(struct regulator_dev *rdev, int lim_uV,
int severity, bool enable)
{ … }
static int bd718x7_get_buck_prot_reg(int id, int *reg)
{ … }
static int bd718x7_get_buck_ovp_info(int id, int *reg, int *bit)
{ … }
static int bd718x7_get_buck_uvp_info(int id, int *reg, int *bit)
{ … }
static int bd718x7_set_buck_uvp(struct regulator_dev *rdev, int lim_uV,
int severity, bool enable)
{ … }
static int bd718x7_set_buck_ovp(struct regulator_dev *rdev, int lim_uV,
int severity,
bool enable)
{ … }
BD718XX_OPS(bd718xx_pickable_range_ldo_ops,
regulator_list_voltage_pickable_linear_range, NULL,
bd718xx_set_voltage_sel_pickable_restricted,
regulator_get_voltage_sel_pickable_regmap, NULL, NULL,
bd718x7_set_ldo_uvp, NULL);
static const struct regulator_ops bd718xx_ldo5_ops_hwstate = …;
BD718XX_OPS(bd718xx_pickable_range_buck_ops,
regulator_list_voltage_pickable_linear_range, NULL,
regulator_set_voltage_sel_pickable_regmap,
regulator_get_voltage_sel_pickable_regmap,
regulator_set_voltage_time_sel, NULL, bd718x7_set_buck_uvp,
bd718x7_set_buck_ovp);
BD718XX_OPS(bd718xx_ldo_regulator_ops, regulator_list_voltage_linear_range,
NULL, bd718xx_set_voltage_sel_restricted,
regulator_get_voltage_sel_regmap, NULL, NULL, bd718x7_set_ldo_uvp,
NULL);
BD718XX_OPS(bd718xx_ldo_regulator_nolinear_ops, regulator_list_voltage_table,
NULL, bd718xx_set_voltage_sel_restricted,
regulator_get_voltage_sel_regmap, NULL, NULL, bd718x7_set_ldo_uvp,
NULL);
BD718XX_OPS(bd718xx_buck_regulator_ops, regulator_list_voltage_linear_range,
NULL, regulator_set_voltage_sel_regmap,
regulator_get_voltage_sel_regmap, regulator_set_voltage_time_sel,
NULL, bd718x7_set_buck_uvp, bd718x7_set_buck_ovp);
BD718XX_OPS(bd718xx_buck_regulator_nolinear_ops, regulator_list_voltage_table,
regulator_map_voltage_ascend, regulator_set_voltage_sel_regmap,
regulator_get_voltage_sel_regmap, regulator_set_voltage_time_sel,
NULL, bd718x7_set_buck_uvp, bd718x7_set_buck_ovp);
BD718XX_OPS(bd71837_pickable_range_ldo_ops,
regulator_list_voltage_pickable_linear_range, NULL,
bd71837_set_voltage_sel_pickable_restricted,
regulator_get_voltage_sel_pickable_regmap, NULL, NULL,
bd718x7_set_ldo_uvp, NULL);
BD718XX_OPS(bd71837_pickable_range_buck_ops,
regulator_list_voltage_pickable_linear_range, NULL,
bd71837_set_voltage_sel_pickable_restricted,
regulator_get_voltage_sel_pickable_regmap,
regulator_set_voltage_time_sel, NULL, bd718x7_set_buck_uvp,
bd718x7_set_buck_ovp);
BD718XX_OPS(bd71837_ldo_regulator_ops, regulator_list_voltage_linear_range,
NULL, rohm_regulator_set_voltage_sel_restricted,
regulator_get_voltage_sel_regmap, NULL, NULL, bd718x7_set_ldo_uvp,
NULL);
BD718XX_OPS(bd71837_ldo_regulator_nolinear_ops, regulator_list_voltage_table,
NULL, rohm_regulator_set_voltage_sel_restricted,
regulator_get_voltage_sel_regmap, NULL, NULL, bd718x7_set_ldo_uvp,
NULL);
BD718XX_OPS(bd71837_buck_regulator_ops, regulator_list_voltage_linear_range,
NULL, rohm_regulator_set_voltage_sel_restricted,
regulator_get_voltage_sel_regmap, regulator_set_voltage_time_sel,
NULL, bd718x7_set_buck_uvp, bd718x7_set_buck_ovp);
BD718XX_OPS(bd71837_buck_regulator_nolinear_ops, regulator_list_voltage_table,
regulator_map_voltage_ascend, rohm_regulator_set_voltage_sel_restricted,
regulator_get_voltage_sel_regmap, regulator_set_voltage_time_sel,
NULL, bd718x7_set_buck_uvp, bd718x7_set_buck_ovp);
static const struct regulator_ops bd71837_buck34_ops_hwctrl = …;
BD718XX_OPS(bd718xx_dvs_buck_regulator_ops, regulator_list_voltage_linear_range,
NULL, regulator_set_voltage_sel_regmap,
regulator_get_voltage_sel_regmap, regulator_set_voltage_time_sel,
regulator_set_ramp_delay_regmap, bd718x7_set_buck_uvp,
bd718x7_set_buck_ovp);
static const struct reg_init bd71837_ldo5_inits[] = …;
static const struct reg_init bd71837_ldo6_inits[] = …;
static int buck_set_hw_dvs_levels(struct device_node *np,
const struct regulator_desc *desc,
struct regulator_config *cfg)
{ … }
static const struct regulator_ops *bd71847_swcontrol_ops[] = …;
static const struct regulator_ops *bd71847_hwcontrol_ops[] = …;
static struct bd718xx_regulator_data bd71847_regulators[] = …;
static const struct regulator_ops *bd71837_swcontrol_ops[] = …;
static const struct regulator_ops *bd71837_hwcontrol_ops[] = …;
static struct bd718xx_regulator_data bd71837_regulators[] = …;
static void mark_hw_controlled(struct device *dev, struct device_node *np,
struct bd718xx_regulator_data *reg_data,
unsigned int num_reg_data, int *info)
{ … }
static int setup_feedback_loop(struct device *dev, struct device_node *np,
struct bd718xx_regulator_data *reg_data,
unsigned int num_reg_data, int fb_uv)
{ … }
static int get_special_regulators(struct device *dev,
struct bd718xx_regulator_data *reg_data,
unsigned int num_reg_data, int *info)
{ … }
static int bd718xx_probe(struct platform_device *pdev)
{ … }
static const struct platform_device_id bd718x7_pmic_id[] = …;
MODULE_DEVICE_TABLE(platform, bd718x7_pmic_id);
static struct platform_driver bd718xx_regulator = …;
module_platform_driver(…) …;
MODULE_AUTHOR(…) …;
MODULE_DESCRIPTION(…) …;
MODULE_LICENSE(…) …;
MODULE_ALIAS(…) …;