Linux 4.16.11
[linux/fpc-iii.git] / drivers / mtd / spi-nor / intel-spi-platform.c
blob5c943df9398fbfa15d5c226bab3f31cc9fe9f95c
1 /*
2 * Intel PCH/PCU SPI flash platform driver.
4 * Copyright (C) 2016, Intel Corporation
5 * Author: Mika Westerberg <mika.westerberg@linux.intel.com>
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License version 2 as
9 * published by the Free Software Foundation.
12 #include <linux/ioport.h>
13 #include <linux/module.h>
14 #include <linux/platform_device.h>
16 #include "intel-spi.h"
18 static int intel_spi_platform_probe(struct platform_device *pdev)
20 struct intel_spi_boardinfo *info;
21 struct intel_spi *ispi;
22 struct resource *mem;
24 info = dev_get_platdata(&pdev->dev);
25 if (!info)
26 return -EINVAL;
28 mem = platform_get_resource(pdev, IORESOURCE_MEM, 0);
29 ispi = intel_spi_probe(&pdev->dev, mem, info);
30 if (IS_ERR(ispi))
31 return PTR_ERR(ispi);
33 platform_set_drvdata(pdev, ispi);
34 return 0;
37 static int intel_spi_platform_remove(struct platform_device *pdev)
39 struct intel_spi *ispi = platform_get_drvdata(pdev);
41 return intel_spi_remove(ispi);
44 static struct platform_driver intel_spi_platform_driver = {
45 .probe = intel_spi_platform_probe,
46 .remove = intel_spi_platform_remove,
47 .driver = {
48 .name = "intel-spi",
52 module_platform_driver(intel_spi_platform_driver);
54 MODULE_DESCRIPTION("Intel PCH/PCU SPI flash platform driver");
55 MODULE_AUTHOR("Mika Westerberg <mika.westerberg@linux.intel.com>");
56 MODULE_LICENSE("GPL v2");
57 MODULE_ALIAS("platform:intel-spi");