Mika Westerberg | 8afda8b | 2016-11-28 15:06:24 +0300 | [diff] [blame] | 1 | /* |
| 2 | * Intel PCH/PCU SPI flash platform driver. |
| 3 | * |
| 4 | * Copyright (C) 2016, Intel Corporation |
| 5 | * Author: Mika Westerberg <mika.westerberg@linux.intel.com> |
| 6 | * |
| 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. |
| 10 | */ |
| 11 | |
| 12 | #include <linux/ioport.h> |
| 13 | #include <linux/module.h> |
| 14 | #include <linux/platform_device.h> |
| 15 | |
| 16 | #include "intel-spi.h" |
| 17 | |
| 18 | static int intel_spi_platform_probe(struct platform_device *pdev) |
| 19 | { |
| 20 | struct intel_spi_boardinfo *info; |
| 21 | struct intel_spi *ispi; |
| 22 | struct resource *mem; |
| 23 | |
| 24 | info = dev_get_platdata(&pdev->dev); |
| 25 | if (!info) |
| 26 | return -EINVAL; |
| 27 | |
| 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); |
| 32 | |
| 33 | platform_set_drvdata(pdev, ispi); |
| 34 | return 0; |
| 35 | } |
| 36 | |
| 37 | static int intel_spi_platform_remove(struct platform_device *pdev) |
| 38 | { |
| 39 | struct intel_spi *ispi = platform_get_drvdata(pdev); |
| 40 | |
| 41 | return intel_spi_remove(ispi); |
| 42 | } |
| 43 | |
| 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", |
| 49 | }, |
| 50 | }; |
| 51 | |
| 52 | module_platform_driver(intel_spi_platform_driver); |
| 53 | |
| 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"); |