blob: a67748098213ab4265fd259d6ef8a80a624a8878 [file] [log] [blame]
Andy Shevchenko4b45efe2015-07-27 18:04:03 +03001/*
2 * Intel LPSS PCI support.
3 *
4 * Copyright (C) 2015, Intel Corporation
5 *
6 * Authors: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
7 * Mika Westerberg <mika.westerberg@linux.intel.com>
8 *
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License version 2 as
11 * published by the Free Software Foundation.
12 */
13
14#include <linux/ioport.h>
15#include <linux/kernel.h>
16#include <linux/module.h>
17#include <linux/pci.h>
18#include <linux/pm.h>
19#include <linux/pm_runtime.h>
Mika Westerberg028af592015-11-30 17:11:42 +020020#include <linux/property.h>
Andy Shevchenko4b45efe2015-07-27 18:04:03 +030021
22#include "intel-lpss.h"
23
24static int intel_lpss_pci_probe(struct pci_dev *pdev,
25 const struct pci_device_id *id)
26{
27 struct intel_lpss_platform_info *info;
28 int ret;
29
30 ret = pcim_enable_device(pdev);
31 if (ret)
32 return ret;
33
34 info = devm_kmemdup(&pdev->dev, (void *)id->driver_data, sizeof(*info),
35 GFP_KERNEL);
36 if (!info)
37 return -ENOMEM;
38
39 info->mem = &pdev->resource[0];
40 info->irq = pdev->irq;
41
42 /* Probably it is enough to set this for iDMA capable devices only */
43 pci_set_master(pdev);
44
45 ret = intel_lpss_probe(&pdev->dev, info);
46 if (ret)
47 return ret;
48
49 pm_runtime_put(&pdev->dev);
50 pm_runtime_allow(&pdev->dev);
51
52 return 0;
53}
54
55static void intel_lpss_pci_remove(struct pci_dev *pdev)
56{
57 pm_runtime_forbid(&pdev->dev);
58 pm_runtime_get_sync(&pdev->dev);
59
60 intel_lpss_remove(&pdev->dev);
61}
62
63static INTEL_LPSS_PM_OPS(intel_lpss_pci_pm_ops);
64
65static const struct intel_lpss_platform_info spt_info = {
66 .clk_rate = 120000000,
67};
68
Mika Westerberg028af592015-11-30 17:11:42 +020069static struct property_entry spt_i2c_properties[] = {
70 PROPERTY_ENTRY_U32("i2c-sda-hold-time-ns", 230),
71 { },
72};
73
74static struct property_set spt_i2c_pset = {
75 .properties = spt_i2c_properties,
76};
77
78static const struct intel_lpss_platform_info spt_i2c_info = {
79 .clk_rate = 120000000,
80 .pset = &spt_i2c_pset,
81};
82
Andy Shevchenko4b45efe2015-07-27 18:04:03 +030083static const struct intel_lpss_platform_info spt_uart_info = {
84 .clk_rate = 120000000,
85 .clk_con_id = "baudclk",
86};
87
Andy Shevchenkoff0a04a2015-10-21 12:41:48 +030088static const struct intel_lpss_platform_info bxt_info = {
89 .clk_rate = 100000000,
90};
91
92static const struct intel_lpss_platform_info bxt_uart_info = {
93 .clk_rate = 100000000,
94 .clk_con_id = "baudclk",
95};
96
97static const struct intel_lpss_platform_info bxt_i2c_info = {
98 .clk_rate = 133000000,
99};
100
Andy Shevchenko4b45efe2015-07-27 18:04:03 +0300101static const struct pci_device_id intel_lpss_pci_ids[] = {
Andy Shevchenkoff0a04a2015-10-21 12:41:48 +0300102 /* BXT */
103 { PCI_VDEVICE(INTEL, 0x0aac), (kernel_ulong_t)&bxt_i2c_info },
104 { PCI_VDEVICE(INTEL, 0x0aae), (kernel_ulong_t)&bxt_i2c_info },
105 { PCI_VDEVICE(INTEL, 0x0ab0), (kernel_ulong_t)&bxt_i2c_info },
106 { PCI_VDEVICE(INTEL, 0x0ab2), (kernel_ulong_t)&bxt_i2c_info },
107 { PCI_VDEVICE(INTEL, 0x0ab4), (kernel_ulong_t)&bxt_i2c_info },
108 { PCI_VDEVICE(INTEL, 0x0ab6), (kernel_ulong_t)&bxt_i2c_info },
109 { PCI_VDEVICE(INTEL, 0x0ab8), (kernel_ulong_t)&bxt_i2c_info },
110 { PCI_VDEVICE(INTEL, 0x0aba), (kernel_ulong_t)&bxt_i2c_info },
111 { PCI_VDEVICE(INTEL, 0x0abc), (kernel_ulong_t)&bxt_uart_info },
112 { PCI_VDEVICE(INTEL, 0x0abe), (kernel_ulong_t)&bxt_uart_info },
113 { PCI_VDEVICE(INTEL, 0x0ac0), (kernel_ulong_t)&bxt_uart_info },
114 { PCI_VDEVICE(INTEL, 0x0ac2), (kernel_ulong_t)&bxt_info },
115 { PCI_VDEVICE(INTEL, 0x0ac4), (kernel_ulong_t)&bxt_info },
116 { PCI_VDEVICE(INTEL, 0x0ac6), (kernel_ulong_t)&bxt_info },
117 { PCI_VDEVICE(INTEL, 0x0aee), (kernel_ulong_t)&bxt_uart_info },
118 /* APL */
119 { PCI_VDEVICE(INTEL, 0x5aac), (kernel_ulong_t)&bxt_i2c_info },
120 { PCI_VDEVICE(INTEL, 0x5aae), (kernel_ulong_t)&bxt_i2c_info },
121 { PCI_VDEVICE(INTEL, 0x5ab0), (kernel_ulong_t)&bxt_i2c_info },
122 { PCI_VDEVICE(INTEL, 0x5ab2), (kernel_ulong_t)&bxt_i2c_info },
123 { PCI_VDEVICE(INTEL, 0x5ab4), (kernel_ulong_t)&bxt_i2c_info },
124 { PCI_VDEVICE(INTEL, 0x5ab6), (kernel_ulong_t)&bxt_i2c_info },
125 { PCI_VDEVICE(INTEL, 0x5ab8), (kernel_ulong_t)&bxt_i2c_info },
126 { PCI_VDEVICE(INTEL, 0x5aba), (kernel_ulong_t)&bxt_i2c_info },
127 { PCI_VDEVICE(INTEL, 0x5abc), (kernel_ulong_t)&bxt_uart_info },
128 { PCI_VDEVICE(INTEL, 0x5abe), (kernel_ulong_t)&bxt_uart_info },
129 { PCI_VDEVICE(INTEL, 0x5ac0), (kernel_ulong_t)&bxt_uart_info },
130 { PCI_VDEVICE(INTEL, 0x5ac2), (kernel_ulong_t)&bxt_info },
131 { PCI_VDEVICE(INTEL, 0x5ac4), (kernel_ulong_t)&bxt_info },
132 { PCI_VDEVICE(INTEL, 0x5ac6), (kernel_ulong_t)&bxt_info },
133 { PCI_VDEVICE(INTEL, 0x5aee), (kernel_ulong_t)&bxt_uart_info },
Andy Shevchenko4b45efe2015-07-27 18:04:03 +0300134 /* SPT-LP */
135 { PCI_VDEVICE(INTEL, 0x9d27), (kernel_ulong_t)&spt_uart_info },
136 { PCI_VDEVICE(INTEL, 0x9d28), (kernel_ulong_t)&spt_uart_info },
137 { PCI_VDEVICE(INTEL, 0x9d29), (kernel_ulong_t)&spt_info },
138 { PCI_VDEVICE(INTEL, 0x9d2a), (kernel_ulong_t)&spt_info },
Mika Westerberg028af592015-11-30 17:11:42 +0200139 { PCI_VDEVICE(INTEL, 0x9d60), (kernel_ulong_t)&spt_i2c_info },
140 { PCI_VDEVICE(INTEL, 0x9d61), (kernel_ulong_t)&spt_i2c_info },
141 { PCI_VDEVICE(INTEL, 0x9d62), (kernel_ulong_t)&spt_i2c_info },
142 { PCI_VDEVICE(INTEL, 0x9d63), (kernel_ulong_t)&spt_i2c_info },
143 { PCI_VDEVICE(INTEL, 0x9d64), (kernel_ulong_t)&spt_i2c_info },
144 { PCI_VDEVICE(INTEL, 0x9d65), (kernel_ulong_t)&spt_i2c_info },
Andy Shevchenko4b45efe2015-07-27 18:04:03 +0300145 { PCI_VDEVICE(INTEL, 0x9d66), (kernel_ulong_t)&spt_uart_info },
146 /* SPT-H */
147 { PCI_VDEVICE(INTEL, 0xa127), (kernel_ulong_t)&spt_uart_info },
148 { PCI_VDEVICE(INTEL, 0xa128), (kernel_ulong_t)&spt_uart_info },
149 { PCI_VDEVICE(INTEL, 0xa129), (kernel_ulong_t)&spt_info },
150 { PCI_VDEVICE(INTEL, 0xa12a), (kernel_ulong_t)&spt_info },
Mika Westerberg028af592015-11-30 17:11:42 +0200151 { PCI_VDEVICE(INTEL, 0xa160), (kernel_ulong_t)&spt_i2c_info },
152 { PCI_VDEVICE(INTEL, 0xa161), (kernel_ulong_t)&spt_i2c_info },
Andy Shevchenko4b45efe2015-07-27 18:04:03 +0300153 { PCI_VDEVICE(INTEL, 0xa166), (kernel_ulong_t)&spt_uart_info },
154 { }
155};
156MODULE_DEVICE_TABLE(pci, intel_lpss_pci_ids);
157
158static struct pci_driver intel_lpss_pci_driver = {
159 .name = "intel-lpss",
160 .id_table = intel_lpss_pci_ids,
161 .probe = intel_lpss_pci_probe,
162 .remove = intel_lpss_pci_remove,
163 .driver = {
164 .pm = &intel_lpss_pci_pm_ops,
165 },
166};
167
168module_pci_driver(intel_lpss_pci_driver);
169
170MODULE_AUTHOR("Andy Shevchenko <andriy.shevchenko@linux.intel.com>");
171MODULE_AUTHOR("Mika Westerberg <mika.westerberg@linux.intel.com>");
172MODULE_DESCRIPTION("Intel LPSS PCI driver");
173MODULE_LICENSE("GPL v2");