Advertisement
Guest User

Untitled

a guest
Apr 9th, 2012
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 8.07 KB | None | 0 0
  1. From 17ecaf8e32f8776cac2fde546e4d70c877b82313 Mon Sep 17 00:00:00 2001
  2. From: "Govindraj.R" <govindraj.raja@ti.com>
  3. Date: Mon, 9 Apr 2012 15:16:52 +0530
  4. Subject: [PATCH] ARM: OMAP2+: UART: Fix usage of default uart pads.
  5.  
  6. The following commit:
  7. (7496ba3 ARM: OMAP2+: UART: Add default mux for all uarts)
  8. added default pads for all uarts. But not all boards tend to
  9. use all uarts and most of unused uart pins are muxed for
  10. other purpose. This commit breaks the modules which where trying
  11. to use unused uart pins on their boards.
  12.  
  13. So check for the availability of uart pins before filling the pads
  14. if both tx and rx are available as uart pins then use them for
  15. filling as default pads where rx pin is muxed dynamically for
  16. rx wakeup capability.
  17.  
  18. However the board file owners can use omap_serial_init_port
  19. and pass mux data part of board data for board specific use cases.
  20.  
  21. Cc: Felipe Balbi <balbi@ti.com>
  22. Cc: Kevin Hilman <khilman@ti.com>
  23. Reported-by: Tony Lindgren <tony@atomide.com>
  24. Signed-off-by: Govindraj.R <govindraj.raja@ti.com>
  25. ---
  26. arch/arm/mach-omap2/mux.c | 2 +-
  27. arch/arm/mach-omap2/mux.h | 10 +++
  28. arch/arm/mach-omap2/serial.c | 158 ++++++++++++------------------------------
  29. 3 files changed, 56 insertions(+), 114 deletions(-)
  30.  
  31. diff --git a/arch/arm/mach-omap2/mux.c b/arch/arm/mach-omap2/mux.c
  32. index 65c3391..5334914 100644
  33. --- a/arch/arm/mach-omap2/mux.c
  34. +++ b/arch/arm/mach-omap2/mux.c
  35. @@ -217,7 +217,7 @@ static int __init _omap_mux_get_by_name(struct omap_mux_partition *partition,
  36. return -ENODEV;
  37. }
  38.  
  39. -static int __init
  40. +int __init
  41. omap_mux_get_by_name(const char *muxname,
  42. struct omap_mux_partition **found_partition,
  43. struct omap_mux **found_mux)
  44. diff --git a/arch/arm/mach-omap2/mux.h b/arch/arm/mach-omap2/mux.h
  45. index 69fe060..461b90d 100644
  46. --- a/arch/arm/mach-omap2/mux.h
  47. +++ b/arch/arm/mach-omap2/mux.h
  48. @@ -225,8 +225,18 @@ omap_hwmod_mux_init(struct omap_device_pad *bpads, int nr_pads);
  49. */
  50. void omap_hwmod_mux(struct omap_hwmod_mux_info *hmux, u8 state);
  51.  
  52. +int omap_mux_get_by_name(const char *muxname,
  53. + struct omap_mux_partition **found_partition,
  54. + struct omap_mux **found_mux);
  55. #else
  56.  
  57. +static inline int omap_mux_get_by_name(const char *muxname,
  58. + struct omap_mux_partition **found_partition,
  59. + struct omap_mux **found_mux)
  60. +{
  61. + return 0;
  62. +}
  63. +
  64. static inline int omap_mux_init_gpio(int gpio, int val)
  65. {
  66. return 0;
  67. diff --git a/arch/arm/mach-omap2/serial.c b/arch/arm/mach-omap2/serial.c
  68. index 0cdd359..30a0f4e 100644
  69. --- a/arch/arm/mach-omap2/serial.c
  70. +++ b/arch/arm/mach-omap2/serial.c
  71. @@ -120,127 +120,59 @@ static void omap_uart_set_smartidle(struct platform_device *pdev) {}
  72. #endif /* CONFIG_PM */
  73.  
  74. #ifdef CONFIG_OMAP_MUX
  75. -static struct omap_device_pad default_uart1_pads[] __initdata = {
  76. - {
  77. - .name = "uart1_cts.uart1_cts",
  78. - .enable = OMAP_PIN_INPUT_PULLUP | OMAP_MUX_MODE0,
  79. - },
  80. - {
  81. - .name = "uart1_rts.uart1_rts",
  82. - .enable = OMAP_PIN_OUTPUT | OMAP_MUX_MODE0,
  83. - },
  84. - {
  85. - .name = "uart1_tx.uart1_tx",
  86. - .enable = OMAP_PIN_OUTPUT | OMAP_MUX_MODE0,
  87. - },
  88. - {
  89. - .name = "uart1_rx.uart1_rx",
  90. - .flags = OMAP_DEVICE_PAD_REMUX | OMAP_DEVICE_PAD_WAKEUP,
  91. - .enable = OMAP_PIN_INPUT_PULLUP | OMAP_MUX_MODE0,
  92. - .idle = OMAP_PIN_INPUT_PULLUP | OMAP_MUX_MODE0,
  93. - },
  94. -};
  95.  
  96. -static struct omap_device_pad default_uart2_pads[] __initdata = {
  97. - {
  98. - .name = "uart2_cts.uart2_cts",
  99. - .enable = OMAP_PIN_INPUT_PULLUP | OMAP_MUX_MODE0,
  100. - },
  101. - {
  102. - .name = "uart2_rts.uart2_rts",
  103. - .enable = OMAP_PIN_OUTPUT | OMAP_MUX_MODE0,
  104. - },
  105. - {
  106. - .name = "uart2_tx.uart2_tx",
  107. - .enable = OMAP_PIN_OUTPUT | OMAP_MUX_MODE0,
  108. - },
  109. - {
  110. - .name = "uart2_rx.uart2_rx",
  111. - .flags = OMAP_DEVICE_PAD_REMUX | OMAP_DEVICE_PAD_WAKEUP,
  112. - .enable = OMAP_PIN_INPUT_PULLUP | OMAP_MUX_MODE0,
  113. - .idle = OMAP_PIN_INPUT_PULLUP | OMAP_MUX_MODE0,
  114. - },
  115. -};
  116. -
  117. -static struct omap_device_pad default_uart3_pads[] __initdata = {
  118. - {
  119. - .name = "uart3_cts_rctx.uart3_cts_rctx",
  120. - .enable = OMAP_PIN_INPUT_PULLUP | OMAP_MUX_MODE0,
  121. - },
  122. - {
  123. - .name = "uart3_rts_sd.uart3_rts_sd",
  124. - .enable = OMAP_PIN_OUTPUT | OMAP_MUX_MODE0,
  125. - },
  126. - {
  127. - .name = "uart3_tx_irtx.uart3_tx_irtx",
  128. - .enable = OMAP_PIN_OUTPUT | OMAP_MUX_MODE0,
  129. - },
  130. - {
  131. - .name = "uart3_rx_irrx.uart3_rx_irrx",
  132. - .flags = OMAP_DEVICE_PAD_REMUX | OMAP_DEVICE_PAD_WAKEUP,
  133. - .enable = OMAP_PIN_INPUT | OMAP_MUX_MODE0,
  134. - .idle = OMAP_PIN_INPUT | OMAP_MUX_MODE0,
  135. - },
  136. -};
  137. +#define OMAP_UART_DEFAULT_PAD_NAME_LEN 28
  138. +static char __initdata rx_pad_name[OMAP_UART_DEFAULT_PAD_NAME_LEN],
  139. + tx_pad_name[OMAP_UART_DEFAULT_PAD_NAME_LEN];
  140.  
  141. -static struct omap_device_pad default_omap36xx_uart4_pads[] __initdata = {
  142. - {
  143. - .name = "gpmc_wait2.uart4_tx",
  144. - .enable = OMAP_PIN_OUTPUT | OMAP_MUX_MODE0,
  145. - },
  146. - {
  147. - .name = "gpmc_wait3.uart4_rx",
  148. - .flags = OMAP_DEVICE_PAD_REMUX | OMAP_DEVICE_PAD_WAKEUP,
  149. - .enable = OMAP_PIN_INPUT | OMAP_MUX_MODE2,
  150. - .idle = OMAP_PIN_INPUT | OMAP_MUX_MODE2,
  151. - },
  152. -};
  153. +static void __init omap_serial_fill_default_pads(struct omap_board_data *bdata)
  154. +{
  155. + struct omap_mux_partition *tx_partition = NULL, *rx_partition = NULL;
  156. + struct omap_mux *rx_mux = NULL, *tx_mux = NULL;
  157. + struct omap_device_pad default_omap_uart_pads[2];
  158. +
  159. + if (bdata->id != 2) {
  160. + snprintf(rx_pad_name, OMAP_UART_DEFAULT_PAD_NAME_LEN,
  161. + "uart%d_rx.uart%d_rx", bdata->id + 1, bdata->id + 1);
  162. + snprintf(tx_pad_name, OMAP_UART_DEFAULT_PAD_NAME_LEN,
  163. + "uart%d_tx.uart%d_tx", bdata->id + 1, bdata->id + 1);
  164. + } else {
  165. + snprintf(rx_pad_name, OMAP_UART_DEFAULT_PAD_NAME_LEN,
  166. + "uart%d_rx_irrx.uart%d_rx_irrx", bdata->id + 1,
  167. + bdata->id + 1);
  168. + snprintf(tx_pad_name, OMAP_UART_DEFAULT_PAD_NAME_LEN,
  169. + "uart%d_tx_irtx.uart%d_tx_irtx", bdata->id + 1,
  170. + bdata->id + 1);
  171. + }
  172.  
  173. -static struct omap_device_pad default_omap4_uart4_pads[] __initdata = {
  174. - {
  175. - .name = "uart4_tx.uart4_tx",
  176. - .enable = OMAP_PIN_OUTPUT | OMAP_MUX_MODE0,
  177. - },
  178. + if (omap_mux_get_by_name(rx_pad_name, &rx_partition, &rx_mux) >= 0 &&
  179. + omap_mux_get_by_name(tx_pad_name, &tx_partition, &tx_mux) >= 0)
  180. {
  181. - .name = "uart4_rx.uart4_rx",
  182. - .flags = OMAP_DEVICE_PAD_REMUX | OMAP_DEVICE_PAD_WAKEUP,
  183. - .enable = OMAP_PIN_INPUT | OMAP_MUX_MODE0,
  184. - .idle = OMAP_PIN_INPUT | OMAP_MUX_MODE0,
  185. - },
  186. -};
  187. -
  188. -static void omap_serial_fill_default_pads(struct omap_board_data *bdata)
  189. -{
  190. - switch (bdata->id) {
  191. - case 0:
  192. - bdata->pads = default_uart1_pads;
  193. - bdata->pads_cnt = ARRAY_SIZE(default_uart1_pads);
  194. - break;
  195. - case 1:
  196. - bdata->pads = default_uart2_pads;
  197. - bdata->pads_cnt = ARRAY_SIZE(default_uart2_pads);
  198. - break;
  199. - case 2:
  200. - bdata->pads = default_uart3_pads;
  201. - bdata->pads_cnt = ARRAY_SIZE(default_uart3_pads);
  202. - break;
  203. - case 3:
  204. - if (cpu_is_omap44xx()) {
  205. - bdata->pads = default_omap4_uart4_pads;
  206. - bdata->pads_cnt =
  207. - ARRAY_SIZE(default_omap4_uart4_pads);
  208. - } else if (cpu_is_omap3630()) {
  209. - bdata->pads = default_omap36xx_uart4_pads;
  210. - bdata->pads_cnt =
  211. - ARRAY_SIZE(default_omap36xx_uart4_pads);
  212. + u16 tx_mode, rx_mode;
  213. +
  214. + tx_mode = omap_mux_read(tx_partition, tx_mux->reg_offset);
  215. + rx_mode = omap_mux_read(rx_partition, rx_mux->reg_offset);
  216. +
  217. + if (!(rx_mode & 0x07) && !(tx_mode & 0x07)) {
  218. + default_omap_uart_pads[0].name = rx_pad_name;
  219. + default_omap_uart_pads[0].flags =
  220. + OMAP_DEVICE_PAD_REMUX | OMAP_DEVICE_PAD_WAKEUP;
  221. + default_omap_uart_pads[0].enable = OMAP_PIN_INPUT |
  222. + OMAP_MUX_MODE0;
  223. + default_omap_uart_pads[0].idle = OMAP_PIN_INPUT |
  224. + OMAP_MUX_MODE0;
  225. +
  226. + default_omap_uart_pads[1].name = tx_pad_name;
  227. + default_omap_uart_pads[1].enable = OMAP_PIN_OUTPUT |
  228. + OMAP_MUX_MODE0;
  229. + bdata->pads = default_omap_uart_pads;
  230. + bdata->pads_cnt = ARRAY_SIZE(default_omap_uart_pads);
  231. }
  232. - break;
  233. - default:
  234. - break;
  235. }
  236. }
  237. #else
  238. -static void omap_serial_fill_default_pads(struct omap_board_data *bdata) {}
  239. +static void __init omap_serial_fill_default_pads(struct omap_board_data *bdata)
  240. +{}
  241. #endif
  242.  
  243. char *cmdline_find_option(char *str)
  244. --
  245. 1.7.9.1
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement