ARM: tegra: whistler: Add sound support
Sumit Bhattacharya [Tue, 30 Aug 2011 16:34:55 +0000 (21:34 +0530)]
Bug 862023

Change-Id: I32d8406a7c1d88b09156b94dda2a2b47e89e515f
Reviewed-on: http://git-master/r/49874
Tested-by: Sumit Bhattacharya <sumitb@nvidia.com>
Reviewed-by: Bharat Nihalani <bnihalani@nvidia.com>

Rebase-Id: R101d312a1a301bc8c8477cb2582583a019f22375

arch/arm/mach-tegra/Kconfig
arch/arm/mach-tegra/board-whistler-pinmux.c
arch/arm/mach-tegra/board-whistler.c
arch/arm/mach-tegra/board-whistler.h

index d8ed09b..9c3438a 100644 (file)
@@ -138,6 +138,7 @@ config MACH_VENTANA
 config MACH_WHISTLER
        bool "Whistler board"
        depends on ARCH_TEGRA_2x_SOC
+       select MACH_HAS_SND_SOC_TEGRA_WM8753 if SND_SOC
        help
          Support for NVIDIA Whistler development platform
 
index aa74f29..5dc8b79 100644 (file)
 
 #include <linux/kernel.h>
 #include <linux/init.h>
+#include <linux/gpio.h>
 #include <mach/pinmux.h>
 
+#include "board-whistler.h"
+#include "gpio-names.h"
+
 #define DEFAULT_DRIVE(_name)                                   \
        {                                                       \
                .pingroup = TEGRA_DRIVE_PINGROUP_##_name,       \
@@ -45,14 +49,14 @@ static __initdata struct tegra_pingroup_config whistler_pinmux[] = {
        {TEGRA_PINGROUP_ATC,   TEGRA_MUX_SDIO4,         TEGRA_PUPD_PULL_UP,   TEGRA_TRI_NORMAL},
        {TEGRA_PINGROUP_ATD,   TEGRA_MUX_SDIO4,         TEGRA_PUPD_NORMAL,    TEGRA_TRI_NORMAL},
        {TEGRA_PINGROUP_ATE,   TEGRA_MUX_GMI,           TEGRA_PUPD_NORMAL,    TEGRA_TRI_NORMAL},
-       {TEGRA_PINGROUP_CDEV1, TEGRA_MUX_OSC,           TEGRA_PUPD_PULL_DOWN, TEGRA_TRI_TRISTATE},
+       {TEGRA_PINGROUP_CDEV1, TEGRA_MUX_PLLA_OUT,      TEGRA_PUPD_NORMAL,    TEGRA_TRI_NORMAL},
        {TEGRA_PINGROUP_CDEV2, TEGRA_MUX_OSC,           TEGRA_PUPD_PULL_DOWN, TEGRA_TRI_TRISTATE},
        {TEGRA_PINGROUP_CRTP,  TEGRA_MUX_CRT,           TEGRA_PUPD_NORMAL,    TEGRA_TRI_TRISTATE},
        {TEGRA_PINGROUP_CSUS,  TEGRA_MUX_VI_SENSOR_CLK, TEGRA_PUPD_NORMAL, TEGRA_TRI_NORMAL},
-       {TEGRA_PINGROUP_DAP1,  TEGRA_MUX_DAP1,          TEGRA_PUPD_PULL_DOWN, TEGRA_TRI_TRISTATE},
-       {TEGRA_PINGROUP_DAP2,  TEGRA_MUX_DAP2,          TEGRA_PUPD_PULL_DOWN, TEGRA_TRI_TRISTATE},
-       {TEGRA_PINGROUP_DAP3,  TEGRA_MUX_DAP3,          TEGRA_PUPD_PULL_DOWN, TEGRA_TRI_TRISTATE},
-       {TEGRA_PINGROUP_DAP4,  TEGRA_MUX_DAP4,          TEGRA_PUPD_PULL_DOWN, TEGRA_TRI_TRISTATE},
+       {TEGRA_PINGROUP_DAP1,  TEGRA_MUX_DAP1,          TEGRA_PUPD_NORMAL,    TEGRA_TRI_NORMAL},
+       {TEGRA_PINGROUP_DAP2,  TEGRA_MUX_DAP2,          TEGRA_PUPD_NORMAL,    TEGRA_TRI_NORMAL},
+       {TEGRA_PINGROUP_DAP3,  TEGRA_MUX_DAP3,          TEGRA_PUPD_NORMAL,    TEGRA_TRI_NORMAL},
+       {TEGRA_PINGROUP_DAP4,  TEGRA_MUX_DAP4,          TEGRA_PUPD_NORMAL,    TEGRA_TRI_NORMAL},
        {TEGRA_PINGROUP_DDC,   TEGRA_MUX_I2C2,          TEGRA_PUPD_PULL_UP,   TEGRA_TRI_NORMAL},
        {TEGRA_PINGROUP_DTA,   TEGRA_MUX_VI,            TEGRA_PUPD_PULL_DOWN, TEGRA_TRI_NORMAL},
        {TEGRA_PINGROUP_DTB,   TEGRA_MUX_VI,            TEGRA_PUPD_PULL_DOWN, TEGRA_TRI_NORMAL},
@@ -158,9 +162,17 @@ static __initdata struct tegra_pingroup_config whistler_pinmux[] = {
        {TEGRA_PINGROUP_XM2D,  TEGRA_MUX_NONE,          TEGRA_PUPD_NORMAL,    TEGRA_TRI_NORMAL},
 };
 
-void __init whistler_pinmux_init(void)
+static struct tegra_gpio_table gpio_table[] = {
+       { .gpio = TEGRA_GPIO_HP_DET,            .enable = true  },
+       { .gpio = TEGRA_GPIO_SPKR_EN,           .enable = true  },
+};
+
+int __init whistler_pinmux_init(void)
 {
        tegra_pinmux_config_table(whistler_pinmux, ARRAY_SIZE(whistler_pinmux));
        tegra_drive_pinmux_config_table(whistler_drive_pinmux,
                                        ARRAY_SIZE(whistler_drive_pinmux));
+
+       tegra_gpio_config(gpio_table, ARRAY_SIZE(gpio_table));
+       return 0;
 }
index 753a323..84aa853 100644 (file)
@@ -44,6 +44,8 @@
 #include <mach/pinmux.h>
 #include <mach/iomap.h>
 #include <mach/io.h>
+#include <mach/i2s.h>
+#include <mach/tegra_wm8753_pdata.h>
 
 #include <asm/mach-types.h>
 #include <asm/mach/arch.h>
@@ -214,6 +216,7 @@ static __initdata struct tegra_clk_init_table whistler_clk_init_table[] = {
        { "pwm",        "clk_32k",      32768,          false},
        { "kbc",        "clk_32k",      32768,          true},
        { "sdmmc2",     "pll_p",        25000000,       false},
+       { "i2s1",       "pll_a_out0",   0,              false},
        { NULL,         NULL,           0,              0},
 };
 
@@ -254,6 +257,10 @@ static struct tegra_i2c_platform_data whistler_dvc_platform_data = {
        .is_dvc         = true,
 };
 
+static struct i2c_board_info __initdata wm8753_board_info = {
+       I2C_BOARD_INFO("wm8753", 0x1a),
+};
+
 static void whistler_i2c_init(void)
 {
        tegra_i2c_device1.dev.platform_data = &whistler_i2c1_platform_data;
@@ -265,6 +272,8 @@ static void whistler_i2c_init(void)
        platform_device_register(&tegra_i2c_device3);
        platform_device_register(&tegra_i2c_device2);
        platform_device_register(&tegra_i2c_device1);
+
+       i2c_register_board_info(4, &wm8753_board_info, 1);
 }
 
 #define GPIO_SCROLL(_pinaction, _gpio, _desc)  \
@@ -301,6 +310,22 @@ static struct platform_device tegra_camera = {
        .id = -1,
 };
 
+static struct tegra_wm8753_platform_data whistler_audio_pdata = {
+       .gpio_spkr_en = TEGRA_GPIO_SPKR_EN,
+       .gpio_hp_det = TEGRA_GPIO_HP_DET,
+       .gpio_hp_mute = -1,
+       .gpio_int_mic_en = -1,
+       .gpio_ext_mic_en = -1,
+};
+
+static struct platform_device whistler_audio_device = {
+       .name   = "tegra-snd-wm8753",
+       .id     = 0,
+       .dev    = {
+               .platform_data  = &whistler_audio_pdata,
+       },
+};
+
 static struct platform_device *whistler_devices[] __initdata = {
        &tegra_pmu_device,
        &tegra_udc_device,
@@ -309,6 +334,10 @@ static struct platform_device *whistler_devices[] __initdata = {
        &tegra_avp_device,
        &whistler_scroll_device,
        &tegra_camera,
+       &tegra_i2s_device1,
+       &tegra_das_device,
+       &tegra_pcm_device,
+       &whistler_audio_device,
 };
 
 static int __init whistler_scroll_init(void)
index c8d2f7b..884f7c4 100644 (file)
@@ -28,6 +28,11 @@ int whistler_emc_init(void);
 
 /* Interrupt numbers from external peripherals */
 #define MAX8907C_INT_BASE       TEGRA_NR_IRQS
-#define MAX8907C_INT_END        (MAX8907C_INT_BASE + 32)
+#define MAX8907C_INT_END        (MAX8907C_INT_BASE + 31)
+
+/* Audio-related GPIOs */
+#define WHISTLER_GPIO_WM8753(_x_)      (MAX8907C_INT_END + 1 + (_x_))
+#define TEGRA_GPIO_SPKR_EN             WHISTLER_GPIO_WM8753(2)
+#define TEGRA_GPIO_HP_DET              TEGRA_GPIO_PW2
 
 #endif