Linux Audio

Check our new training course

Loading...
Note: File does not exist in v3.1.
  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
 21static const struct intel_lpss_platform_info spt_info = {
 22	.clk_rate = 120000000,
 23};
 24
 25static const struct property_entry spt_i2c_properties[] = {
 26	PROPERTY_ENTRY_U32("i2c-sda-hold-time-ns", 230),
 27	{ },
 28};
 29
 30static const struct software_node spt_i2c_node = {
 31	.properties = spt_i2c_properties,
 32};
 33
 34static const struct intel_lpss_platform_info spt_i2c_info = {
 35	.clk_rate = 120000000,
 36	.swnode = &spt_i2c_node,
 37};
 38
 39static const struct property_entry uart_properties[] = {
 40	PROPERTY_ENTRY_U32("reg-io-width", 4),
 41	PROPERTY_ENTRY_U32("reg-shift", 2),
 42	PROPERTY_ENTRY_BOOL("snps,uart-16550-compatible"),
 43	{ },
 44};
 45
 46static const struct software_node uart_node = {
 47	.properties = uart_properties,
 48};
 49
 50static const struct intel_lpss_platform_info spt_uart_info = {
 51	.clk_rate = 120000000,
 52	.clk_con_id = "baudclk",
 53	.swnode = &uart_node,
 54};
 55
 56static const struct intel_lpss_platform_info bxt_info = {
 57	.clk_rate = 100000000,
 58};
 59
 60static const struct property_entry bxt_i2c_properties[] = {
 61	PROPERTY_ENTRY_U32("i2c-sda-hold-time-ns", 42),
 62	PROPERTY_ENTRY_U32("i2c-sda-falling-time-ns", 171),
 63	PROPERTY_ENTRY_U32("i2c-scl-falling-time-ns", 208),
 64	{ },
 65};
 66
 67static const struct software_node bxt_i2c_node = {
 68	.properties = bxt_i2c_properties,
 69};
 70
 71static const struct intel_lpss_platform_info bxt_i2c_info = {
 72	.clk_rate = 133000000,
 73	.swnode = &bxt_i2c_node,
 74};
 75
 76static const struct property_entry apl_i2c_properties[] = {
 77	PROPERTY_ENTRY_U32("i2c-sda-hold-time-ns", 207),
 78	PROPERTY_ENTRY_U32("i2c-sda-falling-time-ns", 171),
 79	PROPERTY_ENTRY_U32("i2c-scl-falling-time-ns", 208),
 80	{ },
 81};
 82
 83static const struct software_node apl_i2c_node = {
 84	.properties = apl_i2c_properties,
 85};
 86
 87static const struct intel_lpss_platform_info apl_i2c_info = {
 88	.clk_rate = 133000000,
 89	.swnode = &apl_i2c_node,
 90};
 91
 92static const struct acpi_device_id intel_lpss_acpi_ids[] = {
 93	/* SPT */
 94	{ "INT3440", (kernel_ulong_t)&spt_info },
 95	{ "INT3441", (kernel_ulong_t)&spt_info },
 96	{ "INT3442", (kernel_ulong_t)&spt_i2c_info },
 97	{ "INT3443", (kernel_ulong_t)&spt_i2c_info },
 98	{ "INT3444", (kernel_ulong_t)&spt_i2c_info },
 99	{ "INT3445", (kernel_ulong_t)&spt_i2c_info },
100	{ "INT3446", (kernel_ulong_t)&spt_i2c_info },
101	{ "INT3447", (kernel_ulong_t)&spt_i2c_info },
102	{ "INT3448", (kernel_ulong_t)&spt_uart_info },
103	{ "INT3449", (kernel_ulong_t)&spt_uart_info },
104	{ "INT344A", (kernel_ulong_t)&spt_uart_info },
105	/* BXT */
106	{ "80860AAC", (kernel_ulong_t)&bxt_i2c_info },
107	{ "80860ABC", (kernel_ulong_t)&bxt_info },
108	{ "80860AC2", (kernel_ulong_t)&bxt_info },
109	/* APL */
110	{ "80865AAC", (kernel_ulong_t)&apl_i2c_info },
111	{ "80865ABC", (kernel_ulong_t)&bxt_info },
112	{ "80865AC2", (kernel_ulong_t)&bxt_info },
113	{ }
114};
115MODULE_DEVICE_TABLE(acpi, intel_lpss_acpi_ids);
116
117static int intel_lpss_acpi_probe(struct platform_device *pdev)
118{
119	struct intel_lpss_platform_info *info;
120	const struct acpi_device_id *id;
121
122	id = acpi_match_device(intel_lpss_acpi_ids, &pdev->dev);
123	if (!id)
124		return -ENODEV;
125
126	info = devm_kmemdup(&pdev->dev, (void *)id->driver_data, sizeof(*info),
127			    GFP_KERNEL);
128	if (!info)
129		return -ENOMEM;
130
131	info->mem = platform_get_resource(pdev, IORESOURCE_MEM, 0);
132	info->irq = platform_get_irq(pdev, 0);
133
134	pm_runtime_set_active(&pdev->dev);
135	pm_runtime_enable(&pdev->dev);
136
137	return intel_lpss_probe(&pdev->dev, info);
138}
139
140static int intel_lpss_acpi_remove(struct platform_device *pdev)
141{
142	intel_lpss_remove(&pdev->dev);
143	pm_runtime_disable(&pdev->dev);
144
145	return 0;
146}
147
148static INTEL_LPSS_PM_OPS(intel_lpss_acpi_pm_ops);
149
150static struct platform_driver intel_lpss_acpi_driver = {
151	.probe = intel_lpss_acpi_probe,
152	.remove = intel_lpss_acpi_remove,
153	.driver = {
154		.name = "intel-lpss",
155		.acpi_match_table = intel_lpss_acpi_ids,
156		.pm = &intel_lpss_acpi_pm_ops,
157	},
158};
159
160module_platform_driver(intel_lpss_acpi_driver);
161
162MODULE_AUTHOR("Andy Shevchenko <andriy.shevchenko@linux.intel.com>");
163MODULE_AUTHOR("Mika Westerberg <mika.westerberg@linux.intel.com>");
164MODULE_DESCRIPTION("Intel LPSS ACPI driver");
165MODULE_LICENSE("GPL v2");