Wed Apr 16 21:28:51 2014 UTC ()
Teach sscom attachment, also the console, to use the busspace handle of the
main register space.

While here, map in the correct amount of memory or bus_space_map() won't
return an error but will wedge the system.


(reinoud)
diff -r1.4 -r1.5 src/sys/arch/arm/samsung/exynos_soc.c
diff -r1.2 -r1.3 src/sys/arch/arm/samsung/exynos_sscom.c
diff -r1.2 -r1.3 src/sys/arch/arm/samsung/sscom.c
diff -r1.2 -r1.3 src/sys/arch/arm/samsung/sscom_var.h

cvs diff -r1.4 -r1.5 src/sys/arch/arm/samsung/exynos_soc.c (expand / switch to unified diff)

--- src/sys/arch/arm/samsung/exynos_soc.c 2014/04/13 20:52:29 1.4
+++ src/sys/arch/arm/samsung/exynos_soc.c 2014/04/16 21:28:51 1.5
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: exynos_soc.c,v 1.4 2014/04/13 20:52:29 reinoud Exp $ */ 1/* $NetBSD: exynos_soc.c,v 1.5 2014/04/16 21:28:51 reinoud Exp $ */
2/*- 2/*-
3 * Copyright (c) 2014 The NetBSD Foundation, Inc. 3 * Copyright (c) 2014 The NetBSD Foundation, Inc.
4 * All rights reserved. 4 * All rights reserved.
5 * 5 *
6 * This code is derived from software contributed to The NetBSD Foundation 6 * This code is derived from software contributed to The NetBSD Foundation
7 * by Reinoud Zandijk. 7 * by Reinoud Zandijk.
8 * 8 *
9 * Redistribution and use in source and binary forms, with or without 9 * Redistribution and use in source and binary forms, with or without
10 * modification, are permitted provided that the following conditions 10 * modification, are permitted provided that the following conditions
11 * are met: 11 * are met:
12 * 1. Redistributions of source code must retain the above copyright 12 * 1. Redistributions of source code must retain the above copyright
13 * notice, this list of conditions and the following disclaimer. 13 * notice, this list of conditions and the following disclaimer.
14 * 2. Redistributions in binary form must reproduce the above copyright 14 * 2. Redistributions in binary form must reproduce the above copyright
@@ -23,27 +23,27 @@ @@ -23,27 +23,27 @@
23 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 23 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
24 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 24 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
25 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 25 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
26 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 26 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
27 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 27 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
28 * POSSIBILITY OF SUCH DAMAGE. 28 * POSSIBILITY OF SUCH DAMAGE.
29 */ 29 */
30 30
31#include "opt_exynos.h" 31#include "opt_exynos.h"
32 32
33#define _ARM32_BUS_DMA_PRIVATE 33#define _ARM32_BUS_DMA_PRIVATE
34 34
35#include <sys/cdefs.h> 35#include <sys/cdefs.h>
36__KERNEL_RCSID(1, "$NetBSD: exynos_soc.c,v 1.4 2014/04/13 20:52:29 reinoud Exp $"); 36__KERNEL_RCSID(1, "$NetBSD: exynos_soc.c,v 1.5 2014/04/16 21:28:51 reinoud Exp $");
37 37
38#include <sys/param.h> 38#include <sys/param.h>
39#include <sys/bus.h> 39#include <sys/bus.h>
40#include <sys/cpu.h> 40#include <sys/cpu.h>
41#include <sys/device.h> 41#include <sys/device.h>
42 42
43#include <prop/proplib.h> 43#include <prop/proplib.h>
44 44
45#include <net/if.h> 45#include <net/if.h>
46#include <net/if_ether.h> 46#include <net/if_ether.h>
47 47
48#include <arm/locore.h> 48#include <arm/locore.h>
49 49
@@ -195,46 +195,52 @@ exynos_l2cc_init(void) @@ -195,46 +195,52 @@ exynos_l2cc_init(void)
195 195
196 exynos_smc(SMC_CMD_L2X0SETUP1, tag_latency, data_latency, prefetch); 196 exynos_smc(SMC_CMD_L2X0SETUP1, tag_latency, data_latency, prefetch);
197 exynos_smc(SMC_CMD_L2X0SETUP2, 197 exynos_smc(SMC_CMD_L2X0SETUP2,
198 POWERCTL_DYNCLKGATE | POWERCTL_STANDBY, 198 POWERCTL_DYNCLKGATE | POWERCTL_STANDBY,
199 aux_val, aux_keepmask); 199 aux_val, aux_keepmask);
200 exynos_smc(SMC_CMD_L2X0INVALL, 0, 0, 0); 200 exynos_smc(SMC_CMD_L2X0INVALL, 0, 0, 0);
201 exynos_smc(SMC_CMD_L2X0CTRL, 1, 0, 0); 201 exynos_smc(SMC_CMD_L2X0CTRL, 1, 0, 0);
202 202
203 return 0; 203 return 0;
204} 204}
205#endif /* ARM_TRUSTZONE_FIRMWARE */ 205#endif /* ARM_TRUSTZONE_FIRMWARE */
206 206
207 207
 208#ifndef EXYNOS4
 209# define EXYNOS4_CORE_SIZE 0
 210#endif
 211#ifndef EXYNOS5
 212# define EXYNOS5_CORE_SIZE 0
 213#endif
208void 214void
209exynos_bootstrap(vaddr_t iobase, vaddr_t uartbase) 215exynos_bootstrap(vaddr_t iobase, vaddr_t uartbase)
210{ 216{
211// int error; 217 int error;
 218 size_t core_size = IS_EXYNOS4_P() ?
 219 EXYNOS4_CORE_SIZE : EXYNOS5_CORE_SIZE;
212 220
213 /* set up early console so we can use printf() and friends */ 221 /* set up early console so we can use printf() and friends */
214#ifdef EXYNOS_CONSOLE_EARLY 222#ifdef EXYNOS_CONSOLE_EARLY
215 uart_base = (volatile uint8_t *) uartbase; 223 uart_base = (volatile uint8_t *) uartbase;
216 cn_tab = &exynos_earlycons; 224 cn_tab = &exynos_earlycons;
217 printf("Exynos early console operational\n\n"); 225 printf("Exynos early console operational\n\n");
218#endif 226#endif
219#if 0 
220 /* map in the exynos io registers */ 227 /* map in the exynos io registers */
221 error = bus_space_map(&exynos_bs_tag, EXYNOS_CORE_PBASE, 228 error = bus_space_map(&exynos_bs_tag, EXYNOS_CORE_PBASE,
222 0x04000000 /*EXYNOS_CORE_SIZE*/, 0, &exynos_core_bsh); 229 core_size, 0, &exynos_core_bsh);
223 if (error) 230 if (error)
224 panic("%s: failed to map in Exynos io registers: %d", 231 panic("%s: failed to map in Exynos io registers: %d",
225 __func__, error); 232 __func__, error);
226 KASSERT(exynos_core_bsh == iobase); 233 KASSERT(exynos_core_bsh == iobase);
227#endif 
228} 234}
229 235
230 236
231void 237void
232exynos_device_register(device_t self, void *aux) 238exynos_device_register(device_t self, void *aux)
233{ 239{
234 if (device_is_a(self, "armperiph") 240 if (device_is_a(self, "armperiph")
235 && device_is_a(device_parent(self), "mainbus")) { 241 && device_is_a(device_parent(self), "mainbus")) {
236 /* 242 /*
237 * XXX KLUDGE ALERT XXX 243 * XXX KLUDGE ALERT XXX
238 * The iot mainbus supplies is completely wrong since it scales 244 * The iot mainbus supplies is completely wrong since it scales
239 * addresses by 2. The simpliest remedy is to replace with our 245 * addresses by 2. The simpliest remedy is to replace with our
240 * bus space used for the armcore regisers (which armperiph uses). 246 * bus space used for the armcore regisers (which armperiph uses).

cvs diff -r1.2 -r1.3 src/sys/arch/arm/samsung/Attic/exynos_sscom.c (expand / switch to unified diff)

--- src/sys/arch/arm/samsung/Attic/exynos_sscom.c 2014/04/14 21:16:15 1.2
+++ src/sys/arch/arm/samsung/Attic/exynos_sscom.c 2014/04/16 21:28:51 1.3
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: exynos_sscom.c,v 1.2 2014/04/14 21:16:15 reinoud Exp $ */ 1/* $NetBSD: exynos_sscom.c,v 1.3 2014/04/16 21:28:51 reinoud Exp $ */
2 2
3/* 3/*
4 * Copyright (c) 2014 Reinoud Zandijk 4 * Copyright (c) 2014 Reinoud Zandijk
5 * Copyright (c) 2002, 2003 Fujitsu Component Limited 5 * Copyright (c) 2002, 2003 Fujitsu Component Limited
6 * Copyright (c) 2002, 2003 Genetec Corporation 6 * Copyright (c) 2002, 2003 Genetec Corporation
7 * All rights reserved. 7 * All rights reserved.
8 * 8 *
9 * Redistribution and use in source and binary forms, with or without 9 * Redistribution and use in source and binary forms, with or without
10 * modification, are permitted provided that the following conditions 10 * modification, are permitted provided that the following conditions
11 * are met: 11 * are met:
12 * 1. Redistributions of source code must retain the above copyright 12 * 1. Redistributions of source code must retain the above copyright
13 * notice, this list of conditions and the following disclaimer. 13 * notice, this list of conditions and the following disclaimer.
14 * 2. Redistributions in binary form must reproduce the above copyright 14 * 2. Redistributions in binary form must reproduce the above copyright
@@ -24,27 +24,27 @@ @@ -24,27 +24,27 @@
24 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 24 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
25 * DISCLAIMED. IN NO EVENT SHALL FUJITSU COMPONENT LIMITED OR GENETEC 25 * DISCLAIMED. IN NO EVENT SHALL FUJITSU COMPONENT LIMITED OR GENETEC
26 * CORPORATION BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 26 * CORPORATION BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
27 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 27 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
28 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF 28 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
29 * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 29 * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
30 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 30 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
31 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT 31 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
32 * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 32 * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
33 * SUCH DAMAGE. 33 * SUCH DAMAGE.
34 */ 34 */
35 35
36#include <sys/cdefs.h> 36#include <sys/cdefs.h>
37__KERNEL_RCSID(0, "$NetBSD: exynos_sscom.c,v 1.2 2014/04/14 21:16:15 reinoud Exp $"); 37__KERNEL_RCSID(0, "$NetBSD: exynos_sscom.c,v 1.3 2014/04/16 21:28:51 reinoud Exp $");
38 38
39#include "opt_sscom.h" 39#include "opt_sscom.h"
40#include "opt_ddb.h" 40#include "opt_ddb.h"
41#include "opt_kgdb.h" 41#include "opt_kgdb.h"
42 42
43#include <sys/param.h> 43#include <sys/param.h>
44#include <sys/systm.h> 44#include <sys/systm.h>
45#include <sys/ioctl.h> 45#include <sys/ioctl.h>
46#include <sys/select.h> 46#include <sys/select.h>
47#include <sys/tty.h> 47#include <sys/tty.h>
48#include <sys/proc.h> 48#include <sys/proc.h>
49#include <sys/conf.h> 49#include <sys/conf.h>
50#include <sys/file.h> 50#include <sys/file.h>
@@ -131,43 +131,45 @@ exynos_clear_interrupts(struct sscom_sof @@ -131,43 +131,45 @@ exynos_clear_interrupts(struct sscom_sof
131 if (flags & SSCOM_HW_RXINT) 131 if (flags & SSCOM_HW_RXINT)
132 val |= sc->sc_rx_irqno; 132 val |= sc->sc_rx_irqno;
133 if (flags & SSCOM_HW_TXINT) 133 if (flags & SSCOM_HW_TXINT)
134 val |= sc->sc_tx_irqno; 134 val |= sc->sc_tx_irqno;
135 bus_space_write_4(sc->sc_iot, sc->sc_ioh, SSCOM_UINTP, val); 135 bus_space_write_4(sc->sc_iot, sc->sc_ioh, SSCOM_UINTP, val);
136} 136}
137 137
138static void 138static void
139sscom_attach(device_t parent, device_t self, void *aux) 139sscom_attach(device_t parent, device_t self, void *aux)
140{ 140{
141 struct sscom_softc *sc = device_private(self); 141 struct sscom_softc *sc = device_private(self);
142 struct exyo_attach_args *exyo = aux; 142 struct exyo_attach_args *exyo = aux;
143 int unit = exyo->exyo_loc.loc_port; 143 int unit = exyo->exyo_loc.loc_port;
144 bus_addr_t iobase = exyo->exyo_loc.loc_offset; 
145 144
146 aprint_normal( ": UART%d addr=%lx", unit, iobase ); 145 /* debug */
 146// bus_addr_t iobase = exyo->exyo_loc.loc_offset;
 147// aprint_normal( ": UART%d addr=%lx", unit, iobase );
147 148
148 sc->sc_dev = self; 149 sc->sc_dev = self;
149 sc->sc_iot = exyo->exyo_core_bst; 150 sc->sc_iot = exyo->exyo_core_bst;
150 sc->sc_unit = unit; 151 sc->sc_unit = unit;
151 sc->sc_frequency = EXYNOS_UART_FREQ; 152 sc->sc_frequency = EXYNOS_UART_FREQ;
152 153
153 sc->sc_change_txrx_interrupts = exynos_change_txrx_interrupts; 154 sc->sc_change_txrx_interrupts = exynos_change_txrx_interrupts;
154 sc->sc_clear_interrupts = exynos_clear_interrupts; 155 sc->sc_clear_interrupts = exynos_clear_interrupts;
155 156
156 sc->sc_rx_irqno = UINT_RXD; 157 sc->sc_rx_irqno = UINT_RXD;
157 sc->sc_tx_irqno = UINT_TXD; 158 sc->sc_tx_irqno = UINT_TXD;
158 159
159 if (!sscom_is_console(sc->sc_iot, unit, &sc->sc_ioh) 160 if (!sscom_is_console(sc->sc_iot, unit, &sc->sc_ioh)
160 && bus_space_map(sc->sc_iot, iobase, SSCOM_SIZE, 0, &sc->sc_ioh)) { 161 && bus_space_subregion(sc->sc_iot, exyo->exyo_core_bsh,
 162 exyo->exyo_loc.loc_offset, SSCOM_SIZE, &sc->sc_ioh)) {
161 printf( ": failed to map registers\n" ); 163 printf( ": failed to map registers\n" );
162 return; 164 return;
163 } 165 }
164 166
165 printf("\n"); 167 printf("\n");
166 168
167 void *ih = intr_establish(exyo->exyo_loc.loc_intr, IPL_SERIAL, 169 void *ih = intr_establish(exyo->exyo_loc.loc_intr, IPL_SERIAL,
168 IST_LEVEL, sscomintr, sc); 170 IST_LEVEL, sscomintr, sc);
169 if (ih != NULL) { 171 if (ih != NULL) {
170 aprint_normal_dev(self, "interrupting at irq %d\n", 172 aprint_normal_dev(self, "interrupting at irq %d\n",
171 exyo->exyo_loc.loc_intr); 173 exyo->exyo_loc.loc_intr);
172 } 174 }
173 sscom_attach_subr(sc); 175 sscom_attach_subr(sc);

cvs diff -r1.2 -r1.3 src/sys/arch/arm/samsung/Attic/sscom.c (expand / switch to unified diff)

--- src/sys/arch/arm/samsung/Attic/sscom.c 2014/04/14 21:16:15 1.2
+++ src/sys/arch/arm/samsung/Attic/sscom.c 2014/04/16 21:28:51 1.3
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: sscom.c,v 1.2 2014/04/14 21:16:15 reinoud Exp $ */ 1/* $NetBSD: sscom.c,v 1.3 2014/04/16 21:28:51 reinoud Exp $ */
2 2
3/* 3/*
4 * Copyright (c) 2002, 2003 Fujitsu Component Limited 4 * Copyright (c) 2002, 2003 Fujitsu Component Limited
5 * Copyright (c) 2002, 2003 Genetec Corporation 5 * Copyright (c) 2002, 2003 Genetec Corporation
6 * All rights reserved. 6 * All rights reserved.
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
@@ -88,27 +88,27 @@ @@ -88,27 +88,27 @@
88 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 88 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
89 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 89 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
90 * SUCH DAMAGE. 90 * SUCH DAMAGE.
91 * 91 *
92 * @(#)com.c 7.5 (Berkeley) 5/16/91 92 * @(#)com.c 7.5 (Berkeley) 5/16/91
93 */ 93 */
94 94
95/* 95/*
96 * Support integrated UARTs of Samsung S3C2800/2400X/2410X 96 * Support integrated UARTs of Samsung S3C2800/2400X/2410X
97 * Derived from sys/dev/ic/com.c 97 * Derived from sys/dev/ic/com.c
98 */ 98 */
99 99
100#include <sys/cdefs.h> 100#include <sys/cdefs.h>
101__KERNEL_RCSID(0, "$NetBSD: sscom.c,v 1.2 2014/04/14 21:16:15 reinoud Exp $"); 101__KERNEL_RCSID(0, "$NetBSD: sscom.c,v 1.3 2014/04/16 21:28:51 reinoud Exp $");
102 102
103#include "opt_sscom.h" 103#include "opt_sscom.h"
104#include "opt_ddb.h" 104#include "opt_ddb.h"
105#include "opt_kgdb.h" 105#include "opt_kgdb.h"
106#include "opt_multiprocessor.h" 106#include "opt_multiprocessor.h"
107#include "opt_lockdebug.h" 107#include "opt_lockdebug.h"
108 108
109#include "rnd.h" 109#include "rnd.h"
110#ifdef RND_COM 110#ifdef RND_COM
111#include <sys/rnd.h> 111#include <sys/rnd.h>
112#endif 112#endif
113 113
114/* 114/*
@@ -171,27 +171,28 @@ integrate void sscom_schedrx (struct ssc @@ -171,27 +171,28 @@ integrate void sscom_schedrx (struct ssc
171static void sscom_modem(struct sscom_softc *, int); 171static void sscom_modem(struct sscom_softc *, int);
172static void sscom_break(struct sscom_softc *, int); 172static void sscom_break(struct sscom_softc *, int);
173static void sscom_iflush(struct sscom_softc *); 173static void sscom_iflush(struct sscom_softc *);
174static void sscom_hwiflow(struct sscom_softc *); 174static void sscom_hwiflow(struct sscom_softc *);
175static void sscom_loadchannelregs(struct sscom_softc *); 175static void sscom_loadchannelregs(struct sscom_softc *);
176static void tiocm_to_sscom(struct sscom_softc *, u_long, int); 176static void tiocm_to_sscom(struct sscom_softc *, u_long, int);
177static int sscom_to_tiocm(struct sscom_softc *); 177static int sscom_to_tiocm(struct sscom_softc *);
178static void tiocm_to_sscom(struct sscom_softc *, u_long, int); 178static void tiocm_to_sscom(struct sscom_softc *, u_long, int);
179static int sscom_to_tiocm(struct sscom_softc *); 179static int sscom_to_tiocm(struct sscom_softc *);
180static void sscom_iflush(struct sscom_softc *); 180static void sscom_iflush(struct sscom_softc *);
181 181
182static int sscomhwiflow(struct tty *tp, int block); 182static int sscomhwiflow(struct tty *tp, int block);
183#if defined(KGDB) || defined(SSCOM0CONSOLE) || defined(SSCOM1CONSOLE) 183#if defined(KGDB) || defined(SSCOM0CONSOLE) || defined(SSCOM1CONSOLE)
184static int sscom_init(bus_space_tag_t, const struct sscom_uart_info *, 184static int sscom_init(bus_space_tag_t, bus_space_handle_t,
 185 const struct sscom_uart_info *,
185 int, int, tcflag_t, bus_space_handle_t *); 186 int, int, tcflag_t, bus_space_handle_t *);
186#endif 187#endif
187 188
188extern struct cfdriver sscom_cd; 189extern struct cfdriver sscom_cd;
189 190
190const struct cdevsw sscom_cdevsw = { 191const struct cdevsw sscom_cdevsw = {
191 .d_open = sscomopen, 192 .d_open = sscomopen,
192 .d_close = sscomclose, 193 .d_close = sscomclose,
193 .d_read = sscomread, 194 .d_read = sscomread,
194 .d_write = sscomwrite, 195 .d_write = sscomwrite,
195 .d_ioctl = sscomioctl, 196 .d_ioctl = sscomioctl,
196 .d_stop = sscomstop, 197 .d_stop = sscomstop,
197 .d_tty = sscomtty, 198 .d_tty = sscomtty,
@@ -1829,35 +1830,35 @@ sscomintr(void *v) @@ -1829,35 +1830,35 @@ sscomintr(void *v)
1829 1830
1830 if (clear) 1831 if (clear)
1831 sc->sc_clear_interrupts(sc, clear); 1832 sc->sc_clear_interrupts(sc, clear);
1832 1833
1833 return clear? 1: 0; 1834 return clear? 1: 0;
1834} 1835}
1835 1836
1836 1837
1837#if defined(KGDB) || defined(SSCOM0CONSOLE) || defined(SSCOM1CONSOLE) 1838#if defined(KGDB) || defined(SSCOM0CONSOLE) || defined(SSCOM1CONSOLE)
1838/* 1839/*
1839 * Initialize UART for use as console or KGDB line. 1840 * Initialize UART for use as console or KGDB line.
1840 */ 1841 */
1841static int 1842static int
1842sscom_init(bus_space_tag_t iot, const struct sscom_uart_info *config, 1843sscom_init(bus_space_tag_t iot, bus_space_handle_t base_ioh,
 1844 const struct sscom_uart_info *config,
1843 int rate, int frequency, tcflag_t cflag, bus_space_handle_t *iohp) 1845 int rate, int frequency, tcflag_t cflag, bus_space_handle_t *iohp)
1844{ 1846{
1845 bus_space_handle_t ioh; 1847 bus_space_handle_t ioh;
1846 bus_addr_t iobase = config->iobase; 1848 bus_addr_t iobase = config->iobase;
1847 int timo = 150000; 1849 int timo = 150000;
1848 1850
1849 if (bus_space_map(iot, iobase, SSCOM_SIZE, 0, &ioh)) 1851 bus_space_subregion(iot, base_ioh, iobase, SSCOM_SIZE, &ioh);
1850 return ENOMEM; /* ??? */ 
1851 1852
1852 /* wait until all is transmitted until we enable this device */ 1853 /* wait until all is transmitted until we enable this device */
1853 while (!(bus_space_read_4(iot, ioh, SSCOM_UTRSTAT) & 1854 while (!(bus_space_read_4(iot, ioh, SSCOM_UTRSTAT) &
1854 UTRSTAT_TXSHIFTER_EMPTY) && --timo); 1855 UTRSTAT_TXSHIFTER_EMPTY) && --timo);
1855 1856
1856 /* reset UART control */ 1857 /* reset UART control */
1857 bus_space_write_4(iot, ioh, SSCOM_UCON, 0); 1858 bus_space_write_4(iot, ioh, SSCOM_UCON, 0);
1858 1859
1859 /* set RX/TX trigger to half values */ 1860 /* set RX/TX trigger to half values */
1860 bus_space_write_4(iot, ioh, SSCOM_UFCON, 1861 bus_space_write_4(iot, ioh, SSCOM_UFCON,
1861 __SHIFTIN(4, UFCON_TXTRIGGER) | 1862 __SHIFTIN(4, UFCON_TXTRIGGER) |
1862 __SHIFTIN(4, UFCON_RXTRIGGER) | 1863 __SHIFTIN(4, UFCON_RXTRIGGER) |
1863 UFCON_FIFO_ENABLE |  1864 UFCON_FIFO_ENABLE |
@@ -1883,32 +1884,34 @@ sscom_init(bus_space_tag_t iot, const st @@ -1883,32 +1884,34 @@ sscom_init(bus_space_tag_t iot, const st
1883#endif 1884#endif
1884 1885
1885#if defined(SSCOM0CONSOLE) || defined(SSCOM1CONSOLE) 1886#if defined(SSCOM0CONSOLE) || defined(SSCOM1CONSOLE)
1886/* 1887/*
1887 * Following are all routines needed for SSCOM to act as console 1888 * Following are all routines needed for SSCOM to act as console
1888 */ 1889 */
1889struct consdev sscomcons = { 1890struct consdev sscomcons = {
1890 NULL, NULL, sscomcngetc, sscomcnputc, sscomcnpollc, NULL, 1891 NULL, NULL, sscomcngetc, sscomcnputc, sscomcnpollc, NULL,
1891 NULL, NULL, NODEV, CN_NORMAL 1892 NULL, NULL, NODEV, CN_NORMAL
1892}; 1893};
1893 1894
1894 1895
1895int 1896int
1896sscom_cnattach(bus_space_tag_t iot, const struct sscom_uart_info *config, 1897sscom_cnattach(bus_space_tag_t iot, bus_space_handle_t ioh,
 1898 const struct sscom_uart_info *config,
1897 int rate, int frequency, tcflag_t cflag) 1899 int rate, int frequency, tcflag_t cflag)
1898{ 1900{
1899 int res; 1901 int res;
1900 1902
1901 res = sscom_init(iot, config, rate, frequency, cflag, &sscomconsioh); 1903 res = sscom_init(iot, ioh, config,
 1904 rate, frequency, cflag, &sscomconsioh);
1902 if (res) 1905 if (res)
1903 return res; 1906 return res;
1904 1907
1905 cn_tab = &sscomcons; 1908 cn_tab = &sscomcons;
1906 cn_init_magic(&sscom_cnm_state); 1909 cn_init_magic(&sscom_cnm_state);
1907 cn_set_magic("\047\001"); /* default magic is BREAK */ 1910 cn_set_magic("\047\001"); /* default magic is BREAK */
1908 1911
1909 sscomconstag = iot; 1912 sscomconstag = iot;
1910 sscomconsunit = config->unit; 1913 sscomconsunit = config->unit;
1911 sscomconsrate = rate; 1914 sscomconsrate = rate;
1912 sscomconscflag = cflag; 1915 sscomconscflag = cflag;
1913 1916
1914 return 0; 1917 return 0;
@@ -2012,37 +2015,39 @@ sscomcnputc(dev_t dev, int c) @@ -2012,37 +2015,39 @@ sscomcnputc(dev_t dev, int c)
2012} 2015}
2013 2016
2014void 2017void
2015sscomcnpollc(dev_t dev, int on) 2018sscomcnpollc(dev_t dev, int on)
2016{ 2019{
2017 2020
2018 sscom_readaheadcount = 0; 2021 sscom_readaheadcount = 0;
2019} 2022}
2020 2023
2021#endif /* SSCOM0CONSOLE||SSCOM1CONSOLE */ 2024#endif /* SSCOM0CONSOLE||SSCOM1CONSOLE */
2022 2025
2023#ifdef KGDB 2026#ifdef KGDB
2024int 2027int
2025sscom_kgdb_attach(bus_space_tag_t iot, const struct sscom_uart_info *config, 2028sscom_kgdb_attach(bus_space_tag_t iot, bus_space_handle_t ioh,
 2029 const struct sscom_uart_info *config,
2026 int rate, int frequency, tcflag_t cflag) 2030 int rate, int frequency, tcflag_t cflag)
2027{ 2031{
2028 int res; 2032 int res;
2029 2033
2030 if (iot == sscomconstag && config->unit == sscomconsunit) { 2034 if (iot == sscomconstag && config->unit == sscomconsunit) {
2031 printf( "console==kgdb_port (%d): kgdb disabled\n", sscomconsunit); 2035 printf( "console==kgdb_port (%d): kgdb disabled\n", sscomconsunit);
2032 return EBUSY; /* cannot share with console */ 2036 return EBUSY; /* cannot share with console */
2033 } 2037 }
2034 2038
2035 res = sscom_init(iot, config, rate, frequency, cflag, &sscom_kgdb_ioh); 2039 res = sscom_init(iot, ioh, config,
 2040 rate, frequency, cflag, &sscom_kgdb_ioh);
2036 if (res) 2041 if (res)
2037 return res; 2042 return res;
2038 2043
2039 kgdb_attach(sscom_kgdb_getc, sscom_kgdb_putc, NULL); 2044 kgdb_attach(sscom_kgdb_getc, sscom_kgdb_putc, NULL);
2040 kgdb_dev = 123; /* unneeded, only to satisfy some tests */ 2045 kgdb_dev = 123; /* unneeded, only to satisfy some tests */
2041 2046
2042 sscom_kgdb_iot = iot; 2047 sscom_kgdb_iot = iot;
2043 sscom_kgdb_unit = config->unit; 2048 sscom_kgdb_unit = config->unit;
2044 2049
2045 return 0; 2050 return 0;
2046} 2051}
2047 2052
2048/* ARGSUSED */ 2053/* ARGSUSED */

cvs diff -r1.2 -r1.3 src/sys/arch/arm/samsung/Attic/sscom_var.h (expand / switch to unified diff)

--- src/sys/arch/arm/samsung/Attic/sscom_var.h 2014/04/14 21:16:15 1.2
+++ src/sys/arch/arm/samsung/Attic/sscom_var.h 2014/04/16 21:28:51 1.3
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: sscom_var.h,v 1.2 2014/04/14 21:16:15 reinoud Exp $ */ 1/* $NetBSD: sscom_var.h,v 1.3 2014/04/16 21:28:51 reinoud Exp $ */
2 2
3/* 3/*
4 * Copyright (c) 2002, 2003 Fujitsu Component Limited 4 * Copyright (c) 2002, 2003 Fujitsu Component Limited
5 * Copyright (c) 2002, 2003 Genetec Corporation 5 * Copyright (c) 2002, 2003 Genetec Corporation
6 * All rights reserved. 6 * All rights reserved.
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
@@ -233,25 +233,26 @@ void sscom_attach_subr(struct sscom_soft @@ -233,25 +233,26 @@ void sscom_attach_subr(struct sscom_soft
233int sscom_detach(device_t, int); 233int sscom_detach(device_t, int);
234int sscom_activate(device_t, enum devact); 234int sscom_activate(device_t, enum devact);
235void sscom_shutdown(struct sscom_softc *); 235void sscom_shutdown(struct sscom_softc *);
236void sscomdiag(void *); 236void sscomdiag(void *);
237void sscomstart(struct tty *); 237void sscomstart(struct tty *);
238int sscomparam(struct tty *, struct termios *); 238int sscomparam(struct tty *, struct termios *);
239int sscomread(dev_t, struct uio *, int); 239int sscomread(dev_t, struct uio *, int);
240void sscom_config(struct sscom_softc *); 240void sscom_config(struct sscom_softc *);
241 241
242int sscomtxintr(void *); 242int sscomtxintr(void *);
243int sscomrxintr(void *); 243int sscomrxintr(void *);
244int sscomintr(void *); 244int sscomintr(void *);
245 245
246int sscom_cnattach(bus_space_tag_t, const struct sscom_uart_info *,  246int sscom_cnattach(bus_space_tag_t, bus_space_handle_t,
247 int, int, tcflag_t); 247 const struct sscom_uart_info *, int, int, tcflag_t);
248void sscom_cndetach(void); 248void sscom_cndetach(void);
249int sscom_is_console(bus_space_tag_t, int, bus_space_handle_t *); 249int sscom_is_console(bus_space_tag_t, int, bus_space_handle_t *);
250 250
251#ifdef KGDB 251#ifdef KGDB
252int sscom_kgdb_attach(bus_space_tag_t, const struct sscom_uart_info *, 252int sscom_kgdb_attach(bus_space_tag_t, bus_space_handle_t,
 253 const struct sscom_uart_info *,
253 int, int, tcflag_t); 254 int, int, tcflag_t);
254#endif 255#endif
255 256
256#endif /* _ARM_SAMSUNG_SSCOM_VAR_H */ 257#endif /* _ARM_SAMSUNG_SSCOM_VAR_H */
257 258