[U-Boot] [v2] net/phy/cortina: Add support for CS4223 PHY

Joe Hershberger joe.hershberger at ni.com
Wed May 2 19:06:44 UTC 2018


On Wed, May 2, 2018 at 6:23 AM, Vicentiu Galanopulo
<vicentiu.galanopulo at nxp.com> wrote:
> Add support for Cortina CS4223 10G PHY
>   - As per the CS4223 specs, an EEPROM module is
>     connected to the PHY. At startup the PHY reads
>     the firmware line and tries to load the firmware
>     into the internal memory.
>   - This driver reads the EEPROM status
>     and checks if firmware has been loaded
>   - v2 - change return value of cs4223_phy_init
>     from -1 to -ENOSYS

Generally you should be using tools/patman/patman to manage your
patches. These version comments would then end up in the proper notes
section and not in the patch's log. It's fine for this patch, I'll
clean it up when I apply it, but please use patman in the future.

>
> Signed-off-by: Vicentiu Galanopulo <vicentiu.galanopulo at nxp.com>

Acked-by: Joe Hershberger <joe.hershberger at ni.com>

> ---
>  drivers/net/phy/cortina.c | 48 ++++++++++++++++++++++++++++++++++++++++++++++-
>  include/cortina.h         |  4 ++++
>  include/phy.h             |  1 +
>  3 files changed, 52 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/net/phy/cortina.c b/drivers/net/phy/cortina.c
> index 9cb3a52..cb6dc56 100644
> --- a/drivers/net/phy/cortina.c
> +++ b/drivers/net/phy/cortina.c
> @@ -285,6 +285,38 @@ int cs4340_startup(struct phy_device *phydev)
>         return 0;
>  }
>
> +int cs4223_phy_init(struct phy_device *phydev)
> +{
> +       int reg_value;
> +
> +       reg_value = phy_read(phydev, 0x00, CS4223_EEPROM_STATUS);
> +       if (!(reg_value & CS4223_EEPROM_FIRMWARE_LOADDONE)) {
> +               printf("%s CS4223 Firmware not present in EERPOM\n", __func__);
> +               return -ENOSYS;
> +       }
> +
> +       return 0;
> +}
> +
> +int cs4223_config(struct phy_device *phydev)
> +{
> +       return cs4223_phy_init(phydev);
> +}
> +
> +int cs4223_probe(struct phy_device *phydev)
> +{
> +       phydev->flags = PHY_FLAG_BROKEN_RESET;
> +       return 0;
> +}
> +
> +int cs4223_startup(struct phy_device *phydev)
> +{
> +       phydev->link = 1;
> +       phydev->speed = SPEED_10000;
> +       phydev->duplex = DUPLEX_FULL;
> +       return 0;
> +}
> +
>  struct phy_driver cs4340_driver = {
>         .name = "Cortina CS4315/CS4340",
>         .uid = PHY_UID_CS4340,
> @@ -299,9 +331,23 @@ struct phy_driver cs4340_driver = {
>         .shutdown = &gen10g_shutdown,
>  };
>
> +struct phy_driver cs4223_driver = {
> +       .name = "Cortina CS4223",
> +       .uid = PHY_UID_CS4223,
> +       .mask = 0x0ffff00f,
> +       .features = PHY_10G_FEATURES,
> +       .mmds = (MDIO_DEVS_PMAPMD | MDIO_DEVS_PCS |
> +                MDIO_DEVS_AN),
> +       .config = &cs4223_config,
> +       .probe  = &cs4223_probe,
> +       .startup = &cs4223_startup,
> +       .shutdown = &gen10g_shutdown,
> +};
> +
>  int phy_cortina_init(void)
>  {
>         phy_register(&cs4340_driver);
> +       phy_register(&cs4223_driver);
>         return 0;
>  }
>
> @@ -320,7 +366,7 @@ int get_phy_id(struct mii_dev *bus, int addr, int devad, u32 *phy_id)
>                 return -EIO;
>         *phy_id |= (phy_reg & 0xffff);
>
> -       if (*phy_id == PHY_UID_CS4340)
> +       if ((*phy_id == PHY_UID_CS4340) || (*phy_id == PHY_UID_CS4223))
>                 return 0;
>
>         /*
> diff --git a/include/cortina.h b/include/cortina.h
> index 6cadd28..b64cb44 100644
> --- a/include/cortina.h
> +++ b/include/cortina.h
> @@ -65,6 +65,10 @@
>  #define VILLA_LINE_SDS_COMMON_STX0_TX_OUTPUT_CTRLA 0x427
>  #define VILLA_LINE_SDS_COMMON_STX0_TX_OUTPUT_CTRLB 0x428
>
> +/* Cortina CS4223 */
> +#define CS4223_EEPROM_STATUS  0x5001
> +#define CS4223_EEPROM_FIRMWARE_LOADDONE  0x1
> +
>  #define mseq_edc_bist_done (0x1<<0)
>  #define mseq_edc_bist_fail (0x1<<8)
>
> diff --git a/include/phy.h b/include/phy.h
> index 0543ec1..2239317 100644
> --- a/include/phy.h
> +++ b/include/phy.h
> @@ -315,6 +315,7 @@ static inline bool phy_interface_is_sgmii(struct phy_device *phydev)
>
>  /* PHY UIDs for various PHYs that are referenced in external code */
>  #define PHY_UID_CS4340  0x13e51002
> +#define PHY_UID_CS4223  0x03e57003
>  #define PHY_UID_TN2020 0x00a19410
>
>  #endif
> --
> 1.9.3
>
> _______________________________________________
> U-Boot mailing list
> U-Boot at lists.denx.de
> https://lists.denx.de/listinfo/u-boot


More information about the U-Boot mailing list