Troy Kisky <[EMAIL PROTECTED]> writes:
> This adds IRAM allocation and free routines which
> will be used to fix audio underrun/overrun problems.
>
> Signed-off-by: Troy Kisky <[EMAIL PROTECTED]>
Thanks, pushing.
Kevin
> ---
> arch/arm/mach-davinci/Makefile | 2 +-
> arch/arm/mach-davinci/include/mach/edma.h | 3 +
> arch/arm/mach-davinci/iram.c | 58
> +++++++++++++++++++++++++++++
> 3 files changed, 62 insertions(+), 1 deletions(-)
> create mode 100755 arch/arm/mach-davinci/iram.c
>
> diff --git a/arch/arm/mach-davinci/Makefile b/arch/arm/mach-davinci/Makefile
> index 945ee80..7067e35 100644
> --- a/arch/arm/mach-davinci/Makefile
> +++ b/arch/arm/mach-davinci/Makefile
> @@ -5,7 +5,7 @@
>
> # Common objects
> obj-y := time.o irq.o clock.o serial.o io.o id.o
> psc.o \
> - gpio.o mux.o dma.o devices.o common.o usb.o
> + gpio.o mux.o dma.o devices.o common.o usb.o iram.o
>
> # Board specific
> obj-$(CONFIG_MACH_DAVINCI_EVM) += board-evm.o
> diff --git a/arch/arm/mach-davinci/include/mach/edma.h
> b/arch/arm/mach-davinci/include/mach/edma.h
> index df58b74..22cd795 100644
> --- a/arch/arm/mach-davinci/include/mach/edma.h
> +++ b/arch/arm/mach-davinci/include/mach/edma.h
> @@ -560,4 +560,7 @@ void davinci_free_dma(int lch);
> * DMA channel
> **/
> void davinci_dma_getposition(int lch, dma_addr_t *src, dma_addr_t *dst);
> +
> +int davinci_alloc_iram(unsigned size);
> +void davinci_free_iram(unsigned addr, unsigned size);
> #endif
> diff --git a/arch/arm/mach-davinci/iram.c b/arch/arm/mach-davinci/iram.c
> new file mode 100755
> index 0000000..f692216
> --- /dev/null
> +++ b/arch/arm/mach-davinci/iram.c
> @@ -0,0 +1,58 @@
> +/*
> + * linux/arch/arm/mach-davinci/iram.c
> + *
> + * DaVinci iram allocation/free
> + * Copyright (C) 2008 Boundary Devices.
> + *
> + * This program is free software; you can redistribute it and/or modify
> + * it under the terms of the GNU General Public License as published by
> + * the Free Software Foundation; either version 2 of the License, or
> + * (at your option) any later version.
> + */
> +#include <linux/module.h>
> +#include <linux/kernel.h>
> +#include <linux/init.h>
> +#include <mach/memory.h>
> +
> +/*
> + * 2**14 (16K) / 2**5 (32) = 2**9 (512 bytes per bit)
> + */
> +static atomic_t iram_mask;
> +int davinci_alloc_iram(unsigned size)
> +{
> + unsigned int mask;
> + unsigned int mask_prior;
> + unsigned addr;
> + unsigned cnt;
> + cnt = (size + 511) >> 9;
> + if (cnt >= 32)
> + return 0;
> + mask = atomic_read(&iram_mask);
> + do {
> + unsigned int need_mask = (1 << cnt) - 1;
> + addr = DAVINCI_IRAM_BASE;
> + while (mask & need_mask) {
> + if (need_mask & (1<<31))
> + return -ENOMEM;
> + need_mask <<= 1;
> + addr += 512;
> + }
> + mask_prior = mask;
> + mask = atomic_cmpxchg(&iram_mask, mask, mask | need_mask);
> + } while (mask != mask_prior);
> + return addr;
> +}
> +EXPORT_SYMBOL(davinci_alloc_iram);
> +
> +void davinci_free_iram(unsigned addr, unsigned size)
> +{
> + unsigned mask;
> + addr -= DAVINCI_IRAM_BASE;
> + addr >>= 9;
> + size = (size + 511) >> 9;
> + if ((size + addr) >= 32)
> + return;
> + mask = ((1 << size) - 1) << addr;
> + atomic_clear_mask(mask, (unsigned long *)&iram_mask.counter);
> +}
> +EXPORT_SYMBOL(davinci_free_iram);
> --
> 1.5.4
>
>
> _______________________________________________
> Davinci-linux-open-source mailing list
> [email protected]
> http://linux.davincidsp.com/mailman/listinfo/davinci-linux-open-source
_______________________________________________
Davinci-linux-open-source mailing list
[email protected]
http://linux.davincidsp.com/mailman/listinfo/davinci-linux-open-source