Driver for AX88183 ethernet chip
PATCH 1/1 Driver for AX88183 ethernet chip
From: Joe Xue <[email protected]>
--- README | 7 + drivers/net/Makefile | 1 + drivers/net/ax88183.c | 265 +++++++++++++++++++++++ drivers/net/ax88183.h | 559 +++++++++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 832 insertions(+), 0 deletions(-) create mode 100644 drivers/net/ax88183.c create mode 100644 drivers/net/ax88183.h
README +7 -0
@@ -876,6 +876,13 @@ The following options need to be configured: automatically converts one 32 bit word to two 16 bit words you may also try CONFIG_SMC911X_32_BIT. + CONFIG_DRIVER_AX88183 + Support for AXIS's AX88183 chips. + + CONFIG_AX88183_BASE + Define this to hold the physical address + of the AX88183's I/O space + - USB Support: At the moment only the UHCI host controller is supported (PIP405, MIP405, MPC5200); define
drivers/net/Makefile +1 -0
@@ -83,6 +83,7 @@ COBJS-$(CONFIG_TSI108_ETH) += tsi108_eth.o COBJS-$(CONFIG_ULI526X) += uli526x.o COBJS-$(CONFIG_VSC7385_ENET) += vsc7385.o COBJS-$(CONFIG_XILINX_EMACLITE) += xilinx_emaclite.o +COBJS-$(CONFIG_DRIVER_AX88183) += ax88183.o COBJS := $(sort $(COBJS-y)) SRCS := $(COBJS:.o=.c)
drivers/net/ax88183.c new file +265 -0
265 lines not on this page · raw message
drivers/net/ax88183.h new file +559 -0
559 lines not on this page · raw message
Signature · 1 line
1.7.0.4
PATCH 1/1 Driver for AX88183 ethernet chip
Dear root,
Quoted 1 line · In message <[email protected]> you wrote:
From: Joe Xue <[email protected]>
Please add your Signed-off-by: line, and provide a real name in the sender address.
And then please run your patch through checkpatch.pl; as is it
reports: total: 383 errors, 327 warnings
Best regards,
Wolfgang Denk
Signature · 5 lines
DENX Software Engineering GmbH, MD: Wolfgang Denk & Detlev Zundel HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de Until you walk a mile in another man's moccasins, you can't imagine the smell.
PATCH 1/1 Driver for AX88183 ethernet chip
In reply to rootQuoted 1 line · root
From: Joe Xue <[email protected]>
You have to set you Signe-off-by in your patch. Please add also a commit message to explain what your patch is doing, and on which board you tested this driver. And set the net custodian as CC, this helps to get faster review.
drivers/net/Makefile COBJS-$(CONFIG_TSI108_ETH) += tsi108_eth.o · line 86
Quoted 7 lines
drivers/net/Makefile +1
-0@@ -83,6 +83,7 @@ COBJS-$(CONFIG_TSI108_ETH) += tsi108_eth.o COBJS-$(CONFIG_ULI526X) += uli526x.o COBJS-$(CONFIG_VSC7385_ENET) += vsc7385.o COBJS-$(CONFIG_XILINX_EMACLITE) += xilinx_emaclite.o +COBJS-$(CONFIG_DRIVER_AX88183) += ax88183.o
Please maintain the list sorted.
drivers/net/Makefile line 7
Quoted 8 lines
drivers/net/Makefile +7
-0@@ -0,0 +1,265 @@ + +/* + * (C) Copyright 2010 Joe Xue <[email protected]> + * + * This file is released under the terms of GPL v2 and any later version. + * See the file COPYING in the root directory of the source tree for details. +*/
The header is not enough. Please add coherent header with license, as you can see for other drivers. This must be fixed globally.
drivers/net/Makefile line 12
Quoted 5 lines
drivers/net/Makefile +5
-0+ +/* + * This driver works on 32bit mode + * AX88783 has two ethernet ports, we only use port 0 in u-boot + */
I suggest you add this comment to the README file, too,
Quoted 6 lines
drivers/net/Makefile +6
-0+#include <common.h> +#include <command.h> +#include <net.h> +#include <linux/mii.h> +#include <miiphy.h> +#include <config.h>
drivers/net/Makefile line 28
Quoted 10 lines
drivers/net/Makefile +10
-0+#include "ax88183.h" + +static int ax88183_init(bd_t *bd) +{ + volatile unsigned int tmp; + int i; + + /* reset chip */ + tmp = CR; + CR = (tmp & ~CR_CHIP_RESET);
u-boot does not not accept anymore to write/read into registers using offsets and volatile variables. Please define an appropriate structure for your chip, and use read/write accessors to work with registers. This must be fixed globally in all your code.
I do not know this chip. However, u-boot has already a ax88180 driver. Would be not possible to modify this driver to make it suitable for your chip, too ?
Other remarks: it seems to me your driver does not support CONFIG_MULTI, as it should do. And it must call eth_register() to be inserted as device at runtime. Please check with other network drivers.
drivers/net/Makefile line 41
Quoted 13 lines
drivers/net/Makefile +13
-0+ udelay(1000); + CR = (tmp | CR_CHIP_RESET); + + /* disable interrupt */ + IMSR = IMSR_MASK_ALL; + + /* set mac address*/ + unsigned char mactmp[4]; + unsigned int * mac = (unsigned int *)mactmp; + mactmp[0] = bd->bi_enetaddr[5]; + mactmp[1] = bd->bi_enetaddr[4]; + mactmp[2] = bd->bi_enetaddr[3]; + mactmp[3] = bd->bi_enetaddr[2];
This is not correct anymore. You do not have to set the mac from the bd. Instead of that, you have to provide in your initialization function a struct eth_device that should be passed to eth_register().
drivers/net/Makefile line 49
Quoted 8 lines
drivers/net/Makefile +8
-0+ +int eth_init (bd_t * bd) +{ + + char *s, *e; + int i; + + s = getenv ("ethaddr");
The driver must not call getenv explicitely.
drivers/net/Makefile line 56
Quoted 7 lines
drivers/net/Makefile +7
-0+#if 0 + printf ("\tHW MAC address: " + "%02X:%02X:%02X:%02X:%02X:%02X\n", + bd->bi_enetaddr[0], bd->bi_enetaddr[1], + bd->bi_enetaddr[2], bd->bi_enetaddr[3], + bd->bi_enetaddr[4], bd->bi_enetaddr[5] ); +#endif
do not add dead code. Instead of that, you can use the debug() function to trace.
drivers/net/Makefile line 63
Quoted 7 lines
drivers/net/Makefile +7
-0+/* + *------------------------------------------------------------------------- + * Registers + *------------------------------------------------------------------------- + */ + +#define PCR (*(volatile unsigned int *)(CONFIG_AX88183_BASE + 0x0004))
Replace all defines with a C structure describing your chip.
Best regards,
Stefano Babic
Signature · 5 lines
===================================================================== DENX Software Engineering GmbH, MD: Wolfgang Denk & Detlev Zundel HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany Phone: +49-8142-66989-0 Fax: +49-8142-66989-80 Email: office at denx.de =====================================================================
PATCH 1/1 Driver for AX88183 ethernet chip
Hi Stefano,
Thank you for your advice.It has been changed according to you suggestion and passed the checking of checkpatch.pl (two warnings , one is asm/io.h one is struct eth_device's member function send has a volatile parameter). Although AX88183 has the similar name with AX88180, they are very different.
It works well on my board.I have submitted it again.
Best wishes.
Joe
Quoted 133 lines
Date: Fri, 28 Jan 2011 09:02:38 +0100
From: sbabic at denx.de
To: lgxue at hotmail.com
CC: u-boot at lists.denx.de
Subject: Re: [U-Boot] [PATCH] Driver for AX88183 ethernet chipQuoted 1 line · root
From: Joe Xue <[email protected]>
You have to set you Signe-off-by in your patch. Please add also a commit message to explain what your patch is doing, and on which board you tested this driver. And set the net custodian as CC, this helps to get faster review.
drivers/net/Makefile COBJS-$(CONFIG_TSI108_ETH) += tsi108_eth.o · line 86
Quoted 7 lines
drivers/net/Makefile +1
-0@@ -83,6 +83,7 @@ COBJS-$(CONFIG_TSI108_ETH) += tsi108_eth.o COBJS-$(CONFIG_ULI526X) += uli526x.o COBJS-$(CONFIG_VSC7385_ENET) += vsc7385.o COBJS-$(CONFIG_XILINX_EMACLITE) += xilinx_emaclite.o +COBJS-$(CONFIG_DRIVER_AX88183) += ax88183.oPlease maintain the list sorted.
drivers/net/Makefile line 7
Quoted 8 lines
drivers/net/Makefile +7
-0@@ -0,0 +1,265 @@ + +/* + * (C) Copyright 2010 Joe Xue <[email protected]> + * + * This file is released under the terms of GPL v2 and any later version. + * See the file COPYING in the root directory of the source tree for details. +*/The header is not enough. Please add coherent header with license, as you can see for other drivers. This must be fixed globally.
drivers/net/Makefile line 12
Quoted 5 lines
drivers/net/Makefile +5
-0+ +/* + * This driver works on 32bit mode + * AX88783 has two ethernet ports, we only use port 0 in u-boot + */I suggest you add this comment to the README file, too,
Quoted 6 lines
drivers/net/Makefile +6
-0+#include <common.h> +#include <command.h> +#include <net.h> +#include <linux/mii.h> +#include <miiphy.h> +#include <config.h>drivers/net/Makefile line 28
Quoted 10 lines
drivers/net/Makefile +10
-0+#include "ax88183.h" + +static int ax88183_init(bd_t *bd) +{ + volatile unsigned int tmp; + int i; + + /* reset chip */ + tmp = CR; + CR = (tmp & ~CR_CHIP_RESET);u-boot does not not accept anymore to write/read into registers using offsets and volatile variables. Please define an appropriate structure for your chip, and use read/write accessors to work with registers. This must be fixed globally in all your code.
I do not know this chip. However, u-boot has already a ax88180 driver. Would be not possible to modify this driver to make it suitable for your chip, too ?
Other remarks: it seems to me your driver does not support
CONFIG_MULTI, as it should do. And it must calleth_register()to be inserted as device at runtime. Please check with other network drivers.drivers/net/Makefile line 41
Quoted 13 lines
drivers/net/Makefile +13
-0+ udelay(1000); + CR = (tmp | CR_CHIP_RESET); + + /* disable interrupt */ + IMSR = IMSR_MASK_ALL; + + /* set mac address*/ + unsigned char mactmp[4]; + unsigned int * mac = (unsigned int *)mactmp; + mactmp[0] = bd->bi_enetaddr[5]; + mactmp[1] = bd->bi_enetaddr[4]; + mactmp[2] = bd->bi_enetaddr[3]; + mactmp[3] = bd->bi_enetaddr[2];This is not correct anymore. You do not have to set the mac from the bd. Instead of that, you have to provide in your initialization function a struct
eth_devicethat should be passed toeth_register().drivers/net/Makefile line 49
Quoted 8 lines
drivers/net/Makefile +8
-0+ +int eth_init (bd_t * bd) +{ + + char *s, *e; + int i; + + s = getenv ("ethaddr");The driver must not call getenv explicitely.
drivers/net/Makefile line 56
Quoted 7 lines
drivers/net/Makefile +7
-0+#if 0 + printf ("\tHW MAC address: " + "%02X:%02X:%02X:%02X:%02X:%02X\n", + bd->bi_enetaddr[0], bd->bi_enetaddr[1], + bd->bi_enetaddr[2], bd->bi_enetaddr[3], + bd->bi_enetaddr[4], bd->bi_enetaddr[5] ); +#endifdo not add dead code. Instead of that, you can use the
debug()function to trace.drivers/net/Makefile line 63
Quoted 7 lines
drivers/net/Makefile +7
-0+/* + *------------------------------------------------------------------------- + * Registers + *------------------------------------------------------------------------- + */ + +#define PCR (*(volatile unsigned int *)(CONFIG_AX88183_BASE + 0x0004))Replace all defines with a C structure describing your chip.
Best regards,
Stefano BabicSignature · 5 lines
===================================================================== DENX Software Engineering GmbH, MD: Wolfgang Denk & Detlev Zundel HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany Phone: +49-8142-66989-0 Fax: +49-8142-66989-80 Email: office at denx.de =====================================================================