* [PATCH 1/3 v1] usb: fotg210: Collect pieces of dual mode controller
@ 2022-10-23 14:47 Linus Walleij
2022-10-23 14:47 ` [PATCH 2/3 v1] usb: fotg210: Compile into one module Linus Walleij
` (3 more replies)
0 siblings, 4 replies; 7+ messages in thread
From: Linus Walleij @ 2022-10-23 14:47 UTC (permalink / raw)
To: Greg Kroah-Hartman
Cc: linux-usb, Linus Walleij, Fabian Vogt, Yuan-Hsin Chen,
Felipe Balbi
The Faraday FOTG210 is a dual-mode OTG USB controller that can
act as host, peripheral or both. To be able to probe from one
hardware description and to follow the pattern of other dual-
mode controllers such as MUSB or MTU3 we need to collect the
two, currently completely separate drivers in the same
directory.
After this, users need to select the main symbol USB_FOTG210
and then each respective subdriver. We pave the road to
compile both drivers into the same kernel and select the
one we want to use at probe() time, and possibly add OTG
support in the end.
This patch doesn't do much more than create the new symbol
and collect the drivers in one place. We also add a comment
for the section of dual-mode controllers in the Kconfig
file so people can see what these selections are about.
Also add myself as maintainer as there has been little
response on my patches to these drivers.
Cc: Fabian Vogt <fabian@ritter-vogt.de>
Cc: Yuan-Hsin Chen <yhchen@faraday-tech.com>
Cc: Felipe Balbi <balbi@kernel.org>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
---
MAINTAINERS | 6 ++++
drivers/usb/Kconfig | 4 +++
drivers/usb/Makefile | 2 ++
drivers/usb/fotg210/Kconfig | 36 +++++++++++++++++++
drivers/usb/fotg210/Makefile | 3 ++
drivers/usb/{host => fotg210}/fotg210-hcd.c | 2 +-
.../{host/fotg210.h => fotg210/fotg210-hcd.h} | 0
.../usb/{gadget/udc => fotg210}/fotg210-udc.c | 2 +-
.../udc/fotg210.h => fotg210/fotg210-udc.h} | 0
drivers/usb/gadget/udc/Kconfig | 11 ------
drivers/usb/gadget/udc/Makefile | 1 -
drivers/usb/host/Kconfig | 11 ------
drivers/usb/host/Makefile | 1 -
13 files changed, 53 insertions(+), 26 deletions(-)
create mode 100644 drivers/usb/fotg210/Kconfig
create mode 100644 drivers/usb/fotg210/Makefile
rename drivers/usb/{host => fotg210}/fotg210-hcd.c (99%)
rename drivers/usb/{host/fotg210.h => fotg210/fotg210-hcd.h} (100%)
rename drivers/usb/{gadget/udc => fotg210}/fotg210-udc.c (99%)
rename drivers/usb/{gadget/udc/fotg210.h => fotg210/fotg210-udc.h} (100%)
diff --git a/MAINTAINERS b/MAINTAINERS
index cf0f18502372..7bb19a676ff9 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -7866,6 +7866,12 @@ F: fs/notify/fanotify/
F: include/linux/fanotify.h
F: include/uapi/linux/fanotify.h
+FARADAY FOTG210 USB2 DUAL-ROLE CONTROLLER
+M: Linus Walleij <linus.walleij@linaro.org>
+L: linux-usb@vger.kernel.org
+S: Maintained
+F: drivers/usb/fotg210/
+
FARSYNC SYNCHRONOUS DRIVER
M: Kevin Curtis <kevin.curtis@farsite.co.uk>
S: Supported
diff --git a/drivers/usb/Kconfig b/drivers/usb/Kconfig
index 578a439e71b5..a871a988829d 100644
--- a/drivers/usb/Kconfig
+++ b/drivers/usb/Kconfig
@@ -111,8 +111,12 @@ source "drivers/usb/usbip/Kconfig"
endif
+comment "USB dual-mode controller drivers"
+
source "drivers/usb/cdns3/Kconfig"
+source "drivers/usb/fotg210/Kconfig"
+
source "drivers/usb/mtu3/Kconfig"
source "drivers/usb/musb/Kconfig"
diff --git a/drivers/usb/Makefile b/drivers/usb/Makefile
index 643edf5fe18c..a81e6ef293af 100644
--- a/drivers/usb/Makefile
+++ b/drivers/usb/Makefile
@@ -17,6 +17,8 @@ obj-$(CONFIG_USB_CDNS_SUPPORT) += cdns3/
obj-$(CONFIG_USB_CDNS3) += cdns3/
obj-$(CONFIG_USB_CDNSP_PCI) += cdns3/
+obj-$(CONFIG_USB_FOTG210) += fotg210/
+
obj-$(CONFIG_USB_MON) += mon/
obj-$(CONFIG_USB_MTU3) += mtu3/
diff --git a/drivers/usb/fotg210/Kconfig b/drivers/usb/fotg210/Kconfig
new file mode 100644
index 000000000000..e7a106785f5d
--- /dev/null
+++ b/drivers/usb/fotg210/Kconfig
@@ -0,0 +1,36 @@
+# SPDX-License-Identifier: GPL-2.0
+
+config USB_FOTG210
+ tristate "Faraday FOTG210 USB2 Dual Role controller"
+ depends on USB || USB_GADGET
+ depends on HAS_DMA && HAS_IOMEM
+ default ARCH_GEMINI
+ help
+ Faraday FOTG210 is a dual-mode USB controller that can act
+ in both host controller and peripheral controller mode.
+
+if USB_FOTG210
+
+config USB_FOTG210_HCD
+ tristate "Faraday FOTG210 USB Host Controller support"
+ depends on USB
+ help
+ Faraday FOTG210 is an OTG controller which can be configured as
+ an USB2.0 host. It is designed to meet USB2.0 EHCI specification
+ with minor modification.
+
+ To compile this driver as a module, choose M here: the
+ module will be called fotg210-hcd.
+
+config USB_FOTG210_UDC
+ depends on USB_GADGET
+ tristate "Faraday FOTG210 USB Peripheral Controller support"
+ help
+ Faraday USB2.0 OTG controller which can be configured as
+ high speed or full speed USB device. This driver suppports
+ Bulk Transfer so far.
+
+ Say "y" to link the driver statically, or "m" to build a
+ dynamically linked module called "fotg210-udc".
+
+endif
diff --git a/drivers/usb/fotg210/Makefile b/drivers/usb/fotg210/Makefile
new file mode 100644
index 000000000000..f4a26ca0e563
--- /dev/null
+++ b/drivers/usb/fotg210/Makefile
@@ -0,0 +1,3 @@
+# SPDX-License-Identifier: GPL-2.0
+obj-$(CONFIG_USB_FOTG210_HCD) += fotg210-hcd.o
+obj-$(CONFIG_USB_FOTG210_UDC) += fotg210-udc.o
diff --git a/drivers/usb/host/fotg210-hcd.c b/drivers/usb/fotg210/fotg210-hcd.c
similarity index 99%
rename from drivers/usb/host/fotg210-hcd.c
rename to drivers/usb/fotg210/fotg210-hcd.c
index 3d1dbcf4c073..8fbf63e76d7d 100644
--- a/drivers/usb/host/fotg210-hcd.c
+++ b/drivers/usb/fotg210/fotg210-hcd.c
@@ -77,7 +77,7 @@ MODULE_PARM_DESC(hird, "host initiated resume duration, +1 for each 75us");
#define INTR_MASK (STS_IAA | STS_FATAL | STS_PCD | STS_ERR | STS_INT)
-#include "fotg210.h"
+#include "fotg210-hcd.h"
#define fotg210_dbg(fotg210, fmt, args...) \
dev_dbg(fotg210_to_hcd(fotg210)->self.controller, fmt, ## args)
diff --git a/drivers/usb/host/fotg210.h b/drivers/usb/fotg210/fotg210-hcd.h
similarity index 100%
rename from drivers/usb/host/fotg210.h
rename to drivers/usb/fotg210/fotg210-hcd.h
diff --git a/drivers/usb/gadget/udc/fotg210-udc.c b/drivers/usb/fotg210/fotg210-udc.c
similarity index 99%
rename from drivers/usb/gadget/udc/fotg210-udc.c
rename to drivers/usb/fotg210/fotg210-udc.c
index fdca28e72a3b..01a4509775b2 100644
--- a/drivers/usb/gadget/udc/fotg210-udc.c
+++ b/drivers/usb/fotg210/fotg210-udc.c
@@ -16,7 +16,7 @@
#include <linux/usb/ch9.h>
#include <linux/usb/gadget.h>
-#include "fotg210.h"
+#include "fotg210-udc.h"
#define DRIVER_DESC "FOTG210 USB Device Controller Driver"
#define DRIVER_VERSION "30-April-2013"
diff --git a/drivers/usb/gadget/udc/fotg210.h b/drivers/usb/fotg210/fotg210-udc.h
similarity index 100%
rename from drivers/usb/gadget/udc/fotg210.h
rename to drivers/usb/fotg210/fotg210-udc.h
diff --git a/drivers/usb/gadget/udc/Kconfig b/drivers/usb/gadget/udc/Kconfig
index 5756acb07b8d..16243964b1cd 100644
--- a/drivers/usb/gadget/udc/Kconfig
+++ b/drivers/usb/gadget/udc/Kconfig
@@ -108,17 +108,6 @@ config USB_FUSB300
help
Faraday usb device controller FUSB300 driver
-config USB_FOTG210_UDC
- depends on HAS_DMA
- tristate "Faraday FOTG210 USB Peripheral Controller"
- help
- Faraday USB2.0 OTG controller which can be configured as
- high speed or full speed USB device. This driver supppors
- Bulk Transfer so far.
-
- Say "y" to link the driver statically, or "m" to build a
- dynamically linked module called "fotg210_udc".
-
config USB_GR_UDC
tristate "Aeroflex Gaisler GRUSBDC USB Peripheral Controller Driver"
depends on HAS_DMA
diff --git a/drivers/usb/gadget/udc/Makefile b/drivers/usb/gadget/udc/Makefile
index 12f9e4c9eb0c..39daf36a2baa 100644
--- a/drivers/usb/gadget/udc/Makefile
+++ b/drivers/usb/gadget/udc/Makefile
@@ -34,7 +34,6 @@ obj-$(CONFIG_USB_EG20T) += pch_udc.o
obj-$(CONFIG_USB_MV_UDC) += mv_udc.o
mv_udc-y := mv_udc_core.o
obj-$(CONFIG_USB_FUSB300) += fusb300_udc.o
-obj-$(CONFIG_USB_FOTG210_UDC) += fotg210-udc.o
obj-$(CONFIG_USB_MV_U3D) += mv_u3d_core.o
obj-$(CONFIG_USB_GR_UDC) += gr_udc.o
obj-$(CONFIG_USB_GADGET_XILINX) += udc-xilinx.o
diff --git a/drivers/usb/host/Kconfig b/drivers/usb/host/Kconfig
index 247568bc17a2..7cebf03d4226 100644
--- a/drivers/usb/host/Kconfig
+++ b/drivers/usb/host/Kconfig
@@ -389,17 +389,6 @@ config USB_ISP1362_HCD
To compile this driver as a module, choose M here: the
module will be called isp1362-hcd.
-config USB_FOTG210_HCD
- tristate "FOTG210 HCD support"
- depends on USB && HAS_DMA && HAS_IOMEM
- help
- Faraday FOTG210 is an OTG controller which can be configured as
- an USB2.0 host. It is designed to meet USB2.0 EHCI specification
- with minor modification.
-
- To compile this driver as a module, choose M here: the
- module will be called fotg210-hcd.
-
config USB_MAX3421_HCD
tristate "MAX3421 HCD (USB-over-SPI) support"
depends on USB && SPI
diff --git a/drivers/usb/host/Makefile b/drivers/usb/host/Makefile
index 2c8a61be7e46..6d8ee264c9b2 100644
--- a/drivers/usb/host/Makefile
+++ b/drivers/usb/host/Makefile
@@ -84,6 +84,5 @@ obj-$(CONFIG_USB_EHCI_FSL) += ehci-fsl.o
obj-$(CONFIG_USB_EHCI_MV) += ehci-mv.o
obj-$(CONFIG_USB_HCD_BCMA) += bcma-hcd.o
obj-$(CONFIG_USB_HCD_SSB) += ssb-hcd.o
-obj-$(CONFIG_USB_FOTG210_HCD) += fotg210-hcd.o
obj-$(CONFIG_USB_MAX3421_HCD) += max3421-hcd.o
obj-$(CONFIG_USB_XEN_HCD) += xen-hcd.o
--
2.37.3
^ permalink raw reply related [flat|nested] 7+ messages in thread
* [PATCH 2/3 v1] usb: fotg210: Compile into one module
2022-10-23 14:47 [PATCH 1/3 v1] usb: fotg210: Collect pieces of dual mode controller Linus Walleij
@ 2022-10-23 14:47 ` Linus Walleij
2022-10-23 14:47 ` [PATCH 3/3 v1] usb: fotg210: Select subdriver by mode Linus Walleij
` (2 subsequent siblings)
3 siblings, 0 replies; 7+ messages in thread
From: Linus Walleij @ 2022-10-23 14:47 UTC (permalink / raw)
To: Greg Kroah-Hartman
Cc: linux-usb, Linus Walleij, Fabian Vogt, Yuan-Hsin Chen,
Felipe Balbi
It is since ages perfectly possible to compile both of these
modules into the same kernel, which makes no sense since it
is one piece of hardware.
Compile one module named "fotg210.ko" for both HCD and UDC
drivers by collecting the init calls into a fotg210-core.c
file and start to centralize things handling one and the same
piece of hardware.
Stub out the initcalls if one or the other part of the driver
was not selected.
Tested by compiling one or the other or both of the drivers
into the kernel and as modules.
Cc: Fabian Vogt <fabian@ritter-vogt.de>
Cc: Yuan-Hsin Chen <yhchen@faraday-tech.com>
Cc: Felipe Balbi <balbi@kernel.org>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
---
drivers/usb/fotg210/Kconfig | 4 +-
drivers/usb/fotg210/Makefile | 11 ++++-
drivers/usb/fotg210/fotg210-core.c | 79 ++++++++++++++++++++++++++++++
drivers/usb/fotg210/fotg210-hcd.c | 49 +++---------------
drivers/usb/fotg210/fotg210-udc.c | 19 ++-----
drivers/usb/fotg210/fotg210.h | 42 ++++++++++++++++
6 files changed, 142 insertions(+), 62 deletions(-)
create mode 100644 drivers/usb/fotg210/fotg210-core.c
create mode 100644 drivers/usb/fotg210/fotg210.h
diff --git a/drivers/usb/fotg210/Kconfig b/drivers/usb/fotg210/Kconfig
index e7a106785f5d..933c513b5728 100644
--- a/drivers/usb/fotg210/Kconfig
+++ b/drivers/usb/fotg210/Kconfig
@@ -12,7 +12,7 @@ config USB_FOTG210
if USB_FOTG210
config USB_FOTG210_HCD
- tristate "Faraday FOTG210 USB Host Controller support"
+ bool "Faraday FOTG210 USB Host Controller support"
depends on USB
help
Faraday FOTG210 is an OTG controller which can be configured as
@@ -24,7 +24,7 @@ config USB_FOTG210_HCD
config USB_FOTG210_UDC
depends on USB_GADGET
- tristate "Faraday FOTG210 USB Peripheral Controller support"
+ bool "Faraday FOTG210 USB Peripheral Controller support"
help
Faraday USB2.0 OTG controller which can be configured as
high speed or full speed USB device. This driver suppports
diff --git a/drivers/usb/fotg210/Makefile b/drivers/usb/fotg210/Makefile
index f4a26ca0e563..5aecff21f24b 100644
--- a/drivers/usb/fotg210/Makefile
+++ b/drivers/usb/fotg210/Makefile
@@ -1,3 +1,10 @@
# SPDX-License-Identifier: GPL-2.0
-obj-$(CONFIG_USB_FOTG210_HCD) += fotg210-hcd.o
-obj-$(CONFIG_USB_FOTG210_UDC) += fotg210-udc.o
+
+# This setup links the different object files into one single
+# module so we don't have to EXPORT() a lot of internal symbols
+# or create unnecessary submodules.
+fotg210-objs-y += fotg210-core.o
+fotg210-objs-$(CONFIG_USB_FOTG210_HCD) += fotg210-hcd.o
+fotg210-objs-$(CONFIG_USB_FOTG210_UDC) += fotg210-udc.o
+fotg210-objs := $(fotg210-objs-y)
+obj-$(CONFIG_USB_FOTG210) += fotg210.o
diff --git a/drivers/usb/fotg210/fotg210-core.c b/drivers/usb/fotg210/fotg210-core.c
new file mode 100644
index 000000000000..ab7b8974bc18
--- /dev/null
+++ b/drivers/usb/fotg210/fotg210-core.c
@@ -0,0 +1,79 @@
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ * Central probing code for the FOTG210 dual role driver
+ * We register one driver for the hardware and then we decide
+ * whether to proceed with probing the host or the peripheral
+ * driver.
+ */
+#include <linux/device.h>
+#include <linux/module.h>
+#include <linux/of.h>
+#include <linux/platform_device.h>
+#include <linux/usb.h>
+
+#include "fotg210.h"
+
+static int fotg210_probe(struct platform_device *pdev)
+{
+ int ret;
+
+ if (IS_ENABLED(CONFIG_USB_FOTG210_HCD)) {
+ ret = fotg210_hcd_probe(pdev);
+ if (ret)
+ return ret;
+ }
+ if (IS_ENABLED(CONFIG_USB_FOTG210_UDC))
+ ret = fotg210_udc_probe(pdev);
+
+ return ret;
+}
+
+static int fotg210_remove(struct platform_device *pdev)
+{
+ if (IS_ENABLED(CONFIG_USB_FOTG210_HCD))
+ fotg210_hcd_remove(pdev);
+ if (IS_ENABLED(CONFIG_USB_FOTG210_UDC))
+ fotg210_udc_remove(pdev);
+
+ return 0;
+}
+
+#ifdef CONFIG_OF
+static const struct of_device_id fotg210_of_match[] = {
+ { .compatible = "faraday,fotg210" },
+ {},
+};
+MODULE_DEVICE_TABLE(of, fotg210_of_match);
+#endif
+
+static struct platform_driver fotg210_driver = {
+ .driver = {
+ .name = "fotg210",
+ .of_match_table = of_match_ptr(fotg210_of_match),
+ },
+ .probe = fotg210_probe,
+ .remove = fotg210_remove,
+};
+
+static int __init fotg210_init(void)
+{
+ if (usb_disabled())
+ return -ENODEV;
+
+ if (IS_ENABLED(CONFIG_USB_FOTG210_HCD))
+ fotg210_hcd_init();
+ return platform_driver_register(&fotg210_driver);
+}
+module_init(fotg210_init);
+
+static void __exit fotg210_cleanup(void)
+{
+ platform_driver_unregister(&fotg210_driver);
+ if (IS_ENABLED(CONFIG_USB_FOTG210_HCD))
+ fotg210_hcd_cleanup();
+}
+module_exit(fotg210_cleanup);
+
+MODULE_AUTHOR("Yuan-Hsin Chen, Feng-Hsin Chiang");
+MODULE_LICENSE("GPL");
+MODULE_DESCRIPTION("FOTG210 Dual Role Controller Driver");
diff --git a/drivers/usb/fotg210/fotg210-hcd.c b/drivers/usb/fotg210/fotg210-hcd.c
index 8fbf63e76d7d..51ac93a2eb98 100644
--- a/drivers/usb/fotg210/fotg210-hcd.c
+++ b/drivers/usb/fotg210/fotg210-hcd.c
@@ -39,8 +39,8 @@
#include <asm/irq.h>
#include <asm/unaligned.h>
-#define DRIVER_AUTHOR "Yuan-Hsin Chen"
-#define DRIVER_DESC "FOTG210 Host Controller (EHCI) Driver"
+#include "fotg210.h"
+
static const char hcd_name[] = "fotg210_hcd";
#undef FOTG210_URB_TRACE
@@ -5490,9 +5490,6 @@ static int fotg210_get_frame(struct usb_hcd *hcd)
* functions and in order to facilitate role switching we cannot
* give the fotg210 driver exclusive access to those.
*/
-MODULE_DESCRIPTION(DRIVER_DESC);
-MODULE_AUTHOR(DRIVER_AUTHOR);
-MODULE_LICENSE("GPL");
static const struct hc_driver fotg210_fotg210_hc_driver = {
.description = hcd_name,
@@ -5560,7 +5557,7 @@ static void fotg210_init(struct fotg210_hcd *fotg210)
* then invokes the start() method for the HCD associated with it
* through the hotplug entry's driver_data.
*/
-static int fotg210_hcd_probe(struct platform_device *pdev)
+int fotg210_hcd_probe(struct platform_device *pdev)
{
struct device *dev = &pdev->dev;
struct usb_hcd *hcd;
@@ -5652,7 +5649,7 @@ static int fotg210_hcd_probe(struct platform_device *pdev)
* @dev: USB Host Controller being removed
*
*/
-static int fotg210_hcd_remove(struct platform_device *pdev)
+int fotg210_hcd_remove(struct platform_device *pdev)
{
struct usb_hcd *hcd = platform_get_drvdata(pdev);
struct fotg210_hcd *fotg210 = hcd_to_fotg210(hcd);
@@ -5668,27 +5665,8 @@ static int fotg210_hcd_remove(struct platform_device *pdev)
return 0;
}
-#ifdef CONFIG_OF
-static const struct of_device_id fotg210_of_match[] = {
- { .compatible = "faraday,fotg210" },
- {},
-};
-MODULE_DEVICE_TABLE(of, fotg210_of_match);
-#endif
-
-static struct platform_driver fotg210_hcd_driver = {
- .driver = {
- .name = "fotg210-hcd",
- .of_match_table = of_match_ptr(fotg210_of_match),
- },
- .probe = fotg210_hcd_probe,
- .remove = fotg210_hcd_remove,
-};
-
-static int __init fotg210_hcd_init(void)
+int __init fotg210_hcd_init(void)
{
- int retval = 0;
-
if (usb_disabled())
return -ENODEV;
@@ -5704,24 +5682,11 @@ static int __init fotg210_hcd_init(void)
fotg210_debug_root = debugfs_create_dir("fotg210", usb_debug_root);
- retval = platform_driver_register(&fotg210_hcd_driver);
- if (retval < 0)
- goto clean;
- return retval;
-
-clean:
- debugfs_remove(fotg210_debug_root);
- fotg210_debug_root = NULL;
-
- clear_bit(USB_EHCI_LOADED, &usb_hcds_loaded);
- return retval;
+ return 0;
}
-module_init(fotg210_hcd_init);
-static void __exit fotg210_hcd_cleanup(void)
+void __exit fotg210_hcd_cleanup(void)
{
- platform_driver_unregister(&fotg210_hcd_driver);
debugfs_remove(fotg210_debug_root);
clear_bit(USB_EHCI_LOADED, &usb_hcds_loaded);
}
-module_exit(fotg210_hcd_cleanup);
diff --git a/drivers/usb/fotg210/fotg210-udc.c b/drivers/usb/fotg210/fotg210-udc.c
index 01a4509775b2..7757aaa11d6f 100644
--- a/drivers/usb/fotg210/fotg210-udc.c
+++ b/drivers/usb/fotg210/fotg210-udc.c
@@ -16,6 +16,7 @@
#include <linux/usb/ch9.h>
#include <linux/usb/gadget.h>
+#include "fotg210.h"
#include "fotg210-udc.h"
#define DRIVER_DESC "FOTG210 USB Device Controller Driver"
@@ -1068,7 +1069,7 @@ static const struct usb_gadget_ops fotg210_gadget_ops = {
.udc_stop = fotg210_udc_stop,
};
-static int fotg210_udc_remove(struct platform_device *pdev)
+int fotg210_udc_remove(struct platform_device *pdev)
{
struct fotg210_udc *fotg210 = platform_get_drvdata(pdev);
int i;
@@ -1085,7 +1086,7 @@ static int fotg210_udc_remove(struct platform_device *pdev)
return 0;
}
-static int fotg210_udc_probe(struct platform_device *pdev)
+int fotg210_udc_probe(struct platform_device *pdev)
{
struct resource *res, *ires;
struct fotg210_udc *fotg210 = NULL;
@@ -1208,17 +1209,3 @@ static int fotg210_udc_probe(struct platform_device *pdev)
err:
return ret;
}
-
-static struct platform_driver fotg210_driver = {
- .driver = {
- .name = udc_name,
- },
- .probe = fotg210_udc_probe,
- .remove = fotg210_udc_remove,
-};
-
-module_platform_driver(fotg210_driver);
-
-MODULE_AUTHOR("Yuan-Hsin Chen, Feng-Hsin Chiang <john453@faraday-tech.com>");
-MODULE_LICENSE("GPL");
-MODULE_DESCRIPTION(DRIVER_DESC);
diff --git a/drivers/usb/fotg210/fotg210.h b/drivers/usb/fotg210/fotg210.h
new file mode 100644
index 000000000000..ef79d8323d89
--- /dev/null
+++ b/drivers/usb/fotg210/fotg210.h
@@ -0,0 +1,42 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+#ifndef __FOTG210_H
+#define __FOTG210_H
+
+#ifdef CONFIG_USB_FOTG210_HCD
+int fotg210_hcd_probe(struct platform_device *pdev);
+int fotg210_hcd_remove(struct platform_device *pdev);
+int fotg210_hcd_init(void);
+void fotg210_hcd_cleanup(void);
+#else
+static inline int fotg210_hcd_probe(struct platform_device *pdev)
+{
+ return 0;
+}
+static inline int fotg210_hcd_remove(struct platform_device *pdev)
+{
+ return 0;
+}
+static inline int fotg210_hcd_init(void)
+{
+ return 0;
+}
+static inline void fotg210_hcd_cleanup(void)
+{
+}
+#endif
+
+#ifdef CONFIG_USB_FOTG210_UDC
+int fotg210_udc_probe(struct platform_device *pdev);
+int fotg210_udc_remove(struct platform_device *pdev);
+#else
+static inline int fotg210_udc_probe(struct platform_device *pdev)
+{
+ return 0;
+}
+static inline int fotg210_udc_remove(struct platform_device *pdev)
+{
+ return 0;
+}
+#endif
+
+#endif /* __FOTG210_H */
--
2.37.3
^ permalink raw reply related [flat|nested] 7+ messages in thread
* [PATCH 3/3 v1] usb: fotg210: Select subdriver by mode
2022-10-23 14:47 [PATCH 1/3 v1] usb: fotg210: Collect pieces of dual mode controller Linus Walleij
2022-10-23 14:47 ` [PATCH 2/3 v1] usb: fotg210: Compile into one module Linus Walleij
@ 2022-10-23 14:47 ` Linus Walleij
2022-10-23 15:33 ` [PATCH 1/3 v1] usb: fotg210: Collect pieces of dual mode controller Greg Kroah-Hartman
2022-11-06 23:20 ` Linus Walleij
3 siblings, 0 replies; 7+ messages in thread
From: Linus Walleij @ 2022-10-23 14:47 UTC (permalink / raw)
To: Greg Kroah-Hartman
Cc: linux-usb, Linus Walleij, Fabian Vogt, Yuan-Hsin Chen,
Felipe Balbi
Check which mode the hardware is in, and selecte the peripheral
driver if the hardware is in explicit peripheral mode, otherwise
select host mode.
This should solve the immediate problem that both subdrivers
can get probed.
Cc: Fabian Vogt <fabian@ritter-vogt.de>
Cc: Yuan-Hsin Chen <yhchen@faraday-tech.com>
Cc: Felipe Balbi <balbi@kernel.org>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
---
drivers/usb/fotg210/fotg210-core.c | 25 ++++++++++++++++---------
1 file changed, 16 insertions(+), 9 deletions(-)
diff --git a/drivers/usb/fotg210/fotg210-core.c b/drivers/usb/fotg210/fotg210-core.c
index ab7b8974bc18..3d07ee46f6d1 100644
--- a/drivers/usb/fotg210/fotg210-core.c
+++ b/drivers/usb/fotg210/fotg210-core.c
@@ -10,30 +10,37 @@
#include <linux/of.h>
#include <linux/platform_device.h>
#include <linux/usb.h>
+#include <linux/usb/otg.h>
#include "fotg210.h"
static int fotg210_probe(struct platform_device *pdev)
{
+ struct device *dev = &pdev->dev;
+ enum usb_dr_mode mode;
int ret;
- if (IS_ENABLED(CONFIG_USB_FOTG210_HCD)) {
- ret = fotg210_hcd_probe(pdev);
- if (ret)
- return ret;
- }
- if (IS_ENABLED(CONFIG_USB_FOTG210_UDC))
+ mode = usb_get_dr_mode(dev);
+
+ if (mode == USB_DR_MODE_PERIPHERAL)
ret = fotg210_udc_probe(pdev);
+ else
+ ret = fotg210_hcd_probe(pdev);
return ret;
}
static int fotg210_remove(struct platform_device *pdev)
{
- if (IS_ENABLED(CONFIG_USB_FOTG210_HCD))
- fotg210_hcd_remove(pdev);
- if (IS_ENABLED(CONFIG_USB_FOTG210_UDC))
+ struct device *dev = &pdev->dev;
+ enum usb_dr_mode mode;
+
+ mode = usb_get_dr_mode(dev);
+
+ if (mode == USB_DR_MODE_PERIPHERAL)
fotg210_udc_remove(pdev);
+ else
+ fotg210_hcd_remove(pdev);
return 0;
}
--
2.37.3
^ permalink raw reply related [flat|nested] 7+ messages in thread
* Re: [PATCH 1/3 v1] usb: fotg210: Collect pieces of dual mode controller
2022-10-23 14:47 [PATCH 1/3 v1] usb: fotg210: Collect pieces of dual mode controller Linus Walleij
2022-10-23 14:47 ` [PATCH 2/3 v1] usb: fotg210: Compile into one module Linus Walleij
2022-10-23 14:47 ` [PATCH 3/3 v1] usb: fotg210: Select subdriver by mode Linus Walleij
@ 2022-10-23 15:33 ` Greg Kroah-Hartman
2022-10-23 19:41 ` Linus Walleij
2022-11-06 23:20 ` Linus Walleij
3 siblings, 1 reply; 7+ messages in thread
From: Greg Kroah-Hartman @ 2022-10-23 15:33 UTC (permalink / raw)
To: Linus Walleij; +Cc: linux-usb, Fabian Vogt, Yuan-Hsin Chen, Felipe Balbi
On Sun, Oct 23, 2022 at 04:47:06PM +0200, Linus Walleij wrote:
> The Faraday FOTG210 is a dual-mode OTG USB controller that can
> act as host, peripheral or both. To be able to probe from one
> hardware description and to follow the pattern of other dual-
> mode controllers such as MUSB or MTU3 we need to collect the
> two, currently completely separate drivers in the same
> directory.
>
> After this, users need to select the main symbol USB_FOTG210
> and then each respective subdriver. We pave the road to
> compile both drivers into the same kernel and select the
> one we want to use at probe() time, and possibly add OTG
> support in the end.
>
> This patch doesn't do much more than create the new symbol
> and collect the drivers in one place. We also add a comment
> for the section of dual-mode controllers in the Kconfig
> file so people can see what these selections are about.
>
> Also add myself as maintainer as there has been little
> response on my patches to these drivers.
Is this IP block still showing up on new devices? It is really old, and
OTG is long dead from what I remember. Does any real device actually
support that type of mode?
I have no objection to taking these, and I'm glad to see you maintain
them, I just don't want you to have to maintain dead code for devices
that are not around anymore.
thanks,
greg k-h
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH 1/3 v1] usb: fotg210: Collect pieces of dual mode controller
2022-10-23 15:33 ` [PATCH 1/3 v1] usb: fotg210: Collect pieces of dual mode controller Greg Kroah-Hartman
@ 2022-10-23 19:41 ` Linus Walleij
0 siblings, 0 replies; 7+ messages in thread
From: Linus Walleij @ 2022-10-23 19:41 UTC (permalink / raw)
To: Greg Kroah-Hartman; +Cc: linux-usb, Fabian Vogt, Yuan-Hsin Chen, Felipe Balbi
On Sun, Oct 23, 2022 at 5:33 PM Greg Kroah-Hartman
<gregkh@linuxfoundation.org> wrote:
> Is this IP block still showing up on new devices?
Don't think so.
> It is really old, and
> OTG is long dead from what I remember. Does any real device actually
> support that type of mode?
What is supports is dual role. In the Gemini devices that I work on
it is either host or peripheral never role switching.
> I have no objection to taking these, and I'm glad to see you maintain
> them, I just don't want you to have to maintain dead code for devices
> that are not around anymore.
Oh, I use it, others use it (new devices were added recently by
Corentin Labbe) and it has full support in the OpenWrt distribution.
I also have a few more patches cooking, but figured collecting the
stuff in one place would be the first step.
Yours,
Linus Walleij
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH 1/3 v1] usb: fotg210: Collect pieces of dual mode controller
2022-10-23 14:47 [PATCH 1/3 v1] usb: fotg210: Collect pieces of dual mode controller Linus Walleij
` (2 preceding siblings ...)
2022-10-23 15:33 ` [PATCH 1/3 v1] usb: fotg210: Collect pieces of dual mode controller Greg Kroah-Hartman
@ 2022-11-06 23:20 ` Linus Walleij
2022-11-09 11:38 ` Greg Kroah-Hartman
3 siblings, 1 reply; 7+ messages in thread
From: Linus Walleij @ 2022-11-06 23:20 UTC (permalink / raw)
To: Greg Kroah-Hartman; +Cc: linux-usb, Fabian Vogt, Yuan-Hsin Chen, Felipe Balbi
On Sun, Oct 23, 2022 at 4:49 PM Linus Walleij <linus.walleij@linaro.org> wrote:
> The Faraday FOTG210 is a dual-mode OTG USB controller that can
> act as host, peripheral or both. To be able to probe from one
> hardware description and to follow the pattern of other dual-
> mode controllers such as MUSB or MTU3 we need to collect the
> two, currently completely separate drivers in the same
> directory.
>
> After this, users need to select the main symbol USB_FOTG210
> and then each respective subdriver. We pave the road to
> compile both drivers into the same kernel and select the
> one we want to use at probe() time, and possibly add OTG
> support in the end.
>
> This patch doesn't do much more than create the new symbol
> and collect the drivers in one place. We also add a comment
> for the section of dual-mode controllers in the Kconfig
> file so people can see what these selections are about.
>
> Also add myself as maintainer as there has been little
> response on my patches to these drivers.
>
> Cc: Fabian Vogt <fabian@ritter-vogt.de>
> Cc: Yuan-Hsin Chen <yhchen@faraday-tech.com>
> Cc: Felipe Balbi <balbi@kernel.org>
> Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
Greg are these fine to merge? I have some more patches coming
so I would like to establish these as a base.
Yours,
Linus Walleij
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH 1/3 v1] usb: fotg210: Collect pieces of dual mode controller
2022-11-06 23:20 ` Linus Walleij
@ 2022-11-09 11:38 ` Greg Kroah-Hartman
0 siblings, 0 replies; 7+ messages in thread
From: Greg Kroah-Hartman @ 2022-11-09 11:38 UTC (permalink / raw)
To: Linus Walleij; +Cc: linux-usb, Fabian Vogt, Yuan-Hsin Chen, Felipe Balbi
On Mon, Nov 07, 2022 at 12:20:14AM +0100, Linus Walleij wrote:
> On Sun, Oct 23, 2022 at 4:49 PM Linus Walleij <linus.walleij@linaro.org> wrote:
>
> > The Faraday FOTG210 is a dual-mode OTG USB controller that can
> > act as host, peripheral or both. To be able to probe from one
> > hardware description and to follow the pattern of other dual-
> > mode controllers such as MUSB or MTU3 we need to collect the
> > two, currently completely separate drivers in the same
> > directory.
> >
> > After this, users need to select the main symbol USB_FOTG210
> > and then each respective subdriver. We pave the road to
> > compile both drivers into the same kernel and select the
> > one we want to use at probe() time, and possibly add OTG
> > support in the end.
> >
> > This patch doesn't do much more than create the new symbol
> > and collect the drivers in one place. We also add a comment
> > for the section of dual-mode controllers in the Kconfig
> > file so people can see what these selections are about.
> >
> > Also add myself as maintainer as there has been little
> > response on my patches to these drivers.
> >
> > Cc: Fabian Vogt <fabian@ritter-vogt.de>
> > Cc: Yuan-Hsin Chen <yhchen@faraday-tech.com>
> > Cc: Felipe Balbi <balbi@kernel.org>
> > Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
>
> Greg are these fine to merge? I have some more patches coming
> so I would like to establish these as a base.
Now queued up, sorry for the delay.
greg k-h
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2022-11-09 11:38 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-10-23 14:47 [PATCH 1/3 v1] usb: fotg210: Collect pieces of dual mode controller Linus Walleij
2022-10-23 14:47 ` [PATCH 2/3 v1] usb: fotg210: Compile into one module Linus Walleij
2022-10-23 14:47 ` [PATCH 3/3 v1] usb: fotg210: Select subdriver by mode Linus Walleij
2022-10-23 15:33 ` [PATCH 1/3 v1] usb: fotg210: Collect pieces of dual mode controller Greg Kroah-Hartman
2022-10-23 19:41 ` Linus Walleij
2022-11-06 23:20 ` Linus Walleij
2022-11-09 11:38 ` Greg Kroah-Hartman
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).