@@ -752,6 +752,14 @@ config STMPE_SPI
This is used to enable SPI interface of STMPE
endmenu
+config MFD_ST_LPC
+ tristate "STMicroelectronics Low-Power-Controller"
+ depends on OF
+ select MFD_CORE
+ help
+ Say yes here to add support for ST's Low-Power-Controller (LPC).
+ This device provides Real-Time Clock and Watchdog functionality.
+
config MFD_STA2X11
bool "STMicroelectronics STA2X11"
depends on STA2X11
@@ -29,6 +29,7 @@ obj-$(CONFIG_MFD_STA2X11) += sta2x11-mfd.o
obj-$(CONFIG_MFD_STMPE) += stmpe.o
obj-$(CONFIG_STMPE_I2C) += stmpe-i2c.o
obj-$(CONFIG_STMPE_SPI) += stmpe-spi.o
+obj-$(CONFIG_MFD_ST_LPC) += st-lpc.o
obj-$(CONFIG_MFD_SUN6I_PRCM) += sun6i-prcm.o
obj-$(CONFIG_MFD_TC3589X) += tc3589x.o
obj-$(CONFIG_MFD_T7L66XB) += t7l66xb.o tmio_core.o
new file mode 100644
@@ -0,0 +1,88 @@
+/*
+ * st-lpc.c - ST's Low Power Controller (LPC) Multi-Function Device Driver
+ *
+ * Copyright (C) 2014 STMicroelectronics -- All Rights Reserved
+ *
+ * Author: Lee Jones <lee.jones@linaro.org> for STMicroelectronics
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public Licence
+ * as published by the Free Software Foundation; either version
+ * 2 of the Licence, or (at your option) any later version.
+ */
+
+#include <linux/err.h>
+#include <linux/mfd/core.h>
+#include <linux/module.h>
+#include <linux/of_device.h>
+#include <dt-bindings/mfd/st-lpc.h>
+
+static int st_lpc_probe(struct platform_device *pdev)
+{
+ struct device_node *np = pdev->dev.of_node;
+ struct mfd_cell *cell;
+ u32 mode;
+ int ret;
+
+ cell = devm_kzalloc(&pdev->dev, sizeof(*cell), GFP_KERNEL);
+ if (!cell)
+ return -ENOMEM;
+
+ ret = of_property_read_u32(np, "st,lpc-mode", &mode);
+ if (ret) {
+ dev_err(&pdev->dev, "An LPC mode must be selected\n");
+ return ret;
+ }
+
+ switch (mode) {
+ case ST_LPC_MODE_RTC:
+ cell->name = "st-lpc-rtc";
+ break;
+ case ST_LPC_MODE_WDT:
+ cell->name = "st-lpc-wdt";
+ break;
+ default:
+ dev_err(&pdev->dev, "Unsupported mode: %d\n", mode);
+ return ret;
+ }
+
+ /* Pass resources though to selected child device. */
+ cell->resources = pdev->resource;
+ cell->num_resources = pdev->num_resources;
+
+ ret = mfd_add_devices(&pdev->dev, PLATFORM_DEVID_AUTO,
+ cell, 1, NULL, 0, NULL);
+ if (ret) {
+ dev_err(&pdev->dev, "Failed to register child devices\n");
+ return ret;
+ }
+
+ return 0;
+}
+
+static int st_lpc_remove(struct platform_device *pdev)
+{
+ mfd_remove_devices(&pdev->dev);
+
+ return 0;
+}
+
+static const struct of_device_id st_lpc_dt_match[] = {
+ { .compatible = "st,stih407-lpc" },
+ { }
+};
+
+static struct platform_driver st_lpc_driver = {
+ .driver = {
+ .name = "st-lpc",
+ .of_match_table = st_lpc_dt_match,
+ },
+ .probe = st_lpc_probe,
+ .remove = st_lpc_remove,
+};
+
+module_platform_driver(st_lpc_driver);
+
+MODULE_AUTHOR("Lee Jones <lee.jones@linaro.org>");
+MODULE_DESCRIPTION("ST's Low Power Controller (LPC) Multi-Function Device");
+MODULE_LICENSE("GPL");
On current ST platforms the LPC controls a number of functions. This patch enables possible support for the LPC Watchdog and LPC RTC devices and ensures only one of them operates at any one time. Signed-off-by: Lee Jones <lee.jones@linaro.org> --- drivers/mfd/Kconfig | 8 +++++ drivers/mfd/Makefile | 1 + drivers/mfd/st-lpc.c | 88 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 97 insertions(+) create mode 100644 drivers/mfd/st-lpc.c