malta-platform.c 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147
  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) 2006, 07 MIPS Technologies, Inc.
  7. * written by Ralf Baechle (ralf@linux-mips.org)
  8. * written by Ralf Baechle <ralf@linux-mips.org>
  9. *
  10. * Copyright (C) 2008 Wind River Systems, Inc.
  11. * updated by Tiejun Chen <tiejun.chen@windriver.com>
  12. *
  13. * 1. Probe driver for the Malta's UART ports:
  14. *
  15. * o 2 ports in the SMC SuperIO
  16. * o 1 port in the CBUS UART, a discrete 16550 which normally is only used
  17. * for bringups.
  18. *
  19. * We don't use 8250_platform.c on Malta as it would result in the CBUS
  20. * UART becoming ttyS0.
  21. *
  22. * 2. Register RTC-CMOS platform device on Malta.
  23. */
  24. #include <linux/init.h>
  25. #include <linux/serial_8250.h>
  26. #include <linux/mc146818rtc.h>
  27. #include <linux/module.h>
  28. #include <linux/irq.h>
  29. #include <linux/mtd/partitions.h>
  30. #include <linux/mtd/physmap.h>
  31. #include <linux/platform_device.h>
  32. #include <asm/mips-boards/maltaint.h>
  33. #include <mtd/mtd-abi.h>
  34. #define SMC_PORT(base, int) \
  35. { \
  36. .iobase = base, \
  37. .irq = int, \
  38. .uartclk = 1843200, \
  39. .iotype = UPIO_PORT, \
  40. .flags = UPF_BOOT_AUTOCONF | UPF_SKIP_TEST, \
  41. .regshift = 0, \
  42. }
  43. #define CBUS_UART_FLAGS (UPF_BOOT_AUTOCONF | UPF_SKIP_TEST | UPF_IOREMAP)
  44. static struct plat_serial8250_port uart8250_data[] = {
  45. SMC_PORT(0x3F8, 4),
  46. SMC_PORT(0x2F8, 3),
  47. #ifndef CONFIG_MIPS_CMP
  48. {
  49. .mapbase = 0x1f000900, /* The CBUS UART */
  50. .irq = MIPS_CPU_IRQ_BASE + MIPSCPU_INT_MB2,
  51. .uartclk = 3686400, /* Twice the usual clk! */
  52. .iotype = UPIO_MEM32,
  53. .flags = CBUS_UART_FLAGS,
  54. .regshift = 3,
  55. },
  56. #endif
  57. { },
  58. };
  59. static struct platform_device malta_uart8250_device = {
  60. .name = "serial8250",
  61. .id = PLAT8250_DEV_PLATFORM,
  62. .dev = {
  63. .platform_data = uart8250_data,
  64. },
  65. };
  66. struct resource malta_rtc_resources[] = {
  67. {
  68. .start = RTC_PORT(0),
  69. .end = RTC_PORT(7),
  70. .flags = IORESOURCE_IO,
  71. }, {
  72. .start = RTC_IRQ,
  73. .end = RTC_IRQ,
  74. .flags = IORESOURCE_IRQ,
  75. }
  76. };
  77. static struct platform_device malta_rtc_device = {
  78. .name = "rtc_cmos",
  79. .id = -1,
  80. .resource = malta_rtc_resources,
  81. .num_resources = ARRAY_SIZE(malta_rtc_resources),
  82. };
  83. static struct mtd_partition malta_mtd_partitions[] = {
  84. {
  85. .name = "YAMON",
  86. .offset = 0x0,
  87. .size = 0x100000,
  88. .mask_flags = MTD_WRITEABLE
  89. }, {
  90. .name = "User FS",
  91. .offset = 0x100000,
  92. .size = 0x2e0000
  93. }, {
  94. .name = "Board Config",
  95. .offset = 0x3e0000,
  96. .size = 0x020000,
  97. .mask_flags = MTD_WRITEABLE
  98. }
  99. };
  100. static struct physmap_flash_data malta_flash_data = {
  101. .width = 4,
  102. .nr_parts = ARRAY_SIZE(malta_mtd_partitions),
  103. .parts = malta_mtd_partitions
  104. };
  105. static struct resource malta_flash_resource = {
  106. .start = 0x1e000000,
  107. .end = 0x1e3fffff,
  108. .flags = IORESOURCE_MEM
  109. };
  110. static struct platform_device malta_flash_device = {
  111. .name = "physmap-flash",
  112. .id = 0,
  113. .dev = {
  114. .platform_data = &malta_flash_data,
  115. },
  116. .num_resources = 1,
  117. .resource = &malta_flash_resource,
  118. };
  119. static struct platform_device *malta_devices[] __initdata = {
  120. &malta_uart8250_device,
  121. &malta_rtc_device,
  122. &malta_flash_device,
  123. };
  124. static int __init malta_add_devices(void)
  125. {
  126. int err;
  127. err = platform_add_devices(malta_devices, ARRAY_SIZE(malta_devices));
  128. if (err)
  129. return err;
  130. return 0;
  131. }
  132. device_initcall(malta_add_devices);