~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

TOMOYO Linux Cross Reference
Linux/arch/mips/ralink/early_printk.c

Version: ~ [ linux-6.12-rc7 ] ~ [ linux-6.11.7 ] ~ [ linux-6.10.14 ] ~ [ linux-6.9.12 ] ~ [ linux-6.8.12 ] ~ [ linux-6.7.12 ] ~ [ linux-6.6.60 ] ~ [ linux-6.5.13 ] ~ [ linux-6.4.16 ] ~ [ linux-6.3.13 ] ~ [ linux-6.2.16 ] ~ [ linux-6.1.116 ] ~ [ linux-6.0.19 ] ~ [ linux-5.19.17 ] ~ [ linux-5.18.19 ] ~ [ linux-5.17.15 ] ~ [ linux-5.16.20 ] ~ [ linux-5.15.171 ] ~ [ linux-5.14.21 ] ~ [ linux-5.13.19 ] ~ [ linux-5.12.19 ] ~ [ linux-5.11.22 ] ~ [ linux-5.10.229 ] ~ [ linux-5.9.16 ] ~ [ linux-5.8.18 ] ~ [ linux-5.7.19 ] ~ [ linux-5.6.19 ] ~ [ linux-5.5.19 ] ~ [ linux-5.4.285 ] ~ [ linux-5.3.18 ] ~ [ linux-5.2.21 ] ~ [ linux-5.1.21 ] ~ [ linux-5.0.21 ] ~ [ linux-4.20.17 ] ~ [ linux-4.19.323 ] ~ [ linux-4.18.20 ] ~ [ linux-4.17.19 ] ~ [ linux-4.16.18 ] ~ [ linux-4.15.18 ] ~ [ linux-4.14.336 ] ~ [ linux-4.13.16 ] ~ [ linux-4.12.14 ] ~ [ linux-4.11.12 ] ~ [ linux-4.10.17 ] ~ [ linux-4.9.337 ] ~ [ linux-4.4.302 ] ~ [ linux-3.10.108 ] ~ [ linux-2.6.32.71 ] ~ [ linux-2.6.0 ] ~ [ linux-2.4.37.11 ] ~ [ unix-v6-master ] ~ [ ccs-tools-1.8.12 ] ~ [ policy-sample ] ~
Architecture: ~ [ i386 ] ~ [ alpha ] ~ [ m68k ] ~ [ mips ] ~ [ ppc ] ~ [ sparc ] ~ [ sparc64 ] ~

Diff markup

Differences between /arch/mips/ralink/early_printk.c (Architecture ppc) and /arch/mips/ralink/early_printk.c (Architecture mips)


  1 // SPDX-License-Identifier: GPL-2.0-only            1 // SPDX-License-Identifier: GPL-2.0-only
  2 /*                                                  2 /*
  3  *                                                  3  *
  4  *  Copyright (C) 2011-2012 Gabor Juhos <juhos      4  *  Copyright (C) 2011-2012 Gabor Juhos <juhosg@openwrt.org>
  5  */                                                 5  */
  6                                                     6 
  7 #include <linux/io.h>                               7 #include <linux/io.h>
  8 #include <linux/serial_reg.h>                       8 #include <linux/serial_reg.h>
  9                                                     9 
 10 #include <asm/addrspace.h>                         10 #include <asm/addrspace.h>
 11 #include <asm/setup.h>                             11 #include <asm/setup.h>
 12                                                    12 
 13 #ifdef CONFIG_SOC_RT288X                           13 #ifdef CONFIG_SOC_RT288X
 14 #define EARLY_UART_BASE         0x300c00           14 #define EARLY_UART_BASE         0x300c00
 15 #define CHIPID_BASE             0x300004           15 #define CHIPID_BASE             0x300004
 16 #elif defined(CONFIG_SOC_MT7621)                   16 #elif defined(CONFIG_SOC_MT7621)
 17 #define EARLY_UART_BASE         0x1E000c00         17 #define EARLY_UART_BASE         0x1E000c00
 18 #define CHIPID_BASE             0x1E000004         18 #define CHIPID_BASE             0x1E000004
 19 #else                                              19 #else
 20 #define EARLY_UART_BASE         0x10000c00         20 #define EARLY_UART_BASE         0x10000c00
 21 #define CHIPID_BASE             0x10000004         21 #define CHIPID_BASE             0x10000004
 22 #endif                                             22 #endif
 23                                                    23 
 24 #define MT7628_CHIP_NAME1       0x20203832         24 #define MT7628_CHIP_NAME1       0x20203832
 25                                                    25 
 26 #define UART_REG_TX             0x04               26 #define UART_REG_TX             0x04
 27 #define UART_REG_LCR            0x0c               27 #define UART_REG_LCR            0x0c
 28 #define UART_REG_LSR            0x14               28 #define UART_REG_LSR            0x14
 29 #define UART_REG_LSR_RT2880     0x1c               29 #define UART_REG_LSR_RT2880     0x1c
 30                                                    30 
 31 static __iomem void *uart_membase = (__iomem v     31 static __iomem void *uart_membase = (__iomem void *) KSEG1ADDR(EARLY_UART_BASE);
 32 static __iomem void *chipid_membase = (__iomem     32 static __iomem void *chipid_membase = (__iomem void *) KSEG1ADDR(CHIPID_BASE);
 33 static int init_complete;                          33 static int init_complete;
 34                                                    34 
 35 static inline void uart_w32(u32 val, unsigned      35 static inline void uart_w32(u32 val, unsigned reg)
 36 {                                                  36 {
 37         __raw_writel(val, uart_membase + reg);     37         __raw_writel(val, uart_membase + reg);
 38 }                                                  38 }
 39                                                    39 
 40 static inline u32 uart_r32(unsigned reg)           40 static inline u32 uart_r32(unsigned reg)
 41 {                                                  41 {
 42         return __raw_readl(uart_membase + reg)     42         return __raw_readl(uart_membase + reg);
 43 }                                                  43 }
 44                                                    44 
 45 static inline int soc_is_mt7628(void)              45 static inline int soc_is_mt7628(void)
 46 {                                                  46 {
 47         return IS_ENABLED(CONFIG_SOC_MT7620) &     47         return IS_ENABLED(CONFIG_SOC_MT7620) &&
 48                 (__raw_readl(chipid_membase) =     48                 (__raw_readl(chipid_membase) == MT7628_CHIP_NAME1);
 49 }                                                  49 }
 50                                                    50 
 51 static void find_uart_base(void)                   51 static void find_uart_base(void)
 52 {                                                  52 {
 53         int i;                                     53         int i;
 54                                                    54 
 55         if (!soc_is_mt7628())                      55         if (!soc_is_mt7628())
 56                 return;                            56                 return;
 57                                                    57 
 58         for (i = 0; i < 3; i++) {                  58         for (i = 0; i < 3; i++) {
 59                 u32 reg = uart_r32(UART_REG_LC     59                 u32 reg = uart_r32(UART_REG_LCR + (0x100 * i));
 60                                                    60 
 61                 if (!reg)                          61                 if (!reg)
 62                         continue;                  62                         continue;
 63                                                    63 
 64                 uart_membase = (__iomem void *     64                 uart_membase = (__iomem void *) KSEG1ADDR(EARLY_UART_BASE +
 65                                                    65                                                           (0x100 * i));
 66                 break;                             66                 break;
 67         }                                          67         }
 68 }                                                  68 }
 69                                                    69 
 70 void prom_putchar(char ch)                         70 void prom_putchar(char ch)
 71 {                                                  71 {
 72         if (!init_complete) {                      72         if (!init_complete) {
 73                 find_uart_base();                  73                 find_uart_base();
 74                 init_complete = 1;                 74                 init_complete = 1;
 75         }                                          75         }
 76                                                    76 
 77         if (IS_ENABLED(CONFIG_SOC_MT7621) || s     77         if (IS_ENABLED(CONFIG_SOC_MT7621) || soc_is_mt7628()) {
 78                 uart_w32((unsigned char)ch, UA     78                 uart_w32((unsigned char)ch, UART_TX);
 79                 while ((uart_r32(UART_REG_LSR)     79                 while ((uart_r32(UART_REG_LSR) & UART_LSR_THRE) == 0)
 80                         ;                          80                         ;
 81         } else {                                   81         } else {
 82                 while ((uart_r32(UART_REG_LSR_     82                 while ((uart_r32(UART_REG_LSR_RT2880) & UART_LSR_THRE) == 0)
 83                         ;                          83                         ;
 84                 uart_w32((unsigned char)ch, UA     84                 uart_w32((unsigned char)ch, UART_REG_TX);
 85                 while ((uart_r32(UART_REG_LSR_     85                 while ((uart_r32(UART_REG_LSR_RT2880) & UART_LSR_THRE) == 0)
 86                         ;                          86                         ;
 87         }                                          87         }
 88 }                                                  88 }
 89                                                    89 

~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

kernel.org | git.kernel.org | LWN.net | Project Home | SVN repository | Mail admin

Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.

sflogo.php