Lines Matching +full:imx +full:- +full:sc +full:- +full:key
1 // SPDX-License-Identifier: GPL-2.0
8 #include <linux/firmware/imx/sci.h>
50 schedule_delayed_work(&priv->check_work, in imx_sc_key_notify()
52 pm_wakeup_event(priv->input->dev.parent, 0); in imx_sc_key_notify()
64 struct input_dev *input = priv->input; in imx_sc_check_for_events()
70 hdr->ver = IMX_SC_RPC_VERSION; in imx_sc_check_for_events()
71 hdr->svc = IMX_SC_RPC_SVC_MISC; in imx_sc_check_for_events()
72 hdr->func = IMX_SC_MISC_FUNC_GET_BUTTON_STATUS; in imx_sc_check_for_events()
73 hdr->size = 1; in imx_sc_check_for_events()
75 error = imx_scu_call_rpc(priv->key_ipc_handle, &msg, true); in imx_sc_check_for_events()
77 dev_err(&input->dev, "read imx sc key failed, error %d\n", error); in imx_sc_check_for_events()
83 * but ONLY the first byte is the key state, other in imx_sc_check_for_events()
85 * ONLY take the first byte as key state. in imx_sc_check_for_events()
89 if (state ^ priv->keystate) { in imx_sc_check_for_events()
90 priv->keystate = state; in imx_sc_check_for_events()
91 input_event(input, EV_KEY, priv->keycode, state); in imx_sc_check_for_events()
93 if (!priv->keystate) in imx_sc_check_for_events()
94 pm_relax(priv->input->dev.parent); in imx_sc_check_for_events()
98 schedule_delayed_work(&priv->check_work, in imx_sc_check_for_events()
107 imx_scu_irq_unregister_notifier(&priv->key_notifier); in imx_sc_key_action()
108 cancel_delayed_work_sync(&priv->check_work); in imx_sc_key_action()
117 priv = devm_kzalloc(&pdev->dev, sizeof(*priv), GFP_KERNEL); in imx_sc_key_probe()
119 return -ENOMEM; in imx_sc_key_probe()
121 error = imx_scu_get_handle(&priv->key_ipc_handle); in imx_sc_key_probe()
125 if (device_property_read_u32(&pdev->dev, "linux,keycodes", in imx_sc_key_probe()
126 &priv->keycode)) { in imx_sc_key_probe()
127 dev_err(&pdev->dev, "missing linux,keycodes property\n"); in imx_sc_key_probe()
128 return -EINVAL; in imx_sc_key_probe()
131 INIT_DELAYED_WORK(&priv->check_work, imx_sc_check_for_events); in imx_sc_key_probe()
133 input = devm_input_allocate_device(&pdev->dev); in imx_sc_key_probe()
135 dev_err(&pdev->dev, "failed to allocate the input device\n"); in imx_sc_key_probe()
136 return -ENOMEM; in imx_sc_key_probe()
139 input->name = pdev->name; in imx_sc_key_probe()
140 input->phys = "imx-sc-key/input0"; in imx_sc_key_probe()
141 input->id.bustype = BUS_HOST; in imx_sc_key_probe()
143 input_set_capability(input, EV_KEY, priv->keycode); in imx_sc_key_probe()
147 dev_err(&pdev->dev, "failed to register input device\n"); in imx_sc_key_probe()
151 priv->input = input; in imx_sc_key_probe()
157 dev_err(&pdev->dev, "failed to enable scu group irq\n"); in imx_sc_key_probe()
161 error = devm_add_action_or_reset(&pdev->dev, imx_sc_key_action, &priv); in imx_sc_key_probe()
165 priv->key_notifier.notifier_call = imx_sc_key_notify; in imx_sc_key_probe()
166 error = imx_scu_irq_register_notifier(&priv->key_notifier); in imx_sc_key_probe()
168 dev_err(&pdev->dev, "failed to register scu notifier\n"); in imx_sc_key_probe()
174 { .compatible = "fsl,imx-sc-key" },
181 .name = "imx-sc-key",
189 MODULE_DESCRIPTION("i.MX System Controller Key Driver");