asoc: bolero: Update version query for bolero 2.1

Expose API from bolero driver to retrieve version
info by macro drivers. Update bolero driver to
get version from dtsi.

Change-Id: Idc3735721de90ee4f74319537b17a530d3c125a6
Signed-off-by: Laxminath Kasam <lkasam@codeaurora.org>
This commit is contained in:
Laxminath Kasam
2019-10-11 18:20:19 +05:30
父節點 1543085859
當前提交 f1623021b1
共有 3 個文件被更改,包括 89 次插入32 次删除

查看文件

@@ -68,12 +68,9 @@ static int regmap_bus_read(void *context, const void *reg, size_t reg_size,
reg_p = (u16 *)reg;
macro_id = bolero_get_macro_id(priv->va_without_decimation,
reg_p[0]);
if (macro_id < 0 || !priv->macros_supported[macro_id]) {
dev_err_ratelimited(dev,
"%s: Unsupported macro %d or reg 0x%x is invalid\n",
__func__, macro_id, reg_p[0]);
return ret;
}
if (macro_id < 0 || !priv->macros_supported[macro_id])
return 0;
mutex_lock(&priv->io_lock);
for (i = 0; i < val_size; i++) {
__reg = (reg_p[0] + i * 4) - macro_id_base_offset[macro_id];
@@ -121,12 +118,9 @@ static int regmap_bus_gather_write(void *context,
reg_p = (u16 *)reg;
macro_id = bolero_get_macro_id(priv->va_without_decimation,
reg_p[0]);
if (macro_id < 0 || !priv->macros_supported[macro_id]) {
dev_err_ratelimited(dev,
"%s: Unsupported macro-id %d or reg 0x%x is invalid\n",
__func__, macro_id, reg_p[0]);
return ret;
}
if (macro_id < 0 || !priv->macros_supported[macro_id])
return 0;
mutex_lock(&priv->io_lock);
for (i = 0; i < val_size; i++) {
__reg = (reg_p[0] + i * 4) - macro_id_base_offset[macro_id];

查看文件

@@ -20,9 +20,6 @@
#define DRV_NAME "bolero_codec"
#define BOLERO_VERSION_1_0 0x0001
#define BOLERO_VERSION_1_1 0x0002
#define BOLERO_VERSION_1_2 0x0003
#define BOLERO_VERSION_ENTRY_SIZE 32
#define BOLERO_CDC_STRING_LEN 80
@@ -507,11 +504,17 @@ int bolero_register_macro(struct device *dev, u16 macro_id,
priv->macro_params[macro_id].reg_evt_listener =
ops->reg_evt_listener;
}
if (priv->version == BOLERO_VERSION_2_1) {
if (macro_id == VA_MACRO)
priv->macro_params[macro_id].reg_wake_irq =
ops->reg_wake_irq;
}
priv->num_dais += ops->num_dais;
priv->num_macros_registered++;
priv->macros_supported[macro_id] = true;
dev_dbg(dev, "%s: register macro successful:%d\n", macro_id);
if (priv->num_macros_registered == priv->num_macros) {
ret = bolero_copy_dais_from_macro(priv);
if (ret < 0) {
@@ -604,6 +607,28 @@ void bolero_wsa_pa_on(struct device *dev)
}
EXPORT_SYMBOL(bolero_wsa_pa_on);
int bolero_get_version(struct device *dev)
{
struct bolero_priv *priv;
if (!dev) {
pr_err("%s: dev is null\n", __func__);
return -EINVAL;
}
if (!bolero_is_valid_child_dev(dev)) {
dev_err(dev, "%s: child device for macro not added yet\n",
__func__);
return -EINVAL;
}
priv = dev_get_drvdata(dev->parent);
if (!priv) {
dev_err(dev, "%s: priv is null\n", __func__);
return -EINVAL;
}
return priv->version;
}
EXPORT_SYMBOL(bolero_get_version);
static ssize_t bolero_version_read(struct snd_info_entry *entry,
void *file_private_data,
struct file *file,
@@ -630,6 +655,9 @@ static ssize_t bolero_version_read(struct snd_info_entry *entry,
case BOLERO_VERSION_1_2:
len = snprintf(buffer, sizeof(buffer), "BOLERO_1_2\n");
break;
case BOLERO_VERSION_2_1:
len = snprintf(buffer, sizeof(buffer), "BOLERO_2_1\n");
break;
default:
len = snprintf(buffer, sizeof(buffer), "VER_UNDEFINED\n");
}
@@ -794,9 +822,15 @@ int bolero_register_wake_irq(struct snd_soc_component *component,
return -EINVAL;
}
if (priv->macro_params[TX_MACRO].reg_wake_irq)
priv->macro_params[TX_MACRO].reg_wake_irq(
component, ipc_wakeup);
if (priv->version == BOLERO_VERSION_2_1) {
if (priv->macro_params[VA_MACRO].reg_wake_irq)
priv->macro_params[VA_MACRO].reg_wake_irq(
component, ipc_wakeup);
} else {
if (priv->macro_params[TX_MACRO].reg_wake_irq)
priv->macro_params[TX_MACRO].reg_wake_irq(
component, ipc_wakeup);
}
return 0;
}
@@ -875,6 +909,29 @@ static int bolero_soc_codec_probe(struct snd_soc_component *component)
snd_soc_component_init_regmap(component, priv->regmap);
if (!priv->version) {
/*
* In order for the ADIE RTC to differentiate between targets
* version info is used.
* Assign 1.0 for target with only one macro
* Assign 1.1 for target with two macros
* Assign 1.2 for target with more than two macros
*/
if (priv->num_macros_registered == 1)
priv->version = BOLERO_VERSION_1_0;
else if (priv->num_macros_registered == 2)
priv->version = BOLERO_VERSION_1_1;
else if (priv->num_macros_registered > 2)
priv->version = BOLERO_VERSION_1_2;
}
/* Assign bolero version 2.1 for bolero 2.1 */
if ((snd_soc_component_read32(component,
BOLERO_CDC_VA_TOP_CSR_CORE_ID_0) == 0x2) &&
(snd_soc_component_read32(component,
BOLERO_CDC_VA_TOP_CSR_CORE_ID_1) == 0xE))
priv->version = BOLERO_VERSION_2_1;
/* call init for supported macros */
for (macro_idx = START_MACRO; macro_idx < MAX_MACRO; macro_idx++) {
if (priv->macro_params[macro_idx].init) {
@@ -888,19 +945,6 @@ static int bolero_soc_codec_probe(struct snd_soc_component *component)
}
}
priv->component = component;
/*
* In order for the ADIE RTC to differentiate between targets
* version info is used.
* Assign 1.0 for target with only one macro
* Assign 1.1 for target with two macros
* Assign 1.2 for target with more than two macros
*/
if (priv->num_macros_registered == 1)
priv->version = BOLERO_VERSION_1_0;
else if (priv->num_macros_registered == 2)
priv->version = BOLERO_VERSION_1_1;
else if (priv->num_macros_registered > 2)
priv->version = BOLERO_VERSION_1_2;
ret = snd_event_client_register(priv->dev, &bolero_ssr_ops, priv);
if (!ret) {
@@ -1044,6 +1088,13 @@ static int bolero_probe(struct platform_device *pdev)
if (priv->va_without_decimation)
bolero_reg_access[VA_MACRO] = bolero_va_top_reg_access;
ret = of_property_read_u32(pdev->dev.of_node,
"qcom,bolero-version", &priv->version);
if (ret) {
dev_dbg(&pdev->dev, "%s:bolero version not specified\n",
__func__);
ret = 0;
}
priv->dev = &pdev->dev;
priv->dev_up = true;
priv->initial_boot = true;

查看文件

@@ -8,6 +8,12 @@
#include <sound/soc.h>
#include <linux/regmap.h>
#define BOLERO_VERSION_1_0 0x0001
#define BOLERO_VERSION_1_1 0x0002
#define BOLERO_VERSION_1_2 0x0003
#define BOLERO_VERSION_2_0 0x0004
#define BOLERO_VERSION_2_1 0x0005
enum {
START_MACRO,
TX_MACRO = START_MACRO,
@@ -85,6 +91,7 @@ int bolero_register_event_listener(struct snd_soc_component *component,
bool enable);
void bolero_wsa_pa_on(struct device *dev);
bool bolero_check_core_votes(struct device *dev);
int bolero_get_version(struct device *dev);
#else
static inline int bolero_register_res_clk(struct device *dev, rsc_clk_cb_t cb)
{
@@ -164,5 +171,10 @@ static inline bool bolero_check_core_votes(struct device *dev)
{
return false;
}
static int bolero_get_version(struct device *dev)
{
return 0;
}
#endif /* CONFIG_SND_SOC_BOLERO */
#endif /* BOLERO_CDC_H */