ip22-platform.c 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209
  1. #include <linux/init.h>
  2. #include <linux/if_ether.h>
  3. #include <linux/kernel.h>
  4. #include <linux/platform_device.h>
  5. #include <asm/paccess.h>
  6. #include <asm/sgi/ip22.h>
  7. #include <asm/sgi/hpc3.h>
  8. #include <asm/sgi/mc.h>
  9. #include <asm/sgi/seeq.h>
  10. #include <asm/sgi/wd.h>
  11. static struct resource sgiwd93_0_resources[] = {
  12. {
  13. .name = "eth0 irq",
  14. .start = SGI_WD93_0_IRQ,
  15. .end = SGI_WD93_0_IRQ,
  16. .flags = IORESOURCE_IRQ
  17. }
  18. };
  19. static struct sgiwd93_platform_data sgiwd93_0_pd = {
  20. .unit = 0,
  21. .irq = SGI_WD93_0_IRQ,
  22. };
  23. static struct platform_device sgiwd93_0_device = {
  24. .name = "sgiwd93",
  25. .id = 0,
  26. .num_resources = ARRAY_SIZE(sgiwd93_0_resources),
  27. .resource = sgiwd93_0_resources,
  28. .dev = {
  29. .platform_data = &sgiwd93_0_pd,
  30. },
  31. };
  32. static struct resource sgiwd93_1_resources[] = {
  33. {
  34. .name = "eth0 irq",
  35. .start = SGI_WD93_1_IRQ,
  36. .end = SGI_WD93_1_IRQ,
  37. .flags = IORESOURCE_IRQ
  38. }
  39. };
  40. static struct sgiwd93_platform_data sgiwd93_1_pd = {
  41. .unit = 1,
  42. .irq = SGI_WD93_1_IRQ,
  43. };
  44. static struct platform_device sgiwd93_1_device = {
  45. .name = "sgiwd93",
  46. .id = 1,
  47. .num_resources = ARRAY_SIZE(sgiwd93_1_resources),
  48. .resource = sgiwd93_1_resources,
  49. .dev = {
  50. .platform_data = &sgiwd93_1_pd,
  51. },
  52. };
  53. /*
  54. * Create a platform device for the GPI port that receives the
  55. * image data from the embedded camera.
  56. */
  57. static int __init sgiwd93_devinit(void)
  58. {
  59. int res;
  60. sgiwd93_0_pd.hregs = &hpc3c0->scsi_chan0;
  61. sgiwd93_0_pd.wdregs = (unsigned char *) hpc3c0->scsi0_ext;
  62. res = platform_device_register(&sgiwd93_0_device);
  63. if (res)
  64. return res;
  65. if (!ip22_is_fullhouse())
  66. return 0;
  67. sgiwd93_1_pd.hregs = &hpc3c0->scsi_chan1;
  68. sgiwd93_1_pd.wdregs = (unsigned char *) hpc3c0->scsi1_ext;
  69. return platform_device_register(&sgiwd93_1_device);
  70. }
  71. device_initcall(sgiwd93_devinit);
  72. static struct resource sgiseeq_0_resources[] = {
  73. {
  74. .name = "eth0 irq",
  75. .start = SGI_ENET_IRQ,
  76. .end = SGI_ENET_IRQ,
  77. .flags = IORESOURCE_IRQ
  78. }
  79. };
  80. static struct sgiseeq_platform_data eth0_pd;
  81. static struct platform_device eth0_device = {
  82. .name = "sgiseeq",
  83. .id = 0,
  84. .num_resources = ARRAY_SIZE(sgiseeq_0_resources),
  85. .resource = sgiseeq_0_resources,
  86. .dev = {
  87. .platform_data = &eth0_pd,
  88. },
  89. };
  90. static struct resource sgiseeq_1_resources[] = {
  91. {
  92. .name = "eth1 irq",
  93. .start = SGI_GIO_0_IRQ,
  94. .end = SGI_GIO_0_IRQ,
  95. .flags = IORESOURCE_IRQ
  96. }
  97. };
  98. static struct sgiseeq_platform_data eth1_pd;
  99. static struct platform_device eth1_device = {
  100. .name = "sgiseeq",
  101. .id = 1,
  102. .num_resources = ARRAY_SIZE(sgiseeq_1_resources),
  103. .resource = sgiseeq_1_resources,
  104. .dev = {
  105. .platform_data = &eth1_pd,
  106. },
  107. };
  108. /*
  109. * Create a platform device for the GPI port that receives the
  110. * image data from the embedded camera.
  111. */
  112. static int __init sgiseeq_devinit(void)
  113. {
  114. unsigned int pbdma __maybe_unused;
  115. int res, i;
  116. eth0_pd.hpc = hpc3c0;
  117. eth0_pd.irq = SGI_ENET_IRQ;
  118. #define EADDR_NVOFS 250
  119. for (i = 0; i < 3; i++) {
  120. unsigned short tmp = ip22_nvram_read(EADDR_NVOFS / 2 + i);
  121. eth0_pd.mac[2 * i] = tmp >> 8;
  122. eth0_pd.mac[2 * i + 1] = tmp & 0xff;
  123. }
  124. res = platform_device_register(&eth0_device);
  125. if (res)
  126. return res;
  127. /* Second HPC is missing? */
  128. if (ip22_is_fullhouse() ||
  129. get_dbe(pbdma, (unsigned int *)&hpc3c1->pbdma[1]))
  130. return 0;
  131. sgimc->giopar |= SGIMC_GIOPAR_MASTEREXP1 | SGIMC_GIOPAR_EXP164 |
  132. SGIMC_GIOPAR_HPC264;
  133. hpc3c1->pbus_piocfg[0][0] = 0x3ffff;
  134. /* interrupt/config register on Challenge S Mezz board */
  135. hpc3c1->pbus_extregs[0][0] = 0x30;
  136. eth1_pd.hpc = hpc3c1;
  137. eth1_pd.irq = SGI_GIO_0_IRQ;
  138. #define EADDR_NVOFS 250
  139. for (i = 0; i < 3; i++) {
  140. unsigned short tmp = ip22_eeprom_read(&hpc3c1->eeprom,
  141. EADDR_NVOFS / 2 + i);
  142. eth1_pd.mac[2 * i] = tmp >> 8;
  143. eth1_pd.mac[2 * i + 1] = tmp & 0xff;
  144. }
  145. return platform_device_register(&eth1_device);
  146. }
  147. device_initcall(sgiseeq_devinit);
  148. static int __init sgi_hal2_devinit(void)
  149. {
  150. return IS_ERR(platform_device_register_simple("sgihal2", 0, NULL, 0));
  151. }
  152. device_initcall(sgi_hal2_devinit);
  153. static int __init sgi_button_devinit(void)
  154. {
  155. if (ip22_is_fullhouse())
  156. return 0; /* full house has no volume buttons */
  157. return IS_ERR(platform_device_register_simple("sgibtns", -1, NULL, 0));
  158. }
  159. device_initcall(sgi_button_devinit);
  160. static int __init sgi_ds1286_devinit(void)
  161. {
  162. struct resource res;
  163. memset(&res, 0, sizeof(res));
  164. res.start = HPC3_CHIP0_BASE + offsetof(struct hpc3_regs, rtcregs);
  165. res.end = res.start + sizeof(hpc3c0->rtcregs) - 1;
  166. res.flags = IORESOURCE_MEM;
  167. return IS_ERR(platform_device_register_simple("rtc-ds1286", -1,
  168. &res, 1));
  169. }
  170. device_initcall(sgi_ds1286_devinit);