synchronousMemoryDatabase.c 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217
  1. /*
  2. * TI DaVinci DM646X EVM board
  3. *
  4. * Derived from: arch/arm/mach-davinci/board-evm.c
  5. * Copyright (C) 2006 Texas Instruments.
  6. *
  7. * (C) 2007-2008, MontaVista Software, Inc.
  8. *
  9. * This file is licensed under the terms of the GNU General Public License
  10. * version 2. This program is licensed "as is" without any warranty of any
  11. * kind, whether express or implied.
  12. *
  13. */
  14. /**************************************************************************
  15. * Included Files
  16. **************************************************************************/
  17. #include <linux/kernel.h>
  18. #include <linux/init.h>
  19. #include <linux/leds.h>
  20. #include <linux/gpio.h>
  21. #include <linux/platform_device.h>
  22. #include <linux/i2c.h>
  23. #include <linux/i2c/at24.h>
  24. #include <linux/i2c/pcf857x.h>
  25. #include <media/tvp514x.h>
  26. #include <media/adv7343.h>
  27. #include <linux/mtd/mtd.h>
  28. #include <linux/mtd/nand.h>
  29. #include <linux/mtd/partitions.h>
  30. #include <linux/clk.h>
  31. #include <linux/export.h>
  32. #include <asm/mach-types.h>
  33. #include <asm/mach/arch.h>
  34. #include <mach/common.h>
  35. #include <mach/serial.h>
  36. #include <linux/platform_data/i2c-davinci.h>
  37. #include <linux/platform_data/mtd-davinci.h>
  38. #include <mach/clock.h>
  39. #include <mach/cdce949.h>
  40. #include <linux/platform_data/mtd-davinci-aemif.h>
  41. #include "davinci.h"
  42. #include "clock.h"
  43. #define NAND_BLOCK_SIZE SZ_128K
  44. /* Note: We are setting first partition as 'bootloader' constituting UBL, U-Boot
  45. * and U-Boot environment this avoids dependency on any particular combination
  46. * of UBL, U-Boot or flashing tools etc.
  47. */
  48. static struct mtd_partition davinci_nand_partitions[] = {
  49. {
  50. /* UBL, U-Boot with environment */
  51. .name = "bootloader",
  52. .offset = MTDPART_OFS_APPEND,
  53. .size = 16 * NAND_BLOCK_SIZE,
  54. .mask_flags = MTD_WRITEABLE, /* force read-only */
  55. }, {
  56. .name = "kernel",
  57. .offset = MTDPART_OFS_APPEND,
  58. .size = SZ_4M,
  59. .mask_flags = 0,
  60. }, {
  61. .name = "filesystem",
  62. .offset = MTDPART_OFS_APPEND,
  63. .size = MTDPART_SIZ_FULL,
  64. .mask_flags = 0,
  65. }
  66. };
  67. static struct davinci_aemif_timing dm6467tevm_nandflash_timing = {
  68. .wsetup = 29,
  69. .wstrobe = 24,
  70. .whold = 14,
  71. .rsetup = 19,
  72. .rstrobe = 33,
  73. .rhold = 0,
  74. .ta = 29,
  75. };
  76. static struct davinci_nand_pdata davinci_nand_data = {
  77. .mask_cle = 0x80000,
  78. .mask_ale = 0x40000,
  79. .parts = davinci_nand_partitions,
  80. .nr_parts = ARRAY_SIZE(davinci_nand_partitions),
  81. .ecc_mode = NAND_ECC_HW,
  82. .options = 0,
  83. };
  84. static struct resource davinci_nand_resources[] = {
  85. {
  86. .start = DM646X_ASYNC_EMIF_CS2_SPACE_BASE,
  87. .end = DM646X_ASYNC_EMIF_CS2_SPACE_BASE + SZ_32M - 1,
  88. .flags = IORESOURCE_MEM,
  89. }, {
  90. .start = DM646X_ASYNC_EMIF_CONTROL_BASE,
  91. .end = DM646X_ASYNC_EMIF_CONTROL_BASE + SZ_4K - 1,
  92. .flags = IORESOURCE_MEM,
  93. },
  94. };
  95. static struct platform_device davinci_nand_device = {
  96. .name = "davinci_nand",
  97. .id = 0,
  98. .num_resources = ARRAY_SIZE(davinci_nand_resources),
  99. .resource = davinci_nand_resources,
  100. .dev = {
  101. .platform_data = &davinci_nand_data,
  102. },
  103. };
  104. #if defined(CONFIG_BLK_DEV_PALMCHIP_BK3710) || \
  105. defined(CONFIG_BLK_DEV_PALMCHIP_BK3710_MODULE)
  106. #define HAS_ATA 1
  107. #else
  108. #define HAS_ATA 0
  109. #endif
  110. /* CPLD Register 0 bits to control ATA */
  111. #define DM646X_EVM_ATA_RST BIT(0)
  112. #define DM646X_EVM_ATA_PWD BIT(1)
  113. /* CPLD Register 0 Client: used for I/O Control */
  114. static int cpld_reg0_probe(struct i2c_client *client,
  115. const struct i2c_device_id *id)
  116. {
  117. if (HAS_ATA) {
  118. u8 data;
  119. struct i2c_msg msg[2] = {
  120. {
  121. .addr = client->addr,
  122. .flags = I2C_M_RD,
  123. .len = 1,
  124. .buf = &data,
  125. },
  126. {
  127. .addr = client->addr,
  128. .flags = 0,
  129. .len = 1,
  130. .buf = &data,
  131. },
  132. };
  133. /* Clear ATA_RSTn and ATA_PWD bits to enable ATA operation. */
  134. i2c_transfer(client->adapter, msg, 1);
  135. data &= ~(DM646X_EVM_ATA_RST | DM646X_EVM_ATA_PWD);
  136. i2c_transfer(client->adapter, msg + 1, 1);
  137. }
  138. return 0;
  139. }
  140. static const struct i2c_device_id cpld_reg_ids[] = {
  141. { "cpld_reg0", 0, },
  142. { },
  143. };
  144. static struct i2c_driver dm6467evm_cpld_driver = {
  145. .driver.name = "cpld_reg0",
  146. .id_table = cpld_reg_ids,
  147. .probe = cpld_reg0_probe,
  148. };
  149. /* LEDS */
  150. static struct gpio_led evm_leds[] = {
  151. { .name = "DS1", .active_low = 1, },
  152. { .name = "DS2", .active_low = 1, },
  153. { .name = "DS3", .active_low = 1, },
  154. { .name = "DS4", .active_low = 1, },
  155. };
  156. static const struct gpio_led_platform_data evm_led_data = {
  157. .num_leds = ARRAY_SIZE(evm_leds),
  158. .leds = evm_leds,
  159. };
  160. static struct platform_device *evm_led_dev;
  161. static int evm_led_setup(struct i2c_client *client, int gpio,
  162. unsigned int ngpio, void *c)
  163. {
  164. struct gpio_led *leds = evm_leds;
  165. int status;
  166. while (ngpio--) {
  167. leds->gpio = gpio++;
  168. leds++;
  169. }
  170. evm_led_dev = platform_device_alloc("leds-gpio", 0);
  171. platform_device_add_data(evm_led_dev, &evm_led_data,
  172. sizeof(evm_led_data));
  173. evm_led_dev->dev.parent = &client->dev;
  174. status = platform_device_add(evm_led_dev);
  175. if (status < 0) {
  176. platform_device_put(evm_led_dev);
  177. evm_led_dev = NULL;
  178. }
  179. return status;
  180. }
  181. static int evm_led_teardown(struct i2c_client *client, int gpio,
  182. unsigned ngpio, void *c)
  183. {
  184. if (evm_led_dev) {
  185. platform_device_unregister(evm_led_dev);
  186. evm_led_dev = NULL;