how to handle usb suspend mode on sama5xww1.microchip.com/downloads/en/appnotes/00002457a.pdf ·...

40
AN2457 How to Handle USB Suspend Mode on SAMA5x Introduction This application note describes the USB Suspend mode operation in the SAMA5x series of microprocessors. The document demonstrates the USB Suspend feature, and its implementation and testing in Linux on a SAMA5D2/D3/D4 Xplained Ultra board. References The following items are available on http://www.microchip.com. Type Title Lit. No. Datasheet SAMA5D2 Device Datasheet DS60001476 Datasheet SAMA5D3 Device Datasheet 11121 Datasheet SAMA5D4 Device Datasheet 11238 User Guide SAMA5D2 Xplained Ultra User Guide 44028 User Guide SAMA5D2 Rev. B Xplained Ultra User Guide 44083 User Guide SAMA5D3 Xplained User Guide 11269 User Guide SAMA5D4 Xplained Ultra User Guide 44005 Application Note SAMA5D2 Low-Power Modes Implementation 44042 Application Note Low-power Modes on the SAMA5D3 Series 11185 Software Package SAMA5D2 Software Package Refer also to Linux Kernel from GitHub on: https://github.com/linux4sam/linux-at91 © 2017 Microchip Technology Inc. Application Note DS00002457A-page 1

Upload: dinhminh

Post on 14-Mar-2019

241 views

Category:

Documents


0 download

TRANSCRIPT

AN2457 How to Handle USB Suspend Mode on SAMA5x

Introduction

This application note describes the USB Suspend mode operation in the SAMA5x series ofmicroprocessors. The document demonstrates the USB Suspend feature, and its implementation andtesting in Linux on a SAMA5D2/D3/D4 Xplained Ultra board.

References

The following items are available on http://www.microchip.com.

Type Title Lit. No.

Datasheet SAMA5D2 Device Datasheet DS60001476

Datasheet SAMA5D3 Device Datasheet 11121

Datasheet SAMA5D4 Device Datasheet 11238

User Guide SAMA5D2 Xplained Ultra User Guide 44028

User Guide SAMA5D2 Rev. B Xplained Ultra User Guide 44083

User Guide SAMA5D3 Xplained User Guide 11269

User Guide SAMA5D4 Xplained Ultra User Guide 44005

Application Note SAMA5D2 Low-Power Modes Implementation 44042

Application Note Low-power Modes on the SAMA5D3 Series 11185

Software Package SAMA5D2 Software Package

Refer also to Linux Kernel from GitHub on:

https://github.com/linux4sam/linux-at91

2017 Microchip Technology Inc. Application Note DS00002457A-page 1

http://www.microchip.comhttps://github.com/linux4sam/linux-at91

Table of Contents

Introduction......................................................................................................................1

References...................................................................................................................... 1

1. USB Suspend Mode ................................................................................................. 4

2. USB Ports in SAMA5Dx Devices...............................................................................62.1. USB Host and Device Ports in SAMA5D2....................................................................................62.2. USB Host and Device Ports in SAMA5D3 and SAMA5D4...........................................................7

3. USB High-Speed Device Port (UDPHS)....................................................................93.1. Description................................................................................................................................... 93.2. Embedded Characteristics........................................................................................................... 93.3. UTMI Transceivers Sharing........................................................................................................103.4. Working with Host Port A as Device Port................................................................................... 10

4. Entering Suspend Mode from USB Device Port......................................................124.1. USB Device Suspend.................................................................................................................12

5. Exiting Suspend Mode from USB Device Port........................................................ 145.1. Receiving a Host Resume..........................................................................................................145.2. Sending an External Resume.....................................................................................................14

6. USB Host High-Speed Port (UHPHS)..................................................................... 166.1. Embedded Characteristics......................................................................................................... 166.2. SAMA5D2 USB Host Ports........................................................................................................ 166.3. SAMA5D3 USB Host Ports........................................................................................................ 166.4. SAMA5D4 USB Host Ports........................................................................................................ 166.5. USB Port Sharing.......................................................................................................................166.6. Block Diagram............................................................................................................................17

7. Types of USB Suspend........................................................................................... 20

8. USB Global Suspend...............................................................................................218.1. USB Global Suspend in SAMA5Dx Devices.............................................................................. 21

9. Suspending USB Host Ports in SAMA5Dx Devices................................................ 229.1. USB Suspend Mode Implementation in Linux Kernel................................................................ 22

10. USB Selective Suspend Example........................................................................... 2410.1. Hardware Setup for USB Selective Suspend.............................................................................2410.2. USB Selective Suspend Mode on Host Ports ........................................................................... 25

11. USB Global Suspend Example................................................................................33

12. Power Consumption during USB Suspend..............................................................34

AN2457

2017 Microchip Technology Inc. Application Note DS00002457A-page 2

13. USB Host Limitations and Corrections.................................................................... 35

14. Revision History.......................................................................................................36

The Microchip Web Site................................................................................................ 37

Customer Change Notification Service..........................................................................37

Customer Support......................................................................................................... 37

Microchip Devices Code Protection Feature................................................................. 37

Legal Notice...................................................................................................................38

Trademarks................................................................................................................... 38

Quality Management System Certified by DNV.............................................................39

Worldwide Sales and Service........................................................................................40

AN2457

2017 Microchip Technology Inc. Application Note DS00002457A-page 3

1. USB Suspend ModeAccording to the USB specification, in absence of bus traffic over USB in powered state for more than 3milliseconds, all devices that are supplied power through the Universal Serial Bus (USB) must enterSuspend mode.

Suspend mode reduces the use of bus power by a device when the host has no reason to communicatewith it. This enables the device to enter low-power mode in order to reduce power consumption. Bus-powered devices draw current from the USB. These devices must reduce their power consumption tomeet USB specifications when they are inactive. For power consumption values, refer to Section 4 of theUSB Specifications datasheet (version 1.1), available on http://www.usb.org.

A device in Suspend mode can resume operation when any active signal is received on its upstream port.It can resume operation from the application using an external interrupt. Selective port suspend reducespower, with most suspended devices drawing less than 500 A, including current from pullup resistors onthe bus. All devices below a suspended port are suspended.

USB High Speed Device Port (UDPHS) and USB High Speed Host Port (UHPHS) in the SAMA5x seriesare compliant with the Universal Serial Bus (USB), revision 2.0 High Speed Device Specification and aredesigned to support Suspend mode when the USB bus is inactive. USB has a start of frame or keep alivepacket sent periodically on the bus. This prevents an idle bus from entering Suspend mode in theabsence of data.

A high-speed bus has microframes sent every 125.0 s 62.5 ns A full-speed bus has a frame sent every 1.000 ms 500 ns

AN2457

2017 Microchip Technology Inc. Application Note DS00002457A-page 4

http://www.usb.org

Figure 1-1.USB Device States

Movement from one state to another depends on the USB bus state or on standard requests sent throughcontrol transactions via the default endpoint (endpoint 0). The USB bus only has two states - active andsuspended - based on traffic over the bus.

AN2457

2017 Microchip Technology Inc. Application Note DS00002457A-page 5

2. USB Ports in SAMA5Dx DevicesThis section classifies the available Universal Serial Bus ports and required power supply on SAMA5Dxproducts.

2.1 USB Host and Device Ports in SAMA5D2SAMA5D2 devices feature three host ports (A, B, C). Host port A and Host port B support high-speed andfull-speed devices as per USB 1.1 and USB 2.0 specifications. Host port A and the device port (UDPHS)share the same transceiver. Host port C is designed for HSIC (High-Speed Inter-Circuit) and supportsonly high-speed devices. A detailed description is given in USB Inter-chip Transceiver (SAMA5D2 only).Figure 2-1.USB Selection

Table 2-1.SAMA5D2 USB Ports

Device SAMA5D21/22/23 SAMA5D24 SAMA5D26 SAMA5D27 SAMA5D28

Package TFBGA196 TFBGA256 LFBGA289

USB 2 (2 hosts or 1 host/1 device) 3 (2 hosts/1HSIC, or 1

host/1 device/1 HSIC)

2 (2 hosts or 1host / 1device)

3 (2 hosts/1 HSIC, or 1host/ 1 device/ 1 HSIC)

AN2457

2017 Microchip Technology Inc. Application Note DS00002457A-page 6

Table 2-2.SAMA5D2 Power Supplies

Name Nominal VoltageRange

AssociatedGround

Powers

VDDUTMII 3.00V-3.60V, 3.30V GNDUTMII USB device and host UTMI+interface

VDDUTMIC 1.10V-1.32V, 1.20V GNDUTMII USB device and host UTMI+core

VDDHSIC 1.10V-1.32V, 1.20V GNDUTMII USB High-Speed Inter-Chip

2.2 USB Host and Device Ports in SAMA5D3 and SAMA5D4SAMA5D3 and SAMA5D4 devices feature three host ports (A, B, C). Host ports A, B and C support high-speed and full-speed devices. Host port A is also shared with the device port (UDPHS) with a separatetransceiver.

Table 2-3.SAMA5D3 USB Ports

Device SAMA5D3x

Package TFBGA/LFBGA

USB 3 (2 hosts/ 1 device or 3 hosts)

Table 2-4.SAMA5D3 Power Supplies

Name Nominal VoltageRange

AssociatedGround

Powers

VDDOSC 1.65-3.6V GNDOSC Main oscillator cell and PLLUTMI. If PLL UTMI or USB isused, the range is to be 3.0-3.6V

VDDUTMIC 1.1-1.32V, 1.2V GNDUTMI USB device and host UTMI+core

VDDUTMII 3.0-3.6V, 3.3V GNDUTMI USB device and host UTMI+interface

Figure 2-2.USB SelectionOther

Transceivers

DMA

HS USB HostHS EHCI FS OHCI

Other Ports PA

10EN_UDPHS

HSUSB

Device

HS Transceiver

DMA

AN2457

2017 Microchip Technology Inc. Application Note DS00002457A-page 7

Table 2-5.SAMA5D4 USB Ports

Device SAMA5D4x

Package TFBGA/LFBGA

USB 3 (2 hosts/ 1 device or 3 hosts)

Table 2-6.SAMA5D4 Power Supplies

Name Nominal Voltage Range Associated Ground Powers

VDDUTMIC 1.1-1.32V, 1.2V GNDUTMI USB device and host UTMI +coreand the UTMI PLL MUST beconnected to VCCCORE.

VDDUTMII 3.0-3.6V, 3.3V GNDUTMI USB device and host UTMI+interface

AN2457

2017 Microchip Technology Inc. Application Note DS00002457A-page 8

3. USB High-Speed Device Port (UDPHS)

3.1 DescriptionThe USB High Speed Device Port (UDPHS) is compliant with the Universal Serial Bus, High-SpeedDevice Specification rev 2.0. Each endpoint can be configured in one of several USB transfer types. Itcan be associated with one, two or three banks of a dual-port RAM used to store the current datapayload. If two or three banks are used, one DPR bank is read or written by the processor, while the otheris read or written by the USB device peripheral. This feature is mandatory for isochronous endpoints.

3.2 Embedded Characteristics High-speed Device UTMI Transceiver shared between Host and Device USB v2.0 High-speed Compliant, 480 Mbit/s 16 Endpoints up to 1024 Bytes Embedded 8Kbytes of Dual-port RAM for Endpoints Suspend/Resume Logic (UTMI Command) Up to Three Memory Banks for Endpoints (Not for Control Endpoint)

Figure 3-1.SAMA5Dx USB Block Diagram

For further description of DPRAM management, endpoint configurations and handling transfer typetransactions with USB V2.0 device peripheral, refer to the respective SAMA5Dx series datasheet.

AN2457

2017 Microchip Technology Inc. Application Note DS00002457A-page 9

3.3 UTMI Transceivers SharingThe high-speed USB host port A is shared with the high-speed USB device port and is connected to oneof the UTMI transceivers.

Figure 3-2.UTMI Transceivers Sharing

The HSIC transceiver is specific to SAMA5D2. It is a high-speed host port compliant with USB 2.0 andconnected to SAMA5D2x port C.

3.4 Working with Host Port A as Device PortThe selection between host and device for port A is controlled by the UDPHS enable bit (EN_UDPHS)located in the UDPHS_CTRL register. If port A is driven by the USB high-speed device, the output signalsare DFSDP, DFSDM, DHSDP and DHSDM. The transceiver is automatically selected for device operationonce the USB high-speed device is enabled.

Name: UDPHS_CTRL

Address: 0xFC02C000

Access : Read/Write

31 30 29 28 27 26 25 24

- - - - - - - -

23 22 21 20 19 18 17 16

- - - - - - - -

15 14 13 12 11 10 9 8

- - - - PULLD_DIS REWAKEUP DETACH EN_UDPHS

7 6 5 4 3 2 1 0

FADDR_EN DEV_ADDR

AN2457

2017 Microchip Technology Inc. Application Note DS00002457A-page 10

EN_UDPHS: UDPHS Enable

0: UDPHS is disabled (read), or this bit disables and resets the UDPHS controller (write). Switch the hostto UTMI.

1: UDPHS is enabled (read), or this bit enables the UDPHS controller (write). Switch the host to UTMI.

AN2457

2017 Microchip Technology Inc. Application Note DS00002457A-page 11

4. Entering Suspend Mode from USB Device PortThere are two different sources from which the system or port enters Suspend state:

Selective Suspend

Global Suspend

SAMA5Dx devices support both modes of suspend. This is discussed in detail in later sections.

4.1 USB Device SuspendIn SAMA5Dx devices, when there is no bus activity on the USB bus for more than 3 milliseconds, theDET_SUSPD signal bit in the UDPHS_INTSTA register is set. This triggers an interrupt if thecorresponding bit is set in the UDPHS_IEN register and the device enters Suspend mode. In this state,bus-powered devices must drain less than 500 A on average from the 5V VBUS and must preserve theirstate so that they can resume from the state where they were suspended. At this time, UDPHS deviceperipheral clocks can be switched off.

Below is the description of UDPHS Interrupt Status and UDPHS Interrupt Enable registers for all SAMA5xseries devices.

Table 4-1.UDPHS Interrupt Status Register

Name: UDPHS_INTSTA

Address: 0xFC02C014

Access : Read-only

31 30 29 28 27 26 25 24

DMA_7 DMA_6 DMA_5 DMA_4 DMA_3 DMA_2 DMA_1 -

23 22 21 20 19 18 17 16

EPT_15 EPT_14 EPT_13 EPT_12 EPT_11 EPT_10 EPT_9 EPT_8

15 14 13 12 11 10 9 8

EPT_7 EPT_6 EPT_5 EPT_4 EPT_3 EPT_2 EPT_1 EPT_0

7 6 5 4 3 2 1 0

UPSTR_RES ENDOFRSM WAKE_UP ENDRESET INT_SOF MICRO_SOF DET_SUSPD SPEED

Table 4-2.UDPHS Interrupt Enable Register

Name: UDPHS_IEN

Address: 0xFC02C010

Access : Read/Write

31 30 29 28 27 26 25 24

DMA_7 DMA_6 DMA_5 DMA_4 DMA_3 DMA_2 DMA_1 -

23 22 21 20 19 18 17 16

AN2457

2017 Microchip Technology Inc. Application Note DS00002457A-page 12

Name: UDPHS_IEN

Address: 0xFC02C010

Access : Read/Write

EPT_15 EPT_14 EPT_13 EPT_12 EPT_11 EPT_10 EPT_9 EPT_8

15 14 13 12 11 10 9 8

EPT_7 EPT_6 EPT_5 EPT_4 EPT_3 EPT_2 EPT_1 EPT_0

7 6 5 4 3 2 1 0

UPSTR_RES ENDOFRSM WAKE_UP ENDRESET INT_SOF MICRO_SOF DET_SUSPD -

AN2457

2017 Microchip Technology Inc. Application Note DS00002457A-page 13

5. Exiting Suspend Mode from USB Device PortDevices can leave suspended state when the host wakes them up. In Suspend mode, USB can resumefrom two sources:

Host Resume

External Resume

5.1 Receiving a Host ResumeIn Suspend mode, a resume event on the USB bus line is detected asynchronously, with transceiver andclocks disabled (however, the pullup should not be removed). Once a resume is detected on the bus, theUDPHS_INTSTA.WAKE_UP signal bit is set. It may generate an interrupt if the corresponding bit in theUDPHS_IEN register is set. This interrupt may be used to wake up the core, enable main oscillators andPLL and configure clocks.

5.2 Sending an External ResumeAny USB device can be woken up by active actions associated with internal functions and then causesignaling on its upstream connections to wake up or alert the rest of the system.

In Suspend state, it is possible to wake up the host by sending an external resume. After enteringSuspend state, the device waits for at least 5 milliseconds before sending an external resume. Thisenables the device to draw the required power to change its state from Suspended to Resume. Thedevice must force a K state from 1 to 15 milliseconds to resume the host.

Table 5-1.UDPHS Interrupt Status Register

Name: UDPHS_INTSTA

Address: 0xFC02C014

Access : Read-only

31 30 29 28 27 26 25 24

DMA_7 DMA_6 DMA_5 DMA_4 DMA_3 DMA_2 DMA_1 -

23 22 21 20 19 18 17 16

EPT_15 EPT_14 EPT_13 EPT_12 EPT_11 EPT_10 EPT_9 EPT_8

15 14 13 12 11 10 9 8

EPT_7 EPT_6 EPT_5 EPT_4 EPT_3 EPT_2 EPT_1 EPT_0

7 6 5 4 3 2 1 0

UPSTR_RES ENDOFRSM WAKE_UP ENDRESET INT_SOF MICRO_SOF DET_SUSPD SPEED

AN2457

2017 Microchip Technology Inc. Application Note DS00002457A-page 14

Table 5-2.UDPHS Interrupt Enable Register

Name: UDPHS_IEN

Address: 0xFC02C010

Access : Read/Write

31 30 29 28 27 26 25 24

DMA_7 DMA_6 DMA_5 DMA_4 DMA_3 DMA_2 DMA_1 -

23 22 21 20 19 18 17 16

EPT_15 EPT_14 EPT_13 EPT_12 EPT_11 EPT_10 EPT_9 EPT_8

15 14 13 12 11 10 9 8

EPT_7 EPT_6 EPT_5 EPT_4 EPT_3 EPT_2 EPT_1 EPT_0

7 6 5 4 3 2 1 0

UPSTR_RES ENDOFRSM WAKE_UP ENDRESET INT_SOF MICRO_SOF DET_SUSPD -

AN2457

2017 Microchip Technology Inc. Application Note DS00002457A-page 15

6. USB Host High-Speed Port (UHPHS)The USB Host High-Speed Port (UHPHS) interfaces the USB with the host application. It handles OpenHCI protocol (Open Host Controller Interface) as well as Enhanced HCI protocol (Enhanced HostController Interface).

6.1 Embedded Characteristics Compliant with Enhanced HCI Rev 1.0 Specification Compliant with USB V2.0 High-speed Specification Supports High-speed 480 Mbps Compliant with Open HCI Rev 1.0 Specification Compliant with USB V2.0 Full-speed and Low-speed Specification Supports both Low-speed 1.5 Mbps and Full-speed 12 Mbps USB devices Root Hub Integrated with 3 Downstream USB HS Ports Embedded USB Transceivers Supports Power Management

6.2 SAMA5D2 USB Host Ports 2 Hosts (A and B) support both High Speed (EHCI) and Full Speed (OHCI) Port A shared with USB Device (UDPHS)

6.3 SAMA5D3 USB Host Ports 3 Hosts (A,B,C) support both High Speed (EHCI) and Full Speed (OHCI). Port A shared with USB Device (UDPHS)

6.4 SAMA5D4 USB Host Ports 3 Hosts (A, B, and C) support both High Speed (EHCI) and Full Speed (OHCI) Port A shared with USB Device (UDPHS)

6.5 USB Port SharingHFSDPs, HFSDMs, HHSDPs and HHSDMs are not controlled by any PIO controllers. The embeddedUSB high-speed physical transceivers are controlled by the USB host controller. One transceiver isshared with the USB high-speed device (port A). For more details, refer to Working with Host Port A asDevice Port.

AN2457

2017 Microchip Technology Inc. Application Note DS00002457A-page 16

6.6 Block DiagramFigure 6-1.SAMA5D2 USB Architecture

AN2457

2017 Microchip Technology Inc. Application Note DS00002457A-page 17

Figure 6-2.SAMA5D3 and SAMA5D4 USB Architecture

6.6.1 Block Diagram DescriptionAccess to the USB host operational registers is achieved through the AHB bus slave interface. The OpenHCI host controller and Enhanced HCI host controller initialize master DMA transfers through the AHBbus master interface as follows:

Fetches the control and transfer type information from endpoint descriptor and transfer typedescriptors

Accesses endpoint data from system memory Notifies information to root hub Depending on the speed information, the companion controllers are notified If the device is a high-speed device, the EHCI companion gets notified, else OHCI Accesses the HC communication area Writes status and retires transfer descriptor

USB physical transceivers are integrated in the product and driven by the root hubs ports. The USB roothub is integrated in the USB host. Several USB downstream ports are available. The number ofdownstream ports can be determined by the software driver reading the root hubs operational registers.Device connection is automatically detected by the USB host port logic. The SAMA5Dx family supportsthree USB ports, which must be enabled and stabilized using the required clocks. The SAMA5D2 USBports handle OHCI- and EHCI-compatible devices and require clocks MCK, UHP48M and UHP12Mrespectively.

AN2457

2017 Microchip Technology Inc. Application Note DS00002457A-page 18

6.6.2 USB Inter-chip Transceiver (SAMA5D2 only)This section describes the HSIC feature available in SAMA5D2.

The High-Speed Inter-Chip (HSIC) is a standard for USB chip-to-chip interconnect with a 2-signal (strobe,data) source synchronous serial interface using 240 MHz DDR signaling to provide only high-speed 480Mbps data rate. External cables, connectors and hot plug & play are not supported. The HSIC interfaceoperates at high speed, 480 Mbps, and is fully compatible with existing USB software stacks. It meets alldata transfer needs through a single unified USB software stack. No transceiver UTMI clock is required.

AN2457

2017 Microchip Technology Inc. Application Note DS00002457A-page 19

7. Types of USB SuspendThis section summarizes the types of Suspend modes supported by the SAMA5Dx family.

The SAMA5Dx product family supports two types of Suspend mode:

Global Suspend Selective Suspend

These modes are discussed in detail in the following sections.

AN2457

2017 Microchip Technology Inc. Application Note DS00002457A-page 20

8. USB Global SuspendUSB Global Suspend enables an entire USB network of devices to enter Suspend state. This providesminimum power consumption over USB.

When a system detects no activity for a period of time, the system enters a low-power state and stopssending Start-of-Frame packets on the bus. When a full- or high-speed device detects that no Start-of-Frame packet has arrived for 3 milliseconds, it enters Suspend state. Low-speed devices do the samewhen they have not received a low-speed keep-alive signal for 3 milliseconds.

When devices enter Suspend state, they must preserve their state and consume no more than 500microamperes of current.

8.1 USB Global Suspend in SAMA5Dx DevicesGlobal Suspend is initiated when all the downstream traffic from the root hub is terminated. This is doneunder software control by issuing a Global Suspend request to the root hub's control endpoint. A deviceentering a low-power mode is considered as Global Suspend. Once a device enters Global Suspend, theUSB bus is notified about the suspend event and the devices (end device or hub) connected to all theports are suspended. The devices' states are saved and the clocks (HSCK, FSCK, MCK, UTMII) aredisabled. By default, the USB port supports Global Suspend. In this mode, the USB ports drain no morethan 500 microamperes of current. Examples of how to test Global Suspend on SAMA5Dx devices areprovided in later sections.

Note: For more information regarding low-power modes, refer to Application Notes SAMA5D2 Low-Power Modes Implementation and Low-power Modes on the SAMA5D3 Series on www.microchip.com.

AN2457

2017 Microchip Technology Inc. Application Note DS00002457A-page 21

http://www.atmel.com

9. Suspending USB Host Ports in SAMA5Dx DevicesThis section explains the generic implementation of USB Suspend to handle Global and SelectiveSuspends in a Linux Kernel subsystem.

9.1 USB Suspend Mode Implementation in Linux KernelThis section explains how a USB device connected to a port gets enumerated, and how a USBsubsystem in the Linux kernel supports runtime power management in the form of the USB Auto Suspendfeature.

This demonstration is based on the example of a USB optical mouse.

When a USB mouse is connected to a host port, the USB bus gets notified and the mouse gets registeredwith the USB bus driver. Depending on its speed specification, the mouse gets registered with the USBhost controller driver's EHCI-compliant controller (in our case atmel-ehci). If it is a low-speed device or afull-speed device, it gets bypassed to other available companion controllers (in our case at91-ohci). Whenfull-speed transactions are performed, these transactions are prevented from reaching the low-speeddevices that otherwise might be confused by a full-speed device transaction. The USB host acquires theinformation regarding the connected USB device over the hub from its endpoint 0. According to thedevice configuration read by the USB host from endpoint 0 (Control), it identifies its type and categorizesit (in this case as an Interrupt type). The USB mouse gets registered with the input device subsystem.

A Linux driver for a USB device informs the USB subsystem that it supports USB auto suspend. It doesso by setting a flag in its usb_driver structure.

For example, the USB storage driver includes this initialization:

static struct usb_driver usb_storage_driver = {

/* ... */

.supports_autosuspend = 1,

/* supports_autosuspend: if set to 0, the USB

Core will not allow auto suspend for devices bound to this driver.*/

};

The API for implementing USB auto-suspend is based on drivers informing the core USB subsystemwhenever a reason for not suspending a device arises or ceases to exist. The subsystem counts thereasons why a device must not be auto-suspended. The core USB subsystem may then suspend adevice whose counter has reached zero. In Linux, the USB device may consist of a multitude ofinterfaces, and each one may have its own driver that manages the counter values depending on the busactivity. The counters are manipulated with "get" and "put" functions that wake or suspend devicesaccording to the state of the counters.

The function below increments the counter and guarantees that the device has been resumed.

usb_autopm_get_interface(struct usb_interface *);

AN2457

2017 Microchip Technology Inc. Application Note DS00002457A-page 22

The function below decrements the counter. (This call may sleep.)

usb_autopm_put_interface(struct usb_interface *);

If the counter is zero, the device is suspended; else it is active.

void usb_enable_autosuspend(struct usb_device *udev)

{

pm_runtime_allow(&udev->dev);

}

For full source code implementation, refer to https://github.com/linux4sam/linux-at91

AN2457

2017 Microchip Technology Inc. Application Note DS00002457A-page 23

https://github.com/linux4sam/linux-at91

10. USB Selective Suspend ExampleThis section demonstrates the USB Selective Suspend mode in SAMA5Dx USB host ports, based on theexample of a USB optical mouse.

10.1 Hardware Setup for USB Selective SuspendThis section describes the hardware setup required to test the USB Selective Suspend feature on aSAMA5D2 Xplained Ultra board.

Figure 10-1.SAMA5D2 Xplained Ultra Board

Connect the Micro USB cable to the EDBG-USB connector (J14). Connect the FTDI cable to the DEBUG connector (J1). Set the baud rate. When a USB optical mouse is connected to A5-USB-B (J13) on the SAMA5D27-XULTRA board as

shown in Figure 10-1, the USB subsystem recognizes the optical mouse and enumerates it byreading the Control, Configuration and Interface information from its Endpoint 0. The mouse getsdetected by the respective layers depending on its control and configuration details.

AN2457

2017 Microchip Technology Inc. Application Note DS00002457A-page 24

Figure 10-2.Hardware Setup

Figure 10-3.FTDI Cable Connection

10.2 USB Selective Suspend Mode on Host PortsThis section describes the Selective Suspend on SAMA5Dx host ports, tested on the following portsindividually:

SAMA5D2: Host Port B

SAMA5D3: Host Port B and Host Port C (see Note)

SAMA5D4: Host Port B and Host Port C

Note: SAMA5D3 Host Port C is OHCI-compliant and does not support EHCI-compliant devices. Formore details, refer to the device datasheet.

AN2457

2017 Microchip Technology Inc. Application Note DS00002457A-page 25

10.2.1 Useful Attributes in Linux USB Subsystem In a Linux kernel, the Sysfs interface can be used to communicate with a device to read some bytes

of data from the hardware and write to it. The hardware can then respond by using deviceattributes.

For a USB subsystem, some attributes help to suspend the USB device that is connected on aspecific port on the USB bus.

When a USB device is connected on the bus and is enumerated, it creates an entry in the Sysfshierarchy of the kernel subsystem. This entry has attributes which enable the user to control theUSB device, read the vendor ID, product ID, configuration, maximum packet size, power andcontrol information of the USB device connected on the USB port.

The following three required Sysfs attributes can be used to suspend the USB device:

root#/sys/bus/usb/$DEVICE/power/control

The above attribute can have any one of the following settings:

on for inactive auto suspend. This means that the device must not be auto-suspended by default. auto for active auto suspend. This means that the device can be suspended when traffic over the

bus is inactive.

root#/sys/bus/usb/$DEVICE/power/autosuspend

The above attribute can have any integer value. This value determines the delay (in seconds) before theUSB device is suspended.

Integer values only are valid. This value specifies that the USB device must remain active for the time specified in seconds if

there is no activity on the USB bus. Once this time has elapsed, the USB device is suspended.

root#/sys/bus/usb/$DEVICE/power/autosuspend_delay_ms

The above attribute can have any integer value. This value determines the delay (in milliseconds) beforethe USB device is suspended.

Integer values only are valid. This value specifies that the USB device must remain active for the time specified in milliseconds if

there is no activity on the USB bus. Once this time has elapsed, the USB device is suspended.

10.2.2 Demo Using a USB Optical Mouse Connected to Host Port B or C (D3/D4)The steps below are applicable for all SAMA5Dx products.

For testing purposes, SAMA5D2_XULTRA is used throughout this demo.

Before starting this demo, make sure that the latest software version is loaded and that the deviceis booting Linux.

For more information, refer to:

http://www.at91.com/linux4sam/bin/view/Linux4SAM/Sama5d2XplainedMainPage#Demo

When the Logitech USB optical mouse is connected to the SAMA5D2 Xplained Ultra board, youcan observe debug messages from the kernel that explain that the USB device is detected on theUSB bus and enumerated as an input device:

AN2457

2017 Microchip Technology Inc. Application Note DS00002457A-page 26

http://www.at91.com/linux4sam/bin/view/Linux4SAM/Sama5d2XplainedMainPage#Demo

The image below shows the power attributes as Sysfs entries that relate to a USB device:

Default value of the control attribute in Sysfs:

Default value of the autosuspend and autosuspend_delay_ms attributes in Sysfs:

When the value of the control attribute is set to on, the USB device will never be suspended. To make sure the USB device enters Suspend state, change the value of control attribute to

auto. The user can change the default values of autosuspend and autosuspend_delay_ms, which

specify the time for the USB device to enter Suspend state as explained in the above sections. Follow the steps below to suspend the connected USB device.

AN2457

2017 Microchip Technology Inc. Application Note DS00002457A-page 27

After the control attribute value is set to auto, the driver checks internally this attribute's status. Itallows the device to be active for the time specified in the autosuspend attribute and immediatelysuspends the device if there is no activity over the port for the time specified (in seconds) byautosuspend.

As the device used in the demo (an optical mouse) is a remote wakeup enabled device, the port willresume to the state where it was before being suspended when the device asserts wakeup signalon the bus. Then, clicking the mouse button or moving the mouse resumes both the port and thedevice.

10.2.3 Signal Behavior on Pins USBB_DP and USBB_DMThis section describes the hardware connection of the SAMA5D2 USB host port B.

Figure 10-4.SAMA5D2 Host Port B

USB-B is connected to SAMA5D2 as shown in the above figure. USBB_VBUS_5V is the line from whichthe USB device gets powered from the USB bus. USBB_DP and USBB_DM are data lines through whichthe device communicates.

AN2457

2017 Microchip Technology Inc. Application Note DS00002457A-page 28

To observe the signal behavior on the data lines of the USB device (in our case, an optical mouse), wecan probe on the USBB_DP and USBB_DM lines when the device is active (not suspended) using anoscilloscope. The figure below shows the signal levels observed.

Figure 10-5.Active Signal on USBB_DP and USBB_DM

When we probe on the USBB_DP and USBB_DM lines when the device is suspended using anoscilloscope, we observe no activity on the respective lines.

10.2.4 Selective Suspend from Host Port A on SAMA5DxThis section, applicable to all SAMA5Dx products, describes Selective Suspend on host ports of theSAMA5Dx products tested individually on the ports below. In all SAMA5Dx devices Host Port A (EHCI-compliant port; for more details, refer to the device datasheet). This port is shared with the device portover the UTMI transceiver. This port is enabled as a device port by default. The selection between hostport A and the USB device is controlled by the UDPHS enable bit (EN_UDPHS) located in theUDPHS_CTRL register. To use port A as host port, make sure that bit EN_UDPHS is cleared in theUDPHS_CTRL register.

Table 10-1.UDPHS Control Register

Name: UDPHS_CTRL

Address: 0xFC02C000

Access : Read/Write

31 30 29 28 27 26 25 24

- - - - - - - -

23 22 21 20 19 18 17 16

- - - - - - - -

15 14 13 12 11 10 9 8

- - - - PULLD_DIS REWAKEUP DETACH EN_UDPHS

7 6 5 4 3 2 1 0

AN2457

2017 Microchip Technology Inc. Application Note DS00002457A-page 29

EN_UDPHS: UDPHS Enable

0: UDPHS is disabled (read), or this bit disables and resets the UDPHS controller (write). Switch the hostto UTMI.

1: UDPHS is enabled (read), or this bit enables the UDPHS controller (write). Switch the host to UTMI.

For testing, the Gadget driver and the HID drivers can be used in order to make the device a host and toaccess the device connected to other host ports of the device.

10.2.5 Hardware Setup for Connecting USB Host Port to PCThis section describes the hardware setup required to test the USB Selective Suspend feature on aSAMA5D2 Xplained Ultra board.

Figure 10-6.SAMA5D2 Xplained Ultra Board

Connect the Micro USB cable to the EDBG-USB connector (J14). Connect the FTDI cable to the DEBUG connector (J1). Set the baud rate to 115200 for an SD_MMC1 boot, or to 57600 for an eMMC boot.

The following steps are applicable to all SAMA5Dx products: Host port A is connected to any preferred Windows or Linux PC to draw the power required to

power up the SAMA5Dx_XULT boards. By using port A from the PC, a selective suspend of the other host ports available on the device

can be performed.

The block diagram below shows the hardware setup required to test Selective Suspend of hostports through port A.

AN2457

2017 Microchip Technology Inc. Application Note DS00002457A-page 30

Figure 10-7.SAMA5Dx Device Port A

Before starting the test, make sure that the configfs support in the kernel configuration is enabled. Make sure that the kernel was compiled successfully and that a kernel image was created, with the

following drivers as modules in the kernel USB subsystem: configfs.ko libcompostie.ko usb_f_mass_storage.ko atmel_usba_udc.ko g_mass_storage.ko

Use the preferred console terminal - preferably Mincom in Linux and Tera Term in Windows, withthe above-mentioned baud rate.

Power up the board. Make sure that the device is up, depending on the preferred boot media, andthat the root filesystem has mounted successfully. Log in at the device prompt.

Copy all the above mentioned kernel modules from kernel USB subsystem located in /lib/modules//kernel/drivers/usb into your present location for easy loading of modules.

AN2457

2017 Microchip Technology Inc. Application Note DS00002457A-page 31

Insert the USB mass storage device in any of the available host ports and perform the followingsteps:# insmod configfs.ko

# insmod libcomposite.ko

# insmod usb_f_mass_storage.ko

# insmod atmel_usba_udc.ko

# insmod g_mass_storage.ko file=/dev/sda

Number of LUNs=8

Mass Storage Function, version: 2009/09/11

LUN: removable file: (no medium)

Number of LUNs=1

LUN: file: /dev/sda

Number of LUNs=1

g_mass_storage gadget: Mass Storage Gadget, version: 2009/09/11

g_mass_storage gadget: userspace failed to provide iSerialNumber

g_mass_storage gadget: g_mass_storage ready

modprobe can also be used to load above kernel modules.

Note: /dev/sda is the mounting point of the attached USB mass storage device.

Perform the above steps in order to detect the USB device connected on the host ports of theSAMA5Dx device on PC through the USB-A port which was connected for powering through themicro-B cable.

Once the setup is done and the USB connected to the host port of the device is accessible throughthe PC, find the node of the device detected on the Linux PC using a command prompt, andproceed as explained in Demo Using a USB Optical Mouse Connected to Host Port B or C (D3/D4).

AN2457

2017 Microchip Technology Inc. Application Note DS00002457A-page 32

11. USB Global Suspend Example Before testing Global Suspend, a hardware setup must be performed. Follow the steps provided in Hardware Setup for USB Selective Suspend Before starting this demo, make sure that the latest software version is loaded and that the device

is booting with Linux.

For more information, refer to:

http://www.at91.com/linux4sam/bin/view/Linux4SAM/Sama5d2XplainedMainPage#Demo

Once the device boots up, log in at the command prompt.

Poky (Yocto Project Reference Distro) 2.0.1 sama5d2-xplained-sd /dev/ttyS0

sama5d2-xplained-sd login:root

root@sama5d2-xplained-sd:~#

Enter the following command to initiate Global Suspend of the device:root@sama5d2-xplained-sd:~# echo mem > /sys/power/state

PM: Syncing filesystems ... done.

Freezing user space processes ... (elapsed 0.005 second) done.

Freezing remaining freezable tasks ... (elapsed 0.003 second) done.

Suspending console(s) (use no_console_suspend to debug)

The device resumes from Global Suspend when the user asserts the WAKE_UP signal to theprocessor. The following messages are delivered over the debug console once the device resumesfrom Global Suspend:

PM: suspend of devices complete after 122.288 msecs

PM: noirq resume of devices complete after 0.762 msecs

PM: early resume of devices complete after 0.751 msecs

usb usb2: root hub lost power or was reset

PM: resume of devices complete after 278.716 msecs

Restarting tasks ... done.

root@sama5d2-xplained-sd:~#

AN2457

2017 Microchip Technology Inc. Application Note DS00002457A-page 33

http://www.at91.com/linux4sam/bin/view/Linux4SAM/Sama5d2XplainedMainPage#Demo

12. Power Consumption during USB SuspendThe following table depicts the updated power consumption data based on SAMA5D27 CN-ES1605CRev B with BGA289_REVA (No. 6/10), MPM-VB_REVB (SH05) when the device is in Global Suspend.

Table 12-1.SAMA5D2x Power Consumption during USB Suspend

Power Rail Voltage Range (V) USB Active USB Suspend

Current (mA) Current (mA)

VDDUTMIC 1.2 5.18 0.005

VDDUTMII 3.3 18.27 0.16

VDDHSIC 1.2 0.001

The following table depicts the updated power consumption data based on the default SAMA5D3 PowerConsumption Demonstration Platform (RevC CMP+RevD MB+5" LCD) (code version: linux4sam-buildroot-sama5d3xek-cmp-demo-v1.0.zip) when the device is in Global Suspend.

Software: Linux

Low Power Mode Suspend to Mem (Global Suspend): echo mem > /sys/power/state

Table 12-2.SAMA5D3x Power Consumption during USB Suspend

USBActive

Standby (MCK=PCK=132MHz)

Suspend to Mem(MCK=PCK=512MHz=32768 Hz (osc)/64)

Power Rail VoltageRange (V)

Voltage (V) Current(mA)

Current(mA)

PowerConsumption (mW)

Current(mA)

PowerConsumption (mW)

VDDUTMIC(JP3)

1.1~1.32 1.15 7.94 0.0095 0.01 0.0014 0.00

VDDUTMII(JP11)

3.0~3.6 3.3 22.95 0.0001 0.00 0.0001 0.00

The following table depicts the updated power consumption data based on SAMA5D4x-MB RevDTM7000 7'' PDA LCD (VS1034274 00061) when device is in Global Suspend.

Software: Linux

Low Power Mode Suspend to Mem (Global Suspend): echo mem > /sys/power/state

Table 12-3.SAMA5D4X Power Consumption during USB Suspend

Standby (MCK=176 MHz, PCKdisabled)

Suspend to Mem (MCK=32768Hz(osc)/3, PCK disabled)

Power Rail Voltage (V) Current (mA) PowerConsumption(mW)

Current (mA) PowerConsumption(mW)

VDDUTMII (L46) 3.3 0.008 0.0264 0.003 0.0099

AN2457

2017 Microchip Technology Inc. Application Note DS00002457A-page 34

13. USB Host Limitations and Corrections SAMA5D3 experiences an issue of over power consumption when USB host ports (UHPHS) are

used in High-speed mode (EHCI). In High-speed mode (EHCI), it is not possible to suspend theports if no device is attached on each port. This leads to increased power consumption even if thesystem is in a low-power mode. However, this issue does not occur when the device is in Full-speed mode (OHCI). This over power consumption issue has been rectified in SAMA5D2 devices.

USB Suspend can be controlled by EHCI-OHCI or can be forced to fully suspended by connectedports. For this, the SFR_OHCIICR register has to be configured. For more detailed description,refer to Section Special Function Registers in the SAMA5D2 datasheet.

AN2457

2017 Microchip Technology Inc. Application Note DS00002457A-page 35

14. Revision HistoryTable 14-1.Revision History

Doc. Rev. Changes

A First release

AN2457

2017 Microchip Technology Inc. Application Note DS00002457A-page 36

The Microchip Web Site

Microchip provides online support via our web site at http://www.microchip.com/. This web site is used asa means to make files and information easily available to customers. Accessible by using your favoriteInternet browser, the web site contains the following information:

Product Support Data sheets and errata, application notes and sample programs, designresources, users guides and hardware support documents, latest software releases and archivedsoftware

General Technical Support Frequently Asked Questions (FAQ), technical support requests,online discussion groups, Microchip consultant program member listing

Business of Microchip Product selector and ordering guides, latest Microchip press releases,listing of seminars and events, listings of Microchip sales offices, distributors and factoryrepresentatives

Customer Change Notification Service

Microchips customer notification service helps keep customers current on Microchip products.Subscribers will receive e-mail notification whenever there are changes, updates, revisions or erratarelated to a specified product family or development tool of interest.

To register, access the Microchip web site at http://www.microchip.com/. Under Support, click onCustomer Change Notification and follow the registration instructions.

Customer Support

Users of Microchip products can receive assistance through several channels:

Distributor or Representative Local Sales Office Field Application Engineer (FAE) Technical Support

Customers should contact their distributor, representative or Field Application Engineer (FAE) for support.Local sales offices are also available to help customers. A listing of sales offices and locations is includedin the back of this document.

Technical support is available through the web site at: http://www.microchip.com/support

Microchip Devices Code Protection Feature

Note the following details of the code protection feature on Microchip devices:

Microchip products meet the specification contained in their particular Microchip Data Sheet. Microchip believes that its family of products is one of the most secure families of its kind on the

market today, when used in the intended manner and under normal conditions. There are dishonest and possibly illegal methods used to breach the code protection feature. All of

these methods, to our knowledge, require using the Microchip products in a manner outside theoperating specifications contained in Microchips Data Sheets. Most likely, the person doing so isengaged in theft of intellectual property.

Microchip is willing to work with the customer who is concerned about the integrity of their code.

AN2457

2017 Microchip Technology Inc. Application Note DS00002457A-page 37

http://www.microchip.com/http://www.microchip.com/http://www.microchip.com/support

Neither Microchip nor any other semiconductor manufacturer can guarantee the security of theircode. Code protection does not mean that we are guaranteeing the product as unbreakable.

Code protection is constantly evolving. We at Microchip are committed to continuously improving thecode protection features of our products. Attempts to break Microchips code protection feature may be aviolation of the Digital Millennium Copyright Act. If such acts allow unauthorized access to your softwareor other copyrighted work, you may have a right to sue for relief under that Act.

Legal NoticeInformation contained in this publication regarding device applications and the like is provided only foryour convenience and may be superseded by updates. It is your responsibility to ensure that yourapplication meets with your specifications. MICROCHIP MAKES NO REPRESENTATIONS ORWARRANTIES OF ANY KIND WHETHER EXPRESS OR IMPLIED, WRITTEN OR ORAL, STATUTORYOR OTHERWISE, RELATED TO THE INFORMATION, INCLUDING BUT NOT LIMITED TO ITSCONDITION, QUALITY, PERFORMANCE, MERCHANTABILITY OR FITNESS FOR PURPOSE.Microchip disclaims all liability arising from this information and its use. Use of Microchip devices in lifesupport and/or safety applications is entirely at the buyers risk, and the buyer agrees to defend,indemnify and hold harmless Microchip from any and all damages, claims, suits, or expenses resultingfrom such use. No licenses are conveyed, implicitly or otherwise, under any Microchip intellectualproperty rights unless otherwise stated.

TrademarksThe Microchip name and logo, the Microchip logo, AnyRate, AVR, AVR logo, AVR Freaks, BeaconThings,BitCloud, CryptoMemory, CryptoRF, dsPIC, FlashFlex, flexPWR, Heldo, JukeBlox, KeeLoq, KeeLoq logo,Kleer, LANCheck, LINK MD, maXStylus, maXTouch, MediaLB, megaAVR, MOST, MOST logo, MPLAB,OptoLyzer, PIC, picoPower, PICSTART, PIC32 logo, Prochip Designer, QTouch, RightTouch, SAM-BA,SpyNIC, SST, SST Logo, SuperFlash, tinyAVR, UNI/O, and XMEGA are registered trademarks ofMicrochip Technology Incorporated in the U.S.A. and other countries.

ClockWorks, The Embedded Control Solutions Company, EtherSynch, Hyper Speed Control, HyperLightLoad, IntelliMOS, mTouch, Precision Edge, and Quiet-Wire are registered trademarks of MicrochipTechnology Incorporated in the U.S.A.

Adjacent Key Suppression, AKS, Analog-for-the-Digital Age, Any Capacitor, AnyIn, AnyOut, BodyCom,chipKIT, chipKIT logo, CodeGuard, CryptoAuthentication, CryptoCompanion, CryptoController,dsPICDEM, dsPICDEM.net, Dynamic Average Matching, DAM, ECAN, EtherGREEN, In-Circuit SerialProgramming, ICSP, Inter-Chip Connectivity, JitterBlocker, KleerNet, KleerNet logo, Mindi, MiWi,motorBench, MPASM, MPF, MPLAB Certified logo, MPLIB, MPLINK, MultiTRAK, NetDetach, OmniscientCode Generation, PICDEM, PICDEM.net, PICkit, PICtail, PureSilicon, QMatrix, RightTouch logo, REALICE, Ripple Blocker, SAM-ICE, Serial Quad I/O, SMART-I.S., SQI, SuperSwitcher, SuperSwitcher II, TotalEndurance, TSHARC, USBCheck, VariSense, ViewSpan, WiperLock, Wireless DNA, and ZENA aretrademarks of Microchip Technology Incorporated in the U.S.A. and other countries.

SQTP is a service mark of Microchip Technology Incorporated in the U.S.A.

Silicon Storage Technology is a registered trademark of Microchip Technology Inc. in other countries.

GestIC is a registered trademark of Microchip Technology Germany II GmbH & Co. KG, a subsidiary ofMicrochip Technology Inc., in other countries.

All other trademarks mentioned herein are property of their respective companies. 2017, Microchip Technology Incorporated, Printed in the U.S.A., All Rights Reserved.

AN2457

2017 Microchip Technology Inc. Application Note DS00002457A-page 38

ISBN: 978-1-5224-1743-9

Quality Management System Certified by DNV

ISO/TS 16949Microchip received ISO/TS-16949:2009 certification for its worldwide headquarters, design and waferfabrication facilities in Chandler and Tempe, Arizona; Gresham, Oregon and design centers in Californiaand India. The Companys quality system processes and procedures are for its PIC MCUs and dsPIC

DSCs, KEELOQ code hopping devices, Serial EEPROMs, microperipherals, nonvolatile memory andanalog products. In addition, Microchips quality system for the design and manufacture of developmentsystems is ISO 9001:2000 certified.

AN2457

2017 Microchip Technology Inc. Application Note DS00002457A-page 39

AMERICAS ASIA/PACIFIC ASIA/PACIFIC EUROPE

Corporate Office2355 West Chandler Blvd.Chandler, AZ 85224-6199Tel: 480-792-7200Fax: 480-792-7277Technical Support:http://www.microchip.com/supportWeb Address:www.microchip.comAtlantaDuluth, GATel: 678-957-9614Fax: 678-957-1455Austin, TXTel: 512-257-3370BostonWestborough, MATel: 774-760-0087Fax: 774-760-0088ChicagoItasca, ILTel: 630-285-0071Fax: 630-285-0075DallasAddison, TXTel: 972-818-7423Fax: 972-818-2924DetroitNovi, MITel: 248-848-4000Houston, TXTel: 281-894-5983IndianapolisNoblesville, INTel: 317-773-8323Fax: 317-773-5453Tel: 317-536-2380Los AngelesMission Viejo, CATel: 949-462-9523Fax: 949-462-9608Tel: 951-273-7800Raleigh, NCTel: 919-844-7510New York, NYTel: 631-435-6000San Jose, CATel: 408-735-9110Tel: 408-436-4270Canada - TorontoTel: 905-695-1980Fax: 905-695-2078

Asia Pacific OfficeSuites 3707-14, 37th FloorTower 6, The GatewayHarbour City, KowloonHong KongTel: 852-2943-5100Fax: 852-2401-3431Australia - SydneyTel: 61-2-9868-6733Fax: 61-2-9868-6755China - BeijingTel: 86-10-8569-7000Fax: 86-10-8528-2104China - ChengduTel: 86-28-8665-5511Fax: 86-28-8665-7889China - ChongqingTel: 86-23-8980-9588Fax: 86-23-8980-9500China - DongguanTel: 86-769-8702-9880China - GuangzhouTel: 86-20-8755-8029China - HangzhouTel: 86-571-8792-8115Fax: 86-571-8792-8116China - Hong Kong SARTel: 852-2943-5100Fax: 852-2401-3431China - NanjingTel: 86-25-8473-2460Fax: 86-25-8473-2470China - QingdaoTel: 86-532-8502-7355Fax: 86-532-8502-7205China - ShanghaiTel: 86-21-3326-8000Fax: 86-21-3326-8021China - ShenyangTel: 86-24-2334-2829Fax: 86-24-2334-2393China - ShenzhenTel: 86-755-8864-2200Fax: 86-755-8203-1760China - WuhanTel: 86-27-5980-5300Fax: 86-27-5980-5118China - XianTel: 86-29-8833-7252Fax: 86-29-8833-7256

China - XiamenTel: 86-592-2388138Fax: 86-592-2388130China - ZhuhaiTel: 86-756-3210040Fax: 86-756-3210049India - BangaloreTel: 91-80-3090-4444Fax: 91-80-3090-4123India - New DelhiTel: 91-11-4160-8631Fax: 91-11-4160-8632India - PuneTel: 91-20-3019-1500Japan - OsakaTel: 81-6-6152-7160Fax: 81-6-6152-9310Japan - TokyoTel: 81-3-6880- 3770Fax: 81-3-6880-3771Korea - DaeguTel: 82-53-744-4301Fax: 82-53-744-4302Korea - SeoulTel: 82-2-554-7200Fax: 82-2-558-5932 or82-2-558-5934Malaysia - Kuala LumpurTel: 60-3-6201-9857Fax: 60-3-6201-9859Malaysia - PenangTel: 60-4-227-8870Fax: 60-4-227-4068Philippines - ManilaTel: 63-2-634-9065Fax: 63-2-634-9069SingaporeTel: 65-6334-8870Fax: 65-6334-8850Taiwan - Hsin ChuTel: 886-3-5778-366Fax: 886-3-5770-955Taiwan - KaohsiungTel: 886-7-213-7830Taiwan - TaipeiTel: 886-2-2508-8600Fax: 886-2-2508-0102Thailand - BangkokTel: 66-2-694-1351Fax: 66-2-694-1350

Austria - WelsTel: 43-7242-2244-39Fax: 43-7242-2244-393Denmark - CopenhagenTel: 45-4450-2828Fax: 45-4485-2829Finland - EspooTel: 358-9-4520-820France - ParisTel: 33-1-69-53-63-20Fax: 33-1-69-30-90-79France - Saint CloudTel: 33-1-30-60-70-00Germany - GarchingTel: 49-8931-9700Germany - HaanTel: 49-2129-3766400Germany - HeilbronnTel: 49-7131-67-3636Germany - KarlsruheTel: 49-721-625370Germany - MunichTel: 49-89-627-144-0Fax: 49-89-627-144-44Germany - RosenheimTel: 49-8031-354-560Israel - RaananaTel: 972-9-744-7705Italy - MilanTel: 39-0331-742611Fax: 39-0331-466781Italy - PadovaTel: 39-049-7625286Netherlands - DrunenTel: 31-416-690399Fax: 31-416-690340Norway - TrondheimTel: 47-7289-7561Poland - WarsawTel: 48-22-3325737Romania - BucharestTel: 40-21-407-87-50Spain - MadridTel: 34-91-708-08-90Fax: 34-91-708-08-91Sweden - GothenbergTel: 46-31-704-60-40Sweden - StockholmTel: 46-8-5090-4654UK - WokinghamTel: 44-118-921-5800Fax: 44-118-921-5820

Worldwide Sales and Service

2017 Microchip Technology Inc. Application Note DS00002457A-page 40

IntroductionReferencesTable of Contents1.USB Suspend Mode2.USB Ports in SAMA5Dx Devices2.1.USB Host and Device Ports in SAMA5D22.2.USB Host and Device Ports in SAMA5D3 and SAMA5D4

3.USB High-Speed Device Port (UDPHS)3.1.Description3.2.Embedded Characteristics3.3.UTMI Transceivers Sharing3.4.Working with Host Port A as Device Port

4.Entering Suspend Mode from USB Device Port4.1.USB Device Suspend

5.Exiting Suspend Mode from USB Device Port5.1.Receiving a Host Resume5.2.Sending an External Resume

6.USB Host High-Speed Port (UHPHS)6.1.Embedded Characteristics6.2.SAMA5D2 USB Host Ports6.3.SAMA5D3 USB Host Ports6.4.SAMA5D4 USB Host Ports6.5.USB Port Sharing6.6.Block Diagram6.6.1.Block Diagram Description6.6.2.USB Inter-chip Transceiver (SAMA5D2 only)

7.Types of USB Suspend8.USB Global Suspend8.1.USB Global Suspend in SAMA5Dx Devices

9.Suspending USB Host Ports in SAMA5Dx Devices9.1.USB Suspend Mode Implementation in Linux Kernel

10.USB Selective Suspend Example10.1.Hardware Setup for USB Selective Suspend10.2.USB Selective Suspend Mode on Host Ports10.2.1.Useful Attributes in Linux USB Subsystem10.2.2.Demo Using a USB Optical Mouse Connected to Host Port B or C (D3/D4)10.2.3.Signal Behavior on Pins USBB_DP and USBB_DM10.2.4.Selective Suspend from Host Port A on SAMA5Dx10.2.5.Hardware Setup for Connecting USB Host Port to PC

11.USB Global Suspend Example12.Power Consumption during USB Suspend13.USB Host Limitations and Corrections14.Revision HistoryThe Microchip Web SiteCustomer Change Notification ServiceCustomer SupportMicrochip Devices Code Protection FeatureLegal NoticeTrademarksQuality Management System Certified by DNVWorldwide Sales and Service