Michael Schwingen | bc24345 | 2008-01-16 19:51:55 +0100 | [diff] [blame] | 1 | /* |
| 2 | * (C) Copyright 2007 |
| 3 | * Michael Schwingen, michael@schwingen.org |
| 4 | * |
| 5 | * (C) Copyright 2006 |
| 6 | * Stefan Roese, DENX Software Engineering, sr@denx.de. |
| 7 | * |
| 8 | * (C) Copyright 2002 |
| 9 | * Kyle Harris, Nexus Technologies, Inc. kharris@nexus-tech.net |
| 10 | * |
| 11 | * (C) Copyright 2002 |
| 12 | * Sysgo Real-Time Solutions, GmbH <www.elinos.com> |
| 13 | * Marius Groeger <mgroeger@sysgo.de> |
| 14 | * |
Wolfgang Denk | 1a45966 | 2013-07-08 09:37:19 +0200 | [diff] [blame] | 15 | * SPDX-License-Identifier: GPL-2.0+ |
Michael Schwingen | bc24345 | 2008-01-16 19:51:55 +0100 | [diff] [blame] | 16 | */ |
| 17 | |
| 18 | #include <common.h> |
| 19 | #include <command.h> |
| 20 | #include <malloc.h> |
| 21 | #include <asm/arch/ixp425.h> |
| 22 | #include <asm/io.h> |
Michael Schwingen | bc24345 | 2008-01-16 19:51:55 +0100 | [diff] [blame] | 23 | #include <miiphy.h> |
Michael Schwingen | bc24345 | 2008-01-16 19:51:55 +0100 | [diff] [blame] | 24 | #include "actux3_hw.h" |
| 25 | |
| 26 | DECLARE_GLOBAL_DATA_PTR; |
| 27 | |
Michael Schwingen | 8b5ab4c | 2011-05-23 00:00:06 +0200 | [diff] [blame] | 28 | int board_early_init_f(void) |
| 29 | { |
| 30 | /* CS1: IPAC-X */ |
| 31 | writel(0x94d10013, IXP425_EXP_CS1); |
| 32 | /* CS5: Debug port */ |
| 33 | writel(0x9d520003, IXP425_EXP_CS5); |
| 34 | /* CS6: Release/Option register */ |
| 35 | writel(0x81860001, IXP425_EXP_CS6); |
| 36 | /* CS7: LEDs */ |
| 37 | writel(0x80900003, IXP425_EXP_CS7); |
| 38 | |
| 39 | return 0; |
| 40 | } |
| 41 | |
| 42 | int board_init(void) |
Michael Schwingen | bc24345 | 2008-01-16 19:51:55 +0100 | [diff] [blame] | 43 | { |
Michael Schwingen | bc24345 | 2008-01-16 19:51:55 +0100 | [diff] [blame] | 44 | /* adress of boot parameters */ |
| 45 | gd->bd->bi_boot_params = 0x00000100; |
| 46 | |
Michael Schwingen | 8b5ab4c | 2011-05-23 00:00:06 +0200 | [diff] [blame] | 47 | GPIO_OUTPUT_ENABLE(CONFIG_SYS_GPIO_IORST); |
| 48 | GPIO_OUTPUT_ENABLE(CONFIG_SYS_GPIO_ETHRST); |
| 49 | GPIO_OUTPUT_ENABLE(CONFIG_SYS_GPIO_DSR); |
| 50 | GPIO_OUTPUT_ENABLE(CONFIG_SYS_GPIO_DCD); |
| 51 | GPIO_OUTPUT_ENABLE(CONFIG_SYS_GPIO_LED5_GN); |
| 52 | GPIO_OUTPUT_ENABLE(CONFIG_SYS_GPIO_LED6_RT); |
| 53 | GPIO_OUTPUT_ENABLE(CONFIG_SYS_GPIO_LED6_GN); |
Michael Schwingen | bc24345 | 2008-01-16 19:51:55 +0100 | [diff] [blame] | 54 | |
Michael Schwingen | 8b5ab4c | 2011-05-23 00:00:06 +0200 | [diff] [blame] | 55 | GPIO_OUTPUT_CLEAR(CONFIG_SYS_GPIO_IORST); |
| 56 | GPIO_OUTPUT_CLEAR(CONFIG_SYS_GPIO_ETHRST); |
Michael Schwingen | bc24345 | 2008-01-16 19:51:55 +0100 | [diff] [blame] | 57 | |
Michael Schwingen | 8b5ab4c | 2011-05-23 00:00:06 +0200 | [diff] [blame] | 58 | GPIO_OUTPUT_CLEAR(CONFIG_SYS_GPIO_DSR); |
| 59 | GPIO_OUTPUT_SET(CONFIG_SYS_GPIO_DCD); |
Michael Schwingen | bc24345 | 2008-01-16 19:51:55 +0100 | [diff] [blame] | 60 | |
Michael Schwingen | 8b5ab4c | 2011-05-23 00:00:06 +0200 | [diff] [blame] | 61 | GPIO_OUTPUT_CLEAR(CONFIG_SYS_GPIO_LED5_GN); |
| 62 | GPIO_OUTPUT_CLEAR(CONFIG_SYS_GPIO_LED6_RT); |
| 63 | GPIO_OUTPUT_CLEAR(CONFIG_SYS_GPIO_LED6_GN); |
Michael Schwingen | bc24345 | 2008-01-16 19:51:55 +0100 | [diff] [blame] | 64 | |
| 65 | /* |
| 66 | * Setup GPIO's for Interrupt inputs |
| 67 | */ |
Michael Schwingen | 8b5ab4c | 2011-05-23 00:00:06 +0200 | [diff] [blame] | 68 | GPIO_OUTPUT_DISABLE(CONFIG_SYS_GPIO_DBGINT); |
| 69 | GPIO_OUTPUT_DISABLE(CONFIG_SYS_GPIO_ETHINT); |
Michael Schwingen | bc24345 | 2008-01-16 19:51:55 +0100 | [diff] [blame] | 70 | |
| 71 | /* |
| 72 | * Setup GPIO's for 33MHz clock output |
| 73 | */ |
Michael Schwingen | 8b5ab4c | 2011-05-23 00:00:06 +0200 | [diff] [blame] | 74 | GPIO_OUTPUT_ENABLE(CONFIG_SYS_GPIO_PCI_CLK); |
| 75 | GPIO_OUTPUT_ENABLE(CONFIG_SYS_GPIO_EXTBUS_CLK); |
| 76 | writel(0x011001FF, IXP425_GPIO_GPCLKR); |
Michael Schwingen | bc24345 | 2008-01-16 19:51:55 +0100 | [diff] [blame] | 77 | |
Michael Schwingen | 8b5ab4c | 2011-05-23 00:00:06 +0200 | [diff] [blame] | 78 | /* we need a minimum PCI reset pulse width after enabling the clock */ |
| 79 | udelay(533); |
| 80 | GPIO_OUTPUT_SET(CONFIG_SYS_GPIO_IORST); |
| 81 | GPIO_OUTPUT_SET(CONFIG_SYS_GPIO_ETHRST); |
Michael Schwingen | bc24345 | 2008-01-16 19:51:55 +0100 | [diff] [blame] | 82 | |
Michael Schwingen | 8b5ab4c | 2011-05-23 00:00:06 +0200 | [diff] [blame] | 83 | ACTUX3_LED1_RT(1); |
| 84 | ACTUX3_LED1_GN(0); |
| 85 | ACTUX3_LED2_RT(0); |
| 86 | ACTUX3_LED2_GN(0); |
| 87 | ACTUX3_LED3_RT(0); |
| 88 | ACTUX3_LED3_GN(0); |
| 89 | ACTUX3_LED4_GN(0); |
| 90 | ACTUX3_LED5_RT(0); |
Michael Schwingen | bc24345 | 2008-01-16 19:51:55 +0100 | [diff] [blame] | 91 | |
| 92 | return 0; |
| 93 | } |
| 94 | |
| 95 | /* |
| 96 | * Check Board Identity |
| 97 | */ |
Michael Schwingen | 8b5ab4c | 2011-05-23 00:00:06 +0200 | [diff] [blame] | 98 | int checkboard(void) |
Michael Schwingen | bc24345 | 2008-01-16 19:51:55 +0100 | [diff] [blame] | 99 | { |
Wolfgang Denk | f0c0b3a | 2011-05-04 10:32:28 +0000 | [diff] [blame] | 100 | char buf[64]; |
| 101 | int i = getenv_f("serial#", buf, sizeof(buf)); |
Michael Schwingen | bc24345 | 2008-01-16 19:51:55 +0100 | [diff] [blame] | 102 | |
Michael Schwingen | 8b5ab4c | 2011-05-23 00:00:06 +0200 | [diff] [blame] | 103 | puts("Board: AcTux-3 rev."); |
| 104 | putc(ACTUX3_BOARDREL + 'A' - 1); |
Michael Schwingen | bc24345 | 2008-01-16 19:51:55 +0100 | [diff] [blame] | 105 | |
Wolfgang Denk | f0c0b3a | 2011-05-04 10:32:28 +0000 | [diff] [blame] | 106 | if (i > 0) { |
Michael Schwingen | bc24345 | 2008-01-16 19:51:55 +0100 | [diff] [blame] | 107 | puts (", serial# "); |
Wolfgang Denk | f0c0b3a | 2011-05-04 10:32:28 +0000 | [diff] [blame] | 108 | puts (buf); |
Michael Schwingen | bc24345 | 2008-01-16 19:51:55 +0100 | [diff] [blame] | 109 | } |
Michael Schwingen | 8b5ab4c | 2011-05-23 00:00:06 +0200 | [diff] [blame] | 110 | putc('\n'); |
Michael Schwingen | bc24345 | 2008-01-16 19:51:55 +0100 | [diff] [blame] | 111 | |
Michael Schwingen | 8b5ab4c | 2011-05-23 00:00:06 +0200 | [diff] [blame] | 112 | return 0; |
Michael Schwingen | bc24345 | 2008-01-16 19:51:55 +0100 | [diff] [blame] | 113 | } |
| 114 | |
| 115 | /************************************************************************* |
| 116 | * get_board_rev() - setup to pass kernel board revision information |
| 117 | * 0 = reserved |
| 118 | * 1 = Rev. A |
| 119 | * 2 = Rev. B |
| 120 | *************************************************************************/ |
Michael Schwingen | 8b5ab4c | 2011-05-23 00:00:06 +0200 | [diff] [blame] | 121 | u32 get_board_rev(void) |
Michael Schwingen | bc24345 | 2008-01-16 19:51:55 +0100 | [diff] [blame] | 122 | { |
| 123 | return ACTUX3_BOARDREL; |
| 124 | } |
| 125 | |
Michael Schwingen | 8b5ab4c | 2011-05-23 00:00:06 +0200 | [diff] [blame] | 126 | int dram_init(void) |
Michael Schwingen | bc24345 | 2008-01-16 19:51:55 +0100 | [diff] [blame] | 127 | { |
Michael Schwingen | 8b5ab4c | 2011-05-23 00:00:06 +0200 | [diff] [blame] | 128 | gd->ram_size = get_ram_size(CONFIG_SYS_SDRAM_BASE, 128<<20); |
| 129 | return 0; |
Michael Schwingen | bc24345 | 2008-01-16 19:51:55 +0100 | [diff] [blame] | 130 | } |
| 131 | |
Michael Schwingen | 8b5ab4c | 2011-05-23 00:00:06 +0200 | [diff] [blame] | 132 | void reset_phy(void) |
Michael Schwingen | bc24345 | 2008-01-16 19:51:55 +0100 | [diff] [blame] | 133 | { |
| 134 | int i; |
| 135 | |
| 136 | /* initialize the PHY */ |
Michael Schwingen | 8b5ab4c | 2011-05-23 00:00:06 +0200 | [diff] [blame] | 137 | miiphy_reset("NPE0", CONFIG_PHY_ADDR); |
Michael Schwingen | bc24345 | 2008-01-16 19:51:55 +0100 | [diff] [blame] | 138 | |
| 139 | /* all LED outputs = Link/Act */ |
Michael Schwingen | 8b5ab4c | 2011-05-23 00:00:06 +0200 | [diff] [blame] | 140 | miiphy_write("NPE0", CONFIG_PHY_ADDR, 0x16, 0x0AAA); |
Michael Schwingen | bc24345 | 2008-01-16 19:51:55 +0100 | [diff] [blame] | 141 | |
| 142 | /* |
| 143 | * The Marvell 88E6060 switch comes up with all ports disabled. |
| 144 | * set all ethernet switch ports to forwarding state |
| 145 | */ |
| 146 | for (i = 1; i <= 5; i++) |
Michael Schwingen | 8b5ab4c | 2011-05-23 00:00:06 +0200 | [diff] [blame] | 147 | miiphy_write("NPE0", CONFIG_PHY_ADDR + 8 + i, 0x04, 0x03); |
Michael Schwingen | bc24345 | 2008-01-16 19:51:55 +0100 | [diff] [blame] | 148 | |
| 149 | } |