nios2: convert altera sysid to driver model
[platform/kernel/u-boot.git] / board / altera / nios2-generic / nios2-generic.c
1 /*
2  * (C) Copyright 2005, Psyent Corporation <www.psyent.com>
3  * Scott McNutt <smcnutt@psyent.com>
4  * (C) Copyright 2010, Thomas Chou <thomas@wytron.com.tw>
5  *
6  * SPDX-License-Identifier:     GPL-2.0+
7  */
8
9 #include <common.h>
10 #include <netdev.h>
11 #if defined(CONFIG_CFI_FLASH_MTD)
12 #include <mtd/cfi_flash.h>
13 #endif
14 #include <asm/io.h>
15 #include <asm/gpio.h>
16
17 #if defined(CONFIG_ENV_IS_IN_FLASH) && defined(CONFIG_ENV_ADDR) && \
18     defined(CONFIG_CFI_FLASH_MTD)
19 static void __early_flash_cmd_reset(void)
20 {
21         /* reset flash before we read env */
22         writeb(AMD_CMD_RESET, CONFIG_ENV_ADDR);
23         writeb(FLASH_CMD_RESET, CONFIG_ENV_ADDR);
24 }
25 void early_flash_cmd_reset(void)
26         __attribute__((weak,alias("__early_flash_cmd_reset")));
27 #endif
28
29 int board_early_init_f(void)
30 {
31 #if defined(CONFIG_ENV_IS_IN_FLASH) && defined(CONFIG_ENV_ADDR) && \
32     defined(CONFIG_CFI_FLASH_MTD)
33         early_flash_cmd_reset();
34 #endif
35         return 0;
36 }
37
38 int checkboard(void)
39 {
40 #ifdef CONFIG_ALTERA_SYSID
41         display_sysid();
42 #endif
43         printf("BOARD: %s\n", CONFIG_BOARD_NAME);
44         return 0;
45 }
46
47 phys_size_t initdram(int board_type)
48 {
49         return 0;
50 }
51
52 #ifdef CONFIG_CMD_NET
53 int board_eth_init(bd_t *bis)
54 {
55         int rc = 0;
56 #ifdef CONFIG_SMC91111
57         rc += smc91111_initialize(0, CONFIG_SMC91111_BASE);
58 #endif
59 #ifdef CONFIG_DRIVER_DM9000
60         rc += dm9000_initialize(bis);
61 #endif
62 #ifdef CONFIG_ALTERA_TSE
63         rc += altera_tse_initialize(0,
64                                     CONFIG_SYS_ALTERA_TSE_MAC_BASE,
65                                     CONFIG_SYS_ALTERA_TSE_SGDMA_RX_BASE,
66                                     CONFIG_SYS_ALTERA_TSE_SGDMA_TX_BASE,
67 #if defined(CONFIG_SYS_ALTERA_TSE_SGDMA_DESC_BASE) && \
68         (CONFIG_SYS_ALTERA_TSE_SGDMA_DESC_SIZE > 0)
69                                     CONFIG_SYS_ALTERA_TSE_SGDMA_DESC_BASE,
70                                     CONFIG_SYS_ALTERA_TSE_SGDMA_DESC_SIZE);
71 #else
72                                     0,
73                                     0);
74 #endif
75 #endif
76 #ifdef CONFIG_ETHOC
77         rc += ethoc_initialize(0, CONFIG_SYS_ETHOC_BASE);
78 #endif
79         return rc;
80 }
81 #endif