Sergey Kubushyn | e8f3912 | 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 | * ---------------------------------------------------------------------------- |
Wolfgang Denk | d79de1d | 2013-07-08 09:37:19 +0200 | [diff] [blame] | 11 | * SPDX-License-Identifier: GPL-2.0+ |
Sergey Kubushyn | e8f3912 | 2007-08-10 20:26:18 +0200 | [diff] [blame] | 12 | * ---------------------------------------------------------------------------- |
| 13 | */ |
| 14 | |
| 15 | #include <common.h> |
| 16 | #include <i2c.h> |
| 17 | #include <asm/arch/hardware.h> |
Sughosh Ganu | 80995f9 | 2010-11-28 20:21:27 -0500 | [diff] [blame] | 18 | #include <asm/arch/davinci_misc.h> |
Sergey Kubushyn | e8f3912 | 2007-08-10 20:26:18 +0200 | [diff] [blame] | 19 | |
Dirk Behme | f2b171c | 2007-09-15 11:55:42 +0200 | [diff] [blame] | 20 | DECLARE_GLOBAL_DATA_PTR; |
| 21 | |
Sergey Kubushyn | e8f3912 | 2007-08-10 20:26:18 +0200 | [diff] [blame] | 22 | int board_init(void) |
| 23 | { |
Sergey Kubushyn | e8f3912 | 2007-08-10 20:26:18 +0200 | [diff] [blame] | 24 | /* arch number of the board */ |
| 25 | gd->bd->bi_arch_number = MACH_TYPE_DAVINCI_EVM; |
| 26 | |
| 27 | /* address of boot parameters */ |
| 28 | gd->bd->bi_boot_params = LINUX_BOOT_PARAM_ADDR; |
| 29 | |
Hugo Villeneuve | c9a2137 | 2008-11-21 14:35:56 -0500 | [diff] [blame] | 30 | /* Configure AEMIF pins (although this should be configured at boot time |
| 31 | * with pull-up/pull-down resistors) */ |
| 32 | REG(PINMUX0) = 0x00000c1f; |
| 33 | |
| 34 | davinci_errata_workarounds(); |
Sergey Kubushyn | e8f3912 | 2007-08-10 20:26:18 +0200 | [diff] [blame] | 35 | |
| 36 | /* Power on required peripherals */ |
Sergey Kubushyn | e8f3912 | 2007-08-10 20:26:18 +0200 | [diff] [blame] | 37 | lpsc_on(DAVINCI_LPSC_GPIO); |
Thomas Abraham | bbcce61 | 2009-01-04 09:41:16 +0530 | [diff] [blame] | 38 | lpsc_on(DAVINCI_LPSC_USB); |
Sergey Kubushyn | e8f3912 | 2007-08-10 20:26:18 +0200 | [diff] [blame] | 39 | |
Jean-Christophe PLAGNIOL-VILLARD | 0383694 | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 40 | #if !defined(CONFIG_SYS_USE_DSPLINK) |
Sergey Kubushyn | e8f3912 | 2007-08-10 20:26:18 +0200 | [diff] [blame] | 41 | /* Powerup the DSP */ |
| 42 | dsp_on(); |
Jean-Christophe PLAGNIOL-VILLARD | 0383694 | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 43 | #endif /* CONFIG_SYS_USE_DSPLINK */ |
Sergey Kubushyn | e8f3912 | 2007-08-10 20:26:18 +0200 | [diff] [blame] | 44 | |
Hugo Villeneuve | c9a2137 | 2008-11-21 14:35:56 -0500 | [diff] [blame] | 45 | davinci_enable_uart0(); |
| 46 | davinci_enable_emac(); |
| 47 | davinci_enable_i2c(); |
Sergey Kubushyn | e8f3912 | 2007-08-10 20:26:18 +0200 | [diff] [blame] | 48 | |
Hugo Villeneuve | c9a2137 | 2008-11-21 14:35:56 -0500 | [diff] [blame] | 49 | lpsc_on(DAVINCI_LPSC_TIMER1); |
Sergey Kubushyn | e8f3912 | 2007-08-10 20:26:18 +0200 | [diff] [blame] | 50 | timer_init(); |
| 51 | |
| 52 | return(0); |
| 53 | } |
| 54 | |
Hugo Villeneuve | 4e352ef | 2008-07-11 15:10:13 -0400 | [diff] [blame] | 55 | int misc_init_r(void) |
Sergey Kubushyn | e8f3912 | 2007-08-10 20:26:18 +0200 | [diff] [blame] | 56 | { |
Hugo Villeneuve | 4e352ef | 2008-07-11 15:10:13 -0400 | [diff] [blame] | 57 | uint8_t video_mode; |
| 58 | uint8_t eeprom_enetaddr[6]; |
Sergey Kubushyn | e8f3912 | 2007-08-10 20:26:18 +0200 | [diff] [blame] | 59 | |
Hugo Villeneuve | 4e352ef | 2008-07-11 15:10:13 -0400 | [diff] [blame] | 60 | /* Read Ethernet MAC address from EEPROM if available. */ |
| 61 | if (dvevm_read_mac_address(eeprom_enetaddr)) |
Ben Gardiner | 1fb49e3 | 2010-09-23 09:58:43 -0400 | [diff] [blame] | 62 | davinci_sync_env_enetaddr(eeprom_enetaddr); |
Sergey Kubushyn | e8f3912 | 2007-08-10 20:26:18 +0200 | [diff] [blame] | 63 | |
Hugo Villeneuve | 4e352ef | 2008-07-11 15:10:13 -0400 | [diff] [blame] | 64 | i2c_read(0x39, 0x00, 1, &video_mode, 1); |
Sergey Kubushyn | e8f3912 | 2007-08-10 20:26:18 +0200 | [diff] [blame] | 65 | |
Hugo Villeneuve | 4e352ef | 2008-07-11 15:10:13 -0400 | [diff] [blame] | 66 | setenv("videostd", ((video_mode & 0x80) ? "pal" : "ntsc")); |
Sergey Kubushyn | e8f3912 | 2007-08-10 20:26:18 +0200 | [diff] [blame] | 67 | |
| 68 | return(0); |
| 69 | } |
Thomas Abraham | e913884 | 2009-01-04 09:41:09 +0530 | [diff] [blame] | 70 | |
| 71 | #ifdef CONFIG_USB_DAVINCI |
| 72 | |
| 73 | /* IO Expander I2C address and USB VBUS enable mask */ |
| 74 | #define IOEXP_I2C_ADDR 0x3A |
| 75 | #define IOEXP_VBUSEN_MASK 1 |
| 76 | |
| 77 | /* |
| 78 | * This function enables USB VBUS by writting to IO expander using I2C. |
| 79 | * Note that the I2C is already initialized at this stage. This |
| 80 | * function is used by davinci specific USB wrapper code. |
| 81 | */ |
| 82 | void enable_vbus(void) |
| 83 | { |
| 84 | uchar data; /* IO Expander data to enable VBUS */ |
| 85 | |
| 86 | /* Write to IO expander to enable VBUS */ |
| 87 | i2c_read(IOEXP_I2C_ADDR, 0, 0, &data, 1); |
| 88 | data &= ~IOEXP_VBUSEN_MASK; |
| 89 | i2c_write(IOEXP_I2C_ADDR, 0, 0, &data, 1); |
| 90 | } |
| 91 | #endif |