Home | History | Annotate | Line # | Download | only in sh3
      1 /*	$NetBSD: cpu.c,v 1.14 2009/04/05 00:04:51 uwe Exp $	*/
      2 
      3 /*-
      4  * Copyright (c) 2002 The NetBSD Foundation, Inc.
      5  * All rights reserved.
      6  *
      7  * Redistribution and use in source and binary forms, with or without
      8  * modification, are permitted provided that the following conditions
      9  * are met:
     10  * 1. Redistributions of source code must retain the above copyright
     11  *    notice, this list of conditions and the following disclaimer.
     12  * 2. Redistributions in binary form must reproduce the above copyright
     13  *    notice, this list of conditions and the following disclaimer in the
     14  *    documentation and/or other materials provided with the distribution.
     15  *
     16  * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
     17  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
     18  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
     19  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
     20  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
     21  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
     22  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
     23  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
     24  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
     25  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
     26  * POSSIBILITY OF SUCH DAMAGE.
     27  */
     28 
     29 #include <sys/cdefs.h>
     30 __KERNEL_RCSID(0, "$NetBSD: cpu.c,v 1.14 2009/04/05 00:04:51 uwe Exp $");
     31 
     32 #include <sys/param.h>
     33 #include <sys/systm.h>
     34 #include <sys/device.h>
     35 #include <sys/proc.h>
     36 
     37 #include <sh3/clock.h>
     38 #include <sh3/cache.h>
     39 #include <sh3/mmu.h>
     40 
     41 #include <machine/autoconf.h>
     42 
     43 extern struct cfdriver cpu_cd;
     44 
     45 static int cpu_match(device_t, struct cfdata *, void *);
     46 static void cpu_attach(device_t, device_t, void *);
     47 
     48 
     49 CFATTACH_DECL_NEW(cpu, 0,
     50     cpu_match, cpu_attach, NULL, NULL);
     51 
     52 
     53 static int
     54 cpu_match(device_t parent, struct cfdata *cf, void *aux)
     55 {
     56 	struct mainbus_attach_args *ma = aux;
     57 
     58 	if (strcmp(ma->ma_name, cpu_cd.cd_name) != 0)
     59 		return (0);
     60 
     61 	return (1);
     62 }
     63 
     64 static void
     65 cpu_attach(device_t parent, device_t self, void *aux)
     66 {
     67 
     68 #define	MHZ(x) ((x) / 1000000), (((x) % 1000000) / 1000)
     69 
     70 	aprint_naive("\n");
     71 	aprint_normal(": SH%d %d.%02d MHz PCLOCK %d.%02d MHz\n",
     72 	       CPU_IS_SH3 ? 3 : 4,
     73 	       MHZ(sh_clock_get_cpuclock()),
     74 	       MHZ(sh_clock_get_pclock()));
     75 
     76 #undef MHZ
     77 
     78 	sh_cache_information();
     79 	sh_mmu_information();
     80 
     81 	if (!pmf_device_register(self, NULL, NULL))
     82 		aprint_error_dev(self, "unable to establish power handler\n");
     83 }
     84