1 // SPDX-License-Identifier: GPL-2.0
3 * TI TPS68470 PMIC platform data definition.
5 * Copyright (c) 2021 Dan Scally <djrscally@gmail.com>
6 * Copyright (c) 2021 Red Hat Inc.
9 * Hans de Goede <hdegoede@redhat.com>
12 #include <linux/dmi.h>
13 #include <linux/gpio/machine.h>
14 #include <linux/platform_data/tps68470.h>
15 #include <linux/regulator/machine.h>
18 static struct regulator_consumer_supply int347a_core_consumer_supplies
[] = {
19 REGULATOR_SUPPLY("dvdd", "i2c-INT347A:00"),
22 static struct regulator_consumer_supply int347a_ana_consumer_supplies
[] = {
23 REGULATOR_SUPPLY("avdd", "i2c-INT347A:00"),
26 static struct regulator_consumer_supply int347a_vcm_consumer_supplies
[] = {
27 REGULATOR_SUPPLY("vdd", "i2c-INT347A:00-VCM"),
30 static struct regulator_consumer_supply int347a_vsio_consumer_supplies
[] = {
31 REGULATOR_SUPPLY("dovdd", "i2c-INT347A:00"),
32 REGULATOR_SUPPLY("vsio", "i2c-INT347A:00-VCM"),
33 REGULATOR_SUPPLY("vddd", "i2c-INT347E:00"),
36 static struct regulator_consumer_supply int347a_aux1_consumer_supplies
[] = {
37 REGULATOR_SUPPLY("vdda", "i2c-INT347E:00"),
40 static struct regulator_consumer_supply int347a_aux2_consumer_supplies
[] = {
41 REGULATOR_SUPPLY("vdddo", "i2c-INT347E:00"),
44 static const struct regulator_init_data surface_go_tps68470_core_reg_init_data
= {
49 .valid_ops_mask
= REGULATOR_CHANGE_STATUS
,
51 .num_consumer_supplies
= ARRAY_SIZE(int347a_core_consumer_supplies
),
52 .consumer_supplies
= int347a_core_consumer_supplies
,
55 static const struct regulator_init_data surface_go_tps68470_ana_reg_init_data
= {
60 .valid_ops_mask
= REGULATOR_CHANGE_STATUS
,
62 .num_consumer_supplies
= ARRAY_SIZE(int347a_ana_consumer_supplies
),
63 .consumer_supplies
= int347a_ana_consumer_supplies
,
66 static const struct regulator_init_data surface_go_tps68470_vcm_reg_init_data
= {
71 .valid_ops_mask
= REGULATOR_CHANGE_STATUS
,
73 .num_consumer_supplies
= ARRAY_SIZE(int347a_vcm_consumer_supplies
),
74 .consumer_supplies
= int347a_vcm_consumer_supplies
,
77 /* Ensure the always-on VIO regulator has the same voltage as VSIO */
78 static const struct regulator_init_data surface_go_tps68470_vio_reg_init_data
= {
87 static const struct regulator_init_data surface_go_tps68470_vsio_reg_init_data
= {
92 .valid_ops_mask
= REGULATOR_CHANGE_STATUS
,
94 .num_consumer_supplies
= ARRAY_SIZE(int347a_vsio_consumer_supplies
),
95 .consumer_supplies
= int347a_vsio_consumer_supplies
,
98 static const struct regulator_init_data surface_go_tps68470_aux1_reg_init_data
= {
103 .valid_ops_mask
= REGULATOR_CHANGE_STATUS
,
105 .num_consumer_supplies
= ARRAY_SIZE(int347a_aux1_consumer_supplies
),
106 .consumer_supplies
= int347a_aux1_consumer_supplies
,
109 static const struct regulator_init_data surface_go_tps68470_aux2_reg_init_data
= {
114 .valid_ops_mask
= REGULATOR_CHANGE_STATUS
,
116 .num_consumer_supplies
= ARRAY_SIZE(int347a_aux2_consumer_supplies
),
117 .consumer_supplies
= int347a_aux2_consumer_supplies
,
120 static const struct tps68470_regulator_platform_data surface_go_tps68470_pdata
= {
122 [TPS68470_CORE
] = &surface_go_tps68470_core_reg_init_data
,
123 [TPS68470_ANA
] = &surface_go_tps68470_ana_reg_init_data
,
124 [TPS68470_VCM
] = &surface_go_tps68470_vcm_reg_init_data
,
125 [TPS68470_VIO
] = &surface_go_tps68470_vio_reg_init_data
,
126 [TPS68470_VSIO
] = &surface_go_tps68470_vsio_reg_init_data
,
127 [TPS68470_AUX1
] = &surface_go_tps68470_aux1_reg_init_data
,
128 [TPS68470_AUX2
] = &surface_go_tps68470_aux2_reg_init_data
,
132 static struct gpiod_lookup_table surface_go_int347a_gpios
= {
133 .dev_id
= "i2c-INT347A:00",
135 GPIO_LOOKUP("tps68470-gpio", 9, "reset", GPIO_ACTIVE_LOW
),
136 GPIO_LOOKUP("tps68470-gpio", 7, "powerdown", GPIO_ACTIVE_LOW
),
141 static struct gpiod_lookup_table surface_go_int347e_gpios
= {
142 .dev_id
= "i2c-INT347E:00",
144 GPIO_LOOKUP("tps68470-gpio", 5, "enable", GPIO_ACTIVE_HIGH
),
149 static const struct int3472_tps68470_board_data surface_go_tps68470_board_data
= {
150 .dev_name
= "i2c-INT3472:05",
151 .tps68470_regulator_pdata
= &surface_go_tps68470_pdata
,
152 .n_gpiod_lookups
= 2,
153 .tps68470_gpio_lookup_tables
= {
154 &surface_go_int347a_gpios
,
155 &surface_go_int347e_gpios
,
159 static const struct int3472_tps68470_board_data surface_go3_tps68470_board_data
= {
160 .dev_name
= "i2c-INT3472:01",
161 .tps68470_regulator_pdata
= &surface_go_tps68470_pdata
,
162 .n_gpiod_lookups
= 2,
163 .tps68470_gpio_lookup_tables
= {
164 &surface_go_int347a_gpios
,
165 &surface_go_int347e_gpios
,
169 static const struct dmi_system_id int3472_tps68470_board_data_table
[] = {
172 DMI_EXACT_MATCH(DMI_SYS_VENDOR
, "Microsoft Corporation"),
173 DMI_EXACT_MATCH(DMI_PRODUCT_NAME
, "Surface Go"),
175 .driver_data
= (void *)&surface_go_tps68470_board_data
,
179 DMI_EXACT_MATCH(DMI_SYS_VENDOR
, "Microsoft Corporation"),
180 DMI_EXACT_MATCH(DMI_PRODUCT_NAME
, "Surface Go 2"),
182 .driver_data
= (void *)&surface_go_tps68470_board_data
,
186 DMI_EXACT_MATCH(DMI_SYS_VENDOR
, "Microsoft Corporation"),
187 DMI_EXACT_MATCH(DMI_PRODUCT_NAME
, "Surface Go 3"),
189 .driver_data
= (void *)&surface_go3_tps68470_board_data
,
194 const struct int3472_tps68470_board_data
*int3472_tps68470_get_board_data(const char *dev_name
)
196 const struct int3472_tps68470_board_data
*board_data
;
197 const struct dmi_system_id
*match
;
199 for (match
= dmi_first_match(int3472_tps68470_board_data_table
);
201 match
= dmi_first_match(match
+ 1)) {
202 board_data
= match
->driver_data
;
203 if (strcmp(board_data
->dev_name
, dev_name
) == 0)