^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1) // SPDX-License-Identifier: GPL-2.0-only
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3) * Carsten Langgaard, carstenl@mips.com
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4) * Copyright (C) 1999,2000 MIPS Technologies, Inc. All rights reserved.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6) * Putting things on the screen/serial line using YAMONs facilities.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8) #include <linux/init.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9) #include <linux/kernel.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10) #include <linux/serial_reg.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11) #include <linux/spinlock.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 12) #include <linux/export.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 13) #include <linux/string.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 14) #include <linux/io.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 15) #include <asm/bootinfo.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 16) #include <asm/setup.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 17)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 18) #include <asm/mach-ar7/ar7.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 19) #include <asm/mach-ar7/prom.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 20)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 21) #define MAX_ENTRY 80
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 22)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 23) struct env_var {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 24) char *name;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 25) char *value;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 26) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 27)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 28) static struct env_var adam2_env[MAX_ENTRY];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 29)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 30) char *prom_getenv(const char *name)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 31) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 32) int i;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 33)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 34) for (i = 0; (i < MAX_ENTRY) && adam2_env[i].name; i++)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 35) if (!strcmp(name, adam2_env[i].name))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 36) return adam2_env[i].value;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 37)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 38) return NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 39) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 40) EXPORT_SYMBOL(prom_getenv);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 41)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 42) static void __init ar7_init_cmdline(int argc, char *argv[])
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 43) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 44) int i;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 45)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 46) for (i = 1; i < argc; i++) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 47) strlcat(arcs_cmdline, argv[i], COMMAND_LINE_SIZE);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 48) if (i < (argc - 1))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 49) strlcat(arcs_cmdline, " ", COMMAND_LINE_SIZE);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 50) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 51) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 52)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 53) struct psbl_rec {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 54) u32 psbl_size;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 55) u32 env_base;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 56) u32 env_size;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 57) u32 ffs_base;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 58) u32 ffs_size;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 59) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 60)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 61) static const char psp_env_version[] __initconst = "TIENV0.8";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 62)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 63) struct psp_env_chunk {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 64) u8 num;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 65) u8 ctrl;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 66) u16 csum;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 67) u8 len;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 68) char data[11];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 69) } __packed;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 70)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 71) struct psp_var_map_entry {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 72) u8 num;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 73) char *value;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 74) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 75)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 76) static const struct psp_var_map_entry psp_var_map[] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 77) { 1, "cpufrequency" },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 78) { 2, "memsize" },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 79) { 3, "flashsize" },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 80) { 4, "modetty0" },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 81) { 5, "modetty1" },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 82) { 8, "maca" },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 83) { 9, "macb" },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 84) { 28, "sysfrequency" },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 85) { 38, "mipsfrequency" },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 86) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 87)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 88) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 89)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 90) Well-known variable (num is looked up in table above for matching variable name)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 91) Example: cpufrequency=211968000
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 92) +----+----+----+----+----+----+----+----+----+----+----+----+----+----+----+---
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 93) | 01 |CTRL|CHECKSUM | 01 | _2 | _1 | _1 | _9 | _6 | _8 | _0 | _0 | _0 | \0 | FF
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 94) +----+----+----+----+----+----+----+----+----+----+----+----+----+----+----+---
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 95)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 96) Name=Value pair in a single chunk
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 97) Example: NAME=VALUE
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 98) +----+----+----+----+----+----+----+----+----+----+----+----+----+----+----+---
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 99) | 00 |CTRL|CHECKSUM | 01 | _N | _A | _M | _E | _0 | _V | _A | _L | _U | _E | \0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 100) +----+----+----+----+----+----+----+----+----+----+----+----+----+----+----+---
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 101)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 102) Name=Value pair in 2 chunks (len is the number of chunks)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 103) Example: bootloaderVersion=1.3.7.15
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 104) +----+----+----+----+----+----+----+----+----+----+----+----+----+----+----+---
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 105) | 00 |CTRL|CHECKSUM | 02 | _b | _o | _o | _t | _l | _o | _a | _d | _e | _r | _V
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 106) +----+----+----+----+----+----+----+----+----+----+----+----+----+----+----+---
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 107) | _e | _r | _s | _i | _o | _n | \0 | _1 | _. | _3 | _. | _7 | _. | _1 | _5 | \0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 108) +----+----+----+----+----+----+----+----+----+----+----+----+----+----+----+---
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 109)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 110) Data is padded with 0xFF
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 111)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 112) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 113)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 114) #define PSP_ENV_SIZE 4096
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 115)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 116) static char psp_env_data[PSP_ENV_SIZE] = { 0, };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 117)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 118) static char * __init lookup_psp_var_map(u8 num)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 119) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 120) int i;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 121)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 122) for (i = 0; i < ARRAY_SIZE(psp_var_map); i++)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 123) if (psp_var_map[i].num == num)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 124) return psp_var_map[i].value;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 125)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 126) return NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 127) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 128)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 129) static void __init add_adam2_var(char *name, char *value)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 130) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 131) int i;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 132)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 133) for (i = 0; i < MAX_ENTRY; i++) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 134) if (!adam2_env[i].name) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 135) adam2_env[i].name = name;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 136) adam2_env[i].value = value;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 137) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 138) } else if (!strcmp(adam2_env[i].name, name)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 139) adam2_env[i].value = value;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 140) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 141) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 142) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 143) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 144)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 145) static int __init parse_psp_env(void *psp_env_base)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 146) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 147) int i, n;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 148) char *name, *value;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 149) struct psp_env_chunk *chunks = (struct psp_env_chunk *)psp_env_data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 150)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 151) memcpy_fromio(chunks, psp_env_base, PSP_ENV_SIZE);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 152)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 153) i = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 154) n = PSP_ENV_SIZE / sizeof(struct psp_env_chunk);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 155) while (i < n) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 156) if ((chunks[i].num == 0xff) || ((i + chunks[i].len) > n))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 157) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 158) value = chunks[i].data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 159) if (chunks[i].num) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 160) name = lookup_psp_var_map(chunks[i].num);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 161) } else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 162) name = value;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 163) value += strlen(name) + 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 164) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 165) if (name)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 166) add_adam2_var(name, value);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 167) i += chunks[i].len;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 168) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 169) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 170) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 171)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 172) static void __init ar7_init_env(struct env_var *env)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 173) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 174) int i;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 175) struct psbl_rec *psbl = (struct psbl_rec *)(KSEG1ADDR(0x14000300));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 176) void *psp_env = (void *)KSEG1ADDR(psbl->env_base);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 177)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 178) if (strcmp(psp_env, psp_env_version) == 0) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 179) parse_psp_env(psp_env);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 180) } else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 181) for (i = 0; i < MAX_ENTRY; i++, env++)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 182) if (env->name)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 183) add_adam2_var(env->name, env->value);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 184) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 185) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 186)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 187) static void __init console_config(void)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 188) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 189) #ifdef CONFIG_SERIAL_8250_CONSOLE
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 190) char console_string[40];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 191) int baud = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 192) char parity = '\0', bits = '\0', flow = '\0';
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 193) char *s, *p;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 194)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 195) if (strstr(arcs_cmdline, "console="))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 196) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 197)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 198) s = prom_getenv("modetty0");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 199) if (s) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 200) baud = simple_strtoul(s, &p, 10);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 201) s = p;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 202) if (*s == ',')
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 203) s++;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 204) if (*s)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 205) parity = *s++;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 206) if (*s == ',')
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 207) s++;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 208) if (*s)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 209) bits = *s++;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 210) if (*s == ',')
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 211) s++;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 212) if (*s == 'h')
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 213) flow = 'r';
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 214) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 215)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 216) if (baud == 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 217) baud = 38400;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 218) if (parity != 'n' && parity != 'o' && parity != 'e')
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 219) parity = 'n';
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 220) if (bits != '7' && bits != '8')
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 221) bits = '8';
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 222)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 223) if (flow == 'r')
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 224) sprintf(console_string, " console=ttyS0,%d%c%c%c", baud,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 225) parity, bits, flow);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 226) else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 227) sprintf(console_string, " console=ttyS0,%d%c%c", baud, parity,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 228) bits);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 229) strlcat(arcs_cmdline, console_string, COMMAND_LINE_SIZE);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 230) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 231) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 232)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 233) void __init prom_init(void)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 234) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 235) ar7_init_cmdline(fw_arg0, (char **)fw_arg1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 236) ar7_init_env((struct env_var *)fw_arg2);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 237) console_config();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 238) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 239)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 240) #define PORT(offset) (KSEG1ADDR(AR7_REGS_UART0 + (offset * 4)))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 241) static inline unsigned int serial_in(int offset)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 242) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 243) return readl((void *)PORT(offset));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 244) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 245)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 246) static inline void serial_out(int offset, int value)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 247) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 248) writel(value, (void *)PORT(offset));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 249) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 250)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 251) void prom_putchar(char c)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 252) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 253) while ((serial_in(UART_LSR) & UART_LSR_TEMT) == 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 254) ;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 255) serial_out(UART_TX, c);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 256) }