net: emaclite: fixes and enable for MIPS
Subsystems (2)
cover net: emaclite: fixes and enable for MIPS
Hi,
This patch series changes the emaclite driver to be slightly more generic and then enables it for the MIPS arch.
Regards,
ZubairLK
Zubair Lutfullah Kakakhel (3):
net: emaclite: Use ioremap_nocache
net: emaclite: use __raw_readl/writel instead of weird define
net: emaclite: Enable driver for MIPS
drivers/net/Kconfig | 2 +- drivers/net/xilinx_emaclite.c | 90 +++++++++++++++++++++++-------------------- 2 files changed, 49 insertions(+), 43 deletions(-)
Signature · 1 line
1.9.1
PATCH 1/3 net: emaclite: Use ioremap_nocache
Virtual to physical mapping isn't necessarily 1:1 for all architectures
Using ioremap_nocache allows for the arch code to translate the physical address to a virtual address.
--- drivers/net/xilinx_emaclite.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/net/xilinx_emaclite.c +3 -1
@@ -19,6 +19,7 @@#include <fdtdec.h> #include <asm-generic/errno.h> #include <linux/kernel.h> +#include <asm/io.h> DECLARE_GLOBAL_DATA_PTR ;
@@ -595,7 +596,8 @@ static int emaclite_ofdata_to_platdata(struct udevice *dev)int offset =0 ; pdata->iobase = (phys_addr_t )dev_get_addr (dev); - emaclite->regs = (struct emaclite_regs *)pdata->iobase; + emaclite->regs = (struct emaclite_regs *)ioremap_nocache (pdata->iobase, +0x10000 ); emaclite->phyaddr =-1 ;
Signature · 1 line
1.9.1
PATCH 1/3 net: emaclite: Use ioremap_nocache
Am 27.07.2016 um 13:25 schrieb Zubair Lutfullah Kakakhel:
Quoted 7 lines
Virtual to physical mapping isn't necessarily 1:1 for all architectures
Using
ioremap_nocacheallows for the arch code to translate the physical address to a virtual address.Signed-off-by Zubair Lutfullah Kakakhel <[email protected]>Reviewed-by Paul Burton <[email protected]>
looks okay because this driver is only used by Microblaze which has ioremap_nocache() defined.
Quoted 27 lines
--- drivers/net/xilinx_emaclite.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)drivers/net/xilinx_emaclite.c +3
-1@@ -19,6 +19,7 @@#include <fdtdec.h> #include <asm-generic/errno.h> #include <linux/kernel.h> +#include <asm/io.h> DECLARE_GLOBAL_DATA_PTR ;@@ -595,7 +596,8 @@ static int emaclite_ofdata_to_platdata(struct udevice *dev)int offset =0 ; pdata->iobase = (phys_addr_t )dev_get_addr (dev); - emaclite->regs = (struct emaclite_regs *)pdata->iobase; + emaclite->regs = (struct emaclite_regs *)ioremap_nocache (pdata->iobase, +0x10000 ); emaclite->phyaddr =-1 ;
Signature · 9 lines
- Daniel -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 473 bytes Desc: OpenPGP digital signature URL: <http://lists.denx.de/pipermail/u-boot/attachments/20160727/c9a86e77/attachment.sig>
PATCH 1/3 net: emaclite: Use ioremap_nocache
Quoted 8 lines · Daniel Schwierzeck
Am 27.07.2016 um 13:25 schrieb Zubair Lutfullah Kakakhel:
Quoted 5 lines
Virtual to physical mapping isn't necessarily 1:1 for all architectures
Using
ioremap_nocacheallows for the arch code to translate the physical address to a virtual address.
Quoted 7 lines
Quoted 2 lines
Signed-off-by Zubair Lutfullah Kakakhel <[email protected]>Reviewed-by Paul Burton <[email protected]>looks okay because this driver is only used by Microblaze which has
ioremap_nocache()defined.Reviewed-by Daniel Schwierzeck <[email protected]>
First of all please keep me in CC for all these xilinx drivers changes.
This driver is enabled only for Microblaze but can be also used for ARM and ARM64.
Thanks,
Michal
PATCH 1/3 net: emaclite: Use ioremap_nocache
In reply to Zubair Lutfullah KakakhelQuoted 7 lines · Zubair Lutfullah Kakakhel
Virtual to physical mapping isn't necessarily 1:1 for all architectures
Using
ioremap_nocacheallows for the arch code to translate the physical address to a virtual address.Signed-off-by Zubair Lutfullah Kakakhel <[email protected]>Reviewed-by Paul Burton <[email protected]>
PATCH 1/3 net: emaclite: Use ioremap_nocache
In reply to Zubair Lutfullah KakakhelAm 27.07.2016 um 13:25 schrieb Zubair Lutfullah Kakakhel:
Quoted 11 lines
Virtual to physical mapping isn't necessarily 1:1 for all architectures
Using
ioremap_nocacheallows for the arch code to translate the physical address to a virtual address.Signed-off-by Zubair Lutfullah Kakakhel <[email protected]>Reviewed-by Paul Burton <[email protected]>--- drivers/net/xilinx_emaclite.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
applied to u-boot-mips/next, thanks
Signature · 9 lines
- Daniel -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 473 bytes Desc: OpenPGP digital signature URL: <http://lists.denx.de/pipermail/u-boot/attachments/20160731/ce8cf3ba/attachment.sig>
PATCH 2/3 net: emaclite: use __raw_readl/writel instead of weird define
In reply to Zubair Lutfullah Kakakhelout_be32 and in_be32 are actually #defined to little endian writel/readl in arch/microblaze.
Just use __raw_writel/readl instead. That is also what is used in the Linux kernel driver for this IP block
Tested on MIPSfpga. Can tftp a kernel.
--- drivers/net/xilinx_emaclite.c | 86 ++++++++++++++++++++++--------------------- 1 file changed, 45 insertions(+), 41 deletions(-)
drivers/net/xilinx_emaclite.c +45 -41
@@ -155,7 +155,7 @@ static int wait_for_bit(const char *func, u32 *reg, const u32 mask,unsigned long start =get_timer (0 );while (1 ) { - val =readl (reg); + val =__raw_readl (reg);if (!set) val = ~val;
@@ -194,16 +194,17 @@ static u32 phyread(struct xemaclite *emaclite, u32 phyaddress, u32 registernum,if (mdio_wait (regs))return 1 ; -u32 ctrl_reg =in_be32 (®s->mdioctrl); -out_be32 (®s->mdioaddr,XEL_MDIOADDR_OP_MASK | - ((phyaddress <<XEL_MDIOADDR_PHYADR_SHIFT ) | registernum)); -out_be32 (®s->mdioctrl, ctrl_reg |XEL_MDIOCTRL_MDIOSTS_MASK ); +u32 ctrl_reg =__raw_readl (®s->mdioctrl); +__raw_writel (XEL_MDIOADDR_OP_MASK + | ((phyaddress <<XEL_MDIOADDR_PHYADR_SHIFT ) + | registernum), ®s->mdioaddr); +__raw_writel (ctrl_reg |XEL_MDIOCTRL_MDIOSTS_MASK , ®s->mdioctrl);if (mdio_wait (regs))return 1 ;/* Read data */ - *data =in_be32 (®s->mdiord); + *data =__raw_readl (®s->mdiord);return 0 ; }
@@ -221,11 +222,12 @@ static u32 phywrite(struct xemaclite *emaclite, u32 phyaddress, u32 registernum,* Data register. Finally, set the Status bit in the MDIO Control * register to start a MDIO write transaction. */ -u32 ctrl_reg =in_be32 (®s->mdioctrl); -out_be32 (®s->mdioaddr, ~XEL_MDIOADDR_OP_MASK & - ((phyaddress <<XEL_MDIOADDR_PHYADR_SHIFT ) | registernum)); -out_be32 (®s->mdiowr, data); -out_be32 (®s->mdioctrl, ctrl_reg |XEL_MDIOCTRL_MDIOSTS_MASK ); +u32 ctrl_reg =__raw_readl (®s->mdioctrl); +__raw_writel (~XEL_MDIOADDR_OP_MASK + & ((phyaddress <<XEL_MDIOADDR_PHYADR_SHIFT ) + | registernum), ®s->mdioaddr); +__raw_writel (data, ®s->mdiowr); +__raw_writel (ctrl_reg |XEL_MDIOCTRL_MDIOSTS_MASK , ®s->mdioctrl);if (mdio_wait (regs))return 1 ;
@@ -328,27 +330,27 @@ static int emaclite_start(struct udevice *dev)* TX - TX_PING & TX_PONG initialization */ /* Restart PING TX */ -out_be32 (®s->tx_ping_tsr,0 ); +__raw_writel (0 , ®s->tx_ping_tsr);/* Copy MAC address */ xemaclite_alignedwrite (pdata->enetaddr, ®s->tx_ping,ENET_ADDR_LENGTH );/* Set the length */ -out_be32 (®s->tx_ping_tplr,ENET_ADDR_LENGTH ); +__raw_writel (ENET_ADDR_LENGTH , ®s->tx_ping_tplr);/* Update the MAC address in the EMAC Lite */ -out_be32 (®s->tx_ping_tsr,XEL_TSR_PROG_MAC_ADDR ); +__raw_writel (XEL_TSR_PROG_MAC_ADDR , ®s->tx_ping_tsr);/* Wait for EMAC Lite to finish with the MAC address update */ -while ((in_be32 (®s->tx_ping_tsr) & +while ((__raw_readl (®s->tx_ping_tsr) &XEL_TSR_PROG_MAC_ADDR ) !=0 ) ;if (emaclite->txpp) {/* The same operation with PONG TX */ -out_be32 (®s->tx_pong_tsr,0 ); +__raw_writel (0 , ®s->tx_pong_tsr);xemaclite_alignedwrite (pdata->enetaddr, ®s->tx_pong,ENET_ADDR_LENGTH ); -out_be32 (®s->tx_pong_tplr,ENET_ADDR_LENGTH ); -out_be32 (®s->tx_pong_tsr,XEL_TSR_PROG_MAC_ADDR ); -while ((in_be32 (®s->tx_pong_tsr) & +__raw_writel (ENET_ADDR_LENGTH , ®s->tx_pong_tplr); +__raw_writel (XEL_TSR_PROG_MAC_ADDR , ®s->tx_pong_tsr); +while ((__raw_readl (®s->tx_pong_tsr) &XEL_TSR_PROG_MAC_ADDR ) !=0 ) ; }
@@ -357,13 +359,13 @@ static int emaclite_start(struct udevice *dev)* RX - RX_PING & RX_PONG initialization */ /* Write out the value to flush the RX buffer */ -out_be32 (®s->rx_ping_rsr,XEL_RSR_RECV_IE_MASK ); +__raw_writel (XEL_RSR_RECV_IE_MASK , ®s->rx_ping_rsr);if (emaclite->rxpp) -out_be32 (®s->rx_pong_rsr,XEL_RSR_RECV_IE_MASK ); +__raw_writel (XEL_RSR_RECV_IE_MASK , ®s->rx_pong_rsr); -out_be32 (®s->mdioctrl,XEL_MDIOCTRL_MDIOEN_MASK ); -if (in_be32 (®s->mdioctrl) &XEL_MDIOCTRL_MDIOEN_MASK ) +__raw_writel (XEL_MDIOCTRL_MDIOEN_MASK , ®s->mdioctrl); +if (__raw_readl (®s->mdioctrl) &XEL_MDIOCTRL_MDIOEN_MASK )if (!setup_phy (dev))return -1 ;
@@ -380,9 +382,9 @@ static int xemaclite_txbufferavailable(struct xemaclite *emaclite)* Read the other buffer register * and determine if the other buffer is available */ - tmp = ~in_be32 (®s->tx_ping_tsr); + tmp = ~__raw_readl (®s->tx_ping_tsr);if (emaclite->txpp) - tmp |= ~in_be32 (®s->tx_pong_tsr); + tmp |= ~__raw_readl (®s->tx_pong_tsr);return !(tmp &XEL_TSR_XMIT_BUSY_MASK ); }
@@ -406,40 +408,42 @@ static int emaclite_send(struct udevice *dev, void *ptr, int len)if (!maxtry) {printf ("Error: Timeout waiting for ethernet TX buffer\n" );/* Restart PING TX */ -out_be32 (®s->tx_ping_tsr,0 ); +__raw_writel (0 , ®s->tx_ping_tsr);if (emaclite->txpp) { -out_be32 (®s->tx_pong_tsr,0 ); +__raw_writel (0 , ®s->tx_pong_tsr); }return -1 ; }/* Determine if the expected buffer address is empty */ - reg =in_be32 (®s->tx_ping_tsr); + reg =__raw_readl (®s->tx_ping_tsr);if ((reg &XEL_TSR_XMIT_BUSY_MASK ) ==0 ) {debug ("Send packet from tx_ping buffer\n" );/* Write the frame to the buffer */ xemaclite_alignedwrite (ptr, ®s->tx_ping, len); -out_be32 (®s->tx_ping_tplr, len & - (XEL_TPLR_LENGTH_MASK_HI |XEL_TPLR_LENGTH_MASK_LO )); - reg =in_be32 (®s->tx_ping_tsr); +__raw_writel (len + & (XEL_TPLR_LENGTH_MASK_HI |XEL_TPLR_LENGTH_MASK_LO ), + ®s->tx_ping_tplr); + reg =__raw_readl (®s->tx_ping_tsr); reg |=XEL_TSR_XMIT_BUSY_MASK ; -out_be32 (®s->tx_ping_tsr, reg); +__raw_writel (reg, ®s->tx_ping_tsr);return 0 ; }if (emaclite->txpp) {/* Determine if the expected buffer address is empty */ - reg =in_be32 (®s->tx_pong_tsr); + reg =__raw_readl (®s->tx_pong_tsr);if ((reg &XEL_TSR_XMIT_BUSY_MASK ) ==0 ) {debug ("Send packet from tx_pong buffer\n" );/* Write the frame to the buffer */ xemaclite_alignedwrite (ptr, ®s->tx_pong, len); -out_be32 (®s->tx_pong_tplr, len & +__raw_writel (len & (XEL_TPLR_LENGTH_MASK_HI | -XEL_TPLR_LENGTH_MASK_LO )); - reg =in_be32 (®s->tx_pong_tsr); +XEL_TPLR_LENGTH_MASK_LO ), + ®s->tx_pong_tplr); + reg =__raw_readl (®s->tx_pong_tsr); reg |=XEL_TSR_XMIT_BUSY_MASK ; -out_be32 (®s->tx_pong_tsr, reg); +__raw_writel (reg, ®s->tx_pong_tsr);return 0 ; } }
@@ -459,7 +463,7 @@ static int emaclite_recv(struct udevice *dev, int flags, uchar **packetp) try_again:if (!emaclite->use_rx_pong_buffer_next) { - reg =in_be32 (®s->rx_ping_rsr); + reg =__raw_readl (®s->rx_ping_rsr);debug ("Testing data at rx_ping\n" );if ((reg &XEL_RSR_RECV_DONE_MASK ) ==XEL_RSR_RECV_DONE_MASK ) {debug ("Data found in rx_ping buffer\n" );
@@ -479,7 +483,7 @@ try_again: goto try_again; } }else { - reg =in_be32 (®s->rx_pong_rsr); + reg =__raw_readl (®s->rx_pong_rsr);debug ("Testing data at rx_pong\n" );if ((reg &XEL_RSR_RECV_DONE_MASK ) ==XEL_RSR_RECV_DONE_MASK ) {debug ("Data found in rx_pong buffer\n" );
@@ -526,9 +530,9 @@ try_again: length - first_read);/* Acknowledge the frame */ - reg =in_be32 (ack); + reg =__raw_readl (ack); reg &= ~XEL_RSR_RECV_DONE_MASK ; -out_be32 (ack, reg); +__raw_writel (reg, ack);debug ("Packet receive from 0x%p, length %dB\n" , addr, length); *packetp = etherrxbuff;
Signature · 1 line
1.9.1
PATCH 2/3 net: emaclite: use __raw_readl/writel instead of weird define
Quoted 10 lines · Zubair Lutfullah Kakakhel
out_be32andin_be32are actually #defined to little endian writel/readl inarch/microblaze.Just use __raw_writel/readl instead. That is also what is used in the Linux kernel driver for this IP block
Tested on MIPSfpga. Can tftp a kernel.
Signed-off-by Zubair Lutfullah Kakakhel <[email protected]>Reviewed-by Paul Burton <[email protected]>
PATCH 2/3 net: emaclite: use __raw_readl/writel instead of weird define
In reply to Zubair Lutfullah KakakhelAm 27.07.2016 um 13:25 schrieb Zubair Lutfullah Kakakhel:
Quoted 6 lines
out_be32andin_be32are actually #defined to little endian writel/readl inarch/microblaze.Just use __raw_writel/readl instead. That is also what is used in the Linux kernel driver for this IP block
Quoted 8 lines
Tested on MIPSfpga. Can tftp a kernel.
Signed-off-by Zubair Lutfullah Kakakhel <[email protected]>Reviewed-by Paul Burton <[email protected]>--- drivers/net/xilinx_emaclite.c | 86 ++++++++++++++++++++++--------------------- 1 file changed, 45 insertions(+), 41 deletions(-)
applied to u-boot-mips/next, thanks
Signature · 9 lines
- Daniel -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 473 bytes Desc: OpenPGP digital signature URL: <http://lists.denx.de/pipermail/u-boot/attachments/20160731/2934e927/attachment.sig>
PATCH 3/3 net: emaclite: Enable driver for MIPS
In reply to Zubair Lutfullah Kakakhel--- drivers/net/Kconfig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/Kconfig +1 -1
@@ -170,7 +170,7 @@ config XILINX_AXIEMAC This MAC is present in Xilinx Microblaze, Zynq and ZynqMP SoCs. config XILINX_EMACLITE - depends on DM_ETH && (MICROBLAZE || ARCH_ZYNQ || ARCH_ZYNQMP) + depends on DM_ETH && (MICROBLAZE || ARCH_ZYNQ || ARCH_ZYNQMP || MIPS) select PHYLIB select MII bool "Xilinx Ethernetlite"
Signature · 1 line
1.9.1
PATCH 3/3 net: emaclite: Enable driver for MIPS
Quoted 2 lines · Zubair Lutfullah Kakakhel
Signed-off-by Zubair Lutfullah Kakakhel <[email protected]>Reviewed-by Paul Burton <[email protected]>
PATCH 3/3 net: emaclite: Enable driver for MIPS
In reply to Zubair Lutfullah KakakhelAm 27.07.2016 um 13:25 schrieb Zubair Lutfullah Kakakhel:
Quoted 6 lines
Signed-off-by Zubair Lutfullah Kakakhel <[email protected]>Reviewed-by Paul Burton <[email protected]>--- drivers/net/Kconfig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
applied to u-boot-mips/next, thanks
Signature · 9 lines
- Daniel -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 473 bytes Desc: OpenPGP digital signature URL: <http://lists.denx.de/pipermail/u-boot/attachments/20160731/98459c88/attachment.sig>