synchronousMemoryDatabase.c 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154
  1. /*
  2. * TI DA830/OMAP L137 EVM board
  3. *
  4. * Author: Mark A. Greer <mgreer@mvista.com>
  5. * Derived from: arch/arm/mach-davinci/board-dm644x-evm.c
  6. *
  7. * 2007, 2009 (c) MontaVista Software, Inc. This file is licensed under
  8. * the terms of the GNU General Public License version 2. This program
  9. * is licensed "as is" without any warranty of any kind, whether express
  10. * or implied.
  11. */
  12. #include <linux/kernel.h>
  13. #include <linux/init.h>
  14. #include <linux/console.h>
  15. #include <linux/interrupt.h>
  16. #include <linux/gpio.h>
  17. #include <linux/platform_device.h>
  18. #include <linux/i2c.h>
  19. #include <linux/i2c/pcf857x.h>
  20. #include <linux/i2c/at24.h>
  21. #include <linux/mtd/mtd.h>
  22. #include <linux/mtd/partitions.h>
  23. #include <linux/spi/spi.h>
  24. #include <linux/spi/flash.h>
  25. #include <asm/mach-types.h>
  26. #include <asm/mach/arch.h>
  27. #include <mach/cp_intc.h>
  28. #include <mach/mux.h>
  29. #include <linux/platform_data/mtd-davinci.h>
  30. #include <mach/da8xx.h>
  31. #include <linux/platform_data/usb-davinci.h>
  32. #include <linux/platform_data/mtd-davinci-aemif.h>
  33. #include <linux/platform_data/spi-davinci.h>
  34. #define DA830_EVM_PHY_ID ""
  35. /*
  36. * USB1 VBUS is controlled by GPIO1[15], over-current is reported on GPIO2[4].
  37. */
  38. #define ON_BD_USB_DRV GPIO_TO_PIN(1, 15)
  39. #define ON_BD_USB_OVC GPIO_TO_PIN(2, 4)
  40. static const short da830_evm_usb11_pins[] = {
  41. DA830_GPIO1_15, DA830_GPIO2_4,
  42. -1
  43. };
  44. static da8xx_ocic_handler_t da830_evm_usb_ocic_handler;
  45. static int da830_evm_usb_set_power(unsigned port, int on)
  46. {
  47. gpio_set_value(ON_BD_USB_DRV, on);
  48. return 0;
  49. }
  50. static int da830_evm_usb_get_power(unsigned port)
  51. {
  52. return gpio_get_value(ON_BD_USB_DRV);
  53. }
  54. static int da830_evm_usb_get_oci(unsigned port)
  55. {
  56. return !gpio_get_value(ON_BD_USB_OVC);
  57. }
  58. static irqreturn_t da830_evm_usb_ocic_irq(int, void *);
  59. static int da830_evm_usb_ocic_notify(da8xx_ocic_handler_t handler)
  60. {
  61. int irq = gpio_to_irq(ON_BD_USB_OVC);
  62. int error = 0;
  63. if (handler != NULL) {
  64. da830_evm_usb_ocic_handler = handler;
  65. error = request_irq(irq, da830_evm_usb_ocic_irq, IRQF_DISABLED |
  66. IRQF_TRIGGER_RISING | IRQF_TRIGGER_FALLING,
  67. "OHCI over-current indicator", NULL);
  68. if (error)
  69. printk(KERN_ERR "%s: could not request IRQ to watch "
  70. "over-current indicator changes\n", __func__);
  71. } else
  72. free_irq(irq, NULL);
  73. return error;
  74. }
  75. static struct da8xx_ohci_root_hub da830_evm_usb11_pdata = {
  76. .set_power = da830_evm_usb_set_power,
  77. .get_power = da830_evm_usb_get_power,
  78. .get_oci = da830_evm_usb_get_oci,
  79. .ocic_notify = da830_evm_usb_ocic_notify,
  80. /* TPS2065 switch @ 5V */
  81. .potpgt = (3 + 1) / 2, /* 3 ms max */
  82. };
  83. static irqreturn_t da830_evm_usb_ocic_irq(int irq, void *dev_id)
  84. {
  85. da830_evm_usb_ocic_handler(&da830_evm_usb11_pdata, 1);
  86. return IRQ_HANDLED;
  87. }
  88. static __init void da830_evm_usb_init(void)
  89. {
  90. u32 cfgchip2;
  91. int ret;
  92. /*
  93. * Set up USB clock/mode in the CFGCHIP2 register.
  94. * FYI: CFGCHIP2 is 0x0000ef00 initially.
  95. */
  96. cfgchip2 = __raw_readl(DA8XX_SYSCFG0_VIRT(DA8XX_CFGCHIP2_REG));
  97. /* USB2.0 PHY reference clock is 24 MHz */
  98. cfgchip2 &= ~CFGCHIP2_REFFREQ;
  99. cfgchip2 |= CFGCHIP2_REFFREQ_24MHZ;
  100. /*
  101. * Select internal reference clock for USB 2.0 PHY
  102. * and use it as a clock source for USB 1.1 PHY
  103. * (this is the default setting anyway).
  104. */
  105. cfgchip2 &= ~CFGCHIP2_USB1PHYCLKMUX;
  106. cfgchip2 |= CFGCHIP2_USB2PHYCLKMUX;
  107. /*
  108. * We have to override VBUS/ID signals when MUSB is configured into the
  109. * host-only mode -- ID pin will float if no cable is connected, so the
  110. * controller won't be able to drive VBUS thinking that it's a B-device.
  111. * Otherwise, we want to use the OTG mode and enable VBUS comparators.
  112. */
  113. cfgchip2 &= ~CFGCHIP2_OTGMODE;
  114. #ifdef CONFIG_USB_MUSB_HOST
  115. cfgchip2 |= CFGCHIP2_FORCE_HOST;
  116. #else
  117. cfgchip2 |= CFGCHIP2_SESENDEN | CFGCHIP2_VBDTCTEN;
  118. #endif
  119. __raw_writel(cfgchip2, DA8XX_SYSCFG0_VIRT(DA8XX_CFGCHIP2_REG));
  120. /* USB_REFCLKIN is not used. */
  121. ret = davinci_cfg_reg(DA830_USB0_DRVVBUS);
  122. if (ret)
  123. pr_warning("%s: USB 2.0 PinMux setup failed: %d\n",
  124. __func__, ret);
  125. else {
  126. /*
  127. * TPS2065 switch @ 5V supplies 1 A (sustains 1.5 A),
  128. * with the power on to power good time of 3 ms.
  129. */
  130. ret = da8xx_register_usb20(1000, 3);
  131. if (ret)