* [PATCH] usb: musb: omap2430: use *syscon* framework API to write to mailbox register
@ 2015-08-04 14:06 Kishon Vijay Abraham I
2015-08-04 15:58 ` Felipe Balbi
2015-08-05 8:01 ` Tony Lindgren
0 siblings, 2 replies; 8+ messages in thread
From: Kishon Vijay Abraham I @ 2015-08-04 14:06 UTC (permalink / raw)
To: balbi, devicetree, linux-kernel, linux-usb, linux-omap, nsekhar
Cc: gregkh, kishon
Deprecate using phy-omap-control driver to write to the mailbox register
and start using *syscon* framework to do the same.
Signed-off-by: Kishon Vijay Abraham I <kishon@ti.com>
---
Documentation/devicetree/bindings/usb/omap-usb.txt | 7 +-
drivers/usb/musb/omap2430.c | 115 ++++++++++++++++----
2 files changed, 99 insertions(+), 23 deletions(-)
diff --git a/Documentation/devicetree/bindings/usb/omap-usb.txt b/Documentation/devicetree/bindings/usb/omap-usb.txt
index 38d9bb8..c001306 100644
--- a/Documentation/devicetree/bindings/usb/omap-usb.txt
+++ b/Documentation/devicetree/bindings/usb/omap-usb.txt
@@ -20,10 +20,15 @@ OMAP MUSB GLUE
- phy-names : the names of the PHY corresponding to the PHYs present in the
*phy* phandle.
-Optional properties:
+Optional Properties:
+Deprecated properties:
- ctrl-module : phandle of the control module this glue uses to write to
mailbox
+Recommended properies:
+ - syscon-otghs : phandle/offset pair. Phandle to the system control module and the
+ register offset of the mailbox.
+
SOC specific device node entry
usb_otg_hs: usb_otg_hs@4a0ab000 {
compatible = "ti,omap4-musb";
diff --git a/drivers/usb/musb/omap2430.c b/drivers/usb/musb/omap2430.c
index 70f2b8a..a03cf1e 100644
--- a/drivers/usb/musb/omap2430.c
+++ b/drivers/usb/musb/omap2430.c
@@ -39,16 +39,27 @@
#include <linux/usb/musb-omap.h>
#include <linux/phy/omap_control_phy.h>
#include <linux/of_platform.h>
+#include <linux/regmap.h>
+#include <linux/mfd/syscon.h>
#include "musb_core.h"
#include "omap2430.h"
+#define OMAP2430_MUSB_MODE_MASK 0x1f
+#define OMAP2430_MUSB_AVALID BIT(0)
+#define OMAP2430_MUSB_BVALID BIT(1)
+#define OMAP2430_MUSB_VBUSVALID BIT(2)
+#define OMAP2430_MUSB_SESSEND BIT(3)
+#define OMAP2430_MUSB_IDDIG BIT(4)
+
struct omap2430_glue {
struct device *dev;
struct platform_device *musb;
enum omap_musb_vbus_id_status status;
struct work_struct omap_musb_mailbox_work;
struct device *control_otghs;
+ struct regmap *syscon_otghs; /* ctrl. reg. acces */
+ unsigned int otghs_reg; /* otghs reg. index within syscon */
};
#define glue_to_musb(g) platform_get_drvdata(g->musb)
@@ -253,6 +264,44 @@ void omap_musb_mailbox(enum omap_musb_vbus_id_status status)
}
EXPORT_SYMBOL_GPL(omap_musb_mailbox);
+static void omap2430_musb_set_usbmode(struct omap2430_glue *glue,
+ enum omap_control_usb_mode mode)
+{
+ u32 val;
+ int ret;
+
+ if (glue->syscon_otghs) {
+ switch (mode) {
+ case USB_MODE_HOST:
+ val = OMAP2430_MUSB_AVALID | OMAP2430_MUSB_VBUSVALID;
+ break;
+ case USB_MODE_DEVICE:
+ val = OMAP2430_MUSB_IDDIG | OMAP2430_MUSB_AVALID |
+ OMAP2430_MUSB_VBUSVALID;
+ break;
+ case USB_MODE_DISCONNECT:
+ val = OMAP2430_MUSB_IDDIG | OMAP2430_MUSB_SESSEND;
+ break;
+ default:
+ dev_dbg(glue->dev, "Invalid mode\n");
+ goto err_regmap_update;
+ }
+
+ ret = regmap_update_bits(glue->syscon_otghs,
+ glue->otghs_reg,
+ OMAP2430_MUSB_MODE_MASK, val);
+ if (ret < 0)
+ goto err_regmap_update;
+ } else {
+ omap_control_usb_set_mode(glue->control_otghs, mode);
+ }
+
+ return;
+
+err_regmap_update:
+ dev_err(glue->dev, "Failed to set mode to %d\n", mode);
+}
+
static void omap_musb_set_mailbox(struct omap2430_glue *glue)
{
struct musb *musb = glue_to_musb(glue);
@@ -270,8 +319,7 @@ static void omap_musb_set_mailbox(struct omap2430_glue *glue)
musb->xceiv->last_event = USB_EVENT_ID;
if (musb->gadget_driver) {
pm_runtime_get_sync(dev);
- omap_control_usb_set_mode(glue->control_otghs,
- USB_MODE_HOST);
+ omap2430_musb_set_usbmode(glue, USB_MODE_HOST);
omap2430_musb_set_vbus(musb, 1);
}
break;
@@ -284,7 +332,7 @@ static void omap_musb_set_mailbox(struct omap2430_glue *glue)
musb->xceiv->last_event = USB_EVENT_VBUS;
if (musb->gadget_driver)
pm_runtime_get_sync(dev);
- omap_control_usb_set_mode(glue->control_otghs, USB_MODE_DEVICE);
+ omap2430_musb_set_usbmode(glue, USB_MODE_DEVICE);
break;
case OMAP_MUSB_ID_FLOAT:
@@ -301,8 +349,7 @@ static void omap_musb_set_mailbox(struct omap2430_glue *glue)
if (data->interface_type == MUSB_INTERFACE_UTMI)
otg_set_vbus(musb->xceiv->otg, 0);
- omap_control_usb_set_mode(glue->control_otghs,
- USB_MODE_DISCONNECT);
+ omap2430_musb_set_usbmode(glue, USB_MODE_DISCONNECT);
break;
default:
dev_dbg(dev, "ID float\n");
@@ -444,7 +491,7 @@ static void omap2430_musb_enable(struct musb *musb)
switch (glue->status) {
case OMAP_MUSB_ID_GROUND:
- omap_control_usb_set_mode(glue->control_otghs, USB_MODE_HOST);
+ omap2430_musb_set_usbmode(glue, USB_MODE_HOST);
if (data->interface_type != MUSB_INTERFACE_UTMI)
break;
devctl = musb_readb(musb->mregs, MUSB_DEVCTL);
@@ -463,7 +510,7 @@ static void omap2430_musb_enable(struct musb *musb)
break;
case OMAP_MUSB_VBUS_VALID:
- omap_control_usb_set_mode(glue->control_otghs, USB_MODE_DEVICE);
+ omap2430_musb_set_usbmode(glue, USB_MODE_DEVICE);
break;
default:
@@ -477,8 +524,7 @@ static void omap2430_musb_disable(struct musb *musb)
struct omap2430_glue *glue = dev_get_drvdata(dev->parent);
if (glue->status != OMAP_MUSB_UNKNOWN)
- omap_control_usb_set_mode(glue->control_otghs,
- USB_MODE_DISCONNECT);
+ omap2430_musb_set_usbmode(glue, USB_MODE_DISCONNECT);
}
static int omap2430_musb_exit(struct musb *musb)
@@ -512,6 +558,40 @@ static const struct musb_platform_ops omap2430_ops = {
static u64 omap2430_dmamask = DMA_BIT_MASK(32);
+static int omap2430_get_sys_ctrl(struct omap2430_glue *glue,
+ struct device_node *np)
+{
+ struct device_node *control_node;
+ struct platform_device *control_pdev;
+
+ glue->syscon_otghs = syscon_regmap_lookup_by_phandle(np,
+ "syscon-otghs");
+ if (IS_ERR(glue->syscon_otghs)) {
+ dev_dbg(glue->dev, "can't get syscon, using control device\n");
+ glue->syscon_otghs = NULL;
+
+ control_node = of_parse_phandle(np, "ctrl-module", 0);
+ if (control_node) {
+ control_pdev = of_find_device_by_node(control_node);
+ if (!control_pdev) {
+ dev_err(glue->dev,
+ "Failed to get control device\n");
+ return -EINVAL;
+ }
+ glue->control_otghs = &control_pdev->dev;
+ }
+ } else {
+ if (of_property_read_u32_index(np, "syscon-otghs", 1,
+ &glue->otghs_reg)) {
+ dev_err(glue->dev,
+ "couldn't get otghs reg. offset\n");
+ return -EINVAL;
+ }
+ }
+
+ return 0;
+}
+
static int omap2430_probe(struct platform_device *pdev)
{
struct resource musb_resources[3];
@@ -543,9 +623,6 @@ static int omap2430_probe(struct platform_device *pdev)
glue->control_otghs = ERR_PTR(-ENODEV);
if (np) {
- struct device_node *control_node;
- struct platform_device *control_pdev;
-
pdata = devm_kzalloc(&pdev->dev, sizeof(*pdata), GFP_KERNEL);
if (!pdata)
goto err2;
@@ -572,16 +649,10 @@ static int omap2430_probe(struct platform_device *pdev)
pdata->board_data = data;
pdata->config = config;
- control_node = of_parse_phandle(np, "ctrl-module", 0);
- if (control_node) {
- control_pdev = of_find_device_by_node(control_node);
- if (!control_pdev) {
- dev_err(&pdev->dev, "Failed to get control device\n");
- ret = -EINVAL;
- goto err2;
- }
- glue->control_otghs = &control_pdev->dev;
- }
+ ret = omap2430_get_sys_ctrl(glue, np);
+ if (ret)
+ goto err2;
+
}
pdata->platform_ops = &omap2430_ops;
--
1.7.9.5
^ permalink raw reply related [flat|nested] 8+ messages in thread* Re: [PATCH] usb: musb: omap2430: use *syscon* framework API to write to mailbox register
2015-08-04 14:06 [PATCH] usb: musb: omap2430: use *syscon* framework API to write to mailbox register Kishon Vijay Abraham I
@ 2015-08-04 15:58 ` Felipe Balbi
2015-08-05 13:50 ` Kishon Vijay Abraham I
2015-08-05 8:01 ` Tony Lindgren
1 sibling, 1 reply; 8+ messages in thread
From: Felipe Balbi @ 2015-08-04 15:58 UTC (permalink / raw)
To: Kishon Vijay Abraham I
Cc: balbi, devicetree, linux-kernel, linux-usb, linux-omap, nsekhar,
gregkh
[-- Attachment #1: Type: text/plain, Size: 3515 bytes --]
Hi,
On Tue, Aug 04, 2015 at 07:36:09PM +0530, Kishon Vijay Abraham I wrote:
> Deprecate using phy-omap-control driver to write to the mailbox register
> and start using *syscon* framework to do the same.
>
> Signed-off-by: Kishon Vijay Abraham I <kishon@ti.com>
> ---
> Documentation/devicetree/bindings/usb/omap-usb.txt | 7 +-
> drivers/usb/musb/omap2430.c | 115 ++++++++++++++++----
> 2 files changed, 99 insertions(+), 23 deletions(-)
>
> diff --git a/Documentation/devicetree/bindings/usb/omap-usb.txt b/Documentation/devicetree/bindings/usb/omap-usb.txt
> index 38d9bb8..c001306 100644
> --- a/Documentation/devicetree/bindings/usb/omap-usb.txt
> +++ b/Documentation/devicetree/bindings/usb/omap-usb.txt
> @@ -20,10 +20,15 @@ OMAP MUSB GLUE
> - phy-names : the names of the PHY corresponding to the PHYs present in the
> *phy* phandle.
>
> -Optional properties:
> +Optional Properties:
> +Deprecated properties:
> - ctrl-module : phandle of the control module this glue uses to write to
> mailbox
>
> +Recommended properies:
> + - syscon-otghs : phandle/offset pair. Phandle to the system control module and the
> + register offset of the mailbox.
> +
> SOC specific device node entry
> usb_otg_hs: usb_otg_hs@4a0ab000 {
> compatible = "ti,omap4-musb";
> diff --git a/drivers/usb/musb/omap2430.c b/drivers/usb/musb/omap2430.c
> index 70f2b8a..a03cf1e 100644
> --- a/drivers/usb/musb/omap2430.c
> +++ b/drivers/usb/musb/omap2430.c
> @@ -39,16 +39,27 @@
> #include <linux/usb/musb-omap.h>
> #include <linux/phy/omap_control_phy.h>
> #include <linux/of_platform.h>
> +#include <linux/regmap.h>
> +#include <linux/mfd/syscon.h>
>
> #include "musb_core.h"
> #include "omap2430.h"
>
> +#define OMAP2430_MUSB_MODE_MASK 0x1f
> +#define OMAP2430_MUSB_AVALID BIT(0)
> +#define OMAP2430_MUSB_BVALID BIT(1)
> +#define OMAP2430_MUSB_VBUSVALID BIT(2)
> +#define OMAP2430_MUSB_SESSEND BIT(3)
> +#define OMAP2430_MUSB_IDDIG BIT(4)
> +
> struct omap2430_glue {
> struct device *dev;
> struct platform_device *musb;
> enum omap_musb_vbus_id_status status;
> struct work_struct omap_musb_mailbox_work;
> struct device *control_otghs;
> + struct regmap *syscon_otghs; /* ctrl. reg. acces */
> + unsigned int otghs_reg; /* otghs reg. index within syscon */
> };
> #define glue_to_musb(g) platform_get_drvdata(g->musb)
>
> @@ -253,6 +264,44 @@ void omap_musb_mailbox(enum omap_musb_vbus_id_status status)
> }
> EXPORT_SYMBOL_GPL(omap_musb_mailbox);
>
> +static void omap2430_musb_set_usbmode(struct omap2430_glue *glue,
> + enum omap_control_usb_mode mode)
> +{
> + u32 val;
> + int ret;
> +
if (!glue->syscon_otghs) {
omap_control_usb_set_mode(glue->control_otghs, mode);
return;
}
switch (mode) {
case USB_MODE_HOST:
val = OMAP2430_MUSB_AVALID | OMAP2430_MUSB_VBUSVALID;
break;
case USB_MODE_DEVICE:
val = OMAP2430_MUSB_IDDIG | OMAP2430_MUSB_AVALID |
OMAP2430_MUSB_VBUSVALID;
break;
case USB_MODE_DISCONNECT:
val = OMAP2430_MUSB_IDDIG | OMAP2430_MUSB_SESSEND;
break;
default:
dev_dbg(glue->dev, "Invalid mode\n");
dev_err(glue->dev, "Failed to set mode to %d\n", mode);
}
ret = regmap_update_bits(glue->syscon_otghs,
glue->otghs_reg,
OMAP2430_MUSB_MODE_MASK, val);
if (ret < 0)
dev_err(glue->dev, "Failed to update regmap\n");
other than that, looks fine.
--
balbi
[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 819 bytes --]
^ permalink raw reply [flat|nested] 8+ messages in thread* Re: [PATCH] usb: musb: omap2430: use *syscon* framework API to write to mailbox register
2015-08-04 15:58 ` Felipe Balbi
@ 2015-08-05 13:50 ` Kishon Vijay Abraham I
0 siblings, 0 replies; 8+ messages in thread
From: Kishon Vijay Abraham I @ 2015-08-05 13:50 UTC (permalink / raw)
To: balbi; +Cc: devicetree, linux-kernel, linux-usb, linux-omap, nsekhar, gregkh
Hi,
On Tuesday 04 August 2015 09:28 PM, Felipe Balbi wrote:
> Hi,
>
> On Tue, Aug 04, 2015 at 07:36:09PM +0530, Kishon Vijay Abraham I wrote:
>> Deprecate using phy-omap-control driver to write to the mailbox register
>> and start using *syscon* framework to do the same.
>>
>> Signed-off-by: Kishon Vijay Abraham I <kishon@ti.com>
>> ---
>> Documentation/devicetree/bindings/usb/omap-usb.txt | 7 +-
>> drivers/usb/musb/omap2430.c | 115 ++++++++++++++++----
>> 2 files changed, 99 insertions(+), 23 deletions(-)
>>
>> diff --git a/Documentation/devicetree/bindings/usb/omap-usb.txt b/Documentation/devicetree/bindings/usb/omap-usb.txt
>> index 38d9bb8..c001306 100644
>> --- a/Documentation/devicetree/bindings/usb/omap-usb.txt
>> +++ b/Documentation/devicetree/bindings/usb/omap-usb.txt
>> @@ -20,10 +20,15 @@ OMAP MUSB GLUE
>> - phy-names : the names of the PHY corresponding to the PHYs present in the
>> *phy* phandle.
>>
>> -Optional properties:
>> +Optional Properties:
>> +Deprecated properties:
>> - ctrl-module : phandle of the control module this glue uses to write to
>> mailbox
>>
>> +Recommended properies:
>> + - syscon-otghs : phandle/offset pair. Phandle to the system control module and the
>> + register offset of the mailbox.
>> +
>> SOC specific device node entry
>> usb_otg_hs: usb_otg_hs@4a0ab000 {
>> compatible = "ti,omap4-musb";
>> diff --git a/drivers/usb/musb/omap2430.c b/drivers/usb/musb/omap2430.c
>> index 70f2b8a..a03cf1e 100644
>> --- a/drivers/usb/musb/omap2430.c
>> +++ b/drivers/usb/musb/omap2430.c
>> @@ -39,16 +39,27 @@
>> #include <linux/usb/musb-omap.h>
>> #include <linux/phy/omap_control_phy.h>
>> #include <linux/of_platform.h>
>> +#include <linux/regmap.h>
>> +#include <linux/mfd/syscon.h>
>>
>> #include "musb_core.h"
>> #include "omap2430.h"
>>
>> +#define OMAP2430_MUSB_MODE_MASK 0x1f
>> +#define OMAP2430_MUSB_AVALID BIT(0)
>> +#define OMAP2430_MUSB_BVALID BIT(1)
>> +#define OMAP2430_MUSB_VBUSVALID BIT(2)
>> +#define OMAP2430_MUSB_SESSEND BIT(3)
>> +#define OMAP2430_MUSB_IDDIG BIT(4)
>> +
>> struct omap2430_glue {
>> struct device *dev;
>> struct platform_device *musb;
>> enum omap_musb_vbus_id_status status;
>> struct work_struct omap_musb_mailbox_work;
>> struct device *control_otghs;
>> + struct regmap *syscon_otghs; /* ctrl. reg. acces */
>> + unsigned int otghs_reg; /* otghs reg. index within syscon */
>> };
>> #define glue_to_musb(g) platform_get_drvdata(g->musb)
>>
>> @@ -253,6 +264,44 @@ void omap_musb_mailbox(enum omap_musb_vbus_id_status status)
>> }
>> EXPORT_SYMBOL_GPL(omap_musb_mailbox);
>>
>> +static void omap2430_musb_set_usbmode(struct omap2430_glue *glue,
>> + enum omap_control_usb_mode mode)
>> +{
>> + u32 val;
>> + int ret;
>> +
>
> if (!glue->syscon_otghs) {
> omap_control_usb_set_mode(glue->control_otghs, mode);
> return;
> }
>
> switch (mode) {
> case USB_MODE_HOST:
> val = OMAP2430_MUSB_AVALID | OMAP2430_MUSB_VBUSVALID;
> break;
> case USB_MODE_DEVICE:
> val = OMAP2430_MUSB_IDDIG | OMAP2430_MUSB_AVALID |
> OMAP2430_MUSB_VBUSVALID;
> break;
> case USB_MODE_DISCONNECT:
> val = OMAP2430_MUSB_IDDIG | OMAP2430_MUSB_SESSEND;
> break;
> default:
> dev_dbg(glue->dev, "Invalid mode\n");
> dev_err(glue->dev, "Failed to set mode to %d\n", mode);
Don't we have to return here? Maybe we should set IDDIG and SESSEND (the same
value as USB_MODE_DISCONNECT). That seems to be the reset value as well.
> }
>
> ret = regmap_update_bits(glue->syscon_otghs,
> glue->otghs_reg,
> OMAP2430_MUSB_MODE_MASK, val);
> if (ret < 0)
> dev_err(glue->dev, "Failed to update regmap\n");
Thanks
Kishon
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH] usb: musb: omap2430: use *syscon* framework API to write to mailbox register
2015-08-04 14:06 [PATCH] usb: musb: omap2430: use *syscon* framework API to write to mailbox register Kishon Vijay Abraham I
2015-08-04 15:58 ` Felipe Balbi
@ 2015-08-05 8:01 ` Tony Lindgren
[not found] ` <20150805080113.GV16878-4v6yS6AI5VpBDgjK7y7TUQ@public.gmane.org>
1 sibling, 1 reply; 8+ messages in thread
From: Tony Lindgren @ 2015-08-05 8:01 UTC (permalink / raw)
To: Kishon Vijay Abraham I
Cc: balbi, devicetree, linux-kernel, linux-usb, linux-omap, nsekhar,
gregkh
* Kishon Vijay Abraham I <kishon@ti.com> [150804 07:11]:
> Deprecate using phy-omap-control driver to write to the mailbox register
> and start using *syscon* framework to do the same.
..
> @@ -512,6 +558,40 @@ static const struct musb_platform_ops omap2430_ops = {
>
> static u64 omap2430_dmamask = DMA_BIT_MASK(32);
>
> +static int omap2430_get_sys_ctrl(struct omap2430_glue *glue,
> + struct device_node *np)
> +{
> + struct device_node *control_node;
> + struct platform_device *control_pdev;
> +
> + glue->syscon_otghs = syscon_regmap_lookup_by_phandle(np,
> + "syscon-otghs");
> + if (IS_ERR(glue->syscon_otghs)) {
> + dev_dbg(glue->dev, "can't get syscon, using control device\n");
> + glue->syscon_otghs = NULL;
> +
> + control_node = of_parse_phandle(np, "ctrl-module", 0);
> + if (control_node) {
> + control_pdev = of_find_device_by_node(control_node);
> + if (!control_pdev) {
> + dev_err(glue->dev,
> + "Failed to get control device\n");
> + return -EINVAL;
> + }
> + glue->control_otghs = &control_pdev->dev;
> + }
> + } else {
> + if (of_property_read_u32_index(np, "syscon-otghs", 1,
> + &glue->otghs_reg)) {
> + dev_err(glue->dev,
> + "couldn't get otghs reg. offset\n");
> + return -EINVAL;
> + }
> + }
> +
> + return 0;
> +}
We don't have syscon-otghs and to me it seems we need a PHY driver
as I pointed out at:
https://lkml.org/lkml/2015/6/24/231
So let's sort that issue first. It also seems this just completely
breaks the MUSB support?
Regards,
Tony
^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2015-08-21 7:00 UTC | newest]
Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-08-04 14:06 [PATCH] usb: musb: omap2430: use *syscon* framework API to write to mailbox register Kishon Vijay Abraham I
2015-08-04 15:58 ` Felipe Balbi
2015-08-05 13:50 ` Kishon Vijay Abraham I
2015-08-05 8:01 ` Tony Lindgren
[not found] ` <20150805080113.GV16878-4v6yS6AI5VpBDgjK7y7TUQ@public.gmane.org>
2015-08-05 14:07 ` Kishon Vijay Abraham I
[not found] ` <55C21885.6000902-l0cyMroinI0@public.gmane.org>
2015-08-06 8:47 ` Tony Lindgren
2015-08-20 6:35 ` Kishon Vijay Abraham I
2015-08-21 7:00 ` Tony Lindgren
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).