kernel: update linux 3.8 to 3.8.3
[openwrt/staging/mkresin.git] / target / linux / lantiq / patches-3.8 / 0031-MIPS-lantiq-adds-minimal-dcdc-driver.patch
1 From 1f95983593d5b6634c13ead8f923237484dc611e Mon Sep 17 00:00:00 2001
2 From: John Crispin <blogic@openwrt.org>
3 Date: Wed, 5 Dec 2012 17:38:48 +0100
4 Subject: [PATCH 31/40] MIPS: lantiq: adds minimal dcdc driver
5
6 This driver so far only reads the core voltage.
7
8 Signed-off-by: John Crispin <blogic@openwrt.org>
9 ---
10 arch/mips/lantiq/xway/Makefile | 2 +-
11 arch/mips/lantiq/xway/dcdc.c | 74 ++++++++++++++++++++++++++++++++++++++++
12 2 files changed, 75 insertions(+), 1 deletion(-)
13 create mode 100644 arch/mips/lantiq/xway/dcdc.c
14
15 --- a/arch/mips/lantiq/xway/Makefile
16 +++ b/arch/mips/lantiq/xway/Makefile
17 @@ -1,3 +1,3 @@
18 -obj-y := prom.o sysctrl.o clk.o reset.o dma.o gptu.o
19 +obj-y := prom.o sysctrl.o clk.o reset.o dma.o gptu.o dcdc.o
20
21 obj-$(CONFIG_XRX200_PHY_FW) += xrx200_phy_fw.o
22 --- /dev/null
23 +++ b/arch/mips/lantiq/xway/dcdc.c
24 @@ -0,0 +1,74 @@
25 +/*
26 + * This program is free software; you can redistribute it and/or modify it
27 + * under the terms of the GNU General Public License version 2 as published
28 + * by the Free Software Foundation.
29 + *
30 + * Copyright (C) 2012 John Crispin <blogic@openwrt.org>
31 + * Copyright (C) 2010 Sameer Ahmad, Lantiq GmbH
32 + */
33 +
34 +#include <linux/interrupt.h>
35 +#include <linux/ioport.h>
36 +#include <linux/module.h>
37 +#include <linux/of_platform.h>
38 +#include <linux/of_irq.h>
39 +
40 +#include <lantiq_soc.h>
41 +
42 +/* Bias and regulator Setup Register */
43 +#define DCDC_BIAS_VREG0 0xa
44 +/* Bias and regulator Setup Register */
45 +#define DCDC_BIAS_VREG1 0xb
46 +
47 +#define dcdc_w8(x, y) ltq_w8((x), dcdc_membase + (y))
48 +#define dcdc_r8(x) ltq_r8(dcdc_membase + (x))
49 +
50 +static void __iomem *dcdc_membase;
51 +
52 +static int dcdc_probe(struct platform_device *pdev)
53 +{
54 + struct resource *res;
55 +
56 + res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
57 + if (!res) {
58 + dev_err(&pdev->dev, "Failed to get resource\n");
59 + return -ENOMEM;
60 + }
61 +
62 + /* remap dcdc register range */
63 + dcdc_membase = devm_request_and_ioremap(&pdev->dev, res);
64 + if (!dcdc_membase) {
65 + dev_err(&pdev->dev, "Failed to remap resource\n");
66 + return -ENOMEM;
67 + }
68 +
69 + dev_info(&pdev->dev, "Core Voltage : %d mV\n", dcdc_r8(DCDC_BIAS_VREG1) * 8);
70 +
71 + return 0;
72 +}
73 +
74 +static const struct of_device_id dcdc_match[] = {
75 + { .compatible = "lantiq,dcdc-xrx200" },
76 + {},
77 +};
78 +MODULE_DEVICE_TABLE(of, dcdc_match);
79 +
80 +static struct platform_driver dcdc_driver = {
81 + .probe = dcdc_probe,
82 + .driver = {
83 + .name = "dcdc-xrx200",
84 + .owner = THIS_MODULE,
85 + .of_match_table = dcdc_match,
86 + },
87 +};
88 +
89 +int __init dcdc_init(void)
90 +{
91 + int ret = platform_driver_register(&dcdc_driver);
92 +
93 + if (ret)
94 + pr_info("dcdc: Error registering platform driver\n");
95 + return ret;
96 +}
97 +
98 +arch_initcall(dcdc_init);