mirror of
git://nv-tegra.nvidia.com/kernel/nvethernetrm.git
synced 2025-12-23 09:56:41 +03:00
nvethernetrm: move core_backup to osi_common.h
Issue: RFE: move struct core_backup to osi_common.h
Fix:
1. Moved core_backup to osi_common.h
2. Added generic osi_mac_restore_registers() and osi_mac_save_registers()
Api's in osi_common.c
Bug 2804631
Change-Id: I5bc71666e104f2e729024e096bd51ce350f2a1f0
Signed-off-by: Mahesh Patil <maheshp@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/c/kernel/nvethernetrm/+/2286642
Reviewed-by: svc-mobile-coverity <svc-mobile-coverity@nvidia.com>
Reviewed-by: svc-mobile-misra <svc-mobile-misra@nvidia.com>
Reviewed-by: svc-mobile-cert <svc-mobile-cert@nvidia.com>
Reviewed-by: Ajay Gupta <ajayg@nvidia.com>
Reviewed-by: Srinivas Ramachandran <srinivasra@nvidia.com>
Reviewed-by: Ashutosh Jha <ajha@nvidia.com>
Reviewed-by: mobile promotions <svcmobile_promotions@nvidia.com>
GVS: Gerrit_Virtual_Submit
Tested-by: mobile promotions <svcmobile_promotions@nvidia.com>
This commit is contained in:
committed by
Bhadram Varka
parent
198951cc39
commit
b993a0368d
@@ -263,6 +263,12 @@
|
|||||||
#define OSI_INVALID_CHAN_NUM 0xFFU
|
#define OSI_INVALID_CHAN_NUM 0xFFU
|
||||||
/** @} */
|
/** @} */
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Max num of MAC core registers to backup. It should be max of or >=
|
||||||
|
* (EQOS_MAX_BAK_IDX=380, MGBE_MAX_BAK_IDX, coreX,...etc) backup registers.
|
||||||
|
*/
|
||||||
|
#define CORE_MAX_BAK_IDX 400U
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @addtogroup EQOS-MAC EQOS MAC HW supported features
|
* @addtogroup EQOS-MAC EQOS MAC HW supported features
|
||||||
*
|
*
|
||||||
@@ -504,6 +510,16 @@ struct osi_hw_features {
|
|||||||
unsigned int aux_snap_num;
|
unsigned int aux_snap_num;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief core_backup - Struct used to store backup of core HW registers.
|
||||||
|
*/
|
||||||
|
struct core_backup {
|
||||||
|
/** Array of reg MMIO addresses (base of MAC core + offset of reg) */
|
||||||
|
void *reg_addr[CORE_MAX_BAK_IDX];
|
||||||
|
/** Array of value stored in each corresponding register */
|
||||||
|
unsigned int reg_val[CORE_MAX_BAK_IDX];
|
||||||
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief osi_lock_init - Initialize lock to unlocked state.
|
* @brief osi_lock_init - Initialize lock to unlocked state.
|
||||||
*
|
*
|
||||||
@@ -664,4 +680,30 @@ void osi_get_hw_features(void *base, struct osi_hw_features *hw_feat);
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
void osi_memset(void *s, unsigned int c, unsigned long count);
|
void osi_memset(void *s, unsigned int c, unsigned long count);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* @brief Function to store a backup of MAC register space during SOC suspend.
|
||||||
|
*
|
||||||
|
* Algorithm: Read registers to be backed up as per struct core_backup and
|
||||||
|
* store the register values in memory.
|
||||||
|
*
|
||||||
|
* @param[in] config: Pointer to core_backup structure.
|
||||||
|
* @param[in] max_regs: Max num of registers to backup.
|
||||||
|
*
|
||||||
|
* @retval none
|
||||||
|
*/
|
||||||
|
void mac_save_registers(struct core_backup *const config);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Function to restore the backup of MAC registers during SOC resume.
|
||||||
|
*
|
||||||
|
* Algorithm: Restore the register values from the in memory backup taken using
|
||||||
|
* osi_save_registers().
|
||||||
|
*
|
||||||
|
* @param[in] config: Pointer to core_backup structure.
|
||||||
|
* @param[in] max_regs: Max num of registers to restore.
|
||||||
|
*
|
||||||
|
* @retval none
|
||||||
|
*/
|
||||||
|
void mac_restore_registers(struct core_backup *const config);
|
||||||
#endif /* OSI_COMMON_H */
|
#endif /* OSI_COMMON_H */
|
||||||
|
|||||||
@@ -259,10 +259,6 @@ struct osi_core_ops {
|
|||||||
void (*configure_eee)(struct osi_core_priv_data *const osi_core,
|
void (*configure_eee)(struct osi_core_priv_data *const osi_core,
|
||||||
const unsigned int tx_lpi_enabled,
|
const unsigned int tx_lpi_enabled,
|
||||||
const unsigned int tx_lpi_timer);
|
const unsigned int tx_lpi_timer);
|
||||||
/** Called to save MAC register space during SOC suspend */
|
|
||||||
void (*save_registers)(struct osi_core_priv_data *const osi_core);
|
|
||||||
/** Called to restore MAC control registers during SOC resume */
|
|
||||||
void (*restore_registers)(struct osi_core_priv_data *const osi_core);
|
|
||||||
/** Called to write into a PHY reg over MDIO bus */
|
/** Called to write into a PHY reg over MDIO bus */
|
||||||
int (*write_phy_reg)(struct osi_core_priv_data *const osi_core,
|
int (*write_phy_reg)(struct osi_core_priv_data *const osi_core,
|
||||||
const unsigned int phyaddr,
|
const unsigned int phyaddr,
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2018-2019, NVIDIA CORPORATION. All rights reserved.
|
* Copyright (c) 2018-2020, NVIDIA CORPORATION. All rights reserved.
|
||||||
*
|
*
|
||||||
* Permission is hereby granted, free of charge, to any person obtaining a
|
* Permission is hereby granted, free of charge, to any person obtaining a
|
||||||
* copy of this software and associated documentation files (the "Software"),
|
* copy of this software and associated documentation files (the "Software"),
|
||||||
@@ -134,3 +134,54 @@ void osi_memset(void *s, unsigned int c, unsigned long count)
|
|||||||
count--;
|
count--;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* @brief Function to store a backup of MAC register space during SOC suspend.
|
||||||
|
*
|
||||||
|
* Algorithm: Read registers to be backed up as per struct core_backup and
|
||||||
|
* store the register values in memory.
|
||||||
|
*
|
||||||
|
* @param[in] config: Pointer to core_backup structure.
|
||||||
|
* @param[in] max_regs: Max num of registers to backup.
|
||||||
|
*
|
||||||
|
* @retval none
|
||||||
|
*/
|
||||||
|
void mac_save_registers(struct core_backup *const config)
|
||||||
|
{
|
||||||
|
unsigned int i;
|
||||||
|
|
||||||
|
if (config == OSI_NULL) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
for (i = 0; i < CORE_MAX_BAK_IDX; i++) {
|
||||||
|
if (config->reg_addr[i] != OSI_NULL) {
|
||||||
|
config->reg_val[i] = osi_readl(config->reg_addr[i]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Function to restore the backup of MAC registers during SOC resume.
|
||||||
|
*
|
||||||
|
* Algorithm: Restore the register values from the in memory backup taken using
|
||||||
|
* osi_save_registers().
|
||||||
|
*
|
||||||
|
* @param[in] config: Pointer to core_backup structure.
|
||||||
|
* @param[in] max_regs: Max num of registers to restore.
|
||||||
|
*
|
||||||
|
* @retval none
|
||||||
|
*/
|
||||||
|
void mac_restore_registers(struct core_backup *const config)
|
||||||
|
{
|
||||||
|
unsigned int i;
|
||||||
|
|
||||||
|
if (config == OSI_NULL) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
for (i = 0; i < CORE_MAX_BAK_IDX; i++) {
|
||||||
|
if (config->reg_addr[i] != OSI_NULL) {
|
||||||
|
osi_writel(config->reg_val[i], config->reg_addr[i]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
@@ -3445,52 +3445,6 @@ static void eqos_configure_eee(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
* @brief Function to store a backup of MAC register space during SOC suspend.
|
|
||||||
*
|
|
||||||
* Algorithm: Read registers to be backed up as per struct core_backup and
|
|
||||||
* store the register values in memory.
|
|
||||||
*
|
|
||||||
* @param[in] osi_core: OSI core private data structure.
|
|
||||||
*
|
|
||||||
* @retval none
|
|
||||||
*/
|
|
||||||
static inline void eqos_save_registers(
|
|
||||||
struct osi_core_priv_data *const osi_core)
|
|
||||||
{
|
|
||||||
unsigned int i;
|
|
||||||
struct core_backup *config = osi_core->backup_config;
|
|
||||||
|
|
||||||
for (i = 0; i < EQOS_MAX_BAK_IDX; i++) {
|
|
||||||
if (config->reg_addr[i] != OSI_NULL) {
|
|
||||||
config->reg_val[i] = osi_readl(config->reg_addr[i]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Function to restore the backup of MAC registers during SOC resume.
|
|
||||||
*
|
|
||||||
* Algorithm: Restore the register values from the in memory backup taken using
|
|
||||||
* eqos_save_registers().
|
|
||||||
*
|
|
||||||
* @param[in] osi_core: OSI core private data structure.
|
|
||||||
*
|
|
||||||
* @retval none
|
|
||||||
*/
|
|
||||||
static inline void eqos_restore_registers(
|
|
||||||
struct osi_core_priv_data *const osi_core)
|
|
||||||
{
|
|
||||||
unsigned int i;
|
|
||||||
struct core_backup *config = osi_core->backup_config;
|
|
||||||
|
|
||||||
for (i = 0; i < EQOS_MAX_BAK_IDX; i++) {
|
|
||||||
if (config->reg_addr[i] != OSI_NULL) {
|
|
||||||
osi_writel(config->reg_val[i], config->reg_addr[i]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief poll_for_mii_idle Query the status of an ongoing DMA transfer
|
* @brief poll_for_mii_idle Query the status of an ongoing DMA transfer
|
||||||
*
|
*
|
||||||
@@ -3689,8 +3643,6 @@ static struct osi_core_ops eqos_core_ops = {
|
|||||||
.read_mmc = eqos_read_mmc,
|
.read_mmc = eqos_read_mmc,
|
||||||
.reset_mmc = eqos_reset_mmc,
|
.reset_mmc = eqos_reset_mmc,
|
||||||
.configure_eee = eqos_configure_eee,
|
.configure_eee = eqos_configure_eee,
|
||||||
.save_registers = eqos_save_registers,
|
|
||||||
.restore_registers = eqos_restore_registers,
|
|
||||||
.write_phy_reg = eqos_write_phy_reg,
|
.write_phy_reg = eqos_write_phy_reg,
|
||||||
.read_phy_reg = eqos_read_phy_reg,
|
.read_phy_reg = eqos_read_phy_reg,
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -599,15 +599,5 @@ struct core_func_safety {
|
|||||||
*/
|
*/
|
||||||
#define EQOS_MAX_BAK_IDX ((EQOS_PAD_AUTO_CAL_CFG_BAK_IDX + 1U))
|
#define EQOS_MAX_BAK_IDX ((EQOS_PAD_AUTO_CAL_CFG_BAK_IDX + 1U))
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief core_backup - Struct used to store backup of core HW registers.
|
|
||||||
*/
|
|
||||||
struct core_backup {
|
|
||||||
/** Array of reg MMIO addresses (base of EQoS + offset of reg) */
|
|
||||||
void *reg_addr[EQOS_MAX_BAK_IDX];
|
|
||||||
/** Array of value stored in each corresponding register */
|
|
||||||
unsigned int reg_val[EQOS_MAX_BAK_IDX];
|
|
||||||
};
|
|
||||||
|
|
||||||
/** @} */
|
/** @} */
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -845,8 +845,8 @@ int osi_configure_eee(struct osi_core_priv_data *const osi_core,
|
|||||||
int osi_save_registers(struct osi_core_priv_data *const osi_core)
|
int osi_save_registers(struct osi_core_priv_data *const osi_core)
|
||||||
{
|
{
|
||||||
if ((osi_core != OSI_NULL) && (osi_core->ops != OSI_NULL) &&
|
if ((osi_core != OSI_NULL) && (osi_core->ops != OSI_NULL) &&
|
||||||
(osi_core->ops->save_registers != OSI_NULL)) {
|
(osi_core->backup_config != OSI_NULL)) {
|
||||||
osi_core->ops->save_registers(osi_core);
|
mac_save_registers(osi_core->backup_config);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -856,8 +856,8 @@ int osi_save_registers(struct osi_core_priv_data *const osi_core)
|
|||||||
int osi_restore_registers(struct osi_core_priv_data *const osi_core)
|
int osi_restore_registers(struct osi_core_priv_data *const osi_core)
|
||||||
{
|
{
|
||||||
if ((osi_core != OSI_NULL) && (osi_core->ops != OSI_NULL) &&
|
if ((osi_core != OSI_NULL) && (osi_core->ops != OSI_NULL) &&
|
||||||
(osi_core->ops->restore_registers != OSI_NULL)) {
|
(osi_core->backup_config != OSI_NULL)) {
|
||||||
osi_core->ops->restore_registers(osi_core);
|
mac_restore_registers(osi_core->backup_config);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user