static void swPanelPowerSequence(int disp,int delay) { unsigned int reg; /* disp should be 1 to open sequence */ reg = PEEK32(PANEL_DISPLAY_CTRL); reg = FIELD_VALUE(reg,PANEL_DISPLAY_CTRL,FPEN,disp); 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); primaryWaitVerticalSync(delay); reg = PEEK32(PANEL_DISPLAY_CTRL); reg = FIELD_VALUE(reg,PANEL_DISPLAY_CTRL,VBIASEN,disp); 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); primaryWaitVerticalSync(delay); }
int hwI2CInit( unsigned char busSpeedMode ) { unsigned int value; /* Enable GPIO 30 & 31 as IIC clock & data */ value = PEEK32(GPIO_MUX); value = FIELD_SET(value, GPIO_MUX, 30, I2C) | FIELD_SET(0, GPIO_MUX, 31, I2C); POKE32(GPIO_MUX, value); /* Enable Hardware I2C power. TODO: Check if we need to enable GPIO power? */ enableI2C(1); /* Enable the I2C Controller and set the bus speed mode */ value = PEEK32(I2C_CTRL); if (busSpeedMode == 0) value = FIELD_SET(value, I2C_CTRL, MODE, STANDARD); else value = FIELD_SET(value, I2C_CTRL, MODE, FAST); value = FIELD_SET(value, I2C_CTRL, EN, ENABLE); POKE32(I2C_CTRL, value); return 0; }
/* SM750LE only: This function takes care extra registers and bit fields required to set up a mode in SM750LE Explanation about Display Control register: HW only supports 7 predefined pixel clocks, and clock select is in bit 29:27 of Display Control register. */ static unsigned long displayControlAdjust_SM750LE(mode_parameter_t *pModeParam, unsigned long dispControl) { unsigned long x, y; x = pModeParam->horizontal_display_end; y = pModeParam->vertical_display_end; /* SM750LE has to set up the top-left and bottom-right registers as well. Note that normal SM750/SM718 only use those two register for auto-centering mode. */ POKE32(CRT_AUTO_CENTERING_TL, FIELD_VALUE(0, CRT_AUTO_CENTERING_TL, TOP, 0) | FIELD_VALUE(0, CRT_AUTO_CENTERING_TL, LEFT, 0)); POKE32(CRT_AUTO_CENTERING_BR, FIELD_VALUE(0, CRT_AUTO_CENTERING_BR, BOTTOM, y-1) | FIELD_VALUE(0, CRT_AUTO_CENTERING_BR, RIGHT, x-1)); /* Assume common fields in dispControl have been properly set before calling this function. This function only sets the extra fields in dispControl. */ /* Clear bit 29:27 of display control register */ dispControl &= FIELD_CLEAR(CRT_DISPLAY_CTRL, CLK); /* Set bit 29:27 of display control register for the right clock */ /* Note that SM750LE only need to supported 7 resoluitons. */ if (x == 800 && y == 600) dispControl = FIELD_SET(dispControl, CRT_DISPLAY_CTRL, CLK, PLL41); else if (x == 1024 && y == 768) dispControl = FIELD_SET(dispControl, CRT_DISPLAY_CTRL, CLK, PLL65); else if (x == 1152 && y == 864) dispControl = FIELD_SET(dispControl, CRT_DISPLAY_CTRL, CLK, PLL80); else if (x == 1280 && y == 768) dispControl = FIELD_SET(dispControl, CRT_DISPLAY_CTRL, CLK, PLL80); else if (x == 1280 && y == 720) dispControl = FIELD_SET(dispControl, CRT_DISPLAY_CTRL, CLK, PLL74); else if (x == 1280 && y == 960) dispControl = FIELD_SET(dispControl, CRT_DISPLAY_CTRL, CLK, PLL108); else if (x == 1280 && y == 1024) dispControl = FIELD_SET(dispControl, CRT_DISPLAY_CTRL, CLK, PLL108); else /* default to VGA clock */ dispControl = FIELD_SET(dispControl, CRT_DISPLAY_CTRL, CLK, PLL25); /* Set bit 25:24 of display controller */ dispControl = FIELD_SET(dispControl, CRT_DISPLAY_CTRL, CRTSELECT, CRT); dispControl = FIELD_SET(dispControl, CRT_DISPLAY_CTRL, RGBBIT, 24BIT); /* Set bit 14 of display controller */ dispControl = FIELD_SET(dispControl, CRT_DISPLAY_CTRL, CLOCK_PHASE, ACTIVE_LOW); POKE32(CRT_DISPLAY_CTRL, dispControl); return dispControl; }
void ddk750_setDPMS(DPMS_t state) { unsigned int value; if (getChipType() == SM750LE) { value = PEEK32(CRT_DISPLAY_CTRL) & ~CRT_DISPLAY_CTRL_DPMS_MASK; value |= (state << CRT_DISPLAY_CTRL_DPMS_SHIFT); POKE32(CRT_DISPLAY_CTRL, value); } else { value = PEEK32(SYSTEM_CTRL); value = (value & ~SYSTEM_CTRL_DPMS_MASK) | state; POKE32(SYSTEM_CTRL, value); } }
/* * This function initializes the i2c attributes and bus * * Parameters: * 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 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 ((clk_gpio > 31) || (data_gpio > 31)) return -1; if (sm750_get_chip_type() == SM750LE) return sm750le_i2c_init(clk_gpio, data_gpio); /* Initialize the GPIO pin for the i2c Clock Register */ 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 */ sw_i2c_clk_gpio = clk_gpio; /* Initialize the GPIO pin for the i2c Data Register */ 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 */ sw_i2c_data_gpio = data_gpio; /* Enable the GPIO pins for the i2c Clock and Data (GPIO MUX) */ 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 */ sm750_enable_gpio(1); /* Clear the i2c lines. */ for (i = 0; i < 9; i++) sw_i2c_stop(); return 0; }
/* * This function reads data from the slave device and stores them * in the given buffer * * Parameters: * deviceAddress - i2c Slave device address * length - Total number of bytes to be read * pBuffer - 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, unsigned int length, unsigned char *pBuffer ) { unsigned char count, i; unsigned int totalBytes = 0; /* Set the Device Address */ POKE32(I2C_SLAVE_ADDRESS, deviceAddress | 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. */ POKE32(I2C_RESET, 0); /* Set the number of bytes to be read */ if (length <= MAX_HWI2C_FIFO) count = length - 1; else count = MAX_HWI2C_FIFO - 1; POKE32(I2C_BYTE_COUNT, count); /* Start the I2C */ POKE32(I2C_CTRL, FIELD_SET(PEEK32(I2C_CTRL), I2C_CTRL, CTRL, START)); /* Wait until transaction done. */ if (hwI2CWaitTXDone() != 0) break; /* Save the data to the given buffer */ for (i = 0; i <= count; i++) *pBuffer++ = PEEK32(I2C_DATA0 + i); /* Substract length by 16 */ length -= (count + 1); /* Number of bytes read. */ totalBytes += (count + 1); } while (length > 0); return totalBytes; }
/* * This function writes data to the i2c slave device registers. * * Parameters: * deviceAddress - 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 * i2c device. * * Return Value: * Total number of bytes those are actually written. */ static unsigned int hwI2CWriteData( unsigned char deviceAddress, unsigned int length, unsigned char *pBuffer ) { unsigned char count, i; unsigned int totalBytes = 0; /* Set the Device Address */ POKE32(I2C_SLAVE_ADDRESS, deviceAddress & ~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. */ POKE32(I2C_RESET, 0); /* Set the number of bytes to be written */ if (length < MAX_HWI2C_FIFO) count = length - 1; else count = MAX_HWI2C_FIFO - 1; POKE32(I2C_BYTE_COUNT, count); /* Move the data to the I2C data register */ for (i = 0; i <= count; i++) POKE32(I2C_DATA0 + i, *pBuffer++); /* Start the I2C */ POKE32(I2C_CTRL, FIELD_SET(PEEK32(I2C_CTRL), I2C_CTRL, CTRL, START)); /* Wait until the transfer is completed. */ if (hwI2CWaitTXDone() != 0) break; /* Substract length */ length -= (count + 1); /* Total byte written */ totalBytes += (count + 1); } while (length > 0); return totalBytes; }
unsigned int ddk750_getVMSize(void) { unsigned int reg; unsigned int data; /* sm750le only use 64 mb memory*/ if (getChipType() == SM750LE) return SZ_64M; /* for 750,always use power mode0*/ reg = PEEK32(MODE0_GATE); reg |= MODE0_GATE_GPIO; POKE32(MODE0_GATE, reg); /* get frame buffer size from GPIO */ reg = PEEK32(MISC_CTRL) & MISC_CTRL_LOCALMEM_SIZE_MASK; switch (reg) { case MISC_CTRL_LOCALMEM_SIZE_8M: data = SZ_8M; break; /* 8 Mega byte */ case MISC_CTRL_LOCALMEM_SIZE_16M: data = SZ_16M; break; /* 16 Mega byte */ case MISC_CTRL_LOCALMEM_SIZE_32M: data = SZ_32M; break; /* 32 Mega byte */ case MISC_CTRL_LOCALMEM_SIZE_64M: data = SZ_64M; break; /* 64 Mega byte */ default: data = 0; break; } return data; }
/* * This function set up the main chip clock. * * Input: Frequency to be set. */ static void setChipClock(unsigned int frequency) { pll_value_t pll; unsigned int ulActualMxClk; /* Cheok_0509: For SM750LE, the chip clock is fixed. Nothing to set. */ if (getChipType() == SM750LE) return; if (frequency) { /* * Set up PLL, a structure to hold the value to be set in clocks. */ pll.inputFreq = DEFAULT_INPUT_CLOCK; /* Defined in CLOCK.H */ pll.clockType = MXCLK_PLL; /* * Call calcPllValue() to fill up the other fields for PLL structure. * Sometime, the chip cannot set up the exact clock required by User. * Return value from calcPllValue() gives the actual possible clock. */ ulActualMxClk = calcPllValue(frequency, &pll); /* Master Clock Control: MXCLK_PLL */ POKE32(MXCLK_PLL_CTRL, formatPllReg(&pll)); } }
unsigned int ddk750_getVMSize() { unsigned int reg; unsigned int data; /* sm750le only use 64 mb memory*/ if(getChipType() == SM750LE) return MB(64); /* for 750,always use power mode0*/ reg = PEEK32(MODE0_GATE); reg = FIELD_SET(reg,MODE0_GATE,GPIO,ON); POKE32(MODE0_GATE,reg); /* get frame buffer size from GPIO */ 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 */ case MISC_CTRL_LOCALMEM_SIZE_16M: data = MB(16); break; /* 16 Mega byte */ case MISC_CTRL_LOCALMEM_SIZE_32M: data = MB(32); break; /* 32 Mega byte */ case MISC_CTRL_LOCALMEM_SIZE_64M: data = MB(64); break; /* 64 Mega byte */ default: data = 0;break; } return data; }
void hw_cursor_setPos(struct lynx_cursor * cursor, int x,int y) { u32 reg; reg = FIELD_VALUE(0,HWC_LOCATION,Y,y)| FIELD_VALUE(0,HWC_LOCATION,X,x); POKE32(HWC_LOCATION,reg); }
/* hw_cursor_xxx works for voyager,718 and 750 */ void hw_cursor_enable(struct lynx_cursor * cursor) { u32 reg; reg = FIELD_VALUE(0,HWC_ADDRESS,ADDRESS,cursor->offset)| FIELD_SET(0,HWC_ADDRESS,EXT,LOCAL)| FIELD_SET(0,HWC_ADDRESS,ENABLE,ENABLE); POKE32(HWC_ADDRESS,reg); }
/* * 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 * * Return Value: * -1 - Fail to initialize the i2c * 0 - Success */ long swI2CInit( unsigned char i2cClkGPIO, unsigned char i2cDataGPIO ) { 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 -1; if (getChipType() == SM750LE) return swI2CInit_SM750LE(i2cClkGPIO, i2cDataGPIO); /* Initialize the GPIO pin for the i2c Clock Register */ g_i2cClkGPIOMuxReg = GPIO_MUX; g_i2cClkGPIODataReg = GPIO_DATA; g_i2cClkGPIODataDirReg = GPIO_DATA_DIRECTION; /* Initialize the Clock GPIO Offset */ g_i2cClockGPIO = i2cClkGPIO; /* Initialize the GPIO pin for the i2c Data Register */ g_i2cDataGPIOMuxReg = GPIO_MUX; g_i2cDataGPIODataReg = GPIO_DATA; g_i2cDataGPIODataDirReg = GPIO_DATA_DIRECTION; /* Initialize the Data GPIO Offset */ g_i2cDataGPIO = i2cDataGPIO; /* 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)); /* Enable GPIO power */ enableGPIO(1); /* Clear the i2c lines. */ for(i=0; i<9; i++) swI2CStop(); return 0; }
void ddk750_setLogicalDispOut(disp_output_t output) { unsigned int reg; if(output & PNL_2_USAGE){ /* set panel path controller select */ reg = PEEK32(PANEL_DISPLAY_CTRL); reg = FIELD_VALUE(reg,PANEL_DISPLAY_CTRL,SELECT,(output & PNL_2_MASK)>>PNL_2_OFFSET); POKE32(PANEL_DISPLAY_CTRL,reg); }
void hwI2CClose(void) { unsigned int value; /* Disable I2C controller */ value = PEEK32(I2C_CTRL); value = FIELD_SET(value, I2C_CTRL, EN, DISABLE); POKE32(I2C_CTRL, value); /* Disable I2C Power */ enableI2C(0); /* Set GPIO 30 & 31 back as GPIO pins */ value = PEEK32(GPIO_MUX); value = FIELD_SET(value, GPIO_MUX, 30, GPIO); value = FIELD_SET(value, GPIO_MUX, 31, GPIO); POKE32(GPIO_MUX, value); }
/* * This function set/reset the SDA GPIO pin * * Parameters: * value - Bit value to set to the SCL or SDA (0 = low, 1 = high) * * Notes: * When setting SCL to high, just set the GPIO as input where the pull up * resistor will pull the signal up. Do not use software to pull up the * signal because the i2c will fail when other device try to drive the * signal due to SM50x will drive the signal to always high. */ static void sw_i2c_sda(unsigned char value) { unsigned long gpio_data; unsigned long gpio_dir; gpio_dir = PEEK32(sw_i2c_data_gpio_data_dir_reg); if (value) { /* High */ /* * 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 */ 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 */ gpio_dir |= (1 << sw_i2c_data_gpio); POKE32(sw_i2c_data_gpio_data_dir_reg, gpio_dir); } }
/* * This function set/reset the SDA GPIO pin * * Parameters: * value - Bit value to set to the SCL or SDA (0 = low, 1 = high) * * Notes: * When setting SCL to high, just set the GPIO as input where the pull up * resistor will pull the signal up. Do not use software to pull up the * 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) { unsigned long ulGPIOData; unsigned long ulGPIODirection; ulGPIODirection = PEEK32(g_i2cDataGPIODataDirReg); if (value) /* High */ { /* Set direction as input. This will automatically pull the signal up. */ ulGPIODirection &= ~(1 << g_i2cDataGPIO); POKE32(g_i2cDataGPIODataDirReg, ulGPIODirection); } else /* Low */ { /* Set the signal down */ ulGPIOData = PEEK32(g_i2cDataGPIODataReg); ulGPIOData &= ~(1 << g_i2cDataGPIO); POKE32(g_i2cDataGPIODataReg, ulGPIOData); /* Set direction as output */ ulGPIODirection |= (1 << g_i2cDataGPIO); POKE32(g_i2cDataGPIODataDirReg, ulGPIODirection); } }
/* * SM50x can operate in one of three modes: 0, 1 or Sleep. * On hardware reset, power mode 0 is default. */ void setPowerMode(unsigned int powerMode) { unsigned int control_value = 0; control_value = PEEK32(POWER_MODE_CTRL) & ~POWER_MODE_CTRL_MODE_MASK; if (getChipType() == SM750LE) return; switch (powerMode) { case POWER_MODE_CTRL_MODE_MODE0: control_value |= POWER_MODE_CTRL_MODE_MODE0; break; case POWER_MODE_CTRL_MODE_MODE1: control_value |= POWER_MODE_CTRL_MODE_MODE1; break; case POWER_MODE_CTRL_MODE_SLEEP: control_value |= POWER_MODE_CTRL_MODE_SLEEP; break; default: break; } /* Set up other fields in Power Control Register */ if (powerMode == POWER_MODE_CTRL_MODE_SLEEP) { control_value &= ~POWER_MODE_CTRL_OSC_INPUT; #ifdef VALIDATION_CHIP control_value &= ~POWER_MODE_CTRL_336CLK; #endif } else { control_value |= POWER_MODE_CTRL_OSC_INPUT; #ifdef VALIDATION_CHIP control_value |= POWER_MODE_CTRL_336CLK; #endif } /* Program new power mode. */ POKE32(POWER_MODE_CTRL, control_value); }
/* * This function read the data from the SDA GPIO pin * * Return Value: * The SDA data bit sent by the Slave */ static unsigned char sw_i2c_read_sda(void) { 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) */ 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 */ gpio_data = PEEK32(sw_i2c_data_gpio_data_reg); if (gpio_data & (1 << sw_i2c_data_gpio)) return 1; else return 0; }
/* * This function read the data from the SDA GPIO pin * * Return Value: * The SDA data bit sent by the Slave */ static unsigned char swI2CReadSDA(void) { unsigned long ulGPIODirection; unsigned long ulGPIOData; /* 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); } /* Now read the SDA line */ ulGPIOData = PEEK32(g_i2cDataGPIODataReg); if (ulGPIOData & (1 << g_i2cDataGPIO)) return 1; else return 0; }
void setCurrentGate(unsigned int gate) { unsigned int gate_reg; unsigned int mode; /* Get current power mode. */ mode = getPowerMode(); switch (mode) { case POWER_MODE_CTRL_MODE_MODE0: gate_reg = MODE0_GATE; break; case POWER_MODE_CTRL_MODE_MODE1: gate_reg = MODE1_GATE; break; default: gate_reg = MODE0_GATE; break; } POKE32(gate_reg, gate); }
void hw_cursor_disable(struct lynx_cursor * cursor) { POKE32(HWC_ADDRESS,0); }
* ************************* */ static unsigned long fli7510_standby_table[] __cacheline_aligned = { END_MARKER, END_MARKER }; /* ********************* * MEM INSTRUCTION TABLE * ********************* */ static unsigned long fli7510_mem_table[] __cacheline_aligned = { /* 1. Enables the DDR self refresh mode based on paraghaph. 7.1.4 * -> from ACCESS to LowPower */ POKE32(DDR0_BASE_REG + DDR_SCTL, DDR_SCTL_SLEEP), WHILE_NE32(DDR0_BASE_REG + DDR_STAT, DDR_STAT_LOW_POWER, DDR_STAT_LOW_POWER), #if 0 OR32(DDR0_BASE_REG + DDR_PHY_IOCRV1, 1), OR32(DDR0_BASE_REG + DDR_PHY_DXCCR, 1), #endif POKE32(DDR1_BASE_REG + DDR_SCTL, DDR_SCTL_SLEEP), WHILE_NE32(DDR1_BASE_REG + DDR_STAT, DDR_STAT_LOW_POWER, DDR_STAT_LOW_POWER), #if 0 OR32(DDR1_BASE_REG + DDR_PHY_IOCRV1, 1), OR32(DDR1_BASE_REG + DDR_PHY_DXCCR, 1), OR32(DDR0_BASE_REG + DDR_PHY_PIR, 1 << 7), OR32(DDR1_BASE_REG + DDR_PHY_PIR, 1 << 7),
#define DDR_CLK_ID 5 #define DDR_CLK_SHIFT (DDR_CLK_ID * 2) #define SYSCONF_CPU_722 (STIG125_SYSCONF_CPU_BASE + 0x58) #define SYSCONF_CPU_760 (STIG125_SYSCONF_CPU_BASE + 0xf0) static void __iomem *clks_base[2]; static struct stm_wakeup_devices stig125_wkd; static long stig125_ddr0_enter[] = { synopsys_ddr32_in_self_refresh(STIG125_DDR_PCTL_BASE), synopsys_ddr32_phy_standby_enter(STIG125_DDR_PCTL_BASE), POKE32(CLK_A1_BASE + SASC_SWITCH_CFG(0), 0), POKE32(CLK_A1_BASE + SASC_POWER_CFG, 0x3), /* bypass and disable the A9.PLL */ OR32(SYSCONF_CPU_722, 1 << 2), OR32(SYSCONF_CPU_722, 1), END_MARKER, }; static long stig125_ddr0_exit[] = { /* enable, wait and don't bypass the A9.PLL */ UPDATE32(SYSCONF_CPU_722, ~1, 0), WHILE_NE32(SYSCONF_CPU_760, 1, 1), UPDATE32(SYSCONF_CPU_722, ~(1 << 2), 0),
static void setDisplayControl(int ctrl,int dispState) { /* state != 0 means turn on both timing & plane en_bit */ unsigned long ulDisplayCtrlReg, ulReservedBits; int cnt; cnt = 0; /* Set the primary display control */ if (!ctrl) { ulDisplayCtrlReg = PEEK32(PANEL_DISPLAY_CTRL); /* Turn on/off the Panel display control */ if (dispState) { /* 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. */ ulDisplayCtrlReg = FIELD_SET(ulDisplayCtrlReg, PANEL_DISPLAY_CTRL, TIMING, ENABLE); POKE32(PANEL_DISPLAY_CTRL, ulDisplayCtrlReg); ulDisplayCtrlReg = FIELD_SET(ulDisplayCtrlReg, PANEL_DISPLAY_CTRL, PLANE, ENABLE); /* Added some masks to mask out the reserved bits. * Sometimes, the reserved bits are set/reset randomly when * writing to the PRIMARY_DISPLAY_CTRL, therefore, the register * reserved bits are needed to be masked out. */ ulReservedBits = FIELD_SET(0, PANEL_DISPLAY_CTRL, RESERVED_1_MASK, ENABLE) | FIELD_SET(0, PANEL_DISPLAY_CTRL, RESERVED_2_MASK, ENABLE) | FIELD_SET(0, PANEL_DISPLAY_CTRL, RESERVED_3_MASK, ENABLE); /* Somehow the register value on the plane is not set * until a few delay. Need to write * and read it a couple times */ do { cnt++; POKE32(PANEL_DISPLAY_CTRL, ulDisplayCtrlReg); } while((PEEK32(PANEL_DISPLAY_CTRL) & ~ulReservedBits) != (ulDisplayCtrlReg & ~ulReservedBits)); printk("Set Panel Plane enbit:after tried %d times\n",cnt); } else { /* When turning off, there is no rule on the programming * sequence since whenever the clock is off, then it does not * matter whether the plane is enabled or disabled. * Note: Modifying the plane bit will take effect on the * next vertical sync. Need to find out if it is necessary to * wait for 1 vsync before modifying the timing enable bit. * */ ulDisplayCtrlReg = FIELD_SET(ulDisplayCtrlReg, PANEL_DISPLAY_CTRL, PLANE, DISABLE); POKE32(PANEL_DISPLAY_CTRL, ulDisplayCtrlReg); ulDisplayCtrlReg = FIELD_SET(ulDisplayCtrlReg, PANEL_DISPLAY_CTRL, TIMING, DISABLE); POKE32(PANEL_DISPLAY_CTRL, ulDisplayCtrlReg); } } /* Set the secondary display control */ else { ulDisplayCtrlReg = PEEK32(CRT_DISPLAY_CTRL); if (dispState) { /* 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. */ ulDisplayCtrlReg = FIELD_SET(ulDisplayCtrlReg, CRT_DISPLAY_CTRL, TIMING, ENABLE); POKE32(CRT_DISPLAY_CTRL, ulDisplayCtrlReg); ulDisplayCtrlReg = FIELD_SET(ulDisplayCtrlReg, CRT_DISPLAY_CTRL, PLANE, ENABLE); /* Added some masks to mask out the reserved bits. * Sometimes, the reserved bits are set/reset randomly when * writing to the PRIMARY_DISPLAY_CTRL, therefore, the register * reserved bits are needed to be masked out. */ ulReservedBits = FIELD_SET(0, CRT_DISPLAY_CTRL, RESERVED_1_MASK, ENABLE) | FIELD_SET(0, CRT_DISPLAY_CTRL, RESERVED_2_MASK, ENABLE) | FIELD_SET(0, CRT_DISPLAY_CTRL, RESERVED_3_MASK, ENABLE) | FIELD_SET(0, CRT_DISPLAY_CTRL, RESERVED_4_MASK, ENABLE); do { cnt++; POKE32(CRT_DISPLAY_CTRL, ulDisplayCtrlReg); } while((PEEK32(CRT_DISPLAY_CTRL) & ~ulReservedBits) != (ulDisplayCtrlReg & ~ulReservedBits)); printk("Set Crt Plane enbit:after tried %d times\n",cnt); } else { /* When turning off, there is no rule on the programming * sequence since whenever the clock is off, then it does not * matter whether the plane is enabled or disabled. * Note: Modifying the plane bit will take effect on the next * vertical sync. Need to find out if it is necessary to * wait for 1 vsync before modifying the timing enable bit. */ ulDisplayCtrlReg = FIELD_SET(ulDisplayCtrlReg, CRT_DISPLAY_CTRL, PLANE, DISABLE); POKE32(CRT_DISPLAY_CTRL, ulDisplayCtrlReg); ulDisplayCtrlReg = FIELD_SET(ulDisplayCtrlReg, CRT_DISPLAY_CTRL, TIMING, DISABLE); POKE32(CRT_DISPLAY_CTRL, ulDisplayCtrlReg); } } }
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; setPowerMode(pInitParam->powerMode); /* Enable display power gate & LOCALMEM power gate*/ ulReg = PEEK32(CURRENT_GATE); ulReg = FIELD_SET(ulReg, CURRENT_GATE, DISPLAY, ON); ulReg = FIELD_SET(ulReg,CURRENT_GATE,LOCALMEM,ON); setCurrentGate(ulReg); if(getChipType() != SM750LE){ /* set panel pll and graphic mode via mmio_88 */ ulReg = PEEK32(VGA_CONFIGURATION); ulReg = FIELD_SET(ulReg,VGA_CONFIGURATION,PLL,PANEL); ulReg = FIELD_SET(ulReg,VGA_CONFIGURATION,MODE,GRAPHIC); POKE32(VGA_CONFIGURATION,ulReg); }else{ #if defined(__i386__) || defined( __x86_64__) /* set graphic mode via IO method */ outb_p(0x88,0x3d4); outb_p(0x06,0x3d5); #endif } /* Set the Main Chip Clock */ setChipClock(MHz((unsigned int)pInitParam->chipClock)); /* Set up memory clock. */ setMemoryClock(MHz(pInitParam->memClock)); /* Set up master clock */ setMasterClock(MHz(pInitParam->masterClock)); /* Reset the memory controller. If the memory controller is not reset in SM750, the system might hang when sw accesses the memory. The memory should be resetted after changing the MXCLK. */ if (pInitParam->resetMemory == 1) { ulReg = PEEK32(MISC_CTRL); ulReg = FIELD_SET(ulReg, MISC_CTRL, LOCALMEM_RESET, RESET); POKE32(MISC_CTRL, ulReg); ulReg = FIELD_SET(ulReg, MISC_CTRL, LOCALMEM_RESET, NORMAL); POKE32(MISC_CTRL, ulReg); } if (pInitParam->setAllEngOff == 1) { enable2DEngine(0); /* Disable Overlay, if a former application left it on */ ulReg = PEEK32(VIDEO_DISPLAY_CTRL); ulReg = FIELD_SET(ulReg, VIDEO_DISPLAY_CTRL, PLANE, DISABLE); POKE32(VIDEO_DISPLAY_CTRL, ulReg); /* Disable video alpha, if a former application left it on */ ulReg = PEEK32(VIDEO_ALPHA_DISPLAY_CTRL); ulReg = FIELD_SET(ulReg, VIDEO_ALPHA_DISPLAY_CTRL, PLANE, DISABLE); POKE32(VIDEO_ALPHA_DISPLAY_CTRL, ulReg); /* Disable alpha plane, if a former application left it on */ ulReg = PEEK32(ALPHA_DISPLAY_CTRL); 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); POKE32(DMA_ABORT_INTERRUPT, ulReg); /* Disable DMA Power, if a former application left it on */ enableDMA(0); } /* We can add more initialization as needed. */ return 0; }
/* only timing related registers will be programed */ static int programModeRegisters(mode_parameter_t *pModeParam, pll_value_t *pll) { int ret = 0; int cnt = 0; unsigned int ulTmpValue, ulReg; if (pll->clockType == SECONDARY_PLL) { /* programe secondary pixel clock */ POKE32(CRT_PLL_CTRL, formatPllReg(pll)); POKE32(CRT_HORIZONTAL_TOTAL, FIELD_VALUE(0, CRT_HORIZONTAL_TOTAL, TOTAL, pModeParam->horizontal_total - 1) | FIELD_VALUE(0, CRT_HORIZONTAL_TOTAL, DISPLAY_END, pModeParam->horizontal_display_end - 1)); POKE32(CRT_HORIZONTAL_SYNC, FIELD_VALUE(0, CRT_HORIZONTAL_SYNC, WIDTH, pModeParam->horizontal_sync_width) | FIELD_VALUE(0, CRT_HORIZONTAL_SYNC, START, pModeParam->horizontal_sync_start - 1)); POKE32(CRT_VERTICAL_TOTAL, FIELD_VALUE(0, CRT_VERTICAL_TOTAL, TOTAL, pModeParam->vertical_total - 1) | FIELD_VALUE(0, CRT_VERTICAL_TOTAL, DISPLAY_END, pModeParam->vertical_display_end - 1)); POKE32(CRT_VERTICAL_SYNC, FIELD_VALUE(0, CRT_VERTICAL_SYNC, HEIGHT, pModeParam->vertical_sync_height) | FIELD_VALUE(0, CRT_VERTICAL_SYNC, START, pModeParam->vertical_sync_start - 1)); ulTmpValue = FIELD_VALUE(0, CRT_DISPLAY_CTRL, VSYNC_PHASE, pModeParam->vertical_sync_polarity)| FIELD_VALUE(0, CRT_DISPLAY_CTRL, HSYNC_PHASE, pModeParam->horizontal_sync_polarity)| FIELD_SET(0, CRT_DISPLAY_CTRL, TIMING, ENABLE)| FIELD_SET(0, CRT_DISPLAY_CTRL, PLANE, ENABLE); if (getChipType() == SM750LE) { displayControlAdjust_SM750LE(pModeParam, ulTmpValue); } else { ulReg = PEEK32(CRT_DISPLAY_CTRL) & FIELD_CLEAR(CRT_DISPLAY_CTRL, VSYNC_PHASE) & FIELD_CLEAR(CRT_DISPLAY_CTRL, HSYNC_PHASE) & FIELD_CLEAR(CRT_DISPLAY_CTRL, TIMING) & FIELD_CLEAR(CRT_DISPLAY_CTRL, PLANE); POKE32(CRT_DISPLAY_CTRL, ulTmpValue|ulReg); } } else if (pll->clockType == PRIMARY_PLL) { unsigned int ulReservedBits; POKE32(PANEL_PLL_CTRL, formatPllReg(pll)); POKE32(PANEL_HORIZONTAL_TOTAL, FIELD_VALUE(0, PANEL_HORIZONTAL_TOTAL, TOTAL, pModeParam->horizontal_total - 1) | FIELD_VALUE(0, PANEL_HORIZONTAL_TOTAL, DISPLAY_END, pModeParam->horizontal_display_end - 1)); POKE32(PANEL_HORIZONTAL_SYNC, FIELD_VALUE(0, PANEL_HORIZONTAL_SYNC, WIDTH, pModeParam->horizontal_sync_width) | FIELD_VALUE(0, PANEL_HORIZONTAL_SYNC, START, pModeParam->horizontal_sync_start - 1)); POKE32(PANEL_VERTICAL_TOTAL, FIELD_VALUE(0, PANEL_VERTICAL_TOTAL, TOTAL, pModeParam->vertical_total - 1) | FIELD_VALUE(0, PANEL_VERTICAL_TOTAL, DISPLAY_END, pModeParam->vertical_display_end - 1)); POKE32(PANEL_VERTICAL_SYNC, FIELD_VALUE(0, PANEL_VERTICAL_SYNC, HEIGHT, pModeParam->vertical_sync_height) | FIELD_VALUE(0, PANEL_VERTICAL_SYNC, START, pModeParam->vertical_sync_start - 1)); ulTmpValue = FIELD_VALUE(0, PANEL_DISPLAY_CTRL, VSYNC_PHASE, pModeParam->vertical_sync_polarity)| FIELD_VALUE(0, PANEL_DISPLAY_CTRL, HSYNC_PHASE, pModeParam->horizontal_sync_polarity)| FIELD_VALUE(0, PANEL_DISPLAY_CTRL, CLOCK_PHASE, pModeParam->clock_phase_polarity)| FIELD_SET(0, PANEL_DISPLAY_CTRL, TIMING, ENABLE)| FIELD_SET(0, PANEL_DISPLAY_CTRL, PLANE, ENABLE); ulReservedBits = FIELD_SET(0, PANEL_DISPLAY_CTRL, RESERVED_1_MASK, ENABLE) | FIELD_SET(0, PANEL_DISPLAY_CTRL, RESERVED_2_MASK, ENABLE) | FIELD_SET(0, PANEL_DISPLAY_CTRL, RESERVED_3_MASK, ENABLE)| FIELD_SET(0, PANEL_DISPLAY_CTRL, VSYNC, ACTIVE_LOW); ulReg = (PEEK32(PANEL_DISPLAY_CTRL) & ~ulReservedBits) & FIELD_CLEAR(PANEL_DISPLAY_CTRL, CLOCK_PHASE) & FIELD_CLEAR(PANEL_DISPLAY_CTRL, VSYNC_PHASE) & FIELD_CLEAR(PANEL_DISPLAY_CTRL, HSYNC_PHASE) & FIELD_CLEAR(PANEL_DISPLAY_CTRL, TIMING) & FIELD_CLEAR(PANEL_DISPLAY_CTRL, PLANE); /* May a hardware bug or just my test chip (not confirmed). * PANEL_DISPLAY_CTRL register seems requiring few writes * before a value can be successfully written in. * Added some masks to mask out the reserved bits. * Note: This problem happens by design. The hardware will wait for the * next vertical sync to turn on/off the plane. */ POKE32(PANEL_DISPLAY_CTRL, ulTmpValue|ulReg); while ((PEEK32(PANEL_DISPLAY_CTRL) & ~ulReservedBits) != (ulTmpValue|ulReg)) { cnt++; if (cnt > 1000) break; POKE32(PANEL_DISPLAY_CTRL, ulTmpValue|ulReg); } } else { ret = -1; } return ret; }
int ddk750_initHw(initchip_param_t *pInitParam) { unsigned int reg; if (pInitParam->powerMode != 0) pInitParam->powerMode = 0; setPowerMode(pInitParam->powerMode); /* Enable display power gate & LOCALMEM power gate*/ reg = PEEK32(CURRENT_GATE); reg |= (CURRENT_GATE_DISPLAY | CURRENT_GATE_LOCALMEM); setCurrentGate(reg); if (getChipType() != SM750LE) { /* set panel pll and graphic mode via mmio_88 */ reg = PEEK32(VGA_CONFIGURATION); reg |= (VGA_CONFIGURATION_PLL | VGA_CONFIGURATION_MODE); POKE32(VGA_CONFIGURATION, reg); } else { #if defined(__i386__) || defined(__x86_64__) /* set graphic mode via IO method */ outb_p(0x88, 0x3d4); outb_p(0x06, 0x3d5); #endif } /* Set the Main Chip Clock */ setChipClock(MHz((unsigned int)pInitParam->chipClock)); /* Set up memory clock. */ setMemoryClock(MHz(pInitParam->memClock)); /* Set up master clock */ setMasterClock(MHz(pInitParam->masterClock)); /* Reset the memory controller. If the memory controller is not reset in SM750, the system might hang when sw accesses the memory. The memory should be resetted after changing the MXCLK. */ if (pInitParam->resetMemory == 1) { reg = PEEK32(MISC_CTRL); reg &= ~MISC_CTRL_LOCALMEM_RESET; POKE32(MISC_CTRL, reg); reg |= MISC_CTRL_LOCALMEM_RESET; POKE32(MISC_CTRL, reg); } if (pInitParam->setAllEngOff == 1) { enable2DEngine(0); /* Disable Overlay, if a former application left it on */ reg = PEEK32(VIDEO_DISPLAY_CTRL); reg &= ~DISPLAY_CTRL_PLANE; POKE32(VIDEO_DISPLAY_CTRL, reg); /* Disable video alpha, if a former application left it on */ reg = PEEK32(VIDEO_ALPHA_DISPLAY_CTRL); reg &= ~DISPLAY_CTRL_PLANE; POKE32(VIDEO_ALPHA_DISPLAY_CTRL, reg); /* Disable alpha plane, if a former application left it on */ reg = PEEK32(ALPHA_DISPLAY_CTRL); reg &= ~DISPLAY_CTRL_PLANE; POKE32(ALPHA_DISPLAY_CTRL, reg); /* Disable DMA Channel, if a former application left it on */ reg = PEEK32(DMA_ABORT_INTERRUPT); reg |= DMA_ABORT_INTERRUPT_ABORT_1; POKE32(DMA_ABORT_INTERRUPT, reg); /* Disable DMA Power, if a former application left it on */ enableDMA(0); } /* We can add more initialization as needed. */ return 0; }
void hw_cursor_setColor(struct lynx_cursor * cursor, u32 fg,u32 bg) { POKE32(HWC_COLOR_12,(fg<<16)|(bg&0xffff)); POKE32(HWC_COLOR_3,0xffe0); }
static const unsigned long __fli7610_hom_ddr_0[] = { OR32(MPE41_DDR0_PCTL_BASE + DDR_DTU_CFG, DDR_DTU_CFG_ENABLE), synopsys_ddr32_in_hom(MPE41_DDR0_PCTL_BASE), }; static const unsigned long __fli7610_hom_ddr_1[] = { OR32(MPE41_DDR1_PCTL_BASE + DDR_DTU_CFG, DDR_DTU_CFG_ENABLE), synopsys_ddr32_in_hom(MPE41_DDR1_PCTL_BASE), }; static const unsigned long __fli7610_hom_lmi_retention[] = { /* * Enable retention mode gpio */ POKE32(SBC_GPIO_PORT(LMI_RET_GPIO_PORT) + STM_GPIO_REG_CLR_POUT, 1 << LMI_RET_GPIO_PIN), }; static const unsigned long __fli7610_hom_enter_passive[] = { /* * Send message 'ENTER_PASSIVE' (0x5) */ POKE32(SBC_MBX_WRITE_STATUS(0), 0x5), }; #define HOM_TBL(name) { \ .addr = name, \ .size = ARRAY_SIZE(name) * sizeof(long),\ } static struct hom_table fli7610_hom_table[] = {