sunxi: Initial A80 support
Subsystems (4)
Hi Ian, ChenYu,
I'm very happy to present this patch series which adds initial A80 support, with this series a u-boot.bin can be build which can then be fel booted using Allwinners boot0 fel binary, and then can load linux from a sdcard using a standard extlinux.conf setup.
Next step getting RSB going and finding out how the 2 pmics are hooked up, and then slowly work towards getting SPL going.
Ian, as always, can you please review these patches ?
ChenYu, if you want to play with this, it is probably easiest to use my sunxi-wip branch.
Regards,
Hans
PATCH 1/12 sunxi: Drop pll6 setting from clock_init_uart
As the comment says now that we have SPL support this is no longer necessary, as PLL6 is already setup with the exact same parameters by the SPL.
--- arch/arm/cpu/armv7/sunxi/clock_sun6i.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-)
arch/arm/cpu/armv7/sunxi/clock_sun6i.c +1 -4
@@ -45,10 +45,10 @@ void clock_init_safe(void)void clock_init_uart (void ) { +#if CONFIG_CONS_INDEX <5 struct sunxi_ccm_reg *const ccm = (struct sunxi_ccm_reg *)SUNXI_CCM_BASE ; -#if CONFIG_CONS_INDEX <5 /* uart clock source is apb2 */ writel(APB2_CLK_SRC_OSC24M| APB2_CLK_RATE_N_1|
@@ -68,9 +68,6 @@ void clock_init_uart(void)/* enable R_PIO and R_UART clocks, and de-assert resets */ prcm_apb0_enable (PRCM_APB0_GATE_PIO |PRCM_APB0_GATE_UART );#endif - -/* Dup with clock_init_safe(), drop once sun6i SPL support lands */ -writel (PLL6_CFG_DEFAULT , &ccm->pll6_cfg); }int clock_twi_onoff (int port,int state)
Signature · 1 line
2.1.0
PATCH 1/12 sunxi: Drop pll6 setting from clock_init_uart
Quoted 4 lines · Hans de Goede
As the comment says now that we have SPL support this is no longer necessary, as PLL6 is already setup with the exact same parameters by the SPL.
Signed-off-by Hans de Goede <[email protected]>
PATCH 2/12 sunxi: Rename cpu.h to cpu_sun4i.h
In reply to Hans de Goedesun4i - sun8i have (aprox.) the same iomem layout, but sun9i is quite different, so add a wrapper cpu.h which includes the right mach specific cpu_sun#i.h based on mach, like we already do with clock.h and dram.h .
Note for reviewers, cpu.h is effectively renamed tp cpu_sun4i.h by this commit, the only change is the #ifndef ... #endif guard around the file.
--- arch/arm/include/asm/arch-sunxi/cpu.h | 148 +------------------------- arch/arm/include/asm/arch-sunxi/cpu_sun4i.h | 154 ++++++++++++++++++++++++++++ 2 files changed, 157 insertions(+), 145 deletions(-) create mode 100644 arch/arm/include/asm/arch-sunxi/cpu_sun4i.h
arch/arm/include/asm/arch-sunxi/cpu.h +3 -145
@@ -1,7 +1,5 @@/* -* (C) Copyright 2007-2011 -* Allwinner Technology Co., Ltd. <www.allwinnertech.com> -* Tom Cubie <[email protected]> +* (C) Copyright 2015 Hans de Goede <[email protected]> * * SPDX-License-Identifier: GPL-2.0+ */
@@ -9,146 +7,6 @@#ifndef _SUNXI_CPU_H#define _SUNXI_CPU_H -#define SUNXI_SRAM_A1_BASE 0x00000000 -#define SUNXI_SRAM_A1_SIZE (16 * 1024)/* 16 kiB */ +#include <asm/arch/cpu_sun4i.h> -#define SUNXI_SRAM_A2_BASE 0x00004000/* 16 kiB */ -#define SUNXI_SRAM_A3_BASE 0x00008000/* 13 kiB */ -#define SUNXI_SRAM_A4_BASE 0x0000b400/* 3 kiB */ -#define SUNXI_SRAM_D_BASE 0x00010000/* 4 kiB */ -#define SUNXI_SRAM_B_BASE 0x00020000/* 64 kiB (secure) */ - -#define SUNXI_SRAMC_BASE 0x01c00000 -#define SUNXI_DRAMC_BASE 0x01c01000 -#define SUNXI_DMA_BASE 0x01c02000 -#define SUNXI_NFC_BASE 0x01c03000 -#define SUNXI_TS_BASE 0x01c04000 -#define SUNXI_SPI0_BASE 0x01c05000 -#define SUNXI_SPI1_BASE 0x01c06000 -#define SUNXI_MS_BASE 0x01c07000 -#define SUNXI_TVD_BASE 0x01c08000 -#define SUNXI_CSI0_BASE 0x01c09000 -#define SUNXI_TVE0_BASE 0x01c0a000 -#define SUNXI_EMAC_BASE 0x01c0b000 -#define SUNXI_LCD0_BASE 0x01c0C000 -#define SUNXI_LCD1_BASE 0x01c0d000 -#define SUNXI_VE_BASE 0x01c0e000 -#define SUNXI_MMC0_BASE 0x01c0f000 -#define SUNXI_MMC1_BASE 0x01c10000 -#define SUNXI_MMC2_BASE 0x01c11000 -#define SUNXI_MMC3_BASE 0x01c12000 -#if !definedCONFIG_MACH_SUN6I && !definedCONFIG_MACH_SUN8I -#define SUNXI_USB0_BASE 0x01c13000 -#define SUNXI_USB1_BASE 0x01c14000 -#endif -#define SUNXI_SS_BASE 0x01c15000 -#define SUNXI_HDMI_BASE 0x01c16000 -#define SUNXI_SPI2_BASE 0x01c17000 -#define SUNXI_SATA_BASE 0x01c18000 -#if !definedCONFIG_MACH_SUN6I && !definedCONFIG_MACH_SUN8I -#define SUNXI_PATA_BASE 0x01c19000 -#define SUNXI_ACE_BASE 0x01c1a000 -#define SUNXI_TVE1_BASE 0x01c1b000 -#define SUNXI_USB2_BASE 0x01c1c000 -#else -#define SUNXI_USB0_BASE 0x01c19000 -#define SUNXI_USB1_BASE 0x01c1a000 -#define SUNXI_USB2_BASE 0x01c1b000 -#endif -#define SUNXI_CSI1_BASE 0x01c1d000 -#define SUNXI_TZASC_BASE 0x01c1e000 -#define SUNXI_SPI3_BASE 0x01c1f000 - -#define SUNXI_CCM_BASE 0x01c20000 -#define SUNXI_INTC_BASE 0x01c20400 -#define SUNXI_PIO_BASE 0x01c20800 -#define SUNXI_TIMER_BASE 0x01c20c00 -#define SUNXI_SPDIF_BASE 0x01c21000 -#define SUNXI_AC97_BASE 0x01c21400 -#define SUNXI_IR0_BASE 0x01c21800 -#define SUNXI_IR1_BASE 0x01c21c00 - -#define SUNXI_IIS_BASE 0x01c22400 -#define SUNXI_LRADC_BASE 0x01c22800 -#define SUNXI_AD_DA_BASE 0x01c22c00 -#define SUNXI_KEYPAD_BASE 0x01c23000 -#define SUNXI_TZPC_BASE 0x01c23400 -#define SUNXI_SID_BASE 0x01c23800 -#define SUNXI_SJTAG_BASE 0x01c23c00 - -#define SUNXI_TP_BASE 0x01c25000 -#define SUNXI_PMU_BASE 0x01c25400 -#define SUN7I_CPUCFG_BASE 0x01c25c00 - -#define SUNXI_UART0_BASE 0x01c28000 -#define SUNXI_UART1_BASE 0x01c28400 -#define SUNXI_UART2_BASE 0x01c28800 -#define SUNXI_UART3_BASE 0x01c28c00 -#define SUNXI_UART4_BASE 0x01c29000 -#define SUNXI_UART5_BASE 0x01c29400 -#define SUNXI_UART6_BASE 0x01c29800 -#define SUNXI_UART7_BASE 0x01c29c00 -#define SUNXI_PS2_0_BASE 0x01c2a000 -#define SUNXI_PS2_1_BASE 0x01c2a400 - -#define SUNXI_TWI0_BASE 0x01c2ac00 -#define SUNXI_TWI1_BASE 0x01c2b000 -#define SUNXI_TWI2_BASE 0x01c2b400 - -#define SUNXI_CAN_BASE 0x01c2bc00 - -#define SUNXI_SCR_BASE 0x01c2c400 - -#ifndef CONFIG_MACH_SUN6I -#define SUNXI_GPS_BASE 0x01c30000 -#define SUNXI_MALI400_BASE 0x01c40000 -#define SUNXI_GMAC_BASE 0x01c50000 -#else -#define SUNXI_GMAC_BASE 0x01c30000 -#endif - -#define SUNXI_DRAM_COM_BASE 0x01c62000 -#define SUNXI_DRAM_CTL0_BASE 0x01c63000 -#define SUNXI_DRAM_CTL1_BASE 0x01c64000 -#define SUNXI_DRAM_PHY0_BASE 0x01c65000 -#define SUNXI_DRAM_PHY1_BASE 0x01c66000 - -/* module sram */ -#define SUNXI_SRAM_C_BASE 0x01d00000 - -#define SUNXI_DE_FE0_BASE 0x01e00000 -#define SUNXI_DE_FE1_BASE 0x01e20000 -#define SUNXI_DE_BE0_BASE 0x01e60000 -#define SUNXI_DE_BE1_BASE 0x01e40000 -#define SUNXI_MP_BASE 0x01e80000 -#define SUNXI_AVG_BASE 0x01ea0000 - -#define SUNXI_RTC_BASE 0x01f00000 -#define SUNXI_PRCM_BASE 0x01f01400 -#define SUN6I_CPUCFG_BASE 0x01f01c00 -#define SUNXI_R_UART_BASE 0x01f02800 -#define SUNXI_R_PIO_BASE 0x01f02c00 -#define SUN6I_P2WI_BASE 0x01f03400 -#define SUNXI_RSB_BASE 0x01f03400 - -/* CoreSight Debug Module */ -#define SUNXI_CSDM_BASE 0x3f500000 - -#define SUNXI_DDRII_DDRIII_BASE 0x40000000/* 2 GiB */ - -#define SUNXI_BROM_BASE 0xffff0000/* 32 kiB */ - -#define SUNXI_CPU_CFG (SUNXI_TIMER_BASE + 0x13c) - -/* SS bonding ids used for cpu identification */ -#define SUNXI_SS_BOND_ID_A31 4 -#define SUNXI_SS_BOND_ID_A31S 5 - -#ifndef __ASSEMBLY__ -void sunxi_board_init (void ); -void sunxi_reset (void ); -int sunxi_get_ss_bonding_id (void ); -int sunxi_get_sid (unsigned int *sid); -#endif /* __ASSEMBLY__ */ - -#endif /* _CPU_H */ +#endif /* _SUNXI_CPU_H */
arch/arm/include/asm/arch-sunxi/cpu_sun4i.h new file +154 -0
154 lines not on this page · raw message
Signature · 1 line
2.1.0
PATCH 2/12 sunxi: Rename cpu.h to cpu_sun4i.h
Quoted 6 lines · Hans de Goede
sun4i - sun8i have (aprox.) the same iomem layout, but sun9i is quite different, so add a wrapper
cpu.hwhich includes the right mach specific cpu_sun#i.h based on mach, like we already do withclock.handdram.h.Note for reviewers,
cpu.his effectively renamed tpcpu_sun4i.hby this commit, the only change is the #ifndef ... #endif guard around the file.
Using -M with git formate-patch/send-email really helps with this sort of thing (I've no idea why it's not the default...)
Quoted 1 line
Signed-off-by Hans de Goede <[email protected]>
PATCH 3/12 sunxi: Move clock_get_pllX / clock_set_pllX protos to mach specific headers
In reply to Hans de GoedeWhich pll-s are available depends on the machine type, move the clock_get_pllX / clock_set_pllX prototypes to the clock_sun?i.h header files so that we only declare what is actually available. e.g. clock_get_pll5p() is not available on sun6i / sun8i, and with sun9i we get a completely different set of plls.
--- arch/arm/include/asm/arch-sunxi/clock.h | 4 ---- arch/arm/include/asm/arch-sunxi/clock_sun4i.h | 7 +++++++ arch/arm/include/asm/arch-sunxi/clock_sun6i.h | 5 +++++ 3 files changed, 12 insertions(+), 4 deletions(-)
arch/arm/include/asm/arch-sunxi/clock.h +0 -4
@@ -24,10 +24,6 @@#ifndef __ASSEMBLY__int clock_init (void );int clock_twi_onoff (int port,int state); -void clock_set_pll1 (unsigned int hz); -void clock_set_pll3 (unsigned int hz); -unsigned int clock_get_pll5p (void ); -unsigned int clock_get_pll6 (void );void clock_set_de_mod_clock (u32 *clk_cfg,unsigned int hz);void clock_init_safe (void );void clock_init_uart (void );
arch/arm/include/asm/arch-sunxi/clock_sun4i.h +7 -0
@@ -320,4 +320,11 @@ struct sunxi_ccm_reg {#define CCM_DE_CTRL_RST (1 << 30)#define CCM_DE_CTRL_GATE (1 << 31) +#ifndef __ASSEMBLY__ +void clock_set_pll1 (unsigned int hz); +void clock_set_pll3 (unsigned int hz); +unsigned int clock_get_pll5p (void ); +unsigned int clock_get_pll6 (void ); +#endif +#endif /* _SUNXI_CLOCK_SUN4I_H */
arch/arm/include/asm/arch-sunxi/clock_sun6i.h +5 -0
@@ -320,6 +320,11 @@ struct sunxi_ccm_reg {#define CCM_DE_CTRL_PLL10 (5 << 24)#define CCM_DE_CTRL_GATE (1 << 31) +#ifndef __ASSEMBLY__ +void clock_set_pll1 (unsigned int hz); +void clock_set_pll3 (unsigned int hz);void clock_set_pll5 (unsigned int clk,bool sigma_delta_enable); +unsigned int clock_get_pll6 (void ); +#endif #endif /* _SUNXI_CLOCK_SUN6I_H */
Signature · 1 line
2.1.0
PATCH 3/12 sunxi: Move clock_get_pllX / clock_set_pllX protos to mach specific headers
Quoted 7 lines · Hans de Goede
Which pll-s are available depends on the machine type, move the
clock_get_pllX/clock_set_pllXprototypes to the clock_sun?i.h header files so that we only declare what is actually available. e.g.clock_get_pll5p()is not available on sun6i / sun8i, and with sun9i we get a completely different set of plls.Signed-off-by Hans de Goede <[email protected]>
PATCH 4/12 sunxi: Update sunxi-common.h to deal with different DRAM base addr on sun9i
In reply to Hans de GoedeThe DRAM Base differs between sun9i and the others and we cannot use math in various places like the environment setting and linker scripts, so "simply" define everything which contains the SDRAM_BASE twice.
--- include/configs/sunxi-common.h | 88 +++++++++++++++++++++++++++++------------- 1 file changed, 62 insertions(+), 26 deletions(-)
include/configs/sunxi-common.h +62 -26
@@ -25,7 +25,68 @@#include <asm/arch/cpu.h> /* get chip and board defs */ +/* +* The DRAM Base differs between sun9i and the others and we cannot use +* math in various places like the environment setting and linker scripts, +* so "simply" define everything which contains the SDRAM_BASE twice. +* +* Note we want to have everything identical except for the DRAM base address, +* when editing this, please keep everything in sync! +*/ + +#ifdef CONFIG_MACH_SUN9I + +#define CONFIG_SYS_SDRAM_BASE 0x20000000 +#define CONFIG_SYS_LOAD_ADDR 0x22000000 +#define CONFIG_SYS_TEXT_BASE 0x2a000000 +#define CONFIG_SYS_SPL_MALLOC_START 0x2ff00000 +#define CONFIG_SYS_SPL_MALLOC_SIZE 0x00080000/* 512 KiB */ +#define CONFIG_SPL_BSS_START_ADDR 0x2ff80000 +#define CONFIG_SPL_BSS_MAX_SIZE 0x00080000/* 512 KiB */ + +/* Use the room between the end of bootm_size and the framebuffer */ +#define CONFIG_PRE_CON_BUF_ADDR 0x2f000000 + +/* +* 240M RAM (256M minimum minus space for the framebuffer), +* 32M uncompressed kernel, 16M compressed kernel, 1M fdt, +* 1M script, 1M pxe and the ramdisk at the end. +*/ +#define MEM_LAYOUT_ENV_SETTINGS \ + "bootm_size=0xf000000\0" \ + "kernel_addr_r=0x22000000\0" \ + "fdt_addr_r=0x23000000\0" \ + "scriptaddr=0x23100000\0" \ + "pxefile_addr_r=0x23200000\0" \ + "ramdisk_addr_r=0x23300000\0" + +#else /* ifdef CONFIG_MACH_SUN9I */ + +#define CONFIG_SYS_SDRAM_BASE 0x40000000 +#define CONFIG_SYS_LOAD_ADDR 0x42000000#define CONFIG_SYS_TEXT_BASE 0x4a000000 +#define CONFIG_SYS_SPL_MALLOC_START 0x4ff00000 +#define CONFIG_SYS_SPL_MALLOC_SIZE 0x00080000/* 512 KiB */ +#define CONFIG_SPL_BSS_START_ADDR 0x4ff80000 +#define CONFIG_SPL_BSS_MAX_SIZE 0x00080000/* 512 KiB */ + +/* Use the room between the end of bootm_size and the framebuffer */ +#define CONFIG_PRE_CON_BUF_ADDR 0x4f000000 + +/* +* 240M RAM (256M minimum minus space for the framebuffer), +* 32M uncompressed kernel, 16M compressed kernel, 1M fdt, +* 1M script, 1M pxe and the ramdisk at the end. +*/ +#define MEM_LAYOUT_ENV_SETTINGS \ + "bootm_size=0xf000000\0" \ + "kernel_addr_r=0x42000000\0" \ + "fdt_addr_r=0x43000000\0" \ + "scriptaddr=0x43100000\0" \ + "pxefile_addr_r=0x43200000\0" \ + "ramdisk_addr_r=0x43300000\0" + +#endif #if !defined(CONFIG_SPL_BUILD ) && defined(CONFIG_DM )# define CONFIG_CMD_DM
@@ -54,8 +115,6 @@# define CONFIG_SYS_NS16550_COM5 SUNXI_R_UART_BASE#endif -/* DRAM Base */ -#define CONFIG_SYS_SDRAM_BASE 0x40000000#define CONFIG_SYS_INIT_RAM_ADDR 0x0#define CONFIG_SYS_INIT_RAM_SIZE 0x8000/* 32 KiB */
@@ -113,10 +172,8 @@/* Boot Argument Buffer Size */ #define CONFIG_SYS_BARGSIZE CONFIG_SYS_CBSIZE -#define CONFIG_SYS_LOAD_ADDR 0x42000000/* default load address */ -/* standalone support */ -#define CONFIG_STANDALONE_LOAD_ADDR 0x42000000 +#define CONFIG_STANDALONE_LOAD_ADDR CONFIG_SYS_LOAD_ADDR/* baudrate */ #define CONFIG_BAUDRATE 115200
@@ -153,9 +210,6 @@#else /* CONFIG_SPL */ -#define CONFIG_SPL_BSS_START_ADDR 0x4ff80000 -#define CONFIG_SPL_BSS_MAX_SIZE 0x80000/* 512 KiB */ -#define CONFIG_SPL_TEXT_BASE 0x20/* sram start+header */ #define CONFIG_SPL_MAX_SIZE 0x5fe0/* 24KB on sun4i/sun7i */
@@ -175,8 +229,6 @@/* end of 32 KiB in sram */ #define LOW_LEVEL_SRAM_STACK 0x00008000/* End of sram */ #define CONFIG_SPL_STACK LOW_LEVEL_SRAM_STACK -#define CONFIG_SYS_SPL_MALLOC_START 0x4ff00000 -#define CONFIG_SYS_SPL_MALLOC_SIZE 0x00080000/* 512 KiB */ /* I2C */ #define CONFIG_SPL_I2C_SUPPORT
@@ -283,22 +335,6 @@/* Enable pre-console buffer to get complete log on the VGA console */ #define CONFIG_PRE_CONSOLE_BUFFER #define CONFIG_PRE_CON_BUF_SZ (1024 * 1024) -/* Use the room between the end of bootm_size and the framebuffer */ -#define CONFIG_PRE_CON_BUF_ADDR 0x4f000000 - -/* -* 240M RAM (256M minimum minus space for the framebuffer), -* 32M uncompressed kernel, 16M compressed kernel, 1M fdt, -* 1M script, 1M pxe and the ramdisk at the end. -*/ -#define MEM_LAYOUT_ENV_SETTINGS \ - "bootm_size=0xf000000\0" \ - "kernel_addr_r=0x42000000\0" \ - "fdt_addr_r=0x43000000\0" \ - "scriptaddr=0x43100000\0" \ - "pxefile_addr_r=0x43200000\0" \ - "ramdisk_addr_r=0x43300000\0" -#ifdef CONFIG_MMC #define BOOT_TARGET_DEVICES_MMC (func) func(MMC, mmc, 0)#else
Signature · 1 line
2.1.0
PATCH 4/12 sunxi: Update sunxi-common.h to deal with different DRAM base addr on sun9i
Quoted 3 lines · Hans de Goede
The DRAM Base differs between sun9i and the others and we cannot use math in various places like the environment setting and linker scripts, so "simply" define everything which contains the
SDRAM_BASEtwice.
Is it really not possible to use maths in linker scripts? How have I never noticed that...
Anyway, given that things only differ in the most significant nibble of the RAM base address I think something like this might work:
/* NB: find out if one of these is already available somewhere */ #define __stringify(x) #x
#define stringify(x) __stringify(x)
#define SDRAM_OFFSET(x) 0x2##x /* or 0x4 */ #define CONFIG_SYS_SDRAM_BASE SDRAM_OFFSET(0000000)
#define MEM_LAYOUT_ENV_SETTINGS \
"kernel_addr_r=" stringify(SDRAM_OFFSET(200000)) "\0"
...Ian.
PATCH 4/12 sunxi: Update sunxi-common.h to deal with different DRAM base addr on sun9i
Hi,
Quoted 7 lines · Ian Campbell
Quoted 3 lines · Hans de Goede
The DRAM Base differs between sun9i and the others and we cannot use math in various places like the environment setting and linker scripts, so "simply" define everything which contains the
SDRAM_BASEtwice.Is it really not possible to use maths in linker scripts? How have I never noticed that...
I'm not 100% sure on that, I'm sure that it is not possible in the environment stuff, so I thought lets play it safe and just write it out fully for everything. I will drop the unconfirmed linker script reference from the commit message for v2
Quoted 8 lines
Anyway, given that things only differ in the most significant nibble of the RAM base address I think something like this might work:
/* NB: find out if one of these is already available somewhere */ #define
__stringify(x)#x
#define stringify(x)__stringify(x)
Quoted 6 lines
#define
SDRAM_OFFSET(x)0x2##x /* or0x4*/ #defineCONFIG_SYS_SDRAM_BASESDRAM_OFFSET(0000000)#define MEM_LAYOUT_ENV_SETTINGS \ "kernel_addr_r=" stringify(SDRAM_OFFSET(200000)) "\0" ...
Yeah I think that will work. I'll do that for v2 (it may take a few days before I get around to doing / posting a v2).
Regards,
Hans
PATCH 4/12 sunxi: Update sunxi-common.h to deal with different DRAM base addr on sun9i
In reply to Ian CampbellHi Ian,
Quoted 15 lines · Ian Campbell
Quoted 3 lines · Hans de Goede
The DRAM Base differs between sun9i and the others and we cannot use math in various places like the environment setting and linker scripts, so "simply" define everything which contains the
SDRAM_BASEtwice.Is it really not possible to use maths in linker scripts? How have I never noticed that...
Anyway, given that things only differ in the most significant nibble of the RAM base address I think something like this might work:
/* NB: find out if one of these is already available somewhere */ #define
__stringify(x)#x
#define stringify(x)__stringify(x)
Quoted 6 lines
#define
SDRAM_OFFSET(x)0x2##x /* or0x4*/ #defineCONFIG_SYS_SDRAM_BASESDRAM_OFFSET(0000000)#define MEM_LAYOUT_ENV_SETTINGS \ "kernel_addr_r=" stringify(SDRAM_OFFSET(200000)) "\0" ...
I've finally brushed of these patches and I'm working on cleaning them up now.
Unfortunately a lot of the CONFIG_xxx variables with dram base address derived values get exported through cpp -E -dM which does not do macro expansion, and then used in Makefiles to pass to the linker and such. So I've been unable to get big of the #ifdef ... #else ... #endif block setting various defines for this.
I've been able to make the environment block use the trick you suggested, so this does give a nice cleanup.
Regards,
Hans
PATCH 5/12 sunxi: Move setting of CPU system control register SMP bit to save_boot_params
In reply to Hans de GoedeAccording to the "Cortex-A7 MPCore Technical Reference Manual":
"You must ensure this bit is set to 1 before the caches and MMU are enabled, or any cache and TLB maintenance operations are performed."
Since arch/arm/cpu/armv7/start.S: cpu_init_cp15 does several cache operations, we should thus enable the SMP bit earlier, and the only chance to do that is to do it at save_boot_params time.
This does not seem to make any noticable difference, but:
1) According to the manual it is the right thing to do
2) We need to do other magic really early on for sun9i (A80) support, so we need to introduce a lowlevel_init.S / save_boot_params function anyways
--- arch/arm/cpu/armv7/sunxi/Makefile | 1 + arch/arm/cpu/armv7/sunxi/board.c | 8 -------- arch/arm/cpu/armv7/sunxi/lowlevel_init.S | 23 +++++++++++++++++++++++ 3 files changed, 24 insertions(+), 8 deletions(-) create mode 100644 arch/arm/cpu/armv7/sunxi/lowlevel_init.S
arch/arm/cpu/armv7/sunxi/Makefile +1 -0
@@ -7,6 +7,7 @@ # # SPDX-License-Identifier: GPL-2.0+ # +obj-y += lowlevel_init.o obj-y += timer.o obj-y += board.o obj-y += clock.o
arch/arm/cpu/armv7/sunxi/board.c +0 -8
@@ -120,14 +120,6 @@ void s_init(void)* access gets messed up (seems cache related) */ setbits_le32 (SUNXI_SRAMC_BASE +0x44 ,0x1800 );#endif -#if !definedCONFIG_SPL_BUILD && (definedCONFIG_MACH_SUN7I || \ - definedCONFIG_MACH_SUN6I || definedCONFIG_MACH_SUN8I ) -/* Enable SMP mode for CPU0, by setting bit 6 of Auxiliary Ctl reg */ - asmvolatile ( -"mrc p15, 0, r0, c1, c0, 1\n" -"orr r0, r0, #1 << 6\n" -"mcr p15, 0, r0, c1, c0, 1\n" ); -#endif clock_init ();timer_init ();
arch/arm/cpu/armv7/sunxi/lowlevel_init.S new file +23 -0
@@ -0,0 +1,23 @@ +/* + * (C) Copyright 2015 Hans de Goede <[email protected]> + * + * SPDX-License-Identifier: GPL-2.0+ + */ + +#include <config.h> +#include <version.h> +#include <linux/linkage.h> + +/* + * On sunxi we need to do some setup *before* cpu_init_cp15 from start.S + * runs, we (ab)use save_boot_params for this. + */ +ENTRY(save_boot_params) +#if defined CONFIG_MACH_SUN6I || defined CONFIG_MACH_SUN7I || \ + defined CONFIG_MACH_SUN8I + mrc p15, 0, r0, c1, c0, 1 + orr r0, r0, #(1<<6) + mcr p15, 0, r0, c1, c0, 1 +#endif + bx lr +ENDPROC(save_boot_params)
Signature · 1 line
2.1.0
PATCH 5/12 sunxi: Move setting of CPU system control register SMP bit to save_boot_params
Quoted 4 lines · Hans de Goede
According to the "Cortex-A7 MPCore Technical Reference Manual":
"You must ensure this bit is set to 1 before the caches and MMU are enabled, or any cache and TLB maintenance operations are performed."
Given that this is a feature of the Cortex-A7 (actually, I believe it applies to at least Cortex-A15 too) and not really specific to sunxi, perhaps we can make this more generic?
Quoted 3 lines
Since
arch/arm/cpu/armv7/start.S:cpu_init_cp15does several cache operations, we should thus enable the SMP bit earlier, and the only chance to do that is to do it atsave_boot_paramstime.
Would it be so terrible to add an ifdef CORTEX_A7 here, or to call out to (or call as a macro) a soc_init_cp15?
I'm cc-ing Albert for input these questions.
FWIW I notice there is some OMAP specific code right before the "bl cpu_init_cp15", although that looks like an even more special case, so perhaps not really precedent.
Quoted 1 line
This does not seem to make any noticable difference, but:
"noticeable"
Quoted 72 lines
1) According to the manual it is the right thing to do
2) We need to do other magic really early on for sun9i (A80) support, so we need to introduce alowlevel_init.S/save_boot_paramsfunction anywaysSigned-off-by Hans de Goede <[email protected]>--- arch/arm/cpu/armv7/sunxi/Makefile | 1 + arch/arm/cpu/armv7/sunxi/board.c | 8 -------- arch/arm/cpu/armv7/sunxi/lowlevel_init.S | 23 +++++++++++++++++++++++ 3 files changed, 24 insertions(+), 8 deletions(-) create mode 100644 arch/arm/cpu/armv7/sunxi/lowlevel_init.Sarch/arm/cpu/armv7/sunxi/Makefile +1
-0@@ -7,6 +7,7 @@ # # SPDX-License-Identifier: GPL-2.0+ # +obj-y += lowlevel_init.o obj-y += timer.o obj-y += board.o obj-y += clock.oarch/arm/cpu/armv7/sunxi/board.c +0
-8@@ -120,14 +120,6 @@ void s_init(void)* access gets messed up (seems cache related) */ setbits_le32 (SUNXI_SRAMC_BASE +0x44 ,0x1800 );#endif -#if !definedCONFIG_SPL_BUILD && (definedCONFIG_MACH_SUN7I || \ - definedCONFIG_MACH_SUN6I || definedCONFIG_MACH_SUN8I ) -/* Enable SMP mode for CPU0, by setting bit 6 of Auxiliary Ctl reg */ - asmvolatile ( -"mrc p15, 0, r0, c1, c0, 1\n" -"orr r0, r0, #1 << 6\n" -"mcr p15, 0, r0, c1, c0, 1\n" ); -#endif clock_init ();timer_init ();arch/arm/cpu/armv7/sunxi/lowlevel_init.S new file +23
-0@@ -0,0 +1,23 @@ +/* + * (C) Copyright 2015 Hans de Goede <[email protected]> + * + * SPDX-License-Identifier: GPL-2.0+ + */ + +#include <config.h> +#include <version.h> +#include <linux/linkage.h> + +/* + * On sunxi we need to do some setup *before* cpu_init_cp15 from start.S + * runs, we (ab)use save_boot_params for this. + */ +ENTRY(save_boot_params) +#if defined CONFIG_MACH_SUN6I || defined CONFIG_MACH_SUN7I || \ + defined CONFIG_MACH_SUN8I + mrc p15, 0, r0, c1, c0, 1 + orr r0, r0, #(1<<6) + mcr p15, 0, r0, c1, c0, 1 +#endif + bx lr +ENDPROC(save_boot_params)
PATCH 5/12 sunxi: Move setting of CPU system control register SMP bit to save_boot_params
Hi,
Quoted 9 lines · Ian Campbell
Quoted 4 lines · Hans de Goede
According to the "Cortex-A7 MPCore Technical Reference Manual":
"You must ensure this bit is set to 1 before the caches and MMU are enabled, or any cache and TLB maintenance operations are performed."
Given that this is a feature of the Cortex-A7 (actually, I believe it applies to at least Cortex-A15 too) and not really specific to sunxi, perhaps we can make this more generic?
Strange enough the bit is different between the A7 and A15, for the A7 the docs say it must be set before doing anything with caches, on the A15 it only needs to be set for the core to accept cache management operations from other cpu cores (or so the docs say), which is likely why it is not in the standard init sequence yet, as for u-boot it seems to only be necessary to do this on a Cortex A7. I agree that it would be good to move this to the generic start.S though, Albert ?
Quoted 7 lines
Quoted 4 lines
Since
arch/arm/cpu/armv7/start.S:cpu_init_cp15does several cache operations, we should thus enable the SMP bit earlier, and the only chance to do that is to do it atsave_boot_paramstime.Would it be so terrible to add an ifdef
CORTEX_A7here, or to call out to (or call as a macro) asoc_init_cp15?
From my pov no that would not be too terrible, but ...
Quoted 2 lines
I'm cc-ing Albert for input these questions.
That indeed is Albert's call.
Note that solving this still leaves the A80 magic sram controller poke which also needs to happen really really early or otherwise the entire SoC just resets as if the watchdog has triggered, I'm fine with using save_boot_params for that, it is not its intended purpose, but it works fine for it, so I see no reason to complicate things with yet another callback.
Quoted 72 lines
FWIW I notice there is some OMAP specific code right before the "bl
cpu_init_cp15", although that looks like an even more special case, so perhaps not really precedent.Quoted 1 line
This does not seem to make any noticable difference, but:
"noticeable"
Quoted 64 lines
1) According to the manual it is the right thing to do
2) We need to do other magic really early on for sun9i (A80) support, so we need to introduce alowlevel_init.S/save_boot_paramsfunction anywaysSigned-off-by Hans de Goede <[email protected]>--- arch/arm/cpu/armv7/sunxi/Makefile | 1 + arch/arm/cpu/armv7/sunxi/board.c | 8 -------- arch/arm/cpu/armv7/sunxi/lowlevel_init.S | 23 +++++++++++++++++++++++ 3 files changed, 24 insertions(+), 8 deletions(-)create mode 100644
arch/arm/cpu/armv7/sunxi/lowlevel_init.Sarch/arm/cpu/armv7/sunxi/Makefile +1
-0@@ -7,6 +7,7 @@ # # SPDX-License-Identifier: GPL-2.0+ # +obj-y += lowlevel_init.o obj-y += timer.o obj-y += board.o obj-y += clock.oarch/arm/cpu/armv7/sunxi/board.c +0
-8@@ -120,14 +120,6 @@ void s_init(void)* access gets messed up (seems cache related) */ setbits_le32 (SUNXI_SRAMC_BASE +0x44 ,0x1800 );#endif -#if !definedCONFIG_SPL_BUILD && (definedCONFIG_MACH_SUN7I || \ - definedCONFIG_MACH_SUN6I || definedCONFIG_MACH_SUN8I ) -/* Enable SMP mode for CPU0, by setting bit 6 of Auxiliary Ctl reg */ - asmvolatile ( -"mrc p15, 0, r0, c1, c0, 1\n" -"orr r0, r0, #1 << 6\n" -"mcr p15, 0, r0, c1, c0, 1\n" ); -#endif clock_init ();timer_init ();arch/arm/cpu/armv7/sunxi/lowlevel_init.S new file +15
-0@@ -0,0 +1,23 @@ +/* + * (C) Copyright 2015 Hans de Goede <[email protected]> + * + * SPDX-License-Identifier: GPL-2.0+ + */ + +#include <config.h> +#include <version.h> +#include <linux/linkage.h> + +/* + * On sunxi we need to do some setup *before* cpu_init_cp15 from start.S + * runs, we (ab)use save_boot_params for this. + */ +ENTRY(save_boot_params)
Quoted 10 lines
arch/arm/cpu/armv7/sunxi/lowlevel_init.S line 23
Quoted 8 lines
arch/arm/cpu/armv7/sunxi/lowlevel_init.S new file +8
-0+#if defined CONFIG_MACH_SUN6I || defined CONFIG_MACH_SUN7I || \ + defined CONFIG_MACH_SUN8I + mrc p15, 0, r0, c1, c0, 1 + orr r0, r0, #(1<<6) + mcr p15, 0, r0, c1, c0, 1 +#endif + bx lr +ENDPROC(save_boot_params)
Regards,
Hans
PATCH 5/12 sunxi: Move setting of CPU system control register SMP bit to save_boot_params
Hello Hans,
Quoted 20 lines · Hans de Goede
Hi,
Quoted 9 lines · Ian Campbell
Quoted 4 lines · Hans de Goede
According to the "Cortex-A7 MPCore Technical Reference Manual":
"You must ensure this bit is set to 1 before the caches and MMU are enabled, or any cache and TLB maintenance operations are performed."
Given that this is a feature of the Cortex-A7 (actually, I believe it applies to at least Cortex-A15 too) and not really specific to sunxi, perhaps we can make this more generic?
Strange enough the bit is different between the A7 and A15, for the A7 the docs say it must be set before doing anything with caches, on the A15 it only needs to be set for the core to accept cache management operations from other cpu cores (or so the docs say), which is likely why it is not in the standard init sequence yet, as for u-boot it seems to only be necessary to do this on a Cortex A7. I agree that it would be good to move this to the generic
start.Sthough, Albert ?
[...]
Quoted 4 lines
Quoted 4 lines
Quoted 3 lines
Since
arch/arm/cpu/armv7/start.S:cpu_init_cp15does several cache operations, we should thus enable the SMP bit earlier, and the only chance to do that is to do it atsave_boot_paramstime.
Quoted 8 lines
Quoted 2 lines
Would it be so terrible to add an ifdef
CORTEX_A7here, or to call out to (or call as a macro) asoc_init_cp15?From my pov no that would not be too terrible, but ...
Quoted 2 lines
I'm cc-ing Albert for input these questions.
That indeed is Albert's call.
Will look into this today.
Amicalement,
Signature · 1 line
Albert.
PATCH 5/12 sunxi: Move setting of CPU system control register SMP bit to save_boot_params
In reply to Hans de GoedeQuoted 34 lines · Hans de Goede
Hi,
Quoted 9 lines · Ian Campbell
Quoted 4 lines · Hans de Goede
According to the "Cortex-A7 MPCore Technical Reference Manual":
"You must ensure this bit is set to 1 before the caches and MMU are enabled, or any cache and TLB maintenance operations are performed."
Given that this is a feature of the Cortex-A7 (actually, I believe it applies to at least Cortex-A15 too) and not really specific to sunxi, perhaps we can make this more generic?
Strange enough the bit is different between the A7 and A15, for the A7 the docs say it must be set before doing anything with caches, on the A15 it only needs to be set for the core to accept cache management operations from other cpu cores (or so the docs say), which is likely why it is not in the standard init sequence yet, as for u-boot it seems to only be necessary to do this on a Cortex A7. I agree that it would be good to move this to the generic
start.Sthough, Albert ?Quoted 7 lines
Quoted 4 lines
Since
arch/arm/cpu/armv7/start.S:cpu_init_cp15does several cache operations, we should thus enable the SMP bit earlier, and the only chance to do that is to do it atsave_boot_paramstime.Would it be so terrible to add an ifdef
CORTEX_A7here, or to call out to (or call as a macro) asoc_init_cp15?From my pov no that would not be too terrible, but ...
Quoted 2 lines
I'm cc-ing Albert for input these questions.
Quoted 7 lines
That indeed is Albert's call.
Note that solving this still leaves the A80 magic sram controller poke which also needs to happen really really early or otherwise the entire SoC just resets as if the watchdog has triggered, I'm fine with using
save_boot_paramsfor that, it is not its intended purpose, but it works fine for it, so I see no reason to complicate things with yet another callback.
Ideally it would be possible to do it in the same hook as sets up the ACTLR.SMP bit.
In general I'm not a big fan of reusing unrelated hooks just because they happen to be in a convenient location -- it leads to surprises when you are reading through/modifying the calling code.
Ian.
PATCH 5/12 sunxi: Move setting of CPU system control register SMP bit to save_boot_params
In reply to Hans de GoedeHello Hans,
Quoted 20 lines · Hans de Goede
Hi,
Quoted 9 lines · Ian Campbell
Quoted 4 lines · Hans de Goede
According to the "Cortex-A7 MPCore Technical Reference Manual":
"You must ensure this bit is set to 1 before the caches and MMU are enabled, or any cache and TLB maintenance operations are performed."
Given that this is a feature of the Cortex-A7 (actually, I believe it applies to at least Cortex-A15 too) and not really specific to sunxi, perhaps we can make this more generic?
Strange enough the bit is different between the A7 and A15, for the A7 the docs say it must be set before doing anything with caches, on the A15 it only needs to be set for the core to accept cache management operations from other cpu cores (or so the docs say), which is likely why it is not in the standard init sequence yet, as for u-boot it seems to only be necessary to do this on a Cortex A7. I agree that it would be good to move this to the generic
start.Sthough, Albert ?
[...]
Quoted 4 lines
Quoted 4 lines
Quoted 3 lines
Since
arch/arm/cpu/armv7/start.S:cpu_init_cp15does several cache operations, we should thus enable the SMP bit earlier, and the only chance to do that is to do it atsave_boot_paramstime.
Quoted 8 lines
Quoted 2 lines
Would it be so terrible to add an ifdef
CORTEX_A7here, or to call out to (or call as a macro) asoc_init_cp15?From my pov no that would not be too terrible, but ...
Quoted 2 lines
I'm cc-ing Albert for input these questions.
That indeed is Albert's call.
I don't like the idea of #ifdef'ing that much.
OTOH, if we do introduce soc_init_cp15, then we end up with two CP15 init functions, soc_init_cp15 and cpu_init_cp15, with all sorts of questions on which should be called first and whether one could break the other's work, and what happens in-between, etc.
Either way, setting CP15 registers is something that all ARM CPUs, and SoCs require, not just armv7. It's just that other start.S files touch cp15 directly.
I'm leaning toward grouping all CP15 inits (including cache(s) and TLB disabling and maybe VBAR setting) in a single CP15 call to a single soc_init_cp15 function.
Now, SoCs with the same CPU will have a common CP15 init part, and that part could go into a <cpu>_init_cp15 function which soc_init_cp15 would call. Of course, since we're doing this way before we have any stack, we will have to handle nested calls by saving and restoring LR in intermediate function contexts.
Quoted 5 lines
Note that solving this still leaves the A80 magic sram controller poke which also needs to happen really really early or otherwise the entire SoC just resets as if the watchdog has triggered, I'm fine with using
save_boot_paramsfor that, it is not its intended purpose, but it works fine for it, so I see no reason to complicate things with yet another callback.
Maybe we could turn soc_init_cp15 into a more general soc_init function which would do whatever is needed, on cp15 or otherwise.
(I see there is one soc_init defined, for spear600, but it is actually empty and could/should be removed. Patch anyone?)
Quoted 3 lines
Regards,
Hans
Amicalement,
Signature · 1 line
Albert.
PATCH 5/12 sunxi: Move setting of CPU system control register SMP bit to save_boot_params
Hi,
Quoted 67 lines · Albert ARIBAUD
Hello Hans,
Quoted 20 lines · Hans de Goede
Hi,
Quoted 9 lines · Ian Campbell
Quoted 4 lines · Hans de Goede
According to the "Cortex-A7 MPCore Technical Reference Manual":
"You must ensure this bit is set to 1 before the caches and MMU are enabled, or any cache and TLB maintenance operations are performed."
Given that this is a feature of the Cortex-A7 (actually, I believe it applies to at least Cortex-A15 too) and not really specific to sunxi, perhaps we can make this more generic?
Strange enough the bit is different between the A7 and A15, for the A7 the docs say it must be set before doing anything with caches, on the A15 it only needs to be set for the core to accept cache management operations from other cpu cores (or so the docs say), which is likely why it is not in the standard init sequence yet, as for u-boot it seems to only be necessary to do this on a Cortex A7. I agree that it would be good to move this to the generic
start.Sthough, Albert ?[...]
Quoted 4 lines
Quoted 4 lines
Quoted 3 lines
Since
arch/arm/cpu/armv7/start.S:cpu_init_cp15does several cache operations, we should thus enable the SMP bit earlier, and the only chance to do that is to do it atsave_boot_paramstime.Quoted 8 lines
Quoted 2 lines
Would it be so terrible to add an ifdef
CORTEX_A7here, or to call out to (or call as a macro) asoc_init_cp15?From my pov no that would not be too terrible, but ...
Quoted 2 lines
I'm cc-ing Albert for input these questions.
That indeed is Albert's call.
I don't like the idea of #ifdef'ing that much.
OTOH, if we do introduce
soc_init_cp15, then we end up with two CP15 init functions,soc_init_cp15andcpu_init_cp15, with all sorts of questions on which should be called first and whether one could break the other's work, and what happens in-between, etc.Either way, setting CP15 registers is something that all ARM CPUs, and SoCs require, not just armv7. It's just that other
start.Sfiles touch cp15 directly.I'm leaning toward grouping all CP15 inits (including cache(s) and TLB disabling and maybe VBAR setting) in a single CP15 call to a single
soc_init_cp15function.Now, SoCs with the same CPU will have a common CP15 init part, and that part could go into a <cpu>_init_cp15 function which
soc_init_cp15would call. Of course, since we're doing this way before we have any stack, we will have to handle nested calls by saving and restoring LR in intermediate function contexts.Quoted 5 lines
Note that solving this still leaves the A80 magic sram controller poke which also needs to happen really really early or otherwise the entire SoC just resets as if the watchdog has triggered, I'm fine with using
save_boot_paramsfor that, it is not its intended purpose, but it works fine for it, so I see no reason to complicate things with yet another callback.
Quoted 5 lines
Maybe we could turn
soc_init_cp15into a more generalsoc_initfunction which would do whatever is needed, on cp15 or otherwise.(I see there is one
soc_initdefined, for spear600, but it is actually empty and could/should be removed. Patch anyone?)
Hmm, so if I'm reading the above correctly, then I think you want to do the following:
1) Rename cpu_init_cp15 to cpu_init_cp15_common
2) Add a new soc_init function, with a weak default which just calls cpu_init_cp15_common
3) Add a a7_init_cp15 which sets the smp bit
4) Have Cortex A7 SoCs override soc_init with one which first calls a7_init_cp15 and then calls cpu_init_cp15_common
5) And on SoC's which need to do something special before or after cp15 init, they can do so by overriding soc_init and do what ever they need to do there before *or* after calling cpu_init_cp15_common
Have I got that right ?
If so I can try to write a patch-set for this, my arm asm is a bit weak, but I should be able to cobble this together using existing code as an example.
Regards,
Hans
PATCH 5/12 sunxi: Move setting of CPU system control register SMP bit to save_boot_params
Hello Hans,
Quoted 41 lines · Hans de Goede
Hi,
Quoted 18 lines · Albert ARIBAUD
Hello Hans,
I'm leaning toward grouping all CP15 inits (including cache(s) and TLB disabling and maybe VBAR setting) in a single CP15 call to a single
soc_init_cp15function.Now, SoCs with the same CPU will have a common CP15 init part, and that part could go into a <cpu>_init_cp15 function which
soc_init_cp15would call. Of course, since we're doing this way before we have any stack, we will have to handle nested calls by saving and restoring LR in intermediate function contexts.Quoted 5 lines
Note that solving this still leaves the A80 magic sram controller poke which also needs to happen really really early or otherwise the entire SoC just resets as if the watchdog has triggered, I'm fine with using
save_boot_paramsfor that, it is not its intended purpose, but it works fine for it, so I see no reason to complicate things with yet another callback.Quoted 5 lines
Maybe we could turn
soc_init_cp15into a more generalsoc_initfunction which would do whatever is needed, on cp15 or otherwise.(I see there is one
soc_initdefined, for spear600, but it is actually empty and could/should be removed. Patch anyone?)Hmm, so if I'm reading the above correctly, then I think you want to do the following:
1) Rename
cpu_init_cp15tocpu_init_cp15_common
2) Add a newsoc_initfunction, with a weak default which just callscpu_init_cp15_common
3) Add aa7_init_cp15which sets the smp bit
4) Have Cortex A7 SoCs overridesoc_initwith one which first callsa7_init_cp15and then callscpu_init_cp15_common
5) And on SoC's which need to do something special before or after cp15 init, they can do so by overridingsoc_initand do what ever they need to do there before *or* after callingcpu_init_cp15_common
Quoted 1 line
Have I got that right ?
Almost entirely. My only comments are on 1) :
- cpu_init_cp15_common does not need the "common" suffix IMO; actually, it might be more general than just touching cp15, so we could just call it "cpu_init" (1).
- if two CPUs need different versions, then we will want to make cpu_init a weak function, with a default based on the 'common denominator'.
(1) Note that there is already a cpu_init() function in U-Boot, used by SH and AVR32; if we want 'cpu_init' to be consistent across architectures, we might have to change "{soc,cpu}_init" to somehting else (for instance "{soc,cpu}_setup" or "{soc,cpu}_boot_init") but I don't like that much, or investigate what the existing cpu_init() does and see if /that/ could be renamed or merged into a common mechanism (I doubt that the second is practically feasible).
Quoted 3 lines
If so I can try to write a patch-set for this, my arm asm is a bit weak, but I should be able to cobble this together using existing code as an example.
Thanks!
Quoted 3 lines
Regards,
Hans
Amicalement,
Signature · 1 line
Albert.
PATCH 6/12 sun9i: Add cpu_sun9i.h with iomem defines
In reply to Hans de GoedeAdd a headerfile with all the base addresses from the sun9i blocks.
--- arch/arm/include/asm/arch-sunxi/cpu.h | 4 ++ arch/arm/include/asm/arch-sunxi/cpu_sun9i.h | 108 ++++++++++++++++++++++++++++ 2 files changed, 112 insertions(+) create mode 100755 arch/arm/include/asm/arch-sunxi/cpu_sun9i.h
arch/arm/include/asm/arch-sunxi/cpu.h +4 -0
@@ -7,6 +7,10 @@#ifndef _SUNXI_CPU_H#define _SUNXI_CPU_H +#if defined(CONFIG_MACH_SUN9I ) +#include <asm/arch/cpu_sun9i.h> +#else #include <asm/arch/cpu_sun4i.h> +#endif #endif /* _SUNXI_CPU_H */
arch/arm/include/asm/arch-sunxi/cpu_sun9i.h new file +108 -0
108 lines not on this page · raw message
Signature · 1 line
2.1.0
PATCH 6/12 sun9i: Add cpu_sun9i.h with iomem defines
Quoted 3 lines · Hans de Goede
Add a headerfile with all the base addresses from the sun9i blocks.
Signed-off-by Hans de Goede <[email protected]>
PATCH 7/12 sun9i: Add clock_sun9i.h with ccu register layout for sun9i
In reply to Hans de GoedeAdd a headerfile with the sun9i ccu register layout.
--- arch/arm/include/asm/arch-sunxi/clock.h | 2 + arch/arm/include/asm/arch-sunxi/clock_sun9i.h | 139 ++++++++++++++++++++++++++ 2 files changed, 141 insertions(+) create mode 100644 arch/arm/include/asm/arch-sunxi/clock_sun9i.h
arch/arm/include/asm/arch-sunxi/clock.h +2 -0
@@ -17,6 +17,8 @@/* clock control module regs definition */ #if defined(CONFIG_MACH_SUN6I ) || defined(CONFIG_MACH_SUN8I )#include <asm/arch/clock_sun6i.h> +#elif defined(CONFIG_MACH_SUN9I ) +#include <asm/arch/clock_sun9i.h> #else #include <asm/arch/clock_sun4i.h> #endif
arch/arm/include/asm/arch-sunxi/clock_sun9i.h new file +139 -0
139 lines not on this page · raw message
Signature · 1 line
2.1.0
PATCH 7/12 sun9i: Add clock_sun9i.h with ccu register layout for sun9i
Quoted 3 lines · Hans de Goede
Add a headerfile with the sun9i ccu register layout.
Signed-off-by Hans de Goede <[email protected]>
PATCH 8/12 sun9i: Add sun9i (A80) clock setup support
In reply to Hans de GoedeAdd initial sun9i (A80) clock setup support, enough to get the uart + mmc going.
--- arch/arm/cpu/armv7/sunxi/Makefile | 1 + arch/arm/cpu/armv7/sunxi/clock_sun9i.c | 68 ++++++++++++++++++++++++++++++++++ 2 files changed, 69 insertions(+) create mode 100644 arch/arm/cpu/armv7/sunxi/clock_sun9i.c
arch/arm/cpu/armv7/sunxi/Makefile +1 -0
@@ -23,6 +23,7 @@ obj-$(CONFIG_MACH_SUN5I) += clock_sun4i.o obj-$(CONFIG_MACH_SUN6I) += clock_sun6i.o obj-$(CONFIG_MACH_SUN7I) += clock_sun4i.o obj-$(CONFIG_MACH_SUN8I) += clock_sun6i.o +obj-$(CONFIG_MACH_SUN9I) += clock_sun9i.o ifndef CONFIG_SPL_BUILD ifdef CONFIG_ARMV7_PSCI
arch/arm/cpu/armv7/sunxi/clock_sun9i.c new file +68 -0
68 lines not on this page · raw message
Signature · 1 line
2.1.0
PATCH 8/12 sun9i: Add sun9i (A80) clock setup support
Quoted 4 lines · Hans de Goede
Add initial sun9i (A80) clock setup support, enough to get the uart + mmc going.
Signed-off-by Hans de Goede <[email protected]>
PATCH 9/12 sunxi: mmc: Use a realistic timeout when sending a mmc command
In reply to Hans de GoedeWait 1 second for the sdcard to respond, rather then waiting for 0xfffff milliseconds.
--- drivers/mmc/sunxi_mmc.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/mmc/sunxi_mmc.c +2 -1
@@ -355,7 +355,8 @@ static int mmc_send_cmd(struct mmc *mmc, struct mmc_cmd *cmd, } } - error =mmc_rint_wait (mmc,0xfffff ,SUNXI_MMC_RINT_COMMAND_DONE ,"cmd" ); + timeout_msecs =1000 ; + error =mmc_rint_wait (mmc, timeout_msecs,SUNXI_MMC_RINT_COMMAND_DONE ,"cmd" );if (error) goto out;
Signature · 1 line
2.1.0
PATCH 9/12 sunxi: mmc: Use a realistic timeout when sending a mmc command
Quoted 4 lines · Hans de Goede
Wait 1 second for the sdcard to respond, rather then waiting for
0xfffffmilliseconds.Signed-off-by Hans de Goede <[email protected]>
(needn't wait for the rest of the series I think)
Quoted 9 lines
--- drivers/mmc/sunxi_mmc.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)drivers/mmc/sunxi_mmc.c +0
-0
drivers/mmc/sunxi_mmc.c static int mmc_send_cmd(struct mmc *mmc, struct mmc_cmd *cmd, · line 358
Quoted 5 lines
drivers/mmc/sunxi_mmc.c +1
-1@@ -355,7 +355,8 @@ static int mmc_send_cmd(struct mmc *mmc, struct mmc_cmd *cmd, } } - error =mmc_rint_wait (mmc,0xfffff ,SUNXI_MMC_RINT_COMMAND_DONE ,"cmd" ); + timeout_msecs =1000 ;
Not strictly necessary to go via the variable, but not harmful either.
Quoted 4 lines
drivers/mmc/sunxi_mmc.c +1
-0+ error =mmc_rint_wait (mmc, timeout_msecs,SUNXI_MMC_RINT_COMMAND_DONE ,"cmd" );if (error) goto out;
PATCH 10/12 sunxi: mmc: Add support for sun9i (A80)
In reply to Hans de GoedeThe clocks on the A80 are hooked up slightly different, add support for this.
--- arch/arm/include/asm/arch-sunxi/mmc.h | 5 ++++- drivers/mmc/sunxi_mmc.c | 14 ++++++++++++-- 2 files changed, 16 insertions(+), 3 deletions(-)
arch/arm/include/asm/arch-sunxi/mmc.h +4 -1
@@ -43,7 +43,7 @@ struct sunxi_mmc {u32 chda;/* 0x90 */ u32 cbda;/* 0x94 */ u32 res1[26 ]; -#if defined(CONFIG_MACH_SUN6I ) || defined(CONFIG_MACH_SUN8I ) +#if defined(CONFIG_MACH_SUN6I ) || defined(CONFIG_MACH_SUN8I ) || defined(CONFIG_MACH_SUN9I )u32 res2[64 ];#endif u32 fifo;/* 0x100 (0x200 on sun6i) FIFO access address */
@@ -123,5 +123,8 @@ struct sunxi_mmc {#define SUNXI_MMC_IDIE_TXIRQ (0x1 << 0)#define SUNXI_MMC_IDIE_RXIRQ (0x1 << 1) +#define SUNXI_MMC_COMMON_CLK_GATE (1 << 16) +#define SUNXI_MMC_COMMON_RESET (1 << 18) +struct mmc *sunxi_mmc_init (int sdc_no);#endif /* _SUNXI_MMC_H */
drivers/mmc/sunxi_mmc.c +12 -2
@@ -89,8 +89,13 @@ static int mmc_set_mod_clk(struct sunxi_mmc_host *mmchost, unsigned int hz) pll =CCM_MMC_CTRL_OSCM24 ; pll_hz =24000000 ; }else { +#ifdef CONFIG_MACH_SUN9I + pll =CCM_MMC_CTRL_PLL_PERIPH0 ; + pll_hz =clock_get_pll4_periph0 (); +#else pll =CCM_MMC_CTRL_PLL6 ; pll_hz =clock_get_pll6 (); +#endif } div = pll_hz / hz;
@@ -146,10 +151,15 @@ static int mmc_clk_io_on(int sdc_no)/* config ahb clock */ setbits_le32 (&ccm->ahb_gate0,1 <<AHB_GATE_OFFSET_MMC (sdc_no)); -#if defined(CONFIG_MACH_SUN6I ) || defined(CONFIG_MACH_SUN8I ) +#if defined(CONFIG_MACH_SUN6I ) || defined(CONFIG_MACH_SUN8I ) || defined(CONFIG_MACH_SUN9I )/* unassert reset */ setbits_le32 (&ccm->ahb_reset0_cfg,1 <<AHB_RESET_OFFSET_MMC (sdc_no));#endif +#if defined(CONFIG_MACH_SUN9I ) +/* sun9i has a mmc-common module, also set the gate and reset there */ +writel (SUNXI_MMC_COMMON_CLK_GATE |SUNXI_MMC_COMMON_RESET , +SUNXI_MMC_COMMON_BASE +4 * sdc_no); +#endif return mmc_set_mod_clk (mmchost,24000000 ); }
@@ -440,7 +450,7 @@ struct mmc *sunxi_mmc_init(int sdc_no) cfg->voltages =MMC_VDD_32_33 |MMC_VDD_33_34 ; cfg->host_caps =MMC_MODE_4BIT ; cfg->host_caps |= MMC_MODE_HS_52MHz |MMC_MODE_HS ; -#if defined(CONFIG_MACH_SUN6I ) || defined(CONFIG_MACH_SUN7I ) || defined(CONFIG_MACH_SUN8I ) +#if defined(CONFIG_MACH_SUN6I ) || defined(CONFIG_MACH_SUN7I ) || defined(CONFIG_MACH_SUN8I ) || defined(CONFIG_MACH_SUN9I ) cfg->host_caps |=MMC_MODE_HC ;#endif cfg->b_max =CONFIG_SYS_MMC_MAX_BLK_COUNT ;
Signature · 1 line
2.1.0
PATCH 10/12 sunxi: mmc: Add support for sun9i (A80)
Quoted 3 lines · Hans de Goede
The clocks on the A80 are hooked up slightly different, add support for this.
Signed-off-by Hans de Goede <[email protected]>
Couple of minor comments:
Quoted 10 lines
--- arch/arm/include/asm/arch-sunxi/mmc.h | 5 ++++- drivers/mmc/sunxi_mmc.c | 14 ++++++++++++-- 2 files changed, 16 insertions(+), 3 deletions(-)arch/arm/include/asm/arch-sunxi/mmc.h +0
-0
arch/arm/include/asm/arch-sunxi/mmc.h struct sunxi_mmc { · line 49
Quoted 8 lines
arch/arm/include/asm/arch-sunxi/mmc.h +1
-1@@ -43,7 +43,7 @@ struct sunxi_mmc {u32 chda;/* 0x90 */ u32 cbda;/* 0x94 */ u32 res1[26 ]; -#if defined(CONFIG_MACH_SUN6I ) || defined(CONFIG_MACH_SUN8I ) +#if defined(CONFIG_MACH_SUN6I ) || defined(CONFIG_MACH_SUN8I ) || defined(CONFIG_MACH_SUN9I )u32 res2[64 ];#endif u32 fifo;/* 0x100 (0x200 on sun6i) FIFO access address */
This comment is now two generations behind.
[...]
arch/arm/include/asm/arch-sunxi/mmc.h
Quoted 2 lines
arch/arm/include/asm/arch-sunxi/mmc.h +1
-1-#if defined(CONFIG_MACH_SUN6I ) || defined(CONFIG_MACH_SUN7I ) || defined(CONFIG_MACH_SUN8I ) +#if defined(CONFIG_MACH_SUN6I ) || defined(CONFIG_MACH_SUN7I ) || defined(CONFIG_MACH_SUN8I ) || defined(CONFIG_MACH_SUN9I )
Can you wrap this a bit please (and perhaps run checkpatch.pl in case there are more which my eye wasn't drawn too).
Ian.
PATCH 10/12 sunxi: mmc: Add support for sun9i (A80)
Hi,
Quoted 14 lines · Ian Campbell
Quoted 3 lines · Hans de Goede
The clocks on the A80 are hooked up slightly different, add support for this.
Signed-off-by Hans de Goede <[email protected]>Acked-by Ian Campbell <[email protected]>Couple of minor comments:
Quoted 5 lines
--- arch/arm/include/asm/arch-sunxi/mmc.h | 5 ++++- drivers/mmc/sunxi_mmc.c | 14 ++++++++++++-- 2 files changed, 16 insertions(+), 3 deletions(-)
Quoted 15 lines
arch/arm/include/asm/arch-sunxi/mmc.h struct sunxi_mmc { · line 49
Quoted 13 lines
arch/arm/include/asm/arch-sunxi/mmc.h +1
-1@@ -43,7 +43,7 @@ struct sunxi_mmc {u32 chda;/* 0x90 */ u32 cbda;/* 0x94 */ u32 res1[26 ]; -#if defined(CONFIG_MACH_SUN6I ) || defined(CONFIG_MACH_SUN8I ) +#if defined(CONFIG_MACH_SUN6I ) || defined(CONFIG_MACH_SUN8I ) || defined(CONFIG_MACH_SUN9I )u32 res2[64 ];#endif u32 fifo;/* 0x100 (0x200 on sun6i) FIFO access address */ This comment is now two generations behind.
Fixed.
Quoted 8 lines
[...]
arch/arm/include/asm/arch-sunxi/mmc.h
Quoted 2 lines
arch/arm/include/asm/arch-sunxi/mmc.h +1
-1-#if defined(CONFIG_MACH_SUN6I ) || defined(CONFIG_MACH_SUN7I ) || defined(CONFIG_MACH_SUN8I ) +#if defined(CONFIG_MACH_SUN6I ) || defined(CONFIG_MACH_SUN7I ) || defined(CONFIG_MACH_SUN8I ) || defined(CONFIG_MACH_SUN9I )Can you wrap this a bit please (and perhaps run checkpatch.pl in case there are more which my eye wasn't drawn too).
I'm about to push a whole bunch of patches to u-boot-sunxi/next, and I've run all of them through checkpatch, and fixed all errors and the warnings where relevant.
Regards,
Hans
PATCH 11/12 sun9i: Basic sun9i (A80) support
In reply to Hans de GoedeAdd initial sun9i (A80) support, only uart + mmc are supported for now.
--- arch/arm/cpu/armv7/sunxi/Makefile | 2 ++ arch/arm/cpu/armv7/sunxi/board.c | 4 ++++ arch/arm/cpu/armv7/sunxi/cpu_info.c | 5 +++++ arch/arm/cpu/armv7/sunxi/lowlevel_init.S | 12 +++++++++++- arch/arm/include/asm/arch-sunxi/gpio.h | 3 +++ board/sunxi/Kconfig | 5 +++++ include/configs/sun9i.h | 23 +++++++++++++++++++++++ 7 files changed, 53 insertions(+), 1 deletion(-) create mode 100644 include/configs/sun9i.h
arch/arm/cpu/armv7/sunxi/Makefile +2 -0
@@ -13,7 +13,9 @@ obj-y += board.o obj-y += clock.o obj-y += cpu_info.o obj-y += pinmux.o +ifndef CONFIG_MACH_SUN9I obj-y += usbc.o +endif obj-$(CONFIG_MACH_SUN6I) += prcm.o obj-$(CONFIG_MACH_SUN8I) += prcm.o obj-$(CONFIG_MACH_SUN6I) += p2wi.o
arch/arm/cpu/armv7/sunxi/board.c +4 -0
@@ -71,6 +71,10 @@ int gpio_init(void)sunxi_gpio_set_cfgpin (SUNXI_GPH (20 ),SUN6I_GPH20_UART0_TX );sunxi_gpio_set_cfgpin (SUNXI_GPH (21 ),SUN6I_GPH21_UART0_RX );sunxi_gpio_set_pull (SUNXI_GPH (21 ),SUNXI_GPIO_PULL_UP ); +#elif CONFIG_CONS_INDEX ==1 && defined(CONFIG_MACH_SUN9I ) +sunxi_gpio_set_cfgpin (SUNXI_GPH (12 ),SUN9I_GPH12_UART0_TX ); +sunxi_gpio_set_cfgpin (SUNXI_GPH (13 ),SUN9I_GPH13_UART0_RX ); +sunxi_gpio_set_pull (SUNXI_GPH (13 ),SUNXI_GPIO_PULL_UP );#elif CONFIG_CONS_INDEX ==2 && defined(CONFIG_MACH_SUN5I )sunxi_gpio_set_cfgpin (SUNXI_GPG (3 ),SUN5I_GPG3_UART1_TX );sunxi_gpio_set_cfgpin (SUNXI_GPG (4 ),SUN5I_GPG4_UART1_RX );
arch/arm/cpu/armv7/sunxi/cpu_info.c +5 -0
@@ -11,6 +11,7 @@#include <asm/arch/cpu.h> #include <asm/arch/clock.h> #include <axp221.h> +#include <errno.h> #ifdef CONFIG_MACH_SUN6I int sunxi_get_ss_bonding_id (void )
@@ -66,6 +67,8 @@ int print_cpuinfo(void)puts ("CPU: Allwinner A20 (SUN7I)\n" );#elif definedCONFIG_MACH_SUN8I puts ("CPU: Allwinner A23 (SUN8I)\n" ); +#elif definedCONFIG_MACH_SUN9I +puts ("CPU: Allwinner A80 (SUN9I)\n" );#else #warning Please update cpu_info.c with correct CPU informationputs ("CPU: SUNXI Family\n" );
@@ -82,6 +85,8 @@ int sunxi_get_sid(unsigned int *sid)#else return -ENODEV ;#endif +#elif defined CONFIG_MACH_SUN9I +return -ENODEV ;/* Not supported yet */ #else int i;
arch/arm/cpu/armv7/sunxi/lowlevel_init.S +11 -1
@@ -14,10 +14,20 @@ */ ENTRY(save_boot_params) #if defined CONFIG_MACH_SUN6I || defined CONFIG_MACH_SUN7I || \ - defined CONFIG_MACH_SUN8I + defined CONFIG_MACH_SUN8I || defined CONFIG_MACH_SUN9I mrc p15, 0, r0, c1, c0, 1 orr r0, r0, #(1<<6) mcr p15, 0, r0, c1, c0, 1 #endif +#if defined CONFIG_MACH_SUN9I + /* + * Dark magic poke of some register in the SYS_CTRL region. + * Allwinners own u-boot does this and without this u-boot causes a + * CPU / system reset as soon as it loads. + */ + ldr r0, =0x008000e0 + ldr r1, =0x16aa0001 + str r1, [r0] +#endif bx lr ENDPROC(save_boot_params)
arch/arm/include/asm/arch-sunxi/gpio.h +3 -0
@@ -174,6 +174,9 @@ enum sunxi_gpio_number {#define SUN4I_GPH22_SDC1 5 +#define SUN9I_GPH12_UART0_TX 2 +#define SUN9I_GPH13_UART0_RX 2 +#define SUN6I_GPH20_UART0_TX 2#define SUN6I_GPH21_UART0_RX 2
board/sunxi/Kconfig +5 -0
@@ -31,6 +31,10 @@ config MACH_SUN8I select CPU_V7 select SUPPORT_SPL +config MACH_SUN9I + bool "sun9i (Allwinner A80)" + select CPU_V7 + endchoice if MACH_SUN6I || MACH_SUN8I
@@ -56,6 +60,7 @@ config SYS_CONFIG_NAME default "sun6i" if MACH_SUN6I default "sun7i" if MACH_SUN7I default "sun8i" if MACH_SUN8I + default "sun9i" if MACH_SUN9I choice prompt "Board"
include/configs/sun9i.h new file +23 -0
@@ -0,0 +1,23 @@ +/* +* (C) Copyright 2015 Hans de Goede <[email protected]> +* +* Configuration settings for the Allwinner A80 (sun9i) CPU +* +* SPDX-License-Identifier: GPL-2.0+ +*/ + +#ifndef __CONFIG_H +#define __CONFIG_H + +/* +* A80 specific configuration +*/ + +#define CONFIG_SYS_PROMPT "sun9i# " + +/* +* Include common sunxi configuration where most the settings are +*/ +#include <configs/sunxi-common.h> + +#endif /* __CONFIG_H */
Signature · 1 line
2.1.0
PATCH 11/12 sun9i: Basic sun9i (A80) support
Quoted 3 lines · Hans de Goede
Add initial sun9i (A80) support, only uart + mmc are supported for now.
Signed-off-by Hans de Goede <[email protected]>
Quoted 1 line
+#define
CONFIG_SYS_PROMPT"sun9i# "
Should we make all these say "sunxi# " in the common header instead (the precise SoC is printed in the banner anyhow), or derive from CONFIG_SYS_CONFIG_NAME?
Ian.
PATCH 11/12 sun9i: Basic sun9i (A80) support
Hi,
Quoted 11 lines · Ian Campbell
Quoted 3 lines · Hans de Goede
Add initial sun9i (A80) support, only uart + mmc are supported for now.
Signed-off-by Hans de Goede <[email protected]>Acked-by Ian Campbell <[email protected]>Quoted 1 line
+#define
CONFIG_SYS_PROMPT"sun9i# "Should we make all these say "sunxi# " in the common header instead (the precise SoC is printed in the banner anyhow),
Yeah that sounds like a good idea, care to submit a patch for that ?
Regards,
Hans
PATCH 11/12 sun9i: Basic sun9i (A80) support
Quoted 8 lines · Hans de Goede
Hi,
Quoted 5 lines · Ian Campbell
Quoted 3 lines · Hans de Goede
Add initial sun9i (A80) support, only uart + mmc are supported for now.
Signed-off-by Hans de Goede <[email protected]>
Quoted 8 lines
Quoted 6 lines
Acked-by Ian Campbell <[email protected]>Quoted 1 line
+#define
CONFIG_SYS_PROMPT"sun9i# "Should we make all these say "sunxi# " in the common header instead (the precise SoC is printed in the banner anyhow),
Yeah that sounds like a good idea, care to submit a patch for that ?
Yep, will do once this one hits #next so I don't need to rebase etc.
Quoted 5 lines
Regards,
Hans
PATCH 12/12 sun9i: Add Merrii_A80_Optimus board / defconfig file
In reply to Hans de Goede--- configs/Merrii_A80_Optimus_defconfig | 6 ++++++ 1 file changed, 6 insertions(+) create mode 100644 configs/Merrii_A80_Optimus_defconfig
configs/Merrii_A80_Optimus_defconfig new file +6 -0
@@ -0,0 +1,6 @@ +CONFIG_FDTFILE="sun9i-a80-optimus.dtb" +CONFIG_VIDEO=n +CONFIG_USB_KEYBOARD=n ++S:CONFIG_ARM=y ++S:CONFIG_ARCH_SUNXI=y ++S:CONFIG_MACH_SUN9I=y
Signature · 1 line
2.1.0
PATCH 12/12 sun9i: Add Merrii_A80_Optimus board / defconfig file
Quoted 3 lines · Hans de Goede
Signed-off-by Hans de Goede <[email protected]>--- configs/Merrii_A80_Optimus_defconfig | 6 ++++++
Needs a MAINTAINERS update, otherwise:
Quoted 15 lines
1 file changed, 6 insertions(+) create mode 100644 configs/Merrii_A80_Optimus_defconfigconfigs/Merrii_A80_Optimus_defconfig new file +6
-0@@ -0,0 +1,6 @@ +CONFIG_FDTFILE="sun9i-a80-optimus.dtb" +CONFIG_VIDEO=n +CONFIG_USB_KEYBOARD=n ++S:CONFIG_ARM=y ++S:CONFIG_ARCH_SUNXI=y ++S:CONFIG_MACH_SUN9I=y