68328serial.c 32 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333
  1. /* 68328serial.c: Serial port driver for 68328 microcontroller
  2. *
  3. * Copyright (C) 1995 David S. Miller <davem@caip.rutgers.edu>
  4. * Copyright (C) 1998 Kenneth Albanowski <kjahds@kjahds.com>
  5. * Copyright (C) 1998, 1999 D. Jeff Dionne <jeff@uclinux.org>
  6. * Copyright (C) 1999 Vladimir Gurevich <vgurevic@cisco.com>
  7. * Copyright (C) 2002-2003 David McCullough <davidm@snapgear.com>
  8. * Copyright (C) 2002 Greg Ungerer <gerg@snapgear.com>
  9. *
  10. * VZ Support/Fixes Evan Stawnyczy <e@lineo.ca>
  11. * Multiple UART support Daniel Potts <danielp@cse.unsw.edu.au>
  12. * Power management support Daniel Potts <danielp@cse.unsw.edu.au>
  13. * VZ Second Serial Port enable Phil Wilshire
  14. * 2.4/2.5 port David McCullough
  15. */
  16. #include <asm/dbg.h>
  17. #include <linux/module.h>
  18. #include <linux/errno.h>
  19. #include <linux/serial.h>
  20. #include <linux/signal.h>
  21. #include <linux/sched.h>
  22. #include <linux/timer.h>
  23. #include <linux/interrupt.h>
  24. #include <linux/tty.h>
  25. #include <linux/tty_flip.h>
  26. #include <linux/major.h>
  27. #include <linux/string.h>
  28. #include <linux/fcntl.h>
  29. #include <linux/mm.h>
  30. #include <linux/kernel.h>
  31. #include <linux/console.h>
  32. #include <linux/reboot.h>
  33. #include <linux/keyboard.h>
  34. #include <linux/init.h>
  35. #include <linux/pm.h>
  36. #include <linux/bitops.h>
  37. #include <linux/delay.h>
  38. #include <linux/gfp.h>
  39. #include <asm/io.h>
  40. #include <asm/irq.h>
  41. #include <asm/delay.h>
  42. #include <asm/uaccess.h>
  43. /* (es) */
  44. /* note: perhaps we can murge these files, so that you can just
  45. * define 1 of them, and they can sort that out for themselves
  46. */
  47. #if defined(CONFIG_M68EZ328)
  48. #include <asm/MC68EZ328.h>
  49. #else
  50. #if defined(CONFIG_M68VZ328)
  51. #include <asm/MC68VZ328.h>
  52. #else
  53. #include <asm/MC68328.h>
  54. #endif /* CONFIG_M68VZ328 */
  55. #endif /* CONFIG_M68EZ328 */
  56. /* Turn off usage of real serial interrupt code, to "support" Copilot */
  57. #ifdef CONFIG_XCOPILOT_BUGS
  58. #undef USE_INTS
  59. #else
  60. #define USE_INTS
  61. #endif
  62. /*
  63. * I believe this is the optimal setting that reduces the number of interrupts.
  64. * At high speeds the output might become a little "bursted" (use USTCNT_TXHE
  65. * if that bothers you), but in most cases it will not, since we try to
  66. * transmit characters every time rs_interrupt is called. Thus, quite often
  67. * you'll see that a receive interrupt occures before the transmit one.
  68. * -- Vladimir Gurevich
  69. */
  70. #define USTCNT_TX_INTR_MASK (USTCNT_TXEE)
  71. /*
  72. * 68328 and 68EZ328 UARTS are a little bit different. EZ328 has special
  73. * "Old data interrupt" which occures whenever the data stay in the FIFO
  74. * longer than 30 bits time. This allows us to use FIFO without compromising
  75. * latency. '328 does not have this feature and without the real 328-based
  76. * board I would assume that RXRE is the safest setting.
  77. *
  78. * For EZ328 I use RXHE (Half empty) interrupt to reduce the number of
  79. * interrupts. RXFE (receive queue full) causes the system to lose data
  80. * at least at 115200 baud
  81. *
  82. * If your board is busy doing other stuff, you might consider to use
  83. * RXRE (data ready intrrupt) instead.
  84. *
  85. * The other option is to make these INTR masks run-time configurable, so
  86. * that people can dynamically adapt them according to the current usage.
  87. * -- Vladimir Gurevich
  88. */
  89. /* (es) */
  90. #if defined(CONFIG_M68EZ328) || defined(CONFIG_M68VZ328)
  91. #define USTCNT_RX_INTR_MASK (USTCNT_RXHE | USTCNT_ODEN)
  92. #elif defined(CONFIG_M68328)
  93. #define USTCNT_RX_INTR_MASK (USTCNT_RXRE)
  94. #else
  95. #error Please, define the Rx interrupt events for your CPU
  96. #endif
  97. /* (/es) */
  98. /*
  99. * This is our internal structure for each serial port's state.
  100. */
  101. struct m68k_serial {
  102. struct tty_port tport;
  103. char is_cons; /* Is this our console. */
  104. int magic;
  105. int baud_base;
  106. int port;
  107. int irq;
  108. int type; /* UART type */
  109. int custom_divisor;
  110. int x_char; /* xon/xoff character */
  111. int line;
  112. unsigned char *xmit_buf;
  113. int xmit_head;
  114. int xmit_tail;
  115. int xmit_cnt;
  116. };
  117. #define SERIAL_MAGIC 0x5301
  118. /*
  119. * Define the number of ports supported and their irqs.
  120. */
  121. #define NR_PORTS 1
  122. static struct m68k_serial m68k_soft[NR_PORTS];
  123. static unsigned int uart_irqs[NR_PORTS] = { UART_IRQ_NUM };
  124. /* multiple ports are contiguous in memory */
  125. m68328_uart *uart_addr = (m68328_uart *)USTCNT_ADDR;
  126. struct tty_driver *serial_driver;
  127. static void change_speed(struct m68k_serial *info, struct tty_struct *tty);
  128. /*
  129. * Setup for console. Argument comes from the boot command line.
  130. */
  131. /* note: this is messy, but it works, again, perhaps defined somewhere else?*/
  132. #ifdef CONFIG_M68VZ328
  133. #define CONSOLE_BAUD_RATE 19200
  134. #define DEFAULT_CBAUD B19200
  135. #endif
  136. #ifndef CONSOLE_BAUD_RATE
  137. #define CONSOLE_BAUD_RATE 9600
  138. #define DEFAULT_CBAUD B9600
  139. #endif
  140. static int m68328_console_initted = 0;
  141. static int m68328_console_baud = CONSOLE_BAUD_RATE;
  142. static int m68328_console_cbaud = DEFAULT_CBAUD;
  143. static inline int serial_paranoia_check(struct m68k_serial *info,
  144. char *name, const char *routine)
  145. {
  146. #ifdef SERIAL_PARANOIA_CHECK
  147. static const char *badmagic =
  148. "Warning: bad magic number for serial struct %s in %s\n";
  149. static const char *badinfo =
  150. "Warning: null m68k_serial for %s in %s\n";
  151. if (!info) {
  152. printk(badinfo, name, routine);
  153. return 1;
  154. }
  155. if (info->magic != SERIAL_MAGIC) {
  156. printk(badmagic, name, routine);
  157. return 1;
  158. }
  159. #endif
  160. return 0;
  161. }
  162. /*
  163. * This is used to figure out the divisor speeds and the timeouts
  164. */
  165. static int baud_table[] = {
  166. 0, 50, 75, 110, 134, 150, 200, 300, 600, 1200, 1800, 2400, 4800,
  167. 9600, 19200, 38400, 57600, 115200, 0 };
  168. /* Utility routines */
  169. static inline int get_baud(struct m68k_serial *ss)
  170. {
  171. unsigned long result = 115200;
  172. unsigned short int baud = uart_addr[ss->line].ubaud;
  173. if (GET_FIELD(baud, UBAUD_PRESCALER) == 0x38) result = 38400;
  174. result >>= GET_FIELD(baud, UBAUD_DIVIDE);
  175. return result;
  176. }
  177. /*
  178. * ------------------------------------------------------------
  179. * rs_stop() and rs_start()
  180. *
  181. * This routines are called before setting or resetting tty->stopped.
  182. * They enable or disable transmitter interrupts, as necessary.
  183. * ------------------------------------------------------------
  184. */
  185. static void rs_stop(struct tty_struct *tty)
  186. {
  187. struct m68k_serial *info = (struct m68k_serial *)tty->driver_data;
  188. m68328_uart *uart = &uart_addr[info->line];
  189. unsigned long flags;
  190. if (serial_paranoia_check(info, tty->name, "rs_stop"))
  191. return;
  192. local_irq_save(flags);
  193. uart->ustcnt &= ~USTCNT_TXEN;
  194. local_irq_restore(flags);
  195. }
  196. static int rs_put_char(char ch)
  197. {
  198. unsigned long flags;
  199. int loops = 0;
  200. local_irq_save(flags);
  201. while (!(UTX & UTX_TX_AVAIL) && (loops < 1000)) {
  202. loops++;
  203. udelay(5);
  204. }
  205. UTX_TXDATA = ch;
  206. udelay(5);
  207. local_irq_restore(flags);
  208. return 1;
  209. }
  210. static void rs_start(struct tty_struct *tty)
  211. {
  212. struct m68k_serial *info = (struct m68k_serial *)tty->driver_data;
  213. m68328_uart *uart = &uart_addr[info->line];
  214. unsigned long flags;
  215. if (serial_paranoia_check(info, tty->name, "rs_start"))
  216. return;
  217. local_irq_save(flags);
  218. if (info->xmit_cnt && info->xmit_buf && !(uart->ustcnt & USTCNT_TXEN)) {
  219. #ifdef USE_INTS
  220. uart->ustcnt |= USTCNT_TXEN | USTCNT_TX_INTR_MASK;
  221. #else
  222. uart->ustcnt |= USTCNT_TXEN;
  223. #endif
  224. }
  225. local_irq_restore(flags);
  226. }
  227. static void receive_chars(struct m68k_serial *info, struct tty_struct *tty,
  228. unsigned short rx)
  229. {
  230. m68328_uart *uart = &uart_addr[info->line];
  231. unsigned char ch, flag;
  232. /*
  233. * This do { } while() loop will get ALL chars out of Rx FIFO
  234. */
  235. #ifndef CONFIG_XCOPILOT_BUGS
  236. do {
  237. #endif
  238. ch = GET_FIELD(rx, URX_RXDATA);
  239. if(info->is_cons) {
  240. if(URX_BREAK & rx) { /* whee, break received */
  241. return;
  242. #ifdef CONFIG_MAGIC_SYSRQ
  243. } else if (ch == 0x10) { /* ^P */
  244. show_state();
  245. show_free_areas(0);
  246. show_buffers();
  247. /* show_net_buffers(); */
  248. return;
  249. } else if (ch == 0x12) { /* ^R */
  250. emergency_restart();
  251. return;
  252. #endif /* CONFIG_MAGIC_SYSRQ */
  253. }
  254. }
  255. if(!tty)
  256. goto clear_and_exit;
  257. flag = TTY_NORMAL;
  258. if (rx & URX_PARITY_ERROR)
  259. flag = TTY_PARITY;
  260. else if (rx & URX_OVRUN)
  261. flag = TTY_OVERRUN;
  262. else if (rx & URX_FRAME_ERROR)
  263. flag = TTY_FRAME;
  264. tty_insert_flip_char(tty, ch, flag);
  265. #ifndef CONFIG_XCOPILOT_BUGS
  266. } while((rx = uart->urx.w) & URX_DATA_READY);
  267. #endif
  268. tty_schedule_flip(tty);
  269. clear_and_exit:
  270. return;
  271. }
  272. static void transmit_chars(struct m68k_serial *info, struct tty_struct *tty)
  273. {
  274. m68328_uart *uart = &uart_addr[info->line];
  275. if (info->x_char) {
  276. /* Send next char */
  277. uart->utx.b.txdata = info->x_char;
  278. info->x_char = 0;
  279. goto clear_and_return;
  280. }
  281. if ((info->xmit_cnt <= 0) || !tty || tty->stopped) {
  282. /* That's peculiar... TX ints off */
  283. uart->ustcnt &= ~USTCNT_TX_INTR_MASK;
  284. goto clear_and_return;
  285. }
  286. /* Send char */
  287. uart->utx.b.txdata = info->xmit_buf[info->xmit_tail++];
  288. info->xmit_tail = info->xmit_tail & (SERIAL_XMIT_SIZE-1);
  289. info->xmit_cnt--;
  290. if(info->xmit_cnt <= 0) {
  291. /* All done for now... TX ints off */
  292. uart->ustcnt &= ~USTCNT_TX_INTR_MASK;
  293. goto clear_and_return;
  294. }
  295. clear_and_return:
  296. /* Clear interrupt (should be auto)*/
  297. return;
  298. }
  299. /*
  300. * This is the serial driver's generic interrupt routine
  301. */
  302. irqreturn_t rs_interrupt(int irq, void *dev_id)
  303. {
  304. struct m68k_serial *info = dev_id;
  305. struct tty_struct *tty = tty_port_tty_get(&info->tport);
  306. m68328_uart *uart;
  307. unsigned short rx;
  308. unsigned short tx;
  309. uart = &uart_addr[info->line];
  310. rx = uart->urx.w;
  311. #ifdef USE_INTS
  312. tx = uart->utx.w;
  313. if (rx & URX_DATA_READY)
  314. receive_chars(info, tty, rx);
  315. if (tx & UTX_TX_AVAIL)
  316. transmit_chars(info, tty);
  317. #else
  318. receive_chars(info, tty, rx);
  319. #endif
  320. tty_kref_put(tty);
  321. return IRQ_HANDLED;
  322. }
  323. static int startup(struct m68k_serial *info, struct tty_struct *tty)
  324. {
  325. m68328_uart *uart = &uart_addr[info->line];
  326. unsigned long flags;
  327. if (info->tport.flags & ASYNC_INITIALIZED)
  328. return 0;
  329. if (!info->xmit_buf) {
  330. info->xmit_buf = (unsigned char *) __get_free_page(GFP_KERNEL);
  331. if (!info->xmit_buf)
  332. return -ENOMEM;
  333. }
  334. local_irq_save(flags);
  335. /*
  336. * Clear the FIFO buffers and disable them
  337. * (they will be reenabled in change_speed())
  338. */
  339. uart->ustcnt = USTCNT_UEN;
  340. uart->ustcnt = USTCNT_UEN | USTCNT_RXEN | USTCNT_TXEN;
  341. (void)uart->urx.w;
  342. /*
  343. * Finally, enable sequencing and interrupts
  344. */
  345. #ifdef USE_INTS
  346. uart->ustcnt = USTCNT_UEN | USTCNT_RXEN |
  347. USTCNT_RX_INTR_MASK | USTCNT_TX_INTR_MASK;
  348. #else
  349. uart->ustcnt = USTCNT_UEN | USTCNT_RXEN | USTCNT_RX_INTR_MASK;
  350. #endif
  351. if (tty)
  352. clear_bit(TTY_IO_ERROR, &tty->flags);
  353. info->xmit_cnt = info->xmit_head = info->xmit_tail = 0;
  354. /*
  355. * and set the speed of the serial port
  356. */
  357. change_speed(info, tty);
  358. info->tport.flags |= ASYNC_INITIALIZED;
  359. local_irq_restore(flags);
  360. return 0;
  361. }
  362. /*
  363. * This routine will shutdown a serial port; interrupts are disabled, and
  364. * DTR is dropped if the hangup on close termio flag is on.
  365. */
  366. static void shutdown(struct m68k_serial *info, struct tty_struct *tty)
  367. {
  368. m68328_uart *uart = &uart_addr[info->line];
  369. unsigned long flags;
  370. uart->ustcnt = 0; /* All off! */
  371. if (!(info->tport.flags & ASYNC_INITIALIZED))
  372. return;
  373. local_irq_save(flags);
  374. if (info->xmit_buf) {
  375. free_page((unsigned long) info->xmit_buf);
  376. info->xmit_buf = 0;
  377. }
  378. if (tty)
  379. set_bit(TTY_IO_ERROR, &tty->flags);
  380. info->tport.flags &= ~ASYNC_INITIALIZED;
  381. local_irq_restore(flags);
  382. }
  383. struct {
  384. int divisor, prescale;
  385. }
  386. #ifndef CONFIG_M68VZ328
  387. hw_baud_table[18] = {
  388. {0,0}, /* 0 */
  389. {0,0}, /* 50 */
  390. {0,0}, /* 75 */
  391. {0,0}, /* 110 */
  392. {0,0}, /* 134 */
  393. {0,0}, /* 150 */
  394. {0,0}, /* 200 */
  395. {7,0x26}, /* 300 */
  396. {6,0x26}, /* 600 */
  397. {5,0x26}, /* 1200 */
  398. {0,0}, /* 1800 */
  399. {4,0x26}, /* 2400 */
  400. {3,0x26}, /* 4800 */
  401. {2,0x26}, /* 9600 */
  402. {1,0x26}, /* 19200 */
  403. {0,0x26}, /* 38400 */
  404. {1,0x38}, /* 57600 */
  405. {0,0x38}, /* 115200 */
  406. };
  407. #else
  408. hw_baud_table[18] = {
  409. {0,0}, /* 0 */
  410. {0,0}, /* 50 */
  411. {0,0}, /* 75 */
  412. {0,0}, /* 110 */
  413. {0,0}, /* 134 */
  414. {0,0}, /* 150 */
  415. {0,0}, /* 200 */
  416. {0,0}, /* 300 */
  417. {7,0x26}, /* 600 */
  418. {6,0x26}, /* 1200 */
  419. {0,0}, /* 1800 */
  420. {5,0x26}, /* 2400 */
  421. {4,0x26}, /* 4800 */
  422. {3,0x26}, /* 9600 */
  423. {2,0x26}, /* 19200 */
  424. {1,0x26}, /* 38400 */
  425. {0,0x26}, /* 57600 */
  426. {1,0x38}, /* 115200 */
  427. };
  428. #endif
  429. /* rate = 1036800 / ((65 - prescale) * (1<<divider)) */
  430. /*
  431. * This routine is called to set the UART divisor registers to match
  432. * the specified baud rate for a serial port.
  433. */
  434. static void change_speed(struct m68k_serial *info, struct tty_struct *tty)
  435. {
  436. m68328_uart *uart = &uart_addr[info->line];
  437. unsigned short port;
  438. unsigned short ustcnt;
  439. unsigned cflag;
  440. int i;
  441. cflag = tty->termios.c_cflag;
  442. if (!(port = info->port))
  443. return;
  444. ustcnt = uart->ustcnt;
  445. uart->ustcnt = ustcnt & ~USTCNT_TXEN;
  446. i = cflag & CBAUD;
  447. if (i & CBAUDEX) {
  448. i = (i & ~CBAUDEX) + B38400;
  449. }
  450. uart->ubaud = PUT_FIELD(UBAUD_DIVIDE, hw_baud_table[i].divisor) |
  451. PUT_FIELD(UBAUD_PRESCALER, hw_baud_table[i].prescale);
  452. ustcnt &= ~(USTCNT_PARITYEN | USTCNT_ODD_EVEN | USTCNT_STOP | USTCNT_8_7);
  453. if ((cflag & CSIZE) == CS8)
  454. ustcnt |= USTCNT_8_7;
  455. if (cflag & CSTOPB)
  456. ustcnt |= USTCNT_STOP;
  457. if (cflag & PARENB)
  458. ustcnt |= USTCNT_PARITYEN;
  459. if (cflag & PARODD)
  460. ustcnt |= USTCNT_ODD_EVEN;
  461. #ifdef CONFIG_SERIAL_68328_RTS_CTS
  462. if (cflag & CRTSCTS) {
  463. uart->utx.w &= ~ UTX_NOCTS;
  464. } else {
  465. uart->utx.w |= UTX_NOCTS;
  466. }
  467. #endif
  468. ustcnt |= USTCNT_TXEN;
  469. uart->ustcnt = ustcnt;
  470. return;
  471. }
  472. /*
  473. * Fair output driver allows a process to speak.
  474. */
  475. static void rs_fair_output(void)
  476. {
  477. int left; /* Output no more than that */
  478. unsigned long flags;
  479. struct m68k_serial *info = &m68k_soft[0];
  480. char c;
  481. if (info == 0) return;
  482. if (info->xmit_buf == 0) return;
  483. local_irq_save(flags);
  484. left = info->xmit_cnt;
  485. while (left != 0) {
  486. c = info->xmit_buf[info->xmit_tail];
  487. info->xmit_tail = (info->xmit_tail+1) & (SERIAL_XMIT_SIZE-1);
  488. info->xmit_cnt--;
  489. local_irq_restore(flags);
  490. rs_put_char(c);
  491. local_irq_save(flags);
  492. left = min(info->xmit_cnt, left-1);
  493. }
  494. /* Last character is being transmitted now (hopefully). */
  495. udelay(5);
  496. local_irq_restore(flags);
  497. return;
  498. }
  499. /*
  500. * m68k_console_print is registered for printk.
  501. */
  502. void console_print_68328(const char *p)
  503. {
  504. char c;
  505. while((c=*(p++)) != 0) {
  506. if(c == '\n')
  507. rs_put_char('\r');
  508. rs_put_char(c);
  509. }
  510. /* Comment this if you want to have a strict interrupt-driven output */
  511. rs_fair_output();
  512. return;
  513. }
  514. static void rs_set_ldisc(struct tty_struct *tty)
  515. {
  516. struct m68k_serial *info = (struct m68k_serial *)tty->driver_data;
  517. if (serial_paranoia_check(info, tty->name, "rs_set_ldisc"))
  518. return;
  519. info->is_cons = (tty->termios.c_line == N_TTY);
  520. printk("ttyS%d console mode %s\n", info->line, info->is_cons ? "on" : "off");
  521. }
  522. static void rs_flush_chars(struct tty_struct *tty)
  523. {
  524. struct m68k_serial *info = (struct m68k_serial *)tty->driver_data;
  525. m68328_uart *uart = &uart_addr[info->line];
  526. unsigned long flags;
  527. if (serial_paranoia_check(info, tty->name, "rs_flush_chars"))
  528. return;
  529. #ifndef USE_INTS
  530. for(;;) {
  531. #endif
  532. /* Enable transmitter */
  533. local_irq_save(flags);
  534. if (info->xmit_cnt <= 0 || tty->stopped || tty->hw_stopped ||
  535. !info->xmit_buf) {
  536. local_irq_restore(flags);
  537. return;
  538. }
  539. #ifdef USE_INTS
  540. uart->ustcnt |= USTCNT_TXEN | USTCNT_TX_INTR_MASK;
  541. #else
  542. uart->ustcnt |= USTCNT_TXEN;
  543. #endif
  544. #ifdef USE_INTS
  545. if (uart->utx.w & UTX_TX_AVAIL) {
  546. #else
  547. if (1) {
  548. #endif
  549. /* Send char */
  550. uart->utx.b.txdata = info->xmit_buf[info->xmit_tail++];
  551. info->xmit_tail = info->xmit_tail & (SERIAL_XMIT_SIZE-1);
  552. info->xmit_cnt--;
  553. }
  554. #ifndef USE_INTS
  555. while (!(uart->utx.w & UTX_TX_AVAIL)) udelay(5);
  556. }
  557. #endif
  558. local_irq_restore(flags);
  559. }
  560. extern void console_printn(const char * b, int count);
  561. static int rs_write(struct tty_struct * tty,
  562. const unsigned char *buf, int count)
  563. {
  564. int c, total = 0;
  565. struct m68k_serial *info = (struct m68k_serial *)tty->driver_data;
  566. m68328_uart *uart = &uart_addr[info->line];
  567. unsigned long flags;
  568. if (serial_paranoia_check(info, tty->name, "rs_write"))
  569. return 0;
  570. if (!tty || !info->xmit_buf)
  571. return 0;
  572. local_save_flags(flags);
  573. while (1) {
  574. local_irq_disable();
  575. c = min_t(int, count, min(SERIAL_XMIT_SIZE - info->xmit_cnt - 1,
  576. SERIAL_XMIT_SIZE - info->xmit_head));
  577. local_irq_restore(flags);
  578. if (c <= 0)
  579. break;
  580. memcpy(info->xmit_buf + info->xmit_head, buf, c);
  581. local_irq_disable();
  582. info->xmit_head = (info->xmit_head + c) & (SERIAL_XMIT_SIZE-1);
  583. info->xmit_cnt += c;
  584. local_irq_restore(flags);
  585. buf += c;
  586. count -= c;
  587. total += c;
  588. }
  589. if (info->xmit_cnt && !tty->stopped && !tty->hw_stopped) {
  590. /* Enable transmitter */
  591. local_irq_disable();
  592. #ifndef USE_INTS
  593. while(info->xmit_cnt) {
  594. #endif
  595. uart->ustcnt |= USTCNT_TXEN;
  596. #ifdef USE_INTS
  597. uart->ustcnt |= USTCNT_TX_INTR_MASK;
  598. #else
  599. while (!(uart->utx.w & UTX_TX_AVAIL)) udelay(5);
  600. #endif
  601. if (uart->utx.w & UTX_TX_AVAIL) {
  602. uart->utx.b.txdata = info->xmit_buf[info->xmit_tail++];
  603. info->xmit_tail = info->xmit_tail & (SERIAL_XMIT_SIZE-1);
  604. info->xmit_cnt--;
  605. }
  606. #ifndef USE_INTS
  607. }
  608. #endif
  609. local_irq_restore(flags);
  610. }
  611. return total;
  612. }
  613. static int rs_write_room(struct tty_struct *tty)
  614. {
  615. struct m68k_serial *info = (struct m68k_serial *)tty->driver_data;
  616. int ret;
  617. if (serial_paranoia_check(info, tty->name, "rs_write_room"))
  618. return 0;
  619. ret = SERIAL_XMIT_SIZE - info->xmit_cnt - 1;
  620. if (ret < 0)
  621. ret = 0;
  622. return ret;
  623. }
  624. static int rs_chars_in_buffer(struct tty_struct *tty)
  625. {
  626. struct m68k_serial *info = (struct m68k_serial *)tty->driver_data;
  627. if (serial_paranoia_check(info, tty->name, "rs_chars_in_buffer"))
  628. return 0;
  629. return info->xmit_cnt;
  630. }
  631. static void rs_flush_buffer(struct tty_struct *tty)
  632. {
  633. struct m68k_serial *info = (struct m68k_serial *)tty->driver_data;
  634. unsigned long flags;
  635. if (serial_paranoia_check(info, tty->name, "rs_flush_buffer"))
  636. return;
  637. local_irq_save(flags);
  638. info->xmit_cnt = info->xmit_head = info->xmit_tail = 0;
  639. local_irq_restore(flags);
  640. tty_wakeup(tty);
  641. }
  642. /*
  643. * ------------------------------------------------------------
  644. * rs_throttle()
  645. *
  646. * This routine is called by the upper-layer tty layer to signal that
  647. * incoming characters should be throttled.
  648. * ------------------------------------------------------------
  649. */
  650. static void rs_throttle(struct tty_struct * tty)
  651. {
  652. struct m68k_serial *info = (struct m68k_serial *)tty->driver_data;
  653. if (serial_paranoia_check(info, tty->name, "rs_throttle"))
  654. return;
  655. if (I_IXOFF(tty))
  656. info->x_char = STOP_CHAR(tty);
  657. /* Turn off RTS line (do this atomic) */
  658. }
  659. static void rs_unthrottle(struct tty_struct * tty)
  660. {
  661. struct m68k_serial *info = (struct m68k_serial *)tty->driver_data;
  662. if (serial_paranoia_check(info, tty->name, "rs_unthrottle"))
  663. return;
  664. if (I_IXOFF(tty)) {
  665. if (info->x_char)
  666. info->x_char = 0;
  667. else
  668. info->x_char = START_CHAR(tty);
  669. }
  670. /* Assert RTS line (do this atomic) */
  671. }
  672. /*
  673. * ------------------------------------------------------------
  674. * rs_ioctl() and friends
  675. * ------------------------------------------------------------
  676. */
  677. static int get_serial_info(struct m68k_serial * info,
  678. struct serial_struct * retinfo)
  679. {
  680. struct serial_struct tmp;
  681. if (!retinfo)
  682. return -EFAULT;
  683. memset(&tmp, 0, sizeof(tmp));
  684. tmp.type = info->type;
  685. tmp.line = info->line;
  686. tmp.port = info->port;
  687. tmp.irq = info->irq;
  688. tmp.flags = info->tport.flags;
  689. tmp.baud_base = info->baud_base;
  690. tmp.close_delay = info->tport.close_delay;
  691. tmp.closing_wait = info->tport.closing_wait;
  692. tmp.custom_divisor = info->custom_divisor;
  693. if (copy_to_user(retinfo, &tmp, sizeof(*retinfo)))
  694. return -EFAULT;
  695. return 0;
  696. }
  697. static int set_serial_info(struct m68k_serial *info, struct tty_struct *tty,
  698. struct serial_struct * new_info)
  699. {
  700. struct tty_port *port = &info->tport;
  701. struct serial_struct new_serial;
  702. struct m68k_serial old_info;
  703. int retval = 0;
  704. if (!new_info)
  705. return -EFAULT;
  706. if (copy_from_user(&new_serial, new_info, sizeof(new_serial)))
  707. return -EFAULT;
  708. old_info = *info;
  709. if (!capable(CAP_SYS_ADMIN)) {
  710. if ((new_serial.baud_base != info->baud_base) ||
  711. (new_serial.type != info->type) ||
  712. (new_serial.close_delay != port->close_delay) ||
  713. ((new_serial.flags & ~ASYNC_USR_MASK) !=
  714. (port->flags & ~ASYNC_USR_MASK)))
  715. return -EPERM;
  716. port->flags = ((port->flags & ~ASYNC_USR_MASK) |
  717. (new_serial.flags & ASYNC_USR_MASK));
  718. info->custom_divisor = new_serial.custom_divisor;
  719. goto check_and_exit;
  720. }
  721. if (port->count > 1)
  722. return -EBUSY;
  723. /*
  724. * OK, past this point, all the error checking has been done.
  725. * At this point, we start making changes.....
  726. */
  727. info->baud_base = new_serial.baud_base;
  728. port->flags = ((port->flags & ~ASYNC_FLAGS) |
  729. (new_serial.flags & ASYNC_FLAGS));
  730. info->type = new_serial.type;
  731. port->close_delay = new_serial.close_delay;
  732. port->closing_wait = new_serial.closing_wait;
  733. check_and_exit:
  734. retval = startup(info, tty);
  735. return retval;
  736. }
  737. /*
  738. * get_lsr_info - get line status register info
  739. *
  740. * Purpose: Let user call ioctl() to get info when the UART physically
  741. * is emptied. On bus types like RS485, the transmitter must
  742. * release the bus after transmitting. This must be done when
  743. * the transmit shift register is empty, not be done when the
  744. * transmit holding register is empty. This functionality
  745. * allows an RS485 driver to be written in user space.
  746. */
  747. static int get_lsr_info(struct m68k_serial * info, unsigned int *value)
  748. {
  749. #ifdef CONFIG_SERIAL_68328_RTS_CTS
  750. m68328_uart *uart = &uart_addr[info->line];
  751. #endif
  752. unsigned char status;
  753. unsigned long flags;
  754. local_irq_save(flags);
  755. #ifdef CONFIG_SERIAL_68328_RTS_CTS
  756. status = (uart->utx.w & UTX_CTS_STAT) ? 1 : 0;
  757. #else
  758. status = 0;
  759. #endif
  760. local_irq_restore(flags);
  761. return put_user(status, value);
  762. }
  763. /*
  764. * This routine sends a break character out the serial port.
  765. */
  766. static void send_break(struct m68k_serial * info, unsigned int duration)
  767. {
  768. m68328_uart *uart = &uart_addr[info->line];
  769. unsigned long flags;
  770. if (!info->port)
  771. return;
  772. local_irq_save(flags);
  773. #ifdef USE_INTS
  774. uart->utx.w |= UTX_SEND_BREAK;
  775. msleep_interruptible(duration);
  776. uart->utx.w &= ~UTX_SEND_BREAK;
  777. #endif
  778. local_irq_restore(flags);
  779. }
  780. static int rs_ioctl(struct tty_struct *tty,
  781. unsigned int cmd, unsigned long arg)
  782. {
  783. struct m68k_serial * info = (struct m68k_serial *)tty->driver_data;
  784. int retval;
  785. if (serial_paranoia_check(info, tty->name, "rs_ioctl"))
  786. return -ENODEV;
  787. if ((cmd != TIOCGSERIAL) && (cmd != TIOCSSERIAL) &&
  788. (cmd != TIOCSERCONFIG) && (cmd != TIOCSERGWILD) &&
  789. (cmd != TIOCSERSWILD) && (cmd != TIOCSERGSTRUCT)) {
  790. if (tty->flags & (1 << TTY_IO_ERROR))
  791. return -EIO;
  792. }
  793. switch (cmd) {
  794. case TCSBRK: /* SVID version: non-zero arg --> no break */
  795. retval = tty_check_change(tty);
  796. if (retval)
  797. return retval;
  798. tty_wait_until_sent(tty, 0);
  799. if (!arg)
  800. send_break(info, 250); /* 1/4 second */
  801. return 0;
  802. case TCSBRKP: /* support for POSIX tcsendbreak() */
  803. retval = tty_check_change(tty);
  804. if (retval)
  805. return retval;
  806. tty_wait_until_sent(tty, 0);
  807. send_break(info, arg ? arg*(100) : 250);
  808. return 0;
  809. case TIOCGSERIAL:
  810. return get_serial_info(info,
  811. (struct serial_struct *) arg);
  812. case TIOCSSERIAL:
  813. return set_serial_info(info, tty,
  814. (struct serial_struct *) arg);
  815. case TIOCSERGETLSR: /* Get line status register */
  816. return get_lsr_info(info, (unsigned int *) arg);
  817. case TIOCSERGSTRUCT:
  818. if (copy_to_user((struct m68k_serial *) arg,
  819. info, sizeof(struct m68k_serial)))
  820. return -EFAULT;
  821. return 0;
  822. default:
  823. return -ENOIOCTLCMD;
  824. }
  825. return 0;
  826. }
  827. static void rs_set_termios(struct tty_struct *tty, struct ktermios *old_termios)
  828. {
  829. struct m68k_serial *info = (struct m68k_serial *)tty->driver_data;
  830. change_speed(info, tty);
  831. if ((old_termios->c_cflag & CRTSCTS) &&
  832. !(tty->termios.c_cflag & CRTSCTS)) {
  833. tty->hw_stopped = 0;
  834. rs_start(tty);
  835. }
  836. }
  837. /*
  838. * ------------------------------------------------------------
  839. * rs_close()
  840. *
  841. * This routine is called when the serial port gets closed. First, we
  842. * wait for the last remaining data to be sent. Then, we unlink its
  843. * S structure from the interrupt chain if necessary, and we free
  844. * that IRQ if nothing is left in the chain.
  845. * ------------------------------------------------------------
  846. */
  847. static void rs_close(struct tty_struct *tty, struct file * filp)
  848. {
  849. struct m68k_serial * info = (struct m68k_serial *)tty->driver_data;
  850. struct tty_port *port = &info->tport;
  851. m68328_uart *uart = &uart_addr[info->line];
  852. unsigned long flags;
  853. if (!info || serial_paranoia_check(info, tty->name, "rs_close"))
  854. return;
  855. local_irq_save(flags);
  856. if (tty_hung_up_p(filp)) {
  857. local_irq_restore(flags);
  858. return;
  859. }
  860. if ((tty->count == 1) && (port->count != 1)) {
  861. /*
  862. * Uh, oh. tty->count is 1, which means that the tty
  863. * structure will be freed. Info->count should always
  864. * be one in these conditions. If it's greater than
  865. * one, we've got real problems, since it means the
  866. * serial port won't be shutdown.
  867. */
  868. printk("rs_close: bad serial port count; tty->count is 1, "
  869. "port->count is %d\n", port->count);
  870. port->count = 1;
  871. }
  872. if (--port->count < 0) {
  873. printk("rs_close: bad serial port count for ttyS%d: %d\n",
  874. info->line, port->count);
  875. port->count = 0;
  876. }
  877. if (port->count) {
  878. local_irq_restore(flags);
  879. return;
  880. }
  881. port->flags |= ASYNC_CLOSING;
  882. /*
  883. * Now we wait for the transmit buffer to clear; and we notify
  884. * the line discipline to only process XON/XOFF characters.
  885. */
  886. tty->closing = 1;
  887. if (port->closing_wait != ASYNC_CLOSING_WAIT_NONE)
  888. tty_wait_until_sent(tty, port->closing_wait);
  889. /*
  890. * At this point we stop accepting input. To do this, we
  891. * disable the receive line status interrupts, and tell the
  892. * interrupt driver to stop checking the data ready bit in the
  893. * line status register.
  894. */
  895. uart->ustcnt &= ~USTCNT_RXEN;
  896. uart->ustcnt &= ~(USTCNT_RXEN | USTCNT_RX_INTR_MASK);
  897. shutdown(info, tty);
  898. rs_flush_buffer(tty);
  899. tty_ldisc_flush(tty);
  900. tty->closing = 0;
  901. tty_port_tty_set(&info->tport, NULL);
  902. #warning "This is not and has never been valid so fix it"
  903. #if 0
  904. if (tty->ldisc.num != ldiscs[N_TTY].num) {
  905. if (tty->ldisc.close)
  906. (tty->ldisc.close)(tty);
  907. tty->ldisc = ldiscs[N_TTY];
  908. tty->termios.c_line = N_TTY;
  909. if (tty->ldisc.open)
  910. (tty->ldisc.open)(tty);
  911. }
  912. #endif
  913. if (port->blocked_open) {
  914. if (port->close_delay)
  915. msleep_interruptible(jiffies_to_msecs(port->close_delay));
  916. wake_up_interruptible(&port->open_wait);
  917. }
  918. port->flags &= ~(ASYNC_NORMAL_ACTIVE|ASYNC_CLOSING);
  919. wake_up_interruptible(&port->close_wait);
  920. local_irq_restore(flags);
  921. }
  922. /*
  923. * rs_hangup() --- called by tty_hangup() when a hangup is signaled.
  924. */
  925. void rs_hangup(struct tty_struct *tty)
  926. {
  927. struct m68k_serial * info = (struct m68k_serial *)tty->driver_data;
  928. if (serial_paranoia_check(info, tty->name, "rs_hangup"))
  929. return;
  930. rs_flush_buffer(tty);
  931. shutdown(info, tty);
  932. info->tport.count = 0;
  933. info->tport.flags &= ~ASYNC_NORMAL_ACTIVE;
  934. tty_port_tty_set(&info->tport, NULL);
  935. wake_up_interruptible(&info->tport.open_wait);
  936. }
  937. /*
  938. * This routine is called whenever a serial port is opened. It
  939. * enables interrupts for a serial port, linking in its S structure into
  940. * the IRQ chain. It also performs the serial-specific
  941. * initialization for the tty structure.
  942. */
  943. int rs_open(struct tty_struct *tty, struct file * filp)
  944. {
  945. struct m68k_serial *info;
  946. int retval;
  947. info = &m68k_soft[tty->index];
  948. if (serial_paranoia_check(info, tty->name, "rs_open"))
  949. return -ENODEV;
  950. info->tport.count++;
  951. tty->driver_data = info;
  952. tty_port_tty_set(&info->tport, tty);
  953. /*
  954. * Start up serial port
  955. */
  956. retval = startup(info, tty);
  957. if (retval)
  958. return retval;
  959. return tty_port_block_til_ready(&info->tport, tty, filp);
  960. }
  961. /* Finally, routines used to initialize the serial driver. */
  962. static void show_serial_version(void)
  963. {
  964. printk("MC68328 serial driver version 1.00\n");
  965. }
  966. static const struct tty_operations rs_ops = {
  967. .open = rs_open,
  968. .close = rs_close,
  969. .write = rs_write,
  970. .flush_chars = rs_flush_chars,
  971. .write_room = rs_write_room,
  972. .chars_in_buffer = rs_chars_in_buffer,
  973. .flush_buffer = rs_flush_buffer,
  974. .ioctl = rs_ioctl,
  975. .throttle = rs_throttle,
  976. .unthrottle = rs_unthrottle,
  977. .set_termios = rs_set_termios,
  978. .stop = rs_stop,
  979. .start = rs_start,
  980. .hangup = rs_hangup,
  981. .set_ldisc = rs_set_ldisc,
  982. };
  983. static const struct tty_port_operations rs_port_ops = {
  984. };
  985. /* rs_init inits the driver */
  986. static int __init
  987. rs68328_init(void)
  988. {
  989. unsigned long flags;
  990. int i;
  991. struct m68k_serial *info;
  992. serial_driver = alloc_tty_driver(NR_PORTS);
  993. if (!serial_driver)
  994. return -ENOMEM;
  995. show_serial_version();
  996. /* Initialize the tty_driver structure */
  997. /* SPARC: Not all of this is exactly right for us. */
  998. serial_driver->name = "ttyS";
  999. serial_driver->major = TTY_MAJOR;
  1000. serial_driver->minor_start = 64;
  1001. serial_driver->type = TTY_DRIVER_TYPE_SERIAL;
  1002. serial_driver->subtype = SERIAL_TYPE_NORMAL;
  1003. serial_driver->init_termios = tty_std_termios;
  1004. serial_driver->init_termios.c_cflag =
  1005. m68328_console_cbaud | CS8 | CREAD | HUPCL | CLOCAL;
  1006. serial_driver->flags = TTY_DRIVER_REAL_RAW;
  1007. tty_set_operations(serial_driver, &rs_ops);
  1008. local_irq_save(flags);
  1009. for(i=0;i<NR_PORTS;i++) {
  1010. info = &m68k_soft[i];
  1011. tty_port_init(&info->tport);
  1012. info->tport.ops = &rs_port_ops;
  1013. info->magic = SERIAL_MAGIC;
  1014. info->port = (int) &uart_addr[i];
  1015. info->irq = uart_irqs[i];
  1016. info->custom_divisor = 16;
  1017. info->x_char = 0;
  1018. info->line = i;
  1019. info->is_cons = 1; /* Means shortcuts work */
  1020. printk("%s%d at 0x%08x (irq = %d)", serial_driver->name, info->line,
  1021. info->port, info->irq);
  1022. printk(" is a builtin MC68328 UART\n");
  1023. #ifdef CONFIG_M68VZ328
  1024. if (i > 0 )
  1025. PJSEL &= 0xCF; /* PSW enable second port output */
  1026. #endif
  1027. if (request_irq(uart_irqs[i],
  1028. rs_interrupt,
  1029. 0,
  1030. "M68328_UART", info))
  1031. panic("Unable to attach 68328 serial interrupt\n");
  1032. tty_port_link_device(&info->tport, serial_driver, i);
  1033. }
  1034. local_irq_restore(flags);
  1035. if (tty_register_driver(serial_driver)) {
  1036. put_tty_driver(serial_driver);
  1037. for (i = 0; i < NR_PORTS; i++)
  1038. tty_port_destroy(&m68k_soft[i].tport);
  1039. printk(KERN_ERR "Couldn't register serial driver\n");
  1040. return -ENOMEM;
  1041. }
  1042. return 0;
  1043. }
  1044. module_init(rs68328_init);
  1045. static void m68328_set_baud(void)
  1046. {
  1047. unsigned short ustcnt;
  1048. int i;
  1049. ustcnt = USTCNT;
  1050. USTCNT = ustcnt & ~USTCNT_TXEN;
  1051. again:
  1052. for (i = 0; i < ARRAY_SIZE(baud_table); i++)
  1053. if (baud_table[i] == m68328_console_baud)
  1054. break;
  1055. if (i >= ARRAY_SIZE(baud_table)) {
  1056. m68328_console_baud = 9600;
  1057. goto again;
  1058. }
  1059. UBAUD = PUT_FIELD(UBAUD_DIVIDE, hw_baud_table[i].divisor) |
  1060. PUT_FIELD(UBAUD_PRESCALER, hw_baud_table[i].prescale);
  1061. ustcnt &= ~(USTCNT_PARITYEN | USTCNT_ODD_EVEN | USTCNT_STOP | USTCNT_8_7);
  1062. ustcnt |= USTCNT_8_7;
  1063. ustcnt |= USTCNT_TXEN;
  1064. USTCNT = ustcnt;
  1065. m68328_console_initted = 1;
  1066. return;
  1067. }
  1068. int m68328_console_setup(struct console *cp, char *arg)
  1069. {
  1070. int i, n = CONSOLE_BAUD_RATE;
  1071. if (!cp)
  1072. return(-1);
  1073. if (arg)
  1074. n = simple_strtoul(arg,NULL,0);
  1075. for (i = 0; i < ARRAY_SIZE(baud_table); i++)
  1076. if (baud_table[i] == n)
  1077. break;
  1078. if (i < ARRAY_SIZE(baud_table)) {
  1079. m68328_console_baud = n;
  1080. m68328_console_cbaud = 0;
  1081. if (i > 15) {
  1082. m68328_console_cbaud |= CBAUDEX;
  1083. i -= 15;
  1084. }
  1085. m68328_console_cbaud |= i;
  1086. }
  1087. m68328_set_baud(); /* make sure baud rate changes */
  1088. return(0);
  1089. }
  1090. static struct tty_driver *m68328_console_device(struct console *c, int *index)
  1091. {
  1092. *index = c->index;
  1093. return serial_driver;
  1094. }
  1095. void m68328_console_write (struct console *co, const char *str,
  1096. unsigned int count)
  1097. {
  1098. if (!m68328_console_initted)
  1099. m68328_set_baud();
  1100. while (count--) {
  1101. if (*str == '\n')
  1102. rs_put_char('\r');
  1103. rs_put_char( *str++ );
  1104. }
  1105. }
  1106. static struct console m68328_driver = {
  1107. .name = "ttyS",
  1108. .write = m68328_console_write,
  1109. .device = m68328_console_device,
  1110. .setup = m68328_console_setup,
  1111. .flags = CON_PRINTBUFFER,
  1112. .index = -1,
  1113. };
  1114. static int __init m68328_console_init(void)
  1115. {
  1116. register_console(&m68328_driver);
  1117. return 0;
  1118. }
  1119. console_initcall(m68328_console_init);