1 #include <linux/device.h>
3 #include <linux/regmap.h>
4 #include <linux/mfd/syscon.h>
5 #include <linux/bitops.h>
6 #include <linux/module.h>
8 #include "pl111_versatile.h"
11 static struct regmap
*versatile_syscon_map
;
14 * We detect the different syscon types from the compatible strings.
26 static const struct of_device_id versatile_clcd_of_match
[] = {
28 .compatible
= "arm,core-module-integrator",
29 .data
= (void *)INTEGRATOR_CLCD_CM
,
32 .compatible
= "arm,versatile-sysreg",
33 .data
= (void *)VERSATILE_CLCD
,
36 .compatible
= "arm,realview-eb-syscon",
37 .data
= (void *)REALVIEW_CLCD_EB
,
40 .compatible
= "arm,realview-pb1176-syscon",
41 .data
= (void *)REALVIEW_CLCD_PB1176
,
44 .compatible
= "arm,realview-pb11mp-syscon",
45 .data
= (void *)REALVIEW_CLCD_PB11MP
,
48 .compatible
= "arm,realview-pba8-syscon",
49 .data
= (void *)REALVIEW_CLCD_PBA8
,
52 .compatible
= "arm,realview-pbx-syscon",
53 .data
= (void *)REALVIEW_CLCD_PBX
,
59 * Core module CLCD control on the Integrator/CP, bits
60 * 8 thru 19 of the CM_CONTROL register controls a bunch
63 #define INTEGRATOR_HDR_CTRL_OFFSET 0x0C
64 #define INTEGRATOR_CLCD_LCDBIASEN BIT(8)
65 #define INTEGRATOR_CLCD_LCDBIASUP BIT(9)
66 #define INTEGRATOR_CLCD_LCDBIASDN BIT(10)
67 /* Bits 11,12,13 controls the LCD type */
68 #define INTEGRATOR_CLCD_LCDMUX_MASK (BIT(11)|BIT(12)|BIT(13))
69 #define INTEGRATOR_CLCD_LCDMUX_LCD24 BIT(11)
70 #define INTEGRATOR_CLCD_LCDMUX_VGA565 BIT(12)
71 #define INTEGRATOR_CLCD_LCDMUX_SHARP (BIT(11)|BIT(12))
72 #define INTEGRATOR_CLCD_LCDMUX_VGA555 BIT(13)
73 #define INTEGRATOR_CLCD_LCDMUX_VGA24 (BIT(11)|BIT(12)|BIT(13))
74 #define INTEGRATOR_CLCD_LCD0_EN BIT(14)
75 #define INTEGRATOR_CLCD_LCD1_EN BIT(15)
76 /* R/L flip on Sharp */
77 #define INTEGRATOR_CLCD_LCD_STATIC1 BIT(16)
78 /* U/D flip on Sharp */
79 #define INTEGRATOR_CLCD_LCD_STATIC2 BIT(17)
80 /* No connection on Sharp */
81 #define INTEGRATOR_CLCD_LCD_STATIC BIT(18)
82 /* 0 = 24bit VGA, 1 = 18bit VGA */
83 #define INTEGRATOR_CLCD_LCD_N24BITEN BIT(19)
85 #define INTEGRATOR_CLCD_MASK (INTEGRATOR_CLCD_LCDBIASEN | \
86 INTEGRATOR_CLCD_LCDBIASUP | \
87 INTEGRATOR_CLCD_LCDBIASDN | \
88 INTEGRATOR_CLCD_LCDMUX_MASK | \
89 INTEGRATOR_CLCD_LCD0_EN | \
90 INTEGRATOR_CLCD_LCD1_EN | \
91 INTEGRATOR_CLCD_LCD_STATIC1 | \
92 INTEGRATOR_CLCD_LCD_STATIC2 | \
93 INTEGRATOR_CLCD_LCD_STATIC | \
94 INTEGRATOR_CLCD_LCD_N24BITEN)
96 static void pl111_integrator_enable(struct drm_device
*drm
, u32 format
)
100 dev_info(drm
->dev
, "enable Integrator CLCD connectors\n");
102 /* FIXME: really needed? */
103 val
= INTEGRATOR_CLCD_LCD_STATIC1
| INTEGRATOR_CLCD_LCD_STATIC2
|
104 INTEGRATOR_CLCD_LCD0_EN
| INTEGRATOR_CLCD_LCD1_EN
;
107 case DRM_FORMAT_XBGR8888
:
108 case DRM_FORMAT_XRGB8888
:
110 case DRM_FORMAT_BGR565
:
111 case DRM_FORMAT_RGB565
:
112 /* truecolor RGB565 */
113 val
|= INTEGRATOR_CLCD_LCDMUX_VGA565
;
115 case DRM_FORMAT_XBGR1555
:
116 case DRM_FORMAT_XRGB1555
:
117 /* Pseudocolor, RGB555, BGR555 */
118 val
|= INTEGRATOR_CLCD_LCDMUX_VGA555
;
121 dev_err(drm
->dev
, "unhandled format on Integrator 0x%08x\n",
126 regmap_update_bits(versatile_syscon_map
,
127 INTEGRATOR_HDR_CTRL_OFFSET
,
128 INTEGRATOR_CLCD_MASK
,
133 * This configuration register in the Versatile and RealView
134 * family is uniformly present but appears more and more
135 * unutilized starting with the RealView series.
137 #define SYS_CLCD 0x50
138 #define SYS_CLCD_MODE_MASK (BIT(0)|BIT(1))
139 #define SYS_CLCD_MODE_888 0
140 #define SYS_CLCD_MODE_5551 BIT(0)
141 #define SYS_CLCD_MODE_565_R_LSB BIT(1)
142 #define SYS_CLCD_MODE_565_B_LSB (BIT(0)|BIT(1))
143 #define SYS_CLCD_CONNECTOR_MASK (BIT(2)|BIT(3)|BIT(4)|BIT(5))
144 #define SYS_CLCD_NLCDIOON BIT(2)
145 #define SYS_CLCD_VDDPOSSWITCH BIT(3)
146 #define SYS_CLCD_PWR3V5SWITCH BIT(4)
147 #define SYS_CLCD_VDDNEGSWITCH BIT(5)
149 static void pl111_versatile_disable(struct drm_device
*drm
)
151 dev_info(drm
->dev
, "disable Versatile CLCD connectors\n");
152 regmap_update_bits(versatile_syscon_map
,
154 SYS_CLCD_CONNECTOR_MASK
,
158 static void pl111_versatile_enable(struct drm_device
*drm
, u32 format
)
162 dev_info(drm
->dev
, "enable Versatile CLCD connectors\n");
165 case DRM_FORMAT_ABGR8888
:
166 case DRM_FORMAT_XBGR8888
:
167 case DRM_FORMAT_ARGB8888
:
168 case DRM_FORMAT_XRGB8888
:
169 val
|= SYS_CLCD_MODE_888
;
171 case DRM_FORMAT_BGR565
:
172 val
|= SYS_CLCD_MODE_565_R_LSB
;
174 case DRM_FORMAT_RGB565
:
175 val
|= SYS_CLCD_MODE_565_B_LSB
;
177 case DRM_FORMAT_ABGR1555
:
178 case DRM_FORMAT_XBGR1555
:
179 case DRM_FORMAT_ARGB1555
:
180 case DRM_FORMAT_XRGB1555
:
181 val
|= SYS_CLCD_MODE_5551
;
184 dev_err(drm
->dev
, "unhandled format on Versatile 0x%08x\n",
190 regmap_update_bits(versatile_syscon_map
,
195 /* Then enable the display */
196 regmap_update_bits(versatile_syscon_map
,
198 SYS_CLCD_CONNECTOR_MASK
,
199 SYS_CLCD_NLCDIOON
| SYS_CLCD_PWR3V5SWITCH
);
202 static void pl111_realview_clcd_disable(struct drm_device
*drm
)
204 dev_info(drm
->dev
, "disable RealView CLCD connectors\n");
205 regmap_update_bits(versatile_syscon_map
,
207 SYS_CLCD_CONNECTOR_MASK
,
211 static void pl111_realview_clcd_enable(struct drm_device
*drm
, u32 format
)
213 dev_info(drm
->dev
, "enable RealView CLCD connectors\n");
214 regmap_update_bits(versatile_syscon_map
,
216 SYS_CLCD_CONNECTOR_MASK
,
217 SYS_CLCD_NLCDIOON
| SYS_CLCD_PWR3V5SWITCH
);
220 int pl111_versatile_init(struct device
*dev
, struct pl111_drm_dev_private
*priv
)
222 const struct of_device_id
*clcd_id
;
223 enum versatile_clcd versatile_clcd_type
;
224 struct device_node
*np
;
227 np
= of_find_matching_node_and_match(NULL
, versatile_clcd_of_match
,
230 /* Non-ARM reference designs, just bail out */
233 versatile_clcd_type
= (enum versatile_clcd
)clcd_id
->data
;
235 map
= syscon_node_to_regmap(np
);
237 dev_err(dev
, "no Versatile syscon regmap\n");
241 switch (versatile_clcd_type
) {
242 case INTEGRATOR_CLCD_CM
:
243 versatile_syscon_map
= map
;
244 priv
->variant_display_enable
= pl111_integrator_enable
;
245 dev_info(dev
, "set up callbacks for Integrator PL110\n");
248 versatile_syscon_map
= map
;
249 priv
->variant_display_enable
= pl111_versatile_enable
;
250 priv
->variant_display_disable
= pl111_versatile_disable
;
251 dev_info(dev
, "set up callbacks for Versatile PL110+\n");
253 case REALVIEW_CLCD_EB
:
254 case REALVIEW_CLCD_PB1176
:
255 case REALVIEW_CLCD_PB11MP
:
256 case REALVIEW_CLCD_PBA8
:
257 case REALVIEW_CLCD_PBX
:
258 versatile_syscon_map
= map
;
259 priv
->variant_display_enable
= pl111_realview_clcd_enable
;
260 priv
->variant_display_disable
= pl111_realview_clcd_disable
;
261 dev_info(dev
, "set up callbacks for RealView PL111\n");
264 dev_info(dev
, "unknown Versatile system controller\n");
270 EXPORT_SYMBOL_GPL(pl111_versatile_init
);