17fb290d0SLiam Girdwood /* 27fb290d0SLiam Girdwood * spitz.c -- SoC audio for Sharp SL-Cxx00 models Spitz, Borzoi and Akita 37fb290d0SLiam Girdwood * 47fb290d0SLiam Girdwood * Copyright 2005 Wolfson Microelectronics PLC. 57fb290d0SLiam Girdwood * Copyright 2005 Openedhand Ltd. 67fb290d0SLiam Girdwood * 7d331124dSLiam Girdwood * Authors: Liam Girdwood <lrg@slimlogic.co.uk> 87fb290d0SLiam Girdwood * Richard Purdie <richard@openedhand.com> 97fb290d0SLiam Girdwood * 107fb290d0SLiam Girdwood * This program is free software; you can redistribute it and/or modify it 117fb290d0SLiam Girdwood * under the terms of the GNU General Public License as published by the 127fb290d0SLiam Girdwood * Free Software Foundation; either version 2 of the License, or (at your 137fb290d0SLiam Girdwood * option) any later version. 147fb290d0SLiam Girdwood * 157fb290d0SLiam Girdwood */ 167fb290d0SLiam Girdwood 177fb290d0SLiam Girdwood #include <linux/module.h> 187fb290d0SLiam Girdwood #include <linux/moduleparam.h> 197fb290d0SLiam Girdwood #include <linux/timer.h> 207fb290d0SLiam Girdwood #include <linux/interrupt.h> 217fb290d0SLiam Girdwood #include <linux/platform_device.h> 22fff14720SEric Miao #include <linux/gpio.h> 237fb290d0SLiam Girdwood #include <sound/core.h> 247fb290d0SLiam Girdwood #include <sound/pcm.h> 257fb290d0SLiam Girdwood #include <sound/soc.h> 267fb290d0SLiam Girdwood 277fb290d0SLiam Girdwood #include <asm/mach-types.h> 28a09e64fbSRussell King #include <mach/spitz.h> 297fb290d0SLiam Girdwood #include "../codecs/wm8750.h" 3097952f60SLiam Girdwood #include "pxa2xx-i2s.h" 317fb290d0SLiam Girdwood 327fb290d0SLiam Girdwood #define SPITZ_HP 0 337fb290d0SLiam Girdwood #define SPITZ_MIC 1 347fb290d0SLiam Girdwood #define SPITZ_LINE 2 357fb290d0SLiam Girdwood #define SPITZ_HEADSET 3 367fb290d0SLiam Girdwood #define SPITZ_HP_OFF 4 377fb290d0SLiam Girdwood #define SPITZ_SPK_ON 0 387fb290d0SLiam Girdwood #define SPITZ_SPK_OFF 1 397fb290d0SLiam Girdwood 407fb290d0SLiam Girdwood /* audio clock in Hz - rounded from 12.235MHz */ 417fb290d0SLiam Girdwood #define SPITZ_AUDIO_CLOCK 12288000 427fb290d0SLiam Girdwood 437fb290d0SLiam Girdwood static int spitz_jack_func; 447fb290d0SLiam Girdwood static int spitz_spk_func; 4504368d05SMarek Vasut static int spitz_mic_gpio; 467fb290d0SLiam Girdwood 477fb290d0SLiam Girdwood static void spitz_ext_control(struct snd_soc_codec *codec) 487fb290d0SLiam Girdwood { 49ce6120ccSLiam Girdwood struct snd_soc_dapm_context *dapm = &codec->dapm; 50ce6120ccSLiam Girdwood 517fb290d0SLiam Girdwood if (spitz_spk_func == SPITZ_SPK_ON) 52ce6120ccSLiam Girdwood snd_soc_dapm_enable_pin(dapm, "Ext Spk"); 537fb290d0SLiam Girdwood else 54ce6120ccSLiam Girdwood snd_soc_dapm_disable_pin(dapm, "Ext Spk"); 557fb290d0SLiam Girdwood 567fb290d0SLiam Girdwood /* set up jack connection */ 577fb290d0SLiam Girdwood switch (spitz_jack_func) { 587fb290d0SLiam Girdwood case SPITZ_HP: 597fb290d0SLiam Girdwood /* enable and unmute hp jack, disable mic bias */ 60ce6120ccSLiam Girdwood snd_soc_dapm_disable_pin(dapm, "Headset Jack"); 61ce6120ccSLiam Girdwood snd_soc_dapm_disable_pin(dapm, "Mic Jack"); 62ce6120ccSLiam Girdwood snd_soc_dapm_disable_pin(dapm, "Line Jack"); 63ce6120ccSLiam Girdwood snd_soc_dapm_enable_pin(dapm, "Headphone Jack"); 64fff14720SEric Miao gpio_set_value(SPITZ_GPIO_MUTE_L, 1); 65fff14720SEric Miao gpio_set_value(SPITZ_GPIO_MUTE_R, 1); 667fb290d0SLiam Girdwood break; 677fb290d0SLiam Girdwood case SPITZ_MIC: 687fb290d0SLiam Girdwood /* enable mic jack and bias, mute hp */ 69ce6120ccSLiam Girdwood snd_soc_dapm_disable_pin(dapm, "Headphone Jack"); 70ce6120ccSLiam Girdwood snd_soc_dapm_disable_pin(dapm, "Headset Jack"); 71ce6120ccSLiam Girdwood snd_soc_dapm_disable_pin(dapm, "Line Jack"); 72ce6120ccSLiam Girdwood snd_soc_dapm_enable_pin(dapm, "Mic Jack"); 73fff14720SEric Miao gpio_set_value(SPITZ_GPIO_MUTE_L, 0); 74fff14720SEric Miao gpio_set_value(SPITZ_GPIO_MUTE_R, 0); 757fb290d0SLiam Girdwood break; 767fb290d0SLiam Girdwood case SPITZ_LINE: 777fb290d0SLiam Girdwood /* enable line jack, disable mic bias and mute hp */ 78ce6120ccSLiam Girdwood snd_soc_dapm_disable_pin(dapm, "Headphone Jack"); 79ce6120ccSLiam Girdwood snd_soc_dapm_disable_pin(dapm, "Headset Jack"); 80ce6120ccSLiam Girdwood snd_soc_dapm_disable_pin(dapm, "Mic Jack"); 81ce6120ccSLiam Girdwood snd_soc_dapm_enable_pin(dapm, "Line Jack"); 82fff14720SEric Miao gpio_set_value(SPITZ_GPIO_MUTE_L, 0); 83fff14720SEric Miao gpio_set_value(SPITZ_GPIO_MUTE_R, 0); 847fb290d0SLiam Girdwood break; 857fb290d0SLiam Girdwood case SPITZ_HEADSET: 867fb290d0SLiam Girdwood /* enable and unmute headset jack enable mic bias, mute L hp */ 87ce6120ccSLiam Girdwood snd_soc_dapm_disable_pin(dapm, "Headphone Jack"); 88ce6120ccSLiam Girdwood snd_soc_dapm_enable_pin(dapm, "Mic Jack"); 89ce6120ccSLiam Girdwood snd_soc_dapm_disable_pin(dapm, "Line Jack"); 90ce6120ccSLiam Girdwood snd_soc_dapm_enable_pin(dapm, "Headset Jack"); 91fff14720SEric Miao gpio_set_value(SPITZ_GPIO_MUTE_L, 0); 92fff14720SEric Miao gpio_set_value(SPITZ_GPIO_MUTE_R, 1); 937fb290d0SLiam Girdwood break; 947fb290d0SLiam Girdwood case SPITZ_HP_OFF: 957fb290d0SLiam Girdwood 967fb290d0SLiam Girdwood /* jack removed, everything off */ 97ce6120ccSLiam Girdwood snd_soc_dapm_disable_pin(dapm, "Headphone Jack"); 98ce6120ccSLiam Girdwood snd_soc_dapm_disable_pin(dapm, "Headset Jack"); 99ce6120ccSLiam Girdwood snd_soc_dapm_disable_pin(dapm, "Mic Jack"); 100ce6120ccSLiam Girdwood snd_soc_dapm_disable_pin(dapm, "Line Jack"); 101fff14720SEric Miao gpio_set_value(SPITZ_GPIO_MUTE_L, 0); 102fff14720SEric Miao gpio_set_value(SPITZ_GPIO_MUTE_R, 0); 1037fb290d0SLiam Girdwood break; 1047fb290d0SLiam Girdwood } 105ce6120ccSLiam Girdwood snd_soc_dapm_sync(dapm); 1067fb290d0SLiam Girdwood } 1077fb290d0SLiam Girdwood 1087fb290d0SLiam Girdwood static int spitz_startup(struct snd_pcm_substream *substream) 1097fb290d0SLiam Girdwood { 1107fb290d0SLiam Girdwood struct snd_soc_pcm_runtime *rtd = substream->private_data; 111f0fba2adSLiam Girdwood struct snd_soc_codec *codec = rtd->codec; 1127fb290d0SLiam Girdwood 11371a29560SMark Brown mutex_lock(&codec->mutex); 11471a29560SMark Brown 1157fb290d0SLiam Girdwood /* check the jack status at stream startup */ 1167fb290d0SLiam Girdwood spitz_ext_control(codec); 11771a29560SMark Brown 11871a29560SMark Brown mutex_unlock(&codec->mutex); 11971a29560SMark Brown 1207fb290d0SLiam Girdwood return 0; 1217fb290d0SLiam Girdwood } 1227fb290d0SLiam Girdwood 12397952f60SLiam Girdwood static int spitz_hw_params(struct snd_pcm_substream *substream, 12497952f60SLiam Girdwood struct snd_pcm_hw_params *params) 12597952f60SLiam Girdwood { 12697952f60SLiam Girdwood struct snd_soc_pcm_runtime *rtd = substream->private_data; 127f0fba2adSLiam Girdwood struct snd_soc_dai *codec_dai = rtd->codec_dai; 128f0fba2adSLiam Girdwood struct snd_soc_dai *cpu_dai = rtd->cpu_dai; 12997952f60SLiam Girdwood unsigned int clk = 0; 13097952f60SLiam Girdwood int ret = 0; 13197952f60SLiam Girdwood 13297952f60SLiam Girdwood switch (params_rate(params)) { 13397952f60SLiam Girdwood case 8000: 13497952f60SLiam Girdwood case 16000: 13597952f60SLiam Girdwood case 48000: 13697952f60SLiam Girdwood case 96000: 13797952f60SLiam Girdwood clk = 12288000; 13897952f60SLiam Girdwood break; 13997952f60SLiam Girdwood case 11025: 14097952f60SLiam Girdwood case 22050: 14197952f60SLiam Girdwood case 44100: 14297952f60SLiam Girdwood clk = 11289600; 14397952f60SLiam Girdwood break; 14497952f60SLiam Girdwood } 14597952f60SLiam Girdwood 14697952f60SLiam Girdwood /* set codec DAI configuration */ 14764105cfdSLiam Girdwood ret = snd_soc_dai_set_fmt(codec_dai, SND_SOC_DAIFMT_I2S | 14897952f60SLiam Girdwood SND_SOC_DAIFMT_NB_NF | SND_SOC_DAIFMT_CBS_CFS); 14997952f60SLiam Girdwood if (ret < 0) 15097952f60SLiam Girdwood return ret; 15197952f60SLiam Girdwood 15297952f60SLiam Girdwood /* set cpu DAI configuration */ 15364105cfdSLiam Girdwood ret = snd_soc_dai_set_fmt(cpu_dai, SND_SOC_DAIFMT_I2S | 15497952f60SLiam Girdwood SND_SOC_DAIFMT_NB_NF | SND_SOC_DAIFMT_CBS_CFS); 15597952f60SLiam Girdwood if (ret < 0) 15697952f60SLiam Girdwood return ret; 15797952f60SLiam Girdwood 15897952f60SLiam Girdwood /* set the codec system clock for DAC and ADC */ 15964105cfdSLiam Girdwood ret = snd_soc_dai_set_sysclk(codec_dai, WM8750_SYSCLK, clk, 16097952f60SLiam Girdwood SND_SOC_CLOCK_IN); 16197952f60SLiam Girdwood if (ret < 0) 16297952f60SLiam Girdwood return ret; 16397952f60SLiam Girdwood 16497952f60SLiam Girdwood /* set the I2S system clock as input (unused) */ 16564105cfdSLiam Girdwood ret = snd_soc_dai_set_sysclk(cpu_dai, PXA2XX_I2S_SYSCLK, 0, 16697952f60SLiam Girdwood SND_SOC_CLOCK_IN); 16797952f60SLiam Girdwood if (ret < 0) 16897952f60SLiam Girdwood return ret; 16997952f60SLiam Girdwood 17097952f60SLiam Girdwood return 0; 17197952f60SLiam Girdwood } 17297952f60SLiam Girdwood 1737fb290d0SLiam Girdwood static struct snd_soc_ops spitz_ops = { 1747fb290d0SLiam Girdwood .startup = spitz_startup, 17597952f60SLiam Girdwood .hw_params = spitz_hw_params, 1767fb290d0SLiam Girdwood }; 1777fb290d0SLiam Girdwood 1787fb290d0SLiam Girdwood static int spitz_get_jack(struct snd_kcontrol *kcontrol, 1797fb290d0SLiam Girdwood struct snd_ctl_elem_value *ucontrol) 1807fb290d0SLiam Girdwood { 1817fb290d0SLiam Girdwood ucontrol->value.integer.value[0] = spitz_jack_func; 1827fb290d0SLiam Girdwood return 0; 1837fb290d0SLiam Girdwood } 1847fb290d0SLiam Girdwood 1857fb290d0SLiam Girdwood static int spitz_set_jack(struct snd_kcontrol *kcontrol, 1867fb290d0SLiam Girdwood struct snd_ctl_elem_value *ucontrol) 1877fb290d0SLiam Girdwood { 1887fb290d0SLiam Girdwood struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol); 1897fb290d0SLiam Girdwood 1907fb290d0SLiam Girdwood if (spitz_jack_func == ucontrol->value.integer.value[0]) 1917fb290d0SLiam Girdwood return 0; 1927fb290d0SLiam Girdwood 1937fb290d0SLiam Girdwood spitz_jack_func = ucontrol->value.integer.value[0]; 1947fb290d0SLiam Girdwood spitz_ext_control(codec); 1957fb290d0SLiam Girdwood return 1; 1967fb290d0SLiam Girdwood } 1977fb290d0SLiam Girdwood 1987fb290d0SLiam Girdwood static int spitz_get_spk(struct snd_kcontrol *kcontrol, 1997fb290d0SLiam Girdwood struct snd_ctl_elem_value *ucontrol) 2007fb290d0SLiam Girdwood { 2017fb290d0SLiam Girdwood ucontrol->value.integer.value[0] = spitz_spk_func; 2027fb290d0SLiam Girdwood return 0; 2037fb290d0SLiam Girdwood } 2047fb290d0SLiam Girdwood 2057fb290d0SLiam Girdwood static int spitz_set_spk(struct snd_kcontrol *kcontrol, 2067fb290d0SLiam Girdwood struct snd_ctl_elem_value *ucontrol) 2077fb290d0SLiam Girdwood { 2087fb290d0SLiam Girdwood struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol); 2097fb290d0SLiam Girdwood 2107fb290d0SLiam Girdwood if (spitz_spk_func == ucontrol->value.integer.value[0]) 2117fb290d0SLiam Girdwood return 0; 2127fb290d0SLiam Girdwood 2137fb290d0SLiam Girdwood spitz_spk_func = ucontrol->value.integer.value[0]; 2147fb290d0SLiam Girdwood spitz_ext_control(codec); 2157fb290d0SLiam Girdwood return 1; 2167fb290d0SLiam Girdwood } 2177fb290d0SLiam Girdwood 218338c7ed0SJarkko Nikula static int spitz_mic_bias(struct snd_soc_dapm_widget *w, 219338c7ed0SJarkko Nikula struct snd_kcontrol *k, int event) 2207fb290d0SLiam Girdwood { 22104368d05SMarek Vasut gpio_set_value_cansleep(spitz_mic_gpio, SND_SOC_DAPM_EVENT_ON(event)); 2227fb290d0SLiam Girdwood return 0; 2237fb290d0SLiam Girdwood } 2247fb290d0SLiam Girdwood 2257fb290d0SLiam Girdwood /* spitz machine dapm widgets */ 2267fb290d0SLiam Girdwood static const struct snd_soc_dapm_widget wm8750_dapm_widgets[] = { 2277fb290d0SLiam Girdwood SND_SOC_DAPM_HP("Headphone Jack", NULL), 2287fb290d0SLiam Girdwood SND_SOC_DAPM_MIC("Mic Jack", spitz_mic_bias), 2297fb290d0SLiam Girdwood SND_SOC_DAPM_SPK("Ext Spk", NULL), 2307fb290d0SLiam Girdwood SND_SOC_DAPM_LINE("Line Jack", NULL), 2317fb290d0SLiam Girdwood 2327fb290d0SLiam Girdwood /* headset is a mic and mono headphone */ 2337fb290d0SLiam Girdwood SND_SOC_DAPM_HP("Headset Jack", NULL), 2347fb290d0SLiam Girdwood }; 2357fb290d0SLiam Girdwood 2367fb290d0SLiam Girdwood /* Spitz machine audio_map */ 23725191c45SMark Brown static const struct snd_soc_dapm_route audio_map[] = { 2387fb290d0SLiam Girdwood 2397fb290d0SLiam Girdwood /* headphone connected to LOUT1, ROUT1 */ 2407fb290d0SLiam Girdwood {"Headphone Jack", NULL, "LOUT1"}, 2417fb290d0SLiam Girdwood {"Headphone Jack", NULL, "ROUT1"}, 2427fb290d0SLiam Girdwood 2437fb290d0SLiam Girdwood /* headset connected to ROUT1 and LINPUT1 with bias (def below) */ 2447fb290d0SLiam Girdwood {"Headset Jack", NULL, "ROUT1"}, 2457fb290d0SLiam Girdwood 2467fb290d0SLiam Girdwood /* ext speaker connected to LOUT2, ROUT2 */ 2477fb290d0SLiam Girdwood {"Ext Spk", NULL , "ROUT2"}, 2487fb290d0SLiam Girdwood {"Ext Spk", NULL , "LOUT2"}, 2497fb290d0SLiam Girdwood 2507fb290d0SLiam Girdwood /* mic is connected to input 1 - with bias */ 2517fb290d0SLiam Girdwood {"LINPUT1", NULL, "Mic Bias"}, 2527fb290d0SLiam Girdwood {"Mic Bias", NULL, "Mic Jack"}, 2537fb290d0SLiam Girdwood 2547fb290d0SLiam Girdwood /* line is connected to input 1 - no bias */ 2557fb290d0SLiam Girdwood {"LINPUT1", NULL, "Line Jack"}, 2567fb290d0SLiam Girdwood }; 2577fb290d0SLiam Girdwood 2587fb290d0SLiam Girdwood static const char *jack_function[] = {"Headphone", "Mic", "Line", "Headset", 2597fb290d0SLiam Girdwood "Off"}; 2607fb290d0SLiam Girdwood static const char *spk_function[] = {"On", "Off"}; 2617fb290d0SLiam Girdwood static const struct soc_enum spitz_enum[] = { 2627fb290d0SLiam Girdwood SOC_ENUM_SINGLE_EXT(5, jack_function), 2637fb290d0SLiam Girdwood SOC_ENUM_SINGLE_EXT(2, spk_function), 2647fb290d0SLiam Girdwood }; 2657fb290d0SLiam Girdwood 2667fb290d0SLiam Girdwood static const struct snd_kcontrol_new wm8750_spitz_controls[] = { 2677fb290d0SLiam Girdwood SOC_ENUM_EXT("Jack Function", spitz_enum[0], spitz_get_jack, 2687fb290d0SLiam Girdwood spitz_set_jack), 2697fb290d0SLiam Girdwood SOC_ENUM_EXT("Speaker Function", spitz_enum[1], spitz_get_spk, 2707fb290d0SLiam Girdwood spitz_set_spk), 2717fb290d0SLiam Girdwood }; 2727fb290d0SLiam Girdwood 2737fb290d0SLiam Girdwood /* 2747fb290d0SLiam Girdwood * Logic for a wm8750 as connected on a Sharp SL-Cxx00 Device 2757fb290d0SLiam Girdwood */ 276f0fba2adSLiam Girdwood static int spitz_wm8750_init(struct snd_soc_pcm_runtime *rtd) 2777fb290d0SLiam Girdwood { 278f0fba2adSLiam Girdwood struct snd_soc_codec *codec = rtd->codec; 279ce6120ccSLiam Girdwood struct snd_soc_dapm_context *dapm = &codec->dapm; 280eb5f6d75SPhilipp Zabel int err; 2817fb290d0SLiam Girdwood 2827fb290d0SLiam Girdwood /* NC codec pins */ 283ce6120ccSLiam Girdwood snd_soc_dapm_nc_pin(dapm, "RINPUT1"); 284ce6120ccSLiam Girdwood snd_soc_dapm_nc_pin(dapm, "LINPUT2"); 285ce6120ccSLiam Girdwood snd_soc_dapm_nc_pin(dapm, "RINPUT2"); 286ce6120ccSLiam Girdwood snd_soc_dapm_nc_pin(dapm, "LINPUT3"); 287ce6120ccSLiam Girdwood snd_soc_dapm_nc_pin(dapm, "RINPUT3"); 288ce6120ccSLiam Girdwood snd_soc_dapm_nc_pin(dapm, "OUT3"); 289ce6120ccSLiam Girdwood snd_soc_dapm_nc_pin(dapm, "MONO1"); 2907fb290d0SLiam Girdwood 2917fb290d0SLiam Girdwood /* Add spitz specific controls */ 292eb5f6d75SPhilipp Zabel err = snd_soc_add_controls(codec, wm8750_spitz_controls, 293eb5f6d75SPhilipp Zabel ARRAY_SIZE(wm8750_spitz_controls)); 2947fb290d0SLiam Girdwood if (err < 0) 2957fb290d0SLiam Girdwood return err; 2967fb290d0SLiam Girdwood 2977fb290d0SLiam Girdwood /* Add spitz specific widgets */ 298ce6120ccSLiam Girdwood snd_soc_dapm_new_controls(dapm, wm8750_dapm_widgets, 29925191c45SMark Brown ARRAY_SIZE(wm8750_dapm_widgets)); 3007fb290d0SLiam Girdwood 30125191c45SMark Brown /* Set up spitz specific audio paths */ 302ce6120ccSLiam Girdwood snd_soc_dapm_add_routes(dapm, audio_map, ARRAY_SIZE(audio_map)); 3037fb290d0SLiam Girdwood 304ce6120ccSLiam Girdwood snd_soc_dapm_sync(dapm); 3057fb290d0SLiam Girdwood return 0; 3067fb290d0SLiam Girdwood } 3077fb290d0SLiam Girdwood 3087fb290d0SLiam Girdwood /* spitz digital audio interface glue - connects codec <--> CPU */ 3097fb290d0SLiam Girdwood static struct snd_soc_dai_link spitz_dai = { 3107fb290d0SLiam Girdwood .name = "wm8750", 3117fb290d0SLiam Girdwood .stream_name = "WM8750", 312a3adfa00SDmitry Eremin-Solenikov .cpu_dai_name = "pxa2xx-i2s", 313f0fba2adSLiam Girdwood .codec_dai_name = "wm8750-hifi", 314f0fba2adSLiam Girdwood .platform_name = "pxa-pcm-audio", 315dc5de62bSMark Brown .codec_name = "wm8750.0-001b", 3167fb290d0SLiam Girdwood .init = spitz_wm8750_init, 31797952f60SLiam Girdwood .ops = &spitz_ops, 3187fb290d0SLiam Girdwood }; 3197fb290d0SLiam Girdwood 3207fb290d0SLiam Girdwood /* spitz audio machine driver */ 32187506549SMark Brown static struct snd_soc_card snd_soc_spitz = { 3227fb290d0SLiam Girdwood .name = "Spitz", 3237fb290d0SLiam Girdwood .dai_link = &spitz_dai, 3247fb290d0SLiam Girdwood .num_links = 1, 3257fb290d0SLiam Girdwood }; 3267fb290d0SLiam Girdwood 3277fb290d0SLiam Girdwood static struct platform_device *spitz_snd_device; 3287fb290d0SLiam Girdwood 3297fb290d0SLiam Girdwood static int __init spitz_init(void) 3307fb290d0SLiam Girdwood { 3317fb290d0SLiam Girdwood int ret; 3327fb290d0SLiam Girdwood 3337fb290d0SLiam Girdwood if (!(machine_is_spitz() || machine_is_borzoi() || machine_is_akita())) 3347fb290d0SLiam Girdwood return -ENODEV; 3357fb290d0SLiam Girdwood 33604368d05SMarek Vasut if (machine_is_borzoi() || machine_is_spitz()) 33704368d05SMarek Vasut spitz_mic_gpio = SPITZ_GPIO_MIC_BIAS; 33804368d05SMarek Vasut else 33904368d05SMarek Vasut spitz_mic_gpio = AKITA_GPIO_MIC_BIAS; 34004368d05SMarek Vasut 34104368d05SMarek Vasut ret = gpio_request(spitz_mic_gpio, "MIC GPIO"); 34204368d05SMarek Vasut if (ret) 34304368d05SMarek Vasut goto err1; 34404368d05SMarek Vasut 34504368d05SMarek Vasut ret = gpio_direction_output(spitz_mic_gpio, 0); 34604368d05SMarek Vasut if (ret) 34704368d05SMarek Vasut goto err2; 34804368d05SMarek Vasut 3497fb290d0SLiam Girdwood spitz_snd_device = platform_device_alloc("soc-audio", -1); 35004368d05SMarek Vasut if (!spitz_snd_device) { 35104368d05SMarek Vasut ret = -ENOMEM; 35204368d05SMarek Vasut goto err2; 35304368d05SMarek Vasut } 3547fb290d0SLiam Girdwood 355f0fba2adSLiam Girdwood platform_set_drvdata(spitz_snd_device, &snd_soc_spitz); 35604368d05SMarek Vasut 3577fb290d0SLiam Girdwood ret = platform_device_add(spitz_snd_device); 3587fb290d0SLiam Girdwood if (ret) 35904368d05SMarek Vasut goto err3; 3607fb290d0SLiam Girdwood 36104368d05SMarek Vasut return 0; 36204368d05SMarek Vasut 36304368d05SMarek Vasut err3: 36404368d05SMarek Vasut platform_device_put(spitz_snd_device); 36504368d05SMarek Vasut err2: 36604368d05SMarek Vasut gpio_free(spitz_mic_gpio); 36704368d05SMarek Vasut err1: 3687fb290d0SLiam Girdwood return ret; 3697fb290d0SLiam Girdwood } 3707fb290d0SLiam Girdwood 3717fb290d0SLiam Girdwood static void __exit spitz_exit(void) 3727fb290d0SLiam Girdwood { 3737fb290d0SLiam Girdwood platform_device_unregister(spitz_snd_device); 37404368d05SMarek Vasut gpio_free(spitz_mic_gpio); 3757fb290d0SLiam Girdwood } 3767fb290d0SLiam Girdwood 3777fb290d0SLiam Girdwood module_init(spitz_init); 3787fb290d0SLiam Girdwood module_exit(spitz_exit); 3797fb290d0SLiam Girdwood 3807fb290d0SLiam Girdwood MODULE_AUTHOR("Richard Purdie"); 3817fb290d0SLiam Girdwood MODULE_DESCRIPTION("ALSA SoC Spitz"); 3827fb290d0SLiam Girdwood MODULE_LICENSE("GPL"); 383