Skip to contentSkip to conversation

sh_eth Add SH7619 support

PATCH Applied Yoshinori Sato 5 participants 12 messages Jul 31, 2008 – Aug 7, 2008

Subsystems (3)
lore
Share & tools
lore

Yoshinori Sato

author maintainer
#0 lore raw

PATCH 1/1 sh_eth Add SH7619 support

SH7619 have same SH7710 ethernet controler.
Add support for sh_eth driver.

---
 drivers/net/Kconfig  |    5 +++--
 drivers/net/sh_eth.c |   34 ++++++++++++++++++----------------
 drivers/net/sh_eth.h |   25 +++++++++++++++++++++++--
 3 files changed, 44 insertions(+), 20 deletions(-)
drivers/net/Kconfig +3 -2
index 8a03875..1a6cf24 100644
@@ -510,14 +510,15 @@ config STNIC
 config SH_ETH
 	tristate "Renesas SuperH Ethernet support"
 	depends on SUPERH && \
-		(CPU_SUBTYPE_SH7710 || CPU_SUBTYPE_SH7712 || CPU_SUBTYPE_SH7763)
+		(CPU_SUBTYPE_SH7710 || CPU_SUBTYPE_SH7712 || \
+		 CPU_SUBTYPE_SH7763 || CPU_SUBTYPE_SH7619)
 	select CRC32
 	select MII
 	select MDIO_BITBANG
 	select PHYLIB
 	help
 	  Renesas SuperH Ethernet device driver.
-	  This driver support SH7710, SH7712 and SH7763.
+	  This driver support SH7710, SH7712, SH7763 and SH7619.
 
 config SUNLANCE
 	tristate "Sun LANCE support"
drivers/net/sh_eth.c +18 -14
index 6a06b95..9661e2d 100644
@@ -240,7 +240,7 @@ static void sh_eth_ring_format(struct net_device *ndev)
 		/* RX descriptor */
 		rxdesc = &mdp->rx_ring[i];
 		rxdesc->addr = (u32)skb->data & ~0x3UL;
-		rxdesc->status = cpu_to_le32(RD_RACT | RD_RFP);
+		rxdesc->status = cpu_to_edmac(RD_RACT | RD_RFP);
 
 		/* The size of the buffer is 16 byte boundary. */
 		rxdesc->buffer_length = (mdp->rx_buf_sz + 16) & ~0x0F;
@@ -262,7 +262,7 @@ static void sh_eth_ring_format(struct net_device *ndev)
 	mdp->dirty_rx = (u32) (i - RX_RING_SIZE);
 
 	/* Mark the last entry as wrapping the ring. */
-	rxdesc->status |= cpu_to_le32(RD_RDEL);
+	rxdesc->status |= cpu_to_edmac(RD_RDEL);
 
 	memset(mdp->tx_ring, 0, tx_ringsize);
 
@@ -270,7 +270,7 @@ static void sh_eth_ring_format(struct net_device *ndev)
 	for (i = 0; i < TX_RING_SIZE; i++) {
 		mdp->tx_skbuff[i] = NULL;
 		txdesc = &mdp->tx_ring[i];
-		txdesc->status = cpu_to_le32(TD_TFP);
+		txdesc->status = cpu_to_edmac(TD_TFP);
 		txdesc->buffer_length = 0;
 		if (i = 0) {
 			/* Rx descriptor address set */
@@ -287,7 +287,7 @@ static void sh_eth_ring_format(struct net_device *ndev)
 	ctrl_outl(0x1, ioaddr + TDFFR);
 #endif
 
-	txdesc->status |= cpu_to_le32(TD_TDLE);
+	txdesc->status |= cpu_to_edmac(TD_TDLE);
 }
 
 /* Get skb and descriptor buffer */
@@ -455,7 +455,7 @@ static int sh_eth_txfree(struct net_device *ndev)
 	for (; mdp->cur_tx - mdp->dirty_tx > 0; mdp->dirty_tx++) {
 		entry = mdp->dirty_tx % TX_RING_SIZE;
 		txdesc = &mdp->tx_ring[entry];
-		if (txdesc->status & cpu_to_le32(TD_TACT))
+		if (txdesc->status & cpu_to_edmac(TD_TACT))
 			break;
 		/* Free the original skb. */
 		if (mdp->tx_skbuff[entry]) {
@@ -463,9 +463,9 @@ static int sh_eth_txfree(struct net_device *ndev)
 			mdp->tx_skbuff[entry] = NULL;
 			freeNum++;
 		}
-		txdesc->status = cpu_to_le32(TD_TFP);
+		txdesc->status = cpu_to_edmac(TD_TFP);
 		if (entry >= TX_RING_SIZE - 1)
-			txdesc->status |= cpu_to_le32(TD_TDLE);
+			txdesc->status |= cpu_to_edmac(TD_TDLE);
 
 		mdp->stats.tx_packets++;
 		mdp->stats.tx_bytes += txdesc->buffer_length;
@@ -486,8 +486,8 @@ static int sh_eth_rx(struct net_device *ndev)
 	u32 desc_status, reserve = 0;
 
 	rxdesc = &mdp->rx_ring[entry];
-	while (!(rxdesc->status & cpu_to_le32(RD_RACT))) {
-		desc_status = le32_to_cpu(rxdesc->status);
+	while (!(rxdesc->status & cpu_to_edmac(RD_RACT))) {
+		desc_status = edmac_to_cpu(rxdesc->status);
 		pkt_len = rxdesc->frame_length;
 
 		if (--boguscnt < 0)
@@ -522,7 +522,7 @@ static int sh_eth_rx(struct net_device *ndev)
 			mdp->stats.rx_packets++;
 			mdp->stats.rx_bytes += pkt_len;
 		}
-		rxdesc->status |= cpu_to_le32(RD_RACT);
+		rxdesc->status |= cpu_to_edmac(RD_RACT);
 		entry = (++mdp->cur_rx) % RX_RING_SIZE;
 	}
 
@@ -552,10 +552,10 @@ static int sh_eth_rx(struct net_device *ndev)
 		}
 		if (entry >= RX_RING_SIZE - 1)
 			rxdesc->status |-				cpu_to_le32(RD_RACT | RD_RFP | RD_RDEL);
+				cpu_to_edmac(RD_RACT | RD_RFP | RD_RDEL);
 		else
 			rxdesc->status |-				cpu_to_le32(RD_RACT | RD_RFP);
+				cpu_to_edmac(RD_RACT | RD_RFP);
 	}
 
 	/* Restart Rx engine if stopped. */
@@ -931,9 +931,9 @@ static int sh_eth_start_xmit(struct sk_buff *skb, struct net_device *ndev)
 		txdesc->buffer_length = skb->len;
 
 	if (entry >= TX_RING_SIZE - 1)
-		txdesc->status |= cpu_to_le32(TD_TACT | TD_TDLE);
+		txdesc->status |= cpu_to_edmac(TD_TACT | TD_TDLE);
 	else
-		txdesc->status |= cpu_to_le32(TD_TACT);
+		txdesc->status |= cpu_to_edmac(TD_TACT);
 
 	mdp->cur_tx++;
 
@@ -1217,12 +1217,14 @@ static int sh_eth_drv_probe(struct platform_device *pdev)
 
 	/* First device only init */
 	if (!devno) {
+#if defined(SH_TSU_ADDR)
 		/* reset device */
 		ctrl_outl(ARSTR_ARSTR, ARSTR);
 		mdelay(1);
 
 		/* TSU init (Init only)*/
 		sh_eth_tsu_init(SH_TSU_ADDR);
+#endif
 	}
 
 	/* network device register */
@@ -1240,8 +1242,8 @@ static int sh_eth_drv_probe(struct platform_device *pdev)
 	       ndev->name, CARDNAME, (u32) ndev->base_addr);
 
 	for (i = 0; i < 5; i++)
-		printk(KERN_INFO "%02X:", ndev->dev_addr[i]);
-	printk(KERN_INFO "%02X, IRQ %d.\n", ndev->dev_addr[i], ndev->irq);
+		printk("%02X:", ndev->dev_addr[i]);
+	printk("%02X, IRQ %d.\n", ndev->dev_addr[i], ndev->irq);
 
 	platform_set_drvdata(pdev, ndev);
 
drivers/net/sh_eth.h +23 -2
index 45ad1b0..ca3cc5f 100644
@@ -143,10 +143,11 @@
 
 #else /* CONFIG_CPU_SUBTYPE_SH7763 */
 # define RX_OFFSET 2	/* skb offset */
+#ifndef CONFIG_CPU_SUBTYPE_SH7619
 /* Chip base address */
 # define SH_TSU_ADDR  0xA7000804
 # define ARSTR		  0xA7000800
-
+#endif
 /* Chip Registers */
 /* E-DMAC */
 # define EDMR	0x0000
@@ -384,7 +385,11 @@ enum FCFTR_BIT {
 	FCFTR_RFD1 = 0x00000002, FCFTR_RFD0 = 0x00000001,
 };
 #define FIFO_F_D_RFF	(FCFTR_RFF2|FCFTR_RFF1|FCFTR_RFF0)
+#ifndef CONFIG_CPU_SUBTYPE_SH7619
 #define FIFO_F_D_RFD	(FCFTR_RFD2|FCFTR_RFD1|FCFTR_RFD0)
+#else
+#define FIFO_F_D_RFD	(FCFTR_RFD0)
+#endif
 
 /* Transfer descriptor bit */
 enum TD_STS_BIT {
@@ -411,9 +416,11 @@ enum FELIC_MODE_BIT {
 	ECMR_PRM = 0x00000001,
 };
 
-#ifdef CONFIG_CPU_SUBTYPE_SH7763
+#if defined(CONFIG_CPU_SUBTYPE_SH7763)
 #define ECMR_CHG_DM	(ECMR_TRCCM | ECMR_RZPF | ECMR_ZPF |\
 			ECMR_PFR | ECMR_RXF | ECMR_TXF | ECMR_MCT)
+#elif defined(CONFIG_CPU_SUBTYPE_SH7619)
+#define ECMR_CHG_DM	(ECMR_ZPF | ECMR_PFR ECMR_RXF | ECMR_TXF)
 #else
 #define ECMR_CHG_DM	(ECMR_ZPF | ECMR_PFR ECMR_RXF | ECMR_TXF | ECMR_MCT)
 #endif
@@ -485,7 +492,11 @@ enum RPADIR_BIT {
 
 /* FDR */
 enum FIFO_SIZE_BIT {
+#if defined(CONFIG_CPU_SUBTYPE_SH7619)
+	FIFO_SIZE_T = 0x00000100, FIFO_SIZE_R = 0x00000001,
+#else
 	FIFO_SIZE_T = 0x00000700, FIFO_SIZE_R = 0x00000007,
+#endif
 };
 enum phy_offsets {
 	PHY_CTRL = 0, PHY_STAT = 1, PHY_IDT1 = 2, PHY_IDT2 = 3,
@@ -663,4 +674,14 @@ static void swaps(char *src, int len)
 #endif
 }
 #endif /* CONFIG_CPU_SUBTYPE_SH7763 */
+
+/* CPU endian from/to EDMAC endian */
+#if !defined(CONFIG_CPU_SUBTYPE_SH7619)
+#define cpu_to_edmac(x) cpu_to_le32(x)
+#define edmac_to_cpu(x) le32_to_cpu(x)
+#else
+#define cpu_to_edmac(x) cpu_to_be32(x)
+#define edmac_to_cpu(x) be32_to_cpu(x)
+#endif
+
 #endif
Signature · 5 lines
1.5.6.3

-- 
Yoshinori Sato
<[email protected]>
#1 lore raw

Hi, Sato-san.

2008/8/1 Yoshinori Sato <[email protected]>:

Quoted 5 lines

SH7619 have same SH7710 ethernet controler.
Add support for sh_eth driver.

<snip>

Quoted 7 lines
drivers/net/sh_eth.h +0 -0
index 45ad1b0..ca3cc5f 100644
@@ -143,10 +143,11 @@
 

<snip>

drivers/net/sh_eth.h static void swaps(char *src, int len) · line 687

Quoted 11 lines
drivers/net/sh_eth.h +10 -0
+
+/* CPU endian from/to EDMAC endian */
+#if !defined(CONFIG_CPU_SUBTYPE_SH7619)
+#define cpu_to_edmac(x) cpu_to_le32(x)
+#define edmac_to_cpu(x) le32_to_cpu(x)
+#else
+#define cpu_to_edmac(x) cpu_to_be32(x)
+#define edmac_to_cpu(x) be32_to_cpu(x)
+#endif
+
 #endif

I think that this depends on an endian not CPU dependence.

Best regards,
Nobuhiro

author maintainer
#2 lore raw

At Fri, 1 Aug 2008 12:48:27 +0900,

Quoted 22 lines · Nobuhiro Iwamatsu

Hi, Sato-san.

2008/8/1 Yoshinori Sato <[email protected]>:

Quoted 5 lines

SH7619 have same SH7710 ethernet controler.
Add support for sh_eth driver.

<snip>

Quoted 7 lines
drivers/net/sh_eth.h +0 -0
index 45ad1b0..ca3cc5f 100644
@@ -143,10 +143,11 @@
 

<snip>

Quoted 12 lines

drivers/net/sh_eth.h static void swaps(char *src, int len) · line 687

Quoted 11 lines
drivers/net/sh_eth.h +10 -0
+
+/* CPU endian from/to EDMAC endian */
+#if !defined(CONFIG_CPU_SUBTYPE_SH7619)
+#define cpu_to_edmac(x) cpu_to_le32(x)
+#define edmac_to_cpu(x) le32_to_cpu(x)
+#else
+#define cpu_to_edmac(x) cpu_to_be32(x)
+#define edmac_to_cpu(x) be32_to_cpu(x)
+#endif
+
 #endif

I think that this depends on an endian not CPU dependence.

I agree.
But I'm no idea.
Are you have good idea?

Quoted 2 lines

Best regards,
Nobuhiro

#3 lore raw
Quoted 37 lines · Yoshinori Sato

At Fri, 1 Aug 2008 12:48:27 +0900,

Quoted 22 lines · Nobuhiro Iwamatsu

Hi, Sato-san.

2008/8/1 Yoshinori Sato <[email protected]>:

Quoted 5 lines

SH7619 have same SH7710 ethernet controler.
Add support for sh_eth driver.

<snip>

Quoted 7 lines
drivers/net/sh_eth.h +0 -0
index 45ad1b0..ca3cc5f 100644
@@ -143,10 +143,11 @@
 

<snip>

Quoted 12 lines

drivers/net/sh_eth.h static void swaps(char *src, int len) · line 687

Quoted 11 lines
drivers/net/sh_eth.h +10 -0
+
+/* CPU endian from/to EDMAC endian */
+#if !defined(CONFIG_CPU_SUBTYPE_SH7619)
+#define cpu_to_edmac(x) cpu_to_le32(x)
+#define edmac_to_cpu(x) le32_to_cpu(x)
+#else
+#define cpu_to_edmac(x) cpu_to_be32(x)
+#define edmac_to_cpu(x) be32_to_cpu(x)
+#endif
+
 #endif

I think that this depends on an endian not CPU dependence.

Quoted 3 lines

I agree.
But I'm no idea.
Are you have good idea?

Iwamatsu-san,

what is the difference between CONFIG_CPU_LITTLE_ENDIAN and __LITTLE_ENDIAN__ as used in drivers/net/sh_eth.h ?

author maintainer
#4 lore raw

At Sat, 2 Aug 2008 17:30:22 +1000,

Quoted 39 lines · Simon Horman
Quoted 37 lines · Yoshinori Sato

At Fri, 1 Aug 2008 12:48:27 +0900,

Quoted 34 lines · Nobuhiro Iwamatsu

Hi, Sato-san.

2008/8/1 Yoshinori Sato <[email protected]>:

Quoted 5 lines

SH7619 have same SH7710 ethernet controler.
Add support for sh_eth driver.

<snip>

Quoted 7 lines
drivers/net/sh_eth.h +0 -0
index 45ad1b0..ca3cc5f 100644
@@ -143,10 +143,11 @@
 

<snip>

drivers/net/sh_eth.h static void swaps(char *src, int len) · line 687

Quoted 11 lines
drivers/net/sh_eth.h +10 -0
+
+/* CPU endian from/to EDMAC endian */
+#if !defined(CONFIG_CPU_SUBTYPE_SH7619)
+#define cpu_to_edmac(x) cpu_to_le32(x)
+#define edmac_to_cpu(x) le32_to_cpu(x)
+#else
+#define cpu_to_edmac(x) cpu_to_be32(x)
+#define edmac_to_cpu(x) be32_to_cpu(x)
+#endif
+
 #endif

I think that this depends on an endian not CPU dependence.

Quoted 8 lines
Quoted 3 lines

I agree.
But I'm no idea.
Are you have good idea?

Iwamatsu-san,

what is the difference between CONFIG_CPU_LITTLE_ENDIAN and __LITTLE_ENDIAN__ as used in drivers/net/sh_eth.h ?

EDMAC endian is no depend CPU endian.

Signature · 2 lines
Yoshinori Sato
<[email protected]>
#5 lore raw
Quoted 19 lines · Yoshinori Sato

At Sat, 2 Aug 2008 17:30:22 +1000,

Quoted 17 lines · Simon Horman
Quoted 15 lines · Yoshinori Sato
Quoted 11 lines

drivers/net/sh_eth.h static void swaps(char *src, int len) · line 687

Quoted 10 lines
drivers/net/sh_eth.h +9 -0
+/* CPU endian from/to EDMAC endian */
+#if !defined(CONFIG_CPU_SUBTYPE_SH7619)
+#define cpu_to_edmac(x) cpu_to_le32(x)
+#define edmac_to_cpu(x) le32_to_cpu(x)
+#else
+#define cpu_to_edmac(x) cpu_to_be32(x)
+#define edmac_to_cpu(x) be32_to_cpu(x)
+#endif
+
 #endif

I think that this depends on an endian not CPU dependence.

I agree.
But I'm no idea.
Are you have good idea?

Quoted 7 lines
Quoted 4 lines

Iwamatsu-san,

what is the difference between CONFIG_CPU_LITTLE_ENDIAN and __LITTLE_ENDIAN__ as used in drivers/net/sh_eth.h ?

EDMAC endian is no depend CPU endian.

The cleaner thing to do might just be to introduce a config symbol for specifying whether the EDMAC is in big or little endian mode, depending on how it's wired up in the CPU. Also, you should use a consistent ifdef style. In some cases you only check if 7619 is defined and do your corner cases there, in others (like this one) you check if it is not defined and push its corner cases further down. The latter of which is very error prone.

If the EDMAC endianness can be changed within a given subtype (or hooked up externally), then we also need to making the conversion run-time configurable, and we can toss the endian hint in the platform data.

author maintainer
#6 lore raw

At Mon, 4 Aug 2008 04:23:35 +0900,

Quoted 36 lines · Paul Mundt
Quoted 19 lines · Yoshinori Sato

At Sat, 2 Aug 2008 17:30:22 +1000,

Quoted 17 lines · Simon Horman
Quoted 15 lines · Yoshinori Sato
Quoted 11 lines

drivers/net/sh_eth.h static void swaps(char *src, int len) · line 687

Quoted 10 lines
drivers/net/sh_eth.h +9 -0
+/* CPU endian from/to EDMAC endian */
+#if !defined(CONFIG_CPU_SUBTYPE_SH7619)
+#define cpu_to_edmac(x) cpu_to_le32(x)
+#define edmac_to_cpu(x) le32_to_cpu(x)
+#else
+#define cpu_to_edmac(x) cpu_to_be32(x)
+#define edmac_to_cpu(x) be32_to_cpu(x)
+#endif
+
 #endif

I think that this depends on an endian not CPU dependence.

I agree.
But I'm no idea.
Are you have good idea?

Quoted 7 lines
Quoted 4 lines

Iwamatsu-san,

what is the difference between CONFIG_CPU_LITTLE_ENDIAN and __LITTLE_ENDIAN__ as used in drivers/net/sh_eth.h ?

EDMAC endian is no depend CPU endian.

The cleaner thing to do might just be to introduce a config symbol for specifying whether the EDMAC is in big or little endian mode, depending on how it's wired up in the CPU. Also, you should use a consistent ifdef style. In some cases you only check if 7619 is defined and do your corner cases there, in others (like this one) you check if it is not defined and push its corner cases further down. The latter of which is very error prone.

Quoted 3 lines

If the EDMAC endianness can be changed within a given subtype (or hooked up externally), then we also need to making the conversion run-time configurable, and we can toss the endian hint in the platform data.

I think it's best solution.

example

struct sh_eth_drvadata drvdata {
.phy = 1,
.edmac_endian = EDMAC_LITTLE, /* or EDMAC_BIG */
};

static struct platform_device eth_device = {
:

        .dev = {
                .platform_data = &drvdata,
        },

:
};

It's OK?

Signature · 2 lines
Yoshinori Sato
<[email protected]>
author maintainer
#7 lore raw
In reply to Yoshinori Sato

At Mon, 4 Aug 2008 04:23:35 +0900,

Quoted 36 lines · Paul Mundt
Quoted 19 lines · Yoshinori Sato

At Sat, 2 Aug 2008 17:30:22 +1000,

Quoted 17 lines · Simon Horman
Quoted 15 lines · Yoshinori Sato
Quoted 11 lines

drivers/net/sh_eth.h static void swaps(char *src, int len) · line 687

Quoted 10 lines
drivers/net/sh_eth.h +9 -0
+/* CPU endian from/to EDMAC endian */
+#if !defined(CONFIG_CPU_SUBTYPE_SH7619)
+#define cpu_to_edmac(x) cpu_to_le32(x)
+#define edmac_to_cpu(x) le32_to_cpu(x)
+#else
+#define cpu_to_edmac(x) cpu_to_be32(x)
+#define edmac_to_cpu(x) be32_to_cpu(x)
+#endif
+
 #endif

I think that this depends on an endian not CPU dependence.

I agree.
But I'm no idea.
Are you have good idea?

Quoted 7 lines
Quoted 4 lines

Iwamatsu-san,

what is the difference between CONFIG_CPU_LITTLE_ENDIAN and __LITTLE_ENDIAN__ as used in drivers/net/sh_eth.h ?

EDMAC endian is no depend CPU endian.

The cleaner thing to do might just be to introduce a config symbol for specifying whether the EDMAC is in big or little endian mode, depending on how it's wired up in the CPU. Also, you should use a consistent ifdef style. In some cases you only check if 7619 is defined and do your corner cases there, in others (like this one) you check if it is not defined and push its corner cases further down. The latter of which is very error prone.

Quoted 3 lines

If the EDMAC endianness can be changed within a given subtype (or hooked up externally), then we also need to making the conversion run-time configurable, and we can toss the endian hint in the platform data.

I think it's best solution.

example

struct sh_eth_drvadata drvdata {
.phy = 1,
.edmac_endian = EDMAC_LITTLE, /* or EDMAC_BIG */
};

static struct platform_device eth_device = {
:

        .dev = {
                .platform_data = &drvdata,
        },

:
};

It's OK?

Signature · 2 lines
Yoshinori Sato
<[email protected]>
#8 lore raw
Quoted 33 lines · Yoshinori Sato

At Mon, 4 Aug 2008 04:23:35 +0900,

Quoted 16 lines · Paul Mundt
Quoted 7 lines · Yoshinori Sato

At Sat, 2 Aug 2008 17:30:22 +1000,

Quoted 2 lines · Simon Horman

what is the difference between CONFIG_CPU_LITTLE_ENDIAN and __LITTLE_ENDIAN__ as used in drivers/net/sh_eth.h ?

EDMAC endian is no depend CPU endian.

The cleaner thing to do might just be to introduce a config symbol for specifying whether the EDMAC is in big or little endian mode, depending on how it's wired up in the CPU. Also, you should use a consistent ifdef style. In some cases you only check if 7619 is defined and do your corner cases there, in others (like this one) you check if it is not defined and push its corner cases further down. The latter of which is very error prone.

Quoted 3 lines

If the EDMAC endianness can be changed within a given subtype (or hooked up externally), then we also need to making the conversion run-time configurable, and we can toss the endian hint in the platform data.

I think it's best solution.

example

struct sh_eth_drvadata drvdata {
.phy = 1,
.edmac_endian = EDMAC_LITTLE, /* or EDMAC_BIG */
};

static struct platform_device eth_device = {
:

Quoted 8 lines
        .dev = {
                .platform_data = &drvdata,
        },

:
};

It's OK?

Looks good to me.

#9 lore raw
In reply to Yoshinori Sato

2008/8/6 Yoshinori Sato <[email protected]>:

Quoted 53 lines

At Mon, 4 Aug 2008 04:23:35 +0900,

Quoted 36 lines · Paul Mundt
Quoted 19 lines · Yoshinori Sato

At Sat, 2 Aug 2008 17:30:22 +1000,

Quoted 17 lines · Simon Horman
Quoted 15 lines · Yoshinori Sato
Quoted 11 lines

drivers/net/sh_eth.h static void swaps(char *src, int len) · line 687

Quoted 10 lines
drivers/net/sh_eth.h +9 -0
+/* CPU endian from/to EDMAC endian */
+#if !defined(CONFIG_CPU_SUBTYPE_SH7619)
+#define cpu_to_edmac(x) cpu_to_le32(x)
+#define edmac_to_cpu(x) le32_to_cpu(x)
+#else
+#define cpu_to_edmac(x) cpu_to_be32(x)
+#define edmac_to_cpu(x) be32_to_cpu(x)
+#endif
+
 #endif

I think that this depends on an endian not CPU dependence.

I agree.
But I'm no idea.
Are you have good idea?

Quoted 7 lines
Quoted 4 lines

Iwamatsu-san,

what is the difference between CONFIG_CPU_LITTLE_ENDIAN and __LITTLE_ENDIAN__ as used in drivers/net/sh_eth.h ?

EDMAC endian is no depend CPU endian.

The cleaner thing to do might just be to introduce a config symbol for specifying whether the EDMAC is in big or little endian mode, depending on how it's wired up in the CPU. Also, you should use a consistent ifdef style. In some cases you only check if 7619 is defined and do your corner cases there, in others (like this one) you check if it is not defined and push its corner cases further down. The latter of which is very error prone.

Quoted 3 lines

If the EDMAC endianness can be changed within a given subtype (or hooked up externally), then we also need to making the conversion run-time configurable, and we can toss the endian hint in the platform data.

I think it's best solution.

example

struct sh_eth_drvadata drvdata {
.phy = 1,
.edmac_endian = EDMAC_LITTLE, /* or EDMAC_BIG */
};

static struct platform_device eth_device = {
:

Quoted 7 lines
       .dev = {
               .platform_data = &drvdata,
       },

:
};

It's OK?

Looks good.
Please resend patch.

Best regards,
Nobuhiro

author maintainer
#10 lore raw

Re: [PATCH 1/2] sh_eth Add SH7619 support (driver)

Add support SH7619 Internal ethernet controler.

 arch/sh/include/asm/sh_eth.h |   11 +++++++
 drivers/net/Kconfig          |    5 ++-
 drivers/net/sh_eth.c         |   69 ++++++++++++++++++++++++++++++-----------
 drivers/net/sh_eth.h         |   22 +++++++++++--
 4 files changed, 82 insertions(+), 25 deletions(-)
 create mode 100644 arch/sh/include/asm/sh_eth.h
arch/sh/include/asm/sh_eth.h new file +11 -0
new file mode 100644
index 0000000..bb83258
@@ -0,0 +1,11 @@
+#ifndef __ASM_SH_ETH_H__
+#define __ASM_SH_ETH_H__
+
+enum {EDMAC_LITTLE_ENDIAN, EDMAC_BIG_ENDIAN};
+
+struct sh_eth_plat_data {
+	int phy;
+	int edmac_endian;
+};
+
+#endif
drivers/net/Kconfig +3 -2
index 8a03875..4b4cb2b 100644
@@ -510,14 +510,15 @@ config STNIC
 config SH_ETH
 	tristate "Renesas SuperH Ethernet support"
 	depends on SUPERH && \
-		(CPU_SUBTYPE_SH7710 || CPU_SUBTYPE_SH7712 || CPU_SUBTYPE_SH7763)
+		(CPU_SUBTYPE_SH7710 || CPU_SUBTYPE_SH7712 || CPU_SUBTYPE_SH7763 || \
+		 CPU_SUBTYPE_SH7619)
 	select CRC32
 	select MII
 	select MDIO_BITBANG
 	select PHYLIB
 	help
 	  Renesas SuperH Ethernet device driver.
-	  This driver support SH7710, SH7712 and SH7763.
+	  This driver support SH7710, SH7712, SH7763 and SH7619.
 
 config SUNLANCE
 	tristate "Sun LANCE support"
drivers/net/sh_eth.c +50 -17

175 lines not on this page · raw message

drivers/net/sh_eth.h +18 -4
index 45ad1b0..73bc718 100644
@@ -30,6 +30,8 @@
 #include <linux/netdevice.h>
 #include <linux/phy.h>
 
+#include <asm/sh_eth.h>
+
 #define CARDNAME	"sh-eth"
 #define TX_TIMEOUT	(5*HZ)
 #define TX_RING_SIZE	64	/* Tx ring size */
@@ -143,10 +145,11 @@
 
 #else /* CONFIG_CPU_SUBTYPE_SH7763 */
 # define RX_OFFSET 2	/* skb offset */
+#ifndef CONFIG_CPU_SUBTYPE_SH7619
 /* Chip base address */
 # define SH_TSU_ADDR  0xA7000804
 # define ARSTR		  0xA7000800
-
+#endif
 /* Chip Registers */
 /* E-DMAC */
 # define EDMR	0x0000
@@ -384,7 +387,11 @@ enum FCFTR_BIT {
 	FCFTR_RFD1 = 0x00000002, FCFTR_RFD0 = 0x00000001,
 };
 #define FIFO_F_D_RFF	(FCFTR_RFF2|FCFTR_RFF1|FCFTR_RFF0)
+#ifndef CONFIG_CPU_SUBTYPE_SH7619
 #define FIFO_F_D_RFD	(FCFTR_RFD2|FCFTR_RFD1|FCFTR_RFD0)
+#else
+#define FIFO_F_D_RFD	(FCFTR_RFD0)
+#endif
 
 /* Transfer descriptor bit */
 enum TD_STS_BIT {
@@ -414,8 +421,10 @@ enum FELIC_MODE_BIT {
 #ifdef CONFIG_CPU_SUBTYPE_SH7763
 #define ECMR_CHG_DM	(ECMR_TRCCM | ECMR_RZPF | ECMR_ZPF |\
 			ECMR_PFR | ECMR_RXF | ECMR_TXF | ECMR_MCT)
+#elif CONFIG_CPU_SUBTYPE_SH7619
+#define ECMR_CHG_DM	(ECMR_ZPF | ECMR_PFR | ECMR_RXF | ECMR_TXF)
 #else
-#define ECMR_CHG_DM	(ECMR_ZPF | ECMR_PFR ECMR_RXF | ECMR_TXF | ECMR_MCT)
+#define ECMR_CHG_DM	(ECMR_ZPF | ECMR_PFR | ECMR_RXF | ECMR_TXF | ECMR_MCT)
 #endif
 
 /* ECSR */
@@ -485,7 +494,11 @@ enum RPADIR_BIT {
 
 /* FDR */
 enum FIFO_SIZE_BIT {
+#ifndef CONFIG_CPU_SUBTYPE_SH7619
 	FIFO_SIZE_T = 0x00000700, FIFO_SIZE_R = 0x00000007,
+#else
+	FIFO_SIZE_T = 0x00000100, FIFO_SIZE_R = 0x00000001,
+#endif
 };
 enum phy_offsets {
 	PHY_CTRL = 0, PHY_STAT = 1, PHY_IDT1 = 2, PHY_IDT2 = 3,
@@ -601,7 +614,7 @@ struct sh_eth_txdesc {
 #endif
 	u32 addr;		/* TD2 */
 	u32 pad1;		/* padding data */
-};
+} __attribute__((aligned(2), packed));
 
 /*
  * The sh ether Rx buffer descriptors.
@@ -618,7 +631,7 @@ struct sh_eth_rxdesc {
 #endif
 	u32 addr;		/* RD2 */
 	u32 pad0;		/* padding data */
-};
+} __attribute__((aligned(2), packed));
 
 struct sh_eth_private {
 	dma_addr_t rx_desc_dma;
@@ -633,6 +646,7 @@ struct sh_eth_private {
 	u32 cur_rx, dirty_rx;	/* Producer/consumer ring indices */
 	u32 cur_tx, dirty_tx;
 	u32 rx_buf_sz;		/* Based on MTU+slack. */
+	int edmac_endian;
 	/* MII transceiver section. */
 	u32 phy_id;					/* PHY ID */
 	struct mii_bus *mii_bus;	/* MDIO bus control */
Signature · 5 lines
1.5.6.3

-- 
Yoshinori Sato
<[email protected]>
Applied
#11 lore raw

Re: [PATCH 1/2] sh_eth Add SH7619 support (driver)

Quoted 8 lines · Yoshinori Sato

Add support SH7619 Internal ethernet controler.

 arch/sh/include/asm/sh_eth.h |   11 +++++++
 drivers/net/Kconfig          |    5 ++-
 drivers/net/sh_eth.c         |   69 ++++++++++++++++++++++++++++++-----------
 drivers/net/sh_eth.h         |   22 +++++++++++--
 4 files changed, 82 insertions(+), 25 deletions(-)
 create mode 100644 arch/sh/include/asm/sh_eth.h

applied