18c2ecf20Sopenharmony_ci/* SPDX-License-Identifier: GPL-1.0+ */
28c2ecf20Sopenharmony_ci/*
38c2ecf20Sopenharmony_ci * Renesas USB driver
48c2ecf20Sopenharmony_ci *
58c2ecf20Sopenharmony_ci * Copyright (C) 2011 Renesas Solutions Corp.
68c2ecf20Sopenharmony_ci * Copyright (C) 2019 Renesas Electronics Corporation
78c2ecf20Sopenharmony_ci * Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
88c2ecf20Sopenharmony_ci */
98c2ecf20Sopenharmony_ci#ifndef RENESAS_USB_DRIVER_H
108c2ecf20Sopenharmony_ci#define RENESAS_USB_DRIVER_H
118c2ecf20Sopenharmony_ci
128c2ecf20Sopenharmony_ci#include <linux/clk.h>
138c2ecf20Sopenharmony_ci#include <linux/extcon.h>
148c2ecf20Sopenharmony_ci#include <linux/platform_device.h>
158c2ecf20Sopenharmony_ci#include <linux/reset.h>
168c2ecf20Sopenharmony_ci#include <linux/usb/renesas_usbhs.h>
178c2ecf20Sopenharmony_ci
188c2ecf20Sopenharmony_cistruct usbhs_priv;
198c2ecf20Sopenharmony_ci
208c2ecf20Sopenharmony_ci#include "mod.h"
218c2ecf20Sopenharmony_ci#include "pipe.h"
228c2ecf20Sopenharmony_ci
238c2ecf20Sopenharmony_ci/*
248c2ecf20Sopenharmony_ci *
258c2ecf20Sopenharmony_ci *		register define
268c2ecf20Sopenharmony_ci *
278c2ecf20Sopenharmony_ci */
288c2ecf20Sopenharmony_ci#define SYSCFG		0x0000
298c2ecf20Sopenharmony_ci#define BUSWAIT		0x0002
308c2ecf20Sopenharmony_ci#define DVSTCTR		0x0008
318c2ecf20Sopenharmony_ci#define TESTMODE	0x000C
328c2ecf20Sopenharmony_ci#define CFIFO		0x0014
338c2ecf20Sopenharmony_ci#define CFIFOSEL	0x0020
348c2ecf20Sopenharmony_ci#define CFIFOCTR	0x0022
358c2ecf20Sopenharmony_ci#define D0FIFO		0x0100
368c2ecf20Sopenharmony_ci#define D0FIFOSEL	0x0028
378c2ecf20Sopenharmony_ci#define D0FIFOCTR	0x002A
388c2ecf20Sopenharmony_ci#define D1FIFO		0x0120
398c2ecf20Sopenharmony_ci#define D1FIFOSEL	0x002C
408c2ecf20Sopenharmony_ci#define D1FIFOCTR	0x002E
418c2ecf20Sopenharmony_ci#define INTENB0		0x0030
428c2ecf20Sopenharmony_ci#define INTENB1		0x0032
438c2ecf20Sopenharmony_ci#define BRDYENB		0x0036
448c2ecf20Sopenharmony_ci#define NRDYENB		0x0038
458c2ecf20Sopenharmony_ci#define BEMPENB		0x003A
468c2ecf20Sopenharmony_ci#define INTSTS0		0x0040
478c2ecf20Sopenharmony_ci#define INTSTS1		0x0042
488c2ecf20Sopenharmony_ci#define BRDYSTS		0x0046
498c2ecf20Sopenharmony_ci#define NRDYSTS		0x0048
508c2ecf20Sopenharmony_ci#define BEMPSTS		0x004A
518c2ecf20Sopenharmony_ci#define FRMNUM		0x004C
528c2ecf20Sopenharmony_ci#define USBREQ		0x0054	/* USB request type register */
538c2ecf20Sopenharmony_ci#define USBVAL		0x0056	/* USB request value register */
548c2ecf20Sopenharmony_ci#define USBINDX		0x0058	/* USB request index register */
558c2ecf20Sopenharmony_ci#define USBLENG		0x005A	/* USB request length register */
568c2ecf20Sopenharmony_ci#define DCPCFG		0x005C
578c2ecf20Sopenharmony_ci#define DCPMAXP		0x005E
588c2ecf20Sopenharmony_ci#define DCPCTR		0x0060
598c2ecf20Sopenharmony_ci#define PIPESEL		0x0064
608c2ecf20Sopenharmony_ci#define PIPECFG		0x0068
618c2ecf20Sopenharmony_ci#define PIPEBUF		0x006A
628c2ecf20Sopenharmony_ci#define PIPEMAXP	0x006C
638c2ecf20Sopenharmony_ci#define PIPEPERI	0x006E
648c2ecf20Sopenharmony_ci#define PIPEnCTR	0x0070
658c2ecf20Sopenharmony_ci#define PIPE1TRE	0x0090
668c2ecf20Sopenharmony_ci#define PIPE1TRN	0x0092
678c2ecf20Sopenharmony_ci#define PIPE2TRE	0x0094
688c2ecf20Sopenharmony_ci#define PIPE2TRN	0x0096
698c2ecf20Sopenharmony_ci#define PIPE3TRE	0x0098
708c2ecf20Sopenharmony_ci#define PIPE3TRN	0x009A
718c2ecf20Sopenharmony_ci#define PIPE4TRE	0x009C
728c2ecf20Sopenharmony_ci#define PIPE4TRN	0x009E
738c2ecf20Sopenharmony_ci#define PIPE5TRE	0x00A0
748c2ecf20Sopenharmony_ci#define PIPE5TRN	0x00A2
758c2ecf20Sopenharmony_ci#define PIPEBTRE	0x00A4
768c2ecf20Sopenharmony_ci#define PIPEBTRN	0x00A6
778c2ecf20Sopenharmony_ci#define PIPECTRE	0x00A8
788c2ecf20Sopenharmony_ci#define PIPECTRN	0x00AA
798c2ecf20Sopenharmony_ci#define PIPEDTRE	0x00AC
808c2ecf20Sopenharmony_ci#define PIPEDTRN	0x00AE
818c2ecf20Sopenharmony_ci#define PIPEETRE	0x00B0
828c2ecf20Sopenharmony_ci#define PIPEETRN	0x00B2
838c2ecf20Sopenharmony_ci#define PIPEFTRE	0x00B4
848c2ecf20Sopenharmony_ci#define PIPEFTRN	0x00B6
858c2ecf20Sopenharmony_ci#define PIPE9TRE	0x00B8
868c2ecf20Sopenharmony_ci#define PIPE9TRN	0x00BA
878c2ecf20Sopenharmony_ci#define PIPEATRE	0x00BC
888c2ecf20Sopenharmony_ci#define PIPEATRN	0x00BE
898c2ecf20Sopenharmony_ci#define DEVADD0		0x00D0 /* Device address n configuration */
908c2ecf20Sopenharmony_ci#define DEVADD1		0x00D2
918c2ecf20Sopenharmony_ci#define DEVADD2		0x00D4
928c2ecf20Sopenharmony_ci#define DEVADD3		0x00D6
938c2ecf20Sopenharmony_ci#define DEVADD4		0x00D8
948c2ecf20Sopenharmony_ci#define DEVADD5		0x00DA
958c2ecf20Sopenharmony_ci#define DEVADD6		0x00DC
968c2ecf20Sopenharmony_ci#define DEVADD7		0x00DE
978c2ecf20Sopenharmony_ci#define DEVADD8		0x00E0
988c2ecf20Sopenharmony_ci#define DEVADD9		0x00E2
998c2ecf20Sopenharmony_ci#define DEVADDA		0x00E4
1008c2ecf20Sopenharmony_ci#define D2FIFOSEL	0x00F0	/* for R-Car Gen2 */
1018c2ecf20Sopenharmony_ci#define D2FIFOCTR	0x00F2	/* for R-Car Gen2 */
1028c2ecf20Sopenharmony_ci#define D3FIFOSEL	0x00F4	/* for R-Car Gen2 */
1038c2ecf20Sopenharmony_ci#define D3FIFOCTR	0x00F6	/* for R-Car Gen2 */
1048c2ecf20Sopenharmony_ci#define SUSPMODE	0x0102	/* for RZ/A */
1058c2ecf20Sopenharmony_ci
1068c2ecf20Sopenharmony_ci/* SYSCFG */
1078c2ecf20Sopenharmony_ci#define SCKE	(1 << 10)	/* USB Module Clock Enable */
1088c2ecf20Sopenharmony_ci#define CNEN	(1 << 8)	/* Single-ended receiver operation Enable */
1098c2ecf20Sopenharmony_ci#define HSE	(1 << 7)	/* High-Speed Operation Enable */
1108c2ecf20Sopenharmony_ci#define DCFM	(1 << 6)	/* Controller Function Select */
1118c2ecf20Sopenharmony_ci#define DRPD	(1 << 5)	/* D+ Line/D- Line Resistance Control */
1128c2ecf20Sopenharmony_ci#define DPRPU	(1 << 4)	/* D+ Line Resistance Control */
1138c2ecf20Sopenharmony_ci#define USBE	(1 << 0)	/* USB Module Operation Enable */
1148c2ecf20Sopenharmony_ci#define UCKSEL	(1 << 2)	/* Clock Select for RZ/A1 */
1158c2ecf20Sopenharmony_ci#define UPLLE	(1 << 1)	/* USB PLL Enable for RZ/A1 */
1168c2ecf20Sopenharmony_ci
1178c2ecf20Sopenharmony_ci/* DVSTCTR */
1188c2ecf20Sopenharmony_ci#define EXTLP	(1 << 10)	/* Controls the EXTLP pin output state */
1198c2ecf20Sopenharmony_ci#define PWEN	(1 << 9)	/* Controls the PWEN pin output state */
1208c2ecf20Sopenharmony_ci#define USBRST	(1 << 6)	/* Bus Reset Output */
1218c2ecf20Sopenharmony_ci#define UACT	(1 << 4)	/* USB Bus Enable */
1228c2ecf20Sopenharmony_ci#define RHST	(0x7)		/* Reset Handshake */
1238c2ecf20Sopenharmony_ci#define  RHST_LOW_SPEED  1	/* Low-speed connection */
1248c2ecf20Sopenharmony_ci#define  RHST_FULL_SPEED 2	/* Full-speed connection */
1258c2ecf20Sopenharmony_ci#define  RHST_HIGH_SPEED 3	/* High-speed connection */
1268c2ecf20Sopenharmony_ci
1278c2ecf20Sopenharmony_ci/* CFIFOSEL */
1288c2ecf20Sopenharmony_ci#define DREQE	(1 << 12)	/* DMA Transfer Request Enable */
1298c2ecf20Sopenharmony_ci#define MBW_32	(0x2 << 10)	/* CFIFO Port Access Bit Width */
1308c2ecf20Sopenharmony_ci
1318c2ecf20Sopenharmony_ci/* CFIFOCTR */
1328c2ecf20Sopenharmony_ci#define BVAL	(1 << 15)	/* Buffer Memory Enable Flag */
1338c2ecf20Sopenharmony_ci#define BCLR	(1 << 14)	/* CPU buffer clear */
1348c2ecf20Sopenharmony_ci#define FRDY	(1 << 13)	/* FIFO Port Ready */
1358c2ecf20Sopenharmony_ci#define DTLN_MASK (0x0FFF)	/* Receive Data Length */
1368c2ecf20Sopenharmony_ci
1378c2ecf20Sopenharmony_ci/* INTENB0 */
1388c2ecf20Sopenharmony_ci#define VBSE	(1 << 15)	/* Enable IRQ VBUS_0 and VBUSIN_0 */
1398c2ecf20Sopenharmony_ci#define RSME	(1 << 14)	/* Enable IRQ Resume */
1408c2ecf20Sopenharmony_ci#define SOFE	(1 << 13)	/* Enable IRQ Frame Number Update */
1418c2ecf20Sopenharmony_ci#define DVSE	(1 << 12)	/* Enable IRQ Device State Transition */
1428c2ecf20Sopenharmony_ci#define CTRE	(1 << 11)	/* Enable IRQ Control Stage Transition */
1438c2ecf20Sopenharmony_ci#define BEMPE	(1 << 10)	/* Enable IRQ Buffer Empty */
1448c2ecf20Sopenharmony_ci#define NRDYE	(1 << 9)	/* Enable IRQ Buffer Not Ready Response */
1458c2ecf20Sopenharmony_ci#define BRDYE	(1 << 8)	/* Enable IRQ Buffer Ready */
1468c2ecf20Sopenharmony_ci
1478c2ecf20Sopenharmony_ci/* INTENB1 */
1488c2ecf20Sopenharmony_ci#define BCHGE	(1 << 14)	/* USB Bus Change Interrupt Enable */
1498c2ecf20Sopenharmony_ci#define DTCHE	(1 << 12)	/* Disconnection Detect Interrupt Enable */
1508c2ecf20Sopenharmony_ci#define ATTCHE	(1 << 11)	/* Connection Detect Interrupt Enable */
1518c2ecf20Sopenharmony_ci#define EOFERRE	(1 << 6)	/* EOF Error Detect Interrupt Enable */
1528c2ecf20Sopenharmony_ci#define SIGNE	(1 << 5)	/* Setup Transaction Error Interrupt Enable */
1538c2ecf20Sopenharmony_ci#define SACKE	(1 << 4)	/* Setup Transaction ACK Interrupt Enable */
1548c2ecf20Sopenharmony_ci
1558c2ecf20Sopenharmony_ci/* INTSTS0 */
1568c2ecf20Sopenharmony_ci#define VBINT	(1 << 15)	/* VBUS0_0 and VBUS1_0 Interrupt Status */
1578c2ecf20Sopenharmony_ci#define DVST	(1 << 12)	/* Device State Transition Interrupt Status */
1588c2ecf20Sopenharmony_ci#define CTRT	(1 << 11)	/* Control Stage Interrupt Status */
1598c2ecf20Sopenharmony_ci#define BEMP	(1 << 10)	/* Buffer Empty Interrupt Status */
1608c2ecf20Sopenharmony_ci#define BRDY	(1 << 8)	/* Buffer Ready Interrupt Status */
1618c2ecf20Sopenharmony_ci#define VBSTS	(1 << 7)	/* VBUS_0 and VBUSIN_0 Input Status */
1628c2ecf20Sopenharmony_ci#define VALID	(1 << 3)	/* USB Request Receive */
1638c2ecf20Sopenharmony_ci
1648c2ecf20Sopenharmony_ci#define DVSQ_MASK		(0x7 << 4)	/* Device State */
1658c2ecf20Sopenharmony_ci#define  POWER_STATE		(0 << 4)
1668c2ecf20Sopenharmony_ci#define  DEFAULT_STATE		(1 << 4)
1678c2ecf20Sopenharmony_ci#define  ADDRESS_STATE		(2 << 4)
1688c2ecf20Sopenharmony_ci#define  CONFIGURATION_STATE	(3 << 4)
1698c2ecf20Sopenharmony_ci#define  SUSPENDED_STATE	(4 << 4)
1708c2ecf20Sopenharmony_ci
1718c2ecf20Sopenharmony_ci#define CTSQ_MASK		(0x7)	/* Control Transfer Stage */
1728c2ecf20Sopenharmony_ci#define  IDLE_SETUP_STAGE	0	/* Idle stage or setup stage */
1738c2ecf20Sopenharmony_ci#define  READ_DATA_STAGE	1	/* Control read data stage */
1748c2ecf20Sopenharmony_ci#define  READ_STATUS_STAGE	2	/* Control read status stage */
1758c2ecf20Sopenharmony_ci#define  WRITE_DATA_STAGE	3	/* Control write data stage */
1768c2ecf20Sopenharmony_ci#define  WRITE_STATUS_STAGE	4	/* Control write status stage */
1778c2ecf20Sopenharmony_ci#define  NODATA_STATUS_STAGE	5	/* Control write NoData status stage */
1788c2ecf20Sopenharmony_ci#define  SEQUENCE_ERROR		6	/* Control transfer sequence error */
1798c2ecf20Sopenharmony_ci
1808c2ecf20Sopenharmony_ci/* INTSTS1 */
1818c2ecf20Sopenharmony_ci#define OVRCR	(1 << 15) /* OVRCR Interrupt Status */
1828c2ecf20Sopenharmony_ci#define BCHG	(1 << 14) /* USB Bus Change Interrupt Status */
1838c2ecf20Sopenharmony_ci#define DTCH	(1 << 12) /* USB Disconnection Detect Interrupt Status */
1848c2ecf20Sopenharmony_ci#define ATTCH	(1 << 11) /* ATTCH Interrupt Status */
1858c2ecf20Sopenharmony_ci#define EOFERR	(1 << 6)  /* EOF Error Detect Interrupt Status */
1868c2ecf20Sopenharmony_ci#define SIGN	(1 << 5)  /* Setup Transaction Error Interrupt Status */
1878c2ecf20Sopenharmony_ci#define SACK	(1 << 4)  /* Setup Transaction ACK Response Interrupt Status */
1888c2ecf20Sopenharmony_ci
1898c2ecf20Sopenharmony_ci/* PIPECFG */
1908c2ecf20Sopenharmony_ci/* DCPCFG */
1918c2ecf20Sopenharmony_ci#define TYPE_NONE	(0 << 14)	/* Transfer Type */
1928c2ecf20Sopenharmony_ci#define TYPE_BULK	(1 << 14)
1938c2ecf20Sopenharmony_ci#define TYPE_INT	(2 << 14)
1948c2ecf20Sopenharmony_ci#define TYPE_ISO	(3 << 14)
1958c2ecf20Sopenharmony_ci#define BFRE		(1 << 10)	/* BRDY Interrupt Operation Spec. */
1968c2ecf20Sopenharmony_ci#define DBLB		(1 << 9)	/* Double Buffer Mode */
1978c2ecf20Sopenharmony_ci#define SHTNAK		(1 << 7)	/* Pipe Disable in Transfer End */
1988c2ecf20Sopenharmony_ci#define DIR_OUT		(1 << 4)	/* Transfer Direction */
1998c2ecf20Sopenharmony_ci
2008c2ecf20Sopenharmony_ci/* PIPEMAXP */
2018c2ecf20Sopenharmony_ci/* DCPMAXP */
2028c2ecf20Sopenharmony_ci#define DEVSEL_MASK	(0xF << 12)	/* Device Select */
2038c2ecf20Sopenharmony_ci#define DCP_MAXP_MASK	(0x7F)
2048c2ecf20Sopenharmony_ci#define PIPE_MAXP_MASK	(0x7FF)
2058c2ecf20Sopenharmony_ci
2068c2ecf20Sopenharmony_ci/* PIPEBUF */
2078c2ecf20Sopenharmony_ci#define BUFSIZE_SHIFT	10
2088c2ecf20Sopenharmony_ci#define BUFSIZE_MASK	(0x1F << BUFSIZE_SHIFT)
2098c2ecf20Sopenharmony_ci#define BUFNMB_MASK	(0xFF)
2108c2ecf20Sopenharmony_ci
2118c2ecf20Sopenharmony_ci/* PIPEnCTR */
2128c2ecf20Sopenharmony_ci/* DCPCTR */
2138c2ecf20Sopenharmony_ci#define BSTS		(1 << 15)	/* Buffer Status */
2148c2ecf20Sopenharmony_ci#define SUREQ		(1 << 14)	/* Sending SETUP Token */
2158c2ecf20Sopenharmony_ci#define INBUFM		(1 << 14)	/* (PIPEnCTR) Transfer Buffer Monitor */
2168c2ecf20Sopenharmony_ci#define CSSTS		(1 << 12)	/* CSSTS Status */
2178c2ecf20Sopenharmony_ci#define	ACLRM		(1 << 9)	/* Buffer Auto-Clear Mode */
2188c2ecf20Sopenharmony_ci#define SQCLR		(1 << 8)	/* Toggle Bit Clear */
2198c2ecf20Sopenharmony_ci#define SQSET		(1 << 7)	/* Toggle Bit Set */
2208c2ecf20Sopenharmony_ci#define SQMON		(1 << 6)	/* Toggle Bit Check */
2218c2ecf20Sopenharmony_ci#define PBUSY		(1 << 5)	/* Pipe Busy */
2228c2ecf20Sopenharmony_ci#define PID_MASK	(0x3)		/* Response PID */
2238c2ecf20Sopenharmony_ci#define  PID_NAK	0
2248c2ecf20Sopenharmony_ci#define  PID_BUF	1
2258c2ecf20Sopenharmony_ci#define  PID_STALL10	2
2268c2ecf20Sopenharmony_ci#define  PID_STALL11	3
2278c2ecf20Sopenharmony_ci
2288c2ecf20Sopenharmony_ci#define CCPL		(1 << 2)	/* Control Transfer End Enable */
2298c2ecf20Sopenharmony_ci
2308c2ecf20Sopenharmony_ci/* PIPEnTRE */
2318c2ecf20Sopenharmony_ci#define TRENB		(1 << 9)	/* Transaction Counter Enable */
2328c2ecf20Sopenharmony_ci#define TRCLR		(1 << 8)	/* Transaction Counter Clear */
2338c2ecf20Sopenharmony_ci
2348c2ecf20Sopenharmony_ci/* FRMNUM */
2358c2ecf20Sopenharmony_ci#define FRNM_MASK	(0x7FF)
2368c2ecf20Sopenharmony_ci
2378c2ecf20Sopenharmony_ci/* DEVADDn */
2388c2ecf20Sopenharmony_ci#define UPPHUB(x)	(((x) & 0xF) << 11)	/* HUB Register */
2398c2ecf20Sopenharmony_ci#define HUBPORT(x)	(((x) & 0x7) << 8)	/* HUB Port for Target Device */
2408c2ecf20Sopenharmony_ci#define USBSPD(x)	(((x) & 0x3) << 6)	/* Device Transfer Rate */
2418c2ecf20Sopenharmony_ci#define USBSPD_SPEED_LOW	0x1
2428c2ecf20Sopenharmony_ci#define USBSPD_SPEED_FULL	0x2
2438c2ecf20Sopenharmony_ci#define USBSPD_SPEED_HIGH	0x3
2448c2ecf20Sopenharmony_ci
2458c2ecf20Sopenharmony_ci/* SUSPMODE */
2468c2ecf20Sopenharmony_ci#define SUSPM		(1 << 14)	/* SuspendM Control */
2478c2ecf20Sopenharmony_ci
2488c2ecf20Sopenharmony_ci/*
2498c2ecf20Sopenharmony_ci *		struct
2508c2ecf20Sopenharmony_ci */
2518c2ecf20Sopenharmony_cistruct usbhs_priv {
2528c2ecf20Sopenharmony_ci
2538c2ecf20Sopenharmony_ci	void __iomem *base;
2548c2ecf20Sopenharmony_ci	unsigned int irq;
2558c2ecf20Sopenharmony_ci	unsigned long irqflags;
2568c2ecf20Sopenharmony_ci
2578c2ecf20Sopenharmony_ci	const struct renesas_usbhs_platform_callback *pfunc;
2588c2ecf20Sopenharmony_ci	struct renesas_usbhs_driver_param	dparam;
2598c2ecf20Sopenharmony_ci
2608c2ecf20Sopenharmony_ci	struct delayed_work notify_hotplug_work;
2618c2ecf20Sopenharmony_ci	struct platform_device *pdev;
2628c2ecf20Sopenharmony_ci
2638c2ecf20Sopenharmony_ci	struct extcon_dev *edev;
2648c2ecf20Sopenharmony_ci
2658c2ecf20Sopenharmony_ci	spinlock_t		lock;
2668c2ecf20Sopenharmony_ci
2678c2ecf20Sopenharmony_ci	/*
2688c2ecf20Sopenharmony_ci	 * module control
2698c2ecf20Sopenharmony_ci	 */
2708c2ecf20Sopenharmony_ci	struct usbhs_mod_info mod_info;
2718c2ecf20Sopenharmony_ci
2728c2ecf20Sopenharmony_ci	/*
2738c2ecf20Sopenharmony_ci	 * pipe control
2748c2ecf20Sopenharmony_ci	 */
2758c2ecf20Sopenharmony_ci	struct usbhs_pipe_info pipe_info;
2768c2ecf20Sopenharmony_ci
2778c2ecf20Sopenharmony_ci	/*
2788c2ecf20Sopenharmony_ci	 * fifo control
2798c2ecf20Sopenharmony_ci	 */
2808c2ecf20Sopenharmony_ci	struct usbhs_fifo_info fifo_info;
2818c2ecf20Sopenharmony_ci
2828c2ecf20Sopenharmony_ci	struct phy *phy;
2838c2ecf20Sopenharmony_ci	struct reset_control *rsts;
2848c2ecf20Sopenharmony_ci	struct clk *clks[2];
2858c2ecf20Sopenharmony_ci};
2868c2ecf20Sopenharmony_ci
2878c2ecf20Sopenharmony_ci/*
2888c2ecf20Sopenharmony_ci * common
2898c2ecf20Sopenharmony_ci */
2908c2ecf20Sopenharmony_ciu16 usbhs_read(struct usbhs_priv *priv, u32 reg);
2918c2ecf20Sopenharmony_civoid usbhs_write(struct usbhs_priv *priv, u32 reg, u16 data);
2928c2ecf20Sopenharmony_civoid usbhs_bset(struct usbhs_priv *priv, u32 reg, u16 mask, u16 data);
2938c2ecf20Sopenharmony_ci
2948c2ecf20Sopenharmony_ci#define usbhs_lock(p, f) spin_lock_irqsave(usbhs_priv_to_lock(p), f)
2958c2ecf20Sopenharmony_ci#define usbhs_unlock(p, f) spin_unlock_irqrestore(usbhs_priv_to_lock(p), f)
2968c2ecf20Sopenharmony_ci
2978c2ecf20Sopenharmony_ciint usbhs_get_id_as_gadget(struct platform_device *pdev);
2988c2ecf20Sopenharmony_ci
2998c2ecf20Sopenharmony_ci/*
3008c2ecf20Sopenharmony_ci * sysconfig
3018c2ecf20Sopenharmony_ci */
3028c2ecf20Sopenharmony_civoid usbhs_sys_host_ctrl(struct usbhs_priv *priv, int enable);
3038c2ecf20Sopenharmony_civoid usbhs_sys_function_ctrl(struct usbhs_priv *priv, int enable);
3048c2ecf20Sopenharmony_civoid usbhs_sys_function_pullup(struct usbhs_priv *priv, int enable);
3058c2ecf20Sopenharmony_civoid usbhs_sys_set_test_mode(struct usbhs_priv *priv, u16 mode);
3068c2ecf20Sopenharmony_ci
3078c2ecf20Sopenharmony_ci/*
3088c2ecf20Sopenharmony_ci * usb request
3098c2ecf20Sopenharmony_ci */
3108c2ecf20Sopenharmony_civoid usbhs_usbreq_get_val(struct usbhs_priv *priv, struct usb_ctrlrequest *req);
3118c2ecf20Sopenharmony_civoid usbhs_usbreq_set_val(struct usbhs_priv *priv, struct usb_ctrlrequest *req);
3128c2ecf20Sopenharmony_ci
3138c2ecf20Sopenharmony_ci/*
3148c2ecf20Sopenharmony_ci * bus
3158c2ecf20Sopenharmony_ci */
3168c2ecf20Sopenharmony_civoid usbhs_bus_send_sof_enable(struct usbhs_priv *priv);
3178c2ecf20Sopenharmony_civoid usbhs_bus_send_reset(struct usbhs_priv *priv);
3188c2ecf20Sopenharmony_ciint usbhs_bus_get_speed(struct usbhs_priv *priv);
3198c2ecf20Sopenharmony_ciint usbhs_vbus_ctrl(struct usbhs_priv *priv, int enable);
3208c2ecf20Sopenharmony_ciint usbhsc_schedule_notify_hotplug(struct platform_device *pdev);
3218c2ecf20Sopenharmony_ci
3228c2ecf20Sopenharmony_ci/*
3238c2ecf20Sopenharmony_ci * frame
3248c2ecf20Sopenharmony_ci */
3258c2ecf20Sopenharmony_ciint usbhs_frame_get_num(struct usbhs_priv *priv);
3268c2ecf20Sopenharmony_ci
3278c2ecf20Sopenharmony_ci/*
3288c2ecf20Sopenharmony_ci * device config
3298c2ecf20Sopenharmony_ci */
3308c2ecf20Sopenharmony_ciint usbhs_set_device_config(struct usbhs_priv *priv, int devnum, u16 upphub,
3318c2ecf20Sopenharmony_ci			   u16 hubport, u16 speed);
3328c2ecf20Sopenharmony_ci
3338c2ecf20Sopenharmony_ci/*
3348c2ecf20Sopenharmony_ci * interrupt functions
3358c2ecf20Sopenharmony_ci */
3368c2ecf20Sopenharmony_civoid usbhs_xxxsts_clear(struct usbhs_priv *priv, u16 sts_reg, u16 bit);
3378c2ecf20Sopenharmony_ci
3388c2ecf20Sopenharmony_ci/*
3398c2ecf20Sopenharmony_ci * data
3408c2ecf20Sopenharmony_ci */
3418c2ecf20Sopenharmony_cistruct usbhs_priv *usbhs_pdev_to_priv(struct platform_device *pdev);
3428c2ecf20Sopenharmony_ci#define usbhs_get_dparam(priv, param)	(priv->dparam.param)
3438c2ecf20Sopenharmony_ci#define usbhs_priv_to_pdev(priv)	(priv->pdev)
3448c2ecf20Sopenharmony_ci#define usbhs_priv_to_dev(priv)		(&priv->pdev->dev)
3458c2ecf20Sopenharmony_ci#define usbhs_priv_to_lock(priv)	(&priv->lock)
3468c2ecf20Sopenharmony_ci
3478c2ecf20Sopenharmony_ci#endif /* RENESAS_USB_DRIVER_H */
348