Lines Matching +full:ati +full:- +full:target

1 // SPDX-License-Identifier: GPL-2.0-only
5 * Frame Buffer Device for ATI Imageon w100 (Wallaby)
7 * Copyright (C) 2002, ATI Corp.
8 * Copyright (C) 2004-2006 Richard Purdie
82 struct w100fb_par *par=info->par; in flip_show()
84 return sprintf(buf, "%d\n",par->flip); in flip_show()
91 struct w100fb_par *par=info->par; in flip_store()
96 par->flip = 1; in flip_store()
98 par->flip = 0; in flip_store()
141 struct w100fb_par *par=info->par; in fastpllclk_show()
143 return sprintf(buf, "%d\n",par->fastpll_mode); in fastpllclk_show()
149 struct w100fb_par *par=info->par; in fastpllclk_store()
152 par->fastpll_mode=1; in fastpllclk_store()
155 par->fastpll_mode=0; in fastpllclk_store()
183 struct w100fb_par *par=info->par; in w100fb_get_hsynclen()
186 if (par->blanked) in w100fb_get_hsynclen()
189 return par->hsync_len; in w100fb_get_hsynclen()
195 …memset_io(remapped_fbuf + (W100_FB_BASE-MEM_WINDOW_BASE), 0, (par->xres * par->yres * BITS_PER_PIX… in w100fb_clear_screen()
212 if (info->var.grayscale) in w100fb_setcolreg()
216 * 16-bit True Colour. We encode the RGB value in w100fb_setcolreg()
220 u32 *pal = info->pseudo_palette; in w100fb_setcolreg()
235 struct w100fb_par *par = info->par; in w100fb_blank()
236 struct w100_tg_info *tg = par->mach->tg; in w100fb_blank()
244 if (par->blanked == 0) { in w100fb_blank()
245 if(tg && tg->suspend) in w100fb_blank()
246 tg->suspend(par); in w100fb_blank()
247 par->blanked = 1; in w100fb_blank()
252 if (par->blanked != 0) { in w100fb_blank()
253 if(tg && tg->resume) in w100fb_blank()
254 tg->resume(par); in w100fb_blank()
255 par->blanked = 0; in w100fb_blank()
290 return -EBUSY; in w100fb_sync()
303 writel(par->xres, remapped_regs + mmDST_PITCH); in w100_init_graphic_engine()
305 writel(par->xres, remapped_regs + mmSRC_PITCH); in w100_init_graphic_engine()
309 writel((par->yres << 16) | par->xres, remapped_regs + mmSC_BOTTOM_RIGHT); in w100_init_graphic_engine()
361 if (info->state != FBINFO_STATE_RUNNING) in w100fb_fillrect()
363 if (info->flags & FBINFO_HWACCEL_DISABLED) { in w100fb_fillrect()
373 writel(rect->color, remapped_regs + mmDP_BRUSH_FRGD_CLR); in w100fb_fillrect()
376 writel((rect->dy << 16) | (rect->dx & 0xffff), remapped_regs + mmDST_Y_X); in w100fb_fillrect()
377 writel((rect->width << 16) | (rect->height & 0xffff), in w100fb_fillrect()
385 u32 dx = area->dx, dy = area->dy, sx = area->sx, sy = area->sy; in w100fb_copyarea()
386 u32 h = area->height, w = area->width; in w100fb_copyarea()
389 if (info->state != FBINFO_STATE_RUNNING) in w100fb_copyarea()
391 if (info->flags & FBINFO_HWACCEL_DISABLED) { in w100fb_copyarea()
414 struct w100_tg_info *tg = par->mach->tg; in w100fb_activate_var()
430 if (!par->blanked && tg && tg->change) in w100fb_activate_var()
431 tg->change(par); in w100fb_activate_var()
442 struct w100_mode *modelist = par->mach->modelist; in w100fb_get_mode()
446 for (i = 0 ; i < par->mach->num_modes ; i++) { in w100fb_get_mode()
472 * if it's too big, return -EINVAL.
476 struct w100fb_par *par=info->par; in w100fb_check_var()
478 if(!w100fb_get_mode(par, &var->xres, &var->yres, 1)) in w100fb_check_var()
479 return -EINVAL; in w100fb_check_var()
481 if (par->mach->mem && ((var->xres*var->yres*BITS_PER_PIXEL/8) > (par->mach->mem->size+1))) in w100fb_check_var()
482 return -EINVAL; in w100fb_check_var()
484 if (!par->mach->mem && ((var->xres*var->yres*BITS_PER_PIXEL/8) > (MEM_INT_SIZE+1))) in w100fb_check_var()
485 return -EINVAL; in w100fb_check_var()
487 var->xres_virtual = max(var->xres_virtual, var->xres); in w100fb_check_var()
488 var->yres_virtual = max(var->yres_virtual, var->yres); in w100fb_check_var()
490 if (var->bits_per_pixel > BITS_PER_PIXEL) in w100fb_check_var()
491 return -EINVAL; in w100fb_check_var()
493 var->bits_per_pixel = BITS_PER_PIXEL; in w100fb_check_var()
495 var->red.offset = 11; in w100fb_check_var()
496 var->red.length = 5; in w100fb_check_var()
497 var->green.offset = 5; in w100fb_check_var()
498 var->green.length = 6; in w100fb_check_var()
499 var->blue.offset = 0; in w100fb_check_var()
500 var->blue.length = 5; in w100fb_check_var()
501 var->transp.offset = var->transp.length = 0; in w100fb_check_var()
503 var->nonstd = 0; in w100fb_check_var()
504 var->height = -1; in w100fb_check_var()
505 var->width = -1; in w100fb_check_var()
506 var->vmode = FB_VMODE_NONINTERLACED; in w100fb_check_var()
507 var->sync = 0; in w100fb_check_var()
508 var->pixclock = 0x04; /* 171521; */ in w100fb_check_var()
521 struct w100fb_par *par=info->par; in w100fb_set_par()
523 if (par->xres != info->var.xres || par->yres != info->var.yres) { in w100fb_set_par()
524 par->xres = info->var.xres; in w100fb_set_par()
525 par->yres = info->var.yres; in w100fb_set_par()
526 par->mode = w100fb_get_mode(par, &par->xres, &par->yres, 0); in w100fb_set_par()
528 info->fix.visual = FB_VISUAL_TRUECOLOR; in w100fb_set_par()
529 info->fix.ypanstep = 0; in w100fb_set_par()
530 info->fix.ywrapstep = 0; in w100fb_set_par()
531 info->fix.line_length = par->xres * BITS_PER_PIXEL / 8; in w100fb_set_par()
533 mutex_lock(&info->mm_lock); in w100fb_set_par()
534 if ((par->xres*par->yres*BITS_PER_PIXEL/8) > (MEM_INT_SIZE+1)) { in w100fb_set_par()
535 par->extmem_active = 1; in w100fb_set_par()
536 info->fix.smem_len = par->mach->mem->size+1; in w100fb_set_par()
538 par->extmem_active = 0; in w100fb_set_par()
539 info->fix.smem_len = MEM_INT_SIZE+1; in w100fb_set_par()
541 mutex_unlock(&info->mm_lock); in w100fb_set_par()
569 if (par->extmem_active) { in w100fb_save_vidmem()
570 memsize=par->mach->mem->size; in w100fb_save_vidmem()
571 par->saved_extmem = vmalloc(memsize); in w100fb_save_vidmem()
572 if (par->saved_extmem) in w100fb_save_vidmem()
573 memcpy_fromio(par->saved_extmem, remapped_fbuf + (W100_FB_BASE-MEM_WINDOW_BASE), memsize); in w100fb_save_vidmem()
576 par->saved_intmem = vmalloc(memsize); in w100fb_save_vidmem()
577 if (par->saved_intmem && par->extmem_active) in w100fb_save_vidmem()
578 memcpy_fromio(par->saved_intmem, remapped_fbuf + (W100_FB_BASE-MEM_INT_BASE_VALUE), memsize); in w100fb_save_vidmem()
579 else if (par->saved_intmem) in w100fb_save_vidmem()
580 memcpy_fromio(par->saved_intmem, remapped_fbuf + (W100_FB_BASE-MEM_WINDOW_BASE), memsize); in w100fb_save_vidmem()
587 if (par->extmem_active && par->saved_extmem) { in w100fb_restore_vidmem()
588 memsize=par->mach->mem->size; in w100fb_restore_vidmem()
589 memcpy_toio(remapped_fbuf + (W100_FB_BASE-MEM_WINDOW_BASE), par->saved_extmem, memsize); in w100fb_restore_vidmem()
590 vfree(par->saved_extmem); in w100fb_restore_vidmem()
591 par->saved_extmem = NULL; in w100fb_restore_vidmem()
593 if (par->saved_intmem) { in w100fb_restore_vidmem()
595 if (par->extmem_active) in w100fb_restore_vidmem()
596 memcpy_toio(remapped_fbuf + (W100_FB_BASE-MEM_INT_BASE_VALUE), par->saved_intmem, memsize); in w100fb_restore_vidmem()
598 memcpy_toio(remapped_fbuf + (W100_FB_BASE-MEM_WINDOW_BASE), par->saved_intmem, memsize); in w100fb_restore_vidmem()
599 vfree(par->saved_intmem); in w100fb_restore_vidmem()
600 par->saved_intmem = NULL; in w100fb_restore_vidmem()
607 struct w100fb_par *par=info->par; in w100fb_suspend()
608 struct w100_tg_info *tg = par->mach->tg; in w100fb_suspend()
611 if(tg && tg->suspend) in w100fb_suspend()
612 tg->suspend(par); in w100fb_suspend()
614 par->blanked = 1; in w100fb_suspend()
622 struct w100fb_par *par=info->par; in w100fb_resume()
623 struct w100_tg_info *tg = par->mach->tg; in w100fb_resume()
628 if(tg && tg->resume) in w100fb_resume()
629 tg->resume(par); in w100fb_resume()
630 par->blanked = 0; in w100fb_resume()
642 int err = -EIO; in w100fb_probe()
650 return -EINVAL; in w100fb_probe()
653 remapped_base = ioremap(mem->start+W100_CFG_BASE, W100_CFG_LEN); in w100fb_probe()
658 remapped_regs = ioremap(mem->start+W100_REG_BASE, W100_REG_LEN); in w100fb_probe()
671 err = -ENODEV; in w100fb_probe()
674 printk(" at 0x%08lx.\n", (unsigned long) mem->start+W100_CFG_BASE); in w100fb_probe()
677 remapped_fbuf = ioremap(mem->start+MEM_WINDOW_BASE, MEM_WINDOW_SIZE); in w100fb_probe()
681 info=framebuffer_alloc(sizeof(struct w100fb_par), &pdev->dev); in w100fb_probe()
683 err = -ENOMEM; in w100fb_probe()
687 par = info->par; in w100fb_probe()
690 inf = dev_get_platdata(&pdev->dev); in w100fb_probe()
691 par->chip_id = chip_id; in w100fb_probe()
692 par->mach = inf; in w100fb_probe()
693 par->fastpll_mode = 0; in w100fb_probe()
694 par->blanked = 0; in w100fb_probe()
696 par->pll_table=w100_get_xtal_table(inf->xtal_freq); in w100fb_probe()
697 if (!par->pll_table) { in w100fb_probe()
699 err = -EINVAL; in w100fb_probe()
703 info->pseudo_palette = kmalloc_array(MAX_PALETTES, sizeof(u32), in w100fb_probe()
705 if (!info->pseudo_palette) { in w100fb_probe()
706 err = -ENOMEM; in w100fb_probe()
710 info->fbops = &w100fb_ops; in w100fb_probe()
711 info->flags = FBINFO_DEFAULT | FBINFO_HWACCEL_COPYAREA | in w100fb_probe()
713 info->node = -1; in w100fb_probe()
714 info->screen_base = remapped_fbuf + (W100_FB_BASE-MEM_WINDOW_BASE); in w100fb_probe()
715 info->screen_size = REMAPPED_FB_LEN; in w100fb_probe()
717 strcpy(info->fix.id, "w100fb"); in w100fb_probe()
718 info->fix.type = FB_TYPE_PACKED_PIXELS; in w100fb_probe()
719 info->fix.type_aux = 0; in w100fb_probe()
720 info->fix.accel = FB_ACCEL_NONE; in w100fb_probe()
721 info->fix.smem_start = mem->start+W100_FB_BASE; in w100fb_probe()
722 info->fix.mmio_start = mem->start+W100_REG_BASE; in w100fb_probe()
723 info->fix.mmio_len = W100_REG_LEN; in w100fb_probe()
725 if (fb_alloc_cmap(&info->cmap, 256, 0) < 0) { in w100fb_probe()
726 err = -ENOMEM; in w100fb_probe()
730 par->mode = &inf->modelist[0]; in w100fb_probe()
731 if(inf->init_mode & INIT_MODE_ROTATED) { in w100fb_probe()
732 info->var.xres = par->mode->yres; in w100fb_probe()
733 info->var.yres = par->mode->xres; in w100fb_probe()
736 info->var.xres = par->mode->xres; in w100fb_probe()
737 info->var.yres = par->mode->yres; in w100fb_probe()
740 if(inf->init_mode &= INIT_MODE_FLIPPED) in w100fb_probe()
741 par->flip = 1; in w100fb_probe()
743 par->flip = 0; in w100fb_probe()
745 info->var.xres_virtual = info->var.xres; in w100fb_probe()
746 info->var.yres_virtual = info->var.yres; in w100fb_probe()
747 info->var.pixclock = 0x04; /* 171521; */ in w100fb_probe()
748 info->var.sync = 0; in w100fb_probe()
749 info->var.grayscale = 0; in w100fb_probe()
750 info->var.xoffset = info->var.yoffset = 0; in w100fb_probe()
751 info->var.accel_flags = 0; in w100fb_probe()
752 info->var.activate = FB_ACTIVATE_NOW; in w100fb_probe()
756 if (w100fb_check_var(&info->var, info) < 0) { in w100fb_probe()
757 err = -EINVAL; in w100fb_probe()
762 err = -EINVAL; in w100fb_probe()
766 fb_info(info, "%s frame buffer device\n", info->fix.id); in w100fb_probe()
770 fb_dealloc_cmap(&info->cmap); in w100fb_probe()
771 kfree(info->pseudo_palette); in w100fb_probe()
788 struct w100fb_par *par=info->par; in w100fb_remove()
792 vfree(par->saved_intmem); in w100fb_remove()
793 vfree(par->saved_extmem); in w100fb_remove()
794 kfree(info->pseudo_palette); in w100fb_remove()
795 fb_dealloc_cmap(&info->cmap); in w100fb_remove()
807 /* ------------------- chipset specific functions -------------------------- */
879 struct w100_gpio_regs *gpio = par->mach->gpio; in w100_hw_init()
952 writel(gpio->init_data1, remapped_regs + mmGPIO_DATA); in w100_hw_init()
953 writel(gpio->init_data2, remapped_regs + mmGPIO_DATA2); in w100_hw_init()
954 writel(gpio->gpio_dir1, remapped_regs + mmGPIO_CNTL1); in w100_hw_init()
955 writel(gpio->gpio_oe1, remapped_regs + mmGPIO_CNTL2); in w100_hw_init()
956 writel(gpio->gpio_dir2, remapped_regs + mmGPIO_CNTL3); in w100_hw_init()
957 writel(gpio->gpio_oe2, remapped_regs + mmGPIO_CNTL4); in w100_hw_init()
1024 if (freq == pll_entry->xtal_freq) in w100_get_xtal_table()
1025 return pll_entry->pll_table; in w100_get_xtal_table()
1027 } while (pll_entry->xtal_freq); in w100_get_xtal_table()
1072 w100_pwr_state.pll_cntl.f.pll_tcpoff = 0x1; /* Hi-Z */ in w100_pll_adjust()
1088 if (tf80 >= (pll->tfgoal)) { in w100_pll_adjust()
1094 if (tf20 <= (pll->tfgoal)) in w100_pll_adjust()
1139 /* set VCO input = Hi-Z, disable DAC */ in w100_pll_calibration()
1166 w100_pwr_state.pll_ref_fb_div.f.pll_ref_div = pll->M; in w100_pll_set_clk()
1167 w100_pwr_state.pll_ref_fb_div.f.pll_fb_div_int = pll->N_int; in w100_pll_set_clk()
1168 w100_pwr_state.pll_ref_fb_div.f.pll_fb_div_frac = pll->N_fac; in w100_pll_set_clk()
1169 w100_pwr_state.pll_ref_fb_div.f.pll_lock_time = pll->lock_time; in w100_pll_set_clk()
1186 /* freq = target frequency of the PLL */
1189 struct w100_pll_info *pll = par->pll_table; in w100_set_pll_freq()
1192 if (freq == pll->freq) { in w100_set_pll_freq()
1196 } while(pll->freq); in w100_set_pll_freq()
1208 w100_pwr_state.clk_pin_cntl.f.xtalin_dbl_en = par->mach->xtal_dbl ? 1 : 0; in w100_pwm_setup()
1257 w100_pwr_state.pll_cntl.f.pll_dactal = 0x0; /* Hi-Z */ in w100_pwm_setup()
1284 struct w100_mode *mode = par->mode; in w100_init_clocks()
1286 if (mode->pixclk_src == CLK_SRC_PLL || mode->sysclk_src == CLK_SRC_PLL) in w100_init_clocks()
1287 …w100_set_pll_freq(par, (par->fastpll_mode && mode->fast_pll_freq) ? mode->fast_pll_freq : mode->pl… in w100_init_clocks()
1289 w100_pwr_state.sclk_cntl.f.sclk_src_sel = mode->sysclk_src; in w100_init_clocks()
1290 w100_pwr_state.sclk_cntl.f.sclk_post_div_fast = mode->sysclk_divider; in w100_init_clocks()
1291 w100_pwr_state.sclk_cntl.f.sclk_post_div_slow = mode->sysclk_divider; in w100_init_clocks()
1298 struct w100_mode *mode = par->mode; in w100_init_lcd()
1299 struct w100_gen_regs *regs = par->mach->regs; in w100_init_lcd()
1309 active_h_disp.f.active_h_start=mode->left_margin; in w100_init_lcd()
1310 active_h_disp.f.active_h_end=mode->left_margin + mode->xres; in w100_init_lcd()
1314 active_v_disp.f.active_v_start=mode->upper_margin; in w100_init_lcd()
1315 active_v_disp.f.active_v_end=mode->upper_margin + mode->yres; in w100_init_lcd()
1319 graphic_h_disp.f.graphic_h_start=mode->left_margin; in w100_init_lcd()
1320 graphic_h_disp.f.graphic_h_end=mode->left_margin + mode->xres; in w100_init_lcd()
1324 graphic_v_disp.f.graphic_v_start=mode->upper_margin; in w100_init_lcd()
1325 graphic_v_disp.f.graphic_v_end=mode->upper_margin + mode->yres; in w100_init_lcd()
1329 crtc_total.f.crtc_h_total=mode->left_margin + mode->xres + mode->right_margin; in w100_init_lcd()
1330 crtc_total.f.crtc_v_total=mode->upper_margin + mode->yres + mode->lower_margin; in w100_init_lcd()
1333 writel(mode->crtc_ss, remapped_regs + mmCRTC_SS); in w100_init_lcd()
1334 writel(mode->crtc_ls, remapped_regs + mmCRTC_LS); in w100_init_lcd()
1335 writel(mode->crtc_gs, remapped_regs + mmCRTC_GS); in w100_init_lcd()
1336 writel(mode->crtc_vpos_gs, remapped_regs + mmCRTC_VPOS_GS); in w100_init_lcd()
1337 writel(mode->crtc_rev, remapped_regs + mmCRTC_REV); in w100_init_lcd()
1338 writel(mode->crtc_dclk, remapped_regs + mmCRTC_DCLK); in w100_init_lcd()
1339 writel(mode->crtc_gclk, remapped_regs + mmCRTC_GCLK); in w100_init_lcd()
1340 writel(mode->crtc_goe, remapped_regs + mmCRTC_GOE); in w100_init_lcd()
1341 writel(mode->crtc_ps1_active, remapped_regs + mmCRTC_PS1_ACTIVE); in w100_init_lcd()
1343 writel(regs->lcd_format, remapped_regs + mmLCD_FORMAT); in w100_init_lcd()
1344 writel(regs->lcdd_cntl1, remapped_regs + mmLCDD_CNTL1); in w100_init_lcd()
1345 writel(regs->lcdd_cntl2, remapped_regs + mmLCDD_CNTL2); in w100_init_lcd()
1346 writel(regs->genlcd_cntl1, remapped_regs + mmGENLCD_CNTL1); in w100_init_lcd()
1347 writel(regs->genlcd_cntl2, remapped_regs + mmGENLCD_CNTL2); in w100_init_lcd()
1348 writel(regs->genlcd_cntl3, remapped_regs + mmGENLCD_CNTL3); in w100_init_lcd()
1366 struct w100_mem_info *mem = par->mach->mem; in w100_setup_memory()
1367 struct w100_bm_mem_info *bm_mem = par->mach->bm_mem; in w100_setup_memory()
1369 if (!par->extmem_active) { in w100_setup_memory()
1377 /* Unmap External Memory - value is *probably* irrelevant but may have meaning in w100_setup_memory()
1380 extmem_location.f.mc_ext_mem_top = (MEM_EXT_BASE_VALUE-1) >> 8; in w100_setup_memory()
1390 extmem_location.f.mc_ext_mem_top = (W100_FB_BASE+par->mach->mem->size) >> 8; in w100_setup_memory()
1394 writel(mem->ext_cntl, remapped_regs + mmMEM_EXT_CNTL); in w100_setup_memory()
1399 writel(mem->sdram_mode_reg, remapped_regs + mmMEM_SDRAM_MODE_REG); in w100_setup_memory()
1401 writel(mem->ext_timing_cntl, remapped_regs + mmMEM_EXT_TIMING_CNTL); in w100_setup_memory()
1402 writel(mem->io_cntl, remapped_regs + mmMEM_IO_CNTL); in w100_setup_memory()
1404 writel(bm_mem->ext_mem_bw, remapped_regs + mmBM_EXT_MEM_BANDWIDTH); in w100_setup_memory()
1405 writel(bm_mem->offset, remapped_regs + mmBM_OFFSET); in w100_setup_memory()
1406 writel(bm_mem->ext_timing_ctl, remapped_regs + mmBM_MEM_EXT_TIMING_CNTL); in w100_setup_memory()
1407 writel(bm_mem->ext_cntl, remapped_regs + mmBM_MEM_EXT_CNTL); in w100_setup_memory()
1408 writel(bm_mem->mode_reg, remapped_regs + mmBM_MEM_MODE_REG); in w100_setup_memory()
1409 writel(bm_mem->io_cntl, remapped_regs + mmBM_MEM_IO_CNTL); in w100_setup_memory()
1410 writel(bm_mem->config, remapped_regs + mmBM_CONFIG); in w100_setup_memory()
1421 if (par->xres == par->mode->xres) { in w100_set_dispregs()
1422 if (par->flip) { in w100_set_dispregs()
1424 offset=(par->xres * par->yres) - 1; in w100_set_dispregs()
1426 divider = par->mode->pixclk_divider; in w100_set_dispregs()
1428 if (par->flip) { in w100_set_dispregs()
1430 offset=par->xres - 1; in w100_set_dispregs()
1433 offset=par->xres * (par->yres - 1); in w100_set_dispregs()
1435 divider = par->mode->pixclk_divider_rotated; in w100_set_dispregs()
1439 switch (par->chip_id) { in w100_set_dispregs()
1452 switch(par->xres) { in w100_set_dispregs()
1487 graphic_ctrl.f_w32xx.total_req_graphic=par->mode->xres >> 1; /* panel xres, not mode */ in w100_set_dispregs()
1493 w100_pwr_state.pclk_cntl.f.pclk_src_sel = par->mode->pixclk_src; in w100_set_dispregs()
1499 writel((par->xres*BITS_PER_PIXEL/8), remapped_regs + mmGRAPHIC_PITCH); in w100_set_dispregs()
1510 struct w100_mode *mode = par->mode; in calc_hsync()
1513 if (mode->pixclk_src == CLK_SRC_XTAL) in calc_hsync()
1514 hsync=par->mach->xtal_freq; in calc_hsync()
1516 hsync=((par->fastpll_mode && mode->fast_pll_freq) ? mode->fast_pll_freq : mode->pll_freq)*100000; in calc_hsync()
1522 par->hsync_len = hsync / (crtc_ss.f.ss_end-crtc_ss.f.ss_start); in calc_hsync()
1524 par->hsync_len = 0; in calc_hsync()
1547 /* CKE: Tri-State */ in w100_suspend()
1611 timeout--; in w100_vsync()
1634 MODULE_DESCRIPTION("ATI Imageon w100 framebuffer driver");