12aec85b2SThomas Gleixner // SPDX-License-Identifier: GPL-2.0-only
230e6599dSAnuj Aggarwal /*
330e6599dSAnuj Aggarwal  * tps65023-regulator.c
430e6599dSAnuj Aggarwal  *
530e6599dSAnuj Aggarwal  * Supports TPS65023 Regulator
630e6599dSAnuj Aggarwal  *
72ca76b3eSAlexander A. Klimov  * Copyright (C) 2009 Texas Instrument Incorporated - https://www.ti.com/
830e6599dSAnuj Aggarwal  */
930e6599dSAnuj Aggarwal 
1030e6599dSAnuj Aggarwal #include <linux/kernel.h>
1130e6599dSAnuj Aggarwal #include <linux/module.h>
1230e6599dSAnuj Aggarwal #include <linux/init.h>
1330e6599dSAnuj Aggarwal #include <linux/err.h>
1430e6599dSAnuj Aggarwal #include <linux/platform_device.h>
1530e6599dSAnuj Aggarwal #include <linux/regulator/driver.h>
1630e6599dSAnuj Aggarwal #include <linux/regulator/machine.h>
1730e6599dSAnuj Aggarwal #include <linux/i2c.h>
185a0e3ad6STejun Heo #include <linux/slab.h>
1990923351SMark Brown #include <linux/regmap.h>
2030e6599dSAnuj Aggarwal 
2130e6599dSAnuj Aggarwal /* Register definitions */
2230e6599dSAnuj Aggarwal #define	TPS65023_REG_VERSION		0
2330e6599dSAnuj Aggarwal #define	TPS65023_REG_PGOODZ		1
2430e6599dSAnuj Aggarwal #define	TPS65023_REG_MASK		2
2530e6599dSAnuj Aggarwal #define	TPS65023_REG_REG_CTRL		3
2630e6599dSAnuj Aggarwal #define	TPS65023_REG_CON_CTRL		4
2730e6599dSAnuj Aggarwal #define	TPS65023_REG_CON_CTRL2		5
2830e6599dSAnuj Aggarwal #define	TPS65023_REG_DEF_CORE		6
2930e6599dSAnuj Aggarwal #define	TPS65023_REG_DEFSLEW		7
3030e6599dSAnuj Aggarwal #define	TPS65023_REG_LDO_CTRL		8
3130e6599dSAnuj Aggarwal 
3230e6599dSAnuj Aggarwal /* PGOODZ bitfields */
3330e6599dSAnuj Aggarwal #define	TPS65023_PGOODZ_PWRFAILZ	BIT(7)
3430e6599dSAnuj Aggarwal #define	TPS65023_PGOODZ_LOWBATTZ	BIT(6)
3530e6599dSAnuj Aggarwal #define	TPS65023_PGOODZ_VDCDC1		BIT(5)
3630e6599dSAnuj Aggarwal #define	TPS65023_PGOODZ_VDCDC2		BIT(4)
3730e6599dSAnuj Aggarwal #define	TPS65023_PGOODZ_VDCDC3		BIT(3)
3830e6599dSAnuj Aggarwal #define	TPS65023_PGOODZ_LDO2		BIT(2)
3930e6599dSAnuj Aggarwal #define	TPS65023_PGOODZ_LDO1		BIT(1)
4030e6599dSAnuj Aggarwal 
4130e6599dSAnuj Aggarwal /* MASK bitfields */
4230e6599dSAnuj Aggarwal #define	TPS65023_MASK_PWRFAILZ		BIT(7)
4330e6599dSAnuj Aggarwal #define	TPS65023_MASK_LOWBATTZ		BIT(6)
4430e6599dSAnuj Aggarwal #define	TPS65023_MASK_VDCDC1		BIT(5)
4530e6599dSAnuj Aggarwal #define	TPS65023_MASK_VDCDC2		BIT(4)
4630e6599dSAnuj Aggarwal #define	TPS65023_MASK_VDCDC3		BIT(3)
4730e6599dSAnuj Aggarwal #define	TPS65023_MASK_LDO2		BIT(2)
4830e6599dSAnuj Aggarwal #define	TPS65023_MASK_LDO1		BIT(1)
4930e6599dSAnuj Aggarwal 
5030e6599dSAnuj Aggarwal /* REG_CTRL bitfields */
5130e6599dSAnuj Aggarwal #define TPS65023_REG_CTRL_VDCDC1_EN	BIT(5)
5230e6599dSAnuj Aggarwal #define TPS65023_REG_CTRL_VDCDC2_EN	BIT(4)
5330e6599dSAnuj Aggarwal #define TPS65023_REG_CTRL_VDCDC3_EN	BIT(3)
5430e6599dSAnuj Aggarwal #define TPS65023_REG_CTRL_LDO2_EN	BIT(2)
5530e6599dSAnuj Aggarwal #define TPS65023_REG_CTRL_LDO1_EN	BIT(1)
5630e6599dSAnuj Aggarwal 
57fc999b83SMarcus Folkesson /* REG_CTRL2 bitfields */
58fc999b83SMarcus Folkesson #define TPS65023_REG_CTRL2_GO		BIT(7)
59fc999b83SMarcus Folkesson #define TPS65023_REG_CTRL2_CORE_ADJ	BIT(6)
60fc999b83SMarcus Folkesson #define TPS65023_REG_CTRL2_DCDC2	BIT(2)
61f068ad8cSMarcus Folkesson #define TPS65023_REG_CTRL2_DCDC1	BIT(1)
62f068ad8cSMarcus Folkesson #define TPS65023_REG_CTRL2_DCDC3	BIT(0)
63f068ad8cSMarcus Folkesson 
6430e6599dSAnuj Aggarwal /* Number of step-down converters available */
6530e6599dSAnuj Aggarwal #define TPS65023_NUM_DCDC		3
6630e6599dSAnuj Aggarwal /* Number of LDO voltage regulators  available */
6730e6599dSAnuj Aggarwal #define TPS65023_NUM_LDO		2
6830e6599dSAnuj Aggarwal /* Number of total regulators available */
6930e6599dSAnuj Aggarwal #define TPS65023_NUM_REGULATOR	(TPS65023_NUM_DCDC + TPS65023_NUM_LDO)
7030e6599dSAnuj Aggarwal 
7130e6599dSAnuj Aggarwal /* DCDCs */
7230e6599dSAnuj Aggarwal #define TPS65023_DCDC_1			0
7330e6599dSAnuj Aggarwal #define TPS65023_DCDC_2			1
7430e6599dSAnuj Aggarwal #define TPS65023_DCDC_3			2
7530e6599dSAnuj Aggarwal /* LDOs */
7630e6599dSAnuj Aggarwal #define TPS65023_LDO_1			3
7730e6599dSAnuj Aggarwal #define TPS65023_LDO_2			4
7830e6599dSAnuj Aggarwal 
7930e6599dSAnuj Aggarwal #define TPS65023_MAX_REG_ID		TPS65023_LDO_2
8030e6599dSAnuj Aggarwal 
812d3eda67SThomas Elste #define TPS65023_REGULATOR_DCDC(_num, _t, _em)			\
822d3eda67SThomas Elste 	{							\
832d3eda67SThomas Elste 		.name		= "VDCDC"#_num,			\
842d3eda67SThomas Elste 		.of_match	= of_match_ptr("VDCDC"#_num),	\
852d3eda67SThomas Elste 		.regulators_node = of_match_ptr("regulators"),	\
862d3eda67SThomas Elste 		.id		= TPS65023_DCDC_##_num,		\
872d3eda67SThomas Elste 		.n_voltages     = ARRAY_SIZE(_t),		\
882d3eda67SThomas Elste 		.ops		= &tps65023_dcdc_ops,		\
892d3eda67SThomas Elste 		.type		= REGULATOR_VOLTAGE,		\
902d3eda67SThomas Elste 		.owner		= THIS_MODULE,			\
912d3eda67SThomas Elste 		.volt_table	= _t,				\
922d3eda67SThomas Elste 		.vsel_reg	= TPS65023_REG_DEF_CORE,	\
932d3eda67SThomas Elste 		.vsel_mask	= ARRAY_SIZE(_t) - 1,		\
942d3eda67SThomas Elste 		.enable_mask	= _em,				\
952d3eda67SThomas Elste 		.enable_reg	= TPS65023_REG_REG_CTRL,	\
962d3eda67SThomas Elste 		.apply_reg	= TPS65023_REG_CON_CTRL2,	\
972d3eda67SThomas Elste 		.apply_bit	= TPS65023_REG_CTRL2_GO,	\
982d3eda67SThomas Elste 	}							\
992d3eda67SThomas Elste 
1002d3eda67SThomas Elste #define TPS65023_REGULATOR_LDO(_num, _t, _vm)			\
1012d3eda67SThomas Elste 	{							\
1022d3eda67SThomas Elste 		.name		= "LDO"#_num,			\
1032d3eda67SThomas Elste 		.of_match	= of_match_ptr("LDO"#_num),	\
1042d3eda67SThomas Elste 		.regulators_node = of_match_ptr("regulators"),	\
1052d3eda67SThomas Elste 		.id		= TPS65023_LDO_##_num,		\
1062d3eda67SThomas Elste 		.n_voltages     = ARRAY_SIZE(_t),		\
1072d3eda67SThomas Elste 		.ops		= &tps65023_ldo_ops,		\
1082d3eda67SThomas Elste 		.type		= REGULATOR_VOLTAGE,		\
1092d3eda67SThomas Elste 		.owner		= THIS_MODULE,			\
1102d3eda67SThomas Elste 		.volt_table	= _t,				\
1112d3eda67SThomas Elste 		.vsel_reg	= TPS65023_REG_LDO_CTRL,	\
1122d3eda67SThomas Elste 		.vsel_mask	= _vm,				\
1132d3eda67SThomas Elste 		.enable_mask	= 1 << (_num),			\
1142d3eda67SThomas Elste 		.enable_reg	= TPS65023_REG_REG_CTRL,	\
1152d3eda67SThomas Elste 	}							\
1162d3eda67SThomas Elste 
11730e6599dSAnuj Aggarwal /* Supported voltage values for regulators */
118ba3bd8a3SAxel Lin static const unsigned int VCORE_VSEL_table[] = {
119ba3bd8a3SAxel Lin 	800000, 825000, 850000, 875000,
120ba3bd8a3SAxel Lin 	900000, 925000, 950000, 975000,
121ba3bd8a3SAxel Lin 	1000000, 1025000, 1050000, 1075000,
122ba3bd8a3SAxel Lin 	1100000, 1125000, 1150000, 1175000,
123ba3bd8a3SAxel Lin 	1200000, 1225000, 1250000, 1275000,
124ba3bd8a3SAxel Lin 	1300000, 1325000, 1350000, 1375000,
125ba3bd8a3SAxel Lin 	1400000, 1425000, 1450000, 1475000,
126ba3bd8a3SAxel Lin 	1500000, 1525000, 1550000, 1600000,
127ba3bd8a3SAxel Lin };
128ba3bd8a3SAxel Lin 
129ba3bd8a3SAxel Lin static const unsigned int DCDC_FIXED_3300000_VSEL_table[] = {
130ba3bd8a3SAxel Lin 	3300000,
131ba3bd8a3SAxel Lin };
132ba3bd8a3SAxel Lin 
133ba3bd8a3SAxel Lin static const unsigned int DCDC_FIXED_1800000_VSEL_table[] = {
134ba3bd8a3SAxel Lin 	1800000,
13530e6599dSAnuj Aggarwal };
13630e6599dSAnuj Aggarwal 
137437afd2aSMarcus Folkesson /* Supported voltage values for LDO regulators for tps65020 */
1382040541aSAxel Lin static const unsigned int TPS65020_LDO_VSEL_table[] = {
139ba3bd8a3SAxel Lin 	1000000, 1050000, 1100000, 1300000,
140ba3bd8a3SAxel Lin 	1800000, 2500000, 3000000, 3300000,
141437afd2aSMarcus Folkesson };
1421c3ede05SMarcus Folkesson 
1431c3ede05SMarcus Folkesson /* Supported voltage values for LDO regulators
1441c3ede05SMarcus Folkesson  * for tps65021 and tps65023 */
145ba3bd8a3SAxel Lin static const unsigned int TPS65023_LDO1_VSEL_table[] = {
146ba3bd8a3SAxel Lin 	1000000, 1100000, 1300000, 1800000,
147ba3bd8a3SAxel Lin 	2200000, 2600000, 2800000, 3150000,
14830e6599dSAnuj Aggarwal };
14930e6599dSAnuj Aggarwal 
150ba3bd8a3SAxel Lin static const unsigned int TPS65023_LDO2_VSEL_table[] = {
151ba3bd8a3SAxel Lin 	1050000, 1200000, 1300000, 1800000,
152ba3bd8a3SAxel Lin 	2500000, 2800000, 3000000, 3300000,
15330e6599dSAnuj Aggarwal };
15430e6599dSAnuj Aggarwal 
15530e6599dSAnuj Aggarwal /* PMIC details */
15630e6599dSAnuj Aggarwal struct tps_pmic {
15730e6599dSAnuj Aggarwal 	struct regulator_dev *rdev[TPS65023_NUM_REGULATOR];
1582d3eda67SThomas Elste 	const struct tps_driver_data *driver_data;
15990923351SMark Brown 	struct regmap *regmap;
1601c3ede05SMarcus Folkesson };
1611c3ede05SMarcus Folkesson 
1621c3ede05SMarcus Folkesson /* Struct passed as driver data */
1631c3ede05SMarcus Folkesson struct tps_driver_data {
1642d3eda67SThomas Elste 	const struct regulator_desc *desc;
1651c3ede05SMarcus Folkesson 	u8 core_regulator;
16630e6599dSAnuj Aggarwal };
16730e6599dSAnuj Aggarwal 
tps65023_dcdc_get_voltage_sel(struct regulator_dev * dev)168a133829eSAxel Lin static int tps65023_dcdc_get_voltage_sel(struct regulator_dev *dev)
16930e6599dSAnuj Aggarwal {
17030e6599dSAnuj Aggarwal 	struct tps_pmic *tps = rdev_get_drvdata(dev);
17146bcb006SAxel Lin 	int dcdc = rdev_get_id(dev);
17230e6599dSAnuj Aggarwal 
17330e6599dSAnuj Aggarwal 	if (dcdc < TPS65023_DCDC_1 || dcdc > TPS65023_DCDC_3)
17430e6599dSAnuj Aggarwal 		return -EINVAL;
17530e6599dSAnuj Aggarwal 
1762d3eda67SThomas Elste 	if (dcdc != tps->driver_data->core_regulator)
177a133829eSAxel Lin 		return 0;
17846bcb006SAxel Lin 
17946bcb006SAxel Lin 	return regulator_get_voltage_sel_regmap(dev);
18030e6599dSAnuj Aggarwal }
18130e6599dSAnuj Aggarwal 
tps65023_dcdc_set_voltage_sel(struct regulator_dev * dev,unsigned selector)1827061873fSAxel Lin static int tps65023_dcdc_set_voltage_sel(struct regulator_dev *dev,
1837061873fSAxel Lin 					 unsigned selector)
18430e6599dSAnuj Aggarwal {
18530e6599dSAnuj Aggarwal 	struct tps_pmic *tps = rdev_get_drvdata(dev);
18630e6599dSAnuj Aggarwal 	int dcdc = rdev_get_id(dev);
18730e6599dSAnuj Aggarwal 
1882d3eda67SThomas Elste 	if (dcdc != tps->driver_data->core_regulator)
18930e6599dSAnuj Aggarwal 		return -EINVAL;
19030e6599dSAnuj Aggarwal 
19146bcb006SAxel Lin 	return regulator_set_voltage_sel_regmap(dev, selector);
19230e6599dSAnuj Aggarwal }
19330e6599dSAnuj Aggarwal 
19430e6599dSAnuj Aggarwal /* Operations permitted on VDCDCx */
1954604a061SKrzysztof Kozlowski static const struct regulator_ops tps65023_dcdc_ops = {
196ee7b1914SAxel Lin 	.is_enabled = regulator_is_enabled_regmap,
197ee7b1914SAxel Lin 	.enable = regulator_enable_regmap,
198ee7b1914SAxel Lin 	.disable = regulator_disable_regmap,
199a133829eSAxel Lin 	.get_voltage_sel = tps65023_dcdc_get_voltage_sel,
2007061873fSAxel Lin 	.set_voltage_sel = tps65023_dcdc_set_voltage_sel,
201ba3bd8a3SAxel Lin 	.list_voltage = regulator_list_voltage_table,
202c4bbfbd5SAxel Lin 	.map_voltage = regulator_map_voltage_ascend,
20330e6599dSAnuj Aggarwal };
20430e6599dSAnuj Aggarwal 
20530e6599dSAnuj Aggarwal /* Operations permitted on LDOx */
2064604a061SKrzysztof Kozlowski static const struct regulator_ops tps65023_ldo_ops = {
207ee7b1914SAxel Lin 	.is_enabled = regulator_is_enabled_regmap,
208ee7b1914SAxel Lin 	.enable = regulator_enable_regmap,
209ee7b1914SAxel Lin 	.disable = regulator_disable_regmap,
210e90a8447SAxel Lin 	.get_voltage_sel = regulator_get_voltage_sel_regmap,
211e90a8447SAxel Lin 	.set_voltage_sel = regulator_set_voltage_sel_regmap,
212ba3bd8a3SAxel Lin 	.list_voltage = regulator_list_voltage_table,
213c4bbfbd5SAxel Lin 	.map_voltage = regulator_map_voltage_ascend,
21430e6599dSAnuj Aggarwal };
21530e6599dSAnuj Aggarwal 
2164604a061SKrzysztof Kozlowski static const struct regmap_config tps65023_regmap_config = {
21790923351SMark Brown 	.reg_bits = 8,
21890923351SMark Brown 	.val_bits = 8,
21990923351SMark Brown };
22090923351SMark Brown 
2212d3eda67SThomas Elste static const struct regulator_desc tps65020_regulators[] = {
2222d3eda67SThomas Elste 	TPS65023_REGULATOR_DCDC(1, DCDC_FIXED_3300000_VSEL_table, 0x20),
2232d3eda67SThomas Elste 	TPS65023_REGULATOR_DCDC(2, DCDC_FIXED_1800000_VSEL_table, 0x10),
2242d3eda67SThomas Elste 	TPS65023_REGULATOR_DCDC(3, VCORE_VSEL_table, 0x08),
2252d3eda67SThomas Elste 	TPS65023_REGULATOR_LDO(1, TPS65020_LDO_VSEL_table, 0x07),
2262d3eda67SThomas Elste 	TPS65023_REGULATOR_LDO(2, TPS65020_LDO_VSEL_table, 0x70),
2272d3eda67SThomas Elste };
2282d3eda67SThomas Elste 
2292d3eda67SThomas Elste static const struct regulator_desc tps65021_regulators[] = {
2302d3eda67SThomas Elste 	TPS65023_REGULATOR_DCDC(1, DCDC_FIXED_3300000_VSEL_table, 0x20),
2312d3eda67SThomas Elste 	TPS65023_REGULATOR_DCDC(2, DCDC_FIXED_1800000_VSEL_table, 0x10),
2322d3eda67SThomas Elste 	TPS65023_REGULATOR_DCDC(3, VCORE_VSEL_table, 0x08),
2332d3eda67SThomas Elste 	TPS65023_REGULATOR_LDO(1, TPS65023_LDO1_VSEL_table, 0x07),
2342d3eda67SThomas Elste 	TPS65023_REGULATOR_LDO(2, TPS65023_LDO2_VSEL_table, 0x70),
2352d3eda67SThomas Elste };
2362d3eda67SThomas Elste 
2372d3eda67SThomas Elste static const struct regulator_desc tps65023_regulators[] = {
2382d3eda67SThomas Elste 	TPS65023_REGULATOR_DCDC(1, VCORE_VSEL_table, 0x20),
2392d3eda67SThomas Elste 	TPS65023_REGULATOR_DCDC(2, DCDC_FIXED_3300000_VSEL_table, 0x10),
2402d3eda67SThomas Elste 	TPS65023_REGULATOR_DCDC(3, DCDC_FIXED_1800000_VSEL_table, 0x08),
2412d3eda67SThomas Elste 	TPS65023_REGULATOR_LDO(1, TPS65023_LDO1_VSEL_table, 0x07),
2422d3eda67SThomas Elste 	TPS65023_REGULATOR_LDO(2, TPS65023_LDO2_VSEL_table, 0x70),
2432d3eda67SThomas Elste };
2442d3eda67SThomas Elste 
2452d3eda67SThomas Elste static struct tps_driver_data tps65020_drv_data = {
2462d3eda67SThomas Elste 	.desc = tps65020_regulators,
2472d3eda67SThomas Elste 	.core_regulator = TPS65023_DCDC_3,
2482d3eda67SThomas Elste };
2492d3eda67SThomas Elste 
2502d3eda67SThomas Elste static struct tps_driver_data tps65021_drv_data = {
2512d3eda67SThomas Elste 	.desc = tps65021_regulators,
2522d3eda67SThomas Elste 	.core_regulator = TPS65023_DCDC_3,
2532d3eda67SThomas Elste };
2542d3eda67SThomas Elste 
2552d3eda67SThomas Elste static struct tps_driver_data tps65023_drv_data = {
2562d3eda67SThomas Elste 	.desc = tps65023_regulators,
2572d3eda67SThomas Elste 	.core_regulator = TPS65023_DCDC_1,
2582d3eda67SThomas Elste };
2592d3eda67SThomas Elste 
tps_65023_probe(struct i2c_client * client)2603b5b07ddSUwe Kleine-König static int tps_65023_probe(struct i2c_client *client)
26130e6599dSAnuj Aggarwal {
2623b5b07ddSUwe Kleine-König 	const struct i2c_device_id *id = i2c_client_get_device_id(client);
2632d3eda67SThomas Elste 	struct regulator_init_data *init_data = dev_get_platdata(&client->dev);
264c172708dSMark Brown 	struct regulator_config config = { };
26530e6599dSAnuj Aggarwal 	struct tps_pmic *tps;
26630e6599dSAnuj Aggarwal 	int i;
26754d13ab1SDmitry Torokhov 	int error;
26830e6599dSAnuj Aggarwal 
26919a8da21SAxel Lin 	tps = devm_kzalloc(&client->dev, sizeof(*tps), GFP_KERNEL);
27030e6599dSAnuj Aggarwal 	if (!tps)
27130e6599dSAnuj Aggarwal 		return -ENOMEM;
27230e6599dSAnuj Aggarwal 
2732d3eda67SThomas Elste 	tps->driver_data = (struct tps_driver_data *)id->driver_data;
2742d3eda67SThomas Elste 
27519a8da21SAxel Lin 	tps->regmap = devm_regmap_init_i2c(client, &tps65023_regmap_config);
27690923351SMark Brown 	if (IS_ERR(tps->regmap)) {
27790923351SMark Brown 		error = PTR_ERR(tps->regmap);
27890923351SMark Brown 		dev_err(&client->dev, "Failed to allocate register map: %d\n",
27990923351SMark Brown 			error);
28019a8da21SAxel Lin 		return error;
28190923351SMark Brown 	}
28230e6599dSAnuj Aggarwal 
28330e6599dSAnuj Aggarwal 	/* common for all regulators */
284c172708dSMark Brown 	config.dev = &client->dev;
285c172708dSMark Brown 	config.driver_data = tps;
286ee7b1914SAxel Lin 	config.regmap = tps->regmap;
287c172708dSMark Brown 
2882d3eda67SThomas Elste 	for (i = 0; i < TPS65023_NUM_REGULATOR; i++) {
2892d3eda67SThomas Elste 		if (init_data)
2902d3eda67SThomas Elste 			config.init_data = &init_data[i];
2912d3eda67SThomas Elste 
29230e6599dSAnuj Aggarwal 		/* Register the regulators */
2932d3eda67SThomas Elste 		tps->rdev[i] = devm_regulator_register(&client->dev,
2942d3eda67SThomas Elste 					&tps->driver_data->desc[i], &config);
2952d3eda67SThomas Elste 		if (IS_ERR(tps->rdev[i])) {
29630e6599dSAnuj Aggarwal 			dev_err(&client->dev, "failed to register %s\n",
29730e6599dSAnuj Aggarwal 				id->name);
2982d3eda67SThomas Elste 			return PTR_ERR(tps->rdev[i]);
29930e6599dSAnuj Aggarwal 		}
30030e6599dSAnuj Aggarwal 	}
30130e6599dSAnuj Aggarwal 
30230e6599dSAnuj Aggarwal 	i2c_set_clientdata(client, tps);
30330e6599dSAnuj Aggarwal 
304fc999b83SMarcus Folkesson 	/* Enable setting output voltage by I2C */
30543530b69SJonghwan Choi 	regmap_update_bits(tps->regmap, TPS65023_REG_CON_CTRL2,
306c90722b5SRichard Cochran 			   TPS65023_REG_CTRL2_CORE_ADJ, 0);
307fc999b83SMarcus Folkesson 
30830e6599dSAnuj Aggarwal 	return 0;
30930e6599dSAnuj Aggarwal }
31030e6599dSAnuj Aggarwal 
3118536bf81SJisheng Zhang static const struct of_device_id __maybe_unused tps65023_of_match[] = {
3122d3eda67SThomas Elste 	{ .compatible = "ti,tps65020", .data = &tps65020_drv_data},
3132d3eda67SThomas Elste 	{ .compatible = "ti,tps65021", .data = &tps65021_drv_data},
3142d3eda67SThomas Elste 	{ .compatible = "ti,tps65023", .data = &tps65023_drv_data},
3159e108d33SLiam Girdwood 	{},
31630e6599dSAnuj Aggarwal };
3172d3eda67SThomas Elste MODULE_DEVICE_TABLE(of, tps65023_of_match);
31830e6599dSAnuj Aggarwal 
3192d3eda67SThomas Elste static const struct i2c_device_id tps_65023_id[] = {
3202d3eda67SThomas Elste 	{
3212d3eda67SThomas Elste 		.name = "tps65023",
3222d3eda67SThomas Elste 		.driver_data = (kernel_ulong_t)&tps65023_drv_data
3232d3eda67SThomas Elste 	}, {
3242d3eda67SThomas Elste 		.name = "tps65021",
3252d3eda67SThomas Elste 		.driver_data = (kernel_ulong_t)&tps65021_drv_data
3262d3eda67SThomas Elste 	}, {
3272d3eda67SThomas Elste 		.name = "tps65020",
3282d3eda67SThomas Elste 		.driver_data = (kernel_ulong_t)&tps65020_drv_data
3292d3eda67SThomas Elste 	},
3302d3eda67SThomas Elste 	{ },
3312d3eda67SThomas Elste };
33230e6599dSAnuj Aggarwal MODULE_DEVICE_TABLE(i2c, tps_65023_id);
33330e6599dSAnuj Aggarwal 
33430e6599dSAnuj Aggarwal static struct i2c_driver tps_65023_i2c_driver = {
33530e6599dSAnuj Aggarwal 	.driver = {
33630e6599dSAnuj Aggarwal 		.name = "tps65023",
337259b93b2SDouglas Anderson 		.probe_type = PROBE_PREFER_ASYNCHRONOUS,
3382d3eda67SThomas Elste 		.of_match_table = of_match_ptr(tps65023_of_match),
33930e6599dSAnuj Aggarwal 	},
340*964e1865SUwe Kleine-König 	.probe = tps_65023_probe,
3419e108d33SLiam Girdwood 	.id_table = tps_65023_id,
34230e6599dSAnuj Aggarwal };
34330e6599dSAnuj Aggarwal 
tps_65023_init(void)34430e6599dSAnuj Aggarwal static int __init tps_65023_init(void)
34530e6599dSAnuj Aggarwal {
34630e6599dSAnuj Aggarwal 	return i2c_add_driver(&tps_65023_i2c_driver);
34730e6599dSAnuj Aggarwal }
34830e6599dSAnuj Aggarwal subsys_initcall(tps_65023_init);
34930e6599dSAnuj Aggarwal 
tps_65023_cleanup(void)35030e6599dSAnuj Aggarwal static void __exit tps_65023_cleanup(void)
35130e6599dSAnuj Aggarwal {
35230e6599dSAnuj Aggarwal 	i2c_del_driver(&tps_65023_i2c_driver);
35330e6599dSAnuj Aggarwal }
35430e6599dSAnuj Aggarwal module_exit(tps_65023_cleanup);
35530e6599dSAnuj Aggarwal 
35630e6599dSAnuj Aggarwal MODULE_AUTHOR("Texas Instruments");
35730e6599dSAnuj Aggarwal MODULE_DESCRIPTION("TPS65023 voltage regulator driver");
35830e6599dSAnuj Aggarwal MODULE_LICENSE("GPL v2");
359