Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on Aug 22nd, 2012  |  syntax: C  |  size: 4.27 KB  |  hits: 11  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. /*
  2.  * arch/arm/mach-tegra/board-smba1002-audio.c
  3.  *
  4.  * Copyright (C) 2011 Eduardo José Tagle <ejtagle@tutopia.com>
  5.  *
  6.  * This software is licensed under the terms of the GNU General Public
  7.  * License version 2, as published by the Free Software Foundation, and
  8.  * may be copied, distributed, and modified under those terms.
  9.  *
  10.  * This program is distributed in the hope that it will be useful,
  11.  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  12.  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  13.  * GNU General Public License for more details.
  14.  *
  15.  */
  16.  
  17. /* All configurations related to audio */
  18. /*#define ALC5623_IS_MASTER*/
  19.  
  20. #include <linux/console.h>
  21. #include <linux/kernel.h>
  22. #include <linux/init.h>
  23. #include <linux/platform_device.h>
  24. #include <linux/clk.h>
  25. #include <linux/gpio.h>
  26. #include <linux/delay.h>
  27. #include <linux/i2c-tegra.h>
  28. #include <linux/i2c.h>
  29. #include <linux/version.h>
  30. #include <sound/alc5623.h>
  31. #include <sound/soc.h>
  32. #include <sound/soc-dai.h>
  33.  
  34. #include <asm/mach-types.h>
  35. #include <asm/mach/arch.h>
  36. #include <asm/mach/time.h>
  37. #include <asm/setup.h>
  38. #include <asm/io.h>
  39.  
  40. #include <mach/tegra_alc5623_pdata.h>
  41. #include <mach/io.h>
  42. #include <mach/irqs.h>
  43. #include <mach/iomap.h>
  44. #include <mach/gpio.h>
  45. #include <mach/spdif.h>
  46. #include <mach/audio.h>
  47.  
  48. #include <mach/system.h>
  49.  
  50. #include "board.h"
  51. #include "board-smba1002.h"
  52. #include "gpio-names.h"
  53. #include "devices.h"
  54.  
  55. /* Default music path: I2S1(DAC1)<->Dap1<->HifiCodec
  56.    Bluetooth to codec: I2S2(DAC2)<->Dap4<->Bluetooth
  57. */
  58. /* For SMBA1002,
  59.         Codec is ALC5623
  60.         Codec I2C Address = 0x34(includes R/W bit), i2c #0
  61.         Codec MCLK = APxx DAP_MCLK1
  62. */
  63.  
  64.  
  65. static struct alc5623_platform_data smba_alc5623_pdata = {
  66.         .avdd_mv                = 3300, /* Analog vdd in millivolts */
  67.  
  68.         .mic1bias_mv            = 2475, /* MIC1 bias voltage */
  69.         .mic1boost_db           = 20,  /* MIC1 gain boost */
  70.         .mic2boost_db           = 20,  /* MIC2 gain boost */
  71.  
  72.         .default_is_mic2        = false,        /* SMBA1002 uses MIC1 as the default capture source */
  73.  
  74. };
  75.  
  76. static struct i2c_board_info __initdata smba_i2c_bus0_board_info[] = {
  77.         {
  78.                 I2C_BOARD_INFO("alc5623", 0x1a),
  79.                 .platform_data = &smba_alc5623_pdata,
  80.         },
  81. };
  82.  
  83.  
  84. static struct tegra_alc5623_platform_data smba_audio_pdata = {
  85.         .gpio_spkr_en           = -2,
  86.         .gpio_int_mic_en        = SMBA1002_INT_MIC_EN,
  87.         .gpio_hp_det            = SMBA1002_HP_DETECT,
  88.         .hifi_codec_datafmt = SND_SOC_DAIFMT_I2S,       /* HiFi codec data format */
  89. #ifdef ALC5623_IS_MASTER
  90.         .hifi_codec_master  = true,                                     /* If Hifi codec is master */
  91. #else
  92.         .hifi_codec_master  = false,                            /* If Hifi codec is master */
  93. #endif
  94.         .bt_codec_datafmt   = SND_SOC_DAIFMT_DSP_A,     /* Bluetooth codec data format */
  95.         .bt_codec_master    = true,                                     /* If bt codec is master */
  96.  
  97. };
  98. static struct platform_device tegra_generic_codec = {
  99.         .name = "tegra-generic-codec",
  100.         .id   = -1,
  101. };
  102.  
  103. static struct platform_device smba_audio_device = {
  104.         .name = "tegra-snd-alc5623",
  105.         .id   = 0,
  106.         .dev    = {
  107.                 .platform_data  = &smba_audio_pdata,
  108.         },
  109.  
  110. };
  111.  
  112. static struct platform_device *smba_i2s_devices[] __initdata = {
  113.         &tegra_i2s_device1,
  114.         &tegra_i2s_device2,
  115.         &tegra_spdif_device,
  116.         &tegra_das_device,
  117.         &spdif_dit_device,
  118.         &bluetooth_dit_device,
  119.         &tegra_pcm_device,
  120.         &tegra_generic_codec,
  121.         &smba_audio_device, /* this must come last, as we need the DAS to be initialized to access the codec registers ! */
  122. };
  123.  
  124.  
  125. int  __init smba_audio_register_devices(void)
  126. {
  127.         int ret;
  128.         /* We NEED the smba audio device to be registered FIRST, as it enables the MCLK
  129.            that is required to get proper access to the codec registers */
  130.         ret = platform_add_devices(smba_i2s_devices, ARRAY_SIZE(smba_i2s_devices));
  131.         if (ret)
  132.                 return ret;
  133.  
  134.         return i2c_register_board_info(0, smba_i2c_bus0_board_info,
  135.                 ARRAY_SIZE(smba_i2c_bus0_board_info));
  136. }