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 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
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
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
29 index 0000000..7688ac0
31 +++ b/arch/mips/lantiq/xway/dcdc.c
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.
38 + * Copyright (C) 2012 John Crispin <blogic@openwrt.org>
39 + * Copyright (C) 2010 Sameer Ahmad, Lantiq GmbH
42 +#include <linux/ioport.h>
43 +#include <linux/of_platform.h>
45 +#include <lantiq_soc.h>
47 +/* Bias and regulator Setup Register */
48 +#define DCDC_BIAS_VREG0 0xa
49 +/* Bias and regulator Setup Register */
50 +#define DCDC_BIAS_VREG1 0xb
52 +#define dcdc_w8(x, y) ltq_w8((x), dcdc_membase + (y))
53 +#define dcdc_r8(x) ltq_r8(dcdc_membase + (x))
55 +static void __iomem *dcdc_membase;
57 +static int dcdc_probe(struct platform_device *pdev)
59 + struct resource *res;
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);
66 + dev_info(&pdev->dev, "Core Voltage : %d mV\n",
67 + dcdc_r8(DCDC_BIAS_VREG1) * 8);
72 +static const struct of_device_id dcdc_match[] = {
73 + { .compatible = "lantiq,dcdc-xrx200" },
77 +static struct platform_driver dcdc_driver = {
78 + .probe = dcdc_probe,
80 + .name = "dcdc-xrx200",
81 + .owner = THIS_MODULE,
82 + .of_match_table = dcdc_match,
86 +int __init dcdc_init(void)
88 + int ret = platform_driver_register(&dcdc_driver);
91 + pr_info("dcdc: Error registering platform driver\n");
95 +arch_initcall(dcdc_init);