max98090.c (2c81a10ae6c6aaef68f8b92b4fc8037d1dfe0d9e) max98090.c (b10ab7b838bdd86031aececcb386dc253ef3466f)
1/*
2 * max98090.c -- MAX98090 ALSA SoC Audio driver
3 *
4 * Copyright 2011-2012 Maxim Integrated Products
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License version 2 as
8 * published by the Free Software Foundation.
9 */
10
11#include <linux/delay.h>
12#include <linux/i2c.h>
13#include <linux/module.h>
14#include <linux/pm.h>
15#include <linux/pm_runtime.h>
16#include <linux/regmap.h>
17#include <linux/slab.h>
18#include <linux/acpi.h>
1/*
2 * max98090.c -- MAX98090 ALSA SoC Audio driver
3 *
4 * Copyright 2011-2012 Maxim Integrated Products
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License version 2 as
8 * published by the Free Software Foundation.
9 */
10
11#include <linux/delay.h>
12#include <linux/i2c.h>
13#include <linux/module.h>
14#include <linux/pm.h>
15#include <linux/pm_runtime.h>
16#include <linux/regmap.h>
17#include <linux/slab.h>
18#include <linux/acpi.h>
19#include <linux/clk.h>
19#include <sound/jack.h>
20#include <sound/pcm.h>
21#include <sound/pcm_params.h>
22#include <sound/soc.h>
23#include <sound/tlv.h>
24#include <sound/max98090.h>
25#include "max98090.h"
26

--- 1766 unchanged lines hidden (view full) ---

1793 struct max98090_priv *max98090 = snd_soc_codec_get_drvdata(codec);
1794 int ret;
1795
1796 switch (level) {
1797 case SND_SOC_BIAS_ON:
1798 break;
1799
1800 case SND_SOC_BIAS_PREPARE:
20#include <sound/jack.h>
21#include <sound/pcm.h>
22#include <sound/pcm_params.h>
23#include <sound/soc.h>
24#include <sound/tlv.h>
25#include <sound/max98090.h>
26#include "max98090.h"
27

--- 1766 unchanged lines hidden (view full) ---

1794 struct max98090_priv *max98090 = snd_soc_codec_get_drvdata(codec);
1795 int ret;
1796
1797 switch (level) {
1798 case SND_SOC_BIAS_ON:
1799 break;
1800
1801 case SND_SOC_BIAS_PREPARE:
1802 /*
1803 * SND_SOC_BIAS_PREPARE is called while preparing for a
1804 * transition to ON or away from ON. If current bias_level
1805 * is SND_SOC_BIAS_ON, then it is preparing for a transition
1806 * away from ON. Disable the clock in that case, otherwise
1807 * enable it.
1808 */
1809 if (!IS_ERR(max98090->mclk)) {
1810 if (codec->dapm.bias_level == SND_SOC_BIAS_ON)
1811 clk_disable_unprepare(max98090->mclk);
1812 else
1813 clk_prepare_enable(max98090->mclk);
1814 }
1801 break;
1802
1803 case SND_SOC_BIAS_STANDBY:
1804 if (codec->dapm.bias_level == SND_SOC_BIAS_OFF) {
1805 ret = regcache_sync(max98090->regmap);
1806 if (ret != 0) {
1807 dev_err(codec->dev,
1808 "Failed to sync cache: %d\n", ret);

--- 113 unchanged lines hidden (view full) ---

1922{
1923 struct snd_soc_codec *codec = dai->codec;
1924 struct max98090_priv *max98090 = snd_soc_codec_get_drvdata(codec);
1925
1926 /* Requested clock frequency is already setup */
1927 if (freq == max98090->sysclk)
1928 return 0;
1929
1815 break;
1816
1817 case SND_SOC_BIAS_STANDBY:
1818 if (codec->dapm.bias_level == SND_SOC_BIAS_OFF) {
1819 ret = regcache_sync(max98090->regmap);
1820 if (ret != 0) {
1821 dev_err(codec->dev,
1822 "Failed to sync cache: %d\n", ret);

--- 113 unchanged lines hidden (view full) ---

1936{
1937 struct snd_soc_codec *codec = dai->codec;
1938 struct max98090_priv *max98090 = snd_soc_codec_get_drvdata(codec);
1939
1940 /* Requested clock frequency is already setup */
1941 if (freq == max98090->sysclk)
1942 return 0;
1943
1944 if (!IS_ERR(max98090->mclk)) {
1945 freq = clk_round_rate(max98090->mclk, freq);
1946 clk_set_rate(max98090->mclk, freq);
1947 }
1948
1930 /* Setup clocks for slave mode, and using the PLL
1931 * PSCLK = 0x01 (when master clk is 10MHz to 20MHz)
1932 * 0x02 (when master clk is 20MHz to 40MHz)..
1933 * 0x03 (when master clk is 40MHz to 60MHz)..
1934 */
1935 if ((freq >= 10000000) && (freq < 20000000)) {
1936 snd_soc_write(codec, M98090_REG_SYSTEM_CLOCK,
1937 M98090_PSCLK_DIV1);

--- 268 unchanged lines hidden (view full) ---

2206static int max98090_probe(struct snd_soc_codec *codec)
2207{
2208 struct max98090_priv *max98090 = snd_soc_codec_get_drvdata(codec);
2209 struct max98090_cdata *cdata;
2210 int ret = 0;
2211
2212 dev_dbg(codec->dev, "max98090_probe\n");
2213
1949 /* Setup clocks for slave mode, and using the PLL
1950 * PSCLK = 0x01 (when master clk is 10MHz to 20MHz)
1951 * 0x02 (when master clk is 20MHz to 40MHz)..
1952 * 0x03 (when master clk is 40MHz to 60MHz)..
1953 */
1954 if ((freq >= 10000000) && (freq < 20000000)) {
1955 snd_soc_write(codec, M98090_REG_SYSTEM_CLOCK,
1956 M98090_PSCLK_DIV1);

--- 268 unchanged lines hidden (view full) ---

2225static int max98090_probe(struct snd_soc_codec *codec)
2226{
2227 struct max98090_priv *max98090 = snd_soc_codec_get_drvdata(codec);
2228 struct max98090_cdata *cdata;
2229 int ret = 0;
2230
2231 dev_dbg(codec->dev, "max98090_probe\n");
2232
2233 max98090->mclk = devm_clk_get(codec->dev, "mclk");
2234 if (PTR_ERR(max98090->mclk) == -EPROBE_DEFER)
2235 return -EPROBE_DEFER;
2236
2214 max98090->codec = codec;
2215
2216 /* Reset the codec, the DSP core, and disable all interrupts */
2217 max98090_reset(max98090);
2218
2219 /* Initialize private data */
2220
2221 max98090->sysclk = (unsigned)-1;

--- 225 unchanged lines hidden ---
2237 max98090->codec = codec;
2238
2239 /* Reset the codec, the DSP core, and disable all interrupts */
2240 max98090_reset(max98090);
2241
2242 /* Initialize private data */
2243
2244 max98090->sysclk = (unsigned)-1;

--- 225 unchanged lines hidden ---