Tom Rini | 10e4779 | 2018-05-06 17:58:06 -0400 | [diff] [blame] | 1 | // SPDX-License-Identifier: GPL-2.0+ |
Masahiro Yamada | 1f3d9c7 | 2015-02-05 14:42:54 +0900 | [diff] [blame] | 2 | /* |
Masahiro Yamada | e59ed19 | 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 | 1f3d9c7 | 2015-02-05 14:42:54 +0900 | [diff] [blame] | 6 | */ |
| 7 | |
Masahiro Yamada | 7b9fc45 | 2017-11-29 15:01:22 +0900 | [diff] [blame] | 8 | #include <linux/errno.h> |
Masahiro Yamada | 2480256 | 2016-06-29 19:39:03 +0900 | [diff] [blame] | 9 | #include <linux/io.h> |
Masahiro Yamada | 7b9fc45 | 2017-11-29 15:01:22 +0900 | [diff] [blame] | 10 | #include <linux/printk.h> |
Masahiro Yamada | 2480256 | 2016-06-29 19:39:03 +0900 | [diff] [blame] | 11 | |
Masahiro Yamada | efdf340 | 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 | 1f3d9c7 | 2015-02-05 14:42:54 +0900 | [diff] [blame] | 15 | |
Masahiro Yamada | ed16cf0 | 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 | 266111c | 2017-01-15 14:59:08 +0900 | [diff] [blame] | 43 | #ifdef CONFIG_ARCH_UNIPHIER_LD20 |
| 44 | static void uniphier_ld20_misc_init(void) |
Masahiro Yamada | 1f3d9c7 | 2015-02-05 14:42:54 +0900 | [diff] [blame] | 45 | { |
Masahiro Yamada | 266111c | 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 | 266111c | 2017-01-15 14:59:08 +0900 | [diff] [blame] | 53 | } |
| 54 | #endif |
Masahiro Yamada | 1f3d9c7 | 2015-02-05 14:42:54 +0900 | [diff] [blame] | 55 | |
Masahiro Yamada | 266111c | 2017-01-15 14:59:08 +0900 | [diff] [blame] | 56 | struct uniphier_initdata { |
Masahiro Yamada | 3164905 | 2017-01-21 18:05:26 +0900 | [diff] [blame] | 57 | unsigned int soc_id; |
Masahiro Yamada | 0cc46ad | 2017-01-15 14:59:10 +0900 | [diff] [blame] | 58 | void (*sbc_init)(void); |
Masahiro Yamada | 266111c | 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 | f17e598 | 2017-01-21 18:05:21 +0900 | [diff] [blame] | 64 | static const struct uniphier_initdata uniphier_initdata[] = { |
Masahiro Yamada | 53c59ae | 2016-03-18 16:41:43 +0900 | [diff] [blame] | 65 | #if defined(CONFIG_ARCH_UNIPHIER_LD4) |
Masahiro Yamada | 266111c | 2017-01-15 14:59:08 +0900 | [diff] [blame] | 66 | { |
Masahiro Yamada | 3164905 | 2017-01-21 18:05:26 +0900 | [diff] [blame] | 67 | .soc_id = UNIPHIER_LD4_ID, |
Masahiro Yamada | 0cc46ad | 2017-01-15 14:59:10 +0900 | [diff] [blame] | 68 | .sbc_init = uniphier_ld4_sbc_init, |
Masahiro Yamada | 266111c | 2017-01-15 14:59:08 +0900 | [diff] [blame] | 69 | .pll_init = uniphier_ld4_pll_init, |
Masahiro Yamada | 266111c | 2017-01-15 14:59:08 +0900 | [diff] [blame] | 70 | }, |
Masahiro Yamada | 75f16f8 | 2015-09-22 00:27:39 +0900 | [diff] [blame] | 71 | #endif |
Masahiro Yamada | 53c59ae | 2016-03-18 16:41:43 +0900 | [diff] [blame] | 72 | #if defined(CONFIG_ARCH_UNIPHIER_PRO4) |
Masahiro Yamada | 266111c | 2017-01-15 14:59:08 +0900 | [diff] [blame] | 73 | { |
Masahiro Yamada | 3164905 | 2017-01-21 18:05:26 +0900 | [diff] [blame] | 74 | .soc_id = UNIPHIER_PRO4_ID, |
Masahiro Yamada | 266111c | 2017-01-15 14:59:08 +0900 | [diff] [blame] | 75 | .pll_init = uniphier_pro4_pll_init, |
| 76 | .clk_init = uniphier_pro4_clk_init, |
| 77 | }, |
Masahiro Yamada | 75f16f8 | 2015-09-22 00:27:39 +0900 | [diff] [blame] | 78 | #endif |
Masahiro Yamada | 53c59ae | 2016-03-18 16:41:43 +0900 | [diff] [blame] | 79 | #if defined(CONFIG_ARCH_UNIPHIER_SLD8) |
Masahiro Yamada | 266111c | 2017-01-15 14:59:08 +0900 | [diff] [blame] | 80 | { |
Masahiro Yamada | 3164905 | 2017-01-21 18:05:26 +0900 | [diff] [blame] | 81 | .soc_id = UNIPHIER_SLD8_ID, |
Masahiro Yamada | 0cc46ad | 2017-01-15 14:59:10 +0900 | [diff] [blame] | 82 | .sbc_init = uniphier_ld4_sbc_init, |
Masahiro Yamada | 266111c | 2017-01-15 14:59:08 +0900 | [diff] [blame] | 83 | .pll_init = uniphier_ld4_pll_init, |
Masahiro Yamada | 266111c | 2017-01-15 14:59:08 +0900 | [diff] [blame] | 84 | }, |
Masahiro Yamada | 75f16f8 | 2015-09-22 00:27:39 +0900 | [diff] [blame] | 85 | #endif |
Masahiro Yamada | 53c59ae | 2016-03-18 16:41:43 +0900 | [diff] [blame] | 86 | #if defined(CONFIG_ARCH_UNIPHIER_PRO5) |
Masahiro Yamada | 266111c | 2017-01-15 14:59:08 +0900 | [diff] [blame] | 87 | { |
Masahiro Yamada | 3164905 | 2017-01-21 18:05:26 +0900 | [diff] [blame] | 88 | .soc_id = UNIPHIER_PRO5_ID, |
Masahiro Yamada | 266111c | 2017-01-15 14:59:08 +0900 | [diff] [blame] | 89 | .clk_init = uniphier_pro5_clk_init, |
| 90 | }, |
Masahiro Yamada | d5167d5 | 2015-09-22 00:27:40 +0900 | [diff] [blame] | 91 | #endif |
Masahiro Yamada | 53c59ae | 2016-03-18 16:41:43 +0900 | [diff] [blame] | 92 | #if defined(CONFIG_ARCH_UNIPHIER_PXS2) |
Masahiro Yamada | 266111c | 2017-01-15 14:59:08 +0900 | [diff] [blame] | 93 | { |
Masahiro Yamada | 3164905 | 2017-01-21 18:05:26 +0900 | [diff] [blame] | 94 | .soc_id = UNIPHIER_PXS2_ID, |
Masahiro Yamada | 0cc46ad | 2017-01-15 14:59:10 +0900 | [diff] [blame] | 95 | .sbc_init = uniphier_pxs2_sbc_init, |
Masahiro Yamada | 266111c | 2017-01-15 14:59:08 +0900 | [diff] [blame] | 96 | .clk_init = uniphier_pxs2_clk_init, |
| 97 | }, |
Masahiro Yamada | 1fe65d3 | 2015-09-22 00:27:41 +0900 | [diff] [blame] | 98 | #endif |
Masahiro Yamada | 53c59ae | 2016-03-18 16:41:43 +0900 | [diff] [blame] | 99 | #if defined(CONFIG_ARCH_UNIPHIER_LD6B) |
Masahiro Yamada | 266111c | 2017-01-15 14:59:08 +0900 | [diff] [blame] | 100 | { |
Masahiro Yamada | 3164905 | 2017-01-21 18:05:26 +0900 | [diff] [blame] | 101 | .soc_id = UNIPHIER_LD6B_ID, |
Masahiro Yamada | 0cc46ad | 2017-01-15 14:59:10 +0900 | [diff] [blame] | 102 | .sbc_init = uniphier_pxs2_sbc_init, |
Masahiro Yamada | 266111c | 2017-01-15 14:59:08 +0900 | [diff] [blame] | 103 | .clk_init = uniphier_pxs2_clk_init, |
| 104 | }, |
Masahiro Yamada | 1fe65d3 | 2015-09-22 00:27:41 +0900 | [diff] [blame] | 105 | #endif |
Masahiro Yamada | 8bbbcbd | 2016-05-24 21:14:01 +0900 | [diff] [blame] | 106 | #if defined(CONFIG_ARCH_UNIPHIER_LD11) |
Masahiro Yamada | 266111c | 2017-01-15 14:59:08 +0900 | [diff] [blame] | 107 | { |
Masahiro Yamada | 3164905 | 2017-01-21 18:05:26 +0900 | [diff] [blame] | 108 | .soc_id = UNIPHIER_LD11_ID, |
Masahiro Yamada | ed16cf0 | 2020-07-09 15:08:19 +0900 | [diff] [blame] | 109 | .sbc_init = uniphier_pxs2_sbc_init, |
Masahiro Yamada | 266111c | 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 | 266111c | 2017-01-15 14:59:08 +0900 | [diff] [blame] | 112 | }, |
Masahiro Yamada | 8bbbcbd | 2016-05-24 21:14:01 +0900 | [diff] [blame] | 113 | #endif |
Masahiro Yamada | 063eb1e | 2016-04-21 14:43:18 +0900 | [diff] [blame] | 114 | #if defined(CONFIG_ARCH_UNIPHIER_LD20) |
Masahiro Yamada | 266111c | 2017-01-15 14:59:08 +0900 | [diff] [blame] | 115 | { |
Masahiro Yamada | 3164905 | 2017-01-21 18:05:26 +0900 | [diff] [blame] | 116 | .soc_id = UNIPHIER_LD20_ID, |
Masahiro Yamada | ed16cf0 | 2020-07-09 15:08:19 +0900 | [diff] [blame] | 117 | .sbc_init = uniphier_pxs2_sbc_init, |
Masahiro Yamada | 266111c | 2017-01-15 14:59:08 +0900 | [diff] [blame] | 118 | .pll_init = uniphier_ld20_pll_init, |
Masahiro Yamada | b3b1bb7 | 2017-02-17 16:17:22 +0900 | [diff] [blame] | 119 | .clk_init = uniphier_ld20_clk_init, |
Masahiro Yamada | 266111c | 2017-01-15 14:59:08 +0900 | [diff] [blame] | 120 | .misc_init = uniphier_ld20_misc_init, |
| 121 | }, |
Masahiro Yamada | 063eb1e | 2016-04-21 14:43:18 +0900 | [diff] [blame] | 122 | #endif |
Masahiro Yamada | 133b126 | 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 | 133b126 | 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 | 8e0a450 | 2017-05-15 14:26:33 +0900 | [diff] [blame] | 128 | .clk_init = uniphier_pxs3_clk_init, |
Masahiro Yamada | 133b126 | 2017-01-21 18:05:31 +0900 | [diff] [blame] | 129 | }, |
| 130 | #endif |
Masahiro Yamada | 266111c | 2017-01-15 14:59:08 +0900 | [diff] [blame] | 131 | }; |
Masahiro Yamada | 1b81898 | 2017-01-21 18:05:27 +0900 | [diff] [blame] | 132 | UNIPHIER_DEFINE_SOCDATA_FUNC(uniphier_get_initdata, uniphier_initdata) |
Masahiro Yamada | 266111c | 2017-01-15 14:59:08 +0900 | [diff] [blame] | 133 | |
| 134 | int board_init(void) |
| 135 | { |
Masahiro Yamada | f17e598 | 2017-01-21 18:05:21 +0900 | [diff] [blame] | 136 | const struct uniphier_initdata *initdata; |
Masahiro Yamada | 266111c | 2017-01-15 14:59:08 +0900 | [diff] [blame] | 137 | |
| 138 | led_puts("U0"); |
| 139 | |
Masahiro Yamada | 1b81898 | 2017-01-21 18:05:27 +0900 | [diff] [blame] | 140 | initdata = uniphier_get_initdata(); |
Masahiro Yamada | 266111c | 2017-01-15 14:59:08 +0900 | [diff] [blame] | 141 | if (!initdata) { |
Masahiro Yamada | 1b81898 | 2017-01-21 18:05:27 +0900 | [diff] [blame] | 142 | pr_err("unsupported SoC\n"); |
Masahiro Yamada | 266111c | 2017-01-15 14:59:08 +0900 | [diff] [blame] | 143 | return -EINVAL; |
| 144 | } |
| 145 | |
Masahiro Yamada | ed16cf0 | 2020-07-09 15:08:19 +0900 | [diff] [blame] | 146 | if (initdata->sbc_init) |
| 147 | initdata->sbc_init(); |
Masahiro Yamada | 0cc46ad | 2017-01-15 14:59:10 +0900 | [diff] [blame] | 148 | |
| 149 | support_card_init(); |
| 150 | |
| 151 | led_puts("U0"); |
| 152 | |
Masahiro Yamada | 266111c | 2017-01-15 14:59:08 +0900 | [diff] [blame] | 153 | if (initdata->pll_init) |
| 154 | initdata->pll_init(); |
Masahiro Yamada | 2480256 | 2016-06-29 19:39:03 +0900 | [diff] [blame] | 155 | |
Masahiro Yamada | 285ceed | 2017-08-26 17:58:03 +0900 | [diff] [blame] | 156 | led_puts("U1"); |
Masahiro Yamada | c04368f | 2015-02-27 02:26:51 +0900 | [diff] [blame] | 157 | |
Masahiro Yamada | 266111c | 2017-01-15 14:59:08 +0900 | [diff] [blame] | 158 | if (initdata->clk_init) |
| 159 | initdata->clk_init(); |
Masahiro Yamada | e59ed19 | 2016-09-14 01:06:08 +0900 | [diff] [blame] | 160 | |
Masahiro Yamada | 285ceed | 2017-08-26 17:58:03 +0900 | [diff] [blame] | 161 | led_puts("U2"); |
Masahiro Yamada | e59ed19 | 2016-09-14 01:06:08 +0900 | [diff] [blame] | 162 | |
Masahiro Yamada | 266111c | 2017-01-15 14:59:08 +0900 | [diff] [blame] | 163 | if (initdata->misc_init) |
| 164 | initdata->misc_init(); |
| 165 | |
Masahiro Yamada | e59ed19 | 2016-09-14 01:06:08 +0900 | [diff] [blame] | 166 | led_puts("Uboo"); |
| 167 | |
Masahiro Yamada | 1f3d9c7 | 2015-02-05 14:42:54 +0900 | [diff] [blame] | 168 | return 0; |
| 169 | } |