lantiq: add v3.10 patches
[openwrt/svn-archive/archive.git] / target / linux / lantiq / patches-3.10 / 0002-MIPS-lantiq-adds-minimal-dcdc-driver.patch
1 From 82a678435e9937dc8a7cb801f476e340fcfbc23e Mon Sep 17 00:00:00 2001
2 From: John Crispin <blogic@openwrt.org>
3 Date: Thu, 8 Aug 2013 14:02:23 +0200
4 Subject: [PATCH 02/34] 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 Acked-by: John Crispin <blogic@openwrt.org>
11 Patchwork: http://patchwork.linux-mips.org/patch/5677/
12 ---
13 arch/mips/lantiq/xway/Makefile | 2 +-
14 arch/mips/lantiq/xway/dcdc.c | 63 ++++++++++++++++++++++++++++++++++++++++
15 2 files changed, 64 insertions(+), 1 deletion(-)
16 create mode 100644 arch/mips/lantiq/xway/dcdc.c
17
18 diff --git a/arch/mips/lantiq/xway/Makefile b/arch/mips/lantiq/xway/Makefile
19 index 7a13660..087497d 100644
20 --- a/arch/mips/lantiq/xway/Makefile
21 +++ b/arch/mips/lantiq/xway/Makefile
22 @@ -1,3 +1,3 @@
23 -obj-y := prom.o sysctrl.o clk.o reset.o dma.o gptu.o
24 +obj-y := prom.o sysctrl.o clk.o reset.o dma.o gptu.o dcdc.o
25
26 obj-$(CONFIG_XRX200_PHY_FW) += xrx200_phy_fw.o
27 diff --git a/arch/mips/lantiq/xway/dcdc.c b/arch/mips/lantiq/xway/dcdc.c
28 new file mode 100644
29 index 0000000..7688ac0
30 --- /dev/null
31 +++ b/arch/mips/lantiq/xway/dcdc.c
32 @@ -0,0 +1,63 @@
33 +/*
34 + * This program is free software; you can redistribute it and/or modify it
35 + * under the terms of the GNU General Public License version 2 as published
36 + * by the Free Software Foundation.
37 + *
38 + * Copyright (C) 2012 John Crispin <blogic@openwrt.org>
39 + * Copyright (C) 2010 Sameer Ahmad, Lantiq GmbH
40 + */
41 +
42 +#include <linux/ioport.h>
43 +#include <linux/of_platform.h>
44 +
45 +#include <lantiq_soc.h>
46 +
47 +/* Bias and regulator Setup Register */
48 +#define DCDC_BIAS_VREG0 0xa
49 +/* Bias and regulator Setup Register */
50 +#define DCDC_BIAS_VREG1 0xb
51 +
52 +#define dcdc_w8(x, y) ltq_w8((x), dcdc_membase + (y))
53 +#define dcdc_r8(x) ltq_r8(dcdc_membase + (x))
54 +
55 +static void __iomem *dcdc_membase;
56 +
57 +static int dcdc_probe(struct platform_device *pdev)
58 +{
59 + struct resource *res;
60 +
61 + res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
62 + dcdc_membase = devm_ioremap_resource(&pdev->dev, res);
63 + if (IS_ERR(dcdc_membase))
64 + return PTR_ERR(dcdc_membase);
65 +
66 + dev_info(&pdev->dev, "Core Voltage : %d mV\n",
67 + dcdc_r8(DCDC_BIAS_VREG1) * 8);
68 +
69 + return 0;
70 +}
71 +
72 +static const struct of_device_id dcdc_match[] = {
73 + { .compatible = "lantiq,dcdc-xrx200" },
74 + {},
75 +};
76 +
77 +static struct platform_driver dcdc_driver = {
78 + .probe = dcdc_probe,
79 + .driver = {
80 + .name = "dcdc-xrx200",
81 + .owner = THIS_MODULE,
82 + .of_match_table = dcdc_match,
83 + },
84 +};
85 +
86 +int __init dcdc_init(void)
87 +{
88 + int ret = platform_driver_register(&dcdc_driver);
89 +
90 + if (ret)
91 + pr_info("dcdc: Error registering platform driver\n");
92 + return ret;
93 +}
94 +
95 +arch_initcall(dcdc_init);
96 --
97 1.7.10.4
98