summaryrefslogtreecommitdiffstats
path: root/drivers/mtd/spi-nor/controllers/intel-spi-platform.c
blob: f80f1086f928cf1792afd24272bd62ca214d85af (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
// SPDX-License-Identifier: GPL-2.0-only
/*
 * Intel PCH/PCU SPI flash platform driver.
 *
 * Copyright (C) 2016, Intel Corporation
 * Author: Mika Westerberg <mika.westerberg@linux.intel.com>
 */

#include <linux/ioport.h>
#include <linux/module.h>
#include <linux/platform_device.h>

#include "intel-spi.h"

static int intel_spi_platform_probe(struct platform_device *pdev)
{
	struct intel_spi_boardinfo *info;
	struct intel_spi *ispi;
	struct resource *mem;

	info = dev_get_platdata(&pdev->dev);
	if (!info)
		return -EINVAL;

	mem = platform_get_resource(pdev, IORESOURCE_MEM, 0);
	ispi = intel_spi_probe(&pdev->dev, mem, info);
	if (IS_ERR(ispi))
		return PTR_ERR(ispi);

	platform_set_drvdata(pdev, ispi);
	return 0;
}

static int intel_spi_platform_remove(struct platform_device *pdev)
{
	struct intel_spi *ispi = platform_get_drvdata(pdev);

	return intel_spi_remove(ispi);
}

static struct platform_driver intel_spi_platform_driver = {
	.probe = intel_spi_platform_probe,
	.remove = intel_spi_platform_remove,
	.driver = {
		.name = "intel-spi",
	},
};

module_platform_driver(intel_spi_platform_driver);

MODULE_DESCRIPTION("Intel PCH/PCU SPI flash platform driver");
MODULE_AUTHOR("Mika Westerberg <mika.westerberg@linux.intel.com>");
MODULE_LICENSE("GPL v2");
MODULE_ALIAS("platform:intel-spi");