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