AT90USB driver: Core/Transceiver part. More...
#include <assert.h>#include <debug.h>#include <intc.h>#include <physmem.h>#include <stdbool.h>#include <interrupt.h>#include <clk/sys.h>#include <chip/clk.h>#include <chip/regs.h>#include <chip/at90usb.h>#include <chip/irq-map.h>#include <cpu/io.h>#include <usb/udc.h>#include <app/usb.h>#include "at90usb_internal.h"#include <slist.h>#include <bitops.h>#include <stdint.h>#include <workqueue.h>#include <usb/request.h>#include "at90usb_regs.h"Go to the source code of this file.
Functions | |
| static struct at90usb_udc * | at90usb_get_udc (struct at90usb_controller *at90usb) |
| Get the AT90USB UDC struct if UDC mode is enabled. | |
| static struct at90usb_host * | at90usb_get_host (struct at90usb_controller *at90usb) |
| Get the AT90USB host struct if USB host mode is enabled. | |
| static bool | at90usb_is_otg (struct at90usb_controller *at90usb) |
| Get the AT90USB OTG struct if USB OTG mode is enabled. | |
| static void | at90usb_check_vbus (struct at90usb_controller *at90usb) |
| Check VBUS and notify the UDC about the status. | |
| static void | at90usb_enter_device_mode (struct at90usb_controller *at90usb) |
| Enter USB device mode. | |
| static void | at90usb_enter_host_mode (struct at90usb_controller *at90usb) |
| Enter USB host mode. | |
| static void | at90usb_check_id (struct at90usb_controller *at90usb) |
| Check the state of the USB OTG ID pin. | |
| static void | at90usb_generic_interrupt (void *data) |
| AT90USB general interrupt handler. | |
| static void | at90usb_ep_interrupt (void *data) |
| AT90USB endpoint/pipe interrupt handler. | |
| static struct at90usb_controller * | at90usb_init (void) |
| Initialize the AT90USB controller. | |
| struct udc * | udc_init (void) |
| Initialize the USB Device Controller. | |
AT90USB driver: Core/Transceiver part.
This file implements a driver for the transceiver logic in the AT90USB USB hardware controller. It is responsible for enabling the host- and device parts of the driver depending on configuration options, transceiver states and USB On-The-Go events originating from HNP and SRP.
For internal use only.
If the driver is configured as host-only or device-only, the OTG logic will be disabled. This file is still responsible for detecting connection and disconnection events, and generating and detecting Vbus.
Copyright (C) 2009 Atmel Corporation. All rights reserved.
Definition in file at90usb_core.c.
| static void at90usb_check_id | ( | struct at90usb_controller * | at90usb | ) | [static] |
Check the state of the USB OTG ID pin.
For internal use only.
Check the state of the USB OTG ID pin and enable host/device functionality as appropriate.
| at90usb | The AT90USB controller. |
Definition at line 209 of file at90usb_core.c.
References at90usb_enter_device_mode(), at90usb_enter_host_mode(), and AT90USB_USBSTA_ID.
Referenced by at90usb_generic_interrupt(), and at90usb_init().
| static void at90usb_check_vbus | ( | struct at90usb_controller * | at90usb | ) | [static] |
Check VBUS and notify the UDC about the status.
For internal use only.
Check the status of the VBUS line and notify the UDC driver about the current status, either on or off.
| at90usb | The AT90USB controller. |
Definition at line 139 of file at90usb_core.c.
References at90usb_get_udc(), at90usb_udc_vbus_off(), at90usb_udc_vbus_on(), and AT90USB_USBSTA_VBUS.
Referenced by at90usb_enter_device_mode(), and at90usb_generic_interrupt().
| static void at90usb_enter_device_mode | ( | struct at90usb_controller * | at90usb | ) | [static] |
Enter USB device mode.
For internal use only.
Disable the host driver (if any), enable the UDC driver and start watching the state of the Vbus line.
| at90usb | The AT90USB controller. |
Definition at line 158 of file at90usb_core.c.
References at90usb_check_vbus(), at90usb_get_host(), at90usb_get_udc(), at90usb_host_is_enabled(), at90usb_udc_enable(), at90usb_udc_is_enabled(), AT90USB_USBCON_VBUSTE, AT90USB_USBINT_VBUSTI, and dbg_verbose.
Referenced by at90usb_check_id(), and at90usb_init().
| static void at90usb_enter_host_mode | ( | struct at90usb_controller * | at90usb | ) | [static] |
Enter USB host mode.
For internal use only.
Disable the UDC driver (if any), and then enable the host driver (if any).
| at90usb | The AT90USB controller. |
Definition at line 187 of file at90usb_core.c.
References at90usb_get_host(), at90usb_get_udc(), at90usb_host_is_enabled(), at90usb_udc_disable(), and at90usb_udc_is_enabled().
Referenced by at90usb_check_id(), and at90usb_init().
| static void at90usb_ep_interrupt | ( | void * | data | ) | [static] |
AT90USB endpoint/pipe interrupt handler.
For internal use only.
This is the endpoint/pipe interrupt handler for the AT90USB controller. It handles OTG and Vbus events, and calls the host- or device-specific interrupt handler, depending on the configuration and/or ID pin state.
| data | Data associated with this interrupt, the AT90USB controller. |
Definition at line 280 of file at90usb_core.c.
References at90usb_get_host(), at90usb_get_udc(), at90usb_host_is_enabled(), at90usb_is_otg(), at90usb_udc_is_enabled(), AT90USB_UEINT_EP, at90usb_udc::ep, main_workqueue, at90usb_udc_ep::task, at90usb_udc_ep::ueienx, and workqueue_add_task().
| static void at90usb_generic_interrupt | ( | void * | data | ) | [static] |
AT90USB general interrupt handler.
For internal use only.
This is the general interrupt handler for the AT90USB controller. It handles OTG and Vbus events, and calls the host- or device-specific interrupt handler, depending on the configuration and/or ID pin state.
| data | Data associated with this interrupt, the AT90USB controller. |
Definition at line 230 of file at90usb_core.c.
References at90usb_check_id(), at90usb_check_vbus(), at90usb_get_host(), at90usb_get_udc(), at90usb_host_is_enabled(), at90usb_is_otg(), at90usb_udc_is_enabled(), AT90USB_USBINT_IDTI, AT90USB_USBINT_VBUSTI, main_workqueue, at90usb_udc::task, and workqueue_add_task().
| static struct at90usb_host* at90usb_get_host | ( | struct at90usb_controller * | at90usb | ) | [static, read] |
Get the AT90USB host struct if USB host mode is enabled.
For internal use only.
| at90usb | The AT90USB controller. |
Definition at line 108 of file at90usb_core.c.
Referenced by at90usb_enter_device_mode(), at90usb_enter_host_mode(), at90usb_ep_interrupt(), at90usb_generic_interrupt(), and at90usb_init().
| static struct at90usb_udc* at90usb_get_udc | ( | struct at90usb_controller * | at90usb | ) | [static, read] |
Get the AT90USB UDC struct if UDC mode is enabled.
For internal use only.
| at90usb | The AT90USB controller. |
Definition at line 90 of file at90usb_core.c.
Referenced by at90usb_check_vbus(), at90usb_enter_device_mode(), at90usb_enter_host_mode(), at90usb_ep_interrupt(), at90usb_generic_interrupt(), at90usb_init(), and udc_init().
| static struct at90usb_controller* at90usb_init | ( | void | ) | [static, read] |
Initialize the AT90USB controller.
For internal use only.
This function will initialize and enable the AT90USB controller. Depending on the configuration, this may involve one or more of the following steps:
Definition at line 336 of file at90usb_core.c.
References at90usb_check_id(), at90usb_enter_device_mode(), at90usb_enter_host_mode(), at90usb_get_host(), at90usb_get_udc(), at90usb_is_otg(), at90usb_udc_init(), at90usb_udc_shutdown(), AT90USB_UHWCON_UIDE, AT90USB_UHWCON_UIMOD, AT90USB_UHWCON_UVREGE, AT90USB_USBCON_FRZCLK, AT90USB_USBCON_IDTE, AT90USB_USBCON_OTGPADE, AT90USB_USBCON_USBE, AT90USB_USBINT_IDTI, clk_enable_at90usb(), intc_setup_handler, sysclk_enable_module(), and SYSCLK_USB.
Referenced by udc_init().
| static bool at90usb_is_otg | ( | struct at90usb_controller * | at90usb | ) | [inline, static] |
Get the AT90USB OTG struct if USB OTG mode is enabled.
For internal use only.
| at90usb | The AT90USB controller. |
Definition at line 121 of file at90usb_core.c.
Referenced by at90usb_ep_interrupt(), at90usb_generic_interrupt(), and at90usb_init().
1.6.3