Linux Audio

Check our new training course

Loading...
v3.15
  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#include <linux/console.h>
 16
 17#include <asm/addrspace.h>
 18#include <asm/sni.h>
 19#include <asm/mipsprom.h>
 20#include <asm/mipsregs.h>
 21#include <asm/bootinfo.h>
 
 22
 23/* special SNI prom calls */
 24/*
 25 * This does not exist in all proms - SINIX compares
 26 * the prom env variable "version" against "2.0008"
 27 * or greater. If lesser it tries to probe interesting
 28 * registers
 29 */
 30#define PROM_GET_MEMCONF	58
 31#define PROM_GET_HWCONF		61
 32
 33#define PROM_VEC		(u64 *)CKSEG1ADDR(0x1fc00000)
 34#define PROM_ENTRY(x)		(PROM_VEC + (x))
 35
 36#define ___prom_putchar		((int *(*)(int))PROM_ENTRY(PROM_PUTCHAR))
 37#define ___prom_getenv		((char *(*)(char *))PROM_ENTRY(PROM_GETENV))
 38#define ___prom_get_memconf	((void (*)(void *))PROM_ENTRY(PROM_GET_MEMCONF))
 39#define ___prom_get_hwconf	((u32 (*)(void))PROM_ENTRY(PROM_GET_HWCONF))
 40
 41#ifdef CONFIG_64BIT
 42
 43/* O32 stack has to be 8-byte aligned. */
 44static u64 o32_stk[4096];
 45#define O32_STK	  &o32_stk[sizeof(o32_stk)]
 46
 47#define __PROM_O32(fun, arg) fun arg __asm__(#fun); \
 48				     __asm__(#fun " = call_o32")
 49
 50int   __PROM_O32(__prom_putchar, (int *(*)(int), void *, int));
 51char *__PROM_O32(__prom_getenv, (char *(*)(char *), void *, char *));
 52void  __PROM_O32(__prom_get_memconf, (void (*)(void *), void *, void *));
 53u32   __PROM_O32(__prom_get_hwconf, (u32 (*)(void), void *));
 54
 55#define _prom_putchar(x)     __prom_putchar(___prom_putchar, O32_STK, x)
 56#define _prom_getenv(x)	     __prom_getenv(___prom_getenv, O32_STK, x)
 57#define _prom_get_memconf(x) __prom_get_memconf(___prom_get_memconf, O32_STK, x)
 58#define _prom_get_hwconf()   __prom_get_hwconf(___prom_get_hwconf, O32_STK)
 59
 60#else
 61#define _prom_putchar(x)     ___prom_putchar(x)
 62#define _prom_getenv(x)	     ___prom_getenv(x)
 63#define _prom_get_memconf(x) ___prom_get_memconf(x)
 64#define _prom_get_hwconf(x)  ___prom_get_hwconf(x)
 65#endif
 66
 67void prom_putchar(char c)
 68{
 69	_prom_putchar(c);
 70}
 71
 72
 73char *prom_getenv(char *s)
 74{
 75	return _prom_getenv(s);
 76}
 77
 78void *prom_get_hwconf(void)
 79{
 80	u32 hwconf = _prom_get_hwconf();
 81
 82	if (hwconf == 0xffffffff)
 83		return NULL;
 84
 85	return (void *)CKSEG1ADDR(hwconf);
 86}
 87
 88void __init prom_free_prom_memory(void)
 89{
 90}
 91
 92/*
 93 * /proc/cpuinfo system type
 94 *
 95 */
 96char *system_type = "Unknown";
 97const char *get_system_type(void)
 98{
 99	return system_type;
100}
101
102static void __init sni_mem_init(void)
103{
104	int i, memsize;
105	struct membank {
106		u32		size;
107		u32		base;
108		u32		size2;
109		u32		pad1;
110		u32		pad2;
111	} memconf[8];
112	int brd_type = *(unsigned char *)SNI_IDPROM_BRDTYPE;
113
114
115	/* MemSIZE from prom in 16MByte chunks */
116	memsize = *((unsigned char *) SNI_IDPROM_MEMSIZE) * 16;
117
118	pr_debug("IDProm memsize: %u MByte\n", memsize);
119
120	/* get memory bank layout from prom */
121	_prom_get_memconf(&memconf);
122
123	pr_debug("prom_get_mem_conf memory configuration:\n");
124	for (i = 0; i < 8 && memconf[i].size; i++) {
125		if (brd_type == SNI_BRD_PCI_TOWER ||
126		    brd_type == SNI_BRD_PCI_TOWER_CPLUS) {
127			if (memconf[i].base >= 0x20000000 &&
128			    memconf[i].base <  0x30000000)
129				memconf[i].base -= 0x20000000;
130		}
131		pr_debug("Bank%d: %08x @ %08x\n", i,
132			memconf[i].size, memconf[i].base);
133		add_memory_region(memconf[i].base, memconf[i].size,
134				  BOOT_MEM_RAM);
135	}
136}
137
138void __init prom_init(void)
139{
140	int argc = fw_arg0;
141	u32 *argv = (u32 *)CKSEG0ADDR(fw_arg1);
142	int i;
143
144	sni_mem_init();
145
146	/* copy prom cmdline parameters to kernel cmdline */
147	for (i = 1; i < argc; i++) {
148		strcat(arcs_cmdline, (char *)CKSEG0ADDR(argv[i]));
149		if (i < (argc - 1))
150			strcat(arcs_cmdline, " ");
151	}
152}
v5.14.15
  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/memblock.h>
 15#include <linux/string.h>
 16#include <linux/console.h>
 17
 18#include <asm/addrspace.h>
 19#include <asm/sni.h>
 20#include <asm/mipsprom.h>
 21#include <asm/mipsregs.h>
 22#include <asm/bootinfo.h>
 23#include <asm/setup.h>
 24
 25/* special SNI prom calls */
 26/*
 27 * This does not exist in all proms - SINIX compares
 28 * the prom env variable "version" against "2.0008"
 29 * or greater. If lesser it tries to probe interesting
 30 * registers
 31 */
 32#define PROM_GET_MEMCONF	58
 33#define PROM_GET_HWCONF		61
 34
 35#define PROM_VEC		(u64 *)CKSEG1ADDR(0x1fc00000)
 36#define PROM_ENTRY(x)		(PROM_VEC + (x))
 37
 38#define ___prom_putchar		((int *(*)(int))PROM_ENTRY(PROM_PUTCHAR))
 39#define ___prom_getenv		((char *(*)(char *))PROM_ENTRY(PROM_GETENV))
 40#define ___prom_get_memconf	((void (*)(void *))PROM_ENTRY(PROM_GET_MEMCONF))
 41#define ___prom_get_hwconf	((u32 (*)(void))PROM_ENTRY(PROM_GET_HWCONF))
 42
 43#ifdef CONFIG_64BIT
 44
 45/* O32 stack has to be 8-byte aligned. */
 46static u64 o32_stk[4096];
 47#define O32_STK	  (&o32_stk[ARRAY_SIZE(o32_stk)])
 48
 49#define __PROM_O32(fun, arg) fun arg __asm__(#fun); \
 50				     __asm__(#fun " = call_o32")
 51
 52int   __PROM_O32(__prom_putchar, (int *(*)(int), void *, int));
 53char *__PROM_O32(__prom_getenv, (char *(*)(char *), void *, char *));
 54void  __PROM_O32(__prom_get_memconf, (void (*)(void *), void *, void *));
 55u32   __PROM_O32(__prom_get_hwconf, (u32 (*)(void), void *));
 56
 57#define _prom_putchar(x)     __prom_putchar(___prom_putchar, O32_STK, x)
 58#define _prom_getenv(x)	     __prom_getenv(___prom_getenv, O32_STK, x)
 59#define _prom_get_memconf(x) __prom_get_memconf(___prom_get_memconf, O32_STK, x)
 60#define _prom_get_hwconf()   __prom_get_hwconf(___prom_get_hwconf, O32_STK)
 61
 62#else
 63#define _prom_putchar(x)     ___prom_putchar(x)
 64#define _prom_getenv(x)	     ___prom_getenv(x)
 65#define _prom_get_memconf(x) ___prom_get_memconf(x)
 66#define _prom_get_hwconf(x)  ___prom_get_hwconf(x)
 67#endif
 68
 69void prom_putchar(char c)
 70{
 71	_prom_putchar(c);
 72}
 73
 74
 75char *prom_getenv(char *s)
 76{
 77	return _prom_getenv(s);
 78}
 79
 80void *prom_get_hwconf(void)
 81{
 82	u32 hwconf = _prom_get_hwconf();
 83
 84	if (hwconf == 0xffffffff)
 85		return NULL;
 86
 87	return (void *)CKSEG1ADDR(hwconf);
 88}
 89
 
 
 
 
 90/*
 91 * /proc/cpuinfo system type
 92 *
 93 */
 94char *system_type = "Unknown";
 95const char *get_system_type(void)
 96{
 97	return system_type;
 98}
 99
100static void __init sni_mem_init(void)
101{
102	int i, memsize;
103	struct membank {
104		u32		size;
105		u32		base;
106		u32		size2;
107		u32		pad1;
108		u32		pad2;
109	} memconf[8];
110	int brd_type = *(unsigned char *)SNI_IDPROM_BRDTYPE;
111
112
113	/* MemSIZE from prom in 16MByte chunks */
114	memsize = *((unsigned char *) SNI_IDPROM_MEMSIZE) * 16;
115
116	pr_debug("IDProm memsize: %u MByte\n", memsize);
117
118	/* get memory bank layout from prom */
119	_prom_get_memconf(&memconf);
120
121	pr_debug("prom_get_mem_conf memory configuration:\n");
122	for (i = 0; i < 8 && memconf[i].size; i++) {
123		if (brd_type == SNI_BRD_PCI_TOWER ||
124		    brd_type == SNI_BRD_PCI_TOWER_CPLUS) {
125			if (memconf[i].base >= 0x20000000 &&
126			    memconf[i].base <  0x30000000)
127				memconf[i].base -= 0x20000000;
128		}
129		pr_debug("Bank%d: %08x @ %08x\n", i,
130			memconf[i].size, memconf[i].base);
131		memblock_add(memconf[i].base, memconf[i].size);
 
132	}
133}
134
135void __init prom_init(void)
136{
137	int argc = fw_arg0;
138	u32 *argv = (u32 *)CKSEG0ADDR(fw_arg1);
139	int i;
140
141	sni_mem_init();
142
143	/* copy prom cmdline parameters to kernel cmdline */
144	for (i = 1; i < argc; i++) {
145		strcat(arcs_cmdline, (char *)CKSEG0ADDR(argv[i]));
146		if (i < (argc - 1))
147			strcat(arcs_cmdline, " ");
148	}
149}