Beniamino Galvani | d1037e4 | 2016-05-08 08:30:16 +0200 | [diff] [blame^] | 1 | /* |
| 2 | * (C) Copyright 2016 Beniamino Galvani <b.galvani@gmail.com> |
| 3 | * |
| 4 | * SPDX-License-Identifier: GPL-2.0+ |
| 5 | */ |
| 6 | |
| 7 | #include <common.h> |
| 8 | #include <asm/io.h> |
| 9 | #include <asm/arch/gxbb.h> |
| 10 | #include <dm/platdata.h> |
| 11 | #include <phy.h> |
| 12 | |
| 13 | int board_init(void) |
| 14 | { |
| 15 | return 0; |
| 16 | } |
| 17 | |
| 18 | static const struct eth_pdata gxbb_eth_pdata = { |
| 19 | .iobase = GXBB_ETH_BASE, |
| 20 | .phy_interface = PHY_INTERFACE_MODE_RGMII, |
| 21 | }; |
| 22 | |
| 23 | U_BOOT_DEVICE(meson_eth) = { |
| 24 | .name = "eth_designware", |
| 25 | .platdata = &gxbb_eth_pdata, |
| 26 | }; |
| 27 | |
| 28 | int misc_init_r(void) |
| 29 | { |
| 30 | /* Select Ethernet function */ |
| 31 | setbits_le32(GXBB_PINMUX(6), 0x3fff); |
| 32 | |
| 33 | /* Set RGMII mode */ |
| 34 | setbits_le32(GXBB_ETH_REG_0, GXBB_ETH_REG_0_PHY_INTF | |
| 35 | GXBB_ETH_REG_0_TX_PHASE(1) | |
| 36 | GXBB_ETH_REG_0_TX_RATIO(4) | |
| 37 | GXBB_ETH_REG_0_PHY_CLK_EN | |
| 38 | GXBB_ETH_REG_0_CLK_EN); |
| 39 | |
| 40 | /* Enable power and clock gate */ |
| 41 | setbits_le32(GXBB_GCLK_MPEG_1, GXBB_GCLK_MPEG_1_ETH); |
| 42 | clrbits_le32(GXBB_MEM_PD_REG_0, GXBB_MEM_PD_REG_0_ETH_MASK); |
| 43 | |
| 44 | /* Reset PHY on GPIOZ_14 */ |
| 45 | clrbits_le32(GXBB_GPIO_EN(3), BIT(14)); |
| 46 | clrbits_le32(GXBB_GPIO_OUT(3), BIT(14)); |
| 47 | mdelay(10); |
| 48 | setbits_le32(GXBB_GPIO_OUT(3), BIT(14)); |
| 49 | |
| 50 | return 0; |
| 51 | } |