imx6: update 3.10 patches
[openwrt.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 --- a/arch/mips/lantiq/xway/Makefile
19 +++ b/arch/mips/lantiq/xway/Makefile
20 @@ -1,3 +1,3 @@
21 -obj-y := prom.o sysctrl.o clk.o reset.o dma.o gptu.o
22 +obj-y := prom.o sysctrl.o clk.o reset.o dma.o gptu.o dcdc.o
23  
24  obj-$(CONFIG_XRX200_PHY_FW) += xrx200_phy_fw.o
25 --- /dev/null
26 +++ b/arch/mips/lantiq/xway/dcdc.c
27 @@ -0,0 +1,63 @@
28 +/*
29 + *  This program is free software; you can redistribute it and/or modify it
30 + *  under the terms of the GNU General Public License version 2 as published
31 + *  by the Free Software Foundation.
32 + *
33 + *  Copyright (C) 2012 John Crispin <blogic@openwrt.org>
34 + *  Copyright (C) 2010 Sameer Ahmad, Lantiq GmbH
35 + */
36 +
37 +#include <linux/ioport.h>
38 +#include <linux/of_platform.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 +       dcdc_membase = devm_ioremap_resource(&pdev->dev, res);
58 +       if (IS_ERR(dcdc_membase))
59 +               return PTR_ERR(dcdc_membase);
60 +
61 +       dev_info(&pdev->dev, "Core Voltage : %d mV\n",
62 +               dcdc_r8(DCDC_BIAS_VREG1) * 8);
63 +
64 +       return 0;
65 +}
66 +
67 +static const struct of_device_id dcdc_match[] = {
68 +       { .compatible = "lantiq,dcdc-xrx200" },
69 +       {},
70 +};
71 +
72 +static struct platform_driver dcdc_driver = {
73 +       .probe = dcdc_probe,
74 +       .driver = {
75 +               .name = "dcdc-xrx200",
76 +               .owner = THIS_MODULE,
77 +               .of_match_table = dcdc_match,
78 +       },
79 +};
80 +
81 +int __init dcdc_init(void)
82 +{
83 +       int ret = platform_driver_register(&dcdc_driver);
84 +
85 +       if (ret)
86 +               pr_info("dcdc: Error registering platform driver\n");
87 +       return ret;
88 +}
89 +
90 +arch_initcall(dcdc_init);