Tom Rini | 83d290c | 2018-05-06 17:58:06 -0400 | [diff] [blame] | 1 | // SPDX-License-Identifier: GPL-2.0+ |
Ajay Bhargav | 2674958 | 2011-08-04 21:26:02 +0530 | [diff] [blame] | 2 | /* |
| 3 | * (C) Copyright 2011 |
| 4 | * eInfochips Ltd. <www.einfochips.com> |
Ajay Bhargav | c7c47ca | 2016-12-21 13:28:06 +0530 | [diff] [blame] | 5 | * Written-by: Ajay Bhargav <contact@8051projects.net> |
Ajay Bhargav | 2674958 | 2011-08-04 21:26:02 +0530 | [diff] [blame] | 6 | * |
| 7 | * Based on Aspenite: |
| 8 | * (C) Copyright 2010 |
| 9 | * Marvell Semiconductor <www.marvell.com> |
| 10 | * Written-by: Prafulla Wadaskar <prafulla@marvell.com> |
| 11 | * Contributor: Mahavir Jain <mjain@marvell.com> |
Ajay Bhargav | 2674958 | 2011-08-04 21:26:02 +0530 | [diff] [blame] | 12 | */ |
| 13 | |
| 14 | #include <common.h> |
Simon Glass | 691d719 | 2020-05-10 11:40:02 -0600 | [diff] [blame] | 15 | #include <init.h> |
Simon Glass | f7ae49f | 2020-05-10 11:40:05 -0600 | [diff] [blame^] | 16 | #include <log.h> |
Ajay Bhargav | 2674958 | 2011-08-04 21:26:02 +0530 | [diff] [blame] | 17 | #include <mvmfp.h> |
Prafulla Wadaskar | cebad16 | 2011-10-18 20:05:47 +0530 | [diff] [blame] | 18 | #include <asm/arch/cpu.h> |
Ajay Bhargav | 2674958 | 2011-08-04 21:26:02 +0530 | [diff] [blame] | 19 | #include <asm/arch/mfp.h> |
| 20 | #include <asm/arch/armada100.h> |
Ajay Bhargav | 47e75d7 | 2011-09-13 22:22:13 +0530 | [diff] [blame] | 21 | #include <asm/gpio.h> |
| 22 | #include <miiphy.h> |
Simon Glass | c62db35 | 2017-05-31 19:47:48 -0600 | [diff] [blame] | 23 | #include <asm/mach-types.h> |
Ajay Bhargav | 2674958 | 2011-08-04 21:26:02 +0530 | [diff] [blame] | 24 | |
Ajay Bhargav | aa0ecfe | 2011-09-13 22:22:04 +0530 | [diff] [blame] | 25 | #ifdef CONFIG_ARMADA100_FEC |
| 26 | #include <net.h> |
| 27 | #include <netdev.h> |
| 28 | #endif /* CONFIG_ARMADA100_FEC */ |
| 29 | |
Ajay Bhargav | 2674958 | 2011-08-04 21:26:02 +0530 | [diff] [blame] | 30 | DECLARE_GLOBAL_DATA_PTR; |
| 31 | |
| 32 | int board_early_init_f(void) |
| 33 | { |
| 34 | u32 mfp_cfg[] = { |
| 35 | /* I2C */ |
| 36 | MFP105_CI2C_SDA, |
| 37 | MFP106_CI2C_SCL, |
| 38 | |
| 39 | /* Enable Console on UART3 */ |
| 40 | MFPO8_UART3_TXD, |
| 41 | MFPO9_UART3_RXD, |
Ajay Bhargav | aa0ecfe | 2011-09-13 22:22:04 +0530 | [diff] [blame] | 42 | |
| 43 | /* Ethernet PHY Interface */ |
| 44 | MFP086_ETH_TXCLK, |
| 45 | MFP087_ETH_TXEN, |
| 46 | MFP088_ETH_TXDQ3, |
| 47 | MFP089_ETH_TXDQ2, |
| 48 | MFP090_ETH_TXDQ1, |
| 49 | MFP091_ETH_TXDQ0, |
| 50 | MFP092_ETH_CRS, |
| 51 | MFP093_ETH_COL, |
| 52 | MFP094_ETH_RXCLK, |
| 53 | MFP095_ETH_RXER, |
| 54 | MFP096_ETH_RXDQ3, |
| 55 | MFP097_ETH_RXDQ2, |
| 56 | MFP098_ETH_RXDQ1, |
| 57 | MFP099_ETH_RXDQ0, |
| 58 | MFP100_ETH_MDC, |
| 59 | MFP101_ETH_MDIO, |
| 60 | MFP103_ETH_RXDV, |
| 61 | |
Ajay Bhargav | daa4b2f | 2011-10-03 14:00:57 +0530 | [diff] [blame] | 62 | /* SSP2 */ |
| 63 | MFP107_SSP2_RXD, |
| 64 | MFP108_SSP2_TXD, |
| 65 | MFP110_SSP2_CS, |
| 66 | MFP111_SSP2_CLK, |
| 67 | |
Ajay Bhargav | 2674958 | 2011-08-04 21:26:02 +0530 | [diff] [blame] | 68 | MFP_EOC /*End of configuration*/ |
| 69 | }; |
| 70 | /* configure MFP's */ |
| 71 | mfp_config(mfp_cfg); |
| 72 | return 0; |
| 73 | } |
| 74 | |
| 75 | int board_init(void) |
| 76 | { |
Ajay Bhargav | daa4b2f | 2011-10-03 14:00:57 +0530 | [diff] [blame] | 77 | struct armd1apb2_registers *apb2_regs = |
| 78 | (struct armd1apb2_registers *)ARMD1_APBC2_BASE; |
| 79 | |
Ajay Bhargav | 2674958 | 2011-08-04 21:26:02 +0530 | [diff] [blame] | 80 | /* arch number of Board */ |
Tom Rini | 92a1bab | 2017-01-25 20:42:36 -0500 | [diff] [blame] | 81 | gd->bd->bi_arch_number = MACH_TYPE_GPLUGD; |
Ajay Bhargav | 2674958 | 2011-08-04 21:26:02 +0530 | [diff] [blame] | 82 | /* adress of boot parameters */ |
| 83 | gd->bd->bi_boot_params = armd1_sdram_base(0) + 0x100; |
Ajay Bhargav | 47e75d7 | 2011-09-13 22:22:13 +0530 | [diff] [blame] | 84 | /* Assert PHY_RST# */ |
| 85 | gpio_direction_output(CONFIG_SYS_GPIO_PHY_RST, GPIO_LOW); |
| 86 | udelay(10); |
| 87 | /* Deassert PHY_RST# */ |
| 88 | gpio_set_value(CONFIG_SYS_GPIO_PHY_RST, GPIO_HIGH); |
Ajay Bhargav | daa4b2f | 2011-10-03 14:00:57 +0530 | [diff] [blame] | 89 | |
| 90 | /* Enable SSP2 clock */ |
| 91 | writel(SSP2_APBCLK | SSP2_FNCLK, &apb2_regs->ssp2_clkrst); |
Ajay Bhargav | 2674958 | 2011-08-04 21:26:02 +0530 | [diff] [blame] | 92 | return 0; |
| 93 | } |
Ajay Bhargav | aa0ecfe | 2011-09-13 22:22:04 +0530 | [diff] [blame] | 94 | |
| 95 | #ifdef CONFIG_ARMADA100_FEC |
| 96 | int board_eth_init(bd_t *bis) |
| 97 | { |
| 98 | struct armd1apmu_registers *apmu_regs = |
| 99 | (struct armd1apmu_registers *)ARMD1_APMU_BASE; |
| 100 | |
| 101 | /* Enable clock of ethernet controller */ |
| 102 | writel(FE_CLK_RST | FE_CLK_ENA, &apmu_regs->fecrc); |
| 103 | |
| 104 | return armada100_fec_register(ARMD1_FEC_BASE); |
| 105 | } |
Ajay Bhargav | 47e75d7 | 2011-09-13 22:22:13 +0530 | [diff] [blame] | 106 | |
| 107 | #ifdef CONFIG_RESET_PHY_R |
| 108 | /* Configure and initialize PHY chip 88E3015 */ |
| 109 | void reset_phy(void) |
| 110 | { |
| 111 | u16 phy_adr; |
| 112 | const char *name = "armd-fec0"; |
| 113 | |
| 114 | if (miiphy_set_current_dev(name)) |
| 115 | return; |
| 116 | |
| 117 | /* command to read PHY dev address */ |
| 118 | if (miiphy_read(name, 0xff, 0xff, &phy_adr)) { |
| 119 | printf("Err..%s could not read PHY dev address\n", __func__); |
| 120 | return; |
| 121 | } |
| 122 | |
| 123 | /* Set Ethernet LED in TX blink mode */ |
| 124 | miiphy_write(name, phy_adr, PHY_LED_MAN_REG, 0x00); |
| 125 | miiphy_write(name, phy_adr, PHY_LED_PAR_SEL_REG, PHY_LED_VAL); |
| 126 | |
| 127 | /* reset the phy */ |
| 128 | miiphy_reset(name, phy_adr); |
| 129 | debug("88E3015 Initialized on %s\n", name); |
| 130 | } |
| 131 | #endif /* CONFIG_RESET_PHY_R */ |
Ajay Bhargav | aa0ecfe | 2011-09-13 22:22:04 +0530 | [diff] [blame] | 132 | #endif /* CONFIG_ARMADA100_FEC */ |