drivers/net/phy/m88e1512: Add a way to set output impedance manually

This patch provides the functionality to set the RGMII output impedance
manually. To ensure that no race condition occurs, the driver strength
values for PMOS and NMOS should be written to the RGMII output impedance
calibration override register first and then the force bit should be
enabled with a second write to this register.

Link to the Marvell PHY 88E1512 datasheet:
https://web.archive.org/web/20230125074158/https://www.marvell.com/content/dam/marvell/en/public-collateral/phys-transceivers/marvell-ethernet-phys-alaska-88e151x-datasheet.pdf

Change-Id: I87fa03aa49514cdc33d2911d7f23386c8f69d95b
Signed-off-by: Mario Scheithauer <mario.scheithauer@siemens.com>
Reviewed-on: https://review.coreboot.org/c/coreboot/+/73018
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Werner Zeh <werner.zeh@siemens.com>
This commit is contained in:
Mario Scheithauer 2023-01-25 11:43:51 +01:00 committed by Felix Held
parent 33ef5c4e3a
commit 481bfe6a8b
3 changed files with 28 additions and 0 deletions

View File

@ -11,4 +11,7 @@ struct drivers_net_phy_m88e1512_config {
/* 1x, 2x,...8x is the number of times the PHY attempts to establish Gigabit link
before the PHY downshifts to the next highest speed. */
unsigned char downshift_cnt;
bool force_mos; /* Force PMOS/NMOS manually */
unsigned char pmos_val; /* Set PMOS calibration value */
unsigned char nmos_val; /* Set NMOS calibration value */
};

View File

@ -67,6 +67,25 @@ static void m88e1512_init(struct device *dev)
mdio_write(dev, LED_TIMER_CTRL_REG, reg);
}
/* Set RGMII output impedance manually. */
if (config->force_mos) {
printk(BIOS_DEBUG, "%s: Set RGMII driver strength manually for %s.\n",
dev_path(dev->bus->dev), dev->chip_ops->name);
/* Select page 2 to access RGMII output impedance calibration override
register. */
switch_page(dev, 2);
reg = mdio_read(dev, OUT_IMP_CAL_OVERRIDE_REG);
/* Set first only NMOS/PMOS values. */
clrsetbits16(&reg, MOS_VALUE_MASK, PMOS_VALUE(config->pmos_val) |
NMOS_VALUE(config->nmos_val));
mdio_write(dev, OUT_IMP_CAL_OVERRIDE_REG, reg);
/* Activate the new setting. */
setbits16(&reg, FORCE_MOS);
mdio_write(dev, OUT_IMP_CAL_OVERRIDE_REG, reg);
}
/* Switch back to page 0. */
switch_page(dev, 0);
}

View File

@ -13,6 +13,12 @@
#define DOWNSHIFT_CNT_MAX 8
#define DOWNSHIFT_CNT(cnt) ((cnt - 1) << 12)
#define DOWNSHIFT_EN (1 << 11)
/* Page 2 registers */
#define OUT_IMP_CAL_OVERRIDE_REG 0x18
#define MOS_VALUE_MASK 0x0F4F
#define PMOS_VALUE(pmos) (pmos << 8)
#define FORCE_MOS (1 << 6)
#define NMOS_VALUE(nmos) (nmos << 0)
/* Page 3 registers */
#define LED_FUNC_CTRL_REG 0x10
#define LED_FUNC_CTRL_MASK 0x0FFF