hcd-ohci.h 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124
  1. /*
  2. * QEMU USB OHCI Emulation
  3. * Copyright (c) 2004 Gianni Tedesco
  4. * Copyright (c) 2006 CodeSourcery
  5. * Copyright (c) 2006 Openedhand Ltd.
  6. *
  7. * This library is free software; you can redistribute it and/or
  8. * modify it under the terms of the GNU Lesser General Public
  9. * License as published by the Free Software Foundation; either
  10. * version 2.1 of the License, or (at your option) any later version.
  11. *
  12. * This library is distributed in the hope that it will be useful,
  13. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  15. * Lesser General Public License for more details.
  16. *
  17. * You should have received a copy of the GNU Lesser General Public
  18. * License along with this library; if not, see <http://www.gnu.org/licenses/>.
  19. */
  20. #ifndef HCD_OHCI_H
  21. #define HCD_OHCI_H
  22. #include "hw/sysbus.h"
  23. #include "sysemu/dma.h"
  24. #include "hw/usb.h"
  25. #include "qom/object.h"
  26. /* Number of Downstream Ports on the root hub: */
  27. #define OHCI_MAX_PORTS 15
  28. typedef struct OHCIPort {
  29. USBPort port;
  30. uint32_t ctrl;
  31. } OHCIPort;
  32. typedef struct OHCIState OHCIState;
  33. struct OHCIState {
  34. USBBus bus;
  35. qemu_irq irq;
  36. MemoryRegion mem;
  37. AddressSpace *as;
  38. uint32_t num_ports;
  39. const char *name;
  40. QEMUTimer *eof_timer;
  41. int64_t sof_time;
  42. /* OHCI state */
  43. /* Control partition */
  44. uint32_t ctl, status;
  45. uint32_t intr_status;
  46. uint32_t intr;
  47. /* memory pointer partition */
  48. uint32_t hcca;
  49. uint32_t ctrl_head, ctrl_cur;
  50. uint32_t bulk_head, bulk_cur;
  51. uint32_t per_cur;
  52. uint32_t done;
  53. int32_t done_count;
  54. /* Frame counter partition */
  55. uint16_t fsmps;
  56. uint8_t fit;
  57. uint16_t fi;
  58. uint8_t frt;
  59. uint16_t frame_number;
  60. uint16_t padding;
  61. uint32_t pstart;
  62. uint32_t lst;
  63. /* Root Hub partition */
  64. uint32_t rhdesc_a, rhdesc_b;
  65. uint32_t rhstatus;
  66. OHCIPort rhport[OHCI_MAX_PORTS];
  67. /* PXA27x Non-OHCI events */
  68. uint32_t hstatus;
  69. uint32_t hmask;
  70. uint32_t hreset;
  71. uint32_t htest;
  72. /* SM501 local memory offset */
  73. dma_addr_t localmem_base;
  74. /* Active packets. */
  75. uint32_t old_ctl;
  76. USBPacket usb_packet;
  77. uint8_t usb_buf[8192];
  78. uint32_t async_td;
  79. bool async_complete;
  80. void (*ohci_die)(OHCIState *ohci);
  81. };
  82. #define TYPE_SYSBUS_OHCI "sysbus-ohci"
  83. OBJECT_DECLARE_SIMPLE_TYPE(OHCISysBusState, SYSBUS_OHCI)
  84. struct OHCISysBusState {
  85. /*< private >*/
  86. SysBusDevice parent_obj;
  87. /*< public >*/
  88. OHCIState ohci;
  89. char *masterbus;
  90. uint32_t num_ports;
  91. uint32_t firstport;
  92. dma_addr_t dma_offset;
  93. };
  94. extern const VMStateDescription vmstate_ohci_state;
  95. void usb_ohci_init(OHCIState *ohci, DeviceState *dev, uint32_t num_ports,
  96. dma_addr_t localmem_base, char *masterbus,
  97. uint32_t firstport, AddressSpace *as,
  98. void (*ohci_die_fn)(OHCIState *), Error **errp);
  99. void ohci_bus_stop(OHCIState *ohci);
  100. void ohci_stop_endpoints(OHCIState *ohci);
  101. void ohci_hard_reset(OHCIState *ohci);
  102. void ohci_sysbus_die(struct OHCIState *ohci);
  103. #endif