Skip to content

Moto Mods Firmware: USB-Ext Protocol

Overview

The Moto Mods platform make both USB 2.0 and USB 3.1 available to the Moto Mod. The USB-Ext protocol controls which USB connection is used, the mode of operation and if the device is attached.

Hardware Manifest

; USB-ext interface on CPort XX
[cport-descriptor XX]
bundle = YY
protocol = 0xec

; USB-ext Bundle YY
[bundle-descriptor YY]
class = 0x0f

XX is a unique integer (within your hardware manifest) defining which CPort is used for the USB-ext Interface.

YY is a unique integer (within your hardware manifest) which Bundle the USB-ext CPort is a member of.

Implementation

Files

nuttx/include/nuttx/device_usb_ext.h nuttx/drivers/fusb302.c

Interface Definition

High-Speed Group A High-Speed Group B
USB 2.0 Yes Yes
USB 3.1 No Yes

USB 2.0 is available as a native physical interface if myDP is not being used at the same time. If myDP is required, you can use either USB 3.1 physical interface or a USB 2.0 HSIC interface provided by the Motorola High-Speed bridge. The USB 3.1 physical interface is not available when a Motorola High-Speed bridge is used in the system.

Configure Protocol and Path Using the Configuration Menu

To enable USB, the following modifications in menuconfig are required:

Device Drivers 
        [*]Greybus support
            [*]MODS support for USB

The behavior of the USB device is communicated to the Moto Z using the a notification of the change in attach state (usb_ext_event) and a few simple methods to get the state. The functions are defined in device_usb_ext.h, and an example implementation is available in the fusb302.c driver.

Methods

get_attached

Returns state of USB connection.

uint8_t get_attached(void)
Parameters
void No parameters
Return
int 1 if USB device is attached,
0 otherwise

get_protocol

Returns protocol type of USB connection.

uint8_t get_protocol(void)
Parameters
void No parameters
Return
int GB_USB_EXT_PROTOCOL_3_1 if connected to a USB 3.1 device,
GB_USB_EXT_PROTOCOL_2_0 if connected to a USB 2.0 device

get_path

Returns path of USB connection.

uint8_t get_path(void)
Parameters
void No parameters
Return
int GB_USB_EXT_PATH_A if using the Group A pins,
GB_USB_EXT_PATH_B if using the Group B pins

get_type

Returns type of USB connection.

uint8_t get_type(void)
Parameters
void No parameters
Return
int GB_USB_EXT_REMOTE_DEVICE if the connected device is a USB device (the Moto Z should act as the host),
GB_USB_EXT_REMOTE_HOST if the device connected is a USB host (the Moto Z should act as the device)

Callback Methods

register_callback

Implement register_callback in ops and save the pointer provided (of type ‘usb_ext_event_callback’) to be called on attach.

typedef int (*usb_ext_event_callback)(bool attached);
int (*register_callback)(struct device *dev, usb_ext_event_callback callback);
Parameters
dev Matches dev passed to the probe function.
callback Function implementing usb_ext_event_callback.
Return
int 0 on success, negative errno on error.

unregister_callback

Implement a function to signal the provided pointer is no longer valid.

int (*unregister_callback)(struct device *dev);
Parameters
dev Matches dev passed to the probe function.
Return
int 0 on success, negative errno on error.

Once configured, the only driver only needs to call send the attached state using the registered callback. The USB enumeration will be handled by the Moto Z side.

< Previous Page HID Protocol