Remove fdtbus_gpio_release() from enet_phy_reset().diff -r1.24 -r1.25 src/sys/arch/arm/imx/if_enet.c
(hkenken)
--- src/sys/arch/arm/imx/if_enet.c 2019/07/23 06:36:36 1.24
+++ src/sys/arch/arm/imx/if_enet.c 2019/07/30 06:26:31 1.25
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | /* $NetBSD: if_enet.c,v 1.24 2019/07/23 06:36:36 hkenken Exp $ */ | 1 | /* $NetBSD: if_enet.c,v 1.25 2019/07/30 06:26:31 hkenken Exp $ */ | |
2 | 2 | |||
3 | /* | 3 | /* | |
4 | * Copyright (c) 2014 Ryo Shimizu <ryo@nerv.org> | 4 | * Copyright (c) 2014 Ryo Shimizu <ryo@nerv.org> | |
5 | * All rights reserved. | 5 | * All rights reserved. | |
6 | * | 6 | * | |
7 | * Redistribution and use in source and binary forms, with or without | 7 | * Redistribution and use in source and binary forms, with or without | |
8 | * modification, are permitted provided that the following conditions | 8 | * modification, are permitted provided that the following conditions | |
9 | * are met: | 9 | * are met: | |
10 | * 1. Redistributions of source code must retain the above copyright | 10 | * 1. Redistributions of source code must retain the above copyright | |
11 | * notice, this list of conditions and the following disclaimer. | 11 | * notice, this list of conditions and the following disclaimer. | |
12 | * 2. Redistributions in binary form must reproduce the above copyright | 12 | * 2. Redistributions in binary form must reproduce the above copyright | |
13 | * notice, this list of conditions and the following disclaimer in the | 13 | * notice, this list of conditions and the following disclaimer in the | |
14 | * documentation and/or other materials provided with the distribution. | 14 | * documentation and/or other materials provided with the distribution. | |
@@ -21,27 +21,27 @@ | @@ -21,27 +21,27 @@ | |||
21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR | 21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR | |
22 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | 22 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | |
23 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, | 23 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, | |
24 | * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING | 24 | * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING | |
25 | * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | 25 | * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | |
26 | * POSSIBILITY OF SUCH DAMAGE. | 26 | * POSSIBILITY OF SUCH DAMAGE. | |
27 | */ | 27 | */ | |
28 | 28 | |||
29 | /* | 29 | /* | |
30 | * i.MX6,7 10/100/1000-Mbps ethernet MAC (ENET) | 30 | * i.MX6,7 10/100/1000-Mbps ethernet MAC (ENET) | |
31 | */ | 31 | */ | |
32 | 32 | |||
33 | #include <sys/cdefs.h> | 33 | #include <sys/cdefs.h> | |
34 | __KERNEL_RCSID(0, "$NetBSD: if_enet.c,v 1.24 2019/07/23 06:36:36 hkenken Exp $"); | 34 | __KERNEL_RCSID(0, "$NetBSD: if_enet.c,v 1.25 2019/07/30 06:26:31 hkenken Exp $"); | |
35 | 35 | |||
36 | #include "vlan.h" | 36 | #include "vlan.h" | |
37 | 37 | |||
38 | #include <sys/param.h> | 38 | #include <sys/param.h> | |
39 | #include <sys/bus.h> | 39 | #include <sys/bus.h> | |
40 | #include <sys/mbuf.h> | 40 | #include <sys/mbuf.h> | |
41 | #include <sys/device.h> | 41 | #include <sys/device.h> | |
42 | #include <sys/sockio.h> | 42 | #include <sys/sockio.h> | |
43 | #include <sys/kernel.h> | 43 | #include <sys/kernel.h> | |
44 | #include <sys/rndsource.h> | 44 | #include <sys/rndsource.h> | |
45 | 45 | |||
46 | #include <lib/libkern/libkern.h> | 46 | #include <lib/libkern/libkern.h> | |
47 | 47 | |||
@@ -156,29 +156,26 @@ static void enet_setmulti(struct enet_so | @@ -156,29 +156,26 @@ static void enet_setmulti(struct enet_so | |||
156 | static int enet_encap_mbufalign(struct mbuf **); | 156 | static int enet_encap_mbufalign(struct mbuf **); | |
157 | static int enet_encap_txring(struct enet_softc *, struct mbuf **); | 157 | static int enet_encap_txring(struct enet_softc *, struct mbuf **); | |
158 | static int enet_init_regs(struct enet_softc *, int); | 158 | static int enet_init_regs(struct enet_softc *, int); | |
159 | static int enet_alloc_ring(struct enet_softc *); | 159 | static int enet_alloc_ring(struct enet_softc *); | |
160 | static void enet_init_txring(struct enet_softc *); | 160 | static void enet_init_txring(struct enet_softc *); | |
161 | static int enet_init_rxring(struct enet_softc *); | 161 | static int enet_init_rxring(struct enet_softc *); | |
162 | static void enet_reset_rxdesc(struct enet_softc *, int); | 162 | static void enet_reset_rxdesc(struct enet_softc *, int); | |
163 | static int enet_alloc_rxbuf(struct enet_softc *, int); | 163 | static int enet_alloc_rxbuf(struct enet_softc *, int); | |
164 | static void enet_drain_txbuf(struct enet_softc *); | 164 | static void enet_drain_txbuf(struct enet_softc *); | |
165 | static void enet_drain_rxbuf(struct enet_softc *); | 165 | static void enet_drain_rxbuf(struct enet_softc *); | |
166 | static int enet_alloc_dma(struct enet_softc *, size_t, void **, | 166 | static int enet_alloc_dma(struct enet_softc *, size_t, void **, | |
167 | bus_dmamap_t *); | 167 | bus_dmamap_t *); | |
168 | 168 | |||
169 | CFATTACH_DECL_NEW(enet, sizeof(struct enet_softc), | |||
170 | enet_match, enet_attach, NULL, NULL); | |||
171 | ||||
172 | int | 169 | int | |
173 | enet_attach_common(device_t self) | 170 | enet_attach_common(device_t self) | |
174 | { | 171 | { | |
175 | struct enet_softc *sc = device_private(self); | 172 | struct enet_softc *sc = device_private(self); | |
176 | struct ifnet *ifp; | 173 | struct ifnet *ifp; | |
177 | struct mii_data * const mii = &sc->sc_mii; | 174 | struct mii_data * const mii = &sc->sc_mii; | |
178 | 175 | |||
179 | /* allocate dma buffer */ | 176 | /* allocate dma buffer */ | |
180 | if (enet_alloc_ring(sc)) | 177 | if (enet_alloc_ring(sc)) | |
181 | return -1; | 178 | return -1; | |
182 | 179 | |||
183 | #define IS_ENADDR_ZERO(enaddr) \ | 180 | #define IS_ENADDR_ZERO(enaddr) \ | |
184 | ((enaddr[0] | enaddr[1] | enaddr[2] | \ | 181 | ((enaddr[0] | enaddr[1] | enaddr[2] | \ |
--- src/sys/arch/arm/imx/Attic/if_enet_imx6.c 2019/07/23 06:36:36 1.5
+++ src/sys/arch/arm/imx/Attic/if_enet_imx6.c 2019/07/30 06:26:31 1.6
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | /* $NetBSD: if_enet_imx6.c,v 1.5 2019/07/23 06:36:36 hkenken Exp $ */ | 1 | /* $NetBSD: if_enet_imx6.c,v 1.6 2019/07/30 06:26:31 hkenken Exp $ */ | |
2 | 2 | |||
3 | /* | 3 | /* | |
4 | * Copyright (c) 2014 Ryo Shimizu <ryo@nerv.org> | 4 | * Copyright (c) 2014 Ryo Shimizu <ryo@nerv.org> | |
5 | * All rights reserved. | 5 | * All rights reserved. | |
6 | * | 6 | * | |
7 | * Redistribution and use in source and binary forms, with or without | 7 | * Redistribution and use in source and binary forms, with or without | |
8 | * modification, are permitted provided that the following conditions | 8 | * modification, are permitted provided that the following conditions | |
9 | * are met: | 9 | * are met: | |
10 | * 1. Redistributions of source code must retain the above copyright | 10 | * 1. Redistributions of source code must retain the above copyright | |
11 | * notice, this list of conditions and the following disclaimer. | 11 | * notice, this list of conditions and the following disclaimer. | |
12 | * 2. Redistributions in binary form must reproduce the above copyright | 12 | * 2. Redistributions in binary form must reproduce the above copyright | |
13 | * notice, this list of conditions and the following disclaimer in the | 13 | * notice, this list of conditions and the following disclaimer in the | |
14 | * documentation and/or other materials provided with the distribution. | 14 | * documentation and/or other materials provided with the distribution. | |
@@ -17,46 +17,49 @@ | @@ -17,46 +17,49 @@ | |||
17 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | 17 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | |
18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | 18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | |
19 | * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, | 19 | * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, | |
20 | * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | 20 | * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | |
21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR | 21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR | |
22 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | 22 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | |
23 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, | 23 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, | |
24 | * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING | 24 | * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING | |
25 | * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | 25 | * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | |
26 | * POSSIBILITY OF SUCH DAMAGE. | 26 | * POSSIBILITY OF SUCH DAMAGE. | |
27 | */ | 27 | */ | |
28 | 28 | |||
29 | #include <sys/cdefs.h> | 29 | #include <sys/cdefs.h> | |
30 | __KERNEL_RCSID(0, "$NetBSD: if_enet_imx6.c,v 1.5 2019/07/23 06:36:36 hkenken Exp $"); | 30 | __KERNEL_RCSID(0, "$NetBSD: if_enet_imx6.c,v 1.6 2019/07/30 06:26:31 hkenken Exp $"); | |
31 | 31 | |||
32 | #include "locators.h" | 32 | #include "locators.h" | |
33 | #include "imxccm.h" | 33 | #include "imxccm.h" | |
34 | #include "imxocotp.h" | 34 | #include "imxocotp.h" | |
35 | 35 | |||
36 | #include <sys/param.h> | 36 | #include <sys/param.h> | |
37 | #include <sys/device.h> | 37 | #include <sys/device.h> | |
38 | #include <sys/bus.h> | 38 | #include <sys/bus.h> | |
39 | 39 | |||
40 | #include <arm/imx/imx6var.h> | 40 | #include <arm/imx/imx6var.h> | |
41 | #include <arm/imx/imx6_reg.h> | 41 | #include <arm/imx/imx6_reg.h> | |
42 | #include <arm/imx/imx6_ccmreg.h> | 42 | #include <arm/imx/imx6_ccmreg.h> | |
43 | #include <arm/imx/imx6_ccmvar.h> | 43 | #include <arm/imx/imx6_ccmvar.h> | |
44 | #include <arm/imx/imx6_iomuxreg.h> | 44 | #include <arm/imx/imx6_iomuxreg.h> | |
45 | #include <arm/imx/imx6_ocotpreg.h> | 45 | #include <arm/imx/imx6_ocotpreg.h> | |
46 | #include <arm/imx/imx6_ocotpvar.h> | 46 | #include <arm/imx/imx6_ocotpvar.h> | |
47 | #include <arm/imx/if_enetreg.h> | 47 | #include <arm/imx/if_enetreg.h> | |
48 | #include <arm/imx/if_enetvar.h> | 48 | #include <arm/imx/if_enetvar.h> | |
49 | 49 | |||
50 | CFATTACH_DECL_NEW(enet, sizeof(struct enet_softc), | |||
51 | enet_match, enet_attach, NULL, NULL); | |||
52 | ||||
50 | static int enet_init_clocks(struct enet_softc *); | 53 | static int enet_init_clocks(struct enet_softc *); | |
51 | 54 | |||
52 | int | 55 | int | |
53 | enet_match(device_t parent __unused, struct cfdata *match __unused, void *aux) | 56 | enet_match(device_t parent __unused, struct cfdata *match __unused, void *aux) | |
54 | { | 57 | { | |
55 | struct axi_attach_args *aa; | 58 | struct axi_attach_args *aa; | |
56 | 59 | |||
57 | aa = aux; | 60 | aa = aux; | |
58 | 61 | |||
59 | switch (aa->aa_addr) { | 62 | switch (aa->aa_addr) { | |
60 | case (IMX6_AIPS2_BASE + AIPS2_ENET_BASE): | 63 | case (IMX6_AIPS2_BASE + AIPS2_ENET_BASE): | |
61 | return 1; | 64 | return 1; | |
62 | case (IMX6_AIPS1_BASE + AIPS1_ENET2_BASE): | 65 | case (IMX6_AIPS1_BASE + AIPS1_ENET2_BASE): |
--- src/sys/arch/arm/imx/Attic/if_enet_imx7.c 2019/07/23 06:36:36 1.3
+++ src/sys/arch/arm/imx/Attic/if_enet_imx7.c 2019/07/30 06:26:31 1.4
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | /* $NetBSD: if_enet_imx7.c,v 1.3 2019/07/23 06:36:36 hkenken Exp $ */ | 1 | /* $NetBSD: if_enet_imx7.c,v 1.4 2019/07/30 06:26:31 hkenken Exp $ */ | |
2 | 2 | |||
3 | /* | 3 | /* | |
4 | * Copyright (c) 2014 Ryo Shimizu <ryo@nerv.org> | 4 | * Copyright (c) 2014 Ryo Shimizu <ryo@nerv.org> | |
5 | * All rights reserved. | 5 | * All rights reserved. | |
6 | * | 6 | * | |
7 | * Redistribution and use in source and binary forms, with or without | 7 | * Redistribution and use in source and binary forms, with or without | |
8 | * modification, are permitted provided that the following conditions | 8 | * modification, are permitted provided that the following conditions | |
9 | * are met: | 9 | * are met: | |
10 | * 1. Redistributions of source code must retain the above copyright | 10 | * 1. Redistributions of source code must retain the above copyright | |
11 | * notice, this list of conditions and the following disclaimer. | 11 | * notice, this list of conditions and the following disclaimer. | |
12 | * 2. Redistributions in binary form must reproduce the above copyright | 12 | * 2. Redistributions in binary form must reproduce the above copyright | |
13 | * notice, this list of conditions and the following disclaimer in the | 13 | * notice, this list of conditions and the following disclaimer in the | |
14 | * documentation and/or other materials provided with the distribution. | 14 | * documentation and/or other materials provided with the distribution. | |
@@ -17,45 +17,48 @@ | @@ -17,45 +17,48 @@ | |||
17 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | 17 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | |
18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | 18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | |
19 | * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, | 19 | * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, | |
20 | * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | 20 | * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | |
21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR | 21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR | |
22 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | 22 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | |
23 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, | 23 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, | |
24 | * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING | 24 | * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING | |
25 | * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | 25 | * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | |
26 | * POSSIBILITY OF SUCH DAMAGE. | 26 | * POSSIBILITY OF SUCH DAMAGE. | |
27 | */ | 27 | */ | |
28 | 28 | |||
29 | #include <sys/cdefs.h> | 29 | #include <sys/cdefs.h> | |
30 | __KERNEL_RCSID(0, "$NetBSD: if_enet_imx7.c,v 1.3 2019/07/23 06:36:36 hkenken Exp $"); | 30 | __KERNEL_RCSID(0, "$NetBSD: if_enet_imx7.c,v 1.4 2019/07/30 06:26:31 hkenken Exp $"); | |
31 | 31 | |||
32 | #include "locators.h" | 32 | #include "locators.h" | |
33 | #include "imxccm.h" | 33 | #include "imxccm.h" | |
34 | #include "imxocotp.h" | 34 | #include "imxocotp.h" | |
35 | 35 | |||
36 | #include <sys/param.h> | 36 | #include <sys/param.h> | |
37 | #include <sys/device.h> | 37 | #include <sys/device.h> | |
38 | #include <sys/bus.h> | 38 | #include <sys/bus.h> | |
39 | 39 | |||
40 | #include <arm/imx/imx7var.h> | 40 | #include <arm/imx/imx7var.h> | |
41 | #include <arm/imx/imx7reg.h> | 41 | #include <arm/imx/imx7reg.h> | |
42 | #include <arm/imx/imx7_ccmreg.h> | 42 | #include <arm/imx/imx7_ccmreg.h> | |
43 | #include <arm/imx/imx7_ccmvar.h> | 43 | #include <arm/imx/imx7_ccmvar.h> | |
44 | #include <arm/imx/imx7_ocotpreg.h> | 44 | #include <arm/imx/imx7_ocotpreg.h> | |
45 | #include <arm/imx/imx7_ocotpvar.h> | 45 | #include <arm/imx/imx7_ocotpvar.h> | |
46 | #include <arm/imx/if_enetreg.h> | 46 | #include <arm/imx/if_enetreg.h> | |
47 | #include <arm/imx/if_enetvar.h> | 47 | #include <arm/imx/if_enetvar.h> | |
48 | 48 | |||
49 | CFATTACH_DECL_NEW(enet, sizeof(struct enet_softc), | |||
50 | enet_match, enet_attach, NULL, NULL); | |||
51 | ||||
49 | static void get_mac_from_ocotp(struct enet_softc *, device_t self, | 52 | static void get_mac_from_ocotp(struct enet_softc *, device_t self, | |
50 | const char *); | 53 | const char *); | |
51 | 54 | |||
52 | int | 55 | int | |
53 | enet_match(device_t parent __unused, struct cfdata *match __unused, void *aux) | 56 | enet_match(device_t parent __unused, struct cfdata *match __unused, void *aux) | |
54 | { | 57 | { | |
55 | struct axi_attach_args *aa; | 58 | struct axi_attach_args *aa; | |
56 | 59 | |||
57 | aa = aux; | 60 | aa = aux; | |
58 | 61 | |||
59 | switch (aa->aa_addr) { | 62 | switch (aa->aa_addr) { | |
60 | case (IMX7_AIPS_BASE + AIPS3_ENET1_BASE): | 63 | case (IMX7_AIPS_BASE + AIPS3_ENET1_BASE): | |
61 | return 1; | 64 | return 1; |
--- src/sys/arch/arm/imx/fdt/Attic/files.imx6 2019/07/27 08:02:04 1.2
+++ src/sys/arch/arm/imx/fdt/Attic/files.imx6 2019/07/30 06:26:31 1.3
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | # $NetBSD: files.imx6,v 1.2 2019/07/27 08:02:04 skrll Exp $ | 1 | # $NetBSD: files.imx6,v 1.3 2019/07/30 06:26:31 hkenken Exp $ | |
2 | # | 2 | # | |
3 | # Configuration info for the Freescale i.MX6 | 3 | # Configuration info for the Freescale i.MX6 | |
4 | # | 4 | # | |
5 | 5 | |||
6 | file arch/arm/arm32/arm32_boot.c | 6 | file arch/arm/arm32/arm32_boot.c | |
7 | file arch/arm/arm32/arm32_kvminit.c | 7 | file arch/arm/arm32/arm32_kvminit.c | |
8 | file arch/arm/arm32/arm32_reboot.c | 8 | file arch/arm/arm32/arm32_reboot.c | |
9 | file arch/arm/arm32/irq_dispatch.S | 9 | file arch/arm/arm32/irq_dispatch.S | |
10 | file arch/arm/arm32/armv7_generic_space.c | 10 | file arch/arm/arm32/armv7_generic_space.c | |
11 | file arch/arm/arm/arm_generic_dma.c | 11 | file arch/arm/arm/arm_generic_dma.c | |
12 | file arch/arm/arm/bus_space_a4x.S | 12 | file arch/arm/arm/bus_space_a4x.S | |
13 | 13 | |||
14 | file arch/arm/imx/fdt/imx6_platform.c soc_imx | 14 | file arch/arm/imx/fdt/imx6_platform.c soc_imx | |
@@ -38,29 +38,29 @@ device imxgpio: gpiobus | @@ -38,29 +38,29 @@ device imxgpio: gpiobus | |||
38 | attach imxgpio at fdt | 38 | attach imxgpio at fdt | |
39 | file arch/arm/imx/imxgpio.c imxgpio needs-flag | 39 | file arch/arm/imx/imxgpio.c imxgpio needs-flag | |
40 | file arch/arm/imx/fdt/imx6_gpio.c imxgpio | 40 | file arch/arm/imx/fdt/imx6_gpio.c imxgpio | |
41 | 41 | |||
42 | # UART | 42 | # UART | |
43 | device imxuart { } : bus_space_generic | 43 | device imxuart { } : bus_space_generic | |
44 | attach imxuart at fdt with imx6_com | 44 | attach imxuart at fdt with imx6_com | |
45 | file arch/arm/imx/imxuart.c imxuart needs-flag | 45 | file arch/arm/imx/imxuart.c imxuart needs-flag | |
46 | file arch/arm/imx/fdt/imx6_com.c imx6_com needs-flag | 46 | file arch/arm/imx/fdt/imx6_com.c imx6_com needs-flag | |
47 | defflag opt_imxuart.h IMXUARTCONSOLE | 47 | defflag opt_imxuart.h IMXUARTCONSOLE | |
48 | 48 | |||
49 | # FEC | 49 | # FEC | |
50 | device enet: ether, ifnet, arp, mii, bus_dma_generic | 50 | device enet: ether, ifnet, arp, mii, bus_dma_generic | |
51 | attach enet at fdt | 51 | attach enet at fdt with enet_fdt | |
52 | file arch/arm/imx/if_enet.c enet | 52 | file arch/arm/imx/if_enet.c enet | |
53 | file arch/arm/imx/fdt/if_enet_imx.c enet | 53 | file arch/arm/imx/fdt/if_enet_imx.c enet_fdt | |
54 | 54 | |||
55 | # SATA | 55 | # SATA | |
56 | attach ahcisata at fdt with imx6_ahcisata | 56 | attach ahcisata at fdt with imx6_ahcisata | |
57 | file arch/arm/imx/fdt/imx6_ahcisata.c imx6_ahcisata | 57 | file arch/arm/imx/fdt/imx6_ahcisata.c imx6_ahcisata | |
58 | 58 | |||
59 | # USB Controller | 59 | # USB Controller | |
60 | device imxusbc { [unit=-1], [irq=-1] } : bus_dma_generic | 60 | device imxusbc { [unit=-1], [irq=-1] } : bus_dma_generic | |
61 | attach imxusbc at fdt with imxusbc_fdt | 61 | attach imxusbc at fdt with imxusbc_fdt | |
62 | file arch/arm/imx/fdt/imx6_usb.c imxusbc_fdt | 62 | file arch/arm/imx/fdt/imx6_usb.c imxusbc_fdt | |
63 | 63 | |||
64 | attach ehci at imxusbc with imxehci | 64 | attach ehci at imxusbc with imxehci | |
65 | file arch/arm/imx/imxusb.c imxehci | 65 | file arch/arm/imx/imxusb.c imxehci | |
66 | 66 |
--- src/sys/arch/arm/imx/fdt/Attic/if_enet_imx.c 2019/07/24 13:12:33 1.1
+++ src/sys/arch/arm/imx/fdt/Attic/if_enet_imx.c 2019/07/30 06:26:31 1.2
@@ -1,75 +1,85 @@ | @@ -1,75 +1,85 @@ | |||
1 | /* $NetBSD: if_enet_imx.c,v 1.1 2019/07/24 13:12:33 hkenken Exp $ */ | 1 | /* $NetBSD: if_enet_imx.c,v 1.2 2019/07/30 06:26:31 hkenken Exp $ */ | |
2 | /*- | 2 | /*- | |
3 | * Copyright (c) 2019 Genetec Corporation. All rights reserved. | 3 | * Copyright (c) 2019 Genetec Corporation. All rights reserved. | |
4 | * Written by Hashimoto Kenichi for Genetec Corporation. | 4 | * Written by Hashimoto Kenichi for Genetec Corporation. | |
5 | * | 5 | * | |
6 | * Redistribution and use in source and binary forms, with or without | 6 | * Redistribution and use in source and binary forms, with or without | |
7 | * modification, are permitted provided that the following conditions | 7 | * modification, are permitted provided that the following conditions | |
8 | * are met: | 8 | * are met: | |
9 | * 1. Redistributions of source code must retain the above copyright | 9 | * 1. Redistributions of source code must retain the above copyright | |
10 | * notice, this list of conditions and the following disclaimer. | 10 | * notice, this list of conditions and the following disclaimer. | |
11 | * 2. Redistributions in binary form must reproduce the above copyright | 11 | * 2. Redistributions in binary form must reproduce the above copyright | |
12 | * notice, this list of conditions and the following disclaimer in the | 12 | * notice, this list of conditions and the following disclaimer in the | |
13 | * documentation and/or other materials provided with the distribution. | 13 | * documentation and/or other materials provided with the distribution. | |
14 | * | 14 | * | |
15 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR | 15 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR | |
16 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES | 16 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES | |
17 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. | 17 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. | |
18 | * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, | 18 | * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, | |
19 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, | 19 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, | |
20 | * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | 20 | * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | |
21 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED | 21 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED | |
22 | * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, | 22 | * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, | |
23 | * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | 23 | * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | |
24 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | 24 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | |
25 | * SUCH DAMAGE. | 25 | * SUCH DAMAGE. | |
26 | */ | 26 | */ | |
27 | #include <sys/cdefs.h> | 27 | #include <sys/cdefs.h> | |
28 | __KERNEL_RCSID(0, "$NetBSD: if_enet_imx.c,v 1.1 2019/07/24 13:12:33 hkenken Exp $"); | 28 | __KERNEL_RCSID(0, "$NetBSD: if_enet_imx.c,v 1.2 2019/07/30 06:26:31 hkenken Exp $"); | |
29 | 29 | |||
30 | #include "opt_fdt.h" | 30 | #include "opt_fdt.h" | |
31 | 31 | |||
32 | #include <sys/param.h> | 32 | #include <sys/param.h> | |
33 | #include <sys/bus.h> | 33 | #include <sys/bus.h> | |
34 | #include <sys/device.h> | 34 | #include <sys/device.h> | |
35 | 35 | |||
36 | #include <arm/imx/imx6var.h> | 36 | #include <arm/imx/imx6var.h> | |
37 | #include <arm/imx/imx6_reg.h> | 37 | #include <arm/imx/imx6_reg.h> | |
38 | #include <arm/imx/if_enetreg.h> | 38 | #include <arm/imx/if_enetreg.h> | |
39 | #include <arm/imx/if_enetvar.h> | 39 | #include <arm/imx/if_enetvar.h> | |
40 | 40 | |||
41 | #include <dev/fdt/fdtvar.h> | 41 | #include <dev/fdt/fdtvar.h> | |
42 | 42 | |||
43 | struct enet_fdt_softc { | |||
44 | struct enet_softc sc_enet; | |||
45 | ||||
46 | struct fdtbus_gpio_pin *sc_pin_reset; | |||
47 | }; | |||
48 | ||||
49 | CFATTACH_DECL_NEW(enet_fdt, sizeof(struct enet_fdt_softc), | |||
50 | enet_match, enet_attach, NULL, NULL); | |||
51 | ||||
43 | static const char * const compatible[] = { | 52 | static const char * const compatible[] = { | |
44 | "fsl,imx6q-fec", | 53 | "fsl,imx6q-fec", | |
45 | NULL | 54 | NULL | |
46 | }; | 55 | }; | |
47 | 56 | |||
48 | static int enet_init_clocks(struct enet_softc *); | 57 | static int enet_init_clocks(struct enet_softc *); | |
49 | static void enet_phy_reset(const int); | 58 | static void enet_phy_reset(struct enet_fdt_softc *, const int); | |
50 | 59 | |||
51 | int | 60 | int | |
52 | enet_match(device_t parent, cfdata_t cf, void *aux) | 61 | enet_match(device_t parent, cfdata_t cf, void *aux) | |
53 | { | 62 | { | |
54 | struct fdt_attach_args * const faa = aux; | 63 | struct fdt_attach_args * const faa = aux; | |
55 | 64 | |||
56 | return of_match_compatible(faa->faa_phandle, compatible); | 65 | return of_match_compatible(faa->faa_phandle, compatible); | |
57 | } | 66 | } | |
58 | 67 | |||
59 | void | 68 | void | |
60 | enet_attach(device_t parent, device_t self, void *aux) | 69 | enet_attach(device_t parent, device_t self, void *aux) | |
61 | { | 70 | { | |
62 | struct enet_softc *sc = device_private(self); | 71 | struct enet_fdt_softc * const efsc = device_private(self); | |
72 | struct enet_softc *sc = &efsc->sc_enet; | |||
63 | struct fdt_attach_args * const faa = aux; | 73 | struct fdt_attach_args * const faa = aux; | |
64 | const int phandle = faa->faa_phandle; | 74 | const int phandle = faa->faa_phandle; | |
65 | bus_space_tag_t bst = faa->faa_bst; | 75 | bus_space_tag_t bst = faa->faa_bst; | |
66 | bus_space_handle_t bsh; | 76 | bus_space_handle_t bsh; | |
67 | bus_addr_t addr; | 77 | bus_addr_t addr; | |
68 | bus_size_t size; | 78 | bus_size_t size; | |
69 | int error; | 79 | int error; | |
70 | 80 | |||
71 | if (fdtbus_get_reg(phandle, 0, &addr, &size) != 0) { | 81 | if (fdtbus_get_reg(phandle, 0, &addr, &size) != 0) { | |
72 | aprint_error(": couldn't get enet registers\n"); | 82 | aprint_error(": couldn't get enet registers\n"); | |
73 | return; | 83 | return; | |
74 | } | 84 | } | |
75 | 85 | |||
@@ -83,27 +93,27 @@ enet_attach(device_t parent, device_t se | @@ -83,27 +93,27 @@ enet_attach(device_t parent, device_t se | |||
83 | if (sc->sc_clk_enet == NULL) { | 93 | if (sc->sc_clk_enet == NULL) { | |
84 | aprint_error(": couldn't get clock ahb\n"); | 94 | aprint_error(": couldn't get clock ahb\n"); | |
85 | goto failure; | 95 | goto failure; | |
86 | } | 96 | } | |
87 | sc->sc_clk_enet_ref= fdtbus_clock_get(phandle, "ptp"); | 97 | sc->sc_clk_enet_ref= fdtbus_clock_get(phandle, "ptp"); | |
88 | if (sc->sc_clk_enet_ref == NULL) { | 98 | if (sc->sc_clk_enet_ref == NULL) { | |
89 | aprint_error(": couldn't get clock ptp\n"); | 99 | aprint_error(": couldn't get clock ptp\n"); | |
90 | goto failure; | 100 | goto failure; | |
91 | } | 101 | } | |
92 | 102 | |||
93 | aprint_naive("\n"); | 103 | aprint_naive("\n"); | |
94 | aprint_normal(": Gigabit Ethernet Controller\n"); | 104 | aprint_normal(": Gigabit Ethernet Controller\n"); | |
95 | 105 | |||
96 | enet_phy_reset(phandle); | 106 | enet_phy_reset(efsc, phandle); | |
97 | 107 | |||
98 | sc->sc_dev = self; | 108 | sc->sc_dev = self; | |
99 | sc->sc_iot = bst; | 109 | sc->sc_iot = bst; | |
100 | sc->sc_ioh = bsh; | 110 | sc->sc_ioh = bsh; | |
101 | sc->sc_dmat = faa->faa_dmat; | 111 | sc->sc_dmat = faa->faa_dmat; | |
102 | 112 | |||
103 | sc->sc_imxtype = 6; /* i.MX6 */ | 113 | sc->sc_imxtype = 6; /* i.MX6 */ | |
104 | sc->sc_rgmii = 1; | 114 | sc->sc_rgmii = 1; | |
105 | 115 | |||
106 | char intrstr[128]; | 116 | char intrstr[128]; | |
107 | if (!fdtbus_intr_str(phandle, 0, intrstr, sizeof(intrstr))) { | 117 | if (!fdtbus_intr_str(phandle, 0, intrstr, sizeof(intrstr))) { | |
108 | aprint_error_dev(self, "failed to decode interrupt\n"); | 118 | aprint_error_dev(self, "failed to decode interrupt\n"); | |
109 | goto failure; | 119 | goto failure; | |
@@ -140,34 +150,31 @@ enet_init_clocks(struct enet_softc *sc) | @@ -140,34 +150,31 @@ enet_init_clocks(struct enet_softc *sc) | |||
140 | aprint_error_dev(sc->sc_dev, "couldn't enable enet: %d\n", error); | 150 | aprint_error_dev(sc->sc_dev, "couldn't enable enet: %d\n", error); | |
141 | return error; | 151 | return error; | |
142 | } | 152 | } | |
143 | error = clk_enable(sc->sc_clk_enet_ref); | 153 | error = clk_enable(sc->sc_clk_enet_ref); | |
144 | if (error) { | 154 | if (error) { | |
145 | aprint_error_dev(sc->sc_dev, "couldn't enable enet_ref: %d\n", error); | 155 | aprint_error_dev(sc->sc_dev, "couldn't enable enet_ref: %d\n", error); | |
146 | return error; | 156 | return error; | |
147 | } | 157 | } | |
148 | 158 | |||
149 | return 0; | 159 | return 0; | |
150 | } | 160 | } | |
151 | 161 | |||
152 | static void | 162 | static void | |
153 | enet_phy_reset(const int phandle) | 163 | enet_phy_reset(struct enet_fdt_softc *sc, const int phandle) | |
154 | { | 164 | { | |
155 | struct fdtbus_gpio_pin *reset; | |||
156 | int error; | 165 | int error; | |
157 | 166 | |||
158 | reset = fdtbus_gpio_acquire(phandle, "phy-reset-gpios", GPIO_PIN_OUTPUT); | 167 | sc->sc_pin_reset = fdtbus_gpio_acquire(phandle, "phy-reset-gpios", GPIO_PIN_OUTPUT); | |
159 | if (reset == NULL) | 168 | if (sc->sc_pin_reset == NULL) | |
160 | return; | 169 | return; | |
161 | 170 | |||
162 | u_int msec; | 171 | u_int msec; | |
163 | error = of_getprop_uint32(phandle, "phy-reset-duration", &msec); | 172 | error = of_getprop_uint32(phandle, "phy-reset-duration", &msec); | |
164 | if (error) | 173 | if (error) | |
165 | msec = 1; | 174 | msec = 1; | |
166 | 175 | |||
167 | /* Reset */ | 176 | /* Reset */ | |
168 | fdtbus_gpio_write(reset, 1); | 177 | fdtbus_gpio_write(sc->sc_pin_reset, 1); | |
169 | delay(msec * 1000); | 178 | delay(msec * 1000); | |
170 | fdtbus_gpio_write(reset, 0); | 179 | fdtbus_gpio_write(sc->sc_pin_reset, 0); | |
171 | ||||
172 | fdtbus_gpio_release(reset); | |||
173 | } | 180 | } |