Path: blob/master/arch/mips/pmc-sierra/yosemite/py-console.c
15118 views
/*1* This file is subject to the terms and conditions of the GNU General Public2* License. See the file "COPYING" in the main directory of this archive3* for more details.4*5* Copyright (C) 2001, 2002, 2004 Ralf Baechle6*/7#include <linux/init.h>8#include <linux/console.h>9#include <linux/kdev_t.h>10#include <linux/major.h>11#include <linux/termios.h>12#include <linux/sched.h>13#include <linux/tty.h>1415#include <linux/serial.h>16#include <linux/serial_core.h>17#include <asm/serial.h>18#include <asm/io.h>1920/* SUPERIO uart register map */21struct yo_uartregs {22union {23volatile u8 rbr; /* read only, DLAB == 0 */24volatile u8 thr; /* write only, DLAB == 0 */25volatile u8 dll; /* DLAB == 1 */26} u1;27union {28volatile u8 ier; /* DLAB == 0 */29volatile u8 dlm; /* DLAB == 1 */30} u2;31union {32volatile u8 iir; /* read only */33volatile u8 fcr; /* write only */34} u3;35volatile u8 iu_lcr;36volatile u8 iu_mcr;37volatile u8 iu_lsr;38volatile u8 iu_msr;39volatile u8 iu_scr;40} yo_uregs_t;4142#define iu_rbr u1.rbr43#define iu_thr u1.thr44#define iu_dll u1.dll45#define iu_ier u2.ier46#define iu_dlm u2.dlm47#define iu_iir u3.iir48#define iu_fcr u3.fcr4950#define ssnop() __asm__ __volatile__("sll $0, $0, 1\n");51#define ssnop_4() do { ssnop(); ssnop(); ssnop(); ssnop(); } while (0)5253#define IO_BASE_64 0x9000000000000000ULL5455static unsigned char readb_outer_space(unsigned long long phys)56{57unsigned long long vaddr = IO_BASE_64 | phys;58unsigned char res;59unsigned int sr;6061sr = read_c0_status();62write_c0_status((sr | ST0_KX) & ~ ST0_IE);63ssnop_4();6465__asm__ __volatile__ (66" .set mips3 \n"67" .set push \n"68" .set noreorder \n"69" .set nomacro \n"70" ld %0, %1 \n"71" .set pop \n"72" lbu %0, (%0) \n"73" .set mips0 \n"74: "=r" (res)75: "R" (vaddr));7677write_c0_status(sr);78ssnop_4();7980return res;81}8283static void writeb_outer_space(unsigned long long phys, unsigned char c)84{85unsigned long long vaddr = IO_BASE_64 | phys;86unsigned long tmp;87unsigned int sr;8889sr = read_c0_status();90write_c0_status((sr | ST0_KX) & ~ ST0_IE);91ssnop_4();9293__asm__ __volatile__ (94" .set mips3 \n"95" .set push \n"96" .set noreorder \n"97" .set nomacro \n"98" ld %0, %1 \n"99" .set pop \n"100" sb %2, (%0) \n"101" .set mips0 \n"102: "=&r" (tmp)103: "R" (vaddr), "r" (c));104105write_c0_status(sr);106ssnop_4();107}108109void prom_putchar(char c)110{111unsigned long lsr = 0xfd000008ULL + offsetof(struct yo_uartregs, iu_lsr);112unsigned long thr = 0xfd000008ULL + offsetof(struct yo_uartregs, iu_thr);113114while ((readb_outer_space(lsr) & 0x20) == 0);115writeb_outer_space(thr, c);116}117118119