Sekhar Nori | a9ada86 | 2009-11-12 11:08:39 -0500 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2009 Nick Thompson, GE Fanuc, Ltd. <nick.thompson@gefanuc.com> |
| 3 | * |
| 4 | * Base on code from TI. Original Notices follow: |
| 5 | * |
| 6 | * (C) Copyright 2008, Texas Instruments, Inc. http://www.ti.com/ |
| 7 | * |
| 8 | * Modified for DA8xx EVM. |
| 9 | * |
| 10 | * Copyright (C) 2007 Sergey Kubushyn <ksi@koi8.net> |
| 11 | * |
| 12 | * Parts are shamelessly stolen from various TI sources, original copyright |
| 13 | * follows: |
| 14 | * ----------------------------------------------------------------- |
| 15 | * |
| 16 | * Copyright (C) 2004 Texas Instruments. |
| 17 | * |
| 18 | * ---------------------------------------------------------------------------- |
| 19 | * This program is free software; you can redistribute it and/or modify |
| 20 | * it under the terms of the GNU General Public License as published by |
| 21 | * the Free Software Foundation; either version 2 of the License, or |
| 22 | * (at your option) any later version. |
| 23 | * |
| 24 | * This program is distributed in the hope that it will be useful, |
| 25 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 26 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 27 | * GNU General Public License for more details. |
| 28 | * |
| 29 | * You should have received a copy of the GNU General Public License |
| 30 | * along with this program; if not, write to the Free Software |
| 31 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. |
| 32 | * ---------------------------------------------------------------------------- |
| 33 | */ |
| 34 | |
| 35 | #include <common.h> |
| 36 | #include <i2c.h> |
| 37 | #include <asm/arch/hardware.h> |
| 38 | #include <asm/io.h> |
| 39 | #include "../common/misc.h" |
| 40 | |
| 41 | DECLARE_GLOBAL_DATA_PTR; |
| 42 | |
| 43 | #define pinmux &davinci_syscfg_regs->pinmux |
| 44 | |
Sekhar Nori | a9ada86 | 2009-11-12 11:08:39 -0500 | [diff] [blame] | 45 | /* SPI0 pin muxer settings */ |
Nick Thompson | 1d300d8 | 2010-01-27 11:11:28 -0500 | [diff] [blame^] | 46 | static const struct pinmux_config spi0_pins[] = { |
Sekhar Nori | a9ada86 | 2009-11-12 11:08:39 -0500 | [diff] [blame] | 47 | { pinmux[7], 1, 3 }, |
| 48 | { pinmux[7], 1, 4 }, |
| 49 | { pinmux[7], 1, 5 }, |
| 50 | { pinmux[7], 1, 6 }, |
| 51 | { pinmux[7], 1, 7 } |
| 52 | }; |
Sekhar Nori | a9ada86 | 2009-11-12 11:08:39 -0500 | [diff] [blame] | 53 | |
| 54 | /* UART pin muxer settings */ |
Nick Thompson | 1d300d8 | 2010-01-27 11:11:28 -0500 | [diff] [blame^] | 55 | static const struct pinmux_config uart_pins[] = { |
Sekhar Nori | a9ada86 | 2009-11-12 11:08:39 -0500 | [diff] [blame] | 56 | { pinmux[8], 2, 7 }, |
| 57 | { pinmux[9], 2, 0 } |
| 58 | }; |
| 59 | |
| 60 | /* I2C pin muxer settings */ |
Nick Thompson | 1d300d8 | 2010-01-27 11:11:28 -0500 | [diff] [blame^] | 61 | static const struct pinmux_config i2c_pins[] = { |
Sekhar Nori | a9ada86 | 2009-11-12 11:08:39 -0500 | [diff] [blame] | 62 | { pinmux[9], 2, 3 }, |
| 63 | { pinmux[9], 2, 4 } |
| 64 | }; |
| 65 | |
Ajay Kumar Gupta | e94491d | 2009-12-22 10:56:11 +0530 | [diff] [blame] | 66 | /* USB0_DRVVBUS pin muxer settings */ |
Nick Thompson | 1d300d8 | 2010-01-27 11:11:28 -0500 | [diff] [blame^] | 67 | static const struct pinmux_config usb_pins[] = { |
Ajay Kumar Gupta | e94491d | 2009-12-22 10:56:11 +0530 | [diff] [blame] | 68 | { pinmux[9], 1, 1 } |
| 69 | }; |
| 70 | |
Nick Thompson | 1d300d8 | 2010-01-27 11:11:28 -0500 | [diff] [blame^] | 71 | static const struct pinmux_resource pinmuxes[] = { |
| 72 | #ifdef CONFIG_SPI_FLASH |
| 73 | PINMUX_ITEM(spi0_pins), |
| 74 | #endif |
| 75 | PINMUX_ITEM(uart_pins), |
| 76 | PINMUX_ITEM(i2c_pins), |
| 77 | #ifdef CONFIG_USB_DA8XX |
| 78 | PINMUX_ITEM(usb_pins), |
| 79 | #endif |
| 80 | }; |
| 81 | |
Sekhar Nori | a9ada86 | 2009-11-12 11:08:39 -0500 | [diff] [blame] | 82 | int board_init(void) |
| 83 | { |
| 84 | #ifndef CONFIG_USE_IRQ |
| 85 | /* |
| 86 | * Mask all IRQs by clearing the global enable and setting |
| 87 | * the enable clear for all the 90 interrupts. |
| 88 | */ |
| 89 | |
| 90 | writel(0, &davinci_aintc_regs->ger); |
| 91 | |
| 92 | writel(0, &davinci_aintc_regs->hier); |
| 93 | |
| 94 | writel(0xffffffff, &davinci_aintc_regs->ecr1); |
| 95 | writel(0xffffffff, &davinci_aintc_regs->ecr2); |
| 96 | writel(0xffffffff, &davinci_aintc_regs->ecr3); |
| 97 | #endif |
| 98 | |
| 99 | /* arch number of the board */ |
| 100 | gd->bd->bi_arch_number = MACH_TYPE_DAVINCI_DA830_EVM; |
| 101 | |
| 102 | /* address of boot parameters */ |
| 103 | gd->bd->bi_boot_params = LINUX_BOOT_PARAM_ADDR; |
| 104 | |
| 105 | /* |
| 106 | * Power on required peripherals |
| 107 | * ARM does not have access by default to PSC0 and PSC1 |
| 108 | * assuming here that the DSP bootloader has set the IOPU |
| 109 | * such that PSC access is available to ARM |
| 110 | */ |
| 111 | lpsc_on(DAVINCI_LPSC_AEMIF); /* NAND, NOR */ |
| 112 | lpsc_on(DAVINCI_LPSC_SPI0); /* Serial Flash */ |
| 113 | lpsc_on(DAVINCI_LPSC_EMAC); /* image download */ |
| 114 | lpsc_on(DAVINCI_LPSC_UART2); /* console */ |
| 115 | lpsc_on(DAVINCI_LPSC_GPIO); |
| 116 | |
| 117 | /* setup the SUSPSRC for ARM to control emulation suspend */ |
| 118 | writel(readl(&davinci_syscfg_regs->suspsrc) & |
| 119 | ~(DAVINCI_SYSCFG_SUSPSRC_EMAC | DAVINCI_SYSCFG_SUSPSRC_I2C | |
| 120 | DAVINCI_SYSCFG_SUSPSRC_SPI0 | DAVINCI_SYSCFG_SUSPSRC_TIMER0 | |
| 121 | DAVINCI_SYSCFG_SUSPSRC_UART2), |
| 122 | &davinci_syscfg_regs->suspsrc); |
| 123 | |
Nick Thompson | 1d300d8 | 2010-01-27 11:11:28 -0500 | [diff] [blame^] | 124 | /* configure pinmux settings */ |
| 125 | if (davinci_configure_pin_mux_items(pinmuxes, ARRAY_SIZE(pinmuxes))) |
Ajay Kumar Gupta | e94491d | 2009-12-22 10:56:11 +0530 | [diff] [blame] | 126 | return 1; |
| 127 | |
Sekhar Nori | a9ada86 | 2009-11-12 11:08:39 -0500 | [diff] [blame] | 128 | /* enable the console UART */ |
| 129 | writel((DAVINCI_UART_PWREMU_MGMT_FREE | DAVINCI_UART_PWREMU_MGMT_URRST | |
| 130 | DAVINCI_UART_PWREMU_MGMT_UTRST), |
| 131 | &davinci_uart2_ctrl_regs->pwremu_mgmt); |
| 132 | |
| 133 | return(0); |
| 134 | } |