mirror of
git://nv-tegra.nvidia.com/linux-nv-oot.git
synced 2025-12-24 18:21:35 +03:00
For T23x, we have a separate R5 based cluster named as Display Controller Engine(DCE) to run our Display RM code. This driver will run on CPU with the following functionality: Via debugfs for test and bring-up purposes: 1. Reads the DCE firmware image into DRAM. 2. Sets up DCE AST to cover the DCE firmware image. 3. Sets up R5 reset vector to point to DCE firmware entry point 4. Brings DCE out of reset 5. Dumps various regsiters for debug In production env: 1. Manages interrupts to CPU from DCE 2. Uses bootstrap command interface to define Admin IPC 3. Locks down bootstrap command interface 4. Uses Admin IPC to define message IPC 5. Uses Admin IPC to define message IPC payload area 6. Uses Admin IPC to set IPC channels 6. Uses Admin IPC to define crashdump area (optional) 7. Provides IPC interfaces for any DCE Client running on CCPLEX including Display RM. 8. Uses Admin IPC to set logging level (optional) This patch puts a framework in place with the following features : 1. Firmware Loading 2. AST Configuration 3. DCE Reset with EVP Programming 4. Logging Infra 5. Debugfs Support 6. Interrupt Handling 7. Mailbox Programming 8. IPC Programming 9. DCE Client Interface 10. Ftrace Support for debug purposes Change-Id: Idd28cd9254706c7313f531fcadaa7024a5b344e7 Signed-off-by: Arun Swain <arswain@nvidia.com> Reviewed-on: https://git-master.nvidia.com/r/c/linux-t23x/+/2289865 Reviewed-by: automaticguardword <automaticguardword@nvidia.com> Reviewed-by: Mahesh Kumar <mahkumar@nvidia.com> Reviewed-by: Santosh Galma <galmar@nvidia.com> Reviewed-by: Mitch Luban <mluban@nvidia.com> Reviewed-by: mobile promotions <svcmobile_promotions@nvidia.com> GVS: Gerrit_Virtual_Submit Tested-by: Mahesh Kumar <mahkumar@nvidia.com> Tested-by: mobile promotions <svcmobile_promotions@nvidia.com>
189 lines
4.7 KiB
C
189 lines
4.7 KiB
C
/*
|
|
* Copyright (c) 2019-2020, NVIDIA CORPORATION. All rights reserved.
|
|
*
|
|
* This program is free software; you can redistribute it and/or modify it
|
|
* under the terms and conditions of the GNU General Public License,
|
|
* version 2, as published by the Free Software Foundation.
|
|
*
|
|
* This program is distributed in the hope it will be useful, but WITHOUT
|
|
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
|
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
|
|
* more details.
|
|
*/
|
|
|
|
#ifndef DCE_IPC_H
|
|
#define DCE_IPC_H
|
|
|
|
#include <dce-lock.h>
|
|
#include <linux/tegra-ivc-instance.h>
|
|
#include <linux/tegra-ivc.h>
|
|
#include <interface/dce-admin-cmds.h>
|
|
#include <interface/dce-core-interface-ipc-types.h>
|
|
#include <interface/dce-ipc-state.h>
|
|
#include <linux/platform/tegra/dce/dce-client-ipc.h>
|
|
|
|
#define DCE_IPC_CHANNEL_TYPE_ADMIN 0U
|
|
#define DCE_IPC_CHANNEL_TYPE_CPU_CLIENTS 1U
|
|
|
|
#define DCE_IPC_MAX_IVC_CHANNELS 2U
|
|
|
|
/**
|
|
* TODO : Move the DispRM max to a config file
|
|
*/
|
|
#define DCE_DISPRM_CMD_MAX_NFRAMES 1U
|
|
#define DCE_DISPRM_CMD_MAX_FSIZE 4096U
|
|
#define DCE_ADMIN_CMD_MAX_FSIZE 1024U
|
|
|
|
#define DCE_IPC_WAIT_TYPE_INVALID 0U
|
|
#define DCE_IPC_WAIT_TYPE_SYNC 1U
|
|
#define DCE_IPC_WAIT_TYPE_RPC 2U
|
|
|
|
#define DCE_IPC_CHANNEL_VALID BIT(0)
|
|
#define DCE_IPC_CHANNEL_INITIALIZED BIT(1)
|
|
#define DCE_IPC_CHANNEL_SYNCED BIT(2)
|
|
#define DCE_IPC_CHANNEL_MSG_HEADER BIT(15)
|
|
|
|
#define DCE_IPC_CH_KMD_TYPE_ADMIN 0U
|
|
#define DCE_IPC_CH_KMD_TYPE_RM 1U
|
|
#define DCE_IPC_CH_KMD_TYPE_HDCP 2U
|
|
#define DCE_IPC_CH_KMD_TYPE_MAX 3U
|
|
/**
|
|
* struct dce_ipc_signal - Stores ivc channel details
|
|
*
|
|
* @d : Pointer to struct tegra_dce.
|
|
* @ibuff : Pointer to the input data buffer.
|
|
* @obuff : Pointer to the output data buffer.
|
|
* @d_ivc : Pointer to the ivc data structure.
|
|
*/
|
|
struct dce_ipc_mailbox {
|
|
u8 mb_type;
|
|
u32 mb_num;
|
|
};
|
|
|
|
/**
|
|
* TODO : Use linux doorbell driver
|
|
*/
|
|
struct dce_ipc_doorbell {
|
|
u32 db_num;
|
|
u32 db_bit;
|
|
};
|
|
|
|
struct dce_ipc_signal_instance {
|
|
u32 type;
|
|
u32 sema_num;
|
|
u32 sema_bit;
|
|
union {
|
|
struct dce_ipc_mailbox mbox;
|
|
struct dce_ipc_doorbell db;
|
|
} form;
|
|
struct dce_ipc_signal *signal;
|
|
struct dce_ipc_signal_instance *next;
|
|
};
|
|
|
|
typedef void (*dce_ipc_signal_notify)(struct tegra_dce *d,
|
|
struct dce_ipc_signal_instance *signal);
|
|
|
|
struct dce_ipc_signal {
|
|
struct dce_ipc_channel *ch;
|
|
dce_ipc_signal_notify notify;
|
|
struct dce_ipc_signal_instance to_d;
|
|
struct dce_ipc_signal_instance from_d;
|
|
};
|
|
|
|
int dce_ipc_signal_init(struct dce_ipc_channel *chan);
|
|
|
|
|
|
/**
|
|
* struct dce_ipc_region - Contains ivc region specific memory info.
|
|
*
|
|
* @size : total IVC region size.
|
|
* @tx : transmit region info.
|
|
* @rx : receive region info.
|
|
*/
|
|
struct dce_ipc_region {
|
|
u32 s_offset;
|
|
dma_addr_t iova;
|
|
unsigned long size;
|
|
void __iomem *base;
|
|
};
|
|
|
|
struct dce_ipc_queue_info {
|
|
u8 nframes;
|
|
u32 frame_sz;
|
|
dma_addr_t rx_iova;
|
|
dma_addr_t tx_iova;
|
|
};
|
|
|
|
/**
|
|
* struct dce_ipc_channel - Stores ivc channel details
|
|
*
|
|
* @d : Pointer to struct tegra_dce.
|
|
* @ibuff : Pointer to the input data buffer.
|
|
* @obuff : Pointer to the output data buffer.
|
|
* @d_ivc : Pointer to the ivc data structure.
|
|
*/
|
|
struct dce_ipc_channel {
|
|
u32 flags;
|
|
u32 w_type;
|
|
u32 ch_type;
|
|
u32 ipc_type;
|
|
void *ibuff;
|
|
void *obuff;
|
|
struct ivc d_ivc;
|
|
struct tegra_dce *d;
|
|
struct dce_mutex lock;
|
|
struct dce_ipc_signal signal;
|
|
struct dce_ipc_queue_info q_info;
|
|
};
|
|
|
|
/**
|
|
* struct dce_ipc - Stores ipc data
|
|
*
|
|
* @region - Store data about ivc region in DRAM
|
|
* @ch - Array of pointers to store dce ivc channel info
|
|
*/
|
|
struct dce_ipc {
|
|
struct dce_ipc_region region;
|
|
struct dce_ipc_channel *ch[DCE_IPC_MAX_IVC_CHANNELS];
|
|
};
|
|
|
|
int dce_ipc_send_message(struct tegra_dce *d,
|
|
u32 ch_type, const void *data, size_t size);
|
|
|
|
int dce_ipc_read_message(struct tegra_dce *d,
|
|
u32 ch_type, void *data, size_t size);
|
|
|
|
int dce_ipc_send_message_sync(struct tegra_dce *d,
|
|
u32 ch_type, struct dce_ipc_message *msg);
|
|
|
|
int dce_ipc_get_channel_info(struct tegra_dce *d,
|
|
struct dce_ipc_queue_info *q_info, u32 ch_index);
|
|
|
|
void dce_ipc_free_region(struct tegra_dce *d);
|
|
|
|
int dce_ipc_allocate_region(struct tegra_dce *d);
|
|
|
|
struct tegra_dce *dce_ipc_get_dce_from_ch(u32 ch_type);
|
|
|
|
int dce_ipc_channel_init(struct tegra_dce *d, u32 ch_type);
|
|
|
|
void dce_ipc_channel_deinit(struct tegra_dce *d, u32 ch_type);
|
|
|
|
void dce_ipc_channel_reset(struct tegra_dce *d, u32 ch_type);
|
|
|
|
uint32_t dce_ipc_get_ipc_type(struct tegra_dce *d, u32 ch_type);
|
|
|
|
bool dce_ipc_channel_is_ready(struct tegra_dce *d, u32 ch_type);
|
|
|
|
u32 dce_ipc_get_cur_wait_type(struct tegra_dce *d, u32 ch_type);
|
|
|
|
bool dce_ipc_is_data_available(struct tegra_dce *d, u32 ch_type);
|
|
|
|
int dce_ipc_get_region_iova_info(struct tegra_dce *d, u64 *iova, u32 *size);
|
|
|
|
int dce_ipc_init_signaling(struct tegra_dce *d, struct dce_ipc_channel *ch);
|
|
|
|
void dce_ipc_deinit_signaling(struct tegra_dce *d, struct dce_ipc_channel *ch);
|
|
|
|
#endif
|