blob: 22308deeb05cbb07cd01b3a9c963fb68e8898c6b [file] [log] [blame]
Sergey Kubushync74b2102007-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 * ----------------------------------------------------------------------------
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 Villeneuve264bbdd2008-07-11 15:10:13 -040030#include "../common/psc.h"
31#include "../common/misc.h"
Sergey Kubushync74b2102007-08-10 20:26:18 +020032
Dirk Behme66b3f242007-09-15 11:55:42 +020033DECLARE_GLOBAL_DATA_PTR;
34
Sergey Kubushync74b2102007-08-10 20:26:18 +020035int board_init(void)
36{
Sergey Kubushync74b2102007-08-10 20:26:18 +020037 /* arch number of the board */
38 gd->bd->bi_arch_number = MACH_TYPE_DAVINCI_EVM;
39
40 /* address of boot parameters */
41 gd->bd->bi_boot_params = LINUX_BOOT_PARAM_ADDR;
42
Hugo Villeneuve0cd18fa2008-11-21 14:35:56 -050043 /* Configure AEMIF pins (although this should be configured at boot time
44 * with pull-up/pull-down resistors) */
45 REG(PINMUX0) = 0x00000c1f;
46
47 davinci_errata_workarounds();
Sergey Kubushync74b2102007-08-10 20:26:18 +020048
49 /* Power on required peripherals */
Sergey Kubushync74b2102007-08-10 20:26:18 +020050 lpsc_on(DAVINCI_LPSC_GPIO);
Thomas Abraham538ef962009-01-04 09:41:16 +053051 lpsc_on(DAVINCI_LPSC_USB);
Sergey Kubushync74b2102007-08-10 20:26:18 +020052
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +020053#if !defined(CONFIG_SYS_USE_DSPLINK)
Sergey Kubushync74b2102007-08-10 20:26:18 +020054 /* Powerup the DSP */
55 dsp_on();
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +020056#endif /* CONFIG_SYS_USE_DSPLINK */
Sergey Kubushync74b2102007-08-10 20:26:18 +020057
Hugo Villeneuve0cd18fa2008-11-21 14:35:56 -050058 davinci_enable_uart0();
59 davinci_enable_emac();
60 davinci_enable_i2c();
Sergey Kubushync74b2102007-08-10 20:26:18 +020061
Hugo Villeneuve0cd18fa2008-11-21 14:35:56 -050062 lpsc_on(DAVINCI_LPSC_TIMER1);
Sergey Kubushync74b2102007-08-10 20:26:18 +020063 timer_init();
64
65 return(0);
66}
67
Hugo Villeneuve264bbdd2008-07-11 15:10:13 -040068int misc_init_r(void)
Sergey Kubushync74b2102007-08-10 20:26:18 +020069{
Hugo Villeneuve264bbdd2008-07-11 15:10:13 -040070 uint8_t video_mode;
71 uint8_t eeprom_enetaddr[6];
Sergey Kubushync74b2102007-08-10 20:26:18 +020072
Hugo Villeneuve264bbdd2008-07-11 15:10:13 -040073 dv_display_clk_infos();
Sergey Kubushync74b2102007-08-10 20:26:18 +020074
Hugo Villeneuve264bbdd2008-07-11 15:10:13 -040075 /* Read Ethernet MAC address from EEPROM if available. */
76 if (dvevm_read_mac_address(eeprom_enetaddr))
77 dv_configure_mac_address(eeprom_enetaddr);
Sergey Kubushync74b2102007-08-10 20:26:18 +020078
Hugo Villeneuve85e58082008-07-11 15:10:11 -040079 if (!eth_hw_init())
Sergey Kubushync74b2102007-08-10 20:26:18 +020080 printf("ethernet init failed!\n");
Sergey Kubushync74b2102007-08-10 20:26:18 +020081
Hugo Villeneuve264bbdd2008-07-11 15:10:13 -040082 i2c_read(0x39, 0x00, 1, &video_mode, 1);
Sergey Kubushync74b2102007-08-10 20:26:18 +020083
Hugo Villeneuve264bbdd2008-07-11 15:10:13 -040084 setenv("videostd", ((video_mode & 0x80) ? "pal" : "ntsc"));
Sergey Kubushync74b2102007-08-10 20:26:18 +020085
86 return(0);
87}
Thomas Abrahama9d39eb2009-01-04 09:41:09 +053088
89#ifdef CONFIG_USB_DAVINCI
90
91/* IO Expander I2C address and USB VBUS enable mask */
92#define IOEXP_I2C_ADDR 0x3A
93#define IOEXP_VBUSEN_MASK 1
94
95/*
96 * This function enables USB VBUS by writting to IO expander using I2C.
97 * Note that the I2C is already initialized at this stage. This
98 * function is used by davinci specific USB wrapper code.
99 */
100void enable_vbus(void)
101{
102 uchar data; /* IO Expander data to enable VBUS */
103
104 /* Write to IO expander to enable VBUS */
105 i2c_read(IOEXP_I2C_ADDR, 0, 0, &data, 1);
106 data &= ~IOEXP_VBUSEN_MASK;
107 i2c_write(IOEXP_I2C_ADDR, 0, 0, &data, 1);
108}
109#endif