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