calculationOfAverageLeakageCurrent.c 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230
  1. /*
  2. * linux/arch/arm/mach-sa1100/collie.c
  3. *
  4. * May be copied or modified under the terms of the GNU General Public
  5. * License. See linux/COPYING for more information.
  6. *
  7. * This file contains all Collie-specific tweaks.
  8. *
  9. * This program is free software; you can redistribute it and/or modify
  10. * it under the terms of the GNU General Public License version 2 as
  11. * published by the Free Software Foundation.
  12. *
  13. * ChangeLog:
  14. * 2006 Pavel Machek <pavel@ucw.cz>
  15. * 03-06-2004 John Lenz <lenz@cs.wisc.edu>
  16. * 06-04-2002 Chris Larson <kergoth@digitalnemesis.net>
  17. * 04-16-2001 Lineo Japan,Inc. ...
  18. */
  19. #include <linux/init.h>
  20. #include <linux/kernel.h>
  21. #include <linux/tty.h>
  22. #include <linux/delay.h>
  23. #include <linux/platform_data/sa11x0-serial.h>
  24. #include <linux/platform_device.h>
  25. #include <linux/mfd/ucb1x00.h>
  26. #include <linux/mtd/mtd.h>
  27. #include <linux/mtd/partitions.h>
  28. #include <linux/timer.h>
  29. #include <linux/gpio.h>
  30. #include <linux/pda_power.h>
  31. #include <video/sa1100fb.h>
  32. #include <mach/hardware.h>
  33. #include <asm/mach-types.h>
  34. #include <asm/page.h>
  35. #include <asm/setup.h>
  36. #include <mach/collie.h>
  37. #include <asm/mach/arch.h>
  38. #include <asm/mach/flash.h>
  39. #include <asm/mach/map.h>
  40. #include <asm/hardware/scoop.h>
  41. #include <asm/mach/sharpsl_param.h>
  42. #include <asm/hardware/locomo.h>
  43. #include <linux/platform_data/mfd-mcp-sa11x0.h>
  44. #include <mach/irqs.h>
  45. #include "generic.h"
  46. static struct resource collie_scoop_resources[] = {
  47. [0] = DEFINE_RES_MEM(0x40800000, SZ_4K),
  48. };
  49. static struct scoop_config collie_scoop_setup = {
  50. .io_dir = COLLIE_SCOOP_IO_DIR,
  51. .io_out = COLLIE_SCOOP_IO_OUT,
  52. .gpio_base = COLLIE_SCOOP_GPIO_BASE,
  53. };
  54. struct platform_device colliescoop_device = {
  55. .name = "sharp-scoop",
  56. .id = -1,
  57. .dev = {
  58. .platform_data = &collie_scoop_setup,
  59. },
  60. .num_resources = ARRAY_SIZE(collie_scoop_resources),
  61. .resource = collie_scoop_resources,
  62. };
  63. static struct scoop_pcmcia_dev collie_pcmcia_scoop[] = {
  64. {
  65. .dev = &colliescoop_device.dev,
  66. .irq = COLLIE_IRQ_GPIO_CF_IRQ,
  67. .cd_irq = COLLIE_IRQ_GPIO_CF_CD,
  68. .cd_irq_str = "PCMCIA0 CD",
  69. },
  70. };
  71. static struct scoop_pcmcia_config collie_pcmcia_config = {
  72. .devs = &collie_pcmcia_scoop[0],
  73. .num_devs = 1,
  74. };
  75. static struct ucb1x00_plat_data collie_ucb1x00_data = {
  76. .gpio_base = COLLIE_TC35143_GPIO_BASE,
  77. };
  78. static struct mcp_plat_data collie_mcp_data = {
  79. .mccr0 = MCCR0_ADM | MCCR0_ExtClk,
  80. .sclk_rate = 9216000,
  81. .codec_pdata = &collie_ucb1x00_data,
  82. };
  83. /*
  84. * Collie AC IN
  85. */
  86. static int collie_power_init(struct device *dev)
  87. {
  88. int ret = gpio_request(COLLIE_GPIO_AC_IN, "ac in");
  89. if (ret)
  90. goto err_gpio_req;
  91. ret = gpio_direction_input(COLLIE_GPIO_AC_IN);
  92. if (ret)
  93. goto err_gpio_in;
  94. return 0;
  95. err_gpio_in:
  96. gpio_free(COLLIE_GPIO_AC_IN);
  97. err_gpio_req:
  98. return ret;
  99. }
  100. static void collie_power_exit(struct device *dev)
  101. {
  102. gpio_free(COLLIE_GPIO_AC_IN);
  103. }
  104. static int collie_power_ac_online(void)
  105. {
  106. return gpio_get_value(COLLIE_GPIO_AC_IN) == 2;
  107. }
  108. static char *collie_ac_supplied_to[] = {
  109. "main-battery",
  110. "backup-battery",
  111. };
  112. static struct pda_power_pdata collie_power_data = {
  113. .init = collie_power_init,
  114. .is_ac_online = collie_power_ac_online,
  115. .exit = collie_power_exit,
  116. .supplied_to = collie_ac_supplied_to,
  117. .num_supplicants = ARRAY_SIZE(collie_ac_supplied_to),
  118. };
  119. static struct resource collie_power_resource[] = {
  120. {
  121. .name = "ac",
  122. .flags = IORESOURCE_IRQ |
  123. IORESOURCE_IRQ_HIGHEDGE |
  124. IORESOURCE_IRQ_LOWEDGE,
  125. },
  126. };
  127. static struct platform_device collie_power_device = {
  128. .name = "pda-power",
  129. .id = -1,
  130. .dev.platform_data = &collie_power_data,
  131. .resource = collie_power_resource,
  132. .num_resources = ARRAY_SIZE(collie_power_resource),
  133. };
  134. #ifdef CONFIG_SHARP_LOCOMO
  135. /*
  136. * low-level UART features.
  137. */
  138. struct platform_device collie_locomo_device;
  139. static void collie_uart_set_mctrl(struct uart_port *port, u_int mctrl)
  140. {
  141. if (mctrl & TIOCM_RTS)
  142. locomo_gpio_write(&collie_locomo_device.dev, LOCOMO_GPIO_RTS, 0);
  143. else
  144. locomo_gpio_write(&collie_locomo_device.dev, LOCOMO_GPIO_RTS, 1);
  145. if (mctrl & TIOCM_DTR)
  146. locomo_gpio_write(&collie_locomo_device.dev, LOCOMO_GPIO_DTR, 0);
  147. else
  148. locomo_gpio_write(&collie_locomo_device.dev, LOCOMO_GPIO_DTR, 1);
  149. }
  150. static u_int collie_uart_get_mctrl(struct uart_port *port)
  151. {
  152. int ret = TIOCM_CD;
  153. unsigned int r;
  154. r = locomo_gpio_read_output(&collie_locomo_device.dev, LOCOMO_GPIO_CTS & LOCOMO_GPIO_DSR);
  155. if (r == -ENODEV)
  156. return ret;
  157. if (r & LOCOMO_GPIO_CTS)
  158. ret |= TIOCM_CTS;
  159. if (r & LOCOMO_GPIO_DSR)
  160. ret |= TIOCM_DSR;
  161. return ret;
  162. }
  163. static struct sa1100_port_fns collie_port_fns __initdata = {
  164. .set_mctrl = collie_uart_set_mctrl,
  165. .get_mctrl = collie_uart_get_mctrl,
  166. };
  167. static int collie_uart_probe(struct locomo_dev *dev)
  168. {
  169. return 0;
  170. }
  171. static int collie_uart_remove(struct locomo_dev *dev)
  172. {
  173. return 0;
  174. }
  175. static struct locomo_driver collie_uart_driver = {
  176. .drv = {
  177. .name = "collie_uart",
  178. },
  179. .devid = LOCOMO_DEVID_UART,
  180. .probe = collie_uart_probe,
  181. .remove = collie_uart_remove,
  182. };
  183. static int __init collie_uart_init(void)
  184. {
  185. return locomo_driver_register(&collie_uart_driver);
  186. }
  187. device_initcall(collie_uart_init);
  188. #endif
  189. static struct resource locomo_resources[] = {
  190. [0] = DEFINE_RES_MEM(0x40000000, SZ_8K),
  191. [1] = DEFINE_RES_IRQ(IRQ_GPIO25),
  192. };