dig297.c 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196
  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. /* board id for Linux */
  89. gd->bd->bi_arch_number = MACH_TYPE_OMAP3_CPS;
  90. /* boot param addr */
  91. gd->bd->bi_boot_params = (OMAP34XX_SDRC_CS0 + 0x100);
  92. return 0;
  93. }
  94. /*
  95. * Routine: misc_init_r
  96. * Description: Configure board specific parts
  97. */
  98. int misc_init_r(void)
  99. {
  100. struct gpio *gpio1_base = (struct gpio *)OMAP34XX_GPIO1_BASE;
  101. struct gpio *gpio5_base = (struct gpio *)OMAP34XX_GPIO5_BASE;
  102. twl4030_power_init();
  103. twl4030_led_init(TWL4030_LED_LEDEN_LEDAON | TWL4030_LED_LEDEN_LEDBON);
  104. /*
  105. * GPIO list
  106. * - 159 OUT (GPIO5+31): reset for remote camera interface connector.
  107. * - 19 OUT (GPIO1+19): integrated speaker amplifier (1=on, 0=shdn).
  108. * - 20 OUT (GPIO1+20): handset amplifier (1=on, 0=shdn).
  109. */
  110. /* Configure GPIOs to output */
  111. writel(~(GPIO19 | GPIO20), &gpio1_base->oe);
  112. writel(~(GPIO31), &gpio5_base->oe);
  113. /* Set GPIO values */
  114. writel((GPIO19 | GPIO20), &gpio1_base->setdataout);
  115. writel(0, &gpio5_base->setdataout);
  116. #if defined(CONFIG_CMD_NET)
  117. setup_net_chip();
  118. #endif
  119. dieid_num_r();
  120. return 0;
  121. }
  122. /*
  123. * Routine: set_muxconf_regs
  124. * Description: Setting up the configuration Mux registers specific to the
  125. * hardware. Many pins need to be moved from protect to primary
  126. * mode.
  127. */
  128. void set_muxconf_regs(void)
  129. {
  130. MUX_DIG297();
  131. }
  132. #ifdef CONFIG_GENERIC_MMC
  133. int board_mmc_init(bd_t *bis)
  134. {
  135. omap_mmc_init(0);
  136. return 0;
  137. }
  138. #endif
  139. #ifdef CONFIG_CMD_NET
  140. /*
  141. * Routine: setup_net_chip
  142. * Description: Setting up the configuration GPMC registers specific to the
  143. * Ethernet hardware.
  144. */
  145. static void setup_net_chip(void)
  146. {
  147. struct ctrl *ctrl_base = (struct ctrl *)OMAP34XX_CTRL_BASE;
  148. /* Configure GPMC registers */
  149. enable_gpmc_cs_config(gpmc_lan_config, &gpmc_cfg->cs[5],
  150. CONFIG_SMC911X_BASE, GPMC_SIZE_16M);
  151. /* Enable off mode for NWE in PADCONF_GPMC_NWE register */
  152. writew(readw(&ctrl_base->gpmc_nwe) | 0x0E00, &ctrl_base->gpmc_nwe);
  153. /* Enable off mode for NOE in PADCONF_GPMC_NADV_ALE register */
  154. writew(readw(&ctrl_base->gpmc_noe) | 0x0E00, &ctrl_base->gpmc_noe);
  155. /* Enable off mode for ALE in PADCONF_GPMC_NADV_ALE register */
  156. writew(readw(&ctrl_base->gpmc_nadv_ale) | 0x0E00,
  157. &ctrl_base->gpmc_nadv_ale);
  158. /* Make GPIO 12 as output pin and send a magic pulse through it */
  159. if (!gpio_request(NET_LAN9221_RESET_GPIO, "")) {
  160. gpio_direction_output(NET_LAN9221_RESET_GPIO, 0);
  161. gpio_set_value(NET_LAN9221_RESET_GPIO, 1);
  162. udelay(1);
  163. gpio_set_value(NET_LAN9221_RESET_GPIO, 0);
  164. udelay(31000); /* Should be >= 30ms according to datasheet */
  165. gpio_set_value(NET_LAN9221_RESET_GPIO, 1);
  166. }
  167. }
  168. #endif /* CONFIG_CMD_NET */
  169. int board_eth_init(bd_t *bis)
  170. {
  171. int rc = 0;
  172. rc = smc911x_initialize(0, CONFIG_SMC911X_BASE);
  173. return rc;
  174. }