Blame view

drivers/mfd/intel-lpss-pci.c 8.08 KB
4b45efe85   Andy Shevchenko   mfd: Add support ...
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
  /*
   * Intel LPSS PCI support.
   *
   * Copyright (C) 2015, Intel Corporation
   *
   * Authors: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
   *          Mika Westerberg <mika.westerberg@linux.intel.com>
   *
   * This program is free software; you can redistribute it and/or modify
   * it under the terms of the GNU General Public License version 2 as
   * published by the Free Software Foundation.
   */
  
  #include <linux/ioport.h>
  #include <linux/kernel.h>
  #include <linux/module.h>
  #include <linux/pci.h>
  #include <linux/pm.h>
  #include <linux/pm_runtime.h>
028af5941   Mika Westerberg   mfd: intel-lpss: ...
20
  #include <linux/property.h>
4b45efe85   Andy Shevchenko   mfd: Add support ...
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
55
56
57
58
59
60
61
62
63
64
65
66
67
  
  #include "intel-lpss.h"
  
  static int intel_lpss_pci_probe(struct pci_dev *pdev,
  				const struct pci_device_id *id)
  {
  	struct intel_lpss_platform_info *info;
  	int ret;
  
  	ret = pcim_enable_device(pdev);
  	if (ret)
  		return ret;
  
  	info = devm_kmemdup(&pdev->dev, (void *)id->driver_data, sizeof(*info),
  			    GFP_KERNEL);
  	if (!info)
  		return -ENOMEM;
  
  	info->mem = &pdev->resource[0];
  	info->irq = pdev->irq;
  
  	/* Probably it is enough to set this for iDMA capable devices only */
  	pci_set_master(pdev);
  
  	ret = intel_lpss_probe(&pdev->dev, info);
  	if (ret)
  		return ret;
  
  	pm_runtime_put(&pdev->dev);
  	pm_runtime_allow(&pdev->dev);
  
  	return 0;
  }
  
  static void intel_lpss_pci_remove(struct pci_dev *pdev)
  {
  	pm_runtime_forbid(&pdev->dev);
  	pm_runtime_get_sync(&pdev->dev);
  
  	intel_lpss_remove(&pdev->dev);
  }
  
  static INTEL_LPSS_PM_OPS(intel_lpss_pci_pm_ops);
  
  static const struct intel_lpss_platform_info spt_info = {
  	.clk_rate = 120000000,
  };
028af5941   Mika Westerberg   mfd: intel-lpss: ...
68
69
70
71
  static struct property_entry spt_i2c_properties[] = {
  	PROPERTY_ENTRY_U32("i2c-sda-hold-time-ns", 230),
  	{ },
  };
028af5941   Mika Westerberg   mfd: intel-lpss: ...
72
73
  static const struct intel_lpss_platform_info spt_i2c_info = {
  	.clk_rate = 120000000,
f4d052660   Heikki Krogerus   device property: ...
74
  	.properties = spt_i2c_properties,
028af5941   Mika Westerberg   mfd: intel-lpss: ...
75
  };
ec14c5395   Andy Shevchenko   mfd: intel-lpss: ...
76
77
78
79
80
81
  static struct property_entry uart_properties[] = {
  	PROPERTY_ENTRY_U32("reg-io-width", 4),
  	PROPERTY_ENTRY_U32("reg-shift", 2),
  	PROPERTY_ENTRY_BOOL("snps,uart-16550-compatible"),
  	{ },
  };
4b45efe85   Andy Shevchenko   mfd: Add support ...
82
83
84
  static const struct intel_lpss_platform_info spt_uart_info = {
  	.clk_rate = 120000000,
  	.clk_con_id = "baudclk",
f4d052660   Heikki Krogerus   device property: ...
85
  	.properties = uart_properties,
4b45efe85   Andy Shevchenko   mfd: Add support ...
86
  };
ff0a04a69   Andy Shevchenko   mfd: lpss: Add In...
87
88
89
90
91
92
93
  static const struct intel_lpss_platform_info bxt_info = {
  	.clk_rate = 100000000,
  };
  
  static const struct intel_lpss_platform_info bxt_uart_info = {
  	.clk_rate = 100000000,
  	.clk_con_id = "baudclk",
f4d052660   Heikki Krogerus   device property: ...
94
  	.properties = uart_properties,
ff0a04a69   Andy Shevchenko   mfd: lpss: Add In...
95
  };
0343b2f4e   Mika Westerberg   mfd: intel-lpss: ...
96
97
98
99
100
101
  static struct property_entry bxt_i2c_properties[] = {
  	PROPERTY_ENTRY_U32("i2c-sda-hold-time-ns", 42),
  	PROPERTY_ENTRY_U32("i2c-sda-falling-time-ns", 171),
  	PROPERTY_ENTRY_U32("i2c-scl-falling-time-ns", 208),
  	{ },
  };
ff0a04a69   Andy Shevchenko   mfd: lpss: Add In...
102
103
  static const struct intel_lpss_platform_info bxt_i2c_info = {
  	.clk_rate = 133000000,
f4d052660   Heikki Krogerus   device property: ...
104
  	.properties = bxt_i2c_properties,
ff0a04a69   Andy Shevchenko   mfd: lpss: Add In...
105
  };
c50cdd62d   Jarkko Nikula   mfd: intel-lpss: ...
106
107
108
109
110
111
112
113
114
115
116
  static struct property_entry apl_i2c_properties[] = {
  	PROPERTY_ENTRY_U32("i2c-sda-hold-time-ns", 207),
  	PROPERTY_ENTRY_U32("i2c-sda-falling-time-ns", 171),
  	PROPERTY_ENTRY_U32("i2c-scl-falling-time-ns", 208),
  	{ },
  };
  
  static const struct intel_lpss_platform_info apl_i2c_info = {
  	.clk_rate = 133000000,
  	.properties = apl_i2c_properties,
  };
4b45efe85   Andy Shevchenko   mfd: Add support ...
117
  static const struct pci_device_id intel_lpss_pci_ids[] = {
023269cc9   Huiquan Zhong   mfd: lpss: Add PC...
118
  	/* BXT A-Step */
ff0a04a69   Andy Shevchenko   mfd: lpss: Add In...
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
  	{ PCI_VDEVICE(INTEL, 0x0aac), (kernel_ulong_t)&bxt_i2c_info },
  	{ PCI_VDEVICE(INTEL, 0x0aae), (kernel_ulong_t)&bxt_i2c_info },
  	{ PCI_VDEVICE(INTEL, 0x0ab0), (kernel_ulong_t)&bxt_i2c_info },
  	{ PCI_VDEVICE(INTEL, 0x0ab2), (kernel_ulong_t)&bxt_i2c_info },
  	{ PCI_VDEVICE(INTEL, 0x0ab4), (kernel_ulong_t)&bxt_i2c_info },
  	{ PCI_VDEVICE(INTEL, 0x0ab6), (kernel_ulong_t)&bxt_i2c_info },
  	{ PCI_VDEVICE(INTEL, 0x0ab8), (kernel_ulong_t)&bxt_i2c_info },
  	{ PCI_VDEVICE(INTEL, 0x0aba), (kernel_ulong_t)&bxt_i2c_info },
  	{ PCI_VDEVICE(INTEL, 0x0abc), (kernel_ulong_t)&bxt_uart_info },
  	{ PCI_VDEVICE(INTEL, 0x0abe), (kernel_ulong_t)&bxt_uart_info },
  	{ PCI_VDEVICE(INTEL, 0x0ac0), (kernel_ulong_t)&bxt_uart_info },
  	{ PCI_VDEVICE(INTEL, 0x0ac2), (kernel_ulong_t)&bxt_info },
  	{ PCI_VDEVICE(INTEL, 0x0ac4), (kernel_ulong_t)&bxt_info },
  	{ PCI_VDEVICE(INTEL, 0x0ac6), (kernel_ulong_t)&bxt_info },
  	{ PCI_VDEVICE(INTEL, 0x0aee), (kernel_ulong_t)&bxt_uart_info },
023269cc9   Huiquan Zhong   mfd: lpss: Add PC...
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
  	/* BXT B-Step */
  	{ PCI_VDEVICE(INTEL, 0x1aac), (kernel_ulong_t)&bxt_i2c_info },
  	{ PCI_VDEVICE(INTEL, 0x1aae), (kernel_ulong_t)&bxt_i2c_info },
  	{ PCI_VDEVICE(INTEL, 0x1ab0), (kernel_ulong_t)&bxt_i2c_info },
  	{ PCI_VDEVICE(INTEL, 0x1ab2), (kernel_ulong_t)&bxt_i2c_info },
  	{ PCI_VDEVICE(INTEL, 0x1ab4), (kernel_ulong_t)&bxt_i2c_info },
  	{ PCI_VDEVICE(INTEL, 0x1ab6), (kernel_ulong_t)&bxt_i2c_info },
  	{ PCI_VDEVICE(INTEL, 0x1ab8), (kernel_ulong_t)&bxt_i2c_info },
  	{ PCI_VDEVICE(INTEL, 0x1aba), (kernel_ulong_t)&bxt_i2c_info },
  	{ PCI_VDEVICE(INTEL, 0x1abc), (kernel_ulong_t)&bxt_uart_info },
  	{ PCI_VDEVICE(INTEL, 0x1abe), (kernel_ulong_t)&bxt_uart_info },
  	{ PCI_VDEVICE(INTEL, 0x1ac0), (kernel_ulong_t)&bxt_uart_info },
  	{ PCI_VDEVICE(INTEL, 0x1ac2), (kernel_ulong_t)&bxt_info },
  	{ PCI_VDEVICE(INTEL, 0x1ac4), (kernel_ulong_t)&bxt_info },
  	{ PCI_VDEVICE(INTEL, 0x1ac6), (kernel_ulong_t)&bxt_info },
  	{ PCI_VDEVICE(INTEL, 0x1aee), (kernel_ulong_t)&bxt_uart_info },
ff0a04a69   Andy Shevchenko   mfd: lpss: Add In...
150
  	/* APL */
c50cdd62d   Jarkko Nikula   mfd: intel-lpss: ...
151
152
153
154
155
156
157
158
  	{ PCI_VDEVICE(INTEL, 0x5aac), (kernel_ulong_t)&apl_i2c_info },
  	{ PCI_VDEVICE(INTEL, 0x5aae), (kernel_ulong_t)&apl_i2c_info },
  	{ PCI_VDEVICE(INTEL, 0x5ab0), (kernel_ulong_t)&apl_i2c_info },
  	{ PCI_VDEVICE(INTEL, 0x5ab2), (kernel_ulong_t)&apl_i2c_info },
  	{ PCI_VDEVICE(INTEL, 0x5ab4), (kernel_ulong_t)&apl_i2c_info },
  	{ PCI_VDEVICE(INTEL, 0x5ab6), (kernel_ulong_t)&apl_i2c_info },
  	{ PCI_VDEVICE(INTEL, 0x5ab8), (kernel_ulong_t)&apl_i2c_info },
  	{ PCI_VDEVICE(INTEL, 0x5aba), (kernel_ulong_t)&apl_i2c_info },
ff0a04a69   Andy Shevchenko   mfd: lpss: Add In...
159
160
161
162
163
164
165
  	{ PCI_VDEVICE(INTEL, 0x5abc), (kernel_ulong_t)&bxt_uart_info },
  	{ PCI_VDEVICE(INTEL, 0x5abe), (kernel_ulong_t)&bxt_uart_info },
  	{ PCI_VDEVICE(INTEL, 0x5ac0), (kernel_ulong_t)&bxt_uart_info },
  	{ PCI_VDEVICE(INTEL, 0x5ac2), (kernel_ulong_t)&bxt_info },
  	{ PCI_VDEVICE(INTEL, 0x5ac4), (kernel_ulong_t)&bxt_info },
  	{ PCI_VDEVICE(INTEL, 0x5ac6), (kernel_ulong_t)&bxt_info },
  	{ PCI_VDEVICE(INTEL, 0x5aee), (kernel_ulong_t)&bxt_uart_info },
4b45efe85   Andy Shevchenko   mfd: Add support ...
166
167
168
169
170
  	/* SPT-LP */
  	{ PCI_VDEVICE(INTEL, 0x9d27), (kernel_ulong_t)&spt_uart_info },
  	{ PCI_VDEVICE(INTEL, 0x9d28), (kernel_ulong_t)&spt_uart_info },
  	{ PCI_VDEVICE(INTEL, 0x9d29), (kernel_ulong_t)&spt_info },
  	{ PCI_VDEVICE(INTEL, 0x9d2a), (kernel_ulong_t)&spt_info },
028af5941   Mika Westerberg   mfd: intel-lpss: ...
171
172
173
174
175
176
  	{ PCI_VDEVICE(INTEL, 0x9d60), (kernel_ulong_t)&spt_i2c_info },
  	{ PCI_VDEVICE(INTEL, 0x9d61), (kernel_ulong_t)&spt_i2c_info },
  	{ PCI_VDEVICE(INTEL, 0x9d62), (kernel_ulong_t)&spt_i2c_info },
  	{ PCI_VDEVICE(INTEL, 0x9d63), (kernel_ulong_t)&spt_i2c_info },
  	{ PCI_VDEVICE(INTEL, 0x9d64), (kernel_ulong_t)&spt_i2c_info },
  	{ PCI_VDEVICE(INTEL, 0x9d65), (kernel_ulong_t)&spt_i2c_info },
4b45efe85   Andy Shevchenko   mfd: Add support ...
177
178
179
180
181
182
  	{ PCI_VDEVICE(INTEL, 0x9d66), (kernel_ulong_t)&spt_uart_info },
  	/* SPT-H */
  	{ PCI_VDEVICE(INTEL, 0xa127), (kernel_ulong_t)&spt_uart_info },
  	{ PCI_VDEVICE(INTEL, 0xa128), (kernel_ulong_t)&spt_uart_info },
  	{ PCI_VDEVICE(INTEL, 0xa129), (kernel_ulong_t)&spt_info },
  	{ PCI_VDEVICE(INTEL, 0xa12a), (kernel_ulong_t)&spt_info },
028af5941   Mika Westerberg   mfd: intel-lpss: ...
183
184
  	{ PCI_VDEVICE(INTEL, 0xa160), (kernel_ulong_t)&spt_i2c_info },
  	{ PCI_VDEVICE(INTEL, 0xa161), (kernel_ulong_t)&spt_i2c_info },
4b45efe85   Andy Shevchenko   mfd: Add support ...
185
  	{ PCI_VDEVICE(INTEL, 0xa166), (kernel_ulong_t)&spt_uart_info },
77fc5ff64   Mika Westerberg   mfd: lpss: Add In...
186
  	/* KBL-H */
2c8c34167   Jarkko Nikula   mfd: lpss: Fix In...
187
188
189
190
191
192
193
194
195
  	{ PCI_VDEVICE(INTEL, 0xa2a7), (kernel_ulong_t)&spt_uart_info },
  	{ PCI_VDEVICE(INTEL, 0xa2a8), (kernel_ulong_t)&spt_uart_info },
  	{ PCI_VDEVICE(INTEL, 0xa2a9), (kernel_ulong_t)&spt_info },
  	{ PCI_VDEVICE(INTEL, 0xa2aa), (kernel_ulong_t)&spt_info },
  	{ PCI_VDEVICE(INTEL, 0xa2e0), (kernel_ulong_t)&spt_i2c_info },
  	{ PCI_VDEVICE(INTEL, 0xa2e1), (kernel_ulong_t)&spt_i2c_info },
  	{ PCI_VDEVICE(INTEL, 0xa2e2), (kernel_ulong_t)&spt_i2c_info },
  	{ PCI_VDEVICE(INTEL, 0xa2e3), (kernel_ulong_t)&spt_i2c_info },
  	{ PCI_VDEVICE(INTEL, 0xa2e6), (kernel_ulong_t)&spt_uart_info },
4b45efe85   Andy Shevchenko   mfd: Add support ...
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
  	{ }
  };
  MODULE_DEVICE_TABLE(pci, intel_lpss_pci_ids);
  
  static struct pci_driver intel_lpss_pci_driver = {
  	.name = "intel-lpss",
  	.id_table = intel_lpss_pci_ids,
  	.probe = intel_lpss_pci_probe,
  	.remove = intel_lpss_pci_remove,
  	.driver = {
  		.pm = &intel_lpss_pci_pm_ops,
  	},
  };
  
  module_pci_driver(intel_lpss_pci_driver);
  
  MODULE_AUTHOR("Andy Shevchenko <andriy.shevchenko@linux.intel.com>");
  MODULE_AUTHOR("Mika Westerberg <mika.westerberg@linux.intel.com>");
  MODULE_DESCRIPTION("Intel LPSS PCI driver");
  MODULE_LICENSE("GPL v2");