/arch/arm/mach-kirkwood/openrd-setup.c

https://github.com/AICP/kernel_google_msm · C · 257 lines · 192 code · 38 blank · 27 comment · 20 complexity · 8d405e094177be2bb8aef8a99c029d31 MD5 · raw file

  1. /*
  2. * arch/arm/mach-kirkwood/openrd-setup.c
  3. *
  4. * Marvell OpenRD (Base|Client|Ultimate) Board Setup
  5. *
  6. * This file is licensed under the terms of the GNU General Public
  7. * License version 2. This program is licensed "as is" without any
  8. * warranty of any kind, whether express or implied.
  9. */
  10. #include <linux/kernel.h>
  11. #include <linux/init.h>
  12. #include <linux/platform_device.h>
  13. #include <linux/mtd/nand.h>
  14. #include <linux/mtd/partitions.h>
  15. #include <linux/ata_platform.h>
  16. #include <linux/mv643xx_eth.h>
  17. #include <linux/i2c.h>
  18. #include <linux/gpio.h>
  19. #include <asm/mach-types.h>
  20. #include <asm/mach/arch.h>
  21. #include <mach/kirkwood.h>
  22. #include <plat/mvsdio.h>
  23. #include "common.h"
  24. #include "mpp.h"
  25. static struct mtd_partition openrd_nand_parts[] = {
  26. {
  27. .name = "u-boot",
  28. .offset = 0,
  29. .size = SZ_1M,
  30. .mask_flags = MTD_WRITEABLE
  31. }, {
  32. .name = "uImage",
  33. .offset = MTDPART_OFS_NXTBLK,
  34. .size = SZ_4M
  35. }, {
  36. .name = "root",
  37. .offset = MTDPART_OFS_NXTBLK,
  38. .size = MTDPART_SIZ_FULL
  39. },
  40. };
  41. static struct mv643xx_eth_platform_data openrd_ge00_data = {
  42. .phy_addr = MV643XX_ETH_PHY_ADDR(8),
  43. };
  44. static struct mv643xx_eth_platform_data openrd_ge01_data = {
  45. .phy_addr = MV643XX_ETH_PHY_ADDR(24),
  46. };
  47. static struct mv_sata_platform_data openrd_sata_data = {
  48. .n_ports = 2,
  49. };
  50. static struct mvsdio_platform_data openrd_mvsdio_data = {
  51. .gpio_card_detect = 29, /* MPP29 used as SD card detect */
  52. };
  53. static unsigned int openrd_mpp_config[] __initdata = {
  54. MPP12_SD_CLK,
  55. MPP13_SD_CMD,
  56. MPP14_SD_D0,
  57. MPP15_SD_D1,
  58. MPP16_SD_D2,
  59. MPP17_SD_D3,
  60. MPP28_GPIO,
  61. MPP29_GPIO,
  62. MPP34_GPIO,
  63. 0
  64. };
  65. /* Configure MPP for UART1 */
  66. static unsigned int openrd_uart1_mpp_config[] __initdata = {
  67. MPP13_UART1_TXD,
  68. MPP14_UART1_RXD,
  69. 0
  70. };
  71. static struct i2c_board_info i2c_board_info[] __initdata = {
  72. {
  73. I2C_BOARD_INFO("cs42l51", 0x4a),
  74. },
  75. };
  76. static struct platform_device openrd_client_audio_device = {
  77. .name = "openrd-client-audio",
  78. .id = -1,
  79. };
  80. static int __initdata uart1;
  81. static int __init sd_uart_selection(char *str)
  82. {
  83. uart1 = -EINVAL;
  84. /* Default is SD. Change if required, for UART */
  85. if (!str)
  86. return 0;
  87. if (!strncmp(str, "232", 3)) {
  88. uart1 = 232;
  89. } else if (!strncmp(str, "485", 3)) {
  90. /* OpenRD-Base doesn't have RS485. Treat is as an
  91. * unknown argument & just have default setting -
  92. * which is SD */
  93. if (machine_is_openrd_base()) {
  94. uart1 = -ENODEV;
  95. return 1;
  96. }
  97. uart1 = 485;
  98. }
  99. return 1;
  100. }
  101. /* Parse boot_command_line string kw_openrd_init_uart1=232/485 */
  102. __setup("kw_openrd_init_uart1=", sd_uart_selection);
  103. static int __init uart1_mpp_config(void)
  104. {
  105. kirkwood_mpp_conf(openrd_uart1_mpp_config);
  106. if (gpio_request(34, "SD_UART1_SEL")) {
  107. printk(KERN_ERR "GPIO request failed for SD/UART1 selection"
  108. ", gpio: 34\n");
  109. return -EIO;
  110. }
  111. if (gpio_request(28, "RS232_RS485_SEL")) {
  112. printk(KERN_ERR "GPIO request failed for RS232/RS485 selection"
  113. ", gpio# 28\n");
  114. gpio_free(34);
  115. return -EIO;
  116. }
  117. /* Select UART1
  118. * Pin # 34: 0 => UART1, 1 => SD */
  119. gpio_direction_output(34, 0);
  120. /* Select RS232 OR RS485
  121. * Pin # 28: 0 => RS232, 1 => RS485 */
  122. if (uart1 == 232)
  123. gpio_direction_output(28, 0);
  124. else
  125. gpio_direction_output(28, 1);
  126. gpio_free(34);
  127. gpio_free(28);
  128. return 0;
  129. }
  130. static void __init openrd_init(void)
  131. {
  132. /*
  133. * Basic setup. Needs to be called early.
  134. */
  135. kirkwood_init();
  136. kirkwood_mpp_conf(openrd_mpp_config);
  137. kirkwood_uart0_init();
  138. kirkwood_nand_init(ARRAY_AND_SIZE(openrd_nand_parts), 25);
  139. kirkwood_ehci_init();
  140. if (machine_is_openrd_ultimate()) {
  141. openrd_ge00_data.phy_addr = MV643XX_ETH_PHY_ADDR(0);
  142. openrd_ge01_data.phy_addr = MV643XX_ETH_PHY_ADDR(1);
  143. }
  144. kirkwood_ge00_init(&openrd_ge00_data);
  145. if (!machine_is_openrd_base())
  146. kirkwood_ge01_init(&openrd_ge01_data);
  147. kirkwood_sata_init(&openrd_sata_data);
  148. kirkwood_i2c_init();
  149. if (machine_is_openrd_client() || machine_is_openrd_ultimate()) {
  150. platform_device_register(&openrd_client_audio_device);
  151. i2c_register_board_info(0, i2c_board_info,
  152. ARRAY_SIZE(i2c_board_info));
  153. kirkwood_audio_init();
  154. }
  155. if (uart1 <= 0) {
  156. if (uart1 < 0)
  157. printk(KERN_ERR "Invalid kernel parameter to select "
  158. "UART1. Defaulting to SD. ERROR CODE: %d\n",
  159. uart1);
  160. /* Select SD
  161. * Pin # 34: 0 => UART1, 1 => SD */
  162. if (gpio_request(34, "SD_UART1_SEL")) {
  163. printk(KERN_ERR "GPIO request failed for SD/UART1 "
  164. "selection, gpio: 34\n");
  165. } else {
  166. gpio_direction_output(34, 1);
  167. gpio_free(34);
  168. kirkwood_sdio_init(&openrd_mvsdio_data);
  169. }
  170. } else {
  171. if (!uart1_mpp_config())
  172. kirkwood_uart1_init();
  173. }
  174. }
  175. static int __init openrd_pci_init(void)
  176. {
  177. if (machine_is_openrd_base() ||
  178. machine_is_openrd_client() ||
  179. machine_is_openrd_ultimate())
  180. kirkwood_pcie_init(KW_PCIE0);
  181. return 0;
  182. }
  183. subsys_initcall(openrd_pci_init);
  184. #ifdef CONFIG_MACH_OPENRD_BASE
  185. MACHINE_START(OPENRD_BASE, "Marvell OpenRD Base Board")
  186. /* Maintainer: Dhaval Vasa <dhaval.vasa@einfochips.com> */
  187. .atag_offset = 0x100,
  188. .init_machine = openrd_init,
  189. .map_io = kirkwood_map_io,
  190. .init_early = kirkwood_init_early,
  191. .init_irq = kirkwood_init_irq,
  192. .timer = &kirkwood_timer,
  193. .restart = kirkwood_restart,
  194. MACHINE_END
  195. #endif
  196. #ifdef CONFIG_MACH_OPENRD_CLIENT
  197. MACHINE_START(OPENRD_CLIENT, "Marvell OpenRD Client Board")
  198. /* Maintainer: Dhaval Vasa <dhaval.vasa@einfochips.com> */
  199. .atag_offset = 0x100,
  200. .init_machine = openrd_init,
  201. .map_io = kirkwood_map_io,
  202. .init_early = kirkwood_init_early,
  203. .init_irq = kirkwood_init_irq,
  204. .timer = &kirkwood_timer,
  205. .restart = kirkwood_restart,
  206. MACHINE_END
  207. #endif
  208. #ifdef CONFIG_MACH_OPENRD_ULTIMATE
  209. MACHINE_START(OPENRD_ULTIMATE, "Marvell OpenRD Ultimate Board")
  210. /* Maintainer: Dhaval Vasa <dhaval.vasa@einfochips.com> */
  211. .atag_offset = 0x100,
  212. .init_machine = openrd_init,
  213. .map_io = kirkwood_map_io,
  214. .init_early = kirkwood_init_early,
  215. .init_irq = kirkwood_init_irq,
  216. .timer = &kirkwood_timer,
  217. .restart = kirkwood_restart,
  218. MACHINE_END
  219. #endif