tps65917: Drivers for TPS65917 PMIC
Subsystems (3)
v2 cover tps65917: Drivers for TPS65917 PMIC
The TPS65917 chip is a power management IC for Portable Navigation Systems and Tablet Computing devices. It contains the following components:
- Regulators.
- GPADC.
- Over Temperature warning and Shut down.
This patch series adds support for TPS65917 mfd device. At this time only the regulator functionality is made available.
The closest drivers are PALMAS series drivers.
The register set is changed. Bit-field defenitions are changed. Hence based on the PALMAS drivers and created a new set of drivers with code changes as required.
The patches are boot tested on DRA72-EVM.
Keerthy (4):
MFD: DT bindings for the TPS65917 family MFD
Regulators: Add TPS65917 Bindings
mfd: tps65917: Add driver for the TPS65917 PMIC
regulator: tps65917: Add Regulator driver for TPS65917 PMIC
Documentation/devicetree/bindings/mfd/tps65917.txt | 35 + .../bindings/regulator/tps65917-pmic.txt | 67 + drivers/mfd/Kconfig | 12 + drivers/mfd/Makefile | 1 + drivers/mfd/tps65917.c | 573 ++++++++ drivers/regulator/Kconfig | 12 + drivers/regulator/Makefile | 1 + drivers/regulator/tps65917-regulator.c | 810 +++++++++++ include/linux/mfd/tps65917.h | 1509 ++++++++++++++++++++ 9 files changed, 3020 insertions(+) create mode 100644 Documentation/devicetree/bindings/mfd/tps65917.txt create mode 100644 Documentation/devicetree/bindings/regulator/tps65917-pmic.txt create mode 100644 drivers/mfd/tps65917.c create mode 100644 drivers/regulator/tps65917-regulator.c create mode 100644 include/linux/mfd/tps65917.h
Signature · 6 lines
1.7.9.5 -- To unsubscribe from this list: send the line "unsubscribe devicetree" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
PATCH v2 1/4 MFD: DT bindings for the TPS65917 family MFD
Add the various binding files for the TPS65917 family of chips. There is a top level MFD binding then a seperate binding for regulators IP blocks on chips.
--- Documentation/devicetree/bindings/mfd/tps65917.txt | 35 ++++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100644 Documentation/devicetree/bindings/mfd/tps65917.txt
Documentation/devicetree/bindings/mfd/tps65917.txt new file +35 -0
@@ -0,0 +1,35 @@ +* TPS65917 device tree bindings + +The TI TPS65917 family of PMICs. + +Required properties: +- compatible : Should be from the list + ti,tps65917 +- interrupt-controller : TPS65917 has its own internal IRQs +- #interrupt-cells : should be set to 2 for IRQ number and flags + The first cell is the IRQ number. + The second cell is the flags, encoded as the trigger masks from + Documentation/devicetree/bindings/interrupts.txt +- interrupt-parent : The parent interrupt controller. + +Optional properties: + ti,mux-padX : set the pad register X (1-2) to the correct muxing for the + hardware, if not set will use muxing in OTP. + +Example: + +tps65917 { + compatible = "ti,tps65917"; + reg = <0x58> + interrupt-parent = <&intc>; + interrupt-controller; + #interrupt-cells = <2>; + + #address-cells = <1>; + #size-cells = <0>; + + pmic { + compatible = "ti,tps65917-pmic"; + .... + }; +}
Signature · 1 line
1.7.9.5
PATCH v2 2/4 regulator: Add TPS65917 Bindings
In reply to KeerthyAdd TPS65917 Regulator Bindings.
--- .../bindings/regulator/tps65917-pmic.txt | 67 ++++++++++++++++++++ 1 file changed, 67 insertions(+) create mode 100644 Documentation/devicetree/bindings/regulator/tps65917-pmic.txt
Documentation/devicetree/bindings/regulator/tps65917-pmic.txt new file +67 -0
@@ -0,0 +1,67 @@ +* tps65917 regulator IP block devicetree bindings + +Required properties: +- compatible : Should be + ti,tps65917-pmic + +- interrupt-parent : The parent interrupt controller which is tps65917. +- interrupts : The interrupt number and the type which can be looked up here: + arch/arm/boot/dts/include/dt-bindings/interrupt-controller/irq.h +- interrupts-name: The names of the individual interrupts. + +Optional nodes: +- regulators : Must contain a sub-node per regulator from the list below. + Each sub-node should contain the constraints and initialization + information for that regulator. See regulator.txt for a + description of standard properties for these sub-nodes. + Additional custom properties are listed below. + + Optional sub-node properties: + ti,warm-reset - maintain voltage during warm reset(boolean) + ti,roof-floor - This takes as optional argument on platform supporting + the rail from desired external control. If there is no argument then + it will be assume that it is controlled by NSLEEP pin. + The valid value for external pins are: + ENABLE1 then 1, + ENABLE2 then 2 or + NSLEEP then 3. + ti,mode-sleep - mode to adopt in pmic sleep 0 - off, 1 - auto, + 2 - eco, 3 - forced pwm + ti,smps-range - OTP has the wrong range set for the hardware so override + 0 - low range, 1 - high range. + +- ti,system-power-controller: Telling whether or not this pmic is controlling + the system power. + +Example: + +#include <dt-bindings/interrupt-controller/irq.h> + +pmic { + compatible = "ti,tps65917-pmic"; + interrupt-parent = <&tps65917>; + interrupts = <14 IRQ_TYPE_NONE>; + interrupts-name = "short-irq"; + + ti,system-power-controller; + + regulators { + smps1_reg : smps1 { + regulator-name = "smps1"; + regulator-min-microvolt = < 600000>; + regulator-max-microvolt = <1500000>; + regulator-always-on; + regulator-boot-on; + ti,warm-reset; + ti,roof-floor = <1>; /* ENABLE1 control */ + ti,mode-sleep = <0>; + ti,smps-range = <1>; + }; + + ldo1_reg: ldo1 { + regulator-name = "ldo1"; + regulator-min-microvolt = <2800000>; + regulator-max-microvolt = <2800000>; + }; + }; +};
Signature · 1 line
1.7.9.5
PATCH v2 3/4 mfd: tps65917: Add driver for the TPS65917 PMIC
In reply to KeerthyThe 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.
---
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 ++++++++++++++++ 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
drivers/mfd/Kconfig +12 -0
@@ -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
drivers/mfd/Makefile +1 -0
@@ -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
drivers/mfd/tps65917.c new file +573 -0
573 lines not on this page · raw message
include/linux/mfd/tps65917.h new file +1509 -0
1,509 lines not on this page · raw message
Signature · 1 line
1.7.9.5
Re: [PATCH v2 3/4] mfd: tps65917: Add driver for the TPS65917 PMIC
Quoted 13 lines
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 <[email protected]>---
Changes in V2:
Quoted 6 lines
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?
Quoted 119 lines
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.hdrivers/mfd/Kconfig +12
-0@@ -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=ydrivers/mfd/Makefile +1
-0@@ -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.odrivers/mfd/tps65917.c new file +73
-0@@ -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 , +};
drivers/mfd/tps65917.c line 83
Quoted 10 lines
drivers/mfd/tps65917.c new file +10
-0+ +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++)
Are you sure? Looks like 10 to me.
Use ARRAY_SIZE(tps65917_voltaile_regs) instead
Quoted 5 lines
drivers/mfd/tps65917.c new file +5
-0+if (reg == tps65917_voltaile_regs[i]) +return true; + +return false; +}
[...]
Quoted 18 lines
drivers/mfd/tps65917.c new file +18
-0+int tps65917_ext_control_req_config (struct tps65917 *tps65917, +enum tps65917_external_requestor_id id, +int ext_ctrl,bool enable) +{ +int preq_mask_bit =0 ; +int reg_add =0 ; +int bit_pos; +int ret; + +if (!(ext_ctrl &TPS65917_EXT_REQ )) +return 0 ; + +if (id >=TPS65917_EXTERNAL_REQSTR_ID_MAX ) +return 0 ; + +if (ext_ctrl &TPS65917_EXT_CONTROL_NSLEEP ) { + reg_add =TPS65917_NSLEEP_RES_ASSIGN ; + preq_mask_bit =0 ;
drivers/mfd/tps65917.c line 282
Quoted 10 lines
drivers/mfd/tps65917.c new file +10
-0+ }else if (ext_ctrl &TPS65917_EXT_CONTROL_ENABLE1 ) { + reg_add =TPS65917_ENABLE1_RES_ASSIGN ; + preq_mask_bit =1 ; + }else if (ext_ctrl &TPS65917_EXT_CONTROL_ENABLE2 ) { + reg_add =TPS65917_ENABLE2_RES_ASSIGN ; + preq_mask_bit =2 ; + } + + bit_pos = sleep_req_info[id].bit_pos; + reg_add += sleep_req_info[id].reg_offset;
New line here.
drivers/mfd/tps65917.c line 288
Quoted 6 lines
drivers/mfd/tps65917.c new file +6
-0+if (enable) + ret =tps65917_update_bits (tps65917,TPS65917_RESOURCE_BASE , + reg_add,BIT (bit_pos),BIT (bit_pos)); +else + ret =tps65917_update_bits (tps65917,TPS65917_RESOURCE_BASE , + reg_add,BIT (bit_pos),0 );
Would prefer:
ret = tps65917_update_bits(tps65917, TPS65917_RESOURCE_BASE,
reg_add, BIT(bit_pos), enable ? BIT(bit_pos) : 0);
Quoted 5 lines
drivers/mfd/tps65917.c new file +5
-0+if (ret <0 ) { +dev_err (tps65917->dev,"Resource reg 0x%02x update failed %d\n" , + reg_add, ret); +return ret; + }
drivers/mfd/tps65917.c line 303
Quoted 10 lines
drivers/mfd/tps65917.c new file +10
-0+ +/* Unmask the PREQ */ + ret =tps65917_update_bits (tps65917,TPS65917_PMU_CONTROL_BASE , +TPS65917_POWER_CTRL ,BIT (preq_mask_bit),0 ); +if (ret <0 ) { +dev_err (tps65917->dev,"POWER_CTRL register update failed %d\n" , + ret); +return ret; + } +return ret;
Just display the error - the function returns 'ret' regardless.
drivers/mfd/tps65917.c line 310
Quoted 7 lines
drivers/mfd/tps65917.c new file +7
-0+} +EXPORT_SYMBOL_GPL (tps65917_ext_control_req_config); + +static int tps65917_set_pdata_irq_flag (struct i2c_client *i2c, +struct tps65917_platform_data *pdata) +{ +struct irq_data *irq_data =irq_get_irq_data (i2c->irq);
New line here.
drivers/mfd/tps65917.c line 317
Quoted 7 lines
drivers/mfd/tps65917.c new file +7
-0+if (!irq_data) { +dev_err (&i2c->dev,"Invalid IRQ: %d\n" , i2c->irq); +return -EINVAL ; + } + + pdata->irq_flags =irqd_get_trigger_type (irq_data); +dev_info (&i2c->dev,"Irq flag is 0x%08x\n" , pdata->irq_flags);
Is this line really required?
New line here.
drivers/mfd/tps65917.c line 324
Quoted 7 lines
drivers/mfd/tps65917.c new file +7
-0+return 0 ; +} + +static void tps65917_dt_to_pdata (struct i2c_client *i2c, +struct tps65917_platform_data *pdata) +{ +struct device_node *node = i2c->dev.of_node;
What kind of node?
Personally, I'd prefer the use of 'np' as a variable name.
drivers/mfd/tps65917.c line 330
Quoted 6 lines
drivers/mfd/tps65917.c new file +6
-0+int ret; +u32 prop; + + ret =of_property_read_u32 (node,"ti,mux-pad1" , &prop); +if (!ret) { + pdata->mux_from_pdata =1 ;
This should be a bool.
drivers/mfd/tps65917.c line 336
Quoted 6 lines
drivers/mfd/tps65917.c new file +6
-0+ pdata->pad1 = prop; + } + + ret =of_property_read_u32 (node,"ti,mux-pad2" , &prop); +if (!ret) { + pdata->mux_from_pdata =1 ;
As above.
drivers/mfd/tps65917.c line 349
Quoted 13 lines
drivers/mfd/tps65917.c new file +13
-0+ pdata->pad2 = prop; + } + +/* The default for this register is all masked */ + ret =of_property_read_u32 (node,"ti,power-ctrl" , &prop); +if (!ret) + pdata->power_ctrl = prop; +else + pdata->power_ctrl =TPS65917_POWER_CTRL_NSLEEP_MASK | +TPS65917_POWER_CTRL_ENABLE1_MASK | +TPS65917_POWER_CTRL_ENABLE2_MASK ; +if (i2c->irq) +tps65917_set_pdata_irq_flag (i2c, pdata);
What's the point of tps65917_set_pdata_irq_flag() providing a return value and then not checking it?
drivers/mfd/tps65917.c line 355
Quoted 5 lines
drivers/mfd/tps65917.c new file +5
-0+ pdata->pm_off =of_property_read_bool (node, +"ti,system-power-controller" ); +} + +static struct tps65917 *tps65917_dev;
This is never used.
drivers/mfd/tps65917.c line 360
Quoted 4 lines
drivers/mfd/tps65917.c new file +4
-0+static const struct of_device_id of_tps65917_match_tbl[] = { + { + .compatible ="ti,tps65917" , + },
This can all sit on one line.
drivers/mfd/tps65917.c line 371
Quoted 11 lines
drivers/mfd/tps65917.c new file +11
-0+ { }, +}; +MODULE_DEVICE_TABLE (of, of_tps65917_match_tbl); + +static int tps65917_i2c_probe (struct i2c_client *i2c, +const struct i2c_device_id *id) +{ +struct tps65917 *tps65917; +struct tps65917_platform_data *pdata; +struct device_node *node = i2c->dev.of_node; +int ret =0 , i;
Break these into separate declarations.
Nit: Put them with the other int declaration(s).
drivers/mfd/tps65917.c line 380
Quoted 9 lines
drivers/mfd/tps65917.c new file +9
-0+unsigned int reg, addr, *features; +int slave; +const struct of_device_id *match; + + pdata =dev_get_platdata (&i2c->dev); + +if (node && !pdata) { + pdata =devm_kzalloc (&i2c->dev,sizeof (*pdata),GFP_KERNEL ); +
Remove this line.
drivers/mfd/tps65917.c line 384
Quoted 4 lines
drivers/mfd/tps65917.c new file +4
-0+if (!pdata) +return -ENOMEM ; + +tps65917_dt_to_pdata (i2c, pdata);
I'm sure we can fail here.
drivers/mfd/tps65917.c line 391
Quoted 7 lines
drivers/mfd/tps65917.c new file +7
-0+ } + +if (!pdata) +return -EINVAL ; + + tps65917 =devm_kzalloc (&i2c->dev,sizeof (struct tps65917 ),GFP_KERNEL ); +if (tps65917 ==NULL )
if (!tps65917)
drivers/mfd/tps65917.c line 394
Quoted 3 lines
drivers/mfd/tps65917.c new file +3
-0+return -ENOMEM ; + +i2c_set_clientdata (i2c, tps65917);
Do this at the end after a clean start-up.
drivers/mfd/tps65917.c line 396
Quoted 2 lines
drivers/mfd/tps65917.c new file +2
-0+ tps65917->dev = &i2c->dev; + tps65917->irq = i2c->irq;
Or just save i2c.
drivers/mfd/tps65917.c line 399
Quoted 2 lines
drivers/mfd/tps65917.c new file +2
-0+ match =of_match_device (of_tps65917_match_tbl, &i2c->dev); +
Remove this line.
drivers/mfd/tps65917.c line 403
Quoted 4 lines
drivers/mfd/tps65917.c new file +4
-0+if (!match) +return -ENODATA ; + + features = (unsigned int *)match->data;
This will be NULL, please remove it.
In fact, why are you even checking for a match?
You only support one device.
Quoted 5 lines
drivers/mfd/tps65917.c new file +5
-0+for (i =0 ; i <TPS65917_NUM_CLIENTS ; i++) { +if (i ==0 ) { + tps65917->i2c_clients[i] = i2c; + }else { + tps65917->i2c_clients[i] =
drivers/mfd/tps65917.c line 419
Quoted 10 lines
drivers/mfd/tps65917.c new file +10
-0+i2c_new_dummy (i2c->adapter, + i2c->addr + i); +if (!tps65917->i2c_clients[i]) { +dev_err (tps65917->dev, +"can't attach client %d\n" , i); + ret = -ENOMEM ; + goto err_i2c; + } + tps65917->i2c_clients[i]->dev.of_node =of_node_get (node); + }
New line here.
Quoted 14 lines
drivers/mfd/tps65917.c new file +14
-0+ tps65917->regmap[i] =devm_regmap_init_i2c (tps65917->i2c_clients[i], + &tps65917_regmap_config[i]); +if (IS_ERR (tps65917->regmap[i])) { + ret =PTR_ERR (tps65917->regmap[i]); +dev_err (tps65917->dev, +"Failed to allocate regmap %d, err: %d\n" , + i, ret); + goto err_i2c; + } + } + +if (!tps65917->irq) { +dev_warn (tps65917->dev,"IRQ missing: skipping irq request\n" ); + goto no_irq;
drivers/mfd/tps65917.c line 443
Quoted 10 lines
drivers/mfd/tps65917.c new file +10
-0+ } + +/* Change interrupt line output polarity */ +if (pdata->irq_flags &IRQ_TYPE_LEVEL_HIGH ) + reg =TPS65917_POLARITY_CTRL_INT_POLARITY ; +else + reg =0 ; + ret =tps65917_update_bits (tps65917,TPS65917_PU_PD_OD_BASE , +TPS65917_POLARITY_CTRL , +TPS65917_POLARITY_CTRL_INT_POLARITY , reg);
Do you need to do this if reg == 0?
Quoted 24 lines
drivers/mfd/tps65917.c new file +24
-0+if (ret <0 ) { +dev_err (tps65917->dev,"POLARITY_CTRL updat failed: %d\n" , ret); + goto err_i2c; + } + +/* Change IRQ into clear on read mode for efficiency */ + slave =TPS65917_BASE_TO_SLAVE (TPS65917_INTERRUPT_BASE ); + addr =TPS65917_BASE_TO_REG (TPS65917_INTERRUPT_BASE ,TPS65917_INT_CTRL ); + reg =TPS65917_INT_CTRL_INT_CLEAR ; + +regmap_write (tps65917->regmap[slave], addr, reg); + + ret =regmap_add_irq_chip (tps65917->regmap[slave], tps65917->irq, +IRQF_ONESHOT | pdata->irq_flags,0 , + &tps65917_irq_chip, + &tps65917->irq_data); +if (ret <0 ) + goto err_i2c; + +no_irq: + slave =TPS65917_BASE_TO_SLAVE (TPS65917_PU_PD_OD_BASE ); + addr =TPS65917_BASE_TO_REG (TPS65917_PU_PD_OD_BASE , +TPS65917_PRIMARY_SECONDARY_PAD1 ); +
drivers/mfd/tps65917.c line 477
Quoted 10 lines
drivers/mfd/tps65917.c new file +10
-0+if (pdata->mux_from_pdata) { + reg = pdata->pad1; + ret =regmap_write (tps65917->regmap[slave], addr, reg); +if (ret) + goto err_irq; + }else { + ret =regmap_read (tps65917->regmap[slave], addr, ®); +if (ret) + goto err_irq; + }
Comment this to let us know what you're trying to do.
drivers/mfd/tps65917.c line 491
Quoted 13 lines
drivers/mfd/tps65917.c new file +13
-0+ addr =TPS65917_BASE_TO_REG (TPS65917_PU_PD_OD_BASE , +TPS65917_PRIMARY_SECONDARY_PAD2 ); + +if (pdata->mux_from_pdata) { + reg = pdata->pad2; + ret =regmap_write (tps65917->regmap[slave], addr, reg); +if (ret) + goto err_irq; + }else { + ret =regmap_read (tps65917->regmap[slave], addr, ®); +if (ret) + goto err_irq; + }
Same here.
drivers/mfd/tps65917.c line 501
Quoted 9 lines
drivers/mfd/tps65917.c new file +9
-0+ reg = pdata->power_ctrl; + + slave =TPS65917_BASE_TO_SLAVE (TPS65917_PMU_CONTROL_BASE ); + addr =TPS65917_BASE_TO_REG (TPS65917_PMU_CONTROL_BASE , +TPS65917_POWER_CTRL ); + + ret =regmap_write (tps65917->regmap[slave], addr, reg); +if (ret) + goto err_irq;
And here.
drivers/mfd/tps65917.c line 505
Quoted 3 lines
drivers/mfd/tps65917.c new file +3
-0+/* +* If we are probing with DT do this the DT way and return here +* otherwise continue and add devices using mfd helpers.
MFD
drivers/mfd/tps65917.c line 508
Quoted 3 lines
drivers/mfd/tps65917.c new file +3
-0+*/ +if (node) { + ret =of_platform_populate (node,NULL ,NULL , &i2c->dev);
What is it you're registering here? I don't see any child devices anywhere.
drivers/mfd/tps65917.c line 511
Quoted 3 lines
drivers/mfd/tps65917.c new file +3
-0+if (ret <0 ) + goto err_irq; +else if (pdata->pm_off && !pm_power_off)
No need for the else.
drivers/mfd/tps65917.c line 512
Quoted 1 line
drivers/mfd/tps65917.c new file +1
-0+ tps65917_dev = tps65917;
What does this do?
drivers/mfd/tps65917.c line 292
Quoted 3 lines
drivers/mfd/tps65917.c new file +3
-0+ } + +return ret;
Where does it continue and add devices using the MFD helpers?
drivers/mfd/tps65917.c line 523
Quoted 7 lines
drivers/mfd/tps65917.c new file +7
-0+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]); + }
New line here.
Quoted 17 lines
drivers/mfd/tps65917.c new file +17
-0+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 ; +}
drivers/mfd/tps65917.c line 550
Quoted 10 lines
drivers/mfd/tps65917.c new file +10
-0+ +static const struct i2c_device_id tps65917_i2c_id[] = { + {"tps65917" , }, +}; +MODULE_DEVICE_TABLE (i2c, tps65917_i2c_id); + +static struct i2c_driver tps65917_i2c_driver = { + .driver = { + .name ="tps65917" , + .of_match_table = of_tps65917_match_tbl,
of_match_ptr()
drivers/mfd/tps65917.c line 562
Quoted 12 lines
drivers/mfd/tps65917.c new file +12
-0+ .owner = THIS_MODULE, + }, + .probe = tps65917_i2c_probe, + .remove = tps65917_i2c_remove, + .id_table = tps65917_i2c_id, +}; + +static int __init tps65917_i2c_init (void ) +{ +return i2c_add_driver (&tps65917_i2c_driver); +} +/* init early so consumer devices can complete system boot */
Defer?
drivers/mfd/tps65917.c line 572
Quoted 10 lines
drivers/mfd/tps65917.c new file +10
-0+subsys_initcall (tps65917_i2c_init); + +static void __exit tps65917_i2c_exit(void) +{ +i2c_del_driver (&tps65917_i2c_driver); +} +module_exit (tps65917_i2c_exit); + +MODULE_AUTHOR ("J Keerthy <[email protected]>" ); +MODULE_DESCRIPTION ("TPS65917 chip family multi-function driver" );
Multi-Function Driver
Quoted 23 lines
drivers/mfd/tps65917.c new file +1
-0+MODULE_LICENSE ("GPL v2" );include/linux/mfd/tps65917.h new file +16
-0@@ -0,0 +1,1509 @@ +/* +* TI TPS65917 +* +* 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. +*/ + +#ifndef __LINUX_MFD_TPS65917_H
include/linux/mfd/tps65917.h line 26
Quoted 10 lines
include/linux/mfd/tps65917.h new file +10
-0+#define __LINUX_MFD_TPS65917_H + +#include <linux/regmap.h> +#include <linux/regulator/driver.h> + +#define TPS65917_NUM_CLIENTS 3 + +/* The ID_REVISION NUMBERS */ +#define TPS65917_CHIP_ID 0xC035 +#define TPS65917_RESERVED -1
Line up with tabs.
include/linux/mfd/tps65917.h line 35
Quoted 8 lines
include/linux/mfd/tps65917.h new file +8
-0+struct tps65917 { +struct device *dev; + +struct i2c_client *i2c_clients[TPS65917_NUM_CLIENTS ]; +struct regmap *regmap[TPS65917_NUM_CLIENTS ]; + +/* Stored chip id */ +int id;
Where is this used?
Quoted 6 lines
include/linux/mfd/tps65917.h new file +6
-0+struct tps65917_pmic *pmic; + +/* IRQ Data */ +int irq; +u32 irq_mask; +/* mutext for irq */
include/linux/mfd/tps65917.h line 52
Quoted 10 lines
include/linux/mfd/tps65917.h new file +10
-0+struct mutex irq_lock; +struct regmap_irq_chip_data *irq_data; +}; + +struct tps65917_reg_init { +/* warm_rest controls the voltage levels after a warm reset +* +* 0: reload default values from OTP on warm reset +* 1: maintain voltage from VSEL on warm reset +*/
Unusual looking comment, please correct.
include/linux/mfd/tps65917.h line 53
Quoted 1 line
include/linux/mfd/tps65917.h new file +1
-0+int warm_reset;
Looks like a bool to me.
include/linux/mfd/tps65917.h line 65
Quoted 11 lines
include/linux/mfd/tps65917.h new file +11
-0+/* roof_floor controls whether the regulator uses the i2c style +* of DVS or uses the method where a GPIO or other control method is +* attached to the NSLEEP/ENABLE1/ENABLE2 pins +* +* For SMPS +* +* 0: i2c selection of voltage +* 1: pin selection of voltage. +* +* For LDO unused +*/
Same here. Top line should not be populated.
include/linux/mfd/tps65917.h line 66
Quoted 1 line
include/linux/mfd/tps65917.h new file +1
-0+int roof_floor;
Only two values is a bool.
Quoted 39 lines
include/linux/mfd/tps65917.h new file +39
-0+/* sleep_mode is the mode loaded to MODE_SLEEP bits as defined in +* the data sheet. +* +* For SMPS +* +* 0: Off +* 1: AUTO +* 2: ECO +* 3: Forced PWM +* +* For LDO +* +* 0: Off +* 1: On +*/ +int mode_sleep; + +/* voltage_sel is the bitfield loaded onto the SMPSX_VOLTAGE +* register. Set this is the default voltage set in OTP needs +* to be overridden. +*/ +u8 vsel; +}; + +enum tps65917_regulators { +/* SMPS regulators */ +TPS65917_REG_SMPS1 , +TPS65917_REG_SMPS2 , +TPS65917_REG_SMPS3 , +TPS65917_REG_SMPS4 , +TPS65917_REG_SMPS5 , +/* LDO regulators */ +TPS65917_REG_LDO1 , +TPS65917_REG_LDO2 , +TPS65917_REG_LDO3 , +TPS65917_REG_LDO4 , +TPS65917_REG_LDO5 , +TPS65917_REG_REGEN1 , +TPS65917_REG_REGEN2 ,
include/linux/mfd/tps65917.h line 116
Quoted 10 lines
include/linux/mfd/tps65917.h new file +10
-0+TPS65917_REG_REGEN3 , + +/* Total number of regulators */ + TPS65917_NUM_REGS, +}; + +struct tps65917_pmic_platform_data { +/* An array of pointers to regulator init data indexed by regulator +* ID +*/
Odd multi-line comments throughout.
Quoted 60 lines
include/linux/mfd/tps65917.h new file +60
-0+struct regulator_init_data *reg_data[TPS65917_NUM_REGS ]; + +/* An array of pointers to structures containing sleep mode and DVS +* configuration for regulators indexed by ID +*/ +struct tps65917_reg_init *reg_init[TPS65917_NUM_REGS ]; +}; + + +struct tps65917_platform_data { +int irq_flags; +int gpio_base; + +/* bit value to be loaded to the POWER_CTRL register */ +u8 power_ctrl; + +/* +* boolean to select if we want to configure muxing here +* then the two value to load into the registers if true +*/ +int mux_from_pdata; +u8 pad1, pad2; +bool pm_off; + +struct tps65917_pmic_platform_data *pmic_pdata; +}; + +/* Define the tps65917 IRQ numbers */ +enum tps65917_irqs { +/* INT1 registers */ +TPS65917_RESERVED1 , +TPS65917_PWRON_IRQ , +TPS65917_LONG_PRESS_KEY_IRQ , +TPS65917_RESERVED2 , +TPS65917_PWRDOWN_IRQ , +TPS65917_HOTDIE_IRQ , +TPS65917_VSYS_MON_IRQ , +TPS65917_RESERVED3 , +/* INT2 registers */ +TPS65917_RESERVED4 , +TPS65917_OTP_ERROR_IRQ , +TPS65917_WDT_IRQ , +TPS65917_RESERVED5 , +TPS65917_RESET_IN_IRQ , +TPS65917_FSD_IRQ , +TPS65917_SHORT_IRQ , +TPS65917_RESERVED6 , +/* INT3 registers */ +TPS65917_GPADC_AUTO_0_IRQ , +TPS65917_GPADC_AUTO_1_IRQ , +TPS65917_GPADC_EOC_SW_IRQ , +TPS65917_RESREVED6 , +TPS65917_RESERVED7 , +TPS65917_RESERVED8 , +TPS65917_RESERVED9 , +TPS65917_VBUS_IRQ , +/* INT4 registers */ +TPS65917_GPIO_0_IRQ , +TPS65917_GPIO_1_IRQ , +TPS65917_GPIO_2_IRQ ,
include/linux/mfd/tps65917.h line 186
Quoted 10 lines
include/linux/mfd/tps65917.h new file +10
-0+TPS65917_GPIO_3_IRQ , +TPS65917_GPIO_4_IRQ , +TPS65917_GPIO_5_IRQ , +TPS65917_GPIO_6_IRQ , +TPS65917_RESERVED10 , +/* Total Number IRQs */ + TPS65917_NUM_IRQ, +}; + +/* External controll signal name */
Spelling.
Quoted 92 lines
include/linux/mfd/tps65917.h new file +92
-0+enum { +TPS65917_EXT_CONTROL_ENABLE1 =0x1 , +TPS65917_EXT_CONTROL_ENABLE2 =0x2 , +TPS65917_EXT_CONTROL_NSLEEP =0x4 , +}; + +/* +* TPS65917 device resources can be controlled externally for +* enabling/disabling it rather than register write through i2c. +* Add the external controlled requestor ID for different resources. +*/ +enum tps65917_external_requestor_id { +TPS65917_EXTERNAL_REQSTR_ID_REGEN1 , +TPS65917_EXTERNAL_REQSTR_ID_REGEN2 , +TPS65917_EXTERNAL_REQSTR_ID_REGEN3 , +TPS65917_EXTERNAL_REQSTR_ID_SMPS1 , +TPS65917_EXTERNAL_REQSTR_ID_SMPS2 , +TPS65917_EXTERNAL_REQSTR_ID_SMPS3 , +TPS65917_EXTERNAL_REQSTR_ID_SMPS4 , +TPS65917_EXTERNAL_REQSTR_ID_SMPS5 , +TPS65917_EXTERNAL_REQSTR_ID_LDO1 , +TPS65917_EXTERNAL_REQSTR_ID_LDO2 , +TPS65917_EXTERNAL_REQSTR_ID_LDO3 , +TPS65917_EXTERNAL_REQSTR_ID_LDO4 , +TPS65917_EXTERNAL_REQSTR_ID_LDO5 , +/* Last entry */ +TPS65917_EXTERNAL_REQSTR_ID_MAX , +}; + +struct tps65917_pmic { +struct tps65917 *tps65917; +struct device *dev; +struct regulator_desc desc[TPS65917_NUM_REGS ]; +struct regulator_dev *rdev[TPS65917_NUM_REGS ]; +/* pmic mutex */ +struct mutex mutex; +int smps12; +int range[TPS65917_REG_SMPS5 ]; +unsigned int ramp_delay[TPS65917_REG_SMPS5 ]; +unsigned int current_reg_mode[TPS65917_REG_SMPS5 ]; +}; + +/* helper macro to get correct slave number */ +#define TPS65917_BASE_TO_SLAVE (x) ((x >> 8) - 1) +#define TPS65917_BASE_TO_REG (x, y) ((x & 0xff) + y) + +/* Base addresses of IP blocks in TPS65917 */ +#define TPS65917_SMPS_DVS_BASE 0x20 +#define TPS65917_VALIDITY_BASE 0x118 +#define TPS65917_SMPS_BASE 0x120 +#define TPS65917_LDO_BASE 0x150 +#define TPS65917_DVFS_BASE 0x180 +#define TPS65917_PMU_CONTROL_BASE 0x1A0 +#define TPS65917_RESOURCE_BASE 0x1D4 +#define TPS65917_PU_PD_OD_BASE 0x1F0 +#define TPS65917_LED_BASE 0x200 +#define TPS65917_INTERRUPT_BASE 0x210 +#define TPS65917_GPIO_BASE 0x280 +#define TPS65917_GPADC_BASE 0x2C0 +#define TPS65917_TRIM_GPADC_BASE 0x3CD + +/* Registers for function BACKUP */ +#define TPS65917_BACKUP0 0x0 +#define TPS65917_BACKUP1 0x1 +#define TPS65917_BACKUP2 0x2 +#define TPS65917_BACKUP3 0x3 +#define TPS65917_BACKUP4 0x4 +#define TPS65917_BACKUP5 0x5 +#define TPS65917_BACKUP6 0x6 +#define TPS65917_BACKUP7 0x7 + +/* Bit definitions for BACKUP0 */ +#define TPS65917_BACKUP0_BACKUP_MASK 0xff +#define TPS65917_BACKUP0_BACKUP_SHIFT 0 + +/* Bit definitions for BACKUP1 */ +#define TPS65917_BACKUP1_BACKUP_MASK 0xff +#define TPS65917_BACKUP1_BACKUP_SHIFT 0 + +/* Bit definitions for BACKUP2 */ +#define TPS65917_BACKUP2_BACKUP_MASK 0xff +#define TPS65917_BACKUP2_BACKUP_SHIFT 0 + +/* Bit definitions for BACKUP3 */ +#define TPS65917_BACKUP3_BACKUP_MASK 0xff +#define TPS65917_BACKUP3_BACKUP_SHIFT 0 + +/* Bit definitions for BACKUP4 */ +#define TPS65917_BACKUP4_BACKUP_MASK 0xff +#define TPS65917_BACKUP4_BACKUP_SHIFT 0 + +/* Bit definitions for BACKUP5 */
include/linux/mfd/tps65917.h line 288
Quoted 10 lines
include/linux/mfd/tps65917.h new file +10
-0+#define TPS65917_BACKUP5_BACKUP_MASK 0xff +#define TPS65917_BACKUP5_BACKUP_SHIFT 0 + +/* Bit definitions for BACKUP6 */ +#define TPS65917_BACKUP6_BACKUP_MASK 0xff +#define TPS65917_BACKUP6_BACKUP_SHIFT 0 + +/* Bit definitions for BACKUP7 */ +#define TPS65917_BACKUP7_BACKUP_MASK 0xff +#define TPS65917_BACKUP7_BACKUP_SHIFT 0
If they do not differ, remove the number and consolidate:
/* Bit definitions for BACKUP{0-7} */
#define TPS65917_BACKUP_BACKUP_MASK 0xff
#define TPS65917_BACKUP_BACKUP_SHIFT 0
Quoted 24 lines
include/linux/mfd/tps65917.h new file +24
-0+/* Registers for function SMPS */ +#define TPS65917_SMPS1_CTRL 0x0 +#define TPS65917_SMPS1_FORCE 0x2 +#define TPS65917_SMPS1_VOLTAGE 0x3 +#define TPS65917_SMPS2_CTRL 0x4 +#define TPS65917_SMPS2_FORCE 0x6 +#define TPS65917_SMPS2_VOLTAGE 0x7 +#define TPS65917_SMPS3_CTRL 0xC +#define TPS65917_SMPS3_FORCE 0xE +#define TPS65917_SMPS3_VOLTAGE 0xF +#define TPS65917_SMPS4_CTRL 0x10 +#define TPS65917_SMPS4_VOLTAGE 0x13 +#define TPS65917_SMPS5_CTRL 0x18 +#define TPS65917_SMPS5_VOLTAGE 0x1B +#define TPS65917_SMPS_CTRL 0x24 +#define TPS65917_SMPS_PD_CTRL 0x25 +#define TPS65917_SMPS_THERMAL_EN 0x27 +#define TPS65917_SMPS_THERMAL_STATUS 0x28 +#define TPS65917_SMPS_SHORT_STATUS 0x29 +#define TPS65917_SMPS_NEGATIVE_CURRENT_LIMIT_EN 0x2A +#define TPS65917_SMPS_POWERGOOD_MASK1 0x2B +#define TPS65917_SMPS_POWERGOOD_MASK2 0x2C + +/* Bit definitions for SMPS1_CTRL */
include/linux/mfd/tps65917.h line 323
Quoted 10 lines
include/linux/mfd/tps65917.h new file +10
-0+#define TPS65917_SMPS1_CTRL_WR_S 0x80 +#define TPS65917_SMPS1_CTRL_WR_S_SHIFT 7 +#define TPS65917_SMPS1_CTRL_ROOF_FLOOR_EN 0x40 +#define TPS65917_SMPS1_CTRL_ROOF_FLOOR_EN_SHIFT 6 +#define TPS65917_SMPS1_CTRL_STATUS_MASK 0x30 +#define TPS65917_SMPS1_CTRL_STATUS_SHIFT 4 +#define TPS65917_SMPS1_CTRL_MODE_SLEEP_MASK 0x0c +#define TPS65917_SMPS1_CTRL_MODE_SLEEP_SHIFT 2 +#define TPS65917_SMPS1_CTRL_MODE_ACTIVE_MASK 0x03 +#define TPS65917_SMPS1_CTRL_MODE_ACTIVE_SHIFT 0
Pick a base and stick with it. I suggest hex throughout.
[...]
include/linux/mfd/tps65917.h line 504
Quoted 8 lines
include/linux/mfd/tps65917.h new file +8
-0+/* Bit definitions for SMPS_PLL_CTRL */ + +#define TPS65917_SMPS_PLL_CTRL_PLL_EN_PLL_BYPASS_SHIFT 0x8 +#define TPS65917_SMPS_PLL_CTRL_PLL_PLL_EN_BYPASS 3 +#define TPS65917_SMPS_PLL_CTRL_PLL_PLL_BYPASS_CLK_SHIFT 0x4 +#define TPS65917_SMPS_PLL_CTRL_PLL_PLL_BYPASS_CLK 2 + +
Remove this line.
include/linux/mfd/tps65917.h line 513
Quoted 9 lines
include/linux/mfd/tps65917.h new file +9
-0+/* Registers for function LDO */ +#define TPS65917_LDO1_CTRL 0x0 +#define TPS65917_LDO1_VOLTAGE 0x1 +#define TPS65917_LDO2_CTRL 0x2 +#define TPS65917_LDO2_VOLTAGE 0x3 +#define TPS65917_LDO3_CTRL 0x4 +#define TPS65917_LDO3_VOLTAGE 0x5 +#define TPS65917_LDO4_CTRL 0xE +#define TPS65917_LDO4_VOLTAGE 0xF
Also standardise the number of digits represented and either capitalise none or all of the hex letters.
[...]
include/linux/mfd/tps65917.h line 1451
Quoted 4 lines
include/linux/mfd/tps65917.h new file +4
-0+static inline int tps65917_read (struct tps65917 *tps65917,unsigned int base, +unsigned int reg,unsigned int *val) +{ +unsigned int addr =TPS65917_BASE_TO_REG (base, reg);
Extra ' '.
Quoted 42 lines
include/linux/mfd/tps65917.h new file +42
-0+int slave_id =TPS65917_BASE_TO_SLAVE (base); + +return regmap_read (tps65917->regmap[slave_id], addr, val); +} + +static inline int tps65917_write (struct tps65917 *tps65917,unsigned int base, +unsigned int reg,unsigned int value) +{ +unsigned int addr =TPS65917_BASE_TO_REG (base, reg); +int slave_id =TPS65917_BASE_TO_SLAVE (base); + +return regmap_write (tps65917->regmap[slave_id], addr, value); +} + +static inline int tps65917_bulk_write (struct tps65917 *tps65917, +unsigned int base, +unsigned int reg,const void *val, +size_t val_count) +{ +unsigned int addr =TPS65917_BASE_TO_REG (base, reg); +int slave_id =TPS65917_BASE_TO_SLAVE (base); + +return regmap_bulk_write (tps65917->regmap[slave_id], addr, + val, val_count); +} + +static inline int tps65917_bulk_read (struct tps65917 *tps65917, +unsigned int base, +unsigned int reg,void *val, +size_t val_count) +{ +unsigned int addr =TPS65917_BASE_TO_REG (base, reg); +int slave_id =TPS65917_BASE_TO_SLAVE (base); + +return regmap_bulk_read (tps65917->regmap[slave_id], addr, + val, val_count); +} + +static inline int tps65917_update_bits (struct tps65917 *tps65917, +unsigned int base,unsigned int reg, +unsigned int mask,unsigned int val) +{
include/linux/mfd/tps65917.h line 1503
Quoted 10 lines
include/linux/mfd/tps65917.h new file +10
-0+unsigned int addr =TPS65917_BASE_TO_REG (base, reg); +int slave_id =TPS65917_BASE_TO_SLAVE (base); + +return regmap_update_bits (tps65917->regmap[slave_id], addr, mask, val); +} + +static inline int tps65917_irq_get_virq (struct tps65917 *tps65917,int irq) +{ +return regmap_irq_get_virq (tps65917->irq_data, irq); +}
This is quite a lot of overhead. Are you sure you require them?
Quoted 5 lines
include/linux/mfd/tps65917.h new file +5
-0+int tps65917_ext_control_req_config (struct tps65917 *tps65917, +enum tps65917_external_requestor_id ext_control_req_id, +int ext_ctrl,bool enable); + +#endif /* __LINUX_MFD_TPS65917_H */
Signature · 4 lines
Lee Jones Linaro STMicroelectronics Landing Team Lead Linaro.org │ Open source software for ARM SoCs Follow Linaro: Facebook | Twitter | Blog
Re: [PATCH v2 3/4] mfd: tps65917: Add driver for the TPS65917 PMIC
Hi Lee Jones,
Thanks for the review.
Quoted 13 lines · Lee Jones
Quoted 13 lines
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 <[email protected]>---
Changes in V2:
Quoted 8 lines
Quoted 6 lines
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.
Quoted 132 lines
Quoted 120 lines
include/linux/mfd/tps65917.h | 1509 ++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 2095 insertions(+)create mode 100644
drivers/mfd/tps65917.c
create mode 100644include/linux/mfd/tps65917.hdrivers/mfd/Kconfig +12
-0@@ -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=ydrivers/mfd/Makefile +1
-0@@ -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.odrivers/mfd/tps65917.c new file +73
-0@@ -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 , +};drivers/mfd/tps65917.c line 83
Quoted 10 lines
drivers/mfd/tps65917.c new file +10
-0+ +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++)Are you sure? Looks like 10 to me.
Quoted 1 line
Use
ARRAY_SIZE(tps65917_voltaile_regs)instead
I will use
ARRAY_SIZE(tps65917_voltaile_regs)
.
Quoted 29 lines
Quoted 6 lines
drivers/mfd/tps65917.c new file +5
-0+if (reg == tps65917_voltaile_regs[i]) +return true; + +return false; +}[...]
Quoted 21 lines
drivers/mfd/tps65917.c new file +21
-0+int tps65917_ext_control_req_config (struct tps65917 *tps65917, +enum tps65917_external_requestor_id id, +int ext_ctrl,bool enable) +{ +int preq_mask_bit =0 ; +int reg_add =0 ; +int bit_pos; +int ret; + +if (!(ext_ctrl &TPS65917_EXT_REQ )) +return 0 ; + +if (id >=TPS65917_EXTERNAL_REQSTR_ID_MAX ) +return 0 ; + +if (ext_ctrl &TPS65917_EXT_CONTROL_NSLEEP ) { + reg_add =TPS65917_NSLEEP_RES_ASSIGN ; + preq_mask_bit =0 ; + }else if (ext_ctrl &TPS65917_EXT_CONTROL_ENABLE1 ) { + reg_add =TPS65917_ENABLE1_RES_ASSIGN ; + preq_mask_bit =1 ;
Quoted 8 lines
drivers/mfd/tps65917.c line 282
Quoted 7 lines
drivers/mfd/tps65917.c new file +7
-0+ }else if (ext_ctrl &TPS65917_EXT_CONTROL_ENABLE2 ) { + reg_add =TPS65917_ENABLE2_RES_ASSIGN ; + preq_mask_bit =2 ; + } + + bit_pos = sleep_req_info[id].bit_pos; + reg_add += sleep_req_info[id].reg_offset;New line here.
Ok.
Quoted 11 lines
drivers/mfd/tps65917.c line 288
Quoted 6 lines
drivers/mfd/tps65917.c new file +6
-0+if (enable) + ret =tps65917_update_bits (tps65917,TPS65917_RESOURCE_BASE , + reg_add,BIT (bit_pos),BIT (bit_pos)); +else + ret =tps65917_update_bits (tps65917,TPS65917_RESOURCE_BASE , + reg_add,BIT (bit_pos),0 );Would prefer:
ret = tps65917_update_bits(tps65917,
TPS65917_RESOURCE_BASE,reg_add, BIT(bit_pos), enable ? BIT(bit_pos) : 0);
Ok. I will do it this way.
Quoted 8 lines
Quoted 8 lines
drivers/mfd/tps65917.c new file +8
-0+if (ret <0 ) { +dev_err (tps65917->dev,"Resource reg 0x%02x update failed %d\n" , + reg_add, ret); +return ret; + } + +/* Unmask the PREQ */ + ret = tps65917_update_bits(tps65917, TPS65917_PMU_CONTROL_BASE,
Quoted 8 lines
drivers/mfd/tps65917.c line 303
Quoted 7 lines
drivers/mfd/tps65917.c new file +7
-0+ TPS65917_POWER_CTRL, BIT(preq_mask_bit), 0); +if (ret <0 ) { +dev_err (tps65917->dev,"POWER_CTRL register update failed %d\n" , + ret); +return ret; + } +return ret;Just display the error - the function returns 'ret' regardless.
Ok.
Quoted 9 lines
drivers/mfd/tps65917.c line 310
Quoted 8 lines
drivers/mfd/tps65917.c new file +7
-0+} +EXPORT_SYMBOL_GPL (tps65917_ext_control_req_config); + +static int tps65917_set_pdata_irq_flag (struct i2c_client *i2c, +struct tps65917_platform_data *pdata) +{ +struct irq_data *irq_data =irq_get_irq_data (i2c->irq);New line here.
Ok
Quoted 11 lines
drivers/mfd/tps65917.c line 317
Quoted 8 lines
drivers/mfd/tps65917.c new file +7
-0+if (!irq_data) { +dev_err (&i2c->dev,"Invalid IRQ: %d\n" , i2c->irq); +return -EINVAL ; + } + + pdata->irq_flags =irqd_get_trigger_type (irq_data); +dev_info (&i2c->dev,"Irq flag is 0x%08x\n" , pdata->irq_flags);Is this line really required?
New line here.
Yeah this is more dev_dbg. I will make it dev_dbg message.
Quoted 10 lines
drivers/mfd/tps65917.c line 324
Quoted 7 lines
drivers/mfd/tps65917.c new file +7
-0+return 0 ; +} + +static void tps65917_dt_to_pdata (struct i2c_client *i2c, +struct tps65917_platform_data *pdata) +{ +struct device_node *node = i2c->dev.of_node;What kind of node?
Personally, I'd prefer the use of 'np' as a variable name.
Ok.
Quoted 8 lines
drivers/mfd/tps65917.c line 330
Quoted 6 lines
drivers/mfd/tps65917.c new file +6
-0+int ret; +u32 prop; + + ret =of_property_read_u32 (node,"ti,mux-pad1" , &prop); +if (!ret) { + pdata->mux_from_pdata =1 ;This should be a bool.
Quoted 7 lines
drivers/mfd/tps65917.c line 336
Quoted 6 lines
drivers/mfd/tps65917.c new file +6
-0+ pdata->pad1 = prop; + } + + ret =of_property_read_u32 (node,"ti,mux-pad2" , &prop); +if (!ret) { + pdata->mux_from_pdata =1 ;As above.
Ok.
Quoted 16 lines
Quoted 4 lines
drivers/mfd/tps65917.c new file +3
-0+ pdata->pad2 = prop; + } +drivers/mfd/tps65917.c line 349
Quoted 10 lines
drivers/mfd/tps65917.c new file +10
-0+/* The default for this register is all masked */ n + ret =of_property_read_u32 (node,"ti,power-ctrl" , &prop); +if (!ret) + pdata->power_ctrl = prop; +else + pdata->power_ctrl =TPS65917_POWER_CTRL_NSLEEP_MASK | +TPS65917_POWER_CTRL_ENABLE1_MASK | +TPS65917_POWER_CTRL_ENABLE2_MASK ; +if (i2c->irq) +tps65917_set_pdata_irq_flag (i2c, pdata);What's the point of
tps65917_set_pdata_irq_flag()providing a return value and then not checking it?
Yes. I will remove this check. Largely borrowed from Palmas driver.
Quoted 8 lines
drivers/mfd/tps65917.c line 355
Quoted 6 lines
drivers/mfd/tps65917.c new file +5
-0+ pdata->pm_off =of_property_read_bool (node, +"ti,system-power-controller" ); +} + +static struct tps65917 *tps65917_dev;This is never used.
Quoted 5 lines
drivers/mfd/tps65917.c line 360
Quoted 4 lines
drivers/mfd/tps65917.c new file +4
-0+static const struct of_device_id of_tps65917_match_tbl[] = { + { + .compatible ="ti,tps65917" , + },This can all sit on one line.
Ok.
Quoted 14 lines
drivers/mfd/tps65917.c line 371
Quoted 12 lines
drivers/mfd/tps65917.c new file +11
-0+ { }, +}; +MODULE_DEVICE_TABLE (of, of_tps65917_match_tbl); + +static int tps65917_i2c_probe (struct i2c_client *i2c, +const struct i2c_device_id *id) +{ +struct tps65917 *tps65917; +struct tps65917_platform_data *pdata; +struct device_node *node = i2c->dev.of_node; +int ret =0 , i;Break these into separate declarations.
Quoted 1 line
Nit: Put them with the other int declaration(s).
Ok.
Quoted 11 lines
drivers/mfd/tps65917.c line 380
Quoted 10 lines
drivers/mfd/tps65917.c new file +9
-0+unsigned int reg, addr, *features; +int slave; +const struct of_device_id *match; + + pdata =dev_get_platdata (&i2c->dev); + +if (node && !pdata) { + pdata =devm_kzalloc (&i2c->dev,sizeof (*pdata),GFP_KERNEL ); +Remove this line.
Ok.
Quoted 5 lines
drivers/mfd/tps65917.c line 384
Quoted 4 lines
drivers/mfd/tps65917.c new file +4
-0+if (!pdata) +return -ENOMEM ; + +tps65917_dt_to_pdata (i2c, pdata);I'm sure we can fail here.
They are optional properties. Hence no check.
Quoted 9 lines
drivers/mfd/tps65917.c line 391
Quoted 8 lines
drivers/mfd/tps65917.c new file +7
-0+ } + +if (!pdata) +return -EINVAL ; + + tps65917 =devm_kzalloc (&i2c->dev,sizeof (struct tps65917 ),GFP_KERNEL ); +if (tps65917 ==NULL )if (!tps65917)
Ok
Quoted 6 lines
drivers/mfd/tps65917.c line 394
Quoted 4 lines
drivers/mfd/tps65917.c new file +3
-0+return -ENOMEM ; + +i2c_set_clientdata (i2c, tps65917);Do this at the end after a clean start-up.
Quoted 7 lines
drivers/mfd/tps65917.c line 396
Quoted 2 lines
drivers/mfd/tps65917.c new file +2
-0+ tps65917->dev = &i2c->dev; + tps65917->irq = i2c->irq;Or just save i2c.
drivers/mfd/tps65917.c line 399
Quoted 2 lines
drivers/mfd/tps65917.c new file +2
-0+ match =of_match_device (of_tps65917_match_tbl, &i2c->dev); +Remove this line.
Ok
Quoted 9 lines
drivers/mfd/tps65917.c line 403
Quoted 4 lines
drivers/mfd/tps65917.c new file +4
-0+if (!match) +return -ENODATA ; + + features = (unsigned int *)match->data;This will be NULL, please remove it.
In fact, why are you even checking for a match?
You only support one device.
Ok. Yes agreed.
Quoted 17 lines
Quoted 6 lines
drivers/mfd/tps65917.c new file +5
-0+for (i =0 ; i <TPS65917_NUM_CLIENTS ; i++) { +if (i ==0 ) { + tps65917->i2c_clients[i] = i2c; + }else { + tps65917->i2c_clients[i] =drivers/mfd/tps65917.c line 419
Quoted 10 lines
drivers/mfd/tps65917.c new file +10
-0+i2c_new_dummy (i2c->adapter, + i2c->addr + i); +if (!tps65917->i2c_clients[i]) { +dev_err (tps65917->dev, +"can't attach client %d\n" , i); + ret = -ENOMEM ; + goto err_i2c; + } + tps65917->i2c_clients[i]->dev.of_node =of_node_get (node); + }New line here.
Ok.
Quoted 17 lines
Quoted 17 lines
drivers/mfd/tps65917.c new file +17
-0+ tps65917->regmap[i] =devm_regmap_init_i2c (tps65917->i2c_clients[i], + &tps65917_regmap_config[i]); +if (IS_ERR (tps65917->regmap[i])) { + ret =PTR_ERR (tps65917->regmap[i]); +dev_err (tps65917->dev, +"Failed to allocate regmap %d, err: %d\n" , + i, ret); + goto err_i2c; + } + } + +if (!tps65917->irq) { +dev_warn (tps65917->dev,"IRQ missing: skipping irq request\n" ); + goto no_irq; + } + +/* Change interrupt line output polarity */
Quoted 8 lines
drivers/mfd/tps65917.c line 443
Quoted 7 lines
drivers/mfd/tps65917.c new file +7
-0+if (pdata->irq_flags &IRQ_TYPE_LEVEL_HIGH ) + reg =TPS65917_POLARITY_CTRL_INT_POLARITY ; +else + reg =0 ; + ret =tps65917_update_bits (tps65917,TPS65917_PU_PD_OD_BASE , +TPS65917_POLARITY_CTRL , +TPS65917_POLARITY_CTRL_INT_POLARITY , reg);Do you need to do this if reg == 0?
No. This can go under if.
Quoted 28 lines
Quoted 28 lines
drivers/mfd/tps65917.c new file +27
-0+if (ret <0 ) { +dev_err (tps65917->dev,"POLARITY_CTRL updat failed: %d\n" , ret); + goto err_i2c; + } + +/* Change IRQ into clear on read mode for efficiency */ + slave =TPS65917_BASE_TO_SLAVE (TPS65917_INTERRUPT_BASE ); + addr =TPS65917_BASE_TO_REG (TPS65917_INTERRUPT_BASE ,TPS65917_INT_CTRL ); + reg =TPS65917_INT_CTRL_INT_CLEAR ; + +regmap_write (tps65917->regmap[slave], addr, reg); + + ret =regmap_add_irq_chip (tps65917->regmap[slave], tps65917->irq, +IRQF_ONESHOT | pdata->irq_flags,0 , + &tps65917_irq_chip, + &tps65917->irq_data); +if (ret <0 ) + goto err_i2c; + +no_irq: + slave =TPS65917_BASE_TO_SLAVE (TPS65917_PU_PD_OD_BASE ); + addr =TPS65917_BASE_TO_REG (TPS65917_PU_PD_OD_BASE , +TPS65917_PRIMARY_SECONDARY_PAD1 ); + +if (pdata->mux_from_pdata) { + reg = pdata->pad1; + ret =regmap_write (tps65917->regmap[slave], addr, reg);
Quoted 8 lines
drivers/mfd/tps65917.c line 477
Quoted 7 lines
drivers/mfd/tps65917.c new file +7
-0+if (ret) + goto err_irq; + }else { + ret =regmap_read (tps65917->regmap[slave], addr, ®); +if (ret) + goto err_irq; + }Comment this to let us know what you're trying to do.
Ok.
Quoted 6 lines
Quoted 6 lines
drivers/mfd/tps65917.c new file +6
-0+ addr =TPS65917_BASE_TO_REG (TPS65917_PU_PD_OD_BASE , +TPS65917_PRIMARY_SECONDARY_PAD2 ); + +if (pdata->mux_from_pdata) { + reg = pdata->pad2; + ret =regmap_write (tps65917->regmap[slave], addr, reg);
Quoted 8 lines
drivers/mfd/tps65917.c line 477
Quoted 7 lines
drivers/mfd/tps65917.c new file +7
-0+if (ret) + goto err_irq; + }else { + ret =regmap_read (tps65917->regmap[slave], addr, ®); +if (ret) + goto err_irq; + }Same here.
Ok.
Quoted 11 lines
drivers/mfd/tps65917.c line 501
Quoted 9 lines
drivers/mfd/tps65917.c new file +9
-0+ reg = pdata->power_ctrl; + + slave =TPS65917_BASE_TO_SLAVE (TPS65917_PMU_CONTROL_BASE ); + addr =TPS65917_BASE_TO_REG (TPS65917_PMU_CONTROL_BASE , +TPS65917_POWER_CTRL ); + + ret =regmap_write (tps65917->regmap[slave], addr, reg); +if (ret) + goto err_irq;And here.
Quoted 4 lines
drivers/mfd/tps65917.c line 505
Quoted 3 lines
drivers/mfd/tps65917.c new file +3
-0+/* +* If we are probing with DT do this the DT way and return here +* otherwise continue and add devices using mfd helpers. MFD
Ok
Quoted 11 lines
drivers/mfd/tps65917.c line 508
Quoted 4 lines
drivers/mfd/tps65917.c new file +3
-0+*/ +if (node) { + ret =of_platform_populate (node,NULL ,NULL , &i2c->dev);What is it you're registering here? I don't see any child devices anywhere.
drivers/mfd/tps65917.c line 511
Quoted 3 lines
drivers/mfd/tps65917.c new file +3
-0+if (ret <0 ) + goto err_irq; +else if (pdata->pm_off && !pm_power_off)No need for the else.
Ok
Quoted 8 lines
drivers/mfd/tps65917.c line 512
Quoted 2 lines
drivers/mfd/tps65917.c new file +1
-0+ tps65917_dev = tps65917;What does this do?
drivers/mfd/tps65917.c line 292
Quoted 3 lines
drivers/mfd/tps65917.c new file +3
-0+ } + +return ret;Where does it continue and add devices using the MFD helpers?
I will remove this part.
Quoted 9 lines
drivers/mfd/tps65917.c line 523
Quoted 8 lines
drivers/mfd/tps65917.c new file +7
-0+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]); + }New line here.
Ok.
Quoted 21 lines
Quoted 21 lines
drivers/mfd/tps65917.c new file +20
-0+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 i2c_device_id tps65917_i2c_id[] = { + {"tps65917" , },
Quoted 8 lines
drivers/mfd/tps65917.c line 550
Quoted 7 lines
drivers/mfd/tps65917.c new file +7
-0+}; +MODULE_DEVICE_TABLE (i2c, tps65917_i2c_id); + +static struct i2c_driver tps65917_i2c_driver = { + .driver = { + .name ="tps65917" , + .of_match_table = of_tps65917_match_tbl,
of_match_ptr()
Ok
Quoted 15 lines
drivers/mfd/tps65917.c line 562
Quoted 13 lines
drivers/mfd/tps65917.c new file +12
-0+ .owner = THIS_MODULE, + }, + .probe = tps65917_i2c_probe, + .remove = tps65917_i2c_remove, + .id_table = tps65917_i2c_id, +}; + +static int __init tps65917_i2c_init (void ) +{ +return i2c_add_driver (&tps65917_i2c_driver); +} +/* init early so consumer devices can complete system boot */ Defer?
Quoted 12 lines
drivers/mfd/tps65917.c line 572
Quoted 10 lines
drivers/mfd/tps65917.c new file +10
-0+subsys_initcall (tps65917_i2c_init); + +static void __exit tps65917_i2c_exit(void) +{ +i2c_del_driver (&tps65917_i2c_driver); +} +module_exit (tps65917_i2c_exit); + +MODULE_AUTHOR ("J Keerthy <[email protected]>" ); +MODULE_DESCRIPTION ("TPS65917 chip family multi-function driver" );Multi-Function Driver
ok
Quoted 26 lines
Quoted 26 lines
drivers/mfd/tps65917.c new file +1
-0+MODULE_LICENSE ("GPL v2" );include/linux/mfd/tps65917.h new file +19
-0@@ -0,0 +1,1509 @@ +/* +* TI TPS65917 +* +* 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. +*/ + +#ifndef __LINUX_MFD_TPS65917_H +#define __LINUX_MFD_TPS65917_H + +#include <linux/regmap.h>
Quoted 8 lines
include/linux/mfd/tps65917.h line 26
Quoted 7 lines
include/linux/mfd/tps65917.h new file +7
-0+#include <linux/regulator/driver.h> + +#define TPS65917_NUM_CLIENTS 3 + +/* The ID_REVISION NUMBERS */ +#define TPS65917_CHIP_ID 0xC035 +#define TPS65917_RESERVED -1Line up with tabs.
Ok
Quoted 9 lines
include/linux/mfd/tps65917.h line 35
Quoted 8 lines
include/linux/mfd/tps65917.h new file +8
-0+struct tps65917 { +struct device *dev; + +struct i2c_client *i2c_clients[TPS65917_NUM_CLIENTS ]; +struct regmap *regmap[TPS65917_NUM_CLIENTS ]; + +/* Stored chip id */ +int id;Where is this used?
for this driver this seems redundant. I will remove this.
Quoted 18 lines
Quoted 6 lines
include/linux/mfd/tps65917.h new file +6
-0+struct tps65917_pmic *pmic; + +/* IRQ Data */ +int irq; +u32 irq_mask; +/* mutext for irq */ include/linux/mfd/tps65917.h line 52
Quoted 10 lines
include/linux/mfd/tps65917.h new file +10
-0+struct mutex irq_lock; +struct regmap_irq_chip_data *irq_data; +}; + +struct tps65917_reg_init { +/* warm_rest controls the voltage levels after a warm reset +* +* 0: reload default values from OTP on warm reset +* 1: maintain voltage from VSEL on warm reset +*/ Unusual looking comment, please correct.
Quoted 2 lines
include/linux/mfd/tps65917.h line 53
Quoted 1 line
include/linux/mfd/tps65917.h new file +1
-0+int warm_reset;Looks like a bool to me.
I will change it to bool
Quoted 4 lines
Quoted 4 lines
include/linux/mfd/tps65917.h new file +4
-0+/* roof_floor controls whether the regulator uses the i2c style +* of DVS or uses the method where a GPIO or other control method is +* attached to the NSLEEP/ENABLE1/ENABLE2 pins +*
Quoted 8 lines
include/linux/mfd/tps65917.h line 65
Quoted 7 lines
include/linux/mfd/tps65917.h new file +7
-0+* For SMPS +* +* 0: i2c selection of voltage +* 1: pin selection of voltage. +* +* For LDO unused +*/ Same here. Top line should not be populated.
Ok
Quoted 2 lines
include/linux/mfd/tps65917.h line 66
Quoted 1 line
include/linux/mfd/tps65917.h new file +1
-0+int roof_floor;Only two values is a bool.
ok
Quoted 42 lines
Quoted 42 lines
include/linux/mfd/tps65917.h new file +42
-0+/* sleep_mode is the mode loaded to MODE_SLEEP bits as defined in +* the data sheet. +* +* For SMPS +* +* 0: Off +* 1: AUTO +* 2: ECO +* 3: Forced PWM +* +* For LDO +* +* 0: Off +* 1: On +*/ +int mode_sleep; + +/* voltage_sel is the bitfield loaded onto the SMPSX_VOLTAGE +* register. Set this is the default voltage set in OTP needs +* to be overridden. +*/ +u8 vsel; +}; + +enum tps65917_regulators { +/* SMPS regulators */ +TPS65917_REG_SMPS1 , +TPS65917_REG_SMPS2 , +TPS65917_REG_SMPS3 , +TPS65917_REG_SMPS4 , +TPS65917_REG_SMPS5 , +/* LDO regulators */ +TPS65917_REG_LDO1 , +TPS65917_REG_LDO2 , +TPS65917_REG_LDO3 , +TPS65917_REG_LDO4 , +TPS65917_REG_LDO5 , +TPS65917_REG_REGEN1 , +TPS65917_REG_REGEN2 , +TPS65917_REG_REGEN3 , + +/* Total number of regulators */
Quoted 8 lines
include/linux/mfd/tps65917.h line 116
Quoted 7 lines
include/linux/mfd/tps65917.h new file +7
-0+ TPS65917_NUM_REGS, +}; + +struct tps65917_pmic_platform_data { +/* An array of pointers to regulator init data indexed by regulator +* ID +*/ Odd multi-line comments throughout.
oops. I will correct this.
Quoted 64 lines
Quoted 64 lines
include/linux/mfd/tps65917.h new file +63
-0+struct regulator_init_data *reg_data[TPS65917_NUM_REGS ]; + +/* An array of pointers to structures containing sleep mode and DVS +* configuration for regulators indexed by ID +*/ +struct tps65917_reg_init *reg_init[TPS65917_NUM_REGS ]; +}; + + +struct tps65917_platform_data { +int irq_flags; +int gpio_base; + +/* bit value to be loaded to the POWER_CTRL register */ +u8 power_ctrl; + +/* +* boolean to select if we want to configure muxing here +* then the two value to load into the registers if true +*/ +int mux_from_pdata; +u8 pad1, pad2; +bool pm_off; + +struct tps65917_pmic_platform_data *pmic_pdata; +}; + +/* Define the tps65917 IRQ numbers */ +enum tps65917_irqs { +/* INT1 registers */ +TPS65917_RESERVED1 , +TPS65917_PWRON_IRQ , +TPS65917_LONG_PRESS_KEY_IRQ , +TPS65917_RESERVED2 , +TPS65917_PWRDOWN_IRQ , +TPS65917_HOTDIE_IRQ , +TPS65917_VSYS_MON_IRQ , +TPS65917_RESERVED3 , +/* INT2 registers */ +TPS65917_RESERVED4 , +TPS65917_OTP_ERROR_IRQ , +TPS65917_WDT_IRQ , +TPS65917_RESERVED5 , +TPS65917_RESET_IN_IRQ , +TPS65917_FSD_IRQ , +TPS65917_SHORT_IRQ , +TPS65917_RESERVED6 , +/* INT3 registers */ +TPS65917_GPADC_AUTO_0_IRQ , +TPS65917_GPADC_AUTO_1_IRQ , +TPS65917_GPADC_EOC_SW_IRQ , +TPS65917_RESREVED6 , +TPS65917_RESERVED7 , +TPS65917_RESERVED8 , +TPS65917_RESERVED9 , +TPS65917_VBUS_IRQ , +/* INT4 registers */ +TPS65917_GPIO_0_IRQ , +TPS65917_GPIO_1_IRQ , +TPS65917_GPIO_2_IRQ , +TPS65917_GPIO_3_IRQ , +TPS65917_GPIO_4_IRQ , +TPS65917_GPIO_5_IRQ ,
Quoted 8 lines
include/linux/mfd/tps65917.h line 186
Quoted 7 lines
include/linux/mfd/tps65917.h new file +7
-0+TPS65917_GPIO_6_IRQ , +TPS65917_RESERVED10 , +/* Total Number IRQs */ + TPS65917_NUM_IRQ, +}; + +/* External controll signal name */ Spelling.
I will correct this.
Quoted 105 lines
Quoted 93 lines
include/linux/mfd/tps65917.h new file +92
-0+enum { +TPS65917_EXT_CONTROL_ENABLE1 =0x1 , +TPS65917_EXT_CONTROL_ENABLE2 =0x2 , +TPS65917_EXT_CONTROL_NSLEEP =0x4 , +}; + +/* +* TPS65917 device resources can be controlled externally for +* enabling/disabling it rather than register write through i2c. +* Add the external controlled requestor ID for different resources. +*/ +enum tps65917_external_requestor_id { +TPS65917_EXTERNAL_REQSTR_ID_REGEN1 , +TPS65917_EXTERNAL_REQSTR_ID_REGEN2 , +TPS65917_EXTERNAL_REQSTR_ID_REGEN3 , +TPS65917_EXTERNAL_REQSTR_ID_SMPS1 , +TPS65917_EXTERNAL_REQSTR_ID_SMPS2 , +TPS65917_EXTERNAL_REQSTR_ID_SMPS3 , +TPS65917_EXTERNAL_REQSTR_ID_SMPS4 , +TPS65917_EXTERNAL_REQSTR_ID_SMPS5 , +TPS65917_EXTERNAL_REQSTR_ID_LDO1 , +TPS65917_EXTERNAL_REQSTR_ID_LDO2 , +TPS65917_EXTERNAL_REQSTR_ID_LDO3 , +TPS65917_EXTERNAL_REQSTR_ID_LDO4 , +TPS65917_EXTERNAL_REQSTR_ID_LDO5 , +/* Last entry */ +TPS65917_EXTERNAL_REQSTR_ID_MAX , +}; + +struct tps65917_pmic { +struct tps65917 *tps65917; +struct device *dev; +struct regulator_desc desc[TPS65917_NUM_REGS ]; +struct regulator_dev *rdev[TPS65917_NUM_REGS ]; +/* pmic mutex */ +struct mutex mutex; +int smps12; +int range[TPS65917_REG_SMPS5 ]; +unsigned int ramp_delay[TPS65917_REG_SMPS5 ]; +unsigned int current_reg_mode[TPS65917_REG_SMPS5 ]; +}; + +/* helper macro to get correct slave number */ +#define TPS65917_BASE_TO_SLAVE (x) ((x >> 8) - 1) +#define TPS65917_BASE_TO_REG (x, y) ((x & 0xff) + y) + +/* Base addresses of IP blocks in TPS65917 */ +#define TPS65917_SMPS_DVS_BASE 0x20 +#define TPS65917_VALIDITY_BASE 0x118 +#define TPS65917_SMPS_BASE 0x120 +#define TPS65917_LDO_BASE 0x150 +#define TPS65917_DVFS_BASE 0x180 +#define TPS65917_PMU_CONTROL_BASE 0x1A0 +#define TPS65917_RESOURCE_BASE 0x1D4 +#define TPS65917_PU_PD_OD_BASE 0x1F0 +#define TPS65917_LED_BASE 0x200 +#define TPS65917_INTERRUPT_BASE 0x210 +#define TPS65917_GPIO_BASE 0x280 +#define TPS65917_GPADC_BASE 0x2C0 +#define TPS65917_TRIM_GPADC_BASE 0x3CD + +/* Registers for function BACKUP */ +#define TPS65917_BACKUP0 0x0 +#define TPS65917_BACKUP1 0x1 +#define TPS65917_BACKUP2 0x2 +#define TPS65917_BACKUP3 0x3 +#define TPS65917_BACKUP4 0x4 +#define TPS65917_BACKUP5 0x5 +#define TPS65917_BACKUP6 0x6 +#define TPS65917_BACKUP7 0x7 + +/* Bit definitions for BACKUP0 */ +#define TPS65917_BACKUP0_BACKUP_MASK 0xff +#define TPS65917_BACKUP0_BACKUP_SHIFT 0 + +/* Bit definitions for BACKUP1 */ +#define TPS65917_BACKUP1_BACKUP_MASK 0xff +#define TPS65917_BACKUP1_BACKUP_SHIFT 0 + +/* Bit definitions for BACKUP2 */ +#define TPS65917_BACKUP2_BACKUP_MASK 0xff +#define TPS65917_BACKUP2_BACKUP_SHIFT 0 + +/* Bit definitions for BACKUP3 */ +#define TPS65917_BACKUP3_BACKUP_MASK 0xff +#define TPS65917_BACKUP3_BACKUP_SHIFT 0 + +/* Bit definitions for BACKUP4 */ +#define TPS65917_BACKUP4_BACKUP_MASK 0xff +#define TPS65917_BACKUP4_BACKUP_SHIFT 0 + +/* Bit definitions for BACKUP5 */ include/linux/mfd/tps65917.h line 288
Quoted 10 lines
include/linux/mfd/tps65917.h new file +10
-0+#define TPS65917_BACKUP5_BACKUP_MASK 0xff +#define TPS65917_BACKUP5_BACKUP_SHIFT 0 + +/* Bit definitions for BACKUP6 */ +#define TPS65917_BACKUP6_BACKUP_MASK 0xff +#define TPS65917_BACKUP6_BACKUP_SHIFT 0 + +/* Bit definitions for BACKUP7 */ +#define TPS65917_BACKUP7_BACKUP_MASK 0xff +#define TPS65917_BACKUP7_BACKUP_SHIFT 0If they do not differ, remove the number and consolidate:
Quoted 3 lines
/* Bit definitions for BACKUP{0-7} */
#defineTPS65917_BACKUP_BACKUP_MASK0xff
#defineTPS65917_BACKUP_BACKUP_SHIFT0
Ok
Quoted 27 lines
Quoted 27 lines
include/linux/mfd/tps65917.h new file +27
-0+/* Registers for function SMPS */ +#define TPS65917_SMPS1_CTRL 0x0 +#define TPS65917_SMPS1_FORCE 0x2 +#define TPS65917_SMPS1_VOLTAGE 0x3 +#define TPS65917_SMPS2_CTRL 0x4 +#define TPS65917_SMPS2_FORCE 0x6 +#define TPS65917_SMPS2_VOLTAGE 0x7 +#define TPS65917_SMPS3_CTRL 0xC +#define TPS65917_SMPS3_FORCE 0xE +#define TPS65917_SMPS3_VOLTAGE 0xF +#define TPS65917_SMPS4_CTRL 0x10 +#define TPS65917_SMPS4_VOLTAGE 0x13 +#define TPS65917_SMPS5_CTRL 0x18 +#define TPS65917_SMPS5_VOLTAGE 0x1B +#define TPS65917_SMPS_CTRL 0x24 +#define TPS65917_SMPS_PD_CTRL 0x25 +#define TPS65917_SMPS_THERMAL_EN 0x27 +#define TPS65917_SMPS_THERMAL_STATUS 0x28 +#define TPS65917_SMPS_SHORT_STATUS 0x29 +#define TPS65917_SMPS_NEGATIVE_CURRENT_LIMIT_EN 0x2A +#define TPS65917_SMPS_POWERGOOD_MASK1 0x2B +#define TPS65917_SMPS_POWERGOOD_MASK2 0x2C + +/* Bit definitions for SMPS1_CTRL */ +#define TPS65917_SMPS1_CTRL_WR_S 0x80 +#define TPS65917_SMPS1_CTRL_WR_S_SHIFT 7 +#define TPS65917_SMPS1_CTRL_ROOF_FLOOR_EN 0x40
Quoted 8 lines
include/linux/mfd/tps65917.h line 323
Quoted 7 lines
include/linux/mfd/tps65917.h new file +7
-0+#define TPS65917_SMPS1_CTRL_ROOF_FLOOR_EN_SHIFT 6 +#define TPS65917_SMPS1_CTRL_STATUS_MASK 0x30 +#define TPS65917_SMPS1_CTRL_STATUS_SHIFT 4 +#define TPS65917_SMPS1_CTRL_MODE_SLEEP_MASK 0x0c +#define TPS65917_SMPS1_CTRL_MODE_SLEEP_SHIFT 2 +#define TPS65917_SMPS1_CTRL_MODE_ACTIVE_MASK 0x03 +#define TPS65917_SMPS1_CTRL_MODE_ACTIVE_SHIFT 0Pick a base and stick with it. I suggest hex throughout.
Ok
Quoted 11 lines
[...]
include/linux/mfd/tps65917.h line 504
Quoted 8 lines
include/linux/mfd/tps65917.h new file +8
-0+/* Bit definitions for SMPS_PLL_CTRL */ + +#define TPS65917_SMPS_PLL_CTRL_PLL_EN_PLL_BYPASS_SHIFT 0x8 +#define TPS65917_SMPS_PLL_CTRL_PLL_PLL_EN_BYPASS 3 +#define TPS65917_SMPS_PLL_CTRL_PLL_PLL_BYPASS_CLK_SHIFT 0x4 +#define TPS65917_SMPS_PLL_CTRL_PLL_PLL_BYPASS_CLK 2 + +Remove this line.
Ok
Quoted 10 lines
include/linux/mfd/tps65917.h line 513
Quoted 9 lines
include/linux/mfd/tps65917.h new file +9
-0+/* Registers for function LDO */ +#define TPS65917_LDO1_CTRL 0x0 +#define TPS65917_LDO1_VOLTAGE 0x1 +#define TPS65917_LDO2_CTRL 0x2 +#define TPS65917_LDO2_VOLTAGE 0x3 +#define TPS65917_LDO3_CTRL 0x4 +#define TPS65917_LDO3_VOLTAGE 0x5 +#define TPS65917_LDO4_CTRL 0xE +#define TPS65917_LDO4_VOLTAGE 0xFAlso standardise the number of digits represented and either
Ok
Quoted 1 line
capitalise none or all of the hex letters.
Ok
Quoted 7 lines
[...]
include/linux/mfd/tps65917.h line 1451
Quoted 4 lines
include/linux/mfd/tps65917.h new file +4
-0+static inline int tps65917_read (struct tps65917 *tps65917,unsigned int base, +unsigned int reg,unsigned int *val) +{ +unsigned int addr =TPS65917_BASE_TO_REG (base, reg);Extra ' '.
I will remove.
Quoted 46 lines
Quoted 46 lines
include/linux/mfd/tps65917.h new file +45
-0+int slave_id =TPS65917_BASE_TO_SLAVE (base); + +return regmap_read (tps65917->regmap[slave_id], addr, val); +} + +static inline int tps65917_write (struct tps65917 *tps65917,unsigned int base, +unsigned int reg,unsigned int value) +{ +unsigned int addr =TPS65917_BASE_TO_REG (base, reg); +int slave_id =TPS65917_BASE_TO_SLAVE (base); + +return regmap_write (tps65917->regmap[slave_id], addr, value); +} + +static inline int tps65917_bulk_write (struct tps65917 *tps65917, +unsigned int base, +unsigned int reg,const void *val, +size_t val_count) +{ +unsigned int addr =TPS65917_BASE_TO_REG (base, reg); +int slave_id =TPS65917_BASE_TO_SLAVE (base); + +return regmap_bulk_write (tps65917->regmap[slave_id], addr, + val, val_count); +} + +static inline int tps65917_bulk_read (struct tps65917 *tps65917, +unsigned int base, +unsigned int reg,void *val, +size_t val_count) +{ +unsigned int addr =TPS65917_BASE_TO_REG (base, reg); +int slave_id =TPS65917_BASE_TO_SLAVE (base); + +return regmap_bulk_read (tps65917->regmap[slave_id], addr, + val, val_count); +} + +static inline int tps65917_update_bits (struct tps65917 *tps65917, +unsigned int base,unsigned int reg, +unsigned int mask,unsigned int val) +{ +unsigned int addr =TPS65917_BASE_TO_REG (base, reg); +int slave_id =TPS65917_BASE_TO_SLAVE (base); +
Quoted 8 lines
include/linux/mfd/tps65917.h line 1503
Quoted 7 lines
include/linux/mfd/tps65917.h new file +7
-0+return regmap_update_bits (tps65917->regmap[slave_id], addr, mask, val); +} + +static inline int tps65917_irq_get_virq (struct tps65917 *tps65917,int irq) +{ +return regmap_irq_get_virq (tps65917->irq_data, irq); +}This is quite a lot of overhead. Are you sure you require them?
I will relook at this.
Quoted 6 lines
include/linux/mfd/tps65917.h line 1509
Quoted 6 lines
include/linux/mfd/tps65917.h new file +5
-0+int tps65917_ext_control_req_config (struct tps65917 *tps65917, +enum tps65917_external_requestor_id ext_control_req_id, +int ext_ctrl,bool enable); + +#endif /* __LINUX_MFD_TPS65917_H */
Thanks,
Keerthy
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH v2 3/4] mfd: tps65917: Add driver for the TPS65917 PMIC
In reply to KeerthyOn 05/20/2014 04:11 AM, Keerthy wrote:
[...]
drivers/mfd/Kconfig config MFD_TPS65912_SPI · line 933
Quoted 6 lines
drivers/mfd/Kconfig +6
-0+config MFD_TPS65917 + bool "TI TPS65917 series chips" + select MFD_CORE + select REGMAP_I2C + select REGMAP_IRQ + depends on I2C=y
^^ why =y?
Quoted 54 lines
drivers/mfd/Kconfig +6
-0+ 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=ydrivers/mfd/Makefile +1
-0@@ -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.odrivers/mfd/tps65917.c new file +27
-0@@ -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>
Quoted 25 lines
drivers/mfd/tps65917.c new file +25
-0+ +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;
drivers/mfd/tps65917.c line 95
Quoted 10 lines
drivers/mfd/tps65917.c new file +10
-0+ +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?
[...]
drivers/mfd/tps65917.c line 258
Quoted 7 lines
drivers/mfd/tps65917.c new file +6
-0+}; + +int tps65917_ext_control_req_config (struct tps65917 *tps65917, +enum tps65917_external_requestor_id id, +int ext_ctrl,bool enable) +{
kernel doc style documentation
[...]
Quoted 13 lines
drivers/mfd/tps65917.c new file +13
-0+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) +{
[...]
drivers/mfd/tps65917.c line 512
Quoted 10 lines
drivers/mfd/tps65917.c new file +10
-0+/* +* 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?
Quoted 41 lines
drivers/mfd/tps65917.c new file +41
-0+ } + +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 i2c_device_id tps65917_i2c_id[] = { + {"tps65917" , }, +}; +MODULE_DEVICE_TABLE (i2c, tps65917_i2c_id); + +static struct i2c_driver tps65917_i2c_driver = { + .driver = { + .name ="tps65917" , + .of_match_table = of_tps65917_match_tbl, + .owner =THIS_MODULE , + }, + .probe = tps65917_i2c_probe,
drivers/mfd/tps65917.c line 563
Quoted 10 lines
drivers/mfd/tps65917.c new file +10
-0+ .remove = tps65917_i2c_remove, + .id_table = tps65917_i2c_id, +}; + +static int __init tps65917_i2c_init (void ) +{ +return i2c_add_driver (&tps65917_i2c_driver); +} +/* init early so consumer devices can complete system boot */ +subsys_initcall (tps65917_i2c_init);
Should we let them just defer?
[...]
Quoted 15 lines
include/linux/mfd/tps65917.h new file +9
-0+ +struct tps65917 { +struct device *dev; + +struct i2c_client *i2c_clients[TPS65917_NUM_CLIENTS ]; +struct regmap *regmap[TPS65917_NUM_CLIENTS ]; + +/* Stored chip id */ +int id;
include/linux/mfd/tps65917.h line 45
Quoted 10 lines
include/linux/mfd/tps65917.h new file +10
-0+ +struct tps65917_pmic *pmic; + +/* IRQ Data */ +int irq; +u32 irq_mask; +/* mutext for irq */ +struct mutex irq_lock; +struct regmap_irq_chip_data *irq_data; +};
For all structures, could you use kerneldoc style documentation?
See: Documentation/kernel-doc-nano-HOWTO.txt +273
include/linux/mfd/tps65917.h line 1449
Quoted 2 lines
include/linux/mfd/tps65917.h new file +2
-0+static inline int tps65917_read (struct tps65917 *tps65917,unsigned int base, +unsigned int reg,unsigned int *val)
Again for all functions expected to be called by other driver(such as regulator) to mfd, kernel-doc style documentation?
[...]
Signature · 2 lines
Regards, Nishanth Menon
Re: [PATCH v2 3/4] mfd: tps65917: Add driver for the TPS65917 PMIC
Hi Nishanth,
Quoted 9 lines · Nishanth Menon
On 05/20/2014 04:11 AM, Keerthy wrote:
[...]drivers/mfd/Kconfig config MFD_TPS65912_SPI · line 933
Quoted 6 lines
drivers/mfd/Kconfig +6
-0+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'
Quoted 85 lines
Quoted 54 lines
drivers/mfd/Kconfig +6
-0+ 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=ydrivers/mfd/Makefile +1
-0@@ -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.odrivers/mfd/tps65917.c new file +27
-0@@ -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>
Quoted 30 lines
drivers/mfd/tps65917.c new file +30
-0+ +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 ] = {
Quoted 8 lines
drivers/mfd/tps65917.c line 95
Quoted 5 lines
drivers/mfd/tps65917.c new file +5
-0+ { + .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.
Quoted 23 lines
drivers/mfd/tps65917.c line 258
Quoted 6 lines
drivers/mfd/tps65917.c new file +6
-0+}; + +int tps65917_ext_control_req_config (struct tps65917 *tps65917, +enum tps65917_external_requestor_id id, +int ext_ctrl,bool enable) +{kernel doc style documentation
[...]Quoted 13 lines
drivers/mfd/tps65917.c new file +13
-0+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) +{[...]
Quoted 11 lines
drivers/mfd/tps65917.c line 512
Quoted 10 lines
drivers/mfd/tps65917.c new file +10
-0+/* +* 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.
Quoted 54 lines
Quoted 42 lines
drivers/mfd/tps65917.c new file +41
-0+ } + +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 i2c_device_id tps65917_i2c_id[] = { + {"tps65917" , }, +}; +MODULE_DEVICE_TABLE (i2c, tps65917_i2c_id); + +static struct i2c_driver tps65917_i2c_driver = { + .driver = { + .name ="tps65917" , + .of_match_table = of_tps65917_match_tbl, + .owner =THIS_MODULE , + }, + .probe = tps65917_i2c_probe,drivers/mfd/tps65917.c line 563
Quoted 10 lines
drivers/mfd/tps65917.c new file +10
-0+ .remove = tps65917_i2c_remove, + .id_table = tps65917_i2c_id, +}; + +static int __init tps65917_i2c_init (void ) +{ +return i2c_add_driver (&tps65917_i2c_driver); +} +/* init early so consumer devices can complete system boot */ +subsys_initcall (tps65917_i2c_init);Should we let them just defer?
Quoted 1 line
[...]
Guess most drivers in the mfd folder use subsys_initcall
Quoted 29 lines
Quoted 15 lines
include/linux/mfd/tps65917.h new file +9
-0+ +struct tps65917 { +struct device *dev; + +struct i2c_client *i2c_clients[TPS65917_NUM_CLIENTS ]; +struct regmap *regmap[TPS65917_NUM_CLIENTS ]; + +/* Stored chip id */ +int id;include/linux/mfd/tps65917.h line 45
Quoted 10 lines
include/linux/mfd/tps65917.h new file +10
-0+ +struct tps65917_pmic *pmic; + +/* IRQ Data */ +int irq; +u32 irq_mask; +/* mutext for irq */ +struct mutex irq_lock; +struct regmap_irq_chip_data *irq_data; +};For all structures, could you use kerneldoc style documentation?
See:Documentation/kernel-doc-nano-HOWTO.txt+273
Quoted 7 lines
include/linux/mfd/tps65917.h line 1449
Quoted 2 lines
include/linux/mfd/tps65917.h new file +2
-0+static inline int tps65917_read (struct tps65917 *tps65917,unsigned int base, +unsigned int reg,unsigned int *val)Again for all functions expected to be called by other driver(such as regulator) to mfd, kernel-doc style documentation?
[...]
Ok.
Thanks,
Keerthy
PATCH v2 4/4 regulator: tps65917: Add Regulator driver for TPS65917 PMIC
In reply to KeerthyThis patch adds support for TPS65917 PMIC regulators.
The regulators set consists of 5 SMPSs and 5 LDOs. The output voltages are configurable and are meant to supply power to the main processor and other components.
---
Comments fixed in V2:
Used the standard functions in helpers.c Added a NULL entry in of_tps65917_match_tbl table. Used linear ranges instead of open coded function.
drivers/regulator/Kconfig | 12 + drivers/regulator/Makefile | 1 + drivers/regulator/tps65917-regulator.c | 810 ++++++++++++++++++++++++++++++++ 3 files changed, 823 insertions(+) create mode 100644 drivers/regulator/tps65917-regulator.c
drivers/regulator/Kconfig +12 -0
@@ -581,6 +581,18 @@ config REGULATOR_TPS65912 help This driver supports TPS65912 voltage regulator chip. +config REGULATOR_TPS65917 + tristate "TI TPS65917 PMIC Regulators" + depends on MFD_TPS65917 + help + If you wish to control the regulators on the TPS65917 series of + chips say Y here. This will enable support for all the software + controllable SMPS/LDO regulators. + + The regulators available on TPS65917 series chips vary depending + on the muxing. This is handled automatically in the driver by + reading the mux info from OTP. + config REGULATOR_TPS80031 tristate "TI TPS80031/TPS80032 power regualtor driver" depends on MFD_TPS80031
drivers/regulator/Makefile +1 -0
@@ -76,6 +76,7 @@ obj-$(CONFIG_REGULATOR_TPS6524X) += tps6524x-regulator.o obj-$(CONFIG_REGULATOR_TPS6586X) += tps6586x-regulator.o obj-$(CONFIG_REGULATOR_TPS65910) += tps65910-regulator.o obj-$(CONFIG_REGULATOR_TPS65912) += tps65912-regulator.o +obj-$(CONFIG_REGULATOR_TPS65917) += tps65917-regulator.o obj-$(CONFIG_REGULATOR_TPS80031) += tps80031-regulator.o obj-$(CONFIG_REGULATOR_TWL4030) += twl-regulator.o obj-$(CONFIG_REGULATOR_VEXPRESS) += vexpress.o
drivers/regulator/tps65917-regulator.c new file +810 -0
810 lines not on this page · raw message
Signature · 1 line
1.7.9.5