Convert the board to enable the driver model support for LCD/video.

Signed-off-by: Wenyou Yang <wenyou.y...@microchip.com>
---

 arch/arm/dts/at91-sama5d2_xplained.dts          | 60 ++++++++++++++++
 arch/arm/dts/sama5d2.dtsi                       |  7 ++
 arch/arm/mach-at91/Kconfig                      |  1 +
 board/atmel/sama5d2_xplained/sama5d2_xplained.c | 95 ++-----------------------
 configs/sama5d2_xplained_mmc_defconfig          |  2 +
 configs/sama5d2_xplained_spiflash_defconfig     |  2 +
 include/configs/sama5d2_xplained.h              | 12 ----
 7 files changed, 79 insertions(+), 100 deletions(-)

diff --git a/arch/arm/dts/at91-sama5d2_xplained.dts 
b/arch/arm/dts/at91-sama5d2_xplained.dts
index b00aaa2c79..01326a1ee0 100644
--- a/arch/arm/dts/at91-sama5d2_xplained.dts
+++ b/arch/arm/dts/at91-sama5d2_xplained.dts
@@ -41,6 +41,31 @@
                };
 
                apb {
+                       hlcdc: hlcdc@f0000000 {
+                               atmel,vl-bpix = <4>;
+                               atmel,guard-time = <1>;
+                               pinctrl-names = "default";
+                               pinctrl-0 = <&pinctrl_lcd_base &pinctrl_lcd_pwm 
&pinctrl_lcd_rgb666>;
+                               status = "okay";
+                               u-boot,dm-pre-reloc;
+
+                               display-timings {
+                                       u-boot,dm-pre-reloc;
+                                       480x272 {
+                                               clock-frequency = <9000000>;
+                                               hactive = <480>;
+                                               vactive = <272>;
+                                               hsync-len = <41>;
+                                               hfront-porch = <2>;
+                                               hback-porch = <2>;
+                                               vfront-porch = <2>;
+                                               vback-porch = <2>;
+                                               vsync-len = <11>;
+                                               u-boot,dm-pre-reloc;
+                                       };
+                               };
+                       };
+
                        qspi0: spi@f0020000 {
                                status = "okay";
 
@@ -117,6 +142,41 @@
                                                bias-disable;
                                        };
 
+                                       pinctrl_lcd_base: pinctrl_lcd_base {
+                                               pinmux = <PIN_PC30__LCDVSYNC>,
+                                                       <PIN_PC31__LCDHSYNC>,
+                                                       <PIN_PD1__LCDDEN>,
+                                                       <PIN_PD0__LCDPCK>;
+                                               bias-disable;
+                                       };
+
+                                       pinctrl_lcd_pwm: pinctrl_lcd_pwm {
+                                               pinmux = <PIN_PC28__LCDPWM>;
+                                               bias-disable;
+                                       };
+
+                                       pinctrl_lcd_rgb666: pinctrl_lcd_rgb666 {
+                                               pinmux = <PIN_PC10__LCDDAT2>,
+                                                       <PIN_PC11__LCDDAT3>,
+                                                       <PIN_PC12__LCDDAT4>,
+                                                       <PIN_PC13__LCDDAT5>,
+                                                       <PIN_PC14__LCDDAT6>,
+                                                       <PIN_PC15__LCDDAT7>,
+                                                       <PIN_PC16__LCDDAT10>,
+                                                       <PIN_PC17__LCDDAT11>,
+                                                       <PIN_PC18__LCDDAT12>,
+                                                       <PIN_PC19__LCDDAT13>,
+                                                       <PIN_PC20__LCDDAT14>,
+                                                       <PIN_PC21__LCDDAT15>,
+                                                       <PIN_PC22__LCDDAT18>,
+                                                       <PIN_PC23__LCDDAT19>,
+                                                       <PIN_PC24__LCDDAT20>,
+                                                       <PIN_PC25__LCDDAT21>,
+                                                       <PIN_PC26__LCDDAT22>,
+                                                       <PIN_PC27__LCDDAT23>;
+                                               bias-disable;
+                                       };
+
                                        pinctrl_macb0_phy_irq: macb0_phy_irq {
                                                pinmux = <PIN_PC9__GPIO>;
                                                bias-disable;
diff --git a/arch/arm/dts/sama5d2.dtsi b/arch/arm/dts/sama5d2.dtsi
index 8d89b83b53..fbaac0834c 100644
--- a/arch/arm/dts/sama5d2.dtsi
+++ b/arch/arm/dts/sama5d2.dtsi
@@ -69,6 +69,13 @@
                        #size-cells = <1>;
                        u-boot,dm-pre-reloc;
 
+                       hlcdc: hlcdc@f0000000 {
+                               compatible = "atmel,at91sam9x5-hlcdc";
+                               reg = <0xf0000000 0x2000>;
+                               clocks = <&lcdc_clk>;
+                               status = "disabled";
+                       };
+
                        pmc: pmc@f0014000 {
                                compatible = "atmel,sama5d2-pmc", "syscon";
                                reg = <0xf0014000 0x160>;
diff --git a/arch/arm/mach-at91/Kconfig b/arch/arm/mach-at91/Kconfig
index 033c1efd2b..a52599ab5b 100644
--- a/arch/arm/mach-at91/Kconfig
+++ b/arch/arm/mach-at91/Kconfig
@@ -97,6 +97,7 @@ config TARGET_SAMA5D2_XPLAINED
        select CPU_V7
        select SUPPORT_SPL
        select BOARD_EARLY_INIT_F
+       select BOARD_LATE_INIT
 
 config TARGET_SAMA5D3_XPLAINED
        bool "SAMA5D3 Xplained board"
diff --git a/board/atmel/sama5d2_xplained/sama5d2_xplained.c 
b/board/atmel/sama5d2_xplained/sama5d2_xplained.c
index fce931d95f..74ef7df079 100644
--- a/board/atmel/sama5d2_xplained/sama5d2_xplained.c
+++ b/board/atmel/sama5d2_xplained/sama5d2_xplained.c
@@ -6,10 +6,7 @@
  */
 
 #include <common.h>
-#include <atmel_hlcdc.h>
 #include <debug_uart.h>
-#include <lcd.h>
-#include <version.h>
 #include <asm/io.h>
 #include <asm/arch/at91_common.h>
 #include <asm/arch/atmel_pio4.h>
@@ -26,90 +23,15 @@ static void board_usb_hw_init(void)
        atmel_pio4_set_pio_output(AT91_PIO_PORTB, 10, 1);
 }
 
-#ifdef CONFIG_LCD
-vidinfo_t panel_info = {
-       .vl_col = 480,
-       .vl_row = 272,
-       .vl_clk = 9000000,
-       .vl_bpix = LCD_BPP,
-       .vl_tft = 1,
-       .vl_hsync_len = 41,
-       .vl_left_margin = 2,
-       .vl_right_margin = 2,
-       .vl_vsync_len = 11,
-       .vl_upper_margin = 2,
-       .vl_lower_margin = 2,
-       .mmio = ATMEL_BASE_LCDC,
-};
-
-/* No power up/down pin for the LCD pannel */
-void lcd_enable(void)  { /* Empty! */ }
-void lcd_disable(void) { /* Empty! */ }
-
-unsigned int has_lcdc(void)
+#ifdef CONFIG_BOARD_LATE_INIT
+int board_late_init(void)
 {
-       return 1;
-}
-
-static void board_lcd_hw_init(void)
-{
-       atmel_pio4_set_a_periph(AT91_PIO_PORTC, 28, 0); /* LCDPWM */
-       atmel_pio4_set_a_periph(AT91_PIO_PORTC, 29, 0); /* LCDDISP */
-       atmel_pio4_set_a_periph(AT91_PIO_PORTC, 30, 0); /* LCDVSYNC */
-       atmel_pio4_set_a_periph(AT91_PIO_PORTC, 31, 0); /* LCDHSYNC */
-       atmel_pio4_set_a_periph(AT91_PIO_PORTD,  0, 0); /* LCDPCK */
-       atmel_pio4_set_a_periph(AT91_PIO_PORTD,  1, 0); /* LCDDEN */
-
-       /* LCDDAT0 */
-       /* LCDDAT1 */
-       atmel_pio4_set_a_periph(AT91_PIO_PORTC, 10, 0); /* LCDDAT2 */
-       atmel_pio4_set_a_periph(AT91_PIO_PORTC, 11, 0); /* LCDDAT3 */
-       atmel_pio4_set_a_periph(AT91_PIO_PORTC, 12, 0); /* LCDDAT4 */
-       atmel_pio4_set_a_periph(AT91_PIO_PORTC, 13, 0); /* LCDDAT5 */
-       atmel_pio4_set_a_periph(AT91_PIO_PORTC, 14, 0); /* LCDDAT6 */
-       atmel_pio4_set_a_periph(AT91_PIO_PORTC, 15, 0); /* LCDDAT7 */
-
-       /* LCDDAT8 */
-       /* LCDDAT9 */
-       atmel_pio4_set_a_periph(AT91_PIO_PORTC, 16, 0); /* LCDDAT10 */
-       atmel_pio4_set_a_periph(AT91_PIO_PORTC, 17, 0); /* LCDDAT11 */
-       atmel_pio4_set_a_periph(AT91_PIO_PORTC, 18, 0); /* LCDDAT12 */
-       atmel_pio4_set_a_periph(AT91_PIO_PORTC, 19, 0); /* LCDDAT13 */
-       atmel_pio4_set_a_periph(AT91_PIO_PORTC, 20, 0); /* LCDDAT14 */
-       atmel_pio4_set_a_periph(AT91_PIO_PORTC, 21, 0); /* LCDDAT15 */
-
-       /* LCDD16 */
-       /* LCDD17 */
-       atmel_pio4_set_a_periph(AT91_PIO_PORTC, 22, 0); /* LCDDAT18 */
-       atmel_pio4_set_a_periph(AT91_PIO_PORTC, 23, 0); /* LCDDAT19 */
-       atmel_pio4_set_a_periph(AT91_PIO_PORTC, 24, 0); /* LCDDAT20 */
-       atmel_pio4_set_a_periph(AT91_PIO_PORTC, 25, 0); /* LCDDAT21 */
-       atmel_pio4_set_a_periph(AT91_PIO_PORTC, 26, 0); /* LCDDAT22 */
-       atmel_pio4_set_a_periph(AT91_PIO_PORTC, 27, 0); /* LCDDAT23 */
-
-       at91_periph_clk_enable(ATMEL_ID_LCDC);
-}
-
-#ifdef CONFIG_LCD_INFO
-void lcd_show_board_info(void)
-{
-       ulong dram_size;
-       int i;
-       char temp[32];
-
-       lcd_printf("%s\n", U_BOOT_VERSION);
-       lcd_printf("2015 ATMEL Corp\n");
-       lcd_printf("%s CPU at %s MHz\n", get_cpu_name(),
-                  strmhz(temp, get_cpu_clk_rate()));
-
-       dram_size = 0;
-       for (i = 0; i < CONFIG_NR_DRAM_BANKS; i++)
-               dram_size += gd->bd->bi_dram[i].size;
-
-       lcd_printf("%ld MB SDRAM\n", dram_size >> 20);
+#ifdef CONFIG_DM_VIDEO
+       at91_video_show_board_info();
+#endif
+       return 0;
 }
-#endif /* CONFIG_LCD_INFO */
-#endif /* CONFIG_LCD */
+#endif
 
 #ifdef CONFIG_DEBUG_UART_BOARD_INIT
 static void board_uart1_hw_init(void)
@@ -142,9 +64,6 @@ int board_init(void)
        /* address of boot parameters */
        gd->bd->bi_boot_params = CONFIG_SYS_SDRAM_BASE + 0x100;
 
-#ifdef CONFIG_LCD
-       board_lcd_hw_init();
-#endif
 #ifdef CONFIG_CMD_USB
        board_usb_hw_init();
 #endif
diff --git a/configs/sama5d2_xplained_mmc_defconfig 
b/configs/sama5d2_xplained_mmc_defconfig
index f1b1d0a93b..4333ea6f93 100644
--- a/configs/sama5d2_xplained_mmc_defconfig
+++ b/configs/sama5d2_xplained_mmc_defconfig
@@ -78,3 +78,5 @@ CONFIG_USB_STORAGE=y
 CONFIG_USB_GADGET=y
 CONFIG_USB_GADGET_ATMEL_USBA=y
 CONFIG_FAT_WRITE=y
+CONFIG_DM_VIDEO=y
+CONFIG_ATMEL_HLCD=y
diff --git a/configs/sama5d2_xplained_spiflash_defconfig 
b/configs/sama5d2_xplained_spiflash_defconfig
index 896e333e49..1176ef1267 100644
--- a/configs/sama5d2_xplained_spiflash_defconfig
+++ b/configs/sama5d2_xplained_spiflash_defconfig
@@ -75,3 +75,5 @@ CONFIG_USB_EHCI_HCD=y
 CONFIG_USB_STORAGE=y
 CONFIG_USB_GADGET=y
 CONFIG_USB_GADGET_ATMEL_USBA=y
+CONFIG_DM_VIDEO=y
+CONFIG_ATMEL_HLCD=y
diff --git a/include/configs/sama5d2_xplained.h 
b/include/configs/sama5d2_xplained.h
index bcddd5b0fe..fdfc1d1bc0 100644
--- a/include/configs/sama5d2_xplained.h
+++ b/include/configs/sama5d2_xplained.h
@@ -38,18 +38,6 @@
 /* NAND flash */
 #undef CONFIG_CMD_NAND
 
-/* LCD */
-
-#ifdef CONFIG_LCD
-#define LCD_BPP                                LCD_COLOR16
-#define LCD_OUTPUT_BPP                  24
-#define CONFIG_LCD_LOGO
-#define CONFIG_LCD_INFO
-#define CONFIG_LCD_INFO_BELOW_LOGO
-#define CONFIG_ATMEL_HLCD
-#define CONFIG_ATMEL_LCD_RGB565
-#endif
-
 #ifdef CONFIG_SYS_USE_MMC
 
 /* bootstrap + u-boot + env in sd card */
-- 
2.13.0

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

Reply via email to