calculationDeviationOfLeakageCurrent.c 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234
  1. /*
  2. * linux/arch/arm/mach-sa1100/assabet.c
  3. *
  4. * Author: Nicolas Pitre
  5. *
  6. * This file contains all Assabet-specific tweaks.
  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. #include <linux/init.h>
  13. #include <linux/kernel.h>
  14. #include <linux/module.h>
  15. #include <linux/errno.h>
  16. #include <linux/ioport.h>
  17. #include <linux/platform_data/sa11x0-serial.h>
  18. #include <linux/serial_core.h>
  19. #include <linux/mfd/ucb1x00.h>
  20. #include <linux/mtd/mtd.h>
  21. #include <linux/mtd/partitions.h>
  22. #include <linux/delay.h>
  23. #include <linux/mm.h>
  24. #include <linux/leds.h>
  25. #include <linux/slab.h>
  26. #include <video/sa1100fb.h>
  27. #include <mach/hardware.h>
  28. #include <asm/mach-types.h>
  29. #include <asm/setup.h>
  30. #include <asm/page.h>
  31. #include <asm/pgtable-hwdef.h>
  32. #include <asm/pgtable.h>
  33. #include <asm/tlbflush.h>
  34. #include <asm/mach/arch.h>
  35. #include <asm/mach/flash.h>
  36. #include <asm/mach/irda.h>
  37. #include <asm/mach/map.h>
  38. #include <mach/assabet.h>
  39. #include <linux/platform_data/mfd-mcp-sa11x0.h>
  40. #include <mach/irqs.h>
  41. #include "generic.h"
  42. #define ASSABET_BCR_DB1110 \
  43. (ASSABET_BCR_SPK_OFF | \
  44. ASSABET_BCR_LED_GREEN | ASSABET_BCR_LED_RED | \
  45. ASSABET_BCR_RS232EN | ASSABET_BCR_LCD_12RGB | \
  46. ASSABET_BCR_IRDA_MD0)
  47. #define ASSABET_BCR_DB1111 \
  48. (ASSABET_BCR_SPK_OFF | \
  49. ASSABET_BCR_LED_GREEN | ASSABET_BCR_LED_RED | \
  50. ASSABET_BCR_RS232EN | ASSABET_BCR_LCD_12RGB | \
  51. ASSABET_BCR_CF_BUS_OFF | ASSABET_BCR_STEREO_LB | \
  52. ASSABET_BCR_IRDA_MD0 | ASSABET_BCR_CF_RST)
  53. unsigned long SCR_value = ASSABET_SCR_INIT;
  54. EXPORT_SYMBOL(SCR_value);
  55. static unsigned long BCR_value = ASSABET_BCR_DB1110;
  56. void ASSABET_BCR_frob(unsigned int mask, unsigned int val)
  57. {
  58. unsigned long flags;
  59. local_irq_save(flags);
  60. BCR_value = (BCR_value & ~mask) | val;
  61. ASSABET_BCR = BCR_value;
  62. local_irq_restore(flags);
  63. }
  64. EXPORT_SYMBOL(ASSABET_BCR_frob);
  65. static void assabet_ucb1x00_reset(enum ucb1x00_reset state)
  66. {
  67. if (state == UCB_RST_PROBE)
  68. ASSABET_BCR_set(ASSABET_BCR_CODEC_RST);
  69. }
  70. /*
  71. * Assabet flash support code.
  72. */
  73. #ifdef ASSABET_REV_4
  74. /*
  75. * Phase 4 Assabet has two 28F160B3 flash parts in bank 0:
  76. */
  77. static struct mtd_partition assabet_partitions[] = {
  78. {
  79. .name = "bootloader",
  80. .size = 0x00020000,
  81. .offset = 0,
  82. .mask_flags = MTD_WRITEABLE,
  83. }, {
  84. .name = "bootloader params",
  85. .size = 0x00020000,
  86. .offset = MTDPART_OFS_APPEND,
  87. .mask_flags = MTD_WRITEABLE,
  88. }, {
  89. .name = "jffs",
  90. .size = MTDPART_SIZ_FULL,
  91. .offset = MTDPART_OFS_APPEND,
  92. }
  93. };
  94. #else
  95. /*
  96. * Phase 5 Assabet has two 28F128J3A flash parts in bank 0:
  97. */
  98. static struct mtd_partition assabet_partitions[] = {
  99. {
  100. .name = "bootloader",
  101. .size = 0x00040000,
  102. .offset = 0,
  103. .mask_flags = MTD_WRITEABLE,
  104. }, {
  105. .name = "bootloader params",
  106. .size = 0x00040000,
  107. .offset = MTDPART_OFS_APPEND,
  108. .mask_flags = MTD_WRITEABLE,
  109. }, {
  110. .name = "jffs",
  111. .size = MTDPART_SIZ_FULL,
  112. .offset = MTDPART_OFS_APPEND,
  113. }
  114. };
  115. #endif
  116. static struct flash_platform_data assabet_flash_data = {
  117. .map_name = "cfi_probe",
  118. .parts = assabet_partitions,
  119. .nr_parts = ARRAY_SIZE(assabet_partitions),
  120. };
  121. static struct resource assabet_flash_resources[] = {
  122. DEFINE_RES_MEM(SA1100_CS0_PHYS, SZ_32M),
  123. DEFINE_RES_MEM(SA1100_CS1_PHYS, SZ_32M),
  124. };
  125. /*
  126. * Assabet IrDA support code.
  127. */
  128. static int assabet_irda_set_power(struct device *dev, unsigned int state)
  129. {
  130. static unsigned int bcr_state[4] = {
  131. ASSABET_BCR_IRDA_MD0,
  132. ASSABET_BCR_IRDA_MD1|ASSABET_BCR_IRDA_MD0,
  133. ASSABET_BCR_IRDA_MD1,
  134. 0
  135. };
  136. if (state < 4) {
  137. state = bcr_state[state];
  138. ASSABET_BCR_clear(state ^ (ASSABET_BCR_IRDA_MD1|
  139. ASSABET_BCR_IRDA_MD0));
  140. ASSABET_BCR_set(state);
  141. }
  142. return 0;
  143. }
  144. static void assabet_irda_set_speed(struct device *dev, unsigned int speed)
  145. {
  146. if (speed < 4000000)
  147. ASSABET_BCR_clear(ASSABET_BCR_IRDA_FSEL);
  148. else
  149. ASSABET_BCR_set(ASSABET_BCR_IRDA_FSEL);
  150. }
  151. static struct irda_platform_data assabet_irda_data = {
  152. .set_power = assabet_irda_set_power,
  153. .set_speed = assabet_irda_set_speed,
  154. };
  155. static struct ucb1x00_plat_data assabet_ucb1x00_data = {
  156. .reset = assabet_ucb1x00_reset,
  157. .gpio_base = -1,
  158. };
  159. static struct mcp_plat_data assabet_mcp_data = {
  160. .mccr0 = MCCR0_ADM,
  161. .sclk_rate = 11981000,
  162. .codec_pdata = &assabet_ucb1x00_data,
  163. };
  164. static void assabet_lcd_set_visual(u32 visual)
  165. {
  166. u_int is_true_color = visual == FB_VISUAL_TRUECOLOR;
  167. if (machine_is_assabet()) {
  168. #if 1 // phase 4 or newer Assabet's
  169. if (is_true_color)
  170. ASSABET_BCR_set(ASSABET_BCR_LCD_12RGB);
  171. else
  172. ASSABET_BCR_clear(ASSABET_BCR_LCD_12RGB);
  173. #else
  174. // older Assabet's
  175. if (is_true_color)
  176. ASSABET_BCR_clear(ASSABET_BCR_LCD_12RGB);
  177. else
  178. ASSABET_BCR_set(ASSABET_BCR_LCD_12RGB);
  179. #endif
  180. }
  181. }
  182. #ifndef ASSABET_PAL_VIDEO
  183. static void assabet_lcd_backlight_power(int on)
  184. {
  185. if (on)
  186. ASSABET_BCR_set(ASSABET_BCR_LIGHT_ON);
  187. else
  188. ASSABET_BCR_clear(ASSABET_BCR_LIGHT_ON);
  189. }
  190. /*
  191. * Turn on/off the backlight. When turning the backlight on, we wait
  192. * 500us after turning it on so we don't cause the supplies to droop
  193. * when we enable the LCD controller (and cause a hard reset.)
  194. */
  195. static void assabet_lcd_power(int on)
  196. {
  197. if (on) {
  198. ASSABET_BCR_set(ASSABET_BCR_LCD_ON);
  199. udelay(500);
  200. } else
  201. ASSABET_BCR_clear(ASSABET_BCR_LCD_ON);
  202. }
  203. /*
  204. * The assabet uses a sharp LQ039Q2DS54 LCD module. It is actually