cachepc-linux

Fork of AMDESE/linux with modifications for CachePC side-channel attack
git clone https://git.sinitax.com/sinitax/cachepc-linux
Log | Files | Refs | README | LICENSE | sfeed.txt

tps68470_board_data.c (4819B)


      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
     18static struct regulator_consumer_supply int347a_core_consumer_supplies[] = {
     19	REGULATOR_SUPPLY("dvdd", "i2c-INT347A:00"),
     20};
     21
     22static struct regulator_consumer_supply int347a_ana_consumer_supplies[] = {
     23	REGULATOR_SUPPLY("avdd", "i2c-INT347A:00"),
     24};
     25
     26static struct regulator_consumer_supply int347a_vcm_consumer_supplies[] = {
     27	REGULATOR_SUPPLY("vdd", "i2c-INT347A:00-VCM"),
     28};
     29
     30static 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
     35static 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
     46static 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
     57static 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 */
     69static 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
     78static 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
     89static 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
     99static 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
    108static const struct int3472_tps68470_board_data surface_go_tps68470_board_data = {
    109	.dev_name = "i2c-INT3472:05",
    110	.tps68470_gpio_lookup_table = &surface_go_tps68470_gpios,
    111	.tps68470_regulator_pdata = &surface_go_tps68470_pdata,
    112};
    113
    114static const struct int3472_tps68470_board_data surface_go3_tps68470_board_data = {
    115	.dev_name = "i2c-INT3472:01",
    116	.tps68470_gpio_lookup_table = &surface_go_tps68470_gpios,
    117	.tps68470_regulator_pdata = &surface_go_tps68470_pdata,
    118};
    119
    120static const struct dmi_system_id int3472_tps68470_board_data_table[] = {
    121	{
    122		.matches = {
    123			DMI_EXACT_MATCH(DMI_SYS_VENDOR, "Microsoft Corporation"),
    124			DMI_EXACT_MATCH(DMI_PRODUCT_NAME, "Surface Go"),
    125		},
    126		.driver_data = (void *)&surface_go_tps68470_board_data,
    127	},
    128	{
    129		.matches = {
    130			DMI_EXACT_MATCH(DMI_SYS_VENDOR, "Microsoft Corporation"),
    131			DMI_EXACT_MATCH(DMI_PRODUCT_NAME, "Surface Go 2"),
    132		},
    133		.driver_data = (void *)&surface_go_tps68470_board_data,
    134	},
    135	{
    136		.matches = {
    137			DMI_EXACT_MATCH(DMI_SYS_VENDOR, "Microsoft Corporation"),
    138			DMI_EXACT_MATCH(DMI_PRODUCT_NAME, "Surface Go 3"),
    139		},
    140		.driver_data = (void *)&surface_go3_tps68470_board_data,
    141	},
    142	{ }
    143};
    144
    145const struct int3472_tps68470_board_data *int3472_tps68470_get_board_data(const char *dev_name)
    146{
    147	const struct int3472_tps68470_board_data *board_data;
    148	const struct dmi_system_id *match;
    149
    150	for (match = dmi_first_match(int3472_tps68470_board_data_table);
    151	     match;
    152	     match = dmi_first_match(match + 1)) {
    153		board_data = match->driver_data;
    154		if (strcmp(board_data->dev_name, dev_name) == 0)
    155			return board_data;
    156	}
    157
    158	return NULL;
    159}