[PATCH v3 0/8] Equivalent of g_ncm.ko with configfs

2013-05-15 Thread Andrzej Pietrasiewicz
Here I present the conversion of everthing that is required to provide
the equivalent of g_ncm.ko with configfs.

This is the second version of the series after discussion with Alan
and Michal's review - thank you guys.

A branch will be available here (from 24th April 2013):
git://git.infradead.org/users/kmpark/linux-samsung usb-gadget-configfs

v2..v3:

- fixed a bug resulting from the delayed registration of a network interface
  (should be registered only once)

v1..v2:

- delayed registering a network interface until gadgets's bind
  (per Alan's request)
- created a helper macro to define USB Ethernet modules' parameters (Michal's
  review)
- fixed and simplified some helper functions (Michal's review)
- changed hostaddr variable name to host_mac in several modules
  (Michal's review)


BACKWARD COMPATIBILITY
==

Please note that the old g_ncm.ko is still available and works.


USING THE NEW "GADGET"
==

Please refer to this post:

http://www.spinics.net/lists/linux-usb/msg76388.html

for general information from Sebastian on how to use configfs-based
gadgets (*).

Here is the description specific to using g_ncm.ko equivalent.

The old g_ncm.ko offered three parameters:

qmult  - queue length multiplier for high/super -speed devices
dev_addr   - device's MAC address
host_addr  - host's MAC address

With configfs the procedure is as follows, compared to the information
mentioned above (*):

instead of mkdir functions/acm.ttyS1 do

mkdir functions/ncm.

e.g. mkdir functions/ncm.usb0

In functions/ncm. there will be the following attribute files:

qmult
dev_addr
host_addr
ifname

and after creating the functions/ncm. they contain default
values: qmult is 5, dev_addr and host_addr are randomly selected.
Except for ifname they can be written to until the function is linked to a
configuration. The ifname is read-only and contains the name of the interface
which was assigned by the net core, e. g. usb0.

The rest of the procedure (*) remains the same.

After unbinding the gadget with echo "" > UDC
the symbolic links in the configuration directory can be removed,
the strings/* subdirectories in the configuration directory can
be removed, the strings/* subdirectories at the gadget level can
be removed and the configs/* subdirectories can be removed.
The functions/* subdirectories can be removed.
After that the gadget directory can be removed.
After that the respective modules can be unloaded.


TESTING THE FUNCTIONS (actually there is just one)
==

ncm)

On the device: ping 
On the host: ping 


Andrzej Pietrasiewicz (8):
  usb/gadget: u_ether: convert into module
  usb/gadget: rndis: convert into module
  usb/gadget: u_ether: construct with default values and add
setters/getters
  usb/gadget: f_ncm: convert to new function interface with backward
compatibility
  usb/gadget: ncm: convert to new function interface
  usb/gadget: f_ncm: remove compatibility layer
  usb/gadget: f_ncm: use usb_gstrings_attach
  usb/gadget: f_ncm: add configfs support

 drivers/usb/gadget/Kconfig   |   20 +++
 drivers/usb/gadget/Makefile  |5 +
 drivers/usb/gadget/cdc2.c|   10 +-
 drivers/usb/gadget/ether.c   |   18 ++-
 drivers/usb/gadget/f_ncm.c   |  333 +
 drivers/usb/gadget/g_ffs.c   |   15 +-
 drivers/usb/gadget/multi.c   |   15 +-
 drivers/usb/gadget/ncm.c |   58 +---
 drivers/usb/gadget/nokia.c   |   11 +-
 drivers/usb/gadget/rndis.c   |   16 ++
 drivers/usb/gadget/rndis.h   |1 +
 drivers/usb/gadget/u_ether.c |  223 +---
 drivers/usb/gadget/u_ether.h |  155 +++-
 drivers/usb/gadget/u_ncm.h   |   36 +
 14 files changed, 776 insertions(+), 140 deletions(-)
 create mode 100644 drivers/usb/gadget/u_ncm.h

--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH v3 2/8] usb/gadget: rndis: convert into module

2013-05-15 Thread Andrzej Pietrasiewicz
In order to convert to configfs the usb functions need to be converted
to a new interface and compiled as modules. This patch creates an rndis
module which will be used by the new functions. After all users of
f_rndis are converted to the new interface, this module can be
merged with f_rndis module.

Signed-off-by: Andrzej Pietrasiewicz 
Signed-off-by: Kyungmin Park 
Acked-by: Michal Nazarewicz 
---
 drivers/usb/gadget/Kconfig  |6 ++
 drivers/usb/gadget/Makefile |2 ++
 drivers/usb/gadget/ether.c  |4 +++-
 drivers/usb/gadget/g_ffs.c  |2 +-
 drivers/usb/gadget/multi.c  |2 +-
 drivers/usb/gadget/rndis.c  |   16 
 drivers/usb/gadget/rndis.h  |1 +
 7 files changed, 30 insertions(+), 3 deletions(-)

diff --git a/drivers/usb/gadget/Kconfig b/drivers/usb/gadget/Kconfig
index 9152428..91b6eab 100644
--- a/drivers/usb/gadget/Kconfig
+++ b/drivers/usb/gadget/Kconfig
@@ -554,6 +554,9 @@ config USB_U_SERIAL
 config USB_U_ETHER
tristate
 
+config USB_U_RNDIS
+   tristate
+
 config USB_F_SERIAL
tristate
 
@@ -651,6 +654,7 @@ config USB_ETH
depends on NET
select USB_LIBCOMPOSITE
select USB_U_ETHER
+   select USB_U_RNDIS
select CRC32
help
  This driver implements Ethernet style communication, in one of
@@ -776,6 +780,7 @@ config USB_FUNCTIONFS_RNDIS
bool "Include configuration with RNDIS (Ethernet)"
depends on USB_FUNCTIONFS && NET
select USB_U_ETHER
+   select USB_U_RNDIS
help
  Include a configuration with RNDIS function (Ethernet) and the 
Filesystem.
 
@@ -923,6 +928,7 @@ config USB_G_MULTI
select USB_LIBCOMPOSITE
select USB_U_SERIAL
select USB_U_ETHER
+   select USB_U_RNDIS
select USB_F_ACM
help
  The Multifunction Composite Gadget provides Ethernet (RNDIS
diff --git a/drivers/usb/gadget/Makefile b/drivers/usb/gadget/Makefile
index 061abec..3f51952 100644
--- a/drivers/usb/gadget/Makefile
+++ b/drivers/usb/gadget/Makefile
@@ -47,6 +47,8 @@ obj-$(CONFIG_USB_F_SERIAL)+= usb_f_serial.o
 usb_f_obex-y   := f_obex.o
 obj-$(CONFIG_USB_F_OBEX)   += usb_f_obex.o
 obj-$(CONFIG_USB_U_ETHER)  += u_ether.o
+u_rndis-y  := rndis.o
+obj-$(CONFIG_USB_U_RNDIS)  += u_rndis.o
 
 #
 # USB gadget drivers
diff --git a/drivers/usb/gadget/ether.c b/drivers/usb/gadget/ether.c
index 75418c7..6bff24f 100644
--- a/drivers/usb/gadget/ether.c
+++ b/drivers/usb/gadget/ether.c
@@ -91,6 +91,8 @@ static inline bool has_rndis(void)
 #endif
 }
 
+#include 
+
 /*-*/
 
 /*
@@ -104,7 +106,7 @@ static inline bool has_rndis(void)
 #include "f_subset.c"
 #ifdef USB_ETH_RNDIS
 #include "f_rndis.c"
-#include "rndis.c"
+#include "rndis.h"
 #endif
 #include "f_eem.c"
 
diff --git a/drivers/usb/gadget/g_ffs.c b/drivers/usb/gadget/g_ffs.c
index 45f26be..fbfdb53 100644
--- a/drivers/usb/gadget/g_ffs.c
+++ b/drivers/usb/gadget/g_ffs.c
@@ -32,7 +32,7 @@
 #  include "f_subset.c"
 #  ifdef USB_ETH_RNDIS
 #include "f_rndis.c"
-#include "rndis.c"
+#include "rndis.h"
 #  endif
 #  include "u_ether.h"
 
diff --git a/drivers/usb/gadget/multi.c b/drivers/usb/gadget/multi.c
index d0dd603..b8222c4 100644
--- a/drivers/usb/gadget/multi.c
+++ b/drivers/usb/gadget/multi.c
@@ -47,7 +47,7 @@ MODULE_LICENSE("GPL");
 #include "f_subset.c"
 #ifdef USB_ETH_RNDIS
 #  include "f_rndis.c"
-#  include "rndis.c"
+#  include "rndis.h"
 #endif
 #include "u_ether.h"
 
diff --git a/drivers/usb/gadget/rndis.c b/drivers/usb/gadget/rndis.c
index d9297ee..1ce6bae 100644
--- a/drivers/usb/gadget/rndis.c
+++ b/drivers/usb/gadget/rndis.c
@@ -761,6 +761,7 @@ int rndis_signal_connect(int configNr)
return rndis_indicate_status_msg(configNr,
  RNDIS_STATUS_MEDIA_CONNECT);
 }
+EXPORT_SYMBOL(rndis_signal_connect);
 
 int rndis_signal_disconnect(int configNr)
 {
@@ -769,6 +770,7 @@ int rndis_signal_disconnect(int configNr)
return rndis_indicate_status_msg(configNr,
  RNDIS_STATUS_MEDIA_DISCONNECT);
 }
+EXPORT_SYMBOL(rndis_signal_disconnect);
 
 void rndis_uninit(int configNr)
 {
@@ -783,11 +785,13 @@ void rndis_uninit(int configNr)
while ((buf = rndis_get_next_response(configNr, &length)))
rndis_free_response(configNr, buf);
 }
+EXPORT_SYMBOL(rndis_uninit);
 
 void rndis_set_host_mac(int configNr, const u8 *addr)
 {
rndis_per_dev_params[configNr].host_mac = addr;
 }
+EXPORT_SYMBOL(rndis_set_host_mac);
 
 /*
  * Message Parser
@@ -870,6 +874,7 @@ int rndis_msg_parser(u8 configNr, u8 *buf)
 
return -ENOTSUPP;
 }
+EXPORT_SYMBOL(rndis_msg_parser);
 
 int rndis_register(void (*resp_avail)(void *v), void *v)
 {
@@ -891,6 +896,7 @@ int rndis_register(void (*resp_avail)(void *v), void *v)
 
return -ENODEV;
 }
+EXPORT_SYMBOL(rndis_regis

[PATCH v3 5/8] usb/gadget: ncm: convert to new function interface

2013-05-15 Thread Andrzej Pietrasiewicz
Signed-off-by: Andrzej Pietrasiewicz 
Signed-off-by: Kyungmin Park 
---
 drivers/usb/gadget/Kconfig |1 +
 drivers/usb/gadget/ncm.c   |   57 +++-
 2 files changed, 36 insertions(+), 22 deletions(-)

diff --git a/drivers/usb/gadget/Kconfig b/drivers/usb/gadget/Kconfig
index 59908b0..629b7bb 100644
--- a/drivers/usb/gadget/Kconfig
+++ b/drivers/usb/gadget/Kconfig
@@ -731,6 +731,7 @@ config USB_G_NCM
depends on NET
select USB_LIBCOMPOSITE
select USB_U_ETHER
+   select USB_F_NCM
select CRC32
help
  This driver implements USB CDC NCM subclass standard. NCM is
diff --git a/drivers/usb/gadget/ncm.c b/drivers/usb/gadget/ncm.c
index e2f97ee..81956fe 100644
--- a/drivers/usb/gadget/ncm.c
+++ b/drivers/usb/gadget/ncm.c
@@ -24,23 +24,12 @@
 #include 
 
 #include "u_ether.h"
+#include "u_ncm.h"
 
 #define DRIVER_DESC"NCM Gadget"
 
 /*-*/
 
-/*
- * Kbuild is not very cooperative with respect to linking separately
- * compiled library objects into one module.  So for now we won't use
- * separate compilation ... ensuring init/exit sections work to shrink
- * the runtime footprint, and giving us at least some parts of what
- * a "gcc --combine ... part1.c part2.c part3.c ... " build would.
- */
-#define USB_FNCM_INCLUDED
-#include "f_ncm.c"
-
-/*-*/
-
 /* DO NOT REUSE THESE IDs with a protocol-incompatible driver!!  Ever!!
  * Instead:  allocate your own, using normal USB-IF procedures.
  */
@@ -113,13 +102,15 @@ static struct usb_gadget_strings *dev_strings[] = {
NULL,
 };
 
-struct eth_dev *the_dev;
-static u8 host_mac[ETH_ALEN];
+static struct usb_function_instance *f_ncm_inst;
+static struct usb_function *f_ncm;
 
 /*-*/
 
 static int __init ncm_do_config(struct usb_configuration *c)
 {
+   int status;
+
/* FIXME alloc iConfiguration string, set it in c->strings */
 
if (gadget_is_otg(c->cdev->gadget)) {
@@ -127,7 +118,19 @@ static int __init ncm_do_config(struct usb_configuration 
*c)
c->bmAttributes |= USB_CONFIG_ATT_WAKEUP;
}
 
-   return ncm_bind_config(c, host_mac, the_dev);
+   f_ncm = usb_get_function(f_ncm_inst);
+   if (IS_ERR(f_ncm)) {
+   status = PTR_ERR(f_ncm);
+   return status;
+   }
+
+   status = usb_add_function(c, f_ncm);
+   if (status < 0) {
+   usb_put_function(f_ncm);
+   return status;
+   }
+
+   return 0;
 }
 
 static struct usb_configuration ncm_config_driver = {
@@ -143,13 +146,20 @@ static struct usb_configuration ncm_config_driver = {
 static int __init gncm_bind(struct usb_composite_dev *cdev)
 {
struct usb_gadget   *gadget = cdev->gadget;
+   struct f_ncm_opts   *ncm_opts;
int status;
 
-   /* set up network link layer */
-   the_dev = gether_setup(cdev->gadget, dev_addr, host_addr, host_mac,
-  qmult);
-   if (IS_ERR(the_dev))
-   return PTR_ERR(the_dev);
+   f_ncm_inst = usb_get_function_instance("ncm");
+   if (IS_ERR(f_ncm_inst))
+   return PTR_ERR(f_ncm_inst);
+
+   ncm_opts = container_of(f_ncm_inst, struct f_ncm_opts, func_inst);
+
+   gether_set_qmult(ncm_opts->net, qmult);
+   if (!gether_set_host_addr(ncm_opts->net, host_addr))
+   pr_info("using host ethernet address: %s", host_addr);
+   if (!gether_set_dev_addr(ncm_opts->net, dev_addr))
+   pr_info("using self ethernet address: %s", dev_addr);
 
/* Allocate string descriptor numbers ... note that string
 * contents can be overridden by the composite_dev glue.
@@ -172,13 +182,16 @@ static int __init gncm_bind(struct usb_composite_dev 
*cdev)
return 0;
 
 fail:
-   gether_cleanup(the_dev);
+   usb_put_function_instance(f_ncm_inst);
return status;
 }
 
 static int __exit gncm_unbind(struct usb_composite_dev *cdev)
 {
-   gether_cleanup(the_dev);
+   if (!IS_ERR_OR_NULL(f_ncm))
+   usb_put_function(f_ncm);
+   if (!IS_ERR_OR_NULL(f_ncm_inst))
+   usb_put_function_instance(f_ncm_inst);
return 0;
 }
 
-- 
1.7.0.4

--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH v3 1/8] usb/gadget: u_ether: convert into module

2013-05-15 Thread Andrzej Pietrasiewicz
u_ether.c has been #include'd by all gadgets which implement
USB Ethernet functions. In order to add configfs support,
the f_ecm.c, f_eem.c, f_ncm.c, f_subset.c, f_rndis.c need to be
converted into modules and must not be #include'd. Consequently,
the u_ether.c needs to be a module too, in a manner similar
to u_serial.c. The resulting module should not take any parameters,
so they are pushed to the current users of it, that is ether.c,
g_ffs.c, multi.c, ncm.c, nokia.c.

Signed-off-by: Andrzej Pietrasiewicz 
Signed-off-by: Kyungmin Park 
---
 drivers/usb/gadget/Kconfig   |   10 ++
 drivers/usb/gadget/Makefile  |1 +
 drivers/usb/gadget/cdc2.c|   10 ++
 drivers/usb/gadget/ether.c   |   14 --
 drivers/usb/gadget/g_ffs.c   |   13 -
 drivers/usb/gadget/multi.c   |   13 -
 drivers/usb/gadget/ncm.c |   10 ++
 drivers/usb/gadget/nokia.c   |   11 +++
 drivers/usb/gadget/u_ether.c |   38 ++
 drivers/usb/gadget/u_ether.h |   30 ++
 10 files changed, 98 insertions(+), 52 deletions(-)

diff --git a/drivers/usb/gadget/Kconfig b/drivers/usb/gadget/Kconfig
index 3ddebff..9152428 100644
--- a/drivers/usb/gadget/Kconfig
+++ b/drivers/usb/gadget/Kconfig
@@ -551,6 +551,9 @@ config USB_F_SS_LB
 config USB_U_SERIAL
tristate
 
+config USB_U_ETHER
+   tristate
+
 config USB_F_SERIAL
tristate
 
@@ -647,6 +650,7 @@ config USB_ETH
tristate "Ethernet Gadget (with CDC Ethernet support)"
depends on NET
select USB_LIBCOMPOSITE
+   select USB_U_ETHER
select CRC32
help
  This driver implements Ethernet style communication, in one of
@@ -719,6 +723,7 @@ config USB_G_NCM
tristate "Network Control Model (NCM) support"
depends on NET
select USB_LIBCOMPOSITE
+   select USB_U_ETHER
select CRC32
help
  This driver implements USB CDC NCM subclass standard. NCM is
@@ -762,6 +767,7 @@ config USB_FUNCTIONFS
 config USB_FUNCTIONFS_ETH
bool "Include configuration with CDC ECM (Ethernet)"
depends on USB_FUNCTIONFS && NET
+   select USB_U_ETHER
help
  Include a configuration with CDC ECM function (Ethernet) and the
  Function Filesystem.
@@ -769,6 +775,7 @@ config USB_FUNCTIONFS_ETH
 config USB_FUNCTIONFS_RNDIS
bool "Include configuration with RNDIS (Ethernet)"
depends on USB_FUNCTIONFS && NET
+   select USB_U_ETHER
help
  Include a configuration with RNDIS function (Ethernet) and the 
Filesystem.
 
@@ -869,6 +876,7 @@ config USB_CDC_COMPOSITE
depends on NET
select USB_LIBCOMPOSITE
select USB_U_SERIAL
+   select USB_U_ETHER
select USB_F_ACM
help
  This driver provides two functions in one configuration:
@@ -886,6 +894,7 @@ config USB_G_NOKIA
depends on PHONET
select USB_LIBCOMPOSITE
select USB_U_SERIAL
+   select USB_U_ETHER
select USB_F_ACM
help
  The Nokia composite gadget provides support for acm, obex
@@ -913,6 +922,7 @@ config USB_G_MULTI
select USB_G_MULTI_CDC if !USB_G_MULTI_RNDIS
select USB_LIBCOMPOSITE
select USB_U_SERIAL
+   select USB_U_ETHER
select USB_F_ACM
help
  The Multifunction Composite Gadget provides Ethernet (RNDIS
diff --git a/drivers/usb/gadget/Makefile b/drivers/usb/gadget/Makefile
index 2e102ff..061abec 100644
--- a/drivers/usb/gadget/Makefile
+++ b/drivers/usb/gadget/Makefile
@@ -46,6 +46,7 @@ usb_f_serial-y:= f_serial.o
 obj-$(CONFIG_USB_F_SERIAL) += usb_f_serial.o
 usb_f_obex-y   := f_obex.o
 obj-$(CONFIG_USB_F_OBEX)   += usb_f_obex.o
+obj-$(CONFIG_USB_U_ETHER)  += u_ether.o
 
 #
 # USB gadget drivers
diff --git a/drivers/usb/gadget/cdc2.c b/drivers/usb/gadget/cdc2.c
index c6ee6f1..07b3aaf 100644
--- a/drivers/usb/gadget/cdc2.c
+++ b/drivers/usb/gadget/cdc2.c
@@ -35,6 +35,8 @@
 /*-*/
 USB_GADGET_COMPOSITE_OPTIONS();
 
+USB_ETHERNET_MODULE_PARAMETERS();
+
 /*
  * Kbuild is not very cooperative with respect to linking separately
  * compiled library objects into one module.  So for now we won't use
@@ -43,7 +45,6 @@ USB_GADGET_COMPOSITE_OPTIONS();
  * a "gcc --combine ... part1.c part2.c part3.c ... " build would.
  */
 #include "f_ecm.c"
-#include "u_ether.c"
 
 /*-*/
 
@@ -102,7 +103,7 @@ static struct usb_gadget_strings *dev_strings[] = {
NULL,
 };
 
-static u8 hostaddr[ETH_ALEN];
+static u8 host_mac[ETH_ALEN];
 static struct eth_dev *the_dev;
 /*-*/
 static struct usb_function *f_acm;
@@ -120,7 +121,7 @@ static int __init cdc_do_config(struct usb_configuration

[PATCH v3 8/8] usb/gadget: f_ncm: add configfs support

2013-05-15 Thread Andrzej Pietrasiewicz
Signed-off-by: Andrzej Pietrasiewicz 
Signed-off-by: Kyungmin Park 
---
 drivers/usb/gadget/f_ncm.c |  166 
 drivers/usb/gadget/u_ncm.h |9 +++
 2 files changed, 175 insertions(+), 0 deletions(-)

diff --git a/drivers/usb/gadget/f_ncm.c b/drivers/usb/gadget/f_ncm.c
index 8f675c0..7411663 100644
--- a/drivers/usb/gadget/f_ncm.c
+++ b/drivers/usb/gadget/f_ncm.c
@@ -1175,8 +1175,10 @@ static int ncm_bind(struct usb_configuration *c, struct 
usb_function *f)
 * with regard to ncm_opts->bound access
 */
if (!ncm_opts->bound) {
+   mutex_lock(&ncm_opts->lock);
gether_set_gadget(ncm_opts->net, cdev->gadget);
status = gether_register_netdev(ncm_opts->net);
+   mutex_unlock(&ncm_opts->lock);
if (status)
return status;
ncm_opts->bound = true;
@@ -1290,6 +1292,159 @@ fail:
return status;
 }
 
+static inline struct f_ncm_opts *to_f_ncm_opts(struct config_item *item)
+{
+   return container_of(to_config_group(item), struct f_ncm_opts,
+   func_inst.group);
+}
+
+CONFIGFS_ATTR_STRUCT(f_ncm_opts);
+CONFIGFS_ATTR_OPS(f_ncm_opts);
+
+static void ncm_attr_release(struct config_item *item)
+{
+   struct f_ncm_opts *opts = to_f_ncm_opts(item);
+
+   usb_put_function_instance(&opts->func_inst);
+}
+
+static struct configfs_item_operations ncm_item_ops = {
+   .release= ncm_attr_release,
+   .show_attribute = f_ncm_opts_attr_show,
+   .store_attribute = f_ncm_opts_attr_store,
+};
+
+static ssize_t ncm_opts_dev_addr_show(struct f_ncm_opts *opts, char *page)
+{
+   int result;
+
+   mutex_lock(&opts->lock);
+   result = gether_get_dev_addr(opts->net, page, PAGE_SIZE);
+   mutex_unlock(&opts->lock);
+
+   return result;
+}
+
+static ssize_t ncm_opts_dev_addr_store(struct f_ncm_opts *opts,
+   const char *page, size_t len)
+{
+   int ret;
+
+   mutex_lock(&opts->lock);
+   if (opts->refcnt) {
+   mutex_unlock(&opts->lock);
+   return -EBUSY;
+   }
+
+   ret = gether_set_dev_addr(opts->net, page);
+   mutex_unlock(&opts->lock);
+   if (!ret)
+   ret = len;
+   return ret;
+}
+
+static struct f_ncm_opts_attribute f_ncm_opts_dev_addr =
+   __CONFIGFS_ATTR(dev_addr, S_IRUGO | S_IWUSR, ncm_opts_dev_addr_show,
+   ncm_opts_dev_addr_store);
+
+static ssize_t ncm_opts_host_addr_show(struct f_ncm_opts *opts, char *page)
+{
+   int result;
+
+   mutex_lock(&opts->lock);
+   result = gether_get_host_addr(opts->net, page, PAGE_SIZE);
+   mutex_unlock(&opts->lock);
+
+   return result;
+}
+
+static ssize_t ncm_opts_host_addr_store(struct f_ncm_opts *opts,
+   const char *page, size_t len)
+{
+   int ret;
+
+   mutex_lock(&opts->lock);
+   if (opts->refcnt) {
+   mutex_unlock(&opts->lock);
+   return -EBUSY;
+   }
+
+   ret = gether_set_host_addr(opts->net, page);
+   mutex_unlock(&opts->lock);
+   if (!ret)
+   ret = len;
+   return ret;
+}
+
+static struct f_ncm_opts_attribute f_ncm_opts_host_addr =
+   __CONFIGFS_ATTR(host_addr, S_IRUGO | S_IWUSR, ncm_opts_host_addr_show,
+   ncm_opts_host_addr_store);
+
+static ssize_t ncm_opts_qmult_show(struct f_ncm_opts *opts, char *page)
+{
+   unsigned qmult;
+
+   mutex_lock(&opts->lock);
+   qmult = gether_get_qmult(opts->net);
+   mutex_unlock(&opts->lock);
+   return sprintf(page, "%d", qmult);
+}
+
+static ssize_t ncm_opts_qmult_store(struct f_ncm_opts *opts,
+   const char *page, size_t len)
+{
+   u8 val;
+   int ret;
+
+   mutex_lock(&opts->lock);
+   if (opts->refcnt) {
+   ret = -EBUSY;
+   goto out;
+   }
+
+   ret = kstrtou8(page, 0, &val);
+   if (ret)
+   goto out;
+
+   gether_set_qmult(opts->net, val);
+   ret = len;
+out:
+   mutex_unlock(&opts->lock);
+   return ret;
+}
+
+static struct f_ncm_opts_attribute f_ncm_opts_qmult =
+   __CONFIGFS_ATTR(qmult, S_IRUGO | S_IWUSR, ncm_opts_qmult_show,
+   ncm_opts_qmult_store);
+
+static ssize_t ncm_opts_ifname_show(struct f_ncm_opts *opts, char *page)
+{
+   int ret;
+
+   mutex_lock(&opts->lock);
+   ret = gether_get_ifname(opts->net, page, PAGE_SIZE);
+   mutex_unlock(&opts->lock);
+
+   return ret;
+}
+
+static struct f_ncm_opts_attribute f_ncm_opts_ifname =
+   __CONFIGFS_ATTR_RO(ifname, ncm_opts_ifname_show);
+
+static struct configfs_attribute *ncm_attrs[] = {
+   &f_ncm_opts_dev_addr.attr,
+   &f_ncm_opts_host_addr.attr,
+   &f_ncm_opts_qmult.attr,
+   &f_ncm_opts_ifname.attr,
+   NULL,
+};
+
+static struct config_item_type ncm_func_type = {
+   .ct_item_ops= &ncm_ite

[PATCH v3 6/8] usb/gadget: f_ncm: remove compatibility layer

2013-05-15 Thread Andrzej Pietrasiewicz
There are no old function interface users left, so the old interface
can be removed.

Signed-off-by: Andrzej Pietrasiewicz 
Signed-off-by: Kyungmin Park 
---
 drivers/usb/gadget/f_ncm.c   |   80 --
 drivers/usb/gadget/u_ether.h |2 -
 2 files changed, 0 insertions(+), 82 deletions(-)

diff --git a/drivers/usb/gadget/f_ncm.c b/drivers/usb/gadget/f_ncm.c
index f76fa91..1517652 100644
--- a/drivers/usb/gadget/f_ncm.c
+++ b/drivers/usb/gadget/f_ncm.c
@@ -1160,8 +1160,6 @@ static int ncm_bind(struct usb_configuration *c, struct 
usb_function *f)
struct f_ncm*ncm = func_to_ncm(f);
int status;
struct usb_ep   *ep;
-
-#ifndef USB_FNCM_INCLUDED
struct f_ncm_opts   *ncm_opts;
 
if (!can_support_ecm(cdev->gadget))
@@ -1182,7 +1180,6 @@ static int ncm_bind(struct usb_configuration *c, struct 
usb_function *f)
return status;
ncm_opts->bound = true;
}
-#endif
if (ncm_string_defs[0].id == 0) {
status = usb_string_ids_tab(c->cdev, ncm_string_defs);
if (status < 0)
@@ -1297,80 +1294,6 @@ fail:
return status;
 }
 
-#ifdef USB_FNCM_INCLUDED
-
-static void
-ncm_old_unbind(struct usb_configuration *c, struct usb_function *f)
-{
-   struct f_ncm*ncm = func_to_ncm(f);
-
-   DBG(c->cdev, "ncm unbind\n");
-
-   ncm_string_defs[0].id = 0;
-   usb_free_all_descriptors(f);
-
-   kfree(ncm->notify_req->buf);
-   usb_ep_free_request(ncm->notify, ncm->notify_req);
-
-   kfree(ncm);
-}
-
-/**
- * ncm_bind_config - add CDC Network link to a configuration
- * @c: the configuration to support the network link
- * @ethaddr: a buffer in which the ethernet address of the host side
- * side of the link was recorded
- * Context: single threaded during gadget setup
- *
- * Returns zero on success, else negative errno.
- *
- * Caller must have called @gether_setup().  Caller is also responsible
- * for calling @gether_cleanup() before module unload.
- */
-int __init ncm_bind_config(struct usb_configuration *c, u8 ethaddr[ETH_ALEN],
-   struct eth_dev *dev)
-{
-   struct f_ncm*ncm;
-   int status;
-
-   if (!can_support_ecm(c->cdev->gadget) || !ethaddr)
-   return -EINVAL;
-
-   /* allocate and initialize one new instance */
-   ncm = kzalloc(sizeof *ncm, GFP_KERNEL);
-   if (!ncm)
-   return -ENOMEM;
-
-   /* export host's Ethernet address in CDC format */
-   snprintf(ncm->ethaddr, sizeof ncm->ethaddr, "%pm", ethaddr);
-   ncm_string_defs[STRING_MAC_IDX].s = ncm->ethaddr;
-
-   spin_lock_init(&ncm->lock);
-   ncm_reset_values(ncm);
-   ncm->port.ioport = dev;
-   ncm->port.is_fixed = true;
-
-   ncm->port.func.name = "cdc_network";
-   ncm->port.func.strings = ncm_strings;
-   /* descriptors are per-instance copies */
-   ncm->port.func.bind = ncm_bind;
-   ncm->port.func.unbind = ncm_old_unbind;
-   ncm->port.func.set_alt = ncm_set_alt;
-   ncm->port.func.get_alt = ncm_get_alt;
-   ncm->port.func.setup = ncm_setup;
-   ncm->port.func.disable = ncm_disable;
-
-   ncm->port.wrap = ncm_wrap_ntb;
-   ncm->port.unwrap = ncm_unwrap_ntb;
-
-   status = usb_add_function(c, &ncm->port.func);
-   if (status)
-   kfree(ncm);
-   return status;
-}
-
-#else
-
 static void ncm_free_inst(struct usb_function_instance *f)
 {
struct f_ncm_opts *opts;
@@ -1463,6 +1386,3 @@ struct usb_function *ncm_alloc(struct 
usb_function_instance *fi)
 DECLARE_USB_FUNCTION_INIT(ncm, ncm_alloc_inst, ncm_alloc);
 MODULE_LICENSE("GPL");
 MODULE_AUTHOR("Yauheni Kaliuta");
-
-#endif
-
diff --git a/drivers/usb/gadget/u_ether.h b/drivers/usb/gadget/u_ether.h
index d74b8f7..1671a79 100644
--- a/drivers/usb/gadget/u_ether.h
+++ b/drivers/usb/gadget/u_ether.h
@@ -262,8 +262,6 @@ int geth_bind_config(struct usb_configuration *c, u8 
ethaddr[ETH_ALEN],
struct eth_dev *dev);
 int ecm_bind_config(struct usb_configuration *c, u8 ethaddr[ETH_ALEN],
struct eth_dev *dev);
-int ncm_bind_config(struct usb_configuration *c, u8 ethaddr[ETH_ALEN],
-   struct eth_dev *dev);
 int eem_bind_config(struct usb_configuration *c, struct eth_dev *dev);
 
 #ifdef USB_ETH_RNDIS
-- 
1.7.0.4

--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH v3 7/8] usb/gadget: f_ncm: use usb_gstrings_attach

2013-05-15 Thread Andrzej Pietrasiewicz
Signed-off-by: Andrzej Pietrasiewicz 
Signed-off-by: Kyungmin Park 
---
 drivers/usb/gadget/f_ncm.c |   26 ++
 1 files changed, 10 insertions(+), 16 deletions(-)

diff --git a/drivers/usb/gadget/f_ncm.c b/drivers/usb/gadget/f_ncm.c
index 1517652..8f675c0 100644
--- a/drivers/usb/gadget/f_ncm.c
+++ b/drivers/usb/gadget/f_ncm.c
@@ -1158,6 +1158,7 @@ static int ncm_bind(struct usb_configuration *c, struct 
usb_function *f)
 {
struct usb_composite_dev *cdev = c->cdev;
struct f_ncm*ncm = func_to_ncm(f);
+   struct usb_string   *us;
int status;
struct usb_ep   *ep;
struct f_ncm_opts   *ncm_opts;
@@ -1180,20 +1181,15 @@ static int ncm_bind(struct usb_configuration *c, struct 
usb_function *f)
return status;
ncm_opts->bound = true;
}
-   if (ncm_string_defs[0].id == 0) {
-   status = usb_string_ids_tab(c->cdev, ncm_string_defs);
-   if (status < 0)
-   return status;
-   ncm_control_intf.iInterface =
-   ncm_string_defs[STRING_CTRL_IDX].id;
-
-   status = ncm_string_defs[STRING_DATA_IDX].id;
-   ncm_data_nop_intf.iInterface = status;
-   ncm_data_intf.iInterface = status;
-
-   ecm_desc.iMACAddress = ncm_string_defs[STRING_MAC_IDX].id;
-   ncm_iad_desc.iFunction = ncm_string_defs[STRING_IAD_IDX].id;
-   }
+   us = usb_gstrings_attach(cdev, ncm_strings,
+ARRAY_SIZE(ncm_string_defs));
+   if (IS_ERR(us))
+   return PTR_ERR(us);
+   ncm_control_intf.iInterface = us[STRING_CTRL_IDX].id;
+   ncm_data_nop_intf.iInterface = us[STRING_DATA_IDX].id;
+   ncm_data_intf.iInterface = us[STRING_DATA_IDX].id;
+   ecm_desc.iMACAddress = us[STRING_MAC_IDX].id;
+   ncm_iad_desc.iFunction = us[STRING_IAD_IDX].id;
 
/* allocate instance-specific interface IDs */
status = usb_interface_id(c, f);
@@ -1332,7 +1328,6 @@ static void ncm_unbind(struct usb_configuration *c, 
struct usb_function *f)
 
DBG(c->cdev, "ncm unbind\n");
 
-   ncm_string_defs[0].id = 0;
usb_free_all_descriptors(f);
 
kfree(ncm->notify_req->buf);
@@ -1367,7 +1362,6 @@ struct usb_function *ncm_alloc(struct 
usb_function_instance *fi)
ncm->port.is_fixed = true;
 
ncm->port.func.name = "cdc_network";
-   ncm->port.func.strings = ncm_strings;
/* descriptors are per-instance copies */
ncm->port.func.bind = ncm_bind;
ncm->port.func.unbind = ncm_unbind;
-- 
1.7.0.4

--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH v3 4/8] usb/gadget: f_ncm: convert to new function interface with backward compatibility

2013-05-15 Thread Andrzej Pietrasiewicz
Converting ncm to the new function interface requires converting
the USB ncm's function code and its users.
This patch converts the f_ncm.c to the new function interface.
The file is now compiled into a separate usb_f_ncm.ko module.
The old function interface is provided by means of a preprocessor
conditional directives. After all users are converted, the old interface
can be removed.

Signed-off-by: Andrzej Pietrasiewicz 
Signed-off-by: Kyungmin Park 
---
 drivers/usb/gadget/Kconfig  |3 +
 drivers/usb/gadget/Makefile |2 +
 drivers/usb/gadget/f_ncm.c  |  193 +++
 drivers/usb/gadget/ncm.c|1 +
 drivers/usb/gadget/u_ncm.h  |   27 ++
 5 files changed, 191 insertions(+), 35 deletions(-)
 create mode 100644 drivers/usb/gadget/u_ncm.h

diff --git a/drivers/usb/gadget/Kconfig b/drivers/usb/gadget/Kconfig
index 91b6eab..59908b0 100644
--- a/drivers/usb/gadget/Kconfig
+++ b/drivers/usb/gadget/Kconfig
@@ -563,6 +563,9 @@ config USB_F_SERIAL
 config USB_F_OBEX
tristate
 
+config USB_F_NCM
+   tristate
+
 choice
tristate "USB Gadget Drivers"
default USB_ETH
diff --git a/drivers/usb/gadget/Makefile b/drivers/usb/gadget/Makefile
index 3f51952..81f14fe 100644
--- a/drivers/usb/gadget/Makefile
+++ b/drivers/usb/gadget/Makefile
@@ -49,6 +49,8 @@ obj-$(CONFIG_USB_F_OBEX)  += usb_f_obex.o
 obj-$(CONFIG_USB_U_ETHER)  += u_ether.o
 u_rndis-y  := rndis.o
 obj-$(CONFIG_USB_U_RNDIS)  += u_rndis.o
+usb_f_ncm-y:= f_ncm.o
+obj-$(CONFIG_USB_F_NCM)+= usb_f_ncm.o
 
 #
 # USB gadget drivers
diff --git a/drivers/usb/gadget/f_ncm.c b/drivers/usb/gadget/f_ncm.c
index ee19bc8..f76fa91 100644
--- a/drivers/usb/gadget/f_ncm.c
+++ b/drivers/usb/gadget/f_ncm.c
@@ -16,6 +16,7 @@
  */
 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -23,6 +24,7 @@
 #include 
 
 #include "u_ether.h"
+#include "u_ncm.h"
 
 /*
  * This function is a "CDC Network Control Model" (CDC NCM) Ethernet link.
@@ -125,7 +127,7 @@ static struct usb_cdc_ncm_ntb_parameters ntb_parameters = {
 #define NCM_STATUS_INTERVAL_MS 32
 #define NCM_STATUS_BYTECOUNT   16  /* 8 byte header + data */
 
-static struct usb_interface_assoc_descriptor ncm_iad_desc __initdata = {
+static struct usb_interface_assoc_descriptor ncm_iad_desc = {
.bLength =  sizeof ncm_iad_desc,
.bDescriptorType =  USB_DT_INTERFACE_ASSOCIATION,
 
@@ -139,7 +141,7 @@ static struct usb_interface_assoc_descriptor ncm_iad_desc 
__initdata = {
 
 /* interface descriptor: */
 
-static struct usb_interface_descriptor ncm_control_intf __initdata = {
+static struct usb_interface_descriptor ncm_control_intf = {
.bLength =  sizeof ncm_control_intf,
.bDescriptorType =  USB_DT_INTERFACE,
 
@@ -151,7 +153,7 @@ static struct usb_interface_descriptor ncm_control_intf 
__initdata = {
/* .iInterface = DYNAMIC */
 };
 
-static struct usb_cdc_header_desc ncm_header_desc __initdata = {
+static struct usb_cdc_header_desc ncm_header_desc = {
.bLength =  sizeof ncm_header_desc,
.bDescriptorType =  USB_DT_CS_INTERFACE,
.bDescriptorSubType =   USB_CDC_HEADER_TYPE,
@@ -159,7 +161,7 @@ static struct usb_cdc_header_desc ncm_header_desc 
__initdata = {
.bcdCDC =   cpu_to_le16(0x0110),
 };
 
-static struct usb_cdc_union_desc ncm_union_desc __initdata = {
+static struct usb_cdc_union_desc ncm_union_desc = {
.bLength =  sizeof(ncm_union_desc),
.bDescriptorType =  USB_DT_CS_INTERFACE,
.bDescriptorSubType =   USB_CDC_UNION_TYPE,
@@ -167,7 +169,7 @@ static struct usb_cdc_union_desc ncm_union_desc __initdata 
= {
/* .bSlaveInterface0 =  DYNAMIC */
 };
 
-static struct usb_cdc_ether_desc ecm_desc __initdata = {
+static struct usb_cdc_ether_desc ecm_desc = {
.bLength =  sizeof ecm_desc,
.bDescriptorType =  USB_DT_CS_INTERFACE,
.bDescriptorSubType =   USB_CDC_ETHERNET_TYPE,
@@ -182,7 +184,7 @@ static struct usb_cdc_ether_desc ecm_desc __initdata = {
 
 #define NCAPS  (USB_CDC_NCM_NCAP_ETH_FILTER | USB_CDC_NCM_NCAP_CRC_MODE)
 
-static struct usb_cdc_ncm_desc ncm_desc __initdata = {
+static struct usb_cdc_ncm_desc ncm_desc = {
.bLength =  sizeof ncm_desc,
.bDescriptorType =  USB_DT_CS_INTERFACE,
.bDescriptorSubType =   USB_CDC_NCM_TYPE,
@@ -194,7 +196,7 @@ static struct usb_cdc_ncm_desc ncm_desc __initdata = {
 
 /* the default data interface has no endpoints ... */
 
-static struct usb_interface_descriptor ncm_data_nop_intf __initdata = {
+static struct usb_interface_descriptor ncm_data_nop_intf = {
.bLength =  sizeof ncm_data_nop_intf,
.bDescriptorType =  USB_DT_INTERFACE,
 
@@ -209,7 +211,7 @@ static struct usb_interface_descriptor ncm_data_nop_intf 
__initdata = {
 
 /* ... but the "re

[PATCH v3 3/8] usb/gadget: u_ether: construct with default values and add setters/getters

2013-05-15 Thread Andrzej Pietrasiewicz
Add an interface to create a struct netdev_dev filled with default values, an 
interface which makes it
an interface to fill the struct with useful values and an interface to
read the values set.

The patch also adds an interface to register the net device associated
with an ethernet-over-usb link.

Signed-off-by: Andrzej Pietrasiewicz 
Signed-off-by: Kyungmin Park 
---
 drivers/usb/gadget/u_ether.c |  185 +-
 drivers/usb/gadget/u_ether.h |  123 
 2 files changed, 307 insertions(+), 1 deletions(-)

diff --git a/drivers/usb/gadget/u_ether.c b/drivers/usb/gadget/u_ether.c
index 5f9dacf..6d3ccdc 100644
--- a/drivers/usb/gadget/u_ether.c
+++ b/drivers/usb/gadget/u_ether.c
@@ -78,6 +78,7 @@ struct eth_dev {
 
boolzlp;
u8  host_mac[ETH_ALEN];
+   u8  dev_mac[ETH_ALEN];
 };
 
 /*-*/
@@ -716,6 +717,17 @@ static int get_ether_addr(const char *str, u8 *dev_addr)
return 1;
 }
 
+static int get_ether_addr_str(u8 dev_addr[ETH_ALEN], char *str, int len)
+{
+   if (len < 18)
+   return -EINVAL;
+
+   snprintf(str, len, "%02x:%02x:%02x:%02x:%02x:%02x",
+dev_addr[0], dev_addr[1], dev_addr[2],
+dev_addr[3], dev_addr[4], dev_addr[5]);
+   return 18;
+}
+
 static const struct net_device_ops eth_netdev_ops = {
.ndo_open   = eth_open,
.ndo_stop   = eth_stop,
@@ -796,7 +808,8 @@ struct eth_dev *gether_setup_name(struct usb_gadget *g,
INFO(dev, "MAC %pM\n", net->dev_addr);
INFO(dev, "HOST MAC %pM\n", dev->host_mac);
 
-   /* two kinds of host-initiated state changes:
+   /*
+* two kinds of host-initiated state changes:
 *  - iff DATA transfer is active, carrier is "on"
 *  - tx queueing enabled if open *and* carrier is "on"
 */
@@ -807,6 +820,176 @@ struct eth_dev *gether_setup_name(struct usb_gadget *g,
 }
 EXPORT_SYMBOL(gether_setup_name);
 
+struct net_device *gether_setup_name_default(const char *netname)
+{
+   struct net_device   *net;
+   struct eth_dev  *dev;
+
+   net = alloc_etherdev(sizeof(*dev));
+   if (!net)
+   return ERR_PTR(-ENOMEM);
+
+   dev = netdev_priv(net);
+   spin_lock_init(&dev->lock);
+   spin_lock_init(&dev->req_lock);
+   INIT_WORK(&dev->work, eth_work);
+   INIT_LIST_HEAD(&dev->tx_reqs);
+   INIT_LIST_HEAD(&dev->rx_reqs);
+
+   skb_queue_head_init(&dev->rx_frames);
+
+   /* network device setup */
+   dev->net = net;
+   dev->qmult = QMULT_DEFAULT;
+   snprintf(net->name, sizeof(net->name), "%s%%d", netname);
+
+   eth_random_addr(dev->dev_mac);
+   pr_warn("using random %s ethernet address\n", "self");
+   eth_random_addr(dev->host_mac);
+   pr_warn("using random %s ethernet address\n", "host");
+
+   net->netdev_ops = ð_netdev_ops;
+
+   SET_ETHTOOL_OPS(net, &ops);
+   SET_NETDEV_DEVTYPE(net, &gadget_type);
+
+   return net;
+}
+EXPORT_SYMBOL(gether_setup_name_default);
+
+int gether_register_netdev(struct net_device *net)
+{
+   struct eth_dev *dev;
+   struct usb_gadget *g;
+   struct sockaddr sa;
+   int status;
+
+   if (!net->dev.parent)
+   return -EINVAL;
+   dev = netdev_priv(net);
+   g = dev->gadget;
+   status = register_netdev(net);
+   if (status < 0) {
+   dev_dbg(&g->dev, "register_netdev failed, %d\n", status);
+   return status;
+   } else {
+   INFO(dev, "HOST MAC %pM\n", dev->host_mac);
+
+   /* two kinds of host-initiated state changes:
+*  - iff DATA transfer is active, carrier is "on"
+*  - tx queueing enabled if open *and* carrier is "on"
+*/
+   netif_carrier_off(net);
+   }
+   sa.sa_family = net->type;
+   memcpy(sa.sa_data, dev->dev_mac, ETH_ALEN);
+   rtnl_lock();
+   status = dev_set_mac_address(net, &sa);
+   rtnl_unlock();
+   if (status)
+   pr_warn("cannot set self ethernet address: %d\n", status);
+   else
+   INFO(dev, "MAC %pM\n", dev->dev_mac);
+
+   return status;
+}
+EXPORT_SYMBOL(gether_register_netdev);
+
+void gether_set_gadget(struct net_device *net, struct usb_gadget *g)
+{
+   struct eth_dev *dev;
+
+   dev = netdev_priv(net);
+   dev->gadget = g;
+   SET_NETDEV_DEV(net, &g->dev);
+}
+EXPORT_SYMBOL(gether_set_gadget);
+
+int gether_set_dev_addr(struct net_device *net, const char *dev_addr)
+{
+   struct eth_dev *dev;
+   u8 new_addr[ETH_ALEN];
+
+   dev = netdev_priv(net);
+   if (get_ether_addr(dev_addr, new_addr))
+   return -EINVAL;
+   me

RE: [PATCH v3 0/8] Equivalent of g_ncm.ko with configfs

2013-05-15 Thread Andrzej Pietrasiewicz
On Wednesday, May 15, 2013 9:11 AM I wrote:
> Here I present the conversion of everthing that is required to provide the
> equivalent of g_ncm.ko with configfs.
> 
> This is the second version of the series after discussion with Alan and
> Michal's review - thank you guys.
> 
> A branch will be available here (from 24th April 2013):
> git://git.infradead.org/users/kmpark/linux-samsung usb-gadget-configfs
> 

As a matter of fact it will be available from 15th May 2013, afternoon UTC.
Sorry about confusion.

Andrzej


--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH v2 0/5] Equivalent of g_cdc.ko with configfs

2013-05-15 Thread Andrzej Pietrasiewicz
Here I present the conversion of everthing that is required to provide
the equivalent of g_cdc.ko with configfs.

A branch will be available here (from 15th May 2013, afternoon UTC):
git://git.infradead.org/users/kmpark/linux-samsung usb-gadget-configfs

v1..v2:

- fixed a bug resulting from the delayed registration of a network interface
  (should be registered only once)


BACKWARD COMPATIBILITY
==

Please note that the old g_cdc.ko is still available and works.


USING THE NEW "GADGET"
==

Please refer to this post:

http://www.spinics.net/lists/linux-usb/msg76388.html

for general information from Sebastian on how to use configfs-based
gadgets (*).

Here is the description specific to using g_cdc.ko equivalent.

The old g_cdc.ko provides two functions:

- acm
- ecm

which can be used simultaneously.

The acm function usage is described in (*).

For ecm the old g_cdc.ko offered three parameters:

qmult  - queue length multiplier for high/super -speed devices
dev_addr   - device's MAC address
host_addr  - host's MAC address

With configfs the procedure is as follows, compared to the information
mentioned above (*):

instead of mkdir functions/acm.ttyS1 do

mkdir functions/ecm.

e.g. mkdir functions/ecm.usb0

In functions/ecm. there will be the following attribute files:

qmult
dev_addr
host_addr
ifname

and after creating the functions/ecm. they contain default
values: qmult is 5, dev_addr and host_addr are randomly selected.
Except for ifname they can be written to until the function is linked to a
configuration. The ifname is read-only and contains the name of the interface
which was assigned by the net core, e. g. usb0.

The rest of the procedure (*) remains the same.

After unbinding the gadget with echo "" > UDC
the symbolic links in the configuration directory can be removed,
the strings/* subdirectories in the configuration directory can
be removed, the strings/* subdirectories at the gadget level can
be removed and the configs/* subdirectories can be removed.
The functions/* subdirectories can be removed.
After that the gadget directory can be removed.
After that the respective modules can be unloaded.


TESTING THE FUNCTIONS


acm)

On host: cat > /dev/ttyACM
On target: cat /dev/ttyGS

then the other way round

On target: cat > /dev/ttyGS
On host: cat /dev/ttyACM

ecm)

On the device: ping 
On the host: ping 

Andrzej Pietrasiewicz (5):
  usb/gadget: add helpers for configfs support for USB Ethernet
  usb/gadget: f_ecm: convert to new function interface with backward
compatibility
  usb/gadget: cdc2: convert to new interface of f_ecm
  usb/gadget: f_ecm: use usb_gstrings_attach
  usb/gadget: f_ecm: add configfs support

 drivers/usb/gadget/Kconfig|4 +
 drivers/usb/gadget/Makefile   |2 +
 drivers/usb/gadget/cdc2.c |   83 +--
 drivers/usb/gadget/ether.c|1 +
 drivers/usb/gadget/f_ecm.c|  193 ++---
 drivers/usb/gadget/f_ncm.c|  139 ++--
 drivers/usb/gadget/g_ffs.c|1 +
 drivers/usb/gadget/multi.c|1 +
 drivers/usb/gadget/nokia.c|3 +-
 drivers/usb/gadget/u_ecm.h|   36 ++
 drivers/usb/gadget/u_ether_configfs.h |  164 
 11 files changed, 451 insertions(+), 176 deletions(-)
 create mode 100644 drivers/usb/gadget/u_ecm.h
 create mode 100644 drivers/usb/gadget/u_ether_configfs.h

--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH v2 2/5] usb/gadget: f_ecm: convert to new function interface with backward compatibility

2013-05-15 Thread Andrzej Pietrasiewicz
Converting ecm to the new function interface requires converting
the USB ecm's function code and its users.
This patch converts the f_ecm.c to the new function interface.
The file is now compiled into a separate usb_f_ecm.ko module.
The old function interface is provided by means of a preprocessor
conditional directives. After all users are converted, the old interface
can be removed.

Signed-off-by: Andrzej Pietrasiewicz 
Signed-off-by: Kyungmin Park 
---
 drivers/usb/gadget/Kconfig  |3 +
 drivers/usb/gadget/Makefile |2 +
 drivers/usb/gadget/cdc2.c   |1 +
 drivers/usb/gadget/ether.c  |1 +
 drivers/usb/gadget/f_ecm.c  |  146 +++
 drivers/usb/gadget/g_ffs.c  |1 +
 drivers/usb/gadget/multi.c  |1 +
 drivers/usb/gadget/nokia.c  |3 +-
 drivers/usb/gadget/u_ecm.h  |   27 
 9 files changed, 171 insertions(+), 14 deletions(-)
 create mode 100644 drivers/usb/gadget/u_ecm.h

diff --git a/drivers/usb/gadget/Kconfig b/drivers/usb/gadget/Kconfig
index 629b7bb..bcadb5c 100644
--- a/drivers/usb/gadget/Kconfig
+++ b/drivers/usb/gadget/Kconfig
@@ -566,6 +566,9 @@ config USB_F_OBEX
 config USB_F_NCM
tristate
 
+config USB_F_ECM
+   tristate
+
 choice
tristate "USB Gadget Drivers"
default USB_ETH
diff --git a/drivers/usb/gadget/Makefile b/drivers/usb/gadget/Makefile
index 81f14fe..ecfa7c3 100644
--- a/drivers/usb/gadget/Makefile
+++ b/drivers/usb/gadget/Makefile
@@ -51,6 +51,8 @@ u_rndis-y := rndis.o
 obj-$(CONFIG_USB_U_RNDIS)  += u_rndis.o
 usb_f_ncm-y:= f_ncm.o
 obj-$(CONFIG_USB_F_NCM)+= usb_f_ncm.o
+usb_f_ecm-y:= f_ecm.o
+obj-$(CONFIG_USB_F_ECM)+= usb_f_ecm.o
 
 #
 # USB gadget drivers
diff --git a/drivers/usb/gadget/cdc2.c b/drivers/usb/gadget/cdc2.c
index 07b3aaf..a0cba7e 100644
--- a/drivers/usb/gadget/cdc2.c
+++ b/drivers/usb/gadget/cdc2.c
@@ -44,6 +44,7 @@ USB_ETHERNET_MODULE_PARAMETERS();
  * the runtime footprint, and giving us at least some parts of what
  * a "gcc --combine ... part1.c part2.c part3.c ... " build would.
  */
+#define USBF_ECM_INCLUDED
 #include "f_ecm.c"
 
 /*-*/
diff --git a/drivers/usb/gadget/ether.c b/drivers/usb/gadget/ether.c
index 6bff24f..862ef65 100644
--- a/drivers/usb/gadget/ether.c
+++ b/drivers/usb/gadget/ether.c
@@ -102,6 +102,7 @@ static inline bool has_rndis(void)
  * the runtime footprint, and giving us at least some parts of what
  * a "gcc --combine ... part1.c part2.c part3.c ... " build would.
  */
+#define USBF_ECM_INCLUDED
 #include "f_ecm.c"
 #include "f_subset.c"
 #ifdef USB_ETH_RNDIS
diff --git a/drivers/usb/gadget/f_ecm.c b/drivers/usb/gadget/f_ecm.c
index d893d69..1b4f290 100644
--- a/drivers/usb/gadget/f_ecm.c
+++ b/drivers/usb/gadget/f_ecm.c
@@ -14,10 +14,12 @@
 
 #include 
 #include 
+#include 
 #include 
 #include 
 
 #include "u_ether.h"
+#include "u_ecm.h"
 
 
 /*
@@ -687,6 +689,40 @@ ecm_bind(struct usb_configuration *c, struct usb_function 
*f)
int status;
struct usb_ep   *ep;
 
+#ifndef USBF_ECM_INCLUDED
+   struct f_ecm_opts   *ecm_opts;
+
+   if (!can_support_ecm(cdev->gadget))
+   return -EINVAL;
+
+   ecm_opts = container_of(f->fi, struct f_ecm_opts, func_inst);
+
+   /*
+* in drivers/usb/gadget/configfs.c:configfs_composite_bind()
+* configurations are bound in sequence with list_for_each_entry,
+* in each configuration its functions are bound in sequence
+* with list_for_each_entry, so we assume no race condition
+* with regard to ecm_opts->bound access
+*/
+   if (!ecm_opts->bound) {
+   gether_set_gadget(ecm_opts->net, cdev->gadget);
+   status = gether_register_netdev(ecm_opts->net);
+   if (status)
+   return status;
+   ecm_opts->bound = true;
+   }
+#endif
+   if (ecm_string_defs[0].id == 0) {
+   status = usb_string_ids_tab(c->cdev, ecm_string_defs);
+   if (status)
+   return status;
+
+   ecm_control_intf.iInterface = ecm_string_defs[0].id;
+   ecm_data_intf.iInterface = ecm_string_defs[2].id;
+   ecm_desc.iMACAddress = ecm_string_defs[1].id;
+   ecm_iad_descriptor.iFunction = ecm_string_defs[3].id;
+   }
+
/* allocate instance-specific interface IDs */
status = usb_interface_id(c, f);
if (status < 0)
@@ -796,8 +832,10 @@ fail:
return status;
 }
 
+#ifdef USBF_ECM_INCLUDED
+
 static void
-ecm_unbind(struct usb_configuration *c, struct usb_function *f)
+ecm_old_unbind(struct usb_configuration *c, struct usb_function *f)
 {
struct f_ecm*ecm = func_to_ecm(f);
 
@@ -833,17 +871,6 @@ ecm_bind_config(struct usb_configuration *c, u8 
ethaddr

[PATCH v2 4/5] usb/gadget: f_ecm: use usb_gstrings_attach

2013-05-15 Thread Andrzej Pietrasiewicz
Signed-off-by: Andrzej Pietrasiewicz 
Signed-off-by: Kyungmin Park 
---
 drivers/usb/gadget/f_ecm.c |   23 +--
 1 files changed, 9 insertions(+), 14 deletions(-)

diff --git a/drivers/usb/gadget/f_ecm.c b/drivers/usb/gadget/f_ecm.c
index 1b4f290..d89e1f3 100644
--- a/drivers/usb/gadget/f_ecm.c
+++ b/drivers/usb/gadget/f_ecm.c
@@ -686,6 +686,7 @@ ecm_bind(struct usb_configuration *c, struct usb_function 
*f)
 {
struct usb_composite_dev *cdev = c->cdev;
struct f_ecm*ecm = func_to_ecm(f);
+   struct usb_string   *us;
int status;
struct usb_ep   *ep;
 
@@ -712,16 +713,14 @@ ecm_bind(struct usb_configuration *c, struct usb_function 
*f)
ecm_opts->bound = true;
}
 #endif
-   if (ecm_string_defs[0].id == 0) {
-   status = usb_string_ids_tab(c->cdev, ecm_string_defs);
-   if (status)
-   return status;
-
-   ecm_control_intf.iInterface = ecm_string_defs[0].id;
-   ecm_data_intf.iInterface = ecm_string_defs[2].id;
-   ecm_desc.iMACAddress = ecm_string_defs[1].id;
-   ecm_iad_descriptor.iFunction = ecm_string_defs[3].id;
-   }
+   us = usb_gstrings_attach(cdev, ecm_strings,
+ARRAY_SIZE(ecm_string_defs));
+   if (IS_ERR(us))
+   return PTR_ERR(us);
+   ecm_control_intf.iInterface = us[0].id;
+   ecm_data_intf.iInterface = us[2].id;
+   ecm_desc.iMACAddress = us[1].id;
+   ecm_iad_descriptor.iFunction = us[3].id;
 
/* allocate instance-specific interface IDs */
status = usb_interface_id(c, f);
@@ -841,7 +840,6 @@ ecm_old_unbind(struct usb_configuration *c, struct 
usb_function *f)
 
DBG(c->cdev, "ecm unbind\n");
 
-   ecm_string_defs[0].id = 0;
usb_free_all_descriptors(f);
 
kfree(ecm->notify_req->buf);
@@ -884,7 +882,6 @@ ecm_bind_config(struct usb_configuration *c, u8 
ethaddr[ETH_ALEN],
ecm->port.cdc_filter = DEFAULT_FILTER;
 
ecm->port.func.name = "cdc_ethernet";
-   ecm->port.func.strings = ecm_strings;
/* descriptors are per-instance copies */
ecm->port.func.bind = ecm_bind;
ecm->port.func.unbind = ecm_old_unbind;
@@ -940,7 +937,6 @@ static void ecm_unbind(struct usb_configuration *c, struct 
usb_function *f)
 
DBG(c->cdev, "ecm unbind\n");
 
-   ecm_string_defs[0].id = 0;
usb_free_all_descriptors(f);
 
kfree(ecm->notify_req->buf);
@@ -973,7 +969,6 @@ struct usb_function *ecm_alloc(struct usb_function_instance 
*fi)
ecm->port.cdc_filter = DEFAULT_FILTER;
 
ecm->port.func.name = "cdc_ethernet";
-   ecm->port.func.strings = ecm_strings;
/* descriptors are per-instance copies */
ecm->port.func.bind = ecm_bind;
ecm->port.func.unbind = ecm_unbind;
-- 
1.7.0.4

--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH v2 5/5] usb/gadget: f_ecm: add configfs support

2013-05-15 Thread Andrzej Pietrasiewicz
Signed-off-by: Andrzej Pietrasiewicz 
Signed-off-by: Kyungmin Park 
---
 drivers/usb/gadget/f_ecm.c |   50 +++-
 drivers/usb/gadget/u_ecm.h |9 
 2 files changed, 58 insertions(+), 1 deletions(-)

diff --git a/drivers/usb/gadget/f_ecm.c b/drivers/usb/gadget/f_ecm.c
index d89e1f3..3a63a56 100644
--- a/drivers/usb/gadget/f_ecm.c
+++ b/drivers/usb/gadget/f_ecm.c
@@ -19,6 +19,7 @@
 #include 
 
 #include "u_ether.h"
+#include "u_ether_configfs.h"
 #include "u_ecm.h"
 
 
@@ -706,8 +707,10 @@ ecm_bind(struct usb_configuration *c, struct usb_function 
*f)
 * with regard to ecm_opts->bound access
 */
if (!ecm_opts->bound) {
+   mutex_lock(&ecm_opts->lock);
gether_set_gadget(ecm_opts->net, cdev->gadget);
status = gether_register_netdev(ecm_opts->net);
+   mutex_unlock(&ecm_opts->lock);
if (status)
return status;
ecm_opts->bound = true;
@@ -898,6 +901,41 @@ ecm_bind_config(struct usb_configuration *c, u8 
ethaddr[ETH_ALEN],
 
 #else
 
+static inline struct f_ecm_opts *to_f_ecm_opts(struct config_item *item)
+{
+   return container_of(to_config_group(item), struct f_ecm_opts,
+   func_inst.group);
+}
+
+/* f_ecm_item_ops */
+USB_ETHERNET_CONFIGFS_ITEM(ecm);
+
+/* f_ecm_opts_dev_addr */
+USB_ETHERNET_CONFIGFS_ITEM_ATTR_DEV_ADDR(ecm);
+
+/* f_ecm_opts_host_addr */
+USB_ETHERNET_CONFIGFS_ITEM_ATTR_HOST_ADDR(ecm);
+
+/* f_ecm_opts_qmult */
+USB_ETHERNET_CONFIGFS_ITEM_ATTR_QMULT(ecm);
+
+/* f_ecm_opts_ifname */
+USB_ETHERNET_CONFIGFS_ITEM_ATTR_IFNAME(ecm);
+
+static struct configfs_attribute *ecm_attrs[] = {
+   &f_ecm_opts_dev_addr.attr,
+   &f_ecm_opts_host_addr.attr,
+   &f_ecm_opts_qmult.attr,
+   &f_ecm_opts_ifname.attr,
+   NULL,
+};
+
+static struct config_item_type ecm_func_type = {
+   .ct_item_ops= &ecm_item_ops,
+   .ct_attrs   = ecm_attrs,
+   .ct_owner   = THIS_MODULE,
+};
+
 static void ecm_free_inst(struct usb_function_instance *f)
 {
struct f_ecm_opts *opts;
@@ -914,21 +952,28 @@ static struct usb_function_instance *ecm_alloc_inst(void)
opts = kzalloc(sizeof(*opts), GFP_KERNEL);
if (!opts)
return ERR_PTR(-ENOMEM);
-
+   mutex_init(&opts->lock);
opts->func_inst.free_func_inst = ecm_free_inst;
opts->net = gether_setup_default();
if (IS_ERR(opts->net))
return ERR_PTR(PTR_ERR(opts->net));
 
+   config_group_init_type_name(&opts->func_inst.group, "", &ecm_func_type);
+
return &opts->func_inst;
 }
 
 static void ecm_free(struct usb_function *f)
 {
struct f_ecm *ecm;
+   struct f_ecm_opts *opts;
 
ecm = func_to_ecm(f);
+   opts = container_of(f->fi, struct f_ecm_opts, func_inst);
kfree(ecm);
+   mutex_lock(&opts->lock);
+   opts->refcnt--;
+   mutex_unlock(&opts->lock);
 }
 
 static void ecm_unbind(struct usb_configuration *c, struct usb_function *f)
@@ -955,6 +1000,8 @@ struct usb_function *ecm_alloc(struct 
usb_function_instance *fi)
return ERR_PTR(-ENOMEM);
 
opts = container_of(fi, struct f_ecm_opts, func_inst);
+   mutex_lock(&opts->lock);
+   opts->refcnt++;
 
/* export host's Ethernet address in CDC format */
status = gether_get_host_addr_cdc(opts->net, ecm->ethaddr,
@@ -966,6 +1013,7 @@ struct usb_function *ecm_alloc(struct 
usb_function_instance *fi)
ecm_string_defs[1].s = ecm->ethaddr;
 
ecm->port.ioport = netdev_priv(opts->net);
+   mutex_unlock(&opts->lock);
ecm->port.cdc_filter = DEFAULT_FILTER;
 
ecm->port.func.name = "cdc_ethernet";
diff --git a/drivers/usb/gadget/u_ecm.h b/drivers/usb/gadget/u_ecm.h
index 99b6b99..262cc03 100644
--- a/drivers/usb/gadget/u_ecm.h
+++ b/drivers/usb/gadget/u_ecm.h
@@ -22,6 +22,15 @@ struct f_ecm_opts {
struct usb_function_instancefunc_inst;
struct net_device   *net;
boolbound;
+
+   /*
+* Read/write access to configfs attributes is handled by configfs.
+*
+* This is to protect the data from concurrent access by read/write
+* and create symlink/remove symlink.
+*/
+   struct mutexlock;
+   int refcnt;
 };
 
 #endif /* U_ECM_H */
-- 
1.7.0.4

--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH v2 1/5] usb/gadget: add helpers for configfs support for USB Ethernet

2013-05-15 Thread Andrzej Pietrasiewicz
All USB Ethernet functions will have very similar attributes in configfs.
This patch provides helper definitions to ease writing the functions and
reduce source code duplication.

Signed-off-by: Andrzej Pietrasiewicz 
Signed-off-by: Kyungmin Park 
---
 drivers/usb/gadget/f_ncm.c|  139 ++-
 drivers/usb/gadget/u_ether_configfs.h |  164 +
 2 files changed, 175 insertions(+), 128 deletions(-)
 create mode 100644 drivers/usb/gadget/u_ether_configfs.h

diff --git a/drivers/usb/gadget/f_ncm.c b/drivers/usb/gadget/f_ncm.c
index 7411663..dbcd542 100644
--- a/drivers/usb/gadget/f_ncm.c
+++ b/drivers/usb/gadget/f_ncm.c
@@ -24,6 +24,7 @@
 #include 
 
 #include "u_ether.h"
+#include "u_ether_configfs.h"
 #include "u_ncm.h"
 
 /*
@@ -1298,138 +1299,20 @@ static inline struct f_ncm_opts *to_f_ncm_opts(struct 
config_item *item)
func_inst.group);
 }
 
-CONFIGFS_ATTR_STRUCT(f_ncm_opts);
-CONFIGFS_ATTR_OPS(f_ncm_opts);
+/* f_ncm_item_ops */
+USB_ETHERNET_CONFIGFS_ITEM(ncm);
 
-static void ncm_attr_release(struct config_item *item)
-{
-   struct f_ncm_opts *opts = to_f_ncm_opts(item);
-
-   usb_put_function_instance(&opts->func_inst);
-}
-
-static struct configfs_item_operations ncm_item_ops = {
-   .release= ncm_attr_release,
-   .show_attribute = f_ncm_opts_attr_show,
-   .store_attribute = f_ncm_opts_attr_store,
-};
-
-static ssize_t ncm_opts_dev_addr_show(struct f_ncm_opts *opts, char *page)
-{
-   int result;
-
-   mutex_lock(&opts->lock);
-   result = gether_get_dev_addr(opts->net, page, PAGE_SIZE);
-   mutex_unlock(&opts->lock);
-
-   return result;
-}
-
-static ssize_t ncm_opts_dev_addr_store(struct f_ncm_opts *opts,
-   const char *page, size_t len)
-{
-   int ret;
-
-   mutex_lock(&opts->lock);
-   if (opts->refcnt) {
-   mutex_unlock(&opts->lock);
-   return -EBUSY;
-   }
-
-   ret = gether_set_dev_addr(opts->net, page);
-   mutex_unlock(&opts->lock);
-   if (!ret)
-   ret = len;
-   return ret;
-}
-
-static struct f_ncm_opts_attribute f_ncm_opts_dev_addr =
-   __CONFIGFS_ATTR(dev_addr, S_IRUGO | S_IWUSR, ncm_opts_dev_addr_show,
-   ncm_opts_dev_addr_store);
-
-static ssize_t ncm_opts_host_addr_show(struct f_ncm_opts *opts, char *page)
-{
-   int result;
-
-   mutex_lock(&opts->lock);
-   result = gether_get_host_addr(opts->net, page, PAGE_SIZE);
-   mutex_unlock(&opts->lock);
-
-   return result;
-}
-
-static ssize_t ncm_opts_host_addr_store(struct f_ncm_opts *opts,
-   const char *page, size_t len)
-{
-   int ret;
+/* f_ncm_opts_dev_addr */
+USB_ETHERNET_CONFIGFS_ITEM_ATTR_DEV_ADDR(ncm);
 
-   mutex_lock(&opts->lock);
-   if (opts->refcnt) {
-   mutex_unlock(&opts->lock);
-   return -EBUSY;
-   }
-
-   ret = gether_set_host_addr(opts->net, page);
-   mutex_unlock(&opts->lock);
-   if (!ret)
-   ret = len;
-   return ret;
-}
-
-static struct f_ncm_opts_attribute f_ncm_opts_host_addr =
-   __CONFIGFS_ATTR(host_addr, S_IRUGO | S_IWUSR, ncm_opts_host_addr_show,
-   ncm_opts_host_addr_store);
-
-static ssize_t ncm_opts_qmult_show(struct f_ncm_opts *opts, char *page)
-{
-   unsigned qmult;
-
-   mutex_lock(&opts->lock);
-   qmult = gether_get_qmult(opts->net);
-   mutex_unlock(&opts->lock);
-   return sprintf(page, "%d", qmult);
-}
-
-static ssize_t ncm_opts_qmult_store(struct f_ncm_opts *opts,
-   const char *page, size_t len)
-{
-   u8 val;
-   int ret;
+/* f_ncm_opts_host_addr */
+USB_ETHERNET_CONFIGFS_ITEM_ATTR_HOST_ADDR(ncm);
 
-   mutex_lock(&opts->lock);
-   if (opts->refcnt) {
-   ret = -EBUSY;
-   goto out;
-   }
-
-   ret = kstrtou8(page, 0, &val);
-   if (ret)
-   goto out;
-
-   gether_set_qmult(opts->net, val);
-   ret = len;
-out:
-   mutex_unlock(&opts->lock);
-   return ret;
-}
-
-static struct f_ncm_opts_attribute f_ncm_opts_qmult =
-   __CONFIGFS_ATTR(qmult, S_IRUGO | S_IWUSR, ncm_opts_qmult_show,
-   ncm_opts_qmult_store);
-
-static ssize_t ncm_opts_ifname_show(struct f_ncm_opts *opts, char *page)
-{
-   int ret;
-
-   mutex_lock(&opts->lock);
-   ret = gether_get_ifname(opts->net, page, PAGE_SIZE);
-   mutex_unlock(&opts->lock);
-
-   return ret;
-}
+/* f_ncm_opts_qmult */
+USB_ETHERNET_CONFIGFS_ITEM_ATTR_QMULT(ncm);
 
-static struct f_ncm_opts_attribute f_ncm_opts_ifname =
-   __CONFIGFS_ATTR_RO(ifname, ncm_opts_ifname_show);
+/* f_ncm_opts_ifname */
+USB_ETHERNET_CONFIGFS_ITEM_ATTR_IFNAME(ncm);
 
 static struct configfs_attribute *ncm_attrs[] = {
&f_ncm_opts_dev_addr.attr,
diff --git a/drivers/usb/gadget/u_ether_configfs.h 
b/drivers/usb/gadget/u_ether_configfs.h
new

[PATCH v2 3/5] usb/gadget: cdc2: convert to new interface of f_ecm

2013-05-15 Thread Andrzej Pietrasiewicz
Signed-off-by: Andrzej Pietrasiewicz 
Signed-off-by: Kyungmin Park 
---
 drivers/usb/gadget/Kconfig |1 +
 drivers/usb/gadget/cdc2.c  |   84 ++-
 2 files changed, 52 insertions(+), 33 deletions(-)

diff --git a/drivers/usb/gadget/Kconfig b/drivers/usb/gadget/Kconfig
index bcadb5c..d064e0f 100644
--- a/drivers/usb/gadget/Kconfig
+++ b/drivers/usb/gadget/Kconfig
@@ -890,6 +890,7 @@ config USB_CDC_COMPOSITE
select USB_U_SERIAL
select USB_U_ETHER
select USB_F_ACM
+   select USB_F_ECM
help
  This driver provides two functions in one configuration:
  a CDC Ethernet (ECM) link, and a CDC ACM (serial port) link.
diff --git a/drivers/usb/gadget/cdc2.c b/drivers/usb/gadget/cdc2.c
index a0cba7e..b80b963 100644
--- a/drivers/usb/gadget/cdc2.c
+++ b/drivers/usb/gadget/cdc2.c
@@ -15,6 +15,7 @@
 
 #include "u_ether.h"
 #include "u_serial.h"
+#include "u_ecm.h"
 
 
 #define DRIVER_DESC"CDC Composite Gadget"
@@ -32,21 +33,10 @@
 #define CDC_VENDOR_NUM 0x0525  /* NetChip */
 #define CDC_PRODUCT_NUM0xa4aa  /* CDC Composite: ECM + ACM */
 
-/*-*/
 USB_GADGET_COMPOSITE_OPTIONS();
 
 USB_ETHERNET_MODULE_PARAMETERS();
 
-/*
- * Kbuild is not very cooperative with respect to linking separately
- * compiled library objects into one module.  So for now we won't use
- * separate compilation ... ensuring init/exit sections work to shrink
- * the runtime footprint, and giving us at least some parts of what
- * a "gcc --combine ... part1.c part2.c part3.c ... " build would.
- */
-#define USBF_ECM_INCLUDED
-#include "f_ecm.c"
-
 /*-*/
 
 static struct usb_device_descriptor device_desc = {
@@ -104,44 +94,54 @@ static struct usb_gadget_strings *dev_strings[] = {
NULL,
 };
 
-static u8 host_mac[ETH_ALEN];
-static struct eth_dev *the_dev;
 /*-*/
 static struct usb_function *f_acm;
 static struct usb_function_instance *fi_serial;
 
+static struct usb_function_instance *fi_ecm;
+static struct usb_function *f_ecm;
+
 /*
  * We _always_ have both CDC ECM and CDC ACM functions.
  */
 static int __init cdc_do_config(struct usb_configuration *c)
 {
-   int status;
+   int status;
 
if (gadget_is_otg(c->cdev->gadget)) {
c->descriptors = otg_desc;
c->bmAttributes |= USB_CONFIG_ATT_WAKEUP;
}
 
-   status = ecm_bind_config(c, host_mac, the_dev);
-   if (status < 0)
-   return status;
+   f_ecm = usb_get_function(fi_ecm);
+   if (IS_ERR(f_ecm)) {
+   status = PTR_ERR(f_ecm);
+   goto err_get_ecm;
+   }
 
-   fi_serial = usb_get_function_instance("acm");
-   if (IS_ERR(fi_serial))
-   return PTR_ERR(fi_serial);
+   status = usb_add_function(c, f_ecm);
+   if (status < 0)
+   goto err_add_ecm;
 
f_acm = usb_get_function(fi_serial);
-   if (IS_ERR(f_acm))
-   goto err_func_acm;
+   if (IS_ERR(f_acm)) {
+   status = PTR_ERR(f_acm);
+   goto err_get_acm;
+   }
 
status = usb_add_function(c, f_acm);
if (status)
-   goto err_conf;
+   goto err_add_acm;
+
return 0;
-err_conf:
+
+err_add_acm:
usb_put_function(f_acm);
-err_func_acm:
-   usb_put_function_instance(fi_serial);
+err_get_acm:
+   usb_remove_function(c, f_ecm);
+err_add_ecm:
+   usb_put_function(f_ecm);
+err_get_ecm:
return status;
 }
 
@@ -157,6 +157,7 @@ static struct usb_configuration cdc_config_driver = {
 static int __init cdc_bind(struct usb_composite_dev *cdev)
 {
struct usb_gadget   *gadget = cdev->gadget;
+   struct f_ecm_opts   *ecm_opts;
int status;
 
if (!can_support_ecm(cdev->gadget)) {
@@ -165,11 +166,23 @@ static int __init cdc_bind(struct usb_composite_dev *cdev)
return -EINVAL;
}
 
-   /* set up network link layer */
-   the_dev = gether_setup(cdev->gadget, dev_addr, host_addr, host_mac,
-  qmult);
-   if (IS_ERR(the_dev))
-   return PTR_ERR(the_dev);
+   fi_ecm = usb_get_function_instance("ecm");
+   if (IS_ERR(fi_ecm))
+   return PTR_ERR(fi_ecm);
+
+   ecm_opts = container_of(fi_ecm, struct f_ecm_opts, func_inst);
+
+   gether_set_qmult(ecm_opts->net, qmult);
+   if (!gether_set_host_addr(ecm_opts->net, host_addr))
+   pr_info("using host ethernet address: %s", host_addr);
+   if (!gether_set_dev_addr(ecm_opts->net, dev_addr))
+   pr_info("using self ethernet address: %s", dev_addr);
+
+   fi_serial = usb_get_function_instance("acm");
+   if (IS_ERR(fi_ser

Re: [PATCH] usb: chipidea: udc: configure iso endpoints

2013-05-15 Thread Michael Grzeschik
Hi Peter,

On Wed, May 15, 2013 at 02:07:44AM +, Chen Peter-B29397 wrote:
>  
> > 
> > This patch adds iso endpoint support to the device controller.
> > It makes use of the multiplication bits in the maxpacket field
> > of the endpoint and calculates the multiplier bits for each
> > transfer description on every request.
> > 
> > Signed-off-by: Michael Grzeschik 
> > ---
> >  drivers/usb/chipidea/core.c |  2 +-
> >  drivers/usb/chipidea/udc.c  | 19 ++-
> >  drivers/usb/chipidea/udc.h  |  1 +
> >  3 files changed, 20 insertions(+), 2 deletions(-)
> > 
> > diff --git a/drivers/usb/chipidea/core.c b/drivers/usb/chipidea/core.c
> > index 450107e..3cdb889 100644
> > --- a/drivers/usb/chipidea/core.c
> > +++ b/drivers/usb/chipidea/core.c
> > @@ -43,7 +43,7 @@
> >   *
> >   * TODO List
> >   * - OTG
> > - * - Isochronous & Interrupt Traffic
> > + * - Interrupt Traffic
> >   * - Handle requests which spawns into several TDs
> >   * - GET_STATUS(device) - always reports 0
> >   * - Gadget API (majority of optional features)
> > diff --git a/drivers/usb/chipidea/udc.c b/drivers/usb/chipidea/udc.c
> > index 3d90e61..84f5ec0 100644
> > --- a/drivers/usb/chipidea/udc.c
> > +++ b/drivers/usb/chipidea/udc.c
> > @@ -466,6 +466,13 @@ static int _hardware_enqueue(struct ci13xxx_ep *mEp,
> > struct ci13xxx_req *mReq)
> > mEp->qh.ptr->td.token &=
> > cpu_to_le32(~(TD_STATUS_HALTED|TD_STATUS_ACTIVE));
> > 
> > +   if (mEp->type == USB_ENDPOINT_XFER_ISOC) {
> > +   u32 mul = mReq->req.length >> __ffs(mEp->ep.maxpacket);
> > +   if (mReq->req.length & ~(mul << __ffs(mEp->ep.maxpacket)))
> > +   mul++;
> > +   mEp->qh.ptr->cap |= mul << __ffs(QH_MULT);
> > +   }
> > +
> 
> I think it is a little hard to read, why not
> if (mEp->type == USB_ENDPOINT_XFER_ISOC) {
>   u32 mul = mReq->req.length / mEp->ep.maxpacket;
>   if (mReq->req.length % mEp->ep.maxpacket)
>   mul++;
>   mEp->qh.ptr->cap |= mul << __ffs(QH_MULT);

Right, will change.

>   }
> 
> > wmb();   /* synchronize before ep prime */
> > 
> > ret = hw_ep_prime(ci, mEp->num, mEp->dir,
> > @@ -678,6 +685,12 @@ static int _ep_queue(struct usb_ep *ep, struct
> > usb_request *req,
> > }
> > }
> > 
> > +   if (usb_endpoint_xfer_isoc(mEp->ep.desc)
> > +   && mReq->req.length > (1 + mEp->ep.mult) * mEp->ep.maxpacket) {
> > +   dev_err(mEp->ci->dev, "request length to big for
> > isochronous\n");
> > +   return -EMSGSIZE;
> > +   }
> > +
> 
> typo, "too big"
> the request length should be less than 3*1024. 

Why not additionally depend on the currently configured
multiplier for the endpoint.

> 
> > /* first nuke then test link, e.g. previous status has not sent */
> > if (!list_empty(&mReq->queue)) {
> > dev_err(mEp->ci->dev, "request already in queue\n");
> > @@ -1060,7 +1073,8 @@ static int ep_enable(struct usb_ep *ep,
> > mEp->num  = usb_endpoint_num(desc);
> > mEp->type = usb_endpoint_type(desc);
> > 
> > -   mEp->ep.maxpacket = usb_endpoint_maxp(desc);
> > +   mEp->ep.maxpacket = usb_endpoint_maxp(desc) & 0x07ff;
> > +   mEp->ep.mult = QH_ISO_MULT(usb_endpoint_maxp(desc));
> > 
> 
> The above change doesn't need.
> maxpacket <= 1024 for high speed
> maxpacket <= 1023 for full speed
> For high speed high bandwidth, it just has two or three transactions per 
> microframe

High bandwidth enpoints have multiplier encoded bits in the
wMaxPacketSize value. This has to be dynamically handled here.

>From dummy_hcd.c @434
--8<---8<--
/*
 * For HS/FS devices only bits 0..10 of the wMaxPacketSize represent the
 * maximum packet size.
 * For SS devices the wMaxPacketSize is limited by 1024.
 */
max = usb_endpoint_maxp(desc) & 0x7ff;
--8<---8<--

Its probably worth a seperate patch.

> 
> > if (mEp->type == USB_ENDPOINT_XFER_CONTROL)
> > cap |= QH_IOS;
> > @@ -1246,6 +1260,9 @@ static int ep_set_halt(struct usb_ep *ep, int value)
> > if (ep == NULL || m p->ep.desc == NULL)
> > return -EINVAL;
> > 
> > +   if (usb_endpoint_xfer_isoc(mEp->ep.desc))
> > +   return -EOPNOTSUPP;
> > +
> > spin_lock_irqsave(mEp->lock, flags);
> > 
> >  #ifndef STALL_IN
> > diff --git a/drivers/usb/chipidea/udc.h b/drivers/usb/chipidea/udc.h
> > index d12e8b5..a75724a 100644
> > --- a/drivers/usb/chipidea/udc.h
> > +++ b/drivers/usb/chipidea/udc.h
> > @@ -50,6 +50,7 @@ struct ci13xxx_qh {
> >  #define QH_MAX_PKT(0x07FFUL << 16)
> >  #define QH_ZLTBIT(29)
> >  #define QH_MULT   (0x0003UL << 30)
> > +#define QH_ISO_MULT(x) ((x >> 11) & 0x03)
> > /* 1 */
> > u32 curr;
> > /* 2 - 8 */
> > --
> > 1.8.2.rc2
> > 

Thanks,
Michael

-- 
Pengutronix e.K.   | |
Industrial Linux Sol

[PATCH 02/39] dmaengine: ste_dma40: Remove unnecessary call to d40_phy_cfg()

2013-05-15 Thread Lee Jones
All configuration left in d40_phy_cfg() is runtime configurable and
there is already a call into it from d40_runtime_config(), so let's
rely on that.

Acked-by: Vinod Koul 
Acked-by: Arnd Bergmann 
Signed-off-by: Lee Jones 
---
 drivers/dma/ste_dma40.c|   14 +++---
 drivers/dma/ste_dma40_ll.c |  101 +---
 drivers/dma/ste_dma40_ll.h |3 +-
 3 files changed, 58 insertions(+), 60 deletions(-)

diff --git a/drivers/dma/ste_dma40.c b/drivers/dma/ste_dma40.c
index 759293e..b7fe46b 100644
--- a/drivers/dma/ste_dma40.c
+++ b/drivers/dma/ste_dma40.c
@@ -2043,6 +2043,14 @@ static int d40_config_memcpy(struct d40_chan *d40c)
} else if (dma_has_cap(DMA_MEMCPY, cap) &&
   dma_has_cap(DMA_SLAVE, cap)) {
d40c->dma_cfg = dma40_memcpy_conf_phy;
+
+   /* Generate interrrupt at end of transfer or relink. */
+   d40c->dst_def_cfg |= BIT(D40_SREG_CFG_TIM_POS);
+
+   /* Generate interrupt on error. */
+   d40c->src_def_cfg |= BIT(D40_SREG_CFG_EIM_POS);
+   d40c->dst_def_cfg |= BIT(D40_SREG_CFG_EIM_POS);
+
} else {
chan_err(d40c, "No memcpy\n");
return -EINVAL;
@@ -2496,9 +2504,6 @@ static int d40_alloc_chan_resources(struct dma_chan *chan)
}
 
pm_runtime_get_sync(d40c->base->dev);
-   /* Fill in basic CFG register values */
-   d40_phy_cfg(&d40c->dma_cfg, &d40c->src_def_cfg,
-   &d40c->dst_def_cfg, chan_is_logical(d40c));
 
d40_set_prio_realtime(d40c);
 
@@ -2862,8 +2867,7 @@ static int d40_set_runtime_config(struct dma_chan *chan,
if (chan_is_logical(d40c))
d40_log_cfg(cfg, &d40c->log_def.lcsp1, &d40c->log_def.lcsp3);
else
-   d40_phy_cfg(cfg, &d40c->src_def_cfg,
-   &d40c->dst_def_cfg, false);
+   d40_phy_cfg(cfg, &d40c->src_def_cfg, &d40c->dst_def_cfg);
 
/* These settings will take precedence later */
d40c->runtime_addr = config_addr;
diff --git a/drivers/dma/ste_dma40_ll.c b/drivers/dma/ste_dma40_ll.c
index 435a223..ab5a2a7 100644
--- a/drivers/dma/ste_dma40_ll.c
+++ b/drivers/dma/ste_dma40_ll.c
@@ -50,63 +50,58 @@ void d40_log_cfg(struct stedma40_chan_cfg *cfg,
 
 }
 
-/* Sets up SRC and DST CFG register for both logical and physical channels */
-void d40_phy_cfg(struct stedma40_chan_cfg *cfg,
-u32 *src_cfg, u32 *dst_cfg, bool is_log)
+void d40_phy_cfg(struct stedma40_chan_cfg *cfg, u32 *src_cfg, u32 *dst_cfg)
 {
u32 src = 0;
u32 dst = 0;
 
-   if (!is_log) {
-   /* Physical channel */
-   if ((cfg->dir ==  STEDMA40_PERIPH_TO_MEM) ||
-   (cfg->dir == STEDMA40_PERIPH_TO_PERIPH)) {
-   /* Set master port to 1 */
-   src |= 1 << D40_SREG_CFG_MST_POS;
-   src |= D40_TYPE_TO_EVENT(cfg->dev_type);
-
-   if (cfg->src_info.flow_ctrl == STEDMA40_NO_FLOW_CTRL)
-   src |= 1 << D40_SREG_CFG_PHY_TM_POS;
-   else
-   src |= 3 << D40_SREG_CFG_PHY_TM_POS;
-   }
-   if ((cfg->dir ==  STEDMA40_MEM_TO_PERIPH) ||
-   (cfg->dir == STEDMA40_PERIPH_TO_PERIPH)) {
-   /* Set master port to 1 */
-   dst |= 1 << D40_SREG_CFG_MST_POS;
-   dst |= D40_TYPE_TO_EVENT(cfg->dev_type);
-
-   if (cfg->dst_info.flow_ctrl == STEDMA40_NO_FLOW_CTRL)
-   dst |= 1 << D40_SREG_CFG_PHY_TM_POS;
-   else
-   dst |= 3 << D40_SREG_CFG_PHY_TM_POS;
-   }
-   /* Interrupt on end of transfer for destination */
-   dst |= 1 << D40_SREG_CFG_TIM_POS;
-
-   /* Generate interrupt on error */
-   src |= 1 << D40_SREG_CFG_EIM_POS;
-   dst |= 1 << D40_SREG_CFG_EIM_POS;
-
-   /* PSIZE */
-   if (cfg->src_info.psize != STEDMA40_PSIZE_PHY_1) {
-   src |= 1 << D40_SREG_CFG_PHY_PEN_POS;
-   src |= cfg->src_info.psize << D40_SREG_CFG_PSIZE_POS;
-   }
-   if (cfg->dst_info.psize != STEDMA40_PSIZE_PHY_1) {
-   dst |= 1 << D40_SREG_CFG_PHY_PEN_POS;
-   dst |= cfg->dst_info.psize << D40_SREG_CFG_PSIZE_POS;
-   }
-
-   /* Element size */
-   src |= cfg->src_info.data_width << D40_SREG_CFG_ESIZE_POS;
-   dst |= cfg->dst_info.data_width << D40_SREG_CFG_ESIZE_POS;
-
-   /* Set the priority bit to high for the physical channel */
-   if (cfg->high_priority) {
-   src |= 1 << D40_SREG_CFG_PRI_POS;
-   dst |= 1 << D40_SREG_CFG_PRI_POS;
-  

[PATCH 04/39] ARM: ux500: Stop passing UART's platform data for Device Tree boots

2013-05-15 Thread Lee Jones
It was required to pass DMA channel configuration information to the
UART driver before the new DMA API was in place. Now that it is, and
is fully compatible with Device Tree we can stop doing that.

Reviewed-by: Linus Walleij 
Signed-off-by: Lee Jones 
---
 arch/arm/mach-ux500/cpu-db8500.c |6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/arch/arm/mach-ux500/cpu-db8500.c b/arch/arm/mach-ux500/cpu-db8500.c
index 38ebf2b..9b26fe2 100644
--- a/arch/arm/mach-ux500/cpu-db8500.c
+++ b/arch/arm/mach-ux500/cpu-db8500.c
@@ -230,9 +230,9 @@ static struct of_dev_auxdata u8500_auxdata_lookup[] 
__initdata = {
/* Requires call-back bindings. */
OF_DEV_AUXDATA("arm,cortex-a9-pmu", 0, "arm-pmu", &db8500_pmu_platdata),
/* Requires DMA bindings. */
-   OF_DEV_AUXDATA("arm,pl011", 0x8012, "uart0", &uart0_plat),
-   OF_DEV_AUXDATA("arm,pl011", 0x80121000, "uart1", &uart1_plat),
-   OF_DEV_AUXDATA("arm,pl011", 0x80007000, "uart2", &uart2_plat),
+   OF_DEV_AUXDATA("arm,pl011", 0x8012, "uart0", NULL),
+   OF_DEV_AUXDATA("arm,pl011", 0x80121000, "uart1", NULL),
+   OF_DEV_AUXDATA("arm,pl011", 0x80007000, "uart2", NULL),
OF_DEV_AUXDATA("arm,pl022", 0x80002000, "ssp0",  &ssp0_plat),
OF_DEV_AUXDATA("arm,pl18x", 0x80126000, "sdi0",  &mop500_sdi0_data),
OF_DEV_AUXDATA("arm,pl18x", 0x80118000, "sdi1",  &mop500_sdi1_data),
-- 
1.7.10.4

--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 13/39] crypto: ux500/hash - Set DMA configuration though dma_slave_config()

2013-05-15 Thread Lee Jones
The DMA controller currently takes configuration information from
information passed though dma_channel_request(), but it shouldn't.
Using the API, the DMA channel should only be configured during
a dma_slave_config() call.

Cc: Herbert Xu 
Cc: David S. Miller 
Cc: Andreas Westin 
Cc: linux-cry...@vger.kernel.org
Acked-by: Arnd Bergmann 
Signed-off-by: Lee Jones 
---
 drivers/crypto/ux500/hash/hash_alg.h  |5 -
 drivers/crypto/ux500/hash/hash_core.c |   10 ++
 2 files changed, 14 insertions(+), 1 deletion(-)

diff --git a/drivers/crypto/ux500/hash/hash_alg.h 
b/drivers/crypto/ux500/hash/hash_alg.h
index cd9351c..be6eb54 100644
--- a/drivers/crypto/ux500/hash/hash_alg.h
+++ b/drivers/crypto/ux500/hash/hash_alg.h
@@ -11,6 +11,7 @@
 #include 
 
 #define HASH_BLOCK_SIZE64
+#define HASH_DMA_FIFO  4
 #define HASH_DMA_ALIGN_SIZE4
 #define HASH_DMA_PERFORMANCE_MIN_SIZE  1024
 #define HASH_BYTES_PER_WORD4
@@ -347,7 +348,8 @@ struct hash_req_ctx {
 
 /**
  * struct hash_device_data - structure for a hash device.
- * @base:  Pointer to the hardware base address.
+ * @base:  Pointer to virtual base address of the hash device.
+ * @phybase:   Pointer to physical memory location of the hash device.
  * @list_node: For inclusion in klist.
  * @dev:   Pointer to the device dev structure.
  * @ctx_lock:  Spinlock for current_ctx.
@@ -361,6 +363,7 @@ struct hash_req_ctx {
  */
 struct hash_device_data {
struct hash_register __iomem*base;
+   phys_addr_t phybase;
struct klist_node   list_node;
struct device   *dev;
struct spinlock ctx_lock;
diff --git a/drivers/crypto/ux500/hash/hash_core.c 
b/drivers/crypto/ux500/hash/hash_core.c
index 4b02428..6269576 100644
--- a/drivers/crypto/ux500/hash/hash_core.c
+++ b/drivers/crypto/ux500/hash/hash_core.c
@@ -122,6 +122,13 @@ static void hash_dma_setup_channel(struct hash_device_data 
*device_data,
struct device *dev)
 {
struct hash_platform_data *platform_data = dev->platform_data;
+   struct dma_slave_config conf = {
+   .direction = DMA_MEM_TO_DEV,
+   .dst_addr = device_data->phybase + HASH_DMA_FIFO,
+   .dst_addr_width = DMA_SLAVE_BUSWIDTH_2_BYTES,
+   .dst_maxburst = 16,
+};
+
dma_cap_zero(device_data->dma.mask);
dma_cap_set(DMA_SLAVE, device_data->dma.mask);
 
@@ -131,6 +138,8 @@ static void hash_dma_setup_channel(struct hash_device_data 
*device_data,
platform_data->dma_filter,
device_data->dma.cfg_mem2hash);
 
+   dmaengine_slave_config(device_data->dma.chan_mem2hash, &conf);
+
init_completion(&device_data->dma.complete);
 }
 
@@ -1699,6 +1708,7 @@ static int ux500_hash_probe(struct platform_device *pdev)
goto out_kfree;
}
 
+   device_data->phybase = res->start;
device_data->base = ioremap(res->start, resource_size(res));
if (!device_data->base) {
dev_err(dev, "[%s] ioremap() failed!",
-- 
1.7.10.4

--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 27/39] ARM: ux500: Remove ux500-musb platform registation when booting with DT

2013-05-15 Thread Lee Jones
Now the ux500-musb driver has been enabled for Device Tree, there is no
requirement to register it from platform code.

Acked-by: Fabio Baltieri 
Signed-off-by: Lee Jones 
---
 arch/arm/mach-ux500/cpu-db8500.c |2 --
 1 file changed, 2 deletions(-)

diff --git a/arch/arm/mach-ux500/cpu-db8500.c b/arch/arm/mach-ux500/cpu-db8500.c
index e20bc10..f1e7a75 100644
--- a/arch/arm/mach-ux500/cpu-db8500.c
+++ b/arch/arm/mach-ux500/cpu-db8500.c
@@ -221,8 +221,6 @@ static struct device * __init u8500_of_init_devices(void)
 {
struct device *parent = db8500_soc_device_init();
 
-   db8500_add_usb(parent, usb_db8500_dma_cfg, usb_db8500_dma_cfg);
-
return parent;
 }
 
-- 
1.7.10.4

--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 32/39] ARM: ux500: Remove recently unused stedma40_xfer_dir enums

2013-05-15 Thread Lee Jones
We're now using the transfer direction definitions provided by the DMA
sub-system, so the home-brew ones have become obsolete.

Signed-off-by: Lee Jones 
---
 include/linux/platform_data/dma-ste-dma40.h |   10 +-
 1 file changed, 1 insertion(+), 9 deletions(-)

diff --git a/include/linux/platform_data/dma-ste-dma40.h 
b/include/linux/platform_data/dma-ste-dma40.h
index 288dc24..54ddca6 100644
--- a/include/linux/platform_data/dma-ste-dma40.h
+++ b/include/linux/platform_data/dma-ste-dma40.h
@@ -77,14 +77,6 @@ enum stedma40_periph_data_width {
STEDMA40_DOUBLEWORD_WIDTH = STEDMA40_ESIZE_64_BIT
 };
 
-enum stedma40_xfer_dir {
-   STEDMA40_MEM_TO_MEM = 1,
-   STEDMA40_MEM_TO_PERIPH,
-   STEDMA40_PERIPH_TO_MEM,
-   STEDMA40_PERIPH_TO_PERIPH
-};
-
-
 /**
  * struct stedma40_half_channel_info - dst/src channel configuration
  *
@@ -120,7 +112,7 @@ struct stedma40_half_channel_info {
  *
  */
 struct stedma40_chan_cfg {
-   enum stedma40_xfer_dir   dir;
+   enum dma_transfer_direction  dir;
bool high_priority;
bool realtime;
enum stedma40_mode   mode;
-- 
1.7.10.4

--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 39/39] dmaengine: ste_dma40: Fetch disabled channels from DT

2013-05-15 Thread Lee Jones
Some platforms have channels which are not available for normal use.
This information is currently passed though platform data in internal
BSP kernels. Once those platforms land, they'll need to configure them
appropriately, so we may as well add the infrastructure.

Cc: Vinod Koul 
Cc: Dan Williams 
Cc: Per Forlin 
Cc: Rabin Vincent 
Acked-by: Arnd Bergmann 
Signed-off-by: Lee Jones 
---
 Documentation/devicetree/bindings/dma/ste-dma40.txt |2 ++
 drivers/dma/ste_dma40.c |   17 -
 2 files changed, 18 insertions(+), 1 deletion(-)

diff --git a/Documentation/devicetree/bindings/dma/ste-dma40.txt 
b/Documentation/devicetree/bindings/dma/ste-dma40.txt
index aa272d8..bea5b73 100644
--- a/Documentation/devicetree/bindings/dma/ste-dma40.txt
+++ b/Documentation/devicetree/bindings/dma/ste-dma40.txt
@@ -11,6 +11,7 @@ Required properties:
 Optional properties:
 - dma-channels: Number of channels supported by hardware - if not present
the driver will attempt to obtain the information from H/W
+- disabled-channels: Channels which can not be used
 
 Example:
 
@@ -23,6 +24,7 @@ Example:
 
#dma-cells = <2>;
memcpy-channels  = <56 57 58 59 60>;
+   disabled-channels  = <12>;
dma-channels = <8>;
};
 
diff --git a/drivers/dma/ste_dma40.c b/drivers/dma/ste_dma40.c
index 4e528dd..ffac822 100644
--- a/drivers/dma/ste_dma40.c
+++ b/drivers/dma/ste_dma40.c
@@ -3482,7 +3482,7 @@ static int __init d40_of_probe(struct platform_device 
*pdev,
   struct device_node *np)
 {
struct stedma40_platform_data *pdata;
-   int num_phy = 0, num_memcpy = 0;
+   int num_phy = 0, num_memcpy = 0, num_disabled = 0;
const const __be32 *list;
 
pdata = devm_kzalloc(&pdev->dev,
@@ -3511,6 +3511,21 @@ static int __init d40_of_probe(struct platform_device 
*pdev,
   dma40_memcpy_channels,
   num_memcpy);
 
+   list = of_get_property(np, "disabled-channels", &num_disabled);
+   num_disabled /= sizeof(*list);
+
+   if (num_disabled > STEDMA40_MAX_PHYS || num_disabled < 0) {
+   d40_err(&pdev->dev,
+   "Invalid number of disabled channels specified (%d)\n",
+   num_disabled);
+   return -EINVAL;
+   }
+
+   of_property_read_u32_array(np, "disabled-channels",
+  pdata->disabled_channels,
+  num_disabled);
+   pdata->disabled_channels[num_disabled] = -1;
+
pdev->dev.platform_data = pdata;
 
return 0;
-- 
1.7.10.4

--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 38/39] dmaengine: ste_dma40: Fetch the number of physical channels from DT

2013-05-15 Thread Lee Jones
Some platforms insist on obscure physical channel availability. This
information is currently passed though platform data in internal BSP
kernels. Once those platforms land, they'll need to configure them
appropriately, so we may as well add the infrastructure.

Cc: Vinod Koul 
Cc: Dan Williams 
Cc: Per Forlin 
Cc: Rabin Vincent 
Signed-off-by: Lee Jones 
---
 drivers/dma/ste_dma40.c |7 ++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/drivers/dma/ste_dma40.c b/drivers/dma/ste_dma40.c
index ae462d3..4e528dd 100644
--- a/drivers/dma/ste_dma40.c
+++ b/drivers/dma/ste_dma40.c
@@ -3482,7 +3482,7 @@ static int __init d40_of_probe(struct platform_device 
*pdev,
   struct device_node *np)
 {
struct stedma40_platform_data *pdata;
-   int num_memcpy = 0;
+   int num_phy = 0, num_memcpy = 0;
const const __be32 *list;
 
pdata = devm_kzalloc(&pdev->dev,
@@ -3491,6 +3491,11 @@ static int __init d40_of_probe(struct platform_device 
*pdev,
if (!pdata)
return -ENOMEM;
 
+   /* If absent this value will be obtained from h/w. */
+   of_property_read_u32(np, "dma-channels", &num_phy);
+   if (num_phy > 0)
+   pdata->num_of_phy_chans = num_phy;
+
list = of_get_property(np, "memcpy-channels", &num_memcpy);
num_memcpy /= sizeof(*list);
 
-- 
1.7.10.4

--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 37/39] ARM: ux500: Stop passing DMA platform data though AUXDATA

2013-05-15 Thread Lee Jones
The DMA platform data is now empty due to some recent refactoring,
so there is no longer a requirement to pass it though.

Acked-by: Arnd Bergmann 
Signed-off-by: Lee Jones 
---
 arch/arm/mach-ux500/cpu-db8500.c |3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/arch/arm/mach-ux500/cpu-db8500.c b/arch/arm/mach-ux500/cpu-db8500.c
index b407601..3b77e36 100644
--- a/arch/arm/mach-ux500/cpu-db8500.c
+++ b/arch/arm/mach-ux500/cpu-db8500.c
@@ -259,8 +259,7 @@ static struct of_dev_auxdata u8500_auxdata_lookup[] 
__initdata = {
OF_DEV_AUXDATA("stericsson,ux500-msp-i2s", 0x80125000,
"ux500-msp-i2s.3", &msp3_platform_data),
/* Requires clock name bindings and channel address lookup table. */
-   OF_DEV_AUXDATA("stericsson,db8500-dma40", 0x801C,
-  "dma40.0", &dma40_plat_data),
+   OF_DEV_AUXDATA("stericsson,db8500-dma40", 0x801C, "dma40.0", NULL),
{},
 };
 
-- 
1.7.10.4

--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 36/39] dmaengine: ste_dma40: Allow memcpy channels to be configured from DT

2013-05-15 Thread Lee Jones
At this moment in time the memcpy channels which can be used by the D40
are fixed, as each supported platform in Mainline uses the same ones.
However, platforms do exist which don't follow this convention, so
these will need to be tailored. Fortunately, these platforms will be DT
only, so this change has very little impact on platform data.

Cc: Vinod Koul 
Cc: Dan Williams 
Cc: Per Forlin 
Cc: Rabin Vincent 
Acked-by: Arnd Bergmann 
Signed-off-by: Lee Jones 
---
 .../devicetree/bindings/dma/ste-dma40.txt  |2 +
 drivers/dma/ste_dma40.c|   40 
 include/linux/platform_data/dma-ste-dma40.h|2 +
 3 files changed, 36 insertions(+), 8 deletions(-)

diff --git a/Documentation/devicetree/bindings/dma/ste-dma40.txt 
b/Documentation/devicetree/bindings/dma/ste-dma40.txt
index 2679a87..aa272d8 100644
--- a/Documentation/devicetree/bindings/dma/ste-dma40.txt
+++ b/Documentation/devicetree/bindings/dma/ste-dma40.txt
@@ -6,6 +6,7 @@ Required properties:
 - reg-names: Names of the above areas to use during resource look-up
 - interrupt: Should contain the DMAC interrupt number
 - #dma-cells: must be <3>
+- memcpy-channels: Channels to be used for memcpy
 
 Optional properties:
 - dma-channels: Number of channels supported by hardware - if not present
@@ -21,6 +22,7 @@ Example:
interrupts = <0 25 0x4>;
 
#dma-cells = <2>;
+   memcpy-channels  = <56 57 58 59 60>;
dma-channels = <8>;
};
 
diff --git a/drivers/dma/ste_dma40.c b/drivers/dma/ste_dma40.c
index 76c255f..ae462d3 100644
--- a/drivers/dma/ste_dma40.c
+++ b/drivers/dma/ste_dma40.c
@@ -58,6 +58,8 @@
 #define D40_ALLOC_PHY  BIT(30)
 #define D40_ALLOC_LOG_FREE 0
 
+#define D40_MEMCPY_MAX_CHANS   8
+
 /* Reserved event lines for memcpy only. */
 #define DB8500_DMA_MEMCPY_EV_0 51
 #define DB8500_DMA_MEMCPY_EV_1 56
@@ -522,6 +524,8 @@ struct d40_gen_dmac {
  * @phy_start: Physical memory start of the DMA registers.
  * @phy_size: Size of the DMA register map.
  * @irq: The IRQ number.
+ * @num_memcpy_chans: The number of channels used for memcpy (mem-to-mem
+ * transfers).
  * @num_phy_chans: The number of physical channels. Read from HW. This
  * is the number of available channels for this driver, not counting "Secure
  * mode" allocated physical channels.
@@ -565,6 +569,7 @@ struct d40_base {
phys_addr_t   phy_start;
resource_size_t   phy_size;
int   irq;
+   int   num_memcpy_chans;
int   num_phy_chans;
int   num_log_chans;
struct device_dma_parameters  dma_parms;
@@ -2938,7 +2943,7 @@ static int __init d40_dmaengine_init(struct d40_base 
*base,
}
 
d40_chan_init(base, &base->dma_memcpy, base->log_chans,
- base->num_log_chans, ARRAY_SIZE(dma40_memcpy_channels));
+ base->num_log_chans, base->num_memcpy_chans);
 
dma_cap_zero(base->dma_memcpy.cap_mask);
dma_cap_set(DMA_MEMCPY, base->dma_memcpy.cap_mask);
@@ -3139,6 +3144,7 @@ static struct d40_base * __init d40_hw_detect_init(struct 
platform_device *pdev)
struct d40_base *base = NULL;
int num_log_chans = 0;
int num_phy_chans;
+   int num_memcpy_chans;
int clk_ret = -EINVAL;
int i;
u32 pid;
@@ -3209,6 +3215,12 @@ static struct d40_base * __init 
d40_hw_detect_init(struct platform_device *pdev)
else
num_phy_chans = 4 * (readl(virtbase + D40_DREG_ICFG) & 0x7) + 4;
 
+   /* The number of channels used for memcpy */
+   if (plat_data->num_of_memcpy_chans)
+   num_memcpy_chans = plat_data->num_of_memcpy_chans;
+   else
+   num_memcpy_chans = ARRAY_SIZE(dma40_memcpy_channels);
+
num_log_chans = num_phy_chans * D40_MAX_LOG_CHAN_PER_PHY;
 
dev_info(&pdev->dev,
@@ -3216,7 +3228,7 @@ static struct d40_base * __init d40_hw_detect_init(struct 
platform_device *pdev)
 rev, res->start, num_phy_chans, num_log_chans);
 
base = kzalloc(ALIGN(sizeof(struct d40_base), 4) +
-  (num_phy_chans + num_log_chans + 
ARRAY_SIZE(dma40_memcpy_channels)) *
+  (num_phy_chans + num_log_chans + num_memcpy_chans) *
   sizeof(struct d40_chan), GFP_KERNEL);
 
if (base == NULL) {
@@ -3226,6 +3238,7 @@ static struct d40_base * __init d40_hw_detect_init(struct 
platform_device *pdev)
 
base->rev = rev;
base->clk = clk;
+   base->num_memcpy_chans = num_memcpy_chans;
base->num_phy_chans = num_phy_chans;
base->num_log_chans = num_log_chans;
base->phy_start = res->start;
@@ -3469,12 +3482,8 @@ static int __init d40_of_probe(struct platform_device 
*pdev,
   

[PATCH 35/39] dmaengine: ste_dma40_ll: Replace meaningless register set with comment

2013-05-15 Thread Lee Jones
Unsure of the author's intentions, rather than just removing the nop,
we're replacing it with a comment containing the possible intention
of the statement OR:ing with 0.

Cc: Vinod Koul 
Cc: Dan Williams 
Cc: Per Forlin 
Cc: Rabin Vincent 
Signed-off-by: Lee Jones 
---
 drivers/dma/ste_dma40_ll.c |6 --
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/drivers/dma/ste_dma40_ll.c b/drivers/dma/ste_dma40_ll.c
index a035dfe..27b818d 100644
--- a/drivers/dma/ste_dma40_ll.c
+++ b/drivers/dma/ste_dma40_ll.c
@@ -182,8 +182,10 @@ static int d40_phy_fill_lli(struct d40_phy_lli *lli,
else
lli->reg_cfg &= ~BIT(D40_SREG_CFG_TIM_POS);
 
-   /* Post link */
-   lli->reg_lnk |= 0 << D40_SREG_LNK_PHY_PRE_POS;
+   /*
+* Post link - D40_SREG_LNK_PHY_PRE_POS = 0
+* Relink happens after transfer completion.
+*/
 
return 0;
 }
-- 
1.7.10.4

--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 24/39] usb: musb: ux500: attempt to find channels by name before using pdata

2013-05-15 Thread Lee Jones
If we can ever get to a state where we can solely search for DMA channels
by name, this will almost completely alleviate the requirement to pass
copious amounts of information though platform data. Here we take the
first step towards this. The next step will be to enable Device Tree
complete with name<->event_line mapping.

Cc: Felipe Balbi 
Cc: linux-usb@vger.kernel.org
Acked-by: Linus Walleij 
Acked-by: Fabio Baltieri 
Signed-off-by: Lee Jones 
---
 drivers/usb/musb/ux500_dma.c |   20 +---
 1 file changed, 17 insertions(+), 3 deletions(-)

diff --git a/drivers/usb/musb/ux500_dma.c b/drivers/usb/musb/ux500_dma.c
index 4bd5400..7d80699 100644
--- a/drivers/usb/musb/ux500_dma.c
+++ b/drivers/usb/musb/ux500_dma.c
@@ -34,6 +34,11 @@
 #include 
 #include "musb_core.h"
 
+static const char *iep_chan_names[] = { "iep_1_9", "iep_2_10", "iep_3_11", 
"iep_4_12",
+   "iep_5_13", "iep_6_14", "iep_7_15", 
"iep_8" };
+static const char *oep_chan_names[] = { "oep_1_9", "oep_2_10", "oep_3_11", 
"oep_4_12",
+   "oep_5_13", "oep_6_14", "oep_7_15", 
"oep_8" };
+
 struct ux500_dma_channel {
struct dma_channel channel;
struct ux500_dma_controller *controller;
@@ -291,6 +296,7 @@ static int ux500_dma_controller_start(struct dma_controller 
*c)
struct musb_hdrc_platform_data *plat = dev->platform_data;
struct ux500_musb_board_data *data;
struct dma_channel *dma_channel = NULL;
+   char **chan_names;
u32 ch_num;
u8 dir;
u8 is_tx = 0;
@@ -312,6 +318,7 @@ static int ux500_dma_controller_start(struct dma_controller 
*c)
/* Prepare the loop for RX channels */
channel_array = controller->rx_channel;
param_array = data ? data->dma_rx_param_array : NULL;
+   chan_names = (char **)iep_chan_names;
 
for (dir = 0; dir < 2; dir++) {
for (ch_num = 0;
@@ -327,9 +334,15 @@ static int ux500_dma_controller_start(struct 
dma_controller *c)
dma_channel->status = MUSB_DMA_STATUS_FREE;
dma_channel->max_len = SZ_16M;
 
-   ux500_channel->dma_chan = dma_request_channel(mask,
-   data->dma_filter,
-   param_array[ch_num]);
+   ux500_channel->dma_chan =
+   dma_request_slave_channel(dev, 
chan_names[ch_num]);
+
+   if (!ux500_channel->dma_chan)
+   ux500_channel->dma_chan =
+   dma_request_channel(mask,
+   data->dma_filter,
+   
param_array[ch_num]);
+
if (!ux500_channel->dma_chan) {
ERR("Dma pipe allocation error dir=%d ch=%d\n",
dir, ch_num);
@@ -345,6 +358,7 @@ static int ux500_dma_controller_start(struct dma_controller 
*c)
/* Prepare the loop for TX channels */
channel_array = controller->tx_channel;
param_array = data ? data->dma_tx_param_array : NULL;
+   chan_names = (char **)oep_chan_names;
is_tx = 1;
}
 
-- 
1.7.10.4

--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 33/39] dmaengine: ste_dma40_ll: Use the BIT macro to replace ugly '(1 << x)'s

2013-05-15 Thread Lee Jones
The aim is to make the code that little more readable.

Cc: Vinod Koul 
Cc: Dan Williams 
Cc: Per Forlin 
Cc: Rabin Vincent 
Signed-off-by: Lee Jones 
---
 drivers/dma/ste_dma40_ll.c |   44 ++--
 1 file changed, 22 insertions(+), 22 deletions(-)

diff --git a/drivers/dma/ste_dma40_ll.c b/drivers/dma/ste_dma40_ll.c
index 121c0ce..5ddd724 100644
--- a/drivers/dma/ste_dma40_ll.c
+++ b/drivers/dma/ste_dma40_ll.c
@@ -20,28 +20,28 @@ void d40_log_cfg(struct stedma40_chan_cfg *cfg,
/* src is mem? -> increase address pos */
if (cfg->dir ==  DMA_MEM_TO_DEV ||
cfg->dir ==  DMA_MEM_TO_MEM)
-   l1 |= 1 << D40_MEM_LCSP1_SCFG_INCR_POS;
+   l1 |= BIT(D40_MEM_LCSP1_SCFG_INCR_POS);
 
/* dst is mem? -> increase address pos */
if (cfg->dir ==  DMA_DEV_TO_MEM ||
cfg->dir ==  DMA_MEM_TO_MEM)
-   l3 |= 1 << D40_MEM_LCSP3_DCFG_INCR_POS;
+   l3 |= BIT(D40_MEM_LCSP3_DCFG_INCR_POS);
 
/* src is hw? -> master port 1 */
if (cfg->dir ==  DMA_DEV_TO_MEM ||
cfg->dir ==  DMA_DEV_TO_DEV)
-   l1 |= 1 << D40_MEM_LCSP1_SCFG_MST_POS;
+   l1 |= BIT(D40_MEM_LCSP1_SCFG_MST_POS);
 
/* dst is hw? -> master port 1 */
if (cfg->dir ==  DMA_MEM_TO_DEV ||
cfg->dir ==  DMA_DEV_TO_DEV)
-   l3 |= 1 << D40_MEM_LCSP3_DCFG_MST_POS;
+   l3 |= BIT(D40_MEM_LCSP3_DCFG_MST_POS);
 
-   l3 |= 1 << D40_MEM_LCSP3_DCFG_EIM_POS;
+   l3 |= BIT(D40_MEM_LCSP3_DCFG_EIM_POS);
l3 |= cfg->dst_info.psize << D40_MEM_LCSP3_DCFG_PSIZE_POS;
l3 |= cfg->dst_info.data_width << D40_MEM_LCSP3_DCFG_ESIZE_POS;
 
-   l1 |= 1 << D40_MEM_LCSP1_SCFG_EIM_POS;
+   l1 |= BIT(D40_MEM_LCSP1_SCFG_EIM_POS);
l1 |= cfg->src_info.psize << D40_MEM_LCSP1_SCFG_PSIZE_POS;
l1 |= cfg->src_info.data_width << D40_MEM_LCSP1_SCFG_ESIZE_POS;
 
@@ -58,39 +58,39 @@ void d40_phy_cfg(struct stedma40_chan_cfg *cfg, u32 
*src_cfg, u32 *dst_cfg)
if ((cfg->dir == DMA_DEV_TO_MEM) ||
(cfg->dir == DMA_DEV_TO_DEV)) {
/* Set master port to 1 */
-   src |= 1 << D40_SREG_CFG_MST_POS;
+   src |= BIT(D40_SREG_CFG_MST_POS);
src |= D40_TYPE_TO_EVENT(cfg->dev_type);
 
if (cfg->src_info.flow_ctrl == STEDMA40_NO_FLOW_CTRL)
-   src |= 1 << D40_SREG_CFG_PHY_TM_POS;
+   src |= BIT(D40_SREG_CFG_PHY_TM_POS);
else
src |= 3 << D40_SREG_CFG_PHY_TM_POS;
}
if ((cfg->dir == DMA_MEM_TO_DEV) ||
(cfg->dir == DMA_DEV_TO_DEV)) {
/* Set master port to 1 */
-   dst |= 1 << D40_SREG_CFG_MST_POS;
+   dst |= BIT(D40_SREG_CFG_MST_POS);
dst |= D40_TYPE_TO_EVENT(cfg->dev_type);
 
if (cfg->dst_info.flow_ctrl == STEDMA40_NO_FLOW_CTRL)
-   dst |= 1 << D40_SREG_CFG_PHY_TM_POS;
+   dst |= BIT(D40_SREG_CFG_PHY_TM_POS);
else
dst |= 3 << D40_SREG_CFG_PHY_TM_POS;
}
/* Interrupt on end of transfer for destination */
-   dst |= 1 << D40_SREG_CFG_TIM_POS;
+   dst |= BIT(D40_SREG_CFG_TIM_POS);
 
/* Generate interrupt on error */
-   src |= 1 << D40_SREG_CFG_EIM_POS;
-   dst |= 1 << D40_SREG_CFG_EIM_POS;
+   src |= BIT(D40_SREG_CFG_EIM_POS);
+   dst |= BIT(D40_SREG_CFG_EIM_POS);
 
/* PSIZE */
if (cfg->src_info.psize != STEDMA40_PSIZE_PHY_1) {
-   src |= 1 << D40_SREG_CFG_PHY_PEN_POS;
+   src |= BIT(D40_SREG_CFG_PHY_PEN_POS);
src |= cfg->src_info.psize << D40_SREG_CFG_PSIZE_POS;
}
if (cfg->dst_info.psize != STEDMA40_PSIZE_PHY_1) {
-   dst |= 1 << D40_SREG_CFG_PHY_PEN_POS;
+   dst |= BIT(D40_SREG_CFG_PHY_PEN_POS);
dst |= cfg->dst_info.psize << D40_SREG_CFG_PSIZE_POS;
}
 
@@ -100,14 +100,14 @@ void d40_phy_cfg(struct stedma40_chan_cfg *cfg, u32 
*src_cfg, u32 *dst_cfg)
 
/* Set the priority bit to high for the physical channel */
if (cfg->high_priority) {
-   src |= 1 << D40_SREG_CFG_PRI_POS;
-   dst |= 1 << D40_SREG_CFG_PRI_POS;
+   src |= BIT(D40_SREG_CFG_PRI_POS);
+   dst |= BIT(D40_SREG_CFG_PRI_POS);
}
 
if (cfg->src_info.big_endian)
-   src |= 1 << D40_SREG_CFG_LBE_POS;
+   src |= BIT(D40_SREG_CFG_LBE_POS);
if (cfg->dst_info.big_endian)
-   dst |= 1 << D40_SREG_CFG_LBE_POS;
+   dst |= BIT(D40_SREG_CFG_LBE_POS);
 
*src_cfg = src;
*dst_cfg = dst;
@@ -157,15 +157,15 @@ static int d40_phy_fill_lli(struct d40_phy_lli *lli,
 
/* If this scatter list entry is the last one, no next link */
if (next_lli == 0)
-  

[PATCH 34/39] dmaengine: ste_dma40: Convert data_width from register bit format to value

2013-05-15 Thread Lee Jones
When a DMA client requests and configures a DMA channel, it requests
data_width in Bytes. The DMA40 driver then swiftly converts it over to
the necessary register bit value. Unfortunately, for any subsequent
calculations we have to shift '1' by the bit pattern (1 << data_width)
times to make any sense of it.

This patch flips the semantics on its head and only converts the value
to its respective register bit pattern when writing to registers. This
way we can use the true data_width (in Bytes) value.

Cc: Vinod Koul 
Cc: Dan Williams 
Cc: Per Forlin 
Cc: Rabin Vincent 
Signed-off-by: Lee Jones 
---
 drivers/dma/ste_dma40.c |   63 +++
 drivers/dma/ste_dma40_ll.c  |   43 --
 include/linux/platform_data/dma-ste-dma40.h |9 +---
 sound/soc/ux500/ux500_pcm.c |   10 ++---
 4 files changed, 60 insertions(+), 65 deletions(-)

diff --git a/drivers/dma/ste_dma40.c b/drivers/dma/ste_dma40.c
index 483da16..76c255f 100644
--- a/drivers/dma/ste_dma40.c
+++ b/drivers/dma/ste_dma40.c
@@ -80,11 +80,11 @@ struct stedma40_chan_cfg dma40_memcpy_conf_phy = {
.mode = STEDMA40_MODE_PHYSICAL,
.dir = DMA_MEM_TO_MEM,
 
-   .src_info.data_width = STEDMA40_BYTE_WIDTH,
+   .src_info.data_width = DMA_SLAVE_BUSWIDTH_1_BYTE,
.src_info.psize = STEDMA40_PSIZE_PHY_1,
.src_info.flow_ctrl = STEDMA40_NO_FLOW_CTRL,
 
-   .dst_info.data_width = STEDMA40_BYTE_WIDTH,
+   .dst_info.data_width = DMA_SLAVE_BUSWIDTH_1_BYTE,
.dst_info.psize = STEDMA40_PSIZE_PHY_1,
.dst_info.flow_ctrl = STEDMA40_NO_FLOW_CTRL,
 };
@@ -94,11 +94,11 @@ struct stedma40_chan_cfg dma40_memcpy_conf_log = {
.mode = STEDMA40_MODE_LOGICAL,
.dir = DMA_MEM_TO_MEM,
 
-   .src_info.data_width = STEDMA40_BYTE_WIDTH,
+   .src_info.data_width = DMA_SLAVE_BUSWIDTH_1_BYTE,
.src_info.psize = STEDMA40_PSIZE_LOG_1,
.src_info.flow_ctrl = STEDMA40_NO_FLOW_CTRL,
 
-   .dst_info.data_width = STEDMA40_BYTE_WIDTH,
+   .dst_info.data_width = DMA_SLAVE_BUSWIDTH_1_BYTE,
.dst_info.psize = STEDMA40_PSIZE_LOG_1,
.dst_info.flow_ctrl = STEDMA40_NO_FLOW_CTRL,
 };
@@ -1005,20 +1005,21 @@ static int d40_psize_2_burst_size(bool is_log, int 
psize)
 
 /*
  * The dma only supports transmitting packages up to
- * STEDMA40_MAX_SEG_SIZE << data_width. Calculate the total number of
- * dma elements required to send the entire sg list
+ * STEDMA40_MAX_SEG_SIZE * data_width, where data_width is stored in Bytes.
+ *
+ * Calculate the total number of dma elements required to send the entire sg 
list.
  */
 static int d40_size_2_dmalen(int size, u32 data_width1, u32 data_width2)
 {
int dmalen;
u32 max_w = max(data_width1, data_width2);
u32 min_w = min(data_width1, data_width2);
-   u32 seg_max = ALIGN(STEDMA40_MAX_SEG_SIZE << min_w, 1 << max_w);
+   u32 seg_max = ALIGN(STEDMA40_MAX_SEG_SIZE * min_w, max_w);
 
if (seg_max > STEDMA40_MAX_SEG_SIZE)
-   seg_max -= (1 << max_w);
+   seg_max -= max_w;
 
-   if (!IS_ALIGNED(size, 1 << max_w))
+   if (!IS_ALIGNED(size, max_w))
return -EINVAL;
 
if (size <= seg_max)
@@ -1464,7 +1465,7 @@ static u32 d40_residue(struct d40_chan *d40c)
  >> D40_SREG_ELEM_PHY_ECNT_POS;
}
 
-   return num_elt * (1 << d40c->dma_cfg.dst_info.data_width);
+   return num_elt * d40c->dma_cfg.dst_info.data_width;
 }
 
 static bool d40_tx_is_linked(struct d40_chan *d40c)
@@ -1784,9 +1785,9 @@ static int d40_validate_conf(struct d40_chan *d40c,
}
 
if (d40_psize_2_burst_size(is_log, conf->src_info.psize) *
-   (1 << conf->src_info.data_width) !=
+   conf->src_info.data_width !=
d40_psize_2_burst_size(is_log, conf->dst_info.psize) *
-   (1 << conf->dst_info.data_width)) {
+   conf->dst_info.data_width) {
/*
 * The DMAC hardware only supports
 * src (burst x width) == dst (burst x width)
@@ -2673,33 +2674,10 @@ static void d40_terminate_all(struct dma_chan *chan)
 static int
 dma40_config_to_halfchannel(struct d40_chan *d40c,
struct stedma40_half_channel_info *info,
-   enum dma_slave_buswidth width,
u32 maxburst)
 {
-   enum stedma40_periph_data_width addr_width;
int psize;
 
-   switch (width) {
-   case DMA_SLAVE_BUSWIDTH_1_BYTE:
-   addr_width = STEDMA40_BYTE_WIDTH;
-   break;
-   case DMA_SLAVE_BUSWIDTH_2_BYTES:
-   addr_width = STEDMA40_HALFWORD_WIDTH;
-   break;
-   case DMA_SLAVE_BUSWIDTH_4_BYTES:
-   addr_width = STEDMA40_WORD_WIDTH;
-   break;
-   case DMA_SLAVE_BUSWIDTH_8_BYTES:
-   addr_width = STEDMA40_DOUBLEWORD_WIDTH;
-   break;
-   

[PATCH 31/39] dmaengine: ste_dma40: Replace ST-E's home-brew DMA direction defs with generic ones

2013-05-15 Thread Lee Jones
STEDMA40_*_TO_* direction definitions are identical in all but name to
the pre-defined generic DMA_*_TO_* ones. Let's make things easy by not
duplicating such things.

Cc: Vinod Koul 
Cc: Dan Williams 
Cc: Per Forlin 
Cc: Rabin Vincent 
Signed-off-by: Lee Jones 
---
 drivers/dma/ste_dma40.c|   56 ++--
 drivers/dma/ste_dma40_ll.c |   24 +--
 2 files changed, 40 insertions(+), 40 deletions(-)

diff --git a/drivers/dma/ste_dma40.c b/drivers/dma/ste_dma40.c
index 08bc58a..483da16 100644
--- a/drivers/dma/ste_dma40.c
+++ b/drivers/dma/ste_dma40.c
@@ -78,7 +78,7 @@ static int dma40_memcpy_channels[] = {
 /* Default configuration for physcial memcpy */
 struct stedma40_chan_cfg dma40_memcpy_conf_phy = {
.mode = STEDMA40_MODE_PHYSICAL,
-   .dir = STEDMA40_MEM_TO_MEM,
+   .dir = DMA_MEM_TO_MEM,
 
.src_info.data_width = STEDMA40_BYTE_WIDTH,
.src_info.psize = STEDMA40_PSIZE_PHY_1,
@@ -92,7 +92,7 @@ struct stedma40_chan_cfg dma40_memcpy_conf_phy = {
 /* Default configuration for logical memcpy */
 struct stedma40_chan_cfg dma40_memcpy_conf_log = {
.mode = STEDMA40_MODE_LOGICAL,
-   .dir = STEDMA40_MEM_TO_MEM,
+   .dir = DMA_MEM_TO_MEM,
 
.src_info.data_width = STEDMA40_BYTE_WIDTH,
.src_info.psize = STEDMA40_PSIZE_LOG_1,
@@ -843,7 +843,7 @@ static void d40_log_lli_to_lcxa(struct d40_chan *chan, 
struct d40_desc *desc)
 * that uses linked lists.
 */
if (!(chan->phy_chan->use_soft_lli &&
-   chan->dma_cfg.dir == STEDMA40_PERIPH_TO_MEM))
+   chan->dma_cfg.dir == DMA_DEV_TO_MEM))
curr_lcla = d40_lcla_alloc_one(chan, desc);
 
first_lcla = curr_lcla;
@@ -1311,12 +1311,12 @@ static void d40_config_set_event(struct d40_chan *d40c,
u32 event = D40_TYPE_TO_EVENT(d40c->dma_cfg.dev_type);
 
/* Enable event line connected to device (or memcpy) */
-   if ((d40c->dma_cfg.dir ==  STEDMA40_PERIPH_TO_MEM) ||
-   (d40c->dma_cfg.dir == STEDMA40_PERIPH_TO_PERIPH))
+   if ((d40c->dma_cfg.dir == DMA_DEV_TO_MEM) ||
+   (d40c->dma_cfg.dir == DMA_DEV_TO_DEV))
__d40_config_set_event(d40c, event_type, event,
   D40_CHAN_REG_SSLNK);
 
-   if (d40c->dma_cfg.dir !=  STEDMA40_PERIPH_TO_MEM)
+   if (d40c->dma_cfg.dir !=  DMA_DEV_TO_MEM)
__d40_config_set_event(d40c, event_type, event,
   D40_CHAN_REG_SDLNK);
 }
@@ -1774,7 +1774,7 @@ static int d40_validate_conf(struct d40_chan *d40c,
res = -EINVAL;
}
 
-   if (conf->dir == STEDMA40_PERIPH_TO_PERIPH) {
+   if (conf->dir == DMA_DEV_TO_DEV) {
/*
 * DMAC HW supports it. Will be added to this driver,
 * in case any dma client requires it.
@@ -1905,11 +1905,11 @@ static int d40_allocate_channel(struct d40_chan *d40c, 
bool *first_phy_user)
phys = d40c->base->phy_res;
num_phy_chans = d40c->base->num_phy_chans;
 
-   if (d40c->dma_cfg.dir == STEDMA40_PERIPH_TO_MEM) {
+   if (d40c->dma_cfg.dir == DMA_DEV_TO_MEM) {
log_num = 2 * dev_type;
is_src = true;
-   } else if (d40c->dma_cfg.dir == STEDMA40_MEM_TO_PERIPH ||
-  d40c->dma_cfg.dir == STEDMA40_MEM_TO_MEM) {
+   } else if (d40c->dma_cfg.dir == DMA_MEM_TO_DEV ||
+  d40c->dma_cfg.dir == DMA_MEM_TO_MEM) {
/* dst event lines are used for logical memcpy */
log_num = 2 * dev_type + 1;
is_src = false;
@@ -1920,7 +1920,7 @@ static int d40_allocate_channel(struct d40_chan *d40c, 
bool *first_phy_user)
event_line = D40_TYPE_TO_EVENT(dev_type);
 
if (!is_log) {
-   if (d40c->dma_cfg.dir == STEDMA40_MEM_TO_MEM) {
+   if (d40c->dma_cfg.dir == DMA_MEM_TO_MEM) {
/* Find physical half channel */
if (d40c->dma_cfg.use_fixed_channel) {
i = d40c->dma_cfg.phy_channel;
@@ -2068,10 +2068,10 @@ static int d40_free_dma(struct d40_chan *d40c)
return -EINVAL;
}
 
-   if (d40c->dma_cfg.dir == STEDMA40_MEM_TO_PERIPH ||
-   d40c->dma_cfg.dir == STEDMA40_MEM_TO_MEM)
+   if (d40c->dma_cfg.dir == DMA_MEM_TO_DEV ||
+   d40c->dma_cfg.dir == DMA_MEM_TO_MEM)
is_src = false;
-   else if (d40c->dma_cfg.dir == STEDMA40_PERIPH_TO_MEM)
+   else if (d40c->dma_cfg.dir == DMA_DEV_TO_MEM)
is_src = true;
else {
chan_err(d40c, "Unknown direction\n");
@@ -2133,10 +2133,10 @@ static bool d40_is_paused(struct d40_chan *d40c)
goto _exit;
}
 
-   if (d40c->dma_cfg.dir == STEDMA40_MEM_TO_PERIPH ||
-   d40c->dma_cfg.dir == STEDMA40_ME

[PATCH 30/39] ARM: ux500: Replace ST-E's home-brew DMA direction definition with the generic one

2013-05-15 Thread Lee Jones
STEDMA40_*_TO_* direction definitions are identical in all but name to
the pre-defined generic DMA_*_TO_* ones. Let's make things easy by not
duplicating such things.

Signed-off-by: Lee Jones 
---
 arch/arm/mach-ux500/board-mop500-audio.c |   12 ++--
 arch/arm/mach-ux500/board-mop500-sdi.c   |   16 
 arch/arm/mach-ux500/board-mop500.c   |   22 +++---
 arch/arm/mach-ux500/usb.c|4 ++--
 4 files changed, 27 insertions(+), 27 deletions(-)

diff --git a/arch/arm/mach-ux500/board-mop500-audio.c 
b/arch/arm/mach-ux500/board-mop500-audio.c
index ec87262..bfe443d 100644
--- a/arch/arm/mach-ux500/board-mop500-audio.c
+++ b/arch/arm/mach-ux500/board-mop500-audio.c
@@ -21,13 +21,13 @@
 
 static struct stedma40_chan_cfg msp0_dma_rx = {
.high_priority = true,
-   .dir = STEDMA40_PERIPH_TO_MEM,
+   .dir = DMA_DEV_TO_MEM,
.dev_type = DB8500_DMA_DEV31_MSP0_SLIM0_CH0,
 };
 
 static struct stedma40_chan_cfg msp0_dma_tx = {
.high_priority = true,
-   .dir = STEDMA40_MEM_TO_PERIPH,
+   .dir = DMA_MEM_TO_DEV,
.dev_type = DB8500_DMA_DEV31_MSP0_SLIM0_CH0,
 };
 
@@ -39,13 +39,13 @@ struct msp_i2s_platform_data msp0_platform_data = {
 
 static struct stedma40_chan_cfg msp1_dma_rx = {
.high_priority = true,
-   .dir = STEDMA40_PERIPH_TO_MEM,
+   .dir = DMA_DEV_TO_MEM,
.dev_type = DB8500_DMA_DEV30_MSP3,
 };
 
 static struct stedma40_chan_cfg msp1_dma_tx = {
.high_priority = true,
-   .dir = STEDMA40_MEM_TO_PERIPH,
+   .dir = DMA_MEM_TO_DEV,
.dev_type = DB8500_DMA_DEV30_MSP1,
 };
 
@@ -57,13 +57,13 @@ struct msp_i2s_platform_data msp1_platform_data = {
 
 static struct stedma40_chan_cfg msp2_dma_rx = {
.high_priority = true,
-   .dir = STEDMA40_PERIPH_TO_MEM,
+   .dir = DMA_DEV_TO_MEM,
.dev_type = DB8500_DMA_DEV14_MSP2,
 };
 
 static struct stedma40_chan_cfg msp2_dma_tx = {
.high_priority = true,
-   .dir = STEDMA40_MEM_TO_PERIPH,
+   .dir = DMA_MEM_TO_DEV,
.dev_type = DB8500_DMA_DEV14_MSP2,
.use_fixed_channel = true,
.phy_channel = 1,
diff --git a/arch/arm/mach-ux500/board-mop500-sdi.c 
b/arch/arm/mach-ux500/board-mop500-sdi.c
index 29be714..e6891d1 100644
--- a/arch/arm/mach-ux500/board-mop500-sdi.c
+++ b/arch/arm/mach-ux500/board-mop500-sdi.c
@@ -34,13 +34,13 @@
 #ifdef CONFIG_STE_DMA40
 struct stedma40_chan_cfg mop500_sdi0_dma_cfg_rx = {
.mode = STEDMA40_MODE_LOGICAL,
-   .dir = STEDMA40_PERIPH_TO_MEM,
+   .dir = DMA_DEV_TO_MEM,
.dev_type = DB8500_DMA_DEV29_SD_MM0,
 };
 
 static struct stedma40_chan_cfg mop500_sdi0_dma_cfg_tx = {
.mode = STEDMA40_MODE_LOGICAL,
-   .dir = STEDMA40_MEM_TO_PERIPH,
+   .dir = DMA_MEM_TO_DEV,
.dev_type = DB8500_DMA_DEV29_SD_MM0,
 };
 #endif
@@ -81,13 +81,13 @@ void mop500_sdi_tc35892_init(struct device *parent)
 #ifdef CONFIG_STE_DMA40
 static struct stedma40_chan_cfg sdi1_dma_cfg_rx = {
.mode = STEDMA40_MODE_LOGICAL,
-   .dir = STEDMA40_PERIPH_TO_MEM,
+   .dir = DMA_DEV_TO_MEM,
.dev_type = DB8500_DMA_DEV32_SD_MM1,
 };
 
 static struct stedma40_chan_cfg sdi1_dma_cfg_tx = {
.mode = STEDMA40_MODE_LOGICAL,
-   .dir = STEDMA40_MEM_TO_PERIPH,
+   .dir = DMA_MEM_TO_DEV,
.dev_type = DB8500_DMA_DEV32_SD_MM1,
 };
 #endif
@@ -112,13 +112,13 @@ struct mmci_platform_data mop500_sdi1_data = {
 #ifdef CONFIG_STE_DMA40
 struct stedma40_chan_cfg mop500_sdi2_dma_cfg_rx = {
.mode = STEDMA40_MODE_LOGICAL,
-   .dir = STEDMA40_PERIPH_TO_MEM,
+   .dir = DMA_DEV_TO_MEM,
.dev_type =  DB8500_DMA_DEV28_SD_MM2,
 };
 
 static struct stedma40_chan_cfg mop500_sdi2_dma_cfg_tx = {
.mode = STEDMA40_MODE_LOGICAL,
-   .dir = STEDMA40_MEM_TO_PERIPH,
+   .dir = DMA_MEM_TO_DEV,
.dev_type = DB8500_DMA_DEV28_SD_MM2,
 };
 #endif
@@ -144,13 +144,13 @@ struct mmci_platform_data mop500_sdi2_data = {
 #ifdef CONFIG_STE_DMA40
 struct stedma40_chan_cfg mop500_sdi4_dma_cfg_rx = {
.mode = STEDMA40_MODE_LOGICAL,
-   .dir = STEDMA40_PERIPH_TO_MEM,
+   .dir = DMA_DEV_TO_MEM,
.dev_type =  DB8500_DMA_DEV42_SD_MM4,
 };
 
 static struct stedma40_chan_cfg mop500_sdi4_dma_cfg_tx = {
.mode = STEDMA40_MODE_LOGICAL,
-   .dir = STEDMA40_MEM_TO_PERIPH,
+   .dir = DMA_MEM_TO_DEV,
.dev_type = DB8500_DMA_DEV42_SD_MM4,
 };
 #endif
diff --git a/arch/arm/mach-ux500/board-mop500.c 
b/arch/arm/mach-ux500/board-mop500.c
index ba26ae3..0b018c4 100644
--- a/arch/arm/mach-ux500/board-mop500.c
+++ b/arch/arm/mach-ux500/board-mop500.c
@@ -424,19 +424,19 @@ void mop500_snowball_ethernet_clock_enable(void)
 
 static struct cryp_platform_data u8500_cryp1_platform_data = {
.mem_to_engine = {
-   .dir = STEDMA40_MEM_TO_PERIPH,
+   .dir = DMA_MEM_TO_DEV,
.dev_type = DB8500

[PATCH 29/39] dmaengine: ste_dma40: Use the BIT macro to replace ugly '(1 << x)'s

2013-05-15 Thread Lee Jones
The aim is to make the code that little more readable.

Acked-by: Vinod Koul 
Acked-by: Arnd Bergmann 
Reviewed-by: Linus Walleij 
Signed-off-by: Lee Jones 
---
 drivers/dma/ste_dma40.c |   20 ++--
 1 file changed, 10 insertions(+), 10 deletions(-)

diff --git a/drivers/dma/ste_dma40.c b/drivers/dma/ste_dma40.c
index 6ed7757..08bc58a 100644
--- a/drivers/dma/ste_dma40.c
+++ b/drivers/dma/ste_dma40.c
@@ -54,8 +54,8 @@
 #define MAX_LCLA_ALLOC_ATTEMPTS 256
 
 /* Bit markings for allocation map */
-#define D40_ALLOC_FREE (1 << 31)
-#define D40_ALLOC_PHY  (1 << 30)
+#define D40_ALLOC_FREE BIT(31)
+#define D40_ALLOC_PHY  BIT(30)
 #define D40_ALLOC_LOG_FREE 0
 
 /* Reserved event lines for memcpy only. */
@@ -1738,7 +1738,7 @@ static irqreturn_t d40_handle_interrupt(int irq, void 
*data)
}
 
/* ACK interrupt */
-   writel(1 << idx, base->virtbase + il[row].clr);
+   writel(BIT(idx), base->virtbase + il[row].clr);
 
spin_lock(&d40c->lock);
 
@@ -1828,8 +1828,8 @@ static bool d40_alloc_mask_set(struct d40_phy_res *phy,
if (phy->allocated_src == D40_ALLOC_FREE)
phy->allocated_src = D40_ALLOC_LOG_FREE;
 
-   if (!(phy->allocated_src & (1 << log_event_line))) {
-   phy->allocated_src |= 1 << log_event_line;
+   if (!(phy->allocated_src & BIT(log_event_line))) {
+   phy->allocated_src |= BIT(log_event_line);
goto found;
} else
goto not_found;
@@ -1840,8 +1840,8 @@ static bool d40_alloc_mask_set(struct d40_phy_res *phy,
if (phy->allocated_dst == D40_ALLOC_FREE)
phy->allocated_dst = D40_ALLOC_LOG_FREE;
 
-   if (!(phy->allocated_dst & (1 << log_event_line))) {
-   phy->allocated_dst |= 1 << log_event_line;
+   if (!(phy->allocated_dst & BIT(log_event_line))) {
+   phy->allocated_dst |= BIT(log_event_line);
goto found;
} else
goto not_found;
@@ -1871,11 +1871,11 @@ static bool d40_alloc_mask_free(struct d40_phy_res 
*phy, bool is_src,
 
/* Logical channel */
if (is_src) {
-   phy->allocated_src &= ~(1 << log_event_line);
+   phy->allocated_src &= ~BIT(log_event_line);
if (phy->allocated_src == D40_ALLOC_LOG_FREE)
phy->allocated_src = D40_ALLOC_FREE;
} else {
-   phy->allocated_dst &= ~(1 << log_event_line);
+   phy->allocated_dst &= ~BIT(log_event_line);
if (phy->allocated_dst == D40_ALLOC_LOG_FREE)
phy->allocated_dst = D40_ALLOC_FREE;
}
@@ -2356,7 +2356,7 @@ static void __d40_set_prio_rt(struct d40_chan *d40c, int 
dev_type, bool src)
u32 rtreg;
u32 event = D40_TYPE_TO_EVENT(dev_type);
u32 group = D40_TYPE_TO_GROUP(dev_type);
-   u32 bit = 1 << event;
+   u32 bit = BIT(event);
u32 prioreg;
struct d40_gen_dmac *dmac = &d40c->base->gen_dmac;
 
-- 
1.7.10.4

--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 28/39] ARM: ux500: Remove empty function u8500_of_init_devices()

2013-05-15 Thread Lee Jones
As promised, now all devices which resided in u8500_of_init_devices()
have been enabled for Device Tree, we can completely remove it.

Acked-by: Fabio Baltieri 
Signed-off-by: Lee Jones 
---
 arch/arm/mach-ux500/cpu-db8500.c |   14 +-
 1 file changed, 1 insertion(+), 13 deletions(-)

diff --git a/arch/arm/mach-ux500/cpu-db8500.c b/arch/arm/mach-ux500/cpu-db8500.c
index f1e7a75..b407601 100644
--- a/arch/arm/mach-ux500/cpu-db8500.c
+++ b/arch/arm/mach-ux500/cpu-db8500.c
@@ -215,15 +215,6 @@ struct device * __init u8500_init_devices(void)
 }
 
 #ifdef CONFIG_MACH_UX500_DT
-
-/* TODO: Once all pieces are DT:ed, remove completely. */
-static struct device * __init u8500_of_init_devices(void)
-{
-   struct device *parent = db8500_soc_device_init();
-
-   return parent;
-}
-
 static struct of_dev_auxdata u8500_auxdata_lookup[] __initdata = {
/* Requires call-back bindings. */
OF_DEV_AUXDATA("arm,cortex-a9-pmu", 0, "arm-pmu", &db8500_pmu_platdata),
@@ -283,7 +274,7 @@ static const struct of_device_id u8500_local_bus_nodes[] = {
 
 static void __init u8500_init_machine(void)
 {
-   struct device *parent = NULL;
+   struct device *parent = db8500_soc_device_init();
 
/* Pinmaps must be in place before devices register */
if (of_machine_is_compatible("st-ericsson,mop500"))
@@ -296,9 +287,6 @@ static void __init u8500_init_machine(void)
else if (of_machine_is_compatible("st-ericsson,ccu9540")) {}
/* TODO: Add pinmaps for ccu9540 board. */
 
-   /* TODO: Export SoC, USB, cpu-freq and DMA40 */
-   parent = u8500_of_init_devices();
-
/* automatically probe child nodes of db8500 device */
of_platform_populate(NULL, u8500_local_bus_nodes, u8500_auxdata_lookup, 
parent);
 }
-- 
1.7.10.4

--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 26/39] ARM: ux500: Add an auxdata entry for MUSB for clock-name look-up

2013-05-15 Thread Lee Jones
The recently DT:ed MUSB driver will require clock-name by device-name
look-up capability, until common clk has is properly supported by the
ux500 platform.

Acked-by: Linus Walleij 
Acked-by: Fabio Baltieri 
Signed-off-by: Lee Jones 
---
 arch/arm/mach-ux500/cpu-db8500.c |1 +
 1 file changed, 1 insertion(+)

diff --git a/arch/arm/mach-ux500/cpu-db8500.c b/arch/arm/mach-ux500/cpu-db8500.c
index b1c9241..e20bc10 100644
--- a/arch/arm/mach-ux500/cpu-db8500.c
+++ b/arch/arm/mach-ux500/cpu-db8500.c
@@ -253,6 +253,7 @@ static struct of_dev_auxdata u8500_auxdata_lookup[] 
__initdata = {
OF_DEV_AUXDATA("st,nomadik-i2c", 0x80128000, "nmk-i2c.2", NULL),
OF_DEV_AUXDATA("st,nomadik-i2c", 0x8011, "nmk-i2c.3", NULL),
OF_DEV_AUXDATA("st,nomadik-i2c", 0x8012a000, "nmk-i2c.4", NULL),
+   OF_DEV_AUXDATA("stericsson,db8500-musb", 0xa03e, "musb-ux500.0", 
NULL),
OF_DEV_AUXDATA("stericsson,db8500-prcmu", 0x80157000, "db8500-prcmu",
&db8500_prcmu_pdata),
OF_DEV_AUXDATA("smsc,lan9115", 0x5000, "smsc911x.0", NULL),
-- 
1.7.10.4

--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 25/39] usb: musb: ux500: add device tree probing support

2013-05-15 Thread Lee Jones
This patch will allow ux500-musb to be probed and configured solely from
configuration found in Device Tree.

Cc: Felipe Balbi 
Cc: Rob Herring 
Cc: linux-usb@vger.kernel.org
Cc: devicetree-disc...@lists.ozlabs.org
Acked-by: Linus Walleij 
Acked-by: Fabio Baltieri 
Signed-off-by: Lee Jones 
---
 .../devicetree/bindings/usb/ux500-usb.txt  |   50 +++
 drivers/usb/musb/ux500.c   |   51 
 2 files changed, 101 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/usb/ux500-usb.txt

diff --git a/Documentation/devicetree/bindings/usb/ux500-usb.txt 
b/Documentation/devicetree/bindings/usb/ux500-usb.txt
new file mode 100644
index 000..330d6ec
--- /dev/null
+++ b/Documentation/devicetree/bindings/usb/ux500-usb.txt
@@ -0,0 +1,50 @@
+Ux500 MUSB
+
+Required properties:
+ - compatible : Should be "stericsson,db8500-musb"
+ - reg: Offset and length of registers
+ - interrupts : Interrupt; mode, number and trigger
+ - dr_mode: Dual-role; either host mode "host", peripheral mode 
"peripheral"
+or both "otg"
+
+Optional properties:
+ - dmas   : A list of dma channels;
+dma-controller, event-line, fixed-channel, flags
+ - dma-names  : An ordered list of channel names affiliated to the above
+
+Example:
+
+usb_per5@a03e {
+   compatible = "stericsson,db8500-musb", "mentor,musb";
+   reg = <0xa03e 0x1>;
+   interrupts = <0 23 0x4>;
+   interrupt-names = "mc";
+
+   dr_mode = "otg";
+
+   dmas = <&dma 38 0 0x2>, /* Logical - DevToMem */
+  <&dma 38 0 0x0>, /* Logical - MemToDev */
+  <&dma 37 0 0x2>, /* Logical - DevToMem */
+  <&dma 37 0 0x0>, /* Logical - MemToDev */
+  <&dma 36 0 0x2>, /* Logical - DevToMem */
+  <&dma 36 0 0x0>, /* Logical - MemToDev */
+  <&dma 19 0 0x2>, /* Logical - DevToMem */
+  <&dma 19 0 0x0>, /* Logical - MemToDev */
+  <&dma 18 0 0x2>, /* Logical - DevToMem */
+  <&dma 18 0 0x0>, /* Logical - MemToDev */
+  <&dma 17 0 0x2>, /* Logical - DevToMem */
+  <&dma 17 0 0x0>, /* Logical - MemToDev */
+  <&dma 16 0 0x2>, /* Logical - DevToMem */
+  <&dma 16 0 0x0>, /* Logical - MemToDev */
+  <&dma 39 0 0x2>, /* Logical - DevToMem */
+  <&dma 39 0 0x0>; /* Logical - MemToDev */
+
+   dma-names = "iep_1_9",  "oep_1_9",
+   "iep_2_10", "oep_2_10",
+   "iep_3_11", "oep_3_11",
+   "iep_4_12", "oep_4_12",
+   "iep_5_13", "oep_5_13",
+   "iep_6_14", "oep_6_14",
+   "iep_7_15", "oep_7_15",
+   "iep_8","oep_8";
+};
diff --git a/drivers/usb/musb/ux500.c b/drivers/usb/musb/ux500.c
index 3cf10bc..f0beee7 100644
--- a/drivers/usb/musb/ux500.c
+++ b/drivers/usb/musb/ux500.c
@@ -25,6 +25,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 
@@ -194,14 +195,57 @@ static const struct musb_platform_ops ux500_ops = {
.set_vbus   = ux500_musb_set_vbus,
 };
 
+static struct musb_hdrc_platform_data *
+ux500_of_probe(struct platform_device *pdev, struct device_node *np)
+{
+   struct musb_hdrc_platform_data *pdata;
+   const char *mode;
+   int strlen;
+
+   pdata = devm_kzalloc(&pdev->dev, sizeof(*pdata), GFP_KERNEL);
+   if (!pdata)
+   return NULL;
+
+   mode = of_get_property(np, "dr_mode", &strlen);
+   if (!mode) {
+   dev_err(&pdev->dev, "No 'dr_mode' property found\n");
+   return NULL;
+   }
+
+   if (strlen > 0) {
+   if (!strcmp(mode, "host"))
+   pdata->mode = MUSB_HOST;
+   if (!strcmp(mode, "otg"))
+   pdata->mode = MUSB_OTG;
+   if (!strcmp(mode, "peripheral"))
+   pdata->mode = MUSB_PERIPHERAL;
+   }
+
+   return pdata;
+}
+
 static int ux500_probe(struct platform_device *pdev)
 {
struct musb_hdrc_platform_data  *pdata = pdev->dev.platform_data;
+   struct device_node  *np = pdev->dev.of_node;
struct platform_device  *musb;
struct ux500_glue   *glue;
struct clk  *clk;
int ret = -ENOMEM;
 
+   if (!pdata) {
+   if (np) {
+   pdata = ux500_of_probe(pdev, np);
+   if (!pdata)
+   goto err0;
+
+   pdev->dev.platform_data = pdata;
+   } else {
+   dev_err(&pdev->dev, "no pdata or device tree found\n");
+   goto err0;
+   }
+   }
+
glue = kzalloc(sizeof(*glue), GFP_KERNEL);
if (!glue) {
dev_err(&pdev->dev, "failed to allocate glue co

[PATCH 09/39] ARM: ux500: Remove DMA address look-up table

2013-05-15 Thread Lee Jones
DMA addresses are now passed as part of the dmaengine API by invoking
dmaengine_slave_config(). So there's no requirement for the DMA40
driver to look them up in a table provided by platform data. This
method does not fit in well using Device Tree either.

Signed-off-by: Lee Jones 
---
 arch/arm/mach-ux500/devices-db8500.c|   80 ---
 include/linux/platform_data/dma-ste-dma40.h |2 -
 2 files changed, 82 deletions(-)

diff --git a/arch/arm/mach-ux500/devices-db8500.c 
b/arch/arm/mach-ux500/devices-db8500.c
index bed25a3..e21ffd8 100644
--- a/arch/arm/mach-ux500/devices-db8500.c
+++ b/arch/arm/mach-ux500/devices-db8500.c
@@ -42,87 +42,7 @@ static struct resource dma40_resources[] = {
}
 };
 
-/*
- * Mapping between destination event lines and physical device address.
- * The event line is tied to a device and therefore the address is constant.
- * When the address comes from a primecell it will be configured in runtime
- * and we set the address to -1 as a placeholder.
- */
-static const dma_addr_t dma40_tx_map[DB8500_DMA_NR_DEV] = {
-   /* MUSB - these will be runtime-reconfigured */
-   [DB8500_DMA_DEV39_USB_OTG_IEP_AND_OEP_8] = -1,
-   [DB8500_DMA_DEV16_USB_OTG_IEP_AND_OEP_7_15] = -1,
-   [DB8500_DMA_DEV17_USB_OTG_IEP_AND_OEP_6_14] = -1,
-   [DB8500_DMA_DEV18_USB_OTG_IEP_AND_OEP_5_13] = -1,
-   [DB8500_DMA_DEV19_USB_OTG_IEP_AND_OEP_4_12] = -1,
-   [DB8500_DMA_DEV36_USB_OTG_IEP_AND_OEP_3_11] = -1,
-   [DB8500_DMA_DEV37_USB_OTG_IEP_AND_OEP_2_10] = -1,
-   [DB8500_DMA_DEV38_USB_OTG_IEP_AND_OEP_1_9] = -1,
-   /* PrimeCells - run-time configured */
-   [DB8500_DMA_DEV0_SPI0] = -1,
-   [DB8500_DMA_DEV1_SD_MMC0] = -1,
-   [DB8500_DMA_DEV2_SD_MMC1] = -1,
-   [DB8500_DMA_DEV3_SD_MMC2] = -1,
-   [DB8500_DMA_DEV8_SSP0] = -1,
-   [DB8500_DMA_DEV9_SSP1] = -1,
-   [DB8500_DMA_DEV11_UART2] = -1,
-   [DB8500_DMA_DEV12_UART1] = -1,
-   [DB8500_DMA_DEV13_UART0] = -1,
-   [DB8500_DMA_DEV28_SD_MM2] = -1,
-   [DB8500_DMA_DEV29_SD_MM0] = -1,
-   [DB8500_DMA_DEV32_SD_MM1] = -1,
-   [DB8500_DMA_DEV33_SPI2] = -1,
-   [DB8500_DMA_DEV35_SPI1] = -1,
-   [DB8500_DMA_DEV40_SPI3] = -1,
-   [DB8500_DMA_DEV41_SD_MM3] = -1,
-   [DB8500_DMA_DEV42_SD_MM4] = -1,
-   [DB8500_DMA_DEV43_SD_MM5] = -1,
-   [DB8500_DMA_DEV14_MSP2] = U8500_MSP2_BASE + MSP_TX_RX_REG_OFFSET,
-   [DB8500_DMA_DEV30_MSP1] = U8500_MSP1_BASE + MSP_TX_RX_REG_OFFSET,
-   [DB8500_DMA_DEV31_MSP0_SLIM0_CH0] = U8500_MSP0_BASE + 
MSP_TX_RX_REG_OFFSET,
-   [DB8500_DMA_DEV48_CAC1] = U8500_CRYP1_BASE + CRYP1_TX_REG_OFFSET,
-   [DB8500_DMA_DEV50_HAC1_TX] = U8500_HASH1_BASE + HASH1_TX_REG_OFFSET,
-};
-
-/* Mapping between source event lines and physical device address */
-static const dma_addr_t dma40_rx_map[DB8500_DMA_NR_DEV] = {
-   /* MUSB - these will be runtime-reconfigured */
-   [DB8500_DMA_DEV39_USB_OTG_IEP_AND_OEP_8] = -1,
-   [DB8500_DMA_DEV16_USB_OTG_IEP_AND_OEP_7_15] = -1,
-   [DB8500_DMA_DEV17_USB_OTG_IEP_AND_OEP_6_14] = -1,
-   [DB8500_DMA_DEV18_USB_OTG_IEP_AND_OEP_5_13] = -1,
-   [DB8500_DMA_DEV19_USB_OTG_IEP_AND_OEP_4_12] = -1,
-   [DB8500_DMA_DEV36_USB_OTG_IEP_AND_OEP_3_11] = -1,
-   [DB8500_DMA_DEV37_USB_OTG_IEP_AND_OEP_2_10] = -1,
-   [DB8500_DMA_DEV38_USB_OTG_IEP_AND_OEP_1_9] = -1,
-   /* PrimeCells */
-   [DB8500_DMA_DEV0_SPI0] = -1,
-   [DB8500_DMA_DEV1_SD_MMC0] = -1,
-   [DB8500_DMA_DEV2_SD_MMC1] = -1,
-   [DB8500_DMA_DEV3_SD_MMC2] = -1,
-   [DB8500_DMA_DEV8_SSP0] = -1,
-   [DB8500_DMA_DEV9_SSP1] = -1,
-   [DB8500_DMA_DEV11_UART2] = -1,
-   [DB8500_DMA_DEV12_UART1] = -1,
-   [DB8500_DMA_DEV13_UART0] = -1,
-   [DB8500_DMA_DEV28_SD_MM2] = -1,
-   [DB8500_DMA_DEV29_SD_MM0] = -1,
-   [DB8500_DMA_DEV32_SD_MM1] = -1,
-   [DB8500_DMA_DEV33_SPI2] = -1,
-   [DB8500_DMA_DEV35_SPI1] = -1,
-   [DB8500_DMA_DEV40_SPI3] = -1,
-   [DB8500_DMA_DEV41_SD_MM3] = -1,
-   [DB8500_DMA_DEV42_SD_MM4] = -1,
-   [DB8500_DMA_DEV43_SD_MM5] = -1,
-   [DB8500_DMA_DEV14_MSP2] = U8500_MSP2_BASE + MSP_TX_RX_REG_OFFSET,
-   [DB8500_DMA_DEV30_MSP3] = U8500_MSP3_BASE + MSP_TX_RX_REG_OFFSET,
-   [DB8500_DMA_DEV31_MSP0_SLIM0_CH0] = U8500_MSP0_BASE + 
MSP_TX_RX_REG_OFFSET,
-   [DB8500_DMA_DEV48_CAC1] = U8500_CRYP1_BASE + CRYP1_RX_REG_OFFSET,
-};
-
 struct stedma40_platform_data dma40_plat_data = {
-   .dev_rx = dma40_rx_map,
-   .dev_tx = dma40_tx_map,
.disabled_channels = {-1},
 };
 
diff --git a/include/linux/platform_data/dma-ste-dma40.h 
b/include/linux/platform_data/dma-ste-dma40.h
index c54af61..af0064e 100644
--- a/include/linux/platform_data/dma-ste-dma40.h
+++ b/include/linux/platform_data/dma-ste-dma40.h
@@ -152,8 +152,6 @@ struct stedma40_chan_cfg {
  * for 'multiple of 4' channels, like 8.
  */
 struct stedma40_platform_data {
-   const dma_addr_t*dev_tx;

[PATCH 15/39] crypto: ux500/cryp - Prepare clock before enabling it

2013-05-15 Thread Lee Jones
If we fail to prepare the ux500-cryp clock before enabling it the
platform will fail to boot. Here we insure this happens.

Cc: Herbert Xu 
Cc: David S. Miller 
Cc: Andreas Westin 
Cc: linux-cry...@vger.kernel.org
Acked-by: Ulf Hansson 
Acked-by: Arnd Bergmann 
Signed-off-by: Lee Jones 
---
 drivers/crypto/ux500/cryp/cryp_core.c |   12 +++-
 1 file changed, 11 insertions(+), 1 deletion(-)

diff --git a/drivers/crypto/ux500/cryp/cryp_core.c 
b/drivers/crypto/ux500/cryp/cryp_core.c
index 32f4806..ccdf173 100644
--- a/drivers/crypto/ux500/cryp/cryp_core.c
+++ b/drivers/crypto/ux500/cryp/cryp_core.c
@@ -1458,11 +1458,17 @@ static int ux500_cryp_probe(struct platform_device 
*pdev)
goto out_regulator;
}
 
+   ret = clk_prepare(device_data->clk);
+   if (ret) {
+   dev_err(dev, "[%s]: clk_prepare() failed!", __func__);
+   goto out_clk;
+   }
+
/* Enable device power (and clock) */
ret = cryp_enable_power(device_data->dev, device_data, false);
if (ret) {
dev_err(dev, "[%s]: cryp_enable_power() failed!", __func__);
-   goto out_clk;
+   goto out_clk_unprepare;
}
 
cryp_error = cryp_check(device_data);
@@ -1523,6 +1529,9 @@ static int ux500_cryp_probe(struct platform_device *pdev)
 out_power:
cryp_disable_power(device_data->dev, device_data, false);
 
+out_clk_unprepare:
+   clk_unprepare(device_data->clk);
+
 out_clk:
clk_put(device_data->clk);
 
@@ -1593,6 +1602,7 @@ static int ux500_cryp_remove(struct platform_device *pdev)
dev_err(&pdev->dev, "[%s]: cryp_disable_power() failed",
__func__);
 
+   clk_unprepare(device_data->clk);
clk_put(device_data->clk);
regulator_put(device_data->pwr_regulator);
 
-- 
1.7.10.4

--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 14/39] ARM: ux500: Stop passing Hash DMA channel config information though pdata

2013-05-15 Thread Lee Jones
DMA channel configuration information should be setup in the driver.
The Ux500 Hash driver now does this, so there's no need to send it
though here too.

Acked-by: Arnd Bergmann 
Signed-off-by: Lee Jones 
---
 arch/arm/mach-ux500/board-mop500.c |4 
 1 file changed, 4 deletions(-)

diff --git a/arch/arm/mach-ux500/board-mop500.c 
b/arch/arm/mach-ux500/board-mop500.c
index 52ffe1c..ec916ca 100644
--- a/arch/arm/mach-ux500/board-mop500.c
+++ b/arch/arm/mach-ux500/board-mop500.c
@@ -446,11 +446,7 @@ static struct cryp_platform_data u8500_cryp1_platform_data 
= {
 static struct stedma40_chan_cfg u8500_hash_dma_cfg_tx = {
.dir = STEDMA40_MEM_TO_PERIPH,
.dev_type = DB8500_DMA_DEV50_HAC1_TX,
-   .src_info.data_width = STEDMA40_WORD_WIDTH,
-   .dst_info.data_width = STEDMA40_WORD_WIDTH,
.mode = STEDMA40_MODE_LOGICAL,
-   .src_info.psize = STEDMA40_PSIZE_LOG_16,
-   .dst_info.psize = STEDMA40_PSIZE_LOG_16,
 };
 
 static struct hash_platform_data u8500_hash1_platform_data = {
-- 
1.7.10.4

--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 22/39] usb: musb: ux500: take the dma_mask from coherent_dma_mask

2013-05-15 Thread Lee Jones
The dma_mask will always be the same as the coherent_dma_mask, so let's
cut down on the platform_data burden and set it as such in the driver.
This also saves us from supporting it separately when we come to enable
this driver for Device Tree.

Cc: Felipe Balbi 
Cc: linux-usb@vger.kernel.org
Acked-by: Linus Walleij 
Acked-by: Fabio Baltieri 
Signed-off-by: Lee Jones 
---
 arch/arm/mach-ux500/usb.c |3 ---
 drivers/usb/musb/ux500.c  |2 +-
 2 files changed, 1 insertion(+), 4 deletions(-)

diff --git a/arch/arm/mach-ux500/usb.c b/arch/arm/mach-ux500/usb.c
index 49d6e57..2f9abe9 100644
--- a/arch/arm/mach-ux500/usb.c
+++ b/arch/arm/mach-ux500/usb.c
@@ -74,8 +74,6 @@ static struct ux500_musb_board_data musb_board_data = {
.dma_filter = stedma40_filter,
 };
 
-static u64 ux500_musb_dmamask = DMA_BIT_MASK(32);
-
 static struct musb_hdrc_platform_data musb_platform_data = {
.mode = MUSB_OTG,
.board_data = &musb_board_data,
@@ -98,7 +96,6 @@ struct platform_device ux500_musb_device = {
.id = 0,
.dev = {
.platform_data = &musb_platform_data,
-   .dma_mask = &ux500_musb_dmamask,
.coherent_dma_mask = DMA_BIT_MASK(32),
},
.num_resources = ARRAY_SIZE(usb_resources),
diff --git a/drivers/usb/musb/ux500.c b/drivers/usb/musb/ux500.c
index 371776f..3cf10bc 100644
--- a/drivers/usb/musb/ux500.c
+++ b/drivers/usb/musb/ux500.c
@@ -228,7 +228,7 @@ static int ux500_probe(struct platform_device *pdev)
}
 
musb->dev.parent= &pdev->dev;
-   musb->dev.dma_mask  = pdev->dev.dma_mask;
+   musb->dev.dma_mask  = &pdev->dev.coherent_dma_mask;
musb->dev.coherent_dma_mask = pdev->dev.coherent_dma_mask;
 
glue->dev   = &pdev->dev;
-- 
1.7.10.4

--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 23/39] usb: musb: ux500: harden checks for platform data

2013-05-15 Thread Lee Jones
In its current state, the ux500-musb driver uses platform data pointers
blindly with no prior checking. If no platform data pointer is passed
this will Oops the kernel. In this patch we ensure platform data and
board data are present prior to using them.

Cc: Felipe Balbi 
Cc: linux-usb@vger.kernel.org
Acked-by: Fabio Baltieri 
Signed-off-by: Lee Jones 
---
 drivers/usb/musb/ux500_dma.c |   11 ---
 1 file changed, 8 insertions(+), 3 deletions(-)

diff --git a/drivers/usb/musb/ux500_dma.c b/drivers/usb/musb/ux500_dma.c
index 382291b..4bd5400 100644
--- a/drivers/usb/musb/ux500_dma.c
+++ b/drivers/usb/musb/ux500_dma.c
@@ -289,7 +289,7 @@ static int ux500_dma_controller_start(struct dma_controller 
*c)
struct musb *musb = controller->private_data;
struct device *dev = musb->controller;
struct musb_hdrc_platform_data *plat = dev->platform_data;
-   struct ux500_musb_board_data *data = plat->board_data;
+   struct ux500_musb_board_data *data;
struct dma_channel *dma_channel = NULL;
u32 ch_num;
u8 dir;
@@ -299,14 +299,19 @@ static int ux500_dma_controller_start(struct 
dma_controller *c)
struct ux500_dma_channel *channel_array;
dma_cap_mask_t mask;
 
+   if (!plat) {
+   dev_err(musb->controller, "No platform data\n");
+   return -EINVAL;
+   }
 
+   data = plat->board_data;
 
dma_cap_zero(mask);
dma_cap_set(DMA_SLAVE, mask);
 
/* Prepare the loop for RX channels */
channel_array = controller->rx_channel;
-   param_array = data->dma_rx_param_array;
+   param_array = data ? data->dma_rx_param_array : NULL;
 
for (dir = 0; dir < 2; dir++) {
for (ch_num = 0;
@@ -339,7 +344,7 @@ static int ux500_dma_controller_start(struct dma_controller 
*c)
 
/* Prepare the loop for TX channels */
channel_array = controller->tx_channel;
-   param_array = data->dma_tx_param_array;
+   param_array = data ? data->dma_tx_param_array : NULL;
is_tx = 1;
}
 
-- 
1.7.10.4

--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 21/39] usb: musb: ux500: move the MUSB HDRC configuration into the driver

2013-05-15 Thread Lee Jones
The MUSB HDRC configuration never changes between each of the ux500
supported platforms, so there's little point passing it though platform
data. If we set it in the driver instead, we can make good use of it
when booting with either ATAGs or Device Tree.

Cc: Felipe Balbi 
Cc: linux-usb@vger.kernel.org
Acked-by: Linus Walleij 
Acked-by: Fabio Baltieri 
Signed-off-by: Lee Jones 
---
 arch/arm/mach-ux500/usb.c |8 
 drivers/usb/musb/ux500.c  |8 
 2 files changed, 8 insertions(+), 8 deletions(-)

diff --git a/arch/arm/mach-ux500/usb.c b/arch/arm/mach-ux500/usb.c
index a21c2e1..49d6e57 100644
--- a/arch/arm/mach-ux500/usb.c
+++ b/arch/arm/mach-ux500/usb.c
@@ -76,16 +76,8 @@ static struct ux500_musb_board_data musb_board_data = {
 
 static u64 ux500_musb_dmamask = DMA_BIT_MASK(32);
 
-static struct musb_hdrc_config musb_hdrc_config = {
-   .multipoint = true,
-   .dyn_fifo   = true,
-   .num_eps= 16,
-   .ram_bits   = 16,
-};
-
 static struct musb_hdrc_platform_data musb_platform_data = {
.mode = MUSB_OTG,
-   .config = &musb_hdrc_config,
.board_data = &musb_board_data,
 };
 
diff --git a/drivers/usb/musb/ux500.c b/drivers/usb/musb/ux500.c
index 2c80004..371776f 100644
--- a/drivers/usb/musb/ux500.c
+++ b/drivers/usb/musb/ux500.c
@@ -30,6 +30,13 @@
 
 #include "musb_core.h"
 
+static struct musb_hdrc_config ux500_musb_hdrc_config = {
+   .multipoint = true,
+   .dyn_fifo   = true,
+   .num_eps= 16,
+   .ram_bits   = 16,
+};
+
 struct ux500_glue {
struct device   *dev;
struct platform_device  *musb;
@@ -229,6 +236,7 @@ static int ux500_probe(struct platform_device *pdev)
glue->clk   = clk;
 
pdata->platform_ops = &ux500_ops;
+   pdata->config   = &ux500_musb_hdrc_config;
 
platform_set_drvdata(pdev, glue);
 
-- 
1.7.10.4

--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 20/39] usb: musb: ux500: move channel number knowledge into the driver

2013-05-15 Thread Lee Jones
For all ux500 based platforms the maximum number of end-points are used.
Move this knowledge into the driver so we can relinquish the burden from
platform data. This also removes quite a bit of complexity from the driver
and will aid us when we come to enable the driver for Device Tree.

Cc: Felipe Balbi 
Cc: linux-usb@vger.kernel.org
Acked-by: Linus Walleij 
Acked-by: Fabio Baltieri 
Signed-off-by: Lee Jones 
---
 arch/arm/mach-ux500/usb.c|   14 ++--
 drivers/usb/musb/ux500_dma.c |   30 --
 include/linux/platform_data/usb-musb-ux500.h |5 +
 3 files changed, 16 insertions(+), 33 deletions(-)

diff --git a/arch/arm/mach-ux500/usb.c b/arch/arm/mach-ux500/usb.c
index 72754e3..a21c2e1 100644
--- a/arch/arm/mach-ux500/usb.c
+++ b/arch/arm/mach-ux500/usb.c
@@ -22,7 +22,7 @@
.dir = STEDMA40_MEM_TO_PERIPH, \
}
 
-static struct stedma40_chan_cfg musb_dma_rx_ch[UX500_MUSB_DMA_NUM_RX_CHANNELS]
+static struct stedma40_chan_cfg 
musb_dma_rx_ch[UX500_MUSB_DMA_NUM_RX_TX_CHANNELS]
= {
MUSB_DMA40_RX_CH,
MUSB_DMA40_RX_CH,
@@ -34,7 +34,7 @@ static struct stedma40_chan_cfg 
musb_dma_rx_ch[UX500_MUSB_DMA_NUM_RX_CHANNELS]
MUSB_DMA40_RX_CH
 };
 
-static struct stedma40_chan_cfg musb_dma_tx_ch[UX500_MUSB_DMA_NUM_TX_CHANNELS]
+static struct stedma40_chan_cfg 
musb_dma_tx_ch[UX500_MUSB_DMA_NUM_RX_TX_CHANNELS]
= {
MUSB_DMA40_TX_CH,
MUSB_DMA40_TX_CH,
@@ -46,7 +46,7 @@ static struct stedma40_chan_cfg 
musb_dma_tx_ch[UX500_MUSB_DMA_NUM_TX_CHANNELS]
MUSB_DMA40_TX_CH,
 };
 
-static void *ux500_dma_rx_param_array[UX500_MUSB_DMA_NUM_RX_CHANNELS] = {
+static void *ux500_dma_rx_param_array[UX500_MUSB_DMA_NUM_RX_TX_CHANNELS] = {
&musb_dma_rx_ch[0],
&musb_dma_rx_ch[1],
&musb_dma_rx_ch[2],
@@ -57,7 +57,7 @@ static void 
*ux500_dma_rx_param_array[UX500_MUSB_DMA_NUM_RX_CHANNELS] = {
&musb_dma_rx_ch[7]
 };
 
-static void *ux500_dma_tx_param_array[UX500_MUSB_DMA_NUM_TX_CHANNELS] = {
+static void *ux500_dma_tx_param_array[UX500_MUSB_DMA_NUM_RX_TX_CHANNELS] = {
&musb_dma_tx_ch[0],
&musb_dma_tx_ch[1],
&musb_dma_tx_ch[2],
@@ -71,8 +71,6 @@ static void 
*ux500_dma_tx_param_array[UX500_MUSB_DMA_NUM_TX_CHANNELS] = {
 static struct ux500_musb_board_data musb_board_data = {
.dma_rx_param_array = ux500_dma_rx_param_array,
.dma_tx_param_array = ux500_dma_tx_param_array,
-   .num_rx_channels = UX500_MUSB_DMA_NUM_RX_CHANNELS,
-   .num_tx_channels = UX500_MUSB_DMA_NUM_TX_CHANNELS,
.dma_filter = stedma40_filter,
 };
 
@@ -119,7 +117,7 @@ static inline void ux500_usb_dma_update_rx_ch_config(int 
*dev_type)
 {
u32 idx;
 
-   for (idx = 0; idx < UX500_MUSB_DMA_NUM_RX_CHANNELS; idx++)
+   for (idx = 0; idx < UX500_MUSB_DMA_NUM_RX_TX_CHANNELS; idx++)
musb_dma_rx_ch[idx].dev_type = dev_type[idx];
 }
 
@@ -127,7 +125,7 @@ static inline void ux500_usb_dma_update_tx_ch_config(int 
*dev_type)
 {
u32 idx;
 
-   for (idx = 0; idx < UX500_MUSB_DMA_NUM_TX_CHANNELS; idx++)
+   for (idx = 0; idx < UX500_MUSB_DMA_NUM_RX_TX_CHANNELS; idx++)
musb_dma_tx_ch[idx].dev_type = dev_type[idx];
 }
 
diff --git a/drivers/usb/musb/ux500_dma.c b/drivers/usb/musb/ux500_dma.c
index 3381206..382291b 100644
--- a/drivers/usb/musb/ux500_dma.c
+++ b/drivers/usb/musb/ux500_dma.c
@@ -48,10 +48,8 @@ struct ux500_dma_channel {
 
 struct ux500_dma_controller {
struct dma_controller controller;
-   struct ux500_dma_channel rx_channel[UX500_MUSB_DMA_NUM_RX_CHANNELS];
-   struct ux500_dma_channel tx_channel[UX500_MUSB_DMA_NUM_TX_CHANNELS];
-   u32 num_rx_channels;
-   u32 num_tx_channels;
+   struct ux500_dma_channel rx_channel[UX500_MUSB_DMA_NUM_RX_TX_CHANNELS];
+   struct ux500_dma_channel tx_channel[UX500_MUSB_DMA_NUM_RX_TX_CHANNELS];
void *private_data;
dma_addr_t phy_base;
 };
@@ -144,19 +142,15 @@ static struct dma_channel 
*ux500_dma_channel_allocate(struct dma_controller *c,
struct ux500_dma_channel *ux500_channel = NULL;
struct musb *musb = controller->private_data;
u8 ch_num = hw_ep->epnum - 1;
-   u32 max_ch;
 
-   /* Max 8 DMA channels (0 - 7). Each DMA channel can only be allocated
+   /* 8 DMA channels (0 - 7). Each DMA channel can only be allocated
 * to specified hw_ep. For example DMA channel 0 can only be allocated
 * to hw_ep 1 and 9.
 */
if (ch_num > 7)
ch_num -= 8;
 
-   max_ch = is_tx ? controller->num_tx_channels :
-   controller->num_rx_channels;
-
-   if (ch_num >= max_ch)
+   if (ch_num >= UX500_MUSB_DMA_NUM_RX_TX_CHANNELS)
return NULL;
 
ux500_channel = is_tx ? &(controller->tx_channel[ch_num]) :
@@ -264,7 +258,7 @@ static int ux500_dma_controller_stop(struct dma_controller 
*c

[PATCH 19/39] ARM: ux500: Register Cyrp and Hash platform drivers on Snowball

2013-05-15 Thread Lee Jones
These drivers are now operational and even use the latest common clk
and DMA APIs. There's no reason why we shouldn't start them up now.

Reviewed-by: Linus Walleij 
Signed-off-by: Lee Jones 
---
 arch/arm/mach-ux500/board-mop500.c |2 ++
 1 file changed, 2 insertions(+)

diff --git a/arch/arm/mach-ux500/board-mop500.c 
b/arch/arm/mach-ux500/board-mop500.c
index 38e321c..ba26ae3 100644
--- a/arch/arm/mach-ux500/board-mop500.c
+++ b/arch/arm/mach-ux500/board-mop500.c
@@ -637,6 +637,8 @@ static void __init snowball_init_machine(void)
 
mop500_snowball_ethernet_clock_enable();
 
+   u8500_cryp1_hash1_init(parent);
+
/* This board has full regulator constraints */
regulator_has_full_constraints();
 }
-- 
1.7.10.4

--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 18/39] crypto: ux500/[cryp|hash] - Show successful start-up in the bootlog

2013-05-15 Thread Lee Jones
The Cryp driver is currently silent and the Hash driver prints the
name of its probe function unnecessarily. Let's just put a nice
descriptive one-liner there instead.

Cc: Herbert Xu 
Cc: David S. Miller 
Cc: Andreas Westin 
Cc: linux-cry...@vger.kernel.org
Acked-by: Arnd Bergmann 
Reviewed-by: Linus Walleij 
Signed-off-by: Lee Jones 
---
 drivers/crypto/ux500/cryp/cryp_core.c |2 ++
 drivers/crypto/ux500/hash/hash_core.c |2 +-
 2 files changed, 3 insertions(+), 1 deletion(-)

diff --git a/drivers/crypto/ux500/cryp/cryp_core.c 
b/drivers/crypto/ux500/cryp/cryp_core.c
index d9c863d..4f8b11a 100644
--- a/drivers/crypto/ux500/cryp/cryp_core.c
+++ b/drivers/crypto/ux500/cryp/cryp_core.c
@@ -1541,6 +1541,8 @@ static int ux500_cryp_probe(struct platform_device *pdev)
goto out_power;
}
 
+   dev_info(dev, "successfully registered\n");
+
return 0;
 
 out_power:
diff --git a/drivers/crypto/ux500/hash/hash_core.c 
b/drivers/crypto/ux500/hash/hash_core.c
index 6269576..9ca6fbb 100644
--- a/drivers/crypto/ux500/hash/hash_core.c
+++ b/drivers/crypto/ux500/hash/hash_core.c
@@ -1772,7 +1772,7 @@ static int ux500_hash_probe(struct platform_device *pdev)
goto out_power;
}
 
-   dev_info(dev, "[%s] successfully probed\n", __func__);
+   dev_info(dev, "successfully registered\n");
return 0;
 
 out_power:
-- 
1.7.10.4

--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 17/39] ARM: ux500: Stop passing Cryp DMA channel config information though pdata

2013-05-15 Thread Lee Jones
DMA channel configuration information should be setup in the driver.
The Ux500 Cryp driver now does this, so there's no need to send it
though here too.

Reviewed-by: Linus Walleij 
Acked-by: Arnd Bergmann 
Signed-off-by: Lee Jones 
---
 arch/arm/mach-ux500/board-mop500.c |8 
 1 file changed, 8 deletions(-)

diff --git a/arch/arm/mach-ux500/board-mop500.c 
b/arch/arm/mach-ux500/board-mop500.c
index ec916ca..38e321c 100644
--- a/arch/arm/mach-ux500/board-mop500.c
+++ b/arch/arm/mach-ux500/board-mop500.c
@@ -426,20 +426,12 @@ static struct cryp_platform_data 
u8500_cryp1_platform_data = {
.mem_to_engine = {
.dir = STEDMA40_MEM_TO_PERIPH,
.dev_type = DB8500_DMA_DEV48_CAC1,
-   .src_info.data_width = STEDMA40_WORD_WIDTH,
-   .dst_info.data_width = STEDMA40_WORD_WIDTH,
.mode = STEDMA40_MODE_LOGICAL,
-   .src_info.psize = STEDMA40_PSIZE_LOG_4,
-   .dst_info.psize = STEDMA40_PSIZE_LOG_4,
},
.engine_to_mem = {
.dir = STEDMA40_PERIPH_TO_MEM,
.dev_type = DB8500_DMA_DEV48_CAC1,
-   .src_info.data_width = STEDMA40_WORD_WIDTH,
-   .dst_info.data_width = STEDMA40_WORD_WIDTH,
.mode = STEDMA40_MODE_LOGICAL,
-   .src_info.psize = STEDMA40_PSIZE_LOG_4,
-   .dst_info.psize = STEDMA40_PSIZE_LOG_4,
}
 };
 
-- 
1.7.10.4

--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 16/39] crypto: ux500/cryp - Set DMA configuration though dma_slave_config()

2013-05-15 Thread Lee Jones
The DMA controller currently takes configuration information from
information passed though dma_channel_request(), but it shouldn't.
Using the API, the DMA channel should only be configured during
a dma_slave_config() call.

Cc: Herbert Xu 
Cc: David S. Miller 
Cc: Andreas Westin 
Cc: linux-cry...@vger.kernel.org
Acked-by: Arnd Bergmann 
Acked-by: Linus Walleij 
Signed-off-by: Lee Jones 
---
 drivers/crypto/ux500/cryp/cryp.h  |7 ++-
 drivers/crypto/ux500/cryp/cryp_core.c |   17 +
 2 files changed, 23 insertions(+), 1 deletion(-)

diff --git a/drivers/crypto/ux500/cryp/cryp.h b/drivers/crypto/ux500/cryp/cryp.h
index 14cfd05..d1d6606 100644
--- a/drivers/crypto/ux500/cryp/cryp.h
+++ b/drivers/crypto/ux500/cryp/cryp.h
@@ -114,6 +114,9 @@ enum cryp_status_id {
 };
 
 /* Cryp DMA interface */
+#define CRYP_DMA_TX_FIFO   0x08
+#define CRYP_DMA_RX_FIFO   0x10
+
 enum cryp_dma_req_type {
CRYP_DMA_DISABLE_BOTH,
CRYP_DMA_ENABLE_IN_DATA,
@@ -217,7 +220,8 @@ struct cryp_dma {
 
 /**
  * struct cryp_device_data - structure for a cryp device.
- * @base: Pointer to the hardware base address.
+ * @base: Pointer to virtual base address of the cryp device.
+ * @phybase: Pointer to physical memory location of the cryp device.
  * @dev: Pointer to the devices dev structure.
  * @clk: Pointer to the device's clock control.
  * @pwr_regulator: Pointer to the device's power control.
@@ -232,6 +236,7 @@ struct cryp_dma {
  */
 struct cryp_device_data {
struct cryp_register __iomem *base;
+   phys_addr_t phybase;
struct device *dev;
struct clk *clk;
struct regulator *pwr_regulator;
diff --git a/drivers/crypto/ux500/cryp/cryp_core.c 
b/drivers/crypto/ux500/cryp/cryp_core.c
index ccdf173..d9c863d 100644
--- a/drivers/crypto/ux500/cryp/cryp_core.c
+++ b/drivers/crypto/ux500/cryp/cryp_core.c
@@ -475,6 +475,19 @@ static int cryp_get_device_data(struct cryp_ctx *ctx,
 static void cryp_dma_setup_channel(struct cryp_device_data *device_data,
   struct device *dev)
 {
+   struct dma_slave_config mem2cryp = {
+   .direction = DMA_MEM_TO_DEV,
+   .dst_addr = device_data->phybase + CRYP_DMA_TX_FIFO,
+   .dst_addr_width = DMA_SLAVE_BUSWIDTH_2_BYTES,
+   .dst_maxburst = 4,
+};
+   struct dma_slave_config cryp2mem = {
+   .direction = DMA_DEV_TO_MEM,
+   .src_addr = device_data->phybase + CRYP_DMA_RX_FIFO,
+   .src_addr_width = DMA_SLAVE_BUSWIDTH_2_BYTES,
+   .src_maxburst = 4,
+};
+
dma_cap_zero(device_data->dma.mask);
dma_cap_set(DMA_SLAVE, device_data->dma.mask);
 
@@ -490,6 +503,9 @@ static void cryp_dma_setup_channel(struct cryp_device_data 
*device_data,
stedma40_filter,
device_data->dma.cfg_cryp2mem);
 
+   dmaengine_slave_config(device_data->dma.chan_mem2cryp, &mem2cryp);
+   dmaengine_slave_config(device_data->dma.chan_cryp2mem, &cryp2mem);
+
init_completion(&device_data->dma.cryp_dma_complete);
 }
 
@@ -1431,6 +1447,7 @@ static int ux500_cryp_probe(struct platform_device *pdev)
goto out_kfree;
}
 
+   device_data->phybase = res->start;
device_data->base = ioremap(res->start, resource_size(res));
if (!device_data->base) {
dev_err(dev, "[%s]: ioremap failed!", __func__);
-- 
1.7.10.4

--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 12/39] crypto: ux500/hash - Prepare clock before enabling it

2013-05-15 Thread Lee Jones
If we fail to prepare the ux500-hash clock before enabling it the
platform will fail to boot. Here we insure this happens.

Cc: Herbert Xu 
Cc: David S. Miller 
Cc: Andreas Westin 
Cc: linux-cry...@vger.kernel.org
Acked-by: Arnd Bergmann 
Acked-by: Ulf Hansson 
Signed-off-by: Lee Jones 
---
 drivers/crypto/ux500/hash/hash_core.c |   12 +++-
 1 file changed, 11 insertions(+), 1 deletion(-)

diff --git a/drivers/crypto/ux500/hash/hash_core.c 
b/drivers/crypto/ux500/hash/hash_core.c
index cf55089..4b02428 100644
--- a/drivers/crypto/ux500/hash/hash_core.c
+++ b/drivers/crypto/ux500/hash/hash_core.c
@@ -1726,11 +1726,17 @@ static int ux500_hash_probe(struct platform_device 
*pdev)
goto out_regulator;
}
 
+   ret = clk_prepare(device_data->clk);
+   if (ret) {
+   dev_err(dev, "[%s] clk_prepare() failed!", __func__);
+   goto out_clk;
+   }
+
/* Enable device power (and clock) */
ret = hash_enable_power(device_data, false);
if (ret) {
dev_err(dev, "[%s]: hash_enable_power() failed!", __func__);
-   goto out_clk;
+   goto out_clk_unprepare;
}
 
ret = hash_check_hw(device_data);
@@ -1762,6 +1768,9 @@ static int ux500_hash_probe(struct platform_device *pdev)
 out_power:
hash_disable_power(device_data, false);
 
+out_clk_unprepare:
+   clk_unprepare(device_data->clk);
+
 out_clk:
clk_put(device_data->clk);
 
@@ -1826,6 +1835,7 @@ static int ux500_hash_remove(struct platform_device *pdev)
dev_err(dev, "[%s]: hash_disable_power() failed",
__func__);
 
+   clk_unprepare(device_data->clk);
clk_put(device_data->clk);
regulator_put(device_data->regulator);
 
-- 
1.7.10.4

--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 11/39] ARM: ux500: Remove unnecessary attributes from DMA channel request pdata

2013-05-15 Thread Lee Jones
DMA data width and packet size information is only required at channel
configuration time. Any information passed from platform data is passed
directly to the DMA40 driver to use during channel allocation, but these
pieces of information are subsequently ignored by the driver, so we may
as well remove them.

Signed-off-by: Lee Jones 
---
 arch/arm/mach-ux500/usb.c |8 
 1 file changed, 8 deletions(-)

diff --git a/arch/arm/mach-ux500/usb.c b/arch/arm/mach-ux500/usb.c
index 45af303..72754e3 100644
--- a/arch/arm/mach-ux500/usb.c
+++ b/arch/arm/mach-ux500/usb.c
@@ -15,19 +15,11 @@
 #define MUSB_DMA40_RX_CH { \
.mode = STEDMA40_MODE_LOGICAL, \
.dir = STEDMA40_PERIPH_TO_MEM, \
-   .src_info.data_width = STEDMA40_WORD_WIDTH, \
-   .dst_info.data_width = STEDMA40_WORD_WIDTH, \
-   .src_info.psize = STEDMA40_PSIZE_LOG_16, \
-   .dst_info.psize = STEDMA40_PSIZE_LOG_16, \
}
 
 #define MUSB_DMA40_TX_CH { \
.mode = STEDMA40_MODE_LOGICAL, \
.dir = STEDMA40_MEM_TO_PERIPH, \
-   .src_info.data_width = STEDMA40_WORD_WIDTH, \
-   .dst_info.data_width = STEDMA40_WORD_WIDTH, \
-   .src_info.psize = STEDMA40_PSIZE_LOG_16, \
-   .dst_info.psize = STEDMA40_PSIZE_LOG_16, \
}
 
 static struct stedma40_chan_cfg musb_dma_rx_ch[UX500_MUSB_DMA_NUM_RX_CHANNELS]
-- 
1.7.10.4

--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 10/39] dmaengine: ste_dma40: Correct copy/paste error

2013-05-15 Thread Lee Jones
'struct stedma40_half_channel_info's header comment says that it's
called 'struct stedma40_chan_cfg'. Let's straighten that out.

Signed-off-by: Lee Jones 
---
 include/linux/platform_data/dma-ste-dma40.h |2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/include/linux/platform_data/dma-ste-dma40.h 
b/include/linux/platform_data/dma-ste-dma40.h
index af0064e..288dc24 100644
--- a/include/linux/platform_data/dma-ste-dma40.h
+++ b/include/linux/platform_data/dma-ste-dma40.h
@@ -86,7 +86,7 @@ enum stedma40_xfer_dir {
 
 
 /**
- * struct stedma40_chan_cfg - dst/src channel configuration
+ * struct stedma40_half_channel_info - dst/src channel configuration
  *
  * @big_endian: true if the src/dst should be read as big endian
  * @data_width: Data width of the src/dst hardware
-- 
1.7.10.4

--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 00/39] Continuation of DMA changes in ux500 based drivers

2013-05-15 Thread Lee Jones
A great deal of these patches have now been applied through various trees.
We now need to grab the attention of the outstanding DMA clients (MUSB and
Crypto) to progress.

Also, Linus could probably do with a hand from Vinod for the remaining
dmaengine patches.

Thanks in advance.

 Documentation/devicetree/bindings/dma/ste-dma40.txt |4 ++
 Documentation/devicetree/bindings/usb/ux500-usb.txt |   50 ++
 arch/arm/mach-ux500/board-mop500-audio.c|   12 ++---
 arch/arm/mach-ux500/board-mop500-sdi.c  |   16 +++---
 arch/arm/mach-ux500/board-mop500.c  |   36 +
 arch/arm/mach-ux500/cpu-db8500.c|   34 
 arch/arm/mach-ux500/devices-db8500.c|   80 

 arch/arm/mach-ux500/usb.c   |   37 +++--
 drivers/crypto/ux500/cryp/cryp.h|7 ++-
 drivers/crypto/ux500/cryp/cryp_core.c   |   31 ++-
 drivers/crypto/ux500/hash/hash_alg.h|5 +-
 drivers/crypto/ux500/hash/hash_core.c   |   24 -
 drivers/dma/ste_dma40.c |  292 
+
 drivers/dma/ste_dma40_ll.c  |  189 
+
 drivers/dma/ste_dma40_ll.h  |3 +-
 drivers/usb/musb/ux500.c|   61 
-
 drivers/usb/musb/ux500_dma.c|   59 
-
 include/linux/platform_data/dma-ste-dma40.h |   25 ++---
 include/linux/platform_data/usb-musb-ux500.h|5 +-
 sound/soc/ux500/ux500_pcm.c |   10 ++--
 20 files changed, 506 insertions(+), 474 deletions(-)

--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 01/39] dmaengine: ste_dma40: Separate Logical Global Interrupt Mask (GIM) unmasking

2013-05-15 Thread Lee Jones
During the initial setup of a logical channel, it is necessary to unmask
the GIM in order to receive generated terminal count and error interrupts.
We're separating out this required code so it will be possible to move
the remaining code in d40_phy_cfg(), which is mostly runtime configuration
into the runtime_config() routine.

Cc: Vinod Koul 
Cc: Dan Williams 
Cc: Per Forlin 
Cc: Rabin Vincent 
Acked-by: Arnd Bergmann 
Signed-off-by: Lee Jones 
---
 drivers/dma/ste_dma40.c|4 
 drivers/dma/ste_dma40_ll.c |5 -
 2 files changed, 4 insertions(+), 5 deletions(-)

diff --git a/drivers/dma/ste_dma40.c b/drivers/dma/ste_dma40.c
index 5e9f6d6..759293e 100644
--- a/drivers/dma/ste_dma40.c
+++ b/drivers/dma/ste_dma40.c
@@ -2513,6 +2513,10 @@ static int d40_alloc_chan_resources(struct dma_chan 
*chan)
d40c->lcpa = d40c->base->lcpa_base +
d40c->dma_cfg.dev_type *
D40_LCPA_CHAN_SIZE + D40_LCPA_CHAN_DST_DELTA;
+
+   /* Unmask the Global Interrupt Mask. */
+   d40c->src_def_cfg |= BIT(D40_SREG_CFG_LOG_GIM_POS);
+   d40c->dst_def_cfg |= BIT(D40_SREG_CFG_LOG_GIM_POS);
}
 
dev_dbg(chan2dev(d40c), "allocated %s channel (phy %d%s)\n",
diff --git a/drivers/dma/ste_dma40_ll.c b/drivers/dma/ste_dma40_ll.c
index 5eb6c10..435a223 100644
--- a/drivers/dma/ste_dma40_ll.c
+++ b/drivers/dma/ste_dma40_ll.c
@@ -107,11 +107,6 @@ void d40_phy_cfg(struct stedma40_chan_cfg *cfg,
src |= 1 << D40_SREG_CFG_PRI_POS;
dst |= 1 << D40_SREG_CFG_PRI_POS;
}
-
-   } else {
-   /* Logical channel */
-   dst |= 1 << D40_SREG_CFG_LOG_GIM_POS;
-   src |= 1 << D40_SREG_CFG_LOG_GIM_POS;
}
 
if (cfg->src_info.big_endian)
-- 
1.7.10.4

--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 05/39] ARM: ux500: Stop passing MMC's platform data for Device Tree boots

2013-05-15 Thread Lee Jones
It was required to pass DMA channel configuration information to the
MMC driver before the new DMA API was in place. Now that it is, and
is fully compatible with Device Tree we can stop doing that.

Reviewed-by: Linus Walleij 
Signed-off-by: Lee Jones 
---
 arch/arm/mach-ux500/cpu-db8500.c |8 
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/arch/arm/mach-ux500/cpu-db8500.c b/arch/arm/mach-ux500/cpu-db8500.c
index 9b26fe2..96ddbae 100644
--- a/arch/arm/mach-ux500/cpu-db8500.c
+++ b/arch/arm/mach-ux500/cpu-db8500.c
@@ -234,10 +234,10 @@ static struct of_dev_auxdata u8500_auxdata_lookup[] 
__initdata = {
OF_DEV_AUXDATA("arm,pl011", 0x80121000, "uart1", NULL),
OF_DEV_AUXDATA("arm,pl011", 0x80007000, "uart2", NULL),
OF_DEV_AUXDATA("arm,pl022", 0x80002000, "ssp0",  &ssp0_plat),
-   OF_DEV_AUXDATA("arm,pl18x", 0x80126000, "sdi0",  &mop500_sdi0_data),
-   OF_DEV_AUXDATA("arm,pl18x", 0x80118000, "sdi1",  &mop500_sdi1_data),
-   OF_DEV_AUXDATA("arm,pl18x", 0x80005000, "sdi2",  &mop500_sdi2_data),
-   OF_DEV_AUXDATA("arm,pl18x", 0x80114000, "sdi4",  &mop500_sdi4_data),
+   OF_DEV_AUXDATA("arm,pl18x", 0x80126000, "sdi0",  NULL),
+   OF_DEV_AUXDATA("arm,pl18x", 0x80118000, "sdi1",  NULL),
+   OF_DEV_AUXDATA("arm,pl18x", 0x80005000, "sdi2",  NULL),
+   OF_DEV_AUXDATA("arm,pl18x", 0x80114000, "sdi4",  NULL),
/* Requires clock name bindings. */
OF_DEV_AUXDATA("st,nomadik-gpio", 0x8012e000, "gpio.0", NULL),
OF_DEV_AUXDATA("st,nomadik-gpio", 0x8012e080, "gpio.1", NULL),
-- 
1.7.10.4

--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 06/39] ARM: ux500: Move SDI (MMC) and UART devices under more descriptive heading

2013-05-15 Thread Lee Jones
Now DMA DT bindings exist and are in use by he MMC and UART drivers, it
should be possible to remove them from the auxdata structure. However,
after doing so the drivers fail. Common clk is still reliant on the
dev_name() call to do device name matching, which will fail due to the
fact that Device Tree naming differs somewhat do the more traditional
conventions.

Reviewed-by: Linus Walleij 
Signed-off-by: Lee Jones 
---
 arch/arm/mach-ux500/cpu-db8500.c |4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/arch/arm/mach-ux500/cpu-db8500.c b/arch/arm/mach-ux500/cpu-db8500.c
index 96ddbae..b1c9241 100644
--- a/arch/arm/mach-ux500/cpu-db8500.c
+++ b/arch/arm/mach-ux500/cpu-db8500.c
@@ -230,15 +230,15 @@ static struct of_dev_auxdata u8500_auxdata_lookup[] 
__initdata = {
/* Requires call-back bindings. */
OF_DEV_AUXDATA("arm,cortex-a9-pmu", 0, "arm-pmu", &db8500_pmu_platdata),
/* Requires DMA bindings. */
+   OF_DEV_AUXDATA("arm,pl022", 0x80002000, "ssp0",  &ssp0_plat),
+   /* Requires clock name bindings. */
OF_DEV_AUXDATA("arm,pl011", 0x8012, "uart0", NULL),
OF_DEV_AUXDATA("arm,pl011", 0x80121000, "uart1", NULL),
OF_DEV_AUXDATA("arm,pl011", 0x80007000, "uart2", NULL),
-   OF_DEV_AUXDATA("arm,pl022", 0x80002000, "ssp0",  &ssp0_plat),
OF_DEV_AUXDATA("arm,pl18x", 0x80126000, "sdi0",  NULL),
OF_DEV_AUXDATA("arm,pl18x", 0x80118000, "sdi1",  NULL),
OF_DEV_AUXDATA("arm,pl18x", 0x80005000, "sdi2",  NULL),
OF_DEV_AUXDATA("arm,pl18x", 0x80114000, "sdi4",  NULL),
-   /* Requires clock name bindings. */
OF_DEV_AUXDATA("st,nomadik-gpio", 0x8012e000, "gpio.0", NULL),
OF_DEV_AUXDATA("st,nomadik-gpio", 0x8012e080, "gpio.1", NULL),
OF_DEV_AUXDATA("st,nomadik-gpio", 0x8000e000, "gpio.2", NULL),
-- 
1.7.10.4

--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 08/39] dmaengine: ste_dma40: Remove redundant address fetching function

2013-05-15 Thread Lee Jones
Addresses are now stored in local data structures and are easy to
obtain, thus a specialist function used to fetch them is now surplus
to requirement.

Signed-off-by: Lee Jones 
---
 drivers/dma/ste_dma40.c |   18 --
 1 file changed, 18 deletions(-)

diff --git a/drivers/dma/ste_dma40.c b/drivers/dma/ste_dma40.c
index 57a127e..6ed7757 100644
--- a/drivers/dma/ste_dma40.c
+++ b/drivers/dma/ste_dma40.c
@@ -2267,24 +2267,6 @@ err:
return NULL;
 }
 
-static dma_addr_t
-d40_get_dev_addr(struct d40_chan *chan, enum dma_transfer_direction direction)
-{
-   struct stedma40_platform_data *plat = chan->base->plat_data;
-   struct stedma40_chan_cfg *cfg = &chan->dma_cfg;
-   dma_addr_t addr = 0;
-
-   if (chan->runtime_addr)
-   return chan->runtime_addr;
-
-   if (direction == DMA_DEV_TO_MEM)
-   addr = plat->dev_rx[cfg->dev_type];
-   else if (direction == DMA_MEM_TO_DEV)
-   addr = plat->dev_tx[cfg->dev_type];
-
-   return addr;
-}
-
 static struct dma_async_tx_descriptor *
 d40_prep_sg(struct dma_chan *dchan, struct scatterlist *sg_src,
struct scatterlist *sg_dst, unsigned int sg_len,
-- 
1.7.10.4

--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 07/39] dmaengine: ste_dma40: Only use addresses passed as configuration information

2013-05-15 Thread Lee Jones
Addresses are passed in from the client's driver via the invocation of
dmaengine_slave_config(), so there's no need to fetch them from platform
data too, hardwired or otherwise. This is a great step forward, as it
elevates a large burden from platform data in the way of a look-up
table.

Signed-off-by: Lee Jones 
---
 drivers/dma/ste_dma40.c |   51 ++-
 1 file changed, 11 insertions(+), 40 deletions(-)

diff --git a/drivers/dma/ste_dma40.c b/drivers/dma/ste_dma40.c
index ba84df8..57a127e 100644
--- a/drivers/dma/ste_dma40.c
+++ b/drivers/dma/ste_dma40.c
@@ -1774,22 +1774,6 @@ static int d40_validate_conf(struct d40_chan *d40c,
res = -EINVAL;
}
 
-   if (conf->dir == STEDMA40_MEM_TO_PERIPH &&
-   d40c->base->plat_data->dev_tx[conf->dev_type] == 0 &&
-   d40c->runtime_addr == 0) {
-   chan_err(d40c, "Invalid TX channel address (%d)\n",
-conf->dev_type);
-   res = -EINVAL;
-   }
-
-   if (conf->dir == STEDMA40_PERIPH_TO_MEM &&
-   d40c->base->plat_data->dev_rx[conf->dev_type] == 0 &&
-   d40c->runtime_addr == 0) {
-   chan_err(d40c, "Invalid RX channel address (%d)\n",
-conf->dev_type);
-   res = -EINVAL;
-   }
-
if (conf->dir == STEDMA40_PERIPH_TO_PERIPH) {
/*
 * DMAC HW supports it. Will be added to this driver,
@@ -2327,14 +2311,10 @@ d40_prep_sg(struct dma_chan *dchan, struct scatterlist 
*sg_src,
if (sg_next(&sg_src[sg_len - 1]) == sg_src)
desc->cyclic = true;
 
-   if (direction != DMA_TRANS_NONE) {
-   dma_addr_t dev_addr = d40_get_dev_addr(chan, direction);
-
-   if (direction == DMA_DEV_TO_MEM)
-   src_dev_addr = dev_addr;
-   else if (direction == DMA_MEM_TO_DEV)
-   dst_dev_addr = dev_addr;
-   }
+   if (direction == DMA_DEV_TO_MEM)
+   src_dev_addr = chan->runtime_addr;
+   else if (direction == DMA_MEM_TO_DEV)
+   dst_dev_addr = chan->runtime_addr;
 
if (chan_is_logical(chan))
ret = d40_prep_sg_log(chan, desc, sg_src, sg_dst,
@@ -2782,15 +2762,8 @@ static int d40_set_runtime_config(struct dma_chan *chan,
dst_maxburst = config->dst_maxburst;
 
if (config->direction == DMA_DEV_TO_MEM) {
-   dma_addr_t dev_addr_rx =
-   d40c->base->plat_data->dev_rx[cfg->dev_type];
-
config_addr = config->src_addr;
-   if (dev_addr_rx)
-   dev_dbg(d40c->base->dev,
-   "channel has a pre-wired RX address %08x "
-   "overriding with %08x\n",
-   dev_addr_rx, config_addr);
+
if (cfg->dir != STEDMA40_PERIPH_TO_MEM)
dev_dbg(d40c->base->dev,
"channel was not configured for peripheral "
@@ -2805,15 +2778,8 @@ static int d40_set_runtime_config(struct dma_chan *chan,
dst_maxburst = src_maxburst;
 
} else if (config->direction == DMA_MEM_TO_DEV) {
-   dma_addr_t dev_addr_tx =
-   d40c->base->plat_data->dev_tx[cfg->dev_type];
-
config_addr = config->dst_addr;
-   if (dev_addr_tx)
-   dev_dbg(d40c->base->dev,
-   "channel has a pre-wired TX address %08x "
-   "overriding with %08x\n",
-   dev_addr_tx, config_addr);
+
if (cfg->dir != STEDMA40_MEM_TO_PERIPH)
dev_dbg(d40c->base->dev,
"channel was not configured for memory "
@@ -2833,6 +2799,11 @@ static int d40_set_runtime_config(struct dma_chan *chan,
return -EINVAL;
}
 
+   if (config_addr <= 0) {
+   dev_err(d40c->base->dev, "no address supplied\n");
+   return -EINVAL;
+   }
+
if (src_maxburst * src_addr_width != dst_maxburst * dst_addr_width) {
dev_err(d40c->base->dev,
"src/dst width/maxburst mismatch: %d*%d != %d*%d\n",
-- 
1.7.10.4

--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 03/39] dmaengine: ste_dma40: Don't configure runtime configurable setup during allocate

2013-05-15 Thread Lee Jones
Using the dmaengine API, allocating and configuring a channel are two
separate actions. Here we're removing logical channel configuration from
the channel allocating routines.

Cc: Vinod Koul 
Cc: Dan Williams 
Cc: Per Forlin 
Cc: Rabin Vincent 
Signed-off-by: Lee Jones 
---
 drivers/dma/ste_dma40.c |6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/dma/ste_dma40.c b/drivers/dma/ste_dma40.c
index b7fe46b..ba84df8 100644
--- a/drivers/dma/ste_dma40.c
+++ b/drivers/dma/ste_dma40.c
@@ -2040,6 +2040,9 @@ static int d40_config_memcpy(struct d40_chan *d40c)
d40c->dma_cfg = dma40_memcpy_conf_log;
d40c->dma_cfg.dev_type = 
dma40_memcpy_channels[d40c->chan.chan_id];
 
+   d40_log_cfg(&d40c->dma_cfg,
+   &d40c->log_def.lcsp1, &d40c->log_def.lcsp3);
+
} else if (dma_has_cap(DMA_MEMCPY, cap) &&
   dma_has_cap(DMA_SLAVE, cap)) {
d40c->dma_cfg = dma40_memcpy_conf_phy;
@@ -2508,9 +2511,6 @@ static int d40_alloc_chan_resources(struct dma_chan *chan)
d40_set_prio_realtime(d40c);
 
if (chan_is_logical(d40c)) {
-   d40_log_cfg(&d40c->dma_cfg,
-   &d40c->log_def.lcsp1, &d40c->log_def.lcsp3);
-
if (d40c->dma_cfg.dir == STEDMA40_PERIPH_TO_MEM)
d40c->lcpa = d40c->base->lcpa_base +
d40c->dma_cfg.dev_type * D40_LCPA_CHAN_SIZE;
-- 
1.7.10.4

--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


About usbmisc_imx.c at chipidea driver

2013-05-15 Thread Peter Chen
Hi Michael & Marc,

Recently, I have worked at i.mx USB loadable module support for  chipidea 
driver,
it needs to write non-core register during the ci13xxx_imx remove process,
but currently, the usbmisc_imx is a driver, and it uses symbol from
ci13xxx_imx, so it will be unload first.

How about I make usbmisc_imx as lib, and using DT entries from ci13xxx_imx?
In fact, if we need support full feature usb functions, it needs touch
non-core register from time to time, eg disable/enable wakeup during
runtime-pm.

Any other suggestions are welcome
Thanks.

-- 

Best Regards,
Peter Chen

--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: About usbmisc_imx.c at chipidea driver

2013-05-15 Thread Alexander Shishkin
Peter Chen  writes:

> Hi Michael & Marc,
>
> Recently, I have worked at i.mx USB loadable module support for  chipidea 
> driver,
> it needs to write non-core register during the ci13xxx_imx remove process,
> but currently, the usbmisc_imx is a driver, and it uses symbol from
> ci13xxx_imx, so it will be unload first.

One driver really shouldn't be using symbols from another driver, we
should fix that first.

> How about I make usbmisc_imx as lib, and using DT entries from ci13xxx_imx?
> In fact, if we need support full feature usb functions, it needs touch
> non-core register from time to time, eg disable/enable wakeup during
> runtime-pm.

Can we move usbmisc_imx code to the imx platform pm code or something? I
suspect it's only needed during probe/remove time or power state
transitions.

Regards,
--
Alex
--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: About usbmisc_imx.c at chipidea driver

2013-05-15 Thread Sascha Hauer
On Wed, May 15, 2013 at 01:34:31PM +0300, Alexander Shishkin wrote:
> Peter Chen  writes:
> 
> > Hi Michael & Marc,
> >
> > Recently, I have worked at i.mx USB loadable module support for  chipidea 
> > driver,
> > it needs to write non-core register during the ci13xxx_imx remove process,
> > but currently, the usbmisc_imx is a driver, and it uses symbol from
> > ci13xxx_imx, so it will be unload first.
> 
> One driver really shouldn't be using symbols from another driver, we
> should fix that first.
> 
> > How about I make usbmisc_imx as lib, and using DT entries from ci13xxx_imx?
> > In fact, if we need support full feature usb functions, it needs touch
> > non-core register from time to time, eg disable/enable wakeup during
> > runtime-pm.
> 
> Can we move usbmisc_imx code to the imx platform pm code or something? I
> suspect it's only needed during probe/remove time or power state
> transitions.

We are currently moving driver specific stuff *out* of architecture
code, so no.

Sascha


-- 
Pengutronix e.K.   | |
Industrial Linux Solutions | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0|
Amtsgericht Hildesheim, HRA 2686   | Fax:   +49-5121-206917- |
--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: About usbmisc_imx.c at chipidea driver

2013-05-15 Thread Alexander Shishkin
Sascha Hauer  writes:

> On Wed, May 15, 2013 at 01:34:31PM +0300, Alexander Shishkin wrote:
>> Peter Chen  writes:
>> 
>> > Hi Michael & Marc,
>> >
>> > Recently, I have worked at i.mx USB loadable module support for  chipidea 
>> > driver,
>> > it needs to write non-core register during the ci13xxx_imx remove process,
>> > but currently, the usbmisc_imx is a driver, and it uses symbol from
>> > ci13xxx_imx, so it will be unload first.
>> 
>> One driver really shouldn't be using symbols from another driver, we
>> should fix that first.
>> 
>> > How about I make usbmisc_imx as lib, and using DT entries from ci13xxx_imx?
>> > In fact, if we need support full feature usb functions, it needs touch
>> > non-core register from time to time, eg disable/enable wakeup during
>> > runtime-pm.
>> 
>> Can we move usbmisc_imx code to the imx platform pm code or something? I
>> suspect it's only needed during probe/remove time or power state
>> transitions.
>
> We are currently moving driver specific stuff *out* of architecture
> code, so no.

This is not driver specific. Nothing else but imxes have these non-core
registers, yet here we are, with a *generic* driver for that.

Regards,
--
Alex
--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: About usbmisc_imx.c at chipidea driver

2013-05-15 Thread Sascha Hauer
On Wed, May 15, 2013 at 01:59:39PM +0300, Alexander Shishkin wrote:
> Sascha Hauer  writes:
> 
> > On Wed, May 15, 2013 at 01:34:31PM +0300, Alexander Shishkin wrote:
> >> Peter Chen  writes:
> >> 
> >> > Hi Michael & Marc,
> >> >
> >> > Recently, I have worked at i.mx USB loadable module support for  
> >> > chipidea driver,
> >> > it needs to write non-core register during the ci13xxx_imx remove 
> >> > process,
> >> > but currently, the usbmisc_imx is a driver, and it uses symbol from
> >> > ci13xxx_imx, so it will be unload first.
> >> 
> >> One driver really shouldn't be using symbols from another driver, we
> >> should fix that first.
> >> 
> >> > How about I make usbmisc_imx as lib, and using DT entries from 
> >> > ci13xxx_imx?
> >> > In fact, if we need support full feature usb functions, it needs touch
> >> > non-core register from time to time, eg disable/enable wakeup during
> >> > runtime-pm.
> >> 
> >> Can we move usbmisc_imx code to the imx platform pm code or something? I
> >> suspect it's only needed during probe/remove time or power state
> >> transitions.
> >
> > We are currently moving driver specific stuff *out* of architecture
> > code, so no.
> 
> This is not driver specific. Nothing else but imxes have these non-core
> registers, yet here we are, with a *generic* driver for that.

This may not be chipidea specific, but still it's driver specific.
Having this stuff next to the driver is the right thing IMO.

No need to make the usbmisc stuff a separate module though, it could be
a part of the chipidea driver.

Sascha

-- 
Pengutronix e.K.   | |
Industrial Linux Solutions | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0|
Amtsgericht Hildesheim, HRA 2686   | Fax:   +49-5121-206917- |
--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH] console/font: Refactor font support code selection logic

2013-05-15 Thread Geert Uytterhoeven
The current Makefile rules to build font support are messy and buggy.
Replace them by Kconfig rules:
  - Introduce CONFIG_FONT_SUPPORT, which controls the building of all font
code,
  - Select CONFIG_FONT_SUPPORT for all drivers that use fonts,
  - Select CONFIG_FONT_8x16 for all drivers that default to the VGA8x16
font,
  - Drop the bogus console dependency for CONFIG_VIDEO_VIVI.

This fixes (if CONFIG_SOLO6X10=y and there are no built-in console
drivers):

drivers/built-in.o: In function `solo_osd_print':
drivers/staging/media/solo6x10/solo6x10-enc.c:144: undefined reference to 
`.find_font'

Signed-off-by: Geert Uytterhoeven 
---
 drivers/media/platform/Kconfig |2 +-
 drivers/staging/media/solo6x10/Kconfig |2 ++
 drivers/usb/misc/sisusbvga/Kconfig |1 +
 drivers/video/console/Kconfig  |   12 ++--
 drivers/video/console/Makefile |   14 +-
 5 files changed, 19 insertions(+), 12 deletions(-)

diff --git a/drivers/media/platform/Kconfig b/drivers/media/platform/Kconfig
index 0cbe1ff..c1f29d5 100644
--- a/drivers/media/platform/Kconfig
+++ b/drivers/media/platform/Kconfig
@@ -220,7 +220,7 @@ if V4L_TEST_DRIVERS
 config VIDEO_VIVI
tristate "Virtual Video Driver"
depends on VIDEO_DEV && VIDEO_V4L2 && !SPARC32 && !SPARC64
-   depends on FRAMEBUFFER_CONSOLE || STI_CONSOLE
+   select FONT_SUPPORT
select FONT_8x16
select VIDEOBUF2_VMALLOC
default n
diff --git a/drivers/staging/media/solo6x10/Kconfig 
b/drivers/staging/media/solo6x10/Kconfig
index ec32776..b34bb6c 100644
--- a/drivers/staging/media/solo6x10/Kconfig
+++ b/drivers/staging/media/solo6x10/Kconfig
@@ -1,6 +1,8 @@
 config SOLO6X10
tristate "Softlogic 6x10 MPEG codec cards"
depends on PCI && VIDEO_DEV && SND && I2C
+   select FONT_SUPPORT
+   select FONT_8x16
select VIDEOBUF2_DMA_SG
select VIDEOBUF2_DMA_CONTIG
select SND_PCM
diff --git a/drivers/usb/misc/sisusbvga/Kconfig 
b/drivers/usb/misc/sisusbvga/Kconfig
index 0d03a52..36bc28c 100644
--- a/drivers/usb/misc/sisusbvga/Kconfig
+++ b/drivers/usb/misc/sisusbvga/Kconfig
@@ -2,6 +2,7 @@
 config USB_SISUSBVGA
tristate "USB 2.0 SVGA dongle support (Net2280/SiS315)"
depends on (USB_MUSB_HDRC || USB_EHCI_HCD)
+   select FONT_SUPPORT if USB_SISUSBVGA_CON
 ---help---
  Say Y here if you intend to attach a USB2VGA dongle based on a
  Net2280 and a SiS315 chip.
diff --git a/drivers/video/console/Kconfig b/drivers/video/console/Kconfig
index bc922c4..baf27dc 100644
--- a/drivers/video/console/Kconfig
+++ b/drivers/video/console/Kconfig
@@ -62,6 +62,7 @@ config MDA_CONSOLE
 config SGI_NEWPORT_CONSOLE
 tristate "SGI Newport Console support"
 depends on SGI_IP22 
+select FONT_SUPPORT
 help
   Say Y here if you want the console on the Newport aka XL graphics
   card of your Indy.  Most people say Y here.
@@ -91,6 +92,7 @@ config FRAMEBUFFER_CONSOLE
tristate "Framebuffer Console support"
depends on FB
select CRC32
+   select FONT_SUPPORT
help
  Low-level framebuffer-based console driver.
 
@@ -123,12 +125,18 @@ config FRAMEBUFFER_CONSOLE_ROTATION
 config STI_CONSOLE
 bool "STI text console"
 depends on PARISC
+select FONT_SUPPORT
 default y
 help
   The STI console is the builtin display/keyboard on HP-PARISC
   machines.  Say Y here to build support for it into your kernel.
   The alternative is to use your primary serial port as a console.
 
+config FONT_SUPPORT
+   tristate
+
+if FONT_SUPPORT
+
 config FONTS
bool "Select compiled-in fonts"
depends on FRAMEBUFFER_CONSOLE || STI_CONSOLE
@@ -158,7 +166,6 @@ config FONT_8x8
 
 config FONT_8x16
bool "VGA 8x16 font" if FONTS
-   depends on FRAMEBUFFER_CONSOLE || SGI_NEWPORT_CONSOLE || STI_CONSOLE || 
USB_SISUSBVGA_CON
default y if !SPARC && !FONTS
help
  This is the "high resolution" font for the VGA frame buffer (the one
@@ -226,7 +233,6 @@ config FONT_10x18
 
 config FONT_AUTOSELECT
def_bool y
-   depends on FRAMEBUFFER_CONSOLE || SGI_NEWPORT_CONSOLE || STI_CONSOLE || 
USB_SISUSBVGA_CON
depends on !FONT_8x8
depends on !FONT_6x11
depends on !FONT_7x14
@@ -238,5 +244,7 @@ config FONT_AUTOSELECT
depends on !FONT_10x18
select FONT_8x16
 
+endif # FONT_SUPPORT
+
 endmenu
 
diff --git a/drivers/video/console/Makefile b/drivers/video/console/Makefile
index a862e91..3a11b63 100644
--- a/drivers/video/console/Makefile
+++ b/drivers/video/console/Makefile
@@ -18,14 +18,14 @@ font-objs-$(CONFIG_FONT_MINI_4x6)  += font_mini_4x6.o
 
 font-objs += $(font-objs-y)
 
-# Each configuration option enables a list of files.
+obj-$(CONFIG_FONT_SUPPORT) += font.o
 
 obj-$(CONFIG_DUMMY_CONSOLE)   += dummycon.o
-obj-$(CONF

Re: [PATCH] console/font: Refactor font support code selection logic

2013-05-15 Thread Hans Verkuil
On Wed 15 May 2013 13:40:50 Geert Uytterhoeven wrote:
> The current Makefile rules to build font support are messy and buggy.
> Replace them by Kconfig rules:
>   - Introduce CONFIG_FONT_SUPPORT, which controls the building of all font
> code,
>   - Select CONFIG_FONT_SUPPORT for all drivers that use fonts,
>   - Select CONFIG_FONT_8x16 for all drivers that default to the VGA8x16
> font,
>   - Drop the bogus console dependency for CONFIG_VIDEO_VIVI.
> 
> This fixes (if CONFIG_SOLO6X10=y and there are no built-in console
> drivers):
> 
> drivers/built-in.o: In function `solo_osd_print':
> drivers/staging/media/solo6x10/solo6x10-enc.c:144: undefined reference to 
> `.find_font'
> 
> Signed-off-by: Geert Uytterhoeven 

That looks much more sane. Thanks!

Acked-by: Hans Verkuil 

> ---
>  drivers/media/platform/Kconfig |2 +-
>  drivers/staging/media/solo6x10/Kconfig |2 ++
>  drivers/usb/misc/sisusbvga/Kconfig |1 +
>  drivers/video/console/Kconfig  |   12 ++--
>  drivers/video/console/Makefile |   14 +-
>  5 files changed, 19 insertions(+), 12 deletions(-)
> 
> diff --git a/drivers/media/platform/Kconfig b/drivers/media/platform/Kconfig
> index 0cbe1ff..c1f29d5 100644
> --- a/drivers/media/platform/Kconfig
> +++ b/drivers/media/platform/Kconfig
> @@ -220,7 +220,7 @@ if V4L_TEST_DRIVERS
>  config VIDEO_VIVI
>   tristate "Virtual Video Driver"
>   depends on VIDEO_DEV && VIDEO_V4L2 && !SPARC32 && !SPARC64
> - depends on FRAMEBUFFER_CONSOLE || STI_CONSOLE
> + select FONT_SUPPORT
>   select FONT_8x16
>   select VIDEOBUF2_VMALLOC
>   default n
> diff --git a/drivers/staging/media/solo6x10/Kconfig 
> b/drivers/staging/media/solo6x10/Kconfig
> index ec32776..b34bb6c 100644
> --- a/drivers/staging/media/solo6x10/Kconfig
> +++ b/drivers/staging/media/solo6x10/Kconfig
> @@ -1,6 +1,8 @@
>  config SOLO6X10
>   tristate "Softlogic 6x10 MPEG codec cards"
>   depends on PCI && VIDEO_DEV && SND && I2C
> + select FONT_SUPPORT
> + select FONT_8x16
>   select VIDEOBUF2_DMA_SG
>   select VIDEOBUF2_DMA_CONTIG
>   select SND_PCM
> diff --git a/drivers/usb/misc/sisusbvga/Kconfig 
> b/drivers/usb/misc/sisusbvga/Kconfig
> index 0d03a52..36bc28c 100644
> --- a/drivers/usb/misc/sisusbvga/Kconfig
> +++ b/drivers/usb/misc/sisusbvga/Kconfig
> @@ -2,6 +2,7 @@
>  config USB_SISUSBVGA
>   tristate "USB 2.0 SVGA dongle support (Net2280/SiS315)"
>   depends on (USB_MUSB_HDRC || USB_EHCI_HCD)
> + select FONT_SUPPORT if USB_SISUSBVGA_CON
>  ---help---
> Say Y here if you intend to attach a USB2VGA dongle based on a
> Net2280 and a SiS315 chip.
> diff --git a/drivers/video/console/Kconfig b/drivers/video/console/Kconfig
> index bc922c4..baf27dc 100644
> --- a/drivers/video/console/Kconfig
> +++ b/drivers/video/console/Kconfig
> @@ -62,6 +62,7 @@ config MDA_CONSOLE
>  config SGI_NEWPORT_CONSOLE
>  tristate "SGI Newport Console support"
>  depends on SGI_IP22 
> +select FONT_SUPPORT
>  help
>Say Y here if you want the console on the Newport aka XL graphics
>card of your Indy.  Most people say Y here.
> @@ -91,6 +92,7 @@ config FRAMEBUFFER_CONSOLE
>   tristate "Framebuffer Console support"
>   depends on FB
>   select CRC32
> + select FONT_SUPPORT
>   help
> Low-level framebuffer-based console driver.
>  
> @@ -123,12 +125,18 @@ config FRAMEBUFFER_CONSOLE_ROTATION
>  config STI_CONSOLE
>  bool "STI text console"
>  depends on PARISC
> +select FONT_SUPPORT
>  default y
>  help
>The STI console is the builtin display/keyboard on HP-PARISC
>machines.  Say Y here to build support for it into your kernel.
>The alternative is to use your primary serial port as a console.
>  
> +config FONT_SUPPORT
> + tristate
> +
> +if FONT_SUPPORT
> +
>  config FONTS
>   bool "Select compiled-in fonts"
>   depends on FRAMEBUFFER_CONSOLE || STI_CONSOLE
> @@ -158,7 +166,6 @@ config FONT_8x8
>  
>  config FONT_8x16
>   bool "VGA 8x16 font" if FONTS
> - depends on FRAMEBUFFER_CONSOLE || SGI_NEWPORT_CONSOLE || STI_CONSOLE || 
> USB_SISUSBVGA_CON
>   default y if !SPARC && !FONTS
>   help
> This is the "high resolution" font for the VGA frame buffer (the one
> @@ -226,7 +233,6 @@ config FONT_10x18
>  
>  config FONT_AUTOSELECT
>   def_bool y
> - depends on FRAMEBUFFER_CONSOLE || SGI_NEWPORT_CONSOLE || STI_CONSOLE || 
> USB_SISUSBVGA_CON
>   depends on !FONT_8x8
>   depends on !FONT_6x11
>   depends on !FONT_7x14
> @@ -238,5 +244,7 @@ config FONT_AUTOSELECT
>   depends on !FONT_10x18
>   select FONT_8x16
>  
> +endif # FONT_SUPPORT
> +
>  endmenu
>  
> diff --git a/drivers/video/console/Makefile b/drivers/video/console/Makefile
> index a862e91..3a11b63 100644
> --- a/drivers/video/console/Makefile
> ++

[PATCH -next 00/10] Various updates for ux500 musb and phy drivers

2013-05-15 Thread Fabio Baltieri
Hello Felipe,

this is another series of updates for the ux500 specific musb drivers.

This mainly upgrade the phy-ab8500-usb driver by adding support for
clock control and new ab8500 variants, with some minor refactoring of
the existing code to better handle those.

Other patches includes some coding style fixes, a patch to enable dma
support in host mode and a small workaround.

These are based on v3.10-rc1, and should merge fine with Lee's dma
patches on ux500-musb. I hope that you could review and take these for
your -next branch.

Thanks,
Fabio


Fabio Baltieri (7):
  usb: musb: various cosmetic fixes on ux500 files
  usb: phy: ab8500-usb: fix phy tuning value select logic
  usb: phy: ab8500-usb: add platform_device_id table
  usb: phy: ab8500-usb: move phy tuning values on separate functions
  usb: phy: ab8500-usb: add flag bits to control driver features
  usb: phy: ab8500-usb: add ab8540 support
  usb: phy: ab8500-usb: add ab9540 support

Mian Yousaf Kaukab (2):
  usb: musb: enable ux500 host side dma support
  usb: phy: ab8500-usb: add transceiver clock control

Sakethram Bommisetti (1):
  usb: phy: ab8500-usb: restart phy during probe

 drivers/usb/musb/musb_host.c |   8 +-
 drivers/usb/musb/ux500_dma.c |   6 +-
 drivers/usb/phy/phy-ab8500-usb.c | 846 +--
 3 files changed, 733 insertions(+), 127 deletions(-)

-- 
1.8.2

--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 04/10] usb: phy: ab8500-usb: restart phy during probe

2013-05-15 Thread Fabio Baltieri
From: Sakethram Bommisetti 

Add an ab8500_usb_restart_phy() function called during probe to ensure
that the AB8500 USB phy is initialized properly even when a cable is
connected at probe time.

Without this fix subsequent host reconnections are not detected
properly.

Acked-by: Linus Walleij 
Acked-by: Maxime Coquelin 
Signed-off-by: Sakethram Bommisetti 
Signed-off-by: Fabio Baltieri 
---
 drivers/usb/phy/phy-ab8500-usb.c | 33 +
 1 file changed, 33 insertions(+)

diff --git a/drivers/usb/phy/phy-ab8500-usb.c b/drivers/usb/phy/phy-ab8500-usb.c
index cc0d7e5..bbe51cc 100644
--- a/drivers/usb/phy/phy-ab8500-usb.c
+++ b/drivers/usb/phy/phy-ab8500-usb.c
@@ -668,6 +668,33 @@ static int ab8500_usb_set_host(struct usb_otg *otg, struct 
usb_bus *host)
return 0;
 }
 
+static void ab8500_usb_restart_phy(struct ab8500_usb *ab)
+{
+   abx500_mask_and_set_register_interruptible(ab->dev,
+   AB8500_USB, AB8500_USB_PHY_CTRL_REG,
+   AB8500_BIT_PHY_CTRL_DEVICE_EN,
+   AB8500_BIT_PHY_CTRL_DEVICE_EN);
+
+   udelay(100);
+
+   abx500_mask_and_set_register_interruptible(ab->dev,
+   AB8500_USB, AB8500_USB_PHY_CTRL_REG,
+   AB8500_BIT_PHY_CTRL_DEVICE_EN,
+   0);
+
+   abx500_mask_and_set_register_interruptible(ab->dev,
+   AB8500_USB, AB8500_USB_PHY_CTRL_REG,
+   AB8500_BIT_PHY_CTRL_HOST_EN,
+   AB8500_BIT_PHY_CTRL_HOST_EN);
+
+   udelay(100);
+
+   abx500_mask_and_set_register_interruptible(ab->dev,
+   AB8500_USB, AB8500_USB_PHY_CTRL_REG,
+   AB8500_BIT_PHY_CTRL_HOST_EN,
+   0);
+}
+
 static int ab8500_usb_regulator_get(struct ab8500_usb *ab)
 {
int err;
@@ -887,6 +914,12 @@ static int ab8500_usb_probe(struct platform_device *pdev)
/* Needed to enable ID detection. */
ab8500_usb_wd_workaround(ab);
 
+   /*
+* This is required for usb-link-status to work properly when a
+* cable is connected at boot time.
+*/
+   ab8500_usb_restart_phy(ab);
+
abx500_usb_link_status_update(ab);
 
dev_info(&pdev->dev, "revision 0x%2x driver initialized\n", rev);
-- 
1.8.2

--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 06/10] usb: phy: ab8500-usb: add platform_device_id table

2013-05-15 Thread Fabio Baltieri
Add an initial platform_device_id table to the ab8500-usb driver to
allow probing additional variants of the ab8500 family chips.

Acked-by: Linus Walleij 
Acked-by: Maxime Coquelin 
Signed-off-by: Fabio Baltieri 
---
 drivers/usb/phy/phy-ab8500-usb.c | 10 --
 1 file changed, 8 insertions(+), 2 deletions(-)

diff --git a/drivers/usb/phy/phy-ab8500-usb.c b/drivers/usb/phy/phy-ab8500-usb.c
index d105cce..2e8db60 100644
--- a/drivers/usb/phy/phy-ab8500-usb.c
+++ b/drivers/usb/phy/phy-ab8500-usb.c
@@ -945,11 +945,18 @@ static int ab8500_usb_remove(struct platform_device *pdev)
return 0;
 }
 
+static struct platform_device_id ab8500_usb_devtype[] = {
+   { .name = "ab8500-usb", },
+   { /* sentinel */ }
+};
+MODULE_DEVICE_TABLE(platform, ab8500_usb_devtype);
+
 static struct platform_driver ab8500_usb_driver = {
.probe  = ab8500_usb_probe,
.remove = ab8500_usb_remove,
+   .id_table   = ab8500_usb_devtype,
.driver = {
-   .name   = "ab8500-usb",
+   .name   = "abx5x0-usb",
.owner  = THIS_MODULE,
},
 };
@@ -966,7 +973,6 @@ static void __exit ab8500_usb_exit(void)
 }
 module_exit(ab8500_usb_exit);
 
-MODULE_ALIAS("platform:ab8500_usb");
 MODULE_AUTHOR("ST-Ericsson AB");
 MODULE_DESCRIPTION("AB8500 usb transceiver driver");
 MODULE_LICENSE("GPL");
-- 
1.8.2

--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 07/10] usb: phy: ab8500-usb: move phy tuning values on separate functions

2013-05-15 Thread Fabio Baltieri
Move each chip's PHY tuning value set code to a separate function to
improve code readability.

Acked-by: Linus Walleij 
Acked-by: Maxime Coquelin 
Signed-off-by: Fabio Baltieri 
---
 drivers/usb/phy/phy-ab8500-usb.c | 161 +--
 1 file changed, 86 insertions(+), 75 deletions(-)

diff --git a/drivers/usb/phy/phy-ab8500-usb.c b/drivers/usb/phy/phy-ab8500-usb.c
index 2e8db60..9b9a975 100644
--- a/drivers/usb/phy/phy-ab8500-usb.c
+++ b/drivers/usb/phy/phy-ab8500-usb.c
@@ -771,6 +771,86 @@ static int ab8500_usb_irq_setup(struct platform_device 
*pdev,
return 0;
 }
 
+static void ab8500_usb_set_ab8500_tuning_values(struct ab8500_usb *ab)
+{
+   int err;
+
+   /* Enable the PBT/Bank 0x12 access */
+   err = abx500_set_register_interruptible(ab->dev,
+   AB8500_DEVELOPMENT, AB8500_BANK12_ACCESS, 0x01);
+   if (err < 0)
+   dev_err(ab->dev, "Failed to enable bank12 access err=%d\n",
+   err);
+
+   err = abx500_set_register_interruptible(ab->dev,
+   AB8500_DEBUG, AB8500_USB_PHY_TUNE1, 0xC8);
+   if (err < 0)
+   dev_err(ab->dev, "Failed to set PHY_TUNE1 register err=%d\n",
+   err);
+
+   err = abx500_set_register_interruptible(ab->dev,
+   AB8500_DEBUG, AB8500_USB_PHY_TUNE2, 0x00);
+   if (err < 0)
+   dev_err(ab->dev, "Failed to set PHY_TUNE2 register err=%d\n",
+   err);
+
+   err = abx500_set_register_interruptible(ab->dev,
+   AB8500_DEBUG, AB8500_USB_PHY_TUNE3, 0x78);
+   if (err < 0)
+   dev_err(ab->dev, "Failed to set PHY_TUNE3 regester err=%d\n",
+   err);
+
+   /* Switch to normal mode/disable Bank 0x12 access */
+   err = abx500_set_register_interruptible(ab->dev,
+   AB8500_DEVELOPMENT, AB8500_BANK12_ACCESS, 0x00);
+   if (err < 0)
+   dev_err(ab->dev, "Failed to switch bank12 access err=%d\n",
+   err);
+}
+
+static void ab8500_usb_set_ab8505_tuning_values(struct ab8500_usb *ab)
+{
+   int err;
+
+   /* Enable the PBT/Bank 0x12 access */
+   err = abx500_mask_and_set_register_interruptible(ab->dev,
+   AB8500_DEVELOPMENT, AB8500_BANK12_ACCESS,
+   0x01, 0x01);
+   if (err < 0)
+   dev_err(ab->dev, "Failed to enable bank12 access err=%d\n",
+   err);
+
+   err = abx500_mask_and_set_register_interruptible(ab->dev,
+   AB8500_DEBUG, AB8500_USB_PHY_TUNE1,
+   0xC8, 0xC8);
+   if (err < 0)
+   dev_err(ab->dev, "Failed to set PHY_TUNE1 register err=%d\n",
+   err);
+
+   err = abx500_mask_and_set_register_interruptible(ab->dev,
+   AB8500_DEBUG, AB8500_USB_PHY_TUNE2,
+   0x60, 0x60);
+   if (err < 0)
+   dev_err(ab->dev, "Failed to set PHY_TUNE2 register err=%d\n",
+   err);
+
+   err = abx500_mask_and_set_register_interruptible(ab->dev,
+   AB8500_DEBUG, AB8500_USB_PHY_TUNE3,
+   0xFC, 0x80);
+
+   if (err < 0)
+   dev_err(ab->dev, "Failed to set PHY_TUNE3 regester err=%d\n",
+   err);
+
+   /* Switch to normal mode/disable Bank 0x12 access */
+   err = abx500_mask_and_set_register_interruptible(ab->dev,
+   AB8500_DEVELOPMENT, AB8500_BANK12_ACCESS,
+   0x00, 0x00);
+   if (err < 0)
+   dev_err(ab->dev, "Failed to switch bank12 access err=%d\n",
+   err);
+}
+
 static int ab8500_usb_probe(struct platform_device *pdev)
 {
struct ab8500_usb   *ab;
@@ -835,81 +915,12 @@ static int ab8500_usb_probe(struct platform_device *pdev)
return err;
}
 
-   /* Phy tuning values for AB8500 > v2.0 */
-   if (is_ab8500(ab->ab8500) && !is_ab8500_2p0_or_earlier(ab->ab8500)) {
-   /* Enable the PBT/Bank 0x12 access */
-   err = abx500_set_register_interruptible(ab->dev,
-   AB8500_DEVELOPMENT, AB8500_BANK12_ACCESS, 0x01);
-   if (err < 0)
-   dev_err(ab->dev, "Failed to enable bank12 access 
err=%d\n",
-   err);
-
-   err = abx500_set_register_interruptible(ab->dev,
-   AB8500_DEBUG, AB8500_USB_PHY_TUNE1, 0xC8);
-   if (err < 0)
-   dev_err(ab->dev, "Failed to set PHY_TUNE1 register 
err=%d\n",
-   err);
-
-   err = abx500_set_register_interruptible(ab->dev,
-   AB8500_DEBUG, AB8500_USB_PH

[PATCH 08/10] usb: phy: ab8500-usb: add flag bits to control driver features

2013-05-15 Thread Fabio Baltieri
Introduce a "flags" field in "struct ab8500_usb" to allow controlling
driver features and quirks depending on ab8500 chip variant and
revision.

Acked-by: Linus Walleij 
Acked-by: Maxime Coquelin 
Signed-off-by: Fabio Baltieri 
---
 drivers/usb/phy/phy-ab8500-usb.c | 109 ++-
 1 file changed, 73 insertions(+), 36 deletions(-)

diff --git a/drivers/usb/phy/phy-ab8500-usb.c b/drivers/usb/phy/phy-ab8500-usb.c
index 9b9a975..4591698 100644
--- a/drivers/usb/phy/phy-ab8500-usb.c
+++ b/drivers/usb/phy/phy-ab8500-usb.c
@@ -121,6 +121,17 @@ enum ab8500_usb_mode {
USB_DEDICATED_CHG
 };
 
+/* Register USB_LINK_STATUS interrupt */
+#define AB8500_USB_FLAG_USE_LINK_STATUS_IRQ(1 << 0)
+/* Register ID_WAKEUP_F interrupt */
+#define AB8500_USB_FLAG_USE_ID_WAKEUP_IRQ  (1 << 1)
+/* Register VBUS_DET_F interrupt */
+#define AB8500_USB_FLAG_USE_VBUS_DET_IRQ   (1 << 2)
+/* Driver is using the ab-iddet driver*/
+#define AB8500_USB_FLAG_USE_AB_IDDET   (1 << 3)
+/* Enable setting regulators voltage */
+#define AB8500_USB_FLAG_REGULATOR_SET_VOLTAGE  (1 << 4)
+
 struct ab8500_usb {
struct usb_phy phy;
struct device *dev;
@@ -136,6 +147,7 @@ struct ab8500_usb {
int previous_link_status_state;
struct pinctrl *pinctrl;
struct pinctrl_state *pins_sleep;
+   unsigned int flags;
 };
 
 static inline struct ab8500_usb *phy_to_ab(struct usb_phy *x)
@@ -174,7 +186,7 @@ static void ab8500_usb_regulator_enable(struct ab8500_usb 
*ab)
if (ret)
dev_err(ab->dev, "Failed to enable v-ape\n");
 
-   if (!is_ab8500_2p0_or_earlier(ab->ab8500)) {
+   if (ab->flags & AB8500_USB_FLAG_REGULATOR_SET_VOLTAGE) {
ab->saved_v_ulpi = regulator_get_voltage(ab->v_ulpi);
if (ab->saved_v_ulpi < 0)
dev_err(ab->dev, "Failed to get v_ulpi voltage\n");
@@ -194,7 +206,7 @@ static void ab8500_usb_regulator_enable(struct ab8500_usb 
*ab)
if (ret)
dev_err(ab->dev, "Failed to enable vddulpivio18\n");
 
-   if (!is_ab8500_2p0_or_earlier(ab->ab8500)) {
+   if (ab->flags & AB8500_USB_FLAG_REGULATOR_SET_VOLTAGE) {
volt = regulator_get_voltage(ab->v_ulpi);
if ((volt != 130) && (volt != 135))
dev_err(ab->dev, "Vintcore is not set to 1.3V 
volt=%d\n",
@@ -215,7 +227,7 @@ static void ab8500_usb_regulator_disable(struct ab8500_usb 
*ab)
regulator_disable(ab->v_ulpi);
 
/* USB is not the only consumer of Vintcore, restore old settings */
-   if (!is_ab8500_2p0_or_earlier(ab->ab8500)) {
+   if (ab->flags & AB8500_USB_FLAG_REGULATOR_SET_VOLTAGE) {
if (ab->saved_v_ulpi > 0) {
ret = regulator_set_voltage(ab->v_ulpi,
ab->saved_v_ulpi, ab->saved_v_ulpi);
@@ -729,43 +741,52 @@ static int ab8500_usb_irq_setup(struct platform_device 
*pdev,
int err;
int irq;
 
-   irq = platform_get_irq_byname(pdev, "USB_LINK_STATUS");
-   if (irq < 0) {
-   dev_err(&pdev->dev, "Link status irq not found\n");
-   return irq;
-   }
-   err = devm_request_threaded_irq(&pdev->dev, irq, NULL,
-   ab8500_usb_link_status_irq,
-   IRQF_NO_SUSPEND | IRQF_SHARED, "usb-link-status", ab);
-   if (err < 0) {
-   dev_err(ab->dev, "request_irq failed for link status irq\n");
-   return err;
+   if (ab->flags & AB8500_USB_FLAG_USE_LINK_STATUS_IRQ) {
+   irq = platform_get_irq_byname(pdev, "USB_LINK_STATUS");
+   if (irq < 0) {
+   dev_err(&pdev->dev, "Link status irq not found\n");
+   return irq;
+   }
+   err = devm_request_threaded_irq(&pdev->dev, irq, NULL,
+   ab8500_usb_link_status_irq,
+   IRQF_NO_SUSPEND | IRQF_SHARED,
+   "usb-link-status", ab);
+   if (err < 0) {
+   dev_err(ab->dev, "request_irq failed for link status 
irq\n");
+   return err;
+   }
}
 
-   irq = platform_get_irq_byname(pdev, "ID_WAKEUP_F");
-   if (irq < 0) {
-   dev_err(&pdev->dev, "ID fall irq not found\n");
-   return irq;
-   }
-   err = devm_request_threaded_irq(&pdev->dev, irq, NULL,
-   ab8500_usb_disconnect_irq,
-   IRQF_NO_SUSPEND | IRQF_SHARED, "usb-id-fall", ab);
-   if (err < 0) {
-   dev_err(ab->dev, "request_irq failed for ID fall irq\n");
-   return err;
+   if (ab->flags & AB8500_USB_FLAG_USE_ID_WAKEUP_IRQ) {
+   irq = platform_get_irq_byname(pdev, "ID_WAKEUP_F");
+   if (irq < 0) {
+   dev_err(&pdev->dev, "ID fall irq not

[PATCH 09/10] usb: phy: ab8500-usb: add ab8540 support

2013-05-15 Thread Fabio Baltieri
Add support for the ab8540 variant of the ab8500 family.

Acked-by: Linus Walleij 
Acked-by: Maxime Coquelin 
Cc: Avinash Kumar 
Signed-off-by: Fabio Baltieri 
---
 drivers/usb/phy/phy-ab8500-usb.c | 297 ++-
 1 file changed, 294 insertions(+), 3 deletions(-)

diff --git a/drivers/usb/phy/phy-ab8500-usb.c b/drivers/usb/phy/phy-ab8500-usb.c
index 4591698..869ca26 100644
--- a/drivers/usb/phy/phy-ab8500-usb.c
+++ b/drivers/usb/phy/phy-ab8500-usb.c
@@ -1,10 +1,11 @@
 /*
  * drivers/usb/otg/ab8500_usb.c
  *
- * USB transceiver driver for AB8500 chip
+ * USB transceiver driver for AB8500 family chips
  *
- * Copyright (C) 2010 ST-Ericsson AB
+ * Copyright (C) 2010-2013 ST-Ericsson AB
  * Mian Yousaf Kaukab 
+ * Avinash Kumar 
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
@@ -43,21 +44,33 @@
 /* Bank AB8500_USB */
 #define AB8500_USB_LINE_STAT_REG 0x80
 #define AB8505_USB_LINE_STAT_REG 0x94
+#define AB8540_USB_LINK_STAT_REG 0x94
+#define AB8540_USB_OTG_CTL_REG 0x87
 #define AB8500_USB_PHY_CTRL_REG 0x8A
+#define AB8540_VBUS_CTRL_REG 0x82
 
 /* Bank AB8500_DEVELOPMENT */
 #define AB8500_BANK12_ACCESS 0x00
 
 /* Bank AB8500_DEBUG */
+#define AB8540_DEBUG 0x32
 #define AB8500_USB_PHY_TUNE1 0x05
 #define AB8500_USB_PHY_TUNE2 0x06
 #define AB8500_USB_PHY_TUNE3 0x07
 
+/* Bank AB8500_INTERRUPT */
+#define AB8500_IT_SOURCE2_REG 0x01
+
 #define AB8500_BIT_OTG_STAT_ID (1 << 0)
 #define AB8500_BIT_PHY_CTRL_HOST_EN (1 << 0)
 #define AB8500_BIT_PHY_CTRL_DEVICE_EN (1 << 1)
 #define AB8500_BIT_WD_CTRL_ENABLE (1 << 0)
 #define AB8500_BIT_WD_CTRL_KICK (1 << 1)
+#define AB8500_BIT_SOURCE2_VBUSDET (1 << 7)
+#define AB8540_BIT_OTG_CTL_VBUS_VALID_ENA (1 << 0)
+#define AB8540_BIT_OTG_CTL_ID_HOST_ENA (1 << 1)
+#define AB8540_BIT_OTG_CTL_ID_DEV_ENA (1 << 5)
+#define AB8540_BIT_VBUS_CTRL_CHARG_DET_ENA (1 << 0)
 
 #define AB8500_WD_KICK_DELAY_US 100 /* usec */
 #define AB8500_WD_V11_DISABLE_DELAY_US 100 /* usec */
@@ -114,6 +127,37 @@ enum ab8505_usb_link_status {
USB_LINK_MOTOROLA_FACTORY_CBL_PHY_EN_8505,
 };
 
+enum ab8540_usb_link_status {
+   USB_LINK_NOT_CONFIGURED_8540 = 0,
+   USB_LINK_STD_HOST_NC_8540,
+   USB_LINK_STD_HOST_C_NS_8540,
+   USB_LINK_STD_HOST_C_S_8540,
+   USB_LINK_CDP_8540,
+   USB_LINK_RESERVED0_8540,
+   USB_LINK_RESERVED1_8540,
+   USB_LINK_DEDICATED_CHG_8540,
+   USB_LINK_ACA_RID_A_8540,
+   USB_LINK_ACA_RID_B_8540,
+   USB_LINK_ACA_RID_C_NM_8540,
+   USB_LINK_RESERVED2_8540,
+   USB_LINK_RESERVED3_8540,
+   USB_LINK_HM_IDGND_8540,
+   USB_LINK_CHARGERPORT_NOT_OK_8540,
+   USB_LINK_CHARGER_DM_HIGH_8540,
+   USB_LINK_PHYEN_NO_VBUS_NO_IDGND_8540,
+   USB_LINK_STD_UPSTREAM_NO_IDGNG_VBUS_8540,
+   USB_LINK_STD_UPSTREAM_8540,
+   USB_LINK_CHARGER_SE1_8540,
+   USB_LINK_CARKIT_CHGR_1_8540,
+   USB_LINK_CARKIT_CHGR_2_8540,
+   USB_LINK_ACA_DOCK_CHGR_8540,
+   USB_LINK_SAMSUNG_BOOT_CBL_PHY_EN_8540,
+   USB_LINK_SAMSUNG_BOOT_CBL_PHY_DISB_8540,
+   USB_LINK_SAMSUNG_UART_CBL_PHY_EN_8540,
+   USB_LINK_SAMSUNG_UART_CBL_PHY_DISB_8540,
+   USB_LINK_MOTOROLA_FACTORY_CBL_PHY_EN_8540
+};
+
 enum ab8500_usb_mode {
USB_IDLE = 0,
USB_PERIPHERAL,
@@ -131,6 +175,10 @@ enum ab8500_usb_mode {
 #define AB8500_USB_FLAG_USE_AB_IDDET   (1 << 3)
 /* Enable setting regulators voltage */
 #define AB8500_USB_FLAG_REGULATOR_SET_VOLTAGE  (1 << 4)
+/* Enable the check_vbus_status workaround */
+#define AB8500_USB_FLAG_USE_CHECK_VBUS_STATUS  (1 << 5)
+/* Enable the vbus host workaround */
+#define AB8500_USB_FLAG_USE_VBUS_HOST_QUIRK(1 << 6)
 
 struct ab8500_usb {
struct usb_phy phy;
@@ -138,6 +186,7 @@ struct ab8500_usb {
struct ab8500 *ab8500;
unsigned vbus_draw;
struct work_struct phy_dis_work;
+   struct work_struct vbus_event_work;
enum ab8500_usb_mode mode;
struct clk *sysclk;
struct regulator *v_ape;
@@ -147,6 +196,7 @@ struct ab8500_usb {
int previous_link_status_state;
struct pinctrl *pinctrl;
struct pinctrl_state *pins_sleep;
+   bool enabled_charging_detection;
unsigned int flags;
 };
 
@@ -275,6 +325,15 @@ static void ab8500_usb_phy_enable(struct ab8500_usb *ab, 
bool sel_host)
abx500_mask_and_set_register_interruptible(ab->dev,
AB8500_USB, AB8500_USB_PHY_CTRL_REG,
bit, bit);
+
+   if (ab->flags & AB8500_USB_FLAG_USE_VBUS_HOST_QUIRK) {
+   if (sel_host)
+   abx500_set_register_interruptible(ab->dev,
+   AB8500_USB, AB8540_USB_OTG_CTL_REG,
+   AB8540_BIT_OTG_CTL_VBUS_VALID_ENA |
+   AB8540_BIT_OTG_CTL_ID_HOST_ENA |
+   AB8540_BIT_

[PATCH 05/10] usb: phy: ab8500-usb: fix phy tuning value select logic

2013-05-15 Thread Fabio Baltieri
The driver supports both ab8500 and ab8505, but the actual phy tuning
values logic sets ab8500 values:

if (!is_ab8500_2p0_or_earlier(ab->ab8500))

which is supposed to set values for ab8500, but incorrectly results true
for ab8505 too.

Fix this by adding an additional is_ab8500(ab->ab8500) check.

Acked-by: Linus Walleij 
Acked-by: Maxime Coquelin 
Signed-off-by: Fabio Baltieri 
---
 drivers/usb/phy/phy-ab8500-usb.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/usb/phy/phy-ab8500-usb.c b/drivers/usb/phy/phy-ab8500-usb.c
index bbe51cc..d105cce 100644
--- a/drivers/usb/phy/phy-ab8500-usb.c
+++ b/drivers/usb/phy/phy-ab8500-usb.c
@@ -835,8 +835,8 @@ static int ab8500_usb_probe(struct platform_device *pdev)
return err;
}
 
-   /* Phy tuning values for AB8500 */
-   if (!is_ab8500_2p0_or_earlier(ab->ab8500)) {
+   /* Phy tuning values for AB8500 > v2.0 */
+   if (is_ab8500(ab->ab8500) && !is_ab8500_2p0_or_earlier(ab->ab8500)) {
/* Enable the PBT/Bank 0x12 access */
err = abx500_set_register_interruptible(ab->dev,
AB8500_DEVELOPMENT, AB8500_BANK12_ACCESS, 0x01);
-- 
1.8.2

--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 02/10] usb: musb: various cosmetic fixes on ux500 files

2013-05-15 Thread Fabio Baltieri
Various non functional coding style fixes on ux500_dma.c and
phy-ab8500-usb.c drivers.

Acked-by: Linus Walleij 
Acked-by: Maxime Coquelin 
Signed-off-by: Fabio Baltieri 
---
 drivers/usb/musb/ux500_dma.c | 6 +++---
 drivers/usb/phy/phy-ab8500-usb.c | 9 +
 2 files changed, 8 insertions(+), 7 deletions(-)

diff --git a/drivers/usb/musb/ux500_dma.c b/drivers/usb/musb/ux500_dma.c
index 3381206..63e7c8a 100644
--- a/drivers/usb/musb/ux500_dma.c
+++ b/drivers/usb/musb/ux500_dma.c
@@ -71,8 +71,7 @@ static void ux500_dma_callback(void *private_data)
spin_lock_irqsave(&musb->lock, flags);
ux500_channel->channel.actual_len = ux500_channel->cur_len;
ux500_channel->channel.status = MUSB_DMA_STATUS_FREE;
-   musb_dma_completion(musb, hw_ep->epnum,
-   ux500_channel->is_tx);
+   musb_dma_completion(musb, hw_ep->epnum, ux500_channel->is_tx);
spin_unlock_irqrestore(&musb->lock, flags);
 
 }
@@ -366,7 +365,8 @@ void dma_controller_destroy(struct dma_controller *c)
kfree(controller);
 }
 
-struct dma_controller *dma_controller_create(struct musb *musb, void __iomem 
*base)
+struct dma_controller *dma_controller_create(struct musb *musb,
+   void __iomem *base)
 {
struct ux500_dma_controller *controller;
struct platform_device *pdev = to_platform_device(musb->controller);
diff --git a/drivers/usb/phy/phy-ab8500-usb.c b/drivers/usb/phy/phy-ab8500-usb.c
index 4acef26..b043faa 100644
--- a/drivers/usb/phy/phy-ab8500-usb.c
+++ b/drivers/usb/phy/phy-ab8500-usb.c
@@ -286,7 +286,8 @@ static void ab8500_usb_phy_disable(struct ab8500_usb *ab, 
bool sel_host)
else if (pinctrl_select_state(ab->pinctrl, ab->pins_sleep))
dev_err(ab->dev, "could not set pins to sleep state\n");
 
-   /* as USB pins are shared with idddet, release them to allow
+   /*
+* as USB pins are shared with iddet, release them to allow
 * iddet to request them
 */
pinctrl_put(ab->pinctrl);
@@ -553,7 +554,7 @@ static irqreturn_t ab8500_usb_disconnect_irq(int irq, void 
*data)
 
 static irqreturn_t ab8500_usb_link_status_irq(int irq, void *data)
 {
-   struct ab8500_usb *ab = (struct ab8500_usb *) data;
+   struct ab8500_usb *ab = (struct ab8500_usb *)data;
 
abx500_usb_link_status_update(ab);
 
@@ -627,7 +628,7 @@ static int ab8500_usb_set_peripheral(struct usb_otg *otg,
 * is fixed.
 */
 
-   if ((ab->mode != USB_IDLE) && (!gadget)) {
+   if ((ab->mode != USB_IDLE) && !gadget) {
ab->mode = USB_IDLE;
schedule_work(&ab->phy_dis_work);
}
@@ -651,7 +652,7 @@ static int ab8500_usb_set_host(struct usb_otg *otg, struct 
usb_bus *host)
 * is fixed.
 */
 
-   if ((ab->mode != USB_IDLE) && (!host)) {
+   if ((ab->mode != USB_IDLE) && !host) {
ab->mode = USB_IDLE;
schedule_work(&ab->phy_dis_work);
}
-- 
1.8.2

--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 03/10] usb: phy: ab8500-usb: add transceiver clock control

2013-05-15 Thread Fabio Baltieri
From: Mian Yousaf Kaukab 

Add common clock support code for the ab8500-usb phy driver.

Acked-by: Linus Walleij 
Acked-by: Maxime Coquelin 
Signed-off-by: Mian Yousaf Kaukab 
Signed-off-by: Fabio Baltieri 
---
 drivers/usb/phy/phy-ab8500-usb.c | 14 ++
 1 file changed, 14 insertions(+)

diff --git a/drivers/usb/phy/phy-ab8500-usb.c b/drivers/usb/phy/phy-ab8500-usb.c
index b043faa..cc0d7e5 100644
--- a/drivers/usb/phy/phy-ab8500-usb.c
+++ b/drivers/usb/phy/phy-ab8500-usb.c
@@ -29,6 +29,8 @@
 #include 
 #include 
 #include 
+#include 
+#include 
 #include 
 #include 
 #include 
@@ -126,6 +128,7 @@ struct ab8500_usb {
unsigned vbus_draw;
struct work_struct phy_dis_work;
enum ab8500_usb_mode mode;
+   struct clk *sysclk;
struct regulator *v_ape;
struct regulator *v_musb;
struct regulator *v_ulpi;
@@ -252,6 +255,9 @@ static void ab8500_usb_phy_enable(struct ab8500_usb *ab, 
bool sel_host)
if (IS_ERR(ab->pinctrl))
dev_err(ab->dev, "could not get/set default pinstate\n");
 
+   if (clk_prepare_enable(ab->sysclk))
+   dev_err(ab->dev, "can't prepare/enable clock\n");
+
ab8500_usb_regulator_enable(ab);
 
abx500_mask_and_set_register_interruptible(ab->dev,
@@ -274,6 +280,8 @@ static void ab8500_usb_phy_disable(struct ab8500_usb *ab, 
bool sel_host)
/* Needed to disable the phy.*/
ab8500_usb_wd_workaround(ab);
 
+   clk_disable_unprepare(ab->sysclk);
+
ab8500_usb_regulator_disable(ab);
 
if (!IS_ERR(ab->pinctrl)) {
@@ -784,6 +792,12 @@ static int ab8500_usb_probe(struct platform_device *pdev)
if (err)
return err;
 
+   ab->sysclk = devm_clk_get(ab->dev, "sysclk");
+   if (IS_ERR(ab->sysclk)) {
+   dev_err(ab->dev, "Could not get sysclk.\n");
+   return PTR_ERR(ab->sysclk);
+   }
+
err = ab8500_usb_irq_setup(pdev, ab);
if (err < 0)
return err;
-- 
1.8.2

--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 01/10] usb: musb: enable ux500 host side dma support

2013-05-15 Thread Fabio Baltieri
From: Mian Yousaf Kaukab 

Host side dma support for ux500 is enabled by piggybacking on Inventra
dma support.

Acked-by: Linus Walleij 
Signed-off-by: Mian Yousaf Kaukab 
Signed-off-by: Fabio Baltieri 
---
 drivers/usb/musb/musb_host.c | 8 
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/usb/musb/musb_host.c b/drivers/usb/musb/musb_host.c
index 8914dec..1a6b5a9 100644
--- a/drivers/usb/musb/musb_host.c
+++ b/drivers/usb/musb/musb_host.c
@@ -625,7 +625,7 @@ static bool musb_tx_dma_program(struct dma_controller *dma,
u16 csr;
u8  mode;
 
-#ifdef CONFIG_USB_INVENTRA_DMA
+#if defined(CONFIG_USB_INVENTRA_DMA) || defined(CONFIG_USB_UX500_DMA)
if (length > channel->max_len)
length = channel->max_len;
 
@@ -1659,7 +1659,7 @@ void musb_host_rx(struct musb *musb, u8 epnum)
 
/* FIXME this is _way_ too much in-line logic for Mentor DMA */
 
-#ifndef CONFIG_USB_INVENTRA_DMA
+#if !defined(CONFIG_USB_INVENTRA_DMA) && !defined(CONFIG_USB_UX500_DMA)
if (rx_csr & MUSB_RXCSR_H_REQPKT)  {
/* REVISIT this happened for a while on some short reads...
 * the cleanup still needs investigation... looks bad...
@@ -1691,7 +1691,7 @@ void musb_host_rx(struct musb *musb, u8 epnum)
| MUSB_RXCSR_RXPKTRDY);
musb_writew(hw_ep->regs, MUSB_RXCSR, val);
 
-#ifdef CONFIG_USB_INVENTRA_DMA
+#if defined(CONFIG_USB_INVENTRA_DMA) || defined(CONFIG_USB_UX500_DMA)
if (usb_pipeisoc(pipe)) {
struct usb_iso_packet_descriptor *d;
 
@@ -1747,7 +1747,7 @@ void musb_host_rx(struct musb *musb, u8 epnum)
}
 
/* we are expecting IN packets */
-#ifdef CONFIG_USB_INVENTRA_DMA
+#if defined(CONFIG_USB_INVENTRA_DMA) || defined(CONFIG_USB_UX500_DMA)
if (dma) {
struct dma_controller   *c;
u16 rx_count;
-- 
1.8.2

--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 10/10] usb: phy: ab8500-usb: add ab9540 support

2013-05-15 Thread Fabio Baltieri
Add support for the ab9540 variant of the ab8500 family.

Acked-by: Linus Walleij 
Acked-by: Maxime Coquelin 
Cc: Avinash Kumar 
Cc: Thirupathi Chippakurthy 
Signed-off-by: Fabio Baltieri 
---
 drivers/usb/phy/phy-ab8500-usb.c | 213 +++
 1 file changed, 213 insertions(+)

diff --git a/drivers/usb/phy/phy-ab8500-usb.c b/drivers/usb/phy/phy-ab8500-usb.c
index 869ca26..7fd19bb 100644
--- a/drivers/usb/phy/phy-ab8500-usb.c
+++ b/drivers/usb/phy/phy-ab8500-usb.c
@@ -6,6 +6,7 @@
  * Copyright (C) 2010-2013 ST-Ericsson AB
  * Mian Yousaf Kaukab 
  * Avinash Kumar 
+ * Thirupathi Chippakurthy 
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
@@ -45,6 +46,7 @@
 #define AB8500_USB_LINE_STAT_REG 0x80
 #define AB8505_USB_LINE_STAT_REG 0x94
 #define AB8540_USB_LINK_STAT_REG 0x94
+#define AB9540_USB_LINK_STAT_REG 0x94
 #define AB8540_USB_OTG_CTL_REG 0x87
 #define AB8500_USB_PHY_CTRL_REG 0x8A
 #define AB8540_VBUS_CTRL_REG 0x82
@@ -158,6 +160,37 @@ enum ab8540_usb_link_status {
USB_LINK_MOTOROLA_FACTORY_CBL_PHY_EN_8540
 };
 
+enum ab9540_usb_link_status {
+   USB_LINK_NOT_CONFIGURED_9540 = 0,
+   USB_LINK_STD_HOST_NC_9540,
+   USB_LINK_STD_HOST_C_NS_9540,
+   USB_LINK_STD_HOST_C_S_9540,
+   USB_LINK_CDP_9540,
+   USB_LINK_RESERVED0_9540,
+   USB_LINK_RESERVED1_9540,
+   USB_LINK_DEDICATED_CHG_9540,
+   USB_LINK_ACA_RID_A_9540,
+   USB_LINK_ACA_RID_B_9540,
+   USB_LINK_ACA_RID_C_NM_9540,
+   USB_LINK_RESERVED2_9540,
+   USB_LINK_RESERVED3_9540,
+   USB_LINK_HM_IDGND_9540,
+   USB_LINK_CHARGERPORT_NOT_OK_9540,
+   USB_LINK_CHARGER_DM_HIGH_9540,
+   USB_LINK_PHYEN_NO_VBUS_NO_IDGND_9540,
+   USB_LINK_STD_UPSTREAM_NO_IDGNG_VBUS_9540,
+   USB_LINK_STD_UPSTREAM_9540,
+   USB_LINK_CHARGER_SE1_9540,
+   USB_LINK_CARKIT_CHGR_1_9540,
+   USB_LINK_CARKIT_CHGR_2_9540,
+   USB_LINK_ACA_DOCK_CHGR_9540,
+   USB_LINK_SAMSUNG_BOOT_CBL_PHY_EN_9540,
+   USB_LINK_SAMSUNG_BOOT_CBL_PHY_DISB_9540,
+   USB_LINK_SAMSUNG_UART_CBL_PHY_EN_9540,
+   USB_LINK_SAMSUNG_UART_CBL_PHY_DISB_9540,
+   USB_LINK_MOTOROLA_FACTORY_CBL_PHY_EN_9540
+};
+
 enum ab8500_usb_mode {
USB_IDLE = 0,
USB_PERIPHERAL,
@@ -378,6 +411,132 @@ static void ab8500_usb_phy_disable(struct ab8500_usb *ab, 
bool sel_host)
 #define ab8500_usb_peri_phy_en(ab) ab8500_usb_phy_enable(ab, false)
 #define ab8500_usb_peri_phy_dis(ab)ab8500_usb_phy_disable(ab, false)
 
+static int ab9540_usb_link_status_update(struct ab8500_usb *ab,
+   enum ab9540_usb_link_status lsts)
+{
+   enum ux500_musb_vbus_id_status event = 0;
+
+   dev_dbg(ab->dev, "ab9540_usb_link_status_update %d\n", lsts);
+
+   if (ab->previous_link_status_state == USB_LINK_HM_IDGND_9540 &&
+   (lsts == USB_LINK_STD_HOST_C_NS_9540 ||
+lsts == USB_LINK_STD_HOST_NC_9540))
+   return 0;
+
+   if (ab->previous_link_status_state == USB_LINK_ACA_RID_A_9540 &&
+   (lsts == USB_LINK_STD_HOST_NC_9540))
+   return 0;
+
+   ab->previous_link_status_state = lsts;
+
+   switch (lsts) {
+   case USB_LINK_ACA_RID_B_9540:
+   event = UX500_MUSB_RIDB;
+   case USB_LINK_NOT_CONFIGURED_9540:
+   case USB_LINK_RESERVED0_9540:
+   case USB_LINK_RESERVED1_9540:
+   case USB_LINK_RESERVED2_9540:
+   case USB_LINK_RESERVED3_9540:
+   if (ab->mode == USB_PERIPHERAL)
+   atomic_notifier_call_chain(&ab->phy.notifier,
+   UX500_MUSB_CLEAN, &ab->vbus_draw);
+   ab->mode = USB_IDLE;
+   ab->phy.otg->default_a = false;
+   ab->vbus_draw = 0;
+   if (event != UX500_MUSB_RIDB)
+   event = UX500_MUSB_NONE;
+   /* Fallback to default B_IDLE as nothing is connected. */
+   ab->phy.state = OTG_STATE_B_IDLE;
+   break;
+
+   case USB_LINK_ACA_RID_C_NM_9540:
+   event = UX500_MUSB_RIDC;
+   case USB_LINK_STD_HOST_NC_9540:
+   case USB_LINK_STD_HOST_C_NS_9540:
+   case USB_LINK_STD_HOST_C_S_9540:
+   case USB_LINK_CDP_9540:
+   if (ab->mode == USB_HOST) {
+   ab->mode = USB_PERIPHERAL;
+   ab8500_usb_host_phy_dis(ab);
+   ab8500_usb_peri_phy_en(ab);
+   atomic_notifier_call_chain(&ab->phy.notifier,
+   UX500_MUSB_PREPARE, &ab->vbus_draw);
+   }
+   if (ab->mode == USB_IDLE) {
+   ab->mode = USB_PERIPHERAL;
+   ab8500_usb_peri_phy_en(ab);
+   atomic_notifier_call_chain(&ab->phy.notifier,
+   UX50

[PATCH] qmi_wwan: Added support for Cinterion's PLxx WWAN Interface

2013-05-15 Thread Schmiedl Christian
/drivers/net/usb/qmi_wwan.c: Added support for Cinterion's PLxx WWAN Interface
by adding QMI_FIXED_INTF with Cinterion's Vendor ID as well as Product ID and
WWAN Interface Number.

Signed-off-by: Hans-Christoph Schemmel  
gemalto.com>
Signed-off-by: Christian Schmiedl  gemalto.com>
---
patch is against linux-3.9
--- linux-3.9/drivers/net/usb/qmi_wwan.c.orig   2013-05-06 08:10:11.170034451 
+0200
+++ linux-3.9/drivers/net/usb/qmi_wwan.c2013-05-06 08:58:00.800264179 
+0200
 -569,6 +569,7  static const struct usb_device_id produc
{QMI_FIXED_INTF(0x1bbb, 0x011e, 4)},/* Telekom Speedstick LTE II 
(Alcatel One Touch L100V LTE) */
{QMI_FIXED_INTF(0x2357, 0x0201, 4)},/* TP-LINK HSUPA Modem MA180 */
{QMI_FIXED_INTF(0x1bc7, 0x1200, 5)},/* Telit LE920 */
+   {QMI_FIXED_INTF(0x1e2d, 0x12d1, 4)},/* Cinterion PLxx */

/* 4. Gobi 1000 devices */
{QMI_GOBI1K_DEVICE(0x05c6, 0x9212)},/* Acer Gobi Modem Device */
--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 0/9] Equivalent of g_nokia.ko with configfs

2013-05-15 Thread Andrzej Pietrasiewicz
Here I present the conversion of everything that is required to provide
the equivalent of g_nokia.ko with configfs.

A branch will be available here (from 15th May 2013, afternoon UTC):
git://git.infradead.org/users/kmpark/linux-samsung usb-gadget-configfs

This series requires the following series to be applied:

http://www.spinics.net/lists/linux-usb/msg85863.html
http://www.spinics.net/lists/linux-usb/msg85873.html
http://www.spinics.net/lists/linux-usb/msg85307.html

BACKWARD COMPATIBILITY
==

Please note that the old g_nokia.ko is still available and works.


USING THE NEW "GADGET"
==

Please refer to this post:

http://www.spinics.net/lists/linux-usb/msg76388.html

for general information from Sebastian on how to use configfs-based
gadgets (*).

Here is the description specific to using g_nokia.ko equivalent.

The old g_nokia.ko provides 4 functions:

- Phonet
- Obex (2 instances)
- ACM
- ECM

in 2 configurations, which contain this same set of functions,
but differ in MaxPower.

The procedure of setting up such a gadget with configfs is given
below with an example:

$ modprobe libcomposite
 
$ mount none cfg -t configfs
 
$ mkdir cfg/usb_gadget/g1
$ cd cfg/usb_gadget/g1
 
$ echo 0x01c8 > idProduct
$ echo 0x0421 > idVendor
$ mkdir strings/0x409
$ echo Nokia > strings/0x409/manufacturer
$ echo "N900 (PC-Suite Mode)" > strings/0x409/product
 
$ mkdir configs/c.1
$ echo 500 > configs/c.1/MaxPower
$ mkdir configs/c.1/strings/0x409
$ echo "Conf 1" > configs/c.1/strings/0x409/configuration
 
$ mkdir configs/c.2
$ echo 100 > configs/c.2/MaxPower
$ mkdir configs/c.2/strings/0x409
$ echo "Conf 2" > configs/c.2/strings/0x409/configuration
 
$ mkdir functions/phonet.pn0
$ mkdir functions/obex.obex1
$ mkdir functions/obex.obex2
$ mkdir functions/acm.tty0
$ mkdir functions/ecm.usb0
 
$ ln -s functions/phonet.pn0 configs/c.1
$ ln -s functions/obex.obex1 configs/c.1
$ ln -s functions/obex.obex2 configs/c.1
$ ln -s functions/acm.tty0 configs/c.1
$ ln -s functions/ecm.usb0 configs/c.1
 
$ ln -s functions/phonet.pn0 configs/c.2
$ ln -s functions/obex.obex1 configs/c.2
$ ln -s functions/obex.obex2 configs/c.2
$ ln -s functions/acm.tty0 configs/c.2
$ ln -s functions/ecm.usb0 configs/c.2
 
$ echo s3c-hsotg > UDC

The obex and acm functions provide only one, readonly, attribute port_num,
which contains their port number.
The phonet function provides only one, readonly, attribute ifname, which
contains the network interface name associated with the function.
The ecm function provides qmult, dev_addr, host_addr read-write attributes,
and ifname readonly attribute.
and after creating the functions/ecm. it contains default
values: qmult is 5, dev_addr and host_addr are randomly selected.
Except for ifname they can be written to until the function is linked to a
configuration. The ifname is read-only and contains the name of the interface
which was assigned by the net core, e. g. usb0.

After unbinding the gadget with echo "" > UDC
the symbolic links in the configuration directory can be removed,
the strings/* subdirectories in the configuration directory can
be removed, the strings/* subdirectories at the gadget level can
be removed and the configs/* subdirectories can be removed.
The functions/* subdirectories can be removed.
After that the gadget directory can be removed.
After that the respective modules can be unloaded.


TESTING THE FUNCTIONS


phonet)

It is not possible to test the SOCK_STREAM protocol without a specific piece
of hardware, so only SOCK_DGRAM has been tested. For the latter to work,
I had to apply the patch mentioned here:

http://www.spinics.net/lists/linux-usb/msg85689.html

For this to work, these tools are required

git://git.gitorious.org/meego-cellular/phonet-utils.git

On the host:

$ ./phonet -a 0x10 -i usbpn0
$ ./pnroute add 0x6c usbpn0
$./pnroute add 0x10 usbpn0
$ ifconfig usbpn0 up

On the device:

$ ./phonet -a 0x6c -i upnlink0
$ ./pnroute add 0x10 upnlink0
$ ifconfig upnlink0 up

Then a test program can be used:

http://www.spinics.net/lists/linux-usb/msg85690.html

On the device:

$ ./pnxmit -a 0x6c -r

On the host:

$ ./pnxmit -a 0x10 -s 0x6c

As a result some data should be sent from host to device.
Then the other way round:

On the host:

$ ./pnxmit -a 0x10 -r

On the device:

$ ./pnxmit -a 0x6c -s 0x10

obex)

On device: seriald -f /dev/ttyGS -s 1024
On host: serialc -v  -p  -i -a1 -s1024 \
 -t -r

where seriald and serialc are Felipe's utilities found here:

https://git.gitorious.org/usb/usb-tools.git master

acm)

On host: cat > /dev/ttyACM
On target: cat /dev/ttyGS

then the other way round

On target: cat > /dev/ttyGS
On host: cat /dev/ttyACM

ecm)

On the device: ping 
On the host: ping 

Andrzej Pietrasiewicz (9):
  usb/gadget: f_obex: use usb_gstrings_attach
  usb/gadget: nokia: convert to new interface of f_obex
  usb/gadget: f_obex: remove compatibility layer
  usb/gadget: phonet: move global dev variable 

[PATCH 1/9] usb/gadget: f_obex: use usb_gstrings_attach

2013-05-15 Thread Andrzej Pietrasiewicz
Signed-off-by: Andrzej Pietrasiewicz 
Signed-off-by: Kyungmin Park 
---
 drivers/usb/gadget/f_obex.c |   19 ---
 1 files changed, 8 insertions(+), 11 deletions(-)

diff --git a/drivers/usb/gadget/f_obex.c b/drivers/usb/gadget/f_obex.c
index 29a348a..be2d762 100644
--- a/drivers/usb/gadget/f_obex.c
+++ b/drivers/usb/gadget/f_obex.c
@@ -309,23 +309,20 @@ static int obex_bind(struct usb_configuration *c, struct 
usb_function *f)
 {
struct usb_composite_dev *cdev = c->cdev;
struct f_obex   *obex = func_to_obex(f);
+   struct usb_string   *us;
int status;
struct usb_ep   *ep;
 
if (!can_support_obex(c))
return -EINVAL;
 
-   if (obex_string_defs[OBEX_CTRL_IDX].id == 0) {
-   status = usb_string_ids_tab(c->cdev, obex_string_defs);
-   if (status < 0)
-   return status;
-   obex_control_intf.iInterface =
-   obex_string_defs[OBEX_CTRL_IDX].id;
-
-   status = obex_string_defs[OBEX_DATA_IDX].id;
-   obex_data_nop_intf.iInterface = status;
-   obex_data_intf.iInterface = status;
-   }
+   us = usb_gstrings_attach(cdev, obex_strings,
+ARRAY_SIZE(obex_string_defs));
+   if (IS_ERR(us))
+   return PTR_ERR(us);
+   obex_control_intf.iInterface = us[OBEX_CTRL_IDX].id;
+   obex_data_nop_intf.iInterface = us[OBEX_DATA_IDX].id;
+   obex_data_intf.iInterface = us[OBEX_DATA_IDX].id;
 
/* allocate instance-specific interface IDs, and patch descriptors */
 
-- 
1.7.0.4

--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 2/9] usb/gadget: nokia: convert to new interface of f_obex

2013-05-15 Thread Andrzej Pietrasiewicz
Signed-off-by: Andrzej Pietrasiewicz 
Signed-off-by: Kyungmin Park 
---
 drivers/usb/gadget/Kconfig |1 +
 drivers/usb/gadget/nokia.c |  122 ++--
 2 files changed, 85 insertions(+), 38 deletions(-)

diff --git a/drivers/usb/gadget/Kconfig b/drivers/usb/gadget/Kconfig
index 7bd831f..0cf2ae7 100644
--- a/drivers/usb/gadget/Kconfig
+++ b/drivers/usb/gadget/Kconfig
@@ -929,6 +929,7 @@ config USB_G_NOKIA
select USB_U_SERIAL
select USB_U_ETHER
select USB_F_ACM
+   select USB_F_OBEX
help
  The Nokia composite gadget provides support for acm, obex
  and phonet in only one composite gadget driver.
diff --git a/drivers/usb/gadget/nokia.c b/drivers/usb/gadget/nokia.c
index 8e42c88..4a5392d 100644
--- a/drivers/usb/gadget/nokia.c
+++ b/drivers/usb/gadget/nokia.c
@@ -16,6 +16,7 @@
  */
 
 #include 
+#include 
 #include 
 
 #include "u_serial.h"
@@ -39,8 +40,6 @@
  */
 #define USBF_ECM_INCLUDED
 #include "f_ecm.c"
-#define USBF_OBEX_INCLUDED
-#include "f_obex.c"
 #include "f_phonet.c"
 #include "u_ether.h"
 
@@ -102,16 +101,12 @@ MODULE_LICENSE("GPL");
 static struct usb_function *f_acm_cfg1;
 static struct usb_function *f_acm_cfg2;
 static u8 host_mac[ETH_ALEN];
+static struct usb_function *f_obex1_cfg1;
+static struct usb_function *f_obex2_cfg1;
+static struct usb_function *f_obex1_cfg2;
+static struct usb_function *f_obex2_cfg2;
 static struct eth_dev *the_dev;
 
-enum {
-   TTY_PORT_OBEX0,
-   TTY_PORT_OBEX1,
-   TTY_PORTS_MAX,
-};
-
-static unsigned char tty_lines[TTY_PORTS_MAX];
-
 static struct usb_configuration nokia_config_500ma_driver = {
.label  = "Bus Powered",
.bConfigurationValue = 1,
@@ -129,27 +124,51 @@ static struct usb_configuration nokia_config_100ma_driver 
= {
 };
 
 static struct usb_function_instance *fi_acm;
+static struct usb_function_instance *fi_obex1;
+static struct usb_function_instance *fi_obex2;
 
 static int __init nokia_bind_config(struct usb_configuration *c)
 {
struct usb_function *f_acm;
+   struct usb_function *f_obex1 = NULL;
+   struct usb_function *f_obex2 = NULL;
int status = 0;
+   int obex1_stat = 0;
+   int obex2_stat = 0;
 
status = phonet_bind_config(c);
if (status)
-   printk(KERN_DEBUG "could not bind phonet config\n");
+   pr_debug("could not bind phonet config\n");
 
-   status = obex_bind_config(c, tty_lines[TTY_PORT_OBEX0]);
-   if (status)
-   printk(KERN_DEBUG "could not bind obex config %d\n", 0);
+   if (!IS_ERR(fi_obex1)) {
+   f_obex1 = usb_get_function(fi_obex1);
+   if (IS_ERR(f_obex1))
+   pr_debug("could not get obex function 0\n");
+   }
 
-   status = obex_bind_config(c, tty_lines[TTY_PORT_OBEX1]);
-   if (status)
-   printk(KERN_DEBUG "could not bind obex config %d\n", 0);
+   if (!IS_ERR(fi_obex2)) {
+   f_obex2 = usb_get_function(fi_obex2);
+   if (IS_ERR(f_obex2))
+   pr_debug("could not get obex function 1\n");
+   }
 
f_acm = usb_get_function(fi_acm);
-   if (IS_ERR(f_acm))
-   return PTR_ERR(f_acm);
+   if (IS_ERR(f_acm)) {
+   status = PTR_ERR(fi_acm);
+   goto err_get_acm;
+   }
+
+   if (!IS_ERR_OR_NULL(f_obex1)) {
+   obex1_stat = usb_add_function(c, f_obex1);
+   if (obex1_stat)
+   pr_debug("could not add obex function 0\n");
+   }
+
+   if (!IS_ERR_OR_NULL(f_obex2)) {
+   obex2_stat = usb_add_function(c, f_obex2);
+   if (obex2_stat)
+   pr_debug("could not add obex function 1\n");
+   }
 
status = usb_add_function(c, f_acm);
if (status)
@@ -160,16 +179,30 @@ static int __init nokia_bind_config(struct 
usb_configuration *c)
pr_debug("could not bind ecm config %d\n", status);
goto err_ecm;
}
-   if (c == &nokia_config_500ma_driver)
+   if (c == &nokia_config_500ma_driver) {
f_acm_cfg1 = f_acm;
-   else
+   f_obex1_cfg1 = f_obex1;
+   f_obex2_cfg1 = f_obex2;
+   } else {
f_acm_cfg2 = f_acm;
+   f_obex1_cfg2 = f_obex1;
+   f_obex2_cfg2 = f_obex2;
+   }
 
return status;
 err_ecm:
usb_remove_function(c, f_acm);
 err_conf:
+   if (!obex2_stat)
+   usb_remove_function(c, f_obex2);
+   if (!obex1_stat)
+   usb_remove_function(c, f_obex1);
usb_put_function(f_acm);
+err_get_acm:
+   if (!IS_ERR_OR_NULL(f_obex2))
+   usb_put_function(f_obex2);
+   if (!IS_ERR_OR_NULL(f_obex1))
+   usb_put_function(f_obex1);
return status;
 }
 
@@ -177,18 +210,11 @@ static int __init nokia_bind(struct usb_composite_dev 
*cdev)

[PATCH 4/9] usb/gadget: phonet: move global dev variable to its user

2013-05-15 Thread Andrzej Pietrasiewicz
Signed-off-by: Andrzej Pietrasiewicz 
Signed-off-by: Kyungmin Park 
---
 drivers/usb/gadget/f_phonet.c |   20 +++-
 drivers/usb/gadget/nokia.c|   14 +-
 drivers/usb/gadget/u_phonet.h |6 +++---
 3 files changed, 23 insertions(+), 17 deletions(-)

diff --git a/drivers/usb/gadget/f_phonet.c b/drivers/usb/gadget/f_phonet.c
index e86763f..e79ee34 100644
--- a/drivers/usb/gadget/f_phonet.c
+++ b/drivers/usb/gadget/f_phonet.c
@@ -574,9 +574,8 @@ pn_unbind(struct usb_configuration *c, struct usb_function 
*f)
 
 /*-*/
 
-static struct net_device *dev;
-
-int __init phonet_bind_config(struct usb_configuration *c)
+int __init phonet_bind_config(struct usb_configuration *c,
+ struct net_device *dev)
 {
struct f_phonet *fp;
int err, size;
@@ -601,16 +600,16 @@ int __init phonet_bind_config(struct usb_configuration *c)
return err;
 }
 
-int __init gphonet_setup(struct usb_gadget *gadget)
+struct net_device __init *gphonet_setup(struct usb_gadget *gadget)
 {
+   struct net_device *dev;
struct phonet_port *port;
int err;
 
/* Create net device */
-   BUG_ON(dev);
dev = alloc_netdev(sizeof(*port), "upnlink%d", pn_net_setup);
if (!dev)
-   return -ENOMEM;
+   return ERR_PTR(-ENOMEM);
 
port = netdev_priv(dev);
spin_lock_init(&port->lock);
@@ -618,12 +617,15 @@ int __init gphonet_setup(struct usb_gadget *gadget)
SET_NETDEV_DEV(dev, &gadget->dev);
 
err = register_netdev(dev);
-   if (err)
+   if (err) {
free_netdev(dev);
-   return err;
+
+   return ERR_PTR(err);
+   }
+   return dev;
 }
 
-void gphonet_cleanup(void)
+void gphonet_cleanup(struct net_device *dev)
 {
unregister_netdev(dev);
 }
diff --git a/drivers/usb/gadget/nokia.c b/drivers/usb/gadget/nokia.c
index 4a5392d..2864f6e 100644
--- a/drivers/usb/gadget/nokia.c
+++ b/drivers/usb/gadget/nokia.c
@@ -106,6 +106,8 @@ static struct usb_function *f_obex2_cfg1;
 static struct usb_function *f_obex1_cfg2;
 static struct usb_function *f_obex2_cfg2;
 static struct eth_dev *the_dev;
+static struct net_device *phonet_dev;
+
 
 static struct usb_configuration nokia_config_500ma_driver = {
.label  = "Bus Powered",
@@ -136,7 +138,7 @@ static int __init nokia_bind_config(struct 
usb_configuration *c)
int obex1_stat = 0;
int obex2_stat = 0;
 
-   status = phonet_bind_config(c);
+   status = phonet_bind_config(c, phonet_dev);
if (status)
pr_debug("could not bind phonet config\n");
 
@@ -211,9 +213,11 @@ static int __init nokia_bind(struct usb_composite_dev 
*cdev)
struct usb_gadget   *gadget = cdev->gadget;
int status;
 
-   status = gphonet_setup(cdev->gadget);
-   if (status < 0)
+   phonet_dev = gphonet_setup(cdev->gadget);
+   if (IS_ERR(phonet_dev)) {
+   status = PTR_ERR(phonet_dev);
goto err_phonet;
+   }
 
the_dev = gether_setup(cdev->gadget, dev_addr, host_addr, host_mac,
   qmult);
@@ -278,7 +282,7 @@ err_obex2_inst:
 err_usb:
gether_cleanup(the_dev);
 err_ether:
-   gphonet_cleanup();
+   gphonet_cleanup(phonet_dev);
 err_phonet:
return status;
 }
@@ -300,7 +304,7 @@ static int __exit nokia_unbind(struct usb_composite_dev 
*cdev)
if (!IS_ERR(fi_obex2))
usb_put_function_instance(fi_obex2);
usb_put_function_instance(fi_acm);
-   gphonet_cleanup();
+   gphonet_cleanup(phonet_dev);
 
gether_cleanup(the_dev);
 
diff --git a/drivers/usb/gadget/u_phonet.h b/drivers/usb/gadget/u_phonet.h
index 09a7525..459ee32 100644
--- a/drivers/usb/gadget/u_phonet.h
+++ b/drivers/usb/gadget/u_phonet.h
@@ -14,8 +14,8 @@
 #include 
 #include 
 
-int gphonet_setup(struct usb_gadget *gadget);
-int phonet_bind_config(struct usb_configuration *c);
-void gphonet_cleanup(void);
+struct net_device *gphonet_setup(struct usb_gadget *gadget);
+int phonet_bind_config(struct usb_configuration *c, struct net_device *dev);
+void gphonet_cleanup(struct net_device *dev);
 
 #endif /* __U_PHONET_H */
-- 
1.7.0.4

--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 5/9] usb/gadget: f_phonet: convert to new function interface with backward compatibility

2013-05-15 Thread Andrzej Pietrasiewicz
Converting f_phonet to the new function interface requires converting
the f_phonet's function code and its users.
This patch converts the f_phonet.c to the new function interface.
The file is now compiled into a separate usb_f_phonet.ko module.
The old function interface is provided by means of preprocessor
conditional directives. After all users are converted, the old interface
can be removed.

Signed-off-by: Andrzej Pietrasiewicz 
Signed-off-by: Kyungmin Park 
---
 drivers/usb/gadget/Kconfig|3 +
 drivers/usb/gadget/Makefile   |2 +
 drivers/usb/gadget/f_phonet.c |  148 +++--
 drivers/usb/gadget/nokia.c|1 +
 drivers/usb/gadget/u_phonet.h |9 +++
 5 files changed, 158 insertions(+), 5 deletions(-)

diff --git a/drivers/usb/gadget/Kconfig b/drivers/usb/gadget/Kconfig
index 0cf2ae7..de7eb2a 100644
--- a/drivers/usb/gadget/Kconfig
+++ b/drivers/usb/gadget/Kconfig
@@ -524,6 +524,9 @@ config USB_F_NCM
 config USB_F_ECM
tristate
 
+config USB_F_PHONET
+   tristate
+
 choice
tristate "USB Gadget Drivers"
default USB_ETH
diff --git a/drivers/usb/gadget/Makefile b/drivers/usb/gadget/Makefile
index 66152f5..db8ce05 100644
--- a/drivers/usb/gadget/Makefile
+++ b/drivers/usb/gadget/Makefile
@@ -52,6 +52,8 @@ usb_f_ncm-y   := f_ncm.o
 obj-$(CONFIG_USB_F_NCM)+= usb_f_ncm.o
 usb_f_ecm-y:= f_ecm.o
 obj-$(CONFIG_USB_F_ECM)+= usb_f_ecm.o
+usb_f_phonet-y := f_phonet.o
+obj-$(CONFIG_USB_F_PHONET) += usb_f_phonet.o
 
 #
 # USB gadget drivers
diff --git a/drivers/usb/gadget/f_phonet.c b/drivers/usb/gadget/f_phonet.c
index e79ee34..e2adab7 100644
--- a/drivers/usb/gadget/f_phonet.c
+++ b/drivers/usb/gadget/f_phonet.c
@@ -13,6 +13,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 
 #include 
@@ -473,8 +474,7 @@ static void pn_disconnect(struct usb_function *f)
 
 /*-*/
 
-static __init
-int pn_bind(struct usb_configuration *c, struct usb_function *f)
+static int pn_bind(struct usb_configuration *c, struct usb_function *f)
 {
struct usb_composite_dev *cdev = c->cdev;
struct usb_gadget *gadget = cdev->gadget;
@@ -482,6 +482,27 @@ int pn_bind(struct usb_configuration *c, struct 
usb_function *f)
struct usb_ep *ep;
int status, i;
 
+#ifndef USBF_PHONET_INCLUDED
+   struct f_phonet_opts *phonet_opts;
+
+   phonet_opts = container_of(f->fi, struct f_phonet_opts, func_inst);
+
+   /*
+* in drivers/usb/gadget/configfs.c:configfs_composite_bind()
+* configurations are bound in sequence with list_for_each_entry,
+* in each configuration its functions are bound in sequence
+* with list_for_each_entry, so we assume no race condition
+* with regard to phonet_opts->bound access
+*/
+   if (!phonet_opts->bound) {
+   gphonet_set_gadget(phonet_opts->net, gadget);
+   status = gphonet_register_netdev(phonet_opts->net);
+   if (status)
+   return status;
+   phonet_opts->bound = true;
+   }
+#endif
+
/* Reserve interface IDs */
status = usb_interface_id(c, f);
if (status < 0)
@@ -555,8 +576,10 @@ err:
return status;
 }
 
+#ifdef USBF_PHONET_INCLUDED
+
 static void
-pn_unbind(struct usb_configuration *c, struct usb_function *f)
+pn_old_unbind(struct usb_configuration *c, struct usb_function *f)
 {
struct f_phonet *fp = func_to_pn(f);
int i;
@@ -588,7 +611,7 @@ int __init phonet_bind_config(struct usb_configuration *c,
fp->dev = dev;
fp->function.name = "phonet";
fp->function.bind = pn_bind;
-   fp->function.unbind = pn_unbind;
+   fp->function.unbind = pn_old_unbind;
fp->function.set_alt = pn_set_alt;
fp->function.get_alt = pn_get_alt;
fp->function.disable = pn_disconnect;
@@ -600,7 +623,122 @@ int __init phonet_bind_config(struct usb_configuration *c,
return err;
 }
 
-struct net_device __init *gphonet_setup(struct usb_gadget *gadget)
+#else
+
+static void phonet_free_inst(struct usb_function_instance *f)
+{
+   struct f_phonet_opts *opts;
+
+   opts = container_of(f, struct f_phonet_opts, func_inst);
+   gphonet_cleanup(opts->net);
+   kfree(opts);
+}
+
+static struct usb_function_instance *phonet_alloc_inst(void)
+{
+   struct f_phonet_opts *opts;
+
+   opts = kzalloc(sizeof(*opts), GFP_KERNEL);
+   if (!opts)
+   return ERR_PTR(-ENOMEM);
+
+   opts->func_inst.free_func_inst = phonet_free_inst;
+   opts->net = gphonet_setup_default();
+   if (IS_ERR(opts->net))
+   return ERR_PTR(PTR_ERR(opts->net));
+
+   return &opts->func_inst;
+}
+
+static void phonet_free(struct usb_function *f)
+{
+   struct f_phonet *phonet;
+
+   phonet = func_to_pn(f);

[PATCH 6/9] usb/gadget: nokia: convert to new interface of f_phonet

2013-05-15 Thread Andrzej Pietrasiewicz
Signed-off-by: Andrzej Pietrasiewicz 
Signed-off-by: Kyungmin Park 
---
 drivers/usb/gadget/Kconfig |1 +
 drivers/usb/gadget/nokia.c |   56 ++-
 2 files changed, 40 insertions(+), 17 deletions(-)

diff --git a/drivers/usb/gadget/Kconfig b/drivers/usb/gadget/Kconfig
index de7eb2a..4a8268c 100644
--- a/drivers/usb/gadget/Kconfig
+++ b/drivers/usb/gadget/Kconfig
@@ -933,6 +933,7 @@ config USB_G_NOKIA
select USB_U_ETHER
select USB_F_ACM
select USB_F_OBEX
+   select USB_F_PHONET
help
  The Nokia composite gadget provides support for acm, obex
  and phonet in only one composite gadget driver.
diff --git a/drivers/usb/gadget/nokia.c b/drivers/usb/gadget/nokia.c
index 4e1e4d6..aad2519 100644
--- a/drivers/usb/gadget/nokia.c
+++ b/drivers/usb/gadget/nokia.c
@@ -40,8 +40,6 @@
  */
 #define USBF_ECM_INCLUDED
 #include "f_ecm.c"
-#define USBF_PHONET_INCLUDED
-#include "f_phonet.c"
 #include "u_ether.h"
 
 /*-*/
@@ -106,8 +104,9 @@ static struct usb_function *f_obex1_cfg1;
 static struct usb_function *f_obex2_cfg1;
 static struct usb_function *f_obex1_cfg2;
 static struct usb_function *f_obex2_cfg2;
+static struct usb_function *f_phonet_cfg1;
+static struct usb_function *f_phonet_cfg2;
 static struct eth_dev *the_dev;
-static struct net_device *phonet_dev;
 
 
 static struct usb_configuration nokia_config_500ma_driver = {
@@ -129,19 +128,24 @@ static struct usb_configuration nokia_config_100ma_driver 
= {
 static struct usb_function_instance *fi_acm;
 static struct usb_function_instance *fi_obex1;
 static struct usb_function_instance *fi_obex2;
+static struct usb_function_instance *fi_phonet;
 
 static int __init nokia_bind_config(struct usb_configuration *c)
 {
struct usb_function *f_acm;
+   struct usb_function *f_phonet = NULL;
struct usb_function *f_obex1 = NULL;
struct usb_function *f_obex2 = NULL;
int status = 0;
int obex1_stat = 0;
int obex2_stat = 0;
+   int phonet_stat = 0;
 
-   status = phonet_bind_config(c, phonet_dev);
-   if (status)
-   pr_debug("could not bind phonet config\n");
+   if (!IS_ERR(fi_phonet)) {
+   f_phonet = usb_get_function(fi_phonet);
+   if (IS_ERR(f_phonet))
+   pr_debug("could not get phonet function\n");
+   }
 
if (!IS_ERR(fi_obex1)) {
f_obex1 = usb_get_function(fi_obex1);
@@ -161,6 +165,12 @@ static int __init nokia_bind_config(struct 
usb_configuration *c)
goto err_get_acm;
}
 
+   if (!IS_ERR_OR_NULL(f_phonet)) {
+   phonet_stat = usb_add_function(c, f_phonet);
+   if (phonet_stat)
+   pr_debug("could not add phonet function\n");
+   }
+
if (!IS_ERR_OR_NULL(f_obex1)) {
obex1_stat = usb_add_function(c, f_obex1);
if (obex1_stat)
@@ -184,10 +194,12 @@ static int __init nokia_bind_config(struct 
usb_configuration *c)
}
if (c == &nokia_config_500ma_driver) {
f_acm_cfg1 = f_acm;
+   f_phonet_cfg1 = f_phonet;
f_obex1_cfg1 = f_obex1;
f_obex2_cfg1 = f_obex2;
} else {
f_acm_cfg2 = f_acm;
+   f_phonet_cfg2 = f_phonet;
f_obex1_cfg2 = f_obex1;
f_obex2_cfg2 = f_obex2;
}
@@ -200,12 +212,16 @@ err_conf:
usb_remove_function(c, f_obex2);
if (!obex1_stat)
usb_remove_function(c, f_obex1);
+   if (!phonet_stat)
+   usb_remove_function(c, f_phonet);
usb_put_function(f_acm);
 err_get_acm:
if (!IS_ERR_OR_NULL(f_obex2))
usb_put_function(f_obex2);
if (!IS_ERR_OR_NULL(f_obex1))
usb_put_function(f_obex1);
+   if (!IS_ERR_OR_NULL(f_phonet))
+   usb_put_function(f_phonet);
return status;
 }
 
@@ -214,12 +230,6 @@ static int __init nokia_bind(struct usb_composite_dev 
*cdev)
struct usb_gadget   *gadget = cdev->gadget;
int status;
 
-   phonet_dev = gphonet_setup(cdev->gadget);
-   if (IS_ERR(phonet_dev)) {
-   status = PTR_ERR(phonet_dev);
-   goto err_phonet;
-   }
-
the_dev = gether_setup(cdev->gadget, dev_addr, host_addr, host_mac,
   qmult);
if (IS_ERR(the_dev)) {
@@ -239,6 +249,10 @@ static int __init nokia_bind(struct usb_composite_dev 
*cdev)
if (!gadget_supports_altsettings(gadget))
goto err_usb;
 
+   fi_phonet = usb_get_function_instance("phonet");
+   if (IS_ERR(fi_phonet))
+   pr_debug("could not find phonet function\n");
+
fi_obex1 = usb_get_function_instance("obex");
if (IS_ERR(fi_obex1))
pr_d

[PATCH 8/9] usb/gadget: nokia: convert to new interface of f_ecm

2013-05-15 Thread Andrzej Pietrasiewicz
Signed-off-by: Andrzej Pietrasiewicz 
Signed-off-by: Kyungmin Park 
---
 drivers/usb/gadget/Kconfig |1 +
 drivers/usb/gadget/nokia.c |   66 +++
 2 files changed, 36 insertions(+), 31 deletions(-)

diff --git a/drivers/usb/gadget/Kconfig b/drivers/usb/gadget/Kconfig
index 4a8268c..9b6286d 100644
--- a/drivers/usb/gadget/Kconfig
+++ b/drivers/usb/gadget/Kconfig
@@ -934,6 +934,7 @@ config USB_G_NOKIA
select USB_F_ACM
select USB_F_OBEX
select USB_F_PHONET
+   select USB_F_ECM
help
  The Nokia composite gadget provides support for acm, obex
  and phonet in only one composite gadget driver.
diff --git a/drivers/usb/gadget/nokia.c b/drivers/usb/gadget/nokia.c
index aad2519..1ec45c8 100644
--- a/drivers/usb/gadget/nokia.c
+++ b/drivers/usb/gadget/nokia.c
@@ -22,6 +22,7 @@
 #include "u_serial.h"
 #include "u_ether.h"
 #include "u_phonet.h"
+#include "u_ecm.h"
 #include "gadget_chips.h"
 
 /* Defines */
@@ -29,20 +30,6 @@
 #define NOKIA_VERSION_NUM  0x0211
 #define NOKIA_LONG_NAME"N900 (PC-Suite Mode)"
 
-/*-*/
-
-/*
- * Kbuild is not very cooperative with respect to linking separately
- * compiled library objects into one module.  So for now we won't use
- * separate compilation ... ensuring init/exit sections work to shrink
- * the runtime footprint, and giving us at least some parts of what
- * a "gcc --combine ... part1.c part2.c part3.c ... " build would.
- */
-#define USBF_ECM_INCLUDED
-#include "f_ecm.c"
-#include "u_ether.h"
-
-/*-*/
 USB_GADGET_COMPOSITE_OPTIONS();
 
 USB_ETHERNET_MODULE_PARAMETERS();
@@ -99,14 +86,14 @@ MODULE_LICENSE("GPL");
 /*-*/
 static struct usb_function *f_acm_cfg1;
 static struct usb_function *f_acm_cfg2;
-static u8 host_mac[ETH_ALEN];
+static struct usb_function *f_ecm_cfg1;
+static struct usb_function *f_ecm_cfg2;
 static struct usb_function *f_obex1_cfg1;
 static struct usb_function *f_obex2_cfg1;
 static struct usb_function *f_obex1_cfg2;
 static struct usb_function *f_obex2_cfg2;
 static struct usb_function *f_phonet_cfg1;
 static struct usb_function *f_phonet_cfg2;
-static struct eth_dev *the_dev;
 
 
 static struct usb_configuration nokia_config_500ma_driver = {
@@ -126,6 +113,7 @@ static struct usb_configuration nokia_config_100ma_driver = 
{
 };
 
 static struct usb_function_instance *fi_acm;
+static struct usb_function_instance *fi_ecm;
 static struct usb_function_instance *fi_obex1;
 static struct usb_function_instance *fi_obex2;
 static struct usb_function_instance *fi_phonet;
@@ -135,6 +123,7 @@ static int __init nokia_bind_config(struct 
usb_configuration *c)
struct usb_function *f_acm;
struct usb_function *f_phonet = NULL;
struct usb_function *f_obex1 = NULL;
+   struct usb_function *f_ecm;
struct usb_function *f_obex2 = NULL;
int status = 0;
int obex1_stat = 0;
@@ -165,6 +154,12 @@ static int __init nokia_bind_config(struct 
usb_configuration *c)
goto err_get_acm;
}
 
+   f_ecm = usb_get_function(fi_ecm);
+   if (IS_ERR(f_ecm)) {
+   status = PTR_ERR(f_ecm);
+   goto err_get_ecm;
+   }
+
if (!IS_ERR_OR_NULL(f_phonet)) {
phonet_stat = usb_add_function(c, f_phonet);
if (phonet_stat)
@@ -187,18 +182,20 @@ static int __init nokia_bind_config(struct 
usb_configuration *c)
if (status)
goto err_conf;
 
-   status = ecm_bind_config(c, host_mac, the_dev);
+   status = usb_add_function(c, f_ecm);
if (status) {
pr_debug("could not bind ecm config %d\n", status);
goto err_ecm;
}
if (c == &nokia_config_500ma_driver) {
f_acm_cfg1 = f_acm;
+   f_ecm_cfg1 = f_ecm;
f_phonet_cfg1 = f_phonet;
f_obex1_cfg1 = f_obex1;
f_obex2_cfg1 = f_obex2;
} else {
f_acm_cfg2 = f_acm;
+   f_ecm_cfg2 = f_ecm;
f_phonet_cfg2 = f_phonet;
f_obex1_cfg2 = f_obex1;
f_obex2_cfg2 = f_obex2;
@@ -214,6 +211,8 @@ err_conf:
usb_remove_function(c, f_obex1);
if (!phonet_stat)
usb_remove_function(c, f_phonet);
+   usb_put_function(f_ecm);
+err_get_ecm:
usb_put_function(f_acm);
 err_get_acm:
if (!IS_ERR_OR_NULL(f_obex2))
@@ -230,13 +229,6 @@ static int __init nokia_bind(struct usb_composite_dev 
*cdev)
struct usb_gadget   *gadget = cdev->gadget;
int status;
 
-   the_dev = gether_setup(cdev->gadget, dev_addr, host_addr, host_mac,
-  qmult);
-   if (IS_

[PATCH 9/9] usb/gadget: f_phonet: add configfs support

2013-05-15 Thread Andrzej Pietrasiewicz
Signed-off-by: Andrzej Pietrasiewicz 
Signed-off-by: Kyungmin Park 
---
 drivers/usb/gadget/Kconfig|   10 +++
 drivers/usb/gadget/f_phonet.c |   56 +
 2 files changed, 66 insertions(+), 0 deletions(-)

diff --git a/drivers/usb/gadget/Kconfig b/drivers/usb/gadget/Kconfig
index 9b6286d..ceabfc0 100644
--- a/drivers/usb/gadget/Kconfig
+++ b/drivers/usb/gadget/Kconfig
@@ -612,6 +612,16 @@ config USB_CONFIGFS_ECM
  favor of simpler vendor-specific hardware, but is widely
  supported by firmware for smart network devices.
 
+config USB_CONFIGFS_PHONET
+   boolean "Phonet protocol"
+   depends on USB_CONFIGFS
+   depends on NET
+   depends on PHONET
+   select USB_U_ETHER
+   select USB_F_PHONET
+   help
+ The Phonet protocol implementation for USB device.
+
 
 config USB_ZERO
tristate "Gadget Zero (DEVELOPMENT)"
diff --git a/drivers/usb/gadget/f_phonet.c b/drivers/usb/gadget/f_phonet.c
index c360149..97d39e3 100644
--- a/drivers/usb/gadget/f_phonet.c
+++ b/drivers/usb/gadget/f_phonet.c
@@ -26,6 +26,7 @@
 #include 
 
 #include "u_phonet.h"
+#include "u_ether.h"
 
 #define PN_MEDIA_USB   0x1B
 #define MAXPACKET  512
@@ -576,6 +577,58 @@ err:
return status;
 }
 
+static inline struct f_phonet_opts *to_f_phonet_opts(struct config_item *item)
+{
+   return container_of(to_config_group(item), struct f_phonet_opts,
+   func_inst.group);
+}
+
+CONFIGFS_ATTR_STRUCT(f_phonet_opts);
+static ssize_t f_phonet_attr_show(struct config_item *item,
+   struct configfs_attribute *attr,
+   char *page)
+{
+   struct f_phonet_opts *opts = to_f_phonet_opts(item);
+   struct f_phonet_opts_attribute *f_phonet_opts_attr =
+   container_of(attr, struct f_phonet_opts_attribute, attr);
+   ssize_t ret = 0;
+
+   if (f_phonet_opts_attr->show)
+   ret = f_phonet_opts_attr->show(opts, page);
+   return ret;
+}
+
+static void phonet_attr_release(struct config_item *item)
+{
+   struct f_phonet_opts *opts = to_f_phonet_opts(item);
+
+   usb_put_function_instance(&opts->func_inst);
+}
+
+static struct configfs_item_operations phonet_item_ops = {
+   .release= phonet_attr_release,
+   .show_attribute = f_phonet_attr_show,
+};
+
+static ssize_t f_phonet_ifname_show(struct f_phonet_opts *opts, char *page)
+{
+   return gether_get_ifname(opts->net, page, PAGE_SIZE);
+}
+
+static struct f_phonet_opts_attribute f_phonet_ifname =
+   __CONFIGFS_ATTR_RO(ifname, f_phonet_ifname_show);
+
+static struct configfs_attribute *phonet_attrs[] = {
+   &f_phonet_ifname.attr,
+   NULL,
+};
+
+static struct config_item_type phonet_func_type = {
+   .ct_item_ops= &phonet_item_ops,
+   .ct_attrs   = phonet_attrs,
+   .ct_owner   = THIS_MODULE,
+};
+
 static void phonet_free_inst(struct usb_function_instance *f)
 {
struct f_phonet_opts *opts;
@@ -598,6 +651,9 @@ static struct usb_function_instance *phonet_alloc_inst(void)
if (IS_ERR(opts->net))
return ERR_PTR(PTR_ERR(opts->net));
 
+   config_group_init_type_name(&opts->func_inst.group, "",
+   &phonet_func_type);
+
return &opts->func_inst;
 }
 
-- 
1.7.0.4

--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 7/9] usb/gadget: f_phonet: remove compatibility layer

2013-05-15 Thread Andrzej Pietrasiewicz
There are no old function interface users left, so the old interface
can be removed.

Signed-off-by: Andrzej Pietrasiewicz 
Signed-off-by: Kyungmin Park 
---
 drivers/usb/gadget/f_phonet.c |   84 ++---
 drivers/usb/gadget/u_phonet.h |1 -
 2 files changed, 4 insertions(+), 81 deletions(-)

diff --git a/drivers/usb/gadget/f_phonet.c b/drivers/usb/gadget/f_phonet.c
index e2adab7..c360149 100644
--- a/drivers/usb/gadget/f_phonet.c
+++ b/drivers/usb/gadget/f_phonet.c
@@ -576,55 +576,6 @@ err:
return status;
 }
 
-#ifdef USBF_PHONET_INCLUDED
-
-static void
-pn_old_unbind(struct usb_configuration *c, struct usb_function *f)
-{
-   struct f_phonet *fp = func_to_pn(f);
-   int i;
-
-   /* We are already disconnected */
-   if (fp->in_req)
-   usb_ep_free_request(fp->in_ep, fp->in_req);
-   for (i = 0; i < phonet_rxq_size; i++)
-   if (fp->out_reqv[i])
-   usb_ep_free_request(fp->out_ep, fp->out_reqv[i]);
-
-   usb_free_all_descriptors(f);
-   kfree(fp);
-}
-
-/*-*/
-
-int __init phonet_bind_config(struct usb_configuration *c,
- struct net_device *dev)
-{
-   struct f_phonet *fp;
-   int err, size;
-
-   size = sizeof(*fp) + (phonet_rxq_size * sizeof(struct usb_request *));
-   fp = kzalloc(size, GFP_KERNEL);
-   if (!fp)
-   return -ENOMEM;
-
-   fp->dev = dev;
-   fp->function.name = "phonet";
-   fp->function.bind = pn_bind;
-   fp->function.unbind = pn_old_unbind;
-   fp->function.set_alt = pn_set_alt;
-   fp->function.get_alt = pn_get_alt;
-   fp->function.disable = pn_disconnect;
-   spin_lock_init(&fp->rx.lock);
-
-   err = usb_add_function(c, &fp->function);
-   if (err)
-   kfree(fp);
-   return err;
-}
-
-#else
-
 static void phonet_free_inst(struct usb_function_instance *f)
 {
struct f_phonet_opts *opts;
@@ -732,38 +683,11 @@ int gphonet_register_netdev(struct net_device *net)
return status;
 }
 
-DECLARE_USB_FUNCTION_INIT(phonet, phonet_alloc_inst, phonet_alloc);
-MODULE_AUTHOR("Rémi Denis-Courmont");
-MODULE_LICENSE("GPL");
-
-#endif
-
-struct net_device *gphonet_setup(struct usb_gadget *gadget)
-{
-   struct net_device *dev;
-   struct phonet_port *port;
-   int err;
-
-   /* Create net device */
-   dev = alloc_netdev(sizeof(*port), "upnlink%d", pn_net_setup);
-   if (!dev)
-   return ERR_PTR(-ENOMEM);
-
-   port = netdev_priv(dev);
-   spin_lock_init(&port->lock);
-   netif_carrier_off(dev);
-   SET_NETDEV_DEV(dev, &gadget->dev);
-
-   err = register_netdev(dev);
-   if (err) {
-   free_netdev(dev);
-
-   return ERR_PTR(err);
-   }
-   return dev;
-}
-
 void gphonet_cleanup(struct net_device *dev)
 {
unregister_netdev(dev);
 }
+
+DECLARE_USB_FUNCTION_INIT(phonet, phonet_alloc_inst, phonet_alloc);
+MODULE_AUTHOR("Rémi Denis-Courmont");
+MODULE_LICENSE("GPL");
diff --git a/drivers/usb/gadget/u_phonet.h b/drivers/usb/gadget/u_phonet.h
index 1ff5ad5..98ced18 100644
--- a/drivers/usb/gadget/u_phonet.h
+++ b/drivers/usb/gadget/u_phonet.h
@@ -23,7 +23,6 @@ struct f_phonet_opts {
 struct net_device *gphonet_setup_default(void);
 void gphonet_set_gadget(struct net_device *net, struct usb_gadget *g);
 int gphonet_register_netdev(struct net_device *net);
-struct net_device *gphonet_setup(struct usb_gadget *gadget);
 int phonet_bind_config(struct usb_configuration *c, struct net_device *dev);
 void gphonet_cleanup(struct net_device *dev);
 
-- 
1.7.0.4

--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 3/9] usb/gadget: f_obex: remove compatibility layer

2013-05-15 Thread Andrzej Pietrasiewicz
There are no old function interface users left, so the old interface
can be removed.

Signed-off-by: Andrzej Pietrasiewicz 
Signed-off-by: Kyungmin Park 
---
 drivers/usb/gadget/f_obex.c |   54 ---
 1 files changed, 0 insertions(+), 54 deletions(-)

diff --git a/drivers/usb/gadget/f_obex.c b/drivers/usb/gadget/f_obex.c
index be2d762..9f4ef2f 100644
--- a/drivers/usb/gadget/f_obex.c
+++ b/drivers/usb/gadget/f_obex.c
@@ -402,57 +402,6 @@ fail:
return status;
 }
 
-#ifdef USBF_OBEX_INCLUDED
-
-static void
-obex_old_unbind(struct usb_configuration *c, struct usb_function *f)
-{
-   obex_string_defs[OBEX_CTRL_IDX].id = 0;
-   usb_free_all_descriptors(f);
-   kfree(func_to_obex(f));
-}
-
-/**
- * obex_bind_config - add a CDC OBEX function to a configuration
- * @c: the configuration to support the CDC OBEX instance
- * @port_num: /dev/ttyGS* port this interface will use
- * Context: single threaded during gadget setup
- *
- * Returns zero on success, else negative errno.
- */
-int __init obex_bind_config(struct usb_configuration *c, u8 port_num)
-{
-   struct f_obex   *obex;
-   int status;
-
-   /* allocate and initialize one new instance */
-   obex = kzalloc(sizeof *obex, GFP_KERNEL);
-   if (!obex)
-   return -ENOMEM;
-
-   obex->port_num = port_num;
-
-   obex->port.connect = obex_connect;
-   obex->port.disconnect = obex_disconnect;
-
-   obex->port.func.name = "obex";
-   obex->port.func.strings = obex_strings;
-   /* descriptors are per-instance copies */
-   obex->port.func.bind = obex_bind;
-   obex->port.func.unbind = obex_old_unbind;
-   obex->port.func.set_alt = obex_set_alt;
-   obex->port.func.get_alt = obex_get_alt;
-   obex->port.func.disable = obex_disable;
-
-   status = usb_add_function(c, &obex->port.func);
-   if (status)
-   kfree(obex);
-
-   return status;
-}
-
-#else
-
 static inline struct f_serial_opts *to_f_serial_opts(struct config_item *item)
 {
return container_of(to_config_group(item), struct f_serial_opts,
@@ -581,8 +530,5 @@ struct usb_function *obex_alloc(struct 
usb_function_instance *fi)
 }
 
 DECLARE_USB_FUNCTION_INIT(obex, obex_alloc_inst, obex_alloc);
-
-#endif
-
 MODULE_AUTHOR("Felipe Balbi");
 MODULE_LICENSE("GPL");
-- 
1.7.0.4

--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH] usb: otg: mxs-phy: add missing type to usb_phy

2013-05-15 Thread Michael Grzeschik
The mxs-phy is missing the phy.type property, why the usb_get_phy helper
function won't be able to find it. This patch adds this missing property.

Signed-off-by: Michael Grzeschik 
---
 drivers/usb/phy/phy-mxs-usb.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/usb/phy/phy-mxs-usb.c b/drivers/usb/phy/phy-mxs-usb.c
index 9d4381e..f8588f1 100644
--- a/drivers/usb/phy/phy-mxs-usb.c
+++ b/drivers/usb/phy/phy-mxs-usb.c
@@ -160,6 +160,7 @@ static int mxs_phy_probe(struct platform_device *pdev)
mxs_phy->phy.set_suspend= mxs_phy_suspend;
mxs_phy->phy.notify_connect = mxs_phy_on_connect;
mxs_phy->phy.notify_disconnect  = mxs_phy_on_disconnect;
+   mxs_phy->phy.type   = USB_PHY_TYPE_USB2;
 
ATOMIC_INIT_NOTIFIER_HEAD(&mxs_phy->phy.notifier);
 
-- 
1.8.2.rc2

--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH] qmi_wwan: Added support for Cinterion's PLxx WWAN Interface

2013-05-15 Thread Sergei Shtylyov

Hello.

On 15-05-2013 16:28, Schmiedl Christian wrote:


/drivers/net/usb/qmi_wwan.c: Added support for Cinterion's PLxx WWAN Interface
by adding QMI_FIXED_INTF with Cinterion's Vendor ID as well as Product ID and
WWAN Interface Number.



Signed-off-by: Hans-Christoph Schemmel  
gemalto.com>
Signed-off-by: Christian Schmiedl  gemalto.com>
---
patch is against linux-3.9
--- linux-3.9/drivers/net/usb/qmi_wwan.c.orig   2013-05-06 08:10:11.170034451 
+0200
+++ linux-3.9/drivers/net/usb/qmi_wwan.c2013-05-06 08:58:00.800264179 
+0200
  -569,6 +569,7  static const struct usb_device_id 
produc


   Your patch is corrupt. From the "  " it seems the corruptor 
was gmane. :-)


WBR, Sergei

--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH] qmi_wwan: Added support for Cinterion's PLxx WWAN Interface

2013-05-15 Thread Schmiedl Christian
/drivers/net/usb/qmi_wwan.c: Added support for Cinterion's PLxx WWAN Interface
by adding QMI_FIXED_INTF with Cinterion's Vendor ID as well as Product ID and
WWAN Interface Number.

Signed-off-by: Hans-Christoph Schemmel 
Signed-off-by: Christian Schmiedl 
---
patch is against linux-3.9
--- linux-3.9/drivers/net/usb/qmi_wwan.c.orig   2013-05-06 08:10:11.170034451 
+0200
+++ linux-3.9/drivers/net/usb/qmi_wwan.c2013-05-06 08:58:00.800264179 
+0200
@@ -569,6 +569,7 @@ static const struct usb_device_id produc
{QMI_FIXED_INTF(0x1bbb, 0x011e, 4)},/* Telekom Speedstick LTE II 
(Alcatel One Touch L100V LTE) */
{QMI_FIXED_INTF(0x2357, 0x0201, 4)},/* TP-LINK HSUPA Modem MA180 */
{QMI_FIXED_INTF(0x1bc7, 0x1200, 5)},/* Telit LE920 */
+   {QMI_FIXED_INTF(0x1e2d, 0x12d1, 4)},/* Cinterion PLxx */

/* 4. Gobi 1000 devices */
{QMI_GOBI1K_DEVICE(0x05c6, 0x9212)},/* Acer Gobi Modem Device */
--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH v6 9/9] rcar-phy: handle platform data

2013-05-15 Thread Felipe Balbi
Hi,

On Tue, Apr 30, 2013 at 11:02:18PM +0400, Sergei Shtylyov wrote:
> >BTW, conversion away from iowrite32() could (should) be part of a
> >separate patch. No need to prevent this one from being applied.
> >
> 
>Of course. You mean conversion to plain writel(), right?

right, "away" from iowrite32() ;-)

-- 
balbi


signature.asc
Description: Digital signature


Re: [PATCH v6 9/9] rcar-phy: handle platform data

2013-05-15 Thread Sergei Shtylyov

Hello.

On 15-05-2013 18:01, Felipe Balbi wrote:


BTW, conversion away from iowrite32() could (should) be part of a
separate patch. No need to prevent this one from being applied.



Of course. You mean conversion to plain writel(), right?



right, "away" from iowrite32() ;-)


   Well, I used to think it's implemented everywhere now, as the recent 
trend seems to use it in preference to readl(), at least in several 
subsystems...


   BTW, how about ACKing patch #7 now that I've recast it?

WBR, Sergei

--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: usb: musb: Fix LapDock enumeration on omap for boot and slow cable insertion

2013-05-15 Thread Felipe Balbi
On Fri, May 03, 2013 at 11:01:33AM -0700, Tony Lindgren wrote:
> * Tony Lindgren  [130503 10:55]:
> > Looks like we can get VBUS interrupt before the ID interrupt

how can this happen ? VBUS interrupt happens when you connect to a port
which is sourcing VBUS to you, while ID interrupt happens when ID is
grounded, meaning that you should be sourcing VBUS.

Have you hacked a Hub to backfeed 5V to OMAP by any chance ?

-- 
balbi


signature.asc
Description: Digital signature


Re: dwc3 on omap5432 no SuperSpeed host mode

2013-05-15 Thread Felipe Balbi
Hi,

On Wed, May 08, 2013 at 06:14:43PM +0200, Ben Dooks wrote:
> >>>* Ben Dooks | 2013-05-07 22:06:33 [+0200]:
> >>>
> We are using an OMAP5432 ES2.0 on an UEVM board
> and running into issues with the dwc3 usb.
> >>>
> >>>Sorry, I can't help at all. I don't have the board and I never had one.
> >>>I had ES1.0 but I never got dwc3 to work.
> >>
> >>I have better news, re-based to 3.8.11 and it has now enumerated
> >>the USB3 card reader at SuperSpeed.
> >>
> >>It seems the board is very picky about what it will play host to
> >>as neither of the mini-b to A adapters I have work. I am using
> >>a mini B to mini B cable to run the card reader.
> >>
> >>I have still got the disable CMD_RESET patch in.
> >
> >yeah, there are a few issues regarding CMD_RESET bit on the XHCI side
> >with that IP. We're still trying to find a proper workaround.
> 
> Is replacing the xhci-hcd.c reset command with a call to the dwc3
> driver not enough? I will leave this for the moment if it is being
> worked on.
> 
> Even if we are just working in gadget mode, having the xhci-hcd driver
> around causes the system to stop working.

yeah, basically CMD_RESET (which is set during XHCI probe) causes some
Global and Device Endpoint registers to corrupt. no workaround yet,
other than constantly resetting the whole thing when you want to switch
roles.

What you can do, however, is to choose in Kconfig to have it working as
peripheral only, then you're safe.

-- 
balbi


signature.asc
Description: Digital signature


Re: dwc3 on omap5432 no SuperSpeed host mode

2013-05-15 Thread Ben Dooks

On 15/05/13 15:09, Felipe Balbi wrote:

Hi,

On Wed, May 08, 2013 at 06:14:43PM +0200, Ben Dooks wrote:

* Ben Dooks | 2013-05-07 22:06:33 [+0200]:


We are using an OMAP5432 ES2.0 on an UEVM board
and running into issues with the dwc3 usb.


Sorry, I can't help at all. I don't have the board and I never had one.
I had ES1.0 but I never got dwc3 to work.


I have better news, re-based to 3.8.11 and it has now enumerated
the USB3 card reader at SuperSpeed.

It seems the board is very picky about what it will play host to
as neither of the mini-b to A adapters I have work. I am using
a mini B to mini B cable to run the card reader.

I have still got the disable CMD_RESET patch in.


yeah, there are a few issues regarding CMD_RESET bit on the XHCI side
with that IP. We're still trying to find a proper workaround.


Is replacing the xhci-hcd.c reset command with a call to the dwc3
driver not enough? I will leave this for the moment if it is being
worked on.

Even if we are just working in gadget mode, having the xhci-hcd driver
around causes the system to stop working.


yeah, basically CMD_RESET (which is set during XHCI probe) causes some
Global and Device Endpoint registers to corrupt. no workaround yet,
other than constantly resetting the whole thing when you want to switch
roles.

What you can do, however, is to choose in Kconfig to have it working as
peripheral only, then you're safe.


Ok, I was under the impression that it was needed even for host only.

We still have not managed to get a stable xhci host mode on the
OMAP5432-UEVM board at SuperSpeed.

--
Ben Dooks   http://www.codethink.co.uk/
Senior Engineer Codethink - Providing Genius
--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH] USB: fix Kconfig logic for USB_UHCI_HCD

2013-05-15 Thread Arnd Bergmann
On Tuesday 14 May 2013, Alan Stern wrote:
> The Kconfig settings for uhci-hcd are too permissive; they allow the
> driver to be built without any bus-glue modules configured
> (USB_UHCI_HCD enabled, PCI disabled, SPARC_LEON disabled, ARCH_VT8500
> enabled, and USB_UHCI_PLATFORM disabled).
> 
> This patch fixes the problem by rearranging the dependencies.  Now the
> platform-dependent config options don't depend on USB_UHCI_HCD;
> instead it depends on them.  Furthermore, there is no user-selectable
> choice as to which glue modules will be built.  If USB_UHCI_HCD is
> enabled then all applicable bus glues will be built.
> 
> Signed-off-by: Alan Stern 
> CC: Arnd Bergmann 

Acked-by: Arnd Bergmann 

How do you want to handle this for OHCI and EHCI? Are you still considering
the patches I sent for those, or do you have another solution?

I think we can simply remove the #error for EHCI now, and do the same
for OHCI once we have a proper version of "USB: OHCI: prepare to make
ohci-hcd a library module".

Arnd
--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [OPW kernel] xhci.c: dma_set_mask

2013-05-15 Thread Alan Stern
On Tue, 14 May 2013, Sarah Sharp wrote:

> On Wed, May 15, 2013 at 04:56:00AM +0300, Xenia Ragiadakou wrote:
> > Hi Sarah,
> 
> Hi Ksenia!
> 
> > In xhci.c line 4665, the function dma_set_mask is used to enable
> > 64-bit DMA addressing
> > (if i understood correctly).
> > 
> > However, accordingly to the Documentation/DMA-API-HOWTO.txt, there
> > is possibility
> > that the platform cannot support the DMA addressing of the device.
> > So the return value of dma_set_mask needs to be tested if it equals
> > zero and if not
> > go to error label. Am I right?
> >
> > Can we assume that 64 bit or 32 bit DMA addressing will always be supported?
> > This is the first time i come through these stuff so my intuition is
> > limited.
> 
> All xHCI hosts are required to support DMA, by the xHCI specification.
> You just can't get USB 3.0 speeds without DMA.
> 
> Or are you concerned that the xHCI host will support 64-bit DMA, but the
> system only supports 32-bit DMA?  Because that would be a question for
> Alan Stern, who has worked on the USB core for far longer than I have.

I suppose it is possible.  It's also possible that the xHCI hardware 
might support 32-bit DMA only.

> The xHCI PCI driver sets the hc_driver->flag for HCD_MEMORY, which means
> the USB host controller requires DMA.

Actually it means that the host controller uses memory-mapped I/O for 
register accesses.  HCD_MEMORY has no connection with DMA.  Maybe 
you're thinking of the uses_dma flag in struct usb_bus.

>  In drivers/usb/core/hcd-pci.c
> (which is what the xHCI PCI driver calls into in its probe function),
> the USB core will fail the init if the device doesn't support DMA.

No, it won't.  The uses_dma flag gets set during initialization in 
usb_create_shared_hcd(), but it isn't checked at all during init.

Alan Stern

--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH v2 1/2] usb: chipidea: big-endian support

2013-05-15 Thread Marc Kleine-Budde
On 05/09/2013 11:22 PM, Svetoslav Neykov wrote:
> Hi Marc,
> 
> Marc Kleine-Budde [mailto:m...@pengutronix.de] (On Thursday, March 28, 2013
> 4:16 PM)
>> On 03/28/2013 10:28 AM, Alexander Shishkin wrote:
>>> Svetoslav Neykov  writes:
>>>
 Convert between big-endian and little-endian format when accessing
 the usb controller structures which are little-endian by
 specification. Fix cases where the little-endian memory layout is
 taken for granted. The patch doesn't have any effect on the already
 supported little-endian architectures.
>>
>> Has anyone tested how the cpu_to_le32 and vice versa effects the
>> load/store operations? Does the compiler generate full 32 bit accesses
>> on mips (and big endian arm) or is a byte-shift-or pattern used?
> 
> Better late than never... I have checked your question, the value is loaded
> in a register and then swapped, so the read is performed only once.

Thanks for checking this.

Marc

-- 
Pengutronix e.K.  | Marc Kleine-Budde   |
Industrial Linux Solutions| Phone: +49-231-2826-924 |
Vertretung West/Dortmund  | Fax:   +49-5121-206917- |
Amtsgericht Hildesheim, HRA 2686  | http://www.pengutronix.de   |



signature.asc
Description: OpenPGP digital signature


Re: dwc3 on omap5432 no SuperSpeed host mode

2013-05-15 Thread Felipe Balbi
Hi,

On Wed, May 15, 2013 at 03:15:44PM +0100, Ben Dooks wrote:
> It seems the board is very picky about what it will play host to
> as neither of the mini-b to A adapters I have work. I am using
> a mini B to mini B cable to run the card reader.
> 
> I have still got the disable CMD_RESET patch in.
> >>>
> >>>yeah, there are a few issues regarding CMD_RESET bit on the XHCI side
> >>>with that IP. We're still trying to find a proper workaround.
> >>
> >>Is replacing the xhci-hcd.c reset command with a call to the dwc3
> >>driver not enough? I will leave this for the moment if it is being
> >>worked on.
> >>
> >>Even if we are just working in gadget mode, having the xhci-hcd driver
> >>around causes the system to stop working.
> >
> >yeah, basically CMD_RESET (which is set during XHCI probe) causes some
> >Global and Device Endpoint registers to corrupt. no workaround yet,
> >other than constantly resetting the whole thing when you want to switch
> >roles.
> >
> >What you can do, however, is to choose in Kconfig to have it working as
> >peripheral only, then you're safe.
> 
> Ok, I was under the impression that it was needed even for host only.
> 
> We still have not managed to get a stable xhci host mode on the
> OMAP5432-UEVM board at SuperSpeed.

funny, we tested this a few days back. Right now I don't have HW with me
(travelling), but Kishon has. Maybe he can help us out ?

-- 
balbi


signature.asc
Description: Digital signature


Re: dwc3 on omap5432 no SuperSpeed host mode

2013-05-15 Thread Ben Dooks

On 15/05/13 15:30, Felipe Balbi wrote:

Hi,

On Wed, May 15, 2013 at 03:15:44PM +0100, Ben Dooks wrote:

It seems the board is very picky about what it will play host to
as neither of the mini-b to A adapters I have work. I am using
a mini B to mini B cable to run the card reader.

I have still got the disable CMD_RESET patch in.


yeah, there are a few issues regarding CMD_RESET bit on the XHCI side
with that IP. We're still trying to find a proper workaround.


Is replacing the xhci-hcd.c reset command with a call to the dwc3
driver not enough? I will leave this for the moment if it is being
worked on.

Even if we are just working in gadget mode, having the xhci-hcd driver
around causes the system to stop working.


yeah, basically CMD_RESET (which is set during XHCI probe) causes some
Global and Device Endpoint registers to corrupt. no workaround yet,
other than constantly resetting the whole thing when you want to switch
roles.

What you can do, however, is to choose in Kconfig to have it working as
peripheral only, then you're safe.


Ok, I was under the impression that it was needed even for host only.

We still have not managed to get a stable xhci host mode on the
OMAP5432-UEVM board at SuperSpeed.


funny, we tested this a few days back. Right now I don't have HW with me
(travelling), but Kishon has. Maybe he can help us out ?


It would be useful to find out which version of the kernel and u-boot
where used.

--
Ben Dooks   http://www.codethink.co.uk/
Senior Engineer Codethink - Providing Genius
--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [V9 PATCH 00/12] mv-usb phy driver

2013-05-15 Thread Felipe Balbi
Hi,

On Wed, Apr 17, 2013 at 09:22:36AM +0800, Chao Xie wrote:
> On Wed, Apr 17, 2013 at 9:17 AM, Chao Xie  wrote:
> >
> > On Sun, Apr 7, 2013 at 6:29 PM, Chao Xie  wrote:
> >>
> >> The patches create the mv-usb phy driver
> >>
> >>
> >>   directly use devm_usb_get_phy_dev return value for error return.
> >>
> >> v9->v8
> >>   Remove u2o_xxx.
> >>   Add prefix for register definition
> >>   Move mutex to common PHY layer
> >>   Use module_platform_driver() to register driver
> >>   Use usleep_range to replace udelay
> >>
> >> Chao Xie (12):
> >>   usb: phy: protect phy init and shutdown for mutiple deivces
> >>   usb: phy: mv_usb2: add PHY driver for marvell usb2 controller
> >>   usb: gadget: mv_udc: use PHY driver for udc
> >>   usb: ehci: ehci-mv: use PHY driver for ehci
> >>   usb: phy: phy-mv-usb: use USB2 PHY driver for otg
> >>   usb: mv_u3d: usb phy drivers for phy operation
> >>   arm: mmp2: change the defintion of usb devices
> >>   arm: pxa910: change the defintion of usb devices
> >>   arm: ttc_dkb: modify usb support
> >>   arm: mmp: remove unused usb devices
> >>   arm: brownstone: add usb support for the board
> >>   usb: mv_usb: remove the phy callbacks in pdata
> >>
> >>  arch/arm/mach-mmp/brownstone.c  |   56 +
> >>  arch/arm/mach-mmp/include/mach/mmp2.h   |4 +
> >>  arch/arm/mach-mmp/include/mach/pxa910.h |7 +-
> >>  arch/arm/mach-mmp/mmp2.c|4 +
> >>  arch/arm/mach-mmp/pxa910.c  |4 +
> >>  arch/arm/mach-mmp/ttc_dkb.c |   39 +++-
> >>  drivers/usb/gadget/mv_u3d.h |3 +-
> >>  drivers/usb/gadget/mv_u3d_core.c|   54 ++---
> >>  drivers/usb/gadget/mv_udc.h |2 +-
> >>  drivers/usb/gadget/mv_udc_core.c|   50 ++---
> >>  drivers/usb/host/ehci-mv.c  |   49 ++---
> >>  drivers/usb/phy/Kconfig |6 +
> >>  drivers/usb/phy/Makefile|1 +
> >>  drivers/usb/phy/phy-mv-usb.c|   53 ++---
> >>  drivers/usb/phy/phy-mv-usb.h|2 +-
> >>  drivers/usb/phy/phy-mv-usb2.c   |  380
> >> +++
> >>  drivers/usb/phy/phy.c   |6 +
> >>  include/linux/platform_data/mv_usb.h|3 -
> >>  include/linux/usb/mv_usb2.h |   29 +++
> >>  include/linux/usb/phy.h |   22 ++-
> >>  20 files changed, 624 insertions(+), 150 deletions(-)
> >>  create mode 100644 drivers/usb/phy/phy-mv-usb2.c
> >>  create mode 100644 include/linux/usb/mv_usb2.h
> >>
> >> --
> >> 1.7.4.1
> >>
> >>
> >
> hi, balbi
> You have given many valuable comments and suggestions for previous version.
> So i modified the driver based on your review feedback. Can you help to
> review the new version? Thanks.

sure, just give me a few more days and I'll get to these.

-- 
balbi


signature.asc
Description: Digital signature


  1   2   >