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

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

Version: ~ [ linux-6.11.5 ] ~ [ linux-6.10.14 ] ~ [ linux-6.9.12 ] ~ [ linux-6.8.12 ] ~ [ linux-6.7.12 ] ~ [ linux-6.6.58 ] ~ [ linux-6.5.13 ] ~ [ linux-6.4.16 ] ~ [ linux-6.3.13 ] ~ [ linux-6.2.16 ] ~ [ linux-6.1.114 ] ~ [ linux-6.0.19 ] ~ [ linux-5.19.17 ] ~ [ linux-5.18.19 ] ~ [ linux-5.17.15 ] ~ [ linux-5.16.20 ] ~ [ linux-5.15.169 ] ~ [ linux-5.14.21 ] ~ [ linux-5.13.19 ] ~ [ linux-5.12.19 ] ~ [ linux-5.11.22 ] ~ [ linux-5.10.228 ] ~ [ linux-5.9.16 ] ~ [ linux-5.8.18 ] ~ [ linux-5.7.19 ] ~ [ linux-5.6.19 ] ~ [ linux-5.5.19 ] ~ [ linux-5.4.284 ] ~ [ linux-5.3.18 ] ~ [ linux-5.2.21 ] ~ [ linux-5.1.21 ] ~ [ linux-5.0.21 ] ~ [ linux-4.20.17 ] ~ [ linux-4.19.322 ] ~ [ linux-4.18.20 ] ~ [ linux-4.17.19 ] ~ [ linux-4.16.18 ] ~ [ linux-4.15.18 ] ~ [ linux-4.14.336 ] ~ [ linux-4.13.16 ] ~ [ linux-4.12.14 ] ~ [ linux-4.11.12 ] ~ [ linux-4.10.17 ] ~ [ linux-4.9.337 ] ~ [ linux-4.4.302 ] ~ [ linux-3.10.108 ] ~ [ linux-2.6.32.71 ] ~ [ linux-2.6.0 ] ~ [ linux-2.4.37.11 ] ~ [ unix-v6-master ] ~ [ ccs-tools-1.8.9 ] ~ [ policy-sample ] ~
Architecture: ~ [ i386 ] ~ [ alpha ] ~ [ m68k ] ~ [ mips ] ~ [ ppc ] ~ [ sparc ] ~ [ sparc64 ] ~

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

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

kernel.org | git.kernel.org | LWN.net | Project Home | 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.

sflogo.php