ip22-platform.c 4.5 KB

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