2 * Intel Langwell USB OTG transceiver driver
3 * Copyright (C) 2008, 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 __LANGWELL_OTG_H__
21 #define __LANGWELL_OTG_H__
23 /* notify transceiver driver about OTG events */
24 extern void langwell_update_transceiver(void);
25 /* HCD register bus driver */
26 extern int langwell_register_host(struct pci_driver *host_driver);
27 /* HCD unregister bus driver */
28 extern void langwell_unregister_host(struct pci_driver *host_driver);
29 /* DCD register bus driver */
30 extern int langwell_register_peripheral(struct pci_driver *client_driver);
31 /* DCD unregister bus driver */
32 extern void langwell_unregister_peripheral(struct pci_driver *client_driver);
33 /* No silent failure, output warning message */
34 extern void langwell_otg_nsf_msg(unsigned long message);
36 #define CI_USBCMD 0x30
37 # define USBCMD_RST BIT(1)
38 # define USBCMD_RS BIT(0)
39 #define CI_USBSTS 0x34
40 # define USBSTS_SLI BIT(8)
41 # define USBSTS_URI BIT(6)
42 # define USBSTS_PCI BIT(2)
43 #define CI_PORTSC1 0x74
44 # define PORTSC_PP BIT(12)
45 # define PORTSC_LS (BIT(11) | BIT(10))
46 # define PORTSC_SUSP BIT(7)
47 # define PORTSC_CCS BIT(0)
48 #define CI_HOSTPC1 0xb4
49 # define HOSTPC1_PHCD BIT(22)
51 # define OTGSC_DPIE BIT(30)
52 # define OTGSC_1MSE BIT(29)
53 # define OTGSC_BSEIE BIT(28)
54 # define OTGSC_BSVIE BIT(27)
55 # define OTGSC_ASVIE BIT(26)
56 # define OTGSC_AVVIE BIT(25)
57 # define OTGSC_IDIE BIT(24)
58 # define OTGSC_DPIS BIT(22)
59 # define OTGSC_1MSS BIT(21)
60 # define OTGSC_BSEIS BIT(20)
61 # define OTGSC_BSVIS BIT(19)
62 # define OTGSC_ASVIS BIT(18)
63 # define OTGSC_AVVIS BIT(17)
64 # define OTGSC_IDIS BIT(16)
65 # define OTGSC_DPS BIT(14)
66 # define OTGSC_1MST BIT(13)
67 # define OTGSC_BSE BIT(12)
68 # define OTGSC_BSV BIT(11)
69 # define OTGSC_ASV BIT(10)
70 # define OTGSC_AVV BIT(9)
71 # define OTGSC_ID BIT(8)
72 # define OTGSC_HABA BIT(7)
73 # define OTGSC_HADP BIT(6)
74 # define OTGSC_IDPU BIT(5)
75 # define OTGSC_DP BIT(4)
76 # define OTGSC_OT BIT(3)
77 # define OTGSC_HAAR BIT(2)
78 # define OTGSC_VC BIT(1)
79 # define OTGSC_VD BIT(0)
80 # define OTGSC_INTEN_MASK (0x7f << 24)
81 # define OTGSC_INTSTS_MASK (0x7f << 16)
82 #define CI_USBMODE 0xf8
83 # define USBMODE_CM (BIT(1) | BIT(0))
84 # define USBMODE_IDLE 0
85 # define USBMODE_DEVICE 0x2
86 # define USBMODE_HOST 0x3
88 #define INTR_DUMMY_MASK (USBSTS_SLI | USBSTS_URI | USBSTS_PCI)
106 /* Internal variables */
111 /* Timeout indicator for timers */
112 int a_wait_vrise_tmout;
113 int a_wait_bcon_tmout;
114 int a_aidl_bdis_tmout;
115 int b_ase0_brst_tmout;
116 int b_bus_suspend_tmout;
119 /* Informative variables */
132 int b_bus_suspend_vld;
135 #define TA_WAIT_VRISE 100
136 #define TA_WAIT_BCON 30000
137 #define TA_AIDL_BDIS 15000
138 #define TB_ASE0_BRST 5000
140 #define TB_SRP_RES 100
141 #define TB_BUS_SUSPEND 500
143 struct langwell_otg_timer {
144 unsigned long expires; /* Number of count increase to timeout */
145 unsigned long count; /* Tick counter */
146 void (*function)(unsigned long); /* Timeout function */
147 unsigned long data; /* Data passed to function */
148 struct list_head list;
151 struct langwell_otg {
152 struct otg_transceiver otg;
156 struct pci_driver *host_ops;
157 struct pci_driver *client_ops;
158 struct pci_dev *pdev;
159 struct work_struct work;
160 struct workqueue_struct *qwork;
165 static inline struct langwell_otg *otg_to_langwell(struct otg_transceiver *otg)
167 return container_of(otg, struct langwell_otg, otg);
171 #define otg_dbg(fmt, args...) \
172 printk(KERN_DEBUG fmt , ## args)
174 #define otg_dbg(fmt, args...) \
177 #endif /* __LANGWELL_OTG_H__ */