| .. | .. |
|---|
| 1 | +// SPDX-License-Identifier: GPL-2.0-or-later |
|---|
| 1 | 2 | /* |
|---|
| 2 | 3 | * Copyright 2007 Freescale Semiconductor, Inc. All Rights Reserved. |
|---|
| 3 | 4 | * Copyright 2008 Juergen Beisert, kernel@pengutronix.de |
|---|
| 4 | | - * |
|---|
| 5 | | - * This program is free software; you can redistribute it and/or |
|---|
| 6 | | - * modify it under the terms of the GNU General Public License |
|---|
| 7 | | - * as published by the Free Software Foundation; either version 2 |
|---|
| 8 | | - * of the License, or (at your option) any later version. |
|---|
| 9 | | - * This program is distributed in the hope that it will be useful, |
|---|
| 10 | | - * but WITHOUT ANY WARRANTY; without even the implied warranty of |
|---|
| 11 | | - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|---|
| 12 | | - * GNU General Public License for more details. |
|---|
| 13 | | - * |
|---|
| 14 | | - * You should have received a copy of the GNU General Public License |
|---|
| 15 | | - * along with this program; if not, write to the Free Software |
|---|
| 16 | | - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, |
|---|
| 17 | | - * MA 02110-1301, USA. |
|---|
| 18 | 5 | */ |
|---|
| 19 | 6 | |
|---|
| 20 | 7 | /* |
|---|
| .. | .. |
|---|
| 22 | 9 | */ |
|---|
| 23 | 10 | |
|---|
| 24 | 11 | #include <linux/io.h> |
|---|
| 12 | +#include <linux/of_address.h> |
|---|
| 25 | 13 | #include <linux/module.h> |
|---|
| 26 | 14 | |
|---|
| 27 | 15 | #include "hardware.h" |
|---|
| .. | .. |
|---|
| 30 | 18 | static int mx27_cpu_partnumber; |
|---|
| 31 | 19 | |
|---|
| 32 | 20 | #define SYS_CHIP_ID 0x00 /* The offset of CHIP ID register */ |
|---|
| 21 | +#define SYSCTRL_OFFSET 0x800 /* Offset from CCM base address */ |
|---|
| 33 | 22 | |
|---|
| 34 | 23 | static int mx27_read_cpu_rev(void) |
|---|
| 35 | 24 | { |
|---|
| 25 | + void __iomem *ccm_base; |
|---|
| 26 | + struct device_node *np; |
|---|
| 36 | 27 | u32 val; |
|---|
| 28 | + |
|---|
| 29 | + np = of_find_compatible_node(NULL, NULL, "fsl,imx27-ccm"); |
|---|
| 30 | + ccm_base = of_iomap(np, 0); |
|---|
| 31 | + BUG_ON(!ccm_base); |
|---|
| 37 | 32 | /* |
|---|
| 38 | 33 | * now we have access to the IO registers. As we need |
|---|
| 39 | 34 | * the silicon revision very early we read it here to |
|---|
| 40 | 35 | * avoid any further hooks |
|---|
| 41 | 36 | */ |
|---|
| 42 | | - val = imx_readl(MX27_IO_ADDRESS(MX27_SYSCTRL_BASE_ADDR + SYS_CHIP_ID)); |
|---|
| 37 | + val = imx_readl(ccm_base + SYSCTRL_OFFSET + SYS_CHIP_ID); |
|---|
| 43 | 38 | |
|---|
| 44 | 39 | mx27_cpu_partnumber = (int)((val >> 12) & 0xFFFF); |
|---|
| 45 | 40 | |
|---|