usb: eth: introduce Moschip MCS7830 driver
Subsystems (7)
v2 cover usb: eth: introduce Moschip MCS7830 driver
this series
- does a little cleanup: BIT() and BITMASK() macros in common.h, no #ifdef for routine declarations in header files
- adds a new USB ethernet driver for adapters that are based on the MCS7730/7830/7832 chips
- enables the driver for those boards which previously had support for "all other" USB ethernet adapters
- updates the README.usb documentation file to list all available drivers for USB ethernet adapters
development and tests were done on a taskit stamp9g20 with Delock and Logilink adapters, running TFTP transfers of a file as large as RAM is
there are several checkpatch warnings
- about CamelCase for NetReceive() and USB related structure members, which cannot get fixed as the names are in the established API
- about a multiple assignment for the "found" flags in the USB endpoint search, which I consider acceptable
version v2 addresses all received feedback:
- adjust the Cc: list (network custodian, BIT() macro committers, board maintainers)
- move the BIT() macro to the common.h header file
- reduce the number of timeouts, only "USB call" and "network link status" timeouts are left
- use errno.h codes instead of the unhelpful "-1" magic number
- factor out common PHY access code, fix the retry logic
- more straight forward init() callback and link status check, silent operation according to the U-Boot philosophy
- remove text fold markers
- kernel nano-doc style comments for data structures, global variables, and routines
- remove #ifdef from function prototypes in header files
- whitespace fixes (in the USB dongle list comments)
- switch the USB dongle list from sentinel terminated to "dense, useful data only" and iterate by means of ARRAY_SIZE()
- remove an ugly and non-obvious "unused" silencer, instead use the __maybe_unused decoration near the implementation
Gerhard Sittig (7):
include: move the BIT() macro into the common.h header file
usb: eth: don't ifdef routine declarations in usb_ether.h
usb: eth: introduce support for Moschip USB ethernet
config: alpha-sort USB ethernet items for Asix and SMSC
config: enable Moschip USB ethernet support for several boards
config: enable USB ethernet for taskit stamp9g20
usb: doc: update README.usb to list all USB ethernet options
arch/arm/cpu/arm1176/tnetv107x/clock.c | 2 - arch/arm/cpu/arm926ejs/davinci/cpu.c | 2 - arch/arm/include/asm/arch-am33xx/cpu.h | 3 +- arch/arm/include/asm/arch-ixp/ixp425.h | 2 +- arch/arm/include/asm/arch-omap5/cpu.h | 4 +- arch/arm/include/asm/arch-tegra20/dc.h | 4 +- doc/README.usb | 13 +- drivers/mtd/nand/jz4740_nand.c | 1 - drivers/net/cpsw.c | 1 - drivers/net/npe/include/IxOsalOsIxp400.h | 2 +- drivers/spi/andes_spi.h | 4 +- drivers/spi/davinci_spi.h | 4 +- drivers/usb/eth/Makefile | 1 + drivers/usb/eth/mcs7830.c | 850 ++++++++++++++++++++++++++++++ drivers/usb/eth/usb_ether.c | 7 + include/common.h | 3 + include/configs/harmony.h | 3 +- include/configs/m53evk.h | 1 + include/configs/mx53loco.h | 1 + include/configs/nitrogen6x.h | 1 + include/configs/omap3_beagle.h | 3 +- include/configs/stamp9g20.h | 5 +- include/usb_ether.h | 14 +- 23 files changed, 903 insertions(+), 28 deletions(-) create mode 100644 drivers/usb/eth/mcs7830.c
Signature · 1 line
1.7.10.4
PATCH v2 1/7 include: move the BIT() macro into the common.h header file
several compile units and local header files re-invented the BIT() macro, move BIT() and BITMASK() declarations into the common.h header file and adjust call sites
--- arch/arm/cpu/arm1176/tnetv107x/clock.c | 2 -- arch/arm/cpu/arm926ejs/davinci/cpu.c | 2 -- arch/arm/include/asm/arch-am33xx/cpu.h | 3 ++- arch/arm/include/asm/arch-ixp/ixp425.h | 2 +- arch/arm/include/asm/arch-omap5/cpu.h | 4 ++-- arch/arm/include/asm/arch-tegra20/dc.h | 4 ++-- drivers/mtd/nand/jz4740_nand.c | 1 - drivers/net/cpsw.c | 1 - drivers/net/npe/include/IxOsalOsIxp400.h | 2 +- drivers/spi/andes_spi.h | 4 ++-- drivers/spi/davinci_spi.h | 4 ++-- include/common.h | 3 +++ 12 files changed, 15 insertions(+), 17 deletions(-)
arch/arm/cpu/arm1176/tnetv107x/clock.c +0 -2
@@ -13,8 +13,6 @@#define CLOCK_BASE TNETV107X_CLOCK_CONTROL_BASE#define PSC_BASE TNETV107X_PSC_BASE -#define BIT (x) (1 << (x)) -#define MAX_PREDIV 64#define MAX_POSTDIV 8#define MAX_MULT 512
arch/arm/cpu/arm926ejs/davinci/cpu.c +0 -2
@@ -28,8 +28,6 @@ DECLARE_GLOBAL_DATA_PTR;#define PLLC_PLLDIV8 0x170#define PLLC_PLLDIV9 0x174 -#define BIT (x) (1 << (x)) -/* SOC-specific pll info */ #ifdef CONFIG_SOC_DM355 #define ARM_PLLDIV PLLC_PLLDIV1
arch/arm/include/asm/arch-am33xx/cpu.h +2 -1
@@ -11,13 +11,14 @@#ifndef _AM33XX_CPU_H#define _AM33XX_CPU_H +#include <common.h> +#if !(defined(__KERNEL_STRICT_NAMES) || defined(__ASSEMBLY__))#include <asm/types.h> #endif /* !(__KERNEL_STRICT_NAMES || __ASSEMBLY__) */ #include <asm/arch/hardware.h> -#define BIT (x) (1 << x)#define CL_BIT (x) (0 << x)/* Timer register bits */
arch/arm/include/asm/arch-ixp/ixp425.h +1 -1
@@ -14,7 +14,7 @@#ifndef _ASM_ARM_IXP425_H_#define _ASM_ARM_IXP425_H_ -#define BIT (x) (1<<(x)) +#include <common.h> /* FIXME: Only this does work for u-boot... find out why... [RS] */ #define UBOOT_REG_FIX 1
arch/arm/include/asm/arch-omap5/cpu.h +2 -2
@@ -10,6 +10,8 @@#ifndef _CPU_H#define _CPU_H +#include <common.h> +#if !(defined(__KERNEL_STRICT_NAMES) || defined(__ASSEMBLY__))#include <asm/types.h> #endif /* !(__KERNEL_STRICT_NAMES || __ASSEMBLY__) */
@@ -99,8 +101,6 @@ struct watchdog {#endif /* __ASSEMBLY__ */ #endif /* __KERNEL_STRICT_NAMES */ -#define BIT (x) (1 << (x)) -#define WD_UNLOCK1 0xAAAA#define WD_UNLOCK2 0x5555
arch/arm/include/asm/arch-tegra20/dc.h +2 -2
@@ -8,6 +8,8 @@#ifndef __ASM_ARCH_TEGRA_DC_H#define __ASM_ARCH_TEGRA_DC_H +#include <common.h> +/* Register definitions for the Tegra display controller */ /* CMD register 0x000 ~ 0x43 */
@@ -351,8 +353,6 @@ struct dc_ctlr {struct dc_winbuf_reg winbuf;/* WINBUF A/B/C 0x800 ~ 0x80a */ }; -#define BIT (pos) (1U << pos) -/* DC_CMD_DISPLAY_COMMAND 0x032 */ #define CTRL_MODE_SHIFT 5#define CTRL_MODE_MASK (0x3 << CTRL_MODE_SHIFT)
drivers/mtd/nand/jz4740_nand.c +0 -1
@@ -16,7 +16,6 @@#define JZ_NAND_CMD_ADDR (JZ_NAND_DATA_ADDR + 0x8000)#define JZ_NAND_ADDR_ADDR (JZ_NAND_DATA_ADDR + 0x10000) -#define BIT (x) (1 << (x))#define JZ_NAND_ECC_CTRL_ENCODING BIT(3)#define JZ_NAND_ECC_CTRL_RS BIT(2)#define JZ_NAND_ECC_CTRL_RESET BIT(1)
drivers/net/cpsw.c +0 -1
@@ -26,7 +26,6 @@#include <phy.h> #include <asm/arch/cpu.h> -#define BITMASK (bits) (BIT(bits) - 1)#define PHY_REG_MASK 0x1f#define PHY_ID_MASK 0x1f#define NUM_DESCS (PKTBUFSRX * 2)
drivers/net/npe/include/IxOsalOsIxp400.h +1 -1
@@ -23,7 +23,7 @@#ifndef IxOsalOsIxp400_H#define IxOsalOsIxp400_H -#define BIT (x) (1<<(x)) +#include <common.h> #define IXP425_EthA_BASE 0xc8009000#define IXP425_EthB_BASE 0xc800a000
drivers/spi/andes_spi.h +2 -2
@@ -10,6 +10,8 @@ #ifndef __ANDES_SPI_H #define __ANDES_SPI_H +#include <common.h> + struct andes_spi_regs { unsigned int apb; /* 0x00 - APB SPI interface setting */ unsigned int pio; /* 0x04 - PIO reg */
@@ -23,8 +25,6 @@ struct andes_spi_regs {unsigned int ver;/* 0x3c - SPI version reg */ }; -#define BIT (x) (1 << (x)) -/* 0x00 - APB SPI interface setting register */ #define ANDES_SPI_APB_BAUD (x) (((x) & 0xff) < 0)#define ANDES_SPI_APB_CSHT (x) (((x) & 0xf) < 16)
drivers/spi/davinci_spi.h +2 -2
@@ -9,6 +9,8 @@ #ifndef _DAVINCI_SPI_H_ #define _DAVINCI_SPI_H_ +#include <common.h> + struct davinci_spi_regs { dv_reg gcr0; /* 0x00 */ dv_reg gcr1; /* 0x04 */
@@ -36,8 +38,6 @@ struct davinci_spi_regs {dv_reg intvec1;/* 0x64 */ }; -#define BIT (x) (1 << (x)) -/* SPIGCR0 */ #define SPIGCR0_SPIENA_MASK 0x1#define SPIGCR0_SPIRST_MASK 0x0
include/common.h +3 -0
@@ -967,6 +967,9 @@ static inline phys_addr_t map_to_sysmem(const void *ptr)#define ALIGN (x,a) __ALIGN_MASK((x),(typeof(x))(a)-1)#define __ALIGN_MASK (x,mask) (((x)+(mask))&~(mask)) +#define BIT (n) (1U << (n)) +#define BITMASK (bits) (BIT(bits) - 1) +/* * ARCH_DMA_MINALIGN is defined in asm/cache.h for each architecture. It * is used to align DMA buffers.
Signature · 1 line
1.7.10.4
PATCH v2 1/7 include: move the BIT() macro into the common.h header file
Dear Gerhard Sittig,
Quoted 3 lines · In message <[email protected]> you wrote:
several compile units and local header files re-invented the
BIT()macro, moveBIT()andBITMASK()declarations into thecommon.hheader file and adjust call sites
...
include/common.h static inline phys_addr_t map_to_sysmem(const void *ptr) · line 972
Quoted 11 lines
include/common.h +3
-0@@ -967,6 +967,9 @@ static inline phys_addr_t map_to_sysmem(const void *ptr)#define ALIGN (x,a) __ALIGN_MASK((x),(typeof(x))(a)-1)#define __ALIGN_MASK (x,mask) (((x)+(mask))&~(mask)) +#define BIT (n) (1U << (n)) +#define BITMASK (bits) (BIT(bits) - 1) +
I'm sorry, but these macros are ugly and make the code harder to read. Also, they are inherently non-portable. I guess you are not aware that "bit 0" is the MSB on Power architecture, not the LSB as you expect in your definition.
I strongly reommend NOT to use any such macros. Adding these to common.h could be considered as an invitation to use them, which is the opposite of what I want.
So sorry, but this is a clear NAK.
Best regards,
Wolfgang Denk
Signature · 4 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 Anything free is worth what you pay for it.
PATCH v2 1/7 include: move the BIT() macro into the common.h header file
Quoted 25 lines · Wolfgang Denk
Dear Gerhard Sittig,
Quoted 3 lines · In message <[email protected]> you wrote:
several compile units and local header files re-invented the
BIT()macro, moveBIT()andBITMASK()declarations into thecommon.hheader file and adjust call sites...
include/common.h static inline phys_addr_t map_to_sysmem(const void *ptr) · line 972
Quoted 11 lines
include/common.h +3
-0@@ -967,6 +967,9 @@ static inline phys_addr_t map_to_sysmem(const void *ptr)#define ALIGN (x,a) __ALIGN_MASK((x),(typeof(x))(a)-1)#define __ALIGN_MASK (x,mask) (((x)+(mask))&~(mask)) +#define BIT (n) (1U << (n)) +#define BITMASK (bits) (BIT(bits) - 1) +I'm sorry, but these macros are ugly and make the code harder to read. Also, they are inherently non-portable. I guess you are not aware that "bit 0" is the MSB on Power architecture, not the LSB as you expect in your definition.
Quoted 5 lines
I strongly reommend NOT to use any such macros. Adding these to
common.hcould be considered as an invitation to use them, which is the opposite of what I want.So sorry, but this is a clear NAK.
That's fine with me. So this patch can get dropped and nothing changes for the existing code base.
The MCS7830 driver will then need a respin (after I took in some more feedback, of course). There was the question of whether to use the BIT(5) macro or re-invented (1 << 5) or 0x20 numbers. The feedback now allows a clear answer. :)
virtually yours
Gerhard Sittig
Signature · 3 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: [email protected]
PATCH v2 2/7 usb: eth: don't ifdef routine declarations in usb_ether.h
In reply to Gerhard Sittigwhile compilation of implemented routines and references from calling sites may be optional, declarations in header files should not be
unconditionally declare the Asix and SMSC related public USB ethernet driver routines in the usb_ether.h header file
--- include/usb_ether.h | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-)
include/usb_ether.h +2 -6
@@ -40,23 +40,19 @@ struct ueth_data { };/* -* Function definitions for each USB ethernet driver go here, bracketed by -* #ifdef CONFIG_USB_ETHER_xxx...#endif +* Function definitions for each USB ethernet driver go here +* (declaration is unconditional, compilation is conditional) */ -#ifdef CONFIG_USB_ETHER_ASIX void asix_eth_before_probe (void );int asix_eth_probe (struct usb_device *dev,unsigned int ifnum,struct ueth_data *ss);int asix_eth_get_info (struct usb_device *dev,struct ueth_data *ss,struct eth_device *eth); -#endif -#ifdef CONFIG_USB_ETHER_SMSC95XX void smsc95xx_eth_before_probe (void );int smsc95xx_eth_probe (struct usb_device *dev,unsigned int ifnum,struct ueth_data *ss);int smsc95xx_eth_get_info (struct usb_device *dev,struct ueth_data *ss,struct eth_device *eth); -#endif #endif /* __USB_ETHER_H__ */
Signature · 1 line
1.7.10.4
PATCH v2 2/7 usb: eth: don't ifdef routine declarations in usb_ether.h
Quoted 8 lines · Gerhard Sittig
while compilation of implemented routines and references from calling sites may be optional, declarations in header files should not be
unconditionally declare the Asix and SMSC related public USB ethernet driver routines in the
usb_ether.hheader fileCc Simon Glass <[email protected]>Signed-off-by Gerhard Sittig <[email protected]>
PATCH v2 3/7 usb: eth: introduce support for Moschip USB ethernet
In reply to Gerhard Sittigintroduce an 'mcs7830' driver for Moschip based USB ethernet adapters, which was implemented based on the U-Boot Asix driver with additional information gathered from the Moschip Linux driver
--- drivers/usb/eth/Makefile | 1 + drivers/usb/eth/mcs7830.c | 850 +++++++++++++++++++++++++++++++++++++++++++ drivers/usb/eth/usb_ether.c | 7 + include/usb_ether.h | 6 + 4 files changed, 864 insertions(+) create mode 100644 drivers/usb/eth/mcs7830.c
drivers/usb/eth/Makefile +1 -0
@@ -8,4 +8,5 @@ obj-$(CONFIG_USB_HOST_ETHER) += usb_ether.o ifdef CONFIG_USB_ETHER_ASIX obj-y += asix.o endif +obj-$(CONFIG_USB_ETHER_MCS7830) += mcs7830.o obj-$(CONFIG_USB_ETHER_SMSC95XX) += smsc95xx.o
drivers/usb/eth/mcs7830.c new file +850 -0
850 lines not on this page · raw message
drivers/usb/eth/usb_ether.c +7 -0
@@ -30,6 +30,13 @@ static const struct usb_eth_prob_dev prob_dev[] = { .get_info = asix_eth_get_info, },#endif +#ifdef CONFIG_USB_ETHER_MCS7830 + { + .before_probe = mcs7830_eth_before_probe, + .probe = mcs7830_eth_probe, + .get_info = mcs7830_eth_get_info, + }, +#endif #ifdef CONFIG_USB_ETHER_SMSC95XX { .before_probe = smsc95xx_eth_before_probe,
include/usb_ether.h +6 -0
@@ -49,6 +49,12 @@ int asix_eth_probe(struct usb_device *dev, unsigned int ifnum,int asix_eth_get_info (struct usb_device *dev,struct ueth_data *ss,struct eth_device *eth); +void mcs7830_eth_before_probe (void ); +int mcs7830_eth_probe (struct usb_device *dev,unsigned int ifnum, +struct ueth_data *ss); +int mcs7830_eth_get_info (struct usb_device *dev,struct ueth_data *ss, +struct eth_device *eth); +void smsc95xx_eth_before_probe (void );int smsc95xx_eth_probe (struct usb_device *dev,unsigned int ifnum,struct ueth_data *ss);
Signature · 1 line
1.7.10.4
PATCH v2 3/7 usb: eth: introduce support for Moschip USB ethernet
On Monday, February 17, 2014 at 08:35:23 PM, Gerhard Sittig wrote:
[...]
Quoted 13 lines
drivers/usb/eth/mcs7830.c new file +13
-0+int mcs7830_eth_get_info (struct usb_device *dev,struct ueth_data *ss, +struct eth_device *eth) +{ +debug ("%s()\n" , __func__); +if (!eth) { +debug ("%s: missing parameter.\n" , __func__); +return 0 ; + } + +snprintf (eth->name,sizeof (eth->name),"%s%d" , +MCS7830_BASE_NAME , mcs7830_iface_idx++); + eth->init = mcs7830_init; + eth->send = mcs7830_send;
drivers/usb/eth/mcs7830.c line 842
Quoted 10 lines
drivers/usb/eth/mcs7830.c new file +10
-0+ eth->recv = mcs7830_recv; + eth->halt = mcs7830_halt; + eth->write_hwaddr = mcs7830_write_mac; + eth->priv = ss; + +if (mcs7830_basic_reset (ss)) +return 0 ; + +#ifdef DEBUG + (void )mcs7830_read_config (eth);
So this is debug-only function? You might want to put the entire function into #ifdef DEBUG and then have an #else , where you define the function as an empty one. The GCC shall handle the rest then as well, but you won't have this ugly ifdef in a function.
[...]
Best regards,
Marek Vasut
PATCH v2 3/7 usb: eth: introduce support for Moschip USB ethernet
Quoted 25 lines · Marek Vasut
On Monday, February 17, 2014 at 08:35:23 PM, Gerhard Sittig wrote:
[...]
Quoted 20 lines
drivers/usb/eth/mcs7830.c new file +20
-0+int mcs7830_eth_get_info (struct usb_device *dev,struct ueth_data *ss, +struct eth_device *eth) +{ +debug ("%s()\n" , __func__); +if (!eth) { +debug ("%s: missing parameter.\n" , __func__); +return 0 ; + } + +snprintf (eth->name,sizeof (eth->name),"%s%d" , +MCS7830_BASE_NAME , mcs7830_iface_idx++); + eth->init = mcs7830_init; + eth->send = mcs7830_send; + eth->recv = mcs7830_recv; + eth->halt = mcs7830_halt; + eth->write_hwaddr = mcs7830_write_mac; + eth->priv = ss; + +if (mcs7830_basic_reset (ss)) +return 0 ;
Quoted 8 lines
drivers/usb/eth/mcs7830.c line 842
Quoted 3 lines
drivers/usb/eth/mcs7830.c new file +3
-0+ +#ifdef DEBUG + (void )mcs7830_read_config (eth);So this is debug-only function? You might want to put the entire function into #ifdef DEBUG and then have an #else , where you define the function as an empty one. The GCC shall handle the rest then as well, but you won't have this ugly ifdef in a function.
I thought about this for a while.
Usually you'd expect separate control and status registers in hardware. Where you write to control, and read back from status. Here those two aspects appear to have been mixed into one "config" register, and only in hindsight the reading became unused. It's not so much an intent, but more of a byproduct.
During development (before the driver became operational), I could not tell whether I had to read-modify-write that config register. Following the Linux driver's approach, currently only fixed values get written to the adapter and nothing gets read back.
Later the shadow in the driver's private data was introduced, such that "updates" neither need to read back what was written before. And since neither multicast nor promiscuous mode may apply to bootloader operation, even those updates may never need not occur.
In the meantime I'd even tend to support the removal of the config register read routine. Adding code "just in case" is a programmer's sin that may not be acceptable in U-Boot, since the cost outweights the benefit.
The current implementation (v3, with "maybe unused" decoration) might be acceptable. But should feedback suggest that v4 is needed, I will remove that routine as well.
virtually yours
Gerhard Sittig
Signature · 3 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 v2 3/7 usb: eth: introduce support for Moschip USB ethernet
Quoted 54 lines · Gerhard Sittig
Quoted 24 lines · Marek Vasut
On Monday, February 17, 2014 at 08:35:23 PM, Gerhard Sittig wrote:
[...]
Quoted 20 lines
drivers/usb/eth/mcs7830.c new file +20
-0+int mcs7830_eth_get_info (struct usb_device *dev,struct ueth_data *ss, +struct eth_device *eth) +{ +debug ("%s()\n" , __func__); +if (!eth) { +debug ("%s: missing parameter.\n" , __func__); +return 0 ; + } + +snprintf (eth->name,sizeof (eth->name),"%s%d" , +MCS7830_BASE_NAME , mcs7830_iface_idx++); + eth->init = mcs7830_init; + eth->send = mcs7830_send; + eth->recv = mcs7830_recv; + eth->halt = mcs7830_halt; + eth->write_hwaddr = mcs7830_write_mac; + eth->priv = ss; + +if (mcs7830_basic_reset (ss)) +return 0 ;Quoted 8 lines
drivers/usb/eth/mcs7830.c line 842
Quoted 3 lines
drivers/usb/eth/mcs7830.c new file +3
-0+ +#ifdef DEBUG + (void )mcs7830_read_config (eth);So this is debug-only function? You might want to put the entire function into #ifdef DEBUG and then have an #else , where you define the function as an empty one. The GCC shall handle the rest then as well, but you won't have this ugly ifdef in a function.
I thought about this for a while.
Usually you'd expect separate control and status registers in hardware. Where you write to control, and read back from status. Here those two aspects appear to have been mixed into one "config" register, and only in hindsight the reading became unused. It's not so much an intent, but more of a byproduct.
During development (before the driver became operational), I could not tell whether I had to read-modify-write that config register. Following the Linux driver's approach, currently only fixed values get written to the adapter and nothing gets read back.
Later the shadow in the driver's private data was introduced, such that "updates" neither need to read back what was written before. And since neither multicast nor promiscuous mode may apply to bootloader operation, even those updates may never need not occur.
Quoted 8 lines
In the meantime I'd even tend to support the removal of the config register read routine. Adding code "just in case" is a programmer's sin that may not be acceptable in U-Boot, since the cost outweights the benefit.
The current implementation (v3, with "maybe unused" decoration) might be acceptable. But should feedback suggest that v4 is needed, I will remove that routine as well.
If you feel like removing the routine, then please remove it .
Best regards,
Marek Vasut
PATCH v2 3/7 usb: eth: introduce support for Moschip USB ethernet
In reply to Gerhard SittigDear Gerhard,
Quoted 3 lines · In message <[email protected]> you wrote:
introduce an 'mcs7830' driver for Moschip based USB ethernet adapters, which was implemented based on the U-Boot Asix driver with additional information gathered from the Moschip Linux driver
...
drivers/usb/eth/mcs7830.c line 58
Quoted 7 lines
drivers/usb/eth/mcs7830.c new file +7
-0+/* bit masks and default values for the above registers */ +#define PHY_CMD1_READ BIT(6) +#define PHY_CMD1_WRITE BIT(5) +#define PHY_CMD1_PHYADDR BIT(0) + +#define PHY_CMD2_PEND BIT(7) +#define PHY_CMD2_READY BIT(6)
...
As mentioned in patch # 1, I object against the use of these obfuscating BIT() macros. Please do not use these; use plain readable code, that leaves no ambiguities to the reader.
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 Just because your doctor has a name for your condition doesn't mean he knows what it is.
PATCH v2 3/7 usb: eth: introduce support for Moschip USB ethernet
Quoted 19 lines · Wolfgang Denk
Dear Gerhard,
Quoted 3 lines · In message <[email protected]> you wrote:
introduce an 'mcs7830' driver for Moschip based USB ethernet adapters, which was implemented based on the U-Boot Asix driver with additional information gathered from the Moschip Linux driver
...
Quoted 7 lines
drivers/usb/eth/mcs7830.c new file +7
-0+/* bit masks and default values for the above registers */ +#define PHY_CMD1_READ BIT(6) +#define PHY_CMD1_WRITE BIT(5) +#define PHY_CMD1_PHYADDR BIT(0) + +#define PHY_CMD2_PEND BIT(7) +#define PHY_CMD2_READY BIT(6)...
Quoted 3 lines
As mentioned in patch # 1, I object against the use of these obfuscating
BIT()macros. Please do not use these; use plain readable code, that leaves no ambiguities to the reader.
Just to chime in real quick, Linux uses these 'BIT()' macros, but I personally have no hard feelings about them either way.
Best regards,
Marek Vasut
PATCH v2 3/7 usb: eth: introduce support for Moschip USB ethernet
Dear Marek,
Quoted 10 lines · In message <[email protected]> you wrote:
Quoted 10 lines
Quoted 7 lines
drivers/usb/eth/mcs7830.c new file +6
-0+#define PHY_CMD1_READ BIT(6) +#define PHY_CMD1_WRITE BIT(5) +#define PHY_CMD1_PHYADDR BIT(0) + +#define PHY_CMD2_PEND BIT(7) +#define PHY_CMD2_READY BIT(6)...
Quoted 6 lines
Quoted 3 lines
As mentioned in patch # 1, I object against the use of these obfuscating
BIT()macros. Please do not use these; use plain readable code, that leaves no ambiguities to the reader.Just to chime in real quick, Linux uses these '
BIT()' macros, but I personally have no hard feelings about them either way.
Yes, certain developers have been using this style before. This does not make it any better. Fact is, that I have no way to tell what the code means. BIT(0) can be expected to have any of the following
meanings: 0x01, 0x80, 0x8000, 0x80000000, ... So I always have to look up the macro definition first, before I can unerstand it. And then I have to compute in my head what the number actually means.
Compare: BIT(6) or 0x40 - what is easier to write, to read, and to understand?
You dump a register - either with the BDI, or with some printf(). You get 0x27051956. Is BIT(17) set? Is bit 0x00020000 set? Which of these questions is easier to answer (even when you are sure that this is on a system where bit no. 0 is the LSB)?
It's all about writing portable and maintainable code.
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 "I've finally learned what `upward compatible' means. It means we get to keep all our old mistakes." - Dennie van Tassel
PATCH v2 3/7 usb: eth: introduce support for Moschip USB ethernet
Hello Wolfgang,
Quoted 26 lines
Dear Marek,
Quoted 9 lines · In message <[email protected]> you wrote:
Quoted 9 lines
Quoted 6 lines
drivers/usb/eth/mcs7830.c new file +6
-0+#define PHY_CMD1_READ BIT(6) +#define PHY_CMD1_WRITE BIT(5) +#define PHY_CMD1_PHYADDR BIT(0) + +#define PHY_CMD2_PEND BIT(7) +#define PHY_CMD2_READY BIT(6)...
Quoted 6 lines
Quoted 3 lines
As mentioned in patch # 1, I object against the use of these obfuscating
BIT()macros. Please do not use these; use plain readable code, that leaves no ambiguities to the reader.Just to chime in real quick, Linux uses these '
BIT()' macros, but I personally have no hard feelings about them either way.Yes, certain developers have been using this style before. This does not make it any better. Fact is, that I have no way to tell what the code means. BIT(0) can be expected to have any of the following
meanings:0x01,0x80,0x8000,0x80000000, ... So I always have to look up the macro definition first, before I can unerstand it. And then I have to compute in my head what the number actually means.
Quoted 2 lines
Compare: BIT(6) or
0x40- what is easier to write, to read, and to understand?
(1 << 6) is easier for me to read honestly, because then I can quickly crosscheck it with the datasheet.
Quoted 4 lines
You dump a register - either with the BDI, or with some
printf(). You get0x27051956. Is BIT(17) set? Is bit0x00020000set? Which of these questions is easier to answer (even when you are sure that this is on a system where bit no. 0 is the LSB)?
You have a point with the endianness here.
Best regards,
Marek Vasut
PATCH v2 4/7 config: alpha-sort USB ethernet items for Asix and SMSC
In reply to Gerhard Sittigadjust the harmony and omap3_beagle board configs to make their CONFIG_USB_ETHER_* items appear in alphabetical order
--- include/configs/harmony.h | 2 +- include/configs/omap3_beagle.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-)
include/configs/harmony.h +1 -1
@@ -61,8 +61,8 @@/* USB networking support */ #define CONFIG_USB_HOST_ETHER -#define CONFIG_USB_ETHER_SMSC95XX #define CONFIG_USB_ETHER_ASIX +#define CONFIG_USB_ETHER_SMSC95XX /* General networking support */ #define CONFIG_CMD_NET
include/configs/omap3_beagle.h +1 -1
@@ -120,8 +120,8 @@#define CONFIG_SYS_USB_EHCI_MAX_ROOT_PORTS 3#define CONFIG_USB_HOST_ETHER -#define CONFIG_USB_ETHER_SMSC95XX #define CONFIG_USB_ETHER_ASIX +#define CONFIG_USB_ETHER_SMSC95XX /* GPIO banks */ #define CONFIG_OMAP3_GPIO_5 /* GPIO128..159 is in GPIO bank 5 */
Signature · 1 line
1.7.10.4
PATCH v2 5/7 config: enable Moschip USB ethernet support for several boards
In reply to Gerhard Sittigenable support for the Moschip USB ethernet adapter for those boards which previously had support for "all other" USB ethernet adapters (that's Asix _and_ SMSC) enabled -- which applies to harmony, m53evk, mx53loco, nitrogen6x, omap3_beagle
--- include/configs/harmony.h | 1 + include/configs/m53evk.h | 1 + include/configs/mx53loco.h | 1 + include/configs/nitrogen6x.h | 1 + include/configs/omap3_beagle.h | 1 + 5 files changed, 5 insertions(+)
include/configs/harmony.h +1 -0
@@ -62,6 +62,7 @@/* USB networking support */ #define CONFIG_USB_HOST_ETHER #define CONFIG_USB_ETHER_ASIX +#define CONFIG_USB_ETHER_MCS7830 #define CONFIG_USB_ETHER_SMSC95XX /* General networking support */
include/configs/m53evk.h +1 -0
@@ -183,6 +183,7 @@#define CONFIG_USB_STORAGE #define CONFIG_USB_HOST_ETHER #define CONFIG_USB_ETHER_ASIX +#define CONFIG_USB_ETHER_MCS7830 #define CONFIG_USB_ETHER_SMSC95XX #define CONFIG_MXC_USB_PORT 1#define CONFIG_MXC_USB_PORTSC (PORT_PTS_UTMI | PORT_PTS_PTW)
include/configs/mx53loco.h +1 -0
@@ -65,6 +65,7 @@#define CONFIG_USB_STORAGE #define CONFIG_USB_HOST_ETHER #define CONFIG_USB_ETHER_ASIX +#define CONFIG_USB_ETHER_MCS7830 #define CONFIG_USB_ETHER_SMSC95XX #define CONFIG_MXC_USB_PORT 1#define CONFIG_MXC_USB_PORTSC (PORT_PTS_UTMI | PORT_PTS_PTW)
include/configs/nitrogen6x.h +1 -0
@@ -115,6 +115,7 @@#define CONFIG_USB_STORAGE #define CONFIG_USB_HOST_ETHER #define CONFIG_USB_ETHER_ASIX +#define CONFIG_USB_ETHER_MCS7830 #define CONFIG_USB_ETHER_SMSC95XX #define CONFIG_USB_MAX_CONTROLLER_COUNT 2#define CONFIG_EHCI_HCD_INIT_AFTER_RESET /* For OTG port */
include/configs/omap3_beagle.h +1 -0
@@ -121,6 +121,7 @@#define CONFIG_SYS_USB_EHCI_MAX_ROOT_PORTS 3#define CONFIG_USB_HOST_ETHER #define CONFIG_USB_ETHER_ASIX +#define CONFIG_USB_ETHER_MCS7830 #define CONFIG_USB_ETHER_SMSC95XX /* GPIO banks */
Signature · 1 line
1.7.10.4
PATCH v2 6/7 config: enable USB ethernet for taskit stamp9g20
In reply to Gerhard Sittigenabling CONFIG_MACB makes other locations in the stamp config file enable network related commands (actually prevents disabling them)
enable USB ethernet support by activating generic support as well as Asix and Moschip ethernet adapters
--- include/configs/stamp9g20.h | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
include/configs/stamp9g20.h +4 -1
@@ -140,7 +140,10 @@* can enable it here if your baseboard features ethernet. */ -/* #define CONFIG_MACB */ +#define CONFIG_MACB +#define CONFIG_USB_HOST_ETHER +#define CONFIG_USB_ETHER_ASIX +#define CONFIG_USB_ETHER_MCS7830 #ifdef CONFIG_MACB # define CONFIG_RMII /* use reduced MII inteface */
Signature · 1 line
1.7.10.4
PATCH v2 7/7 usb: doc: update README.usb to list all USB ethernet options
In reply to Gerhard Sittig- extend the discussion of USB network related config options such that all available adapter drivers are listed, and that the 'usb' command for the interactive prompt and scripting becomes available
- suggest to *not* put individual IP configuration parameters into the exectuable, but instead to put them into external environment or fetch them from network
--- doc/README.usb | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-)
doc/README.usb +11 -2
@@ -127,8 +127,14 @@ To enable USB Host Ethernet in U-Boot, your platform must of course support USB with CONFIG_CMD_USB enabled and working. You will need to add some config settings to your board header file: +#define CONFIG_CMD_USB /* the 'usb' interactive command */ #define CONFIG_USB_HOST_ETHER /* Enable USB Ethernet adapters */ -#define CONFIG_USB_ETHER_ASIX /* Asix, or whatever driver(s) you want */ + +and one or more of the following for individual adapter hardware: + +#define CONFIG_USB_ETHER_ASIX +#define CONFIG_USB_ETHER_MCS7830 +#define CONFIG_USB_ETHER_SMSC95XX As with built-in networking, you will also want to enable some network commands, for example:
@@ -148,7 +154,10 @@ settings should start you off: You can also set the default IP address of your board and the server as well as the default file to load when a 'bootp' command is issued. -All of these can be obtained from the bootp server if not set. +However note that encoding these individual network settings into a +common exectuable is discouraged, as it leads to potential conflicts, +and all the parameters can either get stored in the board's external +environment, or get obtained from the bootp server if not set. #define CONFIG_IPADDR 10.0.0.2 (replace with your value) #define CONFIG_SERVERIP 10.0.0.1 (replace with your value)
Signature · 1 line
1.7.10.4