usb: eth: introduce Moschip MCS7830 driver
v3 cover usb: eth: introduce Moschip MCS7830 driver
this series
- 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 was done on a taskit stamp9g20, tests were done on the taskit stamp9g20 as well as wandboard both with Delock and Logilink adapters, transferring a 56MB file several times with TFTP
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 v3
- drops the BIT() macro stuff since it's discouraged (not portable)
- adds change logs to the individual patches for improved review
- picks up some collected ACKs
version v2
- addressed all received feedback, but tried to be too helpful and moved the BIT() macro to a common place, which was NAKed
- had a change log, but kept in the cover letter where Patchwork based workflows would miss it
Gerhard Sittig (6):
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
doc/README.usb | 13 +- drivers/usb/eth/Makefile | 1 + drivers/usb/eth/mcs7830.c | 850 ++++++++++++++++++++++++++++++++++++++++ drivers/usb/eth/usb_ether.c | 7 + 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 +- 11 files changed, 888 insertions(+), 11 deletions(-) create mode 100644 drivers/usb/eth/mcs7830.c
Signature · 1 line
1.7.10.4
PATCH v3 1/6 usb: eth: don't ifdef routine declarations in usb_ether.h
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.h header file
---
v3 changes:
- record Simon's ACK
v2 introduced this patch
v1 did not have this patch
--- 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 v3 2/6 usb: eth: introduce support for Moschip USB ethernet
In reply to Gerhard Sittigintroduce an 'mcs7830' driver for Moschip MCS7830 based (7730/7830/7832) USB 2.0 Ethernet Devices
see "MCS7830 -- USB 2.0 to 10/100M Fast Ethernet Controller" at
http://www.asix.com.tw/products.php?op=pItemdetail&PItemID=109;74;109
the driver was implemented based on the U-Boot Asix driver with additional information gathered from the Moschip Linux driver
---
v3 changes:
- remove BIT() macro use, declare constant numbers for bit masks for improved portability
- re-word the commit message, include a link to the www.asix.com.tw product page, and explictly list the supported chips
v2 changes:
- don't #ifdef function prototypes in header files (the newly introduced mcs7830_*() routines in usb_ether.h)
- remove editor navigation pseudo comments (text fold markers)
- reduce the number of timeout declarations (only USB communication and ethernet link status remaining)
- declare the ethernet adapter register set layout by means of a struct and offsetof() instead of magic register index numbers
- separate the bit mask declarations from the register layout declaration, use the common BIT() macro instead of re-inventing its implementation
- rename register layout and bit field macros to reduce excessive identifier lengths, and to not collide with the global CONFIG_* name space
- introduce kernel nano doc comments for data structures, global variables, and all routines
- improve handling of the list of supported dongles, remove the unused sentinel and iterate by means of ARRAY_SIZE(), fixup whitespace for the Sitecom entry
- decorate the mcs7830_read_config() routine with the "__maybe_unused" attribute instead of forcing a reference by means of "(void)identifier;" just to silence a potential compiler warning
- silent operation of the ethernet link status detection according to U-Boot philosophy, which simplifies the .init() callback code path
- factor out common logic of PHY read/write support (the "emit a request and wait for completion" part), unbreak the retry logic (correct number of iterations)
- use proper errno.h codes, and propagate errors up in the call chain
- adjust the Cc: list
v1 introduced this change
--- 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 v3 3/6 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
---
v3 changes:
- record Simon's ACK
v2 changes:
- adjust the Cc: list
v1 introduced this patch
--- 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 v3 4/6 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
---
v3 is unchanged
v2 changes:
- adjust the Cc: list
v1 introduced this patch
--- 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 v3 5/6 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
---
v3 is unchanged
v2 changes:
- adjust the Cc: list
v1 introduced this patch
--- 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 v3 6/6 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
---
v3 changes:
- record Simon's ACK
v2 changes:
- adjust the Cc: list
v1 introduced this patch
--- 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