Re: [PATCH 03/15] OMAP: Add VRAM manager
* Tomi Valkeinen [090805 17:19]: > Add a Video RAM manager for OMAP 2 and 3 platforms. VRAM manager is used > to allocate large continuous blocks of SDRAM or SRAM. The features VRAM > manager has that are missing from dma_alloc_* functions are: > > - Support for OMAP2's SRAM > - Allocate without ioremapping > - Allocate at defined physical addresses > - Allows larger VRAM area and larger allocations > > The upcoming DSS2 uses VRAM manager. > > VRAM area size can be defined in kernel config, board file or with > kernel boot parameters. Board file definition overrides kernel config, > and boot parameter overrides kernel config and board file. > > Signed-off-by: Tomi Valkeinen > --- > arch/arm/mach-omap2/io.c |2 + > arch/arm/plat-omap/Kconfig |3 + > arch/arm/plat-omap/Makefile|1 + > arch/arm/plat-omap/include/mach/vram.h | 63 +++ > arch/arm/plat-omap/sram.c |8 + > arch/arm/plat-omap/vram.c | 655 > > 6 files changed, 732 insertions(+), 0 deletions(-) > create mode 100644 arch/arm/plat-omap/include/mach/vram.h > create mode 100644 arch/arm/plat-omap/vram.c Can you place vram.c under drivers/video/omap? > > diff --git a/arch/arm/mach-omap2/io.c b/arch/arm/mach-omap2/io.c > index 7a54e12..e37f736 100644 > --- a/arch/arm/mach-omap2/io.c > +++ b/arch/arm/mach-omap2/io.c > @@ -32,6 +32,7 @@ > #include > #include > #include > +#include > > #ifndef CONFIG_ARCH_OMAP4/* FIXME: Remove this once clkdev is ready */ > #include "clock.h" > @@ -240,6 +241,7 @@ void __init omap2_map_common_io(void) > omap2_check_revision(); > omap_sram_init(); > omapfb_reserve_sdram(); > + omap_vram_reserve_sdram(); > } > > /* > diff --git a/arch/arm/plat-omap/Kconfig b/arch/arm/plat-omap/Kconfig > index efe85d0..ca06037 100644 > --- a/arch/arm/plat-omap/Kconfig > +++ b/arch/arm/plat-omap/Kconfig > @@ -183,6 +183,9 @@ config OMAP_SERIAL_WAKE > to data on the serial RX line. This allows you to wake the > system from serial console. > > +config OMAP2_VRAM > + bool > + > endmenu > > endif > diff --git a/arch/arm/plat-omap/Makefile b/arch/arm/plat-omap/Makefile > index a832795..0472bbe 100644 > --- a/arch/arm/plat-omap/Makefile > +++ b/arch/arm/plat-omap/Makefile > @@ -25,3 +25,4 @@ obj-y += $(i2c-omap-m) $(i2c-omap-y) > # OMAP mailbox framework > obj-$(CONFIG_OMAP_MBOX_FWK) += mailbox.o > > +obj-$(CONFIG_OMAP2_VRAM) += vram.o > diff --git a/arch/arm/plat-omap/include/mach/vram.h > b/arch/arm/plat-omap/include/mach/vram.h > new file mode 100644 > index 000..fe72f81 > --- /dev/null > +++ b/arch/arm/plat-omap/include/mach/vram.h > @@ -0,0 +1,63 @@ > +/* > + * VRAM manager for OMAP > + * > + * Copyright (C) 2009 Nokia Corporation > + * Author: Tomi Valkeinen > + * > + * This program is free software; you can redistribute it and/or modify > + * it under the terms of the GNU General Public License version 2 as > + * published by the Free Software Foundation. > + * > + * This program is distributed in the hope that it will be useful, but > + * WITHOUT ANY WARRANTY; without even the implied warranty of > + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU > + * General Public License for more details. > + * > + * You should have received a copy of the GNU General Public License along > + * with this program; if not, write to the Free Software Foundation, Inc., > + * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. > + */ > + > +#ifndef __OMAP_VRAM_H__ > +#define __OMAP_VRAM_H__ > + > +#include > +#include > + > +#define OMAP_VRAM_MEMTYPE_SDRAM 0 > +#define OMAP_VRAM_MEMTYPE_SRAM 1 > +#define OMAP_VRAM_MEMTYPE_MAX1 > + > +extern int omap_vram_add_region(unsigned long paddr, size_t size); > +extern int omap_vram_free(unsigned long paddr, size_t size); > +extern int omap_vram_alloc(int mtype, size_t size, unsigned long *paddr); > +extern int omap_vram_reserve(unsigned long paddr, size_t size); > +extern void omap_vram_get_info(unsigned long *vram, unsigned long *free_vram, > + unsigned long *largest_free_block); > + > +#ifdef CONFIG_OMAP2_VRAM > +extern void omap_vram_set_sdram_vram(u32 size, u32 start); > +extern void omap_vram_set_sram_vram(u32 size, u32 start); > + > +extern void omap_vram_reserve_sdram(void); > +extern unsigned long omap_vram_reserve_sram(unsigned long sram_pstart, > + unsigned long sram_vstart, > + unsigned long sram_size, > + unsigned long pstart_avail, > + unsigned long size_avail); > +#else > +static inline void omap_vram_set_sdram_vram(u32 size, u32 start) { } > +static inline void omap_vram_set_sram_vram(u32 size, u32 start) { } > + > +static inline void omap_vram_reserve_sdram(void
[PATCH 03/15] OMAP: Add VRAM manager
Add a Video RAM manager for OMAP 2 and 3 platforms. VRAM manager is used to allocate large continuous blocks of SDRAM or SRAM. The features VRAM manager has that are missing from dma_alloc_* functions are: - Support for OMAP2's SRAM - Allocate without ioremapping - Allocate at defined physical addresses - Allows larger VRAM area and larger allocations The upcoming DSS2 uses VRAM manager. VRAM area size can be defined in kernel config, board file or with kernel boot parameters. Board file definition overrides kernel config, and boot parameter overrides kernel config and board file. Signed-off-by: Tomi Valkeinen --- arch/arm/mach-omap2/io.c |2 + arch/arm/plat-omap/Kconfig |3 + arch/arm/plat-omap/Makefile|1 + arch/arm/plat-omap/include/mach/vram.h | 63 +++ arch/arm/plat-omap/sram.c |8 + arch/arm/plat-omap/vram.c | 655 6 files changed, 732 insertions(+), 0 deletions(-) create mode 100644 arch/arm/plat-omap/include/mach/vram.h create mode 100644 arch/arm/plat-omap/vram.c diff --git a/arch/arm/mach-omap2/io.c b/arch/arm/mach-omap2/io.c index 7a54e12..e37f736 100644 --- a/arch/arm/mach-omap2/io.c +++ b/arch/arm/mach-omap2/io.c @@ -32,6 +32,7 @@ #include #include #include +#include #ifndef CONFIG_ARCH_OMAP4 /* FIXME: Remove this once clkdev is ready */ #include "clock.h" @@ -240,6 +241,7 @@ void __init omap2_map_common_io(void) omap2_check_revision(); omap_sram_init(); omapfb_reserve_sdram(); + omap_vram_reserve_sdram(); } /* diff --git a/arch/arm/plat-omap/Kconfig b/arch/arm/plat-omap/Kconfig index efe85d0..ca06037 100644 --- a/arch/arm/plat-omap/Kconfig +++ b/arch/arm/plat-omap/Kconfig @@ -183,6 +183,9 @@ config OMAP_SERIAL_WAKE to data on the serial RX line. This allows you to wake the system from serial console. +config OMAP2_VRAM + bool + endmenu endif diff --git a/arch/arm/plat-omap/Makefile b/arch/arm/plat-omap/Makefile index a832795..0472bbe 100644 --- a/arch/arm/plat-omap/Makefile +++ b/arch/arm/plat-omap/Makefile @@ -25,3 +25,4 @@ obj-y += $(i2c-omap-m) $(i2c-omap-y) # OMAP mailbox framework obj-$(CONFIG_OMAP_MBOX_FWK) += mailbox.o +obj-$(CONFIG_OMAP2_VRAM) += vram.o diff --git a/arch/arm/plat-omap/include/mach/vram.h b/arch/arm/plat-omap/include/mach/vram.h new file mode 100644 index 000..fe72f81 --- /dev/null +++ b/arch/arm/plat-omap/include/mach/vram.h @@ -0,0 +1,63 @@ +/* + * VRAM manager for OMAP + * + * Copyright (C) 2009 Nokia Corporation + * Author: Tomi Valkeinen + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + */ + +#ifndef __OMAP_VRAM_H__ +#define __OMAP_VRAM_H__ + +#include +#include + +#define OMAP_VRAM_MEMTYPE_SDRAM0 +#define OMAP_VRAM_MEMTYPE_SRAM 1 +#define OMAP_VRAM_MEMTYPE_MAX 1 + +extern int omap_vram_add_region(unsigned long paddr, size_t size); +extern int omap_vram_free(unsigned long paddr, size_t size); +extern int omap_vram_alloc(int mtype, size_t size, unsigned long *paddr); +extern int omap_vram_reserve(unsigned long paddr, size_t size); +extern void omap_vram_get_info(unsigned long *vram, unsigned long *free_vram, + unsigned long *largest_free_block); + +#ifdef CONFIG_OMAP2_VRAM +extern void omap_vram_set_sdram_vram(u32 size, u32 start); +extern void omap_vram_set_sram_vram(u32 size, u32 start); + +extern void omap_vram_reserve_sdram(void); +extern unsigned long omap_vram_reserve_sram(unsigned long sram_pstart, + unsigned long sram_vstart, + unsigned long sram_size, + unsigned long pstart_avail, + unsigned long size_avail); +#else +static inline void omap_vram_set_sdram_vram(u32 size, u32 start) { } +static inline void omap_vram_set_sram_vram(u32 size, u32 start) { } + +static inline void omap_vram_reserve_sdram(void) { } +static inline unsigned long omap_vram_reserve_sram(unsigned long sram_pstart, + unsigned long sram_vstart, + unsigned long sram_size, + unsigned long pstart_avail, +