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
6 This driver so far only reads the core voltage.
8 Signed-off-by: John Crispin <blogic@openwrt.org>
10 Acked-by: John Crispin <blogic@openwrt.org>
11 Patchwork: http://patchwork.linux-mips.org/patch/5677/
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
18 --- a/arch/mips/lantiq/xway/Makefile
19 +++ b/arch/mips/lantiq/xway/Makefile
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
24 obj-$(CONFIG_XRX200_PHY_FW) += xrx200_phy_fw.o
26 +++ b/arch/mips/lantiq/xway/dcdc.c
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.
33 + * Copyright (C) 2012 John Crispin <blogic@openwrt.org>
34 + * Copyright (C) 2010 Sameer Ahmad, Lantiq GmbH
37 +#include <linux/ioport.h>
38 +#include <linux/of_platform.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);
57 + dcdc_membase = devm_ioremap_resource(&pdev->dev, res);
58 + if (IS_ERR(dcdc_membase))
59 + return PTR_ERR(dcdc_membase);
61 + dev_info(&pdev->dev, "Core Voltage : %d mV\n",
62 + dcdc_r8(DCDC_BIAS_VREG1) * 8);
67 +static const struct of_device_id dcdc_match[] = {
68 + { .compatible = "lantiq,dcdc-xrx200" },
72 +static struct platform_driver dcdc_driver = {
73 + .probe = dcdc_probe,
75 + .name = "dcdc-xrx200",
76 + .owner = THIS_MODULE,
77 + .of_match_table = dcdc_match,
81 +int __init dcdc_init(void)
83 + int ret = platform_driver_register(&dcdc_driver);
86 + pr_info("dcdc: Error registering platform driver\n");
90 +arch_initcall(dcdc_init);