📄 sa1100fb.c
字号:
#endif DPRINTK("DBAR1 = %p\n", DBAR1); DPRINTK("DBAR2 = %p\n", DBAR2); DPRINTK("LCCR0 = 0x%08x\n", LCCR0); DPRINTK("LCCR1 = 0x%08x\n", LCCR1); DPRINTK("LCCR2 = 0x%08x\n", LCCR2); DPRINTK("LCCR3 = 0x%08x\n", LCCR3);}static void sa1100fb_disable_controller(struct sa1100fb_info *fbi){ DECLARE_WAITQUEUE(wait, current); DPRINTK("Disabling LCD controller\n");#ifdef CONFIG_SA1100_GRAPHICSCLIENT#error Where is GPIO24 set as an output? Can we fit this in somewhere else? if (machine_is_graphicsclient()) { /* * From ADS internal document: * GPIO24 should be LOW at least 10msec prior to disabling * the LCD interface. * * We'll wait 20msec. */ GPCR |= GPIO_GPIO24; set_current_state(TASK_UNINTERRUPTIBLE); schedule_timeout(20 * HZ / 1000); }#endif#ifdef CONFIG_SA1100_HUW_WEBPANEL#error Move me into sa1100fb_power_up_lcd and/or sa1100fb_backlight_on if (machine_is_huw_webpanel()) { // dont forget to set the control lines to zero (?) DPRINTK("ShutDown HuW LCD controller\n"); BCR_clear(BCR_TFT_ENA + BCR_CCFL_POW + BCR_PWM_BACKLIGHT); }#endif add_wait_queue(&fbi->ctrlr_wait, &wait); set_current_state(TASK_UNINTERRUPTIBLE); LCSR = 0xffffffff; /* Clear LCD Status Register */ LCCR0 &= ~LCCR0_LDM; /* Enable LCD Disable Done Interrupt */ enable_irq(IRQ_LCD); /* Enable LCD IRQ */ LCCR0 &= ~LCCR0_LEN; /* Disable LCD Controller */ schedule_timeout(20 * HZ / 1000); current->state = TASK_RUNNING; remove_wait_queue(&fbi->ctrlr_wait, &wait);}/* * sa1100fb_handle_irq: Handle 'LCD DONE' interrupts. */static void sa1100fb_handle_irq(int irq, void *dev_id, struct pt_regs *regs){ struct sa1100fb_info *fbi = dev_id; unsigned int lcsr = LCSR; if (lcsr & LCSR_LDD) { LCCR0 |= LCCR0_LDM; wake_up(&fbi->ctrlr_wait); } LCSR = lcsr;}/* * This function must be called from task context only, since it will * sleep when disabling the LCD controller, or if we get two contending * processes trying to alter state. */static void set_ctrlr_state(struct sa1100fb_info *fbi, u_int state){ u_int old_state; down(&fbi->ctrlr_sem); old_state = fbi->state; switch (state) { case C_DISABLE_CLKCHANGE: /* * Disable controller for clock change. If the * controller is already disabled, then do nothing. */ if (old_state != C_DISABLE) { fbi->state = state; sa1100fb_disable_controller(fbi); } break; case C_DISABLE: /* * Disable controller */ if (old_state != C_DISABLE) { fbi->state = state; sa1100fb_backlight_off(fbi); if (old_state != C_DISABLE_CLKCHANGE) sa1100fb_disable_controller(fbi); sa1100fb_power_down_lcd(fbi); } break; case C_ENABLE_CLKCHANGE: /* * Enable the controller after clock change. Only * do this if we were disabled for the clock change. */ if (old_state == C_DISABLE_CLKCHANGE) { fbi->state = C_ENABLE; sa1100fb_enable_controller(fbi); } break; case C_REENABLE: /* * Re-enable the controller only if it was already * enabled. This is so we reprogram the control * registers. */ if (old_state == C_ENABLE) { sa1100fb_disable_controller(fbi); sa1100fb_setup_gpio(fbi); sa1100fb_enable_controller(fbi); } break; case C_ENABLE: /* * Power up the LCD screen, enable controller, and * turn on the backlight. */ if (old_state != C_ENABLE) { fbi->state = C_ENABLE; sa1100fb_setup_gpio(fbi); sa1100fb_power_up_lcd(fbi); sa1100fb_enable_controller(fbi); sa1100fb_backlight_on(fbi); } break; } up(&fbi->ctrlr_sem);}/* * Our LCD controller task (which is called when we blank or unblank) * via keventd. */static void sa1100fb_task(void *dummy){ struct sa1100fb_info *fbi = dummy; u_int state = xchg(&fbi->task_state, -1); set_ctrlr_state(fbi, state);}#ifdef CONFIG_CPU_FREQ/* * Calculate the minimum DMA period over all displays that we own. * This, together with the SDRAM bandwidth defines the slowest CPU * frequency that can be selected. */static unsigned int sa1100fb_min_dma_period(struct sa1100fb_info *fbi){ unsigned int min_period = (unsigned int)-1; int i; for (i = 0; i < MAX_NR_CONSOLES; i++) { unsigned int period; /* * Do we own this display? */ if (fb_display[i].fb_info != &fbi->fb) continue; /* * Ok, calculate its DMA period */ period = sa1100fb_display_dma_period(get_con_var(&fbi->fb, i)); if (period < min_period) min_period = period; } return min_period;}/* * CPU clock speed change handler. We need to adjust the LCD timing * parameters when the CPU clock is adjusted by the power management * subsystem. */static intsa1100fb_clkchg_notifier(struct notifier_block *nb, unsigned long val, void *data){ struct sa1100fb_info *fbi = TO_INF(nb, clockchg); struct cpufreq_minmax *mm = data; u_int pcd; switch (val) { case CPUFREQ_MINMAX: printk(KERN_DEBUG "min dma period: %d ps, old clock %d kHz, " "new clock %d kHz\n", sa1100fb_min_dma_period(fbi), mm->cur_freq, mm->new_freq); /* todo: fill in min/max values */ break; case CPUFREQ_PRECHANGE: set_ctrlr_state(fbi, C_DISABLE_CLKCHANGE); break; case CPUFREQ_POSTCHANGE: pcd = get_pcd(fbi->fb.var.pixclock); fbi->reg_lccr3 = (fbi->reg_lccr3 & ~0xff) | LCCR3_PixClkDiv(pcd); set_ctrlr_state(fbi, C_ENABLE_CLKCHANGE); break; } return 0;}#endif#ifdef CONFIG_PM/* * Power management hook. Note that we won't be called from IRQ context, * unlike the blank functions above, so we may sleep. */static intsa1100fb_pm_callback(struct pm_dev *pm_dev, pm_request_t req, void *data){ struct sa1100fb_info *fbi = pm_dev->data; DPRINTK("pm_callback: %d\n", req); if (req == PM_SUSPEND || req == PM_RESUME) { int state = (int)data; if (state == 0) { /* Enter D0. */ set_ctrlr_state(fbi, C_ENABLE); } else { /* Enter D1-D3. Disable the LCD controller. */ set_ctrlr_state(fbi, C_DISABLE); } } DPRINTK("done\n"); return 0;}#endif/* * sa1100fb_map_video_memory(): * Allocates the DRAM memory for the frame buffer. This buffer is * remapped into a non-cached, non-buffered, memory region to * allow palette and pixel writes to occur without flushing the * cache. Once this area is remapped, all virtual memory * access to the video memory should occur at the new region. */static int __init sa1100fb_map_video_memory(struct sa1100fb_info *fbi){ /* * We reserve one page for the palette, plus the size * of the framebuffer. */ fbi->map_size = PAGE_ALIGN(fbi->fb.fix.smem_len + PAGE_SIZE); fbi->map_cpu = consistent_alloc(GFP_KERNEL, fbi->map_size, &fbi->map_dma); if (fbi->map_cpu) { fbi->screen_cpu = fbi->map_cpu + PAGE_SIZE; fbi->screen_dma = fbi->map_dma + PAGE_SIZE; fbi->fb.fix.smem_start = fbi->screen_dma; } return fbi->map_cpu ? 0 : -ENOMEM;}/* Fake monspecs to fill in fbinfo structure */static struct fb_monspecs monspecs __initdata = { 30000, 70000, 50, 65, 0 /* Generic */};static struct sa1100fb_info * __init sa1100fb_init_fbinfo(void){ struct sa1100fb_mach_info *inf; struct sa1100fb_info *fbi; fbi = kmalloc(sizeof(struct sa1100fb_info) + sizeof(struct display) + sizeof(u16) * 16, GFP_KERNEL); if (!fbi) return NULL; memset(fbi, 0, sizeof(struct sa1100fb_info) + sizeof(struct display)); fbi->currcon = -1; strcpy(fbi->fb.fix.id, SA1100_NAME); fbi->fb.fix.type = FB_TYPE_PACKED_PIXELS; fbi->fb.fix.type_aux = 0; fbi->fb.fix.xpanstep = 0; fbi->fb.fix.ypanstep = 0; fbi->fb.fix.ywrapstep = 0; fbi->fb.fix.accel = FB_ACCEL_NONE; fbi->fb.var.nonstd = 0; fbi->fb.var.activate = FB_ACTIVATE_NOW; fbi->fb.var.height = -1; fbi->fb.var.width = -1; fbi->fb.var.accel_flags = 0; fbi->fb.var.vmode = FB_VMODE_NONINTERLACED; strcpy(fbi->fb.modename, SA1100_NAME); strcpy(fbi->fb.fontname, "Acorn8x8"); fbi->fb.fbops = &sa1100fb_ops; fbi->fb.changevar = NULL; fbi->fb.switch_con = sa1100fb_switch; fbi->fb.updatevar = sa1100fb_updatevar; fbi->fb.blank = sa1100fb_blank; fbi->fb.flags = FBINFO_FLAG_DEFAULT; fbi->fb.node = -1; fbi->fb.monspecs = monspecs; fbi->fb.disp = (struct display *)(fbi + 1); fbi->fb.pseudo_palette = (void *)(fbi->fb.disp + 1); fbi->rgb[RGB_8] = &rgb_8; fbi->rgb[RGB_16] = &def_rgb_16; inf = sa1100fb_get_machine_info(fbi); fbi->max_xres = inf->xres; fbi->fb.var.xres = inf->xres; fbi->fb.var.xres_virtual = inf->xres; fbi->max_yres = inf->yres; fbi->fb.var.yres = inf->yres; fbi->fb.var.yres_virtual = inf->yres; fbi->max_bpp = inf->bpp; fbi->fb.var.bits_per_pixel = inf->bpp; fbi->fb.var.pixclock = inf->pixclock; fbi->fb.var.hsync_len = inf->hsync_len; fbi->fb.var.left_margin = inf->left_margin; fbi->fb.var.right_margin = inf->right_margin; fbi->fb.var.vsync_len = inf->vsync_len; fbi->fb.var.upper_margin = inf->upper_margin; fbi->fb.var.lower_margin = inf->lower_margin; fbi->fb.var.sync = inf->sync; fbi->fb.var.grayscale = inf->cmap_greyscale; fbi->cmap_inverse = inf->cmap_inverse; fbi->cmap_static = inf->cmap_static; fbi->lccr0 = inf->lccr0; fbi->lccr3 = inf->lccr3; fbi->state = C_DISABLE; fbi->task_state = (u_char)-1; fbi->fb.fix.smem_len = fbi->max_xres * fbi->max_yres * fbi->max_bpp / 8; init_waitqueue_head(&fbi->ctrlr_wait); INIT_TQUEUE(&fbi->task, sa1100fb_task, fbi); init_MUTEX(&fbi->ctrlr_sem); return fbi;}int __init sa1100fb_init(void){ struct sa1100fb_info *fbi; int ret; fbi = sa1100fb_init_fbinfo(); ret = -ENOMEM; if (!fbi) goto failed; /* Initialize video memory */ ret = sa1100fb_map_video_memory(fbi); if (ret) goto failed; ret = request_irq(IRQ_LCD, sa1100fb_handle_irq, SA_INTERRUPT, fbi->fb.fix.id, fbi); if (ret) { printk(KERN_ERR "sa1100fb: request_irq failed: %d\n", ret); goto failed; }#ifdef ASSABET_PAL_VIDEO if (machine_is_assabet()) ASSABET_BCR_clear(ASSABET_BCR_LCD_ON);#endif#ifdef CONFIG_SA1100_FREEBIRD#error Please move this into sa1100fb_power_up_lcd if (machine_is_freebird()) { BCR_set(BCR_FREEBIRD_LCD_DISP); mdelay(20); BCR_set(BCR_FREEBIRD_LCD_PWR); mdelay(20); }#endif sa1100fb_set_var(&fbi->fb.var, -1, &fbi->fb); ret = register_framebuffer(&fbi->fb); if (ret < 0) goto failed;#ifdef CONFIG_PM /* * Note that the console registers this as well, but we want to * power down the display prior to sleeping. */ fbi->pm = pm_register(PM_SYS_DEV, PM_SYS_VGA, sa1100fb_pm_callback); if (fbi->pm) fbi->pm->data = fbi;#endif#ifdef CONFIG_CPU_FREQ fbi->clockchg.notifier_call = sa1100fb_clkchg_notifier; cpufreq_register_notifier(&fbi->clockchg);#endif /* * Ok, now enable the LCD controller */ set_ctrlr_state(fbi, C_ENABLE); /* This driver cannot be unloaded at the moment */ MOD_INC_USE_COUNT; return 0;failed: if (fbi) kfree(fbi); return ret;}int __init sa1100fb_setup(char *options){#if 0 char *this_opt; if (!options || !*options) return 0; while ((this_opt = strsep(&options, ",")) != NULL) { if (!strncmp(this_opt, "bpp:", 4)) current_par.max_bpp = simple_strtoul(this_opt + 4, NULL, 0); if (!strncmp(this_opt, "lccr0:", 6)) lcd_shadow.lccr0 = simple_strtoul(this_opt + 6, NULL, 0); if (!strncmp(this_opt, "lccr1:", 6)) { lcd_shadow.lccr1 = simple_strtoul(this_opt + 6, NULL, 0); current_par.max_xres = (lcd_shadow.lccr1 & 0x3ff) + 16; } if (!strncmp(this_opt, "lccr2:", 6)) { lcd_shadow.lccr2 = simple_strtoul(this_opt + 6, NULL, 0); current_par.max_yres = (lcd_shadow. lccr0 & LCCR0_SDS) ? ((lcd_shadow. lccr2 & 0x3ff) + 1) * 2 : ((lcd_shadow.lccr2 & 0x3ff) + 1); } if (!strncmp(t
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -