Add ram console device to cardhu
[linux-2.6.git] / arch / arm / mach-tegra / board-cardhu.c
index 36f0fdd..b576a23 100644 (file)
 #include <linux/spi/spi.h>
 #include <linux/i2c/atmel_mxt_ts.h>
 #include <linux/tegra_uart.h>
+#include <linux/memblock.h>
 #include <linux/spi-tegra.h>
 #include <linux/nfc/pn544.h>
 
 #include <sound/wm8903.h>
+#include <sound/max98095.h>
 #include <media/tegra_dtv.h>
 
 #include <mach/clk.h>
@@ -49,6 +51,7 @@
 #include <mach/iomap.h>
 #include <mach/io.h>
 #include <mach/i2s.h>
+#include <mach/tegra_asoc_pdata.h>
 #include <mach/tegra_wm8903_pdata.h>
 #include <asm/mach-types.h>
 #include <asm/mach/arch.h>
@@ -66,6 +69,9 @@
 #include "baseband-xmm-power.h"
 #include "wdt-recovery.h"
 
+static unsigned long ramconsole_start;
+static unsigned long ramconsole_size;
+
 /* All units are in millicelsius */
 static struct tegra_thermal_data thermal_data = {
        .temp_throttle = 85000,
@@ -212,6 +218,7 @@ static __initdata struct tegra_clk_init_table cardhu_clk_init_table[] = {
        { "hda2codec_2x","pll_p",       48000000,       false},
        { "pwm",        "pll_p",        3187500,        false},
        { "blink",      "clk_32k",      32768,          true},
+       { "i2s0",       "pll_a_out0",   0,              false},
        { "i2s1",       "pll_a_out0",   0,              false},
        { "i2s3",       "pll_a_out0",   0,              false},
        { "spdif_out",  "pll_a_out0",   0,              false},
@@ -313,12 +320,114 @@ static struct wm8903_platform_data cardhu_wm8903_pdata = {
        },
 };
 
-static struct i2c_board_info __initdata wm8903_board_info = {
+/* Equalizer filter coefs generated from the MAXIM MAX98095
+ * evkit software tool */
+static struct max98095_eq_cfg max98095_eq_cfg[] = {
+       {
+               .name = "FLAT",
+               .rate = 44100,
+               .band1 = {0x2000, 0xC002, 0x4000, 0x00E9, 0x0000},
+               .band2 = {0x2000, 0xC00F, 0x4000, 0x02BC, 0x0000},
+               .band3 = {0x2000, 0xC0A7, 0x4000, 0x0916, 0x0000},
+               .band4 = {0x2000, 0xC5C2, 0x4000, 0x1A87, 0x0000},
+               .band5 = {0x2000, 0xF6B0, 0x4000, 0x3F51, 0x0000},
+       },
+       {
+               .name = "LOWPASS1K",
+               .rate = 44100,
+               .band1 = {0x205D, 0xC001, 0x3FEF, 0x002E, 0x02E0},
+               .band2 = {0x5B9A, 0xC093, 0x3AB2, 0x088B, 0x1981},
+               .band3 = {0x0D22, 0xC170, 0x26EA, 0x0D79, 0x32CF},
+               .band4 = {0x0894, 0xC612, 0x01B3, 0x1B34, 0x3FFA},
+               .band5 = {0x0815, 0x3FFF, 0xCF78, 0x0000, 0x29B7},
+       },
+       { /* BASS=-12dB, TREBLE=+9dB, Fc=5KHz */
+               .name = "HIBOOST",
+               .rate = 44100,
+               .band1 = {0x0815, 0xC001, 0x3AA4, 0x0003, 0x19A2},
+               .band2 = {0x0815, 0xC103, 0x092F, 0x0B55, 0x3F56},
+               .band3 = {0x0E0A, 0xC306, 0x1E5C, 0x136E, 0x3856},
+               .band4 = {0x2459, 0xF665, 0x0CAA, 0x3F46, 0x3EBB},
+               .band5 = {0x5BBB, 0x3FFF, 0xCEB0, 0x0000, 0x28CA},
+       },
+       { /* BASS=12dB, TREBLE=+12dB */
+               .name = "LOUD12DB",
+               .rate = 44100,
+               .band1 = {0x7FC1, 0xC001, 0x3EE8, 0x0020, 0x0BC7},
+               .band2 = {0x51E9, 0xC016, 0x3C7C, 0x033F, 0x14E9},
+               .band3 = {0x1745, 0xC12C, 0x1680, 0x0C2F, 0x3BE9},
+               .band4 = {0x4536, 0xD7E2, 0x0ED4, 0x31DD, 0x3E42},
+               .band5 = {0x7FEF, 0x3FFF, 0x0BAB, 0x0000, 0x3EED},
+       },
+       {
+               .name = "FLAT",
+               .rate = 16000,
+               .band1 = {0x2000, 0xC004, 0x4000, 0x0141, 0x0000},
+               .band2 = {0x2000, 0xC033, 0x4000, 0x0505, 0x0000},
+               .band3 = {0x2000, 0xC268, 0x4000, 0x115F, 0x0000},
+               .band4 = {0x2000, 0xDA62, 0x4000, 0x33C6, 0x0000},
+               .band5 = {0x2000, 0x4000, 0x4000, 0x0000, 0x0000},
+       },
+       {
+               .name = "LOWPASS1K",
+               .rate = 16000,
+               .band1 = {0x2000, 0xC004, 0x4000, 0x0141, 0x0000},
+               .band2 = {0x5BE8, 0xC3E0, 0x3307, 0x15ED, 0x26A0},
+               .band3 = {0x0F71, 0xD15A, 0x08B3, 0x2BD0, 0x3F67},
+               .band4 = {0x0815, 0x3FFF, 0xCF78, 0x0000, 0x29B7},
+               .band5 = {0x0815, 0x3FFF, 0xCF78, 0x0000, 0x29B7},
+       },
+       { /* BASS=-12dB, TREBLE=+9dB, Fc=2KHz */
+               .name = "HIBOOST",
+               .rate = 16000,
+               .band1 = {0x0815, 0xC001, 0x3BD2, 0x0009, 0x16BF},
+               .band2 = {0x080E, 0xC17E, 0xF653, 0x0DBD, 0x3F43},
+               .band3 = {0x0F80, 0xDF45, 0xEE33, 0x36FE, 0x3D79},
+               .band4 = {0x590B, 0x3FF0, 0xE882, 0x02BD, 0x3B87},
+               .band5 = {0x4C87, 0xF3D0, 0x063F, 0x3ED4, 0x3FB1},
+       },
+       { /* BASS=12dB, TREBLE=+12dB */
+               .name = "LOUD12DB",
+               .rate = 16000,
+               .band1 = {0x7FC1, 0xC001, 0x3D07, 0x0058, 0x1344},
+               .band2 = {0x2DA6, 0xC013, 0x3CF1, 0x02FF, 0x138B},
+               .band3 = {0x18F1, 0xC08E, 0x244D, 0x0863, 0x34B5},
+               .band4 = {0x2BE0, 0xF385, 0x04FD, 0x3EC5, 0x3FCE},
+               .band5 = {0x7FEF, 0x4000, 0x0BAB, 0x0000, 0x3EED},
+       },
+};
+
+static struct max98095_pdata cardhu_max98095_pdata = {
+       /* equalizer configuration */
+       .eq_cfg = max98095_eq_cfg,
+       .eq_cfgcnt = ARRAY_SIZE(max98095_eq_cfg),
+
+       /* Biquad filter response configuration */
+       .bq_cfg = NULL,
+       .bq_cfgcnt = 0,
+
+       /* microphone configuration */
+       .digmic_left_mode = 1,
+       .digmic_right_mode = 1,
+};
+
+static struct i2c_board_info __initdata cardhu_codec_wm8903_info = {
        I2C_BOARD_INFO("wm8903", 0x1a),
+       .irq = TEGRA_GPIO_TO_IRQ(TEGRA_GPIO_CDC_IRQ),
        .platform_data = &cardhu_wm8903_pdata,
+};
+
+static struct i2c_board_info __initdata cardhu_codec_aic326x_info = {
+       I2C_BOARD_INFO("aic3262-codec", 0x18),
        .irq = TEGRA_GPIO_TO_IRQ(TEGRA_GPIO_CDC_IRQ),
 };
 
+static struct i2c_board_info __initdata cardhu_codec_max98095_info = {
+       I2C_BOARD_INFO("max98095", 0x10),
+       .irq = TEGRA_GPIO_TO_IRQ(TEGRA_GPIO_CDC_IRQ),
+       .platform_data = &cardhu_max98095_pdata,
+};
+
 static void cardhu_i2c_init(void)
 {
        tegra_i2c_device1.dev.platform_data = &cardhu_i2c1_platform_data;
@@ -333,7 +442,10 @@ static void cardhu_i2c_init(void)
        platform_device_register(&tegra_i2c_device2);
        platform_device_register(&tegra_i2c_device1);
 
-       i2c_register_board_info(4, &wm8903_board_info, 1);
+       i2c_register_board_info(4, &cardhu_codec_wm8903_info, 1);
+       i2c_register_board_info(4, &cardhu_codec_max98095_info, 1);
+       i2c_register_board_info(4, &cardhu_codec_aic326x_info, 1);
+
        i2c_register_board_info(2, cardhu_i2c_bus3_board_info, 1);
 }
 
@@ -378,7 +490,6 @@ static void __init uart_debug_init(void)
                                debug_port_id = 1;
        }
 
-       tegra_init_debug_uart_rate();
        switch (debug_port_id) {
        case 0:
                /* UARTA is the debug port. */
@@ -577,7 +688,7 @@ static struct platform_device tegra_rtc_device = {
        .num_resources = ARRAY_SIZE(tegra_rtc_resources),
 };
 
-static struct tegra_wm8903_platform_data cardhu_audio_pdata = {
+static struct tegra_wm8903_platform_data cardhu_audio_wm8903_pdata = {
        .gpio_spkr_en           = TEGRA_GPIO_SPKR_EN,
        .gpio_hp_det            = TEGRA_GPIO_HP_DET,
        .gpio_hp_mute           = -1,
@@ -585,14 +696,59 @@ static struct tegra_wm8903_platform_data cardhu_audio_pdata = {
        .gpio_ext_mic_en        = -1,
 };
 
-static struct platform_device cardhu_audio_device = {
+static struct tegra_asoc_platform_data cardhu_audio_max98095_pdata = {
+       .gpio_spkr_en           = -1,
+       .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_wm8903_device = {
        .name   = "tegra-snd-wm8903",
        .id     = 0,
        .dev    = {
-               .platform_data  = &cardhu_audio_pdata,
+               .platform_data = &cardhu_audio_wm8903_pdata,
+       },
+};
+
+static struct platform_device cardhu_audio_max98095_device = {
+       .name   = "tegra-snd-max98095",
+       .id     = 0,
+       .dev    = {
+               .platform_data = &cardhu_audio_max98095_pdata,
+       },
+};
+
+static struct tegra_asoc_platform_data cardhu_audio_aic326x_pdata = {
+       .gpio_spkr_en           = -1,
+       .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_aic326x_device = {
+       .name   = "tegra-snd-aic326x",
+       .id     = 0,
+       .dev    = {
+               .platform_data  = &cardhu_audio_aic326x_pdata,
+       },
+};
+
+static struct resource ram_console_resources[] = {
+       {
+               .flags = IORESOURCE_MEM,
        },
 };
 
+static struct platform_device ram_console_device = {
+       .name           = "ram_console",
+       .id             = -1,
+       .num_resources  = ARRAY_SIZE(ram_console_resources),
+       .resource       = ram_console_resources,
+};
+
 static struct platform_device *cardhu_devices[] __initdata = {
        &tegra_pmu_device,
        &tegra_rtc_device,
@@ -612,17 +768,22 @@ static struct platform_device *cardhu_devices[] __initdata = {
        &tegra_dam_device0,
        &tegra_dam_device1,
        &tegra_dam_device2,
+       &tegra_i2s_device0,
        &tegra_i2s_device1,
        &tegra_i2s_device3,
        &tegra_spdif_device,
        &spdif_dit_device,
        &bluetooth_dit_device,
+       &baseband_dit_device,
        &tegra_pcm_device,
-       &cardhu_audio_device,
+       &cardhu_audio_wm8903_device,
+       &cardhu_audio_max98095_device,
+       &cardhu_audio_aic326x_device,
        &tegra_hda_device,
 #if defined(CONFIG_CRYPTO_DEV_TEGRA_AES)
        &tegra_aes_device,
 #endif
+       &ram_console_device,
 };
 
 #define MXT_CONFIG_CRC  0xD62DE8
@@ -963,6 +1124,14 @@ static void cardhu_sata_init(void)
 static void cardhu_sata_init(void) { }
 #endif
 
+static void cardhu_ramconsole_init(void)
+{
+       struct resource *res;
+       res = platform_get_resource(&ram_console_device, IORESOURCE_MEM, 0);
+       res->start = ramconsole_start;
+       res->end = res->start + ramconsole_size - 1;
+}
+
 static void __init tegra_cardhu_init(void)
 {
        tegra_thermal_init(&thermal_data);
@@ -975,7 +1144,7 @@ static void __init tegra_cardhu_init(void)
        cardhu_edp_init();
 #endif
        cardhu_uart_init();
-       cardhu_tsensor_init();
+       cardhu_ramconsole_init();
        platform_add_devices(cardhu_devices, ARRAY_SIZE(cardhu_devices));
        cardhu_sdhci_init();
        cardhu_regulator_init();
@@ -1006,6 +1175,15 @@ static void __init tegra_cardhu_init(void)
 
 static void __init tegra_cardhu_reserve(void)
 {
+       long ret;
+       ramconsole_size = SZ_1M;
+       ramconsole_start = memblock_end_of_DRAM() - ramconsole_size;
+       ret = memblock_remove(ramconsole_start, ramconsole_size);
+       if (ret) {
+               ramconsole_size = 0;
+               pr_err("Failed to reserve memory block for ram console\n");
+       }
+
 #if defined(CONFIG_NVMAP_CONVERT_CARVEOUT_TO_IOVMM)
        /* support 1920X1200 with 24bpp */
        tegra_reserve(0, SZ_8M + SZ_1M, SZ_8M + SZ_1M);