next_update = priv.last_updated_jiffies + msecs_to_jiffies(BATT_DELAY_MS);
if (time_after(jiffies, next_update) || !priv.last_updated_jiffies) {
- switch (priv.devmode) {
- case SIMATIC_IPC_DEVICE_127E:
- case SIMATIC_IPC_DEVICE_227G:
- case SIMATIC_IPC_DEVICE_BX_39A:
- priv.current_state = simatic_ipc_batt_read_gpio();
- break;
- case SIMATIC_IPC_DEVICE_227E:
+ if (priv.devmode == SIMATIC_IPC_DEVICE_227E)
priv.current_state = simatic_ipc_batt_read_io(dev);
- break;
- }
+ else
+ priv.current_state = simatic_ipc_batt_read_gpio();
+
priv.last_updated_jiffies = jiffies;
if (priv.current_state < SIMATIC_IPC_BATT_LEVEL_FULL)
- dev_warn(dev, "CMOS battery needs to be replaced.");
+ dev_warn(dev, "CMOS battery needs to be replaced.\n");
}
return priv.current_state;
struct simatic_ipc_platform *plat;
struct device *dev = &pdev->dev;
struct device *hwmon_dev;
+ unsigned long flags;
int err;
plat = pdev->dev.platform_data;
}
if (table->table[2].key) {
- priv.gpios[2] = devm_gpiod_get_index(dev, "CMOSBattery meter", 2, GPIOD_OUT_HIGH);
+ flags = GPIOD_OUT_HIGH;
+ if (priv.devmode == SIMATIC_IPC_DEVICE_BX_21A)
+ flags = GPIOD_OUT_LOW;
+ priv.gpios[2] = devm_gpiod_get_index(dev, "CMOSBattery meter", 2, flags);
if (IS_ERR(priv.gpios[2])) {
err = PTR_ERR(priv.gpios[1]);
priv.gpios[2] = NULL;