* [PATCH] sh_eth Add SH7619 support
@ 2008-07-31 23:35 Yoshinori Sato
2008-08-01 3:48 ` Nobuhiro Iwamatsu
0 siblings, 1 reply; 11+ messages in thread
From: Yoshinori Sato @ 2008-07-31 23:35 UTC (permalink / raw)
To: Jeff Garzik, Nobuhiro Iwamatsu; +Cc: netdev, linux-sh
SH7619 have same SH7710 ethernet controler.
Add support for sh_eth driver.
Signed-off-by: Yoshinori Sato <ysato@users.sourceforge.jp>
---
drivers/net/Kconfig | 5 +++--
drivers/net/sh_eth.c | 34 ++++++++++++++++++----------------
drivers/net/sh_eth.h | 25 +++++++++++++++++++++++--
3 files changed, 44 insertions(+), 20 deletions(-)
diff --git a/drivers/net/Kconfig b/drivers/net/Kconfig
index 8a03875..1a6cf24 100644
--- a/drivers/net/Kconfig
+++ b/drivers/net/Kconfig
@@ -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"
diff --git a/drivers/net/sh_eth.c b/drivers/net/sh_eth.c
index 6a06b95..9661e2d 100644
--- a/drivers/net/sh_eth.c
+++ b/drivers/net/sh_eth.c
@@ -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);
diff --git a/drivers/net/sh_eth.h b/drivers/net/sh_eth.h
index 45ad1b0..ca3cc5f 100644
--- a/drivers/net/sh_eth.h
+++ b/drivers/net/sh_eth.h
@@ -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
--
1.5.6.3
--
Yoshinori Sato
<ysato@users.sourceforge.jp>
^ permalink raw reply related [flat|nested] 11+ messages in thread
* Re: [PATCH] sh_eth Add SH7619 support
2008-07-31 23:35 [PATCH] sh_eth Add SH7619 support Yoshinori Sato
@ 2008-08-01 3:48 ` Nobuhiro Iwamatsu
2008-08-01 15:32 ` Yoshinori Sato
0 siblings, 1 reply; 11+ messages in thread
From: Nobuhiro Iwamatsu @ 2008-08-01 3:48 UTC (permalink / raw)
To: Yoshinori Sato; +Cc: Jeff Garzik, Nobuhiro Iwamatsu, netdev, linux-sh
Hi, Sato-san.
2008/8/1 Yoshinori Sato <ysato@users.sourceforge.jp>:
> SH7619 have same SH7710 ethernet controler.
> Add support for sh_eth driver.
>
> Signed-off-by: Yoshinori Sato <ysato@users.sourceforge.jp>
>
<snip>
>
> diff --git a/drivers/net/sh_eth.h b/drivers/net/sh_eth.h
> index 45ad1b0..ca3cc5f 100644
> --- a/drivers/net/sh_eth.h
> +++ b/drivers/net/sh_eth.h
> @@ -143,10 +143,11 @@
>
<snip>
> +
> +/* 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
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH] sh_eth Add SH7619 support
2008-08-01 3:48 ` Nobuhiro Iwamatsu
@ 2008-08-01 15:32 ` Yoshinori Sato
2008-08-02 7:30 ` Simon Horman
0 siblings, 1 reply; 11+ messages in thread
From: Yoshinori Sato @ 2008-08-01 15:32 UTC (permalink / raw)
To: Nobuhiro Iwamatsu; +Cc: Jeff Garzik, Nobuhiro Iwamatsu, netdev, linux-sh
At Fri, 1 Aug 2008 12:48:27 +0900,
Nobuhiro Iwamatsu wrote:
>
> Hi, Sato-san.
>
> 2008/8/1 Yoshinori Sato <ysato@users.sourceforge.jp>:
> > SH7619 have same SH7710 ethernet controler.
> > Add support for sh_eth driver.
> >
> > Signed-off-by: Yoshinori Sato <ysato@users.sourceforge.jp>
> >
>
> <snip>
>
> >
> > diff --git a/drivers/net/sh_eth.h b/drivers/net/sh_eth.h
> > index 45ad1b0..ca3cc5f 100644
> > --- a/drivers/net/sh_eth.h
> > +++ b/drivers/net/sh_eth.h
> > @@ -143,10 +143,11 @@
> >
>
> <snip>
>
> > +
> > +/* 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?
> Best regards,
> Nobuhiro
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH] sh_eth Add SH7619 support
2008-08-01 15:32 ` Yoshinori Sato
@ 2008-08-02 7:30 ` Simon Horman
2008-08-02 15:34 ` Yoshinori Sato
0 siblings, 1 reply; 11+ messages in thread
From: Simon Horman @ 2008-08-02 7:30 UTC (permalink / raw)
To: Yoshinori Sato
Cc: Nobuhiro Iwamatsu, Jeff Garzik, Nobuhiro Iwamatsu, netdev,
linux-sh
On Fri, Aug 01, 2008 at 11:32:28AM -0400, Yoshinori Sato wrote:
> At Fri, 1 Aug 2008 12:48:27 +0900,
> Nobuhiro Iwamatsu wrote:
> >
> > Hi, Sato-san.
> >
> > 2008/8/1 Yoshinori Sato <ysato@users.sourceforge.jp>:
> > > SH7619 have same SH7710 ethernet controler.
> > > Add support for sh_eth driver.
> > >
> > > Signed-off-by: Yoshinori Sato <ysato@users.sourceforge.jp>
> > >
> >
> > <snip>
> >
> > >
> > > diff --git a/drivers/net/sh_eth.h b/drivers/net/sh_eth.h
> > > index 45ad1b0..ca3cc5f 100644
> > > --- a/drivers/net/sh_eth.h
> > > +++ b/drivers/net/sh_eth.h
> > > @@ -143,10 +143,11 @@
> > >
> >
> > <snip>
> >
> > > +
> > > +/* 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?
Iwamatsu-san,
what is the difference between CONFIG_CPU_LITTLE_ENDIAN and
__LITTLE_ENDIAN__ as used in drivers/net/sh_eth.h ?
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH] sh_eth Add SH7619 support
2008-08-02 7:30 ` Simon Horman
@ 2008-08-02 15:34 ` Yoshinori Sato
2008-08-03 19:23 ` Paul Mundt
0 siblings, 1 reply; 11+ messages in thread
From: Yoshinori Sato @ 2008-08-02 15:34 UTC (permalink / raw)
To: Simon Horman
Cc: Nobuhiro Iwamatsu, Jeff Garzik, Nobuhiro Iwamatsu, netdev,
linux-sh
At Sat, 2 Aug 2008 17:30:22 +1000,
Simon Horman wrote:
>
> On Fri, Aug 01, 2008 at 11:32:28AM -0400, Yoshinori Sato wrote:
> > At Fri, 1 Aug 2008 12:48:27 +0900,
> > Nobuhiro Iwamatsu wrote:
> > >
> > > Hi, Sato-san.
> > >
> > > 2008/8/1 Yoshinori Sato <ysato@users.sourceforge.jp>:
> > > > SH7619 have same SH7710 ethernet controler.
> > > > Add support for sh_eth driver.
> > > >
> > > > Signed-off-by: Yoshinori Sato <ysato@users.sourceforge.jp>
> > > >
> > >
> > > <snip>
> > >
> > > >
> > > > diff --git a/drivers/net/sh_eth.h b/drivers/net/sh_eth.h
> > > > index 45ad1b0..ca3cc5f 100644
> > > > --- a/drivers/net/sh_eth.h
> > > > +++ b/drivers/net/sh_eth.h
> > > > @@ -143,10 +143,11 @@
> > > >
> > >
> > > <snip>
> > >
> > > > +
> > > > +/* 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?
>
> 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.
--
Yoshinori Sato
<ysato@users.sourceforge.jp>
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH] sh_eth Add SH7619 support
2008-08-02 15:34 ` Yoshinori Sato
@ 2008-08-03 19:23 ` Paul Mundt
2008-08-05 19:21 ` Yoshinori Sato
[not found] ` <87tzdzmfno.wl%ysato@users.sourceforge.jp>
0 siblings, 2 replies; 11+ messages in thread
From: Paul Mundt @ 2008-08-03 19:23 UTC (permalink / raw)
To: Yoshinori Sato
Cc: Simon Horman, Nobuhiro Iwamatsu, Jeff Garzik, Nobuhiro Iwamatsu,
netdev, linux-sh
On Sat, Aug 02, 2008 at 11:34:21AM -0400, Yoshinori Sato wrote:
> At Sat, 2 Aug 2008 17:30:22 +1000,
> Simon Horman wrote:
> > On Fri, Aug 01, 2008 at 11:32:28AM -0400, Yoshinori Sato wrote:
> > > > > +/* 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?
> >
> > 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.
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH] sh_eth Add SH7619 support
2008-08-03 19:23 ` Paul Mundt
@ 2008-08-05 19:21 ` Yoshinori Sato
[not found] ` <87tzdzmfno.wl%ysato@users.sourceforge.jp>
1 sibling, 0 replies; 11+ messages in thread
From: Yoshinori Sato @ 2008-08-05 19:21 UTC (permalink / raw)
To: Paul Mundt, Yoshinori Sato, Simon Horman, Nobuhiro Iwamatsu,
Jeff Garzik
At Mon, 4 Aug 2008 04:23:35 +0900,
Paul Mundt wrote:
>
> On Sat, Aug 02, 2008 at 11:34:21AM -0400, Yoshinori Sato wrote:
> > At Sat, 2 Aug 2008 17:30:22 +1000,
> > Simon Horman wrote:
> > > On Fri, Aug 01, 2008 at 11:32:28AM -0400, Yoshinori Sato wrote:
> > > > > > +/* 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?
> > >
> > > 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.
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?
--
Yoshinori Sato
<ysato@users.sourceforge.jp>
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH] sh_eth Add SH7619 support
[not found] ` <87tzdzmfno.wl%ysato@users.sourceforge.jp>
@ 2008-08-06 2:36 ` Paul Mundt
2008-08-06 7:38 ` Nobuhiro Iwamatsu
1 sibling, 0 replies; 11+ messages in thread
From: Paul Mundt @ 2008-08-06 2:36 UTC (permalink / raw)
To: Yoshinori Sato
Cc: Simon Horman, Nobuhiro Iwamatsu, Jeff Garzik, Nobuhiro Iwamatsu,
netdev, linux-sh
On Tue, Aug 05, 2008 at 03:21:31PM -0400, Yoshinori Sato wrote:
> At Mon, 4 Aug 2008 04:23:35 +0900,
> Paul Mundt wrote:
> > On Sat, Aug 02, 2008 at 11:34:21AM -0400, Yoshinori Sato wrote:
> > > At Sat, 2 Aug 2008 17:30:22 +1000,
> > > Simon Horman wrote:
> > > > 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.
>
> 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?
>
Looks good to me.
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH] sh_eth Add SH7619 support
[not found] ` <87tzdzmfno.wl%ysato@users.sourceforge.jp>
2008-08-06 2:36 ` Paul Mundt
@ 2008-08-06 7:38 ` Nobuhiro Iwamatsu
2008-08-06 23:49 ` [PATCH 1/2] sh_eth Add SH7619 support (driver) Yoshinori Sato
1 sibling, 1 reply; 11+ messages in thread
From: Nobuhiro Iwamatsu @ 2008-08-06 7:38 UTC (permalink / raw)
To: Yoshinori Sato
Cc: Paul Mundt, Simon Horman, Jeff Garzik, Nobuhiro Iwamatsu, netdev,
linux-sh
2008/8/6 Yoshinori Sato <ysato@users.sourceforge.jp>:
> At Mon, 4 Aug 2008 04:23:35 +0900,
> Paul Mundt wrote:
>>
>> On Sat, Aug 02, 2008 at 11:34:21AM -0400, Yoshinori Sato wrote:
>> > At Sat, 2 Aug 2008 17:30:22 +1000,
>> > Simon Horman wrote:
>> > > On Fri, Aug 01, 2008 at 11:32:28AM -0400, Yoshinori Sato wrote:
>> > > > > > +/* 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?
>> > >
>> > > 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.
>
> 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?
Looks good.
Please resend patch.
Best regards,
Nobuhiro
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH 1/2] sh_eth Add SH7619 support (driver)
2008-08-06 7:38 ` Nobuhiro Iwamatsu
@ 2008-08-06 23:49 ` Yoshinori Sato
2008-08-07 6:23 ` Jeff Garzik
0 siblings, 1 reply; 11+ messages in thread
From: Yoshinori Sato @ 2008-08-06 23:49 UTC (permalink / raw)
To: Jeff Garzik, Nobuhiro Iwamatsu; +Cc: Paul Mundt, Simon Horman, netdev, linux-sh
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
diff --git a/arch/sh/include/asm/sh_eth.h b/arch/sh/include/asm/sh_eth.h
new file mode 100644
index 0000000..bb83258
--- /dev/null
+++ b/arch/sh/include/asm/sh_eth.h
@@ -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
diff --git a/drivers/net/Kconfig b/drivers/net/Kconfig
index 8a03875..4b4cb2b 100644
--- a/drivers/net/Kconfig
+++ b/drivers/net/Kconfig
@@ -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"
diff --git a/drivers/net/sh_eth.c b/drivers/net/sh_eth.c
index 6a06b95..25e62cf 100644
--- a/drivers/net/sh_eth.c
+++ b/drivers/net/sh_eth.c
@@ -34,6 +34,29 @@
#include "sh_eth.h"
+/* CPU <-> EDMAC endian convert */
+static inline __u32 cpu_to_edmac(struct sh_eth_private *mdp, u32 x)
+{
+ switch (mdp->edmac_endian) {
+ case EDMAC_LITTLE_ENDIAN:
+ return cpu_to_le32(x);
+ case EDMAC_BIG_ENDIAN:
+ return cpu_to_be32(x);
+ }
+ return x;
+}
+
+static inline __u32 edmac_to_cpu(struct sh_eth_private *mdp, u32 x)
+{
+ switch (mdp->edmac_endian) {
+ case EDMAC_LITTLE_ENDIAN:
+ return le32_to_cpu(x);
+ case EDMAC_BIG_ENDIAN:
+ return be32_to_cpu(x);
+ }
+ return x;
+}
+
/*
* Program the hardware MAC address from dev->dev_addr.
*/
@@ -240,7 +263,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(mdp, RD_RACT | RD_RFP);
/* The size of the buffer is 16 byte boundary. */
rxdesc->buffer_length = (mdp->rx_buf_sz + 16) & ~0x0F;
@@ -262,7 +285,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(mdp, RD_RDEL);
memset(mdp->tx_ring, 0, tx_ringsize);
@@ -270,10 +293,10 @@ 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(mdp, TD_TFP);
txdesc->buffer_length = 0;
if (i == 0) {
- /* Rx descriptor address set */
+ /* Tx descriptor address set */
ctrl_outl((u32)txdesc, ioaddr + TDLAR);
#if defined(CONFIG_CPU_SUBTYPE_SH7763)
ctrl_outl((u32)txdesc, ioaddr + TDFAR);
@@ -281,13 +304,13 @@ static void sh_eth_ring_format(struct net_device *ndev)
}
}
- /* Rx descriptor address set */
+ /* Tx descriptor address set */
#if defined(CONFIG_CPU_SUBTYPE_SH7763)
ctrl_outl((u32)txdesc, ioaddr + TDFXR);
ctrl_outl(0x1, ioaddr + TDFFR);
#endif
- txdesc->status |= cpu_to_le32(TD_TDLE);
+ txdesc->status |= cpu_to_edmac(mdp, TD_TDLE);
}
/* Get skb and descriptor buffer */
@@ -455,7 +478,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(mdp, TD_TACT))
break;
/* Free the original skb. */
if (mdp->tx_skbuff[entry]) {
@@ -463,9 +486,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(mdp, TD_TFP);
if (entry >= TX_RING_SIZE - 1)
- txdesc->status |= cpu_to_le32(TD_TDLE);
+ txdesc->status |= cpu_to_edmac(mdp, TD_TDLE);
mdp->stats.tx_packets++;
mdp->stats.tx_bytes += txdesc->buffer_length;
@@ -486,8 +509,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(mdp, RD_RACT))) {
+ desc_status = edmac_to_cpu(mdp, rxdesc->status);
pkt_len = rxdesc->frame_length;
if (--boguscnt < 0)
@@ -522,7 +545,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(mdp, RD_RACT);
entry = (++mdp->cur_rx) % RX_RING_SIZE;
}
@@ -552,10 +575,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(mdp, RD_RACT | RD_RFP | RD_RDEL);
else
rxdesc->status |=
- cpu_to_le32(RD_RACT | RD_RFP);
+ cpu_to_edmac(mdp, RD_RACT | RD_RFP);
}
/* Restart Rx engine if stopped. */
@@ -931,9 +954,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(mdp, TD_TACT | TD_TDLE);
else
- txdesc->status |= cpu_to_le32(TD_TACT);
+ txdesc->status |= cpu_to_edmac(mdp, TD_TACT);
mdp->cur_tx++;
@@ -1159,6 +1182,7 @@ static int sh_eth_drv_probe(struct platform_device *pdev)
struct resource *res;
struct net_device *ndev = NULL;
struct sh_eth_private *mdp;
+ struct sh_eth_plat_data *pd;
/* get base addr */
res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
@@ -1196,8 +1220,11 @@ static int sh_eth_drv_probe(struct platform_device *pdev)
mdp = netdev_priv(ndev);
spin_lock_init(&mdp->lock);
+ pd = (struct sh_eth_plat_data *)(pdev->dev.platform_data);
/* get PHY ID */
- mdp->phy_id = (int)pdev->dev.platform_data;
+ mdp->phy_id = pd->phy;
+ /* EDMAC endian */
+ mdp->edmac_endian = pd->edmac_endian;
/* set function */
ndev->open = sh_eth_open;
@@ -1217,12 +1244,16 @@ static int sh_eth_drv_probe(struct platform_device *pdev)
/* First device only init */
if (!devno) {
+#if defined(ARSTR)
/* reset device */
ctrl_outl(ARSTR_ARSTR, ARSTR);
mdelay(1);
+#endif
+#if defined(SH_TSU_ADDR)
/* TSU init (Init only)*/
sh_eth_tsu_init(SH_TSU_ADDR);
+#endif
}
/* network device register */
@@ -1240,8 +1271,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);
diff --git a/drivers/net/sh_eth.h b/drivers/net/sh_eth.h
index 45ad1b0..73bc718 100644
--- a/drivers/net/sh_eth.h
+++ b/drivers/net/sh_eth.h
@@ -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 */
--
1.5.6.3
--
Yoshinori Sato
<ysato@users.sourceforge.jp>
^ permalink raw reply related [flat|nested] 11+ messages in thread
* Re: [PATCH 1/2] sh_eth Add SH7619 support (driver)
2008-08-06 23:49 ` [PATCH 1/2] sh_eth Add SH7619 support (driver) Yoshinori Sato
@ 2008-08-07 6:23 ` Jeff Garzik
0 siblings, 0 replies; 11+ messages in thread
From: Jeff Garzik @ 2008-08-07 6:23 UTC (permalink / raw)
To: Yoshinori Sato
Cc: Nobuhiro Iwamatsu, Paul Mundt, Simon Horman, netdev, linux-sh
Yoshinori Sato wrote:
> 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
^ permalink raw reply [flat|nested] 11+ messages in thread
end of thread, other threads:[~2008-08-07 6:23 UTC | newest]
Thread overview: 11+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-07-31 23:35 [PATCH] sh_eth Add SH7619 support Yoshinori Sato
2008-08-01 3:48 ` Nobuhiro Iwamatsu
2008-08-01 15:32 ` Yoshinori Sato
2008-08-02 7:30 ` Simon Horman
2008-08-02 15:34 ` Yoshinori Sato
2008-08-03 19:23 ` Paul Mundt
2008-08-05 19:21 ` Yoshinori Sato
[not found] ` <87tzdzmfno.wl%ysato@users.sourceforge.jp>
2008-08-06 2:36 ` Paul Mundt
2008-08-06 7:38 ` Nobuhiro Iwamatsu
2008-08-06 23:49 ` [PATCH 1/2] sh_eth Add SH7619 support (driver) Yoshinori Sato
2008-08-07 6:23 ` Jeff Garzik
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).