From: =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= Date: Tue, 16 Oct 2018 11:22:49 +0200 Subject: [U-Boot] [PATCH v4 10/13] net: ftgmac100: Add support for the Aspeed SoC In-Reply-To: <20181016092252.11664-1-clg@kaod.org> References: <20181016092252.11664-1-clg@kaod.org> Message-ID: <20181016092252.11664-11-clg@kaod.org> List-Id: MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable To: u-boot@lists.denx.de The Faraday ftgmac100 MAC controllers as found on the Aspeed SoCs have some slight differences in the HW interface (End-Of-Rx/Tx-Ring bits). Signed-off-by: C=C3=A9dric Le Goater Reviewed-by: Simon Glass Reviewed-by: Joel Stanley Acked-by: Joe Hershberger --- drivers/net/ftgmac100.c | 31 +++++++++++++++++++++++++++---- configs/evb-ast2500_defconfig | 8 ++++++++ 2 files changed, 35 insertions(+), 4 deletions(-) diff --git a/drivers/net/ftgmac100.c b/drivers/net/ftgmac100.c index e1104a544748..78abf8b984c0 100644 --- a/drivers/net/ftgmac100.c +++ b/drivers/net/ftgmac100.c @@ -43,6 +43,14 @@ */ #define MDC_CYCTHR 0x34 =20 +/* + * ftgmac100 model variants + */ +enum ftgmac100_model { + FTGMAC100_MODEL_FARADAY, + FTGMAC100_MODEL_ASPEED, +}; + /** * struct ftgmac100_data - private data for the FTGMAC100 driver * @@ -57,6 +65,8 @@ * @phy_mode: The mode of the PHY interface (rgmii, rmii, ...) * @max_speed: Maximum speed of Ethernet connection supported by MAC * @clks: The bulk of clocks assigned to the device in the DT + * @rxdes0_edorr_mask: The bit number identifying the end of the RX ring b= uffer + * @txdes0_edotr_mask: The bit number identifying the end of the TX ring b= uffer */ struct ftgmac100_data { struct ftgmac100 *iobase; @@ -73,6 +83,10 @@ struct ftgmac100_data { u32 max_speed; =20 struct clk_bulk clks; + + /* End of RX/TX ring buffer bits. Depend on model */ + u32 rxdes0_edorr_mask; + u32 txdes0_edotr_mask; }; =20 /* @@ -293,7 +307,7 @@ static int ftgmac100_start(struct udevice *dev) priv->txdes[i].txdes3 =3D 0; priv->txdes[i].txdes0 =3D 0; } - priv->txdes[PKTBUFSTX - 1].txdes0 =3D FTGMAC100_TXDES0_EDOTR; + priv->txdes[PKTBUFSTX - 1].txdes0 =3D priv->txdes0_edotr_mask; =20 start =3D (ulong)&priv->txdes[0]; end =3D start + roundup(sizeof(priv->txdes), ARCH_DMA_MINALIGN); @@ -303,7 +317,7 @@ static int ftgmac100_start(struct udevice *dev) priv->rxdes[i].rxdes3 =3D (unsigned int)net_rx_packets[i]; priv->rxdes[i].rxdes0 =3D 0; } - priv->rxdes[PKTBUFSRX - 1].rxdes0 =3D FTGMAC100_RXDES0_EDORR; + priv->rxdes[PKTBUFSRX - 1].rxdes0 =3D priv->rxdes0_edorr_mask; =20 start =3D (ulong)&priv->rxdes[0]; end =3D start + roundup(sizeof(priv->rxdes), ARCH_DMA_MINALIGN); @@ -478,7 +492,7 @@ static int ftgmac100_send(struct udevice *dev, void *pa= cket, int length) flush_dcache_range(data_start, data_end); =20 /* Only one segment on TXBUF */ - curr_des->txdes0 &=3D FTGMAC100_TXDES0_EDOTR; + curr_des->txdes0 &=3D priv->txdes0_edotr_mask; curr_des->txdes0 |=3D FTGMAC100_TXDES0_FTS | FTGMAC100_TXDES0_LTS | FTGMAC100_TXDES0_TXBUF_SIZE(length) | @@ -528,6 +542,14 @@ static int ftgmac100_ofdata_to_platdata(struct udevice= *dev) =20 pdata->max_speed =3D dev_read_u32_default(dev, "max-speed", 0); =20 + if (dev_get_driver_data(dev) =3D=3D FTGMAC100_MODEL_ASPEED) { + priv->rxdes0_edorr_mask =3D BIT(30); + priv->txdes0_edotr_mask =3D BIT(30); + } else { + priv->rxdes0_edorr_mask =3D BIT(15); + priv->txdes0_edotr_mask =3D BIT(15); + } + return clk_get_bulk(dev, &priv->clks); } =20 @@ -587,7 +609,8 @@ static const struct eth_ops ftgmac100_ops =3D { }; =20 static const struct udevice_id ftgmac100_ids[] =3D { - { .compatible =3D "faraday,ftgmac100" }, + { .compatible =3D "faraday,ftgmac100", .data =3D FTGMAC100_MODEL_FARADAY= }, + { .compatible =3D "aspeed,ast2500-mac", .data =3D FTGMAC100_MODEL_ASPEED = }, { } }; =20 diff --git a/configs/evb-ast2500_defconfig b/configs/evb-ast2500_defconfig index 88230f4a12db..32581f5ada54 100644 --- a/configs/evb-ast2500_defconfig +++ b/configs/evb-ast2500_defconfig @@ -25,3 +25,11 @@ CONFIG_SYS_NS16550=3Dy CONFIG_SYSRESET=3Dy CONFIG_TIMER=3Dy CONFIG_WDT=3Dy +CONFIG_NETDEVICES=3Dy +CONFIG_PHY=3Dy +CONFIG_DM_ETH=3Dy +CONFIG_FTGMAC100=3Dy +CONFIG_PHY_REALTEK=3Dy +CONFIG_CMD_PING=3Dy +CONFIG_CMD_DHCP=3Dy +CONFIG_CMD_MII=3Dy --=20 2.17.2