TsiChungLiew | 4a442d3 | 2007-08-16 19:23:50 -0500 | [diff] [blame] | 1 | /* |
| 2 | * |
| 3 | * (C) Copyright 2000-2003 |
| 4 | * Wolfgang Denk, DENX Software Engineering, wd@denx.de. |
| 5 | * |
Alison Wang | c6d8863 | 2012-03-26 21:49:06 +0000 | [diff] [blame] | 6 | * (C) Copyright 2007, 2012 Freescale Semiconductor, Inc. |
TsiChungLiew | 4a442d3 | 2007-08-16 19:23:50 -0500 | [diff] [blame] | 7 | * TsiChung Liew (Tsi-Chung.Liew@freescale.com) |
| 8 | * |
| 9 | * See file CREDITS for list of people who contributed to this |
| 10 | * project. |
| 11 | * |
| 12 | * This program is free software; you can redistribute it and/or |
| 13 | * modify it under the terms of the GNU General Public License as |
| 14 | * published by the Free Software Foundation; either version 2 of |
| 15 | * the License, or (at your option) any later version. |
| 16 | * |
| 17 | * This program is distributed in the hope that it will be useful, |
| 18 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 19 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 20 | * GNU General Public License for more details. |
| 21 | * |
| 22 | * You should have received a copy of the GNU General Public License |
| 23 | * along with this program; if not, write to the Free Software |
| 24 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, |
| 25 | * MA 02111-1307 USA |
| 26 | */ |
| 27 | |
| 28 | #include <common.h> |
| 29 | #include <watchdog.h> |
TsiChungLiew | 4a442d3 | 2007-08-16 19:23:50 -0500 | [diff] [blame] | 30 | #include <asm/immap.h> |
Alison Wang | c6d8863 | 2012-03-26 21:49:06 +0000 | [diff] [blame] | 31 | #include <asm/io.h> |
TsiChungLiew | 4a442d3 | 2007-08-16 19:23:50 -0500 | [diff] [blame] | 32 | |
TsiChung Liew | f3962d3 | 2008-10-21 13:47:54 +0000 | [diff] [blame] | 33 | #if defined(CONFIG_CMD_NET) |
| 34 | #include <config.h> |
| 35 | #include <net.h> |
| 36 | #include <asm/fec.h> |
| 37 | #endif |
| 38 | |
TsiChungLiew | 4a442d3 | 2007-08-16 19:23:50 -0500 | [diff] [blame] | 39 | /* |
| 40 | * Breath some life into the CPU... |
| 41 | * |
| 42 | * Set up the memory map, |
| 43 | * initialize a bunch of registers, |
| 44 | * initialize the UPM's |
| 45 | */ |
| 46 | void cpu_init_f(void) |
| 47 | { |
Alison Wang | c6d8863 | 2012-03-26 21:49:06 +0000 | [diff] [blame] | 48 | gpio_t *gpio = (gpio_t *) MMAP_GPIO; |
| 49 | fbcs_t *fbcs = (fbcs_t *) MMAP_FBCS; |
| 50 | wdog_t *wdog = (wdog_t *) MMAP_WDOG; |
| 51 | scm_t *scm = (scm_t *) MMAP_SCM; |
TsiChungLiew | 4a442d3 | 2007-08-16 19:23:50 -0500 | [diff] [blame] | 52 | |
| 53 | /* watchdog is enabled by default - disable the watchdog */ |
| 54 | #ifndef CONFIG_WATCHDOG |
Alison Wang | c6d8863 | 2012-03-26 21:49:06 +0000 | [diff] [blame] | 55 | out_be16(&wdog->cr, 0); |
TsiChungLiew | 4a442d3 | 2007-08-16 19:23:50 -0500 | [diff] [blame] | 56 | #endif |
| 57 | |
Alison Wang | c6d8863 | 2012-03-26 21:49:06 +0000 | [diff] [blame] | 58 | out_be32(&scm->rambar, CONFIG_SYS_INIT_RAM_ADDR | SCM_RAMBAR_BDE); |
TsiChungLiew | 4a442d3 | 2007-08-16 19:23:50 -0500 | [diff] [blame] | 59 | |
| 60 | /* Port configuration */ |
Alison Wang | c6d8863 | 2012-03-26 21:49:06 +0000 | [diff] [blame] | 61 | out_8(&gpio->par_cs, 0); |
TsiChungLiew | 4a442d3 | 2007-08-16 19:23:50 -0500 | [diff] [blame] | 62 | |
Jean-Christophe PLAGNIOL-VILLARD | 6d0f6bc | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 63 | #if (defined(CONFIG_SYS_CS0_BASE) && defined(CONFIG_SYS_CS0_MASK) && defined(CONFIG_SYS_CS0_CTRL)) |
Alison Wang | c6d8863 | 2012-03-26 21:49:06 +0000 | [diff] [blame] | 64 | out_be32(&fbcs->csar0, CONFIG_SYS_CS0_BASE); |
| 65 | out_be32(&fbcs->cscr0, CONFIG_SYS_CS0_CTRL); |
| 66 | out_be32(&fbcs->csmr0, CONFIG_SYS_CS0_MASK); |
TsiChungLiew | 4a442d3 | 2007-08-16 19:23:50 -0500 | [diff] [blame] | 67 | #endif |
| 68 | |
Jean-Christophe PLAGNIOL-VILLARD | 6d0f6bc | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 69 | #if (defined(CONFIG_SYS_CS1_BASE) && defined(CONFIG_SYS_CS1_MASK) && defined(CONFIG_SYS_CS1_CTRL)) |
Alison Wang | c6d8863 | 2012-03-26 21:49:06 +0000 | [diff] [blame] | 70 | setbits_8(&gpio->par_cs, GPIO_PAR_CS_CS1); |
| 71 | out_be32(&fbcs->csar1, CONFIG_SYS_CS1_BASE); |
| 72 | out_be32(&fbcs->cscr1, CONFIG_SYS_CS1_CTRL); |
| 73 | out_be32(&fbcs->csmr1, CONFIG_SYS_CS1_MASK); |
TsiChungLiew | 4a442d3 | 2007-08-16 19:23:50 -0500 | [diff] [blame] | 74 | #endif |
| 75 | |
Jean-Christophe PLAGNIOL-VILLARD | 6d0f6bc | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 76 | #if (defined(CONFIG_SYS_CS2_BASE) && defined(CONFIG_SYS_CS2_MASK) && defined(CONFIG_SYS_CS2_CTRL)) |
Alison Wang | c6d8863 | 2012-03-26 21:49:06 +0000 | [diff] [blame] | 77 | setbits_8(&gpio->par_cs, GPIO_PAR_CS_CS2); |
| 78 | out_be32(&fbcs->csar2, CONFIG_SYS_CS2_BASE); |
| 79 | out_be32(&fbcs->cscr2, CONFIG_SYS_CS2_CTRL); |
| 80 | out_be32(&fbcs->csmr2, CONFIG_SYS_CS2_MASK); |
TsiChungLiew | 4a442d3 | 2007-08-16 19:23:50 -0500 | [diff] [blame] | 81 | #endif |
| 82 | |
Jean-Christophe PLAGNIOL-VILLARD | 6d0f6bc | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 83 | #if (defined(CONFIG_SYS_CS3_BASE) && defined(CONFIG_SYS_CS3_MASK) && defined(CONFIG_SYS_CS3_CTRL)) |
Alison Wang | c6d8863 | 2012-03-26 21:49:06 +0000 | [diff] [blame] | 84 | setbits_8(&gpio->par_cs, GPIO_PAR_CS_CS3); |
| 85 | out_be32(&fbcs->csar3, CONFIG_SYS_CS3_BASE); |
| 86 | out_be32(&fbcs->cscr3, CONFIG_SYS_CS3_CTRL); |
| 87 | out_be32(&fbcs->csmr3, CONFIG_SYS_CS3_MASK); |
TsiChungLiew | 4a442d3 | 2007-08-16 19:23:50 -0500 | [diff] [blame] | 88 | #endif |
| 89 | |
Jean-Christophe PLAGNIOL-VILLARD | 6d0f6bc | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 90 | #if (defined(CONFIG_SYS_CS4_BASE) && defined(CONFIG_SYS_CS4_MASK) && defined(CONFIG_SYS_CS4_CTRL)) |
Alison Wang | c6d8863 | 2012-03-26 21:49:06 +0000 | [diff] [blame] | 91 | setbits_8(&gpio->par_cs, GPIO_PAR_CS_CS4); |
| 92 | out_be32(&fbcs->csar4, CONFIG_SYS_CS4_BASE); |
| 93 | out_be32(&fbcs->cscr4, CONFIG_SYS_CS4_CTRL); |
| 94 | out_be32(&fbcs->csmr4, CONFIG_SYS_CS4_MASK); |
TsiChungLiew | 4a442d3 | 2007-08-16 19:23:50 -0500 | [diff] [blame] | 95 | #endif |
| 96 | |
Jean-Christophe PLAGNIOL-VILLARD | 6d0f6bc | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 97 | #if (defined(CONFIG_SYS_CS5_BASE) && defined(CONFIG_SYS_CS5_MASK) && defined(CONFIG_SYS_CS5_CTRL)) |
Alison Wang | c6d8863 | 2012-03-26 21:49:06 +0000 | [diff] [blame] | 98 | setbits_8(&gpio->par_cs, GPIO_PAR_CS_CS5); |
| 99 | out_be32(&fbcs->csar5, CONFIG_SYS_CS5_BASE); |
| 100 | out_be32(&fbcs->cscr5, CONFIG_SYS_CS5_CTRL); |
| 101 | out_be32(&fbcs->csmr5, CONFIG_SYS_CS5_MASK); |
TsiChungLiew | 4a442d3 | 2007-08-16 19:23:50 -0500 | [diff] [blame] | 102 | #endif |
| 103 | |
Jean-Christophe PLAGNIOL-VILLARD | 6d0f6bc | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 104 | #if (defined(CONFIG_SYS_CS6_BASE) && defined(CONFIG_SYS_CS6_MASK) && defined(CONFIG_SYS_CS6_CTRL)) |
Alison Wang | c6d8863 | 2012-03-26 21:49:06 +0000 | [diff] [blame] | 105 | setbits_8(&gpio->par_cs, GPIO_PAR_CS_CS6); |
| 106 | out_be32(&fbcs->csar6, CONFIG_SYS_CS6_BASE); |
| 107 | out_be32(&fbcs->cscr6, CONFIG_SYS_CS6_CTRL); |
| 108 | out_be32(&fbcs->csmr6, CONFIG_SYS_CS6_MASK); |
TsiChungLiew | 4a442d3 | 2007-08-16 19:23:50 -0500 | [diff] [blame] | 109 | #endif |
| 110 | |
Jean-Christophe PLAGNIOL-VILLARD | 6d0f6bc | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 111 | #if (defined(CONFIG_SYS_CS7_BASE) && defined(CONFIG_SYS_CS7_MASK) && defined(CONFIG_SYS_CS7_CTRL)) |
Alison Wang | c6d8863 | 2012-03-26 21:49:06 +0000 | [diff] [blame] | 112 | setbits_8(&gpio->par_cs, GPIO_PAR_CS_CS7); |
| 113 | out_be32(&fbcs->csar7, CONFIG_SYS_CS7_BASE); |
| 114 | out_be32(&fbcs->cscr7, CONFIG_SYS_CS7_CTRL); |
| 115 | out_be32(&fbcs->csmr7, CONFIG_SYS_CS7_MASK); |
TsiChungLiew | 4a442d3 | 2007-08-16 19:23:50 -0500 | [diff] [blame] | 116 | #endif |
| 117 | |
| 118 | #ifdef CONFIG_FSL_I2C |
Jean-Christophe PLAGNIOL-VILLARD | 6d0f6bc | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 119 | CONFIG_SYS_I2C_PINMUX_REG &= CONFIG_SYS_I2C_PINMUX_CLR; |
| 120 | CONFIG_SYS_I2C_PINMUX_REG |= CONFIG_SYS_I2C_PINMUX_SET; |
TsiChungLiew | 4a442d3 | 2007-08-16 19:23:50 -0500 | [diff] [blame] | 121 | #endif |
| 122 | |
| 123 | icache_enable(); |
| 124 | } |
| 125 | |
| 126 | /* |
| 127 | * initialize higher level parts of CPU like timers |
| 128 | */ |
| 129 | int cpu_init_r(void) |
| 130 | { |
| 131 | return (0); |
| 132 | } |
| 133 | |
TsiChung Liew | 52affe0 | 2010-03-09 19:17:52 -0600 | [diff] [blame] | 134 | void uart_port_conf(int port) |
TsiChungLiew | 4a442d3 | 2007-08-16 19:23:50 -0500 | [diff] [blame] | 135 | { |
Alison Wang | c6d8863 | 2012-03-26 21:49:06 +0000 | [diff] [blame] | 136 | gpio_t *gpio = (gpio_t *) MMAP_GPIO; |
TsiChungLiew | 4a442d3 | 2007-08-16 19:23:50 -0500 | [diff] [blame] | 137 | |
Stefan Roese | 8280f6a | 2007-08-18 14:33:02 +0200 | [diff] [blame] | 138 | /* Setup Ports: */ |
TsiChung Liew | 52affe0 | 2010-03-09 19:17:52 -0600 | [diff] [blame] | 139 | switch (port) { |
Stefan Roese | 8280f6a | 2007-08-18 14:33:02 +0200 | [diff] [blame] | 140 | case 0: |
Alison Wang | c6d8863 | 2012-03-26 21:49:06 +0000 | [diff] [blame] | 141 | clrbits_be16(&gpio->par_uart, |
| 142 | GPIO_PAR_UART_U0RXD | GPIO_PAR_UART_U0TXD); |
| 143 | setbits_be16(&gpio->par_uart, |
| 144 | GPIO_PAR_UART_U0RXD | GPIO_PAR_UART_U0TXD); |
Stefan Roese | 8280f6a | 2007-08-18 14:33:02 +0200 | [diff] [blame] | 145 | break; |
| 146 | case 1: |
Alison Wang | c6d8863 | 2012-03-26 21:49:06 +0000 | [diff] [blame] | 147 | clrbits_be16(&gpio->par_uart, |
| 148 | GPIO_PAR_UART_U1RXD_MASK | GPIO_PAR_UART_U1TXD_MASK); |
| 149 | setbits_be16(&gpio->par_uart, |
| 150 | GPIO_PAR_UART_U1RXD_U1RXD | GPIO_PAR_UART_U1TXD_U1TXD); |
Stefan Roese | 8280f6a | 2007-08-18 14:33:02 +0200 | [diff] [blame] | 151 | break; |
| 152 | case 2: |
TsiChung Liew | 52affe0 | 2010-03-09 19:17:52 -0600 | [diff] [blame] | 153 | #ifdef CONFIG_SYS_UART2_PRI_GPIO |
Alison Wang | c6d8863 | 2012-03-26 21:49:06 +0000 | [diff] [blame] | 154 | clrbits_be16(&gpio->par_uart, |
| 155 | GPIO_PAR_UART_U2RXD | GPIO_PAR_UART_U2TXD); |
| 156 | setbits_be16(&gpio->par_uart, |
| 157 | GPIO_PAR_UART_U2RXD | GPIO_PAR_UART_U2TXD); |
TsiChung Liew | 52affe0 | 2010-03-09 19:17:52 -0600 | [diff] [blame] | 158 | #elif defined(CONFIG_SYS_UART2_ALT1_GPIO) |
Alison Wang | c6d8863 | 2012-03-26 21:49:06 +0000 | [diff] [blame] | 159 | clrbits_8(&gpio->par_feci2c, |
| 160 | GPIO_PAR_FECI2C_EMDC_MASK | GPIO_PAR_FECI2C_EMDIO_MASK); |
| 161 | setbits_8(&gpio->par_feci2c, |
| 162 | GPIO_PAR_FECI2C_EMDC_U2TXD | GPIO_PAR_FECI2C_EMDIO_U2RXD); |
TsiChung Liew | 52affe0 | 2010-03-09 19:17:52 -0600 | [diff] [blame] | 163 | #endif |
Stefan Roese | 8280f6a | 2007-08-18 14:33:02 +0200 | [diff] [blame] | 164 | break; |
| 165 | } |
TsiChungLiew | 4a442d3 | 2007-08-16 19:23:50 -0500 | [diff] [blame] | 166 | } |
TsiChung Liew | f3962d3 | 2008-10-21 13:47:54 +0000 | [diff] [blame] | 167 | |
| 168 | #if defined(CONFIG_CMD_NET) |
| 169 | int fecpin_setclear(struct eth_device *dev, int setclear) |
| 170 | { |
Alison Wang | c6d8863 | 2012-03-26 21:49:06 +0000 | [diff] [blame] | 171 | gpio_t *gpio = (gpio_t *) MMAP_GPIO; |
TsiChung Liew | f3962d3 | 2008-10-21 13:47:54 +0000 | [diff] [blame] | 172 | |
| 173 | if (setclear) { |
Alison Wang | c6d8863 | 2012-03-26 21:49:06 +0000 | [diff] [blame] | 174 | setbits_8(&gpio->par_feci2c, |
| 175 | GPIO_PAR_FECI2C_EMDC_FECEMDC | |
| 176 | GPIO_PAR_FECI2C_EMDIO_FECEMDIO); |
TsiChung Liew | f3962d3 | 2008-10-21 13:47:54 +0000 | [diff] [blame] | 177 | } else { |
Alison Wang | c6d8863 | 2012-03-26 21:49:06 +0000 | [diff] [blame] | 178 | clrbits_8(&gpio->par_feci2c, |
| 179 | GPIO_PAR_FECI2C_EMDC_MASK | |
| 180 | GPIO_PAR_FECI2C_EMDIO_MASK); |
TsiChung Liew | f3962d3 | 2008-10-21 13:47:54 +0000 | [diff] [blame] | 181 | } |
| 182 | |
| 183 | return 0; |
| 184 | } |
| 185 | #endif |