Esempio n. 1
0
int cleanup_before_linux (void)
{
    /*
     * this function is called just before we call linux
     * it prepares the processor for linux
     *
     * we turn off caches etc ...
     */

    disable_interrupts ();

#ifdef CONFIG_LCD
    {
        extern void lcd_disable(void);
        extern void lcd_panel_disable(void);

        lcd_disable(); /* proper disable of lcd & panel */
        lcd_panel_disable();
    }
#endif

    /* turn off I/D-cache */
    icache_disable();
    dcache_disable();
    /* flush I/D-cache */
    cache_flush();
    /*Workaround to enable L2CC during kernel decompressing*/
#ifdef fixup_before_linux
    fixup_before_linux;
#endif
    return 0;
}
Esempio n. 2
0
/******************************************************************************
* >>> Обработчик прерывания PVD
*/
__irq void PVD_IRQHandler(void){
    switchOFF();
    if(ps.state.bit.osInit != 0){
        nvMem_savePrm(nvMem.nvMemBase);
    }
    lcd_disable();                  //Выключаем LCD
    LED_ON();
    setFanPwm(500);
    BeepTime(100);
    while(1);
}
Esempio n. 3
0
uint32_t lcd_setbias(uint32_t o)
{
  uint32_t param, w, h;

  #define MEM_Y   (7) //MY row address order
  #define MEM_X   (6) //MX column address order 
  #define MEM_V   (5) //MV row / column exchange 
  #define MEM_L   (4) //ML vertical refresh order
  #define MEM_H   (2) //MH horizontal refresh order
  #define MEM_BGR (3) //RGB-BGR Order 

  switch(o)
  {
    default:
    case 0:
    //case 36:
    //case 360:
      w     = LCD_WIDTH;
      h     = LCD_HEIGHT;
      param = (1<<MEM_BGR) | (1<<MEM_X) | (1<<MEM_Y);
      break;
    case 9:
    case 90:
      w     = LCD_HEIGHT;
      h     = LCD_WIDTH;
      param = (1<<MEM_BGR) | (1<<MEM_X) | (1<<MEM_V);
      break;
    case 18:
    case 180:
      w     = LCD_WIDTH;
      h     = LCD_HEIGHT;
      param = (1<<MEM_BGR) | (1<<MEM_L);
      break;
    case 27:
    case 270:
    case 14: //270&0xFF
      w     = LCD_HEIGHT;
      h     = LCD_WIDTH;
      param = (1<<MEM_BGR) | (1<<MEM_Y) | (1<<MEM_V);
      break;
  }

  lcd_enable();

  lcd_wrcmd8(LCD_CMD_MEMACCESS_CTRL);
  lcd_wrdata8(param);

  lcd_setarea(0, 0, w-1, h-1);

  lcd_disable();

  return (w<<16) | (h<<0);
}
Esempio n. 4
0
int cleanup_before_linux(void)
{
	/*
	 * this function is called just before we call linux
	 * it prepares the processor for linux
	 *
	 * we turn off caches etc ...
	 */
#ifndef CONFIG_SPL_BUILD
	disable_interrupts();
#ifdef CONFIG_LCD
	{
		/* switch off LCD panel */
		lcd_panel_disable();
		/* disable LCD controller */
		lcd_disable();
	}
#endif /* CONFIG_LCD */
#endif /* CONFIG_SPL_BUILD */

	/*
	 * Turn off I-cache and invalidate it
	 */
	icache_disable();
	invalidate_icache_all();

	/*
	 * turn off D-cache
	 * dcache_disable() in turn flushes the d-cache and disables MMU
	 */
	dcache_disable();
	v7_outer_cache_disable();

	/*
	 * After D-cache is flushed and before it is disabled there may
	 * be some new valid entries brought into the cache. We are sure
	 * that these lines are not dirty and will not affect our execution.
	 * (because unwinding the call-stack and setting a bit in CP15 SCTRL
	 * is all we did during this. We have not pushed anything on to the
	 * stack. Neither have we affected any static data)
	 * So just invalidate the entire d-cache again to avoid coherency
	 * problems for kernel
	 */
	invalidate_dcache_all();

	/*
	 * Some CPU need more cache attention before starting the kernel.
	 */
	cpu_cache_initialization();

	return 0;
}
Esempio n. 5
0
/*!
    \brief      LCD Configuration
    \param[in]  none
    \param[out] none
    \retval     none
*/
static void lcd_config(void)
{
    /* configure the LCD control line */
    lcd_ctrl_line_config();
    lcd_disable();
    lcd_enable();
    
    /* configure the GPIO of TLI */
    tli_gpio_config();
    /* configure the LCD_SPI */
    lcd_spi_config(); 

    /* power on the LCD */
    //lcd_power_on();
	lcd_power_on3();  //New Version 3.5" TFT RGB Hardware needs use this initilize funtion  ---By xufei 2016.10.21
}
Esempio n. 6
0
void lcd_invert(uint32_t on)
{
  lcd_enable();

  if(on == 0)
  {
     lcd_wrcmd8(LCD_CMD_INV_OFF);
  }
  else
  {
     lcd_wrcmd8(LCD_CMD_INV_ON);
  }

  lcd_disable();

  return;
}
Esempio n. 7
0
/* search for keyboard and register it if found */
int drv_keyboard_init(void)
{
	int error = 0;
	struct stdio_dev kbd_dev;

	if (0) {
		/* register the keyboard */
		memset (&kbd_dev, 0, sizeof(struct stdio_dev));
		strcpy(kbd_dev.name, "kbd");
		kbd_dev.flags =  DEV_FLAGS_INPUT | DEV_FLAGS_SYSTEM;
		kbd_dev.putc = NULL;
		kbd_dev.puts = NULL;
		kbd_dev.getc = smc1_getc;
		kbd_dev.tstc = smc1_tstc;
		error = stdio_register (&kbd_dev);
	} else {
		lcd_is_enabled = 0;
		lcd_disable();
	}
	return error;
}
static void display_image(enum image_t image, uint16_t soc)
{
	uint16_t *image_start;
	uint16_t *image_end;

	if (soc < SOC_THRESH_DISPLAY_MIN) {
		lcd_disable();
		lcd_is_on = 0;
		return;
	}

	switch(image) {
	case IMAGE_CHARGE_NEEDED:
		image_start = (uint16_t *) _binary_connect_charge_rle_start;
		image_end = (uint16_t *) _binary_connect_charge_rle_end;
		break;
	case IMAGE_CHARGING:
		image_start = (uint16_t *) _binary_lowbatt_charge_rle_start;
		image_end = (uint16_t *) _binary_lowbatt_charge_rle_end;
		break;
	case IMAGE_BOOT:
	default:
		image_start = (uint16_t *) _binary_o_nookcolor_logo_large_rle_start;
		image_end = (uint16_t *) _binary_o_nookcolor_logo_large_rle_end;
		break;
	}

	if (!lcd_is_on) {
		spi_init();
		lcd_enable();
		lcd_is_on = 1;
	}

	if (image == IMAGE_BOOT) {
		lcd_bl_set_brightness(255);
	}

	lcd_display_image(image_start, image_end);
}
Esempio n. 9
0
void lcd_power(uint32_t on)
{
  lcd_enable();

  if(on == 0)
  {
    lcd_wrcmd8(LCD_CMD_DISPLAY_OFF);
    delay_ms(20);
    lcd_wrcmd8(LCD_CMD_SLEEPIN);
    delay_ms(120);
  }
  else
  {
    lcd_wrcmd8(LCD_CMD_SLEEPOUT);
    delay_ms(120);
    lcd_wrcmd8(LCD_CMD_DISPLAY_ON);
    delay_ms(20);
  }

  lcd_disable();

  return;
}
Esempio n. 10
0
void lcd_reset(void)
{
  uint32_t c, i, j;
  uint8_t initdata[] = 
  {
    //0x40| 1, LCD_CMD_RESET,
    //0xC0|60,
    //0xC0|60,
    0x40| 1, LCD_CMD_DISPLAY_OFF,
    0xC0|20,
    0x40| 1, LCD_CMD_POWER_CTRLB,
    0x80| 3, 0x00, 0x83, 0x30, //0x83 0x81 0xAA
    0x40| 1, LCD_CMD_POWERON_SEQ_CTRL,
    0x80| 4, 0x64, 0x03, 0x12, 0x81, //0x64 0x67
    0x40| 1, LCD_CMD_DRV_TIMING_CTRLA,
    0x80| 3, 0x85, 0x01, 0x79, //0x79 0x78
    0x40| 1, LCD_CMD_POWER_CTRLA,
    0x80| 5, 0x39, 0X2C, 0x00, 0x34, 0x02,
    0x40| 1, LCD_CMD_PUMP_RATIO_CTRL,
    0x80| 1, 0x20,
    0x40| 1, LCD_CMD_DRV_TIMING_CTRLB,
    0x80| 2, 0x00, 0x00,
    0x40| 1, LCD_CMD_POWER_CTRL1,
    0x80| 1, 0x26, //0x26 0x25
    0x40| 1, LCD_CMD_POWER_CTRL2,
    0x80| 1, 0x11,
    0x40| 1, LCD_CMD_VCOM_CTRL1,
    0x80| 2, 0x35, 0x3E,
    0x40| 1, LCD_CMD_VCOM_CTRL2,
    0x80| 1, 0xBE, //0xBE 0x94
    0x40| 1, LCD_CMD_FRAME_CTRL,
    0x80| 2, 0x00, 0x1B, //0x1B 0x70
    0x40| 1, LCD_CMD_ENABLE_3G,
    0x80| 1, 0x08, //0x08 0x00
    0x40| 1, LCD_CMD_GAMMA,
    0x80| 1, 0x01, //G2.2
    0x40| 1, LCD_CMD_POS_GAMMA,
    0x80|15, 0x1F, 0x1A, 0x18, 0x0A, 0x0F, 0x06, 0x45, 0x87, 0x32, 0x0A, 0x07, 0x02, 0x07, 0x05, 0x00,
  //0x80|15, 0x0F, 0x1A, 0x18, 0x0A, 0x0F, 0x06, 0x45, 0x87, 0x32, 0x0A, 0x07, 0x02, 0x07, 0x05, 0x00,
    0x40| 1, LCD_CMD_NEG_GAMMA,
    0x80|15, 0x00, 0x25, 0x27, 0x05, 0x10, 0x09, 0x3A, 0x78, 0x4D, 0x05, 0x18, 0x0D, 0x38, 0x3A, 0x1F,
  //0x80|15, 0x00, 0x25, 0x27, 0x05, 0x10, 0x09, 0x3A, 0x78, 0x4D, 0x05, 0x18, 0x0D, 0x38, 0x3A, 0x0F,
    0x40| 1, LCD_CMD_DISPLAY_CTRL,
    0x80| 4, 0x0A, 0x82, 0x27, 0x00,
    0x40| 1, LCD_CMD_ENTRY_MODE,
    0x80| 1, 0x07,
    0x40| 1, LCD_CMD_PIXEL_FORMAT,
    0x80| 1, 0x55, //16bit
    0x40| 1, LCD_CMD_MEMACCESS_CTRL,
    0x80| 1, (1<<MEM_BGR) | (1<<MEM_X) | (1<<MEM_Y),
    0x40| 1, LCD_CMD_COLUMN,
    0x80| 2, 0x00, 0x00,
    0x80| 2, ((LCD_HEIGHT-1)>>8)&0xFF, (LCD_HEIGHT-1)&0xFF,
    0x40| 1, LCD_CMD_PAGE,
    0x80| 2, 0x00, 0x00,
    0x80| 2, ((LCD_WIDTH-1)>>8)&0xFF, (LCD_WIDTH-1)&0xFF,
    0x40| 1, LCD_CMD_SLEEPOUT,
    0xC0|60,
    0xC0|60,
    0x40| 1, LCD_CMD_DISPLAY_ON,
    0xC0|20,
  };

  //init pins
  INIT_PINS();

  //hardware reset
  GPIO_CLRPIN(LCD_PORT, RST_PIN);
  delay_ms(20);
  GPIO_SETPIN(LCD_PORT, RST_PIN);
  delay_ms(120);

  lcd_enable();

  //send init commands and data
  for(i=0; i<sizeof(initdata);)
  {
    c = initdata[i++];
    switch(c&0xC0)
    {
      case 0x40: //command
        for(j=c&0x3F; j!=0; j--)
        {
          c = initdata[i++];
          lcd_wrcmd8(c);
        }
        break;

      case 0x80: //data
        for(j=c&0x3F; j!=0; j--)
        {
          c = initdata[i++];
          lcd_wrdata8(c);
        }
        break;

      case 0xC0: //delay
        delay_ms(c&0x3F);
        break;
    }
  }

  //clear display buffer
  lcd_drawstart();
  for(i=(LCD_WIDTH*LCD_HEIGHT); i!=0; i--)
  {
    lcd_draw(0);
  }
  lcd_drawstop();

  lcd_disable();

  return;
}
static void charge_loop(uint16_t *batt_soc, int emergency_charge)
{
	enum charge_level_t charge_level, charge_level_new;
	int tick = 0;
	uint16_t voltage = 0;
	u8 pwron;
	int microvolts, ret;
	int action = READ_BATTERY; // initially we wan't to read the battery status

	charge_level = charger_detect();
	charger_enable(charge_level, emergency_charge);
	// and we wan't to display a charge status image
	display_image_charging(*batt_soc, charge_level);

	while ((*batt_soc < SOC_THRESH_MIN || emergency_charge) &&
			charge_level != CHARGE_DISABLE) {	
		if (action & READ_BATTERY) {
			ret = max17042_soc(batt_soc);
		
			if (ret) {
				printf("Failed to read battery capacity, reason: %d\n", ret);
				if (!emergency_charge) {
					break;
				}
			}

			ret = max17042_voltage(&voltage);

			if (ret) {
				printf("Failed to read battery voltage, reason: %d\n", ret);

				if (!emergency_charge) {
					break;
				}
			}
		
			microvolts = voltage*625;
			printf("Charging... %hu%% (%d uV)\n", *batt_soc, microvolts);

			// If microvolts isn't 0 then we can talk to the gas gauge
			// and we no longer need to emergency charge
			emergency_charge = (microvolts <= 0);

			charge_level_new = charger_detect();

			if (charge_level != charge_level_new) {
				// to avoid re-writing the GPIOs all the time
				charge_level = charge_level_new;
				charger_enable(charge_level, emergency_charge);
			}
		}

		if (action & UPDATE_DISPLAY) {
			pwron = 0;
			if (twl6030_hw_status(&pwron)) {
				printf("Failed to read twl6030 hw_status\n");
			}

			// if button is pressed turn on screen
			if ((pwron & STS_PWRON) != STS_PWRON) {
				display_image_charging(*batt_soc, charge_level);
			} else if (lcd_is_on) {
				// if not turn off screen
				lcd_disable();
				lcd_is_on = 0;
			}
		}

		// each tick is 200 ms
		udelay(1000 * 200);
		++tick; // tick will overflow in approx. 4971 days
		action = get_charge_action(tick);
	}

	if (charge_level != CHARGE_DISABLE) {
		charger_enable(CHARGE_DISABLE, emergency_charge);
	}
}
Esempio n. 12
0
int enter_boot_power_down()
{
    int key;
    int ac;
    
    power_gate_init();
    lcd_disable();
    video_dac_disable();
    camera_power_off() ;
    vcc2_power_off();
    //turn_off_audio_DAC();
    if (!early_suspend_flag) {
        printf("\n boot_suspend \n");
//        if (pdata->set_exgpio_early_suspend) {
//            pdata->set_exgpio_early_suspend(OFF);
//        }
        early_power_gate_switch(OFF);
        early_clk_switch(OFF);
        early_pll_switch(OFF);
        early_suspend_flag = 1;
    }
    
    printf("enter boot_pm_suspend!\n");
    analog_switch(OFF);
    usb_switch(OFF, 0);
    usb_switch(OFF, 1);
//    if (pdata->set_vccx2) {
//        pdata->set_vccx2(OFF);
//    }
    power_gate_switch(OFF);
    clk_switch(OFF);
    pll_switch(OFF);
    clrbits_le32(P_HHI_SYS_CPU_CLK_CNTL,1<<7); //change A9-->24M 

    
    printf("boot sleep ...\n");
//	WRITE_MPEG_REG_BITS(HHI_MALI_CLK_CNTL, 0, 9, 3); // mali use xtal
//    CLEAR_CBUS_REG_MASK(HHI_SYS_CPU_CLK_CNTL, 1<<7);  // a9 use xtal
//    SET_CBUS_REG_MASK(HHI_SYS_PLL_CNTL, (1 << 15));   // turn off sys pll
//    
//    meson_power_suspend();
    
    key = powerkey_scan();
    ac = axp_charger_is_ac_online();
    while((!key)&&ac) 
    {
        key = powerkey_scan();
        ac = axp_charger_is_ac_online();
    }
    setbits_le32(P_HHI_SYS_CPU_CLK_CNTL,1<<7); //change A9-->normal 

    
    printf("boot... wake up\n");
//    if (pdata->set_vccx2) {
//        pdata->set_vccx2(ON);
//    }
    SET_CBUS_REG_MASK(HHI_SYS_CPU_CLK_CNTL, (1 << 7));  // a9 use pll
    WRITE_MPEG_REG_BITS(HHI_MALI_CLK_CNTL, 3, 9, 3); // mali use pll

    pll_switch(ON);
    clk_switch(ON);
    power_gate_switch(ON);
    usb_switch(ON, 0);
    usb_switch(ON, 1);
    analog_switch(ON);
    if (early_suspend_flag) {
        early_pll_switch(ON);
        early_clk_switch(ON);
        early_power_gate_switch(ON);
        early_suspend_flag = 0;
        printf("boot sys_resume\n");
    }    
    
    printf("mlvds init\n");
    lcd_enable();  
    printf("mlvds init finish\n");  
    
    return ac;
}
Esempio n. 13
0
void lcd_ctrl_init_70(void *lcdbase)
{
	ulong freq_lcdclk; 
	ulong freq_Hclk;
	ulong fb_size;
	unsigned char nn;
	unsigned short *pp;
	int i;

	GPICON_REG = 0xaaaaaaaa;
	GPIPUD_REG = 0xaaaaaaaa;
	GPJCON_REG = 0xaaaaaaaa;
	GPJPUD_REG = 0xaaaaaaaa;

	lcd_disable();
	S3C_WINCON0 &= (~(S3C_WINCONx_ENWIN_F_ENABLE));

	MIFPCON_REG &= (~SEL_BYPASS_MASK);
	SPCON_REG &= (~LCD_SEL_MASK);
	SPCON_REG |= (RGB_IF_STYLE_MASK);

	freq_lcdclk = S3CFB_PIXEL_CLOCK;
	freq_Hclk = get_HCLK();

	nn = (unsigned char)(freq_Hclk / freq_lcdclk) - 1;
	if(freq_lcdclk < freq_Hclk/2)
	{
		S3C_VIDCON0 = S3C_VIDCON0_INTERLACE_F_PROGRESSIVE + S3C_VIDCON0_VIDOUT_RGB_IF + \
		        S3C_VIDCON0_PNRMODE_RGB_P + S3C_VIDCON0_CLKVALUP_ST_FRM + S3C_VIDCON0_CLKVAL_F(nn) + \
		        S3C_VIDCON0_CLKDIR_DIVIDED + S3C_VIDCON0_CLKSEL_F_HCLK;
	}else
	{
		S3C_VIDCON0 = S3C_VIDCON0_INTERLACE_F_PROGRESSIVE + S3C_VIDCON0_VIDOUT_RGB_IF + \
		        S3C_VIDCON0_PNRMODE_RGB_P + S3C_VIDCON0_CLKVALUP_ST_FRM + S3C_VIDCON0_CLKVAL_F(0) + \
		        S3C_VIDCON0_CLKDIR_DIRECTED  + S3C_VIDCON0_CLKSEL_F_HCLK;
	}

	nn = 0;
	if(S3CFB_IVCLK)
	{
		nn += S3C_VIDCON1_IVCLK_RISE_EDGE;
	}
	if(S3CFB_IHSYNC)
	{
		nn += S3C_VIDCON1_IHSYNC_INVERT;
	}
	if(S3CFB_IVSYNC)
	{
		nn += S3C_VIDCON1_IVSYNC_INVERT;
	}
	if(S3CFB_IVDEN)
	{
		nn += S3C_VIDCON1_IVDEN_INVERT;
	}
	S3C_VIDCON1 = (unsigned int)nn;
	S3C_VIDCON2 = 0;

	S3C_VIDTCON0 = S3C_VIDTCON0_VBPD(S3CFB_VBP - 1) | S3C_VIDTCON0_VFPD(S3CFB_VFP - 1) | S3C_VIDTCON0_VSPW(S3CFB_VSW - 1);
	S3C_VIDTCON1 = S3C_VIDTCON1_HBPD(S3CFB_HBP - 1) | S3C_VIDTCON1_HFPD(S3CFB_HFP -1) | S3C_VIDTCON1_HSPW(S3CFB_HSW - 1);
	S3C_VIDTCON2 = S3C_VIDTCON2_LINEVAL(S3CFB_VRES - 1) | S3C_VIDTCON2_HOZVAL(S3CFB_HRES - 1);

#if LCD_BPP == LCD_COLOR32
	S3C_WINCON0 = S3C_WINCONx_BPPMODE_F_24BPP_888;
	S3C_WINCON1 = S3C_WINCONx_BPPMODE_F_24BPP_888 | S3C_WINCONx_BLD_PIX_PIXEL;
#else
	S3C_WINCON0 = S3C_WINCONx_BPPMODE_F_16BPP_565 | S3C_WINCONx_HAWSWP_ENABLE;
	S3C_WINCON1 = S3C_WINCONx_BPPMODE_F_16BPP_565 | S3C_WINCONx_HAWSWP_ENABLE | S3C_WINCONx_BLD_PIX_PIXEL;
#endif

	S3C_WINCON2 = 0;
	S3C_WINCON3 = 0;
	S3C_WINCON4 = 0;

	S3C_VIDOSD0A = S3C_VIDOSDxA_OSD_LTX_F(0) + S3C_VIDOSDxA_OSD_LTY_F(0);
	S3C_VIDOSD0B = S3C_VIDOSDxB_OSD_RBX_F(S3CFB_HRES - 1) | S3C_VIDOSDxB_OSD_RBY_F(S3CFB_VRES - 1);
	S3C_VIDOSD0C = S3C_VIDOSD0C_OSDSIZE(S3CFB_HRES*S3CFB_VRES);

	S3C_VIDOSD1A = S3C_VIDOSDxA_OSD_LTX_F(0) + S3C_VIDOSDxA_OSD_LTY_F(0);
	S3C_VIDOSD1B = S3C_VIDOSDxB_OSD_RBX_F(S3CFB_HRES - 1) | S3C_VIDOSDxB_OSD_RBY_F(S3CFB_VRES - 1);
	S3C_VIDOSD1C = 0xDDD000;/*alpha blending*/
	S3C_VIDOSD1D = S3C_VIDOSD0C_OSDSIZE(S3CFB_HRES*S3CFB_VRES);

	S3C_VIDOSD2A = 0;
	S3C_VIDOSD2B = 0;
	S3C_VIDOSD2C = 0;
	S3C_VIDOSD2D = 0;
	S3C_VIDOSD3A = 0;
	S3C_VIDOSD3B = 0;
	S3C_VIDOSD3C = 0;
	S3C_VIDOSD4A = 0;
	S3C_VIDOSD4B = 0;
	S3C_VIDOSD4C = 0;

	fb_size = calc_fbsize();

	S3C_VIDW00ADD0B0 = virt_to_phys(lcdbase);
	S3C_VIDW00ADD0B1 = 0;
	S3C_VIDW01ADD0B0 = virt_to_phys(osd_frame_buffer);
	S3C_VIDW01ADD0B1 = 0;
	S3C_VIDW02ADD0 = 0;
	S3C_VIDW03ADD0 = 0;
	S3C_VIDW04ADD0 = 0;

	S3C_VIDW00ADD1B0 = virt_to_phys((unsigned int)(lcdbase) + fb_size);
	S3C_VIDW00ADD1B1 = 0;
	S3C_VIDW01ADD1B0 = virt_to_phys(osd_frame_buffer) + fb_size;
	S3C_VIDW01ADD1B1 = 0;
	S3C_VIDW02ADD1 = 0;
	S3C_VIDW03ADD1 = 0;
	S3C_VIDW04ADD1 = 0;

	S3C_VIDW00ADD2 = 0;//S3C_VIDWxxADD2_OFFSIZE_F(0) | (S3C_VIDWxxADD2_PAGEWIDTH_F(panel_info.vl_col*panel_info.vl_bpix/8));
	S3C_VIDW01ADD2 = 0;//S3C_VIDWxxADD2_OFFSIZE_F(0) | (S3C_VIDWxxADD2_PAGEWIDTH_F(panel_info.vl_col*panel_info.vl_bpix/8));
	S3C_VIDW02ADD2 = 0;
	S3C_VIDW03ADD2 = 0;
	S3C_VIDW04ADD2 = 0;

	S3C_W1KEYCON0  = S3C_WxKEYCON0_KEYBLEN_ENABLE | S3C_WxKEYCON0_KEYEN_F_ENABLE | S3C_WxKEYCON0_COMPKEY(0xFFFF);
	S3C_W1KEYCON1  = 0x00000000;/*color key*/

#if 1
	memset(lcdbase,0x00,fb_size*2);
#else
	pp = lcdbase;
	for(i=0;i< S3CFB_HRES * S3CFB_VRES;i++)
	{
		*pp = 0xf100;
		pp++;
	}
#endif
	lcd_enable();

	S3C_WINCON0 |= S3C_WINCONx_ENWIN_F_ENABLE;
	S3C_WINCON1 |= S3C_WINCONx_ENWIN_F_ENABLE;
	return (0);
}
Esempio n. 14
0
/* Write to the 0x0XXX range of ports */
static void control_write(const uint16_t pio, const uint8_t byte, bool poke) {
    unsigned int i;
    uint8_t index = (uint8_t)pio;
    (void)poke;

    switch (index) {
        case 0x00:
            control.ports[index] = byte & 0x93;
            if (byte & (1 << 4)) {
                cpu_crash("writing to bit 4 of port 0");
            }
            /* Setting this bit turns off the calc (not implemented yet) */
            if (byte & (1 << 6)) {
                control.off = true;
            }
            switch (control.readBatteryStatus) {
                case 3: /* Battery Level is 0 */
                    control.readBatteryStatus = control.setBatteryStatus == BATTERY_0 ? 0 : byte & 0x80 ? 5 : 0;
                    break;
                case 5: /* Battery Level is 1 */
                    control.readBatteryStatus = control.setBatteryStatus == BATTERY_1 ? 0 : byte & 0x80 ? 0 : 7;
                    break;
                case 7: /* Battery Level is 2 */
                    control.readBatteryStatus = control.setBatteryStatus == BATTERY_2 ? 0 : byte & 0x80 ? 9 : 0;
                    break;
                case 9: /* Battery Level is 3 (Or 4) */
                    control.readBatteryStatus = control.setBatteryStatus == BATTERY_3 ? 0 : byte & 0x80 ? 0 : 11;
                    break;
            }
            break;
        case 0x01:
            control.ports[index] = byte & 19;
            control.cpuSpeed = byte & 3;
            switch(control.cpuSpeed) {
                case 0:
                    set_cpu_clock(6e6);  /* 6 MHz  */
                    break;
                case 1:
                    set_cpu_clock(12e6); /* 12 MHz */
                    break;
                case 2:
                    set_cpu_clock(24e6); /* 24 MHz */
                    break;
                case 3:
                    set_cpu_clock(48e6); /* 48 MHz */
                    break;
                default:
                    break;
            }
            break;
        case 0x05:
            if (control.ports[index] & (1 << 6) && !(byte & (1 << 6))) {
                cpu_crash("resetting bit 6 of port 5");
            }
            control.ports[index] = byte & 0x1F;
            break;
        case 0x06:
            control.protectedPortsUnlocked = byte & 7;
            if (!protected_ports_unlocked()) {
                control.flashUnlocked &= ~(1 << 3);
            }
            break;
        case 0x07:
            control.readBatteryStatus = (byte & 0x90) ? 1 : 0;
            break;
        case 0x09:
            switch (control.readBatteryStatus) {
                case 1: /* Battery is bad */
                    control.readBatteryStatus = control.setBatteryStatus == BATTERY_DISCHARGED ? 0 : byte & 0x80 ? 0 : 3;
                    break;
            }
            control.ports[index] = byte;

            if (byte == 0xD4) {
                control.ports[0] |= 1 << 6;
                cpu_crash("entering sleep mode");
#ifdef DEBUG_SUPPORT
                if (debug.openOnReset) {
                    debug_open(DBG_MISC_RESET, cpu.registers.PC);
                }
#endif
            }
            break;
        case 0x0A:
            control.readBatteryStatus += (control.readBatteryStatus == 3) ? 1 : 0;
            control.ports[index] = byte;
            break;
        case 0x0B:
        case 0x0C:
            control.readBatteryStatus = 0;
            break;
        case 0x0D:
            /* This bit disables vram and makes it garbage */
            if (!(byte & (1 << 3))) {
                lcd_disable();
                for (i = LCD_RAM_OFFSET; i < LCD_RAM_OFFSET + LCD_BYTE_SIZE; i++) {
                    mem.ram.block[i] = rand();
                }
            } else {
                lcd_update();
            }
            control.ports[index] = (byte & 0xF) << 4 | (byte & 0xF);
            break;
        case 0x0F:
            control.ports[index] = byte & 3;
            break;
        case 0x1D: case 0x1E: case 0x1F:
            write8(control.privileged, (index - 0x1D) << 3, byte);
            break;
        case 0x20: case 0x21: case 0x22:
            write8(control.protectedStart, (index - 0x20) << 3, byte);
            break;
        case 0x23: case 0x24: case 0x25:
            write8(control.protectedEnd, (index - 0x23) << 3, byte);
            break;
        case 0x28:
            control.flashUnlocked = (control.flashUnlocked | 5) & byte;
            break;
        case 0x29:
            control.ports[index] = byte & 1;
            break;
        case 0x3A: case 0x3B: case 0x3C:
            write8(control.stackLimit, (index - 0x3A) << 3, byte);
            break;
        case 0x3E:
            control.protectionStatus &= ~byte;
            break;
        default:
            control.ports[index] = byte;
            break;
    }
}
Esempio n. 15
0
File: lcd.c Progetto: horazont/hint
void lcd_init()
{
    const uint8_t MEM_BGR = 3;
    const uint8_t MEM_X = 6;
    const uint8_t MEM_Y = 7;

    uint8_t init_sequence[] = {
        VCMD_COMMAND | 1, LCD_CMD_RESET,
        VCMD_SLEEP   |20,
        VCMD_COMMAND | 1, LCD_CMD_DISPLAY_OFF,
        VCMD_SLEEP   |20,
        VCMD_COMMAND | 1, LCD_CMD_POWER_CTRLB,
        VCMD_DATA    | 3, 0x00, 0x83, 0x30, //0x83 0x81 0xAA
        VCMD_COMMAND | 1, LCD_CMD_POWERON_SEQ_CTRL,
        VCMD_DATA    | 4, 0x64, 0x03, 0x12, 0x81, //0x64 0x67
        VCMD_COMMAND | 1, LCD_CMD_DRV_TIMING_CTRLA,
        VCMD_DATA    | 3, 0x85, 0x01, 0x79, //0x79 0x78
        VCMD_COMMAND | 1, LCD_CMD_POWER_CTRLA,
        VCMD_DATA    | 5, 0x39, 0X2C, 0x00, 0x34, 0x02,
        VCMD_COMMAND | 1, LCD_CMD_PUMP_RATIO_CTRL,
        VCMD_DATA    | 1, 0x20,
        VCMD_COMMAND | 1, LCD_CMD_DRV_TIMING_CTRLB,
        VCMD_DATA    | 2, 0x00, 0x00,
        VCMD_COMMAND | 1, LCD_CMD_POWER_CTRL1,
        VCMD_DATA    | 1, 0x26, //0x26 0x25
        VCMD_COMMAND | 1, LCD_CMD_POWER_CTRL2,
        VCMD_DATA    | 1, 0x11,
        VCMD_COMMAND | 1, LCD_CMD_VCOM_CTRL1,
        VCMD_DATA    | 2, 0x35, 0x3E,
        VCMD_COMMAND | 1, LCD_CMD_VCOM_CTRL2,
        VCMD_DATA    | 1, 0xBE, //0xBE 0x94
        VCMD_COMMAND | 1, LCD_CMD_FRAME_CTRL,
        VCMD_DATA    | 2, 0x00, 0x1B, //0x1B 0x70
        VCMD_COMMAND | 1, LCD_CMD_ENABLE_3G,
        VCMD_DATA    | 1, 0x08, //0x08 0x00
        VCMD_COMMAND | 1, LCD_CMD_GAMMA,
        VCMD_DATA    | 1, 0x01, //G2.2
        VCMD_COMMAND | 1, LCD_CMD_POS_GAMMA,
        VCMD_DATA    |15, 0x1F, 0x1A, 0x18, 0x0A, 0x0F, 0x06, 0x45, 0x87, 0x32, 0x0A, 0x07, 0x02, 0x07, 0x05, 0x00,
        VCMD_COMMAND | 1, LCD_CMD_NEG_GAMMA,
        VCMD_DATA    |15, 0x00, 0x25, 0x27, 0x05, 0x10, 0x09, 0x3A, 0x78, 0x4D, 0x05, 0x18, 0x0D, 0x38, 0x3A, 0x1F,
        VCMD_COMMAND | 1, LCD_CMD_DISPLAY_CTRL,
        VCMD_DATA    | 4, 0x0A, 0x82, 0x27, 0x00,
        VCMD_COMMAND | 1, LCD_CMD_ENTRY_MODE,
        VCMD_DATA    | 1, 0x07,
        VCMD_COMMAND | 1, LCD_CMD_PIXEL_FORMAT,
        VCMD_DATA    | 1, 0x55, //16bit
        VCMD_COMMAND | 1, LCD_CMD_MEMACCESS_CTRL,
        VCMD_DATA    | 1, (1<<MEM_BGR) | (1<<MEM_X) | (1<<MEM_Y),
        VCMD_COMMAND | 1, LCD_CMD_COLUMN,
        VCMD_DATA    | 2, 0x00, 0x00,
        VCMD_DATA    | 2, ((LCD_HEIGHT-1)>>8)&0xFF, (LCD_HEIGHT-1)&0xFF,
        VCMD_COMMAND | 1, LCD_CMD_PAGE,
        VCMD_DATA    | 2, 0x00, 0x00,
        VCMD_DATA    | 2, ((LCD_WIDTH-1)>>8)&0xFF, (LCD_WIDTH-1)&0xFF,
        VCMD_COMMAND | 1, LCD_CMD_SLEEPOUT,
        VCMD_SLEEP   |60,
        VCMD_SLEEP   |60,
        VCMD_COMMAND | 1, LCD_CMD_DISPLAY_ON,
        VCMD_SLEEP   |20,
    };

    DISABLE_IRQ();

    // initialize pins
    IOCON_PIO2_0  &= ~IOCON_PIO2_0_FUNC_MASK;
    IOCON_PIO2_1  &= ~IOCON_PIO2_1_FUNC_MASK;
    IOCON_PIO2_2  &= ~IOCON_PIO2_2_FUNC_MASK;
    IOCON_PIO2_3  &= ~IOCON_PIO2_3_FUNC_MASK;
    IOCON_PIO2_4  &= ~IOCON_PIO2_4_FUNC_MASK;
    IOCON_PIO2_5  &= ~IOCON_PIO2_5_FUNC_MASK;
    IOCON_PIO2_6  &= ~IOCON_PIO2_6_FUNC_MASK;
    IOCON_PIO2_7  &= ~IOCON_PIO2_7_FUNC_MASK;
    IOCON_PIO2_8  &= ~IOCON_PIO2_8_FUNC_MASK;
    IOCON_PIO2_9  &= ~IOCON_PIO2_9_FUNC_MASK;
    IOCON_PIO2_10 &= ~IOCON_PIO2_10_FUNC_MASK;
    IOCON_PIO2_11 &= ~IOCON_PIO2_11_FUNC_MASK;

    IOCON_PIO3_5  &= ~IOCON_PIO3_5_FUNC_MASK;

    // set all 12 pins to output mode
    GPIO_GPIO2DIR |= 0xFFF;
    // set all pins high
    LCD_GPIO |= 0xFFF;

    // set pin 5 of gpio 3 to output mode
    GPIO_GPIO3DIR |= LCD_RD_MASK;
    GPIO_GPIO3DATA |= LCD_RD_MASK;

    ENABLE_IRQ();

    // trigger hard-reset
    LCD_MASKED_GPIO(LCD_RST_MASK, 0);
    delay_ms(20);
    LCD_MASKED_GPIO(LCD_RST_MASK, LCD_RST_MASK);
    delay_ms(120);

    lcd_enable();
    delay_ms(1);

    for (unsigned int i = 0; i < sizeof(init_sequence);) {
        uint8_t instruction = init_sequence[i++];
        switch (instruction & 0xC0) {
        case VCMD_COMMAND:
        {
            //~ printf("cmd 0x%02x", instruction & 0x3f);
            for (int j = (instruction & 0x3f); j > 0; j--) {
                uint8_t data = init_sequence[i++];
                //~ printf(" 0x%02x", data);
                lcd_wrcmd8(data);
            }
            //~ printf("\n");
            break;
        }
        case VCMD_DATA:
        {
            //~ printf("data 0x%02x\n", instruction & 0x3f);
            for (int j = (instruction & 0x3f); j > 0; j--) {
                uint8_t data = init_sequence[i++];
                //~ printf(" 0x%02x", data);
                lcd_wrdata8(data);
            }
            //~ printf("\n");
            break;
        }
        case VCMD_SLEEP:
        {
            //~ printf("sleep %d\n", instruction & 0x3f);
            delay_ms(instruction & 0x3f);
            break;
        }
        default:
            // cannot happen :)
            continue;
        };
    }

    lcd_drawstart();
    for (int i = (LCD_WIDTH*LCD_HEIGHT/8); i > 0; i--) {
        lcd_draw(0);
        lcd_draw(0);
        lcd_draw(0);
        lcd_draw(0);
        lcd_draw(0);
        lcd_draw(0);
        lcd_draw(0);
        lcd_draw(0);
    }
    lcd_drawstop();

    lcd_disable();
}