Commit 2fa35224 authored by Yuri Tikhonov's avatar Yuri Tikhonov

RM-498 dmamem: get 'dmamem' params from *.dtb (if present)

Signed-off-by: default avatarYuri Tikhonov <yur@emcraft.com>
parent 09c9deb1
......@@ -479,6 +479,52 @@ void fdt_fixup_ethernet(void *fdt)
}
}
#ifdef CONFIG_DMAMEM
void fdt_fixup_dmamem(void *fdt)
{
/*
* By default assume param values specified in U-Boot config
*/
u32 mem_adr = CONFIG_DMAMEM_BASE;
u32 mem_sz = CONFIG_DMAMEM_SZ_ALL;
u32 fb_sz = CONFIG_DMAMEM_SZ_FB;
const u32 *val;
int node;
node = fdt_path_offset(fdt, "/dmamem");
if (node < 0) {
/*
* The device-tree file does not include 'dmamem' node.
* Create it, and fill with U-Boot params
*/
node = fdt_add_subnode(fdt, 0, "dmamem");
if (node < 0)
goto out;
fdt_setprop_string(fdt, node, "compatible", "dmamem");
fdt_setprop_cell(fdt, node, "base-addr", mem_adr);
fdt_setprop_cell(fdt, node, "full-size", mem_sz);
fdt_setprop_cell(fdt, node, "fb-size", fb_sz);
goto out;
}
/*
* Get params from device-tree
*/
val = fdt_getprop(fdt, node, "base-addr", NULL);
if (val)
mem_adr = fdt32_to_cpu(*val);
val = fdt_getprop(fdt, node, "full-size", NULL);
if (val)
mem_sz = fdt32_to_cpu(*val);
out:
/*
* Configure the dmamem area if it's not empty
*/
if (mem_sz)
dmamem_init(mem_adr, mem_sz);
}
#endif
#ifdef CONFIG_HAS_FSL_DR_USB
void fdt_fixup_dr_usb(void *blob, bd_t *bd)
{
......
......@@ -195,17 +195,6 @@ static void stm32f7_mpu_config(void)
#endif
0 << 8 | 24 << 1 | 1 << 0);
#if defined(CONFIG_STM32F7_DCACHE_ON)
/*
* Configure DMAMEM as non-cacheable
*/
cortex_m3_mpu_set_region(MPU_RGN_SDRAM_NC,
CONFIG_DMAMEM_BASE | 1 << 4 | MPU_RGN_SDRAM_NC << 0,
0 << 28 | 3 << 24 |
1 << 19 | 0 << 18 | 0 << 17 | 0 << 16 |
0 << 8 | ((ffs(CONFIG_DMAMEM_SZ_ALL) - 2) << 1) | 1 << 0);
#endif
#if defined(CONFIG_STM32F7_DCACHE_ON) || defined(CONFIG_STM32F7_ICACHE_ON)
stm32f7_envm_mpu_cfg(0, 0);
#endif
......@@ -270,6 +259,27 @@ void stm32f7_cache_sync_range(u32 s, u32 e)
}
#endif
#if defined(CONFIG_DMAMEM)
/*
* Configure the specified area as DMA memory
* - base_adr - start address of the area
* - size - size of the area
*/
void dmamem_init(unsigned long base_adr, unsigned long size)
{
#if defined(CONFIG_STM32F7_DCACHE_ON)
/*
* Configure DMAMEM as non-cacheable
*/
cortex_m3_mpu_set_region(MPU_RGN_SDRAM_NC,
base_adr | 1 << 4 | MPU_RGN_SDRAM_NC << 0,
0 << 28 | 3 << 24 |
1 << 19 | 0 << 18 | 0 << 17 | 0 << 16 |
0 << 8 | ((ffs(size) - 2) << 1) | 1 << 0);
#endif
}
#endif
/*
* SoC configuration code that cannot be put into drivers
*/
......
......@@ -644,6 +644,11 @@ ulong vfd_setmem (ulong);
/* $(CPU)/.../video.c */
ulong video_setmem (ulong);
#if defined(CONFIG_DMAMEM)
/* $(CPU)/.../<soc> */
void dmamem_init(unsigned long, unsigned long);
#endif
/* lib_$(ARCH)/cache.c */
void flush_cache (unsigned long, unsigned long);
void flush_dcache_range(unsigned long start, unsigned long stop);
......
......@@ -320,8 +320,8 @@
#ifdef CONFIG_LCD
#define CONFIG_DMAMEM_TAG
#if defined(CONFIG_DMAMEM_TAG)
#define CONFIG_DMAMEM
#if defined(CONFIG_DMAMEM)
/* Memory for framebuffer: 32-bit 480x272 */
#define CONFIG_DMAMEM_SZ_ALL 0x80000
#define CONFIG_DMAMEM_SZ_FB CONFIG_DMAMEM_SZ_ALL
......@@ -330,7 +330,7 @@
CONFIG_DMAMEM_SZ_ALL)
#define CONFIG_FB_ADDR CONFIG_DMAMEM_BASE
#endif /* CONFIG_DMAMEM_TAG */
#endif /* CONFIG_DMAMEM */
#define CONFIG_VIDEO_STM32F4_LTDC
#define CONFIG_STM32_LTDC_PIXCLK (9 * 1000 * 1000)
......
......@@ -126,8 +126,8 @@
* without DCACHE. So, pass DMAMEM tag always.
* Note, SZ_ALL must be power of 2 (to program MPU correctly)!
*/
#define CONFIG_DMAMEM_TAG
#if defined(CONFIG_DMAMEM_TAG)
#define CONFIG_DMAMEM
#if defined(CONFIG_DMAMEM)
# define CONFIG_DMAMEM_SZ_ALL (1 << 20) /* 1MB */
# define CONFIG_DMAMEM_SZ_FB (640 * 1024)
# define CONFIG_DMAMEM_BASE (CONFIG_SYS_RAM_BASE + \
......
......@@ -117,8 +117,8 @@
* without DCACHE. So, pass a DMAMEM tag to the kernel unconditionally.
* Note, SZ_ALL must be power of 2 (to program MPU correctly)!
*/
#define CONFIG_DMAMEM_TAG
#if defined(CONFIG_DMAMEM_TAG)
#define CONFIG_DMAMEM
#if defined(CONFIG_DMAMEM)
# define CONFIG_DMAMEM_SZ_ALL (1 << 20) /* 1MB */
# define CONFIG_DMAMEM_SZ_FB (640 * 1024)
# define CONFIG_DMAMEM_BASE (CONFIG_SYS_RAM_BASE + \
......
......@@ -54,6 +54,10 @@ int fdt_find_and_setprop(void *fdt, const char *node, const char *prop,
const void *val, int len, int create);
void fdt_fixup_qe_firmware(void *fdt);
#ifdef CONFIG_DMAMEM
void fdt_fixup_dmamem(void *fdt);
#endif
#ifdef CONFIG_HAS_FSL_DR_USB
void fdt_fixup_dr_usb(void *blob, bd_t *bd);
#else
......
......@@ -39,7 +39,7 @@ DECLARE_GLOBAL_DATA_PTR;
defined (CONFIG_REVISION_TAG) || \
defined (CONFIG_VFD) || \
defined (CONFIG_LCD) || \
defined (CONFIG_DMAMEM_TAG)
defined (CONFIG_DMAMEM)
static void setup_start_tag (bd_t *bd);
# ifdef CONFIG_SETUP_MEMORY_TAGS
......@@ -57,7 +57,7 @@ static void setup_end_tag (bd_t *bd);
static void setup_videolfb_tag (gd_t *gd);
# endif
# ifdef CONFIG_DMAMEM_TAG
# ifdef CONFIG_DMAMEM
static void setup_dmamem_tag (void);
# endif
......@@ -150,7 +150,7 @@ int do_bootm_linux(int flag, int argc, char *argv[], bootm_headers_t *images)
defined (CONFIG_REVISION_TAG) || \
defined (CONFIG_LCD) || \
defined (CONFIG_VFD) || \
defined (CONFIG_DMAMEM_TAG)
defined (CONFIG_DMAMEM)
setup_start_tag (bd);
#ifdef CONFIG_SERIAL_TAG
setup_serial_tag (&params);
......@@ -171,7 +171,7 @@ int do_bootm_linux(int flag, int argc, char *argv[], bootm_headers_t *images)
#if defined (CONFIG_SETUP_VIDEOLFB_TAG) && (defined (CONFIG_VFD) || defined (CONFIG_LCD))
setup_videolfb_tag ((gd_t *) gd);
#endif
#ifdef CONFIG_DMAMEM_TAG
#ifdef CONFIG_DMAMEM
setup_dmamem_tag();
#endif
setup_end_tag(bd);
......@@ -232,6 +232,9 @@ static int bootm_linux_fdt(int machid, bootm_headers_t *images)
fixup_memory_node(*of_flat_tree);
fdt_fixup_ethernet(*of_flat_tree);
#ifdef CONFIG_DMAMEM
fdt_fixup_dmamem(*of_flat_tree);
#endif
fdt_initrd(*of_flat_tree, *initrd_start, *initrd_end, 1);
......@@ -397,7 +400,7 @@ void setup_revision_tag(struct tag **in_params)
}
#endif /* CONFIG_REVISION_TAG */
#ifdef CONFIG_DMAMEM_TAG
#ifdef CONFIG_DMAMEM
void setup_dmamem_tag (void)
{
params->hdr.tag = ATAG_DMAMEM;
......@@ -405,6 +408,8 @@ void setup_dmamem_tag (void)
params->u.dmamem.base = CONFIG_DMAMEM_BASE;
params->u.dmamem.sz_all = CONFIG_DMAMEM_SZ_ALL;
params->u.dmamem.sz_fb = CONFIG_DMAMEM_SZ_FB;
dmamem_init(params->u.dmamem.base, params->u.dmamem.sz_all);
params = tag_next(params);
}
#endif
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment