Linux Audio

Check our new training course

Linux debugging, profiling, tracing and performance analysis training

Apr 14-17, 2025
Register
Loading...
v6.8
 1/*
 2 * IP32 basic setup
 3 *
 4 * This file is subject to the terms and conditions of the GNU General Public
 5 * License.  See the file "COPYING" in the main directory of this archive
 6 * for more details.
 7 *
 8 * Copyright (C) 2000 Harald Koerfgen
 9 * Copyright (C) 2002, 2003, 2005 Ilya A. Volynets
10 * Copyright (C) 2006 Ralf Baechle <ralf@linux-mips.org>
11 */
12#include <linux/console.h>
13#include <linux/init.h>
14#include <linux/interrupt.h>
 
15#include <linux/param.h>
16#include <linux/sched.h>
17
18#include <asm/bootinfo.h>
 
19#include <asm/mipsregs.h>
20#include <asm/mmu_context.h>
21#include <asm/sgialib.h>
22#include <asm/time.h>
23#include <asm/traps.h>
24#include <asm/io.h>
25#include <asm/ip32/crime.h>
26#include <asm/ip32/mace.h>
27#include <asm/ip32/ip32_ints.h>
28
29#include "ip32-common.h"
 
30
31#ifdef CONFIG_SGI_O2MACE_ETH
32/*
33 * This is taken care of in here 'cause they say using Arc later on is
34 * problematic
35 */
36extern char o2meth_eaddr[8];
37static inline unsigned char str2hexnum(unsigned char c)
38{
39	if (c >= '0' && c <= '9')
40		return c - '0';
41	if (c >= 'a' && c <= 'f')
42		return c - 'a' + 10;
43	return 0; /* foo */
44}
45
46static inline void str2eaddr(unsigned char *ea, unsigned char *str)
47{
48	int i;
49
50	for (i = 0; i < 6; i++) {
51		unsigned char num;
52
53		if(*str == ':')
54			str++;
55		num = str2hexnum(*str++) << 4;
56		num |= (str2hexnum(*str++));
57		ea[i] = num;
58	}
59}
60#endif
61
62/* An arbitrary time; this can be decreased if reliability looks good */
63#define WAIT_MS 10
64
65void __init plat_time_init(void)
66{
67	printk(KERN_INFO "Calibrating system timer... ");
68	write_c0_count(0);
69	crime->timer = 0;
70	while (crime->timer < CRIME_MASTER_FREQ * WAIT_MS / 1000) ;
71	mips_hpt_frequency = read_c0_count() * 1000 / WAIT_MS;
72	printk("%d MHz CPU detected\n", mips_hpt_frequency * 2 / 1000000);
73}
74
75void __init plat_mem_setup(void)
76{
77	board_be_init = ip32_be_init;
78
79#ifdef CONFIG_SGI_O2MACE_ETH
80	{
81		char *mac = ArcGetEnvironmentVariable("eaddr");
82		str2eaddr(o2meth_eaddr, mac);
83	}
84#endif
85
86#if defined(CONFIG_SERIAL_CORE_CONSOLE)
87	{
88		char* con = ArcGetEnvironmentVariable("console");
89		if (con && *con == 'd') {
90			static char options[8] __initdata;
91			char *baud = ArcGetEnvironmentVariable("dbaud");
92			if (baud)
93				strcpy(options, baud);
94			add_preferred_console("ttyS", *(con + 1) == '2' ? 1 : 0,
95					      baud ? options : NULL);
96		}
97	}
98#endif
99}
v4.17
  1/*
  2 * IP32 basic setup
  3 *
  4 * This file is subject to the terms and conditions of the GNU General Public
  5 * License.  See the file "COPYING" in the main directory of this archive
  6 * for more details.
  7 *
  8 * Copyright (C) 2000 Harald Koerfgen
  9 * Copyright (C) 2002, 2003, 2005 Ilya A. Volynets
 10 * Copyright (C) 2006 Ralf Baechle <ralf@linux-mips.org>
 11 */
 12#include <linux/console.h>
 13#include <linux/init.h>
 14#include <linux/interrupt.h>
 15#include <linux/mc146818rtc.h>
 16#include <linux/param.h>
 17#include <linux/sched.h>
 18
 19#include <asm/bootinfo.h>
 20#include <asm/mc146818-time.h>
 21#include <asm/mipsregs.h>
 22#include <asm/mmu_context.h>
 23#include <asm/sgialib.h>
 24#include <asm/time.h>
 25#include <asm/traps.h>
 26#include <asm/io.h>
 27#include <asm/ip32/crime.h>
 28#include <asm/ip32/mace.h>
 29#include <asm/ip32/ip32_ints.h>
 30
 31extern void ip32_be_init(void);
 32extern void crime_init(void);
 33
 34#ifdef CONFIG_SGI_O2MACE_ETH
 35/*
 36 * This is taken care of in here 'cause they say using Arc later on is
 37 * problematic
 38 */
 39extern char o2meth_eaddr[8];
 40static inline unsigned char str2hexnum(unsigned char c)
 41{
 42	if (c >= '0' && c <= '9')
 43		return c - '0';
 44	if (c >= 'a' && c <= 'f')
 45		return c - 'a' + 10;
 46	return 0; /* foo */
 47}
 48
 49static inline void str2eaddr(unsigned char *ea, unsigned char *str)
 50{
 51	int i;
 52
 53	for (i = 0; i < 6; i++) {
 54		unsigned char num;
 55
 56		if(*str == ':')
 57			str++;
 58		num = str2hexnum(*str++) << 4;
 59		num |= (str2hexnum(*str++));
 60		ea[i] = num;
 61	}
 62}
 63#endif
 64
 65/* An arbitrary time; this can be decreased if reliability looks good */
 66#define WAIT_MS 10
 67
 68void __init plat_time_init(void)
 69{
 70	printk(KERN_INFO "Calibrating system timer... ");
 71	write_c0_count(0);
 72	crime->timer = 0;
 73	while (crime->timer < CRIME_MASTER_FREQ * WAIT_MS / 1000) ;
 74	mips_hpt_frequency = read_c0_count() * 1000 / WAIT_MS;
 75	printk("%d MHz CPU detected\n", mips_hpt_frequency * 2 / 1000000);
 76}
 77
 78void __init plat_mem_setup(void)
 79{
 80	board_be_init = ip32_be_init;
 81
 82#ifdef CONFIG_SGI_O2MACE_ETH
 83	{
 84		char *mac = ArcGetEnvironmentVariable("eaddr");
 85		str2eaddr(o2meth_eaddr, mac);
 86	}
 87#endif
 88
 89#if defined(CONFIG_SERIAL_CORE_CONSOLE)
 90	{
 91		char* con = ArcGetEnvironmentVariable("console");
 92		if (con && *con == 'd') {
 93			static char options[8] __initdata;
 94			char *baud = ArcGetEnvironmentVariable("dbaud");
 95			if (baud)
 96				strcpy(options, baud);
 97			add_preferred_console("ttyS", *(con + 1) == '2' ? 1 : 0,
 98					      baud ? options : NULL);
 99		}
100	}
101#endif
102}