42 ast_io_write8(ast, base, index);
43 tmp = (ast_io_read8(ast, base + 1) &
mask) | val;
44 ast_set_index_reg(ast, base, index, tmp);
51 ast_io_write8(ast, base, index);
52 ret = ast_io_read8(ast, base + 1);
60 ast_io_write8(ast, base, index);
61 ret = ast_io_read8(ast, base + 1) &
mask;
72 DRM_INFO(
"AST 1180 detected\n");
74 if (dev->pdev->revision >= 0x20) {
76 DRM_INFO(
"AST 2300 detected\n");
77 }
else if (dev->pdev->revision >= 0x10) {
79 ast_write32(ast, 0xf004, 0x1e6e0000);
80 ast_write32(ast, 0xf000, 0x1);
82 data = ast_read32(ast, 0x1207c);
83 switch (data & 0x0300) {
86 DRM_INFO(
"AST 1100 detected\n");
90 DRM_INFO(
"AST 2200 detected\n");
94 DRM_INFO(
"AST 2150 detected\n");
98 DRM_INFO(
"AST 2100 detected\n");
104 DRM_INFO(
"AST 2000 detected\n");
110 static int ast_get_dram_info(
struct drm_device *dev)
116 ast_write32(ast, 0xf004, 0x1e6e0000);
117 ast_write32(ast, 0xf000, 0x1);
120 ast_write32(ast, 0x10000, 0xfc600309);
124 }
while (ast_read32(ast, 0x10000) != 0x01);
125 data = ast_read32(ast, 0x10004);
133 switch (data & 0x03) {
149 switch (data & 0x0c) {
166 data = ast_read32(ast, 0x10120);
167 data2 = ast_read32(ast, 0x10170);
174 num = (data & 0x3fe0) >> 5;
175 data = (data & 0xc000) >> 14;
188 ast->
mclk = ref_pll * (num + 2) / (denum + 2) * (div * 1000);
206 dram_efficency = 600;
208 dram_efficency = 400;
210 dram_bandwidth = mclk * dram_bus_width * 2 / 8;
211 actual_dram_bandwidth = dram_bandwidth * dram_efficency / 1000;
214 dclk = actual_dram_bandwidth / ((bpp + 1) / 8);
218 dclk = actual_dram_bandwidth / ((bpp + 1 + 16) / 8);
219 else if ((jreg & 0x08) && (bpp == 8))
220 dclk = actual_dram_bandwidth / ((bpp + 1 + 24) / 8);
222 dclk = actual_dram_bandwidth / ((bpp + 1) / 8);
243 drm_gem_object_unreference_unlocked(ast_fb->
obj);
249 static int ast_user_framebuffer_create_handle(
struct drm_framebuffer *fb,
250 struct drm_file *
file,
257 .destroy = ast_user_framebuffer_destroy,
258 .create_handle = ast_user_framebuffer_create_handle,
265 struct drm_gem_object *obj)
271 DRM_ERROR(
"framebuffer init failed %d\n", ret);
280 ast_user_framebuffer_create(
struct drm_device *dev,
281 struct drm_file *filp,
284 struct drm_gem_object *obj;
292 ast_fb = kzalloc(
sizeof(*ast_fb),
GFP_KERNEL);
294 drm_gem_object_unreference_unlocked(obj);
300 drm_gem_object_unreference_unlocked(obj);
304 return &ast_fb->
base;
308 .fb_create = ast_user_framebuffer_create,
337 dev->dev_private = ast;
340 ast->
regs = pci_iomap(dev->pdev, 1, 0);
345 ast->
ioregs = pci_iomap(dev->pdev, 2, 0);
351 ast_detect_chip(dev);
354 ast_get_dram_info(dev);
365 dev->mode_config.funcs = (
void *)&ast_mode_funcs;
366 dev->mode_config.min_width = 0;
367 dev->mode_config.min_height = 0;
368 dev->mode_config.preferred_depth = 24;
369 dev->mode_config.prefer_shadow = 1;
375 dev->mode_config.max_width = 1920;
376 dev->mode_config.max_height = 2048;
378 dev->mode_config.max_width = 1600;
379 dev->mode_config.max_height = 1200;
393 dev->dev_private =
NULL;
414 struct drm_gem_object **obj)
428 DRM_ERROR(
"failed to allocate GEM object\n");
440 struct drm_gem_object *gobj;
452 drm_gem_object_unreference_unlocked(gobj);
496 static inline u64 ast_bo_mmap_offset(
struct ast_bo *
bo)
498 return bo->
bo.addr_space_offset;
506 struct drm_gem_object *obj;
518 *offset = ast_bo_mmap_offset(bo);
520 drm_gem_object_unreference(obj);