mirror of
https://github.com/raspberrypi/linux.git
synced 2026-01-03 08:14:12 +00:00
Merge tag 'scmi-updates-6.12' of https://git.kernel.org/pub/scm/linux/kernel/git/sudeep.holla/linux into soc/drivers
Arm SCMI updates for v6.12
Few main features include:
1. SCMI transport as stand-alone drivers
Currently the SCMI transport layer is being built embedded into in
the core SCMI stack. Some of these transports, despite being currently
part of the main SCMI module, are indeed also registered with different
subsystems like optee or virtio, and actively probed also by those.
This leads to a few awkward and convoluted tricks to properly handle
such interactions at boot time in the SCMI stack.
This change adds the new logic to the core SCMI stack so that each
existing transport is transitioned to be a standi-alone driver. With
that all the probe deferral and awkward retries between the SCMI
core stack and the transports has been removed, since no more needed.
2. Support for obtaining transport descriptors from the devicetree
SCMI platform firmwares might have different designs depending on
the platform. Some of the transport descriptors rely on such design.
E.g. the maximum receive channel timeout value might vary depending
on the specific underlying hardware and firmware design choices.
This change adds support for max-rx-timeout-ms property to describe
the transport needs of a specific platform design. It will be extended
in the future to obtain other such hardware/firmware dependent
transport related descriptors.
3. NXP i.MX95 specific SCMI vendor protocol extensions
SCMI specification allows vendor or platform-specific extensions to
the interface. NXP i.MX95 System Manager(SM) that implements SCMI
extends the interface to implement couple of vendor/platform specific
protocol, namely:
a. Battery Backed Module(BBM) Protocol
This protocol is intended provide access to the battery-backed
module. This contains persistent storage (GPR), an RTC, and the
ON/OFF button. The protocol can also provide access to similar
functions implemented via external board components.
b. MISC Protocol for misc settings
This includes controls that are misc settings/actions that must
be exposed from the SM to agents. They are device specific and
are usually define to access bit fields in various mix block
control modules, IOMUX_GPR, and other GPR/CSR owned by the SM.
4. SCMI debug/tracking metrics
Since SCMI involves interaction with the entity(software, firmware
and/or hardware) providing services or features, it is quite useful
to track certain metrics(for pure debugging purposes) like how many
messages were sent or received, were there any failures, what kind
of failures, ..etc. This feature adds support for the same via debugfs.
Apart from these main features, there are some miscellaneous updates, fixes
and cleanups.
* tag 'scmi-updates-6.12' of https://git.kernel.org/pub/scm/linux/kernel/git/sudeep.holla/linux: (31 commits)
rtc: support i.MX95 BBM RTC
input: keyboard: support i.MX95 BBM module
firmware: imx: Add i.MX95 MISC driver
firmware: arm_scmi: Add initial support for i.MX MISC protocol
firmware: arm_scmi: Add initial support for i.MX BBM protocol
firmware: arm_scmi: Add NXP i.MX95 SCMI documentation
dt-bindings: firmware: Add i.MX95 SCMI Extension protocol
firmware: arm_scmi: Replace comma with the semicolon
firmware: arm_scmi: Replace the use of of_node_put() to __free(device_node)
firmware: arm_scmi: Fix trivial whitespace/coding style issues
firmware: arm_scmi: Use max-rx-timeout-ms from devicetree
dt-bindings: firmware: arm,scmi: Introduce property max-rx-timeout-ms
firmware: arm_scmi: Remove const from transport descriptors
firmware: arm_scmi: Simplify with scoped for each OF child loop
firmware: arm_scmi: Update various protocols versions
firmware: arm_scmi: Remove legacy transport-layer code
firmware: arm_scmi: Make VirtIO transport a standalone driver
firmware: arm_scmi: Make OPTEE transport a standalone driver
firmware: arm_scmi: Make SMC transport a standalone driver
firmware: arm_scmi: Make MBOX transport a standalone driver
...
Link: https://lore.kernel.org/r/20240830135918.2383664-1-sudeep.holla@arm.com
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
This commit is contained in:
@@ -466,6 +466,17 @@ config KEYBOARD_IMX
|
||||
To compile this driver as a module, choose M here: the
|
||||
module will be called imx_keypad.
|
||||
|
||||
config KEYBOARD_IMX_BBM_SCMI
|
||||
tristate "IMX BBM SCMI Key Driver"
|
||||
depends on IMX_SCMI_BBM_EXT || COMPILE_TEST
|
||||
default y if ARCH_MXC
|
||||
help
|
||||
This is the BBM key driver for NXP i.MX SoCs managed through
|
||||
SCMI protocol.
|
||||
|
||||
To compile this driver as a module, choose M here: the
|
||||
module will be called scmi-imx-bbm-key.
|
||||
|
||||
config KEYBOARD_IMX_SC_KEY
|
||||
tristate "IMX SCU Key Driver"
|
||||
depends on IMX_SCU
|
||||
|
||||
@@ -31,6 +31,7 @@ obj-$(CONFIG_KEYBOARD_IPAQ_MICRO) += ipaq-micro-keys.o
|
||||
obj-$(CONFIG_KEYBOARD_IQS62X) += iqs62x-keys.o
|
||||
obj-$(CONFIG_KEYBOARD_IMX) += imx_keypad.o
|
||||
obj-$(CONFIG_KEYBOARD_IMX_SC_KEY) += imx_sc_key.o
|
||||
obj-$(CONFIG_KEYBOARD_IMX_BBM_SCMI) += imx-sm-bbm-key.o
|
||||
obj-$(CONFIG_KEYBOARD_HP6XX) += jornada680_kbd.o
|
||||
obj-$(CONFIG_KEYBOARD_HP7XX) += jornada720_kbd.o
|
||||
obj-$(CONFIG_KEYBOARD_LKKBD) += lkkbd.o
|
||||
|
||||
225
drivers/input/keyboard/imx-sm-bbm-key.c
Normal file
225
drivers/input/keyboard/imx-sm-bbm-key.c
Normal file
@@ -0,0 +1,225 @@
|
||||
// SPDX-License-Identifier: GPL-2.0+
|
||||
/*
|
||||
* Copyright 2024 NXP.
|
||||
*/
|
||||
|
||||
#include <linux/input.h>
|
||||
#include <linux/jiffies.h>
|
||||
#include <linux/module.h>
|
||||
#include <linux/of.h>
|
||||
#include <linux/platform_device.h>
|
||||
#include <linux/rtc.h>
|
||||
#include <linux/scmi_protocol.h>
|
||||
#include <linux/scmi_imx_protocol.h>
|
||||
#include <linux/suspend.h>
|
||||
|
||||
#define DEBOUNCE_TIME 30
|
||||
#define REPEAT_INTERVAL 60
|
||||
|
||||
struct scmi_imx_bbm {
|
||||
struct scmi_protocol_handle *ph;
|
||||
const struct scmi_imx_bbm_proto_ops *ops;
|
||||
struct notifier_block nb;
|
||||
int keycode;
|
||||
int keystate; /* 1:pressed */
|
||||
bool suspended;
|
||||
struct delayed_work check_work;
|
||||
struct input_dev *input;
|
||||
};
|
||||
|
||||
static void scmi_imx_bbm_pwrkey_check_for_events(struct work_struct *work)
|
||||
{
|
||||
struct scmi_imx_bbm *bbnsm = container_of(to_delayed_work(work),
|
||||
struct scmi_imx_bbm, check_work);
|
||||
struct scmi_protocol_handle *ph = bbnsm->ph;
|
||||
struct input_dev *input = bbnsm->input;
|
||||
u32 state = 0;
|
||||
int ret;
|
||||
|
||||
ret = bbnsm->ops->button_get(ph, &state);
|
||||
if (ret) {
|
||||
pr_err("%s: %d\n", __func__, ret);
|
||||
return;
|
||||
}
|
||||
|
||||
pr_debug("%s: state: %d, keystate %d\n", __func__, state, bbnsm->keystate);
|
||||
|
||||
/* only report new event if status changed */
|
||||
if (state ^ bbnsm->keystate) {
|
||||
bbnsm->keystate = state;
|
||||
input_event(input, EV_KEY, bbnsm->keycode, state);
|
||||
input_sync(input);
|
||||
pm_relax(bbnsm->input->dev.parent);
|
||||
pr_debug("EV_KEY: %x\n", bbnsm->keycode);
|
||||
}
|
||||
|
||||
/* repeat check if pressed long */
|
||||
if (state)
|
||||
schedule_delayed_work(&bbnsm->check_work, msecs_to_jiffies(REPEAT_INTERVAL));
|
||||
}
|
||||
|
||||
static int scmi_imx_bbm_pwrkey_event(struct scmi_imx_bbm *bbnsm)
|
||||
{
|
||||
struct input_dev *input = bbnsm->input;
|
||||
|
||||
pm_wakeup_event(input->dev.parent, 0);
|
||||
|
||||
/*
|
||||
* Directly report key event after resume to make no key press
|
||||
* event is missed.
|
||||
*/
|
||||
if (READ_ONCE(bbnsm->suspended)) {
|
||||
bbnsm->keystate = 1;
|
||||
input_event(input, EV_KEY, bbnsm->keycode, 1);
|
||||
input_sync(input);
|
||||
WRITE_ONCE(bbnsm->suspended, false);
|
||||
}
|
||||
|
||||
schedule_delayed_work(&bbnsm->check_work, msecs_to_jiffies(DEBOUNCE_TIME));
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void scmi_imx_bbm_pwrkey_act(void *pdata)
|
||||
{
|
||||
struct scmi_imx_bbm *bbnsm = pdata;
|
||||
|
||||
cancel_delayed_work_sync(&bbnsm->check_work);
|
||||
}
|
||||
|
||||
static int scmi_imx_bbm_key_notifier(struct notifier_block *nb, unsigned long event, void *data)
|
||||
{
|
||||
struct scmi_imx_bbm *bbnsm = container_of(nb, struct scmi_imx_bbm, nb);
|
||||
struct scmi_imx_bbm_notif_report *r = data;
|
||||
|
||||
if (r->is_button) {
|
||||
pr_debug("BBM Button Power key pressed\n");
|
||||
scmi_imx_bbm_pwrkey_event(bbnsm);
|
||||
} else {
|
||||
/* Should never reach here */
|
||||
pr_err("Unexpected BBM event: %s\n", __func__);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int scmi_imx_bbm_pwrkey_init(struct scmi_device *sdev)
|
||||
{
|
||||
const struct scmi_handle *handle = sdev->handle;
|
||||
struct device *dev = &sdev->dev;
|
||||
struct scmi_imx_bbm *bbnsm = dev_get_drvdata(dev);
|
||||
struct input_dev *input;
|
||||
int ret;
|
||||
|
||||
if (device_property_read_u32(dev, "linux,code", &bbnsm->keycode)) {
|
||||
bbnsm->keycode = KEY_POWER;
|
||||
dev_warn(dev, "key code is not specified, using default KEY_POWER\n");
|
||||
}
|
||||
|
||||
INIT_DELAYED_WORK(&bbnsm->check_work, scmi_imx_bbm_pwrkey_check_for_events);
|
||||
|
||||
input = devm_input_allocate_device(dev);
|
||||
if (!input) {
|
||||
dev_err(dev, "failed to allocate the input device for SCMI IMX BBM\n");
|
||||
return -ENOMEM;
|
||||
}
|
||||
|
||||
input->name = dev_name(dev);
|
||||
input->phys = "bbnsm-pwrkey/input0";
|
||||
input->id.bustype = BUS_HOST;
|
||||
|
||||
input_set_capability(input, EV_KEY, bbnsm->keycode);
|
||||
|
||||
ret = devm_add_action_or_reset(dev, scmi_imx_bbm_pwrkey_act, bbnsm);
|
||||
if (ret) {
|
||||
dev_err(dev, "failed to register remove action\n");
|
||||
return ret;
|
||||
}
|
||||
|
||||
bbnsm->input = input;
|
||||
|
||||
bbnsm->nb.notifier_call = &scmi_imx_bbm_key_notifier;
|
||||
ret = handle->notify_ops->devm_event_notifier_register(sdev, SCMI_PROTOCOL_IMX_BBM,
|
||||
SCMI_EVENT_IMX_BBM_BUTTON,
|
||||
NULL, &bbnsm->nb);
|
||||
|
||||
if (ret)
|
||||
dev_err(dev, "Failed to register BBM Button Events %d:", ret);
|
||||
|
||||
ret = input_register_device(input);
|
||||
if (ret) {
|
||||
dev_err(dev, "failed to register input device\n");
|
||||
return ret;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int scmi_imx_bbm_key_probe(struct scmi_device *sdev)
|
||||
{
|
||||
const struct scmi_handle *handle = sdev->handle;
|
||||
struct device *dev = &sdev->dev;
|
||||
struct scmi_protocol_handle *ph;
|
||||
struct scmi_imx_bbm *bbnsm;
|
||||
int ret;
|
||||
|
||||
if (!handle)
|
||||
return -ENODEV;
|
||||
|
||||
bbnsm = devm_kzalloc(dev, sizeof(*bbnsm), GFP_KERNEL);
|
||||
if (!bbnsm)
|
||||
return -ENOMEM;
|
||||
|
||||
bbnsm->ops = handle->devm_protocol_get(sdev, SCMI_PROTOCOL_IMX_BBM, &ph);
|
||||
if (IS_ERR(bbnsm->ops))
|
||||
return PTR_ERR(bbnsm->ops);
|
||||
|
||||
bbnsm->ph = ph;
|
||||
|
||||
device_init_wakeup(dev, true);
|
||||
|
||||
dev_set_drvdata(dev, bbnsm);
|
||||
|
||||
ret = scmi_imx_bbm_pwrkey_init(sdev);
|
||||
if (ret)
|
||||
device_init_wakeup(dev, false);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
static int __maybe_unused scmi_imx_bbm_key_suspend(struct device *dev)
|
||||
{
|
||||
struct scmi_imx_bbm *bbnsm = dev_get_drvdata(dev);
|
||||
|
||||
WRITE_ONCE(bbnsm->suspended, true);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int __maybe_unused scmi_imx_bbm_key_resume(struct device *dev)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
static SIMPLE_DEV_PM_OPS(scmi_imx_bbm_pm_key_ops, scmi_imx_bbm_key_suspend,
|
||||
scmi_imx_bbm_key_resume);
|
||||
|
||||
static const struct scmi_device_id scmi_id_table[] = {
|
||||
{ SCMI_PROTOCOL_IMX_BBM, "imx-bbm-key" },
|
||||
{ },
|
||||
};
|
||||
MODULE_DEVICE_TABLE(scmi, scmi_id_table);
|
||||
|
||||
static struct scmi_driver scmi_imx_bbm_key_driver = {
|
||||
.driver = {
|
||||
.pm = &scmi_imx_bbm_pm_key_ops,
|
||||
},
|
||||
.name = "scmi-imx-bbm-key",
|
||||
.probe = scmi_imx_bbm_key_probe,
|
||||
.id_table = scmi_id_table,
|
||||
};
|
||||
module_scmi_driver(scmi_imx_bbm_key_driver);
|
||||
|
||||
MODULE_AUTHOR("Peng Fan <peng.fan@nxp.com>");
|
||||
MODULE_DESCRIPTION("IMX SM BBM Key driver");
|
||||
MODULE_LICENSE("GPL");
|
||||
Reference in New Issue
Block a user