2 * Copyright (C) 2012-2014 Panasonic Corporation
3 * Author: Masahiro Yamada <yamada.m@jp.panasonic.com>
5 * SPDX-License-Identifier: GPL-2.0+
10 #include <asm/arch/board.h>
12 #if defined(CONFIG_PFC_MICRO_SUPPORT_CARD)
14 #define PFC_MICRO_SUPPORT_CARD_RESET \
15 ((CONFIG_SUPPORT_CARD_BASE) + 0x000D0034)
16 #define PFC_MICRO_SUPPORT_CARD_REVISION \
17 ((CONFIG_SUPPORT_CARD_BASE) + 0x000D00E0)
19 * 0: reset deassert, 1: reset
21 * bit[0]: LAN, I2C, LED
24 void support_card_reset_deassert(void)
26 writel(0, PFC_MICRO_SUPPORT_CARD_RESET);
29 void support_card_reset(void)
31 writel(3, PFC_MICRO_SUPPORT_CARD_RESET);
34 static int support_card_show_revision(void)
38 revision = readl(PFC_MICRO_SUPPORT_CARD_REVISION);
39 printf("(PFC CPLD version %d.%d)\n", revision >> 4, revision & 0xf);
44 #if defined(CONFIG_DCC_MICRO_SUPPORT_CARD)
46 #define DCC_MICRO_SUPPORT_CARD_RESET_LAN \
47 ((CONFIG_SUPPORT_CARD_BASE) + 0x00401300)
48 #define DCC_MICRO_SUPPORT_CARD_RESET_UART \
49 ((CONFIG_SUPPORT_CARD_BASE) + 0x00401304)
50 #define DCC_MICRO_SUPPORT_CARD_RESET_I2C \
51 ((CONFIG_SUPPORT_CARD_BASE) + 0x00401308)
52 #define DCC_MICRO_SUPPORT_CARD_REVISION \
53 ((CONFIG_SUPPORT_CARD_BASE) + 0x005000E0)
55 void support_card_reset_deassert(void)
57 writel(1, DCC_MICRO_SUPPORT_CARD_RESET_LAN); /* LAN and LED */
58 writel(1, DCC_MICRO_SUPPORT_CARD_RESET_UART); /* UART */
59 writel(1, DCC_MICRO_SUPPORT_CARD_RESET_I2C); /* I2C */
62 void support_card_reset(void)
64 writel(0, DCC_MICRO_SUPPORT_CARD_RESET_LAN); /* LAN and LED */
65 writel(0, DCC_MICRO_SUPPORT_CARD_RESET_UART); /* UART */
66 writel(0, DCC_MICRO_SUPPORT_CARD_RESET_I2C); /* I2C */
69 static int support_card_show_revision(void)
73 revision = readl(DCC_MICRO_SUPPORT_CARD_REVISION);
75 if (revision >= 0x67) {
76 printf("(DCC CPLD version 3.%d.%d)\n",
77 revision >> 4, revision & 0xf);
80 printf("(DCC CPLD unknown version)\n");
86 void support_card_init(void)
89 * After power on, we need to keep the LAN controller in reset state
90 * for a while. (200 usec)
91 * Fortunatelly, enough wait time is already inserted in pll_init()
92 * function. So we do not have to wait here.
94 support_card_reset_deassert();
97 int check_support_card(void)
99 printf("SC: Micro Support Card ");
100 return support_card_show_revision();
103 #if defined(CONFIG_SMC911X)
106 int board_eth_init(bd_t *bis)
108 return smc911x_initialize(0, CONFIG_SMC911X_BASE);
112 #if !defined(CONFIG_SYS_NO_FLASH)
114 #include <mtd/cfi_flash.h>
116 #if CONFIG_SYS_MAX_FLASH_BANKS > 1
117 static phys_addr_t flash_banks_list[CONFIG_SYS_MAX_FLASH_BANKS] =
118 CONFIG_SYS_FLASH_BANKS_LIST;
120 phys_addr_t cfi_flash_bank_addr(int i)
122 return flash_banks_list[i];
126 int mem_is_flash(phys_addr_t base)
128 const int loop = 128;
134 scratch_addr = map_physmem(base + 0x01e00000,
135 sizeof(u32) * loop, MAP_NOCACHE);
137 for (i = 0; i < loop; i++, scratch_addr++) {
138 saved_value = readl(scratch_addr);
139 writel(~saved_value, scratch_addr);
140 if (readl(scratch_addr) != saved_value) {
141 /* We assume no memory or SRAM here. */
142 writel(saved_value, scratch_addr);
148 unmap_physmem(scratch_addr, MAP_NOCACHE);
153 int board_flash_wp_on(void)
158 for (i = 0; i < CONFIG_SYS_MAX_FLASH_BANKS; i++) {
159 if (mem_is_flash(cfi_flash_bank_addr(i))) {
161 * We found at least one flash.
162 * We need to return 0 and call flash_init().
166 #if CONFIG_SYS_MAX_FLASH_BANKS > 1
169 * We might have a SRAM here.
170 * To prevent SRAM data from being destroyed,
171 * we set dummy address (SDRAM).
173 flash_banks_list[i] = 0x80000000 + 0x10000 * i;