blob: 929f50a883a3bd9ff8d19b8f019de1f89b4d03cc [file] [log] [blame]
Masahiro Yamada5894ca02014-10-03 19:21:06 +09001/*
Masahiro Yamadaf6e7f072015-05-29 17:30:00 +09002 * Copyright (C) 2011-2015 Masahiro Yamada <yamada.masahiro@socionext.com>
Masahiro Yamada5894ca02014-10-03 19:21:06 +09003 *
4 * SPDX-License-Identifier: GPL-2.0+
5 */
6
7#include <common.h>
Masahiro Yamadaf6e7f072015-05-29 17:30:00 +09008#include <linux/io.h>
Masahiro Yamada323d1f92015-09-22 00:27:39 +09009#include <mach/init.h>
Masahiro Yamadaa86ac952015-02-27 02:26:44 +090010#include <mach/sbc-regs.h>
11#include <mach/sg-regs.h>
Masahiro Yamada5894ca02014-10-03 19:21:06 +090012
Masahiro Yamada323d1f92015-09-22 00:27:39 +090013int ph1_ld4_sbc_init(const struct uniphier_board_data *bd)
Masahiro Yamada5894ca02014-10-03 19:21:06 +090014{
Masahiro Yamada2661dfd2015-01-06 14:20:04 +090015 u32 tmp;
16
17 /* system bus output enable */
18 tmp = readl(PC0CTRL);
19 tmp &= 0xfffffcff;
20 writel(tmp, PC0CTRL);
21
Masahiro Yamadaea6de4a2015-02-27 02:27:02 +090022 /*
23 * Only CS1 is connected to support card.
24 * BKSZ[1:0] should be set to "01".
25 */
26 writel(SBCTRL0_SAVEPIN_PERI_VALUE, SBCTRL10);
27 writel(SBCTRL1_SAVEPIN_PERI_VALUE, SBCTRL11);
28 writel(SBCTRL2_SAVEPIN_PERI_VALUE, SBCTRL12);
29 writel(SBCTRL4_SAVEPIN_PERI_VALUE, SBCTRL14);
Masahiro Yamada5894ca02014-10-03 19:21:06 +090030
Masahiro Yamadaea6de4a2015-02-27 02:27:02 +090031 if (boot_is_swapped()) {
32 /*
33 * Boot Swap On: boot from external NOR/SRAM
Masahiro Yamadad5ed8c52015-09-11 20:17:47 +090034 * 0x42000000-0x43ffffff is a mirror of 0x40000000-0x41ffffff.
Masahiro Yamadaea6de4a2015-02-27 02:27:02 +090035 *
Masahiro Yamadad5ed8c52015-09-11 20:17:47 +090036 * 0x40000000-0x41efffff, 0x42000000-0x43efffff: memory bank
37 * 0x41f00000-0x41ffffff, 0x43f00000-0x43ffffff: peripherals
Masahiro Yamadaea6de4a2015-02-27 02:27:02 +090038 */
39 writel(0x0000bc01, SBBASE0);
40 } else {
41 /*
42 * Boot Swap Off: boot from mask ROM
Masahiro Yamadad5ed8c52015-09-11 20:17:47 +090043 * 0x40000000-0x41ffffff: mask ROM
44 * 0x42000000-0x43efffff: memory bank (31MB)
45 * 0x43f00000-0x43ffffff: peripherals (1MB)
Masahiro Yamadaea6de4a2015-02-27 02:27:02 +090046 */
47 writel(0x0000be01, SBBASE0); /* dummy */
48 writel(0x0200be01, SBBASE1);
49 }
Masahiro Yamada323d1f92015-09-22 00:27:39 +090050
51 return 0;
Masahiro Yamada5894ca02014-10-03 19:21:06 +090052}