mirror of
https://github.com/hardkernel/linux.git
synced 2026-06-08 03:40:35 +09:00
cpu_version: add cpu version for m8b
PD#141217: add cpu version for m8b Change-Id: I2d2fd64e5d27aa7c7887bc34adab058fc1a82e44 Signed-off-by: Jianxin Pan <jianxin.pan@amlogic.com>
This commit is contained in:
@@ -13418,6 +13418,7 @@ AMLOGIC CPU INFORMATION DRIVER
|
||||
M: Yun Cai <yun.cai@amlogic.com>
|
||||
F: drivers/amlogic/cpu_info/
|
||||
F: drivers/amlogic/cpu_version/
|
||||
F: drivers/amlogic/cpu_version/meson32_cpu.c
|
||||
|
||||
AMLOGIC MAILBOX DRIVER
|
||||
M: Yun Cai <yun.cai@amlogic.com>
|
||||
|
||||
@@ -114,7 +114,11 @@
|
||||
reg = <0xc8100000 0x100000>;
|
||||
};
|
||||
};
|
||||
|
||||
cpu_version{
|
||||
reg = <0xc1107d4c 4>,
|
||||
<0xc11081a8 4>,
|
||||
<0xd9040000 4>;
|
||||
};
|
||||
timer@c1109940 {
|
||||
compatible = "amlogic,meson6-timer";
|
||||
reg = <0xc1109940 0x18>;
|
||||
|
||||
@@ -48,6 +48,8 @@ CONFIG_AMLOGIC_USB=y
|
||||
CONFIG_AMLOGIC_USB_DWC_OTG_HCD=y
|
||||
CONFIG_AMLOGIC_USB_HOST_ELECT_TEST=y
|
||||
CONFIG_AMLOGIC_USBPHY=y
|
||||
CONFIG_AMLOGIC_CPU_VERSION=y
|
||||
CONFIG_AMLOGIC_M8B_MESON32_VERSION=y
|
||||
CONFIG_AMLOGIC_REG_ACCESS=y
|
||||
CONFIG_AMLOGIC_CLK=y
|
||||
# CONFIG_AMLOGIC_RESET is not set
|
||||
|
||||
@@ -15,4 +15,12 @@ config AMLOGIC_MESON64_VERSION
|
||||
cpu version driver
|
||||
.
|
||||
|
||||
config AMLOGIC_M8B_MESON32_VERSION
|
||||
bool "Amlogic M8b Meson32 cpu version"
|
||||
default n
|
||||
help
|
||||
say y to enable
|
||||
Amlogic M8b
|
||||
cpu version driver
|
||||
|
||||
endif
|
||||
|
||||
@@ -1 +1,2 @@
|
||||
obj-$(CONFIG_AMLOGIC_MESON64_VERSION) += meson64_cpu.o
|
||||
obj-$(CONFIG_AMLOGIC_M8B_MESON32_VERSION) += meson32_cpu.o
|
||||
99
drivers/amlogic/cpu_version/meson32_cpu.c
Normal file
99
drivers/amlogic/cpu_version/meson32_cpu.c
Normal file
@@ -0,0 +1,99 @@
|
||||
/*
|
||||
* drivers/amlogic/cpu_version/meson32_cpu.c
|
||||
*
|
||||
* Copyright (C) 2017 Amlogic, Inc. All rights reserved.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
|
||||
* more details.
|
||||
*
|
||||
*/
|
||||
|
||||
#include <linux/module.h>
|
||||
#include <linux/kernel.h>
|
||||
#include <linux/init.h>
|
||||
#include <linux/amlogic/cpu_version.h>
|
||||
#include <linux/printk.h>
|
||||
#include <linux/string.h>
|
||||
#include <linux/of_address.h>
|
||||
#include <linux/io.h>
|
||||
#include <linux/amlogic/iomap.h>
|
||||
|
||||
#ifdef CONFIG_MESON_TRUSTZONE
|
||||
#include <mach/meson-secure.h>
|
||||
#endif
|
||||
|
||||
#define IO_REGS_BASE 0xFE000000
|
||||
#define IO_BOOTROM_BASE (IO_REGS_BASE + 0x010000) /*64K*/
|
||||
|
||||
static int meson_cpu_version[MESON_CPU_VERSION_LVL_MAX+1];
|
||||
int __init meson_cpu_version_init(void)
|
||||
{
|
||||
unsigned int version, ver;
|
||||
struct device_node *cpu_version;
|
||||
void __iomem *assist_hw_rev0;
|
||||
void __iomem *assist_hw_rev1;
|
||||
void __iomem *assist_hw_rev2;
|
||||
#ifndef CONFIG_MESON_TRUSTZONE
|
||||
unsigned int *version_map;
|
||||
#endif
|
||||
|
||||
cpu_version = of_find_node_by_name(NULL, "cpu_version");
|
||||
if (!cpu_version) {
|
||||
pr_warn(" Not find cpu_version in dts. %s\n", __func__);
|
||||
return 0;
|
||||
}
|
||||
|
||||
assist_hw_rev0 = of_iomap(cpu_version, 0);
|
||||
assist_hw_rev1 = of_iomap(cpu_version, 1);
|
||||
assist_hw_rev2 = of_iomap(cpu_version, 2);
|
||||
|
||||
if (!assist_hw_rev0 || !assist_hw_rev1 || !assist_hw_rev2) {
|
||||
pr_warn("%s: iomap failed: %p %p %p\n", __func__,
|
||||
assist_hw_rev0, assist_hw_rev1, assist_hw_rev2);
|
||||
return 0;
|
||||
}
|
||||
|
||||
meson_cpu_version[MESON_CPU_VERSION_LVL_MAJOR] = readl(assist_hw_rev0);
|
||||
|
||||
#ifndef CONFIG_MESON_TRUSTZONE
|
||||
version_map = (unsigned int *)assist_hw_rev2;
|
||||
meson_cpu_version[MESON_CPU_VERSION_LVL_MISC] = version_map[1];
|
||||
#else
|
||||
meson_cpu_version[MESON_CPU_VERSION_LVL_MISC] = meson_read_socrev1();
|
||||
#endif
|
||||
|
||||
version = readl(assist_hw_rev1);
|
||||
switch (version) {
|
||||
case 0x11111111:
|
||||
ver = 0xA;
|
||||
break;
|
||||
default:
|
||||
ver = 0xB;
|
||||
break;
|
||||
}
|
||||
meson_cpu_version[MESON_CPU_VERSION_LVL_MINOR] = ver;
|
||||
pr_info("Meson chip version = Rev%X (%X:%X - %X:%X)\n", ver,
|
||||
meson_cpu_version[MESON_CPU_VERSION_LVL_MAJOR],
|
||||
meson_cpu_version[MESON_CPU_VERSION_LVL_MINOR],
|
||||
meson_cpu_version[MESON_CPU_VERSION_LVL_PACK],
|
||||
meson_cpu_version[MESON_CPU_VERSION_LVL_MISC]
|
||||
);
|
||||
return 0;
|
||||
}
|
||||
EXPORT_SYMBOL(meson_cpu_version_init);
|
||||
|
||||
int get_meson_cpu_version(int level)
|
||||
{
|
||||
if (level >= 0 && level <= MESON_CPU_VERSION_LVL_MAX)
|
||||
return meson_cpu_version[level];
|
||||
return 0;
|
||||
}
|
||||
EXPORT_SYMBOL(get_meson_cpu_version);
|
||||
early_initcall(meson_cpu_version_init);
|
||||
@@ -24,6 +24,7 @@
|
||||
#define MESON_CPU_MAJOR_ID_GXL 0x21
|
||||
#define MESON_CPU_MAJOR_ID_GXM 0x22
|
||||
#define MESON_CPU_MAJOR_ID_TXL 0x23
|
||||
#define MESON_CPU_MAJOR_ID_TXLX 0x24
|
||||
|
||||
#define MESON_CPU_VERSION_LVL_MAJOR 0
|
||||
#define MESON_CPU_VERSION_LVL_MINOR 1
|
||||
@@ -69,6 +70,11 @@ static inline bool package_id_is(unsigned int id)
|
||||
return get_cpu_package() == id;
|
||||
}
|
||||
|
||||
static inline bool is_meson_m8b_cpu(void)
|
||||
{
|
||||
return get_cpu_type() == MESON_CPU_MAJOR_ID_M8B;
|
||||
}
|
||||
|
||||
static inline bool is_meson_gxbb_cpu(void)
|
||||
{
|
||||
return get_cpu_type() == MESON_CPU_MAJOR_ID_GXBB;
|
||||
@@ -125,6 +131,11 @@ static inline bool is_meson_txl_cpu(void)
|
||||
return get_cpu_type() == MESON_CPU_MAJOR_ID_TXL;
|
||||
}
|
||||
|
||||
static inline bool is_meson_txlx_cpu(void)
|
||||
{
|
||||
return get_cpu_type() == MESON_CPU_MAJOR_ID_TXLX;
|
||||
}
|
||||
|
||||
static inline bool cpu_after_eq(unsigned int id)
|
||||
{
|
||||
return get_cpu_type() >= id;
|
||||
|
||||
@@ -57,11 +57,6 @@ static inline bool is_meson_mtvd_cpu(void)
|
||||
return get_cpu_type() == MESON_CPU_MAJOR_ID_MTVD;
|
||||
}
|
||||
|
||||
static inline bool is_meson_m8b_cpu(void)
|
||||
{
|
||||
return get_cpu_type() == MESON_CPU_MAJOR_ID_M8B;
|
||||
}
|
||||
|
||||
static inline bool is_meson_m8m2_cpu(void)
|
||||
{
|
||||
return get_cpu_type() == MESON_CPU_MAJOR_ID_M8M2;
|
||||
|
||||
Reference in New Issue
Block a user