Linux Audio

Check our new training course

Loading...
v6.2
  1/* SPDX-License-Identifier: GPL-2.0 */
  2/* Author: Dan Scally <djrscally@gmail.com> */
  3
  4#ifndef _INTEL_SKL_INT3472_H
  5#define _INTEL_SKL_INT3472_H
  6
  7#include <linux/clk-provider.h>
  8#include <linux/gpio/machine.h>
 
  9#include <linux/regulator/driver.h>
 10#include <linux/regulator/machine.h>
 11#include <linux/types.h>
 12
 13/* FIXME drop this once the I2C_DEV_NAME_FORMAT macro has been added to include/linux/i2c.h */
 14#ifndef I2C_DEV_NAME_FORMAT
 15#define I2C_DEV_NAME_FORMAT					"i2c-%s"
 16#endif
 17
 18/* PMIC GPIO Types */
 19#define INT3472_GPIO_TYPE_RESET					0x00
 20#define INT3472_GPIO_TYPE_POWERDOWN				0x01
 21#define INT3472_GPIO_TYPE_POWER_ENABLE				0x0b
 22#define INT3472_GPIO_TYPE_CLK_ENABLE				0x0c
 23#define INT3472_GPIO_TYPE_PRIVACY_LED				0x0d
 24
 25#define INT3472_PDEV_MAX_NAME_LEN				23
 26#define INT3472_MAX_SENSOR_GPIOS				3
 27
 28#define GPIO_REGULATOR_NAME_LENGTH				21
 29#define GPIO_REGULATOR_SUPPLY_NAME_LENGTH			9
 
 
 
 30
 31#define CIO2_SENSOR_SSDB_MCLKSPEED_OFFSET			86
 32
 33#define INT3472_REGULATOR(_name, _supply, _ops)			\
 34	(const struct regulator_desc) {				\
 35		.name = _name,					\
 36		.supply_name = _supply,				\
 37		.type = REGULATOR_VOLTAGE,			\
 38		.ops = _ops,					\
 39		.owner = THIS_MODULE,				\
 40	}
 41
 42#define to_int3472_clk(hw)					\
 43	container_of(hw, struct int3472_gpio_clock, clk_hw)
 44
 45#define to_int3472_device(clk)					\
 46	container_of(clk, struct int3472_discrete_device, clock)
 47
 48struct acpi_device;
 49struct i2c_client;
 50struct platform_device;
 51
 52struct int3472_cldb {
 53	u8 version;
 54	/*
 55	 * control logic type
 56	 * 0: UNKNOWN
 57	 * 1: DISCRETE(CRD-D)
 58	 * 2: PMIC TPS68470
 59	 * 3: PMIC uP6641
 60	 */
 61	u8 control_logic_type;
 62	u8 control_logic_id;
 63	u8 sensor_card_sku;
 64	u8 reserved[28];
 65};
 66
 67struct int3472_gpio_function_remap {
 68	const char *documented;
 69	const char *actual;
 70};
 71
 72struct int3472_sensor_config {
 73	const char *sensor_module_name;
 74	struct regulator_consumer_supply supply_map;
 75	const struct int3472_gpio_function_remap *function_maps;
 76};
 77
 78struct int3472_discrete_device {
 79	struct acpi_device *adev;
 80	struct device *dev;
 81	struct acpi_device *sensor;
 82	const char *sensor_name;
 83
 84	const struct int3472_sensor_config *sensor_config;
 85
 86	struct int3472_gpio_regulator {
 
 
 87		char regulator_name[GPIO_REGULATOR_NAME_LENGTH];
 88		char supply_name[GPIO_REGULATOR_SUPPLY_NAME_LENGTH];
 89		struct gpio_desc *gpio;
 90		struct regulator_dev *rdev;
 91		struct regulator_desc rdesc;
 92	} regulator;
 93
 94	struct int3472_gpio_clock {
 95		struct clk *clk;
 96		struct clk_hw clk_hw;
 97		struct clk_lookup *cl;
 98		struct gpio_desc *ena_gpio;
 99		struct gpio_desc *led_gpio;
100		u32 frequency;
 
101	} clock;
102
 
 
 
 
 
 
 
103	unsigned int ngpios; /* how many GPIOs have we seen */
104	unsigned int n_sensor_gpios; /* how many have we mapped to sensor */
105	struct gpiod_lookup_table gpios;
106};
107
108union acpi_object *skl_int3472_get_acpi_buffer(struct acpi_device *adev,
109					       char *id);
110int skl_int3472_fill_cldb(struct acpi_device *adev, struct int3472_cldb *cldb);
111int skl_int3472_get_sensor_adev_and_name(struct device *dev,
112					 struct acpi_device **sensor_adev_ret,
113					 const char **name_ret);
114
115int skl_int3472_register_clock(struct int3472_discrete_device *int3472);
 
 
116void skl_int3472_unregister_clock(struct int3472_discrete_device *int3472);
117
118int skl_int3472_register_regulator(struct int3472_discrete_device *int3472,
119				   struct acpi_resource_gpio *agpio);
120void skl_int3472_unregister_regulator(struct int3472_discrete_device *int3472);
 
 
 
121
122#endif
v6.8
  1/* SPDX-License-Identifier: GPL-2.0 */
  2/* Author: Dan Scally <djrscally@gmail.com> */
  3
  4#ifndef _INTEL_SKL_INT3472_H
  5#define _INTEL_SKL_INT3472_H
  6
  7#include <linux/clk-provider.h>
  8#include <linux/gpio/machine.h>
  9#include <linux/leds.h>
 10#include <linux/regulator/driver.h>
 11#include <linux/regulator/machine.h>
 12#include <linux/types.h>
 13
 14/* FIXME drop this once the I2C_DEV_NAME_FORMAT macro has been added to include/linux/i2c.h */
 15#ifndef I2C_DEV_NAME_FORMAT
 16#define I2C_DEV_NAME_FORMAT					"i2c-%s"
 17#endif
 18
 19/* PMIC GPIO Types */
 20#define INT3472_GPIO_TYPE_RESET					0x00
 21#define INT3472_GPIO_TYPE_POWERDOWN				0x01
 22#define INT3472_GPIO_TYPE_POWER_ENABLE				0x0b
 23#define INT3472_GPIO_TYPE_CLK_ENABLE				0x0c
 24#define INT3472_GPIO_TYPE_PRIVACY_LED				0x0d
 25
 26#define INT3472_PDEV_MAX_NAME_LEN				23
 27#define INT3472_MAX_SENSOR_GPIOS				3
 28
 29#define GPIO_REGULATOR_NAME_LENGTH				21
 30#define GPIO_REGULATOR_SUPPLY_NAME_LENGTH			9
 31#define GPIO_REGULATOR_SUPPLY_MAP_COUNT				2
 32
 33#define INT3472_LED_MAX_NAME_LEN				32
 34
 35#define CIO2_SENSOR_SSDB_MCLKSPEED_OFFSET			86
 36
 37#define INT3472_REGULATOR(_name, _supply, _ops)			\
 38	(const struct regulator_desc) {				\
 39		.name = _name,					\
 40		.supply_name = _supply,				\
 41		.type = REGULATOR_VOLTAGE,			\
 42		.ops = _ops,					\
 43		.owner = THIS_MODULE,				\
 44	}
 45
 46#define to_int3472_clk(hw)					\
 47	container_of(hw, struct int3472_clock, clk_hw)
 48
 49#define to_int3472_device(clk)					\
 50	container_of(clk, struct int3472_discrete_device, clock)
 51
 52struct acpi_device;
 53struct i2c_client;
 54struct platform_device;
 55
 56struct int3472_cldb {
 57	u8 version;
 58	/*
 59	 * control logic type
 60	 * 0: UNKNOWN
 61	 * 1: DISCRETE(CRD-D)
 62	 * 2: PMIC TPS68470
 63	 * 3: PMIC uP6641
 64	 */
 65	u8 control_logic_type;
 66	u8 control_logic_id;
 67	u8 sensor_card_sku;
 68	u8 reserved[10];
 69	u8 clock_source;
 70	u8 reserved2[17];
 
 
 
 
 
 
 
 
 
 71};
 72
 73struct int3472_discrete_device {
 74	struct acpi_device *adev;
 75	struct device *dev;
 76	struct acpi_device *sensor;
 77	const char *sensor_name;
 78
 79	const struct int3472_sensor_config *sensor_config;
 80
 81	struct int3472_gpio_regulator {
 82		/* SUPPLY_MAP_COUNT * 2 to make room for second sensor mappings */
 83		struct regulator_consumer_supply supply_map[GPIO_REGULATOR_SUPPLY_MAP_COUNT * 2];
 84		char regulator_name[GPIO_REGULATOR_NAME_LENGTH];
 85		char supply_name[GPIO_REGULATOR_SUPPLY_NAME_LENGTH];
 86		struct gpio_desc *gpio;
 87		struct regulator_dev *rdev;
 88		struct regulator_desc rdesc;
 89	} regulator;
 90
 91	struct int3472_clock {
 92		struct clk *clk;
 93		struct clk_hw clk_hw;
 94		struct clk_lookup *cl;
 95		struct gpio_desc *ena_gpio;
 
 96		u32 frequency;
 97		u8 imgclk_index;
 98	} clock;
 99
100	struct int3472_pled {
101		struct led_classdev classdev;
102		struct led_lookup_data lookup;
103		char name[INT3472_LED_MAX_NAME_LEN];
104		struct gpio_desc *gpio;
105	} pled;
106
107	unsigned int ngpios; /* how many GPIOs have we seen */
108	unsigned int n_sensor_gpios; /* how many have we mapped to sensor */
109	struct gpiod_lookup_table gpios;
110};
111
112union acpi_object *skl_int3472_get_acpi_buffer(struct acpi_device *adev,
113					       char *id);
114int skl_int3472_fill_cldb(struct acpi_device *adev, struct int3472_cldb *cldb);
115int skl_int3472_get_sensor_adev_and_name(struct device *dev,
116					 struct acpi_device **sensor_adev_ret,
117					 const char **name_ret);
118
119int skl_int3472_register_gpio_clock(struct int3472_discrete_device *int3472,
120				    struct gpio_desc *gpio);
121int skl_int3472_register_dsm_clock(struct int3472_discrete_device *int3472);
122void skl_int3472_unregister_clock(struct int3472_discrete_device *int3472);
123
124int skl_int3472_register_regulator(struct int3472_discrete_device *int3472,
125				   struct gpio_desc *gpio);
126void skl_int3472_unregister_regulator(struct int3472_discrete_device *int3472);
127
128int skl_int3472_register_pled(struct int3472_discrete_device *int3472, struct gpio_desc *gpio);
129void skl_int3472_unregister_pled(struct int3472_discrete_device *int3472);
130
131#endif