diff --git a/arch/arm64/boot/dts/amlogic/s6_s905x5_raman_ai.dts b/arch/arm64/boot/dts/amlogic/s6_s905x5_raman_ai.dts index a1c62571c..3a882d30c 100644 --- a/arch/arm64/boot/dts/amlogic/s6_s905x5_raman_ai.dts +++ b/arch/arm64/boot/dts/amlogic/s6_s905x5_raman_ai.dts @@ -952,6 +952,13 @@ detect_mode = <0>; }; + radar_wakeup { + compatible = "radar-wakeup"; + report-type = ; + report-value = ; + status = "okay"; + }; + vin_12v_reg: fixed@vin_12v_reg { compatible = "regulator-fixed"; regulator-name = "DC_IN"; diff --git a/drivers/external/Kconfig b/drivers/external/Kconfig index f5183bb75..593e958f6 100644 --- a/drivers/external/Kconfig +++ b/drivers/external/Kconfig @@ -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 diff --git a/drivers/external/Makefile b/drivers/external/Makefile index fb72ea101..3bfb142c6 100644 --- a/drivers/external/Makefile +++ b/drivers/external/Makefile @@ -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/ diff --git a/drivers/external/sensor/radar/Kconfig b/drivers/external/sensor/radar/Kconfig new file mode 100644 index 000000000..924f4c294 --- /dev/null +++ b/drivers/external/sensor/radar/Kconfig @@ -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. diff --git a/drivers/external/sensor/radar/Makefile b/drivers/external/sensor/radar/Makefile new file mode 100644 index 000000000..2c2df9f37 --- /dev/null +++ b/drivers/external/sensor/radar/Makefile @@ -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 diff --git a/drivers/external/sensor/radar/radar_wakeup.c b/drivers/external/sensor/radar/radar_wakeup.c new file mode 100644 index 000000000..db62aa58a --- /dev/null +++ b/drivers/external/sensor/radar/radar_wakeup.c @@ -0,0 +1,107 @@ +// SPDX-License-Identifier: (GPL-2.0+ OR MIT) +/* + * Copyright (c) 2019 Amlogic, Inc. All rights reserved. + */ + +#include +#include +#include +#include +#include +#include +#include + +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"); diff --git a/include/linux/amlogic/pm.h b/include/linux/amlogic/pm.h index 9fb960aff..422a8eecb 100644 --- a/include/linux/amlogic/pm.h +++ b/include/linux/amlogic/pm.h @@ -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); diff --git a/patchinfo/Ide60dbb0c71c1d401d3490af9ba2ebb6e2ff49f6 b/patchinfo/Ide60dbb0c71c1d401d3490af9ba2ebb6e2ff49f6 new file mode 100644 index 000000000..271eaabf9 --- /dev/null +++ b/patchinfo/Ide60dbb0c71c1d401d3490af9ba2ebb6e2ff49f6 @@ -0,0 +1 @@ +SWPL-209963