Add support for MAXIM MAX77620/MAX20024 PMIC
Subsystems (6)
v6 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 access 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.
Changes from V2:
- Run coccicheck and checkpatch in strict mode for the alignment.
- Drop RTC driver and its i2c client registartion.
- Refactor Regulator driver to use core API for DT parsing.
Changes from V3:
- Change all sys initcall to module driver.
- change the max77620_read argument to unisgned int from u8.
Changes from V4:
- Provide more details in the dt binding doc.
- Take care of fps nodes.
- Split the submodule's DT binding doc on respective folder.
- Drop the battery charger and low battery binding and related code as it need to go on power driver.
Changes from V5:
- None
Laxman Dewangan (8):
DT: mfd: add device-tree binding doc for PMIC max77620/max20024
mfd: max77620: add core driver for MAX77620/MAX20024
DT: pinctrl: add DT binding doc for pincontrol of PMIC
max77620/max20024
pinctrl: max77620: add pincontrol driver for MAX77620/MAX20024
DT: gpio: add DT binding doc for gpio of PMIC max77620/max20024
gpio: max77620: add gpio driver for MAX77620/MAX20024
DT: regulator: add DT binding doc for regulator of PMIC
max77620/max20024regulator: max77620: add regulator driver for max77620/max20024
.../devicetree/bindings/gpio/gpio-max77620.txt | 25 + Documentation/devicetree/bindings/mfd/max77620.txt | 118 +++ .../bindings/pinctrl/pinctrl-max77620.txt | 87 +++ .../bindings/regulator/regulator-max77620.txt | 163 ++++ drivers/gpio/Kconfig | 9 + drivers/gpio/Makefile | 1 + drivers/gpio/gpio-max77620.c | 292 +++++++ drivers/mfd/Kconfig | 15 + drivers/mfd/Makefile | 1 + drivers/mfd/max77620.c | 727 ++++++++++++++++++ drivers/pinctrl/Kconfig | 10 + drivers/pinctrl/Makefile | 1 + drivers/pinctrl/pinctrl-max77620.c | 693 +++++++++++++++++ drivers/regulator/Kconfig | 9 + drivers/regulator/Makefile | 1 + drivers/regulator/max77620-regulator.c | 844 +++++++++++++++++++++ include/dt-bindings/mfd/max77620.h | 35 + include/linux/mfd/max77620.h | 406 ++++++++++ 18 files changed, 3437 insertions(+) create mode 100644 Documentation/devicetree/bindings/gpio/gpio-max77620.txt create mode 100644 Documentation/devicetree/bindings/mfd/max77620.txt create mode 100644 Documentation/devicetree/bindings/pinctrl/pinctrl-max77620.txt create mode 100644 Documentation/devicetree/bindings/regulator/regulator-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 include/dt-bindings/mfd/max77620.h create mode 100644 include/linux/mfd/max77620.h
Signature · 6 lines
2.1.4 -- To unsubscribe from this list: send the line "unsubscribe devicetree" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
PATCH v6 1/8 DT: mfd: add device-tree binding doc for 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.
Change from V2:
- added unit in period related dt property.
Change from V3: None
- Added Rob's ack.
Changes from V4:
- A- Provide more details in the dt binding doc.
- Take care of fps nodes.
- Split the submodule's DT binding doc on respective folder.
- Drop the battery charger and low battery binding and related code as it need to go on power driver.
Change from V5:
- None
Documentation/devicetree/bindings/mfd/max77620.txt | 118 +++++++++++++++++++++ include/dt-bindings/mfd/max77620.h | 35 ++++++ 2 files changed, 153 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 +118 -0
@@ -0,0 +1,118 @@ +MAX77620 Power management IC from Maxim Semiconductor. + +Required properties: +------------------- +- compatible: Must be one of + "maxim,max77620" + "maxim,max20024". +- reg: I2C device address. + +Optional properties: +------------------- +- interrupts: the interrupt on the parent the controller is + connected to +- interrupt-controller: Marks the device node as an interrupt controller. +- #interrupt-cells: is <2> and their usage is compliant to the 2 cells + variant of <../interrupt-controller/interrupts.txt> + IRQ numbers for different interrupt source of MAX77620 + are defined at dt-bindings/mfd/max77620.h. + +Optional subnodes and their properties: +======================================= + +Flexible power sequence configurations: +-------------------------------------- +The PMIC has multiple control mode: + Normal mode also called as active mode on which all step-down + regulators, all linear regulators, GPIOs, and the 32kHz + oscillator are in normal active mode. + sleep mode: Regulators/GPIOs/clock can go on OFF state based on + their configurations. + Global Low power mode (GLPM): In this mode, step-down regulators, linear + regulators, and the 32kHz oscillator are in low-power modes. + + Different modes of regulators/clock/GPIOs are controlled by the their +FPS configurations. There is different configuration registers for each of +these resources. Typical configurations per resource are: + FPS source: Attach the resource to required FPS source. When + resources are attached to one of FPS source then + resournce can be enable/disable when related FPS + source gets the control signal for ON and OFF. + Power on slot: Slot number on which resource is ON once FPS source + get ON signal. + Power down slot Slot number on which resource is OFF once FPS source + get OFF signal. + +There is three FPS source for resources called FPS0, FPS1 and FPS2. All +resources need to attached to one of these FPS. It can alsoi be set +FPS source to NONE, and on this case, it is completely controlled by +the register control rather than external input control to PMIC. + +The configuration parameters of FPS is provided through subnode "fps" +and their child for FPS specific. +The node name for FPS child are defined as "fps0", "fps1", and "fps2" for +the FPS0, FPS1 and FPS2 respectively. + +There is need for different FPS configuration parameters based on system +state like when system state changed from active to suspend or active to +power off (shutdown). + +Optinal properties: +------------------- +-maxim,fps-control: u32, FPS control source like external control input + to PMIC i.e. EN0, EN1 or software (SW). The macros + are defined on dt-bindings/mfd/max77620.h for + different control source. + FPS_CONTROL_SRC_EN0 for PMIC external input EN0. + FPS_CONTROL_SRC_EN1 for PMIC external input EN1. + FPS_CONTROL_SRC_SW for software control. + +-maxim,shutdown-fps-time-period-us: u32, FPS time period in microseconds + when system enters to shutdown state. +-maxim,suspend-fps-time-period-us: u32, FPS time period in microseconds + when system enters to suspend state. + +-maxim,enable-sleep: Boolean, enable sleep state of PMIC + when the FPS control input become active. +-maxim,enable-global-lpm: Boolean, enable Global Low Power Mode (GLPM) + of PMIC when the FPS control input become + active. + +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. + +For different sub modules like GPIO, pincontrol, regulator, power, please refer +respected device-tree binding document on respective directories. + +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>; + + fps { + fps0 { + maxim,shutdown-fps-time-period-us = <1280>; + maxim,fps-control = <FPS_CONTROL_SRC_EN1>; + }; + + fps1 { + maxim,shutdown-fps-time-period-us = <1280>; + maxim,fps-control = <FPS_CONTROL_SRC_EN0>; + }; + + fps2 { + maxim,shutdown-fps-time-period-us = <1280>; + maxim,fps-control = <FPS_CONTROL_SRC_SW>; + }; + }; +};
include/dt-bindings/mfd/max77620.h new file +35 -0
@@ -0,0 +1,35 @@ +/* +* 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 control inputs */ +#define FPS_CONTROL_SRC_EN0 0 +#define FPS_CONTROL_SRC_EN1 1 +#define FPS_CONTROL_SRC_SW 2 + +/* 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 v6 2/8 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.
---
Changes from V1:
- 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
Changes from V2:
- Run coccicheck and checkpatch in strict mode for the alignment.
- Drop RTC driver and its i2c client registration.
Changes from V3:
- Change all sys initcall to module driver.
- change the max77620_read argument to unisgned int from u8.
Changes from V4:
- Take care of fps nodes.
- Drop the battery charger and low battery binding and related code as it need to go on power driver.
Changes from V5:
-None
drivers/mfd/Kconfig | 15 + drivers/mfd/Makefile | 1 + drivers/mfd/max77620.c | 727 +++++++++++++++++++++++++++++++++++++++++++ include/linux/mfd/max77620.h | 406 ++++++++++++++++++++++++ 4 files changed, 1149 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 +727 -0
727 lines not on this page · raw message
include/linux/mfd/max77620.h new file +406 -0
406 lines not on this page · raw message
Signature · 1 line
2.1.4
Re: [PATCH V6 2/8] mfd: max77620: add core driver for MAX77620/MAX20024
Quoted 96 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]>Reviewed-by Krzysztof Kozlowski <[email protected]>---
Changes from V1:
- 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 deviceChanges from V2:
- Run coccicheck and checkpatch in strict mode for the alignment.
- Drop RTC driver and its i2c client registration.Changes from V3:
- Change all sys initcall to module driver.
- change themax77620_readargument to unisgned int from u8.Changes from V4:
- Take care of fps nodes.
- Drop the battery charger and low battery binding and related code as it need to go on power driver.
Changes from V5:(quoted diff) +0
-1-None drivers/mfd/Kconfig | 15 + drivers/mfd/Makefile | 1 + drivers/mfd/max77620.c | 727 +++++++++++++++++++++++++++++++++++++++++++ include/linux/mfd/max77620.h | 406 ++++++++++++++++++++++++ 4 files changed, 1149 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 +9
-0@@ -0,0 +1,727 @@ +/* +* 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]>
drivers/mfd/max77620.c line 19
Quoted 10 lines
drivers/mfd/max77620.c new file +10
-0+* +* 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. +*/
Can you use the shorter version?
drivers/mfd/max77620.c line 29
Quoted 9 lines
drivers/mfd/max77620.c new file +9
-0+#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>
Alphabetical.
drivers/mfd/max77620.c line 35
Quoted 5 lines
drivers/mfd/max77620.c new file +5
-0+static const char *of_max77620_fps_node_name[MAX77620_FPS_COUNT ] = { +"fps0" , +"fps1" , +"fps2" +};
No need for this arrray. Just use '"fps%d", i' in the for loop below.
Quoted 26 lines
drivers/mfd/max77620.c new file +26
-0+static struct resource gpio_resources[] = { + { + .start =MAX77620_IRQ_TOP_GPIO , + .end =MAX77620_IRQ_TOP_GPIO , + .flags =IORESOURCE_IRQ , + } +}; + +static struct resource power_resources[] = { + { + .start =MAX77620_IRQ_LBT_MBATLOW , + .end =MAX77620_IRQ_LBT_MBATLOW , + .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[] = { + {
drivers/mfd/max77620.c line 72
Quoted 10 lines
drivers/mfd/max77620.c new file +10
-0+ .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, + } +};
Simplify all of these by using the DEFINE_RES_* defines.
Quoted 34 lines
drivers/mfd/max77620.c new file +34
-0+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 , + },
drivers/mfd/max77620.c line 117
Quoted 10 lines
drivers/mfd/max77620.c new file +10
-0+ [MAX77620_IRQ_LBT_TJALRM1 ] = { + .mask =MAX77620_IRQ_TJALRM1_MASK , + .reg_offset =1 , + }, + [MAX77620_IRQ_LBT_TJALRM2 ] = { + .mask =MAX77620_IRQ_TJALRM2_MASK , + .reg_offset =1 , + }, + +};
Please simply by using REGMAP_IRQ_REG().
Quoted 17 lines
drivers/mfd/max77620.c new file +17
-0+#define MAX77620_SUB_MODULE_RES (_name, _id) \ + [_id] = { \ + .name = "max77620-"#_name, \ + .num_resources = ARRAY_SIZE(_name##_resources), \ + .resources = &_name##_resources[0], \ + .id = _id, \ + } + +#define MAX20024_SUB_MODULE_RES (_name, _id) \ + [_id] = { \ + .name = "max20024-"#_name, \ + .num_resources = ARRAY_SIZE(_name##_resources), \ + .resources = &_name##_resources[0], \ + .id = _id, \ + } + +#define MAX77620_SUB_MODULE_NO_RES (_name, _id) \
drivers/mfd/max77620.c line 145
Quoted 10 lines
drivers/mfd/max77620.c new file +10
-0+ [_id] = { \ + .name = "max77620-"#_name, \ + .id = _id, \ + } + +#define MAX20024_SUB_MODULE_NO_RES (_name, _id) \ + [_id] = { \ + .name = "max20024-"#_name, \ + .id = _id, \ + }
I don't want people hand-rolling this stuff. If it's useful to you, it's useful to others, so great a generic implementation that lives in the kernel headers directory.
drivers/mfd/max77620.c line 155
Quoted 9 lines
drivers/mfd/max77620.c new file +9
-0+static struct mfd_cell max77620_children[] = { +MAX77620_SUB_MODULE_NO_RES (pinctrl,0 ), +MAX77620_SUB_MODULE_RES (gpio,1 ), +MAX77620_SUB_MODULE_NO_RES (pmic,2 ), +MAX77620_SUB_MODULE_RES (rtc,3 ), +MAX77620_SUB_MODULE_RES (power,4 ), +MAX77620_SUB_MODULE_NO_RES (wdt,5 ), +MAX77620_SUB_MODULE_NO_RES (clk,6 ), +MAX77620_SUB_MODULE_RES (thermal,7 ),
For what purpose are you id'ing these manually?
Quoted 6 lines
drivers/mfd/max77620.c new file +6
-0+}; + +static struct mfd_cell max20024_children[] = { +MAX20024_SUB_MODULE_NO_RES (pinctrl,0 ), +MAX20024_SUB_MODULE_RES (gpio,1 ), +MAX20024_SUB_MODULE_NO_RES (pmic,2 ),
drivers/mfd/max77620.c line 171
Quoted 10 lines
drivers/mfd/max77620.c new file +10
-0+MAX20024_SUB_MODULE_RES (rtc,3 ), +MAX77620_SUB_MODULE_RES (power,4 ), +MAX20024_SUB_MODULE_NO_RES (wdt,5 ), + MAX20024_SUB_MODULE_NO_RES(clk, 6), +}; + +struct max77620_sub_modules { +struct mfd_cell *cells; +int ncells; +u32 id;
Do you have any way of interrogating the device for it's ID i.e. can you obtain this dynamically?
Quoted 105 lines
drivers/mfd/max77620.c new file +105
-0+}; + +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 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 = { + .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, +}; + +static const struct regmap_config max20024_regmap_config = { + .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, +}; + +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,unsigned int reg,unsigned int val) +{ +struct max77620_chip *chip =dev_get_drvdata (dev); + +return regmap_write (chip->rmap, reg, val); +} +EXPORT_SYMBOL_GPL (max77620_reg_write); + +int max77620_reg_read (struct device *dev,unsigned int reg,unsigned int *val) +{ +struct max77620_chip *chip =dev_get_drvdata (dev); + +return regmap_read (chip->rmap, reg, val); +}
drivers/mfd/max77620.c line 286
Quoted 10 lines
drivers/mfd/max77620.c new file +10
-0+EXPORT_SYMBOL_GPL (max77620_reg_read); + +int max77620_reg_update (struct device *dev,unsigned int reg, +unsigned int mask,unsigned int val) +{ +struct max77620_chip *chip =dev_get_drvdata (dev); + +return regmap_update_bits (chip->rmap, reg, mask, val); +} +EXPORT_SYMBOL_GPL (max77620_reg_update);
All of the above look look look abstraction for the sake of abstraction. Why aren't you ing the regmap_ calls from the child devices?
Quoted 18 lines
drivers/mfd/max77620.c new file +18
-0+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) +{
drivers/mfd/max77620.c line 315
Quoted 10 lines
drivers/mfd/max77620.c new file +10
-0+struct device *dev = chip->dev; +unsigned int mask =0 , config =0 ; +u32 pval; +int tperiod, fps_id; +int ret; + +for (fps_id =0 ; fps_id <MAX77620_FPS_COUNT ; ++fps_id) { +if (!strcmp (fps_np->name, of_max77620_fps_node_name[fps_id])) +break ; + }
Please see my comment at the declaration of of_max77620_fps_node_name for my suggestion.
drivers/mfd/max77620.c line 318
Quoted 5 lines
drivers/mfd/max77620.c new file +1
-0+if (fps_id ==MAX77620_FPS_COUNT ) {=
drivers/mfd/max77620.c new file +1
-0+dev_err (dev,"FPS child name %s is not valid\n" , fps_np->name);
"node name"
drivers/mfd/max77620.c line 323
Quoted 5 lines
drivers/mfd/max77620.c new file +5
-0+return -EINVAL ; + } + + ret =of_property_read_u32 (fps_np,"maxim,shutdown-fps-time-period-us" , + &pval);
What's a pval?
Do me that's a pointer to a value, which is not the case here.
drivers/mfd/max77620.c line 328
Quoted 5 lines
drivers/mfd/max77620.c new file +5
-0+if (!ret) { + mask |=MAX77620_FPS_TIME_PERIOD_MASK ; + chip->shutdown_fps_period[fps_id] =min (pval,5120U ); + tperiod =max77620_get_fps_period_reg_value ( + chip, chip->shutdown_fps_period[fps_id]);
Don't break lines after '('.
drivers/mfd/max77620.c line 340
Quoted 12 lines
drivers/mfd/max77620.c new file +12
-0+ config |= tperiod <<MAX77620_FPS_TIME_PERIOD_SHIFT ; + } + + ret =of_property_read_u32 (fps_np,"maxim,suspend-fps-time-period-us" , + &pval); +if (!ret) + chip->suspend_fps_period[fps_id] =min (pval,5120U ); + + ret =of_property_read_u32 (fps_np,"maxim,fps-control" , &pval); +if (!ret) { +if (pval >2 ) { +dev_err (dev,"FPS %d fps-control invalid\n" , fps_id);
You can't issue an error, then not return one.
Either return, or demote to dev_warn().
drivers/mfd/max77620.c line 353
Quoted 13 lines
drivers/mfd/max77620.c new file +13
-0+ }else { + mask |=MAX77620_FPS_EN_SRC_MASK ; + config |= (pval &0x3 ) <<MAX77620_FPS_EN_SRC_SHIFT ; +if (pval ==2 ) { + mask |=MAX77620_FPS_ENFPS_SW_MASK ; + config |=MAX77620_FPS_ENFPS_SW ; + } + } + } + +if (!chip->sleep_enable) + chip->sleep_enable =of_property_read_bool (fps_np, +"maxim,enable-sleep" );
Better to break at the '=' here.
drivers/mfd/max77620.c line 356
Quoted 3 lines
drivers/mfd/max77620.c new file +3
-0+if (!chip->enable_global_lpm) + chip->enable_global_lpm =of_property_read_bool (fps_np, +"maxim,enable-global-lpm" );
Same here.
Quoted 10 lines
drivers/mfd/max77620.c new file +10
-0+ ret =max77620_reg_update (dev,MAX77620_REG_FPS_CFG0 + fps_id, + mask, config); +if (ret <0 ) { +dev_err (dev,"Reg 0x%02x update failed: %d\n" , +MAX77620_REG_FPS_CFG0 + fps_id, ret); +return ret; + } + +return 0 ; +}
drivers/mfd/max77620.c line 377
Quoted 10 lines
drivers/mfd/max77620.c new file +10
-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) {
MAX77620_FPS_COUNT
fps_id++
Quoted 57 lines
drivers/mfd/max77620.c new file +57
-0+ chip->shutdown_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_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_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_REG_ONOFFCNFG1 , + config, config); +if (ret <0 ) { +dev_err (dev,"Reg ONOFFCNFG1 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;
drivers/mfd/max77620.c line 444
Quoted 10 lines
drivers/mfd/max77620.c new file +10
-0+ + 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 ;
These need defining.
Quoted 18 lines
drivers/mfd/max77620.c new file +18
-0+ reg_val <<=MAX77620_ONOFFCNFG1_MRT_SHIFT ; + + ret =max77620_reg_update (dev,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_REG_ONOFFCNFG2 , +MAX77620_ONOFFCNFG2_WK_ALARM1 ,0 ); +if (ret <0 ) { +dev_err (dev,"REG ONOFFCNFG2 update failed: %d\n" , ret); +return ret; + } + +return ret;
drivers/mfd/max77620.c line 473
Quoted 10 lines
drivers/mfd/max77620.c new file +10
-0+} + +static int max77620_read_es_version (struct max77620_chip *chip) +{ +unsigned int val; +u8 cid_val[6 ]; +int i; +int ret; + +for (i =MAX77620_REG_CID0 ; i <=MAX77620_REG_CID5 ; ++i) {
i++
Quoted 13 lines
drivers/mfd/max77620.c new file +12
-0+ ret =max77620_reg_read (chip->dev, 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 and CID5 is ES version */
drivers/mfd/max77620.c line 495
Quoted 10 lines
drivers/mfd/max77620.c new file +10
-0+dev_info (chip->dev,"PMIC Version OTP:0x%02X and ES:0x%02X\n" , + cid_val[4 ],MAX77620_CID5_DIDM (cid_val[5 ])); + +return ret; +} + +static int max77620_probe (struct i2c_client *client, +const struct i2c_device_id *id) +{ +struct device_node *node = client->dev.of_node;
You've used 'np' before, which also happens to be my preference.
Quoted 14 lines
drivers/mfd/max77620.c new file +14
-0+const struct max77620_sub_modules *children; +const struct regmap_config *rmap_config = &max77620_regmap_config; +struct max77620_chip *chip; +int ret =0 ; + +if (!node) { +dev_err (&client->dev,"Device is not from DT\n" ); +return -ENODEV ; + } + + children =of_device_get_match_data (&client->dev); +if (!children) +return -ENODEV ; +
drivers/mfd/max77620.c line 519
Quoted 10 lines
drivers/mfd/max77620.c new file +10
-0+ 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; + chip->base_client = client;
You don't need client AND client->dev AND client->irq.
If you have one, you have them all, please the superfluous attributes.
Quoted 18 lines
drivers/mfd/max77620.c new file +18
-0+if (chip->id ==MAX20024 ) + rmap_config = &max20024_regmap_config; + + chip->rmap =devm_regmap_init_i2c (chip->base_client, rmap_config); +if (IS_ERR (chip->rmap)) { + ret =PTR_ERR (chip->rmap); +dev_err (&client->dev,"regmap init failed %d\n" , ret); +return ret; + } + +mutex_init (&chip->mutex_config); + + ret =max77620_read_es_version (chip); +if (ret <0 ) +return ret; + + ret =max77620_initialise_chip (chip, &client->dev); +if (ret <0 )
drivers/mfd/max77620.c line 548
Quoted 10 lines
drivers/mfd/max77620.c new file +10
-0+return ret; + + ret =regmap_add_irq_chip (chip->rmap, chip->chip_irq, +IRQF_ONESHOT |IRQF_SHARED , + chip->irq_base, &max77620_top_irq_chip, + &chip->top_irq_data); +if (ret <0 ) { +dev_err (chip->dev,"Failed to add top irq_chip %d\n" , ret); +return ret; + }
What do you mean by 'top'?
drivers/mfd/max77620.c line 554
Quoted 5 lines
drivers/mfd/max77620.c new file +5
-0+ ret =max77620_initialise_fps (chip, &client->dev); +if (ret <0 ) + goto fail_free_irq; + + ret = mfd_add_devices(&client->dev, -1, children->cells,
Please use the PLATFORM_DEVID_ defines.
drivers/mfd/max77620.c line 558
Quoted 4 lines
drivers/mfd/max77620.c new file +4
-0+ children->ncells,NULL ,0 , + regmap_irq_get_domain(chip->top_irq_data)); +if (ret <0 ) { +dev_err (&client->dev,"mfd add dev fail %d\n" , ret);
"Failed to add sub devices"
Quoted 135 lines
drivers/mfd/max77620.c new file +135
-0+ goto fail_free_irq; + } + +return 0 ; + +fail_free_irq: +regmap_del_irq_chip (chip->chip_irq, chip->top_irq_data); + +return ret; +} + +static int max77620_remove (struct i2c_client *client) +{ +struct max77620_chip *chip =i2c_get_clientdata (client); + +mfd_remove_devices (chip->dev); +regmap_del_irq_chip (chip->chip_irq, chip->top_irq_data); + +return 0 ; +} + +#ifdef CONFIG_PM_SLEEP +static int max77620_set_fps_period (struct max77620_chip *chip, +int fps_id,int time_period) +{ +struct device *dev = chip->dev; +int period =max77620_get_fps_period_reg_value (chip, time_period); +int ret; + + ret =max77620_reg_update (dev,MAX77620_REG_FPS_CFG0 + fps_id, +MAX77620_FPS_TIME_PERIOD_MASK , + period <<MAX77620_FPS_TIME_PERIOD_SHIFT ); +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_i2c_suspend (struct device *dev) +{ +struct max77620_chip *chip =dev_get_drvdata (dev); +unsigned int config; +int fps; +int ret; + +for (fps =0 ; fps <2 ; ++fps) { +if (chip->suspend_fps_period[fps] <0 ) +continue ; + + ret =max77620_set_fps_period (chip, fps, + chip->suspend_fps_period[fps]); +if (ret <0 ) +dev_err (dev,"FPS%d config failed: %d\n" , fps, ret); + } + +/* +* For MAX20024: No need to configure SLPEN on suspend as +* it will be configured on Init. +*/ +if (chip->id ==MAX20024 ) + goto out; + + config = (chip->sleep_enable) ?MAX77620_ONOFFCNFG1_SLPEN :0 ; + ret =max77620_reg_update (chip->dev,MAX77620_REG_ONOFFCNFG1 , +MAX77620_ONOFFCNFG1_SLPEN , + config); +if (ret <0 ) { +dev_err (dev,"Reg ONOFFCNFG1 update failed: %d\n" , ret); +return ret; + } + +/* Disable WK_EN0 */ + ret =max77620_reg_update (chip->dev,MAX77620_REG_ONOFFCNFG2 , +MAX77620_ONOFFCNFG2_WK_EN0 ,0 ); +if (ret <0 ) { +dev_err (dev,"Reg ONOFFCNFG2 WK_EN0 update failed: %d\n" , ret); +return ret; + } + +out: +disable_irq (chip->chip_irq); + +return 0 ; +} + +static int max77620_i2c_resume (struct device *dev) +{ +struct max77620_chip *chip =dev_get_drvdata (dev); +int ret; +int fps; + +for (fps =0 ; fps <2 ; ++fps) { +if (chip->shutdown_fps_period[fps] <0 ) +continue ; + + ret =max77620_set_fps_period (chip, fps, + chip->shutdown_fps_period[fps]); +if (ret <0 ) +dev_err (dev,"FPS%d config failed: %d\n" , fps, ret); + } + +/* +* For MAX20024: No need to configure WKEN0 on resume as +* it is configured on Init. +*/ +if (chip->id ==MAX20024 ) + goto out; + +/* Enable WK_EN0 */ + ret =max77620_reg_update (chip->dev,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; + } + +out: +enable_irq (chip->chip_irq); + +return 0 ; +} +#endif + +static const struct i2c_device_id max77620_id[] = { + {"max77620" ,MAX77620 }, + {"max20024" ,MAX20024 }, + {}, +}; +MODULE_DEVICE_TABLE (i2c, max77620_id); + +static const struct of_device_id max77620_of_match[] = {
drivers/mfd/max77620.c line 703
Quoted 10 lines
drivers/mfd/max77620.c new file +10
-0+ { + .compatible = "maxim,max77620", + .data = &max77620_cells, + }, { + .compatible = "maxim,max20024", + .data = &max20024_cells, + }, { + }, +}; +MODULE_DEVICE_TABLE (of, max77620_of_match);
This is not acceptable. EITHER use DT OR MFD methods of registering devices, do not mix the two.
Quoted 29 lines
drivers/mfd/max77620.c new file +23
-0+static const struct dev_pm_ops max77620_pm_ops = { +SET_SYSTEM_SLEEP_PM_OPS (max77620_i2c_suspend, max77620_i2c_resume) +}; + +static struct i2c_driver max77620_driver = { + .driver = { + .name ="max77620" , + .pm = &max77620_pm_ops, + .of_match_table = max77620_of_match, + }, + .probe = max77620_probe, + .remove = max77620_remove, + .id_table = max77620_id, +}; + +module_i2c_driver (max77620_driver); + +MODULE_DESCRIPTION ("MAX77620/MAX20024 Multi Function Device Core Driver" ); +MODULE_AUTHOR ("Laxman Dewangan <[email protected]>" ); +MODULE_AUTHOR ("Chaitanya Bandi <[email protected]>" ); +MODULE_AUTHOR ("Mallikarjun Kasoju <[email protected]>" ); +MODULE_ALIAS ("i2c:max77620" ); +MODULE_LICENSE ("GPL v2" );include/linux/mfd/max77620.h new file +0
-0
include/linux/mfd/max77620.h line 2
Quoted 2 lines
include/linux/mfd/max77620.h new file +2
-0@@ -0,0 +1,406 @@ +/* +* max77620.h: Defining registers address and its bit definitions
Please remove the filename from the header.
include/linux/mfd/max77620.h line 15
Quoted 13 lines
include/linux/mfd/max77620.h new file +13
-0+* of MAX77620 and MAX20024 +* +* Copyright (C) 2016 NVIDIA CORPORATION. All rights reserved. +* +* 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. +*/
Can you use the shorter version?
Quoted 390 lines
include/linux/mfd/max77620.h new file +390
-0+#ifndef _LINUX_MFD_MAX77620_H_ +#define _LINUX_MFD_MAX77620_H_ + +/* GLOBAL, PMIC, GPIO, FPS, ONOFFC, CID Registers */ +#define MAX77620_REG_CNFGGLBL1 0x00 +#define MAX77620_REG_CNFGGLBL2 0x01 +#define MAX77620_REG_CNFGGLBL3 0x02 +#define MAX77620_REG_CNFG1_32K 0x03 +#define MAX77620_REG_CNFGBBC 0x04 +#define MAX77620_REG_IRQTOP 0x05 +#define MAX77620_REG_INTLBT 0x06 +#define MAX77620_REG_IRQSD 0x07 +#define MAX77620_REG_IRQ_LVL2_L0_7 0x08 +#define MAX77620_REG_IRQ_LVL2_L8 0x09 +#define MAX77620_REG_IRQ_LVL2_GPIO 0x0A +#define MAX77620_REG_ONOFFIRQ 0x0B +#define MAX77620_REG_NVERC 0x0C +#define MAX77620_REG_IRQTOPM 0x0D +#define MAX77620_REG_INTENLBT 0x0E +#define MAX77620_REG_IRQMASKSD 0x0F +#define MAX77620_REG_IRQ_MSK_L0_7 0x10 +#define MAX77620_REG_IRQ_MSK_L8 0x11 +#define MAX77620_REG_ONOFFIRQM 0x12 +#define MAX77620_REG_STATLBT 0x13 +#define MAX77620_REG_STATSD 0x14 +#define MAX77620_REG_ONOFFSTAT 0x15 + +/* SD and LDO Registers */ +#define MAX77620_REG_SD0 0x16 +#define MAX77620_REG_SD1 0x17 +#define MAX77620_REG_SD2 0x18 +#define MAX77620_REG_SD3 0x19 +#define MAX77620_REG_SD4 0x1A +#define MAX77620_REG_DVSSD0 0x1B +#define MAX77620_REG_DVSSD1 0x1C +#define MAX77620_REG_SD0_CFG 0x1D +#define MAX77620_REG_SD1_CFG 0x1E +#define MAX77620_REG_SD2_CFG 0x1F +#define MAX77620_REG_SD3_CFG 0x20 +#define MAX77620_REG_SD4_CFG 0x21 +#define MAX77620_REG_SD_CFG2 0x22 +#define MAX77620_REG_LDO0_CFG 0x23 +#define MAX77620_REG_LDO0_CFG2 0x24 +#define MAX77620_REG_LDO1_CFG 0x25 +#define MAX77620_REG_LDO1_CFG2 0x26 +#define MAX77620_REG_LDO2_CFG 0x27 +#define MAX77620_REG_LDO2_CFG2 0x28 +#define MAX77620_REG_LDO3_CFG 0x29 +#define MAX77620_REG_LDO3_CFG2 0x2A +#define MAX77620_REG_LDO4_CFG 0x2B +#define MAX77620_REG_LDO4_CFG2 0x2C +#define MAX77620_REG_LDO5_CFG 0x2D +#define MAX77620_REG_LDO5_CFG2 0x2E +#define MAX77620_REG_LDO6_CFG 0x2F +#define MAX77620_REG_LDO6_CFG2 0x30 +#define MAX77620_REG_LDO7_CFG 0x31 +#define MAX77620_REG_LDO7_CFG2 0x32 +#define MAX77620_REG_LDO8_CFG 0x33 +#define MAX77620_REG_LDO8_CFG2 0x34 +#define MAX77620_REG_LDO_CFG3 0x35 + +#define MAX77620_LDO_SLEW_RATE_MASK 0x1 + +/* LDO Configuration 3 */ +#define MAX77620_TRACK4_MASK BIT(5) +#define MAX77620_TRACK4_SHIFT 5 + +/* Voltage */ +#define MAX77620_SDX_VOLT_MASK 0xFF +#define MAX77620_SD0_VOLT_MASK 0x3F +#define MAX77620_SD1_VOLT_MASK 0x7F +#define MAX77620_LDO_VOLT_MASK 0x3F + +#define MAX77620_REG_GPIO0 0x36 +#define MAX77620_REG_GPIO1 0x37 +#define MAX77620_REG_GPIO2 0x38 +#define MAX77620_REG_GPIO3 0x39 +#define MAX77620_REG_GPIO4 0x3A +#define MAX77620_REG_GPIO5 0x3B +#define MAX77620_REG_GPIO6 0x3C +#define MAX77620_REG_GPIO7 0x3D +#define MAX77620_REG_PUE_GPIO 0x3E +#define MAX77620_REG_PDE_GPIO 0x3F +#define MAX77620_REG_AME_GPIO 0x40 +#define MAX77620_REG_ONOFFCNFG1 0x41 +#define MAX77620_REG_ONOFFCNFG2 0x42 + +/* FPS Registers */ +#define MAX77620_REG_FPS_CFG0 0x43 +#define MAX77620_REG_FPS_CFG1 0x44 +#define MAX77620_REG_FPS_CFG2 0x45 +#define MAX77620_REG_FPS_LDO0 0x46 +#define MAX77620_REG_FPS_LDO1 0x47 +#define MAX77620_REG_FPS_LDO2 0x48 +#define MAX77620_REG_FPS_LDO3 0x49 +#define MAX77620_REG_FPS_LDO4 0x4A +#define MAX77620_REG_FPS_LDO5 0x4B +#define MAX77620_REG_FPS_LDO6 0x4C +#define MAX77620_REG_FPS_LDO7 0x4D +#define MAX77620_REG_FPS_LDO8 0x4E +#define MAX77620_REG_FPS_SD0 0x4F +#define MAX77620_REG_FPS_SD1 0x50 +#define MAX77620_REG_FPS_SD2 0x51 +#define MAX77620_REG_FPS_SD3 0x52 +#define MAX77620_REG_FPS_SD4 0x53 +#define MAX77620_REG_FPS_NONE 0 + +#define MAX77620_FPS_SRC_MASK 0xC0 +#define MAX77620_FPS_SRC_SHIFT 6 +#define MAX77620_FPS_PU_PERIOD_MASK 0x38 +#define MAX77620_FPS_PU_PERIOD_SHIFT 3 +#define MAX77620_FPS_PD_PERIOD_MASK 0x07 +#define MAX77620_FPS_PD_PERIOD_SHIFT 0 +#define MAX77620_FPS_TIME_PERIOD_MASK 0x38 +#define MAX77620_FPS_TIME_PERIOD_SHIFT 3 +#define MAX77620_FPS_EN_SRC_MASK 0x06 +#define MAX77620_FPS_EN_SRC_SHIFT 1 +#define MAX77620_FPS_ENFPS_SW_MASK 0x01 +#define MAX77620_FPS_ENFPS_SW 0x01 + +#define MAX77620_REG_FPS_GPIO1 0x54 +#define MAX77620_REG_FPS_GPIO2 0x55 +#define MAX77620_REG_FPS_GPIO3 0x56 +#define MAX77620_REG_FPS_RSO 0x57 +#define MAX77620_REG_CID0 0x58 +#define MAX77620_REG_CID1 0x59 +#define MAX77620_REG_CID2 0x5A +#define MAX77620_REG_CID3 0x5B +#define MAX77620_REG_CID4 0x5C +#define MAX77620_REG_CID5 0x5D + +#define MAX77620_REG_DVSSD4 0x5E +#define MAX20024_REG_MAX_ADD 0x70 + +#define MAX77620_CID_DIDM_MASK 0xF0 +#define MAX77620_CID_DIDM_SHIFT 4 + +/* CNCG2SD */ +#define MAX77620_SD_CNF2_ROVS_EN_SD1 BIT(1) +#define MAX77620_SD_CNF2_ROVS_EN_SD0 BIT(2) + +/* Device Identification Metal */ +#define MAX77620_CID5_DIDM (n) (((n) >> 4) & 0xF) +/* Device Indentification OTP */ +#define MAX77620_CID5_DIDO (n) ((n) & 0xF) + +/* SD CNFG1 */ +#define MAX77620_SD_SR_MASK 0xC0 +#define MAX77620_SD_SR_SHIFT 6 +#define MAX77620_SD_POWER_MODE_MASK 0x30 +#define MAX77620_SD_POWER_MODE_SHIFT 4 +#define MAX77620_SD_CFG1_ADE_MASK BIT(3) +#define MAX77620_SD_CFG1_ADE_DISABLE 0 +#define MAX77620_SD_CFG1_ADE_ENABLE BIT(3) +#define MAX77620_SD_FPWM_MASK 0x04 +#define MAX77620_SD_FPWM_SHIFT 2 +#define MAX77620_SD_FSRADE_MASK 0x01 +#define MAX77620_SD_FSRADE_SHIFT 0 +#define MAX77620_SD_CFG1_FPWM_SD_MASK BIT(2) +#define MAX77620_SD_CFG1_FPWM_SD_SKIP 0 +#define MAX77620_SD_CFG1_FPWM_SD_FPWM BIT(2) +#define MAX77620_SD_CFG1_FSRADE_SD_MASK BIT(0) +#define MAX77620_SD_CFG1_FSRADE_SD_DISABLE 0 +#define MAX77620_SD_CFG1_FSRADE_SD_ENABLE BIT(0) + +/* LDO_CNFG2 */ +#define MAX77620_LDO_POWER_MODE_MASK 0xC0 +#define MAX77620_LDO_POWER_MODE_SHIFT 6 +#define MAX77620_LDO_CFG2_ADE_MASK BIT(1) +#define MAX77620_LDO_CFG2_ADE_DISABLE 0 +#define MAX77620_LDO_CFG2_ADE_ENABLE BIT(1) +#define MAX77620_LDO_CFG2_SS_MASK BIT(0) +#define MAX77620_LDO_CFG2_SS_FAST BIT(0) +#define MAX77620_LDO_CFG2_SS_SLOW 0 + +#define MAX77620_IRQ_TOP_GLBL_MASK BIT(7) +#define MAX77620_IRQ_TOP_SD_MASK BIT(6) +#define MAX77620_IRQ_TOP_LDO_MASK BIT(5) +#define MAX77620_IRQ_TOP_GPIO_MASK BIT(4) +#define MAX77620_IRQ_TOP_RTC_MASK BIT(3) +#define MAX77620_IRQ_TOP_32K_MASK BIT(2) +#define MAX77620_IRQ_TOP_ONOFF_MASK BIT(1) + +#define MAX77620_IRQ_LBM_MASK BIT(3) +#define MAX77620_IRQ_TJALRM1_MASK BIT(2) +#define MAX77620_IRQ_TJALRM2_MASK BIT(1) + +#define MAX77620_PWR_I2C_ADDR 0x3c +#define MAX77620_RTC_I2C_ADDR 0x68 + +#define MAX77620_CNFG_GPIO_DRV_MASK BIT(0) +#define MAX77620_CNFG_GPIO_DRV_PUSHPULL BIT(0) +#define MAX77620_CNFG_GPIO_DRV_OPENDRAIN 0 +#define MAX77620_CNFG_GPIO_DIR_MASK BIT(1) +#define MAX77620_CNFG_GPIO_DIR_INPUT BIT(1) +#define MAX77620_CNFG_GPIO_DIR_OUTPUT 0 +#define MAX77620_CNFG_GPIO_INPUT_VAL_MASK BIT(2) +#define MAX77620_CNFG_GPIO_OUTPUT_VAL_MASK BIT(3) +#define MAX77620_CNFG_GPIO_OUTPUT_VAL_HIGH BIT(3) +#define MAX77620_CNFG_GPIO_OUTPUT_VAL_LOW 0 +#define MAX77620_CNFG_GPIO_INT_MASK (0x3 << 4) +#define MAX77620_CNFG_GPIO_INT_FALLING BIT(4) +#define MAX77620_CNFG_GPIO_INT_RISING BIT(5) +#define MAX77620_CNFG_GPIO_DBNC_MASK (0x3 << 6) +#define MAX77620_CNFG_GPIO_DBNC_None (0x0 << 6) +#define MAX77620_CNFG_GPIO_DBNC_8ms (0x1 << 6) +#define MAX77620_CNFG_GPIO_DBNC_16ms (0x2 << 6) +#define MAX77620_CNFG_GPIO_DBNC_32ms (0x3 << 6) + +#define MAX77620_IRQ_LVL2_GPIO_EDGE0 BIT(0) +#define MAX77620_IRQ_LVL2_GPIO_EDGE1 BIT(1) +#define MAX77620_IRQ_LVL2_GPIO_EDGE2 BIT(2) +#define MAX77620_IRQ_LVL2_GPIO_EDGE3 BIT(3) +#define MAX77620_IRQ_LVL2_GPIO_EDGE4 BIT(4) +#define MAX77620_IRQ_LVL2_GPIO_EDGE5 BIT(5) +#define MAX77620_IRQ_LVL2_GPIO_EDGE6 BIT(6) +#define MAX77620_IRQ_LVL2_GPIO_EDGE7 BIT(7) + +#define MAX77620_CNFG1_32K_OUT0_EN BIT(2) + +#define MAX77620_ONOFFCNFG1_SFT_RST BIT(7) +#define MAX77620_ONOFFCNFG1_MRT_MASK 0x38 +#define MAX77620_ONOFFCNFG1_MRT_SHIFT 0x3 +#define MAX77620_ONOFFCNFG1_SLPEN BIT(2) +#define MAX77620_ONOFFCNFG1_PWR_OFF BIT(1) +#define MAX20024_ONOFFCNFG1_CLRSE 0x18 + +#define MAX77620_ONOFFCNFG2_SFT_RST_WK BIT(7) +#define MAX77620_ONOFFCNFG2_WD_RST_WK BIT(6) +#define MAX77620_ONOFFCNFG2_SLP_LPM_MSK BIT(5) +#define MAX77620_ONOFFCNFG2_WK_ALARM1 BIT(2) +#define MAX77620_ONOFFCNFG2_WK_EN0 BIT(0) + +#define MAX77620_GLBLM_MASK BIT(0) + +#define MAX77620_WDTC_MASK 0x3 +#define MAX77620_WDTOFFC BIT(4) +#define MAX77620_WDTSLPC BIT(3) +#define MAX77620_WDTEN BIT(2) + +#define MAX77620_TWD_MASK 0x3 +#define MAX77620_TWD_2s 0x0 +#define MAX77620_TWD_16s 0x1 +#define MAX77620_TWD_64s 0x2 +#define MAX77620_TWD_128s 0x3 + +#define MAX77620_CNFGGLBL1_LBDAC_EN BIT(7) +#define MAX77620_CNFGGLBL1_MPPLD BIT(6) +#define MAX77620_CNFGGLBL1_LBHYST (BIT(5) | BIT(4)) +#define MAX77620_CNFGGLBL1_LBDAC 0x0E +#define MAX77620_CNFGGLBL1_LBRSTEN BIT(0) + +/* CNFG BBC registers */ +#define MAX77620_CNFGBBC_ENABLE BIT(0) +#define MAX77620_CNFGBBC_CURRENT_MASK 0x06 +#define MAX77620_CNFGBBC_CURRENT_SHIFT 1 +#define MAX77620_CNFGBBC_VOLTAGE_MASK 0x18 +#define MAX77620_CNFGBBC_VOLTAGE_SHIFT 3 +#define MAX77620_CNFGBBC_LOW_CURRENT_DISABLE BIT(5) +#define MAX77620_CNFGBBC_RESISTOR_MASK 0xC0 +#define MAX77620_CNFGBBC_RESISTOR_SHIFT 6 + +#define MAX77620_FPS_COUNT 3 + +/* I2c Slave Id */ +enum { +MAX77620_PWR_SLAVE , +MAX77620_RTC_SLAVE , +MAX77620_NUM_SLAVES , +}; + +/* GPIOs */ +enum { +MAX77620_GPIO0 , +MAX77620_GPIO1 , +MAX77620_GPIO2 , +MAX77620_GPIO3 , +MAX77620_GPIO4 , +MAX77620_GPIO5 , +MAX77620_GPIO6 , +MAX77620_GPIO7 , + +MAX77620_GPIO_NR , +}; + +/* Interrupts */ +enum { +MAX77620_IRQ_TOP_GLBL ,/* Low-Battery */ +MAX77620_IRQ_TOP_SD ,/* SD power fail */ +MAX77620_IRQ_TOP_LDO ,/* LDO power fail */ +MAX77620_IRQ_TOP_GPIO ,/* TOP GPIO internal int to MAX77620 */ +MAX77620_IRQ_TOP_RTC ,/* RTC */ +MAX77620_IRQ_TOP_32K ,/* 32kHz oscillator */ +MAX77620_IRQ_TOP_ONOFF ,/* ON/OFF oscillator */ + +MAX77620_IRQ_LBT_MBATLOW ,/* Thermal alarm status, > 120C */ +MAX77620_IRQ_LBT_TJALRM1 ,/* Thermal alarm status, > 120C */ +MAX77620_IRQ_LBT_TJALRM2 ,/* Thermal alarm status, > 140C */ + +MAX77620_IRQ_GPIO0 ,/* GPIO0 edge detection */ +MAX77620_IRQ_GPIO1 ,/* GPIO1 edge detection */ +MAX77620_IRQ_GPIO2 ,/* GPIO2 edge detection */ +MAX77620_IRQ_GPIO3 ,/* GPIO3 edge detection */ +MAX77620_IRQ_GPIO4 ,/* GPIO4 edge detection */ +MAX77620_IRQ_GPIO5 ,/* GPIO5 edge detection */ +MAX77620_IRQ_GPIO6 ,/* GPIO6 edge detection */ +MAX77620_IRQ_GPIO7 ,/* GPIO7 edge detection */ + +MAX77620_IRQ_ONOFF_MRWRN ,/* Hard power off warnning */ +MAX77620_IRQ_ONOFF_EN0_1SEC ,/* EN0 active for 1s */ +MAX77620_IRQ_ONOFF_EN0_F ,/* EN0 falling */ +MAX77620_IRQ_ONOFF_EN0_R ,/* EN0 rising */ +MAX77620_IRQ_ONOFF_LID_F ,/* LID falling */ +MAX77620_IRQ_ONOFF_LID_R ,/* LID rising */ +MAX77620_IRQ_ONOFF_ACOK_F ,/* ACOK falling */ +MAX77620_IRQ_ONOFF_ACOK_R ,/* ACOK rising */ + +MAX77620_IRQ_NVER ,/* Non-Volatile Event Recorder */ +MAX77620_IRQ_NR , +}; + +enum max77620_regulators { +MAX77620_REGULATOR_ID_SD0 , +MAX77620_REGULATOR_ID_SD1 , +MAX77620_REGULATOR_ID_SD2 , +MAX77620_REGULATOR_ID_SD3 , +MAX77620_REGULATOR_ID_SD4 , +MAX77620_REGULATOR_ID_LDO0 , +MAX77620_REGULATOR_ID_LDO1 , +MAX77620_REGULATOR_ID_LDO2 , +MAX77620_REGULATOR_ID_LDO3 , +MAX77620_REGULATOR_ID_LDO4 , +MAX77620_REGULATOR_ID_LDO5 , +MAX77620_REGULATOR_ID_LDO6 , +MAX77620_REGULATOR_ID_LDO7 , +MAX77620_REGULATOR_ID_LDO8 , +MAX77620_NUM_REGS , +}; + +/* FPS Source */ +enum max77620_regulator_fps_src { +FPS_SRC_0 , +FPS_SRC_1 , +FPS_SRC_2 , +FPS_SRC_NONE , +FPS_SRC_DEF , +}; + +/* Regulator types */ +enum max77620_regulator_type { +MAX77620_REGULATOR_TYPE_SD , +MAX77620_REGULATOR_TYPE_LDO_N , +MAX77620_REGULATOR_TYPE_LDO_P , +}; + +enum max77620_chip_id { +MAX77620 , +MAX20024 , +}; + +struct max77620_chip { +struct device *dev; + +struct i2c_client *base_client; +struct regmap *rmap; + +int chip_irq; +int irq_base; + +struct mutex mutex_config; +bool sleep_enable; +bool enable_global_lpm; +int shutdown_fps_period[MAX77620_FPS_COUNT ]; +int suspend_fps_period[MAX77620_FPS_COUNT ]; + +struct regmap_irq_chip_data *top_irq_data; +struct regmap_irq_chip_data *gpio_irq_data; + +/* chip id */ +u32 id; +}; + +extern int max77620_irq_get_virq (struct device *dev,int irq); +extern int max77620_reg_write (struct device *dev,unsigned int reg, +unsigned int val); +extern int max77620_reg_read (struct device *dev,unsigned int reg, +unsigned int *val); +extern int max77620_reg_update (struct device *dev,unsigned int reg, +unsigned int mask,unsigned int val); +#endif /* _LINUX_MFD_MAX77620_H_ */
Signature · 4 lines
Lee Jones Linaro STMicroelectronics Landing Team Lead Linaro.org │ Open source software for ARM SoCs Follow Linaro: Facebook | Twitter | Blog
Re: [PATCH V6 2/8] mfd: max77620: add core driver for MAX77620/MAX20024
Thanks Lee for review.
I will take care of most of stuff on next version of patch.
However, I have some query form your comment.
Quoted 13 lines · Lee Jones
drivers/mfd/max77620.c line 145
Quoted 7 lines · Laxman Dewangan
drivers/mfd/max77620.c new file +7
-0+ } + +#define MAX20024_SUB_MODULE_NO_RES (_name, _id) \ + [_id] = { \ + .name = "max20024-"#_name, \ + .id = _id, \ + }I don't want people hand-rolling this stuff. If it's useful to you, it's useful to others, so great a generic implementation that lives in the kernel headers directory.
yaah, generic implementation possible. I can put the new defines in the mfd/core.h.
This will be similar to
+/* Define mfd cells with name and resource */
+#define DEFINE_MFD_CELL_NAME_RESOURCE(_name, _res) \
+ { \
+ .name = (_name), \
+ .num_resources = ARRAY_SIZE((res)), \
+ .resources = (_res), \
+ }
+
+/* Define mfd cells with name */
+#define DEFINE_MFD_CELL_NAME(_name) \
+ { \
+ .name = (_name), \+ }
+
This will be separate patch and should be applied before this series. Does it look fine?
Quoted 13 lines
Quoted 13 lines
drivers/mfd/max77620.c new file +12
-0+static const struct i2c_device_id max77620_id[] = { + {"max77620" ,MAX77620 }, + {"max20024" ,MAX20024 }, + {}, +}; +MODULE_DEVICE_TABLE (i2c, max77620_id); + +static const struct of_device_id max77620_of_match[] = { + { + .compatible ="maxim,max77620" , + .data = &max77620_cells, + }, {
Quoted 8 lines
drivers/mfd/max77620.c line 703
Quoted 6 lines
drivers/mfd/max77620.c new file +6
-0+ .compatible = "maxim,max20024", + .data = &max20024_cells, + }, { + }, +}; +MODULE_DEVICE_TABLE (of, max77620_of_match);This is not acceptable. EITHER use DT OR MFD methods of registering devices, do not mix the two.
You mean I need to either provide the i2c_device_id table or the of_device_id table, not both? Do I need to protect it by CONFIG_OF?
This only support the DT method of registration. So do I need to remove i2c_device_id?
--
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 V6 2/8] mfd: max77620: add core driver for MAX77620/MAX20024
Quoted 38 lines · Laxman Dewangan
Thanks Lee for review.
I will take care of most of stuff on next version of patch.However, I have some query form your comment.
Quoted 13 lines · Lee Jones
drivers/mfd/max77620.c line 145
Quoted 7 lines · Laxman Dewangan
drivers/mfd/max77620.c new file +7
-0+ } + +#define MAX20024_SUB_MODULE_NO_RES (_name, _id) \ + [_id] = { \ + .name = "max20024-"#_name, \ + .id = _id, \ + }I don't want people hand-rolling this stuff. If it's useful to you, it's useful to others, so great a generic implementation that lives in the kernel headers directory.
yaah, generic implementation possible. I can put the new defines in the
mfd/core.h.This will be similar to
(quoted diff) +14
-0+/* Define mfd cells with name and resource */ +#define DEFINE_MFD_CELL_NAME_RESOURCE(_name, _res) \ + { \ + .name = (_name), \ + .num_resources = ARRAY_SIZE((res)), \ + .resources = (_res), \ + } + +/* Define mfd cells with name */ +#define DEFINE_MFD_CELL_NAME(_name) \ + { \ + .name = (_name), \ + } +
Quoted 2 lines
This will be separate patch and should be applied before this series. Does it look fine?
Hmm... Actually, I have my own ideas of how this should look. How do you feel about me submitting my own patch. I'll keep you on Cc, so you can review and make use of it in your set.
Quoted 21 lines
Quoted 12 lines
Quoted 12 lines
drivers/mfd/max77620.c new file +12
-0+static const struct i2c_device_id max77620_id[] = { + {"max77620" ,MAX77620 }, + {"max20024" ,MAX20024 }, + {}, +}; +MODULE_DEVICE_TABLE (i2c, max77620_id); + +static const struct of_device_id max77620_of_match[] = { + { + .compatible ="maxim,max77620" , + .data = &max77620_cells, + }, {Quoted 8 lines
drivers/mfd/max77620.c line 703
Quoted 6 lines
drivers/mfd/max77620.c new file +6
-0+ .compatible = "maxim,max20024", + .data = &max20024_cells, + }, { + }, +}; +MODULE_DEVICE_TABLE (of, max77620_of_match);This is not acceptable. EITHER use DT OR MFD methods of registering devices, do not mix the two.
Quoted 6 lines
You mean I need to either provide the
i2c_device_idtable or theof_device_idtable, not both?
Do I need to protect it byCONFIG_OF?This only support the DT method of registration. So do I need to remove
i2c_device_id?
No, I mean I don't want you providing platform data via an MFD cell and passing it through the OF .data attribute.
Signature · 8 lines
Lee Jones Linaro STMicroelectronics Landing Team Lead Linaro.org │ Open source software for ARM SoCs Follow Linaro: Facebook | Twitter | Blog -- To unsubscribe from this list: send the line "unsubscribe linux-gpio" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH V6 2/8] mfd: max77620: add core driver for MAX77620/MAX20024
Quoted 39 lines · Lee Jones
Quoted 37 lines · Laxman Dewangan
Thanks Lee for review.
I will take care of most of stuff on next version of patch.However, I have some query form your comment.
Quoted 13 lines · Lee Jones
drivers/mfd/max77620.c line 145
Quoted 7 lines · Laxman Dewangan
drivers/mfd/max77620.c new file +7
-0+ } + +#define MAX20024_SUB_MODULE_NO_RES (_name, _id) \ + [_id] = { \ + .name = "max20024-"#_name, \ + .id = _id, \ + }I don't want people hand-rolling this stuff. If it's useful to you, it's useful to others, so great a generic implementation that lives in the kernel headers directory.
yaah, generic implementation possible. I can put the new defines in the
mfd/core.h.This will be similar to
(quoted diff) +14
-0+/* Define mfd cells with name and resource */ +#define DEFINE_MFD_CELL_NAME_RESOURCE(_name, _res) \ + { \ + .name = (_name), \ + .num_resources = ARRAY_SIZE((res)), \ + .resources = (_res), \ + } + +/* Define mfd cells with name */ +#define DEFINE_MFD_CELL_NAME(_name) \ + { \ + .name = (_name), \ + } +
Quoted 5 lines
Quoted 2 lines
This will be separate patch and should be applied before this series. Does it look fine?
Hmm... Actually, I have my own ideas of how this should look. How do you feel about me submitting my own patch. I'll keep you on Cc, so you can review and make use of it in your set.
Sure, I am fine with this. Please send the patch and CC me so that I can make my patch on top of it and void my mfd/core.h patch. Thanks for taking care.
Quoted 20 lines
Quoted 20 lines
Quoted 20 lines
Quoted 8 lines
drivers/mfd/max77620.c new file +8
-0+static const struct i2c_device_id max77620_id[] = { + {"max77620" ,MAX77620 }, + {"max20024" ,MAX20024 }, + {}, +}; +MODULE_DEVICE_TABLE (i2c, max77620_id); + +static const struct of_device_id max77620_of_match[] = {drivers/mfd/max77620.c line 703
Quoted 10 lines
drivers/mfd/max77620.c new file +10
-0+ { + .compatible = "maxim,max77620", + .data = &max77620_cells, + }, { + .compatible = "maxim,max20024", + .data = &max20024_cells, + }, { + }, +}; +MODULE_DEVICE_TABLE (of, max77620_of_match);This is not acceptable. EITHER use DT OR MFD methods of registering devices, do not mix the two.
Quoted 8 lines
Quoted 6 lines
You mean I need to either provide the
i2c_device_idtable or theof_device_idtable, not both?
Do I need to protect it byCONFIG_OF?This only support the DT method of registration. So do I need to remove
i2c_device_id?No, I mean I don't want you providing platform data via an MFD cell and passing it through the OF .data attribute.
This is not platform data, this is chip specific data.
However, In patch V7, I removed this and use the id_table for the chip data to optimized the chip ID. This is not required.
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
PATCH v6 3/8 DT: pinctrl: add DT binding doc for pincontrol of PMIC max77620/max20024
In reply to Laxman DewanganMaxim Semiconductor's PMIC MAX77620/MAX20024 has 8 GPIO pins which act as GPIO as well as special function mode.
Add DT binding document to configure pins in function mode as well as pin configuration parameters.
---
Changes from V4:
- Separate out from pincontrol driver
.../bindings/pinctrl/pinctrl-max77620.txt | 87 ++++++++++++++++++++++ 1 file changed, 87 insertions(+) create mode 100644 Documentation/devicetree/bindings/pinctrl/pinctrl-max77620.txt
Documentation/devicetree/bindings/pinctrl/pinctrl-max77620.txt new file +87 -0
@@ -0,0 +1,87 @@ +Pincontrol driver for MAX77620 Power management IC from Maxim Semiconductor. + +Device has 8 GPIO pins which can be configured as GPIO as well as the +special IO functions. + +Please refer file <devicetree/bindings/pinctrl/pinctrl-bindings.txt> +for details of the common pinctrl bindings used by client devices, +including the meaning of the phrase "pin configuration node". + +Optional Pinmux properties: +-------------------------- +Following properties are require if pin control setting is required at boot. +- pinctrl-names: A pinctrl state named per <pinctrl-binding.txt>. +- pinctrl[0...n]: Properties to contain the phandle for pinctrl states per + <pinctrl-binding.txt>. + +The pin configurations are defined as child of the pinctrl states node. Each +sub-node 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: +Following are optional properties defined as pinmux DT binding document +<pinctrl-bindings.txt>. Absence of properties will leave the configuration +on default. + function, + drive-push-pull, + drive-open-drain, + bias-pull-up, + bias-pull-down. + +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 properties for the GPIO1, GPIO2 and GPIO3. +The properties are required to configure these resource FPS parameters +when system is in "active" state or in "suspend" state. +Here "active" state means system is UP and working normally. +"suspend" state means system enters into the suspend state. + +- 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 active 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 to 7. +- maxim,suspend-fps-source: Suspend state FPS source. Valid values are + same as maxim,active-fps-source. +- maxim,suspend-fps-power-down-slot: Suspend state power down slot. Valid + values are 0 to 7. +- maxim,suspend-fps-power-up-slot: Suspend state power up slot. Valid values + are 0 to 7. + +Example: +-------- +#include <dt-bindings/mfd/max77620.h> +... +max77620@3c { + + pinctrl-names = "default"; + pinctrl-0 = <&spmic_default>; + + spmic_default: pinmux@0 { + pin_gpio0 { + pins = "gpio0"; + function = "gpio"; + }; + + pin_gpio1 { + pins = "gpio1"; + function = "fps-out"; + maxim,fps-source = <FPS_SRC_0>; + }; + + pin_gpio2 { + pins = "gpio2"; + function = "fps-out"; + maxim,fps-source = <FPS_SRC_1>; + }; + }; +};
Signature · 1 line
2.1.4
PATCH v6 4/8 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.
Changes form V2:
- Run coccicheck and checkpatch in strict mode for the alignment.
- update based on api changes from core.
Changes from V3:
- Change all sys initcall to module driver.
- change the max77620_read argument to unisgned int from u8.
Changes from V4:
- Added DT binding document as devicetree/bindings/pinctrl/pinctrl-max77620.txt
- Detail out properties as per review comment.
Changes from V5:
- Separate out DT binding doc for pincontrol.
- Added reviewed by for Linus W
drivers/pinctrl/Kconfig | 10 + drivers/pinctrl/Makefile | 1 + drivers/pinctrl/pinctrl-max77620.c | 693 +++++++++++++++++++++++++++++++++++++ 3 files changed, 704 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 +693 -0
693 lines not on this page · raw message
Signature · 1 line
2.1.4
PATCH v6 5/8 DT: gpio: add DT binding doc for gpio of PMIC max77620/max20024
In reply to Laxman DewanganMaxim Semiconductor's PMIC MAX77620/MAX20024 has 8 GPIO pins which act as GPIO as well as special function mode.
Add DT binding document to support these pins in GPIO mode via GPIO framework.
---
Changes from V4:
- Separate out from gpio driver
.../devicetree/bindings/gpio/gpio-max77620.txt | 25 ++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 Documentation/devicetree/bindings/gpio/gpio-max77620.txt
Documentation/devicetree/bindings/gpio/gpio-max77620.txt new file +25 -0
@@ -0,0 +1,25 @@ +GPIO driver for MAX77620 Power management IC from Maxim Semiconductor. + +Device has 8 GPIO pins which can be configured as GPIO as well as the +special IO functions. + +Required properties: +------------------- +- gpio-controller : Marks the device node as a gpio controller. +- #gpio-cells : Should be two. The first cell is the pin number and + the second cell is used to specify the gpio polarity: + 0 = active high + 1 = active low +For more details, please refer generic GPIO DT binding document +<devicetree/bindings/gpio/gpio.txt>. + +Example: +-------- +#include <dt-bindings/mfd/max77620.h> +... +max77620@3c { + compatible = "maxim,max77620"; + + gpio-controller; + #gpio-cells = <2>; +};
Signature · 1 line
2.1.4
PATCH v6 6/8 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.
---
Changes from V1:
- 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.
Changes form V2:
- Run coccicheck and checkpatch in strict mode for the alignment.
- update based on api changes from core.
Changes from V3:
- Change all sys initcall to module driver.
- change the max77620_read argument to unisgned int from u8.
Changes from V4:
- Added DT binding document as devicetree/bindings/gpio/gpio-max77620.txt
Changes from V5:
- Separate out DT binding doc for gpio.
- Added reviewed by for Linus W
drivers/gpio/Kconfig | 9 ++ drivers/gpio/Makefile | 1 + drivers/gpio/gpio-max77620.c | 292 +++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 302 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 +292 -0
292 lines not on this page · raw message
Signature · 1 line
2.1.4
PATCH v6 7/8 DT: regulator: add DT binding doc for regulator of PMIC max77620/max20024
In reply to Laxman DewanganMaxim Semiconductor's PMIC MAX77620/MAX20024 has multiple DCDCs and LDOs.
Add DT binding document to support these regulators via regulator framework.
---
Changes from V4:
- Separate out from regulator driver
.../bindings/regulator/regulator-max77620.txt | 163 +++++++++++++++++++++ 1 file changed, 163 insertions(+) create mode 100644 Documentation/devicetree/bindings/regulator/regulator-max77620.txt
Documentation/devicetree/bindings/regulator/regulator-max77620.txt new file +163 -0
@@ -0,0 +1,163 @@ +Regulator DT binding for MAX77620 Power management IC from Maxim Semiconductor. + +Device has multiple DCDC(sd[0-3] and LDOs(ldo[0-8]). The details of regulator +properties are defined under the sub node "regulators" of parent node. + +Please refer file <Documentation/devicetree/bindings/regulator/regulator.txt> +for common regulator bindings used by client. + +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. The definition for each of these +nodes is defined using the standard binding for regulators found at +<Documentation/devicetree/bindings/regulator/regulator.txt>. + +Theres is also additional properties for SD/LDOs. +The properties are required to configure SDs/LDOs FPS parameters +when system is in "active" state or in "suspend" state. +Here "active" state means system is UP and working normally. +"suspend" state means system enters into the suspend state. + +- 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 active 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 to 7. +- maxim,suspend-fps-source: Suspend state FPS source. Valid values are + same as maxim,active-fps-source. +- maxim,suspend-fps-power-down-slot: Suspend state power down slot. Valid + values are 0 to 7. +- maxim,suspend-fps-power-up-slot: Suspend state power up slot. Valid values + are 0 to 7. +- maxim,disable-active-discharge: boolean, Disable active discharge. + +Example: +-------- +#include <dt-bindings/mfd/max77620.h> +... +max77620@3c { + regulators { + in-ldo0-1-supply = <&max77620_sd2>; + in-ldo7-8-supply = <&max77620_sd2>; + + sd0 { + regulator-name = "vdd-core"; + regulator-min-microvolt = <600000>; + regulator-max-microvolt = <1400000>; + regulator-boot-on; + regulator-always-on; + maxim,active-fps-source = <FPS_SRC_1>; + }; + + sd1 { + regulator-name = "vddio-ddr"; + regulator-min-microvolt = <1200000>; + regulator-max-microvolt = <1200000>; + regulator-always-on; + regulator-boot-on; + maxim,active-fps-source = <FPS_SRC_0>; + }; + + sd2 { + regulator-name = "vdd-pre-reg"; + regulator-min-microvolt = <1350000>; + regulator-max-microvolt = <1350000>; + }; + + sd3 { + regulator-name = "vdd-1v8"; + regulator-min-microvolt = <1800000>; + regulator-max-microvolt = <1800000>; + regulator-always-on; + regulator-boot-on; + }; + + ldo0 { + regulator-name = "avdd-sys"; + regulator-min-microvolt = <1200000>; + regulator-max-microvolt = <1200000>; + regulator-always-on; + regulator-boot-on; + }; + + ldo1 { + regulator-name = "vdd-pex"; + regulator-min-microvolt = <1050000>; + regulator-max-microvolt = <1050000>; + }; + + ldo2 { + regulator-name = "vddio-sdmmc3"; + regulator-min-microvolt = <1800000>; + regulator-max-microvolt = <3300000>; + }; + + ldo3 { + regulator-name = "vdd-cam-hv"; + regulator-min-microvolt = <2800000>; + regulator-max-microvolt = <2800000>; + }; + + ldo4 { + regulator-name = "vdd-rtc"; + regulator-min-microvolt = <1250000>; + regulator-max-microvolt = <1250000>; + regulator-always-on; + regulator-boot-on; + }; + + ldo5 { + regulator-name = "avdd-ts-hv"; + regulator-min-microvolt = <3000000>; + regulator-max-microvolt = <3000000>; + }; + + ldo6 { + regulator-name = "vdd-ts"; + regulator-min-microvolt = <1800000>; + regulator-max-microvolt = <1800000>; + regulator-always-on; + regulator-boot-on; + }; + + ldo7 { + regulator-name = "vdd-gen-pll-edp"; + regulator-min-microvolt = <1050000>; + regulator-max-microvolt = <1050000>; + regulator-always-on; + regulator-boot-on; + }; + + ldo8 { + regulator-name = "vdd-hdmi-dp"; + regulator-min-microvolt = <1050000>; + regulator-max-microvolt = <1050000>; + }; + }; +};
Signature · 1 line
2.1.4
Mark Brown
maintainerRe: [PATCH V6 7/8] DT: regulator: add DT binding doc for regulator of PMIC max77620/max20024
Quoted 2 lines · Laxman Dewangan
Maxim Semiconductor's PMIC MAX77620/MAX20024 has multiple DCDCs and LDOs.
Please use subject lines matching the style for the subsystem. I'm fairly sure I've mentioned this before and really if your subject lines don't visually resemble anything else in the directory that ought to be a warning sign.
Quoted 1 line
+- maxim,disable-active-discharge: boolean, Disable active discharge.
That's something I've seen other regulators do, can we make it a standard property with an op?
Documentation/devicetree/bindings/regulator/regulator-max77620.txt line 67
Quoted 4 lines
Documentation/devicetree/bindings/regulator/regulator-max77620.txt new file +4
-0+max77620@3c { + regulators { + in-ldo0-1-supply = <&max77620_sd2>; + in-ldo7-8-supply = <&max77620_sd2>;
I'd expect any supplies for the device to be at the device level, including supplies used by regulators.
PATCH v6 8/8 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.
Changes form V2:
- Run coccicheck and checkpatch in strict mode for the alignment.
- Refactor Regulator driver to use core API for DT parsing.
- Update based on API changes.
Changes from V3:
- Change all sys initcall to module driver.
- change the max77620_read argument to unisgned int from u8.
Changes from V4:
- Added DT binding document as devicetree/bindings/regulator/regulator-max77620.txt
- Detail out properties.
Changes from V5:
- Separate out DT binding doc for regulator.
drivers/regulator/Kconfig | 9 + drivers/regulator/Makefile | 1 + drivers/regulator/max77620-regulator.c | 844 +++++++++++++++++++++++++++++++++ 3 files changed, 854 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 +844 -0
844 lines not on this page · raw message
Signature · 1 line
2.1.4