diff --git a/MAINTAINERS b/MAINTAINERS index b67edfa38951..be178956edcd 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -13418,6 +13418,7 @@ AMLOGIC CPU INFORMATION DRIVER M: Yun Cai F: drivers/amlogic/cpu_info/ F: drivers/amlogic/cpu_version/ +F: drivers/amlogic/cpu_version/meson32_cpu.c AMLOGIC MAILBOX DRIVER M: Yun Cai diff --git a/arch/arm/boot/dts/amlogic/meson8b.dtsi b/arch/arm/boot/dts/amlogic/meson8b.dtsi index a845fad3c5d7..23d0ba92068f 100644 --- a/arch/arm/boot/dts/amlogic/meson8b.dtsi +++ b/arch/arm/boot/dts/amlogic/meson8b.dtsi @@ -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>; diff --git a/arch/arm/configs/meson32_defconfig b/arch/arm/configs/meson32_defconfig index 9d460f6b2bb6..b623088be77c 100644 --- a/arch/arm/configs/meson32_defconfig +++ b/arch/arm/configs/meson32_defconfig @@ -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 diff --git a/drivers/amlogic/cpu_version/Kconfig b/drivers/amlogic/cpu_version/Kconfig index 153474db3cff..16089dc7cd61 100644 --- a/drivers/amlogic/cpu_version/Kconfig +++ b/drivers/amlogic/cpu_version/Kconfig @@ -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 diff --git a/drivers/amlogic/cpu_version/Makefile b/drivers/amlogic/cpu_version/Makefile index a33637582d00..f6d020df0af2 100644 --- a/drivers/amlogic/cpu_version/Makefile +++ b/drivers/amlogic/cpu_version/Makefile @@ -1 +1,2 @@ obj-$(CONFIG_AMLOGIC_MESON64_VERSION) += meson64_cpu.o +obj-$(CONFIG_AMLOGIC_M8B_MESON32_VERSION) += meson32_cpu.o \ No newline at end of file diff --git a/drivers/amlogic/cpu_version/meson32_cpu.c b/drivers/amlogic/cpu_version/meson32_cpu.c new file mode 100644 index 000000000000..ac567cc0cc62 --- /dev/null +++ b/drivers/amlogic/cpu_version/meson32_cpu.c @@ -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 +#include +#include +#include +#include +#include +#include +#include +#include + +#ifdef CONFIG_MESON_TRUSTZONE +#include +#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); diff --git a/include/linux/amlogic/cpu_version.h b/include/linux/amlogic/cpu_version.h index 476926abf655..5c35a0f1bd2c 100644 --- a/include/linux/amlogic/cpu_version.h +++ b/include/linux/amlogic/cpu_version.h @@ -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; diff --git a/include/linux/amlogic/media/old_cpu_version.h b/include/linux/amlogic/media/old_cpu_version.h index 86e8fe7d56c2..8fd7a027fc82 100644 --- a/include/linux/amlogic/media/old_cpu_version.h +++ b/include/linux/amlogic/media/old_cpu_version.h @@ -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;