Michael Schwingen | 10c9787 | 2011-05-23 00:00:09 +0200 | [diff] [blame] | 1 | /* |
| 2 | * (C) Copyright 2009 |
| 3 | * Michael Schwingen, michael@schwingen.org |
| 4 | * |
Wolfgang Denk | 1a45966 | 2013-07-08 09:37:19 +0200 | [diff] [blame] | 5 | * SPDX-License-Identifier: GPL-2.0+ |
Michael Schwingen | 10c9787 | 2011-05-23 00:00:09 +0200 | [diff] [blame] | 6 | */ |
| 7 | |
| 8 | #include <common.h> |
| 9 | #include <config.h> |
| 10 | #include <command.h> |
| 11 | #include <malloc.h> |
| 12 | #include <asm/arch/ixp425.h> |
| 13 | #include <asm/io.h> |
| 14 | #include <miiphy.h> |
| 15 | #ifdef CONFIG_PCI |
| 16 | #include <pci.h> |
| 17 | #include <asm/arch/ixp425pci.h> |
| 18 | #endif |
| 19 | |
| 20 | #include "dvlhost_hw.h" |
| 21 | |
| 22 | DECLARE_GLOBAL_DATA_PTR; |
| 23 | |
| 24 | int board_early_init_f(void) |
| 25 | { |
| 26 | /* CS1: LED Latch */ |
| 27 | writel(0xBFFF0002, IXP425_EXP_CS1); |
| 28 | return 0; |
| 29 | } |
| 30 | |
| 31 | int board_init(void) |
| 32 | { |
Michael Schwingen | 10c9787 | 2011-05-23 00:00:09 +0200 | [diff] [blame] | 33 | /* adress of boot parameters */ |
| 34 | gd->bd->bi_boot_params = 0x00000100; |
| 35 | |
| 36 | /* Setup GPIOs used as output */ |
| 37 | GPIO_OUTPUT_CLEAR(CONFIG_SYS_GPIO_WDGTRIGGER); |
| 38 | GPIO_OUTPUT_SET(CONFIG_SYS_GPIO_DLAN_PAIRING); |
| 39 | GPIO_OUTPUT_CLEAR(CONFIG_SYS_GPIO_PCIRST); |
| 40 | |
| 41 | /* |
| 42 | * LED latch enable and watchdog enable are tied to the same GPIO, |
| 43 | * so we need to trigger the watchdog if we want to enable the LEDs. |
| 44 | */ |
| 45 | #ifdef CONFIG_HW_WATCHDOG |
| 46 | GPIO_OUTPUT_CLEAR(CONFIG_SYS_GPIO_WDG_LED_EN); |
| 47 | #else |
| 48 | GPIO_OUTPUT_SET(CONFIG_SYS_GPIO_WDG_LED_EN); |
| 49 | #endif |
| 50 | |
| 51 | GPIO_OUTPUT_ENABLE(CONFIG_SYS_GPIO_WDGTRIGGER); |
| 52 | GPIO_OUTPUT_ENABLE(CONFIG_SYS_GPIO_DLAN_PAIRING); |
| 53 | GPIO_OUTPUT_ENABLE(CONFIG_SYS_GPIO_WDG_LED_EN); |
| 54 | GPIO_OUTPUT_ENABLE(CONFIG_SYS_GPIO_PCIRST); |
| 55 | |
| 56 | /* Setup GPIOs for Interrupt inputs */ |
| 57 | GPIO_OUTPUT_DISABLE(CONFIG_SYS_GPIO_BTN_WLAN); |
| 58 | GPIO_OUTPUT_DISABLE(CONFIG_SYS_GPIO_BTN_PAIRING); |
| 59 | GPIO_OUTPUT_DISABLE(CONFIG_SYS_GPIO_BTN_RESET); |
| 60 | GPIO_OUTPUT_DISABLE(CONFIG_SYS_GPIO_IRQA); |
| 61 | GPIO_OUTPUT_DISABLE(CONFIG_SYS_GPIO_IRQB); |
| 62 | |
| 63 | /* Setup GPIO's for 33MHz clock output */ |
| 64 | GPIO_OUTPUT_ENABLE(CONFIG_SYS_GPIO_PCI_CLK); |
| 65 | GPIO_OUTPUT_ENABLE(CONFIG_SYS_GPIO_EXTBUS_CLK); |
| 66 | writel(0x01FF01FF, IXP425_GPIO_GPCLKR); |
| 67 | |
| 68 | /* turn off all LEDs */ |
| 69 | writew(0x0000, DVLHOST_LED_LATCH); |
| 70 | |
| 71 | udelay(533); |
| 72 | GPIO_OUTPUT_SET(CONFIG_SYS_GPIO_PCIRST); |
| 73 | |
| 74 | return 0; |
| 75 | } |
| 76 | |
| 77 | /* Check Board Identity */ |
| 78 | int checkboard(void) |
| 79 | { |
| 80 | char *s = getenv("serial#"); |
| 81 | |
| 82 | puts("Board: dLAN 200AV (dvlhost)"); |
| 83 | |
| 84 | if (s != NULL) { |
| 85 | puts(", serial# "); |
| 86 | puts(s); |
| 87 | } |
| 88 | putc('\n'); |
| 89 | |
| 90 | return 0; |
| 91 | } |
| 92 | |
| 93 | int dram_init(void) |
| 94 | { |
| 95 | gd->ram_size = get_ram_size(CONFIG_SYS_SDRAM_BASE, 128<<20); |
| 96 | return 0; |
| 97 | } |
| 98 | |
| 99 | #ifdef CONFIG_PCI |
| 100 | struct pci_controller hose; |
| 101 | |
| 102 | void pci_init_board(void) |
| 103 | { |
| 104 | pci_ixp_init(&hose); |
| 105 | } |
| 106 | #endif |
| 107 | |
| 108 | void reset_phy(void) |
| 109 | { |
| 110 | /* init IcPlus IP175C ethernet switch to native IP175C mode */ |
| 111 | miiphy_write("NPE1", 29, 31, 0x175C); |
| 112 | } |