blob: 30e4e23a6438d561fd149b5df39f01eb7e85145f [file] [log] [blame]
Tom Rini10e47792018-05-06 17:58:06 -04001// SPDX-License-Identifier: GPL-2.0+
Masahiro Yamada1f3d9c72015-02-05 14:42:54 +09002/*
Masahiro Yamadae59ed192016-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 Yamada1f3d9c72015-02-05 14:42:54 +09006 */
7
Masahiro Yamada7b9fc452017-11-29 15:01:22 +09008#include <linux/errno.h>
Masahiro Yamada24802562016-06-29 19:39:03 +09009#include <linux/io.h>
Masahiro Yamada7b9fc452017-11-29 15:01:22 +090010#include <linux/printk.h>
Masahiro Yamada24802562016-06-29 19:39:03 +090011
Masahiro Yamadaefdf3402016-01-09 01:51:13 +090012#include "init.h"
13#include "micro-support-card.h"
14#include "soc-info.h"
Masahiro Yamada1f3d9c72015-02-05 14:42:54 +090015
Masahiro Yamadaed16cf02020-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 Yamada266111c2017-01-15 14:59:08 +090043#ifdef CONFIG_ARCH_UNIPHIER_LD20
44static void uniphier_ld20_misc_init(void)
Masahiro Yamada1f3d9c72015-02-05 14:42:54 +090045{
Masahiro Yamada266111c2017-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 Yamada266111c2017-01-15 14:59:08 +090053}
54#endif
Masahiro Yamada1f3d9c72015-02-05 14:42:54 +090055
Masahiro Yamada266111c2017-01-15 14:59:08 +090056struct uniphier_initdata {
Masahiro Yamada31649052017-01-21 18:05:26 +090057 unsigned int soc_id;
Masahiro Yamada0cc46ad2017-01-15 14:59:10 +090058 void (*sbc_init)(void);
Masahiro Yamada266111c2017-01-15 14:59:08 +090059 void (*pll_init)(void);
60 void (*clk_init)(void);
61 void (*misc_init)(void);
62};
63
Masahiro Yamadaf17e5982017-01-21 18:05:21 +090064static const struct uniphier_initdata uniphier_initdata[] = {
Masahiro Yamada53c59ae2016-03-18 16:41:43 +090065#if defined(CONFIG_ARCH_UNIPHIER_LD4)
Masahiro Yamada266111c2017-01-15 14:59:08 +090066 {
Masahiro Yamada31649052017-01-21 18:05:26 +090067 .soc_id = UNIPHIER_LD4_ID,
Masahiro Yamada0cc46ad2017-01-15 14:59:10 +090068 .sbc_init = uniphier_ld4_sbc_init,
Masahiro Yamada266111c2017-01-15 14:59:08 +090069 .pll_init = uniphier_ld4_pll_init,
Masahiro Yamada266111c2017-01-15 14:59:08 +090070 },
Masahiro Yamada75f16f82015-09-22 00:27:39 +090071#endif
Masahiro Yamada53c59ae2016-03-18 16:41:43 +090072#if defined(CONFIG_ARCH_UNIPHIER_PRO4)
Masahiro Yamada266111c2017-01-15 14:59:08 +090073 {
Masahiro Yamada31649052017-01-21 18:05:26 +090074 .soc_id = UNIPHIER_PRO4_ID,
Masahiro Yamada266111c2017-01-15 14:59:08 +090075 .pll_init = uniphier_pro4_pll_init,
76 .clk_init = uniphier_pro4_clk_init,
77 },
Masahiro Yamada75f16f82015-09-22 00:27:39 +090078#endif
Masahiro Yamada53c59ae2016-03-18 16:41:43 +090079#if defined(CONFIG_ARCH_UNIPHIER_SLD8)
Masahiro Yamada266111c2017-01-15 14:59:08 +090080 {
Masahiro Yamada31649052017-01-21 18:05:26 +090081 .soc_id = UNIPHIER_SLD8_ID,
Masahiro Yamada0cc46ad2017-01-15 14:59:10 +090082 .sbc_init = uniphier_ld4_sbc_init,
Masahiro Yamada266111c2017-01-15 14:59:08 +090083 .pll_init = uniphier_ld4_pll_init,
Masahiro Yamada266111c2017-01-15 14:59:08 +090084 },
Masahiro Yamada75f16f82015-09-22 00:27:39 +090085#endif
Masahiro Yamada53c59ae2016-03-18 16:41:43 +090086#if defined(CONFIG_ARCH_UNIPHIER_PRO5)
Masahiro Yamada266111c2017-01-15 14:59:08 +090087 {
Masahiro Yamada31649052017-01-21 18:05:26 +090088 .soc_id = UNIPHIER_PRO5_ID,
Masahiro Yamada266111c2017-01-15 14:59:08 +090089 .clk_init = uniphier_pro5_clk_init,
90 },
Masahiro Yamadad5167d52015-09-22 00:27:40 +090091#endif
Masahiro Yamada53c59ae2016-03-18 16:41:43 +090092#if defined(CONFIG_ARCH_UNIPHIER_PXS2)
Masahiro Yamada266111c2017-01-15 14:59:08 +090093 {
Masahiro Yamada31649052017-01-21 18:05:26 +090094 .soc_id = UNIPHIER_PXS2_ID,
Masahiro Yamada0cc46ad2017-01-15 14:59:10 +090095 .sbc_init = uniphier_pxs2_sbc_init,
Masahiro Yamada266111c2017-01-15 14:59:08 +090096 .clk_init = uniphier_pxs2_clk_init,
97 },
Masahiro Yamada1fe65d32015-09-22 00:27:41 +090098#endif
Masahiro Yamada53c59ae2016-03-18 16:41:43 +090099#if defined(CONFIG_ARCH_UNIPHIER_LD6B)
Masahiro Yamada266111c2017-01-15 14:59:08 +0900100 {
Masahiro Yamada31649052017-01-21 18:05:26 +0900101 .soc_id = UNIPHIER_LD6B_ID,
Masahiro Yamada0cc46ad2017-01-15 14:59:10 +0900102 .sbc_init = uniphier_pxs2_sbc_init,
Masahiro Yamada266111c2017-01-15 14:59:08 +0900103 .clk_init = uniphier_pxs2_clk_init,
104 },
Masahiro Yamada1fe65d32015-09-22 00:27:41 +0900105#endif
Masahiro Yamada8bbbcbd2016-05-24 21:14:01 +0900106#if defined(CONFIG_ARCH_UNIPHIER_LD11)
Masahiro Yamada266111c2017-01-15 14:59:08 +0900107 {
Masahiro Yamada31649052017-01-21 18:05:26 +0900108 .soc_id = UNIPHIER_LD11_ID,
Masahiro Yamadaed16cf02020-07-09 15:08:19 +0900109 .sbc_init = uniphier_pxs2_sbc_init,
Masahiro Yamada266111c2017-01-15 14:59:08 +0900110 .pll_init = uniphier_ld11_pll_init,
111 .clk_init = uniphier_ld11_clk_init,
Masahiro Yamada266111c2017-01-15 14:59:08 +0900112 },
Masahiro Yamada8bbbcbd2016-05-24 21:14:01 +0900113#endif
Masahiro Yamada063eb1e2016-04-21 14:43:18 +0900114#if defined(CONFIG_ARCH_UNIPHIER_LD20)
Masahiro Yamada266111c2017-01-15 14:59:08 +0900115 {
Masahiro Yamada31649052017-01-21 18:05:26 +0900116 .soc_id = UNIPHIER_LD20_ID,
Masahiro Yamadaed16cf02020-07-09 15:08:19 +0900117 .sbc_init = uniphier_pxs2_sbc_init,
Masahiro Yamada266111c2017-01-15 14:59:08 +0900118 .pll_init = uniphier_ld20_pll_init,
Masahiro Yamadab3b1bb72017-02-17 16:17:22 +0900119 .clk_init = uniphier_ld20_clk_init,
Masahiro Yamada266111c2017-01-15 14:59:08 +0900120 .misc_init = uniphier_ld20_misc_init,
121 },
Masahiro Yamada063eb1e2016-04-21 14:43:18 +0900122#endif
Masahiro Yamada133b1262017-01-21 18:05:31 +0900123#if defined(CONFIG_ARCH_UNIPHIER_PXS3)
124 {
125 .soc_id = UNIPHIER_PXS3_ID,
Masahiro Yamada133b1262017-01-21 18:05:31 +0900126 .sbc_init = uniphier_pxs2_sbc_init,
127 .pll_init = uniphier_pxs3_pll_init,
Masahiro Yamada8e0a4502017-05-15 14:26:33 +0900128 .clk_init = uniphier_pxs3_clk_init,
Masahiro Yamada133b1262017-01-21 18:05:31 +0900129 },
130#endif
Masahiro Yamada266111c2017-01-15 14:59:08 +0900131};
Masahiro Yamada1b818982017-01-21 18:05:27 +0900132UNIPHIER_DEFINE_SOCDATA_FUNC(uniphier_get_initdata, uniphier_initdata)
Masahiro Yamada266111c2017-01-15 14:59:08 +0900133
134int board_init(void)
135{
Masahiro Yamadaf17e5982017-01-21 18:05:21 +0900136 const struct uniphier_initdata *initdata;
Masahiro Yamada266111c2017-01-15 14:59:08 +0900137
138 led_puts("U0");
139
Masahiro Yamada1b818982017-01-21 18:05:27 +0900140 initdata = uniphier_get_initdata();
Masahiro Yamada266111c2017-01-15 14:59:08 +0900141 if (!initdata) {
Masahiro Yamada1b818982017-01-21 18:05:27 +0900142 pr_err("unsupported SoC\n");
Masahiro Yamada266111c2017-01-15 14:59:08 +0900143 return -EINVAL;
144 }
145
Masahiro Yamadaed16cf02020-07-09 15:08:19 +0900146 if (initdata->sbc_init)
147 initdata->sbc_init();
Masahiro Yamada0cc46ad2017-01-15 14:59:10 +0900148
149 support_card_init();
150
151 led_puts("U0");
152
Masahiro Yamada266111c2017-01-15 14:59:08 +0900153 if (initdata->pll_init)
154 initdata->pll_init();
Masahiro Yamada24802562016-06-29 19:39:03 +0900155
Masahiro Yamada285ceed2017-08-26 17:58:03 +0900156 led_puts("U1");
Masahiro Yamadac04368f2015-02-27 02:26:51 +0900157
Masahiro Yamada266111c2017-01-15 14:59:08 +0900158 if (initdata->clk_init)
159 initdata->clk_init();
Masahiro Yamadae59ed192016-09-14 01:06:08 +0900160
Masahiro Yamada285ceed2017-08-26 17:58:03 +0900161 led_puts("U2");
Masahiro Yamadae59ed192016-09-14 01:06:08 +0900162
Masahiro Yamada266111c2017-01-15 14:59:08 +0900163 if (initdata->misc_init)
164 initdata->misc_init();
165
Masahiro Yamadae59ed192016-09-14 01:06:08 +0900166 led_puts("Uboo");
167
Masahiro Yamada1f3d9c72015-02-05 14:42:54 +0900168 return 0;
169}