board-tnetv107x-evm.c 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174
  1. /*
  2. * Texas Instruments TNETV107X EVM Board Support
  3. *
  4. * Copyright (C) 2010 Texas Instruments
  5. *
  6. * This program is free software; you can redistribute it and/or
  7. * modify it under the terms of the GNU General Public License as
  8. * published by the Free Software Foundation version 2.
  9. *
  10. * This program is distributed "as is" WITHOUT ANY WARRANTY of any
  11. * kind, whether express or implied; without even the implied warranty
  12. * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. * GNU General Public License for more details.
  14. */
  15. #include <linux/kernel.h>
  16. #include <linux/init.h>
  17. #include <linux/console.h>
  18. #include <linux/dma-mapping.h>
  19. #include <linux/interrupt.h>
  20. #include <linux/gpio.h>
  21. #include <linux/delay.h>
  22. #include <linux/platform_device.h>
  23. #include <linux/ratelimit.h>
  24. #include <linux/mtd/mtd.h>
  25. #include <linux/mtd/partitions.h>
  26. #include <asm/mach/arch.h>
  27. #include <asm/mach-types.h>
  28. #include <mach/irqs.h>
  29. #include <mach/edma.h>
  30. #include <mach/mux.h>
  31. #include <mach/cp_intc.h>
  32. #include <mach/tnetv107x.h>
  33. #define EVM_MMC_WP_GPIO 21
  34. #define EVM_MMC_CD_GPIO 24
  35. static int initialize_gpio(int gpio, char *desc)
  36. {
  37. int ret;
  38. ret = gpio_request(gpio, desc);
  39. if (ret < 0) {
  40. pr_err_ratelimited("cannot open %s gpio\n", desc);
  41. return -ENOSYS;
  42. }
  43. gpio_direction_input(gpio);
  44. return gpio;
  45. }
  46. static int mmc_get_cd(int index)
  47. {
  48. static int gpio;
  49. if (!gpio)
  50. gpio = initialize_gpio(EVM_MMC_CD_GPIO, "mmc card detect");
  51. if (gpio < 0)
  52. return gpio;
  53. return gpio_get_value(gpio) ? 0 : 1;
  54. }
  55. static int mmc_get_ro(int index)
  56. {
  57. static int gpio;
  58. if (!gpio)
  59. gpio = initialize_gpio(EVM_MMC_WP_GPIO, "mmc write protect");
  60. if (gpio < 0)
  61. return gpio;
  62. return gpio_get_value(gpio) ? 1 : 0;
  63. }
  64. static struct davinci_mmc_config mmc_config = {
  65. .get_cd = mmc_get_cd,
  66. .get_ro = mmc_get_ro,
  67. .wires = 4,
  68. .max_freq = 50000000,
  69. .caps = MMC_CAP_MMC_HIGHSPEED | MMC_CAP_SD_HIGHSPEED,
  70. .version = MMC_CTLR_VERSION_1,
  71. };
  72. static const short sdio1_pins[] __initdata = {
  73. TNETV107X_SDIO1_CLK_1, TNETV107X_SDIO1_CMD_1,
  74. TNETV107X_SDIO1_DATA0_1, TNETV107X_SDIO1_DATA1_1,
  75. TNETV107X_SDIO1_DATA2_1, TNETV107X_SDIO1_DATA3_1,
  76. TNETV107X_GPIO21, TNETV107X_GPIO24,
  77. -1
  78. };
  79. static const short uart1_pins[] __initdata = {
  80. TNETV107X_UART1_RD, TNETV107X_UART1_TD,
  81. -1
  82. };
  83. static struct mtd_partition nand_partitions[] = {
  84. /* bootloader (U-Boot, etc) in first 12 sectors */
  85. {
  86. .name = "bootloader",
  87. .offset = 0,
  88. .size = (12*SZ_128K),
  89. .mask_flags = MTD_WRITEABLE, /* force read-only */
  90. },
  91. /* bootloader params in the next sector */
  92. {
  93. .name = "params",
  94. .offset = MTDPART_OFS_NXTBLK,
  95. .size = SZ_128K,
  96. .mask_flags = MTD_WRITEABLE, /* force read-only */
  97. },
  98. /* kernel */
  99. {
  100. .name = "kernel",
  101. .offset = MTDPART_OFS_NXTBLK,
  102. .size = SZ_4M,
  103. .mask_flags = 0,
  104. },
  105. /* file system */
  106. {
  107. .name = "filesystem",
  108. .offset = MTDPART_OFS_NXTBLK,
  109. .size = MTDPART_SIZ_FULL,
  110. .mask_flags = 0,
  111. }
  112. };
  113. static struct davinci_nand_pdata nand_config = {
  114. .mask_cle = 0x4000,
  115. .mask_ale = 0x2000,
  116. .parts = nand_partitions,
  117. .nr_parts = ARRAY_SIZE(nand_partitions),
  118. .ecc_mode = NAND_ECC_HW,
  119. .options = NAND_USE_FLASH_BBT,
  120. .ecc_bits = 1,
  121. };
  122. static struct davinci_uart_config serial_config __initconst = {
  123. .enabled_uarts = BIT(1),
  124. };
  125. static struct tnetv107x_device_info evm_device_info __initconst = {
  126. .serial_config = &serial_config,
  127. .mmc_config[1] = &mmc_config, /* controller 1 */
  128. .nand_config[0] = &nand_config, /* chip select 0 */
  129. };
  130. static __init void tnetv107x_evm_board_init(void)
  131. {
  132. davinci_cfg_reg_list(sdio1_pins);
  133. davinci_cfg_reg_list(uart1_pins);
  134. tnetv107x_devices_init(&evm_device_info);
  135. }
  136. #ifdef CONFIG_SERIAL_8250_CONSOLE
  137. static int __init tnetv107x_evm_console_init(void)
  138. {
  139. return add_preferred_console("ttyS", 0, "115200");
  140. }
  141. console_initcall(tnetv107x_evm_console_init);
  142. #endif
  143. MACHINE_START(TNETV107X, "TNETV107X EVM")
  144. .phys_io = TNETV107X_IO_BASE,
  145. .io_pg_offst = (TNETV107X_IO_VIRT >> 18) & 0xfffc,
  146. .boot_params = (TNETV107X_DDR_BASE + 0x100),
  147. .map_io = tnetv107x_init,
  148. .init_irq = cp_intc_init,
  149. .timer = &davinci_timer,
  150. .init_machine = tnetv107x_evm_board_init,
  151. MACHINE_END