include: Organise OOT prod headers

There is two implementation of the prod setting, legacy
where driver directly get the register offset/mask/value
and upstreamable where configuration come as property of the
respective field.

The legacy is supported till K5.15 and afterwards, the upstreamable
solution is supported.

Add the dummy header incase the core kernel have not implemented
the prods and organise the oot prod accordingly.

Bug 4097475

Change-Id: Idd0e8759342c1c4ffd88df046785595aa4fab52d
Signed-off-by: Laxman Dewangan <ldewangan@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/c/linux-nv-oot/+/2996588
GVS: Gerrit_Virtual_Submit <buildbot_gerritrpt@nvidia.com>
This commit is contained in:
Laxman Dewangan
2023-10-13 04:36:57 +00:00
committed by mobile promotions
parent a4334a5009
commit 869fff1af3
4 changed files with 117 additions and 152 deletions

View File

@@ -13,7 +13,7 @@
#include <linux/pinctrl/pinconf-generic.h>
#include <linux/pinctrl/pinmux.h>
#include <linux/slab.h>
#include <linux/tegra-prod.h>
#include <linux/tegra-oot-prod.h>
#define PCIE_PEXCLK_PADCTL1_REFCLK_OVRD_0 0x8
#define CFG2TMC_SW_CTL BIT(0)

View File

@@ -6,143 +6,21 @@
#ifndef _TEGRA_OOT_PRODS_H
#define _TEGRA_OOT_PRODS_H
#include <linux/version.h>
#if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 16, 0)
#ifdef CONFIG_TEGRA_PROD_ENABLE
#include <soc/tegra/tegra-prod.h>
#include <linux/tegra_prod.h>
#else
#include <linux/tegra-prod-upstream-dummy.h>
#include <linux/tegra-prod-legacy-dummy.h>
#endif
#else /* LINUX_VERSION_CODE */
#ifdef CONFIG_TEGRA_PROD_ENABLE
#include <linux/tegra_prod.h>
#else
/**
* Implement the tegra prod APIs as static inline with success to avoid
* the failure in client side due to prod.
*/
struct tegra_prod;
/**
* tegra_prod_set_list(): Set all prods configurations
* @base: List of IO mapped registers.
* @tegra_prod: tegra_prod handle which is allocated by devm_tegra_prod_get()
* or tegra_prod_get_from_node();
*
* Configure all the prod configuration listed on prod-setting nodes.
*
* Returns 0 on success otherwise negative error number for failed case.
*/
static inline int tegra_prod_set_list(void __iomem **base, struct tegra_prod *tegra_prod)
{
return 0;
}
/**
* tegra_prod_set_boot_init(): Set all prods configurations which has boot init
* flag on the prod setting nodes.
* @base: List of IO mapped registers.
* @tegra_prod: tegra_prod handle which is allocated by devm_tegra_prod_get()
* or tegra_prod_get_from_node();
*
* Configure all the prod configuration listed on prod-setting nodes.
*
* Returns 0 on success otherwise negative error number for failed case.
*/
static inline int tegra_prod_set_boot_init(void __iomem **base,
struct tegra_prod *tegra_prod)
{
return 0;
}
/**
* tegra_prod_set_by_name(): Set prod configuration with specific prod name.
* This is used for conditional prod configurations.
* @base: List of IO mapped registers.
* @name: Name of conditional prod which need to be configure.
* @tegra_prod: tegra_prod handle which is allocated by devm_tegra_prod_get()
* or tegra_prod_get_from_node();
*
* Configure prod configuration with specific prod name for conditional
* prod configurations.
*
* Returns 0 on success otherwise negative error number for failed case.
*/
static inline int tegra_prod_set_by_name(void __iomem **base, const char *name,
struct tegra_prod *tegra_prod)
{
return 0;
}
/**
* tegra_prod_set_by_name_partially - Set the prod setting from list partially
* under given prod name. The matching is done
* qith index, offset and mask.
* @base: base address of the register.
* @name: the name of tegra prod need to set.
* @tegra_prod: the list of tegra prods.
* @index: Index of base address.
* @offset: Offset of the register.
* @mask: Mask field on given register.
*
* Find the tegra prod in the list according to the name. Then set
* that tegra prod which has matching of index, offset and mask.
*
* Returns 0 on success.
*/
static inline int tegra_prod_set_by_name_partially(void __iomem **base, const char *name,
struct tegra_prod *tegra_prod, u32 index,
u32 offset, u32 mask)
{
return 0;
}
/**
* tegra_prod_by_name_supported - Tell whether tegra prod will be supported by
* given name or not.
* @tegra_prod: the list of tegra prods.
* @name: the name of tegra prod need to set.
*
* Find the tegra prod in the list according to the name. If it exist then
* return true else false.
*/
static inline bool tegra_prod_by_name_supported(struct tegra_prod *tegra_prod,
const char *name)
{
return true;
}
/**
* devm_tegra_prod_get(): Get the prod handle from the device.
* @dev: Device handle on which prod setting nodes are available.
*
* Parse the prod-setting node of the dev->of_node and keep all prod
* setting data in prod handle.
* This handle is used for setting prod configurations.
*
* Returns valid prod_list handle on success or pointer to the error
* when it failed.
*/
static inline struct tegra_prod *devm_tegra_prod_get(struct device *dev)
{
return (struct tegra_prod *)dev;
}
/**
* devm_tegra_prod_get_from_node(): Get the prod handle from the node.
* @dev: Device handle.
* @np: Node pointer on which prod setting nodes are available.
*
* Parse the prod-setting node of the node pointer "np" and keep all prod
* setting data in prod handle.
* This handle is used for setting prod configurations.
*
* Returns valid prod_list handle on success or pointer to the error
* when it failed.
* The allocated resource is released by driver core framework when device
* is unbinded and so no need to call any release APIs for the tegra_prod
* handle.
*/
static inline struct tegra_prod *devm_tegra_prod_get_from_node(struct device *dev,
struct device_node *np)
{
return (struct tegra_prod *)dev;
}
#endif /* CONFIG_TEGRA_PROD_ENABLE */
#include <linux/tegra-prod-legacy-dummy.h>
#endif
#endif /* LINUX_VERSION_CODE */
#endif /* _TEGRA_OOT_PRODS_H */

View File

@@ -1,10 +1,15 @@
/* SPDX-License-Identifier: GPL-2.0-only */
/*
* Copyright (c) 2014-2023, NVIDIA CORPORATION. All rights reserved.
* Copyright (c) 2023, NVIDIA CORPORATION & AFFILIATES. All rights reserved.
*/
#ifndef _TEGRA_PRODS_H
#define _TEGRA_PRODS_H
#ifndef TEGRA_PROD_LEGACY_DUMMY_H__
#define TEGRA_PROD_LEGACY_DUMMY_H__
/**
* Implement the tegra prod APIs as static inline with success to avoid
* the failure in client side due to prod.
*/
struct tegra_prod;
@@ -16,14 +21,13 @@ struct tegra_prod;
*
* Configure all the prod configuration listed on prod-setting nodes.
*
* Returns 0 on success otherwise negive error number for failed case.
* Returns 0 on success otherwise negative error number for failed case.
*/
static inline int tegra_prod_set_list(void __iomem **base, struct tegra_prod *tegra_prod)
{
return -ENOTSUPP;
return 0;
}
/**
* tegra_prod_set_boot_init(): Set all prods configurations which has boot init
* flag on the prod setting nodes.
@@ -33,11 +37,12 @@ static inline int tegra_prod_set_list(void __iomem **base, struct tegra_prod *te
*
* Configure all the prod configuration listed on prod-setting nodes.
*
* Returns 0 on success otherwise negive error number for failed case.
* Returns 0 on success otherwise negative error number for failed case.
*/
static inline int tegra_prod_set_boot_init(void __iomem **base, struct tegra_prod *tegra_prod)
static inline int tegra_prod_set_boot_init(void __iomem **base,
struct tegra_prod *tegra_prod)
{
return -ENOTSUPP;
return 0;
}
/**
@@ -51,12 +56,12 @@ static inline int tegra_prod_set_boot_init(void __iomem **base, struct tegra_pro
* Configure prod configuration with specific prod name for conditional
* prod configurations.
*
* Returns 0 on success otherwise negive error number for failed case.
* Returns 0 on success otherwise negative error number for failed case.
*/
static inline int tegra_prod_set_by_name(void __iomem **base, const char *name,
struct tegra_prod *tegra_prod)
{
return -ENOTSUPP;
return 0;
}
/**
@@ -79,7 +84,7 @@ static inline int tegra_prod_set_by_name_partially(void __iomem **base, const ch
struct tegra_prod *tegra_prod, u32 index,
u32 offset, u32 mask)
{
return -ENOTSUPP;
return 0;
}
/**
@@ -94,7 +99,7 @@ static inline int tegra_prod_set_by_name_partially(void __iomem **base, const ch
static inline bool tegra_prod_by_name_supported(struct tegra_prod *tegra_prod,
const char *name)
{
return false;
return true;
}
/**
@@ -110,7 +115,7 @@ static inline bool tegra_prod_by_name_supported(struct tegra_prod *tegra_prod,
*/
static inline struct tegra_prod *devm_tegra_prod_get(struct device *dev)
{
return ERR_PTR(-ENOTSUPP);
return (struct tegra_prod *)dev;
}
/**
@@ -131,6 +136,7 @@ static inline struct tegra_prod *devm_tegra_prod_get(struct device *dev)
static inline struct tegra_prod *devm_tegra_prod_get_from_node(struct device *dev,
struct device_node *np)
{
return ERR_PTR(-ENOTSUPP);
return (struct tegra_prod *)dev;
}
#endif
#endif /* TEGRA_PROD_LEGACY_DUMMY_H__ */

View File

@@ -0,0 +1,81 @@
/* SPDX-License-Identifier: GPL-2.0-only */
/*
* Copyright (c) 2023, NVIDIA CORPORATION. All rights reserved.
*/
#ifndef __LINUX_TEGRA_PROD_UPSTREAM_DUMMY_H__
#define __LINUX_TEGRA_PROD_UPSTREAM_DUMMY_H__
#include <linux/types.h>
/**
* Prod configuration of device provided from client.
* This structure have the details about each of prod settings.
*/
struct tegra_prod_dev_reg_field {
const char *field_name;
uint32_t reg_index;
uint32_t reg_offset;
uint32_t field_start;
uint32_t field_len;
};
/**
* Prod setting from controller where it passes the total number of registers
* having prod, and their register field names.
*/
struct tegra_prod_dev_info {
uint32_t num_total_dev_reg;
uint32_t num_dev_reg_field;
const struct tegra_prod_dev_reg_field *dev_reg_field;
};
/**
* Prod register information as register index, offset from base,
* register mask for the given prod and prod value for given
* register field.
*/
struct tegra_prod_reg_info {
uint32_t reg_index;
uint32_t reg_offset;
uint32_t reg_mask;
uint32_t reg_value;
};
/**
* Contains prod setting of all registers.
*/
struct tegra_prod_cfg_info {
const char *prod_name;
uint32_t num_reg_info;
struct tegra_prod_reg_info *reg_info;
};
/**
* Contains prod setting list of all prod values.
*/
struct tegra_prod_cfg_list {
uint32_t num_list;
struct tegra_prod_cfg_info *prod_cfg;
};
static inline struct tegra_prod_cfg_info *tegra_prod_get_by_name_from_list(struct device *dev,
const struct tegra_prod_cfg_list *prod_list,
const char *prod_name)
{
return ERR_PTR(-ENODEV);
}
static inline struct tegra_prod_cfg_list *devm_tegra_prod_get_list_from_node(struct device *dev,
const struct device_node *np,
const struct tegra_prod_dev_info *prod_dev)
{
return ERR_PTR(-ENODEV);
}
static inline struct tegra_prod_cfg_list *devm_tegra_prod_get_list(struct device *dev,
const struct tegra_prod_dev_info *prod_dev)
{
return ERR_PTR(-ENODEV);
}
#endif /* __LINUX_TEGRA_PROD_UPSTREAM_DUMMY_H__ */