platform.c 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177
  1. /*
  2. * Pb1200/DBAu1200 board platform device registration
  3. *
  4. * Copyright (C) 2008 MontaVista Software Inc. <source@mvista.com>
  5. *
  6. * This program is free software; you can redistribute it and/or modify
  7. * it under the terms of the GNU General Public License as published by
  8. * the Free Software Foundation; either version 2 of the License, or
  9. * (at your option) any later version.
  10. *
  11. * This program is distributed in the hope that it will be useful,
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. * GNU General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU General Public License
  17. * along with this program; if not, write to the Free Software
  18. * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
  19. */
  20. #include <linux/dma-mapping.h>
  21. #include <linux/init.h>
  22. #include <linux/leds.h>
  23. #include <linux/platform_device.h>
  24. #include <linux/smc91x.h>
  25. #include <asm/mach-au1x00/au1xxx.h>
  26. #include <asm/mach-au1x00/au1100_mmc.h>
  27. #include <asm/mach-db1x00/bcsr.h>
  28. static int mmc_activity;
  29. static void pb1200mmc0_set_power(void *mmc_host, int state)
  30. {
  31. if (state)
  32. bcsr_mod(BCSR_BOARD, 0, BCSR_BOARD_SD0PWR);
  33. else
  34. bcsr_mod(BCSR_BOARD, BCSR_BOARD_SD0PWR, 0);
  35. msleep(1);
  36. }
  37. static int pb1200mmc0_card_readonly(void *mmc_host)
  38. {
  39. return (bcsr_read(BCSR_STATUS) & BCSR_STATUS_SD0WP) ? 1 : 0;
  40. }
  41. static int pb1200mmc0_card_inserted(void *mmc_host)
  42. {
  43. return (bcsr_read(BCSR_SIGSTAT) & BCSR_INT_SD0INSERT) ? 1 : 0;
  44. }
  45. static void pb1200_mmcled_set(struct led_classdev *led,
  46. enum led_brightness brightness)
  47. {
  48. if (brightness != LED_OFF) {
  49. if (++mmc_activity == 1)
  50. bcsr_mod(BCSR_LEDS, BCSR_LEDS_LED0, 0);
  51. } else {
  52. if (--mmc_activity == 0)
  53. bcsr_mod(BCSR_LEDS, 0, BCSR_LEDS_LED0);
  54. }
  55. }
  56. static struct led_classdev pb1200mmc_led = {
  57. .brightness_set = pb1200_mmcled_set,
  58. };
  59. #ifndef CONFIG_MIPS_DB1200
  60. static void pb1200mmc1_set_power(void *mmc_host, int state)
  61. {
  62. if (state)
  63. bcsr_mod(BCSR_BOARD, 0, BCSR_BOARD_SD1PWR);
  64. else
  65. bcsr_mod(BCSR_BOARD, BCSR_BOARD_SD1PWR, 0);
  66. msleep(1);
  67. }
  68. static int pb1200mmc1_card_readonly(void *mmc_host)
  69. {
  70. return (bcsr_read(BCSR_STATUS) & BCSR_STATUS_SD1WP) ? 1 : 0;
  71. }
  72. static int pb1200mmc1_card_inserted(void *mmc_host)
  73. {
  74. return (bcsr_read(BCSR_SIGSTAT) & BCSR_INT_SD1INSERT) ? 1 : 0;
  75. }
  76. #endif
  77. const struct au1xmmc_platform_data au1xmmc_platdata[2] = {
  78. [0] = {
  79. .set_power = pb1200mmc0_set_power,
  80. .card_inserted = pb1200mmc0_card_inserted,
  81. .card_readonly = pb1200mmc0_card_readonly,
  82. .cd_setup = NULL, /* use poll-timer in driver */
  83. .led = &pb1200mmc_led,
  84. },
  85. #ifndef CONFIG_MIPS_DB1200
  86. [1] = {
  87. .set_power = pb1200mmc1_set_power,
  88. .card_inserted = pb1200mmc1_card_inserted,
  89. .card_readonly = pb1200mmc1_card_readonly,
  90. .cd_setup = NULL, /* use poll-timer in driver */
  91. .led = &pb1200mmc_led,
  92. },
  93. #endif
  94. };
  95. static struct resource ide_resources[] = {
  96. [0] = {
  97. .start = IDE_PHYS_ADDR,
  98. .end = IDE_PHYS_ADDR + IDE_PHYS_LEN - 1,
  99. .flags = IORESOURCE_MEM
  100. },
  101. [1] = {
  102. .start = IDE_INT,
  103. .end = IDE_INT,
  104. .flags = IORESOURCE_IRQ
  105. }
  106. };
  107. static u64 ide_dmamask = DMA_BIT_MASK(32);
  108. static struct platform_device ide_device = {
  109. .name = "au1200-ide",
  110. .id = 0,
  111. .dev = {
  112. .dma_mask = &ide_dmamask,
  113. .coherent_dma_mask = DMA_BIT_MASK(32),
  114. },
  115. .num_resources = ARRAY_SIZE(ide_resources),
  116. .resource = ide_resources
  117. };
  118. static struct smc91x_platdata smc_data = {
  119. .flags = SMC91X_NOWAIT | SMC91X_USE_16BIT,
  120. .leda = RPC_LED_100_10,
  121. .ledb = RPC_LED_TX_RX,
  122. };
  123. static struct resource smc91c111_resources[] = {
  124. [0] = {
  125. .name = "smc91x-regs",
  126. .start = SMC91C111_PHYS_ADDR,
  127. .end = SMC91C111_PHYS_ADDR + 0xf,
  128. .flags = IORESOURCE_MEM
  129. },
  130. [1] = {
  131. .start = SMC91C111_INT,
  132. .end = SMC91C111_INT,
  133. .flags = IORESOURCE_IRQ
  134. },
  135. };
  136. static struct platform_device smc91c111_device = {
  137. .dev = {
  138. .platform_data = &smc_data,
  139. },
  140. .name = "smc91x",
  141. .id = -1,
  142. .num_resources = ARRAY_SIZE(smc91c111_resources),
  143. .resource = smc91c111_resources
  144. };
  145. static struct platform_device *board_platform_devices[] __initdata = {
  146. &ide_device,
  147. &smc91c111_device
  148. };
  149. static int __init board_register_devices(void)
  150. {
  151. return platform_add_devices(board_platform_devices,
  152. ARRAY_SIZE(board_platform_devices));
  153. }
  154. arch_initcall(board_register_devices);