platform.c 3.9 KB

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