1*83d290c5STom Rini // SPDX-License-Identifier: GPL-2.0+
26c08d5dcSPrafulla Wadaskar /*
36c08d5dcSPrafulla Wadaskar * (C) Copyright 2010
46c08d5dcSPrafulla Wadaskar * Marvell Semiconductor <www.marvell.com>
56c08d5dcSPrafulla Wadaskar * Written-by: Prafulla Wadaskar <prafulla@marvell.com>
66c08d5dcSPrafulla Wadaskar * Contributor: Mahavir Jain <mjain@marvell.com>
76c08d5dcSPrafulla Wadaskar */
86c08d5dcSPrafulla Wadaskar
96c08d5dcSPrafulla Wadaskar #include <common.h>
10ab1b9552SLei Wen #include <asm/arch/cpu.h>
116c08d5dcSPrafulla Wadaskar #include <asm/arch/armada100.h>
126c08d5dcSPrafulla Wadaskar
136c08d5dcSPrafulla Wadaskar #define UARTCLK14745KHZ (APBC_APBCLK | APBC_FNCLK | APBC_FNCLKSEL(1))
146c08d5dcSPrafulla Wadaskar #define SET_MRVL_ID (1<<8)
156c08d5dcSPrafulla Wadaskar #define L2C_RAM_SEL (1<<4)
166c08d5dcSPrafulla Wadaskar
arch_cpu_init(void)176c08d5dcSPrafulla Wadaskar int arch_cpu_init(void)
186c08d5dcSPrafulla Wadaskar {
196c08d5dcSPrafulla Wadaskar u32 val;
206c08d5dcSPrafulla Wadaskar struct armd1cpu_registers *cpuregs =
216c08d5dcSPrafulla Wadaskar (struct armd1cpu_registers *) ARMD1_CPU_BASE;
226c08d5dcSPrafulla Wadaskar
236c08d5dcSPrafulla Wadaskar struct armd1apb1_registers *apb1clkres =
246c08d5dcSPrafulla Wadaskar (struct armd1apb1_registers *) ARMD1_APBC1_BASE;
256c08d5dcSPrafulla Wadaskar
266c08d5dcSPrafulla Wadaskar struct armd1mpmu_registers *mpmu =
276c08d5dcSPrafulla Wadaskar (struct armd1mpmu_registers *) ARMD1_MPMU_BASE;
286c08d5dcSPrafulla Wadaskar
296c08d5dcSPrafulla Wadaskar /* set SEL_MRVL_ID bit in ARMADA100_CPU_CONF register */
306c08d5dcSPrafulla Wadaskar val = readl(&cpuregs->cpu_conf);
316c08d5dcSPrafulla Wadaskar val = val | SET_MRVL_ID;
326c08d5dcSPrafulla Wadaskar writel(val, &cpuregs->cpu_conf);
336c08d5dcSPrafulla Wadaskar
346c08d5dcSPrafulla Wadaskar /* Enable Clocks for all hardware units */
356c08d5dcSPrafulla Wadaskar writel(0xFFFFFFFF, &mpmu->acgr);
366c08d5dcSPrafulla Wadaskar
376c08d5dcSPrafulla Wadaskar /* Turn on AIB and AIB-APB Functional clock */
386c08d5dcSPrafulla Wadaskar writel(APBC_APBCLK | APBC_FNCLK, &apb1clkres->aib);
396c08d5dcSPrafulla Wadaskar
406c08d5dcSPrafulla Wadaskar /* ensure L2 cache is not mapped as SRAM */
416c08d5dcSPrafulla Wadaskar val = readl(&cpuregs->cpu_conf);
426c08d5dcSPrafulla Wadaskar val = val & ~(L2C_RAM_SEL);
436c08d5dcSPrafulla Wadaskar writel(val, &cpuregs->cpu_conf);
446c08d5dcSPrafulla Wadaskar
456c08d5dcSPrafulla Wadaskar /* Enable GPIO clock */
466c08d5dcSPrafulla Wadaskar writel(APBC_APBCLK, &apb1clkres->gpio);
476c08d5dcSPrafulla Wadaskar
4881a9ab21SLei Wen #ifdef CONFIG_I2C_MV
4981a9ab21SLei Wen /* Enable general I2C clock */
5081a9ab21SLei Wen writel(APBC_RST | APBC_FNCLK | APBC_APBCLK, &apb1clkres->twsi0);
5181a9ab21SLei Wen writel(APBC_FNCLK | APBC_APBCLK, &apb1clkres->twsi0);
5281a9ab21SLei Wen
5381a9ab21SLei Wen /* Enable power I2C clock */
5481a9ab21SLei Wen writel(APBC_RST | APBC_FNCLK | APBC_APBCLK, &apb1clkres->twsi1);
5581a9ab21SLei Wen writel(APBC_FNCLK | APBC_APBCLK, &apb1clkres->twsi1);
5681a9ab21SLei Wen #endif
5781a9ab21SLei Wen
586c08d5dcSPrafulla Wadaskar /*
596c08d5dcSPrafulla Wadaskar * Enable Functional and APB clock at 14.7456MHz
606c08d5dcSPrafulla Wadaskar * for configured UART console
616c08d5dcSPrafulla Wadaskar */
626c08d5dcSPrafulla Wadaskar #if (CONFIG_SYS_NS16550_COM1 == ARMD1_UART3_BASE)
636c08d5dcSPrafulla Wadaskar writel(UARTCLK14745KHZ, &apb1clkres->uart3);
646c08d5dcSPrafulla Wadaskar #elif (CONFIG_SYS_NS16550_COM1 == ARMD1_UART2_BASE)
656c08d5dcSPrafulla Wadaskar writel(UARTCLK14745KHZ, &apb1clkres->uart2);
666c08d5dcSPrafulla Wadaskar #else
676c08d5dcSPrafulla Wadaskar writel(UARTCLK14745KHZ, &apb1clkres->uart1);
686c08d5dcSPrafulla Wadaskar #endif
696c08d5dcSPrafulla Wadaskar icache_enable();
706c08d5dcSPrafulla Wadaskar
716c08d5dcSPrafulla Wadaskar return 0;
726c08d5dcSPrafulla Wadaskar }
736c08d5dcSPrafulla Wadaskar
746c08d5dcSPrafulla Wadaskar #if defined(CONFIG_DISPLAY_CPUINFO)
print_cpuinfo(void)756c08d5dcSPrafulla Wadaskar int print_cpuinfo(void)
766c08d5dcSPrafulla Wadaskar {
776c08d5dcSPrafulla Wadaskar u32 id;
786c08d5dcSPrafulla Wadaskar struct armd1cpu_registers *cpuregs =
796c08d5dcSPrafulla Wadaskar (struct armd1cpu_registers *) ARMD1_CPU_BASE;
806c08d5dcSPrafulla Wadaskar
816c08d5dcSPrafulla Wadaskar id = readl(&cpuregs->chip_id);
826c08d5dcSPrafulla Wadaskar printf("SoC: Armada 88AP%X-%X\n", (id & 0xFFF), (id >> 0x10));
836c08d5dcSPrafulla Wadaskar return 0;
846c08d5dcSPrafulla Wadaskar }
856c08d5dcSPrafulla Wadaskar #endif
8681a9ab21SLei Wen
8781a9ab21SLei Wen #ifdef CONFIG_I2C_MV
i2c_clk_enable(void)8881a9ab21SLei Wen void i2c_clk_enable(void)
8981a9ab21SLei Wen {
9081a9ab21SLei Wen }
9181a9ab21SLei Wen #endif
92