Resguardo inicial

This commit is contained in:
lastdragon
2026-09-06 12:53:21 -06:00
parent 662efe3c2a
commit ad2088d178
94853 changed files with 43200404 additions and 0 deletions
@@ -0,0 +1,71 @@
/* SPDX-License-Identifier: GPL-2.0+ */
/*
* Copyright 2019 NXP
*
* Header file for the DSP IPC implementation
*/
#ifndef _IMX_DSP_IPC_H
#define _IMX_DSP_IPC_H
#include <linux/device.h>
#include <linux/types.h>
#include <linux/mailbox_client.h>
#define DSP_MU_CHAN_NUM 4
struct imx_dsp_chan {
struct imx_dsp_ipc *ipc;
struct mbox_client cl;
struct mbox_chan *ch;
char *name;
int idx;
};
struct imx_dsp_ops {
void (*handle_reply)(struct imx_dsp_ipc *ipc);
void (*handle_request)(struct imx_dsp_ipc *ipc);
};
struct imx_dsp_ipc {
/* Host <-> DSP communication uses 2 txdb and 2 rxdb channels */
struct imx_dsp_chan chans[DSP_MU_CHAN_NUM];
struct device *dev;
struct imx_dsp_ops *ops;
void *private_data;
};
static inline void imx_dsp_set_data(struct imx_dsp_ipc *ipc, void *data)
{
ipc->private_data = data;
}
static inline void *imx_dsp_get_data(struct imx_dsp_ipc *ipc)
{
return ipc->private_data;
}
#if IS_ENABLED(CONFIG_IMX_DSP)
int imx_dsp_ring_doorbell(struct imx_dsp_ipc *dsp, unsigned int chan_idx);
struct mbox_chan *imx_dsp_request_channel(struct imx_dsp_ipc *ipc, int idx);
void imx_dsp_free_channel(struct imx_dsp_ipc *ipc, int idx);
#else
static inline int imx_dsp_ring_doorbell(struct imx_dsp_ipc *ipc,
unsigned int chan_idx)
{
return -ENOTSUPP;
}
struct mbox_chan *imx_dsp_request_channel(struct imx_dsp_ipc *ipc, int idx)
{
return ERR_PTR(-EOPNOTSUPP);
}
void imx_dsp_free_channel(struct imx_dsp_ipc *ipc, int idx) { }
#endif
#endif /* _IMX_DSP_IPC_H */
@@ -0,0 +1,71 @@
/* SPDX-License-Identifier: GPL-2.0+ */
/*
* Copyright 2018 NXP
*
* Header file for the IPC implementation.
*/
#ifndef _SC_IPC_H
#define _SC_IPC_H
#include <linux/device.h>
#include <linux/types.h>
#define IMX_SC_RPC_VERSION 1
#define IMX_SC_RPC_MAX_MSG 8
struct imx_sc_ipc;
enum imx_sc_rpc_svc {
IMX_SC_RPC_SVC_UNKNOWN = 0,
IMX_SC_RPC_SVC_RETURN = 1,
IMX_SC_RPC_SVC_PM = 2,
IMX_SC_RPC_SVC_RM = 3,
IMX_SC_RPC_SVC_TIMER = 5,
IMX_SC_RPC_SVC_PAD = 6,
IMX_SC_RPC_SVC_MISC = 7,
IMX_SC_RPC_SVC_IRQ = 8,
};
struct imx_sc_rpc_msg {
uint8_t ver;
uint8_t size;
uint8_t svc;
uint8_t func;
};
#ifdef CONFIG_IMX_SCU
/*
* This is an function to send an RPC message over an IPC channel.
* It is called by client-side SCFW API function shims.
*
* @param[in] ipc IPC handle
* @param[in,out] msg handle to a message
* @param[in] have_resp response flag
*
* If have_resp is true then this function waits for a response
* and returns the result in msg.
*/
int imx_scu_call_rpc(struct imx_sc_ipc *ipc, void *msg, bool have_resp);
/*
* This function gets the default ipc handle used by SCU
*
* @param[out] ipc sc ipc handle
*
* @return Returns an error code (0 = success, failed if < 0)
*/
int imx_scu_get_handle(struct imx_sc_ipc **ipc);
#else
static inline int imx_scu_call_rpc(struct imx_sc_ipc *ipc, void *msg,
bool have_resp)
{
return -ENOTSUPP;
}
static inline int imx_scu_get_handle(struct imx_sc_ipc **ipc)
{
return -ENOTSUPP;
}
#endif
#endif /* _SC_IPC_H */
@@ -0,0 +1,20 @@
/* SPDX-License-Identifier: GPL-2.0+ */
/*
* Copyright 2021 NXP
*
* Header file for the IPC implementation.
*/
#ifndef _S4_IPC_H
#define _S4_IPC_H
struct imx_s4_ipc;
struct imx_s4_rpc_msg {
uint8_t ver;
uint8_t size;
uint8_t cmd;
uint8_t tag;
} __packed;
#endif /* _S4_IPC_H */
@@ -0,0 +1,57 @@
/* SPDX-License-Identifier: GPL-2.0+ */
/*
* Copyright (C) 2016 Freescale Semiconductor, Inc.
* Copyright 2017~2018 NXP
*
* Header file containing the public System Controller Interface (SCI)
* definitions.
*/
#ifndef _SC_SCI_H
#define _SC_SCI_H
#include <linux/firmware/imx/ipc.h>
#include <linux/firmware/imx/svc/misc.h>
#include <linux/firmware/imx/svc/pm.h>
#include <linux/firmware/imx/svc/rm.h>
#if IS_ENABLED(CONFIG_IMX_SCU)
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 -EOPNOTSUPP;
}
static inline int imx_scu_enable_general_irq_channel(struct device *dev)
{
return -EOPNOTSUPP;
}
static inline int imx_scu_irq_register_notifier(struct notifier_block *nb)
{
return -EOPNOTSUPP;
}
static inline int imx_scu_irq_unregister_notifier(struct notifier_block *nb)
{
return -EOPNOTSUPP;
}
static inline int imx_scu_irq_group_enable(u8 group, u32 mask, u8 enable)
{
return -EOPNOTSUPP;
}
static inline int imx_scu_irq_get_status(u8 group, u32 *irq_status)
{
return -EOPNOTSUPP;
}
#endif
#endif /* _SC_SCI_H */
@@ -0,0 +1,99 @@
/* SPDX-License-Identifier: GPL-2.0+ */
/*
* Copyright 2024 NXP
*/
#ifndef _SCMI_IMX_H
#define _SCMI_IMX_H
#include <linux/bitfield.h>
#include <linux/errno.h>
#include <linux/scmi_imx_protocol.h>
#include <linux/types.h>
#define SCMI_IMX95_CTRL_PDM_CLK_SEL 0 /* AON PDM clock sel */
#define SCMI_IMX95_CTRL_MQS1_SETTINGS 1 /* AON MQS settings */
#define SCMI_IMX95_CTRL_SAI1_MCLK 2 /* AON SAI1 MCLK */
#define SCMI_IMX95_CTRL_SAI3_MCLK 3 /* WAKE SAI3 MCLK */
#define SCMI_IMX95_CTRL_SAI4_MCLK 4 /* WAKE SAI4 MCLK */
#define SCMI_IMX95_CTRL_SAI5_MCLK 5 /* WAKE SAI5 MCLK */
#define SCMI_IMX94_CTRL_PDM_CLK_SEL 0U /*!< AON PDM clock sel */
#define SCMI_IMX94_CTRL_MQS1_SETTINGS 1U /*!< AON MQS settings */
#define SCMI_IMX94_CTRL_MQS2_SETTINGS 2U /*!< WAKE MQS settings */
#define SCMI_IMX94_CTRL_SAI1_MCLK 3U /*!< AON SAI1 MCLK */
#define SCMI_IMX94_CTRL_SAI2_MCLK 4U /*!< WAKE SAI2 MCLK */
#define SCMI_IMX94_CTRL_SAI3_MCLK 5U /*!< WAKE SAI3 MCLK */
#define SCMI_IMX94_CTRL_SAI4_MCLK 6U /*!< WAKE SAI4 MCLK */
#define SCMI_IMX952_CTRL_BYPASS_AUDMIX 8U /* WAKE AUDMIX */
#if IS_ENABLED(CONFIG_IMX_SCMI_MISC_DRV)
int scmi_imx_misc_ctrl_get(u32 id, u32 *num, u32 *val);
int scmi_imx_misc_ctrl_set(u32 id, u32 val);
#else
static inline int scmi_imx_misc_ctrl_get(u32 id, u32 *num, u32 *val)
{
return -EOPNOTSUPP;
}
static inline int scmi_imx_misc_ctrl_set(u32 id, u32 val)
{
return -EOPNOTSUPP;
}
#endif
#if IS_ENABLED(CONFIG_IMX_SCMI_CPU_DRV)
int scmi_imx_cpu_start(u32 cpuid, bool start);
int scmi_imx_cpu_started(u32 cpuid, bool *started);
int scmi_imx_cpu_reset_vector_set(u32 cpuid, u64 vector, bool start, bool boot,
bool resume);
#else
static inline int scmi_imx_cpu_start(u32 cpuid, bool start)
{
return -EOPNOTSUPP;
}
static inline int scmi_imx_cpu_started(u32 cpuid, bool *started)
{
return -EOPNOTSUPP;
}
static inline int scmi_imx_cpu_reset_vector_set(u32 cpuid, u64 vector, bool start,
bool boot, bool resume)
{
return -EOPNOTSUPP;
}
#endif
enum scmi_imx_lmm_op {
SCMI_IMX_LMM_BOOT,
SCMI_IMX_LMM_POWER_ON,
SCMI_IMX_LMM_SHUTDOWN,
};
/* For shutdown pperation */
#define SCMI_IMX_LMM_OP_FORCEFUL 0
#define SCMI_IMX_LMM_OP_GRACEFUL BIT(0)
#if IS_ENABLED(CONFIG_IMX_SCMI_LMM_DRV)
int scmi_imx_lmm_operation(u32 lmid, enum scmi_imx_lmm_op op, u32 flags);
int scmi_imx_lmm_info(u32 lmid, struct scmi_imx_lmm_info *info);
int scmi_imx_lmm_reset_vector_set(u32 lmid, u32 cpuid, u32 flags, u64 vector);
#else
static inline int scmi_imx_lmm_operation(u32 lmid, enum scmi_imx_lmm_op op, u32 flags)
{
return -EOPNOTSUPP;
}
static inline int scmi_imx_lmm_info(u32 lmid, struct scmi_imx_lmm_info *info)
{
return -EOPNOTSUPP;
}
static inline int scmi_imx_lmm_reset_vector_set(u32 lmid, u32 cpuid, u32 flags, u64 vector)
{
return -EOPNOTSUPP;
}
#endif
#endif
@@ -0,0 +1,77 @@
/* SPDX-License-Identifier: GPL-2.0+ */
/*
* Copyright (C) 2016 Freescale Semiconductor, Inc.
* Copyright 2017~2018 NXP
*
* Header file containing the public API for the System Controller (SC)
* Miscellaneous (MISC) function.
*
* MISC_SVC (SVC) Miscellaneous Service
*
* Module for the Miscellaneous (MISC) service.
*/
#ifndef _SC_MISC_API_H
#define _SC_MISC_API_H
#include <linux/firmware/imx/sci.h>
/*
* This type is used to indicate RPC MISC function calls.
*/
enum imx_misc_func {
IMX_SC_MISC_FUNC_UNKNOWN = 0,
IMX_SC_MISC_FUNC_SET_CONTROL = 1,
IMX_SC_MISC_FUNC_GET_CONTROL = 2,
IMX_SC_MISC_FUNC_SET_MAX_DMA_GROUP = 4,
IMX_SC_MISC_FUNC_SET_DMA_GROUP = 5,
IMX_SC_MISC_FUNC_SECO_IMAGE_LOAD = 8,
IMX_SC_MISC_FUNC_SECO_AUTHENTICATE = 9,
IMX_SC_MISC_FUNC_DEBUG_OUT = 10,
IMX_SC_MISC_FUNC_WAVEFORM_CAPTURE = 6,
IMX_SC_MISC_FUNC_BUILD_INFO = 15,
IMX_SC_MISC_FUNC_UNIQUE_ID = 19,
IMX_SC_MISC_FUNC_SET_ARI = 3,
IMX_SC_MISC_FUNC_BOOT_STATUS = 7,
IMX_SC_MISC_FUNC_BOOT_DONE = 14,
IMX_SC_MISC_FUNC_OTP_FUSE_READ = 11,
IMX_SC_MISC_FUNC_OTP_FUSE_WRITE = 17,
IMX_SC_MISC_FUNC_SET_TEMP = 12,
IMX_SC_MISC_FUNC_GET_TEMP = 13,
IMX_SC_MISC_FUNC_GET_BOOT_DEV = 16,
IMX_SC_MISC_FUNC_GET_BUTTON_STATUS = 18,
};
/*
* Control Functions
*/
#ifdef CONFIG_IMX_SCU
int imx_sc_misc_set_control(struct imx_sc_ipc *ipc, u32 resource,
u8 ctrl, u32 val);
int imx_sc_misc_get_control(struct imx_sc_ipc *ipc, u32 resource,
u8 ctrl, u32 *val);
int imx_sc_pm_cpu_start(struct imx_sc_ipc *ipc, u32 resource,
bool enable, u64 phys_addr);
#else
static inline int imx_sc_misc_set_control(struct imx_sc_ipc *ipc,
u32 resource, u8 ctrl, u32 val)
{
return -ENOTSUPP;
}
static inline int imx_sc_misc_get_control(struct imx_sc_ipc *ipc,
u32 resource, u8 ctrl, u32 *val)
{
return -ENOTSUPP;
}
static inline int imx_sc_pm_cpu_start(struct imx_sc_ipc *ipc, u32 resource,
bool enable, u64 phys_addr)
{
return -ENOTSUPP;
}
#endif
#endif /* _SC_MISC_API_H */
@@ -0,0 +1,85 @@
/* SPDX-License-Identifier: GPL-2.0+ */
/*
* Copyright (C) 2016 Freescale Semiconductor, Inc.
* Copyright 2017-2018 NXP
*
* Header file containing the public API for the System Controller (SC)
* Power Management (PM) function. This includes functions for power state
* control, clock control, reset control, and wake-up event control.
*
* PM_SVC (SVC) Power Management Service
*
* Module for the Power Management (PM) service.
*/
#ifndef _SC_PM_API_H
#define _SC_PM_API_H
#include <linux/firmware/imx/sci.h>
/*
* This type is used to indicate RPC PM function calls.
*/
enum imx_sc_pm_func {
IMX_SC_PM_FUNC_UNKNOWN = 0,
IMX_SC_PM_FUNC_SET_SYS_POWER_MODE = 19,
IMX_SC_PM_FUNC_SET_PARTITION_POWER_MODE = 1,
IMX_SC_PM_FUNC_GET_SYS_POWER_MODE = 2,
IMX_SC_PM_FUNC_SET_RESOURCE_POWER_MODE = 3,
IMX_SC_PM_FUNC_GET_RESOURCE_POWER_MODE = 4,
IMX_SC_PM_FUNC_REQ_LOW_POWER_MODE = 16,
IMX_SC_PM_FUNC_SET_CPU_RESUME_ADDR = 17,
IMX_SC_PM_FUNC_REQ_SYS_IF_POWER_MODE = 18,
IMX_SC_PM_FUNC_SET_CLOCK_RATE = 5,
IMX_SC_PM_FUNC_GET_CLOCK_RATE = 6,
IMX_SC_PM_FUNC_CLOCK_ENABLE = 7,
IMX_SC_PM_FUNC_SET_CLOCK_PARENT = 14,
IMX_SC_PM_FUNC_GET_CLOCK_PARENT = 15,
IMX_SC_PM_FUNC_RESET = 13,
IMX_SC_PM_FUNC_RESET_REASON = 10,
IMX_SC_PM_FUNC_BOOT = 8,
IMX_SC_PM_FUNC_REBOOT = 9,
IMX_SC_PM_FUNC_REBOOT_PARTITION = 12,
IMX_SC_PM_FUNC_CPU_START = 11,
};
/*
* Defines for ALL parameters
*/
#define IMX_SC_PM_CLK_ALL UINT8_MAX /* All clocks */
/*
* Defines for SC PM Power Mode
*/
#define IMX_SC_PM_PW_MODE_OFF 0 /* Power off */
#define IMX_SC_PM_PW_MODE_STBY 1 /* Power in standby */
#define IMX_SC_PM_PW_MODE_LP 2 /* Power in low-power */
#define IMX_SC_PM_PW_MODE_ON 3 /* Power on */
/*
* Defines for SC PM CLK
*/
#define IMX_SC_PM_CLK_SLV_BUS 0 /* Slave bus clock */
#define IMX_SC_PM_CLK_MST_BUS 1 /* Master bus clock */
#define IMX_SC_PM_CLK_PER 2 /* Peripheral clock */
#define IMX_SC_PM_CLK_PHY 3 /* Phy clock */
#define IMX_SC_PM_CLK_MISC 4 /* Misc clock */
#define IMX_SC_PM_CLK_MISC0 0 /* Misc 0 clock */
#define IMX_SC_PM_CLK_MISC1 1 /* Misc 1 clock */
#define IMX_SC_PM_CLK_MISC2 2 /* Misc 2 clock */
#define IMX_SC_PM_CLK_MISC3 3 /* Misc 3 clock */
#define IMX_SC_PM_CLK_MISC4 4 /* Misc 4 clock */
#define IMX_SC_PM_CLK_CPU 2 /* CPU clock */
#define IMX_SC_PM_CLK_PLL 4 /* PLL */
#define IMX_SC_PM_CLK_BYPASS 4 /* Bypass clock */
/*
* Defines for SC PM CLK Parent
*/
#define IMX_SC_PM_PARENT_XTAL 0 /* Parent is XTAL. */
#define IMX_SC_PM_PARENT_PLL0 1 /* Parent is PLL0 */
#define IMX_SC_PM_PARENT_PLL1 2 /* Parent is PLL1 or PLL0/2 */
#define IMX_SC_PM_PARENT_PLL2 3 /* Parent in PLL2 or PLL0/4 */
#define IMX_SC_PM_PARENT_BYPS 4 /* Parent is a bypass clock. */
#endif /* _SC_PM_API_H */
@@ -0,0 +1,74 @@
/* SPDX-License-Identifier: GPL-2.0+ */
/*
* Copyright (C) 2016 Freescale Semiconductor, Inc.
* Copyright 2017-2020 NXP
*
* Header file containing the public API for the System Controller (SC)
* Resource Management (RM) function. This includes functions for
* partitioning resources, pads, and memory regions.
*
* RM_SVC (SVC) Resource Management Service
*
* Module for the Resource Management (RM) service.
*/
#ifndef _SC_RM_API_H
#define _SC_RM_API_H
#include <linux/firmware/imx/sci.h>
/*
* This type is used to indicate RPC RM function calls.
*/
enum imx_sc_rm_func {
IMX_SC_RM_FUNC_UNKNOWN = 0,
IMX_SC_RM_FUNC_PARTITION_ALLOC = 1,
IMX_SC_RM_FUNC_SET_CONFIDENTIAL = 31,
IMX_SC_RM_FUNC_PARTITION_FREE = 2,
IMX_SC_RM_FUNC_GET_DID = 26,
IMX_SC_RM_FUNC_PARTITION_STATIC = 3,
IMX_SC_RM_FUNC_PARTITION_LOCK = 4,
IMX_SC_RM_FUNC_GET_PARTITION = 5,
IMX_SC_RM_FUNC_SET_PARENT = 6,
IMX_SC_RM_FUNC_MOVE_ALL = 7,
IMX_SC_RM_FUNC_ASSIGN_RESOURCE = 8,
IMX_SC_RM_FUNC_SET_RESOURCE_MOVABLE = 9,
IMX_SC_RM_FUNC_SET_SUBSYS_RSRC_MOVABLE = 28,
IMX_SC_RM_FUNC_SET_MASTER_ATTRIBUTES = 10,
IMX_SC_RM_FUNC_SET_MASTER_SID = 11,
IMX_SC_RM_FUNC_SET_PERIPHERAL_PERMISSIONS = 12,
IMX_SC_RM_FUNC_IS_RESOURCE_OWNED = 13,
IMX_SC_RM_FUNC_GET_RESOURCE_OWNER = 33,
IMX_SC_RM_FUNC_IS_RESOURCE_MASTER = 14,
IMX_SC_RM_FUNC_IS_RESOURCE_PERIPHERAL = 15,
IMX_SC_RM_FUNC_GET_RESOURCE_INFO = 16,
IMX_SC_RM_FUNC_MEMREG_ALLOC = 17,
IMX_SC_RM_FUNC_MEMREG_SPLIT = 29,
IMX_SC_RM_FUNC_MEMREG_FRAG = 32,
IMX_SC_RM_FUNC_MEMREG_FREE = 18,
IMX_SC_RM_FUNC_FIND_MEMREG = 30,
IMX_SC_RM_FUNC_ASSIGN_MEMREG = 19,
IMX_SC_RM_FUNC_SET_MEMREG_PERMISSIONS = 20,
IMX_SC_RM_FUNC_IS_MEMREG_OWNED = 21,
IMX_SC_RM_FUNC_GET_MEMREG_INFO = 22,
IMX_SC_RM_FUNC_ASSIGN_PAD = 23,
IMX_SC_RM_FUNC_SET_PAD_MOVABLE = 24,
IMX_SC_RM_FUNC_IS_PAD_OWNED = 25,
IMX_SC_RM_FUNC_DUMP = 27,
};
#if IS_ENABLED(CONFIG_IMX_SCU)
bool imx_sc_rm_is_resource_owned(struct imx_sc_ipc *ipc, u16 resource);
int imx_sc_rm_get_resource_owner(struct imx_sc_ipc *ipc, u16 resource, u8 *pt);
#else
static inline bool
imx_sc_rm_is_resource_owned(struct imx_sc_ipc *ipc, u16 resource)
{
return true;
}
static inline int imx_sc_rm_get_resource_owner(struct imx_sc_ipc *ipc, u16 resource, u8 *pt)
{
return -EOPNOTSUPP;
}
#endif
#endif