openrd-setup.c 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254
  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. .gpio_write_protect = -1,
  53. };
  54. static unsigned int openrd_mpp_config[] __initdata = {
  55. MPP12_SD_CLK,
  56. MPP13_SD_CMD,
  57. MPP14_SD_D0,
  58. MPP15_SD_D1,
  59. MPP16_SD_D2,
  60. MPP17_SD_D3,
  61. MPP28_GPIO,
  62. MPP29_GPIO,
  63. MPP34_GPIO,
  64. 0
  65. };
  66. /* Configure MPP for UART1 */
  67. static unsigned int openrd_uart1_mpp_config[] __initdata = {
  68. MPP13_UART1_TXD,
  69. MPP14_UART1_RXD,
  70. 0
  71. };
  72. static struct i2c_board_info i2c_board_info[] __initdata = {
  73. {
  74. I2C_BOARD_INFO("cs42l51", 0x4a),
  75. },
  76. };
  77. static struct platform_device openrd_client_audio_device = {
  78. .name = "openrd-client-audio",
  79. .id = -1,
  80. };
  81. static int __initdata uart1;
  82. static int __init sd_uart_selection(char *str)
  83. {
  84. uart1 = -EINVAL;
  85. /* Default is SD. Change if required, for UART */
  86. if (!str)
  87. return 0;
  88. if (!strncmp(str, "232", 3)) {
  89. uart1 = 232;
  90. } else if (!strncmp(str, "485", 3)) {
  91. /* OpenRD-Base doesn't have RS485. Treat is as an
  92. * unknown argument & just have default setting -
  93. * which is SD */
  94. if (machine_is_openrd_base()) {
  95. uart1 = -ENODEV;
  96. return 1;
  97. }
  98. uart1 = 485;
  99. }
  100. return 1;
  101. }
  102. /* Parse boot_command_line string kw_openrd_init_uart1=232/485 */
  103. __setup("kw_openrd_init_uart1=", sd_uart_selection);
  104. static int __init uart1_mpp_config(void)
  105. {
  106. kirkwood_mpp_conf(openrd_uart1_mpp_config);
  107. if (gpio_request(34, "SD_UART1_SEL")) {
  108. pr_err("GPIO request 34 failed for SD/UART1 selection\n");
  109. return -EIO;
  110. }
  111. if (gpio_request(28, "RS232_RS485_SEL")) {
  112. pr_err("GPIO request 28 failed for RS232/RS485 selection\n");
  113. gpio_free(34);
  114. return -EIO;
  115. }
  116. /* Select UART1
  117. * Pin # 34: 0 => UART1, 1 => SD */
  118. gpio_direction_output(34, 0);
  119. /* Select RS232 OR RS485
  120. * Pin # 28: 0 => RS232, 1 => RS485 */
  121. if (uart1 == 232)
  122. gpio_direction_output(28, 0);
  123. else
  124. gpio_direction_output(28, 1);
  125. gpio_free(34);
  126. gpio_free(28);
  127. return 0;
  128. }
  129. static void __init openrd_init(void)
  130. {
  131. /*
  132. * Basic setup. Needs to be called early.
  133. */
  134. kirkwood_init();
  135. kirkwood_mpp_conf(openrd_mpp_config);
  136. kirkwood_uart0_init();
  137. kirkwood_nand_init(ARRAY_AND_SIZE(openrd_nand_parts), 25);
  138. kirkwood_ehci_init();
  139. if (machine_is_openrd_ultimate()) {
  140. openrd_ge00_data.phy_addr = MV643XX_ETH_PHY_ADDR(0);
  141. openrd_ge01_data.phy_addr = MV643XX_ETH_PHY_ADDR(1);
  142. }
  143. kirkwood_ge00_init(&openrd_ge00_data);
  144. if (!machine_is_openrd_base())
  145. kirkwood_ge01_init(&openrd_ge01_data);
  146. kirkwood_sata_init(&openrd_sata_data);
  147. kirkwood_i2c_init();
  148. if (machine_is_openrd_client() || machine_is_openrd_ultimate()) {
  149. platform_device_register(&openrd_client_audio_device);
  150. i2c_register_board_info(0, i2c_board_info,
  151. ARRAY_SIZE(i2c_board_info));
  152. kirkwood_audio_init();
  153. }
  154. if (uart1 <= 0) {
  155. if (uart1 < 0)
  156. pr_err("Invalid kernel parameter to select UART1. Defaulting to SD. ERROR CODE: %d\n",
  157. uart1);
  158. /* Select SD
  159. * Pin # 34: 0 => UART1, 1 => SD */
  160. if (gpio_request(34, "SD_UART1_SEL")) {
  161. pr_err("GPIO request 34 failed for SD/UART1 selection\n");
  162. } else {
  163. gpio_direction_output(34, 1);
  164. gpio_free(34);
  165. kirkwood_sdio_init(&openrd_mvsdio_data);
  166. }
  167. } else {
  168. if (!uart1_mpp_config())
  169. kirkwood_uart1_init();
  170. }
  171. }
  172. static int __init openrd_pci_init(void)
  173. {
  174. if (machine_is_openrd_base() ||
  175. machine_is_openrd_client() ||
  176. machine_is_openrd_ultimate())
  177. kirkwood_pcie_init(KW_PCIE0);
  178. return 0;
  179. }
  180. subsys_initcall(openrd_pci_init);
  181. #ifdef CONFIG_MACH_OPENRD_BASE
  182. MACHINE_START(OPENRD_BASE, "Marvell OpenRD Base Board")
  183. /* Maintainer: Dhaval Vasa <dhaval.vasa@einfochips.com> */
  184. .atag_offset = 0x100,
  185. .init_machine = openrd_init,
  186. .map_io = kirkwood_map_io,
  187. .init_early = kirkwood_init_early,
  188. .init_irq = kirkwood_init_irq,
  189. .init_time = kirkwood_timer_init,
  190. .restart = kirkwood_restart,
  191. MACHINE_END
  192. #endif
  193. #ifdef CONFIG_MACH_OPENRD_CLIENT
  194. MACHINE_START(OPENRD_CLIENT, "Marvell OpenRD Client Board")
  195. /* Maintainer: Dhaval Vasa <dhaval.vasa@einfochips.com> */
  196. .atag_offset = 0x100,
  197. .init_machine = openrd_init,
  198. .map_io = kirkwood_map_io,
  199. .init_early = kirkwood_init_early,
  200. .init_irq = kirkwood_init_irq,
  201. .init_time = kirkwood_timer_init,
  202. .restart = kirkwood_restart,
  203. MACHINE_END
  204. #endif
  205. #ifdef CONFIG_MACH_OPENRD_ULTIMATE
  206. MACHINE_START(OPENRD_ULTIMATE, "Marvell OpenRD Ultimate Board")
  207. /* Maintainer: Dhaval Vasa <dhaval.vasa@einfochips.com> */
  208. .atag_offset = 0x100,
  209. .init_machine = openrd_init,
  210. .map_io = kirkwood_map_io,
  211. .init_early = kirkwood_init_early,
  212. .init_irq = kirkwood_init_irq,
  213. .init_time = kirkwood_timer_init,
  214. .restart = kirkwood_restart,
  215. MACHINE_END
  216. #endif