[U-Boot] [PATCH v4 1/7] arm: add MMU/D-Cache support for Faraday cores
Albert ARIBAUD
albert.u.boot at aribaud.net
Mon Jun 10 19:59:02 CEST 2013
Hi Kuo-Jung,
On Tue, 7 May 2013 14:25:07 +0800, Kuo-Jung Su <dantesu at gmail.com>
wrote:
> diff --git a/arch/arm/include/asm/dma-mapping.h b/arch/arm/include/asm/dma-mapping.h
> index 5bbb0a0..5a13af5 100644
> --- a/arch/arm/include/asm/dma-mapping.h
> +++ b/arch/arm/include/asm/dma-mapping.h
> @@ -3,6 +3,9 @@
> * Stelian Pop <stelian at popies.net>
> * Lead Tech Design <www.leadtechdesign.com>
> *
> + * (C) Copyright 2010
> + * Dante Su <dantesu at faraday-tech.com>
Fix Copyright notices (dates) throughout the patch (and series as
needed).
> * See file CREDITS for list of people who contributed to this
> * project.
> *
> @@ -24,22 +27,76 @@
> #ifndef __ASM_ARM_DMA_MAPPING_H
> #define __ASM_ARM_DMA_MAPPING_H
>
> +#if defined(CONFIG_FARADAY) && !defined(CONFIG_SYS_DCACHE_OFF)
> +#include <asm/u-boot.h>
> +#include <asm/global_data.h>
> +#include <asm/io.h>
> +#include <malloc.h>
> +
> +DECLARE_GLOBAL_DATA_PTR;
> +#endif /* CONFIG_FARADAY && !CONFIG_SYS_DCACHE_OFF */
> +
> enum dma_data_direction {
> DMA_BIDIRECTIONAL = 0,
> DMA_TO_DEVICE = 1,
> DMA_FROM_DEVICE = 2,
> };
>
> -static void *dma_alloc_coherent(size_t len, unsigned long *handle)
> +static inline void *dma_alloc_coherent(size_t len, unsigned long *handle)
> {
> - *handle = (unsigned long)malloc(len);
> +#if defined(CONFIG_FARADAY) && !defined(CONFIG_SYS_DCACHE_OFF)
> + void *map, *va = memalign(ARCH_DMA_MINALIGN, len);
> +
> + if (va && gd->arch.cpu_mmu) {
> + invalidate_dcache_range((ulong)va, (ulong)va + len);
> + map = map_physmem((phys_addr_t)va, len, MAP_NOCACHE);
> + if (!map)
> + free(va);
> + va = map;
> + }
> +
> + if (handle)
> + *handle = virt_to_phys(va);
> +
> + return va;
> +#else /* CONFIG_FARADAY && !CONFIG_SYS_DCACHE_OFF */
> + *handle = (unsigned long)memalign(ARCH_DMA_MINALIGN, len);
> return (void *)*handle;
This is not identical to what the code was before the patch. Why the
difference?
> 1.7.9.5
Amicalement,
--
Albert.
More information about the U-Boot
mailing list