2
* Intel MID (Langwell/Penwell) USB OTG Transceiver driver
3
* Copyright (C) 2008 - 2010, Intel Corporation.
5
* This program is free software; you can redistribute it and/or modify it
6
* under the terms and conditions of the GNU General Public License,
7
* version 2, as published by the Free Software Foundation.
9
* This program is distributed in the hope it will be useful, but WITHOUT
10
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
14
* You should have received a copy of the GNU General Public License along with
15
* this program; if not, write to the Free Software Foundation, Inc.,
16
* 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA.
20
#ifndef __INTEL_MID_OTG_H
21
#define __INTEL_MID_OTG_H
24
#include <linux/usb/otg.h>
25
#include <linux/notifier.h>
27
struct intel_mid_otg_xceiv;
29
/* This is a common data structure for Intel MID platform to
30
* save values of the OTG state machine */
57
/* Internal variables */
63
/* Timeout indicator for timers */
64
int a_wait_vrise_tmout;
65
int a_wait_bcon_tmout;
66
int a_aidl_bdis_tmout;
67
int a_bidl_adis_tmout;
69
int a_wait_vfall_tmout;
70
int b_ase0_brst_tmout;
71
int b_bus_suspend_tmout;
75
int b_adp_sense_tmout;
77
/* Informative variables */
83
int b_bus_suspend_vld;
94
/* must provide ULPI access function to read/write registers implemented in
95
* ULPI address space */
96
struct iotg_ulpi_access_ops {
97
int (*read)(struct intel_mid_otg_xceiv *iotg, u8 reg, u8 *val);
98
int (*write)(struct intel_mid_otg_xceiv *iotg, u8 reg, u8 val);
101
#define OTG_A_DEVICE 0x0
102
#define OTG_B_DEVICE 0x1
105
* the Intel MID (Langwell/Penwell) otg transceiver driver needs to interact
106
* with device and host drivers to implement the USB OTG related feature. More
107
* function members are added based on usb_phy data structure for this
110
struct intel_mid_otg_xceiv {
117
/* ops to access ulpi */
118
struct iotg_ulpi_access_ops ulpi_ops;
120
/* atomic notifier for interrupt context */
121
struct atomic_notifier_head iotg_notifier;
123
/* start/stop USB Host function */
124
int (*start_host)(struct intel_mid_otg_xceiv *iotg);
125
int (*stop_host)(struct intel_mid_otg_xceiv *iotg);
127
/* start/stop USB Peripheral function */
128
int (*start_peripheral)(struct intel_mid_otg_xceiv *iotg);
129
int (*stop_peripheral)(struct intel_mid_otg_xceiv *iotg);
131
/* start/stop ADP sense/probe function */
132
int (*set_adp_probe)(struct intel_mid_otg_xceiv *iotg,
133
bool enabled, int dev);
134
int (*set_adp_sense)(struct intel_mid_otg_xceiv *iotg,
138
/* suspend/resume USB host function */
139
int (*suspend_host)(struct intel_mid_otg_xceiv *iotg,
140
pm_message_t message);
141
int (*resume_host)(struct intel_mid_otg_xceiv *iotg);
143
int (*suspend_peripheral)(struct intel_mid_otg_xceiv *iotg,
144
pm_message_t message);
145
int (*resume_peripheral)(struct intel_mid_otg_xceiv *iotg);
150
struct intel_mid_otg_xceiv *otg_to_mid_xceiv(struct usb_phy *otg)
152
return container_of(otg, struct intel_mid_otg_xceiv, otg);
155
#define MID_OTG_NOTIFY_CONNECT 0x0001
156
#define MID_OTG_NOTIFY_DISCONN 0x0002
157
#define MID_OTG_NOTIFY_HSUSPEND 0x0003
158
#define MID_OTG_NOTIFY_HRESUME 0x0004
159
#define MID_OTG_NOTIFY_CSUSPEND 0x0005
160
#define MID_OTG_NOTIFY_CRESUME 0x0006
161
#define MID_OTG_NOTIFY_HOSTADD 0x0007
162
#define MID_OTG_NOTIFY_HOSTREMOVE 0x0008
163
#define MID_OTG_NOTIFY_CLIENTADD 0x0009
164
#define MID_OTG_NOTIFY_CLIENTREMOVE 0x000a
167
intel_mid_otg_register_notifier(struct intel_mid_otg_xceiv *iotg,
168
struct notifier_block *nb)
170
return atomic_notifier_chain_register(&iotg->iotg_notifier, nb);
174
intel_mid_otg_unregister_notifier(struct intel_mid_otg_xceiv *iotg,
175
struct notifier_block *nb)
177
atomic_notifier_chain_unregister(&iotg->iotg_notifier, nb);
180
#endif /* __INTEL_MID_OTG_H */