averageValueOfWaterPressure.c 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232
  1. /*
  2. * marzen board support
  3. *
  4. * Copyright (C) 2011 Renesas Solutions Corp.
  5. * Copyright (C) 2011 Magnus Damm
  6. *
  7. * This program is free software; you can redistribute it and/or modify
  8. * it under the terms of the GNU General Public License as published by
  9. * the Free Software Foundation; version 2 of the License.
  10. *
  11. * This program is distributed in the hope that it will be useful,
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. * GNU General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU General Public License
  17. * along with this program; if not, write to the Free Software
  18. * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
  19. */
  20. #include <linux/kernel.h>
  21. #include <linux/init.h>
  22. #include <linux/interrupt.h>
  23. #include <linux/irq.h>
  24. #include <linux/platform_device.h>
  25. #include <linux/delay.h>
  26. #include <linux/io.h>
  27. #include <linux/gpio.h>
  28. #include <linux/dma-mapping.h>
  29. #include <linux/regulator/fixed.h>
  30. #include <linux/regulator/machine.h>
  31. #include <linux/smsc911x.h>
  32. #include <linux/spi/spi.h>
  33. #include <linux/spi/sh_hspi.h>
  34. #include <linux/mmc/sh_mobile_sdhi.h>
  35. #include <linux/mfd/tmio.h>
  36. #include <linux/usb/otg.h>
  37. #include <linux/usb/ehci_pdriver.h>
  38. #include <linux/usb/ohci_pdriver.h>
  39. #include <linux/pm_runtime.h>
  40. #include <mach/hardware.h>
  41. #include <mach/r8a7779.h>
  42. #include <mach/common.h>
  43. #include <mach/irqs.h>
  44. #include <asm/mach-types.h>
  45. #include <asm/mach/arch.h>
  46. #include <asm/hardware/gic.h>
  47. #include <asm/traps.h>
  48. /* Fixed 3.3V regulator to be used by SDHI0 */
  49. static struct regulator_consumer_supply fixed3v3_power_consumers[] = {
  50. REGULATOR_SUPPLY("vmmc", "sh_mobile_sdhi.0"),
  51. REGULATOR_SUPPLY("vqmmc", "sh_mobile_sdhi.0"),
  52. };
  53. /* Dummy supplies, where voltage doesn't matter */
  54. static struct regulator_consumer_supply dummy_supplies[] = {
  55. REGULATOR_SUPPLY("vddvario", "smsc911x"),
  56. REGULATOR_SUPPLY("vdd33a", "smsc911x"),
  57. };
  58. /* SMSC LAN89218 */
  59. static struct resource smsc911x_resources[] = {
  60. [0] = {
  61. .start = 0x18000000, /* ExCS0 */
  62. .end = 0x180000ff, /* A1->A7 */
  63. .flags = IORESOURCE_MEM,
  64. },
  65. [1] = {
  66. .start = gic_spi(28), /* IRQ 1 */
  67. .flags = IORESOURCE_IRQ,
  68. },
  69. };
  70. static struct smsc911x_platform_config smsc911x_platdata = {
  71. .flags = SMSC911X_USE_32BIT, /* 32-bit SW on 16-bit HW bus */
  72. .phy_interface = PHY_INTERFACE_MODE_MII,
  73. .irq_polarity = SMSC911X_IRQ_POLARITY_ACTIVE_LOW,
  74. .irq_type = SMSC911X_IRQ_TYPE_PUSH_PULL,
  75. };
  76. static struct platform_device eth_device = {
  77. .name = "smsc911x",
  78. .id = -1,
  79. .dev = {
  80. .platform_data = &smsc911x_platdata,
  81. },
  82. .resource = smsc911x_resources,
  83. .num_resources = ARRAY_SIZE(smsc911x_resources),
  84. };
  85. static struct resource sdhi0_resources[] = {
  86. [0] = {
  87. .name = "sdhi0",
  88. .start = 0xffe4c000,
  89. .end = 0xffe4c0ff,
  90. .flags = IORESOURCE_MEM,
  91. },
  92. [1] = {
  93. .start = gic_spi(104),
  94. .flags = IORESOURCE_IRQ,
  95. },
  96. };
  97. static struct sh_mobile_sdhi_info sdhi0_platform_data = {
  98. .tmio_flags = TMIO_MMC_WRPROTECT_DISABLE | TMIO_MMC_HAS_IDLE_WAIT,
  99. .tmio_caps = MMC_CAP_SD_HIGHSPEED,
  100. };
  101. static struct platform_device sdhi0_device = {
  102. .name = "sh_mobile_sdhi",
  103. .num_resources = ARRAY_SIZE(sdhi0_resources),
  104. .resource = sdhi0_resources,
  105. .id = 0,
  106. .dev = {
  107. .platform_data = &sdhi0_platform_data,
  108. }
  109. };
  110. /* Thermal */
  111. static struct resource thermal_resources[] = {
  112. [0] = {
  113. .start = 0xFFC48000,
  114. .end = 0xFFC48038 - 1,
  115. .flags = IORESOURCE_MEM,
  116. },
  117. };
  118. static struct platform_device thermal_device = {
  119. .name = "rcar_thermal",
  120. .resource = thermal_resources,
  121. .num_resources = ARRAY_SIZE(thermal_resources),
  122. };
  123. /* HSPI */
  124. static struct resource hspi_resources[] = {
  125. [0] = {
  126. .start = 0xFFFC7000,
  127. .end = 0xFFFC7018 - 1,
  128. .flags = IORESOURCE_MEM,
  129. },
  130. };
  131. static struct platform_device hspi_device = {
  132. .name = "sh-hspi",
  133. .id = 0,
  134. .resource = hspi_resources,
  135. .num_resources = ARRAY_SIZE(hspi_resources),
  136. };
  137. /* USB PHY */
  138. static struct resource usb_phy_resources[] = {
  139. [0] = {
  140. .start = 0xffe70000,
  141. .end = 0xffe70900 - 1,
  142. .flags = IORESOURCE_MEM,
  143. },
  144. [1] = {
  145. .start = 0xfff70000,
  146. .end = 0xfff70900 - 1,
  147. .flags = IORESOURCE_MEM,
  148. },
  149. };
  150. static struct platform_device usb_phy_device = {
  151. .name = "rcar_usb_phy",
  152. .resource = usb_phy_resources,
  153. .num_resources = ARRAY_SIZE(usb_phy_resources),
  154. };
  155. static struct platform_device *marzen_devices[] __initdata = {
  156. &eth_device,
  157. &sdhi0_device,
  158. &thermal_device,
  159. &hspi_device,
  160. &usb_phy_device,
  161. };
  162. /* USB */
  163. static struct usb_phy *phy;
  164. static int usb_power_on(struct platform_device *pdev)
  165. {
  166. if (!phy)
  167. return -EIO;
  168. pm_runtime_enable(&pdev->dev);
  169. pm_runtime_get_sync(&pdev->dev);
  170. usb_phy_init(phy);
  171. return 0;
  172. }
  173. static void usb_power_off(struct platform_device *pdev)
  174. {
  175. if (!phy)
  176. return;
  177. usb_phy_shutdown(phy);
  178. pm_runtime_put_sync(&pdev->dev);
  179. pm_runtime_disable(&pdev->dev);
  180. }
  181. static struct usb_ehci_pdata ehcix_pdata = {
  182. .power_on = usb_power_on,
  183. .power_off = usb_power_off,
  184. .power_suspend = usb_power_off,
  185. };
  186. static struct resource ehci0_resources[] = {
  187. [0] = {
  188. .start = 0xffe70000,
  189. .end = 0xffe70400 - 1,
  190. .flags = IORESOURCE_MEM,
  191. },
  192. [1] = {
  193. .start = gic_spi(44),
  194. .flags = IORESOURCE_IRQ,
  195. },
  196. };
  197. static struct platform_device ehci0_device = {
  198. .name = "ehci-platform",
  199. .id = 0,
  200. .dev = {
  201. .dma_mask = &ehci0_device.dev.coherent_dma_mask,
  202. .coherent_dma_mask = 0xffffffff,
  203. .platform_data = &ehcix_pdata,
  204. },
  205. .num_resources = ARRAY_SIZE(ehci0_resources),
  206. .resource = ehci0_resources,