board-sffsdr.c 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172
  1. /*
  2. * Lyrtech SFFSDR board support.
  3. *
  4. * Copyright (C) 2008 Philip Balister, OpenSDR <philip@opensdr.com>
  5. * Copyright (C) 2008 Lyrtech <www.lyrtech.com>
  6. *
  7. * Based on DV-EVM platform, original copyright follows:
  8. *
  9. * Copyright (C) 2007 MontaVista Software, Inc.
  10. *
  11. * This program is free software; you can redistribute it and/or modify
  12. * it under the terms of the GNU General Public License as published by
  13. * the Free Software Foundation; either version 2 of the License, or
  14. * (at your option) any later version.
  15. *
  16. * This program is distributed in the hope that it will be useful,
  17. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  18. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  19. * GNU General Public License for more details.
  20. *
  21. * You should have received a copy of the GNU General Public License
  22. * along with this program; if not, write to the Free Software
  23. * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  24. */
  25. #include <linux/init.h>
  26. #include <linux/platform_device.h>
  27. #include <linux/i2c.h>
  28. #include <linux/i2c/at24.h>
  29. #include <linux/mtd/mtd.h>
  30. #include <linux/mtd/nand.h>
  31. #include <linux/mtd/partitions.h>
  32. #include <asm/mach-types.h>
  33. #include <asm/mach/arch.h>
  34. #include <asm/mach/flash.h>
  35. #include <mach/dm644x.h>
  36. #include <mach/common.h>
  37. #include <mach/i2c.h>
  38. #include <mach/serial.h>
  39. #include <mach/mux.h>
  40. #include <mach/usb.h>
  41. #define SFFSDR_PHY_MASK (0x2)
  42. #define SFFSDR_MDIO_FREQUENCY (2200000) /* PHY bus frequency */
  43. #define DAVINCI_ASYNC_EMIF_CONTROL_BASE 0x01e00000
  44. #define DAVINCI_ASYNC_EMIF_DATA_CE0_BASE 0x02000000
  45. struct mtd_partition davinci_sffsdr_nandflash_partition[] = {
  46. /* U-Boot Environment: Block 0
  47. * UBL: Block 1
  48. * U-Boot: Blocks 6-7 (256 kb)
  49. * Integrity Kernel: Blocks 8-31 (3 Mb)
  50. * Integrity Data: Blocks 100-END
  51. */
  52. {
  53. .name = "Linux Kernel",
  54. .offset = 32 * SZ_128K,
  55. .size = 16 * SZ_128K, /* 2 Mb */
  56. .mask_flags = MTD_WRITEABLE, /* Force read-only */
  57. },
  58. {
  59. .name = "Linux ROOT",
  60. .offset = MTDPART_OFS_APPEND,
  61. .size = 256 * SZ_128K, /* 32 Mb */
  62. .mask_flags = 0, /* R/W */
  63. },
  64. };
  65. static struct flash_platform_data davinci_sffsdr_nandflash_data = {
  66. .parts = davinci_sffsdr_nandflash_partition,
  67. .nr_parts = ARRAY_SIZE(davinci_sffsdr_nandflash_partition),
  68. };
  69. static struct resource davinci_sffsdr_nandflash_resource[] = {
  70. {
  71. .start = DAVINCI_ASYNC_EMIF_DATA_CE0_BASE,
  72. .end = DAVINCI_ASYNC_EMIF_DATA_CE0_BASE + SZ_16M - 1,
  73. .flags = IORESOURCE_MEM,
  74. }, {
  75. .start = DAVINCI_ASYNC_EMIF_CONTROL_BASE,
  76. .end = DAVINCI_ASYNC_EMIF_CONTROL_BASE + SZ_4K - 1,
  77. .flags = IORESOURCE_MEM,
  78. },
  79. };
  80. static struct platform_device davinci_sffsdr_nandflash_device = {
  81. .name = "davinci_nand", /* Name of driver */
  82. .id = 0,
  83. .dev = {
  84. .platform_data = &davinci_sffsdr_nandflash_data,
  85. },
  86. .num_resources = ARRAY_SIZE(davinci_sffsdr_nandflash_resource),
  87. .resource = davinci_sffsdr_nandflash_resource,
  88. };
  89. static struct at24_platform_data eeprom_info = {
  90. .byte_len = (64*1024) / 8,
  91. .page_size = 32,
  92. .flags = AT24_FLAG_ADDR16,
  93. };
  94. static struct i2c_board_info __initdata i2c_info[] = {
  95. {
  96. I2C_BOARD_INFO("24lc64", 0x50),
  97. .platform_data = &eeprom_info,
  98. },
  99. /* Other I2C devices:
  100. * MSP430, addr 0x23 (not used)
  101. * PCA9543, addr 0x70 (setup done by U-Boot)
  102. * ADS7828, addr 0x48 (ADC for voltage monitoring.)
  103. */
  104. };
  105. static struct davinci_i2c_platform_data i2c_pdata = {
  106. .bus_freq = 20 /* kHz */,
  107. .bus_delay = 100 /* usec */,
  108. };
  109. static void __init sffsdr_init_i2c(void)
  110. {
  111. davinci_init_i2c(&i2c_pdata);
  112. i2c_register_board_info(1, i2c_info, ARRAY_SIZE(i2c_info));
  113. }
  114. static struct platform_device *davinci_sffsdr_devices[] __initdata = {
  115. &davinci_sffsdr_nandflash_device,
  116. };
  117. static struct davinci_uart_config uart_config __initdata = {
  118. .enabled_uarts = (1 << 0),
  119. };
  120. static void __init davinci_sffsdr_map_io(void)
  121. {
  122. dm644x_init();
  123. }
  124. static __init void davinci_sffsdr_init(void)
  125. {
  126. struct davinci_soc_info *soc_info = &davinci_soc_info;
  127. platform_add_devices(davinci_sffsdr_devices,
  128. ARRAY_SIZE(davinci_sffsdr_devices));
  129. sffsdr_init_i2c();
  130. davinci_serial_init(&uart_config);
  131. soc_info->emac_pdata->phy_mask = SFFSDR_PHY_MASK;
  132. soc_info->emac_pdata->mdio_max_freq = SFFSDR_MDIO_FREQUENCY;
  133. davinci_setup_usb(0, 0); /* We support only peripheral mode. */
  134. /* mux VLYNQ pins */
  135. davinci_cfg_reg(DM644X_VLYNQEN);
  136. davinci_cfg_reg(DM644X_VLYNQWD);
  137. }
  138. static __init void davinci_sffsdr_irq_init(void)
  139. {
  140. davinci_irq_init();
  141. }
  142. MACHINE_START(SFFSDR, "Lyrtech SFFSDR")
  143. /* Maintainer: Hugo Villeneuve hugo.villeneuve@lyrtech.com */
  144. .phys_io = IO_PHYS,
  145. .io_pg_offst = (__IO_ADDRESS(IO_PHYS) >> 18) & 0xfffc,
  146. .boot_params = (DAVINCI_DDR_BASE + 0x100),
  147. .map_io = davinci_sffsdr_map_io,
  148. .init_irq = davinci_sffsdr_irq_init,
  149. .timer = &davinci_timer,
  150. .init_machine = davinci_sffsdr_init,
  151. MACHINE_END