mirror of
https://github.com/AsahiLinux/u-boot
synced 2024-12-01 17:10:11 +00:00
83d290c56f
When U-Boot started using SPDX tags we were among the early adopters and there weren't a lot of other examples to borrow from. So we picked the area of the file that usually had a full license text and replaced it with an appropriate SPDX-License-Identifier: entry. Since then, the Linux Kernel has adopted SPDX tags and they place it as the very first line in a file (except where shebangs are used, then it's second line) and with slightly different comment styles than us. In part due to community overlap, in part due to better tag visibility and in part for other minor reasons, switch over to that style. This commit changes all instances where we have a single declared license in the tag as both the before and after are identical in tag contents. There's also a few places where I found we did not have a tag and have introduced one. Signed-off-by: Tom Rini <trini@konsulko.com>
99 lines
2.5 KiB
C
99 lines
2.5 KiB
C
// SPDX-License-Identifier: GPL-2.0+
|
|
/*
|
|
* Author Adrian Cox
|
|
* Based somewhat on board/freescale/corenet_ds/eth_hydra.c
|
|
*/
|
|
|
|
#include <common.h>
|
|
#include <netdev.h>
|
|
#include <asm/fsl_serdes.h>
|
|
#include <fm_eth.h>
|
|
#include <fsl_mdio.h>
|
|
#include <malloc.h>
|
|
#include <fdt_support.h>
|
|
#include <fsl_dtsec.h>
|
|
|
|
#ifdef CONFIG_FMAN_ENET
|
|
|
|
#define FIRST_PORT_ADDR 3
|
|
#define SECOND_PORT_ADDR 7
|
|
|
|
#ifdef CONFIG_ARCH_P5040
|
|
#define FIRST_PORT FM1_DTSEC5
|
|
#define SECOND_PORT FM2_DTSEC5
|
|
#else
|
|
#define FIRST_PORT FM1_DTSEC4
|
|
#define SECOND_PORT FM1_DTSEC5
|
|
#endif
|
|
|
|
#define IS_VALID_PORT(p) ((p) == FIRST_PORT || (p) == SECOND_PORT)
|
|
|
|
static void cyrus_phy_tuning(int phy)
|
|
{
|
|
/*
|
|
* Enable RGMII delay on Tx and Rx for CPU port
|
|
*/
|
|
printf("Tuning PHY @ %d\n", phy);
|
|
|
|
/* sets address 0x104 or reg 260 for writing */
|
|
miiphy_write(DEFAULT_FM_MDIO_NAME, phy, 0xb, 0x8104);
|
|
/* Sets RXC/TXC to +0.96ns and TX_CTL/RX_CTL to -0.84ns */
|
|
miiphy_write(DEFAULT_FM_MDIO_NAME, phy, 0xc, 0xf0f0);
|
|
/* sets address 0x105 or reg 261 for writing */
|
|
miiphy_write(DEFAULT_FM_MDIO_NAME, phy, 0xb, 0x8105);
|
|
/* writes to address 0x105 , RXD[3..0] to -0. */
|
|
miiphy_write(DEFAULT_FM_MDIO_NAME, phy, 0xc, 0x0000);
|
|
/* sets address 0x106 or reg 261 for writing */
|
|
miiphy_write(DEFAULT_FM_MDIO_NAME, phy, 0xb, 0x8106);
|
|
/* writes to address 0x106 , TXD[3..0] to -0.84ns */
|
|
miiphy_write(DEFAULT_FM_MDIO_NAME, phy, 0xc, 0x0000);
|
|
/* force re-negotiation */
|
|
miiphy_write(DEFAULT_FM_MDIO_NAME, phy, 0x0, 0x1340);
|
|
}
|
|
#endif
|
|
|
|
int board_eth_init(bd_t *bis)
|
|
{
|
|
#ifdef CONFIG_FMAN_ENET
|
|
struct fsl_pq_mdio_info dtsec_mdio_info;
|
|
unsigned int i;
|
|
|
|
printf("Initializing Fman\n");
|
|
|
|
|
|
/* Register the real 1G MDIO bus */
|
|
dtsec_mdio_info.regs =
|
|
(struct tsec_mii_mng *)CONFIG_SYS_FM1_DTSEC1_MDIO_ADDR;
|
|
dtsec_mdio_info.name = DEFAULT_FM_MDIO_NAME;
|
|
|
|
fsl_pq_mdio_init(bis, &dtsec_mdio_info);
|
|
|
|
|
|
fm_info_set_phy_address(FIRST_PORT, FIRST_PORT_ADDR);
|
|
fm_info_set_mdio(FIRST_PORT,
|
|
miiphy_get_dev_by_name(DEFAULT_FM_MDIO_NAME));
|
|
fm_info_set_phy_address(SECOND_PORT, SECOND_PORT_ADDR);
|
|
fm_info_set_mdio(SECOND_PORT,
|
|
miiphy_get_dev_by_name(DEFAULT_FM_MDIO_NAME));
|
|
|
|
/* Never disable DTSEC1 - it controls MDIO */
|
|
for (i = FM1_DTSEC2; i < FM1_DTSEC1 + CONFIG_SYS_NUM_FM1_DTSEC; i++) {
|
|
if (!IS_VALID_PORT(i))
|
|
fm_disable_port(i);
|
|
}
|
|
|
|
#ifdef CONFIG_ARCH_P5040
|
|
for (i = FM2_DTSEC2; i < FM2_DTSEC1 + CONFIG_SYS_NUM_FM2_DTSEC; i++) {
|
|
if (!IS_VALID_PORT(i))
|
|
fm_disable_port(i);
|
|
}
|
|
#endif
|
|
|
|
cpu_eth_init(bis);
|
|
|
|
cyrus_phy_tuning(FIRST_PORT_ADDR);
|
|
cyrus_phy_tuning(SECOND_PORT_ADDR);
|
|
#endif
|
|
|
|
return pci_eth_init(bis);
|
|
}
|