platform/x86: int3472: Move common.h to public includes, symbols to INTEL_INT3472
authorHans de Goede <hdegoede@redhat.com>
Wed, 7 May 2025 18:47:32 +0000 (20:47 +0200)
committerIlpo Järvinen <ilpo.jarvinen@linux.intel.com>
Thu, 8 May 2025 14:35:28 +0000 (17:35 +0300)
Move the common.h header file to include/linux/platform_data/x86/int3472.h
and add a "INTEL_INT3472" kernel-symbol-namespace to the exported symbols.

This is a preparation patch for exporting some more symbols for re-use in
the atomisp driver.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Reviewed-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Reviewed-by: Andy Shevchenko <andy@kernel.org>
Link: https://lore.kernel.org/r/20250507184737.154747-2-hdegoede@redhat.com
Reviewed-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
Signed-off-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
MAINTAINERS
drivers/platform/x86/intel/int3472/clk_and_regulator.c
drivers/platform/x86/intel/int3472/common.c
drivers/platform/x86/intel/int3472/common.h [deleted file]
drivers/platform/x86/intel/int3472/discrete.c
drivers/platform/x86/intel/int3472/discrete_quirks.c
drivers/platform/x86/intel/int3472/led.c
drivers/platform/x86/intel/int3472/tps68470.c
include/linux/platform_data/x86/int3472.h [new file with mode: 0644]

index f9417b4..08a99fe 100644 (file)
@@ -12241,6 +12241,7 @@ INTEL SKYLAKE INT3472 ACPI DEVICE DRIVER
 M:     Daniel Scally <djrscally@gmail.com>
 S:     Maintained
 F:     drivers/platform/x86/intel/int3472/
+F:     include/linux/platform_data/x86/int3472.h
 
 INTEL SPEED SELECT TECHNOLOGY
 M:     Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
index c85cbfb..4d00494 100644 (file)
@@ -6,11 +6,10 @@
 #include <linux/clk-provider.h>
 #include <linux/device.h>
 #include <linux/gpio/consumer.h>
+#include <linux/platform_data/x86/int3472.h>
 #include <linux/regulator/driver.h>
 #include <linux/slab.h>
 
-#include "common.h"
-
 /*
  * 82c0d13a-78c5-4244-9bb1-eb8b539a8d11
  * This _DSM GUID allows controlling the sensor clk when it is not controlled
index 1638be8..6dc38d5 100644 (file)
@@ -2,10 +2,9 @@
 /* Author: Dan Scally <djrscally@gmail.com> */
 
 #include <linux/acpi.h>
+#include <linux/platform_data/x86/int3472.h>
 #include <linux/slab.h>
 
-#include "common.h"
-
 union acpi_object *skl_int3472_get_acpi_buffer(struct acpi_device *adev, char *id)
 {
        struct acpi_buffer buffer = { ACPI_ALLOCATE_BUFFER, NULL };
@@ -29,7 +28,7 @@ union acpi_object *skl_int3472_get_acpi_buffer(struct acpi_device *adev, char *i
 
        return obj;
 }
-EXPORT_SYMBOL_GPL(skl_int3472_get_acpi_buffer);
+EXPORT_SYMBOL_NS_GPL(skl_int3472_get_acpi_buffer, "INTEL_INT3472");
 
 int skl_int3472_fill_cldb(struct acpi_device *adev, struct int3472_cldb *cldb)
 {
@@ -53,7 +52,7 @@ out_free_obj:
        kfree(obj);
        return ret;
 }
-EXPORT_SYMBOL_GPL(skl_int3472_fill_cldb);
+EXPORT_SYMBOL_NS_GPL(skl_int3472_fill_cldb, "INTEL_INT3472");
 
 /* sensor_adev_ret may be NULL, name_ret must not be NULL */
 int skl_int3472_get_sensor_adev_and_name(struct device *dev,
@@ -84,7 +83,7 @@ int skl_int3472_get_sensor_adev_and_name(struct device *dev,
 
        return ret;
 }
-EXPORT_SYMBOL_GPL(skl_int3472_get_sensor_adev_and_name);
+EXPORT_SYMBOL_NS_GPL(skl_int3472_get_sensor_adev_and_name, "INTEL_INT3472");
 
 MODULE_DESCRIPTION("Intel SkyLake INT3472 ACPI Device Driver library");
 MODULE_AUTHOR("Daniel Scally <djrscally@gmail.com>");
diff --git a/drivers/platform/x86/intel/int3472/common.h b/drivers/platform/x86/intel/int3472/common.h
deleted file mode 100644 (file)
index 51b818e..0000000
+++ /dev/null
@@ -1,160 +0,0 @@
-/* SPDX-License-Identifier: GPL-2.0 */
-/* Author: Dan Scally <djrscally@gmail.com> */
-
-#ifndef _INTEL_SKL_INT3472_H
-#define _INTEL_SKL_INT3472_H
-
-#include <linux/clk-provider.h>
-#include <linux/gpio/machine.h>
-#include <linux/leds.h>
-#include <linux/regulator/driver.h>
-#include <linux/regulator/machine.h>
-#include <linux/types.h>
-
-/* FIXME drop this once the I2C_DEV_NAME_FORMAT macro has been added to include/linux/i2c.h */
-#ifndef I2C_DEV_NAME_FORMAT
-#define I2C_DEV_NAME_FORMAT                                    "i2c-%s"
-#endif
-
-/* PMIC GPIO Types */
-#define INT3472_GPIO_TYPE_RESET                                        0x00
-#define INT3472_GPIO_TYPE_POWERDOWN                            0x01
-#define INT3472_GPIO_TYPE_POWER_ENABLE                         0x0b
-#define INT3472_GPIO_TYPE_CLK_ENABLE                           0x0c
-#define INT3472_GPIO_TYPE_PRIVACY_LED                          0x0d
-#define INT3472_GPIO_TYPE_HANDSHAKE                            0x12
-
-#define INT3472_PDEV_MAX_NAME_LEN                              23
-#define INT3472_MAX_SENSOR_GPIOS                               3
-#define INT3472_MAX_REGULATORS                                 3
-
-/* E.g. "avdd\0" */
-#define GPIO_SUPPLY_NAME_LENGTH                                5
-/* 12 chars for acpi_dev_name() + "-", e.g. "ABCD1234:00-" */
-#define GPIO_REGULATOR_NAME_LENGTH                             (12 + GPIO_SUPPLY_NAME_LENGTH)
-/* lower- and upper-case mapping */
-#define GPIO_REGULATOR_SUPPLY_MAP_COUNT                                2
-/*
- * Ensure the GPIO is driven low/high for at least 2 ms before changing.
- *
- * 2 ms has been chosen because it is the minimum time ovXXXX sensors need to
- * have their reset line driven logical high to properly register a reset.
- */
-#define GPIO_REGULATOR_ENABLE_TIME                             (2 * USEC_PER_MSEC)
-#define GPIO_REGULATOR_OFF_ON_DELAY                            (2 * USEC_PER_MSEC)
-
-#define INT3472_LED_MAX_NAME_LEN                               32
-
-#define CIO2_SENSOR_SSDB_MCLKSPEED_OFFSET                      86
-
-#define INT3472_REGULATOR(_name, _ops, _enable_time, _off_on_delay) \
-       (const struct regulator_desc) {                         \
-               .name = _name,                                  \
-               .type = REGULATOR_VOLTAGE,                      \
-               .ops = _ops,                                    \
-               .owner = THIS_MODULE,                           \
-               .enable_time = _enable_time,                    \
-               .off_on_delay = _off_on_delay,                  \
-       }
-
-#define to_int3472_clk(hw)                                     \
-       container_of(hw, struct int3472_clock, clk_hw)
-
-#define to_int3472_device(clk)                                 \
-       container_of(clk, struct int3472_discrete_device, clock)
-
-struct acpi_device;
-struct dmi_system_id;
-struct i2c_client;
-struct platform_device;
-
-struct int3472_cldb {
-       u8 version;
-       /*
-        * control logic type
-        * 0: UNKNOWN
-        * 1: DISCRETE(CRD-D)
-        * 2: PMIC TPS68470
-        * 3: PMIC uP6641
-        */
-       u8 control_logic_type;
-       u8 control_logic_id;
-       u8 sensor_card_sku;
-       u8 reserved[10];
-       u8 clock_source;
-       u8 reserved2[17];
-};
-
-struct int3472_discrete_quirks {
-       /* For models where AVDD GPIO is shared between sensors */
-       const char *avdd_second_sensor;
-};
-
-struct int3472_gpio_regulator {
-       /* SUPPLY_MAP_COUNT * 2 to make room for second sensor mappings */
-       struct regulator_consumer_supply supply_map[GPIO_REGULATOR_SUPPLY_MAP_COUNT * 2];
-       char supply_name_upper[GPIO_SUPPLY_NAME_LENGTH];
-       char regulator_name[GPIO_REGULATOR_NAME_LENGTH];
-       struct regulator_dev *rdev;
-       struct regulator_desc rdesc;
-};
-
-struct int3472_discrete_device {
-       struct acpi_device *adev;
-       struct device *dev;
-       struct acpi_device *sensor;
-       const char *sensor_name;
-
-       const struct int3472_sensor_config *sensor_config;
-
-       struct int3472_gpio_regulator regulators[INT3472_MAX_REGULATORS];
-
-       struct int3472_clock {
-               struct clk *clk;
-               struct clk_hw clk_hw;
-               struct clk_lookup *cl;
-               struct gpio_desc *ena_gpio;
-               u32 frequency;
-               u8 imgclk_index;
-       } clock;
-
-       struct int3472_pled {
-               struct led_classdev classdev;
-               struct led_lookup_data lookup;
-               char name[INT3472_LED_MAX_NAME_LEN];
-               struct gpio_desc *gpio;
-       } pled;
-
-       struct int3472_discrete_quirks quirks;
-
-       unsigned int ngpios; /* how many GPIOs have we seen */
-       unsigned int n_sensor_gpios; /* how many have we mapped to sensor */
-       unsigned int n_regulator_gpios; /* how many have we mapped to a regulator */
-       struct gpiod_lookup_table gpios;
-};
-
-extern const struct dmi_system_id skl_int3472_discrete_quirks[];
-
-union acpi_object *skl_int3472_get_acpi_buffer(struct acpi_device *adev,
-                                              char *id);
-int skl_int3472_fill_cldb(struct acpi_device *adev, struct int3472_cldb *cldb);
-int skl_int3472_get_sensor_adev_and_name(struct device *dev,
-                                        struct acpi_device **sensor_adev_ret,
-                                        const char **name_ret);
-
-int skl_int3472_register_gpio_clock(struct int3472_discrete_device *int3472,
-                                   struct gpio_desc *gpio);
-int skl_int3472_register_dsm_clock(struct int3472_discrete_device *int3472);
-void skl_int3472_unregister_clock(struct int3472_discrete_device *int3472);
-
-int skl_int3472_register_regulator(struct int3472_discrete_device *int3472,
-                                  struct gpio_desc *gpio,
-                                  unsigned int enable_time,
-                                  const char *supply_name,
-                                  const char *second_sensor);
-void skl_int3472_unregister_regulator(struct int3472_discrete_device *int3472);
-
-int skl_int3472_register_pled(struct int3472_discrete_device *int3472, struct gpio_desc *gpio);
-void skl_int3472_unregister_pled(struct int3472_discrete_device *int3472);
-
-#endif
index 394975f..d0938da 100644 (file)
 #include <linux/kernel.h>
 #include <linux/module.h>
 #include <linux/overflow.h>
+#include <linux/platform_data/x86/int3472.h>
 #include <linux/platform_device.h>
 #include <linux/string_choices.h>
 #include <linux/uuid.h>
 
-#include "common.h"
-
 /*
  * 79234640-9e10-4fea-a5c1-b5aa8b19756f
  * This _DSM GUID returns information about the GPIO lines mapped to a
@@ -479,3 +478,4 @@ module_platform_driver(int3472_discrete);
 MODULE_DESCRIPTION("Intel SkyLake INT3472 ACPI Discrete Device Driver");
 MODULE_AUTHOR("Daniel Scally <djrscally@gmail.com>");
 MODULE_LICENSE("GPL v2");
+MODULE_IMPORT_NS("INTEL_INT3472");
index bf88863..552869e 100644 (file)
@@ -2,8 +2,7 @@
 /* Author: Hans de Goede <hansg@kernel.org> */
 
 #include <linux/dmi.h>
-
-#include "common.h"
+#include <linux/platform_data/x86/int3472.h>
 
 static const struct int3472_discrete_quirks lenovo_miix_510_quirks = {
        .avdd_second_sensor = "i2c-OVTI2680:00",
index 9cbed69..c5588e1 100644 (file)
@@ -4,7 +4,7 @@
 #include <linux/acpi.h>
 #include <linux/gpio/consumer.h>
 #include <linux/leds.h>
-#include "common.h"
+#include <linux/platform_data/x86/int3472.h>
 
 static int int3472_pled_set(struct led_classdev *led_cdev,
                                     enum led_brightness brightness)
index 81ac4c6..0133405 100644 (file)
@@ -8,10 +8,10 @@
 #include <linux/mfd/tps68470.h>
 #include <linux/platform_device.h>
 #include <linux/platform_data/tps68470.h>
+#include <linux/platform_data/x86/int3472.h>
 #include <linux/regmap.h>
 #include <linux/string.h>
 
-#include "common.h"
 #include "tps68470.h"
 
 #define DESIGNED_FOR_CHROMEOS          1
@@ -261,4 +261,5 @@ module_i2c_driver(int3472_tps68470);
 MODULE_DESCRIPTION("Intel SkyLake INT3472 ACPI TPS68470 Device Driver");
 MODULE_AUTHOR("Daniel Scally <djrscally@gmail.com>");
 MODULE_LICENSE("GPL v2");
+MODULE_IMPORT_NS("INTEL_INT3472");
 MODULE_SOFTDEP("pre: clk-tps68470 tps68470-regulator");
diff --git a/include/linux/platform_data/x86/int3472.h b/include/linux/platform_data/x86/int3472.h
new file mode 100644 (file)
index 0000000..4cf02df
--- /dev/null
@@ -0,0 +1,164 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+/*
+ * Intel INT3472 ACPI camera sensor power-management support
+ *
+ * Author: Dan Scally <djrscally@gmail.com>
+ */
+
+#ifndef __PLATFORM_DATA_X86_INT3472_H
+#define __PLATFORM_DATA_X86_INT3472_H
+
+#include <linux/clk-provider.h>
+#include <linux/gpio/machine.h>
+#include <linux/leds.h>
+#include <linux/regulator/driver.h>
+#include <linux/regulator/machine.h>
+#include <linux/types.h>
+
+/* FIXME drop this once the I2C_DEV_NAME_FORMAT macro has been added to include/linux/i2c.h */
+#ifndef I2C_DEV_NAME_FORMAT
+#define I2C_DEV_NAME_FORMAT                                    "i2c-%s"
+#endif
+
+/* PMIC GPIO Types */
+#define INT3472_GPIO_TYPE_RESET                                        0x00
+#define INT3472_GPIO_TYPE_POWERDOWN                            0x01
+#define INT3472_GPIO_TYPE_POWER_ENABLE                         0x0b
+#define INT3472_GPIO_TYPE_CLK_ENABLE                           0x0c
+#define INT3472_GPIO_TYPE_PRIVACY_LED                          0x0d
+#define INT3472_GPIO_TYPE_HANDSHAKE                            0x12
+
+#define INT3472_PDEV_MAX_NAME_LEN                              23
+#define INT3472_MAX_SENSOR_GPIOS                               3
+#define INT3472_MAX_REGULATORS                                 3
+
+/* E.g. "avdd\0" */
+#define GPIO_SUPPLY_NAME_LENGTH                                5
+/* 12 chars for acpi_dev_name() + "-", e.g. "ABCD1234:00-" */
+#define GPIO_REGULATOR_NAME_LENGTH                             (12 + GPIO_SUPPLY_NAME_LENGTH)
+/* lower- and upper-case mapping */
+#define GPIO_REGULATOR_SUPPLY_MAP_COUNT                                2
+/*
+ * Ensure the GPIO is driven low/high for at least 2 ms before changing.
+ *
+ * 2 ms has been chosen because it is the minimum time ovXXXX sensors need to
+ * have their reset line driven logical high to properly register a reset.
+ */
+#define GPIO_REGULATOR_ENABLE_TIME                             (2 * USEC_PER_MSEC)
+#define GPIO_REGULATOR_OFF_ON_DELAY                            (2 * USEC_PER_MSEC)
+
+#define INT3472_LED_MAX_NAME_LEN                               32
+
+#define CIO2_SENSOR_SSDB_MCLKSPEED_OFFSET                      86
+
+#define INT3472_REGULATOR(_name, _ops, _enable_time, _off_on_delay) \
+       (const struct regulator_desc) {                         \
+               .name = _name,                                  \
+               .type = REGULATOR_VOLTAGE,                      \
+               .ops = _ops,                                    \
+               .owner = THIS_MODULE,                           \
+               .enable_time = _enable_time,                    \
+               .off_on_delay = _off_on_delay,                  \
+       }
+
+#define to_int3472_clk(hw)                                     \
+       container_of(hw, struct int3472_clock, clk_hw)
+
+#define to_int3472_device(clk)                                 \
+       container_of(clk, struct int3472_discrete_device, clock)
+
+struct acpi_device;
+struct dmi_system_id;
+struct i2c_client;
+struct platform_device;
+
+struct int3472_cldb {
+       u8 version;
+       /*
+        * control logic type
+        * 0: UNKNOWN
+        * 1: DISCRETE(CRD-D)
+        * 2: PMIC TPS68470
+        * 3: PMIC uP6641
+        */
+       u8 control_logic_type;
+       u8 control_logic_id;
+       u8 sensor_card_sku;
+       u8 reserved[10];
+       u8 clock_source;
+       u8 reserved2[17];
+};
+
+struct int3472_discrete_quirks {
+       /* For models where AVDD GPIO is shared between sensors */
+       const char *avdd_second_sensor;
+};
+
+struct int3472_gpio_regulator {
+       /* SUPPLY_MAP_COUNT * 2 to make room for second sensor mappings */
+       struct regulator_consumer_supply supply_map[GPIO_REGULATOR_SUPPLY_MAP_COUNT * 2];
+       char supply_name_upper[GPIO_SUPPLY_NAME_LENGTH];
+       char regulator_name[GPIO_REGULATOR_NAME_LENGTH];
+       struct regulator_dev *rdev;
+       struct regulator_desc rdesc;
+};
+
+struct int3472_discrete_device {
+       struct acpi_device *adev;
+       struct device *dev;
+       struct acpi_device *sensor;
+       const char *sensor_name;
+
+       const struct int3472_sensor_config *sensor_config;
+
+       struct int3472_gpio_regulator regulators[INT3472_MAX_REGULATORS];
+
+       struct int3472_clock {
+               struct clk *clk;
+               struct clk_hw clk_hw;
+               struct clk_lookup *cl;
+               struct gpio_desc *ena_gpio;
+               u32 frequency;
+               u8 imgclk_index;
+       } clock;
+
+       struct int3472_pled {
+               struct led_classdev classdev;
+               struct led_lookup_data lookup;
+               char name[INT3472_LED_MAX_NAME_LEN];
+               struct gpio_desc *gpio;
+       } pled;
+
+       struct int3472_discrete_quirks quirks;
+
+       unsigned int ngpios; /* how many GPIOs have we seen */
+       unsigned int n_sensor_gpios; /* how many have we mapped to sensor */
+       unsigned int n_regulator_gpios; /* how many have we mapped to a regulator */
+       struct gpiod_lookup_table gpios;
+};
+
+extern const struct dmi_system_id skl_int3472_discrete_quirks[];
+
+union acpi_object *skl_int3472_get_acpi_buffer(struct acpi_device *adev,
+                                              char *id);
+int skl_int3472_fill_cldb(struct acpi_device *adev, struct int3472_cldb *cldb);
+int skl_int3472_get_sensor_adev_and_name(struct device *dev,
+                                        struct acpi_device **sensor_adev_ret,
+                                        const char **name_ret);
+
+int skl_int3472_register_gpio_clock(struct int3472_discrete_device *int3472,
+                                   struct gpio_desc *gpio);
+int skl_int3472_register_dsm_clock(struct int3472_discrete_device *int3472);
+void skl_int3472_unregister_clock(struct int3472_discrete_device *int3472);
+
+int skl_int3472_register_regulator(struct int3472_discrete_device *int3472,
+                                  struct gpio_desc *gpio,
+                                  unsigned int enable_time,
+                                  const char *supply_name,
+                                  const char *second_sensor);
+void skl_int3472_unregister_regulator(struct int3472_discrete_device *int3472);
+
+int skl_int3472_register_pled(struct int3472_discrete_device *int3472, struct gpio_desc *gpio);
+void skl_int3472_unregister_pled(struct int3472_discrete_device *int3472);
+
+#endif