[U-Boot] [PATCH v2 3/3] drivers: usb: gadget: ether/rndis: convert driver to adopt device driver model

2016-12-14 Thread Mugunthan V N
Adopt usb ether gadget and rndis driver to adopt driver model

Signed-off-by: Mugunthan V N <mugunthan...@ti.com>
---
 drivers/usb/gadget/ether.c | 152 ++---
 drivers/usb/gadget/rndis.c |  13 +++-
 drivers/usb/gadget/rndis.h |  19 --
 include/net.h  |   8 +++
 4 files changed, 177 insertions(+), 15 deletions(-)

diff --git a/drivers/usb/gadget/ether.c b/drivers/usb/gadget/ether.c
index e8d9e4a9c9..c5eb552129 100644
--- a/drivers/usb/gadget/ether.c
+++ b/drivers/usb/gadget/ether.c
@@ -25,11 +25,22 @@
 #include "rndis.h"
 
 #include 
+#include 
 #include 
 #include 
 
 #define USB_NET_NAME "usb_ether"
 
+/*
+ * This driver support only the following combinations.
+ * DM_ETH + DM_USB
+ * !DM_ETH + DM_USB
+ * !DM_ETH + !DM_USB
+ */
+#if defined(CONFIG_DM_ETH) && !defined(CONFIG_DM_USB)
+#error "This driver doesn't support the combination of DM_ETH and !DM_USB"
+#endif
+
 #define atomic_read
 extern struct platform_data brd;
 
@@ -116,7 +127,11 @@ struct eth_dev {
 
struct usb_request  *tx_req, *rx_req;
 
+#ifdef CONFIG_DM_ETH
+   struct udevice  *net;
+#else
struct eth_device   *net;
+#endif
struct net_device_stats stats;
unsigned inttx_qlen;
 
@@ -143,7 +158,11 @@ struct eth_dev {
 /*-*/
 struct ether_priv {
struct eth_dev ethdev;
+#ifdef CONFIG_DM_ETH
+   struct udevice *netdev;
+#else
struct eth_device netdev;
+#endif
struct usb_gadget_driver eth_driver;
 };
 
@@ -1851,7 +1870,11 @@ static void rndis_control_ack_complete(struct usb_ep *ep,
 
 static char rndis_resp_buf[8] __attribute__((aligned(sizeof(__le32;
 
+#ifdef CONFIG_DM_ETH
+static int rndis_control_ack(struct udevice *net)
+#else
 static int rndis_control_ack(struct eth_device *net)
+#endif
 {
struct ether_priv   *priv = (struct ether_priv *)net->priv;
struct eth_dev  *dev = >ethdev;
@@ -2000,6 +2023,9 @@ static int eth_bind(struct usb_gadget *gadget)
struct usb_ep   *in_ep, *out_ep, *status_ep = NULL;
int status = -ENOMEM;
int gcnum;
+#ifdef CONFIG_DM_ETH
+   struct eth_pdata*pdata = dev_get_platdata(l_priv->netdev);
+#endif
 
/* these flags are only ever cleared; compiler take note */
 #ifndefCONFIG_USB_ETH_CDC
@@ -2187,7 +2213,11 @@ autoconf_fail:
 
 
/* network device setup */
+#ifdef CONFIG_DM_ETH
+   dev->net = l_priv->netdev;
+#else
dev->net = _priv->netdev;
+#endif
 
dev->cdc = cdc;
dev->zlp = zlp;
@@ -2203,7 +2233,13 @@ autoconf_fail:
 * host side code for the SAFE thing cares -- its original BLAN
 * thing didn't, Sharp never assigned those addresses on Zaurii.
 */
-   get_ether_addr(dev_addr, dev->net->enetaddr);
+#ifdef CONFIG_DM_ETH
+   if (is_eth_addr_valid(dev_addr))
+   get_ether_addr(dev_addr, pdata->enetaddr);
+#else
+   if (is_eth_addr_valid(dev_addr))
+   get_ether_addr(dev_addr, dev->net->enetaddr);
+#endif
 
get_ether_addr(host_addr, dev->host_mac);
 
@@ -2264,10 +2300,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]);
+#ifdef CONFIG_DM_ETH
+   printf("MAC %pM\n", pdata->enetaddr);
+#else
+   printf("MAC %pM\n", dev->net->enetaddr);
+#endif
 
if (cdc || rndis)
printf("HOST MAC %02x:%02x:%02x:%02x:%02x:%02x\n",
@@ -2364,10 +2401,6 @@ static int _usb_eth_init(struct ether_priv *priv)
strlcpy(host_addr, getenv("usbnet_hostaddr"),
sizeof(host_addr));
 
-   if (!is_eth_addr_valid(dev_addr)) {
-   error("Need valid 'usbnet_devaddr' to be set");
-   goto fail;
-   }
if (!is_eth_addr_valid(host_addr)) {
error("Need valid 'usbnet_hostaddr' to be set");
goto fail;
@@ -2527,6 +2560,7 @@ void _usb_eth_halt(struct ether_priv *priv)
 #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 +2627,103 @@ 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 = d

[U-Boot] [PATCH v2 0/3] DM conversion of usb ether gadget

2016-12-14 Thread Mugunthan V N
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 v3:
* Removed the patches already applied.
* Changed to possitive approach for #ifndef CONFIG_DM_USB
* Removed hardcoding of usb device mac id from Kconfig over
  enviroment. Now it is like use enviroment mac or use
  random mac generated by dm-eth framework.
* Added a build error when DM_ETH is defined and DM_USB
  not defined as the driver doesn't support this combination
* Added two new patches which removed tmp variable which is
  initialized and never been used and another to fix a crash
  when DM_USB and DM_ETH are defined.

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/23628667/
[2] - git://git.ti.com/~mugunthanvnm/ti-u-boot/mugunth-ti-u-boot.git 
usb-ether-v4
[3] - http://lists.denx.de/pipermail/u-boot/2016-February/246827.html

Mugunthan V N (3):
  drivers: usb: gadget: ether: do not register usb when DM_USB and
DM_ETH defined
  drivers: usb: gadget: ether: remove unused variable tmp
  drivers: usb: gadget: ether/rndis: convert driver to adopt device
driver model

 drivers/usb/gadget/ether.c | 164 -
 drivers/usb/gadget/rndis.c |  13 +++-
 drivers/usb/gadget/rndis.h |  19 --
 include/net.h  |   8 +++
 4 files changed, 183 insertions(+), 21 deletions(-)

-- 
2.11.0

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


[U-Boot] [PATCH v2 1/3] drivers: usb: gadget: ether: do not register usb when DM_USB and DM_ETH defined

2016-12-14 Thread Mugunthan V N
when both DM_USB and DM_ETH are defined which denoted that
usb_ether has been registered from a usb device. So registering a
USB device doesn't do any thing and de-register leads to crash as
it try to remove its own parent. Sample dm-tree output below.

 eth [ + ]|-- ethernet@4a10
 misc[ + ]`-- usb@4740
 usb_dev_gen [ + ]|-- usb@47401000
 eth [ + ]|   `-- usb_ether
 usb [   ]`-- usb@47401800

Signed-off-by: Mugunthan V N <mugunthan...@ti.com>
---
 drivers/usb/gadget/ether.c | 8 ++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/drivers/usb/gadget/ether.c b/drivers/usb/gadget/ether.c
index 046ad8ca2b..bcc8be86a5 100644
--- a/drivers/usb/gadget/ether.c
+++ b/drivers/usb/gadget/ether.c
@@ -105,7 +105,7 @@ 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
+#if defined(CONFIG_DM_USB) && !defined(CONFIG_DM_ETH)
struct udevice  *usb_udev;
 #endif
 
@@ -2316,7 +2316,7 @@ fail:
 
 /*-*/
 
-#ifdef CONFIG_DM_USB
+#if defined(CONFIG_DM_USB) && !defined(CONFIG_DM_ETH)
 int dm_usb_init(struct eth_dev *e_dev)
 {
struct udevice *dev = NULL;
@@ -2342,10 +2342,12 @@ static int _usb_eth_init(struct ether_priv *priv)
unsigned long timeout = USB_CONNECT_TIMEOUT;
 
 #ifdef CONFIG_DM_USB
+#ifndef CONFIG_DM_ETH
if (dm_usb_init(dev)) {
error("USB ether not found\n");
return -ENODEV;
}
+#endif
 #else
board_usb_init(0, USB_INIT_DEVICE);
 #endif
@@ -2521,7 +2523,9 @@ void _usb_eth_halt(struct ether_priv *priv)
 
usb_gadget_unregister_driver(>eth_driver);
 #ifdef CONFIG_DM_USB
+#ifndef CONFIG_DM_ETH
device_remove(dev->usb_udev);
+#endif
 #else
board_usb_cleanup(0, USB_INIT_DEVICE);
 #endif
-- 
2.11.0

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


[U-Boot] [PATCH v2 2/3] drivers: usb: gadget: ether: remove unused variable tmp

2016-12-14 Thread Mugunthan V N
tmp variable in eth_bind() is never used any where, so remove it.

Signed-off-by: Mugunthan V N <mugunthan...@ti.com>
---
 drivers/usb/gadget/ether.c | 4 
 1 file changed, 4 deletions(-)

diff --git a/drivers/usb/gadget/ether.c b/drivers/usb/gadget/ether.c
index bcc8be86a5..e8d9e4a9c9 100644
--- a/drivers/usb/gadget/ether.c
+++ b/drivers/usb/gadget/ether.c
@@ -2000,7 +2000,6 @@ static int eth_bind(struct usb_gadget *gadget)
struct usb_ep   *in_ep, *out_ep, *status_ep = NULL;
int status = -ENOMEM;
int gcnum;
-   u8  tmp[7];
 
/* these flags are only ever cleared; compiler take note */
 #ifndefCONFIG_USB_ETH_CDC
@@ -2206,9 +2205,6 @@ autoconf_fail:
 */
get_ether_addr(dev_addr, dev->net->enetaddr);
 
-   memset(tmp, 0, sizeof(tmp));
-   memcpy(tmp, dev->net->enetaddr, sizeof(dev->net->enetaddr));
-
get_ether_addr(host_addr, dev->host_mac);
 
sprintf(ethaddr, "%02X%02X%02X%02X%02X%02X",
-- 
2.11.0

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


Re: [U-Boot] [PATCH resend v3 6/6] drivers: usb: gadget: ether/rndis: convert driver to adopt device driver model

2016-11-29 Thread Mugunthan V N
On Wednesday 30 November 2016 05:24 AM, Joe Hershberger wrote:
> On Thu, Nov 17, 2016 at 11:39 PM, Mugunthan V N <mugunthan...@ti.com> wrote:
>> Adopt usb ether gadget and rndis driver to adopt driver model
>>
>> Signed-off-by: Mugunthan V N <mugunthan...@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"
> 
> Please don't do this. We don't have "default" MAC addresses. They are
> either from the env, from ROM, or randomly generated.
> 

Okay will remove this and use either env MAC or random MAC.

>> +
>>  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 
>> +#include 
>>  #include 
>>  #include 
>>
>> @@ -116,7 +117,11 @@ struct eth_dev {
>>
>> struct usb_request  *tx_req, *rx_req;
>>
>> +#ifndef CONFIG_DM_ETH
> 
> Please use positive logic.

Okay, will fix in next version.

> 
>> struct eth_device   *net;
>> +#else
>> +   struct udevice  *net;
>> +#endif
>> struct net_device_stats stats;
>> unsigned inttx_qlen;
>>
>> @@ -143,7 +148,11 @@ struct eth_dev {
>>  
>> /*-*/
>>  struct ether_priv {
>> struct eth_dev ethdev;
>> +#ifndef CONFIG_DM_ETH
> 
> Please use positive logic
> 
>> struct eth_device netdev;
>> +#else
>> +   struct udevice *netdev;
> 
> Did you really intend to have a pointer here when the other is an
> inline structure?

Yes, udevice is the device allocated by probe and passed in probe, but
in non-dm case netdev has to be allocated by driver, in this case it
declared as inline structure.

> 
>> +#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
> 
> Please use positive logic.
> 
>>  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 = >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 */
>>  #ifndefCONFIG_USB_ETH_CDC
>> @@ -2188,7 +2204,11 @@ autoconf_fail:
>>
>>
>> /* network device setup */
>> +#ifndef CONFIG_DM_ETH
>> dev->net = _priv->netdev;
> 
> You wouldn't need this difference if the priv also used a ptr in the
> non-dm case.
> 
> Also, if you are opposed to cleaning this up (preferably by adding a
> preceding patch to make it a pointer), at least use positive logic
> (#ifdef CONFIG_DM_ETH). Same applies elsewhere.

Okay, will add a patch to convert netdev to pointer

> 
>> +#else
>> +   dev->net = l_priv->netdev;
>> +#endif
>>
>> dev->cdc = cdc;
>> dev->zlp = zlp;
>> @@ -2197,6 +2217,7 @@ autoconf_fail:
>> dev->out_ep = out_

Re: [U-Boot] [PATCH v3 1/6] drivers: usb: gadget: ether: adopt to usb driver model

2016-11-29 Thread Mugunthan V N
On Wednesday 30 November 2016 04:43 AM, Joe Hershberger wrote:
> On Sun, Nov 27, 2016 at 11:02 AM, Simon Glass <s...@chromium.org> wrote:
>> Hi Mugunthan,
>>
>> On 24 November 2016 at 01:11, Mugunthan V N <mugunthan...@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 <mugunthan...@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 <mugunthan...@ti.com> wrote:
>>>>>>> Convert usb ether gadget to adopt usb driver model
>>>>>>>
>>>>>>> Signed-off-by: Mugunthan V N <mugunthan...@ti.com>
>>>>>>> Reviewed-by: Simon Glass <s...@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 
>>>>>>> +#include 
>>>>>>> +#include 
>>>>>>> +
>>>>>>>  #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, );
>>>>>>> +   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 = _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
>>>>>

Re: [U-Boot] [PATCH v3 1/6] drivers: usb: gadget: ether: adopt to usb driver model

2016-11-24 Thread Mugunthan V N
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 <mugunthan...@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 <mugunthan...@ti.com> wrote:
>>>> Convert usb ether gadget to adopt usb driver model
>>>>
>>>> Signed-off-by: Mugunthan V N <mugunthan...@ti.com>
>>>> Reviewed-by: Simon Glass <s...@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 
>>>> +#include 
>>>> +#include 
>>>> +
>>>>  #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, );
>>>> +   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 = _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, )
>>>
>>> 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

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


Re: [U-Boot] [PATCH] defconfig: am43xx_evm: Enable DM_SPI and DM_SPI_FLASH

2016-11-22 Thread Mugunthan V N
On Tuesday 22 November 2016 02:42 PM, Vignesh R wrote:
> Commit 4c4e3b37750f3("ARM: AM43xx: Enable FIT") accidentally disabled
> DM_SPI and DM_SPI_FLASH. Add back DM_SPI and DM_SPI_FLASH to
> am43xx_evm_defconfig in order to make use of DM framework for QSPI.
> 
> Signed-off-by: Vignesh R <vigne...@ti.com>

Reviewed-by: Mugunthan V N <mugunthan...@ti.com>

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


Re: [U-Boot] [PATCH v3 1/6] drivers: usb: gadget: ether: adopt to usb driver model

2016-11-20 Thread Mugunthan V N
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 <mugunthan...@ti.com> wrote:
>> Convert usb ether gadget to adopt usb driver model
>>
>> Signed-off-by: Mugunthan V N <mugunthan...@ti.com>
>> Reviewed-by: Simon Glass <s...@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 
>> +#include 
>> +#include 
>> +
>>  #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, );
>> +   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 = _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, )
> 
> 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
___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


[U-Boot] [PATCH v3 4/6] drivers: usb: gadget: ether: use net device priv to pass usb ether priv

2016-11-20 Thread Mugunthan V N
Use net device priv to pass usb ether priv and use it in
net device ops callback.

Signed-off-by: Mugunthan V N <mugunthan...@ti.com>
Reviewed-by: Simon Glass <s...@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 = _priv->ethdev;
+   struct ether_priv   *priv = (struct ether_priv *)net->priv;
+   struct eth_dev  *dev = >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 = _priv->ethdev;
+   struct ether_priv *priv = (struct ether_priv *)netdev->priv;
+   struct eth_dev *dev = >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(_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(>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 = _priv->ethdev;
+   struct ether_priv   *priv = (struct ether_priv *)netdev->priv;
+   struct eth_dev  *dev = >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 = _priv->ethdev;
+   struct ether_priv *priv = (struct ether_priv *)netdev->priv;
+   struct eth_dev *dev = >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 = _priv->ethdev;
-
-   if (!netdev) {
-   error("received NULL ptr");
-   return;
-   }
+   struct ether_priv *priv = (struct ether_priv *)netdev->priv;
+   struct eth_dev *dev = >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(_priv->eth_driver);
+   usb_gadget_unregister_driver(>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

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


[U-Boot] [PATCH v3 6/6] drivers: usb: gadget: ether/rndis: convert driver to adopt device driver model

2016-11-20 Thread Mugunthan V N
Adopt usb ether gadget and rndis driver to adopt driver model

Signed-off-by: Mugunthan V N <mugunthan...@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 
+#include 
 #include 
 #include 
 
@@ -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 inttx_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 = >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 */
 #ifndefCONFIG_USB_ETH_CDC
@@ -2188,7 +2204,11 @@ autoconf_fail:
 
 
/* network device setup */
+#ifndef CONFIG_DM_ETH
dev->net = _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(>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_

[U-Boot] [PATCH v3 3/6] drivers: usb: gadget: ether: consolidate global devices to single struct

2016-11-18 Thread Mugunthan V N
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 <mugunthan...@ti.com>
Reviewed-by: Simon Glass <s...@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 = _ethdev;
+   struct eth_dev  *dev = _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 = _ethdev;
+   struct eth_dev  *dev = _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 = _netdev;
+   dev->net = _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 = _ethdev;
+   struct eth_dev *dev = _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(_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 = _ethdev;
+   struct eth_dev  *dev = _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 = _ethdev;
+   struct eth_dev *dev = _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 = _ethdev;
+   struct eth_dev *dev = _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(_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 = _netdev;
+   struct eth_device *net

[U-Boot] [PATCH v3 0/6] DM conversion of usb ether gadget

2016-11-18 Thread Mugunthan V N
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: 
#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

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


[U-Boot] [PATCH v3 2/6] drivers: usb: gadget: ether: access network_started using local variable

2016-11-18 Thread Mugunthan V N
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 <mugunthan...@ti.com>
Reviewed-by: Simon Glass <s...@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

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


Re: [U-Boot] [PATCH v3 0/6] DM conversion of usb ether gadget

2016-11-17 Thread Mugunthan V N
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
___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


[U-Boot] [PATCH resend v3 6/6] drivers: usb: gadget: ether/rndis: convert driver to adopt device driver model

2016-11-17 Thread Mugunthan V N
Adopt usb ether gadget and rndis driver to adopt driver model

Signed-off-by: Mugunthan V N <mugunthan...@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 
+#include 
 #include 
 #include 
 
@@ -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 inttx_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 = >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 */
 #ifndefCONFIG_USB_ETH_CDC
@@ -2188,7 +2204,11 @@ autoconf_fail:
 
 
/* network device setup */
+#ifndef CONFIG_DM_ETH
dev->net = _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(>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_

[U-Boot] [PATCH resend v3 5/6] drivers: usb: gadget: ether: prepare driver for driver model migration

2016-11-17 Thread Mugunthan V N
prepare driver for driver model migration

Signed-off-by: Mugunthan V N <mugunthan...@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 = >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 = >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 = >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 = >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 = >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 = _priv->netdev;
-- 
2.11.0.rc2

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


[U-Boot] [PATCH resend v3 4/6] drivers: usb: gadget: ether: use net device priv to pass usb ether priv

2016-11-17 Thread Mugunthan V N
Use net device priv to pass usb ether priv and use it in
net device ops callback.

Signed-off-by: Mugunthan V N <mugunthan...@ti.com>
Reviewed-by: Simon Glass <s...@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 = _priv->ethdev;
+   struct ether_priv   *priv = (struct ether_priv *)net->priv;
+   struct eth_dev  *dev = >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 = _priv->ethdev;
+   struct ether_priv *priv = (struct ether_priv *)netdev->priv;
+   struct eth_dev *dev = >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(_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(>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 = _priv->ethdev;
+   struct ether_priv   *priv = (struct ether_priv *)netdev->priv;
+   struct eth_dev  *dev = >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 = _priv->ethdev;
+   struct ether_priv *priv = (struct ether_priv *)netdev->priv;
+   struct eth_dev *dev = >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 = _priv->ethdev;
-
-   if (!netdev) {
-   error("received NULL ptr");
-   return;
-   }
+   struct ether_priv *priv = (struct ether_priv *)netdev->priv;
+   struct eth_dev *dev = >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(_priv->eth_driver);
+   usb_gadget_unregister_driver(>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.rc2

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


[U-Boot] [PATCH resend v3 3/6] drivers: usb: gadget: ether: consolidate global devices to single struct

2016-11-17 Thread Mugunthan V N
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 <mugunthan...@ti.com>
Reviewed-by: Simon Glass <s...@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 = _ethdev;
+   struct eth_dev  *dev = _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 = _ethdev;
+   struct eth_dev  *dev = _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 = _netdev;
+   dev->net = _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 = _ethdev;
+   struct eth_dev *dev = _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(_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 = _ethdev;
+   struct eth_dev  *dev = _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 = _ethdev;
+   struct eth_dev *dev = _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 = _ethdev;
+   struct eth_dev *dev = _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(_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 = _netdev;
+   struct eth_device *net

[U-Boot] [PATCH resend v3 2/6] drivers: usb: gadget: ether: access network_started using local variable

2016-11-17 Thread Mugunthan V N
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 <mugunthan...@ti.com>
Reviewed-by: Simon Glass <s...@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.rc2

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


[U-Boot] [PATCH resend v3 1/6] drivers: usb: gadget: ether: adopt to usb driver model

2016-11-17 Thread Mugunthan V N
Convert usb ether gadget to adopt usb driver model

Signed-off-by: Mugunthan V N <mugunthan...@ti.com>
Reviewed-by: Simon Glass <s...@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 
+#include 
+#include 
+
 #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, );
+   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 = _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.rc2

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


[U-Boot] [PATCH resend v3 0/6] DM conversion of usb ether gadget

2016-11-17 Thread Mugunthan V N
The previous series didn't land on the mailing list properly, so
resending the series as *v3 resend*, sorry for spamming.

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: 
#297: FILE: drivers/usb/gadget/rndis.c:1157:
+int  rndis_set_param_dev(u8 configNr, struct eth_device *dev, int mtu,

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.rc2

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


Re: [U-Boot] [PATCH] drivers: net: keystone_net: add rgmii link type support when parsing dt

2016-11-17 Thread Mugunthan V N
Joe

On Tuesday 15 November 2016 09:10 AM, Joe Hershberger wrote:
> This is great, but can you please add this info to a bindings file in
> doc/device-tree-bindings/net/keystone-netcp.txt so that it's less
> magic?

link-interface is already documented in Kernel device tree bindings
(Documentation/devicetree/bindings/net/keystone-netcp.txt), still do we
need to document the same in u-boot as well?

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


[U-Boot] [PATCH v3 10/10] defconfig: am335x_evm: enable usb driver model

2016-11-17 Thread Mugunthan V N
enable usb driver model for am335x bbb as musb supports
driver model

Signed-off-by: Mugunthan V N <mugunthan...@ti.com>
---
 configs/am335x_evm_defconfig | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/configs/am335x_evm_defconfig b/configs/am335x_evm_defconfig
index e5a1696914..7e1cf3213e 100644
--- a/configs/am335x_evm_defconfig
+++ b/configs/am335x_evm_defconfig
@@ -60,3 +60,6 @@ CONFIG_G_DNL_VENDOR_NUM=0x0451
 CONFIG_G_DNL_PRODUCT_NUM=0xd022
 CONFIG_RSA=y
 CONFIG_SPL_OF_LIBFDT=y
+CONFIG_MISC=y
+CONFIG_DM_USB=y
+CONFIG_USB_MUSB_TI=y
-- 
2.11.0.rc1

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


[U-Boot] [PATCH v3 08/10] am33xx: board: init usb ether gadget for rndis support

2016-11-17 Thread Mugunthan V N
Add usb ether gadget device with usb_ether_init() when
CONFIG_DM_ETH and CONFIG_USB_ETHER are defined.

Signed-off-by: Mugunthan V N <mugunthan...@ti.com>
Reviewed-by: Tom Rini <tr...@konsulko.com>
---
 arch/arm/cpu/armv7/am33xx/board.c | 8 
 1 file changed, 8 insertions(+)

diff --git a/arch/arm/cpu/armv7/am33xx/board.c 
b/arch/arm/cpu/armv7/am33xx/board.c
index 245a9575ec..48816c9809 100644
--- a/arch/arm/cpu/armv7/am33xx/board.c
+++ b/arch/arm/cpu/armv7/am33xx/board.c
@@ -204,6 +204,14 @@ int arch_misc_init(void)
ret = uclass_first_device(UCLASS_MISC, );
if (ret || !dev)
return ret;
+
+#if defined(CONFIG_DM_ETH) && defined(CONFIG_USB_ETHER)
+   ret = usb_ether_init();
+   if (ret) {
+   error("USB ether init failed\n");
+   return ret;
+   }
+#endif
 #endif
return 0;
 }
-- 
2.11.0.rc1

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


[U-Boot] [PATCH v3 09/10] am335x_evm: enable usb ether gadget as it supports DM_ETH

2016-11-17 Thread Mugunthan V N
Since usb ether gadget have support for driver model, so enable
usb ether gadget.

Signed-off-by: Mugunthan V N <mugunthan...@ti.com>
Reviewed-by: Tom Rini <tr...@konsulko.com>
---
 include/configs/am335x_evm.h | 3 ---
 1 file changed, 3 deletions(-)

diff --git a/include/configs/am335x_evm.h b/include/configs/am335x_evm.h
index 8e62248c73..91e02de91f 100644
--- a/include/configs/am335x_evm.h
+++ b/include/configs/am335x_evm.h
@@ -301,12 +301,9 @@
 #endif
 
 #ifdef CONFIG_USB_MUSB_GADGET
-/* Removing USB gadget and can be enabled adter adding support usb DM */
-#ifndef CONFIG_DM_ETH
 #define CONFIG_USB_ETHER
 #define CONFIG_USB_ETH_RNDIS
 #define CONFIG_USBNET_HOST_ADDR"de:ad:be:af:00:00"
-#endif /* CONFIG_DM_ETH */
 #endif /* CONFIG_USB_MUSB_GADGET */
 
 /*
-- 
2.11.0.rc1

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


[U-Boot] [PATCH v3 07/10] drivers: usb: musb: add ti musb peripheral driver with driver model support

2016-11-17 Thread Mugunthan V N
Add a TI MUSB peripheral driver with driver model support and the
driver will be bound by the MUSB wrapper driver based on the
dr_mode device tree entry.

Signed-off-by: Mugunthan V N <mugunthan...@ti.com>
Reviewed-by: Simon Glass <s...@chromium.org>
---
 drivers/usb/musb-new/musb_uboot.c |   2 +
 drivers/usb/musb-new/ti-musb.c| 109 ++
 2 files changed, 111 insertions(+)

diff --git a/drivers/usb/musb-new/musb_uboot.c 
b/drivers/usb/musb-new/musb_uboot.c
index ea71f75947..46e3faeeaa 100644
--- a/drivers/usb/musb-new/musb_uboot.c
+++ b/drivers/usb/musb-new/musb_uboot.c
@@ -373,6 +373,7 @@ struct dm_usb_ops musb_usb_ops = {
 #endif /* CONFIG_DM_USB */
 #endif /* CONFIG_USB_MUSB_HOST */
 
+#ifndef CONFIG_DM_USB
 #ifdef CONFIG_USB_MUSB_GADGET
 static struct musb *gadget;
 
@@ -453,3 +454,4 @@ int musb_register(struct musb_hdrc_platform_data *plat, 
void *bdata,
 
return 0;
 }
+#endif /* CONFIG_DM_USB */
diff --git a/drivers/usb/musb-new/ti-musb.c b/drivers/usb/musb-new/ti-musb.c
index 1c15aa2a42..b8abc1dc58 100644
--- a/drivers/usb/musb-new/ti-musb.c
+++ b/drivers/usb/musb-new/ti-musb.c
@@ -14,6 +14,7 @@
 #include 
 #include 
 
+#include 
 #include 
 #include 
 #include "musb_uboot.h"
@@ -142,6 +143,106 @@ static int ti_musb_ofdata_to_platdata(struct udevice *dev)
return 0;
 }
 
+static struct musb *gadget;
+
+int usb_gadget_handle_interrupts(int index)
+{
+   WATCHDOG_RESET();
+   if (!gadget || !gadget->isr)
+   return -EINVAL;
+
+   return gadget->isr(0, gadget);
+}
+
+int usb_gadget_register_driver(struct usb_gadget_driver *driver)
+{
+   int ret;
+
+   if (!driver || driver->speed < USB_SPEED_FULL || !driver->bind ||
+   !driver->setup) {
+   printf("Bad parameter.\n");
+   return -EINVAL;
+   }
+
+   if (!gadget) {
+   printf("Controller uninitialized\n");
+   return -ENXIO;
+   }
+
+   ret = musb_gadget_start(>g, driver);
+   if (ret < 0)
+   return ret;
+
+   ret = driver->bind(>g);
+   if (ret < 0)
+   return ret;
+
+   return 0;
+}
+
+int usb_gadget_unregister_driver(struct usb_gadget_driver *driver)
+{
+   if (driver->disconnect)
+   driver->disconnect(>g);
+   if (driver->unbind)
+   driver->unbind(>g);
+   return 0;
+}
+
+static int ti_musb_peripheral_usb_probe(struct udevice *dev)
+{
+   struct ti_musb_platdata *platdata = dev_get_platdata(dev);
+   struct usb_bus_priv *priv = dev_get_uclass_priv(dev);
+   struct omap_musb_board_data *otg_board_data;
+
+   otg_board_data = >otg_board_data;
+
+   gadget = musb_init_controller(>plat,
+ (struct device *)otg_board_data,
+ platdata->base);
+   if (!gadget) {
+   error("gadget init failed\n");
+   return -EIO;
+   }
+
+   return 0;
+}
+
+static int ti_musb_peripheral_remove(struct udevice *dev)
+{
+   musb_stop(gadget);
+
+   return 0;
+}
+
+static int ti_musb_peripheral_ofdata_to_platdata(struct udevice *dev)
+{
+   struct ti_musb_platdata *platdata = dev_get_platdata(dev);
+   const void *fdt = gd->fdt_blob;
+   int node = dev->of_offset;
+   int ret;
+
+   ret = ti_musb_ofdata_to_platdata(dev);
+   if (ret) {
+   error("platdata dt parse error\n");
+   return ret;
+   }
+
+   platdata->plat.mode = MUSB_PERIPHERAL;
+
+   return 0;
+}
+
+U_BOOT_DRIVER(ti_musb_peripheral) = {
+   .name   = "ti-musb-peripheral",
+   .id = UCLASS_USB_DEV_GENERIC,
+   .ofdata_to_platdata = ti_musb_peripheral_ofdata_to_platdata,
+   .probe = ti_musb_peripheral_usb_probe,
+   .remove = ti_musb_peripheral_remove,
+   .platdata_auto_alloc_size = sizeof(struct ti_musb_platdata),
+   .priv_auto_alloc_size = sizeof(struct musb),
+};
+
 static int ti_musb_host_probe(struct udevice *dev)
 {
struct musb_host_data *host = dev_get_priv(dev);
@@ -222,7 +323,15 @@ static int ti_musb_wrapper_bind(struct udevice *parent)
dr_mode = usb_get_dr_mode(node);
switch (dr_mode) {
case USB_DR_MODE_PERIPHERAL:
+   case USB_DR_MODE_OTG:
/* Bind MUSB device */
+   ret = device_bind_driver_to_node(parent,
+"ti-musb-peripheral",
+name, node, );
+   if (ret) {
+   error("musb - not able to bind usb device 
node\n");
+   return ret;
+   }
break;
  

[U-Boot] [PATCH v3 06/10] drivers: usb: musb: add ti musb host driver with driver model support

2016-11-17 Thread Mugunthan V N
Add a TI MUSB host driver with driver model support and the
driver will be bound by the MUSB wrapper driver based on the
dr_mode device tree entry.

Signed-off-by: Mugunthan V N <mugunthan...@ti.com>
Reviewed-by: Tom Rini <tr...@konsulko.com>
---
 drivers/usb/musb-new/ti-musb.c | 191 +
 1 file changed, 191 insertions(+)

diff --git a/drivers/usb/musb-new/ti-musb.c b/drivers/usb/musb-new/ti-musb.c
index cf0e296bd0..1c15aa2a42 100644
--- a/drivers/usb/musb-new/ti-musb.c
+++ b/drivers/usb/musb-new/ti-musb.c
@@ -14,10 +14,195 @@
 #include 
 #include 
 
+#include 
+#include 
+#include "musb_uboot.h"
+
 DECLARE_GLOBAL_DATA_PTR;
 
 #ifdef CONFIG_DM_USB
 
+/* USB 2.0 PHY Control */
+#define CM_PHY_PWRDN   (1 << 0)
+#define CM_PHY_OTG_PWRDN   (1 << 1)
+#define OTGVDET_EN (1 << 19)
+#define OTGSESSENDEN   (1 << 20)
+
+#define AM335X_USB1_CTRL   0x8
+
+struct ti_musb_platdata {
+   void *base;
+   void *ctrl_mod_base;
+   struct musb_hdrc_platform_data plat;
+   struct musb_hdrc_config musb_config;
+   struct omap_musb_board_data otg_board_data;
+};
+
+static int ti_musb_get_usb_index(int node)
+{
+   const void *fdt = gd->fdt_blob;
+   int i = 0;
+   char path[64];
+   const char *alias_path;
+   char alias[16];
+
+   fdt_get_path(fdt, node, path, sizeof(path));
+
+   do {
+   snprintf(alias, sizeof(alias), "usb%d", i);
+   alias_path = fdt_get_alias(fdt, alias);
+   if (alias_path == NULL) {
+   debug("USB index not found\n");
+   return -ENOENT;
+   }
+
+   if (!strcmp(path, alias_path))
+   return i;
+
+   i++;
+   } while (alias_path);
+
+   return -ENOENT;
+}
+
+static void ti_musb_set_phy_power(struct udevice *dev, u8 on)
+{
+   struct ti_musb_platdata *platdata = dev_get_platdata(dev);
+
+   if (on) {
+   clrsetbits_le32(platdata->ctrl_mod_base,
+   CM_PHY_PWRDN | CM_PHY_OTG_PWRDN,
+   OTGVDET_EN | OTGSESSENDEN);
+   } else {
+   clrsetbits_le32(platdata->ctrl_mod_base, 0,
+   CM_PHY_PWRDN | CM_PHY_OTG_PWRDN);
+   }
+}
+
+static int ti_musb_ofdata_to_platdata(struct udevice *dev)
+{
+   struct ti_musb_platdata *platdata = dev_get_platdata(dev);
+   const void *fdt = gd->fdt_blob;
+   int node = dev->of_offset;
+   int phys;
+   int ctrl_mod;
+   int usb_index;
+
+   platdata->base = (void *)dev_get_addr_index(dev, 1);
+
+   phys = fdtdec_lookup_phandle(fdt, node, "phys");
+   ctrl_mod = fdtdec_lookup_phandle(fdt, phys, "ti,ctrl_mod");
+   platdata->ctrl_mod_base = (void *)fdtdec_get_addr(fdt, ctrl_mod, "reg");
+   usb_index = ti_musb_get_usb_index(node);
+   switch (usb_index) {
+   case 1:
+   platdata->ctrl_mod_base += AM335X_USB1_CTRL;
+   case 0:
+   default:
+   break;
+   }
+
+   platdata->musb_config.multipoint = fdtdec_get_int(fdt, node,
+ "mentor,multipoint",
+ -1);
+   if (platdata->musb_config.multipoint < 0) {
+   error("MUSB multipoint DT entry missing\n");
+   return -ENOENT;
+   }
+
+   platdata->musb_config.dyn_fifo = 1;
+
+   platdata->musb_config.num_eps = fdtdec_get_int(fdt, node,
+  "mentor,num-eps", -1);
+   if (platdata->musb_config.num_eps < 0) {
+   error("MUSB num-eps DT entry missing\n");
+   return -ENOENT;
+   }
+
+   platdata->musb_config.ram_bits = fdtdec_get_int(fdt, node,
+   "mentor,ram-bits", -1);
+   if (platdata->musb_config.ram_bits < 0) {
+   error("MUSB ram-bits DT entry missing\n");
+   return -ENOENT;
+   }
+
+   platdata->otg_board_data.set_phy_power = ti_musb_set_phy_power;
+   platdata->otg_board_data.dev = dev;
+   platdata->plat.config = >musb_config;
+
+   platdata->plat.power = fdtdec_get_int(fdt, node, "mentor,power", -1);
+   if (platdata->plat.power < 0) {
+   error("MUSB mentor,power DT entry missing\n");
+   return -ENOENT;
+   }
+
+   platdata->plat.platform_ops = _dsps_ops;
+   platdata->plat.board_data = >otg_board_data;
+
+   return 0;
+}
+
+static int ti_musb_host_probe(struct udevice *dev)
+{
+   st

[U-Boot] [PATCH v3 05/10] drivers: usb: musb: adopt musb backend driver to driver model

2016-11-17 Thread Mugunthan V N
Currently all backend driver ops uses hard coded physical
address, so to adopt the driver to DM, add device pointer to ops
call backs so that drivers can get physical addresses from the
usb driver priv/plat data.

Signed-off-by: Mugunthan V N <mugunthan...@ti.com>
Reviewed-by: Tom Rini <tr...@konsulko.com>
---
 arch/arm/cpu/armv7/am33xx/board.c  |  4 ++--
 arch/arm/cpu/armv7/omap3/am35x_musb.c  |  6 +++---
 arch/arm/include/asm/arch-omap3/musb.h |  6 +++---
 arch/arm/include/asm/omap_musb.h   |  7 ---
 drivers/usb/musb-new/am35x.c   | 14 +++---
 drivers/usb/musb-new/musb_dsps.c   |  8 
 6 files changed, 23 insertions(+), 22 deletions(-)

diff --git a/arch/arm/cpu/armv7/am33xx/board.c 
b/arch/arm/cpu/armv7/am33xx/board.c
index c3f50e9733..245a9575ec 100644
--- a/arch/arm/cpu/armv7/am33xx/board.c
+++ b/arch/arm/cpu/armv7/am33xx/board.c
@@ -148,7 +148,7 @@ static struct musb_hdrc_config musb_config = {
 };
 
 #ifdef CONFIG_AM335X_USB0
-static void am33xx_otg0_set_phy_power(u8 on)
+static void am33xx_otg0_set_phy_power(struct udevice *dev, u8 on)
 {
am33xx_usb_set_phy_power(on, >usb_ctrl0);
 }
@@ -167,7 +167,7 @@ static struct musb_hdrc_platform_data otg0_plat = {
 #endif
 
 #ifdef CONFIG_AM335X_USB1
-static void am33xx_otg1_set_phy_power(u8 on)
+static void am33xx_otg1_set_phy_power(struct udevice *dev, u8 on)
 {
am33xx_usb_set_phy_power(on, >usb_ctrl1);
 }
diff --git a/arch/arm/cpu/armv7/omap3/am35x_musb.c 
b/arch/arm/cpu/armv7/omap3/am35x_musb.c
index 74dd105eb6..d542699ab0 100644
--- a/arch/arm/cpu/armv7/omap3/am35x_musb.c
+++ b/arch/arm/cpu/armv7/omap3/am35x_musb.c
@@ -13,7 +13,7 @@
 #include 
 #include 
 
-void am35x_musb_reset(void)
+void am35x_musb_reset(struct udevice *dev)
 {
/* Reset the musb interface */
clrsetbits_le32(_scm_general_regs->ip_sw_reset,
@@ -22,7 +22,7 @@ void am35x_musb_reset(void)
USBOTGSS_SW_RST, 0);
 }
 
-void am35x_musb_phy_power(u8 on)
+void am35x_musb_phy_power(struct udevice *dev, u8 on)
 {
unsigned long start = get_timer(0);
 
@@ -53,7 +53,7 @@ void am35x_musb_phy_power(u8 on)
}
 }
 
-void am35x_musb_clear_irq(void)
+void am35x_musb_clear_irq(struct udevice *dev)
 {
clrsetbits_le32(_scm_general_regs->lvl_intr_clr,
0, USBOTGSS_INT_CLR);
diff --git a/arch/arm/include/asm/arch-omap3/musb.h 
b/arch/arm/include/asm/arch-omap3/musb.h
index cee4ed311e..d06a758f1b 100644
--- a/arch/arm/include/asm/arch-omap3/musb.h
+++ b/arch/arm/include/asm/arch-omap3/musb.h
@@ -7,7 +7,7 @@
 
 #ifndef __ASM_ARCH_OMAP3_MUSB_H
 #define __ASM_ARCH_OMAP3_MUSB_H
-extern void am35x_musb_reset(void);
-extern void am35x_musb_phy_power(u8 on);
-extern void am35x_musb_clear_irq(void);
+void am35x_musb_reset(struct udevice *dev);
+void am35x_musb_phy_power(struct udevice *dev, u8 on);
+void am35x_musb_clear_irq(struct udevice *dev);
 #endif
diff --git a/arch/arm/include/asm/omap_musb.h b/arch/arm/include/asm/omap_musb.h
index 8b9cb0eb8f..7c5fb40774 100644
--- a/arch/arm/include/asm/omap_musb.h
+++ b/arch/arm/include/asm/omap_musb.h
@@ -15,9 +15,10 @@ extern const struct musb_platform_ops omap2430_ops;
 
 struct omap_musb_board_data {
u8 interface_type;
-   void (*set_phy_power)(u8 on);
-   void (*clear_irq)(void);
-   void (*reset)(void);
+   struct udevice *dev;
+   void (*set_phy_power)(struct udevice *dev, u8 on);
+   void (*clear_irq)(struct udevice *dev);
+   void (*reset)(struct udevice *dev);
 };
 
 enum musb_interface{MUSB_INTERFACE_ULPI, MUSB_INTERFACE_UTMI};
diff --git a/drivers/usb/musb-new/am35x.c b/drivers/usb/musb-new/am35x.c
index b8791ddd5c..0167ea7797 100644
--- a/drivers/usb/musb-new/am35x.c
+++ b/drivers/usb/musb-new/am35x.c
@@ -336,7 +336,7 @@ eoi:
if (ret == IRQ_HANDLED || epintr || usbintr) {
/* clear level interrupt */
if (data->clear_irq)
-   data->clear_irq();
+   data->clear_irq(data->dev);
/* write EOI */
musb_writel(reg_base, USB_END_OF_INTR_REG, 0);
}
@@ -401,14 +401,14 @@ static int am35x_musb_init(struct musb *musb)
 
/* Reset the musb */
if (data->reset)
-   data->reset();
+   data->reset(data->dev);
 
/* Reset the controller */
musb_writel(reg_base, USB_CTRL_REG, AM35X_SOFT_RESET_MASK);
 
/* Start the on-chip PHY and its PLL. */
if (data->set_phy_power)
-   data->set_phy_power(1);
+   data->set_phy_power(data->dev, 1);
 
msleep(5);
 
@@ -416,7 +416,7 @@ static int am35x_musb_init(struct musb *musb)
 
/* clear level interrupt */
if (data->clear_irq)
-   data->clear_irq();
+   data->clear_irq(data->dev);
 
return 0;
 }
@@ -439,7 +439,7 @@ static int am35x_mu

[U-Boot] [PATCH v3 04/10] am33xx: board: probe misc drivers to register musb devices

2016-11-17 Thread Mugunthan V N
MUSB wrapper driver is bound as MISC device and underlying usb
devices are bind to usb drivers based on dr_mode, so probing the
MISC wrapper driver to register musb devices.

Signed-off-by: Mugunthan V N <mugunthan...@ti.com>
Reviewed-by: Tom Rini <tr...@konsulko.com>
---
 arch/arm/cpu/armv7/am33xx/board.c | 7 +++
 1 file changed, 7 insertions(+)

diff --git a/arch/arm/cpu/armv7/am33xx/board.c 
b/arch/arm/cpu/armv7/am33xx/board.c
index fd4235e526..c3f50e9733 100644
--- a/arch/arm/cpu/armv7/am33xx/board.c
+++ b/arch/arm/cpu/armv7/am33xx/board.c
@@ -197,6 +197,13 @@ int arch_misc_init(void)
musb_register(_plat, _board_data,
(void *)USB1_OTG_BASE);
 #endif
+#else
+   struct udevice *dev;
+   int ret;
+
+   ret = uclass_first_device(UCLASS_MISC, );
+   if (ret || !dev)
+   return ret;
 #endif
return 0;
 }
-- 
2.11.0.rc1

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


[U-Boot] [PATCH v3 02/10] am33xx: board: do not register usb devices when CONFIG_DM_USB is defined

2016-11-17 Thread Mugunthan V N
Do not register usb devices when CONFIG_DM_USB is define.

Signed-off-by: Mugunthan V N <mugunthan...@ti.com>
Reviewed-by: Tom Rini <tr...@konsulko.com>
---
 arch/arm/cpu/armv7/am33xx/board.c | 5 -
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/arch/arm/cpu/armv7/am33xx/board.c 
b/arch/arm/cpu/armv7/am33xx/board.c
index 68badedd14..fd4235e526 100644
--- a/arch/arm/cpu/armv7/am33xx/board.c
+++ b/arch/arm/cpu/armv7/am33xx/board.c
@@ -120,7 +120,8 @@ int cpu_mmc_init(bd_t *bis)
 
 /* AM33XX has two MUSB controllers which can be host or gadget */
 #if (defined(CONFIG_USB_MUSB_GADGET) || defined(CONFIG_USB_MUSB_HOST)) && \
-   (defined(CONFIG_AM335X_USB0) || defined(CONFIG_AM335X_USB1))
+   (defined(CONFIG_AM335X_USB0) || defined(CONFIG_AM335X_USB1)) && \
+   (!defined(CONFIG_DM_USB))
 static struct ctrl_dev *cdev = (struct ctrl_dev *)CTRL_DEVICE_BASE;
 
 /* USB 2.0 PHY Control */
@@ -187,6 +188,7 @@ static struct musb_hdrc_platform_data otg1_plat = {
 
 int arch_misc_init(void)
 {
+#ifndef CONFIG_DM_USB
 #ifdef CONFIG_AM335X_USB0
musb_register(_plat, _board_data,
(void *)USB0_OTG_BASE);
@@ -195,6 +197,7 @@ int arch_misc_init(void)
musb_register(_plat, _board_data,
(void *)USB1_OTG_BASE);
 #endif
+#endif
return 0;
 }
 
-- 
2.11.0.rc1

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


[U-Boot] [PATCH v3 01/10] configs: am335x: usb: do not define CONFIG_DM_USB for spl

2016-11-17 Thread Mugunthan V N
Since OMAP's spl doesn't support DM currently, do not define
CONFIG_DM_USB for spl build.

Signed-off-by: Mugunthan V N <mugunthan...@ti.com>
Reviewed-by: Tom Rini <tr...@konsulko.com>
---
 include/configs/am335x_evm.h | 1 +
 1 file changed, 1 insertion(+)

diff --git a/include/configs/am335x_evm.h b/include/configs/am335x_evm.h
index ec70b72970..8e62248c73 100644
--- a/include/configs/am335x_evm.h
+++ b/include/configs/am335x_evm.h
@@ -316,6 +316,7 @@
 #ifdef CONFIG_SPL_BUILD
 #undef CONFIG_DM_MMC
 #undef CONFIG_TIMER
+#undef CONFIG_DM_USB
 #endif
 
 #if defined(CONFIG_SPL_BUILD) && defined(CONFIG_SPL_USBETH_SUPPORT)
-- 
2.11.0.rc1

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


[U-Boot] [PATCH v3 00/10] driver model bring-up of musb on AM335x GP and BBB

2016-11-17 Thread Mugunthan V N
This patch series enables musb driver to adopt driver model. This
has been tested on the following evms (logs [1]) by loading
kernel and dtbs from usb mass storage (host) and usb rndis mode (device).
* AM335x GP evm
* AM335x BBB

Also pushed a branch for testing [2]

This patch series depends on the following patch series
* usb ether gadget DM conversion [4]

Changes from v2:
* Removed from non-useful error logs.
* Since defconfig is merged into single defconfig for all
  TI AM335x platforms, rebased those patches as well.

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.
* passed an dummy dev pointer for non-DM case as well for
  reducing the number of #ifdefs in musb backend driver.

[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
[4] - http://lists.denx.de/pipermail/u-boot/2016-November/273037.html

Note:
~
The following checkpatch warning can be ignore as splitting the
line will break grep during debug session.
WARNING: line over 80 characters
#224: FILE: drivers/usb/musb-new/ti-musb.c:232:
+   error("musb - not able to bind usb host 
node\n");

total: 0 errors, 1 warnings, 0 checks, 207 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

../dm-musb/patches/musb/v3.00/0006-drivers-usb-musb-add-ti-musb-host-driver-with-driver.patch
 has style problems, please review.

If any of these errors are false positives, please report
them to the maintainer, see CHECKPATCH in MAINTAINERS.
WARNING: line over 80 characters
#164: FILE: drivers/usb/musb-new/ti-musb.c:332:
+   error("musb - not able to bind usb device 
node\n");

total: 0 errors, 1 warnings, 0 checks, 139 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

../dm-musb/patches/musb/v3.00/0007-drivers-usb-musb-add-ti-musb-peripheral-driver-with-.patch
 has style problems, please review.

If any of these errors are false positives, please report
them to the maintainer, see CHECKPATCH in MAINTAINERS.
total: 0 errors, 0 warnings, 0 checks, 14 lines checked

Mugunthan V N (10):
  configs: am335x: usb: do not define CONFIG_DM_USB for spl
  am33xx: board: do not register usb devices when CONFIG_DM_USB is
defined
  drivers: usb: musb: add ti musb misc driver for wrapper
  am33xx: board: probe misc drivers to register musb devices
  drivers: usb: musb: adopt musb backend driver to driver model
  drivers: usb: musb: add ti musb host driver with driver model support
  drivers: usb: musb: add ti musb peripheral driver with driver model
support
  am33xx: board: init usb ether gadget for rndis support
  am335x_evm: enable usb ether gadget as it supports DM_ETH
  defconfig: am335x_evm: enable usb driver model

 arch/arm/cpu/armv7/am33xx/board.c  |  24 ++-
 arch/arm/cpu/armv7/omap3/am35x_musb.c  |   6 +-
 arch/arm/include/asm/arch-omap3/musb.h |   6 +-
 arch/arm/include/asm/omap_musb.h   |   7 +-
 configs/am335x_evm_defconfig   |   3 +
 drivers/usb/musb-new/Kconfig   |   9 +
 drivers/usb/musb-new/Makefile  |   1 +
 drivers/usb/musb-new/am35x.c   |  14 +-
 drivers/usb/musb-new/musb_dsps.c   |   8 +-
 drivers/usb/musb-new/musb_uboot.c  |   2 +
 drivers/usb/musb-new/ti-musb.c | 364 +
 include/configs/am335x_evm.h   |   4 +-
 12 files changed, 422 insertions(+), 26 deletions(-)
 create mode 100644 drivers/usb/musb-new/ti-musb.c

-- 
2.11.0.rc1

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


[U-Boot] [PATCH v3 03/10] drivers: usb: musb: add ti musb misc driver for wrapper

2016-11-17 Thread Mugunthan V N
Add a misc driver for MUSB wrapper, so that based on dr_mode the
USB devices can bind to USB host or USB device drivers.

Signed-off-by: Mugunthan V N <mugunthan...@ti.com>
Reviewed-by: Tom Rini <tr...@konsulko.com>
---
 drivers/usb/musb-new/Kconfig   |  9 ++
 drivers/usb/musb-new/Makefile  |  1 +
 drivers/usb/musb-new/ti-musb.c | 64 ++
 3 files changed, 74 insertions(+)
 create mode 100644 drivers/usb/musb-new/ti-musb.c

diff --git a/drivers/usb/musb-new/Kconfig b/drivers/usb/musb-new/Kconfig
index c264859b6c..caba42c26f 100644
--- a/drivers/usb/musb-new/Kconfig
+++ b/drivers/usb/musb-new/Kconfig
@@ -14,6 +14,15 @@ config USB_MUSB_GADGET
help
  Enables the MUSB USB dual-role controller in gadget mode.
 
+config USB_MUSB_TI
+   bool "Enable TI OTG USB controller"
+   depends on DM_USB
+   default n
+   help
+ Say y here to enable support for the dual role high
+ speed USB controller based on the Mentor Graphics
+ silicon IP.
+
 if USB_MUSB_HOST || USB_MUSB_GADGET
 
 config USB_MUSB_PIC32
diff --git a/drivers/usb/musb-new/Makefile b/drivers/usb/musb-new/Makefile
index df1c3c8a45..296f230fbf 100644
--- a/drivers/usb/musb-new/Makefile
+++ b/drivers/usb/musb-new/Makefile
@@ -12,6 +12,7 @@ obj-$(CONFIG_USB_MUSB_AM35X) += am35x.o
 obj-$(CONFIG_USB_MUSB_OMAP2PLUS) += omap2430.o
 obj-$(CONFIG_USB_MUSB_PIC32) += pic32.o
 obj-$(CONFIG_USB_MUSB_SUNXI) += sunxi.o
+obj-$(CONFIG_USB_MUSB_TI) += ti-musb.o
 
 ccflags-y := $(call cc-option,-Wno-unused-variable) \
$(call cc-option,-Wno-unused-but-set-variable) \
diff --git a/drivers/usb/musb-new/ti-musb.c b/drivers/usb/musb-new/ti-musb.c
new file mode 100644
index 00..cf0e296bd0
--- /dev/null
+++ b/drivers/usb/musb-new/ti-musb.c
@@ -0,0 +1,64 @@
+/*
+ * MISC driver for TI MUSB Glue.
+ *
+ * (C) Copyright 2016
+ * Texas Instruments Incorporated, 
+ *
+ * SPDX-License-Identifier: GPL-2.0+
+ */
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+DECLARE_GLOBAL_DATA_PTR;
+
+#ifdef CONFIG_DM_USB
+
+static int ti_musb_wrapper_bind(struct udevice *parent)
+{
+   const void *fdt = gd->fdt_blob;
+   int node;
+   int ret;
+
+   for (node = fdt_first_subnode(fdt, parent->of_offset); node > 0;
+node = fdt_next_subnode(fdt, node)) {
+   struct udevice *dev;
+   const char *name = fdt_get_name(fdt, node, NULL);
+   enum usb_dr_mode dr_mode;
+   struct driver *drv;
+
+   if (strncmp(name, "usb@", 4))
+   continue;
+
+   dr_mode = usb_get_dr_mode(node);
+   switch (dr_mode) {
+   case USB_DR_MODE_PERIPHERAL:
+   /* Bind MUSB device */
+   break;
+   case USB_DR_MODE_HOST:
+   /* Bind MUSB host */
+   break;
+   default:
+   break;
+   };
+   }
+   return 0;
+}
+
+static const struct udevice_id ti_musb_ids[] = {
+   { .compatible = "ti,am33xx-usb" },
+   { }
+};
+
+U_BOOT_DRIVER(ti_musb_wrapper) = {
+   .name   = "ti-musb-wrapper",
+   .id = UCLASS_MISC,
+   .of_match = ti_musb_ids,
+   .bind = ti_musb_wrapper_bind,
+};
+
+#endif /* CONFIG_DM_USB */
-- 
2.11.0.rc1

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


[U-Boot] [PATCH v3 5/6] drivers: usb: gadget: ether: prepare driver for driver model migration

2016-11-17 Thread Mugunthan V N
prepare driver for driver model migration

Signed-off-by: Mugunthan V N <mugunthan...@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 = >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 = >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 = >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 = >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 = >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 = _priv->netdev;
-- 
2.11.0.rc1

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


[U-Boot] [PATCH v3 1/6] drivers: usb: gadget: ether: adopt to usb driver model

2016-11-17 Thread Mugunthan V N
Convert usb ether gadget to adopt usb driver model

Signed-off-by: Mugunthan V N <mugunthan...@ti.com>
Reviewed-by: Simon Glass <s...@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 
+#include 
+#include 
+
 #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, );
+   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 = _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

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


[U-Boot] [PATCH] drivers: net: keystone_net: add rgmii link type support when parsing dt

2016-11-14 Thread Mugunthan V N
Add support to detect RGMII link interface from link-interface
device tree entry. Also rename the existing link type enums so
that it provides meaning full interface like SGMII.

Signed-off-by: Mugunthan V N <mugunthan...@ti.com>
---

Without this support there is a crash in K2G EVM tftp boot [1].
Verified this with tftp download on K2G EVM [2]

[1] - http://pastebin.ubuntu.com/23474751/
[2] - http://pastebin.ubuntu.com/23474748/

---
 drivers/net/keystone_net.c | 23 +++
 1 file changed, 15 insertions(+), 8 deletions(-)

diff --git a/drivers/net/keystone_net.c b/drivers/net/keystone_net.c
index f88d83e727..a5120e01ad 100644
--- a/drivers/net/keystone_net.c
+++ b/drivers/net/keystone_net.c
@@ -56,13 +56,16 @@ struct rx_buff_desc net_rx_buffs = {
 #ifdef CONFIG_DM_ETH
 
 enum link_type {
-   LINK_TYPE_MAC_TO_MAC_AUTO = 0,
-   LINK_TYPE_MAC_TO_PHY_MODE = 1,
-   LINK_TYPE_MAC_TO_MAC_FORCED_MODE = 2,
-   LINK_TYPE_MAC_TO_FIBRE_MODE = 3,
-   LINK_TYPE_MAC_TO_PHY_NO_MDIO_MODE = 4,
-   LINK_TYPE_10G_MAC_TO_PHY_MODE = 10,
-   LINK_TYPE_10G_MAC_TO_MAC_FORCED_MODE = 11,
+   LINK_TYPE_SGMII_MAC_TO_MAC_AUTO = 0,
+   LINK_TYPE_SGMII_MAC_TO_PHY_MODE = 1,
+   LINK_TYPE_SGMII_MAC_TO_MAC_FORCED_MODE  = 2,
+   LINK_TYPE_SGMII_MAC_TO_FIBRE_MODE   = 3,
+   LINK_TYPE_SGMII_MAC_TO_PHY_NO_MDIO_MODE = 4,
+   LINK_TYPE_RGMII_LINK_MAC_PHY= 5,
+   LINK_TYPE_RGMII_LINK_MAC_MAC_FORCED = 6,
+   LINK_TYPE_RGMII_LINK_MAC_PHY_NO_MDIO= 7,
+   LINK_TYPE_10G_MAC_TO_PHY_MODE   = 10,
+   LINK_TYPE_10G_MAC_TO_MAC_FORCED_MODE= 11,
 };
 
 #define mac_hi(mac) (((mac)[0] << 0) | ((mac)[1] << 8) |\
@@ -1077,11 +1080,15 @@ static int ks2_eth_parse_slave_interface(int netcp, int 
slave,
priv->mdio_base = (void *)fdtdec_get_addr(fdt, mdio, "reg");
}
 
-   if (priv->link_type == LINK_TYPE_MAC_TO_PHY_MODE) {
+   if (priv->link_type == LINK_TYPE_SGMII_MAC_TO_PHY_MODE) {
priv->phy_if = PHY_INTERFACE_MODE_SGMII;
pdata->phy_interface = priv->phy_if;
priv->sgmii_link_type = SGMII_LINK_MAC_PHY;
priv->has_mdio = true;
+   } else if (priv->link_type == LINK_TYPE_RGMII_LINK_MAC_PHY) {
+   priv->phy_if = PHY_INTERFACE_MODE_RGMII;
+   pdata->phy_interface = priv->phy_if;
+   priv->has_mdio = true;
}
 
return 0;
-- 
2.11.0.rc0.7.gbe5a750

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


[U-Boot] [PATCH v2 2/3] include: configs: am335x: add Atheros phy support

2016-10-13 Thread Mugunthan V N
In AM335x GP EVM, Atheros 8031 phy is used, enable the driver as
AM335x SoC RGMII delay mode has to be enabled in phy as mentioned
in the silicon errata Advisory 1.0.10

Signed-off-by: Mugunthan V N <mugunthan...@ti.com>
Acked-by: Joe Hershberger <joe.hershber...@ni.com>
---
 include/configs/am335x_evm.h | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/include/configs/am335x_evm.h b/include/configs/am335x_evm.h
index 272c71b..daa7dd8 100644
--- a/include/configs/am335x_evm.h
+++ b/include/configs/am335x_evm.h
@@ -432,6 +432,8 @@
 #define CONFIG_PHY_GIGE
 #define CONFIG_PHYLIB
 #define CONFIG_PHY_SMSC
+/* Enable Atheros phy driver */
+#define CONFIG_PHY_ATHEROS
 
 /*
  * NOR Size = 16 MiB
-- 
2.10.1.445.g3cdd5d1

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


[U-Boot] [PATCH v2 0/3] Add Atheros phy delay support and CPSW RGMII id support

2016-10-13 Thread Mugunthan V N
This patch series adds support for RGMII phy internal delay
support for Atheros 8031 phy driver and also add support for
the phy mode configuration in control module in cpsw driver.

Tested the series on the following EVMs with a zImage download
from server, logs [1] and pushed a branch for testing [2].

* DRA 72 Rev B EVM
* DRA 72 Rev C EVM
* DRA 74 EVM
* AM437x GP EVM
* AM335x BBB
* AM335x GP EVM

Changes from initial version:
* Added RMII refl clock "rmii-clock-ext" DT parsing.

[1] - http://pastebin.ubuntu.com/23317809/
[2] - git://git.ti.com/~mugunthanvnm/ti-u-boot/mugunth-ti-u-boot.git 
cpsw-rgmii-v2

Mugunthan V N (3):
  drivers: net: phy: atheros: add separate config for AR8031
  include: configs: am335x: add Atheros phy support
  driver: net: cpsw: add support for RGMII id mode support and RMII
clock source selection

 drivers/net/cpsw.c   | 157 +++
 drivers/net/phy/atheros.c|  37 +-
 include/configs/am335x_evm.h |   2 +
 include/cpsw.h   |   1 +
 4 files changed, 182 insertions(+), 15 deletions(-)

-- 
2.10.1.445.g3cdd5d1

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


[U-Boot] [PATCH v2 3/3] driver: net: cpsw: add support for RGMII id mode support and RMII clock source selection

2016-10-13 Thread Mugunthan V N
cpsw driver supports only selection of phy mode in control module
but control module has more setting like RGMII ID mode selection,
RMII clock source selection. So ported to cpsw-phy-sel driver
from kernel to u-boot.

Signed-off-by: Mugunthan V N <mugunthan...@ti.com>
Signed-off-by: Lokesh Vutla <lokeshvu...@ti.com>
Acked-by: Joe Hershberger <joe.hershber...@ni.com>
---
 drivers/net/cpsw.c | 157 -
 include/cpsw.h |   1 +
 2 files changed, 144 insertions(+), 14 deletions(-)

diff --git a/drivers/net/cpsw.c b/drivers/net/cpsw.c
index d17505e..d1f024e 100644
--- a/drivers/net/cpsw.c
+++ b/drivers/net/cpsw.c
@@ -225,6 +225,18 @@ struct cpdma_chan {
void*hdp, *cp, *rxfree;
 };
 
+/* AM33xx SoC specific definitions for the CONTROL port */
+#define AM33XX_GMII_SEL_MODE_MII   0
+#define AM33XX_GMII_SEL_MODE_RMII  1
+#define AM33XX_GMII_SEL_MODE_RGMII 2
+
+#define AM33XX_GMII_SEL_RGMII1_IDMODE  BIT(4)
+#define AM33XX_GMII_SEL_RGMII2_IDMODE  BIT(5)
+#define AM33XX_GMII_SEL_RMII1_IO_CLK_ENBIT(6)
+#define AM33XX_GMII_SEL_RMII2_IO_CLK_ENBIT(7)
+
+#define GMII_SEL_MODE_MASK 0x3
+
 #define desc_write(desc, fld, val) __raw_writel((u32)(val), &(desc)->fld)
 #define desc_read(desc, fld)   __raw_readl(&(desc)->fld)
 #define desc_read_ptr(desc, fld)   ((void *)__raw_readl(&(desc)->fld))
@@ -1150,12 +1162,129 @@ static inline fdt_addr_t cpsw_get_addr_by_node(const 
void *fdt, int node)
  false);
 }
 
+static void cpsw_gmii_sel_am3352(struct cpsw_priv *priv,
+phy_interface_t phy_mode)
+{
+   u32 reg;
+   u32 mask;
+   u32 mode = 0;
+   bool rgmii_id = false;
+   int slave = priv->data.active_slave;
+
+   reg = readl(priv->data.gmii_sel);
+
+   switch (phy_mode) {
+   case PHY_INTERFACE_MODE_RMII:
+   mode = AM33XX_GMII_SEL_MODE_RMII;
+   break;
+
+   case PHY_INTERFACE_MODE_RGMII:
+   mode = AM33XX_GMII_SEL_MODE_RGMII;
+   break;
+   case PHY_INTERFACE_MODE_RGMII_ID:
+   case PHY_INTERFACE_MODE_RGMII_RXID:
+   case PHY_INTERFACE_MODE_RGMII_TXID:
+   mode = AM33XX_GMII_SEL_MODE_RGMII;
+   rgmii_id = true;
+   break;
+
+   case PHY_INTERFACE_MODE_MII:
+   default:
+   mode = AM33XX_GMII_SEL_MODE_MII;
+   break;
+   };
+
+   mask = GMII_SEL_MODE_MASK << (slave * 2) | BIT(slave + 6);
+   mode <<= slave * 2;
+
+   if (priv->data.rmii_clock_external) {
+   if (slave == 0)
+   mode |= AM33XX_GMII_SEL_RMII1_IO_CLK_EN;
+   else
+   mode |= AM33XX_GMII_SEL_RMII2_IO_CLK_EN;
+   }
+
+   if (rgmii_id) {
+   if (slave == 0)
+   mode |= AM33XX_GMII_SEL_RGMII1_IDMODE;
+   else
+   mode |= AM33XX_GMII_SEL_RGMII2_IDMODE;
+   }
+
+   reg &= ~mask;
+   reg |= mode;
+
+   writel(reg, priv->data.gmii_sel);
+}
+
+static void cpsw_gmii_sel_dra7xx(struct cpsw_priv *priv,
+phy_interface_t phy_mode)
+{
+   u32 reg;
+   u32 mask;
+   u32 mode = 0;
+   int slave = priv->data.active_slave;
+
+   reg = readl(priv->data.gmii_sel);
+
+   switch (phy_mode) {
+   case PHY_INTERFACE_MODE_RMII:
+   mode = AM33XX_GMII_SEL_MODE_RMII;
+   break;
+
+   case PHY_INTERFACE_MODE_RGMII:
+   case PHY_INTERFACE_MODE_RGMII_ID:
+   case PHY_INTERFACE_MODE_RGMII_RXID:
+   case PHY_INTERFACE_MODE_RGMII_TXID:
+   mode = AM33XX_GMII_SEL_MODE_RGMII;
+   break;
+
+   case PHY_INTERFACE_MODE_MII:
+   default:
+   mode = AM33XX_GMII_SEL_MODE_MII;
+   break;
+   };
+
+   switch (slave) {
+   case 0:
+   mask = GMII_SEL_MODE_MASK;
+   break;
+   case 1:
+   mask = GMII_SEL_MODE_MASK << 4;
+   mode <<= 4;
+   break;
+   default:
+   dev_err(priv->dev, "invalid slave number...\n");
+   return;
+   }
+
+   if (priv->data.rmii_clock_external)
+   dev_err(priv->dev, "RMII External clock is not supported\n");
+
+   reg &= ~mask;
+   reg |= mode;
+
+   writel(reg, priv->data.gmii_sel);
+}
+
+static void cpsw_phy_sel(struct cpsw_priv *priv, const char *compat,
+phy_interface_t phy_mode)
+{
+   if (!strcmp(compat, "ti,am3352-cpsw-phy-sel"))
+   cpsw_gmii_sel_am3352(priv, phy_mode);
+   if (!strcmp(compat, "ti,am43xx-cpsw-phy-sel"))
+   cpsw_gmii_sel_am3352(priv, 

[U-Boot] [PATCH v2 1/3] drivers: net: phy: atheros: add separate config for AR8031

2016-10-13 Thread Mugunthan V N
In the current driver implementation, config() callback is common
for AR8035 and AR8031 phy. In config() callback, driver tries to
configure MMD Access Control Register and MMD Access Address Data
Register unconditionally for both phy versions which leads to
auto negotiation failure in AM335x EVMsk second port which uses
AR8031 Giga bit RGMII phy. Fixing this by adding separate config
for AR8031 phy.

Reviewed-by: Sekhar Nori <nsek...@ti.com>
Signed-off-by: Mugunthan V N <mugunthan...@ti.com>
Acked-by: Joe Hershberger <joe.hershber...@ni.com>
---
 drivers/net/phy/atheros.c | 37 -
 1 file changed, 36 insertions(+), 1 deletion(-)

diff --git a/drivers/net/phy/atheros.c b/drivers/net/phy/atheros.c
index e57c412..faf5175 100644
--- a/drivers/net/phy/atheros.c
+++ b/drivers/net/phy/atheros.c
@@ -8,6 +8,15 @@
  */
 #include 
 
+#define AR803x_PHY_DEBUG_ADDR_REG  0x1d
+#define AR803x_PHY_DEBUG_DATA_REG  0x1e
+
+#define AR803x_DEBUG_REG_5 0x5
+#define AR803x_RGMII_TX_CLK_DLY0x100
+
+#define AR803x_DEBUG_REG_0 0x0
+#define AR803x_RGMII_RX_CLK_DLY0x8000
+
 static int ar8021_config(struct phy_device *phydev)
 {
phy_write(phydev, MDIO_DEVAD_NONE, 0x1d, 0x05);
@@ -17,6 +26,32 @@ static int ar8021_config(struct phy_device *phydev)
return 0;
 }
 
+static int ar8031_config(struct phy_device *phydev)
+{
+   if (phydev->interface == PHY_INTERFACE_MODE_RGMII_TXID ||
+   phydev->interface == PHY_INTERFACE_MODE_RGMII_ID) {
+   phy_write(phydev, MDIO_DEVAD_NONE, AR803x_PHY_DEBUG_ADDR_REG,
+ AR803x_DEBUG_REG_5);
+   phy_write(phydev, MDIO_DEVAD_NONE, AR803x_PHY_DEBUG_DATA_REG,
+ AR803x_RGMII_TX_CLK_DLY);
+   }
+
+   if (phydev->interface == PHY_INTERFACE_MODE_RGMII_RXID ||
+   phydev->interface == PHY_INTERFACE_MODE_RGMII_ID) {
+   phy_write(phydev, MDIO_DEVAD_NONE, AR803x_PHY_DEBUG_ADDR_REG,
+ AR803x_DEBUG_REG_0);
+   phy_write(phydev, MDIO_DEVAD_NONE, AR803x_PHY_DEBUG_DATA_REG,
+ AR803x_RGMII_RX_CLK_DLY);
+   }
+
+   phydev->supported = phydev->drv->features;
+
+   genphy_config_aneg(phydev);
+   genphy_restart_aneg(phydev);
+
+   return 0;
+}
+
 static int ar8035_config(struct phy_device *phydev)
 {
int regval;
@@ -54,7 +89,7 @@ static struct phy_driver AR8031_driver =  {
.uid = 0x4dd074,
.mask = 0xffef,
.features = PHY_GBIT_FEATURES,
-   .config = ar8035_config,
+   .config = ar8031_config,
.startup = genphy_startup,
.shutdown = genphy_shutdown,
 };
-- 
2.10.1.445.g3cdd5d1

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


Re: [U-Boot] [PATCH 3/3] driver: net: cpsw: add support for RGMII id mode support and RMII clock source selection

2016-10-12 Thread Mugunthan V N
On Thursday 13 October 2016 09:39 AM, Lokesh Vutla wrote:
> 
> 
> On Monday 10 October 2016 06:27 PM, Mugunthan V N wrote:
>> cpsw driver supports only selection of phy mode in control module
>> but control module has more setting like RGMII ID mode selection,
>> RMII clock source selection. So ported to cpsw-phy-sel driver
>> from kernel to u-boot.
>>
>> Signed-off-by: Mugunthan V N <mugunthan...@ti.com>
>> ---
>>  drivers/net/cpsw.c | 153 
>> -
>>  include/cpsw.h |   1 +
>>  2 files changed, 140 insertions(+), 14 deletions(-)
>>
>> diff --git a/drivers/net/cpsw.c b/drivers/net/cpsw.c
>> index d17505e..1441f44 100644
>> --- a/drivers/net/cpsw.c
>> +++ b/drivers/net/cpsw.c
>> @@ -225,6 +225,18 @@ struct cpdma_chan {
>>  void*hdp, *cp, *rxfree;
>>  };
>>  
>> +/* AM33xx SoC specific definitions for the CONTROL port */
>> +#define AM33XX_GMII_SEL_MODE_MII0
>> +#define AM33XX_GMII_SEL_MODE_RMII   1
>> +#define AM33XX_GMII_SEL_MODE_RGMII  2
>> +
>> +#define AM33XX_GMII_SEL_RGMII1_IDMODE   BIT(4)
>> +#define AM33XX_GMII_SEL_RGMII2_IDMODE   BIT(5)
>> +#define AM33XX_GMII_SEL_RMII1_IO_CLK_EN BIT(6)
>> +#define AM33XX_GMII_SEL_RMII2_IO_CLK_EN BIT(7)
>> +
>> +#define GMII_SEL_MODE_MASK  0x3
>> +
>>  #define desc_write(desc, fld, val)  __raw_writel((u32)(val), &(desc)->fld)
>>  #define desc_read(desc, fld)__raw_readl(&(desc)->fld)
>>  #define desc_read_ptr(desc, fld)((void *)__raw_readl(&(desc)->fld))
>> @@ -1150,12 +1162,129 @@ static inline fdt_addr_t 
>> cpsw_get_addr_by_node(const void *fdt, int node)
>>false);
>>  }
>>  
>> +static void cpsw_gmii_sel_am3352(struct cpsw_priv *priv,
>> + phy_interface_t phy_mode)
>> +{
>> +u32 reg;
>> +u32 mask;
>> +u32 mode = 0;
>> +bool rgmii_id = false;
>> +int slave = priv->data.active_slave;
>> +
>> +reg = readl(priv->data.gmii_sel);
>> +
>> +switch (phy_mode) {
>> +case PHY_INTERFACE_MODE_RMII:
>> +mode = AM33XX_GMII_SEL_MODE_RMII;
>> +break;
>> +
>> +case PHY_INTERFACE_MODE_RGMII:
>> +mode = AM33XX_GMII_SEL_MODE_RGMII;
>> +break;
>> +case PHY_INTERFACE_MODE_RGMII_ID:
>> +case PHY_INTERFACE_MODE_RGMII_RXID:
>> +case PHY_INTERFACE_MODE_RGMII_TXID:
>> +mode = AM33XX_GMII_SEL_MODE_RGMII;
>> +rgmii_id = true;
>> +break;
>> +
>> +case PHY_INTERFACE_MODE_MII:
>> +default:
>> +mode = AM33XX_GMII_SEL_MODE_MII;
>> +    break;
>> +};
>> +
>> +mask = GMII_SEL_MODE_MASK << (slave * 2) | BIT(slave + 6);
>> +mode <<= slave * 2;
>> +
>> +if (priv->data.rmii_clock_external) {
> 
> I do not see any one updating value for priv->data.rmii_clock_external.
> I guess cpsw_eth_ofdata_to_platdata() should be populating this value
> based on DT.
> 

Oops, missed squashing fixup patches from TI repo. Will be careful next
time. Thanks for pointing out early.

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


[U-Boot] [PATCH 2/3] include: configs: am335x: add Atheros phy support

2016-10-10 Thread Mugunthan V N
In AM335x GP EVM, Atheros 8031 phy is used, enable the driver as
AM335x SoC RGMII delay mode has to be enabled in phy as mentioned
in the silicon errata Advisory 1.0.10

Signed-off-by: Mugunthan V N <mugunthan...@ti.com>
---
 include/configs/am335x_evm.h | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/include/configs/am335x_evm.h b/include/configs/am335x_evm.h
index 272c71b..daa7dd8 100644
--- a/include/configs/am335x_evm.h
+++ b/include/configs/am335x_evm.h
@@ -432,6 +432,8 @@
 #define CONFIG_PHY_GIGE
 #define CONFIG_PHYLIB
 #define CONFIG_PHY_SMSC
+/* Enable Atheros phy driver */
+#define CONFIG_PHY_ATHEROS
 
 /*
  * NOR Size = 16 MiB
-- 
2.10.0.372.g6fe1b14

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


[U-Boot] [PATCH 1/3] drivers: net: phy: atheros: add separate config for AR8031

2016-10-10 Thread Mugunthan V N
In the current driver implementation, config() callback is common
for AR8035 and AR8031 phy. In config() callback, driver tries to
configure MMD Access Control Register and MMD Access Address Data
Register unconditionally for both phy versions which leads to
auto negotiation failure in AM335x EVMsk second port which uses
AR8031 Giga bit RGMII phy. Fixing this by adding separate config
for AR8031 phy.

Reviewed-by: Sekhar Nori <nsek...@ti.com>
Signed-off-by: Mugunthan V N <mugunthan...@ti.com>
---
 drivers/net/phy/atheros.c | 37 -
 1 file changed, 36 insertions(+), 1 deletion(-)

diff --git a/drivers/net/phy/atheros.c b/drivers/net/phy/atheros.c
index e57c412..faf5175 100644
--- a/drivers/net/phy/atheros.c
+++ b/drivers/net/phy/atheros.c
@@ -8,6 +8,15 @@
  */
 #include 
 
+#define AR803x_PHY_DEBUG_ADDR_REG  0x1d
+#define AR803x_PHY_DEBUG_DATA_REG  0x1e
+
+#define AR803x_DEBUG_REG_5 0x5
+#define AR803x_RGMII_TX_CLK_DLY0x100
+
+#define AR803x_DEBUG_REG_0 0x0
+#define AR803x_RGMII_RX_CLK_DLY0x8000
+
 static int ar8021_config(struct phy_device *phydev)
 {
phy_write(phydev, MDIO_DEVAD_NONE, 0x1d, 0x05);
@@ -17,6 +26,32 @@ static int ar8021_config(struct phy_device *phydev)
return 0;
 }
 
+static int ar8031_config(struct phy_device *phydev)
+{
+   if (phydev->interface == PHY_INTERFACE_MODE_RGMII_TXID ||
+   phydev->interface == PHY_INTERFACE_MODE_RGMII_ID) {
+   phy_write(phydev, MDIO_DEVAD_NONE, AR803x_PHY_DEBUG_ADDR_REG,
+ AR803x_DEBUG_REG_5);
+   phy_write(phydev, MDIO_DEVAD_NONE, AR803x_PHY_DEBUG_DATA_REG,
+ AR803x_RGMII_TX_CLK_DLY);
+   }
+
+   if (phydev->interface == PHY_INTERFACE_MODE_RGMII_RXID ||
+   phydev->interface == PHY_INTERFACE_MODE_RGMII_ID) {
+   phy_write(phydev, MDIO_DEVAD_NONE, AR803x_PHY_DEBUG_ADDR_REG,
+ AR803x_DEBUG_REG_0);
+   phy_write(phydev, MDIO_DEVAD_NONE, AR803x_PHY_DEBUG_DATA_REG,
+ AR803x_RGMII_RX_CLK_DLY);
+   }
+
+   phydev->supported = phydev->drv->features;
+
+   genphy_config_aneg(phydev);
+   genphy_restart_aneg(phydev);
+
+   return 0;
+}
+
 static int ar8035_config(struct phy_device *phydev)
 {
int regval;
@@ -54,7 +89,7 @@ static struct phy_driver AR8031_driver =  {
.uid = 0x4dd074,
.mask = 0xffef,
.features = PHY_GBIT_FEATURES,
-   .config = ar8035_config,
+   .config = ar8031_config,
.startup = genphy_startup,
.shutdown = genphy_shutdown,
 };
-- 
2.10.0.372.g6fe1b14

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


[U-Boot] [PATCH 3/3] driver: net: cpsw: add support for RGMII id mode support and RMII clock source selection

2016-10-10 Thread Mugunthan V N
cpsw driver supports only selection of phy mode in control module
but control module has more setting like RGMII ID mode selection,
RMII clock source selection. So ported to cpsw-phy-sel driver
from kernel to u-boot.

Signed-off-by: Mugunthan V N <mugunthan...@ti.com>
---
 drivers/net/cpsw.c | 153 -
 include/cpsw.h |   1 +
 2 files changed, 140 insertions(+), 14 deletions(-)

diff --git a/drivers/net/cpsw.c b/drivers/net/cpsw.c
index d17505e..1441f44 100644
--- a/drivers/net/cpsw.c
+++ b/drivers/net/cpsw.c
@@ -225,6 +225,18 @@ struct cpdma_chan {
void*hdp, *cp, *rxfree;
 };
 
+/* AM33xx SoC specific definitions for the CONTROL port */
+#define AM33XX_GMII_SEL_MODE_MII   0
+#define AM33XX_GMII_SEL_MODE_RMII  1
+#define AM33XX_GMII_SEL_MODE_RGMII 2
+
+#define AM33XX_GMII_SEL_RGMII1_IDMODE  BIT(4)
+#define AM33XX_GMII_SEL_RGMII2_IDMODE  BIT(5)
+#define AM33XX_GMII_SEL_RMII1_IO_CLK_ENBIT(6)
+#define AM33XX_GMII_SEL_RMII2_IO_CLK_ENBIT(7)
+
+#define GMII_SEL_MODE_MASK 0x3
+
 #define desc_write(desc, fld, val) __raw_writel((u32)(val), &(desc)->fld)
 #define desc_read(desc, fld)   __raw_readl(&(desc)->fld)
 #define desc_read_ptr(desc, fld)   ((void *)__raw_readl(&(desc)->fld))
@@ -1150,12 +1162,129 @@ static inline fdt_addr_t cpsw_get_addr_by_node(const 
void *fdt, int node)
  false);
 }
 
+static void cpsw_gmii_sel_am3352(struct cpsw_priv *priv,
+phy_interface_t phy_mode)
+{
+   u32 reg;
+   u32 mask;
+   u32 mode = 0;
+   bool rgmii_id = false;
+   int slave = priv->data.active_slave;
+
+   reg = readl(priv->data.gmii_sel);
+
+   switch (phy_mode) {
+   case PHY_INTERFACE_MODE_RMII:
+   mode = AM33XX_GMII_SEL_MODE_RMII;
+   break;
+
+   case PHY_INTERFACE_MODE_RGMII:
+   mode = AM33XX_GMII_SEL_MODE_RGMII;
+   break;
+   case PHY_INTERFACE_MODE_RGMII_ID:
+   case PHY_INTERFACE_MODE_RGMII_RXID:
+   case PHY_INTERFACE_MODE_RGMII_TXID:
+   mode = AM33XX_GMII_SEL_MODE_RGMII;
+   rgmii_id = true;
+   break;
+
+   case PHY_INTERFACE_MODE_MII:
+   default:
+   mode = AM33XX_GMII_SEL_MODE_MII;
+   break;
+   };
+
+   mask = GMII_SEL_MODE_MASK << (slave * 2) | BIT(slave + 6);
+   mode <<= slave * 2;
+
+   if (priv->data.rmii_clock_external) {
+   if (slave == 0)
+   mode |= AM33XX_GMII_SEL_RMII1_IO_CLK_EN;
+   else
+   mode |= AM33XX_GMII_SEL_RMII2_IO_CLK_EN;
+   }
+
+   if (rgmii_id) {
+   if (slave == 0)
+   mode |= AM33XX_GMII_SEL_RGMII1_IDMODE;
+   else
+   mode |= AM33XX_GMII_SEL_RGMII2_IDMODE;
+   }
+
+   reg &= ~mask;
+   reg |= mode;
+
+   writel(reg, priv->data.gmii_sel);
+}
+
+static void cpsw_gmii_sel_dra7xx(struct cpsw_priv *priv,
+phy_interface_t phy_mode)
+{
+   u32 reg;
+   u32 mask;
+   u32 mode = 0;
+   int slave = priv->data.active_slave;
+
+   reg = readl(priv->data.gmii_sel);
+
+   switch (phy_mode) {
+   case PHY_INTERFACE_MODE_RMII:
+   mode = AM33XX_GMII_SEL_MODE_RMII;
+   break;
+
+   case PHY_INTERFACE_MODE_RGMII:
+   case PHY_INTERFACE_MODE_RGMII_ID:
+   case PHY_INTERFACE_MODE_RGMII_RXID:
+   case PHY_INTERFACE_MODE_RGMII_TXID:
+   mode = AM33XX_GMII_SEL_MODE_RGMII;
+   break;
+
+   case PHY_INTERFACE_MODE_MII:
+   default:
+   mode = AM33XX_GMII_SEL_MODE_MII;
+   break;
+   };
+
+   switch (slave) {
+   case 0:
+   mask = GMII_SEL_MODE_MASK;
+   break;
+   case 1:
+   mask = GMII_SEL_MODE_MASK << 4;
+   mode <<= 4;
+   break;
+   default:
+   dev_err(priv->dev, "invalid slave number...\n");
+   return;
+   }
+
+   if (priv->data.rmii_clock_external)
+   dev_err(priv->dev, "RMII External clock is not supported\n");
+
+   reg &= ~mask;
+   reg |= mode;
+
+   writel(reg, priv->data.gmii_sel);
+}
+
+static void cpsw_phy_sel(struct cpsw_priv *priv, const char *compat,
+phy_interface_t phy_mode)
+{
+   if (!strcmp(compat, "ti,am3352-cpsw-phy-sel"))
+   cpsw_gmii_sel_am3352(priv, phy_mode);
+   if (!strcmp(compat, "ti,am43xx-cpsw-phy-sel"))
+   cpsw_gmii_sel_am3352(priv, phy_mode);
+   else if (!strcmp(compat, "ti,dra7xx-cpsw-phy-sel"))
+   cpsw_gmii_sel_dra7xx(p

[U-Boot] [PATCH 0/3] Add Atheros phy delay support and CPSW RGMII id support

2016-10-10 Thread Mugunthan V N
This patch series adds support for RGMII phy internal delay
support for Atheros 8031 phy driver and also add support for
the phy mode configuration in control module in cpsw driver.

Tested the series on the following EVMs with a zImage download
from server, logs [1] and pushed a branch for testing [2].

* DRA 72 Rev B EVM
* DRA 72 Rev C EVM
* DRA 74 EVM
* AM437x GP EVM
* AM335x BBB
* AM335x GP EVM

[1] - http://pastebin.ubuntu.com/23302895/
[2] - git://git.ti.com/~mugunthanvnm/ti-u-boot/mugunth-ti-u-boot.git cpsw-rgmii

Mugunthan V N (3):
  drivers: net: phy: atheros: add separate config for AR8031
  include: configs: am335x: add Atheros phy support
  driver: net: cpsw: add support for RGMII id mode support and RMII
clock source selection

 drivers/net/cpsw.c   | 153 +++
 drivers/net/phy/atheros.c|  37 ++-
 include/configs/am335x_evm.h |   2 +
 include/cpsw.h   |   1 +
 4 files changed, 178 insertions(+), 15 deletions(-)

-- 
2.10.0.372.g6fe1b14

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


[U-Boot] [PATCH 0/2] Add DRA72 Rev C support

2016-09-27 Thread Mugunthan V N
Add support for dra72 Rev C evm. The patch has been tested on
DRA72 EVM Rev C, DRA72 EVM Rev B and DRA74 EVM Rev G, logs [1].
Also pushed a branch for testing [2].

[1] - http://pastebin.ubuntu.com/23239294/
[2] - git://git.ti.com/~mugunthanvnm/ti-u-boot/mugunth-ti-u-boot.git dra72-revC

Mugunthan V N (2):
  ARM: dts: dra72: add rev C evm support
  board: ti: dra7xx: complex definitions should be protected with
parentheses

 arch/arm/dts/Makefile  |   3 +-
 arch/arm/dts/dra72-evm-common.dtsi | 513 
 arch/arm/dts/dra72-evm-revc.dts|  70 
 arch/arm/dts/dra72-evm.dts | 664 +
 board/ti/dra7xx/evm.c  |  24 +-
 configs/dra7xx_evm_defconfig   |   2 +-
 6 files changed, 605 insertions(+), 671 deletions(-)
 create mode 100644 arch/arm/dts/dra72-evm-common.dtsi
 create mode 100644 arch/arm/dts/dra72-evm-revc.dts

-- 
2.10.0.372.g6fe1b14

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


[U-Boot] [PATCH 2/2] board: ti: dra7xx: complex definitions should be protected with parentheses

2016-09-27 Thread Mugunthan V N
As a standard practice complex definitions should be protected
with parentheses, as it might fail when used in a complex if
statements.

Signed-off-by: Mugunthan V N <mugunthan...@ti.com>
---
 board/ti/dra7xx/evm.c | 8 
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/board/ti/dra7xx/evm.c b/board/ti/dra7xx/evm.c
index be9af76..af4bc4e 100644
--- a/board/ti/dra7xx/evm.c
+++ b/board/ti/dra7xx/evm.c
@@ -36,10 +36,10 @@
 
 #define board_is_dra74x_evm()  board_ti_is("5777xCPU")
 #define board_is_dra72x_evm()  board_ti_is("DRA72x-T")
-#define board_is_dra74x_revh_or_later() board_is_dra74x_evm() &&   \
-   (strncmp("H", board_ti_get_rev(), 1) <= 0)
-#define board_is_dra72x_revc_or_later() board_is_dra72x_evm() &&   \
-   (strncmp("C", board_ti_get_rev(), 1) <= 0)
+#define board_is_dra74x_revh_or_later() (board_is_dra74x_evm() &&  \
+   (strncmp("H", board_ti_get_rev(), 1) <= 0))
+#define board_is_dra72x_revc_or_later() (board_is_dra72x_evm() &&  \
+   (strncmp("C", board_ti_get_rev(), 1) <= 0))
 #define board_ti_get_emif_size()   board_ti_get_emif1_size() + \
board_ti_get_emif2_size()
 
-- 
2.10.0.372.g6fe1b14

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


[U-Boot] [PATCH 1/2] ARM: dts: dra72: add rev C evm support

2016-09-27 Thread Mugunthan V N
Add DTS support for dra72 evm Rev C which has the following
changes
* Two ethernet ports now instead of the single one in rev B.
* DP83867 ethernet phy instead of DP838865.

Cc: Vignesh R <vigne...@ti.com>
Signed-off-by: Mugunthan V N <mugunthan...@ti.com>
---
 arch/arm/dts/Makefile  |   3 +-
 arch/arm/dts/dra72-evm-common.dtsi | 513 
 arch/arm/dts/dra72-evm-revc.dts|  70 
 arch/arm/dts/dra72-evm.dts | 664 +
 board/ti/dra7xx/evm.c  |  16 +-
 configs/dra7xx_evm_defconfig   |   2 +-
 6 files changed, 601 insertions(+), 667 deletions(-)
 create mode 100644 arch/arm/dts/dra72-evm-common.dtsi
 create mode 100644 arch/arm/dts/dra72-evm-revc.dts

diff --git a/arch/arm/dts/Makefile b/arch/arm/dts/Makefile
index e89b6e80..472ca1a 100644
--- a/arch/arm/dts/Makefile
+++ b/arch/arm/dts/Makefile
@@ -131,7 +131,8 @@ dtb-$(CONFIG_ARCH_SOCFPGA) +=   
\
socfpga_cyclone5_sr1500.dtb \
socfpga_cyclone5_vining_fpga.dtb
 
-dtb-$(CONFIG_TARGET_DRA7XX_EVM) += dra72-evm.dtb dra7-evm.dtb
+dtb-$(CONFIG_TARGET_DRA7XX_EVM) += dra72-evm.dtb dra7-evm.dtb  \
+   dra72-evm-revc.dtb
 dtb-$(CONFIG_TARGET_AM57XX_EVM) += am57xx-beagle-x15.dtb \
am572x-idk.dtb
 dtb-$(CONFIG_TARGET_STV0991) += stv0991.dtb
diff --git a/arch/arm/dts/dra72-evm-common.dtsi 
b/arch/arm/dts/dra72-evm-common.dtsi
new file mode 100644
index 000..b0993e5
--- /dev/null
+++ b/arch/arm/dts/dra72-evm-common.dtsi
@@ -0,0 +1,513 @@
+/*
+ * Copyright (C) 2016 Texas Instruments Incorporated - http://www.ti.com/
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ */
+/dts-v1/;
+
+#include "dra72x.dtsi"
+#include 
+
+/ {
+   compatible = "ti,dra72-evm", "ti,dra722", "ti,dra72", "ti,dra7";
+
+   chosen {
+   stdout-path = 
+   tick-timer = 
+   };
+
+   aliases {
+   display0 = 
+   };
+
+   evm_3v3: fixedregulator-evm_3v3 {
+   compatible = "regulator-fixed";
+   regulator-name = "evm_3v3";
+   regulator-min-microvolt = <330>;
+   regulator-max-microvolt = <330>;
+   };
+
+   extcon_usb1: extcon_usb1 {
+   compatible = "linux,extcon-usb-gpio";
+   id-gpio = <_gpio_21 1 GPIO_ACTIVE_HIGH>;
+   };
+
+   extcon_usb2: extcon_usb2 {
+   compatible = "linux,extcon-usb-gpio";
+   id-gpio = <_gpio_21 2 GPIO_ACTIVE_HIGH>;
+   };
+
+   hdmi0: connector {
+   compatible = "hdmi-connector";
+   label = "hdmi";
+
+   type = "a";
+
+   port {
+   hdmi_connector_in: endpoint {
+   remote-endpoint = <_out>;
+   };
+   };
+   };
+
+   tpd12s015: encoder {
+   compatible = "ti,tpd12s015";
+
+   gpios = <_hdmi 4 GPIO_ACTIVE_HIGH>, /* P4, CT CP HPD */
+   <_hdmi 5 GPIO_ACTIVE_HIGH>, /* P5, LS OE */
+   < 12 GPIO_ACTIVE_HIGH>;   /* gpio7_12/sp1_cs2, 
HPD */
+
+   ports {
+   #address-cells = <1>;
+   #size-cells = <0>;
+
+   port@0 {
+   reg = <0>;
+
+   tpd12s015_in: endpoint {
+   remote-endpoint = <_out>;
+   };
+   };
+
+   port@1 {
+   reg = <1>;
+
+   tpd12s015_out: endpoint {
+   remote-endpoint = <_connector_in>;
+   };
+   };
+   };
+   };
+};
+
+_pmx_core {
+   mmc1_pins_default: mmc1_pins_default {
+   pinctrl-single,pins = <
+   0x354 (PIN_INPUT_PULLUP | MUX_MODE0) /* mmc1_clk.clk */
+   0x358 (PIN_INPUT_PULLUP | MUX_MODE0) /* mmc1_cmd.cmd */
+   0x35c (PIN_INPUT_PULLUP | MUX_MODE0) /* mmc1_dat0.dat0 
*/
+   0x360 (PIN_INPUT_PULLUP | MUX_MODE0) /* mmc1_dat1.dat1 
*/
+   0x364 (PIN_INPUT_PULLUP | MUX_MODE0) /* mmc1_dat2.dat2 
*/
+   0x368 (PIN_INPUT_PULLUP | MUX_MODE0) /* mmc1_dat3.dat3 
*/
+   >;
+   };
+
+   mmc2_pins_default: mmc2_pins_default {
+   pinctrl-single,pins = <
+

[U-Boot] [PATCH] ARM: dts: dra72-evm: fix broken ethernet

2016-08-31 Thread Mugunthan V N
With commit ceec08f50b6, phy is connected to slave 0, but
changing the phy node was missed, fix it by populating the
phy node to proper cpsw slave node.

Fixes: ceec08f50b6 ("ARM: dts: dra72-evm: Add mode-gpios entry for mac node")
Signed-off-by: Mugunthan V N <mugunthan...@ti.com>
Cc: Vignesh R <vigne...@ti.com>
---
 arch/arm/dts/dra72-evm.dts | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/arm/dts/dra72-evm.dts b/arch/arm/dts/dra72-evm.dts
index 4ca37fa..e7c5db2 100644
--- a/arch/arm/dts/dra72-evm.dts
+++ b/arch/arm/dts/dra72-evm.dts
@@ -591,7 +591,7 @@
mode-gpios = <_gpio_21 4 GPIO_ACTIVE_HIGH>;
 };
 
-_emac1 {
+_emac0 {
phy_id = <_mdio>, <3>;
phy-mode = "rgmii";
 };
-- 
2.10.0.rc1

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


Re: [U-Boot] [PATCH v2 2/2] net: davinci_emac: Invalidate only the received portion of a buffer

2016-08-16 Thread Mugunthan V N
On Monday 15 August 2016 10:53 PM, Karl Beldan wrote:
> ATM when receiving a packet the whole buffer is invalidated, this change
> optimizes this behaviour.
> 
> Signed-off-by: Karl Beldan <karl.beldan+...@gmail.com>

Reviewed-by: Mugunthan V N <mugunthan...@ti.com>

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


Re: [U-Boot] [PATCH v2 1/2] net: davinci_emac: Round up top tx buffer boundaries for dcache ops

2016-08-16 Thread Mugunthan V N
On Monday 15 August 2016 10:53 PM, Karl Beldan wrote:
> check_cache_range() warns that the top boundaries are not properly
> aligned when flushing or invalidating the buffers and make these
> operations fail.
> 
> This gets rid of the remaining warnings:
> CACHE: Misaligned operation at range
> 
> Signed-off-by: Karl Beldan <karl.beldan+...@gmail.com>

Reviewed-by: Mugunthan V N <mugunthan...@ti.com>

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


[U-Boot] [PATCH] drivers: net: keystone_net: add rgmii link type support when parsing dt

2016-08-11 Thread Mugunthan V N
Add support to detect RGMII link interface from link-interface
device tree entry. Also rename the existing link type enums so
that it provides meaningful interface like SGMII.

Signed-off-by: Mugunthan V N <mugunthan...@ti.com>
---

Tested this patch on Keystone K2G evm, logs [1]

[1] - http://pastebin.ubuntu.com/23026361/

---
 drivers/net/keystone_net.c | 23 +++
 1 file changed, 15 insertions(+), 8 deletions(-)

diff --git a/drivers/net/keystone_net.c b/drivers/net/keystone_net.c
index e41b7d1..0da3325 100644
--- a/drivers/net/keystone_net.c
+++ b/drivers/net/keystone_net.c
@@ -56,13 +56,16 @@ struct rx_buff_desc net_rx_buffs = {
 #ifdef CONFIG_DM_ETH
 
 enum link_type {
-   LINK_TYPE_MAC_TO_MAC_AUTO = 0,
-   LINK_TYPE_MAC_TO_PHY_MODE = 1,
-   LINK_TYPE_MAC_TO_MAC_FORCED_MODE = 2,
-   LINK_TYPE_MAC_TO_FIBRE_MODE = 3,
-   LINK_TYPE_MAC_TO_PHY_NO_MDIO_MODE = 4,
-   LINK_TYPE_10G_MAC_TO_PHY_MODE = 10,
-   LINK_TYPE_10G_MAC_TO_MAC_FORCED_MODE = 11,
+   LINK_TYPE_SGMII_MAC_TO_MAC_AUTO = 0,
+   LINK_TYPE_SGMII_MAC_TO_PHY_MODE = 1,
+   LINK_TYPE_SGMII_MAC_TO_MAC_FORCED_MODE  = 2,
+   LINK_TYPE_SGMII_MAC_TO_FIBRE_MODE   = 3,
+   LINK_TYPE_SGMII_MAC_TO_PHY_NO_MDIO_MODE = 4,
+   LINK_TYPE_RGMII_LINK_MAC_PHY= 5,
+   LINK_TYPE_RGMII_LINK_MAC_MAC_FORCED = 6,
+   LINK_TYPE_RGMII_LINK_MAC_PHY_NO_MDIO= 7,
+   LINK_TYPE_10G_MAC_TO_PHY_MODE   = 10,
+   LINK_TYPE_10G_MAC_TO_MAC_FORCED_MODE= 11,
 };
 
 #define mac_hi(mac) (((mac)[0] << 0) | ((mac)[1] << 8) |\
@@ -1077,11 +1080,15 @@ static int ks2_eth_parse_slave_interface(int netcp, int 
slave,
priv->mdio_base = (void *)fdtdec_get_addr(fdt, mdio, "reg");
}
 
-   if (priv->link_type == LINK_TYPE_MAC_TO_PHY_MODE) {
+   if (priv->link_type == LINK_TYPE_SGMII_MAC_TO_PHY_MODE) {
priv->phy_if = PHY_INTERFACE_MODE_SGMII;
pdata->phy_interface = priv->phy_if;
priv->sgmii_link_type = SGMII_LINK_MAC_PHY;
priv->has_mdio = true;
+   } else if (priv->link_type == LINK_TYPE_RGMII_LINK_MAC_PHY) {
+   priv->phy_if = PHY_INTERFACE_MODE_RGMII;
+   pdata->phy_interface = priv->phy_if;
+   priv->has_mdio = true;
}
 
return 0;
-- 
2.9.2.664.ga0a1831

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


Re: [U-Boot] [PATCH v3] drivers: net: cpsw: always flush cache of size aligned to PKTALIGN

2016-08-11 Thread Mugunthan V N
On Thursday 11 August 2016 01:00 PM, Lokesh Vutla wrote:
> cpsw tries to flush dcache which is not in the range of PKTALIGN.
> Because of this the following warning comes while flushing:
> 
> CACHE: Misaligned operation at range [dffecec0, dffed016]
> 
> Fix it by flushing cache of size aligned to PKTALIGN.
> 
> Signed-off-by: Lokesh Vutla <lokeshvu...@ti.com>
> ---

Reviewed-by: Mugunthan V N <mugunthan...@ti.com>

Regards
Mugunthan V N

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


[U-Boot] [PATCH] defconfig: am43xx_evm: enable eth driver model

2016-08-11 Thread Mugunthan V N
Enable eth driver model for am43xx_evm as cpsw supports
driver model.

This was already added with the commit bc705ea1cf12 but with
commit 4c4e3b37750f to add fit support CONFIG_DM_ETH was missed.

Signed-off-by: Mugunthan V N <mugunthan...@ti.com>
Cc: Lokesh Vutla <lokeshvu...@ti.com>
---
 configs/am43xx_evm_defconfig| 1 +
 configs/am43xx_hs_evm_defconfig | 1 +
 2 files changed, 2 insertions(+)

diff --git a/configs/am43xx_evm_defconfig b/configs/am43xx_evm_defconfig
index b3fe269..56782f1 100644
--- a/configs/am43xx_evm_defconfig
+++ b/configs/am43xx_evm_defconfig
@@ -56,3 +56,4 @@ CONFIG_G_DNL_VENDOR_NUM=0x0403
 CONFIG_G_DNL_PRODUCT_NUM=0xbd00
 CONFIG_SPL_OF_LIBFDT=y
 CONFIG_DM_I2C=y
+CONFIG_DM_ETH=y
diff --git a/configs/am43xx_hs_evm_defconfig b/configs/am43xx_hs_evm_defconfig
index c8ce723..1553196 100644
--- a/configs/am43xx_hs_evm_defconfig
+++ b/configs/am43xx_hs_evm_defconfig
@@ -59,3 +59,4 @@ CONFIG_G_DNL_VENDOR_NUM=0x0403
 CONFIG_G_DNL_PRODUCT_NUM=0xbd00
 CONFIG_SPL_OF_LIBFDT=y
 CONFIG_DM_I2C=y
+CONFIG_DM_ETH=y
-- 
2.9.2.664.ga0a1831

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


[U-Boot] [PATCH] configs: dra7xx_evm: enable eth driver model

2016-08-10 Thread Mugunthan V N
Enable eth driver model for dra7xx_evm as cpsw supports
driver model.

This was already added with the commit 641b936fa5ba but with
commit bd7245849f7c to add fit support CONFIG_DM_ETH was missed.

Signed-off-by: Mugunthan V N <mugunthan...@ti.com>
Cc: Lokesh Vutla <lokeshvu...@ti.com>
---
 configs/dra7xx_evm_defconfig | 1 +
 1 file changed, 1 insertion(+)

diff --git a/configs/dra7xx_evm_defconfig b/configs/dra7xx_evm_defconfig
index 81d2a0e..e5f813d 100644
--- a/configs/dra7xx_evm_defconfig
+++ b/configs/dra7xx_evm_defconfig
@@ -59,3 +59,4 @@ CONFIG_SPL_LOAD_FIT=y
 CONFIG_OF_LIST="dra7-evm dra72-evm"
 CONFIG_DM_I2C=y
 CONFIG_PCF8575_GPIO=y
+CONFIG_DM_ETH=y
-- 
2.9.2.664.ga0a1831

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


Re: [U-Boot] [PATCH 3/4] ARM: dts: k2g-evm: enable mmc/sd suppport

2016-08-10 Thread Mugunthan V N
On Wednesday 10 August 2016 07:24 PM, Sekhar Nori wrote:
> The K2G EVM from TI has an SD card slot as
> well as onboard eMMC for data storage.
> 
> Enable support for these.
> 
> Signed-off-by: Sekhar Nori <nsek...@ti.com>

Acked-by: Mugunthan V N <mugunthan...@ti.com>

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


Re: [U-Boot] [PATCH 4/4] defconfig: k2g_evm_defconfig: Enable mmc driver model

2016-08-10 Thread Mugunthan V N
On Wednesday 10 August 2016 07:24 PM, Sekhar Nori wrote:
> K2G can benefit from driver model support in the
> MMC/SD driver it uses: omap_hsmmc
> 
> Enable driver model MMC support for K2G.
> 
> Signed-off-by: Sekhar Nori <nsek...@ti.com>
> ---

Acked-by: Mugunthan V N <mugunthan...@ti.com>

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


Re: [U-Boot] [PATCH 2/4] ARM: dts: K2G: Add support for MMC controller

2016-08-10 Thread Mugunthan V N
On Wednesday 10 August 2016 07:24 PM, Sekhar Nori wrote:
> K2G SoC from TI has two MMC/SD controllers.
> Add device tree data for these.
> 
> Signed-off-by: Sekhar Nori <nsek...@ti.com>
> ---

Acked-by: Mugunthan V N <mugunthan...@ti.com>

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


Re: [U-Boot] [PATCH 1/4] drivers: mmc: omap_hsmmc: fix build breakage

2016-08-10 Thread Mugunthan V N
On Wednesday 10 August 2016 07:24 PM, Sekhar Nori wrote:
> structure member 'cd_inverted' of omap_hsmmc_data
> is available only when OMAP_HSMMC_USE_GPIO is
> defined.
> 
> When CONFIG_DM_MMC is defined, but not
> CONFIG_OMAP_GPIO, this will cause build breakage
> in omap_hsmmc driver of the sort:
> 
>   CC  drivers/mmc/omap_hsmmc.o
> ../drivers/mmc/omap_hsmmc.c: In function 'omap_hsmmc_ofdata_to_platdata':
> ../drivers/mmc/omap_hsmmc.c:1763:6: error: 'struct omap_hsmmc_data' has no 
> member named 'cd_inverted'
>   priv->cd_inverted = fdtdec_get_bool(fdt, node, "cd-inverted");
>   ^
> 
> Fix this by accessing cd_inverted only when
> OMAP_HSMMC_USE_GPIO is defined.
> 
> Signed-off-by: Sekhar Nori <nsek...@ti.com>

Acked-by: Mugunthan V N <mugunthan...@ti.com>

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


Re: [U-Boot] [PATCH v2] drivers: net: cpsw: always flush cache of size PKTSIZE_ALIGN

2016-08-09 Thread Mugunthan V N
On Tuesday 09 August 2016 11:17 AM, Lokesh Vutla wrote:
> cpsw tries to flush dcache which is not in the range of PKTSIZE.
> Because of this the following warning comes while flushing:
> 
> CACHE: Misaligned operation at range [dffecec0, dffed016]
> 
> Fix it by flushing cache of size PKTSIZE_ALIGN as similar to what is
> being done in _cpsw_recv.
> 
> Signed-off-by: Lokesh Vutla <lokeshvu...@ti.com>

Tested-by: Mugunthan V N <mugunthan...@ti.com>

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


Re: [U-Boot] [PATCH v3 5/5] ARM: dts: dra72-evm: Add mode-gpios entry for mac node

2016-08-02 Thread Mugunthan V N
On Tuesday 02 August 2016 10:14 AM, Vignesh R wrote:
> On DRA72 EVM, cpsw slave1 is muxed with VIN2A, hence switch to cpsw
> slave0 for ethernet. This is controlled by pcf gpio line. Add
> appropriate mode-gpios DT entry so that driver can select the required
> slave.
> 
> Signed-off-by: Vignesh R <vigne...@ti.com>
> Reviewed-by: Tom Rini <tr...@konsulko.com>

Reviewed-by: Mugunthan V N <mugunthan...@ti.com>

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


Re: [U-Boot] [PATCH v3 3/5] ARM: dts: dra7xx: Add u-boot specific property for PCF8575 nodes

2016-08-02 Thread Mugunthan V N
On Tuesday 02 August 2016 10:14 AM, Vignesh R wrote:
> PCF8575 does not have any registers hence, offset field needs to be
> ignored for i2c read/write. Therefore populate u-boot,i2c-offset-len
> with 0 in PCF8575 DT nodes.
> 
> Signed-off-by: Vignesh R <vigne...@ti.com>

Reviewed-by: Mugunthan V N <mugunthan...@ti.com>

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


Re: [U-Boot] [PATCH v3 4/5] net: cpsw: Add support to drive gpios for ethernet to be functional

2016-08-02 Thread Mugunthan V N
On Tuesday 02 August 2016 10:14 AM, Vignesh R wrote:
> On DRA72 EVM, cpsw slaves may be muxed with other modules. This
> selection is controlled by a pcf gpio line. Add support for cpsw driver
> to acquire mode-gpios and select the appropriate slave using gpio APIs.
> 
> Signed-off-by: Vignesh R <vigne...@ti.com>
> Reviewed-by: Tom Rini <tr...@konsulko.com>
> Acked-by: Joe Hershberger <joe.hershber...@ni.com>

Reviewed-by: Mugunthan V N <mugunthan...@ti.com>

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


Re: [U-Boot] [PATCH v3 2/5] ARM: dra7xx_evm: Enable support for TI PCF8575

2016-08-02 Thread Mugunthan V N
On Tuesday 02 August 2016 10:14 AM, Vignesh R wrote:
> On DRA7, pcf chip present at address 0x21 on i2c1, is used to
> switch between cpsw slave0 and slave1. Hence, enable PCF
> driver for the same.
> 
> Signed-off-by: Vignesh R <vigne...@ti.com>

Reviewed-by: Mugunthan V N <mugunthan...@ti.com>

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


Re: [U-Boot] [PATCH v3 1/5] gpio: Add driver for TI PCF8575 I2C GPIO expander

2016-08-02 Thread Mugunthan V N
On Tuesday 02 August 2016 10:14 AM, Vignesh R wrote:
> TI's PCF8575 is a 16-bit I2C GPIO expander.The device features a
> 16-bit quasi-bidirectional I/O ports. Each quasi-bidirectional I/O can
> be used as an input or output without the use of a data-direction
> control signal. The I/Os should be high before being used as inputs.
> Read the device documentation for more details[1].
> 
> This driver is based on pcf857x driver available in Linux v4.7 kernel.
> It supports basic reading and writing of gpio pins.
> 
> [1] http://www.ti.com/lit/ds/symlink/pcf8575.pdf
> 
> Signed-off-by: Vignesh R <vigne...@ti.com>
> Reviewed-by: Tom Rini <tr...@konsulko.com>
> Reviewed-by: Simon Glass <s...@chromium.org>

Reviewed-by: Mugunthan V N <mugunthan...@ti.com>

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


[U-Boot] [PATCH 4/5] configs: k2e_evm: add random eth address support

2016-08-02 Thread Mugunthan V N
There is only one ethernet mac address in e-fuse, but there are
multiple slaves in keystone net, so enable random mac address
support.

Signed-off-by: Mugunthan V N <mugunthan...@ti.com>
---
 configs/k2e_evm_defconfig | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/configs/k2e_evm_defconfig b/configs/k2e_evm_defconfig
index 65561b1..04c52f0 100644
--- a/configs/k2e_evm_defconfig
+++ b/configs/k2e_evm_defconfig
@@ -37,3 +37,5 @@ CONFIG_SYS_NS16550=y
 CONFIG_USB=y
 CONFIG_USB_XHCI_HCD=y
 CONFIG_USB_XHCI_DWC3=y
+CONFIG_LIB_RAND=y
+CONFIG_NET_RANDOM_ETHADDR=y
-- 
2.9.2.517.gf8f7adc

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


[U-Boot] [PATCH 5/5] configs: k2l_evm: add random eth address support

2016-08-02 Thread Mugunthan V N
There is only one ethernet mac address in e-fuse, but there are
multiple slaves in keystone net, so enable random mac address
support.

Signed-off-by: Mugunthan V N <mugunthan...@ti.com>
---
 configs/k2l_evm_defconfig | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/configs/k2l_evm_defconfig b/configs/k2l_evm_defconfig
index 9aa429c..e1386f7 100644
--- a/configs/k2l_evm_defconfig
+++ b/configs/k2l_evm_defconfig
@@ -37,3 +37,5 @@ CONFIG_SYS_NS16550=y
 CONFIG_USB=y
 CONFIG_USB_XHCI_HCD=y
 CONFIG_USB_XHCI_DWC3=y
+CONFIG_LIB_RAND=y
+CONFIG_NET_RANDOM_ETHADDR=y
-- 
2.9.2.517.gf8f7adc

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


[U-Boot] [PATCH 0/5] Enabling multi port ethernet support for keystone net

2016-08-02 Thread Mugunthan V N
Keystone net has multiple slave ethernets, register each slave as
individual ethernet so that tftp can be used on any of the
ethernet ports.

Tested the series on K2HK, K2L, K2E (logs [1]). Also pushed a
branch for testing [2]

With the patch series there is a checkpatch warning and it can be
ignored as it is error log which helps to grep the text.

[1] - http://pastebin.ubuntu.com/21861232/
[2] - git://git.ti.com/~mugunthanvnm/ti-u-boot/mugunth-ti-u-boot.git 
k2net-multi-slave

WARNING: line over 80 characters
#143: FILE: drivers/net/keystone_net.c:1011:
+   error("ks2_net - not able to bind slave 
interfaces\n");

total: 0 errors, 1 warnings, 0 checks, 276 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/multi-port-support/v1.00/0002-drivers-net-keystone_net-add-support-for-multi-slave.patch
 has style problems, please review.

Mugunthan V N (5):
  drivers: net: keystone_net: fix line termination with semi-colon
  drivers: net: keystone_net: add support for multi slave ethernet
  configs: k2hk_evm: add random eth address support
  configs: k2e_evm: add random eth address support
  configs: k2l_evm: add random eth address support

 configs/k2e_evm_defconfig  |   2 +
 configs/k2hk_evm_defconfig |   2 +
 configs/k2l_evm_defconfig  |   2 +
 drivers/net/keystone_net.c | 228 +++--
 4 files changed, 186 insertions(+), 48 deletions(-)

-- 
2.9.2.517.gf8f7adc

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


[U-Boot] [PATCH 2/5] drivers: net: keystone_net: add support for multi slave ethernet

2016-08-02 Thread Mugunthan V N
Keystone net can have multiple ethernet slaves, currently only
slave 1 is supported by the driver. Register multiple slaves as
individual ethernets to network framework.

Signed-off-by: Mugunthan V N <mugunthan...@ti.com>
---
 drivers/net/keystone_net.c | 222 -
 1 file changed, 177 insertions(+), 45 deletions(-)

diff --git a/drivers/net/keystone_net.c b/drivers/net/keystone_net.c
index 1756c09..e41b7d1 100644
--- a/drivers/net/keystone_net.c
+++ b/drivers/net/keystone_net.c
@@ -11,6 +11,7 @@
 #include 
 
 #include 
+#include 
 
 #include 
 #include 
@@ -765,6 +766,8 @@ static int ks2_eth_start(struct udevice *dev)
hw_config_streaming_switch();
 
if (priv->has_mdio) {
+   keystone2_mdio_reset(priv->mdio_bus);
+
phy_startup(priv->phydev);
if (priv->phydev->link == 0) {
error("phy startup failed\n");
@@ -910,23 +913,34 @@ static int ks2_eth_probe(struct udevice *dev)
priv->net_rx_buffs.num_buffs = RX_BUFF_NUMS;
priv->net_rx_buffs.buff_len = RX_BUFF_LEN;
 
-   /* Register MDIO bus */
-   mdio_bus = mdio_alloc();
-   if (!mdio_bus) {
-   error("MDIO alloc failed\n");
-   return -ENOMEM;
-   }
-   priv->mdio_bus = mdio_bus;
-   mdio_bus->read  = keystone2_mdio_read;
-   mdio_bus->write = keystone2_mdio_write;
-   mdio_bus->reset = keystone2_mdio_reset;
-   mdio_bus->priv  = priv->mdio_base;
-   sprintf(mdio_bus->name, "ethernet-mdio");
-
-   ret = mdio_register(mdio_bus);
-   if (ret) {
-   error("MDIO bus register failed\n");
-   return ret;
+   if (priv->slave_port == 1) {
+   /*
+* Register MDIO bus for slave 0 only, other slave have
+* to re-use the same
+*/
+   mdio_bus = mdio_alloc();
+   if (!mdio_bus) {
+   error("MDIO alloc failed\n");
+   return -ENOMEM;
+   }
+   priv->mdio_bus = mdio_bus;
+   mdio_bus->read  = keystone2_mdio_read;
+   mdio_bus->write = keystone2_mdio_write;
+   mdio_bus->reset = keystone2_mdio_reset;
+   mdio_bus->priv  = priv->mdio_base;
+   sprintf(mdio_bus->name, "ethernet-mdio");
+
+   ret = mdio_register(mdio_bus);
+   if (ret) {
+   error("MDIO bus register failed\n");
+   return ret;
+   }
+   } else {
+   /* Get the MDIO bus from slave 0 device */
+   struct ks2_eth_priv *parent_priv;
+
+   parent_priv = dev_get_priv(dev->parent);
+   priv->mdio_bus = parent_priv->mdio_bus;
}
 
 #ifndef CONFIG_SOC_K2G
@@ -935,8 +949,11 @@ static int ks2_eth_probe(struct udevice *dev)
 
priv->netcp_pktdma = _pktdma;
 
-   priv->phydev = phy_connect(mdio_bus, priv->phy_addr, dev, priv->phy_if);
-   phy_config(priv->phydev);
+   if (priv->has_mdio) {
+   priv->phydev = phy_connect(priv->mdio_bus, priv->phy_addr,
+  dev, priv->phy_if);
+   phy_config(priv->phydev);
+   }
 
return 0;
 }
@@ -962,39 +979,103 @@ static const struct eth_ops ks2_eth_ops = {
.write_hwaddr   = ks2_eth_write_hwaddr,
 };
 
-
-static int ks2_eth_ofdata_to_platdata(struct udevice *dev)
+static int ks2_eth_bind_slaves(struct udevice *dev, int gbe, int *gbe_0)
 {
-   struct ks2_eth_priv *priv = dev_get_priv(dev);
-   struct eth_pdata *pdata = dev_get_platdata(dev);
const void *fdt = gd->fdt_blob;
+   struct udevice *sl_dev;
int interfaces;
-   int interface_0;
-   int netcp_gbe_0;
-   int phy;
+   int sec_slave;
+   int slave;
+   int ret;
+   char *slave_name;
+
+   interfaces = fdt_subnode_offset(fdt, gbe, "interfaces");
+   fdt_for_each_subnode(fdt, slave, interfaces) {
+   int slave_no;
+
+   slave_no = fdtdec_get_int(fdt, slave, "slave-port", -ENOENT);
+   if (slave_no == -ENOENT)
+   continue;
+
+   if (slave_no == 0) {
+   /* This is the current eth device */
+   *gbe_0 = slave;
+   } else {
+   /* Slave devices to be registered */
+   slave_name = malloc(20);
+   snprintf(slave_name, 20, "netcp@slave-%d", slave_no);
+   ret = device_bind_driver_to_node(dev, "eth_ks2_sl",
+slave_name, slave,
+  

[U-Boot] [PATCH 1/5] drivers: net: keystone_net: fix line termination with semi-colon

2016-08-02 Thread Mugunthan V N
Each line should be terminated by semi-colon. It was not caught
earlier as there is a proper statement. Fix it by changing the
comma with semi-colon.

Signed-off-by: Mugunthan V N <mugunthan...@ti.com>
---
 drivers/net/keystone_net.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/net/keystone_net.c b/drivers/net/keystone_net.c
index 6b28df0..1756c09 100644
--- a/drivers/net/keystone_net.c
+++ b/drivers/net/keystone_net.c
@@ -906,9 +906,9 @@ static int ks2_eth_probe(struct udevice *dev)
pll_pa_clk_sel();
 
 
-   priv->net_rx_buffs.buff_ptr = rx_buffs,
-   priv->net_rx_buffs.num_buffs = RX_BUFF_NUMS,
-   priv->net_rx_buffs.buff_len = RX_BUFF_LEN,
+   priv->net_rx_buffs.buff_ptr = rx_buffs;
+   priv->net_rx_buffs.num_buffs = RX_BUFF_NUMS;
+   priv->net_rx_buffs.buff_len = RX_BUFF_LEN;
 
/* Register MDIO bus */
mdio_bus = mdio_alloc();
-- 
2.9.2.517.gf8f7adc

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


[U-Boot] [PATCH 3/5] configs: k2hk_evm: add random eth address support

2016-08-02 Thread Mugunthan V N
There is only one ethernet mac address in e-fuse, but there are
multiple slaves in keystone net, so enable random mac address
support.

Signed-off-by: Mugunthan V N <mugunthan...@ti.com>
---
 configs/k2hk_evm_defconfig | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/configs/k2hk_evm_defconfig b/configs/k2hk_evm_defconfig
index 8623e1c..c050f07 100644
--- a/configs/k2hk_evm_defconfig
+++ b/configs/k2hk_evm_defconfig
@@ -37,3 +37,5 @@ CONFIG_SYS_NS16550=y
 CONFIG_USB=y
 CONFIG_USB_XHCI_HCD=y
 CONFIG_USB_XHCI_DWC3=y
+CONFIG_LIB_RAND=y
+CONFIG_NET_RANDOM_ETHADDR=y
-- 
2.9.2.517.gf8f7adc

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


Re: [U-Boot] [PATCH v2 2/2] ARM: dts: am57xx-idk-common: Enable support for QSPI

2016-07-29 Thread Mugunthan V N
On Friday 29 July 2016 02:22 PM, Vignesh R wrote:
> AM571x and AM572x IDK have a spansion s25fl256s QSPI flash on the board
> connected to TI QSPI over CS0. Hence, add QSPI and flash slave
> DT nodes.
> 
> Signed-off-by: Vignesh R <vigne...@ti.com>

Reviewed-by: Mugunthan V N <mugunthan...@ti.com>

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


Re: [U-Boot] [PATCH v2 1/2] ARM: am57xx_evm: Enable QSPI support

2016-07-29 Thread Mugunthan V N
On Friday 29 July 2016 02:22 PM, Vignesh R wrote:
> AM571x IDK and AM572x IDK EVMs have spansion s25fl256s QSPI flash on the
> board connected to TI QSPI IP over CS0. Therefore enable QSPI support.
> 
> Signed-off-by: Vignesh R <vigne...@ti.com>

Reviewed-by: Mugunthan V N <mugunthan...@ti.com>

Regards
Mugunthan V N


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


Re: [U-Boot] [PATCH 1/2] ARM: am57xx_evm: Enable QSPI support

2016-07-29 Thread Mugunthan V N
On Friday 29 July 2016 02:27 PM, Vignesh R wrote:
> 
> 
> On Friday 29 July 2016 02:24 PM, Mugunthan V N wrote:
>> On Friday 29 July 2016 12:03 PM, Vignesh R wrote:
>>> AM571x IDK and AM572x IDK EVMs have spansion s25fl256s QSPI flash on the
>>> board connected to TI QSPI IP over CS0. Therefore enable QSPI support.
>>>
>>> Signed-off-by: Vignesh R <vigne...@ti.com>
>>> ---
>>>  configs/am57xx_evm_defconfig |  5 +
>>>  include/configs/am57xx_evm.h | 36 
>>>  2 files changed, 41 insertions(+)
>>>
>>> diff --git a/configs/am57xx_evm_defconfig b/configs/am57xx_evm_defconfig
>>> index 8a8a4c9090b0..c95f45aca8b5 100644
>>> --- a/configs/am57xx_evm_defconfig
>>> +++ b/configs/am57xx_evm_defconfig
>>> @@ -41,3 +41,8 @@ CONFIG_SPL_OF_LIBFDT=y
>>>  CONFIG_SPL_LOAD_FIT=y
>>>  CONFIG_OF_LIST="am57xx-beagle-x15 am572x-idk"
>>>  CONFIG_DM_I2C=y
>>> +CONFIG_DM_SPI=y
>>> +CONFIG_DM_SPI_FLASH=y
>>> +CONFIG_SPI_FLASH_SPANSION=y
>>> +CONFIG_TI_QSPI=y
>>> +CONFIG_CMD_SF=y
>>
>> CONFIG_SPI_FLASH_BAR ???
> 
> That config option is already enabled in am57xx_evm_defconfig.
> 

Okay, I could see all spi related configs here, so I thought you missed
adding CONFIG_SPI_FLASH_BAR.

Reviewed-by: Mugunthan V N <mugunthan...@ti.com>

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


Re: [U-Boot] [PATCH 1/2] ARM: am57xx_evm: Enable QSPI support

2016-07-29 Thread Mugunthan V N
On Friday 29 July 2016 12:03 PM, Vignesh R wrote:
> AM571x IDK and AM572x IDK EVMs have spansion s25fl256s QSPI flash on the
> board connected to TI QSPI IP over CS0. Therefore enable QSPI support.
> 
> Signed-off-by: Vignesh R <vigne...@ti.com>
> ---
>  configs/am57xx_evm_defconfig |  5 +
>  include/configs/am57xx_evm.h | 36 
>  2 files changed, 41 insertions(+)
> 
> diff --git a/configs/am57xx_evm_defconfig b/configs/am57xx_evm_defconfig
> index 8a8a4c9090b0..c95f45aca8b5 100644
> --- a/configs/am57xx_evm_defconfig
> +++ b/configs/am57xx_evm_defconfig
> @@ -41,3 +41,8 @@ CONFIG_SPL_OF_LIBFDT=y
>  CONFIG_SPL_LOAD_FIT=y
>  CONFIG_OF_LIST="am57xx-beagle-x15 am572x-idk"
>  CONFIG_DM_I2C=y
> +CONFIG_DM_SPI=y
> +CONFIG_DM_SPI_FLASH=y
> +CONFIG_SPI_FLASH_SPANSION=y
> +CONFIG_TI_QSPI=y
> +CONFIG_CMD_SF=y

CONFIG_SPI_FLASH_BAR ???

Regards
Mugunthan V N

> diff --git a/include/configs/am57xx_evm.h b/include/configs/am57xx_evm.h
> index 2db199db33b7..083886ba262f 100644
> --- a/include/configs/am57xx_evm.h
> +++ b/include/configs/am57xx_evm.h
> @@ -86,4 +86,40 @@
>  #define CONFIG_EEPROM_CHIP_ADDRESS 0x50
>  #define CONFIG_EEPROM_BUS_ADDRESS 0
>  
> +/*
> + * Default to using SPI for environment, etc.
> + * 0x00 - 0x04 : QSPI.SPL (256KiB)
> + * 0x04 - 0x14 : QSPI.u-boot (1MiB)
> + * 0x14 - 0x1C : QSPI.u-boot-spl-os (512KiB)
> + * 0x1C - 0x1D : QSPI.u-boot-env (64KiB)
> + * 0x1D - 0x1E : QSPI.u-boot-env.backup1 (64KiB)
> + * 0x1E - 0x9E : QSPI.kernel (8MiB)
> + * 0x9E - 0x200 : USERLAND
> + */
> +#define CONFIG_SYS_SPI_KERNEL_OFFS  0x1E
> +#define CONFIG_SYS_SPI_ARGS_OFFS0x14
> +#define CONFIG_SYS_SPI_ARGS_SIZE0x8
> +
> +#ifdef CONFIG_SPL_BUILD
> +#undef CONFIG_DM_SPI
> +#undef CONFIG_DM_SPI_FLASH
> +#undef CONFIG_SPL_MAX_SIZE
> +#define CONFIG_SPL_MAX_SIZE (256 << 10) /* 256 KiB */
> +#endif
> +
> +/* SPI SPL */
> +#define CONFIG_SPL_SPI_SUPPORT
> +#define CONFIG_SPL_DMA_SUPPORT
> +#define CONFIG_TI_EDMA3
> +#define CONFIG_SPL_SPI_LOAD
> +#define CONFIG_SPL_SPI_FLASH_SUPPORT
> +#define CONFIG_SYS_SPI_U_BOOT_OFFS 0x4
> +
> +/* SPI */
> +#undef   CONFIG_OMAP3_SPI
> +#define CONFIG_TI_SPI_MMAP
> +#define CONFIG_SF_DEFAULT_SPEED7680
> +#define CONFIG_SF_DEFAULT_MODE SPI_MODE_0
> +#define CONFIG_QSPI_QUAD_SUPPORT
> +
>  #endif /* __CONFIG_AM57XX_EVM_H */
> 

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


Re: [U-Boot] [PATCH 4/4] ARM: dts: dra7xx: Update spi-max-frequency for QSPI

2016-07-29 Thread Mugunthan V N
On Monday 25 July 2016 03:45 PM, Vignesh R wrote:
> According to AM572x DM SPRS953A, QSPI max bus speed is 76.8MHz.
> Therefore update the spi-max-frequency value of QSPI node for DRA74 and
> DRA72 evm. This increase flash read speed by ~2MB/s.
> 
> Signed-off-by: Vignesh R <vigne...@ti.com>
> ---

Reviewed-by: Mugunthan V N <mugunthan...@ti.com>

Regards
Mugunthan V N

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


Re: [U-Boot] [PATCH 3/4] configs: dra7xx: Update QSPI speed to 76.8MHz

2016-07-29 Thread Mugunthan V N
On Monday 25 July 2016 03:45 PM, Vignesh R wrote:
> Now that QSPI driver can support 76.8MHz, update the
> CONFIG_SF_DEFAULT_SPEED to the same value.
> 
> Signed-off-by: Vignesh R <vigne...@ti.com>

Reviewed-by: Mugunthan V N <mugunthan...@ti.com>

Regards
Mugunthan V N

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


Re: [U-Boot] [PATCH 1/4] ARM: dra7xx: Change DPLL_PER_HS13 divider value

2016-07-29 Thread Mugunthan V N
On Monday 25 July 2016 03:45 PM, Vignesh R wrote:
> From: Lokesh Vutla <lokeshvu...@ti.com>
> 
> According to AM572x DM SPRS953A, QSPI bus speed can be 76.8MHz, hence
> update QSPI input clock divider value (DPLL_PER_HS13) to provide 76.8MHz
> clock, so that driver can use the same.
> 
> Signed-off-by: Vignesh R <vigne...@ti.com>
> ---

Reviewed-by: Mugunthan V N <mugunthan...@ti.com>

Regards
Mugunthan V N


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


Re: [U-Boot] [PATCH 2/4] spi: ti_qspi: dra7xx: Add support to use 76.8MHz clock

2016-07-29 Thread Mugunthan V N
On Monday 25 July 2016 03:45 PM, Vignesh R wrote:
> According to AM572x DM SPRS953A, QSPI bus speed can be 76.8MHz, update
> the driver to use the same.
> 
> Signed-off-by: Vignesh R <vigne...@ti.com>

Reviewed-by: Mugunthan V N <mugunthan...@ti.com>

Regards
Mugunthan V N

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


Re: [U-Boot] [PATCH] configs: am43xx_evm_defconfig: Enable CONFIG_SPI_FLASH_BAR

2016-07-29 Thread Mugunthan V N
On Thursday 28 July 2016 05:27 PM, Vignesh R wrote:
> AM437x SK and AM437x IDK EVMs have 64MB flash, therefore enable
> CONFIG_SPI_FLASH_BAR to access flash regions above 16MB.
> 
> Signed-off-by: Vignesh R <vigne...@ti.com>

Reviewed-by: Mugunthan V N <mugunthan...@ti.com>

Regards
Mugunthan V N

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


Re: [U-Boot] [PATCH 03/14] drivers: i2c: uclass: parse dt parameters only when CONFIG_OF_CONTROL is enable

2016-07-25 Thread Mugunthan V N
On Friday 22 July 2016 07:46 PM, Simon Glass wrote:
> Hi Muganthan,
> 
> On 22 July 2016 at 01:35, Mugunthan V N <mugunthan...@ti.com> wrote:
>> On Friday 22 July 2016 08:51 AM, Simon Glass wrote:
>>> Hi Mugunthan,
>>>
>>> On 18 July 2016 at 03:40, Mugunthan V N <mugunthan...@ti.com> wrote:
>>>> parse dt parameter of i2c devices only when CONFIG_OF_CONTROL
>>>> is enabled.
>>>>
>>>> Signed-off-by: Mugunthan V N <mugunthan...@ti.com>
>>>> ---
>>>>  drivers/i2c/i2c-uclass.c | 14 ++
>>>>  1 file changed, 14 insertions(+)
>>>
>>> Reviewed-by: Simon Glass <s...@chromium.org>
>>>
>>> Please see below.
>>>
>>>>
>>>> diff --git a/drivers/i2c/i2c-uclass.c b/drivers/i2c/i2c-uclass.c
>>>> index 50b99ea..20b30ff 100644
>>>> --- a/drivers/i2c/i2c-uclass.c
>>>> +++ b/drivers/i2c/i2c-uclass.c
>>>> @@ -467,6 +467,7 @@ int i2c_deblock(struct udevice *bus)
>>>> return ops->deblock(bus);
>>>>  }
>>>>
>>>> +#if CONFIG_IS_ENABLED(OF_CONTROL)
>>>>  int i2c_chip_ofdata_to_platdata(const void *blob, int node,
>>>> struct dm_i2c_chip *chip)
>>>>  {
>>>> @@ -482,31 +483,44 @@ int i2c_chip_ofdata_to_platdata(const void *blob, 
>>>> int node,
>>>>
>>>> return 0;
>>>>  }
>>>> +#endif
>>>>
>>>>  static int i2c_post_probe(struct udevice *dev)
>>>>  {
>>>> +#if CONFIG_IS_ENABLED(OF_CONTROL)
>>>> struct dm_i2c_bus *i2c = dev_get_uclass_priv(dev);
>>>>
>>>> i2c->speed_hz = fdtdec_get_int(gd->fdt_blob, dev->of_offset,
>>>>  "clock-frequency", 10);
>>>
>>> The above should be moved into i2c_chip_ofdata_to_platdata(), which
>>> will only be called if there is a device tree.
>>
>> This cannot be moved to i2c_chip_ofdata_to_platdata() as it is called
>> from post_bind where uclass_priv will not be allocated. uclass_priv will
>> be allocated in device probe.
> 
> OK I see. Then why do we need to support i2c without OF_CONTROL? Would
> it not be better to enable OF_CONTROL?
> 

Due to the memory size issue in OMAP SoCs, enabling OF_CONTROL for spl
is not possible. So having an option of enabling i2c uclass without
OF_CONTROL will be a good option.

Regards
Mugunthan V N

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


Re: [U-Boot] [PATCH v2 3/3] spi: ti_qspi: Remove delay in read path for dra7xx

2016-07-22 Thread Mugunthan V N
On Friday 22 July 2016 10:55 AM, Vignesh R wrote:
> As per commit b545a98f5dc563 ("spi: ti_qspi: Add delay
> for successful bulk erase) says its added to meet bulk erase timing
> constraints. But bulk erase is a cmd to flash and delay in read path
> does not make sense. Morever, testing on DRA74/DRA72 evm has shown that
> this delay is no longer required.
> 
> Signed-off-by: Vignesh R <vigne...@ti.com>

Reviewed-by: Mugunthan V N <mugunthan...@ti.com>

Regards
Mugunthan V N

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


Re: [U-Boot] [PATCH v2 2/3] spi: ti_qspi: Fix compiler warning when DEBUG macro is set

2016-07-22 Thread Mugunthan V N
On Friday 22 July 2016 10:55 AM, Vignesh R wrote:
> clk_div is uninitialized at the beginning of ti_spi_set_speed(), move
> debug() print after clk_div calculation to avoid compiler warning and to
> have proper value of clk_div printed during debugging.
> 
> Signed-off-by: Vignesh R <vigne...@ti.com>

Reviewed-by: Mugunthan V N <mugunthan...@ti.com>

Regards
Mugunthan V N

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


Re: [U-Boot] [PATCH v2 1/3] spi: ti_qspi: Fix failure on multiple READ_ID cmd

2016-07-22 Thread Mugunthan V N
On Friday 22 July 2016 10:55 AM, Vignesh R wrote:
> Populating QSPI_RD_SNGL bit(0x1) in priv->cmd means that value
> QSPI_INVAL (0x4) is not written to CMD field of QSPI_SPI_CMD_REG in
> ti_qspi_cs_deactivate(). Therefore CS is never deactivated between
> successive READ ID which results in sf probe to fail.
> Fix this by not populating priv->cmd with QSPI_RD_SNGL and OR it wih
> priv->cmd as required (similar to the convention followed in the
> driver).
> 
> Signed-off-by: Vignesh R <vigne...@ti.com>

Reviewed-by: Mugunthan V N <mugunthan...@ti.com>

Regards
Mugunthan V N

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


Re: [U-Boot] [PATCH 03/14] drivers: i2c: uclass: parse dt parameters only when CONFIG_OF_CONTROL is enable

2016-07-22 Thread Mugunthan V N
On Friday 22 July 2016 08:51 AM, Simon Glass wrote:
> Hi Mugunthan,
> 
> On 18 July 2016 at 03:40, Mugunthan V N <mugunthan...@ti.com> wrote:
>> parse dt parameter of i2c devices only when CONFIG_OF_CONTROL
>> is enabled.
>>
>> Signed-off-by: Mugunthan V N <mugunthan...@ti.com>
>> ---
>>  drivers/i2c/i2c-uclass.c | 14 ++
>>  1 file changed, 14 insertions(+)
> 
> Reviewed-by: Simon Glass <s...@chromium.org>
> 
> Please see below.
> 
>>
>> diff --git a/drivers/i2c/i2c-uclass.c b/drivers/i2c/i2c-uclass.c
>> index 50b99ea..20b30ff 100644
>> --- a/drivers/i2c/i2c-uclass.c
>> +++ b/drivers/i2c/i2c-uclass.c
>> @@ -467,6 +467,7 @@ int i2c_deblock(struct udevice *bus)
>> return ops->deblock(bus);
>>  }
>>
>> +#if CONFIG_IS_ENABLED(OF_CONTROL)
>>  int i2c_chip_ofdata_to_platdata(const void *blob, int node,
>> struct dm_i2c_chip *chip)
>>  {
>> @@ -482,31 +483,44 @@ int i2c_chip_ofdata_to_platdata(const void *blob, int 
>> node,
>>
>> return 0;
>>  }
>> +#endif
>>
>>  static int i2c_post_probe(struct udevice *dev)
>>  {
>> +#if CONFIG_IS_ENABLED(OF_CONTROL)
>> struct dm_i2c_bus *i2c = dev_get_uclass_priv(dev);
>>
>> i2c->speed_hz = fdtdec_get_int(gd->fdt_blob, dev->of_offset,
>>  "clock-frequency", 10);
> 
> The above should be moved into i2c_chip_ofdata_to_platdata(), which
> will only be called if there is a device tree.

This cannot be moved to i2c_chip_ofdata_to_platdata() as it is called
from post_bind where uclass_priv will not be allocated. uclass_priv will
be allocated in device probe.

Regards
Mugunthan V N

> 
>>
>> return dm_i2c_set_bus_speed(dev, i2c->speed_hz);
> 
> I'm not sure about this one. In principle there should be a value
> i2c->speed_hz even if OF_CONTROL is not used. But I suppose it's OK to
> retain this #ifdef.
> 
>> +#else
>> +   return 0;
>> +#endif
>>  }
>>
>>  static int i2c_post_bind(struct udevice *dev)
>>  {
>> +#if CONFIG_IS_ENABLED(OF_CONTROL)
>> /* Scan the bus for devices */
>> return dm_scan_fdt_node(dev, gd->fdt_blob, dev->of_offset, false);
>> +#else
>> +   return 0;
>> +#endif
>>  }
>>
>>  static int i2c_child_post_bind(struct udevice *dev)
>>  {
>> +#if CONFIG_IS_ENABLED(OF_CONTROL)
>> struct dm_i2c_chip *plat = dev_get_parent_platdata(dev);
>>
>> if (dev->of_offset == -1)
>> return 0;
>>
>> return i2c_chip_ofdata_to_platdata(gd->fdt_blob, dev->of_offset, 
>> plat);
>> +#else
>> +   return 0;
>> +#endif
>>  }
>>
>>  UCLASS_DRIVER(i2c) = {
>> --
>> 2.9.1.200.gb1ec08f
>>
> 
> Regards,
> Simon
> 

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


[U-Boot] [PATCH 14/14] defconfig: am57xx_hs_evm: enable i2c driver model

2016-07-18 Thread Mugunthan V N
Enable i2c driver model for am57xx_hs_evm as omap i2c
supports driver model.

Signed-off-by: Mugunthan V N <mugunthan...@ti.com>
---
 configs/am57xx_hs_evm_defconfig | 1 +
 1 file changed, 1 insertion(+)

diff --git a/configs/am57xx_hs_evm_defconfig b/configs/am57xx_hs_evm_defconfig
index 01a4701..2ccb332 100644
--- a/configs/am57xx_hs_evm_defconfig
+++ b/configs/am57xx_hs_evm_defconfig
@@ -42,3 +42,4 @@ CONFIG_SPL_OF_LIBFDT=y
 CONFIG_SPL_LOAD_FIT=y
 CONFIG_SPL_FIT_IMAGE_POST_PROCESS=y
 CONFIG_OF_LIST="am57xx-beagle-x15"
+CONFIG_DM_I2C=y
-- 
2.9.1.200.gb1ec08f

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


[U-Boot] [PATCH 10/14] defconfig: am43xx_hs_evm: enable i2c driver model

2016-07-18 Thread Mugunthan V N
Enable i2c driver model for am43xx_hs_evm as omap i2c
supports driver model.

Signed-off-by: Mugunthan V N <mugunthan...@ti.com>
---
 configs/am43xx_hs_evm_defconfig | 1 +
 1 file changed, 1 insertion(+)

diff --git a/configs/am43xx_hs_evm_defconfig b/configs/am43xx_hs_evm_defconfig
index 68dfb6c..c8ce723 100644
--- a/configs/am43xx_hs_evm_defconfig
+++ b/configs/am43xx_hs_evm_defconfig
@@ -58,3 +58,4 @@ CONFIG_G_DNL_MANUFACTURER="Texas Instruments"
 CONFIG_G_DNL_VENDOR_NUM=0x0403
 CONFIG_G_DNL_PRODUCT_NUM=0xbd00
 CONFIG_SPL_OF_LIBFDT=y
+CONFIG_DM_I2C=y
-- 
2.9.1.200.gb1ec08f

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


[U-Boot] [PATCH 13/14] defconfig: am57xx_evm: enable i2c driver model

2016-07-18 Thread Mugunthan V N
Enable i2c driver model for am57xx_evm as omap i2c
supports driver model.

Signed-off-by: Mugunthan V N <mugunthan...@ti.com>
---
 configs/am57xx_evm_defconfig | 1 +
 1 file changed, 1 insertion(+)

diff --git a/configs/am57xx_evm_defconfig b/configs/am57xx_evm_defconfig
index c29a05a..8a8a4c9 100644
--- a/configs/am57xx_evm_defconfig
+++ b/configs/am57xx_evm_defconfig
@@ -40,3 +40,4 @@ CONFIG_FIT=y
 CONFIG_SPL_OF_LIBFDT=y
 CONFIG_SPL_LOAD_FIT=y
 CONFIG_OF_LIST="am57xx-beagle-x15 am572x-idk"
+CONFIG_DM_I2C=y
-- 
2.9.1.200.gb1ec08f

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


[U-Boot] [PATCH 12/14] defconfig: dra7xx_hs_evm: enable i2c driver model

2016-07-18 Thread Mugunthan V N
Enable i2c driver model for dra7xx_hs_evm as omap i2c
supports driver model.

Signed-off-by: Mugunthan V N <mugunthan...@ti.com>
---
 configs/dra7xx_hs_evm_defconfig | 1 +
 1 file changed, 1 insertion(+)

diff --git a/configs/dra7xx_hs_evm_defconfig b/configs/dra7xx_hs_evm_defconfig
index eb01f41..faf9cd5 100644
--- a/configs/dra7xx_hs_evm_defconfig
+++ b/configs/dra7xx_hs_evm_defconfig
@@ -60,3 +60,4 @@ CONFIG_SPL_OF_LIBFDT=y
 CONFIG_SPL_LOAD_FIT=y
 CONFIG_SPL_FIT_IMAGE_POST_PROCESS=y
 CONFIG_OF_LIST="dra7-evm dra72-evm"
+CONFIG_DM_I2C=y
-- 
2.9.1.200.gb1ec08f

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


[U-Boot] [PATCH 11/14] defconfig: dra7xx_evm: enable i2c driver model

2016-07-18 Thread Mugunthan V N
Enable i2c driver model for dra7xx_evm as omap i2c
supports driver model.

Signed-off-by: Mugunthan V N <mugunthan...@ti.com>
---
 configs/dra7xx_evm_defconfig | 1 +
 1 file changed, 1 insertion(+)

diff --git a/configs/dra7xx_evm_defconfig b/configs/dra7xx_evm_defconfig
index 756af63..1d27e52 100644
--- a/configs/dra7xx_evm_defconfig
+++ b/configs/dra7xx_evm_defconfig
@@ -57,3 +57,4 @@ CONFIG_FIT=y
 CONFIG_SPL_OF_LIBFDT=y
 CONFIG_SPL_LOAD_FIT=y
 CONFIG_OF_LIST="dra7-evm dra72-evm"
+CONFIG_DM_I2C=y
-- 
2.9.1.200.gb1ec08f

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


[U-Boot] [PATCH 09/14] defconfig: am43xx_evm: enable i2c driver model

2016-07-18 Thread Mugunthan V N
Enable i2c driver model for am43xx_evm as omap i2c
supports driver model.

Signed-off-by: Mugunthan V N <mugunthan...@ti.com>
---
 configs/am43xx_evm_defconfig | 1 +
 1 file changed, 1 insertion(+)

diff --git a/configs/am43xx_evm_defconfig b/configs/am43xx_evm_defconfig
index cb3de11..0eab4ad 100644
--- a/configs/am43xx_evm_defconfig
+++ b/configs/am43xx_evm_defconfig
@@ -54,3 +54,4 @@ CONFIG_G_DNL_MANUFACTURER="Texas Instruments"
 CONFIG_G_DNL_VENDOR_NUM=0x0403
 CONFIG_G_DNL_PRODUCT_NUM=0xbd00
 CONFIG_SPL_OF_LIBFDT=y
+CONFIG_DM_I2C=y
-- 
2.9.1.200.gb1ec08f

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


[U-Boot] [PATCH 08/14] defconfig: am335x_evm: enable i2c driver model

2016-07-18 Thread Mugunthan V N
Enable i2c driver model for am335x_evm as omap i2c
supports driver model.

Signed-off-by: Mugunthan V N <mugunthan...@ti.com>
---
 configs/am335x_evm_defconfig | 1 +
 1 file changed, 1 insertion(+)

diff --git a/configs/am335x_evm_defconfig b/configs/am335x_evm_defconfig
index 696024c..6885230 100644
--- a/configs/am335x_evm_defconfig
+++ b/configs/am335x_evm_defconfig
@@ -49,3 +49,4 @@ CONFIG_FIT=y
 CONFIG_SPL_OF_LIBFDT=y
 CONFIG_SPL_LOAD_FIT=y
 CONFIG_OF_LIST="am335x-evm am335x-bone am335x-boneblack am335x-evmsk 
am335x-bonegreen am335x-icev2"
+CONFIG_DM_I2C=y
-- 
2.9.1.200.gb1ec08f

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


[U-Boot] [PATCH 07/14] defconfig: am335x_boneblack_vboot: enable i2c driver model

2016-07-18 Thread Mugunthan V N
Enable i2c driver model for am335x_boneblack_vboot as omap i2c
supports driver model. Also enable CONFIG_DM_I2C_COMPAT for
legacy drivers of i2c devices.

Signed-off-by: Mugunthan V N <mugunthan...@ti.com>
---
 configs/am335x_boneblack_vboot_defconfig | 1 +
 include/configs/ti_armv7_common.h| 8 
 2 files changed, 9 insertions(+)

diff --git a/configs/am335x_boneblack_vboot_defconfig 
b/configs/am335x_boneblack_vboot_defconfig
index 903f518..c2f09cb 100644
--- a/configs/am335x_boneblack_vboot_defconfig
+++ b/configs/am335x_boneblack_vboot_defconfig
@@ -49,3 +49,4 @@ CONFIG_USB_GADGET_DOWNLOAD=y
 CONFIG_G_DNL_MANUFACTURER="Texas Instruments"
 CONFIG_G_DNL_VENDOR_NUM=0x0451
 CONFIG_G_DNL_PRODUCT_NUM=0xd022
+CONFIG_DM_I2C=y
diff --git a/include/configs/ti_armv7_common.h 
b/include/configs/ti_armv7_common.h
index b996f35..9f947ee 100644
--- a/include/configs/ti_armv7_common.h
+++ b/include/configs/ti_armv7_common.h
@@ -118,7 +118,15 @@
 
 /* I2C IP block */
 #define CONFIG_I2C
+#ifndef CONFIG_DM_I2C
 #define CONFIG_SYS_I2C
+#else
+/*
+ * Enable CONFIG_DM_I2C_COMPAT temporarily until all the i2c client
+ * devices are adopted to DM
+ */
+#define CONFIG_DM_I2C_COMPAT
+#endif
 
 /* MMC/SD IP block */
 #define CONFIG_MMC
-- 
2.9.1.200.gb1ec08f

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


[U-Boot] [PATCH 06/14] drivers: i2c: omap24xx_i2c: adopt omap_i2c driver to driver model

2016-07-18 Thread Mugunthan V N
Convert omap i2c driver to adopt i2c driver model

Signed-off-by: Mugunthan V N <mugunthan...@ti.com>
---
 drivers/i2c/omap24xx_i2c.c | 99 ++
 1 file changed, 99 insertions(+)

diff --git a/drivers/i2c/omap24xx_i2c.c b/drivers/i2c/omap24xx_i2c.c
index 8dea5fa..0006343 100644
--- a/drivers/i2c/omap24xx_i2c.c
+++ b/drivers/i2c/omap24xx_i2c.c
@@ -39,6 +39,7 @@
  */
 
 #include 
+#include 
 #include 
 
 #include 
@@ -53,6 +54,14 @@ DECLARE_GLOBAL_DATA_PTR;
 /* Absolutely safe for status update at 100 kHz I2C: */
 #define I2C_WAIT   200
 
+struct omap_i2c {
+   struct udevice *clk;
+   struct i2c *regs;
+   unsigned int speed;
+   int waitdelay;
+   int clk_id;
+};
+
 static int omap24_i2c_findpsc(u32 *pscl, u32 *psch, uint speed)
 {
unsigned int sampleclk, prescaler;
@@ -667,6 +676,7 @@ wr_exit:
return i2c_error;
 }
 
+#ifndef CONFIG_DM_I2C
 /*
  * The legacy I2C functions. These need to get removed once
  * all users of this driver are converted to DM.
@@ -811,3 +821,92 @@ U_BOOT_I2C_ADAP_COMPLETE(omap24_4, omap24_i2c_init, 
omap24_i2c_probe,
 #endif
 #endif
 #endif
+
+#else /* CONFIG_DM_I2C */
+
+static int omap_i2c_xfer(struct udevice *bus, struct i2c_msg *msg, int nmsgs)
+{
+   struct omap_i2c *priv = dev_get_priv(bus);
+   int ret;
+
+   debug("i2c_xfer: %d messages\n", nmsgs);
+   for (; nmsgs > 0; nmsgs--, msg++) {
+   debug("i2c_xfer: chip=0x%x, len=0x%x\n", msg->addr, msg->len);
+   if (msg->flags & I2C_M_RD) {
+   ret = __omap24_i2c_read(priv->regs, priv->waitdelay,
+   msg->addr, 0, 0, msg->buf,
+   msg->len);
+   } else {
+   ret = __omap24_i2c_write(priv->regs, priv->waitdelay,
+msg->addr, 0, 0, msg->buf,
+msg->len);
+   }
+   if (ret) {
+   debug("i2c_write: error sending\n");
+   return -EREMOTEIO;
+   }
+   }
+
+   return 0;
+}
+
+static int omap_i2c_set_bus_speed(struct udevice *bus, unsigned int speed)
+{
+   struct omap_i2c *priv = dev_get_priv(bus);
+
+   priv->speed = speed;
+
+   return __omap24_i2c_setspeed(priv->regs, speed, >waitdelay);
+}
+
+static int omap_i2c_probe_chip(struct udevice *bus, uint chip_addr,
+uint chip_flags)
+{
+   struct omap_i2c *priv = dev_get_priv(bus);
+
+   return __omap24_i2c_probe(priv->regs, priv->waitdelay, chip_addr);
+}
+
+static int omap_i2c_probe(struct udevice *bus)
+{
+   struct omap_i2c *priv = dev_get_priv(bus);
+
+   __omap24_i2c_init(priv->regs, priv->speed, 0, >waitdelay);
+
+   return 0;
+}
+
+static int omap_i2c_ofdata_to_platdata(struct udevice *bus)
+{
+   struct omap_i2c *priv = dev_get_priv(bus);
+
+   priv->regs = map_physmem(dev_get_addr(bus), sizeof(void *),
+MAP_NOCACHE);
+   priv->speed = CONFIG_SYS_OMAP24_I2C_SPEED;
+
+   return 0;
+}
+
+static const struct dm_i2c_ops omap_i2c_ops = {
+   .xfer   = omap_i2c_xfer,
+   .probe_chip = omap_i2c_probe_chip,
+   .set_bus_speed  = omap_i2c_set_bus_speed,
+};
+
+static const struct udevice_id omap_i2c_ids[] = {
+   { .compatible = "ti,omap4-i2c" },
+   { }
+};
+
+U_BOOT_DRIVER(i2c_omap) = {
+   .name   = "i2c_omap",
+   .id = UCLASS_I2C,
+   .of_match = omap_i2c_ids,
+   .ofdata_to_platdata = omap_i2c_ofdata_to_platdata,
+   .probe  = omap_i2c_probe,
+   .priv_auto_alloc_size = sizeof(struct omap_i2c),
+   .ops= _i2c_ops,
+   .flags  = DM_FLAG_PRE_RELOC,
+};
+
+#endif /* CONFIG_DM_I2C */
-- 
2.9.1.200.gb1ec08f

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


[U-Boot] [PATCH 02/14] omap5/dra7: i2c: correct register offset for sync register

2016-07-18 Thread Mugunthan V N
The register offset of i2c_sysc offset is not correct as per
omap5[1]/dra7[2] TRM, correct the offsets as per the
documentation.

[1] - http://www.ti.com/lit/pdf/swpu249
[2] - http://www.ti.com/lit/pdf/spruhz6

Signed-off-by: Mugunthan V N <mugunthan...@ti.com>
---
 arch/arm/include/asm/arch-omap5/i2c.h | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/arch/arm/include/asm/arch-omap5/i2c.h 
b/arch/arm/include/asm/arch-omap5/i2c.h
index d875cfe..2b55edf 100644
--- a/arch/arm/include/asm/arch-omap5/i2c.h
+++ b/arch/arm/include/asm/arch-omap5/i2c.h
@@ -14,9 +14,9 @@ struct i2c {
unsigned short revnb_lo;/* 0x00 */
unsigned short res1;
unsigned short revnb_hi;/* 0x04 */
-   unsigned short res2[13];
-   unsigned short sysc;/* 0x20 */
-   unsigned short res3;
+   unsigned short res2[5];
+   unsigned short sysc;/* 0x10 */
+   unsigned short res3[9];
unsigned short irqstatus_raw;   /* 0x24 */
unsigned short res4;
unsigned short stat;/* 0x28 */
-- 
2.9.1.200.gb1ec08f

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


[U-Boot] [PATCH 03/14] drivers: i2c: uclass: parse dt parameters only when CONFIG_OF_CONTROL is enable

2016-07-18 Thread Mugunthan V N
parse dt parameter of i2c devices only when CONFIG_OF_CONTROL
is enabled.

Signed-off-by: Mugunthan V N <mugunthan...@ti.com>
---
 drivers/i2c/i2c-uclass.c | 14 ++
 1 file changed, 14 insertions(+)

diff --git a/drivers/i2c/i2c-uclass.c b/drivers/i2c/i2c-uclass.c
index 50b99ea..20b30ff 100644
--- a/drivers/i2c/i2c-uclass.c
+++ b/drivers/i2c/i2c-uclass.c
@@ -467,6 +467,7 @@ int i2c_deblock(struct udevice *bus)
return ops->deblock(bus);
 }
 
+#if CONFIG_IS_ENABLED(OF_CONTROL)
 int i2c_chip_ofdata_to_platdata(const void *blob, int node,
struct dm_i2c_chip *chip)
 {
@@ -482,31 +483,44 @@ int i2c_chip_ofdata_to_platdata(const void *blob, int 
node,
 
return 0;
 }
+#endif
 
 static int i2c_post_probe(struct udevice *dev)
 {
+#if CONFIG_IS_ENABLED(OF_CONTROL)
struct dm_i2c_bus *i2c = dev_get_uclass_priv(dev);
 
i2c->speed_hz = fdtdec_get_int(gd->fdt_blob, dev->of_offset,
 "clock-frequency", 10);
 
return dm_i2c_set_bus_speed(dev, i2c->speed_hz);
+#else
+   return 0;
+#endif
 }
 
 static int i2c_post_bind(struct udevice *dev)
 {
+#if CONFIG_IS_ENABLED(OF_CONTROL)
/* Scan the bus for devices */
return dm_scan_fdt_node(dev, gd->fdt_blob, dev->of_offset, false);
+#else
+   return 0;
+#endif
 }
 
 static int i2c_child_post_bind(struct udevice *dev)
 {
+#if CONFIG_IS_ENABLED(OF_CONTROL)
struct dm_i2c_chip *plat = dev_get_parent_platdata(dev);
 
if (dev->of_offset == -1)
return 0;
 
return i2c_chip_ofdata_to_platdata(gd->fdt_blob, dev->of_offset, plat);
+#else
+   return 0;
+#endif
 }
 
 UCLASS_DRIVER(i2c) = {
-- 
2.9.1.200.gb1ec08f

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


[U-Boot] [PATCH 04/14] ti_armv7_common: i2c: do not define DM_I2C for spl

2016-07-18 Thread Mugunthan V N
Since omap's spl doesn't support DM currently, do not define
DM_I2C for spl build.

Signed-off-by: Mugunthan V N <mugunthan...@ti.com>
---
 include/configs/ti_armv7_common.h | 8 
 1 file changed, 8 insertions(+)

diff --git a/include/configs/ti_armv7_common.h 
b/include/configs/ti_armv7_common.h
index ba7cf15..b996f35 100644
--- a/include/configs/ti_armv7_common.h
+++ b/include/configs/ti_armv7_common.h
@@ -108,6 +108,14 @@
 /* Timer information. */
 #define CONFIG_SYS_PTV 2   /* Divisor: 2^(PTV+1) => 8 */
 
+/*
+ * Disable DM_* for SPL build and can be re-enabled after adding
+ * DM support in SPL
+ */
+#ifdef CONFIG_SPL_BUILD
+#undef CONFIG_DM_I2C
+#endif
+
 /* I2C IP block */
 #define CONFIG_I2C
 #define CONFIG_SYS_I2C
-- 
2.9.1.200.gb1ec08f

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


[U-Boot] [PATCH 05/14] drivers: i2c: omap24xx_i2c: prepare driver for DM conversion

2016-07-18 Thread Mugunthan V N
Prepare the driver for DM conversion.

Signed-off-by: Mugunthan V N <mugunthan...@ti.com>
---
 drivers/i2c/omap24xx_i2c.c | 308 +
 1 file changed, 175 insertions(+), 133 deletions(-)

diff --git a/drivers/i2c/omap24xx_i2c.c b/drivers/i2c/omap24xx_i2c.c
index a7f3fb4..8dea5fa 100644
--- a/drivers/i2c/omap24xx_i2c.c
+++ b/drivers/i2c/omap24xx_i2c.c
@@ -53,10 +53,6 @@ DECLARE_GLOBAL_DATA_PTR;
 /* Absolutely safe for status update at 100 kHz I2C: */
 #define I2C_WAIT   200
 
-static int wait_for_bb(struct i2c_adapter *adap);
-static struct i2c *omap24_get_base(struct i2c_adapter *adap);
-static u16 wait_for_event(struct i2c_adapter *adap);
-static void flush_fifo(struct i2c_adapter *adap);
 static int omap24_i2c_findpsc(u32 *pscl, u32 *psch, uint speed)
 {
unsigned int sampleclk, prescaler;
@@ -90,9 +86,96 @@ static int omap24_i2c_findpsc(u32 *pscl, u32 *psch, uint 
speed)
}
return -1;
 }
-static uint omap24_i2c_setspeed(struct i2c_adapter *adap, uint speed)
+
+/*
+ * Wait for the bus to be free by checking the Bus Busy (BB)
+ * bit to become clear
+ */
+static int wait_for_bb(struct i2c *i2c_base, int waitdelay)
+{
+   int timeout = I2C_TIMEOUT;
+   u16 stat;
+
+   writew(0x, _base->stat);/* clear current interrupts...*/
+#if defined(CONFIG_OMAP243X) || defined(CONFIG_OMAP34XX)
+   while ((stat = readw(_base->stat) & I2C_STAT_BB) && timeout--) {
+#else
+   /* Read RAW status */
+   while ((stat = readw(_base->irqstatus_raw) &
+   I2C_STAT_BB) && timeout--) {
+#endif
+   writew(stat, _base->stat);
+   udelay(waitdelay);
+   }
+
+   if (timeout <= 0) {
+   printf("Timed out in wait_for_bb: status=%04x\n",
+  stat);
+   return 1;
+   }
+   writew(0x, _base->stat); /* clear delayed stuff*/
+   return 0;
+}
+
+/*
+ * Wait for the I2C controller to complete current action
+ * and update status
+ */
+static u16 wait_for_event(struct i2c *i2c_base, int waitdelay)
+{
+   u16 status;
+   int timeout = I2C_TIMEOUT;
+
+   do {
+   udelay(waitdelay);
+#if defined(CONFIG_OMAP243X) || defined(CONFIG_OMAP34XX)
+   status = readw(_base->stat);
+#else
+   /* Read RAW status */
+   status = readw(_base->irqstatus_raw);
+#endif
+   } while (!(status &
+  (I2C_STAT_ROVR | I2C_STAT_XUDF | I2C_STAT_XRDY |
+   I2C_STAT_RRDY | I2C_STAT_ARDY | I2C_STAT_NACK |
+   I2C_STAT_AL)) && timeout--);
+
+   if (timeout <= 0) {
+   printf("Timed out in wait_for_event: status=%04x\n",
+  status);
+   /*
+* If status is still 0 here, probably the bus pads have
+* not been configured for I2C, and/or pull-ups are missing.
+*/
+   printf("Check if pads/pull-ups of bus are properly 
configured\n");
+   writew(0x, _base->stat);
+   status = 0;
+   }
+
+   return status;
+}
+
+static void flush_fifo(struct i2c *i2c_base)
+{
+   u16 stat;
+
+   /*
+* note: if you try and read data when its not there or ready
+* you get a bus error
+*/
+   while (1) {
+   stat = readw(_base->stat);
+   if (stat == I2C_STAT_RRDY) {
+   readb(_base->data);
+   writew(I2C_STAT_RRDY, _base->stat);
+   udelay(1000);
+   } else
+   break;
+   }
+}
+
+static int __omap24_i2c_setspeed(struct i2c *i2c_base, uint speed,
+int *waitdelay)
 {
-   struct i2c *i2c_base = omap24_get_base(adap);
int psc, fsscll = 0, fssclh = 0;
int hsscll = 0, hssclh = 0;
u32 scll = 0, sclh = 0;
@@ -142,8 +225,7 @@ static uint omap24_i2c_setspeed(struct i2c_adapter *adap, 
uint speed)
}
}
 
-   adap->speed = speed;
-   adap->waitdelay = (1000 / speed) * 2; /* wait for 20 clkperiods */
+   *waitdelay = (1000 / speed) * 2; /* wait for 20 clkperiods */
writew(0, _base->con);
writew(psc, _base->psc);
writew(scll, _base->scll);
@@ -154,9 +236,8 @@ static uint omap24_i2c_setspeed(struct i2c_adapter *adap, 
uint speed)
return 0;
 }
 
-static void omap24_i2c_deblock(struct i2c_adapter *adap)
+static void omap24_i2c_deblock(struct i2c *i2c_base)
 {
-   struct i2c *i2c_base = omap24_get_base(adap);
int i;
u16 systest;
u16 orgsystest;
@@ -200,9 +281,9 @@ static void omap24_i2c_deblock(struct i2c_adapter *adap)
writew(orgsystest, _base->systest);
 }
 
-static void omap24_i2c_ini

[U-Boot] [PATCH 01/14] omap4: i2c: correct register offset for sync register

2016-07-18 Thread Mugunthan V N
The register offset of i2c_sysc offset is not correct as per
omap4 TRM [1], correct the offsets as per the documentation.

[1] - http://www.ti.com/lit/ug/swpu235ab/swpu235ab.pdf

Signed-off-by: Mugunthan V N <mugunthan...@ti.com>
---
 arch/arm/include/asm/arch-omap4/i2c.h | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/arch/arm/include/asm/arch-omap4/i2c.h 
b/arch/arm/include/asm/arch-omap4/i2c.h
index adc8eb2..463e979 100644
--- a/arch/arm/include/asm/arch-omap4/i2c.h
+++ b/arch/arm/include/asm/arch-omap4/i2c.h
@@ -14,9 +14,9 @@ struct i2c {
unsigned short revnb_lo;/* 0x00 */
unsigned short res1;
unsigned short revnb_hi;/* 0x04 */
-   unsigned short res2[13];
-   unsigned short sysc;/* 0x20 */
-   unsigned short res3;
+   unsigned short res2[5];
+   unsigned short sysc;/* 0x10 */
+   unsigned short res3[9];
unsigned short irqstatus_raw;   /* 0x24 */
unsigned short res4;
unsigned short stat;/* 0x28 */
-- 
2.9.1.200.gb1ec08f

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


  1   2   3   4   5   6   7   >