162306a36Sopenharmony_ci// SPDX-License-Identifier: GPL-2.0-only
262306a36Sopenharmony_ci/*
362306a36Sopenharmony_ci * tps65023-regulator.c
462306a36Sopenharmony_ci *
562306a36Sopenharmony_ci * Supports TPS65023 Regulator
662306a36Sopenharmony_ci *
762306a36Sopenharmony_ci * Copyright (C) 2009 Texas Instrument Incorporated - https://www.ti.com/
862306a36Sopenharmony_ci */
962306a36Sopenharmony_ci
1062306a36Sopenharmony_ci#include <linux/kernel.h>
1162306a36Sopenharmony_ci#include <linux/module.h>
1262306a36Sopenharmony_ci#include <linux/init.h>
1362306a36Sopenharmony_ci#include <linux/err.h>
1462306a36Sopenharmony_ci#include <linux/platform_device.h>
1562306a36Sopenharmony_ci#include <linux/regulator/driver.h>
1662306a36Sopenharmony_ci#include <linux/regulator/machine.h>
1762306a36Sopenharmony_ci#include <linux/i2c.h>
1862306a36Sopenharmony_ci#include <linux/slab.h>
1962306a36Sopenharmony_ci#include <linux/regmap.h>
2062306a36Sopenharmony_ci
2162306a36Sopenharmony_ci/* Register definitions */
2262306a36Sopenharmony_ci#define	TPS65023_REG_VERSION		0
2362306a36Sopenharmony_ci#define	TPS65023_REG_PGOODZ		1
2462306a36Sopenharmony_ci#define	TPS65023_REG_MASK		2
2562306a36Sopenharmony_ci#define	TPS65023_REG_REG_CTRL		3
2662306a36Sopenharmony_ci#define	TPS65023_REG_CON_CTRL		4
2762306a36Sopenharmony_ci#define	TPS65023_REG_CON_CTRL2		5
2862306a36Sopenharmony_ci#define	TPS65023_REG_DEF_CORE		6
2962306a36Sopenharmony_ci#define	TPS65023_REG_DEFSLEW		7
3062306a36Sopenharmony_ci#define	TPS65023_REG_LDO_CTRL		8
3162306a36Sopenharmony_ci
3262306a36Sopenharmony_ci/* PGOODZ bitfields */
3362306a36Sopenharmony_ci#define	TPS65023_PGOODZ_PWRFAILZ	BIT(7)
3462306a36Sopenharmony_ci#define	TPS65023_PGOODZ_LOWBATTZ	BIT(6)
3562306a36Sopenharmony_ci#define	TPS65023_PGOODZ_VDCDC1		BIT(5)
3662306a36Sopenharmony_ci#define	TPS65023_PGOODZ_VDCDC2		BIT(4)
3762306a36Sopenharmony_ci#define	TPS65023_PGOODZ_VDCDC3		BIT(3)
3862306a36Sopenharmony_ci#define	TPS65023_PGOODZ_LDO2		BIT(2)
3962306a36Sopenharmony_ci#define	TPS65023_PGOODZ_LDO1		BIT(1)
4062306a36Sopenharmony_ci
4162306a36Sopenharmony_ci/* MASK bitfields */
4262306a36Sopenharmony_ci#define	TPS65023_MASK_PWRFAILZ		BIT(7)
4362306a36Sopenharmony_ci#define	TPS65023_MASK_LOWBATTZ		BIT(6)
4462306a36Sopenharmony_ci#define	TPS65023_MASK_VDCDC1		BIT(5)
4562306a36Sopenharmony_ci#define	TPS65023_MASK_VDCDC2		BIT(4)
4662306a36Sopenharmony_ci#define	TPS65023_MASK_VDCDC3		BIT(3)
4762306a36Sopenharmony_ci#define	TPS65023_MASK_LDO2		BIT(2)
4862306a36Sopenharmony_ci#define	TPS65023_MASK_LDO1		BIT(1)
4962306a36Sopenharmony_ci
5062306a36Sopenharmony_ci/* REG_CTRL bitfields */
5162306a36Sopenharmony_ci#define TPS65023_REG_CTRL_VDCDC1_EN	BIT(5)
5262306a36Sopenharmony_ci#define TPS65023_REG_CTRL_VDCDC2_EN	BIT(4)
5362306a36Sopenharmony_ci#define TPS65023_REG_CTRL_VDCDC3_EN	BIT(3)
5462306a36Sopenharmony_ci#define TPS65023_REG_CTRL_LDO2_EN	BIT(2)
5562306a36Sopenharmony_ci#define TPS65023_REG_CTRL_LDO1_EN	BIT(1)
5662306a36Sopenharmony_ci
5762306a36Sopenharmony_ci/* REG_CTRL2 bitfields */
5862306a36Sopenharmony_ci#define TPS65023_REG_CTRL2_GO		BIT(7)
5962306a36Sopenharmony_ci#define TPS65023_REG_CTRL2_CORE_ADJ	BIT(6)
6062306a36Sopenharmony_ci#define TPS65023_REG_CTRL2_DCDC2	BIT(2)
6162306a36Sopenharmony_ci#define TPS65023_REG_CTRL2_DCDC1	BIT(1)
6262306a36Sopenharmony_ci#define TPS65023_REG_CTRL2_DCDC3	BIT(0)
6362306a36Sopenharmony_ci
6462306a36Sopenharmony_ci/* Number of step-down converters available */
6562306a36Sopenharmony_ci#define TPS65023_NUM_DCDC		3
6662306a36Sopenharmony_ci/* Number of LDO voltage regulators  available */
6762306a36Sopenharmony_ci#define TPS65023_NUM_LDO		2
6862306a36Sopenharmony_ci/* Number of total regulators available */
6962306a36Sopenharmony_ci#define TPS65023_NUM_REGULATOR	(TPS65023_NUM_DCDC + TPS65023_NUM_LDO)
7062306a36Sopenharmony_ci
7162306a36Sopenharmony_ci/* DCDCs */
7262306a36Sopenharmony_ci#define TPS65023_DCDC_1			0
7362306a36Sopenharmony_ci#define TPS65023_DCDC_2			1
7462306a36Sopenharmony_ci#define TPS65023_DCDC_3			2
7562306a36Sopenharmony_ci/* LDOs */
7662306a36Sopenharmony_ci#define TPS65023_LDO_1			3
7762306a36Sopenharmony_ci#define TPS65023_LDO_2			4
7862306a36Sopenharmony_ci
7962306a36Sopenharmony_ci#define TPS65023_MAX_REG_ID		TPS65023_LDO_2
8062306a36Sopenharmony_ci
8162306a36Sopenharmony_ci#define TPS65023_REGULATOR_DCDC(_num, _t, _em)			\
8262306a36Sopenharmony_ci	{							\
8362306a36Sopenharmony_ci		.name		= "VDCDC"#_num,			\
8462306a36Sopenharmony_ci		.of_match	= of_match_ptr("VDCDC"#_num),	\
8562306a36Sopenharmony_ci		.regulators_node = of_match_ptr("regulators"),	\
8662306a36Sopenharmony_ci		.id		= TPS65023_DCDC_##_num,		\
8762306a36Sopenharmony_ci		.n_voltages     = ARRAY_SIZE(_t),		\
8862306a36Sopenharmony_ci		.ops		= &tps65023_dcdc_ops,		\
8962306a36Sopenharmony_ci		.type		= REGULATOR_VOLTAGE,		\
9062306a36Sopenharmony_ci		.owner		= THIS_MODULE,			\
9162306a36Sopenharmony_ci		.volt_table	= _t,				\
9262306a36Sopenharmony_ci		.vsel_reg	= TPS65023_REG_DEF_CORE,	\
9362306a36Sopenharmony_ci		.vsel_mask	= ARRAY_SIZE(_t) - 1,		\
9462306a36Sopenharmony_ci		.enable_mask	= _em,				\
9562306a36Sopenharmony_ci		.enable_reg	= TPS65023_REG_REG_CTRL,	\
9662306a36Sopenharmony_ci		.apply_reg	= TPS65023_REG_CON_CTRL2,	\
9762306a36Sopenharmony_ci		.apply_bit	= TPS65023_REG_CTRL2_GO,	\
9862306a36Sopenharmony_ci	}							\
9962306a36Sopenharmony_ci
10062306a36Sopenharmony_ci#define TPS65023_REGULATOR_LDO(_num, _t, _vm)			\
10162306a36Sopenharmony_ci	{							\
10262306a36Sopenharmony_ci		.name		= "LDO"#_num,			\
10362306a36Sopenharmony_ci		.of_match	= of_match_ptr("LDO"#_num),	\
10462306a36Sopenharmony_ci		.regulators_node = of_match_ptr("regulators"),	\
10562306a36Sopenharmony_ci		.id		= TPS65023_LDO_##_num,		\
10662306a36Sopenharmony_ci		.n_voltages     = ARRAY_SIZE(_t),		\
10762306a36Sopenharmony_ci		.ops		= &tps65023_ldo_ops,		\
10862306a36Sopenharmony_ci		.type		= REGULATOR_VOLTAGE,		\
10962306a36Sopenharmony_ci		.owner		= THIS_MODULE,			\
11062306a36Sopenharmony_ci		.volt_table	= _t,				\
11162306a36Sopenharmony_ci		.vsel_reg	= TPS65023_REG_LDO_CTRL,	\
11262306a36Sopenharmony_ci		.vsel_mask	= _vm,				\
11362306a36Sopenharmony_ci		.enable_mask	= 1 << (_num),			\
11462306a36Sopenharmony_ci		.enable_reg	= TPS65023_REG_REG_CTRL,	\
11562306a36Sopenharmony_ci	}							\
11662306a36Sopenharmony_ci
11762306a36Sopenharmony_ci/* Supported voltage values for regulators */
11862306a36Sopenharmony_cistatic const unsigned int VCORE_VSEL_table[] = {
11962306a36Sopenharmony_ci	800000, 825000, 850000, 875000,
12062306a36Sopenharmony_ci	900000, 925000, 950000, 975000,
12162306a36Sopenharmony_ci	1000000, 1025000, 1050000, 1075000,
12262306a36Sopenharmony_ci	1100000, 1125000, 1150000, 1175000,
12362306a36Sopenharmony_ci	1200000, 1225000, 1250000, 1275000,
12462306a36Sopenharmony_ci	1300000, 1325000, 1350000, 1375000,
12562306a36Sopenharmony_ci	1400000, 1425000, 1450000, 1475000,
12662306a36Sopenharmony_ci	1500000, 1525000, 1550000, 1600000,
12762306a36Sopenharmony_ci};
12862306a36Sopenharmony_ci
12962306a36Sopenharmony_cistatic const unsigned int DCDC_FIXED_3300000_VSEL_table[] = {
13062306a36Sopenharmony_ci	3300000,
13162306a36Sopenharmony_ci};
13262306a36Sopenharmony_ci
13362306a36Sopenharmony_cistatic const unsigned int DCDC_FIXED_1800000_VSEL_table[] = {
13462306a36Sopenharmony_ci	1800000,
13562306a36Sopenharmony_ci};
13662306a36Sopenharmony_ci
13762306a36Sopenharmony_ci/* Supported voltage values for LDO regulators for tps65020 */
13862306a36Sopenharmony_cistatic const unsigned int TPS65020_LDO_VSEL_table[] = {
13962306a36Sopenharmony_ci	1000000, 1050000, 1100000, 1300000,
14062306a36Sopenharmony_ci	1800000, 2500000, 3000000, 3300000,
14162306a36Sopenharmony_ci};
14262306a36Sopenharmony_ci
14362306a36Sopenharmony_ci/* Supported voltage values for LDO regulators
14462306a36Sopenharmony_ci * for tps65021 and tps65023 */
14562306a36Sopenharmony_cistatic const unsigned int TPS65023_LDO1_VSEL_table[] = {
14662306a36Sopenharmony_ci	1000000, 1100000, 1300000, 1800000,
14762306a36Sopenharmony_ci	2200000, 2600000, 2800000, 3150000,
14862306a36Sopenharmony_ci};
14962306a36Sopenharmony_ci
15062306a36Sopenharmony_cistatic const unsigned int TPS65023_LDO2_VSEL_table[] = {
15162306a36Sopenharmony_ci	1050000, 1200000, 1300000, 1800000,
15262306a36Sopenharmony_ci	2500000, 2800000, 3000000, 3300000,
15362306a36Sopenharmony_ci};
15462306a36Sopenharmony_ci
15562306a36Sopenharmony_ci/* PMIC details */
15662306a36Sopenharmony_cistruct tps_pmic {
15762306a36Sopenharmony_ci	struct regulator_dev *rdev[TPS65023_NUM_REGULATOR];
15862306a36Sopenharmony_ci	const struct tps_driver_data *driver_data;
15962306a36Sopenharmony_ci	struct regmap *regmap;
16062306a36Sopenharmony_ci};
16162306a36Sopenharmony_ci
16262306a36Sopenharmony_ci/* Struct passed as driver data */
16362306a36Sopenharmony_cistruct tps_driver_data {
16462306a36Sopenharmony_ci	const struct regulator_desc *desc;
16562306a36Sopenharmony_ci	u8 core_regulator;
16662306a36Sopenharmony_ci};
16762306a36Sopenharmony_ci
16862306a36Sopenharmony_cistatic int tps65023_dcdc_get_voltage_sel(struct regulator_dev *dev)
16962306a36Sopenharmony_ci{
17062306a36Sopenharmony_ci	struct tps_pmic *tps = rdev_get_drvdata(dev);
17162306a36Sopenharmony_ci	int dcdc = rdev_get_id(dev);
17262306a36Sopenharmony_ci
17362306a36Sopenharmony_ci	if (dcdc < TPS65023_DCDC_1 || dcdc > TPS65023_DCDC_3)
17462306a36Sopenharmony_ci		return -EINVAL;
17562306a36Sopenharmony_ci
17662306a36Sopenharmony_ci	if (dcdc != tps->driver_data->core_regulator)
17762306a36Sopenharmony_ci		return 0;
17862306a36Sopenharmony_ci
17962306a36Sopenharmony_ci	return regulator_get_voltage_sel_regmap(dev);
18062306a36Sopenharmony_ci}
18162306a36Sopenharmony_ci
18262306a36Sopenharmony_cistatic int tps65023_dcdc_set_voltage_sel(struct regulator_dev *dev,
18362306a36Sopenharmony_ci					 unsigned selector)
18462306a36Sopenharmony_ci{
18562306a36Sopenharmony_ci	struct tps_pmic *tps = rdev_get_drvdata(dev);
18662306a36Sopenharmony_ci	int dcdc = rdev_get_id(dev);
18762306a36Sopenharmony_ci
18862306a36Sopenharmony_ci	if (dcdc != tps->driver_data->core_regulator)
18962306a36Sopenharmony_ci		return -EINVAL;
19062306a36Sopenharmony_ci
19162306a36Sopenharmony_ci	return regulator_set_voltage_sel_regmap(dev, selector);
19262306a36Sopenharmony_ci}
19362306a36Sopenharmony_ci
19462306a36Sopenharmony_ci/* Operations permitted on VDCDCx */
19562306a36Sopenharmony_cistatic const struct regulator_ops tps65023_dcdc_ops = {
19662306a36Sopenharmony_ci	.is_enabled = regulator_is_enabled_regmap,
19762306a36Sopenharmony_ci	.enable = regulator_enable_regmap,
19862306a36Sopenharmony_ci	.disable = regulator_disable_regmap,
19962306a36Sopenharmony_ci	.get_voltage_sel = tps65023_dcdc_get_voltage_sel,
20062306a36Sopenharmony_ci	.set_voltage_sel = tps65023_dcdc_set_voltage_sel,
20162306a36Sopenharmony_ci	.list_voltage = regulator_list_voltage_table,
20262306a36Sopenharmony_ci	.map_voltage = regulator_map_voltage_ascend,
20362306a36Sopenharmony_ci};
20462306a36Sopenharmony_ci
20562306a36Sopenharmony_ci/* Operations permitted on LDOx */
20662306a36Sopenharmony_cistatic const struct regulator_ops tps65023_ldo_ops = {
20762306a36Sopenharmony_ci	.is_enabled = regulator_is_enabled_regmap,
20862306a36Sopenharmony_ci	.enable = regulator_enable_regmap,
20962306a36Sopenharmony_ci	.disable = regulator_disable_regmap,
21062306a36Sopenharmony_ci	.get_voltage_sel = regulator_get_voltage_sel_regmap,
21162306a36Sopenharmony_ci	.set_voltage_sel = regulator_set_voltage_sel_regmap,
21262306a36Sopenharmony_ci	.list_voltage = regulator_list_voltage_table,
21362306a36Sopenharmony_ci	.map_voltage = regulator_map_voltage_ascend,
21462306a36Sopenharmony_ci};
21562306a36Sopenharmony_ci
21662306a36Sopenharmony_cistatic const struct regmap_config tps65023_regmap_config = {
21762306a36Sopenharmony_ci	.reg_bits = 8,
21862306a36Sopenharmony_ci	.val_bits = 8,
21962306a36Sopenharmony_ci};
22062306a36Sopenharmony_ci
22162306a36Sopenharmony_cistatic const struct regulator_desc tps65020_regulators[] = {
22262306a36Sopenharmony_ci	TPS65023_REGULATOR_DCDC(1, DCDC_FIXED_3300000_VSEL_table, 0x20),
22362306a36Sopenharmony_ci	TPS65023_REGULATOR_DCDC(2, DCDC_FIXED_1800000_VSEL_table, 0x10),
22462306a36Sopenharmony_ci	TPS65023_REGULATOR_DCDC(3, VCORE_VSEL_table, 0x08),
22562306a36Sopenharmony_ci	TPS65023_REGULATOR_LDO(1, TPS65020_LDO_VSEL_table, 0x07),
22662306a36Sopenharmony_ci	TPS65023_REGULATOR_LDO(2, TPS65020_LDO_VSEL_table, 0x70),
22762306a36Sopenharmony_ci};
22862306a36Sopenharmony_ci
22962306a36Sopenharmony_cistatic const struct regulator_desc tps65021_regulators[] = {
23062306a36Sopenharmony_ci	TPS65023_REGULATOR_DCDC(1, DCDC_FIXED_3300000_VSEL_table, 0x20),
23162306a36Sopenharmony_ci	TPS65023_REGULATOR_DCDC(2, DCDC_FIXED_1800000_VSEL_table, 0x10),
23262306a36Sopenharmony_ci	TPS65023_REGULATOR_DCDC(3, VCORE_VSEL_table, 0x08),
23362306a36Sopenharmony_ci	TPS65023_REGULATOR_LDO(1, TPS65023_LDO1_VSEL_table, 0x07),
23462306a36Sopenharmony_ci	TPS65023_REGULATOR_LDO(2, TPS65023_LDO2_VSEL_table, 0x70),
23562306a36Sopenharmony_ci};
23662306a36Sopenharmony_ci
23762306a36Sopenharmony_cistatic const struct regulator_desc tps65023_regulators[] = {
23862306a36Sopenharmony_ci	TPS65023_REGULATOR_DCDC(1, VCORE_VSEL_table, 0x20),
23962306a36Sopenharmony_ci	TPS65023_REGULATOR_DCDC(2, DCDC_FIXED_3300000_VSEL_table, 0x10),
24062306a36Sopenharmony_ci	TPS65023_REGULATOR_DCDC(3, DCDC_FIXED_1800000_VSEL_table, 0x08),
24162306a36Sopenharmony_ci	TPS65023_REGULATOR_LDO(1, TPS65023_LDO1_VSEL_table, 0x07),
24262306a36Sopenharmony_ci	TPS65023_REGULATOR_LDO(2, TPS65023_LDO2_VSEL_table, 0x70),
24362306a36Sopenharmony_ci};
24462306a36Sopenharmony_ci
24562306a36Sopenharmony_cistatic struct tps_driver_data tps65020_drv_data = {
24662306a36Sopenharmony_ci	.desc = tps65020_regulators,
24762306a36Sopenharmony_ci	.core_regulator = TPS65023_DCDC_3,
24862306a36Sopenharmony_ci};
24962306a36Sopenharmony_ci
25062306a36Sopenharmony_cistatic struct tps_driver_data tps65021_drv_data = {
25162306a36Sopenharmony_ci	.desc = tps65021_regulators,
25262306a36Sopenharmony_ci	.core_regulator = TPS65023_DCDC_3,
25362306a36Sopenharmony_ci};
25462306a36Sopenharmony_ci
25562306a36Sopenharmony_cistatic struct tps_driver_data tps65023_drv_data = {
25662306a36Sopenharmony_ci	.desc = tps65023_regulators,
25762306a36Sopenharmony_ci	.core_regulator = TPS65023_DCDC_1,
25862306a36Sopenharmony_ci};
25962306a36Sopenharmony_ci
26062306a36Sopenharmony_cistatic int tps_65023_probe(struct i2c_client *client)
26162306a36Sopenharmony_ci{
26262306a36Sopenharmony_ci	const struct i2c_device_id *id = i2c_client_get_device_id(client);
26362306a36Sopenharmony_ci	struct regulator_init_data *init_data = dev_get_platdata(&client->dev);
26462306a36Sopenharmony_ci	struct regulator_config config = { };
26562306a36Sopenharmony_ci	struct tps_pmic *tps;
26662306a36Sopenharmony_ci	int i;
26762306a36Sopenharmony_ci	int error;
26862306a36Sopenharmony_ci
26962306a36Sopenharmony_ci	tps = devm_kzalloc(&client->dev, sizeof(*tps), GFP_KERNEL);
27062306a36Sopenharmony_ci	if (!tps)
27162306a36Sopenharmony_ci		return -ENOMEM;
27262306a36Sopenharmony_ci
27362306a36Sopenharmony_ci	tps->driver_data = (struct tps_driver_data *)id->driver_data;
27462306a36Sopenharmony_ci
27562306a36Sopenharmony_ci	tps->regmap = devm_regmap_init_i2c(client, &tps65023_regmap_config);
27662306a36Sopenharmony_ci	if (IS_ERR(tps->regmap)) {
27762306a36Sopenharmony_ci		error = PTR_ERR(tps->regmap);
27862306a36Sopenharmony_ci		dev_err(&client->dev, "Failed to allocate register map: %d\n",
27962306a36Sopenharmony_ci			error);
28062306a36Sopenharmony_ci		return error;
28162306a36Sopenharmony_ci	}
28262306a36Sopenharmony_ci
28362306a36Sopenharmony_ci	/* common for all regulators */
28462306a36Sopenharmony_ci	config.dev = &client->dev;
28562306a36Sopenharmony_ci	config.driver_data = tps;
28662306a36Sopenharmony_ci	config.regmap = tps->regmap;
28762306a36Sopenharmony_ci
28862306a36Sopenharmony_ci	for (i = 0; i < TPS65023_NUM_REGULATOR; i++) {
28962306a36Sopenharmony_ci		if (init_data)
29062306a36Sopenharmony_ci			config.init_data = &init_data[i];
29162306a36Sopenharmony_ci
29262306a36Sopenharmony_ci		/* Register the regulators */
29362306a36Sopenharmony_ci		tps->rdev[i] = devm_regulator_register(&client->dev,
29462306a36Sopenharmony_ci					&tps->driver_data->desc[i], &config);
29562306a36Sopenharmony_ci		if (IS_ERR(tps->rdev[i])) {
29662306a36Sopenharmony_ci			dev_err(&client->dev, "failed to register %s\n",
29762306a36Sopenharmony_ci				id->name);
29862306a36Sopenharmony_ci			return PTR_ERR(tps->rdev[i]);
29962306a36Sopenharmony_ci		}
30062306a36Sopenharmony_ci	}
30162306a36Sopenharmony_ci
30262306a36Sopenharmony_ci	i2c_set_clientdata(client, tps);
30362306a36Sopenharmony_ci
30462306a36Sopenharmony_ci	/* Enable setting output voltage by I2C */
30562306a36Sopenharmony_ci	regmap_update_bits(tps->regmap, TPS65023_REG_CON_CTRL2,
30662306a36Sopenharmony_ci			   TPS65023_REG_CTRL2_CORE_ADJ, 0);
30762306a36Sopenharmony_ci
30862306a36Sopenharmony_ci	return 0;
30962306a36Sopenharmony_ci}
31062306a36Sopenharmony_ci
31162306a36Sopenharmony_cistatic const struct of_device_id __maybe_unused tps65023_of_match[] = {
31262306a36Sopenharmony_ci	{ .compatible = "ti,tps65020", .data = &tps65020_drv_data},
31362306a36Sopenharmony_ci	{ .compatible = "ti,tps65021", .data = &tps65021_drv_data},
31462306a36Sopenharmony_ci	{ .compatible = "ti,tps65023", .data = &tps65023_drv_data},
31562306a36Sopenharmony_ci	{},
31662306a36Sopenharmony_ci};
31762306a36Sopenharmony_ciMODULE_DEVICE_TABLE(of, tps65023_of_match);
31862306a36Sopenharmony_ci
31962306a36Sopenharmony_cistatic const struct i2c_device_id tps_65023_id[] = {
32062306a36Sopenharmony_ci	{
32162306a36Sopenharmony_ci		.name = "tps65023",
32262306a36Sopenharmony_ci		.driver_data = (kernel_ulong_t)&tps65023_drv_data
32362306a36Sopenharmony_ci	}, {
32462306a36Sopenharmony_ci		.name = "tps65021",
32562306a36Sopenharmony_ci		.driver_data = (kernel_ulong_t)&tps65021_drv_data
32662306a36Sopenharmony_ci	}, {
32762306a36Sopenharmony_ci		.name = "tps65020",
32862306a36Sopenharmony_ci		.driver_data = (kernel_ulong_t)&tps65020_drv_data
32962306a36Sopenharmony_ci	},
33062306a36Sopenharmony_ci	{ },
33162306a36Sopenharmony_ci};
33262306a36Sopenharmony_ciMODULE_DEVICE_TABLE(i2c, tps_65023_id);
33362306a36Sopenharmony_ci
33462306a36Sopenharmony_cistatic struct i2c_driver tps_65023_i2c_driver = {
33562306a36Sopenharmony_ci	.driver = {
33662306a36Sopenharmony_ci		.name = "tps65023",
33762306a36Sopenharmony_ci		.probe_type = PROBE_PREFER_ASYNCHRONOUS,
33862306a36Sopenharmony_ci		.of_match_table = of_match_ptr(tps65023_of_match),
33962306a36Sopenharmony_ci	},
34062306a36Sopenharmony_ci	.probe = tps_65023_probe,
34162306a36Sopenharmony_ci	.id_table = tps_65023_id,
34262306a36Sopenharmony_ci};
34362306a36Sopenharmony_ci
34462306a36Sopenharmony_cistatic int __init tps_65023_init(void)
34562306a36Sopenharmony_ci{
34662306a36Sopenharmony_ci	return i2c_add_driver(&tps_65023_i2c_driver);
34762306a36Sopenharmony_ci}
34862306a36Sopenharmony_cisubsys_initcall(tps_65023_init);
34962306a36Sopenharmony_ci
35062306a36Sopenharmony_cistatic void __exit tps_65023_cleanup(void)
35162306a36Sopenharmony_ci{
35262306a36Sopenharmony_ci	i2c_del_driver(&tps_65023_i2c_driver);
35362306a36Sopenharmony_ci}
35462306a36Sopenharmony_cimodule_exit(tps_65023_cleanup);
35562306a36Sopenharmony_ci
35662306a36Sopenharmony_ciMODULE_AUTHOR("Texas Instruments");
35762306a36Sopenharmony_ciMODULE_DESCRIPTION("TPS65023 voltage regulator driver");
35862306a36Sopenharmony_ciMODULE_LICENSE("GPL v2");
359