Fri Jan 2 22:00:02 2015 UTC ()
init cpufreq, remove cpu.frequency boot arg support


(jmcneill)
diff -r1.13 -r1.14 src/sys/arch/evbarm/rockchip/rockchip_machdep.c

cvs diff -r1.13 -r1.14 src/sys/arch/evbarm/rockchip/Attic/rockchip_machdep.c (expand / switch to unified diff)

--- src/sys/arch/evbarm/rockchip/Attic/rockchip_machdep.c 2015/01/02 00:50:56 1.13
+++ src/sys/arch/evbarm/rockchip/Attic/rockchip_machdep.c 2015/01/02 22:00:02 1.14
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: rockchip_machdep.c,v 1.13 2015/01/02 00:50:56 jmcneill Exp $ */ 1/* $NetBSD: rockchip_machdep.c,v 1.14 2015/01/02 22:00:02 jmcneill 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: rockchip_machdep.c,v 1.13 2015/01/02 00:50:56 jmcneill Exp $"); 128__KERNEL_RCSID(0, "$NetBSD: rockchip_machdep.c,v 1.14 2015/01/02 22:00:02 jmcneill 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_rockchip.h" 136#include "opt_rockchip.h"
137#include "opt_arm_debug.h" 137#include "opt_arm_debug.h"
138 138
139#include "com.h" 139#include "com.h"
140#if 0 140#if 0
141#include "prcm.h" 141#include "prcm.h"
@@ -458,27 +458,26 @@ rockchip_parse_atag(u_int atag_base) @@ -458,27 +458,26 @@ rockchip_parse_atag(u_int atag_base)
458 * It should be responsible for setting up everything that must be 458 * It should be responsible for setting up everything that must be
459 * in place when main is called. 459 * in place when main is called.
460 * This includes 460 * This includes
461 * Taking a copy of the boot configuration structure. 461 * Taking a copy of the boot configuration structure.
462 * Initialising the physical console so characters can be printed. 462 * Initialising the physical console so characters can be printed.
463 * Setting up page tables for the kernel 463 * Setting up page tables for the kernel
464 * Relocating the kernel to the bottom of physical memory 464 * Relocating the kernel to the bottom of physical memory
465 */ 465 */
466u_int 466u_int
467initarm(void *arg) 467initarm(void *arg)
468{ 468{
469 psize_t ram_size = 0; 469 psize_t ram_size = 0;
470 char *ptr; 470 char *ptr;
471 u_int cpufreq; 
472 *(volatile int *)CONSADDR_VA = 0x40; /* output '@' */ 471 *(volatile int *)CONSADDR_VA = 0x40; /* output '@' */
473#if 1 472#if 1
474 rockchip_putchar('d'); 473 rockchip_putchar('d');
475#endif 474#endif
476 475
477 pmap_devmap_register(devmap); 476 pmap_devmap_register(devmap);
478 rockchip_bootstrap(); 477 rockchip_bootstrap();
479 478
480#ifdef MULTIPROCESSOR 479#ifdef MULTIPROCESSOR
481 uint32_t scu_cfg = bus_space_read_4(&rockchip_bs_tag, 480 uint32_t scu_cfg = bus_space_read_4(&rockchip_bs_tag,
482 rockchip_core0_bsh, ROCKCHIP_SCU_OFFSET + SCU_CFG); 481 rockchip_core0_bsh, ROCKCHIP_SCU_OFFSET + SCU_CFG);
483 arm_cpu_max = (scu_cfg & SCU_CFG_CPUMAX) + 1; 482 arm_cpu_max = (scu_cfg & SCU_CFG_CPUMAX) + 1;
484 membar_producer(); 483 membar_producer();
@@ -590,31 +589,26 @@ initarm(void *arg) @@ -590,31 +589,26 @@ initarm(void *arg)
590 boot_args = bootargs; 589 boot_args = bootargs;
591 parse_mi_bootargs(boot_args); 590 parse_mi_bootargs(boot_args);
592 591
593 /* we've a specific device_register routine */ 592 /* we've a specific device_register routine */
594 evbarm_device_register = rockchip_device_register; 593 evbarm_device_register = rockchip_device_register;
595 594
596 db_trap_callback = rockchip_db_trap; 595 db_trap_callback = rockchip_db_trap;
597 596
598 if (get_bootconf_option(boot_args, "console", 597 if (get_bootconf_option(boot_args, "console",
599 BOOTOPT_TYPE_STRING, &ptr) && strncmp(ptr, "fb", 2) == 0) { 598 BOOTOPT_TYPE_STRING, &ptr) && strncmp(ptr, "fb", 2) == 0) {
600 use_fb_console = true; 599 use_fb_console = true;
601 } 600 }
602 601
603 if (get_bootconf_option(boot_args, "cpu.frequency", 
604 BOOTOPT_TYPE_INT, &cpufreq)) { 
605 rockchip_apll_set_rate(cpufreq * 1000000); 
606 } 
607 
608 curcpu()->ci_data.cpu_cc_freq = rockchip_cpu_get_rate(); 602 curcpu()->ci_data.cpu_cc_freq = rockchip_cpu_get_rate();
609 603
610 return initarm_common(KERNEL_VM_BASE, KERNEL_VM_SIZE, NULL, 0); 604 return initarm_common(KERNEL_VM_BASE, KERNEL_VM_SIZE, NULL, 0);
611 605
612} 606}
613 607
614static void 608static void
615init_clocks(void) 609init_clocks(void)
616{ 610{
617 /* NOT YET */ 611 /* NOT YET */
618} 612}
619 613
620#if NCOM > 0 614#if NCOM > 0
@@ -726,26 +720,30 @@ rockchip_device_register(device_t self,  @@ -726,26 +720,30 @@ rockchip_device_register(device_t self,
726 if (device_is_a(self, "armperiph") 720 if (device_is_a(self, "armperiph")
727 && device_is_a(device_parent(self), "mainbus")) { 721 && device_is_a(device_parent(self), "mainbus")) {
728 /* 722 /*
729 * XXX KLUDGE ALERT XXX 723 * XXX KLUDGE ALERT XXX
730 * The iot mainbus supplies is completely wrong since it scales 724 * The iot mainbus supplies is completely wrong since it scales
731 * addresses by 2. The simpliest remedy is to replace with our 725 * addresses by 2. The simpliest remedy is to replace with our
732 * bus space used for the armcore regisers (which armperiph uses).  726 * bus space used for the armcore regisers (which armperiph uses).
733 */ 727 */
734 struct mainbus_attach_args * const mb = aux; 728 struct mainbus_attach_args * const mb = aux;
735 mb->mb_iot = &rockchip_bs_tag; 729 mb->mb_iot = &rockchip_bs_tag;
736 return; 730 return;
737 } 731 }
738 732
 733 if (device_is_a(self, "cpu") && device_unit(self) == 0) {
 734 rockchip_cpufreq_init();
 735 }
 736
739#ifdef CPU_CORTEXA9  737#ifdef CPU_CORTEXA9
740 /* 738 /*
741 * We need to tell the A9 Global/Watchdog Timer 739 * We need to tell the A9 Global/Watchdog Timer
742 * what frequency it runs at. 740 * what frequency it runs at.
743 */ 741 */
744 if (device_is_a(self, "a9tmr") || device_is_a(self, "a9wdt")) { 742 if (device_is_a(self, "a9tmr") || device_is_a(self, "a9wdt")) {
745 prop_dictionary_set_uint32(dict, "frequency", 743 prop_dictionary_set_uint32(dict, "frequency",
746 rockchip_a9periph_get_rate()); 744 rockchip_a9periph_get_rate());
747 745
748 return; 746 return;
749 } 747 }
750 748
751 if (device_is_a(self, "arml2cc")) { 749 if (device_is_a(self, "arml2cc")) {