Path: blob/master/arch/sh/boards/mach-sdk7786/sram.c
15126 views
/*1* SDK7786 FPGA SRAM Support.2*3* Copyright (C) 2010 Paul Mundt4*5* This file is subject to the terms and conditions of the GNU General Public6* License. See the file "COPYING" in the main directory of this archive7* for more details.8*/9#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt1011#include <linux/init.h>12#include <linux/kernel.h>13#include <linux/types.h>14#include <linux/io.h>15#include <linux/string.h>16#include <mach/fpga.h>17#include <asm/sram.h>18#include <asm/sizes.h>1920static int __init fpga_sram_init(void)21{22unsigned long phys;23unsigned int area;24void __iomem *vaddr;25int ret;26u16 data;2728/* Enable FPGA SRAM */29data = fpga_read_reg(LCLASR);30data |= LCLASR_FRAMEN;31fpga_write_reg(data, LCLASR);3233/*34* FPGA_SEL determines the area mapping35*/36area = (data & LCLASR_FPGA_SEL_MASK) >> LCLASR_FPGA_SEL_SHIFT;37if (unlikely(area == LCLASR_AREA_MASK)) {38pr_err("FPGA memory unmapped.\n");39return -ENXIO;40}4142/*43* The memory itself occupies a 2KiB range at the top of the area44* immediately below the system registers.45*/46phys = (area << 26) + SZ_64M - SZ_4K;4748/*49* The FPGA SRAM resides in translatable physical space, so set50* up a mapping prior to inserting it in to the pool.51*/52vaddr = ioremap(phys, SZ_2K);53if (unlikely(!vaddr)) {54pr_err("Failed remapping FPGA memory.\n");55return -ENXIO;56}5758pr_info("Adding %dKiB of FPGA memory at 0x%08lx-0x%08lx "59"(area %d) to pool.\n",60SZ_2K >> 10, phys, phys + SZ_2K - 1, area);6162ret = gen_pool_add(sram_pool, (unsigned long)vaddr, SZ_2K, -1);63if (unlikely(ret < 0)) {64pr_err("Failed adding memory\n");65iounmap(vaddr);66return ret;67}6869return 0;70}71postcore_initcall(fpga_sram_init);727374