Add support for MAXIM MAX77620/MAX20024 PMIC
Subsystems (6)
v2 cover Add support for MAXIM MAX77620/MAX20024 PMIC
Add SW support for MAXIM Semiconductor's Power Management IC (PMIC) MAX77620/MAX20024. This PMIC supports DC-DC/LDOS, GPIOs, RTC, watchdog, clocks etc.
This series add respective driver for each of sub-modules.
---
Changes from V1:
DT DOC:
- Added units in some of properties.
- Change the boolean property to tristate type and detail some of properties.
RTC:
- Rename the file to rtc-max77xxx.c and make the generic implementation.
- Direct regmap apis are used for the register access.
- Decouped from max77620 driver.
- Taken care of cleanup comments form V1 version.
MFD:
- Code cleanups per review from V1.
- Move register acccess APIs from header to c file.
- Remove some of non required variable, remove duplication in error message and simplify some of function implementation.
GPIO:
- Use the gpiochip_add_data and get the chip data from core APIs.
- Cleanups based on comment received on mfd/rtc.
- Avoid duplication on error message.
Pinctrl:
- Cleanup code based on comment received on mfd/rtc.
- Avoid duplication on error message.
Regulators:
- Cleanup code based on comment received on mfd/rtc.
- Avoid duplication on error message.
- Taken care of review comment from Mark.
Laxman Dewangan (6):
DT: mfd: add device-tree binding doc fro PMIC max77620/max20024
mfd: max77620: add core driver for MAX77620/MAX20024
pinctrl: max77620: add pincontrol driver for MAX77620/MAX20024
gpio: max77620: add gpio driver for MAX77620/MAX20024
rtc: max77xxx: add RTC driver for Maxim MAX77xxx series RTC IP
regulator: max77620: add regulator driver for max77620/max20024
Documentation/devicetree/bindings/mfd/max77620.txt | 397 ++++++++ drivers/gpio/Kconfig | 9 + drivers/gpio/Makefile | 1 + drivers/gpio/gpio-max77620.c | 306 +++++++ drivers/mfd/Kconfig | 15 + drivers/mfd/Makefile | 1 + drivers/mfd/max77620.c | 997 +++++++++++++++++++++ drivers/pinctrl/Kconfig | 10 + drivers/pinctrl/Makefile | 1 + drivers/pinctrl/pinctrl-max77620.c | 705 +++++++++++++++ drivers/regulator/Kconfig | 9 + drivers/regulator/Makefile | 1 + drivers/regulator/max77620-regulator.c | 991 ++++++++++++++++++++ drivers/rtc/Kconfig | 10 + drivers/rtc/Makefile | 1 + drivers/rtc/rtc-max77xxx.c | 500 +++++++++++ include/dt-bindings/mfd/max77620.h | 38 + include/linux/mfd/max77620.h | 407 +++++++++ 18 files changed, 4399 insertions(+) create mode 100644 Documentation/devicetree/bindings/mfd/max77620.txt create mode 100644 drivers/gpio/gpio-max77620.c create mode 100644 drivers/mfd/max77620.c create mode 100644 drivers/pinctrl/pinctrl-max77620.c create mode 100644 drivers/regulator/max77620-regulator.c create mode 100644 drivers/rtc/rtc-max77xxx.c create mode 100644 include/dt-bindings/mfd/max77620.h create mode 100644 include/linux/mfd/max77620.h
Signature · 1 line
2.1.4
PATCH v2 1/6 DT: mfd: add device-tree binding doc fro PMIC max77620/max20024
The MAXIM PMIC MAX77620 and MAX20024 are power management IC which supports RTC, GPIO, DCDC/LDO regulators, interrupt, watchdog etc.
Add DT binding document for the different functionality of this device.
---
Changes from V1:
- Added units in some of properties.
- Change the boolean property to tristate type and detail some of properties.
Documentation/devicetree/bindings/mfd/max77620.txt | 397 +++++++++++++++++++++ include/dt-bindings/mfd/max77620.h | 38 ++ 2 files changed, 435 insertions(+) create mode 100644 Documentation/devicetree/bindings/mfd/max77620.txt create mode 100644 include/dt-bindings/mfd/max77620.h
Documentation/devicetree/bindings/mfd/max77620.txt new file +397 -0
@@ -0,0 +1,397 @@ +* MAX77620 Power management IC from Maxim Semiconductor. + +Required properties: +------------------- +- compatible: Must be one of + "maxim,max77620" or + "maxim,max20024". +- reg: I2C device address. +- interrupt-controller: MAX77620 has internal interrupt controller which + takes the interrupt request from internal sub-blocks like RTC, + regulators, GPIOs as well as external input. +- #interrupt-cells: Should be set to 2 for IRQ number and flags. + The first cell is the IRQ number. IRQ numbers for different interrupt + source of MAX77620 are defined at dt-bindings/mfd/max77620.h + The second cell is the flags, encoded as the trigger masks from binding + document interrupts.txt, using dt-bindings/irq. + +Optional properties: +------------------- +This device also supports the power OFF of system. +Following properties are used for this purpose: +- system-power-controller: Boolean, This device will be use as + system power controller and used for power OFF of system. + Host issue necessary command to PMIC. + + +Optional submodule and their properties: +======================================= + +Flexible power sequence configuration +==================================== +This sub-node configures the Flexible Power Sequnece(FPS) for power ON slot, +power OFF slot and slot period of the device. Device has 3 FPS as FPS0, +FPS1 and FPS2. The details of FPS configuration is provided through +subnode "fps". The details of FPS0, FPS1, FPS2 are provided through the +child node under this subnodes. The FPS number is provided via reg property. + +The property for fps child nodes as: +Required properties: + -reg: FPS number like 0, 1, 2 for FPS0, FPS1 and FPS2 respectively. +Optinal properties: + -maxim,active-fps-time-period: Active state FPS time period in + microseconds. + -maxim,suspend-fps-time-period: Suspend state FPS time period in + microseconds. + -maxim,fps-enable-input: FPS enable source like EN0, EN1 or SW. The + macros are defined on dt-bindings/mfd/max77620.h for + different enable source. + FPS_EN_SRC_EN0 for EN0 enable source. + FPS_EN_SRC_EN1 for En1 enable source. + FPS_EN_SRC_SW for SW based control. + -maxim,fps-sw-enable: Boolean, applicable if enable input is SW. + If this property present then enable the FPS else + disable FPS. + -maxim,enable-sleep: Boolean, enable sleep when the external control + goes from HIGH to LOW. + -maxim,enable-global-lpm: Boolean, enable global LPM when the external + control goes from HIGH to LOW. + +Here supported time periods by device in microseconds are as follows: +MAX77620 supports 40, 80, 160, 320, 640, 1280, 2560 and 5120 microseconds. +MAX20024 supports 20, 40, 80, 160, 320, 640, 1280 and 2540 microseconds. + +Pinmux and GPIO: +=============== +Device has 8 GPIO pins which can be configured as GPIO as well as the +special IO functions. + +Please refer to pinctrl-bindings.txt for details of the common pinctrl +bindings used by client devices, including the meaning of the phrase +"pin configuration node". + +Following are properties which is needed if GPIO and pinmux functionality +is required: + Required properties: + ------------------- + - gpio-controller: Marks the device node as a GPIO controller. + - #gpio-cells: Number of GPIO cells. Refer to binding document + gpio/gpio.txt + + Optional properties: + -------------------- + Following properties are require if pin control setting is required + at boot. + - pinctrl-names: A pinctrl state named "default" be defined, using + the bindings in pinctrl/pinctrl-binding.txt. + - pinctrl[0...n]: Properties to contain the phandle that refer to + different nodes of pin control settings. These nodes + represents the pin control setting of state 0 to state n. + Each of these nodes contains different subnodes to + represents some desired configuration for a list of pins. + This configuration can include the mux function to select + on those pin(s), and various pin configuration parameters, + such as pull-up, open drain. + + Each subnode have following properties: + Required properties: + - pins: List of pins. Valid values of pins properties + are: gpio0, gpio1, gpio2, gpio3, gpio4, + gpio5, gpio6, gpio7 + + Optional properties: + function, drive-push-pull, drive-open-drain, + bias-pull-up, bias-pull-down. + Definitions are in the pinmux dt binding + devicetree/bindings/pinctrl/pinctrl-bindings.txt + Absence of properties will leave the configuration + on default. + + Valid values for function properties are: + gpio, lpm-control-in, fps-out, 32k-out, + sd0-dvs-in, sd1-dvs-in, reference-out + Theres is also customised property for the GPIO1, + GPIO2 and GPIO3. + - maxim,active-fps-source: FPS source for the gpios in + active state of the GPIO. Valid values are + FPS_SRC_0, FPS_SRC_1, FPS_SRC_2 and + FPS_SRC_NONE. Absence of this property will + leave the pin on default. + - maxim,active-fps-power-up-slot: Power up slot on + given FPS for acive state.Valid values are 0 + to 7. + - maxim,active-fps-power-down-slot: Power down slot + on given FPS for active state. Valid values + are 0 t 7. + - maxim,suspend-fps-source: Suspend state FPS source. + - maxim,suspend-fps-power-down-slot: Suspend state + power down slot. + - maxim,suspend-fps-power-up-slot: Suspend state power + up slot. + +Regulators: +=========== +Device has multiple DCDC(sd[0-3] and LDOs(ldo[0-8]). The node "regulators" +is require if regulator functionality is needed. + +Following are properties of regulator subnode. + + Optional properties: + ------------------- + The input supply of regulators are the optional properties on the + regulator node. The input supply of these regulators are provided + through following properties: + in-sd0-supply: Input supply for SD0, INA-SD0 or INB-SD0 pins. + in-sd1-supply: Input supply for SD1. + in-sd2-supply: Input supply for SD2. + in-sd3-supply: Input supply for SD3. + in-ldo0-1-supply: Input supply for LDO0 and LDO1. + in-ldo2-supply: Input supply for LDO2. + in-ldo3-5-supply: Input supply for LDO3 and LDO5 + in-ldo4-6-supply: Input supply for LDO4 and LDO6. + in-ldo7-8-supply: Input supply for LDO7 and LDO8. + + + Optional sub nodes for regulators: + --------------------------------- + The subnodes name is the name of regulator and it must be one of: + sd[0-3], ldo[0-8] + + 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 optional custom properties are listed below. + maxim,active-fps-source: FPS source. The macros are defined at + dt-bindings/mfd/max77620.h + maxim,shutdown-fps-source: Same as maxim,fps-source, but it + will apply during shutdown of system. + maxim,active-fps-power-up-slot: Active state Power up slot for + rail on given FPS. + maxim,active-fps-power-down-slot: Active state Power down slot + for rail on given FPS. + maxim,suspend-fps-source: Suspend state FPS source of rail. + maxim,suspend-fps-power-up-slot: Suspend state FPS power + up slot. + maxim,suspend-fps-power-down-slot: Suspend state FPS power + down slot. + maxim,enable-group-low-power: Enable Group low power mode. + maxim,enable-sd0-en2-control: Enable EN2 pincontrol for SD0. + This property is only applicable for SD0. + maxim,disable-remote-sense-on-suspend: Boolean, disable + remote sense on suspend and re-enable on resume. + If this property is not there then no change on + configuration. + +Backup Battery: +============== +This sub-node configure charging backup battery of the device. Device +has support of charging the backup battery. The subnode name is +"backup-battery". + +The property for backup-battery child nodes as: +Presense of this child node will enable the backup battery charging. + +Optinal properties: + -maxim,bb-charging-current-microamp: Charging current + setting. + The device supports 50/100/200/400/600/800uA. + If this property is unavailable then it will + charge with 50uA. + -maxim,bb-charging-voltage-microvolt: Charging Voltage Limit Setting. + Device supports 2500000/3000000/3300000/350000uV. + Default will be set to 2500mV. The voltage will be roundoff + to nearest lower side if other than above is configured. + -maxim,bb-output-resister-ohm: Output resistor on Ohm. + Device supports 100/1000/3000/6000 Ohms. + +Low-Battery Monitor: +================== +This sub-node configure low battery monitor configuration registers. +Device has support for low-battery monitor configuration through +child DT node "low-battery-monitor". + +Optinal properties: + - maxim,low-battery-dac: Tristate, enable/disable low battery DAC. + 0 for disable, + 1 for enable, + absence will left configuration to default. + - maxim,low-battery-shutdown: Tristate, enable/disable low battery + shutdown. + 0 for disable, + 1 for enable, + absence will left configuration to default. + - maxim,low-battery-reset: Tristate, enable/disable low battery reset. + 0 for disable, + 1 for enable, + absence will left configuration to default. + +Example: +-------- +#include <dt-bindings/mfd/max77620.h> +... +max77620@3c { + compatible = "maxim,max77620"; + reg = <0x3c>; + + interrupt-parent = <&intc>; + interrupts = <0 86 IRQ_TYPE_NONE>; + + +Example: +-------- +#include <dt-bindings/mfd/max77620.h> +... +max77620@3c { + compatible = "maxim,max77620"; + reg = <0x3c>; + + interrupt-parent = <&intc>; + interrupts = <0 86 IRQ_TYPE_NONE>; + + interrupt-controller; + #interrupt-cells = <2>; + + gpio-controller; + #gpio-cells = <2>; + + backup-battery { + maxim,bb-charging-current-microamp = <100>; + maxim,bb-charging-voltage-microvolt = <3000000>; + maxim,bb-output-resister-ohm = <100>; + }; + + fps { + #address-cells = <1>; + #size-cells = <0>; + fps@0 { + reg = <0>; + maxim,fps-time-period = <100>; + maxim,fps-enable-input = <FPS_EN_SRC_EN0>; + }; + + fps@1 { + reg = <1>; + maxim,fps-time-period = <100>; + maxim,fps-enable-input = <FPS_EN_SRC_EN1>; + }; + + fps@2 { + reg = <2>; + maxim,fps-time-period = <100>; + maxim,fps-enable-input = <FPS_EN_SRC_SW>; + }; + }; + + regulators { + in-ldo0-1-supply = <&max77620_sd2>; + in-ldo7-8-supply = <&max77620_sd2>; + + max77620_sd0: sd0 { + regulator-name = "vdd-core"; + regulator-min-microvolt = <600000>; + regulator-max-microvolt = <1400000>; + regulator-boot-on; + regulator-always-on; + maxim,fps-source = <FPS_SRC_1>; + regulator-init-mode = <REGULATOR_MODE_NORMAL>; + }; + + max77620_sd1: sd1 { + regulator-name = "vddio-ddr"; + regulator-min-microvolt = <1200000>; + regulator-max-microvolt = <1200000>; + regulator-always-on; + regulator-boot-on; + regulator-init-mode = <REGULATOR_MODE_NORMAL>; + maxim,fps-source = <FPS_SRC_0>; + }; + + max77620_sd2: sd2 { + regulator-name = "vdd-pre-reg"; + regulator-min-microvolt = <1350000>; + regulator-max-microvolt = <1350000>; + maxim,fps-source = <FPS_SRC_1>; + }; + + max77620_sd3: sd3 { + regulator-name = "vdd-1v8"; + regulator-min-microvolt = <1800000>; + regulator-max-microvolt = <1800000>; + regulator-always-on; + regulator-boot-on; + maxim,fps-source = <FPS_SRC_0>; + regulator-init-mode = <REGULATOR_MODE_NORMAL>; + }; + + max77620_ldo0: ldo0 { + regulator-name = "avdd-sys"; + regulator-min-microvolt = <1200000>; + regulator-max-microvolt = <1200000>; + regulator-always-on; + regulator-boot-on; + maxim,fps-source = <FPS_SRC_NONE>; + }; + + max77620_ldo1: ldo1 { + regulator-name = "vdd-pex"; + regulator-min-microvolt = <1050000>; + regulator-max-microvolt = <1050000>; + maxim,fps-source = <FPS_SRC_NONE>; + }; + + max77620_ldo2: ldo2 { + regulator-name = "vddio-sdmmc3"; + regulator-min-microvolt = <1800000>; + regulator-max-microvolt = <3300000>; + maxim,fps-source = <FPS_SRC_NONE>; + }; + + max77620_ldo3: ldo3 { + regulator-name = "vdd-cam-hv"; + regulator-min-microvolt = <2800000>; + regulator-max-microvolt = <2800000>; + maxim,fps-source = <FPS_SRC_NONE>; + }; + + max77620_ldo4: ldo4 { + regulator-name = "vdd-rtc"; + regulator-min-microvolt = <1250000>; + regulator-max-microvolt = <1250000>; + regulator-always-on; + regulator-boot-on; + maxim,fps-source = <FPS_SRC_0>; + }; + + max77620_ldo5: ldo5 { + regulator-name = "avdd-ts-hv"; + regulator-min-microvolt = <3000000>; + regulator-max-microvolt = <3000000>; + maxim,fps-source = <FPS_SRC_NONE>; + }; + + max77620_ldo6: ldo6 { + regulator-name = "vdd-ts"; + regulator-min-microvolt = <1800000>; + regulator-max-microvolt = <1800000>; + regulator-always-on; + regulator-boot-on; + maxim,fps-source = <FPS_SRC_NONE>; + }; + + max77620_ldo7: ldo7 { + regulator-name = "vdd-gen-pll-edp"; + regulator-min-microvolt = <1050000>; + regulator-max-microvolt = <1050000>; + regulator-always-on; + regulator-boot-on; + maxim,fps-source = <FPS_SRC_1>; + }; + + max77620_ldo8: ldo8 { + regulator-name = "vdd-hdmi-dp"; + regulator-min-microvolt = <1050000>; + regulator-max-microvolt = <1050000>; + maxim,fps-source = <FPS_SRC_NONE>; + }; + }; +};
include/dt-bindings/mfd/max77620.h new file +38 -0
@@ -0,0 +1,38 @@ +/* +* This header provides macros for MAXIM MAX77620 device bindings. +* +* Copyright (c) 2016, NVIDIA Corporation. +* +* Author: Laxman Dewangan <[email protected]> +* +*/ + +#ifndef _DT_BINDINGS_MFD_MAX77620_H +#define _DT_BINDINGS_MFD_MAX77620_H + +/* MAX77620 interrupts */ +#define MAX77620_IRQ_TOP_GLBL 0/* Low-Battery */ +#define MAX77620_IRQ_TOP_SD 1/* SD power fail */ +#define MAX77620_IRQ_TOP_LDO 2/* LDO power fail */ +#define MAX77620_IRQ_TOP_GPIO 3/* GPIO internal int to MAX77620 */ +#define MAX77620_IRQ_TOP_RTC 4/* RTC */ +#define MAX77620_IRQ_TOP_32K 5/* 32kHz oscillator */ +#define MAX77620_IRQ_TOP_ONOFF 6/* ON/OFF oscillator */ +#define MAX77620_IRQ_LBT_MBATLOW 7/* Thermal alarm status, > 120C */ +#define MAX77620_IRQ_LBT_TJALRM1 8/* Thermal alarm status, > 120C */ +#define MAX77620_IRQ_LBT_TJALRM2 9/* Thermal alarm status, > 140C */ + +/* FPS enable -inputs */ +#define FPS_EN_SRC_EN0 0 +#define FPS_EN_SRC_EN1 1 +#define FPS_EN_SRC_SW 2 +#define FPS_EN_SRC_RSVD 3 + +/* FPS source */ +#define FPS_SRC_0 0 +#define FPS_SRC_1 1 +#define FPS_SRC_2 2 +#define FPS_SRC_NONE 3 +#define FPS_SRC_DEF 4 + +#endif
Signature · 1 line
2.1.4
PATCH v2 2/6 mfd: max77620: add core driver for MAX77620/MAX20024
In reply to Laxman DewanganMAX77620/MAX20024 are Power Management IC from the MAXIM. It supports RTC, multiple GPIOs, multiple DCDC and LDOs, watchdog, clock etc.
Add MFD drier to provides common support for accessing the device; additional drivers is developed on respected subsystem in order to use the functionality of the device.
---
- Code cleanups per review from V1.
- Move register acccess APIs from header to c file.
- Remove some of non required variable, remove duplication in error message and simplify some of function implementation.
- Register RTC driver such that it can get the regmap handle form parent device
drivers/mfd/Kconfig | 15 + drivers/mfd/Makefile | 1 + drivers/mfd/max77620.c | 997 +++++++++++++++++++++++++++++++++++++++++++ include/linux/mfd/max77620.h | 407 ++++++++++++++++++ 4 files changed, 1420 insertions(+) create mode 100644 drivers/mfd/max77620.c create mode 100644 include/linux/mfd/max77620.h
drivers/mfd/Kconfig +15 -0
@@ -492,6 +492,21 @@ config MFD_MAX14577 additional drivers must be enabled in order to use the functionality of the device. +config MFD_MAX77620 + bool "Maxim Semiconductor MAX77620 and MAX20024 PMIC Support" + depends on I2C=y + depends on OF + select MFD_CORE + select REGMAP_I2C + select REGMAP_IRQ + select IRQ_DOMAIN + help + Say yes here to add support for Maxim Semiconductor MAX77620 and + MAX20024 which are Power Management IC with General purpose pins, + RTC, regulators, clock generator, watchdog etc. This driver + provides common support for accessing the device; additional drivers + must be enabled in order to use the functionality of the device. + config MFD_MAX77686 bool "Maxim Semiconductor MAX77686/802 PMIC Support" depends on I2C=y
drivers/mfd/Makefile +1 -0
@@ -123,6 +123,7 @@ obj-$(CONFIG_MFD_DA9063) += da9063.o obj-$(CONFIG_MFD_DA9150) += da9150-core.o obj-$(CONFIG_MFD_MAX14577) += max14577.o +obj-$(CONFIG_MFD_MAX77620) += max77620.o obj-$(CONFIG_MFD_MAX77686) += max77686.o obj-$(CONFIG_MFD_MAX77693) += max77693.o obj-$(CONFIG_MFD_MAX77843) += max77843.o
drivers/mfd/max77620.c new file +997 -0
997 lines not on this page · raw message
include/linux/mfd/max77620.h new file +407 -0
407 lines not on this page · raw message
Signature · 1 line
2.1.4
PATCH v2 3/6 pinctrl: max77620: add pincontrol driver for MAX77620/MAX20024
In reply to Laxman DewanganMAXIM Semiconductor's PMIC, MAX77620/MAX20024 has 8 GPIO pins which also act as the special function in alternate mode. Also there is configuration like push-pull, open drain, FPS timing etc for these pins.
Add pincontrol driver to configure these parameters through pincontrol APIs.
---
Changes from V1:
- Cleanup code based on comment received on mfd/rtc.
- Avoid duplication on error message.
drivers/pinctrl/Kconfig | 10 + drivers/pinctrl/Makefile | 1 + drivers/pinctrl/pinctrl-max77620.c | 705 +++++++++++++++++++++++++++++++++++++ 3 files changed, 716 insertions(+) create mode 100644 drivers/pinctrl/pinctrl-max77620.c
drivers/pinctrl/Kconfig +10 -0
@@ -227,6 +227,16 @@ config PINCTRL_COH901 COH 901 335 and COH 901 571/3. They contain 3, 5 or 7 ports of 8 GPIO pins each. +config PINCTRL_MAX77620 + bool "MAX77620/MAX20024 Pincontrol support" + depends on MFD_MAX77620 + select GENERIC_PINCONF + help + Say Yes here to enable Pin control support for Maxim PMIC MAX77620. + This PMIC has 8 GPIO pins that work as GPIO as well as special + function in alternate mode. This driver also configure push-pull, + open drain, FPS slots etc. + config PINCTRL_PALMAS bool "Pinctrl driver for the PALMAS Series MFD devices" depends on OF && MFD_PALMAS
drivers/pinctrl/Makefile +1 -0
@@ -17,6 +17,7 @@ obj-$(CONFIG_PINCTRL_AMD) += pinctrl-amd.o obj-$(CONFIG_PINCTRL_DIGICOLOR) += pinctrl-digicolor.o obj-$(CONFIG_PINCTRL_FALCON) += pinctrl-falcon.o obj-$(CONFIG_PINCTRL_MESON) += meson/ +obj-$(CONFIG_PINCTRL_MAX77620) += pinctrl-max77620.o obj-$(CONFIG_PINCTRL_PALMAS) += pinctrl-palmas.o obj-$(CONFIG_PINCTRL_PISTACHIO) += pinctrl-pistachio.o obj-$(CONFIG_PINCTRL_ROCKCHIP) += pinctrl-rockchip.o
drivers/pinctrl/pinctrl-max77620.c new file +705 -0
705 lines not on this page · raw message
Signature · 1 line
2.1.4
PATCH v2 4/6 gpio: max77620: add gpio driver for MAX77620/MAX20024
In reply to Laxman DewanganMAXIM Semiconductor's PMIC, MAX77620/MAX20024 has 8 GPIO pins. It also supports interrupts from these pins.
Add GPIO driver for these pins to control via GPIO APIs.
---
- Use the gpiochip_add_data and get the chip data from core APIs.
- Cleanups based on comment received on mfd/rtc.
- Avoid duplication on error message.
drivers/gpio/Kconfig | 9 ++ drivers/gpio/Makefile | 1 + drivers/gpio/gpio-max77620.c | 306 +++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 316 insertions(+) create mode 100644 drivers/gpio/gpio-max77620.c
drivers/gpio/Kconfig +9 -0
@@ -797,6 +797,15 @@ config GPIO_LP3943 LP3943 can be used as a GPIO expander which provides up to 16 GPIOs. Open drain outputs are required for this usage. +config GPIO_MAX77620 + bool "GPIO support for PMIC MAX77620 and MAX20024" + depends on MFD_MAX77620 + help + GPIO driver for MAX77620 and MAX20024 PMIC from Maxim Semiconductor. + MAX77620 PMIC has 8 pins that can be configured as GPIOs. The + driver also provides interrupt support for each of the gpios. + Say yes here to enable the max77620 to be used as gpio controller. + config GPIO_MSIC bool "Intel MSIC mixed signal gpio support" depends on MFD_INTEL_MSIC
drivers/gpio/Makefile +1 -0
@@ -57,6 +57,7 @@ obj-$(CONFIG_GPIO_MAX730X) += gpio-max730x.o obj-$(CONFIG_GPIO_MAX7300) += gpio-max7300.o obj-$(CONFIG_GPIO_MAX7301) += gpio-max7301.o obj-$(CONFIG_GPIO_MAX732X) += gpio-max732x.o +obj-$(CONFIG_GPIO_MAX77620) += gpio-max77620.o obj-$(CONFIG_GPIO_MB86S7X) += gpio-mb86s7x.o obj-$(CONFIG_GPIO_MC33880) += gpio-mc33880.o obj-$(CONFIG_GPIO_MC9S08DZ60) += gpio-mc9s08dz60.o
drivers/gpio/gpio-max77620.c new file +306 -0
306 lines not on this page · raw message
Signature · 1 line
2.1.4
PATCH v2 5/6 rtc: max77xxx: add RTC driver for Maxim MAX77xxx series RTC IP
In reply to Laxman DewanganMaxim Semiconductor's PMIC MAX77620, MAX77686, MAX20024 have same RTC IP on these PMICs.
Add generic MAX77xxxx series RTC driver which can be used as RTC driver for these PMIC and avoids duplication of RTC driver for each PMICs. Their MFD driver can be different here.
---
Changes from V1:
- Rename the file to rtc-max77xxx.c and make the generic implementation.
- Direct regmap apis are used for the register access.
- Decouped from max77620 driver.
- Taken care of cleanup comments form V1 version.
drivers/rtc/Kconfig | 10 + drivers/rtc/Makefile | 1 + drivers/rtc/rtc-max77xxx.c | 500 +++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 511 insertions(+) create mode 100644 drivers/rtc/rtc-max77xxx.c
drivers/rtc/Kconfig +10 -0
@@ -315,6 +315,16 @@ config RTC_DRV_MAX8997 This driver can also be built as a module. If so, the module will be called rtc-max8997. +config RTC_DRV_MAX77XXX + tristate "Maxim MAX77XXX series generic RTC driver" + help + If you say yes here you will get support for the generic RTC driver + for Maxim Semiconductor MAX77XXX series of PMIC like MAX77620. + This also supports the RTC driver for Maxim PMIC MaX20024 which + is almost same as MAX77620. + This driver can also be built as a module. If so, the module + will be called rtc-max77xxx. + config RTC_DRV_MAX77686 tristate "Maxim MAX77686" depends on MFD_MAX77686
drivers/rtc/Makefile +1 -0
@@ -85,6 +85,7 @@ obj-$(CONFIG_RTC_DRV_M48T59) += rtc-m48t59.o obj-$(CONFIG_RTC_DRV_M48T86) += rtc-m48t86.o obj-$(CONFIG_RTC_DRV_MAX6900) += rtc-max6900.o obj-$(CONFIG_RTC_DRV_MAX6902) += rtc-max6902.o +obj-$(CONFIG_RTC_DRV_MAX77XXX) += rtc-max77xxx.o obj-$(CONFIG_RTC_DRV_MAX77686) += rtc-max77686.o obj-$(CONFIG_RTC_DRV_MAX77802) += rtc-max77802.o obj-$(CONFIG_RTC_DRV_MAX8907) += rtc-max8907.o
drivers/rtc/rtc-max77xxx.c new file +500 -0
500 lines not on this page · raw message
Signature · 1 line
2.1.4
PATCH v2 6/6 regulator: max77620: add regulator driver for max77620/max20024
In reply to Laxman DewanganMAXIM Semiconductor's PMIC, MAX77620 and MAX20024 have the multiple DCDC and LDOs. This supplies the power to different components of the system.
Also these rails has configuration for ramp time, flexible power sequence, slew rate etc.
Add regulator driver to access these rails via regulator APIs.
---
Changes from V1:
- Cleanup code based on comment received on mfd/rtc.
- Avoid duplication on error message.
drivers/regulator/Kconfig | 9 + drivers/regulator/Makefile | 1 + drivers/regulator/max77620-regulator.c | 991 +++++++++++++++++++++++++++++++++ 3 files changed, 1001 insertions(+) create mode 100644 drivers/regulator/max77620-regulator.c
drivers/regulator/Kconfig +9 -0
@@ -343,6 +343,15 @@ config REGULATOR_MAX1586 regulator via I2C bus. The provided regulator is suitable for PXA27x chips to control VCC_CORE and VCC_USIM voltages. +config REGULATOR_MAX77620 + tristate "Maxim 77620/MAX20024 voltage regulator" + depends on MFD_MAX77620 + help + This driver controls Maxim MAX77620 voltage output regulator + via I2C bus. The provided regulator is suitable for Tegra + chip to control Step-Down DC-DC and LDOs. Say Y here to + enable the regulator driver. + config REGULATOR_MAX8649 tristate "Maxim 8649 voltage regulator" depends on I2C
drivers/regulator/Makefile +1 -0
@@ -46,6 +46,7 @@ obj-$(CONFIG_REGULATOR_LP8755) += lp8755.o obj-$(CONFIG_REGULATOR_LTC3589) += ltc3589.o obj-$(CONFIG_REGULATOR_MAX14577) += max14577.o obj-$(CONFIG_REGULATOR_MAX1586) += max1586.o +obj-$(CONFIG_REGULATOR_MAX77620) += max77620-regulator.o obj-$(CONFIG_REGULATOR_MAX8649) += max8649.o obj-$(CONFIG_REGULATOR_MAX8660) += max8660.o obj-$(CONFIG_REGULATOR_MAX8907) += max8907-regulator.o
drivers/regulator/max77620-regulator.c new file +991 -0
991 lines not on this page · raw message
Signature · 1 line
2.1.4
Re: [PATCH V2 5/6] rtc: max77xxx: add RTC driver for Maxim MAX77xxx series RTC IP
In reply to Laxman DewanganQuoted 29 lines · Laxman Dewangan
Maxim Semiconductor's PMIC MAX77620, MAX77686, MAX20024 have same RTC IP on these PMICs.
Add generic MAX77xxxx series RTC driver which can be used as RTC driver for these PMIC and avoids duplication of RTC driver for each PMICs. Their MFD driver can be different here.
Signed-off-by Laxman Dewangan <[email protected]>---
Changes from V1:
- Rename the file tortc-max77xxx.cand make the generic implementation.
- Direct regmap apis are used for the register access.
- Decouped from max77620 driver.
- Taken care of cleanup comments form V1 version.drivers/rtc/Kconfig | 10 + drivers/rtc/Makefile | 1 + drivers/rtc/rtc-max77xxx.c | 500 +++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 511 insertions(+) create mode 100644 drivers/rtc/rtc-max77xxx.cdrivers/rtc/Kconfig +0
-0@@ -315,6 +315,16 @@ config RTC_DRV_MAX8997 This driver can also be built as a module. If so, the module will be called rtc-max8997.
drivers/rtc/Kconfig config RTC_DRV_MAX8997 · line 327
Quoted 10 lines
drivers/rtc/Kconfig +10
-0+config RTC_DRV_MAX77XXX + tristate "Maxim MAX77XXX series generic RTC driver" + help + If you say yes here you will get support for the generic RTC driver + for Maxim Semiconductor MAX77XXX series of PMIC like MAX77620. + This also supports the RTC driver for Maxim PMIC MaX20024 which + is almost same as MAX77620. + This driver can also be built as a module. If so, the module + will be called rtc-max77xxx. +
That was not the consensus... You still added a new driver - but now with different name.
That is useless duplication
Please work with existing code. Use existing maxim RTC drivers: either max77686 or max77802.
There is no need for new one.
Best regards,
Krzysztof
Re: [PATCH V2 2/6] mfd: max77620: add core driver for MAX77620/MAX20024
In reply to Laxman DewanganQuoted 747 lines · Laxman Dewangan
MAX77620/MAX20024 are Power Management IC from the MAXIM. It supports RTC, multiple GPIOs, multiple DCDC and LDOs, watchdog, clock etc.
Add MFD drier to provides common support for accessing the device; additional drivers is developed on respected subsystem in order to use the functionality of the device.
Signed-off-by Laxman Dewangan <[email protected]>Signed-off-by Chaitanya Bandi <[email protected]>Signed-off-by Mallikarjun Kasoju <[email protected]>---
- Code cleanups per review from V1.
- Move register acccess APIs from header to c file.
- Remove some of non required variable, remove duplication in error message and simplify some of function implementation.
- Register RTC driver such that it can get the regmap handle form parent devicedrivers/mfd/Kconfig | 15 + drivers/mfd/Makefile | 1 + drivers/mfd/max77620.c | 997 +++++++++++++++++++++++++++++++++++++++++++ include/linux/mfd/max77620.h | 407 ++++++++++++++++++ 4 files changed, 1420 insertions(+) create mode 100644 drivers/mfd/max77620.c create mode 100644 include/linux/mfd/max77620.hdrivers/mfd/Kconfig +15
-0@@ -492,6 +492,21 @@ config MFD_MAX14577 additional drivers must be enabled in order to use the functionality of the device. +config MFD_MAX77620 + bool "Maxim Semiconductor MAX77620 and MAX20024 PMIC Support" + depends on I2C=y + depends on OF + select MFD_CORE + select REGMAP_I2C + select REGMAP_IRQ + select IRQ_DOMAIN + help + Say yes here to add support for Maxim Semiconductor MAX77620 and + MAX20024 which are Power Management IC with General purpose pins, + RTC, regulators, clock generator, watchdog etc. This driver + provides common support for accessing the device; additional drivers + must be enabled in order to use the functionality of the device. + config MFD_MAX77686 bool "Maxim Semiconductor MAX77686/802 PMIC Support" depends on I2C=ydrivers/mfd/Makefile +1
-0@@ -123,6 +123,7 @@ obj-$(CONFIG_MFD_DA9063) += da9063.o obj-$(CONFIG_MFD_DA9150) += da9150-core.o obj-$(CONFIG_MFD_MAX14577) += max14577.o +obj-$(CONFIG_MFD_MAX77620) += max77620.o obj-$(CONFIG_MFD_MAX77686) += max77686.o obj-$(CONFIG_MFD_MAX77693) += max77693.o obj-$(CONFIG_MFD_MAX77843) += max77843.odrivers/mfd/max77620.c new file +677
-0@@ -0,0 +1,997 @@ +/* +* Maxim MAX77620 MFD Driver +* +* Copyright (C) 2016 NVIDIA CORPORATION. All rights reserved. +* +* Author: +* Laxman Dewangan <[email protected]> +* Chaitanya Bandi <[email protected]> +* Mallikarjun Kasoju <[email protected]> +* +* This program is free software; you can redistribute it and/or modify it +* under the terms and conditions of the GNU General Public License, +* version 2, as published by the Free Software Foundation. +* +* This program is distributed in the hope it will be useful, but WITHOUT +* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for +* more details. +*/ + +#include <linux/module.h> +#include <linux/i2c.h> +#include <linux/slab.h> +#include <linux/mfd/core.h> +#include <linux/interrupt.h> +#include <linux/regmap.h> +#include <linux/of.h> +#include <linux/of_device.h> +#include <linux/mfd/max77620.h> + +static struct resource gpio_resources[] = { + { + .start =MAX77620_IRQ_TOP_GPIO , + .end =MAX77620_IRQ_TOP_GPIO , + .flags =IORESOURCE_IRQ , + } +}; + +static struct resource rtc_resources[] = { + { + .start =MAX77620_IRQ_TOP_RTC , + .end =MAX77620_IRQ_TOP_RTC , + .flags =IORESOURCE_IRQ , + } +}; + +static struct resource thermal_resources[] = { + { + .start =MAX77620_IRQ_LBT_TJALRM1 , + .end =MAX77620_IRQ_LBT_TJALRM1 , + .flags =IORESOURCE_IRQ , + }, + { + .start =MAX77620_IRQ_LBT_TJALRM2 , + .end =MAX77620_IRQ_LBT_TJALRM2 , + .flags =IORESOURCE_IRQ , + } +}; + +static const struct regmap_irq max77620_top_irqs[] = { + [MAX77620_IRQ_TOP_GLBL ] = { + .mask =MAX77620_IRQ_TOP_GLBL_MASK , + .reg_offset =0 , + }, + [MAX77620_IRQ_TOP_SD ] = { + .mask =MAX77620_IRQ_TOP_SD_MASK , + .reg_offset =0 , + }, + [MAX77620_IRQ_TOP_LDO ] = { + .mask =MAX77620_IRQ_TOP_LDO_MASK , + .reg_offset =0 , + }, + [MAX77620_IRQ_TOP_GPIO ] = { + .mask =MAX77620_IRQ_TOP_GPIO_MASK , + .reg_offset =0 , + }, + [MAX77620_IRQ_TOP_RTC ] = { + .mask =MAX77620_IRQ_TOP_RTC_MASK , + .reg_offset =0 , + }, + [MAX77620_IRQ_TOP_32K ] = { + .mask =MAX77620_IRQ_TOP_32K_MASK , + .reg_offset =0 , + }, + [MAX77620_IRQ_TOP_ONOFF ] = { + .mask =MAX77620_IRQ_TOP_ONOFF_MASK , + .reg_offset =0 , + }, + + [MAX77620_IRQ_LBT_MBATLOW ] = { + .mask =MAX77620_IRQ_LBM_MASK , + .reg_offset =1 , + }, + [MAX77620_IRQ_LBT_TJALRM1 ] = { + .mask =MAX77620_IRQ_TJALRM1_MASK , + .reg_offset =1 , + }, + [MAX77620_IRQ_LBT_TJALRM2 ] = { + .mask =MAX77620_IRQ_TJALRM2_MASK , + .reg_offset =1 , + }, + +}; + +static const char *const max77620_nverc[] = { +"Shutdown-pin" , +"System WatchDog Timer" , +"Hard Reset" , +"Junction Temp Overload" , +"Main-Battery Low" , +"Main-Battery overvoltage Lockout" , +"Main-Battery undervoltage Lockout" , +"Reset input" , +}; + +enum max77660_ids { +MAX77620_PMIC_ID , +MAX77620_GPIO_ID , +MAX77620_PINCTRL_ID , +MAX77620_CLK_ID , +MAX77620_POWER_OFF_ID , +MAX77620_WDT_ID , +MAX77620_THERMAL_ID , +MAX77620_RTC_ID , +}; + +#define MAX77620_SUB_MODULE_RES (_name, _id) \ + [MAX77620_##_id##_ID] = { \ + .name = "max77620-"#_name, \ + .num_resources = ARRAY_SIZE(_name##_resources), \ + .resources = &_name##_resources[0], \ + .id = MAX77620_##_id##_ID, \ + } + +#define MAX20024_SUB_MODULE_RES (_name, _id) \ + [MAX77620_##_id##_ID] = { \ + .name = "max20024-"#_name, \ + .num_resources = ARRAY_SIZE(_name##_resources), \ + .resources = &_name##_resources[0], \ + .id = MAX77620_##_id##_ID, \ + } + +#define MAX77620_SUB_MODULE_NO_RES (_name, _id) \ + [MAX77620_##_id##_ID] = { \ + .name = "max77620-"#_name, \ + .id = MAX77620_##_id##_ID, \ + } + +#define MAX20024_SUB_MODULE_NO_RES (_name, _id) \ + [MAX77620_##_id##_ID] = { \ + .name = "max20024-"#_name, \ + .id = MAX77620_##_id##_ID, \ + } + +static struct mfd_cell max77620_children[] = { +MAX77620_SUB_MODULE_RES (gpio,GPIO ), +MAX77620_SUB_MODULE_NO_RES (pmic,PMIC ), +MAX77620_SUB_MODULE_NO_RES (pinctrl,PINCTRL ), +MAX77620_SUB_MODULE_NO_RES (clk,CLK ), +MAX77620_SUB_MODULE_NO_RES (power-off,POWER_OFF ), +MAX77620_SUB_MODULE_NO_RES (wdt,WDT ), +MAX77620_SUB_MODULE_RES (thermal,THERMAL ), +}; + +static struct mfd_cell max20024_children[] = { +MAX20024_SUB_MODULE_RES (gpio,GPIO ), +MAX20024_SUB_MODULE_NO_RES (pmic,PMIC ), +MAX20024_SUB_MODULE_NO_RES (pinctrl,PINCTRL ), +MAX20024_SUB_MODULE_NO_RES (clk,CLK ), +MAX20024_SUB_MODULE_NO_RES (power-off,POWER_OFF ), +MAX20024_SUB_MODULE_NO_RES (wdt,WDT ), +MAX20024_SUB_MODULE_RES (thermal,THERMAL ), +}; + +static struct mfd_cell max77620_20024_rtc = { + .name ="max77620-rtc" , + .num_resources =ARRAY_SIZE (rtc_resources), + .resources = rtc_resources, + .id =MAX77620_RTC_ID , +}; + +struct max77620_sub_modules { +struct mfd_cell *cells; +int ncells; +u32 id; +}; + +static const struct max77620_sub_modules max77620_cells = { + .cells = max77620_children, + .ncells =ARRAY_SIZE (max77620_children), + .id =MAX77620 , +}; + +static const struct max77620_sub_modules max20024_cells = { + .cells = max20024_children, + .ncells =ARRAY_SIZE (max20024_children), + .id =MAX20024 , +}; + + +static const struct of_device_id max77620_of_match[] = { + { + .compatible ="maxim,max77620" , + .data = &max77620_cells, + }, { + .compatible ="maxim,max20024" , + .data = &max20024_cells, + }, { + }, +}; +MODULE_DEVICE_TABLE (of, max77620_of_match); + +static struct regmap_irq_chip max77620_top_irq_chip = { + .name ="max77620-top" , + .irqs = max77620_top_irqs, + .num_irqs =ARRAY_SIZE (max77620_top_irqs), + .num_regs =2 , + .status_base =MAX77620_REG_IRQTOP , + .mask_base =MAX77620_REG_IRQTOPM , +}; + +static const struct regmap_range max77620_readable_ranges[] = { +regmap_reg_range (MAX77620_REG_CNFGGLBL1 ,MAX77620_REG_DVSSD4 ), +}; + +static const struct regmap_access_table max77620_readable_table = { + .yes_ranges = max77620_readable_ranges, + .n_yes_ranges =ARRAY_SIZE (max77620_readable_ranges), +}; + +static const struct regmap_range max20024_readable_ranges[] = { +regmap_reg_range (MAX77620_REG_CNFGGLBL1 ,MAX77620_REG_DVSSD4 ), +regmap_reg_range (MAX20024_REG_MAX_ADD ,MAX20024_REG_MAX_ADD ), +}; + +static const struct regmap_access_table max20024_readable_table = { + .yes_ranges = max20024_readable_ranges, + .n_yes_ranges =ARRAY_SIZE (max20024_readable_ranges), +}; + +static const struct regmap_range max77620_writable_ranges[] = { +regmap_reg_range (MAX77620_REG_CNFGGLBL1 ,MAX77620_REG_DVSSD4 ), +}; + +static const struct regmap_access_table max77620_writable_table = { + .yes_ranges = max77620_writable_ranges, + .n_yes_ranges =ARRAY_SIZE (max77620_writable_ranges), +}; + +static const struct regmap_range max77620_cacheable_ranges[] = { +regmap_reg_range (MAX77620_REG_SD0_CFG ,MAX77620_REG_LDO_CFG3 ), +regmap_reg_range (MAX77620_REG_FPS_CFG0 ,MAX77620_REG_FPS_SD3 ), +}; + +static const struct regmap_access_table max77620_volatile_table = { + .no_ranges = max77620_cacheable_ranges, + .n_no_ranges =ARRAY_SIZE (max77620_cacheable_ranges), +}; + +static const struct regmap_config max77620_regmap_config[] = { + [MAX77620_PWR_SLAVE ] = { + .name ="power-slave" , + .reg_bits =8 , + .val_bits =8 , + .max_register =MAX77620_REG_DVSSD4 +1 , + .cache_type =REGCACHE_RBTREE , + .rd_table = &max77620_readable_table, + .wr_table = &max77620_writable_table, + .volatile_table = &max77620_volatile_table, + }, + [MAX77620_RTC_SLAVE ] = { + .name ="rtc-slave" , + .reg_bits =8 , + .val_bits =8 , + .max_register =0x1b , + }, +}; + +static const struct regmap_config max20024_regmap_config[] = { + [MAX77620_PWR_SLAVE ] = { + .name ="power-slave" , + .reg_bits =8 , + .val_bits =8 , + .max_register =MAX20024_REG_MAX_ADD +1 , + .cache_type =REGCACHE_RBTREE , + .rd_table = &max20024_readable_table, + .wr_table = &max77620_writable_table, + .volatile_table = &max77620_volatile_table, + }, + [MAX77620_RTC_SLAVE ] = { + .name ="rtc-slave" , + .reg_bits =8 , + .val_bits =8 , + .max_register =0x1b , + }, +}; + +static int max77620_slave_address[MAX77620_NUM_SLAVES ] = { +MAX77620_PWR_I2C_ADDR , +MAX77620_RTC_I2C_ADDR , +}; + +int max77620_irq_get_virq (struct device *dev,int irq) +{ +struct max77620_chip *chip =dev_get_drvdata (dev); + +return regmap_irq_get_virq (chip->top_irq_data, irq); +} +EXPORT_SYMBOL_GPL (max77620_irq_get_virq); + +int max77620_reg_write (struct device *dev,int sid, +unsigned int reg,u8 val) +{ +struct max77620_chip *chip =dev_get_drvdata (dev); + +return regmap_write (chip->rmap[sid], reg, val); +} +EXPORT_SYMBOL_GPL (max77620_reg_write); + +int max77620_reg_read (struct device *dev,int sid, +unsigned int reg,u8 *val) +{ +struct max77620_chip *chip =dev_get_drvdata (dev); +unsigned int ival; +int ret; + + ret =regmap_read (chip->rmap[sid], reg, &ival); +if (ret <0 ) +return ret; + *val = ival; + +return 0 ; +} +EXPORT_SYMBOL_GPL (max77620_reg_read); + +int max77620_reg_update (struct device *dev,int sid, +unsigned int reg,unsigned int mask,unsigned int val) +{ +struct max77620_chip *chip =dev_get_drvdata (dev); + +return regmap_update_bits (chip->rmap[sid], reg, mask, val); +} +EXPORT_SYMBOL_GPL (max77620_reg_update); + +static int max77620_get_fps_period_reg_value (struct max77620_chip *chip, +int tperiod) +{ +int base_fps_time = (chip->id ==MAX20024 ) ?20 :40 ; +int x, i; + +for (i =0 ; i <0x7 ; ++i) { + x = base_fps_time *BIT (i); +if (x >= tperiod) +return i; + } + +return i; +} + +static int max77620_config_fps (struct max77620_chip *chip, +struct device_node *fps_np) +{ +struct device *dev = chip->dev; +unsigned int mask =0 , config =0 ; +int input_enable =2 ; +u32 pval; +int tperiod, fps_id; +int ret; + + ret =of_property_read_u32 (fps_np,"reg" , &pval); +if (ret <0 ) { +dev_err (dev,"reg prop missing from node %s\n" , fps_np->name); +return 0 ; + } +if (pval >2 ) { +dev_err (dev,"FPS%u is not supported\n" , pval); +return 0 ; + } + fps_id = pval; + + ret =of_property_read_u32 (fps_np, +"maxim,active-fps-time-period" , &pval); +if (!ret) { + mask |=MAX77620_FPS_TIME_PERIOD_MASK ; + chip->active_fps_period[fps_id] =min (pval,5120U ); + tperiod =max77620_get_fps_period_reg_value (chip, + chip->active_fps_period[fps_id]); + config |= tperiod <<MAX77620_FPS_TIME_PERIOD_SHIFT ; + } + + ret =of_property_read_u32 (fps_np, +"maxim,suspend-fps-time-period" , &pval); +if (!ret) + chip->suspend_fps_period[fps_id] =min (pval,5120U ); + + ret =of_property_read_u32 (fps_np,"maxim,fps-enable-input" , &pval); +if (!ret) { +if (pval >2 ) { +dev_err (dev,"FPS %d enable-input invalid\n" , fps_id); + }else { + input_enable = pval; + mask |=MAX77620_FPS_EN_SRC_MASK ; + } + } + config |= (input_enable &0x3 ) <<MAX77620_FPS_EN_SRC_SHIFT ; + +if (input_enable ==2 ) { +bool enable_fps =of_property_read_bool (fps_np, +"maxim,fps-sw-enable" ); + mask |=MAX77620_FPS_ENFPS_MASK ; +if (enable_fps) + config |=1 ; + } + +if (!chip->sleep_enable) + chip->sleep_enable =of_property_read_bool (fps_np, +"maxim,enable-sleep" ); +if (!chip->enable_global_lpm) + chip->enable_global_lpm =of_property_read_bool (fps_np, +"maxim,enable-global-lpm" ); + + ret =max77620_reg_update (dev,MAX77620_PWR_SLAVE , +MAX77620_REG_FPS_CFG0 + fps_id, mask, config); +if (ret <0 ) { +dev_err (dev,"Reg 0x%02x write failed: %d\n" , +MAX77620_REG_FPS_CFG0 + fps_id, ret); +return ret; + } + +return 0 ; +} + +static int max77620_initialise_fps (struct max77620_chip *chip, +struct device *dev) +{ +struct device_node *fps_np, *fps_child; +u8 config; +int fps_id; +int ret; + +for (fps_id =0 ; fps_id <3 ; ++fps_id) { + chip->active_fps_period[fps_id] =-1 ; + chip->suspend_fps_period[fps_id] =-1 ; + } + + fps_np =of_get_child_by_name (dev->of_node,"fps" ); +if (!fps_np) + goto skip_fps; + +for_each_child_of_node (fps_np, fps_child) { + ret =max77620_config_fps (chip, fps_child); +if (ret <0 ) +return ret; + } + + config = chip->enable_global_lpm ?MAX77620_ONOFFCNFG2_SLP_LPM_MSK :0 ; + ret =max77620_reg_update (chip->dev,MAX77620_PWR_SLAVE , +MAX77620_REG_ONOFFCNFG2 , +MAX77620_ONOFFCNFG2_SLP_LPM_MSK , config); +if (ret <0 ) { +dev_err (dev,"Reg ONOFFCNFG2 update failed: %d\n" , ret); +return ret; + } + +skip_fps: +/* Enable wake on EN0 pin */ + ret =max77620_reg_update (chip->dev,MAX77620_PWR_SLAVE , +MAX77620_REG_ONOFFCNFG2 ,MAX77620_ONOFFCNFG2_WK_EN0 , +MAX77620_ONOFFCNFG2_WK_EN0 ); +if (ret <0 ) { +dev_err (dev,"Reg ONOFFCNFG2 WK_EN0 update failed: %d\n" , ret); +return ret; + } + +if (!chip->sleep_enable) + chip->sleep_enable =of_property_read_bool (dev->of_node, +"maxim,enable-sleep" ); + +/* For MAX20024, SLPEN will be POR reset if CLRSE is b11 */ +if ((chip->id ==MAX20024 ) && chip->sleep_enable) { + config =MAX77620_ONOFFCNFG1_SLPEN |MAX20024_ONOFFCNFG1_CLRSE ; + ret =max77620_reg_update (chip->dev,MAX77620_PWR_SLAVE , +MAX77620_REG_ONOFFCNFG1 , config, config); +if (ret <0 ) { +dev_err (dev,"Reg ONOFFCNFG1 update failed: %d\n" , ret); +return ret; + } + } + +return 0 ; +} + +static int max77620_init_backup_battery_charging (struct max77620_chip *chip, +struct device *dev) +{ +struct device_node *bb_node; +u32 pval; +u8 config; +int ret; + + bb_node =of_get_child_by_name (dev->of_node,"backup-battery" ); +if (!bb_node) { +dev_info (dev,"Backup battery charging support disabled\n" ); +max77620_reg_update (chip->dev,MAX77620_PWR_SLAVE , +MAX77620_REG_CNFGBBC ,MAX77620_CNFGBBC_ENABLE ,0 ); +return 0 ; + } + + config =MAX77620_CNFGBBC_ENABLE ; + ret =of_property_read_u32 (bb_node, +"maxim,bb-charging-current-microamp" , &pval); +if (ret <0 ) + pval =50 ; +if (pval <=50 ) + config |=0 <<MAX77620_CNFGBBC_CURRENT_SHIFT ; +else if (pval <=100 ) + config |=3 <<MAX77620_CNFGBBC_CURRENT_SHIFT ; +else if (pval <=200 ) + config |=0 <<MAX77620_CNFGBBC_CURRENT_SHIFT ; +else if (pval <=400 ) + config |=3 <<MAX77620_CNFGBBC_CURRENT_SHIFT ; +else if (pval <=600 ) + config |=1 <<MAX77620_CNFGBBC_CURRENT_SHIFT ; +else + config |=2 <<MAX77620_CNFGBBC_CURRENT_SHIFT ; + +if (pval >100 ) + config |=MAX77620_CNFGBBC_LOW_CURRENT_DISABLE ; + + ret =of_property_read_u32 (bb_node, +"maxim,bb-charging-voltage-microvolt" , &pval); +if (ret <0 ) + pval =2500000 ; + pval /=1000 ; +if (pval <=2500 ) + config |=0 <<MAX77620_CNFGBBC_VOLTAGE_SHIFT ; +else if (pval <=3000 ) + config |=1 <<MAX77620_CNFGBBC_VOLTAGE_SHIFT ; +else if (pval <=3300 ) + config |=2 <<MAX77620_CNFGBBC_VOLTAGE_SHIFT ; +else + config |=3 <<MAX77620_CNFGBBC_VOLTAGE_SHIFT ; + + ret =of_property_read_u32 (bb_node, +"maxim,bb-output-resister-ohm" , &pval); +if (ret <0 ) + pval =1000 ; + +if (pval <=100 ) + config |=0 <<MAX77620_CNFGBBC_RESISTOR_SHIFT ; +else if (pval <=1000 ) + config |=1 <<MAX77620_CNFGBBC_RESISTOR_SHIFT ; +else if (pval <=3000 ) + config |=2 <<MAX77620_CNFGBBC_RESISTOR_SHIFT ; +else if (pval <=6000 ) + config |=3 <<MAX77620_CNFGBBC_RESISTOR_SHIFT ; + + ret =max77620_reg_write (dev,MAX77620_PWR_SLAVE , +MAX77620_REG_CNFGBBC , config); +if (ret <0 ) { +dev_err (dev,"Reg 0x%02x write failed: %d\n" , +MAX77620_REG_CNFGBBC , ret); +return ret; + } + +return 0 ; +} + +static int max77620_init_low_battery_monitor (struct max77620_chip *chip, +struct device *dev) +{ +struct device_node *np; +u8 mask =0 , val =0 ; +u32 pval; +int ret; + + np =of_get_child_by_name (dev->of_node,"low-battery-monitor" ); +if (!np) +return 0 ; + + ret =of_property_read_u32 (np,"maxim,low-battery-dac" , &pval); +if (!ret) { + mask |=MAX77620_CNFGGLBL1_LBDAC_EN ; +if (pval) + val |=MAX77620_CNFGGLBL1_LBDAC_EN ; + } + + ret =of_property_read_u32 (np,"maxim,low-battery-shutdown" , &pval); +if (!ret) { + mask |=MAX77620_CNFGGLBL1_MPPLD ; +if (pval) + val |=MAX77620_CNFGGLBL1_MPPLD ; + } + + ret =of_property_read_u32 (np,"maxim,low-battery-reset" , &pval); +if (!ret) { + mask |=MAX77620_CNFGGLBL1_LBRSTEN ; +if (pval) + val |=MAX77620_CNFGGLBL1_LBRSTEN ; + } + +if (mask) { + ret =max77620_reg_update (dev,MAX77620_PWR_SLAVE , +MAX77620_REG_CNFGGLBL1 , mask, val); +if (ret <0 ) +dev_err (dev,"Reg CNFGGLBL1 update failed: %d\n" , ret); +return ret; + } + +return 0 ; +} + +static int max77620_initialise_chip (struct max77620_chip *chip, +struct device *dev) +{ +struct device_node *np = dev->of_node; +u32 mrt_time =0 ; +u8 reg_val; +int ret; + + ret =of_property_read_u32 (np,"maxim,hard-power-off-time" , &mrt_time); +if (ret <0 ) +return 0 ; + + mrt_time = (mrt_time >12 ) ?12 : mrt_time; +if (mrt_time <=6 ) + reg_val = mrt_time -2 ; +else + reg_val = (mrt_time -6 ) /2 +4 ; + + reg_val <<=MAX77620_ONOFFCNFG1_MRT_SHIFT ; + + ret =max77620_reg_update (dev,MAX77620_PWR_SLAVE , +MAX77620_REG_ONOFFCNFG1 ,MAX77620_ONOFFCNFG1_MRT_MASK , + reg_val); +if (ret <0 ) { +dev_err (dev,"REG ONOFFCNFG1 update failed: %d\n" , ret); +return ret; + } + +/* Disable alarm wake to enable sleep from EN input signal */ + ret =max77620_reg_update (dev,MAX77620_PWR_SLAVE , +MAX77620_REG_ONOFFCNFG2 ,MAX77620_ONOFFCNFG2_WK_ALARM1 ,0 ); +if (ret <0 ) { +dev_err (dev,"REG ONOFFCNFG2 update failed: %d\n" , ret); +return ret; + } + +return ret; +} + +static int max77620_read_es_version (struct max77620_chip *chip) +{ +u8 val, cid_val[6 ]; +int i; +int ret; + +for (i =MAX77620_REG_CID0 ; i <=MAX77620_REG_CID5 ; ++i) { + ret =max77620_reg_read (chip->dev,MAX77620_PWR_SLAVE , i, &val); +if (ret <0 ) { +dev_err (chip->dev,"CID%d register read failed: %d\n" , + i -MAX77620_REG_CID0 , ret); +return ret; + } +dev_dbg (chip->dev,"CID%d: 0x%02x\n" , + i -MAX77620_REG_CID0 , val); + cid_val[i -MAX77620_REG_CID0 ] = val; + } + +/* CID4 is OTP Version */ +dev_info (chip->dev,"MAX77620 PMIC OTP Version: 0x%02X\n" , cid_val[4 ]); + +/* CID5 is ES version */ +dev_info (chip->dev,"MAX77620 PMIC ES version: 1.%d\n" , +MAX77620_CID5_DIDM (cid_val[5 ])); + +/* Read NVERC register */
drivers/mfd/max77620.c line 687
Quoted 10 lines
drivers/mfd/max77620.c new file +10
-0+ ret =max77620_reg_read (chip->dev,MAX77620_PWR_SLAVE , +MAX77620_REG_NVERC , &val); +if (ret <0 ) { +dev_err (chip->dev,"NVERC read failed: %d\n" , ret); +return ret; + } +dev_dbg (chip->dev,"NVERC = 0x%02x\n" , val); +for (i =0 ; i <8 ; ++i) { +if (val &BIT (i)) +dev_info (chip->dev,"NVERC: %s\n" , max77620_nverc[i]);
You are still printing two dev_info (OTP, ES) and here NVERC (probably one?). This will be printed on each boot, over and over, till the user will learn it and will remember it forever :).
Quoted 1 line
From my point of view: one
dev_infofor one probed device.
I don't know if others agree with that, though. What's your opinion Lee?
Quoted 22 lines
drivers/mfd/max77620.c new file +22
-0+ } + +return ret; +} + +static irqreturn_t max77620_mbattlow_irq (int irq,void *data) +{ +struct max77620_chip *max77620 = data; + +dev_dbg (max77620->dev,"MBATTLOW interrupt occurred\n" ); + +return IRQ_HANDLED ; +} + +static int max77620_probe (struct i2c_client *client, +const struct i2c_device_id *id) +{ +struct device_node *node = client->dev.of_node; +const struct max77620_sub_modules *children; +const struct of_device_id *match; +const struct regmap_config *rmap_config = max77620_regmap_config; +struct max77620_chip *chip;
drivers/mfd/max77620.c line 719
Quoted 10 lines
drivers/mfd/max77620.c new file +10
-0+int i =0 ; +int ret =0 ; + +if (!node) { +dev_err (&client->dev,"Device is not from DT\n" ); +return -ENODEV ; + } + + match =of_match_device (max77620_of_match, &client->dev); + children = match->data;
You can just use of_device_get_match_data() thus removing "match" variable.
Quoted 42 lines
drivers/mfd/max77620.c new file +42
-0+if (!children) +return -ENODEV ; + + chip =devm_kzalloc (&client->dev,sizeof (*chip),GFP_KERNEL ); +if (!chip) +return -ENOMEM ; + +i2c_set_clientdata (client, chip); + chip->dev = &client->dev; + chip->irq_base =-1 ; + chip->chip_irq = client->irq; + chip->id = children->id; + +if (chip->id ==MAX20024 ) + rmap_config = max20024_regmap_config; + +mutex_init (&chip->mutex_config); + +for (i =0 ; i <MAX77620_NUM_SLAVES ; i++) { +if (max77620_slave_address[i] == client->addr) + chip->clients[i] = client; +else + chip->clients[i] =i2c_new_dummy (client->adapter, + max77620_slave_address[i]); +if (!chip->clients[i]) { +dev_err (&client->dev,"can't attach client %d\n" , i); + ret = -ENOMEM ; + goto fail_client_reg; + } + + chip->clients[i]->dev.of_node = node; +i2c_set_clientdata (chip->clients[i], chip); + chip->rmap[i] =devm_regmap_init_i2c (chip->clients[i], + &rmap_config[i]); +if (IS_ERR (chip->rmap[i])) { + ret =PTR_ERR (chip->rmap[i]); +dev_err (&client->dev, +"regmap %d init failed, err %d\n" , i, ret); + goto fail_client_reg; + } + } +
drivers/mfd/max77620.c line 771
Quoted 10 lines
drivers/mfd/max77620.c new file +10
-0+ ret =max77620_read_es_version (chip); +if (ret <0 ) + goto fail_client_reg; + + ret =max77620_initialise_chip (chip, &client->dev); +if (ret <0 ) + goto fail_client_reg; + + ret = regmap_add_irq_chip(chip->rmap[MAX77620_PWR_SLAVE], + chip->chip_irq, IRQF_ONESHOT | IRQF_SHARED, chip->irq_base,
Why do you need IRQF_SHARED?
drivers/mfd/max77620.c line 772
Quoted 1 line
drivers/mfd/max77620.c new file +1
-0+ &max77620_top_irq_chip, &chip->top_irq_data);
More tabs needed for indentation of arguments.
Actually the alignment of arguments here is mixed. Sometimes arguments are aligned with opening parenthesis, mostly not. Can you make it consistent - always aligned?
Thank you for implementing the comments pointed for v1. Overall the MFD part here looks good for me.
Best regards,
Krzysztof
Re: [PATCH V2 6/6] regulator: max77620: add regulator driver for max77620/max20024
In reply to Laxman DewanganQuoted 71 lines · Laxman Dewangan
MAXIM Semiconductor's PMIC, MAX77620 and MAX20024 have the multiple DCDC and LDOs. This supplies the power to different components of the system.
Also these rails has configuration for ramp time, flexible power sequence, slew rate etc.Add regulator driver to access these rails via regulator APIs.
Signed-off-by Laxman Dewangan <[email protected]>Signed-off-by Mallikarjun Kasoju <[email protected]>---
Changes from V1:
- Cleanup code based on comment received on mfd/rtc.
- Avoid duplication on error message.drivers/regulator/Kconfig | 9 + drivers/regulator/Makefile | 1 + drivers/regulator/max77620-regulator.c | 991 +++++++++++++++++++++++++++++++++ 3 files changed, 1001 insertions(+) create mode 100644 drivers/regulator/max77620-regulator.cdrivers/regulator/Kconfig +9
-0@@ -343,6 +343,15 @@ config REGULATOR_MAX1586 regulator via I2C bus. The provided regulator is suitable for PXA27x chips to control VCC_CORE and VCC_USIM voltages. +config REGULATOR_MAX77620 + tristate "Maxim 77620/MAX20024 voltage regulator" + depends on MFD_MAX77620 + help + This driver controls Maxim MAX77620 voltage output regulator + via I2C bus. The provided regulator is suitable for Tegra + chip to control Step-Down DC-DC and LDOs. Say Y here to + enable the regulator driver. + config REGULATOR_MAX8649 tristate "Maxim 8649 voltage regulator" depends on I2Cdrivers/regulator/Makefile +1
-0@@ -46,6 +46,7 @@ obj-$(CONFIG_REGULATOR_LP8755) += lp8755.o obj-$(CONFIG_REGULATOR_LTC3589) += ltc3589.o obj-$(CONFIG_REGULATOR_MAX14577) += max14577.o obj-$(CONFIG_REGULATOR_MAX1586) += max1586.o +obj-$(CONFIG_REGULATOR_MAX77620) += max77620-regulator.o obj-$(CONFIG_REGULATOR_MAX8649) += max8649.o obj-$(CONFIG_REGULATOR_MAX8660) += max8660.o obj-$(CONFIG_REGULATOR_MAX8907) += max8907-regulator.odrivers/regulator/max77620-regulator.c new file +12
-0@@ -0,0 +1,991 @@ +/* +* Maxim MAX77620 Regulator driver +* +* Copyright (c) 2016, NVIDIA CORPORATION. All rights reserved. +* +* Author: Mallikarjun Kasoju <[email protected]> +* Laxman Dewangan <[email protected]> +* +* This program is free software; you can redistribute it and/or modify it +* under the terms and conditions of the GNU General Public License, +* version 2, as published by the Free Software Foundation. +*
drivers/regulator/max77620-regulator.c line 22
Quoted 10 lines
drivers/regulator/max77620-regulator.c new file +10
-0+* This program is distributed in the hope it will be useful, but WITHOUT +* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for +* more details. +*/ + +#include <linux/init.h> +#include <linux/module.h> +#include <linux/kernel.h> +#include <linux/mfd/core.h>
Do you need kernel.h?mfd/core.h looks unused.
Quoted 49 lines
drivers/regulator/max77620-regulator.c new file +49
-0+#include <linux/mfd/max77620.h> +#include <linux/regulator/driver.h> +#include <linux/regulator/machine.h> +#include <linux/of.h> +#include <linux/regulator/of_regulator.h> + +#define max77620_rails (_name) "max77620-"#_name + +/* Power Mode */ +#define MAX77620_POWER_MODE_NORMAL 3 +#define MAX77620_POWER_MODE_LPM 2 +#define MAX77620_POWER_MODE_GLPM 1 +#define MAX77620_POWER_MODE_DISABLE 0 + +/* SD Slew Rate */ +#define MAX77620_SD_SR_13_75 0 +#define MAX77620_SD_SR_27_5 1 +#define MAX77620_SD_SR_55 2 +#define MAX77620_SD_SR_100 3 + +#define MAX77620_FPS_SRC_NUM 3 + +struct max77620_regulator_info { +u8 type; +u32 min_uV; +u32 max_uV; +u32 step_uV; +u8 fps_addr; +u8 volt_addr; +u8 cfg_addr; +u8 volt_mask; +u8 power_mode_mask; +u8 power_mode_shift; +u8 remote_sense_addr; +u8 remote_sense_mask; +struct regulator_desc desc; +}; + +struct max77620_regulator_pdata { +bool glpm_enable; +bool en2_ctrl_sd0; +bool sd_fsrade_disable; +bool disable_remote_sense_on_suspend; +struct regulator_init_data *reg_idata; +int active_fps_src; +int active_fps_pd_slot; +int active_fps_pu_slot; +int suspend_fps_src; +int suspend_fps_pd_slot;
drivers/regulator/max77620-regulator.c line 81
Quoted 10 lines
drivers/regulator/max77620-regulator.c new file +10
-0+int suspend_fps_pu_slot; +int current_mode; +}; + +struct max77620_regulator { +struct device *dev; +struct max77620_chip *max77620_chip; +struct max77620_regulator_info *rinfo[MAX77620_NUM_REGS ]; +struct max77620_regulator_pdata reg_pdata[MAX77620_NUM_REGS ]; +struct regulator_dev *rdev[MAX77620_NUM_REGS ];
You don't need the rdev. You are not using it anyway.
Quoted 112 lines
drivers/regulator/max77620-regulator.c new file +112
-0+int enable_power_mode[MAX77620_NUM_REGS ]; +int current_power_mode[MAX77620_NUM_REGS ]; +int active_fps_src[MAX77620_NUM_REGS ]; +}; + +#define fps_src_name (fps_src) \ + (fps_src == FPS_SRC_0 ? "FPS_SRC_0" : \ + fps_src == FPS_SRC_1 ? "FPS_SRC_1" : \ + fps_src == FPS_SRC_2 ? "FPS_SRC_2" : "FPS_SRC_NONE") + +static int max77620_regulator_get_fps_src (struct max77620_regulator *reg, +int id) +{ +struct max77620_regulator_info *rinfo = reg->rinfo[id]; +struct device *parent = reg->max77620_chip->dev; +u8 val; +int ret; + + ret =max77620_reg_read (parent,MAX77620_PWR_SLAVE , + rinfo->fps_addr, &val); +if (ret <0 ) { +dev_err (reg->dev,"Reg 0x%02x read failed %d\n" , + rinfo->fps_addr, ret); +return ret; + } + +return (val &MAX77620_FPS_SRC_MASK ) >>MAX77620_FPS_SRC_SHIFT ; +} + +static int max77620_regulator_set_fps_src (struct max77620_regulator *reg, +int fps_src,int id) +{ +struct max77620_regulator_info *rinfo = reg->rinfo[id]; +struct device *parent = reg->max77620_chip->dev; +u8 val; +int ret; + +switch (fps_src) { +case FPS_SRC_0 : +case FPS_SRC_1 : +case FPS_SRC_2 : +case FPS_SRC_NONE : +break ; + +case FPS_SRC_DEF : + ret =max77620_reg_read (parent,MAX77620_PWR_SLAVE , + rinfo->fps_addr, &val); +if (ret <0 ) { +dev_err (reg->dev,"Reg 0x%02x read failed %d\n" , + rinfo->fps_addr, ret); +return ret; + } + ret = (val &MAX77620_FPS_SRC_MASK ) >>MAX77620_FPS_SRC_SHIFT ; + reg->active_fps_src[id] = ret; +return 0 ; + +default : +dev_err (reg->dev,"Invalid FPS %d for regulator %d\n" , + fps_src, id); +return -EINVAL ; + } + + ret =max77620_reg_update (parent,MAX77620_PWR_SLAVE , + rinfo->fps_addr,MAX77620_FPS_SRC_MASK , + fps_src <<MAX77620_FPS_SRC_SHIFT ); +if (ret <0 ) { +dev_err (reg->dev,"Reg 0x%02x update failed %d\n" , + rinfo->fps_addr, ret); +return ret; + } + reg->active_fps_src[id] = fps_src; + +return 0 ; +} + +static int max77620_regulator_set_fps_slots (struct max77620_regulator *reg, +int id,bool is_suspend) +{ +struct max77620_regulator_pdata *rpdata = ®->reg_pdata[id]; +struct max77620_regulator_info *rinfo = reg->rinfo[id]; +struct device *parent = reg->max77620_chip->dev; +unsigned int val =0 ; +unsigned int mask =0 ; +int pu = rpdata->active_fps_pu_slot; +int pd = rpdata->active_fps_pd_slot; +int ret =0 ; + +if (is_suspend) { + pu = rpdata->suspend_fps_pu_slot; + pd = rpdata->suspend_fps_pd_slot; + } + +/* FPS power up period setting */ +if (pu >=0 ) { + val |= (pu <<MAX77620_FPS_PU_PERIOD_SHIFT ); + mask |=MAX77620_FPS_PU_PERIOD_MASK ; + } + +/* FPS power down period setting */ +if (pd >=0 ) { + val |= (pd <<MAX77620_FPS_PD_PERIOD_SHIFT ); + mask |=MAX77620_FPS_PD_PERIOD_MASK ; + } + +if (mask) { + ret =max77620_reg_update (parent,MAX77620_PWR_SLAVE , + rinfo->fps_addr, mask, val); +if (ret <0 ) { +dev_err (reg->dev,"Reg 0x%02x update failed: %d\n" , + rinfo->fps_addr, ret); +return ret; + }
drivers/regulator/max77620-regulator.c line 203
Quoted 10 lines
drivers/regulator/max77620-regulator.c new file +10
-0+ } + +return ret; +} + +static int max77620_regulator_set_power_mode (struct max77620_regulator *reg, +int power_mode,int id) +{ +struct max77620_regulator_info *rinfo = reg->rinfo[id]; +int ret;
Could you put the 'ret' at the end of these variables?
Quoted 22 lines
drivers/regulator/max77620-regulator.c new file +22
-0+struct device *parent = reg->max77620_chip->dev; +u8 mask = rinfo->power_mode_mask; +u8 shift = rinfo->power_mode_shift; +u8 addr; + +switch (rinfo->type) { +case MAX77620_REGULATOR_TYPE_SD : + addr = rinfo->cfg_addr; +break ; +default : + addr = rinfo->volt_addr; +break ; + } + + ret =max77620_reg_update (parent,MAX77620_PWR_SLAVE , + addr, mask, power_mode << shift); +if (ret <0 ) { +dev_err (reg->dev,"Regulator %d mode set failed: %d\n" , + id, ret); +return ret; + } + reg->current_power_mode[id] = power_mode;
drivers/regulator/max77620-regulator.c line 235
Quoted 10 lines
drivers/regulator/max77620-regulator.c new file +10
-0+ +return ret; +} + +static int max77620_regulator_get_power_mode (struct max77620_regulator *reg, +int id) +{ +struct max77620_regulator_info *rinfo = reg->rinfo[id]; +struct device *parent = reg->max77620_chip->dev; +u8 val;
Another nit: 'val' after 'u8 addr'.
Quoted 114 lines
drivers/regulator/max77620-regulator.c new file +114
-0+u8 mask = rinfo->power_mode_mask; +u8 shift = rinfo->power_mode_shift; +u8 addr; +int ret; + +switch (rinfo->type) { +case MAX77620_REGULATOR_TYPE_SD : + addr = rinfo->cfg_addr; +break ; +default : + addr = rinfo->volt_addr; +break ; + } + + ret =max77620_reg_read (parent,MAX77620_PWR_SLAVE , addr, &val); +if (ret <0 ) { +dev_err (reg->dev,"Regulator %d: Reg 0x%02x read failed: %d\n" , + id, addr, ret); +return ret; + } + +return (val & mask) >> shift; +} + +static int max77620_regulator_enable (struct regulator_dev *rdev) +{ +struct max77620_regulator *reg =rdev_get_drvdata (rdev); +int id =rdev_get_id (rdev); +struct max77620_regulator_pdata *rpdata = ®->reg_pdata[id]; + +if (reg->active_fps_src[id] !=FPS_SRC_NONE ) +return 0 ; + +if ((id ==MAX77620_REGULATOR_ID_SD0 ) && rpdata->en2_ctrl_sd0) +return 0 ; + +return max77620_regulator_set_power_mode (reg, + reg->enable_power_mode[id], id); +} + +static int max77620_regulator_disable (struct regulator_dev *rdev) +{ +struct max77620_regulator *reg =rdev_get_drvdata (rdev); +int id =rdev_get_id (rdev); +struct max77620_regulator_pdata *rpdata = ®->reg_pdata[id]; + +if (reg->active_fps_src[id] !=FPS_SRC_NONE ) +return 0 ; + +if ((id ==MAX77620_REGULATOR_ID_SD0 ) && rpdata->en2_ctrl_sd0) +return 0 ; + +return max77620_regulator_set_power_mode (reg, +MAX77620_POWER_MODE_DISABLE , id); +} + +static int max77620_regulator_is_enabled (struct regulator_dev *rdev) +{ +struct max77620_regulator *reg =rdev_get_drvdata (rdev); +int id =rdev_get_id (rdev); +struct max77620_regulator_pdata *rpdata = ®->reg_pdata[id]; +int ret =1 ; + +if (reg->active_fps_src[id] !=FPS_SRC_NONE ) +return 1 ; + +if ((id ==MAX77620_REGULATOR_ID_SD0 ) && rpdata->en2_ctrl_sd0) +return 1 ; + + ret =max77620_regulator_get_power_mode (reg, id); +if (ret <0 ) +return ret; + +if (ret !=MAX77620_POWER_MODE_DISABLE ) +return 1 ; + +return 0 ; +} + +static int max77620_regulator_set_mode (struct regulator_dev *rdev, +unsigned int mode) +{ +struct max77620_regulator *reg =rdev_get_drvdata (rdev); +int id =rdev_get_id (rdev); +struct max77620_regulator_info *rinfo = reg->rinfo[id]; +struct max77620_regulator_pdata *rpdata = ®->reg_pdata[id]; +struct device *parent = reg->max77620_chip->dev; +int power_mode; +int ret; +bool fpwm = false; + +switch (mode) { +case REGULATOR_MODE_FAST : + fpwm = true; + power_mode =MAX77620_POWER_MODE_NORMAL ; +break ; + +case REGULATOR_MODE_NORMAL : + power_mode =MAX77620_POWER_MODE_NORMAL ; +break ; + +case REGULATOR_MODE_IDLE : +if (rpdata->glpm_enable) + power_mode =MAX77620_POWER_MODE_GLPM ; +else + power_mode =MAX77620_POWER_MODE_LPM ; +break ; + +default : +dev_err (reg->dev,"Regulator %d mode %d is invalid\n" , + id, mode); +return -EINVAL ; + } +
drivers/regulator/max77620-regulator.c line 359
Quoted 10 lines
drivers/regulator/max77620-regulator.c new file +10
-0+if (rinfo->type !=MAX77620_REGULATOR_TYPE_SD ) + goto skip_fpwm; + +if (fpwm) + ret =max77620_reg_update (parent,MAX77620_PWR_SLAVE , + rinfo->cfg_addr,MAX77620_SD_FPWM_MASK , +MAX77620_SD_FPWM_MASK ); +else + ret =max77620_reg_update (parent,MAX77620_PWR_SLAVE , + rinfo->cfg_addr,MAX77620_SD_FPWM_MASK ,0 );
Instead something like:
u8 fwpm_val;
if (fpwm)
fwpm_val = MAX77620_SD_FPWM_MASK;
else
fwpm_val = 0;max77620_reg_update(..., fwpm_val);
You could actually combine it with 'fwpm' variable (replacing it) but I am not sure if that would make the code more readable. But definitely one place of calling max77620_reg_update() would be nice.
drivers/regulator/max77620-regulator.c line 369
Quoted 10 lines
drivers/regulator/max77620-regulator.c new file +10
-0+if (ret <0 ) { +dev_err (reg->dev,"Reg 0x%02x update failed: %d\n" , + rinfo->cfg_addr, ret); +return ret; + } + rpdata->current_mode = mode; + +skip_fpwm: + ret =max77620_regulator_set_power_mode (reg, power_mode, id); +if (ret <0 )
You are not reverting the changes made before - setting the fwpm. The entire operation is not atomic. I am not sure whether that is important or not... up to you actually.
Quoted 149 lines
drivers/regulator/max77620-regulator.c new file +149
-0+return ret; + + reg->enable_power_mode[id] = power_mode; + +return 0 ; +} + +static unsigned int max77620_regulator_get_mode (struct regulator_dev *rdev) +{ +struct max77620_regulator *reg =rdev_get_drvdata (rdev); +struct device *parent = reg->max77620_chip->dev; +int id =rdev_get_id (rdev); +struct max77620_regulator_info *rinfo = reg->rinfo[id]; +int fpwm =0 ; +int ret; +int pm_mode, reg_mode; +u8 val; + + ret =max77620_regulator_get_power_mode (reg, id); +if (ret <0 ) +return 0 ; + + pm_mode = ret; + +if (rinfo->type ==MAX77620_REGULATOR_TYPE_SD ) { + ret =max77620_reg_read (parent,MAX77620_PWR_SLAVE , + rinfo->cfg_addr, &val); +if (ret <0 ) { +dev_err (reg->dev,"Reg 0x%02x read failed: %d\n" , + rinfo->cfg_addr, ret); +return ret; + } + fpwm = !!(val &MAX77620_SD_FPWM_MASK ); + } + +switch (pm_mode) { +case MAX77620_POWER_MODE_NORMAL : +case MAX77620_POWER_MODE_DISABLE : +if (fpwm) + reg_mode =REGULATOR_MODE_FAST ; +else + reg_mode =REGULATOR_MODE_NORMAL ; +break ; +case MAX77620_POWER_MODE_LPM : +case MAX77620_POWER_MODE_GLPM : + reg_mode =REGULATOR_MODE_IDLE ; +break ; +default : +return 0 ; + } + +return reg_mode; +} + +static int max77620_regulator_set_ramp_delay (struct regulator_dev *rdev, +int ramp_delay) +{ +struct max77620_regulator *reg =rdev_get_drvdata (rdev); +int id =rdev_get_id (rdev); +struct max77620_regulator_info *rinfo = reg->rinfo[id]; +struct device *parent = reg->max77620_chip->dev; +int ret, val; +u8 mask; + +if (rinfo->type ==MAX77620_REGULATOR_TYPE_SD ) { +if (ramp_delay <=13750 ) + val =0 ; +else if (ramp_delay <=27500 ) + val =1 ; +else if (ramp_delay <=55000 ) + val =2 ; +else + val =3 ; + val <<=MAX77620_SD_SR_SHIFT ; + mask =MAX77620_SD_SR_MASK ; + }else { +if (ramp_delay <=5000 ) + val =1 ; +else + val =0 ; + mask =MAX77620_LDO_SLEW_RATE_MASK ; + } + + ret =max77620_reg_update (parent,MAX77620_PWR_SLAVE , + rinfo->cfg_addr, mask, val); +if (ret <0 ) +dev_err (reg->dev,"Reg 0x%02x update failed: %d\n" , + rinfo->cfg_addr, ret); + +return ret; +} + +static struct regulator_ops max77620_regulator_ops = { + .is_enabled = max77620_regulator_is_enabled, + .enable = max77620_regulator_enable, + .disable = max77620_regulator_disable, + .list_voltage = regulator_list_voltage_linear, + .map_voltage = regulator_map_voltage_linear, + .get_voltage_sel = regulator_get_voltage_sel_regmap, + .set_voltage_sel = regulator_set_voltage_sel_regmap, + .set_mode = max77620_regulator_set_mode, + .get_mode = max77620_regulator_get_mode, + .set_ramp_delay = max77620_regulator_set_ramp_delay, + .set_voltage_time_sel = regulator_set_voltage_time_sel, +}; + +#define MAX77620_SD_CNF2_ROVS_EN_NONE 0 +#define RAIL_SD (_id, _name, _sname, _volt_mask, _min_uV, _max_uV, \ + _step_uV, _rs_add, _rs_mask) \ + [MAX77620_REGULATOR_ID_##_id] = { \ + .type = MAX77620_REGULATOR_TYPE_SD, \ + .volt_mask = MAX77620_##_volt_mask##_VOLT_MASK, \ + .volt_addr = MAX77620_REG_##_id, \ + .cfg_addr = MAX77620_REG_##_id##_CFG, \ + .fps_addr = MAX77620_REG_FPS_##_id, \ + .remote_sense_addr = _rs_add, \ + .remote_sense_mask = MAX77620_SD_CNF2_ROVS_EN_##_rs_mask, \ + .min_uV = _min_uV, \ + .max_uV = _max_uV, \ + .step_uV = _step_uV, \ + .power_mode_mask = MAX77620_SD_POWER_MODE_MASK, \ + .power_mode_shift = MAX77620_SD_POWER_MODE_SHIFT, \ + .desc = { \ + .name = max77620_rails(_name), \ + .supply_name = _sname, \ + .id = MAX77620_REGULATOR_ID_##_id, \ + .ops = &max77620_regulator_ops, \ + .n_voltages = ((_max_uV - _min_uV) / _step_uV) + 1, \ + .min_uV = _min_uV, \ + .uV_step = _step_uV, \ + .enable_time = 500, \ + .vsel_mask = MAX77620_##_volt_mask##_VOLT_MASK, \ + .vsel_reg = MAX77620_REG_##_id, \ + .type = REGULATOR_VOLTAGE, \ + }, \ + } + +#define RAIL_LDO (_id, _name, _sname, _type, _min_uV, _max_uV, _step_uV) \ + [MAX77620_REGULATOR_ID_##_id] = { \ + .type = MAX77620_REGULATOR_TYPE_LDO_##_type, \ + .volt_mask = MAX77620_LDO_VOLT_MASK, \ + .volt_addr = MAX77620_REG_##_id##_CFG, \ + .cfg_addr = MAX77620_REG_##_id##_CFG2, \ + .fps_addr = MAX77620_REG_FPS_##_id, \ + .remote_sense_addr = 0xFF, \ + .min_uV = _min_uV, \ + .max_uV = _max_uV, \ + .step_uV = _step_uV, \ + .power_mode_mask = MAX77620_LDO_POWER_MODE_MASK, \
drivers/regulator/max77620-regulator.c line 528
Quoted 10 lines
drivers/regulator/max77620-regulator.c new file +10
-0+ .power_mode_shift = MAX77620_LDO_POWER_MODE_SHIFT, \ + .desc = { \ + .name = max77620_rails(_name), \ + .supply_name = _sname, \ + .id = MAX77620_REGULATOR_ID_##_id, \ + .ops = &max77620_regulator_ops, \ + .n_voltages = ((_max_uV - _min_uV) / _step_uV) + 1, \ + .min_uV = _min_uV, \ + .uV_step = _step_uV, \ + .enable_time = 500, \
Here and before please put the line concatenator '\' aligned with previous, so:
+ .min_uV = _min_uV, \
Quoted 209 lines
drivers/regulator/max77620-regulator.c new file +209
-0+ .vsel_mask = MAX77620_LDO_VOLT_MASK, \ + .vsel_reg = MAX77620_REG_##_id##_CFG, \ + .type = REGULATOR_VOLTAGE, \ + }, \ + } + +static struct max77620_regulator_info max77620_regs_info[MAX77620_NUM_REGS ] = { +RAIL_SD (SD0 , sd0,"in-sd0" ,SD0 ,600000 ,1400000 ,12500 ,0x22 ,SD0 ), +RAIL_SD (SD1 , sd1,"in-sd1" ,SD1 ,600000 ,1550000 ,12500 ,0x22 ,SD1 ), +RAIL_SD (SD2 , sd2,"in-sd2" ,SDX ,600000 ,3787500 ,12500 ,0xFF ,NONE ), +RAIL_SD (SD3 , sd3,"in-sd3" ,SDX ,600000 ,3787500 ,12500 ,0xFF ,NONE ), +RAIL_SD (SD4 , sd4,"in-sd4" ,SDX ,600000 ,3787500 ,12500 ,0xFF ,NONE ), + +RAIL_LDO (LDO0 , ldo0,"in-ldo0-1" ,N ,800000 ,2375000 ,25000 ), +RAIL_LDO (LDO1 , ldo1,"in-ldo0-1" ,N ,800000 ,2375000 ,25000 ), +RAIL_LDO (LDO2 , ldo2,"in-ldo2" ,P ,800000 ,3950000 ,50000 ), +RAIL_LDO (LDO3 , ldo3,"in-ldo3-5" ,P ,800000 ,3950000 ,50000 ), +RAIL_LDO (LDO4 , ldo4,"in-ldo4-6" ,P ,800000 ,1587500 ,12500 ), +RAIL_LDO (LDO5 , ldo5,"in-ldo3-5" ,P ,800000 ,3950000 ,50000 ), +RAIL_LDO (LDO6 , ldo6,"in-ldo4-6" ,P ,800000 ,3950000 ,50000 ), +RAIL_LDO (LDO7 , ldo7,"in-ldo7-8" ,N ,800000 ,3950000 ,50000 ), +RAIL_LDO (LDO8 , ldo8,"in-ldo7-8" ,N ,800000 ,3950000 ,50000 ), +}; + +static struct max77620_regulator_info max20024_regs_info[MAX77620_NUM_REGS ] = { +RAIL_SD (SD0 , sd0,"in-sd0" ,SD0 ,800000 ,1587500 ,12500 ,0x22 ,SD0 ), +RAIL_SD (SD1 , sd1,"in-sd1" ,SD1 ,600000 ,3387500 ,12500 ,0x22 ,SD1 ), +RAIL_SD (SD2 , sd2,"in-sd2" ,SDX ,600000 ,3787500 ,12500 ,0xFF ,NONE ), +RAIL_SD (SD3 , sd3,"in-sd3" ,SDX ,600000 ,3787500 ,12500 ,0xFF ,NONE ), +RAIL_SD (SD4 , sd4,"in-sd4" ,SDX ,600000 ,3787500 ,12500 ,0xFF ,NONE ), + +RAIL_LDO (LDO0 , ldo0,"in-ldo0-1" ,N ,800000 ,2375000 ,25000 ), +RAIL_LDO (LDO1 , ldo1,"in-ldo0-1" ,N ,800000 ,2375000 ,25000 ), +RAIL_LDO (LDO2 , ldo2,"in-ldo2" ,P ,800000 ,3950000 ,50000 ), +RAIL_LDO (LDO3 , ldo3,"in-ldo3-5" ,P ,800000 ,3950000 ,50000 ), +RAIL_LDO (LDO4 , ldo4,"in-ldo4-6" ,P ,800000 ,1587500 ,12500 ), +RAIL_LDO (LDO5 , ldo5,"in-ldo3-5" ,P ,800000 ,3950000 ,50000 ), +RAIL_LDO (LDO6 , ldo6,"in-ldo4-6" ,P ,800000 ,3950000 ,50000 ), +RAIL_LDO (LDO7 , ldo7,"in-ldo7-8" ,N ,800000 ,3950000 ,50000 ), +RAIL_LDO (LDO8 , ldo8,"in-ldo7-8" ,N ,800000 ,3950000 ,50000 ), +}; + +static struct of_regulator_match max77620_regulator_matches[] = { + { .name ="sd0" , }, + { .name ="sd1" , }, + { .name ="sd2" , }, + { .name ="sd3" , }, + { .name ="sd4" , }, + { .name ="ldo0" , }, + { .name ="ldo1" , }, + { .name ="ldo2" , }, + { .name ="ldo3" , }, + { .name ="ldo4" , }, + { .name ="ldo5" , }, + { .name ="ldo6" , }, + { .name ="ldo7" , }, + { .name ="ldo8" , }, +}; + +static int max77620_regulator_preinit (struct max77620_regulator *reg,int id) +{ +struct max77620_regulator_pdata *rpdata = ®->reg_pdata[id]; +struct max77620_regulator_info *rinfo = reg->rinfo[id]; +struct device *parent = reg->max77620_chip->dev; +struct regulator_init_data *ridata = reg->reg_pdata[id].reg_idata; +struct regulator_desc *rdesc = &max77620_regs_info[id].desc; +struct device *dev = reg->dev; +int init_uv; +u8 val, mask, rval; +int slew_rate; +int ret; + +if (!ridata) +return 0 ; + +/* Update power mode */ + ret =max77620_regulator_get_power_mode (reg, id); +if (ret <0 ) +return ret; + + reg->current_power_mode[id] = ret; + reg->enable_power_mode[id] =MAX77620_POWER_MODE_NORMAL ; + +if (rpdata->active_fps_src ==FPS_SRC_DEF ) { + ret =max77620_regulator_get_fps_src (reg, id); +if (ret <0 ) +return ret; + rpdata->active_fps_src = ret; + } + +/* +* If rails are externally control of FPS control then enable it +* always. +*/ +if ((rpdata->active_fps_src !=FPS_SRC_NONE ) && + (reg->current_power_mode[id] != reg->enable_power_mode[id])) { + ret =max77620_regulator_set_power_mode (reg, + reg->enable_power_mode[id], id); +if (ret <0 ) +return ret; + } + +/* Enable rail before changing FPS to NONE to avoid glitch */ +if (ridata && ridata->constraints.boot_on && + (rpdata->active_fps_src ==FPS_SRC_NONE )) { + init_uv = ridata->constraints.min_uV; +if (init_uv && (init_uv == ridata->constraints.max_uV)) { + val = (init_uv - rdesc->min_uV) / rdesc->uV_step; + ret =max77620_reg_update (parent,MAX77620_PWR_SLAVE , + rdesc->vsel_reg, rdesc->vsel_mask, val); +if (ret <0 ) { +dev_err (dev,"Reg 0x%02x update failed: %d\n" , + rdesc->vsel_reg, ret); +return ret; + } + } + + ret =max77620_regulator_set_power_mode (reg, + reg->enable_power_mode[id], id); +if (ret <0 ) +return ret; + } + + ret =max77620_regulator_set_fps_src (reg, rpdata->active_fps_src, id); +if (ret <0 ) +return ret; + + ret =max77620_regulator_set_fps_slots (reg, id, false); +if (ret <0 ) +return ret; + +switch (rinfo->type) { +case MAX77620_REGULATOR_TYPE_SD : + ret =max77620_reg_read (parent,MAX77620_PWR_SLAVE , + rinfo->cfg_addr, &rval); +if (ret <0 ) { +dev_err (reg->dev,"Register 0x%02x read failed: %d\n" , + rinfo->cfg_addr, ret); +return ret; + } + + slew_rate = (rval >>MAX77620_SD_SR_SHIFT ) &0x3 ; +switch (slew_rate) { +case 0 : + slew_rate =13750 ; +break ; +case 1 : + slew_rate =27500 ; +break ; +case 2 : + slew_rate =55000 ; +break ; +case 3 : + slew_rate =100000 ; +break ; + } + rinfo->desc.ramp_delay = slew_rate; + + mask =MAX77620_SD_FSRADE_MASK ; + val =0 ; +if (rpdata->sd_fsrade_disable) + val |=MAX77620_SD_FSRADE_MASK ; + + ret =max77620_reg_update (parent,MAX77620_PWR_SLAVE , + rinfo->cfg_addr, mask, val); +if (ret <0 ) { +dev_err (reg->dev,"Reg 0x%02x update failed: %d\n" , + rinfo->cfg_addr, ret); +return ret; + } +break ; +default : + ret =max77620_reg_read (parent,MAX77620_PWR_SLAVE , + rinfo->cfg_addr, &rval); +if (ret <0 ) { +dev_err (reg->dev,"Register 0x%02x read failed: %d\n" , + rinfo->cfg_addr, ret); +return ret; + } + slew_rate = rval &0x1 ; +switch (slew_rate) { +case 0 : + slew_rate =100000 ; +break ; +case 1 : + slew_rate =5000 ; +break ; + } + rinfo->desc.ramp_delay = slew_rate; +break ; + } + +if ((id ==MAX77620_REGULATOR_ID_SD0 ) && rpdata->en2_ctrl_sd0) { + ret =max77620_regulator_set_power_mode (reg, +MAX77620_POWER_MODE_NORMAL , id); +if (!ret) + ret =max77620_regulator_set_fps_src (reg,FPS_SRC_0 , + id); + } + +return ret; +} + +static int max77620_get_regulator_dt_data (struct platform_device *pdev, +struct max77620_regulator *max77620_regs) +{ +struct device_node *np; +u32 prop; +int id;
drivers/regulator/max77620-regulator.c line 747
Quoted 10 lines
drivers/regulator/max77620-regulator.c new file +10
-0+int ret; + + np =of_get_child_by_name (pdev->dev.parent->of_node,"regulators" ); +if (!np) { +dev_err (&pdev->dev,"Device is not having regulators node\n" ); +return -ENODEV ; + } + + ret =of_regulator_match (&pdev->dev, np, max77620_regulator_matches, +ARRAY_SIZE (max77620_regulator_matches));
Why not using 'regulators_node' and getting rid of this and some code below? If you need to parse custom regulator properties use 'of_parse_cb'.
Quoted 66 lines
drivers/regulator/max77620-regulator.c new file +66
-0+if (ret <0 ) { +dev_err (&pdev->dev,"regulator node parsing failed: %d\n" , ret); +return ret; + } + +for (id =0 ; id <ARRAY_SIZE (max77620_regulator_matches); ++id) { +struct device_node *reg_node; +struct max77620_regulator_pdata *reg_pdata = + &max77620_regs->reg_pdata[id]; + + reg_node = max77620_regulator_matches[id].of_node; + reg_pdata->reg_idata = max77620_regulator_matches[id].init_data; + +if (!reg_pdata->reg_idata) +continue ; + + reg_pdata->glpm_enable =of_property_read_bool (reg_node, +"maxim,enable-group-low-power" ); + + reg_pdata->en2_ctrl_sd0 =of_property_read_bool (reg_node, +"maxim,enable-sd0-en2-control" ); + + reg_pdata->sd_fsrade_disable =of_property_read_bool (reg_node, +"maxim,disable-active-discharge" ); + + reg_pdata->disable_remote_sense_on_suspend = +of_property_read_bool (reg_node, +"maxim,disable-remote-sense-on-suspend" ); + + ret =of_property_read_u32 (reg_node, +"maxim,active-fps-source" , &prop); +if (!ret) + reg_pdata->active_fps_src = prop; +else + reg_pdata->active_fps_src =FPS_SRC_DEF ; + + ret =of_property_read_u32 (reg_node, +"maxim,active-fps-power-up-slot" , &prop); +if (!ret) + reg_pdata->active_fps_pu_slot = prop; +else + reg_pdata->active_fps_pu_slot =-1 ; + + ret =of_property_read_u32 (reg_node, +"maxim,active-fps-power-down-slot" , &prop); +if (!ret) + reg_pdata->active_fps_pd_slot = prop; +else + reg_pdata->active_fps_pd_slot =-1 ; + + reg_pdata->suspend_fps_src =-1 ; + reg_pdata->suspend_fps_pu_slot =-1 ; + reg_pdata->suspend_fps_pd_slot =-1 ; + ret =of_property_read_u32 (reg_node, +"maxim,suspend-fps-source" , &prop); +if (!ret) + reg_pdata->suspend_fps_src = prop; + + ret =of_property_read_u32 (reg_node, +"maxim,suspend-fps-power-up-slot" , &prop); +if (!ret) + reg_pdata->suspend_fps_pu_slot = prop; + + ret =of_property_read_u32 (reg_node, +"maxim,suspend-fps-power-down-slot" , &prop); +if (!ret)
drivers/regulator/max77620-regulator.c line 823
Quoted 10 lines
drivers/regulator/max77620-regulator.c new file +10
-0+ reg_pdata->suspend_fps_pd_slot = prop; + } + +return 0 ; +} + +static int max77620_regulator_probe (struct platform_device *pdev) +{ +struct max77620_chip *max77620_chip =dev_get_drvdata (pdev->dev.parent); +struct regulator_desc *rdesc;
This is should be local to the for-loop,
Quoted 25 lines
drivers/regulator/max77620-regulator.c new file +25
-0+struct max77620_regulator *pmic; +struct regulator_config config = { }; +struct max77620_regulator_info *regulator_info; +int ret =0 ; +int id; + + pmic =devm_kzalloc (&pdev->dev,sizeof (*pmic),GFP_KERNEL ); +if (!pmic) +return -ENOMEM ; + +max77620_get_regulator_dt_data (pdev, pmic); + +platform_set_drvdata (pdev, pmic); + pmic->max77620_chip = max77620_chip; + pmic->dev = &pdev->dev; + +if (max77620_chip->id ==MAX77620 ) + regulator_info = max77620_regs_info; +else + regulator_info = max20024_regs_info; + +for (id =0 ; id <MAX77620_NUM_REGS ; ++id) { + +if ((max77620_chip->id ==MAX77620 ) && + (id ==MAX77620_REGULATOR_ID_SD4 ))
drivers/regulator/max77620-regulator.c line 858
Quoted 10 lines
drivers/regulator/max77620-regulator.c new file +10
-0+continue ; + + rdesc = ®ulator_info[id].desc; + pmic->rinfo[id] = &max77620_regs_info[id]; + pmic->enable_power_mode[id] =MAX77620_POWER_MODE_NORMAL ; + + config.regmap = max77620_chip->rmap[MAX77620_PWR_SLAVE ]; + config.dev = &pdev->dev; + config.init_data = pmic->reg_pdata[id].reg_idata; + config.driver_data = pmic;
Don't do it for each regulator. Set the config.regmap/dev/driver_data once before the loop.
Each regulator_register() makes a copy of passed 'config'.
Quoted 4 lines
drivers/regulator/max77620-regulator.c new file +4
-0+ config.of_node = max77620_regulator_matches[id].of_node; + + ret =max77620_regulator_preinit (pmic, id); +if (ret <0 ) {
drivers/regulator/max77620-regulator.c line 872
Quoted 10 lines
drivers/regulator/max77620-regulator.c new file +10
-0+dev_err (&pdev->dev,"Preinit regualtor %s failed: %d\n" , + rdesc->name, ret); +return ret; + } + + pmic->rdev[id] =devm_regulator_register (&pdev->dev, + rdesc, &config); +if (IS_ERR (pmic->rdev[id])) { + ret =PTR_ERR (pmic->rdev[id]); + dev_err(&pdev->dev, "Reg registeration %s failed: %d\n",
s/registeration/init/ (or registration?)
Quoted 81 lines
drivers/regulator/max77620-regulator.c new file +81
-0+ rdesc->name, ret); +return ret; + } + } + +return 0 ; +} + +#ifdef CONFIG_PM_SLEEP +static int max77620_regulator_suspend (struct device *dev) +{ +struct max77620_regulator *pmic =dev_get_drvdata (dev); +struct max77620_regulator_pdata *reg_pdata; +struct max77620_regulator_info *rinfo; +struct device *parent = pmic->dev->parent; +int id; +int ret; + +for (id =0 ; id <MAX77620_NUM_REGS ; ++id) { + reg_pdata = &pmic->reg_pdata[id]; + rinfo = pmic->rinfo[id]; +if (!reg_pdata || !rinfo) +continue ; + +if (reg_pdata->disable_remote_sense_on_suspend && + (rinfo->remote_sense_addr !=0xFF )) { + ret =max77620_reg_update (parent,MAX77620_PWR_SLAVE , + rinfo->remote_sense_addr, + rinfo->remote_sense_mask,0 ); +if (ret <0 ) +dev_err (dev,"Reg 0x%02x update failed: %d\n" , + rinfo->remote_sense_addr, ret); + } + +max77620_regulator_set_fps_slots (pmic, id, true); +if (reg_pdata->suspend_fps_src >=0 ) +max77620_regulator_set_fps_src (pmic, + reg_pdata->suspend_fps_src, id); + } + +return 0 ; +} + +static int max77620_regulator_resume (struct device *dev) +{ +struct max77620_regulator *pmic =dev_get_drvdata (dev); +struct max77620_regulator_pdata *reg_pdata; +struct max77620_regulator_info *rinfo; +struct device *parent = pmic->dev->parent; +int id; +int ret; + +for (id =0 ; id <MAX77620_NUM_REGS ; ++id) { + reg_pdata = &pmic->reg_pdata[id]; + rinfo = pmic->rinfo[id]; +if (!reg_pdata || !rinfo) +continue ; + +if (reg_pdata->disable_remote_sense_on_suspend && + (rinfo->remote_sense_addr !=0xFF )) { + ret =max77620_reg_update (parent,MAX77620_PWR_SLAVE , + rinfo->remote_sense_addr, + rinfo->remote_sense_mask, + rinfo->remote_sense_mask); +if (ret <0 ) +dev_err (dev,"Reg 0x%02x update failed: %d\n" , + rinfo->remote_sense_addr, ret); + } + +max77620_regulator_set_fps_slots (pmic, id, false); +if (reg_pdata->active_fps_src >=0 ) +max77620_regulator_set_fps_src (pmic, + reg_pdata->active_fps_src, id); + } + +return 0 ; +} +#endif + +static const struct dev_pm_ops max77620_regulator_pm_ops = { + SET_SYSTEM_SLEEP_PM_OPS(max77620_regulator_suspend,
drivers/regulator/max77620-regulator.c line 963
Quoted 10 lines
drivers/regulator/max77620-regulator.c new file +10
-0+ max77620_regulator_resume) +}; + +static const struct platform_device_id max77620_regulator_devtype[] = { + { + .name ="max77620-pmic" , + }, + { + .name ="max20024-pmic" , + },
Sentinel.MODULE_DEVICE_TABLE
Best regards,
Krzysztof
Rob Herring
maintainerRe: [PATCH V2 1/6] DT: mfd: add device-tree binding doc fro PMIC max77620/max20024
In reply to Laxman DewanganQuoted 13 lines · Laxman Dewangan
The MAXIM PMIC MAX77620 and MAX20024 are power management IC which supports RTC, GPIO, DCDC/LDO regulators, interrupt, watchdog etc.
Add DT binding document for the different functionality of this device.
Signed-off-by Laxman Dewangan <[email protected]>---
Changes from V1:
- Added units in some of properties.
- Change the boolean property to tristate type and detail some of properties.
[...]
Quoted 6 lines
Documentation/devicetree/bindings/mfd/max77620.txt new file +6
-0+Flexible power sequence configuration +==================================== +This sub-node configures the Flexible Power Sequnece(FPS) for power ON slot, +power OFF slot and slot period of the device. Device has 3 FPS as FPS0, +FPS1 and FPS2. The details of FPS configuration is provided through +subnode "fps". The details of FPS0, FPS1, FPS2 are provided through the
Documentation/devicetree/bindings/mfd/max77620.txt line 45
Quoted 10 lines
Documentation/devicetree/bindings/mfd/max77620.txt new file +10
-0+child node under this subnodes. The FPS number is provided via reg property. + +The property for fps child nodes as: +Required properties: + -reg: FPS number like 0, 1, 2 for FPS0, FPS1 and FPS2 respectively. +Optinal properties: + -maxim,active-fps-time-period: Active state FPS time period in + microseconds. + -maxim,suspend-fps-time-period: Suspend state FPS time period in + microseconds.
These property names need units, too. IOW, append with '-us', so something like "maxim,suspend-fps-time-us".
Otherwise, looks fine to me.
--
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 5/6] rtc: max77xxx: add RTC driver for Maxim MAX77xxx series RTC IP
In reply to Krzysztof KozlowskiQuoted 43 lines · Krzysztof Kozlowski
Quoted 29 lines · Laxman Dewangan
Maxim Semiconductor's PMIC MAX77620, MAX77686, MAX20024 have same RTC IP on these PMICs.
Add generic MAX77xxxx series RTC driver which can be used as RTC driver for these PMIC and avoids duplication of RTC driver for each PMICs. Their MFD driver can be different here.
Signed-off-by Laxman Dewangan <[email protected]>---
Changes from V1:
- Rename the file tortc-max77xxx.cand make the generic implementation.
- Direct regmap apis are used for the register access.
- Decouped from max77620 driver.
- Taken care of cleanup comments form V1 version.drivers/rtc/Kconfig | 10 + drivers/rtc/Makefile | 1 + drivers/rtc/rtc-max77xxx.c | 500 +++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 511 insertions(+)create mode 100644
drivers/rtc/rtc-max77xxx.cdrivers/rtc/Kconfig +0
-0@@ -315,6 +315,16 @@ config RTC_DRV_MAX8997 This driver can also be built as a module. If so, the module will be called rtc-max8997.drivers/rtc/Kconfig config RTC_DRV_MAX8997 · line 327
Quoted 10 lines
drivers/rtc/Kconfig +10
-0+config RTC_DRV_MAX77XXX + tristate "Maxim MAX77XXX series generic RTC driver" + help + If you say yes here you will get support for the generic RTC driver + for Maxim Semiconductor MAX77XXX series of PMIC like MAX77620. + This also supports the RTC driver for Maxim PMIC MaX20024 which + is almost same as MAX77620. + This driver can also be built as a module. If so, the module + will be called rtc-max77xxx. +That was not the consensus... You still added a new driver - but now with different name.
Quoted 6 lines
That is useless duplication
Please work with existing code. Use existing maxim RTC drivers: either max77686 or max77802.
There is no need for new one.
If we modify the existing one then that work will be outside of this series to make it independent.
However, the file name does not suggest common in older file. Also this will require mfd and rtc driver changes to decouple it.
Here is my approach:
- Let's have common driver in implementation and file name. This will be independent of the mfd driver on all sense.
- Once it is merged, move the max77686 and max77802 to use this driver, this will need the modification on the mfd driver, related defconfig file and if specific stuff needed in the rtc then addition of that.
Per your approach:
- Modify rtc max77686 and mfd driver max77686 to decouple and proper registration.
- Add support of max77620 on the max77686 driver if any specific is required.
That is also fine to me but still I am not comfortable with the config name and driver file name as this does not suggest the common.
Re: [PATCH V2 5/6] rtc: max77xxx: add RTC driver for Maxim MAX77xxx series RTC IP
In reply to Krzysztof KozlowskiQuoted 10 lines · Krzysztof Kozlowski
Quoted 4 lines · Laxman Dewangan
On Wednesday 13 January 2016 05:36 AM, Krzysztof Kozlowski wrote:
That is also fine to me but still I am not comfortable with the config name and driver file name as this does not suggest the common.
The name does not matter. Really. We have a lot of drivers with a specific device-like name and supporting different devices. To point that your argument is invalid - your initial name of driver "
rtc-max77620.c" supported totally different "names": the max77620 and max20024. It also wasn't suggesting something "common"...
In all config string, I have mentioned the MAX20024.
Quoted 3 lines
With my approach we are not developing common think neither. We just want to extend/re-use existing max77686 (or max77802) driver for new devices. Just like everywhere else.
OK, fine to me if this is acceptable.
I will drop this rtc patch form this series and work in max77686 driver to modify first and once merged, use this config on my defconfig.
Re: [PATCH V2 5/6] rtc: max77xxx: add RTC driver for Maxim MAX77xxx series RTC IP
In reply to Laxman DewanganQuoted 48 lines · Laxman Dewangan
Quoted 46 lines · Krzysztof Kozlowski
Quoted 34 lines · Laxman Dewangan
Maxim Semiconductor's PMIC MAX77620, MAX77686, MAX20024 have same RTC IP on these PMICs.
Add generic MAX77xxxx series RTC driver which can be used as RTC driver for these PMIC and avoids duplication of RTC driver for each PMICs. Their MFD driver can be different here.
Signed-off-by Laxman Dewangan <[email protected]>---
Changes from V1:
- Rename the file tortc-max77xxx.cand make the generic implementation.
- Direct regmap apis are used for the register access.
- Decouped from max77620 driver.
- Taken care of cleanup comments form V1 version.drivers/rtc/Kconfig | 10 + drivers/rtc/Makefile | 1 + drivers/rtc/rtc-max77xxx.c | 500 +++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 511 insertions(+)create mode 100644
drivers/rtc/rtc-max77xxx.cdrivers/rtc/Kconfig +3
-0@@ -315,6 +315,16 @@ config RTC_DRV_MAX8997 This driver can also be built as a module. If so, the module will be called rtc-max8997. +config RTC_DRV_MAX77XXX + tristate "Maxim MAX77XXX series generic RTC driver" + help + If you say yes here you will get support for the generic RTCdriver
drivers/rtc/Kconfig config RTC_DRV_MAX8997 · line 327
Quoted 6 lines
drivers/rtc/Kconfig +6
-0+ for Maxim Semiconductor MAX77XXX series of PMIC like MAX77620. + This also supports the RTC driver for Maxim PMIC MaX20024 which + is almost same as MAX77620. + This driver can also be built as a module. If so, the module + will be called rtc-max77xxx. +That was not the consensus... You still added a new driver - but now with different name.
That is useless duplication
Quoted 7 lines
Quoted 4 lines
Please work with existing code. Use existing maxim RTC drivers: either max77686 or max77802.
There is no need for new one.
If we modify the existing one then that work will be outside of this series to make it independent.
And that is the problem? The series evolve. The ultimate goal is to support max77686, max77802, max77620 and max20024.
Quoted 2 lines
However, the file name does not suggest common in older file.
This is not a sensible argument. The name does not matter. But if really needed we can rename it...
Quoted 2 lines
Also this
will require mfd and rtc driver changes to decouple it.
Yes, decouple everything! I like it! :) Make it robust, generic, readable, fix bugs etc. :)
Quoted 7 lines
Here is my approach:
- Let's have common driver in implementation and file name. This will be independent of the mfd driver on all sense.
- Once it is merged, move the max77686 and max77802 to use this driver, this will need the modification on the mfd driver, related defconfig file and if specific stuff needed in the rtc then addition of that.
Nope, because *the second part won't happen*. Never. After merging you will be happy and another duplicated stuff ends in the kernel.
Fix things before merging. Not after.
Quoted 6 lines
Per your approach:
- Modify rtc max77686 and mfd driver max77686 to decouple and proper registration.
- Add support of max77620 on the max77686 driver if any specific is required.
That is the way we usually extend the drivers for new devices.
Quoted 3 lines
That is also fine to me but still I am not comfortable with the config name and driver file name as this does not suggest the common.
The name does not matter. Really. We have a lot of drivers with a specific device-like name and supporting different devices. To point that your argument is invalid - your initial name of driver "rtc-max77620.c" supported totally different "names": the max77620 and max20024. It also wasn't suggesting something "common"...
With my approach we are not developing common think neither. We just want to extend/re-use existing max77686 (or max77802) driver for new devices. Just like everywhere else.
Best regards,
Krzysztof
Re: [PATCH V2 2/6] mfd: max77620: add core driver for MAX77620/MAX20024
In reply to Krzysztof KozlowskiQuoted 11 lines · Krzysztof Kozlowski
drivers/mfd/max77620.c line 687
Quoted 5 lines · Laxman Dewangan
drivers/mfd/max77620.c new file +5
-0+ } +dev_dbg (chip->dev,"NVERC = 0x%02x\n" , val); +for (i =0 ; i <8 ; ++i) { +if (val &BIT (i)) +dev_info (chip->dev,"NVERC: %s\n" , max77620_nverc[i]);You are still printing two
dev_info(OTP, ES) and here NVERC (probably one?). This will be printed on each boot, over and over, till the user will learn it and will remember it forever :).
Quoted 3 lines
From my point of view: one
dev_infofor one probed device.I don't know if others agree with that, though. What's your opinion Lee?
OK, I make single line print for OTP and ES version.
I remove the NVREC reading and printing as this is read on clear and better to move on uboot for this prints.
Quoted 6 lines
drivers/mfd/max77620.c new file +3
-0+ + ret = regmap_add_irq_chip(chip->rmap[MAX77620_PWR_SLAVE], + chip->chip_irq, IRQF_ONESHOT | IRQF_SHARED, chip->irq_base,Why do you need
IRQF_SHARED?
In one of my design, I have three PMICs, one MAX77620, two MAX77621. MAX77621 alert an MAX77620 interrupt line is tied and going to single interrupt of SoC.
To register same interrupt from all driver, I made it SHARED.
This is per discussion on the other patch
regulator: max8973: add support for junction thermal warning
Quoted 6 lines
drivers/mfd/max77620.c line 772
Quoted 1 line
drivers/mfd/max77620.c new file +1
-0+ &max77620_top_irq_chip, &chip->top_irq_data);More tabs needed for indentation of arguments.
Actually the alignment of arguments here is mixed. Sometimes arguments are aligned with opening parenthesis, mostly not. Can you make it consistent - always aligned?
In my 3rd patch, I tried to align it little more where is possible. But I feel that all these indenting is more over individual choice. Example, I added one more indent in below example to look better.
ret = max77620_reg_update(chip->dev, MAX77620_PWR_SLAVE,
- MAX77620_REG_ONOFFCNFG2, MAX77620_ONOFFCNFG2_WK_EN0,
- MAX77620_ONOFFCNFG2_WK_EN0);
+ MAX77620_REG_ONOFFCNFG2, MAX77620_ONOFFCNFG2_WK_EN0,
+ MAX77620_ONOFFCNFG2_WK_EN0);
Re: [PATCH V2 2/6] mfd: max77620: add core driver for MAX77620/MAX20024
drivers/mfd/max77620.c line 469
Quoted 12 lines · Laxman Dewangan
In my 3rd patch, I tried to align it little more where is possible. But I feel that all these indenting is more over individual choice. Example, I added one more indent in below example to look better.
ret = max77620_reg_update(chip->dev, MAX77620_PWR_SLAVE,drivers/mfd/max77620.c new file +2
-2-MAX77620_REG_ONOFFCNFG2 ,MAX77620_ONOFFCNFG2_WK_EN0 , - MAX77620_ONOFFCNFG2_WK_EN0); +MAX77620_REG_ONOFFCNFG2 ,MAX77620_ONOFFCNFG2_WK_EN0 , + MAX77620_ONOFFCNFG2_WK_EN0);
You should probably use checkpatch.pl --strict, it requires that you align on the open parenthesis.
Signature · 3 lines
Alexandre Belloni, Free Electrons Embedded Linux, Kernel and Android engineering http://free-electrons.com
Re: [PATCH V2 6/6] regulator: max77620: add regulator driver for max77620/max20024
In reply to Krzysztof KozlowskiQuoted 7 lines · Krzysztof Kozlowski
On 12.01.2016 18:17, Laxman Dewangan wrote:
(quoted diff) +3
-0+ + ret = of_regulator_match(&pdev->dev, np, max77620_regulator_matches, + ARRAY_SIZE(max77620_regulator_matches));Why not using '
regulators_node' and getting rid of this and some code below? If you need to parse custom regulator properties use 'of_parse_cb'.
Yaah, this is something new and I think Mark also wanted to do this cleanup on his comment. I did not understand it previously. Looks cool now.
However, I have requirement to configure PMIC with some inital setting based on init_data (parsed) before regulator registration happened. Once I move to this new mecahinsm, the inti_data parsing and regulator init happen in the same function. So I need to have one callback from regulator_register to driver. Something below. This will do the pre configuration before regulator_register happena dn machine constraint sets.
I can not use the init_data->regulator_init() as I need to have the init data passed to the driver.
Created sample patch below.
ldewangan@ldewanganubuntu-System-Product-Name:~/upstream/linux-next/linux-next/drivers/regulator$ git diff core.c ../../include/linux/regulator/driver.h
drivers/regulator/core.c +11 -0
@@ -3899,6 +3899,17 @@ regulator_register(const struct regulator_desc *regulator_desc, rdev->dev.of_node =of_node_get (config->of_node); } +if (init_data && regulator_desc->pre_register_init) { + ret = regulator_desc->pre_register_init (regulator_desc, + config, init_data); +if (ret <0 ) { +dev_err (dev,"Pre register failed: %d\n" , ret); +kfree (rdev); +kfree (config); +return ERR_PTR (ret); + } + } +mutex_lock (®ulator_list_mutex);mutex_init (&rdev->mutex);
include/linux/regulator/driver.h +3 -0
@@ -280,6 +280,9 @@ struct regulator_desc {int (*of_parse_cb)(struct device_node *,const struct regulator_desc *,struct regulator_config *); +int (*pre_register_init)(const struct regulator_desc *, +struct regulator_config *, +struct regulator_init_data *);int id;bool continuous_voltage_range;unsigned n_voltages;
Mark Brown
maintainerRe: [PATCH V2 6/6] regulator: max77620: add regulator driver for max77620/max20024
Quoted 2 lines · Laxman Dewangan
Yaah, this is something new and I think Mark also wanted to do this cleanup on his comment. I did not understand it previously. Looks cool now.
I did, please don't just ignore review comments.
Quoted 10 lines
However, I have requirement to configure PMIC with some inital setting based on
init_data(parsed) before regulator registration happened. Once I move to this new mecahinsm, theinti_dataparsing and regulator init happen in the same function. So I need to have one callback fromregulator_registerto driver.
Something below. This will do the pre configuration beforeregulator_registerhappena dn machine constraint sets.I can not use the
init_data->regulator_init()as I need to have the init data passed to the driver.
Why do you have this requirement?
Re: [PATCH V2 6/6] regulator: max77620: add regulator driver for max77620/max20024
Quoted 7 lines · Mark Brown
* PGP Signed by an unknown key
Quoted 2 lines · Laxman Dewangan
Yaah, this is something new and I think Mark also wanted to do this cleanup on his comment. I did not understand it previously. Looks cool now.
I did, please don't just ignore review comments.
Sure, I respect all comments and thanks for review. Seems your mail got lost somewhere (still not seeing in my inbox).
Quoted 11 lines
Quoted 10 lines
However, I have requirement to configure PMIC with some inital setting based on
init_data(parsed) before regulator registration happened. Once I move to this new mecahinsm, theinti_dataparsing and regulator init happen in the same function. So I need to have one callback fromregulator_registerto driver.
Something below. This will do the pre configuration beforeregulator_registerhappena dn machine constraint sets.
I can not use theinit_data->regulator_init()as I need to have the init data passed to the driver.Why do you have this requirement?
This is require to
- configure FPS_SRC based on platform data for each rail,
- If FPS_SRC enabled then enable it always.
- If FPS_SRC is disabled (NONE) then based on init data constraint,
set it to desired state.
- Power mode and slew rate init based on default configuration from the register if platform does not want to set it.
Mark Brown
maintainerRe: [PATCH V2 6/6] regulator: max77620: add regulator driver for max77620/max20024
Quoted 7 lines · Laxman Dewangan
Quoted 4 lines · Mark Brown
Quoted 4 lines
Something below. This will do the pre configuration before
regulator_registerhappena dn machine constraint sets.
I can not use theinit_data->regulator_init()as I need to have the init data passed to the driver.
Quoted 7 lines
Quoted 1 line
Why do you have this requirement?
This is require to
- configureFPS_SRCbased on platform data for each rail,
- IfFPS_SRCenabled then enable it always.
- IfFPS_SRCis disabled (NONE) then based on init data constraint, set it to desired state.
What is FPS_SRC and why is it set from init_data? A driver should never be looking at init_data.
Quoted 2 lines
- Power mode and slew rate init based on default configuration from the register if platform does not want to set it.
Same here, why is init_data needed here?
Re: [PATCH V2 6/6] regulator: max77620: add regulator driver for max77620/max20024
Quoted 11 lines · Mark Brown
* PGP Signed by an unknown key
Quoted 6 lines · Laxman Dewangan
On Wednesday 13 January 2016 05:27 PM, Mark Brown wrote:
This is require to
- configureFPS_SRCbased on platform data for each rail,
- IfFPS_SRCenabled then enable it always.
- IfFPS_SRCis disabled (NONE) then based on init data constraint, set it to desired state.What is
FPS_SRCand why is it set frominit_data? A driver should never be looking atinit_data.
FPS: Flexible Power Sequence.
Max77620 has three FPS source configuration FPS0,1 2 and can be configured with different digital input signals EN0, EN1 and EN2. Then rails and few GPIOs can configured with these FPS SRC with different slots so that it can be controlled externally.
When FPS_SRC is set to NONE (this is needed from platform data) then based on constraint like boot enable/always enable, it need to be on desired state. Otherwise we may endup with disabling the rail when setting to NONE and create issue.
I need to set the FPS src properly for each rails before callback happen from regulator init so that enable/disable/is_enable can handle it properly.
Quoted 4 lines
Quoted 2 lines
- Power mode and slew rate init based on default configuration from the register if platform does not want to set it.
Same here, why is
init_dataneeded here?
Here, init data is not needed. I was thinking to configure slew rate in preinit but can be done later also through regulator->ops. But I will need the driver specific DT data (customized flag) to configure the PMIC like slots.
Mark Brown
maintainerRe: [PATCH V2 6/6] regulator: max77620: add regulator driver for max77620/max20024
Quoted 9 lines · Laxman Dewangan
Quoted 2 lines · Mark Brown
What is
FPS_SRCand why is it set frominit_data? A driver should never be looking atinit_data.When
FPS_SRCis set to NONE (this is needed from platform data) then based on constraint like boot enable/always enable, it need to be on desired state. Otherwise we may endup with disabling the rail when setting to NONE and create issue.
What is "it" and why can't we check what the current configuration is while setting FPS to NONE?
Quoted 2 lines
I need to set the FPS src properly for each rails before callback happen from regulator init so that enable/disable/is_enable can handle it properly.
Why not just reorder the callback so it happens before the constraints are applied?
Re: [PATCH V2 6/6] regulator: max77620: add regulator driver for max77620/max20024
Quoted 4 lines · Mark Brown
* PGP Signed by an unknown key
Quoted 1 line · Laxman Dewangan
On Wednesday 13 January 2016 06:01 PM, Mark Brown wrote:
Quoted 8 lines
Quoted 6 lines
Quoted 2 lines
What is
FPS_SRCand why is it set frominit_data? A driver should never be looking atinit_data.When
FPS_SRCis set to NONE (this is needed from platform data) then based on constraint like boot enable/always enable, it need to be on desired state. Otherwise we may endup with disabling the rail when setting to NONE and create issue.What is "it" and why can't we check what the current configuration is while setting FPS to NONE?
I will have platform specific data in callback of enable/disable only. Which call back do I need to set this? enable/disable or post register?
Quoted 5 lines
Quoted 2 lines
I need to set the FPS src properly for each rails before callback happen from regulator init so that enable/disable/is_enable can handle it properly.
Why not just reorder the callback so it happens before the constraints are applied?
which callback I need to reorder for getting the context for configruation?
Mark Brown
maintainerRe: [PATCH V2 6/6] regulator: max77620: add regulator driver for max77620/max20024
Quoted 7 lines · Laxman Dewangan
Quoted 2 lines · Mark Brown
What is "it" and why can't we check what the current configuration is while setting FPS to NONE?
I will have platform specific data in callback of enable/disable only. Which call back do I need to set this? enable/disable or post register?
I'm sorry but I can't parse what you're saying here.
Quoted 7 lines
Quoted 5 lines
Quoted 2 lines
I need to set the FPS src properly for each rails before callback happen from regulator init so that enable/disable/is_enable can handle it properly.
Why not just reorder the callback so it happens before the constraints are applied?
which callback I need to reorder for getting the context for configruation?
The existing call to parse the DT.
Re: [PATCH V2 6/6] regulator: max77620: add regulator driver for max77620/max20024
Quoted 9 lines · Mark Brown
* PGP Signed by an unknown key
Quoted 5 lines · Laxman Dewangan
Quoted 2 lines · Mark Brown
What is "it" and why can't we check what the current configuration is while setting FPS to NONE?
I will have platform specific data in callback of enable/disable only. Which call back do I need to set this? enable/disable or post register?
I'm sorry but I can't parse what you're saying here.
Here, before machine constraint applies, I need to configure FPS on desired source.
Quoted 6 lines
Quoted 5 lines
Quoted 4 lines
Quoted 2 lines
I need to set the FPS src properly for each rails before callback happen from regulator init so that enable/disable/is_enable can handle it properly.
Why not just reorder the callback so it happens before the constraints are applied?
which callback I need to reorder for getting the context for configruation?
The existing call to parse the DT.
Are we allow to do i2c transfer in the existing callback for parsing the DT?
By code, nothing is stopping but want to know if there is such limitation on policy/design of this API.
Re: [PATCH V2 5/6] rtc: max77xxx: add RTC driver for Maxim MAX77xxx series RTC IP
In reply to Laxman DewanganQuoted 15 lines · Laxman Dewangan
Quoted 10 lines · Krzysztof Kozlowski
Quoted 4 lines · Laxman Dewangan
On Wednesday 13 January 2016 05:36 AM, Krzysztof Kozlowski wrote:
That is also fine to me but still I am not comfortable with the config name and driver file name as this does not suggest the common.
The name does not matter. Really. We have a lot of drivers with a specific device-like name and supporting different devices. To point that your argument is invalid - your initial name of driver "
rtc-max77620.c" supported totally different "names": the max77620 and max20024. It also wasn't suggesting something "common"...In all config string, I have mentioned the MAX20024.
Quoted 7 lines
Quoted 3 lines
With my approach we are not developing common think neither. We just want to extend/re-use existing max77686 (or max77802) driver for new devices. Just like everywhere else.
OK, fine to me if this is acceptable.
I will drop this rtc patch form this series and work in max77686 driver to modify first and once merged, use this config on my defconfig.
Here, MAX686 RTC driver needs two regmap handle, one for the rtc_regmap and other for STATUS2 register access.
ret = regmap_read(info->max77686->regmap, MAX77686_REG_STATUS2,
&val);
if (ret < 0) {
dev_err(info->dev, "%s:%d fail to read status2 reg(%d)\n",
__func__, __LINE__, ret);
goto out;
}We can not have two regmap handle on rtc driver as both regmap (pmic and rtc) registered with different i2c device.
Also this register should not be accessed by RTC driver if we want to decouple as this is very much MAX77686 register set. Do we need this code?
static int max77686_rtc_read_alarm(struct device *dev, struct rtc_wkalrm *alrm)
{
struct max77686_rtc_info *info = dev_get_drvdata(dev);
u8 data[RTC_NR_TIME];
unsigned int val;
int i, ret;::::::::
alrm->pending = 0;
ret = regmap_read(info->max77686->regmap, MAX77686_REG_STATUS2,
&val);
if (ret < 0) {
dev_err(info->dev, "%s:%d fail to read status2 reg(%d)\n",
__func__, __LINE__, ret);
goto out;
}
if (val & (1 << 4)) /* RTCA1 */
alrm->pending = 1;}
--
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
Mark Brown
maintainerRe: [PATCH V2 6/6] regulator: max77620: add regulator driver for max77620/max20024
In reply to Laxman DewanganQuoted 7 lines · Laxman Dewangan
Quoted 5 lines · Mark Brown
Quoted 4 lines · Laxman Dewangan
Quoted 2 lines · Mark Brown
What is "it" and why can't we check what the current configuration is while setting FPS to NONE?
Quoted 7 lines
Quoted 4 lines
Quoted 2 lines
I will have platform specific data in callback of enable/disable only. Which call back do I need to set this? enable/disable or post register?
I'm sorry but I can't parse what you're saying here.
Here, before machine constraint applies, I need to configure FPS on desired source.
I'm a bit confused here - I had thought you needed things the other way around? Can you describe in concrete terms what you want to configure?
Quoted 10 lines
Quoted 8 lines
Quoted 7 lines
Quoted 5 lines
Quoted 2 lines
I need to set the FPS src properly for each rails before callback happen from regulator init so that enable/disable/is_enable can handle it properly.
Why not just reorder the callback so it happens before the constraints are applied?
which callback I need to reorder for getting the context for configruation?
The existing call to parse the DT.
Are we allow to do i2c transfer in the existing callback for parsing the DT?
Yes, of course.
Re: [PATCH V2 5/6] rtc: max77xxx: add RTC driver for Maxim MAX77xxx series RTC IP
In reply to Laxman DewanganQuoted 65 lines · Laxman Dewangan
Quoted 15 lines · Laxman Dewangan
Quoted 10 lines · Krzysztof Kozlowski
Quoted 4 lines · Laxman Dewangan
On Wednesday 13 January 2016 05:36 AM, Krzysztof Kozlowski wrote:
That is also fine to me but still I am not comfortable with the config name and driver file name as this does not suggest the common.
The name does not matter. Really. We have a lot of drivers with a specific device-like name and supporting different devices. To point that your argument is invalid - your initial name of driver "
rtc-max77620.c" supported totally different "names": the max77620 and max20024. It also wasn't suggesting something "common"...In all config string, I have mentioned the MAX20024.
Quoted 8 lines
Quoted 3 lines
With my approach we are not developing common think neither. We just want to extend/re-use existing max77686 (or max77802) driver for new devices. Just like everywhere else.
OK, fine to me if this is acceptable.
I will drop this rtc patch form this series and work in max77686 driver to modify first and once merged, use this config on my defconfig.Here, MAX686 RTC driver needs two regmap handle, one for the
rtc_regmapand other for STATUS2 register access.ret = regmap_read(info->max77686->regmap, MAX77686_REG_STATUS2, &val); if (ret < 0) { dev_err(info->dev, "%s:%d fail to read status2 reg(%d)\n", __func__, __LINE__, ret); goto out; }We can not have two regmap handle on rtc driver as both regmap (pmic and rtc) registered with different i2c device.
Also this register should not be accessed by RTC driver if we want to decouple as this is very much MAX77686 register set.
Do we need this code?
static intmax77686_rtc_read_alarm(struct device *dev, struct rtc_wkalrm *alrm){ struct max77686_rtc_info *info = dev_get_drvdata(dev); u8 data[RTC_NR_TIME]; unsigned int val; int i, ret;::::::::
alrm->pending = 0; ret = regmap_read(info->max77686->regmap, MAX77686_REG_STATUS2, &val); if (ret < 0) { dev_err(info->dev, "%s:%d fail to read status2 reg(%d)\n", __func__, __LINE__, ret); goto out; } if (val & (1 << 4)) /* RTCA1 */ alrm->pending = 1;
Quoted 1 line
}
Most of the drivers set the 'pending' field when reading alarm. Your original driver did not.
The max77802 does exactly the same (BTW, these should be merged as well... I'll add this to the TODO list) so I think this is necessary.
BR,
Krzysztof
Re: [PATCH V2 5/6] rtc: max77xxx: add RTC driver for Maxim MAX77xxx series RTC IP
Quoted 66 lines · Krzysztof Kozlowski
Quoted 65 lines · Laxman Dewangan
Quoted 15 lines · Laxman Dewangan
Quoted 10 lines · Krzysztof Kozlowski
Quoted 4 lines · Laxman Dewangan
On Wednesday 13 January 2016 05:36 AM, Krzysztof Kozlowski wrote:
That is also fine to me but still I am not comfortable with the config name and driver file name as this does not suggest the common.
The name does not matter. Really. We have a lot of drivers with a specific device-like name and supporting different devices. To point that your argument is invalid - your initial name of driver "
rtc-max77620.c" supported totally different "names": the max77620 and max20024. It also wasn't suggesting something "common"...In all config string, I have mentioned the MAX20024.
Quoted 8 lines
Quoted 3 lines
With my approach we are not developing common think neither. We just want to extend/re-use existing max77686 (or max77802) driver for new devices. Just like everywhere else.
OK, fine to me if this is acceptable.
I will drop this rtc patch form this series and work in max77686 driver to modify first and once merged, use this config on my defconfig.Here, MAX686 RTC driver needs two regmap handle, one for the
rtc_regmapand other for STATUS2 register access.ret = regmap_read(info->max77686->regmap, MAX77686_REG_STATUS2, &val); if (ret < 0) { dev_err(info->dev, "%s:%d fail to read status2 reg(%d)\n", __func__, __LINE__, ret); goto out; }We can not have two regmap handle on rtc driver as both regmap (pmic and rtc) registered with different i2c device.
Also this register should not be accessed by RTC driver if we want to decouple as this is very much MAX77686 register set.
Do we need this code?
static intmax77686_rtc_read_alarm(struct device *dev, struct rtc_wkalrm *alrm){ struct max77686_rtc_info *info = dev_get_drvdata(dev); u8 data[RTC_NR_TIME]; unsigned int val; int i, ret;::::::::
alrm->pending = 0; ret = regmap_read(info->max77686->regmap, MAX77686_REG_STATUS2, &val); if (ret < 0) { dev_err(info->dev, "%s:%d fail to read status2 reg(%d)\n", __func__, __LINE__, ret); goto out; } if (val & (1 << 4)) /* RTCA1 */ alrm->pending = 1;
Quoted 7 lines
Quoted 1 line
}
Most of the drivers set the 'pending' field when reading alarm. Your original driver did not.
The max77802 does exactly the same (BTW, these should be merged as well... I'll add this to the TODO list) so I think this is necessary.
How about merging max77802 to max77686 first? The only differences I found are:
1. It uses main MFD/PMIC regmap.
This can be solved as part of decoupling code. The driver will get
MFD's regmap and set up its own (only on max77686). The max77802 will only use parent's regmap.
2. It has different register address.
We need a register-layout/configuration structure. The logic is the
same except few differences (e.g. presence of MAX77802_RTC_AE1).
It may be easier to merge them now, before adding support for max77620? I could handle this probably next week or in the following week (assuming someone would test max77802 because I don't have the hardware).
Anyway I think we should develop these RTC patches having this in mind:
merge all of them.
Best regards,
Krzysztof
--
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 5/6] rtc: max77xxx: add RTC driver for Maxim MAX77xxx series RTC IP
Quoted 79 lines · Krzysztof Kozlowski
Quoted 61 lines · Krzysztof Kozlowski
Quoted 60 lines · Laxman Dewangan
Quoted 13 lines · Laxman Dewangan
Quoted 9 lines · Krzysztof Kozlowski
Quoted 3 lines · Laxman Dewangan
On Wednesday 13 January 2016 05:36 AM, Krzysztof Kozlowski wrote:
That is also fine to me but still I am not comfortable with the config name and driver file name as this does not suggest the common.The name does not matter. Really. We have a lot of drivers with a specific device-like name and supporting different devices. To point that your argument is invalid - your initial name of driver "
rtc-max77620.c" supported totally different "names": the max77620 and max20024. It also wasn't suggesting something "common"...In all config string, I have mentioned the MAX20024.
Quoted 7 lines
Quoted 3 lines
With my approach we are not developing common think neither. We just want to extend/re-use existing max77686 (or max77802) driver for new devices. Just like everywhere else.
OK, fine to me if this is acceptable.
I will drop this rtc patch form this series and work in max77686 driver to modify first and once merged, use this config on my defconfig.Here, MAX686 RTC driver needs two regmap handle, one for the
rtc_regmapand other for STATUS2 register access.ret = regmap_read(info->max77686->regmap, MAX77686_REG_STATUS2, &val); if (ret < 0) { dev_err(info->dev, "%s:%d fail to read status2 reg(%d)\n", __func__, __LINE__, ret); goto out; }We can not have two regmap handle on rtc driver as both regmap (pmic and rtc) registered with different i2c device.
Also this register should not be accessed by RTC driver if we want to decouple as this is very much MAX77686 register set.
Do we need this code?
static intmax77686_rtc_read_alarm(struct device *dev, struct rtc_wkalrm *alrm){ struct max77686_rtc_info *info = dev_get_drvdata(dev); u8 data[RTC_NR_TIME]; unsigned int val; int i, ret;::::::::
alrm->pending = 0; ret = regmap_read(info->max77686->regmap, MAX77686_REG_STATUS2, &val); if (ret < 0) { dev_err(info->dev, "%s:%d fail to read status2 reg(%d)\n", __func__, __LINE__, ret); goto out; } if (val & (1 << 4)) /* RTCA1 */ alrm->pending = 1;Quoted 6 lines
Quoted 1 line
}
Most of the drivers set the 'pending' field when reading alarm. Your original driver did not.
The max77802 does exactly the same (BTW, these should be merged as well... I'll add this to the TODO list) so I think this is necessary.
How about merging max77802 to max77686 first? The only differences I found are:
1. It uses main MFD/PMIC regmap.
This can be solved as part of decoupling code. The driver will get
MFD's regmap and set up its own (only on max77686). The max77802 will only use parent's regmap.2. It has different register address.
We need a register-layout/configuration structure. The logic is the
same except few differences (e.g. presence ofMAX77802_RTC_AE1).
Quoted 7 lines
It may be easier to merge them now, before adding support for max77620? I could handle this probably next week or in the following week (assuming someone would test max77802 because I don't have the hardware).
Anyway I think we should develop these RTC patches having this in mind:
merge all of them.
I think we can do the merging of max77802 and max77686 at second step.
At first, lets decouple the rtc-max77686.c with its mfd driver. This will give better picture how will it be done. Once this is there then max77620 can use this and in parallel, can be work for max77802 to use the same driver.
Let's first conclude and get accpepted for max77686 and max77620 as both of us have related HW to verify the changes.
Mark Brown
maintainerRe: [PATCH V2 5/6] rtc: max77xxx: add RTC driver for Maxim MAX77xxx series RTC IP
In reply to Krzysztof KozlowskiQuoted 3 lines · Krzysztof Kozlowski
2. It has different register address.
We need a register-layout/configuration structure. The logic is the
same except few differences (e.g. presence ofMAX77802_RTC_AE1).
Depending on what the differences are either just some variables in the driver data that get set on probe with the different registers (if it's just the register) or using regmap_field (if things get shifted as well, or if it happens to make more sense) should work.
Re: [PATCH V2 5/6] rtc: max77xxx: add RTC driver for Maxim MAX77xxx series RTC IP
In reply to Laxman DewanganHello,
Quoted 2 lines · Laxman Dewangan
Quoted 1 line · Krzysztof Kozlowski
On 14.01.2016 09:50, Krzysztof Kozlowski wrote:
[snip]
Quoted 11 lines
Quoted 11 lines
Quoted 3 lines
The max77802 does exactly the same (BTW, these should be merged as well... I'll add this to the TODO list) so I think this is necessary.
How about merging max77802 to max77686 first? The only differences I found are:
1. It uses main MFD/PMIC regmap.
This can be solved as part of decoupling code. The driver will get
MFD's regmap and set up its own (only on max77686). The max77802 will only use parent's regmap.
Quoted 5 lines
Quoted 5 lines
2. It has different register address.
We need a register-layout/configuration structure. The logic is the
same except few differences (e.g. presence ofMAX77802_RTC_AE1).It may be easier to merge them now, before adding support for max77620?
Agreed.
When I originally posted the max77802 support, I had separate MFD, RTC, regulator and clock drivers and the feedback (IIRC) was that the MFD and clock blocks were too similar to the max77686 so I extended those drivers instead of adding new ones. But that the RTC and regulator blocks were different so a separate driver was justified... but it's true that are not that different and rtc-max77686 could be extended and rtc-max77802 removed.
In fact, the ChromiumOS vendor tree has a single RTC driver for both max77686 and max77802:
Quoted 3 lines
Quoted 3 lines
I could handle this probably next week or in the following week (assuming someone would test max77802 because I don't have the hardware).
I could also work on this next week if you want. After all I feel guilty for the code duplication :-)
Quoted 8 lines
Quoted 3 lines
Anyway I think we should develop these RTC patches having this in mind:
merge all of them.I think we can do the merging of max77802 and max77686 at second step.
At first, lets decouple the
rtc-max77686.cwith its mfd driver. This will give better picture how will it be done.
I don't quite understand what you mean by decoupling here, the max77686 MFD driver today is not highly coupled to their cells devices drivers since it supports both max77802 and max77686 already. Yes, some changes will be needed but I think those should be small.
Quoted 7 lines
Once this is there then max77620 can use this and in parallel, can be work for max77802 to use the same driver.
Let's first conclude and get accpepted for max77686 and max77620 as both of us have related HW to verify the changes.
I agree with Krzysztof that merging first before extending makes more sense but I don't have a strong opinion on this and can be done as a followup as well.
Best regards,
Javier
Re: [PATCH V2 5/6] rtc: max77xxx: add RTC driver for Maxim MAX77xxx series RTC IP
In reply to Mark BrownQuoted 10 lines · Mark Brown
Quoted 3 lines · Krzysztof Kozlowski
2. It has different register address.
We need a register-layout/configuration structure. The logic is the
same except few differences (e.g. presence ofMAX77802_RTC_AE1).Depending on what the differences are either just some variables in the driver data that get set on probe with the different registers (if it's just the register) or using
regmap_field(if things get shifted as well, or if it happens to make more sense) should work.
Thanks for the hints!
The addresses for registers are indeed shifted. It is non-linear because apart of different offset at beginning, a new field appears. Anyway it would be good for me (or other person doing this work) to get more knowledge of what regmap API provides.
Best regards,
Krzysztof
Re: [PATCH V2 5/6] rtc: max77xxx: add RTC driver for Maxim MAX77xxx series RTC IP
In reply to Javier Martinez CanillasQuoted 27 lines · Javier Martinez Canillas
Hello,
Quoted 2 lines · Laxman Dewangan
Quoted 1 line · Krzysztof Kozlowski
On 14.01.2016 09:50, Krzysztof Kozlowski wrote:
[snip]
Quoted 11 lines
Quoted 11 lines
Quoted 3 lines
The max77802 does exactly the same (BTW, these should be merged as well... I'll add this to the TODO list) so I think this is necessary.
How about merging max77802 to max77686 first? The only differences I found are:
1. It uses main MFD/PMIC regmap.
This can be solved as part of decoupling code. The driver will get
MFD's regmap and set up its own (only on max77686). The max77802 will only use parent's regmap.Quoted 5 lines
Quoted 5 lines
2. It has different register address.
We need a register-layout/configuration structure. The logic is the
same except few differences (e.g. presence ofMAX77802_RTC_AE1).It may be easier to merge them now, before adding support for max77620?
Agreed.
Quoted 7 lines
When I originally posted the max77802 support, I had separate MFD, RTC, regulator and clock drivers and the feedback (IIRC) was that the MFD and clock blocks were too similar to the max77686 so I extended those drivers instead of adding new ones. But that the RTC and regulator blocks were different so a separate driver was justified... but it's true that are not that different and rtc-max77686 could be extended and rtc-max77802 removed.
Great!
Quoted 4 lines
In fact, the ChromiumOS vendor tree has a single RTC driver for both max77686 and max77802:
Quoted 8 lines
Quoted 3 lines
Quoted 3 lines
I could handle this probably next week or in the following week (assuming someone would test max77802 because I don't have the hardware).
I could also work on this next week if you want. After all I feel guilty for the code duplication :-)
So feel free to take that job from me. :) I will happily do the testing and provide complains (I mean, comments).
Quoted 7 lines
Quoted 7 lines
Quoted 4 lines
Anyway I think we should develop these RTC patches having this in mind:
merge all of them.I think we can do the merging of max77802 and max77686 at second step.
Quoted 7 lines
Quoted 2 lines
At first, lets decouple the
rtc-max77686.cwith its mfd driver. This will give better picture how will it be done.I don't quite understand what you mean by decoupling here, the max77686 MFD driver today is not highly coupled to their cells devices drivers since it supports both max77802 and max77686 already. Yes, some changes will be needed but I think those should be small.
The decoupling needed is to move RTC-related stuff (i2c_new_dummy and regmap) entirely to RTC driver. This work is independent of which driver will be merged to rtc-max77xxx first.
Quoted 5 lines
Quoted 5 lines
Once this is there then max77620 can use this and in parallel, can be work for max77802 to use the same driver.
Quoted 7 lines
Quoted 3 lines
Let's first conclude and get accpepted for max77686 and max77620 as both of us have related HW to verify the changes.
I agree with Krzysztof that merging first before extending makes more sense but I don't have a strong opinion on this and can be done as a followup as well.
AFAIR, Javier have max77802 on Chromebook, right?
Best regards,
Krzysztof
Re: [PATCH V2 5/6] rtc: max77xxx: add RTC driver for Maxim MAX77xxx series RTC IP
Quoted 38 lines · Krzysztof Kozlowski
Quoted 23 lines · Javier Martinez Canillas
Hello,
Quoted 2 lines · Laxman Dewangan
Quoted 1 line · Krzysztof Kozlowski
On 14.01.2016 09:50, Krzysztof Kozlowski wrote:
[snip]
Quoted 9 lines
Quoted 9 lines
Quoted 2 lines
The max77802 does exactly the same (BTW, these should be merged as well... I'll add this to the TODO list) so I think this is necessary.
How about merging max77802 to max77686 first? The only differences I found are:
1. It uses main MFD/PMIC regmap.
This can be solved as part of decoupling code. The driver will get
MFD's regmap and set up its own (only on max77686). The max77802 will only use parent's regmap.Quoted 5 lines
Quoted 5 lines
2. It has different register address.
We need a register-layout/configuration structure. The logic is the
same except few differences (e.g. presence ofMAX77802_RTC_AE1).It may be easier to merge them now, before adding support for max77620?
Agreed.
Quoted 7 lines
When I originally posted the max77802 support, I had separate MFD, RTC, regulator and clock drivers and the feedback (IIRC) was that the MFD and clock blocks were too similar to the max77686 so I extended those drivers instead of adding new ones. But that the RTC and regulator blocks were different so a separate driver was justified... but it's true that are not that different and rtc-max77686 could be extended and rtc-max77802 removed.
Great!
Quoted 5 lines
In fact, the ChromiumOS vendor tree has a single RTC driver for both max77686 and max77802:
Quoted 8 lines
Quoted 5 lines
Quoted 3 lines
Quoted 3 lines
I could handle this probably next week or in the following week (assuming someone would test max77802 because I don't have the hardware).
I could also work on this next week if you want. After all I feel guilty for the code duplication :-)
So feel free to take that job from me. :) I will happily do the testing and provide complains (I mean, comments).
Hi Javier,
If you can provide the patch for moving MAX77802 to MAX77686 then I can create the other change to move the regmap and i2c dummy client for rtc of max77686 to rtc driver from core on top of your change. This will completely decouple the rtc driver from core and so will be easy to use for other chip MAX77620.
Thanks,
Laxman
Re: [PATCH V2 5/6] rtc: max77xxx: add RTC driver for Maxim MAX77xxx series RTC IP
Hello Laxman and Krzysztof,
Quoted 62 lines · Laxman Dewangan
Quoted 53 lines · Krzysztof Kozlowski
Quoted 31 lines · Javier Martinez Canillas
Hello,
Quoted 4 lines · Laxman Dewangan
Quoted 2 lines · Krzysztof Kozlowski
On 14.01.2016 09:50, Krzysztof Kozlowski wrote:
[snip]
Quoted 10 lines
Quoted 10 lines
Quoted 2 lines
The max77802 does exactly the same (BTW, these should be merged as well... I'll add this to the TODO list) so I think this is necessary.
How about merging max77802 to max77686 first? The only differences I found are:
1. It uses main MFD/PMIC regmap.
This can be solved as part of decoupling code. The driver will get
MFD's regmap and set up its own (only on max77686). The max77802 will only use parent's regmap.Quoted 6 lines
Quoted 6 lines
2. It has different register address.
We need a register-layout/configuration structure. The logic is
the
same except few differences (e.g. presence ofMAX77802_RTC_AE1).It may be easier to merge them now, before adding support for max77620?
Agreed.
Quoted 7 lines
When I originally posted the max77802 support, I had separate MFD, RTC, regulator and clock drivers and the feedback (IIRC) was that the MFD and clock blocks were too similar to the max77686 so I extended those drivers instead of adding new ones. But that the RTC and regulator blocks were different so a separate driver was justified... but it's true that are not that different and rtc-max77686 could be extended and rtc-max77802 removed.
Great!
Quoted 10 lines
In fact, the ChromiumOS vendor tree has a single RTC driver for both max77686 and max77802:
Quoted 4 lines
Quoted 4 lines
I could handle this probably next week or in the following week (assuming someone would test max77802 because I don't have the hardware).
Quoted 6 lines
Quoted 2 lines
I could also work on this next week if you want. After all I feel guilty for the code duplication :-)
So feel free to take that job from me. :) I will happily do the testing and provide complains (I mean, comments).
Quoted 7 lines
Hi Javier,
If you can provide the patch for moving MAX77802 to MAX77686 then I can create the other change to move the regmap and i2c dummy client for rtc of max77686 to rtc driver from core on top of your change. This will completely decouple the rtc driver from core and so will be easy to use for other chip MAX77620.
Ok, sounds like a plan. I'll just do the change to extend rtc-max77686 to support the max77802 rtc then and let the other change to you.
I'll work on this today once I finish other task that I'm currently working on.
Quoted 3 lines
Thanks,
Laxman
Best regards,
Javier