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> |
| 30 | #include <asm/arch/emac_defs.h> |
Hugo Villeneuve | 264bbdd | 2008-07-11 15:10:13 -0400 | [diff] [blame] | 31 | #include "../common/psc.h" |
| 32 | #include "../common/misc.h" |
Sergey Kubushyn | c74b210 | 2007-08-10 20:26:18 +0200 | [diff] [blame] | 33 | |
Dirk Behme | 66b3f24 | 2007-09-15 11:55:42 +0200 | [diff] [blame] | 34 | DECLARE_GLOBAL_DATA_PTR; |
| 35 | |
Sergey Kubushyn | c74b210 | 2007-08-10 20:26:18 +0200 | [diff] [blame] | 36 | int board_init(void) |
| 37 | { |
Sergey Kubushyn | c74b210 | 2007-08-10 20:26:18 +0200 | [diff] [blame] | 38 | /* arch number of the board */ |
| 39 | gd->bd->bi_arch_number = MACH_TYPE_DAVINCI_EVM; |
| 40 | |
| 41 | /* address of boot parameters */ |
| 42 | gd->bd->bi_boot_params = LINUX_BOOT_PARAM_ADDR; |
| 43 | |
| 44 | /* Workaround for TMS320DM6446 errata 1.3.22 */ |
| 45 | REG(PSC_SILVER_BULLET) = 0; |
| 46 | |
| 47 | /* Power on required peripherals */ |
| 48 | lpsc_on(DAVINCI_LPSC_EMAC); |
| 49 | lpsc_on(DAVINCI_LPSC_EMAC_WRAPPER); |
| 50 | lpsc_on(DAVINCI_LPSC_MDIO); |
| 51 | lpsc_on(DAVINCI_LPSC_I2C); |
| 52 | lpsc_on(DAVINCI_LPSC_UART0); |
| 53 | lpsc_on(DAVINCI_LPSC_TIMER1); |
| 54 | lpsc_on(DAVINCI_LPSC_GPIO); |
| 55 | |
Jean-Christophe PLAGNIOL-VILLARD | 6d0f6bc | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 56 | #if !defined(CONFIG_SYS_USE_DSPLINK) |
Sergey Kubushyn | c74b210 | 2007-08-10 20:26:18 +0200 | [diff] [blame] | 57 | /* Powerup the DSP */ |
| 58 | dsp_on(); |
Jean-Christophe PLAGNIOL-VILLARD | 6d0f6bc | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 59 | #endif /* CONFIG_SYS_USE_DSPLINK */ |
Sergey Kubushyn | c74b210 | 2007-08-10 20:26:18 +0200 | [diff] [blame] | 60 | |
| 61 | /* Bringup UART0 out of reset */ |
| 62 | REG(UART0_PWREMU_MGMT) = 0x0000e003; |
| 63 | |
| 64 | /* Enable GIO3.3V cells used for EMAC */ |
| 65 | REG(VDD3P3V_PWDN) = 0; |
| 66 | |
| 67 | /* Enable UART0 MUX lines */ |
| 68 | REG(PINMUX1) |= 1; |
| 69 | |
| 70 | /* Enable EMAC and AEMIF pins */ |
| 71 | REG(PINMUX0) = 0x80000c1f; |
| 72 | |
| 73 | /* Enable I2C pin Mux */ |
| 74 | REG(PINMUX1) |= (1 << 7); |
| 75 | |
| 76 | /* Set the Bus Priority Register to appropriate value */ |
| 77 | REG(VBPR) = 0x20; |
| 78 | |
| 79 | timer_init(); |
| 80 | |
| 81 | return(0); |
| 82 | } |
| 83 | |
Hugo Villeneuve | 264bbdd | 2008-07-11 15:10:13 -0400 | [diff] [blame] | 84 | int misc_init_r(void) |
Sergey Kubushyn | c74b210 | 2007-08-10 20:26:18 +0200 | [diff] [blame] | 85 | { |
Hugo Villeneuve | 264bbdd | 2008-07-11 15:10:13 -0400 | [diff] [blame] | 86 | uint8_t video_mode; |
| 87 | uint8_t eeprom_enetaddr[6]; |
Sergey Kubushyn | c74b210 | 2007-08-10 20:26:18 +0200 | [diff] [blame] | 88 | |
Hugo Villeneuve | 264bbdd | 2008-07-11 15:10:13 -0400 | [diff] [blame] | 89 | dv_display_clk_infos(); |
Sergey Kubushyn | c74b210 | 2007-08-10 20:26:18 +0200 | [diff] [blame] | 90 | |
Hugo Villeneuve | 264bbdd | 2008-07-11 15:10:13 -0400 | [diff] [blame] | 91 | /* Read Ethernet MAC address from EEPROM if available. */ |
| 92 | if (dvevm_read_mac_address(eeprom_enetaddr)) |
| 93 | dv_configure_mac_address(eeprom_enetaddr); |
Sergey Kubushyn | c74b210 | 2007-08-10 20:26:18 +0200 | [diff] [blame] | 94 | |
Hugo Villeneuve | 85e5808 | 2008-07-11 15:10:11 -0400 | [diff] [blame] | 95 | if (!eth_hw_init()) |
Sergey Kubushyn | c74b210 | 2007-08-10 20:26:18 +0200 | [diff] [blame] | 96 | printf("ethernet init failed!\n"); |
Sergey Kubushyn | c74b210 | 2007-08-10 20:26:18 +0200 | [diff] [blame] | 97 | |
Hugo Villeneuve | 264bbdd | 2008-07-11 15:10:13 -0400 | [diff] [blame] | 98 | i2c_read(0x39, 0x00, 1, &video_mode, 1); |
Sergey Kubushyn | c74b210 | 2007-08-10 20:26:18 +0200 | [diff] [blame] | 99 | |
Hugo Villeneuve | 264bbdd | 2008-07-11 15:10:13 -0400 | [diff] [blame] | 100 | setenv("videostd", ((video_mode & 0x80) ? "pal" : "ntsc")); |
Sergey Kubushyn | c74b210 | 2007-08-10 20:26:18 +0200 | [diff] [blame] | 101 | |
| 102 | return(0); |
| 103 | } |
Thomas Abraham | a9d39eb | 2009-01-04 09:41:09 +0530 | [diff] [blame] | 104 | |
| 105 | #ifdef CONFIG_USB_DAVINCI |
| 106 | |
| 107 | /* IO Expander I2C address and USB VBUS enable mask */ |
| 108 | #define IOEXP_I2C_ADDR 0x3A |
| 109 | #define IOEXP_VBUSEN_MASK 1 |
| 110 | |
| 111 | /* |
| 112 | * This function enables USB VBUS by writting to IO expander using I2C. |
| 113 | * Note that the I2C is already initialized at this stage. This |
| 114 | * function is used by davinci specific USB wrapper code. |
| 115 | */ |
| 116 | void enable_vbus(void) |
| 117 | { |
| 118 | uchar data; /* IO Expander data to enable VBUS */ |
| 119 | |
| 120 | /* Write to IO expander to enable VBUS */ |
| 121 | i2c_read(IOEXP_I2C_ADDR, 0, 0, &data, 1); |
| 122 | data &= ~IOEXP_VBUSEN_MASK; |
| 123 | i2c_write(IOEXP_I2C_ADDR, 0, 0, &data, 1); |
| 124 | } |
| 125 | #endif |
| 126 | |