You've already forked linux-apfs
mirror of
https://github.com/linux-apfs/linux-apfs.git
synced 2026-05-01 15:00:59 -07:00
sh_mobile_meram: MERAM framework for LCDC
Based on the patch by Takanari Hayama <taki@igel.co.jp> Adds support framework necessary to use Media RAM (MERAM) caching functionality with the LCDC. The MERAM is accessed through up to 4 Interconnect Buffers (ICBs). ICB numbers and MERAM address ranges to use are specified in by filling in the .meram_cfg member of the LCDC platform data Signed-off-by: Damian Hobson-Garcia <dhobsong@igel.co.jp> Signed-off-by: Paul Mundt <lethal@linux-sh.org>
This commit is contained in:
@@ -1986,6 +1986,18 @@ config FB_SH_MOBILE_HDMI
|
||||
---help---
|
||||
Driver for the on-chip SH-Mobile HDMI controller.
|
||||
|
||||
config FB_SH_MOBILE_MERAM
|
||||
tristate "SuperH Mobile MERAM read ahead support for LCDC"
|
||||
depends on FB_SH_MOBILE_LCDC
|
||||
default y
|
||||
---help---
|
||||
Enable MERAM support for the SH-Mobile LCD controller.
|
||||
|
||||
This will allow for caching of the framebuffer to provide more
|
||||
reliable access under heavy main memory bus traffic situations.
|
||||
Up to 4 memory channels can be configured, allowing 4 RGB or
|
||||
2 YCbCr framebuffers to be configured.
|
||||
|
||||
config FB_TMIO
|
||||
tristate "Toshiba Mobile IO FrameBuffer support"
|
||||
depends on FB && MFD_CORE
|
||||
|
||||
@@ -130,6 +130,7 @@ obj-$(CONFIG_FB_UDL) += udlfb.o
|
||||
obj-$(CONFIG_FB_XILINX) += xilinxfb.o
|
||||
obj-$(CONFIG_SH_MIPI_DSI) += sh_mipi_dsi.o
|
||||
obj-$(CONFIG_FB_SH_MOBILE_HDMI) += sh_mobile_hdmi.o
|
||||
obj-$(CONFIG_FB_SH_MOBILE_MERAM) += sh_mobile_meram.o
|
||||
obj-$(CONFIG_FB_SH_MOBILE_LCDC) += sh_mobile_lcdcfb.o
|
||||
obj-$(CONFIG_FB_OMAP) += omap/
|
||||
obj-y += omap2/
|
||||
|
||||
@@ -27,6 +27,7 @@
|
||||
#include <asm/atomic.h>
|
||||
|
||||
#include "sh_mobile_lcdcfb.h"
|
||||
#include "sh_mobile_meram.h"
|
||||
|
||||
#define SIDE_B_OFFSET 0x1000
|
||||
#define MIRROR_OFFSET 0x2000
|
||||
@@ -143,6 +144,7 @@ struct sh_mobile_lcdc_priv {
|
||||
unsigned long saved_shared_regs[NR_SHARED_REGS];
|
||||
int started;
|
||||
int forced_bpp; /* 2 channel LCDC must share bpp setting */
|
||||
struct sh_mobile_meram_info *meram_dev;
|
||||
};
|
||||
|
||||
static bool banked(int reg_nr)
|
||||
@@ -564,6 +566,9 @@ static int sh_mobile_lcdc_start(struct sh_mobile_lcdc_priv *priv)
|
||||
}
|
||||
|
||||
for (k = 0; k < ARRAY_SIZE(priv->ch); k++) {
|
||||
unsigned long base_addr_y;
|
||||
unsigned long base_addr_c = 0;
|
||||
int pitch;
|
||||
ch = &priv->ch[k];
|
||||
|
||||
if (!priv->ch[k].enabled)
|
||||
@@ -598,16 +603,63 @@ static int sh_mobile_lcdc_start(struct sh_mobile_lcdc_priv *priv)
|
||||
}
|
||||
lcdc_write_chan(ch, LDDFR, tmp);
|
||||
|
||||
/* point out our frame buffer */
|
||||
lcdc_write_chan(ch, LDSA1R, ch->info->fix.smem_start);
|
||||
if (ch->info->var.nonstd)
|
||||
lcdc_write_chan(ch, LDSA2R,
|
||||
ch->info->fix.smem_start +
|
||||
base_addr_y = ch->info->fix.smem_start;
|
||||
base_addr_c = base_addr_y +
|
||||
ch->info->var.xres *
|
||||
ch->info->var.yres_virtual);
|
||||
ch->info->var.yres_virtual;
|
||||
pitch = ch->info->fix.line_length;
|
||||
|
||||
/* test if we can enable meram */
|
||||
if (ch->cfg.meram_cfg && priv->meram_dev) {
|
||||
struct sh_mobile_meram_cfg *cfg;
|
||||
struct sh_mobile_meram_info *mdev;
|
||||
unsigned long icb_addr_y, icb_addr_c;
|
||||
int icb_pitch;
|
||||
int pf;
|
||||
|
||||
cfg = ch->cfg.meram_cfg;
|
||||
mdev = priv->meram_dev;
|
||||
/* we need to de-init configured ICBs before we
|
||||
* we can re-initialize them.
|
||||
*/
|
||||
if (ch->meram_enabled)
|
||||
mdev->ops->meram_unregister(mdev, cfg);
|
||||
|
||||
ch->meram_enabled = 0;
|
||||
|
||||
if (ch->info->var.nonstd)
|
||||
pf = SH_MOBILE_MERAM_PF_NV;
|
||||
else
|
||||
pf = SH_MOBILE_MERAM_PF_RGB;
|
||||
|
||||
ret = mdev->ops->meram_register(mdev, cfg, pitch,
|
||||
ch->info->var.yres,
|
||||
pf,
|
||||
base_addr_y,
|
||||
base_addr_c,
|
||||
&icb_addr_y,
|
||||
&icb_addr_c,
|
||||
&icb_pitch);
|
||||
if (!ret) {
|
||||
/* set LDSA1R value */
|
||||
base_addr_y = icb_addr_y;
|
||||
pitch = icb_pitch;
|
||||
|
||||
/* set LDSA2R value if required */
|
||||
if (base_addr_c)
|
||||
base_addr_c = icb_addr_c;
|
||||
|
||||
ch->meram_enabled = 1;
|
||||
}
|
||||
}
|
||||
|
||||
/* point out our frame buffer */
|
||||
lcdc_write_chan(ch, LDSA1R, base_addr_y);
|
||||
if (ch->info->var.nonstd)
|
||||
lcdc_write_chan(ch, LDSA2R, base_addr_c);
|
||||
|
||||
/* set line size */
|
||||
lcdc_write_chan(ch, LDMLSR, ch->info->fix.line_length);
|
||||
lcdc_write_chan(ch, LDMLSR, pitch);
|
||||
|
||||
/* setup deferred io if SYS bus */
|
||||
tmp = ch->cfg.sys_bus_cfg.deferred_io_msec;
|
||||
@@ -692,6 +744,17 @@ static void sh_mobile_lcdc_stop(struct sh_mobile_lcdc_priv *priv)
|
||||
board_cfg->display_off(board_cfg->board_data);
|
||||
module_put(board_cfg->owner);
|
||||
}
|
||||
|
||||
/* disable the meram */
|
||||
if (ch->meram_enabled) {
|
||||
struct sh_mobile_meram_cfg *cfg;
|
||||
struct sh_mobile_meram_info *mdev;
|
||||
cfg = ch->cfg.meram_cfg;
|
||||
mdev = priv->meram_dev;
|
||||
mdev->ops->meram_unregister(mdev, cfg);
|
||||
ch->meram_enabled = 0;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/* stop the lcdc */
|
||||
@@ -875,9 +938,29 @@ static int sh_mobile_fb_pan_display(struct fb_var_screeninfo *var,
|
||||
} else
|
||||
base_addr_c = 0;
|
||||
|
||||
lcdc_write_chan_mirror(ch, LDSA1R, base_addr_y);
|
||||
if (base_addr_c)
|
||||
lcdc_write_chan_mirror(ch, LDSA2R, base_addr_c);
|
||||
if (!ch->meram_enabled) {
|
||||
lcdc_write_chan_mirror(ch, LDSA1R, base_addr_y);
|
||||
if (base_addr_c)
|
||||
lcdc_write_chan_mirror(ch, LDSA2R, base_addr_c);
|
||||
} else {
|
||||
struct sh_mobile_meram_cfg *cfg;
|
||||
struct sh_mobile_meram_info *mdev;
|
||||
unsigned long icb_addr_y, icb_addr_c;
|
||||
int ret;
|
||||
|
||||
cfg = ch->cfg.meram_cfg;
|
||||
mdev = priv->meram_dev;
|
||||
ret = mdev->ops->meram_update(mdev, cfg,
|
||||
base_addr_y, base_addr_c,
|
||||
&icb_addr_y, &icb_addr_c);
|
||||
if (ret)
|
||||
return ret;
|
||||
|
||||
lcdc_write_chan_mirror(ch, LDSA1R, icb_addr_y);
|
||||
if (icb_addr_c)
|
||||
lcdc_write_chan_mirror(ch, LDSA2R, icb_addr_c);
|
||||
|
||||
}
|
||||
|
||||
if (lcdc_chan_is_sublcd(ch))
|
||||
lcdc_write(ch->lcdc, _LDRCNTR, ldrcntr ^ LDRCNTR_SRS);
|
||||
@@ -1420,6 +1503,8 @@ static int __devinit sh_mobile_lcdc_probe(struct platform_device *pdev)
|
||||
goto err1;
|
||||
}
|
||||
|
||||
priv->meram_dev = pdata->meram_dev;
|
||||
|
||||
for (i = 0; i < j; i++) {
|
||||
struct fb_var_screeninfo *var;
|
||||
const struct fb_videomode *lcd_cfg, *max_cfg = NULL;
|
||||
|
||||
@@ -39,6 +39,7 @@ struct sh_mobile_lcdc_chan {
|
||||
int use_count;
|
||||
int blank_status;
|
||||
struct mutex open_lock; /* protects the use counter */
|
||||
int meram_enabled;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,41 @@
|
||||
#ifndef __sh_mobile_meram_h__
|
||||
#define __sh_mobile_meram_h__
|
||||
|
||||
#include <linux/mutex.h>
|
||||
#include <video/sh_mobile_meram.h>
|
||||
|
||||
/*
|
||||
* MERAM private
|
||||
*/
|
||||
|
||||
#define MERAM_ICB_Y 0x1
|
||||
#define MERAM_ICB_C 0x2
|
||||
|
||||
/* MERAM cache size */
|
||||
#define SH_MOBILE_MERAM_ICB_NUM 32
|
||||
|
||||
#define SH_MOBILE_MERAM_CACHE_OFFSET(p) ((p) >> 16)
|
||||
#define SH_MOBILE_MERAM_CACHE_SIZE(p) ((p) & 0xffff)
|
||||
|
||||
struct sh_mobile_meram_priv {
|
||||
void __iomem *base;
|
||||
struct mutex lock;
|
||||
unsigned long used_icb;
|
||||
int used_meram_cache_regions;
|
||||
unsigned long used_meram_cache[SH_MOBILE_MERAM_ICB_NUM];
|
||||
};
|
||||
|
||||
int sh_mobile_meram_alloc_icb(const struct sh_mobile_meram_cfg *cfg,
|
||||
int xres,
|
||||
int yres,
|
||||
unsigned int base_addr,
|
||||
int yuv_mode,
|
||||
int *marker_icb,
|
||||
int *out_pitch);
|
||||
|
||||
void sh_mobile_meram_free_icb(int marker_icb);
|
||||
|
||||
#define SH_MOBILE_MERAM_START(ind, ab) \
|
||||
(0xC0000000 | ((ab & 0x1) << 23) | ((ind & 0x1F) << 24))
|
||||
|
||||
#endif /* !__sh_mobile_meram_h__ */
|
||||
@@ -2,6 +2,7 @@
|
||||
#define __ASM_SH_MOBILE_LCDC_H__
|
||||
|
||||
#include <linux/fb.h>
|
||||
#include <video/sh_mobile_meram.h>
|
||||
|
||||
enum {
|
||||
RGB8, /* 24bpp, 8:8:8 */
|
||||
@@ -87,11 +88,13 @@ struct sh_mobile_lcdc_chan_cfg {
|
||||
struct sh_mobile_lcdc_bl_info bl_info;
|
||||
struct sh_mobile_lcdc_sys_bus_cfg sys_bus_cfg; /* only for SYSn I/F */
|
||||
int nonstd;
|
||||
struct sh_mobile_meram_cfg *meram_cfg;
|
||||
};
|
||||
|
||||
struct sh_mobile_lcdc_info {
|
||||
int clock_source;
|
||||
struct sh_mobile_lcdc_chan_cfg ch[2];
|
||||
struct sh_mobile_meram_info *meram_dev;
|
||||
};
|
||||
|
||||
#endif /* __ASM_SH_MOBILE_LCDC_H__ */
|
||||
|
||||
@@ -0,0 +1,67 @@
|
||||
#ifndef __VIDEO_SH_MOBILE_MERAM_H__
|
||||
#define __VIDEO_SH_MOBILE_MERAM_H__
|
||||
|
||||
/* For sh_mobile_meram_info.addr_mode */
|
||||
enum {
|
||||
SH_MOBILE_MERAM_MODE0 = 0,
|
||||
SH_MOBILE_MERAM_MODE1
|
||||
};
|
||||
|
||||
enum {
|
||||
SH_MOBILE_MERAM_PF_NV = 0,
|
||||
SH_MOBILE_MERAM_PF_RGB
|
||||
};
|
||||
|
||||
|
||||
struct sh_mobile_meram_priv;
|
||||
struct sh_mobile_meram_ops;
|
||||
|
||||
struct sh_mobile_meram_info {
|
||||
int addr_mode;
|
||||
struct sh_mobile_meram_ops *ops;
|
||||
struct sh_mobile_meram_priv *priv;
|
||||
struct platform_device *pdev;
|
||||
};
|
||||
|
||||
/* icb config */
|
||||
struct sh_mobile_meram_icb {
|
||||
int marker_icb; /* ICB # for Marker ICB */
|
||||
int cache_icb; /* ICB # for Cache ICB */
|
||||
int meram_offset; /* MERAM Buffer Offset to use */
|
||||
int meram_size; /* MERAM Buffer Size to use */
|
||||
|
||||
int cache_unit; /* bytes to cache per ICB */
|
||||
};
|
||||
|
||||
struct sh_mobile_meram_cfg {
|
||||
struct sh_mobile_meram_icb icb[2];
|
||||
int pixelformat;
|
||||
int current_reg;
|
||||
};
|
||||
|
||||
struct module;
|
||||
struct sh_mobile_meram_ops {
|
||||
struct module *module;
|
||||
/* register usage of meram */
|
||||
int (*meram_register)(struct sh_mobile_meram_info *meram_dev,
|
||||
struct sh_mobile_meram_cfg *cfg,
|
||||
int xres, int yres, int pixelformat,
|
||||
unsigned long base_addr_y,
|
||||
unsigned long base_addr_c,
|
||||
unsigned long *icb_addr_y,
|
||||
unsigned long *icb_addr_c, int *pitch);
|
||||
|
||||
/* unregister usage of meram */
|
||||
int (*meram_unregister)(struct sh_mobile_meram_info *meram_dev,
|
||||
struct sh_mobile_meram_cfg *cfg);
|
||||
|
||||
/* update meram settings */
|
||||
int (*meram_update)(struct sh_mobile_meram_info *meram_dev,
|
||||
struct sh_mobile_meram_cfg *cfg,
|
||||
unsigned long base_addr_y,
|
||||
unsigned long base_addr_c,
|
||||
unsigned long *icb_addr_y,
|
||||
unsigned long *icb_addr_c);
|
||||
};
|
||||
|
||||
#endif /* __VIDEO_SH_MOBILE_MERAM_H__ */
|
||||
Reference in New Issue
Block a user