TsiChung Liew | f6afe72 | 2007-06-18 13:50:13 -0500 | [diff] [blame] | 1 | /* |
| 2 | * |
| 3 | * (C) Copyright 2000-2003 |
| 4 | * Wolfgang Denk, DENX Software Engineering, wd@denx.de. |
| 5 | * |
TsiChungLiew | 97401c3 | 2007-07-05 23:03:28 -0500 | [diff] [blame] | 6 | * (C) Copyright 2007 Freescale Semiconductor, Inc. |
TsiChung Liew | f6afe72 | 2007-06-18 13:50:13 -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 | 97401c3 | 2007-07-05 23:03:28 -0500 | [diff] [blame] | 30 | #include <asm/immap.h> |
TsiChung Liew | f6afe72 | 2007-06-18 13:50:13 -0500 | [diff] [blame] | 31 | |
TsiChung Liew | 69b1757 | 2008-10-21 13:47:54 +0000 | [diff] [blame] | 32 | #if defined(CONFIG_CMD_NET) |
| 33 | #include <config.h> |
| 34 | #include <net.h> |
| 35 | #include <asm/fec.h> |
| 36 | #endif |
| 37 | |
TsiChung Liew | f6afe72 | 2007-06-18 13:50:13 -0500 | [diff] [blame] | 38 | /* |
| 39 | * Breath some life into the CPU... |
| 40 | * |
| 41 | * Set up the memory map, |
| 42 | * initialize a bunch of registers, |
| 43 | * initialize the UPM's |
| 44 | */ |
| 45 | void cpu_init_f(void) |
| 46 | { |
| 47 | volatile scm1_t *scm1 = (scm1_t *) MMAP_SCM1; |
| 48 | volatile scm2_t *scm2 = (scm2_t *) MMAP_SCM2; |
| 49 | volatile gpio_t *gpio = (gpio_t *) MMAP_GPIO; |
| 50 | volatile fbcs_t *fbcs = (fbcs_t *) MMAP_FBCS; |
| 51 | volatile wdog_t *wdog = (wdog_t *) MMAP_WDOG; |
| 52 | |
| 53 | /* watchdog is enabled by default - disable the watchdog */ |
| 54 | #ifndef CONFIG_WATCHDOG |
| 55 | wdog->cr = 0; |
| 56 | #endif |
| 57 | |
| 58 | scm1->mpr0 = 0x77777777; |
| 59 | scm2->pacra = 0; |
| 60 | scm2->pacrb = 0; |
| 61 | scm2->pacrc = 0; |
| 62 | scm2->pacrd = 0; |
| 63 | scm2->pacre = 0; |
| 64 | scm2->pacrf = 0; |
| 65 | scm2->pacrg = 0; |
| 66 | scm1->pacrh = 0; |
| 67 | |
TsiChung Liew | f6afe72 | 2007-06-18 13:50:13 -0500 | [diff] [blame] | 68 | /* Port configuration */ |
TsiChungLiew | 2325c9f | 2007-08-05 05:15:18 -0500 | [diff] [blame] | 69 | gpio->par_cs = 0; |
TsiChung Liew | f6afe72 | 2007-06-18 13:50:13 -0500 | [diff] [blame] | 70 | |
Jean-Christophe PLAGNIOL-VILLARD | 0383694 | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 71 | #if (defined(CONFIG_SYS_CS0_BASE) && defined(CONFIG_SYS_CS0_MASK) && defined(CONFIG_SYS_CS0_CTRL)) |
| 72 | fbcs->csar0 = CONFIG_SYS_CS0_BASE; |
| 73 | fbcs->cscr0 = CONFIG_SYS_CS0_CTRL; |
| 74 | fbcs->csmr0 = CONFIG_SYS_CS0_MASK; |
TsiChung Liew | f6afe72 | 2007-06-18 13:50:13 -0500 | [diff] [blame] | 75 | #endif |
| 76 | |
Jean-Christophe PLAGNIOL-VILLARD | 0383694 | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 77 | #if (defined(CONFIG_SYS_CS1_BASE) && defined(CONFIG_SYS_CS1_MASK) && defined(CONFIG_SYS_CS1_CTRL)) |
TsiChung Liew | f6afe72 | 2007-06-18 13:50:13 -0500 | [diff] [blame] | 78 | /* Latch chipselect */ |
Stefan Roese | eb8c294 | 2007-08-08 09:54:26 +0200 | [diff] [blame] | 79 | gpio->par_cs |= GPIO_PAR_CS1; |
Jean-Christophe PLAGNIOL-VILLARD | 0383694 | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 80 | fbcs->csar1 = CONFIG_SYS_CS1_BASE; |
| 81 | fbcs->cscr1 = CONFIG_SYS_CS1_CTRL; |
| 82 | fbcs->csmr1 = CONFIG_SYS_CS1_MASK; |
TsiChung Liew | f6afe72 | 2007-06-18 13:50:13 -0500 | [diff] [blame] | 83 | #endif |
| 84 | |
Jean-Christophe PLAGNIOL-VILLARD | 0383694 | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 85 | #if (defined(CONFIG_SYS_CS2_BASE) && defined(CONFIG_SYS_CS2_MASK) && defined(CONFIG_SYS_CS2_CTRL)) |
Stefan Roese | eb8c294 | 2007-08-08 09:54:26 +0200 | [diff] [blame] | 86 | gpio->par_cs |= GPIO_PAR_CS2; |
Jean-Christophe PLAGNIOL-VILLARD | 0383694 | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 87 | fbcs->csar2 = CONFIG_SYS_CS2_BASE; |
| 88 | fbcs->cscr2 = CONFIG_SYS_CS2_CTRL; |
| 89 | fbcs->csmr2 = CONFIG_SYS_CS2_MASK; |
TsiChung Liew | f6afe72 | 2007-06-18 13:50:13 -0500 | [diff] [blame] | 90 | #endif |
| 91 | |
Jean-Christophe PLAGNIOL-VILLARD | 0383694 | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 92 | #if (defined(CONFIG_SYS_CS3_BASE) && defined(CONFIG_SYS_CS3_MASK) && defined(CONFIG_SYS_CS3_CTRL)) |
Stefan Roese | eb8c294 | 2007-08-08 09:54:26 +0200 | [diff] [blame] | 93 | gpio->par_cs |= GPIO_PAR_CS3; |
Jean-Christophe PLAGNIOL-VILLARD | 0383694 | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 94 | fbcs->csar3 = CONFIG_SYS_CS3_BASE; |
| 95 | fbcs->cscr3 = CONFIG_SYS_CS3_CTRL; |
| 96 | fbcs->csmr3 = CONFIG_SYS_CS3_MASK; |
TsiChung Liew | f6afe72 | 2007-06-18 13:50:13 -0500 | [diff] [blame] | 97 | #endif |
| 98 | |
Jean-Christophe PLAGNIOL-VILLARD | 0383694 | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 99 | #if (defined(CONFIG_SYS_CS4_BASE) && defined(CONFIG_SYS_CS4_MASK) && defined(CONFIG_SYS_CS4_CTRL)) |
Stefan Roese | eb8c294 | 2007-08-08 09:54:26 +0200 | [diff] [blame] | 100 | gpio->par_cs |= GPIO_PAR_CS4; |
Jean-Christophe PLAGNIOL-VILLARD | 0383694 | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 101 | fbcs->csar4 = CONFIG_SYS_CS4_BASE; |
| 102 | fbcs->cscr4 = CONFIG_SYS_CS4_CTRL; |
| 103 | fbcs->csmr4 = CONFIG_SYS_CS4_MASK; |
TsiChung Liew | f6afe72 | 2007-06-18 13:50:13 -0500 | [diff] [blame] | 104 | #endif |
| 105 | |
Jean-Christophe PLAGNIOL-VILLARD | 0383694 | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 106 | #if (defined(CONFIG_SYS_CS5_BASE) && defined(CONFIG_SYS_CS5_MASK) && defined(CONFIG_SYS_CS5_CTRL)) |
Stefan Roese | eb8c294 | 2007-08-08 09:54:26 +0200 | [diff] [blame] | 107 | gpio->par_cs |= GPIO_PAR_CS5; |
Jean-Christophe PLAGNIOL-VILLARD | 0383694 | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 108 | fbcs->csar5 = CONFIG_SYS_CS5_BASE; |
| 109 | fbcs->cscr5 = CONFIG_SYS_CS5_CTRL; |
| 110 | fbcs->csmr5 = CONFIG_SYS_CS5_MASK; |
TsiChung Liew | f6afe72 | 2007-06-18 13:50:13 -0500 | [diff] [blame] | 111 | #endif |
TsiChung | 6373c0c | 2007-07-10 15:45:43 -0500 | [diff] [blame] | 112 | |
TsiChungLiew | 2325c9f | 2007-08-05 05:15:18 -0500 | [diff] [blame] | 113 | #ifdef CONFIG_FSL_I2C |
| 114 | gpio->par_feci2c = GPIO_PAR_FECI2C_SCL_SCL | GPIO_PAR_FECI2C_SDA_SDA; |
| 115 | #endif |
| 116 | |
TsiChung | 6373c0c | 2007-07-10 15:45:43 -0500 | [diff] [blame] | 117 | icache_enable(); |
TsiChung Liew | f6afe72 | 2007-06-18 13:50:13 -0500 | [diff] [blame] | 118 | } |
| 119 | |
| 120 | /* |
| 121 | * initialize higher level parts of CPU like timers |
| 122 | */ |
| 123 | int cpu_init_r(void) |
| 124 | { |
TsiChung Liew | f6afe72 | 2007-06-18 13:50:13 -0500 | [diff] [blame] | 125 | return (0); |
| 126 | } |
TsiChungLiew | 74634c8 | 2007-08-05 03:55:21 -0500 | [diff] [blame] | 127 | |
| 128 | void uart_port_conf(void) |
| 129 | { |
| 130 | volatile gpio_t *gpio = (gpio_t *) MMAP_GPIO; |
| 131 | |
| 132 | /* Setup Ports: */ |
Jean-Christophe PLAGNIOL-VILLARD | 0383694 | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 133 | switch (CONFIG_SYS_UART_PORT) { |
TsiChungLiew | 74634c8 | 2007-08-05 03:55:21 -0500 | [diff] [blame] | 134 | case 0: |
| 135 | gpio->par_uart = (GPIO_PAR_UART_TXD0 | GPIO_PAR_UART_RXD0); |
| 136 | break; |
| 137 | case 1: |
| 138 | gpio->par_uart = |
| 139 | (GPIO_PAR_UART_TXD1(3) | GPIO_PAR_UART_RXD1(3)); |
| 140 | break; |
| 141 | case 2: |
| 142 | gpio->par_timer &= 0x0F; |
| 143 | gpio->par_timer |= (GPIO_PAR_TIN3_URXD2 | GPIO_PAR_TIN2_UTXD2); |
| 144 | break; |
| 145 | } |
TsiChung Liew | 69b1757 | 2008-10-21 13:47:54 +0000 | [diff] [blame] | 146 | } |
| 147 | |
| 148 | #if defined(CONFIG_CMD_NET) |
| 149 | int fecpin_setclear(struct eth_device *dev, int setclear) |
| 150 | { |
| 151 | volatile gpio_t *gpio = (gpio_t *) MMAP_GPIO; |
| 152 | |
| 153 | if (setclear) { |
| 154 | gpio->par_fec |= GPIO_PAR_FEC_7W_FEC | GPIO_PAR_FEC_MII_FEC; |
| 155 | gpio->par_feci2c |= |
| 156 | GPIO_PAR_FECI2C_MDC_EMDC | GPIO_PAR_FECI2C_MDIO_EMDIO; |
| 157 | } else { |
| 158 | gpio->par_fec &= ~(GPIO_PAR_FEC_7W_FEC | GPIO_PAR_FEC_MII_FEC); |
| 159 | gpio->par_feci2c &= |
| 160 | ~(GPIO_PAR_FECI2C_MDC_EMDC | GPIO_PAR_FECI2C_MDIO_EMDIO); |
| 161 | } |
| 162 | return 0; |
TsiChungLiew | 74634c8 | 2007-08-05 03:55:21 -0500 | [diff] [blame] | 163 | } |
TsiChung Liew | 69b1757 | 2008-10-21 13:47:54 +0000 | [diff] [blame] | 164 | #endif |