Re: [PATCH v3 0/6] libusbg: Add remove gadget/config/func/binding functionality.

2014-09-23 Thread Matt Porter
On Tue, Mar 18, 2014 at 09:29:00PM +0100, Krzysztof Opasiak wrote:
 Dear Matt,
 
 In this series of patch I have added remove gadget, config, function,
 binding functionality which was missing since introduction of library.
 
 I have also added remove strings functionality which allow to remove
 gadget and configuration strings in given language.
 
 To show how to use new part of API I have also added example
 gadget-vid-pid-remove which removes gadget created by
 gadget-acm-ecm (identified using VID and PID).
 
 This series of patch depends on all my previous series which you can
 find on a list or in github pull request.

Applied to master, thanks.

-Matt

 ---
 Changes since v1:
 - rebased on [1] and adjust to new memory management conventions
 - Replace sprintf with snprintf
 
 1 - http://article.gmane.org/gmane.linux.usb.general/105164
 
 Changes since v2:
 - rebased on v2 of earlier mentioned patch series
 - use sizeof(target) in snprintf() instead of macro with direct size
 - use USBG_MAX_PATH_LENGTH instead of PATH_MAX
 - clean up topic from unwanted patches added by mistake
 
 Krzysztof Opasiak (6):
   libusbg: Add remove binding functionality.
   libusbg: Add remove gadget/config strings functionality.
   libusbg: Add remove configuration functionality.
   libusbg: Add remove function functionality.
   libusbg: Add remove gadget functionality.
   libusbg: Update examples to new API functionality.
 
  examples/Makefile.am |3 +-
  examples/gadget-vid-pid-remove.c |  113 +
  include/usbg/usbg.h  |   57 -
  src/usbg.c   |  259 
 ++
  4 files changed, 430 insertions(+), 2 deletions(-)
  create mode 100644 examples/gadget-vid-pid-remove.c
 
 -- 
 1.7.9.5
 
--
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 0/4] libusbg: Fix potential issues found with coverity

2014-09-23 Thread Matt Porter
On Tue, May 13, 2014 at 05:13:18PM +0300, Philippe De Swert wrote:
 This patch series fixes a number of issues found with coverity in libusbg
 A pull request has also be made:
 https://github.com/libusbg/libusbg/pull/4
 
 This is the second version where we use a different fix for the readlink,
 actually use the right USB_MAX_STR_LENGTH define. I also fixed an issue
 I missed first time around.

Thanks, applied to master.

-Matt

 Philippe De Swert (4):
   libusbg: Fix readlink/buffer overrun issue. CID#56130, CID#56129
   libusbg: Fix buffer overrun issue. CID#56128
   libusbg: Do not try to dereference func when it is NULL. CID#56127
   libusbg: Do not dereference usb config attributes when they are NULL.
 CID#56126
 
  src/usbg.c | 7 ---
  1 file changed, 4 insertions(+), 3 deletions(-)
 
 -- 
 1.8.1.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


Re: [PATCH v2 0/4] libusbg: Add support for functionfs

2014-09-23 Thread Matt Porter
On Wed, Jun 11, 2014 at 05:09:46PM +0200, Krzysztof Opasiak wrote:
 Dear Matt,
 
 Configuration of function fs based functions using config fs has been
 merged to linux kernel quite long ago. To keep libusbg up to date I
 have prepared patches that add support for functionfs function type.
 
 When working with ffs I noticed that it would be a good feature to
 provide device name directly to user and avoid him confusion that
 instance name has to be the same as device to mount ffs. That's why I
 have added structure for ffs attributes which has only one, pure
 virtual (not present in configfs and read-only) attribute dev_name.
 
 Now user can create ffs function in a two ways:
 
 1) Pass instance name name and then get function attributes (device
 name)
 
 2) Pass NULL as instance name and pass function attributes with
 desired device name

This is great, I just made use of this in an application I'm working
on now and like it.

 First commit in this serie fix potential memory leak which could
 take place in usbg_init(). To avoid this usbg_init() has been
 refactored and now all memory should be free() properly.
 
 I have created pull request on github with those patches [1].
 
 Please also notice that there are still two pending patch series:
 
 1) Remove gadget functionality [2]
 This one has been changed according to your review but is still
 pending for over a month.
 
 2) Couple fixes from Philippe De Swert [3]
 That's a few commits which fix errors reported by coverity.
 I have reviewed this serie, build and run and it looks good
 to me. Please also run through this code and merge if you
 don't find anny issues.
 

Applied to master, thanks!

-Matt
--
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 v3 00/15] Add import from/export to file functionality

2014-09-23 Thread Matt Porter
On Mon, Aug 25, 2014 at 10:54:51AM +0200, Krzysztof Opasiak wrote:
 Dear Matt,
 
 This quite big series adds new part of libusbg API which allows to
 import/export gadget/function/configuration from/to file.
 
 Motivation:
 
 Libusbg allows to create a binary file which set up custom
 gadget. This is useful but if we have to create custom binary for
 each gadget we wast a lot of work which kernel people put to separate
 code from configuration. This leads us to main idea of gadget
 schemes. Allow to create simple, human readable config file which
 library will be able to translate into usb gadget.
 
 Description:
 
 Gadget schemes is idea of describing gadget/function/configuration in
 config file. To not reinvent the wheel I have used existing library
 libconfig [1]. This means that the syntax is similar to this described
 in documentation of libconfig.

Thank goodness. Apparently you read my mind and avoided use of xml and
json here. I've used libconfig before and really like the human
readable/creatable syntax.

 
 I have extended the library with set of usbg_export_*() functions
 which allows to export selected gadget to given FILE. There is also
 set of complementary usbg_import_*() functions which allows to read
 scheme of gadget/function/config from file and create it using
 configfs.
 
 To avoid name conflict I have used the convention that
 usbg_import_gadget() function takes name of new gadget as parameter
 and usbg_export_gadget() doesn't export gadget name to scheme
 file. Similar idea is used in configuration and functions.
 
 Base convention of gadget schemes is simple: if something is not set
 in scheme file, default values provided by kernel are used. Moreover
 configfs has some attributes which are read only. To allow to store
 them in scheme file they are ignored by import functions.
 
 Usage of libconfig and whole design of gadget schemes allows us to use
 include directive in gadget definition to import complicated
 configurations or functions.
 
 Syntax and detailed rules of using schemes has been described in
 gadget_schemes.txt in commit:
 
snip

 Summary:
 
 I have created a pull request also for this series:
 
 https://github.com/libusbg/libusbg/pull/8

Applied this to master, thanks.

 
 Feel free to provide your comments about the whole idea and also about
 its implementation.

It all looks good, my major concern when you had first mentioned this
was about was schema/format would be used. APIs look great, and I've
tested this with my own WIP application and it works quite nicely.
Thanks for adding this feature.

-Matt
--
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] libusbg: Fix usbg_disable_gadget to actually clear the UDC

2014-09-23 Thread 'Matt Porter'
On Tue, Sep 23, 2014 at 12:21:01PM +0200, Krzysztof Opasiak wrote:
  -Original Message-
  From: Tony Lindgren [mailto:t...@atomide.com]
  Sent: Monday, September 22, 2014 3:17 PM
  To: Krzysztof Opasiak
  Cc: 'Matt Porter'; linux-usb@vger.kernel.org; Stanislaw Wadas;
  Andrzej Pietrasiewicz; Marek Szyprowski; Karol Lewandowski;
  philippedesw...@gmail.com
  Subject: Re: [PATCH] libusbg: Fix usbg_disable_gadget to actually
  clear the UDC
  
  * Krzysztof Opasiak k.opas...@samsung.com [140922 01:07]:
   Dear Tony,
  
-Original Message-
From: linux-usb-ow...@vger.kernel.org [mailto:linux-usb-
ow...@vger.kernel.org] On Behalf Of Tony Lindgren
Sent: Saturday, September 20, 2014 5:51 PM
To: Matt Porter
Cc: linux-usb@vger.kernel.org
Subject: [PATCH] libusbg: Fix usbg_disable_gadget to actually
  clear
the UDC
   
Currently usbg_disable_gadget() does not actually write
  anything
to UDC to clear it and the configured UDC name stays there.
   
  
   No, udc name doesn't stay there due to O_TRUNC flag which is
  always used
   for writing in usbg_write_string(). With this flag we don't need
  to
   write new line to file because size of file is set to 0 while
  opening.
  
   Summing up:
  
   open(/sys/kernel/config/usb_gadget/g1/UDC,
  O_WRONLY|O_CREAT|O_TRUNC,
   0666) = 3
   close(3)= 0
  
   causes unbind, so everything works fine.
  
  Hmm not clearing for me doing this afterwards:
  
  # cat /sys/kernel/config/usb_gadget/g1/UDC
  musb-hdrc.0.auto
  
  The UDC name stays there and won't get cleared.
  
  Am I missing something?
 
 Please forgive me, I have checked it once again and you are right. I
 thought that truncate flag works on configfs in a similar way than on
 others fs but I was wrong. This flag simply does nothing and you have
 definitely found a bug.
 
 I was certain sure that this function works fine due to
 gadget-vid-pid-remove example. In this simple program gadget is disabled
 before removing. I had in my mind that it is impossible to modify a
 gadget if it is bound to any udc. This example worked fine so I assumed
 that usbg_disable_gadget() also works fine. I have look into configfs
 composite gadget source and there I have found some surprise:
 
   /*
* ideally I would like to forbid to unlink functions while a
 gadget is
* bound to an UDC. Since this isn't possible at the moment, we
 simply
* force an unbind, the function is available here and then we
 can
* remove the function.
*/
   mutex_lock(gi-lock);
   if (gi-udc_name)
   unregister_gadget(gi);
   WARN_ON(gi-udc_name);
 
 This means that it is currently possible to remove function binding on
 enabled gadget and it will cause unbind. This is why usbg_rm_gadget()
 also worked fine without proper usbg_disable_gadget().
 
 Summing up, Your patch fix an important bug. Its form is good for me. I
 have checked it and it works fine. You may add:
 
 Reviewed-by: Krzysztof Opasiak k.opas...@samsung.com
 
 If it is going about Matt Porter activity, he is not responding for
 mails or patches since April. I have github-fork of libusbg [1] with
 latest source (my master is 35 commits ahead of libusbg/master and some
 devel branches are even more). All patches which are intended for
 libusbg (sent on a list or from pull requests) are merged there after
 review.
 
 Please let me also notice that your patch has been also merged into my
 master.
 
 Thank you for fixing this issue.

Also verified that it fixes the issue here. Applied to master [1] along
with all of the backlog, excluding the WIP usbg_udc patches. Thanks for
everybody's patience.

-Matt

[1] https://github.com/libusbg/libusbg
--
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] dt: bindings: dwc2: fix required value for the phy-names property

2014-04-24 Thread Matt Porter
7408484 usb: gadget: s3c-hsotg: enable generic phy support introduces
generic phy support to the dwc2.txt binding and the s3c-hsotg driver
which implements support for the binding. The binding documentation
incorrectly states that the phy-names property will be device. The
binding example, driver, and one dts user all implement the phy-names
property as requiring usb2-phy.

Fix the dwc2.txt binding documentation to correctly specify usb2-phy
as the appropriate value for phy-names.

Reported-by: Tomasz Figa t.f...@samsung.com
Signed-off-by: Matt Porter mpor...@linaro.org
---
 Documentation/devicetree/bindings/usb/dwc2.txt | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/Documentation/devicetree/bindings/usb/dwc2.txt 
b/Documentation/devicetree/bindings/usb/dwc2.txt
index b8b6871..467ddd1 100644
--- a/Documentation/devicetree/bindings/usb/dwc2.txt
+++ b/Documentation/devicetree/bindings/usb/dwc2.txt
@@ -13,7 +13,7 @@ Refer to clk/clock-bindings.txt for generic clock consumer 
properties
 
 Optional properties:
 - phys: phy provider specifier
-- phy-names: shall be device
+- phy-names: shall be usb2-phy
 Refer to phy/phy-bindings.txt for generic phy consumer properties
 
 Example:
-- 
1.8.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


Re: libusbg and vbus detection for UDC driver

2014-04-11 Thread 'Matt Porter'
On Fri, Apr 11, 2014 at 06:20:42PM +0200, Krzysztof Opasiak wrote:
   1. It seems that libusbg from Matt Porter seems the library to
  use.
   Is that correct? I saw patches on the mailing list, but they did
  not
   seem to have made it to: https://github.com/libusbg/libusbg
  
  I think it's the right choice. :) As of last week, all but the
  latest
  two series that have been posted have been merged to master as I
  work
  through some backlog in my copious spare time.
 
 @Matt
 Not all changes has been merged. Remove gadget functionality which I
 have fixed according to your remarks last week is still waiting for
 merge both on the list and in pull request on github.

Yes, I plan to get to that within the day.

Regards,
Matt
--
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: libusbg and vbus detection for UDC driver

2014-04-10 Thread Matt Porter
On Thu, Apr 10, 2014 at 11:24:49PM +0300, Philippe De Swert wrote:
 Hi all,
 
 On first sight it seems that the two things in the subject have
 nothing to do with each other, so I will quickly explain why they do
 (at least for me). So for some time already I have been working on
 usb_moded, which is a small daemon which handles setting up gadget
 drivers, so that a device can offer several different levels of
 functionality (for this it is also capable of setting up network and
 start/stop services over dbus/systemd/upstart when needed)
 
 Now I would like to add support for the new gadgetfs. And there I
 run into two issues.
 
 1. It seems that libusbg from Matt Porter seems the library to use.
 Is that correct? I saw patches on the mailing list, but they did not
 seem to have made it to: https://github.com/libusbg/libusbg

I think it's the right choice. :) As of last week, all but the latest
two series that have been posted have been merged to master as I work
through some backlog in my copious spare time.

 Is this the correct place, and should patches be sent to the mailing
 list here? I also pushed it through a coverity scan already and have
 a nice to do list.

Yes, please post patches here. Bug fixes and new features are very
welcome. On my TODO list is to update docs to explain submitting
patches should occur on this list so we get wider code review. That's
how we've been doing things so far.

 2. I am playing around on a ATSAM5D36-EK and I tried to use that as
 a testing platform. Now the USB udc etc works fine. But there is no
 real way to detect the insertion of a cable. Most udc drivers seem
 to track vbus but this is not exposed. So I added a vbus attribute
 to the base udc, but this only works when a gadget driver is
 actually loaded. So as long as a gadget is active I can see the
 attribute change. (A possible work-around would be a gadget driver
 just to detect vbus, but that is a bit insane)

 What would be the best way to track cable insertion and expose it in
 some way? As in this case I cannot short-cut it by using a
 power_supply class type of device. And just to be sure I would like
 to find a way that would be acceptable upstream.

An extcon driver would be appropriate. It's specifically meant for
this use case. You can then monitor the state of your USB cable
with sysfs or uevents from userspace.

-Matt
--
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 v7 0/4] libusbg: clean up and error handling

2014-04-03 Thread Matt Porter
On Fri, Jan 24, 2014 at 03:30:58PM +0100, Stanislaw Wadas wrote:
 In reference to the message sent by Andrzej Pietrasiewicz
 (about libusbg (formerly libgadget)) I would like to propose
 some changes to libusbg.
 
 Creating directories is now performed after successful memory
 allocation and gadget function creation. Hard coded values are
 replaced with constants. Error handling added to functions that
 operates on strings.

Applied this series, thanks

-Matt
--
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 v5 00/12] libusbg: Cleanup, bug fix and refactoring.

2014-04-03 Thread Matt Porter
On Mon, Jan 27, 2014 at 05:30:12PM +0100, Krzysztof Opasiak wrote:
 Dear Matt,
 
 Please excuse me my passivity after discussuon about libusbg some time ago.
 I had to close some other issues before taking up this one.
 
 Recently I looked into code of libusbg, build it and found some errors
 which are fixed in attached patches. Moreover I have done some clean up
 and minor refactoring.
 
 I have used some defines made by Stanislaw Wadas, so this patch depends
 on: 
 
   http://thread.gmane.org/gmane.linux.usb.general/102014
 
 I hope that you will accept enclosed patched and update the repository.

Applied this series, thanks.

-Matt
--
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 00/26] Bug fixes, feature enhancements and API rework.

2014-04-03 Thread Matt Porter
On Wed, Feb 19, 2014 at 09:25:14PM +0100, Krzysztof Opasiak wrote:
 Hi Matt,
 
 as we have spoken some time ago, I have prepared patches which
 hides definitions of internal library structures.
 
 User shouldn't have access to internal libraries structures which he could
 modify. To avoid this I have provided some public structures which contains
 attributes of gadget/config/function and strings. This allowed to remove
 definitions of gadget/function/config from header file and provide only nice
 typedefs for them. I have also done some API upgrade to allow setting of all
 attributes with only one function call. I have also changed the sizes and 
 order
 of attributes in public structures to be consistent with USB standard and
 libusb implementation. This allow for example to memcpy() from
 libusb_device_descriptor to usbg_gadget_attributes.
 
 Moreover, there were some bugs and missing functionality. I have fixed some
 wrong paths and add missing API functions.
 
 I hope that you will enjoy this code and merge it when it will be possible.
 
 I would like also to remind you that you didn't merge the previous series
 of patches [1]. This series depends on previous one so please update github
 repository.
 
 Footnotes:
 
 1 - http://permalink.gmane.org/gmane.linux.usb.general/102224

This all looks good, applied from your pull request. Thanks.

-Matt
--
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 00/23] libusbg: Add error code propagation and attributes refreshing.

2014-04-03 Thread Matt Porter
On Mon, Mar 10, 2014 at 09:42:31AM +0100, Krzysztof Opasiak wrote:
 Dear Matt,
 
 I have prepared next series of patches. This time I have added error
 code propagation which you have palced at todo list.
 
 In this series I have also removed caching gadget/function/config
 attributes in internal structures. Those attributes may be changed
 by kernel when enabling gadget, so user should get actual attributes
 each time he use usbg_get_*() function.

A nice improvement, thanks.

 
 There was also some bug in matching between binding and function.
 Previously library took only function type and ignore instance name.
 Now while lookup both function type and instance name is considered.
 
 This series depends on my previous series you can easily find them
 on a list or in github pull request. 

Applied the series.

-Matt
--
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 v3 6/6] libusbg: Update examples to new API functionality.

2014-04-03 Thread Matt Porter
On Tue, Mar 18, 2014 at 09:29:06PM +0100, Krzysztof Opasiak wrote:
 Removing gadget/config/function/binding functionality
 has been added to API so add example of how to use it.
 
 Signed-off-by: Krzysztof Opasiak k.opas...@samsung.com
 ---
  examples/Makefile.am |3 +-
  examples/gadget-vid-pid-remove.c |  113 
 ++
  include/usbg/usbg.h  |1 -
  3 files changed, 115 insertions(+), 2 deletions(-)
  create mode 100644 examples/gadget-vid-pid-remove.c
 
 diff --git a/examples/Makefile.am b/examples/Makefile.am
 index f9f9407..9fc235a 100644
 --- a/examples/Makefile.am
 +++ b/examples/Makefile.am
 @@ -1,5 +1,6 @@
 -bin_PROGRAMS = show-gadgets gadget-acm-ecm 
 +bin_PROGRAMS = show-gadgets gadget-acm-ecm gadget-vid-pid-remove
  gadget_acm_ecm_SOURCES = gadget-acm-ecm.c
  show_gadgets_SOURCES = show-gadgets.c
 +gadget_vid_pid_remove_SOURCES = gadget-vid-pid-remove.c
  AM_CPPFLAGS=-I../include/
  AM_LDFLAGS=-L../src/ -lusbg
 diff --git a/examples/gadget-vid-pid-remove.c 
 b/examples/gadget-vid-pid-remove.c
 new file mode 100644
 index 000..e62d231
 --- /dev/null
 +++ b/examples/gadget-vid-pid-remove.c
 @@ -0,0 +1,113 @@
 +/*
 + * Copyright (C) 2014 Samsung Electronics
 + *
 + * Krzysztof Opasiak k.opas...@samsung.com
 + *
 + * 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
 + * the Free Software Foundation; either version 2 of the License, or
 + * (at your option) any later version.
 + *
 + * This program is distributed in the hope that it will be useful,
 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 + * GNU General Public License for more details.
 + */
 +
 +/**
 + * @file gadget-vid-pid-remove.c
 + * @example gadget-vid-pid-remove.c
 + * This is an example of how to find and remove an gadget device with given
 + * Vendor ID and product ID.
 + */
 +
 +#include errno.h
 +#include stdio.h
 +#include usbg/usbg.h
 +
 +#define VENDOR   0x1d6b
 +#define PRODUCT  0x0104
 +
 +int remove_gadget(usbg_gadget *g)
 +{
 + int usbg_ret;
 + char udc[USBG_MAX_STR_LENGTH];
 +
 + /* Check if gadget is enabled */
 + usbg_ret = usbg_get_gadget_udc(g, udc, USBG_MAX_STR_LENGTH);
 + if (usbg_ret != USBG_SUCCESS) {
 + fprintf(stderr, Error on USB get gadget udc\n);
 + fprintf(stderr, Error: %s : %s\n, usbg_error_name(usbg_ret),
 + usbg_strerror(usbg_ret));
 + goto out;
 + }
 +
 + /* If gadget is enable we have to disable it first */
 + if (udc[0] != '\0') {
 + usbg_ret = usbg_disable_gadget(g);
 + if (usbg_ret != USBG_SUCCESS) {
 + fprintf(stderr, Error on USB disable gadget udc\n);
 + fprintf(stderr, Error: %s : %s\n, 
 usbg_error_name(usbg_ret),
 + usbg_strerror(usbg_ret));
 + goto out;
 + }
 + }
 +
 + /* Remove gadget */
 + usbg_ret = usbg_remove_gadget(g, 1 /* Remove also content */);

We're going to need a symbol for the remove content argument.
This use of a magic value of 1 with the unusual comment placement
is ugly. Something like:

usbg_ret = usbg_remove_gadget(g, USBG_RM_CONTENT);

would be more appropriate and meaningful here eliminating the need
for the comment.

Other than that, the API looks fine to me.

-Matt
--
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 v3 5/6] libusbg: Add remove gadget functionality.

2014-04-03 Thread Matt Porter
On Tue, Mar 18, 2014 at 09:29:05PM +0100, Krzysztof Opasiak wrote:
 Add function which allow to remove USB gadget.
 This functions also remove gadget from internal
 library structures what means that after this
 operation all pointers to removed gadget are invalid.
 
 Signed-off-by: Krzysztof Opasiak k.opas...@samsung.com
 ---
  include/usbg/usbg.h |   10 ++
  src/usbg.c  |   54 
 +++
  2 files changed, 64 insertions(+)
 
 diff --git a/include/usbg/usbg.h b/include/usbg/usbg.h
 index f79ace4..cd64eb1 100644
 --- a/include/usbg/usbg.h
 +++ b/include/usbg/usbg.h
 @@ -300,6 +300,16 @@ extern int usbg_remove_config(usbg_config *c, int 
 recursive);
  extern int usbg_remove_function(usbg_function *f, int recursive);
  
  /**
 + * @brief Remove existing USB gadget
 + * @details This function frees also the memory allocated for gadget
 + * @param g Gadget to be removed
 + * @param recursive If different than 0 all configs, functions
 + * and strings will be also removed before removing gadget

So, regarding my comment on the example's use of API. I think it
you should define USBG_RM_RECURSE for use here.

-Matt
--
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 5/5] libusbg: Use config ID and label instead of config name.

2014-04-03 Thread Matt Porter
On Wed, Apr 02, 2014 at 07:42:42PM +0200, Krzysztof Opasiak wrote:
 Naming convention of Config FS should not be exposed
 to user of library. All API functions should use
 configuration ID (configuration number) as unique
 identificator and configuration label as human
 readable description.

100% agree, this looks mostly good but see below...

 
 Signed-off-by: Krzysztof Opasiak k.opas...@samsung.com
 ---
  examples/gadget-acm-ecm.c |4 +-
  examples/show-gadgets.c   |9 +-
  include/usbg/usbg.h   |   35 +---
  src/usbg.c|  200 
 +++--
  4 files changed, 168 insertions(+), 80 deletions(-)
 
 diff --git a/examples/gadget-acm-ecm.c b/examples/gadget-acm-ecm.c
 index 8eb4aeb..7a8b71b 100644
 --- a/examples/gadget-acm-ecm.c
 +++ b/examples/gadget-acm-ecm.c
 @@ -97,8 +97,8 @@ int main(void)
   goto out2;
   }
  
 - usbg_ret = usbg_create_config(g, c.1, NULL /* use defaults */, 
 c_strs,
 - c);
 + usbg_ret = usbg_create_config(g, 1, The only one,
 + NULL /* use defaults */, c_strs, c);

This comment style is unusual, please don't use this going inline with
the arguments.

usbg_ret = usbg_create_config(g, 1, The only one,
  NULL, c_strs, c);

if the NULL argument needs a description it can get something
self-documenting as a preprocessor symbol or put a comment before
this statement to make this example clear. And yes, clearly I didn't
catch this on earlier patches. :)

-Matt
--
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: libusbg - is really fork required?

2014-04-02 Thread Matt Porter
On Wed, Apr 02, 2014 at 03:05:03PM +0200, Krzysztof Opasiak wrote:
 Dear Matt,
 
 I have done a lot of work in libusbg. I have sent you about 80 patches,
 but you did not review nor merge any of them. Current code statistics
 in my git tree looks like:
 
 $ git blame include/usbg/usbg.h | grep Opasiak | wc -l
 601
 
 $ git blame src/usbg.c | grep Opasiak | wc -l
 2032
 
 $ git blame include/usbg/usbg.h | grep Porter | wc -l
 270
 
 $ git blame src/usbg.c | grep Porter | wc -l
 355
 
 Other statistic can be found here:
 
 https://github.com/kopasiak/libusbg
 
 I have forked the github project and created a pull request but you
 also didn��t answer. I have tried to contact you many times using IRC
 but you have not respond for over 3 months. Current situation is hard
 to accept.

Yes, I apologize for the situation, we can fix it now.

First, the work is great. I've caught up on everything but the last
series and will apply it all now. I don't want you to give up on this or
have the idea that I don't value your participation in this..and
frankly, you've taken this a long way already. So, see my comment on the
pull request. I'm prepared to merge all of this except the last series
libusbg: Add remove gadget/config/func/binding functionality as that
still needs some thought as far as changing the API wrt to function
names use. Let's start there and get caught up to the present.

 1) You become more active, review and merge all the patches and
 participate in further development

I'm finally starting to do that now. ;)

 
 2) You will provide me RW access to libusbg github account what
 determines that I will become maintainer/submaintainer of this project
 and merge those patches and continue development

After we do merge the updated pull request I plan to add you as a
co-maintainer with RW access to the github tree. We'll update the docs
to reflect that.

Thanks for your persistence here.

Regards,
Matt
--
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 4/5] libusbg: Replace usage of function name with type and instance.

2014-04-02 Thread Matt Porter
On Wed, Apr 02, 2014 at 03:34:55PM +0200, Krzysztof Opasiak wrote:
  -Original Message-
  From: David Laight [mailto:david.lai...@aculab.com]
  Sent: Wednesday, April 02, 2014 3:09 PM
  To: Krzysztof Opasiak; mpor...@linaro.org; linux-
  u...@vger.kernel.org
  Cc: Andrzej Pietrasiewicz; Karol Lewandowski; Stanislaw Wadas;
  ty317@samsung.com; Marek Szyprowski; Robert Baldyga
  Subject: RE: [PATCH 4/5] libusbg: Replace usage of function name
  with type and instance.
  
  From: Opasiak
   User of library should not use directly function name but
   only type of the function and name of instance. Using this
   will separate user for naming convention on Config FS.
  
  Personally I'd have thought it much better to pass in a
  string name rather than a function number.
  Far less scope for stupid errors.
  
  You probably still want to check that the name passed is one
  of the expected names.
  
 
 In my opinion both approach are considerable. Currently function type is
 represented in library using usbg_function_type enum. This approach also
 has some advantages, you can simply iterate over function types and
 checking the correctness of parameter is far faster and simpler than
 checking if provided string is one of correct function type. Moreover
 operating on enum is easier for API user than operating on string, think
 about copying, passing to function, memory allocation etc. Of course we
 could provide array of function names and users could use cons char*
 pointer but I don't see any advantages in using such pointer instead of
 enum.
 
 Moreover, I'm not a fan of writing few times the same string because
 compiler will not notify you about typos. If you make a typo in enum
 value name (and there is no other enum value with such name) you will
 get compilation error. When you will use acm string and make a typo
 amc you won't get any errors or even warnings.

This was the whole point of having the enumed function types in the
first place, allow the compiler to help us find errors. So yes, I agree,
don't go down the path of passing in a string.

There's other subtle string naming requirements in the gadget configfs
API that ultimately we should hide. Like the requirement on the gadget
instance string or the syntax for configuration instances, for example.

-Matt
--
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 1/6] i2c: bcm-kona: register with subsys_initcall

2014-02-05 Thread Matt Porter
On Wed, Feb 05, 2014 at 10:08:18AM +0100, Wolfram Sang wrote:
 On Tue, Feb 04, 2014 at 07:19:07AM -0500, Matt Porter wrote:
 
  Voltage regulators are needed very early due to deferred probe
  being incompatible with built-in USB gadget drivers.
 
 What does it need to fix those instead?

[added Alan/Felipe for more insight]

Discussion on that topic came about from this submission:
http://www.spinics.net/lists/linux-usb/msg94217.html

End of it is:
http://www.spinics.net/lists/linux-usb/msg94731.html

We can either add to the many drivers that already do subsys_initcall()
for similar reasons...or I can drop this from the series and add gadget
probe ordering to my TODO list.

In short, it can't be a late_initcall() hack like the original post and
really could be solved by converting to a real bus (and letting
deferred probe do its job)..but Alan voiced concerns about that.

-Matt
--
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 1/6] i2c: bcm-kona: register with subsys_initcall

2014-02-05 Thread Matt Porter
On Wed, Feb 05, 2014 at 10:30:29AM -0500, Alan Stern wrote:
 On Wed, 5 Feb 2014, Matt Porter wrote:
 
  On Wed, Feb 05, 2014 at 10:08:18AM +0100, Wolfram Sang wrote:
   On Tue, Feb 04, 2014 at 07:19:07AM -0500, Matt Porter wrote:
   
Voltage regulators are needed very early due to deferred probe
being incompatible with built-in USB gadget drivers.
   
   What does it need to fix those instead?
  
  [added Alan/Felipe for more insight]
  
  Discussion on that topic came about from this submission:
  http://www.spinics.net/lists/linux-usb/msg94217.html
  
  End of it is:
  http://www.spinics.net/lists/linux-usb/msg94731.html
  
  We can either add to the many drivers that already do subsys_initcall()
  for similar reasons...or I can drop this from the series and add gadget
  probe ordering to my TODO list.
  
  In short, it can't be a late_initcall() hack like the original post and
  really could be solved by converting to a real bus (and letting
  deferred probe do its job)..but Alan voiced concerns about that.
 
 Don't worry too much about what I said.  If adding a gadget bus will 
 solve the problem in an appropriate way, and if nobody else objects 
 (particularly Felipe, who is on vacation now), then go for it.

Ok, I'll take a look at what can be done and restart the conversation
when Felipe returns.

Wolfram: given this, as I mentioned, I'll simply drop this patch from
the series and work around it for now. This will probably make Lee and
Mark happy to not see subsys_initcall() in the MFD/regulator drivers as
well.

-Matt
--
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: gadget: s3c-hsotg: fix build on x86 and other architectures

2014-02-03 Thread Matt Porter
The readsl and writesl I/O accessors are only defined on some
architectures. The driver currently depends on CONFIG_ARM because
the build breaks on x86, in particular. Switch to use of ioread32_rep
and iowrite32_rep to fix build on all architectures and remove the
CONFIG_ARM dependency.

Also update printk formatting to handle a long long dma_addr_t to avoid
warnings on !32-bit architectures.

Signed-off-by: Matt Porter mpor...@linaro.org
---
 drivers/usb/gadget/Kconfig |  1 -
 drivers/usb/gadget/s3c-hsotg.c | 12 ++--
 2 files changed, 6 insertions(+), 7 deletions(-)

diff --git a/drivers/usb/gadget/Kconfig b/drivers/usb/gadget/Kconfig
index 8154165..782f43a 100644
--- a/drivers/usb/gadget/Kconfig
+++ b/drivers/usb/gadget/Kconfig
@@ -301,7 +301,6 @@ config USB_PXA27X
   gadget drivers to also be dynamically linked.
 
 config USB_S3C_HSOTG
-   depends on ARM
tristate Designware/S3C HS/OtG USB Device controller
help
  The Designware USB2.0 high-speed gadget controller
diff --git a/drivers/usb/gadget/s3c-hsotg.c b/drivers/usb/gadget/s3c-hsotg.c
index 1172eae..0449b76 100644
--- a/drivers/usb/gadget/s3c-hsotg.c
+++ b/drivers/usb/gadget/s3c-hsotg.c
@@ -617,7 +617,7 @@ static int s3c_hsotg_write_fifo(struct s3c_hsotg *hsotg,
to_write = DIV_ROUND_UP(to_write, 4);
data = hs_req-req.buf + buf_pos;
 
-   writesl(hsotg-regs + EPFIFO(hs_ep-index), data, to_write);
+   iowrite32_rep(hsotg-regs + EPFIFO(hs_ep-index), data, to_write);
 
return (to_write = can_write) ? -ENOSPC : 0;
 }
@@ -720,8 +720,8 @@ static void s3c_hsotg_start_req(struct s3c_hsotg *hsotg,
ureq-length, ureq-actual);
if (0)
dev_dbg(hsotg-dev,
-   REQ buf %p len %d dma 0x%08x noi=%d zp=%d snok=%d\n,
-   ureq-buf, length, ureq-dma,
+   REQ buf %p len %d dma 0x%08llx noi=%d zp=%d snok=%d\n,
+   ureq-buf, length, (unsigned long long)ureq-dma,
ureq-no_interrupt, ureq-zero, ureq-short_not_ok);
 
maxreq = get_ep_limit(hs_ep);
@@ -789,8 +789,8 @@ static void s3c_hsotg_start_req(struct s3c_hsotg *hsotg,
dma_reg = dir_in ? DIEPDMA(index) : DOEPDMA(index);
writel(ureq-dma, hsotg-regs + dma_reg);
 
-   dev_dbg(hsotg-dev, %s: 0x%08x = 0x%08x\n,
-   __func__, ureq-dma, dma_reg);
+   dev_dbg(hsotg-dev, %s: 0x%08llx = 0x%08x\n,
+   __func__, (unsigned long long)ureq-dma, dma_reg);
}
 
ctrl |= DxEPCTL_EPEna;  /* ensure ep enabled */
@@ -1488,7 +1488,7 @@ static void s3c_hsotg_rx_data(struct s3c_hsotg *hsotg, 
int ep_idx, int size)
 * note, we might over-write the buffer end by 3 bytes depending on
 * alignment of the data.
 */
-   readsl(fifo, hs_req-req.buf + read_ptr, to_read);
+   ioread32_rep(fifo, hs_req-req.buf + read_ptr, to_read);
 }
 
 /**
-- 
1.8.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


Re: [PATCH v5 1/4] libusbg: Replace array lengths with defines

2014-01-22 Thread Matt Porter
On Wed, Jan 22, 2014 at 02:56:20PM +0100, Stanislaw Wadas wrote:
 Replace hard coded value of 256 by two constant
 defines, MAX_LENGTH and MAX_PATH_LENGTH
 
 Signed-off-by: Stanislaw Wadas s.wa...@samsung.com
 ---
  include/usbg/usbg.h |   27 +++
  src/usbg.c  |   46 +++---
  2 files changed, 38 insertions(+), 35 deletions(-)
 
 diff --git a/include/usbg/usbg.h b/include/usbg/usbg.h
 index 5f00068..abb9bc2 100644
 --- a/include/usbg/usbg.h
 +++ b/include/usbg/usbg.h
 @@ -33,13 +33,16 @@
  #define DEFAULT_UDC  NULL
  #define LANG_US_ENG  0x0409
  
 +#define MAX_LENGTH 256

This should be MAX_STR_LENGTH to clarify the use as mentioned
before.

 +#define MAX_PATH_LENGTH 256
 +
  /**
   * @struct state
   * @brief State of the gadget devices in the system
   */
  struct state
  {
 - char path[256];
 + char path[MAX_PATH_LENGTH];
  
   TAILQ_HEAD(ghead, gadget) gadgets;
  };
 @@ -51,8 +54,8 @@ struct state
  struct gadget
  {
   char name[40];
 - char path[256];
 - char udc[256];
 + char path[MAX_PATH_LENGTH];
 + char udc[MAX_LENGTH];

and MAX_STR_LENGTH here and throughout

   int dclass;
   int dsubclass;
   int dproto;
 @@ -61,9 +64,9 @@ struct gadget
   int bcdusb;
   int product;
   int vendor;
 - char str_ser[256];
 - char str_mnf[256];
 - char str_prd[256];
 + char str_ser[MAX_LENGTH];
 + char str_mnf[MAX_LENGTH];
 + char str_prd[MAX_LENGTH];
   TAILQ_ENTRY(gadget) gnode;
   TAILQ_HEAD(chead, config) configs;
   TAILQ_HEAD(fhead, function) functions;
 @@ -81,10 +84,10 @@ struct config
   struct gadget *parent;
  
   char name[40];
 - char path[256];
 + char path[MAX_PATH_LENGTH];
   int maxpower;
   int bmattrs;
 - char str_cfg[256];
 + char str_cfg[MAX_LENGTH];
  };
  
  /**
 @@ -136,7 +139,7 @@ struct serial_attrs {
  struct net_attrs {
   struct ether_addr dev_addr;
   struct ether_addr host_addr;
 - char ifname[256];
 + char ifname[MAX_LENGTH];
   int qmult;
  };
  
 @@ -145,7 +148,7 @@ struct net_attrs {
   * @brief Attributes for the phonet USB function
   */
  struct phonet_attrs {
 - char ifname[256];
 + char ifname[MAX_LENGTH];
  };
  
  /**
 @@ -168,7 +171,7 @@ struct function
   struct gadget *parent;
  
   char name[40];
 - char path[256];
 + char path[MAX_PATH_LENGTH];
  
   enum function_type type;
   union attrs attr;
 @@ -187,7 +190,7 @@ struct binding
   struct function *target;
  
   char name[40];
 - char path[256];
 + char path[MAX_PATH_LENGTH];
  };
  
  /* Library init and cleanup */
 diff --git a/src/usbg.c b/src/usbg.c
 index 20447db..cb7f172 100644
 --- a/src/usbg.c
 +++ b/src/usbg.c
 @@ -82,7 +82,7 @@ static int file_select(const struct dirent *dent)
  
  static char *usbg_read_buf(char *path, char *name, char *file, char *buf)
  {
 - char p[256];
 + char p[MAX_LENGTH];
   FILE *fp;
   char *ret = NULL;
  
 @@ -92,7 +92,7 @@ static char *usbg_read_buf(char *path, char *name, char 
 *file, char *buf)
   if (!fp)
   goto out;
  
 - ret = fgets(buf, 256, fp);
 + ret = fgets(buf, MAX_LENGTH, fp);
  
   fclose(fp);
  
 @@ -102,7 +102,7 @@ out:
  
  static int usbg_read_int(char *path, char *name, char *file, int base)
  {
 - char buf[256];
 + char buf[MAX_LENGTH];
  
   if (usbg_read_buf(path, name, file, buf))
   return strtol(buf, NULL, base);
 @@ -125,7 +125,7 @@ static void usbg_read_string(char *path, char *name, char 
 *file, char *buf)
  
  static void usbg_write_buf(char *path, char *name, char *file, char *buf)
  {
 - char p[256];
 + char p[MAX_LENGTH];
   FILE *fp;
  
   sprintf(p, %s/%s/%s, path, name, file);
 @@ -143,7 +143,7 @@ static void usbg_write_buf(char *path, char *name, char 
 *file, char *buf)
  
  static void usbg_write_int(char *path, char *name, char *file, int value, 
 char *str)
  {
 - char buf[256];
 + char buf[MAX_LENGTH];
  
   sprintf(buf, str, value);
   usbg_write_buf(path, name, file, buf);
 @@ -196,7 +196,7 @@ static int usbg_parse_functions(char *path, struct gadget 
 *g)
   struct function *f;
   int i, n;
   struct dirent **dent;
 - char fpath[256];
 + char fpath[MAX_PATH_LENGTH];
  
   sprintf(fpath, %s/%s/functions, path, g-name);
  
 @@ -227,7 +227,7 @@ static void usbg_parse_config_bindings(struct config *c)
  {
   int i, n;
   struct dirent **dent;
 - char bpath[256];
 + char bpath[MAX_PATH_LENGTH];
   struct gadget *g = c-parent;
   struct binding *b;
   struct function *f;
 @@ -240,12 +240,12 @@ static void usbg_parse_config_bindings(struct config *c)
   for (i=0; i  n; i++) {
   TAILQ_FOREACH(f, g-functions, fnode) {
   int n;
 - char contents[256];
 -

libusbg 0.1.0 (formerly libgadget)

2014-01-21 Thread Matt Porter
libusbg 0.1.0 is released. libusbg is a library that provides a C API to
the kernel USB gadget configfs API. It simplifies creation and
management of USB gadget devices from C applications.

Get it at:

git://github.com/libusbg/libusbg.git

API docs at:

http://libusbg.github.com/group__libusbg.html
http://libusbg.github.com/examples.html

Changes since libgadget 0.0.1:

- libusbg now has a new name to avoid conflicts
  with an existing libgadget libary
- use the standard /sys/kernel/config mount path
  in examples
- a new project home on github

Going forward we have a couple contributors with clean up and bug
fixes that will be rolled into libusbg once comments are addressed.
Support for FunctionFS (merged for 3.14) will also be added.

-Matt
--
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 v4 0/2] libusbg: clean up and error handling

2014-01-21 Thread Matt Porter
On Thu, Nov 07, 2013 at 12:55:04PM -0500, Alan Ott wrote:
 On 11/06/2013 08:04 AM, Stanislaw Wadas wrote:
 In reference to the message sent by Andrzej Pietrasiewicz
 (about libusbg (formerly libgadget)) I would like to propose
 some changes to libusbg.
 
 Creating directories is now performed after successful memory
 allocation and gadget function creation. Hard coded values are
 replaced with constants. Error handling added to functions that
 operates on strings.
 
 Changes since v3:
  - changes are now in four separate files
  - fixed code indentation
 
 Changes since v2:
  - fixed code indentation
  - removed unused variable ret
 
 Changes since v1:
  - fixed typos in MAX_LENGTH throughout
 
 Stanislaw Wadas (2):
libusbg: Moved mkdir functions, added MAX_LENGTH  MAX_PATH_LENGTH
libusbg: added fputs()/fgets() error handling
 
 
 It's preferred to use present tense in commit messages:
 Move mkdir functions and add 
 Add puts()/gets() error handling

Yes, thank you ;)

Stanislaw: can you incorporate Alan's comment please? Except for the
remaining comment on 2/2 and changing to use present tense in the commit
messages, I will be able to merge this series.

Thanks,
Matt
--
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 v4 1/4] libusbg: Path length replaced with MAX_LENGTH MAX_PATH_LENGTH

2014-01-21 Thread Matt Porter
On Wed, Nov 06, 2013 at 02:04:40PM +0100, Stanislaw Wadas wrote:
 256 hard coded value has been replaced by two defined
 constants MAX_LENGTH and MAX_PATH_LENGTH

In both the patch summary and commit message, please remember to use
present tense as Alan pointed out. e.g.:


Subject: [PATCH v4 1/4 libusbg: replace array lengths with defines

Replace hard coded value of 256 by two constant defines,
MAX_PATH_LENGTH and MAX_STR_LENGTH.


 
 Signed-off-by: Stanislaw Wadas s.wa...@samsung.com
 ---
 Changes since v1:
 - fixed typos in MAX_LENGTH throughout
 
  include/gadget/gadget.h |   27 +++
  src/gadget.c|   46 +++---
  2 files changed, 38 insertions(+), 35 deletions(-)
 
 diff --git a/include/gadget/gadget.h b/include/gadget/gadget.h
 index 6a32c39..9bca97e 100644
 --- a/include/gadget/gadget.h
 +++ b/include/gadget/gadget.h
 @@ -33,13 +33,16 @@
  #define DEFAULT_UDC  NULL
  #define LANG_US_ENG  0x0409
  
 +#define MAX_LENGTH 256
 +#define MAX_PATH_LENGTH 256
 +
  /**
   * @struct state
   * @brief State of the gadget devices in the system
   */
  struct state
  {
 - char path[256];
 + char path[MAX_PATH_LENGTH];
  
   TAILQ_HEAD(ghead, gadget) gadgets;
  };
 @@ -51,8 +54,8 @@ struct state
  struct gadget
  {
   char name[40];
 - char path[256];
 - char udc[256];
 + char path[MAX_PATH_LENGTH];
 + char udc[MAX_LENGTH];

As David is suggesting, MAX_LENGTH needs a better name. I'm fine with
MAX_PATH_LENGTH. s/MAX_LENGTH/MAX_STR_LENGTH/ would be much better.

-Matt

--
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 v4 0/2] libusbg: clean up and error handling

2014-01-21 Thread Matt Porter
Also, there's something wrong with how you are sending your series.
This cover letter is broken and showing only a 2 part series but you've
posted a 4 part series. Please fix this for v5.

-Matt

On Wed, Nov 06, 2013 at 02:04:39PM +0100, Stanislaw Wadas wrote:
 In reference to the message sent by Andrzej Pietrasiewicz
 (about libusbg (formerly libgadget)) I would like to propose
 some changes to libusbg.
 
 Creating directories is now performed after successful memory
 allocation and gadget function creation. Hard coded values are
 replaced with constants. Error handling added to functions that
 operates on strings.
 
 Changes since v3:
 - changes are now in four separate files
   - fixed code indentation
 
 Changes since v2:
   - fixed code indentation 
   - removed unused variable ret
 
 Changes since v1:
   - fixed typos in MAX_LENGTH throughout
 
 Stanislaw Wadas (2):
   libusbg: Moved mkdir functions, added MAX_LENGTH  MAX_PATH_LENGTH
   libusbg: added fputs()/fgets() error handling
 
  include/gadget/gadget.h |   27 --
  src/gadget.c|   95 
 ++-
  2 files changed, 67 insertions(+), 55 deletions(-)
 
 -- 
 1.7.9.5
 
--
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 00/12] libusbg: Cleanup, bug fix and refactoring.

2014-01-21 Thread Matt Porter
On Thu, Jan 02, 2014 at 05:13:30PM +0100, Krzysztof Opasiak wrote:
 Dear Matt,
 
 Please excuse me my passivity after discussuon about libusbg some time ago.
 I had to close some other issues before taking up this one.
 
 Recently I looked into code of libusbg, build it and found some errors
 which are fixed in attached patches. Moreover I have done some clean up
 and minor refactoring.
 
 I hope that you will accept enclosed patched and update the repository.

Hi Krzysztof,

Thanks, these all look pretty good. A few things:

1) This v3 series didn't get marked as [PATCH v3 ...] so it was a bit
confusing when I was applying to test.

2) In the future, please mention any dependencies in your cover letter.
In this case, you have some dependencies on Stanislaw's series:
http://www.spinics.net/lists/linux-usb/msg96859.html

There's some open comments on that series atm that I need addressed.

3) The series will need to be rebased on the current libusbg. It was
necessary to do a flag day api change early on to get rid of the
libgadget-induced naming. It should be an easy rebase on top of the
tip of libusbg, now at git://github.com/libusbg/libusbg.git

Thanks,
Matt

 Changes since v2:
   - replace // comments with /* */
   - add missing parenthesis in commit message
   - fix minor spelling mistakes in commit messages
 
 Changes since v1:
 - replace memcpy with direct structure assignment
 - Change goto lables on more meaningful in example
 - Remove additional check in gadget_read_string
 
 
 Krzysztof Opasiak (12):
   libusbg: Surround header with include guards.
   libusbg: Add missing return statement in non-void functions.
   libusbg: Fix gadget-acm-ecm example to cleanup at exit.
   libusbg: Move directory creation before writing attributes.
   libusbg: Fix memory leak when unable to create directory.
   libusbg: Add error handling to gadget_read_string().
   libusbg: Add missing config attrs parsing while new config creation.
   libusbg: Separate parsing gadget attributes and strings.
   libusbg: Initialize gadget attributes and strings while gadget
 creation.
   libusbg: Move symlink creation after memory allocation.
   libusbg: Replace memcpy with structure assignment.
   libusbg: Replace directory names with defines.
 
  examples/gadget-acm-ecm.c |   20 -
  include/gadget/gadget.h   |4 ++
  src/gadget.c  |  110 
 +
  3 files changed, 86 insertions(+), 48 deletions(-)
 
 -- 
 1.7.9.5
 
--
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 01/12] libusbg: Surround header with include guards.

2014-01-21 Thread Matt Porter
On Thu, Jan 02, 2014 at 05:13:31PM +0100, Krzysztof Opasiak wrote:
 Surround header with include guards to protect against
 multiple inclusion.
 
 Signed-off-by: Krzysztof Opasiak k.opas...@samsung.com
 ---
  include/gadget/gadget.h |4 
  1 file changed, 4 insertions(+)
 
 diff --git a/include/gadget/gadget.h b/include/gadget/gadget.h
 index 9bca97e..f3c08e9 100644
 --- a/include/gadget/gadget.h
 +++ b/include/gadget/gadget.h
 @@ -14,6 +14,9 @@
   * Lesser General Public License for more details.
   */
  
 +#ifndef __GADGET_H__
 +#define __GADGET_H__

Please rename these to __USBG_H__ due to the library rename.

 +
  #include dirent.h
  #include sys/queue.h
  #include netinet/ether.h
 @@ -438,3 +441,4 @@ extern void gadget_set_net_qmult(struct function *f, int 
 qmult);
  /**
   * @}
   */
 +#endif //__GADGET_H__
 -- 
 1.7.9.5
 
--
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 v8 3/9] usb: gadget: s3c-hsotg: enable build for other platforms

2013-12-23 Thread Matt Porter
On Mon, Dec 23, 2013 at 05:30:41PM +0100, Tomasz Figa wrote:
 On Monday 23 of December 2013 10:25:57 Felipe Balbi wrote:
  On Thu, Dec 19, 2013 at 09:23:04AM -0500, Matt Porter wrote:
   Remove unused Samsung-specific machine include and Kconfig
   dependency on S3C.
   
   Signed-off-by: Matt Porter mpor...@linaro.org
   Reviewed-by: Markus Mayer markus.ma...@linaro.org
   Reviewed-by: Tim Kryger tim.kry...@linaro.org
   ---
drivers/usb/gadget/Kconfig | 7 +++
drivers/usb/gadget/s3c-hsotg.c | 2 --
2 files changed, 3 insertions(+), 6 deletions(-)
   
   diff --git a/drivers/usb/gadget/Kconfig b/drivers/usb/gadget/Kconfig
   index a91e642..181e760 100644
   --- a/drivers/usb/gadget/Kconfig
   +++ b/drivers/usb/gadget/Kconfig
   @@ -294,11 +294,10 @@ config USB_PXA27X
gadget drivers to also be dynamically linked.

config USB_S3C_HSOTG
   - tristate S3C HS/OtG USB Device controller
   - depends on S3C_DEV_USB_HSOTG
   + tristate Designware/S3C HS/OtG USB Device controller
  
  causes build failure in x86. Sorry dropping from my queue.
 
 Maybe depends on ARM would be a good enough stepping stone?

Yes, we could then move from readsl/writesl to ioread_read/io_write_rep
next time around as that fixes the portability issue.

Felipe, since depending on ARM is a trivial fix for this, can you take
an updated version at this point?

-Matt
--
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 v9 7/9] phy: add Broadcom Kona USB2 PHY DT binding

2013-12-23 Thread Matt Porter
Add a binding that describes the Broadcom Kona USB2 PHY found
on the BCM281xx family of SoCs.

Signed-off-by: Matt Porter mpor...@linaro.org
Acked-by: Kishon Vijay Abraham I kis...@ti.com
---
 Documentation/devicetree/bindings/phy/bcm-phy.txt | 15 +++
 1 file changed, 15 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/phy/bcm-phy.txt

diff --git a/Documentation/devicetree/bindings/phy/bcm-phy.txt 
b/Documentation/devicetree/bindings/phy/bcm-phy.txt
new file mode 100644
index 000..3dc8b3d
--- /dev/null
+++ b/Documentation/devicetree/bindings/phy/bcm-phy.txt
@@ -0,0 +1,15 @@
+BROADCOM KONA USB2 PHY
+
+Required properties:
+ - compatible: brcm,kona-usb2-phy
+ - reg: offset and length of the PHY registers
+ - #phy-cells: must be 0
+Refer to phy/phy-bindings.txt for the generic PHY binding properties
+
+Example:
+
+   usbphy: usb-phy@3f13 {
+   compatible = brcm,kona-usb2-phy;
+   reg = 0x3f13 0x28;
+   #phy-cells = 0;
+   };
-- 
1.8.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 v9 9/9] ARM: dts: add usb udc support to bcm281xx

2013-12-23 Thread Matt Porter
Adds USB OTG/PHY and clock support to BCM281xx and enables
UDC support on the bcm11351-brt and bcm28155-ap boards.

Signed-off-by: Matt Porter mpor...@linaro.org
Reviewed-by: Markus Mayer markus.ma...@linaro.org
Reviewed-by: Tim Kryger tim.kry...@linaro.org
---
 arch/arm/boot/dts/bcm11351-brt.dts |  6 ++
 arch/arm/boot/dts/bcm11351.dtsi| 18 ++
 arch/arm/boot/dts/bcm28155-ap.dts  |  8 
 3 files changed, 32 insertions(+)

diff --git a/arch/arm/boot/dts/bcm11351-brt.dts 
b/arch/arm/boot/dts/bcm11351-brt.dts
index 23cd16d..396b704 100644
--- a/arch/arm/boot/dts/bcm11351-brt.dts
+++ b/arch/arm/boot/dts/bcm11351-brt.dts
@@ -44,5 +44,11 @@
status = okay;
};
 
+   usbotg: usb@3f12 {
+   status = okay;
+   };
 
+   usbphy: usb-phy@3f13 {
+   status = okay;
+   };
 };
diff --git a/arch/arm/boot/dts/bcm11351.dtsi b/arch/arm/boot/dts/bcm11351.dtsi
index 1246885..0fbb455 100644
--- a/arch/arm/boot/dts/bcm11351.dtsi
+++ b/arch/arm/boot/dts/bcm11351.dtsi
@@ -243,4 +243,22 @@
#clock-cells = 0;
};
};
+
+   usbotg: usb@3f12 {
+   compatible = snps,dwc2;
+   reg = 0x3f12 0x1;
+   interrupts = GIC_SPI 47 IRQ_TYPE_LEVEL_HIGH;
+   clocks = usb_otg_ahb_clk;
+   clock-names = otg;
+   phys = usbphy;
+   phy-names = usb2-phy;
+   status = disabled;
+   };
+
+   usbphy: usb-phy@3f13 {
+   compatible = brcm,kona-usb2-phy;
+   reg = 0x3f13 0x28;
+   #phy-cells = 0;
+   status = disabled;
+   };
 };
diff --git a/arch/arm/boot/dts/bcm28155-ap.dts 
b/arch/arm/boot/dts/bcm28155-ap.dts
index 08e47c2..a3bc436 100644
--- a/arch/arm/boot/dts/bcm28155-ap.dts
+++ b/arch/arm/boot/dts/bcm28155-ap.dts
@@ -43,4 +43,12 @@
cd-gpios = gpio 14 0;
status = okay;
};
+
+   usbotg: usb@3f12 {
+   status = okay;
+   };
+
+   usbphy: usb-phy@3f13 {
+   status = okay;
+   };
 };
-- 
1.8.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 v9 2/9] staging: dwc2: update DT binding to add generic clock/phy properties

2013-12-23 Thread Matt Porter
dwc2/s3c-hsotg require a single clock to be specified and optionally
a generic phy. On the s3c-hsotg driver old style USB phy support is
present as a fallback so the generic phy properties are optional.

Signed-off-by: Matt Porter mpor...@linaro.org
Acked-by: Kishon Vijay Abraham I kis...@ti.com
---
 Documentation/devicetree/bindings/staging/dwc2.txt | 12 
 1 file changed, 12 insertions(+)

diff --git a/Documentation/devicetree/bindings/staging/dwc2.txt 
b/Documentation/devicetree/bindings/staging/dwc2.txt
index 1a1b7cf..a1753ed 100644
--- a/Documentation/devicetree/bindings/staging/dwc2.txt
+++ b/Documentation/devicetree/bindings/staging/dwc2.txt
@@ -5,6 +5,14 @@ Required properties:
 - compatible : snps,dwc2
 - reg : Should contain 1 register range (address and length)
 - interrupts : Should contain 1 interrupt
+- clocks: clock provider specifier
+- clock-names: shall be otg
+Refer to clk/clock-bindings.txt for generic clock consumer properties
+
+Optional properties:
+- phys: phy provider specifier
+- phy-names: shall be device
+Refer to phy/phy-bindings.txt for generic phy consumer properties
 
 Example:
 
@@ -12,4 +20,8 @@ Example:
 compatible = ralink,rt3050-usb, snps,dwc2;
 reg = 0x101c 4;
 interrupts = 18;
+   clocks = usb_otg_ahb_clk;
+   clock-names = otg;
+   phys = usbphy;
+   phy-names = usb2-phy;
 };
-- 
1.8.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 v9 5/9] usb: gadget: s3c-hsotg: enable generic phy support

2013-12-23 Thread Matt Porter
Adds support for the generic PHY subsystem. Generic PHY
support is probed and then the driver falls back to checking
for an old style USB PHY and pdata if not found.

Signed-off-by: Matt Porter mpor...@linaro.org
---
 drivers/usb/gadget/s3c-hsotg.c | 55 ++
 1 file changed, 39 insertions(+), 16 deletions(-)

diff --git a/drivers/usb/gadget/s3c-hsotg.c b/drivers/usb/gadget/s3c-hsotg.c
index cbfbf41..8f9bcdb 100644
--- a/drivers/usb/gadget/s3c-hsotg.c
+++ b/drivers/usb/gadget/s3c-hsotg.c
@@ -30,6 +30,8 @@
 #include linux/clk.h
 #include linux/regulator/consumer.h
 #include linux/of_platform.h
+#include linux/phy/phy.h
+#include linux/usb/phy.h
 
 #include linux/usb/ch9.h
 #include linux/usb/gadget.h
@@ -138,6 +140,7 @@ struct s3c_hsotg_ep {
  * @dev: The parent device supplied to the probe function
  * @driver: USB gadget driver
  * @phy: The otg phy transceiver structure for phy control.
+ * @uphy: The otg phy transceiver structure for old USB phy control.
  * @plat: The platform specific configuration data. This can be removed once
  * all SoCs support usb transceiver.
  * @regs: The memory area mapped for accessing registers.
@@ -159,7 +162,8 @@ struct s3c_hsotg_ep {
 struct s3c_hsotg {
struct device*dev;
struct usb_gadget_driver *driver;
-   struct usb_phy  *phy;
+   struct phy   *phy;
+   struct usb_phy   *uphy;
struct s3c_hsotg_plat*plat;
 
spinlock_t  lock;
@@ -2901,8 +2905,11 @@ static void s3c_hsotg_phy_enable(struct s3c_hsotg *hsotg)
 
dev_dbg(hsotg-dev, pdev 0x%p\n, pdev);
 
-   if (hsotg-phy)
-   usb_phy_init(hsotg-phy);
+   if (hsotg-phy) {
+   phy_init(hsotg-phy);
+   phy_power_on(hsotg-phy);
+   } else if (hsotg-uphy)
+   usb_phy_init(hsotg-uphy);
else if (hsotg-plat-phy_init)
hsotg-plat-phy_init(pdev, hsotg-plat-phy_type);
 }
@@ -2918,8 +2925,11 @@ static void s3c_hsotg_phy_disable(struct s3c_hsotg 
*hsotg)
 {
struct platform_device *pdev = to_platform_device(hsotg-dev);
 
-   if (hsotg-phy)
-   usb_phy_shutdown(hsotg-phy);
+   if (hsotg-phy) {
+   phy_power_off(hsotg-phy);
+   phy_exit(hsotg-phy);
+   } else if (hsotg-uphy)
+   usb_phy_shutdown(hsotg-uphy);
else if (hsotg-plat-phy_exit)
hsotg-plat-phy_exit(pdev, hsotg-plat-phy_type);
 }
@@ -3526,7 +3536,8 @@ static void s3c_hsotg_delete_debug(struct s3c_hsotg 
*hsotg)
 static int s3c_hsotg_probe(struct platform_device *pdev)
 {
struct s3c_hsotg_plat *plat = dev_get_platdata(pdev-dev);
-   struct usb_phy *phy;
+   struct phy *phy;
+   struct usb_phy *uphy;
struct device *dev = pdev-dev;
struct s3c_hsotg_ep *eps;
struct s3c_hsotg *hsotg;
@@ -3541,19 +3552,26 @@ static int s3c_hsotg_probe(struct platform_device *pdev)
return -ENOMEM;
}
 
-   phy = devm_usb_get_phy(dev, USB_PHY_TYPE_USB2);
+   /*
+* Attempt to find a generic PHY, then look for an old style
+* USB PHY, finally fall back to pdata
+*/
+   phy = devm_phy_get(pdev-dev, usb2-phy);
if (IS_ERR(phy)) {
-   /* Fallback for pdata */
-   plat = dev_get_platdata(pdev-dev);
-   if (!plat) {
-   dev_err(pdev-dev, no platform data or transceiver 
defined\n);
-   return -EPROBE_DEFER;
-   } else {
+   uphy = devm_usb_get_phy(dev, USB_PHY_TYPE_USB2);
+   if (IS_ERR(uphy)) {
+   /* Fallback for pdata */
+   plat = dev_get_platdata(pdev-dev);
+   if (!plat) {
+   dev_err(pdev-dev,
+   no platform data or transceiver defined\n);
+   return -EPROBE_DEFER;
+   }
hsotg-plat = plat;
-   }
-   } else {
+   } else
+   hsotg-uphy = uphy;
+   } else
hsotg-phy = phy;
-   }
 
hsotg-dev = dev;
 
@@ -3620,6 +3638,9 @@ static int s3c_hsotg_probe(struct platform_device *pdev)
goto err_supplies;
}
 
+   if (hsotg-phy)
+   phy_init(hsotg-phy);
+
/* usb phy enable */
s3c_hsotg_phy_enable(hsotg);
 
@@ -3713,6 +3734,8 @@ static int s3c_hsotg_remove(struct platform_device *pdev)
}
 
s3c_hsotg_phy_disable(hsotg);
+   if (hsotg-phy)
+   phy_exit(hsotg-phy);
clk_disable_unprepare(hsotg-clk);
 
return 0;
-- 
1.8.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 v9 1/9] phy: add phy_get_bus_width()/phy_set_bus_width() calls

2013-12-23 Thread Matt Porter
This adds a pair of APIs that allows the generic PHY subsystem to
provide information on the PHY bus width. The PHY provider driver may
use phy_set_bus_width() to set the bus width that the PHY supports.
The controller driver may then use phy_get_bus_width() to fetch the
PHY bus width in order to properly configure the controller.

Signed-off-by: Matt Porter mpor...@linaro.org
Acked-by: Kishon Vijay Abraham I kis...@ti.com
---
 include/linux/phy/phy.h | 28 
 1 file changed, 28 insertions(+)

diff --git a/include/linux/phy/phy.h b/include/linux/phy/phy.h
index 6d72269..e273e5a 100644
--- a/include/linux/phy/phy.h
+++ b/include/linux/phy/phy.h
@@ -38,6 +38,14 @@ struct phy_ops {
 };
 
 /**
+ * struct phy_attrs - represents phy attributes
+ * @bus_width: Data path width implemented by PHY
+ */
+struct phy_attrs {
+   u32 bus_width;
+};
+
+/**
  * struct phy - represents the phy device
  * @dev: phy device
  * @id: id of the phy device
@@ -46,6 +54,7 @@ struct phy_ops {
  * @mutex: mutex to protect phy_ops
  * @init_count: used to protect when the PHY is used by multiple consumers
  * @power_count: used to protect when the PHY is used by multiple consumers
+ * @phy_attrs: used to specify PHY specific attributes
  */
 struct phy {
struct device   dev;
@@ -55,6 +64,7 @@ struct phy {
struct mutexmutex;
int init_count;
int power_count;
+   struct phy_attrsattrs;
 };
 
 /**
@@ -127,6 +137,14 @@ int phy_init(struct phy *phy);
 int phy_exit(struct phy *phy);
 int phy_power_on(struct phy *phy);
 int phy_power_off(struct phy *phy);
+static inline int phy_get_bus_width(struct phy *phy)
+{
+   return phy-attrs.bus_width;
+}
+static inline void phy_set_bus_width(struct phy *phy, int bus_width)
+{
+   phy-attrs.bus_width = bus_width;
+}
 struct phy *phy_get(struct device *dev, const char *string);
 struct phy *devm_phy_get(struct device *dev, const char *string);
 void phy_put(struct phy *phy);
@@ -199,6 +217,16 @@ static inline int phy_power_off(struct phy *phy)
return -ENOSYS;
 }
 
+static inline int phy_get_bus_width(struct phy *phy)
+{
+   return -ENOSYS;
+}
+
+static inline void phy_set_bus_width(struct phy *phy, int bus_width)
+{
+   return;
+}
+
 static inline struct phy *phy_get(struct device *dev, const char *string)
 {
return ERR_PTR(-ENOSYS);
-- 
1.8.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 v9 6/9] usb: gadget: s3c-hsotg: get phy bus width from phy subsystem

2013-12-23 Thread Matt Porter
Adds support for querying the phy bus width from the generic phy
subsystem. Configure UTMI bus width in GUSBCFG based on this value.

Signed-off-by: Matt Porter mpor...@linaro.org
Acked-by: Kishon Vijay Abraham I kis...@ti.com
---
 drivers/usb/gadget/s3c-hsotg.c | 14 +-
 drivers/usb/gadget/s3c-hsotg.h |  1 +
 2 files changed, 14 insertions(+), 1 deletion(-)

diff --git a/drivers/usb/gadget/s3c-hsotg.c b/drivers/usb/gadget/s3c-hsotg.c
index 8f9bcdb..93ba8b6 100644
--- a/drivers/usb/gadget/s3c-hsotg.c
+++ b/drivers/usb/gadget/s3c-hsotg.c
@@ -146,6 +146,7 @@ struct s3c_hsotg_ep {
  * @regs: The memory area mapped for accessing registers.
  * @irq: The IRQ number we are using
  * @supplies: Definition of USB power supplies
+ * @phyif: PHY interface width
  * @dedicated_fifos: Set if the hardware has dedicated IN-EP fifos.
  * @num_of_eps: Number of available EPs (excluding EP0)
  * @debug_root: root directrory for debugfs.
@@ -174,6 +175,7 @@ struct s3c_hsotg {
 
struct regulator_bulk_data supplies[ARRAY_SIZE(s3c_hsotg_supply_names)];
 
+   u32 phyif;
unsigned intdedicated_fifos:1;
unsigned char   num_of_eps;
 
@@ -2279,7 +2281,7 @@ static void s3c_hsotg_core_init(struct s3c_hsotg *hsotg)
 */
 
/* set the PLL on, remove the HNP/SRP and set the PHY */
-   writel(GUSBCFG_PHYIf16 | GUSBCFG_TOutCal(7) |
+   writel(hsotg-phyif | GUSBCFG_TOutCal(7) |
   (0x5  10), hsotg-regs + GUSBCFG);
 
s3c_hsotg_init_fifo(hsotg);
@@ -3638,6 +3640,16 @@ static int s3c_hsotg_probe(struct platform_device *pdev)
goto err_supplies;
}
 
+   /* Set default UTMI width */
+   hsotg-phyif = GUSBCFG_PHYIf16;
+
+   /*
+* If using the generic PHY framework, check if the PHY bus
+* width is 8-bit and set the phyif appropriately.
+*/
+   if (hsotg-phy  (phy_get_bus_width(phy) == 8))
+   hsotg-phyif = GUSBCFG_PHYIf8;
+
if (hsotg-phy)
phy_init(hsotg-phy);
 
diff --git a/drivers/usb/gadget/s3c-hsotg.h b/drivers/usb/gadget/s3c-hsotg.h
index d650b12..85f549f 100644
--- a/drivers/usb/gadget/s3c-hsotg.h
+++ b/drivers/usb/gadget/s3c-hsotg.h
@@ -55,6 +55,7 @@
 #define GUSBCFG_HNPCap (1  9)
 #define GUSBCFG_SRPCap (1  8)
 #define GUSBCFG_PHYIf16(1  3)
+#define GUSBCFG_PHYIf8 (0  3)
 #define GUSBCFG_TOutCal_MASK   (0x7  0)
 #define GUSBCFG_TOutCal_SHIFT  (0)
 #define GUSBCFG_TOutCal_LIMIT  (0x7)
-- 
1.8.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 v9 3/9] usb: gadget: s3c-hsotg: enable build for other platforms

2013-12-23 Thread Matt Porter
Remove unused Samsung-specific machine include and Kconfig
dependency on S3C.

Signed-off-by: Matt Porter mpor...@linaro.org
Reviewed-by: Markus Mayer markus.ma...@linaro.org
Reviewed-by: Tim Kryger tim.kry...@linaro.org
---
 drivers/usb/gadget/Kconfig | 8 
 drivers/usb/gadget/s3c-hsotg.c | 2 --
 2 files changed, 4 insertions(+), 6 deletions(-)

diff --git a/drivers/usb/gadget/Kconfig b/drivers/usb/gadget/Kconfig
index a91e642..cf955f5 100644
--- a/drivers/usb/gadget/Kconfig
+++ b/drivers/usb/gadget/Kconfig
@@ -294,11 +294,11 @@ config USB_PXA27X
   gadget drivers to also be dynamically linked.
 
 config USB_S3C_HSOTG
-   tristate S3C HS/OtG USB Device controller
-   depends on S3C_DEV_USB_HSOTG
+   tristate Designware/S3C HS/OtG USB Device controller
+   depends on ARM
help
- The Samsung S3C64XX USB2.0 high-speed gadget controller
- integrated into the S3C64XX series SoC.
+ The Designware USB2.0 high-speed gadget controller
+ integrated into many SoCs.
 
 config USB_S3C2410
tristate S3C2410 USB Device Controller
diff --git a/drivers/usb/gadget/s3c-hsotg.c b/drivers/usb/gadget/s3c-hsotg.c
index 9875d9c..db797f2 100644
--- a/drivers/usb/gadget/s3c-hsotg.c
+++ b/drivers/usb/gadget/s3c-hsotg.c
@@ -36,8 +36,6 @@
 #include linux/usb/phy.h
 #include linux/platform_data/s3c-hsotg.h
 
-#include mach/map.h
-
 #include s3c-hsotg.h
 
 static const char * const s3c_hsotg_supply_names[] = {
-- 
1.8.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 v9 0/9] USB Device Controller support for BCM281xx

2013-12-23 Thread Matt Porter
Changes since v8:
- Fix build issue in s3c-hsotg on !ARM by guarding with a
  depends on ARM. Will fix by replacing use of readsl/writesl
  for 3.15 and dropping the Kconfig workaround..

Changes since v7:
- Register phy provider with generic phy subsystem only after
  the generic phy has been allocated and configured.

Changes since v6:
- Drop dependency on the Exynos generic phy conversion series
- Bring back original patch that converts s3c-hsotg to use the
  generic phy layer with a fall back to the old usb style phy
  support.

Changes since v5:
- tweak s3c-hsotg Kconfig help message to be more generic

Changes since v4:
- phy_set/get_bus_width now use an int for bus_width

Changes since v3:
- Rebased on 3.13-rc3
- Move struct phy bus_width attribute back into struct phy_attrs
- Fix build issue on !GENERIC_PHY
- Update dwc2 binding to reflect optional phy properties
- Rename bcm-kona-phy.txt binding to bcm-phy.txt
- Reorder bcm kona phy includes and use bitops
- phy-names changed to usb2-phy to match updated s3c-hsotg
  generic phy-ification series

Changes since v2:
- Rebased on 3.13-rc1
- Fix braces in phy_get_bus_width()/phy_set_bus_width()
- Drop generic phy conversion to use the same support from
  the Exynos generic phy conversion series
- Modify dts support to match the device phy name required
  in the v3 Exynos generic phy conversion
- Add s3c-hsotg phy_init/phy_exit support
- Fix typo on reg property in kona phy binding
- Replace phy driver reg struct with offset defines
- Move phy soft reset to phy driver init
- Fix dts node names to match ePAPR conventions

Changes since v1:
- Convert USB phy driver to generic phy subsystem
- Add phy bus width apis
- Drop dwc2 phy bus width DT property in favor of querying the
  phy provider for bus width
- Add generic phy/clock properties to dwc2 DT binding
- Add generic phy subsystem support to s3c-hsotg with the
  existing usb phy and pdata phy methods as a fallback
- Split bindings out to separate patches to match the latest
  DT binding review guidelines

This series adds USB Device Controller support for the Broadcom
BCM281xx family of parts. BCM281xx contains a DWC2 OTG block and
s3c-hsotg is used to support UDC operation.

Part 1 adds phy bus width support to the generic phy subsystem

Parts 2-6 allows s3c-hsotg to build on non-Samsung platforms, supports
the dwc2 binding, adds generic phy layer support, and supports fetching
phy bus width using the generic phy layer.

Parts 7-8 add a generic phy binding and driver for the BCM Kona USB PHY.

Part 9 adds the DT nodes to enable UDC support on both BCM281xx boards
in the kernel.

This series depends on:
- Update Kona drivers to use clocks v4 series
  https://lkml.org/lkml/2013/12/5/508
  (relevant portion now queued for 3.14)

Matt Porter (9):
  phy: add phy_get_bus_width()/phy_set_bus_width() calls
  staging: dwc2: update DT binding to add generic clock/phy properties
  usb: gadget: s3c-hsotg: enable build for other platforms
  usb: gadget: s3c-hsotg: add snps,dwc2 compatible string
  usb: gadget: s3c-hsotg: enable generic phy support
  usb: gadget: s3c-hsotg: get phy bus width from phy subsystem
  phy: add Broadcom Kona USB2 PHY DT binding
  phy: add Broadcom Kona USB2 PHY driver
  ARM: dts: add usb udc support to bcm281xx

 Documentation/devicetree/bindings/phy/bcm-phy.txt  |  15 ++
 Documentation/devicetree/bindings/staging/dwc2.txt |  12 ++
 arch/arm/boot/dts/bcm11351-brt.dts |   6 +
 arch/arm/boot/dts/bcm11351.dtsi|  18 +++
 arch/arm/boot/dts/bcm28155-ap.dts  |   8 ++
 drivers/phy/Kconfig|   6 +
 drivers/phy/Makefile   |   1 +
 drivers/phy/phy-bcm-kona-usb2.c| 158 +
 drivers/usb/gadget/Kconfig |   8 +-
 drivers/usb/gadget/s3c-hsotg.c |  72 +++---
 drivers/usb/gadget/s3c-hsotg.h |   1 +
 include/linux/phy/phy.h|  28 
 12 files changed, 310 insertions(+), 23 deletions(-)
 create mode 100644 Documentation/devicetree/bindings/phy/bcm-phy.txt
 create mode 100644 drivers/phy/phy-bcm-kona-usb2.c

-- 
1.8.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 v8 1/9] phy: add phy_get_bus_width()/phy_set_bus_width() calls

2013-12-19 Thread Matt Porter
This adds a pair of APIs that allows the generic PHY subsystem to
provide information on the PHY bus width. The PHY provider driver may
use phy_set_bus_width() to set the bus width that the PHY supports.
The controller driver may then use phy_get_bus_width() to fetch the
PHY bus width in order to properly configure the controller.

Signed-off-by: Matt Porter mpor...@linaro.org
Acked-by: Kishon Vijay Abraham I kis...@ti.com
---
 include/linux/phy/phy.h | 28 
 1 file changed, 28 insertions(+)

diff --git a/include/linux/phy/phy.h b/include/linux/phy/phy.h
index 6d72269..e273e5a 100644
--- a/include/linux/phy/phy.h
+++ b/include/linux/phy/phy.h
@@ -38,6 +38,14 @@ struct phy_ops {
 };
 
 /**
+ * struct phy_attrs - represents phy attributes
+ * @bus_width: Data path width implemented by PHY
+ */
+struct phy_attrs {
+   u32 bus_width;
+};
+
+/**
  * struct phy - represents the phy device
  * @dev: phy device
  * @id: id of the phy device
@@ -46,6 +54,7 @@ struct phy_ops {
  * @mutex: mutex to protect phy_ops
  * @init_count: used to protect when the PHY is used by multiple consumers
  * @power_count: used to protect when the PHY is used by multiple consumers
+ * @phy_attrs: used to specify PHY specific attributes
  */
 struct phy {
struct device   dev;
@@ -55,6 +64,7 @@ struct phy {
struct mutexmutex;
int init_count;
int power_count;
+   struct phy_attrsattrs;
 };
 
 /**
@@ -127,6 +137,14 @@ int phy_init(struct phy *phy);
 int phy_exit(struct phy *phy);
 int phy_power_on(struct phy *phy);
 int phy_power_off(struct phy *phy);
+static inline int phy_get_bus_width(struct phy *phy)
+{
+   return phy-attrs.bus_width;
+}
+static inline void phy_set_bus_width(struct phy *phy, int bus_width)
+{
+   phy-attrs.bus_width = bus_width;
+}
 struct phy *phy_get(struct device *dev, const char *string);
 struct phy *devm_phy_get(struct device *dev, const char *string);
 void phy_put(struct phy *phy);
@@ -199,6 +217,16 @@ static inline int phy_power_off(struct phy *phy)
return -ENOSYS;
 }
 
+static inline int phy_get_bus_width(struct phy *phy)
+{
+   return -ENOSYS;
+}
+
+static inline void phy_set_bus_width(struct phy *phy, int bus_width)
+{
+   return;
+}
+
 static inline struct phy *phy_get(struct device *dev, const char *string)
 {
return ERR_PTR(-ENOSYS);
-- 
1.8.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 v8 7/9] phy: add Broadcom Kona USB2 PHY DT binding

2013-12-19 Thread Matt Porter
Add a binding that describes the Broadcom Kona USB2 PHY found
on the BCM281xx family of SoCs.

Signed-off-by: Matt Porter mpor...@linaro.org
Acked-by: Kishon Vijay Abraham I kis...@ti.com
---
 Documentation/devicetree/bindings/phy/bcm-phy.txt | 15 +++
 1 file changed, 15 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/phy/bcm-phy.txt

diff --git a/Documentation/devicetree/bindings/phy/bcm-phy.txt 
b/Documentation/devicetree/bindings/phy/bcm-phy.txt
new file mode 100644
index 000..3dc8b3d
--- /dev/null
+++ b/Documentation/devicetree/bindings/phy/bcm-phy.txt
@@ -0,0 +1,15 @@
+BROADCOM KONA USB2 PHY
+
+Required properties:
+ - compatible: brcm,kona-usb2-phy
+ - reg: offset and length of the PHY registers
+ - #phy-cells: must be 0
+Refer to phy/phy-bindings.txt for the generic PHY binding properties
+
+Example:
+
+   usbphy: usb-phy@3f13 {
+   compatible = brcm,kona-usb2-phy;
+   reg = 0x3f13 0x28;
+   #phy-cells = 0;
+   };
-- 
1.8.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 v8 9/9] ARM: dts: add usb udc support to bcm281xx

2013-12-19 Thread Matt Porter
Adds USB OTG/PHY and clock support to BCM281xx and enables
UDC support on the bcm11351-brt and bcm28155-ap boards.

Signed-off-by: Matt Porter mpor...@linaro.org
Reviewed-by: Markus Mayer markus.ma...@linaro.org
Reviewed-by: Tim Kryger tim.kry...@linaro.org
---
 arch/arm/boot/dts/bcm11351-brt.dts |  6 ++
 arch/arm/boot/dts/bcm11351.dtsi| 18 ++
 arch/arm/boot/dts/bcm28155-ap.dts  |  8 
 3 files changed, 32 insertions(+)

diff --git a/arch/arm/boot/dts/bcm11351-brt.dts 
b/arch/arm/boot/dts/bcm11351-brt.dts
index 23cd16d..396b704 100644
--- a/arch/arm/boot/dts/bcm11351-brt.dts
+++ b/arch/arm/boot/dts/bcm11351-brt.dts
@@ -44,5 +44,11 @@
status = okay;
};
 
+   usbotg: usb@3f12 {
+   status = okay;
+   };
 
+   usbphy: usb-phy@3f13 {
+   status = okay;
+   };
 };
diff --git a/arch/arm/boot/dts/bcm11351.dtsi b/arch/arm/boot/dts/bcm11351.dtsi
index 1246885..0fbb455 100644
--- a/arch/arm/boot/dts/bcm11351.dtsi
+++ b/arch/arm/boot/dts/bcm11351.dtsi
@@ -243,4 +243,22 @@
#clock-cells = 0;
};
};
+
+   usbotg: usb@3f12 {
+   compatible = snps,dwc2;
+   reg = 0x3f12 0x1;
+   interrupts = GIC_SPI 47 IRQ_TYPE_LEVEL_HIGH;
+   clocks = usb_otg_ahb_clk;
+   clock-names = otg;
+   phys = usbphy;
+   phy-names = usb2-phy;
+   status = disabled;
+   };
+
+   usbphy: usb-phy@3f13 {
+   compatible = brcm,kona-usb2-phy;
+   reg = 0x3f13 0x28;
+   #phy-cells = 0;
+   status = disabled;
+   };
 };
diff --git a/arch/arm/boot/dts/bcm28155-ap.dts 
b/arch/arm/boot/dts/bcm28155-ap.dts
index 08e47c2..a3bc436 100644
--- a/arch/arm/boot/dts/bcm28155-ap.dts
+++ b/arch/arm/boot/dts/bcm28155-ap.dts
@@ -43,4 +43,12 @@
cd-gpios = gpio 14 0;
status = okay;
};
+
+   usbotg: usb@3f12 {
+   status = okay;
+   };
+
+   usbphy: usb-phy@3f13 {
+   status = okay;
+   };
 };
-- 
1.8.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 v8 6/9] usb: gadget: s3c-hsotg: get phy bus width from phy subsystem

2013-12-19 Thread Matt Porter
Adds support for querying the phy bus width from the generic phy
subsystem. Configure UTMI bus width in GUSBCFG based on this value.

Signed-off-by: Matt Porter mpor...@linaro.org
Acked-by: Kishon Vijay Abraham I kis...@ti.com
---
 drivers/usb/gadget/s3c-hsotg.c | 14 +-
 drivers/usb/gadget/s3c-hsotg.h |  1 +
 2 files changed, 14 insertions(+), 1 deletion(-)

diff --git a/drivers/usb/gadget/s3c-hsotg.c b/drivers/usb/gadget/s3c-hsotg.c
index 8f9bcdb..93ba8b6 100644
--- a/drivers/usb/gadget/s3c-hsotg.c
+++ b/drivers/usb/gadget/s3c-hsotg.c
@@ -146,6 +146,7 @@ struct s3c_hsotg_ep {
  * @regs: The memory area mapped for accessing registers.
  * @irq: The IRQ number we are using
  * @supplies: Definition of USB power supplies
+ * @phyif: PHY interface width
  * @dedicated_fifos: Set if the hardware has dedicated IN-EP fifos.
  * @num_of_eps: Number of available EPs (excluding EP0)
  * @debug_root: root directrory for debugfs.
@@ -174,6 +175,7 @@ struct s3c_hsotg {
 
struct regulator_bulk_data supplies[ARRAY_SIZE(s3c_hsotg_supply_names)];
 
+   u32 phyif;
unsigned intdedicated_fifos:1;
unsigned char   num_of_eps;
 
@@ -2279,7 +2281,7 @@ static void s3c_hsotg_core_init(struct s3c_hsotg *hsotg)
 */
 
/* set the PLL on, remove the HNP/SRP and set the PHY */
-   writel(GUSBCFG_PHYIf16 | GUSBCFG_TOutCal(7) |
+   writel(hsotg-phyif | GUSBCFG_TOutCal(7) |
   (0x5  10), hsotg-regs + GUSBCFG);
 
s3c_hsotg_init_fifo(hsotg);
@@ -3638,6 +3640,16 @@ static int s3c_hsotg_probe(struct platform_device *pdev)
goto err_supplies;
}
 
+   /* Set default UTMI width */
+   hsotg-phyif = GUSBCFG_PHYIf16;
+
+   /*
+* If using the generic PHY framework, check if the PHY bus
+* width is 8-bit and set the phyif appropriately.
+*/
+   if (hsotg-phy  (phy_get_bus_width(phy) == 8))
+   hsotg-phyif = GUSBCFG_PHYIf8;
+
if (hsotg-phy)
phy_init(hsotg-phy);
 
diff --git a/drivers/usb/gadget/s3c-hsotg.h b/drivers/usb/gadget/s3c-hsotg.h
index d650b12..85f549f 100644
--- a/drivers/usb/gadget/s3c-hsotg.h
+++ b/drivers/usb/gadget/s3c-hsotg.h
@@ -55,6 +55,7 @@
 #define GUSBCFG_HNPCap (1  9)
 #define GUSBCFG_SRPCap (1  8)
 #define GUSBCFG_PHYIf16(1  3)
+#define GUSBCFG_PHYIf8 (0  3)
 #define GUSBCFG_TOutCal_MASK   (0x7  0)
 #define GUSBCFG_TOutCal_SHIFT  (0)
 #define GUSBCFG_TOutCal_LIMIT  (0x7)
-- 
1.8.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 v8 3/9] usb: gadget: s3c-hsotg: enable build for other platforms

2013-12-19 Thread Matt Porter
Remove unused Samsung-specific machine include and Kconfig
dependency on S3C.

Signed-off-by: Matt Porter mpor...@linaro.org
Reviewed-by: Markus Mayer markus.ma...@linaro.org
Reviewed-by: Tim Kryger tim.kry...@linaro.org
---
 drivers/usb/gadget/Kconfig | 7 +++
 drivers/usb/gadget/s3c-hsotg.c | 2 --
 2 files changed, 3 insertions(+), 6 deletions(-)

diff --git a/drivers/usb/gadget/Kconfig b/drivers/usb/gadget/Kconfig
index a91e642..181e760 100644
--- a/drivers/usb/gadget/Kconfig
+++ b/drivers/usb/gadget/Kconfig
@@ -294,11 +294,10 @@ config USB_PXA27X
   gadget drivers to also be dynamically linked.
 
 config USB_S3C_HSOTG
-   tristate S3C HS/OtG USB Device controller
-   depends on S3C_DEV_USB_HSOTG
+   tristate Designware/S3C HS/OtG USB Device controller
help
- The Samsung S3C64XX USB2.0 high-speed gadget controller
- integrated into the S3C64XX series SoC.
+ The Designware USB2.0 high-speed gadget controller
+ integrated into many SoCs.
 
 config USB_S3C2410
tristate S3C2410 USB Device Controller
diff --git a/drivers/usb/gadget/s3c-hsotg.c b/drivers/usb/gadget/s3c-hsotg.c
index 9875d9c..db797f2 100644
--- a/drivers/usb/gadget/s3c-hsotg.c
+++ b/drivers/usb/gadget/s3c-hsotg.c
@@ -36,8 +36,6 @@
 #include linux/usb/phy.h
 #include linux/platform_data/s3c-hsotg.h
 
-#include mach/map.h
-
 #include s3c-hsotg.h
 
 static const char * const s3c_hsotg_supply_names[] = {
-- 
1.8.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 v8 4/9] usb: gadget: s3c-hsotg: add snps,dwc2 compatible string

2013-12-19 Thread Matt Porter
Enable support for the dwc2 binding.

Signed-off-by: Matt Porter mpor...@linaro.org
---
 drivers/usb/gadget/s3c-hsotg.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/usb/gadget/s3c-hsotg.c b/drivers/usb/gadget/s3c-hsotg.c
index db797f2..cbfbf41 100644
--- a/drivers/usb/gadget/s3c-hsotg.c
+++ b/drivers/usb/gadget/s3c-hsotg.c
@@ -3726,6 +3726,7 @@ static int s3c_hsotg_remove(struct platform_device *pdev)
 #ifdef CONFIG_OF
 static const struct of_device_id s3c_hsotg_of_ids[] = {
{ .compatible = samsung,s3c6400-hsotg, },
+   { .compatible = snps,dwc2, },
{ /* sentinel */ }
 };
 MODULE_DEVICE_TABLE(of, s3c_hsotg_of_ids);
-- 
1.8.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 v8 5/9] usb: gadget: s3c-hsotg: enable generic phy support

2013-12-19 Thread Matt Porter
Adds support for the generic PHY subsystem. Generic PHY
support is probed and then the driver falls back to checking
for an old style USB PHY and pdata if not found.

Signed-off-by: Matt Porter mpor...@linaro.org
---
 drivers/usb/gadget/s3c-hsotg.c | 55 ++
 1 file changed, 39 insertions(+), 16 deletions(-)

diff --git a/drivers/usb/gadget/s3c-hsotg.c b/drivers/usb/gadget/s3c-hsotg.c
index cbfbf41..8f9bcdb 100644
--- a/drivers/usb/gadget/s3c-hsotg.c
+++ b/drivers/usb/gadget/s3c-hsotg.c
@@ -30,6 +30,8 @@
 #include linux/clk.h
 #include linux/regulator/consumer.h
 #include linux/of_platform.h
+#include linux/phy/phy.h
+#include linux/usb/phy.h
 
 #include linux/usb/ch9.h
 #include linux/usb/gadget.h
@@ -138,6 +140,7 @@ struct s3c_hsotg_ep {
  * @dev: The parent device supplied to the probe function
  * @driver: USB gadget driver
  * @phy: The otg phy transceiver structure for phy control.
+ * @uphy: The otg phy transceiver structure for old USB phy control.
  * @plat: The platform specific configuration data. This can be removed once
  * all SoCs support usb transceiver.
  * @regs: The memory area mapped for accessing registers.
@@ -159,7 +162,8 @@ struct s3c_hsotg_ep {
 struct s3c_hsotg {
struct device*dev;
struct usb_gadget_driver *driver;
-   struct usb_phy  *phy;
+   struct phy   *phy;
+   struct usb_phy   *uphy;
struct s3c_hsotg_plat*plat;
 
spinlock_t  lock;
@@ -2901,8 +2905,11 @@ static void s3c_hsotg_phy_enable(struct s3c_hsotg *hsotg)
 
dev_dbg(hsotg-dev, pdev 0x%p\n, pdev);
 
-   if (hsotg-phy)
-   usb_phy_init(hsotg-phy);
+   if (hsotg-phy) {
+   phy_init(hsotg-phy);
+   phy_power_on(hsotg-phy);
+   } else if (hsotg-uphy)
+   usb_phy_init(hsotg-uphy);
else if (hsotg-plat-phy_init)
hsotg-plat-phy_init(pdev, hsotg-plat-phy_type);
 }
@@ -2918,8 +2925,11 @@ static void s3c_hsotg_phy_disable(struct s3c_hsotg 
*hsotg)
 {
struct platform_device *pdev = to_platform_device(hsotg-dev);
 
-   if (hsotg-phy)
-   usb_phy_shutdown(hsotg-phy);
+   if (hsotg-phy) {
+   phy_power_off(hsotg-phy);
+   phy_exit(hsotg-phy);
+   } else if (hsotg-uphy)
+   usb_phy_shutdown(hsotg-uphy);
else if (hsotg-plat-phy_exit)
hsotg-plat-phy_exit(pdev, hsotg-plat-phy_type);
 }
@@ -3526,7 +3536,8 @@ static void s3c_hsotg_delete_debug(struct s3c_hsotg 
*hsotg)
 static int s3c_hsotg_probe(struct platform_device *pdev)
 {
struct s3c_hsotg_plat *plat = dev_get_platdata(pdev-dev);
-   struct usb_phy *phy;
+   struct phy *phy;
+   struct usb_phy *uphy;
struct device *dev = pdev-dev;
struct s3c_hsotg_ep *eps;
struct s3c_hsotg *hsotg;
@@ -3541,19 +3552,26 @@ static int s3c_hsotg_probe(struct platform_device *pdev)
return -ENOMEM;
}
 
-   phy = devm_usb_get_phy(dev, USB_PHY_TYPE_USB2);
+   /*
+* Attempt to find a generic PHY, then look for an old style
+* USB PHY, finally fall back to pdata
+*/
+   phy = devm_phy_get(pdev-dev, usb2-phy);
if (IS_ERR(phy)) {
-   /* Fallback for pdata */
-   plat = dev_get_platdata(pdev-dev);
-   if (!plat) {
-   dev_err(pdev-dev, no platform data or transceiver 
defined\n);
-   return -EPROBE_DEFER;
-   } else {
+   uphy = devm_usb_get_phy(dev, USB_PHY_TYPE_USB2);
+   if (IS_ERR(uphy)) {
+   /* Fallback for pdata */
+   plat = dev_get_platdata(pdev-dev);
+   if (!plat) {
+   dev_err(pdev-dev,
+   no platform data or transceiver defined\n);
+   return -EPROBE_DEFER;
+   }
hsotg-plat = plat;
-   }
-   } else {
+   } else
+   hsotg-uphy = uphy;
+   } else
hsotg-phy = phy;
-   }
 
hsotg-dev = dev;
 
@@ -3620,6 +3638,9 @@ static int s3c_hsotg_probe(struct platform_device *pdev)
goto err_supplies;
}
 
+   if (hsotg-phy)
+   phy_init(hsotg-phy);
+
/* usb phy enable */
s3c_hsotg_phy_enable(hsotg);
 
@@ -3713,6 +3734,8 @@ static int s3c_hsotg_remove(struct platform_device *pdev)
}
 
s3c_hsotg_phy_disable(hsotg);
+   if (hsotg-phy)
+   phy_exit(hsotg-phy);
clk_disable_unprepare(hsotg-clk);
 
return 0;
-- 
1.8.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


Re: [PATCH v7 8/9] phy: add Broadcom Kona USB2 PHY driver

2013-12-19 Thread Matt Porter
On Thu, Dec 19, 2013 at 11:19:35AM +0530, Kishon Vijay Abraham I wrote:
 Hi Felipe,
 
 On Wednesday 18 December 2013 09:55 PM, Felipe Balbi wrote:
  On Tue, Dec 17, 2013 at 02:42:35PM -0500, Matt Porter wrote:
  Add a driver for the internal Broadcom Kona USB 2.0 PHY found
  on the BCM281xx family of SoCs.
 
  Signed-off-by: Matt Porter mpor...@linaro.org
  
  Kishon, are you ok with this driver ?
 
 yeah. Since this patch touches phy/Kconfig (and Makefile) and there is one 
 more
 PHY driver to be merged that also modifies Kconfig there might be conflicts. 
 So
 thought I should be taking this patch?
  
  +static int bcm_kona_usb2_probe(struct platform_device *pdev)
  +{
  +  struct device *dev = pdev-dev;
  +  struct bcm_kona_usb *phy;
  +  struct resource *res;
  +  struct phy *gphy;
  +  struct phy_provider *phy_provider;
  +
  +  phy = devm_kzalloc(dev, sizeof(*phy), GFP_KERNEL);
  +  if (!phy)
  +  return -ENOMEM;
  +
  +  res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
  +  phy-regs = devm_ioremap_resource(pdev-dev, res);
  +  if (IS_ERR(phy-regs))
  +  return PTR_ERR(phy-regs);
  +
  +  platform_set_drvdata(pdev, phy);
  +
  +  phy_provider = devm_of_phy_provider_register(dev,
  +  of_phy_simple_xlate);
  +  if (IS_ERR(phy_provider))
  +  return PTR_ERR(phy_provider);
  +
  +  gphy = devm_phy_create(dev, ops, NULL);
  +  if (IS_ERR(gphy))
  +  return PTR_ERR(gphy);
  +
  +  /* The Kona PHY supports an 8-bit wide UTMI interface */
  +  phy_set_bus_width(gphy, 8);
  +
  +  phy_set_drvdata(gphy, phy);
  
  I think this set_drvdata() should be done before registering the
  provider, no ?
 
 hmm, right.

I sent a v8 series update that addresses this issue.

-Matt
--
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 v8 8/9] phy: add Broadcom Kona USB2 PHY driver

2013-12-19 Thread Matt Porter
Add a driver for the internal Broadcom Kona USB 2.0 PHY found
on the BCM281xx family of SoCs.

Signed-off-by: Matt Porter mpor...@linaro.org
---
 drivers/phy/Kconfig |   6 ++
 drivers/phy/Makefile|   1 +
 drivers/phy/phy-bcm-kona-usb2.c | 158 
 3 files changed, 165 insertions(+)
 create mode 100644 drivers/phy/phy-bcm-kona-usb2.c

diff --git a/drivers/phy/Kconfig b/drivers/phy/Kconfig
index a344f3d..2e87fa8 100644
--- a/drivers/phy/Kconfig
+++ b/drivers/phy/Kconfig
@@ -51,4 +51,10 @@ config PHY_EXYNOS_DP_VIDEO
help
  Support for Display Port PHY found on Samsung EXYNOS SoCs.
 
+config BCM_KONA_USB2_PHY
+   tristate Broadcom Kona USB2 PHY Driver
+   depends on GENERIC_PHY
+   help
+ Enable this to support the Broadcom Kona USB 2.0 PHY.
+
 endmenu
diff --git a/drivers/phy/Makefile b/drivers/phy/Makefile
index d0caae9..c447f1a 100644
--- a/drivers/phy/Makefile
+++ b/drivers/phy/Makefile
@@ -3,6 +3,7 @@
 #
 
 obj-$(CONFIG_GENERIC_PHY)  += phy-core.o
+obj-$(CONFIG_BCM_KONA_USB2_PHY)+= phy-bcm-kona-usb2.o
 obj-$(CONFIG_PHY_EXYNOS_DP_VIDEO)  += phy-exynos-dp-video.o
 obj-$(CONFIG_PHY_EXYNOS_MIPI_VIDEO)+= phy-exynos-mipi-video.o
 obj-$(CONFIG_OMAP_USB2)+= phy-omap-usb2.o
diff --git a/drivers/phy/phy-bcm-kona-usb2.c b/drivers/phy/phy-bcm-kona-usb2.c
new file mode 100644
index 000..efc5c1a
--- /dev/null
+++ b/drivers/phy/phy-bcm-kona-usb2.c
@@ -0,0 +1,158 @@
+/*
+ * phy-bcm-kona-usb2.c - Broadcom Kona USB2 Phy Driver
+ *
+ * Copyright (C) 2013 Linaro Limited
+ * Matt Porter mpor...@linaro.org
+ *
+ * This software is licensed under the terms of the GNU General Public
+ * License version 2, as published by the Free Software Foundation, and
+ * may be copied, distributed, and modified under those terms.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ */
+
+#include linux/clk.h
+#include linux/delay.h
+#include linux/err.h
+#include linux/io.h
+#include linux/module.h
+#include linux/of.h
+#include linux/phy/phy.h
+#include linux/platform_device.h
+
+#define OTGCTL (0)
+#define OTGCTL_OTGSTAT2BIT(31)
+#define OTGCTL_OTGSTAT1BIT(30)
+#define OTGCTL_PRST_N_SW   BIT(11)
+#define OTGCTL_HRESET_NBIT(10)
+#define OTGCTL_UTMI_LINE_STATE1BIT(9)
+#define OTGCTL_UTMI_LINE_STATE0BIT(8)
+
+#define P1CTL  (8)
+#define P1CTL_SOFT_RESET   BIT(1)
+#define P1CTL_NON_DRIVING  BIT(0)
+
+struct bcm_kona_usb {
+   void __iomem *regs;
+};
+
+static void bcm_kona_usb_phy_power(struct bcm_kona_usb *phy, int on)
+{
+   u32 val;
+
+   val = readl(phy-regs + OTGCTL);
+   if (on) {
+   /* Configure and power PHY */
+   val = ~(OTGCTL_OTGSTAT2 | OTGCTL_OTGSTAT1 |
+OTGCTL_UTMI_LINE_STATE1 | OTGCTL_UTMI_LINE_STATE0);
+   val |= OTGCTL_PRST_N_SW | OTGCTL_HRESET_N;
+   } else {
+   val = ~(OTGCTL_PRST_N_SW | OTGCTL_HRESET_N);
+   }
+   writel(val, phy-regs + OTGCTL);
+}
+
+static int bcm_kona_usb_phy_init(struct phy *gphy)
+{
+   struct bcm_kona_usb *phy = phy_get_drvdata(gphy);
+   u32 val;
+
+   /* Soft reset PHY */
+   val = readl(phy-regs + P1CTL);
+   val = ~P1CTL_NON_DRIVING;
+   val |= P1CTL_SOFT_RESET;
+   writel(val, phy-regs + P1CTL);
+   writel(val  ~P1CTL_SOFT_RESET, phy-regs + P1CTL);
+   /* Reset needs to be asserted for 2ms */
+   mdelay(2);
+   writel(val | P1CTL_SOFT_RESET, phy-regs + P1CTL);
+
+   return 0;
+}
+
+static int bcm_kona_usb_phy_power_on(struct phy *gphy)
+{
+   struct bcm_kona_usb *phy = phy_get_drvdata(gphy);
+
+   bcm_kona_usb_phy_power(phy, 1);
+
+   return 0;
+}
+
+static int bcm_kona_usb_phy_power_off(struct phy *gphy)
+{
+   struct bcm_kona_usb *phy = phy_get_drvdata(gphy);
+
+   bcm_kona_usb_phy_power(phy, 0);
+
+   return 0;
+}
+
+static struct phy_ops ops = {
+   .init   = bcm_kona_usb_phy_init,
+   .power_on   = bcm_kona_usb_phy_power_on,
+   .power_off  = bcm_kona_usb_phy_power_off,
+   .owner  = THIS_MODULE,
+};
+
+static int bcm_kona_usb2_probe(struct platform_device *pdev)
+{
+   struct device *dev = pdev-dev;
+   struct bcm_kona_usb *phy;
+   struct resource *res;
+   struct phy *gphy;
+   struct phy_provider *phy_provider;
+
+   phy = devm_kzalloc(dev, sizeof(*phy), GFP_KERNEL);
+   if (!phy)
+   return -ENOMEM;
+
+   res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
+   phy-regs = devm_ioremap_resource(pdev-dev, res);
+   if (IS_ERR(phy-regs))
+   return

[PATCH v8 2/9] staging: dwc2: update DT binding to add generic clock/phy properties

2013-12-19 Thread Matt Porter
dwc2/s3c-hsotg require a single clock to be specified and optionally
a generic phy. On the s3c-hsotg driver old style USB phy support is
present as a fallback so the generic phy properties are optional.

Signed-off-by: Matt Porter mpor...@linaro.org
Acked-by: Kishon Vijay Abraham I kis...@ti.com
---
 Documentation/devicetree/bindings/staging/dwc2.txt | 12 
 1 file changed, 12 insertions(+)

diff --git a/Documentation/devicetree/bindings/staging/dwc2.txt 
b/Documentation/devicetree/bindings/staging/dwc2.txt
index 1a1b7cf..a1753ed 100644
--- a/Documentation/devicetree/bindings/staging/dwc2.txt
+++ b/Documentation/devicetree/bindings/staging/dwc2.txt
@@ -5,6 +5,14 @@ Required properties:
 - compatible : snps,dwc2
 - reg : Should contain 1 register range (address and length)
 - interrupts : Should contain 1 interrupt
+- clocks: clock provider specifier
+- clock-names: shall be otg
+Refer to clk/clock-bindings.txt for generic clock consumer properties
+
+Optional properties:
+- phys: phy provider specifier
+- phy-names: shall be device
+Refer to phy/phy-bindings.txt for generic phy consumer properties
 
 Example:
 
@@ -12,4 +20,8 @@ Example:
 compatible = ralink,rt3050-usb, snps,dwc2;
 reg = 0x101c 4;
 interrupts = 18;
+   clocks = usb_otg_ahb_clk;
+   clock-names = otg;
+   phys = usbphy;
+   phy-names = usb2-phy;
 };
-- 
1.8.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 v8 0/9] USB Device Controller support for BCM281xx

2013-12-19 Thread Matt Porter
Changes since v7:
- Register phy provider with generic phy subsystem only after
  the generic phy has been allocated and configured.

Changes since v6:
- Drop dependency on the Exynos generic phy conversion series
- Bring back original patch that converts s3c-hsotg to use the
  generic phy layer with a fall back to the old usb style phy
  support.

Changes since v5:
- tweak s3c-hsotg Kconfig help message to be more generic

Changes since v4:
- phy_set/get_bus_width now use an int for bus_width

Changes since v3:
- Rebased on 3.13-rc3
- Move struct phy bus_width attribute back into struct phy_attrs
- Fix build issue on !GENERIC_PHY
- Update dwc2 binding to reflect optional phy properties
- Rename bcm-kona-phy.txt binding to bcm-phy.txt
- Reorder bcm kona phy includes and use bitops
- phy-names changed to usb2-phy to match updated s3c-hsotg
  generic phy-ification series

Changes since v2:
- Rebased on 3.13-rc1
- Fix braces in phy_get_bus_width()/phy_set_bus_width()
- Drop generic phy conversion to use the same support from
  the Exynos generic phy conversion series
- Modify dts support to match the device phy name required
  in the v3 Exynos generic phy conversion
- Add s3c-hsotg phy_init/phy_exit support
- Fix typo on reg property in kona phy binding
- Replace phy driver reg struct with offset defines
- Move phy soft reset to phy driver init
- Fix dts node names to match ePAPR conventions

Changes since v1:
- Convert USB phy driver to generic phy subsystem
- Add phy bus width apis
- Drop dwc2 phy bus width DT property in favor of querying the
  phy provider for bus width
- Add generic phy/clock properties to dwc2 DT binding
- Add generic phy subsystem support to s3c-hsotg with the
  existing usb phy and pdata phy methods as a fallback
- Split bindings out to separate patches to match the latest
  DT binding review guidelines

This series adds USB Device Controller support for the Broadcom
BCM281xx family of parts. BCM281xx contains a DWC2 OTG block and
s3c-hsotg is used to support UDC operation.

Part 1 adds phy bus width support to the generic phy subsystem

Parts 2-6 allows s3c-hsotg to build on non-Samsung platforms, supports
the dwc2 binding, adds generic phy layer support, and supports fetching
phy bus width using the generic phy layer.

Parts 7-8 add a generic phy binding and driver for the BCM Kona USB PHY.

Part 9 adds the DT nodes to enable UDC support on both BCM281xx boards
in the kernel.

This series depends on:
- Update Kona drivers to use clocks v4 series
  https://lkml.org/lkml/2013/12/5/508
  (relevant portion now queued for 3.14)



Matt Porter (9):
  phy: add phy_get_bus_width()/phy_set_bus_width() calls
  staging: dwc2: update DT binding to add generic clock/phy properties
  usb: gadget: s3c-hsotg: enable build for other platforms
  usb: gadget: s3c-hsotg: add snps,dwc2 compatible string
  usb: gadget: s3c-hsotg: enable generic phy support
  usb: gadget: s3c-hsotg: get phy bus width from phy subsystem
  phy: add Broadcom Kona USB2 PHY DT binding
  phy: add Broadcom Kona USB2 PHY driver
  ARM: dts: add usb udc support to bcm281xx

 Documentation/devicetree/bindings/phy/bcm-phy.txt  |  15 ++
 Documentation/devicetree/bindings/staging/dwc2.txt |  12 ++
 arch/arm/boot/dts/bcm11351-brt.dts |   6 +
 arch/arm/boot/dts/bcm11351.dtsi|  18 +++
 arch/arm/boot/dts/bcm28155-ap.dts  |   8 ++
 drivers/phy/Kconfig|   6 +
 drivers/phy/Makefile   |   1 +
 drivers/phy/phy-bcm-kona-usb2.c| 158 +
 drivers/usb/gadget/Kconfig |   7 +-
 drivers/usb/gadget/s3c-hsotg.c |  72 +++---
 drivers/usb/gadget/s3c-hsotg.h |   1 +
 include/linux/phy/phy.h|  28 
 12 files changed, 309 insertions(+), 23 deletions(-)
 create mode 100644 Documentation/devicetree/bindings/phy/bcm-phy.txt
 create mode 100644 drivers/phy/phy-bcm-kona-usb2.c

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


Re: [PATCH v7 8/9] phy: add Broadcom Kona USB2 PHY driver

2013-12-18 Thread Matt Porter
On Wed, Dec 18, 2013 at 10:25:54AM -0600, Felipe Balbi wrote:
 On Tue, Dec 17, 2013 at 02:42:35PM -0500, Matt Porter wrote:
  Add a driver for the internal Broadcom Kona USB 2.0 PHY found
  on the BCM281xx family of SoCs.
  
  Signed-off-by: Matt Porter mpor...@linaro.org
 
 Kishon, are you ok with this driver ?

Kishon did mention he was fine with this if I addressed a couple
comments a couple versions ago, I neglected solicit his ack though.

  +static int bcm_kona_usb2_probe(struct platform_device *pdev)
  +{
  +   struct device *dev = pdev-dev;
  +   struct bcm_kona_usb *phy;
  +   struct resource *res;
  +   struct phy *gphy;
  +   struct phy_provider *phy_provider;
  +
  +   phy = devm_kzalloc(dev, sizeof(*phy), GFP_KERNEL);
  +   if (!phy)
  +   return -ENOMEM;
  +
  +   res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
  +   phy-regs = devm_ioremap_resource(pdev-dev, res);
  +   if (IS_ERR(phy-regs))
  +   return PTR_ERR(phy-regs);
  +
  +   platform_set_drvdata(pdev, phy);
  +
  +   phy_provider = devm_of_phy_provider_register(dev,
  +   of_phy_simple_xlate);
  +   if (IS_ERR(phy_provider))
  +   return PTR_ERR(phy_provider);
  +
  +   gphy = devm_phy_create(dev, ops, NULL);
  +   if (IS_ERR(gphy))
  +   return PTR_ERR(gphy);
  +
  +   /* The Kona PHY supports an 8-bit wide UTMI interface */
  +   phy_set_bus_width(gphy, 8);
  +
  +   phy_set_drvdata(gphy, phy);
 
 I think this set_drvdata() should be done before registering the
 provider, no ?

It seems so, given that we wouldn't want the provider on on the
provider list until the phy has been allocated and configured.

Interestingly, this also needs to be addressed in the four phy
drivers already upstream...they all do the same thing before the
generic phy is created.

-Matt
--
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 v4 5/9] usb: s3c-hsotg: Use the new Exynos USB phy driver with the generic phy framework

2013-12-17 Thread 'Matt Porter'
On Tue, Dec 17, 2013 at 10:41:56AM +0100, Kamil Debski wrote:
 Hi Matt,
 
 I am afraid it is not possible. This patch cannot go in without the 
 new  phy driver. It would break Exynos USB functionality. This
 is because it changes s3c-hsotg to use the new phy driver.

To clarify, I'm proposing that I would bring back the original patch
from my earlier postings on the bcm281xx series that preserves the old
style usb phy support as a fallback along with the pdata path.

 I am working on an updated patch series addressing all the comments.
 time permitting I want to post an alternative version - integrating
 as much as possible in a single file. This way it would be possible
 to have a hands-on comparison of the two approaches we were
 discussing with Kishon. 
 
 I estimate that I post it this week.

Ok, thanks. In the meantime I'll update my original version of this
patch in case your work can't be taken in this window.

-Matt

  -Original Message-
  From: Matt Porter [mailto:mpor...@linaro.org]
  Sent: Monday, December 16, 2013 10:40 PM
  To: Kamil Debski
  Cc: linux-ker...@vger.kernel.org; linux-samsung-...@vger.kernel.org;
  linux-usb@vger.kernel.org; devicet...@vger.kernel.org;
  kyungmin.p...@samsung.com; kis...@ti.com; t.f...@samsung.com;
  s.nawro...@samsung.com; m.szyprow...@samsung.com;
  gautam.vi...@samsung.com; mat.krawc...@gmail.com;
  yulgon@samsung.com; p.pan...@samsung.com; av.tikhomi...@samsung.com;
  jg1@samsung.com; ga...@codeaurora.org; Felipe Balbi
  Subject: Re: [PATCH v4 5/9] usb: s3c-hsotg: Use the new Exynos USB phy
  driver with the generic phy framework
  
  On Thu, Dec 05, 2013 at 01:29:35PM +0100, Kamil Debski wrote:
   Change the used phy driver to the new Exynos USB phy driver that uses
   the generic phy framework.
  
   Signed-off-by: Kamil Debski k.deb...@samsung.com
   Signed-off-by: Kyungmin Park kyungmin.p...@samsung.com
   ---
.../devicetree/bindings/usb/samsung-hsotg.txt  |4 
drivers/usb/gadget/s3c-hsotg.c |   11 ++
  -
2 files changed, 10 insertions(+), 5 deletions(-)
  
  Kamil,
  
  Can we separate this patch out of this series? My bcm281xx series is
  ready to go except for this dependency. Felipe has noted that there's
  only a week until he locks his tree down for 3.14 [1]. I'm willing to
  update this versus the comment Kishon made on fixing the example if you
  don't have time before then. Let me know.
  
  [1] https://lkml.org/lkml/2013/12/16/555
  
  Thanks,
  Matt
  
   diff --git a/Documentation/devicetree/bindings/usb/samsung-hsotg.txt
   b/Documentation/devicetree/bindings/usb/samsung-hsotg.txt
   index b83d428..9340d06 100644
   --- a/Documentation/devicetree/bindings/usb/samsung-hsotg.txt
   +++ b/Documentation/devicetree/bindings/usb/samsung-hsotg.txt
   @@ -24,6 +24,8 @@ Required properties:
- first entry: must be otg
- vusb_d-supply: phandle to voltage regulator of digital section,
- vusb_a-supply: phandle to voltage regulator of analog section.
   +- phys: from general PHY binding: phandle to the PHY device
   +- phy-names: from general PHY binding: should be usb2-phy
  
Example
-
   @@ -36,5 +38,7 @@ Example
 clock-names = otg;
 vusb_d-supply = vusb_reg;
 vusb_a-supply = vusbdac_reg;
   + phys = usb2phy 0;
   + phy-names = device;
 };
  
   diff --git a/drivers/usb/gadget/s3c-hsotg.c
   b/drivers/usb/gadget/s3c-hsotg.c index eccb147..db096fd 100644
   --- a/drivers/usb/gadget/s3c-hsotg.c
   +++ b/drivers/usb/gadget/s3c-hsotg.c
   @@ -31,6 +31,7 @@
#include linux/regulator/consumer.h  #include linux/of.h
   #include linux/of_platform.h
   +#include linux/phy/phy.h
  
#include linux/usb/ch9.h
#include linux/usb/gadget.h
   @@ -162,7 +163,7 @@ struct s3c_hsotg_ep {  struct s3c_hsotg {
 struct device*dev;
 struct usb_gadget_driver *driver;
   - struct usb_phy  *phy;
   + struct phy   *phy;
 struct s3c_hsotg_plat*plat;
  
 spinlock_t  lock;
   @@ -2905,7 +2906,7 @@ static void s3c_hsotg_phy_enable(struct
  s3c_hsotg *hsotg)
 dev_dbg(hsotg-dev, pdev 0x%p\n, pdev);
  
 if (hsotg-phy)
   - usb_phy_init(hsotg-phy);
   + phy_power_on(hsotg-phy);
 else if (hsotg-plat-phy_init)
 hsotg-plat-phy_init(pdev, hsotg-plat-phy_type);  } @@ -
  2922,7
   +2923,7 @@ static void s3c_hsotg_phy_disable(struct s3c_hsotg *hsotg)
 struct platform_device *pdev = to_platform_device(hsotg-dev);
  
 if (hsotg-phy)
   - usb_phy_shutdown(hsotg-phy);
   + phy_power_off(hsotg-phy);
 else if (hsotg-plat-phy_exit)
 hsotg-plat-phy_exit(pdev, hsotg-plat-phy_type);  } @@ -
  3529,7
   +3530,7 @@ static void s3c_hsotg_delete_debug(struct s3c_hsotg *hsotg)
   static int s3c_hsotg_probe(struct platform_device *pdev)  {
 struct s3c_hsotg_plat *plat = dev_get_platdata(pdev-dev

[PATCH v7 7/9] phy: add Broadcom Kona USB2 PHY DT binding

2013-12-17 Thread Matt Porter
Add a binding that describes the Broadcom Kona USB2 PHY found
on the BCM281xx family of SoCs.

Signed-off-by: Matt Porter mpor...@linaro.org
Acked-by: Kishon Vijay Abraham I kis...@ti.com
---
 Documentation/devicetree/bindings/phy/bcm-phy.txt | 15 +++
 1 file changed, 15 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/phy/bcm-phy.txt

diff --git a/Documentation/devicetree/bindings/phy/bcm-phy.txt 
b/Documentation/devicetree/bindings/phy/bcm-phy.txt
new file mode 100644
index 000..3dc8b3d
--- /dev/null
+++ b/Documentation/devicetree/bindings/phy/bcm-phy.txt
@@ -0,0 +1,15 @@
+BROADCOM KONA USB2 PHY
+
+Required properties:
+ - compatible: brcm,kona-usb2-phy
+ - reg: offset and length of the PHY registers
+ - #phy-cells: must be 0
+Refer to phy/phy-bindings.txt for the generic PHY binding properties
+
+Example:
+
+   usbphy: usb-phy@3f13 {
+   compatible = brcm,kona-usb2-phy;
+   reg = 0x3f13 0x28;
+   #phy-cells = 0;
+   };
-- 
1.8.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 v7 1/9] phy: add phy_get_bus_width()/phy_set_bus_width() calls

2013-12-17 Thread Matt Porter
This adds a pair of APIs that allows the generic PHY subsystem to
provide information on the PHY bus width. The PHY provider driver may
use phy_set_bus_width() to set the bus width that the PHY supports.
The controller driver may then use phy_get_bus_width() to fetch the
PHY bus width in order to properly configure the controller.

Signed-off-by: Matt Porter mpor...@linaro.org
Acked-by: Kishon Vijay Abraham I kis...@ti.com
---
 include/linux/phy/phy.h | 28 
 1 file changed, 28 insertions(+)

diff --git a/include/linux/phy/phy.h b/include/linux/phy/phy.h
index 6d72269..e273e5a 100644
--- a/include/linux/phy/phy.h
+++ b/include/linux/phy/phy.h
@@ -38,6 +38,14 @@ struct phy_ops {
 };
 
 /**
+ * struct phy_attrs - represents phy attributes
+ * @bus_width: Data path width implemented by PHY
+ */
+struct phy_attrs {
+   u32 bus_width;
+};
+
+/**
  * struct phy - represents the phy device
  * @dev: phy device
  * @id: id of the phy device
@@ -46,6 +54,7 @@ struct phy_ops {
  * @mutex: mutex to protect phy_ops
  * @init_count: used to protect when the PHY is used by multiple consumers
  * @power_count: used to protect when the PHY is used by multiple consumers
+ * @phy_attrs: used to specify PHY specific attributes
  */
 struct phy {
struct device   dev;
@@ -55,6 +64,7 @@ struct phy {
struct mutexmutex;
int init_count;
int power_count;
+   struct phy_attrsattrs;
 };
 
 /**
@@ -127,6 +137,14 @@ int phy_init(struct phy *phy);
 int phy_exit(struct phy *phy);
 int phy_power_on(struct phy *phy);
 int phy_power_off(struct phy *phy);
+static inline int phy_get_bus_width(struct phy *phy)
+{
+   return phy-attrs.bus_width;
+}
+static inline void phy_set_bus_width(struct phy *phy, int bus_width)
+{
+   phy-attrs.bus_width = bus_width;
+}
 struct phy *phy_get(struct device *dev, const char *string);
 struct phy *devm_phy_get(struct device *dev, const char *string);
 void phy_put(struct phy *phy);
@@ -199,6 +217,16 @@ static inline int phy_power_off(struct phy *phy)
return -ENOSYS;
 }
 
+static inline int phy_get_bus_width(struct phy *phy)
+{
+   return -ENOSYS;
+}
+
+static inline void phy_set_bus_width(struct phy *phy, int bus_width)
+{
+   return;
+}
+
 static inline struct phy *phy_get(struct device *dev, const char *string)
 {
return ERR_PTR(-ENOSYS);
-- 
1.8.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 v7 0/9] USB Device Controller support for BCM281xx

2013-12-17 Thread Matt Porter
Changes since v6:
- Drop dependency on the Exynos generic phy conversion series
- Bring back original patch that converts s3c-hsotg to use the
  generic phy layer with a fall back to the old usb style phy
  support.

Changes since v5:
- tweak s3c-hsotg Kconfig help message to be more generic

Changes since v4:
- phy_set/get_bus_width now use an int for bus_width

Changes since v3:
- Rebased on 3.13-rc3
- Move struct phy bus_width attribute back into struct phy_attrs
- Fix build issue on !GENERIC_PHY
- Update dwc2 binding to reflect optional phy properties
- Rename bcm-kona-phy.txt binding to bcm-phy.txt
- Reorder bcm kona phy includes and use bitops
- phy-names changed to usb2-phy to match updated s3c-hsotg
  generic phy-ification series

Changes since v2:
- Rebased on 3.13-rc1
- Fix braces in phy_get_bus_width()/phy_set_bus_width()
- Drop generic phy conversion to use the same support from
  the Exynos generic phy conversion series
- Modify dts support to match the device phy name required
  in the v3 Exynos generic phy conversion
- Add s3c-hsotg phy_init/phy_exit support
- Fix typo on reg property in kona phy binding
- Replace phy driver reg struct with offset defines
- Move phy soft reset to phy driver init
- Fix dts node names to match ePAPR conventions

Changes since v1:
- Convert USB phy driver to generic phy subsystem
- Add phy bus width apis
- Drop dwc2 phy bus width DT property in favor of querying the
  phy provider for bus width
- Add generic phy/clock properties to dwc2 DT binding
- Add generic phy subsystem support to s3c-hsotg with the
  existing usb phy and pdata phy methods as a fallback
- Split bindings out to separate patches to match the latest
  DT binding review guidelines

This series adds USB Device Controller support for the Broadcom
BCM281xx family of parts. BCM281xx contains a DWC2 OTG block and
s3c-hsotg is used to support UDC operation.

Part 1 adds phy bus width support to the generic phy subsystem

Parts 2-6 allows s3c-hsotg to build on non-Samsung platforms, supports
the dwc2 binding, adds generic phy layer support, and supports fetching
phy bus width using the generic phy layer.

Parts 7-8 add a generic phy binding and driver for the BCM Kona USB PHY.

Part 9 adds the DT nodes to enable UDC support on both BCM281xx boards
in the kernel.

This series depends on:
- Update Kona drivers to use clocks v4 series
  https://lkml.org/lkml/2013/12/5/508
  (relevant portion now queued for 3.14)


Matt Porter (9):
  phy: add phy_get_bus_width()/phy_set_bus_width() calls
  staging: dwc2: update DT binding to add generic clock/phy properties
  usb: gadget: s3c-hsotg: enable build for other platforms
  usb: gadget: s3c-hsotg: add snps,dwc2 compatible string
  usb: gadget: s3c-hsotg: enable generic phy support
  usb: gadget: s3c-hsotg: get phy bus width from phy subsystem
  phy: add Broadcom Kona USB2 PHY DT binding
  phy: add Broadcom Kona USB2 PHY driver
  ARM: dts: add usb udc support to bcm281xx

 Documentation/devicetree/bindings/phy/bcm-phy.txt  |  15 ++
 Documentation/devicetree/bindings/staging/dwc2.txt |  12 ++
 arch/arm/boot/dts/bcm11351-brt.dts |   6 +
 arch/arm/boot/dts/bcm11351.dtsi|  18 +++
 arch/arm/boot/dts/bcm28155-ap.dts  |   8 ++
 drivers/phy/Kconfig|   6 +
 drivers/phy/Makefile   |   1 +
 drivers/phy/phy-bcm-kona-usb2.c| 158 +
 drivers/usb/gadget/Kconfig |   7 +-
 drivers/usb/gadget/s3c-hsotg.c |  72 +++---
 drivers/usb/gadget/s3c-hsotg.h |   1 +
 include/linux/phy/phy.h|  28 
 12 files changed, 309 insertions(+), 23 deletions(-)
 create mode 100644 Documentation/devicetree/bindings/phy/bcm-phy.txt
 create mode 100644 drivers/phy/phy-bcm-kona-usb2.c

-- 
1.8.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 v7 3/9] usb: gadget: s3c-hsotg: enable build for other platforms

2013-12-17 Thread Matt Porter
Remove unused Samsung-specific machine include and Kconfig
dependency on S3C.

Signed-off-by: Matt Porter mpor...@linaro.org
Reviewed-by: Markus Mayer markus.ma...@linaro.org
Reviewed-by: Tim Kryger tim.kry...@linaro.org
---
 drivers/usb/gadget/Kconfig | 7 +++
 drivers/usb/gadget/s3c-hsotg.c | 2 --
 2 files changed, 3 insertions(+), 6 deletions(-)

diff --git a/drivers/usb/gadget/Kconfig b/drivers/usb/gadget/Kconfig
index a91e642..181e760 100644
--- a/drivers/usb/gadget/Kconfig
+++ b/drivers/usb/gadget/Kconfig
@@ -294,11 +294,10 @@ config USB_PXA27X
   gadget drivers to also be dynamically linked.
 
 config USB_S3C_HSOTG
-   tristate S3C HS/OtG USB Device controller
-   depends on S3C_DEV_USB_HSOTG
+   tristate Designware/S3C HS/OtG USB Device controller
help
- The Samsung S3C64XX USB2.0 high-speed gadget controller
- integrated into the S3C64XX series SoC.
+ The Designware USB2.0 high-speed gadget controller
+ integrated into many SoCs.
 
 config USB_S3C2410
tristate S3C2410 USB Device Controller
diff --git a/drivers/usb/gadget/s3c-hsotg.c b/drivers/usb/gadget/s3c-hsotg.c
index 9875d9c..db797f2 100644
--- a/drivers/usb/gadget/s3c-hsotg.c
+++ b/drivers/usb/gadget/s3c-hsotg.c
@@ -36,8 +36,6 @@
 #include linux/usb/phy.h
 #include linux/platform_data/s3c-hsotg.h
 
-#include mach/map.h
-
 #include s3c-hsotg.h
 
 static const char * const s3c_hsotg_supply_names[] = {
-- 
1.8.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 v7 8/9] phy: add Broadcom Kona USB2 PHY driver

2013-12-17 Thread Matt Porter
Add a driver for the internal Broadcom Kona USB 2.0 PHY found
on the BCM281xx family of SoCs.

Signed-off-by: Matt Porter mpor...@linaro.org
---
 drivers/phy/Kconfig |   6 ++
 drivers/phy/Makefile|   1 +
 drivers/phy/phy-bcm-kona-usb2.c | 158 
 3 files changed, 165 insertions(+)
 create mode 100644 drivers/phy/phy-bcm-kona-usb2.c

diff --git a/drivers/phy/Kconfig b/drivers/phy/Kconfig
index a344f3d..2e87fa8 100644
--- a/drivers/phy/Kconfig
+++ b/drivers/phy/Kconfig
@@ -51,4 +51,10 @@ config PHY_EXYNOS_DP_VIDEO
help
  Support for Display Port PHY found on Samsung EXYNOS SoCs.
 
+config BCM_KONA_USB2_PHY
+   tristate Broadcom Kona USB2 PHY Driver
+   depends on GENERIC_PHY
+   help
+ Enable this to support the Broadcom Kona USB 2.0 PHY.
+
 endmenu
diff --git a/drivers/phy/Makefile b/drivers/phy/Makefile
index d0caae9..c447f1a 100644
--- a/drivers/phy/Makefile
+++ b/drivers/phy/Makefile
@@ -3,6 +3,7 @@
 #
 
 obj-$(CONFIG_GENERIC_PHY)  += phy-core.o
+obj-$(CONFIG_BCM_KONA_USB2_PHY)+= phy-bcm-kona-usb2.o
 obj-$(CONFIG_PHY_EXYNOS_DP_VIDEO)  += phy-exynos-dp-video.o
 obj-$(CONFIG_PHY_EXYNOS_MIPI_VIDEO)+= phy-exynos-mipi-video.o
 obj-$(CONFIG_OMAP_USB2)+= phy-omap-usb2.o
diff --git a/drivers/phy/phy-bcm-kona-usb2.c b/drivers/phy/phy-bcm-kona-usb2.c
new file mode 100644
index 000..0046781
--- /dev/null
+++ b/drivers/phy/phy-bcm-kona-usb2.c
@@ -0,0 +1,158 @@
+/*
+ * phy-bcm-kona-usb2.c - Broadcom Kona USB2 Phy Driver
+ *
+ * Copyright (C) 2013 Linaro Limited
+ * Matt Porter mpor...@linaro.org
+ *
+ * This software is licensed under the terms of the GNU General Public
+ * License version 2, as published by the Free Software Foundation, and
+ * may be copied, distributed, and modified under those terms.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ */
+
+#include linux/clk.h
+#include linux/delay.h
+#include linux/err.h
+#include linux/io.h
+#include linux/module.h
+#include linux/of.h
+#include linux/phy/phy.h
+#include linux/platform_device.h
+
+#define OTGCTL (0)
+#define OTGCTL_OTGSTAT2BIT(31)
+#define OTGCTL_OTGSTAT1BIT(30)
+#define OTGCTL_PRST_N_SW   BIT(11)
+#define OTGCTL_HRESET_NBIT(10)
+#define OTGCTL_UTMI_LINE_STATE1BIT(9)
+#define OTGCTL_UTMI_LINE_STATE0BIT(8)
+
+#define P1CTL  (8)
+#define P1CTL_SOFT_RESET   BIT(1)
+#define P1CTL_NON_DRIVING  BIT(0)
+
+struct bcm_kona_usb {
+   void __iomem *regs;
+};
+
+static void bcm_kona_usb_phy_power(struct bcm_kona_usb *phy, int on)
+{
+   u32 val;
+
+   val = readl(phy-regs + OTGCTL);
+   if (on) {
+   /* Configure and power PHY */
+   val = ~(OTGCTL_OTGSTAT2 | OTGCTL_OTGSTAT1 |
+OTGCTL_UTMI_LINE_STATE1 | OTGCTL_UTMI_LINE_STATE0);
+   val |= OTGCTL_PRST_N_SW | OTGCTL_HRESET_N;
+   } else {
+   val = ~(OTGCTL_PRST_N_SW | OTGCTL_HRESET_N);
+   }
+   writel(val, phy-regs + OTGCTL);
+}
+
+static int bcm_kona_usb_phy_init(struct phy *gphy)
+{
+   struct bcm_kona_usb *phy = phy_get_drvdata(gphy);
+   u32 val;
+
+   /* Soft reset PHY */
+   val = readl(phy-regs + P1CTL);
+   val = ~P1CTL_NON_DRIVING;
+   val |= P1CTL_SOFT_RESET;
+   writel(val, phy-regs + P1CTL);
+   writel(val  ~P1CTL_SOFT_RESET, phy-regs + P1CTL);
+   /* Reset needs to be asserted for 2ms */
+   mdelay(2);
+   writel(val | P1CTL_SOFT_RESET, phy-regs + P1CTL);
+
+   return 0;
+}
+
+static int bcm_kona_usb_phy_power_on(struct phy *gphy)
+{
+   struct bcm_kona_usb *phy = phy_get_drvdata(gphy);
+
+   bcm_kona_usb_phy_power(phy, 1);
+
+   return 0;
+}
+
+static int bcm_kona_usb_phy_power_off(struct phy *gphy)
+{
+   struct bcm_kona_usb *phy = phy_get_drvdata(gphy);
+
+   bcm_kona_usb_phy_power(phy, 0);
+
+   return 0;
+}
+
+static struct phy_ops ops = {
+   .init   = bcm_kona_usb_phy_init,
+   .power_on   = bcm_kona_usb_phy_power_on,
+   .power_off  = bcm_kona_usb_phy_power_off,
+   .owner  = THIS_MODULE,
+};
+
+static int bcm_kona_usb2_probe(struct platform_device *pdev)
+{
+   struct device *dev = pdev-dev;
+   struct bcm_kona_usb *phy;
+   struct resource *res;
+   struct phy *gphy;
+   struct phy_provider *phy_provider;
+
+   phy = devm_kzalloc(dev, sizeof(*phy), GFP_KERNEL);
+   if (!phy)
+   return -ENOMEM;
+
+   res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
+   phy-regs = devm_ioremap_resource(pdev-dev, res);
+   if (IS_ERR(phy-regs))
+   return

[PATCH v7 4/9] usb: gadget: s3c-hsotg: add snps,dwc2 compatible string

2013-12-17 Thread Matt Porter
Enable support for the dwc2 binding.

Signed-off-by: Matt Porter mpor...@linaro.org
---
 drivers/usb/gadget/s3c-hsotg.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/usb/gadget/s3c-hsotg.c b/drivers/usb/gadget/s3c-hsotg.c
index db797f2..cbfbf41 100644
--- a/drivers/usb/gadget/s3c-hsotg.c
+++ b/drivers/usb/gadget/s3c-hsotg.c
@@ -3726,6 +3726,7 @@ static int s3c_hsotg_remove(struct platform_device *pdev)
 #ifdef CONFIG_OF
 static const struct of_device_id s3c_hsotg_of_ids[] = {
{ .compatible = samsung,s3c6400-hsotg, },
+   { .compatible = snps,dwc2, },
{ /* sentinel */ }
 };
 MODULE_DEVICE_TABLE(of, s3c_hsotg_of_ids);
-- 
1.8.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 v7 9/9] ARM: dts: add usb udc support to bcm281xx

2013-12-17 Thread Matt Porter
Adds USB OTG/PHY and clock support to BCM281xx and enables
UDC support on the bcm11351-brt and bcm28155-ap boards.

Signed-off-by: Matt Porter mpor...@linaro.org
Reviewed-by: Markus Mayer markus.ma...@linaro.org
Reviewed-by: Tim Kryger tim.kry...@linaro.org
---
 arch/arm/boot/dts/bcm11351-brt.dts |  6 ++
 arch/arm/boot/dts/bcm11351.dtsi| 18 ++
 arch/arm/boot/dts/bcm28155-ap.dts  |  8 
 3 files changed, 32 insertions(+)

diff --git a/arch/arm/boot/dts/bcm11351-brt.dts 
b/arch/arm/boot/dts/bcm11351-brt.dts
index 23cd16d..396b704 100644
--- a/arch/arm/boot/dts/bcm11351-brt.dts
+++ b/arch/arm/boot/dts/bcm11351-brt.dts
@@ -44,5 +44,11 @@
status = okay;
};
 
+   usbotg: usb@3f12 {
+   status = okay;
+   };
 
+   usbphy: usb-phy@3f13 {
+   status = okay;
+   };
 };
diff --git a/arch/arm/boot/dts/bcm11351.dtsi b/arch/arm/boot/dts/bcm11351.dtsi
index 1246885..0fbb455 100644
--- a/arch/arm/boot/dts/bcm11351.dtsi
+++ b/arch/arm/boot/dts/bcm11351.dtsi
@@ -243,4 +243,22 @@
#clock-cells = 0;
};
};
+
+   usbotg: usb@3f12 {
+   compatible = snps,dwc2;
+   reg = 0x3f12 0x1;
+   interrupts = GIC_SPI 47 IRQ_TYPE_LEVEL_HIGH;
+   clocks = usb_otg_ahb_clk;
+   clock-names = otg;
+   phys = usbphy;
+   phy-names = usb2-phy;
+   status = disabled;
+   };
+
+   usbphy: usb-phy@3f13 {
+   compatible = brcm,kona-usb2-phy;
+   reg = 0x3f13 0x28;
+   #phy-cells = 0;
+   status = disabled;
+   };
 };
diff --git a/arch/arm/boot/dts/bcm28155-ap.dts 
b/arch/arm/boot/dts/bcm28155-ap.dts
index 08e47c2..a3bc436 100644
--- a/arch/arm/boot/dts/bcm28155-ap.dts
+++ b/arch/arm/boot/dts/bcm28155-ap.dts
@@ -43,4 +43,12 @@
cd-gpios = gpio 14 0;
status = okay;
};
+
+   usbotg: usb@3f12 {
+   status = okay;
+   };
+
+   usbphy: usb-phy@3f13 {
+   status = okay;
+   };
 };
-- 
1.8.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 v7 5/9] usb: gadget: s3c-hsotg: enable generic phy support

2013-12-17 Thread Matt Porter
Adds support for the generic PHY subsystem. Generic PHY
support is probed and then the driver falls back to checking
for an old style USB PHY and pdata if not found.

Signed-off-by: Matt Porter mpor...@linaro.org
---
 drivers/usb/gadget/s3c-hsotg.c | 55 ++
 1 file changed, 39 insertions(+), 16 deletions(-)

diff --git a/drivers/usb/gadget/s3c-hsotg.c b/drivers/usb/gadget/s3c-hsotg.c
index cbfbf41..8f9bcdb 100644
--- a/drivers/usb/gadget/s3c-hsotg.c
+++ b/drivers/usb/gadget/s3c-hsotg.c
@@ -30,6 +30,8 @@
 #include linux/clk.h
 #include linux/regulator/consumer.h
 #include linux/of_platform.h
+#include linux/phy/phy.h
+#include linux/usb/phy.h
 
 #include linux/usb/ch9.h
 #include linux/usb/gadget.h
@@ -138,6 +140,7 @@ struct s3c_hsotg_ep {
  * @dev: The parent device supplied to the probe function
  * @driver: USB gadget driver
  * @phy: The otg phy transceiver structure for phy control.
+ * @uphy: The otg phy transceiver structure for old USB phy control.
  * @plat: The platform specific configuration data. This can be removed once
  * all SoCs support usb transceiver.
  * @regs: The memory area mapped for accessing registers.
@@ -159,7 +162,8 @@ struct s3c_hsotg_ep {
 struct s3c_hsotg {
struct device*dev;
struct usb_gadget_driver *driver;
-   struct usb_phy  *phy;
+   struct phy   *phy;
+   struct usb_phy   *uphy;
struct s3c_hsotg_plat*plat;
 
spinlock_t  lock;
@@ -2901,8 +2905,11 @@ static void s3c_hsotg_phy_enable(struct s3c_hsotg *hsotg)
 
dev_dbg(hsotg-dev, pdev 0x%p\n, pdev);
 
-   if (hsotg-phy)
-   usb_phy_init(hsotg-phy);
+   if (hsotg-phy) {
+   phy_init(hsotg-phy);
+   phy_power_on(hsotg-phy);
+   } else if (hsotg-uphy)
+   usb_phy_init(hsotg-uphy);
else if (hsotg-plat-phy_init)
hsotg-plat-phy_init(pdev, hsotg-plat-phy_type);
 }
@@ -2918,8 +2925,11 @@ static void s3c_hsotg_phy_disable(struct s3c_hsotg 
*hsotg)
 {
struct platform_device *pdev = to_platform_device(hsotg-dev);
 
-   if (hsotg-phy)
-   usb_phy_shutdown(hsotg-phy);
+   if (hsotg-phy) {
+   phy_power_off(hsotg-phy);
+   phy_exit(hsotg-phy);
+   } else if (hsotg-uphy)
+   usb_phy_shutdown(hsotg-uphy);
else if (hsotg-plat-phy_exit)
hsotg-plat-phy_exit(pdev, hsotg-plat-phy_type);
 }
@@ -3526,7 +3536,8 @@ static void s3c_hsotg_delete_debug(struct s3c_hsotg 
*hsotg)
 static int s3c_hsotg_probe(struct platform_device *pdev)
 {
struct s3c_hsotg_plat *plat = dev_get_platdata(pdev-dev);
-   struct usb_phy *phy;
+   struct phy *phy;
+   struct usb_phy *uphy;
struct device *dev = pdev-dev;
struct s3c_hsotg_ep *eps;
struct s3c_hsotg *hsotg;
@@ -3541,19 +3552,26 @@ static int s3c_hsotg_probe(struct platform_device *pdev)
return -ENOMEM;
}
 
-   phy = devm_usb_get_phy(dev, USB_PHY_TYPE_USB2);
+   /*
+* Attempt to find a generic PHY, then look for an old style
+* USB PHY, finally fall back to pdata
+*/
+   phy = devm_phy_get(pdev-dev, usb2-phy);
if (IS_ERR(phy)) {
-   /* Fallback for pdata */
-   plat = dev_get_platdata(pdev-dev);
-   if (!plat) {
-   dev_err(pdev-dev, no platform data or transceiver 
defined\n);
-   return -EPROBE_DEFER;
-   } else {
+   uphy = devm_usb_get_phy(dev, USB_PHY_TYPE_USB2);
+   if (IS_ERR(uphy)) {
+   /* Fallback for pdata */
+   plat = dev_get_platdata(pdev-dev);
+   if (!plat) {
+   dev_err(pdev-dev,
+   no platform data or transceiver defined\n);
+   return -EPROBE_DEFER;
+   }
hsotg-plat = plat;
-   }
-   } else {
+   } else
+   hsotg-uphy = uphy;
+   } else
hsotg-phy = phy;
-   }
 
hsotg-dev = dev;
 
@@ -3620,6 +3638,9 @@ static int s3c_hsotg_probe(struct platform_device *pdev)
goto err_supplies;
}
 
+   if (hsotg-phy)
+   phy_init(hsotg-phy);
+
/* usb phy enable */
s3c_hsotg_phy_enable(hsotg);
 
@@ -3713,6 +3734,8 @@ static int s3c_hsotg_remove(struct platform_device *pdev)
}
 
s3c_hsotg_phy_disable(hsotg);
+   if (hsotg-phy)
+   phy_exit(hsotg-phy);
clk_disable_unprepare(hsotg-clk);
 
return 0;
-- 
1.8.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 v7 2/9] staging: dwc2: update DT binding to add generic clock/phy properties

2013-12-17 Thread Matt Porter
dwc2/s3c-hsotg require a single clock to be specified and optionally
a generic phy. On the s3c-hsotg driver old style USB phy support is
present as a fallback so the generic phy properties are optional.

Signed-off-by: Matt Porter mpor...@linaro.org
Acked-by: Kishon Vijay Abraham I kis...@ti.com
---
 Documentation/devicetree/bindings/staging/dwc2.txt | 12 
 1 file changed, 12 insertions(+)

diff --git a/Documentation/devicetree/bindings/staging/dwc2.txt 
b/Documentation/devicetree/bindings/staging/dwc2.txt
index 1a1b7cf..a1753ed 100644
--- a/Documentation/devicetree/bindings/staging/dwc2.txt
+++ b/Documentation/devicetree/bindings/staging/dwc2.txt
@@ -5,6 +5,14 @@ Required properties:
 - compatible : snps,dwc2
 - reg : Should contain 1 register range (address and length)
 - interrupts : Should contain 1 interrupt
+- clocks: clock provider specifier
+- clock-names: shall be otg
+Refer to clk/clock-bindings.txt for generic clock consumer properties
+
+Optional properties:
+- phys: phy provider specifier
+- phy-names: shall be device
+Refer to phy/phy-bindings.txt for generic phy consumer properties
 
 Example:
 
@@ -12,4 +20,8 @@ Example:
 compatible = ralink,rt3050-usb, snps,dwc2;
 reg = 0x101c 4;
 interrupts = 18;
+   clocks = usb_otg_ahb_clk;
+   clock-names = otg;
+   phys = usbphy;
+   phy-names = usb2-phy;
 };
-- 
1.8.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


Re: [PATCH v6 5/9] usb: gadget: s3c-hsotg: use generic phy_init()/phy_exit() support

2013-12-16 Thread Matt Porter
On Mon, Dec 16, 2013 at 03:20:01PM -0600, Felipe Balbi wrote:
 On Fri, Dec 13, 2013 at 11:51:19AM -0500, Matt Porter wrote:
  If a generic phy is present, call phy_init()/phy_exit(). This supports
  generic phys that must be soft reset before power on.
  
  Signed-off-by: Matt Porter mpor...@linaro.org
  Acked-by: Kishon Vijay Abraham I kis...@ti.com
  ---
   drivers/usb/gadget/s3c-hsotg.c | 5 +
   1 file changed, 5 insertions(+)
  
  diff --git a/drivers/usb/gadget/s3c-hsotg.c b/drivers/usb/gadget/s3c-hsotg.c
  index 7c5d8bd..e9683c2 100644
  --- a/drivers/usb/gadget/s3c-hsotg.c
  +++ b/drivers/usb/gadget/s3c-hsotg.c
  @@ -3621,6 +3621,9 @@ static int s3c_hsotg_probe(struct platform_device 
  *pdev)
  goto err_supplies;
  }
   
  +   if (hsotg-phy)
  +   phy_init(hsotg-phy);
 
 doesn't build. you need to include linux/phy/phy.h

It depends on https://lkml.org/lkml/2013/12/5/172 which I noted in the
cover letter. At this point, I don't know if Kamil's whole series will
make it to 3.14 so that patch may have to be taken separately. He has a
trivial update to make on the binding example is all for this patch.

I was wondering today if we might just want to separate that out now. I
originally had a similar patch in my series but his was posted first so
I rebased on that.

-Matt
--
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 v4 5/9] usb: s3c-hsotg: Use the new Exynos USB phy driver with the generic phy framework

2013-12-16 Thread Matt Porter
On Thu, Dec 05, 2013 at 01:29:35PM +0100, Kamil Debski wrote:
 Change the used phy driver to the new Exynos USB phy driver that uses the
 generic phy framework.
 
 Signed-off-by: Kamil Debski k.deb...@samsung.com
 Signed-off-by: Kyungmin Park kyungmin.p...@samsung.com
 ---
  .../devicetree/bindings/usb/samsung-hsotg.txt  |4 
  drivers/usb/gadget/s3c-hsotg.c |   11 ++-
  2 files changed, 10 insertions(+), 5 deletions(-)

Kamil,

Can we separate this patch out of this series? My bcm281xx series is
ready to go except for this dependency. Felipe has noted that there's
only a week until he locks his tree down for 3.14 [1]. I'm willing to
update this versus the comment Kishon made on fixing the example if
you don't have time before then. Let me know.

[1] https://lkml.org/lkml/2013/12/16/555

Thanks,
Matt

 diff --git a/Documentation/devicetree/bindings/usb/samsung-hsotg.txt 
 b/Documentation/devicetree/bindings/usb/samsung-hsotg.txt
 index b83d428..9340d06 100644
 --- a/Documentation/devicetree/bindings/usb/samsung-hsotg.txt
 +++ b/Documentation/devicetree/bindings/usb/samsung-hsotg.txt
 @@ -24,6 +24,8 @@ Required properties:
  - first entry: must be otg
  - vusb_d-supply: phandle to voltage regulator of digital section,
  - vusb_a-supply: phandle to voltage regulator of analog section.
 +- phys: from general PHY binding: phandle to the PHY device
 +- phy-names: from general PHY binding: should be usb2-phy
  
  Example
  -
 @@ -36,5 +38,7 @@ Example
   clock-names = otg;
   vusb_d-supply = vusb_reg;
   vusb_a-supply = vusbdac_reg;
 + phys = usb2phy 0;
 + phy-names = device;
   };
  
 diff --git a/drivers/usb/gadget/s3c-hsotg.c b/drivers/usb/gadget/s3c-hsotg.c
 index eccb147..db096fd 100644
 --- a/drivers/usb/gadget/s3c-hsotg.c
 +++ b/drivers/usb/gadget/s3c-hsotg.c
 @@ -31,6 +31,7 @@
  #include linux/regulator/consumer.h
  #include linux/of.h
  #include linux/of_platform.h
 +#include linux/phy/phy.h
  
  #include linux/usb/ch9.h
  #include linux/usb/gadget.h
 @@ -162,7 +163,7 @@ struct s3c_hsotg_ep {
  struct s3c_hsotg {
   struct device*dev;
   struct usb_gadget_driver *driver;
 - struct usb_phy  *phy;
 + struct phy   *phy;
   struct s3c_hsotg_plat*plat;
  
   spinlock_t  lock;
 @@ -2905,7 +2906,7 @@ static void s3c_hsotg_phy_enable(struct s3c_hsotg 
 *hsotg)
   dev_dbg(hsotg-dev, pdev 0x%p\n, pdev);
  
   if (hsotg-phy)
 - usb_phy_init(hsotg-phy);
 + phy_power_on(hsotg-phy);
   else if (hsotg-plat-phy_init)
   hsotg-plat-phy_init(pdev, hsotg-plat-phy_type);
  }
 @@ -2922,7 +2923,7 @@ static void s3c_hsotg_phy_disable(struct s3c_hsotg 
 *hsotg)
   struct platform_device *pdev = to_platform_device(hsotg-dev);
  
   if (hsotg-phy)
 - usb_phy_shutdown(hsotg-phy);
 + phy_power_off(hsotg-phy);
   else if (hsotg-plat-phy_exit)
   hsotg-plat-phy_exit(pdev, hsotg-plat-phy_type);
  }
 @@ -3529,7 +3530,7 @@ static void s3c_hsotg_delete_debug(struct s3c_hsotg 
 *hsotg)
  static int s3c_hsotg_probe(struct platform_device *pdev)
  {
   struct s3c_hsotg_plat *plat = dev_get_platdata(pdev-dev);
 - struct usb_phy *phy;
 + struct phy *phy;
   struct device *dev = pdev-dev;
   struct s3c_hsotg_ep *eps;
   struct s3c_hsotg *hsotg;
 @@ -3544,7 +3545,7 @@ static int s3c_hsotg_probe(struct platform_device *pdev)
   return -ENOMEM;
   }
  
 - phy = devm_usb_get_phy(dev, USB_PHY_TYPE_USB2);
 + phy = devm_phy_get(pdev-dev, usb2-phy);
   if (IS_ERR(phy)) {
   /* Fallback for pdata */
   plat = dev_get_platdata(pdev-dev);
 -- 
 1.7.9.5
 
--
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 v6 6/9] usb: gadget: s3c-hsotg: get phy bus width from phy subsystem

2013-12-13 Thread Matt Porter
Adds support for querying the phy bus width from the generic phy
subsystem. Configure UTMI bus width in GUSBCFG based on this value.

Signed-off-by: Matt Porter mpor...@linaro.org
Acked-by: Kishon Vijay Abraham I kis...@ti.com
---
 drivers/usb/gadget/s3c-hsotg.c | 14 +-
 drivers/usb/gadget/s3c-hsotg.h |  1 +
 2 files changed, 14 insertions(+), 1 deletion(-)

diff --git a/drivers/usb/gadget/s3c-hsotg.c b/drivers/usb/gadget/s3c-hsotg.c
index e9683c2..168aaa9 100644
--- a/drivers/usb/gadget/s3c-hsotg.c
+++ b/drivers/usb/gadget/s3c-hsotg.c
@@ -144,6 +144,7 @@ struct s3c_hsotg_ep {
  * @regs: The memory area mapped for accessing registers.
  * @irq: The IRQ number we are using
  * @supplies: Definition of USB power supplies
+ * @phyif: PHY interface width
  * @dedicated_fifos: Set if the hardware has dedicated IN-EP fifos.
  * @num_of_eps: Number of available EPs (excluding EP0)
  * @debug_root: root directrory for debugfs.
@@ -171,6 +172,7 @@ struct s3c_hsotg {
 
struct regulator_bulk_data supplies[ARRAY_SIZE(s3c_hsotg_supply_names)];
 
+   u32 phyif;
unsigned intdedicated_fifos:1;
unsigned char   num_of_eps;
 
@@ -2276,7 +2278,7 @@ static void s3c_hsotg_core_init(struct s3c_hsotg *hsotg)
 */
 
/* set the PLL on, remove the HNP/SRP and set the PHY */
-   writel(GUSBCFG_PHYIf16 | GUSBCFG_TOutCal(7) |
+   writel(hsotg-phyif | GUSBCFG_TOutCal(7) |
   (0x5  10), hsotg-regs + GUSBCFG);
 
s3c_hsotg_init_fifo(hsotg);
@@ -3621,6 +3623,16 @@ static int s3c_hsotg_probe(struct platform_device *pdev)
goto err_supplies;
}
 
+   /* Set default UTMI width */
+   hsotg-phyif = GUSBCFG_PHYIf16;
+
+   /*
+* If using the generic PHY framework, check if the PHY bus
+* width is 8-bit and set the phyif appropriately.
+*/
+   if (hsotg-phy  (phy_get_bus_width(phy) == 8))
+   hsotg-phyif = GUSBCFG_PHYIf8;
+
if (hsotg-phy)
phy_init(hsotg-phy);
 
diff --git a/drivers/usb/gadget/s3c-hsotg.h b/drivers/usb/gadget/s3c-hsotg.h
index d650b12..85f549f 100644
--- a/drivers/usb/gadget/s3c-hsotg.h
+++ b/drivers/usb/gadget/s3c-hsotg.h
@@ -55,6 +55,7 @@
 #define GUSBCFG_HNPCap (1  9)
 #define GUSBCFG_SRPCap (1  8)
 #define GUSBCFG_PHYIf16(1  3)
+#define GUSBCFG_PHYIf8 (0  3)
 #define GUSBCFG_TOutCal_MASK   (0x7  0)
 #define GUSBCFG_TOutCal_SHIFT  (0)
 #define GUSBCFG_TOutCal_LIMIT  (0x7)
-- 
1.8.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 v6 8/9] phy: add Broadcom Kona USB2 PHY driver

2013-12-13 Thread Matt Porter
Add a driver for the internal Broadcom Kona USB 2.0 PHY found
on the BCM281xx family of SoCs.

Signed-off-by: Matt Porter mpor...@linaro.org
---
 drivers/phy/Kconfig |   6 ++
 drivers/phy/Makefile|   1 +
 drivers/phy/phy-bcm-kona-usb2.c | 158 
 3 files changed, 165 insertions(+)
 create mode 100644 drivers/phy/phy-bcm-kona-usb2.c

diff --git a/drivers/phy/Kconfig b/drivers/phy/Kconfig
index a344f3d..2e87fa8 100644
--- a/drivers/phy/Kconfig
+++ b/drivers/phy/Kconfig
@@ -51,4 +51,10 @@ config PHY_EXYNOS_DP_VIDEO
help
  Support for Display Port PHY found on Samsung EXYNOS SoCs.
 
+config BCM_KONA_USB2_PHY
+   tristate Broadcom Kona USB2 PHY Driver
+   depends on GENERIC_PHY
+   help
+ Enable this to support the Broadcom Kona USB 2.0 PHY.
+
 endmenu
diff --git a/drivers/phy/Makefile b/drivers/phy/Makefile
index d0caae9..c447f1a 100644
--- a/drivers/phy/Makefile
+++ b/drivers/phy/Makefile
@@ -3,6 +3,7 @@
 #
 
 obj-$(CONFIG_GENERIC_PHY)  += phy-core.o
+obj-$(CONFIG_BCM_KONA_USB2_PHY)+= phy-bcm-kona-usb2.o
 obj-$(CONFIG_PHY_EXYNOS_DP_VIDEO)  += phy-exynos-dp-video.o
 obj-$(CONFIG_PHY_EXYNOS_MIPI_VIDEO)+= phy-exynos-mipi-video.o
 obj-$(CONFIG_OMAP_USB2)+= phy-omap-usb2.o
diff --git a/drivers/phy/phy-bcm-kona-usb2.c b/drivers/phy/phy-bcm-kona-usb2.c
new file mode 100644
index 000..0046781
--- /dev/null
+++ b/drivers/phy/phy-bcm-kona-usb2.c
@@ -0,0 +1,158 @@
+/*
+ * phy-bcm-kona-usb2.c - Broadcom Kona USB2 Phy Driver
+ *
+ * Copyright (C) 2013 Linaro Limited
+ * Matt Porter mpor...@linaro.org
+ *
+ * This software is licensed under the terms of the GNU General Public
+ * License version 2, as published by the Free Software Foundation, and
+ * may be copied, distributed, and modified under those terms.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ */
+
+#include linux/clk.h
+#include linux/delay.h
+#include linux/err.h
+#include linux/io.h
+#include linux/module.h
+#include linux/of.h
+#include linux/phy/phy.h
+#include linux/platform_device.h
+
+#define OTGCTL (0)
+#define OTGCTL_OTGSTAT2BIT(31)
+#define OTGCTL_OTGSTAT1BIT(30)
+#define OTGCTL_PRST_N_SW   BIT(11)
+#define OTGCTL_HRESET_NBIT(10)
+#define OTGCTL_UTMI_LINE_STATE1BIT(9)
+#define OTGCTL_UTMI_LINE_STATE0BIT(8)
+
+#define P1CTL  (8)
+#define P1CTL_SOFT_RESET   BIT(1)
+#define P1CTL_NON_DRIVING  BIT(0)
+
+struct bcm_kona_usb {
+   void __iomem *regs;
+};
+
+static void bcm_kona_usb_phy_power(struct bcm_kona_usb *phy, int on)
+{
+   u32 val;
+
+   val = readl(phy-regs + OTGCTL);
+   if (on) {
+   /* Configure and power PHY */
+   val = ~(OTGCTL_OTGSTAT2 | OTGCTL_OTGSTAT1 |
+OTGCTL_UTMI_LINE_STATE1 | OTGCTL_UTMI_LINE_STATE0);
+   val |= OTGCTL_PRST_N_SW | OTGCTL_HRESET_N;
+   } else {
+   val = ~(OTGCTL_PRST_N_SW | OTGCTL_HRESET_N);
+   }
+   writel(val, phy-regs + OTGCTL);
+}
+
+static int bcm_kona_usb_phy_init(struct phy *gphy)
+{
+   struct bcm_kona_usb *phy = phy_get_drvdata(gphy);
+   u32 val;
+
+   /* Soft reset PHY */
+   val = readl(phy-regs + P1CTL);
+   val = ~P1CTL_NON_DRIVING;
+   val |= P1CTL_SOFT_RESET;
+   writel(val, phy-regs + P1CTL);
+   writel(val  ~P1CTL_SOFT_RESET, phy-regs + P1CTL);
+   /* Reset needs to be asserted for 2ms */
+   mdelay(2);
+   writel(val | P1CTL_SOFT_RESET, phy-regs + P1CTL);
+
+   return 0;
+}
+
+static int bcm_kona_usb_phy_power_on(struct phy *gphy)
+{
+   struct bcm_kona_usb *phy = phy_get_drvdata(gphy);
+
+   bcm_kona_usb_phy_power(phy, 1);
+
+   return 0;
+}
+
+static int bcm_kona_usb_phy_power_off(struct phy *gphy)
+{
+   struct bcm_kona_usb *phy = phy_get_drvdata(gphy);
+
+   bcm_kona_usb_phy_power(phy, 0);
+
+   return 0;
+}
+
+static struct phy_ops ops = {
+   .init   = bcm_kona_usb_phy_init,
+   .power_on   = bcm_kona_usb_phy_power_on,
+   .power_off  = bcm_kona_usb_phy_power_off,
+   .owner  = THIS_MODULE,
+};
+
+static int bcm_kona_usb2_probe(struct platform_device *pdev)
+{
+   struct device *dev = pdev-dev;
+   struct bcm_kona_usb *phy;
+   struct resource *res;
+   struct phy *gphy;
+   struct phy_provider *phy_provider;
+
+   phy = devm_kzalloc(dev, sizeof(*phy), GFP_KERNEL);
+   if (!phy)
+   return -ENOMEM;
+
+   res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
+   phy-regs = devm_ioremap_resource(pdev-dev, res);
+   if (IS_ERR(phy-regs))
+   return

[PATCH v6 9/9] ARM: dts: add usb udc support to bcm281xx

2013-12-13 Thread Matt Porter
Adds USB OTG/PHY and clock support to BCM281xx and enables
UDC support on the bcm11351-brt and bcm28155-ap boards.

Signed-off-by: Matt Porter mpor...@linaro.org
Reviewed-by: Markus Mayer markus.ma...@linaro.org
Reviewed-by: Tim Kryger tim.kry...@linaro.org
---
 arch/arm/boot/dts/bcm11351-brt.dts |  6 ++
 arch/arm/boot/dts/bcm11351.dtsi| 18 ++
 arch/arm/boot/dts/bcm28155-ap.dts  |  8 
 3 files changed, 32 insertions(+)

diff --git a/arch/arm/boot/dts/bcm11351-brt.dts 
b/arch/arm/boot/dts/bcm11351-brt.dts
index 23cd16d..396b704 100644
--- a/arch/arm/boot/dts/bcm11351-brt.dts
+++ b/arch/arm/boot/dts/bcm11351-brt.dts
@@ -44,5 +44,11 @@
status = okay;
};
 
+   usbotg: usb@3f12 {
+   status = okay;
+   };
 
+   usbphy: usb-phy@3f13 {
+   status = okay;
+   };
 };
diff --git a/arch/arm/boot/dts/bcm11351.dtsi b/arch/arm/boot/dts/bcm11351.dtsi
index 1246885..0fbb455 100644
--- a/arch/arm/boot/dts/bcm11351.dtsi
+++ b/arch/arm/boot/dts/bcm11351.dtsi
@@ -243,4 +243,22 @@
#clock-cells = 0;
};
};
+
+   usbotg: usb@3f12 {
+   compatible = snps,dwc2;
+   reg = 0x3f12 0x1;
+   interrupts = GIC_SPI 47 IRQ_TYPE_LEVEL_HIGH;
+   clocks = usb_otg_ahb_clk;
+   clock-names = otg;
+   phys = usbphy;
+   phy-names = usb2-phy;
+   status = disabled;
+   };
+
+   usbphy: usb-phy@3f13 {
+   compatible = brcm,kona-usb2-phy;
+   reg = 0x3f13 0x28;
+   #phy-cells = 0;
+   status = disabled;
+   };
 };
diff --git a/arch/arm/boot/dts/bcm28155-ap.dts 
b/arch/arm/boot/dts/bcm28155-ap.dts
index 08e47c2..a3bc436 100644
--- a/arch/arm/boot/dts/bcm28155-ap.dts
+++ b/arch/arm/boot/dts/bcm28155-ap.dts
@@ -43,4 +43,12 @@
cd-gpios = gpio 14 0;
status = okay;
};
+
+   usbotg: usb@3f12 {
+   status = okay;
+   };
+
+   usbphy: usb-phy@3f13 {
+   status = okay;
+   };
 };
-- 
1.8.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 v6 5/9] usb: gadget: s3c-hsotg: use generic phy_init()/phy_exit() support

2013-12-13 Thread Matt Porter
If a generic phy is present, call phy_init()/phy_exit(). This supports
generic phys that must be soft reset before power on.

Signed-off-by: Matt Porter mpor...@linaro.org
Acked-by: Kishon Vijay Abraham I kis...@ti.com
---
 drivers/usb/gadget/s3c-hsotg.c | 5 +
 1 file changed, 5 insertions(+)

diff --git a/drivers/usb/gadget/s3c-hsotg.c b/drivers/usb/gadget/s3c-hsotg.c
index 7c5d8bd..e9683c2 100644
--- a/drivers/usb/gadget/s3c-hsotg.c
+++ b/drivers/usb/gadget/s3c-hsotg.c
@@ -3621,6 +3621,9 @@ static int s3c_hsotg_probe(struct platform_device *pdev)
goto err_supplies;
}
 
+   if (hsotg-phy)
+   phy_init(hsotg-phy);
+
/* usb phy enable */
s3c_hsotg_phy_enable(hsotg);
 
@@ -3714,6 +3717,8 @@ static int s3c_hsotg_remove(struct platform_device *pdev)
}
 
s3c_hsotg_phy_disable(hsotg);
+   if (hsotg-phy)
+   phy_exit(hsotg-phy);
clk_disable_unprepare(hsotg-clk);
 
return 0;
-- 
1.8.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 v6 7/9] phy: add Broadcom Kona USB2 PHY DT binding

2013-12-13 Thread Matt Porter
Add a binding that describes the Broadcom Kona USB2 PHY found
on the BCM281xx family of SoCs.

Signed-off-by: Matt Porter mpor...@linaro.org
Acked-by: Kishon Vijay Abraham I kis...@ti.com
---
 Documentation/devicetree/bindings/phy/bcm-phy.txt | 15 +++
 1 file changed, 15 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/phy/bcm-phy.txt

diff --git a/Documentation/devicetree/bindings/phy/bcm-phy.txt 
b/Documentation/devicetree/bindings/phy/bcm-phy.txt
new file mode 100644
index 000..3dc8b3d
--- /dev/null
+++ b/Documentation/devicetree/bindings/phy/bcm-phy.txt
@@ -0,0 +1,15 @@
+BROADCOM KONA USB2 PHY
+
+Required properties:
+ - compatible: brcm,kona-usb2-phy
+ - reg: offset and length of the PHY registers
+ - #phy-cells: must be 0
+Refer to phy/phy-bindings.txt for the generic PHY binding properties
+
+Example:
+
+   usbphy: usb-phy@3f13 {
+   compatible = brcm,kona-usb2-phy;
+   reg = 0x3f13 0x28;
+   #phy-cells = 0;
+   };
-- 
1.8.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 v6 0/9] USB Device Controller support for BCM281xx

2013-12-13 Thread Matt Porter
Changes since v5:
- tweak s3c-hsotg Kconfig help message to be more generic

Changes since v4:
- phy_set/get_bus_width now use an int for bus_width

Changes since v3:
- Rebased on 3.13-rc3
- Move struct phy bus_width attribute back into struct phy_attrs
- Fix build issue on !GENERIC_PHY
- Update dwc2 binding to reflect optional phy properties
- Rename bcm-kona-phy.txt binding to bcm-phy.txt
- Reorder bcm kona phy includes and use bitops
- phy-names changed to usb2-phy to match updated s3c-hsotg
  generic phy-ification series

Changes since v2:
- Rebased on 3.13-rc1
- Fix braces in phy_get_bus_width()/phy_set_bus_width()
- Drop generic phy conversion to use the same support from
  the Exynos generic phy conversion series
- Modify dts support to match the device phy name required
  in the v3 Exynos generic phy conversion
- Add s3c-hsotg phy_init/phy_exit support
- Fix typo on reg property in kona phy binding
- Replace phy driver reg struct with offset defines
- Move phy soft reset to phy driver init
- Fix dts node names to match ePAPR conventions

Changes since v1:
- Convert USB phy driver to generic phy subsystem
- Add phy bus width apis
- Drop dwc2 phy bus width DT property in favor of querying the
  phy provider for bus width
- Add generic phy/clock properties to dwc2 DT binding
- Add generic phy subsystem support to s3c-hsotg with the
  existing usb phy and pdata phy methods as a fallback
- Split bindings out to separate patches to match the latest
  DT binding review guidelines

This series adds USB Device Controller support for the Broadcom
BCM281xx family of parts. BCM281xx contains a DWC2 OTG block and
s3c-hsotg is used to support UDC operation.

Part 1 adds phy bus width support to the generic phy subsystem

Parts 2-6 allows s3c-hsotg to build on non-Samsung platforms, supports
the dwc2 binding, adds phy_init/phy_exit support, and supports fetching
phy bus width using the generic phy layer.

Parts 7-8 add a generic phy binding and driver for the BCM Kona USB PHY.

Part 9 adds the DT nodes to enable UDC support on both BCM281xx boards
in the kernel.

This series depends on:
- Update Kona drivers to use clocks v4 series
  https://lkml.org/lkml/2013/12/5/508
- Add new Exynos USB 2.0 PHY driver v4 series
  https://lkml.org/lkml/2013/12/5/166

Matt Porter (9):
  phy: add phy_get_bus_width()/phy_set_bus_width() calls
  staging: dwc2: update DT binding to add generic clock/phy properties
  usb: gadget: s3c-hsotg: enable build for other platforms
  usb: gadget: s3c-hsotg: add snps,dwc2 compatible string
  usb: gadget: s3c-hsotg: use generic phy_init()/phy_exit() support
  usb: gadget: s3c-hsotg: get phy bus width from phy subsystem
  phy: add Broadcom Kona USB2 PHY DT binding
  phy: add Broadcom Kona USB2 PHY driver
  ARM: dts: add usb udc support to bcm281xx

 Documentation/devicetree/bindings/phy/bcm-phy.txt  |  15 ++
 Documentation/devicetree/bindings/staging/dwc2.txt |  12 ++
 arch/arm/boot/dts/bcm11351-brt.dts |   6 +
 arch/arm/boot/dts/bcm11351.dtsi|  18 +++
 arch/arm/boot/dts/bcm28155-ap.dts  |   8 ++
 drivers/phy/Kconfig|   6 +
 drivers/phy/Makefile   |   1 +
 drivers/phy/phy-bcm-kona-usb2.c| 158 +
 drivers/usb/gadget/Kconfig |   7 +-
 drivers/usb/gadget/s3c-hsotg.c |  22 ++-
 drivers/usb/gadget/s3c-hsotg.h |   1 +
 include/linux/phy/phy.h|  28 
 12 files changed, 275 insertions(+), 7 deletions(-)
 create mode 100644 Documentation/devicetree/bindings/phy/bcm-phy.txt
 create mode 100644 drivers/phy/phy-bcm-kona-usb2.c

-- 
1.8.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 v6 3/9] usb: gadget: s3c-hsotg: enable build for other platforms

2013-12-13 Thread Matt Porter
Remove unused Samsung-specific machine include and Kconfig
dependency on S3C.

Signed-off-by: Matt Porter mpor...@linaro.org
Reviewed-by: Markus Mayer markus.ma...@linaro.org
Reviewed-by: Tim Kryger tim.kry...@linaro.org
---
 drivers/usb/gadget/Kconfig | 7 +++
 drivers/usb/gadget/s3c-hsotg.c | 2 --
 2 files changed, 3 insertions(+), 6 deletions(-)

diff --git a/drivers/usb/gadget/Kconfig b/drivers/usb/gadget/Kconfig
index a91e642..181e760 100644
--- a/drivers/usb/gadget/Kconfig
+++ b/drivers/usb/gadget/Kconfig
@@ -294,11 +294,10 @@ config USB_PXA27X
   gadget drivers to also be dynamically linked.
 
 config USB_S3C_HSOTG
-   tristate S3C HS/OtG USB Device controller
-   depends on S3C_DEV_USB_HSOTG
+   tristate Designware/S3C HS/OtG USB Device controller
help
- The Samsung S3C64XX USB2.0 high-speed gadget controller
- integrated into the S3C64XX series SoC.
+ The Designware USB2.0 high-speed gadget controller
+ integrated into many SoCs.
 
 config USB_S3C2410
tristate S3C2410 USB Device Controller
diff --git a/drivers/usb/gadget/s3c-hsotg.c b/drivers/usb/gadget/s3c-hsotg.c
index 33eb690..8ceb5ef 100644
--- a/drivers/usb/gadget/s3c-hsotg.c
+++ b/drivers/usb/gadget/s3c-hsotg.c
@@ -37,8 +37,6 @@
 #include linux/usb/phy.h
 #include linux/platform_data/s3c-hsotg.h
 
-#include mach/map.h
-
 #include s3c-hsotg.h
 
 static const char * const s3c_hsotg_supply_names[] = {
-- 
1.8.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 v6 1/9] phy: add phy_get_bus_width()/phy_set_bus_width() calls

2013-12-13 Thread Matt Porter
This adds a pair of APIs that allows the generic PHY subsystem to
provide information on the PHY bus width. The PHY provider driver may
use phy_set_bus_width() to set the bus width that the PHY supports.
The controller driver may then use phy_get_bus_width() to fetch the
PHY bus width in order to properly configure the controller.

Signed-off-by: Matt Porter mpor...@linaro.org
Acked-by: Kishon Vijay Abraham I kis...@ti.com
---
 include/linux/phy/phy.h | 28 
 1 file changed, 28 insertions(+)

diff --git a/include/linux/phy/phy.h b/include/linux/phy/phy.h
index 6d72269..e273e5a 100644
--- a/include/linux/phy/phy.h
+++ b/include/linux/phy/phy.h
@@ -38,6 +38,14 @@ struct phy_ops {
 };
 
 /**
+ * struct phy_attrs - represents phy attributes
+ * @bus_width: Data path width implemented by PHY
+ */
+struct phy_attrs {
+   u32 bus_width;
+};
+
+/**
  * struct phy - represents the phy device
  * @dev: phy device
  * @id: id of the phy device
@@ -46,6 +54,7 @@ struct phy_ops {
  * @mutex: mutex to protect phy_ops
  * @init_count: used to protect when the PHY is used by multiple consumers
  * @power_count: used to protect when the PHY is used by multiple consumers
+ * @phy_attrs: used to specify PHY specific attributes
  */
 struct phy {
struct device   dev;
@@ -55,6 +64,7 @@ struct phy {
struct mutexmutex;
int init_count;
int power_count;
+   struct phy_attrsattrs;
 };
 
 /**
@@ -127,6 +137,14 @@ int phy_init(struct phy *phy);
 int phy_exit(struct phy *phy);
 int phy_power_on(struct phy *phy);
 int phy_power_off(struct phy *phy);
+static inline int phy_get_bus_width(struct phy *phy)
+{
+   return phy-attrs.bus_width;
+}
+static inline void phy_set_bus_width(struct phy *phy, int bus_width)
+{
+   phy-attrs.bus_width = bus_width;
+}
 struct phy *phy_get(struct device *dev, const char *string);
 struct phy *devm_phy_get(struct device *dev, const char *string);
 void phy_put(struct phy *phy);
@@ -199,6 +217,16 @@ static inline int phy_power_off(struct phy *phy)
return -ENOSYS;
 }
 
+static inline int phy_get_bus_width(struct phy *phy)
+{
+   return -ENOSYS;
+}
+
+static inline void phy_set_bus_width(struct phy *phy, int bus_width)
+{
+   return;
+}
+
 static inline struct phy *phy_get(struct device *dev, const char *string)
 {
return ERR_PTR(-ENOSYS);
-- 
1.8.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 v6 4/9] usb: gadget: s3c-hsotg: add snps,dwc2 compatible string

2013-12-13 Thread Matt Porter
Enable support for the dwc2 binding.

Signed-off-by: Matt Porter mpor...@linaro.org
---
 drivers/usb/gadget/s3c-hsotg.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/usb/gadget/s3c-hsotg.c b/drivers/usb/gadget/s3c-hsotg.c
index 8ceb5ef..7c5d8bd 100644
--- a/drivers/usb/gadget/s3c-hsotg.c
+++ b/drivers/usb/gadget/s3c-hsotg.c
@@ -3727,6 +3727,7 @@ static int s3c_hsotg_remove(struct platform_device *pdev)
 #ifdef CONFIG_OF
 static const struct of_device_id s3c_hsotg_of_ids[] = {
{ .compatible = samsung,s3c6400-hsotg, },
+   { .compatible = snps,dwc2, },
{ /* sentinel */ }
 };
 MODULE_DEVICE_TABLE(of, s3c_hsotg_of_ids);
-- 
1.8.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 v6 2/9] staging: dwc2: update DT binding to add generic clock/phy properties

2013-12-13 Thread Matt Porter
dwc2/s3c-hsotg require a single clock to be specified and optionally
a generic phy. On the s3c-hsotg driver old style USB phy support is
present as a fallback so the generic phy properties are optional.

Signed-off-by: Matt Porter mpor...@linaro.org
Acked-by: Kishon Vijay Abraham I kis...@ti.com
---
 Documentation/devicetree/bindings/staging/dwc2.txt | 12 
 1 file changed, 12 insertions(+)

diff --git a/Documentation/devicetree/bindings/staging/dwc2.txt 
b/Documentation/devicetree/bindings/staging/dwc2.txt
index 1a1b7cf..a1753ed 100644
--- a/Documentation/devicetree/bindings/staging/dwc2.txt
+++ b/Documentation/devicetree/bindings/staging/dwc2.txt
@@ -5,6 +5,14 @@ Required properties:
 - compatible : snps,dwc2
 - reg : Should contain 1 register range (address and length)
 - interrupts : Should contain 1 interrupt
+- clocks: clock provider specifier
+- clock-names: shall be otg
+Refer to clk/clock-bindings.txt for generic clock consumer properties
+
+Optional properties:
+- phys: phy provider specifier
+- phy-names: shall be device
+Refer to phy/phy-bindings.txt for generic phy consumer properties
 
 Example:
 
@@ -12,4 +20,8 @@ Example:
 compatible = ralink,rt3050-usb, snps,dwc2;
 reg = 0x101c 4;
 interrupts = 18;
+   clocks = usb_otg_ahb_clk;
+   clock-names = otg;
+   phys = usbphy;
+   phy-names = usb2-phy;
 };
-- 
1.8.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 v4 9/9] ARM: dts: add usb udc support to bcm281xx

2013-12-12 Thread Matt Porter
Adds USB OTG/PHY and clock support to BCM281xx and enables
UDC support on the bcm11351-brt and bcm28155-ap boards.

Signed-off-by: Matt Porter mpor...@linaro.org
Reviewed-by: Markus Mayer markus.ma...@linaro.org
Reviewed-by: Tim Kryger tim.kry...@linaro.org
---
 arch/arm/boot/dts/bcm11351-brt.dts |  6 ++
 arch/arm/boot/dts/bcm11351.dtsi| 18 ++
 arch/arm/boot/dts/bcm28155-ap.dts  |  8 
 3 files changed, 32 insertions(+)

diff --git a/arch/arm/boot/dts/bcm11351-brt.dts 
b/arch/arm/boot/dts/bcm11351-brt.dts
index 23cd16d..396b704 100644
--- a/arch/arm/boot/dts/bcm11351-brt.dts
+++ b/arch/arm/boot/dts/bcm11351-brt.dts
@@ -44,5 +44,11 @@
status = okay;
};
 
+   usbotg: usb@3f12 {
+   status = okay;
+   };
 
+   usbphy: usb-phy@3f13 {
+   status = okay;
+   };
 };
diff --git a/arch/arm/boot/dts/bcm11351.dtsi b/arch/arm/boot/dts/bcm11351.dtsi
index 1246885..0fbb455 100644
--- a/arch/arm/boot/dts/bcm11351.dtsi
+++ b/arch/arm/boot/dts/bcm11351.dtsi
@@ -243,4 +243,22 @@
#clock-cells = 0;
};
};
+
+   usbotg: usb@3f12 {
+   compatible = snps,dwc2;
+   reg = 0x3f12 0x1;
+   interrupts = GIC_SPI 47 IRQ_TYPE_LEVEL_HIGH;
+   clocks = usb_otg_ahb_clk;
+   clock-names = otg;
+   phys = usbphy;
+   phy-names = usb2-phy;
+   status = disabled;
+   };
+
+   usbphy: usb-phy@3f13 {
+   compatible = brcm,kona-usb2-phy;
+   reg = 0x3f13 0x28;
+   #phy-cells = 0;
+   status = disabled;
+   };
 };
diff --git a/arch/arm/boot/dts/bcm28155-ap.dts 
b/arch/arm/boot/dts/bcm28155-ap.dts
index 08e47c2..a3bc436 100644
--- a/arch/arm/boot/dts/bcm28155-ap.dts
+++ b/arch/arm/boot/dts/bcm28155-ap.dts
@@ -43,4 +43,12 @@
cd-gpios = gpio 14 0;
status = okay;
};
+
+   usbotg: usb@3f12 {
+   status = okay;
+   };
+
+   usbphy: usb-phy@3f13 {
+   status = okay;
+   };
 };
-- 
1.8.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 v4 6/9] usb: gadget: s3c-hsotg: get phy bus width from phy subsystem

2013-12-12 Thread Matt Porter
Adds support for querying the phy bus width from the generic phy
subsystem. Configure UTMI bus width in GUSBCFG based on this value.

Signed-off-by: Matt Porter mpor...@linaro.org
---
 drivers/usb/gadget/s3c-hsotg.c | 14 +-
 drivers/usb/gadget/s3c-hsotg.h |  1 +
 2 files changed, 14 insertions(+), 1 deletion(-)

diff --git a/drivers/usb/gadget/s3c-hsotg.c b/drivers/usb/gadget/s3c-hsotg.c
index e9683c2..168aaa9 100644
--- a/drivers/usb/gadget/s3c-hsotg.c
+++ b/drivers/usb/gadget/s3c-hsotg.c
@@ -144,6 +144,7 @@ struct s3c_hsotg_ep {
  * @regs: The memory area mapped for accessing registers.
  * @irq: The IRQ number we are using
  * @supplies: Definition of USB power supplies
+ * @phyif: PHY interface width
  * @dedicated_fifos: Set if the hardware has dedicated IN-EP fifos.
  * @num_of_eps: Number of available EPs (excluding EP0)
  * @debug_root: root directrory for debugfs.
@@ -171,6 +172,7 @@ struct s3c_hsotg {
 
struct regulator_bulk_data supplies[ARRAY_SIZE(s3c_hsotg_supply_names)];
 
+   u32 phyif;
unsigned intdedicated_fifos:1;
unsigned char   num_of_eps;
 
@@ -2276,7 +2278,7 @@ static void s3c_hsotg_core_init(struct s3c_hsotg *hsotg)
 */
 
/* set the PLL on, remove the HNP/SRP and set the PHY */
-   writel(GUSBCFG_PHYIf16 | GUSBCFG_TOutCal(7) |
+   writel(hsotg-phyif | GUSBCFG_TOutCal(7) |
   (0x5  10), hsotg-regs + GUSBCFG);
 
s3c_hsotg_init_fifo(hsotg);
@@ -3621,6 +3623,16 @@ static int s3c_hsotg_probe(struct platform_device *pdev)
goto err_supplies;
}
 
+   /* Set default UTMI width */
+   hsotg-phyif = GUSBCFG_PHYIf16;
+
+   /*
+* If using the generic PHY framework, check if the PHY bus
+* width is 8-bit and set the phyif appropriately.
+*/
+   if (hsotg-phy  (phy_get_bus_width(phy) == 8))
+   hsotg-phyif = GUSBCFG_PHYIf8;
+
if (hsotg-phy)
phy_init(hsotg-phy);
 
diff --git a/drivers/usb/gadget/s3c-hsotg.h b/drivers/usb/gadget/s3c-hsotg.h
index d650b12..85f549f 100644
--- a/drivers/usb/gadget/s3c-hsotg.h
+++ b/drivers/usb/gadget/s3c-hsotg.h
@@ -55,6 +55,7 @@
 #define GUSBCFG_HNPCap (1  9)
 #define GUSBCFG_SRPCap (1  8)
 #define GUSBCFG_PHYIf16(1  3)
+#define GUSBCFG_PHYIf8 (0  3)
 #define GUSBCFG_TOutCal_MASK   (0x7  0)
 #define GUSBCFG_TOutCal_SHIFT  (0)
 #define GUSBCFG_TOutCal_LIMIT  (0x7)
-- 
1.8.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 v4 8/9] phy: add Broadcom Kona USB2 PHY driver

2013-12-12 Thread Matt Porter
Add a driver for the internal Broadcom Kona USB 2.0 PHY found
on the BCM281xx family of SoCs.

Signed-off-by: Matt Porter mpor...@linaro.org
---
 drivers/phy/Kconfig |   6 ++
 drivers/phy/Makefile|   1 +
 drivers/phy/phy-bcm-kona-usb2.c | 158 
 3 files changed, 165 insertions(+)
 create mode 100644 drivers/phy/phy-bcm-kona-usb2.c

diff --git a/drivers/phy/Kconfig b/drivers/phy/Kconfig
index a344f3d..2e87fa8 100644
--- a/drivers/phy/Kconfig
+++ b/drivers/phy/Kconfig
@@ -51,4 +51,10 @@ config PHY_EXYNOS_DP_VIDEO
help
  Support for Display Port PHY found on Samsung EXYNOS SoCs.
 
+config BCM_KONA_USB2_PHY
+   tristate Broadcom Kona USB2 PHY Driver
+   depends on GENERIC_PHY
+   help
+ Enable this to support the Broadcom Kona USB 2.0 PHY.
+
 endmenu
diff --git a/drivers/phy/Makefile b/drivers/phy/Makefile
index d0caae9..c447f1a 100644
--- a/drivers/phy/Makefile
+++ b/drivers/phy/Makefile
@@ -3,6 +3,7 @@
 #
 
 obj-$(CONFIG_GENERIC_PHY)  += phy-core.o
+obj-$(CONFIG_BCM_KONA_USB2_PHY)+= phy-bcm-kona-usb2.o
 obj-$(CONFIG_PHY_EXYNOS_DP_VIDEO)  += phy-exynos-dp-video.o
 obj-$(CONFIG_PHY_EXYNOS_MIPI_VIDEO)+= phy-exynos-mipi-video.o
 obj-$(CONFIG_OMAP_USB2)+= phy-omap-usb2.o
diff --git a/drivers/phy/phy-bcm-kona-usb2.c b/drivers/phy/phy-bcm-kona-usb2.c
new file mode 100644
index 000..0046781
--- /dev/null
+++ b/drivers/phy/phy-bcm-kona-usb2.c
@@ -0,0 +1,158 @@
+/*
+ * phy-bcm-kona-usb2.c - Broadcom Kona USB2 Phy Driver
+ *
+ * Copyright (C) 2013 Linaro Limited
+ * Matt Porter mpor...@linaro.org
+ *
+ * This software is licensed under the terms of the GNU General Public
+ * License version 2, as published by the Free Software Foundation, and
+ * may be copied, distributed, and modified under those terms.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ */
+
+#include linux/clk.h
+#include linux/delay.h
+#include linux/err.h
+#include linux/io.h
+#include linux/module.h
+#include linux/of.h
+#include linux/phy/phy.h
+#include linux/platform_device.h
+
+#define OTGCTL (0)
+#define OTGCTL_OTGSTAT2BIT(31)
+#define OTGCTL_OTGSTAT1BIT(30)
+#define OTGCTL_PRST_N_SW   BIT(11)
+#define OTGCTL_HRESET_NBIT(10)
+#define OTGCTL_UTMI_LINE_STATE1BIT(9)
+#define OTGCTL_UTMI_LINE_STATE0BIT(8)
+
+#define P1CTL  (8)
+#define P1CTL_SOFT_RESET   BIT(1)
+#define P1CTL_NON_DRIVING  BIT(0)
+
+struct bcm_kona_usb {
+   void __iomem *regs;
+};
+
+static void bcm_kona_usb_phy_power(struct bcm_kona_usb *phy, int on)
+{
+   u32 val;
+
+   val = readl(phy-regs + OTGCTL);
+   if (on) {
+   /* Configure and power PHY */
+   val = ~(OTGCTL_OTGSTAT2 | OTGCTL_OTGSTAT1 |
+OTGCTL_UTMI_LINE_STATE1 | OTGCTL_UTMI_LINE_STATE0);
+   val |= OTGCTL_PRST_N_SW | OTGCTL_HRESET_N;
+   } else {
+   val = ~(OTGCTL_PRST_N_SW | OTGCTL_HRESET_N);
+   }
+   writel(val, phy-regs + OTGCTL);
+}
+
+static int bcm_kona_usb_phy_init(struct phy *gphy)
+{
+   struct bcm_kona_usb *phy = phy_get_drvdata(gphy);
+   u32 val;
+
+   /* Soft reset PHY */
+   val = readl(phy-regs + P1CTL);
+   val = ~P1CTL_NON_DRIVING;
+   val |= P1CTL_SOFT_RESET;
+   writel(val, phy-regs + P1CTL);
+   writel(val  ~P1CTL_SOFT_RESET, phy-regs + P1CTL);
+   /* Reset needs to be asserted for 2ms */
+   mdelay(2);
+   writel(val | P1CTL_SOFT_RESET, phy-regs + P1CTL);
+
+   return 0;
+}
+
+static int bcm_kona_usb_phy_power_on(struct phy *gphy)
+{
+   struct bcm_kona_usb *phy = phy_get_drvdata(gphy);
+
+   bcm_kona_usb_phy_power(phy, 1);
+
+   return 0;
+}
+
+static int bcm_kona_usb_phy_power_off(struct phy *gphy)
+{
+   struct bcm_kona_usb *phy = phy_get_drvdata(gphy);
+
+   bcm_kona_usb_phy_power(phy, 0);
+
+   return 0;
+}
+
+static struct phy_ops ops = {
+   .init   = bcm_kona_usb_phy_init,
+   .power_on   = bcm_kona_usb_phy_power_on,
+   .power_off  = bcm_kona_usb_phy_power_off,
+   .owner  = THIS_MODULE,
+};
+
+static int bcm_kona_usb2_probe(struct platform_device *pdev)
+{
+   struct device *dev = pdev-dev;
+   struct bcm_kona_usb *phy;
+   struct resource *res;
+   struct phy *gphy;
+   struct phy_provider *phy_provider;
+
+   phy = devm_kzalloc(dev, sizeof(*phy), GFP_KERNEL);
+   if (!phy)
+   return -ENOMEM;
+
+   res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
+   phy-regs = devm_ioremap_resource(pdev-dev, res);
+   if (IS_ERR(phy-regs))
+   return

[PATCH v4 3/9] usb: gadget: s3c-hsotg: enable build for other platforms

2013-12-12 Thread Matt Porter
Remove unused Samsung-specific machine include and Kconfig
dependency on S3C.

Signed-off-by: Matt Porter mpor...@linaro.org
Reviewed-by: Markus Mayer markus.ma...@linaro.org
Reviewed-by: Tim Kryger tim.kry...@linaro.org
---
 drivers/usb/gadget/Kconfig | 7 +++
 drivers/usb/gadget/s3c-hsotg.c | 2 --
 2 files changed, 3 insertions(+), 6 deletions(-)

diff --git a/drivers/usb/gadget/Kconfig b/drivers/usb/gadget/Kconfig
index a91e642..970bd1a 100644
--- a/drivers/usb/gadget/Kconfig
+++ b/drivers/usb/gadget/Kconfig
@@ -294,11 +294,10 @@ config USB_PXA27X
   gadget drivers to also be dynamically linked.
 
 config USB_S3C_HSOTG
-   tristate S3C HS/OtG USB Device controller
-   depends on S3C_DEV_USB_HSOTG
+   tristate Designware/S3C HS/OtG USB Device controller
help
- The Samsung S3C64XX USB2.0 high-speed gadget controller
- integrated into the S3C64XX series SoC.
+ The Designware USB2.0 high-speed gadget controller
+ integrated into the S3C64XX and BCM281xx series SoC.
 
 config USB_S3C2410
tristate S3C2410 USB Device Controller
diff --git a/drivers/usb/gadget/s3c-hsotg.c b/drivers/usb/gadget/s3c-hsotg.c
index 33eb690..8ceb5ef 100644
--- a/drivers/usb/gadget/s3c-hsotg.c
+++ b/drivers/usb/gadget/s3c-hsotg.c
@@ -37,8 +37,6 @@
 #include linux/usb/phy.h
 #include linux/platform_data/s3c-hsotg.h
 
-#include mach/map.h
-
 #include s3c-hsotg.h
 
 static const char * const s3c_hsotg_supply_names[] = {
-- 
1.8.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 v4 4/9] usb: gadget: s3c-hsotg: add snps,dwc2 compatible string

2013-12-12 Thread Matt Porter
Enable support for the dwc2 binding.

Signed-off-by: Matt Porter mpor...@linaro.org
---
 drivers/usb/gadget/s3c-hsotg.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/usb/gadget/s3c-hsotg.c b/drivers/usb/gadget/s3c-hsotg.c
index 8ceb5ef..7c5d8bd 100644
--- a/drivers/usb/gadget/s3c-hsotg.c
+++ b/drivers/usb/gadget/s3c-hsotg.c
@@ -3727,6 +3727,7 @@ static int s3c_hsotg_remove(struct platform_device *pdev)
 #ifdef CONFIG_OF
 static const struct of_device_id s3c_hsotg_of_ids[] = {
{ .compatible = samsung,s3c6400-hsotg, },
+   { .compatible = snps,dwc2, },
{ /* sentinel */ }
 };
 MODULE_DEVICE_TABLE(of, s3c_hsotg_of_ids);
-- 
1.8.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 v4 0/9] USB Device Controller support for BCM281xx

2013-12-12 Thread Matt Porter
Changes since v3:
- Rebased on 3.13-rc3
- Move struct phy bus_width attribute back into struct phy_attrs
- Fix build issue on !GENERIC_PHY
- Update dwc2 binding to reflect optional phy properties
- Rename bcm-kona-phy.txt binding to bcm-phy.txt
- Reorder bcm kona phy includes and use bitops
- phy-names changed to usb2-phy to match updated s3c-hsotg
  generic phy-ification series

Changes since v2:
- Rebased on 3.13-rc1
- Fix braces in phy_get_bus_width()/phy_set_bus_width()
- Drop generic phy conversion to use the same support from
  the Exynos generic phy conversion series
- Modify dts support to match the device phy name required
  in the v3 Exynos generic phy conversion
- Add s3c-hsotg phy_init/phy_exit support
- Fix typo on reg property in kona phy binding
- Replace phy driver reg struct with offset defines
- Move phy soft reset to phy driver init
- Fix dts node names to match ePAPR conventions

Changes since v1:
- Convert USB phy driver to generic phy subsystem
- Add phy bus width apis
- Drop dwc2 phy bus width DT property in favor of querying the
  phy provider for bus width
- Add generic phy/clock properties to dwc2 DT binding
- Add generic phy subsystem support to s3c-hsotg with the
  existing usb phy and pdata phy methods as a fallback
- Split bindings out to separate patches to match the latest
  DT binding review guidelines

This series adds USB Device Controller support for the Broadcom
BCM281xx family of parts. BCM281xx contains a DWC2 OTG block and
s3c-hsotg is used to support UDC operation.

Part 1 adds phy bus width support to the generic phy subsystem

Parts 2-6 allows s3c-hsotg to build on non-Samsung platforms, supports
the dwc2 binding, adds phy_init/phy_exit support, and supports fetching
phy bus width using the generic phy layer.

Parts 7-8 add a generic phy binding and driver for the BCM Kona USB PHY.

Part 9 adds the DT nodes to enable UDC support on both BCM281xx boards
in the kernel.

This series depends on:
- Update Kona drivers to use clocks v4 series
  https://lkml.org/lkml/2013/12/5/508
- Add new Exynos USB 2.0 PHY driver v4 series
  https://lkml.org/lkml/2013/12/5/166

Matt Porter (9):
  phy: add phy_get_bus_width()/phy_set_bus_width() calls
  staging: dwc2: update DT binding to add generic clock/phy properties
  usb: gadget: s3c-hsotg: enable build for other platforms
  usb: gadget: s3c-hsotg: add snps,dwc2 compatible string
  usb: gadget: s3c-hsotg: use generic phy_init()/phy_exit() support
  usb: gadget: s3c-hsotg: get phy bus width from phy subsystem
  phy: add Broadcom Kona USB2 PHY DT binding
  phy: add Broadcom Kona USB2 PHY driver
  ARM: dts: add usb udc support to bcm281xx

 Documentation/devicetree/bindings/phy/bcm-phy.txt  |  15 ++
 Documentation/devicetree/bindings/staging/dwc2.txt |  12 ++
 arch/arm/boot/dts/bcm11351-brt.dts |   6 +
 arch/arm/boot/dts/bcm11351.dtsi|  18 +++
 arch/arm/boot/dts/bcm28155-ap.dts  |   8 ++
 drivers/phy/Kconfig|   6 +
 drivers/phy/Makefile   |   1 +
 drivers/phy/phy-bcm-kona-usb2.c| 158 +
 drivers/usb/gadget/Kconfig |   7 +-
 drivers/usb/gadget/s3c-hsotg.c |  22 ++-
 drivers/usb/gadget/s3c-hsotg.h |   1 +
 include/linux/phy/phy.h|  28 
 12 files changed, 275 insertions(+), 7 deletions(-)
 create mode 100644 Documentation/devicetree/bindings/phy/bcm-phy.txt
 create mode 100644 drivers/phy/phy-bcm-kona-usb2.c

-- 
1.8.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 v4 2/9] staging: dwc2: update DT binding to add generic clock/phy properties

2013-12-12 Thread Matt Porter
dwc2/s3c-hsotg require a single clock to be specified and optionally
a generic phy. On the s3c-hsotg driver old style USB phy support is
present as a fallback so the generic phy properties are optional.

Signed-off-by: Matt Porter mpor...@linaro.org
Acked-by: Kishon Vijay Abraham I kis...@ti.com
---
 Documentation/devicetree/bindings/staging/dwc2.txt | 12 
 1 file changed, 12 insertions(+)

diff --git a/Documentation/devicetree/bindings/staging/dwc2.txt 
b/Documentation/devicetree/bindings/staging/dwc2.txt
index 1a1b7cf..a1753ed 100644
--- a/Documentation/devicetree/bindings/staging/dwc2.txt
+++ b/Documentation/devicetree/bindings/staging/dwc2.txt
@@ -5,6 +5,14 @@ Required properties:
 - compatible : snps,dwc2
 - reg : Should contain 1 register range (address and length)
 - interrupts : Should contain 1 interrupt
+- clocks: clock provider specifier
+- clock-names: shall be otg
+Refer to clk/clock-bindings.txt for generic clock consumer properties
+
+Optional properties:
+- phys: phy provider specifier
+- phy-names: shall be device
+Refer to phy/phy-bindings.txt for generic phy consumer properties
 
 Example:
 
@@ -12,4 +20,8 @@ Example:
 compatible = ralink,rt3050-usb, snps,dwc2;
 reg = 0x101c 4;
 interrupts = 18;
+   clocks = usb_otg_ahb_clk;
+   clock-names = otg;
+   phys = usbphy;
+   phy-names = usb2-phy;
 };
-- 
1.8.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 v4 1/9] phy: add phy_get_bus_width()/phy_set_bus_width() calls

2013-12-12 Thread Matt Porter
This adds a pair of APIs that allows the generic PHY subsystem to
provide information on the PHY bus width. The PHY provider driver may
use phy_set_bus_width() to set the bus width that the PHY supports.
The controller driver may then use phy_get_bus_width() to fetch the
PHY bus width in order to properly configure the controller.

Signed-off-by: Matt Porter mpor...@linaro.org
---
 include/linux/phy/phy.h | 28 
 1 file changed, 28 insertions(+)

diff --git a/include/linux/phy/phy.h b/include/linux/phy/phy.h
index 6d72269..a0dcf2d 100644
--- a/include/linux/phy/phy.h
+++ b/include/linux/phy/phy.h
@@ -38,6 +38,14 @@ struct phy_ops {
 };
 
 /**
+ * struct phy_attrs - represents phy attributes
+ * @bus_width: Data path width implemented by PHY
+ */
+struct phy_attrs {
+   u32 bus_width;
+};
+
+/**
  * struct phy - represents the phy device
  * @dev: phy device
  * @id: id of the phy device
@@ -46,6 +54,7 @@ struct phy_ops {
  * @mutex: mutex to protect phy_ops
  * @init_count: used to protect when the PHY is used by multiple consumers
  * @power_count: used to protect when the PHY is used by multiple consumers
+ * @phy_attrs: used to specify PHY specific attributes
  */
 struct phy {
struct device   dev;
@@ -55,6 +64,7 @@ struct phy {
struct mutexmutex;
int init_count;
int power_count;
+   struct phy_attrsattrs;
 };
 
 /**
@@ -127,6 +137,14 @@ int phy_init(struct phy *phy);
 int phy_exit(struct phy *phy);
 int phy_power_on(struct phy *phy);
 int phy_power_off(struct phy *phy);
+static inline u32 phy_get_bus_width(struct phy *phy)
+{
+   return phy-attrs.bus_width;
+}
+static inline void phy_set_bus_width(struct phy *phy, u32 bus_width)
+{
+   phy-attrs.bus_width = bus_width;
+}
 struct phy *phy_get(struct device *dev, const char *string);
 struct phy *devm_phy_get(struct device *dev, const char *string);
 void phy_put(struct phy *phy);
@@ -199,6 +217,16 @@ static inline int phy_power_off(struct phy *phy)
return -ENOSYS;
 }
 
+static inline u32 phy_get_bus_width(struct phy *phy)
+{
+   return -ENOSYS;
+}
+
+static inline void phy_set_bus_width(struct phy *phy, u32 bus_width)
+{
+   return;
+}
+
 static inline struct phy *phy_get(struct device *dev, const char *string)
 {
return ERR_PTR(-ENOSYS);
-- 
1.8.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 v4 5/9] usb: gadget: s3c-hsotg: use generic phy_init()/phy_exit() support

2013-12-12 Thread Matt Porter
If a generic phy is present, call phy_init()/phy_exit(). This supports
generic phys that must be soft reset before power on.

Signed-off-by: Matt Porter mpor...@linaro.org
---
 drivers/usb/gadget/s3c-hsotg.c | 5 +
 1 file changed, 5 insertions(+)

diff --git a/drivers/usb/gadget/s3c-hsotg.c b/drivers/usb/gadget/s3c-hsotg.c
index 7c5d8bd..e9683c2 100644
--- a/drivers/usb/gadget/s3c-hsotg.c
+++ b/drivers/usb/gadget/s3c-hsotg.c
@@ -3621,6 +3621,9 @@ static int s3c_hsotg_probe(struct platform_device *pdev)
goto err_supplies;
}
 
+   if (hsotg-phy)
+   phy_init(hsotg-phy);
+
/* usb phy enable */
s3c_hsotg_phy_enable(hsotg);
 
@@ -3714,6 +3717,8 @@ static int s3c_hsotg_remove(struct platform_device *pdev)
}
 
s3c_hsotg_phy_disable(hsotg);
+   if (hsotg-phy)
+   phy_exit(hsotg-phy);
clk_disable_unprepare(hsotg-clk);
 
return 0;
-- 
1.8.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 v4 7/9] phy: add Broadcom Kona USB2 PHY DT binding

2013-12-12 Thread Matt Porter
Add a binding that describes the Broadcom Kona USB2 PHY found
on the BCM281xx family of SoCs.

Signed-off-by: Matt Porter mpor...@linaro.org
Acked-by: Kishon Vijay Abraham I kis...@ti.com
---
 Documentation/devicetree/bindings/phy/bcm-phy.txt | 15 +++
 1 file changed, 15 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/phy/bcm-phy.txt

diff --git a/Documentation/devicetree/bindings/phy/bcm-phy.txt 
b/Documentation/devicetree/bindings/phy/bcm-phy.txt
new file mode 100644
index 000..3dc8b3d
--- /dev/null
+++ b/Documentation/devicetree/bindings/phy/bcm-phy.txt
@@ -0,0 +1,15 @@
+BROADCOM KONA USB2 PHY
+
+Required properties:
+ - compatible: brcm,kona-usb2-phy
+ - reg: offset and length of the PHY registers
+ - #phy-cells: must be 0
+Refer to phy/phy-bindings.txt for the generic PHY binding properties
+
+Example:
+
+   usbphy: usb-phy@3f13 {
+   compatible = brcm,kona-usb2-phy;
+   reg = 0x3f13 0x28;
+   #phy-cells = 0;
+   };
-- 
1.8.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


Re: [PATCH v4 1/9] phy: add phy_get_bus_width()/phy_set_bus_width() calls

2013-12-12 Thread Matt Porter
On Thu, Dec 12, 2013 at 11:27:15AM +, Russell King wrote:
 On Thu, Dec 12, 2013 at 06:18:29AM -0500, Matt Porter wrote:
   /**
  + * struct phy_attrs - represents phy attributes
  + * @bus_width: Data path width implemented by PHY
  + */
  +struct phy_attrs {
  +   u32 bus_width;
 
 Why u32?

Kishon suggested it and I changed it on this rev...forgetting about the
error path below.

   int phy_power_off(struct phy *phy);
  +static inline u32 phy_get_bus_width(struct phy *phy)
  +{
  +   return phy-attrs.bus_width;
 ...
   
  +static inline u32 phy_get_bus_width(struct phy *phy)
  +{
  +   return -ENOSYS;
 
 Why u32, especially as you're returning a negative number here.
 
 If the bus width is a small integer (I'm assuming you don't have up to
 2^30 bus signals) then what's wrong with it being an 'int' ?

Yes, very correct...it's expected to always be a small positive integer
value or zero (when not populated as it's optional). I agree it should
go back to 'int' especially due to the negative value when GENERIC_PHY
isn't enabled.

-Matt
--
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 v5 5/9] usb: gadget: s3c-hsotg: use generic phy_init()/phy_exit() support

2013-12-12 Thread Matt Porter
If a generic phy is present, call phy_init()/phy_exit(). This supports
generic phys that must be soft reset before power on.

Signed-off-by: Matt Porter mpor...@linaro.org
---
 drivers/usb/gadget/s3c-hsotg.c | 5 +
 1 file changed, 5 insertions(+)

diff --git a/drivers/usb/gadget/s3c-hsotg.c b/drivers/usb/gadget/s3c-hsotg.c
index 7c5d8bd..e9683c2 100644
--- a/drivers/usb/gadget/s3c-hsotg.c
+++ b/drivers/usb/gadget/s3c-hsotg.c
@@ -3621,6 +3621,9 @@ static int s3c_hsotg_probe(struct platform_device *pdev)
goto err_supplies;
}
 
+   if (hsotg-phy)
+   phy_init(hsotg-phy);
+
/* usb phy enable */
s3c_hsotg_phy_enable(hsotg);
 
@@ -3714,6 +3717,8 @@ static int s3c_hsotg_remove(struct platform_device *pdev)
}
 
s3c_hsotg_phy_disable(hsotg);
+   if (hsotg-phy)
+   phy_exit(hsotg-phy);
clk_disable_unprepare(hsotg-clk);
 
return 0;
-- 
1.8.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 v5 6/9] usb: gadget: s3c-hsotg: get phy bus width from phy subsystem

2013-12-12 Thread Matt Porter
Adds support for querying the phy bus width from the generic phy
subsystem. Configure UTMI bus width in GUSBCFG based on this value.

Signed-off-by: Matt Porter mpor...@linaro.org
---
 drivers/usb/gadget/s3c-hsotg.c | 14 +-
 drivers/usb/gadget/s3c-hsotg.h |  1 +
 2 files changed, 14 insertions(+), 1 deletion(-)

diff --git a/drivers/usb/gadget/s3c-hsotg.c b/drivers/usb/gadget/s3c-hsotg.c
index e9683c2..168aaa9 100644
--- a/drivers/usb/gadget/s3c-hsotg.c
+++ b/drivers/usb/gadget/s3c-hsotg.c
@@ -144,6 +144,7 @@ struct s3c_hsotg_ep {
  * @regs: The memory area mapped for accessing registers.
  * @irq: The IRQ number we are using
  * @supplies: Definition of USB power supplies
+ * @phyif: PHY interface width
  * @dedicated_fifos: Set if the hardware has dedicated IN-EP fifos.
  * @num_of_eps: Number of available EPs (excluding EP0)
  * @debug_root: root directrory for debugfs.
@@ -171,6 +172,7 @@ struct s3c_hsotg {
 
struct regulator_bulk_data supplies[ARRAY_SIZE(s3c_hsotg_supply_names)];
 
+   u32 phyif;
unsigned intdedicated_fifos:1;
unsigned char   num_of_eps;
 
@@ -2276,7 +2278,7 @@ static void s3c_hsotg_core_init(struct s3c_hsotg *hsotg)
 */
 
/* set the PLL on, remove the HNP/SRP and set the PHY */
-   writel(GUSBCFG_PHYIf16 | GUSBCFG_TOutCal(7) |
+   writel(hsotg-phyif | GUSBCFG_TOutCal(7) |
   (0x5  10), hsotg-regs + GUSBCFG);
 
s3c_hsotg_init_fifo(hsotg);
@@ -3621,6 +3623,16 @@ static int s3c_hsotg_probe(struct platform_device *pdev)
goto err_supplies;
}
 
+   /* Set default UTMI width */
+   hsotg-phyif = GUSBCFG_PHYIf16;
+
+   /*
+* If using the generic PHY framework, check if the PHY bus
+* width is 8-bit and set the phyif appropriately.
+*/
+   if (hsotg-phy  (phy_get_bus_width(phy) == 8))
+   hsotg-phyif = GUSBCFG_PHYIf8;
+
if (hsotg-phy)
phy_init(hsotg-phy);
 
diff --git a/drivers/usb/gadget/s3c-hsotg.h b/drivers/usb/gadget/s3c-hsotg.h
index d650b12..85f549f 100644
--- a/drivers/usb/gadget/s3c-hsotg.h
+++ b/drivers/usb/gadget/s3c-hsotg.h
@@ -55,6 +55,7 @@
 #define GUSBCFG_HNPCap (1  9)
 #define GUSBCFG_SRPCap (1  8)
 #define GUSBCFG_PHYIf16(1  3)
+#define GUSBCFG_PHYIf8 (0  3)
 #define GUSBCFG_TOutCal_MASK   (0x7  0)
 #define GUSBCFG_TOutCal_SHIFT  (0)
 #define GUSBCFG_TOutCal_LIMIT  (0x7)
-- 
1.8.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 v5 7/9] phy: add Broadcom Kona USB2 PHY DT binding

2013-12-12 Thread Matt Porter
Add a binding that describes the Broadcom Kona USB2 PHY found
on the BCM281xx family of SoCs.

Signed-off-by: Matt Porter mpor...@linaro.org
Acked-by: Kishon Vijay Abraham I kis...@ti.com
---
 Documentation/devicetree/bindings/phy/bcm-phy.txt | 15 +++
 1 file changed, 15 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/phy/bcm-phy.txt

diff --git a/Documentation/devicetree/bindings/phy/bcm-phy.txt 
b/Documentation/devicetree/bindings/phy/bcm-phy.txt
new file mode 100644
index 000..3dc8b3d
--- /dev/null
+++ b/Documentation/devicetree/bindings/phy/bcm-phy.txt
@@ -0,0 +1,15 @@
+BROADCOM KONA USB2 PHY
+
+Required properties:
+ - compatible: brcm,kona-usb2-phy
+ - reg: offset and length of the PHY registers
+ - #phy-cells: must be 0
+Refer to phy/phy-bindings.txt for the generic PHY binding properties
+
+Example:
+
+   usbphy: usb-phy@3f13 {
+   compatible = brcm,kona-usb2-phy;
+   reg = 0x3f13 0x28;
+   #phy-cells = 0;
+   };
-- 
1.8.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 v5 2/9] staging: dwc2: update DT binding to add generic clock/phy properties

2013-12-12 Thread Matt Porter
dwc2/s3c-hsotg require a single clock to be specified and optionally
a generic phy. On the s3c-hsotg driver old style USB phy support is
present as a fallback so the generic phy properties are optional.

Signed-off-by: Matt Porter mpor...@linaro.org
Acked-by: Kishon Vijay Abraham I kis...@ti.com
---
 Documentation/devicetree/bindings/staging/dwc2.txt | 12 
 1 file changed, 12 insertions(+)

diff --git a/Documentation/devicetree/bindings/staging/dwc2.txt 
b/Documentation/devicetree/bindings/staging/dwc2.txt
index 1a1b7cf..a1753ed 100644
--- a/Documentation/devicetree/bindings/staging/dwc2.txt
+++ b/Documentation/devicetree/bindings/staging/dwc2.txt
@@ -5,6 +5,14 @@ Required properties:
 - compatible : snps,dwc2
 - reg : Should contain 1 register range (address and length)
 - interrupts : Should contain 1 interrupt
+- clocks: clock provider specifier
+- clock-names: shall be otg
+Refer to clk/clock-bindings.txt for generic clock consumer properties
+
+Optional properties:
+- phys: phy provider specifier
+- phy-names: shall be device
+Refer to phy/phy-bindings.txt for generic phy consumer properties
 
 Example:
 
@@ -12,4 +20,8 @@ Example:
 compatible = ralink,rt3050-usb, snps,dwc2;
 reg = 0x101c 4;
 interrupts = 18;
+   clocks = usb_otg_ahb_clk;
+   clock-names = otg;
+   phys = usbphy;
+   phy-names = usb2-phy;
 };
-- 
1.8.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 v5 1/9] phy: add phy_get_bus_width()/phy_set_bus_width() calls

2013-12-12 Thread Matt Porter
This adds a pair of APIs that allows the generic PHY subsystem to
provide information on the PHY bus width. The PHY provider driver may
use phy_set_bus_width() to set the bus width that the PHY supports.
The controller driver may then use phy_get_bus_width() to fetch the
PHY bus width in order to properly configure the controller.

Signed-off-by: Matt Porter mpor...@linaro.org
---
 include/linux/phy/phy.h | 28 
 1 file changed, 28 insertions(+)

diff --git a/include/linux/phy/phy.h b/include/linux/phy/phy.h
index 6d72269..e273e5a 100644
--- a/include/linux/phy/phy.h
+++ b/include/linux/phy/phy.h
@@ -38,6 +38,14 @@ struct phy_ops {
 };
 
 /**
+ * struct phy_attrs - represents phy attributes
+ * @bus_width: Data path width implemented by PHY
+ */
+struct phy_attrs {
+   u32 bus_width;
+};
+
+/**
  * struct phy - represents the phy device
  * @dev: phy device
  * @id: id of the phy device
@@ -46,6 +54,7 @@ struct phy_ops {
  * @mutex: mutex to protect phy_ops
  * @init_count: used to protect when the PHY is used by multiple consumers
  * @power_count: used to protect when the PHY is used by multiple consumers
+ * @phy_attrs: used to specify PHY specific attributes
  */
 struct phy {
struct device   dev;
@@ -55,6 +64,7 @@ struct phy {
struct mutexmutex;
int init_count;
int power_count;
+   struct phy_attrsattrs;
 };
 
 /**
@@ -127,6 +137,14 @@ int phy_init(struct phy *phy);
 int phy_exit(struct phy *phy);
 int phy_power_on(struct phy *phy);
 int phy_power_off(struct phy *phy);
+static inline int phy_get_bus_width(struct phy *phy)
+{
+   return phy-attrs.bus_width;
+}
+static inline void phy_set_bus_width(struct phy *phy, int bus_width)
+{
+   phy-attrs.bus_width = bus_width;
+}
 struct phy *phy_get(struct device *dev, const char *string);
 struct phy *devm_phy_get(struct device *dev, const char *string);
 void phy_put(struct phy *phy);
@@ -199,6 +217,16 @@ static inline int phy_power_off(struct phy *phy)
return -ENOSYS;
 }
 
+static inline int phy_get_bus_width(struct phy *phy)
+{
+   return -ENOSYS;
+}
+
+static inline void phy_set_bus_width(struct phy *phy, int bus_width)
+{
+   return;
+}
+
 static inline struct phy *phy_get(struct device *dev, const char *string)
 {
return ERR_PTR(-ENOSYS);
-- 
1.8.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 v5 0/9] USB Device Controller support for BCM281xx

2013-12-12 Thread Matt Porter
Changes since v4:
- phy_set/get_bus_width now use an int for bus_width

Changes since v3:
- Rebased on 3.13-rc3
- Move struct phy bus_width attribute back into struct phy_attrs
- Fix build issue on !GENERIC_PHY
- Update dwc2 binding to reflect optional phy properties
- Rename bcm-kona-phy.txt binding to bcm-phy.txt
- Reorder bcm kona phy includes and use bitops
- phy-names changed to usb2-phy to match updated s3c-hsotg
  generic phy-ification series

Changes since v2:
- Rebased on 3.13-rc1
- Fix braces in phy_get_bus_width()/phy_set_bus_width()
- Drop generic phy conversion to use the same support from
  the Exynos generic phy conversion series
- Modify dts support to match the device phy name required
  in the v3 Exynos generic phy conversion
- Add s3c-hsotg phy_init/phy_exit support
- Fix typo on reg property in kona phy binding
- Replace phy driver reg struct with offset defines
- Move phy soft reset to phy driver init
- Fix dts node names to match ePAPR conventions

Changes since v1:
- Convert USB phy driver to generic phy subsystem
- Add phy bus width apis
- Drop dwc2 phy bus width DT property in favor of querying the
  phy provider for bus width
- Add generic phy/clock properties to dwc2 DT binding
- Add generic phy subsystem support to s3c-hsotg with the
  existing usb phy and pdata phy methods as a fallback
- Split bindings out to separate patches to match the latest
  DT binding review guidelines

This series adds USB Device Controller support for the Broadcom
BCM281xx family of parts. BCM281xx contains a DWC2 OTG block and
s3c-hsotg is used to support UDC operation.

Part 1 adds phy bus width support to the generic phy subsystem

Parts 2-6 allows s3c-hsotg to build on non-Samsung platforms, supports
the dwc2 binding, adds phy_init/phy_exit support, and supports fetching
phy bus width using the generic phy layer.

Parts 7-8 add a generic phy binding and driver for the BCM Kona USB PHY.

Part 9 adds the DT nodes to enable UDC support on both BCM281xx boards
in the kernel.

This series depends on:
- Update Kona drivers to use clocks v4 series
  https://lkml.org/lkml/2013/12/5/508
- Add new Exynos USB 2.0 PHY driver v4 series
  https://lkml.org/lkml/2013/12/5/166

Matt Porter (9):
  phy: add phy_get_bus_width()/phy_set_bus_width() calls
  staging: dwc2: update DT binding to add generic clock/phy properties
  usb: gadget: s3c-hsotg: enable build for other platforms
  usb: gadget: s3c-hsotg: add snps,dwc2 compatible string
  usb: gadget: s3c-hsotg: use generic phy_init()/phy_exit() support
  usb: gadget: s3c-hsotg: get phy bus width from phy subsystem
  phy: add Broadcom Kona USB2 PHY DT binding
  phy: add Broadcom Kona USB2 PHY driver
  ARM: dts: add usb udc support to bcm281xx

 Documentation/devicetree/bindings/phy/bcm-phy.txt  |  15 ++
 Documentation/devicetree/bindings/staging/dwc2.txt |  12 ++
 arch/arm/boot/dts/bcm11351-brt.dts |   6 +
 arch/arm/boot/dts/bcm11351.dtsi|  18 +++
 arch/arm/boot/dts/bcm28155-ap.dts  |   8 ++
 drivers/phy/Kconfig|   6 +
 drivers/phy/Makefile   |   1 +
 drivers/phy/phy-bcm-kona-usb2.c| 158 +
 drivers/usb/gadget/Kconfig |   7 +-
 drivers/usb/gadget/s3c-hsotg.c |  22 ++-
 drivers/usb/gadget/s3c-hsotg.h |   1 +
 include/linux/phy/phy.h|  28 
 12 files changed, 275 insertions(+), 7 deletions(-)
 create mode 100644 Documentation/devicetree/bindings/phy/bcm-phy.txt
 create mode 100644 drivers/phy/phy-bcm-kona-usb2.c

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


Re: [PATCH v5 3/9] usb: gadget: s3c-hsotg: enable build for other platforms

2013-12-12 Thread Matt Porter
On Thu, Dec 12, 2013 at 03:51:31PM -0600, Dinh Nguyen wrote:
 Hi Matt,
 
 On 12/12/13 7:26 AM, Matt Porter wrote:
  Remove unused Samsung-specific machine include and Kconfig
  dependency on S3C.
 
  Signed-off-by: Matt Porter mpor...@linaro.org
  Reviewed-by: Markus Mayer markus.ma...@linaro.org
  Reviewed-by: Tim Kryger tim.kry...@linaro.org
  ---
   drivers/usb/gadget/Kconfig | 7 +++
   drivers/usb/gadget/s3c-hsotg.c | 2 --
   2 files changed, 3 insertions(+), 6 deletions(-)
 
  diff --git a/drivers/usb/gadget/Kconfig b/drivers/usb/gadget/Kconfig
  index a91e642..970bd1a 100644
  --- a/drivers/usb/gadget/Kconfig
  +++ b/drivers/usb/gadget/Kconfig
  @@ -294,11 +294,10 @@ config USB_PXA27X
 gadget drivers to also be dynamically linked.
   
   config USB_S3C_HSOTG
  -   tristate S3C HS/OtG USB Device controller
  -   depends on S3C_DEV_USB_HSOTG
  +   tristate Designware/S3C HS/OtG USB Device controller
  help
  - The Samsung S3C64XX USB2.0 high-speed gadget controller
  - integrated into the S3C64XX series SoC.
  + The Designware USB2.0 high-speed gadget controller
  + integrated into the S3C64XX and BCM281xx series SoC.
 Thanks for doing this. The SOCFPGA platform is also using this driver.
 So perhaps a
 more generic message here?

Ok, I wasn't aware since I didn't see anybody else try to fix this
driver in mainline. How about this?

The Designware USB2.0 high-speed gadget controller
integrated into many SoCS.

If that looks better to you I'll plan to add it in an update. I would
like to see if we can gather a couple acks at this point or if there are
any additional DT comments before sending another update.

-Matt

   
   config USB_S3C2410
  tristate S3C2410 USB Device Controller
  diff --git a/drivers/usb/gadget/s3c-hsotg.c b/drivers/usb/gadget/s3c-hsotg.c
  index 33eb690..8ceb5ef 100644
  --- a/drivers/usb/gadget/s3c-hsotg.c
  +++ b/drivers/usb/gadget/s3c-hsotg.c
  @@ -37,8 +37,6 @@
   #include linux/usb/phy.h
   #include linux/platform_data/s3c-hsotg.h
   
  -#include mach/map.h
  -
   #include s3c-hsotg.h
   
   static const char * const s3c_hsotg_supply_names[] = {
 
--
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 v4 5/9] usb: s3c-hsotg: Use the new Exynos USB phy driver with the generic phy framework

2013-12-11 Thread Matt Porter
On Thu, Dec 05, 2013 at 01:29:35PM +0100, Kamil Debski wrote:
 Change the used phy driver to the new Exynos USB phy driver that uses the
 generic phy framework.
 
 Signed-off-by: Kamil Debski k.deb...@samsung.com
 Signed-off-by: Kyungmin Park kyungmin.p...@samsung.com
 ---
  .../devicetree/bindings/usb/samsung-hsotg.txt  |4 
  drivers/usb/gadget/s3c-hsotg.c |   11 ++-
  2 files changed, 10 insertions(+), 5 deletions(-)

This is only applying with fuzz against -rc3, needs an update. It's
otherwise still working fine on my BCM Capri board.

-Matt
--
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 v4 5/9] usb: s3c-hsotg: Use the new Exynos USB phy driver with the generic phy framework

2013-12-06 Thread Matt Porter
On Fri, Dec 06, 2013 at 04:41:51PM +0530, Kishon Vijay Abraham I wrote:
 Hi,
 
 On Thursday 05 December 2013 05:59 PM, Kamil Debski wrote:
  Change the used phy driver to the new Exynos USB phy driver that uses the
  generic phy framework.
  
  Signed-off-by: Kamil Debski k.deb...@samsung.com
  Signed-off-by: Kyungmin Park kyungmin.p...@samsung.com
  ---
   .../devicetree/bindings/usb/samsung-hsotg.txt  |4 
   drivers/usb/gadget/s3c-hsotg.c |   11 ++-
   2 files changed, 10 insertions(+), 5 deletions(-)
  
  diff --git a/Documentation/devicetree/bindings/usb/samsung-hsotg.txt 
  b/Documentation/devicetree/bindings/usb/samsung-hsotg.txt
  index b83d428..9340d06 100644
  --- a/Documentation/devicetree/bindings/usb/samsung-hsotg.txt
  +++ b/Documentation/devicetree/bindings/usb/samsung-hsotg.txt
  @@ -24,6 +24,8 @@ Required properties:
   - first entry: must be otg
   - vusb_d-supply: phandle to voltage regulator of digital section,
   - vusb_a-supply: phandle to voltage regulator of analog section.
  +- phys: from general PHY binding: phandle to the PHY device
  +- phy-names: from general PHY binding: should be usb2-phy
 
 are you sure it's usb2-phy. The example below seems to have a different value.

I requested this be changed to usb2-phy, looks like he just missed the
update to the example.

 
   
   Example
   -
  @@ -36,5 +38,7 @@ Example
  clock-names = otg;
  vusb_d-supply = vusb_reg;
  vusb_a-supply = vusbdac_reg;
  +   phys = usb2phy 0;
  +   phy-names = device;
  };
   
  diff --git a/drivers/usb/gadget/s3c-hsotg.c b/drivers/usb/gadget/s3c-hsotg.c
  index eccb147..db096fd 100644
  --- a/drivers/usb/gadget/s3c-hsotg.c
  +++ b/drivers/usb/gadget/s3c-hsotg.c
  @@ -31,6 +31,7 @@
   #include linux/regulator/consumer.h
   #include linux/of.h
   #include linux/of_platform.h
  +#include linux/phy/phy.h
   
   #include linux/usb/ch9.h
   #include linux/usb/gadget.h
  @@ -162,7 +163,7 @@ struct s3c_hsotg_ep {
   struct s3c_hsotg {
  struct device*dev;
  struct usb_gadget_driver *driver;
  -   struct usb_phy  *phy;
  +   struct phy   *phy;
  struct s3c_hsotg_plat*plat;
   
  spinlock_t  lock;
  @@ -2905,7 +2906,7 @@ static void s3c_hsotg_phy_enable(struct s3c_hsotg 
  *hsotg)
  dev_dbg(hsotg-dev, pdev 0x%p\n, pdev);
   
  if (hsotg-phy)
  -   usb_phy_init(hsotg-phy);
  +   phy_power_on(hsotg-phy);
  else if (hsotg-plat-phy_init)
  hsotg-plat-phy_init(pdev, hsotg-plat-phy_type);
   }
  @@ -2922,7 +2923,7 @@ static void s3c_hsotg_phy_disable(struct s3c_hsotg 
  *hsotg)
  struct platform_device *pdev = to_platform_device(hsotg-dev);
   
  if (hsotg-phy)
  -   usb_phy_shutdown(hsotg-phy);
  +   phy_power_off(hsotg-phy);
  else if (hsotg-plat-phy_exit)
  hsotg-plat-phy_exit(pdev, hsotg-plat-phy_type);
   }
  @@ -3529,7 +3530,7 @@ static void s3c_hsotg_delete_debug(struct s3c_hsotg 
  *hsotg)
   static int s3c_hsotg_probe(struct platform_device *pdev)
   {
  struct s3c_hsotg_plat *plat = dev_get_platdata(pdev-dev);
  -   struct usb_phy *phy;
  +   struct phy *phy;
  struct device *dev = pdev-dev;
  struct s3c_hsotg_ep *eps;
  struct s3c_hsotg *hsotg;
  @@ -3544,7 +3545,7 @@ static int s3c_hsotg_probe(struct platform_device 
  *pdev)
  return -ENOMEM;
  }
   
  -   phy = devm_usb_get_phy(dev, USB_PHY_TYPE_USB2);
  +   phy = devm_phy_get(pdev-dev, usb2-phy);
  if (IS_ERR(phy)) {
  /* Fallback for pdata */
  plat = dev_get_platdata(pdev-dev);
  
 
--
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 v3 5/9] usb: gadget: s3c-hsotg: use generic phy_init()/phy_exit() support

2013-11-28 Thread Matt Porter
On Thu, Nov 28, 2013 at 11:23:52AM +0530, Kishon Vijay Abraham I wrote:
 On Thursday 28 November 2013 04:06 AM, Matt Porter wrote:
  On Wed, Nov 27, 2013 at 12:13:25PM -0500, Matt Porter wrote:
  On Tue, Nov 26, 2013 at 03:53:32PM +0530, Kishon Vijay Abraham I wrote:
  Hi,
 
  On Monday 25 November 2013 11:46 PM, Matt Porter wrote:
  If a generic phy is present, call phy_init()/phy_exit(). This supports
  generic phys that must be soft reset before power on.
 
  Signed-off-by: Matt Porter matt.por...@linaro.org
  ---
   drivers/usb/gadget/s3c-hsotg.c | 5 +
   1 file changed, 5 insertions(+)
 
  diff --git a/drivers/usb/gadget/s3c-hsotg.c 
  b/drivers/usb/gadget/s3c-hsotg.c
  index da3879b..8dfe33f 100644
  --- a/drivers/usb/gadget/s3c-hsotg.c
  +++ b/drivers/usb/gadget/s3c-hsotg.c
  @@ -3622,6 +3622,9 @@ static int s3c_hsotg_probe(struct platform_device 
  *pdev)
   goto err_supplies;
   }
   
  +if (hsotg-phy)
 
  IS_ERR? If your phy_get fails *phy* will have a error value..
 
  Yes, thanks. I'll fix these and also note that the same issue exists in
  Kamil's patch for these same hsotg-phy conditional uses. I'll work with
  Kamil to either get those addressed there or in a follow on fix.
  
  I spoke too soon. If devm_phy_get fails, we don't set hsotg-phy and probe
  defer thus not reaching this point. Since hsotg-phy is either NULL or a
  valid struct phy *, this is correct as is throughout the driver.
  
 
  +phy_init(hsotg-phy);
  +
   /* usb phy enable */
   s3c_hsotg_phy_enable(hsotg);
   
  @@ -3715,6 +3718,8 @@ static int s3c_hsotg_remove(struct platform_device 
  *pdev)
   }
   
   s3c_hsotg_phy_disable(hsotg);
  +if (hsotg-phy)
 
  same here.
 
  Ok.
  
  Same above, this will be NULL on failure (but is only applicable at this
  point on the platform data path.
 
 Ah ok.. Btw where is phy_get being called? Is it not part of this series?

It's in the Kamil's Exynos USB Phy - generic phy series [1] which I depend
on here. I mentioned it in the cover letter toward the end so it's a bit
buried.

I have some outstanding, but trivial, comments on that series but I hear
Kamil will be posting an update in the coming days. I'll wait a few days
to post v4 addressing your comments so I can hopefully rebase against
his updated s3c-hsotg patch.

-Matt

[1] https://lkml.org/lkml/2013/11/5/275
--
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 v3 1/9] phy: add phy_get_bus_width()/phy_set_bus_width() calls

2013-11-27 Thread Matt Porter
On Tue, Nov 26, 2013 at 03:46:26PM +0530, Kishon Vijay Abraham I wrote:
 Hi,
 
 On Monday 25 November 2013 11:45 PM, Matt Porter wrote:
  This adds a pair of APIs that allows the generic PHY subsystem to
  provide information on the PHY bus width. The PHY provider driver may
  use phy_set_bus_width() to set the bus width that the PHY supports.
  The controller driver may then use phy_get_bus_width() to fetch the
  PHY bus width in order to properly configure the controller.
  
  Signed-off-by: Matt Porter matt.por...@linaro.org
  ---
   include/linux/phy/phy.h | 20 
   1 file changed, 20 insertions(+)
  
  diff --git a/include/linux/phy/phy.h b/include/linux/phy/phy.h
  index 6d72269..6ca6c61 100644
  --- a/include/linux/phy/phy.h
  +++ b/include/linux/phy/phy.h
  @@ -46,6 +46,7 @@ struct phy_ops {
* @mutex: mutex to protect phy_ops
* @init_count: used to protect when the PHY is used by multiple consumers
* @power_count: used to protect when the PHY is used by multiple consumers
  + * @bus_width: used to specify data width of the PHY bus
*/
   struct phy {
  struct device   dev;
  @@ -55,6 +56,7 @@ struct phy {
  struct mutexmutex;
  int init_count;
  int power_count;
  +   int bus_width;
 
 the bus_width can be part of the attrs struct which you initially proposed.
 Soon there will be requests for other attributes being added (e.g., speed).

Agreed, I'll merge the accessors with the original attrs struct.

   };
   
   /**
  @@ -127,6 +129,14 @@ int phy_init(struct phy *phy);
   int phy_exit(struct phy *phy);
   int phy_power_on(struct phy *phy);
   int phy_power_off(struct phy *phy);
  +static inline int phy_get_bus_width(struct phy *phy)
  +{
  +   return phy-bus_width;
  +}
  +static inline void phy_set_bus_width(struct phy *phy, int bus_width)
 
 u32 bus_width?

will update

  +{
  +   phy-bus_width = bus_width;
  +}
   struct phy *phy_get(struct device *dev, const char *string);
   struct phy *devm_phy_get(struct device *dev, const char *string);
   void phy_put(struct phy *phy);
  @@ -199,6 +209,16 @@ static inline int phy_power_off(struct phy *phy)
  return -ENOSYS;
   }
   
  +static inline int phy_get_bus_width(struct phy *phy)
  +{
  +   return -ENOSYS;
  +}
  +
  +static inline void phy_set_bus_width(struct phy *phy, bus_width)
 
 er.. has this been compile tested?

*sigh* obviously not, will address this.

-Matt
--
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 v3 2/9] staging: dwc2: update DT binding to add generic clock/phy properties

2013-11-27 Thread Matt Porter
On Tue, Nov 26, 2013 at 03:49:30PM +0530, Kishon Vijay Abraham I wrote:
 On Monday 25 November 2013 11:46 PM, Matt Porter wrote:
  dwc2/s3c-hsotg require a single clock to be specified and optionally
  a generic phy. On the s3c-hsotg driver old style USB phy support is
  present as a fallback so the generic phy properties are optional.
  
  Signed-off-by: Matt Porter matt.por...@linaro.org
  ---
   Documentation/devicetree/bindings/staging/dwc2.txt | 10 ++
   1 file changed, 10 insertions(+)
  
  diff --git a/Documentation/devicetree/bindings/staging/dwc2.txt 
  b/Documentation/devicetree/bindings/staging/dwc2.txt
  index 1a1b7cf..b8b42b6 100644
  --- a/Documentation/devicetree/bindings/staging/dwc2.txt
  +++ b/Documentation/devicetree/bindings/staging/dwc2.txt
  @@ -5,6 +5,12 @@ Required properties:
   - compatible : snps,dwc2
   - reg : Should contain 1 register range (address and length)
   - interrupts : Should contain 1 interrupt
  +- clocks: clock provider specifier
  +- clock-names: shall be otg
  +- phys: phy provider specifier
  +- phy-names: shall be device
 
 lets mention in the Documentation too that the phy properties are optional.
 apart from that..

Good point, will do so.

 Acked-by: Kishon Vijay Abraham I kis...@ti.com
  +Refer to clk/clock-bindings.txt for generic clock consumer properties
  +Refer to phy/phy-bindings.txt for generic phy consumer properties
   
   Example:
   
  @@ -12,4 +18,8 @@ Example:
   compatible = ralink,rt3050-usb, snps,dwc2;
   reg = 0x101c 4;
   interrupts = 18;
  +   clocks = usb_otg_ahb_clk;
  +   clock-names = otg;
  +   phys = usbphy;
  +   phy-names = 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 v3 5/9] usb: gadget: s3c-hsotg: use generic phy_init()/phy_exit() support

2013-11-27 Thread Matt Porter
On Tue, Nov 26, 2013 at 03:53:32PM +0530, Kishon Vijay Abraham I wrote:
 Hi,
 
 On Monday 25 November 2013 11:46 PM, Matt Porter wrote:
  If a generic phy is present, call phy_init()/phy_exit(). This supports
  generic phys that must be soft reset before power on.
  
  Signed-off-by: Matt Porter matt.por...@linaro.org
  ---
   drivers/usb/gadget/s3c-hsotg.c | 5 +
   1 file changed, 5 insertions(+)
  
  diff --git a/drivers/usb/gadget/s3c-hsotg.c b/drivers/usb/gadget/s3c-hsotg.c
  index da3879b..8dfe33f 100644
  --- a/drivers/usb/gadget/s3c-hsotg.c
  +++ b/drivers/usb/gadget/s3c-hsotg.c
  @@ -3622,6 +3622,9 @@ static int s3c_hsotg_probe(struct platform_device 
  *pdev)
  goto err_supplies;
  }
   
  +   if (hsotg-phy)
 
 IS_ERR? If your phy_get fails *phy* will have a error value..

Yes, thanks. I'll fix these and also note that the same issue exists in
Kamil's patch for these same hsotg-phy conditional uses. I'll work with
Kamil to either get those addressed there or in a follow on fix.

 
  +   phy_init(hsotg-phy);
  +
  /* usb phy enable */
  s3c_hsotg_phy_enable(hsotg);
   
  @@ -3715,6 +3718,8 @@ static int s3c_hsotg_remove(struct platform_device 
  *pdev)
  }
   
  s3c_hsotg_phy_disable(hsotg);
  +   if (hsotg-phy)
 
 same here.

Ok.

 
 Thanks
 Kishon
--
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 v3 6/9] usb: gadget: s3c-hsotg: get phy bus width from phy subsystem

2013-11-27 Thread Matt Porter
On Tue, Nov 26, 2013 at 03:58:45PM +0530, Kishon Vijay Abraham I wrote:
 Hi,
 
 On Monday 25 November 2013 11:46 PM, Matt Porter wrote:
  Adds support for querying the phy bus width from the generic phy
  subsystem. Configure UTMI bus width in GUSBCFG based on this value.
  
  Signed-off-by: Matt Porter matt.por...@linaro.org
  ---
   drivers/usb/gadget/s3c-hsotg.c | 14 +-
   drivers/usb/gadget/s3c-hsotg.h |  1 +
   2 files changed, 14 insertions(+), 1 deletion(-)
  
  diff --git a/drivers/usb/gadget/s3c-hsotg.c b/drivers/usb/gadget/s3c-hsotg.c
  index 8dfe33f..be41585 100644
  --- a/drivers/usb/gadget/s3c-hsotg.c
  +++ b/drivers/usb/gadget/s3c-hsotg.c
  @@ -144,6 +144,7 @@ struct s3c_hsotg_ep {
* @regs: The memory area mapped for accessing registers.
* @irq: The IRQ number we are using
* @supplies: Definition of USB power supplies
  + * @phyif: PHY interface width
* @dedicated_fifos: Set if the hardware has dedicated IN-EP fifos.
* @num_of_eps: Number of available EPs (excluding EP0)
* @debug_root: root directrory for debugfs.
  @@ -171,6 +172,7 @@ struct s3c_hsotg {
   
  struct regulator_bulk_data supplies[ARRAY_SIZE(s3c_hsotg_supply_names)];
   
  +   u32 phyif;
  unsigned intdedicated_fifos:1;
  unsigned char   num_of_eps;
   
  @@ -2276,7 +2278,7 @@ static void s3c_hsotg_core_init(struct s3c_hsotg 
  *hsotg)
   */
   
  /* set the PLL on, remove the HNP/SRP and set the PHY */
  -   writel(GUSBCFG_PHYIf16 | GUSBCFG_TOutCal(7) |
  +   writel(hsotg-phyif | GUSBCFG_TOutCal(7) |
 (0x5  10), hsotg-regs + GUSBCFG);
   
  s3c_hsotg_init_fifo(hsotg);
  @@ -3622,6 +3624,16 @@ static int s3c_hsotg_probe(struct platform_device 
  *pdev)
  goto err_supplies;
  }
   
  +   /* Set default UTMI width */
  +   hsotg-phyif = GUSBCFG_PHYIf16;
  +
  +   /*
  +* If using the generic PHY framework, check if the PHY bus
  +* width is 8-bit and set the phyif appropriately.
  +*/
  +   if (hsotg-phy  (phy_get_bus_width(phy) == 8))
 
 what if the phy has error value here?

I'm addressing this like the other !IS_ERR checks. In the platform data
case, we'll have an error value here, and need to use the default. Until
the platform data case is removed (those platform board files removed),
we assume (correctly) that they use a phy interface width of 16.

-Matt
--
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 v3 7/9] phy: add Broadcom Kona USB2 PHY DT binding

2013-11-27 Thread Matt Porter
On Tue, Nov 26, 2013 at 04:01:05PM +0530, Kishon Vijay Abraham I wrote:
 Hi,
 
 On Monday 25 November 2013 11:46 PM, Matt Porter wrote:
  Add a binding that describes the Broadcom Kona USB2 PHY found
  on the BCM281xx family of SoCs.
  
  Signed-off-by: Matt Porter matt.por...@linaro.org
  ---
   .../devicetree/bindings/phy/bcm-kona-usb2-phy.txt | 15 
  +++
   1 file changed, 15 insertions(+)
   create mode 100644 
  Documentation/devicetree/bindings/phy/bcm-kona-usb2-phy.txt
  
  diff --git a/Documentation/devicetree/bindings/phy/bcm-kona-usb2-phy.txt 
  b/Documentation/devicetree/bindings/phy/bcm-kona-usb2-phy.txt
  new file mode 100644
  index 000..3dc8b3d
  --- /dev/null
  +++ b/Documentation/devicetree/bindings/phy/bcm-kona-usb2-phy.txt
 
 you should name this bcm-phy. Then you can add binding info of all (future) 
 PHY
 IP from broadcom here.
 
 other than that this looks fine..

Ok, sounds reasonable. I've noticed that convention with the TI USB
bindings...I'll do the same.

 Acked-by: Kishon Vijay Abraham I kis...@ti.com
 
 Thanks
 Kishon
--
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 v3 8/9] phy: add Broadcom Kona USB2 PHY driver

2013-11-27 Thread Matt Porter
On Wed, Nov 27, 2013 at 02:21:52PM +0530, Kishon Vijay Abraham I wrote:
 Hi,
 
 On Monday 25 November 2013 11:46 PM, Matt Porter wrote:
  Add a driver for the internal Broadcom Kona USB 2.0 PHY found
  on the BCM281xx family of SoCs.
  
  Signed-off-by: Matt Porter matt.por...@linaro.org
  ---
   drivers/phy/Kconfig |   6 ++
   drivers/phy/Makefile|   1 +
   drivers/phy/phy-bcm-kona-usb2.c | 158 
  
   3 files changed, 165 insertions(+)
   create mode 100644 drivers/phy/phy-bcm-kona-usb2.c
  
  diff --git a/drivers/phy/Kconfig b/drivers/phy/Kconfig
  index a344f3d..2e87fa8 100644
  --- a/drivers/phy/Kconfig
  +++ b/drivers/phy/Kconfig
  @@ -51,4 +51,10 @@ config PHY_EXYNOS_DP_VIDEO
  help
Support for Display Port PHY found on Samsung EXYNOS SoCs.
   
  +config BCM_KONA_USB2_PHY
  +   tristate Broadcom Kona USB2 PHY Driver
  +   depends on GENERIC_PHY
  +   help
  + Enable this to support the Broadcom Kona USB 2.0 PHY.
  +
   endmenu
  diff --git a/drivers/phy/Makefile b/drivers/phy/Makefile
  index d0caae9..c447f1a 100644
  --- a/drivers/phy/Makefile
  +++ b/drivers/phy/Makefile
  @@ -3,6 +3,7 @@
   #
   
   obj-$(CONFIG_GENERIC_PHY)  += phy-core.o
  +obj-$(CONFIG_BCM_KONA_USB2_PHY)+= phy-bcm-kona-usb2.o
   obj-$(CONFIG_PHY_EXYNOS_DP_VIDEO)  += phy-exynos-dp-video.o
   obj-$(CONFIG_PHY_EXYNOS_MIPI_VIDEO)+= phy-exynos-mipi-video.o
   obj-$(CONFIG_OMAP_USB2)+= phy-omap-usb2.o
  diff --git a/drivers/phy/phy-bcm-kona-usb2.c 
  b/drivers/phy/phy-bcm-kona-usb2.c
  new file mode 100644
  index 000..2c54fb8
  --- /dev/null
  +++ b/drivers/phy/phy-bcm-kona-usb2.c
  @@ -0,0 +1,158 @@
  +/*
  + * phy-bcm-kona-usb2.c - Broadcom Kona USB2 Phy Driver
  + *
  + * Copyright (C) 2013 Linaro Limited
  + * Matt Porter matt.por...@linaro.org
  + *
  + * This software is licensed under the terms of the GNU General Public
  + * License version 2, as published by the Free Software Foundation, and
  + * may be copied, distributed, and modified under those terms.
  + *
  + * This program is distributed in the hope that it will be useful,
  + * but WITHOUT ANY WARRANTY; without even the implied warranty of
  + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  + * GNU General Public License for more details.
  + */
  +
  +#include linux/module.h
  +#include linux/of.h
  +#include linux/delay.h
  +#include linux/platform_device.h
  +#include linux/err.h
  +#include linux/io.h
  +#include linux/clk.h
  +#include linux/phy/phy.h
 
 arrange the headers in alphabetical order so that it's easy while adding new
 headers. Just my preference.

yeah, same here. just development creep that I will address.

  +
  +#define OTGCTL (0)
  +#define OTGCTL_OTGSTAT2(1  31)
  +#define OTGCTL_OTGSTAT1(1  30)
  +#define OTGCTL_PRST_N_SW   (1  11)
  +#define OTGCTL_HRESET_N(1  10)
  +#define OTGCTL_UTMI_LINE_STATE1(1  9)
  +#define OTGCTL_UTMI_LINE_STATE0(1  8)
  +
  +#define P1CTL  (8)
  +#define P1CTL_SOFT_RESET   (1  1)
  +#define P1CTL_NON_DRIVING  (1  0)
 
 you can use BIT() instead.

will do

  +
  +struct bcm_kona_usb {
  +   void __iomem *regs;
  +};
  +
  +static void bcm_kona_usb_phy_power(struct bcm_kona_usb *phy, int on)
  +{
  +   u32 val;
  +
  +   val = readl(phy-regs + OTGCTL);
  +   if (on) {
  +   /* Configure and power PHY */
  +   val = ~(OTGCTL_OTGSTAT2 | OTGCTL_OTGSTAT1 |
  +OTGCTL_UTMI_LINE_STATE1 | OTGCTL_UTMI_LINE_STATE0);
  +   val |= OTGCTL_PRST_N_SW | OTGCTL_HRESET_N;
  +   } else {
  +   val = ~(OTGCTL_PRST_N_SW | OTGCTL_HRESET_N);
  +   }
  +   writel(val, phy-regs + OTGCTL);
  +}
  +
  +static int bcm_kona_usb_phy_init(struct phy *gphy)
  +{
  +   struct bcm_kona_usb *phy = phy_get_drvdata(gphy);
  +   u32 val;
  +
  +   /* Soft reset PHY */
  +   val = readl(phy-regs + P1CTL);
  +   val = ~P1CTL_NON_DRIVING;
  +   val |= P1CTL_SOFT_RESET;
  +   writel(val, phy-regs + P1CTL);
  +   writel(val  ~P1CTL_SOFT_RESET, phy-regs + P1CTL);
  +   /* Reset needs to be asserted for 2ms */
  +   mdelay(2);
  +   writel(val | P1CTL_SOFT_RESET, phy-regs + P1CTL);
  +
  +   return 0;
  +}
  +
  +static int bcm_kona_usb_phy_power_on(struct phy *gphy)
  +{
  +   struct bcm_kona_usb *phy = phy_get_drvdata(gphy);
  +
  +   bcm_kona_usb_phy_power(phy, 1);
  +
  +   return 0;
  +}
  +
  +static int bcm_kona_usb_phy_power_off(struct phy *gphy)
  +{
  +   struct bcm_kona_usb *phy = phy_get_drvdata(gphy);
  +
  +   bcm_kona_usb_phy_power(phy, 0);
  +
  +   return 0;
  +}
  +
  +static struct phy_ops ops = {
  +   .init   = bcm_kona_usb_phy_init,
  +   .power_on   = bcm_kona_usb_phy_power_on,
  +   .power_off  = bcm_kona_usb_phy_power_off,
  +   .owner = THIS_MODULE,
 
 owner is aligned differently..

ok

  +};
  +
  +static int bcm_kona_usb2_probe(struct

Re: [PATCH v3 9/9] ARM: dts: add usb udc support to bcm281xx

2013-11-27 Thread Matt Porter
On Wed, Nov 27, 2013 at 02:27:19PM +0530, Kishon Vijay Abraham I wrote:
 Hi,
 
 On Monday 25 November 2013 11:46 PM, Matt Porter wrote:
  Adds USB OTG/PHY and clock support to BCM281xx and enables
  UDC support on the bcm11351-brt and bcm28155-ap boards.
  
  Signed-off-by: Matt Porter matt.por...@linaro.org
  Reviewed-by: Markus Mayer markus.ma...@linaro.org
  Reviewed-by: Tim Kryger tim.kry...@linaro.org
  ---
   arch/arm/boot/dts/bcm11351-brt.dts |  6 ++
   arch/arm/boot/dts/bcm11351.dtsi| 18 ++
   arch/arm/boot/dts/bcm28155-ap.dts  |  8 
   3 files changed, 32 insertions(+)
  
  diff --git a/arch/arm/boot/dts/bcm11351-brt.dts 
  b/arch/arm/boot/dts/bcm11351-brt.dts
  index 23cd16d..396b704 100644
  --- a/arch/arm/boot/dts/bcm11351-brt.dts
  +++ b/arch/arm/boot/dts/bcm11351-brt.dts
  @@ -44,5 +44,11 @@
  status = okay;
  };
   
  +   usbotg: usb@3f12 {
  +   status = okay;
  +   };
 
 using usbotg could have been better. I mean if you have something like
 usbotg, you realise that the node has been created somewhere and we are just
 referencing it here to add more properties.

That's normally my preference, but Christian owns this file and doesn't
like that syntax. Instead, I'm conforming with the rest of the .dts
entries. He and I discussed moving to label references a while back and
that's a no go.

Thanks,
Matt
--
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 v3 5/9] usb: gadget: s3c-hsotg: use generic phy_init()/phy_exit() support

2013-11-27 Thread Matt Porter
On Wed, Nov 27, 2013 at 12:13:25PM -0500, Matt Porter wrote:
 On Tue, Nov 26, 2013 at 03:53:32PM +0530, Kishon Vijay Abraham I wrote:
  Hi,
  
  On Monday 25 November 2013 11:46 PM, Matt Porter wrote:
   If a generic phy is present, call phy_init()/phy_exit(). This supports
   generic phys that must be soft reset before power on.
   
   Signed-off-by: Matt Porter matt.por...@linaro.org
   ---
drivers/usb/gadget/s3c-hsotg.c | 5 +
1 file changed, 5 insertions(+)
   
   diff --git a/drivers/usb/gadget/s3c-hsotg.c 
   b/drivers/usb/gadget/s3c-hsotg.c
   index da3879b..8dfe33f 100644
   --- a/drivers/usb/gadget/s3c-hsotg.c
   +++ b/drivers/usb/gadget/s3c-hsotg.c
   @@ -3622,6 +3622,9 @@ static int s3c_hsotg_probe(struct platform_device 
   *pdev)
 goto err_supplies;
 }

   + if (hsotg-phy)
  
  IS_ERR? If your phy_get fails *phy* will have a error value..
 
 Yes, thanks. I'll fix these and also note that the same issue exists in
 Kamil's patch for these same hsotg-phy conditional uses. I'll work with
 Kamil to either get those addressed there or in a follow on fix.

I spoke too soon. If devm_phy_get fails, we don't set hsotg-phy and probe
defer thus not reaching this point. Since hsotg-phy is either NULL or a
valid struct phy *, this is correct as is throughout the driver.

  
   + phy_init(hsotg-phy);
   +
 /* usb phy enable */
 s3c_hsotg_phy_enable(hsotg);

   @@ -3715,6 +3718,8 @@ static int s3c_hsotg_remove(struct platform_device 
   *pdev)
 }

 s3c_hsotg_phy_disable(hsotg);
   + if (hsotg-phy)
  
  same here.
 
 Ok.

Same above, this will be NULL on failure (but is only applicable at this
point on the platform data path.

-Matt
--
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 8/9] phy: add Broadcom Kona USB2 PHY driver

2013-11-25 Thread Matt Porter
On Mon, Nov 04, 2013 at 11:57:10AM +0530, Kishon Vijay Abraham I wrote:
 Hi,
 
 On Saturday 02 November 2013 01:15 AM, Matt Porter wrote:
 Add a driver for the internal Broadcom Kona USB 2.0 PHY found
 on the BCM281xx family of SoCs.
 
 Signed-off-by: Matt Porter matt.por...@linaro.org
 ---
   drivers/phy/Kconfig |   6 ++
   drivers/phy/Makefile|   2 +
   drivers/phy/phy-bcm-kona-usb2.c | 161 
  
   3 files changed, 169 insertions(+)
   create mode 100644 drivers/phy/phy-bcm-kona-usb2.c
 
 diff --git a/drivers/phy/Kconfig b/drivers/phy/Kconfig
 index 349bef2..cedada5 100644
 --- a/drivers/phy/Kconfig
 +++ b/drivers/phy/Kconfig
 @@ -15,4 +15,10 @@ config GENERIC_PHY
phy users can obtain reference to the PHY. All the users of this
framework should select this config.
 
 +config BCM_KONA_USB2_PHY
 +tristate Broadcom Kona USB2 PHY Driver
 +depends on GENERIC_PHY
 +help
 +  Enable this to support the Broadcom Kona USB 2.0 PHY.
 +
   endmenu
 diff --git a/drivers/phy/Makefile b/drivers/phy/Makefile
 index 9e9560f..ce83a14 100644
 --- a/drivers/phy/Makefile
 +++ b/drivers/phy/Makefile
 @@ -3,3 +3,5 @@
   #
 
   obj-$(CONFIG_GENERIC_PHY)  += phy-core.o
 +
 +obj-$(CONFIG_BCM_KONA_USB2_PHY) += phy-bcm-kona-usb2.o
 diff --git a/drivers/phy/phy-bcm-kona-usb2.c 
 b/drivers/phy/phy-bcm-kona-usb2.c
 new file mode 100644
 index 000..1beea7f
 --- /dev/null
 +++ b/drivers/phy/phy-bcm-kona-usb2.c
 @@ -0,0 +1,161 @@
 +/*
 + * phy-bcm-kona-usb2.c - Broadcom Kona USB2 Phy Driver
 + *
 + * Copyright (C) 2013 Linaro Limited
 + * Matt Porter matt.por...@linaro.org
 + *
 + * This software is licensed under the terms of the GNU General Public
 + * License version 2, as published by the Free Software Foundation, and
 + * may be copied, distributed, and modified under those terms.
 + *
 + * This program is distributed in the hope that it will be useful,
 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 + * GNU General Public License for more details.
 + */
 +
 +#include linux/module.h
 +#include linux/of.h
 +#include linux/delay.h
 +#include linux/platform_device.h
 +#include linux/err.h
 +#include linux/io.h
 +#include linux/clk.h
 +#include linux/phy/phy.h
 +
 +#define OTGCTL_OTGSTAT2 (1  31)
 +#define OTGCTL_OTGSTAT1 (1  30)
 +#define OTGCTL_PRST_N_SW(1  11)
 +#define OTGCTL_HRESET_N (1  10)
 +#define OTGCTL_UTMI_LINE_STATE1 (1  9)
 +#define OTGCTL_UTMI_LINE_STATE0 (1  8)
 +
 +#define P1CTL_SOFT_RESET(1  1)
 +#define P1CTL_NON_DRIVING   (1  0)
 +
 +struct bcm_kona_usb_phy_regs {
 +u32 ctrl;
 +u32 cfg;
 +u32 p1ctl;
 +u32 status;
 +u32 bc_cfg;
 +u32 tp_in;
 +u32 tp_out;
 +u32 phy_ctrl;
 +u32 usbreg;
 +u32 usbproben;
 +};
 
 I would prefer to have constant macros for register offset unless
 you have a good reason to do otherwise.

I'll switch to constant macros in v3. It's just my personal preference
for style.

 +
 +struct bcm_kona_usb {
 +struct bcm_kona_usb_phy_regs *regs;
 +};
 +
 +static void bcm_kona_usb_phy_power(struct bcm_kona_usb *phy, int on)
 +{
 +u32 val;
 +
 +val = readl(phy-regs-ctrl);
 +if (on) {
 +/* Configure and power PHY */
 +val = ~(OTGCTL_OTGSTAT2 | OTGCTL_OTGSTAT1 |
 + OTGCTL_UTMI_LINE_STATE1 | OTGCTL_UTMI_LINE_STATE0);
 +val |= OTGCTL_PRST_N_SW | OTGCTL_HRESET_N;
 +writel(val, phy-regs-ctrl);
 +
 +/* Soft reset PHY */
 +val = readl(phy-regs-p1ctl);
 +val = ~P1CTL_NON_DRIVING;
 +val |= P1CTL_SOFT_RESET;
 +writel(val, phy-regs-p1ctl);
 +writel(val  ~P1CTL_SOFT_RESET, phy-regs-p1ctl);
 +/* Reset needs to be asserted for 2ms */
 +mdelay(2);
 +writel(val | P1CTL_SOFT_RESET, phy-regs-p1ctl);
 
 Is soft reset needed for every power-on? Shouldn't soft reset be
 present in phy_init?

Not needed for every power-on. Yes, I've addressed that now for v3,
thanks.

-Matt
--
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


  1   2   >