[MIPS] prom_free_prom_memory cleanup
[linux-2.6-block.git] / arch / mips / sni / sniprom.c
CommitLineData
4a0312fc
TB
1/*
2 * Big Endian PROM code for SNI RM machines
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) 2005-2006 Florian Lohoff (flo@rfc822.org)
9 * Copyright (C) 2005-2006 Thomas Bogendoerfer (tsbogend@alpha.franken.de)
10 */
11
12#include <linux/kernel.h>
13#include <linux/init.h>
14#include <linux/string.h>
15
16#include <asm/addrspace.h>
17#include <asm/sni.h>
18#include <asm/mipsprom.h>
19#include <asm/bootinfo.h>
20
21/* special SNI prom calls */
22/*
23 * This does not exist in all proms - SINIX compares
24 * the prom env variable "version" against "2.0008"
25 * or greater. If lesser it tries to probe interesting
26 * registers
27 */
28#define PROM_GET_MEMCONF 58
29
30#define PROM_VEC (u64 *)CKSEG1ADDR(0x1fc00000)
31#define PROM_ENTRY(x) (PROM_VEC + (x))
32
33
34#undef DEBUG
35#ifdef DEBUG
36#define DBG_PRINTF(x...) prom_printf(x)
37#else
38#define DBG_PRINTF(x...)
39#endif
40
41static int *(*__prom_putchar)(int) = (int *(*)(int))PROM_ENTRY(PROM_PUTCHAR);
42static char *(*__prom_getenv)(char *) = (char *(*)(char *))PROM_ENTRY(PROM_GETENV);
43static void (*__prom_get_memconf)(void *) = (void (*)(void *))PROM_ENTRY(PROM_GET_MEMCONF);
44
45char *prom_getenv (char *s)
46{
47 return __prom_getenv(s);
48}
49
50void prom_printf(char *fmt, ...)
51{
52 va_list args;
53 char ppbuf[1024];
54 char *bptr;
55
56 va_start(args, fmt);
57 vsprintf(ppbuf, fmt, args);
58
59 bptr = ppbuf;
60
61 while (*bptr != 0) {
62 if (*bptr == '\n')
63 __prom_putchar('\r');
64
65 __prom_putchar(*bptr++);
66 }
67 va_end(args);
68}
69
c44e8d5e 70void __init prom_free_prom_memory(void)
4a0312fc 71{
4a0312fc
TB
72}
73
74/*
75 * /proc/cpuinfo system type
76 *
77 */
78static const char *systype = "Unknown";
79const char *get_system_type(void)
80{
81 return systype;
82}
83
84#define SNI_IDPROM_BASE 0xbff00000
85#define SNI_IDPROM_MEMSIZE (SNI_IDPROM_BASE+0x28) /* Memsize in 16MB quantities */
86#define SNI_IDPROM_BRDTYPE (SNI_IDPROM_BASE+0x29) /* Board Type */
87#define SNI_IDPROM_CPUTYPE (SNI_IDPROM_BASE+0x30) /* CPU Type */
88
89#define SNI_IDPROM_SIZE 0x1000
90
91#ifdef DEBUG
92static void sni_idprom_dump(void)
93{
94 int i;
95
96 prom_printf("SNI IDProm dump (first 128byte):\n");
97 for(i=0;i<128;i++) {
98 if (i%16 == 0)
99 prom_printf("%04x ", i);
100
101 prom_printf("%02x ", *(unsigned char *) (SNI_IDPROM_BASE+i));
102
103 if (i%16 == 15)
104 prom_printf("\n");
105 }
106}
107#endif
108
109static void sni_mem_init(void )
110{
111 int i, memsize;
112 struct membank {
113 u32 size;
114 u32 base;
115 u32 size2;
116 u32 pad1;
117 u32 pad2;
118 } memconf[8];
119
120 /* MemSIZE from prom in 16MByte chunks */
121 memsize=*((unsigned char *) SNI_IDPROM_MEMSIZE) * 16;
122
123 DBG_PRINTF("IDProm memsize: %lu MByte\n", memsize);
124
125 /* get memory bank layout from prom */
126 __prom_get_memconf(&memconf);
127
128 DBG_PRINTF("prom_get_mem_conf memory configuration:\n");
129 for(i=0;i<8 && memconf[i].size;i++) {
130 prom_printf("Bank%d: %08x @ %08x\n", i,
131 memconf[i].size, memconf[i].base);
132 add_memory_region(memconf[i].base, memconf[i].size, BOOT_MEM_RAM);
133 }
134}
135
136void __init prom_init(void)
137{
138 int argc = fw_arg0;
139 char **argv = (void *)fw_arg1;
140 unsigned int sni_brd_type = *(unsigned char *) SNI_IDPROM_BRDTYPE;
141 int i;
142
143 DBG_PRINTF("Found SNI brdtype %02x\n", sni_brd_type);
144
145#ifdef DEBUG
146 sni_idprom_dump();
147#endif
148 sni_mem_init();
149
150 /* copy prom cmdline parameters to kernel cmdline */
151 for (i = 1; i < argc; i++) {
152 strcat(arcs_cmdline, argv[i]);
153 if (i < (argc - 1))
154 strcat(arcs_cmdline, " ");
155 }
156}
157