linux/include/linux/usb/renesas_usbhs.h
<<
>>
Prefs
   1// SPDX-License-Identifier: GPL-1.0+
   2/*
   3 * Renesas USB
   4 *
   5 * Copyright (C) 2011 Renesas Solutions Corp.
   6 * Copyright (C) 2019 Renesas Electronics Corporation
   7 * Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
   8 *
   9 * This program is distributed in the hope that it will be useful,
  10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
  11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  12 * GNU General Public License for more details.
  13 *
  14 * You should have received a copy of the GNU General Public License
  15 * along with this program; if not, write to the Free Software
  16 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
  17 *
  18 */
  19#ifndef RENESAS_USB_H
  20#define RENESAS_USB_H
  21#include <linux/notifier.h>
  22#include <linux/platform_device.h>
  23#include <linux/usb/ch9.h>
  24
  25/*
  26 * module type
  27 *
  28 * it will be return value from get_id
  29 */
  30enum {
  31        USBHS_HOST = 0,
  32        USBHS_GADGET,
  33        USBHS_MAX,
  34};
  35
  36/*
  37 * callback functions for platform
  38 *
  39 * These functions are called from driver for platform
  40 */
  41struct renesas_usbhs_platform_callback {
  42
  43        /*
  44         * option:
  45         *
  46         * Hardware init function for platform.
  47         * it is called when driver was probed.
  48         */
  49        int (*hardware_init)(struct platform_device *pdev);
  50
  51        /*
  52         * option:
  53         *
  54         * Hardware exit function for platform.
  55         * it is called when driver was removed
  56         */
  57        int (*hardware_exit)(struct platform_device *pdev);
  58
  59        /*
  60         * option:
  61         *
  62         * for board specific clock control
  63         */
  64        int (*power_ctrl)(struct platform_device *pdev,
  65                           void __iomem *base, int enable);
  66
  67        /*
  68         * option:
  69         *
  70         * Phy reset for platform
  71         */
  72        int (*phy_reset)(struct platform_device *pdev);
  73
  74        /*
  75         * get USB ID function
  76         *  - USBHS_HOST
  77         *  - USBHS_GADGET
  78         */
  79        int (*get_id)(struct platform_device *pdev);
  80
  81        /*
  82         * get VBUS status function.
  83         */
  84        int (*get_vbus)(struct platform_device *pdev);
  85
  86        /*
  87         * option:
  88         *
  89         * VBUS control is needed for Host
  90         */
  91        int (*set_vbus)(struct platform_device *pdev, int enable);
  92
  93        /*
  94         * option:
  95         * extcon notifier to set host/peripheral mode.
  96         */
  97        int (*notifier)(struct notifier_block *nb, unsigned long event,
  98                        void *data);
  99};
 100
 101/*
 102 * parameters for renesas usbhs
 103 *
 104 * some register needs USB chip specific parameters.
 105 * This struct show it to driver
 106 */
 107
 108struct renesas_usbhs_driver_pipe_config {
 109        u8 type;        /* USB_ENDPOINT_XFER_xxx */
 110        u16 bufsize;
 111        u8 bufnum;
 112        bool double_buf;
 113};
 114#define RENESAS_USBHS_PIPE(_type, _size, _num, _double_buf)     {       \
 115                        .type = (_type),                \
 116                        .bufsize = (_size),             \
 117                        .bufnum = (_num),               \
 118                        .double_buf = (_double_buf),    \
 119        }
 120
 121struct renesas_usbhs_driver_param {
 122        /*
 123         * pipe settings
 124         */
 125        struct renesas_usbhs_driver_pipe_config *pipe_configs;
 126        int pipe_size; /* pipe_configs array size */
 127
 128        /*
 129         * option:
 130         *
 131         * for BUSWAIT :: BWAIT
 132         * see
 133         *      renesas_usbhs/common.c :: usbhsc_set_buswait()
 134         * */
 135        int buswait_bwait;
 136
 137        /*
 138         * option:
 139         *
 140         * delay time from notify_hotplug callback
 141         */
 142        int detection_delay; /* msec */
 143
 144        /*
 145         * option:
 146         *
 147         * dma id for dmaengine
 148         * The data transfer direction on D0FIFO/D1FIFO should be
 149         * fixed for keeping consistency.
 150         * So, the platform id settings will be..
 151         *      .d0_tx_id = xx_TX,
 152         *      .d1_rx_id = xx_RX,
 153         * or
 154         *      .d1_tx_id = xx_TX,
 155         *      .d0_rx_id = xx_RX,
 156         */
 157        int d0_tx_id;
 158        int d0_rx_id;
 159        int d1_tx_id;
 160        int d1_rx_id;
 161        int d2_tx_id;
 162        int d2_rx_id;
 163        int d3_tx_id;
 164        int d3_rx_id;
 165
 166        /*
 167         * option:
 168         *
 169         * pio <--> dma border.
 170         */
 171        int pio_dma_border; /* default is 64byte */
 172
 173        /*
 174         * option:
 175         */
 176        u32 has_usb_dmac:1; /* for USB-DMAC */
 177        u32 runtime_pwctrl:1;
 178        u32 has_cnen:1;
 179        u32 cfifo_byte_addr:1; /* CFIFO is byte addressable */
 180#define USBHS_USB_DMAC_XFER_SIZE        32      /* hardcode the xfer size */
 181        u32 multi_clks:1;
 182        u32 has_new_pipe_configs:1;
 183};
 184
 185/*
 186 * option:
 187 *
 188 * platform information for renesas_usbhs driver.
 189 */
 190struct renesas_usbhs_platform_info {
 191        /*
 192         * option:
 193         *
 194         * platform set these functions before
 195         * call platform_add_devices if needed
 196         */
 197        struct renesas_usbhs_platform_callback  platform_callback;
 198
 199        /*
 200         * option:
 201         *
 202         * driver use these param for some register
 203         */
 204        struct renesas_usbhs_driver_param       driver_param;
 205};
 206
 207/*
 208 * macro for platform
 209 */
 210#define renesas_usbhs_get_info(pdev)\
 211        ((struct renesas_usbhs_platform_info *)(pdev)->dev.platform_data)
 212#endif /* RENESAS_USB_H */
 213