Stefano Babic | a521a77 | 2010-01-20 18:19:32 +0100 | [diff] [blame] | 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> |
Stefano Babic | ac41d4d | 2010-03-05 17:54:37 +0100 | [diff] [blame] | 28 | #include <asm/arch/clock.h> |
Fabio Estevam | f231efb | 2011-10-13 05:34:59 +0000 | [diff] [blame] | 29 | #include <asm/arch/sys_proto.h> |
| 30 | |
Stefano Babic | a521a77 | 2010-01-20 18:19:32 +0100 | [diff] [blame] | 31 | #include <asm/errno.h> |
| 32 | #include <asm/io.h> |
| 33 | |
Liu Hui-R64343 | baa2d78 | 2011-01-03 22:27:35 +0000 | [diff] [blame] | 34 | #if !(defined(CONFIG_MX51) || defined(CONFIG_MX53)) |
Jason Liu | e7a7ed2 | 2010-10-18 11:09:26 +0800 | [diff] [blame] | 35 | #error "CPU_TYPE not defined" |
| 36 | #endif |
| 37 | |
Stefano Babic | a521a77 | 2010-01-20 18:19:32 +0100 | [diff] [blame] | 38 | u32 get_cpu_rev(void) |
| 39 | { |
Liu Hui-R64343 | baa2d78 | 2011-01-03 22:27:35 +0000 | [diff] [blame] | 40 | #ifdef CONFIG_MX51 |
| 41 | int system_rev = 0x51000; |
| 42 | #else |
| 43 | int system_rev = 0x53000; |
| 44 | #endif |
Jason Liu | e7a7ed2 | 2010-10-18 11:09:26 +0800 | [diff] [blame] | 45 | int reg = __raw_readl(ROM_SI_REV); |
Stefano Babic | a521a77 | 2010-01-20 18:19:32 +0100 | [diff] [blame] | 46 | |
Liu Hui-R64343 | baa2d78 | 2011-01-03 22:27:35 +0000 | [diff] [blame] | 47 | #if defined(CONFIG_MX51) |
Stefano Babic | a521a77 | 2010-01-20 18:19:32 +0100 | [diff] [blame] | 48 | switch (reg) { |
| 49 | case 0x02: |
Jason Liu | e7a7ed2 | 2010-10-18 11:09:26 +0800 | [diff] [blame] | 50 | system_rev |= CHIP_REV_1_1; |
Stefano Babic | a521a77 | 2010-01-20 18:19:32 +0100 | [diff] [blame] | 51 | break; |
| 52 | case 0x10: |
| 53 | if ((__raw_readl(GPIO1_BASE_ADDR + 0x0) & (0x1 << 22)) == 0) |
Jason Liu | e7a7ed2 | 2010-10-18 11:09:26 +0800 | [diff] [blame] | 54 | system_rev |= CHIP_REV_2_5; |
Stefano Babic | a521a77 | 2010-01-20 18:19:32 +0100 | [diff] [blame] | 55 | else |
Jason Liu | e7a7ed2 | 2010-10-18 11:09:26 +0800 | [diff] [blame] | 56 | system_rev |= CHIP_REV_2_0; |
Stefano Babic | a521a77 | 2010-01-20 18:19:32 +0100 | [diff] [blame] | 57 | break; |
| 58 | case 0x20: |
Jason Liu | e7a7ed2 | 2010-10-18 11:09:26 +0800 | [diff] [blame] | 59 | system_rev |= CHIP_REV_3_0; |
Stefano Babic | a521a77 | 2010-01-20 18:19:32 +0100 | [diff] [blame] | 60 | break; |
Liu Hui-R64343 | baa2d78 | 2011-01-03 22:27:35 +0000 | [diff] [blame] | 61 | default: |
| 62 | system_rev |= CHIP_REV_1_0; |
| 63 | break; |
| 64 | } |
| 65 | #else |
Fabio Estevam | 000f4d0 | 2011-04-26 10:50:15 +0000 | [diff] [blame] | 66 | if (reg < 0x20) |
Jason Liu | e7a7ed2 | 2010-10-18 11:09:26 +0800 | [diff] [blame] | 67 | system_rev |= CHIP_REV_1_0; |
Fabio Estevam | 000f4d0 | 2011-04-26 10:50:15 +0000 | [diff] [blame] | 68 | else |
| 69 | system_rev |= reg; |
Liu Hui-R64343 | baa2d78 | 2011-01-03 22:27:35 +0000 | [diff] [blame] | 70 | #endif |
Stefano Babic | a521a77 | 2010-01-20 18:19:32 +0100 | [diff] [blame] | 71 | return system_rev; |
| 72 | } |
| 73 | |
Benoît Thébaudeau | b8aaed3 | 2012-08-14 03:17:52 +0000 | [diff] [blame] | 74 | #ifndef CONFIG_SYS_DCACHE_OFF |
| 75 | void enable_caches(void) |
| 76 | { |
| 77 | /* Enable D-cache. I-cache is already enabled in start.S */ |
| 78 | dcache_enable(); |
| 79 | } |
| 80 | #endif |
| 81 | |
Stefano Babic | a521a77 | 2010-01-20 18:19:32 +0100 | [diff] [blame] | 82 | #if defined(CONFIG_FEC_MXC) |
Jason Liu | ce0e55e | 2012-01-31 02:07:29 +0000 | [diff] [blame] | 83 | void imx_get_mac_from_fuse(int dev_id, unsigned char *mac) |
Liu Hui-R64343 | 4df6619 | 2010-11-18 23:45:55 +0000 | [diff] [blame] | 84 | { |
| 85 | int i; |
| 86 | struct iim_regs *iim = (struct iim_regs *)IMX_IIM_BASE; |
| 87 | struct fuse_bank *bank = &iim->bank[1]; |
| 88 | struct fuse_bank1_regs *fuse = |
| 89 | (struct fuse_bank1_regs *)bank->fuse_regs; |
| 90 | |
| 91 | for (i = 0; i < 6; i++) |
| 92 | mac[i] = readl(&fuse->mac_addr[i]) & 0xff; |
| 93 | } |
| 94 | #endif |
Stefano Babic | a521a77 | 2010-01-20 18:19:32 +0100 | [diff] [blame] | 95 | |
Fabio Estevam | 88a22a2 | 2011-06-07 07:02:52 +0000 | [diff] [blame] | 96 | void set_chipselect_size(int const cs_size) |
| 97 | { |
| 98 | unsigned int reg; |
| 99 | struct iomuxc *iomuxc_regs = (struct iomuxc *)IOMUXC_BASE_ADDR; |
| 100 | reg = readl(&iomuxc_regs->gpr1); |
| 101 | |
| 102 | switch (cs_size) { |
| 103 | case CS0_128: |
| 104 | reg &= ~0x7; /* CS0=128MB, CS1=0, CS2=0, CS3=0 */ |
| 105 | reg |= 0x5; |
| 106 | break; |
| 107 | case CS0_64M_CS1_64M: |
| 108 | reg &= ~0x3F; /* CS0=64MB, CS1=64MB, CS2=0, CS3=0 */ |
| 109 | reg |= 0x1B; |
| 110 | break; |
| 111 | case CS0_64M_CS1_32M_CS2_32M: |
| 112 | reg &= ~0x1FF; /* CS0=64MB, CS1=32MB, CS2=32MB, CS3=0 */ |
| 113 | reg |= 0x4B; |
| 114 | break; |
| 115 | case CS0_32M_CS1_32M_CS2_32M_CS3_32M: |
| 116 | reg &= ~0xFFF; /* CS0=32MB, CS1=32MB, CS2=32MB, CS3=32MB */ |
| 117 | reg |= 0x249; |
| 118 | break; |
| 119 | default: |
| 120 | printf("Unknown chip select size: %d\n", cs_size); |
| 121 | break; |
| 122 | } |
| 123 | |
| 124 | writel(reg, &iomuxc_regs->gpr1); |
| 125 | } |