Back to home page

OSCL-LXR

 
 

    


0001 // SPDX-License-Identifier: GPL-2.0-only
0002 /*
0003  *  Copyright (C) 2000-2003 Deep Blue Solutions Ltd
0004  */
0005 #include <linux/types.h>
0006 #include <linux/kernel.h>
0007 #include <linux/init.h>
0008 #include <linux/device.h>
0009 #include <linux/export.h>
0010 #include <linux/spinlock.h>
0011 #include <linux/interrupt.h>
0012 #include <linux/irq.h>
0013 #include <linux/memblock.h>
0014 #include <linux/sched.h>
0015 #include <linux/smp.h>
0016 #include <linux/amba/bus.h>
0017 #include <linux/amba/serial.h>
0018 #include <linux/io.h>
0019 #include <linux/stat.h>
0020 #include <linux/of.h>
0021 #include <linux/of_address.h>
0022 #include <linux/pgtable.h>
0023 
0024 #include <asm/mach-types.h>
0025 #include <asm/mach/time.h>
0026 
0027 #include "integrator-hardware.h"
0028 #include "integrator-cm.h"
0029 #include "integrator.h"
0030 
0031 static DEFINE_RAW_SPINLOCK(cm_lock);
0032 static void __iomem *cm_base;
0033 
0034 /**
0035  * cm_get - get the value from the CM_CTRL register
0036  */
0037 u32 cm_get(void)
0038 {
0039     return readl(cm_base + INTEGRATOR_HDR_CTRL_OFFSET);
0040 }
0041 
0042 /**
0043  * cm_control - update the CM_CTRL register.
0044  * @mask: bits to change
0045  * @set: bits to set
0046  */
0047 void cm_control(u32 mask, u32 set)
0048 {
0049     unsigned long flags;
0050     u32 val;
0051 
0052     raw_spin_lock_irqsave(&cm_lock, flags);
0053     val = readl(cm_base + INTEGRATOR_HDR_CTRL_OFFSET) & ~mask;
0054     writel(val | set, cm_base + INTEGRATOR_HDR_CTRL_OFFSET);
0055     raw_spin_unlock_irqrestore(&cm_lock, flags);
0056 }
0057 
0058 void cm_clear_irqs(void)
0059 {
0060     /* disable core module IRQs */
0061     writel(0xffffffffU, cm_base + INTEGRATOR_HDR_IC_OFFSET +
0062         IRQ_ENABLE_CLEAR);
0063 }
0064 
0065 static const struct of_device_id cm_match[] = {
0066     { .compatible = "arm,core-module-integrator"},
0067     { },
0068 };
0069 
0070 void cm_init(void)
0071 {
0072     struct device_node *cm = of_find_matching_node(NULL, cm_match);
0073 
0074     if (!cm) {
0075         pr_crit("no core module node found in device tree\n");
0076         return;
0077     }
0078     cm_base = of_iomap(cm, 0);
0079     if (!cm_base) {
0080         pr_crit("could not remap core module\n");
0081         return;
0082     }
0083     cm_clear_irqs();
0084 }
0085 
0086 /*
0087  * We need to stop things allocating the low memory; ideally we need a
0088  * better implementation of GFP_DMA which does not assume that DMA-able
0089  * memory starts at zero.
0090  */
0091 void __init integrator_reserve(void)
0092 {
0093     memblock_reserve(PHYS_OFFSET, __pa(swapper_pg_dir) - PHYS_OFFSET);
0094 }