blob: 30e4e23a6438d561fd149b5df39f01eb7e85145f [file] [log] [blame]
Tom Rini83d290c2018-05-06 17:58:06 -04001// SPDX-License-Identifier: GPL-2.0+
Masahiro Yamada84ccd792015-02-05 14:42:54 +09002/*
Masahiro Yamadab2916712016-09-14 01:06:08 +09003 * Copyright (C) 2012-2015 Panasonic Corporation
4 * Copyright (C) 2015-2016 Socionext Inc.
5 * Author: Masahiro Yamada <yamada.masahiro@socionext.com>
Masahiro Yamada84ccd792015-02-05 14:42:54 +09006 */
7
Masahiro Yamadaac389b02017-11-29 15:01:22 +09008#include <linux/errno.h>
Masahiro Yamadae64a6b12016-06-29 19:39:03 +09009#include <linux/io.h>
Masahiro Yamadaac389b02017-11-29 15:01:22 +090010#include <linux/printk.h>
Masahiro Yamadae64a6b12016-06-29 19:39:03 +090011
Masahiro Yamada107b3fb2016-01-09 01:51:13 +090012#include "init.h"
13#include "micro-support-card.h"
14#include "soc-info.h"
Masahiro Yamada84ccd792015-02-05 14:42:54 +090015
Masahiro Yamada86227492020-07-09 15:08:19 +090016#define PC0CTRL 0x598000c0
17
18#if defined(CONFIG_ARCH_UNIPHIER_LD4) || defined(CONFIG_ARCH_UNIPHIER_SLD8)
19static void uniphier_ld4_sbc_init(void)
20{
21 u32 tmp;
22
23 /* system bus output enable */
24 tmp = readl(PC0CTRL);
25 tmp &= 0xfffffcff;
26 writel(tmp, PC0CTRL);
27}
28#endif
29
30#if defined(CONFIG_ARCH_UNIPHIER_PXS2) || \
31 defined(CONFIG_ARCH_UNIPHIER_LD6B) || \
32 defined(CONFIG_ARCH_UNIPHIER_LD11) || \
33 defined(CONFIG_ARCH_UNIPHIER_LD20) || \
34 defined(CONFIG_ARCH_UNIPHIER_PXS3)
35static void uniphier_pxs2_sbc_init(void)
36{
37 /* necessary for ROM boot ?? */
38 /* system bus output enable */
39 writel(0x17, PC0CTRL);
40}
41#endif
42
Masahiro Yamadab61664e2017-01-15 14:59:08 +090043#ifdef CONFIG_ARCH_UNIPHIER_LD20
44static void uniphier_ld20_misc_init(void)
45{
Masahiro Yamadab61664e2017-01-15 14:59:08 +090046 /* ES1 errata: increase VDD09 supply to suppress VBO noise */
47 if (uniphier_get_soc_revision() == 1) {
48 writel(0x00000003, 0x6184e004);
49 writel(0x00000100, 0x6184e040);
50 writel(0x0000b500, 0x6184e024);
51 writel(0x00000001, 0x6184e000);
52 }
Masahiro Yamadab61664e2017-01-15 14:59:08 +090053}
54#endif
55
56struct uniphier_initdata {
Masahiro Yamadae27d6c72017-01-21 18:05:26 +090057 unsigned int soc_id;
Masahiro Yamada26b09c02017-01-15 14:59:10 +090058 void (*sbc_init)(void);
Masahiro Yamadab61664e2017-01-15 14:59:08 +090059 void (*pll_init)(void);
60 void (*clk_init)(void);
61 void (*misc_init)(void);
62};
63
Masahiro Yamada7a37bd62017-01-21 18:05:21 +090064static const struct uniphier_initdata uniphier_initdata[] = {
Masahiro Yamadab61664e2017-01-15 14:59:08 +090065#if defined(CONFIG_ARCH_UNIPHIER_LD4)
66 {
Masahiro Yamadae27d6c72017-01-21 18:05:26 +090067 .soc_id = UNIPHIER_LD4_ID,
Masahiro Yamada26b09c02017-01-15 14:59:10 +090068 .sbc_init = uniphier_ld4_sbc_init,
Masahiro Yamadab61664e2017-01-15 14:59:08 +090069 .pll_init = uniphier_ld4_pll_init,
Masahiro Yamadab61664e2017-01-15 14:59:08 +090070 },
71#endif
72#if defined(CONFIG_ARCH_UNIPHIER_PRO4)
73 {
Masahiro Yamadae27d6c72017-01-21 18:05:26 +090074 .soc_id = UNIPHIER_PRO4_ID,
Masahiro Yamadab61664e2017-01-15 14:59:08 +090075 .pll_init = uniphier_pro4_pll_init,
76 .clk_init = uniphier_pro4_clk_init,
77 },
78#endif
79#if defined(CONFIG_ARCH_UNIPHIER_SLD8)
80 {
Masahiro Yamadae27d6c72017-01-21 18:05:26 +090081 .soc_id = UNIPHIER_SLD8_ID,
Masahiro Yamada26b09c02017-01-15 14:59:10 +090082 .sbc_init = uniphier_ld4_sbc_init,
Masahiro Yamadab61664e2017-01-15 14:59:08 +090083 .pll_init = uniphier_ld4_pll_init,
Masahiro Yamadab61664e2017-01-15 14:59:08 +090084 },
85#endif
86#if defined(CONFIG_ARCH_UNIPHIER_PRO5)
87 {
Masahiro Yamadae27d6c72017-01-21 18:05:26 +090088 .soc_id = UNIPHIER_PRO5_ID,
Masahiro Yamadab61664e2017-01-15 14:59:08 +090089 .clk_init = uniphier_pro5_clk_init,
90 },
91#endif
92#if defined(CONFIG_ARCH_UNIPHIER_PXS2)
93 {
Masahiro Yamadae27d6c72017-01-21 18:05:26 +090094 .soc_id = UNIPHIER_PXS2_ID,
Masahiro Yamada26b09c02017-01-15 14:59:10 +090095 .sbc_init = uniphier_pxs2_sbc_init,
Masahiro Yamadab61664e2017-01-15 14:59:08 +090096 .clk_init = uniphier_pxs2_clk_init,
97 },
98#endif
99#if defined(CONFIG_ARCH_UNIPHIER_LD6B)
100 {
Masahiro Yamadae27d6c72017-01-21 18:05:26 +0900101 .soc_id = UNIPHIER_LD6B_ID,
Masahiro Yamada26b09c02017-01-15 14:59:10 +0900102 .sbc_init = uniphier_pxs2_sbc_init,
Masahiro Yamadab61664e2017-01-15 14:59:08 +0900103 .clk_init = uniphier_pxs2_clk_init,
104 },
105#endif
106#if defined(CONFIG_ARCH_UNIPHIER_LD11)
107 {
Masahiro Yamadae27d6c72017-01-21 18:05:26 +0900108 .soc_id = UNIPHIER_LD11_ID,
Masahiro Yamada86227492020-07-09 15:08:19 +0900109 .sbc_init = uniphier_pxs2_sbc_init,
Masahiro Yamadab61664e2017-01-15 14:59:08 +0900110 .pll_init = uniphier_ld11_pll_init,
111 .clk_init = uniphier_ld11_clk_init,
Masahiro Yamadab61664e2017-01-15 14:59:08 +0900112 },
113#endif
114#if defined(CONFIG_ARCH_UNIPHIER_LD20)
115 {
Masahiro Yamadae27d6c72017-01-21 18:05:26 +0900116 .soc_id = UNIPHIER_LD20_ID,
Masahiro Yamada86227492020-07-09 15:08:19 +0900117 .sbc_init = uniphier_pxs2_sbc_init,
Masahiro Yamadab61664e2017-01-15 14:59:08 +0900118 .pll_init = uniphier_ld20_pll_init,
Masahiro Yamadac21f5852017-02-17 16:17:22 +0900119 .clk_init = uniphier_ld20_clk_init,
Masahiro Yamadab61664e2017-01-15 14:59:08 +0900120 .misc_init = uniphier_ld20_misc_init,
121 },
122#endif
Masahiro Yamada2c2ab3d2017-01-21 18:05:31 +0900123#if defined(CONFIG_ARCH_UNIPHIER_PXS3)
124 {
125 .soc_id = UNIPHIER_PXS3_ID,
Masahiro Yamada2c2ab3d2017-01-21 18:05:31 +0900126 .sbc_init = uniphier_pxs2_sbc_init,
127 .pll_init = uniphier_pxs3_pll_init,
Masahiro Yamada81afa9c2017-05-15 14:26:33 +0900128 .clk_init = uniphier_pxs3_clk_init,
Masahiro Yamada2c2ab3d2017-01-21 18:05:31 +0900129 },
130#endif
Masahiro Yamadab61664e2017-01-15 14:59:08 +0900131};
Masahiro Yamadaee8ef5a2017-01-21 18:05:27 +0900132UNIPHIER_DEFINE_SOCDATA_FUNC(uniphier_get_initdata, uniphier_initdata)
Masahiro Yamada5ac9dfb2016-09-17 03:33:04 +0900133
Masahiro Yamadab2916712016-09-14 01:06:08 +0900134int board_init(void)
Masahiro Yamada84ccd792015-02-05 14:42:54 +0900135{
Masahiro Yamada7a37bd62017-01-21 18:05:21 +0900136 const struct uniphier_initdata *initdata;
Masahiro Yamadab61664e2017-01-15 14:59:08 +0900137
Masahiro Yamada84697002015-09-22 00:27:31 +0900138 led_puts("U0");
Masahiro Yamada84ccd792015-02-05 14:42:54 +0900139
Masahiro Yamadaee8ef5a2017-01-21 18:05:27 +0900140 initdata = uniphier_get_initdata();
Masahiro Yamadab61664e2017-01-15 14:59:08 +0900141 if (!initdata) {
Masahiro Yamadaee8ef5a2017-01-21 18:05:27 +0900142 pr_err("unsupported SoC\n");
Masahiro Yamadab61664e2017-01-15 14:59:08 +0900143 return -EINVAL;
Masahiro Yamada323d1f92015-09-22 00:27:39 +0900144 }
Masahiro Yamada198a97a2015-02-27 02:26:51 +0900145
Masahiro Yamada86227492020-07-09 15:08:19 +0900146 if (initdata->sbc_init)
147 initdata->sbc_init();
Masahiro Yamada26b09c02017-01-15 14:59:10 +0900148
149 support_card_init();
150
151 led_puts("U0");
152
Masahiro Yamadab61664e2017-01-15 14:59:08 +0900153 if (initdata->pll_init)
154 initdata->pll_init();
Masahiro Yamadae64a6b12016-06-29 19:39:03 +0900155
Masahiro Yamadae0daca72017-08-26 17:58:03 +0900156 led_puts("U1");
Masahiro Yamada198a97a2015-02-27 02:26:51 +0900157
Masahiro Yamadab61664e2017-01-15 14:59:08 +0900158 if (initdata->clk_init)
159 initdata->clk_init();
Masahiro Yamadab2916712016-09-14 01:06:08 +0900160
Masahiro Yamadae0daca72017-08-26 17:58:03 +0900161 led_puts("U2");
Masahiro Yamadab2916712016-09-14 01:06:08 +0900162
Masahiro Yamadab61664e2017-01-15 14:59:08 +0900163 if (initdata->misc_init)
164 initdata->misc_init();
165
Masahiro Yamadab2916712016-09-14 01:06:08 +0900166 led_puts("Uboo");
167
Masahiro Yamada84ccd792015-02-05 14:42:54 +0900168 return 0;
169}