Back to home page

OSCL-LXR

 
 

    


0001 /* SPDX-License-Identifier: GPL-2.0 */
0002 /*
0003  * This is used to for host and peripheral modes of the driver for
0004  * Inventra (Multidrop) Highspeed Dual-Role Controllers:  (M)HDRC.
0005  *
0006  * Board initialization should put one of these into dev->platform_data,
0007  * probably on some platform_device named "musb-hdrc".  It encapsulates
0008  * key configuration differences between boards.
0009  */
0010 
0011 #ifndef __LINUX_USB_MUSB_H
0012 #define __LINUX_USB_MUSB_H
0013 
0014 /* The USB role is defined by the connector used on the board, so long as
0015  * standards are being followed.  (Developer boards sometimes won't.)
0016  */
0017 enum musb_mode {
0018     MUSB_UNDEFINED = 0,
0019     MUSB_HOST,      /* A or Mini-A connector */
0020     MUSB_PERIPHERAL,    /* B or Mini-B connector */
0021     MUSB_OTG        /* Mini-AB connector */
0022 };
0023 
0024 struct clk;
0025 
0026 enum musb_fifo_style {
0027     FIFO_RXTX,
0028     FIFO_TX,
0029     FIFO_RX
0030 } __attribute__ ((packed));
0031 
0032 enum musb_buf_mode {
0033     BUF_SINGLE,
0034     BUF_DOUBLE
0035 } __attribute__ ((packed));
0036 
0037 struct musb_fifo_cfg {
0038     u8          hw_ep_num;
0039     enum musb_fifo_style    style;
0040     enum musb_buf_mode  mode;
0041     u16         maxpacket;
0042 };
0043 
0044 #define MUSB_EP_FIFO(ep, st, m, pkt)        \
0045 {                       \
0046     .hw_ep_num  = ep,           \
0047     .style      = st,           \
0048     .mode       = m,            \
0049     .maxpacket  = pkt,          \
0050 }
0051 
0052 #define MUSB_EP_FIFO_SINGLE(ep, st, pkt)    \
0053     MUSB_EP_FIFO(ep, st, BUF_SINGLE, pkt)
0054 
0055 #define MUSB_EP_FIFO_DOUBLE(ep, st, pkt)    \
0056     MUSB_EP_FIFO(ep, st, BUF_DOUBLE, pkt)
0057 
0058 struct musb_hdrc_eps_bits {
0059     const char  name[16];
0060     u8      bits;
0061 };
0062 
0063 struct musb_hdrc_config {
0064     struct musb_fifo_cfg    *fifo_cfg;  /* board fifo configuration */
0065     unsigned        fifo_cfg_size;  /* size of the fifo configuration */
0066 
0067     /* MUSB configuration-specific details */
0068     unsigned    multipoint:1;   /* multipoint device */
0069     unsigned    dyn_fifo:1 __deprecated; /* supports dynamic fifo sizing */
0070 
0071     /* need to explicitly de-assert the port reset after resume? */
0072     unsigned    host_port_deassert_reset_at_resume:1;
0073 
0074     u8      num_eps;    /* number of endpoints _with_ ep0 */
0075     u8      ram_bits;   /* ram address size */
0076 
0077     u32     maximum_speed;
0078 };
0079 
0080 struct musb_hdrc_platform_data {
0081     /* MUSB_HOST, MUSB_PERIPHERAL, or MUSB_OTG */
0082     u8      mode;
0083 
0084     /* for clk_get() */
0085     const char  *clock;
0086 
0087     /* (HOST or OTG) switch VBUS on/off */
0088     int     (*set_vbus)(struct device *dev, int is_on);
0089 
0090     /* (HOST or OTG) mA/2 power supplied on (default = 8mA) */
0091     u8      power;
0092 
0093     /* (PERIPHERAL) mA/2 max power consumed (default = 100mA) */
0094     u8      min_power;
0095 
0096     /* (HOST or OTG) msec/2 after VBUS on till power good */
0097     u8      potpgt;
0098 
0099     /* (HOST or OTG) program PHY for external Vbus */
0100     unsigned    extvbus:1;
0101 
0102     /* Power the device on or off */
0103     int     (*set_power)(int state);
0104 
0105     /* MUSB configuration-specific details */
0106     const struct musb_hdrc_config *config;
0107 
0108     /* Architecture specific board data */
0109     void        *board_data;
0110 
0111     /* Platform specific struct musb_ops pointer */
0112     const void  *platform_ops;
0113 };
0114 
0115 enum musb_vbus_id_status {
0116     MUSB_UNKNOWN = 0,
0117     MUSB_ID_GROUND,
0118     MUSB_ID_FLOAT,
0119     MUSB_VBUS_VALID,
0120     MUSB_VBUS_OFF,
0121 };
0122 
0123 #if IS_ENABLED(CONFIG_USB_MUSB_HDRC)
0124 int musb_mailbox(enum musb_vbus_id_status status);
0125 #else
0126 static inline int musb_mailbox(enum musb_vbus_id_status status)
0127 {
0128     return 0;
0129 }
0130 #endif
0131 
0132 /* TUSB 6010 support */
0133 
0134 #define TUSB6010_OSCCLK_60  16667   /* psec/clk @ 60.0 MHz */
0135 #define TUSB6010_REFCLK_24  41667   /* psec/clk @ 24.0 MHz XI */
0136 #define TUSB6010_REFCLK_19  52083   /* psec/clk @ 19.2 MHz CLKIN */
0137 
0138 #ifdef  CONFIG_ARCH_OMAP2
0139 
0140 extern int __init tusb6010_setup_interface(
0141         struct musb_hdrc_platform_data *data,
0142         unsigned ps_refclk, unsigned waitpin,
0143         unsigned async_cs, unsigned sync_cs,
0144         unsigned irq, unsigned dmachan);
0145 
0146 extern int tusb6010_platform_retime(unsigned is_refclk);
0147 
0148 #endif  /* OMAP2 */
0149 
0150 #endif /* __LINUX_USB_MUSB_H */