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