mirror of
git://nv-tegra.nvidia.com/linux-nv-oot.git
synced 2025-12-25 10:42:21 +03:00
XBAR related code is currently put under source files "tegra210_xbar_alt.c" and "tegra210_xbar_utils_alt.c". For upstream we are planning to use a single source file. Thus code in downstream is re-organized so that all XBAR code is moved under a single file. Following is the summary of changes, * All XBAR specific code is moved under, "tegra210_xbar_alt.c" and "tegra210_xbar_alt.h" * Only common code, which is required for other modules, remains in "tegra210_xbar_utils_alt.c" * unused macros or functions are removed Bug 200503387 Change-Id: I11cb93d3cdc07e14ef2e0b3b23ba6a98020a0373 Signed-off-by: Sameer Pujar <spujar@nvidia.com> Reviewed-on: https://git-master.nvidia.com/r/2265584 GVS: Gerrit_Virtual_Submit Reviewed-by: Dara Ramesh <dramesh@nvidia.com> Reviewed-by: Sharad Gupta <sharadg@nvidia.com> Reviewed-by: mobile promotions <svcmobile_promotions@nvidia.com> Tested-by: mobile promotions <svcmobile_promotions@nvidia.com>
105 lines
3.2 KiB
C
105 lines
3.2 KiB
C
/*
|
|
* tegra210_xbar_utils_alt.c - Tegra XBAR driver utils
|
|
*
|
|
* Copyright (c) 2017-2019 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.
|
|
*
|
|
* You should have received a copy of the GNU General Public License
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
*/
|
|
|
|
#include <linux/clk.h>
|
|
#include <linux/device.h>
|
|
#include <linux/io.h>
|
|
#include <linux/module.h>
|
|
#include <linux/of_platform.h>
|
|
#include <linux/platform_device.h>
|
|
#include <linux/pm_runtime.h>
|
|
#include <linux/regmap.h>
|
|
#include <soc/tegra/chip-id.h>
|
|
#include <sound/soc.h>
|
|
#include <linux/clk/tegra.h>
|
|
#include "tegra210_xbar_alt.h"
|
|
|
|
void tegra210_xbar_set_cif(struct regmap *regmap, unsigned int reg,
|
|
struct tegra210_xbar_cif_conf *conf)
|
|
{
|
|
unsigned int value;
|
|
|
|
value = (conf->threshold <<
|
|
TEGRA210_AUDIOCIF_CTRL_FIFO_THRESHOLD_SHIFT) |
|
|
((conf->audio_channels - 1) <<
|
|
TEGRA210_AUDIOCIF_CTRL_AUDIO_CHANNELS_SHIFT) |
|
|
((conf->client_channels - 1) <<
|
|
TEGRA210_AUDIOCIF_CTRL_CLIENT_CHANNELS_SHIFT) |
|
|
(conf->audio_bits <<
|
|
TEGRA210_AUDIOCIF_CTRL_AUDIO_BITS_SHIFT) |
|
|
(conf->client_bits <<
|
|
TEGRA210_AUDIOCIF_CTRL_CLIENT_BITS_SHIFT) |
|
|
(conf->expand <<
|
|
TEGRA210_AUDIOCIF_CTRL_EXPAND_SHIFT) |
|
|
(conf->stereo_conv <<
|
|
TEGRA210_AUDIOCIF_CTRL_STEREO_CONV_SHIFT) |
|
|
(conf->replicate <<
|
|
TEGRA210_AUDIOCIF_CTRL_REPLICATE_SHIFT) |
|
|
(conf->truncate <<
|
|
TEGRA210_AUDIOCIF_CTRL_TRUNCATE_SHIFT) |
|
|
(conf->mono_conv <<
|
|
TEGRA210_AUDIOCIF_CTRL_MONO_CONV_SHIFT);
|
|
|
|
regmap_update_bits(regmap, reg, 0x3fffffff, value);
|
|
}
|
|
EXPORT_SYMBOL_GPL(tegra210_xbar_set_cif);
|
|
|
|
void tegra210_xbar_write_ahubram(struct regmap *regmap, unsigned int reg_ctrl,
|
|
unsigned int reg_data, unsigned int ram_offset,
|
|
unsigned int *data, size_t size)
|
|
{
|
|
unsigned int val = 0;
|
|
int i = 0;
|
|
|
|
val = ram_offset & TEGRA210_AHUBRAMCTL_CTRL_RAM_ADDR_MASK;
|
|
val |= TEGRA210_AHUBRAMCTL_CTRL_ADDR_INIT_EN;
|
|
val |= TEGRA210_AHUBRAMCTL_CTRL_SEQ_ACCESS_EN;
|
|
val |= TEGRA210_AHUBRAMCTL_CTRL_RW_WRITE;
|
|
|
|
regmap_write(regmap, reg_ctrl, val);
|
|
for (i = 0; i < size; i++)
|
|
regmap_write(regmap, reg_data, data[i]);
|
|
|
|
return;
|
|
}
|
|
EXPORT_SYMBOL_GPL(tegra210_xbar_write_ahubram);
|
|
|
|
void tegra210_xbar_read_ahubram(struct regmap *regmap, unsigned int reg_ctrl,
|
|
unsigned int reg_data, unsigned int ram_offset,
|
|
unsigned int *data, size_t size)
|
|
{
|
|
unsigned int val = 0;
|
|
int i = 0;
|
|
|
|
val = ram_offset & TEGRA210_AHUBRAMCTL_CTRL_RAM_ADDR_MASK;
|
|
val |= TEGRA210_AHUBRAMCTL_CTRL_ADDR_INIT_EN;
|
|
val |= TEGRA210_AHUBRAMCTL_CTRL_SEQ_ACCESS_EN;
|
|
val |= TEGRA210_AHUBRAMCTL_CTRL_RW_READ;
|
|
|
|
regmap_write(regmap, reg_ctrl, val);
|
|
/* Since all ahub non-io modules work under same ahub clock it is not
|
|
necessary to check ahub read busy bit after every read */
|
|
for (i = 0; i < size; i++)
|
|
regmap_read(regmap, reg_data, &data[i]);
|
|
|
|
return;
|
|
}
|
|
EXPORT_SYMBOL_GPL(tegra210_xbar_read_ahubram);
|
|
|
|
MODULE_LICENSE("GPL");
|