ARM: uniphier: move XIRQ pin-mux settings of LD11/LD20
[platform/kernel/u-boot.git] / arch / arm / mach-uniphier / board_init.c
1 /*
2  * Copyright (C) 2012-2015 Panasonic Corporation
3  * Copyright (C) 2015-2016 Socionext Inc.
4  *   Author: Masahiro Yamada <yamada.masahiro@socionext.com>
5  *
6  * SPDX-License-Identifier:     GPL-2.0+
7  */
8
9 #include <common.h>
10 #include <libfdt.h>
11 #include <linux/io.h>
12
13 #include "init.h"
14 #include "micro-support-card.h"
15 #include "sg-regs.h"
16 #include "soc-info.h"
17
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
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
59 int board_init(void)
60 {
61         led_puts("U0");
62
63         switch (uniphier_get_soc_type()) {
64 #if defined(CONFIG_ARCH_UNIPHIER_SLD3)
65         case SOC_UNIPHIER_SLD3:
66                 uniphier_nand_pin_init(true);
67                 led_puts("U1");
68                 uniphier_ld4_clk_init();
69                 break;
70 #endif
71 #if defined(CONFIG_ARCH_UNIPHIER_LD4)
72         case SOC_UNIPHIER_LD4:
73                 uniphier_nand_pin_init(true);
74                 led_puts("U1");
75                 uniphier_ld4_clk_init();
76                 break;
77 #endif
78 #if defined(CONFIG_ARCH_UNIPHIER_PRO4)
79         case SOC_UNIPHIER_PRO4:
80                 uniphier_nand_pin_init(false);
81                 led_puts("U1");
82                 uniphier_pro4_clk_init();
83                 break;
84 #endif
85 #if defined(CONFIG_ARCH_UNIPHIER_SLD8)
86         case SOC_UNIPHIER_SLD8:
87                 uniphier_nand_pin_init(true);
88                 led_puts("U1");
89                 uniphier_ld4_clk_init();
90                 break;
91 #endif
92 #if defined(CONFIG_ARCH_UNIPHIER_PRO5)
93         case SOC_UNIPHIER_PRO5:
94                 uniphier_nand_pin_init(true);
95                 led_puts("U1");
96                 uniphier_pro5_clk_init();
97                 break;
98 #endif
99 #if defined(CONFIG_ARCH_UNIPHIER_PXS2)
100         case SOC_UNIPHIER_PXS2:
101                 uniphier_nand_pin_init(true);
102                 led_puts("U1");
103                 uniphier_pxs2_clk_init();
104                 break;
105 #endif
106 #if defined(CONFIG_ARCH_UNIPHIER_LD6B)
107         case SOC_UNIPHIER_LD6B:
108                 uniphier_nand_pin_init(true);
109                 led_puts("U1");
110                 uniphier_pxs2_clk_init();
111                 break;
112 #endif
113 #if defined(CONFIG_ARCH_UNIPHIER_LD11)
114         case SOC_UNIPHIER_LD11:
115                 uniphier_nand_pin_init(false);
116                 sg_set_pinsel(149, 14, 8, 4);   /* XIRQ0    -> XIRQ0 */
117                 sg_set_iectrl(149);
118                 sg_set_pinsel(153, 14, 8, 4);   /* XIRQ4    -> XIRQ4 */
119                 sg_set_iectrl(153);
120                 led_puts("U1");
121                 uniphier_ld11_clk_init();
122                 break;
123 #endif
124 #if defined(CONFIG_ARCH_UNIPHIER_LD20)
125         case SOC_UNIPHIER_LD20:
126                 uniphier_nand_pin_init(false);
127                 sg_set_pinsel(149, 14, 8, 4);   /* XIRQ0    -> XIRQ0 */
128                 sg_set_iectrl(149);
129                 sg_set_pinsel(153, 14, 8, 4);   /* XIRQ4    -> XIRQ4 */
130                 sg_set_iectrl(153);
131                 led_puts("U1");
132                 uniphier_ld20_clk_init();
133                 cci500_init(2);
134                 break;
135 #endif
136         default:
137                 break;
138         }
139
140         uniphier_setup_xirq();
141
142         led_puts("U2");
143
144         support_card_late_init();
145
146         led_puts("U3");
147
148 #ifdef CONFIG_ARM64
149         uniphier_smp_kick_all_cpus();
150 #endif
151
152         led_puts("Uboo");
153
154         return 0;
155 }