19 #include <linux/pci.h>
21 #include <asm/div64.h>
23 #include <asm/swiotlb.h>
34 #if defined(CONFIG_FB_FSL_DIU) || defined(CONFIG_FB_FSL_DIU_MODULE)
36 #define PMUXCR_ELBCDIU_MASK 0xc0000000
37 #define PMUXCR_ELBCDIU_NOR16 0x80000000
38 #define PMUXCR_ELBCDIU_DIU 0x40000000
51 #define CLKDVDR_PXCKEN 0x80000000
52 #define CLKDVDR_PXCKINV 0x10000000
53 #define CLKDVDR_PXCKDLY 0x06000000
54 #define CLKDVDR_PXCLK_MASK 0x00FF0000
61 #define PX_BRDCFG0_ELBC_SPI_MASK 0xc0
62 #define PX_BRDCFG0_ELBC_SPI_ELBC 0x00
63 #define PX_BRDCFG0_ELBC_SPI_NULL 0xc0
64 #define PX_BRDCFG0_ELBC_DIU 0x02
66 #define PX_BRDCFG1_DVIEN 0x80
67 #define PX_BRDCFG1_DFPEN 0x40
68 #define PX_BRDCFG1_BACKLIGHT 0x20
69 #define PX_BRDCFG1_DDCEN 0x10
71 #define PX_CTL_ALTACC 0x80
81 #define AD_BYTE_F 0x10000000
82 #define AD_ALPHA_C_MASK 0x0E000000
83 #define AD_ALPHA_C_SHIFT 25
84 #define AD_BLUE_C_MASK 0x01800000
85 #define AD_BLUE_C_SHIFT 23
86 #define AD_GREEN_C_MASK 0x00600000
87 #define AD_GREEN_C_SHIFT 21
88 #define AD_RED_C_MASK 0x00180000
89 #define AD_RED_C_SHIFT 19
90 #define AD_PALETTE 0x00040000
91 #define AD_PIXEL_S_MASK 0x00030000
92 #define AD_PIXEL_S_SHIFT 16
93 #define AD_COMP_3_MASK 0x0000F000
94 #define AD_COMP_3_SHIFT 12
95 #define AD_COMP_2_MASK 0x00000F00
96 #define AD_COMP_2_SHIFT 8
97 #define AD_COMP_1_MASK 0x000000F0
98 #define AD_COMP_1_SHIFT 4
99 #define AD_COMP_0_MASK 0x0000000F
100 #define AD_COMP_0_SHIFT 0
102 #define MAKE_AD(alpha, red, blue, green, size, c0, c1, c2, c3) \
103 cpu_to_le32(AD_BYTE_F | (alpha << AD_ALPHA_C_SHIFT) | \
104 (blue << AD_BLUE_C_SHIFT) | (green << AD_GREEN_C_SHIFT) | \
105 (red << AD_RED_C_SHIFT) | (c3 << AD_COMP_3_SHIFT) | \
106 (c2 << AD_COMP_2_SHIFT) | (c1 << AD_COMP_1_SHIFT) | \
107 (c0 << AD_COMP_0_SHIFT) | (size << AD_PIXEL_S_SHIFT))
115 static u32 p1022ds_get_pixel_format(
enum fsl_diu_monitor_port
port,
118 switch (bits_per_pixel) {
121 return MAKE_AD(3, 2, 0, 1, 3, 8, 8, 8, 8);
124 return MAKE_AD(4, 0, 1, 2, 2, 0, 8, 8, 8);
127 return MAKE_AD(4, 2, 1, 0, 1, 5, 6, 5, 0);
129 pr_err(
"fsl-diu: unsupported pixel depth %u\n", bits_per_pixel);
140 static void p1022ds_set_gamma_table(
enum fsl_diu_monitor_port port,
141 char *gamma_table_base)
152 #define LAWBAR_MASK 0x00F00000
153 #define LAWBAR_SHIFT 12
155 #define LAWAR_EN 0x80000000
156 #define LAWAR_TGT_MASK 0x01F00000
157 #define LAW_TRGT_IF_LBC (0x04 << 20)
159 #define LAWAR_MASK (LAWAR_EN | LAWAR_TGT_MASK)
160 #define LAWAR_MATCH (LAWAR_EN | LAW_TRGT_IF_LBC)
162 #define BR_BA 0xFFFF8000
173 #ifndef CONFIG_PHYS_64BIT
180 const struct fsl_law *law = ecm + 0xc08;
183 for (i = 0; i <
count; i++) {
187 if ((lawar & LAWAR_MASK) == LAWAR_MATCH)
189 return (br & BR_BA) | ((lawbar & LAWBAR_MASK) << 12);
199 static void p1022ds_set_monitor_port(
enum fsl_diu_monitor_port port)
204 struct ccsr_guts
__iomem *guts;
210 u32 br0, or0, br1, or1;
212 unsigned int num_laws;
218 pr_err(
"p1022ds: missing global utilties device node\n");
224 pr_err(
"p1022ds: could not map global utilties device\n");
230 pr_err(
"p1022ds: missing localbus node\n");
236 pr_err(
"p1022ds: could not map localbus node\n");
242 pr_err(
"p1022ds: missing local access window node\n");
248 pr_err(
"p1022ds: could not map local access window node\n");
254 pr_err(
"p1022ds: LAW node is missing fsl,num-laws property\n");
275 if (!(br0 &
BR_V) || !(br1 & BR_V)) {
276 pr_err(
"p1022ds: CS0 and/or CS1 is not programmed\n");
286 br0 = (br0 &
BR_BA) | BR_V;
287 or0 = 0xFFFF8000 | 0xFF7;
292 br1 = (br1 &
BR_BA) | BR_V;
293 or1 = 0xFFFF8000 | 0xFF7;
298 cs0_addr = lbc_br_to_phys(ecm, num_laws, br0);
300 pr_err(
"p1022ds: could not determine physical address for CS0"
301 " (BR0=%08x)\n", br0);
304 cs1_addr = lbc_br_to_phys(ecm, num_laws, br1);
306 pr_err(
"p1022ds: could not determine physical address for CS1"
307 " (BR1=%08x)\n", br1);
311 lbc_lcs0_ba =
ioremap(cs0_addr, 1);
313 pr_err(
"p1022ds: could not ioremap CS0 address %llx\n",
314 (
unsigned long long)cs0_addr);
317 lbc_lcs1_ba =
ioremap(cs1_addr, 1);
319 pr_err(
"p1022ds: could not ioremap CS1 address %llx\n",
320 (
unsigned long long)cs1_addr);
325 if ((
in_be32(&guts->pmuxcr) & PMUXCR_ELBCDIU_MASK) !=
326 PMUXCR_ELBCDIU_DIU) {
333 pr_err(
"p1022ds: missing pixis node\n");
338 of_node_put(pixis_node);
340 pr_err(
"p1022ds: could not map pixis registers\n");
345 setbits8(pixis + PX_CTL, PX_CTL_ALTACC);
349 out_8(lbc_lcs0_ba, PX_BRDCFG0);
350 b =
in_8(lbc_lcs1_ba);
351 b |= PX_BRDCFG0_ELBC_DIU;
352 out_8(lbc_lcs1_ba, b);
355 clrsetbits_be32(&guts->pmuxcr, PMUXCR_ELBCDIU_MASK,
362 case FSL_DIU_PORT_DVI:
364 out_8(lbc_lcs0_ba, PX_BRDCFG1);
365 b =
in_8(lbc_lcs1_ba);
366 b &= ~(PX_BRDCFG1_DFPEN | PX_BRDCFG1_BACKLIGHT);
367 b |= PX_BRDCFG1_DVIEN;
368 out_8(lbc_lcs1_ba, b);
370 case FSL_DIU_PORT_LVDS:
376 out_8(lbc_lcs0_ba, PX_BRDCFG1);
377 b =
in_8(lbc_lcs1_ba);
378 b &= ~PX_BRDCFG1_DVIEN;
379 b |= PX_BRDCFG1_DFPEN | PX_BRDCFG1_BACKLIGHT;
380 out_8(lbc_lcs1_ba, b);
383 pr_err(
"p1022ds: unsupported monitor port %i\n", port);
398 of_node_put(law_node);
399 of_node_put(lbc_node);
400 of_node_put(guts_node);
408 void p1022ds_set_pixel_clock(
unsigned int pixclock)
411 struct ccsr_guts
__iomem *guts;
419 pr_err(
"p1022ds: missing global utilties device node\n");
424 of_node_put(guts_np);
426 pr_err(
"p1022ds: could not map global utilties device\n");
431 temp = 1000000000000ULL;
444 clrbits32(&guts->clkdvdr,
456 enum fsl_diu_monitor_port
457 p1022ds_valid_monitor_port(
enum fsl_diu_monitor_port port)
460 case FSL_DIU_PORT_DVI:
461 case FSL_DIU_PORT_LVDS:
464 return FSL_DIU_PORT_DVI;
473 MPIC_SINGLE_DEST_CPU,
474 0, 256,
" OpenPIC ");
479 #if defined(CONFIG_FB_FSL_DIU) || defined(CONFIG_FB_FSL_DIU_MODULE)
496 fslfb = (
strncmp(options,
"fslfb:", 6) == 0);
507 static void __init p1022_ds_setup_arch(
void)
510 ppc_md.progress(
"p1022_ds_setup_arch()", 0);
512 #if defined(CONFIG_FB_FSL_DIU) || defined(CONFIG_FB_FSL_DIU_MODULE)
513 diu_ops.get_pixel_format = p1022ds_get_pixel_format;
514 diu_ops.set_gamma_table = p1022ds_set_gamma_table;
515 diu_ops.set_monitor_port = p1022ds_set_monitor_port;
516 diu_ops.set_pixel_clock = p1022ds_set_pixel_clock;
517 diu_ops.valid_monitor_port = p1022ds_valid_monitor_port;
535 static struct property nor_status = {
538 .length =
sizeof(
"disabled"),
549 pr_info(
"p1022ds: disabling %s node",
557 "fsl,elbc-fcm-nand");
559 static struct property nand_status = {
562 .length =
sizeof(
"disabled"),
565 pr_info(
"p1022ds: disabling %s node",
580 fsl_pci_assign_primary();
584 pr_info(
"Freescale P1022 DS reference board\n");
594 static int __init p1022_ds_probe(
void)
596 unsigned long root = of_get_flat_dt_root();
598 return of_flat_dt_is_compatible(root,
"fsl,p1022ds");
603 .probe = p1022_ds_probe,
604 .setup_arch = p1022_ds_setup_arch,
607 .pcibios_fixup_bus = fsl_pcibios_fixup_bus,
610 .restart = fsl_rstcr_restart,