1 // SPDX-License-Identifier: GPL-1.0+
5 * Copyright (C) 2011 Renesas Solutions Corp.
6 * Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
13 * You should have received a copy of the GNU General Public License
14 * along with this program; if not, write to the Free Software
15 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
20 #include <linux/notifier.h>
21 #include <linux/platform_device.h>
22 #include <linux/usb/ch9.h>
27 * it will be return value from get_id
36 * callback functions table for driver
38 * These functions are called from platform for driver.
39 * Callback function's pointer will be set before
40 * renesas_usbhs_platform_callback :: hardware_init was called
42 struct renesas_usbhs_driver_callback
{
43 int (*notify_hotplug
)(struct platform_device
*pdev
);
47 * callback functions for platform
49 * These functions are called from driver for platform
51 struct renesas_usbhs_platform_callback
{
56 * Hardware init function for platform.
57 * it is called when driver was probed.
59 int (*hardware_init
)(struct platform_device
*pdev
);
64 * Hardware exit function for platform.
65 * it is called when driver was removed
67 int (*hardware_exit
)(struct platform_device
*pdev
);
72 * for board specific clock control
74 int (*power_ctrl
)(struct platform_device
*pdev
,
75 void __iomem
*base
, int enable
);
80 * Phy reset for platform
82 int (*phy_reset
)(struct platform_device
*pdev
);
89 int (*get_id
)(struct platform_device
*pdev
);
92 * get VBUS status function.
94 int (*get_vbus
)(struct platform_device
*pdev
);
99 * VBUS control is needed for Host
101 int (*set_vbus
)(struct platform_device
*pdev
, int enable
);
105 * extcon notifier to set host/peripheral mode.
107 int (*notifier
)(struct notifier_block
*nb
, unsigned long event
,
112 * parameters for renesas usbhs
114 * some register needs USB chip specific parameters.
115 * This struct show it to driver
118 struct renesas_usbhs_driver_pipe_config
{
119 u8 type
; /* USB_ENDPOINT_XFER_xxx */
124 #define RENESAS_USBHS_PIPE(_type, _size, _num, _double_buf) { \
126 .bufsize = (_size), \
128 .double_buf = (_double_buf), \
131 struct renesas_usbhs_driver_param
{
135 struct renesas_usbhs_driver_pipe_config
*pipe_configs
;
136 int pipe_size
; /* pipe_configs array size */
141 * for BUSWAIT :: BWAIT
143 * renesas_usbhs/common.c :: usbhsc_set_buswait()
150 * delay time from notify_hotplug callback
152 int detection_delay
; /* msec */
157 * dma id for dmaengine
158 * The data transfer direction on D0FIFO/D1FIFO should be
159 * fixed for keeping consistency.
160 * So, the platform id settings will be..
179 * pio <--> dma border.
181 int pio_dma_border
; /* default is 64byte */
189 u32 has_otg
:1; /* for controlling PWEN/EXTLP */
190 u32 has_sudmac
:1; /* for SUDMAC */
191 u32 has_usb_dmac
:1; /* for USB-DMAC */
192 #define USBHS_USB_DMAC_XFER_SIZE 32 /* hardcode the xfer size */
195 #define USBHS_TYPE_RCAR_GEN2 1
196 #define USBHS_TYPE_RCAR_GEN3 2
197 #define USBHS_TYPE_RCAR_GEN3_WITH_PLL 3
198 #define USBHS_TYPE_RZA1 4
203 * platform information for renesas_usbhs driver.
205 struct renesas_usbhs_platform_info
{
209 * platform set these functions before
210 * call platform_add_devices if needed
212 struct renesas_usbhs_platform_callback platform_callback
;
215 * driver set these callback functions pointer.
216 * platform can use it on callback functions
218 struct renesas_usbhs_driver_callback driver_callback
;
223 * driver use these param for some register
225 struct renesas_usbhs_driver_param driver_param
;
231 #define renesas_usbhs_get_info(pdev)\
232 ((struct renesas_usbhs_platform_info *)(pdev)->dev.platform_data)
234 #define renesas_usbhs_call_notify_hotplug(pdev) \
236 struct renesas_usbhs_driver_callback *dc; \
237 dc = &(renesas_usbhs_get_info(pdev)->driver_callback); \
238 if (dc && dc->notify_hotplug) \
239 dc->notify_hotplug(pdev); \
241 #endif /* RENESAS_USB_H */