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