Back to home page

OSCL-LXR

 
 

    


0001 // SPDX-License-Identifier: GPL-2.0-only
0002 /*
0003  *
0004  *  Copyright (C) 2012 John Crispin <john@phrozen.org>
0005  */
0006 
0007 #include <linux/export.h>
0008 #include <linux/of_platform.h>
0009 #include <linux/of_gpio.h>
0010 #include <linux/dma-mapping.h>
0011 
0012 #include <lantiq_soc.h>
0013 
0014 static unsigned int *cp1_base;
0015 
0016 unsigned int *ltq_get_cp1_base(void)
0017 {
0018     if (!cp1_base)
0019         panic("no cp1 base was set\n");
0020 
0021     return cp1_base;
0022 }
0023 EXPORT_SYMBOL(ltq_get_cp1_base);
0024 
0025 static int vmmc_probe(struct platform_device *pdev)
0026 {
0027 #define CP1_SIZE       (1 << 20)
0028     int gpio_count;
0029     dma_addr_t dma;
0030 
0031     cp1_base =
0032         (void *) CPHYSADDR(dma_alloc_coherent(&pdev->dev, CP1_SIZE,
0033                             &dma, GFP_KERNEL));
0034 
0035     gpio_count = of_gpio_count(pdev->dev.of_node);
0036     while (gpio_count > 0) {
0037         enum of_gpio_flags flags;
0038         int gpio = of_get_gpio_flags(pdev->dev.of_node,
0039                          --gpio_count, &flags);
0040         if (gpio_request(gpio, "vmmc-relay"))
0041             continue;
0042         dev_info(&pdev->dev, "requested GPIO %d\n", gpio);
0043         gpio_direction_output(gpio,
0044                       (flags & OF_GPIO_ACTIVE_LOW) ? (0) : (1));
0045     }
0046 
0047     dev_info(&pdev->dev, "reserved %dMB at 0x%p", CP1_SIZE >> 20, cp1_base);
0048 
0049     return 0;
0050 }
0051 
0052 static const struct of_device_id vmmc_match[] = {
0053     { .compatible = "lantiq,vmmc-xway" },
0054     {},
0055 };
0056 
0057 static struct platform_driver vmmc_driver = {
0058     .probe = vmmc_probe,
0059     .driver = {
0060         .name = "lantiq,vmmc",
0061         .of_match_table = vmmc_match,
0062     },
0063 };
0064 builtin_platform_driver(vmmc_driver);