~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

TOMOYO Linux Cross Reference
Linux/arch/arm/mach-davinci/sram.c

Version: ~ [ linux-5.2-rc4 ] ~ [ linux-5.1.9 ] ~ [ linux-5.0.21 ] ~ [ linux-4.20.17 ] ~ [ linux-4.19.50 ] ~ [ linux-4.18.20 ] ~ [ linux-4.17.19 ] ~ [ linux-4.16.18 ] ~ [ linux-4.15.18 ] ~ [ linux-4.14.125 ] ~ [ linux-4.13.16 ] ~ [ linux-4.12.14 ] ~ [ linux-4.11.12 ] ~ [ linux-4.10.17 ] ~ [ linux-4.9.181 ] ~ [ linux-4.8.17 ] ~ [ linux-4.7.10 ] ~ [ linux-4.6.7 ] ~ [ linux-4.5.7 ] ~ [ linux-4.4.181 ] ~ [ linux-4.3.6 ] ~ [ linux-4.2.8 ] ~ [ linux-4.1.52 ] ~ [ linux-4.0.9 ] ~ [ linux-3.19.8 ] ~ [ linux-3.18.140 ] ~ [ linux-3.17.8 ] ~ [ linux-3.16.68 ] ~ [ linux-3.15.10 ] ~ [ linux-3.14.79 ] ~ [ linux-3.13.11 ] ~ [ linux-3.12.74 ] ~ [ linux-3.11.10 ] ~ [ linux-3.10.108 ] ~ [ linux-3.9.11 ] ~ [ linux-3.8.13 ] ~ [ linux-3.7.10 ] ~ [ linux-3.6.11 ] ~ [ linux-3.5.7 ] ~ [ linux-3.4.113 ] ~ [ linux-3.3.8 ] ~ [ linux-3.2.102 ] ~ [ linux-3.1.10 ] ~ [ linux-3.0.101 ] ~ [ linux-2.6.39.4 ] ~ [ linux-2.6.38.8 ] ~ [ linux-2.6.37.6 ] ~ [ linux-2.6.36.4 ] ~ [ linux-2.6.35.14 ] ~ [ linux-2.6.34.15 ] ~ [ linux-2.6.33.20 ] ~ [ linux-2.6.32.71 ] ~ [ linux-2.6.0 ] ~ [ linux-2.4.37.11 ] ~ [ unix-v6-master ] ~ [ ccs-tools-1.8.5 ] ~ [ policy-sample ] ~
Architecture: ~ [ i386 ] ~ [ alpha ] ~ [ m68k ] ~ [ mips ] ~ [ ppc ] ~ [ sparc ] ~ [ sparc64 ] ~

  1 /*
  2  * mach-davinci/sram.c - DaVinci simple SRAM allocator
  3  *
  4  * Copyright (C) 2009 David Brownell
  5  *
  6  * This program is free software; you can redistribute it and/or modify
  7  * it under the terms of the GNU General Public License as published by
  8  * the Free Software Foundation; either version 2 of the License, or
  9  * (at your option) any later version.
 10  */
 11 #include <linux/module.h>
 12 #include <linux/init.h>
 13 #include <linux/io.h>
 14 #include <linux/genalloc.h>
 15 
 16 #include <mach/common.h>
 17 #include "sram.h"
 18 
 19 static struct gen_pool *sram_pool;
 20 
 21 struct gen_pool *sram_get_gen_pool(void)
 22 {
 23         return sram_pool;
 24 }
 25 
 26 void *sram_alloc(size_t len, dma_addr_t *dma)
 27 {
 28         dma_addr_t dma_base = davinci_soc_info.sram_dma;
 29 
 30         if (dma)
 31                 *dma = 0;
 32         if (!sram_pool || (dma && !dma_base))
 33                 return NULL;
 34 
 35         return gen_pool_dma_alloc(sram_pool, len, dma);
 36 
 37 }
 38 EXPORT_SYMBOL(sram_alloc);
 39 
 40 void sram_free(void *addr, size_t len)
 41 {
 42         gen_pool_free(sram_pool, (unsigned long) addr, len);
 43 }
 44 EXPORT_SYMBOL(sram_free);
 45 
 46 
 47 /*
 48  * REVISIT This supports CPU and DMA access to/from SRAM, but it
 49  * doesn't (yet?) support some other notable uses of SRAM:  as TCM
 50  * for data and/or instructions; and holding code needed to enter
 51  * and exit suspend states (while DRAM can't be used).
 52  */
 53 static int __init sram_init(void)
 54 {
 55         phys_addr_t phys = davinci_soc_info.sram_dma;
 56         unsigned len = davinci_soc_info.sram_len;
 57         int status = 0;
 58         void __iomem *addr;
 59 
 60         if (len) {
 61                 len = min_t(unsigned, len, SRAM_SIZE);
 62                 sram_pool = gen_pool_create(ilog2(SRAM_GRANULARITY), -1);
 63                 if (!sram_pool)
 64                         status = -ENOMEM;
 65         }
 66 
 67         if (sram_pool) {
 68                 addr = ioremap(phys, len);
 69                 if (!addr)
 70                         return -ENOMEM;
 71                 status = gen_pool_add_virt(sram_pool, (unsigned long) addr,
 72                                            phys, len, -1);
 73                 if (status < 0)
 74                         iounmap(addr);
 75         }
 76 
 77         WARN_ON(status < 0);
 78         return status;
 79 }
 80 core_initcall(sram_init);
 81 
 82 

~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

kernel.org | git.kernel.org | LWN.net | Project Home | Wiki (Japanese) | Wiki (English) | SVN repository | Mail admin

Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.

osdn.jp