voltageStandardDeviation.c 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221
  1. /*
  2. * Copyright (c) 2011 Samsung Electronics Co., Ltd.
  3. * http://www.samsung.com
  4. *
  5. * Copyright 2008 Openmoko, Inc.
  6. * Copyright 2008 Simtec Electronics
  7. * Ben Dooks <ben@simtec.co.uk>
  8. * http://armlinux.simtec.co.uk/
  9. *
  10. * Common Codes for S3C64XX machines
  11. *
  12. * This program is free software; you can redistribute it and/or modify
  13. * it under the terms of the GNU General Public License version 2 as
  14. * published by the Free Software Foundation.
  15. */
  16. #include <linux/kernel.h>
  17. #include <linux/init.h>
  18. #include <linux/module.h>
  19. #include <linux/interrupt.h>
  20. #include <linux/ioport.h>
  21. #include <linux/serial_core.h>
  22. #include <linux/platform_device.h>
  23. #include <linux/io.h>
  24. #include <linux/dma-mapping.h>
  25. #include <linux/irq.h>
  26. #include <linux/gpio.h>
  27. #include <asm/mach/arch.h>
  28. #include <asm/mach/map.h>
  29. #include <asm/hardware/vic.h>
  30. #include <asm/system_misc.h>
  31. #include <mach/map.h>
  32. #include <mach/hardware.h>
  33. #include <mach/regs-gpio.h>
  34. #include <plat/cpu.h>
  35. #include <plat/clock.h>
  36. #include <plat/devs.h>
  37. #include <plat/pm.h>
  38. #include <plat/gpio-cfg.h>
  39. #include <plat/irq-uart.h>
  40. #include <plat/irq-vic-timer.h>
  41. #include <plat/regs-irqtype.h>
  42. #include <plat/regs-serial.h>
  43. #include <plat/watchdog-reset.h>
  44. #include "common.h"
  45. /* uart registration process */
  46. static void __init s3c64xx_init_uarts(struct s3c2410_uartcfg *cfg, int no)
  47. {
  48. s3c24xx_init_uartdevs("s3c6400-uart", s3c64xx_uart_resources, cfg, no);
  49. }
  50. /* table of supported CPUs */
  51. static const char name_s3c6400[] = "S3C6400";
  52. static const char name_s3c6410[] = "S3C6410";
  53. static struct cpu_table cpu_ids[] __initdata = {
  54. {
  55. .idcode = S3C6400_CPU_ID,
  56. .idmask = S3C64XX_CPU_MASK,
  57. .map_io = s3c6400_map_io,
  58. .init_clocks = s3c6400_init_clocks,
  59. .init_uarts = s3c64xx_init_uarts,
  60. .init = s3c6400_init,
  61. .name = name_s3c6400,
  62. }, {
  63. .idcode = S3C6410_CPU_ID,
  64. .idmask = S3C64XX_CPU_MASK,
  65. .map_io = s3c6410_map_io,
  66. .init_clocks = s3c6410_init_clocks,
  67. .init_uarts = s3c64xx_init_uarts,
  68. .init = s3c6410_init,
  69. .name = name_s3c6410,
  70. },
  71. };
  72. /* minimal IO mapping */
  73. /* see notes on uart map in arch/arm/mach-s3c64xx/include/mach/debug-macro.S */
  74. #define UART_OFFS (S3C_PA_UART & 0xfffff)
  75. static struct map_desc s3c_iodesc[] __initdata = {
  76. {
  77. .virtual = (unsigned long)S3C_VA_SYS,
  78. .pfn = __phys_to_pfn(S3C64XX_PA_SYSCON),
  79. .length = SZ_4K,
  80. .type = MT_DEVICE,
  81. }, {
  82. .virtual = (unsigned long)S3C_VA_MEM,
  83. .pfn = __phys_to_pfn(S3C64XX_PA_SROM),
  84. .length = SZ_4K,
  85. .type = MT_DEVICE,
  86. }, {
  87. .virtual = (unsigned long)(S3C_VA_UART + UART_OFFS),
  88. .pfn = __phys_to_pfn(S3C_PA_UART),
  89. .length = SZ_4K,
  90. .type = MT_DEVICE,
  91. }, {
  92. .virtual = (unsigned long)VA_VIC0,
  93. .pfn = __phys_to_pfn(S3C64XX_PA_VIC0),
  94. .length = SZ_16K,
  95. .type = MT_DEVICE,
  96. }, {
  97. .virtual = (unsigned long)VA_VIC1,
  98. .pfn = __phys_to_pfn(S3C64XX_PA_VIC1),
  99. .length = SZ_16K,
  100. .type = MT_DEVICE,
  101. }, {
  102. .virtual = (unsigned long)S3C_VA_TIMER,
  103. .pfn = __phys_to_pfn(S3C_PA_TIMER),
  104. .length = SZ_16K,
  105. .type = MT_DEVICE,
  106. }, {
  107. .virtual = (unsigned long)S3C64XX_VA_GPIO,
  108. .pfn = __phys_to_pfn(S3C64XX_PA_GPIO),
  109. .length = SZ_4K,
  110. .type = MT_DEVICE,
  111. }, {
  112. .virtual = (unsigned long)S3C64XX_VA_MODEM,
  113. .pfn = __phys_to_pfn(S3C64XX_PA_MODEM),
  114. .length = SZ_4K,
  115. .type = MT_DEVICE,
  116. }, {
  117. .virtual = (unsigned long)S3C_VA_WATCHDOG,
  118. .pfn = __phys_to_pfn(S3C64XX_PA_WATCHDOG),
  119. .length = SZ_4K,
  120. .type = MT_DEVICE,
  121. }, {
  122. .virtual = (unsigned long)S3C_VA_USB_HSPHY,
  123. .pfn = __phys_to_pfn(S3C64XX_PA_USB_HSPHY),
  124. .length = SZ_1K,
  125. .type = MT_DEVICE,
  126. },
  127. };
  128. static struct bus_type s3c64xx_subsys = {
  129. .name = "s3c64xx-core",
  130. .dev_name = "s3c64xx-core",
  131. };
  132. static struct device s3c64xx_dev = {
  133. .bus = &s3c64xx_subsys,
  134. };
  135. /* read cpu identification code */
  136. void __init s3c64xx_init_io(struct map_desc *mach_desc, int size)
  137. {
  138. /* initialise the io descriptors we need for initialisation */
  139. iotable_init(s3c_iodesc, ARRAY_SIZE(s3c_iodesc));
  140. iotable_init(mach_desc, size);
  141. /* detect cpu id */
  142. s3c64xx_init_cpu();
  143. s3c_init_cpu(samsung_cpu_id, cpu_ids, ARRAY_SIZE(cpu_ids));
  144. }
  145. static __init int s3c64xx_dev_init(void)
  146. {
  147. subsys_system_register(&s3c64xx_subsys, NULL);
  148. return device_register(&s3c64xx_dev);
  149. }
  150. core_initcall(s3c64xx_dev_init);
  151. /*
  152. * setup the sources the vic should advertise resume
  153. * for, even though it is not doing the wake
  154. * (set_irq_wake needs to be valid)
  155. */
  156. #define IRQ_VIC0_RESUME (1 << (IRQ_RTC_TIC - IRQ_VIC0_BASE))
  157. #define IRQ_VIC1_RESUME (1 << (IRQ_RTC_ALARM - IRQ_VIC1_BASE) | \
  158. 1 << (IRQ_PENDN - IRQ_VIC1_BASE) | \
  159. 1 << (IRQ_HSMMC0 - IRQ_VIC1_BASE) | \
  160. 1 << (IRQ_HSMMC1 - IRQ_VIC1_BASE) | \
  161. 1 << (IRQ_HSMMC2 - IRQ_VIC1_BASE))
  162. void __init s3c64xx_init_irq(u32 vic0_valid, u32 vic1_valid)
  163. {
  164. printk(KERN_DEBUG "%s: initialising interrupts\n", __func__);
  165. /* initialise the pair of VICs */
  166. vic_init(VA_VIC0, IRQ_VIC0_BASE, vic0_valid, IRQ_VIC0_RESUME);
  167. vic_init(VA_VIC1, IRQ_VIC1_BASE, vic1_valid, IRQ_VIC1_RESUME);
  168. /* add the timer sub-irqs */
  169. s3c_init_vic_timer_irq(5, IRQ_TIMER0);
  170. }
  171. #define eint_offset(irq) ((irq) - IRQ_EINT(0))
  172. #define eint_irq_to_bit(irq) ((u32)(1 << eint_offset(irq)))
  173. static inline void s3c_irq_eint_mask(struct irq_data *data)
  174. {
  175. u32 mask;
  176. mask = __raw_readl(S3C64XX_EINT0MASK);
  177. mask |= (u32)data->chip_data;
  178. __raw_writel(mask, S3C64XX_EINT0MASK);
  179. }
  180. static void s3c_irq_eint_unmask(struct irq_data *data)
  181. {
  182. u32 mask;
  183. mask = __raw_readl(S3C64XX_EINT0MASK);
  184. mask &= ~((u32)data->chip_data);
  185. __raw_writel(mask, S3C64XX_EINT0MASK);
  186. }
  187. static inline void s3c_irq_eint_ack(struct irq_data *data)
  188. {
  189. __raw_writel((u32)data->chip_data, S3C64XX_EINT0PEND);
  190. }