]> git.kernelconcepts.de Git - karo-tx-uboot.git/blob - board/dvlhost/dvlhost.c
socfpga: Move board/socfpga_cyclone5 to board/socfpga
[karo-tx-uboot.git] / board / dvlhost / dvlhost.c
1 /*
2  * (C) Copyright 2009
3  * Michael Schwingen, michael@schwingen.org
4  *
5  * See file CREDITS for list of people who contributed to this
6  * project.
7  *
8  * This program is free software; you can redistribute it and/or
9  * modify it under the terms of the GNU General Public License as
10  * published by the Free Software Foundation; either version 2 of
11  * the License, or (at your option) any later version.
12  *
13  * This program is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16  * GNU General Public License for more details.
17  *
18  * You should have received a copy of the GNU General Public License
19  * along with this program; if not, write to the Free Software
20  * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
21  * MA 02111-1307 USA
22  */
23
24 #include <common.h>
25 #include <config.h>
26 #include <command.h>
27 #include <malloc.h>
28 #include <asm/arch/ixp425.h>
29 #include <asm/io.h>
30 #include <miiphy.h>
31 #ifdef CONFIG_PCI
32 #include <pci.h>
33 #include <asm/arch/ixp425pci.h>
34 #endif
35
36 #include "dvlhost_hw.h"
37
38 DECLARE_GLOBAL_DATA_PTR;
39
40 int board_early_init_f(void)
41 {
42         /* CS1: LED Latch */
43         writel(0xBFFF0002, IXP425_EXP_CS1);
44         return 0;
45 }
46
47 int board_init(void)
48 {
49         /* adress of boot parameters */
50         gd->bd->bi_boot_params = 0x00000100;
51
52         /* Setup GPIOs used as output */
53         GPIO_OUTPUT_CLEAR(CONFIG_SYS_GPIO_WDGTRIGGER);
54         GPIO_OUTPUT_SET(CONFIG_SYS_GPIO_DLAN_PAIRING);
55         GPIO_OUTPUT_CLEAR(CONFIG_SYS_GPIO_PCIRST);
56
57         /*
58          * LED latch enable and watchdog enable are tied to the same GPIO,
59          * so we need to trigger the watchdog if we want to enable the LEDs.
60         */
61 #ifdef CONFIG_HW_WATCHDOG
62         GPIO_OUTPUT_CLEAR(CONFIG_SYS_GPIO_WDG_LED_EN);
63 #else
64         GPIO_OUTPUT_SET(CONFIG_SYS_GPIO_WDG_LED_EN);
65 #endif
66
67         GPIO_OUTPUT_ENABLE(CONFIG_SYS_GPIO_WDGTRIGGER);
68         GPIO_OUTPUT_ENABLE(CONFIG_SYS_GPIO_DLAN_PAIRING);
69         GPIO_OUTPUT_ENABLE(CONFIG_SYS_GPIO_WDG_LED_EN);
70         GPIO_OUTPUT_ENABLE(CONFIG_SYS_GPIO_PCIRST);
71
72         /* Setup GPIOs for Interrupt inputs */
73         GPIO_OUTPUT_DISABLE(CONFIG_SYS_GPIO_BTN_WLAN);
74         GPIO_OUTPUT_DISABLE(CONFIG_SYS_GPIO_BTN_PAIRING);
75         GPIO_OUTPUT_DISABLE(CONFIG_SYS_GPIO_BTN_RESET);
76         GPIO_OUTPUT_DISABLE(CONFIG_SYS_GPIO_IRQA);
77         GPIO_OUTPUT_DISABLE(CONFIG_SYS_GPIO_IRQB);
78
79         /* Setup GPIO's for 33MHz clock output */
80         GPIO_OUTPUT_ENABLE(CONFIG_SYS_GPIO_PCI_CLK);
81         GPIO_OUTPUT_ENABLE(CONFIG_SYS_GPIO_EXTBUS_CLK);
82         writel(0x01FF01FF, IXP425_GPIO_GPCLKR);
83
84         /* turn off all LEDs */
85         writew(0x0000, DVLHOST_LED_LATCH);
86
87         udelay(533);
88         GPIO_OUTPUT_SET(CONFIG_SYS_GPIO_PCIRST);
89
90         return 0;
91 }
92
93 /* Check Board Identity */
94 int checkboard(void)
95 {
96         char *s = getenv("serial#");
97
98         puts("Board: dLAN 200AV (dvlhost)");
99
100         if (s != NULL) {
101                 puts(", serial# ");
102                 puts(s);
103         }
104         putc('\n');
105
106         return 0;
107 }
108
109 int dram_init(void)
110 {
111         gd->ram_size = get_ram_size(CONFIG_SYS_SDRAM_BASE, 128<<20);
112         return 0;
113 }
114
115 #ifdef CONFIG_PCI
116 struct pci_controller hose;
117
118 void pci_init_board(void)
119 {
120         pci_ixp_init(&hose);
121 }
122 #endif
123
124 void reset_phy(void)
125 {
126         /* init IcPlus IP175C ethernet switch to native IP175C mode */
127         miiphy_write("NPE1", 29, 31, 0x175C);
128 }