Back to home page

OSCL-LXR

 
 

    


0001 // SPDX-License-Identifier: GPL-2.0-only
0002 /*
0003  *
0004  *  Copyright (C) 2012 John Crispin <john@phrozen.org>
0005  *  Copyright (C) 2010 Sameer Ahmad, Lantiq GmbH
0006  */
0007 
0008 #include <linux/ioport.h>
0009 #include <linux/of_platform.h>
0010 
0011 #include <lantiq_soc.h>
0012 
0013 /* Bias and regulator Setup Register */
0014 #define DCDC_BIAS_VREG0 0xa
0015 /* Bias and regulator Setup Register */
0016 #define DCDC_BIAS_VREG1 0xb
0017 
0018 #define dcdc_w8(x, y)   ltq_w8((x), dcdc_membase + (y))
0019 #define dcdc_r8(x)  ltq_r8(dcdc_membase + (x))
0020 
0021 static void __iomem *dcdc_membase;
0022 
0023 static int dcdc_probe(struct platform_device *pdev)
0024 {
0025     struct resource *res;
0026 
0027     res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
0028     dcdc_membase = devm_ioremap_resource(&pdev->dev, res);
0029     if (IS_ERR(dcdc_membase))
0030         return PTR_ERR(dcdc_membase);
0031 
0032     dev_info(&pdev->dev, "Core Voltage : %d mV\n",
0033         dcdc_r8(DCDC_BIAS_VREG1) * 8);
0034 
0035     return 0;
0036 }
0037 
0038 static const struct of_device_id dcdc_match[] = {
0039     { .compatible = "lantiq,dcdc-xrx200" },
0040     {},
0041 };
0042 
0043 static struct platform_driver dcdc_driver = {
0044     .probe = dcdc_probe,
0045     .driver = {
0046         .name = "dcdc-xrx200",
0047         .of_match_table = dcdc_match,
0048     },
0049 };
0050 
0051 int __init dcdc_init(void)
0052 {
0053     int ret = platform_driver_register(&dcdc_driver);
0054 
0055     if (ret)
0056         pr_info("dcdc: Error registering platform driver\n");
0057     return ret;
0058 }
0059 
0060 arch_initcall(dcdc_init);