meson64 linux 5.8 (#2176)

This commit is contained in:
m][sko 2020-09-01 12:59:15 +02:00 committed by GitHub
parent 5a24dad1e7
commit a486772fc8
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
86 changed files with 8884 additions and 2 deletions

View file

@ -32,7 +32,7 @@ case $BRANCH in
KERNELPATCHDIR='meson64-current'
;;
dev)
KERNELBRANCH='branch:linux-5.7.y'
KERNELBRANCH='branch:linux-5.8.y'
KERNELPATCHDIR='meson64-dev'
;;

View file

@ -1 +0,0 @@
meson64-current

View file

@ -0,0 +1,162 @@
From d6b58cbc9e7ba9a4e9ebe63507c9adc0bcd1fb25 Mon Sep 17 00:00:00 2001
From: Igor Pecovnik <igor.pecovnik@gmail.com>
Date: Tue, 4 Aug 2020 23:05:28 +0200
Subject: [PATCH] Add Odroid N2 plus
Signed-off-by: Igor Pecovnik <igor.pecovnik@gmail.com>
---
arch/arm64/boot/dts/amlogic/Makefile | 1 +
.../dts/amlogic/meson-g12b-odroid-n2-plus.dts | 129 ++++++++++++++++++
2 files changed, 130 insertions(+)
create mode 100644 arch/arm64/boot/dts/amlogic/meson-g12b-odroid-n2-plus.dts
diff --git a/arch/arm64/boot/dts/amlogic/Makefile b/arch/arm64/boot/dts/amlogic/Makefile
index 37bf75df9..a1534a4ba 100644
--- a/arch/arm64/boot/dts/amlogic/Makefile
+++ b/arch/arm64/boot/dts/amlogic/Makefile
@@ -6,6 +6,7 @@ dtb-$(CONFIG_ARCH_MESON) += meson-g12a-x96-max.dtb
dtb-$(CONFIG_ARCH_MESON) += meson-g12b-a311d-khadas-vim3.dtb
dtb-$(CONFIG_ARCH_MESON) += meson-g12b-s922x-khadas-vim3.dtb
dtb-$(CONFIG_ARCH_MESON) += meson-g12b-odroid-n2.dtb
+dtb-$(CONFIG_ARCH_MESON) += meson-g12b-odroid-n2-plus.dtb
dtb-$(CONFIG_ARCH_MESON) += meson-g12b-ugoos-am6.dtb
dtb-$(CONFIG_ARCH_MESON) += meson-gxbb-kii-pro.dtb
dtb-$(CONFIG_ARCH_MESON) += meson-gxbb-nanopi-k2.dtb
diff --git a/arch/arm64/boot/dts/amlogic/meson-g12b-odroid-n2-plus.dts b/arch/arm64/boot/dts/amlogic/meson-g12b-odroid-n2-plus.dts
new file mode 100644
index 000000000..e5c2c0465
--- /dev/null
+++ b/arch/arm64/boot/dts/amlogic/meson-g12b-odroid-n2-plus.dts
@@ -0,0 +1,129 @@
+// SPDX-License-Identifier: (GPL-2.0+ OR MIT)
+/*
+ * Copyright (c) 2020 Dongjin Kim <tobetter@gmail.com>
+ * Adjusted igor@armbian.com
+ */
+
+/dts-v1/;
+
+#include "meson-g12b-odroid-n2.dts"
+
+/ {
+ model = "Hardkernel ODROID-N2Plus";
+};
+
+&vddcpu_a {
+ regulator-min-microvolt = <680000>;
+ regulator-max-microvolt = <1040000>;
+
+ pwms = <&pwm_ab 0 1500 0>;
+};
+
+&vddcpu_b {
+ regulator-min-microvolt = <680000>;
+ regulator-max-microvolt = <1040000>;
+
+ pwms = <&pwm_AO_cd 1 1500 0>;
+};
+
+&cpu_opp_table_0 {
+ /delete-node/ opp-100000000;
+ /delete-node/ opp-250000000;
+ /delete-node/ opp-500000000;
+ /delete-node/ opp-667000000;
+ opp-1000000000 {
+ opp-hz = /bits/ 64 <1000000000>;
+ opp-microvolt = <760000>;
+ };
+ opp-1200000000 {
+ opp-hz = /bits/ 64 <1200000000>;
+ opp-microvolt = <780000>;
+ };
+ opp-1398000000 {
+ opp-hz = /bits/ 64 <1398000000>;
+ opp-microvolt = <810000>;
+ };
+ opp-1512000000 {
+ opp-hz = /bits/ 64 <1512000000>;
+ opp-microvolt = <860000>;
+ };
+ opp-1608000000 {
+ opp-hz = /bits/ 64 <1608000000>;
+ opp-microvolt = <900000>;
+ };
+ opp-1704000000 {
+ opp-hz = /bits/ 64 <1704000000>;
+ opp-microvolt = <960000>;
+ };
+ opp-1800000000 {
+ opp-hz = /bits/ 64 <1800000000>;
+ opp-microvolt = <1020000>;
+ };
+ opp-1908000000 {
+ opp-hz = /bits/ 64 <1908000000>;
+ opp-microvolt = <1030000>;
+ };
+ opp-2016000000 {
+ opp-hz = /bits/ 64 <2016000000>;
+ opp-microvolt = <1040000>;
+ };
+};
+
+&cpub_opp_table_1 {
+ /delete-node/ opp-100000000;
+ /delete-node/ opp-250000000;
+ /delete-node/ opp-500000000;
+ /delete-node/ opp-667000000;
+ opp-1000000000 {
+ opp-hz = /bits/ 64 <1000000000>;
+ opp-microvolt = <730000>;
+ };
+ opp-1200000000 {
+ opp-hz = /bits/ 64 <1200000000>;
+ opp-microvolt = <750000>;
+ };
+ opp-1398000000 {
+ opp-hz = /bits/ 64 <1398000000>;
+ opp-microvolt = <770000>;
+ };
+ opp-1512000000 {
+ opp-hz = /bits/ 64 <1512000000>;
+ opp-microvolt = <770000>;
+ };
+ opp-1608000000 {
+ opp-hz = /bits/ 64 <1608000000>;
+ opp-microvolt = <780000>;
+ };
+ opp-1704000000 {
+ opp-hz = /bits/ 64 <1704000000>;
+ opp-microvolt = <790000>;
+ };
+ opp-1800000000 {
+ opp-hz = /bits/ 64 <1800000000>;
+ opp-microvolt = <830000>;
+ };
+ opp-1908000000 {
+ opp-hz = /bits/ 64 <1908000000>;
+ opp-microvolt = <860000>;
+ };
+ opp-2016000000 {
+ opp-hz = /bits/ 64 <2016000000>;
+ opp-microvolt = <910000>;
+ };
+ opp-2100000000 {
+ opp-hz = /bits/ 64 <2100000000>;
+ opp-microvolt = <960000>;
+ };
+ opp-2208000000 {
+ opp-hz = /bits/ 64 <2208000000>;
+ opp-microvolt = <1030000>;
+ };
+ opp-2304000000 {
+ opp-hz = /bits/ 64 <2304000000>;
+ opp-microvolt = <1030000>;
+ };
+ opp-2400000000 {
+ opp-hz = /bits/ 64 <2400000000>;
+ opp-microvolt = <1040000>;
+ };
+};
--
Created with Armbian build tools https://github.com/armbian/build

View file

@ -0,0 +1,34 @@
From a11802ecb5686153614aa19a089900c22928988c Mon Sep 17 00:00:00 2001
From: Igor Pecovnik <igor.pecovnik@gmail.com>
Date: Tue, 4 Aug 2020 22:51:56 +0200
Subject: [PATCH] Add higher clocks for SM1 family
Signed-off-by: Igor Pecovnik <igor.pecovnik@gmail.com>
---
arch/arm64/boot/dts/amlogic/meson-sm1.dtsi | 10 ++++++++++
1 file changed, 10 insertions(+)
diff --git a/arch/arm64/boot/dts/amlogic/meson-sm1.dtsi b/arch/arm64/boot/dts/amlogic/meson-sm1.dtsi
index d4ec735fb..a35cad1d4 100644
--- a/arch/arm64/boot/dts/amlogic/meson-sm1.dtsi
+++ b/arch/arm64/boot/dts/amlogic/meson-sm1.dtsi
@@ -150,6 +150,16 @@ opp-1908000000 {
opp-hz = /bits/ 64 <1908000000>;
opp-microvolt = <950000>;
};
+
+ opp-2016000000 {
+ opp-hz = /bits/ 64 <2016000000>;
+ opp-microvolt = <1000000>;
+ };
+
+ opp-2100000000 {
+ opp-hz = /bits/ 64 <2100000000>;
+ opp-microvolt = <1022000>;
+ };
};
};
--
Created with Armbian build tools https://github.com/armbian/build

View file

@ -0,0 +1,72 @@
From 61043fd422307935e5c026bfa92638cac747ad55 Mon Sep 17 00:00:00 2001
From: tonymac32 <tonymckahan@gmail.com>
Date: Sun, 19 Jul 2020 01:03:51 -0400
Subject: [PATCH] revert ASoC: soc-pcm: dpcm: fix playback/capture checks
Signed-off-by: tonymac32 <tonymckahan@gmail.com>
---
sound/soc/soc-pcm.c | 44 ++++++++++----------------------------------
1 file changed, 10 insertions(+), 34 deletions(-)
diff --git a/sound/soc/soc-pcm.c b/sound/soc/soc-pcm.c
index fde097a7a..3b909533f 100644
--- a/sound/soc/soc-pcm.c
+++ b/sound/soc/soc-pcm.c
@@ -2908,44 +2908,20 @@ int soc_new_pcm(struct snd_soc_pcm_runtime *rtd, int num)
struct snd_pcm *pcm;
char new_name[64];
int ret = 0, playback = 0, capture = 0;
- int stream;
int i;
- if (rtd->dai_link->dynamic && rtd->num_cpus > 1) {
- dev_err(rtd->dev,
- "DPCM doesn't support Multi CPU for Front-Ends yet\n");
- return -EINVAL;
- }
-
if (rtd->dai_link->dynamic || rtd->dai_link->no_pcm) {
- if (rtd->dai_link->dpcm_playback) {
- stream = SNDRV_PCM_STREAM_PLAYBACK;
-
- for_each_rtd_cpu_dais(rtd, i, cpu_dai)
- if (!snd_soc_dai_stream_valid(cpu_dai,
- stream)) {
- dev_err(rtd->card->dev,
- "CPU DAI %s for rtd %s does not support playback\n",
- cpu_dai->name,
- rtd->dai_link->stream_name);
- return -EINVAL;
- }
- playback = 1;
- }
- if (rtd->dai_link->dpcm_capture) {
- stream = SNDRV_PCM_STREAM_CAPTURE;
-
- for_each_rtd_cpu_dais(rtd, i, cpu_dai)
- if (!snd_soc_dai_stream_valid(cpu_dai,
- stream)) {
- dev_err(rtd->card->dev,
- "CPU DAI %s for rtd %s does not support capture\n",
- cpu_dai->name,
- rtd->dai_link->stream_name);
- return -EINVAL;
- }
- capture = 1;
+ cpu_dai = asoc_rtd_to_cpu(rtd, 0);
+ if (rtd->num_cpus > 1) {
+ dev_err(rtd->dev,
+ "DPCM doesn't support Multi CPU yet\n");
+ return -EINVAL;
}
+
+ playback = rtd->dai_link->dpcm_playback &&
+ snd_soc_dai_stream_valid(cpu_dai, SNDRV_PCM_STREAM_PLAYBACK);
+ capture = rtd->dai_link->dpcm_capture &&
+ snd_soc_dai_stream_valid(cpu_dai, SNDRV_PCM_STREAM_CAPTURE);
} else {
/* Adapt stream for codec2codec links */
int cpu_capture = rtd->dai_link->params ?
--
Created with Armbian build tools https://github.com/armbian/build

View file

@ -0,0 +1,58 @@
From ff40d6a1ec6c9d661232d99ecb8e3a3409add62d Mon Sep 17 00:00:00 2001
From: Neil Armstrong <narmstrong@baylibre.com>
Date: Thu, 16 Apr 2020 08:31:55 +0000
Subject: [PATCH 09/40] HACK: mmc: core: always re-init sdcards to set default
3.3v regulator ios
sd-uhs-** in device-tree changes the voltage to 1.8v, so we need to ensure
the card is reset to 3.3v before rebooting else on reboot there is no card
to boot from.
Signed-off-by: Neil Armstrong <narmstrong@baylibre.com>
---
drivers/mmc/core/sd.c | 22 +++++++++++++++++++++-
1 file changed, 21 insertions(+), 1 deletion(-)
diff --git a/drivers/mmc/core/sd.c b/drivers/mmc/core/sd.c
index 5a2210c25aa7..6499ab41195b 100644
--- a/drivers/mmc/core/sd.c
+++ b/drivers/mmc/core/sd.c
@@ -1215,6 +1215,26 @@ static int mmc_sd_suspend(struct mmc_host *host)
return err;
}
+/*
+ * Callback for shutdown
+ */
+static int mmc_sd_shutdown(struct mmc_host *host)
+{
+ mmc_claim_host(host);
+
+ if (mmc_card_suspended(host->card))
+ goto out;
+
+ mmc_power_off(host);
+ mmc_card_set_suspended(host->card);
+
+ pm_runtime_disable(&host->card->dev);
+ pm_runtime_set_suspended(&host->card->dev);
+
+out:
+ return 0;
+}
+
/*
* This function tries to determine if the same card is still present
* and, if so, restore all state to it.
@@ -1293,7 +1313,7 @@ static const struct mmc_bus_ops mmc_sd_ops = {
.suspend = mmc_sd_suspend,
.resume = mmc_sd_resume,
.alive = mmc_sd_alive,
- .shutdown = mmc_sd_suspend,
+ .shutdown = mmc_sd_shutdown,
.hw_reset = mmc_sd_hw_reset,
};
--
2.25.1

View file

@ -0,0 +1,38 @@
From bb440ae7b97aa966416e305405fbab9c7ec83bf3 Mon Sep 17 00:00:00 2001
From: Jerome Brunet <jbrunet@baylibre.com>
Date: Fri, 15 Feb 2019 14:21:27 +0100
Subject: [PATCH 031/101] WIP: clk: meson: g12a: fix gp0 and hifi ranges
While some SoC samples are able to lock with a PLL factor of 55, others
samples can't. ATM, a minimum of 60 appears to work on all the samples
I have tried.
Even with 60, it sometimes takes a long time for the PLL to eventually
lock. The documentation says that the minimum rate of these PLLs DCO
should be 3GHz, a factor of 125. Let's use that to be on the safe side.
With factor range changed, the PLL seems to lock quickly (enough) so far.
It is still unclear if the range was the only reason for the delay.
Fixes: 085a4ea93d54 ("clk: meson: g12a: add peripheral clock controller")
Signed-off-by: Jerome Brunet <jbrunet@baylibre.com>
---
drivers/clk/meson/g12a.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/clk/meson/g12a.c b/drivers/clk/meson/g12a.c
index d2760a021301..cd1de3e004e4 100644
--- a/drivers/clk/meson/g12a.c
+++ b/drivers/clk/meson/g12a.c
@@ -1591,7 +1591,7 @@ static struct clk_regmap g12b_cpub_clk_trace = {
};
static const struct pll_mult_range g12a_gp0_pll_mult_range = {
- .min = 55,
+ .min = 125,
.max = 255,
};
--
2.17.1

View file

@ -0,0 +1,70 @@
From 8c7bb37959ab80afc7a646f539817f9a2adfb85a Mon Sep 17 00:00:00 2001
From: Nick Xie <nick@khadas.com>
Date: Tue, 25 Aug 2020 10:11:50 +0800
Subject: [PATCH 39/40] Revert "usb: dwc3: meson-g12a: fix shared reset control
use"
This reverts commit 7a410953d1fb4dbe91ffcfdee9cbbf889d19b0d7.
---
drivers/usb/dwc3/dwc3-meson-g12a.c | 15 ++++++---------
1 file changed, 6 insertions(+), 9 deletions(-)
diff --git a/drivers/usb/dwc3/dwc3-meson-g12a.c b/drivers/usb/dwc3/dwc3-meson-g12a.c
index 88b75b5a039c..1f7f4d88ed9d 100644
--- a/drivers/usb/dwc3/dwc3-meson-g12a.c
+++ b/drivers/usb/dwc3/dwc3-meson-g12a.c
@@ -737,13 +737,13 @@ static int dwc3_meson_g12a_probe(struct platform_device *pdev)
goto err_disable_clks;
}
- ret = reset_control_deassert(priv->reset);
+ ret = reset_control_reset(priv->reset);
if (ret)
- goto err_assert_reset;
+ goto err_disable_clks;
ret = dwc3_meson_g12a_get_phys(priv);
if (ret)
- goto err_assert_reset;
+ goto err_disable_clks;
ret = priv->drvdata->setup_regmaps(priv, base);
if (ret)
@@ -752,7 +752,7 @@ static int dwc3_meson_g12a_probe(struct platform_device *pdev)
if (priv->vbus) {
ret = regulator_enable(priv->vbus);
if (ret)
- goto err_assert_reset;
+ goto err_disable_clks;
}
/* Get dr_mode */
@@ -765,13 +765,13 @@ static int dwc3_meson_g12a_probe(struct platform_device *pdev)
ret = priv->drvdata->usb_init(priv);
if (ret)
- goto err_assert_reset;
+ goto err_disable_clks;
/* Init PHYs */
for (i = 0 ; i < PHY_COUNT ; ++i) {
ret = phy_init(priv->phys[i]);
if (ret)
- goto err_assert_reset;
+ goto err_disable_clks;
}
/* Set PHY Power */
@@ -809,9 +809,6 @@ static int dwc3_meson_g12a_probe(struct platform_device *pdev)
for (i = 0 ; i < PHY_COUNT ; ++i)
phy_exit(priv->phys[i]);
-err_assert_reset:
- reset_control_assert(priv->reset);
-
err_disable_clks:
clk_bulk_disable_unprepare(priv->drvdata->num_clks,
priv->drvdata->clks);
--
2.25.1

View file

@ -0,0 +1,109 @@
From 86a08466dd986507bbd4d609d2d81d9bfc300999 Mon Sep 17 00:00:00 2001
From: Christian Hewitt <christianshewitt@gmail.com>
Date: Tue, 18 Feb 2020 03:54:58 +0000
Subject: [PATCH 051/101] WIP: arm64: dts: meson: add audio playback to
s905x-p212 dtsi
Signed-off-by: Christian Hewitt <christianshewitt@gmail.com>
---
.../dts/amlogic/meson-gxl-s905x-p212.dtsi | 70 +++++++++++++++++++
1 file changed, 70 insertions(+)
diff --git a/arch/arm64/boot/dts/amlogic/meson-gxl-s905x-p212.dtsi b/arch/arm64/boot/dts/amlogic/meson-gxl-s905x-p212.dtsi
index 43eb7d149e36..ba74f54c5b3f 100644
--- a/arch/arm64/boot/dts/amlogic/meson-gxl-s905x-p212.dtsi
+++ b/arch/arm64/boot/dts/amlogic/meson-gxl-s905x-p212.dtsi
@@ -11,6 +11,7 @@
/* Common DTSI for devices which are based on the P212 reference board. */
#include "meson-gxl-s905x.dtsi"
+#include <dt-bindings/sound/meson-aiu.h>
/ {
aliases {
@@ -23,6 +24,13 @@
stdout-path = "serial0:115200n8";
};
+ dio2133: analog-amplifier {
+ compatible = "simple-audio-amplifier";
+ sound-name-prefix = "AU2";
+ VCC-supply = <&hdmi_5v>;
+ enable-gpios = <&gpio GPIOH_5 GPIO_ACTIVE_HIGH>;
+ };
+
memory@0 {
device_type = "memory";
reg = <0x0 0x0 0x0 0x80000000>;
@@ -86,6 +94,68 @@
clocks = <&wifi32k>;
clock-names = "ext_clock";
};
+
+ sound {
+ compatible = "amlogic,gx-sound-card";
+ model = "GX-SOUND-CARD";
+ audio-aux-devs = <&dio2133>;
+ audio-widgets = "Line", "Lineout";
+ audio-routing = "AU2 INL", "ACODEC LOLN",
+ "AU2 INR", "ACODEC LORN",
+ "Lineout", "AU2 OUTL",
+ "Lineout", "AU2 OUTR";
+ assigned-clocks = <&clkc CLKID_MPLL2>,
+ <&clkc CLKID_MPLL0>,
+ <&clkc CLKID_MPLL1>;
+ assigned-clock-parents = <0>, <0>, <0>;
+ assigned-clock-rates = <294912000>,
+ <270950400>,
+ <393216000>;
+ status = "okay";
+
+ dai-link-0 {
+ sound-dai = <&aiu AIU_CPU CPU_I2S_FIFO>;
+ };
+
+ dai-link-1 {
+ sound-dai = <&aiu AIU_CPU CPU_I2S_ENCODER>;
+ dai-format = "i2s";
+ mclk-fs = <512>;
+
+ codec-0 {
+ sound-dai = <&aiu AIU_HDMI CTRL_I2S>;
+ };
+
+ codec-1 {
+ sound-dai = <&aiu AIU_ACODEC CTRL_I2S>;
+ };
+ };
+
+ dai-link-2 {
+ sound-dai = <&aiu AIU_HDMI CTRL_OUT>;
+
+ codec-0 {
+ sound-dai = <&hdmi_tx>;
+ };
+ };
+
+ dai-link-3 {
+ sound-dai = <&aiu AIU_ACODEC CTRL_OUT>;
+
+ codec-0 {
+ sound-dai = <&acodec>;
+ };
+ };
+ };
+};
+
+&acodec {
+ AVDD-supply = <&vddio_ao18>;
+ status = "okay";
+};
+
+&aiu {
+ status = "okay";
};
&ethmac {
--
2.17.1

View file

@ -0,0 +1,48 @@
From f31c2092f357f1c7ec4931418dc6dfa849c45b81 Mon Sep 17 00:00:00 2001
From: Christian Hewitt <christianshewitt@gmail.com>
Date: Tue, 18 Feb 2020 12:23:31 +0000
Subject: [PATCH 053/101] WIP: arm64: dts: meson-gxbb: add playback audio
devices
Signed-off-by: Christian Hewitt <christianshewitt@gmail.com>
---
arch/arm64/boot/dts/amlogic/meson-gxbb.dtsi | 23 +++++++++++++++++++++
1 file changed, 23 insertions(+)
diff --git a/arch/arm64/boot/dts/amlogic/meson-gxbb.dtsi b/arch/arm64/boot/dts/amlogic/meson-gxbb.dtsi
index 0cb40326b0d3..ccaa1a8e28c5 100644
--- a/arch/arm64/boot/dts/amlogic/meson-gxbb.dtsi
+++ b/arch/arm64/boot/dts/amlogic/meson-gxbb.dtsi
@@ -241,6 +241,29 @@
};
};
+&aiu {
+ compatible = "amlogic,aiu-gxbb", "amlogic,aiu";
+ clocks = <&clkc CLKID_AIU_GLUE>,
+ <&clkc CLKID_I2S_OUT>,
+ <&clkc CLKID_AOCLK_GATE>,
+ <&clkc CLKID_CTS_AMCLK>,
+ <&clkc CLKID_MIXER_IFACE>,
+ <&clkc CLKID_IEC958>,
+ <&clkc CLKID_IEC958_GATE>,
+ <&clkc CLKID_CTS_MCLK_I958>,
+ <&clkc CLKID_CTS_I958>;
+ clock-names = "pclk",
+ "i2s_pclk",
+ "i2s_aoclk",
+ "i2s_mclk",
+ "i2s_mixer",
+ "spdif_pclk",
+ "spdif_aoclk",
+ "spdif_mclk",
+ "spdif_mclk_sel";
+ resets = <&reset RESET_AIU>;
+};
+
&apb {
mali: gpu@c0000 {
compatible = "amlogic,meson-gxbb-mali", "arm,mali-450";
--
2.17.1

View file

@ -0,0 +1,40 @@
From 03bfb3f6a703d7671508b698c5a552d0a0e0197b Mon Sep 17 00:00:00 2001
From: Christian Hewitt <christianshewitt@gmail.com>
Date: Tue, 7 Jan 2020 07:12:47 +0000
Subject: [PATCH 055/101] HACK: media: cec: silence CEC timeout message
If testing with an AVR that does not pass-through CEC state the system
log fills with timeout messages. Silence this to stop the log rotation
and ensure other issues are visible.
[ 42.718009] cec-meson_ao_cec: message ff 84 50 00 01 timed out
[ 45.021994] cec-meson_ao_cec: message ff 87 00 15 82 timed out
[ 47.325965] cec-meson_ao_cec: message 10 timed out
[ 49.630023] cec-meson_ao_cec: message 10 timed out
[ 51.933960] cec-meson_ao_cec: message 10 timed out
Signed-off-by: Christian Hewitt <christianshewitt@gmail.com>
---
drivers/media/cec/core/cec-adap.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/drivers/media/cec/core/cec-adap.c b/drivers/media/cec/core/cec-adap.c
index 6c95dc471d4c..8613cc93eb93 100644
--- a/drivers/media/cec/core/cec-adap.c
+++ b/drivers/media/cec/core/cec-adap.c
@@ -510,9 +510,9 @@ int cec_thread_func(void *_adap)
* unable to transmit for CEC_XFER_TIMEOUT_MS (2.1s).
*/
if (adap->transmitting) {
- pr_warn("cec-%s: message %*ph timed out\n", adap->name,
- adap->transmitting->msg.len,
- adap->transmitting->msg.msg);
+ //pr_warn("cec-%s: message %*ph timed out\n", adap->name,
+ // adap->transmitting->msg.len,
+ // adap->transmitting->msg.msg);
/* Just give up on this. */
cec_data_cancel(adap->transmitting,
CEC_TX_STATUS_TIMEOUT);
--
2.17.1

View file

@ -0,0 +1,112 @@
From 4430c1295e48c617757c1293b1b3457928162ab9 Mon Sep 17 00:00:00 2001
From: chewitt <christianshewitt@gmail.com>
Date: Thu, 12 Dec 2019 13:48:45 +0000
Subject: [PATCH 056/101] HACK: revert mm: emit tracepoint when RSS changes
---
include/linux/mm.h | 14 +++-----------
include/trace/events/kmem.h | 28 ----------------------------
mm/memory.c | 6 ------
3 files changed, 3 insertions(+), 45 deletions(-)
diff --git a/include/linux/mm.h b/include/linux/mm.h
index c54fb96cb1e6..db55e0dea9a5 100644
--- a/include/linux/mm.h
+++ b/include/linux/mm.h
@@ -1629,27 +1629,19 @@ static inline unsigned long get_mm_counter(struct mm_struct *mm, int member)
return (unsigned long)val;
}
-void mm_trace_rss_stat(struct mm_struct *mm, int member, long count);
-
static inline void add_mm_counter(struct mm_struct *mm, int member, long value)
{
- long count = atomic_long_add_return(value, &mm->rss_stat.count[member]);
-
- mm_trace_rss_stat(mm, member, count);
+ atomic_long_add(value, &mm->rss_stat.count[member]);
}
static inline void inc_mm_counter(struct mm_struct *mm, int member)
{
- long count = atomic_long_inc_return(&mm->rss_stat.count[member]);
-
- mm_trace_rss_stat(mm, member, count);
+ atomic_long_inc(&mm->rss_stat.count[member]);
}
static inline void dec_mm_counter(struct mm_struct *mm, int member)
{
- long count = atomic_long_dec_return(&mm->rss_stat.count[member]);
-
- mm_trace_rss_stat(mm, member, count);
+ atomic_long_dec(&mm->rss_stat.count[member]);
}
/* Optimized variant when page is already known not to be PageAnon */
diff --git a/include/trace/events/kmem.h b/include/trace/events/kmem.h
index f65b1f6db22d..788e049f899c 100644
--- a/include/trace/events/kmem.h
+++ b/include/trace/events/kmem.h
@@ -335,34 +335,6 @@ static unsigned int __maybe_unused mm_ptr_to_hash(const void *ptr)
#define __PTR_TO_HASHVAL
#endif
-TRACE_EVENT(rss_stat,
-
- TP_PROTO(struct mm_struct *mm,
- int member,
- long count),
-
- TP_ARGS(mm, member, count),
-
- TP_STRUCT__entry(
- __field(unsigned int, mm_id)
- __field(unsigned int, curr)
- __field(int, member)
- __field(long, size)
- ),
-
- TP_fast_assign(
- __entry->mm_id = mm_ptr_to_hash(mm);
- __entry->curr = !!(current->mm == mm);
- __entry->member = member;
- __entry->size = (count << PAGE_SHIFT);
- ),
-
- TP_printk("mm_id=%u curr=%d member=%d size=%ldB",
- __entry->mm_id,
- __entry->curr,
- __entry->member,
- __entry->size)
- );
#endif /* _TRACE_KMEM_H */
/* This part must be outside protection */
diff --git a/mm/memory.c b/mm/memory.c
index e8bfdf0d9d1d..889bfbb49e19 100644
--- a/mm/memory.c
+++ b/mm/memory.c
@@ -72,8 +72,6 @@
#include <linux/oom.h>
#include <linux/numa.h>
-#include <trace/events/kmem.h>
-
#include <asm/io.h>
#include <asm/mmu_context.h>
#include <asm/pgalloc.h>
@@ -154,10 +152,6 @@ static int __init init_zero_pfn(void)
}
core_initcall(init_zero_pfn);
-void mm_trace_rss_stat(struct mm_struct *mm, int member, long count)
-{
- trace_rss_stat(mm, member, count);
-}
#if defined(SPLIT_RSS_COUNTING)
--
2.17.1

View file

@ -0,0 +1,28 @@
From 0190b87a051b588bd2a7845a858e455bc9ff1af5 Mon Sep 17 00:00:00 2001
From: chewitt <github@chrishewitt.net>
Date: Wed, 14 Aug 2019 19:58:14 +0000
Subject: [PATCH 060/101] HACK: set meson-g12 cma pool to 896MB
This change sets the CMA pool to a larger 896MB! value for (WIP) vdec use
Signed-off-by: Christian Hewitt <christianshewitt@gmail.com>
---
arch/arm64/boot/dts/amlogic/meson-g12-common.dtsi | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/arch/arm64/boot/dts/amlogic/meson-g12-common.dtsi b/arch/arm64/boot/dts/amlogic/meson-g12-common.dtsi
index 4625bdd08c07..3deace05d345 100644
--- a/arch/arm64/boot/dts/amlogic/meson-g12-common.dtsi
+++ b/arch/arm64/boot/dts/amlogic/meson-g12-common.dtsi
@@ -71,7 +71,7 @@
linux,cma {
compatible = "shared-dma-pool";
reusable;
- size = <0x0 0x10000000>;
+ size = <0x0 0x38000000>;
alignment = <0x0 0x400000>;
linux,cma-default;
};
--
2.17.1

View file

@ -0,0 +1,111 @@
From fac579148d3775144bbe922ef013bd4e134fc6df Mon Sep 17 00:00:00 2001
From: Neil Armstrong <narmstrong@baylibre.com>
Date: Thu, 20 Feb 2020 17:13:26 +0000
Subject: [PATCH 076/101] FROMLIST: drm/fourcc: Add modifier definitions for
describing Amlogic Video Framebuffer Compression
Amlogic uses a proprietary lossless image compression protocol and format
for their hardware video codec accelerators, either video decoders or
video input encoders.
It considerably reduces memory bandwidth while writing and reading
frames in memory.
The underlying storage is considered to be 3 components, 8bit or 10-bit
per component, YCbCr 420, single plane :
- DRM_FORMAT_YUV420_8BIT
- DRM_FORMAT_YUV420_10BIT
This modifier will be notably added to DMA-BUF frames imported from the V4L2
Amlogic VDEC decoder.
At least two options are supported :
- Scatter mode: the buffer is filled with a IOMMU scatter table referring
to the encoder current memory layout. This mode if more efficient in terms
of memory allocation but frames are not dumpable and only valid during until
the buffer is freed and back in control of the encoder
- Memory saving: when the pixel bpp is 8b, the size of the superblock can
be reduced, thus saving memory.
Signed-off-by: Neil Armstrong <narmstrong@baylibre.com>
---
include/uapi/drm/drm_fourcc.h | 56 +++++++++++++++++++++++++++++++++++
1 file changed, 56 insertions(+)
diff --git a/include/uapi/drm/drm_fourcc.h b/include/uapi/drm/drm_fourcc.h
index 8bc0b31597d8..8a6e87bacadb 100644
--- a/include/uapi/drm/drm_fourcc.h
+++ b/include/uapi/drm/drm_fourcc.h
@@ -309,6 +309,7 @@ extern "C" {
#define DRM_FORMAT_MOD_VENDOR_BROADCOM 0x07
#define DRM_FORMAT_MOD_VENDOR_ARM 0x08
#define DRM_FORMAT_MOD_VENDOR_ALLWINNER 0x09
+#define DRM_FORMAT_MOD_VENDOR_AMLOGIC 0x0a
/* add more to the end as needed */
@@ -804,6 +805,61 @@ extern "C" {
*/
#define DRM_FORMAT_MOD_ALLWINNER_TILED fourcc_mod_code(ALLWINNER, 1)
+/*
+ * Amlogic Video Framebuffer Compression modifiers
+ *
+ * Amlogic uses a proprietary lossless image compression protocol and format
+ * for their hardware video codec accelerators, either video decoders or
+ * video input encoders.
+ *
+ * It considerably reduces memory bandwidth while writing and reading
+ * frames in memory.
+ * Implementation details may be platform and SoC specific, and shared
+ * between the producer and the decoder on the same platform.
+ *
+ * The underlying storage is considered to be 3 components, 8bit or 10-bit
+ * per component YCbCr 420, single plane :
+ * - DRM_FORMAT_YUV420_8BIT
+ * - DRM_FORMAT_YUV420_10BIT
+ *
+ * The classic memory storage is composed of:
+ * - a body content organized in 64x32 superblocks with 4096 bytes per
+ * superblock in default mode.
+ * - a 32 bytes per 128x64 header block
+ */
+#define DRM_FORMAT_MOD_AMLOGIC_FBC_DEFAULT fourcc_mod_code(AMLOGIC, 0)
+
+/*
+ * Amlogic Video Framebuffer Compression Options
+ *
+ * Two optional features are available which may not supported/used on every
+ * SoCs and Compressed Framebuffer producers.
+ */
+#define DRM_FORMAT_MOD_AMLOGIC_FBC(__modes) fourcc_mod_code(AMLOGIC, __modes)
+
+/*
+ * Amlogic FBC Scatter Memory layout
+ *
+ * Indicates the header contains IOMMU references to the compressed
+ * frames content to optimize memory access and layout.
+ * In this mode, only the header memory address is needed, thus the
+ * content memory organization is tied to the current producer
+ * execution and cannot be saved/dumped.
+ */
+#define DRM_FORMAT_MOD_AMLOGIC_FBC_SCATTER (1ULL << 0)
+
+/*
+ * Amlogic FBC Memory Saving mode
+ *
+ * Indicates the storage is packed when pixel size is multiple of word
+ * boudaries, i.e. 8bit should be stored in this mode to save allocation
+ * memory.
+ *
+ * This mode reduces body layout to 3072 bytes per 64x32 superblock and
+ * 3200 bytes per 64x32 superblock combined with scatter mode.
+ */
+#define DRM_FORMAT_MOD_AMLOGIC_FBC_MEM_SAVING (1ULL << 1)
+
#if defined(__cplusplus)
}
#endif
--
2.17.1

View file

@ -0,0 +1,60 @@
From b0faff15e4b82132d69b8b534ff3b9689370961e Mon Sep 17 00:00:00 2001
From: Neil Armstrong <narmstrong@baylibre.com>
Date: Thu, 20 Feb 2020 17:14:31 +0000
Subject: [PATCH 077/101] FROMLIST: drm/meson: add Amlogic Video FBC registers
Add the registers of the VPU VD1 Amlogic FBC decoder module, and routing
register.
Signed-off-by: Neil Armstrong <narmstrong@baylibre.com>
---
drivers/gpu/drm/meson/meson_registers.h | 22 ++++++++++++++++++++++
1 file changed, 22 insertions(+)
diff --git a/drivers/gpu/drm/meson/meson_registers.h b/drivers/gpu/drm/meson/meson_registers.h
index 8ea00546cd4e..08631fdfe4b9 100644
--- a/drivers/gpu/drm/meson/meson_registers.h
+++ b/drivers/gpu/drm/meson/meson_registers.h
@@ -144,10 +144,15 @@
#define VIU_SW_RESET_OSD1 BIT(0)
#define VIU_MISC_CTRL0 0x1a06
#define VIU_CTRL0_VD1_AFBC_MASK 0x170000
+#define VIU_CTRL0_AFBC_TO_VD1 BIT(20)
#define VIU_MISC_CTRL1 0x1a07
#define MALI_AFBC_MISC GENMASK(15, 8)
#define D2D3_INTF_LENGTH 0x1a08
#define D2D3_INTF_CTRL0 0x1a09
+#define VD1_AFBCD0_MISC_CTRL 0x1a0a
+#define VD1_AXI_SEL_AFBC (1 << 12)
+#define AFBC_VD1_SEL (1 << 10)
+#define VD2_AFBCD1_MISC_CTRL 0x1a0b
#define VIU_OSD1_CTRL_STAT 0x1a10
#define VIU_OSD1_OSD_BLK_ENABLE BIT(0)
#define VIU_OSD1_OSD_MEM_MODE_LINEAR BIT(2)
@@ -365,6 +370,23 @@
#define VIU_OSD1_OETF_LUT_ADDR_PORT 0x1add
#define VIU_OSD1_OETF_LUT_DATA_PORT 0x1ade
#define AFBC_ENABLE 0x1ae0
+#define AFBC_MODE 0x1ae1
+#define AFBC_SIZE_IN 0x1ae2
+#define AFBC_DEC_DEF_COLOR 0x1ae3
+#define AFBC_CONV_CTRL 0x1ae4
+#define AFBC_LBUF_DEPTH 0x1ae5
+#define AFBC_HEAD_BADDR 0x1ae6
+#define AFBC_BODY_BADDR 0x1ae7
+#define AFBC_SIZE_OUT 0x1ae8
+#define AFBC_OUT_YSCOPE 0x1ae9
+#define AFBC_STAT 0x1aea
+#define AFBC_VD_CFMT_CTRL 0x1aeb
+#define AFBC_VD_CFMT_W 0x1aec
+#define AFBC_MIF_HOR_SCOPE 0x1aed
+#define AFBC_MIF_VER_SCOPE 0x1aee
+#define AFBC_PIXEL_HOR_SCOPE 0x1aef
+#define AFBC_PIXEL_VER_SCOPE 0x1af0
+#define AFBC_VD_CFMT_H 0x1af1
/* vpp */
#define VPP_DUMMY_DATA 0x1d00
--
2.17.1

View file

@ -0,0 +1,425 @@
From 4f179b75fd372aad1f4031ace69b92614693dae0 Mon Sep 17 00:00:00 2001
From: Neil Armstrong <narmstrong@baylibre.com>
Date: Thu, 20 Feb 2020 17:15:43 +0000
Subject: [PATCH 078/101] FROMLIST: drm/meson: overlay: setup overlay for
Amlogic FBC
Setup the Amlogic FBC decoder for the VD1 video overlay plane.
The VD1 Amlogic FBC decoder is integrated in the pipeline like the
YUV pixel reading/formatter but used a direct memory address instead.
The default mode needs to calculate the content body size since the header
is allocated after.
The scatter mode needs a simplier management since only the header is needed,
since it contains an IOMMU scatter table to locate the superblocks in memory.
Signed-off-by: Neil Armstrong <narmstrong@baylibre.com>
---
drivers/gpu/drm/meson/meson_drv.h | 16 ++
drivers/gpu/drm/meson/meson_overlay.c | 257 +++++++++++++++++++++++++-
2 files changed, 265 insertions(+), 8 deletions(-)
diff --git a/drivers/gpu/drm/meson/meson_drv.h b/drivers/gpu/drm/meson/meson_drv.h
index 04fdf3826643..da951964e988 100644
--- a/drivers/gpu/drm/meson/meson_drv.h
+++ b/drivers/gpu/drm/meson/meson_drv.h
@@ -80,6 +80,7 @@ struct meson_drm {
bool vd1_enabled;
bool vd1_commit;
+ bool vd1_afbc;
unsigned int vd1_planes;
uint32_t vd1_if0_gen_reg;
uint32_t vd1_if0_luma_x0;
@@ -105,6 +106,21 @@ struct meson_drm {
uint32_t vd1_height0;
uint32_t vd1_height1;
uint32_t vd1_height2;
+ uint32_t vd1_afbc_mode;
+ uint32_t vd1_afbc_en;
+ uint32_t vd1_afbc_head_addr;
+ uint32_t vd1_afbc_body_addr;
+ uint32_t vd1_afbc_conv_ctrl;
+ uint32_t vd1_afbc_dec_def_color;
+ uint32_t vd1_afbc_vd_cfmt_ctrl;
+ uint32_t vd1_afbc_vd_cfmt_w;
+ uint32_t vd1_afbc_vd_cfmt_h;
+ uint32_t vd1_afbc_mif_hor_scope;
+ uint32_t vd1_afbc_mif_ver_scope;
+ uint32_t vd1_afbc_size_out;
+ uint32_t vd1_afbc_pixel_hor_scope;
+ uint32_t vd1_afbc_pixel_ver_scope;
+ uint32_t vd1_afbc_size_in;
uint32_t vpp_pic_in_height;
uint32_t vpp_postblend_vd1_h_start_end;
uint32_t vpp_postblend_vd1_v_start_end;
diff --git a/drivers/gpu/drm/meson/meson_overlay.c b/drivers/gpu/drm/meson/meson_overlay.c
index 2468b0212d52..1fbb81732e9a 100644
--- a/drivers/gpu/drm/meson/meson_overlay.c
+++ b/drivers/gpu/drm/meson/meson_overlay.c
@@ -5,6 +5,7 @@
* Copyright (C) 2015 Amlogic, Inc. All rights reserved.
*/
+#define DEBUG
#include <linux/bitfield.h>
#include <drm/drm_atomic.h>
@@ -76,6 +77,84 @@
#define VD_REGION24_START(value) FIELD_PREP(GENMASK(11, 0), value)
#define VD_REGION13_END(value) FIELD_PREP(GENMASK(27, 16), value)
+/* AFBC_ENABLE */
+#define AFBC_DEC_ENABLE BIT(8)
+#define AFBC_FRM_START BIT(0)
+
+/* AFBC_MODE */
+#define AFBC_HORZ_SKIP_UV(value) FIELD_PREP(GENMASK(1, 0), value)
+#define AFBC_VERT_SKIP_UV(value) FIELD_PREP(GENMASK(3, 2), value)
+#define AFBC_HORZ_SKIP_Y(value) FIELD_PREP(GENMASK(5, 4), value)
+#define AFBC_VERT_SKIP_Y(value) FIELD_PREP(GENMASK(7, 6), value)
+#define AFBC_COMPBITS_YUV(value) FIELD_PREP(GENMASK(13, 8), value)
+#define AFBC_COMPBITS_8BIT 0
+#define AFBC_COMPBITS_10BIT (2 | (2 << 2) | (2 << 4))
+#define AFBC_BURST_LEN(value) FIELD_PREP(GENMASK(15, 14), value)
+#define AFBC_HOLD_LINE_NUM(value) FIELD_PREP(GENMASK(22, 16), value)
+#define AFBC_MIF_URGENT(value) FIELD_PREP(GENMASK(25, 24), value)
+#define AFBC_REV_MODE(value) FIELD_PREP(GENMASK(27, 26), value)
+#define AFBC_BLK_MEM_MODE BIT(28)
+#define AFBC_SCATTER_MODE BIT(29)
+#define AFBC_SOFT_RESET BIT(31)
+
+/* AFBC_SIZE_IN */
+#define AFBC_HSIZE_IN(value) FIELD_PREP(GENMASK(28, 16), value)
+#define AFBC_VSIZE_IN(value) FIELD_PREP(GENMASK(12, 0), value)
+
+/* AFBC_DEC_DEF_COLOR */
+#define AFBC_DEF_COLOR_Y(value) FIELD_PREP(GENMASK(29, 20), value)
+#define AFBC_DEF_COLOR_U(value) FIELD_PREP(GENMASK(19, 10), value)
+#define AFBC_DEF_COLOR_V(value) FIELD_PREP(GENMASK(9, 0), value)
+
+/* AFBC_CONV_CTRL */
+#define AFBC_CONV_LBUF_LEN(value) FIELD_PREP(GENMASK(11, 0), value)
+
+/* AFBC_LBUF_DEPTH */
+#define AFBC_DEC_LBUF_DEPTH(value) FIELD_PREP(GENMASK(27, 16), value)
+#define AFBC_MIF_LBUF_DEPTH(value) FIELD_PREP(GENMASK(11, 0), value)
+
+/* AFBC_OUT_XSCOPE/AFBC_SIZE_OUT */
+#define AFBC_HSIZE_OUT(value) FIELD_PREP(GENMASK(28, 16), value)
+#define AFBC_VSIZE_OUT(value) FIELD_PREP(GENMASK(12, 0), value)
+#define AFBC_OUT_HORZ_BGN(value) FIELD_PREP(GENMASK(28, 16), value)
+#define AFBC_OUT_HORZ_END(value) FIELD_PREP(GENMASK(12, 0), value)
+
+/* AFBC_OUT_YSCOPE */
+#define AFBC_OUT_VERT_BGN(value) FIELD_PREP(GENMASK(28, 16), value)
+#define AFBC_OUT_VERT_END(value) FIELD_PREP(GENMASK(12, 0), value)
+
+/* AFBC_VD_CFMT_CTRL */
+#define AFBC_HORZ_RPT_PIXEL0 BIT(23)
+#define AFBC_HORZ_Y_C_RATIO(value) FIELD_PREP(GENMASK(22, 21), value)
+#define AFBC_HORZ_FMT_EN BIT(20)
+#define AFBC_VERT_RPT_LINE0 BIT(16)
+#define AFBC_VERT_INITIAL_PHASE(value) FIELD_PREP(GENMASK(11, 8), value)
+#define AFBC_VERT_PHASE_STEP(value) FIELD_PREP(GENMASK(7, 1), value)
+#define AFBC_VERT_FMT_EN BIT(0)
+
+/* AFBC_VD_CFMT_W */
+#define AFBC_VD_V_WIDTH(value) FIELD_PREP(GENMASK(11, 0), value)
+#define AFBC_VD_H_WIDTH(value) FIELD_PREP(GENMASK(27, 16), value)
+
+/* AFBC_MIF_HOR_SCOPE */
+#define AFBC_MIF_BLK_BGN_H(value) FIELD_PREP(GENMASK(25, 16), value)
+#define AFBC_MIF_BLK_END_H(value) FIELD_PREP(GENMASK(9, 0), value)
+
+/* AFBC_MIF_VER_SCOPE */
+#define AFBC_MIF_BLK_BGN_V(value) FIELD_PREP(GENMASK(27, 16), value)
+#define AFBC_MIF_BLK_END_V(value) FIELD_PREP(GENMASK(11, 0), value)
+
+/* AFBC_PIXEL_HOR_SCOPE */
+#define AFBC_DEC_PIXEL_BGN_H(value) FIELD_PREP(GENMASK(28, 16), value)
+#define AFBC_DEC_PIXEL_END_H(value) FIELD_PREP(GENMASK(12, 0), value)
+
+/* AFBC_PIXEL_VER_SCOPE */
+#define AFBC_DEC_PIXEL_BGN_V(value) FIELD_PREP(GENMASK(28, 16), value)
+#define AFBC_DEC_PIXEL_END_V(value) FIELD_PREP(GENMASK(12, 0), value)
+
+/* AFBC_VD_CFMT_H */
+#define AFBC_VD_HEIGHT(value) FIELD_PREP(GENMASK(12, 0), value)
+
struct meson_overlay {
struct drm_plane base;
struct meson_drm *priv;
@@ -157,6 +236,9 @@ static void meson_overlay_setup_scaler_params(struct meson_drm *priv,
unsigned int ratio_x, ratio_y;
int temp_height, temp_width;
unsigned int w_in, h_in;
+ int afbc_left, afbc_right;
+ int afbc_top_src, afbc_bottom_src;
+ int afbc_top, afbc_bottom;
int temp, start, end;
if (!crtc_state) {
@@ -169,7 +251,7 @@ static void meson_overlay_setup_scaler_params(struct meson_drm *priv,
w_in = fixed16_to_int(state->src_w);
h_in = fixed16_to_int(state->src_h);
- crop_top = fixed16_to_int(state->src_x);
+ crop_top = fixed16_to_int(state->src_y);
crop_left = fixed16_to_int(state->src_x);
video_top = state->crtc_y;
@@ -243,6 +325,14 @@ static void meson_overlay_setup_scaler_params(struct meson_drm *priv,
DRM_DEBUG("vsc startp %d endp %d start_lines %d end_lines %d\n",
vsc_startp, vsc_endp, vd_start_lines, vd_end_lines);
+ afbc_top = round_down(vd_start_lines, 4);
+ afbc_bottom = round_up(vd_end_lines + 1, 4);
+ afbc_top_src = 0;
+ afbc_bottom_src = round_up(h_in + 1, 4);
+
+ DRM_DEBUG("afbc top %d (src %d) bottom %d (src %d)\n",
+ afbc_top, afbc_top_src, afbc_bottom, afbc_bottom_src);
+
/* Horizontal */
start = video_left + video_width / 2 - ((w_in << 17) / ratio_x);
@@ -278,6 +368,16 @@ static void meson_overlay_setup_scaler_params(struct meson_drm *priv,
DRM_DEBUG("hsc startp %d endp %d start_lines %d end_lines %d\n",
hsc_startp, hsc_endp, hd_start_lines, hd_end_lines);
+ if (hd_start_lines > 0 || (hd_end_lines < w_in)) {
+ afbc_left = 0;
+ afbc_right = round_up(w_in, 32);
+ } else {
+ afbc_left = round_down(hd_start_lines, 32);
+ afbc_right = round_up(hd_end_lines + 1, 32);
+ }
+
+ DRM_DEBUG("afbc left %d right %d\n", afbc_left, afbc_right);
+
priv->viu.vpp_vsc_start_phase_step = ratio_y << 6;
priv->viu.vpp_vsc_ini_phase = vphase << 8;
@@ -293,6 +393,35 @@ static void meson_overlay_setup_scaler_params(struct meson_drm *priv,
VD_H_WIDTH(hd_end_lines - hd_start_lines + 1) |
VD_V_WIDTH(hd_end_lines/2 - hd_start_lines/2 + 1);
+ priv->viu.vd1_afbc_vd_cfmt_w =
+ AFBC_VD_H_WIDTH(afbc_right - afbc_left) |
+ AFBC_VD_V_WIDTH(afbc_right / 2 - afbc_left / 2);
+
+ priv->viu.vd1_afbc_vd_cfmt_h =
+ AFBC_VD_HEIGHT((afbc_bottom - afbc_top) / 2);
+
+ priv->viu.vd1_afbc_mif_hor_scope = AFBC_MIF_BLK_BGN_H(afbc_left / 32) |
+ AFBC_MIF_BLK_END_H((afbc_right / 32) - 1);
+
+ priv->viu.vd1_afbc_mif_ver_scope = AFBC_MIF_BLK_BGN_V(afbc_top / 4) |
+ AFBC_MIF_BLK_END_H((afbc_bottom / 4) - 1);
+
+ priv->viu.vd1_afbc_size_out =
+ AFBC_HSIZE_OUT(afbc_right - afbc_left) |
+ AFBC_VSIZE_OUT(afbc_bottom - afbc_top);
+
+ priv->viu.vd1_afbc_pixel_hor_scope =
+ AFBC_DEC_PIXEL_BGN_H(hd_start_lines - afbc_left) |
+ AFBC_DEC_PIXEL_END_H(hd_end_lines - afbc_left);
+
+ priv->viu.vd1_afbc_pixel_ver_scope =
+ AFBC_DEC_PIXEL_BGN_V(vd_start_lines - afbc_top) |
+ AFBC_DEC_PIXEL_END_V(vd_end_lines - afbc_top);
+
+ priv->viu.vd1_afbc_size_in =
+ AFBC_HSIZE_IN(afbc_right - afbc_left) |
+ AFBC_VSIZE_IN(afbc_bottom_src - afbc_top_src);
+
priv->viu.vd1_if0_luma_y0 = VD_Y_START(vd_start_lines) |
VD_Y_END(vd_end_lines);
@@ -350,11 +479,63 @@ static void meson_overlay_atomic_update(struct drm_plane *plane,
spin_lock_irqsave(&priv->drm->event_lock, flags);
- priv->viu.vd1_if0_gen_reg = VD_URGENT_CHROMA |
- VD_URGENT_LUMA |
- VD_HOLD_LINES(9) |
- VD_CHRO_RPT_LASTL_CTRL |
- VD_ENABLE;
+ if ((fb->modifier & DRM_FORMAT_MOD_AMLOGIC_FBC(0)) ==
+ DRM_FORMAT_MOD_AMLOGIC_FBC(0)) {
+ priv->viu.vd1_afbc = true;
+
+ priv->viu.vd1_afbc_mode = AFBC_MIF_URGENT(3) |
+ AFBC_HOLD_LINE_NUM(8) |
+ AFBC_BURST_LEN(2);
+
+ if (fb->modifier & DRM_FORMAT_MOD_AMLOGIC_FBC_SCATTER)
+ priv->viu.vd1_afbc_mode |= AFBC_SCATTER_MODE;
+
+ if (fb->modifier & DRM_FORMAT_MOD_AMLOGIC_FBC_MEM_SAVING)
+ priv->viu.vd1_afbc_mode |= AFBC_BLK_MEM_MODE;
+
+ priv->viu.vd1_afbc_en = 0x1600 | AFBC_DEC_ENABLE;
+
+ priv->viu.vd1_afbc_conv_ctrl = AFBC_CONV_LBUF_LEN(256);
+
+ priv->viu.vd1_afbc_dec_def_color = AFBC_DEF_COLOR_Y(1023);
+
+ /* 420: horizontal / 2, vertical / 4 */
+ priv->viu.vd1_afbc_vd_cfmt_ctrl = AFBC_HORZ_RPT_PIXEL0 |
+ AFBC_HORZ_Y_C_RATIO(1) |
+ AFBC_HORZ_FMT_EN |
+ AFBC_VERT_RPT_LINE0 |
+ AFBC_VERT_INITIAL_PHASE(12) |
+ AFBC_VERT_PHASE_STEP(8) |
+ AFBC_VERT_FMT_EN;
+
+ switch (fb->format->format) {
+ /* AFBC Only formats */
+ case DRM_FORMAT_YUV420_10BIT:
+ priv->viu.vd1_afbc_mode |=
+ AFBC_COMPBITS_YUV(AFBC_COMPBITS_10BIT);
+ priv->viu.vd1_afbc_dec_def_color |=
+ AFBC_DEF_COLOR_U(512) |
+ AFBC_DEF_COLOR_V(512);
+ break;
+ case DRM_FORMAT_YUV420_8BIT:
+ priv->viu.vd1_afbc_dec_def_color |=
+ AFBC_DEF_COLOR_U(128) |
+ AFBC_DEF_COLOR_V(128);
+ break;
+ }
+
+ priv->viu.vd1_if0_gen_reg = 0;
+ priv->viu.vd1_if0_canvas0 = 0;
+ priv->viu.viu_vd1_fmt_ctrl = 0;
+ } else {
+ priv->viu.vd1_afbc = false;
+
+ priv->viu.vd1_if0_gen_reg = VD_URGENT_CHROMA |
+ VD_URGENT_LUMA |
+ VD_HOLD_LINES(9) |
+ VD_CHRO_RPT_LASTL_CTRL |
+ VD_ENABLE;
+ }
/* Setup scaler params */
meson_overlay_setup_scaler_params(priv, plane, interlace_mode);
@@ -370,6 +551,7 @@ static void meson_overlay_atomic_update(struct drm_plane *plane,
priv->viu.vd1_if0_gen_reg2 = 0;
priv->viu.viu_vd1_fmt_ctrl = 0;
+ /* None will match for AFBC Only formats */
switch (fb->format->format) {
/* TOFIX DRM_FORMAT_RGB888 should be supported */
case DRM_FORMAT_YUYV:
@@ -488,13 +670,42 @@ static void meson_overlay_atomic_update(struct drm_plane *plane,
priv->viu.vd1_stride0 = fb->pitches[0];
priv->viu.vd1_height0 =
drm_format_info_plane_height(fb->format,
- fb->height, 0);
+ fb->height, 0);
DRM_DEBUG("plane 0 addr 0x%x stride %d height %d\n",
priv->viu.vd1_addr0,
priv->viu.vd1_stride0,
priv->viu.vd1_height0);
}
+ if (priv->viu.vd1_afbc) {
+ if (priv->viu.vd1_afbc_mode & AFBC_SCATTER_MODE) {
+ /*
+ * In Scatter mode, the header contains the physical
+ * body content layout, thus the body content
+ * size isn't needed.
+ */
+ priv->viu.vd1_afbc_head_addr = priv->viu.vd1_addr0 >> 4;
+ priv->viu.vd1_afbc_body_addr = 0;
+ } else {
+ /* Default mode is 4k per superblock */
+ unsigned long block_size = 4096;
+ unsigned long body_size;
+
+ /* 8bit mem saving mode is 3072bytes per superblock */
+ if (priv->viu.vd1_afbc_mode & AFBC_BLK_MEM_MODE)
+ block_size = 3072;
+
+ body_size = (ALIGN(priv->viu.vd1_stride0, 64) / 64) *
+ (ALIGN(priv->viu.vd1_height0, 32) / 32) *
+ block_size;
+
+ priv->viu.vd1_afbc_body_addr = priv->viu.vd1_addr0 >> 4;
+ /* Header is after body content */
+ priv->viu.vd1_afbc_head_addr = (priv->viu.vd1_addr0 +
+ body_size) >> 4;
+ }
+ }
+
priv->viu.vd1_enabled = true;
spin_unlock_irqrestore(&priv->drm->event_lock, flags);
@@ -531,6 +742,23 @@ static const struct drm_plane_helper_funcs meson_overlay_helper_funcs = {
.prepare_fb = drm_gem_fb_prepare_fb,
};
+static bool meson_overlay_format_mod_supported(struct drm_plane *plane,
+ u32 format, u64 modifier)
+{
+ if (modifier == DRM_FORMAT_MOD_LINEAR &&
+ format != DRM_FORMAT_YUV420_8BIT &&
+ format != DRM_FORMAT_YUV420_10BIT)
+ return true;
+
+ if ((modifier & DRM_FORMAT_MOD_AMLOGIC_FBC(0)) ==
+ DRM_FORMAT_MOD_AMLOGIC_FBC(0) &&
+ (format == DRM_FORMAT_YUV420_8BIT ||
+ format == DRM_FORMAT_YUV420_10BIT))
+ return true;
+
+ return false;
+}
+
static const struct drm_plane_funcs meson_overlay_funcs = {
.update_plane = drm_atomic_helper_update_plane,
.disable_plane = drm_atomic_helper_disable_plane,
@@ -538,6 +766,7 @@ static const struct drm_plane_funcs meson_overlay_funcs = {
.reset = drm_atomic_helper_plane_reset,
.atomic_duplicate_state = drm_atomic_helper_plane_duplicate_state,
.atomic_destroy_state = drm_atomic_helper_plane_destroy_state,
+ .format_mod_supported = meson_overlay_format_mod_supported,
};
static const uint32_t supported_drm_formats[] = {
@@ -549,6 +778,18 @@ static const uint32_t supported_drm_formats[] = {
DRM_FORMAT_YUV420,
DRM_FORMAT_YUV411,
DRM_FORMAT_YUV410,
+ DRM_FORMAT_YUV420_8BIT, /* Amlogic FBC Only */
+ DRM_FORMAT_YUV420_10BIT, /* Amlogic FBC Only */
+};
+
+static const uint64_t format_modifiers[] = {
+ DRM_FORMAT_MOD_AMLOGIC_FBC(DRM_FORMAT_MOD_AMLOGIC_FBC_SCATTER |
+ DRM_FORMAT_MOD_AMLOGIC_FBC_MEM_SAVING),
+ DRM_FORMAT_MOD_AMLOGIC_FBC(DRM_FORMAT_MOD_AMLOGIC_FBC_SCATTER),
+ DRM_FORMAT_MOD_AMLOGIC_FBC(DRM_FORMAT_MOD_AMLOGIC_FBC_MEM_SAVING),
+ DRM_FORMAT_MOD_AMLOGIC_FBC_DEFAULT,
+ DRM_FORMAT_MOD_LINEAR,
+ DRM_FORMAT_MOD_INVALID,
};
int meson_overlay_create(struct meson_drm *priv)
@@ -570,7 +811,7 @@ int meson_overlay_create(struct meson_drm *priv)
&meson_overlay_funcs,
supported_drm_formats,
ARRAY_SIZE(supported_drm_formats),
- NULL,
+ format_modifiers,
DRM_PLANE_TYPE_OVERLAY, "meson_overlay_plane");
drm_plane_helper_add(plane, &meson_overlay_helper_funcs);
--
2.17.1

View file

@ -0,0 +1,160 @@
From 8e6c592ce9779efbcdab03312a058887297eaeaf Mon Sep 17 00:00:00 2001
From: Neil Armstrong <narmstrong@baylibre.com>
Date: Thu, 20 Feb 2020 17:16:57 +0000
Subject: [PATCH 079/101] FROMLIST: drm/meson: crtc: handle commit of Amlogic
FBC frames
Since the VD1 Amlogic FBC decoder is now configured by the overlay driver,
commit the right registers to decode the Amlogic FBC frame.
Signed-off-by: Neil Armstrong <narmstrong@baylibre.com>
---
drivers/gpu/drm/meson/meson_crtc.c | 118 +++++++++++++++++++++--------
1 file changed, 88 insertions(+), 30 deletions(-)
diff --git a/drivers/gpu/drm/meson/meson_crtc.c b/drivers/gpu/drm/meson/meson_crtc.c
index e66b6271ff58..d6dcfd654e9c 100644
--- a/drivers/gpu/drm/meson/meson_crtc.c
+++ b/drivers/gpu/drm/meson/meson_crtc.c
@@ -291,6 +291,10 @@ static void meson_crtc_enable_vd1(struct meson_drm *priv)
VPP_VD1_PREBLEND | VPP_VD1_POSTBLEND |
VPP_COLOR_MNG_ENABLE,
priv->io_base + _REG(VPP_MISC));
+
+ writel_bits_relaxed(VIU_CTRL0_AFBC_TO_VD1,
+ priv->viu.vd1_afbc ? VIU_CTRL0_AFBC_TO_VD1 : 0,
+ priv->io_base + _REG(VIU_MISC_CTRL0));
}
static void meson_g12a_crtc_enable_vd1(struct meson_drm *priv)
@@ -300,6 +304,10 @@ static void meson_g12a_crtc_enable_vd1(struct meson_drm *priv)
VD_BLEND_POSTBLD_SRC_VD1 |
VD_BLEND_POSTBLD_PREMULT_EN,
priv->io_base + _REG(VD1_BLEND_SRC_CTRL));
+
+ writel_relaxed(priv->viu.vd1_afbc ?
+ (VD1_AXI_SEL_AFBC | AFBC_VD1_SEL) : 0,
+ priv->io_base + _REG(VD1_AFBCD0_MISC_CTRL));
}
void meson_crtc_irq(struct meson_drm *priv)
@@ -383,36 +391,86 @@ void meson_crtc_irq(struct meson_drm *priv)
/* Update the VD1 registers */
if (priv->viu.vd1_enabled && priv->viu.vd1_commit) {
- switch (priv->viu.vd1_planes) {
- case 3:
- meson_canvas_config(priv->canvas,
- priv->canvas_id_vd1_2,
- priv->viu.vd1_addr2,
- priv->viu.vd1_stride2,
- priv->viu.vd1_height2,
- MESON_CANVAS_WRAP_NONE,
- MESON_CANVAS_BLKMODE_LINEAR,
- MESON_CANVAS_ENDIAN_SWAP64);
- /* fallthrough */
- case 2:
- meson_canvas_config(priv->canvas,
- priv->canvas_id_vd1_1,
- priv->viu.vd1_addr1,
- priv->viu.vd1_stride1,
- priv->viu.vd1_height1,
- MESON_CANVAS_WRAP_NONE,
- MESON_CANVAS_BLKMODE_LINEAR,
- MESON_CANVAS_ENDIAN_SWAP64);
- /* fallthrough */
- case 1:
- meson_canvas_config(priv->canvas,
- priv->canvas_id_vd1_0,
- priv->viu.vd1_addr0,
- priv->viu.vd1_stride0,
- priv->viu.vd1_height0,
- MESON_CANVAS_WRAP_NONE,
- MESON_CANVAS_BLKMODE_LINEAR,
- MESON_CANVAS_ENDIAN_SWAP64);
+ if (priv->viu.vd1_afbc) {
+ writel_relaxed(priv->viu.vd1_afbc_head_addr,
+ priv->io_base +
+ _REG(AFBC_HEAD_BADDR));
+ writel_relaxed(priv->viu.vd1_afbc_body_addr,
+ priv->io_base +
+ _REG(AFBC_BODY_BADDR));
+ writel_relaxed(priv->viu.vd1_afbc_en,
+ priv->io_base +
+ _REG(AFBC_ENABLE));
+ writel_relaxed(priv->viu.vd1_afbc_mode,
+ priv->io_base +
+ _REG(AFBC_MODE));
+ writel_relaxed(priv->viu.vd1_afbc_size_in,
+ priv->io_base +
+ _REG(AFBC_SIZE_IN));
+ writel_relaxed(priv->viu.vd1_afbc_dec_def_color,
+ priv->io_base +
+ _REG(AFBC_DEC_DEF_COLOR));
+ writel_relaxed(priv->viu.vd1_afbc_conv_ctrl,
+ priv->io_base +
+ _REG(AFBC_CONV_CTRL));
+ writel_relaxed(priv->viu.vd1_afbc_size_out,
+ priv->io_base +
+ _REG(AFBC_SIZE_OUT));
+ writel_relaxed(priv->viu.vd1_afbc_vd_cfmt_ctrl,
+ priv->io_base +
+ _REG(AFBC_VD_CFMT_CTRL));
+ writel_relaxed(priv->viu.vd1_afbc_vd_cfmt_w,
+ priv->io_base +
+ _REG(AFBC_VD_CFMT_W));
+ writel_relaxed(priv->viu.vd1_afbc_mif_hor_scope,
+ priv->io_base +
+ _REG(AFBC_MIF_HOR_SCOPE));
+ writel_relaxed(priv->viu.vd1_afbc_mif_ver_scope,
+ priv->io_base +
+ _REG(AFBC_MIF_VER_SCOPE));
+ writel_relaxed(priv->viu.vd1_afbc_pixel_hor_scope,
+ priv->io_base+
+ _REG(AFBC_PIXEL_HOR_SCOPE));
+ writel_relaxed(priv->viu.vd1_afbc_pixel_ver_scope,
+ priv->io_base +
+ _REG(AFBC_PIXEL_VER_SCOPE));
+ writel_relaxed(priv->viu.vd1_afbc_vd_cfmt_h,
+ priv->io_base +
+ _REG(AFBC_VD_CFMT_H));
+ } else {
+ switch (priv->viu.vd1_planes) {
+ case 3:
+ meson_canvas_config(priv->canvas,
+ priv->canvas_id_vd1_2,
+ priv->viu.vd1_addr2,
+ priv->viu.vd1_stride2,
+ priv->viu.vd1_height2,
+ MESON_CANVAS_WRAP_NONE,
+ MESON_CANVAS_BLKMODE_LINEAR,
+ MESON_CANVAS_ENDIAN_SWAP64);
+ /* fallthrough */
+ case 2:
+ meson_canvas_config(priv->canvas,
+ priv->canvas_id_vd1_1,
+ priv->viu.vd1_addr1,
+ priv->viu.vd1_stride1,
+ priv->viu.vd1_height1,
+ MESON_CANVAS_WRAP_NONE,
+ MESON_CANVAS_BLKMODE_LINEAR,
+ MESON_CANVAS_ENDIAN_SWAP64);
+ /* fallthrough */
+ case 1:
+ meson_canvas_config(priv->canvas,
+ priv->canvas_id_vd1_0,
+ priv->viu.vd1_addr0,
+ priv->viu.vd1_stride0,
+ priv->viu.vd1_height0,
+ MESON_CANVAS_WRAP_NONE,
+ MESON_CANVAS_BLKMODE_LINEAR,
+ MESON_CANVAS_ENDIAN_SWAP64);
+ }
+
+ writel_relaxed(0, priv->io_base + _REG(AFBC_ENABLE));
}
writel_relaxed(priv->viu.vd1_if0_gen_reg,
--
2.17.1

View file

@ -0,0 +1,93 @@
From 8ab1155a0723c02a717267e34ae823f118f40e53 Mon Sep 17 00:00:00 2001
From: Christian Hewitt <christianshewitt@gmail.com>
Date: Fri, 21 Feb 2020 05:28:24 +0000
Subject: [PATCH 081/101] FROMLIST: arm64: dts: meson: gxl-s905x-khadas-vim:
add thermal zones
Add thermal zones to the VIM1 board so that a cooling fan can be driven
using the i2c interface. Zone config is copied from the VIM2.
Suggested-by: Nick Xie <nick@khadas.com>
Signed-off-by: Christian Hewitt <christianshewitt@gmail.com>
---
.../amlogic/meson-gxl-s905x-khadas-vim.dts | 50 +++++++++++++++++++
1 file changed, 50 insertions(+)
diff --git a/arch/arm64/boot/dts/amlogic/meson-gxl-s905x-khadas-vim.dts b/arch/arm64/boot/dts/amlogic/meson-gxl-s905x-khadas-vim.dts
index 440bc23c7342..2c198c4212b2 100644
--- a/arch/arm64/boot/dts/amlogic/meson-gxl-s905x-khadas-vim.dts
+++ b/arch/arm64/boot/dts/amlogic/meson-gxl-s905x-khadas-vim.dts
@@ -6,6 +6,7 @@
/dts-v1/;
#include <dt-bindings/input/input.h>
+#include <dt-bindings/thermal/thermal.h>
#include "meson-gxl-s905x-p212.dtsi"
@@ -63,6 +64,39 @@
};
};
};
+
+ thermal-zones {
+ cpu-thermal {
+ polling-delay-passive = <250>; /* milliseconds */
+ polling-delay = <1000>; /* milliseconds */
+
+ thermal-sensors = <&scpi_sensors 0>;
+
+ trips {
+ cpu_alert0: cpu-alert0 {
+ temperature = <70000>; /* millicelsius */
+ hysteresis = <2000>; /* millicelsius */
+ type = "active";
+ };
+
+ cpu_alert1: cpu-alert1 {
+ temperature = <80000>; /* millicelsius */
+ hysteresis = <2000>; /* millicelsius */
+ type = "passive";
+ };
+ };
+
+ cooling-maps {
+ map0 {
+ trip = <&cpu_alert1>;
+ cooling-device = <&cpu0 THERMAL_NO_LIMIT THERMAL_NO_LIMIT>,
+ <&cpu1 THERMAL_NO_LIMIT THERMAL_NO_LIMIT>,
+ <&cpu2 THERMAL_NO_LIMIT THERMAL_NO_LIMIT>,
+ <&cpu3 THERMAL_NO_LIMIT THERMAL_NO_LIMIT>;
+ };
+ };
+ };
+ };
};
&cec_AO {
@@ -72,6 +106,22 @@
hdmi-phandle = <&hdmi_tx>;
};
+&cpu0 {
+ #cooling-cells = <2>;
+};
+
+&cpu1 {
+ #cooling-cells = <2>;
+};
+
+&cpu2 {
+ #cooling-cells = <2>;
+};
+
+&cpu3 {
+ #cooling-cells = <2>;
+};
+
&hdmi_tx {
status = "okay";
pinctrl-0 = <&hdmi_hpd_pins>, <&hdmi_i2c_pins>;
--
2.17.1

View file

@ -0,0 +1,54 @@
From 49730246e686155ff656d9bd3574347fcd99c360 Mon Sep 17 00:00:00 2001
From: chewitt <github@chrishewitt.net>
Date: Sun, 11 Aug 2019 10:01:25 +0000
Subject: [PATCH 084/101] WIP: arm64: dts: meson-g12b-khadas-vim3: add the
Ethernet PHY interrupt line
apply the same change as [0] to VIM3.
[0] https://github.com/torvalds/linux/commit/98ba71c94eaff1c3af6170bce9fe63c93dd32f2f
Signed-off-by: Christian Hewitt <christianshewitt@gmail.com>
---
.../dts/amlogic/meson-g12b-khadas-vim3.dtsi | 25 +++++++++++++++++++
1 file changed, 25 insertions(+)
diff --git a/arch/arm64/boot/dts/amlogic/meson-g12b-khadas-vim3.dtsi b/arch/arm64/boot/dts/amlogic/meson-g12b-khadas-vim3.dtsi
index c33e85fbdaba..8158a97a92cb 100644
--- a/arch/arm64/boot/dts/amlogic/meson-g12b-khadas-vim3.dtsi
+++ b/arch/arm64/boot/dts/amlogic/meson-g12b-khadas-vim3.dtsi
@@ -154,6 +154,31 @@
clock-latency = <50000>;
};
+&ext_mdio {
+ external_phy: ethernet-phy@0 {
+ /* Realtek RTL8211F (0x001cc916) */
+ reg = <0>;
+ max-speed = <1000>;
+
+ interrupt-parent = <&gpio_intc>;
+ /* MAC_INTR on GPIOZ_14 */
+ interrupts = <26 IRQ_TYPE_LEVEL_LOW>;
+ };
+};
+
+&ethmac {
+ pinctrl-0 = <&eth_pins>, <&eth_rgmii_pins>;
+ pinctrl-names = "default";
+ status = "okay";
+ phy-mode = "rgmii";
+ phy-handle = <&external_phy>;
+ amlogic,tx-delay-ns = <2>;
+};
+
+&frddr_a {
+ status = "okay";
+};
+
&frddr_b {
status = "okay";
};
--
2.17.1

View file

@ -0,0 +1,62 @@
From 6f010e1f35e82ba7d05e7738b391b8b7b53eb1cf Mon Sep 17 00:00:00 2001
From: Neil Armstrong <narmstrong@baylibre.com>
Date: Thu, 20 Feb 2020 15:58:14 +0000
Subject: [PATCH 085/101] WIP: ASoC: meson: add 2/8 channel constraints
The audio hardware can output in 2 or 8 channels only, so we need must
ensure we start in only these two configurations.
Signed-off-by: Neil Armstrong <narmstrong@baylibre.com>
---
sound/soc/meson/aiu-fifo-i2s.c | 27 ++++++++++++++++++++++++++-
1 file changed, 26 insertions(+), 1 deletion(-)
diff --git a/sound/soc/meson/aiu-fifo-i2s.c b/sound/soc/meson/aiu-fifo-i2s.c
index 9a5271ce80fe..87e0c85eacc8 100644
--- a/sound/soc/meson/aiu-fifo-i2s.c
+++ b/sound/soc/meson/aiu-fifo-i2s.c
@@ -118,15 +118,40 @@ static int aiu_fifo_i2s_hw_params(struct snd_pcm_substream *substream,
snd_soc_component_update_bits(component, AIU_MEM_I2S_MASKS,
AIU_MEM_I2S_MASKS_IRQ_BLOCK, val);
+ snd_soc_component_write(component, AIU_RST_SOFT,
+ AIU_RST_SOFT_I2S_FAST);
+ snd_soc_component_read(component, AIU_I2S_SYNC, &val);
+
return 0;
}
+static const unsigned int channels_2_8[] = {
+ 2, 8
+};
+
+static const struct snd_pcm_hw_constraint_list hw_constraints_2_8_channels = {
+ .count = ARRAY_SIZE(channels_2_8),
+ .list = channels_2_8,
+ .mask = 0,
+};
+
+static int aiu_fifo_i2s_startup(struct snd_pcm_substream *substream,
+ struct snd_soc_dai *dai)
+{
+ /* Make sure either 2ch or 8ch is selected */
+ snd_pcm_hw_constraint_list(substream->runtime, 0,
+ SNDRV_PCM_HW_PARAM_CHANNELS,
+ &hw_constraints_2_8_channels);
+
+ return aiu_fifo_startup(substream, dai);
+}
+
const struct snd_soc_dai_ops aiu_fifo_i2s_dai_ops = {
.trigger = aiu_fifo_i2s_trigger,
.prepare = aiu_fifo_i2s_prepare,
.hw_params = aiu_fifo_i2s_hw_params,
.hw_free = aiu_fifo_hw_free,
- .startup = aiu_fifo_startup,
+ .startup = aiu_fifo_i2s_startup,
.shutdown = aiu_fifo_shutdown,
};
--
2.17.1

View file

@ -0,0 +1,45 @@
From 39727c90aad7a77d216092f55e3604792826c820 Mon Sep 17 00:00:00 2001
From: Nick Xie <nick@khadas.com>
Date: Fri, 21 Aug 2020 14:59:07 +0800
Subject: [PATCH 26/40] GX: update TEXT_OFFSET for Amlogic MESON SoC
Signed-off-by: Nick Xie <nick@khadas.com>
---
arch/arm64/Makefile | 4 ++++
arch/arm64/kernel/head.S | 4 ++--
2 files changed, 6 insertions(+), 2 deletions(-)
diff --git a/arch/arm64/Makefile b/arch/arm64/Makefile
index 148362c285f8..e4cb0644f693 100644
--- a/arch/arm64/Makefile
+++ b/arch/arm64/Makefile
@@ -128,7 +128,11 @@ endif
head-y := arch/arm64/kernel/head.o
# The byte offset of the kernel image in RAM from the start of RAM.
+ifeq ($(CONFIG_ARCH_MESON),y)
+TEXT_OFFSET := 0x01080000
+else
TEXT_OFFSET := 0x0
+endif
ifeq ($(CONFIG_KASAN_SW_TAGS), y)
KASAN_SHADOW_SCALE_SHIFT := 4
diff --git a/arch/arm64/kernel/head.S b/arch/arm64/kernel/head.S
index 037421c66b14..18b37e2d2a00 100644
--- a/arch/arm64/kernel/head.S
+++ b/arch/arm64/kernel/head.S
@@ -42,8 +42,8 @@
#error TEXT_OFFSET must be at least 4KB aligned
#elif (PAGE_OFFSET & 0x1fffff) != 0
#error PAGE_OFFSET must be at least 2MB aligned
-#elif TEXT_OFFSET > 0x1fffff
-#error TEXT_OFFSET must be less than 2MB
+//#elif TEXT_OFFSET > 0x1fffff
+//#error TEXT_OFFSET must be less than 2MB
#endif
/*
--
2.25.1

View file

@ -0,0 +1,53 @@
Use devm_platform_ioremap_resource() to simplify code.
Signed-off-by: Yangtao Li <tiny.windzz@gmail.com>
---
drivers/soc/amlogic/meson-canvas.c | 4 +---
drivers/soc/amlogic/meson-clk-measure.c | 4 +---
2 files changed, 2 insertions(+), 6 deletions(-)
diff --git a/drivers/soc/amlogic/meson-canvas.c b/drivers/soc/amlogic/meson-canvas.c
index c655f5f92b12..561044063319 100644
--- a/drivers/soc/amlogic/meson-canvas.c
+++ b/drivers/soc/amlogic/meson-canvas.c
@@ -166,7 +166,6 @@ EXPORT_SYMBOL_GPL(meson_canvas_free);
static int meson_canvas_probe(struct platform_device *pdev)
{
- struct resource *res;
struct meson_canvas *canvas;
struct device *dev = &pdev->dev;
@@ -174,8 +173,7 @@ static int meson_canvas_probe(struct platform_device *pdev)
if (!canvas)
return -ENOMEM;
- res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
- canvas->reg_base = devm_ioremap_resource(dev, res);
+ canvas->reg_base = devm_platform_ioremap_resource(pdev, 0);
if (IS_ERR(canvas->reg_base))
return PTR_ERR(canvas->reg_base);
diff --git a/drivers/soc/amlogic/meson-clk-measure.c b/drivers/soc/amlogic/meson-clk-measure.c
index 0fa47d77577d..173baa53fce3 100644
--- a/drivers/soc/amlogic/meson-clk-measure.c
+++ b/drivers/soc/amlogic/meson-clk-measure.c
@@ -605,7 +605,6 @@ static int meson_msr_probe(struct platform_device *pdev)
{
const struct meson_msr_id *match_data;
struct meson_msr *priv;
- struct resource *res;
struct dentry *root, *clks;
void __iomem *base;
int i;
@@ -623,8 +622,7 @@ static int meson_msr_probe(struct platform_device *pdev)
memcpy(priv->msr_table, match_data, sizeof(priv->msr_table));
- res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
- base = devm_ioremap_resource(&pdev->dev, res);
+ base = devm_platform_ioremap_resource(pdev, 0);
if (IS_ERR(base)) {
dev_err(&pdev->dev, "io resource mapping failed\n");
return PTR_ERR(base);

View file

@ -0,0 +1,74 @@
From d714aa2f0b8cb6265beb0d15f99d4c87fb934c15 Mon Sep 17 00:00:00 2001
From: Nick Xie <nick@khadas.com>
Date: Wed, 25 Dec 2019 13:41:52 +0800
Subject: [PATCH 100/101] ETH: setup mac address from command line
Signed-off-by: Nick Xie <nick@khadas.com>
---
.../ethernet/stmicro/stmmac/stmmac_platform.c | 42 +++++++++++++++++++
1 file changed, 42 insertions(+)
diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c
index 13fafd905db8..2b2dccd04cbf 100644
--- a/drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c
+++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c
@@ -21,6 +21,40 @@
#ifdef CONFIG_OF
+#if defined (CONFIG_DWMAC_MESON) || defined (CONFIG_DWMAC_ROCKCHIP)
+static u8 DEFMAC[] = {0, 0, 0, 0, 0, 0};
+static unsigned int g_mac_addr_setup;
+static unsigned char chartonum(char c)
+{
+ if (c >= '0' && c <= '9')
+ return c - '0';
+ if (c >= 'A' && c <= 'F')
+ return (c - 'A') + 10;
+ if (c >= 'a' && c <= 'f')
+ return (c - 'a') + 10;
+
+ return 0;
+}
+
+static int __init mac_addr_set(char *line)
+{
+ unsigned char mac[6];
+ int i = 0;
+
+ for (i = 0; i < 6 && line[0] != '\0' && line[1] != '\0'; i++) {
+ mac[i] = chartonum(line[0]) << 4 | chartonum(line[1]);
+ line += 3;
+ }
+ memcpy(DEFMAC, mac, 6);
+ pr_info("uboot setup mac-addr: %02x:%02x:%02x:%02x:%02x:%02x\n",
+ DEFMAC[0], DEFMAC[1], DEFMAC[2], DEFMAC[3], DEFMAC[4], DEFMAC[5]);
+ g_mac_addr_setup++;
+ return 0;
+}
+__setup("mac=", mac_addr_set);
+#endif
+
+
/**
* dwmac1000_validate_mcast_bins - validates the number of Multicast filter bins
* @dev: struct device of the platform device
@@ -404,7 +438,15 @@ stmmac_probe_config_dt(struct platform_device *pdev, const char **mac)
if (!plat)
return ERR_PTR(-ENOMEM);
+#if defined (CONFIG_DWMAC_MESON) || defined (CONFIG_DWMAC_ROCKCHIP)
+ if (g_mac_addr_setup) /*so uboot mac= is first priority.*/
+ *mac = DEFMAC;
+ else
+ *mac = of_get_mac_address(np);
+#else
*mac = of_get_mac_address(np);
+#endif
+
if (IS_ERR(*mac)) {
if (PTR_ERR(*mac) == -EPROBE_DEFER)
return ERR_CAST(*mac);
--
2.17.1

View file

@ -0,0 +1,29 @@
From 192ff185a6f85f2519cc4b97aa015a836f5a8fbb Mon Sep 17 00:00:00 2001
From: Jonas Karlman <jonas@kwiboo.se>
Date: Mon, 9 Jul 2018 21:25:15 +0200
Subject: [PATCH 10/84] TEMP: drm: dw-hdmi: call hdmi_set_cts_n after clock is
enabled
---
drivers/gpu/drm/bridge/synopsys/dw-hdmi.c | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/drivers/gpu/drm/bridge/synopsys/dw-hdmi.c b/drivers/gpu/drm/bridge/synopsys/dw-hdmi.c
index 521d689..e4ab11a 100644
--- a/drivers/gpu/drm/bridge/synopsys/dw-hdmi.c
+++ b/drivers/gpu/drm/bridge/synopsys/dw-hdmi.c
@@ -688,6 +688,11 @@ static void hdmi_enable_audio_clk(struct dw_hdmi *hdmi, bool enable)
else
hdmi->mc_clkdis |= HDMI_MC_CLKDIS_AUDCLK_DISABLE;
hdmi_writeb(hdmi, hdmi->mc_clkdis, HDMI_MC_CLKDIS);
+
+ if (enable) {
+ hdmi_set_cts_n(hdmi, hdmi->audio_cts, 0);
+ hdmi_set_cts_n(hdmi, hdmi->audio_cts, hdmi->audio_n);
+ }
}
static void dw_hdmi_ahb_audio_enable(struct dw_hdmi *hdmi)
--
2.7.1

View file

@ -0,0 +1,89 @@
add register configuration to activate wakeup feature in bl301
Tested-by: Kevin Hilman <khilman@baylibre.com>
Signed-off-by: Guillaume La Roque <glaroque@baylibre.com>
Reviewed-by: Neil Armstrong <narmstrong@baylibre.com>
---
drivers/media/platform/meson/ao-cec-g12a.c | 33 ++++++++++++++++++++++
1 file changed, 33 insertions(+)
diff --git a/drivers/media/cec/platform/meson/ao-cec-g12a.c b/drivers/media/cec/platform/meson/ao-cec-g12a.c
index 891533060d49..85850b974126 100644
--- a/drivers/media/cec/platform/meson/ao-cec-g12a.c
+++ b/drivers/media/cec/platform/meson/ao-cec-g12a.c
@@ -25,6 +25,7 @@
#include <media/cec.h>
#include <media/cec-notifier.h>
#include <linux/clk-provider.h>
+#include <linux/mfd/syscon.h>
/* CEC Registers */
@@ -168,6 +169,18 @@
#define CECB_WAKEUPCTRL 0x31
+#define CECB_FUNC_CFG_REG 0xA0
+#define CECB_FUNC_CFG_MASK GENMASK(6, 0)
+#define CECB_FUNC_CFG_CEC_ON 0x01
+#define CECB_FUNC_CFG_OTP_ON 0x02
+#define CECB_FUNC_CFG_AUTO_STANDBY 0x04
+#define CECB_FUNC_CFG_AUTO_POWER_ON 0x08
+#define CECB_FUNC_CFG_ALL 0x2f
+#define CECB_FUNC_CFG_NONE 0x0
+
+#define CECB_LOG_ADDR_REG 0xA4
+#define CECB_LOG_ADDR_MASK GENMASK(22, 16)
+
struct meson_ao_cec_g12a_data {
/* Setup the internal CECB_CTRL2 register */
bool ctrl2_setup;
@@ -177,6 +190,7 @@ struct meson_ao_cec_g12a_device {
struct platform_device *pdev;
struct regmap *regmap;
struct regmap *regmap_cec;
+ struct regmap *regmap_ao_sysctrl;
spinlock_t cec_reg_lock;
struct cec_notifier *notify;
struct cec_adapter *adap;
@@ -518,6 +532,13 @@ meson_ao_cec_g12a_set_log_addr(struct cec_adapter *adap, u8 logical_addr)
BIT(logical_addr - 8));
}
+ if (ao_cec->regmap_ao_sysctrl)
+ ret |= regmap_update_bits(ao_cec->regmap_ao_sysctrl,
+ CECB_LOG_ADDR_REG,
+ CECB_LOG_ADDR_MASK,
+ FIELD_PREP(CECB_LOG_ADDR_MASK,
+ logical_addr));
+
/* Always set Broadcast/Unregistered 15 address */
ret |= regmap_update_bits(ao_cec->regmap_cec, CECB_LADD_HIGH,
BIT(CEC_LOG_ADDR_UNREGISTERED - 8),
@@ -618,6 +639,13 @@ static int meson_ao_cec_g12a_adap_enable(struct cec_adapter *adap, bool enable)
regmap_write(ao_cec->regmap_cec, CECB_CTRL2,
FIELD_PREP(CECB_CTRL2_RISE_DEL_MAX, 2));
+ if (ao_cec->regmap_ao_sysctrl) {
+ regmap_update_bits(ao_cec->regmap_ao_sysctrl,
+ CECB_FUNC_CFG_REG,
+ CECB_FUNC_CFG_MASK,
+ CECB_FUNC_CFG_ALL);
+ }
+
meson_ao_cec_g12a_irq_setup(ao_cec, true);
return 0;
@@ -685,6 +713,11 @@ static int meson_ao_cec_g12a_probe(struct platform_device *pdev)
goto out_probe_adapter;
}
+ ao_cec->regmap_ao_sysctrl = syscon_regmap_lookup_by_phandle
+ (pdev->dev.of_node, "amlogic,ao-sysctrl");
+ if (IS_ERR(ao_cec->regmap_ao_sysctrl))
+ dev_warn(&pdev->dev, "ao-sysctrl syscon regmap lookup failed.\n");
+
irq = platform_get_irq(pdev, 0);
ret = devm_request_threaded_irq(&pdev->dev, irq,
meson_ao_cec_g12a_irq,

View file

@ -0,0 +1,41 @@
From 2c590b18eee0a8cfe163ab2dc994f211f76853b8 Mon Sep 17 00:00:00 2001
From: Nick Xie <nick@khadas.com>
Date: Wed, 1 Apr 2020 14:11:35 +0800
Subject: [PATCH 095/101] arm64: dts: sdio: VIM1/VIM2: change freq to 100MHz
Signed-off-by: Nick Xie <nick@khadas.com>
---
arch/arm64/boot/dts/amlogic/meson-gxl-s905x-khadas-vim.dts | 3 +++
arch/arm64/boot/dts/amlogic/meson-gxm-khadas-vim2.dts | 2 +-
2 files changed, 4 insertions(+), 1 deletion(-)
diff --git a/arch/arm64/boot/dts/amlogic/meson-gxl-s905x-khadas-vim.dts b/arch/arm64/boot/dts/amlogic/meson-gxl-s905x-khadas-vim.dts
index 8637e6a42bb8..0786ea55f839 100644
--- a/arch/arm64/boot/dts/amlogic/meson-gxl-s905x-khadas-vim.dts
+++ b/arch/arm64/boot/dts/amlogic/meson-gxl-s905x-khadas-vim.dts
@@ -230,6 +230,9 @@
};
&sd_emmc_a {
+
+ max-frequency = <100000000>;
+
brcmf: wifi@1 {
reg = <1>;
compatible = "brcm,bcm4329-fmac";
diff --git a/arch/arm64/boot/dts/amlogic/meson-gxm-khadas-vim2.dts b/arch/arm64/boot/dts/amlogic/meson-gxm-khadas-vim2.dts
index 5ef329f10a06..8060e97d764f 100644
--- a/arch/arm64/boot/dts/amlogic/meson-gxm-khadas-vim2.dts
+++ b/arch/arm64/boot/dts/amlogic/meson-gxm-khadas-vim2.dts
@@ -397,7 +397,7 @@
#size-cells = <0>;
bus-width = <4>;
- max-frequency = <60000000>;
+ max-frequency = <100000000>;
non-removable;
disable-wp;
--
2.17.1

View file

@ -0,0 +1,922 @@
From 9d62f1b8abb852a12a437b94ddc67c3294dd0953 Mon Sep 17 00:00:00 2001
From: Nick Xie <nick@khadas.com>
Date: Mon, 23 Dec 2019 22:51:19 +0800
Subject: [PATCH 098/101] arm64: dts: VIMs: add simple MCU driver for FAN
Signed-off-by: Nick Xie <nick@khadas.com>
---
.../amlogic/meson-gxl-s905x-khadas-vim.dts | 10 +
.../dts/amlogic/meson-gxm-khadas-vim2.dts | 10 +
.../boot/dts/amlogic/meson-khadas-vim3.dtsi | 10 +
drivers/hwmon/scpi-hwmon.c | 18 +
drivers/misc/Kconfig | 5 +
drivers/misc/Makefile | 1 +
drivers/misc/khadas-mcu.c | 720 ++++++++++++++++++
drivers/thermal/amlogic_thermal.c | 19 +
8 files changed, 793 insertions(+)
create mode 100644 drivers/misc/khadas-mcu.c
diff --git a/arch/arm64/boot/dts/amlogic/meson-gxl-s905x-khadas-vim.dts b/arch/arm64/boot/dts/amlogic/meson-gxl-s905x-khadas-vim.dts
index 0786ea55f839..02b6691768b3 100644
--- a/arch/arm64/boot/dts/amlogic/meson-gxl-s905x-khadas-vim.dts
+++ b/arch/arm64/boot/dts/amlogic/meson-gxl-s905x-khadas-vim.dts
@@ -155,6 +155,16 @@
clock-frequency = <32768>;
clock-output-names = "xin32k";
};
+
+ khadas-mcu@18 {
+ status = "okay";
+ compatible = "khadas-mcu";
+ reg = <0x18>;
+ fan,trig_temp_level0 = <50>;
+ fan,trig_temp_level1 = <60>;
+ fan,trig_temp_level2 = <70>;
+ hwver = "VIM1.V12"; /* Will be updated in uboot. */
+ };
};
&ir {
diff --git a/arch/arm64/boot/dts/amlogic/meson-gxm-khadas-vim2.dts b/arch/arm64/boot/dts/amlogic/meson-gxm-khadas-vim2.dts
index 57de06faa841..f9ec3f3efbe1 100644
--- a/arch/arm64/boot/dts/amlogic/meson-gxm-khadas-vim2.dts
+++ b/arch/arm64/boot/dts/amlogic/meson-gxm-khadas-vim2.dts
@@ -363,6 +363,16 @@
clock-frequency = <32768>;
clock-output-names = "xin32k";
};
+
+ khadas-mcu@18 {
+ status = "okay";
+ compatible = "khadas-mcu";
+ reg = <0x18>;
+ fan,trig_temp_level0 = <50>;
+ fan,trig_temp_level1 = <60>;
+ fan,trig_temp_level2 = <70>;
+ hwver = "VIM2.V12"; /* Will be updated in uboot. */
+ };
};
&ir {
diff --git a/arch/arm64/boot/dts/amlogic/meson-khadas-vim3.dtsi b/arch/arm64/boot/dts/amlogic/meson-khadas-vim3.dtsi
index 6d0163f56b0d..f6b5de8328ac 100644
--- a/arch/arm64/boot/dts/amlogic/meson-khadas-vim3.dtsi
+++ b/arch/arm64/boot/dts/amlogic/meson-khadas-vim3.dtsi
@@ -242,6 +242,16 @@
reg = <0x51>;
#clock-cells = <0>;
};
+
+ khadas-mcu@18 {
+ status = "okay";
+ compatible = "khadas-mcu";
+ reg = <0x18>;
+ fan,trig_temp_level0 = <50>;
+ fan,trig_temp_level1 = <60>;
+ fan,trig_temp_level2 = <70>;
+ hwver = "VIM3.V11"; /* Will be updated in uboot. */
+ };
};
&ir {
diff --git a/drivers/hwmon/scpi-hwmon.c b/drivers/hwmon/scpi-hwmon.c
index 25aac40f2764..3dd7af04c5bd 100644
--- a/drivers/hwmon/scpi-hwmon.c
+++ b/drivers/hwmon/scpi-hwmon.c
@@ -54,6 +54,8 @@ static const u32 scpi_scale[] = {
[ENERGY] = 1000000, /* (microjoules) */
};
+static struct scpi_thermal_zone *g_scpi_thermal_zone_ptr;
+
static void scpi_scale_reading(u64 *value, struct sensor_data *sensor)
{
if (scpi_scale[sensor->info.class] != sensor->scale) {
@@ -81,6 +83,20 @@ static int scpi_read_temp(void *dev, int *temp)
return 0;
}
+int meson_gx_get_temperature(void)
+{
+ int temp;
+ int ret;
+ ret = scpi_read_temp(g_scpi_thermal_zone_ptr, &temp);
+ if (ret) {
+ printk("scpi_read_temp() failed!\n");
+ return ret;
+ }
+
+ return temp / 1000;
+}
+EXPORT_SYMBOL(meson_gx_get_temperature);
+
/* hwmon callback functions */
static ssize_t
scpi_show_sensor(struct device *dev, struct device_attribute *attr, char *buf)
@@ -266,6 +282,8 @@ static int scpi_hwmon_probe(struct platform_device *pdev)
if (!zone)
return -ENOMEM;
+ g_scpi_thermal_zone_ptr = zone;
+
zone->sensor_id = i;
zone->scpi_sensors = scpi_sensors;
z = devm_thermal_zone_of_sensor_register(dev,
diff --git a/drivers/misc/Kconfig b/drivers/misc/Kconfig
index 7f0d48f406e3..fb0a3830fd87 100644
--- a/drivers/misc/Kconfig
+++ b/drivers/misc/Kconfig
@@ -465,6 +465,11 @@ config PVPANIC
a paravirtualized device provided by QEMU; it lets a virtual machine
(guest) communicate panic events to the host.
+config KHADAS_MCU
+ tristate "Khadas boards on-board MCU"
+ help
+ This driver provides support for Khadas boards on-board MCU.
+
source "drivers/misc/c2port/Kconfig"
source "drivers/misc/eeprom/Kconfig"
source "drivers/misc/cb710/Kconfig"
diff --git a/drivers/misc/Makefile b/drivers/misc/Makefile
index c1860d35dc7e..9bbf2a479405 100644
--- a/drivers/misc/Makefile
+++ b/drivers/misc/Makefile
@@ -57,3 +57,4 @@ obj-y += cardreader/
obj-$(CONFIG_PVPANIC) += pvpanic.o
obj-$(CONFIG_HABANA_AI) += habanalabs/
obj-$(CONFIG_XILINX_SDFEC) += xilinx_sdfec.o
+obj-$(CONFIG_KHADAS_MCU) += khadas-mcu.o
diff --git a/drivers/misc/khadas-mcu.c b/drivers/misc/khadas-mcu.c
new file mode 100644
index 000000000000..7c6f2903b7a5
--- /dev/null
+++ b/drivers/misc/khadas-mcu.c
@@ -0,0 +1,720 @@
+/*
+ * Khadas MCU control driver
+ *
+ * Written by: Nick <nick@khadas.com>
+ *
+ * Copyright (c) 2019 Shenzhen Wesion Technology Co., Ltd.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ */
+
+#include <linux/module.h>
+#include <linux/i2c.h>
+#include <linux/string.h>
+#include <linux/list.h>
+#include <linux/sysfs.h>
+#include <linux/ctype.h>
+#include <linux/device.h>
+#include <linux/slab.h>
+#include <linux/of.h>
+#include <linux/of_address.h>
+
+
+/* Device registers */
+#define MCU_BOOT_EN_WOL_REG 0x21
+#define MCU_CMD_FAN_STATUS_CTRL_REG 0x88
+#define MCU_USB_PCIE_SWITCH_REG 0x33 /* VIM3/VIM3L only */
+#define MCU_PWR_OFF_CMD_REG 0x80
+#define MCU_SHUTDOWN_NORMAL_REG 0x2c
+
+#define MCU_FAN_TRIG_TEMP_LEVEL0 50 // 50 degree if not set
+#define MCU_FAN_TRIG_TEMP_LEVEL1 60 // 60 degree if not set
+#define MCU_FAN_TRIG_TEMP_LEVEL2 70 // 70 degree if not set
+#define MCU_FAN_TRIG_MAXTEMP 80
+#define MCU_FAN_LOOP_SECS (30 * HZ) // 30 seconds
+#define MCU_FAN_TEST_LOOP_SECS (5 * HZ) // 5 seconds
+#define MCU_FAN_LOOP_NODELAY_SECS 0
+#define MCU_FAN_SPEED_OFF 0
+#define MCU_FAN_SPEED_LOW 1
+#define MCU_FAN_SPEED_MID 2
+#define MCU_FAN_SPEED_HIGH 3
+
+enum mcu_fan_mode {
+ MCU_FAN_MODE_MANUAL = 0,
+ MCU_FAN_MODE_AUTO,
+};
+
+enum mcu_fan_level {
+ MCU_FAN_LEVEL_0 = 0,
+ MCU_FAN_LEVEL_1,
+ MCU_FAN_LEVEL_2,
+ MCU_FAN_LEVEL_3,
+};
+
+enum mcu_fan_status {
+ MCU_FAN_STATUS_DISABLE = 0,
+ MCU_FAN_STATUS_ENABLE,
+};
+
+enum mcu_usb_pcie_switch_mode {
+ MCU_USB_PCIE_SWITCH_MODE_USB3 = 0,
+ MCU_USB_PCIE_SWITCH_MODE_PCIE
+};
+
+enum khadas_board_hwver {
+ KHADAS_BOARD_HWVER_NONE = 0,
+ KHADAS_BOARD_HWVER_V11,
+ KHADAS_BOARD_HWVER_V12,
+ KHADAS_BOARD_HWVER_V13,
+ KHADAS_BOARD_HWVER_V14
+};
+
+enum khadas_board {
+ KHADAS_BOARD_NONE,
+ KHADAS_BOARD_VIM1,
+ KHADAS_BOARD_VIM2,
+ KHADAS_BOARD_VIM3
+};
+
+struct mcu_fan_data {
+ struct platform_device *pdev;
+ struct class *fan_class;
+ struct delayed_work work;
+ struct delayed_work fan_test_work;
+ enum mcu_fan_status enable;
+ enum mcu_fan_mode mode;
+ enum mcu_fan_level level;
+ int trig_temp_level0;
+ int trig_temp_level1;
+ int trig_temp_level2;
+};
+
+struct mcu_data {
+ struct i2c_client *client;
+ struct class *usb_pcie_switch_class;
+ struct class *mcu_class;
+ u8 usb_pcie_switch_mode;
+ enum khadas_board board;
+ enum khadas_board_hwver hwver;
+ struct mcu_fan_data fan_data;
+};
+
+struct mcu_data *g_mcu_data;
+
+static char * mcu_board_type_to_str(enum khadas_board board)
+{
+ switch (board) {
+ case KHADAS_BOARD_NONE:
+ return "Unknown";
+ case KHADAS_BOARD_VIM1:
+ return "VIM1";
+ case KHADAS_BOARD_VIM2:
+ return "VIM2";
+ case KHADAS_BOARD_VIM3:
+ return "VIM3";
+ default:
+ return "Unknown";
+ }
+}
+
+static char * mcu_board_hardware_version_str(enum khadas_board_hwver hwver)
+{
+ switch (hwver) {
+ case KHADAS_BOARD_HWVER_NONE:
+ return "Unknown";
+ case KHADAS_BOARD_HWVER_V11:
+ return "V11";
+ case KHADAS_BOARD_HWVER_V12:
+ return "V12";
+ case KHADAS_BOARD_HWVER_V13:
+ return "V13";
+ case KHADAS_BOARD_HWVER_V14:
+ return "V14";
+ default:
+ return "Unknown";
+ }
+}
+
+static int i2c_master_reg8_send(const struct i2c_client *client,
+ const char reg, const char *buf, int count)
+{
+ struct i2c_adapter *adap = client->adapter;
+ struct i2c_msg msg;
+ int ret;
+ char *tx_buf = kzalloc(count + 1, GFP_KERNEL);
+ if (!tx_buf)
+ return -ENOMEM;
+ tx_buf[0] = reg;
+ memcpy(tx_buf+1, buf, count);
+
+ msg.addr = client->addr;
+ msg.flags = client->flags;
+ msg.len = count + 1;
+ msg.buf = (char *)tx_buf;
+
+ ret = i2c_transfer(adap, &msg, 1);
+ kfree(tx_buf);
+ return (ret == 1) ? count : ret;
+}
+
+static int i2c_master_reg8_recv(const struct i2c_client *client,
+ const char reg, char *buf, int count)
+{
+ struct i2c_adapter *adap = client->adapter;
+ struct i2c_msg msgs[2];
+ int ret;
+ char reg_buf = reg;
+
+ msgs[0].addr = client->addr;
+ msgs[0].flags = client->flags;
+ msgs[0].len = 1;
+ msgs[0].buf = &reg_buf;
+
+ msgs[1].addr = client->addr;
+ msgs[1].flags = client->flags | I2C_M_RD;
+ msgs[1].len = count;
+ msgs[1].buf = (char *)buf;
+
+ ret = i2c_transfer(adap, msgs, 2);
+
+ return (ret == 2) ? count : ret;
+}
+
+static int mcu_i2c_read_regs(struct i2c_client *client,
+ u8 reg, u8 buf[], unsigned len)
+{
+ int ret;
+ ret = i2c_master_reg8_recv(client, reg, buf, len);
+ return ret;
+}
+
+static int mcu_i2c_write_regs(struct i2c_client *client,
+ u8 reg, u8 const buf[], __u16 len)
+{
+ int ret;
+ ret = i2c_master_reg8_send(client, reg, buf, (int)len);
+ return ret;
+}
+
+static int is_mcu_fan_control_supported(void)
+{
+ // MCU FAN control is supported for:
+ // 1. Khadas VIM1 V13 and later
+ // 2. Khadas VIM2 V13 and later
+ // 3. Khadas VIM3 V11 and later
+ if (KHADAS_BOARD_VIM1 == g_mcu_data->board) {
+ if (g_mcu_data->hwver >= KHADAS_BOARD_HWVER_V13)
+ return 1;
+ else
+ return 0;
+ } else if (KHADAS_BOARD_VIM2 == g_mcu_data->board) {
+ if (g_mcu_data->hwver > KHADAS_BOARD_HWVER_V12)
+ return 1;
+ else
+ return 0;
+ } else if (KHADAS_BOARD_VIM3 == g_mcu_data->board) {
+ if (g_mcu_data->hwver >= KHADAS_BOARD_HWVER_V11)
+ return 1;
+ else
+ return 0;
+ } else
+ return 0;
+}
+
+static bool is_mcu_usb_pcie_switch_supported(void)
+{
+ // MCU USB PCIe switch is supported for:
+ // 1. Khadas VIM3
+ if (KHADAS_BOARD_VIM3 == g_mcu_data->board)
+ return 1;
+ else
+ return 0;
+}
+
+static void mcu_fan_level_set(struct mcu_fan_data *fan_data, int level)
+{
+ if (is_mcu_fan_control_supported()) {
+ int ret;
+ u8 data[2] = {0};
+
+ if(0 == level) {
+ data[0] = MCU_FAN_SPEED_OFF;
+ }else if(1 == level){
+ data[0] = MCU_FAN_SPEED_LOW;
+ }else if(2 == level){
+ data[0] = MCU_FAN_SPEED_MID;
+ }else if(3 == level){
+ data[0] = MCU_FAN_SPEED_HIGH;
+ }
+
+ g_mcu_data->fan_data.level = data[0];
+
+ ret = mcu_i2c_write_regs(g_mcu_data->client, MCU_CMD_FAN_STATUS_CTRL_REG, data, 1);
+ if (ret < 0) {
+ printk("write fan control err\n");
+ return;
+ }
+ }
+}
+
+extern int meson_gx_get_temperature(void);
+extern int meson_g12_get_temperature(void);
+static void fan_work_func(struct work_struct *_work)
+{
+ if (is_mcu_fan_control_supported()) {
+ int temp = -EINVAL;
+ struct mcu_fan_data *fan_data = &g_mcu_data->fan_data;
+
+ if ((KHADAS_BOARD_VIM1 == g_mcu_data->board) ||
+ (KHADAS_BOARD_VIM2 == g_mcu_data->board))
+ temp = meson_gx_get_temperature();
+ else if (KHADAS_BOARD_VIM3 == g_mcu_data->board)
+ temp = meson_g12_get_temperature();
+
+ if(temp != -EINVAL){
+ if(temp < fan_data->trig_temp_level0 ) {
+ mcu_fan_level_set(fan_data, 0);
+ }else if(temp < fan_data->trig_temp_level1 ) {
+ mcu_fan_level_set(fan_data, 1);
+ }else if(temp < fan_data->trig_temp_level2 ) {
+ mcu_fan_level_set(fan_data, 2);
+ }else{
+ mcu_fan_level_set(fan_data, 3);
+ }
+ }
+
+ schedule_delayed_work(&fan_data->work, MCU_FAN_LOOP_SECS);
+ }
+}
+
+static void khadas_fan_set(struct mcu_fan_data *fan_data)
+{
+ if (is_mcu_fan_control_supported()) {
+
+ cancel_delayed_work(&fan_data->work);
+
+ if (fan_data->enable == MCU_FAN_STATUS_DISABLE) {
+ mcu_fan_level_set(fan_data, 0);
+ return;
+ }
+ switch (fan_data->mode) {
+ case MCU_FAN_MODE_MANUAL:
+ switch(fan_data->level) {
+ case MCU_FAN_LEVEL_0:
+ mcu_fan_level_set(fan_data, 0);
+ break;
+ case MCU_FAN_LEVEL_1:
+ mcu_fan_level_set(fan_data, 1);
+ break;
+ case MCU_FAN_LEVEL_2:
+ mcu_fan_level_set(fan_data, 2);
+ break;
+ case MCU_FAN_LEVEL_3:
+ mcu_fan_level_set(fan_data, 3);
+ break;
+ default:
+ break;
+ }
+ break;
+
+ case MCU_FAN_MODE_AUTO:
+ // FIXME: achieve with a better way
+ schedule_delayed_work(&fan_data->work, MCU_FAN_LOOP_NODELAY_SECS);
+ break;
+
+ default:
+ break;
+ }
+ }
+}
+
+static ssize_t show_fan_enable(struct class *cls,
+ struct class_attribute *attr, char *buf)
+{
+ return sprintf(buf, "Fan enable: %d\n", g_mcu_data->fan_data.enable);
+}
+
+static ssize_t store_fan_enable(struct class *cls, struct class_attribute *attr,
+ const char *buf, size_t count)
+{
+ int enable;
+
+ if (kstrtoint(buf, 0, &enable))
+ return -EINVAL;
+
+ // 0: manual, 1: auto
+ if( enable >= 0 && enable < 2 ){
+ g_mcu_data->fan_data.enable = enable;
+ khadas_fan_set(&g_mcu_data->fan_data);
+ }
+
+ return count;
+}
+
+static ssize_t show_fan_mode(struct class *cls,
+ struct class_attribute *attr, char *buf)
+{
+ return sprintf(buf, "Fan mode: %d\n", g_mcu_data->fan_data.mode);
+}
+
+static ssize_t store_fan_mode(struct class *cls, struct class_attribute *attr,
+ const char *buf, size_t count)
+{
+ int mode;
+
+ if (kstrtoint(buf, 0, &mode))
+ return -EINVAL;
+
+ // 0: manual, 1: auto
+ if( mode >= 0 && mode < 2 ){
+ g_mcu_data->fan_data.mode = mode;
+ khadas_fan_set(&g_mcu_data->fan_data);
+ }
+
+ return count;
+}
+
+static ssize_t show_fan_level(struct class *cls,
+ struct class_attribute *attr, char *buf)
+{
+ return sprintf(buf, "Fan level: %d\n", g_mcu_data->fan_data.level);
+}
+
+static ssize_t store_fan_level(struct class *cls, struct class_attribute *attr,
+ const char *buf, size_t count)
+{
+ int level;
+
+ if (kstrtoint(buf, 0, &level))
+ return -EINVAL;
+
+ if( level >= 0 && level < 4){
+ g_mcu_data->fan_data.level = level;
+ khadas_fan_set(&g_mcu_data->fan_data);
+ }
+
+ return count;
+}
+
+static ssize_t show_fan_temp(struct class *cls,
+ struct class_attribute *attr, char *buf)
+{
+ int temp = -EINVAL;
+
+ if ((KHADAS_BOARD_VIM1 == g_mcu_data->board) ||
+ (KHADAS_BOARD_VIM2 == g_mcu_data->board))
+ temp = meson_gx_get_temperature();
+ else if (KHADAS_BOARD_VIM3 == g_mcu_data->board)
+ temp = meson_g12_get_temperature();
+
+ return sprintf(buf, "cpu_temp:%d\nFan trigger temperature: level0:%d level1:%d level2:%d\n", temp, g_mcu_data->fan_data.trig_temp_level0, g_mcu_data->fan_data.trig_temp_level1, g_mcu_data->fan_data.trig_temp_level2);
+}
+
+static ssize_t store_usb_pcie_switch_mode(struct class *cls, struct class_attribute *attr,
+ const char *buf, size_t count)
+{
+ int ret;
+ int mode;
+
+ if (kstrtoint(buf, 0, &mode))
+ return -EINVAL;
+
+ if (0 != mode && 1 != mode)
+ return -EINVAL;
+
+ if ((mode < MCU_USB_PCIE_SWITCH_MODE_USB3) || (mode > MCU_USB_PCIE_SWITCH_MODE_PCIE))
+ return -EINVAL;
+
+ g_mcu_data->usb_pcie_switch_mode = (u8)mode;
+ ret = mcu_i2c_write_regs(g_mcu_data->client, MCU_USB_PCIE_SWITCH_REG, &g_mcu_data->usb_pcie_switch_mode, 1);
+ if (ret < 0) {
+ printk("write USB PCIe switch error\n");
+
+ return ret;
+ }
+
+ printk("Set USB PCIe Switch Mode: %s\n", g_mcu_data->usb_pcie_switch_mode ? "PCIe" : "USB3.0");
+
+ return count;
+}
+
+static ssize_t show_usb_pcie_switch_mode(struct class *cls,
+ struct class_attribute *attr, char *buf)
+{
+ printk("USB PCIe Switch Mode: %s\n", g_mcu_data->usb_pcie_switch_mode ? "PCIe" : "USB3.0");
+ return sprintf(buf, "%d\n", g_mcu_data->usb_pcie_switch_mode);
+}
+
+static ssize_t store_mcu_poweroff(struct class *cls, struct class_attribute *attr,
+ const char *buf, size_t count)
+{
+ int ret;
+ int val;
+ u8 reg;
+
+ if (kstrtoint(buf, 0, &val))
+ return -EINVAL;
+
+ if (1 != val)
+ return -EINVAL;
+
+ reg = (u8)val;
+ ret = mcu_i2c_write_regs(g_mcu_data->client, MCU_PWR_OFF_CMD_REG, &reg, 1);
+ if (ret < 0) {
+ printk("write poweroff cmd error\n");
+
+ return ret;
+ }
+
+ return count;
+}
+
+static ssize_t store_mcu_rst(struct class *cls, struct class_attribute *attr,
+ const char *buf, size_t count)
+{
+ u8 reg[2];
+ int ret;
+ int rst;
+
+ if (kstrtoint(buf, 0, &rst))
+ return -EINVAL;
+
+ reg[0] = rst;
+ ret = mcu_i2c_write_regs(g_mcu_data->client, MCU_SHUTDOWN_NORMAL_REG, reg, 1);
+ if (ret < 0)
+ printk("rst mcu err\n");
+
+ return count;
+}
+
+static struct class_attribute fan_class_attrs[] = {
+ __ATTR(enable, 0644, show_fan_enable, store_fan_enable),
+ __ATTR(mode, 0644, show_fan_mode, store_fan_mode),
+ __ATTR(level, 0644, show_fan_level, store_fan_level),
+ __ATTR(temp, 0644, show_fan_temp, NULL),
+};
+
+static struct class_attribute mcu_class_attrs[] = {
+ __ATTR(poweroff, 0644, NULL, store_mcu_poweroff),
+ __ATTR(usb_pcie_switch_mode, 0644, show_usb_pcie_switch_mode, store_usb_pcie_switch_mode),
+ __ATTR(rst, 0644, NULL, store_mcu_rst),
+};
+
+static void create_mcu_attrs(void)
+{
+ int i;
+ printk("%s\n",__func__);
+
+ g_mcu_data->mcu_class = class_create(THIS_MODULE, "mcu");
+ if (IS_ERR(g_mcu_data->mcu_class)) {
+ pr_err("create mcu_class debug class fail\n");
+ return;
+ }
+
+ for (i = 0; i < ARRAY_SIZE(mcu_class_attrs); i++) {
+ if (strstr(mcu_class_attrs[i].attr.name, "usb_pcie_switch_mode")) {
+ if (!is_mcu_usb_pcie_switch_supported())
+ continue;
+ }
+ if (class_create_file(g_mcu_data->mcu_class, &mcu_class_attrs[i]))
+ pr_err("create mcu attribute %s fail\n", mcu_class_attrs[i].attr.name);
+ }
+
+ if (is_mcu_fan_control_supported()) {
+ g_mcu_data->fan_data.fan_class = class_create(THIS_MODULE, "fan");
+ if (IS_ERR(g_mcu_data->fan_data.fan_class)) {
+ pr_err("create fan_class debug class fail\n");
+ return;
+ }
+
+ for (i=0; i<ARRAY_SIZE(fan_class_attrs); i++) {
+ if (class_create_file(g_mcu_data->fan_data.fan_class, &fan_class_attrs[i]))
+ pr_err("create fan attribute %s fail\n", fan_class_attrs[i].attr.name);
+ }
+ }
+}
+
+static int mcu_parse_dt(struct device *dev)
+{
+ int ret;
+ const char *hwver = NULL;
+
+ if (NULL == dev) return -EINVAL;
+
+ // Get hardwere version
+ ret = of_property_read_string(dev->of_node, "hwver", &hwver);
+ if (ret < 0) {
+ g_mcu_data->hwver = KHADAS_BOARD_HWVER_V12;
+ g_mcu_data->board = KHADAS_BOARD_VIM2;
+ } else {
+ if (strstr(hwver, "VIM1"))
+ g_mcu_data->board = KHADAS_BOARD_VIM1;
+ else if (strstr(hwver, "VIM2"))
+ g_mcu_data->board = KHADAS_BOARD_VIM2;
+ else if (strstr(hwver, "VIM3"))
+ g_mcu_data->board = KHADAS_BOARD_VIM3;
+ else
+ g_mcu_data->board = KHADAS_BOARD_NONE;
+
+ if (KHADAS_BOARD_VIM1 == g_mcu_data->board) {
+ if (0 == strcmp(hwver, "VIM1.V13")) {
+ g_mcu_data->hwver = KHADAS_BOARD_HWVER_V13;
+ } else if (0 == strcmp(hwver, "VIM1.V14")) {
+ g_mcu_data->hwver = KHADAS_BOARD_HWVER_V14;
+ } else {
+ g_mcu_data->hwver = KHADAS_BOARD_HWVER_NONE;
+ }
+ } else if (KHADAS_BOARD_VIM2 == g_mcu_data->board) {
+ if (0 == strcmp(hwver, "VIM2.V12")) {
+ g_mcu_data->hwver = KHADAS_BOARD_HWVER_V12;
+ } else if (0 == strcmp(hwver, "VIM2.V13")) {
+ g_mcu_data->hwver = KHADAS_BOARD_HWVER_V13;
+ } else if (0 == strcmp(hwver, "VIM2.V14")) {
+ g_mcu_data->hwver = KHADAS_BOARD_HWVER_V14;
+ } else {
+ g_mcu_data->hwver = KHADAS_BOARD_HWVER_NONE;
+ }
+ } else if (KHADAS_BOARD_VIM3 == g_mcu_data->board) {
+ if (0 == strcmp(hwver, "VIM3.V11")) {
+ g_mcu_data->hwver = KHADAS_BOARD_HWVER_V11;
+ } else if (0 == strcmp(hwver, "VIM3.V12")) {
+ g_mcu_data->hwver = KHADAS_BOARD_HWVER_V12;
+ } else if (0 == strcmp(hwver, "VIM3.V13")) {
+ g_mcu_data->hwver = KHADAS_BOARD_HWVER_V13;
+ } else if (0 == strcmp(hwver, "VIM3.V14")) {
+ g_mcu_data->hwver = KHADAS_BOARD_HWVER_V14;
+ } else {
+ g_mcu_data->hwver = KHADAS_BOARD_HWVER_NONE;
+ }
+ }
+ }
+
+ ret = of_property_read_u32(dev->of_node, "fan,trig_temp_level0", &g_mcu_data->fan_data.trig_temp_level0);
+ if (ret < 0)
+ g_mcu_data->fan_data.trig_temp_level0 = MCU_FAN_TRIG_TEMP_LEVEL0;
+ ret = of_property_read_u32(dev->of_node, "fan,trig_temp_level1", &g_mcu_data->fan_data.trig_temp_level1);
+ if (ret < 0)
+ g_mcu_data->fan_data.trig_temp_level1 = MCU_FAN_TRIG_TEMP_LEVEL1;
+ ret = of_property_read_u32(dev->of_node, "fan,trig_temp_level2", &g_mcu_data->fan_data.trig_temp_level2);
+ if (ret < 0)
+ g_mcu_data->fan_data.trig_temp_level2 = MCU_FAN_TRIG_TEMP_LEVEL2;
+
+ return ret;
+}
+
+static int mcu_probe(struct i2c_client *client, const struct i2c_device_id *id)
+{
+ u8 reg[2];
+ int ret;
+
+ printk("%s\n", __func__);
+
+ if (!i2c_check_functionality(client->adapter, I2C_FUNC_I2C))
+ return -ENODEV;
+
+ g_mcu_data = kzalloc(sizeof(struct mcu_data), GFP_KERNEL);
+
+ if (g_mcu_data == NULL)
+ return -ENOMEM;
+
+ mcu_parse_dt(&client->dev);
+
+ printk("%s: board: %s (%d), hwver: %s (%d)\n", __func__,
+ mcu_board_type_to_str(g_mcu_data->board),
+ (int)g_mcu_data->board,
+ mcu_board_hardware_version_str(g_mcu_data->hwver),
+ (int)g_mcu_data->hwver);
+
+ g_mcu_data->client = client;
+
+ if (is_mcu_usb_pcie_switch_supported()) {
+ // Get USB PCIe Switch status
+ ret = mcu_i2c_read_regs(client, MCU_USB_PCIE_SWITCH_REG, reg, 1);
+ if (ret < 0)
+ goto exit;
+ g_mcu_data->usb_pcie_switch_mode = (u8)reg[0];
+ }
+
+ if (is_mcu_fan_control_supported()) {
+ g_mcu_data->fan_data.mode = MCU_FAN_MODE_AUTO;
+ g_mcu_data->fan_data.level = MCU_FAN_LEVEL_0;
+ g_mcu_data->fan_data.enable = MCU_FAN_STATUS_DISABLE;
+
+ INIT_DELAYED_WORK(&g_mcu_data->fan_data.work, fan_work_func);
+ mcu_fan_level_set(&g_mcu_data->fan_data, 0);
+ }
+ create_mcu_attrs();
+
+ return 0;
+exit:
+ return ret;
+}
+
+
+static int mcu_remove(struct i2c_client *client)
+{
+ return 0;
+}
+
+static void khadas_fan_shutdown(struct i2c_client *client)
+{
+ g_mcu_data->fan_data.enable = MCU_FAN_STATUS_DISABLE;
+ khadas_fan_set(&g_mcu_data->fan_data);
+}
+
+#ifdef CONFIG_PM_SLEEP
+static int khadas_fan_suspend(struct device *dev)
+{
+ cancel_delayed_work(&g_mcu_data->fan_data.work);
+ mcu_fan_level_set(&g_mcu_data->fan_data, 0);
+
+ return 0;
+}
+
+static int khadas_fan_resume(struct device *dev)
+{
+ return 0;
+}
+
+static const struct dev_pm_ops fan_dev_pm_ops = {
+ SET_SYSTEM_SLEEP_PM_OPS(khadas_fan_suspend, khadas_fan_resume)
+};
+
+#define FAN_PM_OPS (&(fan_dev_pm_ops))
+
+#endif
+
+static const struct i2c_device_id mcu_id[] = {
+ { "khadas-mcu", 0 },
+ { }
+};
+MODULE_DEVICE_TABLE(i2c, mcu_id);
+
+
+static struct of_device_id mcu_dt_ids[] = {
+ { .compatible = "khadas-mcu" },
+ {},
+};
+MODULE_DEVICE_TABLE(i2c, mcu_dt_ids);
+
+struct i2c_driver mcu_driver = {
+ .driver = {
+ .name = "khadas-mcu",
+ .owner = THIS_MODULE,
+ .of_match_table = of_match_ptr(mcu_dt_ids),
+#ifdef CONFIG_PM_SLEEP
+ .pm = FAN_PM_OPS,
+#endif
+ },
+ .probe = mcu_probe,
+ .remove = mcu_remove,
+ .shutdown = khadas_fan_shutdown,
+ .id_table = mcu_id,
+};
+module_i2c_driver(mcu_driver);
+
+MODULE_AUTHOR("Nick <nick@khadas.com>");
+MODULE_DESCRIPTION("Khadas MCU control driver");
+MODULE_LICENSE("GPL");
diff --git a/drivers/thermal/amlogic_thermal.c b/drivers/thermal/amlogic_thermal.c
index ccb1fe18e993..3947f3c1f91f 100644
--- a/drivers/thermal/amlogic_thermal.c
+++ b/drivers/thermal/amlogic_thermal.c
@@ -104,6 +104,8 @@ struct amlogic_thermal {
u32 trim_info;
};
+static struct amlogic_thermal *amlogic_thermal_data_ptr;
+
/*
* Calculate a temperature value from a temperature code.
* The unit of the temperature is degree milliCelsius.
@@ -194,6 +196,21 @@ static int amlogic_thermal_get_temp(void *data, int *temp)
return 0;
}
+int meson_g12_get_temperature(void)
+{
+ int temp;
+ int ret;
+
+ ret = amlogic_thermal_get_temp(amlogic_thermal_data_ptr, &temp);
+ if (ret) {
+ printk("amlogic_thermal_get_temp() failed!\n");
+ return ret;
+ }
+
+ return temp / 1000;
+}
+EXPORT_SYMBOL(meson_g12_get_temperature);
+
static const struct thermal_zone_of_device_ops amlogic_thermal_ops = {
.get_temp = amlogic_thermal_get_temp,
};
@@ -248,6 +265,8 @@ static int amlogic_thermal_probe(struct platform_device *pdev)
if (!pdata)
return -ENOMEM;
+ amlogic_thermal_data_ptr = pdata;
+
pdata->data = of_device_get_match_data(dev);
pdata->pdev = pdev;
platform_set_drvdata(pdev, pdata);
--
2.17.1

View file

@ -0,0 +1,26 @@
From b7aad5252373bb1270a9bcc362fa6f869108f1eb Mon Sep 17 00:00:00 2001
From: Nick Xie <nick@khadas.com>
Date: Sat, 17 Aug 2019 15:29:46 +0800
Subject: [PATCH 093/101] arm64: dts: VIM1: enable RTC
Signed-off-by: Nick Xie <nick@khadas.com>
---
arch/arm64/boot/dts/amlogic/meson-gxl-s905x-khadas-vim.dts | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/arch/arm64/boot/dts/amlogic/meson-gxl-s905x-khadas-vim.dts b/arch/arm64/boot/dts/amlogic/meson-gxl-s905x-khadas-vim.dts
index 2c198c4212b2..8637e6a42bb8 100644
--- a/arch/arm64/boot/dts/amlogic/meson-gxl-s905x-khadas-vim.dts
+++ b/arch/arm64/boot/dts/amlogic/meson-gxl-s905x-khadas-vim.dts
@@ -148,7 +148,7 @@
rtc: rtc@51 {
/* has to be enabled manually when a battery is connected: */
- status = "disabled";
+ status = "okay";
compatible = "haoyu,hym8563";
reg = <0x51>;
#clock-cells = <0>;
--
2.17.1

View file

@ -0,0 +1,481 @@
From 037976f20acf9b7d0240fae01870b78580929c24 Mon Sep 17 00:00:00 2001
From: Nick Xie <nick@khadas.com>
Date: Wed, 25 Dec 2019 11:32:49 +0800
Subject: [PATCH 099/101] VIM2: add GPIO FAN driver for V12 version
Signed-off-by: Nick Xie <nick@khadas.com>
---
.../dts/amlogic/meson-gxm-khadas-vim2.dts | 12 +
drivers/misc/Kconfig | 6 +
drivers/misc/Makefile | 1 +
drivers/misc/khadas-fan.c | 407 ++++++++++++++++++
4 files changed, 426 insertions(+)
create mode 100644 drivers/misc/khadas-fan.c
diff --git a/arch/arm64/boot/dts/amlogic/meson-gxm-khadas-vim2.dts b/arch/arm64/boot/dts/amlogic/meson-gxm-khadas-vim2.dts
index f9ec3f3efbe1..fc618b72d5b5 100644
--- a/arch/arm64/boot/dts/amlogic/meson-gxm-khadas-vim2.dts
+++ b/arch/arm64/boot/dts/amlogic/meson-gxm-khadas-vim2.dts
@@ -56,7 +56,19 @@
reset-gpios = <&gpio BOOT_9 GPIO_ACTIVE_LOW>;
};
+ fan {
+ compatible = "fanctl";
+ fan_ctl0 = <&gpio GPIODV_14 GPIO_ACTIVE_HIGH>;
+ fan_ctl1 = <&gpio GPIODV_15 GPIO_ACTIVE_HIGH>;
+ trig_temp_level0 = <50>;
+ trig_temp_level1 = <60>;
+ trig_temp_level2 = <70>;
+ hwver = "VIM2.V12"; /* Will be updated in uboot. */
+ status = "okay";
+ };
+
gpio_fan: gpio-fan {
+ status = "disabled";
compatible = "gpio-fan";
gpios = <&gpio GPIODV_14 GPIO_ACTIVE_HIGH
&gpio GPIODV_15 GPIO_ACTIVE_HIGH>;
diff --git a/drivers/misc/Kconfig b/drivers/misc/Kconfig
index fb0a3830fd87..264e39ccc330 100644
--- a/drivers/misc/Kconfig
+++ b/drivers/misc/Kconfig
@@ -465,6 +465,12 @@ config PVPANIC
a paravirtualized device provided by QEMU; it lets a virtual machine
(guest) communicate panic events to the host.
+config KHADAS_FAN
+ tristate "Khadas FAN"
+ default y
+ help
+ This driver is for Khadas FAN.
+
config KHADAS_MCU
tristate "Khadas boards on-board MCU"
help
diff --git a/drivers/misc/Makefile b/drivers/misc/Makefile
index 9bbf2a479405..c24a29e12f1f 100644
--- a/drivers/misc/Makefile
+++ b/drivers/misc/Makefile
@@ -57,4 +57,5 @@ obj-y += cardreader/
obj-$(CONFIG_PVPANIC) += pvpanic.o
obj-$(CONFIG_HABANA_AI) += habanalabs/
obj-$(CONFIG_XILINX_SDFEC) += xilinx_sdfec.o
+obj-$(CONFIG_KHADAS_FAN) += khadas-fan.o
obj-$(CONFIG_KHADAS_MCU) += khadas-mcu.o
diff --git a/drivers/misc/khadas-fan.c b/drivers/misc/khadas-fan.c
new file mode 100644
index 000000000000..ee0fd42a9dae
--- /dev/null
+++ b/drivers/misc/khadas-fan.c
@@ -0,0 +1,407 @@
+/*
+ * gpio-fan.c - driver for fans controlled by GPIO.
+ */
+#include <linux/module.h>
+#include <linux/init.h>
+#include <linux/platform_device.h>
+#include <linux/err.h>
+#include <linux/gpio.h>
+#include <linux/of_platform.h>
+#include <linux/of_gpio.h>
+#include <linux/time.h>
+#include <linux/workqueue.h>
+
+#define KHADAS_FAN_TRIG_TEMP_LEVEL0 50 // 50 degree if not set
+#define KHADAS_FAN_TRIG_TEMP_LEVEL1 60 // 60 degree if not set
+#define KHADAS_FAN_TRIG_TEMP_LEVEL2 70 // 70 degree if not set
+#define KHADAS_FAN_TRIG_MAXTEMP 80
+#define KHADAS_FAN_LOOP_SECS 30 * HZ // 30 seconds
+#define KHADAS_FAN_TEST_LOOP_SECS 5 * HZ // 5 seconds
+#define KHADAS_FAN_LOOP_NODELAY_SECS 0
+#define KHADAS_FAN_GPIO_OFF 0
+#define KHADAS_FAN_GPIO_ON 1
+
+enum khadas_fan_mode {
+ KHADAS_FAN_STATE_MANUAL = 0,
+ KHADAS_FAN_STATE_AUTO,
+};
+
+enum khadas_fan_level {
+ KHADAS_FAN_LEVEL_0 = 0,
+ KHADAS_FAN_LEVEL_1,
+ KHADAS_FAN_LEVEL_2,
+ KHADAS_FAN_LEVEL_3,
+};
+
+enum khadas_fan_enable {
+ KHADAS_FAN_DISABLE = 0,
+ KHADAS_FAN_ENABLE,
+};
+
+enum khadas_fan_hwver {
+ KHADAS_FAN_HWVER_NONE = 0,
+ KHADAS_FAN_HWVER_V12,
+ KHADAS_FAN_HWVER_V13,
+ KHADAS_FAN_HWVER_V14
+};
+
+struct khadas_fan_data {
+ int initialized;
+ struct platform_device *pdev;
+ struct class *class;
+ struct delayed_work work;
+ struct delayed_work fan_test_work;
+ enum khadas_fan_enable enable;
+ enum khadas_fan_mode mode;
+ enum khadas_fan_level level;
+ int ctrl_gpio0;
+ int ctrl_gpio1;
+ int trig_temp_level0;
+ int trig_temp_level1;
+ int trig_temp_level2;
+ enum khadas_fan_hwver hwver;
+};
+
+struct khadas_fan_data *fan_data = NULL;
+
+void khadas_fan_level_set(struct khadas_fan_data *fan_data, int level )
+{
+ if(0 == level){
+ gpio_set_value(fan_data->ctrl_gpio0, KHADAS_FAN_GPIO_OFF);
+ gpio_set_value(fan_data->ctrl_gpio1, KHADAS_FAN_GPIO_OFF);
+ }else if(1 == level){
+ gpio_set_value(fan_data->ctrl_gpio0, KHADAS_FAN_GPIO_ON);
+ gpio_set_value(fan_data->ctrl_gpio1, KHADAS_FAN_GPIO_OFF);
+ }else if(2 == level){
+ gpio_set_value(fan_data->ctrl_gpio0, KHADAS_FAN_GPIO_OFF);
+ gpio_set_value(fan_data->ctrl_gpio1, KHADAS_FAN_GPIO_ON);
+ }else if(3 == level){
+ gpio_set_value(fan_data->ctrl_gpio0, KHADAS_FAN_GPIO_ON);
+ gpio_set_value(fan_data->ctrl_gpio1, KHADAS_FAN_GPIO_ON);
+ }
+}
+
+extern int meson_gx_get_temperature(void);
+static void fan_work_func(struct work_struct *_work)
+{
+ int temp = -EINVAL;
+ struct khadas_fan_data *fan_data = container_of(_work,
+ struct khadas_fan_data, work.work);
+
+ temp = meson_gx_get_temperature();
+
+ if(temp != -EINVAL){
+ if(temp < fan_data->trig_temp_level0 ){
+ khadas_fan_level_set(fan_data,0);
+
+ }else if(temp < fan_data->trig_temp_level1 ){
+ khadas_fan_level_set(fan_data,1);
+
+ }else if(temp < fan_data->trig_temp_level2 ){
+ khadas_fan_level_set(fan_data,2);
+
+ }else{
+ khadas_fan_level_set(fan_data,3);
+ }
+ }
+
+ schedule_delayed_work(&fan_data->work, KHADAS_FAN_LOOP_SECS);
+}
+
+//static void fan_test_work_func(struct work_struct *_work)
+//{
+// struct khadas_fan_data *fan_data = container_of(_work,
+// struct khadas_fan_data, fan_test_work.work);
+//
+//
+// khadas_fan_level_set(fan_data,0);
+//
+//}
+
+
+static void khadas_fan_set(struct khadas_fan_data *fan_data)
+{
+
+ cancel_delayed_work(&fan_data->work);
+
+ if (fan_data->enable == KHADAS_FAN_DISABLE) {
+ khadas_fan_level_set(fan_data,0);
+ return;
+ }
+ switch (fan_data->mode) {
+ case KHADAS_FAN_STATE_MANUAL:
+ switch(fan_data->level){
+ case KHADAS_FAN_LEVEL_1:
+ khadas_fan_level_set(fan_data,1);
+ break;
+ case KHADAS_FAN_LEVEL_2:
+ khadas_fan_level_set(fan_data,2);
+ break;
+ case KHADAS_FAN_LEVEL_3:
+ khadas_fan_level_set(fan_data,3);
+ break;
+ default:
+ break;
+ }
+ break;
+
+ case KHADAS_FAN_STATE_AUTO:
+ // FIXME: achieve with a better way
+ schedule_delayed_work(&fan_data->work, KHADAS_FAN_LOOP_NODELAY_SECS);
+ break;
+
+ default:
+ break;
+ }
+}
+
+static ssize_t fan_enable_show(struct class *cls,
+ struct class_attribute *attr, char *buf)
+{
+ return sprintf(buf, "Fan enable: %d\n", fan_data->enable);
+}
+
+static ssize_t fan_enable_store(struct class *cls, struct class_attribute *attr,
+ const char *buf, size_t count)
+{
+ int enable;
+
+ if (kstrtoint(buf, 0, &enable))
+ return -EINVAL;
+
+ // 0: manual, 1: auto
+ if( enable >= 0 && enable < 2 ){
+ fan_data->enable = enable;
+ khadas_fan_set(fan_data);
+ }
+
+ return count;
+}
+
+static ssize_t fan_mode_show(struct class *cls,
+ struct class_attribute *attr, char *buf)
+{
+ return sprintf(buf, "Fan mode: %d\n", fan_data->mode);
+}
+
+static ssize_t fan_mode_store(struct class *cls, struct class_attribute *attr,
+ const char *buf, size_t count)
+{
+ int mode;
+
+ if (kstrtoint(buf, 0, &mode))
+ return -EINVAL;
+
+ // 0: manual, 1: auto
+ if( mode >= 0 && mode < 2 ){
+ fan_data->mode = mode;
+ khadas_fan_set(fan_data);
+ }
+
+ return count;
+}
+
+static ssize_t fan_level_show(struct class *cls,
+ struct class_attribute *attr, char *buf)
+{
+ return sprintf(buf, "Fan level: %d\n", fan_data->level);
+}
+
+static ssize_t fan_level_store(struct class *cls, struct class_attribute *attr,
+ const char *buf, size_t count)
+{
+ int level;
+
+ if (kstrtoint(buf, 0, &level))
+ return -EINVAL;
+
+ if( level >= 0 && level < 4){
+ fan_data->level = level;
+ khadas_fan_set(fan_data);
+ }
+
+ return count;
+}
+
+
+static ssize_t fan_temp_show(struct class *cls,
+ struct class_attribute *attr, char *buf)
+{
+ int temp = -EINVAL;
+ temp = meson_gx_get_temperature();
+
+ return sprintf(buf, "cpu_temp:%d\nFan trigger temperature: level0:%d level1:%d level2:%d\n", temp, fan_data->trig_temp_level0, fan_data->trig_temp_level1, fan_data->trig_temp_level2);
+}
+
+#if 0
+static ssize_t fan_temp_store(struct device *dev, struct device_attribute *attr,
+ const char *buf, size_t count)
+{
+ struct khadas_fan_data *fan_data = dev_get_drvdata(dev);
+ int temp;
+
+ if (kstrtoint(buf, 0, &temp))
+ return -EINVAL;
+
+ if (temp > KHADAS_FAN_TRIG_MAXTEMP)
+ temp = KHADAS_FAN_TRIG_MAXTEMP;
+ fan_data->trig_temp_level0 = temp;
+
+ return count;
+}
+#endif
+
+static struct class_attribute fan_class_attrs[] = {
+ __ATTR(enable, 0644, fan_enable_show, fan_enable_store),
+ __ATTR(mode, 0644, fan_mode_show, fan_mode_store),
+ __ATTR(level, 0644, fan_level_show, fan_level_store),
+ __ATTR(temp, 0644, fan_temp_show, NULL),
+};
+
+static int khadas_fan_probe(struct platform_device *pdev)
+{
+ struct device *dev = &pdev->dev;
+ int ret;
+ int i;
+ const char *hwver = NULL;
+
+ printk("khadas_fan_probe\n");
+
+ fan_data = devm_kzalloc(dev, sizeof(struct khadas_fan_data), GFP_KERNEL);
+ if (!fan_data)
+ return -ENOMEM;
+
+ // Get hardwere version
+ ret = of_property_read_string(dev->of_node, "hwver", &hwver);
+ if (ret < 0) {
+ fan_data->hwver = KHADAS_FAN_HWVER_V12;
+ } else {
+ if (0 == strcmp(hwver, "VIM2.V12")) {
+ fan_data->hwver = KHADAS_FAN_HWVER_V12;
+ } else if (0 == strcmp(hwver, "VIM2.V13")) {
+ fan_data->hwver = KHADAS_FAN_HWVER_V13;
+ } else if (0 == strcmp(hwver, "VIM2.V14")) {
+ fan_data->hwver = KHADAS_FAN_HWVER_V14;
+ }
+ else {
+ fan_data->hwver = KHADAS_FAN_HWVER_NONE;
+ }
+ }
+
+ if (KHADAS_FAN_HWVER_V12 != fan_data->hwver) {
+ // This driver is only for Khadas VIM2 V12 version.
+ printk("FAN: This driver is only for Khadas VIM2 V12 version.\n");
+ return 0;
+ }
+
+ ret = of_property_read_u32(dev->of_node, "trig_temp_level0", &fan_data->trig_temp_level0);
+ if (ret < 0)
+ fan_data->trig_temp_level0 = KHADAS_FAN_TRIG_TEMP_LEVEL0;
+ ret = of_property_read_u32(dev->of_node, "trig_temp_level1", &fan_data->trig_temp_level1);
+ if (ret < 0)
+ fan_data->trig_temp_level1 = KHADAS_FAN_TRIG_TEMP_LEVEL1;
+ ret = of_property_read_u32(dev->of_node, "trig_temp_level2", &fan_data->trig_temp_level2);
+ if (ret < 0)
+ fan_data->trig_temp_level2 = KHADAS_FAN_TRIG_TEMP_LEVEL2;
+
+ fan_data->ctrl_gpio0 = of_get_named_gpio(dev->of_node, "fan_ctl0", 0);
+ fan_data->ctrl_gpio1 = of_get_named_gpio(dev->of_node, "fan_ctl1", 0);
+ if ((gpio_request(fan_data->ctrl_gpio0, "FAN") != 0)|| (gpio_request(fan_data->ctrl_gpio1, "FAN") != 0))
+ return -EIO;
+
+ gpio_direction_output(fan_data->ctrl_gpio0, KHADAS_FAN_GPIO_OFF);
+ gpio_direction_output(fan_data->ctrl_gpio1, KHADAS_FAN_GPIO_OFF);
+ fan_data->mode = KHADAS_FAN_STATE_AUTO;
+ fan_data->level = KHADAS_FAN_LEVEL_0;
+ fan_data->enable = KHADAS_FAN_DISABLE;
+
+ INIT_DELAYED_WORK(&fan_data->work, fan_work_func);
+ khadas_fan_level_set(fan_data,0);
+// INIT_DELAYED_WORK(&fan_data->fan_test_work, fan_test_work_func);
+// schedule_delayed_work(&fan_data->fan_test_work, KHADAS_FAN_TEST_LOOP_SECS);
+
+ fan_data->pdev = pdev;
+ platform_set_drvdata(pdev, fan_data);
+
+ fan_data->class = class_create(THIS_MODULE, "fan");
+ if (IS_ERR(fan_data->class)) {
+ return PTR_ERR(fan_data->class);
+ }
+
+ for (i = 0; i < ARRAY_SIZE(fan_class_attrs); i++){
+ ret = class_create_file(fan_data->class, &fan_class_attrs[i]);
+ if(0!=ret){
+ printk("khadas_fan_probe,class_create_file%d failed \n", i);
+ }
+ }
+ dev_info(dev, "trigger temperature is level0:%d, level1:%d, level2:%d.\n", fan_data->trig_temp_level0, fan_data->trig_temp_level1, fan_data->trig_temp_level2);
+
+ fan_data->initialized = 1;
+
+ return 0;
+}
+
+static int khadas_fan_remove(struct platform_device *pdev)
+{
+ if (fan_data->initialized) {
+ fan_data->enable = KHADAS_FAN_DISABLE;
+ khadas_fan_set(fan_data);
+ }
+
+ return 0;
+}
+
+static void khadas_fan_shutdown(struct platform_device *pdev)
+{
+ if (fan_data->initialized) {
+ fan_data->enable = KHADAS_FAN_DISABLE;
+ khadas_fan_set(fan_data);
+ }
+}
+
+#ifdef CONFIG_PM
+static int khadas_fan_suspend(struct platform_device *pdev, pm_message_t state)
+{
+ if (fan_data->initialized) {
+ cancel_delayed_work(&fan_data->work);
+ khadas_fan_level_set(fan_data, 0);
+ }
+
+ return 0;
+}
+
+static int khadas_fan_resume(struct platform_device *pdev)
+{
+ if (fan_data->initialized) {
+ khadas_fan_set(fan_data);
+ }
+
+ return 0;
+}
+#endif
+
+static struct of_device_id of_khadas_fan_match[] = {
+ { .compatible = "fanctl", },
+ {},
+};
+
+static struct platform_driver khadas_fan_driver = {
+ .probe = khadas_fan_probe,
+#ifdef CONFIG_PM
+ .suspend = khadas_fan_suspend,
+ .resume = khadas_fan_resume,
+#endif
+ .remove = khadas_fan_remove,
+ .shutdown = khadas_fan_shutdown,
+ .driver = {
+ .name = "fanctl",
+ .owner = THIS_MODULE,
+ .of_match_table = of_match_ptr(of_khadas_fan_match),
+ },
+};
+
+module_platform_driver(khadas_fan_driver);
+
+MODULE_AUTHOR("kenny <kenny@khadas.com>");
+MODULE_DESCRIPTION("khadas GPIO Fan driver");
+MODULE_LICENSE("GPL");
--
2.17.1

View file

@ -0,0 +1,26 @@
From 096db0ffef76a1fdfe20ff528f120de1e708758a Mon Sep 17 00:00:00 2001
From: Nick Xie <nick@khadas.com>
Date: Sat, 17 Aug 2019 15:44:24 +0800
Subject: [PATCH 094/101] arm64: dts: VIM2: enable RTC
Signed-off-by: Nick Xie <nick@khadas.com>
---
arch/arm64/boot/dts/amlogic/meson-gxm-khadas-vim2.dts | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/arch/arm64/boot/dts/amlogic/meson-gxm-khadas-vim2.dts b/arch/arm64/boot/dts/amlogic/meson-gxm-khadas-vim2.dts
index dfa2abc55918..5ef329f10a06 100644
--- a/arch/arm64/boot/dts/amlogic/meson-gxm-khadas-vim2.dts
+++ b/arch/arm64/boot/dts/amlogic/meson-gxm-khadas-vim2.dts
@@ -356,7 +356,7 @@
rtc: rtc@51 {
/* has to be enabled manually when a battery is connected: */
- status = "disabled";
+ status = "okay";
compatible = "haoyu,hym8563";
reg = <0x51>;
#clock-cells = <0>;
--
2.17.1

View file

@ -0,0 +1,25 @@
From d0a3e14dd72781bc6ff475fce5e8ea57fcc7a871 Mon Sep 17 00:00:00 2001
From: Nick Xie <nick@khadas.com>
Date: Thu, 19 Dec 2019 21:36:14 +0800
Subject: [PATCH 096/101] arm64: dts: SDIO: VIM2: enable 'cap-sd-highspeed'
Signed-off-by: Nick Xie <nick@khadas.com>
---
arch/arm64/boot/dts/amlogic/meson-gxm-khadas-vim2.dts | 1 +
1 file changed, 1 insertion(+)
diff --git a/arch/arm64/boot/dts/amlogic/meson-gxm-khadas-vim2.dts b/arch/arm64/boot/dts/amlogic/meson-gxm-khadas-vim2.dts
index 8060e97d764f..57de06faa841 100644
--- a/arch/arm64/boot/dts/amlogic/meson-gxm-khadas-vim2.dts
+++ b/arch/arm64/boot/dts/amlogic/meson-gxm-khadas-vim2.dts
@@ -397,6 +397,7 @@
#size-cells = <0>;
bus-width = <4>;
+ cap-sd-highspeed;
max-frequency = <100000000>;
non-removable;
--
2.17.1

View file

@ -0,0 +1,29 @@
From 21c5b2840c068b8640e43ce61f9e26b67f48ecc9 Mon Sep 17 00:00:00 2001
From: Nick Xie <nick@khadas.com>
Date: Thu, 19 Dec 2019 21:40:58 +0800
Subject: [PATCH 097/101] arm64: dts: SDIO: VIM3: disable 'sd-uhs-sdr50' to fix
AP6398S
Signed-off-by: Nick Xie <nick@khadas.com>
---
arch/arm64/boot/dts/amlogic/meson-g12b-a311d-khadas-vim3.dts | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/arch/arm64/boot/dts/amlogic/meson-g12b-a311d-khadas-vim3.dts b/arch/arm64/boot/dts/amlogic/meson-g12b-a311d-khadas-vim3.dts
index 124a80901084..d855c79a8288 100644
--- a/arch/arm64/boot/dts/amlogic/meson-g12b-a311d-khadas-vim3.dts
+++ b/arch/arm64/boot/dts/amlogic/meson-g12b-a311d-khadas-vim3.dts
@@ -15,6 +15,10 @@
compatible = "khadas,vim3", "amlogic,a311d", "amlogic,g12b";
};
+&sd_emmc_a {
+ /delete-property/ sd-uhs-sdr50;
+};
+
/*
* The VIM3 on-board MCU can mux the PCIe/USB3.0 shared differential
* lines using a FUSB340TMX USB 3.1 SuperSpeed Data Switch between
--
2.17.1

View file

@ -0,0 +1,45 @@
From 6bcac8270ce9c08d0a53423d4511f3d3fcb99644 Mon Sep 17 00:00:00 2001
From: Christian Hewitt <christianshewitt@gmail.com>
Date: Fri, 21 Feb 2020 03:40:31 +0000
Subject: [PATCH 087/101] WIP: arm64: dts: meson: khadas-vim3: change LED
behaviours on VIM3/3L
VIM3/3L have two LEDs (red/white) located 1mm apart on the board. In the
current configuration both are powered on creating a pink visual status
indication. The boards are also marketed as HTPC devices where heartbeat
pulses are distracting and undesirable.
This change removes the heartbeat and sets the default state so that only
the white LED is on while the board is powered.
Signed-off-by: Christian Hewitt <christianshewitt@gmail.com>
---
arch/arm64/boot/dts/amlogic/meson-khadas-vim3.dtsi | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/arch/arm64/boot/dts/amlogic/meson-khadas-vim3.dtsi b/arch/arm64/boot/dts/amlogic/meson-khadas-vim3.dtsi
index 6022805d2032..6d0163f56b0d 100644
--- a/arch/arm64/boot/dts/amlogic/meson-khadas-vim3.dtsi
+++ b/arch/arm64/boot/dts/amlogic/meson-khadas-vim3.dtsi
@@ -40,14 +40,14 @@
compatible = "gpio-leds";
led-white {
- label = "vim3:white:sys";
- gpios = <&gpio_ao GPIOAO_4 GPIO_ACTIVE_LOW>;
- linux,default-trigger = "heartbeat";
+ label = "vim3:white:power";
+ gpios = <&gpio_ao GPIOAO_4 GPIO_ACTIVE_HIGH>;
+ linux,default-trigger = "default-on";
};
led-red {
label = "vim3:red";
- gpios = <&gpio_expander 5 GPIO_ACTIVE_LOW>;
+ gpios = <&gpio_expander 5 GPIO_ACTIVE_HIGH>;
};
};
--
2.17.1

View file

@ -0,0 +1,38 @@
From 04ba78002ded0f9089b7fae6550a56ccd0669e65 Mon Sep 17 00:00:00 2001
From: Christian Hewitt <christianshewitt@gmail.com>
Date: Fri, 21 Feb 2020 04:43:22 +0000
Subject: [PATCH 086/101] WIP: arm64: dts: meson: khadas-vim3: fix missing i2c3
node
Fixes: c6d29c66e582 ("arm64: dts: meson-g12b-khadas-vim3: add initial device-tree")
The i2c3 node was missed in the original device-tree and is required for the
optional Khadas 3705 fan to work.
Suggested-by: Art Nikpal <email2tema@gmail.com>
Signed-off-by: Christian Hewittt <christianshewitt@gmail.com>
---
arch/arm64/boot/dts/amlogic/meson-khadas-vim3.dtsi | 7 +++++++
1 file changed, 7 insertions(+)
diff --git a/arch/arm64/boot/dts/amlogic/meson-khadas-vim3.dtsi b/arch/arm64/boot/dts/amlogic/meson-khadas-vim3.dtsi
index 0ef60c7151cb..6022805d2032 100644
--- a/arch/arm64/boot/dts/amlogic/meson-khadas-vim3.dtsi
+++ b/arch/arm64/boot/dts/amlogic/meson-khadas-vim3.dtsi
@@ -217,6 +217,13 @@
};
};
+&i2c3 {
+ clock-frequency = <100000>;
+ pinctrl-0 = <&i2c3_sda_a_pins>, <&i2c3_sck_a_pins>;
+ pinctrl-names = "default";
+ status = "okay";
+};
+
&i2c_AO {
status = "okay";
pinctrl-0 = <&i2c_ao_sck_pins>, <&i2c_ao_sda_pins>;
--
2.17.1

View file

@ -0,0 +1,133 @@
From a1f62e3991b56958ab61e9a70f921881202d09d8 Mon Sep 17 00:00:00 2001
From: Christian Hewitt <christianshewitt@gmail.com>
Date: Thu, 20 Feb 2020 16:59:34 +0000
Subject: [PATCH 088/101] WIP: arm64: dts: meson: khadas-vim3l: add audio
playback to vim3l
Add the sound and related audio nodes to the VIM3L device-tree.
Signed-off-by: Christian Hewitt <christianshewitt@gmail.com>
---
.../dts/amlogic/meson-sm1-khadas-vim3l.dts | 88 +++++++++++++++++++
1 file changed, 88 insertions(+)
diff --git a/arch/arm64/boot/dts/amlogic/meson-sm1-khadas-vim3l.dts b/arch/arm64/boot/dts/amlogic/meson-sm1-khadas-vim3l.dts
index dbbf29a0dbf6..0ccb268589df 100644
--- a/arch/arm64/boot/dts/amlogic/meson-sm1-khadas-vim3l.dts
+++ b/arch/arm64/boot/dts/amlogic/meson-sm1-khadas-vim3l.dts
@@ -8,6 +8,7 @@
#include "meson-sm1.dtsi"
#include "meson-khadas-vim3.dtsi"
+#include <dt-bindings/sound/meson-g12a-tohdmitx.h>
/ {
compatible = "khadas,vim3l", "amlogic,sm1";
@@ -31,6 +32,69 @@
regulator-boot-on;
regulator-always-on;
};
+
+ sound {
+ compatible = "amlogic,axg-sound-card";
+ model = "SM1-KHADAS-VIM3L";
+ audio-aux-devs = <&tdmout_b>;
+ audio-routing = "TDMOUT_B IN 0", "FRDDR_A OUT 1",
+ "TDMOUT_B IN 1", "FRDDR_B OUT 1",
+ "TDMOUT_B IN 2", "FRDDR_C OUT 1",
+ "TDM_B Playback", "TDMOUT_B OUT";
+
+ assigned-clocks = <&clkc CLKID_MPLL2>,
+ <&clkc CLKID_MPLL0>,
+ <&clkc CLKID_MPLL1>;
+ assigned-clock-parents = <0>, <0>, <0>;
+ assigned-clock-rates = <294912000>,
+ <270950400>,
+ <393216000>;
+ status = "okay";
+
+ dai-link-0 {
+ sound-dai = <&frddr_a>;
+ };
+
+ dai-link-1 {
+ sound-dai = <&frddr_b>;
+ };
+
+ dai-link-2 {
+ sound-dai = <&frddr_c>;
+ };
+
+ /* 8ch hdmi interface */
+ dai-link-3 {
+ sound-dai = <&tdmif_b>;
+ dai-format = "i2s";
+ dai-tdm-slot-tx-mask-0 = <1 1>;
+ dai-tdm-slot-tx-mask-1 = <1 1>;
+ dai-tdm-slot-tx-mask-2 = <1 1>;
+ dai-tdm-slot-tx-mask-3 = <1 1>;
+ mclk-fs = <256>;
+
+ codec {
+ sound-dai = <&tohdmitx TOHDMITX_I2S_IN_B>;
+ };
+ };
+
+ /* hdmi glue */
+ dai-link-4 {
+ sound-dai = <&tohdmitx TOHDMITX_I2S_OUT>;
+
+ codec {
+ sound-dai = <&hdmi_tx>;
+ };
+ };
+ };
+};
+
+&arb {
+ status = "okay";
+};
+
+&clkc_audio {
+ status = "okay";
};
&cpu0 {
@@ -61,6 +125,18 @@
clock-latency = <50000>;
};
+&frddr_a {
+ status = "okay";
+};
+
+&frddr_b {
+ status = "okay";
+};
+
+&frddr_c {
+ status = "okay";
+};
+
&pwm_AO_cd {
pinctrl-0 = <&pwm_ao_d_e_pins>;
pinctrl-names = "default";
@@ -93,3 +169,15 @@
phy-names = "usb2-phy0", "usb2-phy1";
};
*/
+
+&tdmif_b {
+ status = "okay";
+};
+
+&tdmout_b {
+ status = "okay";
+};
+
+&tohdmitx {
+ status = "okay";
+};
--
2.17.1

View file

@ -0,0 +1,57 @@
diff --git a/arch/arm64/boot/dts/amlogic/meson-gxbb-nanopi-k2.dts b/arch/arm64/boot/dts/amlogic/meson-gxbb-nanopi-k2.dts
index 7d33cacd0..85004e51c 100644
--- a/arch/arm64/boot/dts/amlogic/meson-gxbb-nanopi-k2.dts
+++ b/arch/arm64/boot/dts/amlogic/meson-gxbb-nanopi-k2.dts
@@ -7,6 +7,7 @@
#include "meson-gxbb.dtsi"
#include <dt-bindings/gpio/gpio.h>
+#include <dt-bindings/sound/meson-aiu.h>
/ {
compatible = "friendlyarm,nanopi-k2", "amlogic,meson-gxbb";
@@ -131,6 +132,44 @@
};
};
};
+ sound {
+ compatible = "amlogic,gx-sound-card";
+ model = "GX-SOUND-CARD";
+ assigned-clocks = <&clkc CLKID_MPLL0>,
+ <&clkc CLKID_MPLL1>,
+ <&clkc CLKID_MPLL2>;
+ assigned-clock-parents = <0>, <0>, <0>;
+ assigned-clock-rates = <294912000>,
+ <270950400>,
+ <393216000>;
+ status = "okay";
+
+ dai-link-0 {
+ sound-dai = <&aiu AIU_CPU CPU_I2S_FIFO>;
+ };
+
+ dai-link-1 {
+ sound-dai = <&aiu AIU_CPU CPU_I2S_ENCODER>;
+ dai-format = "i2s";
+ mclk-fs = <256>;
+
+ codec-0 {
+ sound-dai = <&aiu AIU_HDMI CTRL_I2S>;
+ };
+ };
+
+ dai-link-2 {
+ sound-dai = <&aiu AIU_HDMI CTRL_OUT>;
+
+ codec-0 {
+ sound-dai = <&hdmi_tx>;
+ };
+ };
+ };
+};
+
+&aiu {
+ status = "okay";
};
&cec_AO {

View file

@ -0,0 +1,38 @@
diff --git a/arch/arm64/boot/dts/amlogic/meson-gxbb-nanopi-k2.dts b/arch/arm64/boot/dts/amlogic/meson-gxbb-nanopi-k2.dts
index fa4d9f927..b498186a5 100644
--- a/arch/arm64/boot/dts/amlogic/meson-gxbb-nanopi-k2.dts
+++ b/arch/arm64/boot/dts/amlogic/meson-gxbb-nanopi-k2.dts
@@ -162,6 +162,32 @@
};
};
};
+
+ spi-gpio {
+ compatible = "spi-gpio";
+ #address-cells = <0x1>;
+ #size-cells = <0x0>;
+ ranges;
+ status = "ok";
+ sck-gpios = <&gpio GPIOY_9 0>;
+ miso-gpios = <&gpio GPIOY_7 0>;
+ mosi-gpios = <&gpio GPIOY_5 0>;
+ cs-gpios = <&gpio GPIOY_8 0
+ &gpio GPIOY_10 0>;
+ num-chipselects = <2>;
+
+ /* clients */
+ spidev0@0 {
+ compatible = "spidev";
+ reg = <0>;
+ spi-max-frequency = <500000>;
+ };
+ spidev0@1 {
+ compatible = "spidev";
+ reg = <1>;
+ spi-max-frequency = <500000>;
+ };
+ };
};
&audio {

View file

@ -0,0 +1,12 @@
diff --git a/arch/arm64/boot/dts/amlogic/meson-gxbb-nanopi-k2.dts b/arch/arm64/boot/dts/amlogic/meson-gxbb-nanopi-k2.dts
index cbe99bd..80c87e0 100644
--- a/arch/arm64/boot/dts/amlogic/meson-gxbb-nanopi-k2.dts
+++ b/arch/arm64/boot/dts/amlogic/meson-gxbb-nanopi-k2.dts
@@ -13,6 +13,7 @@
aliases {
serial0 = &uart_AO;
+ serial2 = &uart_C;
ethernet0 = &ethmac;
};

View file

@ -0,0 +1,22 @@
diff --git a/arch/arm64/boot/dts/amlogic/meson-gxbb-nanopi-k2.dts b/arch/arm64/boot/dts/amlogic/meson-gxbb-nanopi-k2.dts
index 80c87e0bb..340559727 100644
--- a/arch/arm64/boot/dts/amlogic/meson-gxbb-nanopi-k2.dts
+++ b/arch/arm64/boot/dts/amlogic/meson-gxbb-nanopi-k2.dts
@@ -382,7 +382,7 @@
/* eMMC */
&sd_emmc_c {
- status = "disabled";
+ status = "okay";
pinctrl-0 = <&emmc_pins>, <&emmc_ds_pins>;
pinctrl-1 = <&emmc_clk_gate_pins>;
pinctrl-names = "default", "clk-gate";
@@ -392,8 +392,6 @@
non-removable;
disable-wp;
cap-mmc-highspeed;
- mmc-ddr-1_8v;
- mmc-hs200-1_8v;
mmc-pwrseq = <&emmc_pwrseq>;
vmmc-supply = <&vcc3v3>;

View file

@ -0,0 +1,14 @@
diff --git a/arch/arm64/boot/dts/amlogic/meson-gxbb-nanopi-k2.dts b/arch/arm64/boot/dts/amlogic/meson-gxbb-nanopi-k2.dts
index a12dc0498..2e7e97966 100644
--- a/arch/arm64/boot/dts/amlogic/meson-gxbb-nanopi-k2.dts
+++ b/arch/arm64/boot/dts/amlogic/meson-gxbb-nanopi-k2.dts
@@ -226,8 +226,7 @@
reset-assert-us = <10000>;
reset-deassert-us = <30000>;
- reset-gpios = <&gpio GPIOZ_14 GPIO_ACTIVE_LOW>;
-
+ max-speed = <1000>;
interrupt-parent = <&gpio_intc>;
/* MAC_INTR on GPIOZ_15 */
interrupts = <29 IRQ_TYPE_LEVEL_LOW>;

View file

@ -0,0 +1,58 @@
diff --git a/arch/arm64/boot/dts/amlogic/meson-gxbb-odroidc2.dts b/arch/arm64/boot/dts/amlogic/meson-gxbb-odroidc2.dts
index 0d0dd26ce..9e8384978 100644
--- a/arch/arm64/boot/dts/amlogic/meson-gxbb-odroidc2.dts
+++ b/arch/arm64/boot/dts/amlogic/meson-gxbb-odroidc2.dts
@@ -9,6 +9,7 @@
#include "meson-gxbb.dtsi"
#include <dt-bindings/gpio/gpio.h>
+#include <dt-bindings/sound/meson-aiu.h>
/ {
compatible = "hardkernel,odroid-c2", "amlogic,meson-gxbb";
@@ -200,6 +201,44 @@
};
};
};
+ sound {
+ compatible = "amlogic,gx-sound-card";
+ model = "GX-SOUND-CARD";
+ assigned-clocks = <&clkc CLKID_MPLL0>,
+ <&clkc CLKID_MPLL1>,
+ <&clkc CLKID_MPLL2>;
+ assigned-clock-parents = <0>, <0>, <0>;
+ assigned-clock-rates = <294912000>,
+ <270950400>,
+ <393216000>;
+ status = "okay";
+
+ dai-link-0 {
+ sound-dai = <&aiu AIU_CPU CPU_I2S_FIFO>;
+ };
+
+ dai-link-1 {
+ sound-dai = <&aiu AIU_CPU CPU_I2S_ENCODER>;
+ dai-format = "i2s";
+ mclk-fs = <256>;
+
+ codec-0 {
+ sound-dai = <&aiu AIU_HDMI CTRL_I2S>;
+ };
+ };
+
+ dai-link-2 {
+ sound-dai = <&aiu AIU_HDMI CTRL_OUT>;
+
+ codec-0 {
+ sound-dai = <&hdmi_tx>;
+ };
+ };
+ };
+};
+
+&aiu {
+ status = "okay";
};
&cec_AO {

View file

@ -0,0 +1,32 @@
diff --git a/arch/arm64/boot/dts/amlogic/meson-gxbb-odroidc2.dts b/arch/arm64/boot/dts/amlogic/meson-gxbb-odroidc2.dts
index 1cc9dc6..9f48dff 100644
--- a/arch/arm64/boot/dts/amlogic/meson-gxbb-odroidc2.dts
+++ b/arch/arm64/boot/dts/amlogic/meson-gxbb-odroidc2.dts
@@ -16,6 +16,8 @@
aliases {
serial0 = &uart_AO;
+ serial1 = &uart_A;
+ serial2 = &uart_C;
ethernet0 = &ethmac;
};
@@ -290,6 +355,18 @@
pinctrl-names = "default";
};
+&uart_A {
+ status = "disabled";
+ pinctrl-0 = <&uart_a_pins>;
+ pinctrl-names = "default";
+};
+
+&uart_C {
+ status = "disabled";
+ pinctrl-0 = <&uart_c_pins>;
+ pinctrl-names = "default";
+};
+
&usb0_phy {
status = "okay";
phy-supply = <&usb_otg_pwr>;

View file

@ -0,0 +1,37 @@
diff --git a/arch/arm64/boot/dts/amlogic/meson-gxbb-odroidc2.dts b/arch/arm64/boot/dts/amlogic/meson-gxbb-odroidc2.dts
index 0916dcb..cbc03df 100644
--- a/arch/arm64/boot/dts/amlogic/meson-gxbb-odroidc2.dts
+++ b/arch/arm64/boot/dts/amlogic/meson-gxbb-odroidc2.dts
@@ -116,6 +116,32 @@
};
};
};
+
+ spi-gpio {
+ compatible = "spi-gpio";
+ #address-cells = <0x1>;
+ #size-cells = <0x0>;
+ ranges;
+ status = "disabled";
+ sck-gpios = <&gpio GPIOX_2 0>;
+ miso-gpios = <&gpio GPIOX_4 0>;
+ mosi-gpios = <&gpio GPIOX_7 0>;
+ cs-gpios = <&gpio GPIOX_3 0
+ &gpio GPIOX_1 0>;
+ num-chipselects = <2>;
+
+ /* clients */
+ spidev0@0 {
+ compatible = "spidev";
+ reg = <0>;
+ spi-max-frequency = <500000>;
+ };
+ spidev0@1 {
+ compatible = "spidev";
+ reg = <1>;
+ spi-max-frequency = <500000>;
+ };
+ };
sound {
compatible = "simple-audio-card";

View file

@ -0,0 +1,14 @@
diff --git a/arch/arm64/boot/dts/amlogic/meson-gxbb-odroidc2.dts b/arch/arm64/boot/dts/amlogic/meson-gxbb-odroidc2.dts
index d147c853a..dbde670ba 100644
--- a/arch/arm64/boot/dts/amlogic/meson-gxbb-odroidc2.dts
+++ b/arch/arm64/boot/dts/amlogic/meson-gxbb-odroidc2.dts
@@ -246,7 +246,8 @@
};
&scpi_clocks {
- status = "disabled";
+ /* Works only with new blobs that have limited DVFS table */
+ status = "okay";
};
/* SD */

View file

@ -0,0 +1,11 @@
--- a/arch/arm64/boot/dts/amlogic/meson-g12b-odroid-n2.dts 2020/08/26 03:53:22 1.1
+++ b/arch/arm64/boot/dts/amlogic/meson-g12b-odroid-n2.dts 2020/08/26 03:54:20
@@ -403,7 +403,7 @@
reset-assert-us = <10000>;
reset-deassert-us = <30000>;
- reset-gpios = <&gpio GPIOZ_15 (GPIO_ACTIVE_LOW | GPIO_OPEN_DRAIN)>;
+ /* reset-gpios = <&gpio GPIOZ_15 (GPIO_ACTIVE_LOW | GPIO_OPEN_DRAIN)>; */
interrupt-parent = <&gpio_intc>;
/* MAC_INTR on GPIOZ_14 */

View file

@ -0,0 +1,64 @@
diff -Naur linux-5.3-rc8-old/arch/arm64/boot/dts/amlogic/meson-gxl-s905w-tx3-mini.dts linux-5.3-rc8-new/arch/arm64/boot/dts/amlogic/meson-gxl-s905w-tx3-mini.dts
--- linux-5.3-rc8-old/arch/arm64/boot/dts/amlogic/meson-gxl-s905w-tx3-mini.dts 2019-09-10 13:18:29.000000007 +0200
+++ linux-5.3-rc8-new/arch/arm64/boot/dts/amlogic/meson-gxl-s905w-tx3-mini.dts 2019-09-10 11:51:15.700000008 +0200
@@ -10,6 +10,7 @@
#include "meson-gxl-s905x.dtsi"
#include "meson-gx-p23x-q20x.dtsi"
+#include <dt-bindings/thermal/thermal.h>
/ {
compatible = "oranth,tx3-mini", "amlogic,s905w", "amlogic,meson-gxl";
@@ -19,8 +20,49 @@
device_type = "memory";
reg = <0x0 0x0 0x0 0x40000000>; /* 1 GiB or 2 GiB */
};
-};
-&ir {
- linux,rc-map-name = "rc-tanix-tx3mini";
+ thermal-zones {
+ cpu-thermal {
+ polling-delay-passive = <250>; /* milliseconds */
+ polling-delay = <1000>; /* milliseconds */
+
+ thermal-sensors = <&scpi_sensors 0>;
+
+ trips {
+ cpu_alert0: cpu-alert0 {
+ temperature = <70000>; /* millicelsius */
+ hysteresis = <2000>; /* millicelsius */
+ type = "active";
+ };
+
+ cpu_alert1: cpu-alert1 {
+ temperature = <80000>; /* millicelsius */
+ hysteresis = <2000>; /* millicelsius */
+ type = "passive";
+ };
+ };
+
+ cooling-maps {
+ map0 {
+ trip = <&cpu_alert0>;
+ cooling-device = <&gpio_fan THERMAL_NO_LIMIT 1>;
+ };
+
+ map1 {
+ trip = <&cpu_alert1>;
+ cooling-device = <&gpio_fan THERMAL_NO_LIMIT 1>;
+ };
+ };
+ };
+ };
+
+ gpio_fan: gpio-fan {
+ compatible = "gpio-fan";
+ /* Dummy RPM values since fan is optional */
+ gpio-fan,speed-map = <0 0
+ 1 1
+ 2 2
+ 3 3>;
+ #cooling-cells = <2>;
+ };
};

View file

@ -0,0 +1,53 @@
From a248c9db1deae60a1d77d094599a81a1639976d1 Mon Sep 17 00:00:00 2001
From: Boris Brezillon <boris.brezillon@collabora.com>
Date: Tue, 22 Oct 2019 16:15:50 +0200
Subject: [PATCH 065/101] FROMLIST: dt-bindings: display: bridge: lvds-codec:
Add new bus-width prop
Add the bus-width property to describe the input bus format.
v10:
* Add changelog to the commit message
* Add Rob's R-b
v8 -> v9:
* No changes
v7:
* Rebase on top of lvds-codec changes
* Drop the data-mapping property
v4 -> v6:
* Not part of the series
v3:
* New patch
Signed-off-by: Boris Brezillon <boris.brezillon@collabora.com>
Reviewed-by: Rob Herring <robh@kernel.org>
---
.../devicetree/bindings/display/bridge/lvds-codec.yaml | 8 ++++++++
1 file changed, 8 insertions(+)
diff --git a/Documentation/devicetree/bindings/display/bridge/lvds-codec.yaml b/Documentation/devicetree/bindings/display/bridge/lvds-codec.yaml
index 8f373029f5d2..7c4e42f4de61 100644
--- a/Documentation/devicetree/bindings/display/bridge/lvds-codec.yaml
+++ b/Documentation/devicetree/bindings/display/bridge/lvds-codec.yaml
@@ -55,6 +55,14 @@ properties:
description: |
For LVDS encoders, port 0 is the parallel input
For LVDS decoders, port 0 is the LVDS input
+ properties:
+ bus-width:
+ allOf:
+ - $ref: /schemas/types.yaml#/definitions/uint32
+ - enum: [18, 24]
+ - default: 24
+ description:
+ Number of data lines used to transmit the RGB data.
port@1:
type: object
--
2.17.1

View file

@ -0,0 +1,173 @@
From a97f73e2f405892e47e27b7382b18a055c9cfec5 Mon Sep 17 00:00:00 2001
From: Jerome Brunet <jbrunet@baylibre.com>
Date: Fri, 24 Jan 2020 15:40:25 +0100
Subject: [PATCH 037/101] WIP: ASoC: meson: convert axg fifo to schema
Signed-off-by: Jerome Brunet <jbrunet@baylibre.com>
---
.../bindings/sound/amlogic,axg-fifo.txt | 34 ------
.../bindings/sound/amlogic,axg-fifo.yaml | 111 ++++++++++++++++++
2 files changed, 111 insertions(+), 34 deletions(-)
delete mode 100644 Documentation/devicetree/bindings/sound/amlogic,axg-fifo.txt
create mode 100644 Documentation/devicetree/bindings/sound/amlogic,axg-fifo.yaml
diff --git a/Documentation/devicetree/bindings/sound/amlogic,axg-fifo.txt b/Documentation/devicetree/bindings/sound/amlogic,axg-fifo.txt
deleted file mode 100644
index fa4545ed81ca..000000000000
--- a/Documentation/devicetree/bindings/sound/amlogic,axg-fifo.txt
+++ /dev/null
@@ -1,34 +0,0 @@
-* Amlogic Audio FIFO controllers
-
-Required properties:
-- compatible: 'amlogic,axg-toddr' or
- 'amlogic,axg-toddr' or
- 'amlogic,g12a-frddr' or
- 'amlogic,g12a-toddr' or
- 'amlogic,sm1-frddr' or
- 'amlogic,sm1-toddr'
-- reg: physical base address of the controller and length of memory
- mapped region.
-- interrupts: interrupt specifier for the fifo.
-- clocks: phandle to the fifo peripheral clock provided by the audio
- clock controller.
-- resets: list of reset phandle, one for each entry reset-names.
-- reset-names: should contain the following:
- * "arb" : memory ARB line (required)
- * "rst" : dedicated device reset line (optional)
-- #sound-dai-cells: must be 0.
-- amlogic,fifo-depth: The size of the controller's fifo in bytes. This
- is useful for determining certain configuration such
- as the flush threshold of the fifo
-
-Example of FRDDR A on the A113 SoC:
-
-frddr_a: audio-controller@1c0 {
- compatible = "amlogic,axg-frddr";
- reg = <0x0 0x1c0 0x0 0x1c>;
- #sound-dai-cells = <0>;
- interrupts = <GIC_SPI 88 IRQ_TYPE_EDGE_RISING>;
- clocks = <&clkc_audio AUD_CLKID_FRDDR_A>;
- resets = <&arb AXG_ARB_FRDDR_A>;
- fifo-depth = <512>;
-};
diff --git a/Documentation/devicetree/bindings/sound/amlogic,axg-fifo.yaml b/Documentation/devicetree/bindings/sound/amlogic,axg-fifo.yaml
new file mode 100644
index 000000000000..d9fe4f624784
--- /dev/null
+++ b/Documentation/devicetree/bindings/sound/amlogic,axg-fifo.yaml
@@ -0,0 +1,111 @@
+# SPDX-License-Identifier: GPL-2.0
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/sound/amlogic,axg-fifo.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: Amlogic AXG Audio FIFO controllers
+
+maintainers:
+ - Jerome Brunet <jbrunet@baylibre.com>
+
+properties:
+ $nodename:
+ pattern: "^audio-controller@.*"
+
+ "#sound-dai-cells":
+ const: 0
+
+ compatible:
+ oneOf:
+ - items:
+ - const:
+ amlogic,axg-toddr
+ - items:
+ - const:
+ amlogic,axg-frddr
+ - items:
+ - enum:
+ - amlogic,g12a-toddr
+ - amlogic,sm1-toddr
+ - const:
+ amlogic,axg-toddr
+ - items:
+ - enum:
+ - amlogic,g12a-frddr
+ - amlogic,sm1-frddr
+ - const:
+ amlogic,axg-frddr
+
+ clocks:
+ items:
+ - description: Peripheral clock
+
+ interrupts:
+ maxItems: 1
+
+ reg:
+ maxItems: 1
+
+ resets:
+ minItems: 1
+ items:
+ - description: Memory ARB line
+ - description: Dedicated device reset line
+
+ reset-names:
+ minItems: 1
+ items:
+ - const: arb
+ - const: rst
+
+ amlogic,fifo-depth:
+ $ref: /schemas/types.yaml#/definitions/uint32
+ description: Size of the controller's fifo in bytes
+
+required:
+ - "#sound-dai-cells"
+ - compatible
+ - interrupts
+ - reg
+ - clocks
+ - resets
+ - amlogic,fifo-depth
+
+if:
+ properties:
+ compatible:
+ contains:
+ enum:
+ - amlogic,g12a-toddr
+ - amlogic,sm1-toddr
+ - amlogic,g12a-frddr
+ - amlogic,sm1-frddr
+then:
+ properties:
+ resets:
+ minItems: 2
+ reset-names:
+ minItems: 2
+ required:
+ - reset-names
+
+examples:
+ - |
+ #include <dt-bindings/clock/axg-audio-clkc.h>
+ #include <dt-bindings/interrupt-controller/irq.h>
+ #include <dt-bindings/interrupt-controller/arm-gic.h>
+ #include <dt-bindings/reset/amlogic,meson-axg-audio-arb.h>
+ #include <dt-bindings/reset/amlogic,meson-g12a-audio-reset.h>
+
+ frddr_a: audio-controller@1c0 {
+ compatible = "amlogic,g12a-frddr", "amlogic,axg-frddr";
+ reg = <0x0 0x1c0 0x0 0x1c>;
+ #sound-dai-cells = <0>;
+ interrupts = <GIC_SPI 88 IRQ_TYPE_EDGE_RISING>;
+ clocks = <&clkc_audio AUD_CLKID_FRDDR_A>;
+ resets = <&arb AXG_ARB_FRDDR_A>, <&clkc_audio AUD_RESET_FRDDR_A>;
+ reset-names = "arb", "rst";
+ amlogic,fifo-depth = <512>;
+ };
+
--
2.17.1

View file

@ -0,0 +1,136 @@
From 74524d2255deea105d57a441b266655a304b27f5 Mon Sep 17 00:00:00 2001
From: Jerome Brunet <jbrunet@baylibre.com>
Date: Fri, 24 Jan 2020 12:13:40 +0100
Subject: [PATCH 036/101] WIP: ASoC: meson: convert axg pdm to schema
Signed-off-by: Jerome Brunet <jbrunet@baylibre.com>
---
.../bindings/sound/amlogic,axg-pdm.txt | 29 -------
.../bindings/sound/amlogic,axg-pdm.yaml | 79 +++++++++++++++++++
2 files changed, 79 insertions(+), 29 deletions(-)
delete mode 100644 Documentation/devicetree/bindings/sound/amlogic,axg-pdm.txt
create mode 100644 Documentation/devicetree/bindings/sound/amlogic,axg-pdm.yaml
diff --git a/Documentation/devicetree/bindings/sound/amlogic,axg-pdm.txt b/Documentation/devicetree/bindings/sound/amlogic,axg-pdm.txt
deleted file mode 100644
index 716878107a24..000000000000
--- a/Documentation/devicetree/bindings/sound/amlogic,axg-pdm.txt
+++ /dev/null
@@ -1,29 +0,0 @@
-* Amlogic Audio PDM input
-
-Required properties:
-- compatible: 'amlogic,axg-pdm' or
- 'amlogic,g12a-pdm' or
- 'amlogic,sm1-pdm'
-- reg: physical base address of the controller and length of memory
- mapped region.
-- clocks: list of clock phandle, one for each entry clock-names.
-- clock-names: should contain the following:
- * "pclk" : peripheral clock.
- * "dclk" : pdm digital clock
- * "sysclk" : dsp system clock
-- #sound-dai-cells: must be 0.
-
-Optional property:
-- resets: phandle to the dedicated reset line of the pdm input.
-
-Example of PDM on the A113 SoC:
-
-pdm: audio-controller@ff632000 {
- compatible = "amlogic,axg-pdm";
- reg = <0x0 0xff632000 0x0 0x34>;
- #sound-dai-cells = <0>;
- clocks = <&clkc_audio AUD_CLKID_PDM>,
- <&clkc_audio AUD_CLKID_PDM_DCLK>,
- <&clkc_audio AUD_CLKID_PDM_SYSCLK>;
- clock-names = "pclk", "dclk", "sysclk";
-};
diff --git a/Documentation/devicetree/bindings/sound/amlogic,axg-pdm.yaml b/Documentation/devicetree/bindings/sound/amlogic,axg-pdm.yaml
new file mode 100644
index 000000000000..aa90b77e593d
--- /dev/null
+++ b/Documentation/devicetree/bindings/sound/amlogic,axg-pdm.yaml
@@ -0,0 +1,79 @@
+# SPDX-License-Identifier: GPL-2.0
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/sound/amlogic,axg-pdm.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: Amlogic Audio AXG PDM input
+
+maintainers:
+ - Jerome Brunet <jbrunet@baylibre.com>
+
+properties:
+ $nodename:
+ pattern: "^audio-controller@.*"
+
+ "#sound-dai-cells":
+ const: 0
+
+ compatible:
+ oneOf:
+ - items:
+ - enum:
+ - amlogic,g12a-pdm
+ - amlogic,sm1-pdm
+ - const:
+ amlogic,axg-pdm
+ - items:
+ - const:
+ amlogic,axg-pdm
+
+ clocks:
+ items:
+ - description: Peripheral clock
+ - description: PDM digital clock
+ - description: DSP system clock
+
+ clock-names:
+ items:
+ - const: pclk
+ - const: dclk
+ - const: sysclk
+
+ reg:
+ maxItems: 1
+
+ resets:
+ maxItems: 1
+
+required:
+ - "#sound-dai-cells"
+ - compatible
+ - reg
+ - clocks
+ - clock-names
+
+if:
+ properties:
+ compatible:
+ contains:
+ enum:
+ - amlogic,g12a-pdm
+ - amlogic,sm1-pdm
+then:
+ required:
+ - resets
+
+examples:
+ - |
+ #include <dt-bindings/clock/axg-audio-clkc.h>
+
+ pdm: audio-controller@ff632000 {
+ compatible = "amlogic,axg-pdm";
+ reg = <0x0 0xff632000 0x0 0x34>;
+ #sound-dai-cells = <0>;
+ clocks = <&clkc_audio AUD_CLKID_PDM>,
+ <&clkc_audio AUD_CLKID_PDM_DCLK>,
+ <&clkc_audio AUD_CLKID_PDM_SYSCLK>;
+ clock-names = "pclk", "dclk", "sysclk";
+ };
--
2.17.1

View file

@ -0,0 +1,334 @@
From 3b0d0fb9fb7faf1b00703693500a666be85209a0 Mon Sep 17 00:00:00 2001
From: Jerome Brunet <jbrunet@baylibre.com>
Date: Fri, 24 Jan 2020 18:23:36 +0100
Subject: [PATCH 041/101] WIP: ASoC: meson: convert axg sound card control to
schema
Signed-off-by: Jerome Brunet <jbrunet@baylibre.com>
---
.../bindings/sound/amlogic,axg-sound-card.txt | 124 ------------
.../sound/amlogic,axg-sound-card.yaml | 181 ++++++++++++++++++
2 files changed, 181 insertions(+), 124 deletions(-)
delete mode 100644 Documentation/devicetree/bindings/sound/amlogic,axg-sound-card.txt
create mode 100644 Documentation/devicetree/bindings/sound/amlogic,axg-sound-card.yaml
diff --git a/Documentation/devicetree/bindings/sound/amlogic,axg-sound-card.txt b/Documentation/devicetree/bindings/sound/amlogic,axg-sound-card.txt
deleted file mode 100644
index 80b411296480..000000000000
--- a/Documentation/devicetree/bindings/sound/amlogic,axg-sound-card.txt
+++ /dev/null
@@ -1,124 +0,0 @@
-Amlogic AXG sound card:
-
-Required properties:
-
-- compatible: "amlogic,axg-sound-card"
-- model : User specified audio sound card name, one string
-
-Optional properties:
-
-- audio-aux-devs : List of phandles pointing to auxiliary devices
-- audio-widgets : Please refer to widgets.txt.
-- audio-routing : A list of the connections between audio components.
-
-Subnodes:
-
-- dai-link: Container for dai-link level properties and the CODEC
- sub-nodes. There should be at least one (and probably more)
- subnode of this type.
-
-Required dai-link properties:
-
-- sound-dai: phandle and port of the CPU DAI.
-
-Required TDM Backend dai-link properties:
-- dai-format : CPU/CODEC common audio format
-
-Optional TDM Backend dai-link properties:
-- dai-tdm-slot-rx-mask-{0,1,2,3}: Receive direction slot masks
-- dai-tdm-slot-tx-mask-{0,1,2,3}: Transmit direction slot masks
- When omitted, mask is assumed to have to no
- slots. A valid must have at one slot, so at
- least one these mask should be provided with
- an enabled slot.
-- dai-tdm-slot-num : Please refer to tdm-slot.txt.
- If omitted, slot number is set to accommodate the largest
- mask provided.
-- dai-tdm-slot-width : Please refer to tdm-slot.txt. default to 32 if omitted.
-- mclk-fs : Multiplication factor between stream rate and mclk
-
-Backend dai-link subnodes:
-
-- codec: dai-link representing backend links should have at least one subnode.
- One subnode for each codec of the dai-link.
- dai-link representing frontend links have no codec, therefore have no
- subnodes
-
-Required codec subnodes properties:
-
-- sound-dai: phandle and port of the CODEC DAI.
-
-Optional codec subnodes properties:
-
-- dai-tdm-slot-tx-mask : Please refer to tdm-slot.txt.
-- dai-tdm-slot-rx-mask : Please refer to tdm-slot.txt.
-
-Example:
-
-sound {
- compatible = "amlogic,axg-sound-card";
- model = "AXG-S420";
- audio-aux-devs = <&tdmin_a>, <&tdmout_c>;
- audio-widgets = "Line", "Lineout",
- "Line", "Linein",
- "Speaker", "Speaker1 Left",
- "Speaker", "Speaker1 Right";
- "Speaker", "Speaker2 Left",
- "Speaker", "Speaker2 Right";
- audio-routing = "TDMOUT_C IN 0", "FRDDR_A OUT 2",
- "SPDIFOUT IN 0", "FRDDR_A OUT 3",
- "TDM_C Playback", "TDMOUT_C OUT",
- "TDMIN_A IN 2", "TDM_C Capture",
- "TDMIN_A IN 5", "TDM_C Loopback",
- "TODDR_A IN 0", "TDMIN_A OUT",
- "Lineout", "Lineout AOUTL",
- "Lineout", "Lineout AOUTR",
- "Speaker1 Left", "SPK1 OUT_A",
- "Speaker2 Left", "SPK2 OUT_A",
- "Speaker1 Right", "SPK1 OUT_B",
- "Speaker2 Right", "SPK2 OUT_B",
- "Linein AINL", "Linein",
- "Linein AINR", "Linein";
-
- dai-link@0 {
- sound-dai = <&frddr_a>;
- };
-
- dai-link@1 {
- sound-dai = <&toddr_a>;
- };
-
- dai-link@2 {
- sound-dai = <&tdmif_c>;
- dai-format = "i2s";
- dai-tdm-slot-tx-mask-2 = <1 1>;
- dai-tdm-slot-tx-mask-3 = <1 1>;
- dai-tdm-slot-rx-mask-1 = <1 1>;
- mclk-fs = <256>;
-
- codec@0 {
- sound-dai = <&lineout>;
- };
-
- codec@1 {
- sound-dai = <&speaker_amp1>;
- };
-
- codec@2 {
- sound-dai = <&speaker_amp2>;
- };
-
- codec@3 {
- sound-dai = <&linein>;
- };
-
- };
-
- dai-link@3 {
- sound-dai = <&spdifout>;
-
- codec {
- sound-dai = <&spdif_dit>;
- };
- };
-};
diff --git a/Documentation/devicetree/bindings/sound/amlogic,axg-sound-card.yaml b/Documentation/devicetree/bindings/sound/amlogic,axg-sound-card.yaml
new file mode 100644
index 000000000000..168d84b2dcb7
--- /dev/null
+++ b/Documentation/devicetree/bindings/sound/amlogic,axg-sound-card.yaml
@@ -0,0 +1,181 @@
+# SPDX-License-Identifier: GPL-2.0
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/sound/amlogic,axg-sound-card.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: Amlogic AXG sound card
+
+maintainers:
+ - Jerome Brunet <jbrunet@baylibre.com>
+
+properties:
+ compatible:
+ items:
+ - const: amlogic,axg-sound-card
+
+ audio-aux-devs:
+ $ref: /schemas/types.yaml#/definitions/phandle-array
+ description: list of auxiliary devices
+
+ audio-routing:
+ $ref: /schemas/types.yaml#/definitions/non-unique-string-array
+ minItems: 2
+ description: |-
+ A list of the connections between audio components. Each entry is a
+ pair of strings, the first being the connection's sink, the second
+ being the connection's source.
+
+ audio-widgets:
+ $ref: /schemas/types.yaml#/definitions/non-unique-string-array
+ minItems: 2
+ description: |-
+ A list off component DAPM widget. Each entry is a pair of strings,
+ the first being the widget type, the second being the widget name
+
+ model:
+ $ref: /schemas/types.yaml#/definitions/string
+ description: User specified audio sound card name
+
+patternProperties:
+ "^dai-link-[0-9]+$":
+ type: object
+ description: |-
+ dai-link child nodes:
+ Container for dai-link level properties and the CODEC sub-nodes.
+ There should be at least one (and probably more) subnode of this type
+
+ properties:
+ dai-format:
+ $ref: /schemas/types.yaml#/definitions/string
+ enum: [ i2s, left-j, dsp_a ]
+
+ dai-tdm-slot-num:
+ $ref: /schemas/types.yaml#/definitions/uint32
+ description: |
+ Number of slots in use. If omitted, slot number is set to
+ accommodate the largest mask provided.
+ maximum: 32
+
+ dai-tdm-slot-width:
+ $ref: /schemas/types.yaml#/definitions/uint32
+ description: Width in bits for each slot
+ enum: [ 8, 16, 20, 24, 32 ]
+ default: 32
+
+ mclk-fs:
+ $ref: /schemas/types.yaml#/definitions/uint32
+ description: |-
+ Multiplication factor between the frame rate and master clock
+ rate
+
+ sound-dai:
+ $ref: /schemas/types.yaml#/definitions/phandle
+ description: phandle of the CPU DAI
+
+ patternProperties:
+ "^dai-tdm-slot-(t|r)x-mask-[0-3]$":
+ $ref: /schemas/types.yaml#/definitions/uint32-array
+ description: |-
+ Transmit and receive cpu slot masks of each TDM lane
+ When omitted, mask is assumed to have to no slots. A valid must have
+ at one slot, so at least one these mask should be provided with
+ an enabled slot.
+
+ "^codec-[0-9]+$":
+ type: object
+ description: |-
+ Codecs:
+ dai-link representing backend links should have at least one subnode.
+ One subnode for each codec of the dai-link. dai-link representing
+ frontend links have no codec, therefore have no subnodes
+
+ properties:
+ sound-dai:
+ $ref: /schemas/types.yaml#/definitions/phandle
+ description: phandle of the codec DAI
+
+ patternProperties:
+ "^dai-tdm-slot-(t|r)x-mask$":
+ $ref: /schemas/types.yaml#/definitions/uint32-array
+ description: Transmit and receive codec slot masks
+
+ required:
+ - sound-dai
+
+ required:
+ - sound-dai
+
+required:
+ - model
+ - dai-link-0
+
+examples:
+ - |
+ sound {
+ compatible = "amlogic,axg-sound-card";
+ model = "AXG-S420";
+ audio-aux-devs = <&tdmin_a>, <&tdmout_c>;
+ audio-widgets = "Line", "Lineout",
+ "Line", "Linein",
+ "Speaker", "Speaker1 Left",
+ "Speaker", "Speaker1 Right",
+ "Speaker", "Speaker2 Left",
+ "Speaker", "Speaker2 Right";
+ audio-routing = "TDMOUT_C IN 0", "FRDDR_A OUT 2",
+ "SPDIFOUT IN 0", "FRDDR_A OUT 3",
+ "TDM_C Playback", "TDMOUT_C OUT",
+ "TDMIN_A IN 2", "TDM_C Capture",
+ "TDMIN_A IN 5", "TDM_C Loopback",
+ "TODDR_A IN 0", "TDMIN_A OUT",
+ "Lineout", "Lineout AOUTL",
+ "Lineout", "Lineout AOUTR",
+ "Speaker1 Left", "SPK1 OUT_A",
+ "Speaker2 Left", "SPK2 OUT_A",
+ "Speaker1 Right", "SPK1 OUT_B",
+ "Speaker2 Right", "SPK2 OUT_B",
+ "Linein AINL", "Linein",
+ "Linein AINR", "Linein";
+
+ dai-link-0 {
+ sound-dai = <&frddr_a>;
+ };
+
+ dai-link-1 {
+ sound-dai = <&toddr_a>;
+ };
+
+ dai-link-2 {
+ sound-dai = <&tdmif_c>;
+ dai-format = "i2s";
+ dai-tdm-slot-tx-mask-2 = <1 1>;
+ dai-tdm-slot-tx-mask-3 = <1 1>;
+ dai-tdm-slot-rx-mask-1 = <1 1>;
+ mclk-fs = <256>;
+
+ codec-0 {
+ sound-dai = <&lineout>;
+ };
+
+ codec-1 {
+ sound-dai = <&speaker_amp1>;
+ };
+
+ codec-2 {
+ sound-dai = <&speaker_amp2>;
+ };
+
+ codec-3 {
+ sound-dai = <&linein>;
+ };
+ };
+
+ dai-link@3 {
+ sound-dai = <&spdifout>;
+
+ codec {
+ sound-dai = <&spdif_dit>;
+ };
+ };
+ };
+
--
2.17.1

View file

@ -0,0 +1,139 @@
From d44d6ce650b53d6a05279113e77634405e87e589 Mon Sep 17 00:00:00 2001
From: Jerome Brunet <jbrunet@baylibre.com>
Date: Fri, 24 Jan 2020 15:52:03 +0100
Subject: [PATCH 038/101] WIP: ASoC: meson: convert axg spdif input to schema
Signed-off-by: Jerome Brunet <jbrunet@baylibre.com>
---
.../bindings/sound/amlogic,axg-spdifin.txt | 27 ------
.../bindings/sound/amlogic,axg-spdifin.yaml | 84 +++++++++++++++++++
2 files changed, 84 insertions(+), 27 deletions(-)
delete mode 100644 Documentation/devicetree/bindings/sound/amlogic,axg-spdifin.txt
create mode 100644 Documentation/devicetree/bindings/sound/amlogic,axg-spdifin.yaml
diff --git a/Documentation/devicetree/bindings/sound/amlogic,axg-spdifin.txt b/Documentation/devicetree/bindings/sound/amlogic,axg-spdifin.txt
deleted file mode 100644
index df92a4ecf288..000000000000
--- a/Documentation/devicetree/bindings/sound/amlogic,axg-spdifin.txt
+++ /dev/null
@@ -1,27 +0,0 @@
-* Amlogic Audio SPDIF Input
-
-Required properties:
-- compatible: 'amlogic,axg-spdifin' or
- 'amlogic,g12a-spdifin' or
- 'amlogic,sm1-spdifin'
-- interrupts: interrupt specifier for the spdif input.
-- clocks: list of clock phandle, one for each entry clock-names.
-- clock-names: should contain the following:
- * "pclk" : peripheral clock.
- * "refclk" : spdif input reference clock
-- #sound-dai-cells: must be 0.
-
-Optional property:
-- resets: phandle to the dedicated reset line of the spdif input.
-
-Example on the A113 SoC:
-
-spdifin: audio-controller@400 {
- compatible = "amlogic,axg-spdifin";
- reg = <0x0 0x400 0x0 0x30>;
- #sound-dai-cells = <0>;
- interrupts = <GIC_SPI 87 IRQ_TYPE_EDGE_RISING>;
- clocks = <&clkc_audio AUD_CLKID_SPDIFIN>,
- <&clkc_audio AUD_CLKID_SPDIFIN_CLK>;
- clock-names = "pclk", "refclk";
-};
diff --git a/Documentation/devicetree/bindings/sound/amlogic,axg-spdifin.yaml b/Documentation/devicetree/bindings/sound/amlogic,axg-spdifin.yaml
new file mode 100644
index 000000000000..b9b0863c5723
--- /dev/null
+++ b/Documentation/devicetree/bindings/sound/amlogic,axg-spdifin.yaml
@@ -0,0 +1,84 @@
+# SPDX-License-Identifier: GPL-2.0
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/sound/amlogic,axg-spdifin.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: Amlogic Audio AXG SPDIF Input
+
+maintainers:
+ - Jerome Brunet <jbrunet@baylibre.com>
+
+properties:
+ $nodename:
+ pattern: "^audio-controller@.*"
+
+ "#sound-dai-cells":
+ const: 0
+
+ compatible:
+ oneOf:
+ - items:
+ - const:
+ amlogic,axg-spdifin
+ - items:
+ - enum:
+ - amlogic,g12a-spdifin
+ - amlogic,sm1-spdifin
+ - const:
+ amlogic,axg-spdifin
+
+ clocks:
+ items:
+ - description: Peripheral clock
+ - description: SPDIF input reference clock
+
+ clock-names:
+ items:
+ - const: pclk
+ - const: refclk
+
+ interrupts:
+ maxItems: 1
+
+ reg:
+ maxItems: 1
+
+ resets:
+ maxItems: 1
+
+required:
+ - "#sound-dai-cells"
+ - compatible
+ - reg
+ - interrupts
+ - clocks
+ - clock-names
+
+if:
+ properties:
+ compatible:
+ contains:
+ enum:
+ - amlogic,g12a-spdifin
+ - amlogic,sm1-spdifin
+then:
+ required:
+ - resets
+
+examples:
+ - |
+ #include <dt-bindings/clock/axg-audio-clkc.h>
+ #include <dt-bindings/interrupt-controller/irq.h>
+ #include <dt-bindings/interrupt-controller/arm-gic.h>
+
+ spdifin: audio-controller@400 {
+ compatible = "amlogic,axg-spdifin";
+ reg = <0x0 0x400 0x0 0x30>;
+ #sound-dai-cells = <0>;
+ interrupts = <GIC_SPI 87 IRQ_TYPE_EDGE_RISING>;
+ clocks = <&clkc_audio AUD_CLKID_SPDIFIN>,
+ <&clkc_audio AUD_CLKID_SPDIFIN_CLK>;
+ clock-names = "pclk", "refclk";
+ };
+
--
2.17.1

View file

@ -0,0 +1,130 @@
From 4c8c6dedc0943fcc7a58ea7a41cdd46eda3a69f7 Mon Sep 17 00:00:00 2001
From: Jerome Brunet <jbrunet@baylibre.com>
Date: Fri, 24 Jan 2020 15:58:18 +0100
Subject: [PATCH 039/101] WIP: ASoC: meson: convert axg spdif output to schema
Signed-off-by: Jerome Brunet <jbrunet@baylibre.com>
---
.../bindings/sound/amlogic,axg-spdifout.txt | 25 ------
.../bindings/sound/amlogic,axg-spdifout.yaml | 77 +++++++++++++++++++
2 files changed, 77 insertions(+), 25 deletions(-)
delete mode 100644 Documentation/devicetree/bindings/sound/amlogic,axg-spdifout.txt
create mode 100644 Documentation/devicetree/bindings/sound/amlogic,axg-spdifout.yaml
diff --git a/Documentation/devicetree/bindings/sound/amlogic,axg-spdifout.txt b/Documentation/devicetree/bindings/sound/amlogic,axg-spdifout.txt
deleted file mode 100644
index 28381dd1f633..000000000000
--- a/Documentation/devicetree/bindings/sound/amlogic,axg-spdifout.txt
+++ /dev/null
@@ -1,25 +0,0 @@
-* Amlogic Audio SPDIF Output
-
-Required properties:
-- compatible: 'amlogic,axg-spdifout' or
- 'amlogic,g12a-spdifout' or
- 'amlogic,sm1-spdifout'
-- clocks: list of clock phandle, one for each entry clock-names.
-- clock-names: should contain the following:
- * "pclk" : peripheral clock.
- * "mclk" : master clock
-- #sound-dai-cells: must be 0.
-
-Optional property:
-- resets: phandle to the dedicated reset line of the spdif output.
-
-Example on the A113 SoC:
-
-spdifout: audio-controller@480 {
- compatible = "amlogic,axg-spdifout";
- reg = <0x0 0x480 0x0 0x50>;
- #sound-dai-cells = <0>;
- clocks = <&clkc_audio AUD_CLKID_SPDIFOUT>,
- <&clkc_audio AUD_CLKID_SPDIFOUT_CLK>;
- clock-names = "pclk", "mclk";
-};
diff --git a/Documentation/devicetree/bindings/sound/amlogic,axg-spdifout.yaml b/Documentation/devicetree/bindings/sound/amlogic,axg-spdifout.yaml
new file mode 100644
index 000000000000..9ac52916f88b
--- /dev/null
+++ b/Documentation/devicetree/bindings/sound/amlogic,axg-spdifout.yaml
@@ -0,0 +1,77 @@
+# SPDX-License-Identifier: GPL-2.0
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/sound/amlogic,axg-spdifout.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: Amlogic Audio AXG SPDIF Output
+
+maintainers:
+ - Jerome Brunet <jbrunet@baylibre.com>
+
+properties:
+ $nodename:
+ pattern: "^audio-controller@.*"
+
+ "#sound-dai-cells":
+ const: 0
+
+ compatible:
+ oneOf:
+ - items:
+ - const:
+ amlogic,axg-spdifout
+ - items:
+ - enum:
+ - amlogic,g12a-spdifout
+ - amlogic,sm1-spdifout
+ - const:
+ amlogic,axg-spdifout
+
+ clocks:
+ items:
+ - description: Peripheral clock
+ - description: SPDIF output master clock
+
+ clock-names:
+ items:
+ - const: pclk
+ - const: mclk
+
+ reg:
+ maxItems: 1
+
+ resets:
+ items:
+ - description: dedicated device reset line
+
+required:
+ - "#sound-dai-cells"
+ - compatible
+ - reg
+ - clocks
+ - clock-names
+
+if:
+ properties:
+ compatible:
+ contains:
+ enum:
+ - amlogic,g12a-spdifout
+ - amlogic,sm1-spdifout
+then:
+ required:
+ - resets
+
+examples:
+ - |
+ #include <dt-bindings/clock/axg-audio-clkc.h>
+
+ spdifout: audio-controller@480 {
+ compatible = "amlogic,axg-spdifout";
+ reg = <0x0 0x480 0x0 0x50>;
+ #sound-dai-cells = <0>;
+ clocks = <&clkc_audio AUD_CLKID_SPDIFOUT>,
+ <&clkc_audio AUD_CLKID_SPDIFOUT_CLK>;
+ clock-names = "pclk", "mclk";
+ };
--
2.17.1

View file

@ -0,0 +1,166 @@
From 222de230f3cb9c1452441001807c4ab876e0c959 Mon Sep 17 00:00:00 2001
From: Jerome Brunet <jbrunet@baylibre.com>
Date: Fri, 24 Jan 2020 12:00:01 +0100
Subject: [PATCH 035/101] WIP: ASoC: meson: convert axg tdm formatters to
schema
Signed-off-by: Jerome Brunet <jbrunet@baylibre.com>
---
.../sound/amlogic,axg-tdm-formatters.txt | 36 -------
.../sound/amlogic,axg-tdm-formatters.yaml | 101 ++++++++++++++++++
2 files changed, 101 insertions(+), 36 deletions(-)
delete mode 100644 Documentation/devicetree/bindings/sound/amlogic,axg-tdm-formatters.txt
create mode 100644 Documentation/devicetree/bindings/sound/amlogic,axg-tdm-formatters.yaml
diff --git a/Documentation/devicetree/bindings/sound/amlogic,axg-tdm-formatters.txt b/Documentation/devicetree/bindings/sound/amlogic,axg-tdm-formatters.txt
deleted file mode 100644
index 5996c0cd89c2..000000000000
--- a/Documentation/devicetree/bindings/sound/amlogic,axg-tdm-formatters.txt
+++ /dev/null
@@ -1,36 +0,0 @@
-* Amlogic Audio TDM formatters
-
-Required properties:
-- compatible: 'amlogic,axg-tdmin' or
- 'amlogic,axg-tdmout' or
- 'amlogic,g12a-tdmin' or
- 'amlogic,g12a-tdmout' or
- 'amlogic,sm1-tdmin' or
- 'amlogic,sm1-tdmout
-- reg: physical base address of the controller and length of memory
- mapped region.
-- clocks: list of clock phandle, one for each entry clock-names.
-- clock-names: should contain the following:
- * "pclk" : peripheral clock.
- * "sclk" : bit clock.
- * "sclk_sel" : bit clock input multiplexer.
- * "lrclk" : sample clock
- * "lrclk_sel": sample clock input multiplexer
-
-Optional property:
-- resets: phandle to the dedicated reset line of the tdm formatter.
-
-Example of TDMOUT_A on the S905X2 SoC:
-
-tdmout_a: audio-controller@500 {
- compatible = "amlogic,axg-tdmout";
- reg = <0x0 0x500 0x0 0x40>;
- resets = <&clkc_audio AUD_RESET_TDMOUT_A>;
- clocks = <&clkc_audio AUD_CLKID_TDMOUT_A>,
- <&clkc_audio AUD_CLKID_TDMOUT_A_SCLK>,
- <&clkc_audio AUD_CLKID_TDMOUT_A_SCLK_SEL>,
- <&clkc_audio AUD_CLKID_TDMOUT_A_LRCLK>,
- <&clkc_audio AUD_CLKID_TDMOUT_A_LRCLK>;
- clock-names = "pclk", "sclk", "sclk_sel",
- "lrclk", "lrclk_sel";
-};
diff --git a/Documentation/devicetree/bindings/sound/amlogic,axg-tdm-formatters.yaml b/Documentation/devicetree/bindings/sound/amlogic,axg-tdm-formatters.yaml
new file mode 100644
index 000000000000..77b994df0c84
--- /dev/null
+++ b/Documentation/devicetree/bindings/sound/amlogic,axg-tdm-formatters.yaml
@@ -0,0 +1,101 @@
+# SPDX-License-Identifier: GPL-2.0
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/sound/amlogic,axg-tdm-formatters.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: Amlogic Audio AXG TDM formatters
+
+maintainers:
+ - Jerome Brunet <jbrunet@baylibre.com>
+
+properties:
+ $nodename:
+ pattern: "^audio-controller@.*"
+
+ "#sound-dai-cells":
+ const: 0
+
+ compatible:
+ oneOf:
+ - items:
+ - enum:
+ - amlogic,g12a-tdmout
+ - amlogic,sm1-tdmout
+ - const:
+ amlogic,axg-tdmout
+ - items:
+ - const:
+ amlogic,axg-tdmout
+ - items:
+ - enum:
+ - amlogic,g12a-tdmin
+ - amlogic,sm1-tdmin
+ - const:
+ amlogic,axg-tdmin
+ - items:
+ - const:
+ amlogic,axg-tdmin
+
+ clocks:
+ items:
+ - description: Peripheral clock
+ - description: Bit clock
+ - description: Bit clock input multiplexer
+ - description: Sample clock
+ - description: Sample clock input multiplexer
+
+ clock-names:
+ items:
+ - const: pclk
+ - const: sclk
+ - const: sclk_sel
+ - const: lrclk
+ - const: lrclk_sel
+
+ reg:
+ maxItems: 1
+
+ resets:
+ maxItems: 1
+
+required:
+ - "#sound-dai-cells"
+ - compatible
+ - reg
+ - clocks
+ - clock-names
+
+if:
+ properties:
+ compatible:
+ contains:
+ enum:
+ - amlogic,g12a-tdmin
+ - amlogic,sm1-tdmin
+ - amlogic,g12a-tdmout
+ - amlogic,sm1-tdmout
+then:
+ required:
+ - resets
+
+examples:
+ - |
+ #include <dt-bindings/clock/axg-audio-clkc.h>
+ #include <dt-bindings/reset/amlogic,meson-g12a-audio-reset.h>
+
+ tdmout_a: audio-controller@500 {
+ compatible = "amlogic,g12a-tdmout",
+ "amlogic,axg-tdmout";
+ #sound-dai-cells = <0>;
+ reg = <0x0 0x500 0x0 0x40>;
+ resets = <&clkc_audio AUD_RESET_TDMOUT_A>;
+ clocks = <&clkc_audio AUD_CLKID_TDMOUT_A>,
+ <&clkc_audio AUD_CLKID_TDMOUT_A_SCLK>,
+ <&clkc_audio AUD_CLKID_TDMOUT_A_SCLK_SEL>,
+ <&clkc_audio AUD_CLKID_TDMOUT_A_LRCLK>,
+ <&clkc_audio AUD_CLKID_TDMOUT_A_LRCLK>;
+ clock-names = "pclk", "sclk", "sclk_sel",
+ "lrclk", "lrclk_sel";
+ };
+
--
2.17.1

View file

@ -0,0 +1,107 @@
From ea2bee83aa1bb6a88d6862756b9e1602324ca78b Mon Sep 17 00:00:00 2001
From: Jerome Brunet <jbrunet@baylibre.com>
Date: Fri, 24 Jan 2020 11:08:09 +0100
Subject: [PATCH 034/101] WIP: ASoC: meson: convert axg tdm interface to schema
Signed-off-by: Jerome Brunet <jbrunet@baylibre.com>
---
.../bindings/sound/amlogic,axg-tdm-iface.txt | 22 -------
.../bindings/sound/amlogic,axg-tdm-iface.yaml | 57 +++++++++++++++++++
2 files changed, 57 insertions(+), 22 deletions(-)
delete mode 100644 Documentation/devicetree/bindings/sound/amlogic,axg-tdm-iface.txt
create mode 100644 Documentation/devicetree/bindings/sound/amlogic,axg-tdm-iface.yaml
diff --git a/Documentation/devicetree/bindings/sound/amlogic,axg-tdm-iface.txt b/Documentation/devicetree/bindings/sound/amlogic,axg-tdm-iface.txt
deleted file mode 100644
index cabfb26a5f22..000000000000
--- a/Documentation/devicetree/bindings/sound/amlogic,axg-tdm-iface.txt
+++ /dev/null
@@ -1,22 +0,0 @@
-* Amlogic Audio TDM Interfaces
-
-Required properties:
-- compatible: 'amlogic,axg-tdm-iface'
-- clocks: list of clock phandle, one for each entry clock-names.
-- clock-names: should contain the following:
- * "sclk" : bit clock.
- * "lrclk": sample clock
- * "mclk" : master clock
- -> optional if the interface is in clock slave mode.
-- #sound-dai-cells: must be 0.
-
-Example of TDM_A on the A113 SoC:
-
-tdmif_a: audio-controller@0 {
- compatible = "amlogic,axg-tdm-iface";
- #sound-dai-cells = <0>;
- clocks = <&clkc_audio AUD_CLKID_MST_A_MCLK>,
- <&clkc_audio AUD_CLKID_MST_A_SCLK>,
- <&clkc_audio AUD_CLKID_MST_A_LRCLK>;
- clock-names = "mclk", "sclk", "lrclk";
-};
diff --git a/Documentation/devicetree/bindings/sound/amlogic,axg-tdm-iface.yaml b/Documentation/devicetree/bindings/sound/amlogic,axg-tdm-iface.yaml
new file mode 100644
index 000000000000..5f04f9cf30a0
--- /dev/null
+++ b/Documentation/devicetree/bindings/sound/amlogic,axg-tdm-iface.yaml
@@ -0,0 +1,57 @@
+# SPDX-License-Identifier: GPL-2.0
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/sound/amlogic,axg-tdm-iface.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: Amlogic Audio TDM Interfaces
+
+maintainers:
+ - Jerome Brunet <jbrunet@baylibre.com>
+
+properties:
+ $nodename:
+ pattern: "^audio-controller-.*"
+
+ "#sound-dai-cells":
+ const: 0
+
+ compatible:
+ items:
+ - const: 'amlogic,axg-tdm-iface'
+
+ clocks:
+ minItems: 2
+ maxItems: 3
+ items:
+ - description: Bit clock
+ - description: Sample clock
+ - description: Master clock #optional
+
+ clock-names:
+ minItems: 2
+ maxItems: 3
+ items:
+ - const: sclk
+ - const: lrclk
+ - const: mclk
+
+required:
+ - "#sound-dai-cells"
+ - compatible
+ - clocks
+ - clock-names
+
+examples:
+ - |
+ #include <dt-bindings/clock/axg-audio-clkc.h>
+
+ tdmif_a: audio-controller-0 {
+ compatible = "amlogic,axg-tdm-iface";
+ #sound-dai-cells = <0>;
+ clocks = <&clkc_audio AUD_CLKID_MST_A_SCLK>,
+ <&clkc_audio AUD_CLKID_MST_A_LRCLK>,
+ <&clkc_audio AUD_CLKID_MST_A_MCLK>;
+ clock-names = "sclk", "lrclk", "mclk";
+ };
+
--
2.17.1

View file

@ -0,0 +1,140 @@
From 2c10c55e9061c3ebfb059a54e531c512a9d19aa3 Mon Sep 17 00:00:00 2001
From: Jerome Brunet <jbrunet@baylibre.com>
Date: Fri, 24 Jan 2020 16:02:43 +0100
Subject: [PATCH 040/101] WIP: ASoC: meson: convert g12a tohdmitx control to
schema
Signed-off-by: Jerome Brunet <jbrunet@baylibre.com>
---
.../bindings/sound/amlogic,g12a-tohdmitx.txt | 58 -------------------
.../bindings/sound/amlogic,g12a-tohdmitx.yaml | 53 +++++++++++++++++
2 files changed, 53 insertions(+), 58 deletions(-)
delete mode 100644 Documentation/devicetree/bindings/sound/amlogic,g12a-tohdmitx.txt
create mode 100644 Documentation/devicetree/bindings/sound/amlogic,g12a-tohdmitx.yaml
diff --git a/Documentation/devicetree/bindings/sound/amlogic,g12a-tohdmitx.txt b/Documentation/devicetree/bindings/sound/amlogic,g12a-tohdmitx.txt
deleted file mode 100644
index 4e8cd7eb7cec..000000000000
--- a/Documentation/devicetree/bindings/sound/amlogic,g12a-tohdmitx.txt
+++ /dev/null
@@ -1,58 +0,0 @@
-* Amlogic HDMI Tx control glue
-
-Required properties:
-- compatible: "amlogic,g12a-tohdmitx" or
- "amlogic,sm1-tohdmitx"
-- reg: physical base address of the controller and length of memory
- mapped region.
-- #sound-dai-cells: should be 1.
-- resets: phandle to the dedicated reset line of the hdmitx glue.
-
-Example on the S905X2 SoC:
-
-tohdmitx: audio-controller@744 {
- compatible = "amlogic,g12a-tohdmitx";
- reg = <0x0 0x744 0x0 0x4>;
- #sound-dai-cells = <1>;
- resets = <&clkc_audio AUD_RESET_TOHDMITX>;
-};
-
-Example of an 'amlogic,axg-sound-card':
-
-sound {
- compatible = "amlogic,axg-sound-card";
-
-[...]
-
- dai-link-x {
- sound-dai = <&tdmif_a>;
- dai-format = "i2s";
- dai-tdm-slot-tx-mask-0 = <1 1>;
-
- codec-0 {
- sound-dai = <&tohdmitx TOHDMITX_I2S_IN_A>;
- };
-
- codec-1 {
- sound-dai = <&external_dac>;
- };
- };
-
- dai-link-y {
- sound-dai = <&tdmif_c>;
- dai-format = "i2s";
- dai-tdm-slot-tx-mask-0 = <1 1>;
-
- codec {
- sound-dai = <&tohdmitx TOHDMITX_I2S_IN_C>;
- };
- };
-
- dai-link-z {
- sound-dai = <&tohdmitx TOHDMITX_I2S_OUT>;
-
- codec {
- sound-dai = <&hdmi_tx>;
- };
- };
-};
diff --git a/Documentation/devicetree/bindings/sound/amlogic,g12a-tohdmitx.yaml b/Documentation/devicetree/bindings/sound/amlogic,g12a-tohdmitx.yaml
new file mode 100644
index 000000000000..fdd64d103f33
--- /dev/null
+++ b/Documentation/devicetree/bindings/sound/amlogic,g12a-tohdmitx.yaml
@@ -0,0 +1,53 @@
+# SPDX-License-Identifier: GPL-2.0
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/sound/amlogic,g12a-tohdmitx.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: Amlogic G12a HDMI Tx Control Glue
+
+maintainers:
+ - Jerome Brunet <jbrunet@baylibre.com>
+
+properties:
+ $nodename:
+ pattern: "^audio-controller@.*"
+
+ "#sound-dai-cells":
+ const: 1
+
+ compatible:
+ oneOf:
+ - items:
+ - const:
+ amlogic,g12a-tohdmitx
+ - items:
+ - enum:
+ - amlogic,sm1-tohdmitx
+ - const:
+ amlogic,g12a-tohdmitx
+
+ reg:
+ maxItems: 1
+
+ resets:
+ maxItems: 1
+
+required:
+ - "#sound-dai-cells"
+ - compatible
+ - reg
+ - resets
+
+examples:
+ - |
+ #include <dt-bindings/reset/amlogic,meson-g12a-audio-reset.h>
+
+ tohdmitx: audio-controller@744 {
+ compatible = "amlogic,g12a-tohdmitx";
+ reg = <0x0 0x744 0x0 0x4>;
+ #sound-dai-cells = <1>;
+ resets = <&clkc_audio AUD_RESET_TOHDMITX>;
+ };
+
+
--
2.17.1

View file

@ -0,0 +1,14 @@
diff --git a/drivers/media/rc/meson-ir.c b/drivers/media/rc/meson-ir.c
index f449b35d25e7..9747426719b2 100644
--- a/drivers/media/rc/meson-ir.c
+++ b/drivers/media/rc/meson-ir.c
@@ -97,7 +97,8 @@ static irqreturn_t meson_ir_irq(int irqno, void *dev_id)
status = readl_relaxed(ir->reg + IR_DEC_STATUS);
rawir.pulse = !!(status & STATUS_IR_DEC_IN);
- ir_raw_event_store_with_timeout(ir->rc, &rawir);
+ if (ir_raw_event_store_with_filter(ir->rc, &rawir))
+ ir_raw_event_handle(ir->rc);
spin_unlock(&ir->lock);

View file

@ -0,0 +1,82 @@
diff --git a/arch/arm/boot/.gitignore b/arch/arm/boot/.gitignore
index 3c79f859..4e5c1d59 100644
--- a/arch/arm/boot/.gitignore
+++ b/arch/arm/boot/.gitignore
@@ -3,3 +3,5 @@ zImage
xipImage
bootpImage
uImage
+*.dtb*
+*.scr
diff --git a/scripts/Makefile.dtbinst b/scripts/Makefile.dtbinst
index 50d580d77..94bd15617 100644
--- a/scripts/Makefile.dtbinst
+++ b/scripts/Makefile.dtbinst
@@ -18,9 +18,12 @@ include scripts/Kbuild.include
include $(src)/Makefile
dtbs := $(addprefix $(dst)/, $(dtb-y) $(if $(CONFIG_OF_ALL_DTBS),$(dtb-)))
+dtbos := $(addprefix $(dst)/, $(dtbo-y))
+scrs := $(addprefix $(dst)/, $(scr-y))
+readmes := $(addprefix $(dst)/, $(dtbotxt-y))
subdirs := $(addprefix $(obj)/, $(subdir-y) $(subdir-m))
-__dtbs_install: $(dtbs) $(subdirs)
+__dtbs_install: $(dtbs) $(dtbos) $(scrs) $(readmes) $(subdirs)
@:
quiet_cmd_dtb_install = INSTALL $@
@@ -29,6 +32,15 @@ quiet_cmd_dtb_install = INSTALL $@
$(dst)/%.dtb: $(obj)/%.dtb
$(call cmd,dtb_install)
+$(dst)/%.dtbo: $(obj)/%.dtbo
+ $(call cmd,dtb_install)
+
+$(dst)/%.scr: $(obj)/%.scr
+ $(call cmd,dtb_install)
+
+$(dst)/README.meson-overlays: $(src)/README.meson-overlays
+ $(call cmd,dtb_install)
+
PHONY += $(subdirs)
$(subdirs):
$(Q)$(MAKE) $(dtbinst)=$@ dst=$(patsubst $(obj)/%,$(dst)/%,$@)
diff --git a/scripts/Makefile.lib b/scripts/Makefile.lib
index 58c05e5d..2b95dda9 100644
--- a/scripts/Makefile.lib
+++ b/scripts/Makefile.lib
@@ -278,6 +278,9 @@ cmd_gzip = (cat $(filter-out FORCE,$^) | gzip -n -f -9 > $@) || \
# ---------------------------------------------------------------------------
DTC ?= $(objtree)/scripts/dtc/dtc
+# Overlay support
+DTC_FLAGS += -@ -Wno-unit_address_format -Wno-simple_bus_reg
+
# Disable noisy checks by default
ifeq ($(KBUILD_ENABLE_EXTRA_GCC_CHECKS),)
DTC_FLAGS += -Wno-unit_address_vs_reg \
@@ -324,6 +327,23 @@ cmd_dtc = mkdir -p $(dir ${dtc-tmp}) ; \
$(obj)/%.dtb: $(src)/%.dts FORCE
$(call if_changed_dep,dtc)
+quiet_cmd_dtco = DTCO $@
+cmd_dtco = mkdir -p $(dir ${dtc-tmp}) ; \
+ $(CPP) $(dtc_cpp_flags) -x assembler-with-cpp -o $(dtc-tmp) $< ; \
+ $(DTC) -O dtb -o $@ -b 0 \
+ -i $(dir $<) $(DTC_FLAGS) \
+ -d $(depfile).dtc.tmp $(dtc-tmp) ; \
+ cat $(depfile).pre.tmp $(depfile).dtc.tmp > $(depfile)
+
+$(obj)/%.dtbo: $(src)/%.dts FORCE
+ $(call if_changed_dep,dtco)
+
+quiet_cmd_scr = MKIMAGE $@
+cmd_scr = mkimage -C none -A $(ARCH) -T script -d $< $@
+
+$(obj)/%.scr: $(src)/%.scr-cmd FORCE
+ $(call if_changed,scr)
+
dtc-tmp = $(subst $(comma),_,$(dot-target).dts.tmp)
# Bzip2

View file

@ -0,0 +1,12 @@
diff --git a/drivers/usb/dwc2/params.c b/drivers/usb/dwc2/params.c
index bf7052e03..93561a2df 100644
--- a/drivers/usb/dwc2/params.c
+++ b/drivers/usb/dwc2/params.c
@@ -110,6 +110,7 @@ static void dwc2_set_amlogic_params(struct dwc2_hsotg *hsotg)
p->phy_type = DWC2_PHY_TYPE_PARAM_UTMI;
p->ahbcfg = GAHBCFG_HBSTLEN_INCR8 <<
GAHBCFG_HBSTLEN_SHIFT;
+ p->power_down = false;
}
static void dwc2_set_amcc_params(struct dwc2_hsotg *hsotg)

View file

@ -0,0 +1,16 @@
diff --git a/scripts/package/builddeb b/scripts/package/builddeb
index 3b80bd3f6..79bb8de6d 100755
--- a/scripts/package/builddeb
+++ b/scripts/package/builddeb
@@ -285,6 +285,11 @@ if [ "$ARCH" != "um" ]; then
create_package "$dtb_packagename" "$dtb_dir"
fi
+sed -e "s/exit 0//g" -i $tmpdir/DEBIAN/postinst
+cat >> $tmpdir/DEBIAN/postinst <<EOT
+mkimage -A arm64 -O linux -T kernel -C none -a 0x1080000 -e 0x1080000 -n "Linux" -d /$installed_image_path /boot/uImage > /dev/null 2>&1
+exit 0
+EOT
create_package "$packagename" "$tmpdir"
if [ -n "$BUILD_DEBUG" ] ; then

View file

@ -0,0 +1,22 @@
diff --git a/arch/arm64/boot/dts/amlogic/meson-gxbb.dtsi b/arch/arm64/boot/dts/amlogic/meson-gxbb.dtsi
index 98cbba6..48ca119 100644
--- a/arch/arm64/boot/dts/amlogic/meson-gxbb.dtsi
+++ b/arch/arm64/boot/dts/amlogic/meson-gxbb.dtsi
@@ -321,6 +322,8 @@
&i2c_A {
clocks = <&clkc CLKID_I2C>;
+ pinctrl-names = "default";
+ pinctrl-0 = <&i2c_a_pins>;
};
&i2c_AO {
@@ -329,6 +332,8 @@
&i2c_B {
clocks = <&clkc CLKID_I2C>;
+ pinctrl-names = "default";
+ pinctrl-0 = <&i2c_b_pins>;
};
&i2c_C {

View file

@ -0,0 +1,262 @@
From 58c5526eb1798e61e4e76d37140cf10c8d325bc7 Mon Sep 17 00:00:00 2001
From: Zhang Ning <832666+zhangn1985@users.noreply.github.com>
Date: Thu, 19 Sep 2019 16:20:31 +0800
Subject: [PATCH] general: meson64 overlays
Signed-off-by: Zhang Ning <832666+zhangn1985@users.noreply.github.com>
---
arch/arm64/boot/dts/amlogic/Makefile | 2 ++
arch/arm64/boot/dts/amlogic/overlay/Makefile | 20 ++++++++++++
.../dts/amlogic/overlay/README.meson-overlays | 20 ++++++++++++
.../dts/amlogic/overlay/meson-fixup.scr-cmd | 4 +++
.../boot/dts/amlogic/overlay/meson-i2cA.dts | 17 ++++++++++
.../boot/dts/amlogic/overlay/meson-i2cB.dts | 17 ++++++++++
.../boot/dts/amlogic/overlay/meson-uartA.dts | 11 +++++++
.../boot/dts/amlogic/overlay/meson-uartC.dts | 11 +++++++
.../dts/amlogic/overlay/meson-w1-gpio.dts | 20 ++++++++++++
.../dts/amlogic/overlay/meson-w1AB-gpio.dts | 32 +++++++++++++++++++
scripts/Makefile.lib | 3 ++
12 files changed, 165 insertions(+)
create mode 100644 arch/arm64/boot/dts/amlogic/overlay/Makefile
create mode 100644 arch/arm64/boot/dts/amlogic/overlay/README.meson-overlays
create mode 100644 arch/arm64/boot/dts/amlogic/overlay/meson-fixup.scr-cmd
create mode 100644 arch/arm64/boot/dts/amlogic/overlay/meson-i2cA.dts
create mode 100644 arch/arm64/boot/dts/amlogic/overlay/meson-i2cB.dts
create mode 100644 arch/arm64/boot/dts/amlogic/overlay/meson-uartA.dts
create mode 100644 arch/arm64/boot/dts/amlogic/overlay/meson-uartC.dts
create mode 100644 arch/arm64/boot/dts/amlogic/overlay/meson-w1-gpio.dts
create mode 100644 arch/arm64/boot/dts/amlogic/overlay/meson-w1AB-gpio.dts
diff --git a/arch/arm64/boot/dts/amlogic/Makefile b/arch/arm64/boot/dts/amlogic/Makefile
index 07b861f..9d12b15 100644
--- a/arch/arm64/boot/dts/amlogic/Makefile
+++ b/arch/arm64/boot/dts/amlogic/Makefile
@@ -32,3 +32,5 @@ dtb-$(CONFIG_ARCH_MESON) += meson-gxm-q200.dtb
dtb-$(CONFIG_ARCH_MESON) += meson-sm1-sei610.dtb
dtb-$(CONFIG_ARCH_MESON) += meson-sm1-khadas-vim3l.dtb
dtb-$(CONFIG_ARCH_MESON) += meson-a1-ad401.dtb
+
+subdir-y := $(dts-dirs) overlay
diff --git a/arch/arm64/boot/dts/amlogic/overlay/Makefile b/arch/arm64/boot/dts/amlogic/overlay/Makefile
new file mode 100644
index 000000000000..8630fd1a182d
--- /dev/null
+++ b/arch/arm64/boot/dts/amlogic/overlay/Makefile
@@ -0,0 +1,20 @@
+# SPDX-License-Identifier: GPL-2.0
+dtbo-$(CONFIG_ARCH_MESON) += \
+ meson-i2cA.dtbo \
+ meson-i2cB.dtbo \
+ meson-uartA.dtbo \
+ meson-uartC.dtbo \
+ meson-w1-gpio.dtbo \
+ meson-w1AB-gpio.dtbo
+
+scr-$(CONFIG_ARCH_MESON) += \
+ meson-fixup.scr
+
+dtbotxt-$(CONFIG_ARCH_MESON) += \
+ README.meson-overlays
+
+targets += $(dtbo-y) $(scr-y) $(dtbotxt-y)
+
+always := $(dtbo-y) $(scr-y) $(dtbotxt-y)
+clean-files := *.dtbo *.scr
+
diff --git a/arch/arm64/boot/dts/amlogic/overlay/README.meson-overlays b/arch/arm64/boot/dts/amlogic/overlay/README.meson-overlays
new file mode 100644
index 000000000000..1b169a7a1525
--- /dev/null
+++ b/arch/arm64/boot/dts/amlogic/overlay/README.meson-overlays
@@ -0,0 +1,20 @@
+This document describes overlays provided in the kernel packages
+For generic Armbian overlays documentation please see
+https://docs.armbian.com/User-Guide_Allwinner_overlays/
+
+### Platform:
+
+meson (Amlogic)
+
+### Provided overlays:
+
+- i2c8
+
+### Overlay details:
+
+### i2c8
+
+Activates TWI/I2C bus 8
+
+I2C8 pins (SCL, SDA): GPIO1-C4, GPIO1-C5
+
diff --git a/arch/arm64/boot/dts/amlogic/overlay/meson-fixup.scr-cmd b/arch/arm64/boot/dts/amlogic/overlay/meson-fixup.scr-cmd
new file mode 100644
index 000000000000..d4c39e20a3a2
--- /dev/null
+++ b/arch/arm64/boot/dts/amlogic/overlay/meson-fixup.scr-cmd
@@ -0,0 +1,4 @@
+# overlays fixup script
+# implements (or rather substitutes) overlay arguments functionality
+# using u-boot scripting, environment variables and "fdt" command
+
diff --git a/arch/arm64/boot/dts/amlogic/overlay/meson-i2cA.dts b/arch/arm64/boot/dts/amlogic/overlay/meson-i2cA.dts
new file mode 100644
index 000000000000..bfb72feb7e36
--- /dev/null
+++ b/arch/arm64/boot/dts/amlogic/overlay/meson-i2cA.dts
@@ -0,0 +1,17 @@
+/dts-v1/;
+
+/ {
+ compatible = "amlogic,meson-gxbb";
+ fragment@0 {
+ target-path = "/aliases";
+ __overlay__ {
+ i2cA = "/soc/bus@c1100000/i2c@8500";
+ };
+ };
+ fragment@1 {
+ target-path = "/soc/bus@c1100000/i2c@8500";
+ __overlay__ {
+ status = "okay";
+ };
+ };
+};
diff --git a/arch/arm64/boot/dts/amlogic/overlay/meson-i2cB.dts b/arch/arm64/boot/dts/amlogic/overlay/meson-i2cB.dts
new file mode 100644
index 000000000000..d75867bce99b
--- /dev/null
+++ b/arch/arm64/boot/dts/amlogic/overlay/meson-i2cB.dts
@@ -0,0 +1,17 @@
+/dts-v1/;
+
+/ {
+ compatible = "amlogic,meson-gxbb";
+ fragment@0 {
+ target-path = "/aliases";
+ __overlay__ {
+ i2cA = "/soc/bus@c1100000/i2c@87c0";
+ };
+ };
+ fragment@1 {
+ target-path = "/soc/bus@c1100000/i2c@87c0";
+ __overlay__ {
+ status = "okay";
+ };
+ };
+};
diff --git a/arch/arm64/boot/dts/amlogic/overlay/meson-uartA.dts b/arch/arm64/boot/dts/amlogic/overlay/meson-uartA.dts
new file mode 100644
index 000000000000..3aecd60aaf64
--- /dev/null
+++ b/arch/arm64/boot/dts/amlogic/overlay/meson-uartA.dts
@@ -0,0 +1,11 @@
+/dts-v1/;
+
+/ {
+ compatible = "amlogic,meson-gxbb";
+ fragment@0 {
+ target-path = "/soc/bus@c1100000/serial@84c0";
+ __overlay__ {
+ status = "okay";
+ };
+ };
+};
diff --git a/arch/arm64/boot/dts/amlogic/overlay/meson-uartC.dts b/arch/arm64/boot/dts/amlogic/overlay/meson-uartC.dts
new file mode 100644
index 000000000000..2b40ee4c02d3
--- /dev/null
+++ b/arch/arm64/boot/dts/amlogic/overlay/meson-uartC.dts
@@ -0,0 +1,11 @@
+/dts-v1/;
+
+/ {
+ compatible = "amlogic,meson-gxbb";
+ fragment@0 {
+ target-path = "/soc/bus@c1100000/serial@8700";
+ __overlay__ {
+ status = "okay";
+ };
+ };
+};
diff --git a/arch/arm64/boot/dts/amlogic/overlay/meson-w1-gpio.dts b/arch/arm64/boot/dts/amlogic/overlay/meson-w1-gpio.dts
new file mode 100644
index 000000000000..ac76a4f20ab7
--- /dev/null
+++ b/arch/arm64/boot/dts/amlogic/overlay/meson-w1-gpio.dts
@@ -0,0 +1,20 @@
+// Definitions for w1-gpio module (without external pullup)
+/dts-v1/;
+/plugin/;
+
+/ {
+ compatible = "amlogic,meson-gxbb";
+
+ fragment@0 {
+ target-path = "/";
+ __overlay__ {
+
+ w1: onewire@0 {
+ compatible = "w1-gpio";
+ pinctrl-names = "default";
+ gpios = <&gpio 91 6>; // GPIOY_16
+ status = "okay";
+ };
+ };
+ };
+};
diff --git a/arch/arm64/boot/dts/amlogic/overlay/meson-w1AB-gpio.dts b/arch/arm64/boot/dts/amlogic/overlay/meson-w1AB-gpio.dts
new file mode 100644
index 000000000000..f6b0d7eff158
--- /dev/null
+++ b/arch/arm64/boot/dts/amlogic/overlay/meson-w1AB-gpio.dts
@@ -0,0 +1,32 @@
+// Definitions for w1-gpio module (without external pullup)
+/dts-v1/;
+/plugin/;
+
+/ {
+ compatible = "amlogic,meson-gxbb";
+
+ fragment@0 {
+ target-path = "/";
+ __overlay__ {
+
+ w1a: onewire@0 {
+ compatible = "w1-gpio";
+ pinctrl-names = "default";
+ gpios = <&gpio 91 6>; // GPIOY_16
+ status = "okay";
+ };
+ };
+ };
+ fragment@1 {
+ target-path = "/";
+ __overlay__ {
+
+ w1b: onewire@1 {
+ compatible = "w1-gpio";
+ pinctrl-names = "default";
+ gpios = <&gpio 90 6>; // GPIOY_15
+ status = "okay";
+ };
+ };
+ };
+};
diff --git a/scripts/Makefile.lib b/scripts/Makefile.lib
index 41c50f9461e5..387659d5b252 100644
--- a/scripts/Makefile.lib
+++ b/scripts/Makefile.lib
@@ -79,6 +79,9 @@ header-test-y += $(filter-out $(header-test-), \
extra-$(CONFIG_HEADER_TEST) += $(addsuffix .s, $(header-test-y) $(header-test-m))
+# Overlay targets
+extra-y += $(dtbo-y) $(scr-y) $(dtbotxt-y)
+
# Add subdir path
extra-y := $(addprefix $(obj)/,$(extra-y))
--
2.20.1

View file

@ -0,0 +1,31 @@
From 2a7c14cbaec2d8307fb97a0036b155ee2857f7e2 Mon Sep 17 00:00:00 2001
From: ckkim <changkon12@gmail.com>
Date: Tue, 3 Mar 2020 14:20:59 +0900
Subject: [PATCH 03/74] ODROID-N2: arm64/dts: support Ulta High Speed MMC card
Signed-off-by: ckkim <changkon12@gmail.com>
Change-Id: I52bbf26aaf807e96bff7665bb65a1ee5594f6449
---
arch/arm64/boot/dts/amlogic/meson-g12b-odroid-n2.dts | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/arch/arm64/boot/dts/amlogic/meson-g12b-odroid-n2.dts b/arch/arm64/boot/dts/amlogic/meson-g12b-odroid-n2.dts
index 169ea283d4ee..84236c578075 100644
--- a/arch/arm64/boot/dts/amlogic/meson-g12b-odroid-n2.dts
+++ b/arch/arm64/boot/dts/amlogic/meson-g12b-odroid-n2.dts
@@ -423,7 +423,11 @@ &sd_emmc_b {
bus-width = <4>;
cap-sd-highspeed;
- max-frequency = <50000000>;
+ max-frequency = <200000000>;
+ sd-uhs-sdr12;
+ sd-uhs-sdr25;
+ sd-uhs-sdr50;
+ sd-uhs-sdr104;
disable-wp;
cd-gpios = <&gpio GPIOC_6 GPIO_ACTIVE_LOW>;
--
2.25.1

View file

@ -0,0 +1,69 @@
From abe827c2f577deecd87f04dcf06b0f26a607e79c Mon Sep 17 00:00:00 2001
From: Hyeonki Hong <hhk7734@gmail.com>
Date: Fri, 13 Mar 2020 14:07:34 +0900
Subject: [PATCH 05/74] ODROID-N2: arm64/dts: Add gpio-line-names
Change-Id: Ie5b40ea8885c324c81b4fa80a5bbe59b533b1b3a
---
.../boot/dts/amlogic/meson-g12b-odroid-n2.dts | 45 +++++++++++++++++++
1 file changed, 45 insertions(+)
diff --git a/arch/arm64/boot/dts/amlogic/meson-g12b-odroid-n2.dts b/arch/arm64/boot/dts/amlogic/meson-g12b-odroid-n2.dts
index e9d8d6bf4100..0bbd97997a42 100644
--- a/arch/arm64/boot/dts/amlogic/meson-g12b-odroid-n2.dts
+++ b/arch/arm64/boot/dts/amlogic/meson-g12b-odroid-n2.dts
@@ -412,6 +412,51 @@ &frddr_c {
};
&gpio {
+ gpio-line-names =
+ /* GPIOZ */
+ "", "", "", "", "", "", "", "",
+ "", "", "", "", "", "", "", "",
+ /* GPIOH */
+ "", "", "", "", "", "", "", "",
+ "",
+ /* BOOT */
+ "", "", "", "", "", "", "", "",
+ "", "", "", "", "", "", "", "",
+ /* GPIOC */
+ "", "", "", "", "", "", "", "",
+ /* GPIOA */
+ "PIN_44", /* GPIOA_0 */
+ "PIN_46", /* GPIOA_1 */
+ "PIN_45", /* GPIOA_2 */
+ "PIN_47", /* GPIOA_3 */
+ "PIN_26", /* GPIOA_4 */
+ "", "", "", "", "", "",
+ "PIN_42", /* GPIOA_11 */
+ "PIN_32", /* GPIOA_12 */
+ "PIN_7", /* GPIOA_13 */
+ "PIN_27", /* GPIOA_14 */
+ "PIN_28", /* GPIOA_15 */
+ /* GPIOX */
+ "PIN_16", /* GPIOX_0 */
+ "PIN_18", /* GPIOX_1 */
+ "PIN_22", /* GPIOX_2 */
+ "PIN_11", /* GPIOX_3 */
+ "PIN_13", /* GPIOX_4 */
+ "PIN_33", /* GPIOX_5 */
+ "PIN_35", /* GPIOX_6 */
+ "PIN_15", /* GPIOX_7 */
+ "PIN_19", /* GPIOX_8 */
+ "PIN_21", /* GPIOX_9 */
+ "PIN_24", /* GPIOX_10 */
+ "PIN_23", /* GPIOX_11 */
+ "PIN_8", /* GPIOX_12 */
+ "PIN_10", /* GPIOX_13 */
+ "PIN_29", /* GPIOX_14 */
+ "PIN_31", /* GPIOX_15 */
+ "PIN_12", /* GPIOX_16 */
+ "PIN_3", /* GPIOX_17 */
+ "PIN_5", /* GPIOX_18 */
+ "PIN_36"; /* GPIOX_19 */
/*
* WARNING: The USB Hub on the Odroid-N2 needs a reset signal
* to be turned high in order to be detected by the USB Controller
--
2.25.1

View file

@ -0,0 +1,41 @@
From bd699b3618b708c7a184e174336dce1c451f9a16 Mon Sep 17 00:00:00 2001
From: Hyeonki Hong <hhk7734@gmail.com>
Date: Fri, 27 Mar 2020 17:05:22 +0900
Subject: [PATCH 06/74] ODROID-N2: ARM64/dts: add uart_A node
Change-Id: I129c3d059231a7941285deffc293ee72784adcce
---
arch/arm64/boot/dts/amlogic/meson-g12b-odroid-n2.dts | 9 ++++++++-
1 file changed, 8 insertions(+), 1 deletion(-)
diff --git a/arch/arm64/boot/dts/amlogic/meson-g12b-odroid-n2.dts b/arch/arm64/boot/dts/amlogic/meson-g12b-odroid-n2.dts
index 0bbd97997a42..9e29fdbf149d 100644
--- a/arch/arm64/boot/dts/amlogic/meson-g12b-odroid-n2.dts
+++ b/arch/arm64/boot/dts/amlogic/meson-g12b-odroid-n2.dts
@@ -16,8 +16,9 @@ / {
model = "Hardkernel ODROID-N2";
aliases {
- serial0 = &uart_AO;
ethernet0 = &ethmac;
+ serial0 = &uart_AO;
+ serial1 = &uart_A;
};
chosen {
@@ -581,6 +582,12 @@ &tohdmitx {
status = "okay";
};
+&uart_A {
+ status = "okay";
+ pinctrl-names = "default";
+ pinctrl-0 = <&uart_a_pins>;
+};
+
&uart_AO {
status = "okay";
pinctrl-0 = <&uart_ao_a_pins>;
--
2.25.1

View file

@ -0,0 +1,91 @@
From a0bdfa3b38982cff581f8db8573064526a210434 Mon Sep 17 00:00:00 2001
From: Hyeonki Hong <hhk7734@gmail.com>
Date: Fri, 27 Mar 2020 16:54:02 +0900
Subject: [PATCH 07/74] ODROID-N2: ARM64/dts: add i2c2, i2c3 node
Change-Id: I00e3748a6f8474a99d05200afc60b8d794f75c96
---
.../boot/dts/amlogic/meson-g12b-odroid-n2.dts | 53 +++++++++++++++++++
1 file changed, 53 insertions(+)
diff --git a/arch/arm64/boot/dts/amlogic/meson-g12b-odroid-n2.dts b/arch/arm64/boot/dts/amlogic/meson-g12b-odroid-n2.dts
index 9e29fdbf149d..758528f988dd 100644
--- a/arch/arm64/boot/dts/amlogic/meson-g12b-odroid-n2.dts
+++ b/arch/arm64/boot/dts/amlogic/meson-g12b-odroid-n2.dts
@@ -17,6 +17,8 @@ / {
aliases {
ethernet0 = &ethmac;
+ i2c1 = &i2c2;
+ i2c2 = &i2c3;
serial0 = &uart_AO;
serial1 = &uart_A;
};
@@ -485,6 +487,35 @@ hdmi_tx_tmds_out: endpoint {
};
};
+&i2c2 {
+ status = "okay";
+
+ /*
+ * 40 Pin Header : SDA(GPIOX.17->3 Pin)
+ * SCL(GPIOX.18->5 Pin)
+ */
+ pinctrl-names = "default";
+ pinctrl-0 = <&i2c2_master_pins1>;
+
+ /* default 400k */
+ clock-frequency = <400000>;
+};
+
+&i2c3 {
+ /* default i2c clock-frequency is 100Khz */
+ status = "okay";
+
+ /*
+ * 40 Pin Header : SDA(GPIOA.14->27 Pin)
+ * SCL(GPIOA.15->28 Pin)
+ */
+ pinctrl-names = "default";
+ pinctrl-0 = <&i2c3_master_pins2>;
+
+ /* default 100k */
+ clock-frequency = <100000>;
+};
+
&ir {
status = "okay";
pinctrl-0 = <&remote_input_ao_pins>;
@@ -492,6 +523,28 @@ &ir {
linux,rc-map-name = "rc-odroid";
};
+&periphs_pinctrl {
+ i2c2_master_pins1:i2c2-master-pins1 {
+ mux {
+ groups = "i2c2_sda_x",
+ "i2c2_sck_x";
+ function = "i2c2";
+ bias-pull-up;
+ drive-strength-microamp = <3000>;
+ };
+ };
+
+ i2c3_master_pins2:i2c2-master-pins2 {
+ mux {
+ groups = "i2c3_sda_a",
+ "i2c3_sck_a";
+ function = "i2c3";
+ bias-pull-up;
+ drive-strength-microamp = <3000>;
+ };
+ };
+};
+
&pwm_ab {
pinctrl-0 = <&pwm_a_e_pins>;
pinctrl-names = "default";
--
2.25.1

View file

@ -0,0 +1,28 @@
From 3b201de7e491b9686a019a936a1d04eb59c6c3c7 Mon Sep 17 00:00:00 2001
From: Hyeonki Hong <hhk7734@gmail.com>
Date: Fri, 27 Mar 2020 17:36:37 +0900
Subject: [PATCH 08/74] ODROID-N2: ARM64/dts: add saradc node
Change-Id: Ieced434cbde791edee600832f51bd5021b4604aa
---
arch/arm64/boot/dts/amlogic/meson-g12b-odroid-n2.dts | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/arch/arm64/boot/dts/amlogic/meson-g12b-odroid-n2.dts b/arch/arm64/boot/dts/amlogic/meson-g12b-odroid-n2.dts
index 758528f988dd..63b23c84e022 100644
--- a/arch/arm64/boot/dts/amlogic/meson-g12b-odroid-n2.dts
+++ b/arch/arm64/boot/dts/amlogic/meson-g12b-odroid-n2.dts
@@ -561,6 +561,10 @@ &pwm_AO_cd {
status = "okay";
};
+&saradc {
+ status = "okay";
+};
+
/* SD card */
&sd_emmc_b {
status = "okay";
--
2.25.1

View file

@ -0,0 +1,37 @@
From fc7ffa81905a6efeb8a900dddc9ec468b5d382ca Mon Sep 17 00:00:00 2001
From: Hyeonki Hong <hhk7734@gmail.com>
Date: Tue, 21 Apr 2020 16:22:24 +0900
Subject: [PATCH 09/74] ODROID-N2: arm64/dts: modify i2c alias bus number
Change-Id: I49b58c681dea5377df0ee7ab98163165d5521cb8
---
arch/arm64/boot/dts/amlogic/meson-g12b-odroid-n2.dts | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/arch/arm64/boot/dts/amlogic/meson-g12b-odroid-n2.dts b/arch/arm64/boot/dts/amlogic/meson-g12b-odroid-n2.dts
index 63b23c84e022..90d9d38fe57a 100644
--- a/arch/arm64/boot/dts/amlogic/meson-g12b-odroid-n2.dts
+++ b/arch/arm64/boot/dts/amlogic/meson-g12b-odroid-n2.dts
@@ -17,8 +17,8 @@ / {
aliases {
ethernet0 = &ethmac;
- i2c1 = &i2c2;
- i2c2 = &i2c3;
+ i2c0 = &i2c2;
+ i2c1 = &i2c3;
serial0 = &uart_AO;
serial1 = &uart_A;
};
@@ -379,7 +379,7 @@ cpufreq_map1 {
&ext_mdio {
external_phy: ethernet-phy@0 {
- /* Realtek RTL8211F (0x001cc916) */
+ /* Realtek RTL8211F (0x001cc916) */
reg = <0>;
max-speed = <1000>;
--
2.25.1

View file

@ -0,0 +1,28 @@
From 3df99e8732d51402c0540d58d0a3be67e6576fb3 Mon Sep 17 00:00:00 2001
From: Hyeonki Hong <hhk7734@gmail.com>
Date: Tue, 21 Apr 2020 16:22:24 +0900
Subject: [PATCH 10/74] ODROID-N2: arm64/dts: modify i2c alias bus number
Change-Id: I49b58c681dea5377df0ee7ab98163165d5521cb8
---
arch/arm64/boot/dts/amlogic/meson-g12b-odroid-n2.dts | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/arch/arm64/boot/dts/amlogic/meson-g12b-odroid-n2.dts b/arch/arm64/boot/dts/amlogic/meson-g12b-odroid-n2.dts
index 90d9d38fe57a..c1b905260d34 100644
--- a/arch/arm64/boot/dts/amlogic/meson-g12b-odroid-n2.dts
+++ b/arch/arm64/boot/dts/amlogic/meson-g12b-odroid-n2.dts
@@ -17,8 +17,8 @@ / {
aliases {
ethernet0 = &ethmac;
- i2c0 = &i2c2;
- i2c1 = &i2c3;
+ i2c1 = &i2c2;
+ i2c2 = &i2c3;
serial0 = &uart_AO;
serial1 = &uart_A;
};
--
2.25.1

View file

@ -0,0 +1,41 @@
From ca89096189299862a7b2b3123d96fc8bfbe74ce3 Mon Sep 17 00:00:00 2001
From: Hyeonki Hong <hhk7734@gmail.com>
Date: Tue, 14 Apr 2020 14:15:25 +0900
Subject: [PATCH 13/74] ODROID-C4: arm64/dts: add uart_A node
Change-Id: Ib66a03da2fcf39fc459c20c9f98b1baca34dcf5b
---
arch/arm64/boot/dts/amlogic/meson-sm1-odroid-c4.dts | 9 ++++++++-
1 file changed, 8 insertions(+), 1 deletion(-)
diff --git a/arch/arm64/boot/dts/amlogic/meson-sm1-odroid-c4.dts b/arch/arm64/boot/dts/amlogic/meson-sm1-odroid-c4.dts
index 1b749bd340ce..e5d73598c131 100644
--- a/arch/arm64/boot/dts/amlogic/meson-sm1-odroid-c4.dts
+++ b/arch/arm64/boot/dts/amlogic/meson-sm1-odroid-c4.dts
@@ -14,8 +14,9 @@ / {
model = "Hardkernel ODROID-C4";
aliases {
- serial0 = &uart_AO;
ethernet0 = &ethmac;
+ serial0 = &uart_AO;
+ serial1 = &uart_A;
};
chosen {
@@ -385,6 +386,12 @@ &sd_emmc_c {
vqmmc-supply = <&flash_1v8>;
};
+&uart_A {
+ status = "okay";
+ pinctrl-names = "default";
+ pinctrl-0 = <&uart_a_pins>;
+};
+
&uart_AO {
status = "okay";
pinctrl-0 = <&uart_ao_a_pins>;
--
2.25.1

View file

@ -0,0 +1,638 @@
From 7466fab49314ed98f8b1512acf3e6ecb97c95315 Mon Sep 17 00:00:00 2001
From: Hyeonki Hong <hhk7734@gmail.com>
Date: Thu, 5 Mar 2020 19:01:43 +0900
Subject: [PATCH 15/74] ODROID-COMMON: input/touchscreen: Add D-WAV Multitouch
driver.
Change-Id: Ia1c8c29d3f69c6ba5d630279c4cc98119b68ab71
---
drivers/hid/hid-ids.h | 6 +
drivers/hid/hid-quirks.c | 4 +
drivers/input/touchscreen/Kconfig | 10 +
drivers/input/touchscreen/Makefile | 1 +
drivers/input/touchscreen/dwav-usb-mt.c | 554 ++++++++++++++++++++++++
5 files changed, 575 insertions(+)
create mode 100644 drivers/input/touchscreen/dwav-usb-mt.c
diff --git a/drivers/hid/hid-ids.h b/drivers/hid/hid-ids.h
index 6f370e020feb..5775322fb5d4 100644
--- a/drivers/hid/hid-ids.h
+++ b/drivers/hid/hid-ids.h
@@ -1294,4 +1294,10 @@
#define USB_VENDOR_ID_SIGNOTEC 0x2133
#define USB_DEVICE_ID_SIGNOTEC_VIEWSONIC_PD1011 0x0018
+#define USB_DEVICE_ID_DWAV_MULTITOUCH 0x0005
+
+#define USB_VENDOR_ID_ODROID 0x16b4
+#define USB_DEVICE_ID_VU5 0x0704
+#define USB_DEVICE_ID_VU7PLUS 0x0705
+
#endif
diff --git a/drivers/hid/hid-quirks.c b/drivers/hid/hid-quirks.c
index 934fc0a798d4..9cf96f48238e 100644
--- a/drivers/hid/hid-quirks.c
+++ b/drivers/hid/hid-quirks.c
@@ -845,6 +845,10 @@ static const struct hid_device_id hid_ignore_list[] = {
{ HID_USB_DEVICE(USB_VENDOR_ID_SYNAPTICS, USB_DEVICE_ID_SYNAPTICS_DPAD) },
#endif
{ HID_USB_DEVICE(USB_VENDOR_ID_YEALINK, USB_DEVICE_ID_YEALINK_P1K_P4K_B2K) },
+
+ { HID_USB_DEVICE(USB_VENDOR_ID_DWAV, USB_DEVICE_ID_DWAV_MULTITOUCH) },
+ { HID_USB_DEVICE(USB_VENDOR_ID_ODROID, USB_DEVICE_ID_VU5) },
+ { HID_USB_DEVICE(USB_VENDOR_ID_ODROID, USB_DEVICE_ID_VU7PLUS) },
{ }
};
diff --git a/drivers/input/touchscreen/Kconfig b/drivers/input/touchscreen/Kconfig
index 35c867b2d9a7..01d680a5736b 100644
--- a/drivers/input/touchscreen/Kconfig
+++ b/drivers/input/touchscreen/Kconfig
@@ -1322,4 +1322,14 @@ config TOUCHSCREEN_IQS5XX
To compile this driver as a module, choose M here: the
module will be called iqs5xx.
+config TOUCHSCREEN_DWAV_USB_MT
+ tristate "D-WAV Scientific USB MultiTouch"
+ depends on USB_ARCH_HAS_HCD
+ select USB
+ help
+ Say Y here if you have a D-WAV Scientific USB(HID) based MultiTouch
+ controller.
+
+ module will be called dwav-usb-mt.
+
endif
diff --git a/drivers/input/touchscreen/Makefile b/drivers/input/touchscreen/Makefile
index 30d1e1b42492..4585f02ad833 100644
--- a/drivers/input/touchscreen/Makefile
+++ b/drivers/input/touchscreen/Makefile
@@ -111,3 +111,4 @@ obj-$(CONFIG_TOUCHSCREEN_COLIBRI_VF50) += colibri-vf50-ts.o
obj-$(CONFIG_TOUCHSCREEN_ROHM_BU21023) += rohm_bu21023.o
obj-$(CONFIG_TOUCHSCREEN_RASPBERRYPI_FW) += raspberrypi-ts.o
obj-$(CONFIG_TOUCHSCREEN_IQS5XX) += iqs5xx.o
+obj-$(CONFIG_TOUCHSCREEN_DWAV_USB_MT) += dwav-usb-mt.o
diff --git a/drivers/input/touchscreen/dwav-usb-mt.c b/drivers/input/touchscreen/dwav-usb-mt.c
new file mode 100644
index 000000000000..7ec8b6dd15fd
--- /dev/null
+++ b/drivers/input/touchscreen/dwav-usb-mt.c
@@ -0,0 +1,554 @@
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ * D-WAV Scientific USB(HID) MultiTouch Screen Driver(Based on usbtouchscreen.c)
+ *
+ * Copyright (C) Hardkernel, 2015
+ */
+
+#include <linux/kernel.h>
+#include <linux/slab.h>
+#include <linux/input.h>
+#include <linux/module.h>
+#include <linux/init.h>
+#include <linux/usb.h>
+#include <linux/usb/input.h>
+#include <linux/hid.h>
+
+#include <linux/input/mt.h>
+
+#define USB_VENDOR_ID_DWAV 0x0eef /* 800 x 480, 7" DWAV touch */
+#define USB_DEVICE_ID_VU7 0x0005
+
+#define USB_VENDOR_ID_ODROID 0x16b4
+#define USB_DEVICE_ID_VU5 0x0704
+#define USB_DEVICE_ID_VU7PLUS 0x0705
+
+enum {
+ ODROID_VU7 = 0, /* 800 x 480, 7" Touch */
+ ODROID_VU5, /* 800 x 480, 5" Touch */
+ ODROID_VU7PLUS, /* 1024 x 600, 7" Touch */
+};
+
+struct usbtouch_device_info {
+ char name[64];
+ int max_x;
+ int max_y;
+ int max_press;
+ int max_finger;
+};
+
+const struct usbtouch_device_info DEV_INFO[] = {
+ [ODROID_VU7] = {
+ .name = "ODROID VU7 MultiTouch(800x480)",
+ .max_x = 800,
+ .max_y = 480,
+ .max_press = 255,
+ .max_finger = 5,
+ },
+ [ODROID_VU5] = {
+ .name = "ODROID VU5 MultiTouch(800x480)",
+ .max_x = 800,
+ .max_y = 480,
+ .max_press = 255,
+ .max_finger = 5,
+ },
+ [ODROID_VU7PLUS] = {
+ .name = "ODROID VU7 Plus MultiTouch(1024x600)",
+ .max_x = 1024,
+ .max_y = 600,
+ .max_press = 255,
+ .max_finger = 5,
+ },
+};
+
+static const struct usb_device_id dwav_usb_mt_devices[] = {
+ {USB_DEVICE(USB_VENDOR_ID_DWAV, USB_DEVICE_ID_VU7),
+ .driver_info = ODROID_VU7},
+ {USB_DEVICE(USB_VENDOR_ID_ODROID, USB_DEVICE_ID_VU5),
+ .driver_info = ODROID_VU5},
+ {USB_DEVICE(USB_VENDOR_ID_ODROID, USB_DEVICE_ID_VU7PLUS),
+ .driver_info = ODROID_VU7PLUS},
+ {}
+};
+
+struct dwav_raw { /* Total 25 bytes */
+ unsigned char header; /* frame header 0xAA*/
+ unsigned char press;
+ /* Touch flag (1:valid touch data, 0:touch finished) */
+ unsigned short x1; /* 1st x */
+ unsigned short y1; /* 1st y */
+ unsigned char end;
+ /* 1st touch finish flags 0xBB, RPI only uses the first 7 bytes */
+ unsigned char ids; /* touch ID(bit field) */
+ unsigned short y2;
+ unsigned short x2;
+ unsigned short y3;
+ unsigned short x3;
+ unsigned short y4;
+ unsigned short x4;
+ unsigned short y5;
+ unsigned short x5;
+ unsigned char tail; /* frame end 0xCC */
+};
+
+#define TS_EVENT_UNKNOWN 0x00
+#define TS_EVENT_PRESS 0x01
+#define TS_EVENT_RELEASE 0x02
+
+struct finger_t {
+ unsigned int status; /* ts event type */
+ unsigned int x; /* ts data x */
+ unsigned int y; /* ts data y */
+} __packed;
+
+struct dwav_usb_mt {
+ char name[128], phys[64];
+
+ int dev_id;
+ /* for URB Data DMA */
+ dma_addr_t data_dma;
+ unsigned char *data;
+ int data_size;
+
+ struct urb *irq;
+ struct usb_interface *interface;
+ struct input_dev *input;
+
+ struct finger_t *finger;
+};
+
+static void dwav_usb_mt_report(struct dwav_usb_mt *dwav_usb_mt)
+{
+ int id, max_x, max_y, max_press, max_finger;
+
+ max_x = DEV_INFO[dwav_usb_mt->dev_id].max_x;
+ max_y = DEV_INFO[dwav_usb_mt->dev_id].max_y;
+ max_press = DEV_INFO[dwav_usb_mt->dev_id].max_press;
+ max_finger = DEV_INFO[dwav_usb_mt->dev_id].max_finger;
+
+ for (id = 0; id < max_finger; id++) {
+
+ if (dwav_usb_mt->finger[id].status == TS_EVENT_UNKNOWN)
+ continue;
+
+ if (dwav_usb_mt->finger[id].x >= max_x ||
+ dwav_usb_mt->finger[id].y >= max_y)
+ continue;
+
+ input_mt_slot(dwav_usb_mt->input, id);
+
+ if (dwav_usb_mt->finger[id].status != TS_EVENT_RELEASE) {
+ input_mt_report_slot_state(dwav_usb_mt->input,
+ MT_TOOL_FINGER, true);
+ input_report_abs(dwav_usb_mt->input,
+ ABS_MT_POSITION_X,
+ dwav_usb_mt->finger[id].x);
+ input_report_abs(dwav_usb_mt->input,
+ ABS_MT_POSITION_Y,
+ dwav_usb_mt->finger[id].y);
+ input_report_abs(dwav_usb_mt->input,
+ ABS_MT_PRESSURE,
+ max_press);
+ } else {
+ input_mt_report_slot_state(dwav_usb_mt->input,
+ MT_TOOL_FINGER, false);
+ dwav_usb_mt->finger[id].status = TS_EVENT_UNKNOWN;
+ }
+ input_mt_report_pointer_emulation(dwav_usb_mt->input, true);
+ input_sync(dwav_usb_mt->input);
+ }
+}
+
+static void dwav_usb_mt_process(struct dwav_usb_mt *dwav_usb_mt,
+ unsigned char *pkt, int len)
+{
+ struct dwav_raw *dwav_raw = (struct dwav_raw *)pkt;
+ unsigned char bit_mask, cnt;
+
+ for (cnt = 0, bit_mask = 0x01;
+ cnt < DEV_INFO[dwav_usb_mt->dev_id].max_finger;
+ cnt++, bit_mask <<= 1) {
+ if ((dwav_raw->ids & bit_mask) && dwav_raw->press) {
+ dwav_usb_mt->finger[cnt].status = TS_EVENT_PRESS;
+ switch (cnt) {
+ case 0:
+ dwav_usb_mt->finger[cnt].x
+ = cpu_to_be16(dwav_raw->x1);
+ dwav_usb_mt->finger[cnt].y
+ = cpu_to_be16(dwav_raw->y1);
+ break;
+ case 1:
+ dwav_usb_mt->finger[cnt].x
+ = cpu_to_be16(dwav_raw->x2);
+ dwav_usb_mt->finger[cnt].y
+ = cpu_to_be16(dwav_raw->y2);
+ break;
+ case 2:
+ dwav_usb_mt->finger[cnt].x
+ = cpu_to_be16(dwav_raw->x3);
+ dwav_usb_mt->finger[cnt].y
+ = cpu_to_be16(dwav_raw->y3);
+ break;
+ case 3:
+ dwav_usb_mt->finger[cnt].x
+ = cpu_to_be16(dwav_raw->x4);
+ dwav_usb_mt->finger[cnt].y
+ = cpu_to_be16(dwav_raw->y4);
+ break;
+ case 4:
+ dwav_usb_mt->finger[cnt].x
+ = cpu_to_be16(dwav_raw->x5);
+ dwav_usb_mt->finger[cnt].y
+ = cpu_to_be16(dwav_raw->y5);
+ break;
+ default:
+ break;
+ }
+ } else {
+ if (dwav_usb_mt->finger[cnt].status == TS_EVENT_PRESS)
+ dwav_usb_mt->finger[cnt].status
+ = TS_EVENT_RELEASE;
+ else
+ dwav_usb_mt->finger[cnt].status
+ = TS_EVENT_UNKNOWN;
+ }
+ }
+ dwav_usb_mt_report(dwav_usb_mt);
+}
+
+static void dwav_usb_mt_irq(struct urb *urb)
+{
+ struct dwav_usb_mt *dwav_usb_mt = urb->context;
+ struct device *dev = &dwav_usb_mt->interface->dev;
+ int retval;
+
+ switch (urb->status) {
+ case 0:
+ /* success */
+ break;
+ case -ETIME:
+ /* this urb is timing out */
+ dev_dbg(dev, "%s - urb timed out - was the device unplugged?\n",
+ __func__);
+ return;
+ case -ECONNRESET:
+ case -ENOENT:
+ case -ESHUTDOWN:
+ case -EPIPE:
+ /* this urb is terminated, clean up */
+ dev_dbg(dev, "%s - urb shutting down with status: %d\n",
+ __func__, urb->status);
+ return;
+ default:
+ dev_dbg(dev, "%s - nonzero urb status received: %d\n",
+ __func__, urb->status);
+ goto exit;
+ }
+
+ dwav_usb_mt_process(dwav_usb_mt, dwav_usb_mt->data, urb->actual_length);
+
+exit:
+ usb_mark_last_busy(interface_to_usbdev(dwav_usb_mt->interface));
+ retval = usb_submit_urb(urb, GFP_ATOMIC);
+ if (retval) {
+ dev_err(dev, "%s - usb_submit_urb failed with result: %d\n",
+ __func__, retval);
+ }
+}
+
+static int dwav_usb_mt_open(struct input_dev *input)
+{
+ struct dwav_usb_mt *dwav_usb_mt = input_get_drvdata(input);
+ int r;
+
+ dwav_usb_mt->irq->dev = interface_to_usbdev(dwav_usb_mt->interface);
+
+ r = usb_autopm_get_interface(dwav_usb_mt->interface) ? -EIO : 0;
+ if (r < 0)
+ goto out;
+
+ if (usb_submit_urb(dwav_usb_mt->irq, GFP_KERNEL)) {
+ r = -EIO;
+ goto out_put;
+ }
+
+ dwav_usb_mt->interface->needs_remote_wakeup = 1;
+out_put:
+ usb_autopm_put_interface(dwav_usb_mt->interface);
+out:
+ return r;
+}
+
+static void dwav_usb_mt_close(struct input_dev *input)
+{
+ struct dwav_usb_mt *dwav_usb_mt = input_get_drvdata(input);
+ int r;
+
+ usb_kill_urb(dwav_usb_mt->irq);
+
+ r = usb_autopm_get_interface(dwav_usb_mt->interface);
+
+ dwav_usb_mt->interface->needs_remote_wakeup = 0;
+ if (!r)
+ usb_autopm_put_interface(dwav_usb_mt->interface);
+}
+
+static int dwav_usb_mt_suspend(struct usb_interface *intf, pm_message_t message)
+{
+ struct dwav_usb_mt *dwav_usb_mt = usb_get_intfdata(intf);
+
+ usb_kill_urb(dwav_usb_mt->irq);
+
+ return 0;
+}
+
+static int dwav_usb_mt_resume(struct usb_interface *intf)
+{
+ struct dwav_usb_mt *dwav_usb_mt = usb_get_intfdata(intf);
+ struct input_dev *input = dwav_usb_mt->input;
+ int result = 0;
+
+ mutex_lock(&input->mutex);
+ if (input->users)
+ result = usb_submit_urb(dwav_usb_mt->irq, GFP_NOIO);
+ mutex_unlock(&input->mutex);
+
+ return result;
+}
+
+static int dwav_usb_mt_reset_resume(struct usb_interface *intf)
+{
+ struct dwav_usb_mt *dwav_usb_mt = usb_get_intfdata(intf);
+ struct input_dev *input = dwav_usb_mt->input;
+ int err = 0;
+
+ /* restart IO if needed */
+ mutex_lock(&input->mutex);
+ if (input->users)
+ err = usb_submit_urb(dwav_usb_mt->irq, GFP_NOIO);
+ mutex_unlock(&input->mutex);
+
+ return err;
+}
+
+static void dwav_usb_mt_free_buffers(struct usb_device *udev,
+ struct dwav_usb_mt *dwav_usb_mt)
+{
+ usb_free_coherent(udev, dwav_usb_mt->data_size,
+ dwav_usb_mt->data, dwav_usb_mt->data_dma);
+}
+
+static struct usb_endpoint_descriptor *dwav_usb_mt_get_input_endpoint(
+ struct usb_host_interface *interface)
+{
+ int i;
+
+ for (i = 0; i < interface->desc.bNumEndpoints; i++) {
+ if (usb_endpoint_dir_in(&interface->endpoint[i].desc))
+ return &interface->endpoint[i].desc;
+ }
+
+ return NULL;
+}
+
+static int dwav_usb_mt_init(struct dwav_usb_mt *dwav_usb_mt, void *dev)
+{
+ int err;
+ struct input_dev *input_dev = (struct input_dev *)dev;
+
+ input_dev->name = dwav_usb_mt->name;
+ input_dev->phys = dwav_usb_mt->phys;
+
+ input_set_drvdata(input_dev, dwav_usb_mt);
+
+ input_dev->open = dwav_usb_mt_open;
+ input_dev->close = dwav_usb_mt_close;
+
+ input_dev->id.bustype = BUS_USB;
+
+ /* single touch */
+ input_dev->evbit[0] = BIT_MASK(EV_KEY) | BIT_MASK(EV_ABS);
+ input_dev->keybit[BIT_WORD(BTN_TOUCH)] = BIT_MASK(BTN_TOUCH);
+
+ input_set_abs_params(input_dev, ABS_X, 0,
+ DEV_INFO[dwav_usb_mt->dev_id].max_x, 0, 0);
+ input_set_abs_params(input_dev, ABS_Y, 0,
+ DEV_INFO[dwav_usb_mt->dev_id].max_y, 0, 0);
+
+ /* multi touch */
+ input_set_abs_params(input_dev, ABS_MT_POSITION_X, 0,
+ DEV_INFO[dwav_usb_mt->dev_id].max_x, 0, 0);
+ input_set_abs_params(input_dev, ABS_MT_POSITION_Y, 0,
+ DEV_INFO[dwav_usb_mt->dev_id].max_y, 0, 0);
+ input_mt_init_slots(input_dev,
+ DEV_INFO[dwav_usb_mt->dev_id].max_finger, 0);
+
+ err = input_register_device(input_dev);
+ if (err) {
+ pr_err("%s - input_register_device failed, err: %d\n",
+ __func__, err);
+ return err;
+ }
+
+ dwav_usb_mt->input = input_dev;
+
+ return 0;
+}
+
+static int dwav_usb_mt_probe(struct usb_interface *intf,
+ const struct usb_device_id *id)
+{
+ struct dwav_usb_mt *dwav_usb_mt = NULL;
+ struct input_dev *input_dev = NULL;
+ struct usb_endpoint_descriptor *endpoint;
+ struct usb_device *udev = interface_to_usbdev(intf);
+
+ int err = 0;
+
+ endpoint = dwav_usb_mt_get_input_endpoint(intf->cur_altsetting);
+ if (!endpoint)
+ return -ENXIO;
+
+ dwav_usb_mt = kzalloc(sizeof(struct dwav_usb_mt), GFP_KERNEL);
+ if (!dwav_usb_mt)
+ return -ENOMEM;
+
+ dwav_usb_mt->dev_id = id->driver_info;
+
+ dwav_usb_mt->finger = kzalloc(sizeof(struct finger_t) *
+ DEV_INFO[dwav_usb_mt->dev_id].max_finger,
+ GFP_KERNEL);
+
+ if (!dwav_usb_mt->finger)
+ goto err_free_mem;
+
+ input_dev = input_allocate_device();
+ if (!input_dev)
+ goto err_free_mem;
+
+ dwav_usb_mt->data_size = sizeof(struct dwav_raw);
+ dwav_usb_mt->data = usb_alloc_coherent(udev, dwav_usb_mt->data_size,
+ GFP_KERNEL, &dwav_usb_mt->data_dma);
+ if (!dwav_usb_mt->data)
+ goto err_free_mem;
+
+ dwav_usb_mt->irq = usb_alloc_urb(0, GFP_KERNEL);
+ if (!dwav_usb_mt->irq) {
+ dev_dbg(&intf->dev,
+ "%s - usb_alloc_urb failed: usbtouch->irq\n",
+ __func__);
+ goto err_free_buffers;
+ }
+
+ if (usb_endpoint_type(endpoint) == USB_ENDPOINT_XFER_INT) {
+ usb_fill_int_urb(dwav_usb_mt->irq, udev,
+ usb_rcvintpipe(udev, endpoint->bEndpointAddress),
+ dwav_usb_mt->data, dwav_usb_mt->data_size,
+ dwav_usb_mt_irq, dwav_usb_mt, endpoint->bInterval);
+ } else {
+ usb_fill_bulk_urb(dwav_usb_mt->irq, udev,
+ usb_rcvbulkpipe(udev, endpoint->bEndpointAddress),
+ dwav_usb_mt->data, dwav_usb_mt->data_size,
+ dwav_usb_mt_irq, dwav_usb_mt);
+ }
+
+ dwav_usb_mt->irq->dev = udev;
+ dwav_usb_mt->irq->transfer_dma = dwav_usb_mt->data_dma;
+ dwav_usb_mt->irq->transfer_flags |= URB_NO_TRANSFER_DMA_MAP;
+
+ dwav_usb_mt->interface = intf;
+
+ if (udev->manufacturer)
+ strlcpy(dwav_usb_mt->name,
+ udev->manufacturer, sizeof(dwav_usb_mt->name));
+
+ if (udev->product) {
+ if (udev->manufacturer)
+ strlcat(dwav_usb_mt->name,
+ " ", sizeof(dwav_usb_mt->name));
+
+ strlcat(dwav_usb_mt->name,
+ udev->product, sizeof(dwav_usb_mt->name));
+ }
+
+ if (!strlen(dwav_usb_mt->name)) {
+ snprintf(dwav_usb_mt->name, sizeof(dwav_usb_mt->name),
+ "D-WAV Scientific MultiTouch %04x:%04x",
+ le16_to_cpu(udev->descriptor.idVendor),
+ le16_to_cpu(udev->descriptor.idProduct));
+ }
+
+ usb_make_path(udev, dwav_usb_mt->phys, sizeof(dwav_usb_mt->phys));
+ strlcat(dwav_usb_mt->phys, "/input0", sizeof(dwav_usb_mt->phys));
+
+ usb_to_input_id(udev, &input_dev->id);
+
+ input_dev->dev.parent = &intf->dev;
+
+ err = dwav_usb_mt_init(dwav_usb_mt, (void *)input_dev);
+ if (err)
+ goto err_free_urb;
+
+ usb_set_intfdata(intf, dwav_usb_mt);
+
+ dev_info(&intf->dev, "%s\n", DEV_INFO[dwav_usb_mt->dev_id].name);
+
+ return 0;
+
+err_free_urb:
+ usb_free_urb(dwav_usb_mt->irq);
+
+err_free_buffers:
+ dwav_usb_mt_free_buffers(udev, dwav_usb_mt);
+
+err_free_mem:
+ if (input_dev)
+ input_free_device(input_dev);
+ kfree(dwav_usb_mt);
+
+ return err;
+}
+
+static void dwav_usb_mt_disconnect(struct usb_interface *intf)
+{
+ struct dwav_usb_mt *dwav_usb_mt = usb_get_intfdata(intf);
+
+ if (!dwav_usb_mt)
+ return;
+
+ dev_dbg(&intf->dev,
+ "%s - dwav_usb_mt is initialized, cleaning up\n",
+ __func__);
+
+ usb_set_intfdata(intf, NULL);
+
+ /* this will stop IO via close */
+ input_unregister_device(dwav_usb_mt->input);
+
+ usb_free_urb(dwav_usb_mt->irq);
+
+ dwav_usb_mt_free_buffers(interface_to_usbdev(intf), dwav_usb_mt);
+
+ kfree(dwav_usb_mt);
+}
+
+MODULE_DEVICE_TABLE(usb, dwav_usb_mt_devices);
+
+static struct usb_driver dwav_usb_mt_driver = {
+ .name = "dwav_usb_mt",
+ .probe = dwav_usb_mt_probe,
+ .disconnect = dwav_usb_mt_disconnect,
+ .suspend = dwav_usb_mt_suspend,
+ .resume = dwav_usb_mt_resume,
+ .reset_resume = dwav_usb_mt_reset_resume,
+ .id_table = dwav_usb_mt_devices,
+ .supports_autosuspend = 1,
+};
+
+module_usb_driver(dwav_usb_mt_driver);
+
+MODULE_AUTHOR("Hardkernel Co.,Ltd");
+MODULE_DESCRIPTION("D-WAV USB(HID) MultiTouch Driver");
+MODULE_LICENSE("GPL");
+
+MODULE_ALIAS("dwav_usb_mt");
\ No newline at end of file
--
2.25.1

View file

@ -0,0 +1,146 @@
From 2ede00b489f3afa3bec5e587f53ef8dba2a69dfd Mon Sep 17 00:00:00 2001
From: Dongjin Kim <tobetter@gmail.com>
Date: Thu, 30 Apr 2020 23:51:12 +0900
Subject: [PATCH 17/74] ODROID-C4: arm64: dts: meson-sm1-odroid-c4: add sound
card
Add the sound card on Hardkernel ODROID-C4 and enable HDMI output with
the interface TDM-B.
Tested commands:
amixer sset 'FRDDR_A SINK 1 SEL' 'OUT 1'
amixer sset 'FRDDR_A SRC 1 EN' 'on'
amixer sset 'TDMOUT_B SRC SEL' 'IN 0'
amixer sset 'TOHDMITX I2S SRC' 'I2S B'
amixer sset 'TOHDMITX' 'on'
alsactl store
Change-Id: I7aa2d310fb97af7aa77fc54e3e56a09ee5b30b40
Signed-off-by: Dongjin Kim <tobetter@gmail.com>
---
.../boot/dts/amlogic/meson-sm1-odroid-c4.dts | 88 +++++++++++++++++++
1 file changed, 88 insertions(+)
diff --git a/arch/arm64/boot/dts/amlogic/meson-sm1-odroid-c4.dts b/arch/arm64/boot/dts/amlogic/meson-sm1-odroid-c4.dts
index 807f88cd5280..4dbdf049c87c 100644
--- a/arch/arm64/boot/dts/amlogic/meson-sm1-odroid-c4.dts
+++ b/arch/arm64/boot/dts/amlogic/meson-sm1-odroid-c4.dts
@@ -7,6 +7,7 @@
#include "meson-sm1.dtsi"
#include <dt-bindings/gpio/meson-g12a-gpio.h>
+#include <dt-bindings/sound/meson-g12a-tohdmitx.h>
#include <dt-bindings/leds/common.h>
/ {
@@ -187,6 +188,69 @@ hdmi_connector_in: endpoint {
};
};
};
+
+ sound {
+ compatible = "amlogic,axg-sound-card";
+ model = "SM1-ODROID-C4";
+ audio-aux-devs = <&tdmout_b>;
+ audio-routing = "TDMOUT_B IN 0", "FRDDR_A OUT 1",
+ "TDMOUT_B IN 1", "FRDDR_B OUT 1",
+ "TDMOUT_B IN 2", "FRDDR_C OUT 1",
+ "TDM_B Playback", "TDMOUT_B OUT";
+
+ assigned-clocks = <&clkc CLKID_MPLL2>,
+ <&clkc CLKID_MPLL0>,
+ <&clkc CLKID_MPLL1>;
+ assigned-clock-parents = <0>, <0>, <0>;
+ assigned-clock-rates = <294912000>,
+ <270950400>,
+ <393216000>;
+ status = "okay";
+
+ dai-link-0 {
+ sound-dai = <&frddr_a>;
+ };
+
+ dai-link-1 {
+ sound-dai = <&frddr_b>;
+ };
+
+ dai-link-2 {
+ sound-dai = <&frddr_c>;
+ };
+
+ /* 8ch hdmi interface */
+ dai-link-3 {
+ sound-dai = <&tdmif_b>;
+ dai-format = "i2s";
+ dai-tdm-slot-tx-mask-0 = <1 1>;
+ dai-tdm-slot-tx-mask-1 = <1 1>;
+ dai-tdm-slot-tx-mask-2 = <1 1>;
+ dai-tdm-slot-tx-mask-3 = <1 1>;
+ mclk-fs = <256>;
+
+ codec {
+ sound-dai = <&tohdmitx TOHDMITX_I2S_IN_B>;
+ };
+ };
+
+ /* hdmi glue */
+ dai-link-4 {
+ sound-dai = <&tohdmitx TOHDMITX_I2S_OUT>;
+
+ codec {
+ sound-dai = <&hdmi_tx>;
+ };
+ };
+ };
+};
+
+&arb {
+ status = "okay";
+};
+
+&clkc_audio {
+ status = "okay";
};
&cpu0 {
@@ -242,6 +306,18 @@ &ethmac {
amlogic,tx-delay-ns = <2>;
};
+&frddr_a {
+ status = "okay";
+};
+
+&frddr_b {
+ status = "okay";
+};
+
+&frddr_c {
+ status = "okay";
+};
+
&gpio {
gpio-line-names =
/* GPIOZ */
@@ -390,6 +466,18 @@ &sd_emmc_c {
vqmmc-supply = <&flash_1v8>;
};
+&tdmif_b {
+ status = "okay";
+};
+
+&tdmout_b {
+ status = "okay";
+};
+
+&tohdmitx {
+ status = "okay";
+};
+
&uart_A {
status = "okay";
pinctrl-names = "default";
--
2.25.1

View file

@ -0,0 +1,60 @@
From 6ed323304dfb43ad2741f4e01a79299203c1d21d Mon Sep 17 00:00:00 2001
From: Hyeonki Hong <hhk7734@gmail.com>
Date: Tue, 14 Apr 2020 14:11:30 +0900
Subject: [PATCH 19/74] ODROID-C4: arm64/dts: add spicc0 node
Change-Id: I6ccc3714fce677b1eb104c10f657739320f3772f
(cherry picked from commit e50729e07786d6ee611e0bcfafbfd7b352c9e9ac)
---
.../boot/dts/amlogic/meson-sm1-odroid-c4.dts | 28 +++++++++++++++++++
1 file changed, 28 insertions(+)
diff --git a/arch/arm64/boot/dts/amlogic/meson-sm1-odroid-c4.dts b/arch/arm64/boot/dts/amlogic/meson-sm1-odroid-c4.dts
index 4dbdf049c87c..8d3523c163c5 100644
--- a/arch/arm64/boot/dts/amlogic/meson-sm1-odroid-c4.dts
+++ b/arch/arm64/boot/dts/amlogic/meson-sm1-odroid-c4.dts
@@ -18,6 +18,7 @@ aliases {
ethernet0 = &ethmac;
serial0 = &uart_AO;
serial1 = &uart_A;
+ spi0 = &spicc0;
};
chosen {
@@ -466,6 +467,33 @@ &sd_emmc_c {
vqmmc-supply = <&flash_1v8>;
};
+&spicc0 {
+ status = "okay";
+
+ /*
+ * 40 Pin Header : MOSI(GPIOX.8->19 Pin),
+ * MISO(GPIOX.9->21 Pin),
+ * SPI0_CLK(GPIOX.11->23 Pin)
+ * SPI_CS0(GPIOX.10->24 Pin)
+ * SPI_CS1(GPIOH.6->26 Pin)
+ */
+ pinctrl-names = "default","gpio_periphs";
+ pinctrl-0 = <&spicc0_x_pins>;
+ pinctrl-1 = <&spicc0_ss0_x_pins>;
+ num_chipselect = <1>;
+
+ cs-gpios = <&gpio GPIOX_10 GPIO_ACTIVE_LOW>;
+
+ spidev@0 {
+ status = "okay";
+
+ compatible = "linux,spidev";
+ /* spi default max clock 100Mhz */
+ spi-max-frequency = <100000000>;
+ reg = <0>;
+ };
+};
+
&tdmif_b {
status = "okay";
};
--
2.25.1

View file

@ -0,0 +1,146 @@
From ce866a9b68a21ecde72401bb1ccc82be5981d87f Mon Sep 17 00:00:00 2001
From: Dongjin Kim <tobetter@gmail.com>
Date: Wed, 6 May 2020 15:33:45 +0900
Subject: [PATCH 20/74] ODROID-N2/C4: arm64/dts: add CPU thermal cooling map
Change-Id: Idddee81e210daef5afb8ca059e8dced40c770cc8
Signed-off-by: Dongjin Kim <tobetter@gmail.com>
---
.../boot/dts/amlogic/meson-g12b-odroid-n2.dts | 30 +++++++++++++++++++
.../boot/dts/amlogic/meson-sm1-odroid-c4.dts | 23 ++++++++++++++
2 files changed, 53 insertions(+)
diff --git a/arch/arm64/boot/dts/amlogic/meson-g12b-odroid-n2.dts b/arch/arm64/boot/dts/amlogic/meson-g12b-odroid-n2.dts
index 047e076df661..232f86c6c37d 100644
--- a/arch/arm64/boot/dts/amlogic/meson-g12b-odroid-n2.dts
+++ b/arch/arm64/boot/dts/amlogic/meson-g12b-odroid-n2.dts
@@ -292,6 +292,7 @@ &cpu0 {
operating-points-v2 = <&cpu_opp_table_0>;
clocks = <&clkc CLKID_CPU_CLK>;
clock-latency = <50000>;
+ #cooling-cells = <2>;
};
&cpu1 {
@@ -299,6 +300,7 @@ &cpu1 {
operating-points-v2 = <&cpu_opp_table_0>;
clocks = <&clkc CLKID_CPU_CLK>;
clock-latency = <50000>;
+ #cooling-cells = <2>;
};
&cpu100 {
@@ -306,6 +308,7 @@ &cpu100 {
operating-points-v2 = <&cpub_opp_table_1>;
clocks = <&clkc CLKID_CPUB_CLK>;
clock-latency = <50000>;
+ #cooling-cells = <2>;
};
&cpu101 {
@@ -313,6 +316,7 @@ &cpu101 {
operating-points-v2 = <&cpub_opp_table_1>;
clocks = <&clkc CLKID_CPUB_CLK>;
clock-latency = <50000>;
+ #cooling-cells = <2>;
};
&cpu102 {
@@ -320,6 +324,7 @@ &cpu102 {
operating-points-v2 = <&cpub_opp_table_1>;
clocks = <&clkc CLKID_CPUB_CLK>;
clock-latency = <50000>;
+ #cooling-cells = <2>;
};
&cpu103 {
@@ -327,6 +332,31 @@ &cpu103 {
operating-points-v2 = <&cpub_opp_table_1>;
clocks = <&clkc CLKID_CPUB_CLK>;
clock-latency = <50000>;
+ #cooling-cells = <2>;
+};
+
+&cpu_thermal {
+ trips {
+ cpu_passive: cpu-passive {
+ temperature = <70000>; /* millicelsius */
+ hysteresis = <2000>; /* millicelsius */
+ type = "passive";
+ };
+ };
+ cooling-maps {
+ cpufreq_map0 {
+ trip = <&cpu_passive>;
+ cooling-device = <&cpu0 THERMAL_NO_LIMIT THERMAL_NO_LIMIT>,
+ <&cpu1 THERMAL_NO_LIMIT THERMAL_NO_LIMIT>;
+ };
+ cpufreq_map1 {
+ trip = <&cpu_passive>;
+ cooling-device = <&cpu100 THERMAL_NO_LIMIT THERMAL_NO_LIMIT>,
+ <&cpu101 THERMAL_NO_LIMIT THERMAL_NO_LIMIT>,
+ <&cpu102 THERMAL_NO_LIMIT THERMAL_NO_LIMIT>,
+ <&cpu103 THERMAL_NO_LIMIT THERMAL_NO_LIMIT>;
+ };
+ };
};
&ext_mdio {
diff --git a/arch/arm64/boot/dts/amlogic/meson-sm1-odroid-c4.dts b/arch/arm64/boot/dts/amlogic/meson-sm1-odroid-c4.dts
index 8d3523c163c5..831053aa6dff 100644
--- a/arch/arm64/boot/dts/amlogic/meson-sm1-odroid-c4.dts
+++ b/arch/arm64/boot/dts/amlogic/meson-sm1-odroid-c4.dts
@@ -259,6 +259,7 @@ &cpu0 {
operating-points-v2 = <&cpu_opp_table>;
clocks = <&clkc CLKID_CPU_CLK>;
clock-latency = <50000>;
+ #cooling-cells = <2>;
};
&cpu1 {
@@ -266,6 +267,7 @@ &cpu1 {
operating-points-v2 = <&cpu_opp_table>;
clocks = <&clkc CLKID_CPU1_CLK>;
clock-latency = <50000>;
+ #cooling-cells = <2>;
};
&cpu2 {
@@ -273,6 +275,7 @@ &cpu2 {
operating-points-v2 = <&cpu_opp_table>;
clocks = <&clkc CLKID_CPU2_CLK>;
clock-latency = <50000>;
+ #cooling-cells = <2>;
};
&cpu3 {
@@ -280,6 +283,26 @@ &cpu3 {
operating-points-v2 = <&cpu_opp_table>;
clocks = <&clkc CLKID_CPU3_CLK>;
clock-latency = <50000>;
+ #cooling-cells = <2>;
+};
+
+&cpu_thermal {
+ trips {
+ cpu_passive: cpu-passive {
+ temperature = <70000>; /* millicelsius */
+ hysteresis = <2000>; /* millicelsius */
+ type = "passive";
+ };
+ };
+ cooling-maps {
+ cpufreq_map0 {
+ trip = <&cpu_passive>;
+ cooling-device = <&cpu0 THERMAL_NO_LIMIT THERMAL_NO_LIMIT>,
+ <&cpu1 THERMAL_NO_LIMIT THERMAL_NO_LIMIT>,
+ <&cpu2 THERMAL_NO_LIMIT THERMAL_NO_LIMIT>,
+ <&cpu3 THERMAL_NO_LIMIT THERMAL_NO_LIMIT>;
+ };
+ };
};
&ext_mdio {
--
2.25.1

View file

@ -0,0 +1,85 @@
From 400645dd70ae5a0efbbce35067c8674d380ed2a7 Mon Sep 17 00:00:00 2001
From: Hyeonki Hong <hhk7734@gmail.com>
Date: Wed, 13 May 2020 10:37:28 +0900
Subject: [PATCH 21/74] ODROID-C4: arm64/dts: add i2c2, i2c3 node
Change-Id: Id75f935111744ff6945791deefef20f897dc98ac
(cherry picked from commit 3f4b2ffd0905946175c478baa65361695e78e0de)
---
.../boot/dts/amlogic/meson-sm1-odroid-c4.dts | 53 +++++++++++++++++++
1 file changed, 53 insertions(+)
diff --git a/arch/arm64/boot/dts/amlogic/meson-sm1-odroid-c4.dts b/arch/arm64/boot/dts/amlogic/meson-sm1-odroid-c4.dts
index 831053aa6dff..5988dc5f34d0 100644
--- a/arch/arm64/boot/dts/amlogic/meson-sm1-odroid-c4.dts
+++ b/arch/arm64/boot/dts/amlogic/meson-sm1-odroid-c4.dts
@@ -16,6 +16,8 @@ / {
aliases {
ethernet0 = &ethmac;
+ i2c0 = &i2c2;
+ i2c1 = &i2c3;
serial0 = &uart_AO;
serial1 = &uart_A;
spi0 = &spicc0;
@@ -434,6 +436,57 @@ &ir {
linux,rc-map-name = "rc-odroid";
};
+&i2c2 {
+ status = "okay";
+
+ /*
+ * 40 Pin Header : SDA(GPIOX.17->3 Pin)
+ * SCL(GPIOX.18->5 Pin)
+ */
+ pinctrl-names = "default";
+ pinctrl-0 = <&i2c2_master_pins1>;
+
+ /* default 400k */
+ clock-frequency = <400000>;
+};
+
+&i2c3 {
+ /* default i2c clock-frequency is 100Khz */
+ status = "okay";
+
+ /*
+ * 40 Pin Header : SDA(GPIOA.14->27 Pin)
+ * SCL(GPIOA.15->28 Pin)
+ */
+ pinctrl-names = "default";
+ pinctrl-0 = <&i2c3_master_pins2>;
+
+ /* default 100k */
+ clock-frequency = <100000>;
+};
+
+&periphs_pinctrl {
+ i2c2_master_pins1: i2c2-master-pins1 {
+ mux {
+ groups = "i2c2_sda_x",
+ "i2c2_sck_x";
+ function = "i2c2";
+ bias-pull-up;
+ drive-strength-microamp = <3000>;
+ };
+ };
+
+ i2c3_master_pins2: i2c3-master-pins2 {
+ mux {
+ groups = "i2c3_sda_a",
+ "i2c3_sck_a";
+ function = "i2c3";
+ bias-pull-up;
+ drive-strength-microamp = <3000>;
+ };
+ };
+};
+
&pwm_AO_cd {
pinctrl-0 = <&pwm_ao_d_e_pins>;
pinctrl-names = "default";
--
2.25.1

View file

@ -0,0 +1,41 @@
From 8a4510a8da6f43d13022cfba13b695819a263c83 Mon Sep 17 00:00:00 2001
From: Hyeonki Hong <hhk7734@gmail.com>
Date: Wed, 10 Jun 2020 12:54:06 +0900
Subject: [PATCH 22/74] pinctrl: meson: fix drive strength register and bit
calculation
If a GPIO bank has greater than 16 pins, PAD_DS_REG is split into two
registers. However, when register and bit were calculated, the first
register defined in the bank was used, and the bit was calculated based
on the first pin. This causes problems in setting the driving strength.
Solved the problem by changing the bit using a mask and selecting the
next register when the bit exceeds 15.
Signed-off-by: Hyeonki Hong <hhk7734@gmail.com>
Change-Id: Ie0b046e50f6c92603030b0b490838219e81f5408
---
drivers/pinctrl/meson/pinctrl-meson.c | 7 +++++++
1 file changed, 7 insertions(+)
diff --git a/drivers/pinctrl/meson/pinctrl-meson.c b/drivers/pinctrl/meson/pinctrl-meson.c
index 079f8ee8d353..aa2898c6c1e5 100644
--- a/drivers/pinctrl/meson/pinctrl-meson.c
+++ b/drivers/pinctrl/meson/pinctrl-meson.c
@@ -98,6 +98,13 @@ static void meson_calc_reg_and_bit(struct meson_bank *bank, unsigned int pin,
*reg = desc->reg * 4;
*bit = desc->bit + pin - bank->first;
+
+ if (reg_type == REG_DS) {
+ if (*bit > 15) {
+ *bit &= 0xf;
+ *reg += 4;
+ }
+ }
}
static int meson_get_groups_count(struct pinctrl_dev *pcdev)
--
2.25.1

View file

@ -0,0 +1,28 @@
From b34c9fad04b326725dd5b2723e1868580564741b Mon Sep 17 00:00:00 2001
From: Hyeonki Hong <hhk7734@gmail.com>
Date: Fri, 12 Jun 2020 16:42:39 +0900
Subject: [PATCH 23/74] ODROID-N2: arm64/dts: modify i2c alias bus number
Change-Id: Ie9550c77f01931e6c718b869d6581cadd44d45f8
---
arch/arm64/boot/dts/amlogic/meson-g12b-odroid-n2.dts | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/arch/arm64/boot/dts/amlogic/meson-g12b-odroid-n2.dts b/arch/arm64/boot/dts/amlogic/meson-g12b-odroid-n2.dts
index 232f86c6c37d..65df5fb49ae6 100644
--- a/arch/arm64/boot/dts/amlogic/meson-g12b-odroid-n2.dts
+++ b/arch/arm64/boot/dts/amlogic/meson-g12b-odroid-n2.dts
@@ -17,8 +17,8 @@ / {
aliases {
ethernet0 = &ethmac;
- i2c1 = &i2c2;
- i2c2 = &i2c3;
+ i2c0 = &i2c2;
+ i2c1 = &i2c3;
serial0 = &uart_AO;
serial1 = &uart_A;
};
--
2.25.1

View file

@ -0,0 +1,37 @@
From 803c6b7ac65e833864f34c0e7ece501f8f6a6706 Mon Sep 17 00:00:00 2001
From: ckkim <changkon12@gmail.com>
Date: Thu, 20 Feb 2020 18:52:57 +0900
Subject: [PATCH 24/74] ODROID-N2: sound/soc: remove mono channel as it
currently doesn't work hdmi output.
Change-Id: I4d43b802815779687ade974f049f2b0517a411d1
Signed-off-by: ckkim <changkon12@gmail.com>
---
sound/soc/meson/axg-frddr.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/sound/soc/meson/axg-frddr.c b/sound/soc/meson/axg-frddr.c
index c3ae8ac30745..cfb9b12c2b56 100644
--- a/sound/soc/meson/axg-frddr.c
+++ b/sound/soc/meson/axg-frddr.c
@@ -92,7 +92,7 @@ static struct snd_soc_dai_driver axg_frddr_dai_drv = {
.name = "FRDDR",
.playback = {
.stream_name = "Playback",
- .channels_min = 1,
+ .channels_min = 2,
.channels_max = AXG_FIFO_CH_MAX,
.rates = AXG_FIFO_RATES,
.formats = AXG_FIFO_FORMATS,
@@ -165,7 +165,7 @@ static struct snd_soc_dai_driver g12a_frddr_dai_drv = {
.name = "FRDDR",
.playback = {
.stream_name = "Playback",
- .channels_min = 1,
+ .channels_min = 2,
.channels_max = AXG_FIFO_CH_MAX,
.rates = AXG_FIFO_RATES,
.formats = AXG_FIFO_FORMATS,
--
2.25.1

View file

@ -0,0 +1,29 @@
From c623de44981a195b471cf1c9bac8a1cd3f6279aa Mon Sep 17 00:00:00 2001
From: ckkim <changkon12@gmail.com>
Date: Tue, 16 Jun 2020 16:16:30 +0900
Subject: [PATCH 25/74] ODROID-N2: sound/soc: add audio module for g12a, g12b,
sm1
Signed-off-by: ckkim <changkon12@gmail.com>
Change-Id: I02b2b8d1ec756dfc361300082d94b3ef339cb0d6
---
sound/soc/meson/Kconfig | 3 +++
1 file changed, 3 insertions(+)
diff --git a/sound/soc/meson/Kconfig b/sound/soc/meson/Kconfig
index 8b6295283989..7b6ee708b74c 100644
--- a/sound/soc/meson/Kconfig
+++ b/sound/soc/meson/Kconfig
@@ -69,6 +69,9 @@ config SND_MESON_AXG_SOUND_CARD
imply SND_MESON_AXG_SPDIFIN
imply SND_MESON_AXG_PDM
imply SND_MESON_G12A_TOHDMITX if DRM_MESON_DW_HDMI
+ imply SND_MESON_G12A_TOACODEC
+ imply SND_SOC_MESON_T9015
+ imply SND_SOC_SIMPLE_AMPLIFIER
help
Select Y or M to add support for the AXG SoC sound card
--
2.25.1

View file

@ -0,0 +1,367 @@
From 1167e0322f28f603ca30fba62e6cfbee56e512ce Mon Sep 17 00:00:00 2001
From: Kevin Kim <ckkim@hardkernel.com>
Date: Wed, 16 Jan 2019 14:45:10 +0900
Subject: [PATCH 29/74] ODROID-COMMON: pwm: gpio: Add a generic gpio based PWM
driver
From: Olliver Schinagl <oliver@schinagl.nl>
This patch adds a bit-banging gpio PWM driver. It makes use of hrtimers,
to allow nano-second resolution, though it obviously strongly depends on
the switching speed of the gpio pins, hrtimer and system load.
Each pwm node can have 1 or more "pwm-gpio" entries, which will be
treated as pwm's as part of a pwm chip.
Change-Id: Idd42bf6d79f8ce52275a15965b02af470f28da7c
Signed-off-by: Olliver Schinagl <oliver@schinagl.nl>
---
.../devicetree/bindings/pwm/pwm-gpio.txt | 18 ++
MAINTAINERS | 5 +
drivers/pwm/Kconfig | 15 ++
drivers/pwm/Makefile | 1 +
drivers/pwm/pwm-gpio.c | 253 ++++++++++++++++++
5 files changed, 292 insertions(+)
create mode 100644 Documentation/devicetree/bindings/pwm/pwm-gpio.txt
create mode 100644 drivers/pwm/pwm-gpio.c
diff --git a/Documentation/devicetree/bindings/pwm/pwm-gpio.txt b/Documentation/devicetree/bindings/pwm/pwm-gpio.txt
new file mode 100644
index 000000000000..336f61faa446
--- /dev/null
+++ b/Documentation/devicetree/bindings/pwm/pwm-gpio.txt
@@ -0,0 +1,18 @@
+Generic GPIO bit-banged PWM driver
+
+Required properties:
+ - compatible: should be "pwm-gpio"
+ - #pwm-cells: should be 3, see pwm.txt in this directory for a general
+ description of the cells format.
+ - pwm-gpios: one or more gpios describing the used gpio, see the gpio
+ bindings for the used gpio driver.
+
+Example:
+#include <dt-bindings/gpio/gpio.h>
+
+ pwm: pwm@0 {
+ compatible = "pwm-gpio";
+ #pwm-cells = 3;
+ pwm-gpios = <&pio 7 1 GPIO_ACTIVE_LOW>;
+ pwm-gpios = <&pio 7 2 GPIO_ACTIVE_LOW>;
+ };
diff --git a/MAINTAINERS b/MAINTAINERS
index 4e2698cc7e23..63e59da28c58 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -7186,6 +7186,11 @@ F: Documentation/i2c/muxes/i2c-mux-gpio.rst
F: drivers/i2c/muxes/i2c-mux-gpio.c
F: include/linux/platform_data/i2c-mux-gpio.h
+GENERIC GPIO PWM DRIVER
+M: Olliver Schinagl <oliver@schinagl.nl>
+S: Maintained
+F: drivers/pwm/pwm-gpio.c
+
GENERIC HDLC (WAN) DRIVERS
M: Krzysztof Halasa <khc@pm.waw.pl>
S: Maintained
diff --git a/drivers/pwm/Kconfig b/drivers/pwm/Kconfig
index cb8d739067d2..609011be5aaf 100644
--- a/drivers/pwm/Kconfig
+++ b/drivers/pwm/Kconfig
@@ -181,6 +181,21 @@ config PWM_FSL_FTM
To compile this driver as a module, choose M here: the module
will be called pwm-fsl-ftm.
+config PWM_GPIO
+ tristate "Generic GPIO bit-banged PWM driver"
+ depends on OF
+ depends on GPIOLIB
+ help
+ Some platforms do not offer any hardware PWM capabilities but do have
+ General Purpose Input Output (GPIO) pins available. Using the kernels
+ High-Resolution Timer API this driver tries to toggle GPIO using the
+ generic kernel PWM framework. The maximum frequency and/or accuracy
+ is dependent on several factors such as system load and the maximum
+ speed a pin can be toggled at the hardware.
+
+ To compile this driver as a module, choose M here: the module
+ will be called pwm-gpio.
+
config PWM_HIBVT
tristate "HiSilicon BVT PWM support"
depends on ARCH_HISI || COMPILE_TEST
diff --git a/drivers/pwm/Makefile b/drivers/pwm/Makefile
index a59c710e98c7..0d0bcce797fb 100644
--- a/drivers/pwm/Makefile
+++ b/drivers/pwm/Makefile
@@ -15,6 +15,7 @@ obj-$(CONFIG_PWM_CRC) += pwm-crc.o
obj-$(CONFIG_PWM_CROS_EC) += pwm-cros-ec.o
obj-$(CONFIG_PWM_EP93XX) += pwm-ep93xx.o
obj-$(CONFIG_PWM_FSL_FTM) += pwm-fsl-ftm.o
+obj-$(CONFIG_PWM_GPIO) += pwm-gpio.o
obj-$(CONFIG_PWM_HIBVT) += pwm-hibvt.o
obj-$(CONFIG_PWM_IMG) += pwm-img.o
obj-$(CONFIG_PWM_IMX1) += pwm-imx1.o
diff --git a/drivers/pwm/pwm-gpio.c b/drivers/pwm/pwm-gpio.c
new file mode 100644
index 000000000000..ab421fb4b8ba
--- /dev/null
+++ b/drivers/pwm/pwm-gpio.c
@@ -0,0 +1,253 @@
+/*
+ * Copyright (c) 2015 Olliver Schinagl <oliver@schinagl.nl>
+ *
+ * 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.
+ *
+ * This driver adds a high-resolution timer based PWM driver. Since this is a
+ * bit-banged driver, accuracy will always depend on a lot of factors, such as
+ * GPIO toggle speed and system load.
+ */
+
+#include <linux/mod_devicetable.h>
+#include <linux/module.h>
+#include <linux/gpio/consumer.h>
+#include <linux/of.h>
+#include <linux/of_gpio.h>
+#include <linux/property.h>
+#include <linux/pwm.h>
+#include <linux/errno.h>
+#include <linux/err.h>
+#include <linux/device.h>
+#include <linux/hrtimer.h>
+#include <linux/ktime.h>
+#include <linux/kernel.h>
+#include <linux/platform_device.h>
+
+#define DRV_NAME "pwm-gpio"
+
+struct gpio_pwm_data {
+ struct hrtimer timer;
+ struct gpio_desc *gpiod;
+ bool polarity;
+ bool pin_on;
+ int on_time;
+ int off_time;
+ bool run;
+};
+
+struct gpio_pwm_chip {
+ struct pwm_chip chip;
+};
+
+static void gpio_pwm_off(struct gpio_pwm_data *gpio_data)
+{
+ gpiod_set_value_cansleep(gpio_data->gpiod, gpio_data->polarity ? 0 : 1);
+}
+
+static void gpio_pwm_on(struct gpio_pwm_data *gpio_data)
+{
+ gpiod_set_value_cansleep(gpio_data->gpiod, gpio_data->polarity ? 1 : 0);
+}
+
+enum hrtimer_restart gpio_pwm_timer(struct hrtimer *timer)
+{
+ struct gpio_pwm_data *gpio_data = container_of(timer,
+ struct gpio_pwm_data,
+ timer);
+ if (!gpio_data->run) {
+ gpio_pwm_off(gpio_data);
+ gpio_data->pin_on = false;
+ return HRTIMER_NORESTART;
+ }
+
+ if (!gpio_data->pin_on) {
+ hrtimer_forward_now(&gpio_data->timer,
+ ns_to_ktime(gpio_data->on_time));
+ gpio_pwm_on(gpio_data);
+ gpio_data->pin_on = true;
+ } else {
+ hrtimer_forward_now(&gpio_data->timer,
+ ns_to_ktime(gpio_data->off_time));
+ gpio_pwm_off(gpio_data);
+ gpio_data->pin_on = false;
+ }
+
+ return HRTIMER_RESTART;
+}
+
+static int gpio_pwm_config(struct pwm_chip *chip, struct pwm_device *pwm,
+ int duty_ns, int period_ns)
+{
+ struct gpio_pwm_data *gpio_data = pwm_get_chip_data(pwm);
+
+ gpio_data->on_time = duty_ns;
+ gpio_data->off_time = period_ns - duty_ns;
+
+ return 0;
+}
+
+static int gpio_pwm_set_polarity(struct pwm_chip *chip, struct pwm_device *pwm,
+ enum pwm_polarity polarity)
+{
+ struct gpio_pwm_data *gpio_data = pwm_get_chip_data(pwm);
+
+ gpio_data->polarity = (polarity != PWM_POLARITY_NORMAL) ? true : false;
+
+ return 0;
+}
+
+static int gpio_pwm_enable(struct pwm_chip *chip, struct pwm_device *pwm)
+{
+ struct gpio_pwm_data *gpio_data = pwm_get_chip_data(pwm);
+
+ if (gpio_data->run)
+ return -EBUSY;
+
+ gpio_data->run = true;
+ if (gpio_data->off_time) {
+ hrtimer_start(&gpio_data->timer, ktime_set(0, 0),
+ HRTIMER_MODE_REL);
+ } else {
+ if (gpio_data->on_time)
+ gpio_pwm_on(gpio_data);
+ else
+ gpio_pwm_off(gpio_data);
+ }
+
+ return 0;
+}
+
+static void gpio_pwm_disable(struct pwm_chip *chip, struct pwm_device *pwm)
+{
+ struct gpio_pwm_data *gpio_data = pwm_get_chip_data(pwm);
+
+ gpio_data->run = false;
+ if (!gpio_data->off_time)
+ gpio_pwm_off(gpio_data);
+}
+
+static const struct pwm_ops gpio_pwm_ops = {
+ .config = gpio_pwm_config,
+ .set_polarity = gpio_pwm_set_polarity,
+ .enable = gpio_pwm_enable,
+ .disable = gpio_pwm_disable,
+ .owner = THIS_MODULE,
+};
+
+static int gpio_pwm_probe(struct platform_device *pdev)
+{
+ int ret;
+ struct gpio_pwm_chip *gpio_chip;
+ int npwm, i;
+ int hrtimer = 0;
+
+ npwm = of_gpio_named_count(pdev->dev.of_node, "pwm-gpios");
+ if (npwm < 1)
+ return -ENODEV;
+
+ gpio_chip = devm_kzalloc(&pdev->dev, sizeof(*gpio_chip), GFP_KERNEL);
+ if (!gpio_chip)
+ return -ENOMEM;
+
+ gpio_chip->chip.dev = &pdev->dev;
+ gpio_chip->chip.ops = &gpio_pwm_ops;
+ gpio_chip->chip.base = -1;
+ gpio_chip->chip.npwm = npwm;
+ gpio_chip->chip.of_xlate = of_pwm_xlate_with_flags;
+ gpio_chip->chip.of_pwm_n_cells = 3;
+
+ ret = pwmchip_add(&gpio_chip->chip);
+ if (ret < 0) {
+ dev_err(&pdev->dev, "failed to add PWM chip: %d\n", ret);
+ return ret;
+ }
+
+ for (i = 0; i < npwm; i++) {
+ struct gpio_desc *gpiod;
+ struct gpio_pwm_data *gpio_data;
+
+ gpiod = devm_gpiod_get_index(&pdev->dev, "pwm", i,
+ GPIOD_OUT_LOW);
+ if (IS_ERR(gpiod)) {
+ int error;
+
+ error = PTR_ERR(gpiod);
+ if (error != -EPROBE_DEFER)
+ dev_err(&pdev->dev,
+ "failed to get gpio flags, error: %d\n",
+ error);
+ return error;
+ }
+
+ gpio_data = devm_kzalloc(&pdev->dev, sizeof(*gpio_data),
+ GFP_KERNEL);
+
+ hrtimer_init(&gpio_data->timer,
+ CLOCK_MONOTONIC, HRTIMER_MODE_REL);
+ gpio_data->timer.function = &gpio_pwm_timer;
+ gpio_data->gpiod = gpiod;
+ gpio_data->pin_on = false;
+ gpio_data->run = false;
+
+ if (hrtimer_is_hres_active(&gpio_data->timer))
+ hrtimer++;
+
+ pwm_set_chip_data(&gpio_chip->chip.pwms[i], gpio_data);
+ }
+ if (!hrtimer) {
+ dev_warn(&pdev->dev, "unable to use High-Resolution timer,");
+ dev_warn(&pdev->dev, "%s is restricted to low resolution.",
+ DRV_NAME);
+ }
+
+ platform_set_drvdata(pdev, gpio_chip);
+
+ dev_info(&pdev->dev, "%d gpio pwms loaded\n", npwm);
+
+ return 0;
+}
+
+static int gpio_pwm_remove(struct platform_device *pdev)
+{
+ struct gpio_pwm_chip *gpio_chip;
+ int i;
+
+ gpio_chip = platform_get_drvdata(pdev);
+ for (i = 0; i < gpio_chip->chip.npwm; i++) {
+ struct gpio_pwm_data *gpio_data;
+
+ gpio_data = pwm_get_chip_data(&gpio_chip->chip.pwms[i]);
+
+ hrtimer_cancel(&gpio_data->timer);
+ }
+
+ return pwmchip_remove(&gpio_chip->chip);
+}
+
+static const struct of_device_id gpio_pwm_of_match[] = {
+ { .compatible = DRV_NAME, },
+ {/* sentinel */},
+};
+MODULE_DEVICE_TABLE(of, gpio_pwm_of_match);
+
+static struct platform_driver gpio_pwm_driver = {
+ .probe = gpio_pwm_probe,
+ .remove = gpio_pwm_remove,
+ .driver = {
+ .name = DRV_NAME,
+ .of_match_table = of_match_ptr(gpio_pwm_of_match),
+ },
+};
+module_platform_driver(gpio_pwm_driver);
+
+MODULE_AUTHOR("Olliver Schinagl <oliver@schinagl.nl>");
+MODULE_DESCRIPTION("Generic GPIO bit-banged PWM driver");
+MODULE_LICENSE("GPL");
--
2.25.1

View file

@ -0,0 +1,50 @@
From 7c58b59ddefcfdc18dad2f938c2699c9113f969d Mon Sep 17 00:00:00 2001
From: Dongjin Kim <tobetter@gmail.com>
Date: Wed, 29 Jul 2020 04:05:03 +0900
Subject: [PATCH 32/74] ODROID-N2: drm/meson: Add YUV422 output support
This patch is to support YUV422 output from the Amlogic Meson SoC
VPU to the HDMI controller.
Change-Id: I03952f0592c7341585e518c3038877926a694329
Signed-off-by: Dongjin Kim <tobetter@gmail.com>
---
drivers/gpu/drm/meson/meson_dw_hdmi.c | 8 +++++++-
1 file changed, 7 insertions(+), 1 deletion(-)
diff --git a/drivers/gpu/drm/meson/meson_dw_hdmi.c b/drivers/gpu/drm/meson/meson_dw_hdmi.c
index 24a12c453095..23a78996849c 100644
--- a/drivers/gpu/drm/meson/meson_dw_hdmi.c
+++ b/drivers/gpu/drm/meson/meson_dw_hdmi.c
@@ -702,6 +702,7 @@ dw_hdmi_mode_valid(struct drm_connector *connector,
static const u32 meson_dw_hdmi_out_bus_fmts[] = {
MEDIA_BUS_FMT_YUV8_1X24,
+ MEDIA_BUS_FMT_UYVY8_1X16,
MEDIA_BUS_FMT_UYYVYY8_0_5X24,
};
@@ -801,7 +802,8 @@ static void meson_venc_hdmi_encoder_mode_set(struct drm_bridge *bridge,
if (dw_hdmi->output_bus_fmt == MEDIA_BUS_FMT_UYYVYY8_0_5X24) {
ycrcb_map = VPU_HDMI_OUTPUT_CRYCB;
yuv420_mode = true;
- }
+ } else if (dw_hdmi->output_bus_fmt == MEDIA_BUS_FMT_UYVY8_1X16)
+ ycrcb_map = VPU_HDMI_OUTPUT_CRYCB;
/* VENC + VENC-DVI Mode setup */
meson_venc_hdmi_mode_set(priv, vic, ycrcb_map, yuv420_mode, mode);
@@ -813,6 +815,10 @@ static void meson_venc_hdmi_encoder_mode_set(struct drm_bridge *bridge,
/* Setup YUV420 to HDMI-TX, no 10bit diphering */
writel_relaxed(2 | (2 << 2),
priv->io_base + _REG(VPU_HDMI_FMT_CTRL));
+ else if (dw_hdmi->output_bus_fmt == MEDIA_BUS_FMT_UYVY8_1X16)
+ /* Setup YUV422 to HDMI-TX, no 10bit diphering */
+ writel_relaxed(1 | (2 << 2),
+ priv->io_base + _REG(VPU_HDMI_FMT_CTRL));
else
/* Setup YUV444 to HDMI-TX, no 10bit diphering */
writel_relaxed(0, priv->io_base + _REG(VPU_HDMI_FMT_CTRL));
--
2.25.1

View file

@ -0,0 +1,88 @@
From 2cf6db15ecd5d1d96158c5bba5543ba38f8387f7 Mon Sep 17 00:00:00 2001
From: Igor Pecovnik <igor.pecovnik@gmail.com>
Date: Tue, 4 Aug 2020 23:20:03 +0200
Subject: [PATCH] Add fan support to Odroid N2/plus
Signed-off-by: Igor Pecovnik <igor.pecovnik@gmail.com>
---
.../boot/dts/amlogic/meson-g12b-odroid-n2.dts | 36 +++++++++++++++++++
1 file changed, 36 insertions(+)
diff --git a/arch/arm64/boot/dts/amlogic/meson-g12b-odroid-n2.dts b/arch/arm64/boot/dts/amlogic/meson-g12b-odroid-n2.dts
index 65df5fb49..50bfb0dce 100644
--- a/arch/arm64/boot/dts/amlogic/meson-g12b-odroid-n2.dts
+++ b/arch/arm64/boot/dts/amlogic/meson-g12b-odroid-n2.dts
@@ -2,6 +2,7 @@
/*
* Copyright (c) 2019 BayLibre, SAS
* Author: Neil Armstrong <narmstrong@baylibre.com>
+ * Changed: Igor Pecovnik <igor@armbian.com>
*/
/dts-v1/;
@@ -10,6 +11,7 @@
#include <dt-bindings/input/input.h>
#include <dt-bindings/gpio/meson-g12a-gpio.h>
#include <dt-bindings/sound/meson-g12a-tohdmitx.h>
+#include <dt-bindings/pwm/pwm.h>
/ {
compatible = "hardkernel,odroid-n2", "amlogic,s922x", "amlogic,g12b";
@@ -27,6 +29,22 @@ chosen {
stdout-path = "serial0:115200n8";
};
+ pwmgpio:pwmgpio {
+ compatible = "pwm-gpio";
+ #pwm-cells = <3>;
+ pwm-gpios = <&gpio_ao GPIOAO_10 GPIO_ACTIVE_HIGH>;
+ status = "okay";
+ };
+
+ pwmfan:pwm-fan {
+ compatible = "pwm-fan";
+ pwms = <&pwmgpio 0 40000 PWM_POLARITY_INVERTED>;
+ cooling-min-state = <0>;
+ cooling-max-state = <3>;
+ #cooling-cells = <2>;
+ cooling-levels = <0 120 170 220>;
+ };
+
memory@0 {
device_type = "memory";
reg = <0x0 0x0 0x0 0x40000000>;
@@ -342,6 +360,16 @@ cpu_passive: cpu-passive {
hysteresis = <2000>; /* millicelsius */
type = "passive";
};
+ fan_0: trip-point@0 {
+ temperature = <65000>;
+ hysteresis = <5000>;
+ type = "active";
+ };
+ fan_1: trip-point@1 {
+ temperature = <75000>;
+ hysteresis = <5000>;
+ type = "active";
+ };
};
cooling-maps {
cpufreq_map0 {
@@ -356,6 +384,14 @@ cpufreq_map1 {
<&cpu102 THERMAL_NO_LIMIT THERMAL_NO_LIMIT>,
<&cpu103 THERMAL_NO_LIMIT THERMAL_NO_LIMIT>;
};
+ fan_cooling_map0 {
+ trip = <&fan_0>;
+ cooling-device = <&pwmfan THERMAL_NO_LIMIT 2>;
+ };
+ fan_cooling_map1 {
+ trip = <&fan_1>;
+ cooling-device = <&pwmfan 2 THERMAL_NO_LIMIT>;
+ };
};
};
--
Created with Armbian build tools https://github.com/armbian/build

View file

@ -0,0 +1,94 @@
From 8a928056900e2d1172f174c54965744755654612 Mon Sep 17 00:00:00 2001
From: popcornmix
Date: Tue, 18 Feb 2014 01:43:50 -0300
Subject: [PATCH 1/2] net/smsc95xx: Allow mac address to be set as a parameter
---
drivers/net/usb/smsc95xx.c | 56 ++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 56 insertions(+)
diff --git a/drivers/net/usb/smsc95xx.c b/drivers/net/usb/smsc95xx.c
index 309b88acd3d0..7bc9feb891a1 100644
--- a/drivers/net/usb/smsc95xx.c
+++ b/drivers/net/usb/smsc95xx.c
@@ -60,6 +60,7 @@
#define SUSPEND_SUSPEND3 (0x08)
#define SUSPEND_ALLMODES (SUSPEND_SUSPEND0 | SUSPEND_SUSPEND1 | \
SUSPEND_SUSPEND2 | SUSPEND_SUSPEND3)
+#define MAC_ADDR_LEN (6)
#define CARRIER_CHECK_DELAY (2 * HZ)
@@ -82,6 +83,10 @@ static bool turbo_mode = true;
module_param(turbo_mode, bool, 0644);
MODULE_PARM_DESC(turbo_mode, "Enable multiple frames per Rx transaction");
+static char *macaddr = ":";
+module_param(macaddr, charp, 0);
+MODULE_PARM_DESC(macaddr, "MAC address");
+
static int __must_check __smsc95xx_read_reg(struct usbnet *dev, u32 index,
u32 *data, int in_pm)
{
@@ -910,8 +915,59 @@ static int smsc95xx_ioctl(struct net_device *netdev, struct ifreq *rq, int cmd)
return generic_mii_ioctl(&dev->mii, if_mii(rq), cmd, NULL);
}
+/* Check the macaddr module parameter for a MAC address */
+static int smsc95xx_is_macaddr_param(struct usbnet *dev, u8 *dev_mac)
+{
+ int i, j, got_num, num;
+ u8 mtbl[MAC_ADDR_LEN];
+
+ if (macaddr[0] == ':')
+ return 0;
+
+ i = 0;
+ j = 0;
+ num = 0;
+ got_num = 0;
+ while (j < MAC_ADDR_LEN) {
+ if (macaddr[i] && macaddr[i] != ':') {
+ got_num++;
+ if ('0' <= macaddr[i] && macaddr[i] <= '9')
+ num = num * 16 + macaddr[i] - '0';
+ else if ('A' <= macaddr[i] && macaddr[i] <= 'F')
+ num = num * 16 + 10 + macaddr[i] - 'A';
+ else if ('a' <= macaddr[i] && macaddr[i] <= 'f')
+ num = num * 16 + 10 + macaddr[i] - 'a';
+ else
+ break;
+ i++;
+ } else if (got_num == 2) {
+ mtbl[j++] = (u8) num;
+ num = 0;
+ got_num = 0;
+ i++;
+ } else {
+ break;
+ }
+ }
+
+ if (j == MAC_ADDR_LEN) {
+ netif_dbg(dev, ifup, dev->net, "Overriding MAC address with: "
+ "%02x:%02x:%02x:%02x:%02x:%02x\n", mtbl[0], mtbl[1], mtbl[2],
+ mtbl[3], mtbl[4], mtbl[5]);
+ for (i = 0; i < MAC_ADDR_LEN; i++)
+ dev_mac[i] = mtbl[i];
+ return 1;
+ } else {
+ return 0;
+ }
+}
+
static void smsc95xx_init_mac_address(struct usbnet *dev)
{
+ /* Check module parameters */
+ if (smsc95xx_is_macaddr_param(dev, dev->net->dev_addr))
+ return;
+
const u8 *mac_addr;
/* maybe the boot loader passed the MAC address in devicetree */
--
2.15.0

View file

@ -0,0 +1,17 @@
diff --git a/drivers/spi/spidev.c b/drivers/spi/spidev.c
index b0c76e262..f8f91353f 100644
--- a/drivers/spi/spidev.c
+++ b/drivers/spi/spidev.c
@@ -725,9 +725,9 @@ static int spidev_probe(struct spi_device *spi)
* compatible string, it is a Linux implementation thing
* rather than a description of the hardware.
*/
- WARN(spi->dev.of_node &&
- of_device_is_compatible(spi->dev.of_node, "spidev"),
- "%pOF: buggy DT: spidev listed directly in DT\n", spi->dev.of_node);
+ if (spi->dev.of_node && !of_match_device(spidev_dt_ids, &spi->dev)) {
+ dev_info(&spi->dev, "probing from DT");
+ }
spidev_probe_acpi(spi);

View file

@ -0,0 +1,372 @@
diff --git a/drivers/net/wireless/rtl8189es/include/rtw_security.h b/drivers/net/wireless/rtl8189es/include/rtw_security.h
index 5820a55..3e8e428 100644
--- a/drivers/net/wireless/rtl8189es/include/rtw_security.h
+++ b/drivers/net/wireless/rtl8189es/include/rtw_security.h
@@ -238,7 +238,7 @@ struct security_priv
#endif /* DBG_SW_SEC_CNT */
};
-struct sha256_state {
+struct rtl_sha256_state {
u64 length;
u32 state[8], curlen;
u8 buf[64];
diff --git a/drivers/net/wireless/rtl8189es/core/rtw_security.c b/drivers/net/wireless/rtl8189es/core/rtw_security.c
index 8dac771..9b3a1f9 100644
--- a/drivers/net/wireless/rtl8189es/core/rtw_security.c
+++ b/drivers/net/wireless/rtl8189es/core/rtw_security.c
@@ -2281,7 +2281,7 @@ BIP_exit:
#ifndef PLATFORM_FREEBSD
/* compress 512-bits */
-static int sha256_compress(struct sha256_state *md, unsigned char *buf)
+static int sha256_compress(struct rtl_sha256_state *md, unsigned char *buf)
{
u32 S[8], W[64], t0, t1;
u32 t;
@@ -2323,7 +2323,7 @@ static int sha256_compress(struct sha256_state *md, unsigned char *buf)
}
/* Initialize the hash state */
-static void sha256_init(struct sha256_state *md)
+static void sha256_init(struct rtl_sha256_state *md)
{
md->curlen = 0;
md->length = 0;
@@ -2344,7 +2344,7 @@ static void sha256_init(struct sha256_state *md)
@param inlen The length of the data (octets)
@return CRYPT_OK if successful
*/
-static int sha256_process(struct sha256_state *md, unsigned char *in,
+static int sha256_process(struct rtl_sha256_state *md, unsigned char *in,
unsigned long inlen)
{
unsigned long n;
@@ -2385,7 +2385,7 @@ static int sha256_process(struct sha256_state *md, unsigned char *in,
@param out [out] The destination of the hash (32 bytes)
@return CRYPT_OK if successful
*/
-static int sha256_done(struct sha256_state *md, unsigned char *out)
+static int sha256_done(struct rtl_sha256_state *md, unsigned char *out)
{
int i;
@@ -2437,7 +2437,7 @@ static int sha256_done(struct sha256_state *md, unsigned char *out)
static int sha256_vector(size_t num_elem, u8 *addr[], size_t *len,
u8 *mac)
{
- struct sha256_state ctx;
+ struct rtl_sha256_state ctx;
size_t i;
sha256_init(&ctx);
diff --git a/drivers/net/wireless/rtl8189fs/include/rtw_security.h b/drivers/net/wireless/rtl8189fs/include/rtw_security.h
index 5820a55..3e8e428 100644
--- a/drivers/net/wireless/rtl8189fs/include/rtw_security.h
+++ b/drivers/net/wireless/rtl8189fs/include/rtw_security.h
@@ -238,7 +238,7 @@ struct security_priv
#endif /* DBG_SW_SEC_CNT */
};
-struct sha256_state {
+struct rtl_sha256_state {
u64 length;
u32 state[8], curlen;
u8 buf[64];
diff --git a/drivers/net/wireless/rtl8189fs/core/rtw_security.c b/drivers/net/wireless/rtl8189fs/core/rtw_security.c
index 8dac771..9b3a1f9 100644
--- a/drivers/net/wireless/rtl8189fs/core/rtw_security.c
+++ b/drivers/net/wireless/rtl8189fs/core/rtw_security.c
@@ -2281,7 +2281,7 @@ BIP_exit:
#ifndef PLATFORM_FREEBSD
/* compress 512-bits */
-static int sha256_compress(struct sha256_state *md, unsigned char *buf)
+static int sha256_compress(struct rtl_sha256_state *md, unsigned char *buf)
{
u32 S[8], W[64], t0, t1;
u32 t;
@@ -2323,7 +2323,7 @@ static int sha256_compress(struct sha256_state *md, unsigned char *buf)
}
/* Initialize the hash state */
-static void sha256_init(struct sha256_state *md)
+static void sha256_init(struct rtl_sha256_state *md)
{
md->curlen = 0;
md->length = 0;
@@ -2344,7 +2344,7 @@ static void sha256_init(struct sha256_state *md)
@param inlen The length of the data (octets)
@return CRYPT_OK if successful
*/
-static int sha256_process(struct sha256_state *md, unsigned char *in,
+static int sha256_process(struct rtl_sha256_state *md, unsigned char *in,
unsigned long inlen)
{
unsigned long n;
@@ -2385,7 +2385,7 @@ static int sha256_process(struct sha256_state *md, unsigned char *in,
@param out [out] The destination of the hash (32 bytes)
@return CRYPT_OK if successful
*/
-static int sha256_done(struct sha256_state *md, unsigned char *out)
+static int sha256_done(struct rtl_sha256_state *md, unsigned char *out)
{
int i;
@@ -2437,7 +2437,7 @@ static int sha256_done(struct sha256_state *md, unsigned char *out)
static int sha256_vector(size_t num_elem, u8 *addr[], size_t *len,
u8 *mac)
{
- struct sha256_state ctx;
+ struct rtl_sha256_state ctx;
size_t i;
sha256_init(&ctx);
diff --git a/drivers/net/wireless/rtl8811cu/include/rtw_security.h b/drivers/net/wireless/rtl8811cu/include/rtw_security.h
index ac8432e..5f74fb7 100755
--- a/drivers/net/wireless/rtl8811cu/include/rtw_security.h
+++ b/drivers/net/wireless/rtl8811cu/include/rtw_security.h
@@ -249,7 +249,7 @@ struct security_priv {
#define SEC_IS_BIP_KEY_INSTALLED(sec) _FALSE
#endif
-struct sha256_state {
+struct rtl_sha256_state {
u64 length;
u32 state[8], curlen;
u8 buf[64];
diff --git a/drivers/net/wireless/rtl8811cu/core/rtw_security.c b/drivers/net/wireless/rtl8811cu/core/rtw_security.c
index b537a26..f8c42f4 100755
--- a/drivers/net/wireless/rtl8811cu/core/rtw_security.c
+++ b/drivers/net/wireless/rtl8811cu/core/rtw_security.c
@@ -2133,7 +2133,7 @@ BIP_exit:
#ifndef PLATFORM_FREEBSD
#if defined(CONFIG_TDLS)
/* compress 512-bits */
-static int sha256_compress(struct sha256_state *md, unsigned char *buf)
+static int sha256_compress(struct rtl_sha256_state *md, unsigned char *buf)
{
u32 S[8], W[64], t0, t1;
u32 t;
@@ -2181,7 +2181,7 @@ static int sha256_compress(struct sha256_state *md, unsigned char *buf)
}
/* Initialize the hash state */
-static void sha256_init(struct sha256_state *md)
+static void sha256_init(struct rtl_sha256_state *md)
{
md->curlen = 0;
md->length = 0;
@@ -2202,7 +2202,7 @@ static void sha256_init(struct sha256_state *md)
@param inlen The length of the data (octets)
@return CRYPT_OK if successful
*/
-static int sha256_process(struct sha256_state *md, unsigned char *in,
+static int sha256_process(struct rtl_sha256_state *md, unsigned char *in,
unsigned long inlen)
{
unsigned long n;
@@ -2243,7 +2243,7 @@ static int sha256_process(struct sha256_state *md, unsigned char *in,
@param out [out] The destination of the hash (32 bytes)
@return CRYPT_OK if successful
*/
-static int sha256_done(struct sha256_state *md, unsigned char *out)
+static int sha256_done(struct rtl_sha256_state *md, unsigned char *out)
{
int i;
@@ -2293,7 +2293,7 @@ static int sha256_done(struct sha256_state *md, unsigned char *out)
static int sha256_vector(size_t num_elem, u8 *addr[], size_t *len,
u8 *mac)
{
- struct sha256_state ctx;
+ struct rtl_sha256_state ctx;
size_t i;
sha256_init(&ctx);
diff --git a/drivers/net/wireless/rtl8188eu/include/rtw_security.h b/drivers/net/wireless/rtl8188eu/include/rtw_security.h
index 0adc700..2a9cf9d 100644
--- a/drivers/net/wireless/rtl8188eu/include/rtw_security.h
+++ b/drivers/net/wireless/rtl8188eu/include/rtw_security.h
@@ -249,7 +249,7 @@ struct security_priv {
#define SEC_IS_BIP_KEY_INSTALLED(sec) _FALSE
#endif
-struct sha256_state {
+struct rtl_sha256_state {
u64 length;
u32 state[8], curlen;
u8 buf[64];
diff --git a/drivers/net/wireless/rtl8188eu/core/rtw_security.c b/drivers/net/wireless/rtl8188eu/core/rtw_security.c
index 5807521..0b3eed2 100644
--- a/drivers/net/wireless/rtl8188eu/core/rtw_security.c
+++ b/drivers/net/wireless/rtl8188eu/core/rtw_security.c
@@ -2133,7 +2133,7 @@ BIP_exit:
#ifndef PLATFORM_FREEBSD
#if defined(CONFIG_TDLS)
/* compress 512-bits */
-static int sha256_compress(struct sha256_state *md, unsigned char *buf)
+static int sha256_compress(struct rtl_sha256_state *md, unsigned char *buf)
{
u32 S[8], W[64], t0, t1;
u32 t;
@@ -2181,7 +2181,7 @@ static int sha256_compress(struct sha256_state *md, unsigned char *buf)
}
/* Initialize the hash state */
-static void sha256_init(struct sha256_state *md)
+static void sha256_init(struct rtl_sha256_state *md)
{
md->curlen = 0;
md->length = 0;
@@ -2202,7 +2202,7 @@ static void sha256_init(struct sha256_state *md)
@param inlen The length of the data (octets)
@return CRYPT_OK if successful
*/
-static int sha256_process(struct sha256_state *md, unsigned char *in,
+static int sha256_process(struct rtl_sha256_state *md, unsigned char *in,
unsigned long inlen)
{
unsigned long n;
@@ -2243,7 +2243,7 @@ static int sha256_process(struct sha256_state *md, unsigned char *in,
@param out [out] The destination of the hash (32 bytes)
@return CRYPT_OK if successful
*/
-static int sha256_done(struct sha256_state *md, unsigned char *out)
+static int sha256_done(struct rtl_sha256_state *md, unsigned char *out)
{
int i;
@@ -2293,7 +2293,7 @@ static int sha256_done(struct sha256_state *md, unsigned char *out)
static int sha256_vector(size_t num_elem, u8 *addr[], size_t *len,
u8 *mac)
{
- struct sha256_state ctx;
+ struct rtl_sha256_state ctx;
size_t i;
sha256_init(&ctx);
diff --git a/drivers/net/wireless/rtl88x2bu/include/rtw_security.h b/drivers/net/wireless/rtl88x2bu/include/rtw_security.h
index ac8432e..5f74fb7 100644
--- a/drivers/net/wireless/rtl88x2bu/include/rtw_security.h
+++ b/drivers/net/wireless/rtl88x2bu/include/rtw_security.h
@@ -249,7 +249,7 @@ struct security_priv {
#define SEC_IS_BIP_KEY_INSTALLED(sec) _FALSE
#endif
-struct sha256_state {
+struct rtl_sha256_state {
u64 length;
u32 state[8], curlen;
u8 buf[64];
diff --git a/drivers/net/wireless/rtl88x2bu/core/rtw_security.c b/drivers/net/wireless/rtl88x2bu/core/rtw_security.c
index b537a26..f8c42f4 100644
--- a/drivers/net/wireless/rtl88x2bu/core/rtw_security.c
+++ b/drivers/net/wireless/rtl88x2bu/core/rtw_security.c
@@ -2133,7 +2133,7 @@ BIP_exit:
#ifndef PLATFORM_FREEBSD
#if defined(CONFIG_TDLS)
/* compress 512-bits */
-static int sha256_compress(struct sha256_state *md, unsigned char *buf)
+static int sha256_compress(struct rtl_sha256_state *md, unsigned char *buf)
{
u32 S[8], W[64], t0, t1;
u32 t;
@@ -2181,7 +2181,7 @@ static int sha256_compress(struct sha256_state *md, unsigned char *buf)
}
/* Initialize the hash state */
-static void sha256_init(struct sha256_state *md)
+static void sha256_init(struct rtl_sha256_state *md)
{
md->curlen = 0;
md->length = 0;
@@ -2202,7 +2202,7 @@ static void sha256_init(struct sha256_state *md)
@param inlen The length of the data (octets)
@return CRYPT_OK if successful
*/
-static int sha256_process(struct sha256_state *md, unsigned char *in,
+static int sha256_process(struct rtl_sha256_state *md, unsigned char *in,
unsigned long inlen)
{
unsigned long n;
@@ -2243,7 +2243,7 @@ static int sha256_process(struct sha256_state *md, unsigned char *in,
@param out [out] The destination of the hash (32 bytes)
@return CRYPT_OK if successful
*/
-static int sha256_done(struct sha256_state *md, unsigned char *out)
+static int sha256_done(struct rtl_sha256_state *md, unsigned char *out)
{
int i;
@@ -2293,7 +2293,7 @@ static int sha256_done(struct sha256_state *md, unsigned char *out)
static int sha256_vector(size_t num_elem, u8 *addr[], size_t *len,
u8 *mac)
{
- struct sha256_state ctx;
+ struct rtl_sha256_state ctx;
size_t i;
sha256_init(&ctx);
diff --git a/drivers/net/wireless/rtl8723ds/include/rtw_security.h b/drivers/net/wireless/rtl8723ds/include/rtw_security.h
index 83c06a5..bcea21a 100644
--- a/drivers/net/wireless/rtl8723ds/include/rtw_security.h
+++ b/drivers/net/wireless/rtl8723ds/include/rtw_security.h
@@ -242,7 +242,7 @@ struct security_priv {
#endif /* DBG_SW_SEC_CNT */
};
-struct sha256_state {
+struct rtl_sha256_state {
u64 length;
u32 state[8], curlen;
u8 buf[64];
diff --git a/drivers/net/wireless/rtl8723ds/core/rtw_security.c b/drivers/net/wireless/rtl8723ds/core/rtw_security.c
index 88033df..11aa9a4 100644
--- a/drivers/net/wireless/rtl8723ds/core/rtw_security.c
+++ b/drivers/net/wireless/rtl8723ds/core/rtw_security.c
@@ -2132,7 +2132,7 @@ BIP_exit:
#endif /* CONFIG_IEEE80211W */
/* compress 512-bits */
-static int sha256_compress(struct sha256_state *md, unsigned char *buf)
+static int sha256_compress(struct rtl_sha256_state *md, unsigned char *buf)
{
u32 S[8], W[64], t0, t1;
u32 t;
@@ -2180,7 +2180,7 @@ static int sha256_compress(struct sha256_state *md, unsigned char *buf)
}
/* Initialize the hash state */
-static void sha256_init(struct sha256_state *md)
+static void sha256_init(struct rtl_sha256_state *md)
{
md->curlen = 0;
md->length = 0;
@@ -2201,7 +2201,7 @@ static void sha256_init(struct sha256_state *md)
@param inlen The length of the data (octets)
@return CRYPT_OK if successful
*/
-static int sha256_process(struct sha256_state *md, unsigned char *in,
+static int sha256_process(struct rtl_sha256_state *md, unsigned char *in,
unsigned long inlen)
{
unsigned long n;
@@ -2242,7 +2242,7 @@ static int sha256_process(struct sha256_state *md, unsigned char *in,
@param out [out] The destination of the hash (32 bytes)
@return CRYPT_OK if successful
*/
-static int sha256_done(struct sha256_state *md, unsigned char *out)
+static int sha256_done(struct rtl_sha256_state *md, unsigned char *out)
{
int i;
@@ -2292,7 +2292,7 @@ static int sha256_done(struct sha256_state *md, unsigned char *out)
static int sha256_vector(size_t num_elem, u8 *addr[], size_t *len,
u8 *mac)
{
- struct sha256_state ctx;
+ struct rtl_sha256_state ctx;
size_t i;
sha256_init(&ctx);

View file

@ -0,0 +1,354 @@
diff --git a/drivers/net/wireless/rtl8189es/os_dep/linux/ioctl_cfg80211.c b/drivers/net/wireless/rtl8189es/os_dep/linux/ioctl_cfg80211.c
index d77cc17..32cc240 100644
--- a/drivers/net/wireless/rtl8189es/os_dep/linux/ioctl_cfg80211.c
+++ b/drivers/net/wireless/rtl8189es/os_dep/linux/ioctl_cfg80211.c
@@ -5567,6 +5567,33 @@ exit:
return ret;
}
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(5, 8, 0))
+
+static void
+cfg80211_rtw_update_mgmt_frame_registrations(struct wiphy *wiphy,
+ struct wireless_dev *wdev,
+ struct mgmt_frame_regs *upd)
+{
+ struct net_device *ndev = wdev_to_ndev(wdev);
+ struct rtw_wdev_priv *pwdev_priv;
+ _adapter *adapter;
+
+ if (ndev == NULL)
+ return;
+
+ adapter = (_adapter *)rtw_netdev_priv(ndev);
+ pwdev_priv = adapter_wdev_data(adapter);
+
+#ifdef CONFIG_DEBUG_CFG80211
+ RTW_INFO(FUNC_ADPT_FMT" stypes:%x\n", FUNC_ADPT_ARG(adapter),
+ upd->interface_stypes);
+#endif
+
+ /* not implemented, see bellow */
+}
+
+#else
+
static void cfg80211_rtw_mgmt_frame_register(struct wiphy *wiphy,
#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 6, 0))
struct wireless_dev *wdev,
@@ -5611,6 +5638,8 @@ exit:
return;
}
+#endif
+
#if defined(CONFIG_TDLS) && (LINUX_VERSION_CODE >= KERNEL_VERSION(3,2,0))
static int cfg80211_rtw_tdls_mgmt(struct wiphy *wiphy,
struct net_device *ndev,
@@ -6505,7 +6534,11 @@ static struct cfg80211_ops rtw_cfg80211_ops = {
#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,37)) || defined(COMPAT_KERNEL_RELEASE)
.mgmt_tx = cfg80211_rtw_mgmt_tx,
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(5, 8, 0))
+ .update_mgmt_frame_registrations = cfg80211_rtw_update_mgmt_frame_registrations,
+#else
.mgmt_frame_register = cfg80211_rtw_mgmt_frame_register,
+#endif
#elif (LINUX_VERSION_CODE>=KERNEL_VERSION(2,6,34) && LINUX_VERSION_CODE<=KERNEL_VERSION(2,6,35))
.action = cfg80211_rtw_mgmt_tx,
#endif
diff --git a/drivers/net/wireless/rtl8189fs/os_dep/linux/ioctl_cfg80211.c b/drivers/net/wireless/rtl8189fs/os_dep/linux/ioctl_cfg80211.c
index e894e97..e594cdf 100644
--- a/drivers/net/wireless/rtl8189fs/os_dep/linux/ioctl_cfg80211.c
+++ b/drivers/net/wireless/rtl8189fs/os_dep/linux/ioctl_cfg80211.c
@@ -5711,6 +5711,33 @@ exit:
return ret;
}
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(5, 8, 0))
+
+static void
+cfg80211_rtw_update_mgmt_frame_registrations(struct wiphy *wiphy,
+ struct wireless_dev *wdev,
+ struct mgmt_frame_regs *upd)
+{
+ struct net_device *ndev = wdev_to_ndev(wdev);
+ struct rtw_wdev_priv *pwdev_priv;
+ _adapter *adapter;
+
+ if (ndev == NULL)
+ return;
+
+ adapter = (_adapter *)rtw_netdev_priv(ndev);
+ pwdev_priv = adapter_wdev_data(adapter);
+
+#ifdef CONFIG_DEBUG_CFG80211
+ RTW_INFO(FUNC_ADPT_FMT" stypes:%x\n", FUNC_ADPT_ARG(adapter),
+ upd->interface_stypes);
+#endif
+
+ /* not implemented, see bellow */
+}
+
+#else
+
static void cfg80211_rtw_mgmt_frame_register(struct wiphy *wiphy,
#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 6, 0))
struct wireless_dev *wdev,
@@ -5755,6 +5782,8 @@ exit:
return;
}
+#endif
+
#if defined(CONFIG_TDLS) && (LINUX_VERSION_CODE >= KERNEL_VERSION(3,2,0))
static int cfg80211_rtw_tdls_mgmt(struct wiphy *wiphy,
struct net_device *ndev,
@@ -6760,7 +6789,11 @@ static struct cfg80211_ops rtw_cfg80211_ops = {
#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,37)) || defined(COMPAT_KERNEL_RELEASE)
.mgmt_tx = cfg80211_rtw_mgmt_tx,
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(5, 8, 0))
+ .update_mgmt_frame_registrations = cfg80211_rtw_update_mgmt_frame_registrations,
+#else
.mgmt_frame_register = cfg80211_rtw_mgmt_frame_register,
+#endif
#elif (LINUX_VERSION_CODE>=KERNEL_VERSION(2,6,34) && LINUX_VERSION_CODE<=KERNEL_VERSION(2,6,35))
.action = cfg80211_rtw_mgmt_tx,
#endif
diff --git a/drivers/net/wireless/rtl8811cu/os_dep/linux/ioctl_cfg80211.c b/drivers/net/wireless/rtl8811cu/os_dep/linux/ioctl_cfg80211.c
index c0df148..9bff924 100755
--- a/drivers/net/wireless/rtl8811cu/os_dep/linux/ioctl_cfg80211.c
+++ b/drivers/net/wireless/rtl8811cu/os_dep/linux/ioctl_cfg80211.c
@@ -7143,6 +7143,33 @@ exit:
return ret;
}
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(5, 8, 0))
+
+static void
+cfg80211_rtw_update_mgmt_frame_registrations(struct wiphy *wiphy,
+ struct wireless_dev *wdev,
+ struct mgmt_frame_regs *upd)
+{
+ struct net_device *ndev = wdev_to_ndev(wdev);
+ struct rtw_wdev_priv *pwdev_priv;
+ _adapter *adapter;
+
+ if (ndev == NULL)
+ return;
+
+ adapter = (_adapter *)rtw_netdev_priv(ndev);
+ pwdev_priv = adapter_wdev_data(adapter);
+
+#ifdef CONFIG_DEBUG_CFG80211
+ RTW_INFO(FUNC_ADPT_FMT" stypes:%x\n", FUNC_ADPT_ARG(adapter),
+ upd->interface_stypes);
+#endif
+
+ /* not implemented, see bellow */
+}
+
+#else
+
static void cfg80211_rtw_mgmt_frame_register(struct wiphy *wiphy,
#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 6, 0))
struct wireless_dev *wdev,
@@ -7187,6 +7214,8 @@ exit:
return;
}
+#endif
+
#if defined(CONFIG_TDLS) && (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 2, 0))
static int cfg80211_rtw_tdls_mgmt(struct wiphy *wiphy,
struct net_device *ndev,
@@ -9457,7 +9486,11 @@ static struct cfg80211_ops rtw_cfg80211_ops = {
#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 37)) || defined(COMPAT_KERNEL_RELEASE)
.mgmt_tx = cfg80211_rtw_mgmt_tx,
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(5, 8, 0))
+ .update_mgmt_frame_registrations = cfg80211_rtw_update_mgmt_frame_registrations,
+#else
.mgmt_frame_register = cfg80211_rtw_mgmt_frame_register,
+#endif
#elif (LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 34) && LINUX_VERSION_CODE <= KERNEL_VERSION(2, 6, 35))
.action = cfg80211_rtw_mgmt_tx,
#endif
diff --git a/drivers/net/wireless/rtl8188eu/os_dep/linux/ioctl_cfg80211.c b/drivers/net/wireless/rtl8188eu/os_dep/linux/ioctl_cfg80211.c
index 721723e..62fd530 100644
--- a/drivers/net/wireless/rtl8188eu/os_dep/linux/ioctl_cfg80211.c
+++ b/drivers/net/wireless/rtl8188eu/os_dep/linux/ioctl_cfg80211.c
@@ -7470,6 +7470,33 @@ exit:
return ret;
}
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(5, 8, 0))
+
+static void
+cfg80211_rtw_update_mgmt_frame_registrations(struct wiphy *wiphy,
+ struct wireless_dev *wdev,
+ struct mgmt_frame_regs *upd)
+{
+ struct net_device *ndev = wdev_to_ndev(wdev);
+ struct rtw_wdev_priv *pwdev_priv;
+ _adapter *adapter;
+
+ if (ndev == NULL)
+ return;
+
+ adapter = (_adapter *)rtw_netdev_priv(ndev);
+ pwdev_priv = adapter_wdev_data(adapter);
+
+#ifdef CONFIG_DEBUG_CFG80211
+ RTW_INFO(FUNC_ADPT_FMT" stypes:%x\n", FUNC_ADPT_ARG(adapter),
+ upd->interface_stypes);
+#endif
+
+ /* not implemented, see bellow */
+}
+
+#else
+
static void cfg80211_rtw_mgmt_frame_register(struct wiphy *wiphy,
#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 6, 0))
struct wireless_dev *wdev,
@@ -7525,6 +7552,8 @@ exit:
return;
}
+#endif
+
#if defined(CONFIG_TDLS) && (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 2, 0))
static int cfg80211_rtw_tdls_mgmt(struct wiphy *wiphy,
struct net_device *ndev,
@@ -9903,7 +9932,11 @@ static struct cfg80211_ops rtw_cfg80211_ops = {
#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 37)) || defined(COMPAT_KERNEL_RELEASE)
.mgmt_tx = cfg80211_rtw_mgmt_tx,
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(5, 8, 0))
+ .update_mgmt_frame_registrations = cfg80211_rtw_update_mgmt_frame_registrations,
+#else
.mgmt_frame_register = cfg80211_rtw_mgmt_frame_register,
+#endif
#elif (LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 34) && LINUX_VERSION_CODE <= KERNEL_VERSION(2, 6, 35))
.action = cfg80211_rtw_mgmt_tx,
#endif
diff --git a/drivers/net/wireless/rtl88x2bu/os_dep/linux/ioctl_cfg80211.c b/drivers/net/wireless/rtl88x2bu/os_dep/linux/ioctl_cfg80211.c
index 2fd4e28..b463e55 100755
--- a/drivers/net/wireless/rtl88x2bu/os_dep/linux/ioctl_cfg80211.c
+++ b/drivers/net/wireless/rtl88x2bu/os_dep/linux/ioctl_cfg80211.c
@@ -7325,6 +7325,33 @@ exit:
return ret;
}
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(5, 8, 0))
+
+static void
+cfg80211_rtw_update_mgmt_frame_registrations(struct wiphy *wiphy,
+ struct wireless_dev *wdev,
+ struct mgmt_frame_regs *upd)
+{
+ struct net_device *ndev = wdev_to_ndev(wdev);
+ struct rtw_wdev_priv *pwdev_priv;
+ _adapter *adapter;
+
+ if (ndev == NULL)
+ return;
+
+ adapter = (_adapter *)rtw_netdev_priv(ndev);
+ pwdev_priv = adapter_wdev_data(adapter);
+
+#ifdef CONFIG_DEBUG_CFG80211
+ RTW_INFO(FUNC_ADPT_FMT" stypes:%x\n", FUNC_ADPT_ARG(adapter),
+ upd->interface_stypes);
+#endif
+
+ /* not implemented, see bellow */
+}
+
+#else
+
static void cfg80211_rtw_mgmt_frame_register(struct wiphy *wiphy,
#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 6, 0))
struct wireless_dev *wdev,
@@ -7369,6 +7396,8 @@ exit:
return;
}
+#endif
+
#if defined(CONFIG_TDLS) && (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 2, 0))
static int cfg80211_rtw_tdls_mgmt(struct wiphy *wiphy,
struct net_device *ndev,
@@ -9652,7 +9681,11 @@ static struct cfg80211_ops rtw_cfg80211_ops = {
#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 37)) || defined(COMPAT_KERNEL_RELEASE)
.mgmt_tx = cfg80211_rtw_mgmt_tx,
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(5, 8, 0))
+ .update_mgmt_frame_registrations = cfg80211_rtw_update_mgmt_frame_registrations,
+#else
.mgmt_frame_register = cfg80211_rtw_mgmt_frame_register,
+#endif
#elif (LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 34) && LINUX_VERSION_CODE <= KERNEL_VERSION(2, 6, 35))
.action = cfg80211_rtw_mgmt_tx,
#endif
diff --git a/drivers/net/wireless/rtl8723ds/os_dep/linux/ioctl_cfg80211.c b/drivers/net/wireless/rtl8723ds/os_dep/linux/ioctl_cfg80211.c
index 564c2c5..921a452 100644
--- a/drivers/net/wireless/rtl8723ds/os_dep/linux/ioctl_cfg80211.c
+++ b/drivers/net/wireless/rtl8723ds/os_dep/linux/ioctl_cfg80211.c
@@ -5872,6 +5872,33 @@ exit:
return ret;
}
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(5, 8, 0))
+
+static void
+cfg80211_rtw_update_mgmt_frame_registrations(struct wiphy *wiphy,
+ struct wireless_dev *wdev,
+ struct mgmt_frame_regs *upd)
+{
+ struct net_device *ndev = wdev_to_ndev(wdev);
+ struct rtw_wdev_priv *pwdev_priv;
+ _adapter *adapter;
+
+ if (ndev == NULL)
+ return;
+
+ adapter = (_adapter *)rtw_netdev_priv(ndev);
+ pwdev_priv = adapter_wdev_data(adapter);
+
+#ifdef CONFIG_DEBUG_CFG80211
+ RTW_INFO(FUNC_ADPT_FMT" stypes:%x\n", FUNC_ADPT_ARG(adapter),
+ upd->interface_stypes);
+#endif
+
+ /* not implemented, see bellow */
+}
+
+#else
+
static void cfg80211_rtw_mgmt_frame_register(struct wiphy *wiphy,
#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 6, 0))
struct wireless_dev *wdev,
@@ -5916,6 +5943,8 @@ exit:
return;
}
+#endif
+
#if defined(CONFIG_TDLS) && (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 2, 0))
static int cfg80211_rtw_tdls_mgmt(struct wiphy *wiphy,
struct net_device *ndev,
@@ -6866,7 +6895,11 @@ static struct cfg80211_ops rtw_cfg80211_ops = {
#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 37)) || defined(COMPAT_KERNEL_RELEASE)
.mgmt_tx = cfg80211_rtw_mgmt_tx,
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(5, 8, 0))
+ .update_mgmt_frame_registrations = cfg80211_rtw_update_mgmt_frame_registrations,
+#else
.mgmt_frame_register = cfg80211_rtw_mgmt_frame_register,
+#endif
#elif (LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 34) && LINUX_VERSION_CODE <= KERNEL_VERSION(2, 6, 35))
.action = cfg80211_rtw_mgmt_tx,
#endif

View file

@ -0,0 +1,28 @@
From 2e01cc074cc426da4b390af025a736eda9aef80c Mon Sep 17 00:00:00 2001
From: Koumes <koumes@centrum.cz>
Date: Sat, 1 Jun 2019 21:20:26 +0000
Subject: [PATCH] si2168: fix cmd timeout
Some demuxer si2168 commands may take 130-140 ms.
(DVB-T/T2 tuner MyGica T230C v2).
Details: https://github.com/CoreELEC/CoreELEC/pull/208
---
drivers/media/dvb-frontends/si2168.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/media/dvb-frontends/si2168.c b/drivers/media/dvb-frontends/si2168.c
index b05e6772c..ffaba6f81 100644
--- a/drivers/media/dvb-frontends/si2168.c
+++ b/drivers/media/dvb-frontends/si2168.c
@@ -42,7 +42,7 @@ static int si2168_cmd_execute(struct i2c_client *client, struct si2168_cmd *cmd)
if (cmd->rlen) {
/* wait cmd execution terminate */
- #define TIMEOUT 70
+ #define TIMEOUT 200
timeout = jiffies + msecs_to_jiffies(TIMEOUT);
while (!time_after(jiffies, timeout)) {
ret = i2c_master_recv(client, cmd->args, cmd->rlen);
--
2.17.1