Sat Apr 19 19:47:55 2014 UTC ()
Use the conspeed and div/frac from the uart to figure out the frequency
for the console.   XXX until we actually compute from the chip clocks.


(matt)
diff -r1.7 -r1.8 src/sys/arch/evbarm/odroid/odroid_machdep.c

cvs diff -r1.7 -r1.8 src/sys/arch/evbarm/odroid/Attic/odroid_machdep.c (expand / switch to unified diff)

--- src/sys/arch/evbarm/odroid/Attic/odroid_machdep.c 2014/04/18 14:17:11 1.7
+++ src/sys/arch/evbarm/odroid/Attic/odroid_machdep.c 2014/04/19 19:47:55 1.8
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: odroid_machdep.c,v 1.7 2014/04/18 14:17:11 reinoud Exp $ */ 1/* $NetBSD: odroid_machdep.c,v 1.8 2014/04/19 19:47:55 matt Exp $ */
2 2
3/* 3/*
4 * Copyright (c) 2014 The NetBSD Foundation, Inc. 4 * Copyright (c) 2014 The NetBSD Foundation, Inc.
5 * All rights reserved. 5 * All rights reserved.
6 * 6 *
7 * This code is derived from software contributed to The NetBSD Foundation 7 * This code is derived from software contributed to The NetBSD Foundation
8 * by Reinoud Zandijk. 8 * by Reinoud Zandijk.
9 * 9 *
10 * Redistribution and use in source and binary forms, with or without 10 * Redistribution and use in source and binary forms, with or without
11 * modification, are permitted provided that the following conditions 11 * modification, are permitted provided that the following conditions
12 * are met: 12 * are met:
13 * 1. Redistributions of source code must retain the above copyright 13 * 1. Redistributions of source code must retain the above copyright
14 * notice, this list of conditions and the following disclaimer. 14 * notice, this list of conditions and the following disclaimer.
@@ -21,27 +21,27 @@ @@ -21,27 +21,27 @@
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS 22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
23 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 23 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
24 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 24 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
25 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 25 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
26 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 26 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
27 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 27 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
28 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 28 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
29 * POSSIBILITY OF SUCH DAMAGE. 29 * POSSIBILITY OF SUCH DAMAGE.
30 * 30 *
31 */ 31 */
32 32
33#include <sys/cdefs.h> 33#include <sys/cdefs.h>
34__KERNEL_RCSID(0, "$NetBSD: odroid_machdep.c,v 1.7 2014/04/18 14:17:11 reinoud Exp $"); 34__KERNEL_RCSID(0, "$NetBSD: odroid_machdep.c,v 1.8 2014/04/19 19:47:55 matt Exp $");
35 35
36#include "opt_evbarm_boardtype.h" 36#include "opt_evbarm_boardtype.h"
37#include "opt_exynos.h" 37#include "opt_exynos.h"
38#include "opt_machdep.h" 38#include "opt_machdep.h"
39#include "opt_ddb.h" 39#include "opt_ddb.h"
40#include "opt_kgdb.h" 40#include "opt_kgdb.h"
41#include "opt_ipkdb.h" 41#include "opt_ipkdb.h"
42#include "opt_md.h" 42#include "opt_md.h"
43#include "opt_sscom.h" 43#include "opt_sscom.h"
44#include "opt_arm_debug.h" 44#include "opt_arm_debug.h"
45 45
46#include "ukbd.h" 46#include "ukbd.h"
47#include "arml2cc.h" // RPZ why is it not called opt_l2cc.h? 47#include "arml2cc.h" // RPZ why is it not called opt_l2cc.h?
@@ -423,40 +423,53 @@ strcpy(tmp, "-v"); @@ -423,40 +423,53 @@ strcpy(tmp, "-v");
423} 423}
424 424
425 425
426void 426void
427consinit(void) 427consinit(void)
428{ 428{
429 static bool consinit_called; 429 static bool consinit_called;
430 430
431 if (consinit_called) 431 if (consinit_called)
432 return; 432 return;
433 consinit_called = true; 433 consinit_called = true;
434 434
435#if NSSCOM > 0 435#if NSSCOM > 0
 436 bus_space_tag_t bst = &exynos_bs_tag;
436 bus_addr_t iobase = armreg_tpidruro_read(); 437 bus_addr_t iobase = armreg_tpidruro_read();
437 size_t i; 438 bus_space_handle_t bsh = EXYNOS_IOPHYSTOVIRT(iobase);
 439 u_int i;
 440 /*
 441 * No need to guess at the UART frequency since we can caclulate it.
 442 */
 443 uint32_t freq = conspeed
 444 * (16 * (bus_space_read_4(bst, bsh, SSCOM_UBRDIV) + 1)
 445 + bus_space_read_4(bst, bsh, SSCOM_UFRACVAL));
 446 freq = (freq + conspeed / 2) / 1000;
 447 freq *= 1000;
438 448
439 for (i = 0; i < __arraycount(exynos_uarts); i++) { 449 for (i = 0; i < __arraycount(exynos_uarts); i++) {
440 /* attach console */ 450 /* attach console */
441 if (exynos_uarts[i].iobase + EXYNOS_CORE_PBASE == iobase) 451 if (exynos_uarts[i].iobase + EXYNOS_CORE_PBASE == iobase)
442 break; 452 break;
443 } 453 }
444 KASSERT(i < __arraycount(exynos_uarts)); 454 KASSERT(i < __arraycount(exynos_uarts));
445 455 printf("%s: attaching console @ %#"PRIxPTR" (%u HZ, %u bps)\n",
446 if (sscom_cnattach(&exynos_bs_tag, exynos_core_bsh, 456 __func__, iobase, freq, conspeed);
447 &exynos_uarts[i], conspeed, EXYNOS_UART_FREQ, 457 if (sscom_cnattach(bst, exynos_core_bsh, &exynos_uarts[i],
448 conmode)) 458 conspeed, freq, conmode))
449 panic("Serial console can not be initialized"); 459 panic("Serial console can not be initialized");
 460#ifdef VERBOSE_INIT_ARM
 461 printf("Console initialized\n");
 462#endif
450#else 463#else
451#error only serial console is supported 464#error only serial console is supported
452#if NUKBD > 0 465#if NUKBD > 0
453 /* allow USB keyboards to become console */ 466 /* allow USB keyboards to become console */
454 ukbd_cnattach(); 467 ukbd_cnattach();
455#endif /* NUKBD */ 468#endif /* NUKBD */
456#endif 469#endif
457} 470}
458 471
459void 472void
460odroid_device_register(device_t self, void *aux) 473odroid_device_register(device_t self, void *aux)
461{ 474{
462 prop_dictionary_t dict = device_properties(self); 475 prop_dictionary_t dict = device_properties(self);