Sergey Kubushyn | c74b210 | 2007-08-10 20:26:18 +0200 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2007 Sergey Kubushyn <ksi@koi8.net> |
| 3 | * |
| 4 | * Parts are shamelessly stolen from various TI sources, original copyright |
| 5 | * follows: |
| 6 | * ----------------------------------------------------------------- |
| 7 | * |
| 8 | * Copyright (C) 2004 Texas Instruments. |
| 9 | * |
| 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 | */ |
| 26 | |
| 27 | #include <common.h> |
| 28 | #include <i2c.h> |
| 29 | #include <asm/arch/hardware.h> |
Hugo Villeneuve | 264bbdd | 2008-07-11 15:10:13 -0400 | [diff] [blame] | 30 | #include "../common/misc.h" |
Sergey Kubushyn | c74b210 | 2007-08-10 20:26:18 +0200 | [diff] [blame] | 31 | |
Dirk Behme | 66b3f24 | 2007-09-15 11:55:42 +0200 | [diff] [blame] | 32 | DECLARE_GLOBAL_DATA_PTR; |
| 33 | |
Sergey Kubushyn | c74b210 | 2007-08-10 20:26:18 +0200 | [diff] [blame] | 34 | int board_init(void) |
| 35 | { |
Sergey Kubushyn | c74b210 | 2007-08-10 20:26:18 +0200 | [diff] [blame] | 36 | /* arch number of the board */ |
| 37 | gd->bd->bi_arch_number = MACH_TYPE_DAVINCI_EVM; |
| 38 | |
| 39 | /* address of boot parameters */ |
| 40 | gd->bd->bi_boot_params = LINUX_BOOT_PARAM_ADDR; |
| 41 | |
Hugo Villeneuve | 0cd18fa | 2008-11-21 14:35:56 -0500 | [diff] [blame] | 42 | /* Configure AEMIF pins (although this should be configured at boot time |
| 43 | * with pull-up/pull-down resistors) */ |
| 44 | REG(PINMUX0) = 0x00000c1f; |
| 45 | |
| 46 | davinci_errata_workarounds(); |
Sergey Kubushyn | c74b210 | 2007-08-10 20:26:18 +0200 | [diff] [blame] | 47 | |
| 48 | /* Power on required peripherals */ |
Sergey Kubushyn | c74b210 | 2007-08-10 20:26:18 +0200 | [diff] [blame] | 49 | lpsc_on(DAVINCI_LPSC_GPIO); |
Thomas Abraham | 538ef96 | 2009-01-04 09:41:16 +0530 | [diff] [blame] | 50 | lpsc_on(DAVINCI_LPSC_USB); |
Sergey Kubushyn | c74b210 | 2007-08-10 20:26:18 +0200 | [diff] [blame] | 51 | |
Jean-Christophe PLAGNIOL-VILLARD | 6d0f6bc | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 52 | #if !defined(CONFIG_SYS_USE_DSPLINK) |
Sergey Kubushyn | c74b210 | 2007-08-10 20:26:18 +0200 | [diff] [blame] | 53 | /* Powerup the DSP */ |
| 54 | dsp_on(); |
Jean-Christophe PLAGNIOL-VILLARD | 6d0f6bc | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 55 | #endif /* CONFIG_SYS_USE_DSPLINK */ |
Sergey Kubushyn | c74b210 | 2007-08-10 20:26:18 +0200 | [diff] [blame] | 56 | |
Hugo Villeneuve | 0cd18fa | 2008-11-21 14:35:56 -0500 | [diff] [blame] | 57 | davinci_enable_uart0(); |
| 58 | davinci_enable_emac(); |
| 59 | davinci_enable_i2c(); |
Sergey Kubushyn | c74b210 | 2007-08-10 20:26:18 +0200 | [diff] [blame] | 60 | |
Hugo Villeneuve | 0cd18fa | 2008-11-21 14:35:56 -0500 | [diff] [blame] | 61 | lpsc_on(DAVINCI_LPSC_TIMER1); |
Sergey Kubushyn | c74b210 | 2007-08-10 20:26:18 +0200 | [diff] [blame] | 62 | timer_init(); |
| 63 | |
| 64 | return(0); |
| 65 | } |
| 66 | |
Hugo Villeneuve | 264bbdd | 2008-07-11 15:10:13 -0400 | [diff] [blame] | 67 | int misc_init_r(void) |
Sergey Kubushyn | c74b210 | 2007-08-10 20:26:18 +0200 | [diff] [blame] | 68 | { |
Hugo Villeneuve | 264bbdd | 2008-07-11 15:10:13 -0400 | [diff] [blame] | 69 | uint8_t video_mode; |
| 70 | uint8_t eeprom_enetaddr[6]; |
Sergey Kubushyn | c74b210 | 2007-08-10 20:26:18 +0200 | [diff] [blame] | 71 | |
Hugo Villeneuve | 264bbdd | 2008-07-11 15:10:13 -0400 | [diff] [blame] | 72 | /* Read Ethernet MAC address from EEPROM if available. */ |
| 73 | if (dvevm_read_mac_address(eeprom_enetaddr)) |
Ben Gardiner | 7b37a27 | 2010-09-23 09:58:43 -0400 | [diff] [blame^] | 74 | davinci_sync_env_enetaddr(eeprom_enetaddr); |
Sergey Kubushyn | c74b210 | 2007-08-10 20:26:18 +0200 | [diff] [blame] | 75 | |
Hugo Villeneuve | 264bbdd | 2008-07-11 15:10:13 -0400 | [diff] [blame] | 76 | i2c_read(0x39, 0x00, 1, &video_mode, 1); |
Sergey Kubushyn | c74b210 | 2007-08-10 20:26:18 +0200 | [diff] [blame] | 77 | |
Hugo Villeneuve | 264bbdd | 2008-07-11 15:10:13 -0400 | [diff] [blame] | 78 | setenv("videostd", ((video_mode & 0x80) ? "pal" : "ntsc")); |
Sergey Kubushyn | c74b210 | 2007-08-10 20:26:18 +0200 | [diff] [blame] | 79 | |
| 80 | return(0); |
| 81 | } |
Thomas Abraham | a9d39eb | 2009-01-04 09:41:09 +0530 | [diff] [blame] | 82 | |
| 83 | #ifdef CONFIG_USB_DAVINCI |
| 84 | |
| 85 | /* IO Expander I2C address and USB VBUS enable mask */ |
| 86 | #define IOEXP_I2C_ADDR 0x3A |
| 87 | #define IOEXP_VBUSEN_MASK 1 |
| 88 | |
| 89 | /* |
| 90 | * This function enables USB VBUS by writting to IO expander using I2C. |
| 91 | * Note that the I2C is already initialized at this stage. This |
| 92 | * function is used by davinci specific USB wrapper code. |
| 93 | */ |
| 94 | void enable_vbus(void) |
| 95 | { |
| 96 | uchar data; /* IO Expander data to enable VBUS */ |
| 97 | |
| 98 | /* Write to IO expander to enable VBUS */ |
| 99 | i2c_read(IOEXP_I2C_ADDR, 0, 0, &data, 1); |
| 100 | data &= ~IOEXP_VBUSEN_MASK; |
| 101 | i2c_write(IOEXP_I2C_ADDR, 0, 0, &data, 1); |
| 102 | } |
| 103 | #endif |