1// SPDX-License-Identifier: GPL-2.0+ 2/* 3 * (C) Copyright 2012 Henrik Nordstrom <henrik@henriknordstrom.net> 4 * 5 * (C) Copyright 2007-2011 6 * Allwinner Technology Co., Ltd. <www.allwinnertech.com> 7 * Tom Cubie <tangliang@allwinnertech.com> 8 * 9 * SRAM init for older sunxi SoCs. 10 */ 11 12#include <common.h> 13#include <init.h> 14#include <asm/io.h> 15#include <asm/arch/cpu.h> 16 17void sunxi_sram_init(void) 18{ 19 /* 20 * Undocumented magic taken from boot0, without this DRAM 21 * access gets messed up (seems cache related). 22 * The boot0 sources describe this as: "config ema for cache sram" 23 * Newer SoCs (A83T, H3 and anything beyond) don't need this anymore. 24 */ 25 if (IS_ENABLED(CONFIG_MACH_SUN6I)) 26 setbits_le32(SUNXI_SRAMC_BASE + 0x44, 0x1800); 27 28 if (IS_ENABLED(CONFIG_MACH_SUN8I)) { 29 uint version = sunxi_get_sram_id(); 30 31 if (IS_ENABLED(CONFIG_MACH_SUN8I_A23)) { 32 if (version == 0x1650) 33 setbits_le32(SUNXI_SRAMC_BASE + 0x44, 0x1800); 34 else /* 0x1661 ? */ 35 setbits_le32(SUNXI_SRAMC_BASE + 0x44, 0xc0); 36 } else if (IS_ENABLED(CONFIG_MACH_SUN8I_A33)) { 37 if (version != 0x1667) 38 setbits_le32(SUNXI_SRAMC_BASE + 0x44, 0xc0); 39 } 40 } 41} 42