From d330a080a87831b693a2dad1058cd11bbb6c3736 Mon Sep 17 00:00:00 2001 From: Mark Brown Date: Thu, 30 Sep 2010 14:18:48 -0700 Subject: ASoC: Relax restrictions on WM8962 BCLK configuration The restrictions on configuring BCLK are overly cautious, other constraints in the system should ensure that reconfiguration is not possible when the device is sufficiently active to be unable to support reclocking. Signed-off-by: Mark Brown Acked-by: Liam Girdwood diff --git a/sound/soc/codecs/wm8962.c b/sound/soc/codecs/wm8962.c index be34146..38cbf85 100644 --- a/sound/soc/codecs/wm8962.c +++ b/sound/soc/codecs/wm8962.c @@ -911,12 +911,6 @@ static void wm8962_configure_bclk(struct snd_soc_codec *codec) int clocking2 = 0; int aif2 = 0; - /* If the CODEC is powered on we can configure BCLK */ - if (codec->bias_level != SND_SOC_BIAS_OFF) { - dev_dbg(codec->dev, "Bias is off, can't configure BCLK\n"); - return; - } - if (!wm8962->bclk) { dev_dbg(codec->dev, "No BCLK rate configured\n"); return; -- cgit v0.10.2 From 205d231bfbd26bb10400518586d2a9f1b62858ee Mon Sep 17 00:00:00 2001 From: Mark Brown Date: Thu, 30 Sep 2010 13:46:14 -0700 Subject: ASoC: Remove -dai suffix from i.MX SSI driver MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit While it is a generic serial port in practice the i.MX SSI is only supported in Linux as an audio port (the i.MX has dedicated SPI controllers and so on). This means we don't need to disambiguate against other uses of the hardware and so can drop the -dai suffix from the driver name which fixes merge issues with the i.MX tree in -next. Signed-off-by: Mark Brown Acked-by: Uwe Kleine-König Acked-by: Liam Girdwood diff --git a/arch/arm/mach-mx3/clock-imx31.c b/arch/arm/mach-mx3/clock-imx31.c index 9b52a67..9a9eb6d 100644 --- a/arch/arm/mach-mx3/clock-imx31.c +++ b/arch/arm/mach-mx3/clock-imx31.c @@ -558,8 +558,8 @@ static struct clk_lookup lookups[] = { _REGISTER_CLOCK("mxc_w1.0", NULL, owire_clk) _REGISTER_CLOCK("mxc-mmc.0", NULL, sdhc1_clk) _REGISTER_CLOCK("mxc-mmc.1", NULL, sdhc2_clk) - _REGISTER_CLOCK("imx-ssi-dai.0", NULL, ssi1_clk) - _REGISTER_CLOCK("imx-ssi-dai.1", NULL, ssi2_clk) + _REGISTER_CLOCK("imx-ssi.0", NULL, ssi1_clk) + _REGISTER_CLOCK("imx-ssi.1", NULL, ssi2_clk) _REGISTER_CLOCK(NULL, "firi", firi_clk) _REGISTER_CLOCK(NULL, "ata", ata_clk) _REGISTER_CLOCK(NULL, "rtic", rtic_clk) diff --git a/arch/arm/mach-mx3/clock-imx35.c b/arch/arm/mach-mx3/clock-imx35.c index f29c3e9..d3af0fd 100644 --- a/arch/arm/mach-mx3/clock-imx35.c +++ b/arch/arm/mach-mx3/clock-imx35.c @@ -464,8 +464,8 @@ static struct clk_lookup lookups[] = { _REGISTER_CLOCK(NULL, "sdma", sdma_clk) _REGISTER_CLOCK(NULL, "spba", spba_clk) _REGISTER_CLOCK(NULL, "spdif", spdif_clk) - _REGISTER_CLOCK("imx-ssi-dai.0", NULL, ssi1_clk) - _REGISTER_CLOCK("imx-ssi-dai.1", NULL, ssi2_clk) + _REGISTER_CLOCK("imx-ssi.0", NULL, ssi1_clk) + _REGISTER_CLOCK("imx-ssi.1", NULL, ssi2_clk) _REGISTER_CLOCK("imx-uart.0", NULL, uart1_clk) _REGISTER_CLOCK("imx-uart.1", NULL, uart2_clk) _REGISTER_CLOCK("imx-uart.2", NULL, uart3_clk) diff --git a/arch/arm/mach-mx3/devices.c b/arch/arm/mach-mx3/devices.c index 90eccba..a4fd1a2 100644 --- a/arch/arm/mach-mx3/devices.c +++ b/arch/arm/mach-mx3/devices.c @@ -327,14 +327,14 @@ static struct resource imx_ssi_resources1[] = { }; struct platform_device imx_ssi_device0 = { - .name = "imx-ssi-dai", + .name = "imx-ssi", .id = 0, .num_resources = ARRAY_SIZE(imx_ssi_resources0), .resource = imx_ssi_resources0, }; struct platform_device imx_ssi_device1 = { - .name = "imx-ssi-dai", + .name = "imx-ssi", .id = 1, .num_resources = ARRAY_SIZE(imx_ssi_resources1), .resource = imx_ssi_resources1, diff --git a/arch/arm/plat-mxc/audmux-v2.c b/arch/arm/plat-mxc/audmux-v2.c index 910374d..f9e7cdb 100644 --- a/arch/arm/plat-mxc/audmux-v2.c +++ b/arch/arm/plat-mxc/audmux-v2.c @@ -45,9 +45,9 @@ static const char *audmux_port_string(int port) { switch (port) { case MX31_AUDMUX_PORT1_SSI0: - return "imx-ssi-dai.0"; + return "imx-ssi.0"; case MX31_AUDMUX_PORT2_SSI1: - return "imx-ssi-dai.1"; + return "imx-ssi.1"; case MX31_AUDMUX_PORT3_SSI_PINS_3: return "SSI3"; case MX31_AUDMUX_PORT4_SSI_PINS_4: diff --git a/sound/soc/imx/eukrea-tlv320.c b/sound/soc/imx/eukrea-tlv320.c index 807f736..b596752 100644 --- a/sound/soc/imx/eukrea-tlv320.c +++ b/sound/soc/imx/eukrea-tlv320.c @@ -82,7 +82,7 @@ static struct snd_soc_dai_link eukrea_tlv320_dai = { .codec_dai = "tlv320aic23-hifi", .platform_name = "imx-pcm-audio.0", .codec_name = "tlv320aic23-codec.0-001a", - .cpu_dai = "imx-ssi-dai.0", + .cpu_dai = "imx-ssi.0", .ops = &eukrea_tlv320_snd_ops, }; diff --git a/sound/soc/imx/imx-ssi.c b/sound/soc/imx/imx-ssi.c index 26716e9..d4bd345 100644 --- a/sound/soc/imx/imx-ssi.c +++ b/sound/soc/imx/imx-ssi.c @@ -734,7 +734,7 @@ static struct platform_driver imx_ssi_driver = { .remove = __devexit_p(imx_ssi_remove), .driver = { - .name = "imx-ssi-dai", + .name = "imx-ssi", .owner = THIS_MODULE, }, }; diff --git a/sound/soc/imx/phycore-ac97.c b/sound/soc/imx/phycore-ac97.c index 65f0f99..6a65dd7 100644 --- a/sound/soc/imx/phycore-ac97.c +++ b/sound/soc/imx/phycore-ac97.c @@ -34,7 +34,7 @@ static struct snd_soc_dai_link imx_phycore_dai_ac97[] = { .stream_name = "HiFi", .codec_dai_name = "wm9712-hifi", .codec_name = "wm9712-codec", - .cpu_dai_name = "imx-ssi-dai.0", + .cpu_dai_name = "imx-ssi.0", .platform_name = "imx-fiq-pcm-audio.0", .ops = &imx_phycore_hifi_ops, }, diff --git a/sound/soc/imx/wm1133-ev1.c b/sound/soc/imx/wm1133-ev1.c index 7406863..30fdb15 100644 --- a/sound/soc/imx/wm1133-ev1.c +++ b/sound/soc/imx/wm1133-ev1.c @@ -243,7 +243,7 @@ static int wm1133_ev1_init(struct snd_soc_pcm_runtime *rtd) static struct snd_soc_dai_link wm1133_ev1_dai = { .name = "WM1133-EV1", .stream_name = "Audio", - .cpu_dai_name = "imx-ssi-dai.0", + .cpu_dai_name = "imx-ssi.0", .codec_dai_name = "wm8350-hifi", .platform_name = "imx-fiq-pcm-audio.0", .codec_name = "wm8350-codec.0-0x1a", -- cgit v0.10.2 From 3367b8d4278d1f8a28995cc5e57a995f7147cb73 Mon Sep 17 00:00:00 2001 From: Mark Brown Date: Mon, 20 Sep 2010 17:34:58 +0100 Subject: ASoC: Add support for WM8962 GPIO outputs The WM8962 features five GPIOs, add support for controlling their output state via gpiolib. Signed-off-by: Mark Brown Acked-by: Liam Girdwood diff --git a/include/sound/wm8962.h b/include/sound/wm8962.h index 9722aac..2b5306c 100644 --- a/include/sound/wm8962.h +++ b/include/sound/wm8962.h @@ -15,6 +15,7 @@ #define WM8962_GPIO_SET 0x10000 struct wm8962_pdata { + int gpio_base; u32 gpio_init[WM8962_MAX_GPIO]; /* Setup for microphone detection, raw value to be written to diff --git a/sound/soc/codecs/wm8962.c b/sound/soc/codecs/wm8962.c index 38cbf85..eb66c66 100644 --- a/sound/soc/codecs/wm8962.c +++ b/sound/soc/codecs/wm8962.c @@ -17,6 +17,7 @@ #include #include #include +#include #include #include #include @@ -70,6 +71,10 @@ struct wm8962_priv { struct work_struct beep_work; int beep_rate; #endif + +#ifdef CONFIG_GPIOLIB + struct gpio_chip gpio_chip; +#endif }; /* We can't use the same notifier block for more than one supply and @@ -1646,6 +1651,118 @@ static void wm8962_free_beep(struct snd_soc_codec *codec) } #endif +#ifdef CONFIG_GPIOLIB +static inline struct wm8962_priv *gpio_to_wm8962(struct gpio_chip *chip) +{ + return container_of(chip, struct wm8962_priv, gpio_chip); +} + +static int wm8962_gpio_request(struct gpio_chip *chip, unsigned offset) +{ + struct wm8962_priv *wm8962 = gpio_to_wm8962(chip); + struct snd_soc_codec *codec = wm8962->codec; + int mask = 0; + int val; + + /* The WM8962 GPIOs aren't linearly numbered. For simplicity + * we export linear numbers and error out if the unsupported + * ones are requsted. + */ + switch (offset + 1) { + case 2: + mask = WM8962_CLKOUT2_SEL_MASK; + val = 1 << WM8962_CLKOUT2_SEL_SHIFT; + break; + case 3: + mask = WM8962_CLKOUT3_SEL_MASK; + val = 1 << WM8962_CLKOUT3_SEL_SHIFT; + break; + case 5: + case 6: + break; + default: + return -EINVAL; + } + + /* Some of the GPIOs are behind MFP configuration */ + if (mask) + snd_soc_update_bits(codec, WM8962_ANALOGUE_CLOCKING1, + mask, val); + + return 0; +} + +static void wm8962_gpio_set(struct gpio_chip *chip, unsigned offset, int value) +{ + struct wm8962_priv *wm8962 = gpio_to_wm8962(chip); + struct snd_soc_codec *codec = wm8962->codec; + + snd_soc_update_bits(codec, WM8962_GPIO_BASE + offset, + WM8962_GP2_LVL, value << WM8962_GP2_LVL_SHIFT); +} + +static int wm8962_gpio_direction_out(struct gpio_chip *chip, + unsigned offset, int value) +{ + struct wm8962_priv *wm8962 = gpio_to_wm8962(chip); + struct snd_soc_codec *codec = wm8962->codec; + int val; + + /* Force function 1 (logic output) */ + val = (1 << WM8962_GP2_FN_SHIFT) | (value << WM8962_GP2_LVL_SHIFT); + + return snd_soc_update_bits(codec, WM8962_GPIO_BASE + offset, + WM8962_GP2_FN_MASK | WM8962_GP2_LVL, val); +} + +static struct gpio_chip wm8962_template_chip = { + .label = "wm8962", + .owner = THIS_MODULE, + .request = wm8962_gpio_request, + .direction_output = wm8962_gpio_direction_out, + .set = wm8962_gpio_set, + .can_sleep = 1, +}; + +static void wm8962_init_gpio(struct snd_soc_codec *codec) +{ + struct wm8962_priv *wm8962 = snd_soc_codec_get_drvdata(codec); + struct wm8962_pdata *pdata = dev_get_platdata(codec->dev); + int ret; + + wm8962->gpio_chip = wm8962_template_chip; + wm8962->gpio_chip.ngpio = WM8962_MAX_GPIO; + wm8962->gpio_chip.dev = codec->dev; + + if (pdata && pdata->gpio_base) + wm8962->gpio_chip.base = pdata->gpio_base; + else + wm8962->gpio_chip.base = -1; + + ret = gpiochip_add(&wm8962->gpio_chip); + if (ret != 0) + dev_err(codec->dev, "Failed to add GPIOs: %d\n", ret); +} + +static void wm8962_free_gpio(struct snd_soc_codec *codec) +{ + struct wm8962_priv *wm8962 = snd_soc_codec_get_drvdata(codec); + int ret; + + ret = gpiochip_remove(&wm8962->gpio_chip); + if (ret != 0) + dev_err(codec->dev, "Failed to remove GPIOs: %d\n", ret); +} +#else +static void wm8962_init_gpio(struct snd_soc_codec *codec) +{ +} + +static void wm8962_free_gpio(struct snd_soc_codec *codec) +{ +} +#endif + static int wm8962_probe(struct snd_soc_codec *codec) { int ret; @@ -1778,6 +1895,7 @@ static int wm8962_probe(struct snd_soc_codec *codec) wm8962_add_widgets(codec); wm8962_init_beep(codec); + wm8962_init_gpio(codec); if (i2c->irq) { if (pdata && pdata->irq_active_low) { @@ -1828,6 +1946,7 @@ static int wm8962_remove(struct snd_soc_codec *codec) if (i2c->irq) free_irq(i2c->irq, codec); + wm8962_free_gpio(codec); wm8962_free_beep(codec); for (i = 0; i < ARRAY_SIZE(wm8962->supplies); i++) regulator_unregister_notifier(wm8962->supplies[i].consumer, diff --git a/sound/soc/codecs/wm8962.h b/sound/soc/codecs/wm8962.h index 6145399..fce1199 100644 --- a/sound/soc/codecs/wm8962.h +++ b/sound/soc/codecs/wm8962.h @@ -181,6 +181,7 @@ #define WM8962_EQ39 0x175 #define WM8962_EQ40 0x176 #define WM8962_EQ41 0x177 +#define WM8962_GPIO_BASE 0x200 #define WM8962_GPIO_2 0x201 #define WM8962_GPIO_3 0x202 #define WM8962_GPIO_5 0x204 -- cgit v0.10.2 From 7711308ae68900a047782f5fe1bd46196ea8be0e Mon Sep 17 00:00:00 2001 From: Mark Brown Date: Thu, 30 Sep 2010 15:37:53 -0700 Subject: ASoC: Implement interrupt based jack detection Allow microphone detection on WM8962 to be performed using the interrupt signal, allowing the detection of both microphone presence and button presses with a signal singal from the CODEC to CPU. Currently a 250ms debounce time is applied to both short circuit and presence detection, this has not been optimised. Signed-off-by: Mark Brown Acked-by: Liam Girdwood diff --git a/sound/soc/codecs/wm8962.c b/sound/soc/codecs/wm8962.c index eb66c66..3a1db4a 100644 --- a/sound/soc/codecs/wm8962.c +++ b/sound/soc/codecs/wm8962.c @@ -25,6 +25,7 @@ #include #include #include +#include #include #include #include @@ -63,6 +64,9 @@ struct wm8962_priv { int fll_fref; int fll_fout; + struct delayed_work mic_work; + struct snd_soc_jack *jack; + struct regulator_bulk_data supplies[WM8962_NUM_SUPPLIES]; struct notifier_block disable_nb[WM8962_NUM_SUPPLIES]; @@ -1462,9 +1466,40 @@ static struct snd_soc_dai_driver wm8962_dai = { .symmetric_rates = 1, }; +static void wm8962_mic_work(struct work_struct *work) +{ + struct wm8962_priv *wm8962 = container_of(work, + struct wm8962_priv, + mic_work.work); + struct snd_soc_codec *codec = wm8962->codec; + int status = 0; + int irq_pol = 0; + int reg; + + reg = snd_soc_read(codec, WM8962_ADDITIONAL_CONTROL_4); + + if (reg & WM8962_MICDET_STS) { + status |= SND_JACK_MICROPHONE; + irq_pol |= WM8962_MICD_IRQ_POL; + } + + if (reg & WM8962_MICSHORT_STS) { + status |= SND_JACK_BTN_0; + irq_pol |= WM8962_MICSCD_IRQ_POL; + } + + snd_soc_jack_report(wm8962->jack, status, + SND_JACK_MICROPHONE | SND_JACK_BTN_0); + + snd_soc_update_bits(codec, WM8962_MICINT_SOURCE_POL, + WM8962_MICSCD_IRQ_POL | + WM8962_MICD_IRQ_POL, irq_pol); +} + static irqreturn_t wm8962_irq(int irq, void *data) { struct snd_soc_codec *codec = data; + struct wm8962_priv *wm8962 = snd_soc_codec_get_drvdata(codec); int mask; int active; @@ -1479,12 +1514,59 @@ static irqreturn_t wm8962_irq(int irq, void *data) if (active & WM8962_TEMP_SHUT_EINT) dev_crit(codec->dev, "Thermal shutdown\n"); + if (active & (WM8962_MICSCD_EINT | WM8962_MICD_EINT)) { + dev_dbg(codec->dev, "Microphone event detected\n"); + + schedule_delayed_work(&wm8962->mic_work, + msecs_to_jiffies(250)); + } + /* Acknowledge the interrupts */ snd_soc_write(codec, WM8962_INTERRUPT_STATUS_2, active); return IRQ_HANDLED; } +/** + * wm8962_mic_detect - Enable microphone detection via the WM8962 IRQ + * + * @codec: WM8962 codec + * @jack: jack to report detection events on + * + * Enable microphone detection via IRQ on the WM8962. If GPIOs are + * being used to bring out signals to the processor then only platform + * data configuration is needed for WM8962 and processor GPIOs should + * be configured using snd_soc_jack_add_gpios() instead. + * + * If no jack is supplied detection will be disabled. + */ +int wm8962_mic_detect(struct snd_soc_codec *codec, struct snd_soc_jack *jack) +{ + struct wm8962_priv *wm8962 = snd_soc_codec_get_drvdata(codec); + int irq_mask, enable; + + wm8962->jack = jack; + if (jack) { + irq_mask = 0; + enable = WM8962_MICDET_ENA; + } else { + irq_mask = WM8962_MICD_EINT | WM8962_MICSCD_EINT; + enable = 0; + } + + snd_soc_update_bits(codec, WM8962_INTERRUPT_STATUS_2_MASK, + WM8962_MICD_EINT | WM8962_MICSCD_EINT, irq_mask); + snd_soc_update_bits(codec, WM8962_ADDITIONAL_CONTROL_4, + WM8962_MICDET_ENA, enable); + + /* Send an initial empty report */ + snd_soc_jack_report(wm8962->jack, 0, + SND_JACK_MICROPHONE | SND_JACK_BTN_0); + + return 0; +} +EXPORT_SYMBOL_GPL(wm8962_mic_detect); + #ifdef CONFIG_PM static int wm8962_resume(struct snd_soc_codec *codec) { @@ -1773,6 +1855,7 @@ static int wm8962_probe(struct snd_soc_codec *codec) int i, trigger, irq_pol; wm8962->codec = codec; + INIT_DELAYED_WORK(&wm8962->mic_work, wm8962_mic_work); codec->cache_sync = 1; codec->idle_bias_off = 1; @@ -1946,6 +2029,8 @@ static int wm8962_remove(struct snd_soc_codec *codec) if (i2c->irq) free_irq(i2c->irq, codec); + cancel_delayed_work_sync(&wm8962->mic_work); + wm8962_free_gpio(codec); wm8962_free_beep(codec); for (i = 0; i < ARRAY_SIZE(wm8962->supplies); i++) diff --git a/sound/soc/codecs/wm8962.h b/sound/soc/codecs/wm8962.h index fce1199..2af6c93 100644 --- a/sound/soc/codecs/wm8962.h +++ b/sound/soc/codecs/wm8962.h @@ -14,6 +14,7 @@ #define _WM8962_H #include +#include #define WM8962_SYSCLK_MCLK 1 #define WM8962_SYSCLK_FLL 2 @@ -3785,4 +3786,6 @@ struct wm8962_reg_access { extern const struct wm8962_reg_access wm8962_reg_access[WM8962_MAX_REGISTER + 1]; +int wm8962_mic_detect(struct snd_soc_codec *codec, struct snd_soc_jack *jack); + #endif -- cgit v0.10.2 From 8ca2aa9c59c39805c746b137c041576838f3de92 Mon Sep 17 00:00:00 2001 From: Mark Brown Date: Fri, 1 Oct 2010 17:46:37 -0700 Subject: ASoC: Put WM8962 GPIO2/3 into GPIO mode when configuring platform data too GPIO2 and GPIO3 on the WM8962 are MFPs and need to be put into GPIO mode before the GPIO block can be used to control them. We're already doing this when used via gpiolib, factor out the code for use when setting static configurations via platform data as well. Signed-off-by: Mark Brown Acked-by: Liam Girdwood diff --git a/sound/soc/codecs/wm8962.c b/sound/soc/codecs/wm8962.c index 3a1db4a..6d30f34 100644 --- a/sound/soc/codecs/wm8962.c +++ b/sound/soc/codecs/wm8962.c @@ -1733,6 +1733,31 @@ static void wm8962_free_beep(struct snd_soc_codec *codec) } #endif +static void wm8962_set_gpio_mode(struct snd_soc_codec *codec, int gpio) +{ + int mask = 0; + int val = 0; + + /* Some of the GPIOs are behind MFP configuration and need to + * be put into GPIO mode. */ + switch (gpio) { + case 2: + mask = WM8962_CLKOUT2_SEL_MASK; + val = 1 << WM8962_CLKOUT2_SEL_SHIFT; + break; + case 3: + mask = WM8962_CLKOUT3_SEL_MASK; + val = 1 << WM8962_CLKOUT3_SEL_SHIFT; + break; + default: + break; + } + + if (mask) + snd_soc_update_bits(codec, WM8962_ANALOGUE_CLOCKING1, + mask, val); +} + #ifdef CONFIG_GPIOLIB static inline struct wm8962_priv *gpio_to_wm8962(struct gpio_chip *chip) { @@ -1743,8 +1768,6 @@ static int wm8962_gpio_request(struct gpio_chip *chip, unsigned offset) { struct wm8962_priv *wm8962 = gpio_to_wm8962(chip); struct snd_soc_codec *codec = wm8962->codec; - int mask = 0; - int val; /* The WM8962 GPIOs aren't linearly numbered. For simplicity * we export linear numbers and error out if the unsupported @@ -1752,13 +1775,7 @@ static int wm8962_gpio_request(struct gpio_chip *chip, unsigned offset) */ switch (offset + 1) { case 2: - mask = WM8962_CLKOUT2_SEL_MASK; - val = 1 << WM8962_CLKOUT2_SEL_SHIFT; - break; case 3: - mask = WM8962_CLKOUT3_SEL_MASK; - val = 1 << WM8962_CLKOUT3_SEL_SHIFT; - break; case 5: case 6: break; @@ -1766,10 +1783,7 @@ static int wm8962_gpio_request(struct gpio_chip *chip, unsigned offset) return -EINVAL; } - /* Some of the GPIOs are behind MFP configuration */ - if (mask) - snd_soc_update_bits(codec, WM8962_ANALOGUE_CLOCKING1, - mask, val); + wm8962_set_gpio_mode(codec, offset + 1); return 0; } @@ -1943,9 +1957,11 @@ static int wm8962_probe(struct snd_soc_codec *codec) if (pdata) { /* Apply static configuration for GPIOs */ for (i = 0; i < ARRAY_SIZE(pdata->gpio_init); i++) - if (pdata->gpio_init[i]) + if (pdata->gpio_init[i]) { + wm8962_set_gpio_mode(codec, i + 1); snd_soc_write(codec, 0x200 + i, pdata->gpio_init[i] & 0xffff); + } /* Put the speakers into mono mode? */ if (pdata->spk_mono) -- cgit v0.10.2 From cb13c6b3ca8a1d72996ab1b6a43e291219993292 Mon Sep 17 00:00:00 2001 From: Dimitris Papastamos Date: Fri, 1 Oct 2010 09:12:14 +0100 Subject: ASoC: WM8804: Use a proper DAI name Make sure the DAI name does not include a '/' since we might have per DAI debugfs or sysfs entries in the future. Signed-off-by: Dimitris Papastamos Acked-by: Liam Girdwood Signed-off-by: Mark Brown diff --git a/sound/soc/codecs/wm8804.c b/sound/soc/codecs/wm8804.c index ca7d9ee..40e5067 100644 --- a/sound/soc/codecs/wm8804.c +++ b/sound/soc/codecs/wm8804.c @@ -669,7 +669,7 @@ static struct snd_soc_dai_ops wm8804_dai_ops = { SNDRV_PCM_FMTBIT_S24_LE) static struct snd_soc_dai_driver wm8804_dai = { - .name = "wm8804-s/pdif", + .name = "wm8804-spdif", .playback = { .stream_name = "Playback", .channels_min = 2, -- cgit v0.10.2 From 86ce6c9a62c333157d3f2ef4e4dc1fe18b70eb63 Mon Sep 17 00:00:00 2001 From: Dimitris Papastamos Date: Mon, 4 Oct 2010 09:31:42 +0100 Subject: ASoC: WM8804: Refactor set_pll code to avoid GCC warnings Ensure that no uninitialised variable warnings are generated by GCC. Signed-off-by: Dimitris Papastamos Acked-by: Liam Girdwood Signed-off-by: Mark Brown diff --git a/sound/soc/codecs/wm8804.c b/sound/soc/codecs/wm8804.c index 40e5067..b23c57c 100644 --- a/sound/soc/codecs/wm8804.c +++ b/sound/soc/codecs/wm8804.c @@ -390,36 +390,41 @@ static int wm8804_set_pll(struct snd_soc_dai *dai, int pll_id, int source, unsigned int freq_in, unsigned int freq_out) { - int ret; struct snd_soc_codec *codec; - struct pll_div pll_div = { 0 }; codec = dai->codec; - if (freq_in && freq_out) { + if (!freq_in || !freq_out) { + /* disable the PLL */ + snd_soc_update_bits(codec, WM8804_PWRDN, 0x1, 0); + return 0; + } else { + int ret; + struct pll_div pll_div; + ret = pll_factors(&pll_div, freq_out, freq_in); if (ret) return ret; - } - /* power down the PLL before reprogramming it */ - snd_soc_update_bits(codec, WM8804_PWRDN, 0x1, 0); + /* power down the PLL before reprogramming it */ + snd_soc_update_bits(codec, WM8804_PWRDN, 0x1, 0); - if (!freq_in || !freq_out) - return 0; + if (!freq_in || !freq_out) + return 0; - /* set PLLN and PRESCALE */ - snd_soc_update_bits(codec, WM8804_PLL4, 0xf | 0x10, - pll_div.n | (pll_div.prescale << 4)); - /* set mclkdiv and freqmode */ - snd_soc_update_bits(codec, WM8804_PLL5, 0x3 | 0x8, - pll_div.freqmode | (pll_div.mclkdiv << 3)); - /* set PLLK */ - snd_soc_write(codec, WM8804_PLL1, pll_div.k & 0xff); - snd_soc_write(codec, WM8804_PLL2, (pll_div.k >> 8) & 0xff); - snd_soc_write(codec, WM8804_PLL3, pll_div.k >> 16); - - /* power up the PLL */ - snd_soc_update_bits(codec, WM8804_PWRDN, 0x1, 0x1); + /* set PLLN and PRESCALE */ + snd_soc_update_bits(codec, WM8804_PLL4, 0xf | 0x10, + pll_div.n | (pll_div.prescale << 4)); + /* set mclkdiv and freqmode */ + snd_soc_update_bits(codec, WM8804_PLL5, 0x3 | 0x8, + pll_div.freqmode | (pll_div.mclkdiv << 3)); + /* set PLLK */ + snd_soc_write(codec, WM8804_PLL1, pll_div.k & 0xff); + snd_soc_write(codec, WM8804_PLL2, (pll_div.k >> 8) & 0xff); + snd_soc_write(codec, WM8804_PLL3, pll_div.k >> 16); + + /* power up the PLL */ + snd_soc_update_bits(codec, WM8804_PWRDN, 0x1, 0x1); + } return 0; } -- cgit v0.10.2 From 6c20c807cf5a13f61193d39bb718f7a9b5df3813 Mon Sep 17 00:00:00 2001 From: Dimitris Papastamos Date: Mon, 4 Oct 2010 09:37:48 +0100 Subject: ASoC: WM8804: Power down the PLL correctly The PLL is disabled when the corresponding bit is set not the other way around. This commit depends on my other commit with Subject "ASoC: WM8804: Refactor set_pll code to avoid GCC warnings". Signed-off-by: Dimitris Papastamos Acked-by: Liam Girdwood Signed-off-by: Mark Brown diff --git a/sound/soc/codecs/wm8804.c b/sound/soc/codecs/wm8804.c index b23c57c..2657f5c 100644 --- a/sound/soc/codecs/wm8804.c +++ b/sound/soc/codecs/wm8804.c @@ -395,7 +395,7 @@ static int wm8804_set_pll(struct snd_soc_dai *dai, int pll_id, codec = dai->codec; if (!freq_in || !freq_out) { /* disable the PLL */ - snd_soc_update_bits(codec, WM8804_PWRDN, 0x1, 0); + snd_soc_update_bits(codec, WM8804_PWRDN, 0x1, 0x1); return 0; } else { int ret; @@ -406,7 +406,7 @@ static int wm8804_set_pll(struct snd_soc_dai *dai, int pll_id, return ret; /* power down the PLL before reprogramming it */ - snd_soc_update_bits(codec, WM8804_PWRDN, 0x1, 0); + snd_soc_update_bits(codec, WM8804_PWRDN, 0x1, 0x1); if (!freq_in || !freq_out) return 0; @@ -423,7 +423,7 @@ static int wm8804_set_pll(struct snd_soc_dai *dai, int pll_id, snd_soc_write(codec, WM8804_PLL3, pll_div.k >> 16); /* power up the PLL */ - snd_soc_update_bits(codec, WM8804_PWRDN, 0x1, 0x1); + snd_soc_update_bits(codec, WM8804_PWRDN, 0x1, 0); } return 0; -- cgit v0.10.2