mbox series

[00/19] sunxi: SPL cleanup part 1

Message ID 20240103001239.17482-1-andre.przywara@arm.com
Headers show
Series sunxi: SPL cleanup part 1 | expand

Message

Andre Przywara Jan. 3, 2024, 12:12 a.m. UTC
This is the first part of a series to clean up the Allwinner SPL a bit.
One big driver for this whole clean up is to eventually accommodate the
RISC-V chips, which share most platform devices, but cannot use any code
that currently lives under arch/arm. So the idea is to disentangle the
code, to get a cleaner separation between ARM specific and platform
specific code. Another related reason is that the RISC-V port aims to
use a DM SPL, so we want to split off code bits that won't be needed when
we have the DM framework in the SPL.

This first part of the series is mostly preparation, and some smaller
cleanups, of code that was around for a long time and missed some
updates.
We start with some removal of no longer needed definitions, in the first
seven patches. The next seven patches tighten the SPL clock code: quite
some functions were compiled for U-Boot proper, however were not needed
there. Sorting this out helps to identify legacy code.
The final five patches move the SPL pinmux setup code into separate
functions and files, and convert the #ifdef hell into proper C "if"
statements.

It would be great if Samuel can have a look and say whether this is
helpful or not. For instance I don't really know how much of the SPL
clock code will be needed for the RISC-V port, since we don't really
model the bus clocks in the DT at all, and currently don't support PLLs
in the DM clock code.

Much of this first series should be good regardless, for instance the
replacement of #ifdef's with C "if" statements, since that became
tedious to expand for new SoCs and boards. But if some parts should live
in a different directory, or should be grouped differently, this can
certainly be factored in.

Please have a look, review and test!

Cheers,
Andre

Andre Przywara (19):
  sunxi: cleanup sunxi-common.h
  sunxi: sun50i-h6: remove unneeded base addresses from header
  sunxi: sun4i: remove unneeded base addresses from header
  sunxi: sun9i: remove unneeded base addresses from header
  sunxi: move #ifdef guards around tzpc_init() to header file
  sunxi: remove common.h inclusion
  sunxi: simplify U-Boot proper only builds
  sunxi: remove unneeded i2c_init_board() call for U-Boot proper
  sunxi: compile clock.c for SPL only
  sunxi: sun4i: make more clock functions SPL only
  sunxi: sun6i: make more clock functions SPL only
  sunxi: sun50i_h6: make more clock functions SPL only
  sunxi: sun8i_a83t: make more clock functions SPL only
  sunxi: sun9i: make more clock functions SPL only
  sunxi: move pinmux setup into separate SPL only file
  sunxi: SPL pinmux: rewrite without #ifdefs
  sunxi: move UART pinmux setup into separate file
  sunxi: SPL pinmux: split out UART pinmux per port
  sunxi: SPL pinmux: rewrite UART setup without #ifdefs

 arch/arm/Kconfig                              |   4 +-
 arch/arm/include/asm/arch-sunxi/clock_sun9i.h |   3 -
 arch/arm/include/asm/arch-sunxi/cpu_sun4i.h   |  47 ---
 .../include/asm/arch-sunxi/cpu_sun50i_h6.h    |  21 --
 arch/arm/include/asm/arch-sunxi/cpu_sun9i.h   |  41 ---
 arch/arm/include/asm/arch-sunxi/tzpc.h        |   6 +
 arch/arm/mach-sunxi/Kconfig                   |  16 +-
 arch/arm/mach-sunxi/Makefile                  |   4 +-
 arch/arm/mach-sunxi/board.c                   | 113 +------
 arch/arm/mach-sunxi/clock.c                   |   3 -
 arch/arm/mach-sunxi/clock_sun4i.c             |   6 +-
 arch/arm/mach-sunxi/clock_sun50i_h6.c         |  58 ++--
 arch/arm/mach-sunxi/clock_sun6i.c             |   4 +-
 arch/arm/mach-sunxi/clock_sun8i_a83t.c        |   6 +-
 arch/arm/mach-sunxi/clock_sun9i.c             |  98 +++---
 arch/arm/mach-sunxi/cpu_info.c                |   1 -
 arch/arm/mach-sunxi/dram_helpers.c            |   3 +-
 arch/arm/mach-sunxi/dram_sun4i.c              |   1 -
 arch/arm/mach-sunxi/dram_sun50i_h6.c          |   1 -
 arch/arm/mach-sunxi/dram_sun50i_h616.c        |   1 -
 arch/arm/mach-sunxi/dram_sun6i.c              |   1 -
 arch/arm/mach-sunxi/dram_sun8i_a23.c          |   1 -
 arch/arm/mach-sunxi/dram_sun8i_a33.c          |   1 -
 arch/arm/mach-sunxi/dram_sun8i_a83t.c         |   1 -
 arch/arm/mach-sunxi/dram_sun9i.c              |   1 -
 arch/arm/mach-sunxi/dram_suniv.c              |   2 +-
 arch/arm/mach-sunxi/dram_sunxi_dw.c           |   1 -
 arch/arm/mach-sunxi/gtbus_sun9i.c             |   1 -
 arch/arm/mach-sunxi/pmic_bus.c                |   1 -
 arch/arm/mach-sunxi/prcm.c                    |   1 -
 arch/arm/mach-sunxi/spl_pinmux.c              | 312 +++++++++++++++++
 arch/arm/mach-sunxi/spl_spi_sunxi.c           |   1 -
 arch/arm/mach-sunxi/timer.c                   |   1 -
 arch/arm/mach-sunxi/uart_pinmux.c             | 158 +++++++++
 board/sunxi/board.c                           | 318 +-----------------
 include/configs/sunxi-common.h                |  56 +--
 36 files changed, 592 insertions(+), 702 deletions(-)
 create mode 100644 arch/arm/mach-sunxi/spl_pinmux.c
 create mode 100644 arch/arm/mach-sunxi/uart_pinmux.c

Comments

Andre Przywara Jan. 17, 2024, 1:52 p.m. UTC | #1
On Wed,  3 Jan 2024 00:12:20 +0000
Andre Przywara <andre.przywara@arm.com> wrote:

Hi,

> This is the first part of a series to clean up the Allwinner SPL a bit.

will anyone have a chance to look at this?

I compiled patches 1-4,6,7 for all sunxi boards and the resulting binaries
were identical compared to the base, so if no one screams, I would like to
merge those 6 patches ASAP.

The other patches can surely wait, though I would be glad if someone would
have a look and could confirm if that goes into the right direction in
general.

Cheers,
Andre

> One big driver for this whole clean up is to eventually accommodate the
> RISC-V chips, which share most platform devices, but cannot use any code
> that currently lives under arch/arm. So the idea is to disentangle the
> code, to get a cleaner separation between ARM specific and platform
> specific code. Another related reason is that the RISC-V port aims to
> use a DM SPL, so we want to split off code bits that won't be needed when
> we have the DM framework in the SPL.
> 
> This first part of the series is mostly preparation, and some smaller
> cleanups, of code that was around for a long time and missed some
> updates.
> We start with some removal of no longer needed definitions, in the first
> seven patches. The next seven patches tighten the SPL clock code: quite
> some functions were compiled for U-Boot proper, however were not needed
> there. Sorting this out helps to identify legacy code.
> The final five patches move the SPL pinmux setup code into separate
> functions and files, and convert the #ifdef hell into proper C "if"
> statements.
> 
> It would be great if Samuel can have a look and say whether this is
> helpful or not. For instance I don't really know how much of the SPL
> clock code will be needed for the RISC-V port, since we don't really
> model the bus clocks in the DT at all, and currently don't support PLLs
> in the DM clock code.
> 
> Much of this first series should be good regardless, for instance the
> replacement of #ifdef's with C "if" statements, since that became
> tedious to expand for new SoCs and boards. But if some parts should live
> in a different directory, or should be grouped differently, this can
> certainly be factored in.
> 
> Please have a look, review and test!
> 
> Cheers,
> Andre
> 
> Andre Przywara (19):
>   sunxi: cleanup sunxi-common.h
>   sunxi: sun50i-h6: remove unneeded base addresses from header
>   sunxi: sun4i: remove unneeded base addresses from header
>   sunxi: sun9i: remove unneeded base addresses from header
>   sunxi: move #ifdef guards around tzpc_init() to header file
>   sunxi: remove common.h inclusion
>   sunxi: simplify U-Boot proper only builds
>   sunxi: remove unneeded i2c_init_board() call for U-Boot proper
>   sunxi: compile clock.c for SPL only
>   sunxi: sun4i: make more clock functions SPL only
>   sunxi: sun6i: make more clock functions SPL only
>   sunxi: sun50i_h6: make more clock functions SPL only
>   sunxi: sun8i_a83t: make more clock functions SPL only
>   sunxi: sun9i: make more clock functions SPL only
>   sunxi: move pinmux setup into separate SPL only file
>   sunxi: SPL pinmux: rewrite without #ifdefs
>   sunxi: move UART pinmux setup into separate file
>   sunxi: SPL pinmux: split out UART pinmux per port
>   sunxi: SPL pinmux: rewrite UART setup without #ifdefs
> 
>  arch/arm/Kconfig                              |   4 +-
>  arch/arm/include/asm/arch-sunxi/clock_sun9i.h |   3 -
>  arch/arm/include/asm/arch-sunxi/cpu_sun4i.h   |  47 ---
>  .../include/asm/arch-sunxi/cpu_sun50i_h6.h    |  21 --
>  arch/arm/include/asm/arch-sunxi/cpu_sun9i.h   |  41 ---
>  arch/arm/include/asm/arch-sunxi/tzpc.h        |   6 +
>  arch/arm/mach-sunxi/Kconfig                   |  16 +-
>  arch/arm/mach-sunxi/Makefile                  |   4 +-
>  arch/arm/mach-sunxi/board.c                   | 113 +------
>  arch/arm/mach-sunxi/clock.c                   |   3 -
>  arch/arm/mach-sunxi/clock_sun4i.c             |   6 +-
>  arch/arm/mach-sunxi/clock_sun50i_h6.c         |  58 ++--
>  arch/arm/mach-sunxi/clock_sun6i.c             |   4 +-
>  arch/arm/mach-sunxi/clock_sun8i_a83t.c        |   6 +-
>  arch/arm/mach-sunxi/clock_sun9i.c             |  98 +++---
>  arch/arm/mach-sunxi/cpu_info.c                |   1 -
>  arch/arm/mach-sunxi/dram_helpers.c            |   3 +-
>  arch/arm/mach-sunxi/dram_sun4i.c              |   1 -
>  arch/arm/mach-sunxi/dram_sun50i_h6.c          |   1 -
>  arch/arm/mach-sunxi/dram_sun50i_h616.c        |   1 -
>  arch/arm/mach-sunxi/dram_sun6i.c              |   1 -
>  arch/arm/mach-sunxi/dram_sun8i_a23.c          |   1 -
>  arch/arm/mach-sunxi/dram_sun8i_a33.c          |   1 -
>  arch/arm/mach-sunxi/dram_sun8i_a83t.c         |   1 -
>  arch/arm/mach-sunxi/dram_sun9i.c              |   1 -
>  arch/arm/mach-sunxi/dram_suniv.c              |   2 +-
>  arch/arm/mach-sunxi/dram_sunxi_dw.c           |   1 -
>  arch/arm/mach-sunxi/gtbus_sun9i.c             |   1 -
>  arch/arm/mach-sunxi/pmic_bus.c                |   1 -
>  arch/arm/mach-sunxi/prcm.c                    |   1 -
>  arch/arm/mach-sunxi/spl_pinmux.c              | 312 +++++++++++++++++
>  arch/arm/mach-sunxi/spl_spi_sunxi.c           |   1 -
>  arch/arm/mach-sunxi/timer.c                   |   1 -
>  arch/arm/mach-sunxi/uart_pinmux.c             | 158 +++++++++
>  board/sunxi/board.c                           | 318 +-----------------
>  include/configs/sunxi-common.h                |  56 +--
>  36 files changed, 592 insertions(+), 702 deletions(-)
>  create mode 100644 arch/arm/mach-sunxi/spl_pinmux.c
>  create mode 100644 arch/arm/mach-sunxi/uart_pinmux.c
>