Commit c2f6702d authored by Stephen Warren's avatar Stephen Warren Committed by Mark Brown

ASoC: tegra: utils: add support for Tegra30 devices

Tegra30 has some additional clocks that need to be manipulated, names
some clocks differently, runs PLLs at different base rates, etc. The
utility code needs to handle this.
Signed-off-by: default avatarStephen Warren <swarren@nvidia.com>
Signed-off-by: default avatarMark Brown <broonie@opensource.wolfsonmicro.com>
parent a9005b67
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* tegra_asoc_utils.c - Harmony machine ASoC driver * tegra_asoc_utils.c - Harmony machine ASoC driver
* *
* Author: Stephen Warren <swarren@nvidia.com> * Author: Stephen Warren <swarren@nvidia.com>
* Copyright (C) 2010 - NVIDIA, Inc. * Copyright (C) 2010,2012 - NVIDIA, Inc.
* *
* This program is free software; you can redistribute it and/or * This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License * modify it under the terms of the GNU General Public License
...@@ -25,6 +25,7 @@ ...@@ -25,6 +25,7 @@
#include <linux/err.h> #include <linux/err.h>
#include <linux/kernel.h> #include <linux/kernel.h>
#include <linux/module.h> #include <linux/module.h>
#include <linux/of.h>
#include "tegra_asoc_utils.h" #include "tegra_asoc_utils.h"
...@@ -40,7 +41,10 @@ int tegra_asoc_utils_set_rate(struct tegra_asoc_utils_data *data, int srate, ...@@ -40,7 +41,10 @@ int tegra_asoc_utils_set_rate(struct tegra_asoc_utils_data *data, int srate,
case 22050: case 22050:
case 44100: case 44100:
case 88200: case 88200:
if (data->soc == TEGRA_ASOC_UTILS_SOC_TEGRA20)
new_baseclock = 56448000; new_baseclock = 56448000;
else
new_baseclock = 564480000;
break; break;
case 8000: case 8000:
case 16000: case 16000:
...@@ -48,7 +52,10 @@ int tegra_asoc_utils_set_rate(struct tegra_asoc_utils_data *data, int srate, ...@@ -48,7 +52,10 @@ int tegra_asoc_utils_set_rate(struct tegra_asoc_utils_data *data, int srate,
case 48000: case 48000:
case 64000: case 64000:
case 96000: case 96000:
if (data->soc == TEGRA_ASOC_UTILS_SOC_TEGRA20)
new_baseclock = 73728000; new_baseclock = 73728000;
else
new_baseclock = 552960000;
break; break;
default: default:
return -EINVAL; return -EINVAL;
...@@ -78,7 +85,7 @@ int tegra_asoc_utils_set_rate(struct tegra_asoc_utils_data *data, int srate, ...@@ -78,7 +85,7 @@ int tegra_asoc_utils_set_rate(struct tegra_asoc_utils_data *data, int srate,
return err; return err;
} }
/* Don't set cdev1 rate; its locked to pll_a_out0 */ /* Don't set cdev1/extern1 rate; it's locked to pll_a_out0 */
err = clk_enable(data->clk_pll_a); err = clk_enable(data->clk_pll_a);
if (err) { if (err) {
...@@ -112,6 +119,15 @@ int tegra_asoc_utils_init(struct tegra_asoc_utils_data *data, ...@@ -112,6 +119,15 @@ int tegra_asoc_utils_init(struct tegra_asoc_utils_data *data,
data->dev = dev; data->dev = dev;
if (!of_have_populated_dt())
data->soc = TEGRA_ASOC_UTILS_SOC_TEGRA20;
else 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
return -EINVAL;
data->clk_pll_a = clk_get_sys(NULL, "pll_a"); data->clk_pll_a = clk_get_sys(NULL, "pll_a");
if (IS_ERR(data->clk_pll_a)) { if (IS_ERR(data->clk_pll_a)) {
dev_err(data->dev, "Can't retrieve clk pll_a\n"); dev_err(data->dev, "Can't retrieve clk pll_a\n");
...@@ -126,7 +142,10 @@ int tegra_asoc_utils_init(struct tegra_asoc_utils_data *data, ...@@ -126,7 +142,10 @@ int tegra_asoc_utils_init(struct tegra_asoc_utils_data *data,
goto err_put_pll_a; goto err_put_pll_a;
} }
if (data->soc == TEGRA_ASOC_UTILS_SOC_TEGRA20)
data->clk_cdev1 = clk_get_sys(NULL, "cdev1"); data->clk_cdev1 = clk_get_sys(NULL, "cdev1");
else
data->clk_cdev1 = clk_get_sys("extern1", NULL);
if (IS_ERR(data->clk_cdev1)) { if (IS_ERR(data->clk_cdev1)) {
dev_err(data->dev, "Can't retrieve clk cdev1\n"); dev_err(data->dev, "Can't retrieve clk cdev1\n");
ret = PTR_ERR(data->clk_cdev1); ret = PTR_ERR(data->clk_cdev1);
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* tegra_asoc_utils.h - Definitions for Tegra DAS driver * tegra_asoc_utils.h - Definitions for Tegra DAS driver
* *
* Author: Stephen Warren <swarren@nvidia.com> * Author: Stephen Warren <swarren@nvidia.com>
* Copyright (C) 2010 - NVIDIA, Inc. * Copyright (C) 2010,2012 - NVIDIA, Inc.
* *
* This program is free software; you can redistribute it and/or * This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License * modify it under the terms of the GNU General Public License
...@@ -26,8 +26,14 @@ ...@@ -26,8 +26,14 @@
struct clk; struct clk;
struct device; struct device;
enum tegra_asoc_utils_soc {
TEGRA_ASOC_UTILS_SOC_TEGRA20,
TEGRA_ASOC_UTILS_SOC_TEGRA30,
};
struct tegra_asoc_utils_data { struct tegra_asoc_utils_data {
struct device *dev; struct device *dev;
enum tegra_asoc_utils_soc soc;
struct clk *clk_pll_a; struct clk *clk_pll_a;
struct clk *clk_pll_a_out0; struct clk *clk_pll_a_out0;
struct clk *clk_cdev1; struct clk *clk_cdev1;
...@@ -42,4 +48,3 @@ int tegra_asoc_utils_init(struct tegra_asoc_utils_data *data, ...@@ -42,4 +48,3 @@ int tegra_asoc_utils_init(struct tegra_asoc_utils_data *data,
void tegra_asoc_utils_fini(struct tegra_asoc_utils_data *data); void tegra_asoc_utils_fini(struct tegra_asoc_utils_data *data);
#endif #endif
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment