Skip to contentSkip to conversation

meson: add clk and adc support for JetHub D1 (j100)

PATCH In review Vyacheslav Bocharov 2 participants 13 messages Apr 24, 2022 – Apr 25, 2022

Subsystems (4)
lore
Share & tools
lore
#0 lore raw

v3 cover meson: add clk and adc support for JetHub D1 (j100)

Prepare to use ADC channel 1 in JetHub D1 (j100) to check the hardware revision of the board.

- add support for AXG in saradc driver
- add simple clk-ao driver for AXG (base is taken from g12a)
- enable saradc in dts and board config file
- fix typo in the g12a-clk-ao driver name
- move clk->id check to .request function for g12a-clk-ao driver
- remove unnecessary check (gate->reg == 0) in g12a-clk-ao driver
- enable saradc in dts/board config for JetHub D1 (j100)

From v2:
- remove unnecessary check (gate->reg == 0) in axg/g12a clk-ao drivers
- move j100 dts changes to -u-boot.dtsi
From v1:
- move clk-id check to .request function for axg/g12a-ao clk driver

Vyacheslav Bocharov (6):
clk: meson: add minimal driver for axg-ao clocks
clk: meson: fix driver name for g12a-ao clocks
clk: meson: update driver for g12a-ao clocks
adc: meson-saradc: add AXG variant
board: amlogic: jethub j100: enable saradc in dts
board: amlogic: jethub j100: enable saradc in config

 .../meson-axg-jethome-jethub-j100-u-boot.dtsi | 10 +++
 configs/jethub_j100_defconfig                 |  5 ++
 drivers/adc/meson-saradc.c                    |  2 +
 drivers/clk/meson/Makefile                    |  1 +
 drivers/clk/meson/axg-ao.c                    | 86 +++++++++++++++++++
 drivers/clk/meson/g12a-ao.c                   | 17 ++--
 6 files changed, 114 insertions(+), 7 deletions(-)
 create mode 100644 arch/arm/dts/meson-axg-jethome-jethub-j100-u-boot.dtsi
 create mode 100644 drivers/clk/meson/axg-ao.c
Signature · 1 line
2.30.2
#1 lore raw

PATCH v3 1/6 clk: meson: add minimal driver for axg-ao clocks

Add minimal driver AO clocks on meson AXG family. Only ADC related clocks are supported.

---
 drivers/clk/meson/Makefile |  1 +
 drivers/clk/meson/axg-ao.c | 86 ++++++++++++++++++++++++++++++++++++++
 2 files changed, 87 insertions(+)
 create mode 100644 drivers/clk/meson/axg-ao.c
drivers/clk/meson/Makefile +1 -0
index b9c6bd66cf..a486b13e9c 100644
@@ -5,5 +5,6 @@
 
 obj-$(CONFIG_CLK_MESON_GX) += gxbb.o
 obj-$(CONFIG_CLK_MESON_AXG) += axg.o
+obj-$(CONFIG_CLK_MESON_AXG) += axg-ao.o
 obj-$(CONFIG_CLK_MESON_G12A) += g12a.o
 obj-$(CONFIG_CLK_MESON_G12A) += g12a-ao.o
drivers/clk/meson/axg-ao.c new file +86 -0

86 lines not on this page · raw message

Signature · 1 line
2.30.2
#2 lore raw

PATCH v3 2/6 clk: meson: fix driver name for g12a-ao clocks

In reply to Vyacheslav Bocharov

Update the clk-g12a-ao driver from "axg" to "g12a"

---
 drivers/clk/meson/g12a-ao.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/clk/meson/g12a-ao.c +1 -1
index 0148529e04..17b11eb52a 100644
@@ -73,7 +73,7 @@ static const struct udevice_id meson_clk_ids[] = {
 	{ }
 };
 
-U_BOOT_DRIVER(meson_clk_axg) = {
+U_BOOT_DRIVER(meson_clk_g12a_ao) = {
 	.name		= "meson_clk_g12a_ao",
 	.id		= UCLASS_CLK,
 	.of_match	= meson_clk_ids,
Signature · 1 line
2.30.2
#3 lore raw

PATCH v3 3/6 clk: meson: update driver for g12a-ao clocks

In reply to Vyacheslav Bocharov

Update g12a-ao clk driver:
- move clk->id check to .request function
- remove unnecessary check (gate->reg == 0)

---
 drivers/clk/meson/g12a-ao.c | 15 +++++++++------
 1 file changed, 9 insertions(+), 6 deletions(-)
drivers/clk/meson/g12a-ao.c +9 -6
index 17b11eb52a..1a855a6896 100644
@@ -28,14 +28,8 @@ static int meson_set_gate(struct clk *clk, bool on)
 	struct meson_clk *priv = dev_get_priv(clk->dev);
 	struct meson_gate *gate;
 
-	if (clk->id >= ARRAY_SIZE(gates))
-		return -ENOENT;
-
 	gate = &gates[clk->id];
 
-	if (gate->reg == 0)
-		return 0;
-
 	regmap_update_bits(priv->map, gate->reg,
 			   BIT(gate->bit), on ? BIT(gate->bit) : 0);
 
@@ -63,9 +57,18 @@ static int meson_clk_probe(struct udevice *dev)
 	return 0;
 }
 
+static int meson_clk_request(struct clk *clk)
+{
+	if (clk->id >= ARRAY_SIZE(gates))
+		return -ENOENT;
+
+	return 0;
+}
+
 static struct clk_ops meson_clk_ops = {
 	.disable	= meson_clk_disable,
 	.enable		= meson_clk_enable,
+	.request	= meson_clk_request,
 };
 
 static const struct udevice_id meson_clk_ids[] = {
Signature · 1 line
2.30.2
Acked-by on v3 3/6
#4 lore raw

Re: [PATCH v3 3/6] clk: meson: update driver for g12a-ao clocks

Quoted 37 lines · Vyacheslav Bocharov

Update g12a-ao clk driver:
- move clk->id check to .request function
- remove unnecessary check (gate->reg == 0)

---
  drivers/clk/meson/g12a-ao.c | 15 +++++++++------
  1 file changed, 9 insertions(+), 6 deletions(-)
drivers/clk/meson/g12a-ao.c +5 -6
index 17b11eb52a..1a855a6896 100644
@@ -28,14 +28,8 @@ static int meson_set_gate(struct clk *clk, bool on)
  	struct meson_clk *priv = dev_get_priv(clk->dev);
  	struct meson_gate *gate;
 
-	if (clk->id >= ARRAY_SIZE(gates))
-		return -ENOENT;
-
  	gate = &gates[clk->id];
 
-	if (gate->reg == 0)
-		return 0;
-
  	regmap_update_bits(priv->map, gate->reg,
  			   BIT(gate->bit), on ? BIT(gate->bit) : 0);
 
@@ -63,9 +57,18 @@ static int meson_clk_probe(struct udevice *dev)
  	return 0;
  }
 
+static int meson_clk_request(struct clk *clk)
+{
+	if (clk->id >= ARRAY_SIZE(gates))
+		return -ENOENT;
+

drivers/clk/meson/g12a-ao.c static int meson_clk_probe(struct udevice *dev) · line 74

Quoted 10 lines
drivers/clk/meson/g12a-ao.c +4 -0
+	return 0;
+}
+
  static struct clk_ops meson_clk_ops = {
  	.disable	= meson_clk_disable,
  	.enable		= meson_clk_enable,
+	.request	= meson_clk_request,
  };
 
  static const struct udevice_id meson_clk_ids[] = {
#5 lore raw

PATCH v3 4/6 adc: meson-saradc: add AXG variant

In reply to Vyacheslav Bocharov

Add support for the SARADC variant found on the AXG SoCs family.

---
 drivers/adc/meson-saradc.c | 2 ++
 1 file changed, 2 insertions(+)
drivers/adc/meson-saradc.c +2 -0
index 1a45a3a265..37023512f0 100644
@@ -737,6 +737,8 @@ static const struct udevice_id meson_saradc_ids[] = {
 	  .data = (ulong)&gxl_saradc_data },
 	{ .compatible = "amlogic,meson-g12a-saradc",
 	  .data = (ulong)&gxl_saradc_data },
+	{ .compatible = "amlogic,meson-axg-saradc",
+	  .data = (ulong)&gxl_saradc_data },
 	{ }
 };
 
Signature · 1 line
2.30.2
#6 lore raw

PATCH v3 5/6 board: amlogic: jethub j100: enable saradc in dts

In reply to Vyacheslav Bocharov

Prepare to use ADC channel 1 to check the hardware revision of the board:
- add u-boot dts include with saradc node

---
 arch/arm/dts/meson-axg-jethome-jethub-j100-u-boot.dtsi | 10 ++++++++++
 1 file changed, 10 insertions(+)
 create mode 100644 arch/arm/dts/meson-axg-jethome-jethub-j100-u-boot.dtsi
arch/arm/dts/meson-axg-jethome-jethub-j100-u-boot.dtsi new file +10 -0
new file mode 100644
index 0000000000..3ecb233f8e
@@ -0,0 +1,10 @@
+// SPDX-License-Identifier: (GPL-2.0+ OR MIT)
+/*
+ * Copyright (c) 2022 Vyacheslav Bocharov <[email protected]>
+ * Author: Vyacheslav Bocharov <[email protected]>
+ */
+
+&saradc {
+	status = "okay";
+	vref-supply = <&vddio_ao18>;
+};
Signature · 1 line
2.30.2
Reviewed-by on v3 5/6
#7 lore raw

Re: [PATCH v3 5/6] board: amlogic: jethub j100: enable saradc in dts

Quoted 15 lines · Vyacheslav Bocharov

Prepare to use ADC channel 1 to check the hardware revision of the board:
- add u-boot dts include with saradc node

---
  arch/arm/dts/meson-axg-jethome-jethub-j100-u-boot.dtsi | 10 ++++++++++
  1 file changed, 10 insertions(+)

create mode 100644 arch/arm/dts/meson-axg-jethome-jethub-j100-u-boot.dtsi

arch/arm/dts/meson-axg-jethome-jethub-j100-u-boot.dtsi new file +0 -0
new file mode 100644
index 0000000000..3ecb233f8e

arch/arm/dts/meson-axg-jethome-jethub-j100-u-boot.dtsi line 10

Quoted 10 lines
arch/arm/dts/meson-axg-jethome-jethub-j100-u-boot.dtsi new file +10 -0
@@ -0,0 +1,10 @@
+// SPDX-License-Identifier: (GPL-2.0+ OR MIT)
+/*
+ * Copyright (c) 2022 Vyacheslav Bocharov <[email protected]>
+ * Author: Vyacheslav Bocharov <[email protected]>
+ */
+
+&saradc {
+	status = "okay";
+	vref-supply = <&vddio_ao18>;
+};
#8 lore raw

PATCH v3 6/6 board: amlogic: jethub j100: enable saradc in config

In reply to Vyacheslav Bocharov

Enable ADC in board config file

---
 configs/jethub_j100_defconfig | 5 +++++
 1 file changed, 5 insertions(+)
configs/jethub_j100_defconfig +5 -0
index 1c6db9f6a0..a30940bf1c 100644
@@ -17,6 +17,7 @@ CONFIG_REMAKE_ELF=y
 CONFIG_OF_BOARD_SETUP=y
 # CONFIG_DISPLAY_CPUINFO is not set
 CONFIG_MISC_INIT_R=y
+CONFIG_CMD_ADC=y
 # CONFIG_CMD_BDI is not set
 # CONFIG_CMD_IMI is not set
 CONFIG_CMD_EEPROM=y
@@ -34,6 +35,10 @@ CONFIG_OF_CONTROL=y
 CONFIG_SYS_RELOC_GD_ENV_ADDR=y
 CONFIG_DM_I2C=y
 CONFIG_SYS_I2C_MESON=y
+CONFIG_ADC=y
+CONFIG_SARADC_MESON=y
+CONFIG_CLK=y
+CONFIG_CLK_MESON_AXG=y
 CONFIG_MMC_MESON_GX=y
 CONFIG_MTD_UBI=y
 CONFIG_PHY_REALTEK=y
Signature · 1 line
2.30.2
Reviewed-by on v3 6/6
#9 lore raw

Re: [PATCH v3 6/6] board: amlogic: jethub j100: enable saradc in config

Quoted 21 lines · Vyacheslav Bocharov

Enable ADC in board config file

---
  configs/jethub_j100_defconfig | 5 +++++
  1 file changed, 5 insertions(+)
configs/jethub_j100_defconfig +1 -0
index 1c6db9f6a0..a30940bf1c 100644
@@ -17,6 +17,7 @@ CONFIG_REMAKE_ELF=y
  CONFIG_OF_BOARD_SETUP=y
  # CONFIG_DISPLAY_CPUINFO is not set
  CONFIG_MISC_INIT_R=y
+CONFIG_CMD_ADC=y
  # CONFIG_CMD_BDI is not set
  # CONFIG_CMD_IMI is not set
  CONFIG_CMD_EEPROM=y

configs/jethub_j100_defconfig CONFIG_OF_CONTROL=y · line 44

Quoted 10 lines
configs/jethub_j100_defconfig +4 -0
@@ -34,6 +35,10 @@ CONFIG_OF_CONTROL=y
  CONFIG_SYS_RELOC_GD_ENV_ADDR=y
  CONFIG_DM_I2C=y
  CONFIG_SYS_I2C_MESON=y
+CONFIG_ADC=y
+CONFIG_SARADC_MESON=y
+CONFIG_CLK=y
+CONFIG_CLK_MESON_AXG=y
  CONFIG_MMC_MESON_GX=y
  CONFIG_MTD_UBI=y
  CONFIG_PHY_REALTEK=y
#10 lore raw
In reply to Vyacheslav Bocharov

Hi,

Quoted 11 lines · Vyacheslav Bocharov

Prepare to use ADC channel 1 in JetHub D1 (j100) to check the hardware revision of the board.

- add support for AXG in saradc driver
- add simple clk-ao driver for AXG (base is taken from g12a)
- enable saradc in dts and board config file
- fix typo in the g12a-clk-ao driver name
- move clk->id check to .request function for g12a-clk-ao driver
- remove unnecessary check (gate->reg == 0) in g12a-clk-ao driver
- enable saradc in dts/board config for JetHub D1 (j100)

Quoted 1 line

[...]

Thanks, Applied to https://source.denx.de/u-boot/custodians/u-boot-amlogic (u-boot-amlogic-test)

[1/6] clk: meson: add minimal driver for axg-ao clocks

      https://source.denx.de/u-boot/custodians/u-boot-amlogic/-/commit/dcccf730043197464f7bafdb1abcebcb7fd828b0
[2/6] clk: meson: fix driver name for g12a-ao clocks
      https://source.denx.de/u-boot/custodians/u-boot-amlogic/-/commit/4da098656228535539be40f76806ad6657b94407
[3/6] clk: meson: update driver for g12a-ao clocks
      https://source.denx.de/u-boot/custodians/u-boot-amlogic/-/commit/66a657b7c6082fe374c99d5b2a7e0d911091dbe4
[4/6] adc: meson-saradc: add AXG variant
      https://source.denx.de/u-boot/custodians/u-boot-amlogic/-/commit/8a4a73f466c1d2189aa5f8612f2f90ec9a727ea0
[5/6] board: amlogic: jethub j100: enable saradc in dts
      https://source.denx.de/u-boot/custodians/u-boot-amlogic/-/commit/ee8094f69646825d2c30b8bb9082e976f023f710
[6/6] board: amlogic: jethub j100: enable saradc in config
      https://source.denx.de/u-boot/custodians/u-boot-amlogic/-/commit/a718f5524d492fb5708e884cb1db21384f826c00
Signature · 1 line
Neil
author
#11 lore raw
Quoted 14 lines · Neil Armstrong

Hi,

Quoted 11 lines · Vyacheslav Bocharov

Prepare to use ADC channel 1 in JetHub D1 (j100) to check the hardware revision of the board.

- add support for AXG in saradc driver
- add simple clk-ao driver for AXG (base is taken from g12a)
- enable saradc in dts and board config file
- fix typo in the g12a-clk-ao driver name
- move clk->id check to .request function for g12a-clk-ao driver
- remove unnecessary check (gate->reg == 0) in g12a-clk-ao driver
- enable saradc in dts/board config for JetHub D1 (j100)

Quoted 3 lines
Quoted 1 line

[...]

Thanks, Applied to https://source.denx.de/u-boot/custodians/u-boot-amlogic (u-boot-amlogic-test)

Thanks. Let me know if additional testing or rework is needed.

Quoted 14 lines

[1/6] clk: meson: add minimal driver for axg-ao clocks

       https://source.denx.de/u-boot/custodians/u-boot-amlogic/-/commit/dcccf730043197464f7bafdb1abcebcb7fd828b0
[2/6] clk: meson: fix driver name for g12a-ao clocks
       https://source.denx.de/u-boot/custodians/u-boot-amlogic/-/commit/4da098656228535539be40f76806ad6657b94407
[3/6] clk: meson: update driver for g12a-ao clocks
       https://source.denx.de/u-boot/custodians/u-boot-amlogic/-/commit/66a657b7c6082fe374c99d5b2a7e0d911091dbe4
[4/6] adc: meson-saradc: add AXG variant
       https://source.denx.de/u-boot/custodians/u-boot-amlogic/-/commit/8a4a73f466c1d2189aa5f8612f2f90ec9a727ea0
[5/6] board: amlogic: jethub j100: enable saradc in dts
       https://source.denx.de/u-boot/custodians/u-boot-amlogic/-/commit/ee8094f69646825d2c30b8bb9082e976f023f710
[6/6] board: amlogic: jethub j100: enable saradc in config
       https://source.denx.de/u-boot/custodians/u-boot-amlogic/-/commit/a718f5524d492fb5708e884cb1db21384f826c00
#12 lore raw

Hi,

Quoted 15 lines · Vyacheslav
Quoted 14 lines · Neil Armstrong

Hi,

Quoted 11 lines · Vyacheslav Bocharov

Prepare to use ADC channel 1 in JetHub D1 (j100) to check the hardware revision of the board.

- add support for AXG in saradc driver
- add simple clk-ao driver for AXG (base is taken from g12a)
- enable saradc in dts and board config file
- fix typo in the g12a-clk-ao driver name
- move clk->id check to .request function for g12a-clk-ao driver
- remove unnecessary check (gate->reg == 0) in g12a-clk-ao driver
- enable saradc in dts/board config for JetHub D1 (j100)

Quoted 5 lines
Quoted 3 lines
Quoted 1 line

[...]

Thanks, Applied to https://source.denx.de/u-boot/custodians/u-boot-amlogic (u-boot-amlogic-test)

Thanks. Let me know if additional testing or rework is needed.

So far all is ok, CI passed:
https://source.denx.de/u-boot/custodians/u-boot-amlogic/-/pipelines/11853

Can you send a following patch to update the doc and indicate ADC is supported on AXG (and G12A, G12B & SM1 by the way) ?

Thanks,
Neil

Quoted 16 lines
Quoted 15 lines

[1/6] clk: meson: add minimal driver for axg-ao clocks
       https://source.denx.de/u-boot/custodians/u-boot-amlogic/-/commit/dcccf730043197464f7bafdb1abcebcb7fd828b0
[2/6] clk: meson: fix driver name for g12a-ao clocks
       https://source.denx.de/u-boot/custodians/u-boot-amlogic/-/commit/4da098656228535539be40f76806ad6657b94407
[3/6] clk: meson: update driver for g12a-ao clocks
       https://source.denx.de/u-boot/custodians/u-boot-amlogic/-/commit/66a657b7c6082fe374c99d5b2a7e0d911091dbe4
[4/6] adc: meson-saradc: add AXG variant
       https://source.denx.de/u-boot/custodians/u-boot-amlogic/-/commit/8a4a73f466c1d2189aa5f8612f2f90ec9a727ea0
[5/6] board: amlogic: jethub j100: enable saradc in dts
       https://source.denx.de/u-boot/custodians/u-boot-amlogic/-/commit/ee8094f69646825d2c30b8bb9082e976f023f710
[6/6] board: amlogic: jethub j100: enable saradc in config
       https://source.denx.de/u-boot/custodians/u-boot-amlogic/-/commit/a718f5524d492fb5708e884cb1db21384f826c00