* [PATCH 0/2] hw/usb: Add TI TUSB73X0 XHCI controller model @ 2024-11-10 5:00 Nicholas Piggin 2024-11-10 5:00 ` [PATCH 1/2] hw/usb: Make PCI device more configurable Nicholas Piggin 2024-11-10 5:00 ` [PATCH 2/2] hw/usb: Add TI TUSB73X0 XHCI controller model Nicholas Piggin 0 siblings, 2 replies; 5+ messages in thread From: Nicholas Piggin @ 2024-11-10 5:00 UTC (permalink / raw) To: qemu-devel Cc: Nicholas Piggin, Paolo Bonzini, Michael S. Tsirkin, Marcel Apfelbaum, Gerd Hoffmann Hi, This adds a new USB XHCI model. The biggest change is really making some XHCI PCI config dynamic and the MSIX init has some changes to support a separate BAR (hopefully now it has better error handling. Thanks, Nick Nicholas Piggin (2): hw/usb: Make PCI device more configurable hw/usb: Add TI TUSB73X0 XHCI controller model hw/usb/hcd-xhci-pci.h | 9 ++++ include/hw/pci/pci_ids.h | 1 + include/hw/usb/xhci.h | 1 + hw/usb/hcd-xhci-nec.c | 10 +++++ hw/usb/hcd-xhci-pci.c | 69 ++++++++++++++++++++++++----- hw/usb/hcd-xhci-ti.c | 94 ++++++++++++++++++++++++++++++++++++++++ hw/usb/Kconfig | 5 +++ hw/usb/meson.build | 1 + 8 files changed, 180 insertions(+), 10 deletions(-) create mode 100644 hw/usb/hcd-xhci-ti.c -- 2.45.2 ^ permalink raw reply [flat|nested] 5+ messages in thread
* [PATCH 1/2] hw/usb: Make PCI device more configurable 2024-11-10 5:00 [PATCH 0/2] hw/usb: Add TI TUSB73X0 XHCI controller model Nicholas Piggin @ 2024-11-10 5:00 ` Nicholas Piggin 2024-11-10 5:00 ` [PATCH 2/2] hw/usb: Add TI TUSB73X0 XHCI controller model Nicholas Piggin 1 sibling, 0 replies; 5+ messages in thread From: Nicholas Piggin @ 2024-11-10 5:00 UTC (permalink / raw) To: qemu-devel Cc: Nicholas Piggin, Paolo Bonzini, Michael S. Tsirkin, Marcel Apfelbaum, Gerd Hoffmann To prepare to support another USB PCI Host Controller, make some PCI configuration dynamic. Signed-off-by: Nicholas Piggin <npiggin@gmail.com> --- hw/usb/hcd-xhci-pci.h | 9 ++++++ hw/usb/hcd-xhci-nec.c | 10 +++++++ hw/usb/hcd-xhci-pci.c | 69 ++++++++++++++++++++++++++++++++++++------- 3 files changed, 78 insertions(+), 10 deletions(-) diff --git a/hw/usb/hcd-xhci-pci.h b/hw/usb/hcd-xhci-pci.h index 08f70ce97c..213076aabf 100644 --- a/hw/usb/hcd-xhci-pci.h +++ b/hw/usb/hcd-xhci-pci.h @@ -40,6 +40,15 @@ typedef struct XHCIPciState { XHCIState xhci; OnOffAuto msi; OnOffAuto msix; + uint8_t cache_line_size; + uint8_t pm_cap_off; + uint8_t pcie_cap_off; + uint8_t msi_cap_off; + uint8_t msix_cap_off; + int msix_bar_nr; + uint64_t msix_bar_size; + uint32_t msix_table_off; + uint32_t msix_pba_off; } XHCIPciState; #endif diff --git a/hw/usb/hcd-xhci-nec.c b/hw/usb/hcd-xhci-nec.c index 0c063b3697..e23b5ff084 100644 --- a/hw/usb/hcd-xhci-nec.c +++ b/hw/usb/hcd-xhci-nec.c @@ -54,6 +54,16 @@ static void nec_xhci_instance_init(Object *obj) pci->xhci.flags = nec->flags; pci->xhci.numintrs = nec->intrs; pci->xhci.numslots = nec->slots; + + pci->cache_line_size = 0x10; + pci->pm_cap_off = 0; + pci->pcie_cap_off = 0xa0; + pci->msi_cap_off = 0x70; + pci->msix_cap_off = 0x90; + pci->msix_bar_nr = 0; + pci->msix_bar_size = 0; + pci->msix_table_off = 0x3000; + pci->msix_pba_off = 0x3800; } static void nec_xhci_class_init(ObjectClass *klass, void *data) diff --git a/hw/usb/hcd-xhci-pci.c b/hw/usb/hcd-xhci-pci.c index a039f5778a..948d75b737 100644 --- a/hw/usb/hcd-xhci-pci.c +++ b/hw/usb/hcd-xhci-pci.c @@ -32,8 +32,9 @@ #include "trace.h" #include "qapi/error.h" -#define OFF_MSIX_TABLE 0x3000 -#define OFF_MSIX_PBA 0x3800 +#define MSIX_BAR_SIZE 0x800000 +#define OFF_MSIX_TABLE 0x0000 +#define OFF_MSIX_PBA 0x1000 static void xhci_pci_intr_update(XHCIState *xhci, int n, bool enable) { @@ -104,6 +105,31 @@ static int xhci_pci_vmstate_post_load(void *opaque, int version_id) return 0; } +static int xhci_pci_add_pm_capability(PCIDevice *pci_dev, uint8_t offset, + Error **errp) +{ + int err; + + err = pci_add_capability(pci_dev, PCI_CAP_ID_PM, offset, + PCI_PM_SIZEOF, errp); + if (err < 0) { + return err; + } + + pci_set_word(pci_dev->config + offset + PCI_PM_PMC, + PCI_PM_CAP_VER_1_2 | + PCI_PM_CAP_D1 | PCI_PM_CAP_D2 | + PCI_PM_CAP_PME_D0 | PCI_PM_CAP_PME_D1 | + PCI_PM_CAP_PME_D2 | PCI_PM_CAP_PME_D3hot); + pci_set_word(pci_dev->wmask + offset + PCI_PM_PMC, 0); + pci_set_word(pci_dev->config + offset + PCI_PM_CTRL, + PCI_PM_CTRL_NO_SOFT_RESET); + pci_set_word(pci_dev->wmask + offset + PCI_PM_CTRL, + PCI_PM_CTRL_STATE_MASK); + + return 0; +} + static void usb_xhci_pci_realize(struct PCIDevice *dev, Error **errp) { int ret; @@ -112,7 +138,7 @@ static void usb_xhci_pci_realize(struct PCIDevice *dev, Error **errp) dev->config[PCI_CLASS_PROG] = 0x30; /* xHCI */ dev->config[PCI_INTERRUPT_PIN] = 0x01; /* interrupt pin 1 */ - dev->config[PCI_CACHE_LINE_SIZE] = 0x10; + dev->config[PCI_CACHE_LINE_SIZE] = s->cache_line_size; dev->config[0x60] = 0x30; /* release number */ object_property_set_link(OBJECT(&s->xhci), "host", OBJECT(s), NULL); @@ -125,8 +151,16 @@ static void usb_xhci_pci_realize(struct PCIDevice *dev, Error **errp) s->xhci.nec_quirks = true; } + if (s->pm_cap_off) { + if (xhci_pci_add_pm_capability(dev, s->pm_cap_off, &err)) { + error_propagate(errp, err); + return; + } + } + if (s->msi != ON_OFF_AUTO_OFF) { - ret = msi_init(dev, 0x70, s->xhci.numintrs, true, false, &err); + ret = msi_init(dev, s->msi_cap_off, s->xhci.numintrs, + true, false, &err); /* * Any error other than -ENOTSUP(board's MSI support is broken) * is a programming error @@ -143,22 +177,37 @@ static void usb_xhci_pci_realize(struct PCIDevice *dev, Error **errp) /* With msi=auto, we fall back to MSI off silently */ error_free(err); } + pci_register_bar(dev, 0, PCI_BASE_ADDRESS_SPACE_MEMORY | PCI_BASE_ADDRESS_MEM_TYPE_64, &s->xhci.mem); if (pci_bus_is_express(pci_get_bus(dev))) { - ret = pcie_endpoint_cap_init(dev, 0xa0); + ret = pcie_endpoint_cap_init(dev, s->pcie_cap_off); assert(ret > 0); } if (s->msix != ON_OFF_AUTO_OFF) { - /* TODO check for errors, and should fail when msix=on */ - msix_init(dev, s->xhci.numintrs, - &s->xhci.mem, 0, OFF_MSIX_TABLE, - &s->xhci.mem, 0, OFF_MSIX_PBA, - 0x90, NULL); + MemoryRegion *msix_bar = &s->xhci.mem; + if (s->msix_bar_nr != 0) { + memory_region_init(&dev->msix_exclusive_bar, OBJECT(dev), + "xhci-msix", s->msix_bar_size); + msix_bar = &dev->msix_exclusive_bar; + } + + ret = msix_init(dev, s->xhci.numintrs, + msix_bar, s->msix_bar_nr, s->msix_table_off, + msix_bar, s->msix_bar_nr, s->msix_pba_off, + s->msix_cap_off, errp); + if (ret) { + return; + } + + pci_register_bar(dev, s->msix_bar_nr, + PCI_BASE_ADDRESS_SPACE_MEMORY | + PCI_BASE_ADDRESS_MEM_TYPE_64, + msix_bar); } s->xhci.as = pci_get_address_space(dev); } -- 2.45.2 ^ permalink raw reply related [flat|nested] 5+ messages in thread
* [PATCH 2/2] hw/usb: Add TI TUSB73X0 XHCI controller model 2024-11-10 5:00 [PATCH 0/2] hw/usb: Add TI TUSB73X0 XHCI controller model Nicholas Piggin 2024-11-10 5:00 ` [PATCH 1/2] hw/usb: Make PCI device more configurable Nicholas Piggin @ 2024-11-10 5:00 ` Nicholas Piggin 2024-11-10 15:39 ` Philippe Mathieu-Daudé 1 sibling, 1 reply; 5+ messages in thread From: Nicholas Piggin @ 2024-11-10 5:00 UTC (permalink / raw) To: qemu-devel Cc: Nicholas Piggin, Paolo Bonzini, Michael S. Tsirkin, Marcel Apfelbaum, Gerd Hoffmann This controller is accepted by IBM Power firmware when the subsystem IDs are set to Power servers. Firmware is picky about device support so the NEC driver does not work. The TI HW has some interesting differences from NEC, notably a separate BAR for MSIX, and PM capabilities. The spec is freely available without sign-up. Signed-off-by: Nicholas Piggin <npiggin@gmail.com> --- include/hw/pci/pci_ids.h | 1 + include/hw/usb/xhci.h | 1 + hw/usb/hcd-xhci-ti.c | 94 ++++++++++++++++++++++++++++++++++++++++ hw/usb/Kconfig | 5 +++ hw/usb/meson.build | 1 + 5 files changed, 102 insertions(+) create mode 100644 hw/usb/hcd-xhci-ti.c diff --git a/include/hw/pci/pci_ids.h b/include/hw/pci/pci_ids.h index f1a53fea8d..fdb692db51 100644 --- a/include/hw/pci/pci_ids.h +++ b/include/hw/pci/pci_ids.h @@ -182,6 +182,7 @@ #define PCI_VENDOR_ID_HP 0x103c #define PCI_VENDOR_ID_TI 0x104c +#define PCI_DEVICE_ID_TI_TUSB73X0 0x8241 #define PCI_VENDOR_ID_MOTOROLA 0x1057 #define PCI_DEVICE_ID_MOTOROLA_MPC106 0x0002 diff --git a/include/hw/usb/xhci.h b/include/hw/usb/xhci.h index 5c90e1373e..203ec1fca3 100644 --- a/include/hw/usb/xhci.h +++ b/include/hw/usb/xhci.h @@ -3,6 +3,7 @@ #define TYPE_XHCI "base-xhci" #define TYPE_NEC_XHCI "nec-usb-xhci" +#define TYPE_TI_XHCI "ti-usb-xhci" #define TYPE_QEMU_XHCI "qemu-xhci" #define TYPE_XHCI_SYSBUS "sysbus-xhci" diff --git a/hw/usb/hcd-xhci-ti.c b/hw/usb/hcd-xhci-ti.c new file mode 100644 index 0000000000..a3f7ef8ba2 --- /dev/null +++ b/hw/usb/hcd-xhci-ti.c @@ -0,0 +1,94 @@ +/* + * USB xHCI controller emulation + * Datasheet https://www.ti.com/product/TUSB7340 + * + * Copyright (c) 2011 Securiforest + * Date: 2011-05-11 ; Author: Hector Martin <hector@marcansoft.com> + * Based on usb-xhci-nec.c, emulates TI TUSB73X0 + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library 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 + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, see <http://www.gnu.org/licenses/>. + */ + +#include "qemu/osdep.h" +#include "hw/usb.h" +#include "qemu/module.h" +#include "hw/pci/pci.h" +#include "hw/qdev-properties.h" + +#include "hcd-xhci-pci.h" + +OBJECT_DECLARE_SIMPLE_TYPE(XHCITiState, TI_XHCI) + +struct XHCITiState { + /*< private >*/ + XHCIPciState parent_obj; + /*< public >*/ + uint32_t flags; + uint32_t intrs; + uint32_t slots; +}; + +static Property ti_xhci_properties[] = { + DEFINE_PROP_ON_OFF_AUTO("msi", XHCIPciState, msi, ON_OFF_AUTO_AUTO), + DEFINE_PROP_ON_OFF_AUTO("msix", XHCIPciState, msix, ON_OFF_AUTO_AUTO), + DEFINE_PROP_UINT32("intrs", XHCITiState, intrs, 8), + DEFINE_PROP_UINT32("slots", XHCITiState, slots, XHCI_MAXSLOTS), + DEFINE_PROP_END_OF_LIST(), +}; + +static void ti_xhci_instance_init(Object *obj) +{ + XHCIPciState *pci = XHCI_PCI(obj); + XHCITiState *ti = TI_XHCI(obj); + + pci->xhci.flags = ti->flags; + pci->xhci.numintrs = ti->intrs; + pci->xhci.numslots = ti->slots; + + pci->cache_line_size = 0x0; + pci->pm_cap_off = 0x40; + pci->pcie_cap_off = 0x70; + pci->msi_cap_off = 0x48; + pci->msix_cap_off = 0xc0; + pci->msix_bar_nr = 0x2; + pci->msix_bar_size = 0x800000; + pci->msix_table_off = 0x0; + pci->msix_pba_off = 0x1000; +} + +static void ti_xhci_class_init(ObjectClass *klass, void *data) +{ + PCIDeviceClass *k = PCI_DEVICE_CLASS(klass); + DeviceClass *dc = DEVICE_CLASS(klass); + + device_class_set_props(dc, ti_xhci_properties); + k->vendor_id = PCI_VENDOR_ID_TI; + k->device_id = PCI_DEVICE_ID_TI_TUSB73X0; + k->revision = 0x02; +} + +static const TypeInfo ti_xhci_info = { + .name = TYPE_TI_XHCI, + .parent = TYPE_XHCI_PCI, + .instance_size = sizeof(XHCITiState), + .instance_init = ti_xhci_instance_init, + .class_init = ti_xhci_class_init, +}; + +static void ti_xhci_register_types(void) +{ + type_register_static(&ti_xhci_info); +} + +type_init(ti_xhci_register_types) diff --git a/hw/usb/Kconfig b/hw/usb/Kconfig index 5fbecd2f43..8e5c4747af 100644 --- a/hw/usb/Kconfig +++ b/hw/usb/Kconfig @@ -49,6 +49,11 @@ config USB_XHCI_NEC default y if PCI_DEVICES select USB_XHCI_PCI +config USB_XHCI_TI + bool + default y if PCI_DEVICES + select USB_XHCI_PCI + config USB_XHCI_SYSBUS bool select USB_XHCI diff --git a/hw/usb/meson.build b/hw/usb/meson.build index 1b4d1507e4..b874a93f16 100644 --- a/hw/usb/meson.build +++ b/hw/usb/meson.build @@ -23,6 +23,7 @@ system_ss.add(when: 'CONFIG_USB_XHCI', if_true: files('hcd-xhci.c')) system_ss.add(when: 'CONFIG_USB_XHCI_PCI', if_true: files('hcd-xhci-pci.c')) system_ss.add(when: 'CONFIG_USB_XHCI_SYSBUS', if_true: files('hcd-xhci-sysbus.c')) system_ss.add(when: 'CONFIG_USB_XHCI_NEC', if_true: files('hcd-xhci-nec.c')) +system_ss.add(when: 'CONFIG_USB_XHCI_TI', if_true: files('hcd-xhci-ti.c')) system_ss.add(when: 'CONFIG_USB_DWC2', if_true: files('hcd-dwc2.c')) system_ss.add(when: 'CONFIG_USB_DWC3', if_true: files('hcd-dwc3.c')) -- 2.45.2 ^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH 2/2] hw/usb: Add TI TUSB73X0 XHCI controller model 2024-11-10 5:00 ` [PATCH 2/2] hw/usb: Add TI TUSB73X0 XHCI controller model Nicholas Piggin @ 2024-11-10 15:39 ` Philippe Mathieu-Daudé 2024-11-27 2:07 ` Nicholas Piggin 0 siblings, 1 reply; 5+ messages in thread From: Philippe Mathieu-Daudé @ 2024-11-10 15:39 UTC (permalink / raw) To: Nicholas Piggin, qemu-devel Cc: Paolo Bonzini, Michael S. Tsirkin, Marcel Apfelbaum, Gerd Hoffmann Hi Nick, On 10/11/24 05:00, Nicholas Piggin wrote: > This controller is accepted by IBM Power firmware when the subsystem IDs > are set to Power servers. Firmware is picky about device support so the > NEC driver does not work. > > The TI HW has some interesting differences from NEC, notably a separate > BAR for MSIX, and PM capabilities. The spec is freely available without > sign-up. > > Signed-off-by: Nicholas Piggin <npiggin@gmail.com> > --- > include/hw/pci/pci_ids.h | 1 + > include/hw/usb/xhci.h | 1 + > hw/usb/hcd-xhci-ti.c | 94 ++++++++++++++++++++++++++++++++++++++++ > hw/usb/Kconfig | 5 +++ > hw/usb/meson.build | 1 + > 5 files changed, 102 insertions(+) > create mode 100644 hw/usb/hcd-xhci-ti.c > > diff --git a/include/hw/pci/pci_ids.h b/include/hw/pci/pci_ids.h > index f1a53fea8d..fdb692db51 100644 > --- a/include/hw/pci/pci_ids.h > +++ b/include/hw/pci/pci_ids.h > @@ -182,6 +182,7 @@ > #define PCI_VENDOR_ID_HP 0x103c > > #define PCI_VENDOR_ID_TI 0x104c > +#define PCI_DEVICE_ID_TI_TUSB73X0 0x8241 > > #define PCI_VENDOR_ID_MOTOROLA 0x1057 > #define PCI_DEVICE_ID_MOTOROLA_MPC106 0x0002 > diff --git a/include/hw/usb/xhci.h b/include/hw/usb/xhci.h > index 5c90e1373e..203ec1fca3 100644 > --- a/include/hw/usb/xhci.h > +++ b/include/hw/usb/xhci.h > @@ -3,6 +3,7 @@ > > #define TYPE_XHCI "base-xhci" > #define TYPE_NEC_XHCI "nec-usb-xhci" > +#define TYPE_TI_XHCI "ti-usb-xhci" > #define TYPE_QEMU_XHCI "qemu-xhci" > #define TYPE_XHCI_SYSBUS "sysbus-xhci" > > diff --git a/hw/usb/hcd-xhci-ti.c b/hw/usb/hcd-xhci-ti.c > new file mode 100644 > index 0000000000..a3f7ef8ba2 > --- /dev/null > +++ b/hw/usb/hcd-xhci-ti.c > @@ -0,0 +1,94 @@ > +/* > + * USB xHCI controller emulation > + * Datasheet https://www.ti.com/product/TUSB7340 > + * > + * Copyright (c) 2011 Securiforest > + * Date: 2011-05-11 ; Author: Hector Martin <hector@marcansoft.com> > + * Based on usb-xhci-nec.c, emulates TI TUSB73X0 > + * > + * This library is free software; you can redistribute it and/or > + * modify it under the terms of the GNU Lesser General Public > + * License as published by the Free Software Foundation; either > + * version 2.1 of the License, or (at your option) any later version. > + * > + * This library 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 > + * Lesser General Public License for more details. > + * > + * You should have received a copy of the GNU Lesser General Public > + * License along with this library; if not, see <http://www.gnu.org/licenses/>. > + */ > + > +#include "qemu/osdep.h" > +#include "hw/usb.h" > +#include "qemu/module.h" > +#include "hw/pci/pci.h" > +#include "hw/qdev-properties.h" > + > +#include "hcd-xhci-pci.h" > + > +OBJECT_DECLARE_SIMPLE_TYPE(XHCITiState, TI_XHCI) > + > +struct XHCITiState { > + /*< private >*/ > + XHCIPciState parent_obj; > + /*< public >*/ > + uint32_t flags; > + uint32_t intrs; > + uint32_t slots; > +}; > + > +static Property ti_xhci_properties[] = { > + DEFINE_PROP_ON_OFF_AUTO("msi", XHCIPciState, msi, ON_OFF_AUTO_AUTO), > + DEFINE_PROP_ON_OFF_AUTO("msix", XHCIPciState, msix, ON_OFF_AUTO_AUTO), > + DEFINE_PROP_UINT32("intrs", XHCITiState, intrs, 8), > + DEFINE_PROP_UINT32("slots", XHCITiState, slots, XHCI_MAXSLOTS), > + DEFINE_PROP_END_OF_LIST(), > +}; > + > +static void ti_xhci_instance_init(Object *obj) > +{ > + XHCIPciState *pci = XHCI_PCI(obj); > + XHCITiState *ti = TI_XHCI(obj); > + > + pci->xhci.flags = ti->flags; ti->flags doesn't seem initialized / used. > + pci->xhci.numintrs = ti->intrs; > + pci->xhci.numslots = ti->slots; > + > + pci->cache_line_size = 0x0; > + pci->pm_cap_off = 0x40; > + pci->pcie_cap_off = 0x70; > + pci->msi_cap_off = 0x48; > + pci->msix_cap_off = 0xc0; > + pci->msix_bar_nr = 0x2; > + pci->msix_bar_size = 0x800000; > + pci->msix_table_off = 0x0; > + pci->msix_pba_off = 0x1000; > +} > + > +static void ti_xhci_class_init(ObjectClass *klass, void *data) > +{ > + PCIDeviceClass *k = PCI_DEVICE_CLASS(klass); > + DeviceClass *dc = DEVICE_CLASS(klass); > + > + device_class_set_props(dc, ti_xhci_properties); > + k->vendor_id = PCI_VENDOR_ID_TI; > + k->device_id = PCI_DEVICE_ID_TI_TUSB73X0; > + k->revision = 0x02; > +} > + > +static const TypeInfo ti_xhci_info = { > + .name = TYPE_TI_XHCI, > + .parent = TYPE_XHCI_PCI, > + .instance_size = sizeof(XHCITiState), > + .instance_init = ti_xhci_instance_init, > + .class_init = ti_xhci_class_init, > +}; > + > +static void ti_xhci_register_types(void) > +{ > + type_register_static(&ti_xhci_info); > +} > + > +type_init(ti_xhci_register_types) > diff --git a/hw/usb/Kconfig b/hw/usb/Kconfig > index 5fbecd2f43..8e5c4747af 100644 > --- a/hw/usb/Kconfig > +++ b/hw/usb/Kconfig > @@ -49,6 +49,11 @@ config USB_XHCI_NEC > default y if PCI_DEVICES > select USB_XHCI_PCI > > +config USB_XHCI_TI > + bool > + default y if PCI_DEVICES > + select USB_XHCI_PCI > + > config USB_XHCI_SYSBUS > bool > select USB_XHCI > diff --git a/hw/usb/meson.build b/hw/usb/meson.build > index 1b4d1507e4..b874a93f16 100644 > --- a/hw/usb/meson.build > +++ b/hw/usb/meson.build > @@ -23,6 +23,7 @@ system_ss.add(when: 'CONFIG_USB_XHCI', if_true: files('hcd-xhci.c')) > system_ss.add(when: 'CONFIG_USB_XHCI_PCI', if_true: files('hcd-xhci-pci.c')) > system_ss.add(when: 'CONFIG_USB_XHCI_SYSBUS', if_true: files('hcd-xhci-sysbus.c')) > system_ss.add(when: 'CONFIG_USB_XHCI_NEC', if_true: files('hcd-xhci-nec.c')) > +system_ss.add(when: 'CONFIG_USB_XHCI_TI', if_true: files('hcd-xhci-ti.c')) > system_ss.add(when: 'CONFIG_USB_DWC2', if_true: files('hcd-dwc2.c')) > system_ss.add(when: 'CONFIG_USB_DWC3', if_true: files('hcd-dwc3.c')) > ^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH 2/2] hw/usb: Add TI TUSB73X0 XHCI controller model 2024-11-10 15:39 ` Philippe Mathieu-Daudé @ 2024-11-27 2:07 ` Nicholas Piggin 0 siblings, 0 replies; 5+ messages in thread From: Nicholas Piggin @ 2024-11-27 2:07 UTC (permalink / raw) To: Philippe Mathieu-Daudé, qemu-devel Cc: Paolo Bonzini, Michael S. Tsirkin, Marcel Apfelbaum, Gerd Hoffmann On Mon Nov 11, 2024 at 1:39 AM AEST, Philippe Mathieu-Daudé wrote: > Hi Nick, > > On 10/11/24 05:00, Nicholas Piggin wrote: > > This controller is accepted by IBM Power firmware when the subsystem IDs > > are set to Power servers. Firmware is picky about device support so the > > NEC driver does not work. > > > > The TI HW has some interesting differences from NEC, notably a separate > > BAR for MSIX, and PM capabilities. The spec is freely available without > > sign-up. > > > > Signed-off-by: Nicholas Piggin <npiggin@gmail.com> > > --- > > include/hw/pci/pci_ids.h | 1 + > > include/hw/usb/xhci.h | 1 + > > hw/usb/hcd-xhci-ti.c | 94 ++++++++++++++++++++++++++++++++++++++++ > > hw/usb/Kconfig | 5 +++ > > hw/usb/meson.build | 1 + > > 5 files changed, 102 insertions(+) > > create mode 100644 hw/usb/hcd-xhci-ti.c > > > > diff --git a/include/hw/pci/pci_ids.h b/include/hw/pci/pci_ids.h > > index f1a53fea8d..fdb692db51 100644 > > --- a/include/hw/pci/pci_ids.h > > +++ b/include/hw/pci/pci_ids.h > > @@ -182,6 +182,7 @@ > > #define PCI_VENDOR_ID_HP 0x103c > > > > #define PCI_VENDOR_ID_TI 0x104c > > +#define PCI_DEVICE_ID_TI_TUSB73X0 0x8241 > > > > #define PCI_VENDOR_ID_MOTOROLA 0x1057 > > #define PCI_DEVICE_ID_MOTOROLA_MPC106 0x0002 > > diff --git a/include/hw/usb/xhci.h b/include/hw/usb/xhci.h > > index 5c90e1373e..203ec1fca3 100644 > > --- a/include/hw/usb/xhci.h > > +++ b/include/hw/usb/xhci.h > > @@ -3,6 +3,7 @@ > > > > #define TYPE_XHCI "base-xhci" > > #define TYPE_NEC_XHCI "nec-usb-xhci" > > +#define TYPE_TI_XHCI "ti-usb-xhci" > > #define TYPE_QEMU_XHCI "qemu-xhci" > > #define TYPE_XHCI_SYSBUS "sysbus-xhci" > > > > diff --git a/hw/usb/hcd-xhci-ti.c b/hw/usb/hcd-xhci-ti.c > > new file mode 100644 > > index 0000000000..a3f7ef8ba2 > > --- /dev/null > > +++ b/hw/usb/hcd-xhci-ti.c > > @@ -0,0 +1,94 @@ > > +/* > > + * USB xHCI controller emulation > > + * Datasheet https://www.ti.com/product/TUSB7340 > > + * > > + * Copyright (c) 2011 Securiforest > > + * Date: 2011-05-11 ; Author: Hector Martin <hector@marcansoft.com> > > + * Based on usb-xhci-nec.c, emulates TI TUSB73X0 > > + * > > + * This library is free software; you can redistribute it and/or > > + * modify it under the terms of the GNU Lesser General Public > > + * License as published by the Free Software Foundation; either > > + * version 2.1 of the License, or (at your option) any later version. > > + * > > + * This library 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 > > + * Lesser General Public License for more details. > > + * > > + * You should have received a copy of the GNU Lesser General Public > > + * License along with this library; if not, see <http://www.gnu.org/licenses/>. > > + */ > > + > > +#include "qemu/osdep.h" > > +#include "hw/usb.h" > > +#include "qemu/module.h" > > +#include "hw/pci/pci.h" > > +#include "hw/qdev-properties.h" > > + > > +#include "hcd-xhci-pci.h" > > + > > +OBJECT_DECLARE_SIMPLE_TYPE(XHCITiState, TI_XHCI) > > + > > +struct XHCITiState { > > + /*< private >*/ > > + XHCIPciState parent_obj; > > + /*< public >*/ > > + uint32_t flags; > > + uint32_t intrs; > > + uint32_t slots; > > +}; > > + > > +static Property ti_xhci_properties[] = { > > + DEFINE_PROP_ON_OFF_AUTO("msi", XHCIPciState, msi, ON_OFF_AUTO_AUTO), > > + DEFINE_PROP_ON_OFF_AUTO("msix", XHCIPciState, msix, ON_OFF_AUTO_AUTO), > > + DEFINE_PROP_UINT32("intrs", XHCITiState, intrs, 8), > > + DEFINE_PROP_UINT32("slots", XHCITiState, slots, XHCI_MAXSLOTS), > > + DEFINE_PROP_END_OF_LIST(), > > +}; > > + > > +static void ti_xhci_instance_init(Object *obj) > > +{ > > + XHCIPciState *pci = XHCI_PCI(obj); > > + XHCITiState *ti = TI_XHCI(obj); > > + > > + pci->xhci.flags = ti->flags; > > ti->flags doesn't seem initialized / used. Aha, because you removed the last flags from nec driver and I copied this from there :P Good catch. Shall we just remove the flags from XHCINecState? Thanks, Nick ^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2024-11-27 2:09 UTC | newest] Thread overview: 5+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2024-11-10 5:00 [PATCH 0/2] hw/usb: Add TI TUSB73X0 XHCI controller model Nicholas Piggin 2024-11-10 5:00 ` [PATCH 1/2] hw/usb: Make PCI device more configurable Nicholas Piggin 2024-11-10 5:00 ` [PATCH 2/2] hw/usb: Add TI TUSB73X0 XHCI controller model Nicholas Piggin 2024-11-10 15:39 ` Philippe Mathieu-Daudé 2024-11-27 2:07 ` Nicholas Piggin
This is an external index of several public inboxes, see mirroring instructions on how to clone and mirror all data and code used by this external index.