realizationOfDataCalculation.c 6.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222
  1. /*
  2. * linux/arch/arm/mach-omap1/board-osk.c
  3. *
  4. * Board specific init for OMAP5912 OSK
  5. *
  6. * Written by Dirk Behme <dirk.behme@de.bosch.com>
  7. *
  8. * This program is free software; you can redistribute it and/or modify it
  9. * under the terms of the GNU General Public License as published by the
  10. * Free Software Foundation; either version 2 of the License, or (at your
  11. * option) any later version.
  12. *
  13. * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED
  14. * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
  15. * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN
  16. * NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
  17. * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
  18. * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
  19. * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
  20. * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  21. * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
  22. * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  23. *
  24. * You should have received a copy of the GNU General Public License along
  25. * with this program; if not, write to the Free Software Foundation, Inc.,
  26. * 675 Mass Ave, Cambridge, MA 02139, USA.
  27. */
  28. #include <linux/gpio.h>
  29. #include <linux/kernel.h>
  30. #include <linux/init.h>
  31. #include <linux/platform_device.h>
  32. #include <linux/interrupt.h>
  33. #include <linux/irq.h>
  34. #include <linux/i2c.h>
  35. #include <linux/leds.h>
  36. #include <linux/smc91x.h>
  37. #include <linux/omapfb.h>
  38. #include <linux/mtd/mtd.h>
  39. #include <linux/mtd/partitions.h>
  40. #include <linux/mtd/physmap.h>
  41. #include <linux/i2c/tps65010.h>
  42. #include <linux/platform_data/gpio-omap.h>
  43. #include <linux/platform_data/omap1_bl.h>
  44. #include <asm/mach-types.h>
  45. #include <asm/mach/arch.h>
  46. #include <asm/mach/map.h>
  47. #include <mach/flash.h>
  48. #include <mach/mux.h>
  49. #include <mach/tc.h>
  50. #include <mach/hardware.h>
  51. #include <mach/usb.h>
  52. #include "common.h"
  53. /* At OMAP5912 OSK the Ethernet is directly connected to CS1 */
  54. #define OMAP_OSK_ETHR_START 0x04800300
  55. /* TPS65010 has four GPIOs. nPG and LED2 can be treated like GPIOs with
  56. * alternate pin configurations for hardware-controlled blinking.
  57. */
  58. #define OSK_TPS_GPIO_BASE (OMAP_MAX_GPIO_LINES + 16 /* MPUIO */)
  59. # define OSK_TPS_GPIO_USB_PWR_EN (OSK_TPS_GPIO_BASE + 0)
  60. # define OSK_TPS_GPIO_LED_D3 (OSK_TPS_GPIO_BASE + 1)
  61. # define OSK_TPS_GPIO_LAN_RESET (OSK_TPS_GPIO_BASE + 2)
  62. # define OSK_TPS_GPIO_DSP_PWR_EN (OSK_TPS_GPIO_BASE + 3)
  63. # define OSK_TPS_GPIO_LED_D9 (OSK_TPS_GPIO_BASE + 4)
  64. # define OSK_TPS_GPIO_LED_D2 (OSK_TPS_GPIO_BASE + 5)
  65. static struct mtd_partition osk_partitions[] = {
  66. /* bootloader (U-Boot, etc) in first sector */
  67. {
  68. .name = "bootloader",
  69. .offset = 0,
  70. .size = SZ_128K,
  71. .mask_flags = MTD_WRITEABLE, /* force read-only */
  72. },
  73. /* bootloader params in the next sector */
  74. {
  75. .name = "params",
  76. .offset = MTDPART_OFS_APPEND,
  77. .size = SZ_128K,
  78. .mask_flags = 0,
  79. }, {
  80. .name = "kernel",
  81. .offset = MTDPART_OFS_APPEND,
  82. .size = SZ_2M,
  83. .mask_flags = 0
  84. }, {
  85. .name = "filesystem",
  86. .offset = MTDPART_OFS_APPEND,
  87. .size = MTDPART_SIZ_FULL,
  88. .mask_flags = 0
  89. }
  90. };
  91. static struct physmap_flash_data osk_flash_data = {
  92. .width = 2,
  93. .set_vpp = omap1_set_vpp,
  94. .parts = osk_partitions,
  95. .nr_parts = ARRAY_SIZE(osk_partitions),
  96. };
  97. static struct resource osk_flash_resource = {
  98. /* this is on CS3, wherever it's mapped */
  99. .flags = IORESOURCE_MEM,
  100. };
  101. static struct platform_device osk5912_flash_device = {
  102. .name = "physmap-flash",
  103. .id = 0,
  104. .dev = {
  105. .platform_data = &osk_flash_data,
  106. },
  107. .num_resources = 1,
  108. .resource = &osk_flash_resource,
  109. };
  110. static struct smc91x_platdata osk5912_smc91x_info = {
  111. .flags = SMC91X_USE_16BIT | SMC91X_NOWAIT,
  112. .leda = RPC_LED_100_10,
  113. .ledb = RPC_LED_TX_RX,
  114. };
  115. static struct resource osk5912_smc91x_resources[] = {
  116. [0] = {
  117. .start = OMAP_OSK_ETHR_START, /* Physical */
  118. .end = OMAP_OSK_ETHR_START + 0xf,
  119. .flags = IORESOURCE_MEM,
  120. },
  121. [1] = {
  122. .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHEDGE,
  123. },
  124. };
  125. static struct platform_device osk5912_smc91x_device = {
  126. .name = "smc91x",
  127. .id = -1,
  128. .dev = {
  129. .platform_data = &osk5912_smc91x_info,
  130. },
  131. .num_resources = ARRAY_SIZE(osk5912_smc91x_resources),
  132. .resource = osk5912_smc91x_resources,
  133. };
  134. static struct resource osk5912_cf_resources[] = {
  135. [0] = {
  136. .flags = IORESOURCE_IRQ,
  137. },
  138. };
  139. static struct platform_device osk5912_cf_device = {
  140. .name = "omap_cf",
  141. .id = -1,
  142. .dev = {
  143. .platform_data = (void *) 2 /* CS2 */,
  144. },
  145. .num_resources = ARRAY_SIZE(osk5912_cf_resources),
  146. .resource = osk5912_cf_resources,
  147. };
  148. static struct platform_device *osk5912_devices[] __initdata = {
  149. &osk5912_flash_device,
  150. &osk5912_smc91x_device,
  151. &osk5912_cf_device,
  152. };
  153. static struct gpio_led tps_leds[] = {
  154. /* NOTE: D9 and D2 have hardware blink support.
  155. * Also, D9 requires non-battery power.
  156. */
  157. { .gpio = OSK_TPS_GPIO_LED_D9, .name = "d9",
  158. .default_trigger = "ide-disk", },
  159. { .gpio = OSK_TPS_GPIO_LED_D2, .name = "d2", },
  160. { .gpio = OSK_TPS_GPIO_LED_D3, .name = "d3", .active_low = 1,
  161. .default_trigger = "heartbeat", },
  162. };
  163. static struct gpio_led_platform_data tps_leds_data = {
  164. .num_leds = 3,
  165. .leds = tps_leds,
  166. };
  167. static struct platform_device osk5912_tps_leds = {
  168. .name = "leds-gpio",
  169. .id = 0,
  170. .dev.platform_data = &tps_leds_data,
  171. };
  172. static int osk_tps_setup(struct i2c_client *client, void *context)
  173. {
  174. /* Set GPIO 1 HIGH to disable VBUS power supply;
  175. * OHCI driver powers it up/down as needed.
  176. */
  177. gpio_request(OSK_TPS_GPIO_USB_PWR_EN, "n_vbus_en");
  178. gpio_direction_output(OSK_TPS_GPIO_USB_PWR_EN, 1);
  179. /* Set GPIO 2 high so LED D3 is off by default */
  180. tps65010_set_gpio_out_value(GPIO2, HIGH);
  181. /* Set GPIO 3 low to take ethernet out of reset */
  182. gpio_request(OSK_TPS_GPIO_LAN_RESET, "smc_reset");
  183. gpio_direction_output(OSK_TPS_GPIO_LAN_RESET, 0);
  184. /* GPIO4 is VDD_DSP */
  185. gpio_request(OSK_TPS_GPIO_DSP_PWR_EN, "dsp_power");
  186. gpio_direction_output(OSK_TPS_GPIO_DSP_PWR_EN, 1);
  187. /* REVISIT if DSP support isn't configured, power it off ... */
  188. /* Let LED1 (D9) blink; leds-gpio may override it */
  189. tps65010_set_led(LED1, BLINK);
  190. /* Set LED2 off by default */
  191. tps65010_set_led(LED2, OFF);
  192. /* Enable LOW_PWR handshake */
  193. tps65010_set_low_pwr(ON);
  194. /* Switch VLDO2 to 3.0V for AIC23 */
  195. tps65010_config_vregs1(TPS_LDO2_ENABLE | TPS_VLDO2_3_0V