blob: bb32e3d2c53a9c0146ef93fdfce997575ce29ab0 [file] [log] [blame]
Tom Rini10e47792018-05-06 17:58:06 -04001// SPDX-License-Identifier: GPL-2.0+
Marek Vasutb47bc372017-10-09 21:08:10 +02002/*
3 * board/renesas/eagle/eagle.c
4 * This file is Eagle board support.
5 *
6 * Copyright (C) 2017 Marek Vasut <marek.vasut+renesas@gmail.com>
Marek Vasutb47bc372017-10-09 21:08:10 +02007 */
8
9#include <common.h>
Simon Glassafb02152019-12-28 10:45:01 -070010#include <cpu_func.h>
Simon Glassf11478f2019-12-28 10:45:07 -070011#include <hang.h>
Simon Glass97589732020-05-10 11:40:02 -060012#include <init.h>
Marek Vasutb47bc372017-10-09 21:08:10 +020013#include <malloc.h>
14#include <netdev.h>
15#include <dm.h>
Simon Glass3ba929a2020-10-30 21:38:53 -060016#include <asm/global_data.h>
Marek Vasutb47bc372017-10-09 21:08:10 +020017#include <dm/platform_data/serial_sh.h>
18#include <asm/processor.h>
19#include <asm/mach-types.h>
20#include <asm/io.h>
21#include <linux/errno.h>
22#include <asm/arch/sys_proto.h>
23#include <asm/gpio.h>
24#include <asm/arch/gpio.h>
25#include <asm/arch/rmobile.h>
26#include <asm/arch/rcar-mstp.h>
27#include <asm/arch/sh_sdhi.h>
28#include <i2c.h>
29#include <mmc.h>
30
31DECLARE_GLOBAL_DATA_PTR;
32
Marek Vasutf20ea912018-06-16 01:16:50 +020033#define CPGWPR 0xE6150900
Marek Vasutb47bc372017-10-09 21:08:10 +020034#define CPGWPCR 0xE6150904
Marek Vasutb47bc372017-10-09 21:08:10 +020035
36/* PLL */
37#define PLL0CR 0xE61500D8
38#define PLL0_STC_MASK 0x7F000000
39#define PLL0_STC_OFFSET 24
40
41#define CLK2MHZ(clk) (clk / 1000 / 1000)
42void s_init(void)
43{
44 struct rcar_rwdt *rwdt = (struct rcar_rwdt *)RWDT_BASE;
45 struct rcar_swdt *swdt = (struct rcar_swdt *)SWDT_BASE;
46 u32 stc;
47
48 /* Watchdog init */
49 writel(0xA5A5A500, &rwdt->rwtcsra);
50 writel(0xA5A5A500, &swdt->swtcsra);
51
52 /* CPU frequency setting. Set to 0.8GHz */
53 stc = ((800 / CLK2MHZ(CONFIG_SYS_CLK_FREQ)) - 1) << PLL0_STC_OFFSET;
54 clrsetbits_le32(PLL0CR, PLL0_STC_MASK, stc);
55}
56
Marek Vasutb47bc372017-10-09 21:08:10 +020057int board_early_init_f(void)
58{
Marek Vasutf20ea912018-06-16 01:16:50 +020059 /* Unlock CPG access */
60 writel(0xA5A5FFFF, CPGWPR);
61 writel(0x5A5A0000, CPGWPCR);
Marek Vasutb47bc372017-10-09 21:08:10 +020062
Marek Vasutb47bc372017-10-09 21:08:10 +020063 return 0;
64}
65
66int board_init(void)
67{
68 /* adress of boot parameters */
69 gd->bd->bi_boot_params = CONFIG_SYS_TEXT_BASE + 0x50000;
70
71 return 0;
72}
73
Marek Vasutb47bc372017-10-09 21:08:10 +020074#define RST_BASE 0xE6160000
75#define RST_CA57RESCNT (RST_BASE + 0x40)
76#define RST_CA53RESCNT (RST_BASE + 0x44)
77#define RST_RSTOUTCR (RST_BASE + 0x58)
78#define RST_CA57_CODE 0xA5A5000F
79#define RST_CA53_CODE 0x5A5A000F
80
Harald Seiler6f14d5f2020-12-15 16:47:52 +010081void reset_cpu(void)
Marek Vasutb47bc372017-10-09 21:08:10 +020082{
83 unsigned long midr, cputype;
84
85 asm volatile("mrs %0, midr_el1" : "=r" (midr));
86 cputype = (midr >> 4) & 0xfff;
87
88 if (cputype == 0xd03)
89 writel(RST_CA53_CODE, RST_CA53RESCNT);
90 else if (cputype == 0xd07)
91 writel(RST_CA57_CODE, RST_CA57RESCNT);
92 else
93 hang();
94}