* [U-Boot] [PATCH v3 0/6] DM conversion of usb ether gadget
@ 2016-11-17 8:09 Mugunthan V N
2016-11-17 8:09 ` [U-Boot] [PATCH v3 1/6] drivers: usb: gadget: ether: adopt to usb driver model Mugunthan V N
` (6 more replies)
0 siblings, 7 replies; 15+ messages in thread
From: Mugunthan V N @ 2016-11-17 8:09 UTC (permalink / raw)
To: u-boot
This patch series adopts driver model for usb ether gadget
driver. This series is tested with MUSB driver model conversion
on AM335x GP evm and AM335x BBB (logs [1]).
Also pushed a branch for testing [2]
Changes from v2:
* Moved USB ether address from driver hard code to Kconfig entry
* Optimized if check in patch 5/6 as mentioned by Marek Vasut.
Changes from initial version:
* Separated out the usb gadget driver patches from earlier musb
series [3] for testing and submitting of dwc3 dm musb patches.
[1] - http://pastebin.ubuntu.com/23489333/
[2] - git://git.ti.com/~mugunthanvnm/ti-u-boot/mugunth-ti-u-boot.git dm-musb-v3
[3] - http://lists.denx.de/pipermail/u-boot/2016-February/246827.html
Note:
~~~~~
The following checkpatch warning can be ignored as this has to be
fixed all over the file which should be a separate patch.
CHECK: Avoid CamelCase: <configNr>
#297: FILE: drivers/usb/gadget/rndis.c:1157:
+int rndis_set_param_dev(u8 configNr, struct eth_device *dev, int mtu,
total: 0 errors, 0 warnings, 1 checks, 303 lines checked
NOTE: Ignored message types: COMPLEX_MACRO CONSIDER_KSTRTO MINMAX MULTISTATEMENT_MACRO_USE_DO_WHILE NETWORKING_BLOCK_COMMENT_STYLE PREFER_ETHER_ADDR_COPY USLEEP_RANGE
patches/usb_gadget/v3.00/0006-drivers-usb-gadget-ether-rndis-convert-driver-to-ado.patch has style problems, please review.
Mugunthan V N (6):
drivers: usb: gadget: ether: adopt to usb driver model
drivers: usb: gadget: ether: access network_started using local
variable
drivers: usb: gadget: ether: consolidate global devices to single
struct
drivers: usb: gadget: ether: use net device priv to pass usb ether
priv
drivers: usb: gadget: ether: prepare driver for driver model migration
drivers: usb: gadget: ether/rndis: convert driver to adopt device
driver model
drivers/usb/gadget/Kconfig | 4 +
drivers/usb/gadget/ether.c | 315 ++++++++++++++++++++++++++++++++++++---------
drivers/usb/gadget/rndis.c | 13 +-
drivers/usb/gadget/rndis.h | 19 ++-
include/net.h | 7 +
5 files changed, 293 insertions(+), 65 deletions(-)
--
2.11.0.rc1
^ permalink raw reply [flat|nested] 15+ messages in thread
* [U-Boot] [PATCH v3 1/6] drivers: usb: gadget: ether: adopt to usb driver model
2016-11-17 8:09 [U-Boot] [PATCH v3 0/6] DM conversion of usb ether gadget Mugunthan V N
@ 2016-11-17 8:09 ` Mugunthan V N
2016-11-18 19:34 ` Simon Glass
2016-11-17 8:09 ` [U-Boot] [PATCH v3 2/6] drivers: usb: gadget: ether: access network_started using local variable Mugunthan V N
` (5 subsequent siblings)
6 siblings, 1 reply; 15+ messages in thread
From: Mugunthan V N @ 2016-11-17 8:09 UTC (permalink / raw)
To: u-boot
Convert usb ether gadget to adopt usb driver model
Signed-off-by: Mugunthan V N <mugunthanvnm@ti.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
---
drivers/usb/gadget/ether.c | 36 ++++++++++++++++++++++++++++++++++++
1 file changed, 36 insertions(+)
diff --git a/drivers/usb/gadget/ether.c b/drivers/usb/gadget/ether.c
index 497b981129..9bc61186cf 100644
--- a/drivers/usb/gadget/ether.c
+++ b/drivers/usb/gadget/ether.c
@@ -24,6 +24,10 @@
#include "gadget_chips.h"
#include "rndis.h"
+#include <dm.h>
+#include <dm/uclass-internal.h>
+#include <dm/device-internal.h>
+
#define USB_NET_NAME "usb_ether"
#define atomic_read
@@ -101,6 +105,9 @@ struct eth_dev {
struct usb_gadget *gadget;
struct usb_request *req; /* for control responses */
struct usb_request *stat_req; /* for cdc & rndis status */
+#ifdef CONFIG_DM_USB
+ struct udevice *usb_udev;
+#endif
u8 config;
struct usb_ep *in_ep, *out_ep, *status_ep;
@@ -2303,6 +2310,24 @@ fail:
/*-------------------------------------------------------------------------*/
+#ifdef CONFIG_DM_USB
+int dm_usb_init(struct eth_dev *e_dev)
+{
+ struct udevice *dev = NULL;
+ int ret;
+
+ ret = uclass_first_device(UCLASS_USB_DEV_GENERIC, &dev);
+ if (!dev || ret) {
+ error("No USB device found\n");
+ return -ENODEV;
+ }
+
+ e_dev->usb_udev = dev;
+
+ return ret;
+}
+#endif
+
static int usb_eth_init(struct eth_device *netdev, bd_t *bd)
{
struct eth_dev *dev = &l_ethdev;
@@ -2315,7 +2340,14 @@ static int usb_eth_init(struct eth_device *netdev, bd_t *bd)
goto fail;
}
+#ifdef CONFIG_DM_USB
+ if (dm_usb_init(dev)) {
+ error("USB ether not found\n");
+ return -ENODEV;
+ }
+#else
board_usb_init(0, USB_INIT_DEVICE);
+#endif
/* Configure default mac-addresses for the USB ethernet device */
#ifdef CONFIG_USBNET_DEV_ADDR
@@ -2497,7 +2529,11 @@ void usb_eth_halt(struct eth_device *netdev)
}
usb_gadget_unregister_driver(ð_driver);
+#ifdef CONFIG_DM_USB
+ device_remove(dev->usb_udev);
+#else
board_usb_cleanup(0, USB_INIT_DEVICE);
+#endif
}
static struct usb_gadget_driver eth_driver = {
--
2.11.0.rc1
^ permalink raw reply related [flat|nested] 15+ messages in thread
* [U-Boot] [PATCH v3 2/6] drivers: usb: gadget: ether: access network_started using local variable
2016-11-17 8:09 [U-Boot] [PATCH v3 0/6] DM conversion of usb ether gadget Mugunthan V N
2016-11-17 8:09 ` [U-Boot] [PATCH v3 1/6] drivers: usb: gadget: ether: adopt to usb driver model Mugunthan V N
@ 2016-11-17 8:09 ` Mugunthan V N
2016-11-17 8:09 ` [U-Boot] [PATCH v3 3/6] drivers: usb: gadget: ether: consolidate global devices to single struct Mugunthan V N
` (4 subsequent siblings)
6 siblings, 0 replies; 15+ messages in thread
From: Mugunthan V N @ 2016-11-17 8:09 UTC (permalink / raw)
To: u-boot
network_started of struct eth_dev can be accessed using local
variable dev and no reason to access it with the global struct.
Signed-off-by: Mugunthan V N <mugunthanvnm@ti.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
---
drivers/usb/gadget/ether.c | 10 +++++-----
1 file changed, 5 insertions(+), 5 deletions(-)
diff --git a/drivers/usb/gadget/ether.c b/drivers/usb/gadget/ether.c
index 9bc61186cf..71d9252f74 100644
--- a/drivers/usb/gadget/ether.c
+++ b/drivers/usb/gadget/ether.c
@@ -1142,7 +1142,7 @@ static void eth_status_complete(struct usb_ep *ep, struct usb_request *req)
event->bNotificationType, value);
if (event->bNotificationType ==
USB_CDC_NOTIFY_SPEED_CHANGE) {
- l_ethdev.network_started = 1;
+ dev->network_started = 1;
printf("USB network up!\n");
}
}
@@ -1330,7 +1330,7 @@ eth_setup(struct usb_gadget *gadget, const struct usb_ctrlrequest *ctrl)
* that network is working. So we signalize it
* here.
*/
- l_ethdev.network_started = 1;
+ dev->network_started = 1;
debug("USB network up!\n");
goto done_set_intf;
}
@@ -1830,10 +1830,10 @@ static void rndis_control_ack_complete(struct usb_ep *ep,
debug("rndis control ack complete --> %d, %d/%d\n",
req->status, req->actual, req->length);
- if (!l_ethdev.network_started) {
+ if (!dev->network_started) {
if (rndis_get_state(dev->rndis_config)
== RNDIS_DATA_INITIALIZED) {
- l_ethdev.network_started = 1;
+ dev->network_started = 1;
printf("USB RNDIS network up!\n");
}
}
@@ -2389,7 +2389,7 @@ static int usb_eth_init(struct eth_device *netdev, bd_t *bd)
timeout = simple_strtoul(getenv("cdc_connect_timeout"),
NULL, 10) * CONFIG_SYS_HZ;
ts = get_timer(0);
- while (!l_ethdev.network_started) {
+ while (!dev->network_started) {
/* Handle control-c and timeouts */
if (ctrlc() || (get_timer(ts) > timeout)) {
error("The remote end did not respond in time.");
--
2.11.0.rc1
^ permalink raw reply related [flat|nested] 15+ messages in thread
* [U-Boot] [PATCH v3 3/6] drivers: usb: gadget: ether: consolidate global devices to single struct
2016-11-17 8:09 [U-Boot] [PATCH v3 0/6] DM conversion of usb ether gadget Mugunthan V N
2016-11-17 8:09 ` [U-Boot] [PATCH v3 1/6] drivers: usb: gadget: ether: adopt to usb driver model Mugunthan V N
2016-11-17 8:09 ` [U-Boot] [PATCH v3 2/6] drivers: usb: gadget: ether: access network_started using local variable Mugunthan V N
@ 2016-11-17 8:09 ` Mugunthan V N
2016-11-17 8:09 ` [U-Boot] [PATCH v3 4/6] drivers: usb: gadget: ether: use net device priv to pass usb ether priv Mugunthan V N
` (3 subsequent siblings)
6 siblings, 0 replies; 15+ messages in thread
From: Mugunthan V N @ 2016-11-17 8:09 UTC (permalink / raw)
To: u-boot
Consolidate the net device, usb eth device and gadget device
struct to single struct and a single global variable so that the
same can be passed as priv of ethernet driver.
Signed-off-by: Mugunthan V N <mugunthanvnm@ti.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
---
drivers/usb/gadget/ether.c | 53 +++++++++++++++++++++++-----------------------
1 file changed, 26 insertions(+), 27 deletions(-)
diff --git a/drivers/usb/gadget/ether.c b/drivers/usb/gadget/ether.c
index 71d9252f74..16edeead65 100644
--- a/drivers/usb/gadget/ether.c
+++ b/drivers/usb/gadget/ether.c
@@ -141,9 +141,14 @@ struct eth_dev {
*/
/*-------------------------------------------------------------------------*/
-static struct eth_dev l_ethdev;
-static struct eth_device l_netdev;
-static struct usb_gadget_driver eth_driver;
+struct ether_priv {
+ struct eth_dev ethdev;
+ struct eth_device netdev;
+ struct usb_gadget_driver eth_driver;
+};
+
+struct ether_priv eth_priv;
+struct ether_priv *l_priv = ð_priv;
/*-------------------------------------------------------------------------*/
@@ -1848,7 +1853,7 @@ static char rndis_resp_buf[8] __attribute__((aligned(sizeof(__le32))));
static int rndis_control_ack(struct eth_device *net)
{
- struct eth_dev *dev = &l_ethdev;
+ struct eth_dev *dev = &l_priv->ethdev;
int length;
struct usb_request *resp = dev->stat_req;
@@ -1989,7 +1994,7 @@ static int get_ether_addr(const char *str, u8 *dev_addr)
static int eth_bind(struct usb_gadget *gadget)
{
- struct eth_dev *dev = &l_ethdev;
+ struct eth_dev *dev = &l_priv->ethdev;
u8 cdc = 1, zlp = 1, rndis = 1;
struct usb_ep *in_ep, *out_ep, *status_ep = NULL;
int status = -ENOMEM;
@@ -2182,7 +2187,7 @@ autoconf_fail:
/* network device setup */
- dev->net = &l_netdev;
+ dev->net = &l_priv->netdev;
dev->cdc = cdc;
dev->zlp = zlp;
@@ -2330,7 +2335,7 @@ int dm_usb_init(struct eth_dev *e_dev)
static int usb_eth_init(struct eth_device *netdev, bd_t *bd)
{
- struct eth_dev *dev = &l_ethdev;
+ struct eth_dev *dev = &l_priv->ethdev;
struct usb_gadget *gadget;
unsigned long ts;
unsigned long timeout = USB_CONNECT_TIMEOUT;
@@ -2374,7 +2379,15 @@ static int usb_eth_init(struct eth_device *netdev, bd_t *bd)
goto fail;
}
- if (usb_gadget_register_driver(ð_driver) < 0)
+ l_priv->eth_driver.speed = DEVSPEED;
+ l_priv->eth_driver.bind = eth_bind;
+ l_priv->eth_driver.unbind = eth_unbind;
+ l_priv->eth_driver.setup = eth_setup;
+ l_priv->eth_driver.reset = eth_disconnect;
+ l_priv->eth_driver.disconnect = eth_disconnect;
+ l_priv->eth_driver.suspend = eth_suspend;
+ l_priv->eth_driver.resume = eth_resume;
+ if (usb_gadget_register_driver(&l_priv->eth_driver) < 0)
goto fail;
dev->network_started = 0;
@@ -2409,7 +2422,7 @@ static int usb_eth_send(struct eth_device *netdev, void *packet, int length)
{
int retval;
void *rndis_pkt = NULL;
- struct eth_dev *dev = &l_ethdev;
+ struct eth_dev *dev = &l_priv->ethdev;
struct usb_request *req = dev->tx_req;
unsigned long ts;
unsigned long timeout = USB_CONNECT_TIMEOUT;
@@ -2476,7 +2489,7 @@ drop:
static int usb_eth_recv(struct eth_device *netdev)
{
- struct eth_dev *dev = &l_ethdev;
+ struct eth_dev *dev = &l_priv->ethdev;
usb_gadget_handle_interrupts(0);
@@ -2496,7 +2509,7 @@ static int usb_eth_recv(struct eth_device *netdev)
void usb_eth_halt(struct eth_device *netdev)
{
- struct eth_dev *dev = &l_ethdev;
+ struct eth_dev *dev = &l_priv->ethdev;
if (!netdev) {
error("received NULL ptr");
@@ -2528,7 +2541,7 @@ void usb_eth_halt(struct eth_device *netdev)
dev->network_started = 0;
}
- usb_gadget_unregister_driver(ð_driver);
+ usb_gadget_unregister_driver(&l_priv->eth_driver);
#ifdef CONFIG_DM_USB
device_remove(dev->usb_udev);
#else
@@ -2536,23 +2549,9 @@ void usb_eth_halt(struct eth_device *netdev)
#endif
}
-static struct usb_gadget_driver eth_driver = {
- .speed = DEVSPEED,
-
- .bind = eth_bind,
- .unbind = eth_unbind,
-
- .setup = eth_setup,
- .reset = eth_disconnect,
- .disconnect = eth_disconnect,
-
- .suspend = eth_suspend,
- .resume = eth_resume,
-};
-
int usb_eth_initialize(bd_t *bi)
{
- struct eth_device *netdev = &l_netdev;
+ struct eth_device *netdev = &l_priv->netdev;
strlcpy(netdev->name, USB_NET_NAME, sizeof(netdev->name));
--
2.11.0.rc1
^ permalink raw reply related [flat|nested] 15+ messages in thread
* [U-Boot] [PATCH v3 4/6] drivers: usb: gadget: ether: use net device priv to pass usb ether priv
2016-11-17 8:09 [U-Boot] [PATCH v3 0/6] DM conversion of usb ether gadget Mugunthan V N
` (2 preceding siblings ...)
2016-11-17 8:09 ` [U-Boot] [PATCH v3 3/6] drivers: usb: gadget: ether: consolidate global devices to single struct Mugunthan V N
@ 2016-11-17 8:09 ` Mugunthan V N
2016-11-17 8:09 ` [U-Boot] [PATCH v3 5/6] drivers: usb: gadget: ether: prepare driver for driver model migration Mugunthan V N
` (2 subsequent siblings)
6 siblings, 0 replies; 15+ messages in thread
From: Mugunthan V N @ 2016-11-17 8:09 UTC (permalink / raw)
To: u-boot
Use net device priv to pass usb ether priv and use it in
net device ops callback.
Signed-off-by: Mugunthan V N <mugunthanvnm@ti.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
---
drivers/usb/gadget/ether.c | 46 +++++++++++++++++++++-------------------------
1 file changed, 21 insertions(+), 25 deletions(-)
diff --git a/drivers/usb/gadget/ether.c b/drivers/usb/gadget/ether.c
index 16edeead65..54b8b59b29 100644
--- a/drivers/usb/gadget/ether.c
+++ b/drivers/usb/gadget/ether.c
@@ -1853,7 +1853,8 @@ static char rndis_resp_buf[8] __attribute__((aligned(sizeof(__le32))));
static int rndis_control_ack(struct eth_device *net)
{
- struct eth_dev *dev = &l_priv->ethdev;
+ struct ether_priv *priv = (struct ether_priv *)net->priv;
+ struct eth_dev *dev = &priv->ethdev;
int length;
struct usb_request *resp = dev->stat_req;
@@ -2335,16 +2336,12 @@ int dm_usb_init(struct eth_dev *e_dev)
static int usb_eth_init(struct eth_device *netdev, bd_t *bd)
{
- struct eth_dev *dev = &l_priv->ethdev;
+ struct ether_priv *priv = (struct ether_priv *)netdev->priv;
+ struct eth_dev *dev = &priv->ethdev;
struct usb_gadget *gadget;
unsigned long ts;
unsigned long timeout = USB_CONNECT_TIMEOUT;
- if (!netdev) {
- error("received NULL ptr");
- goto fail;
- }
-
#ifdef CONFIG_DM_USB
if (dm_usb_init(dev)) {
error("USB ether not found\n");
@@ -2379,15 +2376,15 @@ static int usb_eth_init(struct eth_device *netdev, bd_t *bd)
goto fail;
}
- l_priv->eth_driver.speed = DEVSPEED;
- l_priv->eth_driver.bind = eth_bind;
- l_priv->eth_driver.unbind = eth_unbind;
- l_priv->eth_driver.setup = eth_setup;
- l_priv->eth_driver.reset = eth_disconnect;
- l_priv->eth_driver.disconnect = eth_disconnect;
- l_priv->eth_driver.suspend = eth_suspend;
- l_priv->eth_driver.resume = eth_resume;
- if (usb_gadget_register_driver(&l_priv->eth_driver) < 0)
+ priv->eth_driver.speed = DEVSPEED;
+ priv->eth_driver.bind = eth_bind;
+ priv->eth_driver.unbind = eth_unbind;
+ priv->eth_driver.setup = eth_setup;
+ priv->eth_driver.reset = eth_disconnect;
+ priv->eth_driver.disconnect = eth_disconnect;
+ priv->eth_driver.suspend = eth_suspend;
+ priv->eth_driver.resume = eth_resume;
+ if (usb_gadget_register_driver(&priv->eth_driver) < 0)
goto fail;
dev->network_started = 0;
@@ -2422,7 +2419,8 @@ static int usb_eth_send(struct eth_device *netdev, void *packet, int length)
{
int retval;
void *rndis_pkt = NULL;
- struct eth_dev *dev = &l_priv->ethdev;
+ struct ether_priv *priv = (struct ether_priv *)netdev->priv;
+ struct eth_dev *dev = &priv->ethdev;
struct usb_request *req = dev->tx_req;
unsigned long ts;
unsigned long timeout = USB_CONNECT_TIMEOUT;
@@ -2489,7 +2487,8 @@ drop:
static int usb_eth_recv(struct eth_device *netdev)
{
- struct eth_dev *dev = &l_priv->ethdev;
+ struct ether_priv *priv = (struct ether_priv *)netdev->priv;
+ struct eth_dev *dev = &priv->ethdev;
usb_gadget_handle_interrupts(0);
@@ -2509,12 +2508,8 @@ static int usb_eth_recv(struct eth_device *netdev)
void usb_eth_halt(struct eth_device *netdev)
{
- struct eth_dev *dev = &l_priv->ethdev;
-
- if (!netdev) {
- error("received NULL ptr");
- return;
- }
+ struct ether_priv *priv = (struct ether_priv *)netdev->priv;
+ struct eth_dev *dev = &priv->ethdev;
/* If the gadget not registered, simple return */
if (!dev->gadget)
@@ -2541,7 +2536,7 @@ void usb_eth_halt(struct eth_device *netdev)
dev->network_started = 0;
}
- usb_gadget_unregister_driver(&l_priv->eth_driver);
+ usb_gadget_unregister_driver(&priv->eth_driver);
#ifdef CONFIG_DM_USB
device_remove(dev->usb_udev);
#else
@@ -2559,6 +2554,7 @@ int usb_eth_initialize(bd_t *bi)
netdev->send = usb_eth_send;
netdev->recv = usb_eth_recv;
netdev->halt = usb_eth_halt;
+ netdev->priv = l_priv;
#ifdef CONFIG_MCAST_TFTP
#error not supported
--
2.11.0.rc1
^ permalink raw reply related [flat|nested] 15+ messages in thread
* [U-Boot] [PATCH v3 5/6] drivers: usb: gadget: ether: prepare driver for driver model migration
2016-11-17 8:09 [U-Boot] [PATCH v3 0/6] DM conversion of usb ether gadget Mugunthan V N
` (3 preceding siblings ...)
2016-11-17 8:09 ` [U-Boot] [PATCH v3 4/6] drivers: usb: gadget: ether: use net device priv to pass usb ether priv Mugunthan V N
@ 2016-11-17 8:09 ` Mugunthan V N
2016-11-17 8:09 ` [U-Boot] [PATCH v3 6/6] drivers: usb: gadget: ether/rndis: convert driver to adopt device driver model Mugunthan V N
2016-11-18 5:56 ` [U-Boot] [PATCH v3 0/6] DM conversion of usb ether gadget Mugunthan V N
6 siblings, 0 replies; 15+ messages in thread
From: Mugunthan V N @ 2016-11-17 8:09 UTC (permalink / raw)
To: u-boot
prepare driver for driver model migration
Signed-off-by: Mugunthan V N <mugunthanvnm@ti.com>
---
drivers/usb/gadget/ether.c | 73 +++++++++++++++++++++++++++++++++-------------
1 file changed, 52 insertions(+), 21 deletions(-)
diff --git a/drivers/usb/gadget/ether.c b/drivers/usb/gadget/ether.c
index 54b8b59b29..046ad8ca2b 100644
--- a/drivers/usb/gadget/ether.c
+++ b/drivers/usb/gadget/ether.c
@@ -2334,9 +2334,8 @@ int dm_usb_init(struct eth_dev *e_dev)
}
#endif
-static int usb_eth_init(struct eth_device *netdev, bd_t *bd)
+static int _usb_eth_init(struct ether_priv *priv)
{
- struct ether_priv *priv = (struct ether_priv *)netdev->priv;
struct eth_dev *dev = &priv->ethdev;
struct usb_gadget *gadget;
unsigned long ts;
@@ -2415,11 +2414,10 @@ fail:
return -1;
}
-static int usb_eth_send(struct eth_device *netdev, void *packet, int length)
+static int _usb_eth_send(struct ether_priv *priv, void *packet, int length)
{
int retval;
void *rndis_pkt = NULL;
- struct ether_priv *priv = (struct ether_priv *)netdev->priv;
struct eth_dev *dev = &priv->ethdev;
struct usb_request *req = dev->tx_req;
unsigned long ts;
@@ -2485,30 +2483,15 @@ drop:
return -ENOMEM;
}
-static int usb_eth_recv(struct eth_device *netdev)
+static int _usb_eth_recv(struct ether_priv *priv)
{
- struct ether_priv *priv = (struct ether_priv *)netdev->priv;
- struct eth_dev *dev = &priv->ethdev;
-
usb_gadget_handle_interrupts(0);
- if (packet_received) {
- debug("%s: packet received\n", __func__);
- if (dev->rx_req) {
- net_process_received_packet(net_rx_packets[0],
- dev->rx_req->length);
- packet_received = 0;
-
- rx_submit(dev, dev->rx_req, 0);
- } else
- error("dev->rx_req invalid");
- }
return 0;
}
-void usb_eth_halt(struct eth_device *netdev)
+void _usb_eth_halt(struct ether_priv *priv)
{
- struct ether_priv *priv = (struct ether_priv *)netdev->priv;
struct eth_dev *dev = &priv->ethdev;
/* If the gadget not registered, simple return */
@@ -2544,6 +2527,54 @@ void usb_eth_halt(struct eth_device *netdev)
#endif
}
+static int usb_eth_init(struct eth_device *netdev, bd_t *bd)
+{
+ struct ether_priv *priv = (struct ether_priv *)netdev->priv;
+
+ return _usb_eth_init(priv);
+}
+
+static int usb_eth_send(struct eth_device *netdev, void *packet, int length)
+{
+ struct ether_priv *priv = (struct ether_priv *)netdev->priv;
+
+ return _usb_eth_send(priv, packet, length);
+}
+
+static int usb_eth_recv(struct eth_device *netdev)
+{
+ struct ether_priv *priv = (struct ether_priv *)netdev->priv;
+ struct eth_dev *dev = &priv->ethdev;
+ int ret;
+
+ ret = _usb_eth_recv(priv);
+ if (ret) {
+ error("error packet receive\n");
+ return ret;
+ }
+
+ if (!packet_received)
+ return 0;
+
+ if (dev->rx_req) {
+ net_process_received_packet(net_rx_packets[0],
+ dev->rx_req->length);
+ } else {
+ error("dev->rx_req invalid");
+ }
+ packet_received = 0;
+ rx_submit(dev, dev->rx_req, 0);
+
+ return 0;
+}
+
+void usb_eth_halt(struct eth_device *netdev)
+{
+ struct ether_priv *priv = (struct ether_priv *)netdev->priv;
+
+ _usb_eth_halt(priv);
+}
+
int usb_eth_initialize(bd_t *bi)
{
struct eth_device *netdev = &l_priv->netdev;
--
2.11.0.rc1
^ permalink raw reply related [flat|nested] 15+ messages in thread
* [U-Boot] [PATCH v3 6/6] drivers: usb: gadget: ether/rndis: convert driver to adopt device driver model
2016-11-17 8:09 [U-Boot] [PATCH v3 0/6] DM conversion of usb ether gadget Mugunthan V N
` (4 preceding siblings ...)
2016-11-17 8:09 ` [U-Boot] [PATCH v3 5/6] drivers: usb: gadget: ether: prepare driver for driver model migration Mugunthan V N
@ 2016-11-17 8:09 ` Mugunthan V N
2016-11-18 5:56 ` [U-Boot] [PATCH v3 0/6] DM conversion of usb ether gadget Mugunthan V N
6 siblings, 0 replies; 15+ messages in thread
From: Mugunthan V N @ 2016-11-17 8:09 UTC (permalink / raw)
To: u-boot
Adopt usb ether gadget and rndis driver to adopt driver model
Signed-off-by: Mugunthan V N <mugunthanvnm@ti.com>
---
drivers/usb/gadget/Kconfig | 4 ++
drivers/usb/gadget/ether.c | 153 ++++++++++++++++++++++++++++++++++++++++++---
drivers/usb/gadget/rndis.c | 13 +++-
drivers/usb/gadget/rndis.h | 19 ++++--
include/net.h | 7 +++
5 files changed, 181 insertions(+), 15 deletions(-)
diff --git a/drivers/usb/gadget/Kconfig b/drivers/usb/gadget/Kconfig
index 40839d89e9..261ed128ac 100644
--- a/drivers/usb/gadget/Kconfig
+++ b/drivers/usb/gadget/Kconfig
@@ -112,6 +112,10 @@ config G_DNL_VENDOR_NUM
config G_DNL_PRODUCT_NUM
hex "Product ID of USB device"
+config USBNET_DEVADDR
+ string "USB Gadget Ethernet device mac address"
+ default "de:ad:be:ef:00:01"
+
endif # USB_GADGET_DOWNLOAD
endif # USB_GADGET
diff --git a/drivers/usb/gadget/ether.c b/drivers/usb/gadget/ether.c
index 046ad8ca2b..8c3c3fd9ab 100644
--- a/drivers/usb/gadget/ether.c
+++ b/drivers/usb/gadget/ether.c
@@ -25,6 +25,7 @@
#include "rndis.h"
#include <dm.h>
+#include <dm/lists.h>
#include <dm/uclass-internal.h>
#include <dm/device-internal.h>
@@ -116,7 +117,11 @@ struct eth_dev {
struct usb_request *tx_req, *rx_req;
+#ifndef CONFIG_DM_ETH
struct eth_device *net;
+#else
+ struct udevice *net;
+#endif
struct net_device_stats stats;
unsigned int tx_qlen;
@@ -143,7 +148,11 @@ struct eth_dev {
/*-------------------------------------------------------------------------*/
struct ether_priv {
struct eth_dev ethdev;
+#ifndef CONFIG_DM_ETH
struct eth_device netdev;
+#else
+ struct udevice *netdev;
+#endif
struct usb_gadget_driver eth_driver;
};
@@ -1851,7 +1860,11 @@ static void rndis_control_ack_complete(struct usb_ep *ep,
static char rndis_resp_buf[8] __attribute__((aligned(sizeof(__le32))));
+#ifndef CONFIG_DM_ETH
static int rndis_control_ack(struct eth_device *net)
+#else
+static int rndis_control_ack(struct udevice *net)
+#endif
{
struct ether_priv *priv = (struct ether_priv *)net->priv;
struct eth_dev *dev = &priv->ethdev;
@@ -2001,6 +2014,9 @@ static int eth_bind(struct usb_gadget *gadget)
int status = -ENOMEM;
int gcnum;
u8 tmp[7];
+#ifdef CONFIG_DM_ETH
+ struct eth_pdata *pdata = dev_get_platdata(l_priv->netdev);
+#endif
/* these flags are only ever cleared; compiler take note */
#ifndef CONFIG_USB_ETH_CDC
@@ -2188,7 +2204,11 @@ autoconf_fail:
/* network device setup */
+#ifndef CONFIG_DM_ETH
dev->net = &l_priv->netdev;
+#else
+ dev->net = l_priv->netdev;
+#endif
dev->cdc = cdc;
dev->zlp = zlp;
@@ -2197,6 +2217,7 @@ autoconf_fail:
dev->out_ep = out_ep;
dev->status_ep = status_ep;
+ memset(tmp, 0, sizeof(tmp));
/*
* Module params for these addresses should come from ID proms.
* The host side address is used with CDC and RNDIS, and commonly
@@ -2204,10 +2225,13 @@ autoconf_fail:
* host side code for the SAFE thing cares -- its original BLAN
* thing didn't, Sharp never assigned those addresses on Zaurii.
*/
+#ifndef CONFIG_DM_ETH
get_ether_addr(dev_addr, dev->net->enetaddr);
-
- memset(tmp, 0, sizeof(tmp));
memcpy(tmp, dev->net->enetaddr, sizeof(dev->net->enetaddr));
+#else
+ get_ether_addr(dev_addr, pdata->enetaddr);
+ memcpy(tmp, pdata->enetaddr, sizeof(pdata->enetaddr));
+#endif
get_ether_addr(host_addr, dev->host_mac);
@@ -2268,10 +2292,11 @@ autoconf_fail:
status_ep ? " STATUS " : "",
status_ep ? status_ep->name : ""
);
- printf("MAC %02x:%02x:%02x:%02x:%02x:%02x\n",
- dev->net->enetaddr[0], dev->net->enetaddr[1],
- dev->net->enetaddr[2], dev->net->enetaddr[3],
- dev->net->enetaddr[4], dev->net->enetaddr[5]);
+#ifndef CONFIG_DM_ETH
+ printf("MAC %pM\n", dev->net->enetaddr);
+#else
+ printf("MAC %pM\n", pdata->enetaddr);
+#endif
if (cdc || rndis)
printf("HOST MAC %02x:%02x:%02x:%02x:%02x:%02x\n",
@@ -2520,13 +2545,12 @@ void _usb_eth_halt(struct ether_priv *priv)
}
usb_gadget_unregister_driver(&priv->eth_driver);
-#ifdef CONFIG_DM_USB
- device_remove(dev->usb_udev);
-#else
+#ifndef CONFIG_DM_USB
board_usb_cleanup(0, USB_INIT_DEVICE);
#endif
}
+#ifndef CONFIG_DM_ETH
static int usb_eth_init(struct eth_device *netdev, bd_t *bd)
{
struct ether_priv *priv = (struct ether_priv *)netdev->priv;
@@ -2593,3 +2617,114 @@ int usb_eth_initialize(bd_t *bi)
eth_register(netdev);
return 0;
}
+#else
+static int usb_eth_start(struct udevice *dev)
+{
+ struct ether_priv *priv = dev_get_priv(dev);
+
+ return _usb_eth_init(priv);
+}
+
+static int usb_eth_send(struct udevice *dev, void *packet, int length)
+{
+ struct ether_priv *priv = dev_get_priv(dev);
+
+ return _usb_eth_send(priv, packet, length);
+}
+
+static int usb_eth_recv(struct udevice *dev, int flags, uchar **packetp)
+{
+ struct ether_priv *priv = dev_get_priv(dev);
+ struct eth_dev *ethdev = &priv->ethdev;
+ int ret;
+
+ ret = _usb_eth_recv(priv);
+ if (ret) {
+ error("error packet receive\n");
+ return ret;
+ }
+
+ if (packet_received) {
+ if (ethdev->rx_req) {
+ *packetp = (uchar *)net_rx_packets[0];
+ return ethdev->rx_req->length;
+ } else {
+ error("dev->rx_req invalid");
+ return -EFAULT;
+ }
+ }
+
+ return -EAGAIN;
+}
+
+static int usb_eth_free_pkt(struct udevice *dev, uchar *packet,
+ int length)
+{
+ struct ether_priv *priv = dev_get_priv(dev);
+ struct eth_dev *ethdev = &priv->ethdev;
+
+ packet_received = 0;
+
+ return rx_submit(ethdev, ethdev->rx_req, 0);
+}
+
+static void usb_eth_stop(struct udevice *dev)
+{
+ struct ether_priv *priv = dev_get_priv(dev);
+
+ _usb_eth_halt(priv);
+}
+
+static int usb_eth_probe(struct udevice *dev)
+{
+ struct ether_priv *priv = dev_get_priv(dev);
+ struct eth_pdata *pdata = dev_get_platdata(dev);
+
+ priv->netdev = dev;
+ l_priv = priv;
+
+ get_ether_addr(CONFIG_USBNET_DEVADDR, pdata->enetaddr);
+ eth_setenv_enetaddr("usbnet_devaddr", pdata->enetaddr);
+
+ return 0;
+}
+
+static const struct eth_ops usb_eth_ops = {
+ .start = usb_eth_start,
+ .send = usb_eth_send,
+ .recv = usb_eth_recv,
+ .free_pkt = usb_eth_free_pkt,
+ .stop = usb_eth_stop,
+};
+
+int usb_ether_init(void)
+{
+ struct udevice *dev;
+ struct udevice *usb_dev;
+ int ret;
+
+ ret = uclass_first_device(UCLASS_USB_DEV_GENERIC, &usb_dev);
+ if (!usb_dev || ret) {
+ error("No USB device found\n");
+ return ret;
+ }
+
+ ret = device_bind_driver(usb_dev, "usb_ether", "usb_ether", &dev);
+ if (!dev || ret) {
+ error("usb - not able to bind usb_ether device\n");
+ return ret;
+ }
+
+ return 0;
+}
+
+U_BOOT_DRIVER(eth_usb) = {
+ .name = "usb_ether",
+ .id = UCLASS_ETH,
+ .probe = usb_eth_probe,
+ .ops = &usb_eth_ops,
+ .priv_auto_alloc_size = sizeof(struct ether_priv),
+ .platdata_auto_alloc_size = sizeof(struct eth_pdata),
+ .flags = DM_FLAG_ALLOC_PRIV_DMA,
+};
+#endif /* CONFIG_DM_ETH */
diff --git a/drivers/usb/gadget/rndis.c b/drivers/usb/gadget/rndis.c
index 844a0c7236..5ad481302b 100644
--- a/drivers/usb/gadget/rndis.c
+++ b/drivers/usb/gadget/rndis.c
@@ -1121,7 +1121,11 @@ int rndis_msg_parser(u8 configNr, u8 *buf)
return -ENOTSUPP;
}
+#ifndef CONFIG_DM_ETH
int rndis_register(int (*rndis_control_ack)(struct eth_device *))
+#else
+int rndis_register(int (*rndis_control_ack)(struct udevice *))
+#endif
{
u8 i;
@@ -1149,8 +1153,13 @@ void rndis_deregister(int configNr)
return;
}
-int rndis_set_param_dev(u8 configNr, struct eth_device *dev, int mtu,
- struct net_device_stats *stats, u16 *cdc_filter)
+#ifndef CONFIG_DM_ETH
+int rndis_set_param_dev(u8 configNr, struct eth_device *dev, int mtu,
+ struct net_device_stats *stats, u16 *cdc_filter)
+#else
+int rndis_set_param_dev(u8 configNr, struct udevice *dev, int mtu,
+ struct net_device_stats *stats, u16 *cdc_filter)
+#endif
{
debug("%s: configNr = %d\n", __func__, configNr);
if (!dev || !stats)
diff --git a/drivers/usb/gadget/rndis.h b/drivers/usb/gadget/rndis.h
index 7a389a580a..084af8541c 100644
--- a/drivers/usb/gadget/rndis.h
+++ b/drivers/usb/gadget/rndis.h
@@ -222,23 +222,34 @@ typedef struct rndis_params {
const u8 *host_mac;
u16 *filter;
- struct eth_device *dev;
struct net_device_stats *stats;
int mtu;
u32 vendorID;
const char *vendorDescr;
- int (*ack)(struct eth_device *);
+#ifndef CONFIG_DM_ETH
+ struct eth_device *dev;
+ int (*ack)(struct eth_device *);
+#else
+ struct udevice *dev;
+ int (*ack)(struct udevice *);
+#endif
struct list_head resp_queue;
} rndis_params;
/* RNDIS Message parser and other useless functions */
int rndis_msg_parser(u8 configNr, u8 *buf);
enum rndis_state rndis_get_state(int configNr);
-int rndis_register(int (*rndis_control_ack)(struct eth_device *));
void rndis_deregister(int configNr);
+#ifndef CONFIG_DM_ETH
+int rndis_register(int (*rndis_control_ack)(struct eth_device *));
int rndis_set_param_dev(u8 configNr, struct eth_device *dev, int mtu,
- struct net_device_stats *stats, u16 *cdc_filter);
+ struct net_device_stats *stats, u16 *cdc_filter);
+#else
+int rndis_register(int (*rndis_control_ack)(struct udevice *));
+int rndis_set_param_dev(u8 configNr, struct udevice *dev, int mtu,
+ struct net_device_stats *stats, u16 *cdc_filter);
+#endif
int rndis_set_param_vendor(u8 configNr, u32 vendorID,
const char *vendorDescr);
int rndis_set_param_medium(u8 configNr, u32 medium, u32 speed);
diff --git a/include/net.h b/include/net.h
index 06320c6514..1f4d947350 100644
--- a/include/net.h
+++ b/include/net.h
@@ -255,6 +255,13 @@ int eth_setenv_enetaddr_by_index(const char *base_name, int index,
/*
+ * Initialize USB ethernet device with CONFIG_DM_ETH
+ * Returns:
+ * 0 is success, non-zero is error status.
+ */
+int usb_ether_init(void);
+
+/*
* Get the hardware address for an ethernet interface .
* Args:
* base_name - base name for device (normally "eth")
--
2.11.0.rc1
^ permalink raw reply related [flat|nested] 15+ messages in thread
* [U-Boot] [PATCH v3 0/6] DM conversion of usb ether gadget
2016-11-17 8:09 [U-Boot] [PATCH v3 0/6] DM conversion of usb ether gadget Mugunthan V N
` (5 preceding siblings ...)
2016-11-17 8:09 ` [U-Boot] [PATCH v3 6/6] drivers: usb: gadget: ether/rndis: convert driver to adopt device driver model Mugunthan V N
@ 2016-11-18 5:56 ` Mugunthan V N
6 siblings, 0 replies; 15+ messages in thread
From: Mugunthan V N @ 2016-11-18 5:56 UTC (permalink / raw)
To: u-boot
On Thursday 17 November 2016 01:39 PM, Mugunthan V N wrote:
> This patch series adopts driver model for usb ether gadget
> driver. This series is tested with MUSB driver model conversion
> on AM335x GP evm and AM335x BBB (logs [1]).
Please drop this patch series as not all patches of this series landed
on mailing list. resent the series [1].
[1] - http://lists.denx.de/pipermail/u-boot/2016-November/273164.html
Regards
Mugunthan V N
^ permalink raw reply [flat|nested] 15+ messages in thread
* [U-Boot] [PATCH v3 1/6] drivers: usb: gadget: ether: adopt to usb driver model
2016-11-17 8:09 ` [U-Boot] [PATCH v3 1/6] drivers: usb: gadget: ether: adopt to usb driver model Mugunthan V N
@ 2016-11-18 19:34 ` Simon Glass
2016-11-21 5:38 ` Mugunthan V N
0 siblings, 1 reply; 15+ messages in thread
From: Simon Glass @ 2016-11-18 19:34 UTC (permalink / raw)
To: u-boot
Hi Mugunthan,
On 17 November 2016 at 01:09, Mugunthan V N <mugunthanvnm@ti.com> wrote:
> Convert usb ether gadget to adopt usb driver model
>
> Signed-off-by: Mugunthan V N <mugunthanvnm@ti.com>
> Reviewed-by: Simon Glass <sjg@chromium.org>
Sorry, but I'd like to 'un-review' this.
> ---
> drivers/usb/gadget/ether.c | 36 ++++++++++++++++++++++++++++++++++++
> 1 file changed, 36 insertions(+)
>
> diff --git a/drivers/usb/gadget/ether.c b/drivers/usb/gadget/ether.c
> index 497b981129..9bc61186cf 100644
> --- a/drivers/usb/gadget/ether.c
> +++ b/drivers/usb/gadget/ether.c
> @@ -24,6 +24,10 @@
> #include "gadget_chips.h"
> #include "rndis.h"
>
> +#include <dm.h>
> +#include <dm/uclass-internal.h>
> +#include <dm/device-internal.h>
> +
> #define USB_NET_NAME "usb_ether"
>
> #define atomic_read
> @@ -101,6 +105,9 @@ struct eth_dev {
> struct usb_gadget *gadget;
> struct usb_request *req; /* for control responses */
> struct usb_request *stat_req; /* for cdc & rndis status */
> +#ifdef CONFIG_DM_USB
> + struct udevice *usb_udev;
> +#endif
>
> u8 config;
> struct usb_ep *in_ep, *out_ep, *status_ep;
> @@ -2303,6 +2310,24 @@ fail:
>
> /*-------------------------------------------------------------------------*/
>
> +#ifdef CONFIG_DM_USB
> +int dm_usb_init(struct eth_dev *e_dev)
> +{
> + struct udevice *dev = NULL;
> + int ret;
> +
> + ret = uclass_first_device(UCLASS_USB_DEV_GENERIC, &dev);
> + if (!dev || ret) {
> + error("No USB device found\n");
> + return -ENODEV;
> + }
> +
> + e_dev->usb_udev = dev;
> +
> + return ret;
> +}
> +#endif
> +
> static int usb_eth_init(struct eth_device *netdev, bd_t *bd)
> {
> struct eth_dev *dev = &l_ethdev;
> @@ -2315,7 +2340,14 @@ static int usb_eth_init(struct eth_device *netdev, bd_t *bd)
> goto fail;
> }
>
> +#ifdef CONFIG_DM_USB
> + if (dm_usb_init(dev)) {
> + error("USB ether not found\n");
> + return -ENODEV;
> + }
> +#else
> board_usb_init(0, USB_INIT_DEVICE);
> +#endif
>
> /* Configure default mac-addresses for the USB ethernet device */
> #ifdef CONFIG_USBNET_DEV_ADDR
> @@ -2497,7 +2529,11 @@ void usb_eth_halt(struct eth_device *netdev)
> }
>
> usb_gadget_unregister_driver(ð_driver);
> +#ifdef CONFIG_DM_USB
> + device_remove(dev->usb_udev);
> +#else
> board_usb_cleanup(0, USB_INIT_DEVICE);
> +#endif
This doesn't look right to me. If your board is to be an Ethernet
device then it should do:
uclass_first_device(UCLASS_ETH, &dev)
to get the device. That could be in the device tree under the USB
node, or perhaps you want to have a setup function which manualy binds
the device, a bit like usb_find_and_bind_driver().
> }
>
> static struct usb_gadget_driver eth_driver = {
> --
> 2.11.0.rc1
>
Regards,
Simon
^ permalink raw reply [flat|nested] 15+ messages in thread
* [U-Boot] [PATCH v3 1/6] drivers: usb: gadget: ether: adopt to usb driver model
2016-11-18 19:34 ` Simon Glass
@ 2016-11-21 5:38 ` Mugunthan V N
2016-11-24 2:21 ` Simon Glass
0 siblings, 1 reply; 15+ messages in thread
From: Mugunthan V N @ 2016-11-21 5:38 UTC (permalink / raw)
To: u-boot
Hi Simon,
On Saturday 19 November 2016 01:04 AM, Simon Glass wrote:
> Hi Mugunthan,
>
> On 17 November 2016 at 01:09, Mugunthan V N <mugunthanvnm@ti.com> wrote:
>> Convert usb ether gadget to adopt usb driver model
>>
>> Signed-off-by: Mugunthan V N <mugunthanvnm@ti.com>
>> Reviewed-by: Simon Glass <sjg@chromium.org>
>
> Sorry, but I'd like to 'un-review' this.
>
>> ---
>> drivers/usb/gadget/ether.c | 36 ++++++++++++++++++++++++++++++++++++
>> 1 file changed, 36 insertions(+)
>>
>> diff --git a/drivers/usb/gadget/ether.c b/drivers/usb/gadget/ether.c
>> index 497b981129..9bc61186cf 100644
>> --- a/drivers/usb/gadget/ether.c
>> +++ b/drivers/usb/gadget/ether.c
>> @@ -24,6 +24,10 @@
>> #include "gadget_chips.h"
>> #include "rndis.h"
>>
>> +#include <dm.h>
>> +#include <dm/uclass-internal.h>
>> +#include <dm/device-internal.h>
>> +
>> #define USB_NET_NAME "usb_ether"
>>
>> #define atomic_read
>> @@ -101,6 +105,9 @@ struct eth_dev {
>> struct usb_gadget *gadget;
>> struct usb_request *req; /* for control responses */
>> struct usb_request *stat_req; /* for cdc & rndis status */
>> +#ifdef CONFIG_DM_USB
>> + struct udevice *usb_udev;
>> +#endif
>>
>> u8 config;
>> struct usb_ep *in_ep, *out_ep, *status_ep;
>> @@ -2303,6 +2310,24 @@ fail:
>>
>> /*-------------------------------------------------------------------------*/
>>
>> +#ifdef CONFIG_DM_USB
>> +int dm_usb_init(struct eth_dev *e_dev)
>> +{
>> + struct udevice *dev = NULL;
>> + int ret;
>> +
>> + ret = uclass_first_device(UCLASS_USB_DEV_GENERIC, &dev);
>> + if (!dev || ret) {
>> + error("No USB device found\n");
>> + return -ENODEV;
>> + }
>> +
>> + e_dev->usb_udev = dev;
>> +
>> + return ret;
>> +}
>> +#endif
>> +
>> static int usb_eth_init(struct eth_device *netdev, bd_t *bd)
>> {
>> struct eth_dev *dev = &l_ethdev;
>> @@ -2315,7 +2340,14 @@ static int usb_eth_init(struct eth_device *netdev, bd_t *bd)
>> goto fail;
>> }
>>
>> +#ifdef CONFIG_DM_USB
>> + if (dm_usb_init(dev)) {
>> + error("USB ether not found\n");
>> + return -ENODEV;
>> + }
>> +#else
>> board_usb_init(0, USB_INIT_DEVICE);
>> +#endif
>>
>> /* Configure default mac-addresses for the USB ethernet device */
>> #ifdef CONFIG_USBNET_DEV_ADDR
>> @@ -2497,7 +2529,11 @@ void usb_eth_halt(struct eth_device *netdev)
>> }
>>
>> usb_gadget_unregister_driver(ð_driver);
>> +#ifdef CONFIG_DM_USB
>> + device_remove(dev->usb_udev);
>> +#else
>> board_usb_cleanup(0, USB_INIT_DEVICE);
>> +#endif
>
> This doesn't look right to me. If your board is to be an Ethernet
> device then it should do:
>
> uclass_first_device(UCLASS_ETH, &dev)
>
> to get the device. That could be in the device tree under the USB
> node, or perhaps you want to have a setup function which manualy binds
> the device, a bit like usb_find_and_bind_driver().
>
This patch is to get usb device for the ether gadget. It uses the same
api with UCLASS_USB_DEV_GENERIC to get usb device. The patch hadn't done
for eth driver model adoption.
Regards
Mugunthan V N
^ permalink raw reply [flat|nested] 15+ messages in thread
* [U-Boot] [PATCH v3 1/6] drivers: usb: gadget: ether: adopt to usb driver model
2016-11-21 5:38 ` Mugunthan V N
@ 2016-11-24 2:21 ` Simon Glass
2016-11-24 8:11 ` Mugunthan V N
0 siblings, 1 reply; 15+ messages in thread
From: Simon Glass @ 2016-11-24 2:21 UTC (permalink / raw)
To: u-boot
Hi Mugunthan,
On 20 November 2016 at 22:38, Mugunthan V N <mugunthanvnm@ti.com> wrote:
> Hi Simon,
>
> On Saturday 19 November 2016 01:04 AM, Simon Glass wrote:
>> Hi Mugunthan,
>>
>> On 17 November 2016 at 01:09, Mugunthan V N <mugunthanvnm@ti.com> wrote:
>>> Convert usb ether gadget to adopt usb driver model
>>>
>>> Signed-off-by: Mugunthan V N <mugunthanvnm@ti.com>
>>> Reviewed-by: Simon Glass <sjg@chromium.org>
>>
>> Sorry, but I'd like to 'un-review' this.
>>
>>> ---
>>> drivers/usb/gadget/ether.c | 36 ++++++++++++++++++++++++++++++++++++
>>> 1 file changed, 36 insertions(+)
>>>
>>> diff --git a/drivers/usb/gadget/ether.c b/drivers/usb/gadget/ether.c
>>> index 497b981129..9bc61186cf 100644
>>> --- a/drivers/usb/gadget/ether.c
>>> +++ b/drivers/usb/gadget/ether.c
>>> @@ -24,6 +24,10 @@
>>> #include "gadget_chips.h"
>>> #include "rndis.h"
>>>
>>> +#include <dm.h>
>>> +#include <dm/uclass-internal.h>
>>> +#include <dm/device-internal.h>
>>> +
>>> #define USB_NET_NAME "usb_ether"
>>>
>>> #define atomic_read
>>> @@ -101,6 +105,9 @@ struct eth_dev {
>>> struct usb_gadget *gadget;
>>> struct usb_request *req; /* for control responses */
>>> struct usb_request *stat_req; /* for cdc & rndis status */
>>> +#ifdef CONFIG_DM_USB
>>> + struct udevice *usb_udev;
>>> +#endif
>>>
>>> u8 config;
>>> struct usb_ep *in_ep, *out_ep, *status_ep;
>>> @@ -2303,6 +2310,24 @@ fail:
>>>
>>> /*-------------------------------------------------------------------------*/
>>>
>>> +#ifdef CONFIG_DM_USB
>>> +int dm_usb_init(struct eth_dev *e_dev)
>>> +{
>>> + struct udevice *dev = NULL;
>>> + int ret;
>>> +
>>> + ret = uclass_first_device(UCLASS_USB_DEV_GENERIC, &dev);
>>> + if (!dev || ret) {
>>> + error("No USB device found\n");
>>> + return -ENODEV;
>>> + }
>>> +
>>> + e_dev->usb_udev = dev;
>>> +
>>> + return ret;
>>> +}
>>> +#endif
>>> +
>>> static int usb_eth_init(struct eth_device *netdev, bd_t *bd)
>>> {
>>> struct eth_dev *dev = &l_ethdev;
>>> @@ -2315,7 +2340,14 @@ static int usb_eth_init(struct eth_device *netdev, bd_t *bd)
>>> goto fail;
>>> }
>>>
>>> +#ifdef CONFIG_DM_USB
>>> + if (dm_usb_init(dev)) {
>>> + error("USB ether not found\n");
>>> + return -ENODEV;
>>> + }
>>> +#else
>>> board_usb_init(0, USB_INIT_DEVICE);
>>> +#endif
>>>
>>> /* Configure default mac-addresses for the USB ethernet device */
>>> #ifdef CONFIG_USBNET_DEV_ADDR
>>> @@ -2497,7 +2529,11 @@ void usb_eth_halt(struct eth_device *netdev)
>>> }
>>>
>>> usb_gadget_unregister_driver(ð_driver);
>>> +#ifdef CONFIG_DM_USB
>>> + device_remove(dev->usb_udev);
>>> +#else
>>> board_usb_cleanup(0, USB_INIT_DEVICE);
>>> +#endif
>>
>> This doesn't look right to me. If your board is to be an Ethernet
>> device then it should do:
>>
>> uclass_first_device(UCLASS_ETH, &dev)
>>
>> to get the device. That could be in the device tree under the USB
>> node, or perhaps you want to have a setup function which manualy binds
>> the device, a bit like usb_find_and_bind_driver().
>>
>
> This patch is to get usb device for the ether gadget. It uses the same
> api with UCLASS_USB_DEV_GENERIC to get usb device. The patch hadn't done
> for eth driver model adoption.
So can you do that one first, or is it coming soon?
Regards,
Simon
^ permalink raw reply [flat|nested] 15+ messages in thread
* [U-Boot] [PATCH v3 1/6] drivers: usb: gadget: ether: adopt to usb driver model
2016-11-24 2:21 ` Simon Glass
@ 2016-11-24 8:11 ` Mugunthan V N
2016-11-27 17:02 ` Simon Glass
0 siblings, 1 reply; 15+ messages in thread
From: Mugunthan V N @ 2016-11-24 8:11 UTC (permalink / raw)
To: u-boot
Hi Simon
On Thursday 24 November 2016 07:51 AM, Simon Glass wrote:
> Hi Mugunthan,
>
> On 20 November 2016 at 22:38, Mugunthan V N <mugunthanvnm@ti.com> wrote:
>> Hi Simon,
>>
>> On Saturday 19 November 2016 01:04 AM, Simon Glass wrote:
>>> Hi Mugunthan,
>>>
>>> On 17 November 2016 at 01:09, Mugunthan V N <mugunthanvnm@ti.com> wrote:
>>>> Convert usb ether gadget to adopt usb driver model
>>>>
>>>> Signed-off-by: Mugunthan V N <mugunthanvnm@ti.com>
>>>> Reviewed-by: Simon Glass <sjg@chromium.org>
>>>
>>> Sorry, but I'd like to 'un-review' this.
>>>
>>>> ---
>>>> drivers/usb/gadget/ether.c | 36 ++++++++++++++++++++++++++++++++++++
>>>> 1 file changed, 36 insertions(+)
>>>>
>>>> diff --git a/drivers/usb/gadget/ether.c b/drivers/usb/gadget/ether.c
>>>> index 497b981129..9bc61186cf 100644
>>>> --- a/drivers/usb/gadget/ether.c
>>>> +++ b/drivers/usb/gadget/ether.c
>>>> @@ -24,6 +24,10 @@
>>>> #include "gadget_chips.h"
>>>> #include "rndis.h"
>>>>
>>>> +#include <dm.h>
>>>> +#include <dm/uclass-internal.h>
>>>> +#include <dm/device-internal.h>
>>>> +
>>>> #define USB_NET_NAME "usb_ether"
>>>>
>>>> #define atomic_read
>>>> @@ -101,6 +105,9 @@ struct eth_dev {
>>>> struct usb_gadget *gadget;
>>>> struct usb_request *req; /* for control responses */
>>>> struct usb_request *stat_req; /* for cdc & rndis status */
>>>> +#ifdef CONFIG_DM_USB
>>>> + struct udevice *usb_udev;
>>>> +#endif
>>>>
>>>> u8 config;
>>>> struct usb_ep *in_ep, *out_ep, *status_ep;
>>>> @@ -2303,6 +2310,24 @@ fail:
>>>>
>>>> /*-------------------------------------------------------------------------*/
>>>>
>>>> +#ifdef CONFIG_DM_USB
>>>> +int dm_usb_init(struct eth_dev *e_dev)
>>>> +{
>>>> + struct udevice *dev = NULL;
>>>> + int ret;
>>>> +
>>>> + ret = uclass_first_device(UCLASS_USB_DEV_GENERIC, &dev);
>>>> + if (!dev || ret) {
>>>> + error("No USB device found\n");
>>>> + return -ENODEV;
>>>> + }
>>>> +
>>>> + e_dev->usb_udev = dev;
>>>> +
>>>> + return ret;
>>>> +}
>>>> +#endif
>>>> +
>>>> static int usb_eth_init(struct eth_device *netdev, bd_t *bd)
>>>> {
>>>> struct eth_dev *dev = &l_ethdev;
>>>> @@ -2315,7 +2340,14 @@ static int usb_eth_init(struct eth_device *netdev, bd_t *bd)
>>>> goto fail;
>>>> }
>>>>
>>>> +#ifdef CONFIG_DM_USB
>>>> + if (dm_usb_init(dev)) {
>>>> + error("USB ether not found\n");
>>>> + return -ENODEV;
>>>> + }
>>>> +#else
>>>> board_usb_init(0, USB_INIT_DEVICE);
>>>> +#endif
>>>>
>>>> /* Configure default mac-addresses for the USB ethernet device */
>>>> #ifdef CONFIG_USBNET_DEV_ADDR
>>>> @@ -2497,7 +2529,11 @@ void usb_eth_halt(struct eth_device *netdev)
>>>> }
>>>>
>>>> usb_gadget_unregister_driver(ð_driver);
>>>> +#ifdef CONFIG_DM_USB
>>>> + device_remove(dev->usb_udev);
>>>> +#else
>>>> board_usb_cleanup(0, USB_INIT_DEVICE);
>>>> +#endif
>>>
>>> This doesn't look right to me. If your board is to be an Ethernet
>>> device then it should do:
>>>
>>> uclass_first_device(UCLASS_ETH, &dev)
>>>
>>> to get the device. That could be in the device tree under the USB
>>> node, or perhaps you want to have a setup function which manualy binds
>>> the device, a bit like usb_find_and_bind_driver().
>>>
>>
>> This patch is to get usb device for the ether gadget. It uses the same
>> api with UCLASS_USB_DEV_GENERIC to get usb device. The patch hadn't done
>> for eth driver model adoption.
>
> So can you do that one first, or is it coming soon?
>
Its already implemented above in the function dm_usb_init()
Regards
Mugunthan V N
^ permalink raw reply [flat|nested] 15+ messages in thread
* [U-Boot] [PATCH v3 1/6] drivers: usb: gadget: ether: adopt to usb driver model
2016-11-24 8:11 ` Mugunthan V N
@ 2016-11-27 17:02 ` Simon Glass
2016-11-29 23:13 ` Joe Hershberger
0 siblings, 1 reply; 15+ messages in thread
From: Simon Glass @ 2016-11-27 17:02 UTC (permalink / raw)
To: u-boot
Hi Mugunthan,
On 24 November 2016 at 01:11, Mugunthan V N <mugunthanvnm@ti.com> wrote:
> Hi Simon
>
> On Thursday 24 November 2016 07:51 AM, Simon Glass wrote:
>> Hi Mugunthan,
>>
>> On 20 November 2016 at 22:38, Mugunthan V N <mugunthanvnm@ti.com> wrote:
>>> Hi Simon,
>>>
>>> On Saturday 19 November 2016 01:04 AM, Simon Glass wrote:
>>>> Hi Mugunthan,
>>>>
>>>> On 17 November 2016 at 01:09, Mugunthan V N <mugunthanvnm@ti.com> wrote:
>>>>> Convert usb ether gadget to adopt usb driver model
>>>>>
>>>>> Signed-off-by: Mugunthan V N <mugunthanvnm@ti.com>
>>>>> Reviewed-by: Simon Glass <sjg@chromium.org>
>>>>
>>>> Sorry, but I'd like to 'un-review' this.
>>>>
>>>>> ---
>>>>> drivers/usb/gadget/ether.c | 36 ++++++++++++++++++++++++++++++++++++
>>>>> 1 file changed, 36 insertions(+)
>>>>>
>>>>> diff --git a/drivers/usb/gadget/ether.c b/drivers/usb/gadget/ether.c
>>>>> index 497b981129..9bc61186cf 100644
>>>>> --- a/drivers/usb/gadget/ether.c
>>>>> +++ b/drivers/usb/gadget/ether.c
>>>>> @@ -24,6 +24,10 @@
>>>>> #include "gadget_chips.h"
>>>>> #include "rndis.h"
>>>>>
>>>>> +#include <dm.h>
>>>>> +#include <dm/uclass-internal.h>
>>>>> +#include <dm/device-internal.h>
>>>>> +
>>>>> #define USB_NET_NAME "usb_ether"
>>>>>
>>>>> #define atomic_read
>>>>> @@ -101,6 +105,9 @@ struct eth_dev {
>>>>> struct usb_gadget *gadget;
>>>>> struct usb_request *req; /* for control responses */
>>>>> struct usb_request *stat_req; /* for cdc & rndis status */
>>>>> +#ifdef CONFIG_DM_USB
>>>>> + struct udevice *usb_udev;
>>>>> +#endif
>>>>>
>>>>> u8 config;
>>>>> struct usb_ep *in_ep, *out_ep, *status_ep;
>>>>> @@ -2303,6 +2310,24 @@ fail:
>>>>>
>>>>> /*-------------------------------------------------------------------------*/
>>>>>
>>>>> +#ifdef CONFIG_DM_USB
>>>>> +int dm_usb_init(struct eth_dev *e_dev)
>>>>> +{
>>>>> + struct udevice *dev = NULL;
>>>>> + int ret;
>>>>> +
>>>>> + ret = uclass_first_device(UCLASS_USB_DEV_GENERIC, &dev);
>>>>> + if (!dev || ret) {
>>>>> + error("No USB device found\n");
>>>>> + return -ENODEV;
>>>>> + }
>>>>> +
>>>>> + e_dev->usb_udev = dev;
>>>>> +
>>>>> + return ret;
>>>>> +}
>>>>> +#endif
>>>>> +
>>>>> static int usb_eth_init(struct eth_device *netdev, bd_t *bd)
>>>>> {
>>>>> struct eth_dev *dev = &l_ethdev;
>>>>> @@ -2315,7 +2340,14 @@ static int usb_eth_init(struct eth_device *netdev, bd_t *bd)
>>>>> goto fail;
>>>>> }
>>>>>
>>>>> +#ifdef CONFIG_DM_USB
>>>>> + if (dm_usb_init(dev)) {
>>>>> + error("USB ether not found\n");
>>>>> + return -ENODEV;
>>>>> + }
>>>>> +#else
>>>>> board_usb_init(0, USB_INIT_DEVICE);
>>>>> +#endif
>>>>>
>>>>> /* Configure default mac-addresses for the USB ethernet device */
>>>>> #ifdef CONFIG_USBNET_DEV_ADDR
>>>>> @@ -2497,7 +2529,11 @@ void usb_eth_halt(struct eth_device *netdev)
>>>>> }
>>>>>
>>>>> usb_gadget_unregister_driver(ð_driver);
>>>>> +#ifdef CONFIG_DM_USB
>>>>> + device_remove(dev->usb_udev);
>>>>> +#else
>>>>> board_usb_cleanup(0, USB_INIT_DEVICE);
>>>>> +#endif
>>>>
>>>> This doesn't look right to me. If your board is to be an Ethernet
>>>> device then it should do:
>>>>
>>>> uclass_first_device(UCLASS_ETH, &dev)
>>>>
>>>> to get the device. That could be in the device tree under the USB
>>>> node, or perhaps you want to have a setup function which manualy binds
>>>> the device, a bit like usb_find_and_bind_driver().
>>>>
>>>
>>> This patch is to get usb device for the ether gadget. It uses the same
>>> api with UCLASS_USB_DEV_GENERIC to get usb device. The patch hadn't done
>>> for eth driver model adoption.
>>
>> So can you do that one first, or is it coming soon?
>>
>
> Its already implemented above in the function dm_usb_init()
So are you saying that the Ethernet 'USB device' driver needs to be
converted to driver model? Otherwise what stops us from using
UCLASS_ETH here?
Regards,
Simon
^ permalink raw reply [flat|nested] 15+ messages in thread
* [U-Boot] [PATCH v3 1/6] drivers: usb: gadget: ether: adopt to usb driver model
2016-11-27 17:02 ` Simon Glass
@ 2016-11-29 23:13 ` Joe Hershberger
2016-11-30 5:13 ` Mugunthan V N
0 siblings, 1 reply; 15+ messages in thread
From: Joe Hershberger @ 2016-11-29 23:13 UTC (permalink / raw)
To: u-boot
On Sun, Nov 27, 2016 at 11:02 AM, Simon Glass <sjg@chromium.org> wrote:
> Hi Mugunthan,
>
> On 24 November 2016 at 01:11, Mugunthan V N <mugunthanvnm@ti.com> wrote:
>> Hi Simon
>>
>> On Thursday 24 November 2016 07:51 AM, Simon Glass wrote:
>>> Hi Mugunthan,
>>>
>>> On 20 November 2016 at 22:38, Mugunthan V N <mugunthanvnm@ti.com> wrote:
>>>> Hi Simon,
>>>>
>>>> On Saturday 19 November 2016 01:04 AM, Simon Glass wrote:
>>>>> Hi Mugunthan,
>>>>>
>>>>> On 17 November 2016 at 01:09, Mugunthan V N <mugunthanvnm@ti.com> wrote:
>>>>>> Convert usb ether gadget to adopt usb driver model
>>>>>>
>>>>>> Signed-off-by: Mugunthan V N <mugunthanvnm@ti.com>
>>>>>> Reviewed-by: Simon Glass <sjg@chromium.org>
>>>>>
>>>>> Sorry, but I'd like to 'un-review' this.
>>>>>
>>>>>> ---
>>>>>> drivers/usb/gadget/ether.c | 36 ++++++++++++++++++++++++++++++++++++
>>>>>> 1 file changed, 36 insertions(+)
>>>>>>
>>>>>> diff --git a/drivers/usb/gadget/ether.c b/drivers/usb/gadget/ether.c
>>>>>> index 497b981129..9bc61186cf 100644
>>>>>> --- a/drivers/usb/gadget/ether.c
>>>>>> +++ b/drivers/usb/gadget/ether.c
>>>>>> @@ -24,6 +24,10 @@
>>>>>> #include "gadget_chips.h"
>>>>>> #include "rndis.h"
>>>>>>
>>>>>> +#include <dm.h>
>>>>>> +#include <dm/uclass-internal.h>
>>>>>> +#include <dm/device-internal.h>
>>>>>> +
>>>>>> #define USB_NET_NAME "usb_ether"
>>>>>>
>>>>>> #define atomic_read
>>>>>> @@ -101,6 +105,9 @@ struct eth_dev {
>>>>>> struct usb_gadget *gadget;
>>>>>> struct usb_request *req; /* for control responses */
>>>>>> struct usb_request *stat_req; /* for cdc & rndis status */
>>>>>> +#ifdef CONFIG_DM_USB
>>>>>> + struct udevice *usb_udev;
>>>>>> +#endif
>>>>>>
>>>>>> u8 config;
>>>>>> struct usb_ep *in_ep, *out_ep, *status_ep;
>>>>>> @@ -2303,6 +2310,24 @@ fail:
>>>>>>
>>>>>> /*-------------------------------------------------------------------------*/
>>>>>>
>>>>>> +#ifdef CONFIG_DM_USB
>>>>>> +int dm_usb_init(struct eth_dev *e_dev)
>>>>>> +{
>>>>>> + struct udevice *dev = NULL;
>>>>>> + int ret;
>>>>>> +
>>>>>> + ret = uclass_first_device(UCLASS_USB_DEV_GENERIC, &dev);
>>>>>> + if (!dev || ret) {
>>>>>> + error("No USB device found\n");
>>>>>> + return -ENODEV;
>>>>>> + }
>>>>>> +
>>>>>> + e_dev->usb_udev = dev;
>>>>>> +
>>>>>> + return ret;
>>>>>> +}
>>>>>> +#endif
>>>>>> +
>>>>>> static int usb_eth_init(struct eth_device *netdev, bd_t *bd)
>>>>>> {
>>>>>> struct eth_dev *dev = &l_ethdev;
>>>>>> @@ -2315,7 +2340,14 @@ static int usb_eth_init(struct eth_device *netdev, bd_t *bd)
>>>>>> goto fail;
>>>>>> }
>>>>>>
>>>>>> +#ifdef CONFIG_DM_USB
>>>>>> + if (dm_usb_init(dev)) {
>>>>>> + error("USB ether not found\n");
>>>>>> + return -ENODEV;
>>>>>> + }
>>>>>> +#else
>>>>>> board_usb_init(0, USB_INIT_DEVICE);
>>>>>> +#endif
>>>>>>
>>>>>> /* Configure default mac-addresses for the USB ethernet device */
>>>>>> #ifdef CONFIG_USBNET_DEV_ADDR
>>>>>> @@ -2497,7 +2529,11 @@ void usb_eth_halt(struct eth_device *netdev)
>>>>>> }
>>>>>>
>>>>>> usb_gadget_unregister_driver(ð_driver);
>>>>>> +#ifdef CONFIG_DM_USB
>>>>>> + device_remove(dev->usb_udev);
>>>>>> +#else
>>>>>> board_usb_cleanup(0, USB_INIT_DEVICE);
>>>>>> +#endif
>>>>>
>>>>> This doesn't look right to me. If your board is to be an Ethernet
>>>>> device then it should do:
>>>>>
>>>>> uclass_first_device(UCLASS_ETH, &dev)
>>>>>
>>>>> to get the device. That could be in the device tree under the USB
>>>>> node, or perhaps you want to have a setup function which manualy binds
>>>>> the device, a bit like usb_find_and_bind_driver().
>>>>>
>>>>
>>>> This patch is to get usb device for the ether gadget. It uses the same
>>>> api with UCLASS_USB_DEV_GENERIC to get usb device. The patch hadn't done
>>>> for eth driver model adoption.
>>>
>>> So can you do that one first, or is it coming soon?
>>>
>>
>> Its already implemented above in the function dm_usb_init()
>
> So are you saying that the Ethernet 'USB device' driver needs to be
> converted to driver model? Otherwise what stops us from using
> UCLASS_ETH here?
I think the confusion might be that this is a USB gadget and it
doesn't support ETH DM yet. This code needs lots of clean-up. It is
still using the old Ethernet stack. This just makes the driver able to
function if you have USB DM enabled.
At least that how I understand this patch.
-Joe
^ permalink raw reply [flat|nested] 15+ messages in thread
* [U-Boot] [PATCH v3 1/6] drivers: usb: gadget: ether: adopt to usb driver model
2016-11-29 23:13 ` Joe Hershberger
@ 2016-11-30 5:13 ` Mugunthan V N
0 siblings, 0 replies; 15+ messages in thread
From: Mugunthan V N @ 2016-11-30 5:13 UTC (permalink / raw)
To: u-boot
On Wednesday 30 November 2016 04:43 AM, Joe Hershberger wrote:
> On Sun, Nov 27, 2016 at 11:02 AM, Simon Glass <sjg@chromium.org> wrote:
>> Hi Mugunthan,
>>
>> On 24 November 2016 at 01:11, Mugunthan V N <mugunthanvnm@ti.com> wrote:
>>> Hi Simon
>>>
>>> On Thursday 24 November 2016 07:51 AM, Simon Glass wrote:
>>>> Hi Mugunthan,
>>>>
>>>> On 20 November 2016 at 22:38, Mugunthan V N <mugunthanvnm@ti.com> wrote:
>>>>> Hi Simon,
>>>>>
>>>>> On Saturday 19 November 2016 01:04 AM, Simon Glass wrote:
>>>>>> Hi Mugunthan,
>>>>>>
>>>>>> On 17 November 2016 at 01:09, Mugunthan V N <mugunthanvnm@ti.com> wrote:
>>>>>>> Convert usb ether gadget to adopt usb driver model
>>>>>>>
>>>>>>> Signed-off-by: Mugunthan V N <mugunthanvnm@ti.com>
>>>>>>> Reviewed-by: Simon Glass <sjg@chromium.org>
>>>>>>
>>>>>> Sorry, but I'd like to 'un-review' this.
>>>>>>
>>>>>>> ---
>>>>>>> drivers/usb/gadget/ether.c | 36 ++++++++++++++++++++++++++++++++++++
>>>>>>> 1 file changed, 36 insertions(+)
>>>>>>>
>>>>>>> diff --git a/drivers/usb/gadget/ether.c b/drivers/usb/gadget/ether.c
>>>>>>> index 497b981129..9bc61186cf 100644
>>>>>>> --- a/drivers/usb/gadget/ether.c
>>>>>>> +++ b/drivers/usb/gadget/ether.c
>>>>>>> @@ -24,6 +24,10 @@
>>>>>>> #include "gadget_chips.h"
>>>>>>> #include "rndis.h"
>>>>>>>
>>>>>>> +#include <dm.h>
>>>>>>> +#include <dm/uclass-internal.h>
>>>>>>> +#include <dm/device-internal.h>
>>>>>>> +
>>>>>>> #define USB_NET_NAME "usb_ether"
>>>>>>>
>>>>>>> #define atomic_read
>>>>>>> @@ -101,6 +105,9 @@ struct eth_dev {
>>>>>>> struct usb_gadget *gadget;
>>>>>>> struct usb_request *req; /* for control responses */
>>>>>>> struct usb_request *stat_req; /* for cdc & rndis status */
>>>>>>> +#ifdef CONFIG_DM_USB
>>>>>>> + struct udevice *usb_udev;
>>>>>>> +#endif
>>>>>>>
>>>>>>> u8 config;
>>>>>>> struct usb_ep *in_ep, *out_ep, *status_ep;
>>>>>>> @@ -2303,6 +2310,24 @@ fail:
>>>>>>>
>>>>>>> /*-------------------------------------------------------------------------*/
>>>>>>>
>>>>>>> +#ifdef CONFIG_DM_USB
>>>>>>> +int dm_usb_init(struct eth_dev *e_dev)
>>>>>>> +{
>>>>>>> + struct udevice *dev = NULL;
>>>>>>> + int ret;
>>>>>>> +
>>>>>>> + ret = uclass_first_device(UCLASS_USB_DEV_GENERIC, &dev);
>>>>>>> + if (!dev || ret) {
>>>>>>> + error("No USB device found\n");
>>>>>>> + return -ENODEV;
>>>>>>> + }
>>>>>>> +
>>>>>>> + e_dev->usb_udev = dev;
>>>>>>> +
>>>>>>> + return ret;
>>>>>>> +}
>>>>>>> +#endif
>>>>>>> +
>>>>>>> static int usb_eth_init(struct eth_device *netdev, bd_t *bd)
>>>>>>> {
>>>>>>> struct eth_dev *dev = &l_ethdev;
>>>>>>> @@ -2315,7 +2340,14 @@ static int usb_eth_init(struct eth_device *netdev, bd_t *bd)
>>>>>>> goto fail;
>>>>>>> }
>>>>>>>
>>>>>>> +#ifdef CONFIG_DM_USB
>>>>>>> + if (dm_usb_init(dev)) {
>>>>>>> + error("USB ether not found\n");
>>>>>>> + return -ENODEV;
>>>>>>> + }
>>>>>>> +#else
>>>>>>> board_usb_init(0, USB_INIT_DEVICE);
>>>>>>> +#endif
>>>>>>>
>>>>>>> /* Configure default mac-addresses for the USB ethernet device */
>>>>>>> #ifdef CONFIG_USBNET_DEV_ADDR
>>>>>>> @@ -2497,7 +2529,11 @@ void usb_eth_halt(struct eth_device *netdev)
>>>>>>> }
>>>>>>>
>>>>>>> usb_gadget_unregister_driver(ð_driver);
>>>>>>> +#ifdef CONFIG_DM_USB
>>>>>>> + device_remove(dev->usb_udev);
>>>>>>> +#else
>>>>>>> board_usb_cleanup(0, USB_INIT_DEVICE);
>>>>>>> +#endif
>>>>>>
>>>>>> This doesn't look right to me. If your board is to be an Ethernet
>>>>>> device then it should do:
>>>>>>
>>>>>> uclass_first_device(UCLASS_ETH, &dev)
>>>>>>
>>>>>> to get the device. That could be in the device tree under the USB
>>>>>> node, or perhaps you want to have a setup function which manualy binds
>>>>>> the device, a bit like usb_find_and_bind_driver().
>>>>>>
>>>>>
>>>>> This patch is to get usb device for the ether gadget. It uses the same
>>>>> api with UCLASS_USB_DEV_GENERIC to get usb device. The patch hadn't done
>>>>> for eth driver model adoption.
>>>>
>>>> So can you do that one first, or is it coming soon?
>>>>
>>>
>>> Its already implemented above in the function dm_usb_init()
>>
>> So are you saying that the Ethernet 'USB device' driver needs to be
>> converted to driver model? Otherwise what stops us from using
>> UCLASS_ETH here?
>
> I think the confusion might be that this is a USB gadget and it
> doesn't support ETH DM yet. This code needs lots of clean-up. It is
> still using the old Ethernet stack. This just makes the driver able to
> function if you have USB DM enabled.
>
> At least that how I understand this patch.
>
Yes, this patch adopts the driver to use DM_USB and still use only non
DM ETH. Patch 6/6 actually converts the driver to adopt DM_ETH.
Regards
Mugunthan V N
^ permalink raw reply [flat|nested] 15+ messages in thread
end of thread, other threads:[~2016-11-30 5:13 UTC | newest]
Thread overview: 15+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-11-17 8:09 [U-Boot] [PATCH v3 0/6] DM conversion of usb ether gadget Mugunthan V N
2016-11-17 8:09 ` [U-Boot] [PATCH v3 1/6] drivers: usb: gadget: ether: adopt to usb driver model Mugunthan V N
2016-11-18 19:34 ` Simon Glass
2016-11-21 5:38 ` Mugunthan V N
2016-11-24 2:21 ` Simon Glass
2016-11-24 8:11 ` Mugunthan V N
2016-11-27 17:02 ` Simon Glass
2016-11-29 23:13 ` Joe Hershberger
2016-11-30 5:13 ` Mugunthan V N
2016-11-17 8:09 ` [U-Boot] [PATCH v3 2/6] drivers: usb: gadget: ether: access network_started using local variable Mugunthan V N
2016-11-17 8:09 ` [U-Boot] [PATCH v3 3/6] drivers: usb: gadget: ether: consolidate global devices to single struct Mugunthan V N
2016-11-17 8:09 ` [U-Boot] [PATCH v3 4/6] drivers: usb: gadget: ether: use net device priv to pass usb ether priv Mugunthan V N
2016-11-17 8:09 ` [U-Boot] [PATCH v3 5/6] drivers: usb: gadget: ether: prepare driver for driver model migration Mugunthan V N
2016-11-17 8:09 ` [U-Boot] [PATCH v3 6/6] drivers: usb: gadget: ether/rndis: convert driver to adopt device driver model Mugunthan V N
2016-11-18 5:56 ` [U-Boot] [PATCH v3 0/6] DM conversion of usb ether gadget Mugunthan V N
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.