diff options
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/regulator/Kconfig | 15 | ||||
-rw-r--r-- | drivers/regulator/Makefile | 1 | ||||
-rw-r--r-- | drivers/regulator/bd71815-regulator.c | 4 | ||||
-rw-r--r-- | drivers/regulator/core.c | 12 | ||||
-rw-r--r-- | drivers/regulator/dummy.c | 3 | ||||
-rw-r--r-- | drivers/regulator/lp872x.c | 52 | ||||
-rw-r--r-- | drivers/regulator/max8973-regulator.c | 4 | ||||
-rw-r--r-- | drivers/regulator/pwm-regulator.c | 12 | ||||
-rw-r--r-- | drivers/regulator/qcom-rpmh-regulator.c | 32 | ||||
-rw-r--r-- | drivers/regulator/qcom_smd-regulator.c | 49 | ||||
-rw-r--r-- | drivers/regulator/rtq6752-regulator.c | 18 | ||||
-rw-r--r-- | drivers/regulator/s5m8767.c | 21 | ||||
-rw-r--r-- | drivers/regulator/sy7636a-regulator.c | 2 | ||||
-rw-r--r-- | drivers/regulator/ti-abb-regulator.c | 31 | ||||
-rw-r--r-- | drivers/regulator/tps62360-regulator.c | 59 | ||||
-rw-r--r-- | drivers/regulator/tps80031-regulator.c | 753 | ||||
-rw-r--r-- | drivers/regulator/uniphier-regulator.c | 4 | ||||
-rw-r--r-- | drivers/regulator/vqmmc-ipq4019-regulator.c | 4 | ||||
-rw-r--r-- | drivers/spi/spi.c | 41 |
19 files changed, 220 insertions, 897 deletions
diff --git a/drivers/regulator/Kconfig b/drivers/regulator/Kconfig index 4fd13b06231f..6be9b1c8a615 100644 --- a/drivers/regulator/Kconfig +++ b/drivers/regulator/Kconfig @@ -609,12 +609,12 @@ config REGULATOR_MAX8952 modes ranging from 0.77V to 1.40V by 0.01V steps. config REGULATOR_MAX8973 - tristate "Maxim MAX8973 voltage regulator " + tristate "Maxim MAX8973A voltage regulator" depends on I2C depends on THERMAL && THERMAL_OF select REGMAP_I2C help - The MAXIM MAX8973 high-efficiency. three phase, DC-DC step-down + The MAXIM MAX8973A high-efficiency. three phase, DC-DC step-down switching regulator delivers up to 9A of output current. Each phase operates at a 2MHz fixed frequency with a 120 deg shift from the adjacent phase, allowing the use of small magnetic component. @@ -1181,7 +1181,7 @@ config REGULATOR_STPMIC1 config REGULATOR_TI_ABB tristate "TI Adaptive Body Bias on-chip LDO" - depends on ARCH_OMAP + depends on ARCH_OMAP || COMPILE_TEST help Select this option to support Texas Instruments' on-chip Adaptive Body Bias (ABB) LDO regulators. It is recommended that this option be @@ -1339,15 +1339,6 @@ config REGULATOR_TPS65912 help This driver supports TPS65912 voltage regulator chip. -config REGULATOR_TPS80031 - tristate "TI TPS80031/TPS80032 power regulator driver" - depends on MFD_TPS80031 - help - TPS80031/ TPS80032 Fully Integrated Power Management with Power - Path and Battery Charger. It has 5 configurable step-down - converters, 11 general purpose LDOs, VBUS generator and digital - output to control regulators. - config REGULATOR_TWL4030 tristate "TI TWL4030/TWL5030/TWL6030/TPS659x0 PMIC" depends on TWL4030_CORE diff --git a/drivers/regulator/Makefile b/drivers/regulator/Makefile index 9e382b50a5ef..b07d2a22df0b 100644 --- a/drivers/regulator/Makefile +++ b/drivers/regulator/Makefile @@ -158,7 +158,6 @@ obj-$(CONFIG_REGULATOR_TPS6524X) += tps6524x-regulator.o obj-$(CONFIG_REGULATOR_TPS6586X) += tps6586x-regulator.o obj-$(CONFIG_REGULATOR_TPS65910) += tps65910-regulator.o obj-$(CONFIG_REGULATOR_TPS65912) += tps65912-regulator.o -obj-$(CONFIG_REGULATOR_TPS80031) += tps80031-regulator.o obj-$(CONFIG_REGULATOR_TPS65132) += tps65132-regulator.o obj-$(CONFIG_REGULATOR_TWL4030) += twl-regulator.o twl6030-regulator.o obj-$(CONFIG_REGULATOR_UNIPHIER) += uniphier-regulator.o diff --git a/drivers/regulator/bd71815-regulator.c b/drivers/regulator/bd71815-regulator.c index 16edd9062ca9..acaa6607898e 100644 --- a/drivers/regulator/bd71815-regulator.c +++ b/drivers/regulator/bd71815-regulator.c @@ -461,9 +461,9 @@ static const struct regulator_ops bd7181x_led_regulator_ops = { .min_uV = (min), \ .uV_step = (step), \ .vsel_reg = (vsel), \ - .vsel_mask = 0x3f, \ + .vsel_mask = BD71815_VOLT_MASK, \ .enable_reg = (ereg), \ - .enable_mask = 0x04, \ + .enable_mask = BD71815_BUCK_RUN_ON, \ .ramp_reg = (ereg), \ .ramp_mask = BD71815_BUCK_RAMPRATE_MASK, \ .ramp_delay_table = bd7181x_ramp_table, \ diff --git a/drivers/regulator/core.c b/drivers/regulator/core.c index f4d441b1a8bf..86aa4141efa9 100644 --- a/drivers/regulator/core.c +++ b/drivers/regulator/core.c @@ -1151,9 +1151,10 @@ static int machine_constraints_voltage(struct regulator_dev *rdev, } if (current_uV < 0) { - rdev_err(rdev, - "failed to get the current voltage: %pe\n", - ERR_PTR(current_uV)); + if (current_uV != -EPROBE_DEFER) + rdev_err(rdev, + "failed to get the current voltage: %pe\n", + ERR_PTR(current_uV)); return current_uV; } @@ -1570,7 +1571,7 @@ static int set_supply(struct regulator_dev *rdev, { int err; - rdev_info(rdev, "supplied by %s\n", rdev_get_name(supply_rdev)); + rdev_dbg(rdev, "supplied by %s\n", rdev_get_name(supply_rdev)); if (!try_module_get(supply_rdev->owner)) return -ENODEV; @@ -4248,6 +4249,9 @@ int regulator_sync_voltage(struct regulator *regulator) struct regulator_voltage *voltage = ®ulator->voltage[PM_SUSPEND_ON]; int ret, min_uV, max_uV; + if (!regulator_ops_is_valid(rdev, REGULATOR_CHANGE_VOLTAGE)) + return 0; + regulator_lock(rdev); if (!rdev->desc->ops->set_voltage && diff --git a/drivers/regulator/dummy.c b/drivers/regulator/dummy.c index d8059f596391..24e586f93855 100644 --- a/drivers/regulator/dummy.c +++ b/drivers/regulator/dummy.c @@ -45,7 +45,8 @@ static int dummy_regulator_probe(struct platform_device *pdev) config.dev = &pdev->dev; config.init_data = &dummy_initdata; - dummy_regulator_rdev = regulator_register(&dummy_desc, &config); + dummy_regulator_rdev = devm_regulator_register(&pdev->dev, &dummy_desc, + &config); if (IS_ERR(dummy_regulator_rdev)) { ret = PTR_ERR(dummy_regulator_rdev); pr_err("Failed to register regulator: %d\n", ret); diff --git a/drivers/regulator/lp872x.c b/drivers/regulator/lp872x.c index e84be29533f4..35d826fe9def 100644 --- a/drivers/regulator/lp872x.c +++ b/drivers/regulator/lp872x.c @@ -10,13 +10,12 @@ #include <linux/i2c.h> #include <linux/regmap.h> #include <linux/err.h> -#include <linux/gpio.h> +#include <linux/gpio/consumer.h> #include <linux/delay.h> #include <linux/regulator/lp872x.h> #include <linux/regulator/driver.h> #include <linux/platform_device.h> #include <linux/of.h> -#include <linux/of_gpio.h> #include <linux/regulator/of_regulator.h> /* Registers : LP8720/8725 shared */ @@ -104,7 +103,7 @@ struct lp872x { enum lp872x_id chipid; struct lp872x_platform_data *pdata; int num_regulators; - enum lp872x_dvs_state dvs_pin; + enum gpiod_flags dvs_pin; }; /* LP8720/LP8725 shared voltage table for LDOs */ @@ -250,12 +249,12 @@ static int lp872x_regulator_enable_time(struct regulator_dev *rdev) } static void lp872x_set_dvs(struct lp872x *lp, enum lp872x_dvs_sel dvs_sel, - int gpio) + struct gpio_desc *gpio) { - enum lp872x_dvs_state state; + enum gpiod_flags state; - state = dvs_sel == SEL_V1 ? DVS_HIGH : DVS_LOW; - gpio_set_value(gpio, state); + state = dvs_sel == SEL_V1 ? GPIOD_OUT_HIGH : GPIOD_OUT_LOW; + gpiod_set_value(gpio, state); lp->dvs_pin = state; } @@ -270,7 +269,7 @@ static u8 lp872x_select_buck_vout_addr(struct lp872x *lp, switch (buck) { case LP8720_ID_BUCK: if (val & LP8720_EXT_DVS_M) { - addr = (lp->dvs_pin == DVS_HIGH) ? + addr = (lp->dvs_pin == GPIOD_OUT_HIGH) ? LP8720_BUCK_VOUT1 : LP8720_BUCK_VOUT2; } else { if (lp872x_read_byte(lp, LP8720_ENABLE, &val)) @@ -284,7 +283,7 @@ static u8 lp872x_select_buck_vout_addr(struct lp872x *lp, if (val & LP8725_DVS1_M) addr = LP8725_BUCK1_VOUT1; else - addr = (lp->dvs_pin == DVS_HIGH) ? + addr = (lp->dvs_pin == GPIOD_OUT_HIGH) ? LP8725_BUCK1_VOUT1 : LP8725_BUCK1_VOUT2; break; case LP8725_ID_BUCK2: @@ -321,7 +320,7 @@ static int lp872x_buck_set_voltage_sel(struct regulator_dev *rdev, u8 addr, mask = LP872X_VOUT_M; struct lp872x_dvs *dvs = lp->pdata ? lp->pdata->dvs : NULL; - if (dvs && gpio_is_valid(dvs->gpio)) + if (dvs && dvs->gpio) lp872x_set_dvs(lp, dvs->vsel, dvs->gpio); addr = lp872x_select_buck_vout_addr(lp, buck); @@ -675,24 +674,23 @@ static const struct regulator_desc lp8725_regulator_desc[] = { static int lp872x_init_dvs(struct lp872x *lp) { - int ret, gpio; struct lp872x_dvs *dvs = lp->pdata ? lp->pdata->dvs : NULL; - enum lp872x_dvs_state pinstate; + enum gpiod_flags pinstate; u8 mask[] = { LP8720_EXT_DVS_M, LP8725_DVS1_M | LP8725_DVS2_M }; u8 default_dvs_mode[] = { LP8720_DEFAULT_DVS, LP8725_DEFAULT_DVS }; if (!dvs) goto set_default_dvs_mode; - gpio = dvs->gpio; - if (!gpio_is_valid(gpio)) + if (!dvs->gpio) goto set_default_dvs_mode; pinstate = dvs->init_state; - ret = devm_gpio_request_one(lp->dev, gpio, pinstate, "LP872X DVS"); - if (ret) { - dev_err(lp->dev, "gpio request err: %d\n", ret); - return ret; + dvs->gpio = devm_gpiod_get_optional(lp->dev, "ti,dvs", pinstate); + + if (IS_ERR(dvs->gpio)) { + dev_err(lp->dev, "gpio request err: %ld\n", PTR_ERR(dvs->gpio)); + return PTR_ERR(dvs->gpio); } lp->dvs_pin = pinstate; @@ -706,20 +704,17 @@ set_default_dvs_mode: static int lp872x_hw_enable(struct lp872x *lp) { - int ret, gpio; - if (!lp->pdata) return -EINVAL; - gpio = lp->pdata->enable_gpio; - if (!gpio_is_valid(gpio)) + if (!lp->pdata->enable_gpio) return 0; /* Always set enable GPIO high. */ - ret = devm_gpio_request_one(lp->dev, gpio, GPIOF_OUT_INIT_HIGH, "LP872X EN"); - if (ret) { - dev_err(lp->dev, "gpio request err: %d\n", ret); - return ret; + lp->pdata->enable_gpio = devm_gpiod_get_optional(lp->dev, "enable", GPIOD_OUT_HIGH); + if (IS_ERR(lp->pdata->enable_gpio)) { + dev_err(lp->dev, "gpio request err: %ld\n", PTR_ERR(lp->pdata->enable_gpio)); + return PTR_ERR(lp->pdata->enable_gpio); } /* Each chip has a different enable delay. */ @@ -844,12 +839,9 @@ static struct lp872x_platform_data if (!pdata->dvs) return ERR_PTR(-ENOMEM); - pdata->dvs->gpio = of_get_named_gpio(np, "ti,dvs-gpio", 0); of_property_read_u8(np, "ti,dvs-vsel", (u8 *)&pdata->dvs->vsel); of_property_read_u8(np, "ti,dvs-state", &dvs_state); - pdata->dvs->init_state = dvs_state ? DVS_HIGH : DVS_LOW; - - pdata->enable_gpio = of_get_named_gpio(np, "enable-gpios", 0); + pdata->dvs->init_state = dvs_state ? GPIOD_OUT_HIGH : GPIOD_OUT_LOW; if (of_get_child_count(np) == 0) goto out; diff --git a/drivers/regulator/max8973-regulator.c b/drivers/regulator/max8973-regulator.c index 8da8f9b6c4fd..80b65cb87cef 100644 --- a/drivers/regulator/max8973-regulator.c +++ b/drivers/regulator/max8973-regulator.c @@ -1,7 +1,7 @@ /* - * max8973-regulator.c -- Maxim max8973 + * max8973-regulator.c -- Maxim max8973A * - * Regulator driver for MAXIM 8973 DC-DC step-down switching regulator. + * Regulator driver for MAXIM 8973A DC-DC step-down switching regulator. * * Copyright (c) 2012, NVIDIA Corporation. * diff --git a/drivers/regulator/pwm-regulator.c b/drivers/regulator/pwm-regulator.c index 7629476d94ae..b9eeaff1c661 100644 --- a/drivers/regulator/pwm-regulator.c +++ b/drivers/regulator/pwm-regulator.c @@ -352,15 +352,9 @@ static int pwm_regulator_probe(struct platform_device *pdev) config.init_data = init_data; drvdata->pwm = devm_pwm_get(&pdev->dev, NULL); - if (IS_ERR(drvdata->pwm)) { - ret = PTR_ERR(drvdata->pwm); - if (ret == -EPROBE_DEFER) - dev_dbg(&pdev->dev, - "Failed to get PWM, deferring probe\n"); - else - dev_err(&pdev->dev, "Failed to get PWM: %d\n", ret); - return ret; - } + if (IS_ERR(drvdata->pwm)) + return dev_err_probe(&pdev->dev, PTR_ERR(drvdata->pwm), + "Failed to get PWM\n"); if (init_data->constraints.boot_on || init_data->constraints.always_on) gpio_flags = GPIOD_OUT_HIGH; diff --git a/drivers/regulator/qcom-rpmh-regulator.c b/drivers/regulator/qcom-rpmh-regulator.c index 7f458d510483..12425f667c00 100644 --- a/drivers/regulator/qcom-rpmh-regulator.c +++ b/drivers/regulator/qcom-rpmh-regulator.c @@ -1047,6 +1047,34 @@ static const struct rpmh_vreg_init_data pm6150l_vreg_data[] = { {} }; +static const struct rpmh_vreg_init_data pm6350_vreg_data[] = { + RPMH_VREG("smps1", "smp%s1", &pmic5_ftsmps510, NULL), + RPMH_VREG("smps2", "smp%s2", &pmic5_hfsmps510, NULL), + /* smps3 - smps5 not configured */ + RPMH_VREG("ldo1", "ldo%s1", &pmic5_nldo, NULL), + RPMH_VREG("ldo2", "ldo%s2", &pmic5_pldo, NULL), + RPMH_VREG("ldo3", "ldo%s3", &pmic5_pldo, NULL), + RPMH_VREG("ldo4", "ldo%s4", &pmic5_nldo, NULL), + RPMH_VREG("ldo5", "ldo%s5", &pmic5_pldo, NULL), + RPMH_VREG("ldo6", "ldo%s6", &pmic5_pldo, NULL), + RPMH_VREG("ldo7", "ldo%s7", &pmic5_pldo, NULL), + RPMH_VREG("ldo8", "ldo%s8", &pmic5_pldo, NULL), + RPMH_VREG("ldo9", "ldo%s9", &pmic5_pldo, NULL), + RPMH_VREG("ldo10", "ldo%s10", &pmic5_pldo, NULL), + RPMH_VREG("ldo11", "ldo%s11", &pmic5_pldo, NULL), + RPMH_VREG("ldo12", "ldo%s12", &pmic5_pldo, NULL), + RPMH_VREG("ldo13", "ldo%s13", &pmic5_nldo, NULL), + RPMH_VREG("ldo14", "ldo%s14", &pmic5_pldo, NULL), + RPMH_VREG("ldo15", "ldo%s15", &pmic5_nldo, NULL), + RPMH_VREG("ldo16", "ldo%s16", &pmic5_nldo, NULL), + /* ldo17 not configured */ + RPMH_VREG("ldo18", "ldo%s18", &pmic5_nldo, NULL), + RPMH_VREG("ldo19", "ldo%s19", &pmic5_nldo, NULL), + RPMH_VREG("ldo20", "ldo%s20", &pmic5_nldo, NULL), + RPMH_VREG("ldo21", "ldo%s21", &pmic5_nldo, NULL), + RPMH_VREG("ldo22", "ldo%s22", &pmic5_nldo, NULL), +}; + static const struct rpmh_vreg_init_data pmx55_vreg_data[] = { RPMH_VREG("smps1", "smp%s1", &pmic5_ftsmps510, "vdd-s1"), RPMH_VREG("smps2", "smp%s2", &pmic5_hfsmps510, "vdd-s2"), @@ -1202,6 +1230,10 @@ static const struct of_device_id __maybe_unused rpmh_regulator_match_table[] = { .data = pm6150l_vreg_data, }, { + .compatible = "qcom,pm6350-rpmh-regulators", + .data = pm6350_vreg_data, + }, + { .compatible = "qcom,pmc8180-rpmh-regulators", .data = pm8150_vreg_data, }, diff --git a/drivers/regulator/qcom_smd-regulator.c b/drivers/regulator/qcom_smd-regulator.c index 198fcc6551f6..8bac024dde8b 100644 --- a/drivers/regulator/qcom_smd-regulator.c +++ b/drivers/regulator/qcom_smd-regulator.c @@ -738,6 +738,24 @@ static const struct regulator_desc mp5496_ldoa2 = { .ops = &rpm_mp5496_ops, }; +static const struct regulator_desc pm2250_lvftsmps = { + .linear_ranges = (struct linear_range[]) { + REGULATOR_LINEAR_RANGE(320000, 0, 269, 4000), + }, + .n_linear_ranges = 1, + .n_voltages = 270, + .ops = &rpm_smps_ldo_ops, +}; + +static const struct regulator_desc pm2250_ftsmps = { + .linear_ranges = (struct linear_range[]) { + REGULATOR_LINEAR_RANGE(640000, 0, 269, 8000), + }, + .n_linear_ranges = 1, + .n_voltages = 270, + .ops = &rpm_smps_ldo_ops, +}; + struct rpm_regulator_data { const char *name; u32 type; @@ -1170,6 +1188,36 @@ static const struct rpm_regulator_data rpm_pms405_regulators[] = { {} }; +static const struct rpm_regulator_data rpm_pm2250_regulators[] = { + { "s1", QCOM_SMD_RPM_SMPA, 1, &pm2250_lvftsmps, "vdd_s1" }, + { "s2", QCOM_SMD_RPM_SMPA, 2, &pm2250_lvftsmps, "vdd_s2" }, + { "s3", QCOM_SMD_RPM_SMPA, 3, &pm2250_lvftsmps, "vdd_s3" }, + { "s4", QCOM_SMD_RPM_SMPA, 4, &pm2250_ftsmps, "vdd_s4" }, + { "l1", QCOM_SMD_RPM_LDOA, 1, &pm660_nldo660, "vdd_l1_l2_l3_l5_l6_l7_l8_l9_l10_l11_l12" }, + { "l2", QCOM_SMD_RPM_LDOA, 2, &pm660_nldo660, "vdd_l1_l2_l3_l5_l6_l7_l8_l9_l10_l11_l12" }, + { "l3", QCOM_SMD_RPM_LDOA, 3, &pm660_nldo660, "vdd_l1_l2_l3_l5_l6_l7_l8_l9_l10_l11_l12" }, + { "l4", QCOM_SMD_RPM_LDOA, 4, &pm660_pldo660, "vdd_l4_l17_l18_l19_l20_l21_l22" }, + { "l5", QCOM_SMD_RPM_LDOA, 5, &pm660_nldo660, "vdd_l1_l2_l3_l5_l6_l7_l8_l9_l10_l11_l12" }, + { "l6", QCOM_SMD_RPM_LDOA, 6, &pm660_nldo660, "vdd_l1_l2_l3_l5_l6_l7_l8_l9_l10_l11_l12" }, + { "l7", QCOM_SMD_RPM_LDOA, 7, &pm660_nldo660, "vdd_l1_l2_l3_l5_l6_l7_l8_l9_l10_l11_l12" }, + { "l8", QCOM_SMD_RPM_LDOA, 8, &pm660_nldo660, "vdd_l1_l2_l3_l5_l6_l7_l8_l9_l10_l11_l12" }, + { "l9", QCOM_SMD_RPM_LDOA, 9, &pm660_nldo660, "vdd_l1_l2_l3_l5_l6_l7_l8_l9_l10_l11_l12" }, + { "l10", QCOM_SMD_RPM_LDOA, 10, &pm660_nldo660, "vdd_l1_l2_l3_l5_l6_l7_l8_l9_l10_l11_l12" }, + { "l11", QCOM_SMD_RPM_LDOA, 11, &pm660_nldo660, "vdd_l1_l2_l3_l5_l6_l7_l8_l9_l10_l11_l12" }, + { "l12", QCOM_SMD_RPM_LDOA, 12, &pm660_nldo660, "vdd_l1_l2_l3_l5_l6_l7_l8_l9_l10_l11_l12" }, + { "l13", QCOM_SMD_RPM_LDOA, 13, &pm660_ht_lvpldo, "vdd_l13_l14_l15_l16" }, + { "l14", QCOM_SMD_RPM_LDOA, 14, &pm660_ht_lvpldo, "vdd_l13_l14_l15_l16" }, + { "l15", QCOM_SMD_RPM_LDOA, 15, &pm660_ht_lvpldo, "vdd_l13_l14_l15_l16" }, + { "l16", QCOM_SMD_RPM_LDOA, 16, &pm660_ht_lvpldo, "vdd_l13_l14_l15_l16" }, + { "l17", QCOM_SMD_RPM_LDOA, 17, &pm660_pldo660, "vdd_l4_l17_l18_l19_l20_l21_l22" }, + { "l18", QCOM_SMD_RPM_LDOA, 18, &pm660_pldo660, "vdd_l4_l17_l18_l19_l20_l21_l22" }, + { "l19", QCOM_SMD_RPM_LDOA, 19, &pm660_pldo660, "vdd_l4_l17_l18_l19_l20_l21_l22" }, + { "l20", QCOM_SMD_RPM_LDOA, 20, &pm660_pldo660, "vdd_l4_l17_l18_l19_l20_l21_l22" }, + { "l21", QCOM_SMD_RPM_LDOA, 21, &pm660_pldo660, "vdd_l4_l17_l18_l19_l20_l21_l22" }, + { "l22", QCOM_SMD_RPM_LDOA, 22, &pm660_pldo660, "vdd_l4_l17_l18_l19_l20_l21_l22" }, + {} +}; + static const struct of_device_id rpm_of_match[] = { { .compatible = "qcom,rpm-mp5496-regulators", .data = &rpm_mp5496_regulators }, { .compatible = "qcom,rpm-pm8841-regulators", .data = &rpm_pm8841_regulators }, @@ -1186,6 +1234,7 @@ static const struct of_device_id rpm_of_match[] = { { .compatible = "qcom,rpm-pmi8994-regulators", .data = &rpm_pmi8994_regulators }, { .compatible = "qcom,rpm-pmi8998-regulators", .data = &rpm_pmi8998_regulators }, { .compatible = "qcom,rpm-pms405-regulators", .data = &rpm_pms405_regulators }, + { .compatible = "qcom,rpm-pm2250-regulators", .data = &rpm_pm2250_regulators }, {} }; MODULE_DEVICE_TABLE(of, rpm_of_match); diff --git a/drivers/regulator/rtq6752-regulator.c b/drivers/regulator/rtq6752-regulator.c index 609d3fcf4923..dfe45fb67353 100644 --- a/drivers/regulator/rtq6752-regulator.c +++ b/drivers/regulator/rtq6752-regulator.c @@ -54,14 +54,14 @@ static int rtq6752_set_vdd_enable(struct regulator_dev *rdev) int rid = rdev_get_id(rdev), ret; mutex_lock(&priv->lock); - if (priv->enable_gpio) { - gpiod_set_value(priv->enable_gpio, 1); + if (!priv->enable_flag) { + if (priv->enable_gpio) { + gpiod_set_value(priv->enable_gpio, 1); - usleep_range(RTQ6752_I2CRDY_TIMEUS, - RTQ6752_I2CRDY_TIMEUS + 100); - } + usleep_range(RTQ6752_I2CRDY_TIMEUS, + RTQ6752_I2CRDY_TIMEUS + 100); + } - if (!priv->enable_flag) { regcache_cache_only(priv->regmap, false); ret = regcache_sync(priv->regmap); if (ret) { @@ -91,11 +91,11 @@ static int rtq6752_set_vdd_disable(struct regulator_dev *rdev) if (!priv->enable_flag) { regcache_cache_only(priv->regmap, true); regcache_mark_dirty(priv->regmap); - } - if (priv->enable_gpio) - gpiod_set_value(priv->enable_gpio, 0); + if (priv->enable_gpio) + gpiod_set_value(priv->enable_gpio, 0); + } mutex_unlock(&priv->lock); return 0; diff --git a/drivers/regulator/s5m8767.c b/drivers/regulator/s5m8767.c index 7c111bbdc2af..35269f998210 100644 --- a/drivers/regulator/s5m8767.c +++ b/drivers/regulator/s5m8767.c @@ -850,18 +850,15 @@ static int s5m8767_pmic_probe(struct platform_device *pdev) /* DS4 GPIO */ gpio_direction_output(pdata->buck_ds[2], 0x0); - if (pdata->buck2_gpiodvs || pdata->buck3_gpiodvs || - pdata->buck4_gpiodvs) { - regmap_update_bits(s5m8767->iodev->regmap_pmic, - S5M8767_REG_BUCK2CTRL, 1 << 1, - (pdata->buck2_gpiodvs) ? (1 << 1) : (0 << 1)); - regmap_update_bits(s5m8767->iodev->regmap_pmic, - S5M8767_REG_BUCK3CTRL, 1 << 1, - (pdata->buck3_gpiodvs) ? (1 << 1) : (0 << 1)); - regmap_update_bits(s5m8767->iodev->regmap_pmic, - S5M8767_REG_BUCK4CTRL, 1 << 1, - (pdata->buck4_gpiodvs) ? (1 << 1) : (0 << 1)); - } + regmap_update_bits(s5m8767->iodev->regmap_pmic, + S5M8767_REG_BUCK2CTRL, 1 << 1, + (pdata->buck2_gpiodvs) ? (1 << 1) : (0 << 1)); + regmap_update_bits(s5m8767->iodev->regmap_pmic, + S5M8767_REG_BUCK3CTRL, 1 << 1, + (pdata->buck3_gpiodvs) ? (1 << 1) : (0 << 1)); + regmap_update_bits(s5m8767->iodev->regmap_pmic, + S5M8767_REG_BUCK4CTRL, 1 << 1, + (pdata->buck4_gpiodvs) ? (1 << 1) : (0 << 1)); /* Initialize GPIO DVS registers */ for (i = 0; i < 8; i++) { diff --git a/drivers/regulator/sy7636a-regulator.c b/drivers/regulator/sy7636a-regulator.c index 8360b3947ead..22fddf868e4c 100644 --- a/drivers/regulator/sy7636a-regulator.c +++ b/drivers/regulator/sy7636a-regulator.c @@ -70,7 +70,7 @@ static const struct regulator_desc desc = { static int sy7636a_regulator_probe(struct platform_device *pdev) { - struct regmap *regmap = dev_get_drvdata(pdev->dev.parent); + struct regmap *regmap = dev_get_regmap(pdev->dev.parent, NULL); struct regulator_config config = { }; struct regulator_dev *rdev; struct gpio_desc *gdp; diff --git a/drivers/regulator/ti-abb-regulator.c b/drivers/regulator/ti-abb-regulator.c index 9f0a4d50cead..2931a0b89bff 100644 --- a/drivers/regulator/ti-abb-regulator.c +++ b/drivers/regulator/ti-abb-regulator.c @@ -725,9 +725,7 @@ static int ti_abb_probe(struct platform_device *pdev) /* Map ABB resources */ if (abb->regs->setup_off || abb->regs->control_off) { - pname = "base-address"; - res = platform_get_resource_byname(pdev, IORESOURCE_MEM, pname); - abb->base = devm_ioremap_resource(dev, res); + abb->base = devm_platform_ioremap_resource_byname(pdev, "base-address"); if (IS_ERR(abb->base)) return PTR_ERR(abb->base); @@ -735,35 +733,18 @@ static int ti_abb_probe(struct platform_device *pdev) abb->control_reg = abb->base + abb->regs->control_off; } else { - pname = "control-address"; - res = platform_get_resource_byname(pdev, IORESOURCE_MEM, pname); - abb->control_reg = devm_ioremap_resource(dev, res); + abb->control_reg = devm_platform_ioremap_resource_byname(pdev, "control-address"); if (IS_ERR(abb->control_reg)) return PTR_ERR(abb->control_reg); - pname = "setup-address"; - res = platform_get_resource_byname(pdev, IORESOURCE_MEM, pname); - abb->setup_reg = devm_ioremap_resource(dev, res); + abb->setup_reg = devm_platform_ioremap_resource_byname(pdev, "setup-address"); if (IS_ERR(abb->setup_reg)) return PTR_ERR(abb->setup_reg); } - pname = "int-address"; - res = platform_get_resource_byname(pdev, IORESOURCE_MEM, pname); - if (!res) { - dev_err(dev, "Missing '%s' IO resource\n", pname); - return -ENODEV; - } - /* - * We may have shared interrupt register offsets which are - * write-1-to-clear between domains ensuring exclusivity. - */ - abb->int_base = devm_ioremap(dev, res->start, - resource_size(res)); - if (!abb->int_base) { - dev_err(dev, "Unable to map '%s'\n", pname); - return -ENOMEM; - } + abb->int_base = devm_platform_ioremap_resource_byname(pdev, "int-address"); + if (IS_ERR(abb->int_base)) + return PTR_ERR(abb->int_base); /* Map Optional resources */ pname = "efuse-address"; diff --git a/drivers/regulator/tps62360-regulator.c b/drivers/regulator/tps62360-regulator.c index 315cd5daf480..574958690ace 100644 --- a/drivers/regulator/tps62360-regulator.c +++ b/drivers/regulator/tps62360-regulator.c @@ -28,13 +28,12 @@ #include <linux/err.h> #include <linux/of.h> #include <linux/of_device.h> -#include <linux/of_gpio.h> #include <linux/regulator/of_regulator.h> #include <linux/platform_device.h> #include <linux/regulator/driver.h> #include <linux/regulator/machine.h> #include <linux/regulator/tps62360.h> -#include <linux/gpio.h> +#include <linux/gpio/consumer.h> #include <linux/i2c.h> #include <linux/slab.h> #include <linux/regmap.h> @@ -65,8 +64,8 @@ struct tps62360_chip { struct regulator_desc desc; struct regulator_dev *rdev; struct regmap *regmap; - int vsel0_gpio; - int vsel1_gpio; + struct gpio_desc *vsel0_gpio; + struct gpio_desc *vsel1_gpio; u8 voltage_reg_mask; bool en_internal_pulldn; bool en_discharge; @@ -165,8 +164,8 @@ static int tps62360_dcdc_set_voltage_sel(struct regulator_dev *dev, /* Select proper VSET register vio gpios */ if (tps->valid_gpios) { - gpio_set_value_cansleep(tps->vsel0_gpio, new_vset_id & 0x1); - gpio_set_value_cansleep(tps->vsel1_gpio, + gpiod_set_value_cansleep(tps->vsel0_gpio, new_vset_id & 0x1); + gpiod_set_value_cansleep(tps->vsel1_gpio, (new_vset_id >> 1) & 0x1); } return 0; @@ -310,9 +309,6 @@ static struct tps62360_regulator_platform_data * return NULL; } - pdata->vsel0_gpio = of_get_named_gpio(np, "vsel0-gpio", 0); - pdata->vsel1_gpio = of_get_named_gpio(np, "vsel1-gpio", 0); - if (of_find_property(np, "ti,vsel0-state-high", NULL)) pdata->vsel0_def_state = 1; @@ -349,6 +345,7 @@ static int tps62360_probe(struct i2c_client *client, int ret; int i; int chip_id; + int gpio_flags; pdata = dev_get_platdata(&client->dev); @@ -390,8 +387,6 @@ static int tps62360_probe(struct i2c_client *client, tps->en_discharge = pdata->en_discharge; tps->en_internal_pulldn = pdata->en_internal_pulldn; - tps->vsel0_gpio = pdata->vsel0_gpio; - tps->vsel1_gpio = pdata->vsel1_gpio; tps->dev = &client->dev; switch (chip_id) { @@ -426,29 +421,27 @@ static int tps62360_probe(struct i2c_client *client, tps->lru_index[0] = tps->curr_vset_id; tps->valid_gpios = false; - if (gpio_is_valid(tps->vsel0_gpio) && gpio_is_valid(tps->vsel1_gpio)) { - int gpio_flags; - gpio_flags = (pdata->vsel0_def_state) ? - GPIOF_OUT_INIT_HIGH : GPIOF_OUT_INIT_LOW; - ret = devm_gpio_request_one(&client->dev, tps->vsel0_gpio, - gpio_flags, "tps62360-vsel0"); - if (ret) { - dev_err(&client->dev, - "%s(): Could not obtain vsel0 GPIO %d: %d\n", - __func__, tps->vsel0_gpio, ret); - return ret; - } + gpio_flags = (pdata->vsel0_def_state) ? + GPIOD_OUT_HIGH : GPIOD_OUT_LOW; + tps->vsel0_gpio = devm_gpiod_get_optional(&client->dev, "vsel0", gpio_flags); + if (IS_ERR(tps->vsel0_gpio)) { + dev_err(&client->dev, + "%s(): Could not obtain vsel0 GPIO: %ld\n", + __func__, PTR_ERR(tps->vsel0_gpio)); + return PTR_ERR(tps->vsel0_gpio); + } - gpio_flags = (pdata->vsel1_def_state) ? - GPIOF_OUT_INIT_HIGH : GPIOF_OUT_INIT_LOW; - ret = devm_gpio_request_one(&client->dev, tps->vsel1_gpio, - gpio_flags, "tps62360-vsel1"); - if (ret) { - dev_err(&client->dev, - "%s(): Could not obtain vsel1 GPIO %d: %d\n", - __func__, tps->vsel1_gpio, ret); - return ret; - } + gpio_flags = (pdata->vsel1_def_state) ? + GPIOD_OUT_HIGH : GPIOD_OUT_LOW; + tps->vsel1_gpio = devm_gpiod_get_optional(&client->dev, "vsel1", gpio_flags); + if (IS_ERR(tps->vsel1_gpio)) { + dev_err(&client->dev, + "%s(): Could not obtain vsel1 GPIO: %ld\n", + __func__, PTR_ERR(tps->vsel1_gpio)); + return PTR_ERR(tps->vsel1_gpio); + } + + if (tps->vsel0_gpio != NULL && tps->vsel1_gpio != NULL) { tps->valid_gpios = true; /* diff --git a/drivers/regulator/tps80031-regulator.c b/drivers/regulator/tps80031-regulator.c deleted file mode 100644 index a29e65230132..000000000000 --- a/drivers/regulator/tps80031-regulator.c +++ /dev/null @@ -1,753 +0,0 @@ -// SPDX-License-Identifier: GPL-2.0 -// -// tps80031-regulator.c -- TI TPS80031 regulator driver. -// -// Regulator driver for TI TPS80031/TPS80032 Fully Integrated Power -// Management with Power Path and Battery Charger. -// -// Copyright (c) 2012, NVIDIA Corporation. -// -// Author: Laxman Dewangan <ldewangan@nvidia.com> - -#include <linux/delay.h> -#include <linux/err.h> -#include <linux/init.h> -#include <linux/kernel.h> -#include <linux/mfd/tps80031.h> -#include <linux/module.h> -#include <linux/platform_device.h> -#include <linux/regulator/driver.h> -#include <linux/regulator/machine.h> -#include <linux/slab.h> - -/* Flags for DCDC Voltage reading */ -#define DCDC_OFFSET_EN BIT(0) -#define DCDC_EXTENDED_EN BIT(1) -#define TRACK_MODE_ENABLE BIT(2) - -#define SMPS_MULTOFFSET_VIO BIT(1) -#define SMPS_MULTOFFSET_SMPS1 BIT(3) -#define SMPS_MULTOFFSET_SMPS2 BIT(4) -#define SMPS_MULTOFFSET_SMPS3 BIT(6) -#define SMPS_MULTOFFSET_SMPS4 BIT(0) - -#define SMPS_CMD_MASK 0xC0 -#define SMPS_VSEL_MASK 0x3F -#define LDO_VSEL_MASK 0x1F -#define LDO_TRACK_VSEL_MASK 0x3F - -#define MISC2_LDOUSB_IN_VSYS BIT(4) -#define MISC2_LDOUSB_IN_PMID BIT(3) -#define MISC2_LDOUSB_IN_MASK 0x18 - -#define MISC2_LDO3_SEL_VIB_VAL BIT(0) -#define MISC2_LDO3_SEL_VIB_MASK 0x1 - -#define BOOST_HW_PWR_EN BIT(5) -#define BOOST_HW_PWR_EN_MASK BIT(5) - -#define OPA_MODE_EN BIT(6) -#define OPA_MODE_EN_MASK BIT(6) - -#define USB_VBUS_CTRL_SET 0x04 -#define USB_VBUS_CTRL_CLR 0x05 -#define VBUS_DISCHRG 0x20 - -struct tps80031_regulator_info { - /* Regulator register address.*/ - u8 trans_reg; - u8 state_reg; - u8 force_reg; - u8 volt_reg; - u8 volt_id; - - /*Power request bits */ - int preq_bit; - - /* used by regulator core */ - struct regulator_desc desc; - -}; - -struct tps80031_regulator { - struct device *dev; - struct tps80031_regulator_info *rinfo; - - u8 device_flags; - unsigned int config_flags; - unsigned int ext_ctrl_flag; -}; - -static inline struct device *to_tps80031_dev(struct regulator_dev *rdev) -{ - return rdev_get_dev(rdev)->parent->parent; -} - -static int tps80031_reg_is_enabled(struct regulator_dev *rdev) -{ - struct tps80031_regulator *ri = rdev_get_drvdata(rdev); - struct device *parent = to_tps80031_dev(rdev); - u8 reg_val; - int ret; - - if (ri->ext_ctrl_flag & TPS80031_EXT_PWR_REQ) - return true; - - ret = tps80031_read(parent, TPS80031_SLAVE_ID1, ri->rinfo->state_reg, - ®_val); - if (ret < 0) { - dev_err(&rdev->dev, "Reg 0x%02x read failed, err = %d\n", - ri->rinfo->state_reg, ret); - return ret; - } - return (reg_val & TPS80031_STATE_MASK) == TPS80031_STATE_ON; -} - -static int tps80031_reg_enable(struct regulator_dev *rdev) -{ - struct tps80031_regulator *ri = rdev_get_drvdata(rdev); - struct device *parent = to_tps80031_dev(rdev); - int ret; - - if (ri->ext_ctrl_flag & TPS80031_EXT_PWR_REQ) - return 0; - - ret = tps80031_update(parent, TPS80031_SLAVE_ID1, ri->rinfo->state_reg, - TPS80031_STATE_ON, TPS80031_STATE_MASK); - if (ret < 0) { - dev_err(&rdev->dev, "Reg 0x%02x update failed, err = %d\n", - ri->rinfo->state_reg, ret); - return ret; - } - return ret; -} - -static int tps80031_reg_disable(struct regulator_dev *rdev) -{ - struct tps80031_regulator *ri = rdev_get_drvdata(rdev); - struct device *parent = to_tps80031_dev(rdev); - int ret; - - if (ri->ext_ctrl_flag & TPS80031_EXT_PWR_REQ) - return 0; - - ret = tps80031_update(parent, TPS80031_SLAVE_ID1, ri->rinfo->state_reg, - TPS80031_STATE_OFF, TPS80031_STATE_MASK); - if (ret < 0) - dev_err(&rdev->dev, "Reg 0x%02x update failed, err = %d\n", - ri->rinfo->state_reg, ret); - return ret; -} - -/* DCDC voltages for the selector of 58 to 63 */ -static const int tps80031_dcdc_voltages[4][5] = { - { 1350, 1500, 1800, 1900, 2100}, - { 1350, 1500, 1800, 1900, 2100}, - { 2084, 2315, 2778, 2932, 3241}, - { 4167, 2315, 2778, 2932, 3241}, -}; - -static int tps80031_dcdc_list_voltage(struct regulator_dev *rdev, unsigned sel) -{ - struct tps80031_regulator *ri = rdev_get_drvdata(rdev); - int volt_index = ri->device_flags & 0x3; - - if (sel == 0) - return 0; - else if (sel < 58) - return regulator_list_voltage_linear(rdev, sel - 1); - else - return tps80031_dcdc_voltages[volt_index][sel - 58] * 1000; -} - -static int tps80031_dcdc_set_voltage_sel(struct regulator_dev *rdev, - unsigned vsel) -{ - struct tps80031_regulator *ri = rdev_get_drvdata(rdev); - struct device *parent = to_tps80031_dev(rdev); - int ret; - u8 reg_val; - - if (ri->rinfo->force_reg) { - ret = tps80031_read(parent, ri->rinfo->volt_id, - ri->rinfo->force_reg, ®_val); - if (ret < 0) { - dev_err(ri->dev, "reg 0x%02x read failed, e = %d\n", - ri->rinfo->force_reg, ret); - return ret; - } - if (!(reg_val & SMPS_CMD_MASK)) { - ret = tps80031_update(parent, ri->rinfo->volt_id, - ri->rinfo->force_reg, vsel, SMPS_VSEL_MASK); - if (ret < 0) - dev_err(ri->dev, - "reg 0x%02x update failed, e = %d\n", - ri->rinfo->force_reg, ret); - return ret; - } - } - ret = tps80031_update(parent, ri->rinfo->volt_id, - ri->rinfo->volt_reg, vsel, SMPS_VSEL_MASK); - if (ret < 0) - dev_err(ri->dev, "reg 0x%02x update failed, e = %d\n", - ri->rinfo->volt_reg, ret); - return ret; -} - -static int tps80031_dcdc_get_voltage_sel(struct regulator_dev *rdev) -{ - struct tps80031_regulator *ri = rdev_get_drvdata(rdev); - struct device *parent = to_tps80031_dev(rdev); - uint8_t vsel = 0; - int ret; - - if (ri->rinfo->force_reg) { - ret = tps80031_read(parent, ri->rinfo->volt_id, - ri->rinfo->force_reg, &vsel); - if (ret < 0) { - dev_err(ri->dev, "reg 0x%02x read failed, e = %d\n", - ri->rinfo->force_reg, ret); - return ret; - } - - if (!(vsel & SMPS_CMD_MASK)) - return vsel & SMPS_VSEL_MASK; - } - ret = tps80031_read(parent, ri->rinfo->volt_id, - ri->rinfo->volt_reg, &vsel); - if (ret < 0) { - dev_err(ri->dev, "reg 0x%02x read failed, e = %d\n", - ri->rinfo->volt_reg, ret); - return ret; - } - return vsel & SMPS_VSEL_MASK; -} - -static int tps80031_ldo_list_voltage(struct regulator_dev *rdev, - unsigned int sel) -{ - struct tps80031_regulator *ri = rdev_get_drvdata(rdev); - struct device *parent = to_tps80031_dev(rdev); - - /* Check for valid setting for TPS80031 or TPS80032-ES1.0 */ - if ((ri->rinfo->desc.id == TPS80031_REGULATOR_LDO2) && - (ri->device_flags & TRACK_MODE_ENABLE)) { - unsigned nvsel = (sel) & 0x1F; - if (((tps80031_get_chip_info(parent) == TPS80031) || - ((tps80031_get_chip_info(parent) == TPS80032) && - (tps80031_get_pmu_version(parent) == 0x0))) && - ((nvsel == 0x0) || (nvsel >= 0x19 && nvsel <= 0x1F))) { - dev_err(ri->dev, - "Invalid sel %d in track mode LDO2\n", - nvsel); - return -EINVAL; - } - } - - return regulator_list_voltage_linear(rdev, sel); -} - -static int tps80031_ldo_map_voltage(struct regulator_dev *rdev, - int min_uV, int max_uV) -{ - struct tps80031_regulator *ri = rdev_get_drvdata(rdev); - struct device *parent = to_tps80031_dev(rdev); - - /* Check for valid setting for TPS80031 or TPS80032-ES1.0 */ - if ((ri->rinfo->desc.id == TPS80031_REGULATOR_LDO2) && - (ri->device_flags & TRACK_MODE_ENABLE)) { - if (((tps80031_get_chip_info(parent) == TPS80031) || - ((tps80031_get_chip_info(parent) == TPS80032) && - (tps80031_get_pmu_version(parent) == 0x0)))) { - return regulator_map_voltage_iterate(rdev, min_uV, - max_uV); - } - } - - return regulator_map_voltage_linear(rdev, min_uV, max_uV); -} - -static int tps80031_vbus_is_enabled(struct regulator_dev *rdev) -{ - struct tps80031_regulator *ri = rdev_get_drvdata(rdev); - struct device *parent = to_tps80031_dev(rdev); - int ret; - uint8_t ctrl1 = 0; - uint8_t ctrl3 = 0; - - ret = tps80031_read(parent, TPS80031_SLAVE_ID2, - TPS80031_CHARGERUSB_CTRL1, &ctrl1); - if (ret < 0) { - dev_err(ri->dev, "reg 0x%02x read failed, e = %d\n", - TPS80031_CHARGERUSB_CTRL1, ret); - return ret; - } - ret = tps80031_read(parent, TPS80031_SLAVE_ID2, - TPS80031_CHARGERUSB_CTRL3, &ctrl3); - if (ret < 0) { - dev_err(ri->dev, "reg 0x%02x read failed, e = %d\n", - TPS80031_CHARGERUSB_CTRL3, ret); - return ret; - } - if ((ctrl1 & OPA_MODE_EN) && (ctrl3 & BOOST_HW_PWR_EN)) - return 1; - return ret; -} - -static int tps80031_vbus_enable(struct regulator_dev *rdev) -{ - struct tps80031_regulator *ri = rdev_get_drvdata(rdev); - struct device *parent = to_tps80031_dev(rdev); - int ret; - - ret = tps80031_set_bits(parent, TPS80031_SLAVE_ID2, - TPS80031_CHARGERUSB_CTRL1, OPA_MODE_EN); - if (ret < 0) { - dev_err(ri->dev, "reg 0x%02x read failed, e = %d\n", - TPS80031_CHARGERUSB_CTRL1, ret); - return ret; - } - - ret = tps80031_set_bits(parent, TPS80031_SLAVE_ID2, - TPS80031_CHARGERUSB_CTRL3, BOOST_HW_PWR_EN); - if (ret < 0) { - dev_err(ri->dev, "reg 0x%02x read failed, e = %d\n", - TPS80031_CHARGERUSB_CTRL3, ret); - return ret; - } - return ret; -} - -static int tps80031_vbus_disable(struct regulator_dev *rdev) -{ - struct tps80031_regulator *ri = rdev_get_drvdata(rdev); - struct device *parent = to_tps80031_dev(rdev); - int ret; - - if (ri->config_flags & TPS80031_VBUS_DISCHRG_EN_PDN) { - ret = tps80031_write(parent, TPS80031_SLAVE_ID2, - USB_VBUS_CTRL_SET, VBUS_DISCHRG); - if (ret < 0) { - dev_err(ri->dev, "reg 0x%02x write failed, e = %d\n", - USB_VBUS_CTRL_SET, ret); - return ret; - } - } - - ret = tps80031_clr_bits(parent, TPS80031_SLAVE_ID2, - TPS80031_CHARGERUSB_CTRL1, OPA_MODE_EN); - if (ret < 0) { - dev_err(ri->dev, "reg 0x%02x clearbit failed, e = %d\n", - TPS80031_CHARGERUSB_CTRL1, ret); - return ret; - } - - ret = tps80031_clr_bits(parent, TPS80031_SLAVE_ID2, - TPS80031_CHARGERUSB_CTRL3, BOOST_HW_PWR_EN); - if (ret < 0) { - dev_err(ri->dev, "reg 0x%02x clearbit failed, e = %d\n", - TPS80031_CHARGERUSB_CTRL3, ret); - return ret; - } - - mdelay(DIV_ROUND_UP(ri->rinfo->desc.enable_time, 1000)); - if (ri->config_flags & TPS80031_VBUS_DISCHRG_EN_PDN) { - ret = tps80031_write(parent, TPS80031_SLAVE_ID2, - USB_VBUS_CTRL_CLR, VBUS_DISCHRG); - if (ret < 0) { - dev_err(ri->dev, "reg 0x%02x write failed, e = %d\n", - USB_VBUS_CTRL_CLR, ret); - return ret; - } - } - return ret; -} - -static const struct regulator_ops tps80031_dcdc_ops = { - .list_voltage = tps80031_dcdc_list_voltage, - .set_voltage_sel = tps80031_dcdc_set_voltage_sel, - .get_voltage_sel = tps80031_dcdc_get_voltage_sel, - .enable = tps80031_reg_enable, - .disable = tps80031_reg_disable, - .is_enabled = tps80031_reg_is_enabled, -}; - -static const struct regulator_ops tps80031_ldo_ops = { - .list_voltage = tps80031_ldo_list_voltage, - .map_voltage = tps80031_ldo_map_voltage, - .set_voltage_sel = regulator_set_voltage_sel_regmap, - .get_voltage_sel = regulator_get_voltage_sel_regmap, - .enable = tps80031_reg_enable, - .disable = tps80031_reg_disable, - .is_enabled = tps80031_reg_is_enabled, -}; - -static const struct regulator_ops tps80031_vbus_sw_ops = { - .list_voltage = regulator_list_voltage_linear, - .enable = tps80031_vbus_enable, - .disable = tps80031_vbus_disable, - .is_enabled = tps80031_vbus_is_enabled, -}; - -static const struct regulator_ops tps80031_vbus_hw_ops = { - .list_voltage = regulator_list_voltage_linear, -}; - -static const struct regulator_ops tps80031_ext_reg_ops = { - .list_voltage = regulator_list_voltage_linear, - .enable = tps80031_reg_enable, - .disable = tps80031_reg_disable, - .is_enabled = tps80031_reg_is_enabled, -}; - -/* Non-exiting default definition for some register */ -#define TPS80031_SMPS3_CFG_FORCE 0 -#define TPS80031_SMPS4_CFG_FORCE 0 - -#define TPS80031_VBUS_CFG_TRANS 0 -#define TPS80031_VBUS_CFG_STATE 0 - -#define TPS80031_REG_SMPS(_id, _volt_id, _pbit) \ -{ \ - .trans_reg = TPS80031_##_id##_CFG_TRANS, \ - .state_reg = TPS80031_##_id##_CFG_STATE, \ - .force_reg = TPS80031_##_id##_CFG_FORCE, \ - .volt_reg = TPS80031_##_id##_CFG_VOLTAGE, \ - .volt_id = TPS80031_SLAVE_##_volt_id, \ - .preq_bit = _pbit, \ - .desc = { \ - .name = "tps80031_"#_id, \ - .id = TPS80031_REGULATOR_##_id, \ - .n_voltages = 63, \ - .ops = &tps80031_dcdc_ops, \ - .type = REGULATOR_VOLTAGE, \ - .owner = THIS_MODULE, \ - .enable_time = 500, \ - }, \ -} - -#define TPS80031_REG_LDO(_id, _preq_bit) \ -{ \ - .trans_reg = TPS80031_##_id##_CFG_TRANS, \ - .state_reg = TPS80031_##_id##_CFG_STATE, \ - .volt_reg = TPS80031_##_id##_CFG_VOLTAGE, \ - .volt_id = TPS80031_SLAVE_ID1, \ - .preq_bit = _preq_bit, \ - .desc = { \ - .owner = THIS_MODULE, \ - .name = "tps80031_"#_id, \ - .id = TPS80031_REGULATOR_##_id, \ - .ops = &tps80031_ldo_ops, \ - .type = REGULATOR_VOLTAGE, \ - .min_uV = 1000000, \ - .uV_step = 100000, \ - .linear_min_sel = 1, \ - .n_voltages = 25, \ - .vsel_reg = TPS80031_##_id##_CFG_VOLTAGE, \ - .vsel_mask = LDO_VSEL_MASK, \ - .enable_time = 500, \ - }, \ -} - -#define TPS80031_REG_FIXED(_id, max_mV, _ops, _delay, _pbit) \ -{ \ - .trans_reg = TPS80031_##_id##_CFG_TRANS, \ - .state_reg = TPS80031_##_id##_CFG_STATE, \ - .volt_id = TPS80031_SLAVE_ID1, \ - .preq_bit = _pbit, \ - .desc = { \ - .name = "tps80031_"#_id, \ - .id = TPS80031_REGULATOR_##_id, \ - .min_uV = max_mV * 1000, \ - .n_voltages = 1, \ - .ops = &_ops, \ - .type = REGULATOR_VOLTAGE, \ - .owner = THIS_MODULE, \ - .enable_time = _delay, \ - }, \ -} - -static struct tps80031_regulator_info tps80031_rinfo[TPS80031_REGULATOR_MAX] = { - TPS80031_REG_SMPS(VIO, ID0, 4), - TPS80031_REG_SMPS(SMPS1, ID0, 0), - TPS80031_REG_SMPS(SMPS2, ID0, 1), - TPS80031_REG_SMPS(SMPS3, ID1, 2), - TPS80031_REG_SMPS(SMPS4, ID1, 3), - TPS80031_REG_LDO(VANA, -1), - TPS80031_REG_LDO(LDO1, 8), - TPS80031_REG_LDO(LDO2, 9), - TPS80031_REG_LDO(LDO3, 10), - TPS80031_REG_LDO(LDO4, 11), - TPS80031_REG_LDO(LDO5, 12), - TPS80031_REG_LDO(LDO6, 13), - TPS80031_REG_LDO(LDO7, 14), - TPS80031_REG_LDO(LDOLN, 15), - TPS80031_REG_LDO(LDOUSB, 5), - TPS80031_REG_FIXED(VBUS, 5000, tps80031_vbus_hw_ops, 100000, -1), - TPS80031_REG_FIXED(REGEN1, 3300, tps80031_ext_reg_ops, 0, 16), - TPS80031_REG_FIXED(REGEN2, 3300, tps80031_ext_reg_ops, 0, 17), - TPS80031_REG_FIXED(SYSEN, 3300, tps80031_ext_reg_ops, 0, 18), -}; - -static int tps80031_power_req_config(struct device *parent, - struct tps80031_regulator *ri, - struct tps80031_regulator_platform_data *tps80031_pdata) -{ - int ret = 0; - - if (ri->rinfo->preq_bit < 0) - goto skip_pwr_req_config; - - ret = tps80031_ext_power_req_config(parent, ri->ext_ctrl_flag, - ri->rinfo->preq_bit, ri->rinfo->state_reg, - ri->rinfo->trans_reg); - if (ret < 0) { - dev_err(ri->dev, "ext powerreq config failed, err = %d\n", ret); - return ret; - } - -skip_pwr_req_config: - if (tps80031_pdata->ext_ctrl_flag & TPS80031_PWR_ON_ON_SLEEP) { - ret = tps80031_update(parent, TPS80031_SLAVE_ID1, - ri->rinfo->trans_reg, TPS80031_TRANS_SLEEP_ON, - TPS80031_TRANS_SLEEP_MASK); - if (ret < 0) { - dev_err(ri->dev, "Reg 0x%02x update failed, e %d\n", - ri->rinfo->trans_reg, ret); - return ret; - } - } - return ret; -} - -static int tps80031_regulator_config(struct device *parent, - struct tps80031_regulator *ri, - struct tps80031_regulator_platform_data *tps80031_pdata) -{ - int ret = 0; - - switch (ri->rinfo->desc.id) { - case TPS80031_REGULATOR_LDOUSB: - if (ri->config_flags & (TPS80031_USBLDO_INPUT_VSYS | - TPS80031_USBLDO_INPUT_PMID)) { - unsigned val; - - if (ri->config_flags & TPS80031_USBLDO_INPUT_VSYS) - val = MISC2_LDOUSB_IN_VSYS; - else - val = MISC2_LDOUSB_IN_PMID; - - ret = tps80031_update(parent, TPS80031_SLAVE_ID1, - TPS80031_MISC2, val, - MISC2_LDOUSB_IN_MASK); - if (ret < 0) { - dev_err(ri->dev, - "LDOUSB config failed, e= %d\n", ret); - return ret; - } - } - break; - - case TPS80031_REGULATOR_LDO3: - if (ri->config_flags & TPS80031_LDO3_OUTPUT_VIB) { - ret = tps80031_update(parent, TPS80031_SLAVE_ID1, - TPS80031_MISC2, MISC2_LDO3_SEL_VIB_VAL, - MISC2_LDO3_SEL_VIB_MASK); - if (ret < 0) { - dev_err(ri->dev, - "LDO3 config failed, e = %d\n", ret); - return ret; - } - } - break; - - case TPS80031_REGULATOR_VBUS: - /* Provide SW control Ops if VBUS is SW control */ - if (!(ri->config_flags & TPS80031_VBUS_SW_ONLY)) - ri->rinfo->desc.ops = &tps80031_vbus_sw_ops; - break; - default: - break; - } - - /* Configure Active state to ON, SLEEP to OFF and OFF_state to OFF */ - ret = tps80031_update(parent, TPS80031_SLAVE_ID1, ri->rinfo->trans_reg, - TPS80031_TRANS_ACTIVE_ON | TPS80031_TRANS_SLEEP_OFF | - TPS80031_TRANS_OFF_OFF, TPS80031_TRANS_ACTIVE_MASK | - TPS80031_TRANS_SLEEP_MASK | TPS80031_TRANS_OFF_MASK); - if (ret < 0) { - dev_err(ri->dev, "trans reg update failed, e %d\n", ret); - return ret; - } - - return ret; -} - -static int check_smps_mode_mult(struct device *parent, - struct tps80031_regulator *ri) -{ - int mult_offset; - int ret; - u8 smps_offset; - u8 smps_mult; - - ret = tps80031_read(parent, TPS80031_SLAVE_ID1, - TPS80031_SMPS_OFFSET, &smps_offset); - if (ret < 0) { - dev_err(parent, "Error in reading smps offset register\n"); - return ret; - } - - ret = tps80031_read(parent, TPS80031_SLAVE_ID1, - TPS80031_SMPS_MULT, &smps_mult); - if (ret < 0) { - dev_err(parent, "Error in reading smps mult register\n"); - return ret; - } - - switch (ri->rinfo->desc.id) { - case TPS80031_REGULATOR_VIO: - mult_offset = SMPS_MULTOFFSET_VIO; - break; - case TPS80031_REGULATOR_SMPS1: - mult_offset = SMPS_MULTOFFSET_SMPS1; - break; - case TPS80031_REGULATOR_SMPS2: - mult_offset = SMPS_MULTOFFSET_SMPS2; - break; - case TPS80031_REGULATOR_SMPS3: - mult_offset = SMPS_MULTOFFSET_SMPS3; - break; - case TPS80031_REGULATOR_SMPS4: - mult_offset = SMPS_MULTOFFSET_SMPS4; - break; - case TPS80031_REGULATOR_LDO2: - ri->device_flags = smps_mult & BIT(5) ? TRACK_MODE_ENABLE : 0; - /* TRACK mode the ldo2 varies from 600mV to 1300mV */ - if (ri->device_flags & TRACK_MODE_ENABLE) { - ri->rinfo->desc.min_uV = 600000; - ri->rinfo->desc.uV_step = 12500; - ri->rinfo->desc.n_voltages = 57; - ri->rinfo->desc.vsel_mask = LDO_TRACK_VSEL_MASK; - } - return 0; - default: - return 0; - } - - ri->device_flags = (smps_offset & mult_offset) ? DCDC_OFFSET_EN : 0; - ri->device_flags |= (smps_mult & mult_offset) ? DCDC_EXTENDED_EN : 0; - switch (ri->device_flags) { - case 0: - ri->rinfo->desc.min_uV = 607700; - ri->rinfo->desc.uV_step = 12660; - break; - case DCDC_OFFSET_EN: - ri->rinfo->desc.min_uV = 700000; - ri->rinfo->desc.uV_step = 12500; - break; - case DCDC_EXTENDED_EN: - ri->rinfo->desc.min_uV = 1852000; - ri->rinfo->desc.uV_step = 38600; - break; - case DCDC_OFFSET_EN | DCDC_EXTENDED_EN: - ri->rinfo->desc.min_uV = 2161000; - ri->rinfo->desc.uV_step = 38600; - break; - } - return 0; -} - -static int tps80031_regulator_probe(struct platform_device *pdev) -{ - struct tps80031_platform_data *pdata; - struct tps80031_regulator_platform_data *tps_pdata; - struct tps80031_regulator *ri; - struct tps80031_regulator *pmic; - struct regulator_dev *rdev; - struct regulator_config config = { }; - struct tps80031 *tps80031_mfd = dev_get_drvdata(pdev->dev.parent); - int ret; - int num; - - pdata = dev_get_platdata(pdev->dev.parent); - - if (!pdata) { - dev_err(&pdev->dev, "No platform data\n"); - return -EINVAL; - } - - pmic = devm_kcalloc(&pdev->dev, - TPS80031_REGULATOR_MAX, sizeof(*pmic), GFP_KERNEL); - if (!pmic) - return -ENOMEM; - - for (num = 0; num < TPS80031_REGULATOR_MAX; ++num) { - tps_pdata = pdata->regulator_pdata[num]; - ri = &pmic[num]; - ri->rinfo = &tps80031_rinfo[num]; - ri->dev = &pdev->dev; - - check_smps_mode_mult(pdev->dev.parent, ri); - config.dev = &pdev->dev; - config.init_data = NULL; - config.driver_data = ri; - config.regmap = tps80031_mfd->regmap[ri->rinfo->volt_id]; - - if (tps_pdata) { - config.init_data = tps_pdata->reg_init_data; - ri->config_flags = tps_pdata->config_flags; - ri->ext_ctrl_flag = tps_pdata->ext_ctrl_flag; - ret = tps80031_regulator_config(pdev->dev.parent, - ri, tps_pdata); - if (ret < 0) { - dev_err(&pdev->dev, - "regulator config failed, e %d\n", ret); - return ret; - } - - ret = tps80031_power_req_config(pdev->dev.parent, - ri, tps_pdata); - if (ret < 0) { - dev_err(&pdev->dev, - "pwr_req config failed, err %d\n", ret); - return ret; - } - } - rdev = devm_regulator_register(&pdev->dev, &ri->rinfo->desc, - &config); - if (IS_ERR(rdev)) { - dev_err(&pdev->dev, - "register regulator failed %s\n", - ri->rinfo->desc.name); - return PTR_ERR(rdev); - } - } - - platform_set_drvdata(pdev, pmic); - return 0; -} - -static struct platform_driver tps80031_regulator_driver = { - .driver = { - .name = "tps80031-pmic", - }, - .probe = tps80031_regulator_probe, -}; - -static int __init tps80031_regulator_init(void) -{ - return platform_driver_register(&tps80031_regulator_driver); -} -subsys_initcall(tps80031_regulator_init); - -static void __exit tps80031_regulator_exit(void) -{ - platform_driver_unregister(&tps80031_regulator_driver); -} -module_exit(tps80031_regulator_exit); - -MODULE_ALIAS("platform:tps80031-regulator"); -MODULE_DESCRIPTION("Regulator Driver for TI TPS80031/TPS80032 PMIC"); -MODULE_AUTHOR("Laxman Dewangan <ldewangan@nvidia.com>"); -MODULE_LICENSE("GPL v2"); diff --git a/drivers/regulator/uniphier-regulator.c b/drivers/regulator/uniphier-regulator.c index e75b0973e325..39a68b01fc38 100644 --- a/drivers/regulator/uniphier-regulator.c +++ b/drivers/regulator/uniphier-regulator.c @@ -199,6 +199,10 @@ static const struct of_device_id uniphier_regulator_match[] = { .compatible = "socionext,uniphier-pxs3-usb3-regulator", .data = &uniphier_pxs2_usb3_data, }, + { + .compatible = "socionext,uniphier-nx1-usb3-regulator", + .data = &uniphier_pxs2_usb3_data, + }, { /* Sentinel */ }, }; MODULE_DEVICE_TABLE(of, uniphier_regulator_match); diff --git a/drivers/regulator/vqmmc-ipq4019-regulator.c b/drivers/regulator/vqmmc-ipq4019-regulator.c index 6d5ae25d08d1..c4213f096fe5 100644 --- a/drivers/regulator/vqmmc-ipq4019-regulator.c +++ b/drivers/regulator/vqmmc-ipq4019-regulator.c @@ -48,7 +48,6 @@ static int ipq4019_regulator_probe(struct platform_device *pdev) struct regulator_init_data *init_data; struct regulator_config cfg = {}; struct regulator_dev *rdev; - struct resource *res; struct regmap *rmap; void __iomem *base; @@ -57,8 +56,7 @@ static int ipq4019_regulator_probe(struct platform_device *pdev) if (!init_data) return -EINVAL; - res = platform_get_resource(pdev, IORESOURCE_MEM, 0); - base = devm_ioremap_resource(dev, res); + base = devm_platform_ioremap_resource(pdev, 0); if (IS_ERR(base)) return PTR_ERR(base); diff --git a/drivers/spi/spi.c b/drivers/spi/spi.c index 926b68aa45d3..2a2f41b6df68 100644 --- a/drivers/spi/spi.c +++ b/drivers/spi/spi.c @@ -451,6 +451,47 @@ int __spi_register_driver(struct module *owner, struct spi_driver *sdrv) { sdrv->driver.owner = owner; sdrv->driver.bus = &spi_bus_type; + + /* + * For Really Good Reasons we use spi: modaliases not of: + * modaliases for DT so module autoloading won't work if we + * don't have a spi_device_id as well as a compatible string. + */ + if (sdrv->driver.of_match_table) { + const struct of_device_id *of_id; + + for (of_id = sdrv->driver.of_match_table; of_id->compatible[0]; + of_id++) { + const char *of_name; + + /* Strip off any vendor prefix */ + of_name = strnchr(of_id->compatible, + sizeof(of_id->compatible), ','); + if (of_name) + of_name++; + else + of_name = of_id->compatible; + + if (sdrv->id_table) { + const struct spi_device_id *spi_id; + + for (spi_id = sdrv->id_table; spi_id->name[0]; + spi_id++) + if (strcmp(spi_id->name, of_name) == 0) + break; + + if (spi_id->name[0]) + continue; + } else { + if (strcmp(sdrv->driver.name, of_name) == 0) + continue; + } + + pr_warn("SPI driver %s has no spi_device_id for %s\n", + sdrv->driver.name, of_id->compatible); + } + } + return driver_register(&sdrv->driver); } EXPORT_SYMBOL_GPL(__spi_register_driver); |