dig297.c 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194
  1. /*
  2. * (C) Copyright 2011 Comelit Group SpA
  3. * Luca Ceresoli <luca.ceresoli@comelit.it>
  4. *
  5. * Based on board/ti/beagle/beagle.c:
  6. * (C) Copyright 2004-2008
  7. * Texas Instruments, <www.ti.com>
  8. *
  9. * Author :
  10. * Sunil Kumar <sunilsaini05@gmail.com>
  11. * Shashi Ranjan <shashiranjanmca05@gmail.com>
  12. *
  13. * Derived from Beagle Board and 3430 SDP code by
  14. * Richard Woodruff <r-woodruff2@ti.com>
  15. * Syed Mohammed Khasim <khasim@ti.com>
  16. *
  17. *
  18. * See file CREDITS for list of people who contributed to this
  19. * project.
  20. *
  21. * This program is free software; you can redistribute it and/or
  22. * modify it under the terms of the GNU General Public License as
  23. * published by the Free Software Foundation; either version 2 of
  24. * the License, or (at your option) any later version.
  25. *
  26. * This program is distributed in the hope that it will be useful,
  27. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  28. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  29. * GNU General Public License for more details.
  30. *
  31. * You should have received a copy of the GNU General Public License
  32. * along with this program; if not, write to the Free Software
  33. * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
  34. * MA 02111-1307 USA
  35. */
  36. #include <common.h>
  37. #include <netdev.h>
  38. #include <twl4030.h>
  39. #include <asm/io.h>
  40. #include <asm/arch/mmc_host_def.h>
  41. #include <asm/arch/omap3-regs.h>
  42. #include <asm/arch/mux.h>
  43. #include <asm/arch/mem.h>
  44. #include <asm/arch/sys_proto.h>
  45. #include <asm/gpio.h>
  46. #include <asm/mach-types.h>
  47. #include "dig297.h"
  48. DECLARE_GLOBAL_DATA_PTR;
  49. #ifdef CONFIG_CMD_NET
  50. static void setup_net_chip(void);
  51. #define NET_LAN9221_RESET_GPIO 12
  52. /* GPMC CS 5 connected to an SMSC LAN9220 ethernet controller */
  53. #define NET_LAN9220_GPMC_CONFIG1 (DEVICESIZE_16BIT)
  54. #define NET_LAN9220_GPMC_CONFIG2 (CSWROFFTIME(8) | \
  55. CSRDOFFTIME(7) | \
  56. ADVONTIME(1))
  57. #define NET_LAN9220_GPMC_CONFIG3 (ADVWROFFTIME(2) | \
  58. ADVRDOFFTIME(2) | \
  59. ADVONTIME(1))
  60. #define NET_LAN9220_GPMC_CONFIG4 (WEOFFTIME(8) | \
  61. WEONTIME(1) | \
  62. OEOFFTIME(7)| \
  63. OEONTIME(1))
  64. #define NET_LAN9220_GPMC_CONFIG5 (PAGEBURSTACCESSTIME(0) | \
  65. RDACCESSTIME(6) | \
  66. WRCYCLETIME(0x1D) | \
  67. RDCYCLETIME(0x1D))
  68. #define NET_LAN9220_GPMC_CONFIG6 ((1 << 31) | \
  69. WRACCESSTIME(0x1D) | \
  70. WRDATAONADMUXBUS(3))
  71. static const u32 gpmc_lan_config[] = {
  72. NET_LAN9220_GPMC_CONFIG1,
  73. NET_LAN9220_GPMC_CONFIG2,
  74. NET_LAN9220_GPMC_CONFIG3,
  75. NET_LAN9220_GPMC_CONFIG4,
  76. NET_LAN9220_GPMC_CONFIG5,
  77. NET_LAN9220_GPMC_CONFIG6,
  78. /* CONFIG7: computed by enable_gpmc_cs_config() */
  79. };
  80. #endif /* CONFIG_CMD_NET */
  81. /*
  82. * Routine: board_init
  83. * Description: Early hardware init.
  84. */
  85. int board_init(void)
  86. {
  87. gpmc_init(); /* in SRAM or SDRAM, finish GPMC */
  88. /* boot param addr */
  89. gd->bd->bi_boot_params = (OMAP34XX_SDRC_CS0 + 0x100);
  90. return 0;
  91. }
  92. /*
  93. * Routine: misc_init_r
  94. * Description: Configure board specific parts
  95. */
  96. int misc_init_r(void)
  97. {
  98. struct gpio *gpio1_base = (struct gpio *)OMAP34XX_GPIO1_BASE;
  99. struct gpio *gpio5_base = (struct gpio *)OMAP34XX_GPIO5_BASE;
  100. twl4030_power_init();
  101. twl4030_led_init(TWL4030_LED_LEDEN_LEDAON | TWL4030_LED_LEDEN_LEDBON);
  102. /*
  103. * GPIO list
  104. * - 159 OUT (GPIO5+31): reset for remote camera interface connector.
  105. * - 19 OUT (GPIO1+19): integrated speaker amplifier (1=on, 0=shdn).
  106. * - 20 OUT (GPIO1+20): handset amplifier (1=on, 0=shdn).
  107. */
  108. /* Configure GPIOs to output */
  109. writel(~(GPIO19 | GPIO20), &gpio1_base->oe);
  110. writel(~(GPIO31), &gpio5_base->oe);
  111. /* Set GPIO values */
  112. writel((GPIO19 | GPIO20), &gpio1_base->setdataout);
  113. writel(0, &gpio5_base->setdataout);
  114. #if defined(CONFIG_CMD_NET)
  115. setup_net_chip();
  116. #endif
  117. dieid_num_r();
  118. return 0;
  119. }
  120. /*
  121. * Routine: set_muxconf_regs
  122. * Description: Setting up the configuration Mux registers specific to the
  123. * hardware. Many pins need to be moved from protect to primary
  124. * mode.
  125. */
  126. void set_muxconf_regs(void)
  127. {
  128. MUX_DIG297();
  129. }
  130. #ifdef CONFIG_GENERIC_MMC
  131. int board_mmc_init(bd_t *bis)
  132. {
  133. omap_mmc_init(0, 0, 0);
  134. return 0;
  135. }
  136. #endif
  137. #ifdef CONFIG_CMD_NET
  138. /*
  139. * Routine: setup_net_chip
  140. * Description: Setting up the configuration GPMC registers specific to the
  141. * Ethernet hardware.
  142. */
  143. static void setup_net_chip(void)
  144. {
  145. struct ctrl *ctrl_base = (struct ctrl *)OMAP34XX_CTRL_BASE;
  146. /* Configure GPMC registers */
  147. enable_gpmc_cs_config(gpmc_lan_config, &gpmc_cfg->cs[5],
  148. CONFIG_SMC911X_BASE, GPMC_SIZE_16M);
  149. /* Enable off mode for NWE in PADCONF_GPMC_NWE register */
  150. writew(readw(&ctrl_base->gpmc_nwe) | 0x0E00, &ctrl_base->gpmc_nwe);
  151. /* Enable off mode for NOE in PADCONF_GPMC_NADV_ALE register */
  152. writew(readw(&ctrl_base->gpmc_noe) | 0x0E00, &ctrl_base->gpmc_noe);
  153. /* Enable off mode for ALE in PADCONF_GPMC_NADV_ALE register */
  154. writew(readw(&ctrl_base->gpmc_nadv_ale) | 0x0E00,
  155. &ctrl_base->gpmc_nadv_ale);
  156. /* Make GPIO 12 as output pin and send a magic pulse through it */
  157. if (!gpio_request(NET_LAN9221_RESET_GPIO, "")) {
  158. gpio_direction_output(NET_LAN9221_RESET_GPIO, 0);
  159. gpio_set_value(NET_LAN9221_RESET_GPIO, 1);
  160. udelay(1);
  161. gpio_set_value(NET_LAN9221_RESET_GPIO, 0);
  162. udelay(31000); /* Should be >= 30ms according to datasheet */
  163. gpio_set_value(NET_LAN9221_RESET_GPIO, 1);
  164. }
  165. }
  166. #endif /* CONFIG_CMD_NET */
  167. int board_eth_init(bd_t *bis)
  168. {
  169. int rc = 0;
  170. rc = smc911x_initialize(0, CONFIG_SMC911X_BASE);
  171. return rc;
  172. }