Tony Prisk | 86cc0ef | 2012-07-19 03:42:19 +1200 | [diff] [blame] | 1 | /* linux/arch/arm/mach-vt8500/restart.c |
| 2 | * |
| 3 | * Copyright (C) 2012 Tony Prisk <linux@prisktech.co.nz> |
| 4 | * |
| 5 | * This software is licensed under the terms of the GNU General Public |
| 6 | * License version 2, as published by the Free Software Foundation, and |
| 7 | * may be copied, distributed, and modified under those terms. |
| 8 | * |
| 9 | * This program is distributed in the hope that it will be useful, |
| 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 12 | * GNU General Public License for more details. |
| 13 | * |
| 14 | */ |
| 15 | #include <asm/io.h> |
| 16 | #include <linux/of.h> |
| 17 | #include <linux/of_address.h> |
| 18 | |
| 19 | #define LEGACY_PMC_BASE 0xD8130000 |
| 20 | #define WMT_PRIZM_PMSR_REG 0x60 |
| 21 | |
| 22 | static void __iomem *pmc_base; |
| 23 | |
| 24 | void wmt_setup_restart(void) |
| 25 | { |
| 26 | struct device_node *np; |
| 27 | |
| 28 | /* |
| 29 | * Check if Power Mgmt Controller node is present in device tree. If no |
| 30 | * device tree node, use the legacy PMSR value (valid for all current |
| 31 | * SoCs). |
| 32 | */ |
| 33 | np = of_find_compatible_node(NULL, NULL, "wmt,prizm-pmc"); |
| 34 | if (np) { |
| 35 | pmc_base = of_iomap(np, 0); |
| 36 | |
| 37 | if (!pmc_base) |
| 38 | pr_err("%s:of_iomap(pmc) failed\n", __func__); |
| 39 | |
| 40 | of_node_put(np); |
| 41 | } else { |
| 42 | pmc_base = ioremap(LEGACY_PMC_BASE, 0x1000); |
| 43 | if (!pmc_base) { |
| 44 | pr_err("%s:ioremap(rstc) failed\n", __func__); |
| 45 | return; |
| 46 | } |
| 47 | } |
| 48 | } |
| 49 | |
| 50 | void wmt_restart(char mode, const char *cmd) |
| 51 | { |
| 52 | if (pmc_base) |
| 53 | writel(1, pmc_base + WMT_PRIZM_PMSR_REG); |
| 54 | } |