diff options
| author | w20740 <w20740@motorola.com> | 2014-01-30 13:27:53 -0600 |
|---|---|---|
| committer | James Wylder <jwylder@motorola.com> | 2014-03-05 17:47:11 -0600 |
| commit | 211425a438c01d8a7d576d71011e1b0e826df7b8 (patch) | |
| tree | ad60dfc16f163cb8fe8f2596e4490cc271981515 | |
| parent | fdd3fb967703847d599b36f83a32a68b5d5e5633 (diff) | |
| download | olio-linux-3.10-211425a438c01d8a7d576d71011e1b0e826df7b8.tar.xz olio-linux-3.10-211425a438c01d8a7d576d71011e1b0e826df7b8.zip | |
IKXCLOCK-84 Initial audio bringup from C55 DSP
Author: Jee Su Chang - w20740
Change-Id: I26dcea03727462b0a776618b69b0a66071e9acd8
Reviewed-on: http://gerrit.pcs.mot.com/607244
SLTApproved: Slta Waiver <sltawvr@motorola.com>
Tested-by: Jira Key <jirakey@motorola.com>
Reviewed-by: Douglas Zobel <dzobel1@motorola.com>
Submit-Approved: Jira Key <jirakey@motorola.com>
| -rw-r--r-- | arch/arm/boot/dts/omap3-minnow-p0.dts | 7 | ||||
| -rw-r--r-- | arch/arm/boot/dts/omap3-minnow.dtsi | 24 | ||||
| -rw-r--r-- | arch/arm/configs/eng_minnow_defconfig | 49 | ||||
| -rw-r--r-- | arch/arm/configs/minnow_defconfig | 49 | ||||
| -rw-r--r-- | drivers/misc/Makefile | 3 | ||||
| -rw-r--r-- | sound/soc/codecs/Kconfig | 3 | ||||
| -rw-r--r-- | sound/soc/codecs/Makefile | 2 | ||||
| -rw-r--r-- | sound/soc/codecs/c55audio.c | 182 | ||||
| -rw-r--r-- | sound/soc/omap/Kconfig | 11 | ||||
| -rw-r--r-- | sound/soc/omap/Makefile | 2 | ||||
| -rw-r--r-- | sound/soc/omap/mcbsp.h | 2 | ||||
| -rw-r--r-- | sound/soc/omap/omap-c55audio.c | 161 |
12 files changed, 480 insertions, 15 deletions
diff --git a/arch/arm/boot/dts/omap3-minnow-p0.dts b/arch/arm/boot/dts/omap3-minnow-p0.dts index f01a7ac9d0b..2ec7f03acad 100644 --- a/arch/arm/boot/dts/omap3-minnow-p0.dts +++ b/arch/arm/boot/dts/omap3-minnow-p0.dts @@ -67,6 +67,13 @@ }; }; +&audio_gpio_pins { + pinctrl-single,pins = < + 0x0ba 0x004 /* DSS_DATA7, MODE4 | OUTPUT */ + 0x0c8 0x004 /* DSS_DATA14, MODE4 | OUTPUT */ + >; +}; + &usb_phy_pins { pinctrl-single,pins = < 0x140 0x104 /* MCBSP3_CLKX, MODE4 (GPIO-142) | INPUT */ diff --git a/arch/arm/boot/dts/omap3-minnow.dtsi b/arch/arm/boot/dts/omap3-minnow.dtsi index 3f0108c9c44..dd9c60769e0 100644 --- a/arch/arm/boot/dts/omap3-minnow.dtsi +++ b/arch/arm/boot/dts/omap3-minnow.dtsi @@ -91,6 +91,18 @@ compatible = "mot,m4stillmode"; }; }; + + sound { + compatible = "mot,omap-soc-c55"; + mot,model = "omap3c55audio"; + mot,mcbsp = <&mcbsp4>; + }; + + soc { + compatible = "mot,soc-c55"; + mot,mic_bias1_en = <&gpio3 13 0>; /* gpio-077 */ + mot,mic_bias3_en = <&gpio3 20 0>; /* gpio-084 */ + }; }; @@ -154,6 +166,7 @@ pinctrl-names = "default"; pinctrl-0 = < &board_pins + &audio_gpio_pins &usb_phy_pins >; @@ -183,10 +196,10 @@ 0x14e 0x000 /* UART1_RTS, MODE0 | OUTPUT */ 0x150 0x100 /* UART1_CTS, MODE0 | INPUT */ 0x152 0x100 /* UART1_RX, MODE0 | INPUT */ - 0x154 0x100 /* MCBSP4_CLKX, MODE0| INPUT*/ + 0x154 0x100 /* MCBSP4_CLKX, MODE0 | INPUT */ 0x156 0x100 /* MCBSP4_DR, MODE0 | INPUT */ - 0x158 0x000 /* MCBSP4_DX, MODE0 | OUTPUT */ - 0x15a 0x118 /* MCBSP4_FSX,MODE0 | INPUT_PULLUP*/ + 0x158 0x000 /* MCBSP4_DX, MODE0 | OUTPUT */ + 0x15a 0x118 /* MCBSP4_FSX,MODE0 | INPUT_PULLUP */ 0x168 0x104 /* MCBSP1_CLKX, MODE4 | INPUT */ 0x16c 0x004 /* UART3_RTS_SD, MODE4 | OUTPUT */ 0x18e 0x118 /* I2C2_SCL, MODE0 | INPUT_PULLUP */ @@ -202,7 +215,7 @@ 0x1a8 0x000 /* MCSPI2_SIMO, MODE0 | OUTPUT */ 0x1aa 0x100 /* MCSPI2_SOMI, MODE0 | INPUT */ 0x1ac 0x000 /* MCSPI2_CS0, MODE0 | OUTPUT */ - 0x1ae 0x004 /* GPIO_182, MODE4 | OUTPUT */ + 0x1ae 0x004 /* MCSPI2_CS1, MODE4 | OUTPUT */ 0x1b0 0x104 /* SYS_NIRQ, MODE4 | INPUT */ 0x1b2 0x004 /* SYS_CLKOUT2, MODE4 | OUTPUT */ 0x5a8 0x11a /* ETK_CLK, MODE2 | INPUT_PULLUP */ @@ -217,6 +230,9 @@ >; }; + audio_gpio_pins: pinmux_audio_gpio_pins { + }; + usb_phy_pins: pinmux_usb_phy_pins { }; diff --git a/arch/arm/configs/eng_minnow_defconfig b/arch/arm/configs/eng_minnow_defconfig index aafebef36dd..f22d5e27ec5 100644 --- a/arch/arm/configs/eng_minnow_defconfig +++ b/arch/arm/configs/eng_minnow_defconfig @@ -823,6 +823,9 @@ CONFIG_FW_LOADER_USER_HELPER=y # CONFIG_SYS_HYPERVISOR is not set # CONFIG_GENERIC_CPU_DEVICES is not set CONFIG_SOC_BUS=y +CONFIG_REGMAP=y +CONFIG_REGMAP_I2C=y +CONFIG_REGMAP_SPI=y # CONFIG_DMA_SHARED_BUFFER is not set # CONFIG_CMA is not set @@ -1657,10 +1660,42 @@ CONFIG_BACKLIGHT_GENERIC=y # CONFIG_LOGO is not set # CONFIG_FB_SSD1307 is not set CONFIG_SOUND=y -CONFIG_SOUND_OSS_CORE=y -CONFIG_SOUND_OSS_CORE_PRECLAIM=y -# CONFIG_SND is not set -CONFIG_SOUND_PRIME=y +# CONFIG_SOUND_OSS_CORE is not set +CONFIG_SND=y +CONFIG_SND_TIMER=y +CONFIG_SND_PCM=y +CONFIG_SND_COMPRESS_OFFLOAD=y +CONFIG_SND_JACK=y +# CONFIG_SND_SEQUENCER is not set +# CONFIG_SND_MIXER_OSS is not set +# CONFIG_SND_PCM_OSS is not set +# CONFIG_SND_HRTIMER is not set +# CONFIG_SND_DYNAMIC_MINORS is not set +# CONFIG_SND_SUPPORT_OLD_API is not set +# CONFIG_SND_VERBOSE_PROCFS is not set +# CONFIG_SND_VERBOSE_PRINTK is not set +# CONFIG_SND_DEBUG is not set +# CONFIG_SND_RAWMIDI_SEQ is not set +# CONFIG_SND_OPL3_LIB_SEQ is not set +# CONFIG_SND_OPL4_LIB_SEQ is not set +# CONFIG_SND_SBAWE_SEQ is not set +# CONFIG_SND_EMU10K1_SEQ is not set +# CONFIG_SND_DRIVERS is not set +# CONFIG_SND_ARM is not set +# CONFIG_SND_SPI is not set +# CONFIG_SND_USB is not set +CONFIG_SND_SOC=y +CONFIG_SND_SOC_DMAENGINE_PCM=y +# CONFIG_SND_ATMEL_SOC is not set +# CONFIG_SND_DESIGNWARE_I2S is not set +CONFIG_SND_OMAP_SOC=y +CONFIG_SND_OMAP_SOC_C55=y +CONFIG_SND_OMAP_SOC_MCBSP=y +CONFIG_SND_SOC_I2C_AND_SPI=y +# CONFIG_SND_SOC_ALL_CODECS is not set +CONFIG_SND_SOC_C55=y +# CONFIG_SND_SIMPLE_CARD is not set +# CONFIG_SOUND_PRIME is not set # # HID support @@ -1682,6 +1717,7 @@ CONFIG_HID_GENERIC=y # CONFIG_HID_BELKIN is not set # CONFIG_HID_CHERRY is not set # CONFIG_HID_CHICONY is not set +# CONFIG_HID_PRODIKEYS is not set # CONFIG_HID_CYPRESS is not set # CONFIG_HID_DRAGONRISE is not set # CONFIG_HID_EMS_FF is not set @@ -1873,12 +1909,14 @@ CONFIG_USB_LIBCOMPOSITE=y CONFIG_USB_F_ACM=y CONFIG_USB_U_SERIAL=y # CONFIG_USB_ZERO is not set +# CONFIG_USB_AUDIO is not set # CONFIG_USB_ETH is not set # CONFIG_USB_G_NCM is not set # CONFIG_USB_GADGETFS is not set # CONFIG_USB_FUNCTIONFS is not set # CONFIG_USB_MASS_STORAGE is not set # CONFIG_USB_G_SERIAL is not set +# CONFIG_USB_MIDI_GADGET is not set # CONFIG_USB_G_PRINTER is not set CONFIG_USB_G_ANDROID=y # CONFIG_USB_ANDROID_RNDIS_DWORD_ALIGNED is not set @@ -2070,6 +2108,7 @@ CONFIG_STAGING=y # CONFIG_RTLLIB is not set # CONFIG_R8712U is not set # CONFIG_TRANZPORT is not set +# CONFIG_LINE6_USB is not set # CONFIG_VT6656 is not set # CONFIG_ZSMALLOC is not set # CONFIG_BCM_WIMAX is not set @@ -2541,6 +2580,8 @@ CONFIG_LIBCRC32C=y # CONFIG_CRC8 is not set CONFIG_ZLIB_INFLATE=y CONFIG_ZLIB_DEFLATE=y +CONFIG_LZO_COMPRESS=y +CONFIG_LZO_DECOMPRESS=y CONFIG_XZ_DEC=y CONFIG_XZ_DEC_X86=y CONFIG_XZ_DEC_POWERPC=y diff --git a/arch/arm/configs/minnow_defconfig b/arch/arm/configs/minnow_defconfig index 9d1c8df1842..df0c858e104 100644 --- a/arch/arm/configs/minnow_defconfig +++ b/arch/arm/configs/minnow_defconfig @@ -817,6 +817,9 @@ CONFIG_FW_LOADER_USER_HELPER=y # CONFIG_SYS_HYPERVISOR is not set # CONFIG_GENERIC_CPU_DEVICES is not set CONFIG_SOC_BUS=y +CONFIG_REGMAP=y +CONFIG_REGMAP_I2C=y +CONFIG_REGMAP_SPI=y # CONFIG_DMA_SHARED_BUFFER is not set # CONFIG_CMA is not set @@ -1648,10 +1651,42 @@ CONFIG_BACKLIGHT_GENERIC=y # CONFIG_LOGO is not set # CONFIG_FB_SSD1307 is not set CONFIG_SOUND=y -CONFIG_SOUND_OSS_CORE=y -CONFIG_SOUND_OSS_CORE_PRECLAIM=y -# CONFIG_SND is not set -CONFIG_SOUND_PRIME=y +# CONFIG_SOUND_OSS_CORE is not set +CONFIG_SND=y +CONFIG_SND_TIMER=y +CONFIG_SND_PCM=y +CONFIG_SND_COMPRESS_OFFLOAD=y +CONFIG_SND_JACK=y +# CONFIG_SND_SEQUENCER is not set +# CONFIG_SND_MIXER_OSS is not set +# CONFIG_SND_PCM_OSS is not set +# CONFIG_SND_HRTIMER is not set +# CONFIG_SND_DYNAMIC_MINORS is not set +# CONFIG_SND_SUPPORT_OLD_API is not set +# CONFIG_SND_VERBOSE_PROCFS is not set +# CONFIG_SND_VERBOSE_PRINTK is not set +# CONFIG_SND_DEBUG is not set +# CONFIG_SND_RAWMIDI_SEQ is not set +# CONFIG_SND_OPL3_LIB_SEQ is not set +# CONFIG_SND_OPL4_LIB_SEQ is not set +# CONFIG_SND_SBAWE_SEQ is not set +# CONFIG_SND_EMU10K1_SEQ is not set +# CONFIG_SND_DRIVERS is not set +# CONFIG_SND_ARM is not set +# CONFIG_SND_SPI is not set +# CONFIG_SND_USB is not set +CONFIG_SND_SOC=y +CONFIG_SND_SOC_DMAENGINE_PCM=y +# CONFIG_SND_ATMEL_SOC is not set +# CONFIG_SND_DESIGNWARE_I2S is not set +CONFIG_SND_OMAP_SOC=y +CONFIG_SND_OMAP_SOC_C55=y +CONFIG_SND_OMAP_SOC_MCBSP=y +CONFIG_SND_SOC_I2C_AND_SPI=y +# CONFIG_SND_SOC_ALL_CODECS is not set +CONFIG_SND_SOC_C55=y +# CONFIG_SND_SIMPLE_CARD is not set +# CONFIG_SOUND_PRIME is not set # # HID support @@ -1673,6 +1708,7 @@ CONFIG_HID_GENERIC=y # CONFIG_HID_BELKIN is not set # CONFIG_HID_CHERRY is not set # CONFIG_HID_CHICONY is not set +# CONFIG_HID_PRODIKEYS is not set # CONFIG_HID_CYPRESS is not set # CONFIG_HID_DRAGONRISE is not set # CONFIG_HID_EMS_FF is not set @@ -1863,12 +1899,14 @@ CONFIG_USB_LIBCOMPOSITE=y CONFIG_USB_F_ACM=y CONFIG_USB_U_SERIAL=y # CONFIG_USB_ZERO is not set +# CONFIG_USB_AUDIO is not set # CONFIG_USB_ETH is not set # CONFIG_USB_G_NCM is not set # CONFIG_USB_GADGETFS is not set # CONFIG_USB_FUNCTIONFS is not set # CONFIG_USB_MASS_STORAGE is not set # CONFIG_USB_G_SERIAL is not set +# CONFIG_USB_MIDI_GADGET is not set # CONFIG_USB_G_PRINTER is not set CONFIG_USB_G_ANDROID=y # CONFIG_USB_ANDROID_RNDIS_DWORD_ALIGNED is not set @@ -2060,6 +2098,7 @@ CONFIG_STAGING=y # CONFIG_RTLLIB is not set # CONFIG_R8712U is not set # CONFIG_TRANZPORT is not set +# CONFIG_LINE6_USB is not set # CONFIG_VT6656 is not set # CONFIG_ZSMALLOC is not set # CONFIG_BCM_WIMAX is not set @@ -2518,6 +2557,8 @@ CONFIG_LIBCRC32C=y # CONFIG_CRC8 is not set CONFIG_ZLIB_INFLATE=y CONFIG_ZLIB_DEFLATE=y +CONFIG_LZO_COMPRESS=y +CONFIG_LZO_DECOMPRESS=y CONFIG_XZ_DEC=y CONFIG_XZ_DEC_X86=y CONFIG_XZ_DEC_POWERPC=y diff --git a/drivers/misc/Makefile b/drivers/misc/Makefile index 933f59a92a3..fb30252d4e5 100644 --- a/drivers/misc/Makefile +++ b/drivers/misc/Makefile @@ -61,8 +61,7 @@ obj-$(CONFIG_MFD_M4SENSORHUB) += m4sensorhub_gesture.o obj-$(CONFIG_MFD_M4SENSORHUB) += m4sensorhub_stillmode.o obj-$(CONFIG_MFD_M4SENSORHUB) += m4sensorhub_download.o obj-$(CONFIG_MFD_M4SENSORHUB) += m4sensorhub_display.o -obj-$(CONFIG_MFD_M4SENSORHUB) += m4sensorhub_audio.o obj-$(CONFIG_MFD_M4SENSORHUB) += m4sensorhub_passive.o obj-$(CONFIG_VIB_GPIO) += vib-gpio.o obj-$(CONFIG_C55_CTRL) += c55_ctrl.o -obj-$(CONFIG_MMI_FACTORY) += mmi-factory.o
\ No newline at end of file +obj-$(CONFIG_MMI_FACTORY) += mmi-factory.o diff --git a/sound/soc/codecs/Kconfig b/sound/soc/codecs/Kconfig index 2f45f00e31b..50ff7ca10a9 100644 --- a/sound/soc/codecs/Kconfig +++ b/sound/soc/codecs/Kconfig @@ -287,6 +287,9 @@ config SND_SOC_MAX98095 config SND_SOC_MAX9850 tristate +config SND_SOC_C55 + tristate + config SND_SOC_OMAP_HDMI_CODEC tristate diff --git a/sound/soc/codecs/Makefile b/sound/soc/codecs/Makefile index b9e41c9a1f4..39747d34c41 100644 --- a/sound/soc/codecs/Makefile +++ b/sound/soc/codecs/Makefile @@ -16,6 +16,7 @@ snd-soc-ak4642-objs := ak4642.o snd-soc-ak4671-objs := ak4671.o snd-soc-ak5386-objs := ak5386.o snd-soc-arizona-objs := arizona.o +snd-soc-c55-objs := c55audio.o snd-soc-cq93vc-objs := cq93vc.o snd-soc-cs42l51-objs := cs42l51.o snd-soc-cs42l52-objs := cs42l52.o @@ -143,6 +144,7 @@ obj-$(CONFIG_SND_SOC_AK5386) += snd-soc-ak5386.o obj-$(CONFIG_SND_SOC_ALC5623) += snd-soc-alc5623.o obj-$(CONFIG_SND_SOC_ALC5632) += snd-soc-alc5632.o obj-$(CONFIG_SND_SOC_ARIZONA) += snd-soc-arizona.o +obj-$(CONFIG_SND_SOC_C55) += snd-soc-c55.o obj-$(CONFIG_SND_SOC_CQ0093VC) += snd-soc-cq93vc.o obj-$(CONFIG_SND_SOC_CS42L51) += snd-soc-cs42l51.o obj-$(CONFIG_SND_SOC_CS42L52) += snd-soc-cs42l52.o diff --git a/sound/soc/codecs/c55audio.c b/sound/soc/codecs/c55audio.c new file mode 100644 index 00000000000..de2798c0998 --- /dev/null +++ b/sound/soc/codecs/c55audio.c @@ -0,0 +1,182 @@ +/* + * Copyright (C) 2014 Motorola, Inc. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA + * 02111-1307, USA + */ + +#include <linux/gpio.h> +#include <linux/module.h> +#include <linux/of.h> +#include <linux/of_device.h> +#include <linux/of_gpio.h> +#include <sound/soc.h> + +/* codec private data */ +struct soc_c55_private { + int mic_bias1_en_gpio; + int mic_bias3_en_gpio; +}; + +static const struct snd_soc_dapm_widget soc_c55_dapm_widgets[] = { + SND_SOC_DAPM_ADC("ADC", "Voice Capture", SND_SOC_NOPM, 0, 0), + SND_SOC_DAPM_INPUT("MIC"), +}; + +static const struct snd_soc_dapm_route soc_c55_audio_map[] = { + {"ADC", NULL, "MIC"}, +}; + +static const struct of_device_id soc_c55_of_match[] = { + {.compatible = "mot,soc-c55", }, + { }, +}; +MODULE_DEVICE_TABLE(of, soc_c55_of_match); + +static int soc_codec_c55_set_bias_level(struct snd_soc_codec *codec, + enum snd_soc_bias_level level) +{ + struct soc_c55_private *priv = snd_soc_codec_get_drvdata(codec); + + switch (level) { + case SND_SOC_BIAS_ON: + break; + case SND_SOC_BIAS_PREPARE: + break; + case SND_SOC_BIAS_STANDBY: + if (codec->dapm.bias_level == SND_SOC_BIAS_OFF) { + /* Enable mic biases */ + gpio_set_value(priv->mic_bias1_en_gpio, 1); + gpio_set_value(priv->mic_bias3_en_gpio, 1); + } + break; + case SND_SOC_BIAS_OFF: + /* Disable mic biases */ + gpio_set_value(priv->mic_bias1_en_gpio, 0); + gpio_set_value(priv->mic_bias3_en_gpio, 0); + break; + } + codec->dapm.bias_level = level; + + return 0; +} + +static struct snd_soc_dai_driver soc_codec_c55_dai = { + .name = "c55-voice", + .capture = { + .stream_name = "Voice Capture", + .channels_min = 1, + .channels_max = 2, + .rates = SNDRV_PCM_RATE_16000, + .formats = SNDRV_PCM_FMTBIT_S16_LE,}, +}; + +static int soc_codec_c55_probe(struct snd_soc_codec *codec) +{ + struct soc_c55_private *c55; + int gpio; + int ret; + + c55 = devm_kzalloc(codec->dev, sizeof(struct soc_c55_private), + GFP_KERNEL); + if (c55 == NULL) { + dev_err(codec->dev, "Can not allocate memory\n"); + return -ENOMEM; + } + snd_soc_codec_set_drvdata(codec, c55); + +#ifdef CONFIG_OF + if (of_match_device(soc_c55_of_match, codec->dev)) { + gpio = of_get_named_gpio(codec->dev->of_node, + "mot,mic_bias1_en", 0); + ret = (gpio < 0) ? -ENODEV : gpio_request(gpio, "mic_bias1_en"); + if (ret) { + dev_err(codec->dev, + "Failed acquiring Mic Bias 1 En GPIO-%d (%d)\n", + gpio, ret); + return ret; + } + gpio_direction_output(gpio, 0); + c55->mic_bias1_en_gpio = gpio; + + gpio = of_get_named_gpio(codec->dev->of_node, + "mot,mic_bias3_en", 0); + ret = (gpio < 0) ? -ENODEV : gpio_request(gpio, "mic_bias3_en"); + if (ret) { + dev_err(codec->dev, + "Failed acquiring Mic Bias 3 En GPIO-%d (%d)\n", + gpio, ret); + return ret; + } + gpio_direction_output(gpio, 0); + c55->mic_bias3_en_gpio = gpio; + } +#endif + + return 0; +} + +static int soc_codec_c55_remove(struct snd_soc_codec *codec) +{ + struct soc_c55_private *priv = snd_soc_codec_get_drvdata(codec); + + soc_codec_c55_set_bias_level(codec, SND_SOC_BIAS_OFF); + + if (priv) { + gpio_free(priv->mic_bias1_en_gpio); + gpio_free(priv->mic_bias3_en_gpio); + } + + return 0; +} + +static struct snd_soc_codec_driver soc_codec_c55 = { + .probe = soc_codec_c55_probe, + .remove = soc_codec_c55_remove, + .set_bias_level = soc_codec_c55_set_bias_level, + .idle_bias_off = true, + .dapm_widgets = soc_c55_dapm_widgets, + .num_dapm_widgets = ARRAY_SIZE(soc_c55_dapm_widgets), + .dapm_routes = soc_c55_audio_map, + .num_dapm_routes = ARRAY_SIZE(soc_c55_audio_map), +}; + +static int soc_c55_probe(struct platform_device *pdev) +{ + return snd_soc_register_codec(&pdev->dev, &soc_codec_c55, + &soc_codec_c55_dai, 1); +} + +static int soc_c55_remove(struct platform_device *pdev) +{ + snd_soc_unregister_codec(&pdev->dev); + return 0; +} + +static struct platform_driver soc_c55_driver = { + .probe = soc_c55_probe, + .remove = soc_c55_remove, + .driver = { + .name = "soc-c55", + .owner = THIS_MODULE, + .of_match_table = of_match_ptr(soc_c55_of_match), + }, +}; + +module_platform_driver(soc_c55_driver); + +MODULE_AUTHOR("Motorola"); +MODULE_DESCRIPTION("ALSA SoC c55 audio codec driver"); +MODULE_LICENSE("GPL"); +MODULE_ALIAS("platform:soc-c55"); diff --git a/sound/soc/omap/Kconfig b/sound/soc/omap/Kconfig index 60259f2f3f2..77157ed6efd 100644 --- a/sound/soc/omap/Kconfig +++ b/sound/soc/omap/Kconfig @@ -3,6 +3,17 @@ config SND_OMAP_SOC depends on ARCH_OMAP && DMA_OMAP select SND_SOC_DMAENGINE_PCM +config SND_OMAP_SOC_C55 + tristate "SoC Audio support for C55 audio" + depends on SND_OMAP_SOC + select SND_OMAP_SOC_MCBSP + select SND_SOC_C55 + help + Say Y if you want to add support for SoC audio from the C55 DSP. This + pulls audio over the McBSP bus in I2S format. The C55 DSP outputs the + data in 16 bit 2 channel 16 kHz audio. It uses an input clock + frequency of 83.456 Mhz. + config SND_OMAP_SOC_DMIC tristate diff --git a/sound/soc/omap/Makefile b/sound/soc/omap/Makefile index 2b225945359..7272bf4da6d 100644 --- a/sound/soc/omap/Makefile +++ b/sound/soc/omap/Makefile @@ -17,6 +17,7 @@ snd-soc-rx51-objs := rx51.o snd-soc-ams-delta-objs := ams-delta.o snd-soc-osk5912-objs := osk5912.o snd-soc-am3517evm-objs := am3517evm.o +snd-soc-omap-c55-objs := omap-c55audio.o snd-soc-omap-abe-twl6040-objs := omap-abe-twl6040.o snd-soc-omap-twl4030-objs := omap-twl4030.o snd-soc-omap3pandora-objs := omap3pandora.o @@ -28,6 +29,7 @@ obj-$(CONFIG_SND_OMAP_SOC_AMS_DELTA) += snd-soc-ams-delta.o obj-$(CONFIG_SND_OMAP_SOC_OSK5912) += snd-soc-osk5912.o obj-$(CONFIG_SND_OMAP_SOC_OMAP2EVM) += snd-soc-omap2evm.o obj-$(CONFIG_SND_OMAP_SOC_AM3517EVM) += snd-soc-am3517evm.o +obj-$(CONFIG_SND_OMAP_SOC_C55) += snd-soc-omap-c55.o obj-$(CONFIG_SND_OMAP_SOC_OMAP_ABE_TWL6040) += snd-soc-omap-abe-twl6040.o obj-$(CONFIG_SND_OMAP_SOC_OMAP_TWL4030) += snd-soc-omap-twl4030.o obj-$(CONFIG_SND_OMAP_SOC_OMAP3_PANDORA) += snd-soc-omap3pandora.o diff --git a/sound/soc/omap/mcbsp.h b/sound/soc/omap/mcbsp.h index 96d1b086bcf..02f85959561 100644 --- a/sound/soc/omap/mcbsp.h +++ b/sound/soc/omap/mcbsp.h @@ -160,7 +160,7 @@ enum { #define XPHASE BIT(15) /************************* McBSP SRGR1 bit definitions ************************/ -#define CLKGDV(value) ((value) & 0x7f) /* Bits 0:7 */ +#define CLKGDV(value) ((value) & 0xff) /* Bits 0:7 */ #define FWID(value) (((value) & 0xff) << 8) /* Bits 8:15 */ /************************* McBSP SRGR2 bit definitions ************************/ diff --git a/sound/soc/omap/omap-c55audio.c b/sound/soc/omap/omap-c55audio.c new file mode 100644 index 00000000000..8103d18437c --- /dev/null +++ b/sound/soc/omap/omap-c55audio.c @@ -0,0 +1,161 @@ +/* + * Copyright (C) 2014 Motorola, Inc. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA + * 02111-1307, USA + */ + +#include <linux/module.h> +#include <linux/of.h> +#include <sound/soc.h> + +#include "omap-mcbsp.h" + +#define INPUT_CLOCK_FREQUENCY 83456000 +/* We desire a bit clock of 512 kHz for 16 bit 2 channel 16 kHz audio. + * We get this from 83.456 Mhz / (162 + 1) = 512 kHz */ +#define CLKDIV (INPUT_CLOCK_FREQUENCY / 512000 - 1) + +static int omap_soc_c55_hw_params(struct snd_pcm_substream *substream, + struct snd_pcm_hw_params *params) +{ + struct snd_soc_pcm_runtime *rtd = substream->private_data; + struct snd_soc_dai *cpu_dai = rtd->cpu_dai; + int ret; + + /* Set McBSP4 clock to use PER_96M_FCLK */ + ret = snd_soc_dai_set_sysclk(cpu_dai, OMAP_MCBSP_SYSCLK_CLKS_FCLK, + INPUT_CLOCK_FREQUENCY, SND_SOC_CLOCK_OUT); + if (ret < 0) { + dev_err(rtd->dev, "can't set cpu system clock\n"); + return ret; + } + + /* Set McBSP4 clock to use MCBSP4_ICLK */ + ret = snd_soc_dai_set_sysclk(cpu_dai, OMAP_MCBSP_SYSCLK_CLK, + INPUT_CLOCK_FREQUENCY, SND_SOC_CLOCK_OUT); + if (ret < 0) { + dev_err(rtd->dev, "can't set cpu system clock\n"); + return ret; + } + + ret = snd_soc_dai_set_clkdiv(cpu_dai, OMAP_MCBSP_CLKGDV, CLKDIV); + if (ret < 0) { + dev_err(rtd->dev, "can't set SRG clock divider\n"); + return ret; + } + + return 0; +} + +static struct snd_soc_ops omap_soc_c55_ops = { + .hw_params = omap_soc_c55_hw_params, +}; + +/* Digital audio interface glue - connects codec <--> CPU */ +static struct snd_soc_dai_link omap_soc_c55_dai_links[] = { + { + .name = "OMAP SOC C55 Audio", + .stream_name = "OMAP SOC C55", + .cpu_dai_name = "omap-mcbsp.4", + .codec_dai_name = "c55-voice", + .platform_name = "omap-pcm-audio", + .codec_name = "soc.1", + .dai_fmt = SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_NB_NF | + SND_SOC_DAIFMT_CBS_CFS, + .ops = &omap_soc_c55_ops, + }, +}; + +/* Audio machine driver */ +static struct snd_soc_card omap_soc_c55_card = { + .owner = THIS_MODULE, + .dai_link = omap_soc_c55_dai_links, + .num_links = ARRAY_SIZE(omap_soc_c55_dai_links), +}; + +static int omap_soc_c55_probe(struct platform_device *pdev) +{ + struct device_node *node = pdev->dev.of_node; + struct snd_soc_card *card = &omap_soc_c55_card; + int ret = 0; + + card->dev = &pdev->dev; + +#ifdef CONFIG_OF + if (node) { + struct device_node *dai_node; + + if (snd_soc_of_parse_card_name(card, "mot,model")) { + dev_err(&pdev->dev, "Card name is not provided\n"); + return -ENODEV; + } + + dai_node = of_parse_phandle(node, "mot,mcbsp", 0); + if (!dai_node) { + dev_err(&pdev->dev, "McBSP node is not provided\n"); + return -EINVAL; + } + omap_soc_c55_dai_links[0].cpu_dai_name = NULL; + omap_soc_c55_dai_links[0].cpu_of_node = dai_node; + + } else { + dev_err(&pdev->dev, "Missing node\n"); + return -ENODEV; + } +#endif + + snd_soc_card_set_drvdata(card, NULL); + ret = snd_soc_register_card(card); + if (ret) { + dev_err(&pdev->dev, "snd_soc_register_card() failed: %d\n", + ret); + return ret; + } + + return 0; +} + +static int omap_soc_c55_remove(struct platform_device *pdev) +{ + struct snd_soc_card *card = platform_get_drvdata(pdev); + + snd_soc_unregister_card(card); + + return 0; +} + +static const struct of_device_id omap_soc_c55_of_match[] = { + {.compatible = "mot,omap-soc-c55", }, + { }, +}; +MODULE_DEVICE_TABLE(of, omap_soc_c55_of_match); + +static struct platform_driver omap_soc_c55_driver = { + .driver = { + .name = "omap-soc-c55", + .owner = THIS_MODULE, + .pm = &snd_soc_pm_ops, + .of_match_table = of_match_ptr(omap_soc_c55_of_match), + }, + .probe = omap_soc_c55_probe, + .remove = omap_soc_c55_remove, +}; + +module_platform_driver(omap_soc_c55_driver); + +MODULE_AUTHOR("Motorola"); +MODULE_DESCRIPTION("ALSA SoC for c55 audio"); +MODULE_LICENSE("GPL"); +MODULE_ALIAS("platform:omap-soc-c55"); |