dcdc.c 1.3 KB

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