xref: /openbmc/linux/arch/mips/lantiq/xway/dcdc.c (revision b593bce5)
1 // SPDX-License-Identifier: GPL-2.0-only
2 /*
3  *
4  *  Copyright (C) 2012 John Crispin <john@phrozen.org>
5  *  Copyright (C) 2010 Sameer Ahmad, Lantiq GmbH
6  */
7 
8 #include <linux/ioport.h>
9 #include <linux/of_platform.h>
10 
11 #include <lantiq_soc.h>
12 
13 /* Bias and regulator Setup Register */
14 #define DCDC_BIAS_VREG0	0xa
15 /* Bias and regulator Setup Register */
16 #define DCDC_BIAS_VREG1	0xb
17 
18 #define dcdc_w8(x, y)	ltq_w8((x), dcdc_membase + (y))
19 #define dcdc_r8(x)	ltq_r8(dcdc_membase + (x))
20 
21 static void __iomem *dcdc_membase;
22 
23 static int dcdc_probe(struct platform_device *pdev)
24 {
25 	struct resource *res;
26 
27 	res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
28 	dcdc_membase = devm_ioremap_resource(&pdev->dev, res);
29 	if (IS_ERR(dcdc_membase))
30 		return PTR_ERR(dcdc_membase);
31 
32 	dev_info(&pdev->dev, "Core Voltage : %d mV\n",
33 		dcdc_r8(DCDC_BIAS_VREG1) * 8);
34 
35 	return 0;
36 }
37 
38 static const struct of_device_id dcdc_match[] = {
39 	{ .compatible = "lantiq,dcdc-xrx200" },
40 	{},
41 };
42 
43 static struct platform_driver dcdc_driver = {
44 	.probe = dcdc_probe,
45 	.driver = {
46 		.name = "dcdc-xrx200",
47 		.of_match_table = dcdc_match,
48 	},
49 };
50 
51 int __init dcdc_init(void)
52 {
53 	int ret = platform_driver_register(&dcdc_driver);
54 
55 	if (ret)
56 		pr_info("dcdc: Error registering platform driver\n");
57 	return ret;
58 }
59 
60 arch_initcall(dcdc_init);
61