cpu.c 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167
  1. /* linux/arch/arm/plat-s3c64xx/cpu.c
  2. *
  3. * Copyright 2008 Openmoko, Inc.
  4. * Copyright 2008 Simtec Electronics
  5. * Ben Dooks <ben@simtec.co.uk>
  6. * http://armlinux.simtec.co.uk/
  7. *
  8. * S3C64XX CPU Support
  9. *
  10. * This program is free software; you can redistribute it and/or modify
  11. * it under the terms of the GNU General Public License version 2 as
  12. * published by the Free Software Foundation.
  13. */
  14. #include <linux/init.h>
  15. #include <linux/module.h>
  16. #include <linux/interrupt.h>
  17. #include <linux/ioport.h>
  18. #include <linux/sysdev.h>
  19. #include <linux/serial_core.h>
  20. #include <linux/platform_device.h>
  21. #include <linux/io.h>
  22. #include <mach/hardware.h>
  23. #include <mach/map.h>
  24. #include <asm/mach/arch.h>
  25. #include <asm/mach/map.h>
  26. #include <plat/regs-serial.h>
  27. #include <plat/cpu.h>
  28. #include <plat/devs.h>
  29. #include <plat/clock.h>
  30. #include <mach/s3c6400.h>
  31. #include <mach/s3c6410.h>
  32. /* table of supported CPUs */
  33. static const char name_s3c6400[] = "S3C6400";
  34. static const char name_s3c6410[] = "S3C6410";
  35. static struct cpu_table cpu_ids[] __initdata = {
  36. {
  37. .idcode = 0x36400000,
  38. .idmask = 0xfffff000,
  39. .map_io = s3c6400_map_io,
  40. .init_clocks = s3c6400_init_clocks,
  41. .init_uarts = s3c6400_init_uarts,
  42. .init = s3c6400_init,
  43. .name = name_s3c6400,
  44. }, {
  45. .idcode = 0x36410100,
  46. .idmask = 0xffffff00,
  47. .map_io = s3c6410_map_io,
  48. .init_clocks = s3c6410_init_clocks,
  49. .init_uarts = s3c6410_init_uarts,
  50. .init = s3c6410_init,
  51. .name = name_s3c6410,
  52. },
  53. };
  54. /* minimal IO mapping */
  55. /* see notes on uart map in arch/arm/mach-s3c6400/include/mach/debug-macro.S */
  56. #define UART_OFFS (S3C_PA_UART & 0xfffff)
  57. static struct map_desc s3c_iodesc[] __initdata = {
  58. {
  59. .virtual = (unsigned long)S3C_VA_SYS,
  60. .pfn = __phys_to_pfn(S3C64XX_PA_SYSCON),
  61. .length = SZ_4K,
  62. .type = MT_DEVICE,
  63. }, {
  64. .virtual = (unsigned long)S3C_VA_MEM,
  65. .pfn = __phys_to_pfn(S3C64XX_PA_SROM),
  66. .length = SZ_4K,
  67. .type = MT_DEVICE,
  68. }, {
  69. .virtual = (unsigned long)(S3C_VA_UART + UART_OFFS),
  70. .pfn = __phys_to_pfn(S3C_PA_UART),
  71. .length = SZ_4K,
  72. .type = MT_DEVICE,
  73. }, {
  74. .virtual = (unsigned long)VA_VIC0,
  75. .pfn = __phys_to_pfn(S3C64XX_PA_VIC0),
  76. .length = SZ_16K,
  77. .type = MT_DEVICE,
  78. }, {
  79. .virtual = (unsigned long)VA_VIC1,
  80. .pfn = __phys_to_pfn(S3C64XX_PA_VIC1),
  81. .length = SZ_16K,
  82. .type = MT_DEVICE,
  83. }, {
  84. .virtual = (unsigned long)S3C_VA_TIMER,
  85. .pfn = __phys_to_pfn(S3C_PA_TIMER),
  86. .length = SZ_16K,
  87. .type = MT_DEVICE,
  88. }, {
  89. .virtual = (unsigned long)S3C64XX_VA_GPIO,
  90. .pfn = __phys_to_pfn(S3C64XX_PA_GPIO),
  91. .length = SZ_4K,
  92. .type = MT_DEVICE,
  93. }, {
  94. .virtual = (unsigned long)S3C64XX_VA_MODEM,
  95. .pfn = __phys_to_pfn(S3C64XX_PA_MODEM),
  96. .length = SZ_4K,
  97. .type = MT_DEVICE,
  98. }, {
  99. .virtual = (unsigned long)S3C_VA_WATCHDOG,
  100. .pfn = __phys_to_pfn(S3C64XX_PA_WATCHDOG),
  101. .length = SZ_4K,
  102. .type = MT_DEVICE,
  103. }, {
  104. .virtual = (unsigned long)S3C_VA_USB_HSPHY,
  105. .pfn = __phys_to_pfn(S3C64XX_PA_USB_HSPHY),
  106. .length = SZ_1K,
  107. .type = MT_DEVICE,
  108. },
  109. };
  110. struct sysdev_class s3c64xx_sysclass = {
  111. .name = "s3c64xx-core",
  112. };
  113. static struct sys_device s3c64xx_sysdev = {
  114. .cls = &s3c64xx_sysclass,
  115. };
  116. /* uart registration process */
  117. void __init s3c6400_common_init_uarts(struct s3c2410_uartcfg *cfg, int no)
  118. {
  119. s3c24xx_init_uartdevs("s3c6400-uart", s3c64xx_uart_resources, cfg, no);
  120. }
  121. /* read cpu identification code */
  122. void __init s3c64xx_init_io(struct map_desc *mach_desc, int size)
  123. {
  124. unsigned long idcode;
  125. /* initialise the io descriptors we need for initialisation */
  126. iotable_init(s3c_iodesc, ARRAY_SIZE(s3c_iodesc));
  127. iotable_init(mach_desc, size);
  128. idcode = __raw_readl(S3C_VA_SYS + 0x118);
  129. if (!idcode) {
  130. /* S3C6400 has the ID register in a different place,
  131. * and needs a write before it can be read. */
  132. __raw_writel(0x0, S3C_VA_SYS + 0xA1C);
  133. idcode = __raw_readl(S3C_VA_SYS + 0xA1C);
  134. }
  135. s3c_init_cpu(idcode, cpu_ids, ARRAY_SIZE(cpu_ids));
  136. }
  137. static __init int s3c64xx_sysdev_init(void)
  138. {
  139. sysdev_class_register(&s3c64xx_sysclass);
  140. return sysdev_register(&s3c64xx_sysdev);
  141. }
  142. core_initcall(s3c64xx_sysdev_init);