18c2ecf20Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0 */
28c2ecf20Sopenharmony_ci/*
38c2ecf20Sopenharmony_ci * FIXME correct answer depends on hmc_mode,
48c2ecf20Sopenharmony_ci * as does (on omap1) any nonzero value for config->otg port number
58c2ecf20Sopenharmony_ci */
68c2ecf20Sopenharmony_ci#if IS_ENABLED(CONFIG_USB_OMAP)
78c2ecf20Sopenharmony_ci#define	is_usb0_device(config)	1
88c2ecf20Sopenharmony_ci#else
98c2ecf20Sopenharmony_ci#define	is_usb0_device(config)	0
108c2ecf20Sopenharmony_ci#endif
118c2ecf20Sopenharmony_ci
128c2ecf20Sopenharmony_ci#include <linux/platform_data/usb-omap1.h>
138c2ecf20Sopenharmony_ci
148c2ecf20Sopenharmony_ci#if IS_ENABLED(CONFIG_USB_SUPPORT)
158c2ecf20Sopenharmony_civoid omap1_usb_init(struct omap_usb_config *pdata);
168c2ecf20Sopenharmony_ci#else
178c2ecf20Sopenharmony_cistatic inline void omap1_usb_init(struct omap_usb_config *pdata)
188c2ecf20Sopenharmony_ci{
198c2ecf20Sopenharmony_ci}
208c2ecf20Sopenharmony_ci#endif
218c2ecf20Sopenharmony_ci
228c2ecf20Sopenharmony_ci#define OMAP1_OTG_BASE			0xfffb0400
238c2ecf20Sopenharmony_ci#define OMAP1_UDC_BASE			0xfffb4000
248c2ecf20Sopenharmony_ci#define OMAP1_OHCI_BASE			0xfffba000
258c2ecf20Sopenharmony_ci
268c2ecf20Sopenharmony_ci#define OMAP2_OHCI_BASE			0x4805e000
278c2ecf20Sopenharmony_ci#define OMAP2_UDC_BASE			0x4805e200
288c2ecf20Sopenharmony_ci#define OMAP2_OTG_BASE			0x4805e300
298c2ecf20Sopenharmony_ci#define OTG_BASE			OMAP1_OTG_BASE
308c2ecf20Sopenharmony_ci#define UDC_BASE			OMAP1_UDC_BASE
318c2ecf20Sopenharmony_ci#define OMAP_OHCI_BASE			OMAP1_OHCI_BASE
328c2ecf20Sopenharmony_ci
338c2ecf20Sopenharmony_ci/*
348c2ecf20Sopenharmony_ci * OTG and transceiver registers, for OMAPs starting with ARM926
358c2ecf20Sopenharmony_ci */
368c2ecf20Sopenharmony_ci#define OTG_REV				(OTG_BASE + 0x00)
378c2ecf20Sopenharmony_ci#define OTG_SYSCON_1			(OTG_BASE + 0x04)
388c2ecf20Sopenharmony_ci#	define	 USB2_TRX_MODE(w)	(((w)>>24)&0x07)
398c2ecf20Sopenharmony_ci#	define	 USB1_TRX_MODE(w)	(((w)>>20)&0x07)
408c2ecf20Sopenharmony_ci#	define	 USB0_TRX_MODE(w)	(((w)>>16)&0x07)
418c2ecf20Sopenharmony_ci#	define	 OTG_IDLE_EN		(1 << 15)
428c2ecf20Sopenharmony_ci#	define	 HST_IDLE_EN		(1 << 14)
438c2ecf20Sopenharmony_ci#	define	 DEV_IDLE_EN		(1 << 13)
448c2ecf20Sopenharmony_ci#	define	 OTG_RESET_DONE		(1 << 2)
458c2ecf20Sopenharmony_ci#	define	 OTG_SOFT_RESET		(1 << 1)
468c2ecf20Sopenharmony_ci#define OTG_SYSCON_2			(OTG_BASE + 0x08)
478c2ecf20Sopenharmony_ci#	define	 OTG_EN			(1 << 31)
488c2ecf20Sopenharmony_ci#	define	 USBX_SYNCHRO		(1 << 30)
498c2ecf20Sopenharmony_ci#	define	 OTG_MST16		(1 << 29)
508c2ecf20Sopenharmony_ci#	define	 SRP_GPDATA		(1 << 28)
518c2ecf20Sopenharmony_ci#	define	 SRP_GPDVBUS		(1 << 27)
528c2ecf20Sopenharmony_ci#	define	 SRP_GPUVBUS(w)		(((w)>>24)&0x07)
538c2ecf20Sopenharmony_ci#	define	 A_WAIT_VRISE(w)	(((w)>>20)&0x07)
548c2ecf20Sopenharmony_ci#	define	 B_ASE_BRST(w)		(((w)>>16)&0x07)
558c2ecf20Sopenharmony_ci#	define	 SRP_DPW		(1 << 14)
568c2ecf20Sopenharmony_ci#	define	 SRP_DATA		(1 << 13)
578c2ecf20Sopenharmony_ci#	define	 SRP_VBUS		(1 << 12)
588c2ecf20Sopenharmony_ci#	define	 OTG_PADEN		(1 << 10)
598c2ecf20Sopenharmony_ci#	define	 HMC_PADEN		(1 << 9)
608c2ecf20Sopenharmony_ci#	define	 UHOST_EN		(1 << 8)
618c2ecf20Sopenharmony_ci#	define	 HMC_TLLSPEED		(1 << 7)
628c2ecf20Sopenharmony_ci#	define	 HMC_TLLATTACH		(1 << 6)
638c2ecf20Sopenharmony_ci#	define	 OTG_HMC(w)		(((w)>>0)&0x3f)
648c2ecf20Sopenharmony_ci#define OTG_CTRL			(OTG_BASE + 0x0c)
658c2ecf20Sopenharmony_ci#	define	 OTG_USB2_EN		(1 << 29)
668c2ecf20Sopenharmony_ci#	define	 OTG_USB2_DP		(1 << 28)
678c2ecf20Sopenharmony_ci#	define	 OTG_USB2_DM		(1 << 27)
688c2ecf20Sopenharmony_ci#	define	 OTG_USB1_EN		(1 << 26)
698c2ecf20Sopenharmony_ci#	define	 OTG_USB1_DP		(1 << 25)
708c2ecf20Sopenharmony_ci#	define	 OTG_USB1_DM		(1 << 24)
718c2ecf20Sopenharmony_ci#	define	 OTG_USB0_EN		(1 << 23)
728c2ecf20Sopenharmony_ci#	define	 OTG_USB0_DP		(1 << 22)
738c2ecf20Sopenharmony_ci#	define	 OTG_USB0_DM		(1 << 21)
748c2ecf20Sopenharmony_ci#	define	 OTG_ASESSVLD		(1 << 20)
758c2ecf20Sopenharmony_ci#	define	 OTG_BSESSEND		(1 << 19)
768c2ecf20Sopenharmony_ci#	define	 OTG_BSESSVLD		(1 << 18)
778c2ecf20Sopenharmony_ci#	define	 OTG_VBUSVLD		(1 << 17)
788c2ecf20Sopenharmony_ci#	define	 OTG_ID			(1 << 16)
798c2ecf20Sopenharmony_ci#	define	 OTG_DRIVER_SEL		(1 << 15)
808c2ecf20Sopenharmony_ci#	define	 OTG_A_SETB_HNPEN	(1 << 12)
818c2ecf20Sopenharmony_ci#	define	 OTG_A_BUSREQ		(1 << 11)
828c2ecf20Sopenharmony_ci#	define	 OTG_B_HNPEN		(1 << 9)
838c2ecf20Sopenharmony_ci#	define	 OTG_B_BUSREQ		(1 << 8)
848c2ecf20Sopenharmony_ci#	define	 OTG_BUSDROP		(1 << 7)
858c2ecf20Sopenharmony_ci#	define	 OTG_PULLDOWN		(1 << 5)
868c2ecf20Sopenharmony_ci#	define	 OTG_PULLUP		(1 << 4)
878c2ecf20Sopenharmony_ci#	define	 OTG_DRV_VBUS		(1 << 3)
888c2ecf20Sopenharmony_ci#	define	 OTG_PD_VBUS		(1 << 2)
898c2ecf20Sopenharmony_ci#	define	 OTG_PU_VBUS		(1 << 1)
908c2ecf20Sopenharmony_ci#	define	 OTG_PU_ID		(1 << 0)
918c2ecf20Sopenharmony_ci#define OTG_IRQ_EN			(OTG_BASE + 0x10)	/* 16-bit */
928c2ecf20Sopenharmony_ci#	define	 DRIVER_SWITCH		(1 << 15)
938c2ecf20Sopenharmony_ci#	define	 A_VBUS_ERR		(1 << 13)
948c2ecf20Sopenharmony_ci#	define	 A_REQ_TMROUT		(1 << 12)
958c2ecf20Sopenharmony_ci#	define	 A_SRP_DETECT		(1 << 11)
968c2ecf20Sopenharmony_ci#	define	 B_HNP_FAIL		(1 << 10)
978c2ecf20Sopenharmony_ci#	define	 B_SRP_TMROUT		(1 << 9)
988c2ecf20Sopenharmony_ci#	define	 B_SRP_DONE		(1 << 8)
998c2ecf20Sopenharmony_ci#	define	 B_SRP_STARTED		(1 << 7)
1008c2ecf20Sopenharmony_ci#	define	 OPRT_CHG		(1 << 0)
1018c2ecf20Sopenharmony_ci#define OTG_IRQ_SRC			(OTG_BASE + 0x14)	/* 16-bit */
1028c2ecf20Sopenharmony_ci	// same bits as in IRQ_EN
1038c2ecf20Sopenharmony_ci#define OTG_OUTCTRL			(OTG_BASE + 0x18)	/* 16-bit */
1048c2ecf20Sopenharmony_ci#	define	 OTGVPD			(1 << 14)
1058c2ecf20Sopenharmony_ci#	define	 OTGVPU			(1 << 13)
1068c2ecf20Sopenharmony_ci#	define	 OTGPUID		(1 << 12)
1078c2ecf20Sopenharmony_ci#	define	 USB2VDR		(1 << 10)
1088c2ecf20Sopenharmony_ci#	define	 USB2PDEN		(1 << 9)
1098c2ecf20Sopenharmony_ci#	define	 USB2PUEN		(1 << 8)
1108c2ecf20Sopenharmony_ci#	define	 USB1VDR		(1 << 6)
1118c2ecf20Sopenharmony_ci#	define	 USB1PDEN		(1 << 5)
1128c2ecf20Sopenharmony_ci#	define	 USB1PUEN		(1 << 4)
1138c2ecf20Sopenharmony_ci#	define	 USB0VDR		(1 << 2)
1148c2ecf20Sopenharmony_ci#	define	 USB0PDEN		(1 << 1)
1158c2ecf20Sopenharmony_ci#	define	 USB0PUEN		(1 << 0)
1168c2ecf20Sopenharmony_ci#define OTG_TEST			(OTG_BASE + 0x20)	/* 16-bit */
1178c2ecf20Sopenharmony_ci#define OTG_VENDOR_CODE			(OTG_BASE + 0xfc)	/* 16-bit */
1188c2ecf20Sopenharmony_ci
1198c2ecf20Sopenharmony_ci/*-------------------------------------------------------------------------*/
1208c2ecf20Sopenharmony_ci
1218c2ecf20Sopenharmony_ci/* OMAP1 */
1228c2ecf20Sopenharmony_ci#define	USB_TRANSCEIVER_CTRL		(0xfffe1000 + 0x0064)
1238c2ecf20Sopenharmony_ci#	define	CONF_USB2_UNI_R		(1 << 8)
1248c2ecf20Sopenharmony_ci#	define	CONF_USB1_UNI_R		(1 << 7)
1258c2ecf20Sopenharmony_ci#	define	CONF_USB_PORT0_R(x)	(((x)>>4)&0x7)
1268c2ecf20Sopenharmony_ci#	define	CONF_USB0_ISOLATE_R	(1 << 3)
1278c2ecf20Sopenharmony_ci#	define	CONF_USB_PWRDN_DM_R	(1 << 2)
1288c2ecf20Sopenharmony_ci#	define	CONF_USB_PWRDN_DP_R	(1 << 1)
129