xref: /openbmc/linux/drivers/mfd/intel-lpss-acpi.c (revision cbdf59ad)
1 // SPDX-License-Identifier: GPL-2.0-only
2 /*
3  * Intel LPSS ACPI support.
4  *
5  * Copyright (C) 2015, Intel Corporation
6  *
7  * Authors: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
8  *          Mika Westerberg <mika.westerberg@linux.intel.com>
9  */
10 
11 #include <linux/acpi.h>
12 #include <linux/ioport.h>
13 #include <linux/kernel.h>
14 #include <linux/module.h>
15 #include <linux/pm_runtime.h>
16 #include <linux/platform_device.h>
17 #include <linux/property.h>
18 
19 #include "intel-lpss.h"
20 
21 static struct property_entry spt_i2c_properties[] = {
22 	PROPERTY_ENTRY_U32("i2c-sda-hold-time-ns", 230),
23 	{ },
24 };
25 
26 static const struct intel_lpss_platform_info spt_i2c_info = {
27 	.clk_rate = 120000000,
28 	.properties = spt_i2c_properties,
29 };
30 
31 static const struct intel_lpss_platform_info bxt_info = {
32 	.clk_rate = 100000000,
33 };
34 
35 static struct property_entry bxt_i2c_properties[] = {
36 	PROPERTY_ENTRY_U32("i2c-sda-hold-time-ns", 42),
37 	PROPERTY_ENTRY_U32("i2c-sda-falling-time-ns", 171),
38 	PROPERTY_ENTRY_U32("i2c-scl-falling-time-ns", 208),
39 	{ },
40 };
41 
42 static const struct intel_lpss_platform_info bxt_i2c_info = {
43 	.clk_rate = 133000000,
44 	.properties = bxt_i2c_properties,
45 };
46 
47 static struct property_entry apl_i2c_properties[] = {
48 	PROPERTY_ENTRY_U32("i2c-sda-hold-time-ns", 207),
49 	PROPERTY_ENTRY_U32("i2c-sda-falling-time-ns", 171),
50 	PROPERTY_ENTRY_U32("i2c-scl-falling-time-ns", 208),
51 	{ },
52 };
53 
54 static const struct intel_lpss_platform_info apl_i2c_info = {
55 	.clk_rate = 133000000,
56 	.properties = apl_i2c_properties,
57 };
58 
59 static const struct acpi_device_id intel_lpss_acpi_ids[] = {
60 	/* SPT */
61 	{ "INT3446", (kernel_ulong_t)&spt_i2c_info },
62 	{ "INT3447", (kernel_ulong_t)&spt_i2c_info },
63 	/* BXT */
64 	{ "80860AAC", (kernel_ulong_t)&bxt_i2c_info },
65 	{ "80860ABC", (kernel_ulong_t)&bxt_info },
66 	{ "80860AC2", (kernel_ulong_t)&bxt_info },
67 	/* APL */
68 	{ "80865AAC", (kernel_ulong_t)&apl_i2c_info },
69 	{ "80865ABC", (kernel_ulong_t)&bxt_info },
70 	{ "80865AC2", (kernel_ulong_t)&bxt_info },
71 	{ }
72 };
73 MODULE_DEVICE_TABLE(acpi, intel_lpss_acpi_ids);
74 
75 static int intel_lpss_acpi_probe(struct platform_device *pdev)
76 {
77 	struct intel_lpss_platform_info *info;
78 	const struct acpi_device_id *id;
79 
80 	id = acpi_match_device(intel_lpss_acpi_ids, &pdev->dev);
81 	if (!id)
82 		return -ENODEV;
83 
84 	info = devm_kmemdup(&pdev->dev, (void *)id->driver_data, sizeof(*info),
85 			    GFP_KERNEL);
86 	if (!info)
87 		return -ENOMEM;
88 
89 	info->mem = platform_get_resource(pdev, IORESOURCE_MEM, 0);
90 	info->irq = platform_get_irq(pdev, 0);
91 
92 	pm_runtime_set_active(&pdev->dev);
93 	pm_runtime_enable(&pdev->dev);
94 
95 	return intel_lpss_probe(&pdev->dev, info);
96 }
97 
98 static int intel_lpss_acpi_remove(struct platform_device *pdev)
99 {
100 	intel_lpss_remove(&pdev->dev);
101 	pm_runtime_disable(&pdev->dev);
102 
103 	return 0;
104 }
105 
106 static INTEL_LPSS_PM_OPS(intel_lpss_acpi_pm_ops);
107 
108 static struct platform_driver intel_lpss_acpi_driver = {
109 	.probe = intel_lpss_acpi_probe,
110 	.remove = intel_lpss_acpi_remove,
111 	.driver = {
112 		.name = "intel-lpss",
113 		.acpi_match_table = intel_lpss_acpi_ids,
114 		.pm = &intel_lpss_acpi_pm_ops,
115 	},
116 };
117 
118 module_platform_driver(intel_lpss_acpi_driver);
119 
120 MODULE_AUTHOR("Andy Shevchenko <andriy.shevchenko@linux.intel.com>");
121 MODULE_AUTHOR("Mika Westerberg <mika.westerberg@linux.intel.com>");
122 MODULE_DESCRIPTION("Intel LPSS ACPI driver");
123 MODULE_LICENSE("GPL v2");
124