blob: ffaa286a71e17328c974cf077a89a5b8e9955ccd [file] [log] [blame]
Peter De Schrijver26fe6812012-02-10 01:47:44 +02001/*
2 * arch/arm/mach-tegra/flowctrl.c
3 *
4 * functions and macros to control the flowcontroller
5 *
6 * Copyright (c) 2010-2012, NVIDIA Corporation. All rights reserved.
7 *
8 * This program is free software; you can redistribute it and/or modify it
9 * under the terms and conditions of the GNU General Public License,
10 * version 2, as published by the Free Software Foundation.
11 *
12 * This program is distributed in the hope that it will be useful, but WITHOUT
13 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
14 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
15 * more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program. If not, see <http://www.gnu.org/licenses/>.
19 */
20
21#include <linux/init.h>
22#include <linux/kernel.h>
23#include <linux/io.h>
24
Peter De Schrijver26fe6812012-02-10 01:47:44 +020025#include "flowctrl.h"
Stephen Warren2be39c02012-10-04 14:24:09 -060026#include "iomap.h"
Peter De Schrijver26fe6812012-02-10 01:47:44 +020027
28u8 flowctrl_offset_halt_cpu[] = {
29 FLOW_CTRL_HALT_CPU0_EVENTS,
30 FLOW_CTRL_HALT_CPU1_EVENTS,
31 FLOW_CTRL_HALT_CPU1_EVENTS + 8,
32 FLOW_CTRL_HALT_CPU1_EVENTS + 16,
33};
34
35u8 flowctrl_offset_cpu_csr[] = {
36 FLOW_CTRL_CPU0_CSR,
37 FLOW_CTRL_CPU1_CSR,
38 FLOW_CTRL_CPU1_CSR + 8,
39 FLOW_CTRL_CPU1_CSR + 16,
40};
41
42static void flowctrl_update(u8 offset, u32 value)
43{
44 void __iomem *addr = IO_ADDRESS(TEGRA_FLOW_CTRL_BASE) + offset;
45
46 writel(value, addr);
47
48 /* ensure the update has reached the flow controller */
49 wmb();
50 readl_relaxed(addr);
51}
52
53void flowctrl_write_cpu_csr(unsigned int cpuid, u32 value)
54{
Peter De Schrijver97e7abc2012-05-14 13:27:09 +030055 return flowctrl_update(flowctrl_offset_cpu_csr[cpuid], value);
Peter De Schrijver26fe6812012-02-10 01:47:44 +020056}
57
58void flowctrl_write_cpu_halt(unsigned int cpuid, u32 value)
59{
Peter De Schrijver97e7abc2012-05-14 13:27:09 +030060 return flowctrl_update(flowctrl_offset_halt_cpu[cpuid], value);
Peter De Schrijver26fe6812012-02-10 01:47:44 +020061}