platform/x86/siemens: simatic-ipc-batt: add support for module BX-59A
This is used for the Siemens Simatic IPC BX-59A, which can monitor the voltage of the CMOS battery with two bits that indicate low or empty state Signed-off-by: xingtong.wu <xingtong.wu@siemens.com> Link: https://lore.kernel.org/r/20230731072148.4781-1-xingtong_wu@163.com Reviewed-by: Hans de Goede <hdegoede@redhat.com> Signed-off-by: Hans de Goede <hdegoede@redhat.com>
This commit is contained in:
parent
b8af779519
commit
c56beff203
@ -54,6 +54,7 @@ config SIEMENS_SIMATIC_IPC_BATT_F7188X
|
|||||||
tristate "CMOS Battery monitoring for Simatic IPCs based on Nuvoton GPIO"
|
tristate "CMOS Battery monitoring for Simatic IPCs based on Nuvoton GPIO"
|
||||||
default SIEMENS_SIMATIC_IPC_BATT
|
default SIEMENS_SIMATIC_IPC_BATT
|
||||||
depends on GPIO_F7188X
|
depends on GPIO_F7188X
|
||||||
|
depends on PINCTRL_ALDERLAKE
|
||||||
depends on SIEMENS_SIMATIC_IPC_BATT
|
depends on SIEMENS_SIMATIC_IPC_BATT
|
||||||
help
|
help
|
||||||
This option enables CMOS battery monitoring for Simatic Industrial PCs
|
This option enables CMOS battery monitoring for Simatic Industrial PCs
|
||||||
|
@ -17,6 +17,8 @@
|
|||||||
|
|
||||||
#include "simatic-ipc-batt.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 = {
|
static struct gpiod_lookup_table simatic_ipc_batt_gpio_table_227g = {
|
||||||
.table = {
|
.table = {
|
||||||
GPIO_LOOKUP_IDX("gpio-f7188x-7", 6, NULL, 0, GPIO_ACTIVE_HIGH),
|
GPIO_LOOKUP_IDX("gpio-f7188x-7", 6, NULL, 0, GPIO_ACTIVE_HIGH),
|
||||||
@ -34,24 +36,39 @@ static struct gpiod_lookup_table simatic_ipc_batt_gpio_table_bx_39a = {
|
|||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
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)
|
static int simatic_ipc_batt_f7188x_remove(struct platform_device *pdev)
|
||||||
{
|
{
|
||||||
const struct simatic_ipc_platform *plat = pdev->dev.platform_data;
|
return simatic_ipc_batt_remove(pdev, batt_lookup_table);
|
||||||
|
|
||||||
if (plat->devmode == SIMATIC_IPC_DEVICE_227G)
|
|
||||||
return simatic_ipc_batt_remove(pdev, &simatic_ipc_batt_gpio_table_227g);
|
|
||||||
|
|
||||||
return simatic_ipc_batt_remove(pdev, &simatic_ipc_batt_gpio_table_bx_39a);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static int simatic_ipc_batt_f7188x_probe(struct platform_device *pdev)
|
static int simatic_ipc_batt_f7188x_probe(struct platform_device *pdev)
|
||||||
{
|
{
|
||||||
const struct simatic_ipc_platform *plat = pdev->dev.platform_data;
|
const struct simatic_ipc_platform *plat = pdev->dev.platform_data;
|
||||||
|
|
||||||
if (plat->devmode == SIMATIC_IPC_DEVICE_227G)
|
switch (plat->devmode) {
|
||||||
return simatic_ipc_batt_probe(pdev, &simatic_ipc_batt_gpio_table_227g);
|
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, &simatic_ipc_batt_gpio_table_bx_39a);
|
return simatic_ipc_batt_probe(pdev, batt_lookup_table);
|
||||||
}
|
}
|
||||||
|
|
||||||
static struct platform_driver simatic_ipc_batt_driver = {
|
static struct platform_driver simatic_ipc_batt_driver = {
|
||||||
@ -66,5 +83,5 @@ module_platform_driver(simatic_ipc_batt_driver);
|
|||||||
|
|
||||||
MODULE_LICENSE("GPL");
|
MODULE_LICENSE("GPL");
|
||||||
MODULE_ALIAS("platform:" KBUILD_MODNAME);
|
MODULE_ALIAS("platform:" KBUILD_MODNAME);
|
||||||
MODULE_SOFTDEP("pre: simatic-ipc-batt gpio_f7188x platform:elkhartlake-pinctrl");
|
MODULE_SOFTDEP("pre: simatic-ipc-batt gpio_f7188x platform:elkhartlake-pinctrl platform:alderlake-pinctrl");
|
||||||
MODULE_AUTHOR("Henning Schild <henning.schild@siemens.com>");
|
MODULE_AUTHOR("Henning Schild <henning.schild@siemens.com>");
|
||||||
|
@ -169,6 +169,7 @@ int simatic_ipc_batt_probe(struct platform_device *pdev, struct gpiod_lookup_tab
|
|||||||
case SIMATIC_IPC_DEVICE_227G:
|
case SIMATIC_IPC_DEVICE_227G:
|
||||||
case SIMATIC_IPC_DEVICE_BX_39A:
|
case SIMATIC_IPC_DEVICE_BX_39A:
|
||||||
case SIMATIC_IPC_DEVICE_BX_21A:
|
case SIMATIC_IPC_DEVICE_BX_21A:
|
||||||
|
case SIMATIC_IPC_DEVICE_BX_59A:
|
||||||
table->dev_id = dev_name(dev);
|
table->dev_id = dev_name(dev);
|
||||||
gpiod_add_lookup_table(table);
|
gpiod_add_lookup_table(table);
|
||||||
break;
|
break;
|
||||||
@ -193,7 +194,7 @@ int simatic_ipc_batt_probe(struct platform_device *pdev, struct gpiod_lookup_tab
|
|||||||
|
|
||||||
if (table->table[2].key) {
|
if (table->table[2].key) {
|
||||||
flags = GPIOD_OUT_HIGH;
|
flags = GPIOD_OUT_HIGH;
|
||||||
if (priv.devmode == SIMATIC_IPC_DEVICE_BX_21A)
|
if (priv.devmode == SIMATIC_IPC_DEVICE_BX_21A || SIMATIC_IPC_DEVICE_BX_59A)
|
||||||
flags = GPIOD_OUT_LOW;
|
flags = GPIOD_OUT_LOW;
|
||||||
priv.gpios[2] = devm_gpiod_get_index(dev, "CMOSBattery meter", 2, flags);
|
priv.gpios[2] = devm_gpiod_get_index(dev, "CMOSBattery meter", 2, flags);
|
||||||
if (IS_ERR(priv.gpios[2])) {
|
if (IS_ERR(priv.gpios[2])) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user