Linux kernel mirror (for testing)
git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel
os
linux
1/* SPDX-License-Identifier: GPL-2.0 */
2/*
3 * Intel INT3472 ACPI camera sensor power-management support
4 *
5 * Author: Dan Scally <djrscally@gmail.com>
6 */
7
8#ifndef __PLATFORM_DATA_X86_INT3472_H
9#define __PLATFORM_DATA_X86_INT3472_H
10
11#include <linux/clk-provider.h>
12#include <linux/gpio/machine.h>
13#include <linux/leds.h>
14#include <linux/regulator/driver.h>
15#include <linux/regulator/machine.h>
16#include <linux/types.h>
17
18/* FIXME drop this once the I2C_DEV_NAME_FORMAT macro has been added to include/linux/i2c.h */
19#ifndef I2C_DEV_NAME_FORMAT
20#define I2C_DEV_NAME_FORMAT "i2c-%s"
21#endif
22
23/* PMIC GPIO Types */
24#define INT3472_GPIO_TYPE_RESET 0x00
25#define INT3472_GPIO_TYPE_POWERDOWN 0x01
26#define INT3472_GPIO_TYPE_POWER_ENABLE 0x0b
27#define INT3472_GPIO_TYPE_CLK_ENABLE 0x0c
28#define INT3472_GPIO_TYPE_PRIVACY_LED 0x0d
29#define INT3472_GPIO_TYPE_HANDSHAKE 0x12
30#define INT3472_GPIO_TYPE_HOTPLUG_DETECT 0x13
31
32#define INT3472_PDEV_MAX_NAME_LEN 23
33#define INT3472_MAX_SENSOR_GPIOS 3
34#define INT3472_MAX_REGULATORS 3
35
36/* E.g. "avdd\0" */
37#define GPIO_SUPPLY_NAME_LENGTH 5
38/* 12 chars for acpi_dev_name() + "-", e.g. "ABCD1234:00-" */
39#define GPIO_REGULATOR_NAME_LENGTH (12 + GPIO_SUPPLY_NAME_LENGTH)
40/* lower- and upper-case mapping */
41#define GPIO_REGULATOR_SUPPLY_MAP_COUNT 2
42/*
43 * Ensure the GPIO is driven low/high for at least 2 ms before changing.
44 *
45 * 2 ms has been chosen because it is the minimum time ovXXXX sensors need to
46 * have their reset line driven logical high to properly register a reset.
47 */
48#define GPIO_REGULATOR_ENABLE_TIME (2 * USEC_PER_MSEC)
49#define GPIO_REGULATOR_OFF_ON_DELAY (2 * USEC_PER_MSEC)
50
51#define INT3472_LED_MAX_NAME_LEN 32
52
53#define CIO2_SENSOR_SSDB_MCLKSPEED_OFFSET 86
54
55#define INT3472_REGULATOR(_name, _ops, _enable_time, _off_on_delay) \
56 (const struct regulator_desc) { \
57 .name = _name, \
58 .type = REGULATOR_VOLTAGE, \
59 .ops = _ops, \
60 .owner = THIS_MODULE, \
61 .enable_time = _enable_time, \
62 .off_on_delay = _off_on_delay, \
63 }
64
65#define to_int3472_clk(hw) \
66 container_of(hw, struct int3472_clock, clk_hw)
67
68#define to_int3472_device(clk) \
69 container_of(clk, struct int3472_discrete_device, clock)
70
71struct acpi_device;
72struct dmi_system_id;
73struct i2c_client;
74struct platform_device;
75
76struct int3472_cldb {
77 u8 version;
78 /*
79 * control logic type
80 * 0: UNKNOWN
81 * 1: DISCRETE(CRD-D)
82 * 2: PMIC TPS68470
83 * 3: PMIC uP6641
84 */
85 u8 control_logic_type;
86 u8 control_logic_id;
87 u8 sensor_card_sku;
88 u8 reserved[10];
89 u8 clock_source;
90 u8 reserved2[17];
91};
92
93struct int3472_discrete_quirks {
94 /* For models where AVDD GPIO is shared between sensors */
95 const char *avdd_second_sensor;
96};
97
98struct int3472_gpio_regulator {
99 /* SUPPLY_MAP_COUNT * 2 to make room for second sensor mappings */
100 struct regulator_consumer_supply supply_map[GPIO_REGULATOR_SUPPLY_MAP_COUNT * 2];
101 char supply_name_upper[GPIO_SUPPLY_NAME_LENGTH];
102 char regulator_name[GPIO_REGULATOR_NAME_LENGTH];
103 struct regulator_dev *rdev;
104 struct regulator_desc rdesc;
105};
106
107struct int3472_discrete_device {
108 struct acpi_device *adev;
109 struct device *dev;
110 struct acpi_device *sensor;
111 const char *sensor_name;
112
113 struct int3472_gpio_regulator regulators[INT3472_MAX_REGULATORS];
114
115 struct int3472_clock {
116 struct clk *clk;
117 struct clk_hw clk_hw;
118 struct clk_lookup *cl;
119 struct gpio_desc *ena_gpio;
120 u32 frequency;
121 u8 imgclk_index;
122 } clock;
123
124 struct int3472_pled {
125 struct led_classdev classdev;
126 struct led_lookup_data lookup;
127 char name[INT3472_LED_MAX_NAME_LEN];
128 struct gpio_desc *gpio;
129 } pled;
130
131 struct int3472_discrete_quirks quirks;
132
133 unsigned int ngpios; /* how many GPIOs have we seen */
134 unsigned int n_sensor_gpios; /* how many have we mapped to sensor */
135 unsigned int n_regulator_gpios; /* how many have we mapped to a regulator */
136 struct gpiod_lookup_table gpios;
137};
138
139extern const struct dmi_system_id skl_int3472_discrete_quirks[];
140
141union acpi_object *skl_int3472_get_acpi_buffer(struct acpi_device *adev,
142 char *id);
143int skl_int3472_fill_cldb(struct acpi_device *adev, struct int3472_cldb *cldb);
144int skl_int3472_get_sensor_adev_and_name(struct device *dev,
145 struct acpi_device **sensor_adev_ret,
146 const char **name_ret);
147
148int int3472_discrete_parse_crs(struct int3472_discrete_device *int3472);
149void int3472_discrete_cleanup(struct int3472_discrete_device *int3472);
150
151int skl_int3472_register_gpio_clock(struct int3472_discrete_device *int3472,
152 struct gpio_desc *gpio);
153int skl_int3472_register_dsm_clock(struct int3472_discrete_device *int3472);
154void skl_int3472_unregister_clock(struct int3472_discrete_device *int3472);
155
156int skl_int3472_register_regulator(struct int3472_discrete_device *int3472,
157 struct gpio_desc *gpio,
158 unsigned int enable_time,
159 const char *supply_name,
160 const char *second_sensor);
161void skl_int3472_unregister_regulator(struct int3472_discrete_device *int3472);
162
163int skl_int3472_register_pled(struct int3472_discrete_device *int3472, struct gpio_desc *gpio);
164void skl_int3472_unregister_pled(struct int3472_discrete_device *int3472);
165
166#endif