Re: [U-Boot] [PATCH 1/2] TI: netdev: add driver for cpsw ethernet device

2011-11-28 Thread Kumar Nath, Chandan
Tom,
Can we do cache enabling of cpsw as a follow up patch to this?
As, initial aim is to upstream basic cpsw functional driver first
and then follow on other features like you said cache enable etc.

Regards
Chandan

 -Original Message-
 From: u-boot-boun...@lists.denx.de [mailto:u-boot-
 boun...@lists.denx.de] On Behalf Of Kumar Nath, Chandan
 Sent: Friday, November 11, 2011 8:42 PM
 To: Tom Rini
 Cc: u-boot@lists.denx.de; Chemparathy, Cyril
 Subject: Re: [U-Boot] [PATCH 1/2] TI: netdev: add driver for cpsw
 ethernet device
 
 
 
  -Original Message-
  From: Tom Rini [mailto:tom.r...@gmail.com]
  Sent: Friday, November 11, 2011 8:19 PM
  To: Kumar Nath, Chandan
  Cc: u-boot@lists.denx.de; Chemparathy, Cyril
  Subject: Re: [U-Boot] [PATCH 1/2] TI: netdev: add driver for cpsw
  ethernet device
 
  On Thu, Nov 10, 2011 at 11:01 PM, Kumar Nath, Chandan
  chandan.n...@ti.com wrote:
  
  
   -Original Message-
   From: Tom Rini [mailto:tom.r...@gmail.com]
   Sent: Thursday, November 10, 2011 8:11 PM
   To: Kumar Nath, Chandan
   Cc: u-boot@lists.denx.de; Chemparathy, Cyril
   Subject: Re: [U-Boot] [PATCH 1/2] TI: netdev: add driver for cpsw
   ethernet device
  
   On Wed, Nov 9, 2011 at 10:47 PM, Kumar Nath, Chandan
   chandan.n...@ti.com wrote:
-Original Message-
From: Tom Rini [mailto:tom.r...@gmail.com]
Sent: Friday, October 21, 2011 9:09 PM
To: Kumar Nath, Chandan
Cc: u-boot@lists.denx.de; Chemparathy, Cyril
Subject: Re: [U-Boot] [PATCH 1/2] TI: netdev: add driver for
 cpsw
ethernet device
   
On Fri, Oct 21, 2011 at 12:02 AM, Chandan Nath
  chandan.n...@ti.com
wrote:
 From: Cyril Chemparathy cy...@ti.com

 CPSW is an on-chip ethernet switch that is found on various
  SoCs
   from
Texas
 Instruments.  This patch adds a simple driver (based on the
  Linux
driver) for
 this hardware module.
   
Have you made the driver safe with dcache enabled?
   
No, driver is not made safe with dcache enabled. Can you please
  tell
   me
why I need to enable dcache.
  
   Because we really want to enable the dcache for performance
 reasons.
   Given that to enable dcache on am335x we just need:
   #ifndef CONFIG_SYS_DCACHE_OFF
   void enable_caches(void)
   {
           /* Enable D-cache. I-cache is already enabled in start.S
 */
           dcache_enable();
   }
   #endif
  
   We really want to not add drivers that aren't cache safe,
 especially
   when it's not a lot of work to do so.
  
  
   I tried enabling dcache by adding above code. But when I executed
  dhcp command,
   it was not able to find any IP address and keeps trying infinitely.
 
  Correct.  The cpsw driver in u-boot is not cache coherent, which is
  what I'm asking you to fix.  Looking at the patches to make the
  davinci emac driver cache cohernet might be of some help here.
 
 
 Ok, I will look into this and update you.
 
  --
  Tom
 ___
 U-Boot mailing list
 U-Boot@lists.denx.de
 http://lists.denx.de/mailman/listinfo/u-boot
___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


Re: [U-Boot] [PATCH 1/2] TI: netdev: add driver for cpsw ethernet device

2011-11-28 Thread Tom Rini
On Mon, Nov 28, 2011 at 1:23 AM, Kumar Nath, Chandan
chandan.n...@ti.com wrote:
 Tom,
 Can we do cache enabling of cpsw as a follow up patch to this?
 As, initial aim is to upstream basic cpsw functional driver first
 and then follow on other features like you said cache enable etc.

Per Wolfgang in the davinci emac thread, no, no new enet drivers that
aren't cache safe.

-- 
Tom
___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


Re: [U-Boot] [PATCH 1/2] TI: netdev: add driver for cpsw ethernet device

2011-11-11 Thread Tom Rini
On Thu, Nov 10, 2011 at 11:01 PM, Kumar Nath, Chandan
chandan.n...@ti.com wrote:


 -Original Message-
 From: Tom Rini [mailto:tom.r...@gmail.com]
 Sent: Thursday, November 10, 2011 8:11 PM
 To: Kumar Nath, Chandan
 Cc: u-boot@lists.denx.de; Chemparathy, Cyril
 Subject: Re: [U-Boot] [PATCH 1/2] TI: netdev: add driver for cpsw
 ethernet device

 On Wed, Nov 9, 2011 at 10:47 PM, Kumar Nath, Chandan
 chandan.n...@ti.com wrote:
  -Original Message-
  From: Tom Rini [mailto:tom.r...@gmail.com]
  Sent: Friday, October 21, 2011 9:09 PM
  To: Kumar Nath, Chandan
  Cc: u-boot@lists.denx.de; Chemparathy, Cyril
  Subject: Re: [U-Boot] [PATCH 1/2] TI: netdev: add driver for cpsw
  ethernet device
 
  On Fri, Oct 21, 2011 at 12:02 AM, Chandan Nath chandan.n...@ti.com
  wrote:
   From: Cyril Chemparathy cy...@ti.com
  
   CPSW is an on-chip ethernet switch that is found on various SoCs
 from
  Texas
   Instruments.  This patch adds a simple driver (based on the Linux
  driver) for
   this hardware module.
 
  Have you made the driver safe with dcache enabled?
 
  No, driver is not made safe with dcache enabled. Can you please tell
 me
  why I need to enable dcache.

 Because we really want to enable the dcache for performance reasons.
 Given that to enable dcache on am335x we just need:
 #ifndef CONFIG_SYS_DCACHE_OFF
 void enable_caches(void)
 {
         /* Enable D-cache. I-cache is already enabled in start.S */
         dcache_enable();
 }
 #endif

 We really want to not add drivers that aren't cache safe, especially
 when it's not a lot of work to do so.


 I tried enabling dcache by adding above code. But when I executed dhcp 
 command,
 it was not able to find any IP address and keeps trying infinitely.

Correct.  The cpsw driver in u-boot is not cache coherent, which is
what I'm asking you to fix.  Looking at the patches to make the
davinci emac driver cache cohernet might be of some help here.

-- 
Tom
___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


Re: [U-Boot] [PATCH 1/2] TI: netdev: add driver for cpsw ethernet device

2011-11-11 Thread Kumar Nath, Chandan


 -Original Message-
 From: Tom Rini [mailto:tom.r...@gmail.com]
 Sent: Friday, November 11, 2011 8:19 PM
 To: Kumar Nath, Chandan
 Cc: u-boot@lists.denx.de; Chemparathy, Cyril
 Subject: Re: [U-Boot] [PATCH 1/2] TI: netdev: add driver for cpsw
 ethernet device
 
 On Thu, Nov 10, 2011 at 11:01 PM, Kumar Nath, Chandan
 chandan.n...@ti.com wrote:
 
 
  -Original Message-
  From: Tom Rini [mailto:tom.r...@gmail.com]
  Sent: Thursday, November 10, 2011 8:11 PM
  To: Kumar Nath, Chandan
  Cc: u-boot@lists.denx.de; Chemparathy, Cyril
  Subject: Re: [U-Boot] [PATCH 1/2] TI: netdev: add driver for cpsw
  ethernet device
 
  On Wed, Nov 9, 2011 at 10:47 PM, Kumar Nath, Chandan
  chandan.n...@ti.com wrote:
   -Original Message-
   From: Tom Rini [mailto:tom.r...@gmail.com]
   Sent: Friday, October 21, 2011 9:09 PM
   To: Kumar Nath, Chandan
   Cc: u-boot@lists.denx.de; Chemparathy, Cyril
   Subject: Re: [U-Boot] [PATCH 1/2] TI: netdev: add driver for cpsw
   ethernet device
  
   On Fri, Oct 21, 2011 at 12:02 AM, Chandan Nath
 chandan.n...@ti.com
   wrote:
From: Cyril Chemparathy cy...@ti.com
   
CPSW is an on-chip ethernet switch that is found on various
 SoCs
  from
   Texas
Instruments.  This patch adds a simple driver (based on the
 Linux
   driver) for
this hardware module.
  
   Have you made the driver safe with dcache enabled?
  
   No, driver is not made safe with dcache enabled. Can you please
 tell
  me
   why I need to enable dcache.
 
  Because we really want to enable the dcache for performance reasons.
  Given that to enable dcache on am335x we just need:
  #ifndef CONFIG_SYS_DCACHE_OFF
  void enable_caches(void)
  {
          /* Enable D-cache. I-cache is already enabled in start.S */
          dcache_enable();
  }
  #endif
 
  We really want to not add drivers that aren't cache safe, especially
  when it's not a lot of work to do so.
 
 
  I tried enabling dcache by adding above code. But when I executed
 dhcp command,
  it was not able to find any IP address and keeps trying infinitely.
 
 Correct.  The cpsw driver in u-boot is not cache coherent, which is
 what I'm asking you to fix.  Looking at the patches to make the
 davinci emac driver cache cohernet might be of some help here.
 

Ok, I will look into this and update you.

 --
 Tom
___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


Re: [U-Boot] [PATCH 1/2] TI: netdev: add driver for cpsw ethernet device

2011-11-10 Thread Tom Rini
On Wed, Nov 9, 2011 at 10:47 PM, Kumar Nath, Chandan
chandan.n...@ti.com wrote:
 -Original Message-
 From: Tom Rini [mailto:tom.r...@gmail.com]
 Sent: Friday, October 21, 2011 9:09 PM
 To: Kumar Nath, Chandan
 Cc: u-boot@lists.denx.de; Chemparathy, Cyril
 Subject: Re: [U-Boot] [PATCH 1/2] TI: netdev: add driver for cpsw
 ethernet device

 On Fri, Oct 21, 2011 at 12:02 AM, Chandan Nath chandan.n...@ti.com
 wrote:
  From: Cyril Chemparathy cy...@ti.com
 
  CPSW is an on-chip ethernet switch that is found on various SoCs from
 Texas
  Instruments.  This patch adds a simple driver (based on the Linux
 driver) for
  this hardware module.

 Have you made the driver safe with dcache enabled?

 No, driver is not made safe with dcache enabled. Can you please tell me
 why I need to enable dcache.

Because we really want to enable the dcache for performance reasons.
Given that to enable dcache on am335x we just need:
#ifndef CONFIG_SYS_DCACHE_OFF
void enable_caches(void)
{
/* Enable D-cache. I-cache is already enabled in start.S */
dcache_enable();
}
#endif

We really want to not add drivers that aren't cache safe, especially
when it's not a lot of work to do so.

-- 
Tom
___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


Re: [U-Boot] [PATCH 1/2] TI: netdev: add driver for cpsw ethernet device

2011-11-10 Thread Kumar Nath, Chandan


 -Original Message-
 From: Tom Rini [mailto:tom.r...@gmail.com]
 Sent: Thursday, November 10, 2011 8:11 PM
 To: Kumar Nath, Chandan
 Cc: u-boot@lists.denx.de; Chemparathy, Cyril
 Subject: Re: [U-Boot] [PATCH 1/2] TI: netdev: add driver for cpsw
 ethernet device
 
 On Wed, Nov 9, 2011 at 10:47 PM, Kumar Nath, Chandan
 chandan.n...@ti.com wrote:
  -Original Message-
  From: Tom Rini [mailto:tom.r...@gmail.com]
  Sent: Friday, October 21, 2011 9:09 PM
  To: Kumar Nath, Chandan
  Cc: u-boot@lists.denx.de; Chemparathy, Cyril
  Subject: Re: [U-Boot] [PATCH 1/2] TI: netdev: add driver for cpsw
  ethernet device
 
  On Fri, Oct 21, 2011 at 12:02 AM, Chandan Nath chandan.n...@ti.com
  wrote:
   From: Cyril Chemparathy cy...@ti.com
  
   CPSW is an on-chip ethernet switch that is found on various SoCs
 from
  Texas
   Instruments.  This patch adds a simple driver (based on the Linux
  driver) for
   this hardware module.
 
  Have you made the driver safe with dcache enabled?
 
  No, driver is not made safe with dcache enabled. Can you please tell
 me
  why I need to enable dcache.
 
 Because we really want to enable the dcache for performance reasons.
 Given that to enable dcache on am335x we just need:
 #ifndef CONFIG_SYS_DCACHE_OFF
 void enable_caches(void)
 {
 /* Enable D-cache. I-cache is already enabled in start.S */
 dcache_enable();
 }
 #endif
 
 We really want to not add drivers that aren't cache safe, especially
 when it's not a lot of work to do so.
 

I tried enabling dcache by adding above code. But when I executed dhcp command,
it was not able to find any IP address and keeps trying infinitely. 

 --
 Tom
___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


Re: [U-Boot] [PATCH 1/2] TI: netdev: add driver for cpsw ethernet device

2011-11-09 Thread Kumar Nath, Chandan


 -Original Message-
 From: Tom Rini [mailto:tom.r...@gmail.com]
 Sent: Friday, October 21, 2011 9:09 PM
 To: Kumar Nath, Chandan
 Cc: u-boot@lists.denx.de; Chemparathy, Cyril
 Subject: Re: [U-Boot] [PATCH 1/2] TI: netdev: add driver for cpsw
 ethernet device
 
 On Fri, Oct 21, 2011 at 12:02 AM, Chandan Nath chandan.n...@ti.com
 wrote:
  From: Cyril Chemparathy cy...@ti.com
 
  CPSW is an on-chip ethernet switch that is found on various SoCs from
 Texas
  Instruments.  This patch adds a simple driver (based on the Linux
 driver) for
  this hardware module.
 
 Have you made the driver safe with dcache enabled?
 

No, driver is not made safe with dcache enabled. Can you please tell me
why I need to enable dcache.

 --
 Tom
___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


[U-Boot] [PATCH 1/2] TI: netdev: add driver for cpsw ethernet device

2011-10-21 Thread Chandan Nath
From: Cyril Chemparathy cy...@ti.com

CPSW is an on-chip ethernet switch that is found on various SoCs from Texas
Instruments.  This patch adds a simple driver (based on the Linux driver) for
this hardware module.

Signed-off-by: Cyril Chemparathy cy...@ti.com
---
 drivers/net/Makefile |1 +
 drivers/net/cpsw.c   |  862 ++
 include/netdev.h |   29 ++
 3 files changed, 892 insertions(+), 0 deletions(-)
 create mode 100644 drivers/net/cpsw.c

diff --git a/drivers/net/Makefile b/drivers/net/Makefile
index 819b197..080f767 100644
--- a/drivers/net/Makefile
+++ b/drivers/net/Makefile
@@ -80,6 +80,7 @@ COBJS-$(CONFIG_TIGON3) += bcm570x_autoneg.o
 COBJS-$(CONFIG_TIGON3) += 5701rls.o
 COBJS-$(CONFIG_DRIVER_TI_EMAC) += davinci_emac.o
 COBJS-$(CONFIG_TSEC_ENET) += tsec.o fsl_mdio.o
+COBJS-$(CONFIG_DRIVER_TI_CPSW) += cpsw.o
 COBJS-$(CONFIG_TSI108_ETH) += tsi108_eth.o
 COBJS-$(CONFIG_ULI526X) += uli526x.o
 COBJS-$(CONFIG_VSC7385_ENET) += vsc7385.o
diff --git a/drivers/net/cpsw.c b/drivers/net/cpsw.c
new file mode 100644
index 000..4cef4cf
--- /dev/null
+++ b/drivers/net/cpsw.c
@@ -0,0 +1,862 @@
+/*
+ * CPSW Ethernet Switch Driver
+ *
+ * See file CREDITS for list of people who contributed to this
+ * project.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+
+#include common.h
+#include command.h
+#include net.h
+#include miiphy.h
+#include malloc.h
+#include net.h
+#include netdev.h
+#include asm/errno.h
+#include asm/io.h
+#include linux/mii.h
+
+#define BIT(x) (1  (x))
+#define BITMASK(bits)  (BIT(bits) - 1)
+#define PHY_REG_MASK   0x1f
+#define PHY_ID_MASK0x1f
+#define NUM_DESCS  (PKTBUFSRX * 2)
+#define PKT_MIN60
+#define PKT_MAX(1500 + 14 + 4 + 4)
+
+/* DMA Registers */
+#define CPDMA_TXCONTROL0x004
+#define CPDMA_RXCONTROL0x014
+#define CPDMA_SOFTRESET0x01c
+#define CPDMA_RXFREE   0x0e0
+#define CPDMA_TXHDP0x100
+#define CPDMA_RXHDP0x120
+#define CPDMA_TXCP 0x140
+#define CPDMA_RXCP 0x160
+
+/* Descriptor mode bits */
+#define CPDMA_DESC_SOP BIT(31)
+#define CPDMA_DESC_EOP BIT(30)
+#define CPDMA_DESC_OWNER   BIT(29)
+#define CPDMA_DESC_EOQ BIT(28)
+
+struct cpsw_mdio_regs {
+   u32 version;
+   u32 control;
+#define CONTROL_IDLE   (1  31)
+#define CONTROL_ENABLE (1  30)
+
+   u32 alive;
+   u32 link;
+   u32 linkintraw;
+   u32 linkintmasked;
+   u32 __reserved_0[2];
+   u32 userintraw;
+   u32 userintmasked;
+   u32 userintmaskset;
+   u32 userintmaskclr;
+   u32 __reserved_1[20];
+
+   struct {
+   u32 access;
+   u32 physel;
+#define USERACCESS_GO  (1  31)
+#define USERACCESS_WRITE   (1  30)
+#define USERACCESS_ACK (1  29)
+#define USERACCESS_READ(0)
+#define USERACCESS_DATA(0x)
+   } user[0];
+};
+
+struct cpsw_regs {
+   u32 id_ver;
+   u32 control;
+   u32 soft_reset;
+   u32 stat_port_en;
+   u32 ptype;
+};
+
+struct cpsw_slave_regs {
+   u32 max_blks;
+   u32 blk_cnt;
+   u32 flow_thresh;
+   u32 port_vlan;
+   u32 tx_pri_map;
+   u32 gap_thresh;
+   u32 sa_lo;
+   u32 sa_hi;
+};
+
+struct cpsw_host_regs {
+   u32 max_blks;
+   u32 blk_cnt;
+   u32 flow_thresh;
+   u32 port_vlan;
+   u32 tx_pri_map;
+   u32 cpdma_tx_pri_map;
+   u32 cpdma_rx_chan_map;
+};
+
+struct cpsw_sliver_regs {
+   u32 id_ver;
+   u32 mac_control;
+   u32 mac_status;
+   u32 soft_reset;
+   u32 rx_maxlen;
+   u32 __reserved_0;
+   u32 rx_pause;
+   u32 tx_pause;
+   u32 __reserved_1;
+   u32 rx_pri_map;
+};
+
+#define ALE_ENTRY_BITS 68
+#define ALE_ENTRY_WORDSDIV_ROUND_UP(ALE_ENTRY_BITS, 32)
+
+/* ALE Registers */
+#define ALE_CONTROL0x08
+#define ALE_UNKNOWNVLAN0x18
+#define 

Re: [U-Boot] [PATCH 1/2] TI: netdev: add driver for cpsw ethernet device

2011-10-21 Thread Tom Rini
On Fri, Oct 21, 2011 at 12:02 AM, Chandan Nath chandan.n...@ti.com wrote:
 From: Cyril Chemparathy cy...@ti.com

 CPSW is an on-chip ethernet switch that is found on various SoCs from Texas
 Instruments.  This patch adds a simple driver (based on the Linux driver) for
 this hardware module.

Have you made the driver safe with dcache enabled?

-- 
Tom
___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


Re: [U-Boot] [PATCH 1/2] TI: netdev: add driver for cpsw ethernet device

2010-09-01 Thread Cyril Chemparathy
Hi Ben,

I seem to have missed a comment while responding earlier:

[...]
 +int cpsw_register(struct cpsw_platform_data *data)
 Please redo things so that this function takes generic arguments.  Build
 up your struct internally.

Could you elaborate on the generic arguments here?  Are you referring to
the eth_device struct and bd_t args?

Regards
Cyril.
___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


Re: [U-Boot] [PATCH 1/2] TI: netdev: add driver for cpsw ethernet device

2010-09-01 Thread Ben Warren
  Hi Cyril,

On 9/1/2010 8:34 AM, Cyril Chemparathy wrote:
 Hi Ben,

 I seem to have missed a comment while responding earlier:

 [...]
 +int cpsw_register(struct cpsw_platform_data *data)
 Please redo things so that this function takes generic arguments.  Build
 up your struct internally.
 Could you elaborate on the generic arguments here?  Are you referring to
 the eth_device struct and bd_t args?

By generic I mean primitive, or structs that are defined in headers that 
are universally included.  Ideally, you'll pass in arguments that don't 
require another header file to resolve, such as a base address or index 
number.  As you've proposed, anybody that includes netdev.h will need 
to know what a 'struct cpsw_platform_data' is, and that's not appropriate.
 Regards
 Cyril.
regards,
Ben
___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


Re: [U-Boot] [PATCH 1/2] TI: netdev: add driver for cpsw ethernet device

2010-09-01 Thread Ben Warren
  On 8/31/2010 8:58 AM, Cyril Chemparathy wrote:
 Hi Ben,

 [...]
 +COBJS-$(CONFIG_DRIVER_TI_CPSW) += cpsw.o
 Please don't use the word DRIVER here.  If possible, use something more
 verbose than CPSW too.
 Will TI_CPSW_SWITCH work better considering that CPSW is the name of
 the hardware block?

Sure.
 [...]
 +++ b/drivers/net/cpsw.c
 Please rename this ti_cpsw.c
 Agreed.

 [...]
 +struct cpsw_priv {
 + struct eth_device   *dev;
 + struct cpsw_platform_data   data;
 + int host_port;
 +
 + struct cpsw_regs*regs;
 + void*dma_regs;
 + struct cpsw_host_regs   *host_port_regs;
 + void*ale_regs;
 +
 + struct cpdma_desc   descs[NUM_DESCS];
 + struct cpdma_desc   *desc_free;
 + struct cpdma_chan   rx_chan, tx_chan;
 +
 + struct cpsw_slave   *slaves;
 +#define for_each_slave(priv, func, arg...)   \
 + do {\
 + int idx;\
 + for (idx = 0; idx   (priv)-data.slaves; idx++) \
 + (func)((priv)-slaves + idx, ##arg);\
 + } while (0)
 +};
 +
 Can this stuff go in a header file?
 This stuff is intended to be private within the driver.  I can split
 this out into drivers/net/ti_cpsw.h.

If it's truly private within the driver and will never be needed by 
anybody else, the source file is OK, but since you're going to create a 
new header file in /include/net anyway, maybe you'll want to put some 
stuff there.  Your call...
 [...]
 diff --git a/include/netdev.h b/include/netdev.h
 index 94eedfe..009e2f1 100644
 --- a/include/netdev.h
 +++ b/include/netdev.h
 @@ -180,4 +180,33 @@ struct mv88e61xx_config {
int mv88e61xx_switch_initialize(struct mv88e61xx_config *swconfig);
#endif /* CONFIG_MV88E61XX_SWITCH */

 +#ifdef CONFIG_DRIVER_TI_CPSW
 +
 +struct cpsw_slave_data {
 + u32 slave_reg_ofs;
 + u32 sliver_reg_ofs;
 + int phy_id;
 +};
 +
 +struct cpsw_platform_data {
 + u32 mdio_base;
 + u32 cpsw_base;
 + int mdio_div;
 + int channels;   /* number of cpdma channels (symmetric) */
 + u32 cpdma_reg_ofs;  /* cpdma register offset*/
 + int slaves; /* number of slave cpgmac ports */
 + u32 ale_reg_ofs;/* address lookup engine reg offset */
 + int ale_entries;/* ale table size   */
 + u32 host_port_reg_ofs;  /* cpdma host port registers*/
 + u32 hw_stats_reg_ofs;   /* cpsw hw stats counters   */
 + u32 mac_control;
 + struct cpsw_slave_data  *slave_data;
 + void(*control)(int enabled);
 + void(*phy_init)(char *name, int addr);
 +};
 +
 This stuff doesn't belong in this file.  Definitions specific to your
 driver should go in /include/net/ti_cpsw.h (note that you'll be creating
 this directory, but that's where we want driver headers to go moving
 forward.  Also, please call the initialize function
 'ti_cpsw_initialize()'.  Despite what the readme file recommends, you're
 initializing something, not registering it.  If anything, the 'init()'
 functions are misnamed, but that's another discussion.
 Will do.

 We will post an updated v2 series shortly, with these changes.

 Thanks
 Cyril.
regards,
Ben
___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


Re: [U-Boot] [PATCH 1/2] TI: netdev: add driver for cpsw ethernet device

2010-08-31 Thread Cyril Chemparathy
Hi Ben,

[...]
 +COBJS-$(CONFIG_DRIVER_TI_CPSW) += cpsw.o
 Please don't use the word DRIVER here.  If possible, use something more
 verbose than CPSW too.

Will TI_CPSW_SWITCH work better considering that CPSW is the name of
the hardware block?

[...]
 +++ b/drivers/net/cpsw.c
 Please rename this ti_cpsw.c
Agreed.

[...]
 +struct cpsw_priv {
 + struct eth_device   *dev;
 + struct cpsw_platform_data   data;
 + int host_port;
 +
 + struct cpsw_regs*regs;
 + void*dma_regs;
 + struct cpsw_host_regs   *host_port_regs;
 + void*ale_regs;
 +
 + struct cpdma_desc   descs[NUM_DESCS];
 + struct cpdma_desc   *desc_free;
 + struct cpdma_chan   rx_chan, tx_chan;
 +
 + struct cpsw_slave   *slaves;
 +#define for_each_slave(priv, func, arg...)   \
 + do {\
 + int idx;\
 + for (idx = 0; idx  (priv)-data.slaves; idx++) \
 + (func)((priv)-slaves + idx, ##arg);\
 + } while (0)
 +};
 +
 
 Can this stuff go in a header file?

This stuff is intended to be private within the driver.  I can split
this out into drivers/net/ti_cpsw.h.

[...]
 diff --git a/include/netdev.h b/include/netdev.h
 index 94eedfe..009e2f1 100644
 --- a/include/netdev.h
 +++ b/include/netdev.h
 @@ -180,4 +180,33 @@ struct mv88e61xx_config {
   int mv88e61xx_switch_initialize(struct mv88e61xx_config *swconfig);
   #endif /* CONFIG_MV88E61XX_SWITCH */

 +#ifdef CONFIG_DRIVER_TI_CPSW
 +
 +struct cpsw_slave_data {
 + u32 slave_reg_ofs;
 + u32 sliver_reg_ofs;
 + int phy_id;
 +};
 +
 +struct cpsw_platform_data {
 + u32 mdio_base;
 + u32 cpsw_base;
 + int mdio_div;
 + int channels;   /* number of cpdma channels (symmetric) */
 + u32 cpdma_reg_ofs;  /* cpdma register offset*/
 + int slaves; /* number of slave cpgmac ports */
 + u32 ale_reg_ofs;/* address lookup engine reg offset */
 + int ale_entries;/* ale table size   */
 + u32 host_port_reg_ofs;  /* cpdma host port registers*/
 + u32 hw_stats_reg_ofs;   /* cpsw hw stats counters   */
 + u32 mac_control;
 + struct cpsw_slave_data  *slave_data;
 + void(*control)(int enabled);
 + void(*phy_init)(char *name, int addr);
 +};
 +
 This stuff doesn't belong in this file.  Definitions specific to your
 driver should go in /include/net/ti_cpsw.h (note that you'll be creating
 this directory, but that's where we want driver headers to go moving
 forward.  Also, please call the initialize function
 'ti_cpsw_initialize()'.  Despite what the readme file recommends, you're
 initializing something, not registering it.  If anything, the 'init()'
 functions are misnamed, but that's another discussion.

Will do.

We will post an updated v2 series shortly, with these changes.

Thanks
Cyril.
___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


Re: [U-Boot] [PATCH 1/2] TI: netdev: add driver for cpsw ethernet device

2010-08-30 Thread Ben Warren
  Hi Cyril,

Sorry for taking so long to look at this.

On 8/3/2010 6:33 PM, Cyril Chemparathy wrote:
 CPSW is an on-chip ethernet switch that is found on various SoCs from Texas
 Instruments.  This patch adds a simple driver (based on the Linux driver) for
 this hardware module.

 Signed-off-by: Cyril Chemparathycy...@ti.com
 ---
   drivers/net/Makefile |1 +
   drivers/net/cpsw.c   |  861 
 ++
   include/netdev.h |   29 ++
   3 files changed, 891 insertions(+), 0 deletions(-)
   create mode 100644 drivers/net/cpsw.c

 diff --git a/drivers/net/Makefile b/drivers/net/Makefile
 index 218eeff..f4f1ed2 100644
 --- a/drivers/net/Makefile
 +++ b/drivers/net/Makefile
 @@ -73,6 +73,7 @@ COBJS-$(CONFIG_SMC9) += smc9.o
   COBJS-$(CONFIG_SMC911X) += smc911x.o
   COBJS-$(CONFIG_TIGON3) += tigon3.o bcm570x_autoneg.o 5701rls.o
   COBJS-$(CONFIG_DRIVER_TI_EMAC) += davinci_emac.o
 +COBJS-$(CONFIG_DRIVER_TI_CPSW) += cpsw.o
Please don't use the word DRIVER here.  If possible, use something more 
verbose than CPSW too.
   COBJS-$(CONFIG_TSEC_ENET) += tsec.o
   COBJS-$(CONFIG_TSI108_ETH) += tsi108_eth.o
   COBJS-$(CONFIG_ULI526X) += uli526x.o
 diff --git a/drivers/net/cpsw.c b/drivers/net/cpsw.c
 new file mode 100644
 index 000..c84ec78
 --- /dev/null
 +++ b/drivers/net/cpsw.c
Please rename this ti_cpsw.c
 @@ -0,0 +1,861 @@
 +/*
 + * CPSW Ethernet Switch Driver
 + *
 + * See file CREDITS for list of people who contributed to this
 + * project.
 + *
 + * This program is free software; you can redistribute it and/or modify
 + * it under the terms of the GNU General Public License as published by
 + * the Free Software Foundation; either version 2 of the License, or
 + * (at your option) any later version.
 + *
 + * This program is distributed in the hope that it will be useful,
 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 + * GNU General Public License for more details.
 + *
 + * You should have received a copy of the GNU General Public License
 + * along with this program; if not, write to the Free Software
 + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 + */
 +
 +#includecommon.h
 +#includecommand.h
 +#includenet.h
 +#includemiiphy.h
 +#includemalloc.h
 +#includenet.h
 +#includenetdev.h
 +#includeasm/errno.h
 +#includeasm/io.h
 +
 +#define BIT(x)   (1  (x))
 +#define BITMASK(bits)(BIT(bits) - 1)
 +#define PHY_REG_MASK 0x1f
 +#define PHY_ID_MASK  0x1f
 +#define NUM_DESCS(PKTBUFSRX * 2)
 +#define PKT_MIN  60
 +#define PKT_MAX  (1500 + 14 + 4 + 4)
 +
 +/* DMA Registers */
 +#define CPDMA_TXCONTROL  0x004
 +#define CPDMA_RXCONTROL  0x014
 +#define CPDMA_SOFTRESET  0x01c
 +#define CPDMA_RXFREE 0x0e0
 +#define CPDMA_TXHDP  0x100
 +#define CPDMA_RXHDP  0x120
 +#define CPDMA_TXCP   0x140
 +#define CPDMA_RXCP   0x160
 +
 +/* Descriptor mode bits */
 +#define CPDMA_DESC_SOP   BIT(31)
 +#define CPDMA_DESC_EOP   BIT(30)
 +#define CPDMA_DESC_OWNER BIT(29)
 +#define CPDMA_DESC_EOQ   BIT(28)
 +
 +struct cpsw_mdio_regs {
 + u32 version;
 + u32 control;
 +#define CONTROL_IDLE (1  31)
 +#define CONTROL_ENABLE   (1  30)
 +
 + u32 alive;
 + u32 link;
 + u32 linkintraw;
 + u32 linkintmasked;
 + u32 __reserved_0[2];
 + u32 userintraw;
 + u32 userintmasked;
 + u32 userintmaskset;
 + u32 userintmaskclr;
 + u32 __reserved_1[20];
 +
 + struct {
 + u32 access;
 + u32 physel;
 +#define USERACCESS_GO(1  31)
 +#define USERACCESS_WRITE (1  30)
 +#define USERACCESS_ACK   (1  29)
 +#define USERACCESS_READ  (0)
 +#define USERACCESS_DATA  (0x)
 + } user[0];
 +};
 +
 +struct cpsw_regs {
 + u32 id_ver;
 + u32 control;
 + u32 soft_reset;
 + u32 stat_port_en;
 + u32 ptype;
 +};
 +
 +struct cpsw_slave_regs {
 + u32 max_blks;
 + u32 blk_cnt;
 + u32 flow_thresh;
 + u32 port_vlan;
 + u32 tx_pri_map;
 + u32 gap_thresh;
 + u32 sa_lo;
 + u32 sa_hi;
 +};
 +
 +struct cpsw_host_regs {
 + u32 max_blks;
 + u32 blk_cnt;
 + u32 flow_thresh;
 + u32 port_vlan;
 + u32 tx_pri_map;
 + u32 cpdma_tx_pri_map;
 + u32 cpdma_rx_chan_map;
 +};
 +
 +struct cpsw_sliver_regs {
 + u32 id_ver;
 + u32 mac_control;
 + u32 mac_status;
 + u32 soft_reset;
 + u32 rx_maxlen;
 + u32 __reserved_0;
 + u32 rx_pause;
 + u32 tx_pause;
 + u32 __reserved_1;
 + 

[U-Boot] [PATCH 1/2] TI: netdev: add driver for cpsw ethernet device

2010-08-03 Thread Cyril Chemparathy
CPSW is an on-chip ethernet switch that is found on various SoCs from Texas
Instruments.  This patch adds a simple driver (based on the Linux driver) for
this hardware module.

Signed-off-by: Cyril Chemparathy cy...@ti.com
---
 drivers/net/Makefile |1 +
 drivers/net/cpsw.c   |  861 ++
 include/netdev.h |   29 ++
 3 files changed, 891 insertions(+), 0 deletions(-)
 create mode 100644 drivers/net/cpsw.c

diff --git a/drivers/net/Makefile b/drivers/net/Makefile
index 218eeff..f4f1ed2 100644
--- a/drivers/net/Makefile
+++ b/drivers/net/Makefile
@@ -73,6 +73,7 @@ COBJS-$(CONFIG_SMC9) += smc9.o
 COBJS-$(CONFIG_SMC911X) += smc911x.o
 COBJS-$(CONFIG_TIGON3) += tigon3.o bcm570x_autoneg.o 5701rls.o
 COBJS-$(CONFIG_DRIVER_TI_EMAC) += davinci_emac.o
+COBJS-$(CONFIG_DRIVER_TI_CPSW) += cpsw.o
 COBJS-$(CONFIG_TSEC_ENET) += tsec.o
 COBJS-$(CONFIG_TSI108_ETH) += tsi108_eth.o
 COBJS-$(CONFIG_ULI526X) += uli526x.o
diff --git a/drivers/net/cpsw.c b/drivers/net/cpsw.c
new file mode 100644
index 000..c84ec78
--- /dev/null
+++ b/drivers/net/cpsw.c
@@ -0,0 +1,861 @@
+/*
+ * CPSW Ethernet Switch Driver
+ *
+ * See file CREDITS for list of people who contributed to this
+ * project.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+
+#include common.h
+#include command.h
+#include net.h
+#include miiphy.h
+#include malloc.h
+#include net.h
+#include netdev.h
+#include asm/errno.h
+#include asm/io.h
+
+#define BIT(x) (1  (x))
+#define BITMASK(bits)  (BIT(bits) - 1)
+#define PHY_REG_MASK   0x1f
+#define PHY_ID_MASK0x1f
+#define NUM_DESCS  (PKTBUFSRX * 2)
+#define PKT_MIN60
+#define PKT_MAX(1500 + 14 + 4 + 4)
+
+/* DMA Registers */
+#define CPDMA_TXCONTROL0x004
+#define CPDMA_RXCONTROL0x014
+#define CPDMA_SOFTRESET0x01c
+#define CPDMA_RXFREE   0x0e0
+#define CPDMA_TXHDP0x100
+#define CPDMA_RXHDP0x120
+#define CPDMA_TXCP 0x140
+#define CPDMA_RXCP 0x160
+
+/* Descriptor mode bits */
+#define CPDMA_DESC_SOP BIT(31)
+#define CPDMA_DESC_EOP BIT(30)
+#define CPDMA_DESC_OWNER   BIT(29)
+#define CPDMA_DESC_EOQ BIT(28)
+
+struct cpsw_mdio_regs {
+   u32 version;
+   u32 control;
+#define CONTROL_IDLE   (1  31)
+#define CONTROL_ENABLE (1  30)
+
+   u32 alive;
+   u32 link;
+   u32 linkintraw;
+   u32 linkintmasked;
+   u32 __reserved_0[2];
+   u32 userintraw;
+   u32 userintmasked;
+   u32 userintmaskset;
+   u32 userintmaskclr;
+   u32 __reserved_1[20];
+
+   struct {
+   u32 access;
+   u32 physel;
+#define USERACCESS_GO  (1  31)
+#define USERACCESS_WRITE   (1  30)
+#define USERACCESS_ACK (1  29)
+#define USERACCESS_READ(0)
+#define USERACCESS_DATA(0x)
+   } user[0];
+};
+
+struct cpsw_regs {
+   u32 id_ver;
+   u32 control;
+   u32 soft_reset;
+   u32 stat_port_en;
+   u32 ptype;
+};
+
+struct cpsw_slave_regs {
+   u32 max_blks;
+   u32 blk_cnt;
+   u32 flow_thresh;
+   u32 port_vlan;
+   u32 tx_pri_map;
+   u32 gap_thresh;
+   u32 sa_lo;
+   u32 sa_hi;
+};
+
+struct cpsw_host_regs {
+   u32 max_blks;
+   u32 blk_cnt;
+   u32 flow_thresh;
+   u32 port_vlan;
+   u32 tx_pri_map;
+   u32 cpdma_tx_pri_map;
+   u32 cpdma_rx_chan_map;
+};
+
+struct cpsw_sliver_regs {
+   u32 id_ver;
+   u32 mac_control;
+   u32 mac_status;
+   u32 soft_reset;
+   u32 rx_maxlen;
+   u32 __reserved_0;
+   u32 rx_pause;
+   u32 tx_pause;
+   u32 __reserved_1;
+   u32 rx_pri_map;
+};
+
+#define ALE_ENTRY_BITS 68
+#define ALE_ENTRY_WORDSDIV_ROUND_UP(ALE_ENTRY_BITS, 32)
+
+/* ALE Registers */
+#define ALE_CONTROL0x08
+#define ALE_UNKNOWNVLAN0x18
+#define ALE_TABLE_CONTROL  0x20
+#define ALE_TABLE