From owner-p4-projects@FreeBSD.ORG Thu May 14 19:47:54 2009 Return-Path: Delivered-To: p4-projects@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 32767) id DB30D1065676; Thu, 14 May 2009 19:47:53 +0000 (UTC) Delivered-To: perforce@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 9ADF21065674 for ; Thu, 14 May 2009 19:47:53 +0000 (UTC) (envelope-from hselasky@FreeBSD.org) Received: from repoman.freebsd.org (repoman.freebsd.org [IPv6:2001:4f8:fff6::29]) by mx1.freebsd.org (Postfix) with ESMTP id 896618FC14 for ; Thu, 14 May 2009 19:47:53 +0000 (UTC) (envelope-from hselasky@FreeBSD.org) Received: from repoman.freebsd.org (localhost [127.0.0.1]) by repoman.freebsd.org (8.14.3/8.14.3) with ESMTP id n4EJlrQt065222 for ; Thu, 14 May 2009 19:47:53 GMT (envelope-from hselasky@FreeBSD.org) Received: (from perforce@localhost) by repoman.freebsd.org (8.14.3/8.14.3/Submit) id n4EJlrli065220 for perforce@freebsd.org; Thu, 14 May 2009 19:47:53 GMT (envelope-from hselasky@FreeBSD.org) Date: Thu, 14 May 2009 19:47:53 GMT Message-Id: <200905141947.n4EJlrli065220@repoman.freebsd.org> X-Authentication-Warning: repoman.freebsd.org: perforce set sender to hselasky@FreeBSD.org using -f From: Hans Petter Selasky To: Perforce Change Reviews Cc: Subject: PERFORCE change 162082 for review X-BeenThere: p4-projects@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: p4 projects tree changes List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 14 May 2009 19:47:54 -0000 http://perforce.freebsd.org/chv.cgi?CH=162082 Change 162082 by hselasky@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_ */