Hi Leith,

I have a better example for reference:
arch/mips/mach-mtmips

ARCH_MTMIPS is defined for the entire MediaTek MIPS platform, same as
ARCH_MEDIATEK.

The mtmips then defined its SoC families:
SOC_MT7620, SOC_MT7621 and SOC_MT7628

Each SoC has its own folder and Kconfig, e.g.:
arch/mips/mach-mtmips/mt7620/Kconfig

Every SoC then defined its own boards, e.g.:
BOARD_MT7620_RFB and BOARD_MT7620_MT7530_RFB

So you can define configs like SOC_MT7622 (not just MT7622), and treat
TARGET_MT7622 as a board, selecting SOC_MT7622. This will make sure
all mediatek chips have unified SOC_MTxxxx

Other device driver can then be changed to depend on SOC_MTxxxx

Best Regards,
Weijie

On Wed, 2024-07-03 at 18:40 +1000, Leith Bade wrote:
>        
>  The current MediaTek Kconfig layout prevents the addition of new
> board
> targets that require the existing SoC drivers.
> 
> By making the SoC drivers depend on new CONFIG_MTxxxx variables, it
> becomes possible to select these drivers when adding new boards to
> the
> board selection list. The existing TARGET_MTxxxx are then changed to
> select the correct SoC driver targets and can continue to be used as
> a
> generic target.
> 
> Signed-off-by: Leith Bade <le...@bade.nz>
> Cc: Chunfeng Yun <chunfeng....@mediatek.com>
> Cc: Ryder Lee <ryder....@mediatek.com>
> Cc: Weijie Gao <weijie....@mediatek.com>
> Cc: Sam Shih <sam.s...@mediatek.com>
> ---
> This is my first U-boot patch so I apologise in advance if I am doing
> something wrong.
> 
> There seems to be a number of different ways to organise the Kconfig
> file to support multiple boards using the same CPU. So picked an
> approach
> that required the least number of changes.
> 
> My motivation was to be able to add files under a new
> board/bananapi/bpi-r3 directory for the Banana Pi BPI-R3 board so I
> can
> add a .env file to set up the required values for the "Standard
> Boot".
> 
> If this change is accepted I plan to follow up with future patches to
> add this .env file.
> 
>  arch/arm/mach-mediatek/Kconfig  | 43
> ++++++++++++++++++++++++++++++++-
>  arch/arm/mach-mediatek/Makefile | 20 +++++++--------
>  drivers/clk/mediatek/Makefile   | 20 +++++++--------
>  drivers/ram/mediatek/Makefile   |  2 +-
>  4 files changed, 63 insertions(+), 22 deletions(-)
> 
> diff --git a/arch/arm/mach-mediatek/Kconfig b/arch/arm/mach-
> mediatek/Kconfig
> index ff1fdee5c8..4b4faad8b4 100644
> --- a/arch/arm/mach-mediatek/Kconfig
> +++ b/arch/arm/mach-mediatek/Kconfig
> @@ -6,8 +6,38 @@ config SYS_SOC
>  config SYS_VENDOR
>       default "mediatek"
>  
> +config MT7622
> +     bool
> +
> +config MT7623
> +     bool
> +
> +config MT7629
> +     bool
> +
> +config MT7981
> +     bool
> +
> +config MT7986
> +     bool
> +
> +config MT7988
> +     bool
> +
> +config MT8183
> +     bool
> +
> +config MT8365
> +        bool
> +
>  config MT8512
> -     bool "MediaTek MT8512 SoC"
> +     bool
> +
> +config MT8516
> +     bool
> +
> +config MT8518
> +     bool
>  
>  choice
>       prompt "MediaTek board select"
> @@ -15,6 +45,7 @@ choice
>  config TARGET_MT7622
>       bool "MediaTek MT7622 SoC"
>       select ARM64
> +     select MT7622
>       help
>         The MediaTek MT7622 is a ARM64-based SoC with a dual-core
> Cortex-A53.
>         including UART, SPI, USB3.0, SD and MMC cards, NAND, SNFI,
> PWM, PCIe,
> @@ -24,6 +55,7 @@ config TARGET_MT7623
>       bool "MediaTek MT7623 SoC"
>       select CPU_V7A
>       select MMC_SUPPORTS_TUNING
> +     select MT7623
>       help
>         The MediaTek MT7623 is a ARM-based SoC with a quad-core
> Cortex-A7
>         including NEON and GPU, Mali-450 graphics, several DDR3
> options,
> @@ -36,6 +68,7 @@ config TARGET_MT7629
>       bool "MediaTek MT7629 SoC"
>       select CPU_V7A
>       select SPL
> +     select MT7629
>       help
>         The MediaTek MT7629 is a ARM-based SoC with a dual-core
> Cortex-A7
>         including DDR3, crypto engine, 3x3 11n/ac Wi-Fi, Gigabit
> Ethernet,
> @@ -45,6 +78,7 @@ config TARGET_MT7981
>       bool "MediaTek MT7981 SoC"
>       select ARM64
>       select CPU
> +     select MT7981
>       help
>         The MediaTek MT7981 is a ARM64-based SoC with a dual-core
> Cortex-A53.
>         including UART, SPI, USB, NAND, SNFI, PWM, Gigabit Ethernet,
> I2C,
> @@ -54,6 +88,7 @@ config TARGET_MT7986
>       bool "MediaTek MT7986 SoC"
>       select ARM64
>       select CPU
> +     select MT7986
>       help
>         The MediaTek MT7986 is a ARM64-based SoC with a quad-core
> Cortex-A53.
>         including UART, SPI, SPI flash, USB3.0, MMC, NAND, SNFI, PWM,
> PCIe,
> @@ -63,6 +98,7 @@ config TARGET_MT7988
>       bool "MediaTek MT7988 SoC"
>       select ARM64
>       select CPU
> +     select MT7988
>       help
>         The MediaTek MT7988 is a ARM64-based SoC with a quad-core
> Cortex-A73.
>         including UART, SPI, SPI flash, USB3.0, MMC, NAND, SNFI, PWM,
> PCIe,
> @@ -71,6 +107,7 @@ config TARGET_MT7988
>  config TARGET_MT8183
>       bool "MediaTek MT8183 SoC"
>       select ARM64
> +     select MT8183
>       help
>         The MediaTek MT8183 is a ARM64-based SoC with a quad-core
> Cortex-A73 and
>         a quad-core Cortex-A53. It is including UART, SPI, USB3.0
> dual role,
> @@ -80,6 +117,7 @@ config TARGET_MT8183
>  config TARGET_MT8365
>       bool "MediaTek MT8365 SoC"
>       select ARM64
> +     select MT8365
>       help
>         The MediaTek MT8365 is a ARM64-based SoC with a quad-core
> Cortex-A53.
>         It is including UART, SPI, USB2.0 dual role, SD and MMC
> cards, NAND, PWM,
> @@ -98,6 +136,7 @@ config TARGET_MT8512
>  config TARGET_MT8516
>       bool "MediaTek MT8516 SoC"
>       select ARM64
> +     select MT8516
>       help
>         The MediaTek MT8516 is a ARM64-based SoC with a quad-core
> Cortex-A35.
>         including UART, SPI, USB2.0 and OTG, SD and MMC cards, NAND,
> PWM,
> @@ -107,6 +146,7 @@ config TARGET_MT8516
>  config TARGET_MT8518
>       bool "MediaTek MT8518 SoC"
>       select ARM64
> +     select MT8518
>       help
>         The MediaTek MT8518 is a ARM64-based SoC with a quad-core
> Cortex-A53.
>         including UART, SPI, USB2.0 and OTG, SD and MMC cards, NAND,
> PWM,
> @@ -124,6 +164,7 @@ config SYS_BOARD
>       default "mt7986" if TARGET_MT7986
>       default "mt7988" if TARGET_MT7988
>       default "mt8183" if TARGET_MT8183
> +        default "mt8365" if TARGET_MT8365
>       default "mt8512" if TARGET_MT8512
>       default "mt8516" if TARGET_MT8516
>       default "mt8518" if TARGET_MT8518
> diff --git a/arch/arm/mach-mediatek/Makefile b/arch/arm/mach-
> mediatek/Makefile
> index 46bdab8820..c32f78f82b 100644
> --- a/arch/arm/mach-mediatek/Makefile
> +++ b/arch/arm/mach-mediatek/Makefile
> @@ -3,14 +3,14 @@
>  obj-y        += cpu.o
>  obj-$(CONFIG_SPL_BUILD)      += spl.o
>  
> +obj-$(CONFIG_MT7622) += mt7622/
> +obj-$(CONFIG_MT7623) += mt7623/
> +obj-$(CONFIG_MT7629) += mt7629/
> +obj-$(CONFIG_MT7981) += mt7981/
> +obj-$(CONFIG_MT7986) += mt7986/
> +obj-$(CONFIG_MT7988) += mt7988/
> +obj-$(CONFIG_MT8183) += mt8183/
> +obj-$(TARGET_MT8365) += mt8365/
>  obj-$(CONFIG_MT8512) += mt8512/
> -obj-$(CONFIG_TARGET_MT7622) += mt7622/
> -obj-$(CONFIG_TARGET_MT7623) += mt7623/
> -obj-$(CONFIG_TARGET_MT7629) += mt7629/
> -obj-$(CONFIG_TARGET_MT7981) += mt7981/
> -obj-$(CONFIG_TARGET_MT7986) += mt7986/
> -obj-$(CONFIG_TARGET_MT7988) += mt7988/
> -obj-$(CONFIG_TARGET_MT8183) += mt8183/
> -obj-$(CONFIG_TARGET_MT8365) += mt8365/
> -obj-$(CONFIG_TARGET_MT8516) += mt8516/
> -obj-$(CONFIG_TARGET_MT8518) += mt8518/
> +obj-$(CONFIG_MT8516) += mt8516/
> +obj-$(CONFIG_MT8518) += mt8518/
> diff --git a/drivers/clk/mediatek/Makefile
> b/drivers/clk/mediatek/Makefile
> index e631f79e4d..62e26de5e0 100644
> --- a/drivers/clk/mediatek/Makefile
> +++ b/drivers/clk/mediatek/Makefile
> @@ -3,14 +3,14 @@
>  obj-$(CONFIG_ARCH_MEDIATEK) += clk-mtk.o
>  
>  # SoC Drivers
> +obj-$(CONFIG_MT7623) += clk-mt7623.o
> +obj-$(CONFIG_MT7622) += clk-mt7622.o
> +obj-$(CONFIG_MT7629) += clk-mt7629.o
> +obj-$(CONFIG_MT7986) += clk-mt7986.o
> +obj-$(CONFIG_MT7981) += clk-mt7981.o
> +obj-$(CONFIG_MT7988) += clk-mt7988.o
> +obj-$(CONFIG_MT8183) += clk-mt8183.o
> +obj-$(CONFIG_MT8365) += clk-mt8365.o
>  obj-$(CONFIG_MT8512) += clk-mt8512.o
> -obj-$(CONFIG_TARGET_MT7623) += clk-mt7623.o
> -obj-$(CONFIG_TARGET_MT7622) += clk-mt7622.o
> -obj-$(CONFIG_TARGET_MT7629) += clk-mt7629.o
> -obj-$(CONFIG_TARGET_MT7986) += clk-mt7986.o
> -obj-$(CONFIG_TARGET_MT7981) += clk-mt7981.o
> -obj-$(CONFIG_TARGET_MT7988) += clk-mt7988.o
> -obj-$(CONFIG_TARGET_MT8183) += clk-mt8183.o
> -obj-$(CONFIG_TARGET_MT8365) += clk-mt8365.o
> -obj-$(CONFIG_TARGET_MT8516) += clk-mt8516.o
> -obj-$(CONFIG_TARGET_MT8518) += clk-mt8518.o
> +obj-$(CONFIG_MT8516) += clk-mt8516.o
> +obj-$(CONFIG_MT8518) += clk-mt8518.o
> diff --git a/drivers/ram/mediatek/Makefile
> b/drivers/ram/mediatek/Makefile
> index 95507b593c..71f2c4fe83 100644
> --- a/drivers/ram/mediatek/Makefile
> +++ b/drivers/ram/mediatek/Makefile
> @@ -4,4 +4,4 @@
>  # SPDX-License-Identifier:      GPL-2.0
>  #
>  
> -obj-$(CONFIG_TARGET_MT7629) = ddr3-mt7629.o
> +obj-$(CONFIG_MT7629) = ddr3-mt7629.o
> -- 
> 2.25.1

Reply via email to