blob: 7535f915286d430451abe4409b020839d5807871 [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 Yamadab61664e2017-01-15 14:59:08 +090016#ifdef CONFIG_ARCH_UNIPHIER_LD20
17static void uniphier_ld20_misc_init(void)
18{
Masahiro Yamadab61664e2017-01-15 14:59:08 +090019 /* ES1 errata: increase VDD09 supply to suppress VBO noise */
20 if (uniphier_get_soc_revision() == 1) {
21 writel(0x00000003, 0x6184e004);
22 writel(0x00000100, 0x6184e040);
23 writel(0x0000b500, 0x6184e024);
24 writel(0x00000001, 0x6184e000);
25 }
Masahiro Yamadab61664e2017-01-15 14:59:08 +090026}
27#endif
28
29struct uniphier_initdata {
Masahiro Yamadae27d6c72017-01-21 18:05:26 +090030 unsigned int soc_id;
Masahiro Yamada26b09c02017-01-15 14:59:10 +090031 void (*sbc_init)(void);
Masahiro Yamadab61664e2017-01-15 14:59:08 +090032 void (*pll_init)(void);
33 void (*clk_init)(void);
34 void (*misc_init)(void);
35};
36
Masahiro Yamada7a37bd62017-01-21 18:05:21 +090037static const struct uniphier_initdata uniphier_initdata[] = {
Masahiro Yamadab61664e2017-01-15 14:59:08 +090038#if defined(CONFIG_ARCH_UNIPHIER_LD4)
39 {
Masahiro Yamadae27d6c72017-01-21 18:05:26 +090040 .soc_id = UNIPHIER_LD4_ID,
Masahiro Yamada26b09c02017-01-15 14:59:10 +090041 .sbc_init = uniphier_ld4_sbc_init,
Masahiro Yamadab61664e2017-01-15 14:59:08 +090042 .pll_init = uniphier_ld4_pll_init,
43 .clk_init = uniphier_ld4_clk_init,
44 },
45#endif
46#if defined(CONFIG_ARCH_UNIPHIER_PRO4)
47 {
Masahiro Yamadae27d6c72017-01-21 18:05:26 +090048 .soc_id = UNIPHIER_PRO4_ID,
Masahiro Yamada26b09c02017-01-15 14:59:10 +090049 .sbc_init = uniphier_sbc_init_savepin,
Masahiro Yamadab61664e2017-01-15 14:59:08 +090050 .pll_init = uniphier_pro4_pll_init,
51 .clk_init = uniphier_pro4_clk_init,
52 },
53#endif
54#if defined(CONFIG_ARCH_UNIPHIER_SLD8)
55 {
Masahiro Yamadae27d6c72017-01-21 18:05:26 +090056 .soc_id = UNIPHIER_SLD8_ID,
Masahiro Yamada26b09c02017-01-15 14:59:10 +090057 .sbc_init = uniphier_ld4_sbc_init,
Masahiro Yamadab61664e2017-01-15 14:59:08 +090058 .pll_init = uniphier_ld4_pll_init,
59 .clk_init = uniphier_ld4_clk_init,
60 },
61#endif
62#if defined(CONFIG_ARCH_UNIPHIER_PRO5)
63 {
Masahiro Yamadae27d6c72017-01-21 18:05:26 +090064 .soc_id = UNIPHIER_PRO5_ID,
Masahiro Yamada26b09c02017-01-15 14:59:10 +090065 .sbc_init = uniphier_sbc_init_savepin,
Masahiro Yamadab61664e2017-01-15 14:59:08 +090066 .clk_init = uniphier_pro5_clk_init,
67 },
68#endif
69#if defined(CONFIG_ARCH_UNIPHIER_PXS2)
70 {
Masahiro Yamadae27d6c72017-01-21 18:05:26 +090071 .soc_id = UNIPHIER_PXS2_ID,
Masahiro Yamada26b09c02017-01-15 14:59:10 +090072 .sbc_init = uniphier_pxs2_sbc_init,
Masahiro Yamadab61664e2017-01-15 14:59:08 +090073 .clk_init = uniphier_pxs2_clk_init,
74 },
75#endif
76#if defined(CONFIG_ARCH_UNIPHIER_LD6B)
77 {
Masahiro Yamadae27d6c72017-01-21 18:05:26 +090078 .soc_id = UNIPHIER_LD6B_ID,
Masahiro Yamada26b09c02017-01-15 14:59:10 +090079 .sbc_init = uniphier_pxs2_sbc_init,
Masahiro Yamadab61664e2017-01-15 14:59:08 +090080 .clk_init = uniphier_pxs2_clk_init,
81 },
82#endif
83#if defined(CONFIG_ARCH_UNIPHIER_LD11)
84 {
Masahiro Yamadae27d6c72017-01-21 18:05:26 +090085 .soc_id = UNIPHIER_LD11_ID,
Masahiro Yamada26b09c02017-01-15 14:59:10 +090086 .sbc_init = uniphier_ld11_sbc_init,
Masahiro Yamadab61664e2017-01-15 14:59:08 +090087 .pll_init = uniphier_ld11_pll_init,
88 .clk_init = uniphier_ld11_clk_init,
Masahiro Yamadab61664e2017-01-15 14:59:08 +090089 },
90#endif
91#if defined(CONFIG_ARCH_UNIPHIER_LD20)
92 {
Masahiro Yamadae27d6c72017-01-21 18:05:26 +090093 .soc_id = UNIPHIER_LD20_ID,
Masahiro Yamada26b09c02017-01-15 14:59:10 +090094 .sbc_init = uniphier_ld11_sbc_init,
Masahiro Yamadab61664e2017-01-15 14:59:08 +090095 .pll_init = uniphier_ld20_pll_init,
Masahiro Yamadac21f5852017-02-17 16:17:22 +090096 .clk_init = uniphier_ld20_clk_init,
Masahiro Yamadab61664e2017-01-15 14:59:08 +090097 .misc_init = uniphier_ld20_misc_init,
98 },
99#endif
Masahiro Yamada2c2ab3d2017-01-21 18:05:31 +0900100#if defined(CONFIG_ARCH_UNIPHIER_PXS3)
101 {
102 .soc_id = UNIPHIER_PXS3_ID,
Masahiro Yamada2c2ab3d2017-01-21 18:05:31 +0900103 .sbc_init = uniphier_pxs2_sbc_init,
104 .pll_init = uniphier_pxs3_pll_init,
Masahiro Yamada81afa9c2017-05-15 14:26:33 +0900105 .clk_init = uniphier_pxs3_clk_init,
Masahiro Yamada2c2ab3d2017-01-21 18:05:31 +0900106 },
107#endif
Masahiro Yamadab61664e2017-01-15 14:59:08 +0900108};
Masahiro Yamadaee8ef5a2017-01-21 18:05:27 +0900109UNIPHIER_DEFINE_SOCDATA_FUNC(uniphier_get_initdata, uniphier_initdata)
Masahiro Yamada5ac9dfb2016-09-17 03:33:04 +0900110
Masahiro Yamadab2916712016-09-14 01:06:08 +0900111int board_init(void)
Masahiro Yamada84ccd792015-02-05 14:42:54 +0900112{
Masahiro Yamada7a37bd62017-01-21 18:05:21 +0900113 const struct uniphier_initdata *initdata;
Masahiro Yamadab61664e2017-01-15 14:59:08 +0900114
Masahiro Yamada84697002015-09-22 00:27:31 +0900115 led_puts("U0");
Masahiro Yamada84ccd792015-02-05 14:42:54 +0900116
Masahiro Yamadaee8ef5a2017-01-21 18:05:27 +0900117 initdata = uniphier_get_initdata();
Masahiro Yamadab61664e2017-01-15 14:59:08 +0900118 if (!initdata) {
Masahiro Yamadaee8ef5a2017-01-21 18:05:27 +0900119 pr_err("unsupported SoC\n");
Masahiro Yamadab61664e2017-01-15 14:59:08 +0900120 return -EINVAL;
Masahiro Yamada323d1f92015-09-22 00:27:39 +0900121 }
Masahiro Yamada198a97a2015-02-27 02:26:51 +0900122
Masahiro Yamada26b09c02017-01-15 14:59:10 +0900123 initdata->sbc_init();
124
125 support_card_init();
126
127 led_puts("U0");
128
Masahiro Yamadab61664e2017-01-15 14:59:08 +0900129 if (initdata->pll_init)
130 initdata->pll_init();
Masahiro Yamadae64a6b12016-06-29 19:39:03 +0900131
Masahiro Yamadae0daca72017-08-26 17:58:03 +0900132 led_puts("U1");
Masahiro Yamada198a97a2015-02-27 02:26:51 +0900133
Masahiro Yamadab61664e2017-01-15 14:59:08 +0900134 if (initdata->clk_init)
135 initdata->clk_init();
Masahiro Yamadab2916712016-09-14 01:06:08 +0900136
Masahiro Yamadae0daca72017-08-26 17:58:03 +0900137 led_puts("U2");
Masahiro Yamadab2916712016-09-14 01:06:08 +0900138
Masahiro Yamadab61664e2017-01-15 14:59:08 +0900139 if (initdata->misc_init)
140 initdata->misc_init();
141
Masahiro Yamadae0daca72017-08-26 17:58:03 +0900142 led_puts("U3");
Masahiro Yamadab61664e2017-01-15 14:59:08 +0900143
Masahiro Yamadab61664e2017-01-15 14:59:08 +0900144 support_card_late_init();
145
Masahiro Yamadab2916712016-09-14 01:06:08 +0900146 led_puts("Uboo");
147
Masahiro Yamada84ccd792015-02-05 14:42:54 +0900148 return 0;
149}