[linux-sunxi] [PATCH v7 2/8] pwm: sun4i: Add an optional probe for reset line

2019-11-19 Thread Clément Péron
From: Jernej Skrabec 

H6 PWM core needs deasserted reset line in order to work.

Add an optional probe for it.

Signed-off-by: Jernej Skrabec 
Reviewed-by: Uwe Kleine-König 
Signed-off-by: Clément Péron 
---
 drivers/pwm/pwm-sun4i.c | 33 +++--
 1 file changed, 31 insertions(+), 2 deletions(-)

diff --git a/drivers/pwm/pwm-sun4i.c b/drivers/pwm/pwm-sun4i.c
index 581d23287333..c17935805690 100644
--- a/drivers/pwm/pwm-sun4i.c
+++ b/drivers/pwm/pwm-sun4i.c
@@ -16,6 +16,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -78,6 +79,7 @@ struct sun4i_pwm_data {
 struct sun4i_pwm_chip {
struct pwm_chip chip;
struct clk *clk;
+   struct reset_control *rst;
void __iomem *base;
spinlock_t ctrl_lock;
const struct sun4i_pwm_data *data;
@@ -364,6 +366,21 @@ static int sun4i_pwm_probe(struct platform_device *pdev)
if (IS_ERR(pwm->clk))
return PTR_ERR(pwm->clk);
 
+   pwm->rst = devm_reset_control_get_optional_shared(&pdev->dev, NULL);
+   if (IS_ERR(pwm->rst)) {
+   if (PTR_ERR(pwm->rst) != -EPROBE_DEFER)
+   dev_err(&pdev->dev, "get reset failed %pe\n",
+   pwm->rst);
+   return PTR_ERR(pwm->rst);
+   }
+
+   /* Deassert reset */
+   ret = reset_control_deassert(pwm->rst);
+   if (ret) {
+   dev_err(&pdev->dev, "Cannot deassert reset control\n");
+   return ret;
+   }
+
pwm->chip.dev = &pdev->dev;
pwm->chip.ops = &sun4i_pwm_ops;
pwm->chip.base = -1;
@@ -376,19 +393,31 @@ static int sun4i_pwm_probe(struct platform_device *pdev)
ret = pwmchip_add(&pwm->chip);
if (ret < 0) {
dev_err(&pdev->dev, "failed to add PWM chip: %d\n", ret);
-   return ret;
+   goto err_pwm_add;
}
 
platform_set_drvdata(pdev, pwm);
 
return 0;
+
+err_pwm_add:
+   reset_control_assert(pwm->rst);
+
+   return ret;
 }
 
 static int sun4i_pwm_remove(struct platform_device *pdev)
 {
struct sun4i_pwm_chip *pwm = platform_get_drvdata(pdev);
+   int ret;
+
+   ret = pwmchip_remove(&pwm->chip);
+   if (ret)
+   return ret;
+
+   reset_control_assert(pwm->rst);
 
-   return pwmchip_remove(&pwm->chip);
+   return 0;
 }
 
 static struct platform_driver sun4i_pwm_driver = {
-- 
2.20.1

-- 
You received this message because you are subscribed to the Google Groups 
"linux-sunxi" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to linux-sunxi+unsubscr...@googlegroups.com.
To view this discussion on the web, visit 
https://groups.google.com/d/msgid/linux-sunxi/20191119175319.16561-3-peron.clem%40gmail.com.


[linux-sunxi] [PATCH v7 7/8] arm64: dts: allwinner: h6: Add PWM node

2019-11-19 Thread Clément Péron
From: Jernej Skrabec 

Allwinner H6 PWM is similar to that in A20 except that it has additional
bus clock and reset line.

Note that first PWM channel is connected to output pin and second
channel is used internally, as a clock source to AC200 co-packaged chip.
This means that any combination of these two channels can be used and
thus it doesn't make sense to add pinctrl nodes at this point.

Signed-off-by: Jernej Skrabec 
Signed-off-by: Clément Péron 
---
 arch/arm64/boot/dts/allwinner/sun50i-h6.dtsi | 10 ++
 1 file changed, 10 insertions(+)

diff --git a/arch/arm64/boot/dts/allwinner/sun50i-h6.dtsi 
b/arch/arm64/boot/dts/allwinner/sun50i-h6.dtsi
index 29824081b43b..6d4bde488f15 100644
--- a/arch/arm64/boot/dts/allwinner/sun50i-h6.dtsi
+++ b/arch/arm64/boot/dts/allwinner/sun50i-h6.dtsi
@@ -245,6 +245,16 @@
status = "disabled";
};
 
+   pwm: pwm@300a000 {
+   compatible = "allwinner,sun50i-h6-pwm";
+   reg = <0x0300a000 0x400>;
+   clocks = <&osc24M>, <&ccu CLK_BUS_PWM>;
+   clock-names = "mod", "bus";
+   resets = <&ccu RST_BUS_PWM>;
+   #pwm-cells = <3>;
+   status = "disabled";
+   };
+
pio: pinctrl@300b000 {
compatible = "allwinner,sun50i-h6-pinctrl";
reg = <0x0300b000 0x400>;
-- 
2.20.1

-- 
You received this message because you are subscribed to the Google Groups 
"linux-sunxi" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to linux-sunxi+unsubscr...@googlegroups.com.
To view this discussion on the web, visit 
https://groups.google.com/d/msgid/linux-sunxi/20191119175319.16561-8-peron.clem%40gmail.com.


[linux-sunxi] [PATCH v7 4/8] pwm: sun4i: Add an optional probe for bus clock

2019-11-19 Thread Clément Péron
From: Jernej Skrabec 

H6 PWM core needs bus clock to be enabled in order to work.

Add an optional probe for it.

Signed-off-by: Jernej Skrabec 
Signed-off-by: Clément Péron 
---
 drivers/pwm/pwm-sun4i.c | 22 ++
 1 file changed, 22 insertions(+)

diff --git a/drivers/pwm/pwm-sun4i.c b/drivers/pwm/pwm-sun4i.c
index 6d97fef4ed43..ce83d479ba0e 100644
--- a/drivers/pwm/pwm-sun4i.c
+++ b/drivers/pwm/pwm-sun4i.c
@@ -78,6 +78,7 @@ struct sun4i_pwm_data {
 
 struct sun4i_pwm_chip {
struct pwm_chip chip;
+   struct clk *bus_clk;
struct clk *clk;
struct reset_control *rst;
void __iomem *base;
@@ -391,6 +392,14 @@ static int sun4i_pwm_probe(struct platform_device *pdev)
}
}
 
+   pwm->bus_clk = devm_clk_get_optional(&pdev->dev, "bus");
+   if (IS_ERR(pwm->bus_clk)) {
+   if (PTR_ERR(pwm->rst) != -EPROBE_DEFER)
+   dev_err(&pdev->dev, "get bus clock failed %pe\n",
+   pwm->bus_clk);
+   return PTR_ERR(pwm->bus_clk);
+   }
+
pwm->rst = devm_reset_control_get_optional_shared(&pdev->dev, NULL);
if (IS_ERR(pwm->rst)) {
if (PTR_ERR(pwm->rst) != -EPROBE_DEFER)
@@ -406,6 +415,16 @@ static int sun4i_pwm_probe(struct platform_device *pdev)
return ret;
}
 
+   /*
+* We're keeping the bus clock on for the sake of simplicity.
+* Actually it only needs to be on for hardware register accesses.
+*/
+   ret = clk_prepare_enable(pwm->bus_clk);
+   if (ret) {
+   dev_err(&pdev->dev, "Cannot prepare and enable bus_clk\n");
+   goto err_bus;
+   }
+
pwm->chip.dev = &pdev->dev;
pwm->chip.ops = &sun4i_pwm_ops;
pwm->chip.base = -1;
@@ -426,6 +445,8 @@ static int sun4i_pwm_probe(struct platform_device *pdev)
return 0;
 
 err_pwm_add:
+   clk_disable_unprepare(pwm->bus_clk);
+err_bus:
reset_control_assert(pwm->rst);
 
return ret;
@@ -440,6 +461,7 @@ static int sun4i_pwm_remove(struct platform_device *pdev)
if (ret)
return ret;
 
+   clk_disable_unprepare(pwm->bus_clk);
reset_control_assert(pwm->rst);
 
return 0;
-- 
2.20.1

-- 
You received this message because you are subscribed to the Google Groups 
"linux-sunxi" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to linux-sunxi+unsubscr...@googlegroups.com.
To view this discussion on the web, visit 
https://groups.google.com/d/msgid/linux-sunxi/20191119175319.16561-5-peron.clem%40gmail.com.


[linux-sunxi] [PATCH v7 8/8] [DO NOT MERGE] arm64: allwinner: h6: enable Beelink GS1 PWM

2019-11-19 Thread Clément Péron
Signed-off-by: Clément Péron 
---
 arch/arm64/boot/dts/allwinner/sun50i-h6-beelink-gs1.dts | 4 
 1 file changed, 4 insertions(+)

diff --git a/arch/arm64/boot/dts/allwinner/sun50i-h6-beelink-gs1.dts 
b/arch/arm64/boot/dts/allwinner/sun50i-h6-beelink-gs1.dts
index f335f7482a73..cf684bc7374d 100644
--- a/arch/arm64/boot/dts/allwinner/sun50i-h6-beelink-gs1.dts
+++ b/arch/arm64/boot/dts/allwinner/sun50i-h6-beelink-gs1.dts
@@ -136,6 +136,10 @@
vcc-pg-supply = <®_aldo1>;
 };
 
+&pwm {
+   status = "okay";
+};
+
 &r_i2c {
status = "okay";
 
-- 
2.20.1

-- 
You received this message because you are subscribed to the Google Groups 
"linux-sunxi" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to linux-sunxi+unsubscr...@googlegroups.com.
To view this discussion on the web, visit 
https://groups.google.com/d/msgid/linux-sunxi/20191119175319.16561-9-peron.clem%40gmail.com.


[linux-sunxi] [PATCH v2] sun8i: h3: Support H3 variant of Orange Pi Zero Plus 2

2019-11-19 Thread Diego Rondini
Orangepi Zero Plus 2 is an open-source single-board computer, available
in two Allwinner SOC variants, H3 and H5. We add support for H3 variant
here, as the H5 is already supported.

H3 Orangepi Zero Plus 2 has:
- Quad-core Cortex-A7
- 512MB DDR3
- microSD slot and 8GB eMMC
- Debug TTL UART
- HDMI
- Wifi + BT
- OTG + power supply

Sync dts from linux v5.2 commit:
"ARM: dts: sunxi: h3/h5: Remove stale pinctrl-names entry"
(sha1: 75f9a058838be9880afd75c4cb14e1bf4fe34a0b)
Commit:
"ARM: dts: sun8i: h3: Refactor the pinctrl node names"
(sha1: a4dc791974e568a15f7f37131729b1a6912f4811)
has been avoided as it breaks U-Boot build.

Signed-off-by: Diego Rondini 
---
Changes in v2:
- clarify where the dts comes from
---
 arch/arm/dts/Makefile |   3 +-
 arch/arm/dts/sun8i-h3-orangepi-zero-plus2.dts | 139 ++
 board/sunxi/MAINTAINERS   |   5 +
 configs/orangepi_zero_plus2_h3_defconfig  |  19 +++
 4 files changed, 165 insertions(+), 1 deletion(-)
 create mode 100644 arch/arm/dts/sun8i-h3-orangepi-zero-plus2.dts
 create mode 100644 configs/orangepi_zero_plus2_h3_defconfig

diff --git a/arch/arm/dts/Makefile b/arch/arm/dts/Makefile
index d8846df1bd..fc6d66ddab 100644
--- a/arch/arm/dts/Makefile
+++ b/arch/arm/dts/Makefile
@@ -522,7 +522,8 @@ dtb-$(CONFIG_MACH_SUN8I_H3) += \
sun8i-h3-orangepi-pc.dtb \
sun8i-h3-orangepi-pc-plus.dtb \
sun8i-h3-orangepi-plus.dtb \
-   sun8i-h3-orangepi-plus2e.dtb
+   sun8i-h3-orangepi-plus2e.dtb \
+   sun8i-h3-orangepi-zero-plus2.dtb
 dtb-$(CONFIG_MACH_SUN8I_R40) += \
sun8i-r40-bananapi-m2-ultra.dtb \
sun8i-v40-bananapi-m2-berry.dtb
diff --git a/arch/arm/dts/sun8i-h3-orangepi-zero-plus2.dts 
b/arch/arm/dts/sun8i-h3-orangepi-zero-plus2.dts
new file mode 100644
index 00..f2f7b7a925
--- /dev/null
+++ b/arch/arm/dts/sun8i-h3-orangepi-zero-plus2.dts
@@ -0,0 +1,139 @@
+/*
+ * Copyright (C) 2017 Jagan Teki 
+ * Copyright (C) 2018 Diego Rondini 
+ *
+ * This file is dual-licensed: you can use it either under the terms
+ * of the GPL or the X11 license, at your option. Note that this dual
+ * licensing only applies to this file, and not this project as a
+ * whole.
+ *
+ *  a) This file 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 file 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.
+ *
+ * Or, alternatively,
+ *
+ *  b) Permission is hereby granted, free of charge, to any person
+ * obtaining a copy of this software and associated documentation
+ * files (the "Software"), to deal in the Software without
+ * restriction, including without limitation the rights to use,
+ * copy, modify, merge, publish, distribute, sublicense, and/or
+ * sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following
+ * conditions:
+ *
+ * The above copyright notice and this permission notice shall be
+ * included in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
+ * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
+ * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+ * OTHER DEALINGS IN THE SOFTWARE.
+ */
+
+/dts-v1/;
+
+#include "sun8i-h3.dtsi"
+
+#include 
+
+/ {
+   model = "OrangePi Zero Plus2 H3";
+   compatible = "xunlong,orangepi-zero-plus2-h3", "allwinner,sun8i-h3";
+
+   aliases {
+   serial0 = &uart0;
+   };
+
+   chosen {
+   stdout-path = "serial0:115200n8";
+   };
+
+   connector {
+   compatible = "hdmi-connector";
+   type = "a";
+
+   port {
+   hdmi_con_in: endpoint {
+   remote-endpoint = <&hdmi_out_con>;
+   };
+   };
+   };
+
+   reg_vcc3v3: vcc3v3 {
+   compatible = "regulator-fixed";
+   regulator-name = "vcc3v3";
+   regulator-min-microvolt = <330>;
+   regulator-max-microvolt = <330>;
+   };
+
+   wifi_pwrseq: wifi_pwrseq {
+   compatible = "mmc-pwrseq-simple";
+   reset-gpios = <&pio 0 9 GPIO_ACTIVE_LOW>; /* PA9 */
+  

Re: [linux-sunxi] [PATCH] sun8i: h3: Support H3 variant of Orange Pi Zero Plus 2

2019-11-19 Thread Jagan Teki
On Wed, Nov 6, 2019 at 3:28 AM Diego Rondini  wrote:
>
> Orangepi Zero Plus 2 is an open-source single-board computer, available
> in two Allwinner SOC variants, H3 and H5. We add support for H3 variant
> here, as the H5 is already supported.
>
> H3 Orangepi Zero Plus 2 has:
> - Quad-core Cortex-A7
> - 512MB DDR3
> - microSD slot and 8GB eMMC
> - Debug TTL UART
> - HDMI
> - Wifi + BT
> - OTG + power supply
>
> Signed-off-by: Diego Rondini 
> ---

Add linux commit details on above commit message.

-- 
You received this message because you are subscribed to the Google Groups 
"linux-sunxi" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to linux-sunxi+unsubscr...@googlegroups.com.
To view this discussion on the web, visit 
https://groups.google.com/d/msgid/linux-sunxi/CAMty3ZBCYUrtfNwVCKSx%3Dos6DM3HO7Cc2j0ND5NAtUEvgvG0Ew%40mail.gmail.com.


[linux-sunxi] Re: [PATCH 1/1] net: sun8i_emac: Remove debug message

2019-11-19 Thread Jagan Teki
On Mon, Nov 4, 2019 at 3:13 PM Stefan Mavrodiev  wrote:
>
> When booting with sun8i_emac driver, the user get output like this:
>
>   ...
>   Net:   phy interface7
>   eth0: ethernet@1c3
>   ...
>
> The first line doesn't provide any useful information except for the
> developers. I guess this is some leftover debugging message. This
> patch change it to such. The new output is:
>
>   ...
>   Net:   eth0: ethernet@1c3
>   ...
>
> Signed-off-by: Stefan Mavrodiev 
> ---

Applied to u-boot-sunxi/master

-- 
You received this message because you are subscribed to the Google Groups 
"linux-sunxi" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to linux-sunxi+unsubscr...@googlegroups.com.
To view this discussion on the web, visit 
https://groups.google.com/d/msgid/linux-sunxi/CAMty3ZDSwG0UTY4n52HYaLVf_hb35YnLNzzsgUTNnu%2B-zpUiRg%40mail.gmail.com.