PERFORCE change 162082 for review
Hans Petter Selasky
hselasky at FreeBSD.org
Thu May 14 19:47:54 UTC 2009
http://perforce.freebsd.org/chv.cgi?CH=162082
Change 162082 by hselasky at hselasky_laptop001 on 2009/05/14 19:47:11
USB controller (AVR32 DCI)
- add basic structures, mostly copied from the atmegadci driver.
Affected files ...
.. //depot/projects/usb/src/sys/dev/usb/controller/avr32dci.h#2 edit
Differences ...
==== //depot/projects/usb/src/sys/dev/usb/controller/avr32dci.h#2 (text+ko) ====
@@ -1,3 +1,4 @@
+/* $FreeBSD: src/sys/dev/usb/controller/avr32dci.h $ */
/*-
* Copyright (c) 2009 Hans Petter Selasky. All rights reserved.
*
@@ -26,6 +27,8 @@
#ifndef _AVR32DCI_H_
#define _AVR32DCI_H_
+#define AVR32_MAX_DEVICES (USB_MIN_DEVICES + 1)
+
/* Register definitions */
#define AVR32_CTRL 0x00 /* Control */
@@ -60,4 +63,114 @@
#define AVR32_DMANXTDSC 0x310 /* DMA Next Descriptor Address */
#define AVR32_DMAADDRESS 0x314 /* DMA Channel Address */
+#define AVR32_READ_4(sc, reg) \
+ bus_space_read_4((sc)->sc_io_tag, (sc)->sc_io_hdl, reg)
+
+#define AVR32_WRITE_4(sc, reg, data) \
+ bus_space_write_4((sc)->sc_io_tag, (sc)->sc_io_hdl, reg, data)
+
+#define AVR32_WRITE_MULTI_4(sc, reg, ptr, len) \
+ bus_space_write_multi_4((sc)->sc_io_tag, (sc)->sc_io_hdl, reg, ptr, len)
+
+#define AVR32_READ_MULTI_4(sc, reg, ptr, len) \
+ bus_space_read_multi_4((sc)->sc_io_tag, (sc)->sc_io_hdl, reg, ptr, len)
+
+/*
+ * Maximum number of endpoints supported:
+ */
+#define AVR32_EP_MAX 7
+
+struct avr32dci_td;
+
+typedef uint8_t (avr32dci_cmd_t)(struct avr32dci_td *td);
+typedef void (avr32dci_clocks_t)(struct usb2_bus *);
+
+struct avr32dci_td {
+ struct avr32dci_td *obj_next;
+ avr32dci_cmd_t *func;
+ struct usb2_page_cache *pc;
+ uint32_t offset;
+ uint32_t remainder;
+ uint16_t max_packet_size;
+ uint8_t error:1;
+ uint8_t alt_next:1;
+ uint8_t short_pkt:1;
+ uint8_t support_multi_buffer:1;
+ uint8_t did_stall:1;
+ uint8_t ep_no:3;
+};
+
+struct avr32dci_std_temp {
+ avr32dci_cmd_t *func;
+ struct usb2_page_cache *pc;
+ struct avr32dci_td *td;
+ struct avr32dci_td *td_next;
+ uint32_t len;
+ uint32_t offset;
+ uint16_t max_frame_size;
+ uint8_t short_pkt;
+ /*
+ * short_pkt = 0: transfer should be short terminated
+ * short_pkt = 1: transfer should not be short terminated
+ */
+ uint8_t setup_alt_next;
+};
+
+struct avr32dci_config_desc {
+ struct usb2_config_descriptor confd;
+ struct usb2_interface_descriptor ifcd;
+ struct usb2_endpoint_descriptor endpd;
+} __packed;
+
+union avr32dci_hub_temp {
+ uWord wValue;
+ struct usb2_port_status ps;
+};
+
+struct avr32dci_flags {
+ uint8_t change_connect:1;
+ uint8_t change_suspend:1;
+ uint8_t status_suspend:1; /* set if suspended */
+ uint8_t status_vbus:1; /* set if present */
+ uint8_t status_bus_reset:1; /* set if reset complete */
+ uint8_t remote_wakeup:1;
+ uint8_t self_powered:1;
+ uint8_t clocks_off:1;
+ uint8_t port_powered:1;
+ uint8_t port_enabled:1;
+ uint8_t d_pulled_up:1;
+};
+
+struct avr32dci_softc {
+ struct usb2_bus sc_bus;
+ union avr32dci_hub_temp sc_hub_temp;
+
+ /* must be set by by the bus interface layer */
+ avr32dci_clocks_t *sc_clocks_on;
+ avr32dci_clocks_t *sc_clocks_off;
+
+ struct usb2_device *sc_devices[AVR32_MAX_DEVICES];
+ struct resource *sc_irq_res;
+ void *sc_intr_hdl;
+ struct resource *sc_io_res;
+ bus_space_tag_t sc_io_tag;
+ bus_space_handle_t sc_io_hdl;
+
+ uint8_t sc_rt_addr; /* root hub address */
+ uint8_t sc_dv_addr; /* device address */
+ uint8_t sc_conf; /* root hub config */
+
+ uint8_t sc_hub_idata[1];
+
+ struct avr32dci_flags sc_flags;
+};
+
+/* prototypes */
+
+usb2_error_t avr32dci_init(struct avr32dci_softc *sc);
+void avr32dci_uninit(struct avr32dci_softc *sc);
+void avr32dci_suspend(struct avr32dci_softc *sc);
+void avr32dci_resume(struct avr32dci_softc *sc);
+void avr32dci_interrupt(struct avr32dci_softc *sc);
+
#endif /* _AVR32DCI_H_ */
More information about the p4-projects
mailing list