Tom Rini | 83d290c | 2018-05-06 17:58:06 -0400 | [diff] [blame] | 1 | // SPDX-License-Identifier: GPL-2.0+ |
Masahiro Yamada | 84ccd79 | 2015-02-05 14:42:54 +0900 | [diff] [blame] | 2 | /* |
Masahiro Yamada | b291671 | 2016-09-14 01:06:08 +0900 | [diff] [blame] | 3 | * Copyright (C) 2012-2015 Panasonic Corporation |
| 4 | * Copyright (C) 2015-2016 Socionext Inc. |
| 5 | * Author: Masahiro Yamada <yamada.masahiro@socionext.com> |
Masahiro Yamada | 84ccd79 | 2015-02-05 14:42:54 +0900 | [diff] [blame] | 6 | */ |
| 7 | |
Masahiro Yamada | ac389b0 | 2017-11-29 15:01:22 +0900 | [diff] [blame] | 8 | #include <linux/errno.h> |
Masahiro Yamada | e64a6b1 | 2016-06-29 19:39:03 +0900 | [diff] [blame] | 9 | #include <linux/io.h> |
Masahiro Yamada | ac389b0 | 2017-11-29 15:01:22 +0900 | [diff] [blame] | 10 | #include <linux/printk.h> |
Masahiro Yamada | e64a6b1 | 2016-06-29 19:39:03 +0900 | [diff] [blame] | 11 | |
Masahiro Yamada | 107b3fb | 2016-01-09 01:51:13 +0900 | [diff] [blame] | 12 | #include "init.h" |
| 13 | #include "micro-support-card.h" |
| 14 | #include "soc-info.h" |
Masahiro Yamada | 84ccd79 | 2015-02-05 14:42:54 +0900 | [diff] [blame] | 15 | |
Masahiro Yamada | 8622749 | 2020-07-09 15:08:19 +0900 | [diff] [blame] | 16 | #define PC0CTRL 0x598000c0 |
| 17 | |
| 18 | #if defined(CONFIG_ARCH_UNIPHIER_LD4) || defined(CONFIG_ARCH_UNIPHIER_SLD8) |
| 19 | static 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) |
| 35 | static 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 Yamada | b61664e | 2017-01-15 14:59:08 +0900 | [diff] [blame] | 43 | #ifdef CONFIG_ARCH_UNIPHIER_LD20 |
| 44 | static void uniphier_ld20_misc_init(void) |
| 45 | { |
Masahiro Yamada | b61664e | 2017-01-15 14:59:08 +0900 | [diff] [blame] | 46 | /* 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 Yamada | b61664e | 2017-01-15 14:59:08 +0900 | [diff] [blame] | 53 | } |
| 54 | #endif |
| 55 | |
| 56 | struct uniphier_initdata { |
Masahiro Yamada | e27d6c7 | 2017-01-21 18:05:26 +0900 | [diff] [blame] | 57 | unsigned int soc_id; |
Masahiro Yamada | 26b09c0 | 2017-01-15 14:59:10 +0900 | [diff] [blame] | 58 | void (*sbc_init)(void); |
Masahiro Yamada | b61664e | 2017-01-15 14:59:08 +0900 | [diff] [blame] | 59 | void (*pll_init)(void); |
| 60 | void (*clk_init)(void); |
| 61 | void (*misc_init)(void); |
| 62 | }; |
| 63 | |
Masahiro Yamada | 7a37bd6 | 2017-01-21 18:05:21 +0900 | [diff] [blame] | 64 | static const struct uniphier_initdata uniphier_initdata[] = { |
Masahiro Yamada | b61664e | 2017-01-15 14:59:08 +0900 | [diff] [blame] | 65 | #if defined(CONFIG_ARCH_UNIPHIER_LD4) |
| 66 | { |
Masahiro Yamada | e27d6c7 | 2017-01-21 18:05:26 +0900 | [diff] [blame] | 67 | .soc_id = UNIPHIER_LD4_ID, |
Masahiro Yamada | 26b09c0 | 2017-01-15 14:59:10 +0900 | [diff] [blame] | 68 | .sbc_init = uniphier_ld4_sbc_init, |
Masahiro Yamada | b61664e | 2017-01-15 14:59:08 +0900 | [diff] [blame] | 69 | .pll_init = uniphier_ld4_pll_init, |
Masahiro Yamada | b61664e | 2017-01-15 14:59:08 +0900 | [diff] [blame] | 70 | }, |
| 71 | #endif |
| 72 | #if defined(CONFIG_ARCH_UNIPHIER_PRO4) |
| 73 | { |
Masahiro Yamada | e27d6c7 | 2017-01-21 18:05:26 +0900 | [diff] [blame] | 74 | .soc_id = UNIPHIER_PRO4_ID, |
Masahiro Yamada | b61664e | 2017-01-15 14:59:08 +0900 | [diff] [blame] | 75 | .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 Yamada | e27d6c7 | 2017-01-21 18:05:26 +0900 | [diff] [blame] | 81 | .soc_id = UNIPHIER_SLD8_ID, |
Masahiro Yamada | 26b09c0 | 2017-01-15 14:59:10 +0900 | [diff] [blame] | 82 | .sbc_init = uniphier_ld4_sbc_init, |
Masahiro Yamada | b61664e | 2017-01-15 14:59:08 +0900 | [diff] [blame] | 83 | .pll_init = uniphier_ld4_pll_init, |
Masahiro Yamada | b61664e | 2017-01-15 14:59:08 +0900 | [diff] [blame] | 84 | }, |
| 85 | #endif |
| 86 | #if defined(CONFIG_ARCH_UNIPHIER_PRO5) |
| 87 | { |
Masahiro Yamada | e27d6c7 | 2017-01-21 18:05:26 +0900 | [diff] [blame] | 88 | .soc_id = UNIPHIER_PRO5_ID, |
Masahiro Yamada | b61664e | 2017-01-15 14:59:08 +0900 | [diff] [blame] | 89 | .clk_init = uniphier_pro5_clk_init, |
| 90 | }, |
| 91 | #endif |
| 92 | #if defined(CONFIG_ARCH_UNIPHIER_PXS2) |
| 93 | { |
Masahiro Yamada | e27d6c7 | 2017-01-21 18:05:26 +0900 | [diff] [blame] | 94 | .soc_id = UNIPHIER_PXS2_ID, |
Masahiro Yamada | 26b09c0 | 2017-01-15 14:59:10 +0900 | [diff] [blame] | 95 | .sbc_init = uniphier_pxs2_sbc_init, |
Masahiro Yamada | b61664e | 2017-01-15 14:59:08 +0900 | [diff] [blame] | 96 | .clk_init = uniphier_pxs2_clk_init, |
| 97 | }, |
| 98 | #endif |
| 99 | #if defined(CONFIG_ARCH_UNIPHIER_LD6B) |
| 100 | { |
Masahiro Yamada | e27d6c7 | 2017-01-21 18:05:26 +0900 | [diff] [blame] | 101 | .soc_id = UNIPHIER_LD6B_ID, |
Masahiro Yamada | 26b09c0 | 2017-01-15 14:59:10 +0900 | [diff] [blame] | 102 | .sbc_init = uniphier_pxs2_sbc_init, |
Masahiro Yamada | b61664e | 2017-01-15 14:59:08 +0900 | [diff] [blame] | 103 | .clk_init = uniphier_pxs2_clk_init, |
| 104 | }, |
| 105 | #endif |
| 106 | #if defined(CONFIG_ARCH_UNIPHIER_LD11) |
| 107 | { |
Masahiro Yamada | e27d6c7 | 2017-01-21 18:05:26 +0900 | [diff] [blame] | 108 | .soc_id = UNIPHIER_LD11_ID, |
Masahiro Yamada | 8622749 | 2020-07-09 15:08:19 +0900 | [diff] [blame] | 109 | .sbc_init = uniphier_pxs2_sbc_init, |
Masahiro Yamada | b61664e | 2017-01-15 14:59:08 +0900 | [diff] [blame] | 110 | .pll_init = uniphier_ld11_pll_init, |
| 111 | .clk_init = uniphier_ld11_clk_init, |
Masahiro Yamada | b61664e | 2017-01-15 14:59:08 +0900 | [diff] [blame] | 112 | }, |
| 113 | #endif |
| 114 | #if defined(CONFIG_ARCH_UNIPHIER_LD20) |
| 115 | { |
Masahiro Yamada | e27d6c7 | 2017-01-21 18:05:26 +0900 | [diff] [blame] | 116 | .soc_id = UNIPHIER_LD20_ID, |
Masahiro Yamada | 8622749 | 2020-07-09 15:08:19 +0900 | [diff] [blame] | 117 | .sbc_init = uniphier_pxs2_sbc_init, |
Masahiro Yamada | b61664e | 2017-01-15 14:59:08 +0900 | [diff] [blame] | 118 | .pll_init = uniphier_ld20_pll_init, |
Masahiro Yamada | c21f585 | 2017-02-17 16:17:22 +0900 | [diff] [blame] | 119 | .clk_init = uniphier_ld20_clk_init, |
Masahiro Yamada | b61664e | 2017-01-15 14:59:08 +0900 | [diff] [blame] | 120 | .misc_init = uniphier_ld20_misc_init, |
| 121 | }, |
| 122 | #endif |
Masahiro Yamada | 2c2ab3d | 2017-01-21 18:05:31 +0900 | [diff] [blame] | 123 | #if defined(CONFIG_ARCH_UNIPHIER_PXS3) |
| 124 | { |
| 125 | .soc_id = UNIPHIER_PXS3_ID, |
Masahiro Yamada | 2c2ab3d | 2017-01-21 18:05:31 +0900 | [diff] [blame] | 126 | .sbc_init = uniphier_pxs2_sbc_init, |
| 127 | .pll_init = uniphier_pxs3_pll_init, |
Masahiro Yamada | 81afa9c | 2017-05-15 14:26:33 +0900 | [diff] [blame] | 128 | .clk_init = uniphier_pxs3_clk_init, |
Masahiro Yamada | 2c2ab3d | 2017-01-21 18:05:31 +0900 | [diff] [blame] | 129 | }, |
| 130 | #endif |
Masahiro Yamada | b61664e | 2017-01-15 14:59:08 +0900 | [diff] [blame] | 131 | }; |
Masahiro Yamada | ee8ef5a | 2017-01-21 18:05:27 +0900 | [diff] [blame] | 132 | UNIPHIER_DEFINE_SOCDATA_FUNC(uniphier_get_initdata, uniphier_initdata) |
Masahiro Yamada | 5ac9dfb | 2016-09-17 03:33:04 +0900 | [diff] [blame] | 133 | |
Masahiro Yamada | b291671 | 2016-09-14 01:06:08 +0900 | [diff] [blame] | 134 | int board_init(void) |
Masahiro Yamada | 84ccd79 | 2015-02-05 14:42:54 +0900 | [diff] [blame] | 135 | { |
Masahiro Yamada | 7a37bd6 | 2017-01-21 18:05:21 +0900 | [diff] [blame] | 136 | const struct uniphier_initdata *initdata; |
Masahiro Yamada | b61664e | 2017-01-15 14:59:08 +0900 | [diff] [blame] | 137 | |
Masahiro Yamada | 8469700 | 2015-09-22 00:27:31 +0900 | [diff] [blame] | 138 | led_puts("U0"); |
Masahiro Yamada | 84ccd79 | 2015-02-05 14:42:54 +0900 | [diff] [blame] | 139 | |
Masahiro Yamada | ee8ef5a | 2017-01-21 18:05:27 +0900 | [diff] [blame] | 140 | initdata = uniphier_get_initdata(); |
Masahiro Yamada | b61664e | 2017-01-15 14:59:08 +0900 | [diff] [blame] | 141 | if (!initdata) { |
Masahiro Yamada | ee8ef5a | 2017-01-21 18:05:27 +0900 | [diff] [blame] | 142 | pr_err("unsupported SoC\n"); |
Masahiro Yamada | b61664e | 2017-01-15 14:59:08 +0900 | [diff] [blame] | 143 | return -EINVAL; |
Masahiro Yamada | 323d1f9 | 2015-09-22 00:27:39 +0900 | [diff] [blame] | 144 | } |
Masahiro Yamada | 198a97a | 2015-02-27 02:26:51 +0900 | [diff] [blame] | 145 | |
Masahiro Yamada | 8622749 | 2020-07-09 15:08:19 +0900 | [diff] [blame] | 146 | if (initdata->sbc_init) |
| 147 | initdata->sbc_init(); |
Masahiro Yamada | 26b09c0 | 2017-01-15 14:59:10 +0900 | [diff] [blame] | 148 | |
| 149 | support_card_init(); |
| 150 | |
| 151 | led_puts("U0"); |
| 152 | |
Masahiro Yamada | b61664e | 2017-01-15 14:59:08 +0900 | [diff] [blame] | 153 | if (initdata->pll_init) |
| 154 | initdata->pll_init(); |
Masahiro Yamada | e64a6b1 | 2016-06-29 19:39:03 +0900 | [diff] [blame] | 155 | |
Masahiro Yamada | e0daca7 | 2017-08-26 17:58:03 +0900 | [diff] [blame] | 156 | led_puts("U1"); |
Masahiro Yamada | 198a97a | 2015-02-27 02:26:51 +0900 | [diff] [blame] | 157 | |
Masahiro Yamada | b61664e | 2017-01-15 14:59:08 +0900 | [diff] [blame] | 158 | if (initdata->clk_init) |
| 159 | initdata->clk_init(); |
Masahiro Yamada | b291671 | 2016-09-14 01:06:08 +0900 | [diff] [blame] | 160 | |
Masahiro Yamada | e0daca7 | 2017-08-26 17:58:03 +0900 | [diff] [blame] | 161 | led_puts("U2"); |
Masahiro Yamada | b291671 | 2016-09-14 01:06:08 +0900 | [diff] [blame] | 162 | |
Masahiro Yamada | b61664e | 2017-01-15 14:59:08 +0900 | [diff] [blame] | 163 | if (initdata->misc_init) |
| 164 | initdata->misc_init(); |
| 165 | |
Masahiro Yamada | b291671 | 2016-09-14 01:06:08 +0900 | [diff] [blame] | 166 | led_puts("Uboo"); |
| 167 | |
Masahiro Yamada | 84ccd79 | 2015-02-05 14:42:54 +0900 | [diff] [blame] | 168 | return 0; |
| 169 | } |