openrd-setup.c 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253
  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 <linux/platform_data/mmc-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. pr_err("GPIO request 34 failed for SD/UART1 selection\n");
  108. return -EIO;
  109. }
  110. if (gpio_request(28, "RS232_RS485_SEL")) {
  111. pr_err("GPIO request 28 failed for RS232/RS485 selection\n");
  112. gpio_free(34);
  113. return -EIO;
  114. }
  115. /* Select UART1
  116. * Pin # 34: 0 => UART1, 1 => SD */
  117. gpio_direction_output(34, 0);
  118. /* Select RS232 OR RS485
  119. * Pin # 28: 0 => RS232, 1 => RS485 */
  120. if (uart1 == 232)
  121. gpio_direction_output(28, 0);
  122. else
  123. gpio_direction_output(28, 1);
  124. gpio_free(34);
  125. gpio_free(28);
  126. return 0;
  127. }
  128. static void __init openrd_init(void)
  129. {
  130. /*
  131. * Basic setup. Needs to be called early.
  132. */
  133. kirkwood_init();
  134. kirkwood_mpp_conf(openrd_mpp_config);
  135. kirkwood_uart0_init();
  136. kirkwood_nand_init(ARRAY_AND_SIZE(openrd_nand_parts), 25);
  137. kirkwood_ehci_init();
  138. if (machine_is_openrd_ultimate()) {
  139. openrd_ge00_data.phy_addr = MV643XX_ETH_PHY_ADDR(0);
  140. openrd_ge01_data.phy_addr = MV643XX_ETH_PHY_ADDR(1);
  141. }
  142. kirkwood_ge00_init(&openrd_ge00_data);
  143. if (!machine_is_openrd_base())
  144. kirkwood_ge01_init(&openrd_ge01_data);
  145. kirkwood_sata_init(&openrd_sata_data);
  146. kirkwood_i2c_init();
  147. if (machine_is_openrd_client() || machine_is_openrd_ultimate()) {
  148. platform_device_register(&openrd_client_audio_device);
  149. i2c_register_board_info(0, i2c_board_info,
  150. ARRAY_SIZE(i2c_board_info));
  151. kirkwood_audio_init();
  152. }
  153. if (uart1 <= 0) {
  154. if (uart1 < 0)
  155. pr_err("Invalid kernel parameter to select UART1. Defaulting to SD. ERROR CODE: %d\n",
  156. uart1);
  157. /* Select SD
  158. * Pin # 34: 0 => UART1, 1 => SD */
  159. if (gpio_request(34, "SD_UART1_SEL")) {
  160. pr_err("GPIO request 34 failed for SD/UART1 selection\n");
  161. } else {
  162. gpio_direction_output(34, 1);
  163. gpio_free(34);
  164. kirkwood_sdio_init(&openrd_mvsdio_data);
  165. }
  166. } else {
  167. if (!uart1_mpp_config())
  168. kirkwood_uart1_init();
  169. }
  170. }
  171. static int __init openrd_pci_init(void)
  172. {
  173. if (machine_is_openrd_base() ||
  174. machine_is_openrd_client() ||
  175. machine_is_openrd_ultimate())
  176. kirkwood_pcie_init(KW_PCIE0);
  177. return 0;
  178. }
  179. subsys_initcall(openrd_pci_init);
  180. #ifdef CONFIG_MACH_OPENRD_BASE
  181. MACHINE_START(OPENRD_BASE, "Marvell OpenRD Base Board")
  182. /* Maintainer: Dhaval Vasa <dhaval.vasa@einfochips.com> */
  183. .atag_offset = 0x100,
  184. .init_machine = openrd_init,
  185. .map_io = kirkwood_map_io,
  186. .init_early = kirkwood_init_early,
  187. .init_irq = kirkwood_init_irq,
  188. .init_time = kirkwood_timer_init,
  189. .restart = kirkwood_restart,
  190. MACHINE_END
  191. #endif
  192. #ifdef CONFIG_MACH_OPENRD_CLIENT
  193. MACHINE_START(OPENRD_CLIENT, "Marvell OpenRD Client Board")
  194. /* Maintainer: Dhaval Vasa <dhaval.vasa@einfochips.com> */
  195. .atag_offset = 0x100,
  196. .init_machine = openrd_init,
  197. .map_io = kirkwood_map_io,
  198. .init_early = kirkwood_init_early,
  199. .init_irq = kirkwood_init_irq,
  200. .init_time = kirkwood_timer_init,
  201. .restart = kirkwood_restart,
  202. MACHINE_END
  203. #endif
  204. #ifdef CONFIG_MACH_OPENRD_ULTIMATE
  205. MACHINE_START(OPENRD_ULTIMATE, "Marvell OpenRD Ultimate Board")
  206. /* Maintainer: Dhaval Vasa <dhaval.vasa@einfochips.com> */
  207. .atag_offset = 0x100,
  208. .init_machine = openrd_init,
  209. .map_io = kirkwood_map_io,
  210. .init_early = kirkwood_init_early,
  211. .init_irq = kirkwood_init_irq,
  212. .init_time = kirkwood_timer_init,
  213. .restart = kirkwood_restart,
  214. MACHINE_END
  215. #endif