]> git.kernelconcepts.de Git - karo-tx-uboot.git/blob - arch/arm/cpu/armv7/mx5/soc.c
Unified codebase for TX28, TX48, TX51, TX53
[karo-tx-uboot.git] / arch / arm / cpu / armv7 / mx5 / soc.c
1 /*
2  * (C) Copyright 2007
3  * Sascha Hauer, Pengutronix
4  *
5  * (C) Copyright 2009 Freescale Semiconductor, Inc.
6  *
7  * See file CREDITS for list of people who contributed to this
8  * project.
9  *
10  * This program is free software; you can redistribute it and/or
11  * modify it under the terms of the GNU General Public License as
12  * published by the Free Software Foundation; either version 2 of
13  * the License, or (at your option) any later version.
14  *
15  * This program is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18  * GNU General Public License for more details.
19  *
20  * You should have received a copy of the GNU General Public License
21  * along with this program; if not, write to the Free Software
22  * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
23  * MA 02111-1307 USA
24  */
25
26 #include <common.h>
27 #include <asm/arch/imx-regs.h>
28 #include <asm/arch/clock.h>
29 #include <asm/arch/sys_proto.h>
30
31 #include <asm/errno.h>
32 #include <asm/io.h>
33
34 #if !(defined(CONFIG_MX51) || defined(CONFIG_MX53))
35 #error "CPU_TYPE not defined"
36 #endif
37
38 #ifdef CONFIG_HW_WATCHDOG
39 #define wdog_base       ((void *)WDOG1_BASE_ADDR)
40 #define WDOG_WCR        0x00
41 #define WCR_WDE         (1 << 2)
42 #define WDOG_WSR        0x02
43
44 void hw_watchdog_reset(void)
45 {
46         if (readw(wdog_base + WDOG_WCR) & WCR_WDE) {
47                 static u16 toggle = 0xaaaa;
48
49                 writew(toggle, wdog_base + WDOG_WSR);
50                 toggle ^= 0xffff;
51         }
52 }
53 #endif
54
55 u32 get_cpu_rev(void)
56 {
57 #ifdef CONFIG_MX51
58         int system_rev = 0x51000;
59 #else
60         int system_rev = 0x53000;
61 #endif
62         int reg = __raw_readl(ROM_SI_REV);
63
64 #if defined(CONFIG_MX51)
65         switch (reg) {
66         case 0x02:
67                 system_rev |= CHIP_REV_1_1;
68                 break;
69         case 0x10:
70                 if ((__raw_readl(GPIO1_BASE_ADDR + 0x0) & (0x1 << 22)) == 0)
71                         system_rev |= CHIP_REV_2_5;
72                 else
73                         system_rev |= CHIP_REV_2_0;
74                 break;
75         case 0x20:
76                 system_rev |= CHIP_REV_3_0;
77                 break;
78         default:
79                 system_rev |= CHIP_REV_1_0;
80                 break;
81         }
82 #else
83         if (reg < 0x20)
84                 system_rev |= CHIP_REV_1_0;
85         else
86                 system_rev |= reg;
87 #endif
88         return system_rev;
89 }
90
91 #if defined(CONFIG_FEC_MXC)
92 static void __imx_get_mac_from_fuse(int dev_id, unsigned char *mac)
93 {
94         int i;
95         struct iim_regs *iim = (struct iim_regs *)IMX_IIM_BASE;
96         struct fuse_bank *bank = &iim->bank[1];
97         struct fuse_bank1_regs *fuse =
98                         (struct fuse_bank1_regs *)bank->fuse_regs;
99
100         for (i = 0; i < 6; i++)
101                 mac[i] = readl(&fuse->mac_addr[i]) & 0xff;
102 }
103
104 void imx_get_mac_from_fuse(int dev_id, unsigned char *mac)
105         __attribute__((weak, alias("__imx_get_mac_from_fuse")));
106
107 #endif
108
109 void set_chipselect_size(int const cs_size)
110 {
111         unsigned int reg;
112         struct iomuxc *iomuxc_regs = (struct iomuxc *)IOMUXC_BASE_ADDR;
113         reg = readl(&iomuxc_regs->gpr1);
114
115         switch (cs_size) {
116         case CS0_128:
117                 reg &= ~0x7;    /* CS0=128MB, CS1=0, CS2=0, CS3=0 */
118                 reg |= 0x5;
119                 break;
120         case CS0_64M_CS1_64M:
121                 reg &= ~0x3F;   /* CS0=64MB, CS1=64MB, CS2=0, CS3=0 */
122                 reg |= 0x1B;
123                 break;
124         case CS0_64M_CS1_32M_CS2_32M:
125                 reg &= ~0x1FF;  /* CS0=64MB, CS1=32MB, CS2=32MB, CS3=0 */
126                 reg |= 0x4B;
127                 break;
128         case CS0_32M_CS1_32M_CS2_32M_CS3_32M:
129                 reg &= ~0xFFF;  /* CS0=32MB, CS1=32MB, CS2=32MB, CS3=32MB */
130                 reg |= 0x249;
131                 break;
132         default:
133                 printf("Unknown chip select size: %d\n", cs_size);
134                 break;
135         }
136
137         writel(reg, &iomuxc_regs->gpr1);
138 }
139
140 void enable_caches(void)
141 {
142 #ifndef CONFIG_SYS_DCACHE_OFF
143         /* Enable D-cache. I-cache is already enabled in start.S */
144         dcache_enable();
145 #endif
146 }