mirror of
https://github.com/torvalds/linux.git
synced 2024-12-01 00:21:32 +00:00
259b93b21a
Probing of regulators can be a slow operation and can contribute to slower boot times. This is especially true if a regulator is turned on at probe time (with regulator-boot-on or regulator-always-on) and the regulator requires delays (off-on-time, ramp time, etc). While the overall kernel is not ready to switch to async probe by default, as per the discussion on the mailing lists [1] it is believed that the regulator subsystem is in good shape and we can move regulator drivers over wholesale. There is no way to just magically opt in all regulators (regulators are just normal drivers like platform_driver), so we set PROBE_PREFER_ASYNCHRONOUS for all regulators found in 'drivers/regulator' individually. Given the number of drivers touched and the impossibility to test this ahead of time, it wouldn't be shocking at all if this caused a regression for someone. If there is a regression caused by this patch, it's likely to be one of the cases talked about in [1]. As a "quick fix", drivers involved in the regression could be fixed by changing them to PROBE_FORCE_SYNCHRONOUS. That being said, the correct fix would be to directly fix the problem that caused the issue with async probe. The approach here follows a similar approach that was used for the mmc subsystem several years ago [2]. In fact, I ran nearly the same python script to auto-generate the changes. The only thing I changed was to search for "i2c_driver", "spmi_driver", and "spi_driver" in addition to "platform_driver". [1] https://lore.kernel.org/r/06db017f-e985-4434-8d1d-02ca2100cca0@sirena.org.uk [2] https://lore.kernel.org/r/20200903232441.2694866-1-dianders@chromium.org/ Signed-off-by: Douglas Anderson <dianders@chromium.org> Link: https://lore.kernel.org/r/20230316125351.1.I2a4677392a38db5758dee0788b2cea5872562a82@changeid Signed-off-by: Mark Brown <broonie@kernel.org>
210 lines
5.1 KiB
C
210 lines
5.1 KiB
C
// SPDX-License-Identifier: GPL-2.0-or-later
|
|
/*
|
|
* isl9305 - Intersil ISL9305 DCDC regulator
|
|
*
|
|
* Copyright 2014 Linaro Ltd
|
|
*
|
|
* Author: Mark Brown <broonie@kernel.org>
|
|
*/
|
|
|
|
#include <linux/module.h>
|
|
#include <linux/err.h>
|
|
#include <linux/i2c.h>
|
|
#include <linux/of.h>
|
|
#include <linux/platform_data/isl9305.h>
|
|
#include <linux/regmap.h>
|
|
#include <linux/regulator/driver.h>
|
|
#include <linux/regulator/of_regulator.h>
|
|
#include <linux/slab.h>
|
|
|
|
/*
|
|
* Registers
|
|
*/
|
|
#define ISL9305_DCD1OUT 0x0
|
|
#define ISL9305_DCD2OUT 0x1
|
|
#define ISL9305_LDO1OUT 0x2
|
|
#define ISL9305_LDO2OUT 0x3
|
|
#define ISL9305_DCD_PARAMETER 0x4
|
|
#define ISL9305_SYSTEM_PARAMETER 0x5
|
|
#define ISL9305_DCD_SRCTL 0x6
|
|
|
|
#define ISL9305_MAX_REG ISL9305_DCD_SRCTL
|
|
|
|
/*
|
|
* DCD_PARAMETER
|
|
*/
|
|
#define ISL9305_DCD_PHASE 0x40
|
|
#define ISL9305_DCD2_ULTRA 0x20
|
|
#define ISL9305_DCD1_ULTRA 0x10
|
|
#define ISL9305_DCD2_BLD 0x08
|
|
#define ISL9305_DCD1_BLD 0x04
|
|
#define ISL9305_DCD2_MODE 0x02
|
|
#define ISL9305_DCD1_MODE 0x01
|
|
|
|
/*
|
|
* SYSTEM_PARAMETER
|
|
*/
|
|
#define ISL9305_I2C_EN 0x40
|
|
#define ISL9305_DCDPOR_MASK 0x30
|
|
#define ISL9305_LDO2_EN 0x08
|
|
#define ISL9305_LDO1_EN 0x04
|
|
#define ISL9305_DCD2_EN 0x02
|
|
#define ISL9305_DCD1_EN 0x01
|
|
|
|
/*
|
|
* DCD_SRCTL
|
|
*/
|
|
#define ISL9305_DCD2SR_MASK 0xc0
|
|
#define ISL9305_DCD1SR_MASK 0x07
|
|
|
|
static const struct regulator_ops isl9305_ops = {
|
|
.enable = regulator_enable_regmap,
|
|
.disable = regulator_disable_regmap,
|
|
.is_enabled = regulator_is_enabled_regmap,
|
|
.list_voltage = regulator_list_voltage_linear,
|
|
.get_voltage_sel = regulator_get_voltage_sel_regmap,
|
|
.set_voltage_sel = regulator_set_voltage_sel_regmap,
|
|
};
|
|
|
|
static const struct regulator_desc isl9305_regulators[] = {
|
|
[ISL9305_DCD1] = {
|
|
.name = "DCD1",
|
|
.of_match = of_match_ptr("dcd1"),
|
|
.regulators_node = of_match_ptr("regulators"),
|
|
.n_voltages = 0x70,
|
|
.min_uV = 825000,
|
|
.uV_step = 25000,
|
|
.vsel_reg = ISL9305_DCD1OUT,
|
|
.vsel_mask = 0x7f,
|
|
.enable_reg = ISL9305_SYSTEM_PARAMETER,
|
|
.enable_mask = ISL9305_DCD1_EN,
|
|
.supply_name = "VINDCD1",
|
|
.ops = &isl9305_ops,
|
|
.owner = THIS_MODULE,
|
|
},
|
|
[ISL9305_DCD2] = {
|
|
.name = "DCD2",
|
|
.of_match = of_match_ptr("dcd2"),
|
|
.regulators_node = of_match_ptr("regulators"),
|
|
.n_voltages = 0x70,
|
|
.min_uV = 825000,
|
|
.uV_step = 25000,
|
|
.vsel_reg = ISL9305_DCD2OUT,
|
|
.vsel_mask = 0x7f,
|
|
.enable_reg = ISL9305_SYSTEM_PARAMETER,
|
|
.enable_mask = ISL9305_DCD2_EN,
|
|
.supply_name = "VINDCD2",
|
|
.ops = &isl9305_ops,
|
|
.owner = THIS_MODULE,
|
|
},
|
|
[ISL9305_LDO1] = {
|
|
.name = "LDO1",
|
|
.of_match = of_match_ptr("ldo1"),
|
|
.regulators_node = of_match_ptr("regulators"),
|
|
.n_voltages = 0x37,
|
|
.min_uV = 900000,
|
|
.uV_step = 50000,
|
|
.vsel_reg = ISL9305_LDO1OUT,
|
|
.vsel_mask = 0x3f,
|
|
.enable_reg = ISL9305_SYSTEM_PARAMETER,
|
|
.enable_mask = ISL9305_LDO1_EN,
|
|
.supply_name = "VINLDO1",
|
|
.ops = &isl9305_ops,
|
|
.owner = THIS_MODULE,
|
|
},
|
|
[ISL9305_LDO2] = {
|
|
.name = "LDO2",
|
|
.of_match = of_match_ptr("ldo2"),
|
|
.regulators_node = of_match_ptr("regulators"),
|
|
.n_voltages = 0x37,
|
|
.min_uV = 900000,
|
|
.uV_step = 50000,
|
|
.vsel_reg = ISL9305_LDO2OUT,
|
|
.vsel_mask = 0x3f,
|
|
.enable_reg = ISL9305_SYSTEM_PARAMETER,
|
|
.enable_mask = ISL9305_LDO2_EN,
|
|
.supply_name = "VINLDO2",
|
|
.ops = &isl9305_ops,
|
|
.owner = THIS_MODULE,
|
|
},
|
|
};
|
|
|
|
static const struct regmap_config isl9305_regmap = {
|
|
.reg_bits = 8,
|
|
.val_bits = 8,
|
|
|
|
.max_register = ISL9305_MAX_REG,
|
|
.cache_type = REGCACHE_RBTREE,
|
|
};
|
|
|
|
static int isl9305_i2c_probe(struct i2c_client *i2c)
|
|
{
|
|
struct regulator_config config = { };
|
|
struct isl9305_pdata *pdata = i2c->dev.platform_data;
|
|
struct regulator_dev *rdev;
|
|
struct regmap *regmap;
|
|
int i, ret;
|
|
|
|
regmap = devm_regmap_init_i2c(i2c, &isl9305_regmap);
|
|
if (IS_ERR(regmap)) {
|
|
ret = PTR_ERR(regmap);
|
|
dev_err(&i2c->dev, "Failed to create regmap: %d\n", ret);
|
|
return ret;
|
|
}
|
|
|
|
config.dev = &i2c->dev;
|
|
|
|
for (i = 0; i < ARRAY_SIZE(isl9305_regulators); i++) {
|
|
if (pdata)
|
|
config.init_data = pdata->init_data[i];
|
|
else
|
|
config.init_data = NULL;
|
|
|
|
rdev = devm_regulator_register(&i2c->dev,
|
|
&isl9305_regulators[i],
|
|
&config);
|
|
if (IS_ERR(rdev)) {
|
|
ret = PTR_ERR(rdev);
|
|
dev_err(&i2c->dev, "Failed to register %s: %d\n",
|
|
isl9305_regulators[i].name, ret);
|
|
return ret;
|
|
}
|
|
}
|
|
|
|
return 0;
|
|
}
|
|
|
|
#ifdef CONFIG_OF
|
|
static const struct of_device_id isl9305_dt_ids[] = {
|
|
{ .compatible = "isl,isl9305" }, /* for backward compat., don't use */
|
|
{ .compatible = "isil,isl9305" },
|
|
{ .compatible = "isl,isl9305h" }, /* for backward compat., don't use */
|
|
{ .compatible = "isil,isl9305h" },
|
|
{},
|
|
};
|
|
MODULE_DEVICE_TABLE(of, isl9305_dt_ids);
|
|
#endif
|
|
|
|
static const struct i2c_device_id isl9305_i2c_id[] = {
|
|
{ "isl9305", },
|
|
{ "isl9305h", },
|
|
{ }
|
|
};
|
|
MODULE_DEVICE_TABLE(i2c, isl9305_i2c_id);
|
|
|
|
static struct i2c_driver isl9305_regulator_driver = {
|
|
.driver = {
|
|
.name = "isl9305",
|
|
.probe_type = PROBE_PREFER_ASYNCHRONOUS,
|
|
.of_match_table = of_match_ptr(isl9305_dt_ids),
|
|
},
|
|
.probe_new = isl9305_i2c_probe,
|
|
.id_table = isl9305_i2c_id,
|
|
};
|
|
|
|
module_i2c_driver(isl9305_regulator_driver);
|
|
|
|
MODULE_AUTHOR("Mark Brown");
|
|
MODULE_DESCRIPTION("Intersil ISL9305 DCDC regulator");
|
|
MODULE_LICENSE("GPL");
|