[PATCH resend v4] i2c: hibvt: add Hisilicon BVT I2C controller driver

2016-10-21 Thread Pan Wen
add Hisilicon BVT I2C controller driver support.

Signed-off-by: Pan Wen <wen...@hisilicon.com>
Acked-by: Rob Herring <r...@kernel.org>
---
change log
v4:
Modify the default frequency to 100KHz.
v3:
Add a SoC specific compatible string.
v2:
1)Fixed a compile error.
2)Dropped the clock-names property.
 .../devicetree/bindings/i2c/i2c-hibvt.txt  |  24 +
 drivers/i2c/busses/Kconfig |  10 +
 drivers/i2c/busses/Makefile|   1 +
 drivers/i2c/busses/i2c-hibvt.c | 737 +
 4 files changed, 772 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/i2c/i2c-hibvt.txt
 create mode 100644 drivers/i2c/busses/i2c-hibvt.c

diff --git a/Documentation/devicetree/bindings/i2c/i2c-hibvt.txt 
b/Documentation/devicetree/bindings/i2c/i2c-hibvt.txt
new file mode 100644
index 000..db3d2e2
--- /dev/null
+++ b/Documentation/devicetree/bindings/i2c/i2c-hibvt.txt
@@ -0,0 +1,24 @@
+Hisilicon BVT I2C master controller
+
+Required properties:
+- compatible: should be "hisilicon,hibvt-i2c" and one of the following:
+   "hisilicon,hi3516cv300-i2c"
+- reg: physical base address of the controller and length of memory mapped.
+ region.
+- interrupts: interrupt number to the cpu.
+- clocks: phandles to input clocks.
+
+Optional properties:
+- clock-frequency: Desired I2C bus frequency in Hz, otherwise defaults to 
10.
+
+Other properties:
+see Documentation/devicetree/bindings/i2c/i2c.txt.
+
+Examples:
+i2c_bus0: i2c@1211 {
+   compatible = "hisilicon,hi3516cv300-i2c", "hisilicon,hibvt-i2c";
+   reg = <0x1211 0x100>;
+   interrupts = <20>;
+   clocks = <_ctrl HI3516CV300_APB_CLK>;
+   clock-frequency = <10>;
+};
diff --git a/drivers/i2c/busses/Kconfig b/drivers/i2c/busses/Kconfig
index 5c3993b..fc1b679 100644
--- a/drivers/i2c/busses/Kconfig
+++ b/drivers/i2c/busses/Kconfig
@@ -555,6 +555,16 @@ config I2C_GPIO
  This is a very simple bitbanging I2C driver utilizing the
  arch-neutral GPIO API to control the SCL and SDA lines.
 
+config I2C_HIBVT
+   tristate "Hisilicon BVT I2C Controller"
+   depends on ARCH_HISI
+   help
+ Say Y here to include support for Hisilicon BVT I2C controller in the
+ Hisilicon BVT SoCs.
+
+ This driver can also be built as a module.  If so, the module
+ will be called i2c-hibvt.
+
 config I2C_HIGHLANDER
tristate "Highlander FPGA SMBus interface"
depends on SH_HIGHLANDER
diff --git a/drivers/i2c/busses/Makefile b/drivers/i2c/busses/Makefile
index 37f2819..42ef2e0 100644
--- a/drivers/i2c/busses/Makefile
+++ b/drivers/i2c/busses/Makefile
@@ -51,6 +51,7 @@ obj-$(CONFIG_I2C_EG20T)   += i2c-eg20t.o
 obj-$(CONFIG_I2C_EMEV2)+= i2c-emev2.o
 obj-$(CONFIG_I2C_EXYNOS5)  += i2c-exynos5.o
 obj-$(CONFIG_I2C_GPIO) += i2c-gpio.o
+obj-$(CONFIG_I2C_HIBVT)+= i2c-hibvt.o
 obj-$(CONFIG_I2C_HIGHLANDER)   += i2c-highlander.o
 obj-$(CONFIG_I2C_HIX5HD2)  += i2c-hix5hd2.o
 obj-$(CONFIG_I2C_IBM_IIC)  += i2c-ibm_iic.o
diff --git a/drivers/i2c/busses/i2c-hibvt.c b/drivers/i2c/busses/i2c-hibvt.c
new file mode 100644
index 000..e8af63e
--- /dev/null
+++ b/drivers/i2c/busses/i2c-hibvt.c
@@ -0,0 +1,737 @@
+/*
+ * Hisilicon BVT I2C Controller Driver
+ *
+ * Copyright (c) 2016 HiSilicon Technologies Co., Ltd.
+ *
+ * Authors: wen...@hisilicon.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.
+ *
+ * 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.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+/*
+ * I2C Registers offsets
+ */
+#define HIBVT_I2C_GLB  0x0
+#define HIBVT_I2C_SCL_H0x4
+#define HIBVT_I2C_SCL_L0x8
+#define HIBVT_I2C_DATA10x10
+#define HIBVT_I2C_TXF  0x20
+#define HIBVT_I2C_RXF  0x24
+#define HIBVT_I2C_CMD_BASE 0x30
+#define HIBVT_I2C_LOOP10xb0
+#define HIBVT_I2C_DST1 0xb4
+#define HIBVT_I2C_TX_WATER 0xc8
+#define HIBVT_I2C_RX_WATER 0xcc
+#define HIBVT_I2C_CTRL10xd0
+#define HIBVT_I2C_STAT 0xd8
+#define HIBVT_I2C_INTR_RAW 0xe0
+#define HIBVT_I2C_INTR_EN  0xe4
+#define HIBVT_I2C_INTR_STAT0xe8
+
+/

[PATCH resend v4] i2c: hibvt: add Hisilicon BVT I2C controller driver

2016-10-21 Thread Pan Wen
add Hisilicon BVT I2C controller driver support.

Signed-off-by: Pan Wen 
Acked-by: Rob Herring 
---
change log
v4:
Modify the default frequency to 100KHz.
v3:
Add a SoC specific compatible string.
v2:
1)Fixed a compile error.
2)Dropped the clock-names property.
 .../devicetree/bindings/i2c/i2c-hibvt.txt  |  24 +
 drivers/i2c/busses/Kconfig |  10 +
 drivers/i2c/busses/Makefile|   1 +
 drivers/i2c/busses/i2c-hibvt.c | 737 +
 4 files changed, 772 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/i2c/i2c-hibvt.txt
 create mode 100644 drivers/i2c/busses/i2c-hibvt.c

diff --git a/Documentation/devicetree/bindings/i2c/i2c-hibvt.txt 
b/Documentation/devicetree/bindings/i2c/i2c-hibvt.txt
new file mode 100644
index 000..db3d2e2
--- /dev/null
+++ b/Documentation/devicetree/bindings/i2c/i2c-hibvt.txt
@@ -0,0 +1,24 @@
+Hisilicon BVT I2C master controller
+
+Required properties:
+- compatible: should be "hisilicon,hibvt-i2c" and one of the following:
+   "hisilicon,hi3516cv300-i2c"
+- reg: physical base address of the controller and length of memory mapped.
+ region.
+- interrupts: interrupt number to the cpu.
+- clocks: phandles to input clocks.
+
+Optional properties:
+- clock-frequency: Desired I2C bus frequency in Hz, otherwise defaults to 
10.
+
+Other properties:
+see Documentation/devicetree/bindings/i2c/i2c.txt.
+
+Examples:
+i2c_bus0: i2c@1211 {
+   compatible = "hisilicon,hi3516cv300-i2c", "hisilicon,hibvt-i2c";
+   reg = <0x1211 0x100>;
+   interrupts = <20>;
+   clocks = <_ctrl HI3516CV300_APB_CLK>;
+   clock-frequency = <10>;
+};
diff --git a/drivers/i2c/busses/Kconfig b/drivers/i2c/busses/Kconfig
index 5c3993b..fc1b679 100644
--- a/drivers/i2c/busses/Kconfig
+++ b/drivers/i2c/busses/Kconfig
@@ -555,6 +555,16 @@ config I2C_GPIO
  This is a very simple bitbanging I2C driver utilizing the
  arch-neutral GPIO API to control the SCL and SDA lines.
 
+config I2C_HIBVT
+   tristate "Hisilicon BVT I2C Controller"
+   depends on ARCH_HISI
+   help
+ Say Y here to include support for Hisilicon BVT I2C controller in the
+ Hisilicon BVT SoCs.
+
+ This driver can also be built as a module.  If so, the module
+ will be called i2c-hibvt.
+
 config I2C_HIGHLANDER
tristate "Highlander FPGA SMBus interface"
depends on SH_HIGHLANDER
diff --git a/drivers/i2c/busses/Makefile b/drivers/i2c/busses/Makefile
index 37f2819..42ef2e0 100644
--- a/drivers/i2c/busses/Makefile
+++ b/drivers/i2c/busses/Makefile
@@ -51,6 +51,7 @@ obj-$(CONFIG_I2C_EG20T)   += i2c-eg20t.o
 obj-$(CONFIG_I2C_EMEV2)+= i2c-emev2.o
 obj-$(CONFIG_I2C_EXYNOS5)  += i2c-exynos5.o
 obj-$(CONFIG_I2C_GPIO) += i2c-gpio.o
+obj-$(CONFIG_I2C_HIBVT)+= i2c-hibvt.o
 obj-$(CONFIG_I2C_HIGHLANDER)   += i2c-highlander.o
 obj-$(CONFIG_I2C_HIX5HD2)  += i2c-hix5hd2.o
 obj-$(CONFIG_I2C_IBM_IIC)  += i2c-ibm_iic.o
diff --git a/drivers/i2c/busses/i2c-hibvt.c b/drivers/i2c/busses/i2c-hibvt.c
new file mode 100644
index 000..e8af63e
--- /dev/null
+++ b/drivers/i2c/busses/i2c-hibvt.c
@@ -0,0 +1,737 @@
+/*
+ * Hisilicon BVT I2C Controller Driver
+ *
+ * Copyright (c) 2016 HiSilicon Technologies Co., Ltd.
+ *
+ * Authors: wen...@hisilicon.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.
+ *
+ * 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.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+/*
+ * I2C Registers offsets
+ */
+#define HIBVT_I2C_GLB  0x0
+#define HIBVT_I2C_SCL_H0x4
+#define HIBVT_I2C_SCL_L0x8
+#define HIBVT_I2C_DATA10x10
+#define HIBVT_I2C_TXF  0x20
+#define HIBVT_I2C_RXF  0x24
+#define HIBVT_I2C_CMD_BASE 0x30
+#define HIBVT_I2C_LOOP10xb0
+#define HIBVT_I2C_DST1 0xb4
+#define HIBVT_I2C_TX_WATER 0xc8
+#define HIBVT_I2C_RX_WATER 0xcc
+#define HIBVT_I2C_CTRL10xd0
+#define HIBVT_I2C_STAT 0xd8
+#define HIBVT_I2C_INTR_RAW 0xe0
+#define HIBVT_I2C_INTR_EN  0xe4
+#define HIBVT_I2C_INTR_STAT0xe8
+
+/*
+ * I2C Global Config Register -- HIBVT_I2C_GLB
+ */
+#de

[PATCH 3/3] dts: hisi: add dts files for Hi3516CV300 demo board

2016-10-17 Thread Pan Wen
Add dts files for Hi3516CV300 demo board.

Signed-off-by: Pan Wen <wen...@hisilicon.com>
---
 arch/arm/boot/dts/Makefile |   1 +
 arch/arm/boot/dts/hi3516cv300-demb.dts | 148 
 arch/arm/boot/dts/hi3516cv300.dtsi | 397 +
 3 files changed, 546 insertions(+)
 create mode 100644 arch/arm/boot/dts/hi3516cv300-demb.dts
 create mode 100644 arch/arm/boot/dts/hi3516cv300.dtsi

diff --git a/arch/arm/boot/dts/Makefile b/arch/arm/boot/dts/Makefile
index befcd26..1f25530 100644
--- a/arch/arm/boot/dts/Makefile
+++ b/arch/arm/boot/dts/Makefile
@@ -171,6 +171,7 @@ dtb-$(CONFIG_ARCH_HIP01) += \
 dtb-$(CONFIG_ARCH_HIP04) += \
hip04-d01.dtb
 dtb-$(CONFIG_ARCH_HISI) += \
+   hi3516cv300-demb.dtb \
hi3519-demb.dtb
 dtb-$(CONFIG_ARCH_HIX5HD2) += \
hisi-x5hd2-dkb.dtb
diff --git a/arch/arm/boot/dts/hi3516cv300-demb.dts 
b/arch/arm/boot/dts/hi3516cv300-demb.dts
new file mode 100644
index 000..6a75cd6
--- /dev/null
+++ b/arch/arm/boot/dts/hi3516cv300-demb.dts
@@ -0,0 +1,148 @@
+/*
+ * Copyright (c) 2016 HiSilicon Technologies Co., Ltd.
+ *
+ * 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.
+ *
+ * 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.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
+
+/dts-v1/;
+#include "hi3516cv300.dtsi"
+
+/ {
+   model = "Hisilicon Hi3516CV300 DEMO Board";
+   compatible = "hisilicon,hi3516cv300";
+
+   aliases {
+   serial0 = 
+   serial1 = 
+   serial2 = 
+   i2c0 = _bus0;
+   i2c1 = _bus1;
+   spi0 = _bus0;
+   spi1 = _bus1;
+   };
+
+   chosen {
+   stdout-path = "serial0:115200n8";
+   };
+
+   memory {
+   device_type = "memory";
+   reg = <0x8000 0x1000>;
+   };
+};
+
+_timer0 {
+   status = "okay";
+};
+
+ {
+   status = "okay";
+};
+
+ {
+   status = "okay";
+};
+
+ {
+   status = "okay";
+};
+
+_bus0 {
+   status = "okay";
+   clock-frequency = <10>;
+   pinctrl-names = "default";
+   pinctrl-0 = <_pmux>;
+};
+
+_bus1 {
+   status = "okay";
+   clock-frequency = <10>;
+   pinctrl-names = "default";
+   pinctrl-0 = <_pmux>;
+};
+
+_bus0{
+   status = "disabled";
+   num-cs = <1>;
+   cs-gpios = <_chip0 6 0>;
+   pinctrl-names = "default";
+   pinctrl-0 = <_pmux>;
+};
+
+_bus1{
+   status = "okay";
+   num-cs = <2>;
+   cs-gpios = <_chip5 3 0>, <_chip5 4 0>;
+   pinctrl-names = "default";
+   pinctrl-0 = <_pmux>;
+};
+
+ {
+   spi-nor@0 {
+   compatible = "jedec,spi-nor";
+   reg = <0>;
+   spi-max-frequency = <16000>;
+   m25p,fast-read;
+   };
+};
+
+ {
+   phy0: phy@1 {
+   reg = <1>;
+   };
+};
+
+_femac {
+   mac-address = [00 00 00 00 00 00];
+   phy-mode = "rmii";
+   phy-handle = <>;
+   hisilicon,phy-reset-delays-us = <1 1 15>;
+};
+
+ {
+   status = "okay";
+};
+
+ {
+   i2c0_pmux: i2c0_pmux {
+   pinctrl-single,pins = <
+   0x2c 0x3
+   0x30 0x3>;
+   };
+
+   i2c1_pmux: i2c1_pmux {
+   pinctrl-single,pins = <
+   0x20 0x1
+   0x24 0x1>;
+   };
+
+   spi0_pmux: spi0_pmux {
+   pinctrl-single,pins = <
+   0x28 0x1
+   0x2c 0x1
+   0x30 0x1
+   0x34 0x1>;
+   };
+
+   spi1_pmux: spi1_pmux {
+   pinctrl-single,pins = <
+   0xc4 0x1
+   0xc8 0x1
+   0xcc 0x1
+   0xd0 0x1
+   0xd4 0x1>;
+   };
+};
diff --git a/arch/arm/boot/dts/hi3516cv300.dtsi 
b/arch/arm/boot/dts/hi3516cv300.dtsi
new file mode 100644
index 000..1da41ab
--- /dev/null
+++ b/arch/arm/boot/dts/hi3516cv300.dtsi
@@ -0,0 +1,397 @@
+/*
+ * Copyright (c) 2016 HiSilicon Technologies Co., Lt

[PATCH 1/3] arm: hisi: add ARCH_MULTI_V5 support

2016-10-17 Thread Pan Wen
Add support for some HiSilicon SoCs which depend on ARCH_MULTI_V5.

Signed-off-by: Pan Wen <wen...@hisilicon.com>
---
 arch/arm/mach-hisi/Kconfig | 10 --
 1 file changed, 4 insertions(+), 6 deletions(-)

diff --git a/arch/arm/mach-hisi/Kconfig b/arch/arm/mach-hisi/Kconfig
index a3b091a..03d8379 100644
--- a/arch/arm/mach-hisi/Kconfig
+++ b/arch/arm/mach-hisi/Kconfig
@@ -1,12 +1,14 @@
 config ARCH_HISI
bool "Hisilicon SoC Support"
-   depends on ARCH_MULTI_V7
select ARM_AMBA
-   select ARM_GIC
+   select ARM_GIC if ARCH_MULTI_V7
+   select ARM_VIC if ARCH_MULTI_V5
select ARM_TIMER_SP804
select POWER_RESET
select POWER_RESET_HISI
select POWER_SUPPLY
+   select PINCTRL
+   select PINCTRL_SINGLE
 
 if ARCH_HISI
 
@@ -18,8 +20,6 @@ config ARCH_HI3xxx
select CACHE_L2X0
select HAVE_ARM_SCU if SMP
select HAVE_ARM_TWD if SMP
-   select PINCTRL
-   select PINCTRL_SINGLE
help
  Support for Hisilicon Hi36xx SoC family
 
@@ -48,8 +48,6 @@ config ARCH_HIX5HD2
select CACHE_L2X0
select HAVE_ARM_SCU if SMP
select HAVE_ARM_TWD if SMP
-   select PINCTRL
-   select PINCTRL_SINGLE
help
  Support for Hisilicon HIX5HD2 SoC family
 endmenu
-- 
2.9.3



[PATCH 1/3] arm: hisi: add ARCH_MULTI_V5 support

2016-10-17 Thread Pan Wen
Add support for some HiSilicon SoCs which depend on ARCH_MULTI_V5.

Signed-off-by: Pan Wen 
---
 arch/arm/mach-hisi/Kconfig | 10 --
 1 file changed, 4 insertions(+), 6 deletions(-)

diff --git a/arch/arm/mach-hisi/Kconfig b/arch/arm/mach-hisi/Kconfig
index a3b091a..03d8379 100644
--- a/arch/arm/mach-hisi/Kconfig
+++ b/arch/arm/mach-hisi/Kconfig
@@ -1,12 +1,14 @@
 config ARCH_HISI
bool "Hisilicon SoC Support"
-   depends on ARCH_MULTI_V7
select ARM_AMBA
-   select ARM_GIC
+   select ARM_GIC if ARCH_MULTI_V7
+   select ARM_VIC if ARCH_MULTI_V5
select ARM_TIMER_SP804
select POWER_RESET
select POWER_RESET_HISI
select POWER_SUPPLY
+   select PINCTRL
+   select PINCTRL_SINGLE
 
 if ARCH_HISI
 
@@ -18,8 +20,6 @@ config ARCH_HI3xxx
select CACHE_L2X0
select HAVE_ARM_SCU if SMP
select HAVE_ARM_TWD if SMP
-   select PINCTRL
-   select PINCTRL_SINGLE
help
  Support for Hisilicon Hi36xx SoC family
 
@@ -48,8 +48,6 @@ config ARCH_HIX5HD2
select CACHE_L2X0
select HAVE_ARM_SCU if SMP
select HAVE_ARM_TWD if SMP
-   select PINCTRL
-   select PINCTRL_SINGLE
help
  Support for Hisilicon HIX5HD2 SoC family
 endmenu
-- 
2.9.3



[PATCH 3/3] dts: hisi: add dts files for Hi3516CV300 demo board

2016-10-17 Thread Pan Wen
Add dts files for Hi3516CV300 demo board.

Signed-off-by: Pan Wen 
---
 arch/arm/boot/dts/Makefile |   1 +
 arch/arm/boot/dts/hi3516cv300-demb.dts | 148 
 arch/arm/boot/dts/hi3516cv300.dtsi | 397 +
 3 files changed, 546 insertions(+)
 create mode 100644 arch/arm/boot/dts/hi3516cv300-demb.dts
 create mode 100644 arch/arm/boot/dts/hi3516cv300.dtsi

diff --git a/arch/arm/boot/dts/Makefile b/arch/arm/boot/dts/Makefile
index befcd26..1f25530 100644
--- a/arch/arm/boot/dts/Makefile
+++ b/arch/arm/boot/dts/Makefile
@@ -171,6 +171,7 @@ dtb-$(CONFIG_ARCH_HIP01) += \
 dtb-$(CONFIG_ARCH_HIP04) += \
hip04-d01.dtb
 dtb-$(CONFIG_ARCH_HISI) += \
+   hi3516cv300-demb.dtb \
hi3519-demb.dtb
 dtb-$(CONFIG_ARCH_HIX5HD2) += \
hisi-x5hd2-dkb.dtb
diff --git a/arch/arm/boot/dts/hi3516cv300-demb.dts 
b/arch/arm/boot/dts/hi3516cv300-demb.dts
new file mode 100644
index 000..6a75cd6
--- /dev/null
+++ b/arch/arm/boot/dts/hi3516cv300-demb.dts
@@ -0,0 +1,148 @@
+/*
+ * Copyright (c) 2016 HiSilicon Technologies Co., Ltd.
+ *
+ * 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.
+ *
+ * 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.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
+
+/dts-v1/;
+#include "hi3516cv300.dtsi"
+
+/ {
+   model = "Hisilicon Hi3516CV300 DEMO Board";
+   compatible = "hisilicon,hi3516cv300";
+
+   aliases {
+   serial0 = 
+   serial1 = 
+   serial2 = 
+   i2c0 = _bus0;
+   i2c1 = _bus1;
+   spi0 = _bus0;
+   spi1 = _bus1;
+   };
+
+   chosen {
+   stdout-path = "serial0:115200n8";
+   };
+
+   memory {
+   device_type = "memory";
+   reg = <0x8000 0x1000>;
+   };
+};
+
+_timer0 {
+   status = "okay";
+};
+
+ {
+   status = "okay";
+};
+
+ {
+   status = "okay";
+};
+
+ {
+   status = "okay";
+};
+
+_bus0 {
+   status = "okay";
+   clock-frequency = <10>;
+   pinctrl-names = "default";
+   pinctrl-0 = <_pmux>;
+};
+
+_bus1 {
+   status = "okay";
+   clock-frequency = <10>;
+   pinctrl-names = "default";
+   pinctrl-0 = <_pmux>;
+};
+
+_bus0{
+   status = "disabled";
+   num-cs = <1>;
+   cs-gpios = <_chip0 6 0>;
+   pinctrl-names = "default";
+   pinctrl-0 = <_pmux>;
+};
+
+_bus1{
+   status = "okay";
+   num-cs = <2>;
+   cs-gpios = <_chip5 3 0>, <_chip5 4 0>;
+   pinctrl-names = "default";
+   pinctrl-0 = <_pmux>;
+};
+
+ {
+   spi-nor@0 {
+   compatible = "jedec,spi-nor";
+   reg = <0>;
+   spi-max-frequency = <16000>;
+   m25p,fast-read;
+   };
+};
+
+ {
+   phy0: phy@1 {
+   reg = <1>;
+   };
+};
+
+_femac {
+   mac-address = [00 00 00 00 00 00];
+   phy-mode = "rmii";
+   phy-handle = <>;
+   hisilicon,phy-reset-delays-us = <1 1 15>;
+};
+
+ {
+   status = "okay";
+};
+
+ {
+   i2c0_pmux: i2c0_pmux {
+   pinctrl-single,pins = <
+   0x2c 0x3
+   0x30 0x3>;
+   };
+
+   i2c1_pmux: i2c1_pmux {
+   pinctrl-single,pins = <
+   0x20 0x1
+   0x24 0x1>;
+   };
+
+   spi0_pmux: spi0_pmux {
+   pinctrl-single,pins = <
+   0x28 0x1
+   0x2c 0x1
+   0x30 0x1
+   0x34 0x1>;
+   };
+
+   spi1_pmux: spi1_pmux {
+   pinctrl-single,pins = <
+   0xc4 0x1
+   0xc8 0x1
+   0xcc 0x1
+   0xd0 0x1
+   0xd4 0x1>;
+   };
+};
diff --git a/arch/arm/boot/dts/hi3516cv300.dtsi 
b/arch/arm/boot/dts/hi3516cv300.dtsi
new file mode 100644
index 000..1da41ab
--- /dev/null
+++ b/arch/arm/boot/dts/hi3516cv300.dtsi
@@ -0,0 +1,397 @@
+/*
+ * Copyright (c) 2016 HiSilicon Technologies Co., Ltd.
+ *
+ * This program is free soft

[PATCH 2/3] clk: hisilicon: add CRG driver for Hi3516CV300 SoC

2016-10-17 Thread Pan Wen
Add CRG driver for Hi3516CV300 SoC. CRG(Clock and Reset
Generator) module generates clock and reset signals used
by other module blocks on SoC.

Signed-off-by: Pan Wen <wen...@hisilicon.com>
---
 .../devicetree/bindings/clock/hisi-crg.txt |  50 
 drivers/clk/hisilicon/Kconfig  |   8 +
 drivers/clk/hisilicon/Makefile |   1 +
 drivers/clk/hisilicon/crg-hi3516cv300.c| 330 +
 drivers/clk/hisilicon/crg.h|  34 +++
 include/dt-bindings/clock/hi3516cv300-clock.h  |  48 +++
 6 files changed, 471 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/clock/hisi-crg.txt
 create mode 100644 drivers/clk/hisilicon/crg-hi3516cv300.c
 create mode 100644 drivers/clk/hisilicon/crg.h
 create mode 100644 include/dt-bindings/clock/hi3516cv300-clock.h

diff --git a/Documentation/devicetree/bindings/clock/hisi-crg.txt 
b/Documentation/devicetree/bindings/clock/hisi-crg.txt
new file mode 100644
index 000..cc60b3d
--- /dev/null
+++ b/Documentation/devicetree/bindings/clock/hisi-crg.txt
@@ -0,0 +1,50 @@
+* HiSilicon Clock and Reset Generator(CRG)
+
+The CRG module provides clock and reset signals to various
+modules within the SoC.
+
+This binding uses the following bindings:
+Documentation/devicetree/bindings/clock/clock-bindings.txt
+Documentation/devicetree/bindings/reset/reset.txt
+
+Required Properties:
+
+- compatible: should be one of the following.
+  - "hisilicon,hi3516cv300-crg"
+  - "hisilicon,hi3516cv300-sysctrl"
+  - "hisilicon,hi3519-crg"
+  - "hisilicon,hi3798cv200-crg"
+  - "hisilicon,hi3798cv200-sysctrl"
+
+- reg: physical base address of the controller and length of memory mapped
+  region.
+
+- #clock-cells: should be 1.
+
+Each clock is assigned an identifier and client nodes use this identifier
+to specify the clock which they consume.
+
+All these identifier could be found in .
+
+- #reset-cells: should be 2.
+
+A reset signal can be controlled by writing a bit register in the CRG module.
+The reset specifier consists of two cells. The first cell represents the
+register offset relative to the base address. The second cell represents the
+bit index in the register.
+
+Example: CRG nodes
+CRG: clock-reset-controller@1201 {
+   compatible = "hisilicon,hi3519-crg";
+   reg = <0x1201 0x1>;
+   #clock-cells = <1>;
+   #reset-cells = <2>;
+};
+
+Example: consumer nodes
+i2c0: i2c@1211 {
+   compatible = "hisilicon,hi3519-i2c";
+   reg = <0x1211 0x1000>;
+   clocks = < HI3519_I2C0_RST>;
+   resets = < 0xe4 0>;
+};
diff --git a/drivers/clk/hisilicon/Kconfig b/drivers/clk/hisilicon/Kconfig
index 3f537a0..5ceb42f 100644
--- a/drivers/clk/hisilicon/Kconfig
+++ b/drivers/clk/hisilicon/Kconfig
@@ -1,3 +1,11 @@
+config COMMON_CLK_HI3516CV300
+   tristate "HI3516CV300 Clock Driver"
+   depends on ARCH_HISI || COMPILE_TEST
+   select RESET_HISI
+   default ARCH_HISI
+   help
+ Build the clock driver for hi3516cv300.
+
 config COMMON_CLK_HI3519
tristate "Hi3519 Clock Driver"
depends on ARCH_HISI || COMPILE_TEST
diff --git a/drivers/clk/hisilicon/Makefile b/drivers/clk/hisilicon/Makefile
index e169ec7..6c5c34d 100644
--- a/drivers/clk/hisilicon/Makefile
+++ b/drivers/clk/hisilicon/Makefile
@@ -7,6 +7,7 @@ obj-y   += clk.o clkgate-separated.o clkdivider-hi6220.o
 obj-$(CONFIG_ARCH_HI3xxx)  += clk-hi3620.o
 obj-$(CONFIG_ARCH_HIP04)   += clk-hip04.o
 obj-$(CONFIG_ARCH_HIX5HD2) += clk-hix5hd2.o
+obj-$(CONFIG_COMMON_CLK_HI3516CV300)   += crg-hi3516cv300.o
 obj-$(CONFIG_COMMON_CLK_HI3519)+= clk-hi3519.o
 obj-$(CONFIG_COMMON_CLK_HI6220)+= clk-hi6220.o
 obj-$(CONFIG_RESET_HISI)   += reset.o
diff --git a/drivers/clk/hisilicon/crg-hi3516cv300.c 
b/drivers/clk/hisilicon/crg-hi3516cv300.c
new file mode 100644
index 000..2007123
--- /dev/null
+++ b/drivers/clk/hisilicon/crg-hi3516cv300.c
@@ -0,0 +1,330 @@
+/*
+ * Hi3516CV300 Clock and Reset Generator Driver
+ *
+ * Copyright (c) 2016 HiSilicon Technologies Co., Ltd.
+ *
+ * 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.
+ *
+ * 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.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 

[PATCH 2/3] clk: hisilicon: add CRG driver for Hi3516CV300 SoC

2016-10-17 Thread Pan Wen
Add CRG driver for Hi3516CV300 SoC. CRG(Clock and Reset
Generator) module generates clock and reset signals used
by other module blocks on SoC.

Signed-off-by: Pan Wen 
---
 .../devicetree/bindings/clock/hisi-crg.txt |  50 
 drivers/clk/hisilicon/Kconfig  |   8 +
 drivers/clk/hisilicon/Makefile |   1 +
 drivers/clk/hisilicon/crg-hi3516cv300.c| 330 +
 drivers/clk/hisilicon/crg.h|  34 +++
 include/dt-bindings/clock/hi3516cv300-clock.h  |  48 +++
 6 files changed, 471 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/clock/hisi-crg.txt
 create mode 100644 drivers/clk/hisilicon/crg-hi3516cv300.c
 create mode 100644 drivers/clk/hisilicon/crg.h
 create mode 100644 include/dt-bindings/clock/hi3516cv300-clock.h

diff --git a/Documentation/devicetree/bindings/clock/hisi-crg.txt 
b/Documentation/devicetree/bindings/clock/hisi-crg.txt
new file mode 100644
index 000..cc60b3d
--- /dev/null
+++ b/Documentation/devicetree/bindings/clock/hisi-crg.txt
@@ -0,0 +1,50 @@
+* HiSilicon Clock and Reset Generator(CRG)
+
+The CRG module provides clock and reset signals to various
+modules within the SoC.
+
+This binding uses the following bindings:
+Documentation/devicetree/bindings/clock/clock-bindings.txt
+Documentation/devicetree/bindings/reset/reset.txt
+
+Required Properties:
+
+- compatible: should be one of the following.
+  - "hisilicon,hi3516cv300-crg"
+  - "hisilicon,hi3516cv300-sysctrl"
+  - "hisilicon,hi3519-crg"
+  - "hisilicon,hi3798cv200-crg"
+  - "hisilicon,hi3798cv200-sysctrl"
+
+- reg: physical base address of the controller and length of memory mapped
+  region.
+
+- #clock-cells: should be 1.
+
+Each clock is assigned an identifier and client nodes use this identifier
+to specify the clock which they consume.
+
+All these identifier could be found in .
+
+- #reset-cells: should be 2.
+
+A reset signal can be controlled by writing a bit register in the CRG module.
+The reset specifier consists of two cells. The first cell represents the
+register offset relative to the base address. The second cell represents the
+bit index in the register.
+
+Example: CRG nodes
+CRG: clock-reset-controller@1201 {
+   compatible = "hisilicon,hi3519-crg";
+   reg = <0x1201 0x1>;
+   #clock-cells = <1>;
+   #reset-cells = <2>;
+};
+
+Example: consumer nodes
+i2c0: i2c@1211 {
+   compatible = "hisilicon,hi3519-i2c";
+   reg = <0x1211 0x1000>;
+   clocks = < HI3519_I2C0_RST>;
+   resets = < 0xe4 0>;
+};
diff --git a/drivers/clk/hisilicon/Kconfig b/drivers/clk/hisilicon/Kconfig
index 3f537a0..5ceb42f 100644
--- a/drivers/clk/hisilicon/Kconfig
+++ b/drivers/clk/hisilicon/Kconfig
@@ -1,3 +1,11 @@
+config COMMON_CLK_HI3516CV300
+   tristate "HI3516CV300 Clock Driver"
+   depends on ARCH_HISI || COMPILE_TEST
+   select RESET_HISI
+   default ARCH_HISI
+   help
+ Build the clock driver for hi3516cv300.
+
 config COMMON_CLK_HI3519
tristate "Hi3519 Clock Driver"
depends on ARCH_HISI || COMPILE_TEST
diff --git a/drivers/clk/hisilicon/Makefile b/drivers/clk/hisilicon/Makefile
index e169ec7..6c5c34d 100644
--- a/drivers/clk/hisilicon/Makefile
+++ b/drivers/clk/hisilicon/Makefile
@@ -7,6 +7,7 @@ obj-y   += clk.o clkgate-separated.o clkdivider-hi6220.o
 obj-$(CONFIG_ARCH_HI3xxx)  += clk-hi3620.o
 obj-$(CONFIG_ARCH_HIP04)   += clk-hip04.o
 obj-$(CONFIG_ARCH_HIX5HD2) += clk-hix5hd2.o
+obj-$(CONFIG_COMMON_CLK_HI3516CV300)   += crg-hi3516cv300.o
 obj-$(CONFIG_COMMON_CLK_HI3519)+= clk-hi3519.o
 obj-$(CONFIG_COMMON_CLK_HI6220)+= clk-hi6220.o
 obj-$(CONFIG_RESET_HISI)   += reset.o
diff --git a/drivers/clk/hisilicon/crg-hi3516cv300.c 
b/drivers/clk/hisilicon/crg-hi3516cv300.c
new file mode 100644
index 000..2007123
--- /dev/null
+++ b/drivers/clk/hisilicon/crg-hi3516cv300.c
@@ -0,0 +1,330 @@
+/*
+ * Hi3516CV300 Clock and Reset Generator Driver
+ *
+ * Copyright (c) 2016 HiSilicon Technologies Co., Ltd.
+ *
+ * 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.
+ *
+ * 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.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include "clk.h"
+#include &

[PATCH 0/3] add basic SoC support for HiSilicon Hi3516CV300

2016-10-17 Thread Pan Wen
Hi3516CV300 is a SoC designed for HD IP camera. It has an integrated ISP and
H.265 video compression encoder. This patch set is mainly used to add basic SoC
support for Hi3516CV300. It includes crg driver and basic dts files.

Pan Wen (3):
  arm: hisi: add ARCH_MULTI_V5 support
  clk: hisilicon: add CRG driver for Hi3516CV300 SoC
  dts: hisi: add dts files for Hi3516CV300 demo board

 .../devicetree/bindings/clock/hisi-crg.txt |  50 +++
 arch/arm/boot/dts/Makefile |   1 +
 arch/arm/boot/dts/hi3516cv300-demb.dts | 148 
 arch/arm/boot/dts/hi3516cv300.dtsi | 397 +
 arch/arm/mach-hisi/Kconfig |  10 +-
 drivers/clk/hisilicon/Kconfig  |   8 +
 drivers/clk/hisilicon/Makefile |   1 +
 drivers/clk/hisilicon/crg-hi3516cv300.c| 330 +
 drivers/clk/hisilicon/crg.h|  34 ++
 include/dt-bindings/clock/hi3516cv300-clock.h  |  48 +++
 10 files changed, 1021 insertions(+), 6 deletions(-)
 create mode 100644 Documentation/devicetree/bindings/clock/hisi-crg.txt
 create mode 100644 arch/arm/boot/dts/hi3516cv300-demb.dts
 create mode 100644 arch/arm/boot/dts/hi3516cv300.dtsi
 create mode 100644 drivers/clk/hisilicon/crg-hi3516cv300.c
 create mode 100644 drivers/clk/hisilicon/crg.h
 create mode 100644 include/dt-bindings/clock/hi3516cv300-clock.h

-- 
2.9.3



[PATCH 0/3] add basic SoC support for HiSilicon Hi3516CV300

2016-10-17 Thread Pan Wen
Hi3516CV300 is a SoC designed for HD IP camera. It has an integrated ISP and
H.265 video compression encoder. This patch set is mainly used to add basic SoC
support for Hi3516CV300. It includes crg driver and basic dts files.

Pan Wen (3):
  arm: hisi: add ARCH_MULTI_V5 support
  clk: hisilicon: add CRG driver for Hi3516CV300 SoC
  dts: hisi: add dts files for Hi3516CV300 demo board

 .../devicetree/bindings/clock/hisi-crg.txt |  50 +++
 arch/arm/boot/dts/Makefile |   1 +
 arch/arm/boot/dts/hi3516cv300-demb.dts | 148 
 arch/arm/boot/dts/hi3516cv300.dtsi | 397 +
 arch/arm/mach-hisi/Kconfig |  10 +-
 drivers/clk/hisilicon/Kconfig  |   8 +
 drivers/clk/hisilicon/Makefile |   1 +
 drivers/clk/hisilicon/crg-hi3516cv300.c| 330 +
 drivers/clk/hisilicon/crg.h|  34 ++
 include/dt-bindings/clock/hi3516cv300-clock.h  |  48 +++
 10 files changed, 1021 insertions(+), 6 deletions(-)
 create mode 100644 Documentation/devicetree/bindings/clock/hisi-crg.txt
 create mode 100644 arch/arm/boot/dts/hi3516cv300-demb.dts
 create mode 100644 arch/arm/boot/dts/hi3516cv300.dtsi
 create mode 100644 drivers/clk/hisilicon/crg-hi3516cv300.c
 create mode 100644 drivers/clk/hisilicon/crg.h
 create mode 100644 include/dt-bindings/clock/hi3516cv300-clock.h

-- 
2.9.3



[PATCH v4] i2c: hibvt: add Hisilicon BVT I2C controller driver

2016-09-27 Thread Pan Wen
add Hisilicon BVT I2C controller driver support.

Signed-off-by: Pan Wen <wen...@hisilicon.com>
---
change log
v4:
Modify the default frequency to 100KHz.
v3:
Add a SoC specific compatible string.
v2:
1)Fixed a compile error.
2)Dropped the clock-names property.
 .../devicetree/bindings/i2c/i2c-hibvt.txt  |  24 +
 drivers/i2c/busses/Kconfig |  10 +
 drivers/i2c/busses/Makefile|   1 +
 drivers/i2c/busses/i2c-hibvt.c | 737 +
 4 files changed, 772 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/i2c/i2c-hibvt.txt
 create mode 100644 drivers/i2c/busses/i2c-hibvt.c

diff --git a/Documentation/devicetree/bindings/i2c/i2c-hibvt.txt 
b/Documentation/devicetree/bindings/i2c/i2c-hibvt.txt
new file mode 100644
index 000..db3d2e2
--- /dev/null
+++ b/Documentation/devicetree/bindings/i2c/i2c-hibvt.txt
@@ -0,0 +1,24 @@
+Hisilicon BVT I2C master controller
+
+Required properties:
+- compatible: should be "hisilicon,hibvt-i2c" and one of the following:
+   "hisilicon,hi3516cv300-i2c"
+- reg: physical base address of the controller and length of memory mapped.
+ region.
+- interrupts: interrupt number to the cpu.
+- clocks: phandles to input clocks.
+
+Optional properties:
+- clock-frequency: Desired I2C bus frequency in Hz, otherwise defaults to 
10.
+
+Other properties:
+see Documentation/devicetree/bindings/i2c/i2c.txt.
+
+Examples:
+i2c_bus0: i2c@1211 {
+   compatible = "hisilicon,hi3516cv300-i2c", "hisilicon,hibvt-i2c";
+   reg = <0x1211 0x100>;
+   interrupts = <20>;
+   clocks = <_ctrl HI3516CV300_APB_CLK>;
+   clock-frequency = <10>;
+};
diff --git a/drivers/i2c/busses/Kconfig b/drivers/i2c/busses/Kconfig
index 5c3993b..fc1b679 100644
--- a/drivers/i2c/busses/Kconfig
+++ b/drivers/i2c/busses/Kconfig
@@ -555,6 +555,16 @@ config I2C_GPIO
  This is a very simple bitbanging I2C driver utilizing the
  arch-neutral GPIO API to control the SCL and SDA lines.
 
+config I2C_HIBVT
+   tristate "Hisilicon BVT I2C Controller"
+   depends on ARCH_HISI
+   help
+ Say Y here to include support for Hisilicon BVT I2C controller in the
+ Hisilicon BVT SoCs.
+
+ This driver can also be built as a module.  If so, the module
+ will be called i2c-hibvt.
+
 config I2C_HIGHLANDER
tristate "Highlander FPGA SMBus interface"
depends on SH_HIGHLANDER
diff --git a/drivers/i2c/busses/Makefile b/drivers/i2c/busses/Makefile
index 37f2819..42ef2e0 100644
--- a/drivers/i2c/busses/Makefile
+++ b/drivers/i2c/busses/Makefile
@@ -51,6 +51,7 @@ obj-$(CONFIG_I2C_EG20T)   += i2c-eg20t.o
 obj-$(CONFIG_I2C_EMEV2)+= i2c-emev2.o
 obj-$(CONFIG_I2C_EXYNOS5)  += i2c-exynos5.o
 obj-$(CONFIG_I2C_GPIO) += i2c-gpio.o
+obj-$(CONFIG_I2C_HIBVT)+= i2c-hibvt.o
 obj-$(CONFIG_I2C_HIGHLANDER)   += i2c-highlander.o
 obj-$(CONFIG_I2C_HIX5HD2)  += i2c-hix5hd2.o
 obj-$(CONFIG_I2C_IBM_IIC)  += i2c-ibm_iic.o
diff --git a/drivers/i2c/busses/i2c-hibvt.c b/drivers/i2c/busses/i2c-hibvt.c
new file mode 100644
index 000..e8af63e
--- /dev/null
+++ b/drivers/i2c/busses/i2c-hibvt.c
@@ -0,0 +1,737 @@
+/*
+ * Hisilicon BVT I2C Controller Driver
+ *
+ * Copyright (c) 2016 HiSilicon Technologies Co., Ltd.
+ *
+ * Authors: wen...@hisilicon.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.
+ *
+ * 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.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+/*
+ * I2C Registers offsets
+ */
+#define HIBVT_I2C_GLB  0x0
+#define HIBVT_I2C_SCL_H0x4
+#define HIBVT_I2C_SCL_L0x8
+#define HIBVT_I2C_DATA10x10
+#define HIBVT_I2C_TXF  0x20
+#define HIBVT_I2C_RXF  0x24
+#define HIBVT_I2C_CMD_BASE 0x30
+#define HIBVT_I2C_LOOP10xb0
+#define HIBVT_I2C_DST1 0xb4
+#define HIBVT_I2C_TX_WATER 0xc8
+#define HIBVT_I2C_RX_WATER 0xcc
+#define HIBVT_I2C_CTRL10xd0
+#define HIBVT_I2C_STAT 0xd8
+#define HIBVT_I2C_INTR_RAW 0xe0
+#define HIBVT_I2C_INTR_EN  0xe4
+#define HIBVT_I2C_INTR_STAT0xe8
+
+/*
+ * I2C Global Config Register -- HIBVT_I2C_GLB
+ *

[PATCH v4] i2c: hibvt: add Hisilicon BVT I2C controller driver

2016-09-27 Thread Pan Wen
add Hisilicon BVT I2C controller driver support.

Signed-off-by: Pan Wen 
---
change log
v4:
Modify the default frequency to 100KHz.
v3:
Add a SoC specific compatible string.
v2:
1)Fixed a compile error.
2)Dropped the clock-names property.
 .../devicetree/bindings/i2c/i2c-hibvt.txt  |  24 +
 drivers/i2c/busses/Kconfig |  10 +
 drivers/i2c/busses/Makefile|   1 +
 drivers/i2c/busses/i2c-hibvt.c | 737 +
 4 files changed, 772 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/i2c/i2c-hibvt.txt
 create mode 100644 drivers/i2c/busses/i2c-hibvt.c

diff --git a/Documentation/devicetree/bindings/i2c/i2c-hibvt.txt 
b/Documentation/devicetree/bindings/i2c/i2c-hibvt.txt
new file mode 100644
index 000..db3d2e2
--- /dev/null
+++ b/Documentation/devicetree/bindings/i2c/i2c-hibvt.txt
@@ -0,0 +1,24 @@
+Hisilicon BVT I2C master controller
+
+Required properties:
+- compatible: should be "hisilicon,hibvt-i2c" and one of the following:
+   "hisilicon,hi3516cv300-i2c"
+- reg: physical base address of the controller and length of memory mapped.
+ region.
+- interrupts: interrupt number to the cpu.
+- clocks: phandles to input clocks.
+
+Optional properties:
+- clock-frequency: Desired I2C bus frequency in Hz, otherwise defaults to 
10.
+
+Other properties:
+see Documentation/devicetree/bindings/i2c/i2c.txt.
+
+Examples:
+i2c_bus0: i2c@1211 {
+   compatible = "hisilicon,hi3516cv300-i2c", "hisilicon,hibvt-i2c";
+   reg = <0x1211 0x100>;
+   interrupts = <20>;
+   clocks = <_ctrl HI3516CV300_APB_CLK>;
+   clock-frequency = <10>;
+};
diff --git a/drivers/i2c/busses/Kconfig b/drivers/i2c/busses/Kconfig
index 5c3993b..fc1b679 100644
--- a/drivers/i2c/busses/Kconfig
+++ b/drivers/i2c/busses/Kconfig
@@ -555,6 +555,16 @@ config I2C_GPIO
  This is a very simple bitbanging I2C driver utilizing the
  arch-neutral GPIO API to control the SCL and SDA lines.
 
+config I2C_HIBVT
+   tristate "Hisilicon BVT I2C Controller"
+   depends on ARCH_HISI
+   help
+ Say Y here to include support for Hisilicon BVT I2C controller in the
+ Hisilicon BVT SoCs.
+
+ This driver can also be built as a module.  If so, the module
+ will be called i2c-hibvt.
+
 config I2C_HIGHLANDER
tristate "Highlander FPGA SMBus interface"
depends on SH_HIGHLANDER
diff --git a/drivers/i2c/busses/Makefile b/drivers/i2c/busses/Makefile
index 37f2819..42ef2e0 100644
--- a/drivers/i2c/busses/Makefile
+++ b/drivers/i2c/busses/Makefile
@@ -51,6 +51,7 @@ obj-$(CONFIG_I2C_EG20T)   += i2c-eg20t.o
 obj-$(CONFIG_I2C_EMEV2)+= i2c-emev2.o
 obj-$(CONFIG_I2C_EXYNOS5)  += i2c-exynos5.o
 obj-$(CONFIG_I2C_GPIO) += i2c-gpio.o
+obj-$(CONFIG_I2C_HIBVT)+= i2c-hibvt.o
 obj-$(CONFIG_I2C_HIGHLANDER)   += i2c-highlander.o
 obj-$(CONFIG_I2C_HIX5HD2)  += i2c-hix5hd2.o
 obj-$(CONFIG_I2C_IBM_IIC)  += i2c-ibm_iic.o
diff --git a/drivers/i2c/busses/i2c-hibvt.c b/drivers/i2c/busses/i2c-hibvt.c
new file mode 100644
index 000..e8af63e
--- /dev/null
+++ b/drivers/i2c/busses/i2c-hibvt.c
@@ -0,0 +1,737 @@
+/*
+ * Hisilicon BVT I2C Controller Driver
+ *
+ * Copyright (c) 2016 HiSilicon Technologies Co., Ltd.
+ *
+ * Authors: wen...@hisilicon.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.
+ *
+ * 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.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+/*
+ * I2C Registers offsets
+ */
+#define HIBVT_I2C_GLB  0x0
+#define HIBVT_I2C_SCL_H0x4
+#define HIBVT_I2C_SCL_L0x8
+#define HIBVT_I2C_DATA10x10
+#define HIBVT_I2C_TXF  0x20
+#define HIBVT_I2C_RXF  0x24
+#define HIBVT_I2C_CMD_BASE 0x30
+#define HIBVT_I2C_LOOP10xb0
+#define HIBVT_I2C_DST1 0xb4
+#define HIBVT_I2C_TX_WATER 0xc8
+#define HIBVT_I2C_RX_WATER 0xcc
+#define HIBVT_I2C_CTRL10xd0
+#define HIBVT_I2C_STAT 0xd8
+#define HIBVT_I2C_INTR_RAW 0xe0
+#define HIBVT_I2C_INTR_EN  0xe4
+#define HIBVT_I2C_INTR_STAT0xe8
+
+/*
+ * I2C Global Config Register -- HIBVT_I2C_GLB
+ */
+#define GLB_EN_MASK  

[PATCH resend v3] i2c: hibvt: add Hisilicon BVT I2C controller driver

2016-09-19 Thread Pan Wen
add Hisilicon BVT I2C controller driver support.

Signed-off-by: Pan Wen <wen...@hisilicon.com>
---
 .../devicetree/bindings/i2c/i2c-hibvt.txt  |  24 +
 drivers/i2c/busses/Kconfig |  10 +
 drivers/i2c/busses/Makefile|   1 +
 drivers/i2c/busses/i2c-hibvt.c | 737 +
 4 files changed, 772 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/i2c/i2c-hibvt.txt
 create mode 100644 drivers/i2c/busses/i2c-hibvt.c

diff --git a/Documentation/devicetree/bindings/i2c/i2c-hibvt.txt 
b/Documentation/devicetree/bindings/i2c/i2c-hibvt.txt
new file mode 100644
index 000..db3d2e2
--- /dev/null
+++ b/Documentation/devicetree/bindings/i2c/i2c-hibvt.txt
@@ -0,0 +1,24 @@
+Hisilicon BVT I2C master controller
+
+Required properties:
+- compatible: should be "hisilicon,hibvt-i2c" and one of the following:
+   "hisilicon,hi3516cv300-i2c"
+- reg: physical base address of the controller and length of memory mapped.
+ region.
+- interrupts: interrupt number to the cpu.
+- clocks: phandles to input clocks.
+
+Optional properties:
+- clock-frequency: Desired I2C bus frequency in Hz, otherwise defaults to 
10.
+
+Other properties:
+see Documentation/devicetree/bindings/i2c/i2c.txt.
+
+Examples:
+i2c_bus0: i2c@1211 {
+   compatible = "hisilicon,hi3516cv300-i2c", "hisilicon,hibvt-i2c";
+   reg = <0x1211 0x100>;
+   interrupts = <20>;
+   clocks = <_ctrl HI3516CV300_APB_CLK>;
+   clock-frequency = <10>;
+};
diff --git a/drivers/i2c/busses/Kconfig b/drivers/i2c/busses/Kconfig
index 5c3993b..fc1b679 100644
--- a/drivers/i2c/busses/Kconfig
+++ b/drivers/i2c/busses/Kconfig
@@ -555,6 +555,16 @@ config I2C_GPIO
  This is a very simple bitbanging I2C driver utilizing the
  arch-neutral GPIO API to control the SCL and SDA lines.
 
+config I2C_HIBVT
+   tristate "Hisilicon BVT I2C Controller"
+   depends on ARCH_HISI
+   help
+ Say Y here to include support for Hisilicon BVT I2C controller in the
+ Hisilicon BVT SoCs.
+
+ This driver can also be built as a module.  If so, the module
+ will be called i2c-hibvt.
+
 config I2C_HIGHLANDER
tristate "Highlander FPGA SMBus interface"
depends on SH_HIGHLANDER
diff --git a/drivers/i2c/busses/Makefile b/drivers/i2c/busses/Makefile
index 37f2819..42ef2e0 100644
--- a/drivers/i2c/busses/Makefile
+++ b/drivers/i2c/busses/Makefile
@@ -51,6 +51,7 @@ obj-$(CONFIG_I2C_EG20T)   += i2c-eg20t.o
 obj-$(CONFIG_I2C_EMEV2)+= i2c-emev2.o
 obj-$(CONFIG_I2C_EXYNOS5)  += i2c-exynos5.o
 obj-$(CONFIG_I2C_GPIO) += i2c-gpio.o
+obj-$(CONFIG_I2C_HIBVT)+= i2c-hibvt.o
 obj-$(CONFIG_I2C_HIGHLANDER)   += i2c-highlander.o
 obj-$(CONFIG_I2C_HIX5HD2)  += i2c-hix5hd2.o
 obj-$(CONFIG_I2C_IBM_IIC)  += i2c-ibm_iic.o
diff --git a/drivers/i2c/busses/i2c-hibvt.c b/drivers/i2c/busses/i2c-hibvt.c
new file mode 100644
index 000..abe8a07
--- /dev/null
+++ b/drivers/i2c/busses/i2c-hibvt.c
@@ -0,0 +1,737 @@
+/*
+ * Hisilicon BVT I2C Controller Driver
+ *
+ * Copyright (c) 2016 HiSilicon Technologies Co., Ltd.
+ *
+ * Authors: wen...@hisilicon.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.
+ *
+ * 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.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+/*
+ * I2C Registers offsets
+ */
+#define HIBVT_I2C_GLB  0x0
+#define HIBVT_I2C_SCL_H0x4
+#define HIBVT_I2C_SCL_L0x8
+#define HIBVT_I2C_DATA10x10
+#define HIBVT_I2C_TXF  0x20
+#define HIBVT_I2C_RXF  0x24
+#define HIBVT_I2C_CMD_BASE 0x30
+#define HIBVT_I2C_LOOP10xb0
+#define HIBVT_I2C_DST1 0xb4
+#define HIBVT_I2C_TX_WATER 0xc8
+#define HIBVT_I2C_RX_WATER 0xcc
+#define HIBVT_I2C_CTRL10xd0
+#define HIBVT_I2C_STAT 0xd8
+#define HIBVT_I2C_INTR_RAW 0xe0
+#define HIBVT_I2C_INTR_EN  0xe4
+#define HIBVT_I2C_INTR_STAT0xe8
+
+/*
+ * I2C Global Config Register -- HIBVT_I2C_GLB
+ */
+#define GLB_EN_MASKBIT(0)
+#define GLB_SDA_HOLD_MASK  GENMASK(23, 8)
+#define GLB_SDA_HOLD_SHIFT (8)
+
+/*
+ * I2C Timing CMD Register -- HIB

[PATCH resend v3] i2c: hibvt: add Hisilicon BVT I2C controller driver

2016-09-19 Thread Pan Wen
add Hisilicon BVT I2C controller driver support.

Signed-off-by: Pan Wen 
---
 .../devicetree/bindings/i2c/i2c-hibvt.txt  |  24 +
 drivers/i2c/busses/Kconfig |  10 +
 drivers/i2c/busses/Makefile|   1 +
 drivers/i2c/busses/i2c-hibvt.c | 737 +
 4 files changed, 772 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/i2c/i2c-hibvt.txt
 create mode 100644 drivers/i2c/busses/i2c-hibvt.c

diff --git a/Documentation/devicetree/bindings/i2c/i2c-hibvt.txt 
b/Documentation/devicetree/bindings/i2c/i2c-hibvt.txt
new file mode 100644
index 000..db3d2e2
--- /dev/null
+++ b/Documentation/devicetree/bindings/i2c/i2c-hibvt.txt
@@ -0,0 +1,24 @@
+Hisilicon BVT I2C master controller
+
+Required properties:
+- compatible: should be "hisilicon,hibvt-i2c" and one of the following:
+   "hisilicon,hi3516cv300-i2c"
+- reg: physical base address of the controller and length of memory mapped.
+ region.
+- interrupts: interrupt number to the cpu.
+- clocks: phandles to input clocks.
+
+Optional properties:
+- clock-frequency: Desired I2C bus frequency in Hz, otherwise defaults to 
10.
+
+Other properties:
+see Documentation/devicetree/bindings/i2c/i2c.txt.
+
+Examples:
+i2c_bus0: i2c@1211 {
+   compatible = "hisilicon,hi3516cv300-i2c", "hisilicon,hibvt-i2c";
+   reg = <0x1211 0x100>;
+   interrupts = <20>;
+   clocks = <_ctrl HI3516CV300_APB_CLK>;
+   clock-frequency = <10>;
+};
diff --git a/drivers/i2c/busses/Kconfig b/drivers/i2c/busses/Kconfig
index 5c3993b..fc1b679 100644
--- a/drivers/i2c/busses/Kconfig
+++ b/drivers/i2c/busses/Kconfig
@@ -555,6 +555,16 @@ config I2C_GPIO
  This is a very simple bitbanging I2C driver utilizing the
  arch-neutral GPIO API to control the SCL and SDA lines.
 
+config I2C_HIBVT
+   tristate "Hisilicon BVT I2C Controller"
+   depends on ARCH_HISI
+   help
+ Say Y here to include support for Hisilicon BVT I2C controller in the
+ Hisilicon BVT SoCs.
+
+ This driver can also be built as a module.  If so, the module
+ will be called i2c-hibvt.
+
 config I2C_HIGHLANDER
tristate "Highlander FPGA SMBus interface"
depends on SH_HIGHLANDER
diff --git a/drivers/i2c/busses/Makefile b/drivers/i2c/busses/Makefile
index 37f2819..42ef2e0 100644
--- a/drivers/i2c/busses/Makefile
+++ b/drivers/i2c/busses/Makefile
@@ -51,6 +51,7 @@ obj-$(CONFIG_I2C_EG20T)   += i2c-eg20t.o
 obj-$(CONFIG_I2C_EMEV2)+= i2c-emev2.o
 obj-$(CONFIG_I2C_EXYNOS5)  += i2c-exynos5.o
 obj-$(CONFIG_I2C_GPIO) += i2c-gpio.o
+obj-$(CONFIG_I2C_HIBVT)+= i2c-hibvt.o
 obj-$(CONFIG_I2C_HIGHLANDER)   += i2c-highlander.o
 obj-$(CONFIG_I2C_HIX5HD2)  += i2c-hix5hd2.o
 obj-$(CONFIG_I2C_IBM_IIC)  += i2c-ibm_iic.o
diff --git a/drivers/i2c/busses/i2c-hibvt.c b/drivers/i2c/busses/i2c-hibvt.c
new file mode 100644
index 000..abe8a07
--- /dev/null
+++ b/drivers/i2c/busses/i2c-hibvt.c
@@ -0,0 +1,737 @@
+/*
+ * Hisilicon BVT I2C Controller Driver
+ *
+ * Copyright (c) 2016 HiSilicon Technologies Co., Ltd.
+ *
+ * Authors: wen...@hisilicon.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.
+ *
+ * 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.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+/*
+ * I2C Registers offsets
+ */
+#define HIBVT_I2C_GLB  0x0
+#define HIBVT_I2C_SCL_H0x4
+#define HIBVT_I2C_SCL_L0x8
+#define HIBVT_I2C_DATA10x10
+#define HIBVT_I2C_TXF  0x20
+#define HIBVT_I2C_RXF  0x24
+#define HIBVT_I2C_CMD_BASE 0x30
+#define HIBVT_I2C_LOOP10xb0
+#define HIBVT_I2C_DST1 0xb4
+#define HIBVT_I2C_TX_WATER 0xc8
+#define HIBVT_I2C_RX_WATER 0xcc
+#define HIBVT_I2C_CTRL10xd0
+#define HIBVT_I2C_STAT 0xd8
+#define HIBVT_I2C_INTR_RAW 0xe0
+#define HIBVT_I2C_INTR_EN  0xe4
+#define HIBVT_I2C_INTR_STAT0xe8
+
+/*
+ * I2C Global Config Register -- HIBVT_I2C_GLB
+ */
+#define GLB_EN_MASKBIT(0)
+#define GLB_SDA_HOLD_MASK  GENMASK(23, 8)
+#define GLB_SDA_HOLD_SHIFT (8)
+
+/*
+ * I2C Timing CMD Register -- HIBVT_I2C_CMD_BASE + n * 4 (

[PATCH v3] i2c: hibvt: add Hisilicon BVT I2C controller driver

2016-07-31 Thread Pan Wen
add Hisilicon BVT I2C controller driver support.

Signed-off-by: Pan Wen <wen...@hisilicon.com>
---
change log
v3:
Add a SoC specific compatible string.
v2:
1)Fixed a compile error.
2)Dropped the clock-names property.
 .../devicetree/bindings/i2c/i2c-hibvt.txt  |  24 +
 drivers/i2c/busses/Kconfig |  10 +
 drivers/i2c/busses/Makefile|   1 +
 drivers/i2c/busses/i2c-hibvt.c | 737 +
 4 files changed, 772 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/i2c/i2c-hibvt.txt
 create mode 100644 drivers/i2c/busses/i2c-hibvt.c

diff --git a/Documentation/devicetree/bindings/i2c/i2c-hibvt.txt 
b/Documentation/devicetree/bindings/i2c/i2c-hibvt.txt
new file mode 100644
index 000..db3d2e2
--- /dev/null
+++ b/Documentation/devicetree/bindings/i2c/i2c-hibvt.txt
@@ -0,0 +1,24 @@
+Hisilicon BVT I2C master controller
+
+Required properties:
+- compatible: should be "hisilicon,hibvt-i2c" and one of the following:
+   "hisilicon,hi3516cv300-i2c"
+- reg: physical base address of the controller and length of memory mapped.
+ region.
+- interrupts: interrupt number to the cpu.
+- clocks: phandles to input clocks.
+
+Optional properties:
+- clock-frequency: Desired I2C bus frequency in Hz, otherwise defaults to 
10.
+
+Other properties:
+see Documentation/devicetree/bindings/i2c/i2c.txt.
+
+Examples:
+i2c_bus0: i2c@1211 {
+   compatible = "hisilicon,hi3516cv300-i2c", "hisilicon,hibvt-i2c";
+   reg = <0x1211 0x100>;
+   interrupts = <20>;
+   clocks = <_ctrl HI3516CV300_APB_CLK>;
+   clock-frequency = <10>;
+};
diff --git a/drivers/i2c/busses/Kconfig b/drivers/i2c/busses/Kconfig
index f167021..6c5d24a 100644
--- a/drivers/i2c/busses/Kconfig
+++ b/drivers/i2c/busses/Kconfig
@@ -552,6 +552,16 @@ config I2C_GPIO
  This is a very simple bitbanging I2C driver utilizing the
  arch-neutral GPIO API to control the SCL and SDA lines.
 
+config I2C_HIBVT
+   tristate "Hisilicon BVT I2C Controller"
+   depends on ARCH_HISI
+   help
+ Say Y here to include support for Hisilicon BVT I2C controller in the
+ Hisilicon BVT SoCs.
+
+ This driver can also be built as a module.  If so, the module
+ will be called i2c-hibvt.
+
 config I2C_HIGHLANDER
tristate "Highlander FPGA SMBus interface"
depends on SH_HIGHLANDER
diff --git a/drivers/i2c/busses/Makefile b/drivers/i2c/busses/Makefile
index 37f2819..42ef2e0 100644
--- a/drivers/i2c/busses/Makefile
+++ b/drivers/i2c/busses/Makefile
@@ -51,6 +51,7 @@ obj-$(CONFIG_I2C_EG20T)   += i2c-eg20t.o
 obj-$(CONFIG_I2C_EMEV2)+= i2c-emev2.o
 obj-$(CONFIG_I2C_EXYNOS5)  += i2c-exynos5.o
 obj-$(CONFIG_I2C_GPIO) += i2c-gpio.o
+obj-$(CONFIG_I2C_HIBVT)+= i2c-hibvt.o
 obj-$(CONFIG_I2C_HIGHLANDER)   += i2c-highlander.o
 obj-$(CONFIG_I2C_HIX5HD2)  += i2c-hix5hd2.o
 obj-$(CONFIG_I2C_IBM_IIC)  += i2c-ibm_iic.o
diff --git a/drivers/i2c/busses/i2c-hibvt.c b/drivers/i2c/busses/i2c-hibvt.c
new file mode 100644
index 000..abe8a07
--- /dev/null
+++ b/drivers/i2c/busses/i2c-hibvt.c
@@ -0,0 +1,737 @@
+/*
+ * Hisilicon BVT I2C Controller Driver
+ *
+ * Copyright (c) 2016 HiSilicon Technologies Co., Ltd.
+ *
+ * Authors: wen...@hisilicon.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.
+ *
+ * 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.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+/*
+ * I2C Registers offsets
+ */
+#define HIBVT_I2C_GLB  0x0
+#define HIBVT_I2C_SCL_H0x4
+#define HIBVT_I2C_SCL_L0x8
+#define HIBVT_I2C_DATA10x10
+#define HIBVT_I2C_TXF  0x20
+#define HIBVT_I2C_RXF  0x24
+#define HIBVT_I2C_CMD_BASE 0x30
+#define HIBVT_I2C_LOOP10xb0
+#define HIBVT_I2C_DST1 0xb4
+#define HIBVT_I2C_TX_WATER 0xc8
+#define HIBVT_I2C_RX_WATER 0xcc
+#define HIBVT_I2C_CTRL10xd0
+#define HIBVT_I2C_STAT 0xd8
+#define HIBVT_I2C_INTR_RAW 0xe0
+#define HIBVT_I2C_INTR_EN  0xe4
+#define HIBVT_I2C_INTR_STAT0xe8
+
+/*
+ * I2C Global Config Register -- HIBVT_I2C_GLB
+ */
+#define GLB_EN_MASKBIT(0)
+#defin

[PATCH v3] i2c: hibvt: add Hisilicon BVT I2C controller driver

2016-07-31 Thread Pan Wen
add Hisilicon BVT I2C controller driver support.

Signed-off-by: Pan Wen 
---
change log
v3:
Add a SoC specific compatible string.
v2:
1)Fixed a compile error.
2)Dropped the clock-names property.
 .../devicetree/bindings/i2c/i2c-hibvt.txt  |  24 +
 drivers/i2c/busses/Kconfig |  10 +
 drivers/i2c/busses/Makefile|   1 +
 drivers/i2c/busses/i2c-hibvt.c | 737 +
 4 files changed, 772 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/i2c/i2c-hibvt.txt
 create mode 100644 drivers/i2c/busses/i2c-hibvt.c

diff --git a/Documentation/devicetree/bindings/i2c/i2c-hibvt.txt 
b/Documentation/devicetree/bindings/i2c/i2c-hibvt.txt
new file mode 100644
index 000..db3d2e2
--- /dev/null
+++ b/Documentation/devicetree/bindings/i2c/i2c-hibvt.txt
@@ -0,0 +1,24 @@
+Hisilicon BVT I2C master controller
+
+Required properties:
+- compatible: should be "hisilicon,hibvt-i2c" and one of the following:
+   "hisilicon,hi3516cv300-i2c"
+- reg: physical base address of the controller and length of memory mapped.
+ region.
+- interrupts: interrupt number to the cpu.
+- clocks: phandles to input clocks.
+
+Optional properties:
+- clock-frequency: Desired I2C bus frequency in Hz, otherwise defaults to 
10.
+
+Other properties:
+see Documentation/devicetree/bindings/i2c/i2c.txt.
+
+Examples:
+i2c_bus0: i2c@1211 {
+   compatible = "hisilicon,hi3516cv300-i2c", "hisilicon,hibvt-i2c";
+   reg = <0x1211 0x100>;
+   interrupts = <20>;
+   clocks = <_ctrl HI3516CV300_APB_CLK>;
+   clock-frequency = <10>;
+};
diff --git a/drivers/i2c/busses/Kconfig b/drivers/i2c/busses/Kconfig
index f167021..6c5d24a 100644
--- a/drivers/i2c/busses/Kconfig
+++ b/drivers/i2c/busses/Kconfig
@@ -552,6 +552,16 @@ config I2C_GPIO
  This is a very simple bitbanging I2C driver utilizing the
  arch-neutral GPIO API to control the SCL and SDA lines.
 
+config I2C_HIBVT
+   tristate "Hisilicon BVT I2C Controller"
+   depends on ARCH_HISI
+   help
+ Say Y here to include support for Hisilicon BVT I2C controller in the
+ Hisilicon BVT SoCs.
+
+ This driver can also be built as a module.  If so, the module
+ will be called i2c-hibvt.
+
 config I2C_HIGHLANDER
tristate "Highlander FPGA SMBus interface"
depends on SH_HIGHLANDER
diff --git a/drivers/i2c/busses/Makefile b/drivers/i2c/busses/Makefile
index 37f2819..42ef2e0 100644
--- a/drivers/i2c/busses/Makefile
+++ b/drivers/i2c/busses/Makefile
@@ -51,6 +51,7 @@ obj-$(CONFIG_I2C_EG20T)   += i2c-eg20t.o
 obj-$(CONFIG_I2C_EMEV2)+= i2c-emev2.o
 obj-$(CONFIG_I2C_EXYNOS5)  += i2c-exynos5.o
 obj-$(CONFIG_I2C_GPIO) += i2c-gpio.o
+obj-$(CONFIG_I2C_HIBVT)+= i2c-hibvt.o
 obj-$(CONFIG_I2C_HIGHLANDER)   += i2c-highlander.o
 obj-$(CONFIG_I2C_HIX5HD2)  += i2c-hix5hd2.o
 obj-$(CONFIG_I2C_IBM_IIC)  += i2c-ibm_iic.o
diff --git a/drivers/i2c/busses/i2c-hibvt.c b/drivers/i2c/busses/i2c-hibvt.c
new file mode 100644
index 000..abe8a07
--- /dev/null
+++ b/drivers/i2c/busses/i2c-hibvt.c
@@ -0,0 +1,737 @@
+/*
+ * Hisilicon BVT I2C Controller Driver
+ *
+ * Copyright (c) 2016 HiSilicon Technologies Co., Ltd.
+ *
+ * Authors: wen...@hisilicon.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.
+ *
+ * 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.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+/*
+ * I2C Registers offsets
+ */
+#define HIBVT_I2C_GLB  0x0
+#define HIBVT_I2C_SCL_H0x4
+#define HIBVT_I2C_SCL_L0x8
+#define HIBVT_I2C_DATA10x10
+#define HIBVT_I2C_TXF  0x20
+#define HIBVT_I2C_RXF  0x24
+#define HIBVT_I2C_CMD_BASE 0x30
+#define HIBVT_I2C_LOOP10xb0
+#define HIBVT_I2C_DST1 0xb4
+#define HIBVT_I2C_TX_WATER 0xc8
+#define HIBVT_I2C_RX_WATER 0xcc
+#define HIBVT_I2C_CTRL10xd0
+#define HIBVT_I2C_STAT 0xd8
+#define HIBVT_I2C_INTR_RAW 0xe0
+#define HIBVT_I2C_INTR_EN  0xe4
+#define HIBVT_I2C_INTR_STAT0xe8
+
+/*
+ * I2C Global Config Register -- HIBVT_I2C_GLB
+ */
+#define GLB_EN_MASKBIT(0)
+#define GLB_SDA_HOLD_MASK

[PATCH v2] i2c: hibvt: add Hisilicon BVT I2C controller driver

2016-07-12 Thread Pan Wen
add Hisilicon BVT I2C controller driver support.

Signed-off-by: Pan Wen <wen...@hisilicon.com>
---
change log
v2:
1)Fixed a compile error.
2)Dropped the clock-names property.
 .../devicetree/bindings/i2c/i2c-hibvt.txt  |  23 +
 drivers/i2c/busses/Kconfig |  10 +
 drivers/i2c/busses/Makefile|   1 +
 drivers/i2c/busses/i2c-hibvt.c | 736 +
 4 files changed, 770 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/i2c/i2c-hibvt.txt
 create mode 100644 drivers/i2c/busses/i2c-hibvt.c

diff --git a/Documentation/devicetree/bindings/i2c/i2c-hibvt.txt 
b/Documentation/devicetree/bindings/i2c/i2c-hibvt.txt
new file mode 100644
index 000..9b88afe
--- /dev/null
+++ b/Documentation/devicetree/bindings/i2c/i2c-hibvt.txt
@@ -0,0 +1,23 @@
+Hisilicon BVT I2C master controller
+
+Required properties:
+- compatible: should be "hisilicon,hibvt-i2c".
+- reg: physical base address of the controller and length of memory mapped.
+ region.
+- interrupts: interrupt number to the cpu.
+- clocks: phandles to input clocks.
+
+Optional properties:
+- clock-frequency: Desired I2C bus frequency in Hz, otherwise defaults to 
10.
+
+Other properties:
+see Documentation/devicetree/bindings/i2c/i2c.txt.
+
+Examples:
+i2c_bus0: i2c@1211 {
+   compatible = "hisilicon,hibvt-i2c";
+   reg = <0x1211 0x100>;
+   interrupts = <20>;
+   clocks = <_ctrl HI3516CV300_APB_CLK>;
+   clock-frequency = <10>;
+};
diff --git a/drivers/i2c/busses/Kconfig b/drivers/i2c/busses/Kconfig
index f167021..6c5d24a 100644
--- a/drivers/i2c/busses/Kconfig
+++ b/drivers/i2c/busses/Kconfig
@@ -552,6 +552,16 @@ config I2C_GPIO
  This is a very simple bitbanging I2C driver utilizing the
  arch-neutral GPIO API to control the SCL and SDA lines.
 
+config I2C_HIBVT
+   tristate "Hisilicon BVT I2C Controller"
+   depends on ARCH_HISI
+   help
+ Say Y here to include support for Hisilicon BVT I2C controller in the
+ Hisilicon BVT SoCs.
+
+ This driver can also be built as a module.  If so, the module
+ will be called i2c-hibvt.
+
 config I2C_HIGHLANDER
tristate "Highlander FPGA SMBus interface"
depends on SH_HIGHLANDER
diff --git a/drivers/i2c/busses/Makefile b/drivers/i2c/busses/Makefile
index 37f2819..42ef2e0 100644
--- a/drivers/i2c/busses/Makefile
+++ b/drivers/i2c/busses/Makefile
@@ -51,6 +51,7 @@ obj-$(CONFIG_I2C_EG20T)   += i2c-eg20t.o
 obj-$(CONFIG_I2C_EMEV2)+= i2c-emev2.o
 obj-$(CONFIG_I2C_EXYNOS5)  += i2c-exynos5.o
 obj-$(CONFIG_I2C_GPIO) += i2c-gpio.o
+obj-$(CONFIG_I2C_HIBVT)+= i2c-hibvt.o
 obj-$(CONFIG_I2C_HIGHLANDER)   += i2c-highlander.o
 obj-$(CONFIG_I2C_HIX5HD2)  += i2c-hix5hd2.o
 obj-$(CONFIG_I2C_IBM_IIC)  += i2c-ibm_iic.o
diff --git a/drivers/i2c/busses/i2c-hibvt.c b/drivers/i2c/busses/i2c-hibvt.c
new file mode 100644
index 000..ce5cf4b
--- /dev/null
+++ b/drivers/i2c/busses/i2c-hibvt.c
@@ -0,0 +1,736 @@
+/*
+ * Hisilicon BVT I2C Controller Driver
+ *
+ * Copyright (c) 2016 HiSilicon Technologies Co., Ltd.
+ *
+ * Authors: wen...@hisilicon.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.
+ *
+ * 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.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+/*
+ * I2C Registers offsets
+ */
+#define HIBVT_I2C_GLB  0x0
+#define HIBVT_I2C_SCL_H0x4
+#define HIBVT_I2C_SCL_L0x8
+#define HIBVT_I2C_DATA10x10
+#define HIBVT_I2C_TXF  0x20
+#define HIBVT_I2C_RXF  0x24
+#define HIBVT_I2C_CMD_BASE 0x30
+#define HIBVT_I2C_LOOP10xb0
+#define HIBVT_I2C_DST1 0xb4
+#define HIBVT_I2C_TX_WATER 0xc8
+#define HIBVT_I2C_RX_WATER 0xcc
+#define HIBVT_I2C_CTRL10xd0
+#define HIBVT_I2C_STAT 0xd8
+#define HIBVT_I2C_INTR_RAW 0xe0
+#define HIBVT_I2C_INTR_EN  0xe4
+#define HIBVT_I2C_INTR_STAT0xe8
+
+/*
+ * I2C Global Config Register -- HIBVT_I2C_GLB
+ */
+#define GLB_EN_MASKBIT(0)
+#define GLB_SDA_HOLD_MASK  GENMASK(23, 8)
+#define GLB_SDA_HOLD_SHIFT (8)
+
+/*
+ * I2C Timing CMD Register -- HIBVT_I2C_CMD_BASE + n * 4 (n = 0

[PATCH v2] i2c: hibvt: add Hisilicon BVT I2C controller driver

2016-07-12 Thread Pan Wen
add Hisilicon BVT I2C controller driver support.

Signed-off-by: Pan Wen 
---
change log
v2:
1)Fixed a compile error.
2)Dropped the clock-names property.
 .../devicetree/bindings/i2c/i2c-hibvt.txt  |  23 +
 drivers/i2c/busses/Kconfig |  10 +
 drivers/i2c/busses/Makefile|   1 +
 drivers/i2c/busses/i2c-hibvt.c | 736 +
 4 files changed, 770 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/i2c/i2c-hibvt.txt
 create mode 100644 drivers/i2c/busses/i2c-hibvt.c

diff --git a/Documentation/devicetree/bindings/i2c/i2c-hibvt.txt 
b/Documentation/devicetree/bindings/i2c/i2c-hibvt.txt
new file mode 100644
index 000..9b88afe
--- /dev/null
+++ b/Documentation/devicetree/bindings/i2c/i2c-hibvt.txt
@@ -0,0 +1,23 @@
+Hisilicon BVT I2C master controller
+
+Required properties:
+- compatible: should be "hisilicon,hibvt-i2c".
+- reg: physical base address of the controller and length of memory mapped.
+ region.
+- interrupts: interrupt number to the cpu.
+- clocks: phandles to input clocks.
+
+Optional properties:
+- clock-frequency: Desired I2C bus frequency in Hz, otherwise defaults to 
10.
+
+Other properties:
+see Documentation/devicetree/bindings/i2c/i2c.txt.
+
+Examples:
+i2c_bus0: i2c@1211 {
+   compatible = "hisilicon,hibvt-i2c";
+   reg = <0x1211 0x100>;
+   interrupts = <20>;
+   clocks = <_ctrl HI3516CV300_APB_CLK>;
+   clock-frequency = <10>;
+};
diff --git a/drivers/i2c/busses/Kconfig b/drivers/i2c/busses/Kconfig
index f167021..6c5d24a 100644
--- a/drivers/i2c/busses/Kconfig
+++ b/drivers/i2c/busses/Kconfig
@@ -552,6 +552,16 @@ config I2C_GPIO
  This is a very simple bitbanging I2C driver utilizing the
  arch-neutral GPIO API to control the SCL and SDA lines.
 
+config I2C_HIBVT
+   tristate "Hisilicon BVT I2C Controller"
+   depends on ARCH_HISI
+   help
+ Say Y here to include support for Hisilicon BVT I2C controller in the
+ Hisilicon BVT SoCs.
+
+ This driver can also be built as a module.  If so, the module
+ will be called i2c-hibvt.
+
 config I2C_HIGHLANDER
tristate "Highlander FPGA SMBus interface"
depends on SH_HIGHLANDER
diff --git a/drivers/i2c/busses/Makefile b/drivers/i2c/busses/Makefile
index 37f2819..42ef2e0 100644
--- a/drivers/i2c/busses/Makefile
+++ b/drivers/i2c/busses/Makefile
@@ -51,6 +51,7 @@ obj-$(CONFIG_I2C_EG20T)   += i2c-eg20t.o
 obj-$(CONFIG_I2C_EMEV2)+= i2c-emev2.o
 obj-$(CONFIG_I2C_EXYNOS5)  += i2c-exynos5.o
 obj-$(CONFIG_I2C_GPIO) += i2c-gpio.o
+obj-$(CONFIG_I2C_HIBVT)+= i2c-hibvt.o
 obj-$(CONFIG_I2C_HIGHLANDER)   += i2c-highlander.o
 obj-$(CONFIG_I2C_HIX5HD2)  += i2c-hix5hd2.o
 obj-$(CONFIG_I2C_IBM_IIC)  += i2c-ibm_iic.o
diff --git a/drivers/i2c/busses/i2c-hibvt.c b/drivers/i2c/busses/i2c-hibvt.c
new file mode 100644
index 000..ce5cf4b
--- /dev/null
+++ b/drivers/i2c/busses/i2c-hibvt.c
@@ -0,0 +1,736 @@
+/*
+ * Hisilicon BVT I2C Controller Driver
+ *
+ * Copyright (c) 2016 HiSilicon Technologies Co., Ltd.
+ *
+ * Authors: wen...@hisilicon.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.
+ *
+ * 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.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+/*
+ * I2C Registers offsets
+ */
+#define HIBVT_I2C_GLB  0x0
+#define HIBVT_I2C_SCL_H0x4
+#define HIBVT_I2C_SCL_L0x8
+#define HIBVT_I2C_DATA10x10
+#define HIBVT_I2C_TXF  0x20
+#define HIBVT_I2C_RXF  0x24
+#define HIBVT_I2C_CMD_BASE 0x30
+#define HIBVT_I2C_LOOP10xb0
+#define HIBVT_I2C_DST1 0xb4
+#define HIBVT_I2C_TX_WATER 0xc8
+#define HIBVT_I2C_RX_WATER 0xcc
+#define HIBVT_I2C_CTRL10xd0
+#define HIBVT_I2C_STAT 0xd8
+#define HIBVT_I2C_INTR_RAW 0xe0
+#define HIBVT_I2C_INTR_EN  0xe4
+#define HIBVT_I2C_INTR_STAT0xe8
+
+/*
+ * I2C Global Config Register -- HIBVT_I2C_GLB
+ */
+#define GLB_EN_MASKBIT(0)
+#define GLB_SDA_HOLD_MASK  GENMASK(23, 8)
+#define GLB_SDA_HOLD_SHIFT (8)
+
+/*
+ * I2C Timing CMD Register -- HIBVT_I2C_CMD_BASE + n * 4 (n = 0, 1, 2, ... 31)
+ */
+#define CMD_

[PATCH] i2c: hibvt: add Hisilicon BVT I2C controller driver

2016-06-22 Thread Pan Wen
add Hisilicon BVT I2C controller driver support.

Signed-off-by: Pan Wen <wen...@hisilicon.com>
---
 .../devicetree/bindings/i2c/i2c-hibvt.txt  |  24 +
 drivers/i2c/busses/Kconfig |  10 +
 drivers/i2c/busses/Makefile|   1 +
 drivers/i2c/busses/i2c-hibvt.c | 736 +
 4 files changed, 771 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/i2c/i2c-hibvt.txt
 create mode 100644 drivers/i2c/busses/i2c-hibvt.c

diff --git a/Documentation/devicetree/bindings/i2c/i2c-hibvt.txt 
b/Documentation/devicetree/bindings/i2c/i2c-hibvt.txt
new file mode 100644
index 000..3aa2cee
--- /dev/null
+++ b/Documentation/devicetree/bindings/i2c/i2c-hibvt.txt
@@ -0,0 +1,24 @@
+Hisilicon BVT I2C master controller
+
+Required properties:
+- compatible: should be "hisilicon,hibvt-i2c".
+- reg: physical base address of the controller and length of memory mapped.
+ region.
+- interrupts: interrupt number to the cpu.
+- clocks: phandles to input clocks.
+
+Optional properties:
+- clock-frequency: Desired I2C bus frequency in Hz, otherwise defaults to 
10.
+
+Other properties:
+see Documentation/devicetree/bindings/i2c/i2c.txt.
+
+Examples:
+i2c_bus0: i2c@1211 {
+   compatible = "hisilicon,hibvt-i2c";
+   reg = <0x1211 0x100>;
+   interrupts = <20>;
+   clocks = <_ctrl HI3516CV300_APB_CLK>;
+   clock-names = "apb_pclk";
+   clock-frequency = <10>;
+};
diff --git a/drivers/i2c/busses/Kconfig b/drivers/i2c/busses/Kconfig
index f167021..fe167e0 100644
--- a/drivers/i2c/busses/Kconfig
+++ b/drivers/i2c/busses/Kconfig
@@ -564,6 +564,16 @@ config I2C_HIGHLANDER
  This driver can also be built as a module.  If so, the module
  will be called i2c-highlander.
 
+config I2C_HIBVT
+   tristate "Hisilicon BVT I2C Controller"
+   depends on ARCH_HISI
+   help
+ Say Y here to include support for Hisilicon BVT I2C controller in the
+ Hisilicon BVT SoCs.
+
+ This driver can also be built as a module.  If so, the module
+ will be called i2c-hibvt.
+
 config I2C_IBM_IIC
tristate "IBM PPC 4xx on-chip I2C interface"
depends on 4xx
diff --git a/drivers/i2c/busses/Makefile b/drivers/i2c/busses/Makefile
index 37f2819..37a6f6e 100644
--- a/drivers/i2c/busses/Makefile
+++ b/drivers/i2c/busses/Makefile
@@ -118,5 +118,6 @@ obj-$(CONFIG_I2C_PCA_ISA)   += i2c-pca-isa.o
 obj-$(CONFIG_I2C_SIBYTE)   += i2c-sibyte.o
 obj-$(CONFIG_I2C_XGENE_SLIMPRO) += i2c-xgene-slimpro.o
 obj-$(CONFIG_SCx200_ACB)   += scx200_acb.o
+obj-$(CONFIG_I2C_HIBVT)+= i2c-hibvt.o
 
 ccflags-$(CONFIG_I2C_DEBUG_BUS) := -DDEBUG
diff --git a/drivers/i2c/busses/i2c-hibvt.c b/drivers/i2c/busses/i2c-hibvt.c
new file mode 100644
index 000..18de3cf
--- /dev/null
+++ b/drivers/i2c/busses/i2c-hibvt.c
@@ -0,0 +1,736 @@
+/*
+ * Hisilicon BVT I2C Controller Driver
+ *
+ * Copyright (c) 2016 HiSilicon Technologies Co., Ltd.
+ *
+ * Authors: wen...@hisilicon.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.
+ *
+ * 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.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+/*
+ * I2C Registers offsets
+ */
+#define HIBVT_I2C_GLB  0x0
+#define HIBVT_I2C_SCL_H0x4
+#define HIBVT_I2C_SCL_L0x8
+#define HIBVT_I2C_DATA10x10
+#define HIBVT_I2C_TXF  0x20
+#define HIBVT_I2C_RXF  0x24
+#define HIBVT_I2C_CMD_BASE 0x30
+#define HIBVT_I2C_LOOP10xb0
+#define HIBVT_I2C_DST1 0xb4
+#define HIBVT_I2C_TX_WATER 0xc8
+#define HIBVT_I2C_RX_WATER 0xcc
+#define HIBVT_I2C_CTRL10xd0
+#define HIBVT_I2C_STAT 0xd8
+#define HIBVT_I2C_INTR_RAW 0xe0
+#define HIBVT_I2C_INTR_EN  0xe4
+#define HIBVT_I2C_INTR_STAT0xe8
+
+/*
+ * I2C Global Config Register -- HIBVT_I2C_GLB
+ */
+#define GLB_EN_MASKBIT(0)
+#define GLB_SDA_HOLD_MASK  GENMASK(23, 8)
+#define GLB_SDA_HOLD_SHIFT (8)
+
+/*
+ * I2C Timing CMD Register -- HIBVT_I2C_CMD_BASE + n * 4 (n = 0, 1, 2, ... 31)
+ */
+#define CMD_EXIT   0x0
+#define CMD_TX_S   0x1
+#define CMD_TX_D1_20x4
+#define CMD_TX_D1_10x5
+#define CMD_TX_FIFO0x9
+#define CMD_RX_FIFO

[PATCH] i2c: hibvt: add Hisilicon BVT I2C controller driver

2016-06-22 Thread Pan Wen
add Hisilicon BVT I2C controller driver support.

Signed-off-by: Pan Wen 
---
 .../devicetree/bindings/i2c/i2c-hibvt.txt  |  24 +
 drivers/i2c/busses/Kconfig |  10 +
 drivers/i2c/busses/Makefile|   1 +
 drivers/i2c/busses/i2c-hibvt.c | 736 +
 4 files changed, 771 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/i2c/i2c-hibvt.txt
 create mode 100644 drivers/i2c/busses/i2c-hibvt.c

diff --git a/Documentation/devicetree/bindings/i2c/i2c-hibvt.txt 
b/Documentation/devicetree/bindings/i2c/i2c-hibvt.txt
new file mode 100644
index 000..3aa2cee
--- /dev/null
+++ b/Documentation/devicetree/bindings/i2c/i2c-hibvt.txt
@@ -0,0 +1,24 @@
+Hisilicon BVT I2C master controller
+
+Required properties:
+- compatible: should be "hisilicon,hibvt-i2c".
+- reg: physical base address of the controller and length of memory mapped.
+ region.
+- interrupts: interrupt number to the cpu.
+- clocks: phandles to input clocks.
+
+Optional properties:
+- clock-frequency: Desired I2C bus frequency in Hz, otherwise defaults to 
10.
+
+Other properties:
+see Documentation/devicetree/bindings/i2c/i2c.txt.
+
+Examples:
+i2c_bus0: i2c@1211 {
+   compatible = "hisilicon,hibvt-i2c";
+   reg = <0x1211 0x100>;
+   interrupts = <20>;
+   clocks = <_ctrl HI3516CV300_APB_CLK>;
+   clock-names = "apb_pclk";
+   clock-frequency = <10>;
+};
diff --git a/drivers/i2c/busses/Kconfig b/drivers/i2c/busses/Kconfig
index f167021..fe167e0 100644
--- a/drivers/i2c/busses/Kconfig
+++ b/drivers/i2c/busses/Kconfig
@@ -564,6 +564,16 @@ config I2C_HIGHLANDER
  This driver can also be built as a module.  If so, the module
  will be called i2c-highlander.
 
+config I2C_HIBVT
+   tristate "Hisilicon BVT I2C Controller"
+   depends on ARCH_HISI
+   help
+ Say Y here to include support for Hisilicon BVT I2C controller in the
+ Hisilicon BVT SoCs.
+
+ This driver can also be built as a module.  If so, the module
+ will be called i2c-hibvt.
+
 config I2C_IBM_IIC
tristate "IBM PPC 4xx on-chip I2C interface"
depends on 4xx
diff --git a/drivers/i2c/busses/Makefile b/drivers/i2c/busses/Makefile
index 37f2819..37a6f6e 100644
--- a/drivers/i2c/busses/Makefile
+++ b/drivers/i2c/busses/Makefile
@@ -118,5 +118,6 @@ obj-$(CONFIG_I2C_PCA_ISA)   += i2c-pca-isa.o
 obj-$(CONFIG_I2C_SIBYTE)   += i2c-sibyte.o
 obj-$(CONFIG_I2C_XGENE_SLIMPRO) += i2c-xgene-slimpro.o
 obj-$(CONFIG_SCx200_ACB)   += scx200_acb.o
+obj-$(CONFIG_I2C_HIBVT)+= i2c-hibvt.o
 
 ccflags-$(CONFIG_I2C_DEBUG_BUS) := -DDEBUG
diff --git a/drivers/i2c/busses/i2c-hibvt.c b/drivers/i2c/busses/i2c-hibvt.c
new file mode 100644
index 000..18de3cf
--- /dev/null
+++ b/drivers/i2c/busses/i2c-hibvt.c
@@ -0,0 +1,736 @@
+/*
+ * Hisilicon BVT I2C Controller Driver
+ *
+ * Copyright (c) 2016 HiSilicon Technologies Co., Ltd.
+ *
+ * Authors: wen...@hisilicon.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.
+ *
+ * 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.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+/*
+ * I2C Registers offsets
+ */
+#define HIBVT_I2C_GLB  0x0
+#define HIBVT_I2C_SCL_H0x4
+#define HIBVT_I2C_SCL_L0x8
+#define HIBVT_I2C_DATA10x10
+#define HIBVT_I2C_TXF  0x20
+#define HIBVT_I2C_RXF  0x24
+#define HIBVT_I2C_CMD_BASE 0x30
+#define HIBVT_I2C_LOOP10xb0
+#define HIBVT_I2C_DST1 0xb4
+#define HIBVT_I2C_TX_WATER 0xc8
+#define HIBVT_I2C_RX_WATER 0xcc
+#define HIBVT_I2C_CTRL10xd0
+#define HIBVT_I2C_STAT 0xd8
+#define HIBVT_I2C_INTR_RAW 0xe0
+#define HIBVT_I2C_INTR_EN  0xe4
+#define HIBVT_I2C_INTR_STAT0xe8
+
+/*
+ * I2C Global Config Register -- HIBVT_I2C_GLB
+ */
+#define GLB_EN_MASKBIT(0)
+#define GLB_SDA_HOLD_MASK  GENMASK(23, 8)
+#define GLB_SDA_HOLD_SHIFT (8)
+
+/*
+ * I2C Timing CMD Register -- HIBVT_I2C_CMD_BASE + n * 4 (n = 0, 1, 2, ... 31)
+ */
+#define CMD_EXIT   0x0
+#define CMD_TX_S   0x1
+#define CMD_TX_D1_20x4
+#define CMD_TX_D1_10x5
+#define CMD_TX_FIFO0x9
+#define CMD_RX_FIFO0x12
+#define CMD_RX