EDAC: i7core, sb_edac: Don't return NOTIFY_BAD from mce_decoder callback
[linux/fpc-iii.git] / drivers / soc / samsung / exynos-pmu.c
blob0acdfd82e7510189bc8bb4a254c653667d012e89
1 /*
2 * Copyright (c) 2011-2014 Samsung Electronics Co., Ltd.
3 * http://www.samsung.com/
5 * EXYNOS - CPU PMU(Power Management Unit) support
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License version 2 as
9 * published by the Free Software Foundation.
12 #include <linux/of.h>
13 #include <linux/of_address.h>
14 #include <linux/platform_device.h>
15 #include <linux/delay.h>
17 #include <linux/soc/samsung/exynos-regs-pmu.h>
18 #include <linux/soc/samsung/exynos-pmu.h>
20 #include "exynos-pmu.h"
22 struct exynos_pmu_context {
23 struct device *dev;
24 const struct exynos_pmu_data *pmu_data;
27 void __iomem *pmu_base_addr;
28 static struct exynos_pmu_context *pmu_context;
30 void pmu_raw_writel(u32 val, u32 offset)
32 writel_relaxed(val, pmu_base_addr + offset);
35 u32 pmu_raw_readl(u32 offset)
37 return readl_relaxed(pmu_base_addr + offset);
40 void exynos_sys_powerdown_conf(enum sys_powerdown mode)
42 unsigned int i;
43 const struct exynos_pmu_data *pmu_data;
45 if (!pmu_context)
46 return;
48 pmu_data = pmu_context->pmu_data;
50 if (pmu_data->powerdown_conf)
51 pmu_data->powerdown_conf(mode);
53 if (pmu_data->pmu_config) {
54 for (i = 0; (pmu_data->pmu_config[i].offset != PMU_TABLE_END); i++)
55 pmu_raw_writel(pmu_data->pmu_config[i].val[mode],
56 pmu_data->pmu_config[i].offset);
59 if (pmu_data->powerdown_conf_extra)
60 pmu_data->powerdown_conf_extra(mode);
62 if (pmu_data->pmu_config_extra) {
63 for (i = 0; pmu_data->pmu_config_extra[i].offset != PMU_TABLE_END; i++)
64 pmu_raw_writel(pmu_data->pmu_config_extra[i].val[mode],
65 pmu_data->pmu_config_extra[i].offset);
70 * PMU platform driver and devicetree bindings.
72 static const struct of_device_id exynos_pmu_of_device_ids[] = {
74 .compatible = "samsung,exynos3250-pmu",
75 .data = &exynos3250_pmu_data,
76 }, {
77 .compatible = "samsung,exynos4210-pmu",
78 .data = &exynos4210_pmu_data,
79 }, {
80 .compatible = "samsung,exynos4212-pmu",
81 .data = &exynos4212_pmu_data,
82 }, {
83 .compatible = "samsung,exynos4412-pmu",
84 .data = &exynos4412_pmu_data,
85 }, {
86 .compatible = "samsung,exynos5250-pmu",
87 .data = &exynos5250_pmu_data,
88 }, {
89 .compatible = "samsung,exynos5420-pmu",
90 .data = &exynos5420_pmu_data,
92 { /*sentinel*/ },
95 static int exynos_pmu_probe(struct platform_device *pdev)
97 const struct of_device_id *match;
98 struct device *dev = &pdev->dev;
99 struct resource *res;
101 res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
102 pmu_base_addr = devm_ioremap_resource(dev, res);
103 if (IS_ERR(pmu_base_addr))
104 return PTR_ERR(pmu_base_addr);
106 pmu_context = devm_kzalloc(&pdev->dev,
107 sizeof(struct exynos_pmu_context),
108 GFP_KERNEL);
109 if (!pmu_context) {
110 dev_err(dev, "Cannot allocate memory.\n");
111 return -ENOMEM;
113 pmu_context->dev = dev;
115 match = of_match_node(exynos_pmu_of_device_ids, dev->of_node);
117 pmu_context->pmu_data = match->data;
119 if (pmu_context->pmu_data->pmu_init)
120 pmu_context->pmu_data->pmu_init();
122 platform_set_drvdata(pdev, pmu_context);
124 dev_dbg(dev, "Exynos PMU Driver probe done\n");
125 return 0;
128 static struct platform_driver exynos_pmu_driver = {
129 .driver = {
130 .name = "exynos-pmu",
131 .of_match_table = exynos_pmu_of_device_ids,
133 .probe = exynos_pmu_probe,
136 static int __init exynos_pmu_init(void)
138 return platform_driver_register(&exynos_pmu_driver);
141 postcore_initcall(exynos_pmu_init);