Skip to content

Commit 7a992d3

Browse files
committed
Merge branch '3.8/vrfb-conversion'
Merge omap vrfb code to remove direct omap platform dependencies from the driver.
2 parents 9253d2d + a89d1a8 commit 7a992d3

11 files changed

Lines changed: 191 additions & 55 deletions

File tree

‎arch/arm/mach-omap2/sdrc.c‎

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -160,19 +160,3 @@ void __init omap2_sdrc_init(struct omap_sdrc_params *sdrc_cs0,
160160
sdrc_write_reg(l, SDRC_POWER);
161161
omap2_sms_save_context();
162162
}
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-

‎arch/arm/plat-omap/fb.c‎

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,67 @@
3333
#include <mach/hardware.h>
3434
#include <asm/mach/map.h>
3535

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+
3697
#if defined(CONFIG_FB_OMAP) || defined(CONFIG_FB_OMAP_MODULE)
3798

3899
static bool omapfb_lcd_configured;

‎arch/arm/plat-omap/include/plat/sdrc.h‎

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -94,9 +94,6 @@
9494
/* SMS register offsets - read/write with sms_{read,write}_reg() */
9595

9696
#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)
10097
/* REVISIT: fill in other SMS registers here */
10198

10299

@@ -137,10 +134,6 @@ int omap2_sdrc_get_params(unsigned long r,
137134
void omap2_sms_save_context(void);
138135
void omap2_sms_restore_context(void);
139136

140-
void omap2_sms_write_rot_control(u32 val, unsigned ctx);
141-
void omap2_sms_write_rot_size(u32 val, unsigned ctx);
142-
void omap2_sms_write_rot_physical_ba(u32 val, unsigned ctx);
143-
144137
#ifdef CONFIG_ARCH_OMAP2
145138

146139
struct memory_timings {

‎drivers/media/platform/omap/omap_vout.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@
4646

4747
#include <plat/cpu.h>
4848
#include <plat/dma.h>
49-
#include <plat/vrfb.h>
49+
#include <video/omapvrfb.h>
5050
#include <video/omapdss.h>
5151

5252
#include "omap_voutlib.h"

‎drivers/media/platform/omap/omap_vout_vrfb.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
#include <media/v4l2-device.h>
1818

1919
#include <plat/dma.h>
20-
#include <plat/vrfb.h>
20+
#include <video/omapvrfb.h>
2121

2222
#include "omap_voutdef.h"
2323
#include "omap_voutlib.h"

‎drivers/media/platform/omap/omap_voutdef.h‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
#define OMAP_VOUTDEF_H
1313

1414
#include <video/omapdss.h>
15-
#include <plat/vrfb.h>
15+
#include <video/omapvrfb.h>
1616

1717
#define YUYV_BPP 2
1818
#define RGB565_BPP 2

‎drivers/video/omap2/omapfb/omapfb-ioctl.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
#include <linux/export.h>
3131

3232
#include <video/omapdss.h>
33-
#include <plat/vrfb.h>
33+
#include <video/omapvrfb.h>
3434
#include <plat/vram.h>
3535

3636
#include "omapfb.h"

‎drivers/video/omap2/omapfb/omapfb-main.c‎

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,8 @@
3131
#include <linux/omapfb.h>
3232

3333
#include <video/omapdss.h>
34-
#include <plat/cpu.h>
3534
#include <plat/vram.h>
36-
#include <plat/vrfb.h>
35+
#include <video/omapvrfb.h>
3736

3837
#include "omapfb.h"
3938

@@ -2396,10 +2395,7 @@ static int __init omapfb_probe(struct platform_device *pdev)
23962395
goto err0;
23972396
}
23982397

2399-
/* TODO : Replace cpu check with omap_has_vrfb once HAS_FEATURE
2400-
* available for OMAP2 and OMAP3
2401-
*/
2402-
if (def_vrfb && !cpu_is_omap24xx() && !cpu_is_omap34xx()) {
2398+
if (def_vrfb && !omap_vrfb_supported()) {
24032399
def_vrfb = 0;
24042400
dev_warn(&pdev->dev, "VRFB is not supported on this hardware, "
24052401
"ignoring the module parameter vrfb=y\n");

‎drivers/video/omap2/omapfb/omapfb-sysfs.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
#include <linux/omapfb.h>
3131

3232
#include <video/omapdss.h>
33-
#include <plat/vrfb.h>
33+
#include <video/omapvrfb.h>
3434

3535
#include "omapfb.h"
3636

‎drivers/video/omap2/vrfb.c‎

Lines changed: 121 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -26,20 +26,20 @@
2626
#include <linux/io.h>
2727
#include <linux/bitops.h>
2828
#include <linux/mutex.h>
29+
#include <linux/platform_device.h>
2930

30-
#include <plat/vrfb.h>
31-
#include <plat/sdrc.h>
31+
#include <video/omapvrfb.h>
3232

3333
#ifdef DEBUG
3434
#define DBG(format, ...) pr_debug("VRFB: " format, ## __VA_ARGS__)
3535
#else
3636
#define DBG(format, ...)
3737
#endif
3838

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))
4343

4444
#define OMAP_VRFB_SIZE (2048 * 2048 * 4)
4545

@@ -53,10 +53,16 @@
5353
#define SMS_PW_OFFSET 4
5454
#define SMS_PS_OFFSET 0
5555

56-
#define VRFB_NUM_CTXS 12
5756
/* bitmap of reserved contexts */
5857
static unsigned long ctx_map;
5958

59+
struct vrfb_ctx {
60+
u32 base;
61+
u32 physical_ba;
62+
u32 control;
63+
u32 size;
64+
};
65+
6066
static DEFINE_MUTEX(ctx_lock);
6167

6268
/*
@@ -65,17 +71,34 @@ static DEFINE_MUTEX(ctx_lock);
6571
* we don't need locking, since no drivers will run until after the wake-up
6672
* has finished.
6773
*/
68-
static struct {
69-
u32 physical_ba;
70-
u32 control;
71-
u32 size;
72-
} vrfb_hw_context[VRFB_NUM_CTXS];
74+
75+
static void __iomem *vrfb_base;
76+
77+
static int num_ctxs;
78+
static struct vrfb_ctx *ctxs;
79+
80+
static bool vrfb_loaded;
81+
82+
static void omap2_sms_write_rot_control(u32 val, unsigned ctx)
83+
{
84+
__raw_writel(val, vrfb_base + SMS_ROT_CONTROL(ctx));
85+
}
86+
87+
static void omap2_sms_write_rot_size(u32 val, unsigned ctx)
88+
{
89+
__raw_writel(val, vrfb_base + SMS_ROT_SIZE(ctx));
90+
}
91+
92+
static void omap2_sms_write_rot_physical_ba(u32 val, unsigned ctx)
93+
{
94+
__raw_writel(val, vrfb_base + SMS_ROT_PHYSICAL_BA(ctx));
95+
}
7396

7497
static inline void restore_hw_context(int ctx)
7598
{
76-
omap2_sms_write_rot_control(vrfb_hw_context[ctx].control, ctx);
77-
omap2_sms_write_rot_size(vrfb_hw_context[ctx].size, ctx);
78-
omap2_sms_write_rot_physical_ba(vrfb_hw_context[ctx].physical_ba, ctx);
99+
omap2_sms_write_rot_control(ctxs[ctx].control, ctx);
100+
omap2_sms_write_rot_size(ctxs[ctx].size, ctx);
101+
omap2_sms_write_rot_physical_ba(ctxs[ctx].physical_ba, ctx);
79102
}
80103

81104
static u32 get_image_width_roundup(u16 width, u8 bytespp)
@@ -196,9 +219,9 @@ void omap_vrfb_setup(struct vrfb *vrfb, unsigned long paddr,
196219
control |= VRFB_PAGE_WIDTH_EXP << SMS_PW_OFFSET;
197220
control |= VRFB_PAGE_HEIGHT_EXP << SMS_PH_OFFSET;
198221

199-
vrfb_hw_context[ctx].physical_ba = paddr;
200-
vrfb_hw_context[ctx].size = size;
201-
vrfb_hw_context[ctx].control = control;
222+
ctxs[ctx].physical_ba = paddr;
223+
ctxs[ctx].size = size;
224+
ctxs[ctx].control = control;
202225

203226
omap2_sms_write_rot_physical_ba(paddr, ctx);
204227
omap2_sms_write_rot_size(size, ctx);
@@ -274,11 +297,11 @@ int omap_vrfb_request_ctx(struct vrfb *vrfb)
274297

275298
mutex_lock(&ctx_lock);
276299

277-
for (ctx = 0; ctx < VRFB_NUM_CTXS; ++ctx)
300+
for (ctx = 0; ctx < num_ctxs; ++ctx)
278301
if ((ctx_map & (1 << ctx)) == 0)
279302
break;
280303

281-
if (ctx == VRFB_NUM_CTXS) {
304+
if (ctx == num_ctxs) {
282305
pr_err("vrfb: no free contexts\n");
283306
r = -EBUSY;
284307
goto out;
@@ -293,7 +316,7 @@ int omap_vrfb_request_ctx(struct vrfb *vrfb)
293316
vrfb->context = ctx;
294317

295318
for (rot = 0; rot < 4; ++rot) {
296-
paddr = SMS_ROT_VIRT_BASE(ctx, rot);
319+
paddr = ctxs[ctx].base + SMS_ROT_VIRT_BASE(rot);
297320
if (!request_mem_region(paddr, OMAP_VRFB_SIZE, "vrfb")) {
298321
pr_err("vrfb: failed to reserve VRFB "
299322
"area for ctx %d, rotation %d\n",
@@ -314,3 +337,80 @@ int omap_vrfb_request_ctx(struct vrfb *vrfb)
314337
return r;
315338
}
316339
EXPORT_SYMBOL(omap_vrfb_request_ctx);
340+
341+
bool omap_vrfb_supported(void)
342+
{
343+
return vrfb_loaded;
344+
}
345+
EXPORT_SYMBOL(omap_vrfb_supported);
346+
347+
static int __init vrfb_probe(struct platform_device *pdev)
348+
{
349+
struct resource *mem;
350+
int i;
351+
352+
/* first resource is the register res, the rest are vrfb contexts */
353+
354+
mem = platform_get_resource(pdev, IORESOURCE_MEM, 0);
355+
if (!mem) {
356+
dev_err(&pdev->dev, "can't get vrfb base address\n");
357+
return -EINVAL;
358+
}
359+
360+
vrfb_base = devm_request_and_ioremap(&pdev->dev, mem);
361+
if (!vrfb_base) {
362+
dev_err(&pdev->dev, "can't ioremap vrfb memory\n");
363+
return -ENOMEM;
364+
}
365+
366+
num_ctxs = pdev->num_resources - 1;
367+
368+
ctxs = devm_kzalloc(&pdev->dev,
369+
sizeof(struct vrfb_ctx) * num_ctxs,
370+
GFP_KERNEL);
371+
372+
if (!ctxs)
373+
return -ENOMEM;
374+
375+
for (i = 0; i < num_ctxs; ++i) {
376+
mem = platform_get_resource(pdev, IORESOURCE_MEM, 1 + i);
377+
if (!mem) {
378+
dev_err(&pdev->dev, "can't get vrfb ctx %d address\n",
379+
i);
380+
return -EINVAL;
381+
}
382+
383+
ctxs[i].base = mem->start;
384+
}
385+
386+
vrfb_loaded = true;
387+
388+
return 0;
389+
}
390+
391+
static void __exit vrfb_remove(struct platform_device *pdev)
392+
{
393+
vrfb_loaded = false;
394+
}
395+
396+
static struct platform_driver vrfb_driver = {
397+
.driver.name = "omapvrfb",
398+
.remove = __exit_p(vrfb_remove),
399+
};
400+
401+
static int __init vrfb_init(void)
402+
{
403+
return platform_driver_probe(&vrfb_driver, &vrfb_probe);
404+
}
405+
406+
static void __exit vrfb_exit(void)
407+
{
408+
platform_driver_unregister(&vrfb_driver);
409+
}
410+
411+
module_init(vrfb_init);
412+
module_exit(vrfb_exit);
413+
414+
MODULE_AUTHOR("Tomi Valkeinen <tomi.valkeinen@ti.com>");
415+
MODULE_DESCRIPTION("OMAP VRFB");
416+
MODULE_LICENSE("GPL v2");

0 commit comments

Comments
 (0)