Add rockchip RK808 pmic driver
Subsystems (6)
v8 cover Add rockchip RK808 pmic driver
This is the initial version of the RK808 PMIC. This is a power management IC for multimedia products.
It provides regulators that are able to supply power to processor cores and other components. The chip provides other modules including RTC, Clockout
Changes in v8:
Advices by Doug
- add description about "vccn-supply"
- modify description about clock-cells Adviced by Lee Jones
- add Author
- remove if(np) and of_match_ptr() since depend on OF
- coding style
Adviced by Doug
- coding style
- fix regmap_update_bits()
- if(rk808_rtc->irq < 0) return err num Adviced by Mike
-rename "control" to "enable"
-define RK808_NR_OUTPUT 2
Adviced by Doug
- remove rk808_regulator_dts() function
- remove the check about "client->dev.of_node"
Changes in v7:
Advices by Mark Rutland
- modify description about clock-cells
- update the example
Adviced by Lee Jones
- coding style
- remove rk808_pre_init function
Adviced by Doug
- add "&& OF" to the dependencies
- add .init_ack_masked = true in rk808_irq_chip
Adviced by doug
- read rtc time from shadowed registers
Adviced by Dmitry
- use CONFIG_PM_SLEEP replace CONFIG_PM
- use SIMPLE_DEV_PM_OPS replace dev_pm_ops
- fix dev_warn
- coding style
Adviced by Heiko
- remove rtc_ctl
Adviced by doug
-fix coding style problems
- remove pdata struct from header file, add rk808_regulator struct
Changes in v6:
Advices by Mark Rutland
- add description about clock-cells
Advices by Doug
- modify description about regulator
- remove pinctrl description
Adviced by Lee Jones in v2
- rk808_i2c_client instead of g_rk808
- remove pdata form struct rk808
Adviced by doug
- move RTC_READSEL setting into probe
Adviced by doug
- use correct argument call of_clk_add_provider in probe
- remove the redundant code
Changes in v5:
Advices by Mark Brown
- add description about regulator valid name.
- add a header file "rockchip,rk808".
- fixed a bug about set_time failed
Adviced by doug
- add some error checking in probe
- move "rockchip,rk808.h" into the patch about dt-bindings
- re-edit base on Mark's branch
Changes in v4:
Advices by Doug
- add a "#clock-cells" propertiy
- update the example
Adviced by Lee Jones in v2
- modify the description in Kconfig
- remove some unnecessary header files
- remove dev from struct rk808
- use enum for define RK808_ID...
- use &client->dev replace rk808->dev
Adviced by doug
- add "clock-output-names" propertiey
- add a header file "rockchip,rk808.h"
- use &client->dev replace rk808->dev
Changes in v3:
- fix compile err
- fix compile err
Changes in v2:
Adviced by Mark Browm:
- use defines for register setting value
- remove rtc alarm disable in shutdown
- remove while(1) in shutdown
- remove read 0x2f in probe
Adviced by javier.martinez
- Add a separate clock driver, rather than in RTC driver Adviced by javier.martinez
- separated from rtc-rk808.c
Adviced by Mark Browm:
- change of_find_node_by_name to find_child_by_name
- use RK808_NUM_REGULATORS as the name of the constant
- create a pdata when missing platform data
- use the rk808_reg name to supply_regulator name
- replace regulator_register with devm_regulator_register
- some other problem with coding style
Chris Zhong (5):
dt-bindings: Add RK808 device tree bindings document
MFD: RK808: Add new mfd driver for RK808
RTC: RK808: add RTC driver for RK808
clk: RK808: Add clkout driver for RK808
regulator: RK808: Remove pdata from the regulator
Documentation/devicetree/bindings/mfd/rk808.txt | 177 ++++++++++ drivers/clk/Kconfig | 9 + drivers/clk/Makefile | 1 + drivers/clk/clk-rk808.c | 164 +++++++++ drivers/mfd/Kconfig | 13 + drivers/mfd/Makefile | 1 + drivers/mfd/rk808.c | 245 +++++++++++++ drivers/regulator/rk808-regulator.c | 89 +---- drivers/rtc/Kconfig | 10 + drivers/rtc/Makefile | 1 + drivers/rtc/rtc-rk808.c | 426 +++++++++++++++++++++++ include/dt-bindings/clock/rockchip,rk808.h | 11 + include/linux/mfd/rk808.h | 196 +++++++++++ 13 files changed, 1271 insertions(+), 72 deletions(-) create mode 100644 Documentation/devicetree/bindings/mfd/rk808.txt create mode 100644 drivers/clk/clk-rk808.c create mode 100644 drivers/mfd/rk808.c create mode 100644 drivers/rtc/rtc-rk808.c create mode 100644 include/dt-bindings/clock/rockchip,rk808.h create mode 100644 include/linux/mfd/rk808.h
Signature · 6 lines
1.7.9.5 -- To unsubscribe from this list: send the line "unsubscribe devicetree" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
PATCH v8 1/5 dt-bindings: Add RK808 device tree bindings document
Add device tree bindings documentation and a header file for rockchip's RK808 pmic.
---
Changes in v8:
Advices by Doug
- add description about "vccn-supply"
- modify description about clock-cells
Changes in v7:
Advices by Mark Rutland
- modify description about clock-cells
- update the example
Changes in v6:
Advices by Mark Rutland
- add description about clock-cells
Advices by Doug
- modify description about regulator
- remove pinctrl description
Changes in v5:
Advices by Mark Brown
- add description about regulator valid name.
- add a header file "rockchip,rk808".
Changes in v4:
Advices by Doug
- add a "#clock-cells" propertiy
- update the example
Changes in v3: None
Changes in v2: None
Documentation/devicetree/bindings/mfd/rk808.txt | 177 +++++++++++++++++++++++ include/dt-bindings/clock/rockchip,rk808.h | 11 ++ 2 files changed, 188 insertions(+) create mode 100644 Documentation/devicetree/bindings/mfd/rk808.txt create mode 100644 include/dt-bindings/clock/rockchip,rk808.h
Documentation/devicetree/bindings/mfd/rk808.txt new file +177 -0
@@ -0,0 +1,177 @@ +RK808 Power Management Integrated Circuit + +Required properties: +- compatible: "rockchip,rk808" +- reg: I2C slave address +- interrupt-parent: The parent interrupt controller. +- interrupts: the interrupt outputs of the controller. +- #clock-cells: from common clock binding; shall be set to 1 (multiple clock + outputs). See <dt-bindings/clock/rockchip,rk808.h> for clock IDs. + +Optional properties: +- clock-output-names: From common clock binding to override the + default output clock name +- rockchip,system-power-controller: Telling whether or not this pmic is controlling + the system power. +- vcc1-supply: The input supply for DCDC_REG1 +- vcc2-supply: The input supply for DCDC_REG2 +- vcc3-supply: The input supply for DCDC_REG3 +- vcc4-supply: The input supply for DCDC_REG4 +- vcc6-supply: The input supply for LDO_REG1 and LDO_REG2 +- vcc7-supply: The input supply for LDO_REG3 and LDO_REG7 +- vcc8-supply: The input supply for SWITCH_REG1 +- vcc9-supply: The input supply for LDO_REG4 and LDO_REG5 +- vcc10-supply: The input supply for LDO_REG6 +- vcc11-supply: The input supply for LDO_REG8 +- vcc12-supply: The input supply for SWITCH_REG2 + +Regulators: All the regulators of RK808 to be instantiated shall be +listed in a child node named 'regulators'. Each regulator is represented +by a child node of the 'regulators' node. + + regulator-name { + /* standard regulator bindings here */ + }; + +Following regulators of the RK808 PMIC block are supported. Note that +the 'n' in regulator name, as in DCDC_REGn or LDOn, represents the DCDC or LDO +number as described in RK808 datasheet. + + - DCDC_REGn + - valid values for n are 1 to 4. + - LDO_REGn + - valid values for n are 1 to 8. + - SWITCH_REGn + - valid values for n are 1 to 2 + +Standard regulator bindings are used inside regulator subnodes. Check + Documentation/devicetree/bindings/regulator/regulator.txt +for more details + +Example: + rk808: pmic@1b { + compatible = "rockchip,rk808"; + clock-output-names = "xin32k", "rk808-clkout2"; + interrupt-parent = <&gpio0>; + interrupts = <4 IRQ_TYPE_LEVEL_LOW>; + pinctrl-names = "default"; + pinctrl-0 = <&pmic_int>; + reg = <0x1b>; + rockchip,system-power-controller; + wakeup-source; + #clock-cells = <1>; + + vcc8-supply = <&vcc_18>; + vcc9-supply = <&vcc_io>; + vcc10-supply = <&vcc_io>; + vcc12-supply = <&vcc_io>; + vddio-supply = <&vccio_pmu>; + + regulators { + vdd_cpu: DCDC_REG1 { + regulator-always-on; + regulator-boot-on; + regulator-min-microvolt = <750000>; + regulator-max-microvolt = <1300000>; + regulator-name = "vdd_arm"; + }; + + vdd_gpu: DCDC_REG2 { + regulator-always-on; + regulator-boot-on; + regulator-min-microvolt = <850000>; + regulator-max-microvolt = <1250000>; + regulator-name = "vdd_gpu"; + }; + + vcc_ddr: DCDC_REG3 { + regulator-always-on; + regulator-boot-on; + regulator-name = "vcc_ddr"; + }; + + vcc_io: DCDC_REG4 { + regulator-always-on; + regulator-boot-on; + regulator-min-microvolt = <3300000>; + regulator-max-microvolt = <3300000>; + regulator-name = "vcc_io"; + }; + + vccio_pmu: LDO_REG1 { + regulator-always-on; + regulator-boot-on; + regulator-min-microvolt = <3300000>; + regulator-max-microvolt = <3300000>; + regulator-name = "vccio_pmu"; + }; + + vcc_tp: LDO_REG2 { + regulator-always-on; + regulator-boot-on; + regulator-min-microvolt = <3300000>; + regulator-max-microvolt = <3300000>; + regulator-name = "vcc_tp"; + }; + + vdd_10: LDO_REG3 { + regulator-always-on; + regulator-boot-on; + regulator-min-microvolt = <1000000>; + regulator-max-microvolt = <1000000>; + regulator-name = "vdd_10"; + }; + + vcc18_lcd: LDO_REG4 { + regulator-always-on; + regulator-boot-on; + regulator-min-microvolt = <1800000>; + regulator-max-microvolt = <1800000>; + regulator-name = "vcc18_lcd"; + }; + + vccio_sd: LDO_REG5 { + regulator-always-on; + regulator-boot-on; + regulator-min-microvolt = <1800000>; + regulator-max-microvolt = <3300000>; + regulator-name = "vccio_sd"; + }; + + vdd10_lcd: LDO_REG6 { + regulator-always-on; + regulator-boot-on; + regulator-min-microvolt = <1000000>; + regulator-max-microvolt = <1000000>; + regulator-name = "vdd10_lcd"; + }; + + vcc_18: LDO_REG7 { + regulator-always-on; + regulator-boot-on; + regulator-min-microvolt = <1800000>; + regulator-max-microvolt = <1800000>; + regulator-name = "vcc_18"; + }; + + vcca_codec: LDO_REG8 { + regulator-always-on; + regulator-boot-on; + regulator-min-microvolt = <3300000>; + regulator-max-microvolt = <3300000>; + regulator-name = "vcca_codec"; + }; + + vcc_wl: SWITCH_REG1 { + regulator-always-on; + regulator-boot-on; + regulator-name = "vcc_wl"; + }; + + vcc_lcd: SWITCH_REG2 { + regulator-always-on; + regulator-boot-on; + regulator-name = "vcc_lcd"; + }; + }; + };
include/dt-bindings/clock/rockchip,rk808.h new file +11 -0
@@ -0,0 +1,11 @@ +/* +* This header provides constants clk index RK808 pmic clkout +*/ +#ifndef _CLK_ROCKCHIP_RK808 +#define _CLK_ROCKCHIP_RK808 + +/* CLOCKOUT index */ +#define RK808_CLKOUT0 0 +#define RK808_CLKOUT1 1 + +#endif
Signature · 1 line
1.7.9.5
PATCH v8 2/5 MFD: RK808: Add new mfd driver for RK808
In reply to Chris ZhongThe RK808 chip is a power management IC for multimedia and handheld devices. It contains the following components:
- Regulators
- RTC
- Clkout
The RK808 core driver is registered as a platform driver and provides communication through I2C with the host device for the different components.
---
Changes in v8:
Adviced by Lee Jones
- add Author
- remove if(np) and of_match_ptr() since depend on OF
- coding style
Changes in v7:
Adviced by Lee Jones
- coding style
- remove rk808_pre_init function
Adviced by Doug
- add "&& OF" to the dependencies
- add .init_ack_masked = true in rk808_irq_chip
Changes in v6:
Adviced by Lee Jones in v2
- rk808_i2c_client instead of g_rk808
- remove pdata form struct rk808
Changes in v5: None
Changes in v4:
Adviced by Lee Jones in v2
- modify the description in Kconfig
- remove some unnecessary header files
- remove dev from struct rk808
- use enum for define RK808_ID...
Changes in v3:
- fix compile err
Changes in v2:
Adviced by Mark Browm:
- use defines for register setting value
- remove rtc alarm disable in shutdown
- remove while(1) in shutdown
- remove read 0x2f in probe
drivers/mfd/Kconfig | 13 +++ drivers/mfd/Makefile | 1 + drivers/mfd/rk808.c | 245 +++++++++++++++++++++++++++++++++++++++++++++ include/linux/mfd/rk808.h | 196 ++++++++++++++++++++++++++++++++++++ 4 files changed, 455 insertions(+) create mode 100644 drivers/mfd/rk808.c create mode 100644 include/linux/mfd/rk808.h
drivers/mfd/Kconfig +13 -0
@@ -582,6 +582,19 @@ config MFD_RC5T583 Additional drivers must be enabled in order to use the different functionality of the device. +config MFD_RK808 + tristate "Rockchip RK808 Power Management chip" + depends on I2C && OF + select MFD_CORE + select REGMAP_I2C + select REGMAP_IRQ + help + If you say yes here you get support for the RK808 + Power Management chips. + This driver provides common support for accessing the device + through I2C interface. The device supports multiple sub-devices + including interrupts, RTC, LDO & DCDC regulators, and onkey. + config MFD_SEC_CORE bool "SAMSUNG Electronics PMIC Series Support" depends on I2C=y
drivers/mfd/Makefile +1 -0
@@ -160,6 +160,7 @@ obj-$(CONFIG_MFD_INTEL_MSIC) += intel_msic.o obj-$(CONFIG_MFD_PALMAS) += palmas.o obj-$(CONFIG_MFD_VIPERBOARD) += viperboard.o obj-$(CONFIG_MFD_RC5T583) += rc5t583.o rc5t583-irq.o +obj-$(CONFIG_MFD_RK808) += rk808.o obj-$(CONFIG_MFD_SEC_CORE) += sec-core.o sec-irq.o obj-$(CONFIG_MFD_SYSCON) += syscon.o obj-$(CONFIG_MFD_LM3533) += lm3533-core.o lm3533-ctrlbank.o
drivers/mfd/rk808.c new file +245 -0
245 lines not on this page · raw message
include/linux/mfd/rk808.h new file +196 -0
196 lines not on this page · raw message
Signature · 1 line
1.7.9.5
Lee Jones
AppliedRe: [PATCH v8 1/5] dt-bindings: Add RK808 device tree bindings document
In reply to Chris ZhongQuoted 37 lines · Chris Zhong
Add device tree bindings documentation and a header file for rockchip's RK808 pmic.
Signed-off-by Doug Anderson <[email protected]>Signed-off-by Chris Zhong <[email protected]>Signed-off-by Zhang Qing <[email protected]>Tested-by Heiko <[email protected]>---
Changes in v8:
Advices by Doug
- add description about "vccn-supply"
- modify description about clock-cellsChanges in v7:
Advices by Mark Rutland
- modify description about clock-cells
- update the exampleChanges in v6:
Advices by Mark Rutland
- add description about clock-cells
Advices by Doug
- modify description about regulator
- remove pinctrl descriptionChanges in v5:
Advices by Mark Brown
- add description about regulator valid name.
- add a header file "rockchip,rk808".Changes in v4:
Advices by Doug
- add a "#clock-cells" propertiy
- update the example
Quoted 8 lines
Changes in v3: None
Changes in v2: NoneDocumentation/devicetree/bindings/mfd/rk808.txt | 177 +++++++++++++++++++++++ include/dt-bindings/clock/rockchip,rk808.h | 11 ++ 2 files changed, 188 insertions(+) create mode 100644 Documentation/devicetree/bindings/mfd/rk808.txt create mode 100644 include/dt-bindings/clock/rockchip,rk808.h
Applied, thanks.
Quoted 200 lines
Documentation/devicetree/bindings/mfd/rk808.txt new file +177
-0@@ -0,0 +1,177 @@ +RK808 Power Management Integrated Circuit + +Required properties: +- compatible: "rockchip,rk808" +- reg: I2C slave address +- interrupt-parent: The parent interrupt controller. +- interrupts: the interrupt outputs of the controller. +- #clock-cells: from common clock binding; shall be set to 1 (multiple clock + outputs). See <dt-bindings/clock/rockchip,rk808.h> for clock IDs. + +Optional properties: +- clock-output-names: From common clock binding to override the + default output clock name +- rockchip,system-power-controller: Telling whether or not this pmic is controlling + the system power. +- vcc1-supply: The input supply for DCDC_REG1 +- vcc2-supply: The input supply for DCDC_REG2 +- vcc3-supply: The input supply for DCDC_REG3 +- vcc4-supply: The input supply for DCDC_REG4 +- vcc6-supply: The input supply for LDO_REG1 and LDO_REG2 +- vcc7-supply: The input supply for LDO_REG3 and LDO_REG7 +- vcc8-supply: The input supply for SWITCH_REG1 +- vcc9-supply: The input supply for LDO_REG4 and LDO_REG5 +- vcc10-supply: The input supply for LDO_REG6 +- vcc11-supply: The input supply for LDO_REG8 +- vcc12-supply: The input supply for SWITCH_REG2 + +Regulators: All the regulators of RK808 to be instantiated shall be +listed in a child node named 'regulators'. Each regulator is represented +by a child node of the 'regulators' node. + + regulator-name { + /* standard regulator bindings here */ + }; + +Following regulators of the RK808 PMIC block are supported. Note that +the 'n' in regulator name, as in DCDC_REGn or LDOn, represents the DCDC or LDO +number as described in RK808 datasheet. + + - DCDC_REGn + - valid values for n are 1 to 4. + - LDO_REGn + - valid values for n are 1 to 8. + - SWITCH_REGn + - valid values for n are 1 to 2 + +Standard regulator bindings are used inside regulator subnodes. Check + Documentation/devicetree/bindings/regulator/regulator.txt +for more details + +Example: + rk808: pmic@1b { + compatible = "rockchip,rk808"; + clock-output-names = "xin32k", "rk808-clkout2"; + interrupt-parent = <&gpio0>; + interrupts = <4 IRQ_TYPE_LEVEL_LOW>; + pinctrl-names = "default"; + pinctrl-0 = <&pmic_int>; + reg = <0x1b>; + rockchip,system-power-controller; + wakeup-source; + #clock-cells = <1>; + + vcc8-supply = <&vcc_18>; + vcc9-supply = <&vcc_io>; + vcc10-supply = <&vcc_io>; + vcc12-supply = <&vcc_io>; + vddio-supply = <&vccio_pmu>; + + regulators { + vdd_cpu: DCDC_REG1 { + regulator-always-on; + regulator-boot-on; + regulator-min-microvolt = <750000>; + regulator-max-microvolt = <1300000>; + regulator-name = "vdd_arm"; + }; + + vdd_gpu: DCDC_REG2 { + regulator-always-on; + regulator-boot-on; + regulator-min-microvolt = <850000>; + regulator-max-microvolt = <1250000>; + regulator-name = "vdd_gpu"; + }; + + vcc_ddr: DCDC_REG3 { + regulator-always-on; + regulator-boot-on; + regulator-name = "vcc_ddr"; + }; + + vcc_io: DCDC_REG4 { + regulator-always-on; + regulator-boot-on; + regulator-min-microvolt = <3300000>; + regulator-max-microvolt = <3300000>; + regulator-name = "vcc_io"; + }; + + vccio_pmu: LDO_REG1 { + regulator-always-on; + regulator-boot-on; + regulator-min-microvolt = <3300000>; + regulator-max-microvolt = <3300000>; + regulator-name = "vccio_pmu"; + }; + + vcc_tp: LDO_REG2 { + regulator-always-on; + regulator-boot-on; + regulator-min-microvolt = <3300000>; + regulator-max-microvolt = <3300000>; + regulator-name = "vcc_tp"; + }; + + vdd_10: LDO_REG3 { + regulator-always-on; + regulator-boot-on; + regulator-min-microvolt = <1000000>; + regulator-max-microvolt = <1000000>; + regulator-name = "vdd_10"; + }; + + vcc18_lcd: LDO_REG4 { + regulator-always-on; + regulator-boot-on; + regulator-min-microvolt = <1800000>; + regulator-max-microvolt = <1800000>; + regulator-name = "vcc18_lcd"; + }; + + vccio_sd: LDO_REG5 { + regulator-always-on; + regulator-boot-on; + regulator-min-microvolt = <1800000>; + regulator-max-microvolt = <3300000>; + regulator-name = "vccio_sd"; + }; + + vdd10_lcd: LDO_REG6 { + regulator-always-on; + regulator-boot-on; + regulator-min-microvolt = <1000000>; + regulator-max-microvolt = <1000000>; + regulator-name = "vdd10_lcd"; + }; + + vcc_18: LDO_REG7 { + regulator-always-on; + regulator-boot-on; + regulator-min-microvolt = <1800000>; + regulator-max-microvolt = <1800000>; + regulator-name = "vcc_18"; + }; + + vcca_codec: LDO_REG8 { + regulator-always-on; + regulator-boot-on; + regulator-min-microvolt = <3300000>; + regulator-max-microvolt = <3300000>; + regulator-name = "vcca_codec"; + }; + + vcc_wl: SWITCH_REG1 { + regulator-always-on; + regulator-boot-on; + regulator-name = "vcc_wl"; + }; + + vcc_lcd: SWITCH_REG2 { + regulator-always-on; + regulator-boot-on; + regulator-name = "vcc_lcd"; + }; + }; + };include/dt-bindings/clock/rockchip,rk808.h new file +11
-0@@ -0,0 +1,11 @@ +/* +* This header provides constants clk index RK808 pmic clkout +*/ +#ifndef _CLK_ROCKCHIP_RK808 +#define _CLK_ROCKCHIP_RK808 + +/* CLOCKOUT index */ +#define RK808_CLKOUT0 0 +#define RK808_CLKOUT1 1 + +#endif
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 devicetree" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
Lee Jones
AppliedRe: [PATCH v8 2/5] MFD: RK808: Add new mfd driver for RK808
In reply to Chris ZhongQuoted 11 lines · Chris Zhong
The RK808 chip is a power management IC for multimedia and handheld devices. It contains the following components:
- Regulators
- RTC
- ClkoutThe RK808 core driver is registered as a platform driver and provides communication through I2C with the host device for the different components.
Quoted 5 lines
Signed-off-by Chris Zhong <[email protected]>Signed-off-by Zhang Qing <[email protected]>Acked-by Lee Jones <[email protected]>Tested-by Heiko <[email protected]>
Applied, thanks.
Quoted 536 lines
---
Changes in v8:
Adviced by Lee Jones
- add Author
- remove if(np) andof_match_ptr()since depend on OF
- coding styleChanges in v7:
Adviced by Lee Jones
- coding style
- removerk808_pre_initfunction
Adviced by Doug
- add "&& OF" to the dependencies
- add .init_ack_masked = true inrk808_irq_chipChanges in v6:
Adviced by Lee Jones in v2
-rk808_i2c_clientinstead ofg_rk808
- remove pdata form struct rk808Changes in v5: None
Changes in v4:
Adviced by Lee Jones in v2
- modify the description inKconfig
- remove some unnecessary header files
- remove dev from struct rk808
- use enum for defineRK808_ID...Changes in v3:
- fix compile errChanges in v2:
Adviced by Mark Browm:
- use defines for register setting value
- remove rtc alarm disable in shutdown
- remove while(1) in shutdown
- remove read0x2fin probedrivers/mfd/Kconfig | 13 +++ drivers/mfd/Makefile | 1 + drivers/mfd/rk808.c | 245 +++++++++++++++++++++++++++++++++++++++++++++ include/linux/mfd/rk808.h | 196 ++++++++++++++++++++++++++++++++++++ 4 files changed, 455 insertions(+) create mode 100644 drivers/mfd/rk808.c create mode 100644 include/linux/mfd/rk808.hdrivers/mfd/Kconfig +13
-0@@ -582,6 +582,19 @@ config MFD_RC5T583 Additional drivers must be enabled in order to use the different functionality of the device. +config MFD_RK808 + tristate "Rockchip RK808 Power Management chip" + depends on I2C && OF + select MFD_CORE + select REGMAP_I2C + select REGMAP_IRQ + help + If you say yes here you get support for the RK808 + Power Management chips. + This driver provides common support for accessing the device + through I2C interface. The device supports multiple sub-devices + including interrupts, RTC, LDO & DCDC regulators, and onkey. + config MFD_SEC_CORE bool "SAMSUNG Electronics PMIC Series Support" depends on I2C=ydrivers/mfd/Makefile +1
-0@@ -160,6 +160,7 @@ obj-$(CONFIG_MFD_INTEL_MSIC) += intel_msic.o obj-$(CONFIG_MFD_PALMAS) += palmas.o obj-$(CONFIG_MFD_VIPERBOARD) += viperboard.o obj-$(CONFIG_MFD_RC5T583) += rc5t583.o rc5t583-irq.o +obj-$(CONFIG_MFD_RK808) += rk808.o obj-$(CONFIG_MFD_SEC_CORE) += sec-core.o sec-irq.o obj-$(CONFIG_MFD_SYSCON) += syscon.o obj-$(CONFIG_MFD_LM3533) += lm3533-core.o lm3533-ctrlbank.odrivers/mfd/rk808.c new file +245
-0@@ -0,0 +1,245 @@ +/* +* MFD core driver for Rockchip RK808 +* +* Copyright (c) 2014, Fuzhou Rockchip Electronics Co., Ltd +* +* Author: Chris Zhong <[email protected]> +* Author: Zhang Qing <[email protected]> +* +* This program is free software; you can redistribute it and/or modify it +* under the terms and conditions of the GNU General Public License, +* version 2, as published by the Free Software Foundation. +* +* This program is distributed in the hope it will be useful, but WITHOUT +* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for +* more details. +*/ + +#include <linux/i2c.h> +#include <linux/interrupt.h> +#include <linux/mfd/rk808.h> +#include <linux/mfd/core.h> +#include <linux/module.h> +#include <linux/regmap.h> + +struct rk808_reg_data { +int addr; +int mask; +int value; +}; + +static const struct regmap_config rk808_regmap_config = { + .reg_bits =8 , + .val_bits =8 , + .max_register =RK808_IO_POL_REG , +}; + +static struct resource rtc_resources[] = { + { + .start =RK808_IRQ_RTC_ALARM , + .end =RK808_IRQ_RTC_ALARM , + .flags =IORESOURCE_IRQ , + } +}; + +static const struct mfd_cell rk808s[] = { + { .name ="rk808-clkout" , }, + { .name ="rk808-regulator" , }, + { + .name ="rk808-rtc" , + .num_resources =ARRAY_SIZE (rtc_resources), + .resources = &rtc_resources[0 ], + }, +}; + +static const struct rk808_reg_data pre_init_reg[] = { + {RK808_BUCK3_CONFIG_REG ,BUCK_ILMIN_MASK ,BUCK_ILMIN_150MA }, + {RK808_BUCK4_CONFIG_REG ,BUCK_ILMIN_MASK ,BUCK_ILMIN_200MA }, + {RK808_BOOST_CONFIG_REG ,BOOST_ILMIN_MASK ,BOOST_ILMIN_100MA }, + {RK808_BUCK1_CONFIG_REG ,BUCK1_RATE_MASK ,BUCK_ILMIN_200MA }, + {RK808_BUCK2_CONFIG_REG ,BUCK2_RATE_MASK ,BUCK_ILMIN_200MA }, + {RK808_VB_MON_REG ,MASK_ALL ,VB_LO_ACT | +VB_LO_SEL_3500MV }, +}; + +static const struct regmap_irq rk808_irqs[] = { +/* INT_STS */ + [RK808_IRQ_VOUT_LO ] = { + .mask =RK808_IRQ_VOUT_LO_MSK , + .reg_offset =0 , + }, + [RK808_IRQ_VB_LO ] = { + .mask =RK808_IRQ_VB_LO_MSK , + .reg_offset =0 , + }, + [RK808_IRQ_PWRON ] = { + .mask =RK808_IRQ_PWRON_MSK , + .reg_offset =0 , + }, + [RK808_IRQ_PWRON_LP ] = { + .mask =RK808_IRQ_PWRON_LP_MSK , + .reg_offset =0 , + }, + [RK808_IRQ_HOTDIE ] = { + .mask =RK808_IRQ_HOTDIE_MSK , + .reg_offset =0 , + }, + [RK808_IRQ_RTC_ALARM ] = { + .mask =RK808_IRQ_RTC_ALARM_MSK , + .reg_offset =0 , + }, + [RK808_IRQ_RTC_PERIOD ] = { + .mask =RK808_IRQ_RTC_PERIOD_MSK , + .reg_offset =0 , + }, + +/* INT_STS2 */ + [RK808_IRQ_PLUG_IN_INT ] = { + .mask =RK808_IRQ_PLUG_IN_INT_MSK , + .reg_offset =1 , + }, + [RK808_IRQ_PLUG_OUT_INT ] = { + .mask =RK808_IRQ_PLUG_OUT_INT_MSK , + .reg_offset =1 , + }, +}; + +static struct regmap_irq_chip rk808_irq_chip = { + .name ="rk808" , + .irqs = rk808_irqs, + .num_irqs =ARRAY_SIZE (rk808_irqs), + .num_regs =2 , + .irq_reg_stride =2 , + .status_base =RK808_INT_STS_REG1 , + .mask_base =RK808_INT_STS_MSK_REG1 , + .ack_base =RK808_INT_STS_REG1 , + .init_ack_masked = true, +}; + +static struct i2c_client *rk808_i2c_client; +static void rk808_device_shutdown (void ) +{ +int ret; +struct rk808 *rk808 =i2c_get_clientdata (rk808_i2c_client); + +if (!rk808) { +dev_warn (&rk808_i2c_client->dev, +"have no rk808, so do nothing here\n" ); +return ; + } + + ret =regmap_update_bits (rk808->regmap, +RK808_DEVCTRL_REG , +DEV_OFF_RST ,DEV_OFF_RST ); +if (ret) +dev_err (&rk808_i2c_client->dev,"power off error!\n" ); +} + +static int rk808_probe (struct i2c_client *client, +const struct i2c_device_id *id) +{ +struct device_node *np = client->dev.of_node; +struct rk808 *rk808; +int pm_off =0 ; +int ret; +int i; + +if (!client->irq) { +dev_err (&client->dev,"No interrupt support, no core IRQ\n" ); +return -EINVAL ; + } + + rk808 =devm_kzalloc (&client->dev,sizeof (*rk808),GFP_KERNEL ); +if (!rk808) +return -ENOMEM ; + + rk808->regmap =devm_regmap_init_i2c (client, &rk808_regmap_config); +if (IS_ERR (rk808->regmap)) { +dev_err (&client->dev,"regmap initialization failed\n" ); +return PTR_ERR (rk808->regmap); + } + +for (i =0 ; i <ARRAY_SIZE (pre_init_reg); i++) { + ret =regmap_update_bits (rk808->regmap, pre_init_reg[i].addr, + pre_init_reg[i].mask, + pre_init_reg[i].value); +if (ret) { +dev_err (&client->dev, +"0x%x write err\n" , pre_init_reg[i].addr); +return ret; + } + } + + ret =regmap_add_irq_chip (rk808->regmap, client->irq, +IRQF_ONESHOT ,-1 , + &rk808_irq_chip, &rk808->irq_data); +if (ret) { +dev_err (&client->dev,"Failed to add irq_chip %d\n" , ret); +return ret; + } + + rk808->i2c = client; +i2c_set_clientdata (client, rk808); + + ret =mfd_add_devices (&client->dev,-1 , + rk808s,ARRAY_SIZE (rk808s), +NULL ,0 ,regmap_irq_get_domain (rk808->irq_data)); +if (ret) { +dev_err (&client->dev,"failed to add MFD devices %d\n" , ret); + goto err_irq; + } + + pm_off =of_property_read_bool (np, +"rockchip,system-power-controller" ); +if (pm_off && !pm_power_off) { + rk808_i2c_client = client; + pm_power_off = rk808_device_shutdown; + } + +return 0 ; + +err_irq: +regmap_del_irq_chip (client->irq, rk808->irq_data); +return ret; +} + +static int rk808_remove (struct i2c_client *client) +{ +struct rk808 *rk808 =i2c_get_clientdata (client); + +regmap_del_irq_chip (client->irq, rk808->irq_data); +mfd_remove_devices (&client->dev); + pm_power_off =NULL ; + +return 0 ; +} + +static struct of_device_id rk808_of_match[] = { + { .compatible ="rockchip,rk808" }, + { }, +}; +MODULE_DEVICE_TABLE (of, rk808_of_match); + +static const struct i2c_device_id rk808_ids[] = { + {"rk808" }, + { }, +}; +MODULE_DEVICE_TABLE (i2c, rk808_ids); + +static struct i2c_driver rk808_i2c_driver = { + .driver = { + .name ="rk808" , + .of_match_table = rk808_of_match, + }, + .probe = rk808_probe, + .remove = rk808_remove, + .id_table = rk808_ids, +}; + +module_i2c_driver (rk808_i2c_driver); + +MODULE_LICENSE ("GPL" ); +MODULE_AUTHOR ("Chris Zhong <[email protected]>" ); +MODULE_AUTHOR ("Zhang Qing <[email protected]>" ); +MODULE_DESCRIPTION ("RK808 PMIC driver" );include/linux/mfd/rk808.h new file +196
-0@@ -0,0 +1,196 @@ +/* +* rk808.h for Rockchip RK808 +* +* Copyright (c) 2014, Fuzhou Rockchip Electronics Co., Ltd +* +* Author: Chris Zhong <[email protected]> +* Author: Zhang Qing <[email protected]> +* +* This program is free software; you can redistribute it and/or modify it +* under the terms and conditions of the GNU General Public License, +* version 2, as published by the Free Software Foundation. +* +* This program is distributed in the hope it will be useful, but WITHOUT +* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for +* more details. +*/ + +#ifndef __LINUX_REGULATOR_rk808_H +#define __LINUX_REGULATOR_rk808_H + +#include <linux/regulator/machine.h> +#include <linux/regmap.h> + +/* +* rk808 Global Register Map. +*/ + +#define RK808_DCDC1 0/* (0+RK808_START) */ +#define RK808_LDO1 4/* (4+RK808_START) */ +#define RK808_NUM_REGULATORS 14 + +enum rk808_reg { +RK808_ID_DCDC1 , +RK808_ID_DCDC2 , +RK808_ID_DCDC3 , +RK808_ID_DCDC4 , +RK808_ID_LDO1 , +RK808_ID_LDO2 , +RK808_ID_LDO3 , +RK808_ID_LDO4 , +RK808_ID_LDO5 , +RK808_ID_LDO6 , +RK808_ID_LDO7 , +RK808_ID_LDO8 , +RK808_ID_SWITCH1 , +RK808_ID_SWITCH2 , +}; + +#define RK808_SECONDS_REG 0x00 +#define RK808_MINUTES_REG 0x01 +#define RK808_HOURS_REG 0x02 +#define RK808_DAYS_REG 0x03 +#define RK808_MONTHS_REG 0x04 +#define RK808_YEARS_REG 0x05 +#define RK808_WEEKS_REG 0x06 +#define RK808_ALARM_SECONDS_REG 0x08 +#define RK808_ALARM_MINUTES_REG 0x09 +#define RK808_ALARM_HOURS_REG 0x0a +#define RK808_ALARM_DAYS_REG 0x0b +#define RK808_ALARM_MONTHS_REG 0x0c +#define RK808_ALARM_YEARS_REG 0x0d +#define RK808_RTC_CTRL_REG 0x10 +#define RK808_RTC_STATUS_REG 0x11 +#define RK808_RTC_INT_REG 0x12 +#define RK808_RTC_COMP_LSB_REG 0x13 +#define RK808_RTC_COMP_MSB_REG 0x14 +#define RK808_CLK32OUT_REG 0x20 +#define RK808_VB_MON_REG 0x21 +#define RK808_THERMAL_REG 0x22 +#define RK808_DCDC_EN_REG 0x23 +#define RK808_LDO_EN_REG 0x24 +#define RK808_SLEEP_SET_OFF_REG1 0x25 +#define RK808_SLEEP_SET_OFF_REG2 0x26 +#define RK808_DCDC_UV_STS_REG 0x27 +#define RK808_DCDC_UV_ACT_REG 0x28 +#define RK808_LDO_UV_STS_REG 0x29 +#define RK808_LDO_UV_ACT_REG 0x2a +#define RK808_DCDC_PG_REG 0x2b +#define RK808_LDO_PG_REG 0x2c +#define RK808_VOUT_MON_TDB_REG 0x2d +#define RK808_BUCK1_CONFIG_REG 0x2e +#define RK808_BUCK1_ON_VSEL_REG 0x2f +#define RK808_BUCK1_SLP_VSEL_REG 0x30 +#define RK808_BUCK1_DVS_VSEL_REG 0x31 +#define RK808_BUCK2_CONFIG_REG 0x32 +#define RK808_BUCK2_ON_VSEL_REG 0x33 +#define RK808_BUCK2_SLP_VSEL_REG 0x34 +#define RK808_BUCK2_DVS_VSEL_REG 0x35 +#define RK808_BUCK3_CONFIG_REG 0x36 +#define RK808_BUCK4_CONFIG_REG 0x37 +#define RK808_BUCK4_ON_VSEL_REG 0x38 +#define RK808_BUCK4_SLP_VSEL_REG 0x39 +#define RK808_BOOST_CONFIG_REG 0x3a +#define RK808_LDO1_ON_VSEL_REG 0x3b +#define RK808_LDO1_SLP_VSEL_REG 0x3c +#define RK808_LDO2_ON_VSEL_REG 0x3d +#define RK808_LDO2_SLP_VSEL_REG 0x3e +#define RK808_LDO3_ON_VSEL_REG 0x3f +#define RK808_LDO3_SLP_VSEL_REG 0x40 +#define RK808_LDO4_ON_VSEL_REG 0x41 +#define RK808_LDO4_SLP_VSEL_REG 0x42 +#define RK808_LDO5_ON_VSEL_REG 0x43 +#define RK808_LDO5_SLP_VSEL_REG 0x44 +#define RK808_LDO6_ON_VSEL_REG 0x45 +#define RK808_LDO6_SLP_VSEL_REG 0x46 +#define RK808_LDO7_ON_VSEL_REG 0x47 +#define RK808_LDO7_SLP_VSEL_REG 0x48 +#define RK808_LDO8_ON_VSEL_REG 0x49 +#define RK808_LDO8_SLP_VSEL_REG 0x4a +#define RK808_DEVCTRL_REG 0x4b +#define RK808_INT_STS_REG1 0x4c +#define RK808_INT_STS_MSK_REG1 0x4d +#define RK808_INT_STS_REG2 0x4e +#define RK808_INT_STS_MSK_REG2 0x4f +#define RK808_IO_POL_REG 0x50 + +/* IRQ Definitions */ +#define RK808_IRQ_VOUT_LO 0 +#define RK808_IRQ_VB_LO 1 +#define RK808_IRQ_PWRON 2 +#define RK808_IRQ_PWRON_LP 3 +#define RK808_IRQ_HOTDIE 4 +#define RK808_IRQ_RTC_ALARM 5 +#define RK808_IRQ_RTC_PERIOD 6 +#define RK808_IRQ_PLUG_IN_INT 7 +#define RK808_IRQ_PLUG_OUT_INT 8 +#define RK808_NUM_IRQ 9 + +#define RK808_IRQ_VOUT_LO_MSK BIT(0) +#define RK808_IRQ_VB_LO_MSK BIT(1) +#define RK808_IRQ_PWRON_MSK BIT(2) +#define RK808_IRQ_PWRON_LP_MSK BIT(3) +#define RK808_IRQ_HOTDIE_MSK BIT(4) +#define RK808_IRQ_RTC_ALARM_MSK BIT(5) +#define RK808_IRQ_RTC_PERIOD_MSK BIT(6) +#define RK808_IRQ_PLUG_IN_INT_MSK BIT(0) +#define RK808_IRQ_PLUG_OUT_INT_MSK BIT(1) + +#define RK808_VBAT_LOW_2V8 0x00 +#define RK808_VBAT_LOW_2V9 0x01 +#define RK808_VBAT_LOW_3V0 0x02 +#define RK808_VBAT_LOW_3V1 0x03 +#define RK808_VBAT_LOW_3V2 0x04 +#define RK808_VBAT_LOW_3V3 0x05 +#define RK808_VBAT_LOW_3V4 0x06 +#define RK808_VBAT_LOW_3V5 0x07 +#define VBAT_LOW_VOL_MASK (0x07 << 0) +#define EN_VABT_LOW_SHUT_DOWN (0x00 << 4) +#define EN_VBAT_LOW_IRQ (0x1 << 4) +#define VBAT_LOW_ACT_MASK (0x1 << 4) + +#define BUCK_ILMIN_MASK (7 << 0) +#define BOOST_ILMIN_MASK (7 << 0) +#define BUCK1_RATE_MASK (3 << 3) +#define BUCK2_RATE_MASK (3 << 3) +#define MASK_ALL 0xff + +#define SWITCH2_EN BIT(6) +#define SWITCH1_EN BIT(5) +#define DEV_OFF_RST BIT(3) + +#define VB_LO_ACT BIT(4) +#define VB_LO_SEL_3500MV (7 << 0) + +#define VOUT_LO_INT BIT(0) +#define CLK32KOUT2_EN BIT(0) + +enum { +BUCK_ILMIN_50MA , +BUCK_ILMIN_100MA , +BUCK_ILMIN_150MA , +BUCK_ILMIN_200MA , +BUCK_ILMIN_250MA , +BUCK_ILMIN_300MA , +BUCK_ILMIN_350MA , +BUCK_ILMIN_400MA , +}; + +enum { +BOOST_ILMIN_75MA , +BOOST_ILMIN_100MA , +BOOST_ILMIN_125MA , +BOOST_ILMIN_150MA , +BOOST_ILMIN_175MA , +BOOST_ILMIN_200MA , +BOOST_ILMIN_225MA , +BOOST_ILMIN_250MA , +}; + +struct rk808 { +struct i2c_client *i2c; +struct regmap_irq_chip_data *irq_data; +struct regmap *regmap; +}; +#endif /* __LINUX_REGULATOR_rk808_H */
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 devicetree" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
PATCH v8 3/5 RTC: RK808: add RTC driver for RK808
In reply to Chris ZhongAdding RTC driver for supporting RTC device present inside RK808 PMIC.
---
Changes in v8:
Adviced by Doug
- coding style
- fix regmap_update_bits()
- if(rk808_rtc->irq < 0) return err num
Changes in v7:
Adviced by doug
- read rtc time from shadowed registers
Adviced by Dmitry
- use CONFIG_PM_SLEEP replace CONFIG_PM
- use SIMPLE_DEV_PM_OPS replace dev_pm_ops
- fix dev_warn
- coding style
Adviced by Heiko
- remove rtc_ctl
Changes in v6:
Adviced by doug
- move RTC_READSEL setting into probe
Changes in v5:
- fixed a bug about set_time failed
Changes in v4:
- use &client->dev replace rk808->dev
Changes in v3: None
Changes in v2:
Adviced by javier.martinez
- Add a separate clock driver, rather than in RTC driver
drivers/rtc/Kconfig | 10 ++ drivers/rtc/Makefile | 1 + drivers/rtc/rtc-rk808.c | 426 +++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 437 insertions(+) create mode 100644 drivers/rtc/rtc-rk808.c
drivers/rtc/Kconfig +10 -0
@@ -288,6 +288,16 @@ config RTC_DRV_MAX77686 This driver can also be built as a module. If so, the module will be called rtc-max77686. +config RTC_DRV_RK808 + tristate "Rockchip RK808 RTC" + depends on MFD_RK808 + help + If you say yes here you will get support for the + RTC of RK808 PMIC. + + This driver can also be built as a module. If so, the module + will be called rk808-rtc. + config RTC_DRV_RS5C372 tristate "Ricoh R2025S/D, RS5C372A/B, RV5C386, RV5C387A" help
drivers/rtc/Makefile +1 -0
@@ -109,6 +109,7 @@ obj-$(CONFIG_RTC_DRV_PUV3) += rtc-puv3.o obj-$(CONFIG_RTC_DRV_PXA) += rtc-pxa.o obj-$(CONFIG_RTC_DRV_R9701) += rtc-r9701.o obj-$(CONFIG_RTC_DRV_RC5T583) += rtc-rc5t583.o +obj-$(CONFIG_RTC_DRV_RK808) += rtc-rk808.o obj-$(CONFIG_RTC_DRV_RP5C01) += rtc-rp5c01.o obj-$(CONFIG_RTC_DRV_RS5C313) += rtc-rs5c313.o obj-$(CONFIG_RTC_DRV_RS5C348) += rtc-rs5c348.o
drivers/rtc/rtc-rk808.c new file +426 -0
426 lines not on this page · raw message
Signature · 1 line
1.7.9.5
PATCH v8 4/5 clk: RK808: Add clkout driver for RK808
In reply to Chris Zhong---
Changes in v8:
Adviced by Mike
-rename "control" to "enable"
-define RK808_NR_OUTPUT 2
Changes in v7:
Adviced by doug
-fix coding style problems
Changes in v6:
Adviced by doug
- use correct argument call of_clk_add_provider in probe
Changes in v5:
Adviced by doug
- add some error checking in probe
- move "rockchip,rk808.h" into the patch about dt-bindings
Changes in v4:
Adviced by doug
- add "clock-output-names" propertiey
- add a header file "rockchip,rk808.h"
Changes in v3:
- fix compile err
Changes in v2:
Adviced by javier.martinez
- separated from rtc-rk808.c
drivers/clk/Kconfig | 9 +++ drivers/clk/Makefile | 1 + drivers/clk/clk-rk808.c | 164 +++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 174 insertions(+) create mode 100644 drivers/clk/clk-rk808.c
drivers/clk/Kconfig +9 -0
@@ -38,6 +38,15 @@ config COMMON_CLK_MAX77686 ---help--- This driver supports Maxim 77686 crystal oscillator clock. +config COMMON_CLK_RK808 + tristate "Clock driver for RK808" + depends on MFD_RK808 + ---help--- + This driver supports RK808 crystal oscillator clock. These + multi-function devices have two fixed-rate oscillators, + clocked at 32KHz each. Clkout1 is always on, Clkout2 can off + by control register. + config COMMON_CLK_SI5351 tristate "Clock driver for SiLabs 5351A/B/C" depends on I2C
drivers/clk/Makefile +1 -0
@@ -28,6 +28,7 @@ obj-$(CONFIG_ARCH_NOMADIK) += clk-nomadik.o obj-$(CONFIG_ARCH_NSPIRE) += clk-nspire.o obj-$(CONFIG_COMMON_CLK_PALMAS) += clk-palmas.o obj-$(CONFIG_CLK_PPC_CORENET) += clk-ppc-corenet.o +obj-$(CONFIG_COMMON_CLK_RK808) += clk-rk808.o obj-$(CONFIG_COMMON_CLK_S2MPS11) += clk-s2mps11.o obj-$(CONFIG_COMMON_CLK_SI5351) += clk-si5351.o obj-$(CONFIG_COMMON_CLK_SI570) += clk-si570.o
drivers/clk/clk-rk808.c new file +164 -0
164 lines not on this page · raw message
Signature · 1 line
1.7.9.5
PATCH v8 5/5 regulator: RK808: Remove pdata from the regulator
In reply to Chris Zhong---
Changes in v8:
Adviced by Doug
- remove rk808_regulator_dts() function
- remove the check about "client->dev.of_node"
Changes in v7:
- remove pdata struct from header file, add rk808_regulator struct
Changes in v6:
- remove the redundant code
Changes in v5:
- re-edit base on Mark's branch
Changes in v4:
- use &client->dev replace rk808->dev
Changes in v3: None
Changes in v2:
Adviced by Mark Browm:
- change of_find_node_by_name to find_child_by_name
- use RK808_NUM_REGULATORS as the name of the constant
- create a pdata when missing platform data
- use the rk808_reg name to supply_regulator name
- replace regulator_register with devm_regulator_register
- some other problem with coding style
drivers/regulator/rk808-regulator.c | 89 +++++++---------------------------- 1 file changed, 17 insertions(+), 72 deletions(-)
drivers/regulator/rk808-regulator.c +17 -72
@@ -3,8 +3,8 @@* * Copyright (c) 2014, Fuzhou Rockchip Electronics Co., Ltd * -* Author: Chris Zhong <[email protected]> -* Author: Zhang Qing <[email protected]> +* Author: Chris Zhong<[email protected]> +* Author: Zhang Qing<[email protected]> * * This program is free software; you can redistribute it and/or modify it * under the terms and conditions of the GNU General Public License,
@@ -14,24 +14,16 @@* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for * more details. -* */ #include <linux/module.h> -#include <linux/init.h> #include <linux/i2c.h> -#include <linux/err.h> -#include <linux/platform_device.h> #include <linux/mfd/rk808.h> -#include <linux/of.h> #include <linux/of_device.h> #include <linux/regulator/driver.h> #include <linux/regulator/of_regulator.h> -#include <linux/regmap.h> -#include <linux/slab.h> -/* -* Field Definitions. -*/ + +/* Field Definitions */ #define RK808_BUCK_VSEL_MASK 0x3f#define RK808_BUCK4_VSEL_MASK 0xf#define RK808_LDO_VSEL_MASK 0x1f
@@ -50,10 +42,6 @@ static const int buck_contr_base_addr[] = { RK808_BUCK4_CONFIG_REG, }; -#define rk808_BUCK_SET_VOL_REG (x) (buck_set_vol_base_addr[x]) -#define rk808_BUCK_CONTR_REG (x) (buck_contr_base_addr[x]) -#define rk808_LDO_SET_VOL_REG (x) (ldo_set_vol_base_addr[x]) -static const int ldo_set_vol_base_addr[] = {RK808_LDO1_ON_VSEL_REG ,RK808_LDO2_ON_VSEL_REG ,
@@ -65,9 +53,7 @@ static const int ldo_set_vol_base_addr[] = { RK808_LDO8_ON_VSEL_REG, }; -/* -* rk808 voltage number -*/ +/* rk808 voltage number */ static const struct regulator_linear_range rk808_buck_voltage_ranges[] = {REGULATOR_LINEAR_RANGE (700000 ,0 ,63 ,12500 ), };
@@ -308,77 +294,35 @@ static struct of_regulator_match rk808_reg_matches[] = { [RK808_ID_SWITCH2] = { .name = "SWITCH_REG2" }, }; -static int rk808_regulator_dts (struct i2c_client *client, -struct rk808_board *pdata) -{ -struct device_node *np, *reg_np; -int i, ret; - - np = client->dev.of_node; -if (!np) { -dev_err (&client->dev,"could not find pmic sub-node\n" ); -return -ENXIO ; - } - - reg_np =of_get_child_by_name (np,"regulators" ); -if (!reg_np) -return -ENXIO ; - - ret =of_regulator_match (&client->dev, reg_np, rk808_reg_matches, -RK808_NUM_REGULATORS ); -if (ret <0 ) { -dev_err (&client->dev, -"failed to parse regulator data: %d\n" , ret); -return ret; - } - -for (i =0 ; i <RK808_NUM_REGULATORS ; i++) { -if (!rk808_reg_matches[i].init_data || - !rk808_reg_matches[i].of_node) -continue ; - - pdata->rk808_init_data[i] = rk808_reg_matches[i].init_data; - pdata->of_node[i] = rk808_reg_matches[i].of_node; - } - -return 0 ; -} -static int rk808_regulator_probe (struct platform_device *pdev) {struct rk808 *rk808 =dev_get_drvdata (pdev->dev.parent);struct i2c_client *client = rk808->i2c; -struct rk808_board *pdata =dev_get_platdata (&client->dev);struct regulator_config config = {};struct regulator_dev *rk808_rdev; -struct regulator_init_data *reg_data; -int i =0 ;int ret =0 ; +int i =0 ; -if (!pdata) { - pdata =devm_kzalloc (&pdev->dev,sizeof (*pdata),GFP_KERNEL ); -if (!pdata) -return -ENOMEM ; - } + reg_np =of_get_child_by_name (np,"regulators" ); +if (!reg_np) +return -ENXIO ; - ret =rk808_regulator_dts (client, pdata); -if (ret) + ret =of_regulator_match (&client->dev, reg_np, rk808_reg_matches, +RK808_NUM_REGULATORS ); +if (ret <0 )return ret;/* Instantiate the regulators */ for (i =0 ; i <RK808_NUM_REGULATORS ; i++) { - reg_data = pdata->rk808_init_data[i]; -if (!reg_data) +if (!rk808_reg_matches[i].init_data || + !rk808_reg_matches[i].of_node)continue ; config.dev = &client->dev; config.driver_data = rk808; config.regmap = rk808->regmap; - -if (client->dev.of_node) - config.of_node = pdata->of_node[i]; - - config.init_data = reg_data; + config.of_node = rk808_reg_matches[i].of_node; + config.init_data = rk808_reg_matches[i].init_data; rk808_rdev =devm_regulator_register (&pdev->dev, &rk808_reg[i], &config);
@@ -388,6 +332,7 @@ static int rk808_regulator_probe(struct platform_device *pdev)return PTR_ERR (rk808_rdev); } } +return 0 ; }
Signature · 1 line
1.7.9.5
PATCH v8 3/5 RTC: RK808: add RTC driver for RK808
In reply to Chris ZhongAdding RTC driver for supporting RTC device present inside RK808 PMIC.
---
Changes in v8:
Adviced by Doug
- coding style
- fix regmap_update_bits()
- if(rk808_rtc->irq < 0) return err num
Changes in v7:
Adviced by doug
- read rtc time from shadowed registers
Adviced by Dmitry
- use CONFIG_PM_SLEEP replace CONFIG_PM
- use SIMPLE_DEV_PM_OPS replace dev_pm_ops
- fix dev_warn
- coding style
Adviced by Heiko
- remove rtc_ctl
Changes in v6:
Adviced by doug
- move RTC_READSEL setting into probe
Changes in v5:
- fixed a bug about set_time failed
Changes in v4:
- use &client->dev replace rk808->dev
Changes in v3: None
Changes in v2:
Adviced by javier.martinez
- Add a separate clock driver, rather than in RTC driver
drivers/rtc/Kconfig | 10 ++ drivers/rtc/Makefile | 1 + drivers/rtc/rtc-rk808.c | 426 +++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 437 insertions(+) create mode 100644 drivers/rtc/rtc-rk808.c
drivers/rtc/Kconfig +10 -0
@@ -288,6 +288,16 @@ config RTC_DRV_MAX77686 This driver can also be built as a module. If so, the module will be called rtc-max77686. +config RTC_DRV_RK808 + tristate "Rockchip RK808 RTC" + depends on MFD_RK808 + help + If you say yes here you will get support for the + RTC of RK808 PMIC. + + This driver can also be built as a module. If so, the module + will be called rk808-rtc. + config RTC_DRV_RS5C372 tristate "Ricoh R2025S/D, RS5C372A/B, RV5C386, RV5C387A" help
drivers/rtc/Makefile +1 -0
@@ -109,6 +109,7 @@ obj-$(CONFIG_RTC_DRV_PUV3) += rtc-puv3.o obj-$(CONFIG_RTC_DRV_PXA) += rtc-pxa.o obj-$(CONFIG_RTC_DRV_R9701) += rtc-r9701.o obj-$(CONFIG_RTC_DRV_RC5T583) += rtc-rc5t583.o +obj-$(CONFIG_RTC_DRV_RK808) += rtc-rk808.o obj-$(CONFIG_RTC_DRV_RP5C01) += rtc-rp5c01.o obj-$(CONFIG_RTC_DRV_RS5C313) += rtc-rs5c313.o obj-$(CONFIG_RTC_DRV_RS5C348) += rtc-rs5c348.o
drivers/rtc/rtc-rk808.c new file +426 -0
426 lines not on this page · raw message
Signature · 6 lines
1.7.9.5 -- To unsubscribe from this list: send the line "unsubscribe devicetree" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
PATCH v8 4/5 clk: RK808: Add clkout driver for RK808
In reply to Chris Zhong---
Changes in v8:
Adviced by Mike
-rename "control" to "enable"
-define RK808_NR_OUTPUT 2
Changes in v7:
Adviced by doug
-fix coding style problems
Changes in v6:
Adviced by doug
- use correct argument call of_clk_add_provider in probe
Changes in v5:
Adviced by doug
- add some error checking in probe
- move "rockchip,rk808.h" into the patch about dt-bindings
Changes in v4:
Adviced by doug
- add "clock-output-names" propertiey
- add a header file "rockchip,rk808.h"
Changes in v3:
- fix compile err
Changes in v2:
Adviced by javier.martinez
- separated from rtc-rk808.c
drivers/clk/Kconfig | 9 +++ drivers/clk/Makefile | 1 + drivers/clk/clk-rk808.c | 164 +++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 174 insertions(+) create mode 100644 drivers/clk/clk-rk808.c
drivers/clk/Kconfig +9 -0
@@ -38,6 +38,15 @@ config COMMON_CLK_MAX77686 ---help--- This driver supports Maxim 77686 crystal oscillator clock. +config COMMON_CLK_RK808 + tristate "Clock driver for RK808" + depends on MFD_RK808 + ---help--- + This driver supports RK808 crystal oscillator clock. These + multi-function devices have two fixed-rate oscillators, + clocked at 32KHz each. Clkout1 is always on, Clkout2 can off + by control register. + config COMMON_CLK_SI5351 tristate "Clock driver for SiLabs 5351A/B/C" depends on I2C
drivers/clk/Makefile +1 -0
@@ -28,6 +28,7 @@ obj-$(CONFIG_ARCH_NOMADIK) += clk-nomadik.o obj-$(CONFIG_ARCH_NSPIRE) += clk-nspire.o obj-$(CONFIG_COMMON_CLK_PALMAS) += clk-palmas.o obj-$(CONFIG_CLK_PPC_CORENET) += clk-ppc-corenet.o +obj-$(CONFIG_COMMON_CLK_RK808) += clk-rk808.o obj-$(CONFIG_COMMON_CLK_S2MPS11) += clk-s2mps11.o obj-$(CONFIG_COMMON_CLK_SI5351) += clk-si5351.o obj-$(CONFIG_COMMON_CLK_SI570) += clk-si570.o
drivers/clk/clk-rk808.c new file +164 -0
164 lines not on this page · raw message
Signature · 1 line
1.7.9.5
PATCH v8 3/5 RTC: RK808: add RTC driver for RK808
In reply to Chris ZhongAdding RTC driver for supporting RTC device present inside RK808 PMIC.
---
Changes in v8:
Adviced by Doug
- coding style
- fix regmap_update_bits()
- if(rk808_rtc->irq < 0) return err num
Changes in v7:
Adviced by doug
- read rtc time from shadowed registers
Adviced by Dmitry
- use CONFIG_PM_SLEEP replace CONFIG_PM
- use SIMPLE_DEV_PM_OPS replace dev_pm_ops
- fix dev_warn
- coding style
Adviced by Heiko
- remove rtc_ctl
Changes in v6:
Adviced by doug
- move RTC_READSEL setting into probe
Changes in v5:
- fixed a bug about set_time failed
Changes in v4:
- use &client->dev replace rk808->dev
Changes in v3: None
Changes in v2:
Adviced by javier.martinez
- Add a separate clock driver, rather than in RTC driver
drivers/rtc/Kconfig | 10 ++ drivers/rtc/Makefile | 1 + drivers/rtc/rtc-rk808.c | 426 +++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 437 insertions(+) create mode 100644 drivers/rtc/rtc-rk808.c
drivers/rtc/Kconfig +10 -0
@@ -288,6 +288,16 @@ config RTC_DRV_MAX77686 This driver can also be built as a module. If so, the module will be called rtc-max77686. +config RTC_DRV_RK808 + tristate "Rockchip RK808 RTC" + depends on MFD_RK808 + help + If you say yes here you will get support for the + RTC of RK808 PMIC. + + This driver can also be built as a module. If so, the module + will be called rk808-rtc. + config RTC_DRV_RS5C372 tristate "Ricoh R2025S/D, RS5C372A/B, RV5C386, RV5C387A" help
drivers/rtc/Makefile +1 -0
@@ -109,6 +109,7 @@ obj-$(CONFIG_RTC_DRV_PUV3) += rtc-puv3.o obj-$(CONFIG_RTC_DRV_PXA) += rtc-pxa.o obj-$(CONFIG_RTC_DRV_R9701) += rtc-r9701.o obj-$(CONFIG_RTC_DRV_RC5T583) += rtc-rc5t583.o +obj-$(CONFIG_RTC_DRV_RK808) += rtc-rk808.o obj-$(CONFIG_RTC_DRV_RP5C01) += rtc-rp5c01.o obj-$(CONFIG_RTC_DRV_RS5C313) += rtc-rs5c313.o obj-$(CONFIG_RTC_DRV_RS5C348) += rtc-rs5c348.o
drivers/rtc/rtc-rk808.c new file +426 -0
426 lines not on this page · raw message
Signature · 1 line
1.7.9.5
PATCH v8 3/5 RTC: RK808: add RTC driver for RK808
In reply to Chris ZhongAdding RTC driver for supporting RTC device present inside RK808 PMIC.
---
Changes in v8:
Adviced by Doug
- coding style
- fix regmap_update_bits()
- if(rk808_rtc->irq < 0) return err num
Changes in v7:
Adviced by doug
- read rtc time from shadowed registers
Adviced by Dmitry
- use CONFIG_PM_SLEEP replace CONFIG_PM
- use SIMPLE_DEV_PM_OPS replace dev_pm_ops
- fix dev_warn
- coding style
Adviced by Heiko
- remove rtc_ctl
Changes in v6:
Adviced by doug
- move RTC_READSEL setting into probe
Changes in v5:
- fixed a bug about set_time failed
Changes in v4:
- use &client->dev replace rk808->dev
Changes in v3: None
Changes in v2:
Adviced by javier.martinez
- Add a separate clock driver, rather than in RTC driver
drivers/rtc/Kconfig | 10 ++ drivers/rtc/Makefile | 1 + drivers/rtc/rtc-rk808.c | 426 +++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 437 insertions(+) create mode 100644 drivers/rtc/rtc-rk808.c
drivers/rtc/Kconfig +10 -0
@@ -288,6 +288,16 @@ config RTC_DRV_MAX77686 This driver can also be built as a module. If so, the module will be called rtc-max77686. +config RTC_DRV_RK808 + tristate "Rockchip RK808 RTC" + depends on MFD_RK808 + help + If you say yes here you will get support for the + RTC of RK808 PMIC. + + This driver can also be built as a module. If so, the module + will be called rk808-rtc. + config RTC_DRV_RS5C372 tristate "Ricoh R2025S/D, RS5C372A/B, RV5C386, RV5C387A" help
drivers/rtc/Makefile +1 -0
@@ -109,6 +109,7 @@ obj-$(CONFIG_RTC_DRV_PUV3) += rtc-puv3.o obj-$(CONFIG_RTC_DRV_PXA) += rtc-pxa.o obj-$(CONFIG_RTC_DRV_R9701) += rtc-r9701.o obj-$(CONFIG_RTC_DRV_RC5T583) += rtc-rc5t583.o +obj-$(CONFIG_RTC_DRV_RK808) += rtc-rk808.o obj-$(CONFIG_RTC_DRV_RP5C01) += rtc-rp5c01.o obj-$(CONFIG_RTC_DRV_RS5C313) += rtc-rs5c313.o obj-$(CONFIG_RTC_DRV_RS5C348) += rtc-rs5c348.o
drivers/rtc/rtc-rk808.c new file +426 -0
426 lines not on this page · raw message
Signature · 1 line
1.7.9.5
PATCH v8 3/5 RTC: RK808: add RTC driver for RK808
In reply to Chris ZhongAdding RTC driver for supporting RTC device present inside RK808 PMIC.
---
Changes in v8:
Adviced by Doug
- coding style
- fix regmap_update_bits()
- if(rk808_rtc->irq < 0) return err num
Changes in v7:
Adviced by doug
- read rtc time from shadowed registers
Adviced by Dmitry
- use CONFIG_PM_SLEEP replace CONFIG_PM
- use SIMPLE_DEV_PM_OPS replace dev_pm_ops
- fix dev_warn
- coding style
Adviced by Heiko
- remove rtc_ctl
Changes in v6:
Adviced by doug
- move RTC_READSEL setting into probe
Changes in v5:
- fixed a bug about set_time failed
Changes in v4:
- use &client->dev replace rk808->dev
Changes in v3: None
Changes in v2:
Adviced by javier.martinez
- Add a separate clock driver, rather than in RTC driver
drivers/rtc/Kconfig | 10 ++ drivers/rtc/Makefile | 1 + drivers/rtc/rtc-rk808.c | 426 +++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 437 insertions(+) create mode 100644 drivers/rtc/rtc-rk808.c
drivers/rtc/Kconfig +10 -0
@@ -288,6 +288,16 @@ config RTC_DRV_MAX77686 This driver can also be built as a module. If so, the module will be called rtc-max77686. +config RTC_DRV_RK808 + tristate "Rockchip RK808 RTC" + depends on MFD_RK808 + help + If you say yes here you will get support for the + RTC of RK808 PMIC. + + This driver can also be built as a module. If so, the module + will be called rk808-rtc. + config RTC_DRV_RS5C372 tristate "Ricoh R2025S/D, RS5C372A/B, RV5C386, RV5C387A" help
drivers/rtc/Makefile +1 -0
@@ -109,6 +109,7 @@ obj-$(CONFIG_RTC_DRV_PUV3) += rtc-puv3.o obj-$(CONFIG_RTC_DRV_PXA) += rtc-pxa.o obj-$(CONFIG_RTC_DRV_R9701) += rtc-r9701.o obj-$(CONFIG_RTC_DRV_RC5T583) += rtc-rc5t583.o +obj-$(CONFIG_RTC_DRV_RK808) += rtc-rk808.o obj-$(CONFIG_RTC_DRV_RP5C01) += rtc-rp5c01.o obj-$(CONFIG_RTC_DRV_RS5C313) += rtc-rs5c313.o obj-$(CONFIG_RTC_DRV_RS5C348) += rtc-rs5c348.o
drivers/rtc/rtc-rk808.c new file +426 -0
426 lines not on this page · raw message
Signature · 6 lines
1.7.9.5 -- To unsubscribe from this list: send the line "unsubscribe devicetree" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
Heiko Stübner
maintainerRe: [PATCH v8 5/5] regulator: RK808: Remove pdata from the regulator
In reply to Chris ZhongAm Donnerstag, 4. September 2014, 01:06:14 schrieb Chris Zhong:
Quoted 148 lines
Signed-off-by Chris Zhong <[email protected]>Tested-by Heiko <[email protected]>---
Changes in v8:
Adviced by Doug
- removerk808_regulator_dts()function
- remove the check about "client->dev.of_node"Changes in v7:
- remove pdata struct from header file, addrk808_regulatorstructChanges in v6:
- remove the redundant codeChanges in v5:
- re-edit base on Mark's branchChanges in v4:
- use&client->devreplacerk808->devChanges in v3: None
Changes in v2:
Adviced by Mark Browm:
- changeof_find_node_by_nametofind_child_by_name
- useRK808_NUM_REGULATORSas the name of the constant
- create a pdata when missing platform data
- use therk808_regname tosupply_regulatorname
- replaceregulator_registerwithdevm_regulator_register
- some other problem with coding styledrivers/regulator/rk808-regulator.c | 89+++++++---------------------------- 1 file changed, 17 insertions(+), 72 deletions(-)
(quoted diff) +0
-0
b/drivers/regulator/rk808-regulator.cindex e372008..1f6d108 100644drivers/regulator/rk808-regulator.c +2
-2@@ -3,8 +3,8 @@* * Copyright (c) 2014, Fuzhou Rockchip Electronics Co., Ltd * -* Author: Chris Zhong <[email protected]> -* Author: Zhang Qing <[email protected]> +* Author: Chris Zhong<[email protected]> +* Author: Zhang Qing<[email protected]> * * This program is free software; you can redistribute it and/or modify it * under the terms and conditions of the GNU General Public License, @@ -14,24 +14,16 @@* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for * more details.
- *
*/#include <
linux/module.h>drivers/regulator/rk808-regulator.c +3
-54-#include <linux/init.h> #include <linux/i2c.h> -#include <linux/err.h> -#include <linux/platform_device.h> #include <linux/mfd/rk808.h> -#include <linux/of.h> #include <linux/of_device.h> #include <linux/regulator/driver.h> #include <linux/regulator/of_regulator.h> -#include <linux/regmap.h> -#include <linux/slab.h> -/* -* Field Definitions. -*/ + +/* Field Definitions */ #define RK808_BUCK_VSEL_MASK 0x3f#define RK808_BUCK4_VSEL_MASK 0xf#define RK808_LDO_VSEL_MASK 0x1f@@ -50,10 +42,6 @@ static const int buck_contr_base_addr[] = { RK808_BUCK4_CONFIG_REG, }; -#define rk808_BUCK_SET_VOL_REG (x) (buck_set_vol_base_addr[x]) -#define rk808_BUCK_CONTR_REG (x) (buck_contr_base_addr[x]) -#define rk808_LDO_SET_VOL_REG (x) (ldo_set_vol_base_addr[x]) -static const int ldo_set_vol_base_addr[] = {RK808_LDO1_ON_VSEL_REG ,RK808_LDO2_ON_VSEL_REG ,@@ -65,9 +53,7 @@ static const int ldo_set_vol_base_addr[] = { RK808_LDO8_ON_VSEL_REG, }; -/* -* rk808 voltage number -*/ +/* rk808 voltage number */ static const struct regulator_linear_range rk808_buck_voltage_ranges[] = {REGULATOR_LINEAR_RANGE (700000 ,0 ,63 ,12500 ), };@@ -308,77 +294,35 @@ static struct of_regulator_match rk808_reg_matches[] = { [RK808_ID_SWITCH2] = { .name = "SWITCH_REG2" }, }; -static int rk808_regulator_dts (struct i2c_client *client, -struct rk808_board *pdata) -{ -struct device_node *np, *reg_np; -int i, ret; - - np = client->dev.of_node; -if (!np) { -dev_err (&client->dev,"could not find pmic sub-node\n" ); -return -ENXIO ; - } - - reg_np =of_get_child_by_name (np,"regulators" ); -if (!reg_np) -return -ENXIO ; - - ret =of_regulator_match (&client->dev, reg_np, rk808_reg_matches, -RK808_NUM_REGULATORS ); -if (ret <0 ) { -dev_err (&client->dev, -"failed to parse regulator data: %d\n" , ret); -return ret; - } - -for (i =0 ; i <RK808_NUM_REGULATORS ; i++) { -if (!rk808_reg_matches[i].init_data || - !rk808_reg_matches[i].of_node) -continue ; - - pdata->rk808_init_data[i] = rk808_reg_matches[i].init_data; - pdata->of_node[i] = rk808_reg_matches[i].of_node; - } - -return 0 ; -} -static int rk808_regulator_probe (struct platform_device *pdev) {struct rk808 *rk808 =dev_get_drvdata (pdev->dev.parent);struct i2c_client *client = rk808->i2c; -struct rk808_board *pdata =dev_get_platdata (&client->dev);struct regulator_config config = {};struct regulator_dev *rk808_rdev; -struct regulator_init_data *reg_data;
drivers/regulator/rk808-regulator.c static struct of_regulator_match rk808_reg_matches[] = · line 306
Quoted 10 lines
drivers/regulator/rk808-regulator.c +2
-6-int i =0 ;int ret =0 ; +int i =0 ; -if (!pdata) { - pdata =devm_kzalloc (&pdev->dev,sizeof (*pdata),GFP_KERNEL ); -if (!pdata) -return -ENOMEM ; - } + reg_np =of_get_child_by_name (np,"regulators" );
It looks like an error happened while moving that block of code, because with this applied both "reg_np" and "np" are not defined - thus producing compile errors.
Heiko
Quoted 38 lines
drivers/regulator/rk808-regulator.c +10
-9+if (!reg_np) +return -ENXIO ; - ret =rk808_regulator_dts (client, pdata); -if (ret) + ret =of_regulator_match (&client->dev, reg_np, rk808_reg_matches, +RK808_NUM_REGULATORS ); +if (ret <0 )return ret;/* Instantiate the regulators */ for (i =0 ; i <RK808_NUM_REGULATORS ; i++) { - reg_data = pdata->rk808_init_data[i]; -if (!reg_data) +if (!rk808_reg_matches[i].init_data || + !rk808_reg_matches[i].of_node)continue ; config.dev = &client->dev; config.driver_data = rk808; config.regmap = rk808->regmap; - -if (client->dev.of_node) - config.of_node = pdata->of_node[i]; - - config.init_data = reg_data; + config.of_node = rk808_reg_matches[i].of_node; + config.init_data = rk808_reg_matches[i].init_data; rk808_rdev =devm_regulator_register (&pdev->dev, &rk808_reg[i], &config);@@ -388,6 +332,7 @@ static int rk808_regulator_probe(struct platform_device *pdev) return PTR_ERR(rk808_rdev); } } +return 0 ; }
Am Mittwoch, 3. September 2014, 21:51:42 schrieb Chris Zhong:
Quoted 6 lines
This is the initial version of the RK808 PMIC. This is a power management IC for multimedia products.
It provides regulators that are able to supply power to processor cores and other components. The chip provides other modules including RTC, Clockout
after fixing the glitch in patch 5, again
@Chris: also please use the full name as stated above when transfering tags to patches. I'm sadly not unique enough to be identified only by my first name ;-)
Heiko
Quoted 133 lines
Changes in v8:
Advices by Doug
- add description about "vccn-supply"
- modify description about clock-cells Adviced by Lee Jones
- add Author
- remove if(np) andof_match_ptr()since depend on OF
- coding style
Adviced by Doug
- coding style
- fixregmap_update_bits()
-if(rk808_rtc->irq < 0)return err num Adviced by Mike(quoted diff) +0
-2-rename "control" to "enable" -define RK808_NR_OUTPUT 2Adviced by Doug
- removerk808_regulator_dts()function
- remove the check about "client->dev.of_node"Changes in v7:
Advices by Mark Rutland
- modify description about clock-cells
- update the example
Adviced by Lee Jones
- coding style
- removerk808_pre_initfunction
Adviced by Doug
- add "&& OF" to the dependencies
- add .init_ack_masked = true inrk808_irq_chip
Adviced by doug
- read rtc time from shadowed registers
Adviced by Dmitry
- useCONFIG_PM_SLEEPreplaceCONFIG_PM
- useSIMPLE_DEV_PM_OPSreplacedev_pm_ops
- fixdev_warn
- coding style
Adviced by Heiko
- removertc_ctl
Adviced by doug
-fix coding style problems
- remove pdata struct from header file, addrk808_regulatorstructChanges in v6:
Advices by Mark Rutland
- add description about clock-cells
Advices by Doug
- modify description about regulator
- remove pinctrl description
Adviced by Lee Jones in v2
-rk808_i2c_clientinstead ofg_rk808
- remove pdata form struct rk808
Adviced by doug
- moveRTC_READSELsetting into probe
Adviced by doug
- use correct argument callof_clk_add_providerin probe
- remove the redundant codeChanges in v5:
Advices by Mark Brown
- add description about regulator valid name.
- add a header file "rockchip,rk808".
- fixed a bug aboutset_timefailed
Adviced by doug
- add some error checking in probe
- move "rockchip,rk808.h" into the patch about dt-bindings
- re-edit base on Mark's branchChanges in v4:
Advices by Doug
- add a "#clock-cells" propertiy
- update the example
Adviced by Lee Jones in v2
- modify the description inKconfig
- remove some unnecessary header files
- remove dev from struct rk808
- use enum for defineRK808_ID...
- use&client->devreplacerk808->dev
Adviced by doug
- add "clock-output-names" propertiey
- add a header file "rockchip,rk808.h"
- use&client->devreplacerk808->devChanges in v3:
- fix compile err
- fix compile errChanges in v2:
Adviced by Mark Browm:
- use defines for register setting value
- remove rtc alarm disable in shutdown
- remove while(1) in shutdown
- remove read0x2fin probe
Adviced by javier.martinez
- Add a separate clock driver, rather than in RTC driver Adviced by javier.martinez
- separated fromrtc-rk808.c
Adviced by Mark Browm:
- changeof_find_node_by_nametofind_child_by_name
- useRK808_NUM_REGULATORSas the name of the constant
- create a pdata when missing platform data
- use therk808_regname tosupply_regulatorname
- replaceregulator_registerwithdevm_regulator_register
- some other problem with coding styleChris Zhong (5):
dt-bindings: Add RK808 device tree bindings document
MFD: RK808: Add new mfd driver for RK808
RTC: RK808: add RTC driver for RK808
clk: RK808: Add clkout driver for RK808
regulator: RK808: Remove pdata from the regulatorDocumentation/devicetree/bindings/mfd/rk808.txt | 177 ++++++++++ drivers/clk/Kconfig | 9 + drivers/clk/Makefile | 1 + drivers/clk/clk-rk808.c | 164 +++++++++ drivers/mfd/Kconfig | 13 + drivers/mfd/Makefile | 1 + drivers/mfd/rk808.c | 245 +++++++++++++ drivers/regulator/rk808-regulator.c | 89 +---- drivers/rtc/Kconfig | 10 + drivers/rtc/Makefile | 1 + drivers/rtc/rtc-rk808.c | 426 +++++++++++++++++++++++ include/dt-bindings/clock/rockchip,rk808.h | 11 + include/linux/mfd/rk808.h | 196 +++++++++++ 13 files changed, 1271 insertions(+), 72 deletions(-) create mode 100644 Documentation/devicetree/bindings/mfd/rk808.txt create mode 100644 drivers/clk/clk-rk808.c create mode 100644 drivers/mfd/rk808.c create mode 100644 drivers/rtc/rtc-rk808.c create mode 100644 include/dt-bindings/clock/rockchip,rk808.h create mode 100644 include/linux/mfd/rk808.h
Re: [PATCH v8 3/5] RTC: RK808: add RTC driver for RK808
In reply to Chris ZhongChris,
drivers/rtc/rtc-rk808.c line 398
Quoted 6 lines · Chris Zhong
drivers/rtc/rtc-rk808.c new file +6
-0+ rk808_rtc->irq =platform_get_irq (pdev,0 ); +if (rk808_rtc->irq <=0 ) { +dev_err (&pdev->dev,"Wake up is not possible as irq = %d\n" , + rk808_rtc->irq); +return -ENXIO ; + }
You missed some of my feedback (though your changelog says otherwise).
Note: it would probably be good to also only print if it's not EPROBE_DEFER.
Thus, the above should be:
rk808_rtc->irq = platform_get_irq(pdev, 0);
if (rk808_rtc->irq < 0) {
if (rk808_rtc->irq != -EPROBE_DEFER)
dev_err(&pdev->dev, "Wake up is not possible as irq = %d\n",
rk808_rtc->irq);
return rk808_rtc->irq;
}--
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 v8 5/5] regulator: RK808: Remove pdata from the regulator
In reply to Chris ZhongChris,
Quoted 9 lines · Chris Zhong
Signed-off-by Chris Zhong <[email protected]>Tested-by Heiko <[email protected]>---
Changes in v8:
Adviced by Doug
- removerk808_regulator_dts()function
- remove the check about "client->dev.of_node"
Nice, this cleaned this up a lot. Thanks!
drivers/regulator/rk808-regulator.c static struct of_regulator_match rk808_reg_matches[] = { · line 355
Quoted 9 lines
static int
rk808_regulator_probe(struct platform_device *pdev){ struct rk808 *rk808 = dev_get_drvdata(pdev->dev.parent); struct i2c_client *client = rk808->i2c;drivers/regulator/rk808-regulator.c +0
-3-struct rk808_board *pdata =dev_get_platdata (&client->dev);struct regulator_config config = {};struct regulator_dev *rk808_rdev; -struct regulator_init_data *reg_data; -int i =0 ;
As Heiko mentioned, you need "struct device_node *np, *reg_np;" here.
Quoted 2 lines
int ret = 0;+ int i = 0;
nit: I think neither "ret" nor "i" needs to be initted here.
Otherwise I agree that this looks really good!
-Doug
--
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