Back to home page

OSCL-LXR

 
 

    


0001 /* SPDX-License-Identifier: GPL-2.0 */
0002 /*
0003  * Platform data for the chipidea USB dual role controller
0004  */
0005 
0006 #ifndef __LINUX_USB_CHIPIDEA_H
0007 #define __LINUX_USB_CHIPIDEA_H
0008 
0009 #include <linux/extcon.h>
0010 #include <linux/usb/otg.h>
0011 
0012 struct ci_hdrc;
0013 
0014 /**
0015  * struct ci_hdrc_cable - structure for external connector cable state tracking
0016  * @connected: true if cable is connected, false otherwise
0017  * @changed: set to true when extcon event happen
0018  * @enabled: set to true if we've enabled the vbus or id interrupt
0019  * @edev: device which generate events
0020  * @ci: driver state of the chipidea device
0021  * @nb: hold event notification callback
0022  * @conn: used for notification registration
0023  */
0024 struct ci_hdrc_cable {
0025     bool                connected;
0026     bool                changed;
0027     bool                enabled;
0028     struct extcon_dev       *edev;
0029     struct ci_hdrc          *ci;
0030     struct notifier_block       nb;
0031 };
0032 
0033 struct ci_hdrc_platform_data {
0034     const char  *name;
0035     /* offset of the capability registers */
0036     uintptr_t    capoffset;
0037     unsigned     power_budget;
0038     struct phy  *phy;
0039     /* old usb_phy interface */
0040     struct usb_phy  *usb_phy;
0041     enum usb_phy_interface phy_mode;
0042     unsigned long    flags;
0043 #define CI_HDRC_REGS_SHARED     BIT(0)
0044 #define CI_HDRC_DISABLE_DEVICE_STREAMING    BIT(1)
0045 #define CI_HDRC_SUPPORTS_RUNTIME_PM BIT(2)
0046 #define CI_HDRC_DISABLE_HOST_STREAMING  BIT(3)
0047 #define CI_HDRC_DISABLE_STREAMING (CI_HDRC_DISABLE_DEVICE_STREAMING |   \
0048         CI_HDRC_DISABLE_HOST_STREAMING)
0049     /*
0050      * Only set it when DCCPARAMS.DC==1 and DCCPARAMS.HC==1,
0051      * but otg is not supported (no register otgsc).
0052      */
0053 #define CI_HDRC_DUAL_ROLE_NOT_OTG   BIT(4)
0054 #define CI_HDRC_IMX28_WRITE_FIX     BIT(5)
0055 #define CI_HDRC_FORCE_FULLSPEED     BIT(6)
0056 #define CI_HDRC_TURN_VBUS_EARLY_ON  BIT(7)
0057 #define CI_HDRC_SET_NON_ZERO_TTHA   BIT(8)
0058 #define CI_HDRC_OVERRIDE_AHB_BURST  BIT(9)
0059 #define CI_HDRC_OVERRIDE_TX_BURST   BIT(10)
0060 #define CI_HDRC_OVERRIDE_RX_BURST   BIT(11)
0061 #define CI_HDRC_OVERRIDE_PHY_CONTROL    BIT(12) /* Glue layer manages phy */
0062 #define CI_HDRC_REQUIRES_ALIGNED_DMA    BIT(13)
0063 #define CI_HDRC_IMX_IS_HSIC     BIT(14)
0064 #define CI_HDRC_PMQOS           BIT(15)
0065     enum usb_dr_mode    dr_mode;
0066 #define CI_HDRC_CONTROLLER_RESET_EVENT      0
0067 #define CI_HDRC_CONTROLLER_STOPPED_EVENT    1
0068 #define CI_HDRC_IMX_HSIC_ACTIVE_EVENT       2
0069 #define CI_HDRC_IMX_HSIC_SUSPEND_EVENT      3
0070 #define CI_HDRC_CONTROLLER_VBUS_EVENT       4
0071     int (*notify_event) (struct ci_hdrc *ci, unsigned event);
0072     struct regulator    *reg_vbus;
0073     struct usb_otg_caps ci_otg_caps;
0074     bool            tpl_support;
0075     /* interrupt threshold setting */
0076     u32         itc_setting;
0077     u32         ahb_burst_config;
0078     u32         tx_burst_size;
0079     u32         rx_burst_size;
0080 
0081     /* VBUS and ID signal state tracking, using extcon framework */
0082     struct ci_hdrc_cable        vbus_extcon;
0083     struct ci_hdrc_cable        id_extcon;
0084     u32         phy_clkgate_delay_us;
0085 
0086     /* pins */
0087     struct pinctrl *pctl;
0088     struct pinctrl_state *pins_default;
0089     struct pinctrl_state *pins_host;
0090     struct pinctrl_state *pins_device;
0091 
0092     /* platform-specific hooks */
0093     int (*hub_control)(struct ci_hdrc *ci, u16 typeReq, u16 wValue,
0094                u16 wIndex, char *buf, u16 wLength,
0095                bool *done, unsigned long *flags);
0096     void (*enter_lpm)(struct ci_hdrc *ci, bool enable);
0097 };
0098 
0099 /* Default offset of capability registers */
0100 #define DEF_CAPOFFSET       0x100
0101 
0102 /* Add ci hdrc device */
0103 struct platform_device *ci_hdrc_add_device(struct device *dev,
0104             struct resource *res, int nres,
0105             struct ci_hdrc_platform_data *platdata);
0106 /* Remove ci hdrc device */
0107 void ci_hdrc_remove_device(struct platform_device *pdev);
0108 /* Get current available role */
0109 enum usb_dr_mode ci_hdrc_query_available_role(struct platform_device *pdev);
0110 
0111 #endif