Tom Rini | 10e4779 | 2018-05-06 17:58:06 -0400 | [diff] [blame] | 1 | // SPDX-License-Identifier: GPL-2.0+ |
Marek Vasut | b47bc37 | 2017-10-09 21:08:10 +0200 | [diff] [blame] | 2 | /* |
| 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 Vasut | b47bc37 | 2017-10-09 21:08:10 +0200 | [diff] [blame] | 7 | */ |
| 8 | |
| 9 | #include <common.h> |
Tom Rini | 8c70baa | 2021-12-14 13:36:40 -0500 | [diff] [blame] | 10 | #include <clock_legacy.h> |
Simon Glass | afb0215 | 2019-12-28 10:45:01 -0700 | [diff] [blame] | 11 | #include <cpu_func.h> |
Simon Glass | f11478f | 2019-12-28 10:45:07 -0700 | [diff] [blame] | 12 | #include <hang.h> |
Simon Glass | 9758973 | 2020-05-10 11:40:02 -0600 | [diff] [blame] | 13 | #include <init.h> |
Marek Vasut | b47bc37 | 2017-10-09 21:08:10 +0200 | [diff] [blame] | 14 | #include <malloc.h> |
| 15 | #include <netdev.h> |
| 16 | #include <dm.h> |
Simon Glass | 3ba929a | 2020-10-30 21:38:53 -0600 | [diff] [blame] | 17 | #include <asm/global_data.h> |
Marek Vasut | b47bc37 | 2017-10-09 21:08:10 +0200 | [diff] [blame] | 18 | #include <dm/platform_data/serial_sh.h> |
| 19 | #include <asm/processor.h> |
| 20 | #include <asm/mach-types.h> |
| 21 | #include <asm/io.h> |
| 22 | #include <linux/errno.h> |
| 23 | #include <asm/arch/sys_proto.h> |
| 24 | #include <asm/gpio.h> |
| 25 | #include <asm/arch/gpio.h> |
| 26 | #include <asm/arch/rmobile.h> |
| 27 | #include <asm/arch/rcar-mstp.h> |
| 28 | #include <asm/arch/sh_sdhi.h> |
| 29 | #include <i2c.h> |
| 30 | #include <mmc.h> |
| 31 | |
| 32 | DECLARE_GLOBAL_DATA_PTR; |
| 33 | |
Marek Vasut | f20ea91 | 2018-06-16 01:16:50 +0200 | [diff] [blame] | 34 | #define CPGWPR 0xE6150900 |
Marek Vasut | b47bc37 | 2017-10-09 21:08:10 +0200 | [diff] [blame] | 35 | #define CPGWPCR 0xE6150904 |
Marek Vasut | b47bc37 | 2017-10-09 21:08:10 +0200 | [diff] [blame] | 36 | |
| 37 | /* PLL */ |
| 38 | #define PLL0CR 0xE61500D8 |
| 39 | #define PLL0_STC_MASK 0x7F000000 |
| 40 | #define PLL0_STC_OFFSET 24 |
| 41 | |
| 42 | #define CLK2MHZ(clk) (clk / 1000 / 1000) |
| 43 | void s_init(void) |
| 44 | { |
| 45 | struct rcar_rwdt *rwdt = (struct rcar_rwdt *)RWDT_BASE; |
| 46 | struct rcar_swdt *swdt = (struct rcar_swdt *)SWDT_BASE; |
| 47 | u32 stc; |
| 48 | |
| 49 | /* Watchdog init */ |
| 50 | writel(0xA5A5A500, &rwdt->rwtcsra); |
| 51 | writel(0xA5A5A500, &swdt->swtcsra); |
| 52 | |
| 53 | /* CPU frequency setting. Set to 0.8GHz */ |
Tom Rini | 8c70baa | 2021-12-14 13:36:40 -0500 | [diff] [blame] | 54 | stc = ((800 / CLK2MHZ(get_board_sys_clk())) - 1) << PLL0_STC_OFFSET; |
Marek Vasut | b47bc37 | 2017-10-09 21:08:10 +0200 | [diff] [blame] | 55 | clrsetbits_le32(PLL0CR, PLL0_STC_MASK, stc); |
| 56 | } |
| 57 | |
Marek Vasut | b47bc37 | 2017-10-09 21:08:10 +0200 | [diff] [blame] | 58 | int board_early_init_f(void) |
| 59 | { |
Marek Vasut | f20ea91 | 2018-06-16 01:16:50 +0200 | [diff] [blame] | 60 | /* Unlock CPG access */ |
| 61 | writel(0xA5A5FFFF, CPGWPR); |
| 62 | writel(0x5A5A0000, CPGWPCR); |
Marek Vasut | b47bc37 | 2017-10-09 21:08:10 +0200 | [diff] [blame] | 63 | |
Marek Vasut | b47bc37 | 2017-10-09 21:08:10 +0200 | [diff] [blame] | 64 | return 0; |
| 65 | } |
| 66 | |
| 67 | int board_init(void) |
| 68 | { |
Marek Vasut | b47bc37 | 2017-10-09 21:08:10 +0200 | [diff] [blame] | 69 | return 0; |
| 70 | } |
| 71 | |
Marek Vasut | b47bc37 | 2017-10-09 21:08:10 +0200 | [diff] [blame] | 72 | #define RST_BASE 0xE6160000 |
| 73 | #define RST_CA57RESCNT (RST_BASE + 0x40) |
| 74 | #define RST_CA53RESCNT (RST_BASE + 0x44) |
| 75 | #define RST_RSTOUTCR (RST_BASE + 0x58) |
| 76 | #define RST_CA57_CODE 0xA5A5000F |
| 77 | #define RST_CA53_CODE 0x5A5A000F |
| 78 | |
Harald Seiler | 6f14d5f | 2020-12-15 16:47:52 +0100 | [diff] [blame] | 79 | void reset_cpu(void) |
Marek Vasut | b47bc37 | 2017-10-09 21:08:10 +0200 | [diff] [blame] | 80 | { |
| 81 | unsigned long midr, cputype; |
| 82 | |
| 83 | asm volatile("mrs %0, midr_el1" : "=r" (midr)); |
| 84 | cputype = (midr >> 4) & 0xfff; |
| 85 | |
| 86 | if (cputype == 0xd03) |
| 87 | writel(RST_CA53_CODE, RST_CA53RESCNT); |
| 88 | else if (cputype == 0xd07) |
| 89 | writel(RST_CA57_CODE, RST_CA57RESCNT); |
| 90 | else |
| 91 | hang(); |
| 92 | } |