Masahiro Yamada | 84ccd79 | 2015-02-05 14:42:54 +0900 | [diff] [blame] | 1 | /* |
Masahiro Yamada | b291671 | 2016-09-14 01:06:08 +0900 | [diff] [blame] | 2 | * Copyright (C) 2012-2015 Panasonic Corporation |
| 3 | * Copyright (C) 2015-2016 Socionext Inc. |
| 4 | * Author: Masahiro Yamada <yamada.masahiro@socionext.com> |
Masahiro Yamada | 84ccd79 | 2015-02-05 14:42:54 +0900 | [diff] [blame] | 5 | * |
| 6 | * SPDX-License-Identifier: GPL-2.0+ |
| 7 | */ |
| 8 | |
Masahiro Yamada | e64a6b1 | 2016-06-29 19:39:03 +0900 | [diff] [blame] | 9 | #include <common.h> |
| 10 | #include <libfdt.h> |
| 11 | #include <linux/io.h> |
| 12 | |
Masahiro Yamada | 107b3fb | 2016-01-09 01:51:13 +0900 | [diff] [blame] | 13 | #include "init.h" |
| 14 | #include "micro-support-card.h" |
Masahiro Yamada | b78ffc5 | 2016-09-17 03:33:07 +0900 | [diff] [blame] | 15 | #include "sg-regs.h" |
Masahiro Yamada | 107b3fb | 2016-01-09 01:51:13 +0900 | [diff] [blame] | 16 | #include "soc-info.h" |
Masahiro Yamada | 84ccd79 | 2015-02-05 14:42:54 +0900 | [diff] [blame] | 17 | |
Masahiro Yamada | e64a6b1 | 2016-06-29 19:39:03 +0900 | [diff] [blame] | 18 | DECLARE_GLOBAL_DATA_PTR; |
| 19 | |
| 20 | static void uniphier_setup_xirq(void) |
| 21 | { |
| 22 | const void *fdt = gd->fdt_blob; |
| 23 | int soc_node, aidet_node; |
| 24 | const u32 *val; |
| 25 | unsigned long aidet_base; |
| 26 | u32 tmp; |
| 27 | |
| 28 | soc_node = fdt_path_offset(fdt, "/soc"); |
| 29 | if (soc_node < 0) |
| 30 | return; |
| 31 | |
| 32 | aidet_node = fdt_subnode_offset_namelen(fdt, soc_node, "aidet", 5); |
| 33 | if (aidet_node < 0) |
| 34 | return; |
| 35 | |
| 36 | val = fdt_getprop(fdt, aidet_node, "reg", NULL); |
| 37 | if (!val) |
| 38 | return; |
| 39 | |
| 40 | aidet_base = fdt32_to_cpu(*val); |
| 41 | |
| 42 | tmp = readl(aidet_base + 8); /* AIDET DETCONFR2 */ |
| 43 | tmp |= 0x00ff0000; /* Set XIRQ0-7 low active */ |
| 44 | writel(tmp, aidet_base + 8); |
| 45 | |
| 46 | tmp = readl(0x55000090); /* IRQCTL */ |
| 47 | tmp |= 0x000000ff; |
| 48 | writel(tmp, 0x55000090); |
| 49 | } |
| 50 | |
Masahiro Yamada | 5ac9dfb | 2016-09-17 03:33:04 +0900 | [diff] [blame] | 51 | static void uniphier_nand_pin_init(bool cs2) |
| 52 | { |
| 53 | #ifdef CONFIG_NAND_DENALI |
| 54 | if (uniphier_pin_init(cs2 ? "nand2cs_grp" : "nand_grp")) |
| 55 | pr_err("failed to init NAND pins\n"); |
| 56 | #endif |
| 57 | } |
| 58 | |
Masahiro Yamada | b291671 | 2016-09-14 01:06:08 +0900 | [diff] [blame] | 59 | int board_init(void) |
Masahiro Yamada | 84ccd79 | 2015-02-05 14:42:54 +0900 | [diff] [blame] | 60 | { |
Masahiro Yamada | 682e09f | 2016-09-17 03:33:11 +0900 | [diff] [blame] | 61 | const struct uniphier_board_data *bd; |
| 62 | |
Masahiro Yamada | 8469700 | 2015-09-22 00:27:31 +0900 | [diff] [blame] | 63 | led_puts("U0"); |
Masahiro Yamada | 84ccd79 | 2015-02-05 14:42:54 +0900 | [diff] [blame] | 64 | |
Masahiro Yamada | 682e09f | 2016-09-17 03:33:11 +0900 | [diff] [blame] | 65 | bd = uniphier_get_board_param(); |
| 66 | if (!bd) |
| 67 | return -ENODEV; |
| 68 | |
Masahiro Yamada | 323d1f9 | 2015-09-22 00:27:39 +0900 | [diff] [blame] | 69 | switch (uniphier_get_soc_type()) { |
Masahiro Yamada | ea65c98 | 2016-03-18 16:41:43 +0900 | [diff] [blame] | 70 | #if defined(CONFIG_ARCH_UNIPHIER_SLD3) |
| 71 | case SOC_UNIPHIER_SLD3: |
Masahiro Yamada | 5ac9dfb | 2016-09-17 03:33:04 +0900 | [diff] [blame] | 72 | uniphier_nand_pin_init(true); |
Masahiro Yamada | 323d1f9 | 2015-09-22 00:27:39 +0900 | [diff] [blame] | 73 | led_puts("U1"); |
Masahiro Yamada | 6a3e427 | 2016-09-17 03:33:09 +0900 | [diff] [blame] | 74 | uniphier_sld3_pll_init(); |
Masahiro Yamada | 5b66006 | 2016-03-30 20:17:02 +0900 | [diff] [blame] | 75 | uniphier_ld4_clk_init(); |
Masahiro Yamada | 323d1f9 | 2015-09-22 00:27:39 +0900 | [diff] [blame] | 76 | break; |
| 77 | #endif |
Masahiro Yamada | ea65c98 | 2016-03-18 16:41:43 +0900 | [diff] [blame] | 78 | #if defined(CONFIG_ARCH_UNIPHIER_LD4) |
| 79 | case SOC_UNIPHIER_LD4: |
Masahiro Yamada | 5ac9dfb | 2016-09-17 03:33:04 +0900 | [diff] [blame] | 80 | uniphier_nand_pin_init(true); |
Masahiro Yamada | 323d1f9 | 2015-09-22 00:27:39 +0900 | [diff] [blame] | 81 | led_puts("U1"); |
Masahiro Yamada | 6a3e427 | 2016-09-17 03:33:09 +0900 | [diff] [blame] | 82 | uniphier_ld4_pll_init(); |
Masahiro Yamada | 5b66006 | 2016-03-30 20:17:02 +0900 | [diff] [blame] | 83 | uniphier_ld4_clk_init(); |
Masahiro Yamada | 323d1f9 | 2015-09-22 00:27:39 +0900 | [diff] [blame] | 84 | break; |
| 85 | #endif |
Masahiro Yamada | ea65c98 | 2016-03-18 16:41:43 +0900 | [diff] [blame] | 86 | #if defined(CONFIG_ARCH_UNIPHIER_PRO4) |
| 87 | case SOC_UNIPHIER_PRO4: |
Masahiro Yamada | 5ac9dfb | 2016-09-17 03:33:04 +0900 | [diff] [blame] | 88 | uniphier_nand_pin_init(false); |
Masahiro Yamada | 323d1f9 | 2015-09-22 00:27:39 +0900 | [diff] [blame] | 89 | led_puts("U1"); |
Masahiro Yamada | 6a3e427 | 2016-09-17 03:33:09 +0900 | [diff] [blame] | 90 | uniphier_pro4_pll_init(); |
Masahiro Yamada | 5b66006 | 2016-03-30 20:17:02 +0900 | [diff] [blame] | 91 | uniphier_pro4_clk_init(); |
Masahiro Yamada | 323d1f9 | 2015-09-22 00:27:39 +0900 | [diff] [blame] | 92 | break; |
| 93 | #endif |
Masahiro Yamada | ea65c98 | 2016-03-18 16:41:43 +0900 | [diff] [blame] | 94 | #if defined(CONFIG_ARCH_UNIPHIER_SLD8) |
| 95 | case SOC_UNIPHIER_SLD8: |
Masahiro Yamada | 5ac9dfb | 2016-09-17 03:33:04 +0900 | [diff] [blame] | 96 | uniphier_nand_pin_init(true); |
Masahiro Yamada | 323d1f9 | 2015-09-22 00:27:39 +0900 | [diff] [blame] | 97 | led_puts("U1"); |
Masahiro Yamada | 6a3e427 | 2016-09-17 03:33:09 +0900 | [diff] [blame] | 98 | uniphier_ld4_pll_init(); |
Masahiro Yamada | 5b66006 | 2016-03-30 20:17:02 +0900 | [diff] [blame] | 99 | uniphier_ld4_clk_init(); |
Masahiro Yamada | 323d1f9 | 2015-09-22 00:27:39 +0900 | [diff] [blame] | 100 | break; |
| 101 | #endif |
Masahiro Yamada | ea65c98 | 2016-03-18 16:41:43 +0900 | [diff] [blame] | 102 | #if defined(CONFIG_ARCH_UNIPHIER_PRO5) |
| 103 | case SOC_UNIPHIER_PRO5: |
Masahiro Yamada | 5ac9dfb | 2016-09-17 03:33:04 +0900 | [diff] [blame] | 104 | uniphier_nand_pin_init(true); |
Masahiro Yamada | 28f40d4 | 2015-09-22 00:27:40 +0900 | [diff] [blame] | 105 | led_puts("U1"); |
Masahiro Yamada | 5b66006 | 2016-03-30 20:17:02 +0900 | [diff] [blame] | 106 | uniphier_pro5_clk_init(); |
Masahiro Yamada | 28f40d4 | 2015-09-22 00:27:40 +0900 | [diff] [blame] | 107 | break; |
| 108 | #endif |
Masahiro Yamada | ea65c98 | 2016-03-18 16:41:43 +0900 | [diff] [blame] | 109 | #if defined(CONFIG_ARCH_UNIPHIER_PXS2) |
| 110 | case SOC_UNIPHIER_PXS2: |
Masahiro Yamada | 5ac9dfb | 2016-09-17 03:33:04 +0900 | [diff] [blame] | 111 | uniphier_nand_pin_init(true); |
Masahiro Yamada | 019df87 | 2015-09-22 00:27:41 +0900 | [diff] [blame] | 112 | led_puts("U1"); |
Masahiro Yamada | 5b66006 | 2016-03-30 20:17:02 +0900 | [diff] [blame] | 113 | uniphier_pxs2_clk_init(); |
Masahiro Yamada | 019df87 | 2015-09-22 00:27:41 +0900 | [diff] [blame] | 114 | break; |
| 115 | #endif |
Masahiro Yamada | ea65c98 | 2016-03-18 16:41:43 +0900 | [diff] [blame] | 116 | #if defined(CONFIG_ARCH_UNIPHIER_LD6B) |
| 117 | case SOC_UNIPHIER_LD6B: |
Masahiro Yamada | 5ac9dfb | 2016-09-17 03:33:04 +0900 | [diff] [blame] | 118 | uniphier_nand_pin_init(true); |
Masahiro Yamada | 019df87 | 2015-09-22 00:27:41 +0900 | [diff] [blame] | 119 | led_puts("U1"); |
Masahiro Yamada | 5b66006 | 2016-03-30 20:17:02 +0900 | [diff] [blame] | 120 | uniphier_pxs2_clk_init(); |
Masahiro Yamada | 019df87 | 2015-09-22 00:27:41 +0900 | [diff] [blame] | 121 | break; |
| 122 | #endif |
Masahiro Yamada | 667dbcd | 2016-05-24 21:14:01 +0900 | [diff] [blame] | 123 | #if defined(CONFIG_ARCH_UNIPHIER_LD11) |
| 124 | case SOC_UNIPHIER_LD11: |
Masahiro Yamada | 5ac9dfb | 2016-09-17 03:33:04 +0900 | [diff] [blame] | 125 | uniphier_nand_pin_init(false); |
Masahiro Yamada | b78ffc5 | 2016-09-17 03:33:07 +0900 | [diff] [blame] | 126 | sg_set_pinsel(149, 14, 8, 4); /* XIRQ0 -> XIRQ0 */ |
| 127 | sg_set_iectrl(149); |
| 128 | sg_set_pinsel(153, 14, 8, 4); /* XIRQ4 -> XIRQ4 */ |
| 129 | sg_set_iectrl(153); |
Masahiro Yamada | 667dbcd | 2016-05-24 21:14:01 +0900 | [diff] [blame] | 130 | led_puts("U1"); |
Masahiro Yamada | c72f4d4 | 2016-09-22 07:42:19 +0900 | [diff] [blame] | 131 | uniphier_ld11_pll_init(); |
Masahiro Yamada | 667dbcd | 2016-05-24 21:14:01 +0900 | [diff] [blame] | 132 | uniphier_ld11_clk_init(); |
| 133 | break; |
| 134 | #endif |
Masahiro Yamada | 9d0c2ce | 2016-04-21 14:43:18 +0900 | [diff] [blame] | 135 | #if defined(CONFIG_ARCH_UNIPHIER_LD20) |
| 136 | case SOC_UNIPHIER_LD20: |
Masahiro Yamada | baaafaa | 2016-10-08 13:25:25 +0900 | [diff] [blame^] | 137 | /* ES1 errata: increase VDD09 supply to suppress VBO noise */ |
| 138 | if (uniphier_get_soc_revision() == 1) { |
| 139 | writel(0x00000003, 0x6184e004); |
| 140 | writel(0x00000100, 0x6184e040); |
| 141 | writel(0x0000b500, 0x6184e024); |
| 142 | writel(0x00000001, 0x6184e000); |
| 143 | } |
Masahiro Yamada | 5ac9dfb | 2016-09-17 03:33:04 +0900 | [diff] [blame] | 144 | uniphier_nand_pin_init(false); |
Masahiro Yamada | b78ffc5 | 2016-09-17 03:33:07 +0900 | [diff] [blame] | 145 | sg_set_pinsel(149, 14, 8, 4); /* XIRQ0 -> XIRQ0 */ |
| 146 | sg_set_iectrl(149); |
| 147 | sg_set_pinsel(153, 14, 8, 4); /* XIRQ4 -> XIRQ4 */ |
| 148 | sg_set_iectrl(153); |
Masahiro Yamada | 9d0c2ce | 2016-04-21 14:43:18 +0900 | [diff] [blame] | 149 | led_puts("U1"); |
Masahiro Yamada | 682e09f | 2016-09-17 03:33:11 +0900 | [diff] [blame] | 150 | uniphier_ld20_pll_init(bd); |
Masahiro Yamada | 9d0c2ce | 2016-04-21 14:43:18 +0900 | [diff] [blame] | 151 | uniphier_ld20_clk_init(); |
| 152 | cci500_init(2); |
| 153 | break; |
| 154 | #endif |
Masahiro Yamada | 323d1f9 | 2015-09-22 00:27:39 +0900 | [diff] [blame] | 155 | default: |
| 156 | break; |
| 157 | } |
Masahiro Yamada | 198a97a | 2015-02-27 02:26:51 +0900 | [diff] [blame] | 158 | |
Masahiro Yamada | e64a6b1 | 2016-06-29 19:39:03 +0900 | [diff] [blame] | 159 | uniphier_setup_xirq(); |
| 160 | |
Masahiro Yamada | 8469700 | 2015-09-22 00:27:31 +0900 | [diff] [blame] | 161 | led_puts("U2"); |
Masahiro Yamada | 198a97a | 2015-02-27 02:26:51 +0900 | [diff] [blame] | 162 | |
Masahiro Yamada | b291671 | 2016-09-14 01:06:08 +0900 | [diff] [blame] | 163 | support_card_late_init(); |
| 164 | |
| 165 | led_puts("U3"); |
| 166 | |
| 167 | #ifdef CONFIG_ARM64 |
| 168 | uniphier_smp_kick_all_cpus(); |
| 169 | #endif |
| 170 | |
| 171 | led_puts("Uboo"); |
| 172 | |
Masahiro Yamada | 84ccd79 | 2015-02-05 14:42:54 +0900 | [diff] [blame] | 173 | return 0; |
| 174 | } |