blob: c34bde4fa6013fbc691be2d7cceb804a34905495 [file] [log] [blame]
Sergey Kubushyne8f39122007-08-10 20:26:18 +02001/*
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 Denkd79de1d2013-07-08 09:37:19 +020011 * SPDX-License-Identifier: GPL-2.0+
Sergey Kubushyne8f39122007-08-10 20:26:18 +020012 * ----------------------------------------------------------------------------
13 */
14
15#include <common.h>
16#include <i2c.h>
17#include <asm/arch/hardware.h>
Sughosh Ganu80995f92010-11-28 20:21:27 -050018#include <asm/arch/davinci_misc.h>
Sergey Kubushyne8f39122007-08-10 20:26:18 +020019
Dirk Behmef2b171c2007-09-15 11:55:42 +020020DECLARE_GLOBAL_DATA_PTR;
21
Sergey Kubushyne8f39122007-08-10 20:26:18 +020022int board_init(void)
23{
Sergey Kubushyne8f39122007-08-10 20:26:18 +020024 /* 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 Villeneuvec9a21372008-11-21 14:35:56 -050030 /* 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 Kubushyne8f39122007-08-10 20:26:18 +020035
36 /* Power on required peripherals */
Sergey Kubushyne8f39122007-08-10 20:26:18 +020037 lpsc_on(DAVINCI_LPSC_GPIO);
Thomas Abrahambbcce612009-01-04 09:41:16 +053038 lpsc_on(DAVINCI_LPSC_USB);
Sergey Kubushyne8f39122007-08-10 20:26:18 +020039
Jean-Christophe PLAGNIOL-VILLARD03836942008-10-16 15:01:15 +020040#if !defined(CONFIG_SYS_USE_DSPLINK)
Sergey Kubushyne8f39122007-08-10 20:26:18 +020041 /* Powerup the DSP */
42 dsp_on();
Jean-Christophe PLAGNIOL-VILLARD03836942008-10-16 15:01:15 +020043#endif /* CONFIG_SYS_USE_DSPLINK */
Sergey Kubushyne8f39122007-08-10 20:26:18 +020044
Hugo Villeneuvec9a21372008-11-21 14:35:56 -050045 davinci_enable_uart0();
46 davinci_enable_emac();
47 davinci_enable_i2c();
Sergey Kubushyne8f39122007-08-10 20:26:18 +020048
Hugo Villeneuvec9a21372008-11-21 14:35:56 -050049 lpsc_on(DAVINCI_LPSC_TIMER1);
Sergey Kubushyne8f39122007-08-10 20:26:18 +020050 timer_init();
51
52 return(0);
53}
54
Hugo Villeneuve4e352ef2008-07-11 15:10:13 -040055int misc_init_r(void)
Sergey Kubushyne8f39122007-08-10 20:26:18 +020056{
Hugo Villeneuve4e352ef2008-07-11 15:10:13 -040057 uint8_t video_mode;
58 uint8_t eeprom_enetaddr[6];
Sergey Kubushyne8f39122007-08-10 20:26:18 +020059
Hugo Villeneuve4e352ef2008-07-11 15:10:13 -040060 /* Read Ethernet MAC address from EEPROM if available. */
61 if (dvevm_read_mac_address(eeprom_enetaddr))
Ben Gardiner1fb49e32010-09-23 09:58:43 -040062 davinci_sync_env_enetaddr(eeprom_enetaddr);
Sergey Kubushyne8f39122007-08-10 20:26:18 +020063
Hugo Villeneuve4e352ef2008-07-11 15:10:13 -040064 i2c_read(0x39, 0x00, 1, &video_mode, 1);
Sergey Kubushyne8f39122007-08-10 20:26:18 +020065
Hugo Villeneuve4e352ef2008-07-11 15:10:13 -040066 setenv("videostd", ((video_mode & 0x80) ? "pal" : "ntsc"));
Sergey Kubushyne8f39122007-08-10 20:26:18 +020067
68 return(0);
69}
Thomas Abrahame9138842009-01-04 09:41:09 +053070
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 */
82void 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