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