arm64: meson: Add s4 support
Subsystems (5)
v2 cover arm64: meson: Add s4 support
This series (along with several patches submitted separately) adds basic support for the amlogic s4 SoCs (S805X2/S905W2/S905Y4). My tree with all patches on it is at [1].
I developed this for a custom board, but I believe a better candidate for a defconfig is the publically-available Khadas VIM1S [2]. Khadas has kindly sent me a VIM1S so I was able to add some more features and fix a few bugs.
Creating a bootable image currently requires modifying AMLogic's FIP [3]. Unfortunately, that software has a proprietary license and I have already reviewed it in order to make the necessary modifications. Therefore, I am wary about submitting patches to [4] (or binman). If anyone would like to do so, I can try writing up a specification for you to implement so we can avoid any copyright issues.
Linux boots but can't read either the eMMC or SD card (mmc0/mmc1):
[ 1.537445] Run /init as init process [ 1.573054] mmc1: new SDHC card at address 0001 [ 1.573722] mmcblk1: mmc1:0001 032GB 29.1 GiB [ 1.578302] mmcblk1: p1 p2 [ 1.594234] mmc0: new HS200 MMC card at address 0001 [ 1.595881] mmcblk0: mmc0:0001 AJTD4R 14.6 GiB [ 1.598333] mmcblk0boot0: mmc0:0001 AJTD4R 4.00 MiB [ 1.600596] mmcblk0boot1: mmc0:0001 AJTD4R 4.00 MiB [ 1.602689] mmcblk0rpmb: mmc0:0001 AJTD4R 4.00 MiB, chardev (239:0) Starting systemd-udevd version 255.21^ [ 1.681013] mmc2: new UHS-I speed SDR104 SDIO card at address 0001 [ 1.758610] usb 1-1: new high-speed USB device number 2 using xhci-hcd [ 1.884396] mmc1: card 0001 removed [ 1.902656] hub 1-1:1.0: USB hub found [ 1.902829] hub 1-1:1.0: 4 ports detected Waiting for /dev/mmcblk0p2 to show up... [ 2.083595] mmc1: new SDHC card at address 0001 [ 2.084253] mmcblk1: mmc1:0001 032GB 29.1 GiB [ 2.086749] mmcblk1: p1 p2 [ 3.102764] mmc1: card 0001 removed [ 3.247600] mmc1: new SDHC card at address 0001 [ 3.248274] mmcblk1: mmc1:0001 032GB 29.1 GiB [ 3.250416] mmcblk1: p1 p2 [ 4.254738] mmc1: card 0001 removed [ 4.399589] mmc1: new SDHC card at address 0001 [ 4.400230] mmcblk1: mmc1:0001 032GB 29.1 GiB [ 4.402721] mmcblk1: p1 p2 [ 5.406737] mmc1: card 0001 removed [ 6.604775] mmc1: new SDHC card at address 0001 [ 6.605518] mmcblk1: mmc1:0001 032GB 29.1 GiB [ 6.607752] mmcblk1: p1 p2 [ 6.774076] mmc1: tried to HW reset card, got error -95 [ 6.774133] mmcblk1: recovery failed! [ 6.774594] I/O error, dev mmcblk1, sector 61066752 op 0x0:(READ) flags 0x80700 phys_seg 5 prio class 2 [ 6.780963] I/O error, dev mmcblk1, sector 61067016 op 0x0:(READ) flags 0x80700 phys_seg 2 prio class 2 [ 6.781018] mmc1: card 0001 removed [ 6.927580] mmc1: new SDHC card at address 0001 [ 6.928252] mmcblk1: mmc1:0001 032GB 29.1 GiB [ 6.930422] mmcblk1: p1 p2 [ 7.934738] mmc1: card 0001 removed [ 8.003206] meson-gx-mmc fe08a000.mmc: card claims to support voltages below defined range [ 8.003576] meson-gx-mmc fe08a000.mmc: no support for card's volts [ 8.004334] mmc1: error -22 whilst initialising SDIO card [ 8.032146] mmc1: error -95 whilst initialising SD card [ 9.163594] mmc1: new SDHC card at address 0001 [ 9.164282] mmcblk1: mmc1:0001 032GB 29.1 GiB [ 9.166825] mmcblk1: p1 p2 [ 9.334084] mmc1: tried to HW reset card, got error -95 [ 9.334140] mmcblk1: recovery failed! [ 9.334605] I/O error, dev mmcblk1, sector 61067016 op 0x0:(READ) flags 0x80700 phys_seg 14 prio class 2 [ 9.340984] I/O error, dev mmcblk1, sector 61067208 op 0x0:(READ) flags 0x80700 phys_seg 5 prio class 2 [ 9.341040] mmc1: card 0001 removed [ 9.491572] mmc1: new SDHC card at address 0001 [ 9.492239] mmcblk1: mmc1:0001 032GB 29.1 GiB [ 9.494407] mmcblk1: p1 p2 [ 10.526746] mmc1: card 0001 removed
Not sure what's going on. Maybe the drive strength needs to be adjusted?
[1] https://github.com/brivolabs/u-boot/tree/meson_s4
[2] https://www.khadas.com/vim1s
[3] https://github.com/khadas/u-boot-fip-yocto
[4] https://github.com/LibreELEC/amlogic-boot-fip
Changes in v2:
- Add S4 to meson board info
- Add DEBUG_UART defaults
- Extend initial padding to 4096 to match what Amlogic does
- Add ADC clocks
- Use our own board instead of reusing q200
- Enable more peripherals (buttons, LEDs, etc.)
- Use defaults where possible (commands, distro boot, etc.)
- Set mac address the same way Khadas does
- Set config/stdout-path so we can find the serial
Sean Anderson (9):
arm64: meson: Add s4 SoC support
clk: meson: a1: Eliminate separate id parameter
clk: meson: a1: Use clk_set_rate from meson_mux_set_rate
clk: meson: Use soc-specific naming for common functions
clk: meson: Export a1 functions to common file
clk: meson: Support fractional fixed-factor clocks
clk: meson: Support power-of-two dividers
clk: meson: Add s4 clock driver
meson: Add Khadas VIM1S support
.../meson-s4-s905y4-khadas-vim1s-u-boot.dtsi | 5 + arch/arm/include/asm/arch-meson/boot0.h | 12 + arch/arm/mach-meson/Kconfig | 7 + arch/arm/mach-meson/Makefile | 1 + arch/arm/mach-meson/board-info.c | 2 + arch/arm/mach-meson/board-s4.c | 50 ++ board/amlogic/vim1s/MAINTAINERS | 7 + board/amlogic/vim1s/Makefile | 1 + board/amlogic/vim1s/vim1s.c | 26 + configs/khadas-vim1s_defconfig | 66 ++ drivers/clk/meson/Kconfig | 8 + drivers/clk/meson/Makefile | 2 + drivers/clk/meson/a1.c | 495 +-------------- drivers/clk/meson/axg-ao.c | 12 +- drivers/clk/meson/axg.c | 16 +- drivers/clk/meson/clk_meson.c | 376 +++++++++++ drivers/clk/meson/clk_meson.h | 149 +++++ drivers/clk/meson/g12a-ao.c | 12 +- drivers/clk/meson/g12a.c | 24 +- drivers/clk/meson/gxbb.c | 24 +- drivers/clk/meson/s4.c | 601 ++++++++++++++++++ drivers/serial/Kconfig | 2 + 22 files changed, 1358 insertions(+), 540 deletions(-) create mode 100644 arch/arm/dts/meson-s4-s905y4-khadas-vim1s-u-boot.dtsi create mode 100644 arch/arm/include/asm/arch-meson/boot0.h create mode 100644 arch/arm/mach-meson/board-s4.c create mode 100644 board/amlogic/vim1s/MAINTAINERS create mode 100644 board/amlogic/vim1s/Makefile create mode 100644 board/amlogic/vim1s/vim1s.c create mode 100644 configs/khadas-vim1s_defconfig create mode 100644 drivers/clk/meson/clk_meson.c create mode 100644 drivers/clk/meson/s4.c
---
base-commit: 2b8902913c19eb581fb0d567201c09b8fa46ac74
branch: s4_clk
Signature · 1 line
2.53.0
PATCH v2 1/9 arm64: meson: Add s4 SoC support
Add support for amlogic s4 (S805X2/S905W2/S905Y4) SoCs. These are very similar to other recent SoCs, with the exception of a workaround for some BL2 (mis)behavior. Memory for ATF/TEE is expected to be reserved in the board devicetree, so we don't reserve it in board-s4.c.
---
Changes in v2:
- Add S4 to meson board info
- Add DEBUG_UART defaults
- Extend initial padding to 4096 to match what Amlogic does
arch/arm/include/asm/arch-meson/boot0.h | 12 ++++++ arch/arm/mach-meson/Kconfig | 7 ++++ arch/arm/mach-meson/Makefile | 1 + arch/arm/mach-meson/board-info.c | 2 + arch/arm/mach-meson/board-s4.c | 50 +++++++++++++++++++++++++ drivers/serial/Kconfig | 2 + 6 files changed, 74 insertions(+) create mode 100644 arch/arm/include/asm/arch-meson/boot0.h create mode 100644 arch/arm/mach-meson/board-s4.c
arch/arm/include/asm/arch-meson/boot0.h new file +12 -0
@@ -0,0 +1,12 @@ +/* SPDX-License-Identifier: GPL-2.0+ */ +/* +* Copyright (C) 2026 Brivo Systems LLC +*/ +b reset +/* +* BL2 copies some keys to the start of DRAM, clobbering anything in the first +* 4k aside from the initial instruction. I measured the actual data clobbered +* as 1076 bytes, but I suspect the amount depends on the configuration, so +* just go with what amlogic does. +*/ +.skip 4096
arch/arm/mach-meson/Kconfig +7 -0
@@ -67,6 +67,13 @@ config MESON_A1 help Select this if your SoC is an A113L +config MESON_S4 + bool "S4" + select MESON64_COMMON + select ENABLE_ARM_SOC_BOOT0_HOOK + help + Select this if your SoC is an S905Y4/S905W2/S805X2 + endchoice config SYS_SOC
arch/arm/mach-meson/Makefile +1 -0
@@ -17,3 +17,4 @@ endif obj-$(CONFIG_MESON_AXG) += board-axg.o obj-$(CONFIG_MESON_G12A) += board-g12a.o obj-$(CONFIG_MESON_A1) += board-a1.o +obj-$(CONFIG_MESON_S4) += board-s4.o
arch/arm/mach-meson/board-info.c +2 -0
@@ -40,6 +40,7 @@ static const struct meson_gx_soc_id { { "G12B", 0x29 }, { "SM1", 0x2b }, { "A1", 0x2c }, + { "S4", 0x37 }, }; static const struct meson_gx_package_id {
@@ -73,6 +74,7 @@ static const struct meson_gx_package_id { { "S905X3", 0x2b, 0x10, 0x3f }, { "S905D3", 0x2b, 0x30, 0x3f }, { "A113L", 0x2c, 0x0, 0xf8 }, + { "S905Y4", 0x37, 0x03, 0xff }, };DECLARE_GLOBAL_DATA_PTR ;
arch/arm/mach-meson/board-s4.c new file +50 -0
50 lines not on this page · raw message
drivers/serial/Kconfig +2 -0
@@ -537,6 +537,7 @@ config DEBUG_UART_BASE default 0xe0000000 if DEBUG_UART_ZYNQ && ARCH_ZYNQ default 0xff000000 if DEBUG_UART_PL011 && ARCH_VERSAL default 0xf1920000 if DEBUG_UART_PL011 && (ARCH_VERSAL_NET || ARCH_VERSAL2) + default 0xfe07a000 if DEBUG_UART_MESON && MESON_S4 help This is the base address of your UART for memory-mapped UARTs.
@@ -573,6 +574,7 @@ config DEBUG_UART_CLOCK default 100000000 if DEBUG_UART_ZYNQ && ARCH_ZYNQMP default 50000000 if DEBUG_UART_ZYNQ && ARCH_ZYNQ default 100000000 if DEBUG_UART_PL011 && (ARCH_VERSAL || ARCH_VERSAL_NET || ARCH_VERSAL2) + default 24000000 if DEBUG_UART_MESON && MESON_S4 help The UART input clock determines the speed of the internal UART circuitry. The baud rate is derived from this by dividing the input
Signature · 1 line
2.53.0
PATCH v2 2/9 clk: meson: a1: Eliminate separate id parameter
In reply to Sean AndersonInstead of passing a struct clk (containing the device and an unrelated id) and a separate id parameter to most functions, just pass a single struct clk with the correct id. This is in preparation for converting some instances of meson_clk_* functions to clk_* functions to allow for greater extensibility.
In general, this transformation requires constructing a synthetic struct clk wherever we used to call a function with an id different from clk->id. We don't bother to call clk_request since we don't implement it ourselves.
---
(no changes since v1)
drivers/clk/meson/a1.c | 150 ++++++++++++++++++++--------------------- 1 file changed, 74 insertions(+), 76 deletions(-)
drivers/clk/meson/a1.c +74 -76
@@ -302,17 +302,16 @@ static const struct meson_clk_info *meson_pll_clocks[] = { ), }; -static const struct meson_clk_info *meson_clk_get_info (struct clk *clk,ulong id, +static const struct meson_clk_info *meson_clk_get_info (struct clk *clk,enum meson_clk_type type) { -struct meson_clk_data *data; +struct meson_clk_data *data = (void *)dev_get_driver_data (clk->dev);const struct meson_clk_info *info; - data = (struct meson_clk_data *)dev_get_driver_data (clk->dev); -if (id >= data->num_clocks) +if (clk->id >= data->num_clocks)return ERR_PTR (-EINVAL ); - info = data->clocks[id]; + info = data->clocks[clk->id];if (!info)return ERR_PTR (-ENOENT );
@@ -322,7 +321,7 @@ static const struct meson_clk_info *meson_clk_get_info(struct clk *clk, ulong idreturn info; } -static ulong meson_clk_get_rate_by_id (struct clk *clk,unsigned long id); +static ulong meson_clk_get_rate (struct clk *clk);static int meson_set_gate (struct clk *clk,bool on) {
@@ -331,7 +330,7 @@ static int meson_set_gate(struct clk *clk, bool on)debug ("%s: %sabling %lu\n" , __func__, on ?"en" :"dis" , clk->id); - info =meson_clk_get_info (clk, clk->id,MESON_CLK_ANY ); + info =meson_clk_get_info (clk,MESON_CLK_ANY );if (IS_ERR (info))return PTR_ERR (info);
@@ -350,32 +349,35 @@ static int meson_clk_disable(struct clk *clk)return meson_set_gate (clk, false); } -static ulong meson_div_get_rate (struct clk *clk,unsigned long id) +static ulong meson_div_get_rate (struct clk *clk) {struct meson_clk *priv =dev_get_priv (clk->dev);u16 n;ulong rate;const struct meson_clk_info *info; +struct clk parent; - info =meson_clk_get_info (clk, id,MESON_CLK_DIV ); + info =meson_clk_get_info (clk,MESON_CLK_DIV );if (IS_ERR (info))return PTR_ERR (info);/* Actual divider value is (field value + 1), hence the increment */ n =GET_PARM_VALUE (priv, info->parm) +1 ; - rate =meson_clk_get_rate_by_id (clk, info->parents[0 ]); + parent.dev = clk->dev; + parent.id = info->parents[0 ]; + rate =meson_clk_get_rate (&parent);return rate / n; } -static int meson_clk_get_parent (struct clk *clk,unsigned long id) +static int meson_clk_get_parent (struct clk *clk) {uint reg =0 ;struct meson_clk *priv =dev_get_priv (clk->dev);const struct meson_clk_info *info; - info =meson_clk_get_info (clk, id,MESON_CLK_ANY ); + info =meson_clk_get_info (clk,MESON_CLK_ANY );if (IS_ERR (info))return PTR_ERR (info);
@@ -391,16 +393,16 @@ static int meson_clk_get_parent(struct clk *clk, unsigned long id)return info->parents[reg]; } -static ulong meson_pll_get_rate (struct clk *clk,unsigned long id) +static ulong meson_pll_get_rate (struct clk *clk) {struct meson_clk *priv =dev_get_priv (clk->dev);const struct meson_clk_info *info;const struct parm *pm, *pn;ulong parent_rate_mhz; -unsigned int parent; +struct clk parent;u16 n, m; - info =meson_clk_get_info (clk, id,MESON_CLK_ANY ); + info =meson_clk_get_info (clk,MESON_CLK_ANY );if (IS_ERR (info))return PTR_ERR (info);
@@ -413,40 +415,39 @@ static ulong meson_pll_get_rate(struct clk *clk, unsigned long id)if (n ==0 )return -EINVAL ; - parent = info->parents[0 ]; - parent_rate_mhz =meson_clk_get_rate_by_id (clk, parent) /1000000 ; + parent.dev = clk->dev; + parent.id = info->parents[0 ]; + parent_rate_mhz =meson_clk_get_rate (&parent) /1000000 ;return parent_rate_mhz * m / n *1000000 ; } -static ulong meson_clk_get_rate_by_id (struct clk *clk,unsigned long id) +static ulong meson_clk_get_rate (struct clk *clk) { -ulong rate, parent; +struct clk parent;const struct meson_clk_info *info; -if (IS_ERR_VALUE (id)) -return id; +if (IS_ERR_VALUE (clk->id)) +return clk->id; - info =meson_clk_get_info (clk, id,MESON_CLK_ANY ); + info =meson_clk_get_info (clk,MESON_CLK_ANY );if (IS_ERR (info))return PTR_ERR (info);switch (info->type) {case MESON_CLK_PLL : - rate =meson_pll_get_rate (clk, id); -break ; +return meson_pll_get_rate (clk);case MESON_CLK_GATE :case MESON_CLK_MUX : - parent =meson_clk_get_parent (clk, id); - rate =meson_clk_get_rate_by_id (clk, parent); -break ; + parent.dev = clk->dev; + parent.id =meson_clk_get_parent (clk); +return meson_clk_get_rate (&parent);case MESON_CLK_DIV : - rate =meson_div_get_rate (clk, id); -break ; +return meson_div_get_rate (clk);case MESON_CLK_FIXED_DIV : - parent =meson_clk_get_parent (clk, id); - rate =meson_clk_get_rate_by_id (clk, parent) / info->div; -break ; + parent.dev = clk->dev; + parent.id =meson_clk_get_parent (clk); +return meson_clk_get_rate (&parent) / info->div;case MESON_CLK_EXTERNAL : {int ret;struct clk external_clk;
@@ -455,20 +456,11 @@ static ulong meson_clk_get_rate_by_id(struct clk *clk, unsigned long id)if (ret)return ret; - rate =clk_get_rate (&external_clk); -break ; +return clk_get_rate (&external_clk); }default : - rate = -EINVAL ; -break ; +return -EINVAL ; } - -return rate; -} - -static ulong meson_clk_get_rate (struct clk *clk) -{ -return meson_clk_get_rate_by_id (clk, clk->id); }/* This implements rate propagation for dividers placed after multiplexer:
@@ -476,19 +468,22 @@ static ulong meson_clk_get_rate(struct clk *clk)* ..... | |---DIV-- * ---------|/ */ -static ulong meson_composite_set_rate (struct clk *clk,ulong id,ulong rate) +static ulong meson_composite_set_rate (struct clk *clk,ulong rate) {unsigned int i, best_div_val;unsigned long best_delta, best_parent;const struct meson_clk_info *div;const struct meson_clk_info *mux;struct meson_clk *priv =dev_get_priv (clk->dev); +struct clk mux_clk; - div =meson_clk_get_info (clk, id,MESON_CLK_DIV ); + div =meson_clk_get_info (clk,MESON_CLK_DIV );if (IS_ERR (div))return PTR_ERR (div); - mux =meson_clk_get_info (clk, div->parents[0 ],MESON_CLK_MUX ); + mux_clk.dev = clk->dev; + mux_clk.id = div->parents[0 ]; + mux =meson_clk_get_info (&mux_clk,MESON_CLK_MUX );if (IS_ERR (mux))return PTR_ERR (mux);
@@ -497,8 +492,12 @@ static ulong meson_composite_set_rate(struct clk *clk, ulong id, ulong rate)for (i =0 ; i < (1 << mux->parm->width); i++) {unsigned long parent_rate, delta;unsigned int div_val; +struct clk parent = { + .dev = clk->dev, + .id = mux->parents[i], + }; - parent_rate =meson_clk_get_rate_by_id (clk, mux->parents[i]); + parent_rate =meson_clk_get_rate (&parent);if (IS_ERR_VALUE (parent_rate))continue ;
@@ -524,21 +523,26 @@ static ulong meson_composite_set_rate(struct clk *clk, ulong id, ulong rate)return 0 ; } -static ulong meson_clk_set_rate_by_id (struct clk *clk,unsigned int id,ulong rate); +static ulong meson_clk_set_rate (struct clk *clk,ulong rate); -static ulong meson_mux_set_rate (struct clk *clk,unsigned long id,ulong rate) +static ulong meson_mux_set_rate (struct clk *clk,ulong rate) {int i;ulong ret = -EINVAL ;struct meson_clk *priv =dev_get_priv (clk->dev);const struct meson_clk_info *info; - info =meson_clk_get_info (clk, id,MESON_CLK_MUX ); + info =meson_clk_get_info (clk,MESON_CLK_MUX );if (IS_ERR (info))return PTR_ERR (info);for (i =0 ; i < (1 << info->parm->width); i++) { - ret =meson_clk_set_rate_by_id (clk, info->parents[i], rate); +struct clk parent = { + .dev = clk->dev, + .id = info->parents[i], + }; + + ret =meson_clk_set_rate (&parent, rate);if (!ret) {SET_PARM_VALUE (priv, info->parm, i);break ;
@@ -551,43 +555,41 @@ static ulong meson_mux_set_rate(struct clk *clk, unsigned long id, ulong rate)/* Rate propagation is implemented for a subcection of a clock tree, that is * required at boot stage. */ -static ulong meson_clk_set_rate_by_id (struct clk *clk,unsigned int id,ulong rate) +static ulong meson_clk_set_rate (struct clk *clk,ulong rate) { -switch (id) { +switch (clk->id) {case CLKID_SPIFC_DIV :case CLKID_USB_BUS_DIV : -return meson_composite_set_rate (clk, id, rate); +return meson_composite_set_rate (clk, rate);case CLKID_SPIFC :case CLKID_USB_BUS : { -unsigned long parent =meson_clk_get_parent (clk, id); +struct clk parent = { + .dev = clk->dev, + .id =meson_clk_get_parent (clk), + }; -return meson_clk_set_rate_by_id (clk, parent, rate); +return meson_clk_set_rate (&parent, rate); }case CLKID_SPIFC_SEL2 : -return meson_mux_set_rate (clk, id, rate); +return meson_mux_set_rate (clk, rate); }return -EINVAL ; } -static ulong meson_clk_set_rate (struct clk *clk,ulong rate) -{ -return meson_clk_set_rate_by_id (clk, clk->id, rate); -} - -static int meson_mux_set_parent_by_id (struct clk *clk,unsigned int parent_id) +static int meson_clk_set_parent (struct clk *clk,struct clk *parent) {unsigned int i, parent_index;struct meson_clk *priv =dev_get_priv (clk->dev);const struct meson_clk_info *info; - info =meson_clk_get_info (clk, clk->id,MESON_CLK_MUX ); + info =meson_clk_get_info (clk,MESON_CLK_MUX );if (IS_ERR (info))return PTR_ERR (info); parent_index = -EINVAL ;for (i =0 ; i < (1 << info->parm->width); i++) { -if (parent_id == info->parents[i]) { +if (parent->id == info->parents[i]) { parent_index = i;break ; }
@@ -601,11 +603,6 @@ static int meson_mux_set_parent_by_id(struct clk *clk, unsigned int parent_id)return 0 ; } -static int meson_clk_set_parent (struct clk *clk,struct clk *parent_clk) -{ -return meson_mux_set_parent_by_id (clk, parent_clk->id); -} -static int meson_clk_probe (struct udevice *dev) {struct meson_clk *priv =dev_get_priv (dev);
@@ -636,11 +633,11 @@ static const struct udevice_id meson_clk_ids[] = { };#if IS_ENABLED (CONFIG_CMD_CLK ) -static const char *meson_clk_get_name (struct clk *clk,int id) +static const char *meson_clk_get_name (struct clk *clk) {const struct meson_clk_info *info; - info =meson_clk_get_info (clk, id,MESON_CLK_ANY ); + info =meson_clk_get_info (clk,MESON_CLK_ANY );return IS_ERR (info) ?"unknown" : info->name; }
@@ -651,11 +648,11 @@ static int meson_clk_dump_single(struct clk *clk)struct meson_clk *priv;unsigned long rate;char *state, frequency[80 ]; -int parent; +struct clk parent; priv =dev_get_priv (clk->dev); - info =meson_clk_get_info (clk, clk->id,MESON_CLK_ANY ); + info =meson_clk_get_info (clk,MESON_CLK_ANY );if (IS_ERR (info) || !info->name)return -EINVAL ;
@@ -670,11 +667,12 @@ static int meson_clk_dump_single(struct clk *clk)else state ="N/A" ; - parent =meson_clk_get_parent (clk, clk->id); + parent.dev = clk->dev; + parent.id =meson_clk_get_parent (clk);printf ("%15s%20s%20s%15s\n" , info->name, frequency, -meson_clk_get_name (clk, parent), +meson_clk_get_name (&parent), state);return 0 ;
Signature · 1 line
2.53.0
PATCH v2 3/9 clk: meson: a1: Use clk_set_rate from meson_mux_set_rate
In reply to Sean AndersonThis function is useful for other drivers, but it's tied to the a1's meson_mux_set_rate implementation. Convert it to use clk_set_rate so the drivers's set_rate implementation will be used (no matter what it is).
---
(no changes since v1)
drivers/clk/meson/a1.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-)
drivers/clk/meson/a1.c +1 -3
@@ -523,8 +523,6 @@ static ulong meson_composite_set_rate(struct clk *clk, ulong rate)return 0 ; } -static ulong meson_clk_set_rate (struct clk *clk,ulong rate); -static ulong meson_mux_set_rate (struct clk *clk,ulong rate) {int i;
@@ -542,7 +540,7 @@ static ulong meson_mux_set_rate(struct clk *clk, ulong rate) .id = info->parents[i], }; - ret =meson_clk_set_rate (&parent, rate); + ret =clk_set_rate (&parent, rate);if (!ret) {SET_PARM_VALUE (priv, info->parm, i);break ;
Signature · 1 line
2.53.0
PATCH v2 4/9 clk: meson: Use soc-specific naming for common functions
In reply to Sean AndersonIn preparation for moving a1 versions of several common functions into a shared file, rename all the conflicting functions to have a soc-specific component.
---
(no changes since v1)
drivers/clk/meson/axg-ao.c | 8 ++++---- drivers/clk/meson/axg.c | 12 ++++++------ drivers/clk/meson/g12a-ao.c | 8 ++++---- drivers/clk/meson/g12a.c | 20 ++++++++++---------- drivers/clk/meson/gxbb.c | 20 ++++++++++---------- 5 files changed, 34 insertions(+), 34 deletions(-)
drivers/clk/meson/axg-ao.c +4 -4
@@ -35,12 +35,12 @@ static int meson_set_gate(struct clk *clk, bool on)return 0 ; } -static int meson_clk_enable (struct clk *clk) +static int meson_axg_ao_clk_enable (struct clk *clk) {return meson_set_gate (clk, true); } -static int meson_clk_disable (struct clk *clk) +static int meson_axg_ao_clk_disable (struct clk *clk) {return meson_set_gate (clk, false); }
@@ -65,8 +65,8 @@ static int meson_clk_request(struct clk *clk) }static struct clk_ops meson_clk_ops = { - .disable = meson_clk_disable, - .enable = meson_clk_enable, + .disable = meson_axg_ao_clk_disable, + .enable = meson_axg_ao_clk_enable, .request = meson_clk_request, };
drivers/clk/meson/axg.c +6 -6
@@ -69,12 +69,12 @@ static int meson_set_gate(struct clk *clk, bool on)return 0 ; } -static int meson_clk_enable (struct clk *clk) +static int meson_axg_clk_enable (struct clk *clk) {return meson_set_gate (clk, true); } -static int meson_clk_disable (struct clk *clk) +static int meson_axg_clk_disable (struct clk *clk) {return meson_set_gate (clk, false); }
@@ -279,7 +279,7 @@ static ulong meson_clk_get_rate_by_id(struct clk *clk, unsigned long id)return rate; } -static ulong meson_clk_get_rate (struct clk *clk) +static ulong meson_axg_clk_get_rate (struct clk *clk) {return meson_clk_get_rate_by_id (clk, clk->id); }
@@ -305,9 +305,9 @@ static int meson_clk_probe(struct udevice *dev) }static struct clk_ops meson_clk_ops = { - .disable = meson_clk_disable, - .enable = meson_clk_enable, - .get_rate = meson_clk_get_rate, + .disable = meson_axg_clk_disable, + .enable = meson_axg_clk_enable, + .get_rate = meson_axg_clk_get_rate, };static const struct udevice_id meson_clk_ids[] = {
drivers/clk/meson/g12a-ao.c +4 -4
@@ -35,12 +35,12 @@ static int meson_set_gate(struct clk *clk, bool on)return 0 ; } -static int meson_clk_enable (struct clk *clk) +static int meson_g12a_ao_clk_enable (struct clk *clk) {return meson_set_gate (clk, true); } -static int meson_clk_disable (struct clk *clk) +static int meson_g12a_ao_clk_disable (struct clk *clk) {return meson_set_gate (clk, false); }
@@ -65,8 +65,8 @@ static int meson_clk_request(struct clk *clk) }static struct clk_ops meson_clk_ops = { - .disable = meson_clk_disable, - .enable = meson_clk_enable, + .disable = meson_g12a_ao_clk_disable, + .enable = meson_g12a_ao_clk_enable, .request = meson_clk_request, };
drivers/clk/meson/g12a.c +10 -10
@@ -194,12 +194,12 @@ static int meson_set_gate_by_id(struct clk *clk, unsigned long id, bool on)return 0 ; } -static int meson_clk_enable (struct clk *clk) +static int meson_g12a_clk_enable (struct clk *clk) {return meson_set_gate_by_id (clk, clk->id, true); } -static int meson_clk_disable (struct clk *clk) +static int meson_g12a_clk_disable (struct clk *clk) {return meson_set_gate_by_id (clk, clk->id, false); }
@@ -858,7 +858,7 @@ static ulong meson_clk_get_rate_by_id(struct clk *clk, unsigned long id)return rate; } -static ulong meson_clk_get_rate (struct clk *clk) +static ulong meson_g12a_clk_get_rate (struct clk *clk) {return meson_clk_get_rate_by_id (clk, clk->id); }
@@ -888,7 +888,7 @@ static ulong meson_pcie_pll_set_rate(struct clk *clk, ulong rate)return 100000000 ; } -static int meson_clk_set_parent (struct clk *clk,struct clk *parent) +static int meson_g12a_clk_set_parent (struct clk *clk,struct clk *parent) {return meson_mux_set_parent (clk, clk->id, parent->id); }
@@ -958,7 +958,7 @@ static ulong meson_clk_set_rate_by_id(struct clk *clk, unsigned long id,return -EINVAL ; } -static ulong meson_clk_set_rate (struct clk *clk,ulong rate) +static ulong meson_g12a_clk_set_rate (struct clk *clk,ulong rate) {ulong current_rate =meson_clk_get_rate_by_id (clk, clk->id);int ret;
@@ -1000,11 +1000,11 @@ static int meson_clk_probe(struct udevice *dev) }static struct clk_ops meson_clk_ops = { - .disable = meson_clk_disable, - .enable = meson_clk_enable, - .get_rate = meson_clk_get_rate, - .set_parent = meson_clk_set_parent, - .set_rate = meson_clk_set_rate, + .disable = meson_g12a_clk_disable, + .enable = meson_g12a_clk_enable, + .get_rate = meson_g12a_clk_get_rate, + .set_parent = meson_g12a_clk_set_parent, + .set_rate = meson_g12a_clk_set_rate, };static const struct udevice_id meson_clk_ids[] = {
drivers/clk/meson/gxbb.c +10 -10
@@ -236,12 +236,12 @@ static int meson_set_gate_by_id(struct clk *clk, unsigned long id, bool on)return 0 ; } -static int meson_clk_enable (struct clk *clk) +static int meson_gxbb_clk_enable (struct clk *clk) {return meson_set_gate_by_id (clk, clk->id, true); } -static int meson_clk_disable (struct clk *clk) +static int meson_gxbb_clk_disable (struct clk *clk) {return meson_set_gate_by_id (clk, clk->id, false); }
@@ -840,12 +840,12 @@ static ulong meson_clk_get_rate_by_id(struct clk *clk, unsigned long id)return rate; } -static ulong meson_clk_get_rate (struct clk *clk) +static ulong meson_gxbb_clk_get_rate (struct clk *clk) {return meson_clk_get_rate_by_id (clk, clk->id); } -static int meson_clk_set_parent (struct clk *clk,struct clk *parent) +static int meson_gxbb_clk_set_parent (struct clk *clk,struct clk *parent) {return meson_mux_set_parent (clk, clk->id, parent->id); }
@@ -912,7 +912,7 @@ static ulong meson_clk_set_rate_by_id(struct clk *clk, unsigned long id,return -EINVAL ; } -static ulong meson_clk_set_rate (struct clk *clk,ulong rate) +static ulong meson_gxbb_clk_set_rate (struct clk *clk,ulong rate) {ulong current_rate =meson_clk_get_rate_by_id (clk, clk->id);int ret;
@@ -954,11 +954,11 @@ static int meson_clk_probe(struct udevice *dev) }static struct clk_ops meson_clk_ops = { - .disable = meson_clk_disable, - .enable = meson_clk_enable, - .get_rate = meson_clk_get_rate, - .set_parent = meson_clk_set_parent, - .set_rate = meson_clk_set_rate, + .disable = meson_gxbb_clk_disable, + .enable = meson_gxbb_clk_enable, + .get_rate = meson_gxbb_clk_get_rate, + .set_parent = meson_gxbb_clk_set_parent, + .set_rate = meson_gxbb_clk_set_rate, };static const struct udevice_id meson_clk_ids[] = {
Signature · 1 line
2.53.0
PATCH v2 5/9 clk: meson: Export a1 functions to common file
In reply to Sean AndersonExport several useful functions from a1 to a common file. These will be used for s4 support.
---
(no changes since v1)
drivers/clk/meson/Makefile | 1 + drivers/clk/meson/a1.c | 473 ---------------------------------- drivers/clk/meson/axg-ao.c | 4 - drivers/clk/meson/axg.c | 4 - drivers/clk/meson/clk_meson.c | 350 +++++++++++++++++++++++++ drivers/clk/meson/clk_meson.h | 143 ++++++++++ drivers/clk/meson/g12a-ao.c | 4 - drivers/clk/meson/g12a.c | 4 - drivers/clk/meson/gxbb.c | 4 - 9 files changed, 494 insertions(+), 493 deletions(-) create mode 100644 drivers/clk/meson/clk_meson.c
drivers/clk/meson/Makefile +1 -0
@@ -3,6 +3,7 @@ # Copyright (c) 2019 Baylibre, SAS # Jerome Brunet <[email protected]> +obj-y += clk_meson.o obj-$(CONFIG_CLK_MESON_GX) += gxbb.o obj-$(CONFIG_CLK_MESON_AXG) += axg.o obj-$(CONFIG_CLK_MESON_AXG) += axg-ao.o
drivers/clk/meson/a1.c +0 -473
497 lines not on this page · raw message
drivers/clk/meson/axg-ao.c +0 -4
@@ -10,10 +10,6 @@#include "clk_meson.h" -struct meson_clk { -struct regmap *map; -}; -#define AO_CLK_GATE0 0x40#define AO_SAR_CLK 0x90
drivers/clk/meson/axg.c +0 -4
@@ -20,10 +20,6 @@#define XTAL_RATE 24000000 -struct meson_clk { -struct regmap *map; -}; -static ulong meson_clk_get_rate_by_id (struct clk *clk,unsigned long id);static struct meson_gate gates[] = {
drivers/clk/meson/clk_meson.c new file +350 -0
350 lines not on this page · raw message
drivers/clk/meson/clk_meson.h +143 -0
153 lines not on this page · raw message
drivers/clk/meson/g12a-ao.c +0 -4
@@ -10,10 +10,6 @@#include "clk_meson.h" -struct meson_clk { -struct regmap *map; -}; -#define AO_CLK_GATE0 0x4c#define AO_SAR_CLK 0x90
drivers/clk/meson/g12a.c +0 -4
@@ -91,10 +91,6 @@#define XTAL_RATE 24000000 -struct meson_clk { -struct regmap *map; -}; -static ulong meson_div_get_rate (struct clk *clk,unsigned long id);static ulong meson_div_set_rate (struct clk *clk,unsigned long id,ulong rate,ulong current_rate);
drivers/clk/meson/gxbb.c +0 -4
@@ -70,10 +70,6 @@#define XTAL_RATE 24000000 -struct meson_clk { -struct regmap *map; -}; -static ulong meson_div_get_rate (struct clk *clk,unsigned long id);static ulong meson_div_set_rate (struct clk *clk,unsigned long id,ulong rate,ulong current_rate);
Signature · 1 line
2.53.0
PATCH v2 6/9 clk: meson: Support fractional fixed-factor clocks
In reply to Sean AndersonOne of the s4 clocks has a non-integer divisor (2.5). Add support for this.
---
(no changes since v1)
drivers/clk/meson/clk_meson.c | 3 ++- drivers/clk/meson/clk_meson.h | 12 +++++++++--- 2 files changed, 11 insertions(+), 4 deletions(-)
drivers/clk/meson/clk_meson.c +2 -1
@@ -153,7 +153,8 @@ ulong meson_clk_get_rate(struct clk *clk)case MESON_CLK_FIXED_DIV : parent.dev = clk->dev; parent.id =meson_clk_get_parent (clk); -return meson_clk_get_rate (&parent) / info->div; +return mult_frac (meson_clk_get_rate (&parent), info->mult, + info->div);case MESON_CLK_EXTERNAL : {int ret;struct clk external_clk;
drivers/clk/meson/clk_meson.h +9 -3
@@ -61,7 +61,7 @@ struct meson_clk {* @MESON_CLK_GATE: This clock is a gate * @MESON_CLK_MUX: This clock is a multiplexer * @MESON_CLK_DIV: This clock is a configurable divider -* @MESON_CLK_FIXED_DIV: This clock is a configurable divider +* @MESON_CLK_FIXED_DIV: This clock is a (fractional) fixed-factor clock * @MESON_CLK_EXTERNAL: This is an external clock from different clock provider * @MESON_CLK_PLL: This is a PLL */
@@ -87,7 +87,10 @@ struct meson_clk_info {const char *name;union {const struct parm *parm; -u8 div; +struct { +u8 mult; +u8 div; + }; };const unsigned int *parents;const enum meson_clk_type type;
@@ -133,13 +136,16 @@ struct meson_clk_data { })/* A fixed divider */ -#define CLK_DIV_FIXED (_name, _div, _parent) \ +#define CLK_DIV_FIXED_FULL (_name, _mult, _div, _parent) \ (&(struct meson_clk_info){ \ .parents = (const unsigned int[]) { (_parent) }, \ + .mult = (_mult), \ .div = (_div), \ .name = (_name), \ .type = MESON_CLK_FIXED_DIV, \ }) +#define CLK_DIV_FIXED (name, div, parent) \ + CLK_DIV_FIXED_FULL(name, 1, div, parent)/* An external clock */ #define CLK_EXTERNAL (_name) \
Signature · 1 line
2.53.0
PATCH v2 7/9 clk: meson: Support power-of-two dividers
In reply to Sean AndersonSeveral s4 clocks use power-of-two dividers. Add support for them.
---
(no changes since v1)
drivers/clk/meson/clk_meson.c | 49 ++++++++++++++++++++++++++--------- drivers/clk/meson/clk_meson.h | 44 +++++++++++++++---------------- 2 files changed, 59 insertions(+), 34 deletions(-)
drivers/clk/meson/clk_meson.c +37 -12
@@ -55,26 +55,49 @@ int meson_clk_disable(struct clk *clk)return meson_set_gate (clk, false); } +static ulong meson_div_get_rate_common (struct clk *clk, +enum meson_clk_type type,u16 *n, +ulong *rate) +{ +struct meson_clk *priv =dev_get_priv (clk->dev); +const struct meson_clk_info *info; +struct clk parent; + + info =meson_clk_get_info (clk, type); +if (IS_ERR (info)) +return PTR_ERR (info); + + *n =GET_PARM_VALUE (priv, info->parm); + + parent.dev = clk->dev; + parent.id = info->parents[0 ]; + *rate =meson_clk_get_rate (&parent); +return 0 ; +} +static ulong meson_div_get_rate (struct clk *clk) { -struct meson_clk *priv =dev_get_priv (clk->dev); +ulong rate, err;u16 n; -ulong rate; -const struct meson_clk_info *info; -struct clk parent; - info =meson_clk_get_info (clk,MESON_CLK_DIV ); -if (IS_ERR (info)) -return PTR_ERR (info); + err =meson_div_get_rate_common (clk,MESON_CLK_DIV , &n, &rate); +if (err) +return err;/* Actual divider value is (field value + 1), hence the increment */ - n =GET_PARM_VALUE (priv, info->parm) +1 ; +return rate / (n +1 ); +} - parent.dev = clk->dev; - parent.id = info->parents[0 ]; - rate =meson_clk_get_rate (&parent); +static ulong meson_div2_get_rate (struct clk *clk) +{ +ulong rate, err; +u16 n; -return rate / n; + err =meson_div_get_rate_common (clk,MESON_CLK_DIV2 , &n, &rate); +if (err) +return err; + +return rate >> n; }int meson_clk_get_parent (struct clk *clk)
@@ -150,6 +173,8 @@ ulong meson_clk_get_rate(struct clk *clk)return meson_clk_get_rate (&parent);case MESON_CLK_DIV :return meson_div_get_rate (clk); +case MESON_CLK_DIV2 : +return meson_div2_get_rate (clk);case MESON_CLK_FIXED_DIV : parent.dev = clk->dev; parent.id =meson_clk_get_parent (clk);
drivers/clk/meson/clk_meson.h +22 -22
69 lines not on this page · raw message
Signature · 1 line
2.53.0
PATCH v2 8/9 clk: meson: Add s4 clock driver
In reply to Sean AndersonAdd a clock driver to support for the "s4" series of SoCs (S805X2 and S905Y4). I've added most of the clocks necessary at boot, although a few of the unused parents (VID_PLL, RTC) have been omitted. I also left out the parents of the MPLL clocks, as they have a custom divider. MPLL2 is enabled by the Ethernet driver but is never actually selected so it's OK to stub out the parent.
=> clk dump
Rate Usecnt Name
------------------------------------------
24000000 0 |-- xtal-clk
meson-clk-s4 clock-controller@0:
clock-controller@0:
----------------------------------------------------------------------
clk frequency parent state
----------------------------------------------------------------------
sysclk_b_sel 498000000 fclk_div4 N/A
sysclk_b_div 166000000 sysclk_b_sel N/A
sysclk_b 166000000 sysclk_b_div enabled
sysclk_a_sel 24000000 xtal N/A
sysclk_a_div 24000000 sysclk_a_sel N/A
sysclk_a 24000000 sysclk_a_div enabled
sys 166000000 sysclk_b N/A
sd_emmc_c_sel 24000000 xtal N/A
sd_emmc_c_div 24000000 sd_emmc_c_sel N/A
sd_emmc_c 24000000 sd_emmc_c_div enabled
sd_emmc_a_sel 24000000 xtal N/A
sd_emmc_a_div 24000000 sd_emmc_a_sel N/A
sd_emmc_a 24000000 sd_emmc_a_div enabled
sd_emmc_b_sel 24000000 xtal N/A
sd_emmc_b_div 24000000 sd_emmc_b_sel N/A
sd_emmc_b 24000000 sd_emmc_b_div enabled
pwm_a_sel 24000000 xtal N/A
pwm_a_div 24000000 pwm_a_sel N/A
pwm_a 24000000 pwm_a_div disabled
pwm_b_sel 24000000 xtal N/A
pwm_b_div 24000000 pwm_b_sel N/A
pwm_b 24000000 pwm_b_div disabled
pwm_c_sel 24000000 xtal N/A
pwm_c_div 24000000 pwm_c_sel N/A
pwm_c 24000000 pwm_c_div disabled
pwm_d_sel 24000000 xtal N/A
pwm_d_div 24000000 pwm_d_sel N/A
pwm_d 24000000 pwm_d_div disabled
pwm_e_sel 24000000 xtal N/A
pwm_e_div 24000000 pwm_e_sel N/A
pwm_e 24000000 pwm_e_div disabled
pwm_f_sel 24000000 xtal N/A
pwm_f_div 24000000 pwm_f_sel N/A
pwm_f 24000000 pwm_f_div disabled
pwm_g_sel 24000000 xtal N/A
pwm_g_div 24000000 pwm_g_sel N/A
pwm_g 24000000 pwm_g_div disabled
pwm_h_sel 24000000 xtal N/A
pwm_h_div 24000000 pwm_h_sel N/A
pwm_h 24000000 pwm_h_div enabled
pwm_i_sel 24000000 xtal N/A
pwm_i_div 24000000 pwm_i_sel N/A
pwm_i 24000000 pwm_i_div disabled
pwm_j_sel 24000000 xtal N/A
pwm_j_div 24000000 pwm_j_sel N/A
pwm_j 24000000 pwm_j_div enabled
saradc_sel 24000000 xtal N/A
saradc_div 150000 saradc_sel N/A
saradc 150000 saradc_div disabled
ethphy 166000000 sys enabled
sdemmc_a 166000000 sys enabled
sdemmc_b 166000000 sys enabled
nand 166000000 sys enabled
eth 166000000 sys enabled
uart_a 166000000 sys enabled
uart_b 166000000 sys enabled
uart_c 166000000 sys enabled
uart_d 166000000 sys enabled
uart_e 166000000 sys enabled
usb 166000000 sys enabled
i2c_m_a 166000000 sys enabled
i2c_m_b 166000000 sys enabled
i2c_m_c 166000000 sys enabled
i2c_m_d 166000000 sys enabled
i2c_m_e 166000000 sys enabled
usb1_to_ddr 166000000 sys enabled
sar_adc 166000000 sys enabled
pwm_ab 166000000 sys enabled
pwm_cd 166000000 sys enabled
pwm_ef 166000000 sys enabled
pwm_gh 166000000 sys enabled
pwm_ij 166000000 sys enabled
xtal 24000000 unknown N/A
fclk_div2 996000000 unknown N/A
fclk_div2p5 796800000 unknown N/A
fclk_div3 664000000 unknown N/A
fclk_div4 498000000 unknown N/A
fclk_div5 398400000 unknown N/A
fclk_div7 284571428 unknown N/A
hifi_pll 1176000000 unknown N/A
gp0_pll unknown unknown N/A
mpll0 unknown unknown N/A
mpll1 unknown unknown N/A
mpll2 unknown unknown N/A
mpll3 unknown unknown N/A
hdmi_pll unknown unknown N/Ameson-clk-s4 clock-controller@8000:
clock-controller@8000:
----------------------------------------------------------------------
clk frequency parent state
----------------------------------------------------------------------
fixed_pll_dco 3984000000 xtal N/A
fixed_pll 1992000000 fixed_pll_dco N/A
fclk_div2_div 996000000 fixed_pll N/A
fclk_div2 996000000 fclk_div2_div enabled
fclk_div3_div 664000000 fixed_pll N/A
fclk_div3 664000000 fclk_div3_div enabled
fclk_div4_div 498000000 fixed_pll N/A
fclk_div4 498000000 fclk_div4_div enabled
fclk_div5_div 398400000 fixed_pll N/A
fclk_div5 398400000 fclk_div5_div enabled
fclk_div7_div 284571428 fixed_pll N/A
fclk_div7 284571428 fclk_div7_div enabled
fclk_div2p5_div 796800000 fixed_pll N/A
fclk_div2p5 796800000 fclk_div2p5_div enabled
gp0_pll_dco unknown xtal N/A
gp0_pll unknown gp0_pll_dco N/A
hifi_pll_dco 4704000000 xtal N/A
hifi_pll 1176000000 hifi_pll_dco N/A
hdmi_pll_dco unknown xtal N/A
hdmi_pll_od unknown hdmi_pll_dco N/A
hdmi_pll unknown hdmi_pll_od N/A
mpll_50m_div 49800000 fixed_pll_dco N/A
mpll_50m 49800000 mpll_50m_div N/A
mpll0 unknown unknown disabled
mpll1 unknown unknown disabled
mpll2 unknown unknown enabled
mpll3 unknown unknown disabled
xtal 24000000 unknown N/A---
Changes in v2:
- Add ADC clocks
drivers/clk/meson/Kconfig | 8 + drivers/clk/meson/Makefile | 1 + drivers/clk/meson/s4.c | 601 +++++++++++++++++++++++++++++++++++++ 3 files changed, 610 insertions(+) create mode 100644 drivers/clk/meson/s4.c
drivers/clk/meson/Kconfig +8 -0
@@ -30,6 +30,14 @@ config CLK_MESON_A1 Enable clock support for the Amlogic A1 SoC family, such as the A113L +config CLK_MESON_S4 + bool "Enable clock support for Amlogic S4" + depends on CLK && ARCH_MESON + default MESON_S4 + help + Enable clock support for the Amlogic S4 SoC family, such as + the S905Y4/S905W2 + config CLK_MESON_MSR bool "Enable clock measure driver for Amlogic SoCs" depends on CLK && ARCH_MESON
drivers/clk/meson/Makefile +1 -0
@@ -10,4 +10,5 @@ obj-$(CONFIG_CLK_MESON_AXG) += axg-ao.o obj-$(CONFIG_CLK_MESON_G12A) += g12a.o obj-$(CONFIG_CLK_MESON_G12A) += g12a-ao.o obj-$(CONFIG_CLK_MESON_A1) += a1.o +obj-$(CONFIG_CLK_MESON_S4) += s4.o obj-$(CONFIG_CLK_MESON_MSR) += clk-measure.o
drivers/clk/meson/s4.c new file +601 -0
601 lines not on this page · raw message
Signature · 1 line
2.53.0
PATCH v2 9/9 meson: Add Khadas VIM1S support
In reply to Sean AndersonThis adds basic support for the Khadas VIM1S [1]. I have tested the following features when booting from the SD card:
- Distro boot
- SD card
- Ethernet (tested with TFTP)
- GPIO/ADC Buttons [*]
- RTC [*]
Features marked with [*] require v7.2 of dts/upstream. The following features do not work:
- The eMMC scans properly but I can only read zeros. I've never seen this kind of failure before.
- The PWM LED does not seem to work [2].
- USB is not currently supported in upstream Linux, but I do have some patches for it locally (adapted from Khadas's tree). I will try to submit these at some point.
- I have made no attempt to get HDMI working.
I have submitted the stdout fix upstream as [3].
[1] https://www.khadas.com/vim1s
[2] https://lore.kernel.org/u-boot/[email protected]
[3] https://lore.kernel.org/linux-arm-kernel/[email protected]/
---
Changes in v2:
- Use our own board instead of reusing q200
- Enable more peripherals (buttons, LEDs, etc.)
- Use defaults where possible (commands, distro boot, etc.)
- Set mac address the same way Khadas does
- Set config/stdout-path so we can find the serial
.../meson-s4-s905y4-khadas-vim1s-u-boot.dtsi | 5 ++ board/amlogic/vim1s/MAINTAINERS | 7 ++ board/amlogic/vim1s/Makefile | 1 + board/amlogic/vim1s/vim1s.c | 26 ++++++++ configs/khadas-vim1s_defconfig | 66 +++++++++++++++++++ 5 files changed, 105 insertions(+) create mode 100644 arch/arm/dts/meson-s4-s905y4-khadas-vim1s-u-boot.dtsi create mode 100644 board/amlogic/vim1s/MAINTAINERS create mode 100644 board/amlogic/vim1s/Makefile create mode 100644 board/amlogic/vim1s/vim1s.c create mode 100644 configs/khadas-vim1s_defconfig
arch/arm/dts/meson-s4-s905y4-khadas-vim1s-u-boot.dtsi new file +5 -0
@@ -0,0 +1,5 @@ +/ { + chosen { + stdout-path = "serial0:921600n8"; + }; +};
board/amlogic/vim1s/MAINTAINERS new file +7 -0
@@ -0,0 +1,7 @@ +VIM1S +M: Neil Armstrong <[email protected]> +R: Sean Anderson <[email protected]> +S: Maintained +L: [email protected] +F: board/amlogic/vim1s/ +F: configs/khadas-vim1s_defconfig
board/amlogic/vim1s/Makefile new file +1 -0
@@ -0,0 +1 @@ +obj-y := vim1s.o
board/amlogic/vim1s/vim1s.c new file +26 -0
@@ -0,0 +1,26 @@ +// SPDX-License-Identifier: GPL-2.0+ +/* +* Copyright (C) 2026 Brivo Inc. +*/ + +#include <env.h> +#include <net-common.h> +#include <asm/io.h> + +#define SYSCTRL_SEC_STATUS_REG18 0xfe010348 + +int misc_init_r (void ) +{ +/* This procedure copied from Khadas's downstream fork */ +u32 val =readl (SYSCTRL_SEC_STATUS_REG18 ); +unsigned char addr[ARP_HLEN ] = { +0x02 , +0xad , + val >>24 , +0x01 , + (val >>8 ) &0xff , + val &0xff , + }; + +return eth_env_set_enetaddr ("ethaddr" , addr); +}
configs/khadas-vim1s_defconfig new file +66 -0
66 lines not on this page · raw message
Signature · 1 line
2.53.0
Neil Armstrong
maintainerHi,
Quoted 10 lines · Sean Anderson
This series (along with several patches submitted separately) adds basic support for the amlogic s4 SoCs (S805X2/S905W2/S905Y4). My tree with all patches on it is at [1].
I developed this for a custom board, but I believe a better candidate for a defconfig is the publically-available Khadas VIM1S [2]. Khadas has kindly sent me a VIM1S so I was able to add some more features and fix a few bugs.
[...]
Thanks, Applied to https://source.denx.de/u-boot/custodians/u-boot-amlogic (u-boot-amlogic-next)
[1/9] arm64: meson: Add s4 SoC support
https://source.denx.de/u-boot/custodians/u-boot-amlogic/-/commit/a0f6e4a9f1b3ba2314c58bcd66a61a8941508b58 [2/9] clk: meson: a1: Eliminate separate id parameter https://source.denx.de/u-boot/custodians/u-boot-amlogic/-/commit/81b3945a2096fba2ba8421641dbdabb5ad73740b [3/9] clk: meson: a1: Use clk_set_rate from meson_mux_set_rate https://source.denx.de/u-boot/custodians/u-boot-amlogic/-/commit/99bd1d3f515842e8801d6c8cfd556077b9ba219b [4/9] clk: meson: Use soc-specific naming for common functions https://source.denx.de/u-boot/custodians/u-boot-amlogic/-/commit/1f615257213246dc741416b3e92a4e9e76d76d5f [5/9] clk: meson: Export a1 functions to common file https://source.denx.de/u-boot/custodians/u-boot-amlogic/-/commit/5dadc8a09b07f2bfa9bbf0d151b660c0beb92a90 [6/9] clk: meson: Support fractional fixed-factor clocks https://source.denx.de/u-boot/custodians/u-boot-amlogic/-/commit/538d95ef9ed6413dbd735ca799dfad2fe8c6e001 [7/9] clk: meson: Support power-of-two dividers https://source.denx.de/u-boot/custodians/u-boot-amlogic/-/commit/10176b815d013d8825fd243ae20892cae35c249f [8/9] clk: meson: Add s4 clock driver https://source.denx.de/u-boot/custodians/u-boot-amlogic/-/commit/5363c69e08d0f96834f4d80dcf23e11d64cfd80a [9/9] meson: Add Khadas VIM1S support https://source.denx.de/u-boot/custodians/u-boot-amlogic/-/commit/9c048da44bed99311355450d70840bb0795e21f8
Signature · 1 line
Neil