]> git.kernelconcepts.de Git - karo-tx-uboot.git/blob - board/davinci/sonata/sonata.c
Merge remote-tracking branch 'u-boot-samsung/master'
[karo-tx-uboot.git] / board / davinci / sonata / sonata.c
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  * SPDX-License-Identifier:     GPL-2.0+
12  * ----------------------------------------------------------------------------
13  */
14
15 #include <common.h>
16 #include <nand.h>
17 #include <asm/ti-common/davinci_nand.h>
18 #include <asm/arch/hardware.h>
19 #include <asm/arch/davinci_misc.h>
20
21 DECLARE_GLOBAL_DATA_PTR;
22
23 int board_init(void)
24 {
25         /* address of boot parameters */
26         gd->bd->bi_boot_params = LINUX_BOOT_PARAM_ADDR;
27
28         /* Configure AEMIF pins (although this should be configured at boot time
29          * with pull-up/pull-down resistors) */
30         REG(PINMUX0) = 0x00000c1f;
31
32         davinci_errata_workarounds();
33
34         /* Power on required peripherals */
35         lpsc_on(DAVINCI_LPSC_GPIO);
36
37 #if !defined(CONFIG_SYS_USE_DSPLINK)
38         /* Powerup the DSP */
39         dsp_on();
40 #endif /* CONFIG_SYS_USE_DSPLINK */
41
42         davinci_enable_uart0();
43         davinci_enable_emac();
44         davinci_enable_i2c();
45
46         lpsc_on(DAVINCI_LPSC_TIMER1);
47         timer_init();
48
49         return(0);
50 }
51
52 int misc_init_r(void)
53 {
54         uint8_t eeprom_enetaddr[6];
55
56         /* Read Ethernet MAC address from EEPROM if available. */
57         if (dvevm_read_mac_address(eeprom_enetaddr))
58                 davinci_sync_env_enetaddr(eeprom_enetaddr);
59
60         return(0);
61 }
62
63 #ifdef CONFIG_NAND_DAVINCI
64
65 /* Set WP on deselect, write enable on select */
66 static void nand_sonata_select_chip(struct mtd_info *mtd, int chip)
67 {
68 #define GPIO_SET_DATA01 0x01c67018
69 #define GPIO_CLR_DATA01 0x01c6701c
70 #define GPIO_NAND_WP    (1 << 4)
71 #ifdef SONATA_BOARD_GPIOWP
72         if (chip < 0) {
73                 REG(GPIO_CLR_DATA01) |= GPIO_NAND_WP;
74         } else {
75                 REG(GPIO_SET_DATA01) |= GPIO_NAND_WP;
76         }
77 #endif
78 }
79
80 int board_nand_init(struct nand_chip *nand)
81 {
82         davinci_nand_init(nand);
83         nand->select_chip = nand_sonata_select_chip;
84         return 0;
85 }
86
87 #endif /* CONFIG_NAND_DAVINCI */