1 // SPDX-License-Identifier: GPL-2.0 2 /* 3 * Siemens SIMATIC IPC driver for CMOS battery monitoring 4 * 5 * Copyright (c) Siemens AG, 2023 6 * 7 * Authors: 8 * Henning Schild <henning.schild@siemens.com> 9 */ 10 11 #include <linux/gpio/machine.h> 12 #include <linux/gpio/consumer.h> 13 #include <linux/kernel.h> 14 #include <linux/module.h> 15 #include <linux/platform_device.h> 16 #include <linux/platform_data/x86/simatic-ipc-base.h> 17 18 #include "simatic-ipc-batt.h" 19 20 static struct gpiod_lookup_table simatic_ipc_batt_gpio_table_227g = { 21 .table = { 22 GPIO_LOOKUP_IDX("gpio-f7188x-7", 6, NULL, 0, GPIO_ACTIVE_HIGH), 23 GPIO_LOOKUP_IDX("gpio-f7188x-7", 5, NULL, 1, GPIO_ACTIVE_HIGH), 24 GPIO_LOOKUP_IDX("INTC1020:01", 66, NULL, 2, GPIO_ACTIVE_HIGH), 25 {} /* Terminating entry */ 26 }, 27 }; 28 29 static struct gpiod_lookup_table simatic_ipc_batt_gpio_table_bx_39a = { 30 .table = { 31 GPIO_LOOKUP_IDX("gpio-f7188x-6", 4, NULL, 0, GPIO_ACTIVE_HIGH), 32 GPIO_LOOKUP_IDX("gpio-f7188x-6", 3, NULL, 1, GPIO_ACTIVE_HIGH), 33 {} /* Terminating entry */ 34 }, 35 }; 36 37 static int simatic_ipc_batt_f7188x_remove(struct platform_device *pdev) 38 { 39 const struct simatic_ipc_platform *plat = pdev->dev.platform_data; 40 41 if (plat->devmode == SIMATIC_IPC_DEVICE_227G) 42 return simatic_ipc_batt_remove(pdev, &simatic_ipc_batt_gpio_table_227g); 43 44 return simatic_ipc_batt_remove(pdev, &simatic_ipc_batt_gpio_table_bx_39a); 45 } 46 47 static int simatic_ipc_batt_f7188x_probe(struct platform_device *pdev) 48 { 49 const struct simatic_ipc_platform *plat = pdev->dev.platform_data; 50 51 if (plat->devmode == SIMATIC_IPC_DEVICE_227G) 52 return simatic_ipc_batt_probe(pdev, &simatic_ipc_batt_gpio_table_227g); 53 54 return simatic_ipc_batt_probe(pdev, &simatic_ipc_batt_gpio_table_bx_39a); 55 } 56 57 static struct platform_driver simatic_ipc_batt_driver = { 58 .probe = simatic_ipc_batt_f7188x_probe, 59 .remove = simatic_ipc_batt_f7188x_remove, 60 .driver = { 61 .name = KBUILD_MODNAME, 62 }, 63 }; 64 65 module_platform_driver(simatic_ipc_batt_driver); 66 67 MODULE_LICENSE("GPL"); 68 MODULE_ALIAS("platform:" KBUILD_MODNAME); 69 MODULE_SOFTDEP("pre: simatic-ipc-batt gpio_f7188x platform:elkhartlake-pinctrl"); 70 MODULE_AUTHOR("Henning Schild <henning.schild@siemens.com>"); 71