]> git.proxmox.com Git - mirror_ubuntu-bionic-kernel.git/blame - arch/arm/mach-integrator/core.c
ARM: dts: Add keep-power-in-suspend to WiFi SDIO node for Peach Boards
[mirror_ubuntu-bionic-kernel.git] / arch / arm / mach-integrator / core.c
CommitLineData
1da177e4
LT
1/*
2 * linux/arch/arm/mach-integrator/core.c
3 *
4 * Copyright (C) 2000-2003 Deep Blue Solutions Ltd
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 version 2, as
8 * published by the Free Software Foundation.
9 */
10#include <linux/types.h>
11#include <linux/kernel.h>
12#include <linux/init.h>
13#include <linux/device.h>
b434f5c9 14#include <linux/export.h>
1da177e4
LT
15#include <linux/spinlock.h>
16#include <linux/interrupt.h>
a03d4d27 17#include <linux/irq.h>
8d717a52 18#include <linux/memblock.h>
1da177e4 19#include <linux/sched.h>
20cf33ea 20#include <linux/smp.h>
a62c80e5 21#include <linux/amba/bus.h>
fbb18a27 22#include <linux/amba/serial.h>
fced80c7 23#include <linux/io.h>
e67ae6be 24#include <linux/stat.h>
bb4dbefe
LW
25#include <linux/of.h>
26#include <linux/of_address.h>
1da177e4 27
ee35887e 28#include <asm/mach-types.h>
1da177e4 29#include <asm/mach/time.h>
98c672cf 30#include <asm/pgtable.h>
1da177e4 31
1b1ef755 32#include "hardware.h"
bb4dbefe 33#include "cm.h"
4672cddf
LW
34#include "common.h"
35
bd31b859 36static DEFINE_RAW_SPINLOCK(cm_lock);
bb4dbefe 37static void __iomem *cm_base;
1da177e4 38
fb61f862
LW
39/**
40 * cm_get - get the value from the CM_CTRL register
41 */
42u32 cm_get(void)
43{
44 return readl(cm_base + INTEGRATOR_HDR_CTRL_OFFSET);
45}
46
1da177e4
LT
47/**
48 * cm_control - update the CM_CTRL register.
49 * @mask: bits to change
50 * @set: bits to set
51 */
52void cm_control(u32 mask, u32 set)
53{
54 unsigned long flags;
55 u32 val;
56
bd31b859 57 raw_spin_lock_irqsave(&cm_lock, flags);
bb4dbefe
LW
58 val = readl(cm_base + INTEGRATOR_HDR_CTRL_OFFSET) & ~mask;
59 writel(val | set, cm_base + INTEGRATOR_HDR_CTRL_OFFSET);
bd31b859 60 raw_spin_unlock_irqrestore(&cm_lock, flags);
1da177e4
LT
61}
62
bb4dbefe
LW
63void cm_clear_irqs(void)
64{
65 /* disable core module IRQs */
66 writel(0xffffffffU, cm_base + INTEGRATOR_HDR_IC_OFFSET +
67 IRQ_ENABLE_CLEAR);
68}
69
70static const struct of_device_id cm_match[] = {
71 { .compatible = "arm,core-module-integrator"},
72 { },
73};
74
75void cm_init(void)
76{
77 struct device_node *cm = of_find_matching_node(NULL, cm_match);
bb4dbefe
LW
78
79 if (!cm) {
80 pr_crit("no core module node found in device tree\n");
81 return;
82 }
83 cm_base = of_iomap(cm, 0);
84 if (!cm_base) {
85 pr_crit("could not remap core module\n");
86 return;
87 }
88 cm_clear_irqs();
bb4dbefe 89}
98c672cf
RK
90
91/*
92 * We need to stop things allocating the low memory; ideally we need a
93 * better implementation of GFP_DMA which does not assume that DMA-able
94 * memory starts at zero.
95 */
96void __init integrator_reserve(void)
97{
8d717a52 98 memblock_reserve(PHYS_OFFSET, __pa(swapper_pg_dir) - PHYS_OFFSET);
98c672cf 99}