misc: Introduce simplified xiaomi hardware identification driver
Change-Id: I6ae7a76dcc687fe8fa9edb5c119182d2c32462be
This commit is contained in:
parent
d0ab7719af
commit
a01318f976
4 changed files with 115 additions and 0 deletions
|
|
@ -524,6 +524,12 @@ config HISI_HIKEY_USB
|
|||
help
|
||||
If you say yes here you get support for usb functionality of HiSilicon Hikey Platform.
|
||||
|
||||
config MI_HARDWARE_ID
|
||||
tristate "Xiaomi hardware identification module"
|
||||
default n
|
||||
help
|
||||
This adds support for mi hwid.
|
||||
|
||||
source "drivers/misc/c2port/Kconfig"
|
||||
source "drivers/misc/eeprom/Kconfig"
|
||||
source "drivers/misc/cb710/Kconfig"
|
||||
|
|
|
|||
|
|
@ -65,3 +65,4 @@ qseecom-mod-$(CONFIG_COMPAT) += compat_qseecom.o
|
|||
obj-$(CONFIG_PROFILER) += profiler.o
|
||||
obj-$(CONFIG_WIGIG_SENSING_SPI) += wigig_sensing.o
|
||||
obj-$(CONFIG_HISI_HIKEY_USB) += hisi_hikey_usb.o
|
||||
obj-$(CONFIG_MI_HARDWARE_ID) += hwid.o
|
||||
|
|
|
|||
63
drivers/misc/hwid.c
Normal file
63
drivers/misc/hwid.c
Normal file
|
|
@ -0,0 +1,63 @@
|
|||
/*
|
||||
* Copyright (C) 2021 XiaoMi, Inc.
|
||||
* 2022 The LineageOS Project
|
||||
*
|
||||
* SPDX-License-Identifier: GPL-2.0
|
||||
*/
|
||||
|
||||
#include <linux/hwid.h>
|
||||
#include <linux/module.h>
|
||||
|
||||
#define HW_MAJOR_VERSION_SHIFT 16
|
||||
#define HW_MINOR_VERSION_SHIFT 0
|
||||
#define HW_COUNTRY_VERSION_SHIFT 20
|
||||
#define HW_BUILD_VERSION_SHIFT 16
|
||||
#define HW_MAJOR_VERSION_MASK 0xFFFF0000
|
||||
#define HW_MINOR_VERSION_MASK 0x0000FFFF
|
||||
#define HW_COUNTRY_VERSION_MASK 0xFFF00000
|
||||
#define HW_BUILD_VERSION_MASK 0x000F0000
|
||||
|
||||
static uint project;
|
||||
module_param(project, uint, 0444);
|
||||
|
||||
static uint hwid_value;
|
||||
module_param(hwid_value, uint, 0444);
|
||||
|
||||
uint32_t get_hw_version_platform(void)
|
||||
{
|
||||
return project;
|
||||
}
|
||||
EXPORT_SYMBOL(get_hw_version_platform);
|
||||
|
||||
uint32_t get_hw_id_value(void)
|
||||
{
|
||||
return hwid_value;
|
||||
}
|
||||
EXPORT_SYMBOL(get_hw_id_value);
|
||||
|
||||
uint32_t get_hw_country_version(void)
|
||||
{
|
||||
return (hwid_value & HW_COUNTRY_VERSION_MASK) >> HW_COUNTRY_VERSION_SHIFT;
|
||||
}
|
||||
EXPORT_SYMBOL(get_hw_country_version);
|
||||
|
||||
uint32_t get_hw_version_major(void)
|
||||
{
|
||||
return (hwid_value & HW_MAJOR_VERSION_MASK) >> HW_MAJOR_VERSION_SHIFT;
|
||||
}
|
||||
EXPORT_SYMBOL(get_hw_version_major);
|
||||
|
||||
uint32_t get_hw_version_minor(void)
|
||||
{
|
||||
return (hwid_value & HW_MINOR_VERSION_MASK) >> HW_MINOR_VERSION_SHIFT;
|
||||
}
|
||||
EXPORT_SYMBOL(get_hw_version_minor);
|
||||
|
||||
uint32_t get_hw_version_build(void)
|
||||
{
|
||||
return (hwid_value & HW_BUILD_VERSION_MASK) >> HW_BUILD_VERSION_SHIFT;
|
||||
}
|
||||
EXPORT_SYMBOL(get_hw_version_build);
|
||||
|
||||
MODULE_AUTHOR("weixiaotian1@xiaomi.com");
|
||||
MODULE_LICENSE("GPL v2");
|
||||
45
include/linux/hwid.h
Normal file
45
include/linux/hwid.h
Normal file
|
|
@ -0,0 +1,45 @@
|
|||
/*
|
||||
* Copyright (C) 2021 XiaoMi, Inc.
|
||||
* 2022 The LineageOS Project
|
||||
*
|
||||
* SPDX-License-Identifier: GPL-2.0
|
||||
*/
|
||||
|
||||
#ifndef __HWID_H__
|
||||
#define __HWID_H__
|
||||
|
||||
#include <linux/types.h>
|
||||
|
||||
#define HARDWARE_PROJECT_UNKNOWN 0
|
||||
#define HARDWARE_PROJECT_J18 1
|
||||
#define HARDWARE_PROJECT_K1 2
|
||||
#define HARDWARE_PROJECT_K2 3
|
||||
#define HARDWARE_PROJECT_K11 4
|
||||
#define HARDWARE_PROJECT_K1A 5
|
||||
#define HARDWARE_PROJECT_K9 6
|
||||
#define HARDWARE_PROJECT_K8 7
|
||||
#define HARDWARE_PROJECT_K3S 8
|
||||
#define HARDWARE_PROJECT_J18S 9
|
||||
#define HARDWARE_PROJECT_K9D 10
|
||||
#define HARDWARE_PROJECT_K9B 11
|
||||
#define HARDWARE_PROJECT_K9E 12
|
||||
#define HARDWARE_PROJECT_L9 13
|
||||
#define HARDWARE_PROJECT_M20 14
|
||||
|
||||
typedef enum {
|
||||
CountryCN = 0x00,
|
||||
CountryGlobal = 0x01,
|
||||
CountryIndia = 0x02,
|
||||
CountryJapan = 0x03,
|
||||
INVALID = 0x04,
|
||||
CountryIDMax = 0x7FFFFFFF
|
||||
} CountryType;
|
||||
|
||||
uint32_t get_hw_version_platform(void);
|
||||
uint32_t get_hw_id_value(void);
|
||||
uint32_t get_hw_country_version(void);
|
||||
uint32_t get_hw_version_major(void);
|
||||
uint32_t get_hw_version_minor(void);
|
||||
uint32_t get_hw_version_build(void);
|
||||
|
||||
#endif /* __HWID_H__ */
|
||||
Loading…
Add table
Reference in a new issue