xref: /openbmc/linux/arch/mips/lantiq/xway/dcdc.c (revision 159c610a)
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 	dcdc_membase = devm_platform_get_and_ioremap_resource(pdev, 0, NULL);
26 	if (IS_ERR(dcdc_membase))
27 		return PTR_ERR(dcdc_membase);
28 
29 	dev_info(&pdev->dev, "Core Voltage : %d mV\n",
30 		dcdc_r8(DCDC_BIAS_VREG1) * 8);
31 
32 	return 0;
33 }
34 
35 static const struct of_device_id dcdc_match[] = {
36 	{ .compatible = "lantiq,dcdc-xrx200" },
37 	{},
38 };
39 
40 static struct platform_driver dcdc_driver = {
41 	.probe = dcdc_probe,
42 	.driver = {
43 		.name = "dcdc-xrx200",
44 		.of_match_table = dcdc_match,
45 	},
46 };
47 
48 int __init dcdc_init(void)
49 {
50 	int ret = platform_driver_register(&dcdc_driver);
51 
52 	if (ret)
53 		pr_info("dcdc: Error registering platform driver\n");
54 	return ret;
55 }
56 
57 arch_initcall(dcdc_init);
58