Mon Jun 17 04:37:39 2013 UTC ()
Don't hardcode beagle_putchar com values.


(matt)
diff -r1.45 -r1.46 src/sys/arch/evbarm/beagle/beagle_machdep.c

cvs diff -r1.45 -r1.46 src/sys/arch/evbarm/beagle/Attic/beagle_machdep.c (expand / switch to unified diff)

--- src/sys/arch/evbarm/beagle/Attic/beagle_machdep.c 2013/06/16 16:48:23 1.45
+++ src/sys/arch/evbarm/beagle/Attic/beagle_machdep.c 2013/06/17 04:37:39 1.46
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: beagle_machdep.c,v 1.45 2013/06/16 16:48:23 matt Exp $ */ 1/* $NetBSD: beagle_machdep.c,v 1.46 2013/06/17 04:37:39 matt Exp $ */
2 2
3/* 3/*
4 * Machine dependent functions for kernel setup for TI OSK5912 board. 4 * Machine dependent functions for kernel setup for TI OSK5912 board.
5 * Based on lubbock_machdep.c which in turn was based on iq80310_machhdep.c 5 * Based on lubbock_machdep.c which in turn was based on iq80310_machhdep.c
6 * 6 *
7 * Copyright (c) 2002, 2003, 2005 Genetec Corporation. All rights reserved. 7 * Copyright (c) 2002, 2003, 2005 Genetec Corporation. All rights reserved.
8 * Written by Hiroyuki Bessho for Genetec Corporation. 8 * Written by Hiroyuki Bessho for Genetec Corporation.
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.
@@ -115,27 +115,27 @@ @@ -115,27 +115,27 @@
115 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 115 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
116 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 116 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
117 * IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTERS BE LIABLE FOR ANY DIRECT, 117 * IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTERS BE LIABLE FOR ANY DIRECT,
118 * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 118 * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
119 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 119 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
120 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 120 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
121 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 121 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
122 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 122 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
123 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 123 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
124 * SUCH DAMAGE. 124 * SUCH DAMAGE.
125 */ 125 */
126 126
127#include <sys/cdefs.h> 127#include <sys/cdefs.h>
128__KERNEL_RCSID(0, "$NetBSD: beagle_machdep.c,v 1.45 2013/06/16 16:48:23 matt Exp $"); 128__KERNEL_RCSID(0, "$NetBSD: beagle_machdep.c,v 1.46 2013/06/17 04:37:39 matt Exp $");
129 129
130#include "opt_machdep.h" 130#include "opt_machdep.h"
131#include "opt_ddb.h" 131#include "opt_ddb.h"
132#include "opt_kgdb.h" 132#include "opt_kgdb.h"
133#include "opt_ipkdb.h" 133#include "opt_ipkdb.h"
134#include "opt_md.h" 134#include "opt_md.h"
135#include "opt_com.h" 135#include "opt_com.h"
136#include "opt_omap.h" 136#include "opt_omap.h"
137#include "prcm.h" 137#include "prcm.h"
138#include "com.h" 138#include "com.h"
139 139
140#include <sys/param.h> 140#include <sys/param.h>
141#include <sys/systm.h> 141#include <sys/systm.h>
@@ -160,26 +160,29 @@ __KERNEL_RCSID(0, "$NetBSD: beagle_machd @@ -160,26 +160,29 @@ __KERNEL_RCSID(0, "$NetBSD: beagle_machd
160#include <ddb/db_sym.h> 160#include <ddb/db_sym.h>
161#include <ddb/db_extern.h> 161#include <ddb/db_extern.h>
162#ifdef KGDB 162#ifdef KGDB
163#include <sys/kgdb.h> 163#include <sys/kgdb.h>
164#endif 164#endif
165 165
166#include <machine/bootconfig.h> 166#include <machine/bootconfig.h>
167#include <arm/armreg.h> 167#include <arm/armreg.h>
168#include <arm/undefined.h> 168#include <arm/undefined.h>
169 169
170#include <arm/arm32/machdep.h> 170#include <arm/arm32/machdep.h>
171#include <arm/mainbus/mainbus.h> 171#include <arm/mainbus/mainbus.h>
172 172
 173#include <dev/ic/ns16550reg.h>
 174#include <dev/ic/comreg.h>
 175
173#include <arm/omap/omap_com.h> 176#include <arm/omap/omap_com.h>
174#include <arm/omap/omap_var.h> 177#include <arm/omap/omap_var.h>
175#include <arm/omap/omap_wdtvar.h> 178#include <arm/omap/omap_wdtvar.h>
176#include <arm/omap/omap2_prcm.h> 179#include <arm/omap/omap2_prcm.h>
177#include <arm/omap/omap2_gpio.h> 180#include <arm/omap/omap2_gpio.h>
178#ifdef TI_AM335X 181#ifdef TI_AM335X
179# include <arm/omap/am335x_prcm.h> 182# include <arm/omap/am335x_prcm.h>
180#endif 183#endif
181 184
182#include <evbarm/include/autoconf.h> 185#include <evbarm/include/autoconf.h>
183#include <evbarm/beagle/beagle.h> 186#include <evbarm/beagle/beagle.h>
184 187
185#include <dev/i2c/i2cvar.h> 188#include <dev/i2c/i2cvar.h>
@@ -385,62 +388,66 @@ beagle_db_trap(int where) @@ -385,62 +388,66 @@ beagle_db_trap(int where)
385 oldwatchdogstate = omapwdt32k_enable(0); 388 oldwatchdogstate = omapwdt32k_enable(0);
386 } else { 389 } else {
387 omapwdt32k_enable(oldwatchdogstate); 390 omapwdt32k_enable(oldwatchdogstate);
388 } 391 }
389#endif 392#endif
390} 393}
391#endif 394#endif
392 395
393void beagle_putchar(char c); 396void beagle_putchar(char c);
394void 397void
395beagle_putchar(char c) 398beagle_putchar(char c)
396{ 399{
397#if NCOM > 0 400#if NCOM > 0
398 unsigned char *com0addr = (char *)CONSADDR_VA; 401 volatile uint32_t *com0addr = (volatile uint32_t *)CONSADDR_VA;
399 int timo = 150000; 402 int timo = 150000;
400 403
401 while ((com0addr[5 * 4] & 0x20) == 0) 404 while ((com0addr[com_lsr] & LSR_TXRDY) == 0) {
402 if (--timo == 0) 405 if (--timo == 0)
403 break; 406 break;
 407 }
404 408
405 com0addr[0] = c; 409 com0addr[com_data] = c;
406 410
407 while ((com0addr[5 * 4] & 0x20) == 0) 411 while ((com0addr[com_lsr] & LSR_TXRDY) == 0) {
408 if (--timo == 0) 412 if (--timo == 0)
409 break; 413 break;
 414 }
410#endif 415#endif
411} 416}
412 417
413/* 418/*
414 * u_int initarm(...) 419 * u_int initarm(...)
415 * 420 *
416 * Initial entry point on startup. This gets called before main() is 421 * Initial entry point on startup. This gets called before main() is
417 * entered. 422 * entered.
418 * It should be responsible for setting up everything that must be 423 * It should be responsible for setting up everything that must be
419 * in place when main is called. 424 * in place when main is called.
420 * This includes 425 * This includes
421 * Taking a copy of the boot configuration structure. 426 * Taking a copy of the boot configuration structure.
422 * Initialising the physical console so characters can be printed. 427 * Initialising the physical console so characters can be printed.
423 * Setting up page tables for the kernel 428 * Setting up page tables for the kernel
424 * Relocating the kernel to the bottom of physical memory 429 * Relocating the kernel to the bottom of physical memory
425 */ 430 */
426u_int 431u_int
427initarm(void *arg) 432initarm(void *arg)
428{ 433{
429 psize_t ram_size = 0; 434 psize_t ram_size = 0;
430 char *ptr; 435 char *ptr;
 436
431#if 1 437#if 1
432 beagle_putchar('d'); 438 beagle_putchar('d');
433#endif 439#endif
 440
434 /* 441 /*
435 * When we enter here, we are using a temporary first level 442 * When we enter here, we are using a temporary first level
436 * translation table with section entries in it to cover the OBIO 443 * translation table with section entries in it to cover the OBIO
437 * peripherals and SDRAM. The temporary first level translation table 444 * peripherals and SDRAM. The temporary first level translation table
438 * is at the end of SDRAM. 445 * is at the end of SDRAM.
439 */ 446 */
440#if defined(OMAP_3430) || defined(OMAP_3530) || defined(TI_DM37XX) 447#if defined(OMAP_3430) || defined(OMAP_3530) || defined(TI_DM37XX)
441 omap3_cpu_clk(); // find our CPU speed. 448 omap3_cpu_clk(); // find our CPU speed.
442#endif 449#endif
443#if defined(OMAP_4430) || defined(OMAP_5430) 450#if defined(OMAP_4430) || defined(OMAP_5430)
444 omap4_cpu_clk(); // find our CPU speed. 451 omap4_cpu_clk(); // find our CPU speed.
445#endif 452#endif
446#if defined(TI_AM335X) 453#if defined(TI_AM335X)
@@ -766,27 +773,28 @@ emif_memprobe(void) @@ -766,27 +773,28 @@ emif_memprobe(void)
766#if defined(TI_AM335X) 773#if defined(TI_AM335X)
767 /* 774 /*
768 * The original bbone's u-boot misprograms the EMIF so correct it 775 * The original bbone's u-boot misprograms the EMIF so correct it
769 * if we detect if it has the wrong value. 776 * if we detect if it has the wrong value.
770 */ 777 */
771 if (sdram_config == 0x41805332) 778 if (sdram_config == 0x41805332)
772 sdram_config -= __SHIFTIN(1, SDRAM_CONFIG_RSIZE); 779 sdram_config -= __SHIFTIN(1, SDRAM_CONFIG_RSIZE);
773#endif 780#endif
774#ifdef OMAP_EMIF2_VBASE 781#ifdef OMAP_EMIF2_VBASE
775 /* 782 /*
776 * OMAP4 and OMAP5 have two EMIFs so if the 2nd one is configured 783 * OMAP4 and OMAP5 have two EMIFs so if the 2nd one is configured
777 * like the first, we have twice the memory. 784 * like the first, we have twice the memory.
778 */ 785 */
779 if (emif_read_sdram_config(OMAP_EMIF2_VBASE) == sdram_config) 786 const uint32_t sdram_config2 = emif_read_sdram_config(OMAP_EMIF2_VBASE);
 787 if (sdram_config2 == sdram_config)
780 memsize <<= 1; 788 memsize <<= 1;
781#endif 789#endif
782 790
783 const u_int ebank = __SHIFTOUT(sdram_config, SDRAM_CONFIG_EBANK); 791 const u_int ebank = __SHIFTOUT(sdram_config, SDRAM_CONFIG_EBANK);
784 const u_int ibank = __SHIFTOUT(sdram_config, SDRAM_CONFIG_IBANK); 792 const u_int ibank = __SHIFTOUT(sdram_config, SDRAM_CONFIG_IBANK);
785 const u_int rsize = 9 + __SHIFTOUT(sdram_config, SDRAM_CONFIG_RSIZE); 793 const u_int rsize = 9 + __SHIFTOUT(sdram_config, SDRAM_CONFIG_RSIZE);
786 const u_int pagesize = 8 + __SHIFTOUT(sdram_config, SDRAM_CONFIG_PAGESIZE); 794 const u_int pagesize = 8 + __SHIFTOUT(sdram_config, SDRAM_CONFIG_PAGESIZE);
787 const u_int width = 2 - __SHIFTOUT(sdram_config, SDRAM_CONFIG_WIDTH); 795 const u_int width = 2 - __SHIFTOUT(sdram_config, SDRAM_CONFIG_WIDTH);
788#ifdef TI_AM335X 796#ifdef TI_AM335X
789 KASSERT(ebank == 0); // No chip selects on Sitara 797 KASSERT(ebank == 0); // No chip selects on Sitara
790#endif 798#endif
791 memsize <<= (ebank + ibank + rsize + pagesize + width); 799 memsize <<= (ebank + ibank + rsize + pagesize + width);
792#ifdef VERBOSE_INIT_ARM 800#ifdef VERBOSE_INIT_ARM