aboutsummaryrefslogtreecommitdiffstats
path: root/include/linux/ulpi
diff options
context:
space:
mode:
authorHeikki Krogerus <heikki.krogerus@linux.intel.com>2015-05-13 08:26:42 -0400
committerFelipe Balbi <balbi@ti.com>2015-05-13 13:04:55 -0400
commit289fcff4bcdb1dcc0ce8788b7ea0f58a9e4a495f (patch)
tree7c5156a0a503fccc18a449de06edda6c07060160 /include/linux/ulpi
parent3521a399dae8d66fc784cef70a78e65ce73e364f (diff)
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>
Diffstat (limited to 'include/linux/ulpi')
-rw-r--r--include/linux/ulpi/driver.h60
-rw-r--r--include/linux/ulpi/interface.h23
-rw-r--r--include/linux/ulpi/regs.h130
3 files changed, 213 insertions, 0 deletions
diff --git a/include/linux/ulpi/driver.h b/include/linux/ulpi/driver.h
new file mode 100644
index 000000000000..388f6e08b9d4
--- /dev/null
+++ b/include/linux/ulpi/driver.h
@@ -0,0 +1,60 @@
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
8struct 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 */
16struct 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
24static inline void ulpi_set_drvdata(struct ulpi *ulpi, void *data)
25{
26 dev_set_drvdata(&ulpi->dev, data);
27}
28
29static 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 */
41struct 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
50int ulpi_register_driver(struct ulpi_driver *drv);
51void 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
57int ulpi_read(struct ulpi *ulpi, u8 addr);
58int ulpi_write(struct ulpi *ulpi, u8 addr, u8 val);
59
60#endif /* __LINUX_ULPI_DRIVER_H */
diff --git a/include/linux/ulpi/interface.h b/include/linux/ulpi/interface.h
new file mode 100644
index 000000000000..4de8ab491038
--- /dev/null
+++ b/include/linux/ulpi/interface.h
@@ -0,0 +1,23 @@
1#ifndef __LINUX_ULPI_INTERFACE_H
2#define __LINUX_ULPI_INTERFACE_H
3
4#include <linux/types.h>
5
6struct 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 */
14struct 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
20struct ulpi *ulpi_register_interface(struct device *, struct ulpi_ops *);
21void ulpi_unregister_interface(struct ulpi *);
22
23#endif /* __LINUX_ULPI_INTERFACE_H */
diff --git a/include/linux/ulpi/regs.h b/include/linux/ulpi/regs.h
new file mode 100644
index 000000000000..b5b8b8804560
--- /dev/null
+++ b/include/linux/ulpi/regs.h
@@ -0,0 +1,130 @@
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 */