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 #ifdef CONFIG_ARCH_UNIPHIER_LD11 21 static void uniphier_ld11_misc_init(void) 22 { 23 sg_set_pinsel(149, 14, 8, 4); /* XIRQ0 -> XIRQ0 */ 24 sg_set_iectrl(149); 25 sg_set_pinsel(153, 14, 8, 4); /* XIRQ4 -> XIRQ4 */ 26 sg_set_iectrl(153); 27 } 28 #endif 29 30 #ifdef CONFIG_ARCH_UNIPHIER_LD20 31 static void uniphier_ld20_misc_init(void) 32 { 33 sg_set_pinsel(149, 14, 8, 4); /* XIRQ0 -> XIRQ0 */ 34 sg_set_iectrl(149); 35 sg_set_pinsel(153, 14, 8, 4); /* XIRQ4 -> XIRQ4 */ 36 sg_set_iectrl(153); 37 38 /* ES1 errata: increase VDD09 supply to suppress VBO noise */ 39 if (uniphier_get_soc_revision() == 1) { 40 writel(0x00000003, 0x6184e004); 41 writel(0x00000100, 0x6184e040); 42 writel(0x0000b500, 0x6184e024); 43 writel(0x00000001, 0x6184e000); 44 } 45 } 46 #endif 47 48 struct uniphier_initdata { 49 unsigned int soc_id; 50 void (*sbc_init)(void); 51 void (*pll_init)(void); 52 void (*clk_init)(void); 53 void (*misc_init)(void); 54 }; 55 56 static const struct uniphier_initdata uniphier_initdata[] = { 57 #if defined(CONFIG_ARCH_UNIPHIER_LD4) 58 { 59 .soc_id = UNIPHIER_LD4_ID, 60 .sbc_init = uniphier_ld4_sbc_init, 61 .pll_init = uniphier_ld4_pll_init, 62 .clk_init = uniphier_ld4_clk_init, 63 }, 64 #endif 65 #if defined(CONFIG_ARCH_UNIPHIER_PRO4) 66 { 67 .soc_id = UNIPHIER_PRO4_ID, 68 .sbc_init = uniphier_sbc_init_savepin, 69 .pll_init = uniphier_pro4_pll_init, 70 .clk_init = uniphier_pro4_clk_init, 71 }, 72 #endif 73 #if defined(CONFIG_ARCH_UNIPHIER_SLD8) 74 { 75 .soc_id = UNIPHIER_SLD8_ID, 76 .sbc_init = uniphier_ld4_sbc_init, 77 .pll_init = uniphier_ld4_pll_init, 78 .clk_init = uniphier_ld4_clk_init, 79 }, 80 #endif 81 #if defined(CONFIG_ARCH_UNIPHIER_PRO5) 82 { 83 .soc_id = UNIPHIER_PRO5_ID, 84 .sbc_init = uniphier_sbc_init_savepin, 85 .clk_init = uniphier_pro5_clk_init, 86 }, 87 #endif 88 #if defined(CONFIG_ARCH_UNIPHIER_PXS2) 89 { 90 .soc_id = UNIPHIER_PXS2_ID, 91 .sbc_init = uniphier_pxs2_sbc_init, 92 .clk_init = uniphier_pxs2_clk_init, 93 }, 94 #endif 95 #if defined(CONFIG_ARCH_UNIPHIER_LD6B) 96 { 97 .soc_id = UNIPHIER_LD6B_ID, 98 .sbc_init = uniphier_pxs2_sbc_init, 99 .clk_init = uniphier_pxs2_clk_init, 100 }, 101 #endif 102 #if defined(CONFIG_ARCH_UNIPHIER_LD11) 103 { 104 .soc_id = UNIPHIER_LD11_ID, 105 .sbc_init = uniphier_ld11_sbc_init, 106 .pll_init = uniphier_ld11_pll_init, 107 .clk_init = uniphier_ld11_clk_init, 108 .misc_init = uniphier_ld11_misc_init, 109 }, 110 #endif 111 #if defined(CONFIG_ARCH_UNIPHIER_LD20) 112 { 113 .soc_id = UNIPHIER_LD20_ID, 114 .sbc_init = uniphier_ld11_sbc_init, 115 .pll_init = uniphier_ld20_pll_init, 116 .clk_init = uniphier_ld20_clk_init, 117 .misc_init = uniphier_ld20_misc_init, 118 }, 119 #endif 120 #if defined(CONFIG_ARCH_UNIPHIER_PXS3) 121 { 122 .soc_id = UNIPHIER_PXS3_ID, 123 .sbc_init = uniphier_pxs2_sbc_init, 124 .pll_init = uniphier_pxs3_pll_init, 125 .clk_init = uniphier_pxs3_clk_init, 126 }, 127 #endif 128 }; 129 UNIPHIER_DEFINE_SOCDATA_FUNC(uniphier_get_initdata, uniphier_initdata) 130 131 int board_init(void) 132 { 133 const struct uniphier_initdata *initdata; 134 135 led_puts("U0"); 136 137 initdata = uniphier_get_initdata(); 138 if (!initdata) { 139 pr_err("unsupported SoC\n"); 140 return -EINVAL; 141 } 142 143 initdata->sbc_init(); 144 145 support_card_init(); 146 147 led_puts("U0"); 148 149 if (initdata->pll_init) 150 initdata->pll_init(); 151 152 led_puts("U1"); 153 154 if (initdata->clk_init) 155 initdata->clk_init(); 156 157 led_puts("U2"); 158 159 if (initdata->misc_init) 160 initdata->misc_init(); 161 162 led_puts("U3"); 163 164 support_card_late_init(); 165 166 led_puts("Uboo"); 167 168 return 0; 169 } 170