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

TOMOYO Linux Cross Reference
Linux/arch/powerpc/boot/serial.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/powerpc/boot/serial.c (Version linux-6.12-rc7) and /arch/sparc/boot/serial.c (Version linux-6.1.116)


  1 // SPDX-License-Identifier: GPL-2.0                 1 
  2 /*                                                
  3  * Generic serial console support                 
  4  *                                                
  5  * Author: Mark A. Greer <mgreer@mvista.com>      
  6  *                                                
  7  * Code in serial_edit_cmdline() copied from <    
  8  * and was written by Matt Porter <mporter@ker    
  9  *                                                
 10  * 2001,2006 (c) MontaVista Software, Inc.        
 11  */                                               
 12 #include <stdarg.h>                               
 13 #include <stddef.h>                               
 14 #include "types.h"                                
 15 #include "string.h"                               
 16 #include "stdio.h"                                
 17 #include "io.h"                                   
 18 #include "ops.h"                                  
 19                                                   
 20 static int serial_open(void)                      
 21 {                                                 
 22         struct serial_console_data *scdp = con    
 23         return scdp->open();                      
 24 }                                                 
 25                                                   
 26 static void serial_write(const char *buf, int     
 27 {                                                 
 28         struct serial_console_data *scdp = con    
 29                                                   
 30         while (*buf != '\0')                      
 31                 scdp->putc(*buf++);               
 32 }                                                 
 33                                                   
 34 static void serial_edit_cmdline(char *buf, int    
 35 {                                                 
 36         int timer = 0, count;                     
 37         char ch, *cp;                             
 38         struct serial_console_data *scdp = con    
 39                                                   
 40         cp = buf;                                 
 41         count = strlen(buf);                      
 42         cp = &buf[count];                         
 43         count++;                                  
 44                                                   
 45         do {                                      
 46                 if (scdp->tstc()) {               
 47                         while (((ch = scdp->ge    
 48                                 /* Test for ba    
 49                                 if ((ch == '\b    
 50                                         if (cp    
 51                                                   
 52                                                   
 53                                                   
 54                                         }         
 55                                 /* Test for ^x    
 56                                 } else if ((ch    
 57                                         while     
 58                                                   
 59                                                   
 60                                                   
 61                                         }         
 62                                 } else if (cou    
 63                                                   
 64                                                   
 65                                                   
 66                                 }                 
 67                         }                         
 68                         break;  /* Exit 'timer    
 69                 }                                 
 70                 udelay(1000);  /* 1 msec */       
 71         } while (timer++ < timeout);              
 72         *cp = 0;                                  
 73 }                                                 
 74                                                   
 75 static void serial_close(void)                    
 76 {                                                 
 77         struct serial_console_data *scdp = con    
 78                                                   
 79         if (scdp->close)                          
 80                 scdp->close();                    
 81 }                                                 
 82                                                   
 83 static void *serial_get_stdout_devp(void)         
 84 {                                                 
 85         void *devp;                               
 86         char devtype[MAX_PROP_LEN];               
 87         char path[MAX_PATH_LEN];                  
 88                                                   
 89         devp = finddevice("/chosen");             
 90         if (devp == NULL)                         
 91                 goto err_out;                     
 92                                                   
 93         if (getprop(devp, "linux,stdout-path",    
 94                 getprop(devp, "stdout-path", p    
 95                 devp = finddevice(path);          
 96                 if (devp == NULL)                 
 97                         goto err_out;             
 98                                                   
 99                 if ((getprop(devp, "device_typ    
100                                 && !strcmp(dev    
101                         return devp;              
102         }                                         
103 err_out:                                          
104         return NULL;                              
105 }                                                 
106                                                   
107 static struct serial_console_data serial_cd;      
108                                                   
109 /* Node's "compatible" property determines whi    
110 int serial_console_init(void)                     
111 {                                                 
112         void *devp;                               
113         int rc = -1;                              
114                                                   
115         devp = serial_get_stdout_devp();          
116         if (devp == NULL)                         
117                 goto err_out;                     
118                                                   
119         if (dt_is_compatible(devp, "ns16550")     
120             dt_is_compatible(devp, "pnpPNP,501    
121                 rc = ns16550_console_init(devp    
122 #ifdef CONFIG_CPM                                 
123         else if (dt_is_compatible(devp, "fsl,c    
124                  dt_is_compatible(devp, "fsl,c    
125                  dt_is_compatible(devp, "fsl,c    
126                  dt_is_compatible(devp, "fsl,c    
127                 rc = cpm_console_init(devp, &s    
128 #endif                                            
129 #ifdef CONFIG_PPC_MPC52xx                         
130         else if (dt_is_compatible(devp, "fsl,m    
131                 rc = mpc5200_psc_console_init(    
132 #endif                                            
133 #ifdef CONFIG_PPC_POWERNV                         
134         else if (dt_is_compatible(devp, "ibm,o    
135                 rc = opal_console_init(devp, &    
136 #endif                                            
137                                                   
138         /* Add other serial console driver cal    
139                                                   
140         if (!rc) {                                
141                 console_ops.open = serial_open    
142                 console_ops.write = serial_wri    
143                 console_ops.close = serial_clo    
144                 console_ops.data = &serial_cd;    
145                                                   
146                 if (serial_cd.getc)               
147                         console_ops.edit_cmdli    
148                                                   
149                 return 0;                         
150         }                                         
151 err_out:                                          
152         return -1;                                
153 }                                                 
154                                                   

~ [ 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