Shengzhou Liu | 4991240 | 2014-11-24 17:11:56 +0800 | [diff] [blame] | 1 | /* |
| 2 | * Copyright 2014 Freescale Semiconductor, Inc. |
| 3 | * |
Shengzhou Liu | 00d7e5b | 2015-03-27 15:48:34 +0800 | [diff] [blame] | 4 | * Shengzhou Liu <Shengzhou.Liu@freescale.com> |
| 5 | * |
Shengzhou Liu | 4991240 | 2014-11-24 17:11:56 +0800 | [diff] [blame] | 6 | * SPDX-License-Identifier: GPL-2.0+ |
| 7 | */ |
| 8 | |
| 9 | #include <common.h> |
| 10 | #include <command.h> |
| 11 | #include <netdev.h> |
| 12 | #include <asm/mmu.h> |
| 13 | #include <asm/processor.h> |
| 14 | #include <asm/immap_85xx.h> |
| 15 | #include <asm/fsl_law.h> |
| 16 | #include <asm/fsl_serdes.h> |
| 17 | #include <asm/fsl_portals.h> |
| 18 | #include <asm/fsl_liodn.h> |
| 19 | #include <malloc.h> |
| 20 | #include <fm_eth.h> |
| 21 | #include <fsl_mdio.h> |
| 22 | #include <miiphy.h> |
| 23 | #include <phy.h> |
Shaohui Xie | 513eaf2 | 2015-10-26 19:47:47 +0800 | [diff] [blame] | 24 | #include <fsl_dtsec.h> |
Shengzhou Liu | 4991240 | 2014-11-24 17:11:56 +0800 | [diff] [blame] | 25 | #include <asm/fsl_serdes.h> |
Shengzhou Liu | ccc57ef | 2014-12-17 16:51:08 +0800 | [diff] [blame] | 26 | #include "../common/fman.h" |
Shengzhou Liu | 4991240 | 2014-11-24 17:11:56 +0800 | [diff] [blame] | 27 | |
| 28 | int board_eth_init(bd_t *bis) |
| 29 | { |
| 30 | #if defined(CONFIG_FMAN_ENET) |
| 31 | int i, interface; |
| 32 | struct memac_mdio_info dtsec_mdio_info; |
| 33 | struct memac_mdio_info tgec_mdio_info; |
| 34 | struct mii_dev *dev; |
| 35 | ccsr_gur_t *gur = (void *)(CONFIG_SYS_MPC85xx_GUTS_ADDR); |
| 36 | u32 srds_s1; |
| 37 | |
| 38 | srds_s1 = in_be32(&gur->rcwsr[4]) & |
| 39 | FSL_CORENET2_RCWSR4_SRDS1_PRTCL; |
| 40 | srds_s1 >>= FSL_CORENET2_RCWSR4_SRDS1_PRTCL_SHIFT; |
| 41 | |
| 42 | dtsec_mdio_info.regs = |
| 43 | (struct memac_mdio_controller *)CONFIG_SYS_FM1_DTSEC_MDIO_ADDR; |
| 44 | |
| 45 | dtsec_mdio_info.name = DEFAULT_FM_MDIO_NAME; |
| 46 | |
| 47 | /* Register the 1G MDIO bus */ |
| 48 | fm_memac_mdio_init(bis, &dtsec_mdio_info); |
| 49 | |
| 50 | tgec_mdio_info.regs = |
| 51 | (struct memac_mdio_controller *)CONFIG_SYS_FM1_TGEC_MDIO_ADDR; |
| 52 | tgec_mdio_info.name = DEFAULT_FM_TGEC_MDIO_NAME; |
| 53 | |
| 54 | /* Register the 10G MDIO bus */ |
| 55 | fm_memac_mdio_init(bis, &tgec_mdio_info); |
| 56 | |
Shengzhou Liu | ccc57ef | 2014-12-17 16:51:08 +0800 | [diff] [blame] | 57 | /* Set the on-board RGMII PHY address */ |
Shengzhou Liu | 4991240 | 2014-11-24 17:11:56 +0800 | [diff] [blame] | 58 | fm_info_set_phy_address(FM1_DTSEC4, RGMII_PHY1_ADDR); |
| 59 | |
| 60 | switch (srds_s1) { |
Shengzhou Liu | 00d7e5b | 2015-03-27 15:48:34 +0800 | [diff] [blame] | 61 | #ifdef CONFIG_T1024RDB |
Shengzhou Liu | 4991240 | 2014-11-24 17:11:56 +0800 | [diff] [blame] | 62 | case 0x95: |
Shengzhou Liu | ccc57ef | 2014-12-17 16:51:08 +0800 | [diff] [blame] | 63 | /* set the on-board RGMII2 PHY */ |
| 64 | fm_info_set_phy_address(FM1_DTSEC3, RGMII_PHY2_ADDR); |
| 65 | |
| 66 | /* set 10G XFI with Aquantia AQR105 PHY */ |
Shengzhou Liu | 4991240 | 2014-11-24 17:11:56 +0800 | [diff] [blame] | 67 | fm_info_set_phy_address(FM1_10GEC1, FM1_10GEC1_PHY_ADDR); |
| 68 | break; |
Shengzhou Liu | 00d7e5b | 2015-03-27 15:48:34 +0800 | [diff] [blame] | 69 | #endif |
| 70 | case 0x6a: |
| 71 | case 0x6b: |
Shengzhou Liu | ccc57ef | 2014-12-17 16:51:08 +0800 | [diff] [blame] | 72 | case 0x77: |
| 73 | case 0x135: |
| 74 | /* set the on-board 2.5G SGMII AQR105 PHY */ |
Shengzhou Liu | 00d7e5b | 2015-03-27 15:48:34 +0800 | [diff] [blame] | 75 | fm_info_set_phy_address(FM1_DTSEC3, SGMII_AQR_PHY_ADDR); |
| 76 | #ifdef CONFIG_T1023RDB |
| 77 | /* set the on-board 1G SGMII RTL8211F PHY */ |
| 78 | fm_info_set_phy_address(FM1_DTSEC1, SGMII_RTK_PHY_ADDR); |
| 79 | #endif |
Shengzhou Liu | ccc57ef | 2014-12-17 16:51:08 +0800 | [diff] [blame] | 80 | break; |
Shengzhou Liu | 4991240 | 2014-11-24 17:11:56 +0800 | [diff] [blame] | 81 | default: |
| 82 | printf("SerDes protocol 0x%x is not supported on T102xRDB\n", |
| 83 | srds_s1); |
| 84 | break; |
| 85 | } |
| 86 | |
| 87 | for (i = FM1_DTSEC1; i < FM1_DTSEC1 + CONFIG_SYS_NUM_FM1_DTSEC; i++) { |
| 88 | interface = fm_info_get_enet_if(i); |
| 89 | switch (interface) { |
| 90 | case PHY_INTERFACE_MODE_RGMII: |
| 91 | dev = miiphy_get_dev_by_name(DEFAULT_FM_MDIO_NAME); |
| 92 | fm_info_set_mdio(i, dev); |
| 93 | break; |
Shengzhou Liu | 00d7e5b | 2015-03-27 15:48:34 +0800 | [diff] [blame] | 94 | case PHY_INTERFACE_MODE_SGMII: |
| 95 | #if defined(CONFIG_T1023RDB) |
| 96 | dev = miiphy_get_dev_by_name(DEFAULT_FM_MDIO_NAME); |
| 97 | #elif defined(CONFIG_T1024RDB) |
| 98 | dev = miiphy_get_dev_by_name(DEFAULT_FM_TGEC_MDIO_NAME); |
| 99 | #endif |
| 100 | fm_info_set_mdio(i, dev); |
| 101 | break; |
Shengzhou Liu | ccc57ef | 2014-12-17 16:51:08 +0800 | [diff] [blame] | 102 | case PHY_INTERFACE_MODE_SGMII_2500: |
| 103 | dev = miiphy_get_dev_by_name(DEFAULT_FM_TGEC_MDIO_NAME); |
| 104 | fm_info_set_mdio(i, dev); |
| 105 | break; |
Shengzhou Liu | 4991240 | 2014-11-24 17:11:56 +0800 | [diff] [blame] | 106 | default: |
| 107 | break; |
| 108 | } |
| 109 | } |
| 110 | |
| 111 | for (i = FM1_10GEC1; i < FM1_10GEC1 + CONFIG_SYS_NUM_FM1_10GEC; i++) { |
| 112 | switch (fm_info_get_enet_if(i)) { |
| 113 | case PHY_INTERFACE_MODE_XGMII: |
| 114 | dev = miiphy_get_dev_by_name(DEFAULT_FM_TGEC_MDIO_NAME); |
| 115 | fm_info_set_mdio(i, dev); |
| 116 | break; |
| 117 | default: |
| 118 | break; |
| 119 | } |
| 120 | } |
| 121 | |
| 122 | cpu_eth_init(bis); |
| 123 | #endif /* CONFIG_FMAN_ENET */ |
| 124 | |
| 125 | return pci_eth_init(bis); |
| 126 | } |
| 127 | |
Shengzhou Liu | ccc57ef | 2014-12-17 16:51:08 +0800 | [diff] [blame] | 128 | void board_ft_fman_fixup_port(void *fdt, char *compat, phys_addr_t addr, |
| 129 | enum fm_port port, int offset) |
| 130 | { |
Shengzhou Liu | 00d7e5b | 2015-03-27 15:48:34 +0800 | [diff] [blame] | 131 | #if defined(CONFIG_T1024RDB) |
| 132 | if (((fm_info_get_enet_if(port) == PHY_INTERFACE_MODE_SGMII_2500) || |
| 133 | (fm_info_get_enet_if(port) == PHY_INTERFACE_MODE_SGMII)) && |
| 134 | (port == FM1_DTSEC3)) { |
Shengzhou Liu | ccc57ef | 2014-12-17 16:51:08 +0800 | [diff] [blame] | 135 | fdt_set_phy_handle(fdt, compat, addr, "sg_2500_aqr105_phy4"); |
Shengzhou Liu | 032df62 | 2015-04-14 17:56:50 +0800 | [diff] [blame] | 136 | fdt_setprop_string(fdt, offset, "phy-connection-type", |
| 137 | "sgmii-2500"); |
Shengzhou Liu | ccc57ef | 2014-12-17 16:51:08 +0800 | [diff] [blame] | 138 | fdt_status_disabled_by_alias(fdt, "xg_aqr105_phy3"); |
| 139 | } |
Shengzhou Liu | 00d7e5b | 2015-03-27 15:48:34 +0800 | [diff] [blame] | 140 | #endif |
Shengzhou Liu | ccc57ef | 2014-12-17 16:51:08 +0800 | [diff] [blame] | 141 | } |
| 142 | |
Shengzhou Liu | 4991240 | 2014-11-24 17:11:56 +0800 | [diff] [blame] | 143 | void fdt_fixup_board_enet(void *fdt) |
| 144 | { |
| 145 | } |