diff mbox series

hw/usb: Add generic sys-bus EHCI controller

Message ID 1546077657-22637-1-git-send-email-hongbo.zhang@linaro.org
State Accepted
Commit 114529f79ec37261dda7e3c7846a04a5bfc212bd
Headers show
Series hw/usb: Add generic sys-bus EHCI controller | expand

Commit Message

Hongbo Zhang Dec. 29, 2018, 10 a.m. UTC
This patch introduces a new system bus generic EHCI controller.
For the system bus EHCI controller, we've already had "xlnx",
"exynos4210", "tegra2", "ppc4xx" and "fusbh200", they are specific and
only suitable for their own platforms, platforms such as an Arm server,
may need a generic system bus EHCI controller, this patch creates it,
and the kernel driver ehci_platform.c works well on it.

Signed-off-by: Hongbo Zhang <hongbo.zhang@linaro.org>

---
 hw/usb/hcd-ehci-sysbus.c | 17 +++++++++++++++++
 hw/usb/hcd-ehci.h        |  1 +
 2 files changed, 18 insertions(+)

-- 
2.7.4

Comments

Gerd Hoffmann Jan. 8, 2019, 11:42 a.m. UTC | #1
On Sat, Dec 29, 2018 at 06:00:57PM +0800, Hongbo Zhang wrote:
> This patch introduces a new system bus generic EHCI controller.

> For the system bus EHCI controller, we've already had "xlnx",

> "exynos4210", "tegra2", "ppc4xx" and "fusbh200", they are specific and

> only suitable for their own platforms, platforms such as an Arm server,

> may need a generic system bus EHCI controller, this patch creates it,

> and the kernel driver ehci_platform.c works well on it.


Added to usb queue.

thanks,
  Gerd
BALATON Zoltan Jan. 8, 2019, 12:11 p.m. UTC | #2
On Tue, 8 Jan 2019, Gerd Hoffmann wrote:
> On Sat, Dec 29, 2018 at 06:00:57PM +0800, Hongbo Zhang wrote:

>> This patch introduces a new system bus generic EHCI controller.

>> For the system bus EHCI controller, we've already had "xlnx",

>> "exynos4210", "tegra2", "ppc4xx" and "fusbh200", they are specific and

>> only suitable for their own platforms, platforms such as an Arm server,

>> may need a generic system bus EHCI controller, this patch creates it,

>> and the kernel driver ehci_platform.c works well on it.

>

> Added to usb queue.


Most of these only differ in capsbase and opregbase and we only need a 
separate subclass for them because ehci-sysbus is .abstract=true so cannot 
be instantiated. I wonder if it would be simpler to add properties to 
ehci-sysbus to allow setting these base values and allow it to be used 
directly, then most of these subclasses could be removed and only need 
subclass for those that are really do something more (maybe only fusbh200 
currently).

(Just asking, I'm not volunteering to make a patch.)

Regards,
BALATON Zoltan
Gerd Hoffmann Jan. 8, 2019, 12:24 p.m. UTC | #3
On Tue, Jan 08, 2019 at 01:11:29PM +0100, BALATON Zoltan wrote:
> On Tue, 8 Jan 2019, Gerd Hoffmann wrote:

> > On Sat, Dec 29, 2018 at 06:00:57PM +0800, Hongbo Zhang wrote:

> > > This patch introduces a new system bus generic EHCI controller.

> > > For the system bus EHCI controller, we've already had "xlnx",

> > > "exynos4210", "tegra2", "ppc4xx" and "fusbh200", they are specific and

> > > only suitable for their own platforms, platforms such as an Arm server,

> > > may need a generic system bus EHCI controller, this patch creates it,

> > > and the kernel driver ehci_platform.c works well on it.

> > 

> > Added to usb queue.

> 

> Most of these only differ in capsbase and opregbase and we only need a

> separate subclass for them because ehci-sysbus is .abstract=true so cannot

> be instantiated. I wonder if it would be simpler to add properties to

> ehci-sysbus to allow setting these base values and allow it to be used

> directly, then most of these subclasses could be removed and only need

> subclass for those that are really do something more (maybe only fusbh200

> currently).


Not sure it is that simple, I think the class names are also used for
device tree generation ...

cheers,
  Gerd
diff mbox series

Patch

diff --git a/hw/usb/hcd-ehci-sysbus.c b/hw/usb/hcd-ehci-sysbus.c
index 3b83beb..331faf8 100644
--- a/hw/usb/hcd-ehci-sysbus.c
+++ b/hw/usb/hcd-ehci-sysbus.c
@@ -94,6 +94,22 @@  static const TypeInfo ehci_type_info = {
     .class_size    = sizeof(SysBusEHCIClass),
 };
 
+static void ehci_platform_class_init(ObjectClass *oc, void *data)
+{
+    SysBusEHCIClass *sec = SYS_BUS_EHCI_CLASS(oc);
+    DeviceClass *dc = DEVICE_CLASS(oc);
+
+    sec->capsbase = 0x0;
+    sec->opregbase = 0x20;
+    set_bit(DEVICE_CATEGORY_USB, dc->categories);
+}
+
+static const TypeInfo ehci_platform_type_info = {
+    .name          = TYPE_PLATFORM_EHCI,
+    .parent        = TYPE_SYS_BUS_EHCI,
+    .class_init    = ehci_platform_class_init,
+};
+
 static void ehci_xlnx_class_init(ObjectClass *oc, void *data)
 {
     SysBusEHCIClass *sec = SYS_BUS_EHCI_CLASS(oc);
@@ -245,6 +261,7 @@  static const TypeInfo ehci_fusbh200_type_info = {
 static void ehci_sysbus_register_types(void)
 {
     type_register_static(&ehci_type_info);
+    type_register_static(&ehci_platform_type_info);
     type_register_static(&ehci_xlnx_type_info);
     type_register_static(&ehci_exynos4210_type_info);
     type_register_static(&ehci_tegra2_type_info);
diff --git a/hw/usb/hcd-ehci.h b/hw/usb/hcd-ehci.h
index 0bc364b..cd30b5d 100644
--- a/hw/usb/hcd-ehci.h
+++ b/hw/usb/hcd-ehci.h
@@ -342,6 +342,7 @@  typedef struct EHCIPCIState {
 
 
 #define TYPE_SYS_BUS_EHCI "sysbus-ehci-usb"
+#define TYPE_PLATFORM_EHCI "platform-ehci-usb"
 #define TYPE_EXYNOS4210_EHCI "exynos4210-ehci-usb"
 #define TYPE_TEGRA2_EHCI "tegra2-ehci-usb"
 #define TYPE_PPC4xx_EHCI "ppc4xx-ehci-usb"