summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorZhang Nian <zhangnian@huawei.com>2014-11-29 14:52:56 +0800
committerXinwei Kong <kong.kongxinwei@hisilicon.com>2015-11-08 14:57:24 +0800
commite0f235c47943bcab7edd82ab05d3aef28f501c06 (patch)
treef4fbedf7394cb86fd8809700eef81c79f6ae9ae7
parenta0b19830b466314b1bde5bbd4286645bc5b3f642 (diff)
pmic/regulator: Add hisilicon hi655X pmic/regulator core driver for hi6220 SoC
Signed-off-by: Zhang Nian <zhangnian@huawei.com> Signed-off-by: Bintian Wang <bintian.wang@huawei.com> Signed-off-by: Dongbin Yu <yudongbin@huawei.com> Signed-off-by: Fei Wang <w.f@huawei.com> Signed-off-by: Xinwei Kong <kong.kongxinwei@hisilicon.com>
-rw-r--r--Documentation/devicetree/bindings/mfd/hi6552.txt75
-rw-r--r--Documentation/devicetree/bindings/regulator/hi6220-mtcmos.txt29
-rw-r--r--arch/arm64/Kconfig2
-rw-r--r--arch/arm64/boot/dts/hisilicon/hi6220.dtsi252
-rw-r--r--arch/arm64/configs/defconfig3
-rw-r--r--drivers/mfd/Kconfig7
-rw-r--r--drivers/mfd/Makefile1
-rw-r--r--drivers/mfd/hi655x-pmic.c392
-rw-r--r--drivers/regulator/Kconfig13
-rw-r--r--drivers/regulator/Makefile3
-rw-r--r--drivers/regulator/hi6220-mtcmos.c268
-rw-r--r--drivers/regulator/hi655x-regulator.c515
-rw-r--r--include/linux/mfd/hi6552_pmic.h49
-rw-r--r--include/linux/mfd/hi655x-pmic.h49
-rw-r--r--include/linux/regulator/hi655x-regulator.h39
15 files changed, 1694 insertions, 3 deletions
diff --git a/Documentation/devicetree/bindings/mfd/hi6552.txt b/Documentation/devicetree/bindings/mfd/hi6552.txt
new file mode 100644
index 000000000000..8cbd46fab79b
--- /dev/null
+++ b/Documentation/devicetree/bindings/mfd/hi6552.txt
@@ -0,0 +1,75 @@
+* Hisilicon hi6552 Power Management Integrated Circuit (PMIC)
+
+hi6552 consists of a large and varied group of sub-devices:
+
+Device Supply Names Description
+------ ------------ -----------
+hi6552-powerkey : : Powerkey
+hi6552-regulator-pmic : : Regulators
+hi6552-usbvbus : : USB plug detection
+hi6552-pmu-rtc : : RTC
+hi6552-coul : : Coulomb
+
+Required properties:
+- compatible : Should be "hisilicon,hi6552-pmic-driver"
+- reg: Base address of PMIC on hi6220 soc
+- #interrupt-cells: Should be 2, is the local IRQ number for hi6552.
+- interrupt-controller: hi6552 has internal IRQs (has own IRQ domain).
+- pmu_irq_gpio: should be &gpio_pmu_irq_n, is the IRQ gpio of hi6552.
+
+Example:
+ pmic: pmic@F8000000 {
+ compatible = "hisilicon,hi6552-pmic-driver";
+ reg = <0x0 0xF8000000 0x0 0x1000>;
+ #interrupt-cells = <2>;
+ interrupt-controller;
+ pmu_irq_gpio = <&gpio_pmu_irq_n>;
+ status = "ok";
+ ponkey:ponkey@b1{
+ compatible = "hisilicon,hi6552-powerkey";
+ interrupt-parent = <&pmic>;
+ interrupts = <6 0>, <5 0>, <4 0>;
+ interrupt-names = "down", "up", "hold 1s";
+ };
+ coul: coul@1 {
+ compatible = "hisilicon,hi6552-coul";
+ interrupt-parent = <&pmic>;
+ interrupts = <24 0>, <25 0>, <26 0>, <27 0>;
+ interrupt-names = "cl_int_i", "cl_out_i", "cl_in_i", "vbat_int_i";
+ battery_product_index = <0>;
+ status = "ok";
+ };
+ rtc: rtc@1 {
+ compatible = "hisilicon,hi6552-pmu-rtc";
+ interrupt-parent = <&pmic>;
+ interrupts = <20 0>;
+ interrupt-names = "hi6552_pmu_rtc";
+ board_id = <1>;
+ };
+ usbvbus:usbvbus@b2{
+ compatible = "hisilicon,hi6552-usbvbus";
+ interrupt-parent = <&pmic>;
+ interrupts = <9 0>, <8 0>;
+ interrupt-names = "connect", "disconnect";
+ };
+ ldo2: regulator@a21 {
+ compatible = "hisilicon,hi6552-regulator-pmic";
+ regulator-name = "ldo2";
+ regulator-min-microvolt = <2500000>;
+ regulator-max-microvolt = <3200000>;
+ hisilicon,valid-modes-mask = <0x02>;
+ hisilicon,valid-ops-mask = <0x01d>;
+ hisilicon,initial-mode = <0x02>;
+ hisilicon,regulator-type = <0x01>;
+
+ hisilicon,off-on-delay = <120>;
+ hisilicon,ctrl-regs = <0x029 0x02a 0x02b>;
+ hisilicon,ctrl-data = <0x1 0x1>;
+ hisilicon,vset-regs = <0x072>;
+ hisilicon,vset-data = <0 0x3>;
+ hisilicon,regulator-n-vol = <8>;
+ hisilicon,vset-table = <2500000>,<2600000>,<2700000>,<2800000>,<2900000>,<3000000>,<3100000>,<3200000>;
+ hisilicon,num_consumer_supplies = <1>;
+ hisilicon,consumer-supplies = "sensor_analog";
+ };
+ };
diff --git a/Documentation/devicetree/bindings/regulator/hi6220-mtcmos.txt b/Documentation/devicetree/bindings/regulator/hi6220-mtcmos.txt
new file mode 100644
index 000000000000..720bdfc02fd1
--- /dev/null
+++ b/Documentation/devicetree/bindings/regulator/hi6220-mtcmos.txt
@@ -0,0 +1,29 @@
+
+Required parent device properties:
+- compatible:
+ - "hisilicon,hi6xxx-mtcmos-driver"
+- hisilicon,mtcmos-steady-us: The time to wait for power steady
+- hisilicon,mtcmos-sc-on-base: address of hi6220 soc control register
+
+Required child device properties:
+- regulator-name: The name of mtcmos
+- hisilicon,ctrl-regs: offset of ctrl-regs
+- hisilicon,ctrl-data: the bit to ctrl the regulator
+
+Example:
+ mtcmos {
+ compatible = "hisilicon,hi6220-mtcmos-driver";
+ hisilicon,mtcmos-steady-us = <10>;
+ hisilicon,mtcmos-sc-on-base = <0xf7800000>;
+
+ mtcmos1: regulator@a1{
+ regulator-name = "G3D_PD_VDD";
+ hisilicon,ctrl-regs = <0x830 0x834 0x83c>;
+ hisilicon,ctrl-data = <1 0x1>;
+ };
+ mtcmos2: regulator@a2{
+ regulator-name = "SOC_MED";
+ hisilicon,ctrl-regs = <0x830 0x834 0x83c>;
+ hisilicon,ctrl-data = <2 0x1>;
+ };
+ };
diff --git a/arch/arm64/Kconfig b/arch/arm64/Kconfig
index 4855e85006ec..0e25ce9d99c7 100644
--- a/arch/arm64/Kconfig
+++ b/arch/arm64/Kconfig
@@ -293,6 +293,8 @@ config ARCH_HISI
select ARCH_REQUIRE_GPIOLIB
select GPIO_PL061
select COMMON_CLK_HI6220
+ select MFD_HI655X_PMIC
+ select REGULATOR_HI655X
help
This enables support for Hisilicon ARMv8 Family of SoCs.
diff --git a/arch/arm64/boot/dts/hisilicon/hi6220.dtsi b/arch/arm64/boot/dts/hisilicon/hi6220.dtsi
index cd99451cbefe..cc4545167912 100644
--- a/arch/arm64/boot/dts/hisilicon/hi6220.dtsi
+++ b/arch/arm64/boot/dts/hisilicon/hi6220.dtsi
@@ -563,7 +563,255 @@
};
};
- gpio_pmu_irq_n:gpio_pmu_irq_n {
- gpios = <&gpio1 6 0>;
+ pmic: pmic@F8000000 {
+ compatible = "hisilicon,hi6552-pmic-driver";
+ reg = <0x0 0xf8000000 0x0 0x1000>;
+ #interrupt-cells = <2>;
+ interrupt-controller;
+ pmu_irq_gpio = <&gpio_pmu_irq_n>;
+ status = "ok";
+ ponkey:ponkey@b1{
+ compatible = "hisilicon,hi6552-powerkey";
+ interrupt-parent = <&pmic>;
+ interrupts = <6 0>, <5 0>, <4 0>;
+ interrupt-names = "down", "up", "hold 1s";
+ };
+ coul: coul@1 {
+ compatible = "hisilicon,hi6552-coul";
+ interrupt-parent = <&pmic>;
+ interrupts = <24 0>, <25 0>, <26 0>, <27 0>;
+ interrupt-names = "cl_int_i", "cl_out_i", "cl_in_i", "vbat_int_i";
+ battery_product_index = <0>;
+ status = "ok";
+ };
+ rtc: rtc@1 {
+ compatible = "hisilicon,hi6552-pmu-rtc";
+ interrupt-parent = <&pmic>;
+ interrupts = <20 0>;
+ interrupt-names = "hi6552_pmu_rtc";
+ board_id = <1>;
+ };
+ ldo2: regulator@a21 {
+ compatible = "hisilicon,hi6552-regulator-pmic";
+ regulator-name = "ldo2";
+ regulator-min-microvolt = <2500000>;
+ regulator-max-microvolt = <3200000>;
+ hisilicon,valid-modes-mask = <0x02>;
+ hisilicon,valid-ops-mask = <0x01d>;
+ hisilicon,initial-mode = <0x02>;
+ hisilicon,regulator-type = <0x01>;
+
+ hisilicon,off-on-delay = <120>;
+ hisilicon,ctrl-regs = <0x029 0x02a 0x02b>;
+ hisilicon,ctrl-data = <0x1 0x1>;
+ hisilicon,vset-regs = <0x072>;
+ hisilicon,vset-data = <0 0x3>;
+ hisilicon,regulator-n-vol = <8>;
+ hisilicon,vset-table = <2500000>,<2600000>,<2700000>,<2800000>,<2900000>,<3000000>,<3100000>,<3200000>;
+ hisilicon,num_consumer_supplies = <1>;
+ hisilicon,consumer-supplies = "sensor_analog";
+ };
+ ldo7: regulator@a26 {
+ compatible = "hisilicon,hi6552-regulator-pmic";
+ regulator-name = "ldo7";
+ regulator-min-microvolt = <1800000>;
+ regulator-max-microvolt = <3300000>;
+ hisilicon,valid-modes-mask = <0x0a>;
+ hisilicon,valid-ops-mask = <0x01d>;
+ hisilicon,initial-mode = <0x02>;
+ hisilicon,regulator-type = <0x01>;
+
+ hisilicon,off-on-delay = <120>;
+ hisilicon,ctrl-regs = <0x029 0x02a 0x02b>;
+ hisilicon,ctrl-data = <0x6 0x1>;
+ hisilicon,vset-regs = <0x078>;
+ hisilicon,vset-data = <0 0x3>;
+ hisilicon,regulator-n-vol = <8>;
+ hisilicon,vset-table = <1800000>,<1850000>,<2850000>,<2900000>,<3000000>,<3100000>,<3200000>,<3300000>;
+ hisilicon,num_consumer_supplies = <1>;
+ hisilicon,consumer-supplies = "sd_card_io";
+ };
+ ldo10: regulator@a29 {
+ compatible = "hisilicon,hi6552-regulator-pmic";
+ regulator-name = "ldo10";
+ regulator-min-microvolt = <1800000>;
+ regulator-max-microvolt = <3000000>;
+ hisilicon,valid-modes-mask = <0x0a>;
+ hisilicon,valid-ops-mask = <0x01d>;
+ hisilicon,initial-mode = <0x02>;
+ hisilicon,regulator-type = <0x01>;
+
+ hisilicon,off-on-delay = <360>;
+ hisilicon,ctrl-regs = <0x02c 0x02d 0x02e>;
+ hisilicon,ctrl-data = <0x1 0x1>;
+ hisilicon,vset-regs = <0x07b>;
+ hisilicon,vset-data = <0 0x3>;
+ hisilicon,regulator-n-vol = <8>;
+ hisilicon,vset-table = <1800000>,<1850000>,<1900000>,<2750000>,<2800000>,<2850000>,<2900000>,<3000000>;
+ hisilicon,num_consumer_supplies = <1>;
+ hisilicon,consumer-supplies = "sd_card";
+ };
+ ldo13: regulator@a32 {
+ compatible = "hisilicon,hi6552-regulator-pmic";
+ regulator-name = "ldo13";
+ regulator-min-microvolt = <1600000>;
+ regulator-max-microvolt = <1950000>;
+ hisilicon,valid-modes-mask = <0x0a>;
+ hisilicon,valid-ops-mask = <0x01d>;
+ hisilicon,initial-mode = <0x02>;
+ hisilicon,regulator-type = <0x01>;
+
+ hisilicon,off-on-delay = <120>;
+ hisilicon,ctrl-regs = <0x02c 0x02d 0x02e>;
+ hisilicon,ctrl-data = <0x4 0x1>;
+ hisilicon,vset-regs = <0x07e>;
+ hisilicon,vset-data = <0 0x3>;
+ hisilicon,regulator-n-vol = <8>;
+ hisilicon,vset-table = <1600000>,<1650000>,<1700000>,<1750000>,<1800000>,<1850000>,<1900000>,<1950000>;
+ hisilicon,num_consumer_supplies = <3>;
+ hisilicon,consumer-supplies = "scamera_core","mcamera_io","scamera_io";
+ };
+ ldo14: regulator@a33 {
+ compatible = "hisilicon,hi6552-regulator-pmic";
+ regulator-name = "ldo14";
+ regulator-min-microvolt = <2500000>;
+ regulator-max-microvolt = <3200000>;
+ hisilicon,valid-modes-mask = <0x02>;
+ hisilicon,valid-ops-mask = <0x01d>;
+ hisilicon,initial-mode = <0x02>;
+ hisilicon,regulator-type = <0x01>;
+
+ hisilicon,off-on-delay = <120>;
+ hisilicon,ctrl-regs = <0x02c 0x02d 0x02e>;
+ hisilicon,ctrl-data = <0x5 0x1>;
+ hisilicon,vset-regs = <0x07f>;
+ hisilicon,vset-data = <0 0x3>;
+ hisilicon,regulator-n-vol = <8>;
+ hisilicon,vset-table = <2500000>,<2600000>,<2700000>,<2800000>,<2900000>,<3000000>,<3100000>,<3200000>;
+ hisilicon,num_consumer_supplies = <3>;
+ hisilicon,consumer-supplies = "scamera_avdd","mcamera_avdd","mcamera_vcm";
+ };
+ ldo15: regulator@a34 {
+ compatible = "hisilicon,hi6552-regulator-pmic";
+ regulator-name = "ldo15";
+ regulator-min-microvolt = <1600000>;
+ regulator-max-microvolt = <1950000>;
+ regulator-boot-on;
+ regulator-always-on;
+ hisilicon,valid-modes-mask = <0x0a>;
+ hisilicon,valid-ops-mask = <0x01d>;
+ hisilicon,initial-mode = <0x02>;
+ hisilicon,regulator-type = <0x01>;
+
+ hisilicon,off-on-delay = <120>;
+ hisilicon,ctrl-regs = <0x02c 0x02d 0x02e>;
+ hisilicon,ctrl-data = <0x6 0x1>;
+ hisilicon,vset-regs = <0x080>;
+ hisilicon,vset-data = <0 0x3>;
+ hisilicon,regulator-n-vol = <8>;
+ hisilicon,vset-table = <1600000>,<1650000>,<1700000>,<1750000>,<1800000>,<1850000>,<1900000>,<1950000>;
+ hisilicon,num_consumer_supplies = <1>;
+ hisilicon,consumer-supplies = "codec_analog";
+ };
+ ldo17: regulator@a36 {
+ compatible = "hisilicon,hi6552-regulator-pmic";
+ regulator-name = "ldo17";
+ regulator-min-microvolt = <2500000>;
+ regulator-max-microvolt = <3200000>;
+ hisilicon,valid-modes-mask = <0x02>;
+ hisilicon,valid-ops-mask = <0x01d>;
+ hisilicon,initial-mode = <0x02>;
+ hisilicon,regulator-type = <0x01>;
+
+ hisilicon,off-on-delay = <120>;
+ hisilicon,ctrl-regs = <0x02f 0x030 0x031>;
+ hisilicon,ctrl-data = <0x0 0x1>;
+ hisilicon,vset-regs = <0x082>;
+ hisilicon,vset-data = <0 0x3>;
+ hisilicon,regulator-n-vol = <8>;
+ hisilicon,vset-table = <2500000>,<2600000>,<2700000>,<2800000>,<2900000>,<3000000>,<3100000>,<3200000>;
+ hisilicon,num_consumer_supplies = <1>;
+ hisilicon,consumer-supplies = "vibrator";
+ };
+ ldo19: regulator@a38 {
+ compatible = "hisilicon,hi6552-regulator-pmic";
+ regulator-name = "ldo19";
+ regulator-min-microvolt = <1800000>;
+ regulator-max-microvolt = <3000000>;
+ hisilicon,valid-modes-mask = <0x0a>;
+ hisilicon,valid-ops-mask = <0x01d>;
+ hisilicon,initial-mode = <0x02>;
+ hisilicon,regulator-type = <0x01>;
+
+ hisilicon,off-on-delay = <360>;
+ hisilicon,ctrl-regs = <0x02f 0x030 0x031>;
+ hisilicon,ctrl-data = <0x2 0x1>;
+ hisilicon,vset-regs = <0x084>;
+ hisilicon,vset-data = <0 0x3>;
+ hisilicon,regulator-n-vol = <8>;
+ hisilicon,vset-table = <1800000>,<1850000>,<1900000>,<2750000>,<2800000>,<2850000>,<2900000>,<3000000>;
+ hisilicon,num_consumer_supplies = <1>;
+ hisilicon,consumer-supplies = "emmc_vddm";
+ };
+ ldo21: regulator@a40 {
+ compatible = "hisilicon,hi6552-regulator-pmic";
+ regulator-name = "ldo21";
+ regulator-min-microvolt = <1650000>;
+ regulator-max-microvolt = <2000000>;
+ regulator-always-on;
+ hisilicon,valid-modes-mask = <0x02>;
+ hisilicon,valid-ops-mask = <0x01d>;
+ hisilicon,initial-mode = <0x02>;
+ hisilicon,regulator-type = <0x01>;
+
+ hisilicon,off-on-delay = <120>;
+ hisilicon,ctrl-regs = <0x02f 0x030 0x031>;
+ hisilicon,ctrl-data = <0x4 0x1>;
+ hisilicon,vset-regs = <0x086>;
+ hisilicon,vset-data = <0 0x3>;
+ hisilicon,regulator-n-vol = <8>;
+ hisilicon,vset-table = <1650000>,<1700000>,<1750000>,<1800000>,<1850000>,<1900000>,<1950000>,<2000000>;
+ };
+ ldo22: regulator@a41 {
+ compatible = "hisilicon,hi6552-regulator-pmic";
+ regulator-name = "ldo22";
+ regulator-min-microvolt = <900000>;
+ regulator-max-microvolt = <1200000>;
+ regulator-boot-on;
+ regulator-always-on;
+ hisilicon,valid-modes-mask = <0x02>;
+ hisilicon,valid-ops-mask = <0x01d>;
+ hisilicon,initial-mode = <0x02>;
+ hisilicon,regulator-type = <0x01>;
+
+ hisilicon,off-on-delay = <120>;
+ hisilicon,ctrl-regs = <0x02f 0x030 0x031>;
+ hisilicon,ctrl-data = <0x5 0x1>;
+ hisilicon,vset-regs = <0x087>;
+ hisilicon,vset-data = <0 0x3>;
+ hisilicon,regulator-n-vol = <8>;
+ hisilicon,vset-table = <900000>,<1000000>,<1050000>,<1100000>,<1150000>,<1175000>,<1185000>,<1200000>;
+ hisilicon,num_consumer_supplies = <1>;
+ hisilicon,consumer-supplies = "mcamera_core";
+ };
};
+
+ mtcmos {
+ compatible = "hisilicon,hi6220-mtcmos-driver";
+ hisilicon,mtcmos-steady-us = <10>;
+ hisilicon,mtcmos-sc-on-base = <0xf7800000>;
+ hisilicon,mtcmos-acpu-on-base = <0xf65a0000>;
+
+ mtcmos1: regulator@a1{
+ regulator-name = "G3D_PD_VDD";
+ hisilicon,ctrl-regs = <0x830 0x834 0x83c>;
+ hisilicon,ctrl-data = <1 0x1>;
+ };
+ mtcmos2: regulator@a2{
+ regulator-name = "SOC_MED";
+ hisilicon,ctrl-regs = <0x830 0x834 0x83c>;
+ hisilicon,ctrl-data = <2 0x1>;
+ };
+ };
+
};
diff --git a/arch/arm64/configs/defconfig b/arch/arm64/configs/defconfig
index 42b0b9228cda..32fb2beaa614 100644
--- a/arch/arm64/configs/defconfig
+++ b/arch/arm64/configs/defconfig
@@ -3961,6 +3961,7 @@ CONFIG_MFD_WM831X_SPI=y
CONFIG_MFD_WM8350=y
CONFIG_MFD_WM8350_I2C=y
CONFIG_MFD_WM8994=m
+CONFIG_MFD_HI655X_PMIC=y
CONFIG_MFD_VEXPRESS_SYSREG=y
CONFIG_REGULATOR=y
# CONFIG_REGULATOR_DEBUG is not set
@@ -4042,6 +4043,8 @@ CONFIG_REGULATOR_WM831X=m
CONFIG_REGULATOR_WM8350=m
CONFIG_REGULATOR_WM8400=m
CONFIG_REGULATOR_WM8994=m
+CONFIG_REGULATOR_HI6220=y
+CONFIG_REGULATOR_HI655X=y
CONFIG_MEDIA_SUPPORT=m
#
diff --git a/drivers/mfd/Kconfig b/drivers/mfd/Kconfig
index d5ad04dad081..78456525376a 100644
--- a/drivers/mfd/Kconfig
+++ b/drivers/mfd/Kconfig
@@ -1430,6 +1430,13 @@ config MFD_STW481X
in various ST Microelectronics and ST-Ericsson embedded
Nomadik series.
+config MFD_HI655X_PMIC
+ tristate "HiSilicon Hi655X series pmic driver"
+ depends on ARCH_HISI
+ select MFD_CORE
+ help
+ Select this option to enable Hisilicon hi655x series pmic driver.
+
menu "Multimedia Capabilities Port drivers"
depends on ARCH_SA1100
diff --git a/drivers/mfd/Makefile b/drivers/mfd/Makefile
index 0e5cfeba107c..7289209b0a1a 100644
--- a/drivers/mfd/Makefile
+++ b/drivers/mfd/Makefile
@@ -174,6 +174,7 @@ obj-$(CONFIG_MFD_VEXPRESS_SYSREG) += vexpress-sysreg.o
obj-$(CONFIG_MFD_RETU) += retu-mfd.o
obj-$(CONFIG_MFD_AS3711) += as3711.o
obj-$(CONFIG_MFD_AS3722) += as3722.o
+obj-$(CONFIG_MFD_HI655X_PMIC) += hi655x-pmic.o
obj-$(CONFIG_MFD_STW481X) += stw481x.o
obj-$(CONFIG_MFD_IPAQ_MICRO) += ipaq-micro.o
obj-$(CONFIG_MFD_MENF21BMC) += menf21bmc.o
diff --git a/drivers/mfd/hi655x-pmic.c b/drivers/mfd/hi655x-pmic.c
new file mode 100644
index 000000000000..a0910345f6b6
--- /dev/null
+++ b/drivers/mfd/hi655x-pmic.c
@@ -0,0 +1,392 @@
+/*
+ * Hisilicon Hi655x series PMIC driver
+ *
+ * Copyright (c) 2015 Hisilicon Co. Ltd
+ *
+ * Author:
+ * Dongbin Yu <yudongbin@huawei.com>
+ * Bintian Wang <bintian.wang@huawei.com>
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License as published by the
+ * Free Software Foundation; either version 2 of the License, or (at your
+ * option) any later version.
+ *
+ */
+
+#include <linux/io.h>
+#include <linux/irq.h>
+#include <linux/err.h>
+#include <linux/clk.h>
+#include <linux/slab.h>
+#include <linux/ioport.h>
+#include <linux/interrupt.h>
+#include <linux/init.h>
+#include <linux/gpio.h>
+#include <linux/types.h>
+#include <linux/mutex.h>
+#include <linux/delay.h>
+#include <linux/module.h>
+#include <linux/kernel.h>
+#include <linux/hardirq.h>
+#include <linux/of_gpio.h>
+#include <linux/platform_device.h>
+#include <linux/of_platform.h>
+#include <linux/irqdomain.h>
+#include <linux/mfd/hi655x-pmic.h>
+
+static void __iomem *PMUSSI_BASE_ADDR;
+
+#define PMUSSI_REG(addr) ((char *)PMUSSI_BASE_ADDR + ((addr) << 2))
+
+#define DEBUG_PMIC_GPIO
+
+struct hi655x_pmic {
+ struct resource *res;
+ struct device *dev;
+ spinlock_t ssi_hw_lock;
+ struct clk *clk;
+ struct irq_domain *domain;
+ int irq;
+ int gpio;
+ unsigned int irqs[HI655x_NR_IRQ];
+ unsigned int ver;
+};
+
+static struct hi655x_pmic *pmic_dev;
+
+unsigned char hi655x_pmic_reg_read (unsigned int addr)
+{
+ unsigned char val;
+ val = *(volatile unsigned char*)PMUSSI_REG(addr);
+ return val;
+}
+EXPORT_SYMBOL(hi655x_pmic_reg_read);
+
+void hi655x_pmic_reg_write (unsigned int addr, unsigned char val)
+{
+ *(volatile unsigned char*)PMUSSI_REG(addr) = val;
+}
+EXPORT_SYMBOL(hi655x_pmic_reg_write);
+
+unsigned char hi655x_pmic_reg_read_ex (void *pmu_base, unsigned int addr)
+{
+ unsigned char val;
+ val = *(volatile unsigned char*)PMUSSI_REG_EX(pmu_base, addr);
+ return val;
+}
+EXPORT_SYMBOL(hi655x_pmic_reg_read_ex);
+
+void hi655x_pmic_reg_write_ex(void *pmu_base, unsigned int addr, unsigned char val)
+{
+ *(volatile unsigned char*)PMUSSI_REG_EX(pmu_base, addr) = val;
+}
+EXPORT_SYMBOL(hi655x_pmic_reg_write_ex);
+
+static struct of_device_id of_hi655x_pmic_child_match_tbl[] = {
+ { .compatible = "hisilicon,hi6552-regulator-pmic", },
+ { .compatible = "hisilicon,hi6552-powerkey", },
+ { .compatible = "hisilicon,hi6552-usbvbus", },
+ { .compatible = "hisilicon,hi6552-coul", },
+ { .compatible = "hisilicon,hi6552-pmu-rtc", },
+ { .compatible = "hisilicon,hi6552-pmic-mntn", },
+ { /* end */ }
+};
+
+static struct of_device_id of_hi655x_pmic_match_tbl[] = {
+ { .compatible = "hisilicon,hi6552-pmic-driver", },
+ { /* end */ }
+};
+
+unsigned int hi655x_pmic_get_version(void)
+{
+ unsigned int uvalue = 0;
+ uvalue = (unsigned int)hi655x_pmic_reg_read(HI655x_VER_REG);
+ uvalue = uvalue & HI655x_REG_WIDTH;
+
+ return uvalue;
+}
+
+static int hi655x_pmic_version_check(void)
+{
+ int ret = SSI_DEVICE_ERR;
+ int ver = 0;
+
+ ver = hi655x_pmic_get_version();
+ if ((ver >= PMU_VER_START) && (ver <= PMU_VER_END))
+ return SSI_DEVICE_OK;
+
+ return ret;
+}
+
+static irqreturn_t hi655x_pmic_irq_handler(int irq, void *data)
+{
+ struct hi655x_pmic *pmic = (struct hi655x_pmic *)data;
+ unsigned long pending;
+ unsigned int ret = IRQ_NONE;
+ int i, offset;
+
+ for (i = 0; i < HI655x_IRQ_ARRAY; i++) {
+ pending = hi655x_pmic_reg_read((i + HI655x_IRQ_STAT_BASE));
+ pending &= HI655x_REG_WIDTH;
+ if (pending != 0)
+ pr_debug("pending[%d]=0x%lx\n\r", i, pending);
+
+ /* clear pmic-sub-interrupt */
+ hi655x_pmic_reg_write((i + HI655x_IRQ_STAT_BASE), pending);
+
+ if (pending) {
+ for_each_set_bit(offset, &pending, HI655x_BITS)
+ generic_handle_irq(pmic->irqs[offset + i * HI655x_BITS]);
+ ret = IRQ_HANDLED;
+ }
+ }
+
+ return ret;
+}
+
+static void hi655x_pmic_irq_mask(struct irq_data *d)
+{
+ u32 data, offset;
+ unsigned long pmic_spin_flag = 0;
+ offset = ((irqd_to_hwirq(d) >> 3) + HI655x_IRQ_MASK_BASE);
+
+ spin_lock_irqsave(&pmic_dev->ssi_hw_lock, pmic_spin_flag);
+ data = hi655x_pmic_reg_read(offset);
+ data |= (1 << (irqd_to_hwirq(d) & 0x07));
+ hi655x_pmic_reg_write(offset, data);
+ spin_unlock_irqrestore(&pmic_dev->ssi_hw_lock, pmic_spin_flag);
+}
+
+static void hi655x_pmic_irq_unmask(struct irq_data *d)
+{
+ u32 data, offset;
+ unsigned long pmic_spin_flag = 0;
+ offset = ((irqd_to_hwirq(d) >> 3) + HI655x_IRQ_MASK_BASE);
+
+ spin_lock_irqsave(&pmic_dev->ssi_hw_lock, pmic_spin_flag);
+ data = hi655x_pmic_reg_read(offset);
+ data &= ~(1 << (irqd_to_hwirq(d) & 0x07));
+ hi655x_pmic_reg_write(offset, data);
+ spin_unlock_irqrestore(&pmic_dev->ssi_hw_lock, pmic_spin_flag);
+}
+
+static struct irq_chip hi655x_pmic_irqchip = {
+ .name = "hisi-hi655x-pmic-irqchip",
+ .irq_mask = hi655x_pmic_irq_mask,
+ .irq_unmask = hi655x_pmic_irq_unmask,
+};
+
+static int hi655x_pmic_irq_map(struct irq_domain *d, unsigned int virq,
+ irq_hw_number_t hw)
+{
+ struct hi655x_pmic *pmic = d->host_data;
+
+ irq_set_chip_and_handler_name(virq, &hi655x_pmic_irqchip,
+ handle_simple_irq, "hisi-hi655x-pmic-irqchip");
+ irq_set_chip_data(virq, pmic);
+ irq_set_irq_type(virq, IRQ_TYPE_NONE);
+
+ return 0;
+}
+
+static struct irq_domain_ops hi655x_domain_ops = {
+ .map = hi655x_pmic_irq_map,
+ .xlate = irq_domain_xlate_twocell,
+};
+
+static inline void hi655x_pmic_clear_int(void)
+{
+ int addr;
+
+ for (addr = HI655x_IRQ_STAT_BASE; addr < (HI655x_IRQ_STAT_BASE + HI655x_IRQ_ARRAY); addr++)
+ hi655x_pmic_reg_write(addr, HI655x_IRQ_CLR);
+}
+
+static inline void hi655x_pmic_mask_int(void)
+{
+ int addr;
+
+ for (addr = HI655x_IRQ_MASK_BASE; addr < (HI655x_IRQ_MASK_BASE + HI655x_IRQ_ARRAY); addr++)
+ hi655x_pmic_reg_write(addr, HI655x_IRQ_MASK);
+}
+
+static int hi655x_pmic_probe(struct platform_device *pdev)
+{
+ int i = 0;
+ int ret = 0 ;
+ int dev_stat = 0;
+ unsigned int virq = 0;
+ int pmu_on = 1;
+ enum of_gpio_flags gpio_flags;
+ struct device_node *gpio_np = NULL;
+
+ struct device *dev = &pdev->dev;
+ struct device_node *np = dev->of_node;
+ struct hi655x_pmic *pmic = NULL;
+
+ /*
+ * this is new feature in kernel 3.10
+ */
+ pmic = devm_kzalloc(dev, sizeof(*pmic), GFP_KERNEL);
+ if (!pmic) {
+ printk("cannot allocate hi655x_pmic device info\n");
+ return -ENOMEM;
+ }
+ pmic_dev = pmic;
+
+ /* init spin lock */
+ spin_lock_init(&pmic->ssi_hw_lock);
+
+ pmic->res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
+ if (!pmic->res) {
+ printk("platform_get_resource err\n");
+ return -ENOENT;
+ }
+ if (!devm_request_mem_region(dev, pmic->res->start,
+ resource_size(pmic->res),
+ pdev->name)) {
+ printk("cannot claim register memory\n");
+ return -ENOMEM;
+ }
+ PMUSSI_BASE_ADDR = ioremap(pmic->res->start,
+ resource_size(pmic->res));
+ if (!PMUSSI_BASE_ADDR) {
+ printk("cannot map register memory\n");
+ return -ENOMEM;
+ }
+
+ /* confirm the pmu version */
+ pmic->ver = hi655x_pmic_get_version();
+ if ((pmic->ver < PMU_VER_START) || (pmic->ver > PMU_VER_END)) {
+ pr_err("it is wrong pmu version\n");
+ pmu_on = 0;
+ }
+
+ hi655x_pmic_reg_write(0x1b5, 0xff);
+
+#ifdef DEBUG_PMIC_GPIO
+ /*
+ * must finish the gpio&irq is function
+ */
+ gpio_np = of_parse_phandle(np, "pmu_irq_gpio", 0);
+ if (!gpio_np) {
+ dev_err(dev, "can't parse property\n");
+ return -ENOENT;
+ }
+ pmic->gpio = of_get_gpio_flags(gpio_np, 0, &gpio_flags);
+ if (pmic->gpio < 0) {
+ dev_err(dev, "failed to of_get_gpio_flags %d\n", pmic->gpio);
+ return pmic->gpio;
+ }
+ if (!gpio_is_valid(pmic->gpio)) {
+ dev_err(dev, "it is invalid gpio %d\n", pmic->gpio);
+ return -EINVAL;
+ }
+
+ ret = gpio_request_one(pmic->gpio, GPIOF_IN, "hi655x_pmic_irq");
+ if (ret < 0) {
+ pr_err("failed to request gpio %d, ret:%d\n", pmic->gpio, ret);
+ return ret;
+ }
+ pmic->irq = gpio_to_irq(pmic->gpio);
+#endif
+
+ /* clear PMIC sub-interrupt */
+ hi655x_pmic_clear_int();
+
+ /* mask PMIC sub-interrupt */
+ hi655x_pmic_mask_int();
+
+ /* register irq domain */
+ pmic->domain = irq_domain_add_simple(np, HI655x_NR_IRQ, 0,
+ &hi655x_domain_ops, pmic);
+ if (!pmic->domain) {
+ pr_err("in %s failed irq domain add simple!\n", __func__);
+ ret = -ENODEV;
+ return ret;
+ }
+
+ for (i = 0; i < HI655x_NR_IRQ; i++) {
+ virq = irq_create_mapping(pmic->domain, i);
+ if (0 == virq) {
+ printk("Failed mapping hwirq\n");
+ ret = -ENOSPC;
+ return ret;
+ }
+ pmic->irqs[i] = virq;
+ }
+
+ /* Check the GPIO status is high */
+ if (pmu_on) {
+ ret = request_threaded_irq(pmic->irq, hi655x_pmic_irq_handler, NULL,
+ IRQF_TRIGGER_LOW | IRQF_SHARED | IRQF_NO_SUSPEND,
+ "hi655x-pmic-irq", pmic);
+ if (ret < 0) {
+ pr_err("*************could not claim pmic %d\n", ret);
+ ret = -ENODEV;
+ return ret;
+ }
+ }
+
+ pmic->dev = dev;
+
+ /* bind pmic to device */
+ platform_set_drvdata(pdev, pmic);
+
+ /* populate sub nodes */
+ of_platform_populate(np, of_hi655x_pmic_child_match_tbl, NULL, dev);
+
+ dev_stat = hi655x_pmic_version_check();
+ return 0;
+}
+
+#ifdef CONFIG_PM
+static int hi655x_pmic_suspend(struct platform_device *pdev, pm_message_t pm)
+{
+ return 0;
+}
+
+static int hi655x_pmic_resume(struct platform_device *pdev)
+{
+ return 0;
+}
+#endif
+
+static struct platform_driver pmic_driver = {
+ .driver = {
+ .name = "hisi,hi655x-pmic",
+ .owner = THIS_MODULE,
+ .of_match_table = of_hi655x_pmic_match_tbl,
+ },
+ .probe = hi655x_pmic_probe,
+#ifdef CONFIG_PM
+ .suspend = hi655x_pmic_suspend,
+ .resume = hi655x_pmic_resume,
+#endif
+};
+
+static int __init hi655x_pmic_init(void)
+{
+ int ret = 0;
+
+ ret = platform_driver_register(&pmic_driver);
+ if (ret) {
+ printk("%s: platform_driver_register failed %d\n",
+ __func__, ret);
+ }
+
+ return ret;
+}
+
+static void __exit hi655x_pmic_exit(void)
+{
+ platform_driver_unregister(&pmic_driver);
+}
+
+module_init(hi655x_pmic_init);
+module_exit(hi655x_pmic_exit);
+
+MODULE_AUTHOR("Dongbin Yu <yudongbin@huawei.com>");
+MODULE_DESCRIPTION("Hisilicon HI655x PMU SSI interface driver");
+MODULE_LICENSE("GPL v2");
diff --git a/drivers/regulator/Kconfig b/drivers/regulator/Kconfig
index a6f116aa5235..b629c9ccf423 100644
--- a/drivers/regulator/Kconfig
+++ b/drivers/regulator/Kconfig
@@ -750,5 +750,18 @@ config REGULATOR_WM8994
This driver provides support for the voltage regulators on the
WM8994 CODEC.
+config REGULATOR_HI6220
+ tristate "Hisilicon Hi6220 MTCMOS"
+ depends on ARCH_HISI
+ help
+ This driver provides support for the mtcmos regulators on the
+ Hisilicon Hi6220 chip.
+
+config REGULATOR_HI655X
+ tristate "Hisilicon HI655X PMIC regulators"
+ depends on ARCH_HISI
+ help
+ This driver provides support for the voltage regulators of the
+ Hisilicon PMIC device.
endif
diff --git a/drivers/regulator/Makefile b/drivers/regulator/Makefile
index 2c4da15e1545..30b5b3d5d2c3 100644
--- a/drivers/regulator/Makefile
+++ b/drivers/regulator/Makefile
@@ -98,6 +98,7 @@ obj-$(CONFIG_REGULATOR_WM831X) += wm831x-ldo.o
obj-$(CONFIG_REGULATOR_WM8350) += wm8350-regulator.o
obj-$(CONFIG_REGULATOR_WM8400) += wm8400-regulator.o
obj-$(CONFIG_REGULATOR_WM8994) += wm8994-regulator.o
-
+obj-$(CONFIG_REGULATOR_HI6220) += hi6220-mtcmos.o
+obj-$(CONFIG_REGULATOR_HI655X) += hi655x-regulator.o
ccflags-$(CONFIG_REGULATOR_DEBUG) += -DDEBUG
diff --git a/drivers/regulator/hi6220-mtcmos.c b/drivers/regulator/hi6220-mtcmos.c
new file mode 100644
index 000000000000..883a32fb37e8
--- /dev/null
+++ b/drivers/regulator/hi6220-mtcmos.c
@@ -0,0 +1,268 @@
+/*
+ * Device driver for MTCMOS DRIVER in HI6220 SOC
+ *
+ * Copyright (c) 2011 Hisilicon Co. Ltd
+ *
+ */
+#include <linux/slab.h>
+#include <linux/device.h>
+#include <linux/module.h>
+#include <linux/err.h>
+#include <linux/io.h>
+#include <linux/platform_device.h>
+#include <linux/of.h>
+#include <linux/of_device.h>
+#include <linux/of_address.h>
+#include <linux/regmap.h>
+#include <linux/regulator/driver.h>
+#include <linux/regulator/machine.h>
+#include <linux/regulator/of_regulator.h>
+#include <linux/delay.h>
+#include <linux/time.h>
+
+enum {
+ HI6220_MTCMOS1,
+ HI6220_MTCMOS2,
+ HI6220_RG_MAX,
+};
+
+struct hi6220_mtcmos_ctrl_regs {
+ unsigned int enable_reg;
+ unsigned int disable_reg;
+ unsigned int status_reg;
+};
+
+struct hi6220_mtcmos_ctrl_data {
+ int shift;
+ unsigned int mask;
+};
+
+struct hi6220_mtcmos_info {
+ struct regulator_desc rdesc;
+ struct hi6220_mtcmos_ctrl_regs ctrl_regs;
+ struct hi6220_mtcmos_ctrl_data ctrl_data;
+};
+
+struct hi6220_mtcmos {
+ struct regulator_dev *rdev[HI6220_RG_MAX];
+ void __iomem *sc_on_regs;
+ int mtcmos_steady_time;
+ spinlock_t mtcmos_spin_lock;
+};
+
+static int hi6220_mtcmos_is_on(struct hi6220_mtcmos *mtcmos,
+ unsigned int regs, unsigned int mask, int shift)
+{
+ unsigned int ret;
+ unsigned long mtcmos_spin_flag = 0;
+
+ spin_lock_irqsave(&mtcmos->mtcmos_spin_lock, mtcmos_spin_flag);
+ ret = readl(mtcmos->sc_on_regs + regs);
+ spin_unlock_irqrestore(&mtcmos->mtcmos_spin_lock, mtcmos_spin_flag);
+
+ ret &= (mask << shift);
+ return !!ret;
+}
+
+int hi6220_mtcmos_on(struct hi6220_mtcmos *mtcmos,
+ unsigned int regs, unsigned int mask, int shift)
+{
+ unsigned long mtcmos_spin_flag = 0;
+
+ spin_lock_irqsave(&mtcmos->mtcmos_spin_lock, mtcmos_spin_flag);
+ writel(mask << shift, mtcmos->sc_on_regs + regs);
+ udelay(mtcmos->mtcmos_steady_time);
+ spin_unlock_irqrestore(&mtcmos->mtcmos_spin_lock, mtcmos_spin_flag);
+
+ return 0;
+}
+
+int hi6220_mtcmos_off(struct hi6220_mtcmos *mtcmos,
+ unsigned int regs, unsigned int mask, int shift)
+{
+ unsigned long mtcmos_spin_flag = 0;
+
+ spin_lock_irqsave(&mtcmos->mtcmos_spin_lock, mtcmos_spin_flag);
+ writel(mask << shift, mtcmos->sc_on_regs + regs);
+ udelay(mtcmos->mtcmos_steady_time);
+ spin_unlock_irqrestore(&mtcmos->mtcmos_spin_lock,
+ mtcmos_spin_flag);
+
+ return 0;
+}
+
+static int hi6220_regulator_mtcmos_is_enabled(struct regulator_dev *rdev)
+{
+ int ret;
+ struct hi6220_mtcmos_info *sreg = rdev_get_drvdata(rdev);
+ struct platform_device *pdev =
+ container_of(rdev->dev.parent, struct platform_device, dev);
+ struct hi6220_mtcmos *mtcmos = platform_get_drvdata(pdev);
+ struct hi6220_mtcmos_ctrl_regs *ctrl_regs = &(sreg->ctrl_regs);
+ struct hi6220_mtcmos_ctrl_data *ctrl_data = &(sreg->ctrl_data);
+
+ ret = hi6220_mtcmos_is_on(mtcmos, ctrl_regs->status_reg,
+ ctrl_data->mask, ctrl_data->shift);
+ return ret;
+}
+
+static int hi6220_regulator_mtcmos_enabled(struct regulator_dev *rdev)
+{
+ int ret;
+ struct hi6220_mtcmos_info *sreg = rdev_get_drvdata(rdev);
+ struct platform_device *pdev =
+ container_of(rdev->dev.parent, struct platform_device, dev);
+ struct hi6220_mtcmos *mtcmos = platform_get_drvdata(pdev);
+ struct hi6220_mtcmos_ctrl_regs *ctrl_regs = &(sreg->ctrl_regs);
+ struct hi6220_mtcmos_ctrl_data *ctrl_data = &(sreg->ctrl_data);
+
+ ret = hi6220_mtcmos_on(mtcmos, ctrl_regs->enable_reg,
+ ctrl_data->mask, ctrl_data->shift);
+ if (0 == hi6220_mtcmos_is_on(mtcmos, ctrl_regs->status_reg,
+ ctrl_data->mask, ctrl_data->shift)) {
+ return -1;
+ }
+ return ret;
+}
+
+static int hi6220_regulator_mtcmos_disabled(struct regulator_dev *rdev)
+{
+ int ret;
+ struct hi6220_mtcmos_info *sreg = rdev_get_drvdata(rdev);
+ struct platform_device *pdev =
+ container_of(rdev->dev.parent, struct platform_device, dev);
+ struct hi6220_mtcmos *mtcmos = platform_get_drvdata(pdev);
+ struct hi6220_mtcmos_ctrl_regs *ctrl_regs = &(sreg->ctrl_regs);
+ struct hi6220_mtcmos_ctrl_data *ctrl_data = &(sreg->ctrl_data);
+
+ ret = hi6220_mtcmos_off(mtcmos, ctrl_regs->disable_reg,
+ ctrl_data->mask, ctrl_data->shift);
+
+ return ret;
+}
+
+static struct regulator_ops hi6220_mtcmos_mtcmos_rops = {
+ .is_enabled = hi6220_regulator_mtcmos_is_enabled,
+ .enable = hi6220_regulator_mtcmos_enabled,
+ .disable = hi6220_regulator_mtcmos_disabled,
+};
+
+#define HI6220_MTCMOS(vreg) \
+{ \
+ .rdesc = { \
+ .name = #vreg, \
+ .ops = &hi6220_mtcmos_mtcmos_rops, \
+ .type = REGULATOR_VOLTAGE, \
+ .owner = THIS_MODULE, \
+ }, \
+}
+
+static struct hi6220_mtcmos_info hi6220_mtcmos_info[] = {
+ HI6220_MTCMOS(MTCMOS1),
+ HI6220_MTCMOS(MTCMOS2),
+};
+
+static struct of_regulator_match hi6220_mtcmos_matches[] = {
+ { .name = "mtcmos1",
+ .driver_data = &hi6220_mtcmos_info[HI6220_MTCMOS1], },
+ { .name = "mtcmos2",
+ .driver_data = &hi6220_mtcmos_info[HI6220_MTCMOS2], },
+};
+
+static int hi6220_mtcmos_probe(struct platform_device *pdev)
+{
+ int ret;
+ struct hi6220_mtcmos *mtcmos;
+ const __be32 *sc_on_regs = NULL;
+ void __iomem *regs;
+ struct device *dev;
+ struct device_node *np, *child;
+ int count, i;
+ struct regulator_config config = { };
+ struct regulator_init_data *init_data;
+ struct hi6220_mtcmos_info *sreg;
+
+ dev = &pdev->dev;
+ np = dev->of_node;
+ mtcmos = devm_kzalloc(dev,
+ sizeof(struct hi6220_mtcmos), GFP_KERNEL);
+ if (!mtcmos) {
+ dev_err(dev, "cannot allocate hi6220_mtcmos device info\n");
+ return -ENOMEM;
+ }
+
+ spin_lock_init((spinlock_t *)&mtcmos->mtcmos_spin_lock);
+ sc_on_regs = of_get_property(np, "hisilicon,mtcmos-sc-on-base", NULL);
+ if (sc_on_regs) {
+ regs = ioremap(be32_to_cpu(*sc_on_regs), 0x1000);
+ mtcmos->sc_on_regs = regs;
+ }
+ ret = of_property_read_u32(np, "hisilicon,mtcmos-steady-us",
+ &mtcmos->mtcmos_steady_time);
+
+ count = of_regulator_match(&pdev->dev, np,
+ hi6220_mtcmos_matches,
+ ARRAY_SIZE(hi6220_mtcmos_matches));
+
+ for (i = 0; i < HI6220_RG_MAX; i++) {
+ init_data = hi6220_mtcmos_matches[i].init_data;
+ if (!init_data)
+ continue;
+ sreg = hi6220_mtcmos_matches[i].driver_data;
+ config.dev = &pdev->dev;
+ config.init_data = init_data;
+ config.driver_data = sreg;
+ config.of_node = hi6220_mtcmos_matches[i].of_node;
+ child = config.of_node;
+
+ ret = of_property_read_u32_array(child, "hisilicon,ctrl-regs",
+ (unsigned int *)(&sreg->ctrl_regs), 0x3);
+ ret = of_property_read_u32_array(child, "hisilicon,ctrl-data",
+ (unsigned int *)(&sreg->ctrl_data), 0x2);
+
+ mtcmos->rdev[i] = regulator_register(&sreg->rdesc, &config);
+ if (IS_ERR(mtcmos->rdev[i])) {
+ ret = PTR_ERR(mtcmos->rdev[i]);
+ dev_err(&pdev->dev, "failed to register mtcmos %s\n",
+ sreg->rdesc.name);
+ while (--i >= 0)
+ regulator_unregister(mtcmos->rdev[i]);
+
+ return ret;
+ }
+ }
+
+ platform_set_drvdata(pdev, mtcmos);
+ return 0;
+}
+
+static struct of_device_id of_hi6220_mtcmos_match_tbl[] = {
+ { .compatible = "hisilicon,hi6220-mtcmos-driver", },
+ {}
+};
+
+static struct platform_driver mtcmos_driver = {
+ .driver = {
+ .name = "hisi_hi6220_mtcmos",
+ .owner = THIS_MODULE,
+ .of_match_table = of_hi6220_mtcmos_match_tbl,
+ },
+ .probe = hi6220_mtcmos_probe,
+};
+
+static int __init hi6220_mtcmos_init(void)
+{
+ return platform_driver_register(&mtcmos_driver);
+}
+
+static void __exit hi6220_mtcmos_exit(void)
+{
+ platform_driver_unregister(&mtcmos_driver);
+}
+
+fs_initcall(hi6220_mtcmos_init);
+module_exit(hi6220_mtcmos_exit);
+
+MODULE_AUTHOR("Baixing Quan<quanbaixing@huawei.com>");
+MODULE_DESCRIPTION("HI6220 MTCMOS interface driver");
+MODULE_LICENSE("GPL V2");
diff --git a/drivers/regulator/hi655x-regulator.c b/drivers/regulator/hi655x-regulator.c
new file mode 100644
index 000000000000..6424a2e92342
--- /dev/null
+++ b/drivers/regulator/hi655x-regulator.c
@@ -0,0 +1,515 @@
+/*
+ * Hisilicon HI655X PMIC regulator driver
+ *
+ * Copyright (c) 2015 Hisilicon Co. Ltd.
+ *
+ * Author:
+ * Dongbin Yu <yudongbin@huawei.com>
+ * Bintian Wang <bintian.wang@huawei.com>
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License as published by the
+ * Free Software Foundation; either version 2 of the License, or (at your
+ * option) any later version.
+ *
+ */
+
+#include <linux/slab.h>
+#include <linux/device.h>
+#include <linux/module.h>
+#include <linux/err.h>
+#include <linux/io.h>
+#include <linux/platform_device.h>
+#include <linux/of.h>
+#include <linux/of_device.h>
+#include <linux/of_address.h>
+#include <linux/regmap.h>
+#include <linux/regulator/driver.h>
+#include <linux/regulator/machine.h>
+#include <linux/regulator/of_regulator.h>
+#include <linux/delay.h>
+#include <linux/time.h>
+#include <linux/regulator/hi655x-regulator.h>
+#include <linux/mfd/hi655x-pmic.h>
+
+#define FORMAT_SSI_PMUREG(base, reg) (*(volatile unsigned int *)((char *)base + (reg)))
+#define BSP_REG_SETBITS(base, reg, pos, bits, val) \
+ ((FORMAT_SSI_PMUREG(base, reg) = (FORMAT_SSI_PMUREG(base, reg) \
+ & (~((((unsigned int)1 << (bits)) - 1) << (pos)))) \
+ | ((unsigned int)((val) & (((unsigned int)1 << (bits)) - 1)) << (pos))))
+
+#define BSP_REG_GETBITS(base, reg, pos, bits) \
+ (((FORMAT_SSI_PMUREG(base, reg) >> (pos)) \
+ &(((unsigned int)1 << (bits)) - 1)))
+
+struct hi655x_regulator {
+ int status; /* this property in child node */
+ unsigned int off_on_delay; /* this property in parent node */
+ enum hi655x_regulator_type type; /* this property in child node */
+ int regulator_id;
+
+ /* this property must be unify which is in child node */
+ struct hi655x_regulator_ctrl_regs ctrl_regs;
+ struct hi655x_regulator_ctrl_data ctrl_data;
+
+ struct hi655x_regulator_vset_regs vset_regs;
+ struct hi655x_regulator_vset_data vset_data;
+ unsigned int vol_numb;
+ unsigned int *vset_table;
+ struct regulator_desc rdesc;
+ int (*dt_parse)(struct hi655x_regulator*, struct platform_device*);
+};
+
+static int hi655x_regulator_pmic_is_enabled(struct regulator_dev *rdev)
+{
+ int ret = 0;
+ unsigned char value_u8 = 0;
+
+ struct hi655x_regulator *sreg = rdev_get_drvdata(rdev);
+ struct hi655x_regulator_ctrl_regs *ctrl_regs = &(sreg->ctrl_regs);
+ struct hi655x_regulator_ctrl_data *ctrl_data = &(sreg->ctrl_data);
+
+ /*
+ * regulator is all set,but the pmu is only subset.
+ * maybe this "buck"/"ldo"/"lvs" is not contrl by a core.
+ * and in regulator have a "status" member ("okey" or "disable").
+ */
+ value_u8 = hi655x_pmic_reg_read(ctrl_regs->status_reg);
+ ret = ((int)BSP_REG_GETBITS(&value_u8, 0, ctrl_data->shift, ctrl_data->mask) & 0xff);
+
+ return ret;
+}
+
+static int hi655x_regulator_pmic_enable(struct regulator_dev *rdev)
+{
+ int ret = 0;
+ unsigned char value_u8 = 0;
+ unsigned int value_u32 = 0;
+ struct hi655x_regulator *sreg = rdev_get_drvdata(rdev);
+ struct hi655x_regulator_ctrl_regs *ctrl_regs = &(sreg->ctrl_regs);
+ struct hi655x_regulator_ctrl_data *ctrl_data = &(sreg->ctrl_data);
+
+ BSP_REG_SETBITS(&value_u32, 0, ctrl_data->shift, ctrl_data->mask, 0x1);
+ value_u8 = (unsigned char)value_u32;
+ hi655x_pmic_reg_write(ctrl_regs->enable_reg, value_u8);
+ udelay(sreg->off_on_delay);
+
+ return ret;
+}
+
+static int hi655x_regulator_pmic_disable(struct regulator_dev *rdev)
+{
+ int ret = 0;
+ int flag = 1;
+ unsigned char value_u8 = 0;
+ unsigned int value_u32 = 0;
+
+ struct hi655x_regulator *sreg = rdev_get_drvdata(rdev);
+ struct hi655x_regulator_ctrl_regs *ctrl_regs = &(sreg->ctrl_regs);
+ struct hi655x_regulator_ctrl_data *ctrl_data = &(sreg->ctrl_data);
+
+ /*
+ * regulator is all set,but the pmu is only subset.
+ * maybe this "buck"/"ldo"/"lvs" is not contrl by a core.
+ * and in regulator have a "status" member (okey or disable).
+ * maybe we can del some regulator which is not contrl by core.
+ */
+ if (sreg->type == PMIC_BOOST_TYPE)
+ flag = 0;
+
+ BSP_REG_SETBITS(&value_u32, 0, ctrl_data->shift, ctrl_data->mask, flag);
+ value_u8 = (unsigned char)value_u32;
+ hi655x_pmic_reg_write(ctrl_regs->disable_reg, value_u8);
+
+ return ret;
+}
+
+static int hi655x_regulator_pmic_list_voltage_linear(struct regulator_dev *rdev,
+ unsigned int selector)
+{
+ struct hi655x_regulator *sreg = rdev_get_drvdata(rdev);
+ /*
+ * regulator is all set,but the pmu is only subset.
+ * maybe this "buck"/"ldo"/"lvs" is not contrl by a core.
+ * and in regulator have a "status" member (okey or disable).
+ * maybe we can del some regulator which is not contrl by core.
+ * we will return min_uV
+ */
+ if (sreg->type == PMIC_LVS_TYPE)
+ return 900000;
+
+ if (selector >= sreg->vol_numb) {
+ printk("selector err %s %d \n", __func__, __LINE__);
+ return -1;
+ }
+
+ return sreg->vset_table[selector];
+}
+
+static int hi655x_regulator_pmic_get_voltage(struct regulator_dev *rdev)
+{
+ int index = 0;
+ unsigned int value_u32 = 0;
+ struct hi655x_regulator *sreg = rdev_get_drvdata(rdev);
+ struct hi655x_regulator_vset_regs *vset_regs = &(sreg->vset_regs);
+ struct hi655x_regulator_vset_data *vset_data = &(sreg->vset_data);
+
+ if (sreg->type == PMIC_LVS_TYPE)
+ return 900000;
+
+ value_u32 = (unsigned int)hi655x_pmic_reg_read(vset_regs->vset_reg) & 0xff;
+ index = ((unsigned int)BSP_REG_GETBITS(&value_u32, 0, vset_data->shift, vset_data->mask) & 0xff);
+
+ return sreg->vset_table[index];
+}
+
+static int hi655x_regulator_pmic_set_voltage(struct regulator_dev *rdev,
+ int min_uV, int max_uV, unsigned *selector)
+{
+ int i = 0;
+ int ret = 0;
+ int vol = 0;
+ unsigned char value_u8 = 0;
+ unsigned int value_u32 = 0;
+
+ struct hi655x_regulator *sreg = rdev_get_drvdata(rdev);
+ struct hi655x_regulator_vset_regs *vset_regs = &(sreg->vset_regs);
+ struct hi655x_regulator_vset_data *vset_data = &(sreg->vset_data);
+
+ if (sreg->type == PMIC_LVS_TYPE)
+ return 0;
+ /*
+ * search the matched vol and get its index
+ */
+ for (i = 0; i < sreg->vol_numb; i++) {
+ vol = sreg->vset_table[i];
+
+ if ((vol >= min_uV) && (vol <= max_uV))
+ break;
+ }
+
+ if (i == sreg->vol_numb)
+ return -1;
+
+ value_u32 = (unsigned int)hi655x_pmic_reg_read(vset_regs->vset_reg) & 0xff;
+ BSP_REG_SETBITS(&value_u32, 0, vset_data->shift, vset_data->mask, i);
+ value_u8 = (unsigned char)value_u32;
+ hi655x_pmic_reg_write(vset_regs->vset_reg, value_u8);
+
+ *selector = i;
+
+ return ret;
+}
+
+static unsigned int hi655x_regulator_pmic_get_mode(struct regulator_dev *rdev)
+{
+ return REGULATOR_MODE_NORMAL;
+}
+
+static int hi655x_regulator_pmic_set_mode(struct regulator_dev *rdev,
+ unsigned int mode)
+{
+ return 0;
+}
+
+static unsigned int hi655x_regulator_pmic_get_optimum_mode(struct regulator_dev *rdev,
+ int input_uV, int output_uV, int load_uA)
+{
+ return REGULATOR_MODE_NORMAL;
+}
+
+static int hi655x_set_current_limit(struct regulator_dev *rdev,
+ int min_uA, int max_uA)
+{
+ return 0;
+}
+
+static int hi655x_get_current_limit(struct regulator_dev *rdev)
+{
+ return 0;
+}
+
+static struct regulator_ops hi655x_regulator_pmic_rops = {
+ .is_enabled = hi655x_regulator_pmic_is_enabled,
+ .enable = hi655x_regulator_pmic_enable,
+ .disable = hi655x_regulator_pmic_disable,
+ .list_voltage = hi655x_regulator_pmic_list_voltage_linear,
+ .get_voltage = hi655x_regulator_pmic_get_voltage,
+ .set_voltage = hi655x_regulator_pmic_set_voltage,
+ .get_mode = hi655x_regulator_pmic_get_mode,
+ .set_mode = hi655x_regulator_pmic_set_mode,
+ .get_optimum_mode = hi655x_regulator_pmic_get_optimum_mode,
+ .set_current_limit = hi655x_set_current_limit,
+ .get_current_limit = hi655x_get_current_limit,
+};
+
+static int hi655x_regualtor_dt_parse_common(struct hi655x_regulator *sreg,
+ struct platform_device *pdev)
+{
+ return 0;
+}
+
+static int hi655x_regualtor_pmic_dt_parse(struct hi655x_regulator *sreg,
+ struct platform_device *pdev)
+{
+ int ret;
+ ret = hi655x_regualtor_dt_parse_common(sreg, pdev);
+
+ return ret;
+}
+
+static const struct hi655x_regulator hi655x_regulator_pmic = {
+ .rdesc = {
+ .ops = &hi655x_regulator_pmic_rops,
+ .type = REGULATOR_VOLTAGE,
+ .owner = THIS_MODULE,
+ },
+ .dt_parse = hi655x_regualtor_pmic_dt_parse,
+};
+
+static struct of_device_id of_hi655x_regulator_match_tbl[] = {
+ {
+ .compatible = "hisilicon,hi6552-regulator-pmic",
+ .data = &hi655x_regulator_pmic,
+ },
+ { /* end */ }
+};
+
+static struct regulator_init_data *fake_of_get_regulator_init_data(struct device *dev,
+ struct device_node *np)
+{
+ struct regulator_init_data *init_data = NULL;
+ const __be32 *num_consumer_supplies = NULL;
+ struct regulator_consumer_supply *consumer_supplies = NULL;
+ int consumer_id = 0;
+
+ init_data = devm_kzalloc(dev, sizeof(*init_data), GFP_KERNEL);
+ if (!init_data)
+ return NULL;
+
+ init_data->supply_regulator = of_get_property(np, "hisilicon,regulator-supply", NULL);
+
+ num_consumer_supplies = of_get_property(np, "hisilicon,num_consumer_supplies", NULL);
+ if ((NULL == num_consumer_supplies) || (0 == *num_consumer_supplies)) {
+ dev_warn(dev, "%s no consumer_supplies \n", __func__);
+ return init_data;
+ }
+
+ init_data->num_consumer_supplies = be32_to_cpu(*num_consumer_supplies);
+ init_data->consumer_supplies = (struct regulator_consumer_supply *)devm_kzalloc(dev,
+ init_data->num_consumer_supplies * sizeof(struct regulator_consumer_supply), GFP_KERNEL);
+ if (NULL == init_data->consumer_supplies) {
+ dev_err(dev, "%s devm_kzalloc consumer_supplies err\n", __func__);
+ return NULL;
+ }
+
+ consumer_supplies = init_data->consumer_supplies ;
+
+ for (consumer_id = 0; consumer_id < init_data->num_consumer_supplies;
+ consumer_id++, consumer_supplies++) {
+ int ret = of_property_read_string_index(np, "hisilicon,consumer-supplies", consumer_id, &consumer_supplies->supply);
+ if (ret)
+ dev_err(dev, "\n %s of_property_read_string_index consumer-supplies err\n", np->name);
+ }
+
+ return init_data;
+}
+
+static int fake_of_get_regulator_constraint(struct regulation_constraints *constraints,
+ struct device_node *np)
+{
+ const __be32 *min_uV, *max_uV;
+ unsigned int *valid_modes_mask;
+ unsigned int *valid_ops_mask;
+ unsigned int *initial_mode;
+
+ if (!np)
+ return -1;
+
+ if (!constraints)
+ return -1;
+
+ constraints->name = of_get_property(np, "regulator-name", NULL);
+
+ min_uV = of_get_property(np, "regulator-min-microvolt", NULL);
+ if (min_uV) {
+ (constraints)->min_uV = be32_to_cpu(*min_uV);
+ (constraints)->min_uA = be32_to_cpu(*min_uV);
+ }
+
+ max_uV = of_get_property(np, "regulator-max-microvolt", NULL);
+ if (max_uV) {
+ constraints->max_uV = be32_to_cpu(*max_uV);
+ constraints->max_uA = be32_to_cpu(*max_uV);
+ }
+
+ valid_modes_mask = (unsigned int *)of_get_property(np, "hisilicon,valid-modes-mask", NULL);
+ if (valid_modes_mask)
+ constraints->valid_modes_mask = be32_to_cpu(*valid_modes_mask);
+
+ valid_ops_mask = (unsigned int *)of_get_property(np, "hisilicon,valid-ops-mask", NULL);
+ if (valid_ops_mask)
+ constraints->valid_ops_mask = be32_to_cpu(*valid_ops_mask);
+
+ initial_mode = (unsigned int *)of_get_property(np, "hisilicon,initial-mode", NULL);
+ if (initial_mode)
+ constraints->initial_mode = be32_to_cpu(*initial_mode);
+
+ constraints->always_on = !!(of_find_property(np, "regulator-always-on", NULL));
+
+ constraints->boot_on = !!(of_find_property(np, "regulator-boot-on", NULL));
+
+ return 0;
+}
+
+static int fake_of_get_regulator_sreg(struct hi655x_regulator *sreg, struct device *dev,
+ struct device_node *np)
+{
+ int *vol_numb;
+ unsigned int *off_on_delay;
+ enum hi655x_regulator_type *regulator_type;
+ const char *status = NULL;
+ unsigned int *vset_table = NULL;
+ int *regulator_id;
+
+ status = of_get_property(np, "hisilicon,regulator-status", NULL);
+ if (status)
+ sreg->status = !(strcmp(status, "okey"));
+
+ regulator_type = (enum hi655x_regulator_type *)of_get_property(np, "hisilicon,regulator-type", NULL);
+ if (regulator_type)
+ sreg->type = be32_to_cpu(*regulator_type);
+
+ off_on_delay = (unsigned int *)of_get_property(np, "hisilicon,off-on-delay", NULL);
+ if (off_on_delay)
+ sreg->off_on_delay = be32_to_cpu(*off_on_delay);
+
+ of_property_read_u32_array(np, "hisilicon,ctrl-regs", (unsigned int *)(&sreg->ctrl_regs), 0x3);
+
+ of_property_read_u32_array(np, "hisilicon,ctrl-data", (unsigned int *)(&sreg->ctrl_data), 0x2);
+
+ of_property_read_u32_array(np, "hisilicon,vset-regs", (unsigned int *)(&sreg->vset_regs), 0x1);
+
+ of_property_read_u32_array(np, "hisilicon,vset-data", (unsigned int *)(&sreg->vset_data), 0x2);
+
+ vol_numb = (int *)of_get_property(np, "hisilicon,regulator-n-vol", NULL);
+ if (vol_numb)
+ sreg->vol_numb = be32_to_cpu(*vol_numb);
+
+ regulator_id = (int *)of_get_property(np, "hisilicon,hisi-scharger-regulator-id", NULL);
+ if (regulator_id)
+ sreg->regulator_id = be32_to_cpu(*regulator_id);
+
+ vset_table = devm_kzalloc(dev, sreg->vol_numb * sizeof(int), GFP_KERNEL);
+ if (!vset_table)
+ return -1;
+
+ of_property_read_u32_array(np, "hisilicon,vset-table", (unsigned int *)vset_table, sreg->vol_numb);
+ sreg->vset_table = vset_table;
+
+ return 0;
+}
+
+static int hi655x_regulator_probe(struct platform_device *pdev)
+{
+ int ret = 0;
+ struct device *dev = &pdev->dev;
+ struct device_node *np = dev->of_node;
+ struct regulator_dev *rdev = NULL;
+ struct regulator_desc *rdesc = NULL;
+ struct hi655x_regulator *sreg = NULL;
+ struct regulator_init_data *initdata = NULL;
+ const struct of_device_id *match = NULL;
+ const struct hi655x_regulator *template = NULL;
+ struct regulator_config config = { };
+
+ /* to check which type of regulator this is */
+ match = of_match_device(of_hi655x_regulator_match_tbl, &pdev->dev);
+
+ if (NULL == match) {
+ dev_err(dev, "of match hi655x regulator fail!\n\r");
+ return -EINVAL;
+ }
+
+ /*tempdev is regulator device*/
+ template = match->data;
+
+ /*just for getting "std regulator node" value-key about constraint*/
+ initdata = fake_of_get_regulator_init_data(dev, np);
+ if (!initdata) {
+ dev_err(dev, "get regulator init data error !\n");
+ return -EINVAL;
+ }
+
+ ret = fake_of_get_regulator_constraint(&initdata->constraints, np);
+ if (!!ret) {
+ dev_err(dev, "get regulator constraint error !\n");
+ return -EINVAL;
+ }
+
+ /* TODO:hi655x regulator supports two modes */
+ sreg = kmemdup(template, sizeof(*sreg), GFP_KERNEL);
+ if (!sreg)
+ return -ENOMEM;
+
+ if (0 != fake_of_get_regulator_sreg(sreg, dev, np)) {
+ kfree(sreg);
+ return -EINVAL;
+ }
+
+ rdesc = &sreg->rdesc;
+ rdesc->n_voltages = sreg->vol_numb;
+ rdesc->name = initdata->constraints.name;
+ rdesc->id = sreg->regulator_id;
+ rdesc->min_uV = initdata->constraints.min_uV;
+
+ /* to parse device tree data for regulator specific */
+ config.dev = &pdev->dev;
+ config.init_data = initdata;
+ config.driver_data = sreg;
+ config.of_node = pdev->dev.of_node;
+
+ /* register regulator */
+ rdev = regulator_register(rdesc, &config);
+ if (IS_ERR(rdev)) {
+ dev_err(dev, "regulator failed to register %s\n", rdesc->name);
+ ret = PTR_ERR(rdev);
+ return -EINVAL;
+ }
+
+ platform_set_drvdata(pdev, rdev);
+
+ return ret;
+}
+
+static int hi655x_regulator_remove(struct platform_device *pdev)
+{
+ return 0;
+}
+
+static struct platform_driver hi655x_regulator_driver = {
+ .driver = {
+ .name = "hi655x_regulator",
+ .owner = THIS_MODULE,
+ .of_match_table = of_hi655x_regulator_match_tbl,
+ },
+ .probe = hi655x_regulator_probe,
+ .remove = hi655x_regulator_remove,
+};
+
+static int __init hi655x_regulator_init(void)
+{
+ return platform_driver_register(&hi655x_regulator_driver);
+}
+
+static void __exit hi655x_regulator_exit(void)
+{
+ platform_driver_unregister(&hi655x_regulator_driver);
+}
+
+fs_initcall(hi655x_regulator_init);
+module_exit(hi655x_regulator_exit);
+
+MODULE_AUTHOR("Dongbin Yu <yudongbin@huawei.com>");
+MODULE_DESCRIPTION("Hisilicon HI655X PMIC regulator driver");
+MODULE_LICENSE("GPL v2");
diff --git a/include/linux/mfd/hi6552_pmic.h b/include/linux/mfd/hi6552_pmic.h
new file mode 100644
index 000000000000..91f75dd21003
--- /dev/null
+++ b/include/linux/mfd/hi6552_pmic.h
@@ -0,0 +1,49 @@
+/*
+ * Copyright (C) 2015 Hisilicon Co. Ltd.
+ *
+ *
+ * This software is licensed under the terms of the GNU General Public
+ * License version 2, as published by the Free Software Foundation, and
+ * may be copied, distributed, and modified under those terms.
+ *
+ * This program is distributed in the hope that 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 __PMUSSI_DRV_H
+#define __PMUSSI_DRV_H
+
+#define HI6552_BITS (8)
+
+/*numb of sub-interrupt*/
+#define HI6552_NR_IRQ (32)
+
+#define HI6552_IRQ_STAT_BASE (0x003)
+#define HI6552_IRQ_MASK_BASE (0x007)
+#define HI6552_IRQ_ARRAY (4)
+#define HI6552_IRQ_MASK (0xFF)
+#define HI6552_IRQ_CLR (0xFF)
+
+#define HI6552_VER_REG (0x000)
+#define HI6552_REG_WIDTH (0xFF)
+
+#define PMU_VER_START 0x10
+#define PMU_VER_END 0x38
+
+#define SSI_DEVICE_OK 1
+#define SSI_DEVICE_ERR 0
+
+#define PMUSSI_REG_EX(pmu_base, reg_addr) (((reg_addr) << 2) + (char *)pmu_base)
+
+unsigned char hi6552_pmic_reg_read(unsigned int addr);
+void hi6552_pmic_reg_write(unsigned int addr, unsigned char val);
+unsigned char hi6552_pmic_reg_read_ex(void *pmu_base, unsigned int addr);
+void hi6552_pmic_reg_write_ex (void *pmu_base, unsigned int addr, unsigned char val);
+int *hi6552_pmic_get_buck_vol_table(int id);
+unsigned int hi6552_pmic_get_version(void);
+int hi6552_pmic_device_stat_notify(char *dev_name, int dev_stat);
+
+#endif
diff --git a/include/linux/mfd/hi655x-pmic.h b/include/linux/mfd/hi655x-pmic.h
new file mode 100644
index 000000000000..bd66f7f74727
--- /dev/null
+++ b/include/linux/mfd/hi655x-pmic.h
@@ -0,0 +1,49 @@
+/*
+ * Copyright (C) 2015 Hisilicon Co. Ltd.
+ *
+ *
+ * This software is licensed under the terms of the GNU General Public
+ * License version 2, as published by the Free Software Foundation, and
+ * may be copied, distributed, and modified under those terms.
+ *
+ * This program is distributed in the hope that 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 __PMUSSI_DRV_H
+#define __PMUSSI_DRV_H
+
+#define HI655x_BITS (8)
+
+/*numb of sub-interrupt*/
+#define HI655x_NR_IRQ (32)
+
+#define HI655x_IRQ_STAT_BASE (0x003)
+#define HI655x_IRQ_MASK_BASE (0x007)
+#define HI655x_IRQ_ARRAY (4)
+#define HI655x_IRQ_MASK (0xFF)
+#define HI655x_IRQ_CLR (0xFF)
+
+#define HI655x_VER_REG (0x000)
+#define HI655x_REG_WIDTH (0xFF)
+
+#define PMU_VER_START 0x10
+#define PMU_VER_END 0x38
+
+#define SSI_DEVICE_OK 1
+#define SSI_DEVICE_ERR 0
+
+#define PMUSSI_REG_EX(pmu_base, reg_addr) (((reg_addr) << 2) + (char *)pmu_base)
+
+unsigned char hi655x_pmic_reg_read(unsigned int addr);
+void hi655x_pmic_reg_write(unsigned int addr, unsigned char val);
+unsigned char hi655x_pmic_reg_read_ex(void *pmu_base, unsigned int addr);
+void hi655x_pmic_reg_write_ex (void *pmu_base, unsigned int addr, unsigned char val);
+int *hi655x_pmic_get_buck_vol_table(int id);
+unsigned int hi655x_pmic_get_version(void);
+int hi655x_pmic_device_stat_notify(char *dev_name, int dev_stat);
+
+#endif
diff --git a/include/linux/regulator/hi655x-regulator.h b/include/linux/regulator/hi655x-regulator.h
new file mode 100644
index 000000000000..3398d7efab6d
--- /dev/null
+++ b/include/linux/regulator/hi655x-regulator.h
@@ -0,0 +1,39 @@
+/*
+ * Copyright (c) 2015 Hisilicon Co. Ltd.
+ *
+ */
+
+#ifndef __HISI_HI655X_REGULATOR_H__
+#define __HISI_HI655X_REGULATOR_H__
+
+enum hi655x_regulator_type {
+ PMIC_BUCK_TYPE = 0,
+ PMIC_LDO_TYPE = 1,
+ PMIC_LVS_TYPE = 2,
+ PMIC_BOOST_TYPE = 3,
+ MTCMOS_SC_ON_TYPE = 4,
+ MTCMOS_ACPU_ON_TYPE = 5,
+ SCHARGE_TYPE = 6,
+};
+
+struct hi655x_regulator_ctrl_regs {
+ unsigned int enable_reg;
+ unsigned int disable_reg;
+ unsigned int status_reg;
+};
+
+struct hi655x_regulator_vset_regs {
+ unsigned int vset_reg;
+};
+
+struct hi655x_regulator_ctrl_data {
+ int shift;
+ unsigned int mask;
+};
+
+struct hi655x_regulator_vset_data {
+ int shift;
+ unsigned int mask;
+};
+
+#endif