Add the necessary glue and enable LCD support on ATSTK1002 and
ATSTK1006.

Signed-off-by: Haavard Skinnemoen <[EMAIL PROTECTED]>
---
 board/atmel/atstk1000/atstk1000.c |   97 +++++++++++++++++++++++++++++++++++++
 include/configs/atstk1002.h       |   22 ++++++++
 include/configs/atstk1006.h       |   23 +++++++++
 3 files changed, 142 insertions(+), 0 deletions(-)

diff --git a/board/atmel/atstk1000/atstk1000.c 
b/board/atmel/atstk1000/atstk1000.c
index 31174d3..d88db5d 100644
--- a/board/atmel/atstk1000/atstk1000.c
+++ b/board/atmel/atstk1000/atstk1000.c
@@ -24,6 +24,7 @@
 #include <asm/io.h>
 #include <asm/sdram.h>
 #include <asm/arch/clk.h>
+#include <asm/arch/gpio.h>
 #include <asm/arch/hmatrix.h>
 #include <asm/arch/portmux.h>
 
@@ -72,8 +73,59 @@ static const struct sdram_config sdram_config = {
 #endif
 };
 
+#ifdef CONFIG_LCD
+#include <lcd.h>
+#include <atmel_lcdc.h>
+
+vidinfo_t panel_info = {
+       .vl_col                 = 320,
+       .vl_row                 = 240,
+       .vl_clk                 = 6891000,
+       .vl_sync                = ATMEL_LCDC_INVCLK_INVERTED
+                                       | ATMEL_LCDC_INVFRAME_INVERTED
+                                       | ATMEL_LCDC_INVLINE_INVERTED,
+       .vl_bpix                = LCD_BPP,
+       .vl_tft                 = 1,
+       .vl_hsync_len           = 16,
+       .vl_left_margin         = 17,
+       .vl_right_margin        = 33,
+       .vl_vsync_len           = 1,
+       .vl_upper_margin        = 10,
+       .vl_lower_margin        = 10,
+       .mmio                   = LCDC_BASE,
+};
+
+#ifdef CONFIG_LCD_INFO
+#include <version.h>
+
+void lcd_show_board_info(void)
+{
+       unsigned int i;
+       unsigned long dram_size = 0;
+       char mhz[32];
+
+       lcd_printf("%s\n", U_BOOT_VERSION);
+       lcd_printf("%s (C) 2008 Atmel Corporation\n", CFG_BOARD_NAME);
+       lcd_printf("%s CPU at %s MHz\n", CFG_CPU_NAME, strmhz(mhz, gd->cpu_hz));
+       for (i = 0; i < CONFIG_NR_DRAM_BANKS; i++)
+               dram_size += gd->bd->bi_dram[i].size;
+       lcd_printf("  %ld MiB SDRAM, %ld MiB Flash\n",
+                       dram_size >> 20, gd->bd->bi_flashsize >> 20);
+}
+#endif
+
+int board_postclk_init(void)
+{
+       gclk_set_rate(GCLK_LCDC_PIXCLK, GCLK_PARENT_PLL0,
+                       CONFIG_LCDC_PIXCLK_RATE);
+       return 0;
+}
+#endif
+
 int board_early_init_f(void)
 {
+       unsigned int spi_cs_mask = 0;
+
        /* Enable SDRAM in the EBI mux */
        hmatrix_slave_write(EBI, SFR, HMATRIX_BIT(EBI_SDRAM_ENABLE));
 
@@ -88,6 +140,16 @@ int board_early_init_f(void)
 #if defined(CONFIG_MMC)
        portmux_enable_mmci(0, PORTMUX_MMCI_4BIT, PORTMUX_DRIVE_LOW);
 #endif
+#if defined(CONFIG_ATMEL_SPI)
+#if defined(CONFIG_LCD)
+       spi_cs_mask |= 1 << CFG_LCD_NPCS;
+#endif
+#endif
+       if (spi_cs_mask)
+               portmux_enable_spi0(spi_cs_mask, PORTMUX_DRIVE_LOW);
+#if defined(CONFIG_LCD)
+       portmux_enable_lcdc();
+#endif
 
        return 0;
 }
@@ -133,3 +195,38 @@ int board_eth_init(bd_t *bi)
        return 0;
 }
 #endif
+
+#ifdef CONFIG_ATMEL_SPI
+#include <spi.h>
+
+int spi_cs_is_valid(unsigned int bus, unsigned int cs)
+{
+#if defined(CONFIG_LCD)
+       if (bus == 0 && cs == CFG_LCD_NPCS)
+               return 1;
+#endif
+       return 0;
+}
+
+void spi_cs_activate(struct spi_slave *slave)
+{
+       switch (slave->cs) {
+#ifdef CONFIG_LCD
+       case CFG_LCD_NPCS:
+               gpio_set_value(CFG_LCD_NPCS_PIN, 0);
+               break;
+#endif
+       }
+}
+
+void spi_cs_deactivate(struct spi_slave *slave)
+{
+       switch (slave->cs) {
+#ifdef CONFIG_LCD
+       case CFG_LCD_NPCS:
+               gpio_set_value(CFG_LCD_NPCS_PIN, 1);
+               break;
+#endif
+       }
+}
+#endif /* CONFIG_ATMEL_SPI */
diff --git a/include/configs/atstk1002.h b/include/configs/atstk1002.h
index 4509416..dc20620 100644
--- a/include/configs/atstk1002.h
+++ b/include/configs/atstk1002.h
@@ -32,6 +32,9 @@
 #define CONFIG_ATSTK1002               1
 #define CONFIG_ATSTK1000               1
 
+#define CFG_CPU_NAME                   "AT32AP7000"
+#define CFG_BOARD_NAME                 "ATSTK1002"
+
 #define CONFIG_ATSTK1000_EXT_FLASH     1
 
 /*
@@ -129,6 +132,8 @@
 #define CONFIG_BOOTP_SUBNETMASK
 #define CONFIG_BOOTP_GATEWAY
 
+/* LCD support. This will affect a few other settings */
+#define CONFIG_LCD                     1
 
 /*
  * Command line configuration.
@@ -158,6 +163,23 @@
 #define CONFIG_MMC                     1
 #define CONFIG_ATMEL_MCI               1
 
+#ifdef CONFIG_LCD
+/* Second MACB conflicts with LCD signals */
+#undef CONFIG_ATSTK1000_MACB1
+#define CONFIG_ATMEL_SPI               1
+#define CFG_LCD_NPCS                   1
+#define CFG_LCD_NPCS_PIN               GPIO_PIN_PA(4)
+#define CONFIG_ATMEL_LCD               1
+#define CONFIG_LCDC_PIXCLK_RATE                PLL0_RATE
+#define CONFIG_ATMEL_LCD_BGR555                1
+#define LCD_BPP                                LCD_COLOR8
+#define CONFIG_LCD_LOGO                        1
+#define CONFIG_LCD_INFO                        1
+#define CONFIG_LCD_INFO_BELOW_LOGO     1
+#define CFG_WHITE_ON_BLACK             1
+#define CFG_CONSOLE_IS_IN_ENV          1
+#endif
+
 #define CFG_DCACHE_LINESZ              32
 #define CFG_ICACHE_LINESZ              32
 
diff --git a/include/configs/atstk1006.h b/include/configs/atstk1006.h
index 8a6c044..b97032f 100644
--- a/include/configs/atstk1006.h
+++ b/include/configs/atstk1006.h
@@ -32,6 +32,9 @@
 #define CONFIG_ATSTK1006               1
 #define CONFIG_ATSTK1000               1
 
+#define CFG_CPU_NAME                   "AT32AP7000"
+#define CFG_BOARD_NAME                 "ATSTK1006"
+
 #define CONFIG_ATSTK1000_EXT_FLASH     1
 
 /*
@@ -130,6 +133,9 @@
 #define CONFIG_BOOTP_GATEWAY
 
 
+/* LCD support. This will affect a few other settings */
+#define CONFIG_LCD                     1
+
 /*
  * Command line configuration.
  */
@@ -158,6 +164,23 @@
 #define CONFIG_MMC                     1
 #define CONFIG_ATMEL_MCI               1
 
+#ifdef CONFIG_LCD
+/* Second MACB conflicts with LCD signals */
+#undef CONFIG_ATSTK1000_MACB1
+#define CONFIG_ATMEL_SPI               1
+#define CFG_LCD_NPCS                   1
+#define CFG_LCD_NPCS_PIN               GPIO_PIN_PA(4)
+#define CONFIG_ATMEL_LCD               1
+#define CONFIG_LCDC_PIXCLK_RATE                PLL0_RATE
+#define CONFIG_ATMEL_LCD_BGR555                1
+#define LCD_BPP                                LCD_COLOR8
+#define CONFIG_LCD_LOGO                        1
+#define CONFIG_LCD_INFO                        1
+#define CONFIG_LCD_INFO_BELOW_LOGO     1
+#define CFG_WHITE_ON_BLACK             1
+#define CFG_CONSOLE_IS_IN_ENV          1
+#endif
+
 #define CFG_DCACHE_LINESZ              32
 #define CFG_ICACHE_LINESZ              32
 
-- 
1.5.6.3

_______________________________________________
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot

Reply via email to