blob: f9be467d669531733b4889311029ac8d251a327e [file] [log] [blame]
Alexander Shishkine443b332012-05-11 17:25:46 +03001/*
2 * Platform data for the chipidea USB dual role controller
3 */
4
5#ifndef __LINUX_USB_CHIPIDEA_H
6#define __LINUX_USB_CHIPIDEA_H
7
Ivan T. Ivanov3ecb3e02015-09-07 14:45:25 +03008#include <linux/extcon.h>
Richard Zhaoa2c3d692012-07-07 22:56:46 +08009#include <linux/usb/otg.h>
10
Alexander Shishkin8e229782013-06-24 14:46:36 +030011struct ci_hdrc;
Ivan T. Ivanov3ecb3e02015-09-07 14:45:25 +030012
13/**
14 * struct ci_hdrc_cable - structure for external connector cable state tracking
15 * @state: current state of the line
16 * @changed: set to true when extcon event happen
Stephen Boydb6c17072016-12-28 14:56:51 -080017 * @enabled: set to true if we've enabled the vbus or id interrupt
Ivan T. Ivanov3ecb3e02015-09-07 14:45:25 +030018 * @edev: device which generate events
19 * @ci: driver state of the chipidea device
20 * @nb: hold event notification callback
21 * @conn: used for notification registration
22 */
23struct ci_hdrc_cable {
24 bool state;
25 bool changed;
Stephen Boydb6c17072016-12-28 14:56:51 -080026 bool enabled;
Ivan T. Ivanov3ecb3e02015-09-07 14:45:25 +030027 struct extcon_dev *edev;
28 struct ci_hdrc *ci;
29 struct notifier_block nb;
30};
31
Alexander Shishkin8e229782013-06-24 14:46:36 +030032struct ci_hdrc_platform_data {
Alexander Shishkine443b332012-05-11 17:25:46 +030033 const char *name;
34 /* offset of the capability registers */
35 uintptr_t capoffset;
Alexander Shishkinbd841982012-05-11 17:25:55 +030036 unsigned power_budget;
Antoine Tenart1e5e2d32014-10-30 18:41:19 +010037 struct phy *phy;
38 /* old usb_phy interface */
Antoine Tenartef44cb42014-10-30 18:41:16 +010039 struct usb_phy *usb_phy;
Michael Grzeschik40dcd0e2013-06-13 17:59:56 +030040 enum usb_phy_interface phy_mode;
Alexander Shishkine443b332012-05-11 17:25:46 +030041 unsigned long flags;
Alexander Shishkin8e229782013-06-24 14:46:36 +030042#define CI_HDRC_REGS_SHARED BIT(0)
Peter Chen8022d3d2014-10-30 09:15:15 +080043#define CI_HDRC_DISABLE_DEVICE_STREAMING BIT(1)
Peter Chen1f874ed2015-02-11 12:44:45 +080044#define CI_HDRC_SUPPORTS_RUNTIME_PM BIT(2)
Peter Chen8022d3d2014-10-30 09:15:15 +080045#define CI_HDRC_DISABLE_HOST_STREAMING BIT(3)
46#define CI_HDRC_DISABLE_STREAMING (CI_HDRC_DISABLE_DEVICE_STREAMING | \
47 CI_HDRC_DISABLE_HOST_STREAMING)
Peter Chen577b2322013-08-14 12:44:08 +030048 /*
49 * Only set it when DCCPARAMS.DC==1 and DCCPARAMS.HC==1,
50 * but otg is not supported (no register otgsc).
51 */
52#define CI_HDRC_DUAL_ROLE_NOT_OTG BIT(4)
Peter Chened8f8312014-01-10 13:51:27 +080053#define CI_HDRC_IMX28_WRITE_FIX BIT(5)
Michael Grzeschik4f6743d2014-02-19 13:41:43 +080054#define CI_HDRC_FORCE_FULLSPEED BIT(6)
Li Jun6adb9b7b2015-02-11 12:45:01 +080055#define CI_HDRC_TURN_VBUS_EARLY_ON BIT(7)
Peter Chen28362672015-06-18 11:51:53 +080056#define CI_HDRC_SET_NON_ZERO_TTHA BIT(8)
Peter Chen65668712015-03-17 14:21:00 +080057#define CI_HDRC_OVERRIDE_AHB_BURST BIT(9)
Peter Chen96625ea2015-03-17 17:32:45 +080058#define CI_HDRC_OVERRIDE_TX_BURST BIT(10)
59#define CI_HDRC_OVERRIDE_RX_BURST BIT(11)
Sascha Hauer691962d2013-06-13 17:59:57 +030060 enum usb_dr_mode dr_mode;
Alexander Shishkin8e229782013-06-24 14:46:36 +030061#define CI_HDRC_CONTROLLER_RESET_EVENT 0
62#define CI_HDRC_CONTROLLER_STOPPED_EVENT 1
63 void (*notify_event) (struct ci_hdrc *ci, unsigned event);
Peter Chen1542d9c2013-08-14 12:44:03 +030064 struct regulator *reg_vbus;
Li Jun79742352015-07-09 15:18:45 +080065 struct usb_otg_caps ci_otg_caps;
Peter Chenf6a9ff02014-08-19 09:51:56 +080066 bool tpl_support;
Peter Chendf96ed82014-09-22 16:45:39 +080067 /* interrupt threshold setting */
68 u32 itc_setting;
Peter Chen65668712015-03-17 14:21:00 +080069 u32 ahb_burst_config;
Peter Chen96625ea2015-03-17 17:32:45 +080070 u32 tx_burst_size;
71 u32 rx_burst_size;
Ivan T. Ivanov3ecb3e02015-09-07 14:45:25 +030072
73 /* VBUS and ID signal state tracking, using extcon framework */
74 struct ci_hdrc_cable vbus_extcon;
75 struct ci_hdrc_cable id_extcon;
Fabio Estevam1fbf4622015-09-08 22:18:14 -030076 u32 phy_clkgate_delay_us;
Alexander Shishkine443b332012-05-11 17:25:46 +030077};
78
79/* Default offset of capability registers */
80#define DEF_CAPOFFSET 0x100
81
Alexander Shishkin8e229782013-06-24 14:46:36 +030082/* Add ci hdrc device */
83struct platform_device *ci_hdrc_add_device(struct device *dev,
Richard Zhaocbc6dc22012-07-07 22:56:41 +080084 struct resource *res, int nres,
Alexander Shishkin8e229782013-06-24 14:46:36 +030085 struct ci_hdrc_platform_data *platdata);
86/* Remove ci hdrc device */
87void ci_hdrc_remove_device(struct platform_device *pdev);
Richard Zhaocbc6dc22012-07-07 22:56:41 +080088
Alexander Shishkine443b332012-05-11 17:25:46 +030089#endif