xref: /openbmc/linux/sound/soc/pxa/spitz.c (revision 87506549)
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 #include <sound/soc-dapm.h>
277fb290d0SLiam Girdwood 
287fb290d0SLiam Girdwood #include <asm/mach-types.h>
29a09e64fbSRussell King #include <mach/pxa-regs.h>
30a09e64fbSRussell King #include <mach/hardware.h>
31a09e64fbSRussell King #include <mach/spitz.h>
327fb290d0SLiam Girdwood #include "../codecs/wm8750.h"
337fb290d0SLiam Girdwood #include "pxa2xx-pcm.h"
3497952f60SLiam Girdwood #include "pxa2xx-i2s.h"
357fb290d0SLiam Girdwood 
367fb290d0SLiam Girdwood #define SPITZ_HP        0
377fb290d0SLiam Girdwood #define SPITZ_MIC       1
387fb290d0SLiam Girdwood #define SPITZ_LINE      2
397fb290d0SLiam Girdwood #define SPITZ_HEADSET   3
407fb290d0SLiam Girdwood #define SPITZ_HP_OFF    4
417fb290d0SLiam Girdwood #define SPITZ_SPK_ON    0
427fb290d0SLiam Girdwood #define SPITZ_SPK_OFF   1
437fb290d0SLiam Girdwood 
447fb290d0SLiam Girdwood  /* audio clock in Hz - rounded from 12.235MHz */
457fb290d0SLiam Girdwood #define SPITZ_AUDIO_CLOCK 12288000
467fb290d0SLiam Girdwood 
477fb290d0SLiam Girdwood static int spitz_jack_func;
487fb290d0SLiam Girdwood static int spitz_spk_func;
497fb290d0SLiam Girdwood 
507fb290d0SLiam Girdwood static void spitz_ext_control(struct snd_soc_codec *codec)
517fb290d0SLiam Girdwood {
527fb290d0SLiam Girdwood 	if (spitz_spk_func == SPITZ_SPK_ON)
53a5302181SLiam Girdwood 		snd_soc_dapm_enable_pin(codec, "Ext Spk");
547fb290d0SLiam Girdwood 	else
55a5302181SLiam Girdwood 		snd_soc_dapm_disable_pin(codec, "Ext Spk");
567fb290d0SLiam Girdwood 
577fb290d0SLiam Girdwood 	/* set up jack connection */
587fb290d0SLiam Girdwood 	switch (spitz_jack_func) {
597fb290d0SLiam Girdwood 	case SPITZ_HP:
607fb290d0SLiam Girdwood 		/* enable and unmute hp jack, disable mic bias */
61a5302181SLiam Girdwood 		snd_soc_dapm_disable_pin(codec, "Headset Jack");
62a5302181SLiam Girdwood 		snd_soc_dapm_disable_pin(codec, "Mic Jack");
63a5302181SLiam Girdwood 		snd_soc_dapm_disable_pin(codec, "Line Jack");
64a5302181SLiam Girdwood 		snd_soc_dapm_enable_pin(codec, "Headphone Jack");
65fff14720SEric Miao 		gpio_set_value(SPITZ_GPIO_MUTE_L, 1);
66fff14720SEric Miao 		gpio_set_value(SPITZ_GPIO_MUTE_R, 1);
677fb290d0SLiam Girdwood 		break;
687fb290d0SLiam Girdwood 	case SPITZ_MIC:
697fb290d0SLiam Girdwood 		/* enable mic jack and bias, mute hp */
70a5302181SLiam Girdwood 		snd_soc_dapm_disable_pin(codec, "Headphone Jack");
71a5302181SLiam Girdwood 		snd_soc_dapm_disable_pin(codec, "Headset Jack");
72a5302181SLiam Girdwood 		snd_soc_dapm_disable_pin(codec, "Line Jack");
73a5302181SLiam Girdwood 		snd_soc_dapm_enable_pin(codec, "Mic Jack");
74fff14720SEric Miao 		gpio_set_value(SPITZ_GPIO_MUTE_L, 0);
75fff14720SEric Miao 		gpio_set_value(SPITZ_GPIO_MUTE_R, 0);
767fb290d0SLiam Girdwood 		break;
777fb290d0SLiam Girdwood 	case SPITZ_LINE:
787fb290d0SLiam Girdwood 		/* enable line jack, disable mic bias and mute hp */
79a5302181SLiam Girdwood 		snd_soc_dapm_disable_pin(codec, "Headphone Jack");
80a5302181SLiam Girdwood 		snd_soc_dapm_disable_pin(codec, "Headset Jack");
81a5302181SLiam Girdwood 		snd_soc_dapm_disable_pin(codec, "Mic Jack");
82a5302181SLiam Girdwood 		snd_soc_dapm_enable_pin(codec, "Line Jack");
83fff14720SEric Miao 		gpio_set_value(SPITZ_GPIO_MUTE_L, 0);
84fff14720SEric Miao 		gpio_set_value(SPITZ_GPIO_MUTE_R, 0);
857fb290d0SLiam Girdwood 		break;
867fb290d0SLiam Girdwood 	case SPITZ_HEADSET:
877fb290d0SLiam Girdwood 		/* enable and unmute headset jack enable mic bias, mute L hp */
88a5302181SLiam Girdwood 		snd_soc_dapm_disable_pin(codec, "Headphone Jack");
89a5302181SLiam Girdwood 		snd_soc_dapm_enable_pin(codec, "Mic Jack");
90a5302181SLiam Girdwood 		snd_soc_dapm_disable_pin(codec, "Line Jack");
91a5302181SLiam Girdwood 		snd_soc_dapm_enable_pin(codec, "Headset Jack");
92fff14720SEric Miao 		gpio_set_value(SPITZ_GPIO_MUTE_L, 0);
93fff14720SEric Miao 		gpio_set_value(SPITZ_GPIO_MUTE_R, 1);
947fb290d0SLiam Girdwood 		break;
957fb290d0SLiam Girdwood 	case SPITZ_HP_OFF:
967fb290d0SLiam Girdwood 
977fb290d0SLiam Girdwood 		/* jack removed, everything off */
98a5302181SLiam Girdwood 		snd_soc_dapm_disable_pin(codec, "Headphone Jack");
99a5302181SLiam Girdwood 		snd_soc_dapm_disable_pin(codec, "Headset Jack");
100a5302181SLiam Girdwood 		snd_soc_dapm_disable_pin(codec, "Mic Jack");
101a5302181SLiam Girdwood 		snd_soc_dapm_disable_pin(codec, "Line Jack");
102fff14720SEric Miao 		gpio_set_value(SPITZ_GPIO_MUTE_L, 0);
103fff14720SEric Miao 		gpio_set_value(SPITZ_GPIO_MUTE_R, 0);
1047fb290d0SLiam Girdwood 		break;
1057fb290d0SLiam Girdwood 	}
106a5302181SLiam Girdwood 	snd_soc_dapm_sync(codec);
1077fb290d0SLiam Girdwood }
1087fb290d0SLiam Girdwood 
1097fb290d0SLiam Girdwood static int spitz_startup(struct snd_pcm_substream *substream)
1107fb290d0SLiam Girdwood {
1117fb290d0SLiam Girdwood 	struct snd_soc_pcm_runtime *rtd = substream->private_data;
1127fb290d0SLiam Girdwood 	struct snd_soc_codec *codec = rtd->socdev->codec;
1137fb290d0SLiam Girdwood 
1147fb290d0SLiam Girdwood 	/* check the jack status at stream startup */
1157fb290d0SLiam Girdwood 	spitz_ext_control(codec);
1167fb290d0SLiam Girdwood 	return 0;
1177fb290d0SLiam Girdwood }
1187fb290d0SLiam Girdwood 
11997952f60SLiam Girdwood static int spitz_hw_params(struct snd_pcm_substream *substream,
12097952f60SLiam Girdwood 	struct snd_pcm_hw_params *params)
12197952f60SLiam Girdwood {
12297952f60SLiam Girdwood 	struct snd_soc_pcm_runtime *rtd = substream->private_data;
123917f93acSLiam Girdwood 	struct snd_soc_dai *codec_dai = rtd->dai->codec_dai;
124917f93acSLiam Girdwood 	struct snd_soc_dai *cpu_dai = rtd->dai->cpu_dai;
12597952f60SLiam Girdwood 	unsigned int clk = 0;
12697952f60SLiam Girdwood 	int ret = 0;
12797952f60SLiam Girdwood 
12897952f60SLiam Girdwood 	switch (params_rate(params)) {
12997952f60SLiam Girdwood 	case 8000:
13097952f60SLiam Girdwood 	case 16000:
13197952f60SLiam Girdwood 	case 48000:
13297952f60SLiam Girdwood 	case 96000:
13397952f60SLiam Girdwood 		clk = 12288000;
13497952f60SLiam Girdwood 		break;
13597952f60SLiam Girdwood 	case 11025:
13697952f60SLiam Girdwood 	case 22050:
13797952f60SLiam Girdwood 	case 44100:
13897952f60SLiam Girdwood 		clk = 11289600;
13997952f60SLiam Girdwood 		break;
14097952f60SLiam Girdwood 	}
14197952f60SLiam Girdwood 
14297952f60SLiam Girdwood 	/* set codec DAI configuration */
14364105cfdSLiam Girdwood 	ret = snd_soc_dai_set_fmt(codec_dai, SND_SOC_DAIFMT_I2S |
14497952f60SLiam Girdwood 		SND_SOC_DAIFMT_NB_NF | SND_SOC_DAIFMT_CBS_CFS);
14597952f60SLiam Girdwood 	if (ret < 0)
14697952f60SLiam Girdwood 		return ret;
14797952f60SLiam Girdwood 
14897952f60SLiam Girdwood 	/* set cpu DAI configuration */
14964105cfdSLiam Girdwood 	ret = snd_soc_dai_set_fmt(cpu_dai, SND_SOC_DAIFMT_I2S |
15097952f60SLiam Girdwood 		SND_SOC_DAIFMT_NB_NF | SND_SOC_DAIFMT_CBS_CFS);
15197952f60SLiam Girdwood 	if (ret < 0)
15297952f60SLiam Girdwood 		return ret;
15397952f60SLiam Girdwood 
15497952f60SLiam Girdwood 	/* set the codec system clock for DAC and ADC */
15564105cfdSLiam Girdwood 	ret = snd_soc_dai_set_sysclk(codec_dai, WM8750_SYSCLK, clk,
15697952f60SLiam Girdwood 		SND_SOC_CLOCK_IN);
15797952f60SLiam Girdwood 	if (ret < 0)
15897952f60SLiam Girdwood 		return ret;
15997952f60SLiam Girdwood 
16097952f60SLiam Girdwood 	/* set the I2S system clock as input (unused) */
16164105cfdSLiam Girdwood 	ret = snd_soc_dai_set_sysclk(cpu_dai, PXA2XX_I2S_SYSCLK, 0,
16297952f60SLiam Girdwood 		SND_SOC_CLOCK_IN);
16397952f60SLiam Girdwood 	if (ret < 0)
16497952f60SLiam Girdwood 		return ret;
16597952f60SLiam Girdwood 
16697952f60SLiam Girdwood 	return 0;
16797952f60SLiam Girdwood }
16897952f60SLiam Girdwood 
1697fb290d0SLiam Girdwood static struct snd_soc_ops spitz_ops = {
1707fb290d0SLiam Girdwood 	.startup = spitz_startup,
17197952f60SLiam Girdwood 	.hw_params = spitz_hw_params,
1727fb290d0SLiam Girdwood };
1737fb290d0SLiam Girdwood 
1747fb290d0SLiam Girdwood static int spitz_get_jack(struct snd_kcontrol *kcontrol,
1757fb290d0SLiam Girdwood 	struct snd_ctl_elem_value *ucontrol)
1767fb290d0SLiam Girdwood {
1777fb290d0SLiam Girdwood 	ucontrol->value.integer.value[0] = spitz_jack_func;
1787fb290d0SLiam Girdwood 	return 0;
1797fb290d0SLiam Girdwood }
1807fb290d0SLiam Girdwood 
1817fb290d0SLiam Girdwood static int spitz_set_jack(struct snd_kcontrol *kcontrol,
1827fb290d0SLiam Girdwood 	struct snd_ctl_elem_value *ucontrol)
1837fb290d0SLiam Girdwood {
1847fb290d0SLiam Girdwood 	struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol);
1857fb290d0SLiam Girdwood 
1867fb290d0SLiam Girdwood 	if (spitz_jack_func == ucontrol->value.integer.value[0])
1877fb290d0SLiam Girdwood 		return 0;
1887fb290d0SLiam Girdwood 
1897fb290d0SLiam Girdwood 	spitz_jack_func = ucontrol->value.integer.value[0];
1907fb290d0SLiam Girdwood 	spitz_ext_control(codec);
1917fb290d0SLiam Girdwood 	return 1;
1927fb290d0SLiam Girdwood }
1937fb290d0SLiam Girdwood 
1947fb290d0SLiam Girdwood static int spitz_get_spk(struct snd_kcontrol *kcontrol,
1957fb290d0SLiam Girdwood 	struct snd_ctl_elem_value *ucontrol)
1967fb290d0SLiam Girdwood {
1977fb290d0SLiam Girdwood 	ucontrol->value.integer.value[0] = spitz_spk_func;
1987fb290d0SLiam Girdwood 	return 0;
1997fb290d0SLiam Girdwood }
2007fb290d0SLiam Girdwood 
2017fb290d0SLiam Girdwood static int spitz_set_spk(struct snd_kcontrol *kcontrol,
2027fb290d0SLiam Girdwood 	struct snd_ctl_elem_value *ucontrol)
2037fb290d0SLiam Girdwood {
2047fb290d0SLiam Girdwood 	struct snd_soc_codec *codec =  snd_kcontrol_chip(kcontrol);
2057fb290d0SLiam Girdwood 
2067fb290d0SLiam Girdwood 	if (spitz_spk_func == ucontrol->value.integer.value[0])
2077fb290d0SLiam Girdwood 		return 0;
2087fb290d0SLiam Girdwood 
2097fb290d0SLiam Girdwood 	spitz_spk_func = ucontrol->value.integer.value[0];
2107fb290d0SLiam Girdwood 	spitz_ext_control(codec);
2117fb290d0SLiam Girdwood 	return 1;
2127fb290d0SLiam Girdwood }
2137fb290d0SLiam Girdwood 
214338c7ed0SJarkko Nikula static int spitz_mic_bias(struct snd_soc_dapm_widget *w,
215338c7ed0SJarkko Nikula 	struct snd_kcontrol *k, int event)
2167fb290d0SLiam Girdwood {
217fff14720SEric Miao 	if (machine_is_borzoi() || machine_is_spitz())
218fff14720SEric Miao 		gpio_set_value(SPITZ_GPIO_MIC_BIAS,
219fff14720SEric Miao 				SND_SOC_DAPM_EVENT_ON(event));
2207fb290d0SLiam Girdwood 
221f72de663SEric Miao 	if (machine_is_akita())
222f72de663SEric Miao 		gpio_set_value(AKITA_GPIO_MIC_BIAS,
223f72de663SEric Miao 				SND_SOC_DAPM_EVENT_ON(event));
224f72de663SEric Miao 
2257fb290d0SLiam Girdwood 	return 0;
2267fb290d0SLiam Girdwood }
2277fb290d0SLiam Girdwood 
2287fb290d0SLiam Girdwood /* spitz machine dapm widgets */
2297fb290d0SLiam Girdwood static const struct snd_soc_dapm_widget wm8750_dapm_widgets[] = {
2307fb290d0SLiam Girdwood 	SND_SOC_DAPM_HP("Headphone Jack", NULL),
2317fb290d0SLiam Girdwood 	SND_SOC_DAPM_MIC("Mic Jack", spitz_mic_bias),
2327fb290d0SLiam Girdwood 	SND_SOC_DAPM_SPK("Ext Spk", NULL),
2337fb290d0SLiam Girdwood 	SND_SOC_DAPM_LINE("Line Jack", NULL),
2347fb290d0SLiam Girdwood 
2357fb290d0SLiam Girdwood 	/* headset is a mic and mono headphone */
2367fb290d0SLiam Girdwood 	SND_SOC_DAPM_HP("Headset Jack", NULL),
2377fb290d0SLiam Girdwood };
2387fb290d0SLiam Girdwood 
2397fb290d0SLiam Girdwood /* Spitz machine audio_map */
24025191c45SMark Brown static const struct snd_soc_dapm_route audio_map[] = {
2417fb290d0SLiam Girdwood 
2427fb290d0SLiam Girdwood 	/* headphone connected to LOUT1, ROUT1 */
2437fb290d0SLiam Girdwood 	{"Headphone Jack", NULL, "LOUT1"},
2447fb290d0SLiam Girdwood 	{"Headphone Jack", NULL, "ROUT1"},
2457fb290d0SLiam Girdwood 
2467fb290d0SLiam Girdwood 	/* headset connected to ROUT1 and LINPUT1 with bias (def below) */
2477fb290d0SLiam Girdwood 	{"Headset Jack", NULL, "ROUT1"},
2487fb290d0SLiam Girdwood 
2497fb290d0SLiam Girdwood 	/* ext speaker connected to LOUT2, ROUT2  */
2507fb290d0SLiam Girdwood 	{"Ext Spk", NULL , "ROUT2"},
2517fb290d0SLiam Girdwood 	{"Ext Spk", NULL , "LOUT2"},
2527fb290d0SLiam Girdwood 
2537fb290d0SLiam Girdwood 	/* mic is connected to input 1 - with bias */
2547fb290d0SLiam Girdwood 	{"LINPUT1", NULL, "Mic Bias"},
2557fb290d0SLiam Girdwood 	{"Mic Bias", NULL, "Mic Jack"},
2567fb290d0SLiam Girdwood 
2577fb290d0SLiam Girdwood 	/* line is connected to input 1 - no bias */
2587fb290d0SLiam Girdwood 	{"LINPUT1", NULL, "Line Jack"},
2597fb290d0SLiam Girdwood };
2607fb290d0SLiam Girdwood 
2617fb290d0SLiam Girdwood static const char *jack_function[] = {"Headphone", "Mic", "Line", "Headset",
2627fb290d0SLiam Girdwood 	"Off"};
2637fb290d0SLiam Girdwood static const char *spk_function[] = {"On", "Off"};
2647fb290d0SLiam Girdwood static const struct soc_enum spitz_enum[] = {
2657fb290d0SLiam Girdwood 	SOC_ENUM_SINGLE_EXT(5, jack_function),
2667fb290d0SLiam Girdwood 	SOC_ENUM_SINGLE_EXT(2, spk_function),
2677fb290d0SLiam Girdwood };
2687fb290d0SLiam Girdwood 
2697fb290d0SLiam Girdwood static const struct snd_kcontrol_new wm8750_spitz_controls[] = {
2707fb290d0SLiam Girdwood 	SOC_ENUM_EXT("Jack Function", spitz_enum[0], spitz_get_jack,
2717fb290d0SLiam Girdwood 		spitz_set_jack),
2727fb290d0SLiam Girdwood 	SOC_ENUM_EXT("Speaker Function", spitz_enum[1], spitz_get_spk,
2737fb290d0SLiam Girdwood 		spitz_set_spk),
2747fb290d0SLiam Girdwood };
2757fb290d0SLiam Girdwood 
2767fb290d0SLiam Girdwood /*
2777fb290d0SLiam Girdwood  * Logic for a wm8750 as connected on a Sharp SL-Cxx00 Device
2787fb290d0SLiam Girdwood  */
2797fb290d0SLiam Girdwood static int spitz_wm8750_init(struct snd_soc_codec *codec)
2807fb290d0SLiam Girdwood {
2817fb290d0SLiam Girdwood 	int i, err;
2827fb290d0SLiam Girdwood 
2837fb290d0SLiam Girdwood 	/* NC codec pins */
28435f5e54dSMark Brown 	snd_soc_dapm_nc_pin(codec, "RINPUT1");
28535f5e54dSMark Brown 	snd_soc_dapm_nc_pin(codec, "LINPUT2");
28635f5e54dSMark Brown 	snd_soc_dapm_nc_pin(codec, "RINPUT2");
28735f5e54dSMark Brown 	snd_soc_dapm_nc_pin(codec, "LINPUT3");
28835f5e54dSMark Brown 	snd_soc_dapm_nc_pin(codec, "RINPUT3");
28935f5e54dSMark Brown 	snd_soc_dapm_nc_pin(codec, "OUT3");
29035f5e54dSMark Brown 	snd_soc_dapm_nc_pin(codec, "MONO1");
2917fb290d0SLiam Girdwood 
2927fb290d0SLiam Girdwood 	/* Add spitz specific controls */
2937fb290d0SLiam Girdwood 	for (i = 0; i < ARRAY_SIZE(wm8750_spitz_controls); i++) {
2947fb290d0SLiam Girdwood 		err = snd_ctl_add(codec->card,
2957fb290d0SLiam Girdwood 			snd_soc_cnew(&wm8750_spitz_controls[i], codec, NULL));
2967fb290d0SLiam Girdwood 		if (err < 0)
2977fb290d0SLiam Girdwood 			return err;
2987fb290d0SLiam Girdwood 	}
2997fb290d0SLiam Girdwood 
3007fb290d0SLiam Girdwood 	/* Add spitz specific widgets */
30125191c45SMark Brown 	snd_soc_dapm_new_controls(codec, wm8750_dapm_widgets,
30225191c45SMark Brown 				  ARRAY_SIZE(wm8750_dapm_widgets));
3037fb290d0SLiam Girdwood 
30425191c45SMark Brown 	/* Set up spitz specific audio paths */
30525191c45SMark Brown 	snd_soc_dapm_add_routes(codec, audio_map, ARRAY_SIZE(audio_map));
3067fb290d0SLiam Girdwood 
307a5302181SLiam Girdwood 	snd_soc_dapm_sync(codec);
3087fb290d0SLiam Girdwood 	return 0;
3097fb290d0SLiam Girdwood }
3107fb290d0SLiam Girdwood 
3117fb290d0SLiam Girdwood /* spitz digital audio interface glue - connects codec <--> CPU */
3127fb290d0SLiam Girdwood static struct snd_soc_dai_link spitz_dai = {
3137fb290d0SLiam Girdwood 	.name = "wm8750",
3147fb290d0SLiam Girdwood 	.stream_name = "WM8750",
3157fb290d0SLiam Girdwood 	.cpu_dai = &pxa_i2s_dai,
3167fb290d0SLiam Girdwood 	.codec_dai = &wm8750_dai,
3177fb290d0SLiam Girdwood 	.init = spitz_wm8750_init,
31897952f60SLiam Girdwood 	.ops = &spitz_ops,
3197fb290d0SLiam Girdwood };
3207fb290d0SLiam Girdwood 
3217fb290d0SLiam Girdwood /* spitz audio machine driver */
32287506549SMark Brown static struct snd_soc_card snd_soc_spitz = {
3237fb290d0SLiam Girdwood 	.name = "Spitz",
3247fb290d0SLiam Girdwood 	.dai_link = &spitz_dai,
3257fb290d0SLiam Girdwood 	.num_links = 1,
3267fb290d0SLiam Girdwood };
3277fb290d0SLiam Girdwood 
3287fb290d0SLiam Girdwood /* spitz audio private data */
3297fb290d0SLiam Girdwood static struct wm8750_setup_data spitz_wm8750_setup = {
330ee1d0099SJean Delvare 	.i2c_bus = 0,
3317fb290d0SLiam Girdwood 	.i2c_address = 0x1b,
3327fb290d0SLiam Girdwood };
3337fb290d0SLiam Girdwood 
3347fb290d0SLiam Girdwood /* spitz audio subsystem */
3357fb290d0SLiam Girdwood static struct snd_soc_device spitz_snd_devdata = {
33687506549SMark Brown 	.card = &snd_soc_spitz,
3377fb290d0SLiam Girdwood 	.platform = &pxa2xx_soc_platform,
3387fb290d0SLiam Girdwood 	.codec_dev = &soc_codec_dev_wm8750,
3397fb290d0SLiam Girdwood 	.codec_data = &spitz_wm8750_setup,
3407fb290d0SLiam Girdwood };
3417fb290d0SLiam Girdwood 
3427fb290d0SLiam Girdwood static struct platform_device *spitz_snd_device;
3437fb290d0SLiam Girdwood 
3447fb290d0SLiam Girdwood static int __init spitz_init(void)
3457fb290d0SLiam Girdwood {
3467fb290d0SLiam Girdwood 	int ret;
3477fb290d0SLiam Girdwood 
3487fb290d0SLiam Girdwood 	if (!(machine_is_spitz() || machine_is_borzoi() || machine_is_akita()))
3497fb290d0SLiam Girdwood 		return -ENODEV;
3507fb290d0SLiam Girdwood 
3517fb290d0SLiam Girdwood 	spitz_snd_device = platform_device_alloc("soc-audio", -1);
3527fb290d0SLiam Girdwood 	if (!spitz_snd_device)
3537fb290d0SLiam Girdwood 		return -ENOMEM;
3547fb290d0SLiam Girdwood 
3557fb290d0SLiam Girdwood 	platform_set_drvdata(spitz_snd_device, &spitz_snd_devdata);
3567fb290d0SLiam Girdwood 	spitz_snd_devdata.dev = &spitz_snd_device->dev;
3577fb290d0SLiam Girdwood 	ret = platform_device_add(spitz_snd_device);
3587fb290d0SLiam Girdwood 
3597fb290d0SLiam Girdwood 	if (ret)
3607fb290d0SLiam Girdwood 		platform_device_put(spitz_snd_device);
3617fb290d0SLiam Girdwood 
3627fb290d0SLiam Girdwood 	return ret;
3637fb290d0SLiam Girdwood }
3647fb290d0SLiam Girdwood 
3657fb290d0SLiam Girdwood static void __exit spitz_exit(void)
3667fb290d0SLiam Girdwood {
3677fb290d0SLiam Girdwood 	platform_device_unregister(spitz_snd_device);
3687fb290d0SLiam Girdwood }
3697fb290d0SLiam Girdwood 
3707fb290d0SLiam Girdwood module_init(spitz_init);
3717fb290d0SLiam Girdwood module_exit(spitz_exit);
3727fb290d0SLiam Girdwood 
3737fb290d0SLiam Girdwood MODULE_AUTHOR("Richard Purdie");
3747fb290d0SLiam Girdwood MODULE_DESCRIPTION("ALSA SoC Spitz");
3757fb290d0SLiam Girdwood MODULE_LICENSE("GPL");
376