Tom Rini | 10e4779 | 2018-05-06 17:58:06 -0400 | [diff] [blame] | 1 | // SPDX-License-Identifier: GPL-2.0+ |
TsiChungLiew | 8999e6b | 2008-01-15 13:37:34 -0600 | [diff] [blame] | 2 | /* |
| 3 | * |
| 4 | * (C) Copyright 2000-2003 |
| 5 | * Wolfgang Denk, DENX Software Engineering, wd@denx.de. |
| 6 | * |
Alison Wang | 027f76f | 2012-03-26 21:49:07 +0000 | [diff] [blame] | 7 | * (C) Copyright 2007, 2012 Freescale Semiconductor, Inc. |
TsiChungLiew | 8999e6b | 2008-01-15 13:37:34 -0600 | [diff] [blame] | 8 | * TsiChung Liew (Tsi-Chung.Liew@freescale.com) |
TsiChungLiew | 8999e6b | 2008-01-15 13:37:34 -0600 | [diff] [blame] | 9 | */ |
| 10 | |
| 11 | #include <common.h> |
| 12 | #include <MCD_dma.h> |
| 13 | #include <asm/immap.h> |
Alison Wang | 027f76f | 2012-03-26 21:49:07 +0000 | [diff] [blame] | 14 | #include <asm/io.h> |
TsiChungLiew | 8999e6b | 2008-01-15 13:37:34 -0600 | [diff] [blame] | 15 | |
TsiChung Liew | 69b1757 | 2008-10-21 13:47:54 +0000 | [diff] [blame] | 16 | #if defined(CONFIG_CMD_NET) |
| 17 | #include <config.h> |
| 18 | #include <net.h> |
| 19 | #include <asm/fsl_mcdmafec.h> |
| 20 | #endif |
| 21 | |
TsiChungLiew | 8999e6b | 2008-01-15 13:37:34 -0600 | [diff] [blame] | 22 | /* |
| 23 | * Breath some life into the CPU... |
| 24 | * |
| 25 | * Set up the memory map, |
| 26 | * initialize a bunch of registers, |
| 27 | * initialize the UPM's |
| 28 | */ |
| 29 | void cpu_init_f(void) |
| 30 | { |
Alison Wang | 027f76f | 2012-03-26 21:49:07 +0000 | [diff] [blame] | 31 | gpio_t *gpio = (gpio_t *) MMAP_GPIO; |
| 32 | fbcs_t *fbcs = (fbcs_t *) MMAP_FBCS; |
| 33 | xlbarb_t *xlbarb = (xlbarb_t *) MMAP_XARB; |
TsiChungLiew | 8999e6b | 2008-01-15 13:37:34 -0600 | [diff] [blame] | 34 | |
Alison Wang | 027f76f | 2012-03-26 21:49:07 +0000 | [diff] [blame] | 35 | out_be32(&xlbarb->adrto, 0x2000); |
| 36 | out_be32(&xlbarb->datto, 0x2500); |
| 37 | out_be32(&xlbarb->busto, 0x3000); |
TsiChungLiew | 8999e6b | 2008-01-15 13:37:34 -0600 | [diff] [blame] | 38 | |
Alison Wang | 027f76f | 2012-03-26 21:49:07 +0000 | [diff] [blame] | 39 | out_be32(&xlbarb->cfg, XARB_CFG_AT | XARB_CFG_DT); |
TsiChungLiew | 8999e6b | 2008-01-15 13:37:34 -0600 | [diff] [blame] | 40 | |
| 41 | /* Master Priority Enable */ |
Alison Wang | 027f76f | 2012-03-26 21:49:07 +0000 | [diff] [blame] | 42 | out_be32(&xlbarb->prien, 0xff); |
| 43 | out_be32(&xlbarb->pri, 0); |
TsiChungLiew | 8999e6b | 2008-01-15 13:37:34 -0600 | [diff] [blame] | 44 | |
Jean-Christophe PLAGNIOL-VILLARD | 0383694 | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 45 | #if (defined(CONFIG_SYS_CS0_BASE) && defined(CONFIG_SYS_CS0_MASK) && defined(CONFIG_SYS_CS0_CTRL)) |
Alison Wang | 027f76f | 2012-03-26 21:49:07 +0000 | [diff] [blame] | 46 | out_be32(&fbcs->csar0, CONFIG_SYS_CS0_BASE); |
| 47 | out_be32(&fbcs->cscr0, CONFIG_SYS_CS0_CTRL); |
| 48 | out_be32(&fbcs->csmr0, CONFIG_SYS_CS0_MASK); |
TsiChungLiew | 8999e6b | 2008-01-15 13:37:34 -0600 | [diff] [blame] | 49 | #endif |
| 50 | |
Jean-Christophe PLAGNIOL-VILLARD | 0383694 | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 51 | #if (defined(CONFIG_SYS_CS1_BASE) && defined(CONFIG_SYS_CS1_MASK) && defined(CONFIG_SYS_CS1_CTRL)) |
Alison Wang | 027f76f | 2012-03-26 21:49:07 +0000 | [diff] [blame] | 52 | out_be32(&fbcs->csar1, CONFIG_SYS_CS1_BASE); |
| 53 | out_be32(&fbcs->cscr1, CONFIG_SYS_CS1_CTRL); |
| 54 | out_be32(&fbcs->csmr1, CONFIG_SYS_CS1_MASK); |
TsiChungLiew | 8999e6b | 2008-01-15 13:37:34 -0600 | [diff] [blame] | 55 | #endif |
| 56 | |
Jean-Christophe PLAGNIOL-VILLARD | 0383694 | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 57 | #if (defined(CONFIG_SYS_CS2_BASE) && defined(CONFIG_SYS_CS2_MASK) && defined(CONFIG_SYS_CS2_CTRL)) |
Alison Wang | 027f76f | 2012-03-26 21:49:07 +0000 | [diff] [blame] | 58 | out_be32(&fbcs->csar2, CONFIG_SYS_CS2_BASE); |
| 59 | out_be32(&fbcs->cscr2, CONFIG_SYS_CS2_CTRL); |
| 60 | out_be32(&fbcs->csmr2, CONFIG_SYS_CS2_MASK); |
TsiChungLiew | 8999e6b | 2008-01-15 13:37:34 -0600 | [diff] [blame] | 61 | #endif |
| 62 | |
Jean-Christophe PLAGNIOL-VILLARD | 0383694 | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 63 | #if (defined(CONFIG_SYS_CS3_BASE) && defined(CONFIG_SYS_CS3_MASK) && defined(CONFIG_SYS_CS3_CTRL)) |
Alison Wang | 027f76f | 2012-03-26 21:49:07 +0000 | [diff] [blame] | 64 | out_be32(&fbcs->csar3, CONFIG_SYS_CS3_BASE); |
| 65 | out_be32(&fbcs->cscr3, CONFIG_SYS_CS3_CTRL); |
| 66 | out_be32(&fbcs->csmr3, CONFIG_SYS_CS3_MASK); |
TsiChungLiew | 8999e6b | 2008-01-15 13:37:34 -0600 | [diff] [blame] | 67 | #endif |
| 68 | |
Jean-Christophe PLAGNIOL-VILLARD | 0383694 | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 69 | #if (defined(CONFIG_SYS_CS4_BASE) && defined(CONFIG_SYS_CS4_MASK) && defined(CONFIG_SYS_CS4_CTRL)) |
Alison Wang | 027f76f | 2012-03-26 21:49:07 +0000 | [diff] [blame] | 70 | out_be32(&fbcs->csar4, CONFIG_SYS_CS4_BASE); |
| 71 | out_be32(&fbcs->cscr4, CONFIG_SYS_CS4_CTRL); |
| 72 | out_be32(&fbcs->csmr4, CONFIG_SYS_CS4_MASK); |
TsiChungLiew | 8999e6b | 2008-01-15 13:37:34 -0600 | [diff] [blame] | 73 | #endif |
| 74 | |
Jean-Christophe PLAGNIOL-VILLARD | 0383694 | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 75 | #if (defined(CONFIG_SYS_CS5_BASE) && defined(CONFIG_SYS_CS5_MASK) && defined(CONFIG_SYS_CS5_CTRL)) |
Alison Wang | 027f76f | 2012-03-26 21:49:07 +0000 | [diff] [blame] | 76 | out_be32(&fbcs->csar5, CONFIG_SYS_CS5_BASE); |
| 77 | out_be32(&fbcs->cscr5, CONFIG_SYS_CS5_CTRL); |
| 78 | out_be32(&fbcs->csmr5, CONFIG_SYS_CS5_MASK); |
TsiChungLiew | 8999e6b | 2008-01-15 13:37:34 -0600 | [diff] [blame] | 79 | #endif |
| 80 | |
Heiko Schocher | f285074 | 2012-10-24 13:48:22 +0200 | [diff] [blame] | 81 | #ifdef CONFIG_SYS_I2C_FSL |
Alison Wang | 027f76f | 2012-03-26 21:49:07 +0000 | [diff] [blame] | 82 | out_be16(&gpio->par_feci2cirq, |
| 83 | GPIO_PAR_FECI2CIRQ_SCL | GPIO_PAR_FECI2CIRQ_SDA); |
TsiChungLiew | 8999e6b | 2008-01-15 13:37:34 -0600 | [diff] [blame] | 84 | #endif |
| 85 | |
| 86 | icache_enable(); |
| 87 | } |
| 88 | |
| 89 | /* |
| 90 | * initialize higher level parts of CPU like timers |
| 91 | */ |
| 92 | int cpu_init_r(void) |
| 93 | { |
| 94 | #if defined(CONFIG_CMD_NET) && defined(CONFIG_FSLDMAFEC) |
| 95 | MCD_initDma((dmaRegs *) (MMAP_MCDMA), (void *)(MMAP_SRAM + 512), |
| 96 | MCD_RELOC_TASKS); |
| 97 | #endif |
| 98 | return (0); |
| 99 | } |
| 100 | |
TsiChung Liew | f9556a7 | 2010-03-09 19:17:52 -0600 | [diff] [blame] | 101 | void uart_port_conf(int port) |
TsiChungLiew | 8999e6b | 2008-01-15 13:37:34 -0600 | [diff] [blame] | 102 | { |
Alison Wang | 027f76f | 2012-03-26 21:49:07 +0000 | [diff] [blame] | 103 | gpio_t *gpio = (gpio_t *) MMAP_GPIO; |
| 104 | u8 *pscsicr = (u8 *) (CONFIG_SYS_UART_BASE + 0x40); |
TsiChungLiew | 8999e6b | 2008-01-15 13:37:34 -0600 | [diff] [blame] | 105 | |
| 106 | /* Setup Ports: */ |
TsiChung Liew | f9556a7 | 2010-03-09 19:17:52 -0600 | [diff] [blame] | 107 | switch (port) { |
TsiChungLiew | 8999e6b | 2008-01-15 13:37:34 -0600 | [diff] [blame] | 108 | case 0: |
Alison Wang | 027f76f | 2012-03-26 21:49:07 +0000 | [diff] [blame] | 109 | out_8(&gpio->par_psc0, GPIO_PAR_PSC0_TXD0 | GPIO_PAR_PSC0_RXD0); |
TsiChungLiew | 8999e6b | 2008-01-15 13:37:34 -0600 | [diff] [blame] | 110 | break; |
| 111 | case 1: |
Alison Wang | 027f76f | 2012-03-26 21:49:07 +0000 | [diff] [blame] | 112 | out_8(&gpio->par_psc1, GPIO_PAR_PSC1_TXD1 | GPIO_PAR_PSC1_RXD1); |
TsiChungLiew | 8999e6b | 2008-01-15 13:37:34 -0600 | [diff] [blame] | 113 | break; |
| 114 | case 2: |
Alison Wang | 027f76f | 2012-03-26 21:49:07 +0000 | [diff] [blame] | 115 | out_8(&gpio->par_psc2, GPIO_PAR_PSC2_TXD2 | GPIO_PAR_PSC2_RXD2); |
TsiChungLiew | 8999e6b | 2008-01-15 13:37:34 -0600 | [diff] [blame] | 116 | break; |
| 117 | case 3: |
Alison Wang | 027f76f | 2012-03-26 21:49:07 +0000 | [diff] [blame] | 118 | out_8(&gpio->par_psc3, GPIO_PAR_PSC3_TXD3 | GPIO_PAR_PSC3_RXD3); |
TsiChungLiew | 8999e6b | 2008-01-15 13:37:34 -0600 | [diff] [blame] | 119 | break; |
| 120 | } |
| 121 | |
Alison Wang | 027f76f | 2012-03-26 21:49:07 +0000 | [diff] [blame] | 122 | clrbits_8(pscsicr, 0x07); |
TsiChungLiew | 8999e6b | 2008-01-15 13:37:34 -0600 | [diff] [blame] | 123 | } |
TsiChung Liew | 69b1757 | 2008-10-21 13:47:54 +0000 | [diff] [blame] | 124 | |
| 125 | #if defined(CONFIG_CMD_NET) |
| 126 | int fecpin_setclear(struct eth_device *dev, int setclear) |
| 127 | { |
Alison Wang | 027f76f | 2012-03-26 21:49:07 +0000 | [diff] [blame] | 128 | gpio_t *gpio = (gpio_t *) MMAP_GPIO; |
TsiChung Liew | 69b1757 | 2008-10-21 13:47:54 +0000 | [diff] [blame] | 129 | struct fec_info_dma *info = (struct fec_info_dma *)dev->priv; |
| 130 | |
| 131 | if (setclear) { |
| 132 | if (info->iobase == CONFIG_SYS_FEC0_IOBASE) |
Alison Wang | 027f76f | 2012-03-26 21:49:07 +0000 | [diff] [blame] | 133 | setbits_be16(&gpio->par_feci2cirq, 0xf000); |
TsiChung Liew | 69b1757 | 2008-10-21 13:47:54 +0000 | [diff] [blame] | 134 | else |
Alison Wang | 027f76f | 2012-03-26 21:49:07 +0000 | [diff] [blame] | 135 | setbits_be16(&gpio->par_feci2cirq, 0x0fc0); |
TsiChung Liew | 69b1757 | 2008-10-21 13:47:54 +0000 | [diff] [blame] | 136 | } else { |
| 137 | if (info->iobase == CONFIG_SYS_FEC0_IOBASE) |
Alison Wang | 027f76f | 2012-03-26 21:49:07 +0000 | [diff] [blame] | 138 | clrbits_be16(&gpio->par_feci2cirq, 0xf000); |
TsiChung Liew | 69b1757 | 2008-10-21 13:47:54 +0000 | [diff] [blame] | 139 | else |
Alison Wang | 027f76f | 2012-03-26 21:49:07 +0000 | [diff] [blame] | 140 | clrbits_be16(&gpio->par_feci2cirq, 0x0fc0); |
TsiChung Liew | 69b1757 | 2008-10-21 13:47:54 +0000 | [diff] [blame] | 141 | } |
| 142 | return 0; |
| 143 | } |
| 144 | #endif |