dig297.c 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187
  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/omap3-regs.h>
  41. #include <asm/arch/mux.h>
  42. #include <asm/arch/mem.h>
  43. #include <asm/arch/sys_proto.h>
  44. #include <asm/arch/gpio.h>
  45. #include <asm/mach-types.h>
  46. #include "dig297.h"
  47. DECLARE_GLOBAL_DATA_PTR;
  48. #ifdef CONFIG_CMD_NET
  49. static void setup_net_chip(void);
  50. #define NET_LAN9221_RESET_GPIO 12
  51. /* GPMC CS 5 connected to an SMSC LAN9220 ethernet controller */
  52. #define NET_LAN9220_GPMC_CONFIG1 (DEVICESIZE_16BIT)
  53. #define NET_LAN9220_GPMC_CONFIG2 (CSWROFFTIME(8) | \
  54. CSRDOFFTIME(7) | \
  55. ADVONTIME(1))
  56. #define NET_LAN9220_GPMC_CONFIG3 (ADVWROFFTIME(2) | \
  57. ADVRDOFFTIME(2) | \
  58. ADVONTIME(1))
  59. #define NET_LAN9220_GPMC_CONFIG4 (WEOFFTIME(8) | \
  60. WEONTIME(1) | \
  61. OEOFFTIME(7)| \
  62. OEONTIME(1))
  63. #define NET_LAN9220_GPMC_CONFIG5 (PAGEBURSTACCESSTIME(0) | \
  64. RDACCESSTIME(6) | \
  65. WRCYCLETIME(0x1D) | \
  66. RDCYCLETIME(0x1D))
  67. #define NET_LAN9220_GPMC_CONFIG6 ((1 << 31) | \
  68. WRACCESSTIME(0x1D) | \
  69. WRDATAONADMUXBUS(3))
  70. static const u32 gpmc_lan_config[] = {
  71. NET_LAN9220_GPMC_CONFIG1,
  72. NET_LAN9220_GPMC_CONFIG2,
  73. NET_LAN9220_GPMC_CONFIG3,
  74. NET_LAN9220_GPMC_CONFIG4,
  75. NET_LAN9220_GPMC_CONFIG5,
  76. NET_LAN9220_GPMC_CONFIG6,
  77. /* CONFIG7: computed by enable_gpmc_cs_config() */
  78. };
  79. #endif /* CONFIG_CMD_NET */
  80. /*
  81. * Routine: board_init
  82. * Description: Early hardware init.
  83. */
  84. int board_init(void)
  85. {
  86. gpmc_init(); /* in SRAM or SDRAM, finish GPMC */
  87. /* board id for Linux */
  88. gd->bd->bi_arch_number = MACH_TYPE_OMAP3_CPS;
  89. /* boot param addr */
  90. gd->bd->bi_boot_params = (OMAP34XX_SDRC_CS0 + 0x100);
  91. return 0;
  92. }
  93. /*
  94. * Routine: misc_init_r
  95. * Description: Configure board specific parts
  96. */
  97. int misc_init_r(void)
  98. {
  99. struct gpio *gpio1_base = (struct gpio *)OMAP34XX_GPIO1_BASE;
  100. struct gpio *gpio5_base = (struct gpio *)OMAP34XX_GPIO5_BASE;
  101. twl4030_power_init();
  102. twl4030_led_init(TWL4030_LED_LEDEN_LEDAON | TWL4030_LED_LEDEN_LEDBON);
  103. /*
  104. * GPIO list
  105. * - 159 OUT (GPIO5+31): reset for remote camera interface connector.
  106. * - 19 OUT (GPIO1+19): integrated speaker amplifier (1=on, 0=shdn).
  107. * - 20 OUT (GPIO1+20): handset amplifier (1=on, 0=shdn).
  108. */
  109. /* Configure GPIOs to output */
  110. writel(~(GPIO19 | GPIO20), &gpio1_base->oe);
  111. writel(~(GPIO31), &gpio5_base->oe);
  112. /* Set GPIO values */
  113. writel((GPIO19 | GPIO20), &gpio1_base->setdataout);
  114. writel(0, &gpio5_base->setdataout);
  115. #if defined(CONFIG_CMD_NET)
  116. setup_net_chip();
  117. #endif
  118. dieid_num_r();
  119. return 0;
  120. }
  121. /*
  122. * Routine: set_muxconf_regs
  123. * Description: Setting up the configuration Mux registers specific to the
  124. * hardware. Many pins need to be moved from protect to primary
  125. * mode.
  126. */
  127. void set_muxconf_regs(void)
  128. {
  129. MUX_DIG297();
  130. }
  131. #ifdef CONFIG_CMD_NET
  132. /*
  133. * Routine: setup_net_chip
  134. * Description: Setting up the configuration GPMC registers specific to the
  135. * Ethernet hardware.
  136. */
  137. static void setup_net_chip(void)
  138. {
  139. struct ctrl *ctrl_base = (struct ctrl *)OMAP34XX_CTRL_BASE;
  140. /* Configure GPMC registers */
  141. enable_gpmc_cs_config(gpmc_lan_config, &gpmc_cfg->cs[5],
  142. CONFIG_SMC911X_BASE, GPMC_SIZE_16M);
  143. /* Enable off mode for NWE in PADCONF_GPMC_NWE register */
  144. writew(readw(&ctrl_base->gpmc_nwe) | 0x0E00, &ctrl_base->gpmc_nwe);
  145. /* Enable off mode for NOE in PADCONF_GPMC_NADV_ALE register */
  146. writew(readw(&ctrl_base->gpmc_noe) | 0x0E00, &ctrl_base->gpmc_noe);
  147. /* Enable off mode for ALE in PADCONF_GPMC_NADV_ALE register */
  148. writew(readw(&ctrl_base->gpmc_nadv_ale) | 0x0E00,
  149. &ctrl_base->gpmc_nadv_ale);
  150. /* Make GPIO 12 as output pin and send a magic pulse through it */
  151. if (!omap_request_gpio(NET_LAN9221_RESET_GPIO)) {
  152. omap_set_gpio_direction(NET_LAN9221_RESET_GPIO, 0);
  153. omap_set_gpio_dataout(NET_LAN9221_RESET_GPIO, 1);
  154. udelay(1);
  155. omap_set_gpio_dataout(NET_LAN9221_RESET_GPIO, 0);
  156. udelay(31000); /* Should be >= 30ms according to datasheet */
  157. omap_set_gpio_dataout(NET_LAN9221_RESET_GPIO, 1);
  158. }
  159. }
  160. #endif /* CONFIG_CMD_NET */
  161. int board_eth_init(bd_t *bis)
  162. {
  163. int rc = 0;
  164. rc = smc911x_initialize(0, CONFIG_SMC911X_BASE);
  165. return rc;
  166. }