Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

usb: add bus type for USB ULPI

UTMI+ Low Pin Interface (ULPI) is a commonly used PHY
interface for USB 2.0. The ULPI specification describes a
standard set of registers which the vendors can extend for
their specific needs. ULPI PHYs provide often functions
such as charger detection and ADP sensing and probing.

There are two major issues that the bus type is meant to
tackle:

Firstly, ULPI registers are accessed from the controller.
The bus provides convenient method for the controller
drivers to share that access with the actual PHY drivers.

Secondly, there are already platforms that assume ULPI PHYs
are runtime detected, such as many Intel Baytrail based
platforms. They do not provide any kind of hardware
description for the ULPI PHYs like separate ACPI device
object that could be used to enumerate a device from.

Signed-off-by: Heikki Krogerus <heikki.krogerus@linux.intel.com>
Acked-by: David Cohen <david.a.cohen@linux.intel.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>

authored by

Heikki Krogerus and committed by
Felipe Balbi
289fcff4 3521a399

+521 -132
+7
MAINTAINERS
··· 10453 10453 F: Documentation/video4linux/zr364xx.txt 10454 10454 F: drivers/media/usb/zr364xx/ 10455 10455 10456 + ULPI BUS 10457 + M: Heikki Krogerus <heikki.krogerus@linux.intel.com> 10458 + L: linux-usb@vger.kernel.org 10459 + S: Maintained 10460 + F: drivers/usb/common/ulpi.c 10461 + F: include/linux/ulpi/ 10462 + 10456 10463 USER-MODE LINUX (UML) 10457 10464 M: Jeff Dike <jdike@addtoit.com> 10458 10465 M: Richard Weinberger <richard@nod.at>
+1
drivers/usb/common/Makefile
··· 7 7 usb-common-$(CONFIG_USB_LED_TRIG) += led.o 8 8 9 9 obj-$(CONFIG_USB_OTG_FSM) += usb-otg-fsm.o 10 + obj-$(CONFIG_USB_ULPI_BUS) += ulpi.o
+255
drivers/usb/common/ulpi.c
··· 1 + /** 2 + * ulpi.c - USB ULPI PHY bus 3 + * 4 + * Copyright (C) 2015 Intel Corporation 5 + * 6 + * Author: Heikki Krogerus <heikki.krogerus@linux.intel.com> 7 + * 8 + * This program is free software; you can redistribute it and/or modify 9 + * it under the terms of the GNU General Public License version 2 as 10 + * published by the Free Software Foundation. 11 + */ 12 + 13 + #include <linux/ulpi/interface.h> 14 + #include <linux/ulpi/driver.h> 15 + #include <linux/ulpi/regs.h> 16 + #include <linux/module.h> 17 + #include <linux/slab.h> 18 + #include <linux/acpi.h> 19 + 20 + /* -------------------------------------------------------------------------- */ 21 + 22 + int ulpi_read(struct ulpi *ulpi, u8 addr) 23 + { 24 + return ulpi->ops->read(ulpi->ops, addr); 25 + } 26 + EXPORT_SYMBOL_GPL(ulpi_read); 27 + 28 + int ulpi_write(struct ulpi *ulpi, u8 addr, u8 val) 29 + { 30 + return ulpi->ops->write(ulpi->ops, addr, val); 31 + } 32 + EXPORT_SYMBOL_GPL(ulpi_write); 33 + 34 + /* -------------------------------------------------------------------------- */ 35 + 36 + static int ulpi_match(struct device *dev, struct device_driver *driver) 37 + { 38 + struct ulpi_driver *drv = to_ulpi_driver(driver); 39 + struct ulpi *ulpi = to_ulpi_dev(dev); 40 + const struct ulpi_device_id *id; 41 + 42 + for (id = drv->id_table; id->vendor; id++) 43 + if (id->vendor == ulpi->id.vendor && 44 + id->product == ulpi->id.product) 45 + return 1; 46 + 47 + return 0; 48 + } 49 + 50 + static int ulpi_uevent(struct device *dev, struct kobj_uevent_env *env) 51 + { 52 + struct ulpi *ulpi = to_ulpi_dev(dev); 53 + 54 + if (add_uevent_var(env, "MODALIAS=ulpi:v%04xp%04x", 55 + ulpi->id.vendor, ulpi->id.product)) 56 + return -ENOMEM; 57 + return 0; 58 + } 59 + 60 + static int ulpi_probe(struct device *dev) 61 + { 62 + struct ulpi_driver *drv = to_ulpi_driver(dev->driver); 63 + 64 + return drv->probe(to_ulpi_dev(dev)); 65 + } 66 + 67 + static int ulpi_remove(struct device *dev) 68 + { 69 + struct ulpi_driver *drv = to_ulpi_driver(dev->driver); 70 + 71 + if (drv->remove) 72 + drv->remove(to_ulpi_dev(dev)); 73 + 74 + return 0; 75 + } 76 + 77 + static struct bus_type ulpi_bus = { 78 + .name = "ulpi", 79 + .match = ulpi_match, 80 + .uevent = ulpi_uevent, 81 + .probe = ulpi_probe, 82 + .remove = ulpi_remove, 83 + }; 84 + 85 + /* -------------------------------------------------------------------------- */ 86 + 87 + static ssize_t modalias_show(struct device *dev, struct device_attribute *attr, 88 + char *buf) 89 + { 90 + struct ulpi *ulpi = to_ulpi_dev(dev); 91 + 92 + return sprintf(buf, "ulpi:v%04xp%04x\n", 93 + ulpi->id.vendor, ulpi->id.product); 94 + } 95 + static DEVICE_ATTR_RO(modalias); 96 + 97 + static struct attribute *ulpi_dev_attrs[] = { 98 + &dev_attr_modalias.attr, 99 + NULL 100 + }; 101 + 102 + static struct attribute_group ulpi_dev_attr_group = { 103 + .attrs = ulpi_dev_attrs, 104 + }; 105 + 106 + static const struct attribute_group *ulpi_dev_attr_groups[] = { 107 + &ulpi_dev_attr_group, 108 + NULL 109 + }; 110 + 111 + static void ulpi_dev_release(struct device *dev) 112 + { 113 + kfree(to_ulpi_dev(dev)); 114 + } 115 + 116 + static struct device_type ulpi_dev_type = { 117 + .name = "ulpi_device", 118 + .groups = ulpi_dev_attr_groups, 119 + .release = ulpi_dev_release, 120 + }; 121 + 122 + /* -------------------------------------------------------------------------- */ 123 + 124 + /** 125 + * ulpi_register_driver - register a driver with the ULPI bus 126 + * @drv: driver being registered 127 + * 128 + * Registers a driver with the ULPI bus. 129 + */ 130 + int ulpi_register_driver(struct ulpi_driver *drv) 131 + { 132 + if (!drv->probe) 133 + return -EINVAL; 134 + 135 + drv->driver.bus = &ulpi_bus; 136 + 137 + return driver_register(&drv->driver); 138 + } 139 + EXPORT_SYMBOL_GPL(ulpi_register_driver); 140 + 141 + /** 142 + * ulpi_unregister_driver - unregister a driver with the ULPI bus 143 + * @drv: driver to unregister 144 + * 145 + * Unregisters a driver with the ULPI bus. 146 + */ 147 + void ulpi_unregister_driver(struct ulpi_driver *drv) 148 + { 149 + driver_unregister(&drv->driver); 150 + } 151 + EXPORT_SYMBOL_GPL(ulpi_unregister_driver); 152 + 153 + /* -------------------------------------------------------------------------- */ 154 + 155 + static int ulpi_register(struct device *dev, struct ulpi *ulpi) 156 + { 157 + int ret; 158 + 159 + /* Test the interface */ 160 + ret = ulpi_write(ulpi, ULPI_SCRATCH, 0xaa); 161 + if (ret < 0) 162 + return ret; 163 + 164 + ret = ulpi_read(ulpi, ULPI_SCRATCH); 165 + if (ret < 0) 166 + return ret; 167 + 168 + if (ret != 0xaa) 169 + return -ENODEV; 170 + 171 + ulpi->id.vendor = ulpi_read(ulpi, ULPI_VENDOR_ID_LOW); 172 + ulpi->id.vendor |= ulpi_read(ulpi, ULPI_VENDOR_ID_HIGH) << 8; 173 + 174 + ulpi->id.product = ulpi_read(ulpi, ULPI_PRODUCT_ID_LOW); 175 + ulpi->id.product |= ulpi_read(ulpi, ULPI_PRODUCT_ID_HIGH) << 8; 176 + 177 + ulpi->dev.parent = dev; 178 + ulpi->dev.bus = &ulpi_bus; 179 + ulpi->dev.type = &ulpi_dev_type; 180 + dev_set_name(&ulpi->dev, "%s.ulpi", dev_name(dev)); 181 + 182 + ACPI_COMPANION_SET(&ulpi->dev, ACPI_COMPANION(dev)); 183 + 184 + request_module("ulpi:v%04xp%04x", ulpi->id.vendor, ulpi->id.product); 185 + 186 + ret = device_register(&ulpi->dev); 187 + if (ret) 188 + return ret; 189 + 190 + dev_dbg(&ulpi->dev, "registered ULPI PHY: vendor %04x, product %04x\n", 191 + ulpi->id.vendor, ulpi->id.product); 192 + 193 + return 0; 194 + } 195 + 196 + /** 197 + * ulpi_register_interface - instantiate new ULPI device 198 + * @dev: USB controller's device interface 199 + * @ops: ULPI register access 200 + * 201 + * Allocates and registers a ULPI device and an interface for it. Called from 202 + * the USB controller that provides the ULPI interface. 203 + */ 204 + struct ulpi *ulpi_register_interface(struct device *dev, struct ulpi_ops *ops) 205 + { 206 + struct ulpi *ulpi; 207 + int ret; 208 + 209 + ulpi = kzalloc(sizeof(*ulpi), GFP_KERNEL); 210 + if (!ulpi) 211 + return ERR_PTR(-ENOMEM); 212 + 213 + ulpi->ops = ops; 214 + ops->dev = dev; 215 + 216 + ret = ulpi_register(dev, ulpi); 217 + if (ret) { 218 + kfree(ulpi); 219 + return ERR_PTR(ret); 220 + } 221 + 222 + return ulpi; 223 + } 224 + EXPORT_SYMBOL_GPL(ulpi_register_interface); 225 + 226 + /** 227 + * ulpi_unregister_interface - unregister ULPI interface 228 + * @intrf: struct ulpi_interface 229 + * 230 + * Unregisters a ULPI device and it's interface that was created with 231 + * ulpi_create_interface(). 232 + */ 233 + void ulpi_unregister_interface(struct ulpi *ulpi) 234 + { 235 + device_unregister(&ulpi->dev); 236 + } 237 + EXPORT_SYMBOL_GPL(ulpi_unregister_interface); 238 + 239 + /* -------------------------------------------------------------------------- */ 240 + 241 + static int __init ulpi_init(void) 242 + { 243 + return bus_register(&ulpi_bus); 244 + } 245 + module_init(ulpi_init); 246 + 247 + static void __exit ulpi_exit(void) 248 + { 249 + bus_unregister(&ulpi_bus); 250 + } 251 + module_exit(ulpi_exit); 252 + 253 + MODULE_AUTHOR("Intel Corporation"); 254 + MODULE_LICENSE("GPL v2"); 255 + MODULE_DESCRIPTION("USB ULPI PHY bus");
+20
drivers/usb/core/Kconfig
··· 84 84 Implements OTG Finite State Machine as specified in On-The-Go 85 85 and Embedded Host Supplement to the USB Revision 2.0 Specification. 86 86 87 + config USB_ULPI_BUS 88 + tristate "USB ULPI PHY interface support" 89 + depends on USB_SUPPORT 90 + help 91 + UTMI+ Low Pin Interface (ULPI) is specification for a commonly used 92 + USB 2.0 PHY interface. The ULPI specification defines a standard set 93 + of registers that can be used to detect the vendor and product which 94 + allows ULPI to be handled as a bus. This module is the driver for that 95 + bus. 96 + 97 + The ULPI interfaces (the buses) are registered by the drivers for USB 98 + controllers which support ULPI register access and have ULPI PHY 99 + attached to them. The ULPI PHY drivers themselves are normal PHY 100 + drivers. 101 + 102 + ULPI PHYs provide often functions such as ADP sensing/probing (OTG 103 + protocol) and USB charger detection. 104 + 105 + To compile this driver as a module, choose M here: the module will 106 + be called ulpi.
+6
include/linux/mod_devicetable.h
··· 629 629 kernel_ulong_t driver_data; 630 630 }; 631 631 632 + struct ulpi_device_id { 633 + __u16 vendor; 634 + __u16 product; 635 + kernel_ulong_t driver_data; 636 + }; 637 + 632 638 #endif /* LINUX_MOD_DEVICETABLE_H */
+60
include/linux/ulpi/driver.h
··· 1 + #ifndef __LINUX_ULPI_DRIVER_H 2 + #define __LINUX_ULPI_DRIVER_H 3 + 4 + #include <linux/mod_devicetable.h> 5 + 6 + #include <linux/device.h> 7 + 8 + struct ulpi_ops; 9 + 10 + /** 11 + * struct ulpi - describes ULPI PHY device 12 + * @id: vendor and product ids for ULPI device 13 + * @ops: I/O access 14 + * @dev: device interface 15 + */ 16 + struct ulpi { 17 + struct ulpi_device_id id; 18 + struct ulpi_ops *ops; 19 + struct device dev; 20 + }; 21 + 22 + #define to_ulpi_dev(d) container_of(d, struct ulpi, dev) 23 + 24 + static inline void ulpi_set_drvdata(struct ulpi *ulpi, void *data) 25 + { 26 + dev_set_drvdata(&ulpi->dev, data); 27 + } 28 + 29 + static inline void *ulpi_get_drvdata(struct ulpi *ulpi) 30 + { 31 + return dev_get_drvdata(&ulpi->dev); 32 + } 33 + 34 + /** 35 + * struct ulpi_driver - describes a ULPI PHY driver 36 + * @id_table: array of device identifiers supported by this driver 37 + * @probe: binds this driver to ULPI device 38 + * @remove: unbinds this driver from ULPI device 39 + * @driver: the name and owner members must be initialized by the drivers 40 + */ 41 + struct ulpi_driver { 42 + const struct ulpi_device_id *id_table; 43 + int (*probe)(struct ulpi *ulpi); 44 + void (*remove)(struct ulpi *ulpi); 45 + struct device_driver driver; 46 + }; 47 + 48 + #define to_ulpi_driver(d) container_of(d, struct ulpi_driver, driver) 49 + 50 + int ulpi_register_driver(struct ulpi_driver *drv); 51 + void ulpi_unregister_driver(struct ulpi_driver *drv); 52 + 53 + #define module_ulpi_driver(__ulpi_driver) \ 54 + module_driver(__ulpi_driver, ulpi_register_driver, \ 55 + ulpi_unregister_driver) 56 + 57 + int ulpi_read(struct ulpi *ulpi, u8 addr); 58 + int ulpi_write(struct ulpi *ulpi, u8 addr, u8 val); 59 + 60 + #endif /* __LINUX_ULPI_DRIVER_H */
+23
include/linux/ulpi/interface.h
··· 1 + #ifndef __LINUX_ULPI_INTERFACE_H 2 + #define __LINUX_ULPI_INTERFACE_H 3 + 4 + #include <linux/types.h> 5 + 6 + struct ulpi; 7 + 8 + /** 9 + * struct ulpi_ops - ULPI register access 10 + * @dev: the interface provider 11 + * @read: read operation for ULPI register access 12 + * @write: write operation for ULPI register access 13 + */ 14 + struct ulpi_ops { 15 + struct device *dev; 16 + int (*read)(struct ulpi_ops *ops, u8 addr); 17 + int (*write)(struct ulpi_ops *ops, u8 addr, u8 val); 18 + }; 19 + 20 + struct ulpi *ulpi_register_interface(struct device *, struct ulpi_ops *); 21 + void ulpi_unregister_interface(struct ulpi *); 22 + 23 + #endif /* __LINUX_ULPI_INTERFACE_H */
+130
include/linux/ulpi/regs.h
··· 1 + #ifndef __LINUX_ULPI_REGS_H 2 + #define __LINUX_ULPI_REGS_H 3 + 4 + /* 5 + * Macros for Set and Clear 6 + * See ULPI 1.1 specification to find the registers with Set and Clear offsets 7 + */ 8 + #define ULPI_SET(a) (a + 1) 9 + #define ULPI_CLR(a) (a + 2) 10 + 11 + /* 12 + * Register Map 13 + */ 14 + #define ULPI_VENDOR_ID_LOW 0x00 15 + #define ULPI_VENDOR_ID_HIGH 0x01 16 + #define ULPI_PRODUCT_ID_LOW 0x02 17 + #define ULPI_PRODUCT_ID_HIGH 0x03 18 + #define ULPI_FUNC_CTRL 0x04 19 + #define ULPI_IFC_CTRL 0x07 20 + #define ULPI_OTG_CTRL 0x0a 21 + #define ULPI_USB_INT_EN_RISE 0x0d 22 + #define ULPI_USB_INT_EN_FALL 0x10 23 + #define ULPI_USB_INT_STS 0x13 24 + #define ULPI_USB_INT_LATCH 0x14 25 + #define ULPI_DEBUG 0x15 26 + #define ULPI_SCRATCH 0x16 27 + /* Optional Carkit Registers */ 28 + #define ULPI_CARKIT_CTRL 0x19 29 + #define ULPI_CARKIT_INT_DELAY 0x1c 30 + #define ULPI_CARKIT_INT_EN 0x1d 31 + #define ULPI_CARKIT_INT_STS 0x20 32 + #define ULPI_CARKIT_INT_LATCH 0x21 33 + #define ULPI_CARKIT_PLS_CTRL 0x22 34 + /* Other Optional Registers */ 35 + #define ULPI_TX_POS_WIDTH 0x25 36 + #define ULPI_TX_NEG_WIDTH 0x26 37 + #define ULPI_POLARITY_RECOVERY 0x27 38 + /* Access Extended Register Set */ 39 + #define ULPI_ACCESS_EXTENDED 0x2f 40 + /* Vendor Specific */ 41 + #define ULPI_VENDOR_SPECIFIC 0x30 42 + /* Extended Registers */ 43 + #define ULPI_EXT_VENDOR_SPECIFIC 0x80 44 + 45 + /* 46 + * Register Bits 47 + */ 48 + 49 + /* Function Control */ 50 + #define ULPI_FUNC_CTRL_XCVRSEL BIT(0) 51 + #define ULPI_FUNC_CTRL_XCVRSEL_MASK 0x3 52 + #define ULPI_FUNC_CTRL_HIGH_SPEED 0x0 53 + #define ULPI_FUNC_CTRL_FULL_SPEED 0x1 54 + #define ULPI_FUNC_CTRL_LOW_SPEED 0x2 55 + #define ULPI_FUNC_CTRL_FS4LS 0x3 56 + #define ULPI_FUNC_CTRL_TERMSELECT BIT(2) 57 + #define ULPI_FUNC_CTRL_OPMODE BIT(3) 58 + #define ULPI_FUNC_CTRL_OPMODE_MASK (0x3 << 3) 59 + #define ULPI_FUNC_CTRL_OPMODE_NORMAL (0x0 << 3) 60 + #define ULPI_FUNC_CTRL_OPMODE_NONDRIVING (0x1 << 3) 61 + #define ULPI_FUNC_CTRL_OPMODE_DISABLE_NRZI (0x2 << 3) 62 + #define ULPI_FUNC_CTRL_OPMODE_NOSYNC_NOEOP (0x3 << 3) 63 + #define ULPI_FUNC_CTRL_RESET BIT(5) 64 + #define ULPI_FUNC_CTRL_SUSPENDM BIT(6) 65 + 66 + /* Interface Control */ 67 + #define ULPI_IFC_CTRL_6_PIN_SERIAL_MODE BIT(0) 68 + #define ULPI_IFC_CTRL_3_PIN_SERIAL_MODE BIT(1) 69 + #define ULPI_IFC_CTRL_CARKITMODE BIT(2) 70 + #define ULPI_IFC_CTRL_CLOCKSUSPENDM BIT(3) 71 + #define ULPI_IFC_CTRL_AUTORESUME BIT(4) 72 + #define ULPI_IFC_CTRL_EXTERNAL_VBUS BIT(5) 73 + #define ULPI_IFC_CTRL_PASSTHRU BIT(6) 74 + #define ULPI_IFC_CTRL_PROTECT_IFC_DISABLE BIT(7) 75 + 76 + /* OTG Control */ 77 + #define ULPI_OTG_CTRL_ID_PULLUP BIT(0) 78 + #define ULPI_OTG_CTRL_DP_PULLDOWN BIT(1) 79 + #define ULPI_OTG_CTRL_DM_PULLDOWN BIT(2) 80 + #define ULPI_OTG_CTRL_DISCHRGVBUS BIT(3) 81 + #define ULPI_OTG_CTRL_CHRGVBUS BIT(4) 82 + #define ULPI_OTG_CTRL_DRVVBUS BIT(5) 83 + #define ULPI_OTG_CTRL_DRVVBUS_EXT BIT(6) 84 + #define ULPI_OTG_CTRL_EXTVBUSIND BIT(7) 85 + 86 + /* USB Interrupt Enable Rising, 87 + * USB Interrupt Enable Falling, 88 + * USB Interrupt Status and 89 + * USB Interrupt Latch 90 + */ 91 + #define ULPI_INT_HOST_DISCONNECT BIT(0) 92 + #define ULPI_INT_VBUS_VALID BIT(1) 93 + #define ULPI_INT_SESS_VALID BIT(2) 94 + #define ULPI_INT_SESS_END BIT(3) 95 + #define ULPI_INT_IDGRD BIT(4) 96 + 97 + /* Debug */ 98 + #define ULPI_DEBUG_LINESTATE0 BIT(0) 99 + #define ULPI_DEBUG_LINESTATE1 BIT(1) 100 + 101 + /* Carkit Control */ 102 + #define ULPI_CARKIT_CTRL_CARKITPWR BIT(0) 103 + #define ULPI_CARKIT_CTRL_IDGNDDRV BIT(1) 104 + #define ULPI_CARKIT_CTRL_TXDEN BIT(2) 105 + #define ULPI_CARKIT_CTRL_RXDEN BIT(3) 106 + #define ULPI_CARKIT_CTRL_SPKLEFTEN BIT(4) 107 + #define ULPI_CARKIT_CTRL_SPKRIGHTEN BIT(5) 108 + #define ULPI_CARKIT_CTRL_MICEN BIT(6) 109 + 110 + /* Carkit Interrupt Enable */ 111 + #define ULPI_CARKIT_INT_EN_IDFLOAT_RISE BIT(0) 112 + #define ULPI_CARKIT_INT_EN_IDFLOAT_FALL BIT(1) 113 + #define ULPI_CARKIT_INT_EN_CARINTDET BIT(2) 114 + #define ULPI_CARKIT_INT_EN_DP_RISE BIT(3) 115 + #define ULPI_CARKIT_INT_EN_DP_FALL BIT(4) 116 + 117 + /* Carkit Interrupt Status and 118 + * Carkit Interrupt Latch 119 + */ 120 + #define ULPI_CARKIT_INT_IDFLOAT BIT(0) 121 + #define ULPI_CARKIT_INT_CARINTDET BIT(1) 122 + #define ULPI_CARKIT_INT_DP BIT(2) 123 + 124 + /* Carkit Pulse Control*/ 125 + #define ULPI_CARKIT_PLS_CTRL_TXPLSEN BIT(0) 126 + #define ULPI_CARKIT_PLS_CTRL_RXPLSEN BIT(1) 127 + #define ULPI_CARKIT_PLS_CTRL_SPKRLEFT_BIASEN BIT(2) 128 + #define ULPI_CARKIT_PLS_CTRL_SPKRRIGHT_BIASEN BIT(3) 129 + 130 + #endif /* __LINUX_ULPI_REGS_H */
+2 -132
include/linux/usb/ulpi.h
··· 12 12 #define __LINUX_USB_ULPI_H 13 13 14 14 #include <linux/usb/otg.h> 15 + #include <linux/ulpi/regs.h> 16 + 15 17 /*-------------------------------------------------------------------------*/ 16 18 17 19 /* ··· 48 46 #define ULPI_FC_OP_NSYNC_NEOP (1 << 24) 49 47 #define ULPI_FC_RST (1 << 25) 50 48 #define ULPI_FC_SUSPM (1 << 26) 51 - 52 - /*-------------------------------------------------------------------------*/ 53 - 54 - /* 55 - * Macros for Set and Clear 56 - * See ULPI 1.1 specification to find the registers with Set and Clear offsets 57 - */ 58 - #define ULPI_SET(a) (a + 1) 59 - #define ULPI_CLR(a) (a + 2) 60 - 61 - /*-------------------------------------------------------------------------*/ 62 - 63 - /* 64 - * Register Map 65 - */ 66 - #define ULPI_VENDOR_ID_LOW 0x00 67 - #define ULPI_VENDOR_ID_HIGH 0x01 68 - #define ULPI_PRODUCT_ID_LOW 0x02 69 - #define ULPI_PRODUCT_ID_HIGH 0x03 70 - #define ULPI_FUNC_CTRL 0x04 71 - #define ULPI_IFC_CTRL 0x07 72 - #define ULPI_OTG_CTRL 0x0a 73 - #define ULPI_USB_INT_EN_RISE 0x0d 74 - #define ULPI_USB_INT_EN_FALL 0x10 75 - #define ULPI_USB_INT_STS 0x13 76 - #define ULPI_USB_INT_LATCH 0x14 77 - #define ULPI_DEBUG 0x15 78 - #define ULPI_SCRATCH 0x16 79 - /* Optional Carkit Registers */ 80 - #define ULPI_CARCIT_CTRL 0x19 81 - #define ULPI_CARCIT_INT_DELAY 0x1c 82 - #define ULPI_CARCIT_INT_EN 0x1d 83 - #define ULPI_CARCIT_INT_STS 0x20 84 - #define ULPI_CARCIT_INT_LATCH 0x21 85 - #define ULPI_CARCIT_PLS_CTRL 0x22 86 - /* Other Optional Registers */ 87 - #define ULPI_TX_POS_WIDTH 0x25 88 - #define ULPI_TX_NEG_WIDTH 0x26 89 - #define ULPI_POLARITY_RECOVERY 0x27 90 - /* Access Extended Register Set */ 91 - #define ULPI_ACCESS_EXTENDED 0x2f 92 - /* Vendor Specific */ 93 - #define ULPI_VENDOR_SPECIFIC 0x30 94 - /* Extended Registers */ 95 - #define ULPI_EXT_VENDOR_SPECIFIC 0x80 96 - 97 - /*-------------------------------------------------------------------------*/ 98 - 99 - /* 100 - * Register Bits 101 - */ 102 - 103 - /* Function Control */ 104 - #define ULPI_FUNC_CTRL_XCVRSEL (1 << 0) 105 - #define ULPI_FUNC_CTRL_XCVRSEL_MASK (3 << 0) 106 - #define ULPI_FUNC_CTRL_HIGH_SPEED (0 << 0) 107 - #define ULPI_FUNC_CTRL_FULL_SPEED (1 << 0) 108 - #define ULPI_FUNC_CTRL_LOW_SPEED (2 << 0) 109 - #define ULPI_FUNC_CTRL_FS4LS (3 << 0) 110 - #define ULPI_FUNC_CTRL_TERMSELECT (1 << 2) 111 - #define ULPI_FUNC_CTRL_OPMODE (1 << 3) 112 - #define ULPI_FUNC_CTRL_OPMODE_MASK (3 << 3) 113 - #define ULPI_FUNC_CTRL_OPMODE_NORMAL (0 << 3) 114 - #define ULPI_FUNC_CTRL_OPMODE_NONDRIVING (1 << 3) 115 - #define ULPI_FUNC_CTRL_OPMODE_DISABLE_NRZI (2 << 3) 116 - #define ULPI_FUNC_CTRL_OPMODE_NOSYNC_NOEOP (3 << 3) 117 - #define ULPI_FUNC_CTRL_RESET (1 << 5) 118 - #define ULPI_FUNC_CTRL_SUSPENDM (1 << 6) 119 - 120 - /* Interface Control */ 121 - #define ULPI_IFC_CTRL_6_PIN_SERIAL_MODE (1 << 0) 122 - #define ULPI_IFC_CTRL_3_PIN_SERIAL_MODE (1 << 1) 123 - #define ULPI_IFC_CTRL_CARKITMODE (1 << 2) 124 - #define ULPI_IFC_CTRL_CLOCKSUSPENDM (1 << 3) 125 - #define ULPI_IFC_CTRL_AUTORESUME (1 << 4) 126 - #define ULPI_IFC_CTRL_EXTERNAL_VBUS (1 << 5) 127 - #define ULPI_IFC_CTRL_PASSTHRU (1 << 6) 128 - #define ULPI_IFC_CTRL_PROTECT_IFC_DISABLE (1 << 7) 129 - 130 - /* OTG Control */ 131 - #define ULPI_OTG_CTRL_ID_PULLUP (1 << 0) 132 - #define ULPI_OTG_CTRL_DP_PULLDOWN (1 << 1) 133 - #define ULPI_OTG_CTRL_DM_PULLDOWN (1 << 2) 134 - #define ULPI_OTG_CTRL_DISCHRGVBUS (1 << 3) 135 - #define ULPI_OTG_CTRL_CHRGVBUS (1 << 4) 136 - #define ULPI_OTG_CTRL_DRVVBUS (1 << 5) 137 - #define ULPI_OTG_CTRL_DRVVBUS_EXT (1 << 6) 138 - #define ULPI_OTG_CTRL_EXTVBUSIND (1 << 7) 139 - 140 - /* USB Interrupt Enable Rising, 141 - * USB Interrupt Enable Falling, 142 - * USB Interrupt Status and 143 - * USB Interrupt Latch 144 - */ 145 - #define ULPI_INT_HOST_DISCONNECT (1 << 0) 146 - #define ULPI_INT_VBUS_VALID (1 << 1) 147 - #define ULPI_INT_SESS_VALID (1 << 2) 148 - #define ULPI_INT_SESS_END (1 << 3) 149 - #define ULPI_INT_IDGRD (1 << 4) 150 - 151 - /* Debug */ 152 - #define ULPI_DEBUG_LINESTATE0 (1 << 0) 153 - #define ULPI_DEBUG_LINESTATE1 (1 << 1) 154 - 155 - /* Carkit Control */ 156 - #define ULPI_CARKIT_CTRL_CARKITPWR (1 << 0) 157 - #define ULPI_CARKIT_CTRL_IDGNDDRV (1 << 1) 158 - #define ULPI_CARKIT_CTRL_TXDEN (1 << 2) 159 - #define ULPI_CARKIT_CTRL_RXDEN (1 << 3) 160 - #define ULPI_CARKIT_CTRL_SPKLEFTEN (1 << 4) 161 - #define ULPI_CARKIT_CTRL_SPKRIGHTEN (1 << 5) 162 - #define ULPI_CARKIT_CTRL_MICEN (1 << 6) 163 - 164 - /* Carkit Interrupt Enable */ 165 - #define ULPI_CARKIT_INT_EN_IDFLOAT_RISE (1 << 0) 166 - #define ULPI_CARKIT_INT_EN_IDFLOAT_FALL (1 << 1) 167 - #define ULPI_CARKIT_INT_EN_CARINTDET (1 << 2) 168 - #define ULPI_CARKIT_INT_EN_DP_RISE (1 << 3) 169 - #define ULPI_CARKIT_INT_EN_DP_FALL (1 << 4) 170 - 171 - /* Carkit Interrupt Status and 172 - * Carkit Interrupt Latch 173 - */ 174 - #define ULPI_CARKIT_INT_IDFLOAT (1 << 0) 175 - #define ULPI_CARKIT_INT_CARINTDET (1 << 1) 176 - #define ULPI_CARKIT_INT_DP (1 << 2) 177 - 178 - /* Carkit Pulse Control*/ 179 - #define ULPI_CARKIT_PLS_CTRL_TXPLSEN (1 << 0) 180 - #define ULPI_CARKIT_PLS_CTRL_RXPLSEN (1 << 1) 181 - #define ULPI_CARKIT_PLS_CTRL_SPKRLEFT_BIASEN (1 << 2) 182 - #define ULPI_CARKIT_PLS_CTRL_SPKRRIGHT_BIASEN (1 << 3) 183 49 184 50 /*-------------------------------------------------------------------------*/ 185 51
+4
scripts/mod/devicetable-offsets.c
··· 189 189 DEVID_FIELD(rio_device_id, asm_did); 190 190 DEVID_FIELD(rio_device_id, asm_vid); 191 191 192 + DEVID(ulpi_device_id); 193 + DEVID_FIELD(ulpi_device_id, vendor); 194 + DEVID_FIELD(ulpi_device_id, product); 195 + 192 196 return 0; 193 197 }
+13
scripts/mod/file2alias.c
··· 1192 1192 } 1193 1193 ADD_TO_DEVTABLE("rapidio", rio_device_id, do_rio_entry); 1194 1194 1195 + /* Looks like: ulpi:vNpN */ 1196 + static int do_ulpi_entry(const char *filename, void *symval, 1197 + char *alias) 1198 + { 1199 + DEF_FIELD(symval, ulpi_device_id, vendor); 1200 + DEF_FIELD(symval, ulpi_device_id, product); 1201 + 1202 + sprintf(alias, "ulpi:v%04xp%04x", vendor, product); 1203 + 1204 + return 1; 1205 + } 1206 + ADD_TO_DEVTABLE("ulpi", ulpi_device_id, do_ulpi_entry); 1207 + 1195 1208 /* Does namelen bytes of name exactly match the symbol? */ 1196 1209 static bool sym_is(const char *name, unsigned namelen, const char *symbol) 1197 1210 {