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 | 266111c | 2017-01-15 14:59:08 +0900 | [diff] [blame] | 16 | #ifdef CONFIG_ARCH_UNIPHIER_LD20 |
| 17 | static void uniphier_ld20_misc_init(void) |
Masahiro Yamada | 1f3d9c7 | 2015-02-05 14:42:54 +0900 | [diff] [blame] | 18 | { |
Masahiro Yamada | 266111c | 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 | 266111c | 2017-01-15 14:59:08 +0900 | [diff] [blame] | 26 | } |
| 27 | #endif |
Masahiro Yamada | 1f3d9c7 | 2015-02-05 14:42:54 +0900 | [diff] [blame] | 28 | |
Masahiro Yamada | 266111c | 2017-01-15 14:59:08 +0900 | [diff] [blame] | 29 | struct uniphier_initdata { |
Masahiro Yamada | 3164905 | 2017-01-21 18:05:26 +0900 | [diff] [blame] | 30 | unsigned int soc_id; |
Masahiro Yamada | 0cc46ad | 2017-01-15 14:59:10 +0900 | [diff] [blame] | 31 | void (*sbc_init)(void); |
Masahiro Yamada | 266111c | 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 | f17e598 | 2017-01-21 18:05:21 +0900 | [diff] [blame] | 37 | static const struct uniphier_initdata uniphier_initdata[] = { |
Masahiro Yamada | 53c59ae | 2016-03-18 16:41:43 +0900 | [diff] [blame] | 38 | #if defined(CONFIG_ARCH_UNIPHIER_LD4) |
Masahiro Yamada | 266111c | 2017-01-15 14:59:08 +0900 | [diff] [blame] | 39 | { |
Masahiro Yamada | 3164905 | 2017-01-21 18:05:26 +0900 | [diff] [blame] | 40 | .soc_id = UNIPHIER_LD4_ID, |
Masahiro Yamada | 0cc46ad | 2017-01-15 14:59:10 +0900 | [diff] [blame] | 41 | .sbc_init = uniphier_ld4_sbc_init, |
Masahiro Yamada | 266111c | 2017-01-15 14:59:08 +0900 | [diff] [blame] | 42 | .pll_init = uniphier_ld4_pll_init, |
| 43 | .clk_init = uniphier_ld4_clk_init, |
| 44 | }, |
Masahiro Yamada | 75f16f8 | 2015-09-22 00:27:39 +0900 | [diff] [blame] | 45 | #endif |
Masahiro Yamada | 53c59ae | 2016-03-18 16:41:43 +0900 | [diff] [blame] | 46 | #if defined(CONFIG_ARCH_UNIPHIER_PRO4) |
Masahiro Yamada | 266111c | 2017-01-15 14:59:08 +0900 | [diff] [blame] | 47 | { |
Masahiro Yamada | 3164905 | 2017-01-21 18:05:26 +0900 | [diff] [blame] | 48 | .soc_id = UNIPHIER_PRO4_ID, |
Masahiro Yamada | 0cc46ad | 2017-01-15 14:59:10 +0900 | [diff] [blame] | 49 | .sbc_init = uniphier_sbc_init_savepin, |
Masahiro Yamada | 266111c | 2017-01-15 14:59:08 +0900 | [diff] [blame] | 50 | .pll_init = uniphier_pro4_pll_init, |
| 51 | .clk_init = uniphier_pro4_clk_init, |
| 52 | }, |
Masahiro Yamada | 75f16f8 | 2015-09-22 00:27:39 +0900 | [diff] [blame] | 53 | #endif |
Masahiro Yamada | 53c59ae | 2016-03-18 16:41:43 +0900 | [diff] [blame] | 54 | #if defined(CONFIG_ARCH_UNIPHIER_SLD8) |
Masahiro Yamada | 266111c | 2017-01-15 14:59:08 +0900 | [diff] [blame] | 55 | { |
Masahiro Yamada | 3164905 | 2017-01-21 18:05:26 +0900 | [diff] [blame] | 56 | .soc_id = UNIPHIER_SLD8_ID, |
Masahiro Yamada | 0cc46ad | 2017-01-15 14:59:10 +0900 | [diff] [blame] | 57 | .sbc_init = uniphier_ld4_sbc_init, |
Masahiro Yamada | 266111c | 2017-01-15 14:59:08 +0900 | [diff] [blame] | 58 | .pll_init = uniphier_ld4_pll_init, |
| 59 | .clk_init = uniphier_ld4_clk_init, |
| 60 | }, |
Masahiro Yamada | 75f16f8 | 2015-09-22 00:27:39 +0900 | [diff] [blame] | 61 | #endif |
Masahiro Yamada | 53c59ae | 2016-03-18 16:41:43 +0900 | [diff] [blame] | 62 | #if defined(CONFIG_ARCH_UNIPHIER_PRO5) |
Masahiro Yamada | 266111c | 2017-01-15 14:59:08 +0900 | [diff] [blame] | 63 | { |
Masahiro Yamada | 3164905 | 2017-01-21 18:05:26 +0900 | [diff] [blame] | 64 | .soc_id = UNIPHIER_PRO5_ID, |
Masahiro Yamada | 0cc46ad | 2017-01-15 14:59:10 +0900 | [diff] [blame] | 65 | .sbc_init = uniphier_sbc_init_savepin, |
Masahiro Yamada | 266111c | 2017-01-15 14:59:08 +0900 | [diff] [blame] | 66 | .clk_init = uniphier_pro5_clk_init, |
| 67 | }, |
Masahiro Yamada | d5167d5 | 2015-09-22 00:27:40 +0900 | [diff] [blame] | 68 | #endif |
Masahiro Yamada | 53c59ae | 2016-03-18 16:41:43 +0900 | [diff] [blame] | 69 | #if defined(CONFIG_ARCH_UNIPHIER_PXS2) |
Masahiro Yamada | 266111c | 2017-01-15 14:59:08 +0900 | [diff] [blame] | 70 | { |
Masahiro Yamada | 3164905 | 2017-01-21 18:05:26 +0900 | [diff] [blame] | 71 | .soc_id = UNIPHIER_PXS2_ID, |
Masahiro Yamada | 0cc46ad | 2017-01-15 14:59:10 +0900 | [diff] [blame] | 72 | .sbc_init = uniphier_pxs2_sbc_init, |
Masahiro Yamada | 266111c | 2017-01-15 14:59:08 +0900 | [diff] [blame] | 73 | .clk_init = uniphier_pxs2_clk_init, |
| 74 | }, |
Masahiro Yamada | 1fe65d3 | 2015-09-22 00:27:41 +0900 | [diff] [blame] | 75 | #endif |
Masahiro Yamada | 53c59ae | 2016-03-18 16:41:43 +0900 | [diff] [blame] | 76 | #if defined(CONFIG_ARCH_UNIPHIER_LD6B) |
Masahiro Yamada | 266111c | 2017-01-15 14:59:08 +0900 | [diff] [blame] | 77 | { |
Masahiro Yamada | 3164905 | 2017-01-21 18:05:26 +0900 | [diff] [blame] | 78 | .soc_id = UNIPHIER_LD6B_ID, |
Masahiro Yamada | 0cc46ad | 2017-01-15 14:59:10 +0900 | [diff] [blame] | 79 | .sbc_init = uniphier_pxs2_sbc_init, |
Masahiro Yamada | 266111c | 2017-01-15 14:59:08 +0900 | [diff] [blame] | 80 | .clk_init = uniphier_pxs2_clk_init, |
| 81 | }, |
Masahiro Yamada | 1fe65d3 | 2015-09-22 00:27:41 +0900 | [diff] [blame] | 82 | #endif |
Masahiro Yamada | 8bbbcbd | 2016-05-24 21:14:01 +0900 | [diff] [blame] | 83 | #if defined(CONFIG_ARCH_UNIPHIER_LD11) |
Masahiro Yamada | 266111c | 2017-01-15 14:59:08 +0900 | [diff] [blame] | 84 | { |
Masahiro Yamada | 3164905 | 2017-01-21 18:05:26 +0900 | [diff] [blame] | 85 | .soc_id = UNIPHIER_LD11_ID, |
Masahiro Yamada | 0cc46ad | 2017-01-15 14:59:10 +0900 | [diff] [blame] | 86 | .sbc_init = uniphier_ld11_sbc_init, |
Masahiro Yamada | 266111c | 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 | 266111c | 2017-01-15 14:59:08 +0900 | [diff] [blame] | 89 | }, |
Masahiro Yamada | 8bbbcbd | 2016-05-24 21:14:01 +0900 | [diff] [blame] | 90 | #endif |
Masahiro Yamada | 063eb1e | 2016-04-21 14:43:18 +0900 | [diff] [blame] | 91 | #if defined(CONFIG_ARCH_UNIPHIER_LD20) |
Masahiro Yamada | 266111c | 2017-01-15 14:59:08 +0900 | [diff] [blame] | 92 | { |
Masahiro Yamada | 3164905 | 2017-01-21 18:05:26 +0900 | [diff] [blame] | 93 | .soc_id = UNIPHIER_LD20_ID, |
Masahiro Yamada | 0cc46ad | 2017-01-15 14:59:10 +0900 | [diff] [blame] | 94 | .sbc_init = uniphier_ld11_sbc_init, |
Masahiro Yamada | 266111c | 2017-01-15 14:59:08 +0900 | [diff] [blame] | 95 | .pll_init = uniphier_ld20_pll_init, |
Masahiro Yamada | b3b1bb7 | 2017-02-17 16:17:22 +0900 | [diff] [blame] | 96 | .clk_init = uniphier_ld20_clk_init, |
Masahiro Yamada | 266111c | 2017-01-15 14:59:08 +0900 | [diff] [blame] | 97 | .misc_init = uniphier_ld20_misc_init, |
| 98 | }, |
Masahiro Yamada | 063eb1e | 2016-04-21 14:43:18 +0900 | [diff] [blame] | 99 | #endif |
Masahiro Yamada | 133b126 | 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 | 133b126 | 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 | 8e0a450 | 2017-05-15 14:26:33 +0900 | [diff] [blame] | 105 | .clk_init = uniphier_pxs3_clk_init, |
Masahiro Yamada | 133b126 | 2017-01-21 18:05:31 +0900 | [diff] [blame] | 106 | }, |
| 107 | #endif |
Masahiro Yamada | 266111c | 2017-01-15 14:59:08 +0900 | [diff] [blame] | 108 | }; |
Masahiro Yamada | 1b81898 | 2017-01-21 18:05:27 +0900 | [diff] [blame] | 109 | UNIPHIER_DEFINE_SOCDATA_FUNC(uniphier_get_initdata, uniphier_initdata) |
Masahiro Yamada | 266111c | 2017-01-15 14:59:08 +0900 | [diff] [blame] | 110 | |
| 111 | int board_init(void) |
| 112 | { |
Masahiro Yamada | f17e598 | 2017-01-21 18:05:21 +0900 | [diff] [blame] | 113 | const struct uniphier_initdata *initdata; |
Masahiro Yamada | 266111c | 2017-01-15 14:59:08 +0900 | [diff] [blame] | 114 | |
| 115 | led_puts("U0"); |
| 116 | |
Masahiro Yamada | 1b81898 | 2017-01-21 18:05:27 +0900 | [diff] [blame] | 117 | initdata = uniphier_get_initdata(); |
Masahiro Yamada | 266111c | 2017-01-15 14:59:08 +0900 | [diff] [blame] | 118 | if (!initdata) { |
Masahiro Yamada | 1b81898 | 2017-01-21 18:05:27 +0900 | [diff] [blame] | 119 | pr_err("unsupported SoC\n"); |
Masahiro Yamada | 266111c | 2017-01-15 14:59:08 +0900 | [diff] [blame] | 120 | return -EINVAL; |
| 121 | } |
| 122 | |
Masahiro Yamada | 0cc46ad | 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 | 266111c | 2017-01-15 14:59:08 +0900 | [diff] [blame] | 129 | if (initdata->pll_init) |
| 130 | initdata->pll_init(); |
Masahiro Yamada | 2480256 | 2016-06-29 19:39:03 +0900 | [diff] [blame] | 131 | |
Masahiro Yamada | 285ceed | 2017-08-26 17:58:03 +0900 | [diff] [blame] | 132 | led_puts("U1"); |
Masahiro Yamada | c04368f | 2015-02-27 02:26:51 +0900 | [diff] [blame] | 133 | |
Masahiro Yamada | 266111c | 2017-01-15 14:59:08 +0900 | [diff] [blame] | 134 | if (initdata->clk_init) |
| 135 | initdata->clk_init(); |
Masahiro Yamada | e59ed19 | 2016-09-14 01:06:08 +0900 | [diff] [blame] | 136 | |
Masahiro Yamada | 285ceed | 2017-08-26 17:58:03 +0900 | [diff] [blame] | 137 | led_puts("U2"); |
Masahiro Yamada | e59ed19 | 2016-09-14 01:06:08 +0900 | [diff] [blame] | 138 | |
Masahiro Yamada | 266111c | 2017-01-15 14:59:08 +0900 | [diff] [blame] | 139 | if (initdata->misc_init) |
| 140 | initdata->misc_init(); |
| 141 | |
Masahiro Yamada | 285ceed | 2017-08-26 17:58:03 +0900 | [diff] [blame] | 142 | led_puts("U3"); |
Masahiro Yamada | 266111c | 2017-01-15 14:59:08 +0900 | [diff] [blame] | 143 | |
Masahiro Yamada | 266111c | 2017-01-15 14:59:08 +0900 | [diff] [blame] | 144 | support_card_late_init(); |
| 145 | |
Masahiro Yamada | e59ed19 | 2016-09-14 01:06:08 +0900 | [diff] [blame] | 146 | led_puts("Uboo"); |
| 147 | |
Masahiro Yamada | 1f3d9c7 | 2015-02-05 14:42:54 +0900 | [diff] [blame] | 148 | return 0; |
| 149 | } |