Skip to content

Commit

Permalink
Merge remote-tracking branch 'asoc/topic/tegra' into asoc-next
Browse files Browse the repository at this point in the history
  • Loading branch information
Mark Brown committed Apr 12, 2013
2 parents 5b9fd76 + a7fc5d2 commit d14bc15
Show file tree
Hide file tree
Showing 11 changed files with 214 additions and 223 deletions.
26 changes: 21 additions & 5 deletions Documentation/devicetree/bindings/sound/nvidia,tegra30-ahub.txt
Original file line number Diff line number Diff line change
@@ -1,12 +1,22 @@
NVIDIA Tegra30 AHUB (Audio Hub)

Required properties:
- compatible : "nvidia,tegra30-ahub"
- compatible : "nvidia,tegra30-ahub", "nvidia,tegra114-ahub", etc.
- reg : Should contain the register physical address and length for each of
the AHUB's APBIF registers and the AHUB's own registers.
the AHUB's register blocks.
- Tegra30 requires 2 entries, for the APBIF and AHUB/AUDIO register blocks.
- Tegra114 requires an additional entry, for the APBIF2 register block.
- interrupts : Should contain AHUB interrupt
- nvidia,dma-request-selector : The Tegra DMA controller's phandle and
request selector for the first APBIF channel.
- nvidia,dma-request-selector : A list of the DMA channel specifiers. Each
entry contains the Tegra DMA controller's phandle and request selector.
If a single entry is present, the request selectors for the channels are
assumed to be contiguous, and increment from this value.
If multiple values are given, one value must be given per channel.
- clocks : Must contain an entry for each required entry in clock-names.
- clock-names : Must include the following entries:
- Tegra30: Requires d_audio, apbif, i2s0, i2s1, i2s2, i2s3, i2s4, dam0,
dam1, dam2, spdif_in.
- Tegra114: Additionally requires amx, adx.
- ranges : The bus address mapping for the configlink register bus.
Can be empty since the mapping is 1:1.
- #address-cells : For the configlink bus. Should be <1>;
Expand All @@ -25,7 +35,13 @@ ahub@70080000 {
reg = <0x70080000 0x200 0x70080200 0x100>;
interrupts = < 0 103 0x04 >;
nvidia,dma-request-selector = <&apbdma 1>;

clocks = <&tegra_car 106>, <&tegra_car 107>, <&tegra_car 30>,
<&tegra_car 11>, <&tegra_car 18>, <&tegra_car 101>,
<&tegra_car 102>, <&tegra_car 108>, <&tegra_car 109>,
<&tegra_car 110>, <&tegra_car 162>;
clock-names = "d_audio", "apbif", "i2s0", "i2s1", "i2s2",
"i2s3", "i2s4", "dam0", "dam1", "dam2",
"spdif_in";
ranges;
#address-cells = <1>;
#size-cells = <1>;
Expand Down
26 changes: 0 additions & 26 deletions include/sound/tegra_wm8903.h

This file was deleted.

64 changes: 47 additions & 17 deletions sound/soc/tegra/tegra30_ahub.c
Original file line number Diff line number Diff line change
Expand Up @@ -287,16 +287,27 @@ int tegra30_ahub_unset_rx_cif_source(enum tegra30_ahub_rxcif rxcif)
}
EXPORT_SYMBOL_GPL(tegra30_ahub_unset_rx_cif_source);

static const char * const configlink_clocks[] = {
"i2s0",
"i2s1",
"i2s2",
"i2s3",
"i2s4",
"dam0",
"dam1",
"dam2",
"spdif_in",
#define CLK_LIST_MASK_TEGRA30 BIT(0)
#define CLK_LIST_MASK_TEGRA114 BIT(1)

#define CLK_LIST_MASK_TEGRA30_OR_LATER \
(CLK_LIST_MASK_TEGRA30 | CLK_LIST_MASK_TEGRA114)

static const struct {
const char *clk_name;
u32 clk_list_mask;
} configlink_clocks[] = {
{ "i2s0", CLK_LIST_MASK_TEGRA30_OR_LATER },
{ "i2s1", CLK_LIST_MASK_TEGRA30_OR_LATER },
{ "i2s2", CLK_LIST_MASK_TEGRA30_OR_LATER },
{ "i2s3", CLK_LIST_MASK_TEGRA30_OR_LATER },
{ "i2s4", CLK_LIST_MASK_TEGRA30_OR_LATER },
{ "dam0", CLK_LIST_MASK_TEGRA30_OR_LATER },
{ "dam1", CLK_LIST_MASK_TEGRA30_OR_LATER },
{ "dam2", CLK_LIST_MASK_TEGRA30_OR_LATER },
{ "spdif_in", CLK_LIST_MASK_TEGRA30_OR_LATER },
{ "amx", CLK_LIST_MASK_TEGRA114 },
{ "adx", CLK_LIST_MASK_TEGRA114 },
};

#define LAST_REG(name) \
Expand Down Expand Up @@ -424,8 +435,24 @@ static const struct regmap_config tegra30_ahub_ahub_regmap_config = {
.cache_type = REGCACHE_RBTREE,
};

static struct tegra30_ahub_soc_data soc_data_tegra30 = {
.clk_list_mask = CLK_LIST_MASK_TEGRA30,
};

static struct tegra30_ahub_soc_data soc_data_tegra114 = {
.clk_list_mask = CLK_LIST_MASK_TEGRA114,
};

static const struct of_device_id tegra30_ahub_of_match[] = {
{ .compatible = "nvidia,tegra114-ahub", .data = &soc_data_tegra114 },
{ .compatible = "nvidia,tegra30-ahub", .data = &soc_data_tegra30 },
{},
};

static int tegra30_ahub_probe(struct platform_device *pdev)
{
const struct of_device_id *match;
const struct tegra30_ahub_soc_data *soc_data;
struct clk *clk;
int i;
struct resource *res0, *res1, *region;
Expand All @@ -436,16 +463,24 @@ static int tegra30_ahub_probe(struct platform_device *pdev)
if (ahub)
return -ENODEV;

match = of_match_device(tegra30_ahub_of_match, &pdev->dev);
if (!match)
return -EINVAL;
soc_data = match->data;

/*
* The AHUB hosts a register bus: the "configlink". For this to
* operate correctly, all devices on this bus must be out of reset.
* Ensure that here.
*/
for (i = 0; i < ARRAY_SIZE(configlink_clocks); i++) {
clk = clk_get(&pdev->dev, configlink_clocks[i]);
if (!(configlink_clocks[i].clk_list_mask &
soc_data->clk_list_mask))
continue;
clk = clk_get(&pdev->dev, configlink_clocks[i].clk_name);
if (IS_ERR(clk)) {
dev_err(&pdev->dev, "Can't get clock %s\n",
configlink_clocks[i]);
configlink_clocks[i].clk_name);
ret = PTR_ERR(clk);
goto err;
}
Expand Down Expand Up @@ -592,11 +627,6 @@ static int tegra30_ahub_remove(struct platform_device *pdev)
return 0;
}

static const struct of_device_id tegra30_ahub_of_match[] = {
{ .compatible = "nvidia,tegra30-ahub", },
{},
};

static const struct dev_pm_ops tegra30_ahub_pm_ops = {
SET_RUNTIME_PM_OPS(tegra30_ahub_runtime_suspend,
tegra30_ahub_runtime_resume, NULL)
Expand Down
16 changes: 16 additions & 0 deletions sound/soc/tegra/tegra30_ahub.h
Original file line number Diff line number Diff line change
Expand Up @@ -468,7 +468,23 @@ extern int tegra30_ahub_set_rx_cif_source(enum tegra30_ahub_rxcif rxcif,
enum tegra30_ahub_txcif txcif);
extern int tegra30_ahub_unset_rx_cif_source(enum tegra30_ahub_rxcif rxcif);

struct tegra30_ahub_soc_data {
u32 clk_list_mask;
/*
* FIXME: There are many more differences in HW, such as:
* - More APBIF channels.
* - Extra separate chunks of register address space to represent
* the extra APBIF channels.
* - More units connected to the AHUB, so that tegra30_ahub_[rt]xcif
* need expansion, coupled with there being more defined bits in
* the AHUB routing registers.
* However, the driver doesn't support those new features yet, so we
* don't represent them here yet.
*/
};

struct tegra30_ahub {
const struct tegra30_ahub_soc_data *soc_data;
struct device *dev;
struct clk *clk_d_audio;
struct clk *clk_apbif;
Expand Down
15 changes: 4 additions & 11 deletions sound/soc/tegra/tegra_alc5632.c
Original file line number Diff line number Diff line change
Expand Up @@ -161,20 +161,13 @@ static int tegra_alc5632_probe(struct platform_device *pdev)
sizeof(struct tegra_alc5632), GFP_KERNEL);
if (!alc5632) {
dev_err(&pdev->dev, "Can't allocate tegra_alc5632\n");
ret = -ENOMEM;
goto err;
return -ENOMEM;
}

card->dev = &pdev->dev;
platform_set_drvdata(pdev, card);
snd_soc_card_set_drvdata(card, alc5632);

if (!(pdev->dev.of_node)) {
dev_err(&pdev->dev, "Must be instantiated using device tree\n");
ret = -EINVAL;
goto err;
}

alc5632->gpio_hp_det = of_get_named_gpio(np, "nvidia,hp-det-gpios", 0);
if (alc5632->gpio_hp_det == -EPROBE_DEFER)
return -EPROBE_DEFER;
Expand All @@ -197,11 +190,11 @@ static int tegra_alc5632_probe(struct platform_device *pdev)
goto err;
}

tegra_alc5632_dai.cpu_of_node = of_parse_phandle(
pdev->dev.of_node, "nvidia,i2s-controller", 0);
tegra_alc5632_dai.cpu_of_node = of_parse_phandle(np,
"nvidia,i2s-controller", 0);
if (!tegra_alc5632_dai.cpu_of_node) {
dev_err(&pdev->dev,
"Property 'nvidia,i2s-controller' missing or invalid\n");
"Property 'nvidia,i2s-controller' missing or invalid\n");
ret = -EINVAL;
goto err;
}
Expand Down
34 changes: 24 additions & 10 deletions sound/soc/tegra/tegra_asoc_utils.c
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,10 @@ int tegra_asoc_utils_set_rate(struct tegra_asoc_utils_data *data, int srate,
case 88200:
if (data->soc == TEGRA_ASOC_UTILS_SOC_TEGRA20)
new_baseclock = 56448000;
else
else if (data->soc == TEGRA_ASOC_UTILS_SOC_TEGRA30)
new_baseclock = 564480000;
else
new_baseclock = 282240000;
break;
case 8000:
case 16000:
Expand All @@ -54,8 +56,10 @@ int tegra_asoc_utils_set_rate(struct tegra_asoc_utils_data *data, int srate,
case 96000:
if (data->soc == TEGRA_ASOC_UTILS_SOC_TEGRA20)
new_baseclock = 73728000;
else
else if (data->soc == TEGRA_ASOC_UTILS_SOC_TEGRA30)
new_baseclock = 552960000;
else
new_baseclock = 368640000;
break;
default:
return -EINVAL;
Expand Down Expand Up @@ -169,35 +173,45 @@ int tegra_asoc_utils_init(struct tegra_asoc_utils_data *data,
struct device *dev)
{
int ret;
bool new_clocks = false;

data->dev = dev;

if (of_machine_is_compatible("nvidia,tegra20"))
data->soc = TEGRA_ASOC_UTILS_SOC_TEGRA20;
else if (of_machine_is_compatible("nvidia,tegra30"))
data->soc = TEGRA_ASOC_UTILS_SOC_TEGRA30;
else if (!dev->of_node)
/* non-DT is always Tegra20 */
data->soc = TEGRA_ASOC_UTILS_SOC_TEGRA20;
else
/* DT boot, but unknown SoC */
else if (of_machine_is_compatible("nvidia,tegra114")) {
data->soc = TEGRA_ASOC_UTILS_SOC_TEGRA114;
new_clocks = true;
} else {
dev_err(data->dev, "SoC unknown to Tegra ASoC utils\n");
return -EINVAL;
}

data->clk_pll_a = clk_get_sys(NULL, "pll_a");
if (new_clocks)
data->clk_pll_a = clk_get(dev, "pll_a");
else
data->clk_pll_a = clk_get_sys(NULL, "pll_a");
if (IS_ERR(data->clk_pll_a)) {
dev_err(data->dev, "Can't retrieve clk pll_a\n");
ret = PTR_ERR(data->clk_pll_a);
goto err;
}

data->clk_pll_a_out0 = clk_get_sys(NULL, "pll_a_out0");
if (new_clocks)
data->clk_pll_a_out0 = clk_get(dev, "pll_a_out0");
else
data->clk_pll_a_out0 = clk_get_sys(NULL, "pll_a_out0");
if (IS_ERR(data->clk_pll_a_out0)) {
dev_err(data->dev, "Can't retrieve clk pll_a_out0\n");
ret = PTR_ERR(data->clk_pll_a_out0);
goto err_put_pll_a;
}

if (data->soc == TEGRA_ASOC_UTILS_SOC_TEGRA20)
if (new_clocks)
data->clk_cdev1 = clk_get(dev, "mclk");
else if (data->soc == TEGRA_ASOC_UTILS_SOC_TEGRA20)
data->clk_cdev1 = clk_get_sys(NULL, "cdev1");
else
data->clk_cdev1 = clk_get_sys("extern1", NULL);
Expand Down
1 change: 1 addition & 0 deletions sound/soc/tegra/tegra_asoc_utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ struct device;
enum tegra_asoc_utils_soc {
TEGRA_ASOC_UTILS_SOC_TEGRA20,
TEGRA_ASOC_UTILS_SOC_TEGRA30,
TEGRA_ASOC_UTILS_SOC_TEGRA114,
};

struct tegra_asoc_utils_data {
Expand Down
15 changes: 7 additions & 8 deletions sound/soc/tegra/tegra_wm8753.c
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,7 @@ static struct snd_soc_card snd_soc_tegra_wm8753 = {

static int tegra_wm8753_driver_probe(struct platform_device *pdev)
{
struct device_node *np = pdev->dev.of_node;
struct snd_soc_card *card = &snd_soc_tegra_wm8753;
struct tegra_wm8753 *machine;
int ret;
Expand All @@ -132,8 +133,7 @@ static int tegra_wm8753_driver_probe(struct platform_device *pdev)
GFP_KERNEL);
if (!machine) {
dev_err(&pdev->dev, "Can't allocate tegra_wm8753 struct\n");
ret = -ENOMEM;
goto err;
return -ENOMEM;
}

card->dev = &pdev->dev;
Expand All @@ -148,26 +148,25 @@ static int tegra_wm8753_driver_probe(struct platform_device *pdev)
if (ret)
goto err;

tegra_wm8753_dai.codec_of_node = of_parse_phandle(
pdev->dev.of_node, "nvidia,audio-codec", 0);
tegra_wm8753_dai.codec_of_node = of_parse_phandle(np,
"nvidia,audio-codec", 0);
if (!tegra_wm8753_dai.codec_of_node) {
dev_err(&pdev->dev,
"Property 'nvidia,audio-codec' missing or invalid\n");
ret = -EINVAL;
goto err;
}

tegra_wm8753_dai.cpu_of_node = of_parse_phandle(
pdev->dev.of_node, "nvidia,i2s-controller", 0);
tegra_wm8753_dai.cpu_of_node = of_parse_phandle(np,
"nvidia,i2s-controller", 0);
if (!tegra_wm8753_dai.cpu_of_node) {
dev_err(&pdev->dev,
"Property 'nvidia,i2s-controller' missing or invalid\n");
ret = -EINVAL;
goto err;
}

tegra_wm8753_dai.platform_of_node =
tegra_wm8753_dai.cpu_of_node;
tegra_wm8753_dai.platform_of_node = tegra_wm8753_dai.cpu_of_node;

ret = tegra_asoc_utils_init(&machine->util_data, &pdev->dev);
if (ret)
Expand Down
Loading

0 comments on commit d14bc15

Please sign in to comment.