36a53f2bae180695e7258bf1969d77218fedec66
[openwrt/svn-archive/archive.git] / target / linux / lantiq / patches-3.14 / 0003-MIPS-lantiq-handle-vmmc-memory-reservation.patch
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/31] MIPS: lantiq: handle vmmc memory reservation
5
6 Signed-off-by: John Crispin <blogic@openwrt.org>
7 ---
8 arch/mips/lantiq/xway/Makefile | 2 ++
9 arch/mips/lantiq/xway/vmmc.c | 63 ++++++++++++++++++++++++++++++++++++++++
10 2 files changed, 65 insertions(+)
11 create mode 100644 arch/mips/lantiq/xway/vmmc.c
12
13 diff --git a/arch/mips/lantiq/xway/Makefile b/arch/mips/lantiq/xway/Makefile
14 index 087497d..a2edc53 100644
15 --- a/arch/mips/lantiq/xway/Makefile
16 +++ b/arch/mips/lantiq/xway/Makefile
17 @@ -1,3 +1,5 @@
18 obj-y := prom.o sysctrl.o clk.o reset.o dma.o gptu.o dcdc.o
19
20 +obj-y += vmmc.o
21 +
22 obj-$(CONFIG_XRX200_PHY_FW) += xrx200_phy_fw.o
23 diff --git a/arch/mips/lantiq/xway/vmmc.c b/arch/mips/lantiq/xway/vmmc.c
24 new file mode 100644
25 index 0000000..cea0ff9
26 --- /dev/null
27 +++ b/arch/mips/lantiq/xway/vmmc.c
28 @@ -0,0 +1,63 @@
29 +/*
30 + * This program is free software; you can redistribute it and/or modify it
31 + * under the terms of the GNU General Public License version 2 as published
32 + * by the Free Software Foundation.
33 + *
34 + * Copyright (C) 2012 John Crispin <blogic@openwrt.org>
35 + */
36 +
37 +#include <linux/module.h>
38 +#include <linux/of_platform.h>
39 +#include <linux/of_gpio.h>
40 +#include <linux/dma-mapping.h>
41 +
42 +#include <lantiq_soc.h>
43 +
44 +static unsigned int *cp1_base = 0;
45 +unsigned int* ltq_get_cp1_base(void)
46 +{
47 + if (!cp1_base)
48 + panic("no cp1 base was set\n");
49 + return cp1_base;
50 +}
51 +EXPORT_SYMBOL(ltq_get_cp1_base);
52 +
53 +static int vmmc_probe(struct platform_device *pdev)
54 +{
55 +#define CP1_SIZE (1 << 20)
56 + int gpio_count;
57 + dma_addr_t dma;
58 + cp1_base =
59 + (void*)CPHYSADDR(dma_alloc_coherent(NULL, CP1_SIZE, &dma, GFP_ATOMIC));
60 +
61 + gpio_count = of_gpio_count(pdev->dev.of_node);
62 + while (gpio_count > 0) {
63 + enum of_gpio_flags flags;
64 + int gpio = of_get_gpio_flags(pdev->dev.of_node, --gpio_count, &flags);
65 + if (gpio_request(gpio, "vmmc-relay"))
66 + continue;
67 + dev_info(&pdev->dev, "requested GPIO %d\n", gpio);
68 + gpio_direction_output(gpio, (flags & OF_GPIO_ACTIVE_LOW) ? (0) : (1));
69 + }
70 +
71 + dev_info(&pdev->dev, "reserved %dMB at 0x%p", CP1_SIZE >> 20, cp1_base);
72 +
73 + return 0;
74 +}
75 +
76 +static const struct of_device_id vmmc_match[] = {
77 + { .compatible = "lantiq,vmmc" },
78 + {},
79 +};
80 +MODULE_DEVICE_TABLE(of, vmmc_match);
81 +
82 +static struct platform_driver vmmc_driver = {
83 + .probe = vmmc_probe,
84 + .driver = {
85 + .name = "lantiq,vmmc",
86 + .owner = THIS_MODULE,
87 + .of_match_table = vmmc_match,
88 + },
89 +};
90 +
91 +module_platform_driver(vmmc_driver);
92 --
93 1.7.10.4
94