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 | b61664e | 2017-01-15 14:59:08 +0900 | [diff] [blame] | 16 | #ifdef CONFIG_ARCH_UNIPHIER_LD20 |
| 17 | static void uniphier_ld20_misc_init(void) |
| 18 | { |
Masahiro Yamada | b61664e | 2017-01-15 14:59:08 +0900 | [diff] [blame] | 19 | /* 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 Yamada | b61664e | 2017-01-15 14:59:08 +0900 | [diff] [blame] | 26 | } |
| 27 | #endif |
| 28 | |
| 29 | struct uniphier_initdata { |
Masahiro Yamada | e27d6c7 | 2017-01-21 18:05:26 +0900 | [diff] [blame] | 30 | unsigned int soc_id; |
Masahiro Yamada | 26b09c0 | 2017-01-15 14:59:10 +0900 | [diff] [blame] | 31 | void (*sbc_init)(void); |
Masahiro Yamada | b61664e | 2017-01-15 14:59:08 +0900 | [diff] [blame] | 32 | void (*pll_init)(void); |
| 33 | void (*clk_init)(void); |
| 34 | void (*misc_init)(void); |
| 35 | }; |
| 36 | |
Masahiro Yamada | 7a37bd6 | 2017-01-21 18:05:21 +0900 | [diff] [blame] | 37 | static const struct uniphier_initdata uniphier_initdata[] = { |
Masahiro Yamada | b61664e | 2017-01-15 14:59:08 +0900 | [diff] [blame] | 38 | #if defined(CONFIG_ARCH_UNIPHIER_LD4) |
| 39 | { |
Masahiro Yamada | e27d6c7 | 2017-01-21 18:05:26 +0900 | [diff] [blame] | 40 | .soc_id = UNIPHIER_LD4_ID, |
Masahiro Yamada | 26b09c0 | 2017-01-15 14:59:10 +0900 | [diff] [blame] | 41 | .sbc_init = uniphier_ld4_sbc_init, |
Masahiro Yamada | b61664e | 2017-01-15 14:59:08 +0900 | [diff] [blame] | 42 | .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 Yamada | e27d6c7 | 2017-01-21 18:05:26 +0900 | [diff] [blame] | 48 | .soc_id = UNIPHIER_PRO4_ID, |
Masahiro Yamada | 26b09c0 | 2017-01-15 14:59:10 +0900 | [diff] [blame] | 49 | .sbc_init = uniphier_sbc_init_savepin, |
Masahiro Yamada | b61664e | 2017-01-15 14:59:08 +0900 | [diff] [blame] | 50 | .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 Yamada | e27d6c7 | 2017-01-21 18:05:26 +0900 | [diff] [blame] | 56 | .soc_id = UNIPHIER_SLD8_ID, |
Masahiro Yamada | 26b09c0 | 2017-01-15 14:59:10 +0900 | [diff] [blame] | 57 | .sbc_init = uniphier_ld4_sbc_init, |
Masahiro Yamada | b61664e | 2017-01-15 14:59:08 +0900 | [diff] [blame] | 58 | .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 Yamada | e27d6c7 | 2017-01-21 18:05:26 +0900 | [diff] [blame] | 64 | .soc_id = UNIPHIER_PRO5_ID, |
Masahiro Yamada | 26b09c0 | 2017-01-15 14:59:10 +0900 | [diff] [blame] | 65 | .sbc_init = uniphier_sbc_init_savepin, |
Masahiro Yamada | b61664e | 2017-01-15 14:59:08 +0900 | [diff] [blame] | 66 | .clk_init = uniphier_pro5_clk_init, |
| 67 | }, |
| 68 | #endif |
| 69 | #if defined(CONFIG_ARCH_UNIPHIER_PXS2) |
| 70 | { |
Masahiro Yamada | e27d6c7 | 2017-01-21 18:05:26 +0900 | [diff] [blame] | 71 | .soc_id = UNIPHIER_PXS2_ID, |
Masahiro Yamada | 26b09c0 | 2017-01-15 14:59:10 +0900 | [diff] [blame] | 72 | .sbc_init = uniphier_pxs2_sbc_init, |
Masahiro Yamada | b61664e | 2017-01-15 14:59:08 +0900 | [diff] [blame] | 73 | .clk_init = uniphier_pxs2_clk_init, |
| 74 | }, |
| 75 | #endif |
| 76 | #if defined(CONFIG_ARCH_UNIPHIER_LD6B) |
| 77 | { |
Masahiro Yamada | e27d6c7 | 2017-01-21 18:05:26 +0900 | [diff] [blame] | 78 | .soc_id = UNIPHIER_LD6B_ID, |
Masahiro Yamada | 26b09c0 | 2017-01-15 14:59:10 +0900 | [diff] [blame] | 79 | .sbc_init = uniphier_pxs2_sbc_init, |
Masahiro Yamada | b61664e | 2017-01-15 14:59:08 +0900 | [diff] [blame] | 80 | .clk_init = uniphier_pxs2_clk_init, |
| 81 | }, |
| 82 | #endif |
| 83 | #if defined(CONFIG_ARCH_UNIPHIER_LD11) |
| 84 | { |
Masahiro Yamada | e27d6c7 | 2017-01-21 18:05:26 +0900 | [diff] [blame] | 85 | .soc_id = UNIPHIER_LD11_ID, |
Masahiro Yamada | 26b09c0 | 2017-01-15 14:59:10 +0900 | [diff] [blame] | 86 | .sbc_init = uniphier_ld11_sbc_init, |
Masahiro Yamada | b61664e | 2017-01-15 14:59:08 +0900 | [diff] [blame] | 87 | .pll_init = uniphier_ld11_pll_init, |
| 88 | .clk_init = uniphier_ld11_clk_init, |
Masahiro Yamada | b61664e | 2017-01-15 14:59:08 +0900 | [diff] [blame] | 89 | }, |
| 90 | #endif |
| 91 | #if defined(CONFIG_ARCH_UNIPHIER_LD20) |
| 92 | { |
Masahiro Yamada | e27d6c7 | 2017-01-21 18:05:26 +0900 | [diff] [blame] | 93 | .soc_id = UNIPHIER_LD20_ID, |
Masahiro Yamada | 26b09c0 | 2017-01-15 14:59:10 +0900 | [diff] [blame] | 94 | .sbc_init = uniphier_ld11_sbc_init, |
Masahiro Yamada | b61664e | 2017-01-15 14:59:08 +0900 | [diff] [blame] | 95 | .pll_init = uniphier_ld20_pll_init, |
Masahiro Yamada | c21f585 | 2017-02-17 16:17:22 +0900 | [diff] [blame] | 96 | .clk_init = uniphier_ld20_clk_init, |
Masahiro Yamada | b61664e | 2017-01-15 14:59:08 +0900 | [diff] [blame] | 97 | .misc_init = uniphier_ld20_misc_init, |
| 98 | }, |
| 99 | #endif |
Masahiro Yamada | 2c2ab3d | 2017-01-21 18:05:31 +0900 | [diff] [blame] | 100 | #if defined(CONFIG_ARCH_UNIPHIER_PXS3) |
| 101 | { |
| 102 | .soc_id = UNIPHIER_PXS3_ID, |
Masahiro Yamada | 2c2ab3d | 2017-01-21 18:05:31 +0900 | [diff] [blame] | 103 | .sbc_init = uniphier_pxs2_sbc_init, |
| 104 | .pll_init = uniphier_pxs3_pll_init, |
Masahiro Yamada | 81afa9c | 2017-05-15 14:26:33 +0900 | [diff] [blame] | 105 | .clk_init = uniphier_pxs3_clk_init, |
Masahiro Yamada | 2c2ab3d | 2017-01-21 18:05:31 +0900 | [diff] [blame] | 106 | }, |
| 107 | #endif |
Masahiro Yamada | b61664e | 2017-01-15 14:59:08 +0900 | [diff] [blame] | 108 | }; |
Masahiro Yamada | ee8ef5a | 2017-01-21 18:05:27 +0900 | [diff] [blame] | 109 | UNIPHIER_DEFINE_SOCDATA_FUNC(uniphier_get_initdata, uniphier_initdata) |
Masahiro Yamada | 5ac9dfb | 2016-09-17 03:33:04 +0900 | [diff] [blame] | 110 | |
Masahiro Yamada | b291671 | 2016-09-14 01:06:08 +0900 | [diff] [blame] | 111 | int board_init(void) |
Masahiro Yamada | 84ccd79 | 2015-02-05 14:42:54 +0900 | [diff] [blame] | 112 | { |
Masahiro Yamada | 7a37bd6 | 2017-01-21 18:05:21 +0900 | [diff] [blame] | 113 | const struct uniphier_initdata *initdata; |
Masahiro Yamada | b61664e | 2017-01-15 14:59:08 +0900 | [diff] [blame] | 114 | |
Masahiro Yamada | 8469700 | 2015-09-22 00:27:31 +0900 | [diff] [blame] | 115 | led_puts("U0"); |
Masahiro Yamada | 84ccd79 | 2015-02-05 14:42:54 +0900 | [diff] [blame] | 116 | |
Masahiro Yamada | ee8ef5a | 2017-01-21 18:05:27 +0900 | [diff] [blame] | 117 | initdata = uniphier_get_initdata(); |
Masahiro Yamada | b61664e | 2017-01-15 14:59:08 +0900 | [diff] [blame] | 118 | if (!initdata) { |
Masahiro Yamada | ee8ef5a | 2017-01-21 18:05:27 +0900 | [diff] [blame] | 119 | pr_err("unsupported SoC\n"); |
Masahiro Yamada | b61664e | 2017-01-15 14:59:08 +0900 | [diff] [blame] | 120 | return -EINVAL; |
Masahiro Yamada | 323d1f9 | 2015-09-22 00:27:39 +0900 | [diff] [blame] | 121 | } |
Masahiro Yamada | 198a97a | 2015-02-27 02:26:51 +0900 | [diff] [blame] | 122 | |
Masahiro Yamada | 26b09c0 | 2017-01-15 14:59:10 +0900 | [diff] [blame] | 123 | initdata->sbc_init(); |
| 124 | |
| 125 | support_card_init(); |
| 126 | |
| 127 | led_puts("U0"); |
| 128 | |
Masahiro Yamada | b61664e | 2017-01-15 14:59:08 +0900 | [diff] [blame] | 129 | if (initdata->pll_init) |
| 130 | initdata->pll_init(); |
Masahiro Yamada | e64a6b1 | 2016-06-29 19:39:03 +0900 | [diff] [blame] | 131 | |
Masahiro Yamada | e0daca7 | 2017-08-26 17:58:03 +0900 | [diff] [blame] | 132 | led_puts("U1"); |
Masahiro Yamada | 198a97a | 2015-02-27 02:26:51 +0900 | [diff] [blame] | 133 | |
Masahiro Yamada | b61664e | 2017-01-15 14:59:08 +0900 | [diff] [blame] | 134 | if (initdata->clk_init) |
| 135 | initdata->clk_init(); |
Masahiro Yamada | b291671 | 2016-09-14 01:06:08 +0900 | [diff] [blame] | 136 | |
Masahiro Yamada | e0daca7 | 2017-08-26 17:58:03 +0900 | [diff] [blame] | 137 | led_puts("U2"); |
Masahiro Yamada | b291671 | 2016-09-14 01:06:08 +0900 | [diff] [blame] | 138 | |
Masahiro Yamada | b61664e | 2017-01-15 14:59:08 +0900 | [diff] [blame] | 139 | if (initdata->misc_init) |
| 140 | initdata->misc_init(); |
| 141 | |
Masahiro Yamada | e0daca7 | 2017-08-26 17:58:03 +0900 | [diff] [blame] | 142 | led_puts("U3"); |
Masahiro Yamada | b61664e | 2017-01-15 14:59:08 +0900 | [diff] [blame] | 143 | |
Masahiro Yamada | b61664e | 2017-01-15 14:59:08 +0900 | [diff] [blame] | 144 | support_card_late_init(); |
| 145 | |
Masahiro Yamada | b291671 | 2016-09-14 01:06:08 +0900 | [diff] [blame] | 146 | led_puts("Uboo"); |
| 147 | |
Masahiro Yamada | 84ccd79 | 2015-02-05 14:42:54 +0900 | [diff] [blame] | 148 | return 0; |
| 149 | } |