summaryrefslogtreecommitdiff
path: root/drivers/staging/sm750fb
diff options
context:
space:
mode:
authorAndré Fabian Silva Delgado <emulatorman@parabola.nu>2016-01-20 14:01:31 -0300
committerAndré Fabian Silva Delgado <emulatorman@parabola.nu>2016-01-20 14:01:31 -0300
commitb4b7ff4b08e691656c9d77c758fc355833128ac0 (patch)
tree82fcb00e6b918026dc9f2d1f05ed8eee83874cc0 /drivers/staging/sm750fb
parent35acfa0fc609f2a2cd95cef4a6a9c3a5c38f1778 (diff)
Linux-libre 4.4-gnupck-4.4-gnu
Diffstat (limited to 'drivers/staging/sm750fb')
-rw-r--r--drivers/staging/sm750fb/ddk750_chip.c323
-rw-r--r--drivers/staging/sm750fb/ddk750_chip.h9
-rw-r--r--drivers/staging/sm750fb/ddk750_display.c50
-rw-r--r--drivers/staging/sm750fb/ddk750_display.h69
-rw-r--r--drivers/staging/sm750fb/ddk750_help.h13
-rw-r--r--drivers/staging/sm750fb/ddk750_hwi2c.c109
-rw-r--r--drivers/staging/sm750fb/ddk750_hwi2c.h9
-rw-r--r--drivers/staging/sm750fb/ddk750_mode.c3
-rw-r--r--drivers/staging/sm750fb/ddk750_power.c71
-rw-r--r--drivers/staging/sm750fb/ddk750_power.h17
-rw-r--r--drivers/staging/sm750fb/ddk750_reg.h244
-rw-r--r--drivers/staging/sm750fb/ddk750_sii164.c8
-rw-r--r--drivers/staging/sm750fb/ddk750_swi2c.c296
-rw-r--r--drivers/staging/sm750fb/ddk750_swi2c.h47
-rw-r--r--drivers/staging/sm750fb/sm750.c439
-rw-r--r--drivers/staging/sm750fb/sm750.h134
-rw-r--r--drivers/staging/sm750fb/sm750_accel.c51
-rw-r--r--drivers/staging/sm750fb/sm750_cursor.c74
-rw-r--r--drivers/staging/sm750fb/sm750_help.h37
-rw-r--r--drivers/staging/sm750fb/sm750_hw.c209
-rw-r--r--drivers/staging/sm750fb/sm750_hw.h101
21 files changed, 637 insertions, 1676 deletions
diff --git a/drivers/staging/sm750fb/ddk750_chip.c b/drivers/staging/sm750fb/ddk750_chip.c
index 5e6798ea9..0331d3445 100644
--- a/drivers/staging/sm750fb/ddk750_chip.c
+++ b/drivers/staging/sm750fb/ddk750_chip.c
@@ -1,15 +1,9 @@
+#include <linux/sizes.h>
+
#include "ddk750_help.h"
#include "ddk750_reg.h"
#include "ddk750_chip.h"
#include "ddk750_power.h"
-typedef struct _pllcalparam {
- unsigned char power;/* d : 0~ 6*/
- unsigned char pod;
- unsigned char od;
- unsigned char value;/* value of 2 power d (2^d) */
-}
-pllcalparam;
-
logical_chip_type_t getChipType(void)
{
@@ -33,82 +27,36 @@ logical_chip_type_t getChipType(void)
return chip;
}
-
-inline unsigned int twoToPowerOfx(unsigned long x)
-{
- unsigned long i;
- unsigned long result = 1;
-
- for (i = 1; i <= x; i++)
- result *= 2;
- return result;
-}
-
-inline unsigned int calcPLL(pll_value_t *pPLL)
-{
- return (pPLL->inputFreq * pPLL->M / pPLL->N / twoToPowerOfx(pPLL->OD) / twoToPowerOfx(pPLL->POD));
-}
-
-unsigned int getPllValue(clock_type_t clockType, pll_value_t *pPLL)
+static unsigned int get_mxclk_freq(void)
{
- unsigned int ulPllReg = 0;
-
- pPLL->inputFreq = DEFAULT_INPUT_CLOCK;
- pPLL->clockType = clockType;
-
- switch (clockType) {
- case MXCLK_PLL:
- ulPllReg = PEEK32(MXCLK_PLL_CTRL);
- break;
- case PRIMARY_PLL:
- ulPllReg = PEEK32(PANEL_PLL_CTRL);
- break;
- case SECONDARY_PLL:
- ulPllReg = PEEK32(CRT_PLL_CTRL);
- break;
- case VGA0_PLL:
- ulPllReg = PEEK32(VGA_PLL0_CTRL);
- break;
- case VGA1_PLL:
- ulPllReg = PEEK32(VGA_PLL1_CTRL);
- break;
- }
-
- pPLL->M = FIELD_GET(ulPllReg, PANEL_PLL_CTRL, M);
- pPLL->N = FIELD_GET(ulPllReg, PANEL_PLL_CTRL, N);
- pPLL->OD = FIELD_GET(ulPllReg, PANEL_PLL_CTRL, OD);
- pPLL->POD = FIELD_GET(ulPllReg, PANEL_PLL_CTRL, POD);
-
- return calcPLL(pPLL);
-}
-
+ unsigned int pll_reg;
+ unsigned int M, N, OD, POD;
-unsigned int getChipClock(void)
-{
- pll_value_t pll;
-#if 1
if (getChipType() == SM750LE)
return MHz(130);
-#endif
- return getPllValue(MXCLK_PLL, &pll);
-}
+ pll_reg = PEEK32(MXCLK_PLL_CTRL);
+ M = FIELD_GET(pll_reg, PANEL_PLL_CTRL, M);
+ N = FIELD_GET(pll_reg, PANEL_PLL_CTRL, N);
+ OD = FIELD_GET(pll_reg, PANEL_PLL_CTRL, OD);
+ POD = FIELD_GET(pll_reg, PANEL_PLL_CTRL, POD);
+ return DEFAULT_INPUT_CLOCK * M / N / (1 << OD) / (1 << POD);
+}
/*
* This function set up the main chip clock.
*
* Input: Frequency to be set.
*/
-void setChipClock(unsigned int frequency)
+static void setChipClock(unsigned int frequency)
{
pll_value_t pll;
unsigned int ulActualMxClk;
-#if 1
+
/* Cheok_0509: For SM750LE, the chip clock is fixed. Nothing to set. */
if (getChipType() == SM750LE)
return;
-#endif
if (frequency) {
/*
@@ -129,16 +77,14 @@ void setChipClock(unsigned int frequency)
}
}
-
-
-void setMemoryClock(unsigned int frequency)
+static void setMemoryClock(unsigned int frequency)
{
unsigned int ulReg, divisor;
- #if 1
+
/* Cheok_0509: For SM750LE, the memory clock is fixed. Nothing to set. */
if (getChipType() == SM750LE)
return;
-#endif
+
if (frequency) {
/* Set the frequency to the maximum frequency that the DDR Memory can take
which is 336MHz. */
@@ -146,7 +92,7 @@ void setMemoryClock(unsigned int frequency)
frequency = MHz(336);
/* Calculate the divisor */
- divisor = (unsigned int) roundedDiv(getChipClock(), frequency);
+ divisor = roundedDiv(get_mxclk_freq(), frequency);
/* Set the corresponding divisor in the register. */
ulReg = PEEK32(CURRENT_GATE);
@@ -170,7 +116,6 @@ void setMemoryClock(unsigned int frequency)
}
}
-
/*
* This function set up the master clock (MCLK).
*
@@ -179,14 +124,14 @@ void setMemoryClock(unsigned int frequency)
* NOTE:
* The maximum frequency the engine can run is 168MHz.
*/
-void setMasterClock(unsigned int frequency)
+static void setMasterClock(unsigned int frequency)
{
unsigned int ulReg, divisor;
-#if 1
+
/* Cheok_0509: For SM750LE, the memory clock is fixed. Nothing to set. */
if (getChipType() == SM750LE)
return;
-#endif
+
if (frequency) {
/* Set the frequency to the maximum frequency that the SM750 engine can
run, which is about 190 MHz. */
@@ -194,7 +139,7 @@ void setMasterClock(unsigned int frequency)
frequency = MHz(190);
/* Calculate the divisor */
- divisor = (unsigned int) roundedDiv(getChipClock(), frequency);
+ divisor = roundedDiv(get_mxclk_freq(), frequency);
/* Set the corresponding divisor in the register. */
ulReg = PEEK32(CURRENT_GATE);
@@ -218,7 +163,6 @@ void setMasterClock(unsigned int frequency)
}
}
-
unsigned int ddk750_getVMSize(void)
{
unsigned int reg;
@@ -226,7 +170,7 @@ unsigned int ddk750_getVMSize(void)
/* sm750le only use 64 mb memory*/
if (getChipType() == SM750LE)
- return MB(64);
+ return SZ_64M;
/* for 750,always use power mode0*/
reg = PEEK32(MODE0_GATE);
@@ -237,36 +181,23 @@ unsigned int ddk750_getVMSize(void)
reg = FIELD_GET(PEEK32(MISC_CTRL), MISC_CTRL, LOCALMEM_SIZE);
switch (reg) {
case MISC_CTRL_LOCALMEM_SIZE_8M:
- data = MB(8); break; /* 8 Mega byte */
+ data = SZ_8M; break; /* 8 Mega byte */
case MISC_CTRL_LOCALMEM_SIZE_16M:
- data = MB(16); break; /* 16 Mega byte */
+ data = SZ_16M; break; /* 16 Mega byte */
case MISC_CTRL_LOCALMEM_SIZE_32M:
- data = MB(32); break; /* 32 Mega byte */
+ data = SZ_32M; break; /* 32 Mega byte */
case MISC_CTRL_LOCALMEM_SIZE_64M:
- data = MB(64); break; /* 64 Mega byte */
+ data = SZ_64M; break; /* 64 Mega byte */
default:
data = 0;
break;
}
return data;
-
}
int ddk750_initHw(initchip_param_t *pInitParam)
{
-
unsigned int ulReg;
-#if 0
- /* move the code to map regiter function. */
- if (getChipType() == SM718) {
- /* turn on big endian bit*/
- ulReg = PEEK32(0x74);
- /* now consider register definition in a big endian pattern*/
- POKE32(0x74, ulReg|0x80000000);
- }
-
-#endif
-
if (pInitParam->powerMode != 0)
pInitParam->powerMode = 0;
@@ -333,37 +264,6 @@ int ddk750_initHw(initchip_param_t *pInitParam)
ulReg = FIELD_SET(ulReg, ALPHA_DISPLAY_CTRL, PLANE, DISABLE);
POKE32(ALPHA_DISPLAY_CTRL, ulReg);
-#if 0
- /* Disable LCD hardware cursor, if a former application left it on */
- ulReg = PEEK32(PANEL_HWC_ADDRESS);
- ulReg = FIELD_SET(ulReg, PANEL_HWC_ADDRESS, ENABLE, DISABLE);
- POKE32(PANEL_HWC_ADDRESS, ulReg);
-
- /* Disable CRT hardware cursor, if a former application left it on */
- ulReg = PEEK32(CRT_HWC_ADDRESS);
- ulReg = FIELD_SET(ulReg, CRT_HWC_ADDRESS, ENABLE, DISABLE);
- POKE32(CRT_HWC_ADDRESS, ulReg);
-
- /* Disable ZV Port 0, if a former application left it on */
- ulReg = PEEK32(ZV0_CAPTURE_CTRL);
- ulReg = FIELD_SET(ulReg, ZV0_CAPTURE_CTRL, CAP, DISABLE);
- POKE32(ZV0_CAPTURE_CTRL, ulReg);
-
- /* Disable ZV Port 1, if a former application left it on */
- ulReg = PEEK32(ZV1_CAPTURE_CTRL);
- ulReg = FIELD_SET(ulReg, ZV1_CAPTURE_CTRL, CAP, DISABLE);
- POKE32(ZV1_CAPTURE_CTRL, ulReg);
-
- /* Disable ZV Port Power, if a former application left it on */
- enableZVPort(0);
- /* Disable DMA Channel, if a former application left it on */
- ulReg = PEEK32(DMA_ABORT_INTERRUPT);
- ulReg = FIELD_SET(ulReg, DMA_ABORT_INTERRUPT, ABORT_1, ABORT);
- POKE32(DMA_ABORT_INTERRUPT, ulReg);
-
- /* Disable i2c */
- enableI2C(0);
-#endif
/* Disable DMA Channel, if a former application left it on */
ulReg = PEEK32(DMA_ABORT_INTERRUPT);
ulReg = FIELD_SET(ulReg, DMA_ABORT_INTERRUPT, ABORT_1, ABORT);
@@ -378,17 +278,6 @@ int ddk750_initHw(initchip_param_t *pInitParam)
return 0;
}
-#if 0
-
-unsigned int absDiff(unsigned int a, unsigned int b)
-{
- if (a > b)
- return(a - b);
- else
- return(b - a);
-}
-
-#endif
/*
monk liu @ 4/6/2011:
re-write the calculatePLL function of ddk750.
@@ -407,57 +296,29 @@ unsigned int absDiff(unsigned int a, unsigned int b)
*/
unsigned int calcPllValue(unsigned int request_orig, pll_value_t *pll)
{
- /* used for primary and secondary channel pixel clock pll */
- static pllcalparam xparm_PIXEL[] = {
- /* 2^0 = 1*/ {0, 0, 0, 1},
- /* 2^ 1 =2*/ {1, 0, 1, 2},
- /* 2^ 2 = 4*/ {2, 0, 2, 4},
- {3, 0, 3, 8},
- {4, 1, 3, 16},
- {5, 2, 3, 32},
- /* 2^6 = 64 */ {6, 3, 3, 64},
- };
-
- /* used for MXCLK (chip clock) */
- static pllcalparam xparm_MXCLK[] = {
- /* 2^0 = 1*/ {0, 0, 0, 1},
- /* 2^ 1 =2*/ {1, 0, 1, 2},
- /* 2^ 2 = 4*/ {2, 0, 2, 4},
- {3, 0, 3, 8},
- };
-
/* as sm750 register definition, N located in 2,15 and M located in 1,255 */
int N, M, X, d;
- int xcnt;
- int miniDiff;
+ int mini_diff;
unsigned int RN, quo, rem, fl_quo;
unsigned int input, request;
unsigned int tmpClock, ret;
- pllcalparam *xparm;
+ const int max_OD = 3;
+ int max_d;
-#if 1
if (getChipType() == SM750LE) {
/* SM750LE don't have prgrammable PLL and M/N values to work on.
Just return the requested clock. */
return request_orig;
}
-#endif
ret = 0;
- miniDiff = ~0;
+ mini_diff = ~0;
request = request_orig / 1000;
input = pll->inputFreq / 1000;
/* for MXCLK register , no POD provided, so need be treated differently */
-
- if (pll->clockType != MXCLK_PLL) {
- xparm = &xparm_PIXEL[0];
- xcnt = sizeof(xparm_PIXEL)/sizeof(xparm_PIXEL[0]);
- } else {
- xparm = &xparm_MXCLK[0];
- xcnt = sizeof(xparm_MXCLK)/sizeof(xparm_MXCLK[0]);
- }
-
+ if (pll->clockType == MXCLK_PLL)
+ max_d = 3;
for (N = 15; N > 1; N--) {
/* RN will not exceed maximum long if @request <= 285 MHZ (for 32bit cpu) */
@@ -466,23 +327,25 @@ unsigned int calcPllValue(unsigned int request_orig, pll_value_t *pll)
rem = RN % input;/* rem always small than 14318181 */
fl_quo = (rem * 10000 / input);
- for (d = xcnt - 1; d >= 0; d--) {
- X = xparm[d].value;
- M = quo*X;
+ for (d = max_d; d >= 0; d--) {
+ X = (1 << d);
+ M = quo * X;
M += fl_quo * X / 10000;
/* round step */
- M += (fl_quo*X % 10000) > 5000?1:0;
+ M += (fl_quo * X % 10000) > 5000 ? 1 : 0;
if (M < 256 && M > 0) {
unsigned int diff;
tmpClock = pll->inputFreq * M / N / X;
diff = absDiff(tmpClock, request_orig);
- if (diff < miniDiff) {
+ if (diff < mini_diff) {
pll->M = M;
pll->N = N;
- pll->OD = xparm[d].od;
- pll->POD = xparm[d].pod;
- miniDiff = diff;
+ pll->POD = 0;
+ if (d > max_OD)
+ pll->POD = d - max_OD;
+ pll->OD = d - pll->POD;
+ mini_diff = diff;
ret = tmpClock;
}
}
@@ -491,106 +354,6 @@ unsigned int calcPllValue(unsigned int request_orig, pll_value_t *pll)
return ret;
}
-unsigned int calcPllValue2(
-unsigned int ulRequestClk, /* Required pixel clock in Hz unit */
-pll_value_t *pPLL /* Structure to hold the value to be set in PLL */
-)
-{
- unsigned int M, N, OD, POD = 0, diff, pllClk, odPower, podPower;
- unsigned int bestDiff = 0xffffffff; /* biggest 32 bit unsigned number */
- unsigned int ret;
- /* Init PLL structure to know states */
- pPLL->M = 0;
- pPLL->N = 0;
- pPLL->OD = 0;
- pPLL->POD = 0;
-
- /* Sanity check: None at the moment */
-
- /* Convert everything in Khz range in order to avoid calculation overflow */
- pPLL->inputFreq /= 1000;
- ulRequestClk /= 1000;
-
-#ifndef VALIDATION_CHIP
- /* The maximum of post divider is 8. */
- for (POD = 0; POD <= 3; POD++)
-#endif
- {
-
-#ifndef VALIDATION_CHIP
- /* MXCLK_PLL does not have post divider. */
- if ((POD > 0) && (pPLL->clockType == MXCLK_PLL))
- break;
-#endif
-
- /* Work out 2 to the power of POD */
- podPower = twoToPowerOfx(POD);
-
- /* OD has only 2 bits [15:14] and its value must between 0 to 3 */
- for (OD = 0; OD <= 3; OD++) {
- /* Work out 2 to the power of OD */
- odPower = twoToPowerOfx(OD);
-
-#ifdef VALIDATION_CHIP
- if (odPower > 4)
- podPower = 4;
- else
- podPower = odPower;
-#endif
-
- /* N has 4 bits [11:8] and its value must between 2 and 15.
- The N == 1 will behave differently --> Result is not correct. */
- for (N = 2; N <= 15; N++) {
- /* The formula for PLL is ulRequestClk = inputFreq * M / N / (2^OD)
- In the following steps, we try to work out a best M value given the others are known.
- To avoid decimal calculation, we use 1000 as multiplier for up to 3 decimal places of accuracy.
- */
- M = ulRequestClk * N * odPower * 1000 / pPLL->inputFreq;
- M = roundedDiv(M, 1000);
-
- /* M field has only 8 bits, reject value bigger than 8 bits */
- if (M < 256) {
- /* Calculate the actual clock for a given M & N */
- pllClk = pPLL->inputFreq * M / N / odPower / podPower;
-
- /* How much are we different from the requirement */
- diff = absDiff(pllClk, ulRequestClk);
-
- if (diff < bestDiff) {
- bestDiff = diff;
-
- /* Store M and N values */
- pPLL->M = M;
- pPLL->N = N;
- pPLL->OD = OD;
-
-#ifdef VALIDATION_CHIP
- if (OD > 2)
- POD = 2;
- else
- POD = OD;
-#endif
-
- pPLL->POD = POD;
- }
- }
- }
- }
- }
-
- /* Restore input frequency from Khz to hz unit */
- ulRequestClk *= 1000;
- pPLL->inputFreq = DEFAULT_INPUT_CLOCK; /* Default reference clock */
-
- /* Return actual frequency that the PLL can set */
- ret = calcPLL(pPLL);
- return ret;
-}
-
-
-
-
-
unsigned int formatPllReg(pll_value_t *pPLL)
{
unsigned int ulPllReg = 0;
diff --git a/drivers/staging/sm750fb/ddk750_chip.h b/drivers/staging/sm750fb/ddk750_chip.h
index 6ff043608..0891384ef 100644
--- a/drivers/staging/sm750fb/ddk750_chip.h
+++ b/drivers/staging/sm750fb/ddk750_chip.h
@@ -16,7 +16,6 @@ typedef enum _logical_chip_type_t {
}
logical_chip_type_t;
-
typedef enum _clock_type_t {
MXCLK_PLL,
PRIMARY_PLL,
@@ -70,19 +69,11 @@ typedef struct _initchip_param_t {
}
initchip_param_t;
-
logical_chip_type_t getChipType(void);
unsigned int calcPllValue(unsigned int request, pll_value_t *pll);
-unsigned int calcPllValue2(unsigned int, pll_value_t *);
unsigned int formatPllReg(pll_value_t *pPLL);
void ddk750_set_mmio(void __iomem *, unsigned short, char);
unsigned int ddk750_getVMSize(void);
int ddk750_initHw(initchip_param_t *);
-unsigned int getPllValue(clock_type_t clockType, pll_value_t *pPLL);
-unsigned int getChipClock(void);
-void setChipClock(unsigned int);
-void setMemoryClock(unsigned int frequency);
-void setMasterClock(unsigned int frequency);
-
#endif
diff --git a/drivers/staging/sm750fb/ddk750_display.c b/drivers/staging/sm750fb/ddk750_display.c
index 834811348..84f6e8b8c 100644
--- a/drivers/staging/sm750fb/ddk750_display.c
+++ b/drivers/staging/sm750fb/ddk750_display.c
@@ -6,7 +6,7 @@
#define primaryWaitVerticalSync(delay) waitNextVerticalSync(0, delay)
-static void setDisplayControl(int ctrl, int dispState)
+static void setDisplayControl(int ctrl, int disp_state)
{
/* state != 0 means turn on both timing & plane en_bit */
unsigned long ulDisplayCtrlReg, ulReservedBits;
@@ -18,7 +18,7 @@ static void setDisplayControl(int ctrl, int dispState)
if (!ctrl) {
ulDisplayCtrlReg = PEEK32(PANEL_DISPLAY_CTRL);
/* Turn on/off the Panel display control */
- if (dispState) {
+ 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.
@@ -70,7 +70,7 @@ static void setDisplayControl(int ctrl, int dispState)
/* Set the secondary display control */
ulDisplayCtrlReg = PEEK32(CRT_DISPLAY_CTRL);
- if (dispState) {
+ 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.
*/
@@ -117,7 +117,6 @@ static void setDisplayControl(int ctrl, int dispState)
}
}
-
static void waitNextVerticalSync(int ctrl, int delay)
{
unsigned int status;
@@ -189,7 +188,6 @@ static void swPanelPowerSequence(int disp, int delay)
POKE32(PANEL_DISPLAY_CTRL, reg);
primaryWaitVerticalSync(delay);
-
reg = PEEK32(PANEL_DISPLAY_CTRL);
reg = FIELD_VALUE(reg, PANEL_DISPLAY_CTRL, DATA, disp);
POKE32(PANEL_DISPLAY_CTRL, reg);
@@ -200,7 +198,6 @@ static void swPanelPowerSequence(int disp, int delay)
POKE32(PANEL_DISPLAY_CTRL, reg);
primaryWaitVerticalSync(delay);
-
reg = PEEK32(PANEL_DISPLAY_CTRL);
reg = FIELD_VALUE(reg, PANEL_DISPLAY_CTRL, FPEN, disp);
POKE32(PANEL_DISPLAY_CTRL, reg);
@@ -231,55 +228,22 @@ void ddk750_setLogicalDispOut(disp_output_t output)
if (output & PRI_TP_USAGE) {
/* set primary timing and plane en_bit */
- setDisplayControl(0, (output&PRI_TP_MASK)>>PRI_TP_OFFSET);
+ setDisplayControl(0, (output & PRI_TP_MASK) >> PRI_TP_OFFSET);
}
if (output & SEC_TP_USAGE) {
/* set secondary timing and plane en_bit*/
- setDisplayControl(1, (output&SEC_TP_MASK)>>SEC_TP_OFFSET);
+ setDisplayControl(1, (output & SEC_TP_MASK) >> SEC_TP_OFFSET);
}
if (output & PNL_SEQ_USAGE) {
/* set panel sequence */
- swPanelPowerSequence((output&PNL_SEQ_MASK)>>PNL_SEQ_OFFSET, 4);
+ swPanelPowerSequence((output & PNL_SEQ_MASK) >> PNL_SEQ_OFFSET, 4);
}
if (output & DAC_USAGE)
- setDAC((output & DAC_MASK)>>DAC_OFFSET);
+ setDAC((output & DAC_MASK) >> DAC_OFFSET);
if (output & DPMS_USAGE)
ddk750_setDPMS((output & DPMS_MASK) >> DPMS_OFFSET);
}
-
-
-int ddk750_initDVIDisp(void)
-{
- /* Initialize DVI. If the dviInit fail and the VendorID or the DeviceID are
- not zeroed, then set the failure flag. If it is zeroe, it might mean
- that the system is in Dual CRT Monitor configuration. */
-
- /* De-skew enabled with default 111b value.
- This will fix some artifacts problem in some mode on board 2.2.
- Somehow this fix does not affect board 2.1.
- */
- if ((dviInit(1, /* Select Rising Edge */
- 1, /* Select 24-bit bus */
- 0, /* Select Single Edge clock */
- 1, /* Enable HSync as is */
- 1, /* Enable VSync as is */
- 1, /* Enable De-skew */
- 7, /* Set the de-skew setting to maximum setup */
- 1, /* Enable continuous Sync */
- 1, /* Enable PLL Filter */
- 4 /* Use the recommended value for PLL Filter value */
- ) != 0) && (dviGetVendorID() != 0x0000) && (dviGetDeviceID() != 0x0000)) {
- return (-1);
- }
-
- /* TODO: Initialize other display component */
-
- /* Success */
- return 0;
-
-}
-
diff --git a/drivers/staging/sm750fb/ddk750_display.h b/drivers/staging/sm750fb/ddk750_display.h
index abccf84a8..ca35aa1df 100644
--- a/drivers/staging/sm750fb/ddk750_display.h
+++ b/drivers/staging/sm750fb/ddk750_display.h
@@ -17,7 +17,7 @@
0: both off
*/
#define PRI_TP_OFFSET 4
-#define PRI_TP_MASK (1 << PRI_TP_OFFSET)
+#define PRI_TP_MASK BIT(PRI_TP_OFFSET)
#define PRI_TP_USAGE (PRI_TP_MASK << 16)
#define PRI_TP_ON ((0x1 << PRI_TP_OFFSET)|PRI_TP_USAGE)
#define PRI_TP_OFF ((0x0 << PRI_TP_OFFSET)|PRI_TP_USAGE)
@@ -27,18 +27,18 @@
80000[27:24]
*/
#define PNL_SEQ_OFFSET 6
-#define PNL_SEQ_MASK (1 << PNL_SEQ_OFFSET)
+#define PNL_SEQ_MASK BIT(PNL_SEQ_OFFSET)
#define PNL_SEQ_USAGE (PNL_SEQ_MASK << 16)
-#define PNL_SEQ_ON ((1 << PNL_SEQ_OFFSET)|PNL_SEQ_USAGE)
+#define PNL_SEQ_ON (BIT(PNL_SEQ_OFFSET)|PNL_SEQ_USAGE)
#define PNL_SEQ_OFF ((0 << PNL_SEQ_OFFSET)|PNL_SEQ_USAGE)
/* dual digital output
80000[19]
*/
#define DUAL_TFT_OFFSET 8
-#define DUAL_TFT_MASK (1 << DUAL_TFT_OFFSET)
+#define DUAL_TFT_MASK BIT(DUAL_TFT_OFFSET)
#define DUAL_TFT_USAGE (DUAL_TFT_MASK << 16)
-#define DUAL_TFT_ON ((1 << DUAL_TFT_OFFSET)|DUAL_TFT_USAGE)
+#define DUAL_TFT_ON (BIT(DUAL_TFT_OFFSET)|DUAL_TFT_USAGE)
#define DUAL_TFT_OFF ((0 << DUAL_TFT_OFFSET)|DUAL_TFT_USAGE)
/* secondary timing & plane enable bit
@@ -46,7 +46,7 @@
0: both off
*/
#define SEC_TP_OFFSET 5
-#define SEC_TP_MASK (1 << SEC_TP_OFFSET)
+#define SEC_TP_MASK BIT(SEC_TP_OFFSET)
#define SEC_TP_USAGE (SEC_TP_MASK << 16)
#define SEC_TP_ON ((0x1 << SEC_TP_OFFSET)|SEC_TP_USAGE)
#define SEC_TP_OFF ((0x0 << SEC_TP_OFFSET)|SEC_TP_USAGE)
@@ -65,7 +65,7 @@
4[20]
*/
#define DAC_OFFSET 7
-#define DAC_MASK (1 << DAC_OFFSET)
+#define DAC_MASK BIT(DAC_OFFSET)
#define DAC_USAGE (DAC_MASK << 16)
#define DAC_ON ((0x0 << DAC_OFFSET)|DAC_USAGE)
#define DAC_OFF ((0x1 << DAC_OFFSET)|DAC_USAGE)
@@ -85,75 +85,20 @@
LCD1 means panel path TFT1 & panel path DVI (so enable DAC)
CRT means crt path DSUB
*/
-#if 0
-typedef enum _disp_output_t {
- NO_DISPLAY = DPMS_OFF,
-
- LCD1_PRI = PNL_2_PRI|PRI_TP_ON|PNL_SEQ_ON|DPMS_OFF|DAC_ON,
- LCD1_SEC = PNL_2_SEC|SEC_TP_ON|PNL_SEQ_ON|DPMS_OFF|DAC_ON,
-
- LCD2_PRI = CRT_2_PRI|PRI_TP_ON|DUAL_TFT_ON|DPMS_OFF,
- LCD2_SEC = CRT_2_SEC|SEC_TP_ON|DUAL_TFT_ON|DPMS_OFF,
-
- DSUB_PRI = CRT_2_PRI|PRI_TP_ON|DAC_ON,
- DSUB_SEC = CRT_2_SEC|SEC_TP_ON|DAC_ON,
-
- LCD1_DSUB_PRI = PNL_2_PRI|PRI_TP_ON|PNL_SEQ_ON|
- CRT_2_PRI|SEC_TP_OFF|DAC_ON,
-
- LCD1_DSUB_SEC = PNL_2_SEC|SEC_TP_ON|PNL_SEQ_ON|
- CRT_2_SEC|PRI_TP_OFF|DAC_ON,
-
- /* LCD1 show primary and DSUB show secondary */
- LCD1_DSUB_DUAL = PNL_2_PRI|PRI_TP_ON|PNL_SEQ_ON|
- CRT_2_SEC|SEC_TP_ON|DAC_ON,
-
- /* LCD1 show secondary and DSUB show primary */
- LCD1_DSUB_DUAL_SWAP = PNL_2_SEC|SEC_TP_ON|PNL_SEQ_ON|
- CRT_2_PRI|PRI_TP_ON|DAC_ON,
-
- LCD1_LCD2_PRI = PNL_2_PRI|PRI_TP_ON|PNL_SEQ_ON|
- CRT_2_PRI|SEC_TP_OFF|DPMS_OFF|DUAL_TFT_ON,
-
- LCD1_LCD2_SEC = PNL_2_SEC|SEC_TP_ON|PNL_SEQ_ON|
- CRT_2_SEC|PRI_TP_OFF|DPMS_OFF|DUAL_TFT_ON,
-
- LCD1_LCD2_DSUB_PRI = PNL_2_PRI|PRI_TP_ON|PNL_SEQ_ON|DAC_ON|
- CRT_2_PRI|SEC_TP_OFF|DPMS_ON|DUAL_TFT_ON,
-
- LCD1_LCD2_DSUB_SEC = PNL_2_SEC|SEC_TP_ON|PNL_SEQ_ON|DAC_ON|
- CRT_2_SEC|PRI_TP_OFF|DPMS_ON|DUAL_TFT_ON,
-
-
-}
-disp_output_t;
-#else
typedef enum _disp_output_t {
do_LCD1_PRI = PNL_2_PRI|PRI_TP_ON|PNL_SEQ_ON|DAC_ON,
do_LCD1_SEC = PNL_2_SEC|SEC_TP_ON|PNL_SEQ_ON|DAC_ON,
-#if 0
- do_LCD2_PRI = CRT_2_PRI|PRI_TP_ON,
- do_LCD2_SEC = CRT_2_SEC|SEC_TP_ON,
-#else
do_LCD2_PRI = CRT_2_PRI|PRI_TP_ON|DUAL_TFT_ON,
do_LCD2_SEC = CRT_2_SEC|SEC_TP_ON|DUAL_TFT_ON,
-#endif
/*
do_DSUB_PRI = CRT_2_PRI|PRI_TP_ON|DPMS_ON|DAC_ON,
do_DSUB_SEC = CRT_2_SEC|SEC_TP_ON|DPMS_ON|DAC_ON,
*/
-#if 0
- do_CRT_PRI = CRT_2_PRI|PRI_TP_ON,
- do_CRT_SEC = CRT_2_SEC|SEC_TP_ON,
-#else
do_CRT_PRI = CRT_2_PRI|PRI_TP_ON|DPMS_ON|DAC_ON,
do_CRT_SEC = CRT_2_SEC|SEC_TP_ON|DPMS_ON|DAC_ON,
-#endif
}
disp_output_t;
-#endif
void ddk750_setLogicalDispOut(disp_output_t);
-int ddk750_initDVIDisp(void);
#endif
diff --git a/drivers/staging/sm750fb/ddk750_help.h b/drivers/staging/sm750fb/ddk750_help.h
index 3b06aed43..5be814eed 100644
--- a/drivers/staging/sm750fb/ddk750_help.h
+++ b/drivers/staging/sm750fb/ddk750_help.h
@@ -4,20 +4,13 @@
#ifndef USE_INTERNAL_REGISTER_ACCESS
#include <linux/ioport.h>
-#include <asm/io.h>
-#include <asm/uaccess.h>
+#include <linux/io.h>
+#include <linux/uaccess.h>
#include "sm750_help.h"
-
-#if 0
-/* if 718 big endian turned on,be aware that don't use this driver for general use,only for ppc big-endian */
-#warning "big endian on target cpu and enable nature big endian support of 718 capability !"
-#define PEEK32(addr) __raw_readl(mmio750 + addr)
-#define POKE32(addr, data) __raw_writel(data, mmio750 + addr)
-#else /* software control endianness */
+/* software control endianness */
#define PEEK32(addr) readl(addr + mmio750)
#define POKE32(addr, data) writel(data, addr + mmio750)
-#endif
extern void __iomem *mmio750;
extern char revId750;
diff --git a/drivers/staging/sm750fb/ddk750_hwi2c.c b/drivers/staging/sm750fb/ddk750_hwi2c.c
index 5ddac430a..7be211128 100644
--- a/drivers/staging/sm750fb/ddk750_hwi2c.c
+++ b/drivers/staging/sm750fb/ddk750_hwi2c.c
@@ -8,9 +8,8 @@
#define MAX_HWI2C_FIFO 16
#define HWI2C_WAIT_TIMEOUT 0xF0000
-
-int hwI2CInit(
-unsigned char busSpeedMode
+int sm750_hw_i2c_init(
+unsigned char bus_speed_mode
)
{
unsigned int value;
@@ -29,7 +28,7 @@ unsigned char busSpeedMode
/* Enable the I2C Controller and set the bus speed mode */
value = PEEK32(I2C_CTRL);
- if (busSpeedMode == 0)
+ if (bus_speed_mode == 0)
value = FIELD_SET(value, I2C_CTRL, MODE, STANDARD);
else
value = FIELD_SET(value, I2C_CTRL, MODE, FAST);
@@ -39,8 +38,7 @@ unsigned char busSpeedMode
return 0;
}
-
-void hwI2CClose(void)
+void sm750_hw_i2c_close(void)
{
unsigned int value;
@@ -59,14 +57,14 @@ void hwI2CClose(void)
POKE32(GPIO_MUX, value);
}
-
-static long hwI2CWaitTXDone(void)
+static long hw_i2c_wait_tx_done(void)
{
unsigned int timeout;
/* Wait until the transfer is completed. */
timeout = HWI2C_WAIT_TIMEOUT;
- while ((FIELD_GET(PEEK32(I2C_STATUS), I2C_STATUS, TX) != I2C_STATUS_TX_COMPLETED) &&
+ while ((FIELD_GET(PEEK32(I2C_STATUS),
+ I2C_STATUS, TX) != I2C_STATUS_TX_COMPLETED) &&
(timeout != 0))
timeout--;
@@ -76,38 +74,39 @@ static long hwI2CWaitTXDone(void)
return 0;
}
-
-
/*
* This function writes data to the i2c slave device registers.
*
* Parameters:
- * deviceAddress - i2c Slave device address
+ * addr - i2c Slave device address
* length - Total number of bytes to be written to the device
- * pBuffer - The buffer that contains the data to be written to the
+ * buf - The buffer that contains the data to be written to the
* i2c device.
*
* Return Value:
* Total number of bytes those are actually written.
*/
-static unsigned int hwI2CWriteData(
- unsigned char deviceAddress,
+static unsigned int hw_i2c_write_data(
+ unsigned char addr,
unsigned int length,
- unsigned char *pBuffer
+ unsigned char *buf
)
{
unsigned char count, i;
- unsigned int totalBytes = 0;
+ unsigned int total_bytes = 0;
/* Set the Device Address */
- POKE32(I2C_SLAVE_ADDRESS, deviceAddress & ~0x01);
+ POKE32(I2C_SLAVE_ADDRESS, addr & ~0x01);
/* Write data.
* Note:
* Only 16 byte can be accessed per i2c start instruction.
*/
do {
- /* Reset I2C by writing 0 to I2C_RESET register to clear the previous status. */
+ /*
+ * Reset I2C by writing 0 to I2C_RESET register to
+ * clear the previous status.
+ */
POKE32(I2C_RESET, 0);
/* Set the number of bytes to be written */
@@ -119,61 +118,62 @@ static unsigned int hwI2CWriteData(
/* Move the data to the I2C data register */
for (i = 0; i <= count; i++)
- POKE32(I2C_DATA0 + i, *pBuffer++);
+ POKE32(I2C_DATA0 + i, *buf++);
/* Start the I2C */
- POKE32(I2C_CTRL, FIELD_SET(PEEK32(I2C_CTRL), I2C_CTRL, CTRL, START));
+ POKE32(I2C_CTRL,
+ FIELD_SET(PEEK32(I2C_CTRL), I2C_CTRL, CTRL, START));
/* Wait until the transfer is completed. */
- if (hwI2CWaitTXDone() != 0)
+ if (hw_i2c_wait_tx_done() != 0)
break;
/* Substract length */
length -= (count + 1);
/* Total byte written */
- totalBytes += (count + 1);
+ total_bytes += (count + 1);
} while (length > 0);
- return totalBytes;
+ return total_bytes;
}
-
-
-
/*
* This function reads data from the slave device and stores them
* in the given buffer
*
* Parameters:
- * deviceAddress - i2c Slave device address
+ * addr - i2c Slave device address
* length - Total number of bytes to be read
- * pBuffer - Pointer to a buffer to be filled with the data read
+ * buf - Pointer to a buffer to be filled with the data read
* from the slave device. It has to be the same size as the
* length to make sure that it can keep all the data read.
*
* Return Value:
* Total number of actual bytes read from the slave device
*/
-static unsigned int hwI2CReadData(
- unsigned char deviceAddress,
+static unsigned int hw_i2c_read_data(
+ unsigned char addr,
unsigned int length,
- unsigned char *pBuffer
+ unsigned char *buf
)
{
unsigned char count, i;
- unsigned int totalBytes = 0;
+ unsigned int total_bytes = 0;
/* Set the Device Address */
- POKE32(I2C_SLAVE_ADDRESS, deviceAddress | 0x01);
+ POKE32(I2C_SLAVE_ADDRESS, addr | 0x01);
/* Read data and save them to the buffer.
* Note:
* Only 16 byte can be accessed per i2c start instruction.
*/
do {
- /* Reset I2C by writing 0 to I2C_RESET register to clear all the status. */
+ /*
+ * Reset I2C by writing 0 to I2C_RESET register to
+ * clear all the status.
+ */
POKE32(I2C_RESET, 0);
/* Set the number of bytes to be read */
@@ -184,30 +184,28 @@ static unsigned int hwI2CReadData(
POKE32(I2C_BYTE_COUNT, count);
/* Start the I2C */
- POKE32(I2C_CTRL, FIELD_SET(PEEK32(I2C_CTRL), I2C_CTRL, CTRL, START));
+ POKE32(I2C_CTRL,
+ FIELD_SET(PEEK32(I2C_CTRL), I2C_CTRL, CTRL, START));
/* Wait until transaction done. */
- if (hwI2CWaitTXDone() != 0)
+ if (hw_i2c_wait_tx_done() != 0)
break;
/* Save the data to the given buffer */
for (i = 0; i <= count; i++)
- *pBuffer++ = PEEK32(I2C_DATA0 + i);
+ *buf++ = PEEK32(I2C_DATA0 + i);
/* Substract length by 16 */
length -= (count + 1);
/* Number of bytes read. */
- totalBytes += (count + 1);
+ total_bytes += (count + 1);
} while (length > 0);
- return totalBytes;
+ return total_bytes;
}
-
-
-
/*
* This function reads the slave device's register
*
@@ -219,23 +217,19 @@ static unsigned int hwI2CReadData(
* Return Value:
* Register value
*/
-unsigned char hwI2CReadReg(
- unsigned char deviceAddress,
- unsigned char registerIndex
+unsigned char sm750_hw_i2c_read_reg(
+ unsigned char addr,
+ unsigned char reg
)
{
unsigned char value = (0xFF);
- if (hwI2CWriteData(deviceAddress, 1, &registerIndex) == 1)
- hwI2CReadData(deviceAddress, 1, &value);
+ if (hw_i2c_write_data(addr, 1, &reg) == 1)
+ hw_i2c_read_data(addr, 1, &value);
return value;
}
-
-
-
-
/*
* This function writes a value to the slave device's register
*
@@ -249,21 +243,20 @@ unsigned char hwI2CReadReg(
* 0 - Success
* -1 - Fail
*/
-int hwI2CWriteReg(
- unsigned char deviceAddress,
- unsigned char registerIndex,
+int sm750_hw_i2c_write_reg(
+ unsigned char addr,
+ unsigned char reg,
unsigned char data
)
{
unsigned char value[2];
- value[0] = registerIndex;
+ value[0] = reg;
value[1] = data;
- if (hwI2CWriteData(deviceAddress, 2, value) == 2)
+ if (hw_i2c_write_data(addr, 2, value) == 2)
return 0;
return (-1);
}
-
#endif
diff --git a/drivers/staging/sm750fb/ddk750_hwi2c.h b/drivers/staging/sm750fb/ddk750_hwi2c.h
index 0b830ba65..46e22dce2 100644
--- a/drivers/staging/sm750fb/ddk750_hwi2c.h
+++ b/drivers/staging/sm750fb/ddk750_hwi2c.h
@@ -2,9 +2,10 @@
#define DDK750_HWI2C_H__
/* hwi2c functions */
-int hwI2CInit(unsigned char busSpeedMode);
-void hwI2CClose(void);
+int sm750_hw_i2c_init(unsigned char bus_speed_mode);
+void sm750_hw_i2c_close(void);
-unsigned char hwI2CReadReg(unsigned char deviceAddress, unsigned char registerIndex);
-int hwI2CWriteReg(unsigned char deviceAddress, unsigned char registerIndex, unsigned char data);
+unsigned char sm750_hw_i2c_read_reg(unsigned char addr, unsigned char reg);
+int sm750_hw_i2c_write_reg(unsigned char addr, unsigned char reg,
+ unsigned char data);
#endif
diff --git a/drivers/staging/sm750fb/ddk750_mode.c b/drivers/staging/sm750fb/ddk750_mode.c
index 2399b175a..fa3592668 100644
--- a/drivers/staging/sm750fb/ddk750_mode.c
+++ b/drivers/staging/sm750fb/ddk750_mode.c
@@ -168,14 +168,13 @@ static int programModeRegisters(mode_parameter_t *pModeParam, pll_value_t *pll)
*/
POKE32(PANEL_DISPLAY_CTRL, ulTmpValue|ulReg);
-#if 1
+
while ((PEEK32(PANEL_DISPLAY_CTRL) & ~ulReservedBits) != (ulTmpValue|ulReg)) {
cnt++;
if (cnt > 1000)
break;
POKE32(PANEL_DISPLAY_CTRL, ulTmpValue|ulReg);
}
-#endif
} else {
ret = -1;
}
diff --git a/drivers/staging/sm750fb/ddk750_power.c b/drivers/staging/sm750fb/ddk750_power.c
index e580dab2b..667e4f822 100644
--- a/drivers/staging/sm750fb/ddk750_power.c
+++ b/drivers/staging/sm750fb/ddk750_power.c
@@ -17,7 +17,7 @@ void ddk750_setDPMS(DPMS_t state)
}
}
-unsigned int getPowerMode(void)
+static unsigned int getPowerMode(void)
{
if (getChipType() == SM750LE)
return 0;
@@ -108,7 +108,7 @@ void setCurrentGate(unsigned int gate)
*/
void enable2DEngine(unsigned int enable)
{
- uint32_t gate;
+ u32 gate;
gate = PEEK32(CURRENT_GATE);
if (enable) {
@@ -122,53 +122,9 @@ void enable2DEngine(unsigned int enable)
setCurrentGate(gate);
}
-
-/*
- * This function enable/disable the ZV Port.
- */
-void enableZVPort(unsigned int enable)
-{
- uint32_t gate;
-
- /* Enable ZV Port Gate */
- gate = PEEK32(CURRENT_GATE);
- if (enable) {
- gate = FIELD_SET(gate, CURRENT_GATE, ZVPORT, ON);
-#if 1
- /* Using Software I2C */
- gate = FIELD_SET(gate, CURRENT_GATE, GPIO, ON);
-#else
- /* Using Hardware I2C */
- gate = FIELD_SET(gate, CURRENT_GATE, I2C, ON);
-#endif
- } else {
- /* Disable ZV Port Gate. There is no way to know whether the
- GPIO pins are being used or not. Therefore, do not disable the
- GPIO gate. */
- gate = FIELD_SET(gate, CURRENT_GATE, ZVPORT, OFF);
- }
-
- setCurrentGate(gate);
-}
-
-
-void enableSSP(unsigned int enable)
-{
- uint32_t gate;
-
- /* Enable SSP Gate */
- gate = PEEK32(CURRENT_GATE);
- if (enable)
- gate = FIELD_SET(gate, CURRENT_GATE, SSP, ON);
- else
- gate = FIELD_SET(gate, CURRENT_GATE, SSP, OFF);
-
- setCurrentGate(gate);
-}
-
void enableDMA(unsigned int enable)
{
- uint32_t gate;
+ u32 gate;
/* Enable DMA Gate */
gate = PEEK32(CURRENT_GATE);
@@ -185,7 +141,7 @@ void enableDMA(unsigned int enable)
*/
void enableGPIO(unsigned int enable)
{
- uint32_t gate;
+ u32 gate;
/* Enable GPIO Gate */
gate = PEEK32(CURRENT_GATE);
@@ -198,28 +154,11 @@ void enableGPIO(unsigned int enable)
}
/*
- * This function enable/disable the PWM Engine
- */
-void enablePWM(unsigned int enable)
-{
- uint32_t gate;
-
- /* Enable PWM Gate */
- gate = PEEK32(CURRENT_GATE);
- if (enable)
- gate = FIELD_SET(gate, CURRENT_GATE, PWM, ON);
- else
- gate = FIELD_SET(gate, CURRENT_GATE, PWM, OFF);
-
- setCurrentGate(gate);
-}
-
-/*
* This function enable/disable the I2C Engine
*/
void enableI2C(unsigned int enable)
{
- uint32_t gate;
+ u32 gate;
/* Enable I2C Gate */
gate = PEEK32(CURRENT_GATE);
diff --git a/drivers/staging/sm750fb/ddk750_power.h b/drivers/staging/sm750fb/ddk750_power.h
index b7cf6b281..6e804d990 100644
--- a/drivers/staging/sm750fb/ddk750_power.h
+++ b/drivers/staging/sm750fb/ddk750_power.h
@@ -19,8 +19,6 @@ DPMS_t;
void ddk750_setDPMS(DPMS_t);
-unsigned int getPowerMode(void);
-
/*
* This function sets the current power mode
*/
@@ -37,11 +35,6 @@ void setCurrentGate(unsigned int gate);
void enable2DEngine(unsigned int enable);
/*
- * This function enable/disable the ZV Port
- */
-void enableZVPort(unsigned int enable);
-
-/*
* This function enable/disable the DMA Engine
*/
void enableDMA(unsigned int enable);
@@ -52,19 +45,9 @@ void enableDMA(unsigned int enable);
void enableGPIO(unsigned int enable);
/*
- * This function enable/disable the PWM Engine
- */
-void enablePWM(unsigned int enable);
-
-/*
* This function enable/disable the I2C Engine
*/
void enableI2C(unsigned int enable);
-/*
- * This function enable/disable the SSP.
- */
-void enableSSP(unsigned int enable);
-
#endif
diff --git a/drivers/staging/sm750fb/ddk750_reg.h b/drivers/staging/sm750fb/ddk750_reg.h
index 2995625c3..16a01c254 100644
--- a/drivers/staging/sm750fb/ddk750_reg.h
+++ b/drivers/staging/sm750fb/ddk750_reg.h
@@ -1836,23 +1836,6 @@
#define CRT_HWC_COLOR_3 0x08023C
#define CRT_HWC_COLOR_3_RGB565 15:0
-/* Old Definitions +++. Need to be removed if no application use it. */
-#if 0
- #define CRT_HWC_COLOR_01 0x080238
- #define CRT_HWC_COLOR_01_1_RED 31:27
- #define CRT_HWC_COLOR_01_1_GREEN 26:21
- #define CRT_HWC_COLOR_01_1_BLUE 20:16
- #define CRT_HWC_COLOR_01_0_RED 15:11
- #define CRT_HWC_COLOR_01_0_GREEN 10:5
- #define CRT_HWC_COLOR_01_0_BLUE 4:0
-
- #define CRT_HWC_COLOR_2 0x08023C
- #define CRT_HWC_COLOR_2_RED 15:11
- #define CRT_HWC_COLOR_2_GREEN 10:5
- #define CRT_HWC_COLOR_2_BLUE 4:0
-#endif
-/* Old Definitions --- */
-
/* This vertical expansion below start at 0x080240 ~ 0x080264 */
#define CRT_VERTICAL_EXPANSION 0x080240
#ifndef VALIDATION_CHIP
@@ -1891,233 +1874,6 @@
/* Panel Palette register starts at 0x080C00 ~ 0x080FFC */
#define CRT_PALETTE_RAM 0x080C00
-/* 2D registers
- * move their defination into general lynx_accel.h file
- * because all smi graphic chip share the same drawing engine
- * register format */
-#if 0
-#define DE_SOURCE 0x100000
-#define DE_SOURCE_WRAP 31:31
-#define DE_SOURCE_WRAP_DISABLE 0
-#define DE_SOURCE_WRAP_ENABLE 1
-
-/*
- * The following definitions are used in different setting
- */
-
-/* Use these definitions in XY addressing mode or linear addressing mode. */
-#define DE_SOURCE_X_K1 27:16
-#define DE_SOURCE_Y_K2 11:0
-
-/* Use this definition in host write mode for mono. The Y_K2 is not used
- in host write mode. */
-#define DE_SOURCE_X_K1_MONO 20:16
-
-/* Use these definitions in Bresenham line drawing mode. */
-#define DE_SOURCE_X_K1_LINE 29:16
-#define DE_SOURCE_Y_K2_LINE 13:0
-
-#define DE_DESTINATION 0x100004
-#define DE_DESTINATION_WRAP 31:31
-#define DE_DESTINATION_WRAP_DISABLE 0
-#define DE_DESTINATION_WRAP_ENABLE 1
-#if 1
- #define DE_DESTINATION_X 27:16
- #define DE_DESTINATION_Y 11:0
-#else
- #define DE_DESTINATION_X 28:16
- #define DE_DESTINATION_Y 15:0
-#endif
-
-#define DE_DIMENSION 0x100008
-#define DE_DIMENSION_X 28:16
-#define DE_DIMENSION_Y_ET 15:0
-
-#define DE_CONTROL 0x10000C
-#define DE_CONTROL_STATUS 31:31
-#define DE_CONTROL_STATUS_STOP 0
-#define DE_CONTROL_STATUS_START 1
-#define DE_CONTROL_PATTERN 30:30
-#define DE_CONTROL_PATTERN_MONO 0
-#define DE_CONTROL_PATTERN_COLOR 1
-#define DE_CONTROL_UPDATE_DESTINATION_X 29:29
-#define DE_CONTROL_UPDATE_DESTINATION_X_DISABLE 0
-#define DE_CONTROL_UPDATE_DESTINATION_X_ENABLE 1
-#define DE_CONTROL_QUICK_START 28:28
-#define DE_CONTROL_QUICK_START_DISABLE 0
-#define DE_CONTROL_QUICK_START_ENABLE 1
-#define DE_CONTROL_DIRECTION 27:27
-#define DE_CONTROL_DIRECTION_LEFT_TO_RIGHT 0
-#define DE_CONTROL_DIRECTION_RIGHT_TO_LEFT 1
-#define DE_CONTROL_MAJOR 26:26
-#define DE_CONTROL_MAJOR_X 0
-#define DE_CONTROL_MAJOR_Y 1
-#define DE_CONTROL_STEP_X 25:25
-#define DE_CONTROL_STEP_X_POSITIVE 0
-#define DE_CONTROL_STEP_X_NEGATIVE 1
-#define DE_CONTROL_STEP_Y 24:24
-#define DE_CONTROL_STEP_Y_POSITIVE 0
-#define DE_CONTROL_STEP_Y_NEGATIVE 1
-#define DE_CONTROL_STRETCH 23:23
-#define DE_CONTROL_STRETCH_DISABLE 0
-#define DE_CONTROL_STRETCH_ENABLE 1
-#define DE_CONTROL_HOST 22:22
-#define DE_CONTROL_HOST_COLOR 0
-#define DE_CONTROL_HOST_MONO 1
-#define DE_CONTROL_LAST_PIXEL 21:21
-#define DE_CONTROL_LAST_PIXEL_OFF 0
-#define DE_CONTROL_LAST_PIXEL_ON 1
-#define DE_CONTROL_COMMAND 20:16
-#define DE_CONTROL_COMMAND_BITBLT 0
-#define DE_CONTROL_COMMAND_RECTANGLE_FILL 1
-#define DE_CONTROL_COMMAND_DE_TILE 2
-#define DE_CONTROL_COMMAND_TRAPEZOID_FILL 3
-#define DE_CONTROL_COMMAND_ALPHA_BLEND 4
-#define DE_CONTROL_COMMAND_RLE_STRIP 5
-#define DE_CONTROL_COMMAND_SHORT_STROKE 6
-#define DE_CONTROL_COMMAND_LINE_DRAW 7
-#define DE_CONTROL_COMMAND_HOST_WRITE 8
-#define DE_CONTROL_COMMAND_HOST_READ 9
-#define DE_CONTROL_COMMAND_HOST_WRITE_BOTTOM_UP 10
-#define DE_CONTROL_COMMAND_ROTATE 11
-#define DE_CONTROL_COMMAND_FONT 12
-#define DE_CONTROL_COMMAND_TEXTURE_LOAD 15
-#define DE_CONTROL_ROP_SELECT 15:15
-#define DE_CONTROL_ROP_SELECT_ROP3 0
-#define DE_CONTROL_ROP_SELECT_ROP2 1
-#define DE_CONTROL_ROP2_SOURCE 14:14
-#define DE_CONTROL_ROP2_SOURCE_BITMAP 0
-#define DE_CONTROL_ROP2_SOURCE_PATTERN 1
-#define DE_CONTROL_MONO_DATA 13:12
-#define DE_CONTROL_MONO_DATA_NOT_PACKED 0
-#define DE_CONTROL_MONO_DATA_8_PACKED 1
-#define DE_CONTROL_MONO_DATA_16_PACKED 2
-#define DE_CONTROL_MONO_DATA_32_PACKED 3
-#define DE_CONTROL_REPEAT_ROTATE 11:11
-#define DE_CONTROL_REPEAT_ROTATE_DISABLE 0
-#define DE_CONTROL_REPEAT_ROTATE_ENABLE 1
-#define DE_CONTROL_TRANSPARENCY_MATCH 10:10
-#define DE_CONTROL_TRANSPARENCY_MATCH_OPAQUE 0
-#define DE_CONTROL_TRANSPARENCY_MATCH_TRANSPARENT 1
-#define DE_CONTROL_TRANSPARENCY_SELECT 9:9
-#define DE_CONTROL_TRANSPARENCY_SELECT_SOURCE 0
-#define DE_CONTROL_TRANSPARENCY_SELECT_DESTINATION 1
-#define DE_CONTROL_TRANSPARENCY 8:8
-#define DE_CONTROL_TRANSPARENCY_DISABLE 0
-#define DE_CONTROL_TRANSPARENCY_ENABLE 1
-#define DE_CONTROL_ROP 7:0
-
-/* Pseudo fields. */
-
-#define DE_CONTROL_SHORT_STROKE_DIR 27:24
-#define DE_CONTROL_SHORT_STROKE_DIR_225 0
-#define DE_CONTROL_SHORT_STROKE_DIR_135 1
-#define DE_CONTROL_SHORT_STROKE_DIR_315 2
-#define DE_CONTROL_SHORT_STROKE_DIR_45 3
-#define DE_CONTROL_SHORT_STROKE_DIR_270 4
-#define DE_CONTROL_SHORT_STROKE_DIR_90 5
-#define DE_CONTROL_SHORT_STROKE_DIR_180 8
-#define DE_CONTROL_SHORT_STROKE_DIR_0 10
-#define DE_CONTROL_ROTATION 25:24
-#define DE_CONTROL_ROTATION_0 0
-#define DE_CONTROL_ROTATION_270 1
-#define DE_CONTROL_ROTATION_90 2
-#define DE_CONTROL_ROTATION_180 3
-
-#define DE_PITCH 0x100010
-#define DE_PITCH_DESTINATION 28:16
-#define DE_PITCH_SOURCE 12:0
-
-#define DE_FOREGROUND 0x100014
-#define DE_FOREGROUND_COLOR 31:0
-
-#define DE_BACKGROUND 0x100018
-#define DE_BACKGROUND_COLOR 31:0
-
-#define DE_STRETCH_FORMAT 0x10001C
-#define DE_STRETCH_FORMAT_PATTERN_XY 30:30
-#define DE_STRETCH_FORMAT_PATTERN_XY_NORMAL 0
-#define DE_STRETCH_FORMAT_PATTERN_XY_OVERWRITE 1
-#define DE_STRETCH_FORMAT_PATTERN_Y 29:27
-#define DE_STRETCH_FORMAT_PATTERN_X 25:23
-#define DE_STRETCH_FORMAT_PIXEL_FORMAT 21:20
-#define DE_STRETCH_FORMAT_PIXEL_FORMAT_8 0
-#define DE_STRETCH_FORMAT_PIXEL_FORMAT_16 1
-#define DE_STRETCH_FORMAT_PIXEL_FORMAT_32 2
-#define DE_STRETCH_FORMAT_ADDRESSING 19:16
-#define DE_STRETCH_FORMAT_ADDRESSING_XY 0
-#define DE_STRETCH_FORMAT_ADDRESSING_LINEAR 15
-#define DE_STRETCH_FORMAT_SOURCE_HEIGHT 11:0
-
-#define DE_COLOR_COMPARE 0x100020
-#define DE_COLOR_COMPARE_COLOR 23:0
-
-#define DE_COLOR_COMPARE_MASK 0x100024
-#define DE_COLOR_COMPARE_MASK_MASKS 23:0
-
-#define DE_MASKS 0x100028
-#define DE_MASKS_BYTE_MASK 31:16
-#define DE_MASKS_BIT_MASK 15:0
-
-#define DE_CLIP_TL 0x10002C
-#define DE_CLIP_TL_TOP 31:16
-#define DE_CLIP_TL_STATUS 13:13
-#define DE_CLIP_TL_STATUS_DISABLE 0
-#define DE_CLIP_TL_STATUS_ENABLE 1
-#define DE_CLIP_TL_INHIBIT 12:12
-#define DE_CLIP_TL_INHIBIT_OUTSIDE 0
-#define DE_CLIP_TL_INHIBIT_INSIDE 1
-#define DE_CLIP_TL_LEFT 11:0
-
-#define DE_CLIP_BR 0x100030
-#define DE_CLIP_BR_BOTTOM 31:16
-#define DE_CLIP_BR_RIGHT 12:0
-
-#define DE_MONO_PATTERN_LOW 0x100034
-#define DE_MONO_PATTERN_LOW_PATTERN 31:0
-
-#define DE_MONO_PATTERN_HIGH 0x100038
-#define DE_MONO_PATTERN_HIGH_PATTERN 31:0
-
-#define DE_WINDOW_WIDTH 0x10003C
-#define DE_WINDOW_WIDTH_DESTINATION 28:16
-#define DE_WINDOW_WIDTH_SOURCE 12:0
-
-#define DE_WINDOW_SOURCE_BASE 0x100040
-#define DE_WINDOW_SOURCE_BASE_EXT 27:27
-#define DE_WINDOW_SOURCE_BASE_EXT_LOCAL 0
-#define DE_WINDOW_SOURCE_BASE_EXT_EXTERNAL 1
-#define DE_WINDOW_SOURCE_BASE_CS 26:26
-#define DE_WINDOW_SOURCE_BASE_CS_0 0
-#define DE_WINDOW_SOURCE_BASE_CS_1 1
-#define DE_WINDOW_SOURCE_BASE_ADDRESS 25:0
-
-#define DE_WINDOW_DESTINATION_BASE 0x100044
-#define DE_WINDOW_DESTINATION_BASE_EXT 27:27
-#define DE_WINDOW_DESTINATION_BASE_EXT_LOCAL 0
-#define DE_WINDOW_DESTINATION_BASE_EXT_EXTERNAL 1
-#define DE_WINDOW_DESTINATION_BASE_CS 26:26
-#define DE_WINDOW_DESTINATION_BASE_CS_0 0
-#define DE_WINDOW_DESTINATION_BASE_CS_1 1
-#define DE_WINDOW_DESTINATION_BASE_ADDRESS 25:0
-
-#define DE_ALPHA 0x100048
-#define DE_ALPHA_VALUE 7:0
-
-#define DE_WRAP 0x10004C
-#define DE_WRAP_X 31:16
-#define DE_WRAP_Y 15:0
-
-#define DE_STATUS 0x100050
-#define DE_STATUS_CSC 1:1
-#define DE_STATUS_CSC_CLEAR 0
-#define DE_STATUS_CSC_NOT_ACTIVE 0
-#define DE_STATUS_CSC_ACTIVE 1
-#define DE_STATUS_2D 0:0
-#define DE_STATUS_2D_CLEAR 0
-#define DE_STATUS_2D_NOT_ACTIVE 0
-#define DE_STATUS_2D_ACTIVE 1
-#endif
/* Color Space Conversion registers. */
#define CSC_Y_SOURCE_BASE 0x1000C8
diff --git a/drivers/staging/sm750fb/ddk750_sii164.c b/drivers/staging/sm750fb/ddk750_sii164.c
index 0bdf3db11..241b77b92 100644
--- a/drivers/staging/sm750fb/ddk750_sii164.c
+++ b/drivers/staging/sm750fb/ddk750_sii164.c
@@ -11,8 +11,8 @@
#define USE_HW_I2C
#ifdef USE_HW_I2C
- #define i2cWriteReg hwI2CWriteReg
- #define i2cReadReg hwI2CReadReg
+ #define i2cWriteReg sm750_hw_i2c_write_reg
+ #define i2cReadReg sm750_hw_i2c_read_reg
#else
#define i2cWriteReg swI2CWriteReg
#define i2cReadReg swI2CReadReg
@@ -130,9 +130,9 @@ long sii164InitChip(
/* Initialize the i2c bus */
#ifdef USE_HW_I2C
/* Use fast mode. */
- hwI2CInit(1);
+ sm750_hw_i2c_init(1);
#else
- swI2CInit(DEFAULT_I2C_SCL, DEFAULT_I2C_SDA);
+ sm750_sw_i2c_init(DEFAULT_I2C_SCL, DEFAULT_I2C_SDA);
#endif
/* Check if SII164 Chip exists */
diff --git a/drivers/staging/sm750fb/ddk750_swi2c.c b/drivers/staging/sm750fb/ddk750_swi2c.c
index 5133bccf1..8d644a7cb 100644
--- a/drivers/staging/sm750fb/ddk750_swi2c.c
+++ b/drivers/staging/sm750fb/ddk750_swi2c.c
@@ -15,7 +15,6 @@
#include "ddk750_swi2c.h"
#include "ddk750_power.h"
-
/*******************************************************************
* I2C Software Master Driver:
* ===========================
@@ -55,8 +54,8 @@
******************************************************************/
/* GPIO pins used for this I2C. It ranges from 0 to 63. */
-static unsigned char g_i2cClockGPIO = DEFAULT_I2C_SCL;
-static unsigned char g_i2cDataGPIO = DEFAULT_I2C_SDA;
+static unsigned char sw_i2c_clk_gpio = DEFAULT_I2C_SCL;
+static unsigned char sw_i2c_data_gpio = DEFAULT_I2C_SDA;
/*
* Below is the variable declaration for the GPIO pin register usage
@@ -70,19 +69,19 @@ static unsigned char g_i2cDataGPIO = DEFAULT_I2C_SDA;
*/
/* i2c Clock GPIO Register usage */
-static unsigned long g_i2cClkGPIOMuxReg = GPIO_MUX;
-static unsigned long g_i2cClkGPIODataReg = GPIO_DATA;
-static unsigned long g_i2cClkGPIODataDirReg = GPIO_DATA_DIRECTION;
+static unsigned long sw_i2c_clk_gpio_mux_reg = GPIO_MUX;
+static unsigned long sw_i2c_clk_gpio_data_reg = GPIO_DATA;
+static unsigned long sw_i2c_clk_gpio_data_dir_reg = GPIO_DATA_DIRECTION;
/* i2c Data GPIO Register usage */
-static unsigned long g_i2cDataGPIOMuxReg = GPIO_MUX;
-static unsigned long g_i2cDataGPIODataReg = GPIO_DATA;
-static unsigned long g_i2cDataGPIODataDirReg = GPIO_DATA_DIRECTION;
+static unsigned long sw_i2c_data_gpio_mux_reg = GPIO_MUX;
+static unsigned long sw_i2c_data_gpio_data_reg = GPIO_DATA;
+static unsigned long sw_i2c_data_gpio_data_dir_reg = GPIO_DATA_DIRECTION;
/*
* This function puts a delay between command
*/
-static void swI2CWait(void)
+static void sw_i2c_wait(void)
{
/* find a bug:
* peekIO method works well before suspend/resume
@@ -91,20 +90,17 @@ static void swI2CWait(void)
* never finish.
* use non-ultimate for loop below is safe
* */
-#if 0
+
/* Change wait algorithm to use PCI bus clock,
it's more reliable than counter loop ..
write 0x61 to 0x3ce and read from 0x3cf
*/
- while (peekIO(0x3ce, 0x61) & 0x10);
-#else
- int i, Temp;
+ int i, tmp;
for (i = 0; i < 600; i++) {
- Temp = i;
- Temp += i;
+ tmp = i;
+ tmp += i;
}
-#endif
}
/*
@@ -119,25 +115,28 @@ static void swI2CWait(void)
* signal because the i2c will fail when other device try to drive the
* signal due to SM50x will drive the signal to always high.
*/
-void swI2CSCL(unsigned char value)
+static void sw_i2c_scl(unsigned char value)
{
- unsigned long ulGPIOData;
- unsigned long ulGPIODirection;
+ unsigned long gpio_data;
+ unsigned long gpio_dir;
- ulGPIODirection = PEEK32(g_i2cClkGPIODataDirReg);
+ gpio_dir = PEEK32(sw_i2c_clk_gpio_data_dir_reg);
if (value) { /* High */
- /* Set direction as input. This will automatically pull the signal up. */
- ulGPIODirection &= ~(1 << g_i2cClockGPIO);
- POKE32(g_i2cClkGPIODataDirReg, ulGPIODirection);
+ /*
+ * Set direction as input. This will automatically
+ * pull the signal up.
+ */
+ gpio_dir &= ~(1 << sw_i2c_clk_gpio);
+ POKE32(sw_i2c_clk_gpio_data_dir_reg, gpio_dir);
} else { /* Low */
/* Set the signal down */
- ulGPIOData = PEEK32(g_i2cClkGPIODataReg);
- ulGPIOData &= ~(1 << g_i2cClockGPIO);
- POKE32(g_i2cClkGPIODataReg, ulGPIOData);
+ gpio_data = PEEK32(sw_i2c_clk_gpio_data_reg);
+ gpio_data &= ~(1 << sw_i2c_clk_gpio);
+ POKE32(sw_i2c_clk_gpio_data_reg, gpio_data);
/* Set direction as output */
- ulGPIODirection |= (1 << g_i2cClockGPIO);
- POKE32(g_i2cClkGPIODataDirReg, ulGPIODirection);
+ gpio_dir |= (1 << sw_i2c_clk_gpio);
+ POKE32(sw_i2c_clk_gpio_data_dir_reg, gpio_dir);
}
}
@@ -153,25 +152,28 @@ void swI2CSCL(unsigned char value)
* signal because the i2c will fail when other device try to drive the
* signal due to SM50x will drive the signal to always high.
*/
-void swI2CSDA(unsigned char value)
+static void sw_i2c_sda(unsigned char value)
{
- unsigned long ulGPIOData;
- unsigned long ulGPIODirection;
+ unsigned long gpio_data;
+ unsigned long gpio_dir;
- ulGPIODirection = PEEK32(g_i2cDataGPIODataDirReg);
+ gpio_dir = PEEK32(sw_i2c_data_gpio_data_dir_reg);
if (value) { /* High */
- /* Set direction as input. This will automatically pull the signal up. */
- ulGPIODirection &= ~(1 << g_i2cDataGPIO);
- POKE32(g_i2cDataGPIODataDirReg, ulGPIODirection);
+ /*
+ * Set direction as input. This will automatically
+ * pull the signal up.
+ */
+ gpio_dir &= ~(1 << sw_i2c_data_gpio);
+ POKE32(sw_i2c_data_gpio_data_dir_reg, gpio_dir);
} else { /* Low */
/* Set the signal down */
- ulGPIOData = PEEK32(g_i2cDataGPIODataReg);
- ulGPIOData &= ~(1 << g_i2cDataGPIO);
- POKE32(g_i2cDataGPIODataReg, ulGPIOData);
+ gpio_data = PEEK32(sw_i2c_data_gpio_data_reg);
+ gpio_data &= ~(1 << sw_i2c_data_gpio);
+ POKE32(sw_i2c_data_gpio_data_reg, gpio_data);
/* Set direction as output */
- ulGPIODirection |= (1 << g_i2cDataGPIO);
- POKE32(g_i2cDataGPIODataDirReg, ulGPIODirection);
+ gpio_dir |= (1 << sw_i2c_data_gpio);
+ POKE32(sw_i2c_data_gpio_data_dir_reg, gpio_dir);
}
}
@@ -181,21 +183,22 @@ void swI2CSDA(unsigned char value)
* Return Value:
* The SDA data bit sent by the Slave
*/
-static unsigned char swI2CReadSDA(void)
+static unsigned char sw_i2c_read_sda(void)
{
- unsigned long ulGPIODirection;
- unsigned long ulGPIOData;
+ unsigned long gpio_dir;
+ unsigned long gpio_data;
+ unsigned long dir_mask = 1 << sw_i2c_data_gpio;
/* Make sure that the direction is input (High) */
- ulGPIODirection = PEEK32(g_i2cDataGPIODataDirReg);
- if ((ulGPIODirection & (1 << g_i2cDataGPIO)) != (~(1 << g_i2cDataGPIO))) {
- ulGPIODirection &= ~(1 << g_i2cDataGPIO);
- POKE32(g_i2cDataGPIODataDirReg, ulGPIODirection);
+ gpio_dir = PEEK32(sw_i2c_data_gpio_data_dir_reg);
+ if ((gpio_dir & dir_mask) != ~dir_mask) {
+ gpio_dir &= ~(1 << sw_i2c_data_gpio);
+ POKE32(sw_i2c_data_gpio_data_dir_reg, gpio_dir);
}
/* Now read the SDA line */
- ulGPIOData = PEEK32(g_i2cDataGPIODataReg);
- if (ulGPIOData & (1 << g_i2cDataGPIO))
+ gpio_data = PEEK32(sw_i2c_data_gpio_data_reg);
+ if (gpio_data & (1 << sw_i2c_data_gpio))
return 1;
else
return 0;
@@ -204,7 +207,7 @@ static unsigned char swI2CReadSDA(void)
/*
* This function sends ACK signal
*/
-static void swI2CAck(void)
+static void sw_i2c_ack(void)
{
return; /* Single byte read is ok without it. */
}
@@ -212,23 +215,23 @@ static void swI2CAck(void)
/*
* This function sends the start command to the slave device
*/
-static void swI2CStart(void)
+static void sw_i2c_start(void)
{
/* Start I2C */
- swI2CSDA(1);
- swI2CSCL(1);
- swI2CSDA(0);
+ sw_i2c_sda(1);
+ sw_i2c_scl(1);
+ sw_i2c_sda(0);
}
/*
* This function sends the stop command to the slave device
*/
-static void swI2CStop(void)
+static void sw_i2c_stop(void)
{
/* Stop the I2C */
- swI2CSCL(1);
- swI2CSDA(0);
- swI2CSDA(1);
+ sw_i2c_scl(1);
+ sw_i2c_sda(0);
+ sw_i2c_sda(1);
}
/*
@@ -241,7 +244,7 @@ static void swI2CStop(void)
* 0 - Success
* -1 - Fail to write byte
*/
-static long swI2CWriteByte(unsigned char data)
+static long sw_i2c_write_byte(unsigned char data)
{
unsigned char value = data;
int i;
@@ -249,47 +252,47 @@ static long swI2CWriteByte(unsigned char data)
/* Sending the data bit by bit */
for (i = 0; i < 8; i++) {
/* Set SCL to low */
- swI2CSCL(0);
+ sw_i2c_scl(0);
/* Send data bit */
if ((value & 0x80) != 0)
- swI2CSDA(1);
+ sw_i2c_sda(1);
else
- swI2CSDA(0);
+ sw_i2c_sda(0);
- swI2CWait();
+ sw_i2c_wait();
/* Toggle clk line to one */
- swI2CSCL(1);
- swI2CWait();
+ sw_i2c_scl(1);
+ sw_i2c_wait();
/* Shift byte to be sent */
value = value << 1;
}
/* Set the SCL Low and SDA High (prepare to get input) */
- swI2CSCL(0);
- swI2CSDA(1);
+ sw_i2c_scl(0);
+ sw_i2c_sda(1);
/* Set the SCL High for ack */
- swI2CWait();
- swI2CSCL(1);
- swI2CWait();
+ sw_i2c_wait();
+ sw_i2c_scl(1);
+ sw_i2c_wait();
/* Read SDA, until SDA==0 */
for (i = 0; i < 0xff; i++) {
- if (!swI2CReadSDA())
+ if (!sw_i2c_read_sda())
break;
- swI2CSCL(0);
- swI2CWait();
- swI2CSCL(1);
- swI2CWait();
+ sw_i2c_scl(0);
+ sw_i2c_wait();
+ sw_i2c_scl(1);
+ sw_i2c_wait();
}
/* Set the SCL Low and SDA High */
- swI2CSCL(0);
- swI2CSDA(1);
+ sw_i2c_scl(0);
+ sw_i2c_sda(1);
if (i < 0xff)
return 0;
@@ -307,31 +310,31 @@ static long swI2CWriteByte(unsigned char data)
* Return Value:
* One byte data read from the Slave device
*/
-static unsigned char swI2CReadByte(unsigned char ack)
+static unsigned char sw_i2c_read_byte(unsigned char ack)
{
int i;
unsigned char data = 0;
for (i = 7; i >= 0; i--) {
/* Set the SCL to Low and SDA to High (Input) */
- swI2CSCL(0);
- swI2CSDA(1);
- swI2CWait();
+ sw_i2c_scl(0);
+ sw_i2c_sda(1);
+ sw_i2c_wait();
/* Set the SCL High */
- swI2CSCL(1);
- swI2CWait();
+ sw_i2c_scl(1);
+ sw_i2c_wait();
/* Read data bits from SDA */
- data |= (swI2CReadSDA() << i);
+ data |= (sw_i2c_read_sda() << i);
}
if (ack)
- swI2CAck();
+ sw_i2c_ack();
/* Set the SCL Low and SDA High */
- swI2CSCL(0);
- swI2CSDA(1);
+ sw_i2c_scl(0);
+ sw_i2c_sda(1);
return data;
}
@@ -340,37 +343,37 @@ static unsigned char swI2CReadByte(unsigned char ack)
* This function initializes GPIO port for SW I2C communication.
*
* Parameters:
- * i2cClkGPIO - The GPIO pin to be used as i2c SCL
- * i2cDataGPIO - The GPIO pin to be used as i2c SDA
+ * clk_gpio - The GPIO pin to be used as i2c SCL
+ * data_gpio - The GPIO pin to be used as i2c SDA
*
* Return Value:
* -1 - Fail to initialize the i2c
* 0 - Success
*/
-static long swI2CInit_SM750LE(unsigned char i2cClkGPIO,
- unsigned char i2cDataGPIO)
+static long sm750le_i2c_init(unsigned char clk_gpio,
+ unsigned char data_gpio)
{
int i;
/* Initialize the GPIO pin for the i2c Clock Register */
- g_i2cClkGPIODataReg = GPIO_DATA_SM750LE;
- g_i2cClkGPIODataDirReg = GPIO_DATA_DIRECTION_SM750LE;
+ sw_i2c_clk_gpio_data_reg = GPIO_DATA_SM750LE;
+ sw_i2c_clk_gpio_data_dir_reg = GPIO_DATA_DIRECTION_SM750LE;
/* Initialize the Clock GPIO Offset */
- g_i2cClockGPIO = i2cClkGPIO;
+ sw_i2c_clk_gpio = clk_gpio;
/* Initialize the GPIO pin for the i2c Data Register */
- g_i2cDataGPIODataReg = GPIO_DATA_SM750LE;
- g_i2cDataGPIODataDirReg = GPIO_DATA_DIRECTION_SM750LE;
+ sw_i2c_data_gpio_data_reg = GPIO_DATA_SM750LE;
+ sw_i2c_data_gpio_data_dir_reg = GPIO_DATA_DIRECTION_SM750LE;
/* Initialize the Data GPIO Offset */
- g_i2cDataGPIO = i2cDataGPIO;
+ sw_i2c_data_gpio = data_gpio;
/* Note that SM750LE don't have GPIO MUX and power is always on */
/* Clear the i2c lines. */
for (i = 0; i < 9; i++)
- swI2CStop();
+ sw_i2c_stop();
return 0;
}
@@ -379,55 +382,58 @@ static long swI2CInit_SM750LE(unsigned char i2cClkGPIO,
* This function initializes the i2c attributes and bus
*
* Parameters:
- * i2cClkGPIO - The GPIO pin to be used as i2c SCL
- * i2cDataGPIO - The GPIO pin to be used as i2c SDA
+ * clk_gpio - The GPIO pin to be used as i2c SCL
+ * data_gpio - The GPIO pin to be used as i2c SDA
*
* Return Value:
* -1 - Fail to initialize the i2c
* 0 - Success
*/
-long swI2CInit(
- unsigned char i2cClkGPIO,
- unsigned char i2cDataGPIO
+long sm750_sw_i2c_init(
+ unsigned char clk_gpio,
+ unsigned char data_gpio
)
{
int i;
- /* Return 0 if the GPIO pins to be used is out of range. The range is only from [0..63] */
- if ((i2cClkGPIO > 31) || (i2cDataGPIO > 31))
+ /*
+ * Return 0 if the GPIO pins to be used is out of range. The
+ * range is only from [0..63]
+ */
+ if ((clk_gpio > 31) || (data_gpio > 31))
return -1;
if (getChipType() == SM750LE)
- return swI2CInit_SM750LE(i2cClkGPIO, i2cDataGPIO);
+ return sm750le_i2c_init(clk_gpio, data_gpio);
/* Initialize the GPIO pin for the i2c Clock Register */
- g_i2cClkGPIOMuxReg = GPIO_MUX;
- g_i2cClkGPIODataReg = GPIO_DATA;
- g_i2cClkGPIODataDirReg = GPIO_DATA_DIRECTION;
+ sw_i2c_clk_gpio_mux_reg = GPIO_MUX;
+ sw_i2c_clk_gpio_data_reg = GPIO_DATA;
+ sw_i2c_clk_gpio_data_dir_reg = GPIO_DATA_DIRECTION;
/* Initialize the Clock GPIO Offset */
- g_i2cClockGPIO = i2cClkGPIO;
+ sw_i2c_clk_gpio = clk_gpio;
/* Initialize the GPIO pin for the i2c Data Register */
- g_i2cDataGPIOMuxReg = GPIO_MUX;
- g_i2cDataGPIODataReg = GPIO_DATA;
- g_i2cDataGPIODataDirReg = GPIO_DATA_DIRECTION;
+ sw_i2c_data_gpio_mux_reg = GPIO_MUX;
+ sw_i2c_data_gpio_data_reg = GPIO_DATA;
+ sw_i2c_data_gpio_data_dir_reg = GPIO_DATA_DIRECTION;
/* Initialize the Data GPIO Offset */
- g_i2cDataGPIO = i2cDataGPIO;
+ sw_i2c_data_gpio = data_gpio;
/* Enable the GPIO pins for the i2c Clock and Data (GPIO MUX) */
- POKE32(g_i2cClkGPIOMuxReg,
- PEEK32(g_i2cClkGPIOMuxReg) & ~(1 << g_i2cClockGPIO));
- POKE32(g_i2cDataGPIOMuxReg,
- PEEK32(g_i2cDataGPIOMuxReg) & ~(1 << g_i2cDataGPIO));
+ POKE32(sw_i2c_clk_gpio_mux_reg,
+ PEEK32(sw_i2c_clk_gpio_mux_reg) & ~(1 << sw_i2c_clk_gpio));
+ POKE32(sw_i2c_data_gpio_mux_reg,
+ PEEK32(sw_i2c_data_gpio_mux_reg) & ~(1 << sw_i2c_data_gpio));
/* Enable GPIO power */
enableGPIO(1);
/* Clear the i2c lines. */
for (i = 0; i < 9; i++)
- swI2CStop();
+ sw_i2c_stop();
return 0;
}
@@ -436,36 +442,36 @@ long swI2CInit(
* This function reads the slave device's register
*
* Parameters:
- * deviceAddress - i2c Slave device address which register
+ * addr - i2c Slave device address which register
* to be read from
- * registerIndex - Slave device's register to be read
+ * reg - Slave device's register to be read
*
* Return Value:
* Register value
*/
-unsigned char swI2CReadReg(
- unsigned char deviceAddress,
- unsigned char registerIndex
+unsigned char sm750_sw_i2c_read_reg(
+ unsigned char addr,
+ unsigned char reg
)
{
unsigned char data;
/* Send the Start signal */
- swI2CStart();
+ sw_i2c_start();
/* Send the device address */
- swI2CWriteByte(deviceAddress);
+ sw_i2c_write_byte(addr);
/* Send the register index */
- swI2CWriteByte(registerIndex);
+ sw_i2c_write_byte(reg);
/* Get the bus again and get the data from the device read address */
- swI2CStart();
- swI2CWriteByte(deviceAddress + 1);
- data = swI2CReadByte(1);
+ sw_i2c_start();
+ sw_i2c_write_byte(addr + 1);
+ data = sw_i2c_read_byte(1);
/* Stop swI2C and release the bus */
- swI2CStop();
+ sw_i2c_stop();
return data;
}
@@ -474,37 +480,37 @@ unsigned char swI2CReadReg(
* This function writes a value to the slave device's register
*
* Parameters:
- * deviceAddress - i2c Slave device address which register
+ * addr - i2c Slave device address which register
* to be written
- * registerIndex - Slave device's register to be written
+ * reg - Slave device's register to be written
* data - Data to be written to the register
*
* Result:
* 0 - Success
* -1 - Fail
*/
-long swI2CWriteReg(
- unsigned char deviceAddress,
- unsigned char registerIndex,
+long sm750_sw_i2c_write_reg(
+ unsigned char addr,
+ unsigned char reg,
unsigned char data
)
{
- long returnValue = 0;
+ long ret = 0;
/* Send the Start signal */
- swI2CStart();
+ sw_i2c_start();
/* Send the device address and read the data. All should return success
in order for the writing processed to be successful
*/
- if ((swI2CWriteByte(deviceAddress) != 0) ||
- (swI2CWriteByte(registerIndex) != 0) ||
- (swI2CWriteByte(data) != 0)) {
- returnValue = -1;
+ if ((sw_i2c_write_byte(addr) != 0) ||
+ (sw_i2c_write_byte(reg) != 0) ||
+ (sw_i2c_write_byte(data) != 0)) {
+ ret = -1;
}
/* Stop i2c and release the bus */
- swI2CStop();
+ sw_i2c_stop();
- return returnValue;
+ return ret;
}
diff --git a/drivers/staging/sm750fb/ddk750_swi2c.h b/drivers/staging/sm750fb/ddk750_swi2c.h
index 4af2b7aa1..b53629cda 100644
--- a/drivers/staging/sm750fb/ddk750_swi2c.h
+++ b/drivers/staging/sm750fb/ddk750_swi2c.h
@@ -28,65 +28,44 @@
* -1 - Fail to initialize the i2c
* 0 - Success
*/
-long swI2CInit(
- unsigned char i2cClkGPIO,
- unsigned char i2cDataGPIO
+long sm750_sw_i2c_init(
+ unsigned char clk_gpio,
+ unsigned char data_gpio
);
/*
* This function reads the slave device's register
*
* Parameters:
- * deviceAddress - i2c Slave device address which register
+ * addr - i2c Slave device address which register
* to be read from
- * registerIndex - Slave device's register to be read
+ * reg - Slave device's register to be read
*
* Return Value:
* Register value
*/
-unsigned char swI2CReadReg(
- unsigned char deviceAddress,
- unsigned char registerIndex
+unsigned char sm750_sw_i2c_read_reg(
+ unsigned char addr,
+ unsigned char reg
);
/*
* This function writes a value to the slave device's register
*
* Parameters:
- * deviceAddress - i2c Slave device address which register
+ * addr - i2c Slave device address which register
* to be written
- * registerIndex - Slave device's register to be written
+ * reg - Slave device's register to be written
* data - Data to be written to the register
*
* Result:
* 0 - Success
* -1 - Fail
*/
-long swI2CWriteReg(
- unsigned char deviceAddress,
- unsigned char registerIndex,
+long sm750_sw_i2c_write_reg(
+ unsigned char addr,
+ unsigned char reg,
unsigned char data
);
-/*
- * These two functions toggle the data on the SCL and SDA I2C lines.
- * The use of these two functions is not recommended unless it is necessary.
- */
-
-/*
- * This function set/reset the SCL GPIO pin
- *
- * Parameters:
- * value - Bit value to set to the SCL or SDA (0 = low, 1 = high)
- */
-void swI2CSCL(unsigned char value);
-
-/*
- * This function set/reset the SDA GPIO pin
- *
- * Parameters:
- * value - Bit value to set to the SCL or SDA (0 = low, 1 = high)
- */
-void swI2CSDA(unsigned char value);
-
#endif /* _SWI2C_H_ */
diff --git a/drivers/staging/sm750fb/sm750.c b/drivers/staging/sm750fb/sm750.c
index 07f8afd2d..860e1c288 100644
--- a/drivers/staging/sm750fb/sm750.c
+++ b/drivers/staging/sm750fb/sm750.c
@@ -1,31 +1,28 @@
-#include<linux/kernel.h>
-#include<linux/module.h>
-#include<linux/errno.h>
-#include<linux/string.h>
-#include<linux/mm.h>
-#include<linux/slab.h>
-#include<linux/delay.h>
-#include<linux/fb.h>
-#include<linux/ioport.h>
-#include<linux/init.h>
-#include<linux/pci.h>
-#include<linux/mm_types.h>
-#include<linux/vmalloc.h>
-#include<linux/pagemap.h>
-#include<linux/screen_info.h>
-#include<linux/vmalloc.h>
-#include<linux/pagemap.h>
+#include <linux/kernel.h>
+#include <linux/module.h>
+#include <linux/errno.h>
+#include <linux/string.h>
+#include <linux/mm.h>
+#include <linux/slab.h>
+#include <linux/delay.h>
+#include <linux/fb.h>
+#include <linux/ioport.h>
+#include <linux/init.h>
+#include <linux/pci.h>
+#include <linux/mm_types.h>
+#include <linux/vmalloc.h>
+#include <linux/pagemap.h>
+#include <linux/screen_info.h>
+#include <linux/vmalloc.h>
+#include <linux/pagemap.h>
#include <linux/console.h>
#include <asm/fb.h>
#include "sm750.h"
-#include "sm750_hw.h"
#include "sm750_accel.h"
#include "sm750_cursor.h"
#include "modedb.h"
-int smi_indent;
-
/*
* #ifdef __BIG_ENDIAN
* ssize_t lynxfb_ops_write(struct fb_info *info, const char __user *buf,
@@ -35,10 +32,6 @@ int smi_indent;
* #endif
*/
-typedef void (*PROC_SPEC_SETUP)(struct lynx_share*, char *);
-typedef int (*PROC_SPEC_MAP)(struct lynx_share*, struct pci_dev*);
-typedef int (*PROC_SPEC_INITHW)(struct lynx_share*, struct pci_dev*);
-
/* common var for all device */
static int g_hwcursor = 1;
static int g_noaccel;
@@ -129,16 +122,16 @@ static int lynxfb_ops_cursor(struct fb_info *info, struct fb_cursor *fbcursor)
return -ENXIO;
}
- cursor->disable(cursor);
+ hw_cursor_disable(cursor);
if (fbcursor->set & FB_CUR_SETSIZE)
- cursor->setSize(cursor,
- fbcursor->image.width,
- fbcursor->image.height);
+ hw_cursor_setSize(cursor,
+ fbcursor->image.width,
+ fbcursor->image.height);
if (fbcursor->set & FB_CUR_SETPOS)
- cursor->setPos(cursor,
- fbcursor->image.dx - info->var.xoffset,
- fbcursor->image.dy - info->var.yoffset);
+ hw_cursor_setPos(cursor,
+ fbcursor->image.dx - info->var.xoffset,
+ fbcursor->image.dy - info->var.yoffset);
if (fbcursor->set & FB_CUR_SETCMAP) {
/* get the 16bit color of kernel means */
@@ -152,18 +145,18 @@ static int lynxfb_ops_cursor(struct fb_info *info, struct fb_cursor *fbcursor)
((info->cmap.green[fbcursor->image.bg_color] & 0xfc00) >> 5) |
((info->cmap.blue[fbcursor->image.bg_color] & 0xf800) >> 11);
- cursor->setColor(cursor, fg, bg);
+ hw_cursor_setColor(cursor, fg, bg);
}
if (fbcursor->set & (FB_CUR_SETSHAPE | FB_CUR_SETIMAGE)) {
- cursor->setData(cursor,
- fbcursor->rop,
- fbcursor->image.data,
- fbcursor->mask);
+ hw_cursor_setData(cursor,
+ fbcursor->rop,
+ fbcursor->image.data,
+ fbcursor->mask);
}
if (fbcursor->enable)
- cursor->enable(cursor);
+ hw_cursor_enable(cursor);
return 0;
}
@@ -172,7 +165,7 @@ static void lynxfb_ops_fillrect(struct fb_info *info,
const struct fb_fillrect *region)
{
struct lynxfb_par *par;
- struct lynx_share *share;
+ struct sm750_dev *sm750_dev;
unsigned int base, pitch, Bpp, rop;
u32 color;
@@ -180,7 +173,7 @@ static void lynxfb_ops_fillrect(struct fb_info *info,
return;
par = info->par;
- share = par->share;
+ sm750_dev = par->dev;
/*
* each time 2d function begin to work,below three variable always need
@@ -198,27 +191,27 @@ static void lynxfb_ops_fillrect(struct fb_info *info,
* If not use spin_lock,system will die if user load driver
* and immediately unload driver frequently (dual)
*/
- if (share->dual)
- spin_lock(&share->slock);
-
- share->accel.de_fillrect(&share->accel,
- base, pitch, Bpp,
- region->dx, region->dy,
- region->width, region->height,
- color, rop);
- if (share->dual)
- spin_unlock(&share->slock);
+ if (sm750_dev->dual)
+ spin_lock(&sm750_dev->slock);
+
+ sm750_dev->accel.de_fillrect(&sm750_dev->accel,
+ base, pitch, Bpp,
+ region->dx, region->dy,
+ region->width, region->height,
+ color, rop);
+ if (sm750_dev->dual)
+ spin_unlock(&sm750_dev->slock);
}
static void lynxfb_ops_copyarea(struct fb_info *info,
const struct fb_copyarea *region)
{
struct lynxfb_par *par;
- struct lynx_share *share;
+ struct sm750_dev *sm750_dev;
unsigned int base, pitch, Bpp;
par = info->par;
- share = par->share;
+ sm750_dev = par->dev;
/*
* each time 2d function begin to work,below three variable always need
@@ -232,15 +225,16 @@ static void lynxfb_ops_copyarea(struct fb_info *info,
* If not use spin_lock, system will die if user load driver
* and immediately unload driver frequently (dual)
*/
- if (share->dual)
- spin_lock(&share->slock);
-
- share->accel.de_copyarea(&share->accel,
- base, pitch, region->sx, region->sy,
- base, pitch, Bpp, region->dx, region->dy,
- region->width, region->height, HW_ROP2_COPY);
- if (share->dual)
- spin_unlock(&share->slock);
+ if (sm750_dev->dual)
+ spin_lock(&sm750_dev->slock);
+
+ sm750_dev->accel.de_copyarea(&sm750_dev->accel,
+ base, pitch, region->sx, region->sy,
+ base, pitch, Bpp, region->dx, region->dy,
+ region->width, region->height,
+ HW_ROP2_COPY);
+ if (sm750_dev->dual)
+ spin_unlock(&sm750_dev->slock);
}
static void lynxfb_ops_imageblit(struct fb_info *info,
@@ -249,10 +243,10 @@ static void lynxfb_ops_imageblit(struct fb_info *info,
unsigned int base, pitch, Bpp;
unsigned int fgcol, bgcol;
struct lynxfb_par *par;
- struct lynx_share *share;
+ struct sm750_dev *sm750_dev;
par = info->par;
- share = par->share;
+ sm750_dev = par->dev;
/*
* each time 2d function begin to work,below three variable always need
* be set, seems we can put them together in some place
@@ -280,17 +274,17 @@ static void lynxfb_ops_imageblit(struct fb_info *info,
* If not use spin_lock, system will die if user load driver
* and immediately unload driver frequently (dual)
*/
- if (share->dual)
- spin_lock(&share->slock);
-
- share->accel.de_imageblit(&share->accel,
- image->data, image->width >> 3, 0,
- base, pitch, Bpp,
- image->dx, image->dy,
- image->width, image->height,
- fgcol, bgcol, HW_ROP2_COPY);
- if (share->dual)
- spin_unlock(&share->slock);
+ if (sm750_dev->dual)
+ spin_lock(&sm750_dev->slock);
+
+ sm750_dev->accel.de_imageblit(&sm750_dev->accel,
+ image->data, image->width >> 3, 0,
+ base, pitch, Bpp,
+ image->dx, image->dy,
+ image->width, image->height,
+ fgcol, bgcol, HW_ROP2_COPY);
+ if (sm750_dev->dual)
+ spin_unlock(&sm750_dev->slock);
}
static int lynxfb_ops_pan_display(struct fb_var_screeninfo *var,
@@ -304,13 +298,12 @@ static int lynxfb_ops_pan_display(struct fb_var_screeninfo *var,
par = info->par;
crtc = &par->crtc;
- return crtc->proc_panDisplay(crtc, var, info);
+ return hw_sm750_pan_display(crtc, var, info);
}
static int lynxfb_ops_set_par(struct fb_info *info)
{
struct lynxfb_par *par;
- struct lynx_share *share;
struct lynxfb_crtc *crtc;
struct lynxfb_output *output;
struct fb_var_screeninfo *var;
@@ -323,7 +316,6 @@ static int lynxfb_ops_set_par(struct fb_info *info)
ret = 0;
par = info->par;
- share = par->share;
crtc = &par->crtc;
output = &par->output;
var = &info->var;
@@ -331,7 +323,7 @@ static int lynxfb_ops_set_par(struct fb_info *info)
/* fix structur is not so FIX ... */
line_length = var->xres_virtual * var->bits_per_pixel / 8;
- line_length = PADDING(crtc->line_pad, line_length);
+ line_length = ALIGN(line_length, crtc->line_pad);
fix->line_length = line_length;
pr_info("fix->line_length = %d\n", fix->line_length);
@@ -384,9 +376,9 @@ static int lynxfb_ops_set_par(struct fb_info *info)
pr_err("pixel bpp format not satisfied\n.");
return ret;
}
- ret = crtc->proc_setMode(crtc, var, fix);
+ ret = hw_sm750_crtc_setMode(crtc, var, fix);
if (!ret)
- ret = output->proc_setMode(output, var, fix);
+ ret = hw_sm750_output_setMode(output, var, fix);
return ret;
}
@@ -402,14 +394,14 @@ static inline unsigned int chan_to_field(unsigned int chan,
static int lynxfb_suspend(struct pci_dev *pdev, pm_message_t mesg)
{
struct fb_info *info;
- struct lynx_share *share;
+ struct sm750_dev *sm750_dev;
int ret;
if (mesg.event == pdev->dev.power.power_state.event)
return 0;
ret = 0;
- share = pci_get_drvdata(pdev);
+ sm750_dev = pci_get_drvdata(pdev);
switch (mesg.event) {
case PM_EVENT_FREEZE:
case PM_EVENT_PRETHAW:
@@ -419,11 +411,11 @@ static int lynxfb_suspend(struct pci_dev *pdev, pm_message_t mesg)
console_lock();
if (mesg.event & PM_EVENT_SLEEP) {
- info = share->fbinfo[0];
+ info = sm750_dev->fbinfo[0];
if (info)
/* 1 means do suspend */
fb_set_suspend(info, 1);
- info = share->fbinfo[1];
+ info = sm750_dev->fbinfo[1];
if (info)
/* 1 means do suspend */
fb_set_suspend(info, 1);
@@ -434,10 +426,6 @@ static int lynxfb_suspend(struct pci_dev *pdev, pm_message_t mesg)
return ret;
}
- /* set chip to sleep mode */
- if (share->suspend)
- (*share->suspend)(share);
-
pci_disable_device(pdev);
ret = pci_set_power_state(pdev, pci_choose_state(pdev, mesg));
if (ret) {
@@ -454,7 +442,7 @@ static int lynxfb_suspend(struct pci_dev *pdev, pm_message_t mesg)
static int lynxfb_resume(struct pci_dev *pdev)
{
struct fb_info *info;
- struct lynx_share *share;
+ struct sm750_dev *sm750_dev;
struct lynxfb_par *par;
struct lynxfb_crtc *crtc;
@@ -463,7 +451,7 @@ static int lynxfb_resume(struct pci_dev *pdev)
int ret;
ret = 0;
- share = pci_get_drvdata(pdev);
+ sm750_dev = pci_get_drvdata(pdev);
console_lock();
@@ -482,12 +470,10 @@ static int lynxfb_resume(struct pci_dev *pdev)
}
pci_set_master(pdev);
}
- if (share->resume)
- (*share->resume)(share);
- hw_sm750_inithw(share, pdev);
+ hw_sm750_inithw(sm750_dev, pdev);
- info = share->fbinfo[0];
+ info = sm750_dev->fbinfo[0];
if (info) {
par = info->par;
@@ -499,7 +485,7 @@ static int lynxfb_resume(struct pci_dev *pdev)
fb_set_suspend(info, 0);
}
- info = share->fbinfo[1];
+ info = sm750_dev->fbinfo[1];
if (info) {
par = info->par;
@@ -511,6 +497,7 @@ static int lynxfb_resume(struct pci_dev *pdev)
fb_set_suspend(info, 0);
}
+ pdev->dev.power.power_state.event = PM_EVENT_RESUME;
console_unlock();
return ret;
}
@@ -522,15 +509,11 @@ static int lynxfb_ops_check_var(struct fb_var_screeninfo *var,
struct lynxfb_par *par;
struct lynxfb_crtc *crtc;
struct lynxfb_output *output;
- struct lynx_share *share;
- int ret;
resource_size_t request;
par = info->par;
crtc = &par->crtc;
output = &par->output;
- share = par->share;
- ret = 0;
pr_debug("check var:%dx%d-%d\n",
var->xres,
@@ -539,18 +522,6 @@ static int lynxfb_ops_check_var(struct fb_var_screeninfo *var,
switch (var->bits_per_pixel) {
case 8:
- case 16:
- case 24: /* support 24 bpp for only lynx712/722/720 */
- case 32:
- break;
- default:
- pr_err("bpp %d not supported\n", var->bits_per_pixel);
- ret = -EINVAL;
- goto exit;
- }
-
- switch (var->bits_per_pixel) {
- case 8:
info->fix.visual = FB_VISUAL_PSEUDOCOLOR;
var->red.offset = 0;
var->red.length = 8;
@@ -583,8 +554,8 @@ static int lynxfb_ops_check_var(struct fb_var_screeninfo *var,
info->fix.visual = FB_VISUAL_TRUECOLOR;
break;
default:
- ret = -EINVAL;
- break;
+ pr_err("bpp %d not supported\n", var->bits_per_pixel);
+ return -EINVAL;
}
var->height = var->width = -1;
var->accel_flags = 0;/* FB_ACCELF_TEXT; */
@@ -593,18 +564,14 @@ static int lynxfb_ops_check_var(struct fb_var_screeninfo *var,
request = var->xres_virtual * (var->bits_per_pixel >> 3);
/* defaulty crtc->channel go with par->index */
- request = PADDING(crtc->line_pad, request);
+ request = ALIGN(request, crtc->line_pad);
request = request * var->yres_virtual;
if (crtc->vidmem_size < request) {
pr_err("not enough video memory for mode\n");
return -ENOMEM;
}
- ret = output->proc_checkMode(output, var);
- if (!ret)
- ret = crtc->proc_checkMode(crtc, var);
-exit:
- return ret;
+ return hw_sm750_crtc_checkMode(crtc, var);
}
static int lynxfb_ops_setcolreg(unsigned regno,
@@ -637,7 +604,7 @@ static int lynxfb_ops_setcolreg(unsigned regno,
red >>= 8;
green >>= 8;
blue >>= 8;
- ret = crtc->proc_setColReg(crtc, regno, red, green, blue);
+ ret = hw_sm750_setColReg(crtc, regno, red, green, blue);
goto exit;
}
@@ -675,68 +642,57 @@ static int lynxfb_ops_blank(int blank, struct fb_info *info)
static int sm750fb_set_drv(struct lynxfb_par *par)
{
int ret;
- struct lynx_share *share;
- struct sm750_share *spec_share;
+ struct sm750_dev *sm750_dev;
struct lynxfb_output *output;
struct lynxfb_crtc *crtc;
ret = 0;
- share = par->share;
- spec_share = container_of(share, struct sm750_share, share);
+ sm750_dev = par->dev;
output = &par->output;
crtc = &par->crtc;
- crtc->vidmem_size = (share->dual) ? share->vidmem_size >> 1 :
- share->vidmem_size;
+ crtc->vidmem_size = (sm750_dev->dual) ? sm750_dev->vidmem_size >> 1 :
+ sm750_dev->vidmem_size;
/* setup crtc and output member */
- spec_share->hwCursor = g_hwcursor;
+ sm750_dev->hwCursor = g_hwcursor;
- crtc->proc_setMode = hw_sm750_crtc_setMode;
- crtc->proc_checkMode = hw_sm750_crtc_checkMode;
- crtc->proc_setColReg = hw_sm750_setColReg;
- crtc->proc_panDisplay = hw_sm750_pan_display;
- crtc->clear = hw_sm750_crtc_clear;
crtc->line_pad = 16;
crtc->xpanstep = 8;
crtc->ypanstep = 1;
crtc->ywrapstep = 0;
- output->proc_setMode = hw_sm750_output_setMode;
- output->proc_checkMode = hw_sm750_output_checkMode;
-
- output->proc_setBLANK = (share->revid == SM750LE_REVISION_ID) ?
+ output->proc_setBLANK = (sm750_dev->revid == SM750LE_REVISION_ID) ?
hw_sm750le_setBLANK : hw_sm750_setBLANK;
- output->clear = hw_sm750_output_clear;
/* chip specific phase */
- share->accel.de_wait = (share->revid == SM750LE_REVISION_ID) ?
- hw_sm750le_deWait : hw_sm750_deWait;
- switch (spec_share->state.dataflow) {
+ sm750_dev->accel.de_wait = (sm750_dev->revid == SM750LE_REVISION_ID) ?
+ hw_sm750le_deWait : hw_sm750_deWait;
+ switch (sm750_dev->dataflow) {
case sm750_simul_pri:
output->paths = sm750_pnc;
crtc->channel = sm750_primary;
crtc->oScreen = 0;
- crtc->vScreen = share->pvMem;
+ crtc->vScreen = sm750_dev->pvMem;
pr_info("use simul primary mode\n");
break;
case sm750_simul_sec:
output->paths = sm750_pnc;
crtc->channel = sm750_secondary;
crtc->oScreen = 0;
- crtc->vScreen = share->pvMem;
+ crtc->vScreen = sm750_dev->pvMem;
break;
case sm750_dual_normal:
if (par->index == 0) {
output->paths = sm750_panel;
crtc->channel = sm750_primary;
crtc->oScreen = 0;
- crtc->vScreen = share->pvMem;
+ crtc->vScreen = sm750_dev->pvMem;
} else {
output->paths = sm750_crt;
crtc->channel = sm750_secondary;
/* not consider of padding stuffs for oScreen,need fix */
- crtc->oScreen = (share->vidmem_size >> 1);
- crtc->vScreen = share->pvMem + crtc->oScreen;
+ crtc->oScreen = (sm750_dev->vidmem_size >> 1);
+ crtc->vScreen = sm750_dev->pvMem + crtc->oScreen;
}
break;
case sm750_dual_swap:
@@ -744,13 +700,13 @@ static int sm750fb_set_drv(struct lynxfb_par *par)
output->paths = sm750_panel;
crtc->channel = sm750_secondary;
crtc->oScreen = 0;
- crtc->vScreen = share->pvMem;
+ crtc->vScreen = sm750_dev->pvMem;
} else {
output->paths = sm750_crt;
crtc->channel = sm750_primary;
/* not consider of padding stuffs for oScreen,need fix */
- crtc->oScreen = (share->vidmem_size >> 1);
- crtc->vScreen = share->pvMem + crtc->oScreen;
+ crtc->oScreen = (sm750_dev->vidmem_size >> 1);
+ crtc->vScreen = sm750_dev->pvMem + crtc->oScreen;
}
break;
default:
@@ -777,7 +733,7 @@ static int lynxfb_set_fbinfo(struct fb_info *info, int index)
{
int i;
struct lynxfb_par *par;
- struct lynx_share *share;
+ struct sm750_dev *sm750_dev;
struct lynxfb_crtc *crtc;
struct lynxfb_output *output;
struct fb_var_screeninfo *var;
@@ -801,7 +757,7 @@ static int lynxfb_set_fbinfo(struct fb_info *info, int index)
ret = 0;
par = (struct lynxfb_par *)info->par;
- share = par->share;
+ sm750_dev = par->dev;
crtc = &par->crtc;
output = &par->output;
var = &info->var;
@@ -818,28 +774,22 @@ static int lynxfb_set_fbinfo(struct fb_info *info, int index)
* must be set after crtc member initialized
*/
crtc->cursor.offset = crtc->oScreen + crtc->vidmem_size - 1024;
- crtc->cursor.mmio = share->pvReg + 0x800f0 + (int)crtc->channel * 0x140;
+ crtc->cursor.mmio = sm750_dev->pvReg +
+ 0x800f0 + (int)crtc->channel * 0x140;
pr_info("crtc->cursor.mmio = %p\n", crtc->cursor.mmio);
crtc->cursor.maxH = crtc->cursor.maxW = 64;
crtc->cursor.size = crtc->cursor.maxH * crtc->cursor.maxW * 2 / 8;
- crtc->cursor.disable = hw_cursor_disable;
- crtc->cursor.enable = hw_cursor_enable;
- crtc->cursor.setColor = hw_cursor_setColor;
- crtc->cursor.setPos = hw_cursor_setPos;
- crtc->cursor.setSize = hw_cursor_setSize;
- crtc->cursor.setData = hw_cursor_setData;
- crtc->cursor.vstart = share->pvMem + crtc->cursor.offset;
-
- crtc->cursor.share = share;
- memset_io(crtc->cursor.vstart, 0, crtc->cursor.size);
+ crtc->cursor.vstart = sm750_dev->pvMem + crtc->cursor.offset;
+
+ memset_io(crtc->cursor.vstart, 0, crtc->cursor.size);
if (!g_hwcursor) {
lynxfb_ops.fb_cursor = NULL;
- crtc->cursor.disable(&crtc->cursor);
+ hw_cursor_disable(&crtc->cursor);
}
/* set info->fbops, must be set before fb_find_mode */
- if (!share->accel_off) {
+ if (!sm750_dev->accel_off) {
/* use 2d acceleration */
lynxfb_ops.fb_fillrect = lynxfb_ops_fillrect;
lynxfb_ops.fb_copyarea = lynxfb_ops_copyarea;
@@ -903,8 +853,8 @@ static int lynxfb_set_fbinfo(struct fb_info *info, int index)
par->info = info;
/* set info */
- line_length = PADDING(crtc->line_pad,
- (var->xres_virtual * var->bits_per_pixel / 8));
+ line_length = ALIGN((var->xres_virtual * var->bits_per_pixel / 8),
+ crtc->line_pad);
info->pseudo_palette = &par->pseudo_palette[0];
info->screen_base = crtc->vScreen;
@@ -922,7 +872,7 @@ static int lynxfb_set_fbinfo(struct fb_info *info, int index)
strlcpy(fix->id, fixId[index], sizeof(fix->id));
- fix->smem_start = crtc->oScreen + share->vidmem_start;
+ fix->smem_start = crtc->oScreen + sm750_dev->vidmem_start;
pr_info("fix->smem_start = %lx\n", fix->smem_start);
/*
* according to mmap experiment from user space application,
@@ -935,9 +885,9 @@ static int lynxfb_set_fbinfo(struct fb_info *info, int index)
pr_info("fix->smem_len = %x\n", fix->smem_len);
info->screen_size = fix->smem_len;
fix->line_length = line_length;
- fix->mmio_start = share->vidreg_start;
+ fix->mmio_start = sm750_dev->vidreg_start;
pr_info("fix->mmio_start = %lx\n", fix->mmio_start);
- fix->mmio_len = share->vidreg_size;
+ fix->mmio_len = sm750_dev->vidreg_size;
pr_info("fix->mmio_len = %x\n", fix->mmio_len);
switch (var->bits_per_pixel) {
case 8:
@@ -976,27 +926,19 @@ exit:
}
/* chip specific g_option configuration routine */
-static void sm750fb_setup(struct lynx_share *share, char *src)
+static void sm750fb_setup(struct sm750_dev *sm750_dev, char *src)
{
- struct sm750_share *spec_share;
char *opt;
-#ifdef CAP_EXPENSION
- char *exp_res;
-#endif
int swap;
- spec_share = container_of(share, struct sm750_share, share);
-#ifdef CAP_EXPENSIION
- exp_res = NULL;
-#endif
swap = 0;
- spec_share->state.initParm.chip_clk = 0;
- spec_share->state.initParm.mem_clk = 0;
- spec_share->state.initParm.master_clk = 0;
- spec_share->state.initParm.powerMode = 0;
- spec_share->state.initParm.setAllEngOff = 0;
- spec_share->state.initParm.resetMemory = 1;
+ sm750_dev->initParm.chip_clk = 0;
+ sm750_dev->initParm.mem_clk = 0;
+ sm750_dev->initParm.master_clk = 0;
+ sm750_dev->initParm.powerMode = 0;
+ sm750_dev->initParm.setAllEngOff = 0;
+ sm750_dev->initParm.resetMemory = 1;
/* defaultly turn g_hwcursor on for both view */
g_hwcursor = 3;
@@ -1013,17 +955,13 @@ static void sm750fb_setup(struct lynx_share *share, char *src)
if (!strncmp(opt, "swap", strlen("swap")))
swap = 1;
else if (!strncmp(opt, "nocrt", strlen("nocrt")))
- spec_share->state.nocrt = 1;
+ sm750_dev->nocrt = 1;
else if (!strncmp(opt, "36bit", strlen("36bit")))
- spec_share->state.pnltype = sm750_doubleTFT;
+ sm750_dev->pnltype = sm750_doubleTFT;
else if (!strncmp(opt, "18bit", strlen("18bit")))
- spec_share->state.pnltype = sm750_dualTFT;
+ sm750_dev->pnltype = sm750_dualTFT;
else if (!strncmp(opt, "24bit", strlen("24bit")))
- spec_share->state.pnltype = sm750_24TFT;
-#ifdef CAP_EXPANSION
- else if (!strncmp(opt, "exp:", strlen("exp:")))
- exp_res = opt + strlen("exp:");
-#endif
+ sm750_dev->pnltype = sm750_24TFT;
else if (!strncmp(opt, "nohwc0", strlen("nohwc0")))
g_hwcursor &= ~0x1;
else if (!strncmp(opt, "nohwc1", strlen("nohwc1")))
@@ -1042,33 +980,25 @@ static void sm750fb_setup(struct lynx_share *share, char *src)
}
}
}
-#ifdef CAP_EXPANSION
- if (getExpRes(exp_res,
- &spec_share->state.xLCD,
- &spec_share->state.yLCD)) {
- /* seems exp_res is not valid */
- spec_share->state.xLCD = spec_share->state.yLCD = 0;
- }
-#endif
NO_PARAM:
- if (share->revid != SM750LE_REVISION_ID) {
- if (share->dual) {
+ if (sm750_dev->revid != SM750LE_REVISION_ID) {
+ if (sm750_dev->dual) {
if (swap)
- spec_share->state.dataflow = sm750_dual_swap;
+ sm750_dev->dataflow = sm750_dual_swap;
else
- spec_share->state.dataflow = sm750_dual_normal;
+ sm750_dev->dataflow = sm750_dual_normal;
} else {
if (swap)
- spec_share->state.dataflow = sm750_simul_sec;
+ sm750_dev->dataflow = sm750_simul_sec;
else
- spec_share->state.dataflow = sm750_simul_pri;
+ sm750_dev->dataflow = sm750_simul_pri;
}
} else {
/* SM750LE only have one crt channel */
- spec_share->state.dataflow = sm750_simul_sec;
+ sm750_dev->dataflow = sm750_simul_sec;
/* sm750le do not have complex attributes */
- spec_share->state.nocrt = 0;
+ sm750_dev->nocrt = 0;
}
}
@@ -1076,10 +1006,7 @@ static int lynxfb_pci_probe(struct pci_dev *pdev,
const struct pci_device_id *ent)
{
struct fb_info *info[] = {NULL, NULL};
- struct lynx_share *share = NULL;
-
- struct sm750_share *spec_share = NULL;
- size_t spec_offset = 0;
+ struct sm750_dev *sm750_dev = NULL;
int fbidx;
/* enable device */
@@ -1088,69 +1015,62 @@ static int lynxfb_pci_probe(struct pci_dev *pdev,
goto err_enable;
}
- /*
- * though offset of share in sm750_share is 0,
- * we use this marcro as the same
- */
- spec_offset = offsetof(struct sm750_share, share);
-
- spec_share = kzalloc(sizeof(*spec_share), GFP_KERNEL);
- if (!spec_share) {
+ sm750_dev = kzalloc(sizeof(*sm750_dev), GFP_KERNEL);
+ if (!sm750_dev) {
pr_err("Could not allocate memory for share.\n");
goto err_share;
}
- /* setting share structure */
- share = (struct lynx_share *)(&(spec_share->share));
- share->fbinfo[0] = share->fbinfo[1] = NULL;
- share->devid = pdev->device;
- share->revid = pdev->revision;
-
- pr_info("share->revid = %02x\n", share->revid);
- share->pdev = pdev;
- share->mtrr_off = g_nomtrr;
- share->mtrr.vram = 0;
- share->accel_off = g_noaccel;
- share->dual = g_dualview;
- spin_lock_init(&share->slock);
-
- if (!share->accel_off) {
+ sm750_dev->fbinfo[0] = sm750_dev->fbinfo[1] = NULL;
+ sm750_dev->devid = pdev->device;
+ sm750_dev->revid = pdev->revision;
+
+ pr_info("share->revid = %02x\n", sm750_dev->revid);
+ sm750_dev->pdev = pdev;
+ sm750_dev->mtrr_off = g_nomtrr;
+ sm750_dev->mtrr.vram = 0;
+ sm750_dev->accel_off = g_noaccel;
+ sm750_dev->dual = g_dualview;
+ spin_lock_init(&sm750_dev->slock);
+
+ if (!sm750_dev->accel_off) {
/*
* hook deInit and 2d routines, notes that below hw_xxx
* routine can work on most of lynx chips
* if some chip need specific function,
* please hook it in smXXX_set_drv routine
*/
- share->accel.de_init = hw_de_init;
- share->accel.de_fillrect = hw_fillrect;
- share->accel.de_copyarea = hw_copyarea;
- share->accel.de_imageblit = hw_imageblit;
+ sm750_dev->accel.de_init = hw_de_init;
+ sm750_dev->accel.de_fillrect = hw_fillrect;
+ sm750_dev->accel.de_copyarea = hw_copyarea;
+ sm750_dev->accel.de_imageblit = hw_imageblit;
pr_info("enable 2d acceleration\n");
} else {
pr_info("disable 2d acceleration\n");
}
/* call chip specific setup routine */
- sm750fb_setup(share, g_settings);
+ sm750fb_setup(sm750_dev, g_settings);
/* call chip specific mmap routine */
- if (hw_sm750_map(share, pdev)) {
+ if (hw_sm750_map(sm750_dev, pdev)) {
pr_err("Memory map failed\n");
goto err_map;
}
- if (!share->mtrr_off)
- share->mtrr.vram = arch_phys_wc_add(share->vidmem_start,
- share->vidmem_size);
+ if (!sm750_dev->mtrr_off)
+ sm750_dev->mtrr.vram = arch_phys_wc_add(sm750_dev->vidmem_start,
+ sm750_dev->vidmem_size);
- memset_io(share->pvMem, 0, share->vidmem_size);
+ memset_io(sm750_dev->pvMem, 0, sm750_dev->vidmem_size);
- pr_info("sm%3x mmio address = %p\n", share->devid, share->pvReg);
+ pr_info("sm%3x mmio address = %p\n", sm750_dev->devid,
+ sm750_dev->pvReg);
- pci_set_drvdata(pdev, share);
+ pci_set_drvdata(pdev, sm750_dev);
/* call chipInit routine */
- hw_sm750_inithw(share, pdev);
+ hw_sm750_inithw(sm750_dev, pdev);
/* allocate frame buffer info structor according to g_dualview */
fbidx = 0;
@@ -1167,9 +1087,9 @@ ALLOC_FB:
int errno;
pr_info("framebuffer #%d alloc okay\n", fbidx);
- share->fbinfo[fbidx] = info[fbidx];
+ sm750_dev->fbinfo[fbidx] = info[fbidx];
par = info[fbidx]->par;
- par->share = share;
+ par->dev = sm750_dev;
/* set fb_info structure */
if (lynxfb_set_fbinfo(info[fbidx], fbidx)) {
@@ -1197,7 +1117,7 @@ ALLOC_FB:
/* no dual view by far */
fbidx++;
- if (share->dual && fbidx < 2)
+ if (sm750_dev->dual && fbidx < 2)
goto ALLOC_FB;
return 0;
@@ -1212,7 +1132,7 @@ err_info0_set:
framebuffer_release(info[0]);
err_info0_alloc:
err_map:
- kfree(spec_share);
+ kfree(sm750_dev);
err_share:
err_enable:
return -ENODEV;
@@ -1221,34 +1141,29 @@ err_enable:
static void lynxfb_pci_remove(struct pci_dev *pdev)
{
struct fb_info *info;
- struct lynx_share *share;
- void *spec_share;
+ struct sm750_dev *sm750_dev;
struct lynxfb_par *par;
int cnt;
cnt = 2;
- share = pci_get_drvdata(pdev);
+ sm750_dev = pci_get_drvdata(pdev);
while (cnt-- > 0) {
- info = share->fbinfo[cnt];
+ info = sm750_dev->fbinfo[cnt];
if (!info)
continue;
par = info->par;
unregister_framebuffer(info);
- /* clean crtc & output allocations */
- par->crtc.clear(&par->crtc);
- par->output.clear(&par->output);
/* release frame buffer */
framebuffer_release(info);
}
- arch_phys_wc_del(share->mtrr.vram);
+ arch_phys_wc_del(sm750_dev->mtrr.vram);
- iounmap(share->pvReg);
- iounmap(share->pvMem);
- spec_share = container_of(share, struct sm750_share, share);
+ iounmap(sm750_dev->pvReg);
+ iounmap(sm750_dev->pvMem);
kfree(g_settings);
- kfree(spec_share);
+ kfree(sm750_dev);
pci_set_drvdata(pdev, NULL);
}
diff --git a/drivers/staging/sm750fb/sm750.h b/drivers/staging/sm750fb/sm750.h
index 5bc445571..b0a93cdc7 100644
--- a/drivers/staging/sm750fb/sm750.h
+++ b/drivers/staging/sm750fb/sm750.h
@@ -1,18 +1,51 @@
#ifndef LYNXDRV_H_
#define LYNXDRV_H_
-
-
#define FB_ACCEL_SMI 0xab
-/* please use revision id to distinguish sm750le and sm750*/
-#define SPC_SM750 0
-#define MB(x) ((x)<<20)
#define MHZ(x) ((x) * 1000000)
-/* align should be 2,4,8,16 */
-#define PADDING(align, data) (((data)+(align)-1)&(~((align) - 1)))
-extern int smi_indent;
+#define DEFAULT_SM750_CHIP_CLOCK 290
+#define DEFAULT_SM750LE_CHIP_CLOCK 333
+#ifndef SM750LE_REVISION_ID
+#define SM750LE_REVISION_ID ((unsigned char)0xfe)
+#endif
+
+enum sm750_pnltype {
+ sm750_24TFT = 0, /* 24bit tft */
+ sm750_dualTFT = 2, /* dual 18 bit tft */
+ sm750_doubleTFT = 1, /* 36 bit double pixel tft */
+};
+
+/* vga channel is not concerned */
+enum sm750_dataflow {
+ sm750_simul_pri, /* primary => all head */
+ sm750_simul_sec, /* secondary => all head */
+ sm750_dual_normal, /* primary => panel head and secondary => crt */
+ sm750_dual_swap, /* primary => crt head and secondary => panel */
+};
+
+enum sm750_channel {
+ sm750_primary = 0,
+ /* enum value equal to the register filed data */
+ sm750_secondary = 1,
+};
+
+enum sm750_path {
+ sm750_panel = 1,
+ sm750_crt = 2,
+ sm750_pnc = 3, /* panel and crt */
+};
+
+struct init_status {
+ ushort powerMode;
+ /* below three clocks are in unit of MHZ*/
+ ushort chip_clk;
+ ushort mem_clk;
+ ushort master_clk;
+ ushort setAllEngOff;
+ ushort resetMemory;
+};
struct lynx_accel {
/* base virtual address of DPR registers */
@@ -38,10 +71,7 @@ struct lynx_accel {
};
-/* lynx_share stands for a presentation of two frame buffer
- that use one smi adaptor , it is similar to a basic class of C++
-*/
-struct lynx_share {
+struct sm750_dev {
/* common members */
u16 devid;
u8 revid;
@@ -50,10 +80,10 @@ struct lynx_share {
struct lynx_accel accel;
int accel_off;
int dual;
- int mtrr_off;
- struct{
- int vram;
- } mtrr;
+ int mtrr_off;
+ struct{
+ int vram;
+ } mtrr;
/* all smi graphic adaptor got below attributes */
unsigned long vidmem_start;
unsigned long vidreg_start;
@@ -63,9 +93,19 @@ struct lynx_share {
unsigned char __iomem *pvMem;
/* locks*/
spinlock_t slock;
- /* function pointers */
- void (*suspend)(struct lynx_share *);
- void (*resume)(struct lynx_share *);
+
+ struct init_status initParm;
+ enum sm750_pnltype pnltype;
+ enum sm750_dataflow dataflow;
+ int nocrt;
+
+ /*
+ * 0: no hardware cursor
+ * 1: primary crtc hw cursor enabled,
+ * 2: secondary crtc hw cursor enabled
+ * 3: both ctrc hw cursor enabled
+ */
+ int hwCursor;
};
struct lynx_cursor {
@@ -81,15 +121,6 @@ struct lynx_cursor {
int offset;
/* mmio addr of hw cursor */
volatile char __iomem *mmio;
- /* the lynx_share of this adaptor */
- struct lynx_share *share;
- /* proc_routines */
- void (*enable)(struct lynx_cursor *);
- void (*disable)(struct lynx_cursor *);
- void (*setSize)(struct lynx_cursor *, int, int);
- void (*setPos)(struct lynx_cursor *, int, int);
- void (*setColor)(struct lynx_cursor *, u32, u32);
- void (*setData)(struct lynx_cursor *, u16, const u8*, const u8*);
};
struct lynxfb_crtc {
@@ -108,17 +139,6 @@ struct lynxfb_crtc {
void *priv;
- int (*proc_setMode)(struct lynxfb_crtc*,
- struct fb_var_screeninfo*,
- struct fb_fix_screeninfo*);
-
- int (*proc_checkMode)(struct lynxfb_crtc*, struct fb_var_screeninfo*);
- int (*proc_setColReg)(struct lynxfb_crtc*, ushort, ushort, ushort, ushort);
- void (*clear)(struct lynxfb_crtc *);
- /* pan display */
- int (*proc_panDisplay)(struct lynxfb_crtc *,
- const struct fb_var_screeninfo *,
- const struct fb_info *);
/* cursor information */
struct lynx_cursor cursor;
};
@@ -140,13 +160,7 @@ struct lynxfb_output {
*/
void *priv;
- int (*proc_setMode)(struct lynxfb_output*,
- struct fb_var_screeninfo*,
- struct fb_fix_screeninfo*);
-
- int (*proc_checkMode)(struct lynxfb_output*, struct fb_var_screeninfo*);
int (*proc_setBLANK)(struct lynxfb_output*, int);
- void (*clear)(struct lynxfb_output *);
};
struct lynxfb_par {
@@ -156,20 +170,9 @@ struct lynxfb_par {
struct lynxfb_crtc crtc;
struct lynxfb_output output;
struct fb_info *info;
- struct lynx_share *share;
+ struct sm750_dev *dev;
};
-#ifndef offsetof
-#define offsetof(TYPE, MEMBER) ((size_t) &((TYPE *)0)->MEMBER)
-#endif
-
-
-#define PS_TO_HZ(ps) \
- ({ \
- unsigned long long hz = 1000*1000*1000*1000ULL; \
- do_div(hz, ps); \
- (unsigned long)hz; })
-
static inline unsigned long ps_to_hz(unsigned int psvalue)
{
unsigned long long numerator = 1000*1000*1000*1000ULL;
@@ -178,5 +181,22 @@ static inline unsigned long ps_to_hz(unsigned int psvalue)
return (unsigned long)numerator;
}
+int hw_sm750_map(struct sm750_dev *sm750_dev, struct pci_dev *pdev);
+int hw_sm750_inithw(struct sm750_dev*, struct pci_dev *);
+void hw_sm750_initAccel(struct sm750_dev *);
+int hw_sm750_deWait(void);
+int hw_sm750le_deWait(void);
+
+int hw_sm750_output_setMode(struct lynxfb_output*, struct fb_var_screeninfo*,
+ struct fb_fix_screeninfo*);
+int hw_sm750_crtc_checkMode(struct lynxfb_crtc*, struct fb_var_screeninfo*);
+int hw_sm750_crtc_setMode(struct lynxfb_crtc*, struct fb_var_screeninfo*,
+ struct fb_fix_screeninfo*);
+int hw_sm750_setColReg(struct lynxfb_crtc*, ushort, ushort, ushort, ushort);
+int hw_sm750_setBLANK(struct lynxfb_output*, int);
+int hw_sm750le_setBLANK(struct lynxfb_output*, int);
+int hw_sm750_pan_display(struct lynxfb_crtc *crtc,
+ const struct fb_var_screeninfo *var,
+ const struct fb_info *info);
#endif
diff --git a/drivers/staging/sm750fb/sm750_accel.c b/drivers/staging/sm750fb/sm750_accel.c
index 1dd06a2e4..43e597259 100644
--- a/drivers/staging/sm750fb/sm750_accel.c
+++ b/drivers/staging/sm750fb/sm750_accel.c
@@ -1,19 +1,19 @@
-#include<linux/module.h>
-#include<linux/kernel.h>
-#include<linux/errno.h>
-#include<linux/string.h>
-#include<linux/mm.h>
-#include<linux/slab.h>
-#include<linux/delay.h>
-#include<linux/fb.h>
-#include<linux/ioport.h>
-#include<linux/init.h>
-#include<linux/pci.h>
-#include<linux/vmalloc.h>
-#include<linux/pagemap.h>
+#include <linux/module.h>
+#include <linux/kernel.h>
+#include <linux/errno.h>
+#include <linux/string.h>
+#include <linux/mm.h>
+#include <linux/slab.h>
+#include <linux/delay.h>
+#include <linux/fb.h>
+#include <linux/ioport.h>
+#include <linux/init.h>
+#include <linux/pci.h>
+#include <linux/vmalloc.h>
+#include <linux/pagemap.h>
#include <linux/console.h>
-#include<linux/platform_device.h>
-#include<linux/screen_info.h>
+#include <linux/platform_device.h>
+#include <linux/screen_info.h>
#include "sm750.h"
#include "sm750_accel.h"
@@ -233,20 +233,10 @@ unsigned int rop2) /* ROP value */
*/
write_dpr(accel, DE_WINDOW_DESTINATION_BASE, dBase); /* dpr44 */
-#if 0
/* Program pitch (distance between the 1st points of two adjacent lines).
Note that input pitch is BYTE value, but the 2D Pitch register uses
pixel values. Need Byte to pixel conversion.
*/
- if (Bpp == 3) {
- sx *= 3;
- dx *= 3;
- width *= 3;
- write_dpr(accel, DE_PITCH,
- FIELD_VALUE(0, DE_PITCH, DESTINATION, dPitch) |
- FIELD_VALUE(0, DE_PITCH, SOURCE, sPitch)); /* dpr10 */
- } else
-#endif
{
write_dpr(accel, DE_PITCH,
FIELD_VALUE(0, DE_PITCH, DESTINATION, (dPitch/Bpp)) |
@@ -344,21 +334,10 @@ int hw_imageblit(struct lynx_accel *accel,
It is an address offset (128 bit aligned) from the beginning of frame buffer.
*/
write_dpr(accel, DE_WINDOW_DESTINATION_BASE, dBase);
-#if 0
/* Program pitch (distance between the 1st points of two adjacent lines).
Note that input pitch is BYTE value, but the 2D Pitch register uses
pixel values. Need Byte to pixel conversion.
*/
- if (bytePerPixel == 3) {
- dx *= 3;
- width *= 3;
- startBit *= 3;
- write_dpr(accel, DE_PITCH,
- FIELD_VALUE(0, DE_PITCH, DESTINATION, dPitch) |
- FIELD_VALUE(0, DE_PITCH, SOURCE, dPitch)); /* dpr10 */
-
- } else
-#endif
{
write_dpr(accel, DE_PITCH,
FIELD_VALUE(0, DE_PITCH, DESTINATION, dPitch/bytePerPixel) |
diff --git a/drivers/staging/sm750fb/sm750_cursor.c b/drivers/staging/sm750fb/sm750_cursor.c
index a94a4bbff..3b7ce9275 100644
--- a/drivers/staging/sm750fb/sm750_cursor.c
+++ b/drivers/staging/sm750fb/sm750_cursor.c
@@ -1,19 +1,19 @@
-#include<linux/module.h>
-#include<linux/kernel.h>
-#include<linux/errno.h>
-#include<linux/string.h>
-#include<linux/mm.h>
-#include<linux/slab.h>
-#include<linux/delay.h>
-#include<linux/fb.h>
-#include<linux/ioport.h>
-#include<linux/init.h>
-#include<linux/pci.h>
-#include<linux/vmalloc.h>
-#include<linux/pagemap.h>
+#include <linux/module.h>
+#include <linux/kernel.h>
+#include <linux/errno.h>
+#include <linux/string.h>
+#include <linux/mm.h>
+#include <linux/slab.h>
+#include <linux/delay.h>
+#include <linux/fb.h>
+#include <linux/ioport.h>
+#include <linux/init.h>
+#include <linux/pci.h>
+#include <linux/vmalloc.h>
+#include <linux/pagemap.h>
#include <linux/console.h>
-#include<linux/platform_device.h>
-#include<linux/screen_info.h>
+#include <linux/platform_device.h>
+#include <linux/screen_info.h>
#include "sm750.h"
#include "sm750_help.h"
@@ -129,26 +129,6 @@ void hw_cursor_setData(struct lynx_cursor *cursor,
mask = *pmsk++;
data = 0;
- /* either method below works well,
- * but method 2 shows no lag
- * and method 1 seems a bit wrong*/
-#if 0
- if (rop == ROP_XOR)
- opr = mask ^ color;
- else
- opr = mask & color;
-
- for (j = 0; j < 8; j++) {
-
- if (opr & (0x80 >> j)) {
- /* use fg color,id = 2 */
- data |= 2 << (j*2);
- } else {
- /* use bg color,id = 1 */
- data |= 1 << (j*2);
- }
- }
-#else
for (j = 0; j < 8; j++) {
if (mask & (0x80>>j)) {
if (rop == ROP_XOR)
@@ -160,15 +140,10 @@ void hw_cursor_setData(struct lynx_cursor *cursor,
data |= ((opr & (0x80>>j))?2:1)<<(j*2);
}
}
-#endif
iowrite16(data, pbuffer);
/* assume pitch is 1,2,4,8,...*/
-#if 0
- if (!((i+1)&(pitch-1))) /* below line equal to is line */
-#else
if ((i+1) % pitch == 0)
-#endif
{
/* need a return */
pstart += offset;
@@ -209,29 +184,10 @@ void hw_cursor_setData2(struct lynx_cursor *cursor,
mask = *pmsk++;
data = 0;
- /* either method below works well, but method 2 shows no lag */
-#if 0
- if (rop == ROP_XOR)
- opr = mask ^ color;
- else
- opr = mask & color;
-
- for (j = 0; j < 8; j++) {
-
- if (opr & (0x80 >> j)) {
- /* use fg color,id = 2 */
- data |= 2 << (j*2);
- } else {
- /* use bg color,id = 1 */
- data |= 1 << (j*2);
- }
- }
-#else
for (j = 0; j < 8; j++) {
if (mask & (1<<j))
data |= ((color & (1<<j))?1:2)<<(j*2);
}
-#endif
iowrite16(data, pbuffer);
/* assume pitch is 1,2,4,8,...*/
diff --git a/drivers/staging/sm750fb/sm750_help.h b/drivers/staging/sm750fb/sm750_help.h
index 8dc6bd22f..c070cf25a 100644
--- a/drivers/staging/sm750fb/sm750_help.h
+++ b/drivers/staging/sm750fb/sm750_help.h
@@ -1,20 +1,6 @@
#ifndef LYNX_HELP_H__
#define LYNX_HELP_H__
-/* FIELD MACROS */
-#define _LSB(f) (0 ? f)
-#define _MSB(f) (1 ? f)
-#define _COUNT(f) (_MSB(f) - _LSB(f) + 1)
-
-#define RAW_MASK(f) (0xFFFFFFFF >> (32 - _COUNT(f)))
-#define GET_MASK(f) (RAW_MASK(f) << _LSB(f))
-#define GET_FIELD(d, f) (((d) >> _LSB(f)) & RAW_MASK(f))
-#define TEST_FIELD(d, f, v) (GET_FIELD(d, f) == f ## _ ## v)
-#define SET_FIELD(d, f, v) (((d) & ~GET_MASK(f)) | \
- (((f ## _ ## v) & RAW_MASK(f)) << _LSB(f)))
-#define SET_FIELDV(d, f, v) (((d) & ~GET_MASK(f)) | \
- (((v) & RAW_MASK(f)) << _LSB(f)))
-
/* Internal macros */
#define _F_START(f) (0 ? f)
#define _F_END(f) (1 ? f)
@@ -43,7 +29,7 @@
#define FIELD_CLEAR(reg, field) \
( \
- ~ _F_MASK(reg ## _ ## field) \
+ ~_F_MASK(reg ## _ ## field) \
)
/* Field Macros */
@@ -51,25 +37,6 @@
#define FIELD_END(field) (1 ? field)
#define FIELD_SIZE(field) (1 + FIELD_END(field) - FIELD_START(field))
#define FIELD_MASK(field) (((1 << (FIELD_SIZE(field)-1)) | ((1 << (FIELD_SIZE(field)-1)) - 1)) << FIELD_START(field))
-#define FIELD_NORMALIZE(reg, field) (((reg) & FIELD_MASK(field)) >> FIELD_START(field))
-#define FIELD_DENORMALIZE(field, value) (((value) << FIELD_START(field)) & FIELD_MASK(field))
-
-#define FIELD_INIT(reg, field, value) FIELD_DENORMALIZE(reg ## _ ## field, \
- reg ## _ ## field ## _ ## value)
-#define FIELD_INIT_VAL(reg, field, value) \
- (FIELD_DENORMALIZE(reg ## _ ## field, value))
-#define FIELD_VAL_SET(x, r, f, v) x = x & ~FIELD_MASK(r ## _ ## f) \
- | FIELD_DENORMALIZE(r ## _ ## f, r ## _ ## f ## _ ## v)
-
-#define RGB(r, g, b) \
-( \
- (unsigned long) (((r) << 16) | ((g) << 8) | (b)) \
-)
-
-#define RGB16(r, g, b) \
-( \
- (unsigned short) ((((r) & 0xF8) << 8) | (((g) & 0xFC) << 3) | (((b) & 0xF8) >> 3)) \
-)
static inline unsigned int absDiff(unsigned int a, unsigned int b)
{
@@ -81,8 +48,6 @@ static inline unsigned int absDiff(unsigned int a, unsigned int b)
/* n / d + 1 / 2 = (2n + d) / 2d */
#define roundedDiv(num, denom) ((2 * (num) + (denom)) / (2 * (denom)))
-#define MB(x) ((x)<<20)
-#define KB(x) ((x)<<10)
#define MHz(x) ((x) * 1000000)
diff --git a/drivers/staging/sm750fb/sm750_hw.c b/drivers/staging/sm750fb/sm750_hw.c
index 7317ba9b7..41822c6c0 100644
--- a/drivers/staging/sm750fb/sm750_hw.c
+++ b/drivers/staging/sm750fb/sm750_hw.c
@@ -1,42 +1,39 @@
#include <linux/version.h>
-#include<linux/module.h>
-#include<linux/kernel.h>
-#include<linux/errno.h>
-#include<linux/string.h>
-#include<linux/mm.h>
-#include<linux/slab.h>
-#include<linux/delay.h>
-#include<linux/fb.h>
-#include<linux/ioport.h>
-#include<linux/init.h>
-#include<linux/pci.h>
-#include<linux/vmalloc.h>
-#include<linux/pagemap.h>
+#include <linux/module.h>
+#include <linux/kernel.h>
+#include <linux/errno.h>
+#include <linux/string.h>
+#include <linux/mm.h>
+#include <linux/slab.h>
+#include <linux/delay.h>
+#include <linux/fb.h>
+#include <linux/ioport.h>
+#include <linux/init.h>
+#include <linux/pci.h>
+#include <linux/vmalloc.h>
+#include <linux/pagemap.h>
#include <linux/console.h>
#ifdef CONFIG_MTRR
#include <asm/mtrr.h>
#endif
-#include<linux/platform_device.h>
-#include<linux/screen_info.h>
+#include <linux/platform_device.h>
+#include <linux/screen_info.h>
+#include <linux/sizes.h>
#include "sm750.h"
-#include "sm750_hw.h"
#include "ddk750.h"
#include "sm750_accel.h"
-int hw_sm750_map(struct lynx_share *share, struct pci_dev *pdev)
+int hw_sm750_map(struct sm750_dev *sm750_dev, struct pci_dev *pdev)
{
int ret;
- struct sm750_share *spec_share;
-
- spec_share = container_of(share, struct sm750_share, share);
ret = 0;
- share->vidreg_start = pci_resource_start(pdev, 1);
- share->vidreg_size = MB(2);
+ sm750_dev->vidreg_start = pci_resource_start(pdev, 1);
+ sm750_dev->vidreg_size = SZ_2M;
- pr_info("mmio phyAddr = %lx\n", share->vidreg_start);
+ pr_info("mmio phyAddr = %lx\n", sm750_dev->vidreg_start);
/* reserve the vidreg space of smi adaptor
* if you do this, u need to add release region code
@@ -50,48 +47,41 @@ int hw_sm750_map(struct lynx_share *share, struct pci_dev *pdev)
}
/* now map mmio and vidmem*/
- share->pvReg = ioremap_nocache(share->vidreg_start, share->vidreg_size);
- if (!share->pvReg) {
+ sm750_dev->pvReg = ioremap_nocache(sm750_dev->vidreg_start,
+ sm750_dev->vidreg_size);
+ if (!sm750_dev->pvReg) {
pr_err("mmio failed\n");
ret = -EFAULT;
goto exit;
} else {
- pr_info("mmio virtual addr = %p\n", share->pvReg);
+ pr_info("mmio virtual addr = %p\n", sm750_dev->pvReg);
}
- share->accel.dprBase = share->pvReg + DE_BASE_ADDR_TYPE1;
- share->accel.dpPortBase = share->pvReg + DE_PORT_ADDR_TYPE1;
+ sm750_dev->accel.dprBase = sm750_dev->pvReg + DE_BASE_ADDR_TYPE1;
+ sm750_dev->accel.dpPortBase = sm750_dev->pvReg + DE_PORT_ADDR_TYPE1;
- ddk750_set_mmio(share->pvReg, share->devid, share->revid);
+ ddk750_set_mmio(sm750_dev->pvReg, sm750_dev->devid, sm750_dev->revid);
- share->vidmem_start = pci_resource_start(pdev, 0);
+ sm750_dev->vidmem_start = pci_resource_start(pdev, 0);
/* don't use pdev_resource[x].end - resource[x].start to
* calculate the resource size,its only the maximum available
* size but not the actual size,use
- * @hw_sm750_getVMSize function can be safe.
+ * @ddk750_getVMSize function can be safe.
* */
- share->vidmem_size = hw_sm750_getVMSize(share);
+ sm750_dev->vidmem_size = ddk750_getVMSize();
pr_info("video memory phyAddr = %lx, size = %u bytes\n",
- share->vidmem_start, share->vidmem_size);
+ sm750_dev->vidmem_start, sm750_dev->vidmem_size);
/* reserve the vidmem space of smi adaptor */
-#if 0
- ret = pci_request_region(pdev, 0, _moduleName_);
- if (ret) {
- pr_err("Can not request PCI regions.\n");
- goto exit;
- }
-#endif
-
- share->pvMem = ioremap_wc(share->vidmem_start, share->vidmem_size);
-
- if (!share->pvMem) {
+ sm750_dev->pvMem = ioremap_wc(sm750_dev->vidmem_start,
+ sm750_dev->vidmem_size);
+ if (!sm750_dev->pvMem) {
pr_err("Map video memory failed\n");
ret = -EFAULT;
goto exit;
} else {
- pr_info("video memory vaddr = %p\n", share->pvMem);
+ pr_info("video memory vaddr = %p\n", sm750_dev->pvMem);
}
exit:
return ret;
@@ -99,13 +89,11 @@ exit:
-int hw_sm750_inithw(struct lynx_share *share, struct pci_dev *pdev)
+int hw_sm750_inithw(struct sm750_dev *sm750_dev, struct pci_dev *pdev)
{
- struct sm750_share *spec_share;
struct init_status *parm;
- spec_share = container_of(share, struct sm750_share, share);
- parm = &spec_share->state.initParm;
+ parm = &sm750_dev->initParm;
if (parm->chip_clk == 0)
parm->chip_clk = (getChipType() == SM750LE) ?
DEFAULT_SM750LE_CHIP_CLOCK :
@@ -116,22 +104,16 @@ int hw_sm750_inithw(struct lynx_share *share, struct pci_dev *pdev)
if (parm->master_clk == 0)
parm->master_clk = parm->chip_clk/3;
- ddk750_initHw((initchip_param_t *)&spec_share->state.initParm);
+ ddk750_initHw((initchip_param_t *)&sm750_dev->initParm);
/* for sm718,open pci burst */
- if (share->devid == 0x718) {
+ if (sm750_dev->devid == 0x718) {
POKE32(SYSTEM_CTRL,
FIELD_SET(PEEK32(SYSTEM_CTRL), SYSTEM_CTRL, PCI_BURST, ON));
}
- /* sm750 use sii164, it can be setup with default value
- * by on power, so initDVIDisp can be skipped */
-#if 0
- ddk750_initDVIDisp();
-#endif
-
if (getChipType() != SM750LE) {
/* does user need CRT ?*/
- if (spec_share->state.nocrt) {
+ if (sm750_dev->nocrt) {
POKE32(MISC_CTRL,
FIELD_SET(PEEK32(MISC_CTRL),
MISC_CTRL,
@@ -153,7 +135,7 @@ int hw_sm750_inithw(struct lynx_share *share, struct pci_dev *pdev)
DPMS, VPHP));
}
- switch (spec_share->state.pnltype) {
+ switch (sm750_dev->pnltype) {
case sm750_doubleTFT:
case sm750_24TFT:
case sm750_dualTFT:
@@ -161,7 +143,7 @@ int hw_sm750_inithw(struct lynx_share *share, struct pci_dev *pdev)
FIELD_VALUE(PEEK32(PANEL_DISPLAY_CTRL),
PANEL_DISPLAY_CTRL,
TFT_DISP,
- spec_share->state.pnltype));
+ sm750_dev->pnltype));
break;
}
} else {
@@ -169,49 +151,31 @@ int hw_sm750_inithw(struct lynx_share *share, struct pci_dev *pdev)
/* Set up GPIO for software I2C to program DVI chip in the
Xilinx SP605 board, in order to have video signal.
*/
- swI2CInit(0, 1);
+ sm750_sw_i2c_init(0, 1);
/* Customer may NOT use CH7301 DVI chip, which has to be
initialized differently.
*/
- if (swI2CReadReg(0xec, 0x4a) == 0x95) {
+ if (sm750_sw_i2c_read_reg(0xec, 0x4a) == 0x95) {
/* The following register values for CH7301 are from
Chrontel app note and our experiment.
*/
pr_info("yes,CH7301 DVI chip found\n");
- swI2CWriteReg(0xec, 0x1d, 0x16);
- swI2CWriteReg(0xec, 0x21, 0x9);
- swI2CWriteReg(0xec, 0x49, 0xC0);
+ sm750_sw_i2c_write_reg(0xec, 0x1d, 0x16);
+ sm750_sw_i2c_write_reg(0xec, 0x21, 0x9);
+ sm750_sw_i2c_write_reg(0xec, 0x49, 0xC0);
pr_info("okay,CH7301 DVI chip setup done\n");
}
}
/* init 2d engine */
- if (!share->accel_off)
- hw_sm750_initAccel(share);
-
- return 0;
-}
-
-
-resource_size_t hw_sm750_getVMSize(struct lynx_share *share)
-{
- resource_size_t ret;
-
- ret = ddk750_getVMSize();
- return ret;
-}
-
-
-
-int hw_sm750_output_checkMode(struct lynxfb_output *output, struct fb_var_screeninfo *var)
-{
+ if (!sm750_dev->accel_off)
+ hw_sm750_initAccel(sm750_dev);
return 0;
}
-
int hw_sm750_output_setMode(struct lynxfb_output *output,
struct fb_var_screeninfo *var, struct fb_fix_screeninfo *fix)
{
@@ -254,25 +218,19 @@ int hw_sm750_output_setMode(struct lynxfb_output *output,
return ret;
}
-void hw_sm750_output_clear(struct lynxfb_output *output)
-{
-
- return;
-}
-
int hw_sm750_crtc_checkMode(struct lynxfb_crtc *crtc, struct fb_var_screeninfo *var)
{
- struct lynx_share *share;
-
+ struct sm750_dev *sm750_dev;
+ struct lynxfb_par *par = container_of(crtc, struct lynxfb_par, crtc);
- share = container_of(crtc, struct lynxfb_par, crtc)->share;
+ sm750_dev = par->dev;
switch (var->bits_per_pixel) {
case 8:
case 16:
break;
case 32:
- if (share->revid == SM750LE_REVISION_ID) {
+ if (sm750_dev->revid == SM750LE_REVISION_ID) {
pr_debug("750le do not support 32bpp\n");
return -EINVAL;
}
@@ -297,15 +255,15 @@ int hw_sm750_crtc_setMode(struct lynxfb_crtc *crtc,
u32 reg;
mode_parameter_t modparm;
clock_type_t clock;
- struct lynx_share *share;
+ struct sm750_dev *sm750_dev;
struct lynxfb_par *par;
ret = 0;
par = container_of(crtc, struct lynxfb_par, crtc);
- share = par->share;
-#if 1
- if (!share->accel_off) {
+ sm750_dev = par->dev;
+
+ if (!sm750_dev->accel_off) {
/* set 2d engine pixel format according to mode bpp */
switch (var->bits_per_pixel) {
case 8:
@@ -319,9 +277,8 @@ int hw_sm750_crtc_setMode(struct lynxfb_crtc *crtc,
fmt = 2;
break;
}
- hw_set2dformat(&share->accel, fmt);
+ hw_set2dformat(&sm750_dev->accel, fmt);
}
-#endif
/* set timing */
modparm.pixel_clock = ps_to_hz(var->pixclock);
@@ -359,7 +316,7 @@ int hw_sm750_crtc_setMode(struct lynxfb_crtc *crtc,
reg = var->xres * (var->bits_per_pixel >> 3);
/* crtc->channel is not equal to par->index on numeric,be aware of that */
- reg = PADDING(crtc->line_pad, reg);
+ reg = ALIGN(reg, crtc->line_pad);
POKE32(PANEL_FB_WIDTH,
FIELD_VALUE(0, PANEL_FB_WIDTH, WIDTH, reg)|
@@ -391,7 +348,7 @@ int hw_sm750_crtc_setMode(struct lynxfb_crtc *crtc,
POKE32(CRT_FB_ADDRESS, crtc->oScreen);
reg = var->xres * (var->bits_per_pixel >> 3);
/* crtc->channel is not equal to par->index on numeric,be aware of that */
- reg = PADDING(crtc->line_pad, reg);
+ reg = ALIGN(reg, crtc->line_pad);
POKE32(CRT_FB_WIDTH,
FIELD_VALUE(0, CRT_FB_WIDTH, WIDTH, reg)|
@@ -409,12 +366,6 @@ exit:
return ret;
}
-void hw_sm750_crtc_clear(struct lynxfb_crtc *crtc)
-{
-
- return;
-}
-
int hw_sm750_setColReg(struct lynxfb_crtc *crtc, ushort index,
ushort red, ushort green, ushort blue)
{
@@ -429,41 +380,23 @@ int hw_sm750le_setBLANK(struct lynxfb_output *output, int blank)
int dpms, crtdb;
switch (blank) {
-#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 10)
case FB_BLANK_UNBLANK:
-#else
- case VESA_NO_BLANKING:
-#endif
dpms = CRT_DISPLAY_CTRL_DPMS_0;
crtdb = CRT_DISPLAY_CTRL_BLANK_OFF;
break;
-#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 10)
case FB_BLANK_NORMAL:
dpms = CRT_DISPLAY_CTRL_DPMS_0;
crtdb = CRT_DISPLAY_CTRL_BLANK_ON;
break;
-#endif
-#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 10)
case FB_BLANK_VSYNC_SUSPEND:
-#else
- case VESA_VSYNC_SUSPEND:
-#endif
dpms = CRT_DISPLAY_CTRL_DPMS_2;
crtdb = CRT_DISPLAY_CTRL_BLANK_ON;
break;
-#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 10)
case FB_BLANK_HSYNC_SUSPEND:
-#else
- case VESA_HSYNC_SUSPEND:
-#endif
dpms = CRT_DISPLAY_CTRL_DPMS_1;
crtdb = CRT_DISPLAY_CTRL_BLANK_ON;
break;
-#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 10)
case FB_BLANK_POWERDOWN:
-#else
- case VESA_POWERDOWN:
-#endif
dpms = CRT_DISPLAY_CTRL_DPMS_3;
crtdb = CRT_DISPLAY_CTRL_BLANK_ON;
break;
@@ -485,47 +418,29 @@ int hw_sm750_setBLANK(struct lynxfb_output *output, int blank)
dpms = pps = crtdb = 0;
switch (blank) {
-#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 10)
case FB_BLANK_UNBLANK:
-#else
- case VESA_NO_BLANKING:
-#endif
pr_info("flag = FB_BLANK_UNBLANK\n");
dpms = SYSTEM_CTRL_DPMS_VPHP;
pps = PANEL_DISPLAY_CTRL_DATA_ENABLE;
crtdb = CRT_DISPLAY_CTRL_BLANK_OFF;
break;
-#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 10)
case FB_BLANK_NORMAL:
pr_info("flag = FB_BLANK_NORMAL\n");
dpms = SYSTEM_CTRL_DPMS_VPHP;
pps = PANEL_DISPLAY_CTRL_DATA_DISABLE;
crtdb = CRT_DISPLAY_CTRL_BLANK_ON;
break;
-#endif
-#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 10)
case FB_BLANK_VSYNC_SUSPEND:
-#else
- case VESA_VSYNC_SUSPEND:
-#endif
dpms = SYSTEM_CTRL_DPMS_VNHP;
pps = PANEL_DISPLAY_CTRL_DATA_DISABLE;
crtdb = CRT_DISPLAY_CTRL_BLANK_ON;
break;
-#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 10)
case FB_BLANK_HSYNC_SUSPEND:
-#else
- case VESA_HSYNC_SUSPEND:
-#endif
dpms = SYSTEM_CTRL_DPMS_VPHN;
pps = PANEL_DISPLAY_CTRL_DATA_DISABLE;
crtdb = CRT_DISPLAY_CTRL_BLANK_ON;
break;
-#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 10)
case FB_BLANK_POWERDOWN:
-#else
- case VESA_POWERDOWN:
-#endif
dpms = SYSTEM_CTRL_DPMS_VNHN;
pps = PANEL_DISPLAY_CTRL_DATA_DISABLE;
crtdb = CRT_DISPLAY_CTRL_BLANK_ON;
@@ -545,7 +460,7 @@ int hw_sm750_setBLANK(struct lynxfb_output *output, int blank)
}
-void hw_sm750_initAccel(struct lynx_share *share)
+void hw_sm750_initAccel(struct sm750_dev *sm750_dev)
{
u32 reg;
@@ -572,7 +487,7 @@ void hw_sm750_initAccel(struct lynx_share *share)
}
/* call 2d init */
- share->accel.de_init(&share->accel);
+ sm750_dev->accel.de_init(&sm750_dev->accel);
}
int hw_sm750le_deWait(void)
diff --git a/drivers/staging/sm750fb/sm750_hw.h b/drivers/staging/sm750fb/sm750_hw.h
deleted file mode 100644
index 3781a1a11..000000000
--- a/drivers/staging/sm750fb/sm750_hw.h
+++ /dev/null
@@ -1,101 +0,0 @@
-#ifndef LYNX_HW750_H__
-#define LYNX_HW750_H__
-
-
-#define DEFAULT_SM750_CHIP_CLOCK 290
-#define DEFAULT_SM750LE_CHIP_CLOCK 333
-#ifndef SM750LE_REVISION_ID
-#define SM750LE_REVISION_ID (unsigned char)0xfe
-#endif
-
-
-enum sm750_pnltype {
-
- sm750_24TFT = 0,/* 24bit tft */
-
- sm750_dualTFT = 2,/* dual 18 bit tft */
-
- sm750_doubleTFT = 1,/* 36 bit double pixel tft */
-};
-
-/* vga channel is not concerned */
-enum sm750_dataflow {
- sm750_simul_pri,/* primary => all head */
-
- sm750_simul_sec,/* secondary => all head */
-
- sm750_dual_normal,/* primary => panel head and secondary => crt */
-
- sm750_dual_swap,/* primary => crt head and secondary => panel */
-};
-
-
-enum sm750_channel {
- sm750_primary = 0,
- /* enum value equal to the register filed data */
- sm750_secondary = 1,
-};
-
-enum sm750_path {
- sm750_panel = 1,
- sm750_crt = 2,
- sm750_pnc = 3,/* panel and crt */
-};
-
-struct init_status {
- ushort powerMode;
- /* below three clocks are in unit of MHZ*/
- ushort chip_clk;
- ushort mem_clk;
- ushort master_clk;
- ushort setAllEngOff;
- ushort resetMemory;
-};
-
-struct sm750_state {
- struct init_status initParm;
- enum sm750_pnltype pnltype;
- enum sm750_dataflow dataflow;
- int nocrt;
- int xLCD;
- int yLCD;
-};
-
-/* sm750_share stands for a presentation of two frame buffer
- that use one sm750 adaptor, it is similar to the super class of lynx_share
- in C++
- */
-
-struct sm750_share {
- /* it's better to put lynx_share struct to the first place of sm750_share */
- struct lynx_share share;
- struct sm750_state state;
- int hwCursor;
- /* 0: no hardware cursor
- 1: primary crtc hw cursor enabled,
- 2: secondary crtc hw cursor enabled
- 3: both ctrc hw cursor enabled
- */
-};
-
-int hw_sm750_map(struct lynx_share *share, struct pci_dev *pdev);
-int hw_sm750_inithw(struct lynx_share*, struct pci_dev *);
-void hw_sm750_initAccel(struct lynx_share *);
-int hw_sm750_deWait(void);
-int hw_sm750le_deWait(void);
-
-resource_size_t hw_sm750_getVMSize(struct lynx_share *);
-int hw_sm750_output_checkMode(struct lynxfb_output*, struct fb_var_screeninfo*);
-int hw_sm750_output_setMode(struct lynxfb_output*, struct fb_var_screeninfo*, struct fb_fix_screeninfo*);
-int hw_sm750_crtc_checkMode(struct lynxfb_crtc*, struct fb_var_screeninfo*);
-int hw_sm750_crtc_setMode(struct lynxfb_crtc*, struct fb_var_screeninfo*, struct fb_fix_screeninfo*);
-int hw_sm750_setColReg(struct lynxfb_crtc*, ushort, ushort, ushort, ushort);
-int hw_sm750_setBLANK(struct lynxfb_output*, int);
-int hw_sm750le_setBLANK(struct lynxfb_output*, int);
-void hw_sm750_crtc_clear(struct lynxfb_crtc *);
-void hw_sm750_output_clear(struct lynxfb_output *);
-int hw_sm750_pan_display(struct lynxfb_crtc *crtc,
- const struct fb_var_screeninfo *var,
- const struct fb_info *info);
-
-#endif