1178173Simp/*-
2195162Simp * Copyright (c) 2006-2008 Bruce M. Simpson
3178173Simp * All rights reserved.
4178173Simp *
5178173Simp * Redistribution and use in source and binary forms, with or without
6178173Simp * modification, are permitted provided that the following conditions
7178173Simp * are met:
8178173Simp * 1. Redistributions of source code must retain the above copyright
9178173Simp *    notice, this list of conditions, and the following disclaimer,
10178173Simp *    without modification, immediately at the beginning of the file.
11178173Simp * 2. The name of the author may not be used to endorse or promote products
12178173Simp *    derived from this software without specific prior written permission.
13178173Simp *
14178173Simp * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
15178173Simp * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
16178173Simp * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
17178173Simp * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE FOR
18178173Simp * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
19178173Simp * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
20178173Simp * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
21178173Simp * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
22178173Simp * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
23178173Simp * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
24178173Simp * SUCH DAMAGE.
25178173Simp *
26178173Simp */
27178173Simp
28178173Simp#include <sys/cdefs.h>
29178173Simp__FBSDID("$FreeBSD$");
30178173Simp
31178173Simp#include <sys/param.h>
32178173Simp#include <sys/systm.h>
33178173Simp
34182901Sgonzo#include <mips/malta/yamon.h>
35178173Simp
36178173Simpchar *
37178173Simpyamon_getenv(char *name)
38178173Simp{
39178173Simp	char *value;
40178173Simp	yamon_env_t *p;
41178173Simp
42178173Simp	value = NULL;
43178173Simp	for (p = *fenvp; p->name != NULL; ++p) {
44178173Simp	    if (!strcmp(name, p->name)) {
45178173Simp		value = p->value;
46178173Simp		break;
47178173Simp	    }
48178173Simp	}
49178173Simp
50178173Simp	return (value);
51178173Simp}
52178173Simp
53178173Simpuint32_t
54178173Simpyamon_getcpufreq(void)
55178173Simp{
56178173Simp	uint32_t freq;
57178173Simp	int ret;
58178173Simp
59254944Sgonzo	freq = 0;
60178173Simp	ret = YAMON_SYSCON_READ(SYSCON_BOARD_CPU_CLOCK_FREQ_ID, &freq,
61178173Simp	    sizeof(freq));
62178173Simp	if (ret != 0)
63178173Simp		freq = 0;
64178173Simp
65178173Simp	return (freq);
66178173Simp}
67