Back to home page

OSCL-LXR

 
 

    


0001 /* SPDX-License-Identifier: GPL-2.0 */
0002 /* Author: Dan Scally <djrscally@gmail.com> */
0003 
0004 #ifndef _INTEL_SKL_INT3472_H
0005 #define _INTEL_SKL_INT3472_H
0006 
0007 #include <linux/clk-provider.h>
0008 #include <linux/gpio/machine.h>
0009 #include <linux/regulator/driver.h>
0010 #include <linux/regulator/machine.h>
0011 #include <linux/types.h>
0012 
0013 /* FIXME drop this once the I2C_DEV_NAME_FORMAT macro has been added to include/linux/i2c.h */
0014 #ifndef I2C_DEV_NAME_FORMAT
0015 #define I2C_DEV_NAME_FORMAT                 "i2c-%s"
0016 #endif
0017 
0018 /* PMIC GPIO Types */
0019 #define INT3472_GPIO_TYPE_RESET                 0x00
0020 #define INT3472_GPIO_TYPE_POWERDOWN             0x01
0021 #define INT3472_GPIO_TYPE_POWER_ENABLE              0x0b
0022 #define INT3472_GPIO_TYPE_CLK_ENABLE                0x0c
0023 #define INT3472_GPIO_TYPE_PRIVACY_LED               0x0d
0024 
0025 #define INT3472_PDEV_MAX_NAME_LEN               23
0026 #define INT3472_MAX_SENSOR_GPIOS                3
0027 
0028 #define GPIO_REGULATOR_NAME_LENGTH              21
0029 #define GPIO_REGULATOR_SUPPLY_NAME_LENGTH           9
0030 
0031 #define CIO2_SENSOR_SSDB_MCLKSPEED_OFFSET           86
0032 
0033 #define INT3472_REGULATOR(_name, _supply, _ops)         \
0034     (const struct regulator_desc) {             \
0035         .name = _name,                  \
0036         .supply_name = _supply,             \
0037         .type = REGULATOR_VOLTAGE,          \
0038         .ops = _ops,                    \
0039         .owner = THIS_MODULE,               \
0040     }
0041 
0042 #define to_int3472_clk(hw)                  \
0043     container_of(hw, struct int3472_gpio_clock, clk_hw)
0044 
0045 #define to_int3472_device(clk)                  \
0046     container_of(clk, struct int3472_discrete_device, clock)
0047 
0048 struct acpi_device;
0049 struct i2c_client;
0050 struct platform_device;
0051 
0052 struct int3472_cldb {
0053     u8 version;
0054     /*
0055      * control logic type
0056      * 0: UNKNOWN
0057      * 1: DISCRETE(CRD-D)
0058      * 2: PMIC TPS68470
0059      * 3: PMIC uP6641
0060      */
0061     u8 control_logic_type;
0062     u8 control_logic_id;
0063     u8 sensor_card_sku;
0064     u8 reserved[28];
0065 };
0066 
0067 struct int3472_gpio_function_remap {
0068     const char *documented;
0069     const char *actual;
0070 };
0071 
0072 struct int3472_sensor_config {
0073     const char *sensor_module_name;
0074     struct regulator_consumer_supply supply_map;
0075     const struct int3472_gpio_function_remap *function_maps;
0076 };
0077 
0078 struct int3472_discrete_device {
0079     struct acpi_device *adev;
0080     struct device *dev;
0081     struct acpi_device *sensor;
0082     const char *sensor_name;
0083 
0084     const struct int3472_sensor_config *sensor_config;
0085 
0086     struct int3472_gpio_regulator {
0087         char regulator_name[GPIO_REGULATOR_NAME_LENGTH];
0088         char supply_name[GPIO_REGULATOR_SUPPLY_NAME_LENGTH];
0089         struct gpio_desc *gpio;
0090         struct regulator_dev *rdev;
0091         struct regulator_desc rdesc;
0092     } regulator;
0093 
0094     struct int3472_gpio_clock {
0095         struct clk *clk;
0096         struct clk_hw clk_hw;
0097         struct clk_lookup *cl;
0098         struct gpio_desc *ena_gpio;
0099         struct gpio_desc *led_gpio;
0100         u32 frequency;
0101     } clock;
0102 
0103     unsigned int ngpios; /* how many GPIOs have we seen */
0104     unsigned int n_sensor_gpios; /* how many have we mapped to sensor */
0105     struct gpiod_lookup_table gpios;
0106 };
0107 
0108 union acpi_object *skl_int3472_get_acpi_buffer(struct acpi_device *adev,
0109                            char *id);
0110 int skl_int3472_fill_cldb(struct acpi_device *adev, struct int3472_cldb *cldb);
0111 int skl_int3472_get_sensor_adev_and_name(struct device *dev,
0112                      struct acpi_device **sensor_adev_ret,
0113                      const char **name_ret);
0114 
0115 int skl_int3472_register_clock(struct int3472_discrete_device *int3472);
0116 void skl_int3472_unregister_clock(struct int3472_discrete_device *int3472);
0117 
0118 int skl_int3472_register_regulator(struct int3472_discrete_device *int3472,
0119                    struct acpi_resource_gpio *agpio);
0120 void skl_int3472_unregister_regulator(struct int3472_discrete_device *int3472);
0121 
0122 #endif