Merge tag 'sched-urgent-2020-12-27' of git://git.kernel.org/pub/scm/linux/kernel...
[linux/fpc-iii.git] / arch / mips / lantiq / xway / vmmc.c
blob7a14da8d9d15ed44c43c691394b2925d276e50f8
1 // SPDX-License-Identifier: GPL-2.0-only
2 /*
4 * Copyright (C) 2012 John Crispin <john@phrozen.org>
5 */
7 #include <linux/export.h>
8 #include <linux/of_platform.h>
9 #include <linux/of_gpio.h>
10 #include <linux/dma-mapping.h>
12 #include <lantiq_soc.h>
14 static unsigned int *cp1_base;
16 unsigned int *ltq_get_cp1_base(void)
18 if (!cp1_base)
19 panic("no cp1 base was set\n");
21 return cp1_base;
23 EXPORT_SYMBOL(ltq_get_cp1_base);
25 static int vmmc_probe(struct platform_device *pdev)
27 #define CP1_SIZE (1 << 20)
28 int gpio_count;
29 dma_addr_t dma;
31 cp1_base =
32 (void *) CPHYSADDR(dma_alloc_coherent(&pdev->dev, CP1_SIZE,
33 &dma, GFP_KERNEL));
35 gpio_count = of_gpio_count(pdev->dev.of_node);
36 while (gpio_count > 0) {
37 enum of_gpio_flags flags;
38 int gpio = of_get_gpio_flags(pdev->dev.of_node,
39 --gpio_count, &flags);
40 if (gpio_request(gpio, "vmmc-relay"))
41 continue;
42 dev_info(&pdev->dev, "requested GPIO %d\n", gpio);
43 gpio_direction_output(gpio,
44 (flags & OF_GPIO_ACTIVE_LOW) ? (0) : (1));
47 dev_info(&pdev->dev, "reserved %dMB at 0x%p", CP1_SIZE >> 20, cp1_base);
49 return 0;
52 static const struct of_device_id vmmc_match[] = {
53 { .compatible = "lantiq,vmmc-xway" },
54 {},
57 static struct platform_driver vmmc_driver = {
58 .probe = vmmc_probe,
59 .driver = {
60 .name = "lantiq,vmmc",
61 .of_match_table = vmmc_match,
64 builtin_platform_driver(vmmc_driver);