mirror of
https://github.com/hardkernel/kernel_common_drivers.git
synced 2026-06-25 12:03:48 +09:00
raman_ai: enable radar wakeup gpio func [3/3]
PD#SWPL-209963 Problem: enable radar wakeup gpio. Solution: radar GPIOA_11 wakeup SOC. Verify: raman_ai Change-Id: Ide60dbb0c71c1d401d3490af9ba2ebb6e2ff49f6 Signed-off-by: yidong zhang <yidong.zhang@amlogic.com>
This commit is contained in:
committed by
codewalkerster
parent
aaa3074692
commit
855bd321c7
@@ -952,6 +952,13 @@
|
||||
detect_mode = <0>;
|
||||
};
|
||||
|
||||
radar_wakeup {
|
||||
compatible = "radar-wakeup";
|
||||
report-type = <EV_KEY>;
|
||||
report-value = <KEY_POWER>;
|
||||
status = "okay";
|
||||
};
|
||||
|
||||
vin_12v_reg: fixed@vin_12v_reg {
|
||||
compatible = "regulator-fixed";
|
||||
regulator-name = "DC_IN";
|
||||
|
||||
Vendored
+1
@@ -13,6 +13,7 @@ if AMLOGIC_EXTERNAL_DRIVER
|
||||
source "$(COMMON_DRIVERS_DIR)/drivers/external/leds/Kconfig"
|
||||
source "$(COMMON_DRIVERS_DIR)/drivers/external/nfc/nta533/Kconfig"
|
||||
source "$(COMMON_DRIVERS_DIR)/drivers/external/sensor/htu20d/Kconfig"
|
||||
source "$(COMMON_DRIVERS_DIR)/drivers/external/sensor/radar/Kconfig"
|
||||
source "$(COMMON_DRIVERS_DIR)/drivers/external/sensor/ucs11681/Kconfig"
|
||||
source "$(COMMON_DRIVERS_DIR)/drivers/external/video/st7789v3_tft/Kconfig"
|
||||
endif
|
||||
|
||||
Vendored
+1
@@ -3,5 +3,6 @@
|
||||
obj-$(CONFIG_AMLOGIC_EXTERNAL_DRIVER) += leds/
|
||||
obj-$(CONFIG_AMLOGIC_EXTERNAL_DRIVER) += nfc/nta533/
|
||||
obj-$(CONFIG_AMLOGIC_EXTERNAL_DRIVER) += sensor/htu20d/
|
||||
obj-$(CONFIG_AMLOGIC_EXTERNAL_DRIVER) += sensor/radar/
|
||||
obj-$(CONFIG_AMLOGIC_EXTERNAL_DRIVER) += sensor/ucs11681/
|
||||
obj-$(CONFIG_AMLOGIC_EXTERNAL_DRIVER) += video/st7789v3_tft/
|
||||
|
||||
+7
@@ -0,0 +1,7 @@
|
||||
# SPDX-License-Identifier: (GPL-2.0+ OR MIT)
|
||||
|
||||
config RADAR_WAKEUP
|
||||
tristate "Radar wakeup device support"
|
||||
default n
|
||||
help
|
||||
Say Y here if you want to use the radar wakeup device.
|
||||
+5
@@ -0,0 +1,5 @@
|
||||
SPDX-License-Identifier: (GPL-2.0+ OR MIT)
|
||||
|
||||
MODULE_NAME = radar-wakeup
|
||||
obj-$(CONFIG_RADAR_WAKEUP) = $(MODULE_NAME).o
|
||||
$(MODULE_NAME)-y += radar_wakeup.o
|
||||
+107
@@ -0,0 +1,107 @@
|
||||
// SPDX-License-Identifier: (GPL-2.0+ OR MIT)
|
||||
/*
|
||||
* Copyright (c) 2019 Amlogic, Inc. All rights reserved.
|
||||
*/
|
||||
|
||||
#include <linux/module.h>
|
||||
#include <linux/types.h>
|
||||
#include <linux/of.h>
|
||||
#include <linux/of_device.h>
|
||||
#include <linux/platform_device.h>
|
||||
#include <linux/input.h>
|
||||
#include <linux/amlogic/pm.h>
|
||||
|
||||
struct radar_wakeup {
|
||||
struct input_dev *input;
|
||||
u32 report_type;
|
||||
u32 report_value;
|
||||
};
|
||||
|
||||
static int __maybe_unused radar_wakeup_resume(struct device *dev)
|
||||
{
|
||||
struct radar_wakeup *data = dev_get_drvdata(dev);
|
||||
|
||||
if (get_resume_method() == RADAR_GPIO_WAKEUP) {
|
||||
input_event(data->input, data->report_type, data->report_value, 1);
|
||||
input_sync(data->input);
|
||||
input_event(data->input, data->report_type, data->report_value, 0);
|
||||
input_sync(data->input);
|
||||
dev_info(dev, "Radar wakeup\n");
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int __maybe_unused radar_wakeup_suspend(struct device *dev)
|
||||
{
|
||||
/* Do nothing */
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int radar_wakeup_probe(struct platform_device *pdev)
|
||||
{
|
||||
struct device *dev = &pdev->dev;
|
||||
struct radar_wakeup *priv;
|
||||
const char *const name = dev_name(dev);
|
||||
int ret;
|
||||
|
||||
priv = devm_kzalloc(dev, sizeof(*priv), GFP_KERNEL);
|
||||
if (!priv)
|
||||
dev_err_probe(dev, -ENOMEM, "Failed to allocate memory\n");
|
||||
|
||||
ret = of_property_read_u32(dev->of_node, "report-type", &priv->report_type);
|
||||
if (ret)
|
||||
return dev_err_probe(dev, -EINVAL, "Property not found: report-type\n");
|
||||
|
||||
ret = of_property_read_u32(dev->of_node, "report-value", &priv->report_value);
|
||||
if (ret)
|
||||
return dev_err_probe(dev, -EINVAL, "Property not found: report-value\n");
|
||||
|
||||
priv->input = devm_input_allocate_device(dev);
|
||||
if (!priv->input)
|
||||
dev_err_probe(dev, -ENOMEM, "Failed to allocate input device\n");
|
||||
|
||||
dev_set_drvdata(dev, priv);
|
||||
|
||||
priv->input->name = name;
|
||||
priv->input->phys = "radar-wakeup/input0";
|
||||
priv->input->id.bustype = BUS_HOST;
|
||||
priv->input->id.vendor = 0x0001;
|
||||
priv->input->id.product = 0x0001;
|
||||
priv->input->id.version = 0x0100;
|
||||
|
||||
__set_bit(priv->report_type, priv->input->evbit);
|
||||
__set_bit(priv->report_value, priv->input->keybit);
|
||||
__set_bit(EV_REP, priv->input->evbit);
|
||||
|
||||
ret = input_register_device(priv->input);
|
||||
if (ret)
|
||||
return dev_err_probe(dev, ret, "Unable to register input device\n");
|
||||
|
||||
dev_info(dev, "Radar wakeup driver ready\n");
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static const struct dev_pm_ops radar_wakeup_pm_ops = {
|
||||
SET_SYSTEM_SLEEP_PM_OPS(radar_wakeup_suspend, radar_wakeup_resume)
|
||||
};
|
||||
|
||||
static const struct of_device_id radar_wakeup_of_match[] = {
|
||||
{ .compatible = "radar-wakeup", },
|
||||
{ /* sentinel */ },
|
||||
};
|
||||
|
||||
static struct platform_driver radar_wakeup_driver = {
|
||||
.probe = radar_wakeup_probe,
|
||||
.driver = {
|
||||
.name = "radar_wakeup",
|
||||
.pm = &radar_wakeup_pm_ops,
|
||||
.of_match_table = radar_wakeup_of_match,
|
||||
},
|
||||
};
|
||||
|
||||
module_platform_driver(radar_wakeup_driver);
|
||||
|
||||
MODULE_LICENSE("GPL v2");
|
||||
MODULE_DESCRIPTION("Radar wakeup driver");
|
||||
@@ -23,6 +23,7 @@
|
||||
#define ETH_PHY_GPIO 12
|
||||
#define VAD_WAKEUP 13
|
||||
#define HDMI_RX_WAKEUP 14
|
||||
#define RADAR_GPIO_WAKEUP 16
|
||||
|
||||
#if IS_ENABLED(CONFIG_AMLOGIC_GX_SUSPEND)
|
||||
unsigned int get_resume_method(void);
|
||||
|
||||
@@ -0,0 +1 @@
|
||||
SWPL-209963
|
||||
Reference in New Issue
Block a user