Greg Kroah-Hartman | b244131 | 2017-11-01 15:07:57 +0100 | [diff] [blame] | 1 | /* SPDX-License-Identifier: GPL-2.0 */ |
Alexander Shishkin | e443b33 | 2012-05-11 17:25:46 +0300 | [diff] [blame] | 2 | /* |
| 3 | * Platform data for the chipidea USB dual role controller |
| 4 | */ |
| 5 | |
| 6 | #ifndef __LINUX_USB_CHIPIDEA_H |
| 7 | #define __LINUX_USB_CHIPIDEA_H |
| 8 | |
Ivan T. Ivanov | 3ecb3e0 | 2015-09-07 14:45:25 +0300 | [diff] [blame] | 9 | #include <linux/extcon.h> |
Richard Zhao | a2c3d69 | 2012-07-07 22:56:46 +0800 | [diff] [blame] | 10 | #include <linux/usb/otg.h> |
| 11 | |
Alexander Shishkin | 8e22978 | 2013-06-24 14:46:36 +0300 | [diff] [blame] | 12 | struct ci_hdrc; |
Ivan T. Ivanov | 3ecb3e0 | 2015-09-07 14:45:25 +0300 | [diff] [blame] | 13 | |
| 14 | /** |
| 15 | * struct ci_hdrc_cable - structure for external connector cable state tracking |
Stephen Boyd | 5cc4926 | 2017-01-20 15:11:55 +0800 | [diff] [blame] | 16 | * @connected: true if cable is connected, false otherwise |
Ivan T. Ivanov | 3ecb3e0 | 2015-09-07 14:45:25 +0300 | [diff] [blame] | 17 | * @changed: set to true when extcon event happen |
Stephen Boyd | a89b94b | 2016-12-28 14:56:51 -0800 | [diff] [blame] | 18 | * @enabled: set to true if we've enabled the vbus or id interrupt |
Ivan T. Ivanov | 3ecb3e0 | 2015-09-07 14:45:25 +0300 | [diff] [blame] | 19 | * @edev: device which generate events |
| 20 | * @ci: driver state of the chipidea device |
| 21 | * @nb: hold event notification callback |
| 22 | * @conn: used for notification registration |
| 23 | */ |
| 24 | struct ci_hdrc_cable { |
Stephen Boyd | 5cc4926 | 2017-01-20 15:11:55 +0800 | [diff] [blame] | 25 | bool connected; |
Ivan T. Ivanov | 3ecb3e0 | 2015-09-07 14:45:25 +0300 | [diff] [blame] | 26 | bool changed; |
Stephen Boyd | a89b94b | 2016-12-28 14:56:51 -0800 | [diff] [blame] | 27 | bool enabled; |
Ivan T. Ivanov | 3ecb3e0 | 2015-09-07 14:45:25 +0300 | [diff] [blame] | 28 | struct extcon_dev *edev; |
| 29 | struct ci_hdrc *ci; |
| 30 | struct notifier_block nb; |
| 31 | }; |
| 32 | |
Alexander Shishkin | 8e22978 | 2013-06-24 14:46:36 +0300 | [diff] [blame] | 33 | struct ci_hdrc_platform_data { |
Alexander Shishkin | e443b33 | 2012-05-11 17:25:46 +0300 | [diff] [blame] | 34 | const char *name; |
| 35 | /* offset of the capability registers */ |
| 36 | uintptr_t capoffset; |
Alexander Shishkin | bd84198 | 2012-05-11 17:25:55 +0300 | [diff] [blame] | 37 | unsigned power_budget; |
Antoine Tenart | 1e5e2d3 | 2014-10-30 18:41:19 +0100 | [diff] [blame] | 38 | struct phy *phy; |
| 39 | /* old usb_phy interface */ |
Antoine Tenart | ef44cb4 | 2014-10-30 18:41:16 +0100 | [diff] [blame] | 40 | struct usb_phy *usb_phy; |
Michael Grzeschik | 40dcd0e | 2013-06-13 17:59:56 +0300 | [diff] [blame] | 41 | enum usb_phy_interface phy_mode; |
Alexander Shishkin | e443b33 | 2012-05-11 17:25:46 +0300 | [diff] [blame] | 42 | unsigned long flags; |
Alexander Shishkin | 8e22978 | 2013-06-24 14:46:36 +0300 | [diff] [blame] | 43 | #define CI_HDRC_REGS_SHARED BIT(0) |
Peter Chen | 8022d3d | 2014-10-30 09:15:15 +0800 | [diff] [blame] | 44 | #define CI_HDRC_DISABLE_DEVICE_STREAMING BIT(1) |
Peter Chen | 1f874ed | 2015-02-11 12:44:45 +0800 | [diff] [blame] | 45 | #define CI_HDRC_SUPPORTS_RUNTIME_PM BIT(2) |
Peter Chen | 8022d3d | 2014-10-30 09:15:15 +0800 | [diff] [blame] | 46 | #define CI_HDRC_DISABLE_HOST_STREAMING BIT(3) |
| 47 | #define CI_HDRC_DISABLE_STREAMING (CI_HDRC_DISABLE_DEVICE_STREAMING | \ |
| 48 | CI_HDRC_DISABLE_HOST_STREAMING) |
Peter Chen | 577b232 | 2013-08-14 12:44:08 +0300 | [diff] [blame] | 49 | /* |
| 50 | * Only set it when DCCPARAMS.DC==1 and DCCPARAMS.HC==1, |
| 51 | * but otg is not supported (no register otgsc). |
| 52 | */ |
| 53 | #define CI_HDRC_DUAL_ROLE_NOT_OTG BIT(4) |
Peter Chen | ed8f831 | 2014-01-10 13:51:27 +0800 | [diff] [blame] | 54 | #define CI_HDRC_IMX28_WRITE_FIX BIT(5) |
Michael Grzeschik | 4f6743d | 2014-02-19 13:41:43 +0800 | [diff] [blame] | 55 | #define CI_HDRC_FORCE_FULLSPEED BIT(6) |
Li Jun | 6adb9b7b | 2015-02-11 12:45:01 +0800 | [diff] [blame] | 56 | #define CI_HDRC_TURN_VBUS_EARLY_ON BIT(7) |
Peter Chen | 2836267 | 2015-06-18 11:51:53 +0800 | [diff] [blame] | 57 | #define CI_HDRC_SET_NON_ZERO_TTHA BIT(8) |
Peter Chen | 6566871 | 2015-03-17 14:21:00 +0800 | [diff] [blame] | 58 | #define CI_HDRC_OVERRIDE_AHB_BURST BIT(9) |
Peter Chen | 96625ea | 2015-03-17 17:32:45 +0800 | [diff] [blame] | 59 | #define CI_HDRC_OVERRIDE_TX_BURST BIT(10) |
| 60 | #define CI_HDRC_OVERRIDE_RX_BURST BIT(11) |
Stephen Boyd | 8feb368 | 2016-12-28 14:56:52 -0800 | [diff] [blame] | 61 | #define CI_HDRC_OVERRIDE_PHY_CONTROL BIT(12) /* Glue layer manages phy */ |
Dmitry Osipenko | 581821a | 2017-08-16 13:32:39 +0300 | [diff] [blame] | 62 | #define CI_HDRC_REQUIRES_ALIGNED_DMA BIT(13) |
Sascha Hauer | 691962d | 2013-06-13 17:59:57 +0300 | [diff] [blame] | 63 | enum usb_dr_mode dr_mode; |
Alexander Shishkin | 8e22978 | 2013-06-24 14:46:36 +0300 | [diff] [blame] | 64 | #define CI_HDRC_CONTROLLER_RESET_EVENT 0 |
| 65 | #define CI_HDRC_CONTROLLER_STOPPED_EVENT 1 |
Stephen Boyd | 11893da | 2016-12-28 14:57:06 -0800 | [diff] [blame] | 66 | int (*notify_event) (struct ci_hdrc *ci, unsigned event); |
Peter Chen | 1542d9c | 2013-08-14 12:44:03 +0300 | [diff] [blame] | 67 | struct regulator *reg_vbus; |
Li Jun | 7974235 | 2015-07-09 15:18:45 +0800 | [diff] [blame] | 68 | struct usb_otg_caps ci_otg_caps; |
Peter Chen | f6a9ff0 | 2014-08-19 09:51:56 +0800 | [diff] [blame] | 69 | bool tpl_support; |
Peter Chen | df96ed8 | 2014-09-22 16:45:39 +0800 | [diff] [blame] | 70 | /* interrupt threshold setting */ |
| 71 | u32 itc_setting; |
Peter Chen | 6566871 | 2015-03-17 14:21:00 +0800 | [diff] [blame] | 72 | u32 ahb_burst_config; |
Peter Chen | 96625ea | 2015-03-17 17:32:45 +0800 | [diff] [blame] | 73 | u32 tx_burst_size; |
| 74 | u32 rx_burst_size; |
Ivan T. Ivanov | 3ecb3e0 | 2015-09-07 14:45:25 +0300 | [diff] [blame] | 75 | |
| 76 | /* VBUS and ID signal state tracking, using extcon framework */ |
| 77 | struct ci_hdrc_cable vbus_extcon; |
| 78 | struct ci_hdrc_cable id_extcon; |
Fabio Estevam | 1fbf462 | 2015-09-08 22:18:14 -0300 | [diff] [blame] | 79 | u32 phy_clkgate_delay_us; |
Alexander Shishkin | e443b33 | 2012-05-11 17:25:46 +0300 | [diff] [blame] | 80 | }; |
| 81 | |
| 82 | /* Default offset of capability registers */ |
| 83 | #define DEF_CAPOFFSET 0x100 |
| 84 | |
Alexander Shishkin | 8e22978 | 2013-06-24 14:46:36 +0300 | [diff] [blame] | 85 | /* Add ci hdrc device */ |
| 86 | struct platform_device *ci_hdrc_add_device(struct device *dev, |
Richard Zhao | cbc6dc2 | 2012-07-07 22:56:41 +0800 | [diff] [blame] | 87 | struct resource *res, int nres, |
Alexander Shishkin | 8e22978 | 2013-06-24 14:46:36 +0300 | [diff] [blame] | 88 | struct ci_hdrc_platform_data *platdata); |
| 89 | /* Remove ci hdrc device */ |
| 90 | void ci_hdrc_remove_device(struct platform_device *pdev); |
Richard Zhao | cbc6dc2 | 2012-07-07 22:56:41 +0800 | [diff] [blame] | 91 | |
Alexander Shishkin | e443b33 | 2012-05-11 17:25:46 +0300 | [diff] [blame] | 92 | #endif |