]> www.pilppa.org Git - linux-2.6-omap-h63xx.git/blobdiff - arch/arm/mach-at91/board-sam9261ek.c
[ARM] 4910/1: [AT91] AT73C213 audio on SAM9260-EK and SAM9261-EK boards
[linux-2.6-omap-h63xx.git] / arch / arm / mach-at91 / board-sam9261ek.c
index 42e172cb0f49bfe2d0e40d9382d574234f712f3e..ce512d74e6e988cef5ed09615ac0b99478d4c221 100644 (file)
@@ -26,6 +26,8 @@
 #include <linux/platform_device.h>
 #include <linux/spi/spi.h>
 #include <linux/spi/ads7846.h>
+#include <linux/spi/at73c213.h>
+#include <linux/clk.h>
 #include <linux/dm9000.h>
 #include <linux/fb.h>
 #include <linux/gpio_keys.h>
 
 #include <asm/arch/board.h>
 #include <asm/arch/gpio.h>
-#include <asm/arch/at91sam926x_mc.h>
+#include <asm/arch/at91sam9_smc.h>
 
 #include "generic.h"
 
 
-/*
- * Serial port configuration.
- *    0 .. 2 = USART0 .. USART2
- *    3      = DBGU
- */
-static struct at91_uart_config __initdata ek_uart_config = {
-       .console_tty    = 0,                            /* ttyS0 */
-       .nr_tty         = 1,
-       .tty_map        = { 3, -1, -1, -1 }             /* ttyS0, ..., ttyS3 */
-};
-
 static void __init ek_map_io(void)
 {
        /* Initialize processor: 18.432 MHz crystal */
@@ -68,8 +59,11 @@ static void __init ek_map_io(void)
        /* Setup the LEDs */
        at91_init_leds(AT91_PIN_PA13, AT91_PIN_PA14);
 
-       /* Setup the serial ports and console */
-       at91_init_serial(&ek_uart_config);
+       /* DGBU on ttyS0. (Rx & Tx only) */
+       at91_register_uart(0, 0, 0);
+
+       /* set serial console to ttyS0 (ie, DBGU) */
+       at91_set_serial_console(0);
 }
 
 static void __init ek_init_irq(void)
@@ -238,6 +232,35 @@ static void __init ek_add_device_ts(void)
 static void __init ek_add_device_ts(void) {}
 #endif
 
+/*
+ * Audio
+ */
+static struct at73c213_board_info at73c213_data = {
+       .ssc_id         = 1,
+       .shortname      = "AT91SAM9261-EK external DAC",
+};
+
+#if defined(CONFIG_SND_AT73C213) || defined(CONFIG_SND_AT73C213_MODULE)
+static void __init at73c213_set_clk(struct at73c213_board_info *info)
+{
+       struct clk *pck2;
+       struct clk *plla;
+
+       pck2 = clk_get(NULL, "pck2");
+       plla = clk_get(NULL, "plla");
+
+       /* AT73C213 MCK Clock */
+       at91_set_B_periph(AT91_PIN_PB31, 0);    /* PCK2 */
+
+       clk_set_parent(pck2, plla);
+       clk_put(plla);
+
+       info->dac_clk = pck2;
+}
+#else
+static void __init at73c213_set_clk(struct at73c213_board_info *info) {}
+#endif
+
 /*
  * SPI devices
  */
@@ -256,6 +279,7 @@ static struct spi_board_info ek_spi_devices[] = {
                .bus_num        = 0,
                .platform_data  = &ads_info,
                .irq            = AT91SAM9261_ID_IRQ0,
+               .controller_data = (void *) AT91_PIN_PA28,      /* CS pin */
        },
 #endif
 #if defined(CONFIG_MTD_AT91_DATAFLASH_CARD)
@@ -271,6 +295,9 @@ static struct spi_board_info ek_spi_devices[] = {
                .chip_select    = 3,
                .max_speed_hz   = 10 * 1000 * 1000,
                .bus_num        = 0,
+               .mode           = SPI_MODE_1,
+               .platform_data  = &at73c213_data,
+               .controller_data = (void*) AT91_PIN_PA29,       /* default for CS3 is PA6, but it must be PA29 */
        },
 #endif
 };
@@ -280,6 +307,68 @@ static struct spi_board_info ek_spi_devices[] = {
  * LCD Controller
  */
 #if defined(CONFIG_FB_ATMEL) || defined(CONFIG_FB_ATMEL_MODULE)
+
+#if defined(CONFIG_FB_ATMEL_STN)
+
+/* STN */
+static struct fb_videomode at91_stn_modes[] = {
+        {
+               .name           = "SP06Q002 @ 75",
+               .refresh        = 75,
+               .xres           = 320,          .yres           = 240,
+               .pixclock       = KHZ2PICOS(1440),
+
+               .left_margin    = 1,            .right_margin   = 1,
+               .upper_margin   = 0,            .lower_margin   = 0,
+               .hsync_len      = 1,            .vsync_len      = 1,
+
+               .sync           = FB_SYNC_HOR_HIGH_ACT | FB_SYNC_VERT_HIGH_ACT,
+               .vmode          = FB_VMODE_NONINTERLACED,
+        },
+};
+
+static struct fb_monspecs at91fb_default_stn_monspecs = {
+        .manufacturer   = "HIT",
+        .monitor        = "SP06Q002",
+
+        .modedb         = at91_stn_modes,
+        .modedb_len     = ARRAY_SIZE(at91_stn_modes),
+        .hfmin          = 15000,
+        .hfmax          = 64000,
+        .vfmin          = 50,
+        .vfmax          = 150,
+};
+
+#define AT91SAM9261_DEFAULT_STN_LCDCON2        (ATMEL_LCDC_MEMOR_LITTLE \
+                                       | ATMEL_LCDC_DISTYPE_STNMONO \
+                                       | ATMEL_LCDC_CLKMOD_ALWAYSACTIVE \
+                                       | ATMEL_LCDC_IFWIDTH_4 \
+                                       | ATMEL_LCDC_SCANMOD_SINGLE)
+
+static void at91_lcdc_stn_power_control(int on)
+{
+       /* backlight */
+       if (on) {       /* power up */
+               at91_set_gpio_value(AT91_PIN_PC14, 0);
+               at91_set_gpio_value(AT91_PIN_PC15, 0);
+       } else {        /* power down */
+               at91_set_gpio_value(AT91_PIN_PC14, 1);
+               at91_set_gpio_value(AT91_PIN_PC15, 1);
+       }
+}
+
+static struct atmel_lcdfb_info __initdata ek_lcdc_data = {
+       .default_bpp                    = 1,
+       .default_dmacon                 = ATMEL_LCDC_DMAEN,
+       .default_lcdcon2                = AT91SAM9261_DEFAULT_STN_LCDCON2,
+       .default_monspecs               = &at91fb_default_stn_monspecs,
+       .atmel_lcdfb_power_control      = at91_lcdc_stn_power_control,
+       .guard_time                     = 1,
+};
+
+#else
+
+/* TFT */
 static struct fb_videomode at91_tft_vga_modes[] = {
        {
                .name           = "TX09D50VM1CCA @ 60",
@@ -296,7 +385,7 @@ static struct fb_videomode at91_tft_vga_modes[] = {
        },
 };
 
-static struct fb_monspecs at91fb_default_monspecs = {
+static struct fb_monspecs at91fb_default_tft_monspecs = {
        .manufacturer   = "HIT",
        .monitor        = "TX09D50VM1CCA",
 
@@ -308,11 +397,11 @@ static struct fb_monspecs at91fb_default_monspecs = {
        .vfmax          = 150,
 };
 
-#define AT91SAM9261_DEFAULT_LCDCON2    (ATMEL_LCDC_MEMOR_LITTLE \
+#define AT91SAM9261_DEFAULT_TFT_LCDCON2        (ATMEL_LCDC_MEMOR_LITTLE \
                                        | ATMEL_LCDC_DISTYPE_TFT    \
                                        | ATMEL_LCDC_CLKMOD_ALWAYSACTIVE)
 
-static void at91_lcdc_power_control(int on)
+static void at91_lcdc_tft_power_control(int on)
 {
        if (on)
                at91_set_gpio_value(AT91_PIN_PA12, 0);  /* power up */
@@ -320,15 +409,16 @@ static void at91_lcdc_power_control(int on)
                at91_set_gpio_value(AT91_PIN_PA12, 1);  /* power down */
 }
 
-/* Driver datas */
 static struct atmel_lcdfb_info __initdata ek_lcdc_data = {
+       .lcdcon_is_backlight            = true,
        .default_bpp                    = 16,
        .default_dmacon                 = ATMEL_LCDC_DMAEN,
-       .default_lcdcon2                = AT91SAM9261_DEFAULT_LCDCON2,
-       .default_monspecs               = &at91fb_default_monspecs,
-       .atmel_lcdfb_power_control      = at91_lcdc_power_control,
+       .default_lcdcon2                = AT91SAM9261_DEFAULT_TFT_LCDCON2,
+       .default_monspecs               = &at91fb_default_tft_monspecs,
+       .atmel_lcdfb_power_control      = at91_lcdc_tft_power_control,
        .guard_time                     = 1,
 };
+#endif
 
 #else
 static struct atmel_lcdfb_info __initdata ek_lcdc_data;
@@ -342,25 +432,25 @@ static struct atmel_lcdfb_info __initdata ek_lcdc_data;
 static struct gpio_keys_button ek_buttons[] = {
        {
                .gpio           = AT91_PIN_PA27,
-               .keycode        = BTN_0,
+               .code           = BTN_0,
                .desc           = "Button 0",
                .active_low     = 1,
        },
        {
                .gpio           = AT91_PIN_PA26,
-               .keycode        = BTN_1,
+               .code           = BTN_1,
                .desc           = "Button 1",
                .active_low     = 1,
        },
        {
                .gpio           = AT91_PIN_PA25,
-               .keycode        = BTN_2,
+               .code           = BTN_2,
                .desc           = "Button 2",
                .active_low     = 1,
        },
        {
                .gpio           = AT91_PIN_PA24,
-               .keycode        = BTN_3,
+               .code           = BTN_3,
                .desc           = "Button 3",
                .active_low     = 1,
        }
@@ -382,14 +472,14 @@ static struct platform_device ek_button_device = {
 
 static void __init ek_add_device_buttons(void)
 {
-       at91_set_gpio_input(AT91_PIN_PB27, 0);  /* btn0 */
-       at91_set_deglitch(AT91_PIN_PB27, 1);
-       at91_set_gpio_input(AT91_PIN_PB26, 0);  /* btn1 */
-       at91_set_deglitch(AT91_PIN_PB26, 1);
-       at91_set_gpio_input(AT91_PIN_PB25, 0);  /* btn2 */
-       at91_set_deglitch(AT91_PIN_PB25, 1);
-       at91_set_gpio_input(AT91_PIN_PB24, 0);  /* btn3 */
-       at91_set_deglitch(AT91_PIN_PB24, 1);
+       at91_set_gpio_input(AT91_PIN_PA27, 0);  /* btn0 */
+       at91_set_deglitch(AT91_PIN_PA27, 1);
+       at91_set_gpio_input(AT91_PIN_PA26, 0);  /* btn1 */
+       at91_set_deglitch(AT91_PIN_PA26, 1);
+       at91_set_gpio_input(AT91_PIN_PA25, 0);  /* btn2 */
+       at91_set_deglitch(AT91_PIN_PA25, 1);
+       at91_set_gpio_input(AT91_PIN_PA24, 0);  /* btn3 */
+       at91_set_deglitch(AT91_PIN_PA24, 1);
 
        platform_device_register(&ek_button_device);
 }
@@ -406,7 +496,7 @@ static void __init ek_board_init(void)
        /* USB Device */
        at91_add_device_udc(&ek_udc_data);
        /* I2C */
-       at91_add_device_i2c();
+       at91_add_device_i2c(NULL, 0);
        /* NAND */
        at91_add_device_nand(&ek_nand_data);
        /* DM9000 ethernet */
@@ -418,6 +508,9 @@ static void __init ek_board_init(void)
        at91_add_device_spi(ek_spi_devices, ARRAY_SIZE(ek_spi_devices));
        /* Touchscreen */
        ek_add_device_ts();
+       /* SSC (to AT73C213) */
+       at73c213_set_clk(&at73c213_data);
+       at91_add_device_ssc(AT91SAM9261_ID_SSC1, ATMEL_SSC_TX);
 #else
        /* MMC */
        at91_add_device_mmc(0, &ek_mmc_data);