xref: /netbsd-src/sys/arch/arm/imx/imxusbvar.h (revision 1b53f8867012b6c9584d633cbb812d3af7e001ea)
1*1b53f886Sbouyer /*	$NetBSD: imxusbvar.h,v 1.7 2023/05/04 17:09:44 bouyer Exp $	*/
2f1a047b0Shkenken /*
3f1a047b0Shkenken  * Copyright (c) 2019  Genetec Corporation.  All rights reserved.
4f1a047b0Shkenken  * Written by Hashimoto Kenichi for Genetec Corporation.
5f1a047b0Shkenken  *
6f1a047b0Shkenken  * Redistribution and use in source and binary forms, with or without
7f1a047b0Shkenken  * modification, are permitted provided that the following conditions
8f1a047b0Shkenken  * are met:
9f1a047b0Shkenken  * 1. Redistributions of source code must retain the above copyright
10f1a047b0Shkenken  *    notice, this list of conditions and the following disclaimer.
11f1a047b0Shkenken  * 2. Redistributions in binary form must reproduce the above copyright
12f1a047b0Shkenken  *    notice, this list of conditions and the following disclaimer in the
13f1a047b0Shkenken  *    documentation and/or other materials provided with the distribution.
14f1a047b0Shkenken  *
15f1a047b0Shkenken  * THIS SOFTWARE IS PROVIDED BY GENETEC CORPORATION ``AS IS'' AND
16f1a047b0Shkenken  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
17f1a047b0Shkenken  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
18f1a047b0Shkenken  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL GENETEC CORPORATION
19f1a047b0Shkenken  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
20f1a047b0Shkenken  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
21f1a047b0Shkenken  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
22f1a047b0Shkenken  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
23f1a047b0Shkenken  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
24f1a047b0Shkenken  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
25f1a047b0Shkenken  * POSSIBILITY OF SUCH DAMAGE.
26f1a047b0Shkenken  */
27f1a047b0Shkenken 
28c1719a03Sbsh #ifndef _ARM_IMX_IMXUSBVAR_H
29c1719a03Sbsh #define _ARM_IMX_IMXUSBVAR_H
30c1719a03Sbsh 
31c1719a03Sbsh struct imxehci_softc;
32c1719a03Sbsh 
33c1719a03Sbsh enum imx_usb_role {
34c1719a03Sbsh 	IMXUSB_HOST,
35c1719a03Sbsh 	IMXUSB_DEVICE
36c1719a03Sbsh };
37c1719a03Sbsh 
38c1719a03Sbsh struct imxusbc_softc {
39c1719a03Sbsh 	device_t sc_dev;
4005ac7a10Shkenken 
41c1719a03Sbsh 	bus_space_tag_t sc_iot;
42c1719a03Sbsh 	bus_space_handle_t sc_ioh;
4305ac7a10Shkenken 	bus_space_handle_t sc_ioh_usbnc;
44c1719a03Sbsh 
45f1a047b0Shkenken 	struct clk *sc_clk;
46f1a047b0Shkenken 
47ec482321Sryo 	/* filled in by platform dependent param & routine */
4805ac7a10Shkenken 	bus_addr_t sc_ehci_offset;
49ec482321Sryo 	bus_size_t sc_ehci_size;
5005ac7a10Shkenken 
51*1b53f886Sbouyer 	void (* sc_init_md_hook)(struct imxehci_softc *, uintptr_t);
52*1b53f886Sbouyer 	void *(* sc_intr_establish_md_hook)(struct imxehci_softc *, uintptr_t);
53*1b53f886Sbouyer 	void (* sc_setup_md_hook)(struct imxehci_softc *, enum imx_usb_role,
54*1b53f886Sbouyer 				  uintptr_t);
55*1b53f886Sbouyer 	uintptr_t sc_md_hook_data;
56c1719a03Sbsh };
57c1719a03Sbsh 
58c1719a03Sbsh struct imxusbc_attach_args {
59c1719a03Sbsh 	bus_space_tag_t aa_iot;
60c1719a03Sbsh 	bus_space_handle_t aa_ioh;
61c1719a03Sbsh 	bus_dma_tag_t aa_dmat;
62c1719a03Sbsh 	int aa_unit;	/* 0: OTG, 1: HOST1, 2: HOST2 ... */
63c1719a03Sbsh 	int aa_irq;
64c1719a03Sbsh };
65c1719a03Sbsh 
66c1719a03Sbsh enum imx_usb_if {
67c1719a03Sbsh 	IMXUSBC_IF_UTMI,
68c1719a03Sbsh 	IMXUSBC_IF_PHILIPS,
69c1719a03Sbsh 	IMXUSBC_IF_ULPI,
702868f5bcShkenken 	IMXUSBC_IF_SERIAL,
71ec482321Sryo 	IMXUSBC_IF_UTMI_WIDE,
72ec482321Sryo 	IMXUSBC_IF_HSIC
73c1719a03Sbsh };
74c1719a03Sbsh 
75c1719a03Sbsh struct imxehci_softc {
76c1719a03Sbsh 	ehci_softc_t sc_hsc;
77c1719a03Sbsh 
7805ac7a10Shkenken 	device_t sc_dev;
79c1719a03Sbsh 	bus_space_tag_t sc_iot;
80c1719a03Sbsh 	bus_space_handle_t sc_ioh;
8105ac7a10Shkenken 	void *sc_ih;
8205ac7a10Shkenken 
83c1719a03Sbsh 	struct imxusbc_softc *sc_usbc;
8405ac7a10Shkenken 
85c1719a03Sbsh 	uint sc_unit;
86c1719a03Sbsh 	enum imx_usb_if sc_iftype;
87c1719a03Sbsh };
88c1719a03Sbsh 
8905ac7a10Shkenken int imxusbc_attach_common(device_t, device_t, bus_space_tag_t, bus_addr_t, bus_size_t);
90c1719a03Sbsh void imxehci_reset(struct imxehci_softc *);
91c1719a03Sbsh 
92c1719a03Sbsh #endif	/* _ARM_IMX_IMXUSBVAR_H */
93