int main (void) { SystemInit(); #if 0 if (0x00000004 & inp32(0x40000038)) { outp32(0x40000038, 0x80000000); } else { Led_flash(); while(1); } #endif /* Initialize GPIO */ gpio_init(cb_gpio); #if TEST_SLEEP_NORMAL == TRUE // -------------------------------------------- // sleep wakeup // -------------------------------------------- //set all pin to gpio syscon_SetPMCR0(QN_SYSCON, 0x00000000); syscon_SetPMCR1(QN_SYSCON, 0x00000000); //set all gpio input gpio_set_direction_field(GPIO_PIN_ALL, GPIO_INPUT); gpio_write_pin_field(GPIO_PIN_ALL, (uint32_t)GPIO_HIGH); // pin pull ( 00 : High-Z, 01 : Pull-down, 10 : Pull-up, 11 : Reserved ) syscon_SetPPCR0(QN_SYSCON, 0xAAAA5AAA); // SWD pull-down save 20uA syscon_SetPPCR1(QN_SYSCON, 0x2AAAAAAA); // power down BUCK needed syscon_SetIvrefX32WithMask(QN_SYSCON, SYSCON_MASK_BUCK_BYPASS|SYSCON_MASK_BUCK_DPD, MASK_ENABLE); // power down Flash syscon_SetPGCR2WithMask(QN_SYSCON, SYSCON_MASK_FLASH_VCC_EN, MASK_DISABLE); // enable dbg power down syscon_SetPGCR2WithMask(QN_SYSCON, SYSCON_MASK_DBGPMUENABLE, MASK_ENABLE); // dis sar adc buffer syscon_SetPGCR1WithMask(QN_SYSCON, SYSCON_MASK_DIS_SAR_BUF, MASK_ENABLE); Led_flash(); do { delay(10); } while (gpio_read_pin(GPIO_P14) == GPIO_HIGH); sleep_init(); wakeup_by_sleep_timer(__32K_TYPE); wakeup_by_gpio(GPIO_P15, GPIO_WKUP_BY_LOW); do { gpio_set_direction(GPIO_P01, GPIO_INPUT); //enter_sleep(SLEEP_NORMAL, WAKEUP_BY_GPIO, Led_flash); if (wakeup_form_sleeptimer) { sleep_timer_set(32000); wakeup_form_sleeptimer = 0; #if QN_32K_RCO == TRUE clock_32k_correction_enable(clock_32k_correction_cb); #endif } #if QN_32K_RCO == TRUE if (gpio_sleep_allowed() && !dev_get_bf()) #else if (gpio_sleep_allowed()) #endif enter_sleep(SLEEP_NORMAL, WAKEUP_BY_OSC_EN|WAKEUP_BY_GPIO, Led_flash); } while(1); #endif #if TEST_SLEEP_DEEP == TRUE // -------------------------------------------- // deep sleep wakeup // -------------------------------------------- //set all pin to gpio syscon_SetPMCR0(QN_SYSCON, 0x00000000); syscon_SetPMCR1(QN_SYSCON, 0x00000000); //set all gpio input gpio_set_direction_field(GPIO_PIN_ALL, (uint32_t)GPIO_INPUT); gpio_write_pin_field(GPIO_PIN_ALL, (uint32_t)GPIO_HIGH); // pin pull ( 00 : High-Z, 01 : Pull-down, 10 : Pull-up, 11 : Reserved ) syscon_SetPPCR0(QN_SYSCON, 0xAAAA5AAA); // SWD pull-down save 20uA syscon_SetPPCR1(QN_SYSCON, 0x2AAAAAAA); // power down BUCK needed syscon_SetIvrefX32WithMask(QN_SYSCON, SYSCON_MASK_BUCK_BYPASS|SYSCON_MASK_BUCK_DPD, MASK_ENABLE); // power down Flash syscon_SetPGCR2WithMask(QN_SYSCON, SYSCON_MASK_FLASH_VCC_EN, MASK_DISABLE); // enable dbg power down syscon_SetPGCR2WithMask(QN_SYSCON, SYSCON_MASK_DBGPMUENABLE, MASK_ENABLE); // dis sar adc buffer syscon_SetPGCR1WithMask(QN_SYSCON, SYSCON_MASK_DIS_SAR_BUF, MASK_ENABLE); Led_flash(); do { delay(10); } while (gpio_read_pin(GPIO_P14) == GPIO_HIGH); sleep_init(); do { gpio_set_direction(GPIO_P01, GPIO_INPUT); wakeup_by_gpio(GPIO_P15, GPIO_WKUP_BY_CHANGE); enter_sleep(SLEEP_DEEP, WAKEUP_BY_GPIO, Led_flash); } while(1); #endif #if TEST_SLEEP_CPU_CLK_OFF == TRUE // -------------------------------------------- // clock gating // -------------------------------------------- // Set timer 0 wakeup timer_init(QN_TIMER0, NULL); timer_config(QN_TIMER0, TIMER_PSCAL_DIV, TIMER_COUNT_MS(1000, TIMER_PSCAL_DIV)); timer_enable(QN_TIMER0, MASK_ENABLE); sleep_init(); do { enter_sleep(SLEEP_CPU_CLK_OFF, WAKEUP_BY_TIMER0, NULL); Led_flash(); } while(1); #endif }
static int ebi2_lcd_probe(struct platform_device *pdev) { struct msm_fb_data_type *mfd; struct platform_device *mdp_dev = NULL; struct msm_fb_panel_data *pdata = NULL; int rc, i; if (pdev->id == 0) { for (i = 0; i < pdev->num_resources; i++) { if (!strncmp(pdev->resource[i].name, "base", 4)) { ebi2_base = ioremap(pdev->resource[i].start, pdev->resource[i].end - pdev->resource[i].start + 1); if (!ebi2_base) { printk(KERN_ERR "ebi2_base ioremap failed!\n"); return -ENOMEM; } ebi2_lcd_cfg0 = (void *)(ebi2_base + 0x20); ebi2_lcd_cfg1 = (void *)(ebi2_base + 0x24); } else if (!strncmp(pdev->resource[i].name, "lcd01", 5)) { lcd01_base = ioremap(pdev->resource[i].start, pdev->resource[i].end - pdev->resource[i].start + 1); if (!lcd01_base) { printk(KERN_ERR "lcd01_base ioremap failed!\n"); return -ENOMEM; } } else if (!strncmp(pdev->resource[i].name, "lcd02", 5)) { lcd02_base = ioremap(pdev->resource[i].start, pdev->resource[i].end - pdev->resource[i].start + 1); if (!lcd02_base) { printk(KERN_ERR "lcd02_base ioremap failed!\n"); return -ENOMEM; } } } ebi2_lcd_resource_initialized = 1; return 0; } if (!ebi2_lcd_resource_initialized) return -EPERM; mfd = platform_get_drvdata(pdev); if (!mfd) return -ENODEV; if (mfd->key != MFD_KEY) return -EINVAL; if (pdev_list_cnt >= MSM_FB_MAX_DEV_LIST) return -ENOMEM; if (ebi2_base == NULL) return -ENOMEM; mdp_dev = platform_device_alloc("mdp", pdev->id); if (!mdp_dev) return -ENOMEM; mfd->pdev = mdp_dev; mfd->dest = DISPLAY_LCD; if (platform_device_add_data (mdp_dev, pdev->dev.platform_data, sizeof(struct msm_fb_panel_data))) { printk(KERN_ERR "ebi2_lcd_probe: platform_device_add_data failed!\n"); platform_device_put(mdp_dev); return -ENOMEM; } pdata = mdp_dev->dev.platform_data; pdata->on = panel_next_on; pdata->off = panel_next_off; pdata->next = pdev; mfd->panel_info = pdata->panel_info; if (mfd->panel_info.bpp == 24) mfd->fb_imgType = MDP_RGB_888; else mfd->fb_imgType = MDP_RGB_565; if (mfd->panel_info.pdest == DISPLAY_1) { outp32(ebi2_base, (inp32(ebi2_base) & (~(EBI2_PRIM_LCD_CLR))) | EBI2_PRIM_LCD_SEL); outp32(ebi2_lcd_cfg0, mfd->panel_info.wait_cycle); if (mfd->panel_info.bpp == 18) outp32(ebi2_lcd_cfg1, 0x01000000); else outp32(ebi2_lcd_cfg1, 0x0); } else { #ifdef DEBUG_EBI2_LCD outp32(ebi2_base, (inp32(ebi2_base)&(~(EBI2_SECD_LCD_CLR))) |EBI2_SECD_LCD_SEL); #endif } if (mfd->panel_info.pdest == DISPLAY_1) { mfd->cmd_port = lcd01_base; mfd->data_port = (void *)((uint32) mfd->cmd_port + EBI2_PRIM_LCD_RS_PIN); mfd->data_port_phys = (void *)(LCD_PRIM_BASE_PHYS + EBI2_PRIM_LCD_RS_PIN); } else { mfd->cmd_port = lcd01_base; mfd->data_port = (void *)((uint32) mfd->cmd_port + EBI2_SECD_LCD_RS_PIN); mfd->data_port_phys = (void *)(LCD_SECD_BASE_PHYS + EBI2_SECD_LCD_RS_PIN); } platform_set_drvdata(mdp_dev, mfd); rc = platform_device_add(mdp_dev); if (rc) { goto ebi2_lcd_probe_err; } pdev_list[pdev_list_cnt++] = pdev; return 0; ebi2_lcd_probe_err: platform_device_put(mdp_dev); return rc; }