drivers: misc: Import useless NothingTech drivers
* in case some blobs require these sysfs nodes Change-Id: I5aea4b78eb381e1e2dfeabb7ace31d3c2a623bf3
This commit is contained in:
committed by
Wiktor Rudzki
parent
2edb023319
commit
1d1293e51d
@@ -524,6 +524,21 @@ config HISI_HIKEY_USB
|
||||
help
|
||||
If you say yes here you get support for usb functionality of HiSilicon Hikey Platform.
|
||||
|
||||
config NT_HWID
|
||||
bool "NT Hardware ID Driver"
|
||||
help
|
||||
NT Hardware ID Driver.
|
||||
|
||||
config NT_SECURE_STATE
|
||||
bool "NT Secure State Driver"
|
||||
help
|
||||
NT Secure State Driver.
|
||||
|
||||
config NT_SLOT_STATE
|
||||
bool "NT SLOT State Driver"
|
||||
help
|
||||
NT SLOT State Driver.
|
||||
|
||||
source "drivers/misc/c2port/Kconfig"
|
||||
source "drivers/misc/eeprom/Kconfig"
|
||||
source "drivers/misc/cb710/Kconfig"
|
||||
|
||||
@@ -65,3 +65,6 @@ 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_NT_HWID) += hardware_id.o
|
||||
obj-$(CONFIG_NT_SECURE_STATE) += secure_state.o
|
||||
obj-$(CONFIG_NT_SLOT_STATE) += slot_status.o
|
||||
|
||||
125
drivers/misc/hardware_id.c
Normal file
125
drivers/misc/hardware_id.c
Normal file
@@ -0,0 +1,125 @@
|
||||
#include <linux/kernel.h>
|
||||
#include <linux/module.h>
|
||||
#include <linux/init.h>
|
||||
#include <linux/gpio.h>
|
||||
#include <linux/kobject.h>
|
||||
#include <linux/device.h>
|
||||
#include <linux/platform_device.h>
|
||||
#include <linux/sysfs.h>
|
||||
#include <linux/pm.h>
|
||||
|
||||
#include <linux/err.h>
|
||||
#include <linux/input.h>
|
||||
#include <linux/jiffies.h>
|
||||
|
||||
#include <linux/of_gpio.h>
|
||||
|
||||
#include <linux/types.h>
|
||||
#include <linux/proc_fs.h>
|
||||
#include <linux/seq_file.h>
|
||||
|
||||
/*HWID | GPIO19 | GPIO21*/
|
||||
/* T0 | 0 | 0 */
|
||||
/* EVT | 0 | 1 */
|
||||
/* DVT | 1 | 0 */
|
||||
/* PVT | 1 | 1 */
|
||||
|
||||
/*id1: GPIO19*/
|
||||
/*id2: GPIO21*/
|
||||
|
||||
static char *hw_ver[] = {"T0","EVT","DVT","PVT"};
|
||||
static int ver_gpioflag = 0;
|
||||
|
||||
static int hwid_show(struct seq_file *m, void *v)
|
||||
{
|
||||
seq_printf(m, "%s\n", hw_ver[ver_gpioflag]);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int hwid_open(struct inode *inode, struct file *file)
|
||||
{
|
||||
return single_open(file, hwid_show, inode->i_private);
|
||||
}
|
||||
|
||||
static const struct file_operations hwid_fops = {
|
||||
.open = hwid_open,
|
||||
.read = seq_read,
|
||||
};
|
||||
|
||||
static int create_hwid_proc_file(void)
|
||||
{
|
||||
struct proc_dir_entry *dir;
|
||||
|
||||
dir = proc_create("hwid", 0440, NULL, &hwid_fops);
|
||||
if (!dir) {
|
||||
pr_err("Unable to create /proc/hwid");
|
||||
return -1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int hwid_probe(struct platform_device *pdev)
|
||||
{
|
||||
int ret;
|
||||
int id1;
|
||||
int id2;
|
||||
int id1_val;
|
||||
int id2_val;
|
||||
|
||||
enum of_gpio_flags flags ;
|
||||
|
||||
printk(KERN_EMERG "enter hwid_probe\n");
|
||||
|
||||
id1 = of_get_named_gpio_flags(pdev->dev.of_node, "gpio_id1", 0, &flags);
|
||||
|
||||
ret = gpio_direction_input(id1);
|
||||
if (ret)
|
||||
{
|
||||
pr_err("set gpio id1 failed\n");
|
||||
}
|
||||
|
||||
id1_val = gpio_get_value(id1);
|
||||
|
||||
id2 = of_get_named_gpio_flags(pdev->dev.of_node, "gpio_id2", 0, &flags);
|
||||
|
||||
ret = gpio_direction_input(id2);
|
||||
if (ret)
|
||||
{
|
||||
pr_err("set gpio id2 failed\n");
|
||||
}
|
||||
|
||||
id2_val = gpio_get_value(id2);
|
||||
|
||||
ver_gpioflag = (id1_val << 1) | (id2_val);
|
||||
|
||||
printk(KERN_INFO"%s ver_gpioflag is %d\n", __func__,ver_gpioflag);
|
||||
|
||||
/* create proc for hardware id */
|
||||
create_hwid_proc_file();
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static const struct of_device_id hwid_of_match[] = {
|
||||
{ .compatible = "nt,hwid", },
|
||||
{ },
|
||||
};
|
||||
|
||||
MODULE_DEVICE_TABLE(of, hwid_of_match);
|
||||
static struct platform_driver hwid_driver = {
|
||||
.probe = hwid_probe,
|
||||
.driver = {
|
||||
.name = "nt-hwid",
|
||||
.of_match_table = hwid_of_match,
|
||||
}
|
||||
};
|
||||
|
||||
static int __init hwid_init(void)
|
||||
{
|
||||
printk(KERN_EMERG"%s enter.....\n", __func__);
|
||||
return platform_driver_register(&hwid_driver);
|
||||
}
|
||||
|
||||
module_init(hwid_init);
|
||||
MODULE_DESCRIPTION("hardware id function");
|
||||
59
drivers/misc/secure_state.c
Normal file
59
drivers/misc/secure_state.c
Normal file
@@ -0,0 +1,59 @@
|
||||
#include <linux/kernel.h>
|
||||
#include <linux/module.h>
|
||||
#include <linux/slab.h>
|
||||
#include <linux/interrupt.h>
|
||||
#include <linux/delay.h>
|
||||
#include <linux/input.h>
|
||||
#include <linux/signal.h>
|
||||
#include <linux/sched.h>
|
||||
#include <linux/gpio.h>
|
||||
#include <linux/uaccess.h>
|
||||
#include <linux/cdev.h>
|
||||
#include <linux/device.h>
|
||||
#include <linux/platform_device.h>
|
||||
#include <linux/proc_fs.h>
|
||||
#include <linux/seq_file.h>
|
||||
|
||||
static int secure_state = 0;
|
||||
|
||||
static int secure_state_show(struct seq_file *m, void *v)
|
||||
{
|
||||
seq_printf(m, "%d\n",secure_state);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int secure_state_open(struct inode *inode, struct file *file)
|
||||
{
|
||||
return single_open(file, secure_state_show, inode->i_private);
|
||||
}
|
||||
|
||||
static const struct file_operations secure_state_fops = {
|
||||
.open = secure_state_open,
|
||||
.read = seq_read,
|
||||
.llseek = seq_lseek,
|
||||
.release = single_release,
|
||||
};
|
||||
|
||||
static int __init init_secure_state(void)
|
||||
{
|
||||
struct proc_dir_entry *dir;
|
||||
dir = proc_create("secure_state", 0444, NULL, &secure_state_fops);
|
||||
if (!dir) {
|
||||
pr_alert("Now in %s. proc_create.dir = %p\n", __func__, dir);
|
||||
return -1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int __init setup_secure_state(char *str)
|
||||
{
|
||||
int id;
|
||||
if (get_option(&str, &id)) {
|
||||
secure_state = id;
|
||||
return 0;
|
||||
}
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
early_param("is_secure_fuse", setup_secure_state);
|
||||
module_init(init_secure_state);
|
||||
125
drivers/misc/slot_status.c
Executable file
125
drivers/misc/slot_status.c
Executable file
@@ -0,0 +1,125 @@
|
||||
#include <linux/kernel.h>
|
||||
#include <linux/module.h>
|
||||
#include <linux/init.h>
|
||||
#include <linux/gpio.h>
|
||||
#include <linux/device.h>
|
||||
#include <linux/of_gpio.h>
|
||||
#include <linux/platform_device.h>
|
||||
#include <linux/slab.h>
|
||||
|
||||
#define CLASS_NAME "slot_check"
|
||||
|
||||
struct slot_info {
|
||||
struct platform_device *pdev;
|
||||
struct class *slot_class;
|
||||
int gpio112;
|
||||
int gpio116;
|
||||
};
|
||||
|
||||
static struct slot_info *slot;
|
||||
|
||||
static ssize_t gpio112_show(struct class *class, struct class_attribute *attr,
|
||||
char *buf)
|
||||
{
|
||||
int value;
|
||||
value = gpio_get_value(slot->gpio112);
|
||||
return sprintf(buf, "%d\n",value);
|
||||
}
|
||||
|
||||
static ssize_t gpio116_show(struct class *class, struct class_attribute *attr,
|
||||
char *buf)
|
||||
{
|
||||
int value;
|
||||
value = gpio_get_value(slot->gpio116);
|
||||
return sprintf(buf, "%d\n",value);
|
||||
}
|
||||
|
||||
static CLASS_ATTR_RO(gpio112);
|
||||
static CLASS_ATTR_RO(gpio116);
|
||||
|
||||
static struct attribute *slot_class_attrs[] = {
|
||||
&class_attr_gpio112.attr,
|
||||
&class_attr_gpio116.attr,
|
||||
NULL,
|
||||
};
|
||||
|
||||
ATTRIBUTE_GROUPS(slot_class);
|
||||
|
||||
static struct class slot_class = {
|
||||
.name = CLASS_NAME,
|
||||
.owner = THIS_MODULE,
|
||||
.class_groups = slot_class_groups,
|
||||
};
|
||||
|
||||
static int slot_parse_dt()
|
||||
{
|
||||
slot->gpio112 = of_get_named_gpio(slot->pdev->dev.of_node,"gpio112",0);
|
||||
if(slot->gpio112 < 0){
|
||||
dev_err(&slot->pdev->dev,"can not get gpio112");
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
slot->gpio116 = of_get_named_gpio(slot->pdev->dev.of_node,"gpio116",0);
|
||||
if(slot->gpio116 < 0){
|
||||
dev_err(&slot->pdev->dev,"can not get gpio116");
|
||||
return -EINVAL;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int slot_class_probe(struct platform_device *pdev){
|
||||
|
||||
int ret;
|
||||
|
||||
slot = kzalloc(sizeof(struct slot_info), GFP_KERNEL);
|
||||
slot->pdev = pdev;
|
||||
slot->slot_class = &slot_class;
|
||||
|
||||
ret = slot_parse_dt();
|
||||
if(ret){
|
||||
dev_err(&slot->pdev->dev,"slot_parse_dt failed");
|
||||
goto err;
|
||||
}
|
||||
|
||||
ret = class_register(&slot_class);
|
||||
if(ret){
|
||||
dev_err(&slot->pdev->dev,"class_register fail\n");
|
||||
goto err;
|
||||
}
|
||||
|
||||
return ret;
|
||||
err:
|
||||
kzfree(slot);
|
||||
return ret;
|
||||
}
|
||||
|
||||
static const struct of_device_id slot_of_match[] = {
|
||||
{ .compatible = "nt,slot_check", },
|
||||
{ },
|
||||
};
|
||||
|
||||
MODULE_DEVICE_TABLE(of, slot_of_match);
|
||||
|
||||
static struct platform_driver slot_class_driver = {
|
||||
.probe = slot_class_probe,
|
||||
.driver = {
|
||||
.name = "slot_class",
|
||||
.of_match_table = slot_of_match,
|
||||
}
|
||||
};
|
||||
static int __init slot_check_init(void)
|
||||
{
|
||||
return platform_driver_register(&slot_class_driver);
|
||||
}
|
||||
|
||||
static void __exit slot_check_exit(void)
|
||||
{
|
||||
class_unregister(&slot_class);
|
||||
platform_driver_unregister(&slot_class_driver);
|
||||
kzfree(slot);
|
||||
}
|
||||
|
||||
|
||||
module_init(slot_check_init);
|
||||
module_exit(slot_check_exit);
|
||||
MODULE_DESCRIPTION("slot -check function");
|
||||
@@ -32,6 +32,12 @@
|
||||
#include <asm/current.h>
|
||||
#include <linux/timer.h>
|
||||
|
||||
#define ENABLE_MODEM_RESTART
|
||||
#ifdef ENABLE_MODEM_RESTART
|
||||
#include <linux/proc_fs.h>
|
||||
#include <linux/seq_file.h>
|
||||
#endif
|
||||
|
||||
#define CREATE_TRACE_POINTS
|
||||
#include <trace/events/trace_msm_ssr_event.h>
|
||||
|
||||
@@ -1611,9 +1617,51 @@ static struct notifier_block panic_nb = {
|
||||
.notifier_call = ssr_panic_handler,
|
||||
};
|
||||
|
||||
#ifdef ENABLE_MODEM_RESTART
|
||||
static int modem_restart(void)
|
||||
{
|
||||
int ret;
|
||||
int orig_level; //add for change back the default restart level after triggering modem restart
|
||||
struct subsys_device *dev = find_subsys_device("modem");
|
||||
|
||||
if (!dev)
|
||||
return -ENODEV;
|
||||
|
||||
pr_err("modem restart triggered\n");
|
||||
orig_level = dev->restart_level;
|
||||
dev->restart_level = RESET_SUBSYS_COUPLED;
|
||||
ret = subsystem_restart_dev(dev);
|
||||
dev->restart_level = orig_level;
|
||||
put_device(&dev->dev);
|
||||
return ret;
|
||||
}
|
||||
|
||||
static int modem_restart_show(struct seq_file *m, void *v)
|
||||
{
|
||||
seq_printf(m, "trigger modem restart\n");
|
||||
modem_restart();
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int modem_restart_open(struct inode *inode, struct file *file)
|
||||
{
|
||||
return single_open(file, modem_restart_show, inode->i_private);
|
||||
}
|
||||
|
||||
static const struct file_operations modem_restart_fops = {
|
||||
.open = modem_restart_open,
|
||||
.read = seq_read,
|
||||
.llseek = seq_lseek,
|
||||
.release = single_release,
|
||||
};
|
||||
#endif
|
||||
|
||||
static int __init subsys_restart_init(void)
|
||||
{
|
||||
int ret;
|
||||
#ifdef ENABLE_MODEM_RESTART
|
||||
struct proc_dir_entry *dir;
|
||||
#endif
|
||||
|
||||
ssr_wq = alloc_workqueue("ssr_wq",
|
||||
WQ_UNBOUND | WQ_HIGHPRI | WQ_CPU_INTENSIVE, 0);
|
||||
@@ -1634,6 +1682,14 @@ static int __init subsys_restart_init(void)
|
||||
if (ret)
|
||||
goto err_soc;
|
||||
|
||||
#ifdef ENABLE_MODEM_RESTART
|
||||
dir = proc_create("modem_restart", 0440, NULL, &modem_restart_fops);
|
||||
if (!dir) {
|
||||
pr_alert("Now in %s. proc_create.dir = %p\n", __func__, dir);
|
||||
return -1;
|
||||
}
|
||||
#endif
|
||||
|
||||
return 0;
|
||||
|
||||
err_soc:
|
||||
|
||||
Reference in New Issue
Block a user