rtuTemperatureHumidityDataOperation.c 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183
  1. /*
  2. * Platform level USB initialization for FS USB OTG controller on omap1 and 24xx
  3. *
  4. * Copyright (C) 2004 Texas Instruments, Inc.
  5. *
  6. * This program is free software; you can redistribute it and/or modify
  7. * it under the terms of the GNU General Public License as published by
  8. * the Free Software Foundation; either version 2 of the License, or
  9. * (at your option) any later version.
  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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  19. */
  20. #include <linux/module.h>
  21. #include <linux/kernel.h>
  22. #include <linux/init.h>
  23. #include <linux/platform_device.h>
  24. #include <linux/io.h>
  25. #include <asm/irq.h>
  26. #include <mach/mux.h>
  27. #include <mach/usb.h>
  28. #include "common.h"
  29. /* These routines should handle the standard chip-specific modes
  30. * for usb0/1/2 ports, covering basic mux and transceiver setup.
  31. *
  32. * Some board-*.c files will need to set up additional mux options,
  33. * like for suspend handling, vbus sensing, GPIOs, and the D+ pullup.
  34. */
  35. /* TESTED ON:
  36. * - 1611B H2 (with usb1 mini-AB) using standard Mini-B or OTG cables
  37. * - 5912 OSK OHCI (with usb0 standard-A), standard A-to-B cables
  38. * - 5912 OSK UDC, with *nonstandard* A-to-A cable
  39. * - 1510 Innovator UDC with bundled usb0 cable
  40. * - 1510 Innovator OHCI with bundled usb1/usb2 cable
  41. * - 1510 Innovator OHCI with custom usb0 cable, feeding 5V VBUS
  42. * - 1710 custom development board using alternate pin group
  43. * - 1710 H3 (with usb1 mini-AB) using standard Mini-B or OTG cables
  44. */
  45. #define INT_USB_IRQ_GEN IH2_BASE + 20
  46. #define INT_USB_IRQ_NISO IH2_BASE + 30
  47. #define INT_USB_IRQ_ISO IH2_BASE + 29
  48. #define INT_USB_IRQ_HGEN INT_USB_HHC_1
  49. #define INT_USB_IRQ_OTG IH2_BASE + 8
  50. #ifdef CONFIG_ARCH_OMAP_OTG
  51. void __init
  52. omap_otg_init(struct omap_usb_config *config)
  53. {
  54. u32 syscon;
  55. int alt_pingroup = 0;
  56. /* NOTE: no bus or clock setup (yet?) */
  57. syscon = omap_readl(OTG_SYSCON_1) & 0xffff;
  58. if (!(syscon & OTG_RESET_DONE))
  59. pr_debug("USB resets not complete?\n");
  60. //omap_writew(0, OTG_IRQ_EN);
  61. /* pin muxing and transceiver pinouts */
  62. if (config->pins[0] > 2) /* alt pingroup 2 */
  63. alt_pingroup = 1;
  64. syscon |= config->usb0_init(config->pins[0], is_usb0_device(config));
  65. syscon |= config->usb1_init(config->pins[1]);
  66. syscon |= config->usb2_init(config->pins[2], alt_pingroup);
  67. pr_debug("OTG_SYSCON_1 = %08x\n", omap_readl(OTG_SYSCON_1));
  68. omap_writel(syscon, OTG_SYSCON_1);
  69. syscon = config->hmc_mode;
  70. syscon |= USBX_SYNCHRO | (4 << 16) /* B_ASE0_BRST */;
  71. #ifdef CONFIG_USB_OTG
  72. if (config->otg)
  73. syscon |= OTG_EN;
  74. #endif
  75. if (cpu_class_is_omap1())
  76. pr_debug("USB_TRANSCEIVER_CTRL = %03x\n",
  77. omap_readl(USB_TRANSCEIVER_CTRL));
  78. pr_debug("OTG_SYSCON_2 = %08x\n", omap_readl(OTG_SYSCON_2));
  79. omap_writel(syscon, OTG_SYSCON_2);
  80. printk("USB: hmc %d", config->hmc_mode);
  81. if (!alt_pingroup)
  82. printk(", usb2 alt %d wires", config->pins[2]);
  83. else if (config->pins[0])
  84. printk(", usb0 %d wires%s", config->pins[0],
  85. is_usb0_device(config) ? " (dev)" : "");
  86. if (config->pins[1])
  87. printk(", usb1 %d wires", config->pins[1]);
  88. if (!alt_pingroup && config->pins[2])
  89. printk(", usb2 %d wires", config->pins[2]);
  90. if (config->otg)
  91. printk(", Mini-AB on usb%d", config->otg - 1);
  92. printk("\n");
  93. if (cpu_class_is_omap1()) {
  94. u16 w;
  95. /* leave USB clocks/controllers off until needed */
  96. w = omap_readw(ULPD_SOFT_REQ);
  97. w &= ~SOFT_USB_CLK_REQ;
  98. omap_writew(w, ULPD_SOFT_REQ);
  99. w = omap_readw(ULPD_CLOCK_CTRL);
  100. w &= ~USB_MCLK_EN;
  101. w |= DIS_USB_PVCI_CLK;
  102. omap_writew(w, ULPD_CLOCK_CTRL);
  103. }
  104. syscon = omap_readl(OTG_SYSCON_1);
  105. syscon |= HST_IDLE_EN|DEV_IDLE_EN|OTG_IDLE_EN;
  106. #ifdef CONFIG_USB_GADGET_OMAP
  107. if (config->otg || config->register_dev) {
  108. struct platform_device *udc_device = config->udc_device;
  109. int status;
  110. syscon &= ~DEV_IDLE_EN;
  111. udc_device->dev.platform_data = config;
  112. status = platform_device_register(udc_device);
  113. if (status)
  114. pr_debug("can't register UDC device, %d\n", status);
  115. }
  116. #endif
  117. #if defined(CONFIG_USB_OHCI_HCD) || defined(CONFIG_USB_OHCI_HCD_MODULE)
  118. if (config->otg || config->register_host) {
  119. struct platform_device *ohci_device = config->ohci_device;
  120. int status;
  121. syscon &= ~HST_IDLE_EN;
  122. ohci_device->dev.platform_data = config;
  123. status = platform_device_register(ohci_device);
  124. if (status)
  125. pr_debug("can't register OHCI device, %d\n", status);
  126. }
  127. #endif
  128. #ifdef CONFIG_USB_OTG
  129. if (config->otg) {
  130. struct platform_device *otg_device = config->otg_device;
  131. int status;
  132. syscon &= ~OTG_IDLE_EN;
  133. otg_device->dev.platform_data = config;
  134. status = platform_device_register(otg_device);
  135. if (status)
  136. pr_debug("can't register OTG device, %d\n", status);
  137. }
  138. #endif
  139. pr_debug("OTG_SYSCON_1 = %08x\n", omap_readl(OTG_SYSCON_1));
  140. omap_writel(syscon, OTG_SYSCON_1);
  141. }
  142. #else
  143. void omap_otg_init(struct omap_usb_config *config) {}
  144. #endif
  145. #ifdef CONFIG_USB_GADGET_OMAP
  146. static struct resource udc_resources[] = {
  147. /* order is significant! */
  148. { /* registers */
  149. .start = UDC_BASE,
  150. .end = UDC_BASE + 0xff,
  151. .flags = IORESOURCE_MEM,
  152. }, { /* general IRQ */
  153. .start = INT_USB_IRQ_GEN,
  154. .flags = IORESOURCE_IRQ,
  155. }, { /* PIO IRQ */