Re: [PATCH v2 3/4] mfd: tps65917: Add driver for the TPS65917 PMIC
The TPS65917 chip is a power management IC for Portable Navigation Systems and Tablet Computing devices. It contains the following components: - Regulators. - Over Temperature warning and Shut down. This patch adds support for tps65917 mfd device. At this time only the regulator functionality is made available. Signed-off-by: Keerthy j-keer...@ti.com --- Changes in V2: Added volatile register check as some of the registers in the set are volatile. drivers/mfd/Kconfig | 12 + drivers/mfd/Makefile |1 + drivers/mfd/tps65917.c | 573 We have quite the collection of tps* files now in MFD. How different are they really? Is consolidation possible? include/linux/mfd/tps65917.h | 1509 ++ 4 files changed, 2095 insertions(+) create mode 100644 drivers/mfd/tps65917.c create mode 100644 include/linux/mfd/tps65917.h diff --git a/drivers/mfd/Kconfig b/drivers/mfd/Kconfig index 3383412..ac73e58 100644 --- a/drivers/mfd/Kconfig +++ b/drivers/mfd/Kconfig @@ -925,6 +925,18 @@ config MFD_TPS65912_SPI If you say yes here you get support for the TPS65912 series of PM chips with SPI interface. +config MFD_TPS65917 + bool TI TPS65917 series chips + select MFD_CORE + select REGMAP_I2C + select REGMAP_IRQ + depends on I2C=y + help + If you say yes here you get support for the TPS65917 + PMIC chips from Texas Instruments. The device provides + 5 confgurable SPMSs and 5 LDOs, thermal protection module, + GPADC. + config MFD_TPS80031 bool TI TPS80031/TPS80032 Power Management chips depends on I2C=y diff --git a/drivers/mfd/Makefile b/drivers/mfd/Makefile index 2851275..248a60b 100644 --- a/drivers/mfd/Makefile +++ b/drivers/mfd/Makefile @@ -69,6 +69,7 @@ tps65912-objs := tps65912-core.o tps65912-irq.o obj-$(CONFIG_MFD_TPS65912) += tps65912.o obj-$(CONFIG_MFD_TPS65912_I2C) += tps65912-i2c.o obj-$(CONFIG_MFD_TPS65912_SPI) += tps65912-spi.o +obj-$(CONFIG_MFD_TPS65917) += tps65917.o obj-$(CONFIG_MFD_TPS80031) += tps80031.o obj-$(CONFIG_MENELAUS) += menelaus.o diff --git a/drivers/mfd/tps65917.c b/drivers/mfd/tps65917.c new file mode 100644 index 000..dbd67c5 --- /dev/null +++ b/drivers/mfd/tps65917.c @@ -0,0 +1,573 @@ +/* + * TI TPS65917 Integrated power management chipsets + * + * Copyright (C) 2014 Texas Instruments Incorporated - http://www.ti.com/ + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation. + * + * This program is distributed as is WITHOUT ANY WARRANTY of any + * kind, whether expressed or implied; without even the implied warranty + * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License version 2 for more details. + */ + +#include linux/module.h +#include linux/moduleparam.h +#include linux/init.h +#include linux/slab.h +#include linux/i2c.h +#include linux/interrupt.h +#include linux/irq.h +#include linux/regmap.h +#include linux/err.h +#include linux/mfd/core.h +#include linux/mfd/tps65917.h +#include linux/of_device.h + +#define TPS65917_EXT_REQ (TPS65917_EXT_CONTROL_ENABLE1 | \ + TPS65917_EXT_CONTROL_ENABLE2 | \ + TPS65917_EXT_CONTROL_NSLEEP) + +struct tps65917_sleep_requestor_info { + int id; + int reg_offset; + int bit_pos; +}; + +#define EXTERNAL_REQUESTOR(_id, _offset, _pos) \ + [TPS65917_EXTERNAL_REQSTR_ID_##_id] = { \ + .id = TPS65917_EXTERNAL_REQSTR_ID_##_id,\ + .reg_offset = _offset, \ + .bit_pos = _pos,\ + } + +static struct tps65917_sleep_requestor_info sleep_req_info[] = { + EXTERNAL_REQUESTOR(REGEN1, 0, 0), + EXTERNAL_REQUESTOR(REGEN2, 0, 1), + EXTERNAL_REQUESTOR(REGEN3, 0, 6), + EXTERNAL_REQUESTOR(SMPS1, 1, 0), + EXTERNAL_REQUESTOR(SMPS2, 1, 1), + EXTERNAL_REQUESTOR(SMPS3, 1, 2), + EXTERNAL_REQUESTOR(SMPS4, 1, 3), + EXTERNAL_REQUESTOR(SMPS5, 1, 4), + EXTERNAL_REQUESTOR(LDO1, 2, 0), + EXTERNAL_REQUESTOR(LDO2, 2, 1), + EXTERNAL_REQUESTOR(LDO3, 2, 2), + EXTERNAL_REQUESTOR(LDO4, 2, 3), + EXTERNAL_REQUESTOR(LDO5, 2, 4), +}; + +static int tps65917_voltaile_regs[] = { + TPS65917_SMPS1_CTRL, + TPS65917_SMPS2_CTRL, + TPS65917_SMPS3_CTRL, + TPS65917_SMPS4_CTRL, + TPS65917_SMPS5_CTRL, + TPS65917_LDO1_CTRL, + TPS65917_LDO2_CTRL, + TPS65917_LDO3_CTRL, + TPS65917_LDO4_CTRL, + TPS65917_LDO5_CTRL, +}; + +static bool is_volatile_reg(struct device *dev, unsigned int reg) +{ + int i; + + /*
Re: [PATCH v2 3/4] mfd: tps65917: Add driver for the TPS65917 PMIC
On 05/20/2014 04:11 AM, Keerthy wrote: [...] +config MFD_TPS65917 + bool TI TPS65917 series chips + select MFD_CORE + select REGMAP_I2C + select REGMAP_IRQ + depends on I2C=y ^^ why =y? + help + If you say yes here you get support for the TPS65917 + PMIC chips from Texas Instruments. The device provides + 5 confgurable SPMSs and 5 LDOs, thermal protection module, + GPADC. + config MFD_TPS80031 bool TI TPS80031/TPS80032 Power Management chips depends on I2C=y diff --git a/drivers/mfd/Makefile b/drivers/mfd/Makefile index 2851275..248a60b 100644 --- a/drivers/mfd/Makefile +++ b/drivers/mfd/Makefile @@ -69,6 +69,7 @@ tps65912-objs := tps65912-core.o tps65912-irq.o obj-$(CONFIG_MFD_TPS65912) += tps65912.o obj-$(CONFIG_MFD_TPS65912_I2C) += tps65912-i2c.o obj-$(CONFIG_MFD_TPS65912_SPI) += tps65912-spi.o +obj-$(CONFIG_MFD_TPS65917) += tps65917.o obj-$(CONFIG_MFD_TPS80031) += tps80031.o obj-$(CONFIG_MENELAUS) += menelaus.o diff --git a/drivers/mfd/tps65917.c b/drivers/mfd/tps65917.c new file mode 100644 index 000..dbd67c5 --- /dev/null +++ b/drivers/mfd/tps65917.c @@ -0,0 +1,573 @@ +/* + * TI TPS65917 Integrated power management chipsets + * + * Copyright (C) 2014 Texas Instruments Incorporated - http://www.ti.com/ + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation. + * + * This program is distributed as is WITHOUT ANY WARRANTY of any + * kind, whether expressed or implied; without even the implied warranty + * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License version 2 for more details. + */ + +#include linux/module.h +#include linux/moduleparam.h +#include linux/init.h +#include linux/slab.h +#include linux/i2c.h +#include linux/interrupt.h +#include linux/irq.h +#include linux/regmap.h +#include linux/err.h +#include linux/mfd/core.h +#include linux/mfd/tps65917.h +#include linux/of_device.h snip + +static int tps65917_voltaile_regs[] = { + TPS65917_SMPS1_CTRL, + TPS65917_SMPS2_CTRL, + TPS65917_SMPS3_CTRL, + TPS65917_SMPS4_CTRL, + TPS65917_SMPS5_CTRL, + TPS65917_LDO1_CTRL, + TPS65917_LDO2_CTRL, + TPS65917_LDO3_CTRL, + TPS65917_LDO4_CTRL, + TPS65917_LDO5_CTRL, +}; + +static bool is_volatile_reg(struct device *dev, unsigned int reg) +{ + int i; + + /* + * Caching all the required regulator registers. + */ + + for (i = 0; i 11; i++) + if (reg == tps65917_voltaile_regs[i]) + return true; + + return false; +} + +static const struct regmap_config tps65917_regmap_config[TPS65917_NUM_CLIENTS] = { + { + .reg_bits = 8, + .val_bits = 8, + .volatile_reg = is_volatile_reg, + .cache_type = REGCACHE_NONE, Assume you wanted cached here, since you are marking certain registers as volatile? [...] +}; + +int tps65917_ext_control_req_config(struct tps65917 *tps65917, + enum tps65917_external_requestor_id id, + int ext_ctrl, bool enable) +{ kernel doc style documentation [...] +static struct tps65917 *tps65917_dev; + +static const struct of_device_id of_tps65917_match_tbl[] = { + { + .compatible = ti,tps65917, + }, + { }, +}; +MODULE_DEVICE_TABLE(of, of_tps65917_match_tbl); + +static int tps65917_i2c_probe(struct i2c_client *i2c, + const struct i2c_device_id *id) +{ [...] + /* + * If we are probing with DT do this the DT way and return here + * otherwise continue and add devices using mfd helpers. + */ + if (node) { + ret = of_platform_populate(node, NULL, NULL, i2c-dev); + if (ret 0) + goto err_irq; + else if (pdata-pm_off !pm_power_off) + tps65917_dev = tps65917; and where is the actual power off function? + } + + return ret; + +err_irq: + regmap_del_irq_chip(tps65917-irq, tps65917-irq_data); +err_i2c: + for (i = 1; i TPS65917_NUM_CLIENTS; i++) { + if (tps65917-i2c_clients[i]) + i2c_unregister_device(tps65917-i2c_clients[i]); + } + return ret; +} + +static int tps65917_i2c_remove(struct i2c_client *i2c) +{ + struct tps65917 *tps65917 = i2c_get_clientdata(i2c); + int i; + + regmap_del_irq_chip(tps65917-irq, tps65917-irq_data); + + for (i = 1; i TPS65917_NUM_CLIENTS; i++) { + if (tps65917-i2c_clients[i]) + i2c_unregister_device(tps65917-i2c_clients[i]); + } + + return 0; +} + +static const struct
Re: [PATCH v2 3/4] mfd: tps65917: Add driver for the TPS65917 PMIC
Hi Lee Jones, Thanks for the review. On Tuesday 20 May 2014 07:28 PM, Lee Jones wrote: The TPS65917 chip is a power management IC for Portable Navigation Systems and Tablet Computing devices. It contains the following components: - Regulators. - Over Temperature warning and Shut down. This patch adds support for tps65917 mfd device. At this time only the regulator functionality is made available. Signed-off-by: Keerthy j-keer...@ti.com --- Changes in V2: Added volatile register check as some of the registers in the set are volatile. drivers/mfd/Kconfig | 12 + drivers/mfd/Makefile |1 + drivers/mfd/tps65917.c | 573 We have quite the collection of tps* files now in MFD. How different are they really? Is consolidation possible? Unfortunately yes! This is pretty similar to Palmas. Register offsets are completely different and i have already compensated TPS659038 which essentially had the same register set. I am pretty much based on Palmas driver but most of the register offsets are different and this is a much smaller and simpler PMIC. Hence adding a new driver. include/linux/mfd/tps65917.h | 1509 ++ 4 files changed, 2095 insertions(+) create mode 100644 drivers/mfd/tps65917.c create mode 100644 include/linux/mfd/tps65917.h diff --git a/drivers/mfd/Kconfig b/drivers/mfd/Kconfig index 3383412..ac73e58 100644 --- a/drivers/mfd/Kconfig +++ b/drivers/mfd/Kconfig @@ -925,6 +925,18 @@ config MFD_TPS65912_SPI If you say yes here you get support for the TPS65912 series of PM chips with SPI interface. +config MFD_TPS65917 + bool TI TPS65917 series chips + select MFD_CORE + select REGMAP_I2C + select REGMAP_IRQ + depends on I2C=y + help + If you say yes here you get support for the TPS65917 + PMIC chips from Texas Instruments. The device provides + 5 confgurable SPMSs and 5 LDOs, thermal protection module, + GPADC. + config MFD_TPS80031 bool TI TPS80031/TPS80032 Power Management chips depends on I2C=y diff --git a/drivers/mfd/Makefile b/drivers/mfd/Makefile index 2851275..248a60b 100644 --- a/drivers/mfd/Makefile +++ b/drivers/mfd/Makefile @@ -69,6 +69,7 @@ tps65912-objs := tps65912-core.o tps65912-irq.o obj-$(CONFIG_MFD_TPS65912)+= tps65912.o obj-$(CONFIG_MFD_TPS65912_I2C)+= tps65912-i2c.o obj-$(CONFIG_MFD_TPS65912_SPI) += tps65912-spi.o +obj-$(CONFIG_MFD_TPS65917) += tps65917.o obj-$(CONFIG_MFD_TPS80031)+= tps80031.o obj-$(CONFIG_MENELAUS)+= menelaus.o diff --git a/drivers/mfd/tps65917.c b/drivers/mfd/tps65917.c new file mode 100644 index 000..dbd67c5 --- /dev/null +++ b/drivers/mfd/tps65917.c @@ -0,0 +1,573 @@ +/* + * TI TPS65917 Integrated power management chipsets + * + * Copyright (C) 2014 Texas Instruments Incorporated - http://www.ti.com/ + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation. + * + * This program is distributed as is WITHOUT ANY WARRANTY of any + * kind, whether expressed or implied; without even the implied warranty + * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License version 2 for more details. + */ + +#include linux/module.h +#include linux/moduleparam.h +#include linux/init.h +#include linux/slab.h +#include linux/i2c.h +#include linux/interrupt.h +#include linux/irq.h +#include linux/regmap.h +#include linux/err.h +#include linux/mfd/core.h +#include linux/mfd/tps65917.h +#include linux/of_device.h + +#define TPS65917_EXT_REQ (TPS65917_EXT_CONTROL_ENABLE1 | \ + TPS65917_EXT_CONTROL_ENABLE2 | \ + TPS65917_EXT_CONTROL_NSLEEP) + +struct tps65917_sleep_requestor_info { + int id; + int reg_offset; + int bit_pos; +}; + +#define EXTERNAL_REQUESTOR(_id, _offset, _pos) \ + [TPS65917_EXTERNAL_REQSTR_ID_##_id] = { \ + .id = TPS65917_EXTERNAL_REQSTR_ID_##_id,\ + .reg_offset = _offset, \ + .bit_pos = _pos,\ + } + +static struct tps65917_sleep_requestor_info sleep_req_info[] = { + EXTERNAL_REQUESTOR(REGEN1, 0, 0), + EXTERNAL_REQUESTOR(REGEN2, 0, 1), + EXTERNAL_REQUESTOR(REGEN3, 0, 6), + EXTERNAL_REQUESTOR(SMPS1, 1, 0), + EXTERNAL_REQUESTOR(SMPS2, 1, 1), + EXTERNAL_REQUESTOR(SMPS3, 1, 2), + EXTERNAL_REQUESTOR(SMPS4, 1, 3), + EXTERNAL_REQUESTOR(SMPS5, 1, 4), + EXTERNAL_REQUESTOR(LDO1, 2, 0), + EXTERNAL_REQUESTOR(LDO2, 2, 1), + EXTERNAL_REQUESTOR(LDO3, 2, 2), + EXTERNAL_REQUESTOR(LDO4, 2, 3), + EXTERNAL_REQUESTOR(LDO5, 2, 4), +}; + +static int
Re: [PATCH v2 3/4] mfd: tps65917: Add driver for the TPS65917 PMIC
Hi Nishanth, On Tuesday 20 May 2014 07:45 PM, Nishanth Menon wrote: On 05/20/2014 04:11 AM, Keerthy wrote: [...] +config MFD_TPS65917 + bool TI TPS65917 series chips + select MFD_CORE + select REGMAP_I2C + select REGMAP_IRQ + depends on I2C=y ^^ why =y? Palmas derived. I will knock off the 'y' + help + If you say yes here you get support for the TPS65917 + PMIC chips from Texas Instruments. The device provides + 5 confgurable SPMSs and 5 LDOs, thermal protection module, + GPADC. + config MFD_TPS80031 bool TI TPS80031/TPS80032 Power Management chips depends on I2C=y diff --git a/drivers/mfd/Makefile b/drivers/mfd/Makefile index 2851275..248a60b 100644 --- a/drivers/mfd/Makefile +++ b/drivers/mfd/Makefile @@ -69,6 +69,7 @@ tps65912-objs := tps65912-core.o tps65912-irq.o obj-$(CONFIG_MFD_TPS65912)+= tps65912.o obj-$(CONFIG_MFD_TPS65912_I2C)+= tps65912-i2c.o obj-$(CONFIG_MFD_TPS65912_SPI) += tps65912-spi.o +obj-$(CONFIG_MFD_TPS65917) += tps65917.o obj-$(CONFIG_MFD_TPS80031)+= tps80031.o obj-$(CONFIG_MENELAUS)+= menelaus.o diff --git a/drivers/mfd/tps65917.c b/drivers/mfd/tps65917.c new file mode 100644 index 000..dbd67c5 --- /dev/null +++ b/drivers/mfd/tps65917.c @@ -0,0 +1,573 @@ +/* + * TI TPS65917 Integrated power management chipsets + * + * Copyright (C) 2014 Texas Instruments Incorporated - http://www.ti.com/ + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation. + * + * This program is distributed as is WITHOUT ANY WARRANTY of any + * kind, whether expressed or implied; without even the implied warranty + * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License version 2 for more details. + */ + +#include linux/module.h +#include linux/moduleparam.h +#include linux/init.h +#include linux/slab.h +#include linux/i2c.h +#include linux/interrupt.h +#include linux/irq.h +#include linux/regmap.h +#include linux/err.h +#include linux/mfd/core.h +#include linux/mfd/tps65917.h +#include linux/of_device.h snip + +static int tps65917_voltaile_regs[] = { + TPS65917_SMPS1_CTRL, + TPS65917_SMPS2_CTRL, + TPS65917_SMPS3_CTRL, + TPS65917_SMPS4_CTRL, + TPS65917_SMPS5_CTRL, + TPS65917_LDO1_CTRL, + TPS65917_LDO2_CTRL, + TPS65917_LDO3_CTRL, + TPS65917_LDO4_CTRL, + TPS65917_LDO5_CTRL, +}; + +static bool is_volatile_reg(struct device *dev, unsigned int reg) +{ + int i; + + /* +* Caching all the required regulator registers. +*/ + + for (i = 0; i 11; i++) + if (reg == tps65917_voltaile_regs[i]) + return true; + + return false; +} + +static const struct regmap_config tps65917_regmap_config[TPS65917_NUM_CLIENTS] = { + { + .reg_bits = 8, + .val_bits = 8, + .volatile_reg = is_volatile_reg, + .cache_type = REGCACHE_NONE, Assume you wanted cached here, since you are marking certain registers as volatile? [...] Yes. I will correct this. +}; + +int tps65917_ext_control_req_config(struct tps65917 *tps65917, + enum tps65917_external_requestor_id id, + int ext_ctrl, bool enable) +{ kernel doc style documentation [...] +static struct tps65917 *tps65917_dev; + +static const struct of_device_id of_tps65917_match_tbl[] = { + { + .compatible = ti,tps65917, + }, + { }, +}; +MODULE_DEVICE_TABLE(of, of_tps65917_match_tbl); + +static int tps65917_i2c_probe(struct i2c_client *i2c, + const struct i2c_device_id *id) +{ [...] + /* +* If we are probing with DT do this the DT way and return here +* otherwise continue and add devices using mfd helpers. +*/ + if (node) { + ret = of_platform_populate(node, NULL, NULL, i2c-dev); + if (ret 0) + goto err_irq; + else if (pdata-pm_off !pm_power_off) + tps65917_dev = tps65917; and where is the actual power off function? I will add that. + } + + return ret; + +err_irq: + regmap_del_irq_chip(tps65917-irq, tps65917-irq_data); +err_i2c: + for (i = 1; i TPS65917_NUM_CLIENTS; i++) { + if (tps65917-i2c_clients[i]) + i2c_unregister_device(tps65917-i2c_clients[i]); + } + return ret; +} + +static int tps65917_i2c_remove(struct i2c_client *i2c) +{ + struct tps65917 *tps65917 = i2c_get_clientdata(i2c); + int i; + + regmap_del_irq_chip(tps65917-irq, tps65917-irq_data); + + for (i = 1; i TPS65917_NUM_CLIENTS; i++) { +