Back to home page

OSCL-LXR

 
 

    


0001 // SPDX-License-Identifier: GPL-1.0+
0002 /*
0003  * Renesas USB
0004  *
0005  * Copyright (C) 2011 Renesas Solutions Corp.
0006  * Copyright (C) 2019 Renesas Electronics Corporation
0007  * Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
0008  *
0009  * This program is distributed in the hope that it will be useful,
0010  * but WITHOUT ANY WARRANTY; without even the implied warranty of
0011  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
0012  * GNU General Public License for more details.
0013  *
0014  * You should have received a copy of the GNU General Public License
0015  * along with this program; if not, write to the Free Software
0016  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
0017  *
0018  */
0019 #ifndef RENESAS_USB_H
0020 #define RENESAS_USB_H
0021 #include <linux/notifier.h>
0022 #include <linux/platform_device.h>
0023 #include <linux/usb/ch9.h>
0024 
0025 /*
0026  * module type
0027  *
0028  * it will be return value from get_id
0029  */
0030 enum {
0031     USBHS_HOST = 0,
0032     USBHS_GADGET,
0033     USBHS_MAX,
0034 };
0035 
0036 /*
0037  * callback functions for platform
0038  *
0039  * These functions are called from driver for platform
0040  */
0041 struct renesas_usbhs_platform_callback {
0042 
0043     /*
0044      * option:
0045      *
0046      * Hardware init function for platform.
0047      * it is called when driver was probed.
0048      */
0049     int (*hardware_init)(struct platform_device *pdev);
0050 
0051     /*
0052      * option:
0053      *
0054      * Hardware exit function for platform.
0055      * it is called when driver was removed
0056      */
0057     int (*hardware_exit)(struct platform_device *pdev);
0058 
0059     /*
0060      * option:
0061      *
0062      * for board specific clock control
0063      */
0064     int (*power_ctrl)(struct platform_device *pdev,
0065                void __iomem *base, int enable);
0066 
0067     /*
0068      * option:
0069      *
0070      * Phy reset for platform
0071      */
0072     int (*phy_reset)(struct platform_device *pdev);
0073 
0074     /*
0075      * get USB ID function
0076      *  - USBHS_HOST
0077      *  - USBHS_GADGET
0078      */
0079     int (*get_id)(struct platform_device *pdev);
0080 
0081     /*
0082      * get VBUS status function.
0083      */
0084     int (*get_vbus)(struct platform_device *pdev);
0085 
0086     /*
0087      * option:
0088      *
0089      * VBUS control is needed for Host
0090      */
0091     int (*set_vbus)(struct platform_device *pdev, int enable);
0092 
0093     /*
0094      * option:
0095      * extcon notifier to set host/peripheral mode.
0096      */
0097     int (*notifier)(struct notifier_block *nb, unsigned long event,
0098             void *data);
0099 };
0100 
0101 /*
0102  * parameters for renesas usbhs
0103  *
0104  * some register needs USB chip specific parameters.
0105  * This struct show it to driver
0106  */
0107 
0108 struct renesas_usbhs_driver_pipe_config {
0109     u8 type;    /* USB_ENDPOINT_XFER_xxx */
0110     u16 bufsize;
0111     u8 bufnum;
0112     bool double_buf;
0113 };
0114 #define RENESAS_USBHS_PIPE(_type, _size, _num, _double_buf) {   \
0115             .type = (_type),        \
0116             .bufsize = (_size),     \
0117             .bufnum = (_num),       \
0118             .double_buf = (_double_buf),    \
0119     }
0120 
0121 struct renesas_usbhs_driver_param {
0122     /*
0123      * pipe settings
0124      */
0125     struct renesas_usbhs_driver_pipe_config *pipe_configs;
0126     int pipe_size; /* pipe_configs array size */
0127 
0128     /*
0129      * option:
0130      *
0131      * for BUSWAIT :: BWAIT
0132      * see
0133      *  renesas_usbhs/common.c :: usbhsc_set_buswait()
0134      * */
0135     int buswait_bwait;
0136 
0137     /*
0138      * option:
0139      *
0140      * delay time from notify_hotplug callback
0141      */
0142     int detection_delay; /* msec */
0143 
0144     /*
0145      * option:
0146      *
0147      * dma id for dmaengine
0148      * The data transfer direction on D0FIFO/D1FIFO should be
0149      * fixed for keeping consistency.
0150      * So, the platform id settings will be..
0151      *  .d0_tx_id = xx_TX,
0152      *  .d1_rx_id = xx_RX,
0153      * or
0154      *  .d1_tx_id = xx_TX,
0155      *  .d0_rx_id = xx_RX,
0156      */
0157     int d0_tx_id;
0158     int d0_rx_id;
0159     int d1_tx_id;
0160     int d1_rx_id;
0161     int d2_tx_id;
0162     int d2_rx_id;
0163     int d3_tx_id;
0164     int d3_rx_id;
0165 
0166     /*
0167      * option:
0168      *
0169      * pio <--> dma border.
0170      */
0171     int pio_dma_border; /* default is 64byte */
0172 
0173     /*
0174      * option:
0175      */
0176     u32 has_usb_dmac:1; /* for USB-DMAC */
0177     u32 runtime_pwctrl:1;
0178     u32 has_cnen:1;
0179     u32 cfifo_byte_addr:1; /* CFIFO is byte addressable */
0180 #define USBHS_USB_DMAC_XFER_SIZE    32  /* hardcode the xfer size */
0181     u32 multi_clks:1;
0182     u32 has_new_pipe_configs:1;
0183 };
0184 
0185 /*
0186  * option:
0187  *
0188  * platform information for renesas_usbhs driver.
0189  */
0190 struct renesas_usbhs_platform_info {
0191     /*
0192      * option:
0193      *
0194      * platform set these functions before
0195      * call platform_add_devices if needed
0196      */
0197     struct renesas_usbhs_platform_callback  platform_callback;
0198 
0199     /*
0200      * option:
0201      *
0202      * driver use these param for some register
0203      */
0204     struct renesas_usbhs_driver_param   driver_param;
0205 };
0206 
0207 /*
0208  * macro for platform
0209  */
0210 #define renesas_usbhs_get_info(pdev)\
0211     ((struct renesas_usbhs_platform_info *)(pdev)->dev.platform_data)
0212 #endif /* RENESAS_USB_H */