summaryrefslogtreecommitdiff
path: root/drivers/platform/x86/siemens/simatic-ipc-batt-f7188x.c
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2023-09-01 09:16:47 -0700
committerLinus Torvalds <torvalds@linux-foundation.org>2023-09-01 09:16:47 -0700
commite2c874f999f079e3ec9b8071e92c87d57aded3b6 (patch)
tree1b43236aa03d465095117be5e95167c86b9c4ca3 /drivers/platform/x86/siemens/simatic-ipc-batt-f7188x.c
parente0152e7481c6c63764d6ea8ee41af5cf9dfac5e9 (diff)
parentacce85a7dd28eac3858d44230f4c65985d0f271c (diff)
Merge tag 'platform-drivers-x86-v6.6-1' of git://git.kernel.org/pub/scm/linux/kernel/git/pdx86/platform-drivers-x86
Pull x86 platform driver updates from Hans de Goede: - hp-bioscfg: New firmware-attributes driver for changing BIOS settings from within Linux - asus-wmi: Add charger mode, middle fan and eGPU settings support - ideapad: Support keyboard backlight control on more models - mellanox: Support for new models - sel-3350: New LED and power-supply driver for this industrial mainboard - simatic-ipc: Add RTC battery monitor and various new models support - miscellaneous other cleanups / fixes * tag 'platform-drivers-x86-v6.6-1' of git://git.kernel.org/pub/scm/linux/kernel/git/pdx86/platform-drivers-x86: (101 commits) platform/x86: asus-wmi: corrections to egpu safety check platform/x86: mlx-platform: Add dependency on PCI to Kconfig platform/x86: ideapad-laptop: Add support for keyboard backlights using KBLC ACPI symbol platform/x86/amd/pmc: Fix build error with randconfig platform/x86/amd/pmf: Fix a missing cleanup path watchdog: simatic: Use idiomatic selection of P2SB platform/x86: p2sb: Make the Kconfig symbol hidden Documentation/ABI: Add new attribute for mlxreg-io sysfs interfaces platform: mellanox: nvsw-sn2201: change fans i2c busses. platform: mellanox: mlxreg-hotplug: Extend condition for notification callback processing platform: mellanox: Add initial support for PCIe based programming logic device platform: mellanox: mlx-platform: Get interrupt line through ACPI platform: mellanox: mlx-platform: Introduce ACPI init flow platform: mellanox: mlx-platform: Prepare driver to allow probing through ACPI infrastructure platform: mellanox: mlx-platform: Add reset callback platform: mellanox: Cosmetic changes platform: mellanox: mlx-platform: Modify power off callback platform: mellanox: mlx-platform: add support for additional CPLD platform: mellanox: mlx-platform: Add reset cause attribute platform: mellanox: mlx-platform: Modify health and power hotplug action ...
Diffstat (limited to 'drivers/platform/x86/siemens/simatic-ipc-batt-f7188x.c')
-rw-r--r--drivers/platform/x86/siemens/simatic-ipc-batt-f7188x.c87
1 files changed, 87 insertions, 0 deletions
diff --git a/drivers/platform/x86/siemens/simatic-ipc-batt-f7188x.c b/drivers/platform/x86/siemens/simatic-ipc-batt-f7188x.c
new file mode 100644
index 000000000000..a66107e0fe1e
--- /dev/null
+++ b/drivers/platform/x86/siemens/simatic-ipc-batt-f7188x.c
@@ -0,0 +1,87 @@
+// SPDX-License-Identifier: GPL-2.0
+/*
+ * Siemens SIMATIC IPC driver for CMOS battery monitoring
+ *
+ * Copyright (c) Siemens AG, 2023
+ *
+ * Authors:
+ * Henning Schild <henning.schild@siemens.com>
+ */
+
+#include <linux/gpio/machine.h>
+#include <linux/gpio/consumer.h>
+#include <linux/kernel.h>
+#include <linux/module.h>
+#include <linux/platform_device.h>
+#include <linux/platform_data/x86/simatic-ipc-base.h>
+
+#include "simatic-ipc-batt.h"
+
+static struct gpiod_lookup_table *batt_lookup_table;
+
+static struct gpiod_lookup_table simatic_ipc_batt_gpio_table_227g = {
+ .table = {
+ GPIO_LOOKUP_IDX("gpio-f7188x-7", 6, NULL, 0, GPIO_ACTIVE_HIGH),
+ GPIO_LOOKUP_IDX("gpio-f7188x-7", 5, NULL, 1, GPIO_ACTIVE_HIGH),
+ GPIO_LOOKUP_IDX("INTC1020:01", 66, NULL, 2, GPIO_ACTIVE_HIGH),
+ {} /* Terminating entry */
+ },
+};
+
+static struct gpiod_lookup_table simatic_ipc_batt_gpio_table_bx_39a = {
+ .table = {
+ GPIO_LOOKUP_IDX("gpio-f7188x-6", 4, NULL, 0, GPIO_ACTIVE_HIGH),
+ GPIO_LOOKUP_IDX("gpio-f7188x-6", 3, NULL, 1, GPIO_ACTIVE_HIGH),
+ {} /* Terminating entry */
+ },
+};
+
+static struct gpiod_lookup_table simatic_ipc_batt_gpio_table_bx_59a = {
+ .table = {
+ GPIO_LOOKUP_IDX("gpio-f7188x-7", 6, NULL, 0, GPIO_ACTIVE_HIGH),
+ GPIO_LOOKUP_IDX("gpio-f7188x-7", 5, NULL, 1, GPIO_ACTIVE_HIGH),
+ GPIO_LOOKUP_IDX("INTC1056:00", 438, NULL, 2, GPIO_ACTIVE_HIGH),
+ {} /* Terminating entry */
+ }
+};
+
+static int simatic_ipc_batt_f7188x_remove(struct platform_device *pdev)
+{
+ return simatic_ipc_batt_remove(pdev, batt_lookup_table);
+}
+
+static int simatic_ipc_batt_f7188x_probe(struct platform_device *pdev)
+{
+ const struct simatic_ipc_platform *plat = pdev->dev.platform_data;
+
+ switch (plat->devmode) {
+ case SIMATIC_IPC_DEVICE_227G:
+ batt_lookup_table = &simatic_ipc_batt_gpio_table_227g;
+ break;
+ case SIMATIC_IPC_DEVICE_BX_39A:
+ batt_lookup_table = &simatic_ipc_batt_gpio_table_bx_39a;
+ break;
+ case SIMATIC_IPC_DEVICE_BX_59A:
+ batt_lookup_table = &simatic_ipc_batt_gpio_table_bx_59a;
+ break;
+ default:
+ return -ENODEV;
+ }
+
+ return simatic_ipc_batt_probe(pdev, batt_lookup_table);
+}
+
+static struct platform_driver simatic_ipc_batt_driver = {
+ .probe = simatic_ipc_batt_f7188x_probe,
+ .remove = simatic_ipc_batt_f7188x_remove,
+ .driver = {
+ .name = KBUILD_MODNAME,
+ },
+};
+
+module_platform_driver(simatic_ipc_batt_driver);
+
+MODULE_LICENSE("GPL");
+MODULE_ALIAS("platform:" KBUILD_MODNAME);
+MODULE_SOFTDEP("pre: simatic-ipc-batt gpio_f7188x platform:elkhartlake-pinctrl platform:alderlake-pinctrl");
+MODULE_AUTHOR("Henning Schild <henning.schild@siemens.com>");