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
6 This driver so far only reads the core voltage.
8 Signed-off-by: John Crispin <blogic@openwrt.org>
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
15 --- a/arch/mips/lantiq/xway/Makefile
16 +++ b/arch/mips/lantiq/xway/Makefile
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
21 obj-$(CONFIG_XRX200_PHY_FW) += xrx200_phy_fw.o
23 +++ b/arch/mips/lantiq/xway/dcdc.c
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.
30 + * Copyright (C) 2012 John Crispin <blogic@openwrt.org>
31 + * Copyright (C) 2010 Sameer Ahmad, Lantiq GmbH
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>
40 +#include <lantiq_soc.h>
42 +/* Bias and regulator Setup Register */
43 +#define DCDC_BIAS_VREG0 0xa
44 +/* Bias and regulator Setup Register */
45 +#define DCDC_BIAS_VREG1 0xb
47 +#define dcdc_w8(x, y) ltq_w8((x), dcdc_membase + (y))
48 +#define dcdc_r8(x) ltq_r8(dcdc_membase + (x))
50 +static void __iomem *dcdc_membase;
52 +static int dcdc_probe(struct platform_device *pdev)
54 + struct resource *res;
56 + res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
58 + dev_err(&pdev->dev, "Failed to get resource\n");
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");
69 + dev_info(&pdev->dev, "Core Voltage : %d mV\n", dcdc_r8(DCDC_BIAS_VREG1) * 8);
74 +static const struct of_device_id dcdc_match[] = {
75 + { .compatible = "lantiq,dcdc-xrx200" },
78 +MODULE_DEVICE_TABLE(of, dcdc_match);
80 +static struct platform_driver dcdc_driver = {
81 + .probe = dcdc_probe,
83 + .name = "dcdc-xrx200",
84 + .owner = THIS_MODULE,
85 + .of_match_table = dcdc_match,
89 +int __init dcdc_init(void)
91 + int ret = platform_driver_register(&dcdc_driver);
94 + pr_info("dcdc: Error registering platform driver\n");
98 +arch_initcall(dcdc_init);