da9061: DA9061 driver submission
Subsystems (7)
v5 cover da9061: DA9061 driver submission
From: Steve Twiss <[email protected]>
This patch set adds support for the Dialog DA9061 Power Management IC. Support is made by altering the existing DA9062 device driver, where appropriate.
In this patch set the following is provided:
[PATCH V5 1/8] Binding for watchdog
[PATCH V5 2/8] Binding for thermal supervisor
[PATCH V5 3/8] Binding for MFD and regulators
[PATCH V5 4/8] MFD core support
[PATCH V5 5/8] BUCKs and LDOs
[PATCH V5 6/8] Watchdog
[PATCH V5 7/8] PMIC temperature monitoring
[PATCH V5 8/8] MAINTAINERS update
Some previous patches from this set have been applied already:
Onkey binding -- https://lkml.org/lkml/2016/11/8/958
Onkey driver -- https://lkml.org/lkml/2016/10/26/1169
This patch applies against linux-next and v4.9
Thank you,
Steve Twiss, Dialog Semiconductor Ltd.
Steve Twiss (8):
Documentation: devicetree: watchdog: da9062/61 watchdog timer binding
Documentation: devicetree: thermal: da9062/61 TJUNC temperature
binding
Documentation: devicetree: mfd: da9062/61 MFD binding
mfd: da9061: MFD core support
regulator: da9061: BUCK and LDO regulator driver
watchdog: da9062/61: watchdog driver
thermal: da9062/61: Thermal junction temperature monitoring driver
MAINTAINERS: da9062/61 updates to the Dialog Semiconductor search
terms
Documentation/devicetree/bindings/mfd/da9062.txt | 49 ++- .../devicetree/bindings/thermal/da9062-thermal.txt | 37 ++ .../devicetree/bindings/watchdog/da9062-wdt.txt | 23 ++ MAINTAINERS | 4 + drivers/mfd/Kconfig | 5 +- drivers/mfd/da9062-core.c | 424 ++++++++++++++++++++- drivers/regulator/Kconfig | 4 +- drivers/regulator/da9062-regulator.c | 301 ++++++++++++++- drivers/thermal/Kconfig | 10 + drivers/thermal/Makefile | 1 + drivers/thermal/da9062-thermal.c | 314 +++++++++++++++ drivers/watchdog/Kconfig | 4 +- drivers/watchdog/da9062_wdt.c | 12 +- include/linux/mfd/da9062/core.h | 27 +- include/linux/mfd/da9062/registers.h | 2 + 15 files changed, 1168 insertions(+), 49 deletions(-) create mode 100644 Documentation/devicetree/bindings/thermal/da9062-thermal.txt create mode 100644 Documentation/devicetree/bindings/watchdog/da9062-wdt.txt create mode 100644 drivers/thermal/da9062-thermal.c
Signature · 1 line
end-of-patch for PATCH V5
PATCH v5 1/8 Documentation: devicetree: watchdog: da9062/61 watchdog timer binding
From: Steve Twiss <[email protected]>
Add binding information for DA9062 and DA9061 watchdog.
Example bindings for both DA9062 and DA9061 devices are added. For the DA9061 device, a fallback compatible line is added as a valid combination of compatible strings.
The original binding for DA9062 (only) used to reside inside the Documentation/devicetree/bindings/mfd/da9062.txt MFD document. The da9062-watchdog section was deleted in that file and replaced with a link to the new DA9061/62 binding information stored in this patch.
---
This patch applies against linux-next and v4.9
v4 -> v5
- NO CODE CHANGE
- Rebased from v4.8 to v4.9
v3 -> v4
- NO CODE CHANGE
- Patch renamed from [PATCH V3 2/9] to [PATCH V4 1/8]
- Added Acked-by Rob Herring
v2 -> v3
- Patch renamed from [PATCH V1 02/10] to [PATCH V3 2/9]
- Each compatible line should be a valid combination of compatible strings, alter DA9061 line to include the fall back compatible string
- Update the commit message to describe this change
- Add information about associated patches from this set without describing them as being explicitly dependent on this binding
v1 -> v2
- Patch renamed from [PATCH V1 07/10] to [PATCH V2 02/10] -- these changes were made to fix checkpatch warnings caused by the patch set dependency order
- Updated the patch description to be explicit about where parts of this binding had originally been stored
- A second example for DA9061 is provided to highlight the use of a fall-back compatible option for the DA9062 watchdog driver
Hi,
No code changes for this version PATCH V5.
As previously:
For the watchdog case: the DA9062 device driver is compatible with the DA9061 and for this reason there is minimal change required to the DA9062 watchdog device driver. The example for the DA9061 watchdog shows the use of a fall-back compatible string.
Other information:
The device driver from this patch set (associated with this binding) is
[PATCH V5 6/8] watchdog: da9061: watchdog driver
Regards,
Steve Twiss, Dialog Semiconductor Ltd.
.../devicetree/bindings/watchdog/da9062-wdt.txt | 23 ++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 Documentation/devicetree/bindings/watchdog/da9062-wdt.txt
Documentation/devicetree/bindings/watchdog/da9062-wdt.txt new file +23 -0
@@ -0,0 +1,23 @@ +* Dialog Semiconductor DA9062/61 Watchdog Timer + +Required properties: + +- compatible: should be one of the following valid compatible string lines: + "dlg,da9061-watchdog", "dlg,da9062-watchdog" + "dlg,da9062-watchdog" + +Example: DA9062 + + pmic0: da9062@58 { + watchdog { + compatible = "dlg,da9062-watchdog"; + }; + }; + +Example: DA9061 using a fall-back compatible for the DA9062 watchdog driver + + pmic0: da9061@58 { + watchdog { + compatible = "dlg,da9061-watchdog", "dlg,da9062-watchdog"; + }; + };
Signature · 1 line
end-of-patch for PATCH V5
PATCH v5 2/8 Documentation: devicetree: thermal: da9062/61 TJUNC temperature binding
In reply to Steve TwissFrom: Steve Twiss <[email protected]>
Device tree binding information for DA9062 and DA9061 thermal junction temperature monitor.
Binding descriptions for the DA9061 and DA9062 thermal TJUNC supervisor device driver, using a single THERMAL_TRIP_HOT trip-wire and allowing for a configurable polling period for over-temperature polling.
This patch also adds two examples, one for DA9062 and one for DA9061. The DA9061 example uses a fall-back compatible string for the DA9062.
---
This patch applies against linux-next and v4.9
v4 -> v5
- Rebased from v4.8 to v4.9
- Updates from comments by Eduardo Valentin
- Replace vendor defined dlg,tjunc-temp-polling-period-ms with standard thermal core polling-delay-passive as part of the device tree initialisation
- Remove Acked-by Rob Herring
v3 -> v4
- NO CODE CHANGE
- Patch renamed from [PATCH V3 3/9] to [PATCH V4 2/8]
- Added Acked-by Rob Herring
v2 -> v3
- Patch renamed from [PATCH V2 03/10] to [PATCH V3 3/9]
- Changes suggested from other component reviews by Rob Herring:
- Each compatible line should be a valid combination of compatible
strings: alter DA9061 line to include the fall back compatible string and update the commit message accordingly
- Add e-mail information about associated patches from this set without describing them as being explicitly dependent on this binding
v1 -> v2
- Patch renamed from [PATCH V1 08/10] to [PATCH V2 03/10] -- these changes were made to fix checkpatch warnings caused by the patch set dependency order
- A second example for DA9061 is provided to highlight the use of a fall-back compatible option for the DA9062
Hi,
Updates for PATCH V5: the binding has been altered to remove the proposed dlg,tjunc-temp-polling-period-ms and replaced with the standard thermal core polling-delay-passive instead. This was in response to a request from Eduardo Valentin as part of a driver change.
I have also removed a previous Ack by Rob Herring which was valid for PATCH V3
As previously:
The device driver from this patch set (associated with this binding) is:
[PATCH V5 7/8] thermal: da9061: TJUNC temperature driver
Regards,
Steve Twiss, Dialog Semiconductor Ltd.
.../devicetree/bindings/thermal/da9062-thermal.txt | 37 ++++++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 Documentation/devicetree/bindings/thermal/da9062-thermal.txt
Documentation/devicetree/bindings/thermal/da9062-thermal.txt new file +37 -0
@@ -0,0 +1,37 @@ +* Dialog DA9062/61 TJUNC Thermal Module + +This module is part of the DA9061/DA9062. For more details about entire +DA9062 and DA9061 chips see Documentation/devicetree/bindings/mfd/da9062.txt + +Junction temperature thermal module uses an interrupt signal to identify +high THERMAL_TRIP_HOT temperatures for the PMIC device. + +Required properties: + +- compatible: should be one of the following valid compatible string lines: + "dlg,da9061-thermal", "dlg,da9062-thermal" + "dlg,da9062-thermal" + +Optional properties: + +- polling-delay-passive : Specify the polling period, measured in + milliseconds, between thermal zone device update checks. + +Example: DA9062 + + pmic0: da9062@58 { + thermal { + compatible = "dlg,da9062-thermal"; + polling-delay-passive = <3000>; + }; + }; + +Example: DA9061 using a fall-back compatible for the DA9062 onkey driver + + pmic0: da9061@58 { + thermal { + compatible = "dlg,da9061-thermal", "dlg,da9062-thermal"; + polling-delay-passive = <3000>; + }; + }; +
Signature · 1 line
end-of-patch for PATCH V5
Re: [PATCH V5 2/8] Documentation: devicetree: thermal: da9062/61 TJUNC temperature binding
Quoted 17 lines · Steve Twiss
From: Steve Twiss <[email protected]>
Device tree binding information for DA9062 and DA9061 thermal junction temperature monitor.
Binding descriptions for the DA9061 and DA9062 thermal TJUNC supervisor device driver, using a single
THERMAL_TRIP_HOTtrip-wire and allowing for a configurable polling period for over-temperature polling.This patch also adds two examples, one for DA9062 and one for DA9061. The DA9061 example uses a fall-back compatible string for the DA9062.
Signed-off-by Steve Twiss <[email protected]>---
This patch applies against linux-next and v4.9
Quoted 7 lines
v4 -> v5
- Rebased from v4.8 to v4.9
- Updates from comments by Eduardo Valentin
- Replace vendor defined dlg,tjunc-temp-polling-period-ms with standard thermal core polling-delay-passive as part of the device tree initialisation
- Remove Acked-by Rob Herring
PATCH v5 3/8 Documentation: devicetree: mfd: da9062/61 MFD binding
In reply to Steve TwissFrom: Steve Twiss <[email protected]>
Extend existing DA9062 binding information to include the DA9061 PMIC for MFD core and regulators.
Add a da9062-onkey link to the existing onkey binding file.
Add a da9062-thermal link to the new temperature monitoring binding file.
Delete the da9062-watchdog section and replace it with a link to the new DA9061/62 binding information file.
---
This patch applies against linux-next and v4.9
v4 -> v5
- NO CODE CHANGE
- Rebased from v4.8 to v4.9
v3 -> v4
- Patch renamed from [PATCH V3 4/9] to [PATCH V4 3/8]
- Remove double newline spacing in text file
- Added Acked-by Rob Herring
v2 -> v3
- Patch renamed from [PATCH V2 04/10] to [PATCH V3 4/9]
- Ensure binding description concentrates on the device not the device driver
- Separate the DA9061 and DA9062 sub-device tables to distinguish the difference between the two devices
- Update the commit message to describe this change
- Add e-mail information about associated patches from this set without describing them as being explicitly dependent on this binding
v1 -> v2
- Patch renamed from [PATCH V1 09/10] to [PATCH V2 04/10] -- these changes were made to fix checkpatch warnings caused by the patch set dependency order
Hi,
Added an Ack from Rob Herring for the PATCH V3 version.
As previously:
Other information:
The device driver from this patch set (associated with this binding) is
- [PATCH V5 4/8] mfd: da9061: MFD core support
and also the following binding file changes:
- Binding for onkey (already applied by Dmitry Torokhov)
- [PATCH V5 1/8] Binding for watchdog
- [PATCH V5 2/8] Binding for thermal
Regards,
Steve Twiss, Dialog Semiconductor Ltd.
Documentation/devicetree/bindings/mfd/da9062.txt | 49 +++++++++++++++++------- 1 file changed, 36 insertions(+), 13 deletions(-)
Documentation/devicetree/bindings/mfd/da9062.txt +36 -13
@@ -1,22 +1,39 @@ * Dialog DA9062 Power Management Integrated Circuit (PMIC) -DA9062 consists of a large and varied group of sub-devices: +Product information for the DA9062 and DA9061 devices can be found here: +- http://www.dialog-semiconductor.com/products/da9062 +- http://www.dialog-semiconductor.com/products/da9061 + +The DA9062 PMIC consists of: Device Supply Names Description ------ ------------ ----------- da9062-regulator : : LDOs & BUCKs da9062-rtc : : Real-Time Clock +da9062-onkey : : On Key +da9062-watchdog : : Watchdog Timer +da9062-thermal : : Thermal + +The DA9061 PMIC consists of: + +Device Supply Names Description +------ ------------ ----------- +da9062-regulator : : LDOs & BUCKs +da9062-onkey : : On Key da9062-watchdog : : Watchdog Timer +da9062-thermal : : Thermal ====== Required properties: -- compatible : Should be "dlg,da9062". +- compatible : Should be + "dlg,da9062" for DA9062 + "dlg,da9061" for DA9061 - reg : Specifies the I2C slave address (this defaults to 0x58 but it can be modified to match the chip's OTP settings). - interrupt-parent : Specifies the reference to the interrupt controller for - the DA9062. + the DA9062 or DA9061. - interrupts : IRQ line information. - interrupt-controller
@@ -25,8 +42,8 @@ further information on IRQ bindings. Sub-nodes: -- regulators : This node defines the settings for the LDOs and BUCKs. The - DA9062 regulators are bound using their names listed below: +- regulators : This node defines the settings for the LDOs and BUCKs. + The DA9062 regulators are bound using their names listed below: buck1 : BUCK_1 buck2 : BUCK_2
@@ -37,19 +54,29 @@ Sub-nodes: ldo3 : LDO_3 ldo4 : LDO_4 + The DA9061 regulators are bound using their names listed below: + + buck1 : BUCK_1 + buck2 : BUCK_2 + buck3 : BUCK_3 + ldo1 : LDO_1 + ldo2 : LDO_2 + ldo3 : LDO_3 + ldo4 : LDO_4 + The component follows the standard regulator framework and the bindings details of individual regulator device can be found in: Documentation/devicetree/bindings/regulator/regulator.txt - - rtc : This node defines settings required for the Real-Time Clock associated with the DA9062. There are currently no entries in this binding, however compatible = "dlg,da9062-rtc" should be added if a node is created. -- watchdog: This node defines the settings for the watchdog driver associated - with the DA9062 PMIC. The compatible = "dlg,da9062-watchdog" should be added - if a node is created. +- onkey : See ../input/da9062-onkey.txt + +- watchdog: See ../watchdog/da9062-watchdog.txt +- thermal : See ../thermal/da9062-thermal.txt Example:
@@ -64,10 +91,6 @@ Example: compatible = "dlg,da9062-rtc"; }; - watchdog { - compatible = "dlg,da9062-watchdog"; - }; - regulators { DA9062_BUCK1: buck1 { regulator-name = "BUCK1";
Signature · 1 line
end-of-patch for PATCH V5
PATCH v5 4/8 mfd: da9061: MFD core support
In reply to Steve TwissFrom: Steve Twiss <[email protected]>
MFD support for DA9061 is provided as part of the DA9062 device driver.
The registers header file adds two new chip variant IDs defined in DA9061 and DA9062 hardware. The core header file adds new software enumerations for listing the valid DA9061 IRQs and a da9062_compatible_types enumeration for distinguishing between DA9061/62 devices in software.
The core source code adds a new .compatible of_device_id entry. This is extended from DA9062 to support both "dlg,da9061" and "dlg,da9062". The .data entry now holds a reference to the enumerated device type.
A new regmap_irq_chip model is added for DA9061 and this supports the new list of regmap_irq entries. A new mfd_cell da9061_devs[] array lists the new sub system components for DA9061. Support is added for a new DA9061 regmap_config which lists the correct readable, writable and volatile ranges for this chip.
The probe function uses the device tree compatible string to switch on the da9062_compatible_types and configure the correct mfd cells, irq chip and regmap config.
Kconfig is updated to reflect support for DA9061 and DA9062 PMICs.
---
This patch applies against linux-next and v4.9
v4 -> v5
- NO CODE CHANGE
- Rebased from v4.8 to v4.9
v3 -> v4
- Patch renamed from [PATCH V3 5/9] to [PATCH V4 4/8]
- Removed DEFINE_RES_NAMED() macros for DA9061 resources and replaced them with DEFINE_RES_IRQ_NAMED().
- Removed whitespace
- Reverted change for badly defined mfd_cell da9062_devs of_compatible string from "dlg,da9062-watchdog" back to "dlg,da9062-wdt"
v2 -> v3
- NO CODE CHANGE
- Patch renamed from [PATCH V2 05/10] to [PATCH V3 5/9]
v1 -> v2
- Patch renamed from [PATCH V1 01/10] to [PATCH V2 05/10] -- these changes were made to fix checkpatch warnings caused by the patch set dependency order
- Fixed typo in the commit message "readble" to "readable"
- Removed the explicit cross-check to decide if there is a conflict between the device tree compatible string and the hardware definition. This patch assumes the device tree is correctly written and therefore removes the need for a hardware/DT sanity check.
- Removed extra semicolon in drivers/mfd/da9062-core.c:877
- Re-write compatible entries into numerical order
Lee,
Changes as described in the version history above.
As previously:
This patch adds support for the DA9061 PMIC. This is done as part of the existing DA9062 device driver by extending the of_device_id match table. This in turn allows new MFD cells, irq chip and regmap definitions to support DA9061.
Regards,
Steve Twiss, Dialog Semiconductor Ltd.
drivers/mfd/Kconfig | 5 +- drivers/mfd/da9062-core.c | 424 +++++++++++++++++++++++++++++++++-- include/linux/mfd/da9062/core.h | 27 ++- include/linux/mfd/da9062/registers.h | 2 + 4 files changed, 439 insertions(+), 19 deletions(-)
drivers/mfd/Kconfig +3 -2
@@ -246,13 +246,14 @@ config MFD_DA9055 called "da9055" config MFD_DA9062 - tristate "Dialog Semiconductor DA9062 PMIC Support" + tristate "Dialog Semiconductor DA9062/61 PMIC Support" select MFD_CORE select REGMAP_I2C select REGMAP_IRQ depends on I2C help - Say yes here for support for the Dialog Semiconductor DA9062 PMIC. + Say yes here for support for the Dialog Semiconductor DA9061 and + DA9062 PMICs. This includes the I2C driver and core APIs. Additional drivers must be enabled in order to use the functionality of the device.
drivers/mfd/da9062-core.c +408 -16
509 lines not on this page · raw message
include/linux/mfd/da9062/core.h +26 -1
@@ -18,7 +18,31 @@#include <linux/interrupt.h> #include <linux/mfd/da9062/registers.h> -/* Interrupts */ +enum da9062_compatible_types { +COMPAT_TYPE_DA9061 =1 , +COMPAT_TYPE_DA9062 , +}; + +enum da9061_irqs { +/* IRQ A */ +DA9061_IRQ_ONKEY , +DA9061_IRQ_WDG_WARN , +DA9061_IRQ_SEQ_RDY , +/* IRQ B*/ +DA9061_IRQ_TEMP , +DA9061_IRQ_LDO_LIM , +DA9061_IRQ_DVC_RDY , +DA9061_IRQ_VDD_WARN , +/* IRQ C */ +DA9061_IRQ_GPI0 , +DA9061_IRQ_GPI1 , +DA9061_IRQ_GPI2 , +DA9061_IRQ_GPI3 , +DA9061_IRQ_GPI4 , + +DA9061_NUM_IRQ , +}; +enum da9062_irqs {/* IRQ A */ DA9062_IRQ_ONKEY ,
@@ -45,6 +69,7 @@ struct da9062 {struct device *dev;struct regmap *regmap;struct regmap_irq_chip_data *regmap_irq; + enum da9062_compatible_types chip_type; };#endif /* __MFD_DA9062_CORE_H__ */
include/linux/mfd/da9062/registers.h +2 -0
@@ -18,6 +18,8 @@#define DA9062_PMIC_DEVICE_ID 0x62#define DA9062_PMIC_VARIANT_MRC_AA 0x01 +#define DA9062_PMIC_VARIANT_VRC_DA9061 0x01 +#define DA9062_PMIC_VARIANT_VRC_DA9062 0x02#define DA9062_I2C_PAGE_SEL_SHIFT 1
Signature · 6 lines
end-of-patch for PATCH V5 -- 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 V5 4/8] mfd: da9061: MFD core support
Quoted 511 lines · Steve Twiss
From: Steve Twiss <[email protected]>
MFD support for DA9061 is provided as part of the DA9062 device driver.
The registers header file adds two new chip variant IDs defined in DA9061 and DA9062 hardware. The core header file adds new software enumerations for listing the valid DA9061 IRQs and a
da9062_compatible_typesenumeration for distinguishing between DA9061/62 devices in software.The core source code adds a new .compatible
of_device_identry. This is extended from DA9062 to support both "dlg,da9061" and "dlg,da9062". The .data entry now holds a reference to the enumerated device type.A new
regmap_irq_chipmodel is added for DA9061 and this supports the new list ofregmap_irqentries. A newmfd_cellda9061_devs[] array lists the new sub system components for DA9061. Support is added for a new DA9061regmap_configwhich lists the correct readable, writable and volatile ranges for this chip.The probe function uses the device tree compatible string to switch on the
da9062_compatible_typesand configure the correct mfd cells, irq chip and regmap config.
Kconfigis updated to reflect support for DA9061 and DA9062 PMICs.Signed-off-by Steve Twiss <[email protected]>---
This patch applies against linux-next and v4.9v4 -> v5
- NO CODE CHANGE
- Rebased from v4.8 to v4.9v3 -> v4
- Patch renamed from [PATCH V3 5/9] to [PATCH V4 4/8]
- RemovedDEFINE_RES_NAMED()macros for DA9061 resources and replaced them withDEFINE_RES_IRQ_NAMED().
- Removed whitespace
- Reverted change for badly definedmfd_cellda9062_devsof_compatiblestring from "dlg,da9062-watchdog" back to "dlg,da9062-wdt"v2 -> v3
- NO CODE CHANGE
- Patch renamed from [PATCH V2 05/10] to [PATCH V3 5/9]v1 -> v2
- Patch renamed from [PATCH V1 01/10] to [PATCH V2 05/10] -- these changes were made to fix checkpatch warnings caused by the patch set dependency order
- Fixed typo in the commit message "readble" to "readable"
- Removed the explicit cross-check to decide if there is a conflict between the device tree compatible string and the hardware definition. This patch assumes the device tree is correctly written and therefore removes the need for a hardware/DT sanity check.
- Removed extra semicolon indrivers/mfd/da9062-core.c:877
- Re-write compatible entries into numerical orderLee,
Changes as described in the version history above.
As previously:
This patch adds support for the DA9061 PMIC. This is done as part of the existing DA9062 device driver by extending theof_device_idmatch table. This in turn allows new MFD cells, irq chip and regmap definitions to support DA9061.Regards,
Steve Twiss, Dialog Semiconductor Ltd.drivers/mfd/Kconfig | 5 +- drivers/mfd/da9062-core.c | 424 +++++++++++++++++++++++++++++++++-- include/linux/mfd/da9062/core.h | 27 ++- include/linux/mfd/da9062/registers.h | 2 + 4 files changed, 439 insertions(+), 19 deletions(-)drivers/mfd/Kconfig +3
-2@@ -246,13 +246,14 @@ config MFD_DA9055 called "da9055" config MFD_DA9062 - tristate "Dialog Semiconductor DA9062 PMIC Support" + tristate "Dialog Semiconductor DA9062/61 PMIC Support" select MFD_CORE select REGMAP_I2C select REGMAP_IRQ depends on I2C help - Say yes here for support for the Dialog Semiconductor DA9062 PMIC. + Say yes here for support for the Dialog Semiconductor DA9061 and + DA9062 PMICs. This includes the I2C driver and core APIs. Additional drivers must be enabled in order to use the functionality of the device.drivers/mfd/da9062-core.c +362
-4@@ -1,5 +1,5 @@/* -* Core, IRQ and I2C device driver for DA9062 PMIC +* Core, IRQ and I2C device driver for DA9061 and DA9062 PMICs * Copyright (C) 2015 Dialog Semiconductor Ltd. * * This program is free software; you can redistribute it and/or @@ -30,6 +30,70 @@#define DA9062_REG_EVENT_B_OFFSET 1#define DA9062_REG_EVENT_C_OFFSET 2 +static struct regmap_irq da9061_irqs[] = { +/* EVENT A */ + [DA9061_IRQ_ONKEY ] = { + .reg_offset =DA9062_REG_EVENT_A_OFFSET , + .mask =DA9062AA_M_NONKEY_MASK , + }, + [DA9061_IRQ_WDG_WARN ] = { + .reg_offset =DA9062_REG_EVENT_A_OFFSET , + .mask =DA9062AA_M_WDG_WARN_MASK , + }, + [DA9061_IRQ_SEQ_RDY ] = { + .reg_offset =DA9062_REG_EVENT_A_OFFSET , + .mask =DA9062AA_M_SEQ_RDY_MASK , + }, +/* EVENT B */ + [DA9061_IRQ_TEMP ] = { + .reg_offset =DA9062_REG_EVENT_B_OFFSET , + .mask =DA9062AA_M_TEMP_MASK , + }, + [DA9061_IRQ_LDO_LIM ] = { + .reg_offset =DA9062_REG_EVENT_B_OFFSET , + .mask =DA9062AA_M_LDO_LIM_MASK , + }, + [DA9061_IRQ_DVC_RDY ] = { + .reg_offset =DA9062_REG_EVENT_B_OFFSET , + .mask =DA9062AA_M_DVC_RDY_MASK , + }, + [DA9061_IRQ_VDD_WARN ] = { + .reg_offset =DA9062_REG_EVENT_B_OFFSET , + .mask =DA9062AA_M_VDD_WARN_MASK , + }, +/* EVENT C */ + [DA9061_IRQ_GPI0 ] = { + .reg_offset =DA9062_REG_EVENT_C_OFFSET , + .mask =DA9062AA_M_GPI0_MASK , + }, + [DA9061_IRQ_GPI1 ] = { + .reg_offset =DA9062_REG_EVENT_C_OFFSET , + .mask =DA9062AA_M_GPI1_MASK , + }, + [DA9061_IRQ_GPI2 ] = { + .reg_offset =DA9062_REG_EVENT_C_OFFSET , + .mask =DA9062AA_M_GPI2_MASK , + }, + [DA9061_IRQ_GPI3 ] = { + .reg_offset =DA9062_REG_EVENT_C_OFFSET , + .mask =DA9062AA_M_GPI3_MASK , + }, + [DA9061_IRQ_GPI4 ] = { + .reg_offset =DA9062_REG_EVENT_C_OFFSET , + .mask =DA9062AA_M_GPI4_MASK , + }, +}; + +static struct regmap_irq_chip da9061_irq_chip = { + .name ="da9061-irq" , + .irqs = da9061_irqs, + .num_irqs =DA9061_NUM_IRQ , + .num_regs =3 , + .status_base =DA9062AA_EVENT_A , + .mask_base =DA9062AA_IRQ_MASK_A , + .ack_base =DA9062AA_EVENT_A , +}; +static struct regmap_irq da9062_irqs[] = {/* EVENT A */ [DA9062_IRQ_ONKEY ] = {@@ -102,6 +166,57 @@ .ack_base = DA9062AA_EVENT_A, }; +static struct resource da9061_core_resources[] = { +DEFINE_RES_IRQ_NAMED (DA9061_IRQ_VDD_WARN ,"VDD_WARN" ), +}; + +static struct resource da9061_regulators_resources[] = { +DEFINE_RES_IRQ_NAMED (DA9061_IRQ_LDO_LIM ,"LDO_LIM" ), +}; + +static struct resource da9061_thermal_resources[] = { +DEFINE_RES_IRQ_NAMED (DA9061_IRQ_TEMP ,"THERMAL" ), +}; + +static struct resource da9061_wdt_resources[] = { +DEFINE_RES_IRQ_NAMED (DA9061_IRQ_WDG_WARN ,"WD_WARN" ), +}; + +static struct resource da9061_onkey_resources[] = { +DEFINE_RES_IRQ_NAMED (DA9061_IRQ_ONKEY ,"ONKEY" ), +}; + +static const struct mfd_cell da9061_devs[] = { + { + .name ="da9061-core" , + .num_resources =ARRAY_SIZE (da9061_core_resources), + .resources = da9061_core_resources, + }, + { + .name ="da9062-regulators" , + .num_resources =ARRAY_SIZE (da9061_regulators_resources), + .resources = da9061_regulators_resources, + }, + { + .name ="da9061-watchdog" , + .num_resources =ARRAY_SIZE (da9061_wdt_resources), + .resources = da9061_wdt_resources, + .of_compatible ="dlg,da9061-watchdog" , + }, + { + .name ="da9061-thermal" , + .num_resources =ARRAY_SIZE (da9061_thermal_resources), + .resources = da9061_thermal_resources, + .of_compatible ="dlg,da9061-thermal" , + }, + { + .name ="da9061-onkey" , + .num_resources =ARRAY_SIZE (da9061_onkey_resources), + .resources = da9061_onkey_resources, + .of_compatible ="dlg,da9061-onkey" , + }, +}; +static struct resource da9062_core_resources[] = {DEFINE_RES_NAMED (DA9062_IRQ_VDD_WARN ,1 ,"VDD_WARN" ,IORESOURCE_IRQ ), };@@ -200,7 +315,8 @@ static int da9062_clear_fault_log(struct da9062 *chip)static int da9062_get_device_type (struct da9062 *chip) { -int device_id, variant_id, variant_mrc; +int device_id, variant_id, variant_mrc, variant_vrc; +char *type;int ret; ret =regmap_read (chip->regmap,DA9062AA_DEVICE_ID , &device_id);@@ -219,9 +335,23 @@ static int da9062_get_device_type(struct da9062 *chip)return -EIO ; } + variant_vrc = (variant_id &DA9062AA_VRC_MASK ) >>DA9062AA_VRC_SHIFT ; + +switch (variant_vrc) { +case DA9062_PMIC_VARIANT_VRC_DA9061 : + type ="DA9061" ; +break ; +case DA9062_PMIC_VARIANT_VRC_DA9062 : + type ="DA9062" ; +break ; +default : + type ="Unknown" ; +break ; + } +dev_info (chip->dev, -"Device detected (device-ID: 0x%02X, var-ID: 0x%02X)\n" , - device_id, variant_id); +"Device detected (device-ID: 0x%02X, var-ID: 0x%02X, %s)\n" , + device_id, variant_id, type); variant_mrc = (variant_id &DA9062AA_MRC_MASK ) >>DA9062AA_MRC_SHIFT ;@@ -234,6 +364,234 @@ static int da9062_get_device_type(struct da9062 *chip)return ret; } +static const struct regmap_range da9061_aa_readable_ranges[] = { + { + .range_min =DA9062AA_PAGE_CON , + .range_max =DA9062AA_STATUS_B , + }, { + .range_min =DA9062AA_STATUS_D , + .range_max =DA9062AA_EVENT_C , + }, { + .range_min =DA9062AA_IRQ_MASK_A , + .range_max =DA9062AA_IRQ_MASK_C , + }, { + .range_min =DA9062AA_CONTROL_A , + .range_max =DA9062AA_GPIO_4 , + }, { + .range_min =DA9062AA_GPIO_WKUP_MODE , + .range_max =DA9062AA_GPIO_OUT3_4 , + }, { + .range_min =DA9062AA_BUCK1_CONT , + .range_max =DA9062AA_BUCK4_CONT , + }, { + .range_min =DA9062AA_BUCK3_CONT , + .range_max =DA9062AA_BUCK3_CONT , + }, { + .range_min =DA9062AA_LDO1_CONT , + .range_max =DA9062AA_LDO4_CONT , + }, { + .range_min =DA9062AA_DVC_1 , + .range_max =DA9062AA_DVC_1 , + }, { + .range_min =DA9062AA_SEQ , + .range_max =DA9062AA_ID_4_3 , + }, { + .range_min =DA9062AA_ID_12_11 , + .range_max =DA9062AA_ID_16_15 , + }, { + .range_min =DA9062AA_ID_22_21 , + .range_max =DA9062AA_ID_32_31 , + }, { + .range_min =DA9062AA_SEQ_A , + .range_max =DA9062AA_WAIT , + }, { + .range_min =DA9062AA_RESET , + .range_max =DA9062AA_BUCK_ILIM_C , + }, { + .range_min =DA9062AA_BUCK1_CFG , + .range_max =DA9062AA_BUCK3_CFG , + }, { + .range_min =DA9062AA_VBUCK1_A , + .range_max =DA9062AA_VBUCK4_A , + }, { + .range_min =DA9062AA_VBUCK3_A , + .range_max =DA9062AA_VBUCK3_A , + }, { + .range_min =DA9062AA_VLDO1_A , + .range_max =DA9062AA_VLDO4_A , + }, { + .range_min =DA9062AA_VBUCK1_B , + .range_max =DA9062AA_VBUCK4_B , + }, { + .range_min =DA9062AA_VBUCK3_B , + .range_max =DA9062AA_VBUCK3_B , + }, { + .range_min =DA9062AA_VLDO1_B , + .range_max =DA9062AA_VLDO4_B , + }, { + .range_min =DA9062AA_BBAT_CONT , + .range_max =DA9062AA_BBAT_CONT , + }, { + .range_min =DA9062AA_INTERFACE , + .range_max =DA9062AA_CONFIG_E , + }, { + .range_min =DA9062AA_CONFIG_G , + .range_max =DA9062AA_CONFIG_K , + }, { + .range_min =DA9062AA_CONFIG_M , + .range_max =DA9062AA_CONFIG_M , + }, { + .range_min =DA9062AA_GP_ID_0 , + .range_max =DA9062AA_GP_ID_19 , + }, { + .range_min =DA9062AA_DEVICE_ID , + .range_max =DA9062AA_CONFIG_ID , + }, +}; + +static const struct regmap_range da9061_aa_writeable_ranges[] = { + { + .range_min =DA9062AA_PAGE_CON , + .range_max =DA9062AA_PAGE_CON , + }, { + .range_min =DA9062AA_FAULT_LOG , + .range_max =DA9062AA_EVENT_C , + }, { + .range_min =DA9062AA_IRQ_MASK_A , + .range_max =DA9062AA_IRQ_MASK_C , + }, { + .range_min =DA9062AA_CONTROL_A , + .range_max =DA9062AA_GPIO_4 , + }, { + .range_min =DA9062AA_GPIO_WKUP_MODE , + .range_max =DA9062AA_GPIO_OUT3_4 , + }, { + .range_min =DA9062AA_BUCK1_CONT , + .range_max =DA9062AA_BUCK4_CONT , + }, { + .range_min =DA9062AA_BUCK3_CONT , + .range_max =DA9062AA_BUCK3_CONT , + }, { + .range_min =DA9062AA_LDO1_CONT , + .range_max =DA9062AA_LDO4_CONT , + }, { + .range_min =DA9062AA_DVC_1 , + .range_max =DA9062AA_DVC_1 , + }, { + .range_min =DA9062AA_SEQ , + .range_max =DA9062AA_ID_4_3 , + }, { + .range_min =DA9062AA_ID_12_11 , + .range_max =DA9062AA_ID_16_15 , + }, { + .range_min =DA9062AA_ID_22_21 , + .range_max =DA9062AA_ID_32_31 , + }, { + .range_min =DA9062AA_SEQ_A , + .range_max =DA9062AA_WAIT , + }, { + .range_min =DA9062AA_RESET , + .range_max =DA9062AA_BUCK_ILIM_C , + }, { + .range_min =DA9062AA_BUCK1_CFG , + .range_max =DA9062AA_BUCK3_CFG , + }, { + .range_min =DA9062AA_VBUCK1_A , + .range_max =DA9062AA_VBUCK4_A , + }, { + .range_min =DA9062AA_VBUCK3_A , + .range_max =DA9062AA_VBUCK3_A , + }, { + .range_min =DA9062AA_VLDO1_A , + .range_max =DA9062AA_VLDO4_A , + }, { + .range_min =DA9062AA_VBUCK1_B , + .range_max =DA9062AA_VBUCK4_B , + }, { + .range_min =DA9062AA_VBUCK3_B , + .range_max =DA9062AA_VBUCK3_B , + }, { + .range_min =DA9062AA_VLDO1_B , + .range_max =DA9062AA_VLDO4_B , + }, { + .range_min =DA9062AA_BBAT_CONT , + .range_max =DA9062AA_BBAT_CONT , + }, { + .range_min =DA9062AA_GP_ID_0 , + .range_max =DA9062AA_GP_ID_19 , + }, +}; + +static const struct regmap_range da9061_aa_volatile_ranges[] = { + { + .range_min =DA9062AA_PAGE_CON , + .range_max =DA9062AA_STATUS_B , + }, { + .range_min =DA9062AA_STATUS_D , + .range_max =DA9062AA_EVENT_C , + }, { + .range_min =DA9062AA_CONTROL_A , + .range_max =DA9062AA_CONTROL_B , + }, { + .range_min =DA9062AA_CONTROL_E , + .range_max =DA9062AA_CONTROL_F , + }, { + .range_min =DA9062AA_BUCK1_CONT , + .range_max =DA9062AA_BUCK4_CONT , + }, { + .range_min =DA9062AA_BUCK3_CONT , + .range_max =DA9062AA_BUCK3_CONT , + }, { + .range_min =DA9062AA_LDO1_CONT , + .range_max =DA9062AA_LDO4_CONT , + }, { + .range_min =DA9062AA_DVC_1 , + .range_max =DA9062AA_DVC_1 , + }, { + .range_min =DA9062AA_SEQ , + .range_max =DA9062AA_SEQ , + }, +}; + +static const struct regmap_access_table da9061_aa_readable_table = { + .yes_ranges = da9061_aa_readable_ranges, + .n_yes_ranges =ARRAY_SIZE (da9061_aa_readable_ranges), +}; + +static const struct regmap_access_table da9061_aa_writeable_table = { + .yes_ranges = da9061_aa_writeable_ranges, + .n_yes_ranges =ARRAY_SIZE (da9061_aa_writeable_ranges), +}; + +static const struct regmap_access_table da9061_aa_volatile_table = { + .yes_ranges = da9061_aa_volatile_ranges, + .n_yes_ranges =ARRAY_SIZE (da9061_aa_volatile_ranges), +}; + +static const struct regmap_range_cfg da9061_range_cfg[] = { + { + .range_min =DA9062AA_PAGE_CON , + .range_max =DA9062AA_CONFIG_ID , + .selector_reg =DA9062AA_PAGE_CON , + .selector_mask =1 <<DA9062_I2C_PAGE_SEL_SHIFT , + .selector_shift =DA9062_I2C_PAGE_SEL_SHIFT , + .window_start =0 , + .window_len =256 , + } +}; + +static struct regmap_config da9061_regmap_config = { + .reg_bits =8 , + .val_bits =8 , + .ranges = da9061_range_cfg, + .num_ranges =ARRAY_SIZE (da9061_range_cfg), + .max_register =DA9062AA_CONFIG_ID , + .cache_type =REGCACHE_RBTREE , + .rd_table = &da9061_aa_readable_table, + .wr_table = &da9061_aa_writeable_table, + .volatile_table = &da9061_aa_volatile_table, +}; +static const struct regmap_range da9062_aa_readable_ranges[] = { { .range_min =DA9062AA_PAGE_CON ,
drivers/mfd/da9062-core.c static int da9062_get_device_type(struct da9062 *chip) · line 819
Quoted 6 lines
drivers/mfd/da9062-core.c +3
-0@@ -456,17 +814,38 @@ static int da9062_get_device_type(struct da9062 *chip) .volatile_table = &da9062_aa_volatile_table, }; +static const struct of_device_id da9062_dt_ids[] = { + { .compatible ="dlg,da9061" , .data = (void *)COMPAT_TYPE_DA9061 , }, + { .compatible ="dlg,da9062" , .data = (void *)COMPAT_TYPE_DA9062 , },
It looks like this device can dynamically obtain this information from the device. Please use that method instead.
Quoted 18 lines
drivers/mfd/da9062-core.c +9
-0+ { } +}; +MODULE_DEVICE_TABLE (of, da9062_dt_ids); +static int da9062_i2c_probe (struct i2c_client *i2c,const struct i2c_device_id *id) {struct da9062 *chip; +const struct of_device_id *match;unsigned int irq_base; +const struct mfd_cell *cell; +const struct regmap_irq_chip *irq_chip; +const struct regmap_config *config; +int cell_num;int ret; chip =devm_kzalloc (&i2c->dev,sizeof (*chip),GFP_KERNEL );if (!chip)
drivers/mfd/da9062-core.c static int da9062_get_device_type(struct da9062 *chip) · line 847
Quoted 10 lines
drivers/mfd/da9062-core.c +8
-0return -ENOMEM ; +if (i2c->dev.of_node) { + match =of_match_node (da9062_dt_ids, i2c->dev.of_node); +if (!match) +return -EINVAL ; + + chip->chip_type = (int )match->data; + }else + chip->chip_type = id->driver_data;
Please obtain this information from DA9062AA_VARIANT_ID.
Quoted 51 lines
drivers/mfd/da9062-core.c +22
-4i2c_set_clientdata (i2c, chip); chip->dev = &i2c->dev;@@ -475,7 +854,25 @@ static int da9062_i2c_probe(struct i2c_client *i2c,return -EINVAL ; } - chip->regmap =devm_regmap_init_i2c (i2c, &da9062_regmap_config); +switch (chip->chip_type) { +case (COMPAT_TYPE_DA9061 ): + cell = da9061_devs; + cell_num =ARRAY_SIZE (da9061_devs); + irq_chip = &da9061_irq_chip; + config = &da9061_regmap_config; +break ; +case (COMPAT_TYPE_DA9062 ): + cell = da9062_devs; + cell_num =ARRAY_SIZE (da9062_devs); + irq_chip = &da9062_irq_chip; + config = &da9062_regmap_config; +break ; +default : +dev_err (chip->dev,"Unrecognised chip type\n" ); +return -ENODEV ; + } + + chip->regmap =devm_regmap_init_i2c (i2c, config);if (IS_ERR (chip->regmap)) { ret =PTR_ERR (chip->regmap); dev_err(chip->dev, "Failed to allocate register map: %d\n",@@ -493,7 +890,7 @@ static int da9062_i2c_probe(struct i2c_client *i2c, ret =regmap_add_irq_chip (chip->regmap, i2c->irq,IRQF_TRIGGER_LOW |IRQF_ONESHOT |IRQF_SHARED , --1 , &da9062_irq_chip, +-1 , irq_chip, &chip->regmap_irq);if (ret) { dev_err(chip->dev, "Failed to request IRQ %d: %d\n",@@ -503,8 +900,8 @@ static int da9062_i2c_probe(struct i2c_client *i2c, irq_base =regmap_irq_chip_get_base (chip->regmap_irq); - ret =mfd_add_devices (chip->dev,PLATFORM_DEVID_NONE , da9062_devs, -ARRAY_SIZE (da9062_devs),NULL , irq_base, + ret =mfd_add_devices (chip->dev,PLATFORM_DEVID_NONE , cell, + cell_num,NULL , irq_base,NULL );if (ret) {dev_err (chip->dev,"Cannot register child devices\n" );
drivers/mfd/da9062-core.c static int da9062_i2c_remove(struct i2c_client *i2c) · line 927
Quoted 6 lines
drivers/mfd/da9062-core.c +2
-1@@ -526,17 +923,12 @@ static int da9062_i2c_remove(struct i2c_client *i2c) }static const struct i2c_device_id da9062_i2c_id[] = { - {"da9062" ,0 }, + {"da9061" ,COMPAT_TYPE_DA9061 }, + {"da9062" ,COMPAT_TYPE_DA9062 },
This too.
Quoted 79 lines
drivers/mfd/da9062-core.c +1
-7{ }, };MODULE_DEVICE_TABLE (i2c, da9062_i2c_id); -static const struct of_device_id da9062_dt_ids[] = { - { .compatible ="dlg,da9062" , }, - { } -}; -MODULE_DEVICE_TABLE (of, da9062_dt_ids); -static struct i2c_driver da9062_i2c_driver = { .driver = { .name ="da9062" ,@@ -549,6 +941,6 @@ static int da9062_i2c_remove(struct i2c_client *i2c)module_i2c_driver (da9062_i2c_driver); -MODULE_DESCRIPTION ("Core device driver for Dialog DA9062" ); +MODULE_DESCRIPTION ("Core device driver for Dialog DA9061 and DA9062" );MODULE_AUTHOR ("Steve Twiss <[email protected]>" );MODULE_LICENSE ("GPL" );include/linux/mfd/da9062/core.h +26
-1@@ -18,7 +18,31 @@#include <linux/interrupt.h> #include <linux/mfd/da9062/registers.h> -/* Interrupts */ +enum da9062_compatible_types { +COMPAT_TYPE_DA9061 =1 , +COMPAT_TYPE_DA9062 , +}; + +enum da9061_irqs { +/* IRQ A */ +DA9061_IRQ_ONKEY , +DA9061_IRQ_WDG_WARN , +DA9061_IRQ_SEQ_RDY , +/* IRQ B*/ +DA9061_IRQ_TEMP , +DA9061_IRQ_LDO_LIM , +DA9061_IRQ_DVC_RDY , +DA9061_IRQ_VDD_WARN , +/* IRQ C */ +DA9061_IRQ_GPI0 , +DA9061_IRQ_GPI1 , +DA9061_IRQ_GPI2 , +DA9061_IRQ_GPI3 , +DA9061_IRQ_GPI4 , + +DA9061_NUM_IRQ , +}; +enum da9062_irqs {/* IRQ A */ DA9062_IRQ_ONKEY ,@@ -45,6 +69,7 @@ struct da9062 {struct device *dev;struct regmap *regmap;struct regmap_irq_chip_data *regmap_irq; + enum da9062_compatible_types chip_type; };#endif /* __MFD_DA9062_CORE_H__ */ include/linux/mfd/da9062/registers.h +2
-0@@ -18,6 +18,8 @@#define DA9062_PMIC_DEVICE_ID 0x62#define DA9062_PMIC_VARIANT_MRC_AA 0x01 +#define DA9062_PMIC_VARIANT_VRC_DA9061 0x01 +#define DA9062_PMIC_VARIANT_VRC_DA9062 0x02#define DA9062_I2C_PAGE_SEL_SHIFT 1
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-watchdog" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
RE: [PATCH V5 4/8] mfd: da9061: MFD core support
Hi Lee,
Quoted 3 lines · Lee Jones
Subject: Re: [PATCH V5 4/8] mfd: da9061: MFD core support
Quoted 1 line · Steve Twiss
From: Steve Twiss <[email protected]>
[...]
Quoted 8 lines
Review
Quoted 2 lines
(quoted diff) +2
-0+static const struct of_device_id da9062_dt_ids[] = { + { .compatible = "dlg,da9061", .data = (void *)COMPAT_TYPE_DA9061,},
Review
Quoted 1 line
(quoted diff) +1
-0+ { .compatible = "dlg,da9062", .data = (void *)COMPAT_TYPE_DA9062,},
It looks like this device can dynamically obtain this information from the device. Please use that method instead.
As I mentioned in an earlier post,
https://lkml.org/lkml/2016/11/7/418
The 61/62 device type has been defined by the device tree in this case, and that definition is used to set the register map. With the regmap defined, access to the registers is then possible.
It is not possible to detect the device type automatically in this case because it suggests a predefined regmap.
This is the reason I define the chip type (DA9061 or DA9062) in the device tree and then assign the correct regmap first before accessing any registers.
[...]
Quoted 10 lines
drivers/mfd/da9062-core.c static int da9062_get_device_type(struct da9062 *chip) · line 847
Quoted 8 lines
drivers/mfd/da9062-core.c +8
-0+if (i2c->dev.of_node) { + match =of_match_node (da9062_dt_ids, i2c->dev.of_node); +if (!match) +return -EINVAL ; + + chip->chip_type = (int )match->data; + }else + chip->chip_type = id->driver_data;Please obtain this information from
DA9062AA_VARIANT_ID.
The variant ID does contain the information about whether it is a 61 or 62, but in order to read the register the regmap definition needs to be defined first.
[...]
Quoted 6 lines
drivers/mfd/da9062-core.c static int da9062_i2c_remove(struct i2c_client *i2c) · line 927
Quoted 4 lines
static const struct
i2c_device_idda9062_i2c_id[] = {drivers/mfd/da9062-core.c +2
-1- { "da9062", 0 }, + { "da9061", COMPAT_TYPE_DA9061 }, + { "da9062", COMPAT_TYPE_DA9062 },This too.
Regards,
Steve
Re: [PATCH V5 4/8] mfd: da9061: MFD core support
Quoted 26 lines · Steve Twiss
Hi Lee,
Quoted 3 lines · Lee Jones
Subject: Re: [PATCH V5 4/8] mfd: da9061: MFD core support
Quoted 1 line · Steve Twiss
From: Steve Twiss <[email protected]>
[...]
Quoted 8 lines
Review
Quoted 2 lines
(quoted diff) +2
-0+static const struct of_device_id da9062_dt_ids[] = { + { .compatible = "dlg,da9061", .data = (void *)COMPAT_TYPE_DA9061,},
Review
Quoted 1 line
(quoted diff) +1
-0+ { .compatible = "dlg,da9062", .data = (void *)COMPAT_TYPE_DA9062,},
It looks like this device can dynamically obtain this information from the device. Please use that method instead.
As I mentioned in an earlier post,
https://lkml.org/lkml/2016/11/7/418The 61/62 device type has been defined by the device tree in this case, and that definition is used to set the register map. With the regmap defined, access to the registers is then possible.
Quoted 5 lines
It is not possible to detect the device type automatically in this case because it suggests a predefined regmap.
This is the reason I define the chip type (DA9061 or DA9062) in the device tree and then assign the correct regmap first before accessing any registers.
Well at least I'm consistent. :D
Quoted 26 lines
Quoted 10 lines
drivers/mfd/da9062-core.c static int da9062_get_device_type(struct da9062 *chip) · line 847
Quoted 8 lines
drivers/mfd/da9062-core.c +8
-0+if (i2c->dev.of_node) { + match =of_match_node (da9062_dt_ids, i2c->dev.of_node); +if (!match) +return -EINVAL ; + + chip->chip_type = (int )match->data; + }else + chip->chip_type = id->driver_data;Please obtain this information from
DA9062AA_VARIANT_ID.The variant ID does contain the information about whether it is a 61 or 62, but in order to read the register the regmap definition needs to be defined first.
[...]
Quoted 6 lines
drivers/mfd/da9062-core.c static int da9062_i2c_remove(struct i2c_client *i2c) · line 927
Quoted 4 lines
static const struct
i2c_device_idda9062_i2c_id[] = {drivers/mfd/da9062-core.c +2
-1- { "da9062", 0 }, + { "da9061", COMPAT_TYPE_DA9061 }, + { "da9062", COMPAT_TYPE_DA9062 },This too.
Regards,
Steve
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-watchdog" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH V5 4/8] mfd: da9061: MFD core support
In reply to Steve TwissQuoted 72 lines · Steve Twiss
From: Steve Twiss <[email protected]>
MFD support for DA9061 is provided as part of the DA9062 device driver.
The registers header file adds two new chip variant IDs defined in DA9061 and DA9062 hardware. The core header file adds new software enumerations for listing the valid DA9061 IRQs and a
da9062_compatible_typesenumeration for distinguishing between DA9061/62 devices in software.The core source code adds a new .compatible
of_device_identry. This is extended from DA9062 to support both "dlg,da9061" and "dlg,da9062". The .data entry now holds a reference to the enumerated device type.A new
regmap_irq_chipmodel is added for DA9061 and this supports the new list ofregmap_irqentries. A newmfd_cellda9061_devs[] array lists the new sub system components for DA9061. Support is added for a new DA9061regmap_configwhich lists the correct readable, writable and volatile ranges for this chip.The probe function uses the device tree compatible string to switch on the
da9062_compatible_typesand configure the correct mfd cells, irq chip and regmap config.
Kconfigis updated to reflect support for DA9061 and DA9062 PMICs.Signed-off-by Steve Twiss <[email protected]>---
This patch applies against linux-next and v4.9v4 -> v5
- NO CODE CHANGE
- Rebased from v4.8 to v4.9v3 -> v4
- Patch renamed from [PATCH V3 5/9] to [PATCH V4 4/8]
- RemovedDEFINE_RES_NAMED()macros for DA9061 resources and replaced them withDEFINE_RES_IRQ_NAMED().
- Removed whitespace
- Reverted change for badly definedmfd_cellda9062_devsof_compatiblestring from "dlg,da9062-watchdog" back to "dlg,da9062-wdt"v2 -> v3
- NO CODE CHANGE
- Patch renamed from [PATCH V2 05/10] to [PATCH V3 5/9]v1 -> v2
- Patch renamed from [PATCH V1 01/10] to [PATCH V2 05/10] -- these changes were made to fix checkpatch warnings caused by the patch set dependency order
- Fixed typo in the commit message "readble" to "readable"
- Removed the explicit cross-check to decide if there is a conflict between the device tree compatible string and the hardware definition. This patch assumes the device tree is correctly written and therefore removes the need for a hardware/DT sanity check.
- Removed extra semicolon indrivers/mfd/da9062-core.c:877
- Re-write compatible entries into numerical orderLee,
Changes as described in the version history above.
As previously:
This patch adds support for the DA9061 PMIC. This is done as part of the existing DA9062 device driver by extending theof_device_idmatch table. This in turn allows new MFD cells, irq chip and regmap definitions to support DA9061.Regards,
Steve Twiss, Dialog Semiconductor Ltd.
Quoted 5 lines
drivers/mfd/Kconfig | 5 +- drivers/mfd/da9062-core.c | 424 +++++++++++++++++++++++++++++++++-- include/linux/mfd/da9062/core.h | 27 ++- include/linux/mfd/da9062/registers.h | 2 + 4 files changed, 439 insertions(+), 19 deletions(-)
For my own reference:
Quoted 604 lines
drivers/mfd/Kconfig +3
-2@@ -246,13 +246,14 @@ config MFD_DA9055 called "da9055" config MFD_DA9062 - tristate "Dialog Semiconductor DA9062 PMIC Support" + tristate "Dialog Semiconductor DA9062/61 PMIC Support" select MFD_CORE select REGMAP_I2C select REGMAP_IRQ depends on I2C help - Say yes here for support for the Dialog Semiconductor DA9062 PMIC. + Say yes here for support for the Dialog Semiconductor DA9061 and + DA9062 PMICs. This includes the I2C driver and core APIs. Additional drivers must be enabled in order to use the functionality of the device.drivers/mfd/da9062-core.c +408
-16@@ -1,5 +1,5 @@/* -* Core, IRQ and I2C device driver for DA9062 PMIC +* Core, IRQ and I2C device driver for DA9061 and DA9062 PMICs * Copyright (C) 2015 Dialog Semiconductor Ltd. * * This program is free software; you can redistribute it and/or @@ -30,6 +30,70 @@#define DA9062_REG_EVENT_B_OFFSET 1#define DA9062_REG_EVENT_C_OFFSET 2 +static struct regmap_irq da9061_irqs[] = { +/* EVENT A */ + [DA9061_IRQ_ONKEY ] = { + .reg_offset =DA9062_REG_EVENT_A_OFFSET , + .mask =DA9062AA_M_NONKEY_MASK , + }, + [DA9061_IRQ_WDG_WARN ] = { + .reg_offset =DA9062_REG_EVENT_A_OFFSET , + .mask =DA9062AA_M_WDG_WARN_MASK , + }, + [DA9061_IRQ_SEQ_RDY ] = { + .reg_offset =DA9062_REG_EVENT_A_OFFSET , + .mask =DA9062AA_M_SEQ_RDY_MASK , + }, +/* EVENT B */ + [DA9061_IRQ_TEMP ] = { + .reg_offset =DA9062_REG_EVENT_B_OFFSET , + .mask =DA9062AA_M_TEMP_MASK , + }, + [DA9061_IRQ_LDO_LIM ] = { + .reg_offset =DA9062_REG_EVENT_B_OFFSET , + .mask =DA9062AA_M_LDO_LIM_MASK , + }, + [DA9061_IRQ_DVC_RDY ] = { + .reg_offset =DA9062_REG_EVENT_B_OFFSET , + .mask =DA9062AA_M_DVC_RDY_MASK , + }, + [DA9061_IRQ_VDD_WARN ] = { + .reg_offset =DA9062_REG_EVENT_B_OFFSET , + .mask =DA9062AA_M_VDD_WARN_MASK , + }, +/* EVENT C */ + [DA9061_IRQ_GPI0 ] = { + .reg_offset =DA9062_REG_EVENT_C_OFFSET , + .mask =DA9062AA_M_GPI0_MASK , + }, + [DA9061_IRQ_GPI1 ] = { + .reg_offset =DA9062_REG_EVENT_C_OFFSET , + .mask =DA9062AA_M_GPI1_MASK , + }, + [DA9061_IRQ_GPI2 ] = { + .reg_offset =DA9062_REG_EVENT_C_OFFSET , + .mask =DA9062AA_M_GPI2_MASK , + }, + [DA9061_IRQ_GPI3 ] = { + .reg_offset =DA9062_REG_EVENT_C_OFFSET , + .mask =DA9062AA_M_GPI3_MASK , + }, + [DA9061_IRQ_GPI4 ] = { + .reg_offset =DA9062_REG_EVENT_C_OFFSET , + .mask =DA9062AA_M_GPI4_MASK , + }, +}; + +static struct regmap_irq_chip da9061_irq_chip = { + .name ="da9061-irq" , + .irqs = da9061_irqs, + .num_irqs =DA9061_NUM_IRQ , + .num_regs =3 , + .status_base =DA9062AA_EVENT_A , + .mask_base =DA9062AA_IRQ_MASK_A , + .ack_base =DA9062AA_EVENT_A , +}; +static struct regmap_irq da9062_irqs[] = {/* EVENT A */ [DA9062_IRQ_ONKEY ] = {@@ -102,6 +166,57 @@ .ack_base = DA9062AA_EVENT_A, }; +static struct resource da9061_core_resources[] = { +DEFINE_RES_IRQ_NAMED (DA9061_IRQ_VDD_WARN ,"VDD_WARN" ), +}; + +static struct resource da9061_regulators_resources[] = { +DEFINE_RES_IRQ_NAMED (DA9061_IRQ_LDO_LIM ,"LDO_LIM" ), +}; + +static struct resource da9061_thermal_resources[] = { +DEFINE_RES_IRQ_NAMED (DA9061_IRQ_TEMP ,"THERMAL" ), +}; + +static struct resource da9061_wdt_resources[] = { +DEFINE_RES_IRQ_NAMED (DA9061_IRQ_WDG_WARN ,"WD_WARN" ), +}; + +static struct resource da9061_onkey_resources[] = { +DEFINE_RES_IRQ_NAMED (DA9061_IRQ_ONKEY ,"ONKEY" ), +}; + +static const struct mfd_cell da9061_devs[] = { + { + .name ="da9061-core" , + .num_resources =ARRAY_SIZE (da9061_core_resources), + .resources = da9061_core_resources, + }, + { + .name ="da9062-regulators" , + .num_resources =ARRAY_SIZE (da9061_regulators_resources), + .resources = da9061_regulators_resources, + }, + { + .name ="da9061-watchdog" , + .num_resources =ARRAY_SIZE (da9061_wdt_resources), + .resources = da9061_wdt_resources, + .of_compatible ="dlg,da9061-watchdog" , + }, + { + .name ="da9061-thermal" , + .num_resources =ARRAY_SIZE (da9061_thermal_resources), + .resources = da9061_thermal_resources, + .of_compatible ="dlg,da9061-thermal" , + }, + { + .name ="da9061-onkey" , + .num_resources =ARRAY_SIZE (da9061_onkey_resources), + .resources = da9061_onkey_resources, + .of_compatible ="dlg,da9061-onkey" , + }, +}; +static struct resource da9062_core_resources[] = {DEFINE_RES_NAMED (DA9062_IRQ_VDD_WARN ,1 ,"VDD_WARN" ,IORESOURCE_IRQ ), };@@ -200,7 +315,8 @@ static int da9062_clear_fault_log(struct da9062 *chip)static int da9062_get_device_type (struct da9062 *chip) { -int device_id, variant_id, variant_mrc; +int device_id, variant_id, variant_mrc, variant_vrc; +char *type;int ret; ret =regmap_read (chip->regmap,DA9062AA_DEVICE_ID , &device_id);@@ -219,9 +335,23 @@ static int da9062_get_device_type(struct da9062 *chip)return -EIO ; } + variant_vrc = (variant_id &DA9062AA_VRC_MASK ) >>DA9062AA_VRC_SHIFT ; + +switch (variant_vrc) { +case DA9062_PMIC_VARIANT_VRC_DA9061 : + type ="DA9061" ; +break ; +case DA9062_PMIC_VARIANT_VRC_DA9062 : + type ="DA9062" ; +break ; +default : + type ="Unknown" ; +break ; + } +dev_info (chip->dev, -"Device detected (device-ID: 0x%02X, var-ID: 0x%02X)\n" , - device_id, variant_id); +"Device detected (device-ID: 0x%02X, var-ID: 0x%02X, %s)\n" , + device_id, variant_id, type); variant_mrc = (variant_id &DA9062AA_MRC_MASK ) >>DA9062AA_MRC_SHIFT ;@@ -234,6 +364,234 @@ static int da9062_get_device_type(struct da9062 *chip)return ret; } +static const struct regmap_range da9061_aa_readable_ranges[] = { + { + .range_min =DA9062AA_PAGE_CON , + .range_max =DA9062AA_STATUS_B , + }, { + .range_min =DA9062AA_STATUS_D , + .range_max =DA9062AA_EVENT_C , + }, { + .range_min =DA9062AA_IRQ_MASK_A , + .range_max =DA9062AA_IRQ_MASK_C , + }, { + .range_min =DA9062AA_CONTROL_A , + .range_max =DA9062AA_GPIO_4 , + }, { + .range_min =DA9062AA_GPIO_WKUP_MODE , + .range_max =DA9062AA_GPIO_OUT3_4 , + }, { + .range_min =DA9062AA_BUCK1_CONT , + .range_max =DA9062AA_BUCK4_CONT , + }, { + .range_min =DA9062AA_BUCK3_CONT , + .range_max =DA9062AA_BUCK3_CONT , + }, { + .range_min =DA9062AA_LDO1_CONT , + .range_max =DA9062AA_LDO4_CONT , + }, { + .range_min =DA9062AA_DVC_1 , + .range_max =DA9062AA_DVC_1 , + }, { + .range_min =DA9062AA_SEQ , + .range_max =DA9062AA_ID_4_3 , + }, { + .range_min =DA9062AA_ID_12_11 , + .range_max =DA9062AA_ID_16_15 , + }, { + .range_min =DA9062AA_ID_22_21 , + .range_max =DA9062AA_ID_32_31 , + }, { + .range_min =DA9062AA_SEQ_A , + .range_max =DA9062AA_WAIT , + }, { + .range_min =DA9062AA_RESET , + .range_max =DA9062AA_BUCK_ILIM_C , + }, { + .range_min =DA9062AA_BUCK1_CFG , + .range_max =DA9062AA_BUCK3_CFG , + }, { + .range_min =DA9062AA_VBUCK1_A , + .range_max =DA9062AA_VBUCK4_A , + }, { + .range_min =DA9062AA_VBUCK3_A , + .range_max =DA9062AA_VBUCK3_A , + }, { + .range_min =DA9062AA_VLDO1_A , + .range_max =DA9062AA_VLDO4_A , + }, { + .range_min =DA9062AA_VBUCK1_B , + .range_max =DA9062AA_VBUCK4_B , + }, { + .range_min =DA9062AA_VBUCK3_B , + .range_max =DA9062AA_VBUCK3_B , + }, { + .range_min =DA9062AA_VLDO1_B , + .range_max =DA9062AA_VLDO4_B , + }, { + .range_min =DA9062AA_BBAT_CONT , + .range_max =DA9062AA_BBAT_CONT , + }, { + .range_min =DA9062AA_INTERFACE , + .range_max =DA9062AA_CONFIG_E , + }, { + .range_min =DA9062AA_CONFIG_G , + .range_max =DA9062AA_CONFIG_K , + }, { + .range_min =DA9062AA_CONFIG_M , + .range_max =DA9062AA_CONFIG_M , + }, { + .range_min =DA9062AA_GP_ID_0 , + .range_max =DA9062AA_GP_ID_19 , + }, { + .range_min =DA9062AA_DEVICE_ID , + .range_max =DA9062AA_CONFIG_ID , + }, +}; + +static const struct regmap_range da9061_aa_writeable_ranges[] = { + { + .range_min =DA9062AA_PAGE_CON , + .range_max =DA9062AA_PAGE_CON , + }, { + .range_min =DA9062AA_FAULT_LOG , + .range_max =DA9062AA_EVENT_C , + }, { + .range_min =DA9062AA_IRQ_MASK_A , + .range_max =DA9062AA_IRQ_MASK_C , + }, { + .range_min =DA9062AA_CONTROL_A , + .range_max =DA9062AA_GPIO_4 , + }, { + .range_min =DA9062AA_GPIO_WKUP_MODE , + .range_max =DA9062AA_GPIO_OUT3_4 , + }, { + .range_min =DA9062AA_BUCK1_CONT , + .range_max =DA9062AA_BUCK4_CONT , + }, { + .range_min =DA9062AA_BUCK3_CONT , + .range_max =DA9062AA_BUCK3_CONT , + }, { + .range_min =DA9062AA_LDO1_CONT , + .range_max =DA9062AA_LDO4_CONT , + }, { + .range_min =DA9062AA_DVC_1 , + .range_max =DA9062AA_DVC_1 , + }, { + .range_min =DA9062AA_SEQ , + .range_max =DA9062AA_ID_4_3 , + }, { + .range_min =DA9062AA_ID_12_11 , + .range_max =DA9062AA_ID_16_15 , + }, { + .range_min =DA9062AA_ID_22_21 , + .range_max =DA9062AA_ID_32_31 , + }, { + .range_min =DA9062AA_SEQ_A , + .range_max =DA9062AA_WAIT , + }, { + .range_min =DA9062AA_RESET , + .range_max =DA9062AA_BUCK_ILIM_C , + }, { + .range_min =DA9062AA_BUCK1_CFG , + .range_max =DA9062AA_BUCK3_CFG , + }, { + .range_min =DA9062AA_VBUCK1_A , + .range_max =DA9062AA_VBUCK4_A , + }, { + .range_min =DA9062AA_VBUCK3_A , + .range_max =DA9062AA_VBUCK3_A , + }, { + .range_min =DA9062AA_VLDO1_A , + .range_max =DA9062AA_VLDO4_A , + }, { + .range_min =DA9062AA_VBUCK1_B , + .range_max =DA9062AA_VBUCK4_B , + }, { + .range_min =DA9062AA_VBUCK3_B , + .range_max =DA9062AA_VBUCK3_B , + }, { + .range_min =DA9062AA_VLDO1_B , + .range_max =DA9062AA_VLDO4_B , + }, { + .range_min =DA9062AA_BBAT_CONT , + .range_max =DA9062AA_BBAT_CONT , + }, { + .range_min =DA9062AA_GP_ID_0 , + .range_max =DA9062AA_GP_ID_19 , + }, +}; + +static const struct regmap_range da9061_aa_volatile_ranges[] = { + { + .range_min =DA9062AA_PAGE_CON , + .range_max =DA9062AA_STATUS_B , + }, { + .range_min =DA9062AA_STATUS_D , + .range_max =DA9062AA_EVENT_C , + }, { + .range_min =DA9062AA_CONTROL_A , + .range_max =DA9062AA_CONTROL_B , + }, { + .range_min =DA9062AA_CONTROL_E , + .range_max =DA9062AA_CONTROL_F , + }, { + .range_min =DA9062AA_BUCK1_CONT , + .range_max =DA9062AA_BUCK4_CONT , + }, { + .range_min =DA9062AA_BUCK3_CONT , + .range_max =DA9062AA_BUCK3_CONT , + }, { + .range_min =DA9062AA_LDO1_CONT , + .range_max =DA9062AA_LDO4_CONT , + }, { + .range_min =DA9062AA_DVC_1 , + .range_max =DA9062AA_DVC_1 , + }, { + .range_min =DA9062AA_SEQ , + .range_max =DA9062AA_SEQ , + }, +}; + +static const struct regmap_access_table da9061_aa_readable_table = { + .yes_ranges = da9061_aa_readable_ranges, + .n_yes_ranges =ARRAY_SIZE (da9061_aa_readable_ranges), +}; + +static const struct regmap_access_table da9061_aa_writeable_table = { + .yes_ranges = da9061_aa_writeable_ranges, + .n_yes_ranges =ARRAY_SIZE (da9061_aa_writeable_ranges), +}; + +static const struct regmap_access_table da9061_aa_volatile_table = { + .yes_ranges = da9061_aa_volatile_ranges, + .n_yes_ranges =ARRAY_SIZE (da9061_aa_volatile_ranges), +}; + +static const struct regmap_range_cfg da9061_range_cfg[] = { + { + .range_min =DA9062AA_PAGE_CON , + .range_max =DA9062AA_CONFIG_ID , + .selector_reg =DA9062AA_PAGE_CON , + .selector_mask =1 <<DA9062_I2C_PAGE_SEL_SHIFT , + .selector_shift =DA9062_I2C_PAGE_SEL_SHIFT , + .window_start =0 , + .window_len =256 , + } +}; + +static struct regmap_config da9061_regmap_config = { + .reg_bits =8 , + .val_bits =8 , + .ranges = da9061_range_cfg, + .num_ranges =ARRAY_SIZE (da9061_range_cfg), + .max_register =DA9062AA_CONFIG_ID , + .cache_type =REGCACHE_RBTREE , + .rd_table = &da9061_aa_readable_table, + .wr_table = &da9061_aa_writeable_table, + .volatile_table = &da9061_aa_volatile_table, +}; +static const struct regmap_range da9062_aa_readable_ranges[] = { { .range_min =DA9062AA_PAGE_CON ,@@ -456,17 +814,38 @@ static int da9062_get_device_type(struct da9062 *chip) .volatile_table = &da9062_aa_volatile_table, }; +static const struct of_device_id da9062_dt_ids[] = { + { .compatible ="dlg,da9061" , .data = (void *)COMPAT_TYPE_DA9061 , }, + { .compatible ="dlg,da9062" , .data = (void *)COMPAT_TYPE_DA9062 , }, + { } +}; +MODULE_DEVICE_TABLE (of, da9062_dt_ids); +static int da9062_i2c_probe (struct i2c_client *i2c,const struct i2c_device_id *id) {struct da9062 *chip; +const struct of_device_id *match;unsigned int irq_base; +const struct mfd_cell *cell; +const struct regmap_irq_chip *irq_chip; +const struct regmap_config *config; +int cell_num;int ret; chip =devm_kzalloc (&i2c->dev,sizeof (*chip),GFP_KERNEL );if (!chip)return -ENOMEM ; +if (i2c->dev.of_node) { + match =of_match_node (da9062_dt_ids, i2c->dev.of_node); +if (!match) +return -EINVAL ; + + chip->chip_type = (int )match->data; + }else + chip->chip_type = id->driver_data; +i2c_set_clientdata (i2c, chip); chip->dev = &i2c->dev;@@ -475,7 +854,25 @@ static int da9062_i2c_probe(struct i2c_client *i2c,return -EINVAL ; } - chip->regmap =devm_regmap_init_i2c (i2c, &da9062_regmap_config); +switch (chip->chip_type) { +case (COMPAT_TYPE_DA9061 ): + cell = da9061_devs; + cell_num =ARRAY_SIZE (da9061_devs); + irq_chip = &da9061_irq_chip; + config = &da9061_regmap_config; +break ; +case (COMPAT_TYPE_DA9062 ): + cell = da9062_devs; + cell_num =ARRAY_SIZE (da9062_devs); + irq_chip = &da9062_irq_chip; + config = &da9062_regmap_config; +break ; +default : +dev_err (chip->dev,"Unrecognised chip type\n" ); +return -ENODEV ; + } + + chip->regmap =devm_regmap_init_i2c (i2c, config);if (IS_ERR (chip->regmap)) { ret =PTR_ERR (chip->regmap); dev_err(chip->dev, "Failed to allocate register map: %d\n",@@ -493,7 +890,7 @@ static int da9062_i2c_probe(struct i2c_client *i2c, ret =regmap_add_irq_chip (chip->regmap, i2c->irq,IRQF_TRIGGER_LOW |IRQF_ONESHOT |IRQF_SHARED , --1 , &da9062_irq_chip, +-1 , irq_chip, &chip->regmap_irq);if (ret) { dev_err(chip->dev, "Failed to request IRQ %d: %d\n",@@ -503,8 +900,8 @@ static int da9062_i2c_probe(struct i2c_client *i2c, irq_base =regmap_irq_chip_get_base (chip->regmap_irq); - ret =mfd_add_devices (chip->dev,PLATFORM_DEVID_NONE , da9062_devs, -ARRAY_SIZE (da9062_devs),NULL , irq_base, + ret =mfd_add_devices (chip->dev,PLATFORM_DEVID_NONE , cell, + cell_num,NULL , irq_base,NULL );if (ret) {dev_err (chip->dev,"Cannot register child devices\n" );@@ -526,17 +923,12 @@ static int da9062_i2c_remove(struct i2c_client *i2c) }static const struct i2c_device_id da9062_i2c_id[] = { - {"da9062" ,0 }, + {"da9061" ,COMPAT_TYPE_DA9061 }, + {"da9062" ,COMPAT_TYPE_DA9062 }, { }, };MODULE_DEVICE_TABLE (i2c, da9062_i2c_id); -static const struct of_device_id da9062_dt_ids[] = { - { .compatible ="dlg,da9062" , }, - { } -}; -MODULE_DEVICE_TABLE (of, da9062_dt_ids); -static struct i2c_driver da9062_i2c_driver = { .driver = { .name ="da9062" ,@@ -549,6 +941,6 @@ static int da9062_i2c_remove(struct i2c_client *i2c)module_i2c_driver (da9062_i2c_driver); -MODULE_DESCRIPTION ("Core device driver for Dialog DA9062" ); +MODULE_DESCRIPTION ("Core device driver for Dialog DA9061 and DA9062" );MODULE_AUTHOR ("Steve Twiss <[email protected]>" );MODULE_LICENSE ("GPL" );include/linux/mfd/da9062/core.h +26
-1@@ -18,7 +18,31 @@#include <linux/interrupt.h> #include <linux/mfd/da9062/registers.h> -/* Interrupts */ +enum da9062_compatible_types { +COMPAT_TYPE_DA9061 =1 , +COMPAT_TYPE_DA9062 , +}; + +enum da9061_irqs { +/* IRQ A */ +DA9061_IRQ_ONKEY , +DA9061_IRQ_WDG_WARN , +DA9061_IRQ_SEQ_RDY , +/* IRQ B*/ +DA9061_IRQ_TEMP , +DA9061_IRQ_LDO_LIM , +DA9061_IRQ_DVC_RDY , +DA9061_IRQ_VDD_WARN , +/* IRQ C */ +DA9061_IRQ_GPI0 , +DA9061_IRQ_GPI1 , +DA9061_IRQ_GPI2 , +DA9061_IRQ_GPI3 , +DA9061_IRQ_GPI4 , + +DA9061_NUM_IRQ , +}; +enum da9062_irqs {/* IRQ A */ DA9062_IRQ_ONKEY ,@@ -45,6 +69,7 @@ struct da9062 {struct device *dev;struct regmap *regmap;struct regmap_irq_chip_data *regmap_irq; + enum da9062_compatible_types chip_type; };#endif /* __MFD_DA9062_CORE_H__ */ include/linux/mfd/da9062/registers.h +2
-0@@ -18,6 +18,8 @@#define DA9062_PMIC_DEVICE_ID 0x62#define DA9062_PMIC_VARIANT_MRC_AA 0x01 +#define DA9062_PMIC_VARIANT_VRC_DA9061 0x01 +#define DA9062_PMIC_VARIANT_VRC_DA9062 0x02#define DA9062_I2C_PAGE_SEL_SHIFT 1
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-watchdog" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
PATCH v5 5/8 regulator: da9061: BUCK and LDO regulator driver
In reply to Steve TwissFrom: Steve Twiss <[email protected]>
Regulator support for the DA9061 is added into the DA9062 regulator driver.
The regulators for DA9061 differ from those of DA9062.
A new DA9061 enumeration list for the LDOs and Bucks supported by this device is added. Regulator information added: the old regulator information for DA9062 is renamed from local_regulator_info[] to local_da9062_regulator_info[] and a new array is added to support local_da9061_regulator_info[].
The probe() function switches on the da9062_compatible_types enumeration and configures the correct da9062_regulator_info array and number of regulator entries.
Kconfig is updated to reflect support for DA9061 and DA9062 regulators.
---
This patch applies against linux-next and v4.9
v4 -> v5
- Rebased from v4.8 to v4.9
- NO CODE CHANGE
v3 -> v4
- NO CODE CHANGE
- Patch renamed from [PATCH V3 6/9] to [PATCH V4 5/8]
v2 -> v3
- NO CODE CHANGE
- Patch renamed from [PATCH V2 06/10] to [PATCH V3 6/9]
- Added Ack from Mark Brown
v1 -> v2
- Patch renamed from [PATCH V1 02/10] to [PATCH V2 06/10] -- these changes were made to fix checkpatch warnings caused by the patch set dependency order
- Updated header to use DA9061 and DA9062
Hi,
No code changes for this version PATCH V5.
As previously:
These changes depend on a header file provided as part of an earlier patch [PATCH V5 4/8] from this set. The regulator probe() switches on the chip_type which uses enum da9062_compatible_types in core.h from this patch.
Regards,
Steve Twiss, Dialog Semiconductor Ltd.
drivers/regulator/Kconfig | 4 +- drivers/regulator/da9062-regulator.c | 301 +++++++++++++++++++++++++++++++++-- 2 files changed, 292 insertions(+), 13 deletions(-)
drivers/regulator/Kconfig +2 -2
@@ -188,11 +188,11 @@ config REGULATOR_DA9055 will be called da9055-regulator. config REGULATOR_DA9062 - tristate "Dialog Semiconductor DA9062 regulators" + tristate "Dialog Semiconductor DA9061/62 regulators" depends on MFD_DA9062 help Say y here to support the BUCKs and LDOs regulators found on - DA9062 PMICs. + DA9061 and DA9062 PMICs. This driver can also be built as a module. If so, the module will be called da9062-regulator.
drivers/regulator/da9062-regulator.c +290 -11
354 lines not on this page · raw message
Signature · 6 lines
end-of-patch for PATCH V5 -- To unsubscribe from this list: send the line "unsubscribe linux-watchdog" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
PATCH v5 6/8 watchdog: da9062/61: watchdog driver
In reply to Steve TwissFrom: Steve Twiss <[email protected]>
The of_device_id match array is added to support "dlg,da9062-watchdog" as a valid .compatible string. A MODULE_DEVICE_TABLE() macro is added.
This patch assumes the use of a DA9062 fallback compatible string for the DTS to pick up the DA9062 device driver for use with the DA9061 watchdog hardware
Copyright header is updated to add DA9061 in its description and the module description macro is extended to include DA9061.
Kconfig is updated to reflect support for DA9061/62.
---
This patch applies against linux-next and v4.9
v4 -> v5
- NO CODE CHANGE
- Rebased from v4.8 to v4.9
v3 -> v4
- NO CODE CHANGE
- Patch renamed from [PATCH V3 7/9] to [PATCH V4 6/8]
- Added reviewed by Guenter Roeck
v2 -> v3
- Patch renamed from [PATCH V2 08/10] to [PATCH V3 7/9]
- Removal of match->data and of_match_node search. There is only one compatible string now. and delete the .data = &da9062_watchdog_info association in the struct of_device_id compatible table.
- Addition of MODULE_DEVICE_TABLE macro to allow modinfo additions:
da9062_wdt.ko platform:da9062_watchdog
of:N*T*Cdlg,da9062_watchdogC*
of:N*T*Cdlg,da9062_watchdogv1 -> v2
- Patch renamed from [PATCH V1 04/10] to [PATCH V2 08/10] -- these changes were made to fix checkpatch warnings caused by the patch set dependency order
- Removal of the DA9061 compatible entries for this device driver.
- Additional explanation in the patch description for the use of a fall-back compatible DTS string
Hi,
There are no code changes to this patch compared to the previous submission in [PATCH V3 7/9]. The differences are in the patch version rename and Reviewed-by tag.
Regards,
Steve Twiss, Dialog Semiconductor Ltd.
drivers/watchdog/Kconfig | 4 ++-- drivers/watchdog/da9062_wdt.c | 12 ++++++++++-- 2 files changed, 12 insertions(+), 4 deletions(-)
drivers/watchdog/Kconfig +2 -2
@@ -104,11 +104,11 @@ config DA9063_WATCHDOG This driver can be built as a module. The module name is da9063_wdt. config DA9062_WATCHDOG - tristate "Dialog DA9062 Watchdog" + tristate "Dialog DA9062/61 Watchdog" depends on MFD_DA9062 select WATCHDOG_CORE help - Support for the watchdog in the DA9062 PMIC. + Support for the watchdog in the DA9062 and DA9061 PMICs. This driver can be built as a module. The module name is da9062_wdt.
drivers/watchdog/da9062_wdt.c +10 -2
@@ -1,5 +1,5 @@/* -* da9062_wdt.c - WDT device driver for DA9062 +* Watchdog device driver for DA9062 and DA9061 PMICs * Copyright (C) 2015 Dialog Semiconductor Ltd. * * This program is free software; you can redistribute it and/or
@@ -188,6 +188,13 @@ static int da9062_wdt_set_timeout(struct watchdog_device *wdd, .set_timeout = da9062_wdt_set_timeout, }; +static const struct of_device_id da9062_compatible_id_table[] = { + { .compatible ="dlg,da9062-watchdog" , }, + { }, +}; + +MODULE_DEVICE_TABLE (of, da9062_compatible_id_table); +static int da9062_wdt_probe (struct platform_device *pdev) {int ret;
@@ -244,11 +251,12 @@ static int da9062_wdt_remove(struct platform_device *pdev) .remove = da9062_wdt_remove, .driver = { .name = "da9062-watchdog", + .of_match_table = da9062_compatible_id_table, }, };module_platform_driver (da9062_wdt_driver);MODULE_AUTHOR ("S Twiss <[email protected]>" ); -MODULE_DESCRIPTION ("WDT device driver for Dialog DA9062" ); +MODULE_DESCRIPTION ("WDT device driver for Dialog DA9062 and DA9061" );MODULE_LICENSE ("GPL" );MODULE_ALIAS ("platform:da9062-watchdog" );
Signature · 1 line
end-of-patch for PATCH V5
PATCH v5 7/8 thermal: da9062/61: Thermal junction temperature monitoring driver
In reply to Steve TwissFrom: Steve Twiss <[email protected]>
Add junction temperature monitoring supervisor device driver, compatible with the DA9062 and DA9061 PMICs. A MODULE_DEVICE_TABLE() macro is added.
If the PMIC's internal junction temperature rises above T_WARN (125 degC) an interrupt is issued. This T_WARN level is defined as the THERMAL_TRIP_HOT trip-wire inside the device driver.
The thermal triggering mechanism is interrupt based and happens when the temperature rises above a given threshold level. The component cannot return an exact temperature, it only has knowledge if the temperature is above or below a given threshold value. A status bit must be polled to detect when the temperature falls below that threshold level again. A kernel work queue is configured to repeatedly poll and detect when the temperature falls below this trip-wire, between 1 and 10 second intervals (defaulting at 3 seconds).
This scheme is provided as an example. It would be expected that any final implementation will also include a notify() function and any of these settings could be altered to match the application where appropriate.
When over-temperature is reached, the interrupt from the DA9061/2 will be repeatedly triggered. The IRQ is therefore disabled when the first over-temperature event happens and the status bit is polled using a work-queue until it becomes false.
This strategy is designed to allow the periodic transmission of uevents (HOT trip point) as the first level of temperature supervision method. It is intended for non-invasive temperature control, where the necessary measures for cooling the system down are left to the host software. Once the temperature falls again, the IRQ is re-enabled so a new critical over-temperature event can be detected.
---
This patch applies against linux-next and v4.9
v4 -> v5
- Rebased from v4.8 to v4.9
- Updates from comments by Eduardo Valentin
- Replace vendor defined dlg,tjunc-temp-polling-period-ms with standard thermal core polling-delay-passive as part of the device tree initialisation
- Change to the commit message content and device driver source code to include an explanation of the repeated uevent strategy for monitoring over-temperature
- Rename warning threshold name from TEMP_WARN to T_WARN to match the latest datasheet naming convention
- Added reviewed-by Lukasz Luba to commit message
v3 -> v4
- Patch renamed from [PATCH V3 8/9] to [PATCH V4 7/8]
- Reordering of cancel_delayed_work_sync() in remove function
- dev_warn() message for out-of-range polling period requests
- Explanatory comment for expected values defined for DEFAULT_POLLING_MS_PERIOD, MAX_POLLING_MS_PERIOD and MIN_POLLING_MS_PERIOD
v2 -> v3
- Patch renamed from [PATCH V2 09/10] to [PATCH V3 8/9]
- Addition of MODULE_DEVICE_TABLE macro to allow modinfo additions
v1 -> v2
- Patch renamed from [PATCH V1 05/10] to [PATCH V2 09/10] -- these changes were made to fix checkpatch warnings caused by the patch set dependency order
- List the header files in alphabetical order
- Remove "GPL v2" and replace with MODULE_LICENSE("GPL") to match the copyright "GNU Public License v2 or later" option in the header comment for this file. See the allowed identifiers in the file include/linux/module.h +170
- Remove notify function "da9062_thermal_notify" function.
- MODULE_AUTHOR() macros removes Company Name and just gives Name in accordance with include/linux/module.h +200
- Remove the compatible "dlg,da9061-thermal" option in the of_device_id struct table. This patch now assumes the use of a DA9062 fallback compatible string in the DTS when using the DA9061 thermal component of the DA9061 device.
- Re-ordered some assignments earlier in the probe() for thermal->hw, thermal->polling_period, thermal->mode, thermal->dev
- Added further information in the patch description to explain the use of the device driver's built-in work-queue.
Regards,
Steve Twiss, Dialog Semiconductor Ltd.
drivers/thermal/Kconfig | 10 ++ drivers/thermal/Makefile | 1 + drivers/thermal/da9062-thermal.c | 314 +++++++++++++++++++++++++++++++++++++++ 3 files changed, 325 insertions(+) create mode 100644 drivers/thermal/da9062-thermal.c
drivers/thermal/Kconfig +10 -0
@@ -292,6 +292,16 @@ config DB8500_CPUFREQ_COOLING bound cpufreq cooling device turns active to set CPU frequency low to cool down the CPU. +config DA9062_THERMAL + tristate "DA9062/DA9061 Dialog Semiconductor thermal driver" + depends on MFD_DA9062 + depends on OF + help + Enable this for the Dialog Semiconductor thermal sensor driver. + This will report PMIC junction over-temperature for one thermal trip + zone. + Compatible with the DA9062 and DA9061 PMICs. + config INTEL_POWERCLAMP tristate "Intel PowerClamp idle injection driver" depends on THERMAL
drivers/thermal/Makefile +1 -0
@@ -40,6 +40,7 @@ obj-$(CONFIG_IMX_THERMAL) += imx_thermal.o obj-$(CONFIG_MAX77620_THERMAL) += max77620_thermal.o obj-$(CONFIG_QORIQ_THERMAL) += qoriq_thermal.o obj-$(CONFIG_DB8500_CPUFREQ_COOLING) += db8500_cpufreq_cooling.o +obj-$(CONFIG_DA9062_THERMAL) += da9062-thermal.o obj-$(CONFIG_INTEL_POWERCLAMP) += intel_powerclamp.o obj-$(CONFIG_X86_PKG_TEMP_THERMAL) += x86_pkg_temp_thermal.o obj-$(CONFIG_INTEL_SOC_DTS_IOSF_CORE) += intel_soc_dts_iosf.o
drivers/thermal/da9062-thermal.c new file +314 -0
314 lines not on this page · raw message
Signature · 1 line
end-of-patch for PATCH V5
PATCH v5 8/8 MAINTAINERS: da9062/61 updates to the Dialog Semiconductor search terms
In reply to Steve TwissFrom: Steve Twiss <[email protected]>
Hi,
Dialog Semiconductor support would like to add to the MAINTAINERS search terms. This update will allow us to follow files for device tree bindings and source code relating to input onkey drivers, chip thermal monitoring and watchdog timers.
---
This patch applies against linux-next and v4.9
v4 -> v5
- NO CODE CHANGE
- Rebased from v4.8 to v4.9
v3 -> v4
- NO CODE CHANGE
- Patch renamed from [PATCH V3 9/9] to [PATCH V4 8/8]
v2 -> v3
- NO CODE CHANGE
- Patch renamed from [PATCH V2 10/10] to [PATCH V3 9/9]
v1 -> v2
- NO CODE CHANGE
Hi,
This patch depends on acceptance of the following from this patch set:
- [PATCH V5 7/8] PMIC temperature monitoring
and also from the following binding file changes:
- Binding for onkey (already applied by Dmitry Torokhov)
- [PATCH V5 1/8] Binding for watchdog
- [PATCH V5 2/8] Binding for thermal
Regards,
Steve Twiss, Dialog Semiconductor Ltd.
MAINTAINERS | 4 ++++ 1 file changed, 4 insertions(+)
MAINTAINERS +4 -0
@@ -3814,7 +3814,10 @@ W: http://www.dialog-semiconductor.com/products S: Supported F: Documentation/hwmon/da90?? F: Documentation/devicetree/bindings/mfd/da90*.txt +F: Documentation/devicetree/bindings/input/da90??-onkey.txt +F: Documentation/devicetree/bindings/thermal/da90??-thermal.txt F: Documentation/devicetree/bindings/regulator/da92*.txt +F: Documentation/devicetree/bindings/watchdog/da92??-wdt.txt F: Documentation/devicetree/bindings/sound/da[79]*.txt F: drivers/gpio/gpio-da90??.c F: drivers/hwmon/da90??-hwmon.c
@@ -3829,6 +3832,7 @@ F: drivers/power/supply/da9052-battery.c F: drivers/power/supply/da91??-*.c F: drivers/regulator/da903x.c F: drivers/regulator/da9???-regulator.[ch] +F: drivers/thermal/da90??-thermal.c F: drivers/rtc/rtc-da90??.c F: drivers/video/backlight/da90??_bl.c F: drivers/watchdog/da90??_wdt.c
Signature · 6 lines
end-of-patch for PATCH V5 -- To unsubscribe from this list: send the line "unsubscribe linux-watchdog" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html