* [PATCH 2/4] usb: dwc2: Move static function prototypes into core.c
2020-12-09 14:55 [PATCH 1/4] usb: dwc2: Add support for optional usb phy Jules Maselbas
@ 2020-12-09 14:55 ` Jules Maselbas
2020-12-10 10:05 ` Sascha Hauer
2020-12-09 14:55 ` [PATCH 3/4] usb: dwc2: Fix mode check in dwc2_get_dr_mode Jules Maselbas
` (2 subsequent siblings)
3 siblings, 1 reply; 7+ messages in thread
From: Jules Maselbas @ 2020-12-09 14:55 UTC (permalink / raw)
To: barebox; +Cc: Jules Maselbas
Theses functions were only used in dwc2/core.c and where defined as
static.
Signed-off-by: Jules Maselbas <jmaselbas@kalray.eu>
---
drivers/usb/dwc2/core.c | 5 +++++
drivers/usb/dwc2/dwc2.h | 6 +-----
2 files changed, 6 insertions(+), 5 deletions(-)
diff --git a/drivers/usb/dwc2/core.c b/drivers/usb/dwc2/core.c
index c4a3cc789..a61acf553 100644
--- a/drivers/usb/dwc2/core.c
+++ b/drivers/usb/dwc2/core.c
@@ -1,6 +1,11 @@
// SPDX-License-Identifier: GPL-2.0+
#include "dwc2.h"
+static void dwc2_set_param_otg_cap(struct dwc2 *dwc2);
+static void dwc2_set_param_phy_type(struct dwc2 *dwc2);
+static void dwc2_set_param_speed(struct dwc2 *dwc2);
+static void dwc2_set_param_phy_utmi_width(struct dwc2 *dwc2);
+
/* Returns the controller's GHWCFG2.OTG_MODE. */
static unsigned int dwc2_op_mode(struct dwc2 *dwc2)
{
diff --git a/drivers/usb/dwc2/dwc2.h b/drivers/usb/dwc2/dwc2.h
index 196f4a07f..70a747302 100644
--- a/drivers/usb/dwc2/dwc2.h
+++ b/drivers/usb/dwc2/dwc2.h
@@ -8,13 +8,9 @@
#include "core.h"
/* Core functions */
-void dwc2_set_param_otg_cap(struct dwc2 *dwc2);
-void dwc2_set_param_phy_type(struct dwc2 *dwc2);
-void dwc2_set_param_speed(struct dwc2 *dwc2);
-void dwc2_set_param_phy_utmi_width(struct dwc2 *dwc2);
-void dwc2_set_default_params(struct dwc2 *dwc2);
int dwc2_core_snpsid(struct dwc2 *dwc2);
void dwc2_get_hwparams(struct dwc2 *dwc2);
+void dwc2_set_default_params(struct dwc2 *dwc2);
void dwc2_init_fs_ls_pclk_sel(struct dwc2 *dwc2);
void dwc2_flush_all_fifo(struct dwc2 *dwc2);
--
2.17.1
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH 2/4] usb: dwc2: Move static function prototypes into core.c
2020-12-09 14:55 ` [PATCH 2/4] usb: dwc2: Move static function prototypes into core.c Jules Maselbas
@ 2020-12-10 10:05 ` Sascha Hauer
2020-12-10 10:18 ` Jules Maselbas
0 siblings, 1 reply; 7+ messages in thread
From: Sascha Hauer @ 2020-12-10 10:05 UTC (permalink / raw)
To: Jules Maselbas; +Cc: barebox
Hi Jules,
On Wed, Dec 09, 2020 at 03:55:45PM +0100, Jules Maselbas wrote:
> Theses functions were only used in dwc2/core.c and where defined as
> static.
>
> Signed-off-by: Jules Maselbas <jmaselbas@kalray.eu>
> ---
> drivers/usb/dwc2/core.c | 5 +++++
> drivers/usb/dwc2/dwc2.h | 6 +-----
> 2 files changed, 6 insertions(+), 5 deletions(-)
>
> diff --git a/drivers/usb/dwc2/core.c b/drivers/usb/dwc2/core.c
> index c4a3cc789..a61acf553 100644
> --- a/drivers/usb/dwc2/core.c
> +++ b/drivers/usb/dwc2/core.c
> @@ -1,6 +1,11 @@
> // SPDX-License-Identifier: GPL-2.0+
> #include "dwc2.h"
>
> +static void dwc2_set_param_otg_cap(struct dwc2 *dwc2);
> +static void dwc2_set_param_phy_type(struct dwc2 *dwc2);
> +static void dwc2_set_param_speed(struct dwc2 *dwc2);
> +static void dwc2_set_param_phy_utmi_width(struct dwc2 *dwc2);
> +
There should be a forward declaration necessary for static functions.
You are changing the declarations to static here, but not the
implementations further down in this file, so this shouldn't compile.
> /* Returns the controller's GHWCFG2.OTG_MODE. */
> static unsigned int dwc2_op_mode(struct dwc2 *dwc2)
> {
> diff --git a/drivers/usb/dwc2/dwc2.h b/drivers/usb/dwc2/dwc2.h
> index 196f4a07f..70a747302 100644
> --- a/drivers/usb/dwc2/dwc2.h
> +++ b/drivers/usb/dwc2/dwc2.h
> @@ -8,13 +8,9 @@
> #include "core.h"
>
> /* Core functions */
> -void dwc2_set_param_otg_cap(struct dwc2 *dwc2);
> -void dwc2_set_param_phy_type(struct dwc2 *dwc2);
> -void dwc2_set_param_speed(struct dwc2 *dwc2);
> -void dwc2_set_param_phy_utmi_width(struct dwc2 *dwc2);
> -void dwc2_set_default_params(struct dwc2 *dwc2);
> int dwc2_core_snpsid(struct dwc2 *dwc2);
> void dwc2_get_hwparams(struct dwc2 *dwc2);
> +void dwc2_set_default_params(struct dwc2 *dwc2);
No need to move this declaration.
Sascha
--
Pengutronix e.K. | |
Steuerwalder Str. 21 | http://www.pengutronix.de/ |
31137 Hildesheim, Germany | Phone: +49-5121-206917-0 |
Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 |
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH 2/4] usb: dwc2: Move static function prototypes into core.c
2020-12-10 10:05 ` Sascha Hauer
@ 2020-12-10 10:18 ` Jules Maselbas
0 siblings, 0 replies; 7+ messages in thread
From: Jules Maselbas @ 2020-12-10 10:18 UTC (permalink / raw)
To: Sascha Hauer; +Cc: barebox
On Thu, Dec 10, 2020 at 11:05:09AM +0100, Sascha Hauer wrote:
> Hi Jules,
>
> On Wed, Dec 09, 2020 at 03:55:45PM +0100, Jules Maselbas wrote:
>
> There should be a forward declaration necessary for static functions.
> You are changing the declarations to static here, but not the
> implementations further down in this file, so this shouldn't compile.
>
Yes, I though there were already static, but it wasn't the case...
So I am going to remove theses declarations and add the static keyword
were is it missing.
> No need to move this declaration.
ok
> Sascha
>
> --
> Pengutronix e.K. | |
> Steuerwalder Str. 21 | http://www.pengutronix.de/ |
> 31137 Hildesheim, Germany | Phone: +49-5121-206917-0 |
> Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 |
>
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
^ permalink raw reply [flat|nested] 7+ messages in thread
* [PATCH 3/4] usb: dwc2: Fix mode check in dwc2_get_dr_mode
2020-12-09 14:55 [PATCH 1/4] usb: dwc2: Add support for optional usb phy Jules Maselbas
2020-12-09 14:55 ` [PATCH 2/4] usb: dwc2: Move static function prototypes into core.c Jules Maselbas
@ 2020-12-09 14:55 ` Jules Maselbas
2020-12-09 14:55 ` [PATCH 4/4] usb: dwc2: Rename dwc2_core_snpsid to dwc2_check_core_version Jules Maselbas
2020-12-09 19:14 ` [PATCH 1/4] usb: dwc2: Add support for optional usb phy Michael Grzeschik
3 siblings, 0 replies; 7+ messages in thread
From: Jules Maselbas @ 2020-12-09 14:55 UTC (permalink / raw)
To: barebox; +Cc: Jules Maselbas
In Linux, configs CONFIG_USB_DWC2_HOST and CONFIG_USB_DWC2_GADGET
are respectively for host only and gadget only support, they are
mutually exclusive. However this is not the case in barebox, they
are independent options.
Signed-off-by: Jules Maselbas <jmaselbas@kalray.eu>
---
drivers/usb/dwc2/core.c | 14 ++++++--------
drivers/usb/dwc2/dwc2.c | 2 ++
2 files changed, 8 insertions(+), 8 deletions(-)
diff --git a/drivers/usb/dwc2/core.c b/drivers/usb/dwc2/core.c
index a61acf553..808d80585 100644
--- a/drivers/usb/dwc2/core.c
+++ b/drivers/usb/dwc2/core.c
@@ -654,18 +654,16 @@ int dwc2_get_dr_mode(struct dwc2 *dwc2)
if (dwc2_hw_is_device(dwc2)) {
dwc2_dbg(dwc2, "Controller is device only\n");
- if (IS_ENABLED(CONFIG_USB_DWC2_HOST)) {
- dwc2_err(dwc2,
- "Controller does not support host mode.\n");
- return -EINVAL;
+ if (!IS_ENABLED(CONFIG_USB_DWC2_GADGET)) {
+ dwc2_err(dwc2, "gadget mode support not compiled in!\n");
+ return -ENOTSUPP;
}
mode = USB_DR_MODE_PERIPHERAL;
} else if (dwc2_hw_is_host(dwc2)) {
dwc2_dbg(dwc2, "Controller is host only\n");
- if (IS_ENABLED(CONFIG_USB_DWC2_GADGET)) {
- dwc2_err(dwc2,
- "Controller does not support device mode.\n");
- return -EINVAL;
+ if (!IS_ENABLED(CONFIG_USB_DWC2_HOST)) {
+ dwc2_err(dwc2, "host mode support not compiled in!\n");
+ return -ENOTSUPP;
}
mode = USB_DR_MODE_HOST;
} else {
diff --git a/drivers/usb/dwc2/dwc2.c b/drivers/usb/dwc2/dwc2.c
index ae144698c..120890105 100644
--- a/drivers/usb/dwc2/dwc2.c
+++ b/drivers/usb/dwc2/dwc2.c
@@ -77,6 +77,8 @@ static int dwc2_probe(struct device_d *dev)
dwc2_get_hwparams(dwc2);
ret = dwc2_get_dr_mode(dwc2);
+ if (ret)
+ goto error;
dwc2_set_default_params(dwc2);
--
2.17.1
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
^ permalink raw reply [flat|nested] 7+ messages in thread
* [PATCH 4/4] usb: dwc2: Rename dwc2_core_snpsid to dwc2_check_core_version
2020-12-09 14:55 [PATCH 1/4] usb: dwc2: Add support for optional usb phy Jules Maselbas
2020-12-09 14:55 ` [PATCH 2/4] usb: dwc2: Move static function prototypes into core.c Jules Maselbas
2020-12-09 14:55 ` [PATCH 3/4] usb: dwc2: Fix mode check in dwc2_get_dr_mode Jules Maselbas
@ 2020-12-09 14:55 ` Jules Maselbas
2020-12-09 19:14 ` [PATCH 1/4] usb: dwc2: Add support for optional usb phy Michael Grzeschik
3 siblings, 0 replies; 7+ messages in thread
From: Jules Maselbas @ 2020-12-09 14:55 UTC (permalink / raw)
To: barebox; +Cc: Jules Maselbas
The name dwc2_check_core_version is the one used on Linux, make it this
way.
Signed-off-by: Jules Maselbas <jmaselbas@kalray.eu>
---
drivers/usb/dwc2/core.c | 4 +---
drivers/usb/dwc2/dwc2.c | 2 +-
drivers/usb/dwc2/dwc2.h | 2 +-
3 files changed, 3 insertions(+), 5 deletions(-)
diff --git a/drivers/usb/dwc2/core.c b/drivers/usb/dwc2/core.c
index 808d80585..899c532d4 100644
--- a/drivers/usb/dwc2/core.c
+++ b/drivers/usb/dwc2/core.c
@@ -190,12 +190,10 @@ void dwc2_set_default_params(struct dwc2 *dwc2)
}
}
-int dwc2_core_snpsid(struct dwc2 *dwc2)
+int dwc2_check_core_version(struct dwc2 *dwc2)
{
struct dwc2_hw_params *hw = &dwc2->hw_params;
- hw->snpsid = dwc2_readl(dwc2, GSNPSID);
-
/*
* Attempt to ensure this device is really a DWC2 Controller.
* Read and verify the GSNPSID register contents. The value should be
diff --git a/drivers/usb/dwc2/dwc2.c b/drivers/usb/dwc2/dwc2.c
index 120890105..7835037db 100644
--- a/drivers/usb/dwc2/dwc2.c
+++ b/drivers/usb/dwc2/dwc2.c
@@ -61,7 +61,7 @@ static int dwc2_probe(struct device_d *dev)
goto error;
}
- ret = dwc2_core_snpsid(dwc2);
+ ret = dwc2_check_core_version(dwc2);
if (ret)
goto error;
diff --git a/drivers/usb/dwc2/dwc2.h b/drivers/usb/dwc2/dwc2.h
index 70a747302..476c3205b 100644
--- a/drivers/usb/dwc2/dwc2.h
+++ b/drivers/usb/dwc2/dwc2.h
@@ -8,7 +8,7 @@
#include "core.h"
/* Core functions */
-int dwc2_core_snpsid(struct dwc2 *dwc2);
+int dwc2_check_core_version(struct dwc2 *dwc2);
void dwc2_get_hwparams(struct dwc2 *dwc2);
void dwc2_set_default_params(struct dwc2 *dwc2);
--
2.17.1
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH 1/4] usb: dwc2: Add support for optional usb phy
2020-12-09 14:55 [PATCH 1/4] usb: dwc2: Add support for optional usb phy Jules Maselbas
` (2 preceding siblings ...)
2020-12-09 14:55 ` [PATCH 4/4] usb: dwc2: Rename dwc2_core_snpsid to dwc2_check_core_version Jules Maselbas
@ 2020-12-09 19:14 ` Michael Grzeschik
3 siblings, 0 replies; 7+ messages in thread
From: Michael Grzeschik @ 2020-12-09 19:14 UTC (permalink / raw)
To: Jules Maselbas; +Cc: barebox
[-- Attachment #1.1: Type: text/plain, Size: 2819 bytes --]
On Wed, Dec 09, 2020 at 03:55:44PM +0100, Jules Maselbas wrote:
>Signed-off-by: Jules Maselbas <jmaselbas@kalray.eu>
>---
> drivers/usb/dwc2/core.h | 2 ++
> drivers/usb/dwc2/dwc2.c | 21 +++++++++++++++++++++
> drivers/usb/dwc2/dwc2.h | 1 +
> 3 files changed, 24 insertions(+)
>
>diff --git a/drivers/usb/dwc2/core.h b/drivers/usb/dwc2/core.h
>index 090ca15fe..b9845b552 100644
>--- a/drivers/usb/dwc2/core.h
>+++ b/drivers/usb/dwc2/core.h
>@@ -466,6 +466,8 @@ struct dwc2 {
> struct dwc2_hw_params hw_params;
> struct dwc2_core_params params;
>
>+ struct phy *phy; /* optional */
>+
> #ifdef CONFIG_USB_DWC2_HOST
> struct usb_host host;
> u8 in_data_toggle[MAX_DEVICE][MAX_ENDPOINT];
>diff --git a/drivers/usb/dwc2/dwc2.c b/drivers/usb/dwc2/dwc2.c
>index 282e6754b..ae144698c 100644
>--- a/drivers/usb/dwc2/dwc2.c
>+++ b/drivers/usb/dwc2/dwc2.c
>@@ -50,6 +50,17 @@ static int dwc2_probe(struct device_d *dev)
> dwc2->regs = IOMEM(iores->start);
> dwc2->dev = dev;
>
>+ dwc2->phy = phy_optional_get(dev, "usb2-phy");
>+ if (!dwc2->phy)
>+ dwc2->phy = phy_optional_get(dev, "usb-phy");
>+ if (dwc2->phy) {
dwc2->phy could be of type PTR_ERR. So checking for IS_ERR is necessary.
>+ ret = phy_power_on(dwc2->phy);
>+ if (ret == 0)
>+ ret = phy_init(dwc2->phy);
>+ if (ret)
>+ goto error;
>+ }
>+
> ret = dwc2_core_snpsid(dwc2);
> if (ret)
> goto error;
>@@ -78,15 +89,25 @@ static int dwc2_probe(struct device_d *dev)
> ret = dwc2_set_mode(dwc2, dwc2->dr_mode);
>
> error:
>+ if (dwc2->phy)
>+ phy_power_off(dwc2->phy);
>+
Same here.
> return ret;
> }
>
> static void dwc2_remove(struct device_d *dev)
> {
> struct dwc2 *dwc2 = dev->priv;
>+ int ret;
>
> dwc2_host_uninit(dwc2);
> dwc2_gadget_uninit(dwc2);
>+
>+ if (dwc2->phy) {
>+ ret = phy_exit(dwc2->phy);
>+ if (ret == 0)
>+ phy_power_off(dwc2->phy);
>+ }
> }
>
> static const struct of_device_id dwc2_platform_dt_ids[] = {
>diff --git a/drivers/usb/dwc2/dwc2.h b/drivers/usb/dwc2/dwc2.h
>index 30ad90665..196f4a07f 100644
>--- a/drivers/usb/dwc2/dwc2.h
>+++ b/drivers/usb/dwc2/dwc2.h
>@@ -2,6 +2,7 @@
> #include <usb/usb.h>
> #include <usb/usb_defs.h>
> #include <usb/gadget.h>
>+#include <linux/phy/phy.h>
>
> #include "regs.h"
> #include "core.h"
>--
>2.17.1
>
>
>
>_______________________________________________
>barebox mailing list
>barebox@lists.infradead.org
>http://lists.infradead.org/mailman/listinfo/barebox
>
--
Pengutronix e.K. | |
Steuerwalder Str. 21 | http://www.pengutronix.de/ |
31137 Hildesheim, Germany | Phone: +49-5121-206917-0 |
Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 |
[-- Attachment #1.2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]
[-- Attachment #2: Type: text/plain, Size: 149 bytes --]
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
^ permalink raw reply [flat|nested] 7+ messages in thread