devices.c 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119
  1. /*
  2. * Common devices definition for Gemini
  3. *
  4. * Copyright (C) 2008-2009 Paulius Zaleckas <paulius.zaleckas@teltonika.lt>
  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 version 2 as
  8. * published by the Free Software Foundation.
  9. */
  10. #include <linux/kernel.h>
  11. #include <linux/init.h>
  12. #include <linux/io.h>
  13. #include <linux/platform_device.h>
  14. #include <linux/serial_8250.h>
  15. #include <linux/mtd/physmap.h>
  16. #include <mach/irqs.h>
  17. #include <mach/hardware.h>
  18. #include <mach/global_reg.h>
  19. static struct plat_serial8250_port serial_platform_data[] = {
  20. {
  21. .membase = (void *)IO_ADDRESS(GEMINI_UART_BASE),
  22. .mapbase = GEMINI_UART_BASE,
  23. .irq = IRQ_UART,
  24. .uartclk = UART_CLK,
  25. .regshift = 2,
  26. .iotype = UPIO_MEM,
  27. .type = PORT_16550A,
  28. .flags = UPF_BOOT_AUTOCONF | UPF_SKIP_TEST | UPF_FIXED_TYPE,
  29. },
  30. {},
  31. };
  32. static struct platform_device serial_device = {
  33. .name = "serial8250",
  34. .id = PLAT8250_DEV_PLATFORM,
  35. .dev = {
  36. .platform_data = serial_platform_data,
  37. },
  38. };
  39. int platform_register_uart(void)
  40. {
  41. return platform_device_register(&serial_device);
  42. }
  43. static struct resource flash_resource = {
  44. .start = GEMINI_FLASH_BASE,
  45. .flags = IORESOURCE_MEM,
  46. };
  47. static struct physmap_flash_data pflash_platform_data = {};
  48. static struct platform_device pflash_device = {
  49. .name = "physmap-flash",
  50. .id = 0,
  51. .dev = {
  52. .platform_data = &pflash_platform_data,
  53. },
  54. .resource = &flash_resource,
  55. .num_resources = 1,
  56. };
  57. int platform_register_pflash(unsigned int size, struct mtd_partition *parts,
  58. unsigned int nr_parts)
  59. {
  60. unsigned int reg;
  61. reg = __raw_readl(IO_ADDRESS(GEMINI_GLOBAL_BASE) + GLOBAL_STATUS);
  62. if ((reg & FLASH_TYPE_MASK) != FLASH_TYPE_PARALLEL)
  63. return -ENXIO;
  64. if (reg & FLASH_WIDTH_16BIT)
  65. pflash_platform_data.width = 2;
  66. else
  67. pflash_platform_data.width = 1;
  68. /* enable parallel flash pins and disable others */
  69. reg = __raw_readl(IO_ADDRESS(GEMINI_GLOBAL_BASE) + GLOBAL_MISC_CTRL);
  70. reg &= ~PFLASH_PADS_DISABLE;
  71. reg |= SFLASH_PADS_DISABLE | NAND_PADS_DISABLE;
  72. __raw_writel(reg, IO_ADDRESS(GEMINI_GLOBAL_BASE) + GLOBAL_MISC_CTRL);
  73. flash_resource.end = flash_resource.start + size - 1;
  74. pflash_platform_data.parts = parts;
  75. pflash_platform_data.nr_parts = nr_parts;
  76. return platform_device_register(&pflash_device);
  77. }
  78. static struct resource gemini_rtc_resources[] = {
  79. [0] = {
  80. .start = GEMINI_RTC_BASE,
  81. .end = GEMINI_RTC_BASE + 0x24,
  82. .flags = IORESOURCE_MEM,
  83. },
  84. [1] = {
  85. .start = IRQ_RTC,
  86. .end = IRQ_RTC,
  87. .flags = IORESOURCE_IRQ,
  88. },
  89. };
  90. static struct platform_device gemini_rtc_device = {
  91. .name = "rtc-gemini",
  92. .id = 0,
  93. .num_resources = ARRAY_SIZE(gemini_rtc_resources),
  94. .resource = gemini_rtc_resources,
  95. };
  96. int __init platform_register_rtc(void)
  97. {
  98. return platform_device_register(&gemini_rtc_device);
  99. }