0019-owrt-lantiq-handle-vmmc-memory-reservation.patch 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. From 12ec61455ea440c164c3ff777adbedea350b1e08 Mon Sep 17 00:00:00 2001
  2. From: John Crispin <[email protected]>
  3. Date: Wed, 13 Mar 2013 10:04:01 +0100
  4. Subject: [PATCH 19/22] owrt: lantiq: handle vmmc memory reservation
  5. ---
  6. arch/mips/lantiq/xway/Makefile | 2 +-
  7. arch/mips/lantiq/xway/vmmc.c | 63 ++++++++++++++++++++++++++++++++++++++++
  8. 2 files changed, 64 insertions(+), 1 deletion(-)
  9. create mode 100644 arch/mips/lantiq/xway/vmmc.c
  10. --- a/arch/mips/lantiq/xway/Makefile
  11. +++ b/arch/mips/lantiq/xway/Makefile
  12. @@ -1,6 +1,6 @@
  13. obj-y := prom.o sysctrl.o clk.o reset.o dma.o gptu.o dcdc.o
  14. -obj-y += eth_mac.o
  15. +obj-y += eth_mac.o vmmc.o
  16. obj-$(CONFIG_PCI) += ath_eep.o rt_eep.o pci-ath-fixup.o
  17. obj-$(CONFIG_XRX200_PHY_FW) += xrx200_phy_fw.o
  18. --- /dev/null
  19. +++ b/arch/mips/lantiq/xway/vmmc.c
  20. @@ -0,0 +1,63 @@
  21. +/*
  22. + * This program is free software; you can redistribute it and/or modify it
  23. + * under the terms of the GNU General Public License version 2 as published
  24. + * by the Free Software Foundation.
  25. + *
  26. + * Copyright (C) 2012 John Crispin <[email protected]>
  27. + */
  28. +
  29. +#include <linux/module.h>
  30. +#include <linux/of_platform.h>
  31. +#include <linux/of_gpio.h>
  32. +#include <linux/dma-mapping.h>
  33. +
  34. +#include <lantiq_soc.h>
  35. +
  36. +static unsigned int *cp1_base = 0;
  37. +unsigned int* ltq_get_cp1_base(void)
  38. +{
  39. + if (!cp1_base)
  40. + panic("no cp1 base was set\n");
  41. + return cp1_base;
  42. +}
  43. +EXPORT_SYMBOL(ltq_get_cp1_base);
  44. +
  45. +static int vmmc_probe(struct platform_device *pdev)
  46. +{
  47. +#define CP1_SIZE (1 << 20)
  48. + int gpio_count;
  49. + dma_addr_t dma;
  50. + cp1_base =
  51. + (void*)CPHYSADDR(dma_alloc_coherent(NULL, CP1_SIZE, &dma, GFP_ATOMIC));
  52. +
  53. + gpio_count = of_gpio_count(pdev->dev.of_node);
  54. + while (gpio_count) {
  55. + enum of_gpio_flags flags;
  56. + int gpio = of_get_gpio_flags(pdev->dev.of_node, --gpio_count, &flags);
  57. + if (gpio_request(gpio, "vmmc-relay"))
  58. + continue;
  59. + dev_info(&pdev->dev, "requested GPIO %d\n", gpio);
  60. + gpio_direction_output(gpio, (flags & OF_GPIO_ACTIVE_LOW) ? (0) : (1));
  61. + }
  62. +
  63. + dev_info(&pdev->dev, "reserved %dMB at 0x%p", CP1_SIZE >> 20, cp1_base);
  64. +
  65. + return 0;
  66. +}
  67. +
  68. +static const struct of_device_id vmmc_match[] = {
  69. + { .compatible = "lantiq,vmmc" },
  70. + {},
  71. +};
  72. +MODULE_DEVICE_TABLE(of, vmmc_match);
  73. +
  74. +static struct platform_driver vmmc_driver = {
  75. + .probe = vmmc_probe,
  76. + .driver = {
  77. + .name = "lantiq,vmmc",
  78. + .owner = THIS_MODULE,
  79. + .of_match_table = vmmc_match,
  80. + },
  81. +};
  82. +
  83. +module_platform_driver(vmmc_driver);