video: camera: Port RTCPU drivers to OOT tree

Port RTCPU drivers from kernel/nvidia to kernel/nvidia-oot.
In addition to copying the files this patch:
1) Modifies make files to build rtcpu drivers as modules
2) Modifies licenses of all ported files to SPDX
3) Adds MODULE_LICENSE macro to all modules
4) Removes checks for old kernel versions and the dead code after those checks
5) Fixes style errors according to checkpatch.pl

Change-Id: If64296a22ce958e5326c7509cb69f8f7154f598e
Signed-off-by: Frank Chen <frankc@nvidia.com>
Signed-off-by: Matti Ryttylainen <mryttylainen@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/c/linux-nv-oot/+/2783040
Reviewed-by: Laxman Dewangan <ldewangan@nvidia.com>
Reviewed-by: Ankur Pawar <ankurp@nvidia.com>
Reviewed-by: Semi Malinen <smalinen@nvidia.com>
Reviewed-by: Pekka Pessi <ppessi@nvidia.com>
GVS: Gerrit_Virtual_Submit <buildbot_gerritrpt@nvidia.com>
This commit is contained in:
Frank Chen
2022-09-26 13:29:09 -07:00
committed by mobile promotions
parent 43ae0060cd
commit 304123a3bf
32 changed files with 10802 additions and 0 deletions

View File

@@ -0,0 +1,27 @@
/* SPDX-License-Identifier: GPL-2.0-only */
/*
* Copyright (c) 2022, NVIDIA CORPORATION & AFFILIATES. All rights reserved.
*/
#ifndef _LINUX_TEGRA_CAMERA_RTCPU_H_
#define _LINUX_TEGRA_CAMERA_RTCPU_H_
#include <linux/types.h>
struct device;
int tegra_camrtc_iovm_setup(struct device *dev, dma_addr_t iova);
ssize_t tegra_camrtc_print_version(struct device *dev, char *buf, size_t size);
int tegra_camrtc_reboot(struct device *dev);
int tegra_camrtc_restore(struct device *dev);
bool tegra_camrtc_is_rtcpu_alive(struct device *dev);
void tegra_camrtc_flush_trace(struct device *dev);
bool tegra_camrtc_is_rtcpu_powered(void);
#define TEGRA_CAMRTC_VERSION_LEN 128
int tegra_camrtc_ping(struct device *dev, u32 data, long timeout);
void tegra_camrtc_ivc_ring(struct device *dev, u16 group);
#endif

View File

@@ -0,0 +1,136 @@
/* SPDX-License-Identifier: GPL-2.0-only */
/*
* Copyright (c) 2022, NVIDIA CORPORATION & AFFILIATES. All rights reserved.
*/
#ifndef INCLUDE_CAPTURE_IVC_H
#define INCLUDE_CAPTURE_IVC_H
#include <linux/types.h>
/**
* @brief Submit the control message binary blob to capture-IVC driver,
* which is to be transferred over control IVC channel to RTCPU.
*
* @param[in] control_desc binary blob containing control message
* descriptor, is opaque to capture-IVC driver.
* @param[in] len size of control_desc.
*
* @returns 0 (success), neg. errno (failure)
*/
int tegra_capture_ivc_control_submit(
const void *control_desc,
size_t len);
/**
* @brief Submit the capture message binary blob to capture-IVC driver,
* which is to be transferred over capture IVC channel to RTCPU.
*
* @param[in] capture_desc binary blob containing capture message
* descriptor, is opaque to KMDs.
* @param[in] len size of capture_desc.
*
* @returns 0 (success), neg. errno (failure)
*/
int tegra_capture_ivc_capture_submit(
const void *capture_desc,
size_t len);
/**
* @brief Callback function to be registered by client to receive the rtcpu
* notifications through control or capture IVC channel.
*
* @param[in] resp_desc binary blob containing the response message
* received from rtcpu through control or capture
* IVC channel, its opaque to KMDs.
* @param[in] priv_context Client's private context, opaque to
* capture-IVC driver.
*/
typedef void (*tegra_capture_ivc_cb_func)(
const void *resp_desc,
const void *priv_context);
/**
* @brief Register callback function to receive response messages from rtcpu
* through control IVC channel.
*
* @param[in] control_resp_cb callback function to be registered for
* control IVC channel.
* @param[in] priv_context client's private context, opaque to
* capture-IVC driver.
* @param[out] trans_id temporary id assigned by capture-IVC driver,
* for the clients whose unique chan_id is not
* yet allocated by RTCPU, to match their
* responses with the requests.
*
* @returns 0 (success), neg. errno (failure)
*/
int tegra_capture_ivc_register_control_cb(
tegra_capture_ivc_cb_func control_resp_cb,
uint32_t *trans_id,
const void *priv_context);
/**
* @brief Notify clients channel ID to capture-IVC driver.
* Once client gets the newly allocated channel ID from RTCPU, it has to
* notify it to capture-IVC driver also, so that it can replace the
* temporary ID trans_id with the new channel ID chan_id in its internal
* context. IVC driver uses this unique channel ID for mapping upcoming
* responses with the client requests.
*
* @param[in] chan_id new channel id allocated by RTCPU for the
* client, capture-IVC driver uses to refer the
* client for its future control responses.
* @param[in] trans_id temporary id assigned by capture-IVC driver,
* for the client.
*
* @returns 0 (success), neg. errno (failure)
*/
int tegra_capture_ivc_notify_chan_id(
uint32_t chan_id,
uint32_t trans_id);
/**
* @brief Register callback function to receive status-indication messages from
* rtcpu through capture IVC channel.
*
* @param[in] capture_status_ind_cb callback function to be registered for
* capture ivc channel.
* @param[in] chan_id client's channel id, capture-IVC driver
* uses it refer the client for its capture
* responses.
* @param[in] priv_context client's private context, opaque to
* capture-IVC driver.
*
* @returns 0 (success), neg. errno (failure)
*/
int tegra_capture_ivc_register_capture_cb(
tegra_capture_ivc_cb_func capture_status_ind_cb,
uint32_t chan_id,
const void *priv_context);
/**
* @brief Un-register callback function to stop receiving messages over
* control ivc channel.
*
* @param[in] id client's channel id or transaction id, for which the
* callback needs to be unregistered.
*
* @returns 0 (success), neg. errno (failure)
*/
int tegra_capture_ivc_unregister_control_cb(
uint32_t id);
/**
* @brief Un-register callback function to stop receiving messages over
* capture ivc channel.
*
* @param[in] chan_id client's channel id, for which the callback needs to be
* unregistered.
*
* @returns 0 (success), neg. errno (failure)
*/
int tegra_capture_ivc_unregister_capture_cb(
uint32_t chan_id);
#endif /* INCLUDE_CAPTURE_IVC_H */

View File

@@ -0,0 +1,137 @@
/* SPDX-License-Identifier: GPL-2.0-only */
/*
* Copyright (c) 2022, NVIDIA CORPORATION & AFFILIATES. All rights reserved.
*/
#ifndef _LINUX_TEGRA_IVC_BUS_H
#define _LINUX_TEGRA_IVC_BUS_H
#include <linux/tegra-ivc-instance.h>
#include <linux/types.h>
extern struct bus_type tegra_ivc_bus_type;
extern struct device_type tegra_ivc_bus_dev_type;
struct tegra_ivc_bus;
struct tegra_ivc_rpc_data;
struct tegra_ivc_bus *tegra_ivc_bus_create(struct device *);
void tegra_ivc_bus_ready(struct tegra_ivc_bus *bus, bool online);
void tegra_ivc_bus_destroy(struct tegra_ivc_bus *bus);
int tegra_ivc_bus_boot_sync(struct tegra_ivc_bus *bus);
void tegra_ivc_bus_notify(struct tegra_ivc_bus *bus, u16 group);
struct tegra_ivc_driver {
struct device_driver driver;
struct device_type *dev_type;
union {
const struct tegra_ivc_channel_ops *channel;
} ops;
};
static inline struct tegra_ivc_driver *to_tegra_ivc_driver(
struct device_driver *drv)
{
if (drv == NULL)
return NULL;
return container_of(drv, struct tegra_ivc_driver, driver);
}
int tegra_ivc_driver_register(struct tegra_ivc_driver *drv);
void tegra_ivc_driver_unregister(struct tegra_ivc_driver *drv);
#define tegra_ivc_module_driver(drv) \
module_driver(drv, tegra_ivc_driver_register, \
tegra_ivc_driver_unregister)
#define tegra_ivc_subsys_driver(__driver, __register, __unregister, ...) \
static int __init __driver##_init(void) \
{ \
return __register(&(__driver), ##__VA_ARGS__); \
} \
subsys_initcall_sync(__driver##_init);
#define tegra_ivc_subsys_driver_default(__driver) \
tegra_ivc_subsys_driver(__driver, \
tegra_ivc_driver_register, \
tegra_ivc_driver_unregister)
/* IVC channel driver support */
extern struct device_type tegra_ivc_channel_type;
struct tegra_ivc_channel {
struct ivc ivc;
struct device dev;
const struct tegra_ivc_channel_ops __rcu *ops;
struct tegra_ivc_channel *next;
struct mutex ivc_wr_lock;
struct tegra_ivc_rpc_data *rpc_priv;
atomic_t bus_resets;
u16 group;
bool is_ready;
};
static inline bool tegra_ivc_channel_online_check(
struct tegra_ivc_channel *chan)
{
atomic_set(&chan->bus_resets, 0);
smp_wmb();
smp_rmb();
return chan->is_ready;
}
static inline bool tegra_ivc_channel_has_been_reset(
struct tegra_ivc_channel *chan)
{
smp_rmb();
return atomic_read(&chan->bus_resets) != 0;
}
static inline void *tegra_ivc_channel_get_drvdata(
struct tegra_ivc_channel *chan)
{
return dev_get_drvdata(&chan->dev);
}
static inline void tegra_ivc_channel_set_drvdata(
struct tegra_ivc_channel *chan, void *data)
{
dev_set_drvdata(&chan->dev, data);
}
static inline struct tegra_ivc_channel *to_tegra_ivc_channel(
struct device *dev)
{
return container_of(dev, struct tegra_ivc_channel, dev);
}
static inline struct device *tegra_ivc_channel_to_camrtc_dev(
struct tegra_ivc_channel *ch)
{
if (unlikely(ch == NULL))
return NULL;
BUG_ON(ch->dev.parent == NULL);
BUG_ON(ch->dev.parent->parent == NULL);
return ch->dev.parent->parent;
}
int tegra_ivc_channel_runtime_get(struct tegra_ivc_channel *chan);
void tegra_ivc_channel_runtime_put(struct tegra_ivc_channel *chan);
struct tegra_ivc_channel_ops {
int (*probe)(struct tegra_ivc_channel *);
void (*ready)(struct tegra_ivc_channel *, bool online);
void (*remove)(struct tegra_ivc_channel *);
void (*notify)(struct tegra_ivc_channel *);
};
/* Legacy mailbox support */
struct tegra_ivc_mbox_msg {
int length;
void *data;
};
#endif

View File

@@ -0,0 +1,16 @@
/* SPDX-License-Identifier: GPL-2.0-only */
/*
* Copyright (c) 2022, NVIDIA CORPORATION & AFFILIATES. All rights reserved.
*/
#ifndef INCLUDE_RTCPU_MONITOR_H
#define INCLUDE_RTCPU_MONITOR_H
struct device;
struct tegra_camrtc_mon;
int tegra_camrtc_mon_restore_rtcpu(struct tegra_camrtc_mon *);
struct tegra_camrtc_mon *tegra_camrtc_mon_create(struct device *);
int tegra_cam_rtcpu_mon_destroy(struct tegra_camrtc_mon *);
#endif /* INCLUDE_RTCPU_MONITOR_H */

View File

@@ -0,0 +1,21 @@
/* SPDX-License-Identifier: GPL-2.0-only */
/*
* Copyright (c) 2022, NVIDIA CORPORATION & AFFILIATES. All rights reserved.
*/
#ifndef _LINUX_TEGRA_RTCPU_TRACE_H_
#define _LINUX_TEGRA_RTCPU_TRACE_H_
#include <linux/types.h>
struct tegra_rtcpu_trace;
struct camrtc_device_group;
struct tegra_rtcpu_trace *tegra_rtcpu_trace_create(
struct device *dev,
struct camrtc_device_group *camera_devices);
int tegra_rtcpu_trace_boot_sync(struct tegra_rtcpu_trace *tracer);
void tegra_rtcpu_trace_flush(struct tegra_rtcpu_trace *tracer);
void tegra_rtcpu_trace_destroy(struct tegra_rtcpu_trace *tracer);
#endif