18c2ecf20Sopenharmony_ci// SPDX-License-Identifier: GPL-2.0-or-later 28c2ecf20Sopenharmony_ci/* 38c2ecf20Sopenharmony_ci * Geode GX video processor device. 48c2ecf20Sopenharmony_ci * 58c2ecf20Sopenharmony_ci * Copyright (C) 2006 Arcom Control Systems Ltd. 68c2ecf20Sopenharmony_ci * 78c2ecf20Sopenharmony_ci * Portions from AMD's original 2.4 driver: 88c2ecf20Sopenharmony_ci * Copyright (C) 2004 Advanced Micro Devices, Inc. 98c2ecf20Sopenharmony_ci */ 108c2ecf20Sopenharmony_ci#include <linux/fb.h> 118c2ecf20Sopenharmony_ci#include <linux/delay.h> 128c2ecf20Sopenharmony_ci#include <asm/io.h> 138c2ecf20Sopenharmony_ci#include <asm/delay.h> 148c2ecf20Sopenharmony_ci#include <asm/msr.h> 158c2ecf20Sopenharmony_ci#include <linux/cs5535.h> 168c2ecf20Sopenharmony_ci 178c2ecf20Sopenharmony_ci#include "gxfb.h" 188c2ecf20Sopenharmony_ci 198c2ecf20Sopenharmony_ci 208c2ecf20Sopenharmony_ci/* 218c2ecf20Sopenharmony_ci * Tables of register settings for various DOTCLKs. 228c2ecf20Sopenharmony_ci */ 238c2ecf20Sopenharmony_cistruct gx_pll_entry { 248c2ecf20Sopenharmony_ci long pixclock; /* ps */ 258c2ecf20Sopenharmony_ci u32 sys_rstpll_bits; 268c2ecf20Sopenharmony_ci u32 dotpll_value; 278c2ecf20Sopenharmony_ci}; 288c2ecf20Sopenharmony_ci 298c2ecf20Sopenharmony_ci#define POSTDIV3 ((u32)MSR_GLCP_SYS_RSTPLL_DOTPOSTDIV3) 308c2ecf20Sopenharmony_ci#define PREMULT2 ((u32)MSR_GLCP_SYS_RSTPLL_DOTPREMULT2) 318c2ecf20Sopenharmony_ci#define PREDIV2 ((u32)MSR_GLCP_SYS_RSTPLL_DOTPOSTDIV3) 328c2ecf20Sopenharmony_ci 338c2ecf20Sopenharmony_cistatic const struct gx_pll_entry gx_pll_table_48MHz[] = { 348c2ecf20Sopenharmony_ci { 40123, POSTDIV3, 0x00000BF2 }, /* 24.9230 */ 358c2ecf20Sopenharmony_ci { 39721, 0, 0x00000037 }, /* 25.1750 */ 368c2ecf20Sopenharmony_ci { 35308, POSTDIV3|PREMULT2, 0x00000B1A }, /* 28.3220 */ 378c2ecf20Sopenharmony_ci { 31746, POSTDIV3, 0x000002D2 }, /* 31.5000 */ 388c2ecf20Sopenharmony_ci { 27777, POSTDIV3|PREMULT2, 0x00000FE2 }, /* 36.0000 */ 398c2ecf20Sopenharmony_ci { 26666, POSTDIV3, 0x0000057A }, /* 37.5000 */ 408c2ecf20Sopenharmony_ci { 25000, POSTDIV3, 0x0000030A }, /* 40.0000 */ 418c2ecf20Sopenharmony_ci { 22271, 0, 0x00000063 }, /* 44.9000 */ 428c2ecf20Sopenharmony_ci { 20202, 0, 0x0000054B }, /* 49.5000 */ 438c2ecf20Sopenharmony_ci { 20000, 0, 0x0000026E }, /* 50.0000 */ 448c2ecf20Sopenharmony_ci { 19860, PREMULT2, 0x00000037 }, /* 50.3500 */ 458c2ecf20Sopenharmony_ci { 18518, POSTDIV3|PREMULT2, 0x00000B0D }, /* 54.0000 */ 468c2ecf20Sopenharmony_ci { 17777, 0, 0x00000577 }, /* 56.2500 */ 478c2ecf20Sopenharmony_ci { 17733, 0, 0x000007F7 }, /* 56.3916 */ 488c2ecf20Sopenharmony_ci { 17653, 0, 0x0000057B }, /* 56.6444 */ 498c2ecf20Sopenharmony_ci { 16949, PREMULT2, 0x00000707 }, /* 59.0000 */ 508c2ecf20Sopenharmony_ci { 15873, POSTDIV3|PREMULT2, 0x00000B39 }, /* 63.0000 */ 518c2ecf20Sopenharmony_ci { 15384, POSTDIV3|PREMULT2, 0x00000B45 }, /* 65.0000 */ 528c2ecf20Sopenharmony_ci { 14814, POSTDIV3|PREMULT2, 0x00000FC1 }, /* 67.5000 */ 538c2ecf20Sopenharmony_ci { 14124, POSTDIV3, 0x00000561 }, /* 70.8000 */ 548c2ecf20Sopenharmony_ci { 13888, POSTDIV3, 0x000007E1 }, /* 72.0000 */ 558c2ecf20Sopenharmony_ci { 13426, PREMULT2, 0x00000F4A }, /* 74.4810 */ 568c2ecf20Sopenharmony_ci { 13333, 0, 0x00000052 }, /* 75.0000 */ 578c2ecf20Sopenharmony_ci { 12698, 0, 0x00000056 }, /* 78.7500 */ 588c2ecf20Sopenharmony_ci { 12500, POSTDIV3|PREMULT2, 0x00000709 }, /* 80.0000 */ 598c2ecf20Sopenharmony_ci { 11135, PREMULT2, 0x00000262 }, /* 89.8000 */ 608c2ecf20Sopenharmony_ci { 10582, 0, 0x000002D2 }, /* 94.5000 */ 618c2ecf20Sopenharmony_ci { 10101, PREMULT2, 0x00000B4A }, /* 99.0000 */ 628c2ecf20Sopenharmony_ci { 10000, PREMULT2, 0x00000036 }, /* 100.0000 */ 638c2ecf20Sopenharmony_ci { 9259, 0, 0x000007E2 }, /* 108.0000 */ 648c2ecf20Sopenharmony_ci { 8888, 0, 0x000007F6 }, /* 112.5000 */ 658c2ecf20Sopenharmony_ci { 7692, POSTDIV3|PREMULT2, 0x00000FB0 }, /* 130.0000 */ 668c2ecf20Sopenharmony_ci { 7407, POSTDIV3|PREMULT2, 0x00000B50 }, /* 135.0000 */ 678c2ecf20Sopenharmony_ci { 6349, 0, 0x00000055 }, /* 157.5000 */ 688c2ecf20Sopenharmony_ci { 6172, 0, 0x000009C1 }, /* 162.0000 */ 698c2ecf20Sopenharmony_ci { 5787, PREMULT2, 0x0000002D }, /* 172.798 */ 708c2ecf20Sopenharmony_ci { 5698, 0, 0x000002C1 }, /* 175.5000 */ 718c2ecf20Sopenharmony_ci { 5291, 0, 0x000002D1 }, /* 189.0000 */ 728c2ecf20Sopenharmony_ci { 4938, 0, 0x00000551 }, /* 202.5000 */ 738c2ecf20Sopenharmony_ci { 4357, 0, 0x0000057D }, /* 229.5000 */ 748c2ecf20Sopenharmony_ci}; 758c2ecf20Sopenharmony_ci 768c2ecf20Sopenharmony_cistatic const struct gx_pll_entry gx_pll_table_14MHz[] = { 778c2ecf20Sopenharmony_ci { 39721, 0, 0x00000037 }, /* 25.1750 */ 788c2ecf20Sopenharmony_ci { 35308, 0, 0x00000B7B }, /* 28.3220 */ 798c2ecf20Sopenharmony_ci { 31746, 0, 0x000004D3 }, /* 31.5000 */ 808c2ecf20Sopenharmony_ci { 27777, 0, 0x00000BE3 }, /* 36.0000 */ 818c2ecf20Sopenharmony_ci { 26666, 0, 0x0000074F }, /* 37.5000 */ 828c2ecf20Sopenharmony_ci { 25000, 0, 0x0000050B }, /* 40.0000 */ 838c2ecf20Sopenharmony_ci { 22271, 0, 0x00000063 }, /* 44.9000 */ 848c2ecf20Sopenharmony_ci { 20202, 0, 0x0000054B }, /* 49.5000 */ 858c2ecf20Sopenharmony_ci { 20000, 0, 0x0000026E }, /* 50.0000 */ 868c2ecf20Sopenharmony_ci { 19860, 0, 0x000007C3 }, /* 50.3500 */ 878c2ecf20Sopenharmony_ci { 18518, 0, 0x000007E3 }, /* 54.0000 */ 888c2ecf20Sopenharmony_ci { 17777, 0, 0x00000577 }, /* 56.2500 */ 898c2ecf20Sopenharmony_ci { 17733, 0, 0x000002FB }, /* 56.3916 */ 908c2ecf20Sopenharmony_ci { 17653, 0, 0x0000057B }, /* 56.6444 */ 918c2ecf20Sopenharmony_ci { 16949, 0, 0x0000058B }, /* 59.0000 */ 928c2ecf20Sopenharmony_ci { 15873, 0, 0x0000095E }, /* 63.0000 */ 938c2ecf20Sopenharmony_ci { 15384, 0, 0x0000096A }, /* 65.0000 */ 948c2ecf20Sopenharmony_ci { 14814, 0, 0x00000BC2 }, /* 67.5000 */ 958c2ecf20Sopenharmony_ci { 14124, 0, 0x0000098A }, /* 70.8000 */ 968c2ecf20Sopenharmony_ci { 13888, 0, 0x00000BE2 }, /* 72.0000 */ 978c2ecf20Sopenharmony_ci { 13333, 0, 0x00000052 }, /* 75.0000 */ 988c2ecf20Sopenharmony_ci { 12698, 0, 0x00000056 }, /* 78.7500 */ 998c2ecf20Sopenharmony_ci { 12500, 0, 0x0000050A }, /* 80.0000 */ 1008c2ecf20Sopenharmony_ci { 11135, 0, 0x0000078E }, /* 89.8000 */ 1018c2ecf20Sopenharmony_ci { 10582, 0, 0x000002D2 }, /* 94.5000 */ 1028c2ecf20Sopenharmony_ci { 10101, 0, 0x000011F6 }, /* 99.0000 */ 1038c2ecf20Sopenharmony_ci { 10000, 0, 0x0000054E }, /* 100.0000 */ 1048c2ecf20Sopenharmony_ci { 9259, 0, 0x000007E2 }, /* 108.0000 */ 1058c2ecf20Sopenharmony_ci { 8888, 0, 0x000002FA }, /* 112.5000 */ 1068c2ecf20Sopenharmony_ci { 7692, 0, 0x00000BB1 }, /* 130.0000 */ 1078c2ecf20Sopenharmony_ci { 7407, 0, 0x00000975 }, /* 135.0000 */ 1088c2ecf20Sopenharmony_ci { 6349, 0, 0x00000055 }, /* 157.5000 */ 1098c2ecf20Sopenharmony_ci { 6172, 0, 0x000009C1 }, /* 162.0000 */ 1108c2ecf20Sopenharmony_ci { 5698, 0, 0x000002C1 }, /* 175.5000 */ 1118c2ecf20Sopenharmony_ci { 5291, 0, 0x00000539 }, /* 189.0000 */ 1128c2ecf20Sopenharmony_ci { 4938, 0, 0x00000551 }, /* 202.5000 */ 1138c2ecf20Sopenharmony_ci { 4357, 0, 0x0000057D }, /* 229.5000 */ 1148c2ecf20Sopenharmony_ci}; 1158c2ecf20Sopenharmony_ci 1168c2ecf20Sopenharmony_civoid gx_set_dclk_frequency(struct fb_info *info) 1178c2ecf20Sopenharmony_ci{ 1188c2ecf20Sopenharmony_ci const struct gx_pll_entry *pll_table; 1198c2ecf20Sopenharmony_ci int pll_table_len; 1208c2ecf20Sopenharmony_ci int i, best_i; 1218c2ecf20Sopenharmony_ci long min, diff; 1228c2ecf20Sopenharmony_ci u64 dotpll, sys_rstpll; 1238c2ecf20Sopenharmony_ci int timeout = 1000; 1248c2ecf20Sopenharmony_ci 1258c2ecf20Sopenharmony_ci /* Rev. 1 Geode GXs use a 14 MHz reference clock instead of 48 MHz. */ 1268c2ecf20Sopenharmony_ci if (cpu_data(0).x86_stepping == 1) { 1278c2ecf20Sopenharmony_ci pll_table = gx_pll_table_14MHz; 1288c2ecf20Sopenharmony_ci pll_table_len = ARRAY_SIZE(gx_pll_table_14MHz); 1298c2ecf20Sopenharmony_ci } else { 1308c2ecf20Sopenharmony_ci pll_table = gx_pll_table_48MHz; 1318c2ecf20Sopenharmony_ci pll_table_len = ARRAY_SIZE(gx_pll_table_48MHz); 1328c2ecf20Sopenharmony_ci } 1338c2ecf20Sopenharmony_ci 1348c2ecf20Sopenharmony_ci /* Search the table for the closest pixclock. */ 1358c2ecf20Sopenharmony_ci best_i = 0; 1368c2ecf20Sopenharmony_ci min = abs(pll_table[0].pixclock - info->var.pixclock); 1378c2ecf20Sopenharmony_ci for (i = 1; i < pll_table_len; i++) { 1388c2ecf20Sopenharmony_ci diff = abs(pll_table[i].pixclock - info->var.pixclock); 1398c2ecf20Sopenharmony_ci if (diff < min) { 1408c2ecf20Sopenharmony_ci min = diff; 1418c2ecf20Sopenharmony_ci best_i = i; 1428c2ecf20Sopenharmony_ci } 1438c2ecf20Sopenharmony_ci } 1448c2ecf20Sopenharmony_ci 1458c2ecf20Sopenharmony_ci rdmsrl(MSR_GLCP_SYS_RSTPLL, sys_rstpll); 1468c2ecf20Sopenharmony_ci rdmsrl(MSR_GLCP_DOTPLL, dotpll); 1478c2ecf20Sopenharmony_ci 1488c2ecf20Sopenharmony_ci /* Program new M, N and P. */ 1498c2ecf20Sopenharmony_ci dotpll &= 0x00000000ffffffffull; 1508c2ecf20Sopenharmony_ci dotpll |= (u64)pll_table[best_i].dotpll_value << 32; 1518c2ecf20Sopenharmony_ci dotpll |= MSR_GLCP_DOTPLL_DOTRESET; 1528c2ecf20Sopenharmony_ci dotpll &= ~MSR_GLCP_DOTPLL_BYPASS; 1538c2ecf20Sopenharmony_ci 1548c2ecf20Sopenharmony_ci wrmsrl(MSR_GLCP_DOTPLL, dotpll); 1558c2ecf20Sopenharmony_ci 1568c2ecf20Sopenharmony_ci /* Program dividers. */ 1578c2ecf20Sopenharmony_ci sys_rstpll &= ~( MSR_GLCP_SYS_RSTPLL_DOTPREDIV2 1588c2ecf20Sopenharmony_ci | MSR_GLCP_SYS_RSTPLL_DOTPREMULT2 1598c2ecf20Sopenharmony_ci | MSR_GLCP_SYS_RSTPLL_DOTPOSTDIV3 ); 1608c2ecf20Sopenharmony_ci sys_rstpll |= pll_table[best_i].sys_rstpll_bits; 1618c2ecf20Sopenharmony_ci 1628c2ecf20Sopenharmony_ci wrmsrl(MSR_GLCP_SYS_RSTPLL, sys_rstpll); 1638c2ecf20Sopenharmony_ci 1648c2ecf20Sopenharmony_ci /* Clear reset bit to start PLL. */ 1658c2ecf20Sopenharmony_ci dotpll &= ~(MSR_GLCP_DOTPLL_DOTRESET); 1668c2ecf20Sopenharmony_ci wrmsrl(MSR_GLCP_DOTPLL, dotpll); 1678c2ecf20Sopenharmony_ci 1688c2ecf20Sopenharmony_ci /* Wait for LOCK bit. */ 1698c2ecf20Sopenharmony_ci do { 1708c2ecf20Sopenharmony_ci rdmsrl(MSR_GLCP_DOTPLL, dotpll); 1718c2ecf20Sopenharmony_ci } while (timeout-- && !(dotpll & MSR_GLCP_DOTPLL_LOCK)); 1728c2ecf20Sopenharmony_ci} 1738c2ecf20Sopenharmony_ci 1748c2ecf20Sopenharmony_cistatic void 1758c2ecf20Sopenharmony_cigx_configure_tft(struct fb_info *info) 1768c2ecf20Sopenharmony_ci{ 1778c2ecf20Sopenharmony_ci struct gxfb_par *par = info->par; 1788c2ecf20Sopenharmony_ci unsigned long val; 1798c2ecf20Sopenharmony_ci unsigned long fp; 1808c2ecf20Sopenharmony_ci 1818c2ecf20Sopenharmony_ci /* Set up the DF pad select MSR */ 1828c2ecf20Sopenharmony_ci 1838c2ecf20Sopenharmony_ci rdmsrl(MSR_GX_MSR_PADSEL, val); 1848c2ecf20Sopenharmony_ci val &= ~MSR_GX_MSR_PADSEL_MASK; 1858c2ecf20Sopenharmony_ci val |= MSR_GX_MSR_PADSEL_TFT; 1868c2ecf20Sopenharmony_ci wrmsrl(MSR_GX_MSR_PADSEL, val); 1878c2ecf20Sopenharmony_ci 1888c2ecf20Sopenharmony_ci /* Turn off the panel */ 1898c2ecf20Sopenharmony_ci 1908c2ecf20Sopenharmony_ci fp = read_fp(par, FP_PM); 1918c2ecf20Sopenharmony_ci fp &= ~FP_PM_P; 1928c2ecf20Sopenharmony_ci write_fp(par, FP_PM, fp); 1938c2ecf20Sopenharmony_ci 1948c2ecf20Sopenharmony_ci /* Set timing 1 */ 1958c2ecf20Sopenharmony_ci 1968c2ecf20Sopenharmony_ci fp = read_fp(par, FP_PT1); 1978c2ecf20Sopenharmony_ci fp &= FP_PT1_VSIZE_MASK; 1988c2ecf20Sopenharmony_ci fp |= info->var.yres << FP_PT1_VSIZE_SHIFT; 1998c2ecf20Sopenharmony_ci write_fp(par, FP_PT1, fp); 2008c2ecf20Sopenharmony_ci 2018c2ecf20Sopenharmony_ci /* Timing 2 */ 2028c2ecf20Sopenharmony_ci /* Set bits that are always on for TFT */ 2038c2ecf20Sopenharmony_ci 2048c2ecf20Sopenharmony_ci fp = 0x0F100000; 2058c2ecf20Sopenharmony_ci 2068c2ecf20Sopenharmony_ci /* Configure sync polarity */ 2078c2ecf20Sopenharmony_ci 2088c2ecf20Sopenharmony_ci if (!(info->var.sync & FB_SYNC_VERT_HIGH_ACT)) 2098c2ecf20Sopenharmony_ci fp |= FP_PT2_VSP; 2108c2ecf20Sopenharmony_ci 2118c2ecf20Sopenharmony_ci if (!(info->var.sync & FB_SYNC_HOR_HIGH_ACT)) 2128c2ecf20Sopenharmony_ci fp |= FP_PT2_HSP; 2138c2ecf20Sopenharmony_ci 2148c2ecf20Sopenharmony_ci write_fp(par, FP_PT2, fp); 2158c2ecf20Sopenharmony_ci 2168c2ecf20Sopenharmony_ci /* Set the dither control */ 2178c2ecf20Sopenharmony_ci write_fp(par, FP_DFC, FP_DFC_NFI); 2188c2ecf20Sopenharmony_ci 2198c2ecf20Sopenharmony_ci /* Enable the FP data and power (in case the BIOS didn't) */ 2208c2ecf20Sopenharmony_ci 2218c2ecf20Sopenharmony_ci fp = read_vp(par, VP_DCFG); 2228c2ecf20Sopenharmony_ci fp |= VP_DCFG_FP_PWR_EN | VP_DCFG_FP_DATA_EN; 2238c2ecf20Sopenharmony_ci write_vp(par, VP_DCFG, fp); 2248c2ecf20Sopenharmony_ci 2258c2ecf20Sopenharmony_ci /* Unblank the panel */ 2268c2ecf20Sopenharmony_ci 2278c2ecf20Sopenharmony_ci fp = read_fp(par, FP_PM); 2288c2ecf20Sopenharmony_ci fp |= FP_PM_P; 2298c2ecf20Sopenharmony_ci write_fp(par, FP_PM, fp); 2308c2ecf20Sopenharmony_ci} 2318c2ecf20Sopenharmony_ci 2328c2ecf20Sopenharmony_civoid gx_configure_display(struct fb_info *info) 2338c2ecf20Sopenharmony_ci{ 2348c2ecf20Sopenharmony_ci struct gxfb_par *par = info->par; 2358c2ecf20Sopenharmony_ci u32 dcfg, misc; 2368c2ecf20Sopenharmony_ci 2378c2ecf20Sopenharmony_ci /* Write the display configuration */ 2388c2ecf20Sopenharmony_ci dcfg = read_vp(par, VP_DCFG); 2398c2ecf20Sopenharmony_ci 2408c2ecf20Sopenharmony_ci /* Disable hsync and vsync */ 2418c2ecf20Sopenharmony_ci dcfg &= ~(VP_DCFG_VSYNC_EN | VP_DCFG_HSYNC_EN); 2428c2ecf20Sopenharmony_ci write_vp(par, VP_DCFG, dcfg); 2438c2ecf20Sopenharmony_ci 2448c2ecf20Sopenharmony_ci /* Clear bits from existing mode. */ 2458c2ecf20Sopenharmony_ci dcfg &= ~(VP_DCFG_CRT_SYNC_SKW 2468c2ecf20Sopenharmony_ci | VP_DCFG_CRT_HSYNC_POL | VP_DCFG_CRT_VSYNC_POL 2478c2ecf20Sopenharmony_ci | VP_DCFG_VSYNC_EN | VP_DCFG_HSYNC_EN); 2488c2ecf20Sopenharmony_ci 2498c2ecf20Sopenharmony_ci /* Set default sync skew. */ 2508c2ecf20Sopenharmony_ci dcfg |= VP_DCFG_CRT_SYNC_SKW_DEFAULT; 2518c2ecf20Sopenharmony_ci 2528c2ecf20Sopenharmony_ci /* Enable hsync and vsync. */ 2538c2ecf20Sopenharmony_ci dcfg |= VP_DCFG_HSYNC_EN | VP_DCFG_VSYNC_EN; 2548c2ecf20Sopenharmony_ci 2558c2ecf20Sopenharmony_ci misc = read_vp(par, VP_MISC); 2568c2ecf20Sopenharmony_ci 2578c2ecf20Sopenharmony_ci /* Disable gamma correction */ 2588c2ecf20Sopenharmony_ci misc |= VP_MISC_GAM_EN; 2598c2ecf20Sopenharmony_ci 2608c2ecf20Sopenharmony_ci if (par->enable_crt) { 2618c2ecf20Sopenharmony_ci 2628c2ecf20Sopenharmony_ci /* Power up the CRT DACs */ 2638c2ecf20Sopenharmony_ci misc &= ~(VP_MISC_APWRDN | VP_MISC_DACPWRDN); 2648c2ecf20Sopenharmony_ci write_vp(par, VP_MISC, misc); 2658c2ecf20Sopenharmony_ci 2668c2ecf20Sopenharmony_ci /* Only change the sync polarities if we are running 2678c2ecf20Sopenharmony_ci * in CRT mode. The FP polarities will be handled in 2688c2ecf20Sopenharmony_ci * gxfb_configure_tft */ 2698c2ecf20Sopenharmony_ci if (!(info->var.sync & FB_SYNC_HOR_HIGH_ACT)) 2708c2ecf20Sopenharmony_ci dcfg |= VP_DCFG_CRT_HSYNC_POL; 2718c2ecf20Sopenharmony_ci if (!(info->var.sync & FB_SYNC_VERT_HIGH_ACT)) 2728c2ecf20Sopenharmony_ci dcfg |= VP_DCFG_CRT_VSYNC_POL; 2738c2ecf20Sopenharmony_ci } else { 2748c2ecf20Sopenharmony_ci /* Power down the CRT DACs if in FP mode */ 2758c2ecf20Sopenharmony_ci misc |= (VP_MISC_APWRDN | VP_MISC_DACPWRDN); 2768c2ecf20Sopenharmony_ci write_vp(par, VP_MISC, misc); 2778c2ecf20Sopenharmony_ci } 2788c2ecf20Sopenharmony_ci 2798c2ecf20Sopenharmony_ci /* Enable the display logic */ 2808c2ecf20Sopenharmony_ci /* Set up the DACS to blank normally */ 2818c2ecf20Sopenharmony_ci 2828c2ecf20Sopenharmony_ci dcfg |= VP_DCFG_CRT_EN | VP_DCFG_DAC_BL_EN; 2838c2ecf20Sopenharmony_ci 2848c2ecf20Sopenharmony_ci /* Enable the external DAC VREF? */ 2858c2ecf20Sopenharmony_ci 2868c2ecf20Sopenharmony_ci write_vp(par, VP_DCFG, dcfg); 2878c2ecf20Sopenharmony_ci 2888c2ecf20Sopenharmony_ci /* Set up the flat panel (if it is enabled) */ 2898c2ecf20Sopenharmony_ci 2908c2ecf20Sopenharmony_ci if (par->enable_crt == 0) 2918c2ecf20Sopenharmony_ci gx_configure_tft(info); 2928c2ecf20Sopenharmony_ci} 2938c2ecf20Sopenharmony_ci 2948c2ecf20Sopenharmony_ciint gx_blank_display(struct fb_info *info, int blank_mode) 2958c2ecf20Sopenharmony_ci{ 2968c2ecf20Sopenharmony_ci struct gxfb_par *par = info->par; 2978c2ecf20Sopenharmony_ci u32 dcfg, fp_pm; 2988c2ecf20Sopenharmony_ci int blank, hsync, vsync, crt; 2998c2ecf20Sopenharmony_ci 3008c2ecf20Sopenharmony_ci /* CRT power saving modes. */ 3018c2ecf20Sopenharmony_ci switch (blank_mode) { 3028c2ecf20Sopenharmony_ci case FB_BLANK_UNBLANK: 3038c2ecf20Sopenharmony_ci blank = 0; hsync = 1; vsync = 1; crt = 1; 3048c2ecf20Sopenharmony_ci break; 3058c2ecf20Sopenharmony_ci case FB_BLANK_NORMAL: 3068c2ecf20Sopenharmony_ci blank = 1; hsync = 1; vsync = 1; crt = 1; 3078c2ecf20Sopenharmony_ci break; 3088c2ecf20Sopenharmony_ci case FB_BLANK_VSYNC_SUSPEND: 3098c2ecf20Sopenharmony_ci blank = 1; hsync = 1; vsync = 0; crt = 1; 3108c2ecf20Sopenharmony_ci break; 3118c2ecf20Sopenharmony_ci case FB_BLANK_HSYNC_SUSPEND: 3128c2ecf20Sopenharmony_ci blank = 1; hsync = 0; vsync = 1; crt = 1; 3138c2ecf20Sopenharmony_ci break; 3148c2ecf20Sopenharmony_ci case FB_BLANK_POWERDOWN: 3158c2ecf20Sopenharmony_ci blank = 1; hsync = 0; vsync = 0; crt = 0; 3168c2ecf20Sopenharmony_ci break; 3178c2ecf20Sopenharmony_ci default: 3188c2ecf20Sopenharmony_ci return -EINVAL; 3198c2ecf20Sopenharmony_ci } 3208c2ecf20Sopenharmony_ci dcfg = read_vp(par, VP_DCFG); 3218c2ecf20Sopenharmony_ci dcfg &= ~(VP_DCFG_DAC_BL_EN | VP_DCFG_HSYNC_EN | VP_DCFG_VSYNC_EN | 3228c2ecf20Sopenharmony_ci VP_DCFG_CRT_EN); 3238c2ecf20Sopenharmony_ci if (!blank) 3248c2ecf20Sopenharmony_ci dcfg |= VP_DCFG_DAC_BL_EN; 3258c2ecf20Sopenharmony_ci if (hsync) 3268c2ecf20Sopenharmony_ci dcfg |= VP_DCFG_HSYNC_EN; 3278c2ecf20Sopenharmony_ci if (vsync) 3288c2ecf20Sopenharmony_ci dcfg |= VP_DCFG_VSYNC_EN; 3298c2ecf20Sopenharmony_ci if (crt) 3308c2ecf20Sopenharmony_ci dcfg |= VP_DCFG_CRT_EN; 3318c2ecf20Sopenharmony_ci write_vp(par, VP_DCFG, dcfg); 3328c2ecf20Sopenharmony_ci 3338c2ecf20Sopenharmony_ci /* Power on/off flat panel. */ 3348c2ecf20Sopenharmony_ci 3358c2ecf20Sopenharmony_ci if (par->enable_crt == 0) { 3368c2ecf20Sopenharmony_ci fp_pm = read_fp(par, FP_PM); 3378c2ecf20Sopenharmony_ci if (blank_mode == FB_BLANK_POWERDOWN) 3388c2ecf20Sopenharmony_ci fp_pm &= ~FP_PM_P; 3398c2ecf20Sopenharmony_ci else 3408c2ecf20Sopenharmony_ci fp_pm |= FP_PM_P; 3418c2ecf20Sopenharmony_ci write_fp(par, FP_PM, fp_pm); 3428c2ecf20Sopenharmony_ci } 3438c2ecf20Sopenharmony_ci 3448c2ecf20Sopenharmony_ci return 0; 3458c2ecf20Sopenharmony_ci} 346