Simon Kagstrom | e92daeb | 2009-09-22 04:01:01 +0530 | [diff] [blame] | 1 | /* |
| 2 | * (C) Copyright 2009 |
| 3 | * Net Insight <www.netinsight.net> |
| 4 | * Written-by: Simon Kagstrom <simon.kagstrom@netinsight.net> |
| 5 | * |
| 6 | * Based on sheevaplug.c: |
| 7 | * (C) Copyright 2009 |
| 8 | * Marvell Semiconductor <www.marvell.com> |
| 9 | * Written-by: Prafulla Wadaskar <prafulla@marvell.com> |
| 10 | * |
Wolfgang Denk | 1a45966 | 2013-07-08 09:37:19 +0200 | [diff] [blame^] | 11 | * SPDX-License-Identifier: GPL-2.0+ |
Simon Kagstrom | e92daeb | 2009-09-22 04:01:01 +0530 | [diff] [blame] | 12 | */ |
| 13 | |
| 14 | #include <common.h> |
| 15 | #include <miiphy.h> |
Lei Wen | a7efd71 | 2011-10-18 20:11:42 +0530 | [diff] [blame] | 16 | #include <asm/arch/cpu.h> |
Simon Kagstrom | e92daeb | 2009-09-22 04:01:01 +0530 | [diff] [blame] | 17 | #include <asm/arch/kirkwood.h> |
| 18 | #include <asm/arch/mpp.h> |
Clint Adams | f846604 | 2011-05-06 22:06:47 +0530 | [diff] [blame] | 19 | #include "openrd.h" |
Simon Kagstrom | e92daeb | 2009-09-22 04:01:01 +0530 | [diff] [blame] | 20 | |
| 21 | DECLARE_GLOBAL_DATA_PTR; |
| 22 | |
Prafulla Wadaskar | 754ae3f | 2010-10-20 20:12:27 +0530 | [diff] [blame] | 23 | int board_early_init_f(void) |
Simon Kagstrom | e92daeb | 2009-09-22 04:01:01 +0530 | [diff] [blame] | 24 | { |
| 25 | /* |
| 26 | * default gpio configuration |
| 27 | * There are maximum 64 gpios controlled through 2 sets of registers |
| 28 | * the below configuration configures mainly initial LED status |
| 29 | */ |
| 30 | kw_config_gpio(OPENRD_OE_VAL_LOW, |
| 31 | OPENRD_OE_VAL_HIGH, |
| 32 | OPENRD_OE_LOW, OPENRD_OE_HIGH); |
| 33 | |
| 34 | /* Multi-Purpose Pins Functionality configuration */ |
Albert ARIBAUD | 9d86f0c | 2012-11-26 11:27:36 +0000 | [diff] [blame] | 35 | static const u32 kwmpp_config[] = { |
Simon Kagstrom | e92daeb | 2009-09-22 04:01:01 +0530 | [diff] [blame] | 36 | MPP0_NF_IO2, |
| 37 | MPP1_NF_IO3, |
| 38 | MPP2_NF_IO4, |
| 39 | MPP3_NF_IO5, |
| 40 | MPP4_NF_IO6, |
| 41 | MPP5_NF_IO7, |
| 42 | MPP6_SYSRST_OUTn, |
| 43 | MPP7_GPO, |
| 44 | MPP8_TW_SDA, |
| 45 | MPP9_TW_SCK, |
| 46 | MPP10_UART0_TXD, |
| 47 | MPP11_UART0_RXD, |
| 48 | MPP12_SD_CLK, |
| 49 | MPP13_SD_CMD, /* Alt UART1_TXD */ |
| 50 | MPP14_SD_D0, /* Alt UART1_RXD */ |
| 51 | MPP15_SD_D1, |
| 52 | MPP16_SD_D2, |
| 53 | MPP17_SD_D3, |
| 54 | MPP18_NF_IO0, |
| 55 | MPP19_NF_IO1, |
| 56 | MPP20_GE1_0, |
| 57 | MPP21_GE1_1, |
| 58 | MPP22_GE1_2, |
| 59 | MPP23_GE1_3, |
| 60 | MPP24_GE1_4, |
| 61 | MPP25_GE1_5, |
| 62 | MPP26_GE1_6, |
| 63 | MPP27_GE1_7, |
| 64 | MPP28_GPIO, |
| 65 | MPP29_TSMP9, |
| 66 | MPP30_GE1_10, |
| 67 | MPP31_GE1_11, |
| 68 | MPP32_GE1_12, |
| 69 | MPP33_GE1_13, |
| 70 | MPP34_GPIO, /* UART1 / SD sel */ |
| 71 | MPP35_TDM_CH0_TX_QL, |
| 72 | MPP36_TDM_SPI_CS1, |
| 73 | MPP37_TDM_CH2_TX_QL, |
| 74 | MPP38_TDM_CH2_RX_QL, |
| 75 | MPP39_AUDIO_I2SBCLK, |
| 76 | MPP40_AUDIO_I2SDO, |
| 77 | MPP41_AUDIO_I2SLRC, |
| 78 | MPP42_AUDIO_I2SMCLK, |
| 79 | MPP43_AUDIO_I2SDI, |
| 80 | MPP44_AUDIO_EXTCLK, |
| 81 | MPP45_TDM_PCLK, |
| 82 | MPP46_TDM_FS, |
| 83 | MPP47_TDM_DRX, |
| 84 | MPP48_TDM_DTX, |
| 85 | MPP49_TDM_CH0_RX_QL, |
| 86 | 0 |
| 87 | }; |
| 88 | |
Valentin Longchamp | 8468363 | 2012-06-01 01:31:00 +0000 | [diff] [blame] | 89 | kirkwood_mpp_conf(kwmpp_config, NULL); |
Prafulla Wadaskar | 754ae3f | 2010-10-20 20:12:27 +0530 | [diff] [blame] | 90 | return 0; |
| 91 | } |
Simon Kagstrom | e92daeb | 2009-09-22 04:01:01 +0530 | [diff] [blame] | 92 | |
Prafulla Wadaskar | 754ae3f | 2010-10-20 20:12:27 +0530 | [diff] [blame] | 93 | int board_init(void) |
| 94 | { |
Simon Kagstrom | e92daeb | 2009-09-22 04:01:01 +0530 | [diff] [blame] | 95 | /* |
| 96 | * arch number of board |
| 97 | */ |
Clint Adams | 21861f2 | 2011-05-06 22:06:47 +0530 | [diff] [blame] | 98 | #if defined(CONFIG_BOARD_IS_OPENRD_BASE) |
Simon Kagstrom | e92daeb | 2009-09-22 04:01:01 +0530 | [diff] [blame] | 99 | gd->bd->bi_arch_number = MACH_TYPE_OPENRD_BASE; |
Clint Adams | 21861f2 | 2011-05-06 22:06:47 +0530 | [diff] [blame] | 100 | #elif defined(CONFIG_BOARD_IS_OPENRD_CLIENT) |
| 101 | gd->bd->bi_arch_number = MACH_TYPE_OPENRD_CLIENT; |
| 102 | #elif defined(CONFIG_BOARD_IS_OPENRD_ULTIMATE) |
| 103 | gd->bd->bi_arch_number = MACH_TYPE_OPENRD_ULTIMATE; |
| 104 | #endif |
Simon Kagstrom | e92daeb | 2009-09-22 04:01:01 +0530 | [diff] [blame] | 105 | |
| 106 | /* adress of boot parameters */ |
| 107 | gd->bd->bi_boot_params = kw_sdram_bar(0) + 0x100; |
| 108 | return 0; |
| 109 | } |
| 110 | |
Simon Kagstrom | e92daeb | 2009-09-22 04:01:01 +0530 | [diff] [blame] | 111 | #ifdef CONFIG_RESET_PHY_R |
Clint Adams | 1615db3 | 2011-05-06 22:06:47 +0530 | [diff] [blame] | 112 | /* Configure and enable MV88E1116/88E1121 PHY */ |
| 113 | void mv_phy_init(char *name) |
Simon Kagstrom | e92daeb | 2009-09-22 04:01:01 +0530 | [diff] [blame] | 114 | { |
| 115 | u16 reg; |
| 116 | u16 devadr; |
Simon Kagstrom | e92daeb | 2009-09-22 04:01:01 +0530 | [diff] [blame] | 117 | |
| 118 | if (miiphy_set_current_dev(name)) |
| 119 | return; |
| 120 | |
| 121 | /* command to read PHY dev address */ |
| 122 | if (miiphy_read(name, 0xEE, 0xEE, (u16 *) &devadr)) { |
| 123 | printf("Err..%s could not read PHY dev address\n", |
| 124 | __FUNCTION__); |
| 125 | return; |
| 126 | } |
| 127 | |
| 128 | /* |
| 129 | * Enable RGMII delay on Tx and Rx for CPU port |
| 130 | * Ref: sec 4.7.2 of chip datasheet |
| 131 | */ |
| 132 | miiphy_write(name, devadr, MV88E1116_PGADR_REG, 2); |
| 133 | miiphy_read(name, devadr, MV88E1116_MAC_CTRL_REG, ®); |
| 134 | reg |= (MV88E1116_RGMII_RXTM_CTRL | MV88E1116_RGMII_TXTM_CTRL); |
| 135 | miiphy_write(name, devadr, MV88E1116_MAC_CTRL_REG, reg); |
| 136 | miiphy_write(name, devadr, MV88E1116_PGADR_REG, 0); |
| 137 | |
| 138 | /* reset the phy */ |
| 139 | miiphy_reset(name, devadr); |
| 140 | |
Clint Adams | 1615db3 | 2011-05-06 22:06:47 +0530 | [diff] [blame] | 141 | printf(PHY_NO" Initialized on %s\n", name); |
| 142 | } |
| 143 | |
| 144 | void reset_phy(void) |
| 145 | { |
| 146 | mv_phy_init("egiga0"); |
| 147 | |
| 148 | #ifdef CONFIG_BOARD_IS_OPENRD_CLIENT |
| 149 | /* Kirkwood ethernet driver is written with the assumption that in case |
| 150 | * of multiple PHYs, their addresses are consecutive. But unfortunately |
| 151 | * in case of OpenRD-Client, PHY addresses are not consecutive.*/ |
| 152 | miiphy_write("egiga1", 0xEE, 0xEE, 24); |
| 153 | #endif |
| 154 | |
| 155 | #if defined(CONFIG_BOARD_IS_OPENRD_CLIENT) || \ |
| 156 | defined(CONFIG_BOARD_IS_OPENRD_ULTIMATE) |
| 157 | /* configure and initialize both PHY's */ |
| 158 | mv_phy_init("egiga1"); |
| 159 | #endif |
Simon Kagstrom | e92daeb | 2009-09-22 04:01:01 +0530 | [diff] [blame] | 160 | } |
| 161 | #endif /* CONFIG_RESET_PHY_R */ |