blob: 3f8c38c520decb16e9227dc6ae81af5510d93bc4 [file] [log] [blame]
Tom Rini10e47792018-05-06 17:58:06 -04001// SPDX-License-Identifier: GPL-2.0+
TsiChungLiew8999e6b2008-01-15 13:37:34 -06002/*
3 *
4 * (C) Copyright 2000-2003
5 * Wolfgang Denk, DENX Software Engineering, wd@denx.de.
6 *
Alison Wang027f76f2012-03-26 21:49:07 +00007 * (C) Copyright 2007, 2012 Freescale Semiconductor, Inc.
TsiChungLiew8999e6b2008-01-15 13:37:34 -06008 * TsiChung Liew (Tsi-Chung.Liew@freescale.com)
TsiChungLiew8999e6b2008-01-15 13:37:34 -06009 */
10
11#include <common.h>
12#include <MCD_dma.h>
Simon Glass1d91ba72019-11-14 12:57:37 -070013#include <cpu_func.h>
TsiChungLiew8999e6b2008-01-15 13:37:34 -060014#include <asm/immap.h>
Alison Wang027f76f2012-03-26 21:49:07 +000015#include <asm/io.h>
TsiChungLiew8999e6b2008-01-15 13:37:34 -060016
TsiChung Liew69b17572008-10-21 13:47:54 +000017#if defined(CONFIG_CMD_NET)
18#include <config.h>
19#include <net.h>
20#include <asm/fsl_mcdmafec.h>
21#endif
22
TsiChungLiew8999e6b2008-01-15 13:37:34 -060023/*
24 * Breath some life into the CPU...
25 *
26 * Set up the memory map,
27 * initialize a bunch of registers,
28 * initialize the UPM's
29 */
30void cpu_init_f(void)
31{
Alison Wang027f76f2012-03-26 21:49:07 +000032 gpio_t *gpio = (gpio_t *) MMAP_GPIO;
33 fbcs_t *fbcs = (fbcs_t *) MMAP_FBCS;
34 xlbarb_t *xlbarb = (xlbarb_t *) MMAP_XARB;
TsiChungLiew8999e6b2008-01-15 13:37:34 -060035
Alison Wang027f76f2012-03-26 21:49:07 +000036 out_be32(&xlbarb->adrto, 0x2000);
37 out_be32(&xlbarb->datto, 0x2500);
38 out_be32(&xlbarb->busto, 0x3000);
TsiChungLiew8999e6b2008-01-15 13:37:34 -060039
Alison Wang027f76f2012-03-26 21:49:07 +000040 out_be32(&xlbarb->cfg, XARB_CFG_AT | XARB_CFG_DT);
TsiChungLiew8999e6b2008-01-15 13:37:34 -060041
42 /* Master Priority Enable */
Alison Wang027f76f2012-03-26 21:49:07 +000043 out_be32(&xlbarb->prien, 0xff);
44 out_be32(&xlbarb->pri, 0);
TsiChungLiew8999e6b2008-01-15 13:37:34 -060045
Jean-Christophe PLAGNIOL-VILLARD03836942008-10-16 15:01:15 +020046#if (defined(CONFIG_SYS_CS0_BASE) && defined(CONFIG_SYS_CS0_MASK) && defined(CONFIG_SYS_CS0_CTRL))
Alison Wang027f76f2012-03-26 21:49:07 +000047 out_be32(&fbcs->csar0, CONFIG_SYS_CS0_BASE);
48 out_be32(&fbcs->cscr0, CONFIG_SYS_CS0_CTRL);
49 out_be32(&fbcs->csmr0, CONFIG_SYS_CS0_MASK);
TsiChungLiew8999e6b2008-01-15 13:37:34 -060050#endif
51
Jean-Christophe PLAGNIOL-VILLARD03836942008-10-16 15:01:15 +020052#if (defined(CONFIG_SYS_CS1_BASE) && defined(CONFIG_SYS_CS1_MASK) && defined(CONFIG_SYS_CS1_CTRL))
Alison Wang027f76f2012-03-26 21:49:07 +000053 out_be32(&fbcs->csar1, CONFIG_SYS_CS1_BASE);
54 out_be32(&fbcs->cscr1, CONFIG_SYS_CS1_CTRL);
55 out_be32(&fbcs->csmr1, CONFIG_SYS_CS1_MASK);
TsiChungLiew8999e6b2008-01-15 13:37:34 -060056#endif
57
Jean-Christophe PLAGNIOL-VILLARD03836942008-10-16 15:01:15 +020058#if (defined(CONFIG_SYS_CS2_BASE) && defined(CONFIG_SYS_CS2_MASK) && defined(CONFIG_SYS_CS2_CTRL))
Alison Wang027f76f2012-03-26 21:49:07 +000059 out_be32(&fbcs->csar2, CONFIG_SYS_CS2_BASE);
60 out_be32(&fbcs->cscr2, CONFIG_SYS_CS2_CTRL);
61 out_be32(&fbcs->csmr2, CONFIG_SYS_CS2_MASK);
TsiChungLiew8999e6b2008-01-15 13:37:34 -060062#endif
63
Jean-Christophe PLAGNIOL-VILLARD03836942008-10-16 15:01:15 +020064#if (defined(CONFIG_SYS_CS3_BASE) && defined(CONFIG_SYS_CS3_MASK) && defined(CONFIG_SYS_CS3_CTRL))
Alison Wang027f76f2012-03-26 21:49:07 +000065 out_be32(&fbcs->csar3, CONFIG_SYS_CS3_BASE);
66 out_be32(&fbcs->cscr3, CONFIG_SYS_CS3_CTRL);
67 out_be32(&fbcs->csmr3, CONFIG_SYS_CS3_MASK);
TsiChungLiew8999e6b2008-01-15 13:37:34 -060068#endif
69
Jean-Christophe PLAGNIOL-VILLARD03836942008-10-16 15:01:15 +020070#if (defined(CONFIG_SYS_CS4_BASE) && defined(CONFIG_SYS_CS4_MASK) && defined(CONFIG_SYS_CS4_CTRL))
Alison Wang027f76f2012-03-26 21:49:07 +000071 out_be32(&fbcs->csar4, CONFIG_SYS_CS4_BASE);
72 out_be32(&fbcs->cscr4, CONFIG_SYS_CS4_CTRL);
73 out_be32(&fbcs->csmr4, CONFIG_SYS_CS4_MASK);
TsiChungLiew8999e6b2008-01-15 13:37:34 -060074#endif
75
Jean-Christophe PLAGNIOL-VILLARD03836942008-10-16 15:01:15 +020076#if (defined(CONFIG_SYS_CS5_BASE) && defined(CONFIG_SYS_CS5_MASK) && defined(CONFIG_SYS_CS5_CTRL))
Alison Wang027f76f2012-03-26 21:49:07 +000077 out_be32(&fbcs->csar5, CONFIG_SYS_CS5_BASE);
78 out_be32(&fbcs->cscr5, CONFIG_SYS_CS5_CTRL);
79 out_be32(&fbcs->csmr5, CONFIG_SYS_CS5_MASK);
TsiChungLiew8999e6b2008-01-15 13:37:34 -060080#endif
81
Heiko Schocherf2850742012-10-24 13:48:22 +020082#ifdef CONFIG_SYS_I2C_FSL
Alison Wang027f76f2012-03-26 21:49:07 +000083 out_be16(&gpio->par_feci2cirq,
84 GPIO_PAR_FECI2CIRQ_SCL | GPIO_PAR_FECI2CIRQ_SDA);
TsiChungLiew8999e6b2008-01-15 13:37:34 -060085#endif
86
87 icache_enable();
88}
89
90/*
91 * initialize higher level parts of CPU like timers
92 */
93int cpu_init_r(void)
94{
95#if defined(CONFIG_CMD_NET) && defined(CONFIG_FSLDMAFEC)
96 MCD_initDma((dmaRegs *) (MMAP_MCDMA), (void *)(MMAP_SRAM + 512),
97 MCD_RELOC_TASKS);
98#endif
99 return (0);
100}
101
TsiChung Liewf9556a72010-03-09 19:17:52 -0600102void uart_port_conf(int port)
TsiChungLiew8999e6b2008-01-15 13:37:34 -0600103{
Alison Wang027f76f2012-03-26 21:49:07 +0000104 gpio_t *gpio = (gpio_t *) MMAP_GPIO;
105 u8 *pscsicr = (u8 *) (CONFIG_SYS_UART_BASE + 0x40);
TsiChungLiew8999e6b2008-01-15 13:37:34 -0600106
107 /* Setup Ports: */
TsiChung Liewf9556a72010-03-09 19:17:52 -0600108 switch (port) {
TsiChungLiew8999e6b2008-01-15 13:37:34 -0600109 case 0:
Alison Wang027f76f2012-03-26 21:49:07 +0000110 out_8(&gpio->par_psc0, GPIO_PAR_PSC0_TXD0 | GPIO_PAR_PSC0_RXD0);
TsiChungLiew8999e6b2008-01-15 13:37:34 -0600111 break;
112 case 1:
Alison Wang027f76f2012-03-26 21:49:07 +0000113 out_8(&gpio->par_psc1, GPIO_PAR_PSC1_TXD1 | GPIO_PAR_PSC1_RXD1);
TsiChungLiew8999e6b2008-01-15 13:37:34 -0600114 break;
115 case 2:
Alison Wang027f76f2012-03-26 21:49:07 +0000116 out_8(&gpio->par_psc2, GPIO_PAR_PSC2_TXD2 | GPIO_PAR_PSC2_RXD2);
TsiChungLiew8999e6b2008-01-15 13:37:34 -0600117 break;
118 case 3:
Alison Wang027f76f2012-03-26 21:49:07 +0000119 out_8(&gpio->par_psc3, GPIO_PAR_PSC3_TXD3 | GPIO_PAR_PSC3_RXD3);
TsiChungLiew8999e6b2008-01-15 13:37:34 -0600120 break;
121 }
122
Alison Wang027f76f2012-03-26 21:49:07 +0000123 clrbits_8(pscsicr, 0x07);
TsiChungLiew8999e6b2008-01-15 13:37:34 -0600124}
TsiChung Liew69b17572008-10-21 13:47:54 +0000125
126#if defined(CONFIG_CMD_NET)
127int fecpin_setclear(struct eth_device *dev, int setclear)
128{
Alison Wang027f76f2012-03-26 21:49:07 +0000129 gpio_t *gpio = (gpio_t *) MMAP_GPIO;
TsiChung Liew69b17572008-10-21 13:47:54 +0000130 struct fec_info_dma *info = (struct fec_info_dma *)dev->priv;
131
132 if (setclear) {
133 if (info->iobase == CONFIG_SYS_FEC0_IOBASE)
Alison Wang027f76f2012-03-26 21:49:07 +0000134 setbits_be16(&gpio->par_feci2cirq, 0xf000);
TsiChung Liew69b17572008-10-21 13:47:54 +0000135 else
Alison Wang027f76f2012-03-26 21:49:07 +0000136 setbits_be16(&gpio->par_feci2cirq, 0x0fc0);
TsiChung Liew69b17572008-10-21 13:47:54 +0000137 } else {
138 if (info->iobase == CONFIG_SYS_FEC0_IOBASE)
Alison Wang027f76f2012-03-26 21:49:07 +0000139 clrbits_be16(&gpio->par_feci2cirq, 0xf000);
TsiChung Liew69b17572008-10-21 13:47:54 +0000140 else
Alison Wang027f76f2012-03-26 21:49:07 +0000141 clrbits_be16(&gpio->par_feci2cirq, 0x0fc0);
TsiChung Liew69b17572008-10-21 13:47:54 +0000142 }
143 return 0;
144}
145#endif