openrd-setup.c 5.6 KB

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