musb_core.h 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667
  1. /*
  2. * MUSB OTG driver defines
  3. *
  4. * Copyright 2005 Mentor Graphics Corporation
  5. * Copyright (C) 2005-2006 by Texas Instruments
  6. * Copyright (C) 2006-2007 Nokia Corporation
  7. *
  8. * This program is free software; you can redistribute it and/or
  9. * modify it under the terms of the GNU General Public License
  10. * version 2 as published by the Free Software Foundation.
  11. *
  12. * This program is distributed in the hope that it will be useful, but
  13. * WITHOUT ANY WARRANTY; without even the implied warranty of
  14. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  15. * General Public License for more details.
  16. *
  17. * You should have received a copy of the GNU General Public License
  18. * along with this program; if not, write to the Free Software
  19. * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
  20. * 02110-1301 USA
  21. *
  22. * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
  23. * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
  24. * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN
  25. * NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY DIRECT, INDIRECT,
  26. * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
  27. * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
  28. * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
  29. * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  30. * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
  31. * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  32. *
  33. */
  34. #ifndef __MUSB_CORE_H__
  35. #define __MUSB_CORE_H__
  36. #include <linux/slab.h>
  37. #include <linux/list.h>
  38. #include <linux/interrupt.h>
  39. #include <linux/errno.h>
  40. #include <linux/timer.h>
  41. #include <linux/device.h>
  42. #include <linux/usb/ch9.h>
  43. #include <linux/usb/gadget.h>
  44. #include <linux/usb.h>
  45. #include <linux/usb/otg.h>
  46. #include "musb.h"
  47. #include <linux/wakelock.h>
  48. #include <linux/version.h>
  49. /* data type used from mt_typdefs.h, mt_typedefs.h is removed now */
  50. typedef enum {
  51. KAL_FALSE = 0,
  52. KAL_TRUE = 1,
  53. } kal_bool;
  54. #ifndef TRUE
  55. #define TRUE true
  56. #endif
  57. typedef unsigned int kal_uint32;
  58. typedef uint8_t kal_uint8;
  59. /* data type and MACRO used from mt_typdefs.h for UART USB SWITCH */
  60. typedef unsigned char UINT8;
  61. typedef unsigned int UINT32;
  62. #define WRITE_REGISTER_UINT32(reg, val) ((*(volatile UINT32 * const)(reg)) = (val))
  63. #define READ_REGISTER_UINT8(reg) ((*(volatile UINT8 * const)(reg)))
  64. #define WRITE_REGISTER_UINT8(reg, val) ((*(volatile UINT8 * const)(reg)) = (val))
  65. #define INREG8(x) READ_REGISTER_UINT8((UINT8 *)((void *)(x)))
  66. #define OUTREG8(x, y) WRITE_REGISTER_UINT8((UINT8 *)((void *)(x)), (UINT8)(y))
  67. #define OUTREG32(x, y) WRITE_REGISTER_UINT32((UINT32 *)((void *)(x)), (UINT32)(y))
  68. #define DRV_Reg8(addr) INREG8(addr)
  69. #define DRV_WriteReg8(addr, data) OUTREG8(addr, data)
  70. #define DRV_WriteReg32(addr, data) OUTREG32(addr, data)
  71. #ifdef MUSB_QMU_SUPPORT
  72. #include "mtk_qmu.h"
  73. #endif
  74. #define SHARE_IRQ -1
  75. struct musb;
  76. struct musb_hw_ep;
  77. struct musb_ep;
  78. extern volatile bool usb_is_host;
  79. extern int musb_skip_charge_detect;
  80. extern int musb_is_shutting;
  81. extern int musb_removed;
  82. extern int musb_epx_transfer_allowed;
  83. extern struct usb_ep *ep_in;
  84. extern struct usb_ep *ep_out;
  85. extern int bitdebug_enabled;
  86. extern unsigned bitdebug_writeCnt;
  87. extern unsigned bitdebug_readCnt;
  88. extern unsigned musb_uart_debug;
  89. extern struct musb *mtk_musb;
  90. extern bool mtk_usb_power;
  91. extern int ep_config_from_table_for_host(struct musb *musb);
  92. extern int polling_vbus_value(void *data);
  93. #if defined(CONFIG_USBIF_COMPLIANCE)
  94. extern bool polling_vbus;
  95. extern struct task_struct *vbus_polling_tsk;
  96. extern void musb_set_host_request_flag(struct musb *musb, unsigned value);
  97. extern void pmic_bvalid_det_int_en(int);
  98. #define CONFIG_USBIF_COMPLIANCE_PMIC
  99. #if defined(CONFIG_USBIF_COMPLIANCE_PMIC)
  100. extern int PMIC_IMM_GetOneChannelValue(int dwChannel, int deCount, int trimd);
  101. #define MT6328_AUX_VCDT_AP 2 /* include/mach/upmu_sw.h */
  102. #define AUX_VCDT_AP MT6328_AUX_VCDT_AP /* include/mach/upmu_sw.h */
  103. #define R_CHARGER_1 330
  104. #define R_CHARGER_2 39
  105. #else
  106. extern signed_int battery_meter_get_charger_voltage(void);
  107. #endif
  108. extern void send_otg_event(enum usb_otg_event event);
  109. #endif
  110. /* Helper defines for struct musb->hwvers */
  111. #define MUSB_HWVERS_MAJOR(x) ((x >> 10) & 0x1f)
  112. #define MUSB_HWVERS_MINOR(x) (x & 0x3ff)
  113. #define MUSB_HWVERS_RC 0x8000
  114. #define MUSB_HWVERS_1300 0x52C
  115. #define MUSB_HWVERS_1400 0x590
  116. #define MUSB_HWVERS_1800 0x720
  117. #define MUSB_HWVERS_1900 0x784
  118. #define MUSB_HWVERS_2000 0x800
  119. #define MUSB_HUB_SUPPORT 0x4000
  120. #include "mtk_musb.h"
  121. #include "musb_debug.h"
  122. #include "musb_dma.h"
  123. #include "musb_io.h"
  124. #include "mtk_musb_reg.h"
  125. #include "musb_gadget.h"
  126. #include <linux/usb/hcd.h>
  127. #include "musb_host.h"
  128. #ifdef CONFIG_OF
  129. enum {
  130. usb0 = 0,
  131. usb_sif,
  132. usb_acm_temp_device,
  133. };
  134. extern struct device_node *dts_np;
  135. #endif
  136. #ifdef ENABLE_STORAGE_LOGGER
  137. #define USB_LOGGER(msg_id, func_name, ...) \
  138. do { \
  139. if (unlikely(is_dump_musb())) { \
  140. ADD_USB_TRACE(msg_id, func_name, __VA_ARGS__); \
  141. } \
  142. } while (0)
  143. #else
  144. #define USB_LOGGER(msg_id, func_name, args...) do {} while (0)
  145. #endif
  146. /* NOTE: otg and peripheral-only state machines start at B_IDLE.
  147. * OTG or host-only go to A_IDLE when ID is sensed.
  148. */
  149. #define is_peripheral_active(m) (!(m)->is_host)
  150. #define is_host_active(m) ((m)->is_host)
  151. #ifdef CONFIG_PROC_FS
  152. #include <linux/fs.h>
  153. #define MUSB_CONFIG_PROC_FS
  154. #endif
  155. /****************************** PERIPHERAL ROLE *****************************/
  156. extern irqreturn_t musb_g_ep0_irq(struct musb *);
  157. extern void musb_g_tx(struct musb *, u8);
  158. extern void musb_g_rx(struct musb *, u8);
  159. extern void musb_g_reset(struct musb *);
  160. extern void musb_g_suspend(struct musb *);
  161. extern void musb_g_resume(struct musb *);
  162. extern void musb_g_wakeup(struct musb *);
  163. extern void musb_g_disconnect(struct musb *);
  164. /****************************** HOST ROLE ***********************************/
  165. extern irqreturn_t musb_h_ep0_irq(struct musb *);
  166. extern void musb_host_tx(struct musb *, u8);
  167. extern void musb_host_rx(struct musb *, u8);
  168. /****************************** CONSTANTS ********************************/
  169. #ifndef MUSB_C_NUM_EPS
  170. #define MUSB_C_NUM_EPS ((u8)16)
  171. #endif
  172. #ifndef MUSB_MAX_END0_PACKET
  173. #define MUSB_MAX_END0_PACKET ((u16)MUSB_EP0_FIFOSIZE)
  174. #endif
  175. /* host side ep0 states */
  176. enum musb_h_ep0_state {
  177. MUSB_EP0_IDLE,
  178. MUSB_EP0_START, /* expect ack of setup */
  179. MUSB_EP0_IN, /* expect IN DATA */
  180. MUSB_EP0_OUT, /* expect ack of OUT DATA */
  181. MUSB_EP0_STATUS, /* expect ack of STATUS */
  182. } __packed;
  183. /* peripheral side ep0 states */
  184. enum musb_g_ep0_state {
  185. MUSB_EP0_STAGE_IDLE, /* idle, waiting for SETUP */
  186. MUSB_EP0_STAGE_SETUP, /* received SETUP */
  187. MUSB_EP0_STAGE_TX, /* IN data */
  188. MUSB_EP0_STAGE_RX, /* OUT data */
  189. MUSB_EP0_STAGE_STATUSIN, /* (after OUT data) */
  190. MUSB_EP0_STAGE_STATUSOUT, /* (after IN data) */
  191. MUSB_EP0_STAGE_ACKWAIT, /* after zlp, before statusin */
  192. } __packed;
  193. /*
  194. * OTG protocol constants. See USB OTG 1.3 spec,
  195. * sections 5.5 "Device Timings" and 6.6.5 "Timers".
  196. */
  197. #define OTG_TIME_A_WAIT_VRISE 100 /* msec (max) */
  198. #define OTG_TIME_A_WAIT_BCON 1100 /* min 1 second */
  199. #define OTG_TIME_A_AIDL_BDIS 200 /* min 200 msec */
  200. #if defined(CONFIG_USBIF_COMPLIANCE)
  201. #define OTG_TIME_B_ASE0_BRST 155 /* min 3.125 ms */
  202. #else
  203. #define OTG_TIME_B_ASE0_BRST 100 /* min 3.125 ms */
  204. #endif
  205. /*************************** REGISTER ACCESS ********************************/
  206. #define musb_ep_select(_mbase, _epnum) \
  207. musb_writeb((_mbase), MUSB_INDEX, (_epnum))
  208. #define MUSB_EP_OFFSET MUSB_INDEXED_OFFSET
  209. /****************************** FUNCTIONS ********************************/
  210. #define MUSB_HST_MODE(_musb)\
  211. { (_musb)->is_host = true; }
  212. #define MUSB_DEV_MODE(_musb) \
  213. { (_musb)->is_host = false; }
  214. #define test_devctl_hst_mode(_x) \
  215. (musb_readb((_x)->mregs, MUSB_DEVCTL)&MUSB_DEVCTL_HM)
  216. #define MUSB_MODE(musb) ((musb)->is_host ? "Host" : "Peripheral")
  217. typedef enum {
  218. funcWriteb = 0,
  219. funcWritew,
  220. funcWritel,
  221. funcInterrupt
  222. } writeFunc_enum;
  223. void dumpTime(writeFunc_enum func, int epnum);
  224. /******************************** TYPES *************************************/
  225. /**
  226. * struct musb_platform_ops - Operations passed to musb_core by HW glue layer
  227. * @init: turns on clocks, sets up platform-specific registers, etc
  228. * @exit: undoes @init
  229. * @set_mode: forcefully changes operating mode
  230. * @try_ilde: tries to idle the IP
  231. * @vbus_status: returns vbus status if possible
  232. * @set_vbus: forces vbus status
  233. * @adjust_channel_params: pre check for standard dma channel_program func
  234. */
  235. struct musb_platform_ops {
  236. int (*init)(struct musb *musb);
  237. int (*exit)(struct musb *musb);
  238. void (*enable)(struct musb *musb);
  239. void (*disable)(struct musb *musb);
  240. int (*set_mode)(struct musb *musb, u8 mode);
  241. void (*try_idle)(struct musb *musb, unsigned long timeout);
  242. int (*vbus_status)(struct musb *musb);
  243. void (*set_vbus)(struct musb *musb, int on);
  244. int (*adjust_channel_params)(struct dma_channel *channel,
  245. u16 packet_sz, u8 *mode, dma_addr_t *dma_addr, u32 *len);
  246. };
  247. /*
  248. * struct musb_hw_ep - endpoint hardware (bidirectional)
  249. *
  250. * Ordered slightly for better cacheline locality.
  251. */
  252. struct musb_hw_ep {
  253. struct musb *musb;
  254. void __iomem *fifo;
  255. void __iomem *regs;
  256. /* index in musb->endpoints[] */
  257. u8 epnum;
  258. enum musb_ep_mode ep_mode;
  259. /* hardware configuration, possibly dynamic */
  260. bool is_shared_fifo;
  261. bool tx_double_buffered;
  262. bool rx_double_buffered;
  263. u16 max_packet_sz_tx;
  264. u16 max_packet_sz_rx;
  265. struct dma_channel *tx_channel;
  266. struct dma_channel *rx_channel;
  267. void __iomem *target_regs;
  268. /* currently scheduled peripheral endpoint */
  269. struct musb_qh *in_qh;
  270. struct musb_qh *out_qh;
  271. u8 rx_reinit;
  272. u8 tx_reinit;
  273. /* peripheral side */
  274. struct musb_ep ep_in; /* TX */
  275. struct musb_ep ep_out; /* RX */
  276. };
  277. static inline struct musb_request *next_in_request(struct musb_hw_ep *hw_ep)
  278. {
  279. return next_request(&hw_ep->ep_in);
  280. }
  281. static inline struct musb_request *next_out_request(struct musb_hw_ep *hw_ep)
  282. {
  283. return next_request(&hw_ep->ep_out);
  284. }
  285. struct musb_csr_regs {
  286. /* FIFO registers */
  287. u16 txmaxp, txcsr, rxmaxp, rxcsr;
  288. u16 rxfifoadd, txfifoadd;
  289. u8 txtype, txinterval, rxtype, rxinterval;
  290. u8 rxfifosz, txfifosz;
  291. u8 txfunaddr, txhubaddr, txhubport;
  292. u8 rxfunaddr, rxhubaddr, rxhubport;
  293. };
  294. struct musb_context_registers {
  295. u8 power;
  296. u8 intrusbe;
  297. u16 frame;
  298. u8 index, testmode;
  299. u8 devctl, busctl, misc;
  300. u32 otg_interfsel;
  301. u32 l1_int;
  302. struct musb_csr_regs index_regs[MUSB_C_NUM_EPS];
  303. };
  304. /*
  305. * struct musb - Driver instance data.
  306. */
  307. struct musb {
  308. struct semaphore musb_lock;
  309. /* device lock */
  310. spinlock_t lock;
  311. const struct musb_platform_ops *ops;
  312. struct musb_context_registers context;
  313. irqreturn_t (*isr)(int, void *);
  314. struct work_struct irq_work;
  315. struct work_struct otg_notifier_work;
  316. u16 hwvers;
  317. struct delayed_work id_pin_work;
  318. struct musb_fifo_cfg *fifo_cfg;
  319. unsigned fifo_cfg_size;
  320. struct musb_fifo_cfg *fifo_cfg_host;
  321. unsigned fifo_cfg_host_size;
  322. u32 fifo_size;
  323. u16 intrrxe;
  324. u16 intrtxe;
  325. /* this hub status bit is reserved by USB 2.0 and not seen by usbcore */
  326. #define MUSB_PORT_STAT_RESUME (1 << 31)
  327. u32 port1_status;
  328. unsigned long rh_timer;
  329. enum musb_h_ep0_state ep0_stage;
  330. /* bulk traffic normally dedicates endpoint hardware, and each
  331. * direction has its own ring of host side endpoints.
  332. * we try to progress the transfer at the head of each endpoint's
  333. * queue until it completes or NAKs too much; then we try the next
  334. * endpoint.
  335. */
  336. struct musb_hw_ep *bulk_ep;
  337. struct list_head control; /* of musb_qh */
  338. struct list_head in_bulk; /* of musb_qh */
  339. struct list_head out_bulk; /* of musb_qh */
  340. struct timer_list otg_timer;
  341. #if defined(CONFIG_USBIF_COMPLIANCE)
  342. struct timer_list otg_vbus_polling_timer;
  343. #endif
  344. struct notifier_block nb;
  345. struct dma_controller *dma_controller;
  346. struct device *controller;
  347. void __iomem *ctrl_base;
  348. void __iomem *mregs;
  349. /* passed down from chip/board specific irq handlers */
  350. u8 int_usb;
  351. u16 int_rx;
  352. u16 int_tx;
  353. #ifdef MUSB_QMU_SUPPORT
  354. u32 int_queue;
  355. #ifdef QMU_TASKLET
  356. u32 qmu_done_intr;
  357. struct tasklet_struct qmu_done;
  358. #endif
  359. #endif
  360. struct usb_phy *xceiv;
  361. u8 xceiv_event;
  362. int nIrq;
  363. int dma_irq;
  364. unsigned irq_wake:1;
  365. struct musb_hw_ep endpoints[MUSB_C_NUM_EPS];
  366. #define control_ep endpoints
  367. #define VBUSERR_RETRY_COUNT 3
  368. u16 vbuserr_retry;
  369. u16 epmask;
  370. u8 nr_endpoints;
  371. int (*board_set_power)(int state);
  372. u8 min_power; /* vbus for periph, in mA/2 */
  373. bool is_host;
  374. bool in_ipo_off;
  375. int a_wait_bcon; /* VBUS timeout in msecs */
  376. unsigned long idle_timeout; /* Next timeout in jiffies */
  377. /* active means connected and not suspended */
  378. unsigned is_active:1;
  379. unsigned is_multipoint:1;
  380. unsigned ignore_disconnect:1; /* during bus resets */
  381. unsigned hb_iso_rx:1; /* high bandwidth iso rx? */
  382. unsigned hb_iso_tx:1; /* high bandwidth iso tx? */
  383. unsigned dyn_fifo:1; /* dynamic FIFO supported? */
  384. unsigned bulk_split:1;
  385. #define can_bulk_split(musb, type) \
  386. (((type) == USB_ENDPOINT_XFER_BULK) && (musb)->bulk_split)
  387. unsigned bulk_combine:1;
  388. #define can_bulk_combine(musb, type) \
  389. (((type) == USB_ENDPOINT_XFER_BULK) && (musb)->bulk_combine)
  390. /* is_suspended means USB B_PERIPHERAL suspend */
  391. unsigned is_suspended:1;
  392. /* may_wakeup means remote wakeup is enabled */
  393. unsigned may_wakeup:1;
  394. /* is_self_powered is reported in device status and the
  395. * config descriptor. is_bus_powered means B_PERIPHERAL
  396. * draws some VBUS current; both can be true.
  397. */
  398. unsigned is_self_powered:1;
  399. unsigned is_bus_powered:1;
  400. unsigned set_address:1;
  401. unsigned test_mode:1;
  402. unsigned softconnect:1;
  403. u8 address;
  404. u8 test_mode_nr;
  405. u16 ackpend; /* ep0 */
  406. enum musb_g_ep0_state ep0_state;
  407. struct usb_gadget g; /* the gadget */
  408. struct usb_gadget_driver *gadget_driver; /* its driver */
  409. struct wake_lock usb_lock;
  410. /*
  411. * FIXME: Remove this flag.
  412. *
  413. * This is only added to allow Blackfin to work
  414. * with current driver. For some unknown reason
  415. * Blackfin doesn't work with double buffering
  416. * and that's enabled by default.
  417. *
  418. * We added this flag to forcefully disable double
  419. * buffering until we get it working.
  420. */
  421. unsigned double_buffer_not_ok:1;
  422. struct musb_hdrc_config *config;
  423. #ifdef MUSB_CONFIG_PROC_FS
  424. struct proc_dir_entry *proc_entry;
  425. #endif
  426. int xceiv_old_state;
  427. #ifdef CONFIG_DEBUG_FS
  428. struct dentry *debugfs_root;
  429. #endif
  430. bool power;
  431. bool is_ready:1;
  432. bool usb_if;
  433. u16 fifo_addr;
  434. #if defined(CONFIG_USBIF_COMPLIANCE)
  435. bool srp_drvvbus;
  436. enum usb_otg_event otg_event;
  437. #endif
  438. };
  439. static inline struct musb *gadget_to_musb(struct usb_gadget *g)
  440. {
  441. return container_of(g, struct musb, g);
  442. }
  443. static inline int musb_read_fifosize(struct musb *musb, struct musb_hw_ep *hw_ep, u8 epnum)
  444. {
  445. void __iomem *mbase = musb->mregs;
  446. u8 reg = 0;
  447. /* read from core using indexed model */
  448. reg = musb_readb(mbase, MUSB_EP_OFFSET(epnum, MUSB_FIFOSIZE));
  449. /* 0's returned when no more endpoints */
  450. if (!reg)
  451. return -ENODEV;
  452. musb->nr_endpoints++;
  453. musb->epmask |= (1 << epnum);
  454. hw_ep->max_packet_sz_tx = 1 << (reg & 0x0f);
  455. /* shared TX/RX FIFO? */
  456. if ((reg & 0xf0) == 0xf0) {
  457. hw_ep->max_packet_sz_rx = hw_ep->max_packet_sz_tx;
  458. hw_ep->is_shared_fifo = true;
  459. return 0;
  460. }
  461. hw_ep->max_packet_sz_rx = 1 << ((reg & 0xf0) >> 4);
  462. hw_ep->is_shared_fifo = false;
  463. return 0;
  464. }
  465. static inline void musb_configure_ep0(struct musb *musb)
  466. {
  467. musb->endpoints[0].max_packet_sz_tx = MUSB_EP0_FIFOSIZE;
  468. musb->endpoints[0].max_packet_sz_rx = MUSB_EP0_FIFOSIZE;
  469. musb->endpoints[0].is_shared_fifo = true;
  470. }
  471. /***************************** Glue it together *****************************/
  472. extern const char musb_driver_name[];
  473. extern void musb_start(struct musb *musb);
  474. extern void musb_stop(struct musb *musb);
  475. extern int musb_get_id(struct device *dev, gfp_t gfp_mask);
  476. extern void musb_put_id(struct device *dev, int id);
  477. extern void musb_write_fifo(struct musb_hw_ep *ep, u16 len, const u8 *src);
  478. extern void musb_read_fifo(struct musb_hw_ep *ep, u16 len, u8 *dst);
  479. extern void musb_load_testpacket(struct musb *);
  480. extern void musb_generic_disable(struct musb *);
  481. extern irqreturn_t musb_interrupt(struct musb *);
  482. extern irqreturn_t dma_controller_irq(int irq, void *private_data);
  483. extern void musb_hnp_stop(struct musb *musb);
  484. static inline void musb_platform_set_vbus(struct musb *musb, int is_on)
  485. {
  486. if (musb->ops->set_vbus)
  487. musb->ops->set_vbus(musb, is_on);
  488. }
  489. static inline void musb_platform_enable(struct musb *musb)
  490. {
  491. if (musb->ops->enable)
  492. musb->ops->enable(musb);
  493. }
  494. static inline void musb_platform_disable(struct musb *musb)
  495. {
  496. if (musb->ops->disable)
  497. musb->ops->disable(musb);
  498. }
  499. static inline int musb_platform_set_mode(struct musb *musb, u8 mode)
  500. {
  501. if (!musb->ops->set_mode)
  502. return 0;
  503. return musb->ops->set_mode(musb, mode);
  504. }
  505. static inline void musb_platform_try_idle(struct musb *musb, unsigned long timeout)
  506. {
  507. if (musb->ops->try_idle)
  508. musb->ops->try_idle(musb, timeout);
  509. }
  510. static inline int musb_platform_get_vbus_status(struct musb *musb)
  511. {
  512. if (!musb->ops->vbus_status)
  513. return 0;
  514. return musb->ops->vbus_status(musb);
  515. }
  516. static inline int musb_platform_init(struct musb *musb)
  517. {
  518. if (!musb->ops->init)
  519. return -EINVAL;
  520. return musb->ops->init(musb);
  521. }
  522. static inline int musb_platform_exit(struct musb *musb)
  523. {
  524. if (!musb->ops->exit)
  525. return -EINVAL;
  526. return musb->ops->exit(musb);
  527. }
  528. /* #if LINUX_VERSION_CODE >= KERNEL_VERSION(3, 10, 0) */
  529. #if 1
  530. static inline const char *otg_state_string(enum usb_otg_state state)
  531. {
  532. return usb_otg_state_string(state);
  533. }
  534. #endif
  535. #endif /* __MUSB_CORE_H__ */