blob: 8779384c0ab7e2fa3aaf6bd0e34a1296b2e2cb27 [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>
Angelo Durgehello8ff47f72019-11-15 23:54:16 +010020#include <asm/fec.h>
TsiChung Liew69b17572008-10-21 13:47:54 +000021#include <asm/fsl_mcdmafec.h>
22#endif
23
TsiChungLiew8999e6b2008-01-15 13:37:34 -060024/*
25 * Breath some life into the CPU...
26 *
27 * Set up the memory map,
28 * initialize a bunch of registers,
29 * initialize the UPM's
30 */
31void cpu_init_f(void)
32{
Alison Wang027f76f2012-03-26 21:49:07 +000033 gpio_t *gpio = (gpio_t *) MMAP_GPIO;
34 fbcs_t *fbcs = (fbcs_t *) MMAP_FBCS;
35 xlbarb_t *xlbarb = (xlbarb_t *) MMAP_XARB;
TsiChungLiew8999e6b2008-01-15 13:37:34 -060036
Alison Wang027f76f2012-03-26 21:49:07 +000037 out_be32(&xlbarb->adrto, 0x2000);
38 out_be32(&xlbarb->datto, 0x2500);
39 out_be32(&xlbarb->busto, 0x3000);
TsiChungLiew8999e6b2008-01-15 13:37:34 -060040
Alison Wang027f76f2012-03-26 21:49:07 +000041 out_be32(&xlbarb->cfg, XARB_CFG_AT | XARB_CFG_DT);
TsiChungLiew8999e6b2008-01-15 13:37:34 -060042
43 /* Master Priority Enable */
Alison Wang027f76f2012-03-26 21:49:07 +000044 out_be32(&xlbarb->prien, 0xff);
45 out_be32(&xlbarb->pri, 0);
TsiChungLiew8999e6b2008-01-15 13:37:34 -060046
Jean-Christophe PLAGNIOL-VILLARD03836942008-10-16 15:01:15 +020047#if (defined(CONFIG_SYS_CS0_BASE) && defined(CONFIG_SYS_CS0_MASK) && defined(CONFIG_SYS_CS0_CTRL))
Alison Wang027f76f2012-03-26 21:49:07 +000048 out_be32(&fbcs->csar0, CONFIG_SYS_CS0_BASE);
49 out_be32(&fbcs->cscr0, CONFIG_SYS_CS0_CTRL);
50 out_be32(&fbcs->csmr0, CONFIG_SYS_CS0_MASK);
TsiChungLiew8999e6b2008-01-15 13:37:34 -060051#endif
52
Jean-Christophe PLAGNIOL-VILLARD03836942008-10-16 15:01:15 +020053#if (defined(CONFIG_SYS_CS1_BASE) && defined(CONFIG_SYS_CS1_MASK) && defined(CONFIG_SYS_CS1_CTRL))
Alison Wang027f76f2012-03-26 21:49:07 +000054 out_be32(&fbcs->csar1, CONFIG_SYS_CS1_BASE);
55 out_be32(&fbcs->cscr1, CONFIG_SYS_CS1_CTRL);
56 out_be32(&fbcs->csmr1, CONFIG_SYS_CS1_MASK);
TsiChungLiew8999e6b2008-01-15 13:37:34 -060057#endif
58
Jean-Christophe PLAGNIOL-VILLARD03836942008-10-16 15:01:15 +020059#if (defined(CONFIG_SYS_CS2_BASE) && defined(CONFIG_SYS_CS2_MASK) && defined(CONFIG_SYS_CS2_CTRL))
Alison Wang027f76f2012-03-26 21:49:07 +000060 out_be32(&fbcs->csar2, CONFIG_SYS_CS2_BASE);
61 out_be32(&fbcs->cscr2, CONFIG_SYS_CS2_CTRL);
62 out_be32(&fbcs->csmr2, CONFIG_SYS_CS2_MASK);
TsiChungLiew8999e6b2008-01-15 13:37:34 -060063#endif
64
Jean-Christophe PLAGNIOL-VILLARD03836942008-10-16 15:01:15 +020065#if (defined(CONFIG_SYS_CS3_BASE) && defined(CONFIG_SYS_CS3_MASK) && defined(CONFIG_SYS_CS3_CTRL))
Alison Wang027f76f2012-03-26 21:49:07 +000066 out_be32(&fbcs->csar3, CONFIG_SYS_CS3_BASE);
67 out_be32(&fbcs->cscr3, CONFIG_SYS_CS3_CTRL);
68 out_be32(&fbcs->csmr3, CONFIG_SYS_CS3_MASK);
TsiChungLiew8999e6b2008-01-15 13:37:34 -060069#endif
70
Jean-Christophe PLAGNIOL-VILLARD03836942008-10-16 15:01:15 +020071#if (defined(CONFIG_SYS_CS4_BASE) && defined(CONFIG_SYS_CS4_MASK) && defined(CONFIG_SYS_CS4_CTRL))
Alison Wang027f76f2012-03-26 21:49:07 +000072 out_be32(&fbcs->csar4, CONFIG_SYS_CS4_BASE);
73 out_be32(&fbcs->cscr4, CONFIG_SYS_CS4_CTRL);
74 out_be32(&fbcs->csmr4, CONFIG_SYS_CS4_MASK);
TsiChungLiew8999e6b2008-01-15 13:37:34 -060075#endif
76
Jean-Christophe PLAGNIOL-VILLARD03836942008-10-16 15:01:15 +020077#if (defined(CONFIG_SYS_CS5_BASE) && defined(CONFIG_SYS_CS5_MASK) && defined(CONFIG_SYS_CS5_CTRL))
Alison Wang027f76f2012-03-26 21:49:07 +000078 out_be32(&fbcs->csar5, CONFIG_SYS_CS5_BASE);
79 out_be32(&fbcs->cscr5, CONFIG_SYS_CS5_CTRL);
80 out_be32(&fbcs->csmr5, CONFIG_SYS_CS5_MASK);
TsiChungLiew8999e6b2008-01-15 13:37:34 -060081#endif
82
Heiko Schocherf2850742012-10-24 13:48:22 +020083#ifdef CONFIG_SYS_I2C_FSL
Alison Wang027f76f2012-03-26 21:49:07 +000084 out_be16(&gpio->par_feci2cirq,
85 GPIO_PAR_FECI2CIRQ_SCL | GPIO_PAR_FECI2CIRQ_SDA);
TsiChungLiew8999e6b2008-01-15 13:37:34 -060086#endif
87
88 icache_enable();
89}
90
91/*
92 * initialize higher level parts of CPU like timers
93 */
94int cpu_init_r(void)
95{
96#if defined(CONFIG_CMD_NET) && defined(CONFIG_FSLDMAFEC)
97 MCD_initDma((dmaRegs *) (MMAP_MCDMA), (void *)(MMAP_SRAM + 512),
98 MCD_RELOC_TASKS);
99#endif
100 return (0);
101}
102
TsiChung Liewf9556a72010-03-09 19:17:52 -0600103void uart_port_conf(int port)
TsiChungLiew8999e6b2008-01-15 13:37:34 -0600104{
Alison Wang027f76f2012-03-26 21:49:07 +0000105 gpio_t *gpio = (gpio_t *) MMAP_GPIO;
106 u8 *pscsicr = (u8 *) (CONFIG_SYS_UART_BASE + 0x40);
TsiChungLiew8999e6b2008-01-15 13:37:34 -0600107
108 /* Setup Ports: */
TsiChung Liewf9556a72010-03-09 19:17:52 -0600109 switch (port) {
TsiChungLiew8999e6b2008-01-15 13:37:34 -0600110 case 0:
Alison Wang027f76f2012-03-26 21:49:07 +0000111 out_8(&gpio->par_psc0, GPIO_PAR_PSC0_TXD0 | GPIO_PAR_PSC0_RXD0);
TsiChungLiew8999e6b2008-01-15 13:37:34 -0600112 break;
113 case 1:
Alison Wang027f76f2012-03-26 21:49:07 +0000114 out_8(&gpio->par_psc1, GPIO_PAR_PSC1_TXD1 | GPIO_PAR_PSC1_RXD1);
TsiChungLiew8999e6b2008-01-15 13:37:34 -0600115 break;
116 case 2:
Alison Wang027f76f2012-03-26 21:49:07 +0000117 out_8(&gpio->par_psc2, GPIO_PAR_PSC2_TXD2 | GPIO_PAR_PSC2_RXD2);
TsiChungLiew8999e6b2008-01-15 13:37:34 -0600118 break;
119 case 3:
Alison Wang027f76f2012-03-26 21:49:07 +0000120 out_8(&gpio->par_psc3, GPIO_PAR_PSC3_TXD3 | GPIO_PAR_PSC3_RXD3);
TsiChungLiew8999e6b2008-01-15 13:37:34 -0600121 break;
122 }
123
Alison Wang027f76f2012-03-26 21:49:07 +0000124 clrbits_8(pscsicr, 0x07);
TsiChungLiew8999e6b2008-01-15 13:37:34 -0600125}
TsiChung Liew69b17572008-10-21 13:47:54 +0000126
127#if defined(CONFIG_CMD_NET)
Angelo Durgehello8ff47f72019-11-15 23:54:16 +0100128int fecpin_setclear(fec_info_t *info, int setclear)
TsiChung Liew69b17572008-10-21 13:47:54 +0000129{
Alison Wang027f76f2012-03-26 21:49:07 +0000130 gpio_t *gpio = (gpio_t *) MMAP_GPIO;
Angelo Durgehello8ff47f72019-11-15 23:54:16 +0100131 u32 fec0_base;
132
133 if (fec_get_base_addr(0, &fec0_base))
134 return -1;
TsiChung Liew69b17572008-10-21 13:47:54 +0000135
136 if (setclear) {
Angelo Durgehello8ff47f72019-11-15 23:54:16 +0100137 if (info->iobase == fec0_base)
Alison Wang027f76f2012-03-26 21:49:07 +0000138 setbits_be16(&gpio->par_feci2cirq, 0xf000);
TsiChung Liew69b17572008-10-21 13:47:54 +0000139 else
Alison Wang027f76f2012-03-26 21:49:07 +0000140 setbits_be16(&gpio->par_feci2cirq, 0x0fc0);
TsiChung Liew69b17572008-10-21 13:47:54 +0000141 } else {
Angelo Durgehello8ff47f72019-11-15 23:54:16 +0100142 if (info->iobase == fec0_base)
Alison Wang027f76f2012-03-26 21:49:07 +0000143 clrbits_be16(&gpio->par_feci2cirq, 0xf000);
TsiChung Liew69b17572008-10-21 13:47:54 +0000144 else
Alison Wang027f76f2012-03-26 21:49:07 +0000145 clrbits_be16(&gpio->par_feci2cirq, 0x0fc0);
TsiChung Liew69b17572008-10-21 13:47:54 +0000146 }
147 return 0;
148}
149#endif