ARM: Tegra: ALSA support for Cardhu
Stephen Warren [Tue, 26 Jul 2011 20:08:31 +0000 (14:08 -0600)]
Define GPIO names, platform data, and platform devices for audio support
on Cardhu.

Configure/register the WM8903 IRQ gpio.

Don't statically configure most audio-related clocks; the ASoC utils code
sets this all up now.

Signed-off-by: Stephen Warren <swarren@nvidia.com>

Rebase-Id: R77ca15a61948eefd790d97cbfe1470d2687c5b73

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

index cc7f467..a2350bb 100644 (file)
@@ -143,6 +143,7 @@ config MACH_VENTANA
 config MACH_CARDHU
        bool "Cardhu board"
        depends on ARCH_TEGRA_3x_SOC
+       select MACH_HAS_SND_SOC_TEGRA_WM8903
        help
          Support for NVIDIA Cardhu development platform
 
index 20d64a8..14c2d5a 100644 (file)
@@ -453,6 +453,15 @@ static __initdata struct tegra_pingroup_config unused_pins_lowpower[] = {
        DEFAULT_PINMUX(GMI_DQS,         NAND,           NORMAL,     TRISTATE,     OUTPUT),
 };
 
+static void __init cardhu_pinmux_audio_init(void)
+{
+       tegra_gpio_enable(TEGRA_GPIO_CDC_IRQ);
+       gpio_request(TEGRA_GPIO_CDC_IRQ, "wm8903");
+       gpio_direction_input(TEGRA_GPIO_CDC_IRQ);
+
+       tegra_gpio_enable(TEGRA_GPIO_HP_DET);
+}
+
 int __init cardhu_pinmux_init(void)
 {
        struct board_info board_info;
@@ -486,6 +495,9 @@ int __init cardhu_pinmux_init(void)
                                        ARRAY_SIZE(cardhu_pinmux_e118x));
                break;
        }
+
+       cardhu_pinmux_audio_init();
+
        return 0;
 }
 
index e1b0624..229ba3d 100644 (file)
@@ -36,6 +36,8 @@
 #include <linux/spi/spi.h>
 #include <linux/i2c/atmel_mxt_ts.h>
 
+#include <sound/wm8903.h>
+
 #include <mach/clk.h>
 #include <mach/iomap.h>
 #include <mach/irqs.h>
@@ -43,7 +45,7 @@
 #include <mach/iomap.h>
 #include <mach/io.h>
 #include <mach/i2s.h>
-#include <mach/audio.h>
+#include <mach/tegra_wm8903_pdata.h>
 #include <asm/mach-types.h>
 #include <asm/mach/arch.h>
 #include <mach/usb_phy.h>
@@ -178,12 +180,7 @@ static __initdata struct tegra_clk_init_table cardhu_clk_init_table[] = {
        { "hda2codec_2x","pll_p",       48000000,       false},
        { "pwm",        "clk_32k",      32768,          false},
        { "blink",      "clk_32k",      32768,          true},
-       { "pll_a",      NULL,           552960000,      true},
-       { "pll_a_out0", NULL,           11289600,       true},
-       { "i2s1",       "pll_a_out0",   11289600,       true},
-       { "i2s2",       "pll_a_out0",   11289600,       true},
-       { "audio",      "pll_a_out0",   11289600,       true},
-       { "audio_2x",   "audio",        22579200,       true},
+       { "i2s1",       "pll_a_out0",   0,              false},
        { NULL,         NULL,           0,              0},
 };
 
@@ -227,6 +224,26 @@ struct tegra_wired_jack_conf audio_wr_jack_conf = {
 };
 #endif
 
+static struct wm8903_platform_data cardhu_wm8903_pdata = {
+       .irq_active_low = 0,
+       .micdet_cfg = 0,
+       .micdet_delay = 100,
+       .gpio_base = CARDHU_GPIO_WM8903(0),
+       .gpio_cfg = {
+               WM8903_GPIO_NO_CONFIG,
+               WM8903_GPIO_NO_CONFIG,
+               0,
+               WM8903_GPIO_NO_CONFIG,
+               WM8903_GPIO_NO_CONFIG,
+       },
+};
+
+static struct i2c_board_info __initdata wm8903_board_info = {
+       I2C_BOARD_INFO("wm8903", 0x1a),
+       .platform_data = &cardhu_wm8903_pdata,
+       .irq = TEGRA_GPIO_TO_IRQ(TEGRA_GPIO_CDC_IRQ),
+};
+
 static void cardhu_i2c_init(void)
 {
        tegra_i2c_device1.dev.platform_data = &cardhu_i2c1_platform_data;
@@ -240,6 +257,8 @@ static void cardhu_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, &wm8903_board_info, 1);
 }
 
 static struct platform_device *cardhu_uart_devices[] __initdata = {
@@ -302,6 +321,22 @@ static struct platform_device tegra_camera = {
        .id = -1,
 };
 
+static struct tegra_wm8903_platform_data cardhu_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 cardhu_audio_device = {
+       .name   = "tegra-snd-wm8903",
+       .id     = 0,
+       .dev    = {
+               .platform_data  = &cardhu_audio_pdata,
+       },
+};
+
 static struct platform_device *cardhu_devices[] __initdata = {
        &tegra_pmu_device,
        &tegra_udc_device,
@@ -318,6 +353,10 @@ static struct platform_device *cardhu_devices[] __initdata = {
 #if defined(CONFIG_CRYPTO_DEV_TEGRA_SE)
        &tegra_se_device,
 #endif
+       &tegra_ahub_device,
+       &tegra_i2s_device1,
+       &tegra_pcm_device,
+       &cardhu_audio_device,
 };
 
 #define MXT_CONFIG_CRC  0xD62DE8
index efd2482..12fbec5 100644 (file)
 #define CAM_I2C_MUX_RST_EXP                    CAM_TCA6416_GPIO_BASE + 15
 #define CAM_TCA6416_GPIO_END           CAM_TCA6416_GPIO_BASE + 16
 
+/* WM8903 GPIOs */
+#define CARDHU_GPIO_WM8903(_x_)                (CAM_TCA6416_GPIO_END + (_x_))
+#define CARDHU_GPIO_WM8903_END         CARDHU_GPIO_WM8903(4)
+
+/* Audio-related GPIOs */
+#define TEGRA_GPIO_CDC_IRQ             TEGRA_GPIO_PW3
+#define TEGRA_GPIO_SPKR_EN             CARDHU_GPIO_WM8903(2)
+#define TEGRA_GPIO_HP_DET              TEGRA_GPIO_PW2
+
 /* CAMERA RELATED GPIOs on CARDHU */
 #define OV5650_RESETN_GPIO                     TEGRA_GPIO_PBB0
 #define CAM1_POWER_DWN_GPIO                    TEGRA_GPIO_PBB5