vmmc.c 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. // SPDX-License-Identifier: GPL-2.0-only
  2. /*
  3. *
  4. * Copyright (C) 2012 John Crispin <[email protected]>
  5. */
  6. #include <linux/err.h>
  7. #include <linux/export.h>
  8. #include <linux/gpio/consumer.h>
  9. #include <linux/of_platform.h>
  10. #include <linux/dma-mapping.h>
  11. #include <lantiq_soc.h>
  12. static unsigned int *cp1_base;
  13. unsigned int *ltq_get_cp1_base(void)
  14. {
  15. if (!cp1_base)
  16. panic("no cp1 base was set\n");
  17. return cp1_base;
  18. }
  19. EXPORT_SYMBOL(ltq_get_cp1_base);
  20. static int vmmc_probe(struct platform_device *pdev)
  21. {
  22. #define CP1_SIZE (1 << 20)
  23. struct gpio_desc *gpio;
  24. int gpio_count;
  25. dma_addr_t dma;
  26. int error;
  27. cp1_base =
  28. (void *) CPHYSADDR(dma_alloc_coherent(&pdev->dev, CP1_SIZE,
  29. &dma, GFP_KERNEL));
  30. gpio_count = gpiod_count(&pdev->dev, NULL);
  31. while (gpio_count > 0) {
  32. gpio = devm_gpiod_get_index(&pdev->dev,
  33. NULL, --gpio_count, GPIOD_OUT_HIGH);
  34. error = PTR_ERR_OR_ZERO(gpio);
  35. if (error) {
  36. dev_err(&pdev->dev,
  37. "failed to request GPIO idx %d: %d\n",
  38. gpio_count, error);
  39. continue;
  40. }
  41. gpiod_set_consumer_name(gpio, "vmmc-relay");
  42. }
  43. dev_info(&pdev->dev, "reserved %dMB at 0x%p", CP1_SIZE >> 20, cp1_base);
  44. return 0;
  45. }
  46. static const struct of_device_id vmmc_match[] = {
  47. { .compatible = "lantiq,vmmc-xway" },
  48. {},
  49. };
  50. static struct platform_driver vmmc_driver = {
  51. .probe = vmmc_probe,
  52. .driver = {
  53. .name = "lantiq,vmmc",
  54. .of_match_table = vmmc_match,
  55. },
  56. };
  57. builtin_platform_driver(vmmc_driver);