blob: 8418902a5a74bce4bcd9e88afb0e05af42a32272 [file] [log] [blame]
Masahiro Yamada1f3d9c72015-02-05 14:42:54 +09001/*
Masahiro Yamadae59ed192016-09-14 01:06:08 +09002 * Copyright (C) 2012-2015 Panasonic Corporation
3 * Copyright (C) 2015-2016 Socionext Inc.
4 * Author: Masahiro Yamada <yamada.masahiro@socionext.com>
Masahiro Yamada1f3d9c72015-02-05 14:42:54 +09005 *
6 * SPDX-License-Identifier: GPL-2.0+
7 */
8
Masahiro Yamada7b9fc452017-11-29 15:01:22 +09009#include <linux/errno.h>
Masahiro Yamada24802562016-06-29 19:39:03 +090010#include <linux/io.h>
Masahiro Yamada7b9fc452017-11-29 15:01:22 +090011#include <linux/printk.h>
Masahiro Yamada24802562016-06-29 19:39:03 +090012
Masahiro Yamadaefdf3402016-01-09 01:51:13 +090013#include "init.h"
14#include "micro-support-card.h"
15#include "soc-info.h"
Masahiro Yamada1f3d9c72015-02-05 14:42:54 +090016
Masahiro Yamada266111c2017-01-15 14:59:08 +090017#ifdef CONFIG_ARCH_UNIPHIER_LD20
18static void uniphier_ld20_misc_init(void)
Masahiro Yamada1f3d9c72015-02-05 14:42:54 +090019{
Masahiro Yamada266111c2017-01-15 14:59:08 +090020 /* ES1 errata: increase VDD09 supply to suppress VBO noise */
21 if (uniphier_get_soc_revision() == 1) {
22 writel(0x00000003, 0x6184e004);
23 writel(0x00000100, 0x6184e040);
24 writel(0x0000b500, 0x6184e024);
25 writel(0x00000001, 0x6184e000);
26 }
Masahiro Yamada266111c2017-01-15 14:59:08 +090027}
28#endif
Masahiro Yamada1f3d9c72015-02-05 14:42:54 +090029
Masahiro Yamada266111c2017-01-15 14:59:08 +090030struct uniphier_initdata {
Masahiro Yamada31649052017-01-21 18:05:26 +090031 unsigned int soc_id;
Masahiro Yamada0cc46ad2017-01-15 14:59:10 +090032 void (*sbc_init)(void);
Masahiro Yamada266111c2017-01-15 14:59:08 +090033 void (*pll_init)(void);
34 void (*clk_init)(void);
35 void (*misc_init)(void);
36};
37
Masahiro Yamadaf17e5982017-01-21 18:05:21 +090038static const struct uniphier_initdata uniphier_initdata[] = {
Masahiro Yamada53c59ae2016-03-18 16:41:43 +090039#if defined(CONFIG_ARCH_UNIPHIER_LD4)
Masahiro Yamada266111c2017-01-15 14:59:08 +090040 {
Masahiro Yamada31649052017-01-21 18:05:26 +090041 .soc_id = UNIPHIER_LD4_ID,
Masahiro Yamada0cc46ad2017-01-15 14:59:10 +090042 .sbc_init = uniphier_ld4_sbc_init,
Masahiro Yamada266111c2017-01-15 14:59:08 +090043 .pll_init = uniphier_ld4_pll_init,
44 .clk_init = uniphier_ld4_clk_init,
45 },
Masahiro Yamada75f16f82015-09-22 00:27:39 +090046#endif
Masahiro Yamada53c59ae2016-03-18 16:41:43 +090047#if defined(CONFIG_ARCH_UNIPHIER_PRO4)
Masahiro Yamada266111c2017-01-15 14:59:08 +090048 {
Masahiro Yamada31649052017-01-21 18:05:26 +090049 .soc_id = UNIPHIER_PRO4_ID,
Masahiro Yamada0cc46ad2017-01-15 14:59:10 +090050 .sbc_init = uniphier_sbc_init_savepin,
Masahiro Yamada266111c2017-01-15 14:59:08 +090051 .pll_init = uniphier_pro4_pll_init,
52 .clk_init = uniphier_pro4_clk_init,
53 },
Masahiro Yamada75f16f82015-09-22 00:27:39 +090054#endif
Masahiro Yamada53c59ae2016-03-18 16:41:43 +090055#if defined(CONFIG_ARCH_UNIPHIER_SLD8)
Masahiro Yamada266111c2017-01-15 14:59:08 +090056 {
Masahiro Yamada31649052017-01-21 18:05:26 +090057 .soc_id = UNIPHIER_SLD8_ID,
Masahiro Yamada0cc46ad2017-01-15 14:59:10 +090058 .sbc_init = uniphier_ld4_sbc_init,
Masahiro Yamada266111c2017-01-15 14:59:08 +090059 .pll_init = uniphier_ld4_pll_init,
60 .clk_init = uniphier_ld4_clk_init,
61 },
Masahiro Yamada75f16f82015-09-22 00:27:39 +090062#endif
Masahiro Yamada53c59ae2016-03-18 16:41:43 +090063#if defined(CONFIG_ARCH_UNIPHIER_PRO5)
Masahiro Yamada266111c2017-01-15 14:59:08 +090064 {
Masahiro Yamada31649052017-01-21 18:05:26 +090065 .soc_id = UNIPHIER_PRO5_ID,
Masahiro Yamada0cc46ad2017-01-15 14:59:10 +090066 .sbc_init = uniphier_sbc_init_savepin,
Masahiro Yamada266111c2017-01-15 14:59:08 +090067 .clk_init = uniphier_pro5_clk_init,
68 },
Masahiro Yamadad5167d52015-09-22 00:27:40 +090069#endif
Masahiro Yamada53c59ae2016-03-18 16:41:43 +090070#if defined(CONFIG_ARCH_UNIPHIER_PXS2)
Masahiro Yamada266111c2017-01-15 14:59:08 +090071 {
Masahiro Yamada31649052017-01-21 18:05:26 +090072 .soc_id = UNIPHIER_PXS2_ID,
Masahiro Yamada0cc46ad2017-01-15 14:59:10 +090073 .sbc_init = uniphier_pxs2_sbc_init,
Masahiro Yamada266111c2017-01-15 14:59:08 +090074 .clk_init = uniphier_pxs2_clk_init,
75 },
Masahiro Yamada1fe65d32015-09-22 00:27:41 +090076#endif
Masahiro Yamada53c59ae2016-03-18 16:41:43 +090077#if defined(CONFIG_ARCH_UNIPHIER_LD6B)
Masahiro Yamada266111c2017-01-15 14:59:08 +090078 {
Masahiro Yamada31649052017-01-21 18:05:26 +090079 .soc_id = UNIPHIER_LD6B_ID,
Masahiro Yamada0cc46ad2017-01-15 14:59:10 +090080 .sbc_init = uniphier_pxs2_sbc_init,
Masahiro Yamada266111c2017-01-15 14:59:08 +090081 .clk_init = uniphier_pxs2_clk_init,
82 },
Masahiro Yamada1fe65d32015-09-22 00:27:41 +090083#endif
Masahiro Yamada8bbbcbd2016-05-24 21:14:01 +090084#if defined(CONFIG_ARCH_UNIPHIER_LD11)
Masahiro Yamada266111c2017-01-15 14:59:08 +090085 {
Masahiro Yamada31649052017-01-21 18:05:26 +090086 .soc_id = UNIPHIER_LD11_ID,
Masahiro Yamada0cc46ad2017-01-15 14:59:10 +090087 .sbc_init = uniphier_ld11_sbc_init,
Masahiro Yamada266111c2017-01-15 14:59:08 +090088 .pll_init = uniphier_ld11_pll_init,
89 .clk_init = uniphier_ld11_clk_init,
Masahiro Yamada266111c2017-01-15 14:59:08 +090090 },
Masahiro Yamada8bbbcbd2016-05-24 21:14:01 +090091#endif
Masahiro Yamada063eb1e2016-04-21 14:43:18 +090092#if defined(CONFIG_ARCH_UNIPHIER_LD20)
Masahiro Yamada266111c2017-01-15 14:59:08 +090093 {
Masahiro Yamada31649052017-01-21 18:05:26 +090094 .soc_id = UNIPHIER_LD20_ID,
Masahiro Yamada0cc46ad2017-01-15 14:59:10 +090095 .sbc_init = uniphier_ld11_sbc_init,
Masahiro Yamada266111c2017-01-15 14:59:08 +090096 .pll_init = uniphier_ld20_pll_init,
Masahiro Yamadab3b1bb72017-02-17 16:17:22 +090097 .clk_init = uniphier_ld20_clk_init,
Masahiro Yamada266111c2017-01-15 14:59:08 +090098 .misc_init = uniphier_ld20_misc_init,
99 },
Masahiro Yamada063eb1e2016-04-21 14:43:18 +0900100#endif
Masahiro Yamada133b1262017-01-21 18:05:31 +0900101#if defined(CONFIG_ARCH_UNIPHIER_PXS3)
102 {
103 .soc_id = UNIPHIER_PXS3_ID,
Masahiro Yamada133b1262017-01-21 18:05:31 +0900104 .sbc_init = uniphier_pxs2_sbc_init,
105 .pll_init = uniphier_pxs3_pll_init,
Masahiro Yamada8e0a4502017-05-15 14:26:33 +0900106 .clk_init = uniphier_pxs3_clk_init,
Masahiro Yamada133b1262017-01-21 18:05:31 +0900107 },
108#endif
Masahiro Yamada266111c2017-01-15 14:59:08 +0900109};
Masahiro Yamada1b818982017-01-21 18:05:27 +0900110UNIPHIER_DEFINE_SOCDATA_FUNC(uniphier_get_initdata, uniphier_initdata)
Masahiro Yamada266111c2017-01-15 14:59:08 +0900111
112int board_init(void)
113{
Masahiro Yamadaf17e5982017-01-21 18:05:21 +0900114 const struct uniphier_initdata *initdata;
Masahiro Yamada266111c2017-01-15 14:59:08 +0900115
116 led_puts("U0");
117
Masahiro Yamada1b818982017-01-21 18:05:27 +0900118 initdata = uniphier_get_initdata();
Masahiro Yamada266111c2017-01-15 14:59:08 +0900119 if (!initdata) {
Masahiro Yamada1b818982017-01-21 18:05:27 +0900120 pr_err("unsupported SoC\n");
Masahiro Yamada266111c2017-01-15 14:59:08 +0900121 return -EINVAL;
122 }
123
Masahiro Yamada0cc46ad2017-01-15 14:59:10 +0900124 initdata->sbc_init();
125
126 support_card_init();
127
128 led_puts("U0");
129
Masahiro Yamada266111c2017-01-15 14:59:08 +0900130 if (initdata->pll_init)
131 initdata->pll_init();
Masahiro Yamada24802562016-06-29 19:39:03 +0900132
Masahiro Yamada285ceed2017-08-26 17:58:03 +0900133 led_puts("U1");
Masahiro Yamadac04368f2015-02-27 02:26:51 +0900134
Masahiro Yamada266111c2017-01-15 14:59:08 +0900135 if (initdata->clk_init)
136 initdata->clk_init();
Masahiro Yamadae59ed192016-09-14 01:06:08 +0900137
Masahiro Yamada285ceed2017-08-26 17:58:03 +0900138 led_puts("U2");
Masahiro Yamadae59ed192016-09-14 01:06:08 +0900139
Masahiro Yamada266111c2017-01-15 14:59:08 +0900140 if (initdata->misc_init)
141 initdata->misc_init();
142
Masahiro Yamada285ceed2017-08-26 17:58:03 +0900143 led_puts("U3");
Masahiro Yamada266111c2017-01-15 14:59:08 +0900144
Masahiro Yamada266111c2017-01-15 14:59:08 +0900145 support_card_late_init();
146
Masahiro Yamadae59ed192016-09-14 01:06:08 +0900147 led_puts("Uboo");
148
Masahiro Yamada1f3d9c72015-02-05 14:42:54 +0900149 return 0;
150}