3 * (C) Copyright 2000-2003
4 * Wolfgang Denk, DENX Software Engineering, wd@denx.de.
6 * (C) Copyright 2004-2007 Freescale Semiconductor, Inc.
7 * TsiChung Liew (Tsi-Chung.Liew@freescale.com)
9 * See file CREDITS for list of people who contributed to this
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.
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.
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,
30 #include <asm/immap.h>
33 #if defined(CONFIG_CMD_NET)
40 * Breath some life into the CPU...
42 * Set up the memory map,
43 * initialize a bunch of registers,
44 * initialize the UPM's
48 volatile scm1_t *scm1 = (scm1_t *) MMAP_SCM1;
49 volatile gpio_t *gpio = (gpio_t *) MMAP_GPIO;
50 volatile fbcs_t *fbcs = (fbcs_t *) MMAP_FBCS;
52 scm1->mpr = 0x77777777;
63 GPIO_PAR_BE_BE3_BE3 | GPIO_PAR_BE_BE2_BE2 | GPIO_PAR_BE_BE1_BE1 |
66 GPIO_PAR_FBCTL_OE | GPIO_PAR_FBCTL_TA_TA | GPIO_PAR_FBCTL_RW_RW |
69 #if !defined(CONFIG_CF_SBF)
70 #if (defined(CONFIG_SYS_CS0_BASE) && defined(CONFIG_SYS_CS0_MASK) && defined(CONFIG_SYS_CS0_CTRL))
71 fbcs->csar0 = CONFIG_SYS_CS0_BASE;
72 fbcs->cscr0 = CONFIG_SYS_CS0_CTRL;
73 fbcs->csmr0 = CONFIG_SYS_CS0_MASK;
77 #if (defined(CONFIG_SYS_CS1_BASE) && defined(CONFIG_SYS_CS1_MASK) && defined(CONFIG_SYS_CS1_CTRL))
78 /* Latch chipselect */
79 fbcs->csar1 = CONFIG_SYS_CS1_BASE;
80 fbcs->cscr1 = CONFIG_SYS_CS1_CTRL;
81 fbcs->csmr1 = CONFIG_SYS_CS1_MASK;
84 #if (defined(CONFIG_SYS_CS2_BASE) && defined(CONFIG_SYS_CS2_MASK) && defined(CONFIG_SYS_CS2_CTRL))
85 fbcs->csar2 = CONFIG_SYS_CS2_BASE;
86 fbcs->cscr2 = CONFIG_SYS_CS2_CTRL;
87 fbcs->csmr2 = CONFIG_SYS_CS2_MASK;
90 #if (defined(CONFIG_SYS_CS3_BASE) && defined(CONFIG_SYS_CS3_MASK) && defined(CONFIG_SYS_CS3_CTRL))
91 fbcs->csar3 = CONFIG_SYS_CS3_BASE;
92 fbcs->cscr3 = CONFIG_SYS_CS3_CTRL;
93 fbcs->csmr3 = CONFIG_SYS_CS3_MASK;
96 #if (defined(CONFIG_SYS_CS4_BASE) && defined(CONFIG_SYS_CS4_MASK) && defined(CONFIG_SYS_CS4_CTRL))
97 fbcs->csar4 = CONFIG_SYS_CS4_BASE;
98 fbcs->cscr4 = CONFIG_SYS_CS4_CTRL;
99 fbcs->csmr4 = CONFIG_SYS_CS4_MASK;
102 #if (defined(CONFIG_SYS_CS5_BASE) && defined(CONFIG_SYS_CS5_MASK) && defined(CONFIG_SYS_CS5_CTRL))
103 fbcs->csar5 = CONFIG_SYS_CS5_BASE;
104 fbcs->cscr5 = CONFIG_SYS_CS5_CTRL;
105 fbcs->csmr5 = CONFIG_SYS_CS5_MASK;
108 #ifdef CONFIG_FSL_I2C
109 gpio->par_feci2c = GPIO_PAR_FECI2C_SCL_SCL | GPIO_PAR_FECI2C_SDA_SDA;
116 * initialize higher level parts of CPU like timers
121 volatile rtc_t *rtc = (volatile rtc_t *)(CONFIG_SYS_MCFRTC_BASE);
122 volatile rtcex_t *rtcex = (volatile rtcex_t *)&rtc->extended;
124 rtcex->gocu = (CONFIG_SYS_RTC_OSCILLATOR >> 16) & 0xFFFF;
125 rtcex->gocl = CONFIG_SYS_RTC_OSCILLATOR & 0xFFFF;
131 void uart_port_conf(void)
133 volatile gpio_t *gpio = (gpio_t *) MMAP_GPIO;
136 switch (CONFIG_SYS_UART_PORT) {
139 (GPIO_PAR_UART_U0TXD_U0TXD | GPIO_PAR_UART_U0RXD_U0RXD);
143 (GPIO_PAR_UART_U1TXD_U1TXD | GPIO_PAR_UART_U1RXD_U1RXD);
148 #if defined(CONFIG_CMD_NET)
149 int fecpin_setclear(struct eth_device *dev, int setclear)
151 volatile gpio_t *gpio = (gpio_t *) MMAP_GPIO;
152 struct fec_info_s *info = (struct fec_info_s *)dev->priv;
156 (GPIO_PAR_FECI2C_MDC0_MDC0 | GPIO_PAR_FECI2C_MDIO0_MDIO0);
158 if (info->iobase == CONFIG_SYS_FEC0_IOBASE)
159 gpio->par_fec |= GPIO_PAR_FEC_FEC0_RMII_GPIO;
161 gpio->par_fec |= GPIO_PAR_FEC_FEC1_RMII_ATA;
164 ~(GPIO_PAR_FECI2C_MDC0_MDC0 | GPIO_PAR_FECI2C_MDIO0_MDIO0);
166 if (info->iobase == CONFIG_SYS_FEC0_IOBASE)
167 gpio->par_fec &= GPIO_PAR_FEC_FEC0_MASK;
169 gpio->par_fec &= GPIO_PAR_FEC_FEC1_MASK;
175 #ifdef CONFIG_CF_DSPI
176 void cfspi_port_conf(void)
178 volatile gpio_t *gpio = (gpio_t *) MMAP_GPIO;
180 gpio->par_dspi = GPIO_PAR_DSPI_SIN_SIN | GPIO_PAR_DSPI_SOUT_SOUT |
181 GPIO_PAR_DSPI_SCK_SCK;
184 int cfspi_claim_bus(uint bus, uint cs)
186 volatile dspi_t *dspi = (dspi_t *) MMAP_DSPI;
187 volatile gpio_t *gpio = (gpio_t *) MMAP_GPIO;
189 if ((dspi->sr & DSPI_SR_TXRXS) != DSPI_SR_TXRXS)
192 /* Clear FIFO and resume transfer */
193 dspi->mcr &= ~(DSPI_MCR_CTXF | DSPI_MCR_CRXF);
197 gpio->par_dspi &= ~GPIO_PAR_DSPI_PCS0_PCS0;
198 gpio->par_dspi |= GPIO_PAR_DSPI_PCS0_PCS0;
201 gpio->par_dspi &= ~GPIO_PAR_DSPI_PCS1_PCS1;
202 gpio->par_dspi |= GPIO_PAR_DSPI_PCS1_PCS1;
205 gpio->par_dspi &= ~GPIO_PAR_DSPI_PCS2_PCS2;
206 gpio->par_dspi |= GPIO_PAR_DSPI_PCS2_PCS2;
209 gpio->par_dspi &= ~GPIO_PAR_DSPI_PCS5_PCS5;
210 gpio->par_dspi |= GPIO_PAR_DSPI_PCS5_PCS5;
217 void cfspi_release_bus(uint bus, uint cs)
219 volatile dspi_t *dspi = (dspi_t *) MMAP_DSPI;
220 volatile gpio_t *gpio = (gpio_t *) MMAP_GPIO;
222 dspi->mcr &= ~(DSPI_MCR_CTXF | DSPI_MCR_CRXF); /* Clear FIFO */
226 gpio->par_dspi &= ~GPIO_PAR_DSPI_PCS0_PCS0;
229 gpio->par_dspi &= ~GPIO_PAR_DSPI_PCS1_PCS1;
232 gpio->par_dspi &= ~GPIO_PAR_DSPI_PCS2_PCS2;
235 gpio->par_dspi &= ~GPIO_PAR_DSPI_PCS5_PCS5;