i.MX drivers update for 6.6:

- A series from NXP i.MX developers (Peng Fan, etc.) to update imx-scu
   and imx-scu-irq firmware drivers.
 - Add dedicated lockdep class for nested genpd locks to fix a lockdep
   warning in imx93-blk-ctrl driver.
 - A change from Rob to explicitly include correct DT headers for i.MX
   SoC drivers.
 - Use devm_platform_ioremap_resource() in imx-weim bus driver.
 -----BEGIN PGP SIGNATURE-----
 
 iQFIBAABCgAyFiEEFmJXigPl4LoGSz08UFdYWoewfM4FAmTYNCAUHHNoYXduZ3Vv
 QGtlcm5lbC5vcmcACgkQUFdYWoewfM7x+wgAsB65MMhY74a8pjuO0q1nJierjc46
 of2ayxR8I1jXQK/3IUijBZpg+8bnQkhXiVK1uyzvLmUc28iw1y6B2dWec/hXRld8
 mc516IWjGa0Re+dOeliKPFNWzj6TZRi3TmqKIfg5XIb0poBtxBiXm7tvjm1oYRQl
 ijkCqauOXJmK3yMMTQqxknGQG+B8wQDTPnbssk0A46ShD4RrYXmC3wjTEb27WoGk
 nw18XT5XpS+LomctRcqza3Bcdry6YPmI0hOt9Oy9db2sBtXbz+bf9tLGKztvfxGz
 44R0+Rz/XncJHwRXGgUNR71ps0+WP55qKsqoTw/zHhkS2BPl8gMxhBtQbQ==
 =T2Uo
 -----END PGP SIGNATURE-----
gpgsig -----BEGIN PGP SIGNATURE-----
 
 iQIzBAABCgAdFiEEiK/NIGsWEZVxh/FrYKtH/8kJUicFAmTaT8sACgkQYKtH/8kJ
 UieFHQ//YrvUhNJjVtQeUcZ4s43MKKJsq7HNnki02ZRlIOdcG+vM7JzWe6PsRDbK
 8jeV1tM3ZE67VBeIZU1+ELshebiU01VQY4ZobmGOPMajDFXZmu1Znzr8O6RASrmd
 u+aFhpTGleg4SQQ2avdaQIQ4gpw19ciellxCTx37Y/hae06nANXzFFTlnPO4qseW
 rzJzgh2h3Z1Gv/LdqtlfMAeI2aEQy/+hfKmZs4f20/Rs8wwH7lzrNLSUideY6cqt
 RM1nX3F97b+glRJ4siqRoUISVSW6naWkb5qZ+VZXN4e7xrczuV/1Sp2dqINWXxKp
 dR3WpOfb2V9sIGQOiAb8XSFBkxvDVG6ze6l2RkXA0szqpVBRMOTGshykMqt2I2tN
 8Eeek9+XXZHZxNR6omFX4cvTjRW7hvhB0W35UdoZr1qteC8jV/H1DBYV3v8ri1d8
 z17Y0JGBFrtQFBF/jq1yK0WND4RIb2aHYxrojDQ3/mtqsMailIuogwGpMQyhsCll
 nX2NeKpaKe3MwEtKPOSTkUD5k8TLBfDOn/fcoLRQ6Ys6fsBAcplJ+6Sp3Hv/mgWQ
 W9eWaeBAh0BllI66twAxeTKdy/1IsGpsLyNVDJliAExW3Z1ISPUMw6pI4M+H/QZY
 W+joqcvJYAAiOfIvRqQWvyt40I/2JYx6otsJKN4JB9Qlh3QRvxg=
 =2iHc
 -----END PGP SIGNATURE-----

Merge tag 'imx-drivers-6.6' of git://git.kernel.org/pub/scm/linux/kernel/git/shawnguo/linux into soc/drivers

i.MX drivers update for 6.6:

- A series from NXP i.MX developers (Peng Fan, etc.) to update imx-scu
  and imx-scu-irq firmware drivers.
- Add dedicated lockdep class for nested genpd locks to fix a lockdep
  warning in imx93-blk-ctrl driver.
- A change from Rob to explicitly include correct DT headers for i.MX
  SoC drivers.
- Use devm_platform_ioremap_resource() in imx-weim bus driver.

* tag 'imx-drivers-6.6' of git://git.kernel.org/pub/scm/linux/kernel/git/shawnguo/linux:
  firmware: imx: scu-irq: support identifying SCU wakeup source from sysfs
  firmware: imx: scu-irq: enlarge the IMX_SC_IRQ_NUM_GROUP
  firmware: imx: scu-irq: add imx_scu_irq_get_status
  firmware: imx: scu-irq: fix RCU complaint after M4 partition reset
  firmware: imx: scu: use EOPNOTSUPP
  firmware: imx: scu: use soc name for soc_id
  firmware: imx: scu: increase RPC timeout
  firmware: imx: scu: change init level to subsys_initcall_sync
  soc: imx: Explicitly include correct DT includes
  bus: imx-weim: use devm_platform_ioremap_resource
  soc: imx: imx93-blk-ctrl: Add dedicated lockdep class for nested genpd locks

Link: https://lore.kernel.org/r/20230813133354.847010-1-shawnguo@kernel.org
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
This commit is contained in:
Arnd Bergmann 2023-08-14 18:00:57 +02:00
commit 9fb9ae8061
10 changed files with 158 additions and 33 deletions

View File

@ -273,7 +273,7 @@ static int weim_probe(struct platform_device *pdev)
return -ENOMEM;
/* get the resource */
base = devm_platform_get_and_ioremap_resource(pdev, 0, NULL);
base = devm_platform_ioremap_resource(pdev, 0);
if (IS_ERR(base))
return PTR_ERR(base);

View File

@ -1,6 +1,6 @@
// SPDX-License-Identifier: GPL-2.0+
/*
* Copyright 2019 NXP
* Copyright 2019,2023 NXP
*
* Implementation of the SCU IRQ functions using MU.
*
@ -9,12 +9,14 @@
#include <dt-bindings/firmware/imx/rsrc.h>
#include <linux/firmware/imx/ipc.h>
#include <linux/firmware/imx/sci.h>
#include <linux/kobject.h>
#include <linux/mailbox_client.h>
#include <linux/suspend.h>
#include <linux/sysfs.h>
#define IMX_SC_IRQ_FUNC_ENABLE 1
#define IMX_SC_IRQ_FUNC_STATUS 2
#define IMX_SC_IRQ_NUM_GROUP 4
#define IMX_SC_IRQ_NUM_GROUP 9
static u32 mu_resource_id;
@ -40,63 +42,102 @@ struct imx_sc_msg_irq_enable {
u8 enable;
} __packed;
struct scu_wakeup {
u32 mask;
u32 wakeup_src;
bool valid;
};
/* Sysfs functions */
static struct kobject *wakeup_obj;
static ssize_t wakeup_source_show(struct kobject *kobj, struct kobj_attribute *attr, char *buf);
static struct kobj_attribute wakeup_source_attr =
__ATTR(wakeup_src, 0660, wakeup_source_show, NULL);
static struct scu_wakeup scu_irq_wakeup[IMX_SC_IRQ_NUM_GROUP];
static struct imx_sc_ipc *imx_sc_irq_ipc_handle;
static struct work_struct imx_sc_irq_work;
static ATOMIC_NOTIFIER_HEAD(imx_scu_irq_notifier_chain);
static BLOCKING_NOTIFIER_HEAD(imx_scu_irq_notifier_chain);
int imx_scu_irq_register_notifier(struct notifier_block *nb)
{
return atomic_notifier_chain_register(
return blocking_notifier_chain_register(
&imx_scu_irq_notifier_chain, nb);
}
EXPORT_SYMBOL(imx_scu_irq_register_notifier);
int imx_scu_irq_unregister_notifier(struct notifier_block *nb)
{
return atomic_notifier_chain_unregister(
return blocking_notifier_chain_unregister(
&imx_scu_irq_notifier_chain, nb);
}
EXPORT_SYMBOL(imx_scu_irq_unregister_notifier);
static int imx_scu_irq_notifier_call_chain(unsigned long status, u8 *group)
{
return atomic_notifier_call_chain(&imx_scu_irq_notifier_chain,
return blocking_notifier_call_chain(&imx_scu_irq_notifier_chain,
status, (void *)group);
}
static void imx_scu_irq_work_handler(struct work_struct *work)
{
struct imx_sc_msg_irq_get_status msg;
struct imx_sc_rpc_msg *hdr = &msg.hdr;
u32 irq_status;
int ret;
u8 i;
for (i = 0; i < IMX_SC_IRQ_NUM_GROUP; i++) {
hdr->ver = IMX_SC_RPC_VERSION;
hdr->svc = IMX_SC_RPC_SVC_IRQ;
hdr->func = IMX_SC_IRQ_FUNC_STATUS;
hdr->size = 2;
if (scu_irq_wakeup[i].mask) {
scu_irq_wakeup[i].valid = false;
scu_irq_wakeup[i].wakeup_src = 0;
}
msg.data.req.resource = mu_resource_id;
msg.data.req.group = i;
ret = imx_scu_call_rpc(imx_sc_irq_ipc_handle, &msg, true);
ret = imx_scu_irq_get_status(i, &irq_status);
if (ret) {
pr_err("get irq group %d status failed, ret %d\n",
i, ret);
return;
}
irq_status = msg.data.resp.status;
if (!irq_status)
continue;
if (scu_irq_wakeup[i].mask & irq_status) {
scu_irq_wakeup[i].valid = true;
scu_irq_wakeup[i].wakeup_src = irq_status & scu_irq_wakeup[i].mask;
} else {
scu_irq_wakeup[i].wakeup_src = irq_status;
}
pm_system_wakeup();
imx_scu_irq_notifier_call_chain(irq_status, &i);
}
}
int imx_scu_irq_get_status(u8 group, u32 *irq_status)
{
struct imx_sc_msg_irq_get_status msg;
struct imx_sc_rpc_msg *hdr = &msg.hdr;
int ret;
hdr->ver = IMX_SC_RPC_VERSION;
hdr->svc = IMX_SC_RPC_SVC_IRQ;
hdr->func = IMX_SC_IRQ_FUNC_STATUS;
hdr->size = 2;
msg.data.req.resource = mu_resource_id;
msg.data.req.group = group;
ret = imx_scu_call_rpc(imx_sc_irq_ipc_handle, &msg, true);
if (ret)
return ret;
if (irq_status)
*irq_status = msg.data.resp.status;
return 0;
}
EXPORT_SYMBOL(imx_scu_irq_get_status);
int imx_scu_irq_group_enable(u8 group, u32 mask, u8 enable)
{
struct imx_sc_msg_irq_enable msg;
@ -121,6 +162,11 @@ int imx_scu_irq_group_enable(u8 group, u32 mask, u8 enable)
pr_err("enable irq failed, group %d, mask %d, ret %d\n",
group, mask, ret);
if (enable)
scu_irq_wakeup[group].mask |= mask;
else
scu_irq_wakeup[group].mask &= ~mask;
return ret;
}
EXPORT_SYMBOL(imx_scu_irq_group_enable);
@ -130,6 +176,25 @@ static void imx_scu_irq_callback(struct mbox_client *c, void *msg)
schedule_work(&imx_sc_irq_work);
}
static ssize_t wakeup_source_show(struct kobject *kobj, struct kobj_attribute *attr, char *buf)
{
int i;
for (i = 0; i < IMX_SC_IRQ_NUM_GROUP; i++) {
if (!scu_irq_wakeup[i].wakeup_src)
continue;
if (scu_irq_wakeup[i].valid)
sprintf(buf, "Wakeup source group = %d, irq = 0x%x\n",
i, scu_irq_wakeup[i].wakeup_src);
else
sprintf(buf, "Spurious SCU wakeup, group = %d, irq = 0x%x\n",
i, scu_irq_wakeup[i].wakeup_src);
}
return strlen(buf);
}
int imx_scu_enable_general_irq_channel(struct device *dev)
{
struct of_phandle_args spec;
@ -169,6 +234,25 @@ int imx_scu_enable_general_irq_channel(struct device *dev)
mu_resource_id = IMX_SC_R_MU_0A + i;
/* Create directory under /sysfs/firmware */
wakeup_obj = kobject_create_and_add("scu_wakeup_source", firmware_kobj);
if (!wakeup_obj) {
ret = -ENOMEM;
goto free_ch;
}
ret = sysfs_create_file(wakeup_obj, &wakeup_source_attr.attr);
if (ret) {
dev_err(dev, "Cannot create wakeup source src file......\n");
kobject_put(wakeup_obj);
goto free_ch;
}
return 0;
free_ch:
mbox_free_channel(ch);
return ret;
}
EXPORT_SYMBOL(imx_scu_enable_general_irq_channel);

View File

@ -78,6 +78,22 @@ static int imx_scu_soc_id(void)
return msg.data.resp.id;
}
static const char *imx_scu_soc_name(u32 id)
{
switch (id) {
case 0x1:
return "i.MX8QM";
case 0x2:
return "i.MX8QXP";
case 0xe:
return "i.MX8DXL";
default:
break;
}
return "NULL";
}
int imx_scu_soc_init(struct device *dev)
{
struct soc_device_attribute *soc_dev_attr;
@ -113,9 +129,7 @@ int imx_scu_soc_init(struct device *dev)
/* format soc_id value passed from SCU firmware */
val = id & 0x1f;
soc_dev_attr->soc_id = devm_kasprintf(dev, GFP_KERNEL, "0x%x", val);
if (!soc_dev_attr->soc_id)
return -ENOMEM;
soc_dev_attr->soc_id = imx_scu_soc_name(val);
/* format revision value passed from SCU firmware */
val = (id >> 5) & 0xf;

View File

@ -20,7 +20,7 @@
#include <linux/platform_device.h>
#define SCU_MU_CHAN_NUM 8
#define MAX_RX_TIMEOUT (msecs_to_jiffies(30))
#define MAX_RX_TIMEOUT (msecs_to_jiffies(3000))
struct imx_sc_chan {
struct imx_sc_ipc *sc_ipc;
@ -353,7 +353,12 @@ static struct platform_driver imx_scu_driver = {
},
.probe = imx_scu_probe,
};
builtin_platform_driver(imx_scu_driver);
static int __init imx_scu_driver_init(void)
{
return platform_driver_register(&imx_scu_driver);
}
subsys_initcall_sync(imx_scu_driver_init);
MODULE_AUTHOR("Dong Aisheng <aisheng.dong@nxp.com>");
MODULE_DESCRIPTION("IMX SCU firmware protocol driver");

View File

@ -9,7 +9,7 @@
*/
#include <linux/clk.h>
#include <linux/of_device.h>
#include <linux/of.h>
#include <linux/platform_device.h>
#include <linux/pm_domain.h>
#include <linux/pm_runtime.h>

View File

@ -8,7 +8,8 @@
#include <linux/device.h>
#include <linux/interconnect.h>
#include <linux/module.h>
#include <linux/of_device.h>
#include <linux/of.h>
#include <linux/of_platform.h>
#include <linux/platform_device.h>
#include <linux/pm_domain.h>
#include <linux/pm_runtime.h>

View File

@ -10,7 +10,7 @@
#include <linux/device.h>
#include <linux/interconnect.h>
#include <linux/module.h>
#include <linux/of_device.h>
#include <linux/of.h>
#include <linux/platform_device.h>
#include <linux/pm_domain.h>
#include <linux/pm_runtime.h>

View File

@ -6,7 +6,7 @@
#include <linux/clk.h>
#include <linux/device.h>
#include <linux/module.h>
#include <linux/of_device.h>
#include <linux/of.h>
#include <linux/platform_device.h>
#include <linux/pm_domain.h>
#include <linux/pm_runtime.h>
@ -187,6 +187,8 @@ static int imx93_blk_ctrl_power_off(struct generic_pm_domain *genpd)
return 0;
}
static struct lock_class_key blk_ctrl_genpd_lock_class;
static int imx93_blk_ctrl_probe(struct platform_device *pdev)
{
struct device *dev = &pdev->dev;
@ -269,6 +271,19 @@ static int imx93_blk_ctrl_probe(struct platform_device *pdev)
goto cleanup_pds;
}
/*
* We use runtime PM to trigger power on/off of the upstream GPC
* domain, as a strict hierarchical parent/child power domain
* setup doesn't allow us to meet the sequencing requirements.
* This means we have nested locking of genpd locks, without the
* nesting being visible at the genpd level, so we need a
* separate lock class to make lockdep aware of the fact that
* this are separate domain locks that can be nested without a
* self-deadlock.
*/
lockdep_set_class(&domain->genpd.mlock,
&blk_ctrl_genpd_lock_class);
bc->onecell_data.domains[i] = &domain->genpd;
}

View File

@ -5,8 +5,8 @@
#include <linux/clk.h>
#include <linux/delay.h>
#include <linux/of_device.h>
#include <linux/iopoll.h>
#include <linux/mod_devicetable.h>
#include <linux/module.h>
#include <linux/platform_device.h>
#include <linux/pm_domain.h>

View File

@ -21,31 +21,37 @@ int imx_scu_enable_general_irq_channel(struct device *dev);
int imx_scu_irq_register_notifier(struct notifier_block *nb);
int imx_scu_irq_unregister_notifier(struct notifier_block *nb);
int imx_scu_irq_group_enable(u8 group, u32 mask, u8 enable);
int imx_scu_irq_get_status(u8 group, u32 *irq_status);
int imx_scu_soc_init(struct device *dev);
#else
static inline int imx_scu_soc_init(struct device *dev)
{
return -ENOTSUPP;
return -EOPNOTSUPP;
}
static inline int imx_scu_enable_general_irq_channel(struct device *dev)
{
return -ENOTSUPP;
return -EOPNOTSUPP;
}
static inline int imx_scu_irq_register_notifier(struct notifier_block *nb)
{
return -ENOTSUPP;
return -EOPNOTSUPP;
}
static inline int imx_scu_irq_unregister_notifier(struct notifier_block *nb)
{
return -ENOTSUPP;
return -EOPNOTSUPP;
}
static inline int imx_scu_irq_group_enable(u8 group, u32 mask, u8 enable)
{
return -ENOTSUPP;
return -EOPNOTSUPP;
}
static inline int imx_scu_irq_get_status(u8 group, u32 *irq_status)
{
return -EOPNOTSUPP;
}
#endif
#endif /* _SC_SCI_H */