linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v3 0/4] Add hi6220 media subsystem reset controller driver
@ 2016-06-20  3:50 Xinliang Liu
  2016-06-20  3:50 ` [PATCH v3 1/4] reset: hisilicon: Add media reset controller binding Xinliang Liu
                   ` (3 more replies)
  0 siblings, 4 replies; 7+ messages in thread
From: Xinliang Liu @ 2016-06-20  3:50 UTC (permalink / raw)
  To: p.zabel
  Cc: linux-kernel, robh+dt, xuwei5, puck.chen, saberlily.xia,
	kong.kongxinwei, guodong.xu, Xinliang Liu

This patch set adds support for HiSilicon hi6220 SoC media subsystem
reset controller.

Change history:
v3:
- Split regmap register access change and mediactrl support.

v2:
- Update binding document for media reset controller.
- Separate peripheral and media reset controller ops.

Chen Feng (1):
  reset: hisilicon: Change to syscon register access

Xinliang Liu (3):
  reset: hisilicon: Add media reset controller binding
  arm64: dts: hi6220: Add media subsystem reset dts
  reset: hisilicon: Add hi6220 media subsystem reset support

 .../bindings/reset/hisilicon,hi6220-reset.txt      |   4 +-
 arch/arm64/boot/dts/hisilicon/hi6220.dtsi          |   2 +
 drivers/reset/hisilicon/hi6220_reset.c             | 122 +++++++++++++++------
 include/dt-bindings/reset/hisi,hi6220-resets.h     |   8 ++
 4 files changed, 99 insertions(+), 37 deletions(-)

-- 
2.8.3

^ permalink raw reply	[flat|nested] 7+ messages in thread

* [PATCH v3 1/4] reset: hisilicon: Add media reset controller binding
  2016-06-20  3:50 [PATCH v3 0/4] Add hi6220 media subsystem reset controller driver Xinliang Liu
@ 2016-06-20  3:50 ` Xinliang Liu
  2016-06-20 12:07   ` Philipp Zabel
  2016-06-20  3:50 ` [PATCH v3 2/4] arm64: dts: hi6220: Add media subsystem reset dts Xinliang Liu
                   ` (2 subsequent siblings)
  3 siblings, 1 reply; 7+ messages in thread
From: Xinliang Liu @ 2016-06-20  3:50 UTC (permalink / raw)
  To: p.zabel
  Cc: linux-kernel, robh+dt, xuwei5, puck.chen, saberlily.xia,
	kong.kongxinwei, guodong.xu, Xinliang Liu

Add compatible for media reset controller.

Actually, there are two reset controllers in hi6220 SoC:
The peripheral reset controller bits are part of sysctrl registers.
The media reset controller bits are part of mediactrl registers.
So for the compatible part, it should contain "syscon" for both peripheral
and media reset controller.

Signed-off-by: Xinliang Liu <xinliang.liu@linaro.org>
---
 Documentation/devicetree/bindings/reset/hisilicon,hi6220-reset.txt | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/Documentation/devicetree/bindings/reset/hisilicon,hi6220-reset.txt b/Documentation/devicetree/bindings/reset/hisilicon,hi6220-reset.txt
index e0b185a944ba..c25da39df707 100644
--- a/Documentation/devicetree/bindings/reset/hisilicon,hi6220-reset.txt
+++ b/Documentation/devicetree/bindings/reset/hisilicon,hi6220-reset.txt
@@ -8,7 +8,9 @@ The reset controller registers are part of the system-ctl block on
 hi6220 SoC.
 
 Required properties:
-- compatible: may be "hisilicon,hi6220-sysctrl"
+- compatible: should be one of the following:
+  - "hisilicon,hi6220-sysctrl", "syscon" : For peripheral reset controller.
+  - "hisilicon,hi6220-mediactrl", "syscon" : For media reset controller.
 - reg: should be register base and length as documented in the
   datasheet
 - #reset-cells: 1, see below
-- 
2.8.3

^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [PATCH v3 2/4] arm64: dts: hi6220: Add media subsystem reset dts
  2016-06-20  3:50 [PATCH v3 0/4] Add hi6220 media subsystem reset controller driver Xinliang Liu
  2016-06-20  3:50 ` [PATCH v3 1/4] reset: hisilicon: Add media reset controller binding Xinliang Liu
@ 2016-06-20  3:50 ` Xinliang Liu
  2016-06-20  3:50 ` [PATCH v3 3/4] reset: hisilicon: Change to syscon register access Xinliang Liu
  2016-06-20  3:50 ` [PATCH v3 4/4] reset: hisilicon: Add hi6220 media subsystem reset support Xinliang Liu
  3 siblings, 0 replies; 7+ messages in thread
From: Xinliang Liu @ 2016-06-20  3:50 UTC (permalink / raw)
  To: p.zabel
  Cc: linux-kernel, robh+dt, xuwei5, puck.chen, saberlily.xia,
	kong.kongxinwei, guodong.xu, Xinliang Liu

Add media subsystem reset dts support.

Signed-off-by: Chen Feng <puck.chen@hisilicon.com>
Signed-off-by: Xinliang Liu <xinliang.liu@linaro.org>
---
 arch/arm64/boot/dts/hisilicon/hi6220.dtsi      | 2 ++
 include/dt-bindings/reset/hisi,hi6220-resets.h | 8 ++++++++
 2 files changed, 10 insertions(+)

diff --git a/arch/arm64/boot/dts/hisilicon/hi6220.dtsi b/arch/arm64/boot/dts/hisilicon/hi6220.dtsi
index 189d21541f9c..c19b82799a34 100644
--- a/arch/arm64/boot/dts/hisilicon/hi6220.dtsi
+++ b/arch/arm64/boot/dts/hisilicon/hi6220.dtsi
@@ -5,6 +5,7 @@
  */
 
 #include <dt-bindings/interrupt-controller/arm-gic.h>
+#include <dt-bindings/reset/hisi,hi6220-resets.h>
 #include <dt-bindings/clock/hi6220-clock.h>
 #include <dt-bindings/pinctrl/hisi.h>
 #include <dt-bindings/thermal/thermal.h>
@@ -252,6 +253,7 @@
 			compatible = "hisilicon,hi6220-mediactrl", "syscon";
 			reg = <0x0 0xf4410000 0x0 0x1000>;
 			#clock-cells = <1>;
+			#reset-cells = <1>;
 		};
 
 		pm_ctrl: pm_ctrl@f7032000 {
diff --git a/include/dt-bindings/reset/hisi,hi6220-resets.h b/include/dt-bindings/reset/hisi,hi6220-resets.h
index ca08a7e5248e..322ec5335b65 100644
--- a/include/dt-bindings/reset/hisi,hi6220-resets.h
+++ b/include/dt-bindings/reset/hisi,hi6220-resets.h
@@ -64,4 +64,12 @@
 #define PERIPH_RSDIST9_CARM_SOCDBG      0x507
 #define PERIPH_RSDIST9_CARM_ETM         0x508
 
+#define MEDIA_G3D                       0
+#define MEDIA_CODEC_VPU                 2
+#define MEDIA_CODEC_JPEG                3
+#define MEDIA_ISP                       4
+#define MEDIA_ADE                       5
+#define MEDIA_MMU                       6
+#define MEDIA_XG2RAM1                   7
+
 #endif /*_DT_BINDINGS_RESET_CONTROLLER_HI6220*/
-- 
2.8.3

^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [PATCH v3 3/4] reset: hisilicon: Change to syscon register access
  2016-06-20  3:50 [PATCH v3 0/4] Add hi6220 media subsystem reset controller driver Xinliang Liu
  2016-06-20  3:50 ` [PATCH v3 1/4] reset: hisilicon: Add media reset controller binding Xinliang Liu
  2016-06-20  3:50 ` [PATCH v3 2/4] arm64: dts: hi6220: Add media subsystem reset dts Xinliang Liu
@ 2016-06-20  3:50 ` Xinliang Liu
  2016-06-20  3:50 ` [PATCH v3 4/4] reset: hisilicon: Add hi6220 media subsystem reset support Xinliang Liu
  3 siblings, 0 replies; 7+ messages in thread
From: Xinliang Liu @ 2016-06-20  3:50 UTC (permalink / raw)
  To: p.zabel
  Cc: linux-kernel, robh+dt, xuwei5, puck.chen, saberlily.xia,
	kong.kongxinwei, guodong.xu, Xinliang Liu

From: Chen Feng <puck.chen@hisilicon.com>

There are two reset controllers in hi6220 SoC:
The peripheral reset controller bits are part of sysctrl registers.
The media reset controller bits are part of mediactrl registers.

So change register access to syscon way.
And rename current reset controller to peripheral one.

Signed-off-by: Chen Feng <puck.chen@hisilicon.com>
Signed-off-by: Xia Qing <saberlily.xia@hisilicon.com>
Signed-off-by: Xinliang Liu <xinliang.liu@linaro.org>
---
 drivers/reset/hisilicon/hi6220_reset.c | 85 ++++++++++++++++++----------------
 1 file changed, 45 insertions(+), 40 deletions(-)

diff --git a/drivers/reset/hisilicon/hi6220_reset.c b/drivers/reset/hisilicon/hi6220_reset.c
index 8f55fd4a2630..686fea9e2c54 100644
--- a/drivers/reset/hisilicon/hi6220_reset.c
+++ b/drivers/reset/hisilicon/hi6220_reset.c
@@ -1,7 +1,8 @@
 /*
  * Hisilicon Hi6220 reset controller driver
  *
- * Copyright (c) 2015 Hisilicon Limited.
+ * Copyright (c) 2016 Linaro Limited.
+ * Copyright (c) 2015-2016 Hisilicon Limited.
  *
  * Author: Feng Chen <puck.chen@hisilicon.com>
  *
@@ -15,81 +16,85 @@
 #include <linux/module.h>
 #include <linux/bitops.h>
 #include <linux/of.h>
+#include <linux/of_device.h>
+#include <linux/regmap.h>
+#include <linux/mfd/syscon.h>
 #include <linux/reset-controller.h>
 #include <linux/reset.h>
 #include <linux/platform_device.h>
 
-#define ASSERT_OFFSET            0x300
-#define DEASSERT_OFFSET          0x304
-#define MAX_INDEX                0x509
+#define PERIPH_ASSERT_OFFSET      0x300
+#define PERIPH_DEASSERT_OFFSET    0x304
+#define PERIPH_MAX_INDEX          0x509
 
 #define to_reset_data(x) container_of(x, struct hi6220_reset_data, rc_dev)
 
 struct hi6220_reset_data {
-	void __iomem			*assert_base;
-	void __iomem			*deassert_base;
-	struct reset_controller_dev	rc_dev;
+	struct reset_controller_dev rc_dev;
+	struct regmap *regmap;
 };
 
-static int hi6220_reset_assert(struct reset_controller_dev *rc_dev,
-			       unsigned long idx)
+static int hi6220_peripheral_assert(struct reset_controller_dev *rc_dev,
+				    unsigned long idx)
 {
 	struct hi6220_reset_data *data = to_reset_data(rc_dev);
+	struct regmap *regmap = data->regmap;
+	u32 bank = idx >> 8;
+	u32 offset = idx & 0xff;
+	u32 reg = PERIPH_ASSERT_OFFSET + bank * 0x10;
 
-	int bank = idx >> 8;
-	int offset = idx & 0xff;
-
-	writel(BIT(offset), data->assert_base + (bank * 0x10));
-
-	return 0;
+	return regmap_write(regmap, reg, BIT(offset));
 }
 
-static int hi6220_reset_deassert(struct reset_controller_dev *rc_dev,
-				 unsigned long idx)
+static int hi6220_peripheral_deassert(struct reset_controller_dev *rc_dev,
+				      unsigned long idx)
 {
 	struct hi6220_reset_data *data = to_reset_data(rc_dev);
+	struct regmap *regmap = data->regmap;
+	u32 bank = idx >> 8;
+	u32 offset = idx & 0xff;
+	u32 reg = PERIPH_DEASSERT_OFFSET + bank * 0x10;
 
-	int bank = idx >> 8;
-	int offset = idx & 0xff;
-
-	writel(BIT(offset), data->deassert_base + (bank * 0x10));
-
-	return 0;
+	return regmap_write(regmap, reg, BIT(offset));
 }
 
-static const struct reset_control_ops hi6220_reset_ops = {
-	.assert = hi6220_reset_assert,
-	.deassert = hi6220_reset_deassert,
+static const struct reset_control_ops hi6220_peripheral_reset_ops = {
+	.assert = hi6220_peripheral_assert,
+	.deassert = hi6220_peripheral_deassert,
 };
 
 static int hi6220_reset_probe(struct platform_device *pdev)
 {
+	struct device_node *np = pdev->dev.of_node;
+	struct device *dev = &pdev->dev;
 	struct hi6220_reset_data *data;
-	struct resource *res;
-	void __iomem *src_base;
+	struct regmap *regmap;
 
-	data = devm_kzalloc(&pdev->dev, sizeof(*data), GFP_KERNEL);
+	data = devm_kzalloc(dev, sizeof(*data), GFP_KERNEL);
 	if (!data)
 		return -ENOMEM;
 
-	res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
-	src_base = devm_ioremap_resource(&pdev->dev, res);
-	if (IS_ERR(src_base))
-		return PTR_ERR(src_base);
+	regmap = syscon_node_to_regmap(np);
+	if (IS_ERR(regmap)) {
+		dev_err(dev, "failed to get reset controller regmap\n");
+		return PTR_ERR(regmap);
+	}
 
-	data->assert_base = src_base + ASSERT_OFFSET;
-	data->deassert_base = src_base + DEASSERT_OFFSET;
-	data->rc_dev.nr_resets = MAX_INDEX;
-	data->rc_dev.ops = &hi6220_reset_ops;
-	data->rc_dev.of_node = pdev->dev.of_node;
+	data->regmap = regmap;
+	data->rc_dev.of_node = np;
+	data->rc_dev.ops = &hi6220_peripheral_reset_ops;
+	data->rc_dev.nr_resets = PERIPH_MAX_INDEX;
 
 	return reset_controller_register(&data->rc_dev);
 }
 
 static const struct of_device_id hi6220_reset_match[] = {
-	{ .compatible = "hisilicon,hi6220-sysctrl" },
-	{ },
+	{
+		.compatible = "hisilicon,hi6220-sysctrl",
+	},
+	{ /* sentinel */ },
 };
+MODULE_DEVICE_TABLE(of, hi6220_reset_match);
 
 static struct platform_driver hi6220_reset_driver = {
 	.probe = hi6220_reset_probe,
-- 
2.8.3

^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [PATCH v3 4/4] reset: hisilicon: Add hi6220 media subsystem reset support
  2016-06-20  3:50 [PATCH v3 0/4] Add hi6220 media subsystem reset controller driver Xinliang Liu
                   ` (2 preceding siblings ...)
  2016-06-20  3:50 ` [PATCH v3 3/4] reset: hisilicon: Change to syscon register access Xinliang Liu
@ 2016-06-20  3:50 ` Xinliang Liu
  3 siblings, 0 replies; 7+ messages in thread
From: Xinliang Liu @ 2016-06-20  3:50 UTC (permalink / raw)
  To: p.zabel
  Cc: linux-kernel, robh+dt, xuwei5, puck.chen, saberlily.xia,
	kong.kongxinwei, guodong.xu, Xinliang Liu

Add hi6220 media subsystem reset controller.

Signed-off-by: Chen Feng <puck.chen@hisilicon.com>
Signed-off-by: Xia Qing <saberlily.xia@hisilicon.com>
Signed-off-by: Xinliang Liu <xinliang.liu@linaro.org>
---
 drivers/reset/hisilicon/hi6220_reset.c | 49 ++++++++++++++++++++++++++++++++--
 1 file changed, 47 insertions(+), 2 deletions(-)

diff --git a/drivers/reset/hisilicon/hi6220_reset.c b/drivers/reset/hisilicon/hi6220_reset.c
index 686fea9e2c54..35ce53edabf9 100644
--- a/drivers/reset/hisilicon/hi6220_reset.c
+++ b/drivers/reset/hisilicon/hi6220_reset.c
@@ -27,8 +27,17 @@
 #define PERIPH_DEASSERT_OFFSET    0x304
 #define PERIPH_MAX_INDEX          0x509
 
+#define SC_MEDIA_RSTEN            0x052C
+#define SC_MEDIA_RSTDIS           0x0530
+#define MEDIA_MAX_INDEX           8
+
 #define to_reset_data(x) container_of(x, struct hi6220_reset_data, rc_dev)
 
+enum hi6220_reset_ctrl_type {
+	PERIPHERAL,
+	MEDIA,
+};
+
 struct hi6220_reset_data {
 	struct reset_controller_dev rc_dev;
 	struct regmap *regmap;
@@ -63,10 +72,34 @@ static const struct reset_control_ops hi6220_peripheral_reset_ops = {
 	.deassert = hi6220_peripheral_deassert,
 };
 
+static int hi6220_media_assert(struct reset_controller_dev *rc_dev,
+			       unsigned long idx)
+{
+	struct hi6220_reset_data *data = to_reset_data(rc_dev);
+	struct regmap *regmap = data->regmap;
+
+	return regmap_write(regmap, SC_MEDIA_RSTEN, BIT(idx));
+}
+
+static int hi6220_media_deassert(struct reset_controller_dev *rc_dev,
+				 unsigned long idx)
+{
+	struct hi6220_reset_data *data = to_reset_data(rc_dev);
+	struct regmap *regmap = data->regmap;
+
+	return regmap_write(regmap, SC_MEDIA_RSTDIS, BIT(idx));
+}
+
+static const struct reset_control_ops hi6220_media_reset_ops = {
+	.assert = hi6220_media_assert,
+	.deassert = hi6220_media_deassert,
+};
+
 static int hi6220_reset_probe(struct platform_device *pdev)
 {
 	struct device_node *np = pdev->dev.of_node;
 	struct device *dev = &pdev->dev;
+	enum hi6220_reset_ctrl_type type;
 	struct hi6220_reset_data *data;
 	struct regmap *regmap;
 
@@ -74,6 +107,8 @@ static int hi6220_reset_probe(struct platform_device *pdev)
 	if (!data)
 		return -ENOMEM;
 
+	type = (enum hi6220_reset_ctrl_type)of_device_get_match_data(dev);
+
 	regmap = syscon_node_to_regmap(np);
 	if (IS_ERR(regmap)) {
 		dev_err(dev, "failed to get reset controller regmap\n");
@@ -82,8 +117,13 @@ static int hi6220_reset_probe(struct platform_device *pdev)
 
 	data->regmap = regmap;
 	data->rc_dev.of_node = np;
-	data->rc_dev.ops = &hi6220_peripheral_reset_ops;
-	data->rc_dev.nr_resets = PERIPH_MAX_INDEX;
+	if (type == MEDIA) {
+		data->rc_dev.ops = &hi6220_media_reset_ops;
+		data->rc_dev.nr_resets = MEDIA_MAX_INDEX;
+	} else {
+		data->rc_dev.ops = &hi6220_peripheral_reset_ops;
+		data->rc_dev.nr_resets = PERIPH_MAX_INDEX;
+	}
 
 	return reset_controller_register(&data->rc_dev);
 }
@@ -91,6 +131,11 @@ static int hi6220_reset_probe(struct platform_device *pdev)
 static const struct of_device_id hi6220_reset_match[] = {
 	{
 		.compatible = "hisilicon,hi6220-sysctrl",
+		.data = (void *)PERIPHERAL,
+	},
+	{
+		.compatible = "hisilicon,hi6220-mediactrl",
+		.data = (void *)MEDIA,
 	},
 	{ /* sentinel */ },
 };
-- 
2.8.3

^ permalink raw reply related	[flat|nested] 7+ messages in thread

* Re: [PATCH v3 1/4] reset: hisilicon: Add media reset controller binding
  2016-06-20  3:50 ` [PATCH v3 1/4] reset: hisilicon: Add media reset controller binding Xinliang Liu
@ 2016-06-20 12:07   ` Philipp Zabel
  2016-06-20 13:55     ` Xinliang Liu
  0 siblings, 1 reply; 7+ messages in thread
From: Philipp Zabel @ 2016-06-20 12:07 UTC (permalink / raw)
  To: Xinliang Liu
  Cc: linux-kernel, robh+dt, xuwei5, puck.chen, saberlily.xia,
	kong.kongxinwei, guodong.xu

Am Montag, den 20.06.2016, 11:50 +0800 schrieb Xinliang Liu:
>  
>  Required properties:
> -- compatible: may be "hisilicon,hi6220-sysctrl"
> +- compatible: should be one of the following:
> +  - "hisilicon,hi6220-sysctrl", "syscon" : For peripheral reset controller.
> +  - "hisilicon,hi6220-mediactrl", "syscon" : For media reset controller.
>  - reg: should be register base and length as documented in the
>    datasheet
>  - #reset-cells: 1, see below

Thanks, I've applied all four patches to my reset/next branch.

You should eventually add the "syscon" compatible where it is still
missing in Documentation/devicetree/bindings/arm/hisilicon/hisilicon.txt
and Documentation/devicetree/bindings/clock/hi6220-clock.txt.

regards
Philipp

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH v3 1/4] reset: hisilicon: Add media reset controller binding
  2016-06-20 12:07   ` Philipp Zabel
@ 2016-06-20 13:55     ` Xinliang Liu
  0 siblings, 0 replies; 7+ messages in thread
From: Xinliang Liu @ 2016-06-20 13:55 UTC (permalink / raw)
  To: Philipp Zabel
  Cc: Linux Kernel Mailing List, Rob Herring, Xu Wei, Feng Chen,
	Xia Qing, XinWei Kong, Guodong Xu

On 20 June 2016 at 20:07, Philipp Zabel <p.zabel@pengutronix.de> wrote:
> Am Montag, den 20.06.2016, 11:50 +0800 schrieb Xinliang Liu:
>>
>>  Required properties:
>> -- compatible: may be "hisilicon,hi6220-sysctrl"
>> +- compatible: should be one of the following:
>> +  - "hisilicon,hi6220-sysctrl", "syscon" : For peripheral reset controller.
>> +  - "hisilicon,hi6220-mediactrl", "syscon" : For media reset controller.
>>  - reg: should be register base and length as documented in the
>>    datasheet
>>  - #reset-cells: 1, see below
>
> Thanks, I've applied all four patches to my reset/next branch.

Thanks, Philipp.

>
> You should eventually add the "syscon" compatible where it is still
> missing in Documentation/devicetree/bindings/arm/hisilicon/hisilicon.txt
> and Documentation/devicetree/bindings/clock/hi6220-clock.txt.

Will add the missing patches at other thread.

Thanks,
-xinliang

>
> regards
> Philipp
>

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2016-06-20 14:03 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-06-20  3:50 [PATCH v3 0/4] Add hi6220 media subsystem reset controller driver Xinliang Liu
2016-06-20  3:50 ` [PATCH v3 1/4] reset: hisilicon: Add media reset controller binding Xinliang Liu
2016-06-20 12:07   ` Philipp Zabel
2016-06-20 13:55     ` Xinliang Liu
2016-06-20  3:50 ` [PATCH v3 2/4] arm64: dts: hi6220: Add media subsystem reset dts Xinliang Liu
2016-06-20  3:50 ` [PATCH v3 3/4] reset: hisilicon: Change to syscon register access Xinliang Liu
2016-06-20  3:50 ` [PATCH v3 4/4] reset: hisilicon: Add hi6220 media subsystem reset support Xinliang Liu

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).