0003-MIPS-lantiq-handle-vmmc-memory-reservation.patch 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. From 16e315864132b59749faff739230daf4cee9abbb Mon Sep 17 00:00:00 2001
  2. From: John Crispin <blogic@openwrt.org>
  3. Date: Wed, 13 Mar 2013 10:04:01 +0100
  4. Subject: [PATCH 03/36] MIPS: lantiq: handle vmmc memory reservation
  5. Signed-off-by: John Crispin <blogic@openwrt.org>
  6. ---
  7. arch/mips/lantiq/xway/Makefile | 2 ++
  8. arch/mips/lantiq/xway/vmmc.c | 63 ++++++++++++++++++++++++++++++++++++++++
  9. 2 files changed, 65 insertions(+)
  10. create mode 100644 arch/mips/lantiq/xway/vmmc.c
  11. --- a/arch/mips/lantiq/xway/Makefile
  12. +++ b/arch/mips/lantiq/xway/Makefile
  13. @@ -1,3 +1,5 @@
  14. obj-y := prom.o sysctrl.o clk.o reset.o dma.o gptu.o dcdc.o
  15. +obj-y += vmmc.o
  16. +
  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 <blogic@openwrt.org>
  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 > 0) {
  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);