serial.h
上传用户:jlfgdled
上传日期:2013-04-10
资源大小:33168k
文件大小:12k
源码类别:

Linux/Unix编程

开发平台:

Unix_Linux

  1. /*
  2.  * This file is subject to the terms and conditions of the GNU General Public
  3.  * License.  See the file "COPYING" in the main directory of this archive
  4.  * for more details.
  5.  *
  6.  * Copyright (C) 1999 by Ralf Baechle
  7.  * Copyright (C) 1999, 2000 Silicon Graphics, Inc.
  8.  */
  9. #include <linux/config.h>
  10. #include <asm/jazz.h>
  11. /*
  12.  * This assumes you have a 1.8432 MHz clock for your UART.
  13.  *
  14.  * It'd be nice if someone built a serial card with a 24.576 MHz
  15.  * clock, since the 16550A is capable of handling a top speed of 1.5
  16.  * megabits/second; but this requires the faster clock.
  17.  */
  18. #define BASE_BAUD ( 1843200 / 16 )
  19. #ifndef CONFIG_OLIVETTI_M700
  20.    /* Some Jazz machines seem to have an 8MHz crystal clock but I don't know
  21.       exactly which ones ... XXX */
  22. #define JAZZ_BASE_BAUD ( 8000000 / 16 ) /* ( 3072000 / 16) */
  23. #else
  24. /* but the M700 isn't such a strange beast */
  25. #define JAZZ_BASE_BAUD BASE_BAUD
  26. #endif
  27. /* Standard COM flags (except for COM4, because of the 8514 problem) */
  28. #ifdef CONFIG_SERIAL_DETECT_IRQ
  29. #define STD_COM_FLAGS (ASYNC_BOOT_AUTOCONF | ASYNC_SKIP_TEST | ASYNC_AUTO_IRQ)
  30. #define STD_COM4_FLAGS (ASYNC_BOOT_AUTOCONF | ASYNC_AUTO_IRQ)
  31. #else
  32. #define STD_COM_FLAGS (ASYNC_BOOT_AUTOCONF | ASYNC_SKIP_TEST)
  33. #define STD_COM4_FLAGS ASYNC_BOOT_AUTOCONF
  34. #endif
  35. #ifdef CONFIG_SERIAL_MANY_PORTS
  36. #define FOURPORT_FLAGS ASYNC_FOURPORT
  37. #define ACCENT_FLAGS 0
  38. #define BOCA_FLAGS 0
  39. #define HUB6_FLAGS 0
  40. #define RS_TABLE_SIZE 64
  41. #else
  42. #define RS_TABLE_SIZE
  43. #endif
  44. /*
  45.  * The following define the access methods for the HUB6 card. All
  46.  * access is through two ports for all 24 possible chips. The card is
  47.  * selected through the high 2 bits, the port on that card with the
  48.  * "middle" 3 bits, and the register on that port with the bottom
  49.  * 3 bits.
  50.  *
  51.  * While the access port and interrupt is configurable, the default
  52.  * port locations are 0x302 for the port control register, and 0x303
  53.  * for the data read/write register. Normally, the interrupt is at irq3
  54.  * but can be anything from 3 to 7 inclusive. Note that using 3 will
  55.  * require disabling com2.
  56.  */
  57. #define C_P(card,port) (((card)<<6|(port)<<3) + 1)
  58. #ifdef CONFIG_MIPS_JAZZ
  59. #define _JAZZ_SERIAL_INIT(int, base)
  60. { baud_base: JAZZ_BASE_BAUD, irq: int, flags: STD_COM_FLAGS,
  61.   iomem_base: (u8 *) base, iomem_reg_shift: 0,
  62.   io_type: SERIAL_IO_MEM }
  63. #define JAZZ_SERIAL_PORT_DEFNS
  64. _JAZZ_SERIAL_INIT(JAZZ_SERIAL1_IRQ, JAZZ_SERIAL1_BASE),
  65. _JAZZ_SERIAL_INIT(JAZZ_SERIAL2_IRQ, JAZZ_SERIAL2_BASE),
  66. #else
  67. #define JAZZ_SERIAL_PORT_DEFNS
  68. #endif
  69. #ifdef CONFIG_MIPS_ATLAS
  70. #include <asm/mips-boards/atlas.h>
  71. #include <asm/mips-boards/atlasint.h>
  72. #define ATLAS_SERIAL_PORT_DEFNS
  73. /* UART CLK   PORT IRQ     FLAGS        */
  74. { 0, ATLAS_BASE_BAUD, ATLAS_UART_REGS_BASE, ATLASINT_UART, STD_COM_FLAGS },     /* ttyS0 */
  75. #else
  76. #define ATLAS_SERIAL_PORT_DEFNS
  77. #endif
  78. #ifdef CONFIG_MIPS_SEAD
  79. #include <asm/mips-boards/sead.h>
  80. #include <asm/mips-boards/seadint.h>
  81. #define SEAD_SERIAL_PORT_DEFNS
  82. /* UART CLK   PORT IRQ     FLAGS        */
  83. { 0, SEAD_BASE_BAUD, SEAD_UART0_REGS_BASE, SEADINT_UART0, STD_COM_FLAGS },     /* ttyS0 */
  84. #else
  85. #define SEAD_SERIAL_PORT_DEFNS
  86. #endif
  87. #ifdef CONFIG_MIPS_COBALT
  88. #include <asm/cobalt/cobalt.h>
  89. #define COBALT_BASE_BAUD  (18432000 / 16)
  90. #define COBALT_SERIAL_PORT_DEFNS
  91. /* UART CLK   PORT  IRQ  FLAGS    */ 
  92. { 0, COBALT_BASE_BAUD, 0xc800000, COBALT_SERIAL_IRQ, STD_COM_FLAGS },   /* ttyS0 */
  93. #else
  94. #define COBALT_SERIAL_PORT_DEFNS
  95. #endif
  96. /*
  97.  * Both Galileo boards have the same UART mappings.
  98.  */
  99. #if defined (CONFIG_MIPS_EV96100) || defined (CONFIG_MIPS_EV64120)
  100. #include <asm/galileo-boards/ev96100.h>
  101. #include <asm/galileo-boards/ev96100int.h>
  102. #define EV96100_SERIAL_PORT_DEFNS                                  
  103.     { baud_base: EV96100_BASE_BAUD, irq: EV96100INT_UART_0, 
  104.       flags: STD_COM_FLAGS,  
  105.       iomem_base: EV96100_UART0_REGS_BASE, iomem_reg_shift: 2, 
  106.       io_type: SERIAL_IO_MEM }, 
  107.     { baud_base: EV96100_BASE_BAUD, irq: EV96100INT_UART_0, 
  108.       flags: STD_COM_FLAGS, 
  109.       iomem_base: EV96100_UART1_REGS_BASE, iomem_reg_shift: 2, 
  110.       io_type: SERIAL_IO_MEM },
  111. #else
  112. #define EV96100_SERIAL_PORT_DEFNS
  113. #endif
  114. #ifdef CONFIG_MIPS_ITE8172
  115. #include <asm/it8172/it8172.h>
  116. #include <asm/it8172/it8172_int.h>
  117. #include <asm/it8712.h>
  118. #define ITE_SERIAL_PORT_DEFNS                                  
  119.     { baud_base: BASE_BAUD, port: (IT8172_PCI_IO_BASE + IT_UART_BASE), 
  120.       irq: IT8172_UART_IRQ, flags: STD_COM_FLAGS, type: 0x3 }, 
  121.     { baud_base: (24000000/(16*13)), port: (IT8172_PCI_IO_BASE + IT8712_UART1_PORT), 
  122.       irq: IT8172_SERIRQ_4, flags: STD_COM_FLAGS, type: 0x3 }, 
  123.     /* Smart Card Reader 0 */ 
  124.     { baud_base: BASE_BAUD, port: (IT8172_PCI_IO_BASE + IT_SCR0_BASE), 
  125.       irq: IT8172_SCR0_IRQ, flags: STD_COM_FLAGS, type: 0x3 }, 
  126.     /* Smart Card Reader 1 */ 
  127.     { baud_base: BASE_BAUD, port: (IT8172_PCI_IO_BASE + IT_SCR1_BASE), 
  128.       irq: IT8172_SCR1_IRQ, flags: STD_COM_FLAGS, type: 0x3 },
  129. #else
  130. #define ITE_SERIAL_PORT_DEFNS
  131. #endif
  132. #ifdef CONFIG_MIPS_IVR
  133. #include <asm/it8172/it8172.h>
  134. #include <asm/it8172/it8172_int.h>
  135. #define IVR_SERIAL_PORT_DEFNS                                  
  136.     { baud_base: BASE_BAUD, port: (IT8172_PCI_IO_BASE + IT_UART_BASE), 
  137.       irq: IT8172_UART_IRQ, flags: STD_COM_FLAGS, type: 0x3 },         
  138.     /* Smart Card Reader 1 */ 
  139.     { baud_base: BASE_BAUD, port: (IT8172_PCI_IO_BASE + IT_SCR1_BASE), 
  140.       irq: IT8172_SCR1_IRQ, flags: STD_COM_FLAGS, type: 0x3 },
  141. #else
  142. #define IVR_SERIAL_PORT_DEFNS
  143. #endif
  144. #ifdef CONFIG_AU1000_UART
  145. #include <asm/au1000.h>
  146. #define AU1000_SERIAL_PORT_DEFNS                              
  147.     { baud_base: 0, port: UART0_ADDR, irq: AU1000_UART0_INT,  
  148.       flags: STD_COM_FLAGS, type: 1 },                        
  149.     { baud_base: 0, port: UART1_ADDR, irq: AU1000_UART1_INT,  
  150.       flags: STD_COM_FLAGS, type: 1 },     
  151.     { baud_base: 0, port: UART2_ADDR, irq: AU1000_UART2_INT,  
  152.       flags: STD_COM_FLAGS, type: 1 },    
  153.     { baud_base: 0, port: UART3_ADDR, irq: AU1000_UART3_INT,  
  154.       flags: STD_COM_FLAGS, type: 1 },
  155. #else
  156. #define AU1000_SERIAL_PORT_DEFNS
  157. #endif
  158. #ifdef CONFIG_TOSHIBA_JMR3927
  159. #include <asm/jmr3927/jmr3927.h>
  160. #define TXX927_SERIAL_PORT_DEFNS                              
  161.     { baud_base: JMR3927_BASE_BAUD, port: UART0_ADDR, irq: UART0_INT,  
  162.       flags: UART0_FLAGS, type: 1 },                        
  163.     { baud_base: JMR3927_BASE_BAUD, port: UART1_ADDR, irq: UART1_INT,  
  164.       flags: UART1_FLAGS, type: 1 },
  165. #else
  166. #define TXX927_SERIAL_PORT_DEFNS
  167. #endif
  168. #ifdef CONFIG_HAVE_STD_PC_SERIAL_PORT
  169. #define STD_SERIAL_PORT_DEFNS
  170. /* UART CLK   PORT IRQ     FLAGS        */
  171. { 0, BASE_BAUD, 0x3F8, 4, STD_COM_FLAGS }, /* ttyS0 */
  172. { 0, BASE_BAUD, 0x2F8, 3, STD_COM_FLAGS }, /* ttyS1 */
  173. { 0, BASE_BAUD, 0x3E8, 4, STD_COM_FLAGS }, /* ttyS2 */
  174. { 0, BASE_BAUD, 0x2E8, 3, STD_COM4_FLAGS }, /* ttyS3 */
  175. #ifdef CONFIG_SERIAL_MANY_PORTS
  176. #define EXTRA_SERIAL_PORT_DEFNS
  177. { 0, BASE_BAUD, 0x1A0, 9, FOURPORT_FLAGS },  /* ttyS4 */
  178. { 0, BASE_BAUD, 0x1A8, 9, FOURPORT_FLAGS }, /* ttyS5 */
  179. { 0, BASE_BAUD, 0x1B0, 9, FOURPORT_FLAGS }, /* ttyS6 */
  180. { 0, BASE_BAUD, 0x1B8, 9, FOURPORT_FLAGS }, /* ttyS7 */
  181. { 0, BASE_BAUD, 0x2A0, 5, FOURPORT_FLAGS }, /* ttyS8 */
  182. { 0, BASE_BAUD, 0x2A8, 5, FOURPORT_FLAGS }, /* ttyS9 */
  183. { 0, BASE_BAUD, 0x2B0, 5, FOURPORT_FLAGS }, /* ttyS10 */
  184. { 0, BASE_BAUD, 0x2B8, 5, FOURPORT_FLAGS }, /* ttyS11 */
  185. { 0, BASE_BAUD, 0x330, 4, ACCENT_FLAGS }, /* ttyS12 */
  186. { 0, BASE_BAUD, 0x338, 4, ACCENT_FLAGS }, /* ttyS13 */
  187. { 0, BASE_BAUD, 0x000, 0, 0 }, /* ttyS14 (spare) */ 
  188. { 0, BASE_BAUD, 0x000, 0, 0 }, /* ttyS15 (spare) */ 
  189. { 0, BASE_BAUD, 0x100, 12, BOCA_FLAGS }, /* ttyS16 */
  190. { 0, BASE_BAUD, 0x108, 12, BOCA_FLAGS }, /* ttyS17 */
  191. { 0, BASE_BAUD, 0x110, 12, BOCA_FLAGS }, /* ttyS18 */
  192. { 0, BASE_BAUD, 0x118, 12, BOCA_FLAGS }, /* ttyS19 */
  193. { 0, BASE_BAUD, 0x120, 12, BOCA_FLAGS }, /* ttyS20 */
  194. { 0, BASE_BAUD, 0x128, 12, BOCA_FLAGS }, /* ttyS21 */
  195. { 0, BASE_BAUD, 0x130, 12, BOCA_FLAGS }, /* ttyS22 */
  196. { 0, BASE_BAUD, 0x138, 12, BOCA_FLAGS }, /* ttyS23 */
  197. { 0, BASE_BAUD, 0x140, 12, BOCA_FLAGS }, /* ttyS24 */
  198. { 0, BASE_BAUD, 0x148, 12, BOCA_FLAGS }, /* ttyS25 */
  199. { 0, BASE_BAUD, 0x150, 12, BOCA_FLAGS }, /* ttyS26 */
  200. { 0, BASE_BAUD, 0x158, 12, BOCA_FLAGS }, /* ttyS27 */
  201. { 0, BASE_BAUD, 0x160, 12, BOCA_FLAGS }, /* ttyS28 */
  202. { 0, BASE_BAUD, 0x168, 12, BOCA_FLAGS }, /* ttyS29 */
  203. { 0, BASE_BAUD, 0x170, 12, BOCA_FLAGS }, /* ttyS30 */
  204. { 0, BASE_BAUD, 0x178, 12, BOCA_FLAGS }, /* ttyS31 */
  205. #else /* CONFIG_SERIAL_MANY_PORTS */
  206. #define EXTRA_SERIAL_PORT_DEFNS
  207. #endif /* CONFIG_SERIAL_MANY_PORTS */
  208. #else /* CONFIG_HAVE_STD_PC_SERIAL_PORTS */
  209. #define STD_SERIAL_PORT_DEFNS
  210. #define EXTRA_SERIAL_PORT_DEFNS
  211. #endif /* CONFIG_HAVE_STD_PC_SERIAL_PORTS */
  212. /* You can have up to four HUB6's in the system, but I've only
  213.  * included two cards here for a total of twelve ports.
  214.  */
  215. #if (defined(CONFIG_HUB6) && defined(CONFIG_SERIAL_MANY_PORTS))
  216. #define HUB6_SERIAL_PORT_DFNS
  217. { 0, BASE_BAUD, 0x302, 3, HUB6_FLAGS, C_P(0,0) },  /* ttyS32 */
  218. { 0, BASE_BAUD, 0x302, 3, HUB6_FLAGS, C_P(0,1) },  /* ttyS33 */
  219. { 0, BASE_BAUD, 0x302, 3, HUB6_FLAGS, C_P(0,2) },  /* ttyS34 */
  220. { 0, BASE_BAUD, 0x302, 3, HUB6_FLAGS, C_P(0,3) },  /* ttyS35 */
  221. { 0, BASE_BAUD, 0x302, 3, HUB6_FLAGS, C_P(0,4) },  /* ttyS36 */
  222. { 0, BASE_BAUD, 0x302, 3, HUB6_FLAGS, C_P(0,5) },  /* ttyS37 */
  223. { 0, BASE_BAUD, 0x302, 3, HUB6_FLAGS, C_P(1,0) },  /* ttyS38 */
  224. { 0, BASE_BAUD, 0x302, 3, HUB6_FLAGS, C_P(1,1) },  /* ttyS39 */
  225. { 0, BASE_BAUD, 0x302, 3, HUB6_FLAGS, C_P(1,2) },  /* ttyS40 */
  226. { 0, BASE_BAUD, 0x302, 3, HUB6_FLAGS, C_P(1,3) },  /* ttyS41 */
  227. { 0, BASE_BAUD, 0x302, 3, HUB6_FLAGS, C_P(1,4) },  /* ttyS42 */
  228. { 0, BASE_BAUD, 0x302, 3, HUB6_FLAGS, C_P(1,5) },  /* ttyS43 */
  229. #else
  230. #define HUB6_SERIAL_PORT_DFNS
  231. #endif
  232. #ifdef CONFIG_MCA
  233. #define MCA_SERIAL_PORT_DFNS
  234. { 0, BASE_BAUD, 0x3220, 3, STD_COM_FLAGS },
  235. { 0, BASE_BAUD, 0x3228, 3, STD_COM_FLAGS },
  236. { 0, BASE_BAUD, 0x4220, 3, STD_COM_FLAGS },
  237. { 0, BASE_BAUD, 0x4228, 3, STD_COM_FLAGS },
  238. { 0, BASE_BAUD, 0x5220, 3, STD_COM_FLAGS },
  239. { 0, BASE_BAUD, 0x5228, 3, STD_COM_FLAGS },
  240. #else
  241. #define MCA_SERIAL_PORT_DFNS
  242. #endif
  243. #ifdef CONFIG_MOMENCO_OCELOT
  244. /* Ordinary NS16552 duart with a 20MHz crystal.  */
  245. #define OCELOT_BASE_BAUD ( 20000000 / 16 )
  246. #define OCELOT_SERIAL1_IRQ 4
  247. #define OCELOT_SERIAL1_BASE 0xe0001020
  248. #define _OCELOT_SERIAL_INIT(int, base)
  249. { baud_base: OCELOT_BASE_BAUD, irq: int, flags: STD_COM_FLAGS,
  250.   iomem_base: (u8 *) base, iomem_reg_shift: 2,
  251.   io_type: SERIAL_IO_MEM }
  252. #define MOMENCO_OCELOT_SERIAL_PORT_DEFNS
  253. _OCELOT_SERIAL_INIT(OCELOT_SERIAL1_IRQ, OCELOT_SERIAL1_BASE)
  254. #else
  255. #define MOMENCO_OCELOT_SERIAL_PORT_DEFNS
  256. #endif
  257. #ifdef CONFIG_MOMENCO_OCELOT_G
  258. /* Ordinary NS16552 duart with a 20MHz crystal.  */
  259. #define OCELOT_G_BASE_BAUD ( 20000000 / 16 )
  260. #define OCELOT_G_SERIAL1_IRQ 4
  261. #if 0
  262. #define OCELOT_G_SERIAL1_BASE 0xe0001020
  263. #else
  264. #define OCELOT_G_SERIAL1_BASE 0xfd000020
  265. #endif
  266. #define _OCELOT_G_SERIAL_INIT(int, base)
  267. { baud_base: OCELOT_G_BASE_BAUD, irq: int, flags: STD_COM_FLAGS,
  268.   iomem_base: (u8 *) base, iomem_reg_shift: 2,
  269.   io_type: SERIAL_IO_MEM }
  270. #define MOMENCO_OCELOT_G_SERIAL_PORT_DEFNS
  271. _OCELOT_G_SERIAL_INIT(OCELOT_G_SERIAL1_IRQ, OCELOT_G_SERIAL1_BASE)
  272. #else
  273. #define MOMENCO_OCELOT_G_SERIAL_PORT_DEFNS
  274. #endif
  275. #ifdef CONFIG_DDB5477
  276. #include <asm/ddb5xxx/ddb5477.h>
  277. #define DDB5477_SERIAL_PORT_DEFNS                                             
  278.         { baud_base: BASE_BAUD, irq: VRC5477_IRQ_UART0, flags: STD_COM_FLAGS, 
  279.           iomem_base: (u8*)0xbfa04200, iomem_reg_shift: 3,                    
  280.           io_type: SERIAL_IO_MEM},
  281.         { baud_base: BASE_BAUD, irq: VRC5477_IRQ_UART1, flags: STD_COM_FLAGS, 
  282.           iomem_base: (u8*)0xbfa04240, iomem_reg_shift: 3,                    
  283.           io_type: SERIAL_IO_MEM},
  284. #else
  285. #define DDB5477_SERIAL_PORT_DEFNS
  286. #endif
  287. #define SERIAL_PORT_DFNS
  288. IVR_SERIAL_PORT_DEFNS           
  289. ITE_SERIAL_PORT_DEFNS           
  290. ATLAS_SERIAL_PORT_DEFNS
  291. SEAD_SERIAL_PORT_DEFNS
  292. COBALT_SERIAL_PORT_DEFNS
  293. EV96100_SERIAL_PORT_DEFNS
  294. JAZZ_SERIAL_PORT_DEFNS
  295. STD_SERIAL_PORT_DEFNS
  296. EXTRA_SERIAL_PORT_DEFNS
  297. HUB6_SERIAL_PORT_DFNS
  298. MOMENCO_OCELOT_SERIAL_PORT_DEFNS
  299. MOMENCO_OCELOT_G_SERIAL_PORT_DEFNS
  300. AU1000_SERIAL_PORT_DEFNS
  301.         TXX927_SERIAL_PORT_DEFNS        
  302. DDB5477_SERIAL_PORT_DEFNS