s3c2410.c 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200
  1. /* linux/arch/arm/mach-s3c2410/s3c2410.c
  2. *
  3. * Copyright (c) 2003-2005 Simtec Electronics
  4. * Ben Dooks <ben@simtec.co.uk>
  5. *
  6. * http://www.simtec.co.uk/products/EB2410ITX/
  7. *
  8. * This program is free software; you can redistribute it and/or modify
  9. * it under the terms of the GNU General Public License version 2 as
  10. * published by the Free Software Foundation.
  11. *
  12. * Modifications:
  13. * 16-May-2003 BJD Created initial version
  14. * 16-Aug-2003 BJD Fixed header files and copyright, added URL
  15. * 05-Sep-2003 BJD Moved to kernel v2.6
  16. * 18-Jan-2004 BJD Added serial port configuration
  17. * 21-Aug-2004 BJD Added new struct s3c2410_board handler
  18. * 28-Sep-2004 BJD Updates for new serial port bits
  19. * 04-Nov-2004 BJD Updated UART configuration process
  20. * 10-Jan-2005 BJD Removed s3c2410_clock_tick_rate
  21. */
  22. #include <linux/kernel.h>
  23. #include <linux/types.h>
  24. #include <linux/interrupt.h>
  25. #include <linux/list.h>
  26. #include <linux/timer.h>
  27. #include <linux/init.h>
  28. #include <linux/device.h>
  29. #include <asm/mach/arch.h>
  30. #include <asm/mach/map.h>
  31. #include <asm/mach/irq.h>
  32. #include <asm/hardware.h>
  33. #include <asm/io.h>
  34. #include <asm/irq.h>
  35. #include <asm/arch/regs-clock.h>
  36. #include <asm/arch/regs-serial.h>
  37. #include "s3c2410.h"
  38. #include "cpu.h"
  39. #include "clock.h"
  40. /* Initial IO mappings */
  41. static struct map_desc s3c2410_iodesc[] __initdata = {
  42. IODESC_ENT(USBHOST),
  43. IODESC_ENT(CLKPWR),
  44. IODESC_ENT(LCD),
  45. IODESC_ENT(UART),
  46. IODESC_ENT(TIMER),
  47. IODESC_ENT(ADC),
  48. IODESC_ENT(WATCHDOG)
  49. };
  50. static struct resource s3c_uart0_resource[] = {
  51. [0] = {
  52. .start = S3C2410_PA_UART0,
  53. .end = S3C2410_PA_UART0 + 0x3fff,
  54. .flags = IORESOURCE_MEM,
  55. },
  56. [1] = {
  57. .start = IRQ_S3CUART_RX0,
  58. .end = IRQ_S3CUART_ERR0,
  59. .flags = IORESOURCE_IRQ,
  60. }
  61. };
  62. static struct resource s3c_uart1_resource[] = {
  63. [0] = {
  64. .start = S3C2410_PA_UART1,
  65. .end = S3C2410_PA_UART1 + 0x3fff,
  66. .flags = IORESOURCE_MEM,
  67. },
  68. [1] = {
  69. .start = IRQ_S3CUART_RX1,
  70. .end = IRQ_S3CUART_ERR1,
  71. .flags = IORESOURCE_IRQ,
  72. }
  73. };
  74. static struct resource s3c_uart2_resource[] = {
  75. [0] = {
  76. .start = S3C2410_PA_UART2,
  77. .end = S3C2410_PA_UART2 + 0x3fff,
  78. .flags = IORESOURCE_MEM,
  79. },
  80. [1] = {
  81. .start = IRQ_S3CUART_RX2,
  82. .end = IRQ_S3CUART_ERR2,
  83. .flags = IORESOURCE_IRQ,
  84. }
  85. };
  86. /* our uart devices */
  87. static struct platform_device s3c_uart0 = {
  88. .name = "s3c2410-uart",
  89. .id = 0,
  90. .num_resources = ARRAY_SIZE(s3c_uart0_resource),
  91. .resource = s3c_uart0_resource,
  92. };
  93. static struct platform_device s3c_uart1 = {
  94. .name = "s3c2410-uart",
  95. .id = 1,
  96. .num_resources = ARRAY_SIZE(s3c_uart1_resource),
  97. .resource = s3c_uart1_resource,
  98. };
  99. static struct platform_device s3c_uart2 = {
  100. .name = "s3c2410-uart",
  101. .id = 2,
  102. .num_resources = ARRAY_SIZE(s3c_uart2_resource),
  103. .resource = s3c_uart2_resource,
  104. };
  105. static struct platform_device *uart_devices[] __initdata = {
  106. &s3c_uart0,
  107. &s3c_uart1,
  108. &s3c_uart2
  109. };
  110. /* store our uart devices for the serial driver console */
  111. struct platform_device *s3c2410_uart_devices[3];
  112. static int s3c2410_uart_count = 0;
  113. /* uart registration process */
  114. void __init s3c2410_init_uarts(struct s3c2410_uartcfg *cfg, int no)
  115. {
  116. struct platform_device *platdev;
  117. int uart;
  118. for (uart = 0; uart < no; uart++, cfg++) {
  119. platdev = uart_devices[cfg->hwport];
  120. s3c24xx_uart_devs[uart] = platdev;
  121. platdev->dev.platform_data = cfg;
  122. }
  123. s3c2410_uart_count = uart;
  124. }
  125. /* s3c2410_map_io
  126. *
  127. * register the standard cpu IO areas, and any passed in from the
  128. * machine specific initialisation.
  129. */
  130. void __init s3c2410_map_io(struct map_desc *mach_desc, int mach_size)
  131. {
  132. /* register our io-tables */
  133. iotable_init(s3c2410_iodesc, ARRAY_SIZE(s3c2410_iodesc));
  134. iotable_init(mach_desc, mach_size);
  135. }
  136. void __init s3c2410_init_clocks(int xtal)
  137. {
  138. unsigned long tmp;
  139. unsigned long fclk;
  140. unsigned long hclk;
  141. unsigned long pclk;
  142. /* now we've got our machine bits initialised, work out what
  143. * clocks we've got */
  144. fclk = s3c2410_get_pll(__raw_readl(S3C2410_MPLLCON), xtal);
  145. tmp = __raw_readl(S3C2410_CLKDIVN);
  146. /* work out clock scalings */
  147. hclk = fclk / ((tmp & S3C2410_CLKDIVN_HDIVN) ? 2 : 1);
  148. pclk = hclk / ((tmp & S3C2410_CLKDIVN_PDIVN) ? 2 : 1);
  149. /* print brieft summary of clocks, etc */
  150. printk("S3C2410: core %ld.%03ld MHz, memory %ld.%03ld MHz, peripheral %ld.%03ld MHz\n",
  151. print_mhz(fclk), print_mhz(hclk), print_mhz(pclk));
  152. /* initialise the clocks here, to allow other things like the
  153. * console to use them
  154. */
  155. s3c24xx_setup_clocks(xtal, fclk, hclk, pclk);
  156. }
  157. int __init s3c2410_init(void)
  158. {
  159. printk("S3C2410: Initialising architecture\n");
  160. return platform_add_devices(s3c24xx_uart_devs, s3c2410_uart_count);
  161. }