Commit b117b637 authored by Mike Rapoport's avatar Mike Rapoport Committed by Greg Kroah-Hartman

staging: sm750fb: refactor setDisplayControl function

The enable/disbable sequence in setDisplayControl function is duplicated
for primary and secondary display controllers. The function can be
refactored so that the common part of register access will be shared for
both controllers.
Signed-off-by: default avatarMike Rapoport <mike.rapoport@gmail.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent 9bd2c86b
...@@ -9,96 +9,55 @@ ...@@ -9,96 +9,55 @@
static void setDisplayControl(int ctrl, int disp_state) static void setDisplayControl(int ctrl, int disp_state)
{ {
/* state != 0 means turn on both timing & plane en_bit */ /* state != 0 means turn on both timing & plane en_bit */
unsigned long reg, reserved; unsigned long reg, val, reserved;
int cnt; int cnt = 0;
cnt = 0;
/* Set the primary display control */
if (!ctrl) { if (!ctrl) {
reg = PEEK32(PANEL_DISPLAY_CTRL); reg = PANEL_DISPLAY_CTRL;
/* Turn on/off the Panel display control */
if (disp_state) {
/* Timing should be enabled first before enabling the plane
* because changing at the same time does not guarantee that
* the plane will also enabled or disabled.
*/
reg = FIELD_SET(reg, DISPLAY_CTRL, TIMING, ENABLE);
POKE32(PANEL_DISPLAY_CTRL, reg);
reg = FIELD_SET(reg, DISPLAY_CTRL, PLANE, ENABLE);
/* Added some masks to mask out the reserved bits.
* Sometimes, the reserved bits are set/reset randomly when
* writing to the PRIMARY_DISPLAY_CTRL, therefore, the register
* reserved bits are needed to be masked out.
*/
reserved = PANEL_DISPLAY_CTRL_RESERVED_MASK; reserved = PANEL_DISPLAY_CTRL_RESERVED_MASK;
/* Somehow the register value on the plane is not set
* until a few delay. Need to write
* and read it a couple times
*/
do {
cnt++;
POKE32(PANEL_DISPLAY_CTRL, reg);
} while ((PEEK32(PANEL_DISPLAY_CTRL) & ~reserved) !=
(reg & ~reserved));
printk("Set Panel Plane enbit:after tried %d times\n", cnt);
} else { } else {
/* When turning off, there is no rule on the programming reg = CRT_DISPLAY_CTRL;
* sequence since whenever the clock is off, then it does not reserved = CRT_DISPLAY_CTRL_RESERVED_MASK;
* matter whether the plane is enabled or disabled.
* Note: Modifying the plane bit will take effect on the
* next vertical sync. Need to find out if it is necessary to
* wait for 1 vsync before modifying the timing enable bit.
* */
reg = FIELD_SET(reg, DISPLAY_CTRL, PLANE, DISABLE);
POKE32(PANEL_DISPLAY_CTRL, reg);
reg = FIELD_SET(reg, DISPLAY_CTRL, TIMING, DISABLE);
POKE32(PANEL_DISPLAY_CTRL, reg);
} }
} else { val = PEEK32(reg);
/* Set the secondary display control */
reg = PEEK32(CRT_DISPLAY_CTRL);
if (disp_state) { if (disp_state) {
/* Timing should be enabled first before enabling the plane because changing at the /*
same time does not guarantee that the plane will also enabled or disabled. * Timing should be enabled first before enabling the
* plane because changing at the same time does not
* guarantee that the plane will also enabled or
* disabled.
*/ */
reg = FIELD_SET(reg, DISPLAY_CTRL, TIMING, ENABLE); val = FIELD_SET(val, DISPLAY_CTRL, TIMING, ENABLE);
POKE32(CRT_DISPLAY_CTRL, reg); POKE32(reg, val);
reg = FIELD_SET(reg, DISPLAY_CTRL, PLANE, ENABLE); val = FIELD_SET(val, DISPLAY_CTRL, PLANE, ENABLE);
/* Added some masks to mask out the reserved bits. /*
* Sometimes, the reserved bits are set/reset randomly when * Somehow the register value on the plane is not set
* writing to the PRIMARY_DISPLAY_CTRL, therefore, the register * until a few delay. Need to write and read it a
* reserved bits are needed to be masked out. * couple times
*/ */
reserved = CRT_DISPLAY_CTRL_RESERVED_MASK;
do { do {
cnt++; cnt++;
POKE32(CRT_DISPLAY_CTRL, reg); POKE32(reg, val);
} while ((PEEK32(CRT_DISPLAY_CTRL) & ~reserved) != } while ((PEEK32(reg) & ~reserved) != (val & ~reserved));
(reg & ~reserved)); pr_debug("Set Plane enbit:after tried %d times\n", cnt);
printk("Set Crt Plane enbit:after tried %d times\n", cnt);
} else { } else {
/* When turning off, there is no rule on the programming /*
* sequence since whenever the clock is off, then it does not * When turning off, there is no rule on the
* matter whether the plane is enabled or disabled. * programming sequence since whenever the clock is
* Note: Modifying the plane bit will take effect on the next * off, then it does not matter whether the plane is
* vertical sync. Need to find out if it is necessary to * enabled or disabled. Note: Modifying the plane bit
* wait for 1 vsync before modifying the timing enable bit. * will take effect on the next vertical sync. Need to
* find out if it is necessary to wait for 1 vsync
* before modifying the timing enable bit.
*/ */
reg = FIELD_SET(reg, DISPLAY_CTRL, PLANE, DISABLE); val = FIELD_SET(val, DISPLAY_CTRL, PLANE, DISABLE);
POKE32(CRT_DISPLAY_CTRL, reg); POKE32(reg, val);
reg = FIELD_SET(reg, DISPLAY_CTRL, TIMING, DISABLE); val = FIELD_SET(val, DISPLAY_CTRL, TIMING, DISABLE);
POKE32(CRT_DISPLAY_CTRL, reg); POKE32(reg, val);
}
} }
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment