200-amba_pl010_hacks.patch 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377
  1. --- a/drivers/tty/serial/amba-pl010.c
  2. +++ b/drivers/tty/serial/amba-pl010.c
  3. @@ -48,11 +48,10 @@
  4. #include <linux/slab.h>
  5. #include <linux/io.h>
  6. -#define UART_NR 8
  7. -
  8. #define SERIAL_AMBA_MAJOR 204
  9. #define SERIAL_AMBA_MINOR 16
  10. -#define SERIAL_AMBA_NR UART_NR
  11. +#define SERIAL_AMBA_NR CONFIG_SERIAL_AMBA_PL010_NUMPORTS
  12. +#define SERIAL_AMBA_NAME CONFIG_SERIAL_AMBA_PL010_PORTNAME
  13. #define AMBA_ISR_PASS_LIMIT 256
  14. @@ -78,9 +77,9 @@ static void pl010_stop_tx(struct uart_po
  15. struct uart_amba_port *uap = (struct uart_amba_port *)port;
  16. unsigned int cr;
  17. - cr = readb(uap->port.membase + UART010_CR);
  18. + cr = __raw_readl(uap->port.membase + UART010_CR);
  19. cr &= ~UART010_CR_TIE;
  20. - writel(cr, uap->port.membase + UART010_CR);
  21. + __raw_writel(cr, uap->port.membase + UART010_CR);
  22. }
  23. static void pl010_start_tx(struct uart_port *port)
  24. @@ -88,9 +87,9 @@ static void pl010_start_tx(struct uart_p
  25. struct uart_amba_port *uap = (struct uart_amba_port *)port;
  26. unsigned int cr;
  27. - cr = readb(uap->port.membase + UART010_CR);
  28. + cr = __raw_readl(uap->port.membase + UART010_CR);
  29. cr |= UART010_CR_TIE;
  30. - writel(cr, uap->port.membase + UART010_CR);
  31. + __raw_writel(cr, uap->port.membase + UART010_CR);
  32. }
  33. static void pl010_stop_rx(struct uart_port *port)
  34. @@ -98,9 +97,9 @@ static void pl010_stop_rx(struct uart_po
  35. struct uart_amba_port *uap = (struct uart_amba_port *)port;
  36. unsigned int cr;
  37. - cr = readb(uap->port.membase + UART010_CR);
  38. + cr = __raw_readl(uap->port.membase + UART010_CR);
  39. cr &= ~(UART010_CR_RIE | UART010_CR_RTIE);
  40. - writel(cr, uap->port.membase + UART010_CR);
  41. + __raw_writel(cr, uap->port.membase + UART010_CR);
  42. }
  43. static void pl010_enable_ms(struct uart_port *port)
  44. @@ -108,18 +107,18 @@ static void pl010_enable_ms(struct uart_
  45. struct uart_amba_port *uap = (struct uart_amba_port *)port;
  46. unsigned int cr;
  47. - cr = readb(uap->port.membase + UART010_CR);
  48. + cr = __raw_readl(uap->port.membase + UART010_CR);
  49. cr |= UART010_CR_MSIE;
  50. - writel(cr, uap->port.membase + UART010_CR);
  51. + __raw_writel(cr, uap->port.membase + UART010_CR);
  52. }
  53. static void pl010_rx_chars(struct uart_amba_port *uap)
  54. {
  55. unsigned int status, ch, flag, rsr, max_count = 256;
  56. - status = readb(uap->port.membase + UART01x_FR);
  57. + status = __raw_readl(uap->port.membase + UART01x_FR);
  58. while (UART_RX_DATA(status) && max_count--) {
  59. - ch = readb(uap->port.membase + UART01x_DR);
  60. + ch = __raw_readl(uap->port.membase + UART01x_DR);
  61. flag = TTY_NORMAL;
  62. uap->port.icount.rx++;
  63. @@ -128,9 +127,9 @@ static void pl010_rx_chars(struct uart_a
  64. * Note that the error handling code is
  65. * out of the main execution path
  66. */
  67. - rsr = readb(uap->port.membase + UART01x_RSR) | UART_DUMMY_RSR_RX;
  68. + rsr = __raw_readl(uap->port.membase + UART01x_RSR) | UART_DUMMY_RSR_RX;
  69. if (unlikely(rsr & UART01x_RSR_ANY)) {
  70. - writel(0, uap->port.membase + UART01x_ECR);
  71. + __raw_writel(0, uap->port.membase + UART01x_ECR);
  72. if (rsr & UART01x_RSR_BE) {
  73. rsr &= ~(UART01x_RSR_FE | UART01x_RSR_PE);
  74. @@ -160,7 +159,7 @@ static void pl010_rx_chars(struct uart_a
  75. uart_insert_char(&uap->port, rsr, UART01x_RSR_OE, ch, flag);
  76. ignore_char:
  77. - status = readb(uap->port.membase + UART01x_FR);
  78. + status = __raw_readl(uap->port.membase + UART01x_FR);
  79. }
  80. spin_unlock(&uap->port.lock);
  81. tty_flip_buffer_push(&uap->port.state->port);
  82. @@ -173,7 +172,7 @@ static void pl010_tx_chars(struct uart_a
  83. int count;
  84. if (uap->port.x_char) {
  85. - writel(uap->port.x_char, uap->port.membase + UART01x_DR);
  86. + __raw_writel(uap->port.x_char, uap->port.membase + UART01x_DR);
  87. uap->port.icount.tx++;
  88. uap->port.x_char = 0;
  89. return;
  90. @@ -185,7 +184,7 @@ static void pl010_tx_chars(struct uart_a
  91. count = uap->port.fifosize >> 1;
  92. do {
  93. - writel(xmit->buf[xmit->tail], uap->port.membase + UART01x_DR);
  94. + __raw_writel(xmit->buf[xmit->tail], uap->port.membase + UART01x_DR);
  95. xmit->tail = (xmit->tail + 1) & (UART_XMIT_SIZE - 1);
  96. uap->port.icount.tx++;
  97. if (uart_circ_empty(xmit))
  98. @@ -203,9 +202,9 @@ static void pl010_modem_status(struct ua
  99. {
  100. unsigned int status, delta;
  101. - writel(0, uap->port.membase + UART010_ICR);
  102. + __raw_writel(0, uap->port.membase + UART010_ICR);
  103. - status = readb(uap->port.membase + UART01x_FR) & UART01x_FR_MODEM_ANY;
  104. + status = __raw_readl(uap->port.membase + UART01x_FR) & UART01x_FR_MODEM_ANY;
  105. delta = status ^ uap->old_status;
  106. uap->old_status = status;
  107. @@ -233,7 +232,7 @@ static irqreturn_t pl010_int(int irq, vo
  108. spin_lock(&uap->port.lock);
  109. - status = readb(uap->port.membase + UART010_IIR);
  110. + status = __raw_readl(uap->port.membase + UART010_IIR);
  111. if (status) {
  112. do {
  113. if (status & (UART010_IIR_RTIS | UART010_IIR_RIS))
  114. @@ -246,7 +245,7 @@ static irqreturn_t pl010_int(int irq, vo
  115. if (pass_counter-- == 0)
  116. break;
  117. - status = readb(uap->port.membase + UART010_IIR);
  118. + status = __raw_readl(uap->port.membase + UART010_IIR);
  119. } while (status & (UART010_IIR_RTIS | UART010_IIR_RIS |
  120. UART010_IIR_TIS));
  121. handled = 1;
  122. @@ -260,7 +259,7 @@ static irqreturn_t pl010_int(int irq, vo
  123. static unsigned int pl010_tx_empty(struct uart_port *port)
  124. {
  125. struct uart_amba_port *uap = (struct uart_amba_port *)port;
  126. - unsigned int status = readb(uap->port.membase + UART01x_FR);
  127. + unsigned int status = __raw_readl(uap->port.membase + UART01x_FR);
  128. return status & UART01x_FR_BUSY ? 0 : TIOCSER_TEMT;
  129. }
  130. @@ -270,7 +269,7 @@ static unsigned int pl010_get_mctrl(stru
  131. unsigned int result = 0;
  132. unsigned int status;
  133. - status = readb(uap->port.membase + UART01x_FR);
  134. + status = __raw_readl(uap->port.membase + UART01x_FR);
  135. if (status & UART01x_FR_DCD)
  136. result |= TIOCM_CAR;
  137. if (status & UART01x_FR_DSR)
  138. @@ -296,12 +295,12 @@ static void pl010_break_ctl(struct uart_
  139. unsigned int lcr_h;
  140. spin_lock_irqsave(&uap->port.lock, flags);
  141. - lcr_h = readb(uap->port.membase + UART010_LCRH);
  142. + lcr_h = __raw_readl(uap->port.membase + UART010_LCRH);
  143. if (break_state == -1)
  144. lcr_h |= UART01x_LCRH_BRK;
  145. else
  146. lcr_h &= ~UART01x_LCRH_BRK;
  147. - writel(lcr_h, uap->port.membase + UART010_LCRH);
  148. + __raw_writel(lcr_h, uap->port.membase + UART010_LCRH);
  149. spin_unlock_irqrestore(&uap->port.lock, flags);
  150. }
  151. @@ -329,12 +328,12 @@ static int pl010_startup(struct uart_por
  152. /*
  153. * initialise the old status of the modem signals
  154. */
  155. - uap->old_status = readb(uap->port.membase + UART01x_FR) & UART01x_FR_MODEM_ANY;
  156. + uap->old_status = __raw_readl(uap->port.membase + UART01x_FR) & UART01x_FR_MODEM_ANY;
  157. /*
  158. * Finally, enable interrupts
  159. */
  160. - writel(UART01x_CR_UARTEN | UART010_CR_RIE | UART010_CR_RTIE,
  161. + __raw_writel(UART01x_CR_UARTEN | UART010_CR_RIE | UART010_CR_RTIE,
  162. uap->port.membase + UART010_CR);
  163. return 0;
  164. @@ -357,10 +356,10 @@ static void pl010_shutdown(struct uart_p
  165. /*
  166. * disable all interrupts, disable the port
  167. */
  168. - writel(0, uap->port.membase + UART010_CR);
  169. + __raw_writel(0, uap->port.membase + UART010_CR);
  170. /* disable break condition and fifos */
  171. - writel(readb(uap->port.membase + UART010_LCRH) &
  172. + __raw_writel(__raw_readl(uap->port.membase + UART010_LCRH) &
  173. ~(UART01x_LCRH_BRK | UART01x_LCRH_FEN),
  174. uap->port.membase + UART010_LCRH);
  175. @@ -382,7 +381,7 @@ pl010_set_termios(struct uart_port *port
  176. /*
  177. * Ask the core to calculate the divisor for us.
  178. */
  179. - baud = uart_get_baud_rate(port, termios, old, 0, uap->port.uartclk/16);
  180. + baud = uart_get_baud_rate(port, termios, old, 0, uap->port.uartclk/16);
  181. quot = uart_get_divisor(port, baud);
  182. switch (termios->c_cflag & CSIZE) {
  183. @@ -445,25 +444,25 @@ pl010_set_termios(struct uart_port *port
  184. uap->port.ignore_status_mask |= UART_DUMMY_RSR_RX;
  185. /* first, disable everything */
  186. - old_cr = readb(uap->port.membase + UART010_CR) & ~UART010_CR_MSIE;
  187. + old_cr = __raw_readl(uap->port.membase + UART010_CR) & ~UART010_CR_MSIE;
  188. if (UART_ENABLE_MS(port, termios->c_cflag))
  189. old_cr |= UART010_CR_MSIE;
  190. - writel(0, uap->port.membase + UART010_CR);
  191. + __raw_writel(0, uap->port.membase + UART010_CR);
  192. /* Set baud rate */
  193. quot -= 1;
  194. - writel((quot & 0xf00) >> 8, uap->port.membase + UART010_LCRM);
  195. - writel(quot & 0xff, uap->port.membase + UART010_LCRL);
  196. + __raw_writel((quot & 0xf00) >> 8, uap->port.membase + UART010_LCRM);
  197. + __raw_writel(quot & 0xff, uap->port.membase + UART010_LCRL);
  198. /*
  199. * ----------v----------v----------v----------v-----
  200. * NOTE: MUST BE WRITTEN AFTER UARTLCR_M & UARTLCR_L
  201. * ----------^----------^----------^----------^-----
  202. */
  203. - writel(lcr_h, uap->port.membase + UART010_LCRH);
  204. - writel(old_cr, uap->port.membase + UART010_CR);
  205. + __raw_writel(lcr_h, uap->port.membase + UART010_LCRH);
  206. + __raw_writel(old_cr, uap->port.membase + UART010_CR);
  207. spin_unlock_irqrestore(&uap->port.lock, flags);
  208. }
  209. @@ -545,7 +544,7 @@ static struct uart_ops amba_pl010_pops =
  210. .verify_port = pl010_verify_port,
  211. };
  212. -static struct uart_amba_port *amba_ports[UART_NR];
  213. +static struct uart_amba_port *amba_ports[SERIAL_AMBA_NR];
  214. #ifdef CONFIG_SERIAL_AMBA_PL010_CONSOLE
  215. @@ -555,10 +554,10 @@ static void pl010_console_putchar(struct
  216. unsigned int status;
  217. do {
  218. - status = readb(uap->port.membase + UART01x_FR);
  219. + status = __raw_readl(uap->port.membase + UART01x_FR);
  220. barrier();
  221. } while (!UART_TX_READY(status));
  222. - writel(ch, uap->port.membase + UART01x_DR);
  223. + __raw_writel(ch, uap->port.membase + UART01x_DR);
  224. }
  225. static void
  226. @@ -572,8 +571,8 @@ pl010_console_write(struct console *co,
  227. /*
  228. * First save the CR then disable the interrupts
  229. */
  230. - old_cr = readb(uap->port.membase + UART010_CR);
  231. - writel(UART01x_CR_UARTEN, uap->port.membase + UART010_CR);
  232. + old_cr = __raw_readl(uap->port.membase + UART010_CR);
  233. + __raw_writel(UART01x_CR_UARTEN, uap->port.membase + UART010_CR);
  234. uart_console_write(&uap->port, s, count, pl010_console_putchar);
  235. @@ -582,10 +581,10 @@ pl010_console_write(struct console *co,
  236. * and restore the TCR
  237. */
  238. do {
  239. - status = readb(uap->port.membase + UART01x_FR);
  240. + status = __raw_readl(uap->port.membase + UART01x_FR);
  241. barrier();
  242. } while (status & UART01x_FR_BUSY);
  243. - writel(old_cr, uap->port.membase + UART010_CR);
  244. + __raw_writel(old_cr, uap->port.membase + UART010_CR);
  245. clk_disable(uap->clk);
  246. }
  247. @@ -594,9 +593,9 @@ static void __init
  248. pl010_console_get_options(struct uart_amba_port *uap, int *baud,
  249. int *parity, int *bits)
  250. {
  251. - if (readb(uap->port.membase + UART010_CR) & UART01x_CR_UARTEN) {
  252. + if (__raw_readl(uap->port.membase + UART010_CR) & UART01x_CR_UARTEN) {
  253. unsigned int lcr_h, quot;
  254. - lcr_h = readb(uap->port.membase + UART010_LCRH);
  255. + lcr_h = __raw_readl(uap->port.membase + UART010_LCRH);
  256. *parity = 'n';
  257. if (lcr_h & UART01x_LCRH_PEN) {
  258. @@ -611,8 +610,8 @@ pl010_console_get_options(struct uart_am
  259. else
  260. *bits = 8;
  261. - quot = readb(uap->port.membase + UART010_LCRL) |
  262. - readb(uap->port.membase + UART010_LCRM) << 8;
  263. + quot = __raw_readl(uap->port.membase + UART010_LCRL) |
  264. + __raw_readl(uap->port.membase + UART010_LCRM) << 8;
  265. *baud = uap->port.uartclk / (16 * (quot + 1));
  266. }
  267. }
  268. @@ -631,7 +630,7 @@ static int __init pl010_console_setup(st
  269. * if so, search for the first available port that does have
  270. * console support.
  271. */
  272. - if (co->index >= UART_NR)
  273. + if (co->index >= SERIAL_AMBA_NR)
  274. co->index = 0;
  275. uap = amba_ports[co->index];
  276. if (!uap)
  277. @@ -653,7 +652,7 @@ static int __init pl010_console_setup(st
  278. static struct uart_driver amba_reg;
  279. static struct console amba_console = {
  280. - .name = "ttyAM",
  281. + .name = SERIAL_AMBA_NAME,
  282. .write = pl010_console_write,
  283. .device = uart_console_device,
  284. .setup = pl010_console_setup,
  285. @@ -669,11 +668,11 @@ static struct console amba_console = {
  286. static struct uart_driver amba_reg = {
  287. .owner = THIS_MODULE,
  288. - .driver_name = "ttyAM",
  289. - .dev_name = "ttyAM",
  290. + .driver_name = SERIAL_AMBA_NAME,
  291. + .dev_name = SERIAL_AMBA_NAME,
  292. .major = SERIAL_AMBA_MAJOR,
  293. .minor = SERIAL_AMBA_MINOR,
  294. - .nr = UART_NR,
  295. + .nr = SERIAL_AMBA_NR,
  296. .cons = AMBA_CONSOLE,
  297. };
  298. --- a/drivers/tty/serial/Kconfig
  299. +++ b/drivers/tty/serial/Kconfig
  300. @@ -25,10 +25,25 @@ config SERIAL_AMBA_PL010
  301. help
  302. This selects the ARM(R) AMBA(R) PrimeCell PL010 UART. If you have
  303. an Integrator/AP or Integrator/PP2 platform, or if you have a
  304. - Cirrus Logic EP93xx CPU, say Y or M here.
  305. + Cirrus Logic EP93xx CPU or an Infineon ADM5120 SOC, say Y or M here.
  306. If unsure, say N.
  307. +config SERIAL_AMBA_PL010_NUMPORTS
  308. + int "Maximum number of AMBA PL010 serial ports"
  309. + depends on SERIAL_AMBA_PL010
  310. + default "8"
  311. + ---help---
  312. + Set this to the number of serial ports you want the AMBA PL010 driver
  313. + to support.
  314. +
  315. +config SERIAL_AMBA_PL010_PORTNAME
  316. + string "Name of the AMBA PL010 serial ports"
  317. + depends on SERIAL_AMBA_PL010
  318. + default "ttyAM"
  319. + ---help---
  320. + ::: To be written :::
  321. +
  322. config SERIAL_AMBA_PL010_CONSOLE
  323. bool "Support for console on AMBA serial port"
  324. depends on SERIAL_AMBA_PL010=y