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

TOMOYO Linux Cross Reference
Linux/arch/m68k/atari/debug.c

Version: ~ [ linux-6.11-rc3 ] ~ [ linux-6.10.4 ] ~ [ linux-6.9.12 ] ~ [ linux-6.8.12 ] ~ [ linux-6.7.12 ] ~ [ linux-6.6.45 ] ~ [ linux-6.5.13 ] ~ [ linux-6.4.16 ] ~ [ linux-6.3.13 ] ~ [ linux-6.2.16 ] ~ [ linux-6.1.104 ] ~ [ linux-6.0.19 ] ~ [ linux-5.19.17 ] ~ [ linux-5.18.19 ] ~ [ linux-5.17.15 ] ~ [ linux-5.16.20 ] ~ [ linux-5.15.164 ] ~ [ linux-5.14.21 ] ~ [ linux-5.13.19 ] ~ [ linux-5.12.19 ] ~ [ linux-5.11.22 ] ~ [ linux-5.10.223 ] ~ [ linux-5.9.16 ] ~ [ linux-5.8.18 ] ~ [ linux-5.7.19 ] ~ [ linux-5.6.19 ] ~ [ linux-5.5.19 ] ~ [ linux-5.4.281 ] ~ [ linux-5.3.18 ] ~ [ linux-5.2.21 ] ~ [ linux-5.1.21 ] ~ [ linux-5.0.21 ] ~ [ linux-4.20.17 ] ~ [ linux-4.19.319 ] ~ [ 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.9 ] ~ [ policy-sample ] ~
Architecture: ~ [ i386 ] ~ [ alpha ] ~ [ m68k ] ~ [ mips ] ~ [ ppc ] ~ [ sparc ] ~ [ sparc64 ] ~

Diff markup

Differences between /arch/m68k/atari/debug.c (Architecture m68k) and /arch/sparc64/atari/debug.c (Architecture sparc64)


  1 /*                                                  1 
  2  * linux/arch/m68k/atari/debug.c                  
  3  *                                                
  4  * Atari debugging and serial console stuff       
  5  *                                                
  6  * Assembled of parts of former atari/config.c    
  7  *                                                
  8  * This file is subject to the terms and condi    
  9  * License.  See the file COPYING in the main     
 10  * for more details.                              
 11  */                                               
 12                                                   
 13 #include <linux/types.h>                          
 14 #include <linux/tty.h>                            
 15 #include <linux/console.h>                        
 16 #include <linux/init.h>                           
 17 #include <linux/delay.h>                          
 18 #include <linux/module.h>                         
 19                                                   
 20 #include <asm/atarihw.h>                          
 21 #include <asm/atariints.h>                        
 22                                                   
 23 /* Can be set somewhere, if a SCC master reset    
 24  * not be repeated; used by kgdb */               
 25 int atari_SCC_reset_done;                         
 26 EXPORT_SYMBOL(atari_SCC_reset_done);              
 27                                                   
 28 static struct console atari_console_driver = {    
 29         .name   = "debug",                        
 30         .flags  = CON_PRINTBUFFER,                
 31         .index  = -1,                             
 32 };                                                
 33                                                   
 34                                                   
 35 static inline void ata_mfp_out(char c)            
 36 {                                                 
 37         while (!(st_mfp.trn_stat & 0x80))         
 38                 barrier();                        
 39         st_mfp.usart_dta = c;                     
 40 }                                                 
 41                                                   
 42 static void atari_mfp_console_write(struct con    
 43                                     unsigned i    
 44 {                                                 
 45         while (count--) {                         
 46                 if (*str == '\n')                 
 47                         ata_mfp_out('\r');        
 48                 ata_mfp_out(*str++);              
 49         }                                         
 50 }                                                 
 51                                                   
 52 static inline void ata_scc_out(char c)            
 53 {                                                 
 54         do {                                      
 55                 MFPDELAY();                       
 56         } while (!(atari_scc.cha_b_ctrl & 0x04    
 57         MFPDELAY();                               
 58         atari_scc.cha_b_data = c;                 
 59 }                                                 
 60                                                   
 61 static void atari_scc_console_write(struct con    
 62                                     unsigned i    
 63 {                                                 
 64         while (count--) {                         
 65                 if (*str == '\n')                 
 66                         ata_scc_out('\r');        
 67                 ata_scc_out(*str++);              
 68         }                                         
 69 }                                                 
 70                                                   
 71 static inline void ata_midi_out(char c)           
 72 {                                                 
 73         while (!(acia.mid_ctrl & ACIA_TDRE))      
 74                 barrier();                        
 75         acia.mid_data = c;                        
 76 }                                                 
 77                                                   
 78 static void atari_midi_console_write(struct co    
 79                                      unsigned     
 80 {                                                 
 81         while (count--) {                         
 82                 if (*str == '\n')                 
 83                         ata_midi_out('\r');       
 84                 ata_midi_out(*str++);             
 85         }                                         
 86 }                                                 
 87                                                   
 88 static int ata_par_out(char c)                    
 89 {                                                 
 90         unsigned char tmp;                        
 91         /* This a some-seconds timeout in case    
 92         unsigned long i = loops_per_jiffy > 1     
 93                                                   
 94         while ((st_mfp.par_dt_reg & 1) && --i)    
 95                 ;                                 
 96         if (!i)                                   
 97                 return 0;                         
 98                                                   
 99         sound_ym.rd_data_reg_sel = 15;  /* sel    
100         sound_ym.wd_data = c;           /* put    
101         sound_ym.rd_data_reg_sel = 14;  /* sel    
102         tmp = sound_ym.rd_data_reg_sel;           
103         sound_ym.wd_data = tmp & ~0x20; /* set    
104         MFPDELAY();                     /* wai    
105         sound_ym.wd_data = tmp | 0x20;  /* set    
106         return 1;                                 
107 }                                                 
108                                                   
109 static void atari_par_console_write(struct con    
110                                     unsigned i    
111 {                                                 
112         static int printer_present = 1;           
113                                                   
114         if (!printer_present)                     
115                 return;                           
116                                                   
117         while (count--) {                         
118                 if (*str == '\n') {               
119                         if (!ata_par_out('\r')    
120                                 printer_presen    
121                                 return;           
122                         }                         
123                 }                                 
124                 if (!ata_par_out(*str++)) {       
125                         printer_present = 0;      
126                         return;                   
127                 }                                 
128         }                                         
129 }                                                 
130                                                   
131 #if 0                                             
132 int atari_mfp_console_wait_key(struct console     
133 {                                                 
134         while (!(st_mfp.rcv_stat & 0x80))         
135                 barrier();                        
136         return st_mfp.usart_dta;                  
137 }                                                 
138                                                   
139 int atari_scc_console_wait_key(struct console     
140 {                                                 
141         do {                                      
142                 MFPDELAY();                       
143         } while (!(atari_scc.cha_b_ctrl & 0x01    
144         MFPDELAY();                               
145         return atari_scc.cha_b_data;              
146 }                                                 
147                                                   
148 int atari_midi_console_wait_key(struct console    
149 {                                                 
150         while (!(acia.mid_ctrl & ACIA_RDRF)) /    
151                 barrier();                        
152         return acia.mid_data;                     
153 }                                                 
154 #endif                                            
155                                                   
156 /*                                                
157  * The following two functions do a quick'n'di    
158  * SCC serial ports. They're used by the debug    
159  * serial console code.                           
160  */                                               
161 static void __init atari_init_mfp_port(int cfl    
162 {                                                 
163         /*                                        
164          * timer values for 1200...115200 bps;    
165          * bps, resp., and work only correct i    
166          */                                       
167         static int baud_table[9] = { 16, 11, 8    
168         int baud = cflag & CBAUD;                 
169         int parity = (cflag & PARENB) ? ((cfla    
170         int csize = ((cflag & CSIZE) == CS7) ?    
171                                                   
172         if (cflag & CBAUDEX)                      
173                 baud += B38400;                   
174         if (baud < B1200 || baud > B38400+2)      
175                 baud = B9600;           /* use    
176         baud -= B1200;                  /* bau    
177                                                   
178         st_mfp.trn_stat &= ~0x01;       /* dis    
179         st_mfp.usart_ctr = parity | csize | 0x    
180         st_mfp.tim_ct_cd &= 0x70;       /* sto    
181         st_mfp.tim_dt_d = baud_table[baud];       
182         st_mfp.tim_ct_cd |= 0x01;       /* sta    
183         st_mfp.trn_stat |= 0x01;        /* ena    
184 }                                                 
185                                                   
186 #define SCC_WRITE(reg, val)                       
187         do {                                      
188                 atari_scc.cha_b_ctrl = (reg);     
189                 MFPDELAY();                       
190                 atari_scc.cha_b_ctrl = (val);     
191                 MFPDELAY();                       
192         } while (0)                               
193                                                   
194 /* loops_per_jiffy isn't initialized yet, so w    
195  * delay of ~ 60us. */                            
196 #define LONG_DELAY()                              
197         do {                                      
198                 int i;                            
199                 for (i = 100; i > 0; --i)         
200                         MFPDELAY();               
201         } while (0)                               
202                                                   
203 static void __init atari_init_scc_port(int cfl    
204 {                                                 
205         static int clksrc_table[9] =              
206                 /* reg 11: 0x50 = BRG, 0x00 =     
207                 { 0x50, 0x50, 0x50, 0x50, 0x50    
208         static int brgsrc_table[9] =              
209                 /* reg 14: 0 = RTxC, 2 = PCLK     
210                 { 2, 2, 2, 2, 2, 2, 0, 2, 2 };    
211         static int clkmode_table[9] =             
212                 /* reg 4: 0x40 = x16, 0x80 = x    
213                 { 0x40, 0x40, 0x40, 0x40, 0x40    
214         static int div_table[9] =                 
215                 /* reg12 (BRG low) */             
216                 { 208, 138, 103, 50, 24, 11, 1    
217                                                   
218         int baud = cflag & CBAUD;                 
219         int clksrc, clkmode, div, reg3, reg5;     
220                                                   
221         if (cflag & CBAUDEX)                      
222                 baud += B38400;                   
223         if (baud < B1200 || baud > B38400+2)      
224                 baud = B9600;           /* use    
225         baud -= B1200;                  /* tab    
226                                                   
227         clksrc  = clksrc_table[baud];             
228         clkmode = clkmode_table[baud];            
229         div     = div_table[baud];                
230         if (ATARIHW_PRESENT(TT_MFP) && baud >=    
231                 /* special treatment for TT, w    
232                 clksrc = 0x28;          /* TRx    
233                 clkmode = baud == 6 ? 0xc0 :      
234                           baud == 7 ? 0x80 : /    
235                                       0x40;  /    
236                 div = 0;                          
237         }                                         
238                                                   
239         reg3 = (cflag & CSIZE) == CS8 ? 0xc0 :    
240         reg5 = (cflag & CSIZE) == CS8 ? 0x60 :    
241                                                   
242         (void)atari_scc.cha_b_ctrl;     /* res    
243         SCC_WRITE(9, 0xc0);             /* res    
244         LONG_DELAY();                   /* ext    
245         SCC_WRITE(4, (cflag & PARENB) ? ((cfla    
246                                       : 0 | 0x    
247         SCC_WRITE(3, reg3);                       
248         SCC_WRITE(5, reg5);                       
249         SCC_WRITE(9, 0);                /* no     
250         LONG_DELAY();                   /* ext    
251         SCC_WRITE(10, 0);               /* NRZ    
252         SCC_WRITE(11, clksrc);          /* mai    
253         SCC_WRITE(12, div);             /* BRG    
254         SCC_WRITE(13, 0);               /* BRG    
255         SCC_WRITE(14, brgsrc_table[baud]);        
256         SCC_WRITE(14, brgsrc_table[baud] | (di    
257         SCC_WRITE(3, reg3 | 1);                   
258         SCC_WRITE(5, reg5 | 8);                   
259                                                   
260         atari_SCC_reset_done = 1;                 
261 }                                                 
262                                                   
263 static void __init atari_init_midi_port(int cf    
264 {                                                 
265         int baud = cflag & CBAUD;                 
266         int csize = ((cflag & CSIZE) == CS8) ?    
267         /* warning 7N1 isn't possible! (instea    
268         int parity = (cflag & PARENB) ? ((cfla    
269         int div;                                  
270                                                   
271         /* 4800 selects 7812.5, 115200 selects    
272          * default) the standard MIDI speed 31    
273         if (cflag & CBAUDEX)                      
274                 baud += B38400;                   
275         if (baud == B4800)                        
276                 div = ACIA_DIV64;       /* rea    
277         else if (baud == B38400+2 /* 115200 */    
278                 div = ACIA_DIV1;        /* rea    
279         else                                      
280                 div = ACIA_DIV16;       /* 312    
281                                                   
282         /* RTS low, ints disabled */              
283         acia.mid_ctrl = div | csize | parity |    
284                     ((atari_switches & ATARI_S    
285                      ACIA_RHTID : ACIA_RLTID);    
286 }                                                 
287                                                   
288 static int __init atari_debug_setup(char *arg)    
289 {                                                 
290         bool registered;                          
291                                                   
292         if (!MACH_IS_ATARI)                       
293                 return 0;                         
294                                                   
295         if (!strcmp(arg, "ser"))                  
296                 /* defaults to ser2 for a Falc    
297                 arg = MACH_IS_FALCON ? "ser2"     
298                                                   
299         registered = !!atari_console_driver.wr    
300         if (!strcmp(arg, "ser1")) {               
301                 /* ST-MFP Modem1 serial port *    
302                 atari_init_mfp_port(B9600|CS8)    
303                 atari_console_driver.write = a    
304         } else if (!strcmp(arg, "ser2")) {        
305                 /* SCC Modem2 serial port */      
306                 atari_init_scc_port(B9600|CS8)    
307                 atari_console_driver.write = a    
308         } else if (!strcmp(arg, "midi")) {        
309                 /* MIDI port */                   
310                 atari_init_midi_port(B9600|CS8    
311                 atari_console_driver.write = a    
312         } else if (!strcmp(arg, "par")) {         
313                 /* parallel printer */            
314                 atari_turnoff_irq(IRQ_MFP_BUSY    
315                 sound_ym.rd_data_reg_sel = 7;     
316                 sound_ym.wd_data = 0xff;          
317                 sound_ym.rd_data_reg_sel = 15;    
318                 sound_ym.wd_data = 0;             
319                 sound_ym.rd_data_reg_sel = 14;    
320                 sound_ym.wd_data = sound_ym.rd    
321                 atari_console_driver.write = a    
322         }                                         
323         if (atari_console_driver.write && !reg    
324                 register_console(&atari_consol    
325                                                   
326         return 0;                                 
327 }                                                 
328                                                   
329 early_param("debug", atari_debug_setup);          
330                                                   

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