drivers/usb/at90usb/at90usb_core.c File Reference

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_udcat90usb_get_udc (struct at90usb_controller *at90usb)
 Get the AT90USB UDC struct if UDC mode is enabled.
static struct at90usb_hostat90usb_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_controllerat90usb_init (void)
 Initialize the AT90USB controller.
struct udcudc_init (void)
 Initialize the USB Device Controller.

Detailed Description

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.


Function Documentation

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.

Parameters:
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.

Parameters:
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.

Parameters:
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).

Parameters:
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.

Parameters:
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.

Parameters:
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.

Parameters:
at90usb The AT90USB controller.
Returns:
The AT90USB host instance.

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.

Parameters:
at90usb The AT90USB controller.
Returns:
The AT90USB UDC instance.

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:

  • Initialize the host and device parts of the driver.
  • Start monitoring the ID pin.
  • Switch the controller into host or device mode.
  • Start monitoring the Vbus pin.
Returns:
The AT90USB controller instance.
Todo:
Add support for host and OTG modes.

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.

Parameters:
at90usb The AT90USB controller.
Returns:
True if the controller supports OTG mode, false otherwise.

Definition at line 121 of file at90usb_core.c.

Referenced by at90usb_ep_interrupt(), at90usb_generic_interrupt(), and at90usb_init().

Generated on Thu Apr 29 14:10:34 2010 for xplain-bc by  doxygen 1.6.3