Mario Scheithauer has uploaded this change for review. ( https://review.coreboot.org/c/coreboot/+/69386 )
Change subject: drivers/phy/m88e1512: Provide functionality to customize LED status ......................................................................
drivers/phy/m88e1512: Provide functionality to customize LED status
For Marvel PHY it could be necessary to customize the shown LED status at the connector. The LED status can be changed via PHY Function Control Register on page 3.
Link to the Marvell PHY 88E1512 datasheet: https://www.marvell.com/content/dam/marvell/en/public-collateral/phys-transc...
Change-Id: Ia71c43f4286f9201f03cb759252ebb405ab81904 Signed-off-by: Mario Scheithauer mario.scheithauer@siemens.com --- A src/drivers/phy/m88e1512/chip.h M src/drivers/phy/m88e1512/m88e1512.c A src/drivers/phy/m88e1512/m88e1512.h 3 files changed, 70 insertions(+), 0 deletions(-)
git pull ssh://review.coreboot.org:29418/coreboot refs/changes/86/69386/1
diff --git a/src/drivers/phy/m88e1512/chip.h b/src/drivers/phy/m88e1512/chip.h new file mode 100644 index 0000000..e22a087 --- /dev/null +++ b/src/drivers/phy/m88e1512/chip.h @@ -0,0 +1,8 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ + +#include "m88e1512.h" + +struct drivers_phy_m88e1512_config { + unsigned char led_customize; /* Enable LED customization */ + unsigned char led_ctrl; /* LED[1:0] Control */ +}; diff --git a/src/drivers/phy/m88e1512/m88e1512.c b/src/drivers/phy/m88e1512/m88e1512.c index 7da0651..81c77e6 100644 --- a/src/drivers/phy/m88e1512/m88e1512.c +++ b/src/drivers/phy/m88e1512/m88e1512.c @@ -1,9 +1,41 @@ /* SPDX-License-Identifier: GPL-2.0-only */
+#include <console/console.h> #include <device/device.h> +#include <device/mdio.h> +#include <device/pci.h> +#include <soc/mdio.h> +#include "chip.h" +#include "m88e1512.h"
static void m88e1512_init(struct device *dev) { + const struct mdio_operations *mdio_ops; + struct drivers_phy_m88e1512_config *config = dev->chip_info; + uint16_t page_reg; + + mdio_ops = dev_get_mdio_ops(dev->bus->dev); + + /* Customize LEDs if led_ctrl is set. */ + if (mdio_ops && config->led_customize) { + printk(BIOS_DEBUG, "%s: Set a customized LED mode on 0x%x...\n", + dev->chip_ops->name, dev->bus->dev->device); + + /* Select page 3 to access LED function control register. */ + mdio_ops->write(dev->bus->dev, dev->path.pnp.device, + PHY_MDIO_PAGE_ANY_ADR_REG, PHY_MDIO_PAGE_3_SEL); + + /* Modify PHY LED mode. */ + page_reg = mdio_ops->read(dev->bus->dev, dev->path.pnp.device, + PHY_MDIO_LED_FUNC_CTRL_REG); + clrsetbits16(&page_reg, PHY_MDIO_LED_FUNC_CTRL_MASK, config->led_ctrl); + mdio_ops->write(dev->bus->dev, dev->path.pnp.device, + PHY_MDIO_LED_FUNC_CTRL_REG, page_reg); + + /* Select page back to 0. */ + mdio_ops->write(dev->bus->dev, dev->path.pnp.device, + PHY_MDIO_PAGE_ANY_ADR_REG, PHY_MDIO_PAGE_0_SEL); + } }
static struct device_operations m88e1512_ops = { diff --git a/src/drivers/phy/m88e1512/m88e1512.h b/src/drivers/phy/m88e1512/m88e1512.h new file mode 100644 index 0000000..90ada1a --- /dev/null +++ b/src/drivers/phy/m88e1512/m88e1512.h @@ -0,0 +1,13 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ + +#ifndef _PHY_M88E1512_H_ +#define _PHY_M88E1512_H_ + +/* Register layout */ +#define PHY_MDIO_PAGE_ANY_ADR_REG 0x16 +#define PHY_MDIO_PAGE_0_SEL 0 +#define PHY_MDIO_PAGE_3_SEL 3 +#define PHY_MDIO_LED_FUNC_CTRL_REG 0x10 +#define PHY_MDIO_LED_FUNC_CTRL_MASK 0x00FF + +#endif /* _PHY_M88E1512_H_ */