Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

Merge branch '3.8/vrfb-conversion'

Merge omap vrfb code to remove direct omap platform dependencies from the
driver.

+191 -55
-16
arch/arm/mach-omap2/sdrc.c
··· 160 160 sdrc_write_reg(l, SDRC_POWER); 161 161 omap2_sms_save_context(); 162 162 } 163 - 164 - void omap2_sms_write_rot_control(u32 val, unsigned ctx) 165 - { 166 - sms_write_reg(val, SMS_ROT_CONTROL(ctx)); 167 - } 168 - 169 - void omap2_sms_write_rot_size(u32 val, unsigned ctx) 170 - { 171 - sms_write_reg(val, SMS_ROT_SIZE(ctx)); 172 - } 173 - 174 - void omap2_sms_write_rot_physical_ba(u32 val, unsigned ctx) 175 - { 176 - sms_write_reg(val, SMS_ROT_PHYSICAL_BA(ctx)); 177 - } 178 -
+61
arch/arm/plat-omap/fb.c
··· 33 33 #include <mach/hardware.h> 34 34 #include <asm/mach/map.h> 35 35 36 + #include <plat/cpu.h> 37 + 38 + #ifdef CONFIG_OMAP2_VRFB 39 + 40 + /* 41 + * The first memory resource is the register region for VRFB, 42 + * the rest are VRFB virtual memory areas for each VRFB context. 43 + */ 44 + 45 + static const struct resource omap2_vrfb_resources[] = { 46 + DEFINE_RES_MEM_NAMED(0x68008000u, 0x40, "vrfb-regs"), 47 + DEFINE_RES_MEM_NAMED(0x70000000u, 0x4000000, "vrfb-area-0"), 48 + DEFINE_RES_MEM_NAMED(0x74000000u, 0x4000000, "vrfb-area-1"), 49 + DEFINE_RES_MEM_NAMED(0x78000000u, 0x4000000, "vrfb-area-2"), 50 + DEFINE_RES_MEM_NAMED(0x7c000000u, 0x4000000, "vrfb-area-3"), 51 + }; 52 + 53 + static const struct resource omap3_vrfb_resources[] = { 54 + DEFINE_RES_MEM_NAMED(0x6C000180u, 0xc0, "vrfb-regs"), 55 + DEFINE_RES_MEM_NAMED(0x70000000u, 0x4000000, "vrfb-area-0"), 56 + DEFINE_RES_MEM_NAMED(0x74000000u, 0x4000000, "vrfb-area-1"), 57 + DEFINE_RES_MEM_NAMED(0x78000000u, 0x4000000, "vrfb-area-2"), 58 + DEFINE_RES_MEM_NAMED(0x7c000000u, 0x4000000, "vrfb-area-3"), 59 + DEFINE_RES_MEM_NAMED(0xe0000000u, 0x4000000, "vrfb-area-4"), 60 + DEFINE_RES_MEM_NAMED(0xe4000000u, 0x4000000, "vrfb-area-5"), 61 + DEFINE_RES_MEM_NAMED(0xe8000000u, 0x4000000, "vrfb-area-6"), 62 + DEFINE_RES_MEM_NAMED(0xec000000u, 0x4000000, "vrfb-area-7"), 63 + DEFINE_RES_MEM_NAMED(0xf0000000u, 0x4000000, "vrfb-area-8"), 64 + DEFINE_RES_MEM_NAMED(0xf4000000u, 0x4000000, "vrfb-area-9"), 65 + DEFINE_RES_MEM_NAMED(0xf8000000u, 0x4000000, "vrfb-area-10"), 66 + DEFINE_RES_MEM_NAMED(0xfc000000u, 0x4000000, "vrfb-area-11"), 67 + }; 68 + 69 + static int __init omap_init_vrfb(void) 70 + { 71 + struct platform_device *pdev; 72 + const struct resource *res; 73 + unsigned int num_res; 74 + 75 + if (cpu_is_omap24xx()) { 76 + res = omap2_vrfb_resources; 77 + num_res = ARRAY_SIZE(omap2_vrfb_resources); 78 + } else if (cpu_is_omap34xx()) { 79 + res = omap3_vrfb_resources; 80 + num_res = ARRAY_SIZE(omap3_vrfb_resources); 81 + } else { 82 + return 0; 83 + } 84 + 85 + pdev = platform_device_register_resndata(NULL, "omapvrfb", -1, 86 + res, num_res, NULL, 0); 87 + 88 + if (IS_ERR(pdev)) 89 + return PTR_ERR(pdev); 90 + else 91 + return 0; 92 + } 93 + 94 + arch_initcall(omap_init_vrfb); 95 + #endif 96 + 36 97 #if defined(CONFIG_FB_OMAP) || defined(CONFIG_FB_OMAP_MODULE) 37 98 38 99 static bool omapfb_lcd_configured;
-7
arch/arm/plat-omap/include/plat/sdrc.h
··· 94 94 /* SMS register offsets - read/write with sms_{read,write}_reg() */ 95 95 96 96 #define SMS_SYSCONFIG 0x010 97 - #define SMS_ROT_CONTROL(context) (0x180 + 0x10 * context) 98 - #define SMS_ROT_SIZE(context) (0x184 + 0x10 * context) 99 - #define SMS_ROT_PHYSICAL_BA(context) (0x188 + 0x10 * context) 100 97 /* REVISIT: fill in other SMS registers here */ 101 98 102 99 ··· 133 136 struct omap_sdrc_params **sdrc_cs1); 134 137 void omap2_sms_save_context(void); 135 138 void omap2_sms_restore_context(void); 136 - 137 - void omap2_sms_write_rot_control(u32 val, unsigned ctx); 138 - void omap2_sms_write_rot_size(u32 val, unsigned ctx); 139 - void omap2_sms_write_rot_physical_ba(u32 val, unsigned ctx); 140 139 141 140 #ifdef CONFIG_ARCH_OMAP2 142 141
+2
arch/arm/plat-omap/include/plat/vrfb.h include/video/omapvrfb.h
··· 36 36 }; 37 37 38 38 #ifdef CONFIG_OMAP2_VRFB 39 + extern bool omap_vrfb_supported(void); 39 40 extern int omap_vrfb_request_ctx(struct vrfb *vrfb); 40 41 extern void omap_vrfb_release_ctx(struct vrfb *vrfb); 41 42 extern void omap_vrfb_adjust_size(u16 *width, u16 *height, ··· 50 49 extern void omap_vrfb_restore_context(void); 51 50 52 51 #else 52 + static inline bool omap_vrfb_supported(void) { return false; } 53 53 static inline int omap_vrfb_request_ctx(struct vrfb *vrfb) { return 0; } 54 54 static inline void omap_vrfb_release_ctx(struct vrfb *vrfb) {} 55 55 static inline void omap_vrfb_adjust_size(u16 *width, u16 *height,
+1 -1
drivers/media/platform/omap/omap_vout.c
··· 46 46 47 47 #include <plat/cpu.h> 48 48 #include <plat/dma.h> 49 - #include <plat/vrfb.h> 49 + #include <video/omapvrfb.h> 50 50 #include <video/omapdss.h> 51 51 52 52 #include "omap_voutlib.h"
+1 -1
drivers/media/platform/omap/omap_vout_vrfb.c
··· 17 17 #include <media/v4l2-device.h> 18 18 19 19 #include <plat/dma.h> 20 - #include <plat/vrfb.h> 20 + #include <video/omapvrfb.h> 21 21 22 22 #include "omap_voutdef.h" 23 23 #include "omap_voutlib.h"
+1 -1
drivers/media/platform/omap/omap_voutdef.h
··· 12 12 #define OMAP_VOUTDEF_H 13 13 14 14 #include <video/omapdss.h> 15 - #include <plat/vrfb.h> 15 + #include <video/omapvrfb.h> 16 16 17 17 #define YUYV_BPP 2 18 18 #define RGB565_BPP 2
+1 -1
drivers/video/omap2/omapfb/omapfb-ioctl.c
··· 30 30 #include <linux/export.h> 31 31 32 32 #include <video/omapdss.h> 33 - #include <plat/vrfb.h> 33 + #include <video/omapvrfb.h> 34 34 #include <plat/vram.h> 35 35 36 36 #include "omapfb.h"
+2 -6
drivers/video/omap2/omapfb/omapfb-main.c
··· 31 31 #include <linux/omapfb.h> 32 32 33 33 #include <video/omapdss.h> 34 - #include <plat/cpu.h> 35 34 #include <plat/vram.h> 36 - #include <plat/vrfb.h> 35 + #include <video/omapvrfb.h> 37 36 38 37 #include "omapfb.h" 39 38 ··· 2395 2396 goto err0; 2396 2397 } 2397 2398 2398 - /* TODO : Replace cpu check with omap_has_vrfb once HAS_FEATURE 2399 - * available for OMAP2 and OMAP3 2400 - */ 2401 - if (def_vrfb && !cpu_is_omap24xx() && !cpu_is_omap34xx()) { 2399 + if (def_vrfb && !omap_vrfb_supported()) { 2402 2400 def_vrfb = 0; 2403 2401 dev_warn(&pdev->dev, "VRFB is not supported on this hardware, " 2404 2402 "ignoring the module parameter vrfb=y\n");
+1 -1
drivers/video/omap2/omapfb/omapfb-sysfs.c
··· 30 30 #include <linux/omapfb.h> 31 31 32 32 #include <video/omapdss.h> 33 - #include <plat/vrfb.h> 33 + #include <video/omapvrfb.h> 34 34 35 35 #include "omapfb.h" 36 36
+121 -21
drivers/video/omap2/vrfb.c
··· 26 26 #include <linux/io.h> 27 27 #include <linux/bitops.h> 28 28 #include <linux/mutex.h> 29 + #include <linux/platform_device.h> 29 30 30 - #include <plat/vrfb.h> 31 - #include <plat/sdrc.h> 31 + #include <video/omapvrfb.h> 32 32 33 33 #ifdef DEBUG 34 34 #define DBG(format, ...) pr_debug("VRFB: " format, ## __VA_ARGS__) ··· 36 36 #define DBG(format, ...) 37 37 #endif 38 38 39 - #define SMS_ROT_VIRT_BASE(context, rot) \ 40 - (((context >= 4) ? 0xD0000000 : 0x70000000) \ 41 - + (0x4000000 * (context)) \ 42 - + (0x1000000 * (rot))) 39 + #define SMS_ROT_CONTROL(context) (0x0 + 0x10 * context) 40 + #define SMS_ROT_SIZE(context) (0x4 + 0x10 * context) 41 + #define SMS_ROT_PHYSICAL_BA(context) (0x8 + 0x10 * context) 42 + #define SMS_ROT_VIRT_BASE(rot) (0x1000000 * (rot)) 43 43 44 44 #define OMAP_VRFB_SIZE (2048 * 2048 * 4) 45 45 ··· 53 53 #define SMS_PW_OFFSET 4 54 54 #define SMS_PS_OFFSET 0 55 55 56 - #define VRFB_NUM_CTXS 12 57 56 /* bitmap of reserved contexts */ 58 57 static unsigned long ctx_map; 58 + 59 + struct vrfb_ctx { 60 + u32 base; 61 + u32 physical_ba; 62 + u32 control; 63 + u32 size; 64 + }; 59 65 60 66 static DEFINE_MUTEX(ctx_lock); 61 67 ··· 71 65 * we don't need locking, since no drivers will run until after the wake-up 72 66 * has finished. 73 67 */ 74 - static struct { 75 - u32 physical_ba; 76 - u32 control; 77 - u32 size; 78 - } vrfb_hw_context[VRFB_NUM_CTXS]; 68 + 69 + static void __iomem *vrfb_base; 70 + 71 + static int num_ctxs; 72 + static struct vrfb_ctx *ctxs; 73 + 74 + static bool vrfb_loaded; 75 + 76 + static void omap2_sms_write_rot_control(u32 val, unsigned ctx) 77 + { 78 + __raw_writel(val, vrfb_base + SMS_ROT_CONTROL(ctx)); 79 + } 80 + 81 + static void omap2_sms_write_rot_size(u32 val, unsigned ctx) 82 + { 83 + __raw_writel(val, vrfb_base + SMS_ROT_SIZE(ctx)); 84 + } 85 + 86 + static void omap2_sms_write_rot_physical_ba(u32 val, unsigned ctx) 87 + { 88 + __raw_writel(val, vrfb_base + SMS_ROT_PHYSICAL_BA(ctx)); 89 + } 79 90 80 91 static inline void restore_hw_context(int ctx) 81 92 { 82 - omap2_sms_write_rot_control(vrfb_hw_context[ctx].control, ctx); 83 - omap2_sms_write_rot_size(vrfb_hw_context[ctx].size, ctx); 84 - omap2_sms_write_rot_physical_ba(vrfb_hw_context[ctx].physical_ba, ctx); 93 + omap2_sms_write_rot_control(ctxs[ctx].control, ctx); 94 + omap2_sms_write_rot_size(ctxs[ctx].size, ctx); 95 + omap2_sms_write_rot_physical_ba(ctxs[ctx].physical_ba, ctx); 85 96 } 86 97 87 98 static u32 get_image_width_roundup(u16 width, u8 bytespp) ··· 219 196 control |= VRFB_PAGE_WIDTH_EXP << SMS_PW_OFFSET; 220 197 control |= VRFB_PAGE_HEIGHT_EXP << SMS_PH_OFFSET; 221 198 222 - vrfb_hw_context[ctx].physical_ba = paddr; 223 - vrfb_hw_context[ctx].size = size; 224 - vrfb_hw_context[ctx].control = control; 199 + ctxs[ctx].physical_ba = paddr; 200 + ctxs[ctx].size = size; 201 + ctxs[ctx].control = control; 225 202 226 203 omap2_sms_write_rot_physical_ba(paddr, ctx); 227 204 omap2_sms_write_rot_size(size, ctx); ··· 297 274 298 275 mutex_lock(&ctx_lock); 299 276 300 - for (ctx = 0; ctx < VRFB_NUM_CTXS; ++ctx) 277 + for (ctx = 0; ctx < num_ctxs; ++ctx) 301 278 if ((ctx_map & (1 << ctx)) == 0) 302 279 break; 303 280 304 - if (ctx == VRFB_NUM_CTXS) { 281 + if (ctx == num_ctxs) { 305 282 pr_err("vrfb: no free contexts\n"); 306 283 r = -EBUSY; 307 284 goto out; ··· 316 293 vrfb->context = ctx; 317 294 318 295 for (rot = 0; rot < 4; ++rot) { 319 - paddr = SMS_ROT_VIRT_BASE(ctx, rot); 296 + paddr = ctxs[ctx].base + SMS_ROT_VIRT_BASE(rot); 320 297 if (!request_mem_region(paddr, OMAP_VRFB_SIZE, "vrfb")) { 321 298 pr_err("vrfb: failed to reserve VRFB " 322 299 "area for ctx %d, rotation %d\n", ··· 337 314 return r; 338 315 } 339 316 EXPORT_SYMBOL(omap_vrfb_request_ctx); 317 + 318 + bool omap_vrfb_supported(void) 319 + { 320 + return vrfb_loaded; 321 + } 322 + EXPORT_SYMBOL(omap_vrfb_supported); 323 + 324 + static int __init vrfb_probe(struct platform_device *pdev) 325 + { 326 + struct resource *mem; 327 + int i; 328 + 329 + /* first resource is the register res, the rest are vrfb contexts */ 330 + 331 + mem = platform_get_resource(pdev, IORESOURCE_MEM, 0); 332 + if (!mem) { 333 + dev_err(&pdev->dev, "can't get vrfb base address\n"); 334 + return -EINVAL; 335 + } 336 + 337 + vrfb_base = devm_request_and_ioremap(&pdev->dev, mem); 338 + if (!vrfb_base) { 339 + dev_err(&pdev->dev, "can't ioremap vrfb memory\n"); 340 + return -ENOMEM; 341 + } 342 + 343 + num_ctxs = pdev->num_resources - 1; 344 + 345 + ctxs = devm_kzalloc(&pdev->dev, 346 + sizeof(struct vrfb_ctx) * num_ctxs, 347 + GFP_KERNEL); 348 + 349 + if (!ctxs) 350 + return -ENOMEM; 351 + 352 + for (i = 0; i < num_ctxs; ++i) { 353 + mem = platform_get_resource(pdev, IORESOURCE_MEM, 1 + i); 354 + if (!mem) { 355 + dev_err(&pdev->dev, "can't get vrfb ctx %d address\n", 356 + i); 357 + return -EINVAL; 358 + } 359 + 360 + ctxs[i].base = mem->start; 361 + } 362 + 363 + vrfb_loaded = true; 364 + 365 + return 0; 366 + } 367 + 368 + static void __exit vrfb_remove(struct platform_device *pdev) 369 + { 370 + vrfb_loaded = false; 371 + } 372 + 373 + static struct platform_driver vrfb_driver = { 374 + .driver.name = "omapvrfb", 375 + .remove = __exit_p(vrfb_remove), 376 + }; 377 + 378 + static int __init vrfb_init(void) 379 + { 380 + return platform_driver_probe(&vrfb_driver, &vrfb_probe); 381 + } 382 + 383 + static void __exit vrfb_exit(void) 384 + { 385 + platform_driver_unregister(&vrfb_driver); 386 + } 387 + 388 + module_init(vrfb_init); 389 + module_exit(vrfb_exit); 390 + 391 + MODULE_AUTHOR("Tomi Valkeinen <tomi.valkeinen@ti.com>"); 392 + MODULE_DESCRIPTION("OMAP VRFB"); 393 + MODULE_LICENSE("GPL v2");