platform.c 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176
  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. static int mmc_activity;
  28. static void pb1200mmc0_set_power(void *mmc_host, int state)
  29. {
  30. if (state)
  31. bcsr->board |= BCSR_BOARD_SD0PWR;
  32. else
  33. bcsr->board &= ~BCSR_BOARD_SD0PWR;
  34. au_sync_delay(1);
  35. }
  36. static int pb1200mmc0_card_readonly(void *mmc_host)
  37. {
  38. return (bcsr->status & BCSR_STATUS_SD0WP) ? 1 : 0;
  39. }
  40. static int pb1200mmc0_card_inserted(void *mmc_host)
  41. {
  42. return (bcsr->sig_status & BCSR_INT_SD0INSERT) ? 1 : 0;
  43. }
  44. static void pb1200_mmcled_set(struct led_classdev *led,
  45. enum led_brightness brightness)
  46. {
  47. if (brightness != LED_OFF) {
  48. if (++mmc_activity == 1)
  49. bcsr->disk_leds &= ~(1 << 8);
  50. } else {
  51. if (--mmc_activity == 0)
  52. bcsr->disk_leds |= (1 << 8);
  53. }
  54. }
  55. static struct led_classdev pb1200mmc_led = {
  56. .brightness_set = pb1200_mmcled_set,
  57. };
  58. #ifndef CONFIG_MIPS_DB1200
  59. static void pb1200mmc1_set_power(void *mmc_host, int state)
  60. {
  61. if (state)
  62. bcsr->board |= BCSR_BOARD_SD1PWR;
  63. else
  64. bcsr->board &= ~BCSR_BOARD_SD1PWR;
  65. au_sync_delay(1);
  66. }
  67. static int pb1200mmc1_card_readonly(void *mmc_host)
  68. {
  69. return (bcsr->status & BCSR_STATUS_SD1WP) ? 1 : 0;
  70. }
  71. static int pb1200mmc1_card_inserted(void *mmc_host)
  72. {
  73. return (bcsr->sig_status & BCSR_INT_SD1INSERT) ? 1 : 0;
  74. }
  75. #endif
  76. const struct au1xmmc_platform_data au1xmmc_platdata[2] = {
  77. [0] = {
  78. .set_power = pb1200mmc0_set_power,
  79. .card_inserted = pb1200mmc0_card_inserted,
  80. .card_readonly = pb1200mmc0_card_readonly,
  81. .cd_setup = NULL, /* use poll-timer in driver */
  82. .led = &pb1200mmc_led,
  83. },
  84. #ifndef CONFIG_MIPS_DB1200
  85. [1] = {
  86. .set_power = pb1200mmc1_set_power,
  87. .card_inserted = pb1200mmc1_card_inserted,
  88. .card_readonly = pb1200mmc1_card_readonly,
  89. .cd_setup = NULL, /* use poll-timer in driver */
  90. .led = &pb1200mmc_led,
  91. },
  92. #endif
  93. };
  94. static struct resource ide_resources[] = {
  95. [0] = {
  96. .start = IDE_PHYS_ADDR,
  97. .end = IDE_PHYS_ADDR + IDE_PHYS_LEN - 1,
  98. .flags = IORESOURCE_MEM
  99. },
  100. [1] = {
  101. .start = IDE_INT,
  102. .end = IDE_INT,
  103. .flags = IORESOURCE_IRQ
  104. }
  105. };
  106. static u64 ide_dmamask = DMA_BIT_MASK(32);
  107. static struct platform_device ide_device = {
  108. .name = "au1200-ide",
  109. .id = 0,
  110. .dev = {
  111. .dma_mask = &ide_dmamask,
  112. .coherent_dma_mask = DMA_BIT_MASK(32),
  113. },
  114. .num_resources = ARRAY_SIZE(ide_resources),
  115. .resource = ide_resources
  116. };
  117. static struct smc91x_platdata smc_data = {
  118. .flags = SMC91X_NOWAIT | SMC91X_USE_16BIT,
  119. .leda = RPC_LED_100_10,
  120. .ledb = RPC_LED_TX_RX,
  121. };
  122. static struct resource smc91c111_resources[] = {
  123. [0] = {
  124. .name = "smc91x-regs",
  125. .start = SMC91C111_PHYS_ADDR,
  126. .end = SMC91C111_PHYS_ADDR + 0xf,
  127. .flags = IORESOURCE_MEM
  128. },
  129. [1] = {
  130. .start = SMC91C111_INT,
  131. .end = SMC91C111_INT,
  132. .flags = IORESOURCE_IRQ
  133. },
  134. };
  135. static struct platform_device smc91c111_device = {
  136. .dev = {
  137. .platform_data = &smc_data,
  138. },
  139. .name = "smc91x",
  140. .id = -1,
  141. .num_resources = ARRAY_SIZE(smc91c111_resources),
  142. .resource = smc91c111_resources
  143. };
  144. static struct platform_device *board_platform_devices[] __initdata = {
  145. &ide_device,
  146. &smc91c111_device
  147. };
  148. static int __init board_register_devices(void)
  149. {
  150. return platform_add_devices(board_platform_devices,
  151. ARRAY_SIZE(board_platform_devices));
  152. }
  153. arch_initcall(board_register_devices);