1 // SPDX-License-Identifier: GPL-2.0 2 /* 3 * TI TPS68470 PMIC platform data definition. 4 * 5 * Copyright (c) 2021 Dan Scally <djrscally@gmail.com> 6 * Copyright (c) 2021 Red Hat Inc. 7 * 8 * Red Hat authors: 9 * Hans de Goede <hdegoede@redhat.com> 10 */ 11 12 #include <linux/dmi.h> 13 #include <linux/gpio/machine.h> 14 #include <linux/platform_data/tps68470.h> 15 #include <linux/regulator/machine.h> 16 #include "tps68470.h" 17 18 static struct regulator_consumer_supply int347a_core_consumer_supplies[] = { 19 REGULATOR_SUPPLY("dvdd", "i2c-INT347A:00"), 20 }; 21 22 static struct regulator_consumer_supply int347a_ana_consumer_supplies[] = { 23 REGULATOR_SUPPLY("avdd", "i2c-INT347A:00"), 24 }; 25 26 static struct regulator_consumer_supply int347a_vcm_consumer_supplies[] = { 27 REGULATOR_SUPPLY("vdd", "i2c-INT347A:00-VCM"), 28 }; 29 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 }; 34 35 static const struct regulator_init_data surface_go_tps68470_core_reg_init_data = { 36 .constraints = { 37 .min_uV = 1200000, 38 .max_uV = 1200000, 39 .apply_uV = true, 40 .valid_ops_mask = REGULATOR_CHANGE_STATUS, 41 }, 42 .num_consumer_supplies = ARRAY_SIZE(int347a_core_consumer_supplies), 43 .consumer_supplies = int347a_core_consumer_supplies, 44 }; 45 46 static const struct regulator_init_data surface_go_tps68470_ana_reg_init_data = { 47 .constraints = { 48 .min_uV = 2815200, 49 .max_uV = 2815200, 50 .apply_uV = true, 51 .valid_ops_mask = REGULATOR_CHANGE_STATUS, 52 }, 53 .num_consumer_supplies = ARRAY_SIZE(int347a_ana_consumer_supplies), 54 .consumer_supplies = int347a_ana_consumer_supplies, 55 }; 56 57 static const struct regulator_init_data surface_go_tps68470_vcm_reg_init_data = { 58 .constraints = { 59 .min_uV = 2815200, 60 .max_uV = 2815200, 61 .apply_uV = true, 62 .valid_ops_mask = REGULATOR_CHANGE_STATUS, 63 }, 64 .num_consumer_supplies = ARRAY_SIZE(int347a_vcm_consumer_supplies), 65 .consumer_supplies = int347a_vcm_consumer_supplies, 66 }; 67 68 /* Ensure the always-on VIO regulator has the same voltage as VSIO */ 69 static const struct regulator_init_data surface_go_tps68470_vio_reg_init_data = { 70 .constraints = { 71 .min_uV = 1800600, 72 .max_uV = 1800600, 73 .apply_uV = true, 74 .always_on = true, 75 }, 76 }; 77 78 static const struct regulator_init_data surface_go_tps68470_vsio_reg_init_data = { 79 .constraints = { 80 .min_uV = 1800600, 81 .max_uV = 1800600, 82 .apply_uV = true, 83 .valid_ops_mask = REGULATOR_CHANGE_STATUS, 84 }, 85 .num_consumer_supplies = ARRAY_SIZE(int347a_vsio_consumer_supplies), 86 .consumer_supplies = int347a_vsio_consumer_supplies, 87 }; 88 89 static const struct tps68470_regulator_platform_data surface_go_tps68470_pdata = { 90 .reg_init_data = { 91 [TPS68470_CORE] = &surface_go_tps68470_core_reg_init_data, 92 [TPS68470_ANA] = &surface_go_tps68470_ana_reg_init_data, 93 [TPS68470_VCM] = &surface_go_tps68470_vcm_reg_init_data, 94 [TPS68470_VIO] = &surface_go_tps68470_vio_reg_init_data, 95 [TPS68470_VSIO] = &surface_go_tps68470_vsio_reg_init_data, 96 }, 97 }; 98 99 static struct gpiod_lookup_table surface_go_tps68470_gpios = { 100 .dev_id = "i2c-INT347A:00", 101 .table = { 102 GPIO_LOOKUP("tps68470-gpio", 9, "reset", GPIO_ACTIVE_LOW), 103 GPIO_LOOKUP("tps68470-gpio", 7, "powerdown", GPIO_ACTIVE_LOW) 104 } 105 }; 106 107 static const struct int3472_tps68470_board_data surface_go_tps68470_board_data = { 108 .dev_name = "i2c-INT3472:05", 109 .tps68470_gpio_lookup_table = &surface_go_tps68470_gpios, 110 .tps68470_regulator_pdata = &surface_go_tps68470_pdata, 111 }; 112 113 static const struct int3472_tps68470_board_data surface_go3_tps68470_board_data = { 114 .dev_name = "i2c-INT3472:01", 115 .tps68470_gpio_lookup_table = &surface_go_tps68470_gpios, 116 .tps68470_regulator_pdata = &surface_go_tps68470_pdata, 117 }; 118 119 static const struct dmi_system_id int3472_tps68470_board_data_table[] = { 120 { 121 .matches = { 122 DMI_EXACT_MATCH(DMI_SYS_VENDOR, "Microsoft Corporation"), 123 DMI_EXACT_MATCH(DMI_PRODUCT_NAME, "Surface Go"), 124 }, 125 .driver_data = (void *)&surface_go_tps68470_board_data, 126 }, 127 { 128 .matches = { 129 DMI_EXACT_MATCH(DMI_SYS_VENDOR, "Microsoft Corporation"), 130 DMI_EXACT_MATCH(DMI_PRODUCT_NAME, "Surface Go 2"), 131 }, 132 .driver_data = (void *)&surface_go_tps68470_board_data, 133 }, 134 { 135 .matches = { 136 DMI_EXACT_MATCH(DMI_SYS_VENDOR, "Microsoft Corporation"), 137 DMI_EXACT_MATCH(DMI_PRODUCT_NAME, "Surface Go 3"), 138 }, 139 .driver_data = (void *)&surface_go3_tps68470_board_data, 140 }, 141 { } 142 }; 143 144 const struct int3472_tps68470_board_data *int3472_tps68470_get_board_data(const char *dev_name) 145 { 146 const struct int3472_tps68470_board_data *board_data; 147 const struct dmi_system_id *match; 148 149 for (match = dmi_first_match(int3472_tps68470_board_data_table); 150 match; 151 match = dmi_first_match(match + 1)) { 152 board_data = match->driver_data; 153 if (strcmp(board_data->dev_name, dev_name) == 0) 154 return board_data; 155 } 156 157 return NULL; 158 } 159