Commit 6b7e4008 authored by Lothar Waßmann's avatar Lothar Waßmann Committed by David S. Miller

net: fec: improve access to quirk flags by copying them into fec_enet_private struct

Signed-off-by: default avatarLothar Waßmann <LW@KARO-electronics.de>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 217b5844
...@@ -504,6 +504,7 @@ struct fec_enet_private { ...@@ -504,6 +504,7 @@ struct fec_enet_private {
int irq[FEC_IRQ_NUM]; int irq[FEC_IRQ_NUM];
bool bufdesc_ex; bool bufdesc_ex;
int pause_flag; int pause_flag;
u32 quirks;
struct napi_struct napi; struct napi_struct napi;
int csum_flags; int csum_flags;
......
...@@ -361,8 +361,6 @@ fec_enet_txq_submit_frag_skb(struct fec_enet_priv_tx_q *txq, ...@@ -361,8 +361,6 @@ fec_enet_txq_submit_frag_skb(struct fec_enet_priv_tx_q *txq,
struct net_device *ndev) struct net_device *ndev)
{ {
struct fec_enet_private *fep = netdev_priv(ndev); struct fec_enet_private *fep = netdev_priv(ndev);
const struct platform_device_id *id_entry =
platform_get_device_id(fep->pdev);
struct bufdesc *bdp = txq->cur_tx; struct bufdesc *bdp = txq->cur_tx;
struct bufdesc_ex *ebdp; struct bufdesc_ex *ebdp;
int nr_frags = skb_shinfo(skb)->nr_frags; int nr_frags = skb_shinfo(skb)->nr_frags;
...@@ -398,7 +396,7 @@ fec_enet_txq_submit_frag_skb(struct fec_enet_priv_tx_q *txq, ...@@ -398,7 +396,7 @@ fec_enet_txq_submit_frag_skb(struct fec_enet_priv_tx_q *txq,
} }
if (fep->bufdesc_ex) { if (fep->bufdesc_ex) {
if (id_entry->driver_data & FEC_QUIRK_HAS_AVB) if (fep->quirks & FEC_QUIRK_HAS_AVB)
estatus |= FEC_TX_BD_FTYPE(queue); estatus |= FEC_TX_BD_FTYPE(queue);
if (skb->ip_summed == CHECKSUM_PARTIAL) if (skb->ip_summed == CHECKSUM_PARTIAL)
estatus |= BD_ENET_TX_PINS | BD_ENET_TX_IINS; estatus |= BD_ENET_TX_PINS | BD_ENET_TX_IINS;
...@@ -410,11 +408,11 @@ fec_enet_txq_submit_frag_skb(struct fec_enet_priv_tx_q *txq, ...@@ -410,11 +408,11 @@ fec_enet_txq_submit_frag_skb(struct fec_enet_priv_tx_q *txq,
index = fec_enet_get_bd_index(txq->tx_bd_base, bdp, fep); index = fec_enet_get_bd_index(txq->tx_bd_base, bdp, fep);
if (((unsigned long) bufaddr) & fep->tx_align || if (((unsigned long) bufaddr) & fep->tx_align ||
id_entry->driver_data & FEC_QUIRK_SWAP_FRAME) { fep->quirks & FEC_QUIRK_SWAP_FRAME) {
memcpy(txq->tx_bounce[index], bufaddr, frag_len); memcpy(txq->tx_bounce[index], bufaddr, frag_len);
bufaddr = txq->tx_bounce[index]; bufaddr = txq->tx_bounce[index];
if (id_entry->driver_data & FEC_QUIRK_SWAP_FRAME) if (fep->quirks & FEC_QUIRK_SWAP_FRAME)
swap_buffer(bufaddr, frag_len); swap_buffer(bufaddr, frag_len);
} }
...@@ -450,8 +448,6 @@ static int fec_enet_txq_submit_skb(struct fec_enet_priv_tx_q *txq, ...@@ -450,8 +448,6 @@ static int fec_enet_txq_submit_skb(struct fec_enet_priv_tx_q *txq,
struct sk_buff *skb, struct net_device *ndev) struct sk_buff *skb, struct net_device *ndev)
{ {
struct fec_enet_private *fep = netdev_priv(ndev); struct fec_enet_private *fep = netdev_priv(ndev);
const struct platform_device_id *id_entry =
platform_get_device_id(fep->pdev);
int nr_frags = skb_shinfo(skb)->nr_frags; int nr_frags = skb_shinfo(skb)->nr_frags;
struct bufdesc *bdp, *last_bdp; struct bufdesc *bdp, *last_bdp;
void *bufaddr; void *bufaddr;
...@@ -490,11 +486,11 @@ static int fec_enet_txq_submit_skb(struct fec_enet_priv_tx_q *txq, ...@@ -490,11 +486,11 @@ static int fec_enet_txq_submit_skb(struct fec_enet_priv_tx_q *txq,
queue = skb_get_queue_mapping(skb); queue = skb_get_queue_mapping(skb);
index = fec_enet_get_bd_index(txq->tx_bd_base, bdp, fep); index = fec_enet_get_bd_index(txq->tx_bd_base, bdp, fep);
if (((unsigned long) bufaddr) & fep->tx_align || if (((unsigned long) bufaddr) & fep->tx_align ||
id_entry->driver_data & FEC_QUIRK_SWAP_FRAME) { fep->quirks & FEC_QUIRK_SWAP_FRAME) {
memcpy(txq->tx_bounce[index], skb->data, buflen); memcpy(txq->tx_bounce[index], skb->data, buflen);
bufaddr = txq->tx_bounce[index]; bufaddr = txq->tx_bounce[index];
if (id_entry->driver_data & FEC_QUIRK_SWAP_FRAME) if (fep->quirks & FEC_QUIRK_SWAP_FRAME)
swap_buffer(bufaddr, buflen); swap_buffer(bufaddr, buflen);
} }
...@@ -529,7 +525,7 @@ static int fec_enet_txq_submit_skb(struct fec_enet_priv_tx_q *txq, ...@@ -529,7 +525,7 @@ static int fec_enet_txq_submit_skb(struct fec_enet_priv_tx_q *txq,
fep->hwts_tx_en)) fep->hwts_tx_en))
skb_shinfo(skb)->tx_flags |= SKBTX_IN_PROGRESS; skb_shinfo(skb)->tx_flags |= SKBTX_IN_PROGRESS;
if (id_entry->driver_data & FEC_QUIRK_HAS_AVB) if (fep->quirks & FEC_QUIRK_HAS_AVB)
estatus |= FEC_TX_BD_FTYPE(queue); estatus |= FEC_TX_BD_FTYPE(queue);
if (skb->ip_summed == CHECKSUM_PARTIAL) if (skb->ip_summed == CHECKSUM_PARTIAL)
...@@ -573,8 +569,6 @@ fec_enet_txq_put_data_tso(struct fec_enet_priv_tx_q *txq, struct sk_buff *skb, ...@@ -573,8 +569,6 @@ fec_enet_txq_put_data_tso(struct fec_enet_priv_tx_q *txq, struct sk_buff *skb,
int size, bool last_tcp, bool is_last) int size, bool last_tcp, bool is_last)
{ {
struct fec_enet_private *fep = netdev_priv(ndev); struct fec_enet_private *fep = netdev_priv(ndev);
const struct platform_device_id *id_entry =
platform_get_device_id(fep->pdev);
struct bufdesc_ex *ebdp = container_of(bdp, struct bufdesc_ex, desc); struct bufdesc_ex *ebdp = container_of(bdp, struct bufdesc_ex, desc);
unsigned short queue = skb_get_queue_mapping(skb); unsigned short queue = skb_get_queue_mapping(skb);
unsigned short status; unsigned short status;
...@@ -587,11 +581,11 @@ fec_enet_txq_put_data_tso(struct fec_enet_priv_tx_q *txq, struct sk_buff *skb, ...@@ -587,11 +581,11 @@ fec_enet_txq_put_data_tso(struct fec_enet_priv_tx_q *txq, struct sk_buff *skb,
status |= (BD_ENET_TX_TC | BD_ENET_TX_READY); status |= (BD_ENET_TX_TC | BD_ENET_TX_READY);
if (((unsigned long) data) & fep->tx_align || if (((unsigned long) data) & fep->tx_align ||
id_entry->driver_data & FEC_QUIRK_SWAP_FRAME) { fep->quirks & FEC_QUIRK_SWAP_FRAME) {
memcpy(txq->tx_bounce[index], data, size); memcpy(txq->tx_bounce[index], data, size);
data = txq->tx_bounce[index]; data = txq->tx_bounce[index];
if (id_entry->driver_data & FEC_QUIRK_SWAP_FRAME) if (fep->quirks & FEC_QUIRK_SWAP_FRAME)
swap_buffer(data, size); swap_buffer(data, size);
} }
...@@ -607,7 +601,7 @@ fec_enet_txq_put_data_tso(struct fec_enet_priv_tx_q *txq, struct sk_buff *skb, ...@@ -607,7 +601,7 @@ fec_enet_txq_put_data_tso(struct fec_enet_priv_tx_q *txq, struct sk_buff *skb,
bdp->cbd_bufaddr = addr; bdp->cbd_bufaddr = addr;
if (fep->bufdesc_ex) { if (fep->bufdesc_ex) {
if (id_entry->driver_data & FEC_QUIRK_HAS_AVB) if (fep->quirks & FEC_QUIRK_HAS_AVB)
estatus |= FEC_TX_BD_FTYPE(queue); estatus |= FEC_TX_BD_FTYPE(queue);
if (skb->ip_summed == CHECKSUM_PARTIAL) if (skb->ip_summed == CHECKSUM_PARTIAL)
estatus |= BD_ENET_TX_PINS | BD_ENET_TX_IINS; estatus |= BD_ENET_TX_PINS | BD_ENET_TX_IINS;
...@@ -635,8 +629,6 @@ fec_enet_txq_put_hdr_tso(struct fec_enet_priv_tx_q *txq, ...@@ -635,8 +629,6 @@ fec_enet_txq_put_hdr_tso(struct fec_enet_priv_tx_q *txq,
struct bufdesc *bdp, int index) struct bufdesc *bdp, int index)
{ {
struct fec_enet_private *fep = netdev_priv(ndev); struct fec_enet_private *fep = netdev_priv(ndev);
const struct platform_device_id *id_entry =
platform_get_device_id(fep->pdev);
int hdr_len = skb_transport_offset(skb) + tcp_hdrlen(skb); int hdr_len = skb_transport_offset(skb) + tcp_hdrlen(skb);
struct bufdesc_ex *ebdp = container_of(bdp, struct bufdesc_ex, desc); struct bufdesc_ex *ebdp = container_of(bdp, struct bufdesc_ex, desc);
unsigned short queue = skb_get_queue_mapping(skb); unsigned short queue = skb_get_queue_mapping(skb);
...@@ -652,11 +644,11 @@ fec_enet_txq_put_hdr_tso(struct fec_enet_priv_tx_q *txq, ...@@ -652,11 +644,11 @@ fec_enet_txq_put_hdr_tso(struct fec_enet_priv_tx_q *txq,
bufaddr = txq->tso_hdrs + index * TSO_HEADER_SIZE; bufaddr = txq->tso_hdrs + index * TSO_HEADER_SIZE;
dmabuf = txq->tso_hdrs_dma + index * TSO_HEADER_SIZE; dmabuf = txq->tso_hdrs_dma + index * TSO_HEADER_SIZE;
if (((unsigned long)bufaddr) & fep->tx_align || if (((unsigned long)bufaddr) & fep->tx_align ||
id_entry->driver_data & FEC_QUIRK_SWAP_FRAME) { fep->quirks & FEC_QUIRK_SWAP_FRAME) {
memcpy(txq->tx_bounce[index], skb->data, hdr_len); memcpy(txq->tx_bounce[index], skb->data, hdr_len);
bufaddr = txq->tx_bounce[index]; bufaddr = txq->tx_bounce[index];
if (id_entry->driver_data & FEC_QUIRK_SWAP_FRAME) if (fep->quirks & FEC_QUIRK_SWAP_FRAME)
swap_buffer(bufaddr, hdr_len); swap_buffer(bufaddr, hdr_len);
dmabuf = dma_map_single(&fep->pdev->dev, bufaddr, dmabuf = dma_map_single(&fep->pdev->dev, bufaddr,
...@@ -673,7 +665,7 @@ fec_enet_txq_put_hdr_tso(struct fec_enet_priv_tx_q *txq, ...@@ -673,7 +665,7 @@ fec_enet_txq_put_hdr_tso(struct fec_enet_priv_tx_q *txq,
bdp->cbd_datlen = hdr_len; bdp->cbd_datlen = hdr_len;
if (fep->bufdesc_ex) { if (fep->bufdesc_ex) {
if (id_entry->driver_data & FEC_QUIRK_HAS_AVB) if (fep->quirks & FEC_QUIRK_HAS_AVB)
estatus |= FEC_TX_BD_FTYPE(queue); estatus |= FEC_TX_BD_FTYPE(queue);
if (skb->ip_summed == CHECKSUM_PARTIAL) if (skb->ip_summed == CHECKSUM_PARTIAL)
estatus |= BD_ENET_TX_PINS | BD_ENET_TX_IINS; estatus |= BD_ENET_TX_PINS | BD_ENET_TX_IINS;
...@@ -698,8 +690,6 @@ static int fec_enet_txq_submit_tso(struct fec_enet_priv_tx_q *txq, ...@@ -698,8 +690,6 @@ static int fec_enet_txq_submit_tso(struct fec_enet_priv_tx_q *txq,
struct tso_t tso; struct tso_t tso;
unsigned int index = 0; unsigned int index = 0;
int ret; int ret;
const struct platform_device_id *id_entry =
platform_get_device_id(fep->pdev);
if (tso_count_descs(skb) >= fec_enet_get_free_txdesc_num(fep, txq)) { if (tso_count_descs(skb) >= fec_enet_get_free_txdesc_num(fep, txq)) {
dev_kfree_skb_any(skb); dev_kfree_skb_any(skb);
...@@ -761,7 +751,7 @@ static int fec_enet_txq_submit_tso(struct fec_enet_priv_tx_q *txq, ...@@ -761,7 +751,7 @@ static int fec_enet_txq_submit_tso(struct fec_enet_priv_tx_q *txq,
txq->cur_tx = bdp; txq->cur_tx = bdp;
/* Trigger transmission start */ /* Trigger transmission start */
if (!(id_entry->driver_data & FEC_QUIRK_ERR007885) || if (!(fep->quirks & FEC_QUIRK_ERR007885) ||
!readl(fep->hwp + FEC_X_DES_ACTIVE(queue)) || !readl(fep->hwp + FEC_X_DES_ACTIVE(queue)) ||
!readl(fep->hwp + FEC_X_DES_ACTIVE(queue)) || !readl(fep->hwp + FEC_X_DES_ACTIVE(queue)) ||
!readl(fep->hwp + FEC_X_DES_ACTIVE(queue)) || !readl(fep->hwp + FEC_X_DES_ACTIVE(queue)) ||
...@@ -924,8 +914,6 @@ static void ...@@ -924,8 +914,6 @@ static void
fec_restart(struct net_device *ndev) fec_restart(struct net_device *ndev)
{ {
struct fec_enet_private *fep = netdev_priv(ndev); struct fec_enet_private *fep = netdev_priv(ndev);
const struct platform_device_id *id_entry =
platform_get_device_id(fep->pdev);
u32 val; u32 val;
u32 temp_mac[2]; u32 temp_mac[2];
u32 rcntl = OPT_FRAME_SIZE | 0x04; u32 rcntl = OPT_FRAME_SIZE | 0x04;
...@@ -935,7 +923,7 @@ fec_restart(struct net_device *ndev) ...@@ -935,7 +923,7 @@ fec_restart(struct net_device *ndev)
* For i.MX6SX SOC, enet use AXI bus, we use disable MAC * For i.MX6SX SOC, enet use AXI bus, we use disable MAC
* instead of reset MAC itself. * instead of reset MAC itself.
*/ */
if (id_entry && id_entry->driver_data & FEC_QUIRK_HAS_AVB) { if (fep->quirks & FEC_QUIRK_HAS_AVB) {
writel(0, fep->hwp + FEC_ECNTRL); writel(0, fep->hwp + FEC_ECNTRL);
} else { } else {
writel(1, fep->hwp + FEC_ECNTRL); writel(1, fep->hwp + FEC_ECNTRL);
...@@ -946,7 +934,7 @@ fec_restart(struct net_device *ndev) ...@@ -946,7 +934,7 @@ fec_restart(struct net_device *ndev)
* enet-mac reset will reset mac address registers too, * enet-mac reset will reset mac address registers too,
* so need to reconfigure it. * so need to reconfigure it.
*/ */
if (id_entry->driver_data & FEC_QUIRK_ENET_MAC) { if (fep->quirks & FEC_QUIRK_ENET_MAC) {
memcpy(&temp_mac, ndev->dev_addr, ETH_ALEN); memcpy(&temp_mac, ndev->dev_addr, ETH_ALEN);
writel(cpu_to_be32(temp_mac[0]), fep->hwp + FEC_ADDR_LOW); writel(cpu_to_be32(temp_mac[0]), fep->hwp + FEC_ADDR_LOW);
writel(cpu_to_be32(temp_mac[1]), fep->hwp + FEC_ADDR_HIGH); writel(cpu_to_be32(temp_mac[1]), fep->hwp + FEC_ADDR_HIGH);
...@@ -992,7 +980,7 @@ fec_restart(struct net_device *ndev) ...@@ -992,7 +980,7 @@ fec_restart(struct net_device *ndev)
* The phy interface and speed need to get configured * The phy interface and speed need to get configured
* differently on enet-mac. * differently on enet-mac.
*/ */
if (id_entry->driver_data & FEC_QUIRK_ENET_MAC) { if (fep->quirks & FEC_QUIRK_ENET_MAC) {
/* Enable flow control and length check */ /* Enable flow control and length check */
rcntl |= 0x40000000 | 0x00000020; rcntl |= 0x40000000 | 0x00000020;
...@@ -1015,7 +1003,7 @@ fec_restart(struct net_device *ndev) ...@@ -1015,7 +1003,7 @@ fec_restart(struct net_device *ndev)
} }
} else { } else {
#ifdef FEC_MIIGSK_ENR #ifdef FEC_MIIGSK_ENR
if (id_entry->driver_data & FEC_QUIRK_USE_GASKET) { if (fep->quirks & FEC_QUIRK_USE_GASKET) {
u32 cfgr; u32 cfgr;
/* disable the gasket and wait */ /* disable the gasket and wait */
writel(0, fep->hwp + FEC_MIIGSK_ENR); writel(0, fep->hwp + FEC_MIIGSK_ENR);
...@@ -1068,7 +1056,7 @@ fec_restart(struct net_device *ndev) ...@@ -1068,7 +1056,7 @@ fec_restart(struct net_device *ndev)
writel(0, fep->hwp + FEC_HASH_TABLE_LOW); writel(0, fep->hwp + FEC_HASH_TABLE_LOW);
#endif #endif
if (id_entry->driver_data & FEC_QUIRK_ENET_MAC) { if (fep->quirks & FEC_QUIRK_ENET_MAC) {
/* enable ENET endian swap */ /* enable ENET endian swap */
ecntl |= (1 << 8); ecntl |= (1 << 8);
/* enable ENET store and forward mode */ /* enable ENET store and forward mode */
...@@ -1102,8 +1090,6 @@ static void ...@@ -1102,8 +1090,6 @@ static void
fec_stop(struct net_device *ndev) fec_stop(struct net_device *ndev)
{ {
struct fec_enet_private *fep = netdev_priv(ndev); struct fec_enet_private *fep = netdev_priv(ndev);
const struct platform_device_id *id_entry =
platform_get_device_id(fep->pdev);
u32 rmii_mode = readl(fep->hwp + FEC_R_CNTRL) & (1 << 8); u32 rmii_mode = readl(fep->hwp + FEC_R_CNTRL) & (1 << 8);
/* We cannot expect a graceful transmit stop without link !!! */ /* We cannot expect a graceful transmit stop without link !!! */
...@@ -1118,7 +1104,7 @@ fec_stop(struct net_device *ndev) ...@@ -1118,7 +1104,7 @@ fec_stop(struct net_device *ndev)
* For i.MX6SX SOC, enet use AXI bus, we use disable MAC * For i.MX6SX SOC, enet use AXI bus, we use disable MAC
* instead of reset MAC itself. * instead of reset MAC itself.
*/ */
if (id_entry && id_entry->driver_data & FEC_QUIRK_HAS_AVB) { if (fep->quirks & FEC_QUIRK_HAS_AVB) {
writel(0, fep->hwp + FEC_ECNTRL); writel(0, fep->hwp + FEC_ECNTRL);
} else { } else {
writel(1, fep->hwp + FEC_ECNTRL); writel(1, fep->hwp + FEC_ECNTRL);
...@@ -1128,7 +1114,7 @@ fec_stop(struct net_device *ndev) ...@@ -1128,7 +1114,7 @@ fec_stop(struct net_device *ndev)
writel(FEC_DEFAULT_IMASK, fep->hwp + FEC_IMASK); writel(FEC_DEFAULT_IMASK, fep->hwp + FEC_IMASK);
/* We have to keep ENET enabled to have MII interrupt stay working */ /* We have to keep ENET enabled to have MII interrupt stay working */
if (id_entry->driver_data & FEC_QUIRK_ENET_MAC) { if (fep->quirks & FEC_QUIRK_ENET_MAC) {
writel(2, fep->hwp + FEC_ECNTRL); writel(2, fep->hwp + FEC_ECNTRL);
writel(rmii_mode, fep->hwp + FEC_R_CNTRL); writel(rmii_mode, fep->hwp + FEC_R_CNTRL);
} }
...@@ -1350,8 +1336,6 @@ static int ...@@ -1350,8 +1336,6 @@ static int
fec_enet_rx_queue(struct net_device *ndev, int budget, u16 queue_id) fec_enet_rx_queue(struct net_device *ndev, int budget, u16 queue_id)
{ {
struct fec_enet_private *fep = netdev_priv(ndev); struct fec_enet_private *fep = netdev_priv(ndev);
const struct platform_device_id *id_entry =
platform_get_device_id(fep->pdev);
struct fec_enet_priv_rx_q *rxq; struct fec_enet_priv_rx_q *rxq;
struct bufdesc *bdp; struct bufdesc *bdp;
unsigned short status; unsigned short status;
...@@ -1365,7 +1349,7 @@ fec_enet_rx_queue(struct net_device *ndev, int budget, u16 queue_id) ...@@ -1365,7 +1349,7 @@ fec_enet_rx_queue(struct net_device *ndev, int budget, u16 queue_id)
u16 vlan_tag; u16 vlan_tag;
int index = 0; int index = 0;
bool is_copybreak; bool is_copybreak;
bool need_swap = id_entry->driver_data & FEC_QUIRK_SWAP_FRAME; bool need_swap = fep->quirks & FEC_QUIRK_SWAP_FRAME;
#ifdef CONFIG_M532x #ifdef CONFIG_M532x
flush_cache_all(); flush_cache_all();
...@@ -1880,8 +1864,6 @@ static int fec_enet_clk_enable(struct net_device *ndev, bool enable) ...@@ -1880,8 +1864,6 @@ static int fec_enet_clk_enable(struct net_device *ndev, bool enable)
static int fec_enet_mii_probe(struct net_device *ndev) static int fec_enet_mii_probe(struct net_device *ndev)
{ {
struct fec_enet_private *fep = netdev_priv(ndev); struct fec_enet_private *fep = netdev_priv(ndev);
const struct platform_device_id *id_entry =
platform_get_device_id(fep->pdev);
struct phy_device *phy_dev = NULL; struct phy_device *phy_dev = NULL;
char mdio_bus_id[MII_BUS_ID_SIZE]; char mdio_bus_id[MII_BUS_ID_SIZE];
char phy_name[MII_BUS_ID_SIZE + 3]; char phy_name[MII_BUS_ID_SIZE + 3];
...@@ -1927,7 +1909,7 @@ static int fec_enet_mii_probe(struct net_device *ndev) ...@@ -1927,7 +1909,7 @@ static int fec_enet_mii_probe(struct net_device *ndev)
} }
/* mask with MAC supported features */ /* mask with MAC supported features */
if (id_entry->driver_data & FEC_QUIRK_HAS_GBIT) { if (fep->quirks & FEC_QUIRK_HAS_GBIT) {
phy_dev->supported &= PHY_GBIT_FEATURES; phy_dev->supported &= PHY_GBIT_FEATURES;
phy_dev->supported &= ~SUPPORTED_1000baseT_Half; phy_dev->supported &= ~SUPPORTED_1000baseT_Half;
#if !defined(CONFIG_M5272) #if !defined(CONFIG_M5272)
...@@ -1955,8 +1937,6 @@ static int fec_enet_mii_init(struct platform_device *pdev) ...@@ -1955,8 +1937,6 @@ static int fec_enet_mii_init(struct platform_device *pdev)
static struct mii_bus *fec0_mii_bus; static struct mii_bus *fec0_mii_bus;
struct net_device *ndev = platform_get_drvdata(pdev); struct net_device *ndev = platform_get_drvdata(pdev);
struct fec_enet_private *fep = netdev_priv(ndev); struct fec_enet_private *fep = netdev_priv(ndev);
const struct platform_device_id *id_entry =
platform_get_device_id(fep->pdev);
struct device_node *node; struct device_node *node;
int err = -ENXIO, i; int err = -ENXIO, i;
...@@ -1976,7 +1956,7 @@ static int fec_enet_mii_init(struct platform_device *pdev) ...@@ -1976,7 +1956,7 @@ static int fec_enet_mii_init(struct platform_device *pdev)
* mdio interface in board design, and need to be configured by * mdio interface in board design, and need to be configured by
* fec0 mii_bus. * fec0 mii_bus.
*/ */
if ((id_entry->driver_data & FEC_QUIRK_ENET_MAC) && fep->dev_id > 0) { if ((fep->quirks & FEC_QUIRK_ENET_MAC) && fep->dev_id > 0) {
/* fec1 uses fec0 mii_bus */ /* fec1 uses fec0 mii_bus */
if (mii_cnt && fec0_mii_bus) { if (mii_cnt && fec0_mii_bus) {
fep->mii_bus = fec0_mii_bus; fep->mii_bus = fec0_mii_bus;
...@@ -1997,7 +1977,7 @@ static int fec_enet_mii_init(struct platform_device *pdev) ...@@ -1997,7 +1977,7 @@ static int fec_enet_mii_init(struct platform_device *pdev)
* document. * document.
*/ */
fep->phy_speed = DIV_ROUND_UP(clk_get_rate(fep->clk_ipg), 5000000); fep->phy_speed = DIV_ROUND_UP(clk_get_rate(fep->clk_ipg), 5000000);
if (id_entry->driver_data & FEC_QUIRK_ENET_MAC) if (fep->quirks & FEC_QUIRK_ENET_MAC)
fep->phy_speed--; fep->phy_speed--;
fep->phy_speed <<= 1; fep->phy_speed <<= 1;
writel(fep->phy_speed, fep->hwp + FEC_MII_SPEED); writel(fep->phy_speed, fep->hwp + FEC_MII_SPEED);
...@@ -2039,7 +2019,7 @@ static int fec_enet_mii_init(struct platform_device *pdev) ...@@ -2039,7 +2019,7 @@ static int fec_enet_mii_init(struct platform_device *pdev)
mii_cnt++; mii_cnt++;
/* save fec0 mii_bus */ /* save fec0 mii_bus */
if (id_entry->driver_data & FEC_QUIRK_ENET_MAC) if (fep->quirks & FEC_QUIRK_ENET_MAC)
fec0_mii_bus = fep->mii_bus; fec0_mii_bus = fep->mii_bus;
return 0; return 0;
...@@ -2308,11 +2288,9 @@ static int fec_enet_us_to_itr_clock(struct net_device *ndev, int us) ...@@ -2308,11 +2288,9 @@ static int fec_enet_us_to_itr_clock(struct net_device *ndev, int us)
static void fec_enet_itr_coal_set(struct net_device *ndev) static void fec_enet_itr_coal_set(struct net_device *ndev)
{ {
struct fec_enet_private *fep = netdev_priv(ndev); struct fec_enet_private *fep = netdev_priv(ndev);
const struct platform_device_id *id_entry =
platform_get_device_id(fep->pdev);
int rx_itr, tx_itr; int rx_itr, tx_itr;
if (!(id_entry->driver_data & FEC_QUIRK_HAS_AVB)) if (!(fep->quirks & FEC_QUIRK_HAS_AVB))
return; return;
/* Must be greater than zero to avoid unpredictable behavior */ /* Must be greater than zero to avoid unpredictable behavior */
...@@ -2347,10 +2325,8 @@ static int ...@@ -2347,10 +2325,8 @@ static int
fec_enet_get_coalesce(struct net_device *ndev, struct ethtool_coalesce *ec) fec_enet_get_coalesce(struct net_device *ndev, struct ethtool_coalesce *ec)
{ {
struct fec_enet_private *fep = netdev_priv(ndev); struct fec_enet_private *fep = netdev_priv(ndev);
const struct platform_device_id *id_entry =
platform_get_device_id(fep->pdev);
if (!(id_entry->driver_data & FEC_QUIRK_HAS_AVB)) if (!(fep->quirks & FEC_QUIRK_HAS_AVB))
return -EOPNOTSUPP; return -EOPNOTSUPP;
ec->rx_coalesce_usecs = fep->rx_time_itr; ec->rx_coalesce_usecs = fep->rx_time_itr;
...@@ -2366,12 +2342,9 @@ static int ...@@ -2366,12 +2342,9 @@ static int
fec_enet_set_coalesce(struct net_device *ndev, struct ethtool_coalesce *ec) fec_enet_set_coalesce(struct net_device *ndev, struct ethtool_coalesce *ec)
{ {
struct fec_enet_private *fep = netdev_priv(ndev); struct fec_enet_private *fep = netdev_priv(ndev);
const struct platform_device_id *id_entry =
platform_get_device_id(fep->pdev);
unsigned int cycle; unsigned int cycle;
if (!(id_entry->driver_data & FEC_QUIRK_HAS_AVB)) if (!(fep->quirks & FEC_QUIRK_HAS_AVB))
return -EOPNOTSUPP; return -EOPNOTSUPP;
if (ec->rx_max_coalesced_frames > 255) { if (ec->rx_max_coalesced_frames > 255) {
...@@ -2951,8 +2924,6 @@ static const struct net_device_ops fec_netdev_ops = { ...@@ -2951,8 +2924,6 @@ static const struct net_device_ops fec_netdev_ops = {
static int fec_enet_init(struct net_device *ndev) static int fec_enet_init(struct net_device *ndev)
{ {
struct fec_enet_private *fep = netdev_priv(ndev); struct fec_enet_private *fep = netdev_priv(ndev);
const struct platform_device_id *id_entry =
platform_get_device_id(fep->pdev);
struct fec_enet_priv_tx_q *txq; struct fec_enet_priv_tx_q *txq;
struct fec_enet_priv_rx_q *rxq; struct fec_enet_priv_rx_q *rxq;
struct bufdesc *cbd_base; struct bufdesc *cbd_base;
...@@ -3031,11 +3002,11 @@ static int fec_enet_init(struct net_device *ndev) ...@@ -3031,11 +3002,11 @@ static int fec_enet_init(struct net_device *ndev)
writel(FEC_RX_DISABLED_IMASK, fep->hwp + FEC_IMASK); writel(FEC_RX_DISABLED_IMASK, fep->hwp + FEC_IMASK);
netif_napi_add(ndev, &fep->napi, fec_enet_rx_napi, NAPI_POLL_WEIGHT); netif_napi_add(ndev, &fep->napi, fec_enet_rx_napi, NAPI_POLL_WEIGHT);
if (id_entry->driver_data & FEC_QUIRK_HAS_VLAN) if (fep->quirks & FEC_QUIRK_HAS_VLAN)
/* enable hw VLAN support */ /* enable hw VLAN support */
ndev->features |= NETIF_F_HW_VLAN_CTAG_RX; ndev->features |= NETIF_F_HW_VLAN_CTAG_RX;
if (id_entry->driver_data & FEC_QUIRK_HAS_CSUM) { if (fep->quirks & FEC_QUIRK_HAS_CSUM) {
ndev->gso_max_segs = FEC_MAX_TSO_SEGS; ndev->gso_max_segs = FEC_MAX_TSO_SEGS;
/* enable hw accelerator */ /* enable hw accelerator */
...@@ -3044,7 +3015,7 @@ static int fec_enet_init(struct net_device *ndev) ...@@ -3044,7 +3015,7 @@ static int fec_enet_init(struct net_device *ndev)
fep->csum_flags |= FLAG_RX_CSUM_ENABLED; fep->csum_flags |= FLAG_RX_CSUM_ENABLED;
} }
if (id_entry->driver_data & FEC_QUIRK_HAS_AVB) { if (fep->quirks & FEC_QUIRK_HAS_AVB) {
fep->tx_align = 0; fep->tx_align = 0;
fep->rx_align = 0x3f; fep->rx_align = 0x3f;
} }
...@@ -3144,10 +3115,6 @@ fec_probe(struct platform_device *pdev) ...@@ -3144,10 +3115,6 @@ fec_probe(struct platform_device *pdev)
int num_tx_qs; int num_tx_qs;
int num_rx_qs; int num_rx_qs;
of_id = of_match_device(fec_dt_ids, &pdev->dev);
if (of_id)
pdev->id_entry = of_id->data;
fec_enet_get_queue_num(pdev, &num_tx_qs, &num_rx_qs); fec_enet_get_queue_num(pdev, &num_tx_qs, &num_rx_qs);
/* Init network device */ /* Init network device */
...@@ -3161,13 +3128,17 @@ fec_probe(struct platform_device *pdev) ...@@ -3161,13 +3128,17 @@ fec_probe(struct platform_device *pdev)
/* setup board info structure */ /* setup board info structure */
fep = netdev_priv(ndev); fep = netdev_priv(ndev);
of_id = of_match_device(fec_dt_ids, &pdev->dev);
if (of_id)
pdev->id_entry = of_id->data;
fep->quirks = pdev->id_entry->driver_data;
fep->num_rx_queues = num_rx_qs; fep->num_rx_queues = num_rx_qs;
fep->num_tx_queues = num_tx_qs; fep->num_tx_queues = num_tx_qs;
#if !defined(CONFIG_M5272) #if !defined(CONFIG_M5272)
/* default enable pause frame auto negotiation */ /* default enable pause frame auto negotiation */
if (pdev->id_entry && if (fep->quirks & FEC_QUIRK_HAS_GBIT)
(pdev->id_entry->driver_data & FEC_QUIRK_HAS_GBIT))
fep->pause_flag |= FEC_PAUSE_FLAG_AUTONEG; fep->pause_flag |= FEC_PAUSE_FLAG_AUTONEG;
#endif #endif
...@@ -3236,9 +3207,8 @@ fec_probe(struct platform_device *pdev) ...@@ -3236,9 +3207,8 @@ fec_probe(struct platform_device *pdev)
if (IS_ERR(fep->clk_ref)) if (IS_ERR(fep->clk_ref))
fep->clk_ref = NULL; fep->clk_ref = NULL;
fep->bufdesc_ex = fep->quirks & FEC_QUIRK_HAS_BUFDESC_EX;
fep->clk_ptp = devm_clk_get(&pdev->dev, "ptp"); fep->clk_ptp = devm_clk_get(&pdev->dev, "ptp");
fep->bufdesc_ex =
pdev->id_entry->driver_data & FEC_QUIRK_HAS_BUFDESC_EX;
if (IS_ERR(fep->clk_ptp)) { if (IS_ERR(fep->clk_ptp)) {
fep->clk_ptp = NULL; fep->clk_ptp = NULL;
fep->bufdesc_ex = false; fep->bufdesc_ex = false;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment