summaryrefslogtreecommitdiff
path: root/drivers/mfd/lp87565.c
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2017-07-07 13:30:05 -0700
committerLinus Torvalds <torvalds@linux-foundation.org>2017-07-07 13:30:05 -0700
commit6972b007ca771e33dec992ccd104c95a97a186e5 (patch)
tree0668041e466832b3157bcb02fa7923a29d477ea2 /drivers/mfd/lp87565.c
parentc7d28eca1d58d335ff8de6f33559b221bdd029f9 (diff)
parent1e3496000c11ec1ec56cf664b6a01d66de423507 (diff)
Merge (most of) tag 'mfd-next-4.13' of git://git.kernel.org/pub/scm/linux/kernel/git/lee/mfd
Pull MFD updates from Lee Jones: "New Drivers: - Intel Cherry Trail Whiskey Cove PMIC - TI LP87565 PMIC New Device Support: - Add support for Cannonlake to intel-lpss-pci - Add support for Simatic IOT2000 to intel_quark_i2c_gpio New Functionality: - Add Regulator support (axp20x) Fix-ups: - Rework IRQ handling (intel_soc_pmic_bxtwc, rtsx_pcr, cros_ec) - Remove unused/unwelcome code (ipaq-micro, wm831x-core, da9062-core) - Provide deregistration on unbind (rn5t618) - Rework DT code/documentation (arizona) - Constify things (fsl-imx25-tsadc) - MAINTAINERS updates (DA9062/61) - Kconfig configuration adaptions (INTEL_SOC_PMIC, MFD_AXP20X_I2C) - Switch to DMI matching (intel_quark_i2c_gpio) - Provide an appropriate level of error checking (wm831x-{i2c,spi}, twl4030-irq, tc6393xb) - Make use of devm_* (resource handling) calls (intel_soc_pmic_bxtwc, stm32-timers, atmel-flexcom, cros_ec, fsl-imx25-tsadc, exynos-lpass, palmas, qcom-spmi-pmic, smsc-ece1099, motorola-cpcap)" [ Skipped the last commit in that series that added eight thousand lines of pointless repeated register definitions. - Linus ] * tag 'mfd-next-4.13' of git://git.kernel.org/pub/scm/linux/kernel/git/lee/mfd: (38 commits) mfd: Add LP87565 PMIC support mfd: cros_ec: Free IRQ on exit dt-bindings: vendor-prefixes: Add arctic to vendor prefix mfd: da9061: Fix to remove BBAT_CONT register from chip model mfd: da9061: Fix to remove BBAT_CONT register from chip model mfd: axp20x-i2c: Document that this must be builtin on x86 mfd: Add Cherry Trail Whiskey Cove PMIC driver mfd: tc6393xb: Handle return value of clk_prepare_enable mfd: intel_quark_i2c_gpio: Add support for SIMATIC IOT2000 platform mfd: intel_quark_i2c_gpio: Use dmi_system_id table for retrieving frequency mfd: motorola-cpcap: Use devm_of_platform_populate() mfd: smsc-ece: Use devm_of_platform_populate() mfd: qcom-spmi-pmic: Use devm_of_platform_populate() mfd: palmas: Use devm_of_platform_populate() mfd: exynos: Use devm_of_platform_populate() mfd: fsl-imx25: Use devm_of_platform_populate() mfd: cros_ec: Use devm_of_platform_populate() mfd: atmel: Use devm_of_platform_populate() mfd: stm32-timers: Use devm_of_platform_populate() mfd: intel_soc_pmic: Select designware i2c-bus driver ...
Diffstat (limited to 'drivers/mfd/lp87565.c')
-rw-r--r--drivers/mfd/lp87565.c100
1 files changed, 100 insertions, 0 deletions
diff --git a/drivers/mfd/lp87565.c b/drivers/mfd/lp87565.c
new file mode 100644
index 000000000000..340ad0c63744
--- /dev/null
+++ b/drivers/mfd/lp87565.c
@@ -0,0 +1,100 @@
+/*
+ * Copyright (C) 2017 Texas Instruments Incorporated - http://www.ti.com/
+ *
+ * Author: Keerthy <j-keerthy@ti.com>
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation version 2.
+ */
+
+#include <linux/interrupt.h>
+#include <linux/mfd/core.h>
+#include <linux/module.h>
+#include <linux/of_device.h>
+#include <linux/regmap.h>
+
+#include <linux/mfd/lp87565.h>
+
+static const struct regmap_config lp87565_regmap_config = {
+ .reg_bits = 8,
+ .val_bits = 8,
+ .max_register = LP87565_REG_MAX,
+};
+
+static const struct mfd_cell lp87565_cells[] = {
+ { .name = "lp87565-q1-regulator", },
+ { .name = "lp87565-q1-gpio", },
+};
+
+static const struct of_device_id of_lp87565_match_table[] = {
+ { .compatible = "ti,lp87565", },
+ {
+ .compatible = "ti,lp87565-q1",
+ .data = (void *)LP87565_DEVICE_TYPE_LP87565_Q1,
+ },
+ {}
+};
+MODULE_DEVICE_TABLE(of, of_lp87565_match_table);
+
+static int lp87565_probe(struct i2c_client *client,
+ const struct i2c_device_id *ids)
+{
+ struct lp87565 *lp87565;
+ const struct of_device_id *of_id;
+ int ret;
+ unsigned int otpid;
+
+ lp87565 = devm_kzalloc(&client->dev, sizeof(*lp87565), GFP_KERNEL);
+ if (!lp87565)
+ return -ENOMEM;
+
+ lp87565->dev = &client->dev;
+
+ lp87565->regmap = devm_regmap_init_i2c(client, &lp87565_regmap_config);
+ if (IS_ERR(lp87565->regmap)) {
+ ret = PTR_ERR(lp87565->regmap);
+ dev_err(lp87565->dev,
+ "Failed to initialize register map: %d\n", ret);
+ return ret;
+ }
+
+ ret = regmap_read(lp87565->regmap, LP87565_REG_OTP_REV, &otpid);
+ if (ret) {
+ dev_err(lp87565->dev, "Failed to read OTP ID\n");
+ return ret;
+ }
+
+ lp87565->rev = otpid & LP87565_OTP_REV_OTP_ID;
+
+ of_id = of_match_device(of_lp87565_match_table, &client->dev);
+ if (of_id)
+ lp87565->dev_type = (enum lp87565_device_type)of_id->data;
+
+ i2c_set_clientdata(client, lp87565);
+
+ ret = mfd_add_devices(lp87565->dev, PLATFORM_DEVID_AUTO, lp87565_cells,
+ ARRAY_SIZE(lp87565_cells), NULL, 0, NULL);
+
+ return ret;
+}
+
+static const struct i2c_device_id lp87565_id_table[] = {
+ { "lp87565-q1", 0 },
+ { },
+};
+MODULE_DEVICE_TABLE(i2c, lp87565_id_table);
+
+static struct i2c_driver lp87565_driver = {
+ .driver = {
+ .name = "lp87565",
+ .of_match_table = of_lp87565_match_table,
+ },
+ .probe = lp87565_probe,
+ .id_table = lp87565_id_table,
+};
+module_i2c_driver(lp87565_driver);
+
+MODULE_AUTHOR("J Keerthy <j-keerthy@ti.com>");
+MODULE_DESCRIPTION("lp87565 chip family Multi-Function Device driver");
+MODULE_LICENSE("GPL v2");