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