blob: 99727a3004201664459e00970028ffcd93f33fb3 [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,
Masahiro Yamadab61664e2017-01-15 14:59:08 +090043 },
44#endif
45#if defined(CONFIG_ARCH_UNIPHIER_PRO4)
46 {
Masahiro Yamadae27d6c72017-01-21 18:05:26 +090047 .soc_id = UNIPHIER_PRO4_ID,
Masahiro Yamada26b09c02017-01-15 14:59:10 +090048 .sbc_init = uniphier_sbc_init_savepin,
Masahiro Yamadab61664e2017-01-15 14:59:08 +090049 .pll_init = uniphier_pro4_pll_init,
50 .clk_init = uniphier_pro4_clk_init,
51 },
52#endif
53#if defined(CONFIG_ARCH_UNIPHIER_SLD8)
54 {
Masahiro Yamadae27d6c72017-01-21 18:05:26 +090055 .soc_id = UNIPHIER_SLD8_ID,
Masahiro Yamada26b09c02017-01-15 14:59:10 +090056 .sbc_init = uniphier_ld4_sbc_init,
Masahiro Yamadab61664e2017-01-15 14:59:08 +090057 .pll_init = uniphier_ld4_pll_init,
Masahiro Yamadab61664e2017-01-15 14:59:08 +090058 },
59#endif
60#if defined(CONFIG_ARCH_UNIPHIER_PRO5)
61 {
Masahiro Yamadae27d6c72017-01-21 18:05:26 +090062 .soc_id = UNIPHIER_PRO5_ID,
Masahiro Yamada26b09c02017-01-15 14:59:10 +090063 .sbc_init = uniphier_sbc_init_savepin,
Masahiro Yamadab61664e2017-01-15 14:59:08 +090064 .clk_init = uniphier_pro5_clk_init,
65 },
66#endif
67#if defined(CONFIG_ARCH_UNIPHIER_PXS2)
68 {
Masahiro Yamadae27d6c72017-01-21 18:05:26 +090069 .soc_id = UNIPHIER_PXS2_ID,
Masahiro Yamada26b09c02017-01-15 14:59:10 +090070 .sbc_init = uniphier_pxs2_sbc_init,
Masahiro Yamadab61664e2017-01-15 14:59:08 +090071 .clk_init = uniphier_pxs2_clk_init,
72 },
73#endif
74#if defined(CONFIG_ARCH_UNIPHIER_LD6B)
75 {
Masahiro Yamadae27d6c72017-01-21 18:05:26 +090076 .soc_id = UNIPHIER_LD6B_ID,
Masahiro Yamada26b09c02017-01-15 14:59:10 +090077 .sbc_init = uniphier_pxs2_sbc_init,
Masahiro Yamadab61664e2017-01-15 14:59:08 +090078 .clk_init = uniphier_pxs2_clk_init,
79 },
80#endif
81#if defined(CONFIG_ARCH_UNIPHIER_LD11)
82 {
Masahiro Yamadae27d6c72017-01-21 18:05:26 +090083 .soc_id = UNIPHIER_LD11_ID,
Masahiro Yamada26b09c02017-01-15 14:59:10 +090084 .sbc_init = uniphier_ld11_sbc_init,
Masahiro Yamadab61664e2017-01-15 14:59:08 +090085 .pll_init = uniphier_ld11_pll_init,
86 .clk_init = uniphier_ld11_clk_init,
Masahiro Yamadab61664e2017-01-15 14:59:08 +090087 },
88#endif
89#if defined(CONFIG_ARCH_UNIPHIER_LD20)
90 {
Masahiro Yamadae27d6c72017-01-21 18:05:26 +090091 .soc_id = UNIPHIER_LD20_ID,
Masahiro Yamada26b09c02017-01-15 14:59:10 +090092 .sbc_init = uniphier_ld11_sbc_init,
Masahiro Yamadab61664e2017-01-15 14:59:08 +090093 .pll_init = uniphier_ld20_pll_init,
Masahiro Yamadac21f5852017-02-17 16:17:22 +090094 .clk_init = uniphier_ld20_clk_init,
Masahiro Yamadab61664e2017-01-15 14:59:08 +090095 .misc_init = uniphier_ld20_misc_init,
96 },
97#endif
Masahiro Yamada2c2ab3d2017-01-21 18:05:31 +090098#if defined(CONFIG_ARCH_UNIPHIER_PXS3)
99 {
100 .soc_id = UNIPHIER_PXS3_ID,
Masahiro Yamada2c2ab3d2017-01-21 18:05:31 +0900101 .sbc_init = uniphier_pxs2_sbc_init,
102 .pll_init = uniphier_pxs3_pll_init,
Masahiro Yamada81afa9c2017-05-15 14:26:33 +0900103 .clk_init = uniphier_pxs3_clk_init,
Masahiro Yamada2c2ab3d2017-01-21 18:05:31 +0900104 },
105#endif
Masahiro Yamadab61664e2017-01-15 14:59:08 +0900106};
Masahiro Yamadaee8ef5a2017-01-21 18:05:27 +0900107UNIPHIER_DEFINE_SOCDATA_FUNC(uniphier_get_initdata, uniphier_initdata)
Masahiro Yamada5ac9dfb2016-09-17 03:33:04 +0900108
Masahiro Yamadab2916712016-09-14 01:06:08 +0900109int board_init(void)
Masahiro Yamada84ccd792015-02-05 14:42:54 +0900110{
Masahiro Yamada7a37bd62017-01-21 18:05:21 +0900111 const struct uniphier_initdata *initdata;
Masahiro Yamadab61664e2017-01-15 14:59:08 +0900112
Masahiro Yamada84697002015-09-22 00:27:31 +0900113 led_puts("U0");
Masahiro Yamada84ccd792015-02-05 14:42:54 +0900114
Masahiro Yamadaee8ef5a2017-01-21 18:05:27 +0900115 initdata = uniphier_get_initdata();
Masahiro Yamadab61664e2017-01-15 14:59:08 +0900116 if (!initdata) {
Masahiro Yamadaee8ef5a2017-01-21 18:05:27 +0900117 pr_err("unsupported SoC\n");
Masahiro Yamadab61664e2017-01-15 14:59:08 +0900118 return -EINVAL;
Masahiro Yamada323d1f92015-09-22 00:27:39 +0900119 }
Masahiro Yamada198a97a2015-02-27 02:26:51 +0900120
Masahiro Yamada26b09c02017-01-15 14:59:10 +0900121 initdata->sbc_init();
122
123 support_card_init();
124
125 led_puts("U0");
126
Masahiro Yamadab61664e2017-01-15 14:59:08 +0900127 if (initdata->pll_init)
128 initdata->pll_init();
Masahiro Yamadae64a6b12016-06-29 19:39:03 +0900129
Masahiro Yamadae0daca72017-08-26 17:58:03 +0900130 led_puts("U1");
Masahiro Yamada198a97a2015-02-27 02:26:51 +0900131
Masahiro Yamadab61664e2017-01-15 14:59:08 +0900132 if (initdata->clk_init)
133 initdata->clk_init();
Masahiro Yamadab2916712016-09-14 01:06:08 +0900134
Masahiro Yamadae0daca72017-08-26 17:58:03 +0900135 led_puts("U2");
Masahiro Yamadab2916712016-09-14 01:06:08 +0900136
Masahiro Yamadab61664e2017-01-15 14:59:08 +0900137 if (initdata->misc_init)
138 initdata->misc_init();
139
Masahiro Yamadae0daca72017-08-26 17:58:03 +0900140 led_puts("U3");
Masahiro Yamadab61664e2017-01-15 14:59:08 +0900141
Masahiro Yamadab61664e2017-01-15 14:59:08 +0900142 support_card_late_init();
143
Masahiro Yamadab2916712016-09-14 01:06:08 +0900144 led_puts("Uboo");
145
Masahiro Yamada84ccd792015-02-05 14:42:54 +0900146 return 0;
147}