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