summaryrefslogtreecommitdiff
path: root/drivers/media/rc/meson-ir.c
diff options
context:
space:
mode:
authorAlex Deryskyba <alex@codesnake.com>2017-04-25 10:41:09 +0300
committerMauro Carvalho Chehab <mchehab@s-opensource.com>2017-06-06 14:56:32 +0300
commit2aa1bd1c1ca82f57f3e6967d34c8c985dcc22f48 (patch)
tree1cb6a89758ec6e071f75c146a734de669660345e /drivers/media/rc/meson-ir.c
parent48b0a69126dcc8659c2301eb41729445f444e36b (diff)
downloadlinux-2aa1bd1c1ca82f57f3e6967d34c8c985dcc22f48.tar.xz
[media] rc: meson-ir: switch config to NEC decoding on shutdown
On the Amlogic SoCs, the bootloader firmware can handle the IR hardware in order to Wake up or Power back the system when in suspend on shutdown mode. This patch switches the hardware configuration in a state usable by the firmware to permit powering the system back. Some vendor bootloader firmware were modified to switch to this configuration but it may not be the case for all available products. This patch was originally posted at [1]. [1] https://github.com/LibreELEC/linux-amlogic/pull/27 Signed-off-by: Alex Deryskyba <alex@codesnake.com> Signed-off-by: Neil Armstrong <narmstrong@baylibre.com> Signed-off-by: Sean Young <sean@mess.org> Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
Diffstat (limited to 'drivers/media/rc/meson-ir.c')
-rw-r--r--drivers/media/rc/meson-ir.c27
1 files changed, 27 insertions, 0 deletions
diff --git a/drivers/media/rc/meson-ir.c b/drivers/media/rc/meson-ir.c
index 3375b4e18764..65566d569cb1 100644
--- a/drivers/media/rc/meson-ir.c
+++ b/drivers/media/rc/meson-ir.c
@@ -201,6 +201,32 @@ static int meson_ir_remove(struct platform_device *pdev)
return 0;
}
+static void meson_ir_shutdown(struct platform_device *pdev)
+{
+ struct device *dev = &pdev->dev;
+ struct device_node *node = dev->of_node;
+ struct meson_ir *ir = platform_get_drvdata(pdev);
+ unsigned long flags;
+
+ spin_lock_irqsave(&ir->lock, flags);
+
+ /*
+ * Set operation mode to NEC/hardware decoding to give
+ * bootloader a chance to power the system back on
+ */
+ if (of_device_is_compatible(node, "amlogic,meson6-ir"))
+ meson_ir_set_mask(ir, IR_DEC_REG1, REG1_MODE_MASK,
+ DECODE_MODE_NEC << REG1_MODE_SHIFT);
+ else
+ meson_ir_set_mask(ir, IR_DEC_REG2, REG2_MODE_MASK,
+ DECODE_MODE_NEC << REG2_MODE_SHIFT);
+
+ /* Set rate to default value */
+ meson_ir_set_mask(ir, IR_DEC_REG0, REG0_RATE_MASK, 0x13);
+
+ spin_unlock_irqrestore(&ir->lock, flags);
+}
+
static const struct of_device_id meson_ir_match[] = {
{ .compatible = "amlogic,meson6-ir" },
{ .compatible = "amlogic,meson8b-ir" },
@@ -212,6 +238,7 @@ MODULE_DEVICE_TABLE(of, meson_ir_match);
static struct platform_driver meson_ir_driver = {
.probe = meson_ir_probe,
.remove = meson_ir_remove,
+ .shutdown = meson_ir_shutdown,
.driver = {
.name = DRIVER_NAME,
.of_match_table = meson_ir_match,