2015-03-03 10:51:06 +00:00
|
|
|
|
|
|
|
#include "ddk750_help.h"
|
|
|
|
#include "ddk750_reg.h"
|
|
|
|
#include "ddk750_mode.h"
|
|
|
|
#include "ddk750_chip.h"
|
|
|
|
|
|
|
|
/*
|
|
|
|
SM750LE only:
|
|
|
|
This function takes care extra registers and bit fields required to set
|
|
|
|
up a mode in SM750LE
|
|
|
|
|
|
|
|
Explanation about Display Control register:
|
|
|
|
HW only supports 7 predefined pixel clocks, and clock select is
|
|
|
|
in bit 29:27 of Display Control register.
|
|
|
|
*/
|
|
|
|
static unsigned long displayControlAdjust_SM750LE(mode_parameter_t *pModeParam, unsigned long dispControl)
|
|
|
|
{
|
|
|
|
unsigned long x, y;
|
|
|
|
|
|
|
|
x = pModeParam->horizontal_display_end;
|
|
|
|
y = pModeParam->vertical_display_end;
|
|
|
|
|
2015-07-15 04:14:30 +00:00
|
|
|
/* SM750LE has to set up the top-left and bottom-right
|
|
|
|
registers as well.
|
|
|
|
Note that normal SM750/SM718 only use those two register for
|
|
|
|
auto-centering mode.
|
|
|
|
*/
|
2016-02-15 17:53:45 +00:00
|
|
|
POKE32(CRT_AUTO_CENTERING_TL, 0);
|
2015-07-15 04:14:30 +00:00
|
|
|
|
|
|
|
POKE32(CRT_AUTO_CENTERING_BR,
|
2015-11-25 21:56:30 +00:00
|
|
|
FIELD_VALUE(0, CRT_AUTO_CENTERING_BR, BOTTOM, y - 1)
|
|
|
|
| FIELD_VALUE(0, CRT_AUTO_CENTERING_BR, RIGHT, x - 1));
|
2015-07-15 04:14:30 +00:00
|
|
|
|
|
|
|
/* Assume common fields in dispControl have been properly set before
|
|
|
|
calling this function.
|
|
|
|
This function only sets the extra fields in dispControl.
|
|
|
|
*/
|
2015-03-03 10:51:06 +00:00
|
|
|
|
|
|
|
/* Clear bit 29:27 of display control register */
|
2016-02-10 16:34:19 +00:00
|
|
|
dispControl &= ~CRT_DISPLAY_CTRL_CLK_MASK;
|
2015-03-03 10:51:06 +00:00
|
|
|
|
|
|
|
/* Set bit 29:27 of display control register for the right clock */
|
2016-01-25 15:02:33 +00:00
|
|
|
/* Note that SM750LE only need to supported 7 resolutions. */
|
2015-07-15 04:14:32 +00:00
|
|
|
if (x == 800 && y == 600)
|
2016-02-10 16:34:19 +00:00
|
|
|
dispControl |= CRT_DISPLAY_CTRL_CLK_PLL41;
|
2015-03-03 10:51:06 +00:00
|
|
|
else if (x == 1024 && y == 768)
|
2016-02-10 16:34:19 +00:00
|
|
|
dispControl |= CRT_DISPLAY_CTRL_CLK_PLL65;
|
2015-03-03 10:51:06 +00:00
|
|
|
else if (x == 1152 && y == 864)
|
2016-02-10 16:34:19 +00:00
|
|
|
dispControl |= CRT_DISPLAY_CTRL_CLK_PLL80;
|
2015-03-03 10:51:06 +00:00
|
|
|
else if (x == 1280 && y == 768)
|
2016-02-10 16:34:19 +00:00
|
|
|
dispControl |= CRT_DISPLAY_CTRL_CLK_PLL80;
|
2015-03-03 10:51:06 +00:00
|
|
|
else if (x == 1280 && y == 720)
|
2016-02-10 16:34:19 +00:00
|
|
|
dispControl |= CRT_DISPLAY_CTRL_CLK_PLL74;
|
2015-03-03 10:51:06 +00:00
|
|
|
else if (x == 1280 && y == 960)
|
2016-02-10 16:34:19 +00:00
|
|
|
dispControl |= CRT_DISPLAY_CTRL_CLK_PLL108;
|
2015-03-03 10:51:06 +00:00
|
|
|
else if (x == 1280 && y == 1024)
|
2016-02-10 16:34:19 +00:00
|
|
|
dispControl |= CRT_DISPLAY_CTRL_CLK_PLL108;
|
2015-03-03 10:51:06 +00:00
|
|
|
else /* default to VGA clock */
|
2016-02-10 16:34:19 +00:00
|
|
|
dispControl |= CRT_DISPLAY_CTRL_CLK_PLL25;
|
2015-03-03 10:51:06 +00:00
|
|
|
|
|
|
|
/* Set bit 25:24 of display controller */
|
2016-02-10 16:34:18 +00:00
|
|
|
dispControl |= (CRT_DISPLAY_CTRL_CRTSELECT | CRT_DISPLAY_CTRL_RGBBIT);
|
2015-03-03 10:51:06 +00:00
|
|
|
|
2015-07-15 04:14:30 +00:00
|
|
|
/* Set bit 14 of display controller */
|
2016-02-10 16:34:08 +00:00
|
|
|
dispControl = DISPLAY_CTRL_CLOCK_PHASE;
|
2015-03-03 10:51:06 +00:00
|
|
|
|
2015-07-15 04:14:30 +00:00
|
|
|
POKE32(CRT_DISPLAY_CTRL, dispControl);
|
2015-03-03 10:51:06 +00:00
|
|
|
|
|
|
|
return dispControl;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* only timing related registers will be programed */
|
2015-06-18 20:06:56 +00:00
|
|
|
static int programModeRegisters(mode_parameter_t *pModeParam, pll_value_t *pll)
|
2015-03-03 10:51:06 +00:00
|
|
|
{
|
|
|
|
int ret = 0;
|
|
|
|
int cnt = 0;
|
2016-02-10 16:34:02 +00:00
|
|
|
unsigned int tmp, reg;
|
2015-07-15 04:14:48 +00:00
|
|
|
|
2015-07-15 04:14:45 +00:00
|
|
|
if (pll->clockType == SECONDARY_PLL) {
|
2015-03-03 10:51:06 +00:00
|
|
|
/* programe secondary pixel clock */
|
2015-06-02 10:14:29 +00:00
|
|
|
POKE32(CRT_PLL_CTRL, formatPllReg(pll));
|
2015-07-15 04:14:30 +00:00
|
|
|
POKE32(CRT_HORIZONTAL_TOTAL,
|
|
|
|
FIELD_VALUE(0, CRT_HORIZONTAL_TOTAL, TOTAL, pModeParam->horizontal_total - 1)
|
|
|
|
| FIELD_VALUE(0, CRT_HORIZONTAL_TOTAL, DISPLAY_END, pModeParam->horizontal_display_end - 1));
|
2015-03-03 10:51:06 +00:00
|
|
|
|
2015-07-15 04:14:30 +00:00
|
|
|
POKE32(CRT_HORIZONTAL_SYNC,
|
|
|
|
FIELD_VALUE(0, CRT_HORIZONTAL_SYNC, WIDTH, pModeParam->horizontal_sync_width)
|
|
|
|
| FIELD_VALUE(0, CRT_HORIZONTAL_SYNC, START, pModeParam->horizontal_sync_start - 1));
|
2015-03-03 10:51:06 +00:00
|
|
|
|
2015-07-15 04:14:30 +00:00
|
|
|
POKE32(CRT_VERTICAL_TOTAL,
|
|
|
|
FIELD_VALUE(0, CRT_VERTICAL_TOTAL, TOTAL, pModeParam->vertical_total - 1)
|
|
|
|
| FIELD_VALUE(0, CRT_VERTICAL_TOTAL, DISPLAY_END, pModeParam->vertical_display_end - 1));
|
2015-03-03 10:51:06 +00:00
|
|
|
|
2015-07-15 04:14:30 +00:00
|
|
|
POKE32(CRT_VERTICAL_SYNC,
|
|
|
|
FIELD_VALUE(0, CRT_VERTICAL_SYNC, HEIGHT, pModeParam->vertical_sync_height)
|
|
|
|
| FIELD_VALUE(0, CRT_VERTICAL_SYNC, START, pModeParam->vertical_sync_start - 1));
|
2015-03-03 10:51:06 +00:00
|
|
|
|
|
|
|
|
2016-02-10 16:34:08 +00:00
|
|
|
tmp = DISPLAY_CTRL_TIMING | DISPLAY_CTRL_PLANE;
|
|
|
|
if (pModeParam->vertical_sync_polarity)
|
|
|
|
tmp |= DISPLAY_CTRL_VSYNC_PHASE;
|
|
|
|
if (pModeParam->horizontal_sync_polarity)
|
|
|
|
tmp |= DISPLAY_CTRL_HSYNC_PHASE;
|
2015-03-03 10:51:06 +00:00
|
|
|
|
2015-07-15 04:14:35 +00:00
|
|
|
if (getChipType() == SM750LE) {
|
2016-02-10 16:34:02 +00:00
|
|
|
displayControlAdjust_SM750LE(pModeParam, tmp);
|
2015-07-15 04:14:36 +00:00
|
|
|
} else {
|
2016-02-10 16:34:08 +00:00
|
|
|
reg = PEEK32(CRT_DISPLAY_CTRL) &
|
|
|
|
~(DISPLAY_CTRL_VSYNC_PHASE |
|
|
|
|
DISPLAY_CTRL_HSYNC_PHASE |
|
|
|
|
DISPLAY_CTRL_TIMING | DISPLAY_CTRL_PLANE);
|
2015-03-03 10:51:06 +00:00
|
|
|
|
2016-02-10 16:34:02 +00:00
|
|
|
POKE32(CRT_DISPLAY_CTRL, tmp | reg);
|
2015-03-03 10:51:06 +00:00
|
|
|
}
|
|
|
|
|
2015-07-15 04:14:45 +00:00
|
|
|
} else if (pll->clockType == PRIMARY_PLL) {
|
2016-02-10 16:34:02 +00:00
|
|
|
unsigned int reserved;
|
2015-07-15 04:14:48 +00:00
|
|
|
|
2015-06-02 10:14:29 +00:00
|
|
|
POKE32(PANEL_PLL_CTRL, formatPllReg(pll));
|
2015-03-03 10:51:06 +00:00
|
|
|
|
2016-02-10 16:34:22 +00:00
|
|
|
reg = ((pModeParam->horizontal_total - 1) <<
|
|
|
|
PANEL_HORIZONTAL_TOTAL_TOTAL_SHIFT) &
|
|
|
|
PANEL_HORIZONTAL_TOTAL_TOTAL_MASK;
|
|
|
|
reg |= ((pModeParam->horizontal_display_end - 1) &
|
|
|
|
PANEL_HORIZONTAL_TOTAL_DISPLAY_END_MASK);
|
|
|
|
POKE32(PANEL_HORIZONTAL_TOTAL, reg);
|
2015-03-03 10:51:06 +00:00
|
|
|
|
2015-07-15 04:14:30 +00:00
|
|
|
POKE32(PANEL_HORIZONTAL_SYNC,
|
|
|
|
FIELD_VALUE(0, PANEL_HORIZONTAL_SYNC, WIDTH, pModeParam->horizontal_sync_width)
|
|
|
|
| FIELD_VALUE(0, PANEL_HORIZONTAL_SYNC, START, pModeParam->horizontal_sync_start - 1));
|
2015-03-03 10:51:06 +00:00
|
|
|
|
2015-07-15 04:14:30 +00:00
|
|
|
POKE32(PANEL_VERTICAL_TOTAL,
|
|
|
|
FIELD_VALUE(0, PANEL_VERTICAL_TOTAL, TOTAL, pModeParam->vertical_total - 1)
|
|
|
|
| FIELD_VALUE(0, PANEL_VERTICAL_TOTAL, DISPLAY_END, pModeParam->vertical_display_end - 1));
|
2015-03-03 10:51:06 +00:00
|
|
|
|
2015-07-15 04:14:30 +00:00
|
|
|
POKE32(PANEL_VERTICAL_SYNC,
|
|
|
|
FIELD_VALUE(0, PANEL_VERTICAL_SYNC, HEIGHT, pModeParam->vertical_sync_height)
|
|
|
|
| FIELD_VALUE(0, PANEL_VERTICAL_SYNC, START, pModeParam->vertical_sync_start - 1));
|
2015-03-03 10:51:06 +00:00
|
|
|
|
2016-02-10 16:34:08 +00:00
|
|
|
tmp = DISPLAY_CTRL_TIMING | DISPLAY_CTRL_PLANE;
|
|
|
|
if (pModeParam->vertical_sync_polarity)
|
|
|
|
tmp |= DISPLAY_CTRL_VSYNC_PHASE;
|
|
|
|
if (pModeParam->horizontal_sync_polarity)
|
|
|
|
tmp |= DISPLAY_CTRL_HSYNC_PHASE;
|
|
|
|
if (pModeParam->clock_phase_polarity)
|
|
|
|
tmp |= DISPLAY_CTRL_CLOCK_PHASE;
|
2015-07-15 04:14:30 +00:00
|
|
|
|
2016-02-10 16:34:05 +00:00
|
|
|
reserved = PANEL_DISPLAY_CTRL_RESERVED_MASK |
|
2016-02-10 16:34:08 +00:00
|
|
|
PANEL_DISPLAY_CTRL_VSYNC;
|
2015-03-03 10:51:06 +00:00
|
|
|
|
2016-02-10 16:34:08 +00:00
|
|
|
reg = (PEEK32(PANEL_DISPLAY_CTRL) & ~reserved) &
|
|
|
|
~(DISPLAY_CTRL_CLOCK_PHASE | DISPLAY_CTRL_VSYNC_PHASE |
|
|
|
|
DISPLAY_CTRL_HSYNC_PHASE | DISPLAY_CTRL_TIMING |
|
|
|
|
DISPLAY_CTRL_PLANE);
|
2015-03-03 10:51:06 +00:00
|
|
|
|
|
|
|
/* May a hardware bug or just my test chip (not confirmed).
|
|
|
|
* PANEL_DISPLAY_CTRL register seems requiring few writes
|
2015-04-24 13:40:42 +00:00
|
|
|
* before a value can be successfully written in.
|
2015-03-03 10:51:06 +00:00
|
|
|
* Added some masks to mask out the reserved bits.
|
|
|
|
* Note: This problem happens by design. The hardware will wait for the
|
|
|
|
* next vertical sync to turn on/off the plane.
|
|
|
|
*/
|
|
|
|
|
2016-02-10 16:34:02 +00:00
|
|
|
POKE32(PANEL_DISPLAY_CTRL, tmp | reg);
|
2015-10-22 06:38:39 +00:00
|
|
|
|
2016-02-10 16:34:02 +00:00
|
|
|
while ((PEEK32(PANEL_DISPLAY_CTRL) & ~reserved) !=
|
|
|
|
(tmp | reg)) {
|
2015-03-03 10:51:06 +00:00
|
|
|
cnt++;
|
2015-07-15 04:14:33 +00:00
|
|
|
if (cnt > 1000)
|
2015-03-03 10:51:06 +00:00
|
|
|
break;
|
2016-02-10 16:34:02 +00:00
|
|
|
POKE32(PANEL_DISPLAY_CTRL, tmp | reg);
|
2015-03-03 10:51:06 +00:00
|
|
|
}
|
2015-07-15 04:14:45 +00:00
|
|
|
} else {
|
2015-03-03 10:51:06 +00:00
|
|
|
ret = -1;
|
|
|
|
}
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2015-06-18 20:06:56 +00:00
|
|
|
int ddk750_setModeTiming(mode_parameter_t *parm, clock_type_t clock)
|
2015-03-03 10:51:06 +00:00
|
|
|
{
|
|
|
|
pll_value_t pll;
|
|
|
|
unsigned int uiActualPixelClk;
|
2015-07-15 04:14:48 +00:00
|
|
|
|
2015-03-03 10:51:06 +00:00
|
|
|
pll.inputFreq = DEFAULT_INPUT_CLOCK;
|
|
|
|
pll.clockType = clock;
|
|
|
|
|
2015-06-02 10:14:29 +00:00
|
|
|
uiActualPixelClk = calcPllValue(parm->pixel_clock, &pll);
|
2015-07-15 04:14:35 +00:00
|
|
|
if (getChipType() == SM750LE) {
|
2015-03-03 10:51:06 +00:00
|
|
|
/* set graphic mode via IO method */
|
2015-06-02 10:14:29 +00:00
|
|
|
outb_p(0x88, 0x3d4);
|
|
|
|
outb_p(0x06, 0x3d5);
|
2015-03-03 10:51:06 +00:00
|
|
|
}
|
2015-06-02 10:14:29 +00:00
|
|
|
programModeRegisters(parm, &pll);
|
2015-03-03 10:51:06 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|