#include <linux/serial_reg.h>
#include <linux/spinlock.h>
#include <linux/module.h>
+#include <linux/string.h>
#include <asm/io.h>
#include <asm/bootinfo.h>
#include <asm/mips-boards/prom.h>
+#include <asm/gdb-stub.h>
#include <asm/ar7/ar7.h>
/* I hate this. No. *I* *HATE* *THIS* */
static __initdata struct psp_chip_map psp_chip_map[] = {
{
- .chip = 0x5,
+ .chip = AR7_CHIP_7100,
.names = {
"dummy", "cpufrequency", "memsize",
"flashsize", "modetty0", "modetty1", "prompt",
},
},
{
- .chip = 0x18,
+ .chip = AR7_CHIP_7200,
.names = {
"dummy", "cpufrequency", "memsize",
"flashsize", "modetty0", "modetty1", "prompt",
},
},
{
- .chip = 0x2b,
+ .chip = AR7_CHIP_7300,
.names = {
"dummy", "cpufrequency", "memsize",
"flashsize", "modetty0", "modetty1", "prompt",
static struct env_var adam2_env[MAX_ENTRY] = { { 0, }, };
-char * __init prom_getenv(char *name)
+char * prom_getenv(char *name)
{
int i;
for (i = 0; (i < MAX_ENTRY) && adam2_env[i].name; i++)
char *src, *dest, *name, *value;
struct psp_env_var *vars = start;
- chip = get_chip_id();
+ chip = ar7_chip_id();
for (map = psp_chip_map; map->chip; map++)
if (map->chip == chip)
break;
}
}
+static void __init console_config(void)
+{
+#ifdef CONFIG_SERIAL_8250_CONSOLE
+ char console_string[40];
+ int baud = 0;
+ char parity = '\0', bits = '\0', flow = '\0';
+ char *s, *p;
+
+ if (strstr(prom_getcmdline(), "console="))
+ return;
+
+#ifdef CONFIG_KGDB
+ if (!strstr(prom_getcmdline(), "nokgdb"))
+ {
+ strcat(prom_getcmdline(), " console=kgdb");
+ kgdb_enabled = 1;
+ return;
+ }
+#endif
+
+ if ((s = prom_getenv("modetty0"))) {
+ baud = simple_strtoul(s, &p, 10);
+ s = p;
+ if (*s == ',') s++;
+ if (*s) parity = *s++;
+ if (*s == ',') s++;
+ if (*s) bits = *s++;
+ if (*s == ',') s++;
+ if (*s == 'h') flow = 'r';
+ }
+
+ if (baud == 0)
+ baud = 38400;
+ if (parity != 'n' && parity != 'o' && parity != 'e')
+ parity = 'n';
+ if (bits != '7' && bits != '8')
+ bits = '8';
+ if (flow == '\0')
+ flow = 'r';
+
+ sprintf(console_string, " console=ttyS0,%d%c%c%c", baud,
+ parity, bits, flow);
+ strcat(prom_getcmdline(), console_string);
+#endif
+}
+
void __init prom_init(void)
{
- prom_printf("\nLINUX running...\n");
ar7_init_cmdline(fw_arg0, (char **)fw_arg1);
ar7_init_env((struct env_var *)fw_arg2);
+ console_config();
}
#define PORT(offset) (KSEG1ADDR(AR7_REGS_UART0 + (offset * 4)))
int prom_putchar(char c)
{
- while ((serial_in(UART_LSR) & UART_LSR_THRE) == 0);
+ while ((serial_in(UART_LSR) & UART_LSR_TEMT) == 0);
serial_out(UART_TX, c);
return 1;
}
+// from adm5120/prom.c
+void prom_printf(char *fmt, ...)
+{
+ va_list args;
+ int l;
+ char *p, *buf_end;
+ char buf[1024];
+
+ va_start(args, fmt);
+ l = vsprintf(buf, fmt, args); /* hopefully i < sizeof(buf) */
+ va_end(args);
+
+ buf_end = buf + l;
+
+ for (p = buf; p < buf_end; p++) {
+ /* Crude cr/nl handling is better than none */
+ if (*p == '\n')
+ prom_putchar('\r');
+ prom_putchar(*p);
+ }
+}
+
+#ifdef CONFIG_KGDB
+int putDebugChar(char c)
+{
+ return prom_putchar(c);
+}
+
+char getDebugChar(void)
+{
+ return prom_getchar();
+}
+#endif
+
EXPORT_SYMBOL(prom_getenv);