1 | /* |
---|
2 | * Copyright (c) 2013 embedded brains GmbH. All rights reserved. |
---|
3 | * |
---|
4 | * embedded brains GmbH |
---|
5 | * Dornierstr. 4 |
---|
6 | * 82178 Puchheim |
---|
7 | * Germany |
---|
8 | * <info@embedded-brains.de> |
---|
9 | * |
---|
10 | * The license and distribution terms for this file may be |
---|
11 | * found in the file LICENSE in this distribution or at |
---|
12 | * http://www.rtems.com/license/LICENSE. |
---|
13 | */ |
---|
14 | |
---|
15 | #include <bsp/arm-pl111-fb.h> |
---|
16 | |
---|
17 | #include <bsp.h> |
---|
18 | #include <bsp/io.h> |
---|
19 | #include <bsp/lcd.h> |
---|
20 | #include <bsp/lpc24xx.h> |
---|
21 | |
---|
22 | static const lpc24xx_pin_range tft_16_bit_5_6_5_pins[] = { |
---|
23 | LPC24XX_PIN_LCD_DCLK, |
---|
24 | LPC24XX_PIN_LCD_FP, |
---|
25 | LPC24XX_PIN_LCD_LP, |
---|
26 | LPC24XX_PIN_LCD_VD_3_P4_29, |
---|
27 | LPC24XX_PIN_LCD_VD_4_P2_6, |
---|
28 | LPC24XX_PIN_LCD_VD_5_P2_7, |
---|
29 | LPC24XX_PIN_LCD_VD_6_P2_8, |
---|
30 | LPC24XX_PIN_LCD_VD_7_P2_9, |
---|
31 | LPC24XX_PIN_LCD_VD_10_P1_20, |
---|
32 | LPC24XX_PIN_LCD_VD_11_P1_21, |
---|
33 | LPC24XX_PIN_LCD_VD_12_P1_22, |
---|
34 | LPC24XX_PIN_LCD_VD_13_P1_23, |
---|
35 | LPC24XX_PIN_LCD_VD_14_P1_24, |
---|
36 | LPC24XX_PIN_LCD_VD_15_P1_25, |
---|
37 | LPC24XX_PIN_LCD_VD_19_P2_13, |
---|
38 | LPC24XX_PIN_LCD_VD_20_P1_26, |
---|
39 | LPC24XX_PIN_LCD_VD_21_P1_27, |
---|
40 | LPC24XX_PIN_LCD_VD_22_P1_28, |
---|
41 | LPC24XX_PIN_LCD_VD_23_P1_29, |
---|
42 | LPC24XX_PIN_TERMINAL |
---|
43 | }; |
---|
44 | |
---|
45 | static void fb_set_up(const pl111_fb_config *cfg) |
---|
46 | { |
---|
47 | rtems_status_code sc; |
---|
48 | |
---|
49 | sc = lpc24xx_module_enable(LPC24XX_MODULE_LCD, LPC24XX_MODULE_PCLK_DEFAULT); |
---|
50 | if (sc != RTEMS_SUCCESSFUL) { |
---|
51 | rtems_fatal(RTEMS_FATAL_SOURCE_BSP_SPECIFIC, LPC24XX_FATAL_PL111_SET_UP); |
---|
52 | } |
---|
53 | |
---|
54 | #ifdef ARM_MULTILIB_ARCH_V4 |
---|
55 | PINSEL11 = BSP_FLD32(LCD_MODE_TFT_16_BIT_5_6_5, 1, 3) | LCD_ENABLE; |
---|
56 | #endif |
---|
57 | |
---|
58 | #ifdef ARM_MULTILIB_ARCH_V7M |
---|
59 | volatile lpc17xx_scb *scb = &LPC17XX_SCB; |
---|
60 | |
---|
61 | scb->matrixarb = 0x0c09; |
---|
62 | #endif |
---|
63 | } |
---|
64 | |
---|
65 | static void fb_pins_set_up(const pl111_fb_config *cfg) |
---|
66 | { |
---|
67 | rtems_status_code sc; |
---|
68 | |
---|
69 | sc = lpc24xx_pin_config(tft_16_bit_5_6_5_pins, LPC24XX_PIN_SET_FUNCTION); |
---|
70 | if (sc != RTEMS_SUCCESSFUL) { |
---|
71 | rtems_fatal( |
---|
72 | RTEMS_FATAL_SOURCE_BSP_SPECIFIC, |
---|
73 | LPC24XX_FATAL_PL111_PINS_SET_UP |
---|
74 | ); |
---|
75 | } |
---|
76 | } |
---|
77 | |
---|
78 | static void fb_pins_tear_down(const pl111_fb_config *cfg) |
---|
79 | { |
---|
80 | rtems_status_code sc; |
---|
81 | |
---|
82 | sc = lpc24xx_pin_config(tft_16_bit_5_6_5_pins, LPC24XX_PIN_SET_INPUT); |
---|
83 | if (sc != RTEMS_SUCCESSFUL) { |
---|
84 | rtems_fatal( |
---|
85 | RTEMS_FATAL_SOURCE_BSP_SPECIFIC, |
---|
86 | LPC24XX_FATAL_PL111_PINS_TEAR_DOWN |
---|
87 | ); |
---|
88 | } |
---|
89 | } |
---|
90 | |
---|
91 | static void fb_tear_down(const pl111_fb_config *cfg) |
---|
92 | { |
---|
93 | rtems_status_code sc; |
---|
94 | |
---|
95 | #ifdef ARM_MULTILIB_ARCH_V4 |
---|
96 | PINSEL11 = 0; |
---|
97 | #endif |
---|
98 | |
---|
99 | sc = lpc24xx_module_disable(LPC24XX_MODULE_LCD); |
---|
100 | if (sc != RTEMS_SUCCESSFUL) { |
---|
101 | rtems_fatal( |
---|
102 | RTEMS_FATAL_SOURCE_BSP_SPECIFIC, |
---|
103 | LPC24XX_FATAL_PL111_TEAR_DOWN |
---|
104 | ); |
---|
105 | } |
---|
106 | } |
---|
107 | |
---|
108 | static const pl111_fb_config fb_config = { |
---|
109 | .regs = (volatile pl111 *) LCD_BASE_ADDR, |
---|
110 | |
---|
111 | .timing0 = PL111_LCD_TIMING0_PPL(640 / 16 - 1) |
---|
112 | | PL111_LCD_TIMING0_HSW(0x1d) |
---|
113 | | PL111_LCD_TIMING0_HFP(0x0f) |
---|
114 | | PL111_LCD_TIMING0_HBP(0x71), |
---|
115 | .timing1 = PL111_LCD_TIMING1_LPP(480 - 1) |
---|
116 | | PL111_LCD_TIMING1_VSW(0x02) |
---|
117 | | PL111_LCD_TIMING1_VFP(0x0a) |
---|
118 | | PL111_LCD_TIMING1_VBP(0x20), |
---|
119 | .timing2 = PL111_LCD_TIMING2_PCD_LO(0x3) |
---|
120 | | PL111_LCD_TIMING2_ACB(0x0) |
---|
121 | | PL111_LCD_TIMING2_IVS |
---|
122 | | PL111_LCD_TIMING2_IHS |
---|
123 | | PL111_LCD_TIMING2_IPC |
---|
124 | | PL111_LCD_TIMING2_CPL(640 - 1) |
---|
125 | | PL111_LCD_TIMING2_PCD_HI(0x0), |
---|
126 | .timing3 = 0x0, |
---|
127 | .control = PL111_LCD_CONTROL_LCD_TFT |
---|
128 | | PL111_LCD_CONTROL_LCD_BPP(PL111_LCD_CONTROL_LCD_BPP_16) |
---|
129 | | PL111_LCD_CONTROL_BGR, |
---|
130 | .power_delay_in_us = 100000, |
---|
131 | |
---|
132 | .set_up = fb_set_up, |
---|
133 | .pins_set_up = fb_pins_set_up, |
---|
134 | .pins_tear_down = fb_pins_tear_down, |
---|
135 | .tear_down = fb_tear_down |
---|
136 | }; |
---|
137 | |
---|
138 | const pl111_fb_config *arm_pl111_fb_get_config(void) |
---|
139 | { |
---|
140 | return &fb_config; |
---|
141 | } |
---|