#include <sys/param.h>diff -r1.3 -r1.4 src/sys/arch/arm/allwinner/awin_com.c
(matt)
--- src/sys/arch/arm/allwinner/Attic/awin_com.c 2013/09/07 01:50:12 1.3
+++ src/sys/arch/arm/allwinner/Attic/awin_com.c 2014/02/20 21:48:38 1.4
@@ -1,158 +1,159 @@ | @@ -1,158 +1,159 @@ | |||
1 | /*- | 1 | /*- | |
2 | * Copyright (c) 2013 The NetBSD Foundation, Inc. | 2 | * Copyright (c) 2013 The NetBSD Foundation, Inc. | |
3 | * All rights reserved. | 3 | * All rights reserved. | |
4 | * | 4 | * | |
5 | * This code is derived from software contributed to The NetBSD Foundation | 5 | * This code is derived from software contributed to The NetBSD Foundation | |
6 | * by Matt Thomas of 3am Software Foundry. | 6 | * by Matt Thomas of 3am Software Foundry. | |
7 | * | 7 | * | |
8 | * Redistribution and use in source and binary forms, with or without | 8 | * Redistribution and use in source and binary forms, with or without | |
9 | * modification, are permitted provided that the following conditions | 9 | * modification, are permitted provided that the following conditions | |
10 | * are met: | 10 | * are met: | |
11 | * 1. Redistributions of source code must retain the above copyright | 11 | * 1. Redistributions of source code must retain the above copyright | |
12 | * notice, this list of conditions and the following disclaimer. | 12 | * notice, this list of conditions and the following disclaimer. | |
13 | * 2. Redistributions in binary form must reproduce the above copyright | 13 | * 2. Redistributions in binary form must reproduce the above copyright | |
14 | * notice, this list of conditions and the following disclaimer in the | 14 | * notice, this list of conditions and the following disclaimer in the | |
15 | * documentation and/or other materials provided with the distribution. | 15 | * documentation and/or other materials provided with the distribution. | |
16 | * | 16 | * | |
17 | * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS | 17 | * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS | |
18 | * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED | 18 | * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED | |
19 | * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR | 19 | * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR | |
20 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS | 20 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS | |
21 | * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR | 21 | * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR | |
22 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF | 22 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF | |
23 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS | 23 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS | |
24 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN | 24 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN | |
25 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | 25 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | |
26 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | 26 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | |
27 | * POSSIBILITY OF SUCH DAMAGE. | 27 | * POSSIBILITY OF SUCH DAMAGE. | |
28 | */ | 28 | */ | |
29 | 29 | |||
30 | #include "locators.h" | 30 | #include "locators.h" | |
31 | 31 | |||
32 | #include <sys/cdefs.h> | 32 | #include <sys/cdefs.h> | |
33 | 33 | |||
34 | __KERNEL_RCSID(1, "$NetBSD: awin_com.c,v 1.3 2013/09/07 01:50:12 matt Exp $"); | 34 | __KERNEL_RCSID(1, "$NetBSD: awin_com.c,v 1.4 2014/02/20 21:48:38 matt Exp $"); | |
35 | 35 | |||
36 | #include <sys/param.h> | |||
36 | #include <sys/bus.h> | 37 | #include <sys/bus.h> | |
37 | #include <sys/device.h> | 38 | #include <sys/device.h> | |
38 | #include <sys/intr.h> | 39 | #include <sys/intr.h> | |
39 | #include <sys/systm.h> | 40 | #include <sys/systm.h> | |
40 | #include <sys/time.h> | 41 | #include <sys/time.h> | |
41 | #include <sys/termios.h> | 42 | #include <sys/termios.h> | |
42 | 43 | |||
43 | #include <arm/allwinner/awin_reg.h> | 44 | #include <arm/allwinner/awin_reg.h> | |
44 | #include <arm/allwinner/awin_var.h> | 45 | #include <arm/allwinner/awin_var.h> | |
45 | 46 | |||
46 | #include <dev/ic/comvar.h> | 47 | #include <dev/ic/comvar.h> | |
47 | 48 | |||
48 | static int awin_com_match(device_t, cfdata_t, void *); | 49 | static int awin_com_match(device_t, cfdata_t, void *); | |
49 | static void awin_com_attach(device_t, device_t, void *); | 50 | static void awin_com_attach(device_t, device_t, void *); | |
50 | 51 | |||
51 | struct awin_com_softc { | 52 | struct awin_com_softc { | |
52 | struct com_softc asc_sc; | 53 | struct com_softc asc_sc; | |
53 | void *asc_ih; | 54 | void *asc_ih; | |
54 | }; | 55 | }; | |
55 | 56 | |||
56 | static const struct awin_gpio_pinset awin_com_pinsets[] = { | 57 | static const struct awin_gpio_pinset awin_com_pinsets[] = { | |
57 | { 'B', AWIN_PIO_PB_UART0_FUNC, AWIN_PIO_PB_UART0_PINS }, | 58 | { 'B', AWIN_PIO_PB_UART0_FUNC, AWIN_PIO_PB_UART0_PINS }, | |
58 | { 'A', AWIN_PIO_PA_UART1_FUNC, AWIN_PIO_PA_UART1_PINS }, | 59 | { 'A', AWIN_PIO_PA_UART1_FUNC, AWIN_PIO_PA_UART1_PINS }, | |
59 | { 'I', AWIN_PIO_PI_UART2_FUNC, AWIN_PIO_PI_UART2_PINS }, | 60 | { 'I', AWIN_PIO_PI_UART2_FUNC, AWIN_PIO_PI_UART2_PINS }, | |
60 | { 'H', AWIN_PIO_PH_UART3_FUNC, AWIN_PIO_PH_UART3_PINS }, | 61 | { 'H', AWIN_PIO_PH_UART3_FUNC, AWIN_PIO_PH_UART3_PINS }, | |
61 | { 'H', AWIN_PIO_PH_UART4_FUNC, AWIN_PIO_PH_UART4_PINS }, | 62 | { 'H', AWIN_PIO_PH_UART4_FUNC, AWIN_PIO_PH_UART4_PINS }, | |
62 | { 'H', AWIN_PIO_PH_UART5_FUNC, AWIN_PIO_PH_UART5_PINS }, | 63 | { 'H', AWIN_PIO_PH_UART5_FUNC, AWIN_PIO_PH_UART5_PINS }, | |
63 | { 'I', AWIN_PIO_PI_UART6_FUNC, AWIN_PIO_PI_UART6_PINS }, | 64 | { 'I', AWIN_PIO_PI_UART6_FUNC, AWIN_PIO_PI_UART6_PINS }, | |
64 | { 'I', AWIN_PIO_PI_UART7_FUNC, AWIN_PIO_PI_UART7_PINS }, | 65 | { 'I', AWIN_PIO_PI_UART7_FUNC, AWIN_PIO_PI_UART7_PINS }, | |
65 | }; | 66 | }; | |
66 | 67 | |||
67 | /* alternative pinnings */ | 68 | /* alternative pinnings */ | |
68 | static const struct awin_gpio_pinset awin_com_alt_pinsets[] = { | 69 | static const struct awin_gpio_pinset awin_com_alt_pinsets[] = { | |
69 | { 'F', AWIN_PIO_PF_UART0_FUNC, AWIN_PIO_PF_UART0_PINS }, | 70 | { 'F', AWIN_PIO_PF_UART0_FUNC, AWIN_PIO_PF_UART0_PINS }, | |
70 | { 0, 0, 0}, | 71 | { 0, 0, 0}, | |
71 | { 'A', AWIN_PIO_PA_UART2_FUNC, AWIN_PIO_PA_UART2_PINS }, | 72 | { 'A', AWIN_PIO_PA_UART2_FUNC, AWIN_PIO_PA_UART2_PINS }, | |
72 | { 'G', AWIN_PIO_PG_UART3_FUNC, AWIN_PIO_PG_UART3_PINS }, | 73 | { 'G', AWIN_PIO_PG_UART3_FUNC, AWIN_PIO_PG_UART3_PINS }, | |
73 | { 'G', AWIN_PIO_PG_UART4_FUNC, AWIN_PIO_PG_UART4_PINS }, | 74 | { 'G', AWIN_PIO_PG_UART4_FUNC, AWIN_PIO_PG_UART4_PINS }, | |
74 | { 'I', AWIN_PIO_PI_UART5_FUNC, AWIN_PIO_PI_UART5_PINS }, | 75 | { 'I', AWIN_PIO_PI_UART5_FUNC, AWIN_PIO_PI_UART5_PINS }, | |
75 | { 'A', AWIN_PIO_PA_UART6_FUNC, AWIN_PIO_PA_UART6_PINS }, | 76 | { 'A', AWIN_PIO_PA_UART6_FUNC, AWIN_PIO_PA_UART6_PINS }, | |
76 | { 'A', AWIN_PIO_PA_UART7_FUNC, AWIN_PIO_PA_UART7_PINS }, | 77 | { 'A', AWIN_PIO_PA_UART7_FUNC, AWIN_PIO_PA_UART7_PINS }, | |
77 | }; | 78 | }; | |
78 | 79 | |||
79 | CFATTACH_DECL_NEW(awin_com, sizeof(struct awin_com_softc), | 80 | CFATTACH_DECL_NEW(awin_com, sizeof(struct awin_com_softc), | |
80 | awin_com_match, awin_com_attach, NULL, NULL); | 81 | awin_com_match, awin_com_attach, NULL, NULL); | |
81 | 82 | |||
82 | static int awin_com_ports; | 83 | static int awin_com_ports; | |
83 | 84 | |||
84 | static int | 85 | static int | |
85 | awin_com_match(device_t parent, cfdata_t cf, void *aux) | 86 | awin_com_match(device_t parent, cfdata_t cf, void *aux) | |
86 | { | 87 | { | |
87 | struct awinio_attach_args * const aio = aux; | 88 | struct awinio_attach_args * const aio = aux; | |
88 | const struct awin_locators * const loc = &aio->aio_loc; | 89 | const struct awin_locators * const loc = &aio->aio_loc; | |
89 | bus_space_tag_t iot = aio->aio_core_a4x_bst; | 90 | bus_space_tag_t iot = aio->aio_core_a4x_bst; | |
90 | bus_space_handle_t bsh; | 91 | bus_space_handle_t bsh; | |
91 | const struct awin_gpio_pinset * const pinset = loc->loc_port + | 92 | const struct awin_gpio_pinset * const pinset = loc->loc_port + | |
92 | ((cf->cf_flags & 1) ? awin_com_alt_pinsets : awin_com_pinsets); | 93 | ((cf->cf_flags & 1) ? awin_com_alt_pinsets : awin_com_pinsets); | |
93 | 94 | |||
94 | KASSERT(!strcmp(cf->cf_name, loc->loc_name)); | 95 | KASSERT(!strcmp(cf->cf_name, loc->loc_name)); | |
95 | KASSERT(loc->loc_offset >= AWIN_UART0_OFFSET); | 96 | KASSERT(loc->loc_offset >= AWIN_UART0_OFFSET); | |
96 | KASSERT(loc->loc_offset <= AWIN_UART7_OFFSET); | 97 | KASSERT(loc->loc_offset <= AWIN_UART7_OFFSET); | |
97 | KASSERT((loc->loc_offset & 0x3ff) == 0); | 98 | KASSERT((loc->loc_offset & 0x3ff) == 0); | |
98 | KASSERT((awin_com_ports & __BIT(loc->loc_port)) == 0); | 99 | KASSERT((awin_com_ports & __BIT(loc->loc_port)) == 0); | |
99 | KASSERT(cf->cf_loc[AWINIOCF_PORT] == AWINIOCF_PORT_DEFAULT | 100 | KASSERT(cf->cf_loc[AWINIOCF_PORT] == AWINIOCF_PORT_DEFAULT | |
100 | || cf->cf_loc[AWINIOCF_PORT] == loc->loc_port); | 101 | || cf->cf_loc[AWINIOCF_PORT] == loc->loc_port); | |
101 | 102 | |||
102 | if (!awin_gpio_pinset_available(pinset)) | 103 | if (!awin_gpio_pinset_available(pinset)) | |
103 | return 0; | 104 | return 0; | |
104 | 105 | |||
105 | if (com_is_console(iot, AWIN_CORE_PBASE + loc->loc_offset, NULL)) | 106 | if (com_is_console(iot, AWIN_CORE_PBASE + loc->loc_offset, NULL)) | |
106 | return 1; | 107 | return 1; | |
107 | 108 | |||
108 | awin_gpio_pinset_acquire(pinset); | 109 | awin_gpio_pinset_acquire(pinset); | |
109 | 110 | |||
110 | bus_space_subregion(iot, aio->aio_core_bsh, | 111 | bus_space_subregion(iot, aio->aio_core_bsh, | |
111 | loc->loc_offset, loc->loc_size, &bsh); | 112 | loc->loc_offset, loc->loc_size, &bsh); | |
112 | 113 | |||
113 | const int rv = comprobe1(iot, bsh); | 114 | const int rv = comprobe1(iot, bsh); | |
114 | 115 | |||
115 | awin_gpio_pinset_release(pinset); | 116 | awin_gpio_pinset_release(pinset); | |
116 | 117 | |||
117 | return rv; | 118 | return rv; | |
118 | } | 119 | } | |
119 | 120 | |||
120 | static void | 121 | static void | |
121 | awin_com_attach(device_t parent, device_t self, void *aux) | 122 | awin_com_attach(device_t parent, device_t self, void *aux) | |
122 | { | 123 | { | |
123 | cfdata_t cf = device_cfdata(self); | 124 | cfdata_t cf = device_cfdata(self); | |
124 | struct awin_com_softc * const asc = device_private(self); | 125 | struct awin_com_softc * const asc = device_private(self); | |
125 | struct com_softc * const sc = &asc->asc_sc; | 126 | struct com_softc * const sc = &asc->asc_sc; | |
126 | struct awinio_attach_args * const aio = aux; | 127 | struct awinio_attach_args * const aio = aux; | |
127 | const struct awin_locators * const loc = &aio->aio_loc; | 128 | const struct awin_locators * const loc = &aio->aio_loc; | |
128 | bus_space_tag_t iot = aio->aio_core_a4x_bst; | 129 | bus_space_tag_t iot = aio->aio_core_a4x_bst; | |
129 | const bus_addr_t iobase = AWIN_CORE_PBASE + loc->loc_offset; | 130 | const bus_addr_t iobase = AWIN_CORE_PBASE + loc->loc_offset; | |
130 | const struct awin_gpio_pinset * const pinset = loc->loc_port + | 131 | const struct awin_gpio_pinset * const pinset = loc->loc_port + | |
131 | ((cf->cf_flags & 1) ? awin_com_alt_pinsets : awin_com_pinsets); | 132 | ((cf->cf_flags & 1) ? awin_com_alt_pinsets : awin_com_pinsets); | |
132 | bus_space_handle_t ioh; | 133 | bus_space_handle_t ioh; | |
133 | 134 | |||
134 | awin_com_ports |= __BIT(loc->loc_port); | 135 | awin_com_ports |= __BIT(loc->loc_port); | |
135 | 136 | |||
136 | awin_gpio_pinset_acquire(pinset); | 137 | awin_gpio_pinset_acquire(pinset); | |
137 | 138 | |||
138 | sc->sc_dev = self; | 139 | sc->sc_dev = self; | |
139 | sc->sc_frequency = AWIN_UART_FREQ; | 140 | sc->sc_frequency = AWIN_UART_FREQ; | |
140 | sc->sc_type = COM_TYPE_NORMAL; | 141 | sc->sc_type = COM_TYPE_NORMAL; | |
141 | 142 | |||
142 | if (com_is_console(iot, iobase, &ioh) == 0 | 143 | if (com_is_console(iot, iobase, &ioh) == 0 | |
143 | && bus_space_subregion(iot, aio->aio_core_bsh, | 144 | && bus_space_subregion(iot, aio->aio_core_bsh, | |
144 | loc->loc_offset / 4, loc->loc_size, &ioh)) { | 145 | loc->loc_offset / 4, loc->loc_size, &ioh)) { | |
145 | panic(": can't map registers"); | 146 | panic(": can't map registers"); | |
146 | } | 147 | } | |
147 | COM_INIT_REGS(sc->sc_regs, iot, ioh, iobase); | 148 | COM_INIT_REGS(sc->sc_regs, iot, ioh, iobase); | |
148 | 149 | |||
149 | com_attach_subr(sc); | 150 | com_attach_subr(sc); | |
150 | aprint_naive("\n"); | 151 | aprint_naive("\n"); | |
151 | 152 | |||
152 | KASSERT(loc->loc_intr != AWINIO_INTR_DEFAULT); | 153 | KASSERT(loc->loc_intr != AWINIO_INTR_DEFAULT); | |
153 | asc->asc_ih = intr_establish(loc->loc_intr, IPL_SERIAL, IST_EDGE, | 154 | asc->asc_ih = intr_establish(loc->loc_intr, IPL_SERIAL, IST_EDGE, | |
154 | comintr, sc); | 155 | comintr, sc); | |
155 | if (asc->asc_ih == NULL) | 156 | if (asc->asc_ih == NULL) | |
156 | panic("%s: failed to establish interrupt %d", | 157 | panic("%s: failed to establish interrupt %d", | |
157 | device_xname(self), loc->loc_intr); | 158 | device_xname(self), loc->loc_intr); | |
158 | } | 159 | } |
--- src/sys/arch/arm/allwinner/Attic/awin_sdhc.c 2013/09/07 00:35:52 1.3
+++ src/sys/arch/arm/allwinner/Attic/awin_sdhc.c 2014/02/20 21:48:38 1.4
@@ -1,152 +1,153 @@ | @@ -1,152 +1,153 @@ | |||
1 | /*- | 1 | /*- | |
2 | * Copyright (c) 2012 The NetBSD Foundation, Inc. | 2 | * Copyright (c) 2012 The NetBSD Foundation, Inc. | |
3 | * All rights reserved. | 3 | * All rights reserved. | |
4 | * | 4 | * | |
5 | * This code is derived from software contributed to The NetBSD Foundation | 5 | * This code is derived from software contributed to The NetBSD Foundation | |
6 | * by Matt Thomas of 3am Software Foundry. | 6 | * by Matt Thomas of 3am Software Foundry. | |
7 | * | 7 | * | |
8 | * Redistribution and use in source and binary forms, with or without | 8 | * Redistribution and use in source and binary forms, with or without | |
9 | * modification, are permitted provided that the following conditions | 9 | * modification, are permitted provided that the following conditions | |
10 | * are met: | 10 | * are met: | |
11 | * 1. Redistributions of source code must retain the above copyright | 11 | * 1. Redistributions of source code must retain the above copyright | |
12 | * notice, this list of conditions and the following disclaimer. | 12 | * notice, this list of conditions and the following disclaimer. | |
13 | * 2. Redistributions in binary form must reproduce the above copyright | 13 | * 2. Redistributions in binary form must reproduce the above copyright | |
14 | * notice, this list of conditions and the following disclaimer in the | 14 | * notice, this list of conditions and the following disclaimer in the | |
15 | * documentation and/or other materials provided with the distribution. | 15 | * documentation and/or other materials provided with the distribution. | |
16 | * | 16 | * | |
17 | * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS | 17 | * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS | |
18 | * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED | 18 | * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED | |
19 | * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR | 19 | * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR | |
20 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS | 20 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS | |
21 | * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR | 21 | * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR | |
22 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF | 22 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF | |
23 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS | 23 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS | |
24 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN | 24 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN | |
25 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | 25 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | |
26 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | 26 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | |
27 | * POSSIBILITY OF SUCH DAMAGE. | 27 | * POSSIBILITY OF SUCH DAMAGE. | |
28 | */ | 28 | */ | |
29 | 29 | |||
30 | #include "locators.h" | 30 | #include "locators.h" | |
31 | 31 | |||
32 | #include <sys/cdefs.h> | 32 | #include <sys/cdefs.h> | |
33 | 33 | |||
34 | __KERNEL_RCSID(1, "$NetBSD: awin_sdhc.c,v 1.3 2013/09/07 00:35:52 matt Exp $"); | 34 | __KERNEL_RCSID(1, "$NetBSD: awin_sdhc.c,v 1.4 2014/02/20 21:48:38 matt Exp $"); | |
35 | 35 | |||
36 | #include <sys/param.h> | |||
36 | #include <sys/bus.h> | 37 | #include <sys/bus.h> | |
37 | #include <sys/device.h> | 38 | #include <sys/device.h> | |
38 | #include <sys/intr.h> | 39 | #include <sys/intr.h> | |
39 | #include <sys/systm.h> | 40 | #include <sys/systm.h> | |
40 | 41 | |||
41 | #include <arm/allwinner/awin_reg.h> | 42 | #include <arm/allwinner/awin_reg.h> | |
42 | #include <arm/allwinner/awin_var.h> | 43 | #include <arm/allwinner/awin_var.h> | |
43 | 44 | |||
44 | #include <dev/sdmmc/sdhcreg.h> | 45 | #include <dev/sdmmc/sdhcreg.h> | |
45 | #include <dev/sdmmc/sdhcvar.h> | 46 | #include <dev/sdmmc/sdhcvar.h> | |
46 | 47 | |||
47 | static int awin_sdhc_match(device_t, cfdata_t, void *); | 48 | static int awin_sdhc_match(device_t, cfdata_t, void *); | |
48 | static void awin_sdhc_attach(device_t, device_t, void *); | 49 | static void awin_sdhc_attach(device_t, device_t, void *); | |
49 | 50 | |||
50 | struct awin_sdhc_softc { | 51 | struct awin_sdhc_softc { | |
51 | struct sdhc_softc asc_sc; | 52 | struct sdhc_softc asc_sc; | |
52 | bus_space_tag_t asc_bst; | 53 | bus_space_tag_t asc_bst; | |
53 | bus_space_handle_t asc_bsh; | 54 | bus_space_handle_t asc_bsh; | |
54 | struct sdhc_host *asc_hosts[1]; | 55 | struct sdhc_host *asc_hosts[1]; | |
55 | void *asc_ih; | 56 | void *asc_ih; | |
56 | }; | 57 | }; | |
57 | 58 | |||
58 | static const struct awin_gpio_pinset awin_sdhc_pinsets[] = { | 59 | static const struct awin_gpio_pinset awin_sdhc_pinsets[] = { | |
59 | { 'F', AWIN_PIO_PF_SDC0_FUNC, AWIN_PIO_PF_SDC0_PINS }, | 60 | { 'F', AWIN_PIO_PF_SDC0_FUNC, AWIN_PIO_PF_SDC0_PINS }, | |
60 | { 'G', AWIN_PIO_PG_SDC1_FUNC, AWIN_PIO_PG_SDC1_PINS }, | 61 | { 'G', AWIN_PIO_PG_SDC1_FUNC, AWIN_PIO_PG_SDC1_PINS }, | |
61 | { 'C', AWIN_PIO_PC_SDC2_FUNC, AWIN_PIO_PC_SDC2_PINS }, | 62 | { 'C', AWIN_PIO_PC_SDC2_FUNC, AWIN_PIO_PC_SDC2_PINS }, | |
62 | { 'I', AWIN_PIO_PI_SDC3_FUNC, AWIN_PIO_PI_SDC3_PINS }, | 63 | { 'I', AWIN_PIO_PI_SDC3_FUNC, AWIN_PIO_PI_SDC3_PINS }, | |
63 | }; | 64 | }; | |
64 | 65 | |||
65 | static const struct awin_gpio_pinset awin_sdhc_alt_pinsets[] = { | 66 | static const struct awin_gpio_pinset awin_sdhc_alt_pinsets[] = { | |
66 | { 0, 0, 0 }, | 67 | { 0, 0, 0 }, | |
67 | { 'H', AWIN_PIO_PH_SDC1_FUNC, AWIN_PIO_PH_SDC1_PINS }, | 68 | { 'H', AWIN_PIO_PH_SDC1_FUNC, AWIN_PIO_PH_SDC1_PINS }, | |
68 | { 0, 0, 0 }, | 69 | { 0, 0, 0 }, | |
69 | { 0, 0, 0 }, | 70 | { 0, 0, 0 }, | |
70 | }; | 71 | }; | |
71 | 72 | |||
72 | CFATTACH_DECL_NEW(awin_sdhc, sizeof(struct awin_sdhc_softc), | 73 | CFATTACH_DECL_NEW(awin_sdhc, sizeof(struct awin_sdhc_softc), | |
73 | awin_sdhc_match, awin_sdhc_attach, NULL, NULL); | 74 | awin_sdhc_match, awin_sdhc_attach, NULL, NULL); | |
74 | 75 | |||
75 | static int awin_sdhc_ports; | 76 | static int awin_sdhc_ports; | |
76 | 77 | |||
77 | static int | 78 | static int | |
78 | awin_sdhc_match(device_t parent, cfdata_t cf, void *aux) | 79 | awin_sdhc_match(device_t parent, cfdata_t cf, void *aux) | |
79 | { | 80 | { | |
80 | struct awinio_attach_args * const aio = aux; | 81 | struct awinio_attach_args * const aio = aux; | |
81 | const struct awin_locators * const loc = &aio->aio_loc; | 82 | const struct awin_locators * const loc = &aio->aio_loc; | |
82 | const struct awin_gpio_pinset * const pinset = loc->loc_port | 83 | const struct awin_gpio_pinset * const pinset = loc->loc_port | |
83 | + ((cf->cf_flags & 1) ? awin_sdhc_alt_pinsets : awin_sdhc_pinsets); | 84 | + ((cf->cf_flags & 1) ? awin_sdhc_alt_pinsets : awin_sdhc_pinsets); | |
84 | 85 | |||
85 | KASSERT(!strcmp(cf->cf_name, loc->loc_name)); | 86 | KASSERT(!strcmp(cf->cf_name, loc->loc_name)); | |
86 | KASSERT(cf->cf_loc[AWINIOCF_PORT] == AWINIOCF_PORT_DEFAULT | 87 | KASSERT(cf->cf_loc[AWINIOCF_PORT] == AWINIOCF_PORT_DEFAULT | |
87 | || cf->cf_loc[AWINIOCF_PORT] == loc->loc_port); | 88 | || cf->cf_loc[AWINIOCF_PORT] == loc->loc_port); | |
88 | KASSERT((awin_sdhc_ports & __BIT(loc->loc_port)) == 0); | 89 | KASSERT((awin_sdhc_ports & __BIT(loc->loc_port)) == 0); | |
89 | 90 | |||
90 | if (!awin_gpio_pinset_available(pinset)) | 91 | if (!awin_gpio_pinset_available(pinset)) | |
91 | return 0; | 92 | return 0; | |
92 | 93 | |||
93 | return 1; | 94 | return 1; | |
94 | } | 95 | } | |
95 | 96 | |||
96 | static void | 97 | static void | |
97 | awin_sdhc_attach(device_t parent, device_t self, void *aux) | 98 | awin_sdhc_attach(device_t parent, device_t self, void *aux) | |
98 | { | 99 | { | |
99 | struct awin_sdhc_softc * const asc = device_private(self); | 100 | struct awin_sdhc_softc * const asc = device_private(self); | |
100 | struct sdhc_softc * const sc = &asc->asc_sc; | 101 | struct sdhc_softc * const sc = &asc->asc_sc; | |
101 | struct awinio_attach_args * const aio = aux; | 102 | struct awinio_attach_args * const aio = aux; | |
102 | const struct awin_locators * const loc = &aio->aio_loc; | 103 | const struct awin_locators * const loc = &aio->aio_loc; | |
103 | cfdata_t cf = device_cfdata(self); | 104 | cfdata_t cf = device_cfdata(self); | |
104 | const struct awin_gpio_pinset * const pinset = loc->loc_port | 105 | const struct awin_gpio_pinset * const pinset = loc->loc_port | |
105 | + ((cf->cf_flags & 1) ? awin_sdhc_alt_pinsets : awin_sdhc_pinsets); | 106 | + ((cf->cf_flags & 1) ? awin_sdhc_alt_pinsets : awin_sdhc_pinsets); | |
106 | int error; | 107 | int error; | |
107 | 108 | |||
108 | awin_sdhc_ports |= __BIT(loc->loc_port); | 109 | awin_sdhc_ports |= __BIT(loc->loc_port); | |
109 | 110 | |||
110 | awin_gpio_pinset_acquire(pinset); | 111 | awin_gpio_pinset_acquire(pinset); | |
111 | 112 | |||
112 | asc->asc_bst = aio->aio_core_bst; | 113 | asc->asc_bst = aio->aio_core_bst; | |
113 | bus_space_subregion(asc->asc_bst, aio->aio_core_bsh, | 114 | bus_space_subregion(asc->asc_bst, aio->aio_core_bsh, | |
114 | loc->loc_offset, loc->loc_size, &asc->asc_bsh); | 115 | loc->loc_offset, loc->loc_size, &asc->asc_bsh); | |
115 | 116 | |||
116 | sc->sc_dev = self; | 117 | sc->sc_dev = self; | |
117 | sc->sc_dmat = aio->aio_dmat; | 118 | sc->sc_dmat = aio->aio_dmat; | |
118 | sc->sc_host = asc->asc_hosts; | 119 | sc->sc_host = asc->asc_hosts; | |
119 | sc->sc_flags |= SDHC_FLAG_32BIT_ACCESS; | 120 | sc->sc_flags |= SDHC_FLAG_32BIT_ACCESS; | |
120 | sc->sc_flags |= SDHC_FLAG_HAVE_CGM; | 121 | sc->sc_flags |= SDHC_FLAG_HAVE_CGM; | |
121 | //sc->sc_flags |= SDHC_FLAG_USE_DMA; | 122 | //sc->sc_flags |= SDHC_FLAG_USE_DMA; | |
122 | 123 | |||
123 | aprint_naive(": SDHC controller\n"); | 124 | aprint_naive(": SDHC controller\n"); | |
124 | aprint_normal(": SDHC controller%s\n", | 125 | aprint_normal(": SDHC controller%s\n", | |
125 | (sc->sc_flags & SDHC_FLAG_USE_DMA) ? " (DMA enabled)" : ""); | 126 | (sc->sc_flags & SDHC_FLAG_USE_DMA) ? " (DMA enabled)" : ""); | |
126 | 127 | |||
127 | asc->asc_ih = intr_establish(loc->loc_intr, IPL_VM, IST_LEVEL, | 128 | asc->asc_ih = intr_establish(loc->loc_intr, IPL_VM, IST_LEVEL, | |
128 | sdhc_intr, sc); | 129 | sdhc_intr, sc); | |
129 | if (asc->asc_ih == NULL) { | 130 | if (asc->asc_ih == NULL) { | |
130 | aprint_error_dev(self, "failed to establish interrupt %d\n", | 131 | aprint_error_dev(self, "failed to establish interrupt %d\n", | |
131 | loc->loc_intr); | 132 | loc->loc_intr); | |
132 | goto fail; | 133 | goto fail; | |
133 | } | 134 | } | |
134 | aprint_normal_dev(self, "interrupting on irq %d\n", | 135 | aprint_normal_dev(self, "interrupting on irq %d\n", | |
135 | loc->loc_intr); | 136 | loc->loc_intr); | |
136 | 137 | |||
137 | error = sdhc_host_found(sc, asc->asc_bst, asc->asc_bsh, | 138 | error = sdhc_host_found(sc, asc->asc_bst, asc->asc_bsh, | |
138 | loc->loc_size); | 139 | loc->loc_size); | |
139 | if (error != 0) { | 140 | if (error != 0) { | |
140 | aprint_error_dev(self, "couldn't initialize host, error=%d\n", | 141 | aprint_error_dev(self, "couldn't initialize host, error=%d\n", | |
141 | error); | 142 | error); | |
142 | goto fail; | 143 | goto fail; | |
143 | } | 144 | } | |
144 | 145 | |||
145 | return; | 146 | return; | |
146 | fail: | 147 | fail: | |
147 | 148 | |||
148 | if (asc->asc_ih) { | 149 | if (asc->asc_ih) { | |
149 | intr_disestablish(asc->asc_ih); | 150 | intr_disestablish(asc->asc_ih); | |
150 | asc->asc_ih = NULL; | 151 | asc->asc_ih = NULL; | |
151 | } | 152 | } | |
152 | } | 153 | } |
--- src/sys/arch/arm/allwinner/Attic/awin_gige.c 2013/09/08 04:06:44 1.2
+++ src/sys/arch/arm/allwinner/Attic/awin_gige.c 2014/02/20 21:48:38 1.3
@@ -1,99 +1,100 @@ | @@ -1,99 +1,100 @@ | |||
1 | /*- | 1 | /*- | |
2 | * Copyright (c) 2013 The NetBSD Foundation, Inc. | 2 | * Copyright (c) 2013 The NetBSD Foundation, Inc. | |
3 | * All rights reserved. | 3 | * All rights reserved. | |
4 | * | 4 | * | |
5 | * This code is derived from software contributed to The NetBSD Foundation | 5 | * This code is derived from software contributed to The NetBSD Foundation | |
6 | * by Matt Thomas of 3am Software Foundry. | 6 | * by Matt Thomas of 3am Software Foundry. | |
7 | * | 7 | * | |
8 | * Redistribution and use in source and binary forms, with or without | 8 | * Redistribution and use in source and binary forms, with or without | |
9 | * modification, are permitted provided that the following conditions | 9 | * modification, are permitted provided that the following conditions | |
10 | * are met: | 10 | * are met: | |
11 | * 1. Redistributions of source code must retain the above copyright | 11 | * 1. Redistributions of source code must retain the above copyright | |
12 | * notice, this list of conditions and the following disclaimer. | 12 | * notice, this list of conditions and the following disclaimer. | |
13 | * 2. Redistributions in binary form must reproduce the above copyright | 13 | * 2. Redistributions in binary form must reproduce the above copyright | |
14 | * notice, this list of conditions and the following disclaimer in the | 14 | * notice, this list of conditions and the following disclaimer in the | |
15 | * documentation and/or other materials provided with the distribution. | 15 | * documentation and/or other materials provided with the distribution. | |
16 | * | 16 | * | |
17 | * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS | 17 | * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS | |
18 | * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED | 18 | * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED | |
19 | * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR | 19 | * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR | |
20 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS | 20 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS | |
21 | * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR | 21 | * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR | |
22 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF | 22 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF | |
23 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS | 23 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS | |
24 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN | 24 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN | |
25 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | 25 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | |
26 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | 26 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | |
27 | * POSSIBILITY OF SUCH DAMAGE. | 27 | * POSSIBILITY OF SUCH DAMAGE. | |
28 | */ | 28 | */ | |
29 | 29 | |||
30 | #include "locators.h" | 30 | #include "locators.h" | |
31 | 31 | |||
32 | #include <sys/cdefs.h> | 32 | #include <sys/cdefs.h> | |
33 | 33 | |||
34 | __KERNEL_RCSID(1, "$NetBSD: awin_gige.c,v 1.2 2013/09/08 04:06:44 matt Exp $"); | 34 | __KERNEL_RCSID(1, "$NetBSD: awin_gige.c,v 1.3 2014/02/20 21:48:38 matt Exp $"); | |
35 | 35 | |||
36 | #include <sys/param.h> | |||
36 | #include <sys/bus.h> | 37 | #include <sys/bus.h> | |
37 | #include <sys/device.h> | 38 | #include <sys/device.h> | |
38 | #include <sys/intr.h> | 39 | #include <sys/intr.h> | |
39 | #include <sys/systm.h> | 40 | #include <sys/systm.h> | |
40 | 41 | |||
41 | #include <arm/allwinner/awin_reg.h> | 42 | #include <arm/allwinner/awin_reg.h> | |
42 | #include <arm/allwinner/awin_var.h> | 43 | #include <arm/allwinner/awin_var.h> | |
43 | 44 | |||
44 | static int awin_gige_match(device_t, cfdata_t, void *); | 45 | static int awin_gige_match(device_t, cfdata_t, void *); | |
45 | static void awin_gige_attach(device_t, device_t, void *); | 46 | static void awin_gige_attach(device_t, device_t, void *); | |
46 | 47 | |||
47 | struct awin_gige_softc { | 48 | struct awin_gige_softc { | |
48 | device_t sc_dev; | 49 | device_t sc_dev; | |
49 | bus_space_tag_t sc_bst; | 50 | bus_space_tag_t sc_bst; | |
50 | bus_space_handle_t sc_bsh; | 51 | bus_space_handle_t sc_bsh; | |
51 | bus_dma_tag_t sc_dmat; | 52 | bus_dma_tag_t sc_dmat; | |
52 | }; | 53 | }; | |
53 | 54 | |||
54 | static const struct awin_gpio_pinset awin_gige_gpio_pinset = { | 55 | static const struct awin_gpio_pinset awin_gige_gpio_pinset = { | |
55 | 'A', AWIN_PIO_PA_GMAC_FUNC, AWIN_PIO_PA_GMAC_PINS, | 56 | 'A', AWIN_PIO_PA_GMAC_FUNC, AWIN_PIO_PA_GMAC_PINS, | |
56 | }; | 57 | }; | |
57 | 58 | |||
58 | CFATTACH_DECL_NEW(awin_gige, sizeof(struct awin_gige_softc), | 59 | CFATTACH_DECL_NEW(awin_gige, sizeof(struct awin_gige_softc), | |
59 | awin_gige_match, awin_gige_attach, NULL, NULL); | 60 | awin_gige_match, awin_gige_attach, NULL, NULL); | |
60 | 61 | |||
61 | static int | 62 | static int | |
62 | awin_gige_match(device_t parent, cfdata_t cf, void *aux) | 63 | awin_gige_match(device_t parent, cfdata_t cf, void *aux) | |
63 | { | 64 | { | |
64 | struct awinio_attach_args * const aio = aux; | 65 | struct awinio_attach_args * const aio = aux; | |
65 | #ifdef DIAGNOSTIC | 66 | #ifdef DIAGNOSTIC | |
66 | const struct awin_locators * const loc = &aio->aio_loc; | 67 | const struct awin_locators * const loc = &aio->aio_loc; | |
67 | #endif | 68 | #endif | |
68 | if (cf->cf_flags & 1) | 69 | if (cf->cf_flags & 1) | |
69 | return 0; | 70 | return 0; | |
70 | 71 | |||
71 | KASSERT(!strcmp(cf->cf_name, loc->loc_name)); | 72 | KASSERT(!strcmp(cf->cf_name, loc->loc_name)); | |
72 | KASSERT(cf->cf_loc[AWINIOCF_PORT] == AWINIOCF_PORT_DEFAULT | 73 | KASSERT(cf->cf_loc[AWINIOCF_PORT] == AWINIOCF_PORT_DEFAULT | |
73 | || cf->cf_loc[AWINIOCF_PORT] == loc->loc_port); | 74 | || cf->cf_loc[AWINIOCF_PORT] == loc->loc_port); | |
74 | 75 | |||
75 | if (!awin_gpio_pinset_available(&awin_gige_pinset)) | 76 | if (!awin_gpio_pinset_available(&awin_gige_pinset)) | |
76 | return 0; | 77 | return 0; | |
77 | 78 | |||
78 | return 1; | 79 | return 1; | |
79 | } | 80 | } | |
80 | 81 | |||
81 | static void | 82 | static void | |
82 | awin_gige_attach(device_t parent, device_t self, void *aux) | 83 | awin_gige_attach(device_t parent, device_t self, void *aux) | |
83 | { | 84 | { | |
84 | struct awin_gige_softc * const sc = device_private(self); | 85 | struct awin_gige_softc * const sc = device_private(self); | |
85 | struct awinio_attach_args * const aio = aux; | 86 | struct awinio_attach_args * const aio = aux; | |
86 | const struct awin_locators * const loc = &aio->aio_loc; | 87 | const struct awin_locators * const loc = &aio->aio_loc; | |
87 | 88 | |||
88 | sc->sc_dev = self; | 89 | sc->sc_dev = self; | |
89 | 90 | |||
90 | awin_gpio_pinset_acquire(&awin_gige_pinset); | 91 | awin_gpio_pinset_acquire(&awin_gige_pinset); | |
91 | 92 | |||
92 | sc->sc_bst = aio->aio_core_bst; | 93 | sc->sc_bst = aio->aio_core_bst; | |
93 | sc->sc_dmat = aio->aio_dmat; | 94 | sc->sc_dmat = aio->aio_dmat; | |
94 | bus_space_subregion(sc->sc_bst, aio->aio_core_bsh, | 95 | bus_space_subregion(sc->sc_bst, aio->aio_core_bsh, | |
95 | loc->loc_offset, loc->loc_size, &sc->sc_bsh); | 96 | loc->loc_offset, loc->loc_size, &sc->sc_bsh); | |
96 | 97 | |||
97 | aprint_naive("\n"); | 98 | aprint_naive("\n"); | |
98 | aprint_normal(": Gigabit Ethernet Controller\n"); | 99 | aprint_normal(": Gigabit Ethernet Controller\n"); | |
99 | } | 100 | } |
--- src/sys/arch/arm/allwinner/Attic/awin_twi.c 2013/09/07 00:35:52 1.2
+++ src/sys/arch/arm/allwinner/Attic/awin_twi.c 2014/02/20 21:48:38 1.3
@@ -1,134 +1,135 @@ | @@ -1,134 +1,135 @@ | |||
1 | /*- | 1 | /*- | |
2 | * Copyright (c) 2013 The NetBSD Foundation, Inc. | 2 | * Copyright (c) 2013 The NetBSD Foundation, Inc. | |
3 | * All rights reserved. | 3 | * All rights reserved. | |
4 | * | 4 | * | |
5 | * This code is derived from software contributed to The NetBSD Foundation | 5 | * This code is derived from software contributed to The NetBSD Foundation | |
6 | * by Matt Thomas of 3am Software Foundry. | 6 | * by Matt Thomas of 3am Software Foundry. | |
7 | * | 7 | * | |
8 | * Redistribution and use in source and binary forms, with or without | 8 | * Redistribution and use in source and binary forms, with or without | |
9 | * modification, are permitted provided that the following conditions | 9 | * modification, are permitted provided that the following conditions | |
10 | * are met: | 10 | * are met: | |
11 | * 1. Redistributions of source code must retain the above copyright | 11 | * 1. Redistributions of source code must retain the above copyright | |
12 | * notice, this list of conditions and the following disclaimer. | 12 | * notice, this list of conditions and the following disclaimer. | |
13 | * 2. Redistributions in binary form must reproduce the above copyright | 13 | * 2. Redistributions in binary form must reproduce the above copyright | |
14 | * notice, this list of conditions and the following disclaimer in the | 14 | * notice, this list of conditions and the following disclaimer in the | |
15 | * documentation and/or other materials provided with the distribution. | 15 | * documentation and/or other materials provided with the distribution. | |
16 | * | 16 | * | |
17 | * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS | 17 | * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS | |
18 | * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED | 18 | * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED | |
19 | * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR | 19 | * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR | |
20 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS | 20 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS | |
21 | * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR | 21 | * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR | |
22 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF | 22 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF | |
23 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS | 23 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS | |
24 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN | 24 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN | |
25 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | 25 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | |
26 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | 26 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | |
27 | * POSSIBILITY OF SUCH DAMAGE. | 27 | * POSSIBILITY OF SUCH DAMAGE. | |
28 | */ | 28 | */ | |
29 | 29 | |||
30 | #include "locators.h" | 30 | #include "locators.h" | |
31 | 31 | |||
32 | #include <sys/cdefs.h> | 32 | #include <sys/cdefs.h> | |
33 | 33 | |||
34 | __KERNEL_RCSID(1, "$NetBSD: awin_twi.c,v 1.2 2013/09/07 00:35:52 matt Exp $"); | 34 | __KERNEL_RCSID(1, "$NetBSD: awin_twi.c,v 1.3 2014/02/20 21:48:38 matt Exp $"); | |
35 | 35 | |||
36 | #include <sys/param.h> | |||
36 | #include <sys/bus.h> | 37 | #include <sys/bus.h> | |
37 | #include <sys/device.h> | 38 | #include <sys/device.h> | |
38 | #include <sys/intr.h> | 39 | #include <sys/intr.h> | |
39 | #include <sys/systm.h> | 40 | #include <sys/systm.h> | |
40 | 41 | |||
41 | #include <dev/i2c/i2cvar.h> | 42 | #include <dev/i2c/i2cvar.h> | |
42 | #include <dev/i2c/gttwsivar.h> | 43 | #include <dev/i2c/gttwsivar.h> | |
43 | 44 | |||
44 | #include <arm/allwinner/awin_reg.h> | 45 | #include <arm/allwinner/awin_reg.h> | |
45 | #include <arm/allwinner/awin_var.h> | 46 | #include <arm/allwinner/awin_var.h> | |
46 | 47 | |||
47 | static int awin_twi_match(device_t, cfdata_t, void *); | 48 | static int awin_twi_match(device_t, cfdata_t, void *); | |
48 | static void awin_twi_attach(device_t, device_t, void *); | 49 | static void awin_twi_attach(device_t, device_t, void *); | |
49 | 50 | |||
50 | struct awin_twi_softc { | 51 | struct awin_twi_softc { | |
51 | struct gttwsi_softc asc_sc; | 52 | struct gttwsi_softc asc_sc; | |
52 | void *asc_ih; | 53 | void *asc_ih; | |
53 | }; | 54 | }; | |
54 | 55 | |||
55 | static int awin_twi_ports; | 56 | static int awin_twi_ports; | |
56 | 57 | |||
57 | static const struct awin_gpio_pinset awin_twi_pinsets[] = { | 58 | static const struct awin_gpio_pinset awin_twi_pinsets[] = { | |
58 | [0] = { 'B', AWIN_PIO_PB_TWI0_FUNC, AWIN_PIO_PB_TWI0_PINS }, | 59 | [0] = { 'B', AWIN_PIO_PB_TWI0_FUNC, AWIN_PIO_PB_TWI0_PINS }, | |
59 | [1] = { 'B', AWIN_PIO_PB_TWI1_FUNC, AWIN_PIO_PB_TWI1_PINS }, | 60 | [1] = { 'B', AWIN_PIO_PB_TWI1_FUNC, AWIN_PIO_PB_TWI1_PINS }, | |
60 | [2] = { 'B', AWIN_PIO_PB_TWI2_FUNC, AWIN_PIO_PB_TWI2_PINS }, | 61 | [2] = { 'B', AWIN_PIO_PB_TWI2_FUNC, AWIN_PIO_PB_TWI2_PINS }, | |
61 | [3] = { 'I', AWIN_PIO_PI_TWI3_FUNC, AWIN_PIO_PI_TWI3_PINS }, | 62 | [3] = { 'I', AWIN_PIO_PI_TWI3_FUNC, AWIN_PIO_PI_TWI3_PINS }, | |
62 | [4] = { 'I', AWIN_PIO_PI_TWI4_FUNC, AWIN_PIO_PI_TWI4_PINS }, | 63 | [4] = { 'I', AWIN_PIO_PI_TWI4_FUNC, AWIN_PIO_PI_TWI4_PINS }, | |
63 | }; | 64 | }; | |
64 | 65 | |||
65 | CFATTACH_DECL_NEW(awin_twi, sizeof(struct awin_twi_softc), | 66 | CFATTACH_DECL_NEW(awin_twi, sizeof(struct awin_twi_softc), | |
66 | awin_twi_match, awin_twi_attach, NULL, NULL); | 67 | awin_twi_match, awin_twi_attach, NULL, NULL); | |
67 | 68 | |||
68 | static int | 69 | static int | |
69 | awin_twi_match(device_t parent, cfdata_t cf, void *aux) | 70 | awin_twi_match(device_t parent, cfdata_t cf, void *aux) | |
70 | { | 71 | { | |
71 | struct awinio_attach_args * const aio = aux; | 72 | struct awinio_attach_args * const aio = aux; | |
72 | const struct awin_locators * const loc = &aio->aio_loc; | 73 | const struct awin_locators * const loc = &aio->aio_loc; | |
73 | 74 | |||
74 | KASSERT(!strcmp(cf->cf_name, loc->loc_name)); | 75 | KASSERT(!strcmp(cf->cf_name, loc->loc_name)); | |
75 | KASSERT(cf->cf_loc[AWINIOCF_PORT] == AWINIOCF_PORT_DEFAULT | 76 | KASSERT(cf->cf_loc[AWINIOCF_PORT] == AWINIOCF_PORT_DEFAULT | |
76 | || cf->cf_loc[AWINIOCF_PORT] == loc->loc_port); | 77 | || cf->cf_loc[AWINIOCF_PORT] == loc->loc_port); | |
77 | KASSERT((awin_twi_ports & __BIT(loc->loc_port)) == 0); | 78 | KASSERT((awin_twi_ports & __BIT(loc->loc_port)) == 0); | |
78 | 79 | |||
79 | /* | 80 | /* | |
80 | * We don't have alternative mappings so if one is requested | 81 | * We don't have alternative mappings so if one is requested | |
81 | * fail the match. | 82 | * fail the match. | |
82 | */ | 83 | */ | |
83 | if (cf->cf_flags & 1) | 84 | if (cf->cf_flags & 1) | |
84 | return 0; | 85 | return 0; | |
85 | 86 | |||
86 | if (!awin_gpio_pinset_available(&awin_twi_pinsets[loc->loc_port])) | 87 | if (!awin_gpio_pinset_available(&awin_twi_pinsets[loc->loc_port])) | |
87 | return 0; | 88 | return 0; | |
88 | 89 | |||
89 | return 1; | 90 | return 1; | |
90 | } | 91 | } | |
91 | 92 | |||
92 | static void | 93 | static void | |
93 | awin_twi_attach(device_t parent, device_t self, void *aux) | 94 | awin_twi_attach(device_t parent, device_t self, void *aux) | |
94 | { | 95 | { | |
95 | struct awin_twi_softc * const asc = device_private(self); | 96 | struct awin_twi_softc * const asc = device_private(self); | |
96 | struct awinio_attach_args * const aio = aux; | 97 | struct awinio_attach_args * const aio = aux; | |
97 | const struct awin_locators * const loc = &aio->aio_loc; | 98 | const struct awin_locators * const loc = &aio->aio_loc; | |
98 | bus_space_handle_t bsh; | 99 | bus_space_handle_t bsh; | |
99 | 100 | |||
100 | awin_twi_ports |= __BIT(loc->loc_port); | 101 | awin_twi_ports |= __BIT(loc->loc_port); | |
101 | 102 | |||
102 | /* | 103 | /* | |
103 | * Acquite the PIO pins needed for the TWI port. | 104 | * Acquite the PIO pins needed for the TWI port. | |
104 | */ | 105 | */ | |
105 | awin_gpio_pinset_acquire(&awin_twi_pinsets[loc->loc_port]); | 106 | awin_gpio_pinset_acquire(&awin_twi_pinsets[loc->loc_port]); | |
106 | 107 | |||
107 | /* | 108 | /* | |
108 | * Get a bus space handle for this TWI port. | 109 | * Get a bus space handle for this TWI port. | |
109 | */ | 110 | */ | |
110 | bus_space_subregion(aio->aio_core_bst, aio->aio_core_bsh, | 111 | bus_space_subregion(aio->aio_core_bst, aio->aio_core_bsh, | |
111 | loc->loc_offset, loc->loc_size, &bsh); | 112 | loc->loc_offset, loc->loc_size, &bsh); | |
112 | 113 | |||
113 | /* | 114 | /* | |
114 | * Do the MI attach | 115 | * Do the MI attach | |
115 | */ | 116 | */ | |
116 | gttwsi_attach_subr(self, aio->aio_core_bst, bsh); | 117 | gttwsi_attach_subr(self, aio->aio_core_bst, bsh); | |
117 | 118 | |||
118 | /* | 119 | /* | |
119 | * Establish interrupt for it | 120 | * Establish interrupt for it | |
120 | */ | 121 | */ | |
121 | asc->asc_ih = intr_establish(loc->loc_intr, IPL_BIO, IST_LEVEL, | 122 | asc->asc_ih = intr_establish(loc->loc_intr, IPL_BIO, IST_LEVEL, | |
122 | gttwsi_intr, &asc->asc_sc); | 123 | gttwsi_intr, &asc->asc_sc); | |
123 | if (asc->asc_ih == NULL) { | 124 | if (asc->asc_ih == NULL) { | |
124 | aprint_error_dev(self, "failed to establish interrupt %d\n", | 125 | aprint_error_dev(self, "failed to establish interrupt %d\n", | |
125 | loc->loc_intr); | 126 | loc->loc_intr); | |
126 | return; | 127 | return; | |
127 | } | 128 | } | |
128 | aprint_normal_dev(self, "interrupting on irq %d\n", loc->loc_intr); | 129 | aprint_normal_dev(self, "interrupting on irq %d\n", loc->loc_intr); | |
129 | 130 | |||
130 | /* | 131 | /* | |
131 | * Configure its children | 132 | * Configure its children | |
132 | */ | 133 | */ | |
133 | gttwsi_config_children(self); | 134 | gttwsi_config_children(self); | |
134 | } | 135 | } |
--- src/sys/arch/arm/allwinner/Attic/awin_wdt.c 2013/09/04 17:45:40 1.2
+++ src/sys/arch/arm/allwinner/Attic/awin_wdt.c 2014/02/20 21:48:38 1.3
@@ -1,208 +1,209 @@ | @@ -1,208 +1,209 @@ | |||
1 | /*- | 1 | /*- | |
2 | * Copyright (c) 2013 The NetBSD Foundation, Inc. | 2 | * Copyright (c) 2013 The NetBSD Foundation, Inc. | |
3 | * All rights reserved. | 3 | * All rights reserved. | |
4 | * | 4 | * | |
5 | * This code is derived from software contributed to The NetBSD Foundation | 5 | * This code is derived from software contributed to The NetBSD Foundation | |
6 | * by Matt Thomas of 3am Software Foundry. | 6 | * by Matt Thomas of 3am Software Foundry. | |
7 | * | 7 | * | |
8 | * Redistribution and use in source and binary forms, with or without | 8 | * Redistribution and use in source and binary forms, with or without | |
9 | * modification, are permitted provided that the following conditions | 9 | * modification, are permitted provided that the following conditions | |
10 | * are met: | 10 | * are met: | |
11 | * 1. Redistributions of source code must retain the above copyright | 11 | * 1. Redistributions of source code must retain the above copyright | |
12 | * notice, this list of conditions and the following disclaimer. | 12 | * notice, this list of conditions and the following disclaimer. | |
13 | * 2. Redistributions in binary form must reproduce the above copyright | 13 | * 2. Redistributions in binary form must reproduce the above copyright | |
14 | * notice, this list of conditions and the following disclaimer in the | 14 | * notice, this list of conditions and the following disclaimer in the | |
15 | * documentation and/or other materials provided with the distribution. | 15 | * documentation and/or other materials provided with the distribution. | |
16 | * | 16 | * | |
17 | * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS | 17 | * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS | |
18 | * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED | 18 | * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED | |
19 | * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR | 19 | * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR | |
20 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS | 20 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS | |
21 | * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR | 21 | * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR | |
22 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF | 22 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF | |
23 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS | 23 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS | |
24 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN | 24 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN | |
25 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | 25 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | |
26 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | 26 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | |
27 | * POSSIBILITY OF SUCH DAMAGE. | 27 | * POSSIBILITY OF SUCH DAMAGE. | |
28 | */ | 28 | */ | |
29 | 29 | |||
30 | #include "locators.h" | 30 | #include "locators.h" | |
31 | #include "opt_allwinner.h" | 31 | #include "opt_allwinner.h" | |
32 | #include "awin_wdt.h" | 32 | #include "awin_wdt.h" | |
33 | 33 | |||
34 | #include <sys/cdefs.h> | 34 | #include <sys/cdefs.h> | |
35 | 35 | |||
36 | __KERNEL_RCSID(1, "$NetBSD: awin_wdt.c,v 1.2 2013/09/04 17:45:40 matt Exp $"); | 36 | __KERNEL_RCSID(1, "$NetBSD: awin_wdt.c,v 1.3 2014/02/20 21:48:38 matt Exp $"); | |
37 | 37 | |||
38 | #include <sys/param.h> | |||
38 | #include <sys/bus.h> | 39 | #include <sys/bus.h> | |
39 | #include <sys/device.h> | 40 | #include <sys/device.h> | |
40 | #include <sys/intr.h> | 41 | #include <sys/intr.h> | |
41 | #include <sys/systm.h> | 42 | #include <sys/systm.h> | |
42 | #include <sys/proc.h> | 43 | #include <sys/proc.h> | |
43 | #include <sys/wdog.h> | 44 | #include <sys/wdog.h> | |
44 | 45 | |||
45 | #include <dev/sysmon/sysmonvar.h> | 46 | #include <dev/sysmon/sysmonvar.h> | |
46 | 47 | |||
47 | #include <arm/locore.h> | 48 | #include <arm/locore.h> | |
48 | 49 | |||
49 | #include <arm/allwinner/awin_reg.h> | 50 | #include <arm/allwinner/awin_reg.h> | |
50 | #include <arm/allwinner/awin_var.h> | 51 | #include <arm/allwinner/awin_var.h> | |
51 | 52 | |||
52 | #if NAWIN_WDT > 0 | 53 | #if NAWIN_WDT > 0 | |
53 | static int awin_wdt_match(device_t, cfdata_t, void *); | 54 | static int awin_wdt_match(device_t, cfdata_t, void *); | |
54 | static void awin_wdt_attach(device_t, device_t, void *); | 55 | static void awin_wdt_attach(device_t, device_t, void *); | |
55 | 56 | |||
56 | #ifndef AWIN_WDT_PERIOD_DEFAULT | 57 | #ifndef AWIN_WDT_PERIOD_DEFAULT | |
57 | #define AWIN_WDT_PERIOD_DEFAULT 10 | 58 | #define AWIN_WDT_PERIOD_DEFAULT 10 | |
58 | #endif | 59 | #endif | |
59 | 60 | |||
60 | static const uint8_t period_map[] = { | 61 | static const uint8_t period_map[] = { | |
61 | [0] = __SHIFTIN(AWIN_WDOG_MODE_INTV_1SEC, AWIN_WDOG_MODE_INTV), | 62 | [0] = __SHIFTIN(AWIN_WDOG_MODE_INTV_1SEC, AWIN_WDOG_MODE_INTV), | |
62 | [1] = __SHIFTIN(AWIN_WDOG_MODE_INTV_1SEC, AWIN_WDOG_MODE_INTV), | 63 | [1] = __SHIFTIN(AWIN_WDOG_MODE_INTV_1SEC, AWIN_WDOG_MODE_INTV), | |
63 | [2] = __SHIFTIN(AWIN_WDOG_MODE_INTV_2SEC, AWIN_WDOG_MODE_INTV), | 64 | [2] = __SHIFTIN(AWIN_WDOG_MODE_INTV_2SEC, AWIN_WDOG_MODE_INTV), | |
64 | [3] = __SHIFTIN(AWIN_WDOG_MODE_INTV_3SEC, AWIN_WDOG_MODE_INTV), | 65 | [3] = __SHIFTIN(AWIN_WDOG_MODE_INTV_3SEC, AWIN_WDOG_MODE_INTV), | |
65 | [4] = __SHIFTIN(AWIN_WDOG_MODE_INTV_4SEC, AWIN_WDOG_MODE_INTV), | 66 | [4] = __SHIFTIN(AWIN_WDOG_MODE_INTV_4SEC, AWIN_WDOG_MODE_INTV), | |
66 | [5] = __SHIFTIN(AWIN_WDOG_MODE_INTV_5SEC, AWIN_WDOG_MODE_INTV), | 67 | [5] = __SHIFTIN(AWIN_WDOG_MODE_INTV_5SEC, AWIN_WDOG_MODE_INTV), | |
67 | [6] = __SHIFTIN(AWIN_WDOG_MODE_INTV_6SEC, AWIN_WDOG_MODE_INTV), | 68 | [6] = __SHIFTIN(AWIN_WDOG_MODE_INTV_6SEC, AWIN_WDOG_MODE_INTV), | |
68 | [7] = __SHIFTIN(AWIN_WDOG_MODE_INTV_8SEC, AWIN_WDOG_MODE_INTV), | 69 | [7] = __SHIFTIN(AWIN_WDOG_MODE_INTV_8SEC, AWIN_WDOG_MODE_INTV), | |
69 | [8] = __SHIFTIN(AWIN_WDOG_MODE_INTV_8SEC, AWIN_WDOG_MODE_INTV), | 70 | [8] = __SHIFTIN(AWIN_WDOG_MODE_INTV_8SEC, AWIN_WDOG_MODE_INTV), | |
70 | [9] = __SHIFTIN(AWIN_WDOG_MODE_INTV_10SEC, AWIN_WDOG_MODE_INTV), | 71 | [9] = __SHIFTIN(AWIN_WDOG_MODE_INTV_10SEC, AWIN_WDOG_MODE_INTV), | |
71 | [10] = __SHIFTIN(AWIN_WDOG_MODE_INTV_10SEC, AWIN_WDOG_MODE_INTV), | 72 | [10] = __SHIFTIN(AWIN_WDOG_MODE_INTV_10SEC, AWIN_WDOG_MODE_INTV), | |
72 | [11] = __SHIFTIN(AWIN_WDOG_MODE_INTV_12SEC, AWIN_WDOG_MODE_INTV), | 73 | [11] = __SHIFTIN(AWIN_WDOG_MODE_INTV_12SEC, AWIN_WDOG_MODE_INTV), | |
73 | [12] = __SHIFTIN(AWIN_WDOG_MODE_INTV_12SEC, AWIN_WDOG_MODE_INTV), | 74 | [12] = __SHIFTIN(AWIN_WDOG_MODE_INTV_12SEC, AWIN_WDOG_MODE_INTV), | |
74 | [13] = __SHIFTIN(AWIN_WDOG_MODE_INTV_14SEC, AWIN_WDOG_MODE_INTV), | 75 | [13] = __SHIFTIN(AWIN_WDOG_MODE_INTV_14SEC, AWIN_WDOG_MODE_INTV), | |
75 | [14] = __SHIFTIN(AWIN_WDOG_MODE_INTV_14SEC, AWIN_WDOG_MODE_INTV), | 76 | [14] = __SHIFTIN(AWIN_WDOG_MODE_INTV_14SEC, AWIN_WDOG_MODE_INTV), | |
76 | [15] = __SHIFTIN(AWIN_WDOG_MODE_INTV_16SEC, AWIN_WDOG_MODE_INTV), | 77 | [15] = __SHIFTIN(AWIN_WDOG_MODE_INTV_16SEC, AWIN_WDOG_MODE_INTV), | |
77 | [16] = __SHIFTIN(AWIN_WDOG_MODE_INTV_16SEC, AWIN_WDOG_MODE_INTV), | 78 | [16] = __SHIFTIN(AWIN_WDOG_MODE_INTV_16SEC, AWIN_WDOG_MODE_INTV), | |
78 | }; | 79 | }; | |
79 | 80 | |||
80 | static struct awin_wdt_softc { | 81 | static struct awin_wdt_softc { | |
81 | device_t sc_dev; | 82 | device_t sc_dev; | |
82 | bus_space_tag_t sc_bst; | 83 | bus_space_tag_t sc_bst; | |
83 | bus_space_handle_t sc_bsh; | 84 | bus_space_handle_t sc_bsh; | |
84 | struct sysmon_wdog sc_smw; | 85 | struct sysmon_wdog sc_smw; | |
85 | u_int sc_wdog_period; | 86 | u_int sc_wdog_period; | |
86 | bool sc_wdog_armed; | 87 | bool sc_wdog_armed; | |
87 | uint32_t sc_wdog_mode; | 88 | uint32_t sc_wdog_mode; | |
88 | } awin_wdt_sc = { | 89 | } awin_wdt_sc = { | |
89 | .sc_bst = &awin_bs_tag, | 90 | .sc_bst = &awin_bs_tag, | |
90 | .sc_wdog_period = AWIN_WDT_PERIOD_DEFAULT, | 91 | .sc_wdog_period = AWIN_WDT_PERIOD_DEFAULT, | |
91 | }; | 92 | }; | |
92 | 93 | |||
93 | static int | 94 | static int | |
94 | awin_wdt_tickle(struct sysmon_wdog *smw) | 95 | awin_wdt_tickle(struct sysmon_wdog *smw) | |
95 | { | 96 | { | |
96 | struct awin_wdt_softc * const sc = smw->smw_cookie; | 97 | struct awin_wdt_softc * const sc = smw->smw_cookie; | |
97 | bus_space_write_4(sc->sc_bst, sc->sc_bsh, AWIN_WDOG_CTRL_REG, | 98 | bus_space_write_4(sc->sc_bst, sc->sc_bsh, AWIN_WDOG_CTRL_REG, | |
98 | AWIN_WDOG_CTRL_RSTART); | 99 | AWIN_WDOG_CTRL_RSTART); | |
99 | return 0; | 100 | return 0; | |
100 | } | 101 | } | |
101 | 102 | |||
102 | static int | 103 | static int | |
103 | awin_wdt_setmode(struct sysmon_wdog *smw) | 104 | awin_wdt_setmode(struct sysmon_wdog *smw) | |
104 | { | 105 | { | |
105 | struct awin_wdt_softc * const sc = smw->smw_cookie; | 106 | struct awin_wdt_softc * const sc = smw->smw_cookie; | |
106 | 107 | |||
107 | if ((smw->smw_mode & WDOG_MODE_MASK) == WDOG_MODE_DISARMED) { | 108 | if ((smw->smw_mode & WDOG_MODE_MASK) == WDOG_MODE_DISARMED) { | |
108 | /* | 109 | /* | |
109 | * We can't disarm the watchdog. | 110 | * We can't disarm the watchdog. | |
110 | */ | 111 | */ | |
111 | return sc->sc_wdog_armed ? EBUSY : 0; | 112 | return sc->sc_wdog_armed ? EBUSY : 0; | |
112 | } | 113 | } | |
113 | 114 | |||
114 | if (sc->sc_wdog_armed && smw->smw_period == sc->sc_wdog_period) { | 115 | if (sc->sc_wdog_armed && smw->smw_period == sc->sc_wdog_period) { | |
115 | bus_space_write_4(sc->sc_bst, sc->sc_bsh, AWIN_WDOG_MODE_REG, | 116 | bus_space_write_4(sc->sc_bst, sc->sc_bsh, AWIN_WDOG_MODE_REG, | |
116 | sc->sc_wdog_mode); | 117 | sc->sc_wdog_mode); | |
117 | bus_space_write_4(sc->sc_bst, sc->sc_bsh, AWIN_WDOG_CTRL_REG, | 118 | bus_space_write_4(sc->sc_bst, sc->sc_bsh, AWIN_WDOG_CTRL_REG, | |
118 | AWIN_WDOG_CTRL_RSTART); | 119 | AWIN_WDOG_CTRL_RSTART); | |
119 | return 0; | 120 | return 0; | |
120 | } | 121 | } | |
121 | if (smw->smw_period > __arraycount(period_map)) { | 122 | if (smw->smw_period > __arraycount(period_map)) { | |
122 | return EINVAL; | 123 | return EINVAL; | |
123 | } | 124 | } | |
124 | if (smw->smw_period == WDOG_PERIOD_DEFAULT) { | 125 | if (smw->smw_period == WDOG_PERIOD_DEFAULT) { | |
125 | smw->smw_period = AWIN_WDT_PERIOD_DEFAULT; | 126 | smw->smw_period = AWIN_WDT_PERIOD_DEFAULT; | |
126 | sc->sc_wdog_period = AWIN_WDT_PERIOD_DEFAULT; | 127 | sc->sc_wdog_period = AWIN_WDT_PERIOD_DEFAULT; | |
127 | } | 128 | } | |
128 | sc->sc_wdog_mode = AWIN_WDOG_MODE_EN | AWIN_WDOG_MODE_RST_EN | 129 | sc->sc_wdog_mode = AWIN_WDOG_MODE_EN | AWIN_WDOG_MODE_RST_EN | |
129 | | period_map[sc->sc_wdog_period]; | 130 | | period_map[sc->sc_wdog_period]; | |
130 | 131 | |||
131 | bus_space_write_4(sc->sc_bst, sc->sc_bsh, AWIN_WDOG_MODE_REG, | 132 | bus_space_write_4(sc->sc_bst, sc->sc_bsh, AWIN_WDOG_MODE_REG, | |
132 | sc->sc_wdog_mode); | 133 | sc->sc_wdog_mode); | |
133 | bus_space_write_4(sc->sc_bst, sc->sc_bsh, AWIN_WDOG_CTRL_REG, | 134 | bus_space_write_4(sc->sc_bst, sc->sc_bsh, AWIN_WDOG_CTRL_REG, | |
134 | AWIN_WDOG_CTRL_RSTART); | 135 | AWIN_WDOG_CTRL_RSTART); | |
135 | return 0; | 136 | return 0; | |
136 | } | 137 | } | |
137 | 138 | |||
138 | CFATTACH_DECL_NEW(awin_wdt, 0, | 139 | CFATTACH_DECL_NEW(awin_wdt, 0, | |
139 | awin_wdt_match, awin_wdt_attach, NULL, NULL); | 140 | awin_wdt_match, awin_wdt_attach, NULL, NULL); | |
140 | 141 | |||
141 | static int | 142 | static int | |
142 | awin_wdt_match(device_t parent, cfdata_t cf, void *aux) | 143 | awin_wdt_match(device_t parent, cfdata_t cf, void *aux) | |
143 | { | 144 | { | |
144 | struct awinio_attach_args * const aio = aux; | 145 | struct awinio_attach_args * const aio = aux; | |
145 | const struct awin_locators * const loc = &aio->aio_loc; | 146 | const struct awin_locators * const loc = &aio->aio_loc; | |
146 | const int port = cf->cf_loc[AWINIOCF_PORT]; | 147 | const int port = cf->cf_loc[AWINIOCF_PORT]; | |
147 | 148 | |||
148 | if (awin_wdt_sc.sc_dev != NULL) | 149 | if (awin_wdt_sc.sc_dev != NULL) | |
149 | return 0; | 150 | return 0; | |
150 | 151 | |||
151 | if (strcmp(cf->cf_name, loc->loc_name) | 152 | if (strcmp(cf->cf_name, loc->loc_name) | |
152 | || (port != AWINIOCF_PORT_DEFAULT && port != loc->loc_port)) | 153 | || (port != AWINIOCF_PORT_DEFAULT && port != loc->loc_port)) | |
153 | return 0; | 154 | return 0; | |
154 | 155 | |||
155 | KASSERT(loc->loc_port == AWINIOCF_PORT_DEFAULT); | 156 | KASSERT(loc->loc_port == AWINIOCF_PORT_DEFAULT); | |
156 | 157 | |||
157 | return 1; | 158 | return 1; | |
158 | } | 159 | } | |
159 | 160 | |||
160 | static void | 161 | static void | |
161 | awin_wdt_attach(device_t parent, device_t self, void *aux) | 162 | awin_wdt_attach(device_t parent, device_t self, void *aux) | |
162 | { | 163 | { | |
163 | struct awin_wdt_softc * const sc = &awin_wdt_sc; | 164 | struct awin_wdt_softc * const sc = &awin_wdt_sc; | |
164 | struct awinio_attach_args * const aio = aux; | 165 | struct awinio_attach_args * const aio = aux; | |
165 | const struct awin_locators * const loc = &aio->aio_loc; | 166 | const struct awin_locators * const loc = &aio->aio_loc; | |
166 | 167 | |||
167 | sc->sc_dev = self; | 168 | sc->sc_dev = self; | |
168 | sc->sc_wdog_armed = (device_cfdata(self)->cf_flags & 1) != 0; | 169 | sc->sc_wdog_armed = (device_cfdata(self)->cf_flags & 1) != 0; | |
169 | 170 | |||
170 | sc->sc_bst = aio->aio_core_bst; | 171 | sc->sc_bst = aio->aio_core_bst; | |
171 | bus_space_subregion(sc->sc_bst, aio->aio_core_bsh, | 172 | bus_space_subregion(sc->sc_bst, aio->aio_core_bsh, | |
172 | loc->loc_offset, loc->loc_size, &sc->sc_bsh); | 173 | loc->loc_offset, loc->loc_size, &sc->sc_bsh); | |
173 | 174 | |||
174 | aprint_naive("\n"); | 175 | aprint_naive("\n"); | |
175 | aprint_normal(": default period is %u seconds%s\n", | 176 | aprint_normal(": default period is %u seconds%s\n", | |
176 | sc->sc_wdog_period, | 177 | sc->sc_wdog_period, | |
177 | sc->sc_wdog_armed ? " (wdog is active)" : ""); | 178 | sc->sc_wdog_armed ? " (wdog is active)" : ""); | |
178 | 179 | |||
179 | sc->sc_smw.smw_name = device_xname(sc->sc_dev); | 180 | sc->sc_smw.smw_name = device_xname(sc->sc_dev); | |
180 | sc->sc_smw.smw_cookie = sc; | 181 | sc->sc_smw.smw_cookie = sc; | |
181 | sc->sc_smw.smw_setmode = awin_wdt_setmode; | 182 | sc->sc_smw.smw_setmode = awin_wdt_setmode; | |
182 | sc->sc_smw.smw_tickle = awin_wdt_tickle; | 183 | sc->sc_smw.smw_tickle = awin_wdt_tickle; | |
183 | sc->sc_smw.smw_period = sc->sc_wdog_period; | 184 | sc->sc_smw.smw_period = sc->sc_wdog_period; | |
184 | 185 | |||
185 | if (sysmon_wdog_register(&sc->sc_smw) != 0) | 186 | if (sysmon_wdog_register(&sc->sc_smw) != 0) | |
186 | aprint_error_dev(self, "unable to register with sysmon\n"); | 187 | aprint_error_dev(self, "unable to register with sysmon\n"); | |
187 | 188 | |||
188 | if (sc->sc_wdog_armed) { | 189 | if (sc->sc_wdog_armed) { | |
189 | int error = sysmon_wdog_setmode(&sc->sc_smw, WDOG_MODE_KTICKLE, | 190 | int error = sysmon_wdog_setmode(&sc->sc_smw, WDOG_MODE_KTICKLE, | |
190 | sc->sc_wdog_period); | 191 | sc->sc_wdog_period); | |
191 | if (error) | 192 | if (error) | |
192 | aprint_error_dev(self, | 193 | aprint_error_dev(self, | |
193 | "failed to start kernel tickler: %d\n", error); | 194 | "failed to start kernel tickler: %d\n", error); | |
194 | } | 195 | } | |
195 | } | 196 | } | |
196 | #endif | 197 | #endif | |
197 | 198 | |||
198 | void | 199 | void | |
199 | awin_wdog_reset(void) | 200 | awin_wdog_reset(void) | |
200 | { | 201 | { | |
201 | cpsid(I32_bit|F32_bit); | 202 | cpsid(I32_bit|F32_bit); | |
202 | bus_space_write_4(&awin_bs_tag, awin_core_bsh, | 203 | bus_space_write_4(&awin_bs_tag, awin_core_bsh, | |
203 | AWIN_TMR_OFFSET + AWIN_WDOG_MODE_REG, | 204 | AWIN_TMR_OFFSET + AWIN_WDOG_MODE_REG, | |
204 | AWIN_WDOG_MODE_EN | AWIN_WDOG_MODE_RST_EN); | 205 | AWIN_WDOG_MODE_EN | AWIN_WDOG_MODE_RST_EN); | |
205 | for (;;) { | 206 | for (;;) { | |
206 | __asm("wfi"); | 207 | __asm("wfi"); | |
207 | } | 208 | } | |
208 | } | 209 | } |
--- src/sys/arch/arm/allwinner/Attic/awin_gpio.c 2013/12/19 22:13:38 1.7
+++ src/sys/arch/arm/allwinner/Attic/awin_gpio.c 2014/02/20 21:48:38 1.8
@@ -1,624 +1,625 @@ | @@ -1,624 +1,625 @@ | |||
1 | /*- | 1 | /*- | |
2 | * Copyright (c) 2013 The NetBSD Foundation, Inc. | 2 | * Copyright (c) 2013 The NetBSD Foundation, Inc. | |
3 | * All rights reserved. | 3 | * All rights reserved. | |
4 | * | 4 | * | |
5 | * This code is derived from software contributed to The NetBSD Foundation | 5 | * This code is derived from software contributed to The NetBSD Foundation | |
6 | * by Matt Thomas of 3am Software Foundry. | 6 | * by Matt Thomas of 3am Software Foundry. | |
7 | * | 7 | * | |
8 | * Redistribution and use in source and binary forms, with or without | 8 | * Redistribution and use in source and binary forms, with or without | |
9 | * modification, are permitted provided that the following conditions | 9 | * modification, are permitted provided that the following conditions | |
10 | * are met: | 10 | * are met: | |
11 | * 1. Redistributions of source code must retain the above copyright | 11 | * 1. Redistributions of source code must retain the above copyright | |
12 | * notice, this list of conditions and the following disclaimer. | 12 | * notice, this list of conditions and the following disclaimer. | |
13 | * 2. Redistributions in binary form must reproduce the above copyright | 13 | * 2. Redistributions in binary form must reproduce the above copyright | |
14 | * notice, this list of conditions and the following disclaimer in the | 14 | * notice, this list of conditions and the following disclaimer in the | |
15 | * documentation and/or other materials provided with the distribution. | 15 | * documentation and/or other materials provided with the distribution. | |
16 | * | 16 | * | |
17 | * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS | 17 | * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS | |
18 | * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED | 18 | * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED | |
19 | * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR | 19 | * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR | |
20 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS | 20 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS | |
21 | * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR | 21 | * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR | |
22 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF | 22 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF | |
23 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS | 23 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS | |
24 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN | 24 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN | |
25 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | 25 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | |
26 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | 26 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | |
27 | * POSSIBILITY OF SUCH DAMAGE. | 27 | * POSSIBILITY OF SUCH DAMAGE. | |
28 | */ | 28 | */ | |
29 | 29 | |||
30 | #include "locators.h" | 30 | #include "locators.h" | |
31 | #include "gpio.h" | 31 | #include "gpio.h" | |
32 | 32 | |||
33 | #include <sys/cdefs.h> | 33 | #include <sys/cdefs.h> | |
34 | 34 | |||
35 | __KERNEL_RCSID(1, "$NetBSD: awin_gpio.c,v 1.7 2013/12/19 22:13:38 joerg Exp $"); | 35 | __KERNEL_RCSID(1, "$NetBSD: awin_gpio.c,v 1.8 2014/02/20 21:48:38 matt Exp $"); | |
36 | 36 | |||
37 | #include <sys/param.h> | |||
37 | #include <sys/bus.h> | 38 | #include <sys/bus.h> | |
38 | #include <sys/device.h> | 39 | #include <sys/device.h> | |
39 | #include <sys/intr.h> | 40 | #include <sys/intr.h> | |
40 | #include <sys/systm.h> | 41 | #include <sys/systm.h> | |
41 | #include <sys/kmem.h> | 42 | #include <sys/kmem.h> | |
42 | 43 | |||
43 | #include <sys/gpio.h> | 44 | #include <sys/gpio.h> | |
44 | 45 | |||
45 | #include <dev/gpio/gpiovar.h> | 46 | #include <dev/gpio/gpiovar.h> | |
46 | 47 | |||
47 | #include <arm/allwinner/awin_reg.h> | 48 | #include <arm/allwinner/awin_reg.h> | |
48 | #include <arm/allwinner/awin_var.h> | 49 | #include <arm/allwinner/awin_var.h> | |
49 | 50 | |||
50 | static int awin_gpio_match(device_t, cfdata_t, void *); | 51 | static int awin_gpio_match(device_t, cfdata_t, void *); | |
51 | static void awin_gpio_attach(device_t, device_t, void *); | 52 | static void awin_gpio_attach(device_t, device_t, void *); | |
52 | 53 | |||
53 | static int awin_gpio_pin_read(void *, int); | 54 | static int awin_gpio_pin_read(void *, int); | |
54 | static void awin_gpio_pin_write(void *, int, int); | 55 | static void awin_gpio_pin_write(void *, int, int); | |
55 | static void awin_gpio_pin_ctl(void *, int, int); | 56 | static void awin_gpio_pin_ctl(void *, int, int); | |
56 | 57 | |||
57 | #if 0 | 58 | #if 0 | |
58 | static const int ist_maps[] = { | 59 | static const int ist_maps[] = { | |
59 | [IST_LEVEL_LOW] = AWIN_PIO_EINT_LOW_LEVEL, | 60 | [IST_LEVEL_LOW] = AWIN_PIO_EINT_LOW_LEVEL, | |
60 | [IST_LEVEL_HIGH] = AWIN_PIO_EINT_HIGH_LEVEL, | 61 | [IST_LEVEL_HIGH] = AWIN_PIO_EINT_HIGH_LEVEL, | |
61 | [IST_EDGE_FALLING] = AWIN_PIO_EINT_POSITIVE_EDGE, | 62 | [IST_EDGE_FALLING] = AWIN_PIO_EINT_POSITIVE_EDGE, | |
62 | [IST_EDGE_RISING] = AWIN_PIO_EINT_NEGATIVE_EDGE, | 63 | [IST_EDGE_RISING] = AWIN_PIO_EINT_NEGATIVE_EDGE, | |
63 | [IST_EDGE_BOTH] = AWIN_PIO_EINT_DOUBLE_EDGE, | 64 | [IST_EDGE_BOTH] = AWIN_PIO_EINT_DOUBLE_EDGE, | |
64 | }; | 65 | }; | |
65 | #endif | 66 | #endif | |
66 | 67 | |||
67 | struct awin_gpio_pin_cfg { | 68 | struct awin_gpio_pin_cfg { | |
68 | uint32_t cfg[4]; | 69 | uint32_t cfg[4]; | |
69 | uint32_t drv[2]; | 70 | uint32_t drv[2]; | |
70 | uint32_t pul[2]; | 71 | uint32_t pul[2]; | |
71 | }; | 72 | }; | |
72 | 73 | |||
73 | static struct awin_gpio_pin_group { | 74 | static struct awin_gpio_pin_group { | |
74 | uint32_t grp_pin_mask; | 75 | uint32_t grp_pin_mask; | |
75 | uint32_t grp_pin_inuse_mask; | 76 | uint32_t grp_pin_inuse_mask; | |
76 | bus_space_handle_t grp_bsh; | 77 | bus_space_handle_t grp_bsh; | |
77 | struct awin_gpio_pin_cfg grp_cfg; | 78 | struct awin_gpio_pin_cfg grp_cfg; | |
78 | struct gpio_chipset_tag grp_gc_tag; | 79 | struct gpio_chipset_tag grp_gc_tag; | |
79 | const char grp_nc_name[6]; | 80 | const char grp_nc_name[6]; | |
80 | } pin_groups[] = { | 81 | } pin_groups[] = { | |
81 | [0] = { | 82 | [0] = { | |
82 | .grp_pin_mask = __BIT(AWIN_PIO_PA_PINS) - 1, | 83 | .grp_pin_mask = __BIT(AWIN_PIO_PA_PINS) - 1, | |
83 | .grp_gc_tag = { | 84 | .grp_gc_tag = { | |
84 | .gp_cookie = &pin_groups[0], | 85 | .gp_cookie = &pin_groups[0], | |
85 | .gp_pin_read = awin_gpio_pin_read, | 86 | .gp_pin_read = awin_gpio_pin_read, | |
86 | .gp_pin_write = awin_gpio_pin_write, | 87 | .gp_pin_write = awin_gpio_pin_write, | |
87 | .gp_pin_ctl = awin_gpio_pin_ctl, | 88 | .gp_pin_ctl = awin_gpio_pin_ctl, | |
88 | }, | 89 | }, | |
89 | .grp_nc_name = "nc-pa", | 90 | .grp_nc_name = "nc-pa", | |
90 | }, | 91 | }, | |
91 | [1] = { | 92 | [1] = { | |
92 | .grp_pin_mask = __BIT(AWIN_PIO_PB_PINS) - 1, | 93 | .grp_pin_mask = __BIT(AWIN_PIO_PB_PINS) - 1, | |
93 | .grp_gc_tag = { | 94 | .grp_gc_tag = { | |
94 | .gp_cookie = &pin_groups[1], | 95 | .gp_cookie = &pin_groups[1], | |
95 | .gp_pin_read = awin_gpio_pin_read, | 96 | .gp_pin_read = awin_gpio_pin_read, | |
96 | .gp_pin_write = awin_gpio_pin_write, | 97 | .gp_pin_write = awin_gpio_pin_write, | |
97 | .gp_pin_ctl = awin_gpio_pin_ctl, | 98 | .gp_pin_ctl = awin_gpio_pin_ctl, | |
98 | }, | 99 | }, | |
99 | .grp_nc_name = "nc-pb", | 100 | .grp_nc_name = "nc-pb", | |
100 | }, | 101 | }, | |
101 | [2] = { | 102 | [2] = { | |
102 | .grp_pin_mask = __BIT(AWIN_PIO_PC_PINS) - 1, | 103 | .grp_pin_mask = __BIT(AWIN_PIO_PC_PINS) - 1, | |
103 | .grp_gc_tag = { | 104 | .grp_gc_tag = { | |
104 | .gp_cookie = &pin_groups[2], | 105 | .gp_cookie = &pin_groups[2], | |
105 | .gp_pin_read = awin_gpio_pin_read, | 106 | .gp_pin_read = awin_gpio_pin_read, | |
106 | .gp_pin_write = awin_gpio_pin_write, | 107 | .gp_pin_write = awin_gpio_pin_write, | |
107 | .gp_pin_ctl = awin_gpio_pin_ctl, | 108 | .gp_pin_ctl = awin_gpio_pin_ctl, | |
108 | }, | 109 | }, | |
109 | .grp_nc_name = "nc-pc", | 110 | .grp_nc_name = "nc-pc", | |
110 | }, | 111 | }, | |
111 | [3] = { | 112 | [3] = { | |
112 | .grp_pin_mask = __BIT(AWIN_PIO_PD_PINS) - 1, | 113 | .grp_pin_mask = __BIT(AWIN_PIO_PD_PINS) - 1, | |
113 | .grp_gc_tag = { | 114 | .grp_gc_tag = { | |
114 | .gp_cookie = &pin_groups[3], | 115 | .gp_cookie = &pin_groups[3], | |
115 | .gp_pin_read = awin_gpio_pin_read, | 116 | .gp_pin_read = awin_gpio_pin_read, | |
116 | .gp_pin_write = awin_gpio_pin_write, | 117 | .gp_pin_write = awin_gpio_pin_write, | |
117 | .gp_pin_ctl = awin_gpio_pin_ctl, | 118 | .gp_pin_ctl = awin_gpio_pin_ctl, | |
118 | }, | 119 | }, | |
119 | .grp_nc_name = "nc-pd", | 120 | .grp_nc_name = "nc-pd", | |
120 | }, | 121 | }, | |
121 | [4] = { | 122 | [4] = { | |
122 | .grp_pin_mask = __BIT(AWIN_PIO_PE_PINS) - 1, | 123 | .grp_pin_mask = __BIT(AWIN_PIO_PE_PINS) - 1, | |
123 | .grp_gc_tag = { | 124 | .grp_gc_tag = { | |
124 | .gp_cookie = &pin_groups[4], | 125 | .gp_cookie = &pin_groups[4], | |
125 | .gp_pin_read = awin_gpio_pin_read, | 126 | .gp_pin_read = awin_gpio_pin_read, | |
126 | .gp_pin_write = awin_gpio_pin_write, | 127 | .gp_pin_write = awin_gpio_pin_write, | |
127 | .gp_pin_ctl = awin_gpio_pin_ctl, | 128 | .gp_pin_ctl = awin_gpio_pin_ctl, | |
128 | }, | 129 | }, | |
129 | .grp_nc_name = "nc-pe", | 130 | .grp_nc_name = "nc-pe", | |
130 | }, | 131 | }, | |
131 | [5] = { | 132 | [5] = { | |
132 | .grp_pin_mask = __BIT(AWIN_PIO_PF_PINS) - 1, | 133 | .grp_pin_mask = __BIT(AWIN_PIO_PF_PINS) - 1, | |
133 | .grp_gc_tag = { | 134 | .grp_gc_tag = { | |
134 | .gp_cookie = &pin_groups[5], | 135 | .gp_cookie = &pin_groups[5], | |
135 | .gp_pin_read = awin_gpio_pin_read, | 136 | .gp_pin_read = awin_gpio_pin_read, | |
136 | .gp_pin_write = awin_gpio_pin_write, | 137 | .gp_pin_write = awin_gpio_pin_write, | |
137 | .gp_pin_ctl = awin_gpio_pin_ctl, | 138 | .gp_pin_ctl = awin_gpio_pin_ctl, | |
138 | }, | 139 | }, | |
139 | .grp_nc_name = "nc-pf", | 140 | .grp_nc_name = "nc-pf", | |
140 | }, | 141 | }, | |
141 | [6] = { | 142 | [6] = { | |
142 | .grp_pin_mask = __BIT(AWIN_PIO_PG_PINS) - 1, | 143 | .grp_pin_mask = __BIT(AWIN_PIO_PG_PINS) - 1, | |
143 | .grp_gc_tag = { | 144 | .grp_gc_tag = { | |
144 | .gp_cookie = &pin_groups[6], | 145 | .gp_cookie = &pin_groups[6], | |
145 | .gp_pin_read = awin_gpio_pin_read, | 146 | .gp_pin_read = awin_gpio_pin_read, | |
146 | .gp_pin_write = awin_gpio_pin_write, | 147 | .gp_pin_write = awin_gpio_pin_write, | |
147 | .gp_pin_ctl = awin_gpio_pin_ctl, | 148 | .gp_pin_ctl = awin_gpio_pin_ctl, | |
148 | }, | 149 | }, | |
149 | .grp_nc_name = "nc-pg", | 150 | .grp_nc_name = "nc-pg", | |
150 | }, | 151 | }, | |
151 | [7] = { | 152 | [7] = { | |
152 | .grp_pin_mask = __BIT(AWIN_PIO_PH_PINS) - 1, | 153 | .grp_pin_mask = __BIT(AWIN_PIO_PH_PINS) - 1, | |
153 | .grp_gc_tag = { | 154 | .grp_gc_tag = { | |
154 | .gp_cookie = &pin_groups[7], | 155 | .gp_cookie = &pin_groups[7], | |
155 | .gp_pin_read = awin_gpio_pin_read, | 156 | .gp_pin_read = awin_gpio_pin_read, | |
156 | .gp_pin_write = awin_gpio_pin_write, | 157 | .gp_pin_write = awin_gpio_pin_write, | |
157 | .gp_pin_ctl = awin_gpio_pin_ctl, | 158 | .gp_pin_ctl = awin_gpio_pin_ctl, | |
158 | }, | 159 | }, | |
159 | .grp_nc_name = "nc-ph", | 160 | .grp_nc_name = "nc-ph", | |
160 | }, | 161 | }, | |
161 | [8] = { | 162 | [8] = { | |
162 | .grp_pin_mask = __BIT(AWIN_PIO_PI_PINS) - 1, | 163 | .grp_pin_mask = __BIT(AWIN_PIO_PI_PINS) - 1, | |
163 | .grp_gc_tag = { | 164 | .grp_gc_tag = { | |
164 | .gp_cookie = &pin_groups[8], | 165 | .gp_cookie = &pin_groups[8], | |
165 | .gp_pin_read = awin_gpio_pin_read, | 166 | .gp_pin_read = awin_gpio_pin_read, | |
166 | .gp_pin_write = awin_gpio_pin_write, | 167 | .gp_pin_write = awin_gpio_pin_write, | |
167 | .gp_pin_ctl = awin_gpio_pin_ctl, | 168 | .gp_pin_ctl = awin_gpio_pin_ctl, | |
168 | }, | 169 | }, | |
169 | .grp_nc_name = "nc-pi", | 170 | .grp_nc_name = "nc-pi", | |
170 | }, | 171 | }, | |
171 | }; | 172 | }; | |
172 | 173 | |||
173 | 174 | |||
174 | static struct awin_gpio_softc { | 175 | static struct awin_gpio_softc { | |
175 | device_t sc_dev; | 176 | device_t sc_dev; | |
176 | bus_space_tag_t sc_bst; | 177 | bus_space_tag_t sc_bst; | |
177 | bus_space_handle_t sc_bsh; | 178 | bus_space_handle_t sc_bsh; | |
178 | } awin_gpio_sc = { | 179 | } awin_gpio_sc = { | |
179 | .sc_bst = &awin_bs_tag, | 180 | .sc_bst = &awin_bs_tag, | |
180 | }; | 181 | }; | |
181 | 182 | |||
182 | CFATTACH_DECL_NEW(awin_gpio, sizeof(struct awin_gpio_softc), | 183 | CFATTACH_DECL_NEW(awin_gpio, sizeof(struct awin_gpio_softc), | |
183 | awin_gpio_match, awin_gpio_attach, NULL, NULL); | 184 | awin_gpio_match, awin_gpio_attach, NULL, NULL); | |
184 | 185 | |||
185 | static int | 186 | static int | |
186 | awin_gpio_match(device_t parent, cfdata_t cf, void *aux) | 187 | awin_gpio_match(device_t parent, cfdata_t cf, void *aux) | |
187 | { | 188 | { | |
188 | struct awinio_attach_args * const aio = aux; | 189 | struct awinio_attach_args * const aio = aux; | |
189 | const struct awin_locators * const loc = &aio->aio_loc; | 190 | const struct awin_locators * const loc = &aio->aio_loc; | |
190 | 191 | |||
191 | KASSERT(!strcmp(cf->cf_name, loc->loc_name)); | 192 | KASSERT(!strcmp(cf->cf_name, loc->loc_name)); | |
192 | KASSERT(loc->loc_port == AWINIOCF_PORT_DEFAULT); | 193 | KASSERT(loc->loc_port == AWINIOCF_PORT_DEFAULT); | |
193 | KASSERT(cf->cf_loc[AWINIOCF_PORT] == AWINIOCF_PORT_DEFAULT); | 194 | KASSERT(cf->cf_loc[AWINIOCF_PORT] == AWINIOCF_PORT_DEFAULT); | |
194 | 195 | |||
195 | if (awin_gpio_sc.sc_dev != NULL) | 196 | if (awin_gpio_sc.sc_dev != NULL) | |
196 | return 0; | 197 | return 0; | |
197 | 198 | |||
198 | return 1; | 199 | return 1; | |
199 | } | 200 | } | |
200 | 201 | |||
201 | #if NGPIO > 0 | 202 | #if NGPIO > 0 | |
202 | static void | 203 | static void | |
203 | awin_gpio_config_pins(device_t self) | 204 | awin_gpio_config_pins(device_t self) | |
204 | { | 205 | { | |
205 | struct awin_gpio_softc * const sc = &awin_gpio_sc; | 206 | struct awin_gpio_softc * const sc = &awin_gpio_sc; | |
206 | 207 | |||
207 | /* | 208 | /* | |
208 | * First find out how many pins we can offer. | 209 | * First find out how many pins we can offer. | |
209 | */ | 210 | */ | |
210 | size_t pin_count = 0; | 211 | size_t pin_count = 0; | |
211 | for (u_int i = 0; i < __arraycount(pin_groups); i++) { | 212 | for (u_int i = 0; i < __arraycount(pin_groups); i++) { | |
212 | struct awin_gpio_pin_group * const grp = &pin_groups[i]; | 213 | struct awin_gpio_pin_group * const grp = &pin_groups[i]; | |
213 | 214 | |||
214 | pin_count += | 215 | pin_count += | |
215 | popcount32(grp->grp_pin_mask & ~grp->grp_pin_inuse_mask); | 216 | popcount32(grp->grp_pin_mask & ~grp->grp_pin_inuse_mask); | |
216 | } | 217 | } | |
217 | 218 | |||
218 | /* | 219 | /* | |
219 | * Allocate the pin data. | 220 | * Allocate the pin data. | |
220 | */ | 221 | */ | |
221 | gpio_pin_t * const pins = kmem_zalloc(sizeof(gpio_pin_t) * pin_count, | 222 | gpio_pin_t * const pins = kmem_zalloc(sizeof(gpio_pin_t) * pin_count, | |
222 | KM_SLEEP); | 223 | KM_SLEEP); | |
223 | KASSERT(pins != NULL); | 224 | KASSERT(pins != NULL); | |
224 | 225 | |||
225 | const int pincaps = GPIO_PIN_INPUT | GPIO_PIN_OUTPUT | 226 | const int pincaps = GPIO_PIN_INPUT | GPIO_PIN_OUTPUT | |
226 | | GPIO_PIN_PULLUP | GPIO_PIN_PULLDOWN; | 227 | | GPIO_PIN_PULLUP | GPIO_PIN_PULLDOWN; | |
227 | 228 | |||
228 | gpio_pin_t *pin = pins; | 229 | gpio_pin_t *pin = pins; | |
229 | for (u_int i = 0; i < __arraycount(pin_groups); i++) { | 230 | for (u_int i = 0; i < __arraycount(pin_groups); i++) { | |
230 | struct awin_gpio_pin_group * const grp = &pin_groups[i]; | 231 | struct awin_gpio_pin_group * const grp = &pin_groups[i]; | |
231 | uint32_t mask = grp->grp_pin_mask & ~grp->grp_pin_inuse_mask; | 232 | uint32_t mask = grp->grp_pin_mask & ~grp->grp_pin_inuse_mask; | |
232 | 233 | |||
233 | /* | 234 | /* | |
234 | * If this group has no bits to provide, skip it. | 235 | * If this group has no bits to provide, skip it. | |
235 | */ | 236 | */ | |
236 | if (mask == 0) | 237 | if (mask == 0) | |
237 | continue; | 238 | continue; | |
238 | 239 | |||
239 | struct gpiobus_attach_args gba = { | 240 | struct gpiobus_attach_args gba = { | |
240 | .gba_gc = &grp->grp_gc_tag, | 241 | .gba_gc = &grp->grp_gc_tag, | |
241 | .gba_pins = pin, | 242 | .gba_pins = pin, | |
242 | }; | 243 | }; | |
243 | 244 | |||
244 | uint32_t data = bus_space_read_4(sc->sc_bst, grp->grp_bsh, | 245 | uint32_t data = bus_space_read_4(sc->sc_bst, grp->grp_bsh, | |
245 | AWIN_PIO_DAT_REG); | 246 | AWIN_PIO_DAT_REG); | |
246 | for (int num = 0; mask != 0; mask >>= 1, data >>= 1, num++) { | 247 | for (int num = 0; mask != 0; mask >>= 1, data >>= 1, num++) { | |
247 | if (mask & 1) { | 248 | if (mask & 1) { | |
248 | pin->pin_num = num + (i << 5); | 249 | pin->pin_num = num + (i << 5); | |
249 | pin->pin_caps = pincaps; | 250 | pin->pin_caps = pincaps; | |
250 | pin->pin_flags = pincaps; | 251 | pin->pin_flags = pincaps; | |
251 | pin->pin_state = (data & 1) != 0; | 252 | pin->pin_state = (data & 1) != 0; | |
252 | pin++; | 253 | pin++; | |
253 | } | 254 | } | |
254 | } | 255 | } | |
255 | 256 | |||
256 | gba.gba_npins = pin - gba.gba_pins; | 257 | gba.gba_npins = pin - gba.gba_pins; | |
257 | config_found_ia(self, "gpiobus", &gba, gpiobus_print); | 258 | config_found_ia(self, "gpiobus", &gba, gpiobus_print); | |
258 | } | 259 | } | |
259 | } | 260 | } | |
260 | #endif /* NGPIO > 0 */ | 261 | #endif /* NGPIO > 0 */ | |
261 | 262 | |||
262 | static void | 263 | static void | |
263 | awin_gpio_attach(device_t parent, device_t self, void *aux) | 264 | awin_gpio_attach(device_t parent, device_t self, void *aux) | |
264 | { | 265 | { | |
265 | struct awin_gpio_softc * const sc = &awin_gpio_sc; | 266 | struct awin_gpio_softc * const sc = &awin_gpio_sc; | |
266 | struct awinio_attach_args * const aio = aux; | 267 | struct awinio_attach_args * const aio = aux; | |
267 | const struct awin_locators * const loc = &aio->aio_loc; | 268 | const struct awin_locators * const loc = &aio->aio_loc; | |
268 | prop_dictionary_t dict = device_properties(self); | 269 | prop_dictionary_t dict = device_properties(self); | |
269 | 270 | |||
270 | sc->sc_dev = self; | 271 | sc->sc_dev = self; | |
271 | 272 | |||
272 | sc->sc_bst = aio->aio_core_bst; | 273 | sc->sc_bst = aio->aio_core_bst; | |
273 | bus_space_subregion(sc->sc_bst, aio->aio_core_bsh, | 274 | bus_space_subregion(sc->sc_bst, aio->aio_core_bsh, | |
274 | loc->loc_offset, loc->loc_size, &sc->sc_bsh); | 275 | loc->loc_offset, loc->loc_size, &sc->sc_bsh); | |
275 | 276 | |||
276 | aprint_naive("\n"); | 277 | aprint_naive("\n"); | |
277 | aprint_normal("\n"); | 278 | aprint_normal("\n"); | |
278 | 279 | |||
279 | for (u_int i = 0; i < __arraycount(pin_groups); i++) { | 280 | for (u_int i = 0; i < __arraycount(pin_groups); i++) { | |
280 | struct awin_gpio_pin_group * const grp = &pin_groups[i]; | 281 | struct awin_gpio_pin_group * const grp = &pin_groups[i]; | |
281 | 282 | |||
282 | /* | 283 | /* | |
283 | * See if this group has any unconnected pins and make sure | 284 | * See if this group has any unconnected pins and make sure | |
284 | * we won't use them. | 285 | * we won't use them. | |
285 | */ | 286 | */ | |
286 | uint32_t nc; | 287 | uint32_t nc; | |
287 | if (prop_dictionary_get_uint32(dict, grp->grp_nc_name, &nc)) { | 288 | if (prop_dictionary_get_uint32(dict, grp->grp_nc_name, &nc)) { | |
288 | KASSERT((~grp->grp_pin_mask & nc) == 0); | 289 | KASSERT((~grp->grp_pin_mask & nc) == 0); | |
289 | KASSERT((grp->grp_pin_inuse_mask & ~nc) == 0); | 290 | KASSERT((grp->grp_pin_inuse_mask & ~nc) == 0); | |
290 | grp->grp_pin_mask &= ~nc; | 291 | grp->grp_pin_mask &= ~nc; | |
291 | } | 292 | } | |
292 | } | 293 | } | |
293 | 294 | |||
294 | #if NGPIO > 0 | 295 | #if NGPIO > 0 | |
295 | config_defer(self, awin_gpio_config_pins); | 296 | config_defer(self, awin_gpio_config_pins); | |
296 | #endif | 297 | #endif | |
297 | } | 298 | } | |
298 | 299 | |||
299 | static u_int | 300 | static u_int | |
300 | awin_gpio_get_pin_func(const struct awin_gpio_pin_cfg *cfg, u_int pin) | 301 | awin_gpio_get_pin_func(const struct awin_gpio_pin_cfg *cfg, u_int pin) | |
301 | { | 302 | { | |
302 | const u_int shift = (pin & 7) << 2; | 303 | const u_int shift = (pin & 7) << 2; | |
303 | const u_int i = (pin >> 3) & 3; | 304 | const u_int i = (pin >> 3) & 3; | |
304 | 305 | |||
305 | return (cfg->cfg[i] >> shift) & 0x0f; | 306 | return (cfg->cfg[i] >> shift) & 0x0f; | |
306 | } | 307 | } | |
307 | 308 | |||
308 | static void | 309 | static void | |
309 | awin_gpio_set_pin_func(struct awin_gpio_pin_cfg *cfg, u_int pin, u_int func) | 310 | awin_gpio_set_pin_func(struct awin_gpio_pin_cfg *cfg, u_int pin, u_int func) | |
310 | { | 311 | { | |
311 | const u_int shift = (pin & 7) << 2; | 312 | const u_int shift = (pin & 7) << 2; | |
312 | const u_int i = (pin >> 3) & 3; | 313 | const u_int i = (pin >> 3) & 3; | |
313 | 314 | |||
314 | cfg->cfg[i] &= ~(0x0f << shift); | 315 | cfg->cfg[i] &= ~(0x0f << shift); | |
315 | cfg->cfg[i] |= func << shift; | 316 | cfg->cfg[i] |= func << shift; | |
316 | } | 317 | } | |
317 | 318 | |||
318 | static void | 319 | static void | |
319 | awin_gpio_set_pin_pull(struct awin_gpio_pin_cfg *cfg, u_int pin, u_int pull) | 320 | awin_gpio_set_pin_pull(struct awin_gpio_pin_cfg *cfg, u_int pin, u_int pull) | |
320 | { | 321 | { | |
321 | const u_int shift = (pin & 15) << 1; | 322 | const u_int shift = (pin & 15) << 1; | |
322 | const u_int i = (pin >> 4) & 1; | 323 | const u_int i = (pin >> 4) & 1; | |
323 | 324 | |||
324 | cfg->pul[i] &= ~(0x03 << shift); | 325 | cfg->pul[i] &= ~(0x03 << shift); | |
325 | cfg->pul[i] |= pull << shift; | 326 | cfg->pul[i] |= pull << shift; | |
326 | } | 327 | } | |
327 | 328 | |||
328 | static void | 329 | static void | |
329 | awin_gpio_update_cfg_regs(bus_space_tag_t bst, struct awin_gpio_pin_group *grp, | 330 | awin_gpio_update_cfg_regs(bus_space_tag_t bst, struct awin_gpio_pin_group *grp, | |
330 | const struct awin_gpio_pin_cfg *ncfg) | 331 | const struct awin_gpio_pin_cfg *ncfg) | |
331 | { | 332 | { | |
332 | for (u_int i = 0; i < 4; i++) { | 333 | for (u_int i = 0; i < 4; i++) { | |
333 | if (grp->grp_cfg.cfg[i] != ncfg->cfg[i]) { | 334 | if (grp->grp_cfg.cfg[i] != ncfg->cfg[i]) { | |
334 | bus_space_write_4(bst, grp->grp_bsh, | 335 | bus_space_write_4(bst, grp->grp_bsh, | |
335 | AWIN_PIO_CFG0_REG + 4 * i, ncfg->cfg[i]); | 336 | AWIN_PIO_CFG0_REG + 4 * i, ncfg->cfg[i]); | |
336 | grp->grp_cfg.cfg[i] = ncfg->cfg[i]; | 337 | grp->grp_cfg.cfg[i] = ncfg->cfg[i]; | |
337 | } | 338 | } | |
338 | } | 339 | } | |
339 | for (u_int i = 0; i < 2; i++) { | 340 | for (u_int i = 0; i < 2; i++) { | |
340 | if (grp->grp_cfg.drv[i] != ncfg->drv[i]) { | 341 | if (grp->grp_cfg.drv[i] != ncfg->drv[i]) { | |
341 | bus_space_write_4(bst, grp->grp_bsh, | 342 | bus_space_write_4(bst, grp->grp_bsh, | |
342 | AWIN_PIO_DRV0_REG + 4 * i, ncfg->drv[i]); | 343 | AWIN_PIO_DRV0_REG + 4 * i, ncfg->drv[i]); | |
343 | grp->grp_cfg.drv[i] = ncfg->drv[i]; | 344 | grp->grp_cfg.drv[i] = ncfg->drv[i]; | |
344 | } | 345 | } | |
345 | if (grp->grp_cfg.pul[i] != ncfg->pul[i]) { | 346 | if (grp->grp_cfg.pul[i] != ncfg->pul[i]) { | |
346 | bus_space_write_4(bst, grp->grp_bsh, | 347 | bus_space_write_4(bst, grp->grp_bsh, | |
347 | AWIN_PIO_PUL0_REG + 4 * i, ncfg->pul[i]); | 348 | AWIN_PIO_PUL0_REG + 4 * i, ncfg->pul[i]); | |
348 | grp->grp_cfg.pul[i] = ncfg->pul[i]; | 349 | grp->grp_cfg.pul[i] = ncfg->pul[i]; | |
349 | } | 350 | } | |
350 | } | 351 | } | |
351 | } | 352 | } | |
352 | 353 | |||
353 | void | 354 | void | |
354 | awin_gpio_init(void) | 355 | awin_gpio_init(void) | |
355 | { | 356 | { | |
356 | struct awin_gpio_softc * const sc = &awin_gpio_sc; | 357 | struct awin_gpio_softc * const sc = &awin_gpio_sc; | |
357 | bus_size_t offset = AWIN_PIO_OFFSET; | 358 | bus_size_t offset = AWIN_PIO_OFFSET; | |
358 | 359 | |||
359 | #ifdef VERBOSE_INIT_ARM | 360 | #ifdef VERBOSE_INIT_ARM | |
360 | printf(" free"); | 361 | printf(" free"); | |
361 | #endif | 362 | #endif | |
362 | for (u_int i = 0; | 363 | for (u_int i = 0; | |
363 | i < __arraycount(pin_groups); | 364 | i < __arraycount(pin_groups); | |
364 | i++, offset += AWIN_PIO_GRP_SIZE) { | 365 | i++, offset += AWIN_PIO_GRP_SIZE) { | |
365 | struct awin_gpio_pin_group * const grp = &pin_groups[i]; | 366 | struct awin_gpio_pin_group * const grp = &pin_groups[i]; | |
366 | bus_space_subregion(sc->sc_bst, awin_core_bsh, | 367 | bus_space_subregion(sc->sc_bst, awin_core_bsh, | |
367 | offset, AWIN_PIO_GRP_SIZE, &grp->grp_bsh); | 368 | offset, AWIN_PIO_GRP_SIZE, &grp->grp_bsh); | |
368 | 369 | |||
369 | for (u_int j = 0; j < 4; j++) { | 370 | for (u_int j = 0; j < 4; j++) { | |
370 | grp->grp_cfg.cfg[j] = bus_space_read_4(sc->sc_bst, | 371 | grp->grp_cfg.cfg[j] = bus_space_read_4(sc->sc_bst, | |
371 | grp->grp_bsh, AWIN_PIO_CFG0_REG + j * 4); | 372 | grp->grp_bsh, AWIN_PIO_CFG0_REG + j * 4); | |
372 | } | 373 | } | |
373 | grp->grp_cfg.drv[0] = bus_space_read_4(sc->sc_bst, | 374 | grp->grp_cfg.drv[0] = bus_space_read_4(sc->sc_bst, | |
374 | grp->grp_bsh, AWIN_PIO_DRV0_REG); | 375 | grp->grp_bsh, AWIN_PIO_DRV0_REG); | |
375 | grp->grp_cfg.drv[1] = bus_space_read_4(sc->sc_bst, | 376 | grp->grp_cfg.drv[1] = bus_space_read_4(sc->sc_bst, | |
376 | grp->grp_bsh, AWIN_PIO_DRV1_REG); | 377 | grp->grp_bsh, AWIN_PIO_DRV1_REG); | |
377 | grp->grp_cfg.pul[0] = bus_space_read_4(sc->sc_bst, | 378 | grp->grp_cfg.pul[0] = bus_space_read_4(sc->sc_bst, | |
378 | grp->grp_bsh, AWIN_PIO_PUL0_REG); | 379 | grp->grp_bsh, AWIN_PIO_PUL0_REG); | |
379 | grp->grp_cfg.pul[1] = bus_space_read_4(sc->sc_bst, | 380 | grp->grp_cfg.pul[1] = bus_space_read_4(sc->sc_bst, | |
380 | grp->grp_bsh, AWIN_PIO_PUL1_REG); | 381 | grp->grp_bsh, AWIN_PIO_PUL1_REG); | |
381 | 382 | |||
382 | for (uint32_t j = 0, mask = 1; | 383 | for (uint32_t j = 0, mask = 1; | |
383 | (mask & grp->grp_pin_mask) != 0; | 384 | (mask & grp->grp_pin_mask) != 0; | |
384 | j++, mask <<= 1) { | 385 | j++, mask <<= 1) { | |
385 | u_int func = awin_gpio_get_pin_func(&grp->grp_cfg, j); | 386 | u_int func = awin_gpio_get_pin_func(&grp->grp_cfg, j); | |
386 | if (func > AWIN_PIO_FUNC_OUTPUT) { | 387 | if (func > AWIN_PIO_FUNC_OUTPUT) { | |
387 | grp->grp_pin_inuse_mask |= mask; | 388 | grp->grp_pin_inuse_mask |= mask; | |
388 | } | 389 | } | |
389 | } | 390 | } | |
390 | #ifdef VERBOSE_INIT_ARM | 391 | #ifdef VERBOSE_INIT_ARM | |
391 | printf(" P%c=%d", 'A' + i, | 392 | printf(" P%c=%d", 'A' + i, | |
392 | popcount32(grp->grp_pin_mask & ~grp->grp_pin_inuse_mask)); | 393 | popcount32(grp->grp_pin_mask & ~grp->grp_pin_inuse_mask)); | |
393 | #endif | 394 | #endif | |
394 | } | 395 | } | |
395 | } | 396 | } | |
396 | 397 | |||
397 | bool | 398 | bool | |
398 | awin_gpio_pinset_available(const struct awin_gpio_pinset *req) | 399 | awin_gpio_pinset_available(const struct awin_gpio_pinset *req) | |
399 | { | 400 | { | |
400 | KASSERT(req != NULL); | 401 | KASSERT(req != NULL); | |
401 | 402 | |||
402 | if (!req->pinset_group) | 403 | if (!req->pinset_group) | |
403 | return false; | 404 | return false; | |
404 | 405 | |||
405 | KASSERT('A' <= req->pinset_group && req->pinset_group <= 'I'); | 406 | KASSERT('A' <= req->pinset_group && req->pinset_group <= 'I'); | |
406 | 407 | |||
407 | struct awin_gpio_pin_group * const grp = | 408 | struct awin_gpio_pin_group * const grp = | |
408 | &pin_groups[req->pinset_group - 'A']; | 409 | &pin_groups[req->pinset_group - 'A']; | |
409 | 410 | |||
410 | /* | 411 | /* | |
411 | * If there are unconnected pins, then they've been remove from | 412 | * If there are unconnected pins, then they've been remove from | |
412 | * the groups pin mask. If we want pins that are unconnected, | 413 | * the groups pin mask. If we want pins that are unconnected, | |
413 | * fail the request. | 414 | * fail the request. | |
414 | */ | 415 | */ | |
415 | if (req->pinset_mask & ~grp->grp_pin_mask) | 416 | if (req->pinset_mask & ~grp->grp_pin_mask) | |
416 | return false; | 417 | return false; | |
417 | 418 | |||
418 | /* | 419 | /* | |
419 | * If none of the pins are in use, they must be available. | 420 | * If none of the pins are in use, they must be available. | |
420 | */ | 421 | */ | |
421 | if (req->pinset_mask & ~grp->grp_pin_inuse_mask) | 422 | if (req->pinset_mask & ~grp->grp_pin_inuse_mask) | |
422 | return true; | 423 | return true; | |
423 | 424 | |||
424 | /* | 425 | /* | |
425 | * Check to see if the pins are already setup for this function. | 426 | * Check to see if the pins are already setup for this function. | |
426 | */ | 427 | */ | |
427 | for (uint32_t j = 0, inuse = req->pinset_mask & grp->grp_pin_inuse_mask; | 428 | for (uint32_t j = 0, inuse = req->pinset_mask & grp->grp_pin_inuse_mask; | |
428 | inuse != 0; | 429 | inuse != 0; | |
429 | j++, inuse >>= 1) { | 430 | j++, inuse >>= 1) { | |
430 | const u_int n = ffs(inuse) - 1; | 431 | const u_int n = ffs(inuse) - 1; | |
431 | j += n; | 432 | j += n; | |
432 | inuse >>= n; | 433 | inuse >>= n; | |
433 | /* | 434 | /* | |
434 | * If this pin is in use but it's for a different | 435 | * If this pin is in use but it's for a different | |
435 | * function, fail the request. | 436 | * function, fail the request. | |
436 | */ | 437 | */ | |
437 | if (awin_gpio_get_pin_func(&grp->grp_cfg, j) != req->pinset_func) | 438 | if (awin_gpio_get_pin_func(&grp->grp_cfg, j) != req->pinset_func) | |
438 | return false; | 439 | return false; | |
439 | } | 440 | } | |
440 | 441 | |||
441 | /* | 442 | /* | |
442 | * Nothing incompatible encountered so the pins must be available. | 443 | * Nothing incompatible encountered so the pins must be available. | |
443 | */ | 444 | */ | |
444 | return true; | 445 | return true; | |
445 | } | 446 | } | |
446 | 447 | |||
447 | void | 448 | void | |
448 | awin_gpio_pinset_acquire(const struct awin_gpio_pinset *req) | 449 | awin_gpio_pinset_acquire(const struct awin_gpio_pinset *req) | |
449 | { | 450 | { | |
450 | KASSERT(awin_gpio_pinset_available(req)); | 451 | KASSERT(awin_gpio_pinset_available(req)); | |
451 | 452 | |||
452 | struct awin_gpio_pin_group * const grp = | 453 | struct awin_gpio_pin_group * const grp = | |
453 | &pin_groups[req->pinset_group - 'A']; | 454 | &pin_groups[req->pinset_group - 'A']; | |
454 | 455 | |||
455 | 456 | |||
456 | /* | 457 | /* | |
457 | * If all the pins already have right function, just return. | 458 | * If all the pins already have right function, just return. | |
458 | */ | 459 | */ | |
459 | if ((req->pinset_mask & ~grp->grp_pin_inuse_mask) == 0) { | 460 | if ((req->pinset_mask & ~grp->grp_pin_inuse_mask) == 0) { | |
460 | return; | 461 | return; | |
461 | } | 462 | } | |
462 | 463 | |||
463 | /* | 464 | /* | |
464 | * Copy the current config. | 465 | * Copy the current config. | |
465 | */ | 466 | */ | |
466 | struct awin_gpio_pin_cfg ncfg = grp->grp_cfg; | 467 | struct awin_gpio_pin_cfg ncfg = grp->grp_cfg; | |
467 | 468 | |||
468 | /* | 469 | /* | |
469 | * For each pin not inuse, update the cloned config's function for it. | 470 | * For each pin not inuse, update the cloned config's function for it. | |
470 | */ | 471 | */ | |
471 | for (uint32_t j = 0, todo = req->pinset_mask & ~grp->grp_pin_inuse_mask; | 472 | for (uint32_t j = 0, todo = req->pinset_mask & ~grp->grp_pin_inuse_mask; | |
472 | todo != 0; | 473 | todo != 0; | |
473 | j++, todo >>= 1) { | 474 | j++, todo >>= 1) { | |
474 | const u_int n = ffs(todo) - 1; | 475 | const u_int n = ffs(todo) - 1; | |
475 | j += n; | 476 | j += n; | |
476 | todo >>= n; | 477 | todo >>= n; | |
477 | /* | 478 | /* | |
478 | * Change the function of this pin. | 479 | * Change the function of this pin. | |
479 | */ | 480 | */ | |
480 | awin_gpio_set_pin_func(&ncfg, j, req->pinset_func); | 481 | awin_gpio_set_pin_func(&ncfg, j, req->pinset_func); | |
481 | } | 482 | } | |
482 | 483 | |||
483 | /* | 484 | /* | |
484 | * Now update any config register that changed. | 485 | * Now update any config register that changed. | |
485 | */ | 486 | */ | |
486 | awin_gpio_update_cfg_regs(&awin_bs_tag, grp, &ncfg); | 487 | awin_gpio_update_cfg_regs(&awin_bs_tag, grp, &ncfg); | |
487 | 488 | |||
488 | /* | 489 | /* | |
489 | * Mark all these pins as in use. | 490 | * Mark all these pins as in use. | |
490 | */ | 491 | */ | |
491 | grp->grp_pin_inuse_mask |= req->pinset_mask; | 492 | grp->grp_pin_inuse_mask |= req->pinset_mask; | |
492 | } | 493 | } | |
493 | 494 | |||
494 | void | 495 | void | |
495 | awin_gpio_pinset_release(const struct awin_gpio_pinset *req) | 496 | awin_gpio_pinset_release(const struct awin_gpio_pinset *req) | |
496 | { | 497 | { | |
497 | KASSERT(awin_gpio_pinset_available(req)); | 498 | KASSERT(awin_gpio_pinset_available(req)); | |
498 | 499 | |||
499 | struct awin_gpio_pin_group * const grp = | 500 | struct awin_gpio_pin_group * const grp = | |
500 | &pin_groups[req->pinset_group - 'A']; | 501 | &pin_groups[req->pinset_group - 'A']; | |
501 | 502 | |||
502 | #if 0 | 503 | #if 0 | |
503 | /* | 504 | /* | |
504 | * Copy the current config. | 505 | * Copy the current config. | |
505 | */ | 506 | */ | |
506 | struct awin_gpio_pin_cfg ncfg = grp->grp_cfg; | 507 | struct awin_gpio_pin_cfg ncfg = grp->grp_cfg; | |
507 | 508 | |||
508 | /* | 509 | /* | |
509 | * For each pin not inuse, update the cloned config's function for it. | 510 | * For each pin not inuse, update the cloned config's function for it. | |
510 | */ | 511 | */ | |
511 | for (uint32_t j = 0, todo = req->pinset_mask; | 512 | for (uint32_t j = 0, todo = req->pinset_mask; | |
512 | todo != 0; | 513 | todo != 0; | |
513 | j++, todo >>= 1) { | 514 | j++, todo >>= 1) { | |
514 | const u_int n = ffs(todo) - 1; | 515 | const u_int n = ffs(todo) - 1; | |
515 | j += n; | 516 | j += n; | |
516 | todo >>= n; | 517 | todo >>= n; | |
517 | /* | 518 | /* | |
518 | * Change the function of this pin. | 519 | * Change the function of this pin. | |
519 | */ | 520 | */ | |
520 | awin_gpio_set_pin_func(&ncfg, AWIN_PIO_FUNC_INPUT); | 521 | awin_gpio_set_pin_func(&ncfg, AWIN_PIO_FUNC_INPUT); | |
521 | } | 522 | } | |
522 | 523 | |||
523 | /* | 524 | /* | |
524 | * Now update any config register that changed. | 525 | * Now update any config register that changed. | |
525 | */ | 526 | */ | |
526 | awin_gpio_update_cfg_regs(sc->sc_bst, grp, &ncfg); | 527 | awin_gpio_update_cfg_regs(sc->sc_bst, grp, &ncfg); | |
527 | #endif | 528 | #endif | |
528 | 529 | |||
529 | /* | 530 | /* | |
530 | * Clear these pins as being in use. | 531 | * Clear these pins as being in use. | |
531 | */ | 532 | */ | |
532 | grp->grp_pin_inuse_mask &= ~req->pinset_mask; | 533 | grp->grp_pin_inuse_mask &= ~req->pinset_mask; | |
533 | } | 534 | } | |
534 | 535 | |||
535 | static int | 536 | static int | |
536 | awin_gpio_pin_read(void *cookie, int pin) | 537 | awin_gpio_pin_read(void *cookie, int pin) | |
537 | { | 538 | { | |
538 | struct awin_gpio_pin_group * const grp = cookie; | 539 | struct awin_gpio_pin_group * const grp = cookie; | |
539 | 540 | |||
540 | KASSERT(pin < 32); | 541 | KASSERT(pin < 32); | |
541 | 542 | |||
542 | return (bus_space_read_4(awin_gpio_sc.sc_bst, grp->grp_bsh, | 543 | return (bus_space_read_4(awin_gpio_sc.sc_bst, grp->grp_bsh, | |
543 | AWIN_PIO_DAT_REG) >> pin) & 1; | 544 | AWIN_PIO_DAT_REG) >> pin) & 1; | |
544 | } | 545 | } | |
545 | 546 | |||
546 | static void | 547 | static void | |
547 | awin_gpio_pin_write(void *cookie, int pin, int value) | 548 | awin_gpio_pin_write(void *cookie, int pin, int value) | |
548 | { | 549 | { | |
549 | struct awin_gpio_pin_group * const grp = cookie; | 550 | struct awin_gpio_pin_group * const grp = cookie; | |
550 | 551 | |||
551 | KASSERT(pin < 32); | 552 | KASSERT(pin < 32); | |
552 | 553 | |||
553 | awin_reg_set_clear(awin_gpio_sc.sc_bst, grp->grp_bsh, | 554 | awin_reg_set_clear(awin_gpio_sc.sc_bst, grp->grp_bsh, | |
554 | AWIN_PIO_DAT_REG, value ? __BIT(pin) : 0, __BIT(pin)); | 555 | AWIN_PIO_DAT_REG, value ? __BIT(pin) : 0, __BIT(pin)); | |
555 | } | 556 | } | |
556 | 557 | |||
557 | static void | 558 | static void | |
558 | awin_gpio_pin_ctl(void *cookie, int pin, int flags) | 559 | awin_gpio_pin_ctl(void *cookie, int pin, int flags) | |
559 | { | 560 | { | |
560 | struct awin_gpio_pin_group * const grp = cookie; | 561 | struct awin_gpio_pin_group * const grp = cookie; | |
561 | struct awin_gpio_pin_cfg ncfg = grp->grp_cfg; | 562 | struct awin_gpio_pin_cfg ncfg = grp->grp_cfg; | |
562 | 563 | |||
563 | u_int pull_value = AWIN_PIO_PULL_NONE; | 564 | u_int pull_value = AWIN_PIO_PULL_NONE; | |
564 | if (flags & GPIO_PIN_PULLUP) { | 565 | if (flags & GPIO_PIN_PULLUP) { | |
565 | pull_value = AWIN_PIO_PULL_UP; | 566 | pull_value = AWIN_PIO_PULL_UP; | |
566 | } else if (flags & GPIO_PIN_PULLDOWN) { | 567 | } else if (flags & GPIO_PIN_PULLDOWN) { | |
567 | pull_value = AWIN_PIO_PULL_DOWN; | 568 | pull_value = AWIN_PIO_PULL_DOWN; | |
568 | } | 569 | } | |
569 | awin_gpio_set_pin_pull(&ncfg, pin, pull_value); | 570 | awin_gpio_set_pin_pull(&ncfg, pin, pull_value); | |
570 | 571 | |||
571 | if (flags & GPIO_PIN_INPUT) { | 572 | if (flags & GPIO_PIN_INPUT) { | |
572 | awin_gpio_set_pin_func(&ncfg, pin, AWIN_PIO_FUNC_INPUT); | 573 | awin_gpio_set_pin_func(&ncfg, pin, AWIN_PIO_FUNC_INPUT); | |
573 | } else if (flags & GPIO_PIN_OUTPUT) { | 574 | } else if (flags & GPIO_PIN_OUTPUT) { | |
574 | awin_gpio_set_pin_func(&ncfg, pin, AWIN_PIO_FUNC_OUTPUT); | 575 | awin_gpio_set_pin_func(&ncfg, pin, AWIN_PIO_FUNC_OUTPUT); | |
575 | } | 576 | } | |
576 | 577 | |||
577 | /* | 578 | /* | |
578 | * Now update any config register that changed. | 579 | * Now update any config register that changed. | |
579 | */ | 580 | */ | |
580 | awin_gpio_update_cfg_regs(&awin_bs_tag, grp, &ncfg); | 581 | awin_gpio_update_cfg_regs(&awin_bs_tag, grp, &ncfg); | |
581 | } | 582 | } | |
582 | 583 | |||
583 | bool | 584 | bool | |
584 | awin_gpio_pin_reserve(const char *name, struct awin_gpio_pindata *pd) | 585 | awin_gpio_pin_reserve(const char *name, struct awin_gpio_pindata *pd) | |
585 | { | 586 | { | |
586 | struct awin_gpio_softc * const sc = &awin_gpio_sc; | 587 | struct awin_gpio_softc * const sc = &awin_gpio_sc; | |
587 | prop_dictionary_t dict = device_properties(sc->sc_dev); | 588 | prop_dictionary_t dict = device_properties(sc->sc_dev); | |
588 | const char *pin_data; | 589 | const char *pin_data; | |
589 | 590 | |||
590 | if (!prop_dictionary_get_cstring_nocopy(dict, name, &pin_data)) | 591 | if (!prop_dictionary_get_cstring_nocopy(dict, name, &pin_data)) | |
591 | return false; | 592 | return false; | |
592 | 593 | |||
593 | KASSERT(pin_data[0] == '>' || pin_data[0] == '<'); | 594 | KASSERT(pin_data[0] == '>' || pin_data[0] == '<'); | |
594 | KASSERT(pin_data[1] == 'P'); | 595 | KASSERT(pin_data[1] == 'P'); | |
595 | 596 | |||
596 | KASSERT('A' <= pin_data[2] && pin_data[2] <= 'I'); | 597 | KASSERT('A' <= pin_data[2] && pin_data[2] <= 'I'); | |
597 | struct awin_gpio_pin_group * const grp = &pin_groups[pin_data[2] - 'A']; | 598 | struct awin_gpio_pin_group * const grp = &pin_groups[pin_data[2] - 'A']; | |
598 | 599 | |||
599 | u_int pin = pin_data[3] - '0'; | 600 | u_int pin = pin_data[3] - '0'; | |
600 | KASSERT(pin < 10); | 601 | KASSERT(pin < 10); | |
601 | if (pin_data[4] != 0) { | 602 | if (pin_data[4] != 0) { | |
602 | KASSERT(pin_data[5] == 0); | 603 | KASSERT(pin_data[5] == 0); | |
603 | pin = pin * 10 + pin_data[4] - '0'; | 604 | pin = pin * 10 + pin_data[4] - '0'; | |
604 | } | 605 | } | |
605 | 606 | |||
606 | KASSERT(pin < 32); | 607 | KASSERT(pin < 32); | |
607 | KASSERT(grp->grp_pin_mask & __BIT(pin)); | 608 | KASSERT(grp->grp_pin_mask & __BIT(pin)); | |
608 | KASSERT((grp->grp_pin_inuse_mask & __BIT(pin)) == 0); | 609 | KASSERT((grp->grp_pin_inuse_mask & __BIT(pin)) == 0); | |
609 | 610 | |||
610 | struct awin_gpio_pin_cfg ncfg = grp->grp_cfg; | 611 | struct awin_gpio_pin_cfg ncfg = grp->grp_cfg; | |
611 | awin_gpio_set_pin_func(&ncfg, pin, | 612 | awin_gpio_set_pin_func(&ncfg, pin, | |
612 | pin_data[0] == '<' ? AWIN_PIO_FUNC_INPUT : AWIN_PIO_FUNC_OUTPUT); | 613 | pin_data[0] == '<' ? AWIN_PIO_FUNC_INPUT : AWIN_PIO_FUNC_OUTPUT); | |
613 | 614 | |||
614 | /* | 615 | /* | |
615 | * Now update any config register that changed. | 616 | * Now update any config register that changed. | |
616 | */ | 617 | */ | |
617 | awin_gpio_update_cfg_regs(sc->sc_bst, grp, &ncfg); | 618 | awin_gpio_update_cfg_regs(sc->sc_bst, grp, &ncfg); | |
618 | 619 | |||
619 | grp->grp_pin_inuse_mask &= ~__BIT(pin); | 620 | grp->grp_pin_inuse_mask &= ~__BIT(pin); | |
620 | 621 | |||
621 | pd->pd_gc = &grp->grp_gc_tag; | 622 | pd->pd_gc = &grp->grp_gc_tag; | |
622 | pd->pd_pin = pin; | 623 | pd->pd_pin = pin; | |
623 | return true; | 624 | return true; | |
624 | } | 625 | } |
--- src/sys/arch/arm/allwinner/Attic/awin_icu.c 2013/09/04 02:39:01 1.1
+++ src/sys/arch/arm/allwinner/Attic/awin_icu.c 2014/02/20 21:48:38 1.2
@@ -1,89 +1,90 @@ | @@ -1,89 +1,90 @@ | |||
1 | /*- | 1 | /*- | |
2 | * Copyright (c) 2013 The NetBSD Foundation, Inc. | 2 | * Copyright (c) 2013 The NetBSD Foundation, Inc. | |
3 | * All rights reserved. | 3 | * All rights reserved. | |
4 | * | 4 | * | |
5 | * This code is derived from software contributed to The NetBSD Foundation | 5 | * This code is derived from software contributed to The NetBSD Foundation | |
6 | * by Matt Thomas of 3am Software Foundry. | 6 | * by Matt Thomas of 3am Software Foundry. | |
7 | * | 7 | * | |
8 | * Redistribution and use in source and binary forms, with or without | 8 | * Redistribution and use in source and binary forms, with or without | |
9 | * modification, are permitted provided that the following conditions | 9 | * modification, are permitted provided that the following conditions | |
10 | * are met: | 10 | * are met: | |
11 | * 1. Redistributions of source code must retain the above copyright | 11 | * 1. Redistributions of source code must retain the above copyright | |
12 | * notice, this list of conditions and the following disclaimer. | 12 | * notice, this list of conditions and the following disclaimer. | |
13 | * 2. Redistributions in binary form must reproduce the above copyright | 13 | * 2. Redistributions in binary form must reproduce the above copyright | |
14 | * notice, this list of conditions and the following disclaimer in the | 14 | * notice, this list of conditions and the following disclaimer in the | |
15 | * documentation and/or other materials provided with the distribution. | 15 | * documentation and/or other materials provided with the distribution. | |
16 | * | 16 | * | |
17 | * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS | 17 | * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS | |
18 | * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED | 18 | * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED | |
19 | * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR | 19 | * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR | |
20 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS | 20 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS | |
21 | * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR | 21 | * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR | |
22 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF | 22 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF | |
23 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS | 23 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS | |
24 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN | 24 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN | |
25 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | 25 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | |
26 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | 26 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | |
27 | * POSSIBILITY OF SUCH DAMAGE. | 27 | * POSSIBILITY OF SUCH DAMAGE. | |
28 | */ | 28 | */ | |
29 | 29 | |||
30 | #include "locators.h" | 30 | #include "locators.h" | |
31 | 31 | |||
32 | #include <sys/cdefs.h> | 32 | #include <sys/cdefs.h> | |
33 | 33 | |||
34 | __KERNEL_RCSID(1, "$NetBSD: awin_icu.c,v 1.1 2013/09/04 02:39:01 matt Exp $"); | 34 | __KERNEL_RCSID(1, "$NetBSD: awin_icu.c,v 1.2 2014/02/20 21:48:38 matt Exp $"); | |
35 | 35 | |||
36 | #include <sys/param.h> | |||
36 | #include <sys/bus.h> | 37 | #include <sys/bus.h> | |
37 | #include <sys/device.h> | 38 | #include <sys/device.h> | |
38 | #include <sys/intr.h> | 39 | #include <sys/intr.h> | |
39 | #include <sys/systm.h> | 40 | #include <sys/systm.h> | |
40 | 41 | |||
41 | #include <arm/allwinner/awin_reg.h> | 42 | #include <arm/allwinner/awin_reg.h> | |
42 | #include <arm/allwinner/awin_var.h> | 43 | #include <arm/allwinner/awin_var.h> | |
43 | 44 | |||
44 | static int awin_icu_match(device_t, cfdata_t, void *); | 45 | static int awin_icu_match(device_t, cfdata_t, void *); | |
45 | static void awin_icu_attach(device_t, device_t, void *); | 46 | static void awin_icu_attach(device_t, device_t, void *); | |
46 | 47 | |||
47 | struct awin_icu_softc { | 48 | struct awin_icu_softc { | |
48 | device_t sc_dev; | 49 | device_t sc_dev; | |
49 | bus_space_tag_t sc_bst; | 50 | bus_space_tag_t sc_bst; | |
50 | bus_space_handle_t sc_bsh; | 51 | bus_space_handle_t sc_bsh; | |
51 | bus_dma_tag_t sc_dmat; | 52 | bus_dma_tag_t sc_dmat; | |
52 | }; | 53 | }; | |
53 | 54 | |||
54 | CFATTACH_DECL_NEW(awin_icu, sizeof(struct awin_icu_softc), | 55 | CFATTACH_DECL_NEW(awin_icu, sizeof(struct awin_icu_softc), | |
55 | awin_icu_match, awin_icu_attach, NULL, NULL); | 56 | awin_icu_match, awin_icu_attach, NULL, NULL); | |
56 | 57 | |||
57 | static int | 58 | static int | |
58 | awin_icu_match(device_t parent, cfdata_t cf, void *aux) | 59 | awin_icu_match(device_t parent, cfdata_t cf, void *aux) | |
59 | { | 60 | { | |
60 | struct awinio_attach_args * const aio = aux; | 61 | struct awinio_attach_args * const aio = aux; | |
61 | const struct awin_locators * const loc = &aio->aio_loc; | 62 | const struct awin_locators * const loc = &aio->aio_loc; | |
62 | const int port = cf->cf_loc[AWINIOCF_PORT]; | 63 | const int port = cf->cf_loc[AWINIOCF_PORT]; | |
63 | 64 | |||
64 | KASSERT(loc->loc_port == AWINIOCF_PORT_DEFAULT); | 65 | KASSERT(loc->loc_port == AWINIOCF_PORT_DEFAULT); | |
65 | 66 | |||
66 | if (strcmp(cf->cf_name, loc->loc_name) | 67 | if (strcmp(cf->cf_name, loc->loc_name) | |
67 | || (port != AWINIOCF_PORT_DEFAULT && port != loc->loc_port)) | 68 | || (port != AWINIOCF_PORT_DEFAULT && port != loc->loc_port)) | |
68 | return 0; | 69 | return 0; | |
69 | 70 | |||
70 | return 1; | 71 | return 1; | |
71 | } | 72 | } | |
72 | 73 | |||
73 | static void | 74 | static void | |
74 | awin_icu_attach(device_t parent, device_t self, void *aux) | 75 | awin_icu_attach(device_t parent, device_t self, void *aux) | |
75 | { | 76 | { | |
76 | struct awin_icu_softc * const sc = device_private(self); | 77 | struct awin_icu_softc * const sc = device_private(self); | |
77 | struct awinio_attach_args * const aio = aux; | 78 | struct awinio_attach_args * const aio = aux; | |
78 | const struct awin_locators * const loc = &aio->aio_loc; | 79 | const struct awin_locators * const loc = &aio->aio_loc; | |
79 | 80 | |||
80 | sc->sc_dev = self; | 81 | sc->sc_dev = self; | |
81 | 82 | |||
82 | sc->sc_bst = aio->aio_core_bst; | 83 | sc->sc_bst = aio->aio_core_bst; | |
83 | sc->sc_dmat = aio->aio_dmat; | 84 | sc->sc_dmat = aio->aio_dmat; | |
84 | bus_space_subregion(sc->sc_bst, aio->aio_core_bsh, | 85 | bus_space_subregion(sc->sc_bst, aio->aio_core_bsh, | |
85 | loc->loc_offset, loc->loc_size, &sc->sc_bsh); | 86 | loc->loc_offset, loc->loc_size, &sc->sc_bsh); | |
86 | 87 | |||
87 | aprint_naive("\n"); | 88 | aprint_naive("\n"); | |
88 | aprint_normal("\n"); | 89 | aprint_normal("\n"); | |
89 | } | 90 | } |
--- src/sys/arch/arm/allwinner/Attic/awin_nand.c 2013/09/04 02:39:01 1.1
+++ src/sys/arch/arm/allwinner/Attic/awin_nand.c 2014/02/20 21:48:38 1.2
@@ -1,87 +1,88 @@ | @@ -1,87 +1,88 @@ | |||
1 | /*- | 1 | /*- | |
2 | * Copyright (c) 2013 The NetBSD Foundation, Inc. | 2 | * Copyright (c) 2013 The NetBSD Foundation, Inc. | |
3 | * All rights reserved. | 3 | * All rights reserved. | |
4 | * | 4 | * | |
5 | * This code is derived from software contributed to The NetBSD Foundation | 5 | * This code is derived from software contributed to The NetBSD Foundation | |
6 | * by Matt Thomas of 3am Software Foundry. | 6 | * by Matt Thomas of 3am Software Foundry. | |
7 | * | 7 | * | |
8 | * Redistribution and use in source and binary forms, with or without | 8 | * Redistribution and use in source and binary forms, with or without | |
9 | * modification, are permitted provided that the following conditions | 9 | * modification, are permitted provided that the following conditions | |
10 | * are met: | 10 | * are met: | |
11 | * 1. Redistributions of source code must retain the above copyright | 11 | * 1. Redistributions of source code must retain the above copyright | |
12 | * notice, this list of conditions and the following disclaimer. | 12 | * notice, this list of conditions and the following disclaimer. | |
13 | * 2. Redistributions in binary form must reproduce the above copyright | 13 | * 2. Redistributions in binary form must reproduce the above copyright | |
14 | * notice, this list of conditions and the following disclaimer in the | 14 | * notice, this list of conditions and the following disclaimer in the | |
15 | * documentation and/or other materials provided with the distribution. | 15 | * documentation and/or other materials provided with the distribution. | |
16 | * | 16 | * | |
17 | * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS | 17 | * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS | |
18 | * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED | 18 | * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED | |
19 | * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR | 19 | * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR | |
20 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS | 20 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS | |
21 | * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR | 21 | * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR | |
22 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF | 22 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF | |
23 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS | 23 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS | |
24 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN | 24 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN | |
25 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | 25 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | |
26 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | 26 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | |
27 | * POSSIBILITY OF SUCH DAMAGE. | 27 | * POSSIBILITY OF SUCH DAMAGE. | |
28 | */ | 28 | */ | |
29 | 29 | |||
30 | #include "locators.h" | 30 | #include "locators.h" | |
31 | 31 | |||
32 | #include <sys/cdefs.h> | 32 | #include <sys/cdefs.h> | |
33 | 33 | |||
34 | __KERNEL_RCSID(1, "$NetBSD: awin_nand.c,v 1.1 2013/09/04 02:39:01 matt Exp $"); | 34 | __KERNEL_RCSID(1, "$NetBSD: awin_nand.c,v 1.2 2014/02/20 21:48:38 matt Exp $"); | |
35 | 35 | |||
36 | #include <sys/param.h> | |||
36 | #include <sys/bus.h> | 37 | #include <sys/bus.h> | |
37 | #include <sys/device.h> | 38 | #include <sys/device.h> | |
38 | #include <sys/intr.h> | 39 | #include <sys/intr.h> | |
39 | #include <sys/systm.h> | 40 | #include <sys/systm.h> | |
40 | 41 | |||
41 | #include <arm/allwinner/awin_reg.h> | 42 | #include <arm/allwinner/awin_reg.h> | |
42 | #include <arm/allwinner/awin_var.h> | 43 | #include <arm/allwinner/awin_var.h> | |
43 | 44 | |||
44 | static int awin_nand_match(device_t, cfdata_t, void *); | 45 | static int awin_nand_match(device_t, cfdata_t, void *); | |
45 | static void awin_nand_attach(device_t, device_t, void *); | 46 | static void awin_nand_attach(device_t, device_t, void *); | |
46 | 47 | |||
47 | struct awin_nand_softc { | 48 | struct awin_nand_softc { | |
48 | device_t sc_dev; | 49 | device_t sc_dev; | |
49 | bus_space_tag_t sc_bst; | 50 | bus_space_tag_t sc_bst; | |
50 | bus_space_handle_t sc_bsh; | 51 | bus_space_handle_t sc_bsh; | |
51 | bus_dma_tag_t sc_dmat; | 52 | bus_dma_tag_t sc_dmat; | |
52 | }; | 53 | }; | |
53 | 54 | |||
54 | CFATTACH_DECL_NEW(awin_nand, sizeof(struct awin_nand_softc), | 55 | CFATTACH_DECL_NEW(awin_nand, sizeof(struct awin_nand_softc), | |
55 | awin_nand_match, awin_nand_attach, NULL, NULL); | 56 | awin_nand_match, awin_nand_attach, NULL, NULL); | |
56 | 57 | |||
57 | static int | 58 | static int | |
58 | awin_nand_match(device_t parent, cfdata_t cf, void *aux) | 59 | awin_nand_match(device_t parent, cfdata_t cf, void *aux) | |
59 | { | 60 | { | |
60 | struct awinio_attach_args * const aio = aux; | 61 | struct awinio_attach_args * const aio = aux; | |
61 | const struct awin_locators * const loc = &aio->aio_loc; | 62 | const struct awin_locators * const loc = &aio->aio_loc; | |
62 | 63 | |||
63 | if (strcmp(cf->cf_name, loc->loc_name)) | 64 | if (strcmp(cf->cf_name, loc->loc_name)) | |
64 | return 0; | 65 | return 0; | |
65 | 66 | |||
66 | KASSERT(cf->cf_loc[AWINIOCF_PORT] == AWINIOCF_PORT_DEFAULT); | 67 | KASSERT(cf->cf_loc[AWINIOCF_PORT] == AWINIOCF_PORT_DEFAULT); | |
67 | 68 | |||
68 | return 1; | 69 | return 1; | |
69 | } | 70 | } | |
70 | 71 | |||
71 | static void | 72 | static void | |
72 | awin_nand_attach(device_t parent, device_t self, void *aux) | 73 | awin_nand_attach(device_t parent, device_t self, void *aux) | |
73 | { | 74 | { | |
74 | struct awin_nand_softc * const sc = device_private(self); | 75 | struct awin_nand_softc * const sc = device_private(self); | |
75 | struct awinio_attach_args * const aio = aux; | 76 | struct awinio_attach_args * const aio = aux; | |
76 | const struct awin_locators * const loc = &aio->aio_loc; | 77 | const struct awin_locators * const loc = &aio->aio_loc; | |
77 | 78 | |||
78 | sc->sc_dev = self; | 79 | sc->sc_dev = self; | |
79 | 80 | |||
80 | sc->sc_bst = aio->aio_core_bst; | 81 | sc->sc_bst = aio->aio_core_bst; | |
81 | sc->sc_dmat = aio->aio_dmat; | 82 | sc->sc_dmat = aio->aio_dmat; | |
82 | bus_space_subregion(sc->sc_bst, aio->aio_core_bsh, | 83 | bus_space_subregion(sc->sc_bst, aio->aio_core_bsh, | |
83 | loc->loc_offset, loc->loc_size, &sc->sc_bsh); | 84 | loc->loc_offset, loc->loc_size, &sc->sc_bsh); | |
84 | 85 | |||
85 | aprint_naive("\n"); | 86 | aprint_naive("\n"); | |
86 | aprint_normal("\n"); | 87 | aprint_normal("\n"); | |
87 | } | 88 | } |
--- src/sys/arch/arm/allwinner/Attic/awin_tmr.c 2013/09/04 02:39:01 1.1
+++ src/sys/arch/arm/allwinner/Attic/awin_tmr.c 2014/02/20 21:48:38 1.2
@@ -1,89 +1,90 @@ | @@ -1,89 +1,90 @@ | |||
1 | /*- | 1 | /*- | |
2 | * Copyright (c) 2013 The NetBSD Foundation, Inc. | 2 | * Copyright (c) 2013 The NetBSD Foundation, Inc. | |
3 | * All rights reserved. | 3 | * All rights reserved. | |
4 | * | 4 | * | |
5 | * This code is derived from software contributed to The NetBSD Foundation | 5 | * This code is derived from software contributed to The NetBSD Foundation | |
6 | * by Matt Thomas of 3am Software Foundry. | 6 | * by Matt Thomas of 3am Software Foundry. | |
7 | * | 7 | * | |
8 | * Redistribution and use in source and binary forms, with or without | 8 | * Redistribution and use in source and binary forms, with or without | |
9 | * modification, are permitted provided that the following conditions | 9 | * modification, are permitted provided that the following conditions | |
10 | * are met: | 10 | * are met: | |
11 | * 1. Redistributions of source code must retain the above copyright | 11 | * 1. Redistributions of source code must retain the above copyright | |
12 | * notice, this list of conditions and the following disclaimer. | 12 | * notice, this list of conditions and the following disclaimer. | |
13 | * 2. Redistributions in binary form must reproduce the above copyright | 13 | * 2. Redistributions in binary form must reproduce the above copyright | |
14 | * notice, this list of conditions and the following disclaimer in the | 14 | * notice, this list of conditions and the following disclaimer in the | |
15 | * documentation and/or other materials provided with the distribution. | 15 | * documentation and/or other materials provided with the distribution. | |
16 | * | 16 | * | |
17 | * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS | 17 | * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS | |
18 | * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED | 18 | * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED | |
19 | * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR | 19 | * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR | |
20 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS | 20 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS | |
21 | * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR | 21 | * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR | |
22 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF | 22 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF | |
23 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS | 23 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS | |
24 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN | 24 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN | |
25 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | 25 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | |
26 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | 26 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | |
27 | * POSSIBILITY OF SUCH DAMAGE. | 27 | * POSSIBILITY OF SUCH DAMAGE. | |
28 | */ | 28 | */ | |
29 | 29 | |||
30 | #include "locators.h" | 30 | #include "locators.h" | |
31 | 31 | |||
32 | #include <sys/cdefs.h> | 32 | #include <sys/cdefs.h> | |
33 | 33 | |||
34 | __KERNEL_RCSID(1, "$NetBSD: awin_tmr.c,v 1.1 2013/09/04 02:39:01 matt Exp $"); | 34 | __KERNEL_RCSID(1, "$NetBSD: awin_tmr.c,v 1.2 2014/02/20 21:48:38 matt Exp $"); | |
35 | 35 | |||
36 | #include <sys/param.h> | |||
36 | #include <sys/bus.h> | 37 | #include <sys/bus.h> | |
37 | #include <sys/device.h> | 38 | #include <sys/device.h> | |
38 | #include <sys/intr.h> | 39 | #include <sys/intr.h> | |
39 | #include <sys/systm.h> | 40 | #include <sys/systm.h> | |
40 | 41 | |||
41 | #include <arm/allwinner/awin_reg.h> | 42 | #include <arm/allwinner/awin_reg.h> | |
42 | #include <arm/allwinner/awin_var.h> | 43 | #include <arm/allwinner/awin_var.h> | |
43 | 44 | |||
44 | static int awin_tmr_match(device_t, cfdata_t, void *); | 45 | static int awin_tmr_match(device_t, cfdata_t, void *); | |
45 | static void awin_tmr_attach(device_t, device_t, void *); | 46 | static void awin_tmr_attach(device_t, device_t, void *); | |
46 | 47 | |||
47 | struct awin_tmr_softc { | 48 | struct awin_tmr_softc { | |
48 | device_t sc_dev; | 49 | device_t sc_dev; | |
49 | bus_space_tag_t sc_bst; | 50 | bus_space_tag_t sc_bst; | |
50 | bus_space_handle_t sc_bsh; | 51 | bus_space_handle_t sc_bsh; | |
51 | bus_dma_tag_t sc_dmat; | 52 | bus_dma_tag_t sc_dmat; | |
52 | }; | 53 | }; | |
53 | 54 | |||
54 | CFATTACH_DECL_NEW(awin_tmr, sizeof(struct awin_tmr_softc), | 55 | CFATTACH_DECL_NEW(awin_tmr, sizeof(struct awin_tmr_softc), | |
55 | awin_tmr_match, awin_tmr_attach, NULL, NULL); | 56 | awin_tmr_match, awin_tmr_attach, NULL, NULL); | |
56 | 57 | |||
57 | static int | 58 | static int | |
58 | awin_tmr_match(device_t parent, cfdata_t cf, void *aux) | 59 | awin_tmr_match(device_t parent, cfdata_t cf, void *aux) | |
59 | { | 60 | { | |
60 | struct awinio_attach_args * const aio = aux; | 61 | struct awinio_attach_args * const aio = aux; | |
61 | const struct awin_locators * const loc = &aio->aio_loc; | 62 | const struct awin_locators * const loc = &aio->aio_loc; | |
62 | const int port = cf->cf_loc[AWINIOCF_PORT]; | 63 | const int port = cf->cf_loc[AWINIOCF_PORT]; | |
63 | 64 | |||
64 | if (strcmp(cf->cf_name, loc->loc_name) | 65 | if (strcmp(cf->cf_name, loc->loc_name) | |
65 | || (port != AWINIOCF_PORT_DEFAULT && port != loc->loc_port)) | 66 | || (port != AWINIOCF_PORT_DEFAULT && port != loc->loc_port)) | |
66 | return 0; | 67 | return 0; | |
67 | 68 | |||
68 | KASSERT(loc->loc_port == AWINIOCF_PORT_DEFAULT); | 69 | KASSERT(loc->loc_port == AWINIOCF_PORT_DEFAULT); | |
69 | 70 | |||
70 | return 1; | 71 | return 1; | |
71 | } | 72 | } | |
72 | 73 | |||
73 | static void | 74 | static void | |
74 | awin_tmr_attach(device_t parent, device_t self, void *aux) | 75 | awin_tmr_attach(device_t parent, device_t self, void *aux) | |
75 | { | 76 | { | |
76 | struct awin_tmr_softc * const sc = device_private(self); | 77 | struct awin_tmr_softc * const sc = device_private(self); | |
77 | struct awinio_attach_args * const aio = aux; | 78 | struct awinio_attach_args * const aio = aux; | |
78 | const struct awin_locators * const loc = &aio->aio_loc; | 79 | const struct awin_locators * const loc = &aio->aio_loc; | |
79 | 80 | |||
80 | sc->sc_dev = self; | 81 | sc->sc_dev = self; | |
81 | 82 | |||
82 | sc->sc_bst = aio->aio_core_bst; | 83 | sc->sc_bst = aio->aio_core_bst; | |
83 | sc->sc_dmat = aio->aio_dmat; | 84 | sc->sc_dmat = aio->aio_dmat; | |
84 | bus_space_subregion(sc->sc_bst, aio->aio_core_bsh, | 85 | bus_space_subregion(sc->sc_bst, aio->aio_core_bsh, | |
85 | loc->loc_offset, loc->loc_size, &sc->sc_bsh); | 86 | loc->loc_offset, loc->loc_size, &sc->sc_bsh); | |
86 | 87 | |||
87 | aprint_naive("\n"); | 88 | aprint_naive("\n"); | |
88 | aprint_normal("\n"); | 89 | aprint_normal("\n"); | |
89 | } | 90 | } |
--- src/sys/arch/arm/allwinner/Attic/awin_wdc.c 2013/09/04 02:39:01 1.1
+++ src/sys/arch/arm/allwinner/Attic/awin_wdc.c 2014/02/20 21:48:38 1.2
@@ -1,133 +1,134 @@ | @@ -1,133 +1,134 @@ | |||
1 | /*- | 1 | /*- | |
2 | * Copyright (c) 2012 The NetBSD Foundation, Inc. | 2 | * Copyright (c) 2012 The NetBSD Foundation, Inc. | |
3 | * All rights reserved. | 3 | * All rights reserved. | |
4 | * | 4 | * | |
5 | * This code is derived from software contributed to The NetBSD Foundation | 5 | * This code is derived from software contributed to The NetBSD Foundation | |
6 | * by Matt Thomas of 3am Software Foundry. | 6 | * by Matt Thomas of 3am Software Foundry. | |
7 | * | 7 | * | |
8 | * Redistribution and use in source and binary forms, with or without | 8 | * Redistribution and use in source and binary forms, with or without | |
9 | * modification, are permitted provided that the following conditions | 9 | * modification, are permitted provided that the following conditions | |
10 | * are met: | 10 | * are met: | |
11 | * 1. Redistributions of source code must retain the above copyright | 11 | * 1. Redistributions of source code must retain the above copyright | |
12 | * notice, this list of conditions and the following disclaimer. | 12 | * notice, this list of conditions and the following disclaimer. | |
13 | * 2. Redistributions in binary form must reproduce the above copyright | 13 | * 2. Redistributions in binary form must reproduce the above copyright | |
14 | * notice, this list of conditions and the following disclaimer in the | 14 | * notice, this list of conditions and the following disclaimer in the | |
15 | * documentation and/or other materials provided with the distribution. | 15 | * documentation and/or other materials provided with the distribution. | |
16 | * | 16 | * | |
17 | * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS | 17 | * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS | |
18 | * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED | 18 | * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED | |
19 | * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR | 19 | * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR | |
20 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS | 20 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS | |
21 | * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR | 21 | * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR | |
22 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF | 22 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF | |
23 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS | 23 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS | |
24 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN | 24 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN | |
25 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | 25 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | |
26 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | 26 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | |
27 | * POSSIBILITY OF SUCH DAMAGE. | 27 | * POSSIBILITY OF SUCH DAMAGE. | |
28 | */ | 28 | */ | |
29 | 29 | |||
30 | #include "locators.h" | 30 | #include "locators.h" | |
31 | 31 | |||
32 | #include <sys/cdefs.h> | 32 | #include <sys/cdefs.h> | |
33 | 33 | |||
34 | __KERNEL_RCSID(1, "$NetBSD: awin_wdc.c,v 1.1 2013/09/04 02:39:01 matt Exp $"); | 34 | __KERNEL_RCSID(1, "$NetBSD: awin_wdc.c,v 1.2 2014/02/20 21:48:38 matt Exp $"); | |
35 | 35 | |||
36 | #include <sys/param.h> | |||
36 | #include <sys/bus.h> | 37 | #include <sys/bus.h> | |
37 | #include <sys/device.h> | 38 | #include <sys/device.h> | |
38 | #include <sys/intr.h> | 39 | #include <sys/intr.h> | |
39 | #include <sys/systm.h> | 40 | #include <sys/systm.h> | |
40 | 41 | |||
41 | #include <arm/allwinner/awin_reg.h> | 42 | #include <arm/allwinner/awin_reg.h> | |
42 | #include <arm/allwinner/awin_var.h> | 43 | #include <arm/allwinner/awin_var.h> | |
43 | 44 | |||
44 | #include <dev/ata/atavar.h> | 45 | #include <dev/ata/atavar.h> | |
45 | #include <dev/ic/wdcvar.h> | 46 | #include <dev/ic/wdcvar.h> | |
46 | 47 | |||
47 | static int awin_wdc_match(device_t, cfdata_t, void *); | 48 | static int awin_wdc_match(device_t, cfdata_t, void *); | |
48 | static void awin_wdc_attach(device_t, device_t, void *); | 49 | static void awin_wdc_attach(device_t, device_t, void *); | |
49 | 50 | |||
50 | struct awin_wdc_softc { | 51 | struct awin_wdc_softc { | |
51 | struct wdc_softc asc_sc; | 52 | struct wdc_softc asc_sc; | |
52 | struct ata_channel *asc_chanlist[1]; | 53 | struct ata_channel *asc_chanlist[1]; | |
53 | struct ata_channel asc_channel; | 54 | struct ata_channel asc_channel; | |
54 | struct ata_queue asc_chqueue; | 55 | struct ata_queue asc_chqueue; | |
55 | struct wdc_regs asc_wdc_regs; | 56 | struct wdc_regs asc_wdc_regs; | |
56 | void *asc_ih; | 57 | void *asc_ih; | |
57 | 58 | |||
58 | }; | 59 | }; | |
59 | 60 | |||
60 | CFATTACH_DECL_NEW(awin_wdc, sizeof(struct awin_wdc_softc), | 61 | CFATTACH_DECL_NEW(awin_wdc, sizeof(struct awin_wdc_softc), | |
61 | awin_wdc_match, awin_wdc_attach, NULL, NULL); | 62 | awin_wdc_match, awin_wdc_attach, NULL, NULL); | |
62 | 63 | |||
63 | static int | 64 | static int | |
64 | awin_wdc_match(device_t parent, cfdata_t cf, void *aux) | 65 | awin_wdc_match(device_t parent, cfdata_t cf, void *aux) | |
65 | { | 66 | { | |
66 | struct awinio_attach_args * const aio = aux; | 67 | struct awinio_attach_args * const aio = aux; | |
67 | const struct awin_locators * const loc = &aio->aio_loc; | 68 | const struct awin_locators * const loc = &aio->aio_loc; | |
68 | const int port = cf->cf_loc[AWINIOCF_PORT]; | 69 | const int port = cf->cf_loc[AWINIOCF_PORT]; | |
69 | 70 | |||
70 | if (strcmp(cf->cf_name, loc->loc_name)) | 71 | if (strcmp(cf->cf_name, loc->loc_name)) | |
71 | return 0; | 72 | return 0; | |
72 | 73 | |||
73 | if (port != AWINIOCF_PORT_DEFAULT) | 74 | if (port != AWINIOCF_PORT_DEFAULT) | |
74 | return 0; | 75 | return 0; | |
75 | 76 | |||
76 | return 1; | 77 | return 1; | |
77 | } | 78 | } | |
78 | 79 | |||
79 | static void | 80 | static void | |
80 | awin_wdc_attach(device_t parent, device_t self, void *aux) | 81 | awin_wdc_attach(device_t parent, device_t self, void *aux) | |
81 | { | 82 | { | |
82 | struct awin_wdc_softc * const asc = device_private(self); | 83 | struct awin_wdc_softc * const asc = device_private(self); | |
83 | struct wdc_softc * const sc = &asc->asc_sc; | 84 | struct wdc_softc * const sc = &asc->asc_sc; | |
84 | struct awinio_attach_args * const aio = aux; | 85 | struct awinio_attach_args * const aio = aux; | |
85 | const struct awin_locators * const loc = &aio->aio_loc; | 86 | const struct awin_locators * const loc = &aio->aio_loc; | |
86 | struct wdc_regs * const regs = &asc->asc_wdc_regs; | 87 | struct wdc_regs * const regs = &asc->asc_wdc_regs; | |
87 | 88 | |||
88 | sc->sc_atac.atac_dev = self; | 89 | sc->sc_atac.atac_dev = self; | |
89 | sc->regs = regs; | 90 | sc->regs = regs; | |
90 | 91 | |||
91 | regs->cmd_iot = aio->aio_core_a4x_bst; | 92 | regs->cmd_iot = aio->aio_core_a4x_bst; | |
92 | regs->ctl_iot = aio->aio_core_a4x_bst; | 93 | regs->ctl_iot = aio->aio_core_a4x_bst; | |
93 | regs->data32iot = aio->aio_core_a4x_bst; | 94 | regs->data32iot = aio->aio_core_a4x_bst; | |
94 | 95 | |||
95 | bus_space_subregion(regs->cmd_iot, aio->aio_core_bsh, | 96 | bus_space_subregion(regs->cmd_iot, aio->aio_core_bsh, | |
96 | loc->loc_offset / 4, loc->loc_size, ®s->cmd_baseioh); | 97 | loc->loc_offset / 4, loc->loc_size, ®s->cmd_baseioh); | |
97 | 98 | |||
98 | aprint_naive(": ATA controller\n"); | 99 | aprint_naive(": ATA controller\n"); | |
99 | aprint_normal(": ATA controller\n"); | 100 | aprint_normal(": ATA controller\n"); | |
100 | 101 | |||
101 | for (u_int i = 0; i < 8; i++) { | 102 | for (u_int i = 0; i < 8; i++) { | |
102 | if (bus_space_subregion(regs->cmd_iot, regs->cmd_baseioh, | 103 | if (bus_space_subregion(regs->cmd_iot, regs->cmd_baseioh, | |
103 | i, 1, ®s->cmd_iohs[i]) != 0) { | 104 | i, 1, ®s->cmd_iohs[i]) != 0) { | |
104 | aprint_error(": couldn't subregion registers\n"); | 105 | aprint_error(": couldn't subregion registers\n"); | |
105 | return; | 106 | return; | |
106 | } | 107 | } | |
107 | } | 108 | } | |
108 | 109 | |||
109 | if (bus_space_subregion(regs->ctl_iot, regs->cmd_baseioh, | 110 | if (bus_space_subregion(regs->ctl_iot, regs->cmd_baseioh, | |
110 | AWIN_PATA_CTL_REG, 1, ®s->ctl_ioh) != 0) { | 111 | AWIN_PATA_CTL_REG, 1, ®s->ctl_ioh) != 0) { | |
111 | aprint_error(": couldn't subregion registers\n"); | 112 | aprint_error(": couldn't subregion registers\n"); | |
112 | return; | 113 | return; | |
113 | } | 114 | } | |
114 | 115 | |||
115 | 116 | |||
116 | asc->asc_ih = intr_establish(loc->loc_intr, IPL_VM, IST_LEVEL, | 117 | asc->asc_ih = intr_establish(loc->loc_intr, IPL_VM, IST_LEVEL, | |
117 | wdcintr, sc); | 118 | wdcintr, sc); | |
118 | if (asc->asc_ih == NULL) { | 119 | if (asc->asc_ih == NULL) { | |
119 | aprint_error_dev(self, "failed to establish interrupt %d\n", | 120 | aprint_error_dev(self, "failed to establish interrupt %d\n", | |
120 | loc->loc_intr); | 121 | loc->loc_intr); | |
121 | goto fail; | 122 | goto fail; | |
122 | } | 123 | } | |
123 | aprint_normal_dev(self, "interrupting on irq %d\n", | 124 | aprint_normal_dev(self, "interrupting on irq %d\n", | |
124 | loc->loc_intr); | 125 | loc->loc_intr); | |
125 | 126 | |||
126 | return; | 127 | return; | |
127 | 128 | |||
128 | fail: | 129 | fail: | |
129 | if (asc->asc_ih) { | 130 | if (asc->asc_ih) { | |
130 | intr_disestablish(asc->asc_ih); | 131 | intr_disestablish(asc->asc_ih); | |
131 | asc->asc_ih = NULL; | 132 | asc->asc_ih = NULL; | |
132 | } | 133 | } | |
133 | } | 134 | } |
--- src/sys/arch/arm/allwinner/Attic/awin_io.c 2013/09/08 04:06:44 1.5
+++ src/sys/arch/arm/allwinner/Attic/awin_io.c 2014/02/20 21:48:38 1.6
@@ -1,201 +1,202 @@ | @@ -1,201 +1,202 @@ | |||
1 | /*- | 1 | /*- | |
2 | * Copyright (c) 2013 The NetBSD Foundation, Inc. | 2 | * Copyright (c) 2013 The NetBSD Foundation, Inc. | |
3 | * All rights reserved. | 3 | * All rights reserved. | |
4 | * | 4 | * | |
5 | * This code is derived from software contributed to The NetBSD Foundation | 5 | * This code is derived from software contributed to The NetBSD Foundation | |
6 | * by Matt Thomas of 3am Software Foundry. | 6 | * by Matt Thomas of 3am Software Foundry. | |
7 | * | 7 | * | |
8 | * Redistribution and use in source and binary forms, with or without | 8 | * Redistribution and use in source and binary forms, with or without | |
9 | * modification, are permitted provided that the following conditions | 9 | * modification, are permitted provided that the following conditions | |
10 | * are met: | 10 | * are met: | |
11 | * 1. Redistributions of source code must retain the above copyright | 11 | * 1. Redistributions of source code must retain the above copyright | |
12 | * notice, this list of conditions and the following disclaimer. | 12 | * notice, this list of conditions and the following disclaimer. | |
13 | * 2. Redistributions in binary form must reproduce the above copyright | 13 | * 2. Redistributions in binary form must reproduce the above copyright | |
14 | * notice, this list of conditions and the following disclaimer in the | 14 | * notice, this list of conditions and the following disclaimer in the | |
15 | * documentation and/or other materials provided with the distribution. | 15 | * documentation and/or other materials provided with the distribution. | |
16 | * | 16 | * | |
17 | * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS | 17 | * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS | |
18 | * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED | 18 | * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED | |
19 | * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR | 19 | * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR | |
20 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS | 20 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS | |
21 | * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR | 21 | * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR | |
22 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF | 22 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF | |
23 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS | 23 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS | |
24 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN | 24 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN | |
25 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | 25 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | |
26 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | 26 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | |
27 | * POSSIBILITY OF SUCH DAMAGE. | 27 | * POSSIBILITY OF SUCH DAMAGE. | |
28 | */ | 28 | */ | |
29 | 29 | |||
30 | #include "locators.h" | 30 | #include "locators.h" | |
31 | 31 | |||
32 | #include <sys/cdefs.h> | 32 | #include <sys/cdefs.h> | |
33 | 33 | |||
34 | __KERNEL_RCSID(1, "$NetBSD: awin_io.c,v 1.5 2013/09/08 04:06:44 matt Exp $"); | 34 | __KERNEL_RCSID(1, "$NetBSD: awin_io.c,v 1.6 2014/02/20 21:48:38 matt Exp $"); | |
35 | 35 | |||
36 | #include <sys/param.h> | |||
36 | #include <sys/bus.h> | 37 | #include <sys/bus.h> | |
37 | #include <sys/cpu.h> | 38 | #include <sys/cpu.h> | |
38 | #include <sys/device.h> | 39 | #include <sys/device.h> | |
39 | #include <sys/intr.h> | 40 | #include <sys/intr.h> | |
40 | #include <sys/systm.h> | 41 | #include <sys/systm.h> | |
41 | 42 | |||
42 | #include <arm/locore.h> | 43 | #include <arm/locore.h> | |
43 | #include <arm/mainbus/mainbus.h> | 44 | #include <arm/mainbus/mainbus.h> | |
44 | 45 | |||
45 | #include <arm/allwinner/awin_reg.h> | 46 | #include <arm/allwinner/awin_reg.h> | |
46 | #include <arm/allwinner/awin_var.h> | 47 | #include <arm/allwinner/awin_var.h> | |
47 | 48 | |||
48 | static int awinio_match(device_t, cfdata_t, void *); | 49 | static int awinio_match(device_t, cfdata_t, void *); | |
49 | static void awinio_attach(device_t, device_t, void *); | 50 | static void awinio_attach(device_t, device_t, void *); | |
50 | 51 | |||
51 | static struct awinio_softc { | 52 | static struct awinio_softc { | |
52 | device_t sc_dev; | 53 | device_t sc_dev; | |
53 | bus_space_tag_t sc_bst; | 54 | bus_space_tag_t sc_bst; | |
54 | bus_space_tag_t sc_a4x_bst; | 55 | bus_space_tag_t sc_a4x_bst; | |
55 | bus_space_handle_t sc_bsh; | 56 | bus_space_handle_t sc_bsh; | |
56 | bus_space_handle_t sc_ccm_bsh; | 57 | bus_space_handle_t sc_ccm_bsh; | |
57 | bus_dma_tag_t sc_dmat; | 58 | bus_dma_tag_t sc_dmat; | |
58 | } awinio_sc; | 59 | } awinio_sc; | |
59 | 60 | |||
60 | CFATTACH_DECL_NEW(awin_io, 0, | 61 | CFATTACH_DECL_NEW(awin_io, 0, | |
61 | awinio_match, awinio_attach, NULL, NULL); | 62 | awinio_match, awinio_attach, NULL, NULL); | |
62 | 63 | |||
63 | static int | 64 | static int | |
64 | awinio_match(device_t parent, cfdata_t cf, void *aux) | 65 | awinio_match(device_t parent, cfdata_t cf, void *aux) | |
65 | { | 66 | { | |
66 | if (awinio_sc.sc_dev != NULL) | 67 | if (awinio_sc.sc_dev != NULL) | |
67 | return 0; | 68 | return 0; | |
68 | 69 | |||
69 | return 1; | 70 | return 1; | |
70 | } | 71 | } | |
71 | 72 | |||
72 | static int | 73 | static int | |
73 | awinio_print(void *aux, const char *pnp) | 74 | awinio_print(void *aux, const char *pnp) | |
74 | { | 75 | { | |
75 | const struct awinio_attach_args * const aio = aux; | 76 | const struct awinio_attach_args * const aio = aux; | |
76 | 77 | |||
77 | if (aio->aio_loc.loc_port != AWINIOCF_PORT_DEFAULT) | 78 | if (aio->aio_loc.loc_port != AWINIOCF_PORT_DEFAULT) | |
78 | aprint_normal(" port %d", aio->aio_loc.loc_port); | 79 | aprint_normal(" port %d", aio->aio_loc.loc_port); | |
79 | 80 | |||
80 | return QUIET; | 81 | return QUIET; | |
81 | } | 82 | } | |
82 | 83 | |||
83 | #define OFFANDSIZE(n) AWIN_##n##_OFFSET, (AWIN_##n##_OFFSET < 0x20000 ? 0x1000 : 0x400) | 84 | #define OFFANDSIZE(n) AWIN_##n##_OFFSET, (AWIN_##n##_OFFSET < 0x20000 ? 0x1000 : 0x400) | |
84 | #define NOPORT AWINIOCF_PORT_DEFAULT | 85 | #define NOPORT AWINIOCF_PORT_DEFAULT | |
85 | #define NOINTR AWINIO_INTR_DEFAULT | 86 | #define NOINTR AWINIO_INTR_DEFAULT | |
86 | #define AANY 0 | 87 | #define AANY 0 | |
87 | #define A10 AWINIO_ONLY_A10 | 88 | #define A10 AWINIO_ONLY_A10 | |
88 | #define A20 AWINIO_ONLY_A20 | 89 | #define A20 AWINIO_ONLY_A20 | |
89 | #define REQ AWINIO_REQUIRED | 90 | #define REQ AWINIO_REQUIRED | |
90 | 91 | |||
91 | static const struct awin_locators awin_locators[] = { | 92 | static const struct awin_locators awin_locators[] = { | |
92 | { "awinicu", OFFANDSIZE(INTC), NOPORT, NOINTR, A10|REQ }, | 93 | { "awinicu", OFFANDSIZE(INTC), NOPORT, NOINTR, A10|REQ }, | |
93 | { "awingpio", OFFANDSIZE(PIO), NOPORT, NOINTR, AANY|REQ }, | 94 | { "awingpio", OFFANDSIZE(PIO), NOPORT, NOINTR, AANY|REQ }, | |
94 | { "awintmr", OFFANDSIZE(TMR), NOPORT, AWIN_IRQ_TMR0, A10 }, | 95 | { "awintmr", OFFANDSIZE(TMR), NOPORT, AWIN_IRQ_TMR0, A10 }, | |
95 | { "com", OFFANDSIZE(UART0), 0, AWIN_IRQ_UART0, AANY }, | 96 | { "com", OFFANDSIZE(UART0), 0, AWIN_IRQ_UART0, AANY }, | |
96 | { "com", OFFANDSIZE(UART1), 1, AWIN_IRQ_UART1, AANY }, | 97 | { "com", OFFANDSIZE(UART1), 1, AWIN_IRQ_UART1, AANY }, | |
97 | { "com", OFFANDSIZE(UART2), 2, AWIN_IRQ_UART2, AANY }, | 98 | { "com", OFFANDSIZE(UART2), 2, AWIN_IRQ_UART2, AANY }, | |
98 | { "com", OFFANDSIZE(UART3), 3, AWIN_IRQ_UART3, AANY }, | 99 | { "com", OFFANDSIZE(UART3), 3, AWIN_IRQ_UART3, AANY }, | |
99 | { "com", OFFANDSIZE(UART4), 4, AWIN_IRQ_UART4, AANY }, | 100 | { "com", OFFANDSIZE(UART4), 4, AWIN_IRQ_UART4, AANY }, | |
100 | { "com", OFFANDSIZE(UART5), 5, AWIN_IRQ_UART5, AANY }, | 101 | { "com", OFFANDSIZE(UART5), 5, AWIN_IRQ_UART5, AANY }, | |
101 | { "com", OFFANDSIZE(UART6), 6, AWIN_IRQ_UART6, AANY }, | 102 | { "com", OFFANDSIZE(UART6), 6, AWIN_IRQ_UART6, AANY }, | |
102 | { "com", OFFANDSIZE(UART7), 7, AWIN_IRQ_UART7, AANY }, | 103 | { "com", OFFANDSIZE(UART7), 7, AWIN_IRQ_UART7, AANY }, | |
103 | { "awinwdt", OFFANDSIZE(TMR), NOPORT, NOINTR, AANY }, | 104 | { "awinwdt", OFFANDSIZE(TMR), NOPORT, NOINTR, AANY }, | |
104 | { "awinusb", OFFANDSIZE(USB1), 0, NOINTR, AANY }, | 105 | { "awinusb", OFFANDSIZE(USB1), 0, NOINTR, AANY }, | |
105 | { "awinusb", OFFANDSIZE(USB2), 1, NOINTR, AANY }, | 106 | { "awinusb", OFFANDSIZE(USB2), 1, NOINTR, AANY }, | |
106 | { "sdhc", OFFANDSIZE(SDMMC0), 0, AWIN_IRQ_SDMMC0, AANY }, | 107 | { "sdhc", OFFANDSIZE(SDMMC0), 0, AWIN_IRQ_SDMMC0, AANY }, | |
107 | { "sdhc", OFFANDSIZE(SDMMC1), 1, AWIN_IRQ_SDMMC1, AANY }, | 108 | { "sdhc", OFFANDSIZE(SDMMC1), 1, AWIN_IRQ_SDMMC1, AANY }, | |
108 | { "sdhc", OFFANDSIZE(SDMMC2), 2, AWIN_IRQ_SDMMC2, AANY }, | 109 | { "sdhc", OFFANDSIZE(SDMMC2), 2, AWIN_IRQ_SDMMC2, AANY }, | |
109 | { "sdhc", OFFANDSIZE(SDMMC3), 3, AWIN_IRQ_SDMMC3, AANY }, | 110 | { "sdhc", OFFANDSIZE(SDMMC3), 3, AWIN_IRQ_SDMMC3, AANY }, | |
110 | { "sdhc", OFFANDSIZE(SDMMC1), 4, AWIN_IRQ_SDMMC1, AANY }, | 111 | { "sdhc", OFFANDSIZE(SDMMC1), 4, AWIN_IRQ_SDMMC1, AANY }, | |
111 | { "ahcisata", OFFANDSIZE(SATA), NOPORT, AWIN_IRQ_SATA, AANY }, | 112 | { "ahcisata", OFFANDSIZE(SATA), NOPORT, AWIN_IRQ_SATA, AANY }, | |
112 | { "awiniic", OFFANDSIZE(TWI0), 0, AWIN_IRQ_TWI0, AANY }, | 113 | { "awiniic", OFFANDSIZE(TWI0), 0, AWIN_IRQ_TWI0, AANY }, | |
113 | { "awiniic", OFFANDSIZE(TWI1), 1, AWIN_IRQ_TWI1, AANY }, | 114 | { "awiniic", OFFANDSIZE(TWI1), 1, AWIN_IRQ_TWI1, AANY }, | |
114 | { "awiniic", OFFANDSIZE(TWI2), 2, AWIN_IRQ_TWI2, AANY }, | 115 | { "awiniic", OFFANDSIZE(TWI2), 2, AWIN_IRQ_TWI2, AANY }, | |
115 | { "awiniic", OFFANDSIZE(TWI3), 3, AWIN_IRQ_TWI3, AANY }, | 116 | { "awiniic", OFFANDSIZE(TWI3), 3, AWIN_IRQ_TWI3, AANY }, | |
116 | { "awiniic", OFFANDSIZE(TWI4), 4, AWIN_IRQ_TWI4, AANY }, | 117 | { "awiniic", OFFANDSIZE(TWI4), 4, AWIN_IRQ_TWI4, AANY }, | |
117 | { "spi", OFFANDSIZE(SPI0), 0, AWIN_IRQ_SPI0, AANY }, | 118 | { "spi", OFFANDSIZE(SPI0), 0, AWIN_IRQ_SPI0, AANY }, | |
118 | { "spi", OFFANDSIZE(SPI1), 1, AWIN_IRQ_SPI1, AANY }, | 119 | { "spi", OFFANDSIZE(SPI1), 1, AWIN_IRQ_SPI1, AANY }, | |
119 | { "spi", OFFANDSIZE(SPI2), 1, AWIN_IRQ_SPI2, AANY }, | 120 | { "spi", OFFANDSIZE(SPI2), 1, AWIN_IRQ_SPI2, AANY }, | |
120 | { "spi", OFFANDSIZE(SPI3), 3, AWIN_IRQ_SPI3, AANY }, | 121 | { "spi", OFFANDSIZE(SPI3), 3, AWIN_IRQ_SPI3, AANY }, | |
121 | { "awe", OFFANDSIZE(EMAC), NOPORT, AWIN_IRQ_EMAC, AANY }, | 122 | { "awe", OFFANDSIZE(EMAC), NOPORT, AWIN_IRQ_EMAC, AANY }, | |
122 | { "awge", AWIN_GMAC_OFFSET, AWIN_GMAC_SIZE, NOPORT, AWIN_IRQ_GMAC, A20 }, | 123 | { "awge", AWIN_GMAC_OFFSET, AWIN_GMAC_SIZE, NOPORT, AWIN_IRQ_GMAC, A20 }, | |
123 | { "awincrypto", OFFANDSIZE(SS), NOPORT, AWIN_IRQ_SS, AANY }, | 124 | { "awincrypto", OFFANDSIZE(SS), NOPORT, AWIN_IRQ_SS, AANY }, | |
124 | }; | 125 | }; | |
125 | 126 | |||
126 | static int | 127 | static int | |
127 | awinio_find(device_t parent, cfdata_t cf, const int *ldesc, void *aux) | 128 | awinio_find(device_t parent, cfdata_t cf, const int *ldesc, void *aux) | |
128 | { | 129 | { | |
129 | const struct awinio_attach_args * const aio = aux; | 130 | const struct awinio_attach_args * const aio = aux; | |
130 | const struct awin_locators * const loc = &aio->aio_loc; | 131 | const struct awin_locators * const loc = &aio->aio_loc; | |
131 | const int port = cf->cf_loc[AWINIOCF_PORT]; | 132 | const int port = cf->cf_loc[AWINIOCF_PORT]; | |
132 | 133 | |||
133 | if (strcmp(cf->cf_name, loc->loc_name) | 134 | if (strcmp(cf->cf_name, loc->loc_name) | |
134 | || (port != AWINIOCF_PORT_DEFAULT && port != loc->loc_port)) | 135 | || (port != AWINIOCF_PORT_DEFAULT && port != loc->loc_port)) | |
135 | return 0; | 136 | return 0; | |
136 | 137 | |||
137 | return config_match(parent, cf, aux); | 138 | return config_match(parent, cf, aux); | |
138 | } | 139 | } | |
139 | 140 | |||
140 | static void | 141 | static void | |
141 | awinio_attach(device_t parent, device_t self, void *aux) | 142 | awinio_attach(device_t parent, device_t self, void *aux) | |
142 | { | 143 | { | |
143 | struct awinio_softc * const sc = &awinio_sc; | 144 | struct awinio_softc * const sc = &awinio_sc; | |
144 | const bool a10_p = CPU_ID_CORTEX_A8_P(curcpu()->ci_arm_cpuid); | 145 | const bool a10_p = CPU_ID_CORTEX_A8_P(curcpu()->ci_arm_cpuid); | |
145 | const bool a20_p = CPU_ID_CORTEX_A7_P(curcpu()->ci_arm_cpuid); | 146 | const bool a20_p = CPU_ID_CORTEX_A7_P(curcpu()->ci_arm_cpuid); | |
146 | prop_dictionary_t dict = device_properties(self); | 147 | prop_dictionary_t dict = device_properties(self); | |
147 | 148 | |||
148 | sc->sc_dev = self; | 149 | sc->sc_dev = self; | |
149 | 150 | |||
150 | sc->sc_bst = &awin_bs_tag; | 151 | sc->sc_bst = &awin_bs_tag; | |
151 | sc->sc_a4x_bst = &awin_a4x_bs_tag; | 152 | sc->sc_a4x_bst = &awin_a4x_bs_tag; | |
152 | sc->sc_bsh = awin_core_bsh; | 153 | sc->sc_bsh = awin_core_bsh; | |
153 | sc->sc_dmat = &awin_dma_tag; | 154 | sc->sc_dmat = &awin_dma_tag; | |
154 | 155 | |||
155 | bus_space_subregion(sc->sc_bst, sc->sc_bsh, AWIN_CCM_OFFSET, 0x1000, | 156 | bus_space_subregion(sc->sc_bst, sc->sc_bsh, AWIN_CCM_OFFSET, 0x1000, | |
156 | &sc->sc_ccm_bsh); | 157 | &sc->sc_ccm_bsh); | |
157 | 158 | |||
158 | aprint_naive("\n"); | 159 | aprint_naive("\n"); | |
159 | aprint_normal("\n"); | 160 | aprint_normal("\n"); | |
160 | 161 | |||
161 | const struct awin_locators * const eloc = | 162 | const struct awin_locators * const eloc = | |
162 | awin_locators + __arraycount(awin_locators); | 163 | awin_locators + __arraycount(awin_locators); | |
163 | for (const struct awin_locators *loc = awin_locators; loc < eloc; loc++) { | 164 | for (const struct awin_locators *loc = awin_locators; loc < eloc; loc++) { | |
164 | char prop_name[31]; | 165 | char prop_name[31]; | |
165 | bool skip; | 166 | bool skip; | |
166 | if (loc->loc_port == AWINIOCF_PORT_DEFAULT) { | 167 | if (loc->loc_port == AWINIOCF_PORT_DEFAULT) { | |
167 | snprintf(prop_name, sizeof(prop_name), | 168 | snprintf(prop_name, sizeof(prop_name), | |
168 | "no-%s", loc->loc_name); | 169 | "no-%s", loc->loc_name); | |
169 | } else { | 170 | } else { | |
170 | snprintf(prop_name, sizeof(prop_name), | 171 | snprintf(prop_name, sizeof(prop_name), | |
171 | "no-%s-%d", loc->loc_name, loc->loc_port); | 172 | "no-%s-%d", loc->loc_name, loc->loc_port); | |
172 | } | 173 | } | |
173 | if (prop_dictionary_get_bool(dict, prop_name, &skip) && skip) | 174 | if (prop_dictionary_get_bool(dict, prop_name, &skip) && skip) | |
174 | continue; | 175 | continue; | |
175 | 176 | |||
176 | if (loc->loc_flags & AWINIO_ONLY) { | 177 | if (loc->loc_flags & AWINIO_ONLY) { | |
177 | if (a10_p && !(loc->loc_flags & AWINIO_ONLY_A10)) | 178 | if (a10_p && !(loc->loc_flags & AWINIO_ONLY_A10)) | |
178 | continue; | 179 | continue; | |
179 | if (a20_p && !(loc->loc_flags & AWINIO_ONLY_A20)) | 180 | if (a20_p && !(loc->loc_flags & AWINIO_ONLY_A20)) | |
180 | continue; | 181 | continue; | |
181 | } | 182 | } | |
182 | 183 | |||
183 | struct awinio_attach_args aio = { | 184 | struct awinio_attach_args aio = { | |
184 | .aio_loc = *loc, | 185 | .aio_loc = *loc, | |
185 | .aio_core_bst = sc->sc_bst, | 186 | .aio_core_bst = sc->sc_bst, | |
186 | .aio_core_a4x_bst = sc->sc_a4x_bst, | 187 | .aio_core_a4x_bst = sc->sc_a4x_bst, | |
187 | .aio_core_bsh = sc->sc_bsh, | 188 | .aio_core_bsh = sc->sc_bsh, | |
188 | .aio_ccm_bsh = sc->sc_ccm_bsh, | 189 | .aio_ccm_bsh = sc->sc_ccm_bsh, | |
189 | .aio_dmat = sc->sc_dmat, | 190 | .aio_dmat = sc->sc_dmat, | |
190 | }; | 191 | }; | |
191 | cfdata_t cf = config_search_ia(awinio_find, | 192 | cfdata_t cf = config_search_ia(awinio_find, | |
192 | sc->sc_dev, "awinio", &aio); | 193 | sc->sc_dev, "awinio", &aio); | |
193 | if (cf == NULL) { | 194 | if (cf == NULL) { | |
194 | if (loc->loc_flags & AWINIO_REQUIRED) | 195 | if (loc->loc_flags & AWINIO_REQUIRED) | |
195 | panic("%s: failed to find %s!", __func__, | 196 | panic("%s: failed to find %s!", __func__, | |
196 | loc->loc_name); | 197 | loc->loc_name); | |
197 | continue; | 198 | continue; | |
198 | } | 199 | } | |
199 | config_attach(sc->sc_dev, cf, &aio, awinio_print); | 200 | config_attach(sc->sc_dev, cf, &aio, awinio_print); | |
200 | } | 201 | } | |
201 | } | 202 | } |
--- src/sys/arch/arm/allwinner/Attic/awin_usb.c 2013/09/08 01:01:33 1.9
+++ src/sys/arch/arm/allwinner/Attic/awin_usb.c 2014/02/20 21:48:38 1.10
@@ -1,424 +1,425 @@ | @@ -1,424 +1,425 @@ | |||
1 | /*- | 1 | /*- | |
2 | * Copyright (c) 2013 The NetBSD Foundation, Inc. | 2 | * Copyright (c) 2013 The NetBSD Foundation, Inc. | |
3 | * All rights reserved. | 3 | * All rights reserved. | |
4 | * | 4 | * | |
5 | * This code is derived from software contributed to The NetBSD Foundation | 5 | * This code is derived from software contributed to The NetBSD Foundation | |
6 | * by Matt Thomas of 3am Software Foundry. | 6 | * by Matt Thomas of 3am Software Foundry. | |
7 | * | 7 | * | |
8 | * Redistribution and use in source and binary forms, with or without | 8 | * Redistribution and use in source and binary forms, with or without | |
9 | * modification, are permitted provided that the following conditions | 9 | * modification, are permitted provided that the following conditions | |
10 | * are met: | 10 | * are met: | |
11 | * 1. Redistributions of source code must retain the above copyright | 11 | * 1. Redistributions of source code must retain the above copyright | |
12 | * notice, this list of conditions and the following disclaimer. | 12 | * notice, this list of conditions and the following disclaimer. | |
13 | * 2. Redistributions in binary form must reproduce the above copyright | 13 | * 2. Redistributions in binary form must reproduce the above copyright | |
14 | * notice, this list of conditions and the following disclaimer in the | 14 | * notice, this list of conditions and the following disclaimer in the | |
15 | * documentation and/or other materials provided with the distribution. | 15 | * documentation and/or other materials provided with the distribution. | |
16 | * | 16 | * | |
17 | * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS | 17 | * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS | |
18 | * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED | 18 | * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED | |
19 | * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR | 19 | * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR | |
20 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS | 20 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS | |
21 | * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR | 21 | * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR | |
22 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF | 22 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF | |
23 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS | 23 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS | |
24 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN | 24 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN | |
25 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | 25 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | |
26 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | 26 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | |
27 | * POSSIBILITY OF SUCH DAMAGE. | 27 | * POSSIBILITY OF SUCH DAMAGE. | |
28 | */ | 28 | */ | |
29 | #define USBH_PRIVATE | 29 | #define USBH_PRIVATE | |
30 | 30 | |||
31 | #include "locators.h" | 31 | #include "locators.h" | |
32 | #include "ohci.h" | 32 | #include "ohci.h" | |
33 | #include "ehci.h" | 33 | #include "ehci.h" | |
34 | 34 | |||
35 | #include <sys/cdefs.h> | 35 | #include <sys/cdefs.h> | |
36 | 36 | |||
37 | __KERNEL_RCSID(1, "$NetBSD: awin_usb.c,v 1.9 2013/09/08 01:01:33 matt Exp $"); | 37 | __KERNEL_RCSID(1, "$NetBSD: awin_usb.c,v 1.10 2014/02/20 21:48:38 matt Exp $"); | |
38 | 38 | |||
39 | #include <sys/param.h> | |||
39 | #include <sys/bus.h> | 40 | #include <sys/bus.h> | |
40 | #include <sys/device.h> | 41 | #include <sys/device.h> | |
41 | #include <sys/intr.h> | 42 | #include <sys/intr.h> | |
42 | #include <sys/systm.h> | 43 | #include <sys/systm.h> | |
43 | 44 | |||
44 | #include <arm/allwinner/awin_reg.h> | 45 | #include <arm/allwinner/awin_reg.h> | |
45 | #include <arm/allwinner/awin_var.h> | 46 | #include <arm/allwinner/awin_var.h> | |
46 | 47 | |||
47 | #include <dev/usb/usb.h> | 48 | #include <dev/usb/usb.h> | |
48 | #include <dev/usb/usbdi.h> | 49 | #include <dev/usb/usbdi.h> | |
49 | #include <dev/usb/usbdivar.h> | 50 | #include <dev/usb/usbdivar.h> | |
50 | #include <dev/usb/usb_mem.h> | 51 | #include <dev/usb/usb_mem.h> | |
51 | 52 | |||
52 | #if NOHCI > 0 | 53 | #if NOHCI > 0 | |
53 | #include <dev/usb/ohcireg.h> | 54 | #include <dev/usb/ohcireg.h> | |
54 | #include <dev/usb/ohcivar.h> | 55 | #include <dev/usb/ohcivar.h> | |
55 | #endif | 56 | #endif | |
56 | 57 | |||
57 | #if NEHCI > 0 | 58 | #if NEHCI > 0 | |
58 | #include <dev/usb/ehcireg.h> | 59 | #include <dev/usb/ehcireg.h> | |
59 | #include <dev/usb/ehcivar.h> | 60 | #include <dev/usb/ehcivar.h> | |
60 | #endif | 61 | #endif | |
61 | 62 | |||
62 | #include <dev/pci/pcidevs.h> | 63 | #include <dev/pci/pcidevs.h> | |
63 | 64 | |||
64 | struct awinusb_softc { | 65 | struct awinusb_softc { | |
65 | device_t usbsc_dev; | 66 | device_t usbsc_dev; | |
66 | bus_dma_tag_t usbsc_dmat; | 67 | bus_dma_tag_t usbsc_dmat; | |
67 | bus_space_tag_t usbsc_bst; | 68 | bus_space_tag_t usbsc_bst; | |
68 | bus_space_handle_t usbsc_ehci_bsh; | 69 | bus_space_handle_t usbsc_ehci_bsh; | |
69 | bus_space_handle_t usbsc_ohci_bsh; | 70 | bus_space_handle_t usbsc_ohci_bsh; | |
70 | bus_space_handle_t usbsc_usb0_phy_csr_bsh; | 71 | bus_space_handle_t usbsc_usb0_phy_csr_bsh; | |
71 | u_int usbsc_number; | 72 | u_int usbsc_number; | |
72 | struct awin_gpio_pindata usbsc_drv_pin; | 73 | struct awin_gpio_pindata usbsc_drv_pin; | |
73 | 74 | |||
74 | device_t usbsc_ohci_dev; | 75 | device_t usbsc_ohci_dev; | |
75 | device_t usbsc_ehci_dev; | 76 | device_t usbsc_ehci_dev; | |
76 | void *usbsc_ohci_ih; | 77 | void *usbsc_ohci_ih; | |
77 | void *usbsc_ehci_ih; | 78 | void *usbsc_ehci_ih; | |
78 | }; | 79 | }; | |
79 | 80 | |||
80 | struct awinusb_attach_args { | 81 | struct awinusb_attach_args { | |
81 | const char *usbaa_name; | 82 | const char *usbaa_name; | |
82 | bus_dma_tag_t usbaa_dmat; | 83 | bus_dma_tag_t usbaa_dmat; | |
83 | bus_space_tag_t usbaa_bst; | 84 | bus_space_tag_t usbaa_bst; | |
84 | bus_space_handle_t usbaa_bsh; | 85 | bus_space_handle_t usbaa_bsh; | |
85 | bus_space_handle_t usbaa_ccm_bsh; | 86 | bus_space_handle_t usbaa_ccm_bsh; | |
86 | bus_size_t usbaa_size; | 87 | bus_size_t usbaa_size; | |
87 | int usbaa_port; | 88 | int usbaa_port; | |
88 | }; | 89 | }; | |
89 | 90 | |||
90 | #if NOHCI > 0 | 91 | #if NOHCI > 0 | |
91 | static const int awinusb_ohci_irqs[2] = { AWIN_IRQ_USB3, AWIN_IRQ_USB4 }; | 92 | static const int awinusb_ohci_irqs[2] = { AWIN_IRQ_USB3, AWIN_IRQ_USB4 }; | |
92 | 93 | |||
93 | #ifdef OHCI_DEBUG | 94 | #ifdef OHCI_DEBUG | |
94 | #define OHCI_DPRINTF(x) if (ohcidebug) printf x | 95 | #define OHCI_DPRINTF(x) if (ohcidebug) printf x | |
95 | extern int ohcidebug; | 96 | extern int ohcidebug; | |
96 | #else | 97 | #else | |
97 | #define OHCI_DPRINTF(x) | 98 | #define OHCI_DPRINTF(x) | |
98 | #endif | 99 | #endif | |
99 | 100 | |||
100 | static int ohci_awinusb_match(device_t, cfdata_t, void *); | 101 | static int ohci_awinusb_match(device_t, cfdata_t, void *); | |
101 | static void ohci_awinusb_attach(device_t, device_t, void *); | 102 | static void ohci_awinusb_attach(device_t, device_t, void *); | |
102 | 103 | |||
103 | CFATTACH_DECL_NEW(ohci_awinusb, sizeof(struct ohci_softc), | 104 | CFATTACH_DECL_NEW(ohci_awinusb, sizeof(struct ohci_softc), | |
104 | ohci_awinusb_match, ohci_awinusb_attach, NULL, NULL); | 105 | ohci_awinusb_match, ohci_awinusb_attach, NULL, NULL); | |
105 | 106 | |||
106 | static int | 107 | static int | |
107 | ohci_awinusb_match(device_t parent, cfdata_t cf, void *aux) | 108 | ohci_awinusb_match(device_t parent, cfdata_t cf, void *aux) | |
108 | { | 109 | { | |
109 | struct awinusb_attach_args * const usbaa = aux; | 110 | struct awinusb_attach_args * const usbaa = aux; | |
110 | 111 | |||
111 | if (strcmp(cf->cf_name, usbaa->usbaa_name)) | 112 | if (strcmp(cf->cf_name, usbaa->usbaa_name)) | |
112 | return 0; | 113 | return 0; | |
113 | 114 | |||
114 | return 1; | 115 | return 1; | |
115 | } | 116 | } | |
116 | 117 | |||
117 | static void | 118 | static void | |
118 | ohci_awinusb_attach(device_t parent, device_t self, void *aux) | 119 | ohci_awinusb_attach(device_t parent, device_t self, void *aux) | |
119 | { | 120 | { | |
120 | struct awinusb_softc * const usbsc = device_private(parent); | 121 | struct awinusb_softc * const usbsc = device_private(parent); | |
121 | struct ohci_softc * const sc = device_private(self); | 122 | struct ohci_softc * const sc = device_private(self); | |
122 | struct awinusb_attach_args * const usbaa = aux; | 123 | struct awinusb_attach_args * const usbaa = aux; | |
123 | 124 | |||
124 | sc->sc_dev = self; | 125 | sc->sc_dev = self; | |
125 | 126 | |||
126 | sc->iot = usbaa->usbaa_bst; | 127 | sc->iot = usbaa->usbaa_bst; | |
127 | sc->ioh = usbaa->usbaa_bsh; | 128 | sc->ioh = usbaa->usbaa_bsh; | |
128 | sc->sc_size = usbaa->usbaa_size; | 129 | sc->sc_size = usbaa->usbaa_size; | |
129 | sc->sc_bus.dmatag = usbaa->usbaa_dmat; | 130 | sc->sc_bus.dmatag = usbaa->usbaa_dmat; | |
130 | sc->sc_bus.hci_private = sc; | 131 | sc->sc_bus.hci_private = sc; | |
131 | 132 | |||
132 | //sc->sc_id_vendor = PCI_VENDOR_ALLWINNER; | 133 | //sc->sc_id_vendor = PCI_VENDOR_ALLWINNER; | |
133 | strlcpy(sc->sc_vendor, "Allwinner", sizeof(sc->sc_vendor)); | 134 | strlcpy(sc->sc_vendor, "Allwinner", sizeof(sc->sc_vendor)); | |
134 | 135 | |||
135 | aprint_naive(": OHCI USB controller\n"); | 136 | aprint_naive(": OHCI USB controller\n"); | |
136 | aprint_normal(": OHCI USB controller\n"); | 137 | aprint_normal(": OHCI USB controller\n"); | |
137 | 138 | |||
138 | int error = ohci_init(sc); | 139 | int error = ohci_init(sc); | |
139 | if (error != USBD_NORMAL_COMPLETION) { | 140 | if (error != USBD_NORMAL_COMPLETION) { | |
140 | aprint_error_dev(self, "init failed, error=%d\n", error); | 141 | aprint_error_dev(self, "init failed, error=%d\n", error); | |
141 | } else { | 142 | } else { | |
142 | /* Attach usb device. */ | 143 | /* Attach usb device. */ | |
143 | sc->sc_child = config_found(self, &sc->sc_bus, usbctlprint); | 144 | sc->sc_child = config_found(self, &sc->sc_bus, usbctlprint); | |
144 | } | 145 | } | |
145 | 146 | |||
146 | const int irq = awinusb_ohci_irqs[usbaa->usbaa_port]; | 147 | const int irq = awinusb_ohci_irqs[usbaa->usbaa_port]; | |
147 | usbsc->usbsc_ohci_ih = intr_establish(irq, IPL_USB, | 148 | usbsc->usbsc_ohci_ih = intr_establish(irq, IPL_USB, | |
148 | IST_LEVEL, ohci_intr, sc); | 149 | IST_LEVEL, ohci_intr, sc); | |
149 | if (usbsc->usbsc_ohci_ih == NULL) { | 150 | if (usbsc->usbsc_ohci_ih == NULL) { | |
150 | aprint_error_dev(self, "failed to establish interrupt %d\n", | 151 | aprint_error_dev(self, "failed to establish interrupt %d\n", | |
151 | irq); | 152 | irq); | |
152 | return; | 153 | return; | |
153 | } | 154 | } | |
154 | aprint_normal_dev(self, "interrupting on irq %d\n", irq); | 155 | aprint_normal_dev(self, "interrupting on irq %d\n", irq); | |
155 | } | 156 | } | |
156 | #endif /* NOHCI > 0 */ | 157 | #endif /* NOHCI > 0 */ | |
157 | 158 | |||
158 | #if NEHCI > 0 | 159 | #if NEHCI > 0 | |
159 | #ifdef EHCI_DEBUG | 160 | #ifdef EHCI_DEBUG | |
160 | #define EHCI_DPRINTF(x) if (ehcidebug) printf x | 161 | #define EHCI_DPRINTF(x) if (ehcidebug) printf x | |
161 | extern int ehcidebug; | 162 | extern int ehcidebug; | |
162 | #else | 163 | #else | |
163 | #define EHCI_DPRINTF(x) | 164 | #define EHCI_DPRINTF(x) | |
164 | #endif | 165 | #endif | |
165 | 166 | |||
166 | static int ehci_awinusb_match(device_t, cfdata_t, void *); | 167 | static int ehci_awinusb_match(device_t, cfdata_t, void *); | |
167 | static void ehci_awinusb_attach(device_t, device_t, void *); | 168 | static void ehci_awinusb_attach(device_t, device_t, void *); | |
168 | 169 | |||
169 | static const int awinusb_ehci_irqs[2] = { AWIN_IRQ_USB1, AWIN_IRQ_USB2 }; | 170 | static const int awinusb_ehci_irqs[2] = { AWIN_IRQ_USB1, AWIN_IRQ_USB2 }; | |
170 | 171 | |||
171 | CFATTACH_DECL_NEW(ehci_awinusb, sizeof(struct ehci_softc), | 172 | CFATTACH_DECL_NEW(ehci_awinusb, sizeof(struct ehci_softc), | |
172 | ehci_awinusb_match, ehci_awinusb_attach, NULL, NULL); | 173 | ehci_awinusb_match, ehci_awinusb_attach, NULL, NULL); | |
173 | 174 | |||
174 | static int | 175 | static int | |
175 | ehci_awinusb_match(device_t parent, cfdata_t cf, void *aux) | 176 | ehci_awinusb_match(device_t parent, cfdata_t cf, void *aux) | |
176 | { | 177 | { | |
177 | struct awinusb_attach_args * const usbaa = aux; | 178 | struct awinusb_attach_args * const usbaa = aux; | |
178 | 179 | |||
179 | if (strcmp(cf->cf_name, usbaa->usbaa_name)) | 180 | if (strcmp(cf->cf_name, usbaa->usbaa_name)) | |
180 | return 0; | 181 | return 0; | |
181 | 182 | |||
182 | return 1; | 183 | return 1; | |
183 | } | 184 | } | |
184 | 185 | |||
185 | static void | 186 | static void | |
186 | ehci_awinusb_attach(device_t parent, device_t self, void *aux) | 187 | ehci_awinusb_attach(device_t parent, device_t self, void *aux) | |
187 | { | 188 | { | |
188 | struct awinusb_softc * const usbsc = device_private(parent); | 189 | struct awinusb_softc * const usbsc = device_private(parent); | |
189 | struct ehci_softc * const sc = device_private(self); | 190 | struct ehci_softc * const sc = device_private(self); | |
190 | struct awinusb_attach_args * const usbaa = aux; | 191 | struct awinusb_attach_args * const usbaa = aux; | |
191 | 192 | |||
192 | sc->sc_dev = self; | 193 | sc->sc_dev = self; | |
193 | 194 | |||
194 | sc->iot = usbaa->usbaa_bst; | 195 | sc->iot = usbaa->usbaa_bst; | |
195 | sc->ioh = usbaa->usbaa_bsh; | 196 | sc->ioh = usbaa->usbaa_bsh; | |
196 | sc->sc_size = usbaa->usbaa_size; | 197 | sc->sc_size = usbaa->usbaa_size; | |
197 | sc->sc_bus.dmatag = usbaa->usbaa_dmat; | 198 | sc->sc_bus.dmatag = usbaa->usbaa_dmat; | |
198 | sc->sc_bus.hci_private = sc; | 199 | sc->sc_bus.hci_private = sc; | |
199 | sc->sc_bus.usbrev = USBREV_2_0; | 200 | sc->sc_bus.usbrev = USBREV_2_0; | |
200 | sc->sc_ncomp = 0; | 201 | sc->sc_ncomp = 0; | |
201 | if (usbsc->usbsc_ohci_dev != NULL) { | 202 | if (usbsc->usbsc_ohci_dev != NULL) { | |
202 | sc->sc_comps[sc->sc_ncomp++] = usbsc->usbsc_ohci_dev; | 203 | sc->sc_comps[sc->sc_ncomp++] = usbsc->usbsc_ohci_dev; | |
203 | } | 204 | } | |
204 | 205 | |||
205 | //sc->sc_id_vendor = PCI_VENDOR_ALLWINNER; | 206 | //sc->sc_id_vendor = PCI_VENDOR_ALLWINNER; | |
206 | strlcpy(sc->sc_vendor, "Allwinner", sizeof(sc->sc_vendor)); | 207 | strlcpy(sc->sc_vendor, "Allwinner", sizeof(sc->sc_vendor)); | |
207 | 208 | |||
208 | aprint_naive(": EHCI USB controller\n"); | 209 | aprint_naive(": EHCI USB controller\n"); | |
209 | aprint_normal(": EHCI USB controller\n"); | 210 | aprint_normal(": EHCI USB controller\n"); | |
210 | 211 | |||
211 | int error = ehci_init(sc); | 212 | int error = ehci_init(sc); | |
212 | if (error != USBD_NORMAL_COMPLETION) { | 213 | if (error != USBD_NORMAL_COMPLETION) { | |
213 | aprint_error_dev(self, "init failed, error=%d\n", error); | 214 | aprint_error_dev(self, "init failed, error=%d\n", error); | |
214 | } else { | 215 | } else { | |
215 | /* Attach usb device. */ | 216 | /* Attach usb device. */ | |
216 | sc->sc_child = config_found(self, &sc->sc_bus, usbctlprint); | 217 | sc->sc_child = config_found(self, &sc->sc_bus, usbctlprint); | |
217 | } | 218 | } | |
218 | 219 | |||
219 | const int irq = awinusb_ehci_irqs[usbaa->usbaa_port]; | 220 | const int irq = awinusb_ehci_irqs[usbaa->usbaa_port]; | |
220 | usbsc->usbsc_ehci_ih = intr_establish(irq, IPL_USB, | 221 | usbsc->usbsc_ehci_ih = intr_establish(irq, IPL_USB, | |
221 | IST_LEVEL, ehci_intr, sc); | 222 | IST_LEVEL, ehci_intr, sc); | |
222 | if (usbsc->usbsc_ehci_ih == NULL) { | 223 | if (usbsc->usbsc_ehci_ih == NULL) { | |
223 | aprint_error_dev(self, "failed to establish interrupt %d\n", | 224 | aprint_error_dev(self, "failed to establish interrupt %d\n", | |
224 | irq); | 225 | irq); | |
225 | return; | 226 | return; | |
226 | } | 227 | } | |
227 | aprint_normal_dev(self, "interrupting on irq %d\n", irq); | 228 | aprint_normal_dev(self, "interrupting on irq %d\n", irq); | |
228 | } | 229 | } | |
229 | #endif /* NEHCI > 0 */ | 230 | #endif /* NEHCI > 0 */ | |
230 | 231 | |||
231 | static void | 232 | static void | |
232 | awin_usb_phy_write(struct awinusb_softc *usbsc, u_int bit_addr, u_int bits, | 233 | awin_usb_phy_write(struct awinusb_softc *usbsc, u_int bit_addr, u_int bits, | |
233 | u_int len) | 234 | u_int len) | |
234 | { | 235 | { | |
235 | bus_space_tag_t bst = usbsc->usbsc_bst; | 236 | bus_space_tag_t bst = usbsc->usbsc_bst; | |
236 | bus_space_handle_t bsh = usbsc->usbsc_usb0_phy_csr_bsh; | 237 | bus_space_handle_t bsh = usbsc->usbsc_usb0_phy_csr_bsh; | |
237 | uint32_t clk = AWIN_USB0_PHY_CSR_CLK0 << usbsc->usbsc_number; | 238 | uint32_t clk = AWIN_USB0_PHY_CSR_CLK0 << usbsc->usbsc_number; | |
238 | 239 | |||
239 | uint32_t v = bus_space_read_4(bst, bsh, 0); | 240 | uint32_t v = bus_space_read_4(bst, bsh, 0); | |
240 | 241 | |||
241 | KASSERT((v & AWIN_USB0_PHY_CSR_CLK0) == 0); | 242 | KASSERT((v & AWIN_USB0_PHY_CSR_CLK0) == 0); | |
242 | KASSERT((v & AWIN_USB0_PHY_CSR_CLK1) == 0); | 243 | KASSERT((v & AWIN_USB0_PHY_CSR_CLK1) == 0); | |
243 | KASSERT((v & AWIN_USB0_PHY_CSR_CLK2) == 0); | 244 | KASSERT((v & AWIN_USB0_PHY_CSR_CLK2) == 0); | |
244 | 245 | |||
245 | v &= ~AWIN_USB0_PHY_CSR_ADDR; | 246 | v &= ~AWIN_USB0_PHY_CSR_ADDR; | |
246 | v &= ~AWIN_USB0_PHY_CSR_DAT; | 247 | v &= ~AWIN_USB0_PHY_CSR_DAT; | |
247 | 248 | |||
248 | v |= __SHIFTIN(bit_addr, AWIN_USB0_PHY_CSR_ADDR); | 249 | v |= __SHIFTIN(bit_addr, AWIN_USB0_PHY_CSR_ADDR); | |
249 | 250 | |||
250 | /* | 251 | /* | |
251 | * Bitbang the data to the phy, bit by bit, incrementing bit address | 252 | * Bitbang the data to the phy, bit by bit, incrementing bit address | |
252 | * as we go. | 253 | * as we go. | |
253 | */ | 254 | */ | |
254 | for (; len > 0; bit_addr++, bits >>= 1, len--) { | 255 | for (; len > 0; bit_addr++, bits >>= 1, len--) { | |
255 | v |= __SHIFTIN(bits & 1, AWIN_USB0_PHY_CSR_DAT); | 256 | v |= __SHIFTIN(bits & 1, AWIN_USB0_PHY_CSR_DAT); | |
256 | bus_space_write_4(bst, bsh, 0, v); | 257 | bus_space_write_4(bst, bsh, 0, v); | |
257 | delay(1); | 258 | delay(1); | |
258 | bus_space_write_4(bst, bsh, 0, v | clk); | 259 | bus_space_write_4(bst, bsh, 0, v | clk); | |
259 | delay(1); | 260 | delay(1); | |
260 | bus_space_write_4(bst, bsh, 0, v); | 261 | bus_space_write_4(bst, bsh, 0, v); | |
261 | delay(1); | 262 | delay(1); | |
262 | v += __LOWEST_SET_BIT(AWIN_USB0_PHY_CSR_ADDR); | 263 | v += __LOWEST_SET_BIT(AWIN_USB0_PHY_CSR_ADDR); | |
263 | v &= ~AWIN_USB0_PHY_CSR_DAT; | 264 | v &= ~AWIN_USB0_PHY_CSR_DAT; | |
264 | } | 265 | } | |
265 | } | 266 | } | |
266 | 267 | |||
267 | static int awinusb_match(device_t, cfdata_t, void *); | 268 | static int awinusb_match(device_t, cfdata_t, void *); | |
268 | static void awinusb_attach(device_t, device_t, void *); | 269 | static void awinusb_attach(device_t, device_t, void *); | |
269 | 270 | |||
270 | CFATTACH_DECL_NEW(awin_usb, sizeof(struct awinusb_softc), | 271 | CFATTACH_DECL_NEW(awin_usb, sizeof(struct awinusb_softc), | |
271 | awinusb_match, awinusb_attach, NULL, NULL); | 272 | awinusb_match, awinusb_attach, NULL, NULL); | |
272 | 273 | |||
273 | static int awinusb_ports; | 274 | static int awinusb_ports; | |
274 | 275 | |||
275 | static const char awinusb_drvpin_names[2][8] = { "usb1drv", "usb2drv" }; | 276 | static const char awinusb_drvpin_names[2][8] = { "usb1drv", "usb2drv" }; | |
276 | static const bus_size_t awinusb_dram_hpcr_regs[2] = { | 277 | static const bus_size_t awinusb_dram_hpcr_regs[2] = { | |
277 | AWIN_DRAM_HPCR_USB1_REG, | 278 | AWIN_DRAM_HPCR_USB1_REG, | |
278 | AWIN_DRAM_HPCR_USB2_REG, | 279 | AWIN_DRAM_HPCR_USB2_REG, | |
279 | }; | 280 | }; | |
280 | static const uint32_t awinusb_ahb_gating[2] = { | 281 | static const uint32_t awinusb_ahb_gating[2] = { | |
281 | #if NOHCI > 0 | 282 | #if NOHCI > 0 | |
282 | AWIN_AHB_GATING0_USB_OHCI0 | | 283 | AWIN_AHB_GATING0_USB_OHCI0 | | |
283 | #endif | 284 | #endif | |
284 | AWIN_AHB_GATING0_USB_EHCI0, | 285 | AWIN_AHB_GATING0_USB_EHCI0, | |
285 | #if NOHCI > 0 | 286 | #if NOHCI > 0 | |
286 | AWIN_AHB_GATING0_USB_OHCI1 | | 287 | AWIN_AHB_GATING0_USB_OHCI1 | | |
287 | #endif | 288 | #endif | |
288 | AWIN_AHB_GATING0_USB_EHCI1, | 289 | AWIN_AHB_GATING0_USB_EHCI1, | |
289 | }; | 290 | }; | |
290 | static const uint32_t awinusb_usb_clk_set[2] = { | 291 | static const uint32_t awinusb_usb_clk_set[2] = { | |
291 | #if NOHCI > 0 | 292 | #if NOHCI > 0 | |
292 | AWIN_USB_CLK_OHCI0_ENABLE | | 293 | AWIN_USB_CLK_OHCI0_ENABLE | | |
293 | #endif | 294 | #endif | |
294 | AWIN_USB_CLK_USBPHY_ENABLE|AWIN_USB_CLK_PHY1_ENABLE, | 295 | AWIN_USB_CLK_USBPHY_ENABLE|AWIN_USB_CLK_PHY1_ENABLE, | |
295 | #if NOHCI > 0 | 296 | #if NOHCI > 0 | |
296 | AWIN_USB_CLK_OHCI1_ENABLE | | 297 | AWIN_USB_CLK_OHCI1_ENABLE | | |
297 | #endif | 298 | #endif | |
298 | AWIN_USB_CLK_USBPHY_ENABLE|AWIN_USB_CLK_PHY2_ENABLE, | 299 | AWIN_USB_CLK_USBPHY_ENABLE|AWIN_USB_CLK_PHY2_ENABLE, | |
299 | }; | 300 | }; | |
300 | 301 | |||
301 | int | 302 | int | |
302 | awinusb_match(device_t parent, cfdata_t cf, void *aux) | 303 | awinusb_match(device_t parent, cfdata_t cf, void *aux) | |
303 | { | 304 | { | |
304 | struct awinio_attach_args * const aio = aux; | 305 | struct awinio_attach_args * const aio = aux; | |
305 | const struct awin_locators * const loc = &aio->aio_loc; | 306 | const struct awin_locators * const loc = &aio->aio_loc; | |
306 | 307 | |||
307 | KASSERT(loc->loc_port != AWINIOCF_PORT_DEFAULT); | 308 | KASSERT(loc->loc_port != AWINIOCF_PORT_DEFAULT); | |
308 | KASSERT(!strcmp(cf->cf_name, loc->loc_name)); | 309 | KASSERT(!strcmp(cf->cf_name, loc->loc_name)); | |
309 | KASSERT(cf->cf_loc[AWINIOCF_PORT] == AWINIOCF_PORT_DEFAULT | 310 | KASSERT(cf->cf_loc[AWINIOCF_PORT] == AWINIOCF_PORT_DEFAULT | |
310 | || cf->cf_loc[AWINIOCF_PORT] == loc->loc_port); | 311 | || cf->cf_loc[AWINIOCF_PORT] == loc->loc_port); | |
311 | KASSERT((awinusb_ports & __BIT(loc->loc_port)) == 0); | 312 | KASSERT((awinusb_ports & __BIT(loc->loc_port)) == 0); | |
312 | 313 | |||
313 | return 1; | 314 | return 1; | |
314 | } | 315 | } | |
315 | 316 | |||
316 | void | 317 | void | |
317 | awinusb_attach(device_t parent, device_t self, void *aux) | 318 | awinusb_attach(device_t parent, device_t self, void *aux) | |
318 | { | 319 | { | |
319 | struct awinusb_softc * const usbsc = device_private(self); | 320 | struct awinusb_softc * const usbsc = device_private(self); | |
320 | const struct awinio_attach_args * const aio = aux; | 321 | const struct awinio_attach_args * const aio = aux; | |
321 | const struct awin_locators * const loc = &aio->aio_loc; | 322 | const struct awin_locators * const loc = &aio->aio_loc; | |
322 | 323 | |||
323 | awinusb_ports |= __BIT(loc->loc_port); | 324 | awinusb_ports |= __BIT(loc->loc_port); | |
324 | 325 | |||
325 | usbsc->usbsc_bst = aio->aio_core_bst; | 326 | usbsc->usbsc_bst = aio->aio_core_bst; | |
326 | usbsc->usbsc_dmat = aio->aio_dmat; | 327 | usbsc->usbsc_dmat = aio->aio_dmat; | |
327 | usbsc->usbsc_number = loc->loc_port + 1; | 328 | usbsc->usbsc_number = loc->loc_port + 1; | |
328 | 329 | |||
329 | bus_space_subregion(usbsc->usbsc_bst, aio->aio_core_bsh, | 330 | bus_space_subregion(usbsc->usbsc_bst, aio->aio_core_bsh, | |
330 | loc->loc_offset + AWIN_EHCI_OFFSET, AWIN_EHCI_SIZE, | 331 | loc->loc_offset + AWIN_EHCI_OFFSET, AWIN_EHCI_SIZE, | |
331 | &usbsc->usbsc_ehci_bsh); | 332 | &usbsc->usbsc_ehci_bsh); | |
332 | bus_space_subregion(usbsc->usbsc_bst, aio->aio_core_bsh, | 333 | bus_space_subregion(usbsc->usbsc_bst, aio->aio_core_bsh, | |
333 | loc->loc_offset + AWIN_OHCI_OFFSET, AWIN_OHCI_SIZE, | 334 | loc->loc_offset + AWIN_OHCI_OFFSET, AWIN_OHCI_SIZE, | |
334 | &usbsc->usbsc_ohci_bsh); | 335 | &usbsc->usbsc_ohci_bsh); | |
335 | bus_space_subregion(usbsc->usbsc_bst, aio->aio_core_bsh, | 336 | bus_space_subregion(usbsc->usbsc_bst, aio->aio_core_bsh, | |
336 | AWIN_USB0_OFFSET + AWIN_USB0_PHY_CSR_REG, 4, | 337 | AWIN_USB0_OFFSET + AWIN_USB0_PHY_CSR_REG, 4, | |
337 | &usbsc->usbsc_usb0_phy_csr_bsh); | 338 | &usbsc->usbsc_usb0_phy_csr_bsh); | |
338 | 339 | |||
339 | aprint_naive("\n"); | 340 | aprint_naive("\n"); | |
340 | aprint_normal("\n"); | 341 | aprint_normal("\n"); | |
341 | 342 | |||
342 | /* | 343 | /* | |
343 | * Access to the USB phy is off USB0 so make sure it's on. | 344 | * Access to the USB phy is off USB0 so make sure it's on. | |
344 | */ | 345 | */ | |
345 | awin_reg_set_clear(usbsc->usbsc_bst, aio->aio_ccm_bsh, | 346 | awin_reg_set_clear(usbsc->usbsc_bst, aio->aio_ccm_bsh, | |
346 | AWIN_AHB_GATING0_REG, | 347 | AWIN_AHB_GATING0_REG, | |
347 | AWIN_AHB_GATING0_USB0 | awinusb_ahb_gating[loc->loc_port], 0); | 348 | AWIN_AHB_GATING0_USB0 | awinusb_ahb_gating[loc->loc_port], 0); | |
348 | 349 | |||
349 | 350 | |||
350 | /* | 351 | /* | |
351 | * Enable the USB phy for this port. | 352 | * Enable the USB phy for this port. | |
352 | */ | 353 | */ | |
353 | awin_reg_set_clear(usbsc->usbsc_bst, aio->aio_ccm_bsh, | 354 | awin_reg_set_clear(usbsc->usbsc_bst, aio->aio_ccm_bsh, | |
354 | AWIN_USB_CLK_REG, awinusb_usb_clk_set[loc->loc_port], 0); | 355 | AWIN_USB_CLK_REG, awinusb_usb_clk_set[loc->loc_port], 0); | |
355 | 356 | |||
356 | /* | 357 | /* | |
357 | * Allow USB DMA engine access to the DRAM. | 358 | * Allow USB DMA engine access to the DRAM. | |
358 | */ | 359 | */ | |
359 | awin_reg_set_clear(usbsc->usbsc_bst, aio->aio_core_bsh, | 360 | awin_reg_set_clear(usbsc->usbsc_bst, aio->aio_core_bsh, | |
360 | loc->loc_offset + AWIN_USB_PMU_IRQ_REG, | 361 | loc->loc_offset + AWIN_USB_PMU_IRQ_REG, | |
361 | AWIN_USB_PMU_IRQ_AHB_INCR8 | AWIN_USB_PMU_IRQ_AHB_INCR4 | 362 | AWIN_USB_PMU_IRQ_AHB_INCR8 | AWIN_USB_PMU_IRQ_AHB_INCR4 | |
362 | | AWIN_USB_PMU_IRQ_AHB_INCRX | AWIN_USB_PMU_IRQ_ULPI_BYPASS, | 363 | | AWIN_USB_PMU_IRQ_AHB_INCRX | AWIN_USB_PMU_IRQ_ULPI_BYPASS, | |
363 | 0); | 364 | 0); | |
364 | awin_reg_set_clear(usbsc->usbsc_bst, aio->aio_core_bsh, | 365 | awin_reg_set_clear(usbsc->usbsc_bst, aio->aio_core_bsh, | |
365 | AWIN_DRAM_OFFSET + awinusb_dram_hpcr_regs[loc->loc_port], | 366 | AWIN_DRAM_OFFSET + awinusb_dram_hpcr_regs[loc->loc_port], | |
366 | AWIN_DRAM_HPCR_ACCESS_EN, 0); | 367 | AWIN_DRAM_HPCR_ACCESS_EN, 0); | |
367 | 368 | |||
368 | /* initialize the USB phy */ | 369 | /* initialize the USB phy */ | |
369 | awin_usb_phy_write(usbsc, 0x20, 0x14, 5); | 370 | awin_usb_phy_write(usbsc, 0x20, 0x14, 5); | |
370 | awin_usb_phy_write(usbsc, 0x2a, 0x03, 2); | 371 | awin_usb_phy_write(usbsc, 0x2a, 0x03, 2); | |
371 | 372 | |||
372 | /* | 373 | /* | |
373 | * Now get the GPIO that enables the power to the port and | 374 | * Now get the GPIO that enables the power to the port and | |
374 | * turn it on. | 375 | * turn it on. | |
375 | */ | 376 | */ | |
376 | if (awin_gpio_pin_reserve(awinusb_drvpin_names[loc->loc_port], | 377 | if (awin_gpio_pin_reserve(awinusb_drvpin_names[loc->loc_port], | |
377 | &usbsc->usbsc_drv_pin)) { | 378 | &usbsc->usbsc_drv_pin)) { | |
378 | awin_gpio_pindata_write(&usbsc->usbsc_drv_pin, 1); | 379 | awin_gpio_pindata_write(&usbsc->usbsc_drv_pin, 1); | |
379 | } else { | 380 | } else { | |
380 | aprint_error_dev(self, "no power gpio found\n"); | 381 | aprint_error_dev(self, "no power gpio found\n"); | |
381 | } | 382 | } | |
382 | 383 | |||
383 | /* | 384 | /* | |
384 | * Disable interrupts | 385 | * Disable interrupts | |
385 | */ | 386 | */ | |
386 | #if NOHCI > 0 | 387 | #if NOHCI > 0 | |
387 | bus_space_write_4(usbsc->usbsc_bst, usbsc->usbsc_ohci_bsh, | 388 | bus_space_write_4(usbsc->usbsc_bst, usbsc->usbsc_ohci_bsh, | |
388 | OHCI_INTERRUPT_DISABLE, OHCI_ALL_INTRS); | 389 | OHCI_INTERRUPT_DISABLE, OHCI_ALL_INTRS); | |
389 | #endif | 390 | #endif | |
390 | #if NEHCI > 0 | 391 | #if NEHCI > 0 | |
391 | bus_size_t caplength = bus_space_read_1(usbsc->usbsc_bst, | 392 | bus_size_t caplength = bus_space_read_1(usbsc->usbsc_bst, | |
392 | usbsc->usbsc_ehci_bsh, EHCI_CAPLENGTH); | 393 | usbsc->usbsc_ehci_bsh, EHCI_CAPLENGTH); | |
393 | bus_space_write_4(usbsc->usbsc_bst, usbsc->usbsc_ehci_bsh, | 394 | bus_space_write_4(usbsc->usbsc_bst, usbsc->usbsc_ehci_bsh, | |
394 | caplength + EHCI_USBINTR, 0); | 395 | caplength + EHCI_USBINTR, 0); | |
395 | #endif | 396 | #endif | |
396 | 397 | |||
397 | #if NOHCI > 0 | 398 | #if NOHCI > 0 | |
398 | struct awinusb_attach_args usbaa_ohci = { | 399 | struct awinusb_attach_args usbaa_ohci = { | |
399 | .usbaa_name = "ohci", | 400 | .usbaa_name = "ohci", | |
400 | .usbaa_dmat = usbsc->usbsc_dmat, | 401 | .usbaa_dmat = usbsc->usbsc_dmat, | |
401 | .usbaa_bst = usbsc->usbsc_bst, | 402 | .usbaa_bst = usbsc->usbsc_bst, | |
402 | .usbaa_bsh = usbsc->usbsc_ohci_bsh, | 403 | .usbaa_bsh = usbsc->usbsc_ohci_bsh, | |
403 | .usbaa_ccm_bsh = aio->aio_ccm_bsh, | 404 | .usbaa_ccm_bsh = aio->aio_ccm_bsh, | |
404 | .usbaa_size = AWIN_OHCI_SIZE, | 405 | .usbaa_size = AWIN_OHCI_SIZE, | |
405 | .usbaa_port = loc->loc_port, | 406 | .usbaa_port = loc->loc_port, | |
406 | }; | 407 | }; | |
407 | 408 | |||
408 | usbsc->usbsc_ohci_dev = config_found(self, &usbaa_ohci, NULL); | 409 | usbsc->usbsc_ohci_dev = config_found(self, &usbaa_ohci, NULL); | |
409 | #endif | 410 | #endif | |
410 | 411 | |||
411 | #if NEHCI > 0 | 412 | #if NEHCI > 0 | |
412 | struct awinusb_attach_args usbaa_ehci = { | 413 | struct awinusb_attach_args usbaa_ehci = { | |
413 | .usbaa_name = "ehci", | 414 | .usbaa_name = "ehci", | |
414 | .usbaa_dmat = usbsc->usbsc_dmat, | 415 | .usbaa_dmat = usbsc->usbsc_dmat, | |
415 | .usbaa_bst = usbsc->usbsc_bst, | 416 | .usbaa_bst = usbsc->usbsc_bst, | |
416 | .usbaa_bsh = usbsc->usbsc_ehci_bsh, | 417 | .usbaa_bsh = usbsc->usbsc_ehci_bsh, | |
417 | .usbaa_ccm_bsh = aio->aio_ccm_bsh, | 418 | .usbaa_ccm_bsh = aio->aio_ccm_bsh, | |
418 | .usbaa_size = AWIN_EHCI_SIZE, | 419 | .usbaa_size = AWIN_EHCI_SIZE, | |
419 | .usbaa_port = loc->loc_port, | 420 | .usbaa_port = loc->loc_port, | |
420 | }; | 421 | }; | |
421 | 422 | |||
422 | config_found(self, &usbaa_ehci, NULL); | 423 | config_found(self, &usbaa_ehci, NULL); | |
423 | #endif | 424 | #endif | |
424 | } | 425 | } |