ip32-platform.c 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139
  1. /*
  2. * This file is subject to the terms and conditions of the GNU General Public
  3. * License. See the file "COPYING" in the main directory of this archive
  4. * for more details.
  5. *
  6. * Copyright (C) 2007 Ralf Baechle (ralf@linux-mips.org)
  7. */
  8. #include <linux/init.h>
  9. #include <linux/platform_device.h>
  10. #include <linux/serial_8250.h>
  11. #include <linux/rtc/ds1685.h>
  12. #include <asm/ip32/mace.h>
  13. #include <asm/ip32/ip32_ints.h>
  14. extern void ip32_prepare_poweroff(void);
  15. #define MACEISA_SERIAL1_OFFS offsetof(struct sgi_mace, isa.serial1)
  16. #define MACEISA_SERIAL2_OFFS offsetof(struct sgi_mace, isa.serial2)
  17. #define MACE_PORT(offset,_irq) \
  18. { \
  19. .mapbase = MACE_BASE + offset, \
  20. .irq = _irq, \
  21. .uartclk = 1843200, \
  22. .iotype = UPIO_MEM, \
  23. .flags = UPF_SKIP_TEST|UPF_IOREMAP, \
  24. .regshift = 8, \
  25. }
  26. static struct plat_serial8250_port uart8250_data[] = {
  27. MACE_PORT(MACEISA_SERIAL1_OFFS, MACEISA_SERIAL1_IRQ),
  28. MACE_PORT(MACEISA_SERIAL2_OFFS, MACEISA_SERIAL2_IRQ),
  29. { },
  30. };
  31. static struct platform_device uart8250_device = {
  32. .name = "serial8250",
  33. .id = PLAT8250_DEV_PLATFORM,
  34. .dev = {
  35. .platform_data = uart8250_data,
  36. },
  37. };
  38. static int __init uart8250_init(void)
  39. {
  40. return platform_device_register(&uart8250_device);
  41. }
  42. device_initcall(uart8250_init);
  43. static __init int meth_devinit(void)
  44. {
  45. struct platform_device *pd;
  46. int ret;
  47. pd = platform_device_alloc("meth", -1);
  48. if (!pd)
  49. return -ENOMEM;
  50. ret = platform_device_add(pd);
  51. if (ret)
  52. platform_device_put(pd);
  53. return ret;
  54. }
  55. device_initcall(meth_devinit);
  56. static __init int sgio2audio_devinit(void)
  57. {
  58. struct platform_device *pd;
  59. int ret;
  60. pd = platform_device_alloc("sgio2audio", -1);
  61. if (!pd)
  62. return -ENOMEM;
  63. ret = platform_device_add(pd);
  64. if (ret)
  65. platform_device_put(pd);
  66. return ret;
  67. }
  68. device_initcall(sgio2audio_devinit);
  69. static __init int sgio2btns_devinit(void)
  70. {
  71. return IS_ERR(platform_device_register_simple("sgibtns", -1, NULL, 0));
  72. }
  73. device_initcall(sgio2btns_devinit);
  74. #define MACE_RTC_RES_START (MACE_BASE + offsetof(struct sgi_mace, isa.rtc))
  75. #define MACE_RTC_RES_END (MACE_RTC_RES_START + 32767)
  76. static struct resource ip32_rtc_resources[] = {
  77. {
  78. .start = MACEISA_RTC_IRQ,
  79. .end = MACEISA_RTC_IRQ,
  80. .flags = IORESOURCE_IRQ
  81. }, {
  82. .start = MACE_RTC_RES_START,
  83. .end = MACE_RTC_RES_END,
  84. .flags = IORESOURCE_MEM,
  85. }
  86. };
  87. /* RTC registers on IP32 are each padded by 256 bytes (0x100). */
  88. static struct ds1685_rtc_platform_data
  89. ip32_rtc_platform_data[] = {
  90. {
  91. .regstep = 0x100,
  92. .bcd_mode = true,
  93. .no_irq = false,
  94. .uie_unsupported = false,
  95. .alloc_io_resources = true,
  96. .plat_prepare_poweroff = ip32_prepare_poweroff,
  97. },
  98. };
  99. struct platform_device ip32_rtc_device = {
  100. .name = "rtc-ds1685",
  101. .id = -1,
  102. .dev = {
  103. .platform_data = ip32_rtc_platform_data,
  104. },
  105. .num_resources = ARRAY_SIZE(ip32_rtc_resources),
  106. .resource = ip32_rtc_resources,
  107. };
  108. static __init int sgio2_rtc_devinit(void)
  109. {
  110. return platform_device_register(&ip32_rtc_device);
  111. }
  112. device_initcall(sgio2_rtc_devinit);