ASoC: tegra-alt: probe() cleanup for AHUB modules

Cleanup probe() functions for AHUB module drivers and following is the
summary of changes. This helps later in upstream too.
 * avoid unnecessary goto labels by updating return paths
 * removed following unused header files wherever applicable.
   linux/pinctrl/consumer.h
   linux/version.h
   linux/debugfs.h
   linux/slab.h
 * redundant pm_runtime_get/put removed in tegra186_xbar_registration()
 * Redundant error print during memory allocation failure is removed
 * runtime PM is enabled as late as possible and before the codec
   registration is done.
 * explicit calls to runtime_resume/suspend is avoided in probe(). For
   upstream, PM is enforced and the same can be done in downstream too.
   Hence no need to handle !PM case in driver probe()
   Ref: http://patchwork.ozlabs.org/patch/1048746/
 * IS_ERR() check is sufficient for error handling in case of
   devm_clk_get().

Bug 200520821
Bug 200503387

Change-Id: Ie4192036e72db161fa7d8ff4c6c0b28c17635793
Signed-off-by: Sameer Pujar <spujar@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/2153956
Reviewed-by: Jonathan Hunter <jonathanh@nvidia.com>
GVS: Gerrit_Virtual_Submit
Reviewed-by: Automatic_Commit_Validation_User
Reviewed-by: Ravindra Lokhande <rlokhande@nvidia.com>
Reviewed-by: mobile promotions <svcmobile_promotions@nvidia.com>
Tested-by: mobile promotions <svcmobile_promotions@nvidia.com>
This commit is contained in:
Sameer Pujar
2019-07-15 21:05:19 +05:30
parent 87dc6dec32
commit 446bac0918
20 changed files with 273 additions and 649 deletions

View File

@@ -24,7 +24,6 @@
#include <linux/regulator/consumer.h> #include <linux/regulator/consumer.h>
#include <linux/delay.h> #include <linux/delay.h>
#include <linux/pm_runtime.h> #include <linux/pm_runtime.h>
#include <linux/version.h>
#include <sound/core.h> #include <sound/core.h>
#include <sound/jack.h> #include <sound/jack.h>
#include <sound/pcm.h> #include <sound/pcm.h>

View File

@@ -24,15 +24,12 @@
#include <linux/platform_device.h> #include <linux/platform_device.h>
#include <linux/pm_runtime.h> #include <linux/pm_runtime.h>
#include <linux/regmap.h> #include <linux/regmap.h>
#include <linux/slab.h>
#include <sound/core.h> #include <sound/core.h>
#include <sound/pcm.h> #include <sound/pcm.h>
#include <sound/pcm_params.h> #include <sound/pcm_params.h>
#include <sound/soc.h> #include <sound/soc.h>
#include <linux/pinctrl/consumer.h>
#include <linux/of_device.h> #include <linux/of_device.h>
#include <linux/tegra186_ahc.h> #include <linux/tegra186_ahc.h>
#include <linux/version.h>
#include "tegra186_asrc_alt.h" #include "tegra186_asrc_alt.h"
#include "tegra186_arad_alt.h" #include "tegra186_arad_alt.h"
@@ -753,17 +750,12 @@ static int tegra186_arad_platform_probe(struct platform_device *pdev)
match = of_match_device(tegra186_arad_of_match, &pdev->dev); match = of_match_device(tegra186_arad_of_match, &pdev->dev);
if (!match) { if (!match) {
dev_err(&pdev->dev, "Error: No device match found\n"); dev_err(&pdev->dev, "Error: No device match found\n");
ret = -ENODEV; return -ENODEV;
goto err;
} }
arad = devm_kzalloc(&pdev->dev, arad = devm_kzalloc(&pdev->dev, sizeof(*arad), GFP_KERNEL);
sizeof(struct tegra186_arad), GFP_KERNEL); if (!arad)
if (!arad) { return -ENOMEM;
dev_err(&pdev->dev, "Can't allocate tegra210_arad\n");
ret = -ENOMEM;
goto err;
}
arad_dev = &pdev->dev; arad_dev = &pdev->dev;
dev_set_drvdata(&pdev->dev, arad); dev_set_drvdata(&pdev->dev, arad);
@@ -780,13 +772,11 @@ static int tegra186_arad_platform_probe(struct platform_device *pdev)
} }
regcache_cache_only(arad->regmap, true); regcache_cache_only(arad->regmap, true);
if (of_property_read_u32(pdev->dev.of_node, ret = of_property_read_u32(pdev->dev.of_node, "nvidia,ahub-arad-id",
"nvidia,ahub-arad-id", &pdev->dev.id);
&pdev->dev.id) < 0) { if (ret < 0) {
dev_err(&pdev->dev, dev_err(&pdev->dev, "Missing property nvidia,ahub-arad-id\n");
"Missing property nvidia,ahub-arad-id\n"); return ret;
ret = -ENODEV;
goto err;
} }
pm_runtime_enable(&pdev->dev); pm_runtime_enable(&pdev->dev);
@@ -796,7 +786,8 @@ static int tegra186_arad_platform_probe(struct platform_device *pdev)
ARRAY_SIZE(tegra186_arad_dais)); ARRAY_SIZE(tegra186_arad_dais));
if (ret != 0) { if (ret != 0) {
dev_err(&pdev->dev, "Could not register CODEC: %d\n", ret); dev_err(&pdev->dev, "Could not register CODEC: %d\n", ret);
goto err_suspend; pm_runtime_disable(&pdev->dev);
return ret;
} }
#ifdef CONFIG_SND_SOC_TEGRA186_ARAD_WAR #ifdef CONFIG_SND_SOC_TEGRA186_ARAD_WAR
@@ -808,14 +799,8 @@ static int tegra186_arad_platform_probe(struct platform_device *pdev)
TEGRA186_AHC_ARAD1_CB, &pdev->dev); TEGRA186_AHC_ARAD1_CB, &pdev->dev);
#endif #endif
#endif #endif
return 0;
err_suspend: return 0;
if (!pm_runtime_status_suspended(&pdev->dev))
tegra186_arad_runtime_suspend(&pdev->dev);
pm_runtime_disable(&pdev->dev);
err:
return ret;
} }
static int tegra186_arad_platform_remove(struct platform_device *pdev) static int tegra186_arad_platform_remove(struct platform_device *pdev)

View File

@@ -23,16 +23,13 @@
#include <linux/platform_device.h> #include <linux/platform_device.h>
#include <linux/pm_runtime.h> #include <linux/pm_runtime.h>
#include <linux/regmap.h> #include <linux/regmap.h>
#include <linux/slab.h>
#include <sound/core.h> #include <sound/core.h>
#include <sound/pcm.h> #include <sound/pcm.h>
#include <sound/pcm_params.h> #include <sound/pcm_params.h>
#include <sound/soc.h> #include <sound/soc.h>
#include <linux/delay.h> #include <linux/delay.h>
#include <linux/pinctrl/consumer.h>
#include <linux/of_device.h> #include <linux/of_device.h>
#include <linux/tegra186_ahc.h> #include <linux/tegra186_ahc.h>
#include <linux/version.h>
#include "tegra210_xbar_alt.h" #include "tegra210_xbar_alt.h"
#include "tegra186_asrc_alt.h" #include "tegra186_asrc_alt.h"
@@ -1094,17 +1091,12 @@ static int tegra186_asrc_platform_probe(struct platform_device *pdev)
match = of_match_device(tegra186_asrc_of_match, &pdev->dev); match = of_match_device(tegra186_asrc_of_match, &pdev->dev);
if (!match) { if (!match) {
dev_err(&pdev->dev, "Error: No device match found\n"); dev_err(&pdev->dev, "Error: No device match found\n");
ret = -ENODEV; return -ENODEV;
goto err;
} }
asrc_dev = &pdev->dev; asrc_dev = &pdev->dev;
asrc = devm_kzalloc(&pdev->dev, asrc = devm_kzalloc(&pdev->dev, sizeof(*asrc), GFP_KERNEL);
sizeof(struct tegra186_asrc), GFP_KERNEL); if (!asrc)
if (!asrc) { return -ENOMEM;
dev_err(&pdev->dev, "Can't allocate asrc\n");
ret = -ENOMEM;
goto err;
}
asrc->is_shutdown = false; asrc->is_shutdown = false;
dev_set_drvdata(&pdev->dev, asrc); dev_set_drvdata(&pdev->dev, asrc);
@@ -1121,29 +1113,20 @@ static int tegra186_asrc_platform_probe(struct platform_device *pdev)
} }
regcache_cache_only(asrc->regmap, true); regcache_cache_only(asrc->regmap, true);
if (of_property_read_u32(pdev->dev.of_node, ret = of_property_read_u32(pdev->dev.of_node, "nvidia,ahub-asrc-id",
"nvidia,ahub-asrc-id", &pdev->dev.id);
&pdev->dev.id) < 0) { if (ret < 0) {
dev_err(&pdev->dev, dev_err(&pdev->dev, "Missing property nvidia,ahub-asrc-id\n");
"Missing property nvidia,ahub-asrc-id\n"); return ret;
ret = -ENODEV;
goto err;
} }
#ifdef CONFIG_TEGRA186_AHC #ifdef CONFIG_TEGRA186_AHC
tegra186_ahc_register_cb(tegra186_asrc_ahc_cb, tegra186_ahc_register_cb(tegra186_asrc_ahc_cb, TEGRA186_AHC_ASRC1_CB,
TEGRA186_AHC_ASRC1_CB, &pdev->dev); &pdev->dev);
#endif #endif
pm_runtime_enable(&pdev->dev);
if (!pm_runtime_enabled(&pdev->dev)) {
ret = tegra186_asrc_runtime_resume(&pdev->dev);
if (ret)
goto err_pm_disable;
}
regmap_write(asrc->regmap, TEGRA186_ASRC_GLOBAL_CONFIG, regmap_write(asrc->regmap, TEGRA186_ASRC_GLOBAL_CONFIG,
TEGRA186_ASRC_GLOBAL_CONFIG_FRAC_32BIT_PRECISION); TEGRA186_ASRC_GLOBAL_CONFIG_FRAC_32BIT_PRECISION);
/* initialize default output srate */ /* initialize default output srate */
for (i = 0; i < 6; i++) { for (i = 0; i < 6; i++) {
@@ -1159,23 +1142,17 @@ static int tegra186_asrc_platform_probe(struct platform_device *pdev)
ASRC_STREAM_REG(TEGRA186_ASRC_STREAM1_CONFIG, i), 1, 1); ASRC_STREAM_REG(TEGRA186_ASRC_STREAM1_CONFIG, i), 1, 1);
} }
pm_runtime_enable(&pdev->dev);
ret = snd_soc_register_codec(&pdev->dev, &tegra186_asrc_codec, ret = snd_soc_register_codec(&pdev->dev, &tegra186_asrc_codec,
tegra186_asrc_dais, tegra186_asrc_dais,
ARRAY_SIZE(tegra186_asrc_dais)); ARRAY_SIZE(tegra186_asrc_dais));
if (ret != 0) { if (ret != 0) {
dev_err(&pdev->dev, "Could not register CODEC: %d\n", ret); dev_err(&pdev->dev, "Could not register CODEC: %d\n", ret);
goto err_suspend; pm_runtime_disable(&pdev->dev);
return ret;
} }
return 0; return 0;
err_suspend:
if (!pm_runtime_status_suspended(&pdev->dev))
tegra186_asrc_runtime_suspend(&pdev->dev);
err_pm_disable:
pm_runtime_disable(&pdev->dev);
err:
return ret;
} }
static void tegra186_asrc_platform_shutdown(struct platform_device *pdev) static void tegra186_asrc_platform_shutdown(struct platform_device *pdev)

View File

@@ -23,16 +23,13 @@
#include <linux/platform_device.h> #include <linux/platform_device.h>
#include <linux/pm_runtime.h> #include <linux/pm_runtime.h>
#include <linux/regmap.h> #include <linux/regmap.h>
#include <linux/slab.h>
#include <sound/core.h> #include <sound/core.h>
#include <sound/pcm.h> #include <sound/pcm.h>
#include <sound/pcm_params.h> #include <sound/pcm_params.h>
#include <sound/soc.h> #include <sound/soc.h>
#include <linux/of_device.h> #include <linux/of_device.h>
#include <linux/debugfs.h>
#include <soc/tegra/chip-id.h> #include <soc/tegra/chip-id.h>
#include <linux/pinctrl/consumer.h> #include <linux/pinctrl/consumer.h>
#include <linux/version.h>
#include <linux/pinctrl/pinconf-tegra.h> #include <linux/pinctrl/pinconf-tegra.h>
#include "tegra210_xbar_alt.h" #include "tegra210_xbar_alt.h"
@@ -455,42 +452,36 @@ static int tegra186_dspk_platform_probe(struct platform_device *pdev)
match = of_match_device(tegra186_dspk_of_match, &pdev->dev); match = of_match_device(tegra186_dspk_of_match, &pdev->dev);
if (!match) { if (!match) {
dev_err(&pdev->dev, "Error: No device match found\n"); dev_err(&pdev->dev, "Error: No device match found\n");
ret = -ENODEV; return -ENODEV;
goto err;
} }
dspk = devm_kzalloc(&pdev->dev, sizeof(struct tegra186_dspk), dspk = devm_kzalloc(&pdev->dev, sizeof(*dspk), GFP_KERNEL);
GFP_KERNEL); if (!dspk)
if (!dspk) { return -ENOMEM;
dev_err(&pdev->dev, "Can't allocate dspk\n");
ret = -ENOMEM;
goto err;
}
dspk->is_shutdown = false; dspk->is_shutdown = false;
dspk->prod_name = NULL; dspk->prod_name = NULL;
dspk->rx_fifo_th = 0; dspk->rx_fifo_th = 0;
dspk->osr_val = TEGRA186_DSPK_OSR_64; dspk->osr_val = TEGRA186_DSPK_OSR_64;
dev_set_drvdata(&pdev->dev, dspk);
if (!(tegra_platform_is_unit_fpga() || tegra_platform_is_fpga())) { if (!(tegra_platform_is_unit_fpga() || tegra_platform_is_fpga())) {
dspk->clk_dspk = devm_clk_get(&pdev->dev, NULL); dspk->clk_dspk = devm_clk_get(&pdev->dev, NULL);
if (IS_ERR(dspk->clk_dspk)) { if (IS_ERR(dspk->clk_dspk)) {
dev_err(&pdev->dev, "Can't retrieve dspk clock\n"); dev_err(&pdev->dev, "Can't retrieve dspk clock\n");
ret = PTR_ERR(dspk->clk_dspk); return PTR_ERR(dspk->clk_dspk);
goto err;
} }
dspk->clk_pll_a_out0 = devm_clk_get(&pdev->dev, "pll_a_out0"); dspk->clk_pll_a_out0 = devm_clk_get(&pdev->dev, "pll_a_out0");
if (IS_ERR_OR_NULL(dspk->clk_pll_a_out0)) { if (IS_ERR(dspk->clk_pll_a_out0)) {
dev_err(&pdev->dev, "Can't retrieve pll_a_out0 clock\n"); dev_err(&pdev->dev, "Can't retrieve pll_a_out0 clock\n");
ret = -ENOENT; return PTR_ERR(dspk->clk_pll_a_out0);
goto err;
} }
ret = clk_set_parent(dspk->clk_dspk, dspk->clk_pll_a_out0); ret = clk_set_parent(dspk->clk_dspk, dspk->clk_pll_a_out0);
if (ret) { if (ret) {
dev_err(&pdev->dev, "Can't set parent of dspk clock\n"); dev_err(&pdev->dev, "Can't set parent of dspk clock\n");
goto err; return ret;
} }
} }
@@ -506,34 +497,28 @@ static int tegra186_dspk_platform_probe(struct platform_device *pdev)
} }
regcache_cache_only(dspk->regmap, true); regcache_cache_only(dspk->regmap, true);
if (of_property_read_u32(np, "nvidia,ahub-dspk-id", ret = of_property_read_u32(np, "nvidia,ahub-dspk-id",
&pdev->dev.id) < 0) { &pdev->dev.id);
dev_err(&pdev->dev, if (ret < 0) {
"Missing property nvidia,ahub-dspk-id\n"); dev_err(&pdev->dev, "Missing property nvidia,ahub-dspk-id\n");
ret = -ENODEV; return ret;
goto err;
} }
pm_runtime_enable(&pdev->dev); pm_runtime_enable(&pdev->dev);
if (!pm_runtime_enabled(&pdev->dev)) {
ret = tegra186_dspk_runtime_resume(&pdev->dev);
if (ret)
goto err_pm_disable;
}
ret = snd_soc_register_codec(&pdev->dev, &tegra186_dspk_codec, ret = snd_soc_register_codec(&pdev->dev, &tegra186_dspk_codec,
tegra186_dspk_dais, tegra186_dspk_dais,
ARRAY_SIZE(tegra186_dspk_dais)); ARRAY_SIZE(tegra186_dspk_dais));
if (ret != 0) { if (ret != 0) {
dev_err(&pdev->dev, "Could not register CODEC: %d\n", ret); dev_err(&pdev->dev, "Could not register CODEC: %d\n", ret);
goto err_suspend; pm_runtime_disable(&pdev->dev);
return ret;
} }
if (of_property_read_string(np, "prod-name", &dspk->prod_name) == 0) { if (of_property_read_string(np, "prod-name", &dspk->prod_name) == 0) {
ret = tegra_pinctrl_config_prod(&pdev->dev, dspk->prod_name); ret = tegra_pinctrl_config_prod(&pdev->dev, dspk->prod_name);
if (ret < 0) if (ret < 0)
dev_warn(&pdev->dev, "Failed to set %s setting\n", dev_warn(&pdev->dev, "Failed to set %s setting\n",
dspk->prod_name); dspk->prod_name);
} }
dspk->pinctrl = devm_pinctrl_get(&pdev->dev); dspk->pinctrl = devm_pinctrl_get(&pdev->dev);
@@ -543,31 +528,19 @@ static int tegra186_dspk_platform_probe(struct platform_device *pdev)
} }
dspk->pin_active_state = pinctrl_lookup_state(dspk->pinctrl, dspk->pin_active_state = pinctrl_lookup_state(dspk->pinctrl,
"dap_active"); "dap_active");
if (IS_ERR(dspk->pin_active_state)) { if (IS_ERR(dspk->pin_active_state)) {
dev_dbg(&pdev->dev, "Missing dap-active state\n"); dev_dbg(&pdev->dev, "Missing dap-active state\n");
goto err_dap; goto err_dap;
} }
dspk->pin_idle_state = pinctrl_lookup_state(dspk->pinctrl, dspk->pin_idle_state = pinctrl_lookup_state(dspk->pinctrl,
"dap_inactive"); "dap_inactive");
if (IS_ERR(dspk->pin_idle_state)) { if (IS_ERR(dspk->pin_idle_state))
dev_dbg(&pdev->dev, "Missing dap-inactive state\n"); dev_dbg(&pdev->dev, "Missing dap-inactive state\n");
goto err_dap;
}
err_dap: err_dap:
dev_set_drvdata(&pdev->dev, dspk);
return 0; return 0;
err_suspend:
if (!pm_runtime_status_suspended(&pdev->dev))
tegra186_dspk_runtime_suspend(&pdev->dev);
err_pm_disable:
pm_runtime_disable(&pdev->dev);
err:
return ret;
} }
static void tegra186_dspk_platform_shutdown(struct platform_device *pdev) static void tegra186_dspk_platform_shutdown(struct platform_device *pdev)

View File

@@ -25,7 +25,6 @@
#include <linux/platform_device.h> #include <linux/platform_device.h>
#include <linux/pm_runtime.h> #include <linux/pm_runtime.h>
#include <linux/regmap.h> #include <linux/regmap.h>
#include <linux/slab.h>
#include <linux/clk/tegra.h> #include <linux/clk/tegra.h>
#include <sound/soc.h> #include <sound/soc.h>
#include <sound/pcm_params.h> #include <sound/pcm_params.h>
@@ -33,7 +32,6 @@
#include "tegra_pcm_alt.h" #include "tegra_pcm_alt.h"
#include "tegra210_xbar_alt.h" #include "tegra210_xbar_alt.h"
#include "tegra_isomgr_bw_alt.h" #include "tegra_isomgr_bw_alt.h"
#include "tegra210_admaif_alt.h" #include "tegra210_admaif_alt.h"
#define DRV_NAME "tegra210-ape-admaif" #define DRV_NAME "tegra210-ape-admaif"
@@ -1130,9 +1128,7 @@ static const struct of_device_id tegra_admaif_of_match[] = {
static int tegra_admaif_probe(struct platform_device *pdev) static int tegra_admaif_probe(struct platform_device *pdev)
{ {
int i; int ret, i;
int ret;
struct tegra_admaif *admaif; struct tegra_admaif *admaif;
void __iomem *regs; void __iomem *regs;
struct resource *res; struct resource *res;
@@ -1146,11 +1142,8 @@ static int tegra_admaif_probe(struct platform_device *pdev)
} }
admaif = devm_kzalloc(&pdev->dev, sizeof(*admaif), GFP_KERNEL); admaif = devm_kzalloc(&pdev->dev, sizeof(*admaif), GFP_KERNEL);
if (!admaif) { if (!admaif)
dev_err(&pdev->dev, "Can't allocate tegra_admaif\n"); return -ENOMEM;
ret = -ENOMEM;
goto err;
}
admaif->dev = &pdev->dev; admaif->dev = &pdev->dev;
admaif->soc_data = (struct tegra_admaif_soc_data *)match->data; admaif->soc_data = (struct tegra_admaif_soc_data *)match->data;
@@ -1161,48 +1154,33 @@ static int tegra_admaif_probe(struct platform_device *pdev)
sizeof(struct tegra_alt_pcm_dma_params) * sizeof(struct tegra_alt_pcm_dma_params) *
admaif->soc_data->num_ch, admaif->soc_data->num_ch,
GFP_KERNEL); GFP_KERNEL);
if (!admaif->capture_dma_data) { if (!admaif->capture_dma_data)
dev_err(&pdev->dev, "Can't allocate capture_dma_data\n"); return -ENOMEM;
ret = -ENOMEM;
goto err;
}
admaif->playback_dma_data = devm_kzalloc(&pdev->dev, admaif->playback_dma_data = devm_kzalloc(&pdev->dev,
sizeof(struct tegra_alt_pcm_dma_params) * sizeof(struct tegra_alt_pcm_dma_params) *
admaif->soc_data->num_ch, admaif->soc_data->num_ch,
GFP_KERNEL); GFP_KERNEL);
if (!admaif->playback_dma_data) { if (!admaif->playback_dma_data)
dev_err(&pdev->dev, "Can't allocate playback_dma_data\n"); return -ENOMEM;
ret = -ENOMEM;
goto err;
}
admaif->override_channels = devm_kzalloc(&pdev->dev, admaif->override_channels = devm_kzalloc(&pdev->dev,
sizeof(int) * admaif->soc_data->num_ch, sizeof(int) * admaif->soc_data->num_ch,
GFP_KERNEL); GFP_KERNEL);
if (!admaif->override_channels) { if (!admaif->override_channels)
dev_err(&pdev->dev, "Can't allocate override channel memory\n"); return -ENOMEM;
ret = -ENOMEM;
goto err;
}
admaif->tx_mono_to_stereo = devm_kzalloc(&pdev->dev, admaif->tx_mono_to_stereo = devm_kzalloc(&pdev->dev,
sizeof(int) * admaif->soc_data->num_ch, sizeof(int) * admaif->soc_data->num_ch,
GFP_KERNEL); GFP_KERNEL);
if (!admaif->tx_mono_to_stereo) { if (!admaif->tx_mono_to_stereo)
dev_err(&pdev->dev, "Can't allocate override channel memory\n"); return -ENOMEM;
ret = -ENOMEM;
goto err;
}
admaif->rx_stereo_to_mono = devm_kzalloc(&pdev->dev, admaif->rx_stereo_to_mono = devm_kzalloc(&pdev->dev,
sizeof(int) * admaif->soc_data->num_ch, sizeof(int) * admaif->soc_data->num_ch,
GFP_KERNEL); GFP_KERNEL);
if (!admaif->rx_stereo_to_mono) { if (!admaif->rx_stereo_to_mono)
dev_err(&pdev->dev, "Can't allocate override channel memory\n"); return -ENOMEM;
ret = -ENOMEM;
goto err;
}
res = platform_get_resource(pdev, IORESOURCE_MEM, 0); res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
regs = devm_ioremap_resource(&pdev->dev, res); regs = devm_ioremap_resource(&pdev->dev, res);
@@ -1217,13 +1195,6 @@ static int tegra_admaif_probe(struct platform_device *pdev)
} }
regcache_cache_only(admaif->regmap, true); regcache_cache_only(admaif->regmap, true);
pm_runtime_enable(&pdev->dev);
if (!pm_runtime_enabled(&pdev->dev)) {
ret = tegra_admaif_runtime_resume(&pdev->dev);
if (ret)
goto err_pm_disable;
}
if (admaif->soc_data->is_isomgr_client) if (admaif->soc_data->is_isomgr_client)
tegra_isomgr_adma_register(); tegra_isomgr_adma_register();
@@ -1239,14 +1210,14 @@ static int tegra_admaif_probe(struct platform_device *pdev)
admaif->playback_dma_data[i].width = 32; admaif->playback_dma_data[i].width = 32;
admaif->playback_dma_data[i].req_sel = i + 1; admaif->playback_dma_data[i].req_sel = i + 1;
if (of_property_read_string_index(pdev->dev.of_node, ret = of_property_read_string_index(pdev->dev.of_node,
"dma-names", "dma-names",
(i * 2) + 1, (i * 2) + 1,
&admaif->playback_dma_data[i].chan_name) < 0) { &admaif->playback_dma_data[i].chan_name);
if (ret < 0) {
dev_err(&pdev->dev, dev_err(&pdev->dev,
"Missing property nvidia,dma-names\n"); "Missing property nvidia,dma-names\n");
ret = -ENODEV; return ret;
goto err_suspend;
} }
buffer_size = 0; buffer_size = 0;
if (of_property_read_u32_index(pdev->dev.of_node, if (of_property_read_u32_index(pdev->dev.of_node,
@@ -1260,14 +1231,14 @@ static int tegra_admaif_probe(struct platform_device *pdev)
admaif->capture_dma_data[i].width = 32; admaif->capture_dma_data[i].width = 32;
admaif->capture_dma_data[i].req_sel = i + 1; admaif->capture_dma_data[i].req_sel = i + 1;
if (of_property_read_string_index(pdev->dev.of_node, ret = of_property_read_string_index(pdev->dev.of_node,
"dma-names", "dma-names",
(i * 2), (i * 2),
&admaif->capture_dma_data[i].chan_name) < 0) { &admaif->capture_dma_data[i].chan_name);
if (ret < 0) {
dev_err(&pdev->dev, dev_err(&pdev->dev,
"Missing property nvidia,dma-names\n"); "Missing property nvidia,dma-names\n");
ret = -ENODEV; return ret;
goto err_suspend;
} }
buffer_size = 0; buffer_size = 0;
if (of_property_read_u32_index(pdev->dev.of_node, if (of_property_read_u32_index(pdev->dev.of_node,
@@ -1280,46 +1251,41 @@ static int tegra_admaif_probe(struct platform_device *pdev)
admaif->capture_dma_data[i].buffer_size = buffer_size; admaif->capture_dma_data[i].buffer_size = buffer_size;
} }
ret = snd_soc_register_component(&pdev->dev, regmap_update_bits(admaif->regmap, admaif->soc_data->global_base +
&tegra_admaif_dai_driver, TEGRA_ADMAIF_GLOBAL_ENABLE, 1, 1);
tegra_admaif_dais,
admaif->soc_data->num_ch); ret = devm_snd_soc_register_component(&pdev->dev,
&tegra_admaif_dai_driver,
tegra_admaif_dais,
admaif->soc_data->num_ch);
if (ret) { if (ret) {
dev_err(&pdev->dev, "Could not register DAIs %d: %d\n", dev_err(&pdev->dev, "Could not register DAIs %d: %d\n",
i, ret); i, ret);
ret = -ENOMEM; return ret;
goto err_suspend;
} }
pm_runtime_enable(&pdev->dev);
ret = snd_soc_register_codec(&pdev->dev, admaif->soc_data->admaif_codec, ret = snd_soc_register_codec(&pdev->dev, admaif->soc_data->admaif_codec,
admaif->soc_data->codec_dais, admaif->soc_data->codec_dais,
admaif->soc_data->num_ch * 2); admaif->soc_data->num_ch * 2);
if (ret != 0) { if (ret != 0) {
dev_err(&pdev->dev, "Could not register CODEC: %d\n", ret); dev_err(&pdev->dev, "Could not register CODEC: %d\n", ret);
goto err_unregister_dais; goto pm_disable;
} }
ret = tegra_alt_pcm_platform_register(&pdev->dev); ret = tegra_alt_pcm_platform_register(&pdev->dev);
if (ret) { if (ret) {
dev_err(&pdev->dev, "Could not register PCM: %d\n", ret); dev_err(&pdev->dev, "Could not register PCM: %d\n", ret);
goto err_unregister_codec; goto unregister_codec;
} }
regmap_update_bits(admaif->regmap, admaif->soc_data->global_base +
TEGRA_ADMAIF_GLOBAL_ENABLE, 1, 1);
return 0; return 0;
err_unregister_codec: unregister_codec:
snd_soc_unregister_codec(&pdev->dev); snd_soc_unregister_codec(&pdev->dev);
err_unregister_dais: pm_disable:
snd_soc_unregister_component(&pdev->dev);
err_suspend:
if (!pm_runtime_status_suspended(&pdev->dev))
tegra_admaif_runtime_suspend(&pdev->dev);
err_pm_disable:
pm_runtime_disable(&pdev->dev); pm_runtime_disable(&pdev->dev);
err:
return ret; return ret;
} }

View File

@@ -25,7 +25,6 @@
#include <linux/platform_device.h> #include <linux/platform_device.h>
#include <linux/pm_runtime.h> #include <linux/pm_runtime.h>
#include <linux/regmap.h> #include <linux/regmap.h>
#include <linux/slab.h>
#include <soc/tegra/chip-id.h> #include <soc/tegra/chip-id.h>
#include <sound/core.h> #include <sound/core.h>
#include <sound/pcm.h> #include <sound/pcm.h>
@@ -805,16 +804,12 @@ static int tegra210_adx_platform_probe(struct platform_device *pdev)
match = of_match_device(tegra210_adx_of_match, &pdev->dev); match = of_match_device(tegra210_adx_of_match, &pdev->dev);
if (!match) { if (!match) {
dev_err(&pdev->dev, "Error: No device match found\n"); dev_err(&pdev->dev, "Error: No device match found\n");
ret = -ENODEV; return -ENODEV;
goto err;
} }
adx = devm_kzalloc(&pdev->dev, sizeof(struct tegra210_adx), GFP_KERNEL); adx = devm_kzalloc(&pdev->dev, sizeof(*adx), GFP_KERNEL);
if (!adx) { if (!adx)
dev_err(&pdev->dev, "Can't allocate tegra210_adx\n"); return -ENOMEM;
ret = -ENOMEM;
goto err;
}
adx->is_shutdown = false; adx->is_shutdown = false;
dev_set_drvdata(&pdev->dev, adx); dev_set_drvdata(&pdev->dev, adx);
@@ -831,39 +826,25 @@ static int tegra210_adx_platform_probe(struct platform_device *pdev)
} }
regcache_cache_only(adx->regmap, true); regcache_cache_only(adx->regmap, true);
if (of_property_read_u32(pdev->dev.of_node, ret = of_property_read_u32(pdev->dev.of_node,
"nvidia,ahub-adx-id", "nvidia,ahub-adx-id",
&pdev->dev.id) < 0) { &pdev->dev.id);
dev_err(&pdev->dev, if (ret < 0) {
"Missing property nvidia,ahub-adx-id\n"); dev_err(&pdev->dev, "Missing property nvidia,ahub-adx-id\n");
ret = -ENODEV; return ret;
goto err;
} }
pm_runtime_enable(&pdev->dev); pm_runtime_enable(&pdev->dev);
if (!pm_runtime_enabled(&pdev->dev)) {
ret = tegra210_adx_runtime_resume(&pdev->dev);
if (ret)
goto err_pm_disable;
}
ret = snd_soc_register_codec(&pdev->dev, &tegra210_adx_codec, ret = snd_soc_register_codec(&pdev->dev, &tegra210_adx_codec,
tegra210_adx_dais, tegra210_adx_dais,
ARRAY_SIZE(tegra210_adx_dais)); ARRAY_SIZE(tegra210_adx_dais));
if (ret != 0) { if (ret != 0) {
dev_err(&pdev->dev, "Could not register CODEC: %d\n", ret); dev_err(&pdev->dev, "Could not register CODEC: %d\n", ret);
goto err_suspend; pm_runtime_disable(&pdev->dev);
return ret;
} }
return 0; return 0;
err_suspend:
if (!pm_runtime_status_suspended(&pdev->dev))
tegra210_adx_runtime_suspend(&pdev->dev);
err_pm_disable:
pm_runtime_disable(&pdev->dev);
err:
return ret;
} }
static void tegra210_adx_platform_shutdown(struct platform_device *pdev) static void tegra210_adx_platform_shutdown(struct platform_device *pdev)

View File

@@ -24,12 +24,10 @@
#include <linux/platform_device.h> #include <linux/platform_device.h>
#include <linux/pm_runtime.h> #include <linux/pm_runtime.h>
#include <linux/regmap.h> #include <linux/regmap.h>
#include <linux/slab.h>
#include <sound/core.h> #include <sound/core.h>
#include <sound/pcm.h> #include <sound/pcm.h>
#include <sound/pcm_params.h> #include <sound/pcm_params.h>
#include <sound/soc.h> #include <sound/soc.h>
#include <linux/pinctrl/consumer.h>
#include <linux/of_device.h> #include <linux/of_device.h>
#include "tegra210_xbar_alt.h" #include "tegra210_xbar_alt.h"
@@ -521,17 +519,13 @@ static int tegra210_afc_platform_probe(struct platform_device *pdev)
match = of_match_device(tegra210_afc_of_match, &pdev->dev); match = of_match_device(tegra210_afc_of_match, &pdev->dev);
if (!match) { if (!match) {
dev_err(&pdev->dev, "Error: No device match found\n"); dev_err(&pdev->dev, "Error: No device match found\n");
ret = -ENODEV; return -ENODEV;
goto err;
} }
soc_data = (struct tegra210_afc_soc_data *)match->data; soc_data = (struct tegra210_afc_soc_data *)match->data;
afc = devm_kzalloc(&pdev->dev, sizeof(struct tegra210_afc), GFP_KERNEL); afc = devm_kzalloc(&pdev->dev, sizeof(*afc), GFP_KERNEL);
if (!afc) { if (!afc)
dev_err(&pdev->dev, "Can't allocate afc\n"); return -ENOMEM;
ret = -ENOMEM;
goto err;
}
afc->soc_data = soc_data; afc->soc_data = soc_data;
tegra210_afc_init(afc); tegra210_afc_init(afc);
@@ -550,42 +544,28 @@ static int tegra210_afc_platform_probe(struct platform_device *pdev)
} }
regcache_cache_only(afc->regmap, true); regcache_cache_only(afc->regmap, true);
if (of_property_read_u32(pdev->dev.of_node, ret = of_property_read_u32(pdev->dev.of_node,
"nvidia,ahub-afc-id", "nvidia,ahub-afc-id",
&pdev->dev.id) < 0) { &pdev->dev.id);
dev_err(&pdev->dev, if (ret < 0) {
"Missing property nvidia,ahub-afc-id\n"); dev_err(&pdev->dev, "Missing property nvidia,ahub-afc-id\n");
ret = -ENODEV; return -ret;
goto err;
}
pm_runtime_enable(&pdev->dev);
if (!pm_runtime_enabled(&pdev->dev)) {
ret = tegra210_afc_runtime_resume(&pdev->dev);
if (ret)
goto err_pm_disable;
} }
/* Disable SLGC */ /* Disable SLGC */
regmap_write(afc->regmap, TEGRA210_AFC_CG, 0); regmap_write(afc->regmap, TEGRA210_AFC_CG, 0);
pm_runtime_enable(&pdev->dev);
ret = snd_soc_register_codec(&pdev->dev, afc->soc_data->afc_codec, ret = snd_soc_register_codec(&pdev->dev, afc->soc_data->afc_codec,
tegra210_afc_dais, tegra210_afc_dais,
ARRAY_SIZE(tegra210_afc_dais)); ARRAY_SIZE(tegra210_afc_dais));
if (ret != 0) { if (ret != 0) {
dev_err(&pdev->dev, "Could not register CODEC: %d\n", ret); dev_err(&pdev->dev, "Could not register CODEC: %d\n", ret);
goto err_suspend; pm_runtime_disable(&pdev->dev);
return ret;
} }
return 0; return 0;
err_suspend:
if (!pm_runtime_status_suspended(&pdev->dev))
tegra210_afc_runtime_suspend(&pdev->dev);
err_pm_disable:
pm_runtime_disable(&pdev->dev);
err:
return ret;
} }
static void tegra210_afc_platform_shutdown(struct platform_device *pdev) static void tegra210_afc_platform_shutdown(struct platform_device *pdev)

View File

@@ -25,7 +25,6 @@
#include <linux/platform_device.h> #include <linux/platform_device.h>
#include <linux/pm_runtime.h> #include <linux/pm_runtime.h>
#include <linux/regmap.h> #include <linux/regmap.h>
#include <linux/slab.h>
#include <soc/tegra/chip-id.h> #include <soc/tegra/chip-id.h>
#include <sound/core.h> #include <sound/core.h>
#include <sound/pcm.h> #include <sound/pcm.h>
@@ -886,17 +885,13 @@ static int tegra210_amx_platform_probe(struct platform_device *pdev)
match = of_match_device(tegra210_amx_of_match, &pdev->dev); match = of_match_device(tegra210_amx_of_match, &pdev->dev);
if (!match) { if (!match) {
dev_err(&pdev->dev, "Error: No device match found\n"); dev_err(&pdev->dev, "Error: No device match found\n");
ret = -ENODEV; return -ENODEV;
goto err;
} }
soc_data = (struct tegra210_amx_soc_data *)match->data; soc_data = (struct tegra210_amx_soc_data *)match->data;
amx = devm_kzalloc(&pdev->dev, sizeof(struct tegra210_amx), GFP_KERNEL); amx = devm_kzalloc(&pdev->dev, sizeof(*amx), GFP_KERNEL);
if (!amx) { if (!amx)
dev_err(&pdev->dev, "Can't allocate tegra210_amx\n"); return -ENOMEM;
ret = -ENOMEM;
goto err;
}
amx->soc_data = soc_data; amx->soc_data = soc_data;
amx->is_shutdown = false; amx->is_shutdown = false;
@@ -916,46 +911,31 @@ static int tegra210_amx_platform_probe(struct platform_device *pdev)
} }
regcache_cache_only(amx->regmap, true); regcache_cache_only(amx->regmap, true);
if (of_property_read_u32(pdev->dev.of_node, ret = of_property_read_u32(pdev->dev.of_node,
"nvidia,ahub-amx-id", "nvidia,ahub-amx-id",
&pdev->dev.id) < 0) { &pdev->dev.id);
dev_err(&pdev->dev, if (ret < 0) {
"Missing property nvidia,ahub-amx-id\n"); dev_err(&pdev->dev, "Missing property nvidia,ahub-amx-id\n");
ret = -ENODEV; return ret;
goto err;
} }
/* following is necessary to have the required codec-dai-name */ /* following is necessary to have the required codec-dai-name */
if (dev_set_name(&pdev->dev, "%s.%d", DRV_NAME, pdev->dev.id)) { if (dev_set_name(&pdev->dev, "%s.%d", DRV_NAME, pdev->dev.id)) {
dev_err(&pdev->dev, "error in setting AMX dev name\n"); dev_err(&pdev->dev, "error in setting AMX dev name\n");
ret = -ENODEV; return -ENODEV;
goto err;
} }
pm_runtime_enable(&pdev->dev); pm_runtime_enable(&pdev->dev);
if (!pm_runtime_enabled(&pdev->dev)) {
ret = tegra210_amx_runtime_resume(&pdev->dev);
if (ret)
goto err_pm_disable;
}
ret = snd_soc_register_codec(&pdev->dev, &tegra210_amx_codec, ret = snd_soc_register_codec(&pdev->dev, &tegra210_amx_codec,
tegra210_amx_dais, tegra210_amx_dais,
ARRAY_SIZE(tegra210_amx_dais)); ARRAY_SIZE(tegra210_amx_dais));
if (ret != 0) { if (ret != 0) {
dev_err(&pdev->dev, "Could not register CODEC: %d\n", ret); dev_err(&pdev->dev, "Could not register CODEC: %d\n", ret);
goto err_suspend; pm_runtime_disable(&pdev->dev);
return ret;
} }
return 0; return 0;
err_suspend:
if (!pm_runtime_status_suspended(&pdev->dev))
tegra210_amx_runtime_suspend(&pdev->dev);
err_pm_disable:
pm_runtime_disable(&pdev->dev);
err:
return ret;
} }
static void tegra210_amx_platform_shutdown(struct platform_device *pdev) static void tegra210_amx_platform_shutdown(struct platform_device *pdev)

View File

@@ -568,16 +568,12 @@ static int tegra210_dmic_platform_probe(struct platform_device *pdev)
match = of_match_device(tegra210_dmic_of_match, &pdev->dev); match = of_match_device(tegra210_dmic_of_match, &pdev->dev);
if (!match) { if (!match) {
dev_err(&pdev->dev, "Error: No device match found\n"); dev_err(&pdev->dev, "Error: No device match found\n");
ret = -ENODEV; return -ENODEV;
goto err;
} }
dmic = devm_kzalloc(&pdev->dev, sizeof(struct tegra210_dmic), GFP_KERNEL); dmic = devm_kzalloc(&pdev->dev, sizeof(*dmic), GFP_KERNEL);
if (!dmic) { if (!dmic)
dev_err(&pdev->dev, "Can't allocate dmic\n"); return -ENOMEM;
ret = -ENOMEM;
goto err;
}
dmic->is_shutdown = false; dmic->is_shutdown = false;
dmic->prod_name = NULL; dmic->prod_name = NULL;
@@ -587,23 +583,21 @@ static int tegra210_dmic_platform_probe(struct platform_device *pdev)
if (!(tegra_platform_is_unit_fpga() || tegra_platform_is_fpga())) { if (!(tegra_platform_is_unit_fpga() || tegra_platform_is_fpga())) {
dmic->clk_dmic = devm_clk_get(&pdev->dev, "dmic"); dmic->clk_dmic = devm_clk_get(&pdev->dev, "dmic");
if (IS_ERR_OR_NULL(dmic->clk_dmic)) { if (IS_ERR(dmic->clk_dmic)) {
dev_err(&pdev->dev, "Can't retrieve dmic clock\n"); dev_err(&pdev->dev, "Can't retrieve dmic clock\n");
ret = PTR_ERR(dmic->clk_dmic); return PTR_ERR(dmic->clk_dmic);
goto err;
} }
dmic->clk_parent = devm_clk_get(&pdev->dev, "parent"); dmic->clk_parent = devm_clk_get(&pdev->dev, "parent");
if (IS_ERR_OR_NULL(dmic->clk_parent)) { if (IS_ERR(dmic->clk_parent)) {
dev_err(&pdev->dev, "Can't retrieve parent clock\n"); dev_err(&pdev->dev, "Can't retrieve parent clock\n");
ret = PTR_ERR(dmic->clk_parent); return PTR_ERR(dmic->clk_parent);
goto err;
} }
ret = clk_set_parent(dmic->clk_dmic, dmic->clk_parent); ret = clk_set_parent(dmic->clk_dmic, dmic->clk_parent);
if (ret) { if (ret) {
dev_err(&pdev->dev, "Can't set parent of dmic clock\n"); dev_err(&pdev->dev, "Can't set parent of dmic clock\n");
goto err; return ret;
} }
} }
@@ -623,27 +617,21 @@ static int tegra210_dmic_platform_probe(struct platform_device *pdev)
regmap_write(dmic->regmap, TEGRA210_DMIC_DCR_BIQUAD_0_COEF_4, regmap_write(dmic->regmap, TEGRA210_DMIC_DCR_BIQUAD_0_COEF_4,
0x00000000); 0x00000000);
if (of_property_read_u32(np, "nvidia,ahub-dmic-id", ret = of_property_read_u32(np, "nvidia,ahub-dmic-id",
&pdev->dev.id) < 0) { &pdev->dev.id);
dev_err(&pdev->dev, if (ret < 0) {
"Missing property nvidia,ahub-dmic-id\n"); dev_err(&pdev->dev, "Missing property nvidia,ahub-dmic-id\n");
ret = -ENODEV; return ret;
goto err;
} }
pm_runtime_enable(&pdev->dev); pm_runtime_enable(&pdev->dev);
if (!pm_runtime_enabled(&pdev->dev)) {
ret = tegra210_dmic_runtime_resume(&pdev->dev);
if (ret)
goto err_pm_disable;
}
ret = snd_soc_register_codec(&pdev->dev, &tegra210_dmic_codec, ret = snd_soc_register_codec(&pdev->dev, &tegra210_dmic_codec,
tegra210_dmic_dais, tegra210_dmic_dais,
ARRAY_SIZE(tegra210_dmic_dais)); ARRAY_SIZE(tegra210_dmic_dais));
if (ret != 0) { if (ret != 0) {
dev_err(&pdev->dev, "Could not register CODEC: %d\n", ret); dev_err(&pdev->dev, "Could not register CODEC: %d\n", ret);
goto err_suspend; pm_runtime_disable(&pdev->dev);
return ret;
} }
if (of_property_read_string(np, "prod-name", &dmic->prod_name) == 0) { if (of_property_read_string(np, "prod-name", &dmic->prod_name) == 0) {
@@ -674,15 +662,8 @@ static int tegra210_dmic_platform_probe(struct platform_device *pdev)
} }
err_dap: err_dap:
return 0;
err_suspend: return 0;
if (!pm_runtime_status_suspended(&pdev->dev))
tegra210_dmic_runtime_suspend(&pdev->dev);
err_pm_disable:
pm_runtime_disable(&pdev->dev);
err:
return ret;
} }
static void tegra210_dmic_platform_shutdown(struct platform_device *pdev) static void tegra210_dmic_platform_shutdown(struct platform_device *pdev)

View File

@@ -25,7 +25,6 @@
#include <linux/platform_device.h> #include <linux/platform_device.h>
#include <linux/pm_runtime.h> #include <linux/pm_runtime.h>
#include <linux/regmap.h> #include <linux/regmap.h>
#include <linux/slab.h>
#include <sound/core.h> #include <sound/core.h>
#include <sound/pcm.h> #include <sound/pcm.h>
#include <sound/pcm_params.h> #include <sound/pcm_params.h>
@@ -35,7 +34,6 @@
#include <linux/regulator/consumer.h> #include <linux/regulator/consumer.h>
#include <linux/of_device.h> #include <linux/of_device.h>
#include <linux/delay.h> #include <linux/delay.h>
#include <linux/debugfs.h>
#include <linux/tegra-powergate.h> #include <linux/tegra-powergate.h>
#include <soc/tegra/chip-id.h> #include <soc/tegra/chip-id.h>
#include <linux/pm_domain.h> #include <linux/pm_domain.h>
@@ -1068,16 +1066,12 @@ static int tegra210_i2s_platform_probe(struct platform_device *pdev)
match = of_match_device(tegra210_i2s_of_match, &pdev->dev); match = of_match_device(tegra210_i2s_of_match, &pdev->dev);
if (!match) { if (!match) {
dev_err(&pdev->dev, "Error: No device match found\n"); dev_err(&pdev->dev, "Error: No device match found\n");
ret = -ENODEV; return -ENODEV;
goto err;
} }
i2s = devm_kzalloc(&pdev->dev, sizeof(struct tegra210_i2s), GFP_KERNEL); i2s = devm_kzalloc(&pdev->dev, sizeof(*i2s), GFP_KERNEL);
if (!i2s) { if (!i2s)
dev_err(&pdev->dev, "Can't allocate i2s\n"); return -ENOMEM;
ret = -ENOMEM;
goto err;
}
i2s->tx_mask = i2s->rx_mask = 0xFFFF; i2s->tx_mask = i2s->rx_mask = 0xFFFF;
i2s->enable_cya = false; i2s->enable_cya = false;
@@ -1092,8 +1086,7 @@ static int tegra210_i2s_platform_probe(struct platform_device *pdev)
i2s->clk_i2s = devm_clk_get(&pdev->dev, NULL); i2s->clk_i2s = devm_clk_get(&pdev->dev, NULL);
if (IS_ERR(i2s->clk_i2s)) { if (IS_ERR(i2s->clk_i2s)) {
dev_err(&pdev->dev, "Can't retrieve i2s clock\n"); dev_err(&pdev->dev, "Can't retrieve i2s clock\n");
ret = PTR_ERR(i2s->clk_i2s); return PTR_ERR(i2s->clk_i2s);
goto err;
} }
i2s->clk_i2s_sync = devm_clk_get(&pdev->dev, "ext_audio_sync"); i2s->clk_i2s_sync = devm_clk_get(&pdev->dev, "ext_audio_sync");
@@ -1107,8 +1100,7 @@ static int tegra210_i2s_platform_probe(struct platform_device *pdev)
i2s->clk_i2s_source = devm_clk_get(&pdev->dev, "i2s_clk_parent"); i2s->clk_i2s_source = devm_clk_get(&pdev->dev, "i2s_clk_parent");
if (IS_ERR(i2s->clk_i2s_source)) { if (IS_ERR(i2s->clk_i2s_source)) {
dev_err(&pdev->dev, "Can't retrieve pll_a_out0 clock\n"); dev_err(&pdev->dev, "Can't retrieve pll_a_out0 clock\n");
ret = PTR_ERR(i2s->clk_i2s_source); return PTR_ERR(i2s->clk_i2s_source);
goto err;
} }
} }
@@ -1124,12 +1116,11 @@ static int tegra210_i2s_platform_probe(struct platform_device *pdev)
} }
regcache_cache_only(i2s->regmap, true); regcache_cache_only(i2s->regmap, true);
if (of_property_read_u32(np, "nvidia,ahub-i2s-id", ret = of_property_read_u32(np, "nvidia,ahub-i2s-id",
&pdev->dev.id) < 0) { &pdev->dev.id);
dev_err(&pdev->dev, if (ret < 0) {
"Missing property nvidia,ahub-i2s-id\n"); dev_err(&pdev->dev, "Missing property nvidia,ahub-i2s-id\n");
ret = -ENODEV; return ret;
goto err;
} }
if (of_property_read_u32(pdev->dev.of_node, "bclk-ratio", if (of_property_read_u32(pdev->dev.of_node, "bclk-ratio",
@@ -1152,32 +1143,31 @@ static int tegra210_i2s_platform_probe(struct platform_device *pdev)
i2s->fsync_width = 31; i2s->fsync_width = 31;
} }
i2s->enable_cya = i2s->enable_cya = of_property_read_bool(pdev->dev.of_node,
of_property_read_bool(pdev->dev.of_node, "enable-cya");
"enable-cya");
if (!(tegra_platform_is_unit_fpga() || tegra_platform_is_fpga())) { if (!(tegra_platform_is_unit_fpga() || tegra_platform_is_fpga())) {
if (of_property_read_string(np, "prod-name", if (of_property_read_string(np, "prod-name",
&i2s->prod_name) == 0) &i2s->prod_name) == 0)
tegra_pinctrl_config_prod(&pdev->dev, i2s->prod_name); tegra_pinctrl_config_prod(&pdev->dev, i2s->prod_name);
num_supplies = num_supplies = of_property_count_strings(np,
of_property_count_strings(np, "regulator-supplies"); "regulator-supplies");
if (num_supplies > 0) { if (num_supplies > 0) {
i2s->num_supplies = num_supplies; i2s->num_supplies = num_supplies;
i2s->supplies = devm_kzalloc(&pdev->dev, num_supplies * i2s->supplies = devm_kzalloc(&pdev->dev, num_supplies *
sizeof(*i2s->supplies), GFP_KERNEL); sizeof(*i2s->supplies),
if (!i2s->supplies) { GFP_KERNEL);
ret = -ENOMEM; if (!i2s->supplies)
goto err; return -ENOMEM;
}
of_property_for_each_string(np, of_property_for_each_string(np, "regulator-supplies",
"regulator-supplies", prop, supply) prop, supply)
i2s->supplies[count++].supply = supply; i2s->supplies[count++].supply = supply;
ret = devm_regulator_bulk_get( ret = devm_regulator_bulk_get(&pdev->dev,
&pdev->dev, i2s->num_supplies, i2s->num_supplies,
i2s->supplies); i2s->supplies);
if (ret) { if (ret) {
dev_err(&pdev->dev, dev_err(&pdev->dev,
"Failed to get supplies: %d\n", ret); "Failed to get supplies: %d\n", ret);
@@ -1192,45 +1182,33 @@ static int tegra210_i2s_platform_probe(struct platform_device *pdev)
} }
i2s->pin_default_state = pinctrl_lookup_state(i2s->pinctrl, i2s->pin_default_state = pinctrl_lookup_state(i2s->pinctrl,
"dap_active"); "dap_active");
if (IS_ERR(i2s->pin_default_state)) { if (IS_ERR(i2s->pin_default_state)) {
dev_dbg(&pdev->dev, "Missing dap-active state\n"); dev_dbg(&pdev->dev, "Missing dap-active state\n");
goto err_dap; goto err_dap;
} }
i2s->pin_idle_state = pinctrl_lookup_state(i2s->pinctrl, i2s->pin_idle_state = pinctrl_lookup_state(i2s->pinctrl,
"dap_inactive"); "dap_inactive");
if (IS_ERR(i2s->pin_idle_state)) { if (IS_ERR(i2s->pin_idle_state)) {
dev_dbg(&pdev->dev, "Missing dap-inactive state\n"); dev_dbg(&pdev->dev, "Missing dap-inactive state\n");
goto err_dap; goto err_dap;
} }
} }
err_dap: err_dap:
pm_runtime_enable(&pdev->dev); pm_runtime_enable(&pdev->dev);
if (!pm_runtime_enabled(&pdev->dev)) {
ret = tegra210_i2s_runtime_resume(&pdev->dev);
if (ret)
goto err_pm_disable;
}
ret = snd_soc_register_codec(&pdev->dev, &tegra210_i2s_codec, ret = snd_soc_register_codec(&pdev->dev, &tegra210_i2s_codec,
tegra210_i2s_dais, tegra210_i2s_dais,
ARRAY_SIZE(tegra210_i2s_dais)); ARRAY_SIZE(tegra210_i2s_dais));
if (ret != 0) { if (ret != 0) {
dev_err(&pdev->dev, "Could not register CODEC: %d\n", ret); dev_err(&pdev->dev, "Could not register CODEC: %d\n", ret);
goto err_suspend; pm_runtime_disable(&pdev->dev);
return ret;
} }
return 0; return 0;
err_suspend:
if (!pm_runtime_status_suspended(&pdev->dev))
tegra210_i2s_runtime_suspend(&pdev->dev);
err_pm_disable:
pm_runtime_disable(&pdev->dev);
err:
return ret;
} }
static void tegra210_i2s_platform_shutdown(struct platform_device *pdev) static void tegra210_i2s_platform_shutdown(struct platform_device *pdev)

View File

@@ -23,14 +23,11 @@
#include <linux/platform_device.h> #include <linux/platform_device.h>
#include <linux/pm_runtime.h> #include <linux/pm_runtime.h>
#include <linux/regmap.h> #include <linux/regmap.h>
#include <linux/slab.h>
#include <sound/core.h> #include <sound/core.h>
#include <sound/pcm.h> #include <sound/pcm.h>
#include <sound/pcm_params.h> #include <sound/pcm_params.h>
#include <sound/soc.h> #include <sound/soc.h>
#include <linux/pinctrl/consumer.h>
#include <linux/of_device.h> #include <linux/of_device.h>
#include <linux/debugfs.h>
#include <linux/tegra-soc.h> #include <linux/tegra-soc.h>
#include "tegra210_xbar_alt.h" #include "tegra210_xbar_alt.h"
@@ -300,16 +297,12 @@ static int tegra210_iqc_platform_probe(struct platform_device *pdev)
match = of_match_device(tegra210_iqc_of_match, &pdev->dev); match = of_match_device(tegra210_iqc_of_match, &pdev->dev);
if (!match) { if (!match) {
dev_err(&pdev->dev, "Error: No device match found\n"); dev_err(&pdev->dev, "Error: No device match found\n");
ret = -ENODEV; return -ENODEV;
goto err;
} }
iqc = devm_kzalloc(&pdev->dev, sizeof(struct tegra210_iqc), GFP_KERNEL); iqc = devm_kzalloc(&pdev->dev, sizeof(*iqc), GFP_KERNEL);
if (!iqc) { if (!iqc)
dev_err(&pdev->dev, "Can't allocate iqc\n"); return -ENOMEM;
ret = -ENOMEM;
goto err;
}
dev_set_drvdata(&pdev->dev, iqc); dev_set_drvdata(&pdev->dev, iqc);
@@ -317,8 +310,7 @@ static int tegra210_iqc_platform_probe(struct platform_device *pdev)
iqc->clk_iqc = devm_clk_get(&pdev->dev, NULL); iqc->clk_iqc = devm_clk_get(&pdev->dev, NULL);
if (IS_ERR(iqc->clk_iqc)) { if (IS_ERR(iqc->clk_iqc)) {
dev_err(&pdev->dev, "Can't retrieve iqc clock\n"); dev_err(&pdev->dev, "Can't retrieve iqc clock\n");
ret = PTR_ERR(iqc->clk_iqc); return PTR_ERR(iqc->clk_iqc);
goto err;
} }
} }
@@ -334,19 +326,18 @@ static int tegra210_iqc_platform_probe(struct platform_device *pdev)
} }
regcache_cache_only(iqc->regmap, true); regcache_cache_only(iqc->regmap, true);
if (of_property_read_u32(pdev->dev.of_node, ret = of_property_read_u32(pdev->dev.of_node,
"nvidia,ahub-iqc-id", "nvidia,ahub-iqc-id",
&pdev->dev.id) < 0) { &pdev->dev.id);
dev_err(&pdev->dev, if (ret < 0) {
"Missing property nvidia,ahub-iqc-id\n"); dev_err(&pdev->dev, "Missing property nvidia,ahub-iqc-id\n");
ret = -ENODEV; return ret;
goto err;
} }
if (of_property_read_u32(pdev->dev.of_node, if (of_property_read_u32(pdev->dev.of_node,
"timestamp-enable", "timestamp-enable",
&iqc->timestamp_enable) < 0) { &iqc->timestamp_enable) < 0) {
dev_err(&pdev->dev, dev_dbg(&pdev->dev,
"Missing property timestamp-enable for IQC\n"); "Missing property timestamp-enable for IQC\n");
iqc->timestamp_enable = 1; iqc->timestamp_enable = 1;
} }
@@ -354,35 +345,22 @@ static int tegra210_iqc_platform_probe(struct platform_device *pdev)
if (of_property_read_u32(pdev->dev.of_node, if (of_property_read_u32(pdev->dev.of_node,
"data-offset", "data-offset",
&iqc->data_offset) < 0) { &iqc->data_offset) < 0) {
dev_err(&pdev->dev, dev_dbg(&pdev->dev,
"Missing property data-offset for IQC\n"); "Missing property data-offset for IQC\n");
iqc->data_offset = 0; iqc->data_offset = 0;
} }
pm_runtime_enable(&pdev->dev); pm_runtime_enable(&pdev->dev);
if (!pm_runtime_enabled(&pdev->dev)) {
ret = tegra210_iqc_runtime_resume(&pdev->dev);
if (ret)
goto err_pm_disable;
}
ret = snd_soc_register_codec(&pdev->dev, &tegra210_iqc_codec, ret = snd_soc_register_codec(&pdev->dev, &tegra210_iqc_codec,
tegra210_iqc_dais, tegra210_iqc_dais,
ARRAY_SIZE(tegra210_iqc_dais)); ARRAY_SIZE(tegra210_iqc_dais));
if (ret != 0) { if (ret != 0) {
dev_err(&pdev->dev, "Could not register CODEC: %d\n", ret); dev_err(&pdev->dev, "Could not register CODEC: %d\n", ret);
goto err_suspend; pm_runtime_disable(&pdev->dev);
return ret;
} }
return 0; return 0;
err_suspend:
if (!pm_runtime_status_suspended(&pdev->dev))
tegra210_iqc_runtime_suspend(&pdev->dev);
err_pm_disable:
pm_runtime_disable(&pdev->dev);
err:
return ret;
} }
static int tegra210_iqc_platform_remove(struct platform_device *pdev) static int tegra210_iqc_platform_remove(struct platform_device *pdev)

View File

@@ -21,7 +21,6 @@
#include <linux/module.h> #include <linux/module.h>
#include <linux/pm_runtime.h> #include <linux/pm_runtime.h>
#include <linux/regmap.h> #include <linux/regmap.h>
#include <linux/slab.h>
#include <sound/core.h> #include <sound/core.h>
#include <sound/soc.h> #include <sound/soc.h>

View File

@@ -24,7 +24,6 @@
#include <linux/platform_device.h> #include <linux/platform_device.h>
#include <linux/pm_runtime.h> #include <linux/pm_runtime.h>
#include <linux/regmap.h> #include <linux/regmap.h>
#include <linux/slab.h>
#include <sound/core.h> #include <sound/core.h>
#include <sound/pcm.h> #include <sound/pcm.h>
#include <sound/pcm_params.h> #include <sound/pcm_params.h>
@@ -688,17 +687,12 @@ static int tegra210_mixer_platform_probe(struct platform_device *pdev)
match = of_match_device(tegra210_mixer_of_match, &pdev->dev); match = of_match_device(tegra210_mixer_of_match, &pdev->dev);
if (!match) { if (!match) {
dev_err(&pdev->dev, "Error: No device match found\n"); dev_err(&pdev->dev, "Error: No device match found\n");
ret = -ENODEV; return -ENODEV;
goto err;
} }
mixer = devm_kzalloc(&pdev->dev, mixer = devm_kzalloc(&pdev->dev, sizeof(*mixer), GFP_KERNEL);
sizeof(struct tegra210_mixer), GFP_KERNEL); if (!mixer)
if (!mixer) { return -ENOMEM;
dev_err(&pdev->dev, "Can't allocate tegra210_mixer\n");
ret = -ENOMEM;
goto err;
}
mixer->is_shutdown = false; mixer->is_shutdown = false;
mixer->gain_coeff[0] = 0; mixer->gain_coeff[0] = 0;
@@ -732,39 +726,25 @@ static int tegra210_mixer_platform_probe(struct platform_device *pdev)
} }
regcache_cache_only(mixer->regmap, true); regcache_cache_only(mixer->regmap, true);
if (of_property_read_u32(pdev->dev.of_node, ret = of_property_read_u32(pdev->dev.of_node,
"nvidia,ahub-amixer-id", "nvidia,ahub-amixer-id",
&pdev->dev.id) < 0) { &pdev->dev.id);
dev_err(&pdev->dev, if (ret < 0) {
"Missing property nvidia,ahub-amixer-id\n"); dev_err(&pdev->dev, "Missing property nvidia,ahub-amixer-id\n");
ret = -ENODEV; return ret;
goto err;
} }
pm_runtime_enable(&pdev->dev); pm_runtime_enable(&pdev->dev);
if (!pm_runtime_enabled(&pdev->dev)) {
ret = tegra210_mixer_runtime_resume(&pdev->dev);
if (ret)
goto err_pm_disable;
}
ret = snd_soc_register_codec(&pdev->dev, &tegra210_mixer_codec, ret = snd_soc_register_codec(&pdev->dev, &tegra210_mixer_codec,
tegra210_mixer_dais, tegra210_mixer_dais,
ARRAY_SIZE(tegra210_mixer_dais)); ARRAY_SIZE(tegra210_mixer_dais));
if (ret != 0) { if (ret != 0) {
dev_err(&pdev->dev, "Could not register CODEC: %d\n", ret); dev_err(&pdev->dev, "Could not register CODEC: %d\n", ret);
goto err_suspend; pm_runtime_disable(&pdev->dev);
return ret;
} }
return 0; return 0;
err_suspend:
if (!pm_runtime_status_suspended(&pdev->dev))
tegra210_mixer_runtime_suspend(&pdev->dev);
err_pm_disable:
pm_runtime_disable(&pdev->dev);
err:
return ret;
} }
static void tegra210_mixer_platform_shutdown(struct platform_device *pdev) static void tegra210_mixer_platform_shutdown(struct platform_device *pdev)

View File

@@ -23,12 +23,10 @@
#include <linux/platform_device.h> #include <linux/platform_device.h>
#include <linux/pm_runtime.h> #include <linux/pm_runtime.h>
#include <linux/regmap.h> #include <linux/regmap.h>
#include <linux/slab.h>
#include <sound/core.h> #include <sound/core.h>
#include <sound/pcm.h> #include <sound/pcm.h>
#include <sound/pcm_params.h> #include <sound/pcm_params.h>
#include <sound/soc.h> #include <sound/soc.h>
#include <linux/pinctrl/consumer.h>
#include <linux/of_device.h> #include <linux/of_device.h>
#include <linux/delay.h> #include <linux/delay.h>
@@ -627,16 +625,12 @@ static int tegra210_mvc_platform_probe(struct platform_device *pdev)
match = of_match_device(tegra210_mvc_of_match, &pdev->dev); match = of_match_device(tegra210_mvc_of_match, &pdev->dev);
if (!match) { if (!match) {
dev_err(&pdev->dev, "Error: No device match found\n"); dev_err(&pdev->dev, "Error: No device match found\n");
ret = -ENODEV; return -ENODEV;
goto err;
} }
mvc = devm_kzalloc(&pdev->dev, sizeof(struct tegra210_mvc), GFP_KERNEL); mvc = devm_kzalloc(&pdev->dev, sizeof(*mvc), GFP_KERNEL);
if (!mvc) { if (!mvc)
dev_err(&pdev->dev, "Can't allocate mvc\n"); return -ENOMEM;
ret = -ENOMEM;
goto err;
}
mvc->is_shutdown = false; mvc->is_shutdown = false;
dev_set_drvdata(&pdev->dev, mvc); dev_set_drvdata(&pdev->dev, mvc);
@@ -669,39 +663,25 @@ static int tegra210_mvc_platform_probe(struct platform_device *pdev)
} }
regcache_cache_only(mvc->regmap, true); regcache_cache_only(mvc->regmap, true);
if (of_property_read_u32(pdev->dev.of_node, ret = of_property_read_u32(pdev->dev.of_node,
"nvidia,ahub-mvc-id", "nvidia,ahub-mvc-id",
&pdev->dev.id) < 0) { &pdev->dev.id);
dev_err(&pdev->dev, if (ret < 0) {
"Missing property nvidia,ahub-mvc-id\n"); dev_err(&pdev->dev, "Missing property nvidia,ahub-mvc-id\n");
ret = -ENODEV; return ret;
goto err;
} }
pm_runtime_enable(&pdev->dev); pm_runtime_enable(&pdev->dev);
if (!pm_runtime_enabled(&pdev->dev)) {
ret = tegra210_mvc_runtime_resume(&pdev->dev);
if (ret)
goto err_pm_disable;
}
ret = snd_soc_register_codec(&pdev->dev, &tegra210_mvc_codec, ret = snd_soc_register_codec(&pdev->dev, &tegra210_mvc_codec,
tegra210_mvc_dais, tegra210_mvc_dais,
ARRAY_SIZE(tegra210_mvc_dais)); ARRAY_SIZE(tegra210_mvc_dais));
if (ret != 0) { if (ret != 0) {
dev_err(&pdev->dev, "Could not register CODEC: %d\n", ret); dev_err(&pdev->dev, "Could not register CODEC: %d\n", ret);
goto err_suspend; pm_runtime_disable(&pdev->dev);
return ret;
} }
return 0; return 0;
err_suspend:
if (!pm_runtime_status_suspended(&pdev->dev))
tegra210_mvc_runtime_suspend(&pdev->dev);
err_pm_disable:
pm_runtime_disable(&pdev->dev);
err:
return ret;
} }
static void tegra210_mvc_platform_shutdown(struct platform_device *pdev) static void tegra210_mvc_platform_shutdown(struct platform_device *pdev)

View File

@@ -24,12 +24,10 @@
#include <linux/platform_device.h> #include <linux/platform_device.h>
#include <linux/pm_runtime.h> #include <linux/pm_runtime.h>
#include <linux/regmap.h> #include <linux/regmap.h>
#include <linux/slab.h>
#include <sound/core.h> #include <sound/core.h>
#include <sound/pcm.h> #include <sound/pcm.h>
#include <sound/pcm_params.h> #include <sound/pcm_params.h>
#include <sound/soc.h> #include <sound/soc.h>
#include <linux/pinctrl/consumer.h>
#include <linux/of_device.h> #include <linux/of_device.h>
#include "tegra210_xbar_alt.h" #include "tegra210_xbar_alt.h"
@@ -326,16 +324,12 @@ static int tegra210_ope_platform_probe(struct platform_device *pdev)
match = of_match_device(tegra210_ope_of_match, &pdev->dev); match = of_match_device(tegra210_ope_of_match, &pdev->dev);
if (!match) { if (!match) {
dev_err(&pdev->dev, "Error: No device match found\n"); dev_err(&pdev->dev, "Error: No device match found\n");
ret = -ENODEV; return -ENODEV;
goto err;
} }
ope = devm_kzalloc(&pdev->dev, sizeof(struct tegra210_ope), GFP_KERNEL); ope = devm_kzalloc(&pdev->dev, sizeof(*ope), GFP_KERNEL);
if (!ope) { if (!ope)
dev_err(&pdev->dev, "Can't allocate ope\n"); return -ENOMEM;
ret = -ENOMEM;
goto err;
}
ope->is_shutdown = false; ope->is_shutdown = false;
@@ -356,52 +350,38 @@ static int tegra210_ope_platform_probe(struct platform_device *pdev)
ret = tegra210_peq_init(pdev, TEGRA210_PEQ_IORESOURCE_MEM); ret = tegra210_peq_init(pdev, TEGRA210_PEQ_IORESOURCE_MEM);
if (ret < 0) { if (ret < 0) {
dev_err(&pdev->dev, "peq init failed\n"); dev_err(&pdev->dev, "peq init failed\n");
goto err; return ret;
} }
regcache_cache_only(ope->peq_regmap, true); regcache_cache_only(ope->peq_regmap, true);
ret = tegra210_mbdrc_init(pdev, TEGRA210_MBDRC_IORESOURCE_MEM); ret = tegra210_mbdrc_init(pdev, TEGRA210_MBDRC_IORESOURCE_MEM);
if (ret < 0) { if (ret < 0) {
dev_err(&pdev->dev, "mbdrc init failed\n"); dev_err(&pdev->dev, "mbdrc init failed\n");
goto err; return ret;
} }
regcache_cache_only(ope->mbdrc_regmap, true); regcache_cache_only(ope->mbdrc_regmap, true);
if (of_property_read_u32(pdev->dev.of_node, ret = of_property_read_u32(pdev->dev.of_node,
"nvidia,ahub-ope-id", "nvidia,ahub-ope-id",
&pdev->dev.id) < 0) { &pdev->dev.id);
dev_err(&pdev->dev, if (ret < 0) {
"Missing property nvidia,ahub-ope-id\n"); dev_err(&pdev->dev, "Missing property nvidia,ahub-ope-id\n");
ret = -ENODEV; return ret;
goto err;
} }
pm_runtime_enable(&pdev->dev); pm_runtime_enable(&pdev->dev);
if (!pm_runtime_enabled(&pdev->dev)) {
ret = tegra210_ope_runtime_resume(&pdev->dev);
if (ret)
goto err_pm_disable;
}
ret = snd_soc_register_codec(&pdev->dev, &tegra210_ope_codec, ret = snd_soc_register_codec(&pdev->dev, &tegra210_ope_codec,
tegra210_ope_dais, tegra210_ope_dais,
ARRAY_SIZE(tegra210_ope_dais)); ARRAY_SIZE(tegra210_ope_dais));
if (ret != 0) { if (ret != 0) {
dev_err(&pdev->dev, "Could not register CODEC: %d\n", ret); dev_err(&pdev->dev, "Could not register CODEC: %d\n", ret);
goto err_suspend; pm_runtime_disable(&pdev->dev);
return ret;
} }
pr_info("OPE platform probe successful\n"); pr_info("OPE platform probe successful\n");
return 0; return 0;
err_suspend:
if (!pm_runtime_status_suspended(&pdev->dev))
tegra210_ope_runtime_suspend(&pdev->dev);
err_pm_disable:
pm_runtime_disable(&pdev->dev);
err:
return ret;
} }
static void tegra210_ope_platform_shutdown(struct platform_device *pdev) static void tegra210_ope_platform_shutdown(struct platform_device *pdev)

View File

@@ -24,12 +24,10 @@
#include <linux/platform_device.h> #include <linux/platform_device.h>
#include <linux/pm_runtime.h> #include <linux/pm_runtime.h>
#include <linux/regmap.h> #include <linux/regmap.h>
#include <linux/slab.h>
#include <sound/core.h> #include <sound/core.h>
#include <sound/pcm.h> #include <sound/pcm.h>
#include <sound/pcm_params.h> #include <sound/pcm_params.h>
#include <sound/soc.h> #include <sound/soc.h>
#include <linux/pinctrl/consumer.h>
#include <linux/of_device.h> #include <linux/of_device.h>
#include "tegra210_xbar_alt.h" #include "tegra210_xbar_alt.h"

View File

@@ -23,12 +23,10 @@
#include <linux/platform_device.h> #include <linux/platform_device.h>
#include <linux/pm_runtime.h> #include <linux/pm_runtime.h>
#include <linux/regmap.h> #include <linux/regmap.h>
#include <linux/slab.h>
#include <sound/core.h> #include <sound/core.h>
#include <sound/pcm.h> #include <sound/pcm.h>
#include <sound/pcm_params.h> #include <sound/pcm_params.h>
#include <sound/soc.h> #include <sound/soc.h>
#include <linux/pinctrl/consumer.h>
#include <linux/of_device.h> #include <linux/of_device.h>
#include <linux/delay.h> #include <linux/delay.h>
@@ -3555,16 +3553,12 @@ static int tegra210_sfc_platform_probe(struct platform_device *pdev)
match = of_match_device(tegra210_sfc_of_match, &pdev->dev); match = of_match_device(tegra210_sfc_of_match, &pdev->dev);
if (!match) { if (!match) {
dev_err(&pdev->dev, "Error: No device match found\n"); dev_err(&pdev->dev, "Error: No device match found\n");
ret = -ENODEV; return -ENODEV;
goto err;
} }
sfc = devm_kzalloc(&pdev->dev, sizeof(struct tegra210_sfc), GFP_KERNEL); sfc = devm_kzalloc(&pdev->dev, sizeof(*sfc), GFP_KERNEL);
if (!sfc) { if (!sfc)
dev_err(&pdev->dev, "Can't allocate sfc\n"); return -ENOMEM;
ret = -ENOMEM;
goto err;
}
sfc->is_shutdown = false; sfc->is_shutdown = false;
@@ -3585,39 +3579,25 @@ static int tegra210_sfc_platform_probe(struct platform_device *pdev)
} }
regcache_cache_only(sfc->regmap, true); regcache_cache_only(sfc->regmap, true);
if (of_property_read_u32(pdev->dev.of_node, ret = of_property_read_u32(pdev->dev.of_node,
"nvidia,ahub-sfc-id", "nvidia,ahub-sfc-id",
&pdev->dev.id) < 0) { &pdev->dev.id);
dev_err(&pdev->dev, if (ret < 0) {
"Missing property nvidia,ahub-sfc-id\n"); dev_err(&pdev->dev, "Missing property nvidia,ahub-sfc-id\n");
ret = -ENODEV; return ret;
goto err;
} }
pm_runtime_enable(&pdev->dev); pm_runtime_enable(&pdev->dev);
if (!pm_runtime_enabled(&pdev->dev)) {
ret = tegra210_sfc_runtime_resume(&pdev->dev);
if (ret)
goto err_pm_disable;
}
ret = snd_soc_register_codec(&pdev->dev, &tegra210_sfc_codec, ret = snd_soc_register_codec(&pdev->dev, &tegra210_sfc_codec,
tegra210_sfc_dais, tegra210_sfc_dais,
ARRAY_SIZE(tegra210_sfc_dais)); ARRAY_SIZE(tegra210_sfc_dais));
if (ret != 0) { if (ret != 0) {
dev_err(&pdev->dev, "Could not register CODEC: %d\n", ret); dev_err(&pdev->dev, "Could not register CODEC: %d\n", ret);
goto err_suspend; pm_runtime_disable(&pdev->dev);
return ret;
} }
return 0; return 0;
err_suspend:
if (!pm_runtime_status_suspended(&pdev->dev))
tegra210_sfc_runtime_suspend(&pdev->dev);
err_pm_disable:
pm_runtime_disable(&pdev->dev);
err:
return ret;
} }
static void tegra210_sfc_platform_shutdown(struct platform_device *pdev) static void tegra210_sfc_platform_shutdown(struct platform_device *pdev)

View File

@@ -24,7 +24,6 @@
#include <linux/platform_device.h> #include <linux/platform_device.h>
#include <linux/pm_runtime.h> #include <linux/pm_runtime.h>
#include <linux/regmap.h> #include <linux/regmap.h>
#include <linux/slab.h>
#include <soc/tegra/chip-id.h> #include <soc/tegra/chip-id.h>
#include <sound/core.h> #include <sound/core.h>
#include <sound/pcm.h> #include <sound/pcm.h>
@@ -424,17 +423,12 @@ static int tegra210_spdif_platform_probe(struct platform_device *pdev)
match = of_match_device(tegra210_spdif_of_match, &pdev->dev); match = of_match_device(tegra210_spdif_of_match, &pdev->dev);
if (!match) { if (!match) {
dev_err(&pdev->dev, "Error: No device match found\n"); dev_err(&pdev->dev, "Error: No device match found\n");
ret = -ENODEV; return -ENODEV;
goto err;
} }
spdif = devm_kzalloc(&pdev->dev, sizeof(struct tegra210_spdif), spdif = devm_kzalloc(&pdev->dev, sizeof(*spdif), GFP_KERNEL);
GFP_KERNEL); if (!spdif)
if (!spdif) { return -ENOMEM;
dev_err(&pdev->dev, "Can't allocate tegra210_spdif\n");
ret = -ENOMEM;
goto err;
}
spdif->is_shutdown = false; spdif->is_shutdown = false;
dev_set_drvdata(&pdev->dev, spdif); dev_set_drvdata(&pdev->dev, spdif);
@@ -443,29 +437,25 @@ static int tegra210_spdif_platform_probe(struct platform_device *pdev)
spdif->clk_pll_a_out0 = devm_clk_get(&pdev->dev, "pll_a_out0"); spdif->clk_pll_a_out0 = devm_clk_get(&pdev->dev, "pll_a_out0");
if (IS_ERR(spdif->clk_pll_a_out0)) { if (IS_ERR(spdif->clk_pll_a_out0)) {
dev_err(&pdev->dev, "Can't retrieve pll_a_out0 clock\n"); dev_err(&pdev->dev, "Can't retrieve pll_a_out0 clock\n");
ret = PTR_ERR(spdif->clk_pll_a_out0); return PTR_ERR(spdif->clk_pll_a_out0);
goto err;
} }
spdif->clk_pll_p_out0 = devm_clk_get(&pdev->dev, "pll_p_out0"); spdif->clk_pll_p_out0 = devm_clk_get(&pdev->dev, "pll_p_out0");
if (IS_ERR(spdif->clk_pll_p_out0)) { if (IS_ERR(spdif->clk_pll_p_out0)) {
dev_err(&pdev->dev, "Can't retrieve pll_p_out0 clock\n"); dev_err(&pdev->dev, "Can't retrieve pll_p_out0 clock\n");
ret = PTR_ERR(spdif->clk_pll_p_out0); return PTR_ERR(spdif->clk_pll_p_out0);
goto err;
} }
spdif->clk_spdif_out = devm_clk_get(&pdev->dev, "spdif_out"); spdif->clk_spdif_out = devm_clk_get(&pdev->dev, "spdif_out");
if (IS_ERR(spdif->clk_spdif_out)) { if (IS_ERR(spdif->clk_spdif_out)) {
dev_err(&pdev->dev, "Can't retrieve spdif clock\n"); dev_err(&pdev->dev, "Can't retrieve spdif clock\n");
ret = PTR_ERR(spdif->clk_spdif_out); return PTR_ERR(spdif->clk_spdif_out);
goto err;
} }
spdif->clk_spdif_in = devm_clk_get(&pdev->dev, "spdif_in"); spdif->clk_spdif_in = devm_clk_get(&pdev->dev, "spdif_in");
if (IS_ERR(spdif->clk_spdif_in)) { if (IS_ERR(spdif->clk_spdif_in)) {
dev_err(&pdev->dev, "Can't retrieve spdif clock\n"); dev_err(&pdev->dev, "Can't retrieve spdif clock\n");
ret = PTR_ERR(spdif->clk_spdif_in); return PTR_ERR(spdif->clk_spdif_in);
goto err;
} }
} }
@@ -481,79 +471,64 @@ static int tegra210_spdif_platform_probe(struct platform_device *pdev)
} }
regcache_cache_only(spdif->regmap, true); regcache_cache_only(spdif->regmap, true);
if (of_property_read_u32(np, "nvidia,ahub-spdif-id", ret = of_property_read_u32(np, "nvidia,ahub-spdif-id",
&pdev->dev.id) < 0) { &pdev->dev.id);
dev_err(&pdev->dev, if (ret < 0) {
"Missing property nvidia,ahub-spdif-id\n"); dev_err(&pdev->dev, "Missing property nvidia,ahub-spdif-id\n");
ret = -ENODEV; return ret;
goto err;
} }
pm_runtime_enable(&pdev->dev); pm_runtime_enable(&pdev->dev);
if (!pm_runtime_enabled(&pdev->dev)) {
ret = tegra210_spdif_runtime_resume(&pdev->dev);
if (ret)
goto err_pm_disable;
}
ret = snd_soc_register_codec(&pdev->dev, &tegra210_spdif_codec, ret = snd_soc_register_codec(&pdev->dev, &tegra210_spdif_codec,
tegra210_spdif_dais, tegra210_spdif_dais,
ARRAY_SIZE(tegra210_spdif_dais)); ARRAY_SIZE(tegra210_spdif_dais));
if (ret != 0) { if (ret != 0) {
dev_err(&pdev->dev, "Could not register CODEC: %d\n", ret); dev_err(&pdev->dev, "Could not register CODEC: %d\n", ret);
goto err_suspend; pm_runtime_disable(&pdev->dev);
return ret;
} }
if (of_property_read_string(np, "prod-name", &prod_name) == 0) { if (of_property_read_string(np, "prod-name", &prod_name) == 0) {
ret = tegra_pinctrl_config_prod(&pdev->dev, prod_name); ret = tegra_pinctrl_config_prod(&pdev->dev, prod_name);
if (ret < 0) if (ret < 0)
dev_warn(&pdev->dev, "Failed to set %s setting\n", dev_warn(&pdev->dev, "Failed to set %s setting\n",
prod_name); prod_name);
} }
if (of_property_read_u32(np, "nvidia,is-pinctrl", if (of_property_read_u32(np, "nvidia,is-pinctrl",
&spdif->is_pinctrl) < 0) &spdif->is_pinctrl) < 0)
spdif->is_pinctrl = 0; spdif->is_pinctrl = 0;
if (spdif->is_pinctrl) { if (spdif->is_pinctrl) {
spdif->pinctrl = devm_pinctrl_get(&pdev->dev); spdif->pinctrl = devm_pinctrl_get(&pdev->dev);
if (IS_ERR(spdif->pinctrl)) { if (IS_ERR(spdif->pinctrl)) {
dev_warn(&pdev->dev, "Missing pinctrl device\n"); dev_warn(&pdev->dev, "Missing pinctrl device\n");
goto err_dap; return 0;
} }
spdif->pin_active_state = pinctrl_lookup_state(spdif->pinctrl, spdif->pin_active_state = pinctrl_lookup_state(spdif->pinctrl,
"dap_active"); "dap_active");
if (IS_ERR(spdif->pin_active_state)) { if (IS_ERR(spdif->pin_active_state)) {
dev_dbg(&pdev->dev, "Missing dap-active state\n"); dev_dbg(&pdev->dev, "Missing dap-active state\n");
goto err_dap; return 0;
} }
spdif->pin_idle_state = pinctrl_lookup_state(spdif->pinctrl, spdif->pin_idle_state = pinctrl_lookup_state(spdif->pinctrl,
"dap_inactive"); "dap_inactive");
if (IS_ERR(spdif->pin_idle_state)) { if (IS_ERR(spdif->pin_idle_state)) {
dev_dbg(&pdev->dev, "Missing dap-inactive state\n"); dev_dbg(&pdev->dev, "Missing dap-inactive state\n");
goto err_dap; return 0;
} }
ret = pinctrl_select_state(spdif->pinctrl, ret = pinctrl_select_state(spdif->pinctrl,
spdif->pin_idle_state); spdif->pin_idle_state);
if (ret < 0) { if (ret < 0) {
dev_err(&pdev->dev, "setting state failed\n"); dev_err(&pdev->dev, "setting state failed\n");
goto err_dap; return 0;
} }
} }
err_dap:
return 0; return 0;
err_suspend:
if (!pm_runtime_status_suspended(&pdev->dev))
tegra210_spdif_runtime_suspend(&pdev->dev);
err_pm_disable:
pm_runtime_disable(&pdev->dev);
err:
return ret;
} }
static void tegra210_spdif_platform_shutdown(struct platform_device *pdev) static void tegra210_spdif_platform_shutdown(struct platform_device *pdev)

View File

@@ -23,9 +23,7 @@
#include <linux/of_platform.h> #include <linux/of_platform.h>
#include <linux/platform_device.h> #include <linux/platform_device.h>
#include <linux/pm_runtime.h> #include <linux/pm_runtime.h>
#include <linux/tegra_pm_domains.h>
#include <linux/regmap.h> #include <linux/regmap.h>
#include <linux/slab.h>
#include <soc/tegra/chip-id.h> #include <soc/tegra/chip-id.h>
#include <sound/soc.h> #include <sound/soc.h>
#include <linux/clk/tegra.h> #include <linux/clk/tegra.h>
@@ -1338,21 +1336,9 @@ static int tegra186_xbar_registration(struct platform_device *pdev)
return -EBUSY; return -EBUSY;
} }
ret = pm_runtime_get_sync(&pdev->dev);
if (ret < 0) {
dev_err(&pdev->dev, "pm_runtime_get failed. ret: %d\n", ret);
return ret;
}
of_platform_populate(pdev->dev.of_node, NULL, tegra186_xbar_auxdata, of_platform_populate(pdev->dev.of_node, NULL, tegra186_xbar_auxdata,
&pdev->dev); &pdev->dev);
ret = pm_runtime_put_sync(&pdev->dev);
if (ret < 0) {
dev_err(&pdev->dev, "pm_runtime_put failed. ret: %d\n", ret);
return ret;
}
return 0; return 0;
} }
@@ -1388,26 +1374,21 @@ static int tegra_dev_xbar_probe(struct platform_device *pdev)
{ {
const struct of_device_id *match; const struct of_device_id *match;
struct tegra_xbar_soc_data *soc_data; struct tegra_xbar_soc_data *soc_data;
int ret;
/* required to register the xbar codec with generic name */ /* required to register the xbar codec with generic name */
if (dev_set_name(&pdev->dev, "%s", DRV_NAME) < 0) { if (dev_set_name(&pdev->dev, "%s", DRV_NAME) < 0) {
dev_err(&pdev->dev, "error in setting xbar device name\n"); dev_err(&pdev->dev, "error in setting xbar device name\n");
ret = -ENODEV; return -ENODEV;
goto err;
} }
match = of_match_device(tegra_xbar_of_match, &pdev->dev); match = of_match_device(tegra_xbar_of_match, &pdev->dev);
if (!match) { if (!match) {
dev_err(&pdev->dev, "Error: No device match found\n"); dev_err(&pdev->dev, "Error: No device match found\n");
ret = -ENODEV; return -ENODEV;
goto err;
} }
soc_data = (struct tegra_xbar_soc_data *)match->data; soc_data = (struct tegra_xbar_soc_data *)match->data;
ret = tegra_xbar_probe(pdev, soc_data); return tegra_xbar_probe(pdev, soc_data);
err:
return ret;
} }
static const struct dev_pm_ops tegra_xbar_pm_ops = { static const struct dev_pm_ops tegra_xbar_pm_ops = {

View File

@@ -23,9 +23,7 @@
#include <linux/of_platform.h> #include <linux/of_platform.h>
#include <linux/platform_device.h> #include <linux/platform_device.h>
#include <linux/pm_runtime.h> #include <linux/pm_runtime.h>
#include <linux/tegra_pm_domains.h>
#include <linux/regmap.h> #include <linux/regmap.h>
#include <linux/slab.h>
#include <soc/tegra/chip-id.h> #include <soc/tegra/chip-id.h>
#include <sound/soc.h> #include <sound/soc.h>
#include <linux/clk/tegra.h> #include <linux/clk/tegra.h>
@@ -305,8 +303,6 @@ int tegra_xbar_remove(struct platform_device *pdev)
if (!pm_runtime_status_suspended(&pdev->dev)) if (!pm_runtime_status_suspended(&pdev->dev))
tegra_xbar_runtime_suspend(&pdev->dev); tegra_xbar_runtime_suspend(&pdev->dev);
tegra_pd_remove_device(&pdev->dev);
return 0; return 0;
} }
EXPORT_SYMBOL_GPL(tegra_xbar_remove); EXPORT_SYMBOL_GPL(tegra_xbar_remove);
@@ -320,11 +316,8 @@ int tegra_xbar_probe(struct platform_device *pdev,
int ret; int ret;
xbar = devm_kzalloc(&pdev->dev, sizeof(*xbar), GFP_KERNEL); xbar = devm_kzalloc(&pdev->dev, sizeof(*xbar), GFP_KERNEL);
if (!xbar) { if (!xbar)
dev_err(&pdev->dev, "Can't allocate xbar\n"); return -ENOMEM;
ret = -ENOMEM;
goto err;
}
xbar->soc_data = soc_data; xbar->soc_data = soc_data;
xbar->is_shutdown = false; xbar->is_shutdown = false;
@@ -335,44 +328,39 @@ int tegra_xbar_probe(struct platform_device *pdev,
xbar->clk = devm_clk_get(&pdev->dev, "ahub"); xbar->clk = devm_clk_get(&pdev->dev, "ahub");
if (IS_ERR(xbar->clk)) { if (IS_ERR(xbar->clk)) {
dev_err(&pdev->dev, "Can't retrieve ahub clock\n"); dev_err(&pdev->dev, "Can't retrieve ahub clock\n");
ret = PTR_ERR(xbar->clk); return PTR_ERR(xbar->clk);
goto err;
} }
xbar->clk_parent = devm_clk_get(&pdev->dev, "pll_a_out0"); xbar->clk_parent = devm_clk_get(&pdev->dev, "pll_a_out0");
if (IS_ERR(xbar->clk_parent)) { if (IS_ERR(xbar->clk_parent)) {
dev_err(&pdev->dev, "Can't retrieve pll_a_out0 clock\n"); dev_err(&pdev->dev, "Can't retrieve pll_a_out0 clock\n");
ret = PTR_ERR(xbar->clk_parent); return PTR_ERR(xbar->clk_parent);
goto err;
} }
xbar->clk_apb2ape = devm_clk_get(&pdev->dev, "apb2ape"); xbar->clk_apb2ape = devm_clk_get(&pdev->dev, "apb2ape");
if (IS_ERR(xbar->clk_apb2ape)) { if (IS_ERR(xbar->clk_apb2ape)) {
dev_err(&pdev->dev, "Can't retrieve apb2ape clock\n"); dev_err(&pdev->dev, "Can't retrieve apb2ape clock\n");
ret = PTR_ERR(xbar->clk_apb2ape); return PTR_ERR(xbar->clk_apb2ape);
goto err;
} }
xbar->clk_ape = devm_clk_get(&pdev->dev, "xbar.ape"); xbar->clk_ape = devm_clk_get(&pdev->dev, "xbar.ape");
if (IS_ERR(xbar->clk_ape)) { if (IS_ERR(xbar->clk_ape)) {
dev_err(&pdev->dev, "Can't retrieve ape clock\n"); dev_err(&pdev->dev, "Can't retrieve ape clock\n");
ret = PTR_ERR(xbar->clk_ape); return PTR_ERR(xbar->clk_ape);
goto err;
} }
} }
parent_clk = clk_get_parent(xbar->clk); parent_clk = clk_get_parent(xbar->clk);
if (IS_ERR(parent_clk)) { if (IS_ERR(parent_clk)) {
dev_err(&pdev->dev, "Can't get parent clock for xbar\n"); dev_err(&pdev->dev, "Can't get parent clock for xbar\n");
ret = PTR_ERR(parent_clk); return PTR_ERR(parent_clk);
goto err;
} }
if (!(tegra_platform_is_unit_fpga() || tegra_platform_is_fpga())) { if (!(tegra_platform_is_unit_fpga() || tegra_platform_is_fpga())) {
ret = clk_set_parent(xbar->clk, xbar->clk_parent); ret = clk_set_parent(xbar->clk, xbar->clk_parent);
if (ret) { if (ret) {
dev_err(&pdev->dev, "Failed to set parent clock with pll_a_out0\n"); dev_err(&pdev->dev, "Failed to set parent clock with pll_a_out0\n");
goto err; return ret;
} }
} }
@@ -388,29 +376,14 @@ int tegra_xbar_probe(struct platform_device *pdev,
} }
regcache_cache_only(xbar->regmap, true); regcache_cache_only(xbar->regmap, true);
tegra_pd_add_device(&pdev->dev);
pm_runtime_enable(&pdev->dev); pm_runtime_enable(&pdev->dev);
if (!pm_runtime_enabled(&pdev->dev)) { ret = soc_data->xbar_registration(pdev);
ret = tegra_xbar_runtime_resume(&pdev->dev); if (ret) {
if (ret) pm_runtime_disable(&pdev->dev);
goto err_pm_disable; return ret;
} }
ret = soc_data->xbar_registration(pdev);
if (ret == -EBUSY)
goto err_suspend;
return 0; return 0;
err_suspend:
if (!pm_runtime_status_suspended(&pdev->dev))
tegra_xbar_runtime_suspend(&pdev->dev);
err_pm_disable:
pm_runtime_disable(&pdev->dev);
tegra_pd_remove_device(&pdev->dev);
err:
return ret;
} }
EXPORT_SYMBOL_GPL(tegra_xbar_probe); EXPORT_SYMBOL_GPL(tegra_xbar_probe);
MODULE_LICENSE("GPL"); MODULE_LICENSE("GPL");