aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDave Airlie <airlied@redhat.com>2010-07-07 04:37:35 -0400
committerDave Airlie <airlied@redhat.com>2010-07-07 04:37:35 -0400
commitdb8cc27b804f89e8fd5f9d5385161956a777c471 (patch)
tree4d84e12dbf9b4bd75fa6150f4aedf54a41d722db
parent6dbe7465713f0e45f0e867105ca944978d57346e (diff)
parent05269a3a5a78bb074413de495105d7a2686c4529 (diff)
Merge branch 'drm-platform' into drm-testing
* drm-platform: drm: Make sure the DRM offset matches the CPU drm: Add __arm defines to DRM drm: Add support for platform devices to register as DRM devices drm: Remove drm_resource wrappers
-rw-r--r--drivers/gpu/drm/Kconfig4
-rw-r--r--drivers/gpu/drm/Makefile2
-rw-r--r--drivers/gpu/drm/drm_bufs.c15
-rw-r--r--drivers/gpu/drm/drm_drv.c37
-rw-r--r--drivers/gpu/drm/drm_edid.c4
-rw-r--r--drivers/gpu/drm/drm_gem.c10
-rw-r--r--drivers/gpu/drm/drm_info.c23
-rw-r--r--drivers/gpu/drm/drm_ioctl.c71
-rw-r--r--drivers/gpu/drm/drm_irq.c15
-rw-r--r--drivers/gpu/drm/drm_pci.c143
-rw-r--r--drivers/gpu/drm/drm_platform.c122
-rw-r--r--drivers/gpu/drm/drm_stub.c89
-rw-r--r--drivers/gpu/drm/drm_sysfs.c3
-rw-r--r--drivers/gpu/drm/drm_vm.c14
-rw-r--r--drivers/gpu/drm/i915/i915_dma.c7
-rw-r--r--drivers/gpu/drm/i915/i915_drv.c2
-rw-r--r--drivers/gpu/drm/mga/mga_dma.c4
-rw-r--r--drivers/gpu/drm/nouveau/nouveau_bo.c2
-rw-r--r--drivers/gpu/drm/nouveau/nouveau_channel.c3
-rw-r--r--drivers/gpu/drm/nouveau/nouveau_drv.c2
-rw-r--r--drivers/gpu/drm/nouveau/nouveau_mem.c16
-rw-r--r--drivers/gpu/drm/nouveau/nv20_graph.c4
-rw-r--r--drivers/gpu/drm/nouveau/nv40_graph.c2
-rw-r--r--drivers/gpu/drm/nouveau/nv50_instmem.c2
-rw-r--r--drivers/gpu/drm/radeon/evergreen.c4
-rw-r--r--drivers/gpu/drm/radeon/r100.c4
-rw-r--r--drivers/gpu/drm/radeon/r600.c4
-rw-r--r--drivers/gpu/drm/radeon/radeon_bios.c2
-rw-r--r--drivers/gpu/drm/radeon/radeon_cp.c8
-rw-r--r--drivers/gpu/drm/radeon/radeon_device.c4
-rw-r--r--drivers/gpu/drm/radeon/radeon_drv.c2
-rw-r--r--drivers/gpu/drm/radeon/rs600.c4
-rw-r--r--drivers/gpu/drm/radeon/rs690.c4
-rw-r--r--drivers/gpu/drm/radeon/rv770.c4
-rw-r--r--drivers/gpu/drm/savage/savage_bci.c24
-rw-r--r--drivers/gpu/drm/vmwgfx/vmwgfx_drv.c2
-rw-r--r--include/drm/drmP.h56
37 files changed, 479 insertions, 239 deletions
diff --git a/drivers/gpu/drm/Kconfig b/drivers/gpu/drm/Kconfig
index 88910e5a2c77..520ab23d8a3f 100644
--- a/drivers/gpu/drm/Kconfig
+++ b/drivers/gpu/drm/Kconfig
@@ -6,7 +6,7 @@
6# 6#
7menuconfig DRM 7menuconfig DRM
8 tristate "Direct Rendering Manager (XFree86 4.1.0 and higher DRI support)" 8 tristate "Direct Rendering Manager (XFree86 4.1.0 and higher DRI support)"
9 depends on (AGP || AGP=n) && PCI && !EMULATED_CMPXCHG && MMU 9 depends on (AGP || AGP=n) && !EMULATED_CMPXCHG && MMU
10 select I2C 10 select I2C
11 select I2C_ALGOBIT 11 select I2C_ALGOBIT
12 select SLOW_WORK 12 select SLOW_WORK
@@ -17,7 +17,7 @@ menuconfig DRM
17 These modules provide support for synchronization, security, and 17 These modules provide support for synchronization, security, and
18 DMA transfers. Please see <http://dri.sourceforge.net/> for more 18 DMA transfers. Please see <http://dri.sourceforge.net/> for more
19 details. You should also select and configure AGP 19 details. You should also select and configure AGP
20 (/dev/agpgart) support. 20 (/dev/agpgart) support if it is available for your platform.
21 21
22config DRM_KMS_HELPER 22config DRM_KMS_HELPER
23 tristate 23 tristate
diff --git a/drivers/gpu/drm/Makefile b/drivers/gpu/drm/Makefile
index abe3f446ca48..b4b2b480d0ce 100644
--- a/drivers/gpu/drm/Makefile
+++ b/drivers/gpu/drm/Makefile
@@ -9,7 +9,7 @@ drm-y := drm_auth.o drm_buffer.o drm_bufs.o drm_cache.o \
9 drm_drv.o drm_fops.o drm_gem.o drm_ioctl.o drm_irq.o \ 9 drm_drv.o drm_fops.o drm_gem.o drm_ioctl.o drm_irq.o \
10 drm_lock.o drm_memory.o drm_proc.o drm_stub.o drm_vm.o \ 10 drm_lock.o drm_memory.o drm_proc.o drm_stub.o drm_vm.o \
11 drm_agpsupport.o drm_scatter.o ati_pcigart.o drm_pci.o \ 11 drm_agpsupport.o drm_scatter.o ati_pcigart.o drm_pci.o \
12 drm_sysfs.o drm_hashtab.o drm_sman.o drm_mm.o \ 12 drm_platform.o drm_sysfs.o drm_hashtab.o drm_sman.o drm_mm.o \
13 drm_crtc.o drm_modes.o drm_edid.o \ 13 drm_crtc.o drm_modes.o drm_edid.o \
14 drm_info.o drm_debugfs.o drm_encoder_slave.o 14 drm_info.o drm_debugfs.o drm_encoder_slave.o
15 15
diff --git a/drivers/gpu/drm/drm_bufs.c b/drivers/gpu/drm/drm_bufs.c
index 2092e7bb788f..a5c9ce93bbcb 100644
--- a/drivers/gpu/drm/drm_bufs.c
+++ b/drivers/gpu/drm/drm_bufs.c
@@ -39,19 +39,6 @@
39#include <asm/shmparam.h> 39#include <asm/shmparam.h>
40#include "drmP.h" 40#include "drmP.h"
41 41
42resource_size_t drm_get_resource_start(struct drm_device *dev, unsigned int resource)
43{
44 return pci_resource_start(dev->pdev, resource);
45}
46EXPORT_SYMBOL(drm_get_resource_start);
47
48resource_size_t drm_get_resource_len(struct drm_device *dev, unsigned int resource)
49{
50 return pci_resource_len(dev->pdev, resource);
51}
52
53EXPORT_SYMBOL(drm_get_resource_len);
54
55static struct drm_map_list *drm_find_matching_map(struct drm_device *dev, 42static struct drm_map_list *drm_find_matching_map(struct drm_device *dev,
56 struct drm_local_map *map) 43 struct drm_local_map *map)
57{ 44{
@@ -189,7 +176,7 @@ static int drm_addmap_core(struct drm_device * dev, resource_size_t offset,
189 switch (map->type) { 176 switch (map->type) {
190 case _DRM_REGISTERS: 177 case _DRM_REGISTERS:
191 case _DRM_FRAME_BUFFER: 178 case _DRM_FRAME_BUFFER:
192#if !defined(__sparc__) && !defined(__alpha__) && !defined(__ia64__) && !defined(__powerpc64__) && !defined(__x86_64__) 179#if !defined(__sparc__) && !defined(__alpha__) && !defined(__ia64__) && !defined(__powerpc64__) && !defined(__x86_64__) && !defined(__arm__)
193 if (map->offset + (map->size-1) < map->offset || 180 if (map->offset + (map->size-1) < map->offset ||
194 map->offset < virt_to_phys(high_memory)) { 181 map->offset < virt_to_phys(high_memory)) {
195 kfree(map); 182 kfree(map);
diff --git a/drivers/gpu/drm/drm_drv.c b/drivers/gpu/drm/drm_drv.c
index 4a66201edaec..510bc87d98f6 100644
--- a/drivers/gpu/drm/drm_drv.c
+++ b/drivers/gpu/drm/drm_drv.c
@@ -243,47 +243,20 @@ int drm_lastclose(struct drm_device * dev)
243 * 243 *
244 * Initializes an array of drm_device structures, and attempts to 244 * Initializes an array of drm_device structures, and attempts to
245 * initialize all available devices, using consecutive minors, registering the 245 * initialize all available devices, using consecutive minors, registering the
246 * stubs and initializing the AGP device. 246 * stubs and initializing the device.
247 * 247 *
248 * Expands the \c DRIVER_PREINIT and \c DRIVER_POST_INIT macros before and 248 * Expands the \c DRIVER_PREINIT and \c DRIVER_POST_INIT macros before and
249 * after the initialization for driver customization. 249 * after the initialization for driver customization.
250 */ 250 */
251int drm_init(struct drm_driver *driver) 251int drm_init(struct drm_driver *driver)
252{ 252{
253 struct pci_dev *pdev = NULL;
254 const struct pci_device_id *pid;
255 int i;
256
257 DRM_DEBUG("\n"); 253 DRM_DEBUG("\n");
258
259 INIT_LIST_HEAD(&driver->device_list); 254 INIT_LIST_HEAD(&driver->device_list);
260 255
261 if (driver->driver_features & DRIVER_MODESET) 256 if (driver->driver_features & DRIVER_USE_PLATFORM_DEVICE)
262 return pci_register_driver(&driver->pci_driver); 257 return drm_platform_init(driver);
263 258 else
264 /* If not using KMS, fall back to stealth mode manual scanning. */ 259 return drm_pci_init(driver);
265 for (i = 0; driver->pci_driver.id_table[i].vendor != 0; i++) {
266 pid = &driver->pci_driver.id_table[i];
267
268 /* Loop around setting up a DRM device for each PCI device
269 * matching our ID and device class. If we had the internal
270 * function that pci_get_subsys and pci_get_class used, we'd
271 * be able to just pass pid in instead of doing a two-stage
272 * thing.
273 */
274 pdev = NULL;
275 while ((pdev =
276 pci_get_subsys(pid->vendor, pid->device, pid->subvendor,
277 pid->subdevice, pdev)) != NULL) {
278 if ((pdev->class & pid->class_mask) != pid->class)
279 continue;
280
281 /* stealth mode requires a manual probe */
282 pci_dev_get(pdev);
283 drm_get_dev(pdev, pid, driver);
284 }
285 }
286 return 0;
287} 260}
288 261
289EXPORT_SYMBOL(drm_init); 262EXPORT_SYMBOL(drm_init);
diff --git a/drivers/gpu/drm/drm_edid.c b/drivers/gpu/drm/drm_edid.c
index c1981861bbbd..83d8072066cb 100644
--- a/drivers/gpu/drm/drm_edid.c
+++ b/drivers/gpu/drm/drm_edid.c
@@ -282,7 +282,7 @@ drm_do_get_edid(struct drm_connector *connector, struct i2c_adapter *adapter)
282 return block; 282 return block;
283 283
284carp: 284carp:
285 dev_warn(&connector->dev->pdev->dev, "%s: EDID block %d invalid.\n", 285 dev_warn(connector->dev->dev, "%s: EDID block %d invalid.\n",
286 drm_get_connector_name(connector), j); 286 drm_get_connector_name(connector), j);
287 287
288out: 288out:
@@ -1626,7 +1626,7 @@ int drm_add_edid_modes(struct drm_connector *connector, struct edid *edid)
1626 return 0; 1626 return 0;
1627 } 1627 }
1628 if (!drm_edid_is_valid(edid)) { 1628 if (!drm_edid_is_valid(edid)) {
1629 dev_warn(&connector->dev->pdev->dev, "%s: EDID invalid.\n", 1629 dev_warn(connector->dev->dev, "%s: EDID invalid.\n",
1630 drm_get_connector_name(connector)); 1630 drm_get_connector_name(connector));
1631 return 0; 1631 return 0;
1632 } 1632 }
diff --git a/drivers/gpu/drm/drm_gem.c b/drivers/gpu/drm/drm_gem.c
index 33dad3fa6043..8601b72b6f26 100644
--- a/drivers/gpu/drm/drm_gem.c
+++ b/drivers/gpu/drm/drm_gem.c
@@ -68,8 +68,18 @@
68 * We make up offsets for buffer objects so we can recognize them at 68 * We make up offsets for buffer objects so we can recognize them at
69 * mmap time. 69 * mmap time.
70 */ 70 */
71
72/* pgoff in mmap is an unsigned long, so we need to make sure that
73 * the faked up offset will fit
74 */
75
76#if BITS_PER_LONG == 64
71#define DRM_FILE_PAGE_OFFSET_START ((0xFFFFFFFFUL >> PAGE_SHIFT) + 1) 77#define DRM_FILE_PAGE_OFFSET_START ((0xFFFFFFFFUL >> PAGE_SHIFT) + 1)
72#define DRM_FILE_PAGE_OFFSET_SIZE ((0xFFFFFFFFUL >> PAGE_SHIFT) * 16) 78#define DRM_FILE_PAGE_OFFSET_SIZE ((0xFFFFFFFFUL >> PAGE_SHIFT) * 16)
79#else
80#define DRM_FILE_PAGE_OFFSET_START ((0xFFFFFFFUL >> PAGE_SHIFT) + 1)
81#define DRM_FILE_PAGE_OFFSET_SIZE ((0xFFFFFFFUL >> PAGE_SHIFT) * 16)
82#endif
73 83
74/** 84/**
75 * Initialize the GEM device fields 85 * Initialize the GEM device fields
diff --git a/drivers/gpu/drm/drm_info.c b/drivers/gpu/drm/drm_info.c
index f0f6c6b93f3a..2ef2c7827243 100644
--- a/drivers/gpu/drm/drm_info.c
+++ b/drivers/gpu/drm/drm_info.c
@@ -51,13 +51,24 @@ int drm_name_info(struct seq_file *m, void *data)
51 if (!master) 51 if (!master)
52 return 0; 52 return 0;
53 53
54 if (master->unique) { 54 if (drm_core_check_feature(dev, DRIVER_USE_PLATFORM_DEVICE)) {
55 seq_printf(m, "%s %s %s\n", 55 if (master->unique) {
56 dev->driver->pci_driver.name, 56 seq_printf(m, "%s %s %s\n",
57 pci_name(dev->pdev), master->unique); 57 dev->driver->platform_device->name,
58 dev_name(dev->dev), master->unique);
59 } else {
60 seq_printf(m, "%s\n",
61 dev->driver->platform_device->name);
62 }
58 } else { 63 } else {
59 seq_printf(m, "%s %s\n", dev->driver->pci_driver.name, 64 if (master->unique) {
60 pci_name(dev->pdev)); 65 seq_printf(m, "%s %s %s\n",
66 dev->driver->pci_driver.name,
67 dev_name(dev->dev), master->unique);
68 } else {
69 seq_printf(m, "%s %s\n", dev->driver->pci_driver.name,
70 dev_name(dev->dev));
71 }
61 } 72 }
62 73
63 return 0; 74 return 0;
diff --git a/drivers/gpu/drm/drm_ioctl.c b/drivers/gpu/drm/drm_ioctl.c
index 9b9ff46c2378..76d3d18056dd 100644
--- a/drivers/gpu/drm/drm_ioctl.c
+++ b/drivers/gpu/drm/drm_ioctl.c
@@ -132,32 +132,57 @@ static int drm_set_busid(struct drm_device *dev, struct drm_file *file_priv)
132 struct drm_master *master = file_priv->master; 132 struct drm_master *master = file_priv->master;
133 int len; 133 int len;
134 134
135 if (master->unique != NULL) 135 if (drm_core_check_feature(dev, DRIVER_USE_PLATFORM_DEVICE)) {
136 return -EBUSY; 136 master->unique_len = 10 + strlen(dev->platformdev->name);
137 137 master->unique = kmalloc(master->unique_len + 1, GFP_KERNEL);
138 master->unique_len = 40; 138
139 master->unique_size = master->unique_len; 139 if (master->unique == NULL)
140 master->unique = kmalloc(master->unique_size, GFP_KERNEL); 140 return -ENOMEM;
141 if (master->unique == NULL) 141
142 return -ENOMEM; 142 len = snprintf(master->unique, master->unique_len,
143 "platform:%s", dev->platformdev->name);
144
145 if (len > master->unique_len)
146 DRM_ERROR("Unique buffer overflowed\n");
147
148 dev->devname =
149 kmalloc(strlen(dev->platformdev->name) +
150 master->unique_len + 2, GFP_KERNEL);
151
152 if (dev->devname == NULL)
153 return -ENOMEM;
154
155 sprintf(dev->devname, "%s@%s", dev->platformdev->name,
156 master->unique);
157
158 } else {
159 master->unique_len = 40;
160 master->unique_size = master->unique_len;
161 master->unique = kmalloc(master->unique_size, GFP_KERNEL);
162 if (master->unique == NULL)
163 return -ENOMEM;
164
165 len = snprintf(master->unique, master->unique_len,
166 "pci:%04x:%02x:%02x.%d",
167 drm_get_pci_domain(dev),
168 dev->pdev->bus->number,
169 PCI_SLOT(dev->pdev->devfn),
170 PCI_FUNC(dev->pdev->devfn));
171 if (len >= master->unique_len)
172 DRM_ERROR("buffer overflow");
173 else
174 master->unique_len = len;
143 175
144 len = snprintf(master->unique, master->unique_len, "pci:%04x:%02x:%02x.%d", 176 dev->devname =
145 drm_get_pci_domain(dev), 177 kmalloc(strlen(dev->driver->pci_driver.name) +
146 dev->pdev->bus->number, 178 master->unique_len + 2, GFP_KERNEL);
147 PCI_SLOT(dev->pdev->devfn),
148 PCI_FUNC(dev->pdev->devfn));
149 if (len >= master->unique_len)
150 DRM_ERROR("buffer overflow");
151 else
152 master->unique_len = len;
153 179
154 dev->devname = kmalloc(strlen(dev->driver->pci_driver.name) + 180 if (dev->devname == NULL)
155 master->unique_len + 2, GFP_KERNEL); 181 return -ENOMEM;
156 if (dev->devname == NULL)
157 return -ENOMEM;
158 182
159 sprintf(dev->devname, "%s@%s", dev->driver->pci_driver.name, 183 sprintf(dev->devname, "%s@%s", dev->driver->pci_driver.name,
160 master->unique); 184 master->unique);
185 }
161 186
162 return 0; 187 return 0;
163} 188}
diff --git a/drivers/gpu/drm/drm_irq.c b/drivers/gpu/drm/drm_irq.c
index a263b7070fc6..6353b625e099 100644
--- a/drivers/gpu/drm/drm_irq.c
+++ b/drivers/gpu/drm/drm_irq.c
@@ -57,6 +57,9 @@ int drm_irq_by_busid(struct drm_device *dev, void *data,
57{ 57{
58 struct drm_irq_busid *p = data; 58 struct drm_irq_busid *p = data;
59 59
60 if (drm_core_check_feature(dev, DRIVER_USE_PLATFORM_DEVICE))
61 return -EINVAL;
62
60 if (!drm_core_check_feature(dev, DRIVER_HAVE_IRQ)) 63 if (!drm_core_check_feature(dev, DRIVER_HAVE_IRQ))
61 return -EINVAL; 64 return -EINVAL;
62 65
@@ -211,7 +214,7 @@ int drm_irq_install(struct drm_device *dev)
211 if (!drm_core_check_feature(dev, DRIVER_HAVE_IRQ)) 214 if (!drm_core_check_feature(dev, DRIVER_HAVE_IRQ))
212 return -EINVAL; 215 return -EINVAL;
213 216
214 if (dev->pdev->irq == 0) 217 if (drm_dev_to_irq(dev) == 0)
215 return -EINVAL; 218 return -EINVAL;
216 219
217 mutex_lock(&dev->struct_mutex); 220 mutex_lock(&dev->struct_mutex);
@@ -229,7 +232,7 @@ int drm_irq_install(struct drm_device *dev)
229 dev->irq_enabled = 1; 232 dev->irq_enabled = 1;
230 mutex_unlock(&dev->struct_mutex); 233 mutex_unlock(&dev->struct_mutex);
231 234
232 DRM_DEBUG("irq=%d\n", dev->pdev->irq); 235 DRM_DEBUG("irq=%d\n", drm_dev_to_irq(dev));
233 236
234 /* Before installing handler */ 237 /* Before installing handler */
235 dev->driver->irq_preinstall(dev); 238 dev->driver->irq_preinstall(dev);
@@ -302,14 +305,14 @@ int drm_irq_uninstall(struct drm_device * dev)
302 if (!irq_enabled) 305 if (!irq_enabled)
303 return -EINVAL; 306 return -EINVAL;
304 307
305 DRM_DEBUG("irq=%d\n", dev->pdev->irq); 308 DRM_DEBUG("irq=%d\n", drm_dev_to_irq(dev));
306 309
307 if (!drm_core_check_feature(dev, DRIVER_MODESET)) 310 if (!drm_core_check_feature(dev, DRIVER_MODESET))
308 vga_client_register(dev->pdev, NULL, NULL, NULL); 311 vga_client_register(dev->pdev, NULL, NULL, NULL);
309 312
310 dev->driver->irq_uninstall(dev); 313 dev->driver->irq_uninstall(dev);
311 314
312 free_irq(dev->pdev->irq, dev); 315 free_irq(drm_dev_to_irq(dev), dev);
313 316
314 return 0; 317 return 0;
315} 318}
@@ -341,7 +344,7 @@ int drm_control(struct drm_device *dev, void *data,
341 if (drm_core_check_feature(dev, DRIVER_MODESET)) 344 if (drm_core_check_feature(dev, DRIVER_MODESET))
342 return 0; 345 return 0;
343 if (dev->if_version < DRM_IF_VERSION(1, 2) && 346 if (dev->if_version < DRM_IF_VERSION(1, 2) &&
344 ctl->irq != dev->pdev->irq) 347 ctl->irq != drm_dev_to_irq(dev))
345 return -EINVAL; 348 return -EINVAL;
346 return drm_irq_install(dev); 349 return drm_irq_install(dev);
347 case DRM_UNINST_HANDLER: 350 case DRM_UNINST_HANDLER:
@@ -651,7 +654,7 @@ int drm_wait_vblank(struct drm_device *dev, void *data,
651 int ret = 0; 654 int ret = 0;
652 unsigned int flags, seq, crtc; 655 unsigned int flags, seq, crtc;
653 656
654 if ((!dev->pdev->irq) || (!dev->irq_enabled)) 657 if ((!drm_dev_to_irq(dev)) || (!dev->irq_enabled))
655 return -EINVAL; 658 return -EINVAL;
656 659
657 if (vblwait->request.type & _DRM_VBLANK_SIGNAL) 660 if (vblwait->request.type & _DRM_VBLANK_SIGNAL)
diff --git a/drivers/gpu/drm/drm_pci.c b/drivers/gpu/drm/drm_pci.c
index 2ea9ad4a8d69..e20f78b542a7 100644
--- a/drivers/gpu/drm/drm_pci.c
+++ b/drivers/gpu/drm/drm_pci.c
@@ -124,4 +124,147 @@ void drm_pci_free(struct drm_device * dev, drm_dma_handle_t * dmah)
124 124
125EXPORT_SYMBOL(drm_pci_free); 125EXPORT_SYMBOL(drm_pci_free);
126 126
127#ifdef CONFIG_PCI
128/**
129 * Register.
130 *
131 * \param pdev - PCI device structure
132 * \param ent entry from the PCI ID table with device type flags
133 * \return zero on success or a negative number on failure.
134 *
135 * Attempt to gets inter module "drm" information. If we are first
136 * then register the character device and inter module information.
137 * Try and register, if we fail to register, backout previous work.
138 */
139int drm_get_pci_dev(struct pci_dev *pdev, const struct pci_device_id *ent,
140 struct drm_driver *driver)
141{
142 struct drm_device *dev;
143 int ret;
144
145 DRM_DEBUG("\n");
146
147 dev = kzalloc(sizeof(*dev), GFP_KERNEL);
148 if (!dev)
149 return -ENOMEM;
150
151 ret = pci_enable_device(pdev);
152 if (ret)
153 goto err_g1;
154
155 pci_set_master(pdev);
156
157 dev->pdev = pdev;
158 dev->dev = &pdev->dev;
159
160 dev->pci_device = pdev->device;
161 dev->pci_vendor = pdev->vendor;
162
163#ifdef __alpha__
164 dev->hose = pdev->sysdata;
165#endif
166
167 if ((ret = drm_fill_in_dev(dev, ent, driver))) {
168 printk(KERN_ERR "DRM: Fill_in_dev failed.\n");
169 goto err_g2;
170 }
171
172 if (drm_core_check_feature(dev, DRIVER_MODESET)) {
173 pci_set_drvdata(pdev, dev);
174 ret = drm_get_minor(dev, &dev->control, DRM_MINOR_CONTROL);
175 if (ret)
176 goto err_g2;
177 }
178
179 if ((ret = drm_get_minor(dev, &dev->primary, DRM_MINOR_LEGACY)))
180 goto err_g3;
181
182 if (dev->driver->load) {
183 ret = dev->driver->load(dev, ent->driver_data);
184 if (ret)
185 goto err_g4;
186 }
187
188 /* setup the grouping for the legacy output */
189 if (drm_core_check_feature(dev, DRIVER_MODESET)) {
190 ret = drm_mode_group_init_legacy_group(dev,
191 &dev->primary->mode_group);
192 if (ret)
193 goto err_g4;
194 }
195
196 list_add_tail(&dev->driver_item, &driver->device_list);
197
198 DRM_INFO("Initialized %s %d.%d.%d %s for %s on minor %d\n",
199 driver->name, driver->major, driver->minor, driver->patchlevel,
200 driver->date, pci_name(pdev), dev->primary->index);
201
202 return 0;
203
204err_g4:
205 drm_put_minor(&dev->primary);
206err_g3:
207 if (drm_core_check_feature(dev, DRIVER_MODESET))
208 drm_put_minor(&dev->control);
209err_g2:
210 pci_disable_device(pdev);
211err_g1:
212 kfree(dev);
213 return ret;
214}
215EXPORT_SYMBOL(drm_get_pci_dev);
216
217/**
218 * PCI device initialization. Called via drm_init at module load time,
219 *
220 * \return zero on success or a negative number on failure.
221 *
222 * Initializes a drm_device structures,registering the
223 * stubs and initializing the AGP device.
224 *
225 * Expands the \c DRIVER_PREINIT and \c DRIVER_POST_INIT macros before and
226 * after the initialization for driver customization.
227 */
228int drm_pci_init(struct drm_driver *driver)
229{
230 struct pci_dev *pdev = NULL;
231 const struct pci_device_id *pid;
232 int i;
233
234 if (driver->driver_features & DRIVER_MODESET)
235 return pci_register_driver(&driver->pci_driver);
236
237 /* If not using KMS, fall back to stealth mode manual scanning. */
238 for (i = 0; driver->pci_driver.id_table[i].vendor != 0; i++) {
239 pid = &driver->pci_driver.id_table[i];
240
241 /* Loop around setting up a DRM device for each PCI device
242 * matching our ID and device class. If we had the internal
243 * function that pci_get_subsys and pci_get_class used, we'd
244 * be able to just pass pid in instead of doing a two-stage
245 * thing.
246 */
247 pdev = NULL;
248 while ((pdev =
249 pci_get_subsys(pid->vendor, pid->device, pid->subvendor,
250 pid->subdevice, pdev)) != NULL) {
251 if ((pdev->class & pid->class_mask) != pid->class)
252 continue;
253
254 /* stealth mode requires a manual probe */
255 pci_dev_get(pdev);
256 drm_get_pci_dev(pdev, pid, driver);
257 }
258 }
259 return 0;
260}
261
262#else
263
264int drm_pci_init(struct drm_driver *driver)
265{
266 return -1;
267}
268
269#endif
127/*@}*/ 270/*@}*/
diff --git a/drivers/gpu/drm/drm_platform.c b/drivers/gpu/drm/drm_platform.c
new file mode 100644
index 000000000000..460e9a3afa8d
--- /dev/null
+++ b/drivers/gpu/drm/drm_platform.c
@@ -0,0 +1,122 @@
1/*
2 * Derived from drm_pci.c
3 *
4 * Copyright 2003 José Fonseca.
5 * Copyright 2003 Leif Delgass.
6 * Copyright (c) 2009, Code Aurora Forum.
7 * All Rights Reserved.
8 *
9 * Permission is hereby granted, free of charge, to any person obtaining a
10 * copy of this software and associated documentation files (the "Software"),
11 * to deal in the Software without restriction, including without limitation
12 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
13 * and/or sell copies of the Software, and to permit persons to whom the
14 * Software is furnished to do so, subject to the following conditions:
15 *
16 * The above copyright notice and this permission notice (including the next
17 * paragraph) shall be included in all copies or substantial portions of the
18 * Software.
19 *
20 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
21 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
22 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
23 * AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
24 * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
25 * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
26 */
27
28#include "drmP.h"
29
30/**
31 * Register.
32 *
33 * \param platdev - Platform device struture
34 * \return zero on success or a negative number on failure.
35 *
36 * Attempt to gets inter module "drm" information. If we are first
37 * then register the character device and inter module information.
38 * Try and register, if we fail to register, backout previous work.
39 */
40
41int drm_get_platform_dev(struct platform_device *platdev,
42 struct drm_driver *driver)
43{
44 struct drm_device *dev;
45 int ret;
46
47 DRM_DEBUG("\n");
48
49 dev = kzalloc(sizeof(*dev), GFP_KERNEL);
50 if (!dev)
51 return -ENOMEM;
52
53 dev->platformdev = platdev;
54 dev->dev = &platdev->dev;
55
56 ret = drm_fill_in_dev(dev, NULL, driver);
57
58 if (ret) {
59 printk(KERN_ERR "DRM: Fill_in_dev failed.\n");
60 goto err_g1;
61 }
62
63 if (drm_core_check_feature(dev, DRIVER_MODESET)) {
64 dev_set_drvdata(&platdev->dev, dev);
65 ret = drm_get_minor(dev, &dev->control, DRM_MINOR_CONTROL);
66 if (ret)
67 goto err_g1;
68 }
69
70 ret = drm_get_minor(dev, &dev->primary, DRM_MINOR_LEGACY);
71 if (ret)
72 goto err_g2;
73
74 if (dev->driver->load) {
75 ret = dev->driver->load(dev, 0);
76 if (ret)
77 goto err_g3;
78 }
79
80 /* setup the grouping for the legacy output */
81 if (drm_core_check_feature(dev, DRIVER_MODESET)) {
82 ret = drm_mode_group_init_legacy_group(dev,
83 &dev->primary->mode_group);
84 if (ret)
85 goto err_g3;
86 }
87
88 list_add_tail(&dev->driver_item, &driver->device_list);
89
90 DRM_INFO("Initialized %s %d.%d.%d %s on minor %d\n",
91 driver->name, driver->major, driver->minor, driver->patchlevel,
92 driver->date, dev->primary->index);
93
94 return 0;
95
96err_g3:
97 drm_put_minor(&dev->primary);
98err_g2:
99 if (drm_core_check_feature(dev, DRIVER_MODESET))
100 drm_put_minor(&dev->control);
101err_g1:
102 kfree(dev);
103 return ret;
104}
105EXPORT_SYMBOL(drm_get_platform_dev);
106
107/**
108 * Platform device initialization. Called via drm_init at module load time,
109 *
110 * \return zero on success or a negative number on failure.
111 *
112 * Initializes a drm_device structures,registering the
113 * stubs
114 *
115 * Expands the \c DRIVER_PREINIT and \c DRIVER_POST_INIT macros before and
116 * after the initialization for driver customization.
117 */
118
119int drm_platform_init(struct drm_driver *driver)
120{
121 return drm_get_platform_dev(driver->platform_device, driver);
122}
diff --git a/drivers/gpu/drm/drm_stub.c b/drivers/gpu/drm/drm_stub.c
index a0c365f2e521..63575e2fa882 100644
--- a/drivers/gpu/drm/drm_stub.c
+++ b/drivers/gpu/drm/drm_stub.c
@@ -224,7 +224,7 @@ int drm_dropmaster_ioctl(struct drm_device *dev, void *data,
224 return 0; 224 return 0;
225} 225}
226 226
227static int drm_fill_in_dev(struct drm_device * dev, struct pci_dev *pdev, 227int drm_fill_in_dev(struct drm_device *dev,
228 const struct pci_device_id *ent, 228 const struct pci_device_id *ent,
229 struct drm_driver *driver) 229 struct drm_driver *driver)
230{ 230{
@@ -245,14 +245,6 @@ static int drm_fill_in_dev(struct drm_device * dev, struct pci_dev *pdev,
245 245
246 idr_init(&dev->drw_idr); 246 idr_init(&dev->drw_idr);
247 247
248 dev->pdev = pdev;
249 dev->pci_device = pdev->device;
250 dev->pci_vendor = pdev->vendor;
251
252#ifdef __alpha__
253 dev->hose = pdev->sysdata;
254#endif
255
256 if (drm_ht_create(&dev->map_hash, 12)) { 248 if (drm_ht_create(&dev->map_hash, 12)) {
257 return -ENOMEM; 249 return -ENOMEM;
258 } 250 }
@@ -321,7 +313,7 @@ static int drm_fill_in_dev(struct drm_device * dev, struct pci_dev *pdev,
321 * create the proc init entry via proc_init(). This routines assigns 313 * create the proc init entry via proc_init(). This routines assigns
322 * minor numbers to secondary heads of multi-headed cards 314 * minor numbers to secondary heads of multi-headed cards
323 */ 315 */
324static int drm_get_minor(struct drm_device *dev, struct drm_minor **minor, int type) 316int drm_get_minor(struct drm_device *dev, struct drm_minor **minor, int type)
325{ 317{
326 struct drm_minor *new_minor; 318 struct drm_minor *new_minor;
327 int ret; 319 int ret;
@@ -388,83 +380,6 @@ err_idr:
388} 380}
389 381
390/** 382/**
391 * Register.
392 *
393 * \param pdev - PCI device structure
394 * \param ent entry from the PCI ID table with device type flags
395 * \return zero on success or a negative number on failure.
396 *
397 * Attempt to gets inter module "drm" information. If we are first
398 * then register the character device and inter module information.
399 * Try and register, if we fail to register, backout previous work.
400 */
401int drm_get_dev(struct pci_dev *pdev, const struct pci_device_id *ent,
402 struct drm_driver *driver)
403{
404 struct drm_device *dev;
405 int ret;
406
407 DRM_DEBUG("\n");
408
409 dev = kzalloc(sizeof(*dev), GFP_KERNEL);
410 if (!dev)
411 return -ENOMEM;
412
413 ret = pci_enable_device(pdev);
414 if (ret)
415 goto err_g1;
416
417 pci_set_master(pdev);
418 if ((ret = drm_fill_in_dev(dev, pdev, ent, driver))) {
419 printk(KERN_ERR "DRM: Fill_in_dev failed.\n");
420 goto err_g2;
421 }
422
423 if (drm_core_check_feature(dev, DRIVER_MODESET)) {
424 pci_set_drvdata(pdev, dev);
425 ret = drm_get_minor(dev, &dev->control, DRM_MINOR_CONTROL);
426 if (ret)
427 goto err_g2;
428 }
429
430 if ((ret = drm_get_minor(dev, &dev->primary, DRM_MINOR_LEGACY)))
431 goto err_g3;
432
433 if (dev->driver->load) {
434 ret = dev->driver->load(dev, ent->driver_data);
435 if (ret)
436 goto err_g4;
437 }
438
439 /* setup the grouping for the legacy output */
440 if (drm_core_check_feature(dev, DRIVER_MODESET)) {
441 ret = drm_mode_group_init_legacy_group(dev, &dev->primary->mode_group);
442 if (ret)
443 goto err_g4;
444 }
445
446 list_add_tail(&dev->driver_item, &driver->device_list);
447
448 DRM_INFO("Initialized %s %d.%d.%d %s for %s on minor %d\n",
449 driver->name, driver->major, driver->minor, driver->patchlevel,
450 driver->date, pci_name(pdev), dev->primary->index);
451
452 return 0;
453
454err_g4:
455 drm_put_minor(&dev->primary);
456err_g3:
457 if (drm_core_check_feature(dev, DRIVER_MODESET))
458 drm_put_minor(&dev->control);
459err_g2:
460 pci_disable_device(pdev);
461err_g1:
462 kfree(dev);
463 return ret;
464}
465EXPORT_SYMBOL(drm_get_dev);
466
467/**
468 * Put a secondary minor number. 383 * Put a secondary minor number.
469 * 384 *
470 * \param sec_minor - structure to be released 385 * \param sec_minor - structure to be released
diff --git a/drivers/gpu/drm/drm_sysfs.c b/drivers/gpu/drm/drm_sysfs.c
index 101d381e9d86..86118a742231 100644
--- a/drivers/gpu/drm/drm_sysfs.c
+++ b/drivers/gpu/drm/drm_sysfs.c
@@ -489,7 +489,8 @@ int drm_sysfs_device_add(struct drm_minor *minor)
489 int err; 489 int err;
490 char *minor_str; 490 char *minor_str;
491 491
492 minor->kdev.parent = &minor->dev->pdev->dev; 492 minor->kdev.parent = minor->dev->dev;
493
493 minor->kdev.class = drm_class; 494 minor->kdev.class = drm_class;
494 minor->kdev.release = drm_sysfs_device_release; 495 minor->kdev.release = drm_sysfs_device_release;
495 minor->kdev.devt = minor->device; 496 minor->kdev.devt = minor->device;
diff --git a/drivers/gpu/drm/drm_vm.c b/drivers/gpu/drm/drm_vm.c
index c3b13fb41d0c..3778360eceea 100644
--- a/drivers/gpu/drm/drm_vm.c
+++ b/drivers/gpu/drm/drm_vm.c
@@ -61,7 +61,7 @@ static pgprot_t drm_io_prot(uint32_t map_type, struct vm_area_struct *vma)
61 tmp = pgprot_writecombine(tmp); 61 tmp = pgprot_writecombine(tmp);
62 else 62 else
63 tmp = pgprot_noncached(tmp); 63 tmp = pgprot_noncached(tmp);
64#elif defined(__sparc__) 64#elif defined(__sparc__) || defined(__arm__)
65 tmp = pgprot_noncached(tmp); 65 tmp = pgprot_noncached(tmp);
66#endif 66#endif
67 return tmp; 67 return tmp;
@@ -601,6 +601,7 @@ int drm_mmap_locked(struct file *filp, struct vm_area_struct *vma)
601 } 601 }
602 602
603 switch (map->type) { 603 switch (map->type) {
604#if !defined(__arm__)
604 case _DRM_AGP: 605 case _DRM_AGP:
605 if (drm_core_has_AGP(dev) && dev->agp->cant_use_aperture) { 606 if (drm_core_has_AGP(dev) && dev->agp->cant_use_aperture) {
606 /* 607 /*
@@ -615,20 +616,31 @@ int drm_mmap_locked(struct file *filp, struct vm_area_struct *vma)
615 break; 616 break;
616 } 617 }
617 /* fall through to _DRM_FRAME_BUFFER... */ 618 /* fall through to _DRM_FRAME_BUFFER... */
619#endif
618 case _DRM_FRAME_BUFFER: 620 case _DRM_FRAME_BUFFER:
619 case _DRM_REGISTERS: 621 case _DRM_REGISTERS:
620 offset = dev->driver->get_reg_ofs(dev); 622 offset = dev->driver->get_reg_ofs(dev);
621 vma->vm_flags |= VM_IO; /* not in core dump */ 623 vma->vm_flags |= VM_IO; /* not in core dump */
622 vma->vm_page_prot = drm_io_prot(map->type, vma); 624 vma->vm_page_prot = drm_io_prot(map->type, vma);
625#if !defined(__arm__)
623 if (io_remap_pfn_range(vma, vma->vm_start, 626 if (io_remap_pfn_range(vma, vma->vm_start,
624 (map->offset + offset) >> PAGE_SHIFT, 627 (map->offset + offset) >> PAGE_SHIFT,
625 vma->vm_end - vma->vm_start, 628 vma->vm_end - vma->vm_start,
626 vma->vm_page_prot)) 629 vma->vm_page_prot))
627 return -EAGAIN; 630 return -EAGAIN;
631#else
632 if (remap_pfn_range(vma, vma->vm_start,
633 (map->offset + offset) >> PAGE_SHIFT,
634 vma->vm_end - vma->vm_start,
635 vma->vm_page_prot))
636 return -EAGAIN;
637#endif
638
628 DRM_DEBUG(" Type = %d; start = 0x%lx, end = 0x%lx," 639 DRM_DEBUG(" Type = %d; start = 0x%lx, end = 0x%lx,"
629 " offset = 0x%llx\n", 640 " offset = 0x%llx\n",
630 map->type, 641 map->type,
631 vma->vm_start, vma->vm_end, (unsigned long long)(map->offset + offset)); 642 vma->vm_start, vma->vm_end, (unsigned long long)(map->offset + offset));
643
632 vma->vm_ops = &drm_vm_ops; 644 vma->vm_ops = &drm_vm_ops;
633 break; 645 break;
634 case _DRM_CONSISTENT: 646 case _DRM_CONSISTENT:
diff --git a/drivers/gpu/drm/i915/i915_dma.c b/drivers/gpu/drm/i915/i915_dma.c
index f00c5ae9556c..92898035845d 100644
--- a/drivers/gpu/drm/i915/i915_dma.c
+++ b/drivers/gpu/drm/i915/i915_dma.c
@@ -34,6 +34,7 @@
34#include "i915_drm.h" 34#include "i915_drm.h"
35#include "i915_drv.h" 35#include "i915_drv.h"
36#include "i915_trace.h" 36#include "i915_trace.h"
37#include <linux/pci.h>
37#include <linux/vgaarb.h> 38#include <linux/vgaarb.h>
38#include <linux/acpi.h> 39#include <linux/acpi.h>
39#include <linux/pnp.h> 40#include <linux/pnp.h>
@@ -1354,7 +1355,7 @@ static int i915_load_modeset_init(struct drm_device *dev,
1354 int fb_bar = IS_I9XX(dev) ? 2 : 0; 1355 int fb_bar = IS_I9XX(dev) ? 2 : 0;
1355 int ret = 0; 1356 int ret = 0;
1356 1357
1357 dev->mode_config.fb_base = drm_get_resource_start(dev, fb_bar) & 1358 dev->mode_config.fb_base = pci_resource_start(dev->pdev, fb_bar) &
1358 0xff000000; 1359 0xff000000;
1359 1360
1360 /* Basic memrange allocator for stolen space (aka vram) */ 1361 /* Basic memrange allocator for stolen space (aka vram) */
@@ -2063,8 +2064,8 @@ int i915_driver_load(struct drm_device *dev, unsigned long flags)
2063 2064
2064 /* Add register map (needed for suspend/resume) */ 2065 /* Add register map (needed for suspend/resume) */
2065 mmio_bar = IS_I9XX(dev) ? 0 : 1; 2066 mmio_bar = IS_I9XX(dev) ? 0 : 1;
2066 base = drm_get_resource_start(dev, mmio_bar); 2067 base = pci_resource_start(dev->pdev, mmio_bar);
2067 size = drm_get_resource_len(dev, mmio_bar); 2068 size = pci_resource_len(dev->pdev, mmio_bar);
2068 2069
2069 if (i915_get_bridge_dev(dev)) { 2070 if (i915_get_bridge_dev(dev)) {
2070 ret = -EIO; 2071 ret = -EIO;
diff --git a/drivers/gpu/drm/i915/i915_drv.c b/drivers/gpu/drm/i915/i915_drv.c
index 423dc90c1e20..65d3f3e8475b 100644
--- a/drivers/gpu/drm/i915/i915_drv.c
+++ b/drivers/gpu/drm/i915/i915_drv.c
@@ -413,7 +413,7 @@ int i965_reset(struct drm_device *dev, u8 flags)
413static int __devinit 413static int __devinit
414i915_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent) 414i915_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
415{ 415{
416 return drm_get_dev(pdev, ent, &driver); 416 return drm_get_pci_dev(pdev, ent, &driver);
417} 417}
418 418
419static void 419static void
diff --git a/drivers/gpu/drm/mga/mga_dma.c b/drivers/gpu/drm/mga/mga_dma.c
index 3c917fb3a60b..ccc129c328a4 100644
--- a/drivers/gpu/drm/mga/mga_dma.c
+++ b/drivers/gpu/drm/mga/mga_dma.c
@@ -405,8 +405,8 @@ int mga_driver_load(struct drm_device * dev, unsigned long flags)
405 dev_priv->usec_timeout = MGA_DEFAULT_USEC_TIMEOUT; 405 dev_priv->usec_timeout = MGA_DEFAULT_USEC_TIMEOUT;
406 dev_priv->chipset = flags; 406 dev_priv->chipset = flags;
407 407
408 dev_priv->mmio_base = drm_get_resource_start(dev, 1); 408 dev_priv->mmio_base = pci_resource_start(dev->pdev, 1);
409 dev_priv->mmio_size = drm_get_resource_len(dev, 1); 409 dev_priv->mmio_size = pci_resource_len(dev->pdev, 1);
410 410
411 dev->counters += 3; 411 dev->counters += 3;
412 dev->types[6] = _DRM_STAT_IRQ; 412 dev->types[6] = _DRM_STAT_IRQ;
diff --git a/drivers/gpu/drm/nouveau/nouveau_bo.c b/drivers/gpu/drm/nouveau/nouveau_bo.c
index 6f3c19522377..9f5ab4677758 100644
--- a/drivers/gpu/drm/nouveau/nouveau_bo.c
+++ b/drivers/gpu/drm/nouveau/nouveau_bo.c
@@ -783,7 +783,7 @@ nouveau_ttm_io_mem_reserve(struct ttm_bo_device *bdev, struct ttm_mem_reg *mem)
783 break; 783 break;
784 case TTM_PL_VRAM: 784 case TTM_PL_VRAM:
785 mem->bus.offset = mem->mm_node->start << PAGE_SHIFT; 785 mem->bus.offset = mem->mm_node->start << PAGE_SHIFT;
786 mem->bus.base = drm_get_resource_start(dev, 1); 786 mem->bus.base = pci_resource_start(dev->pdev, 1);
787 mem->bus.is_iomem = true; 787 mem->bus.is_iomem = true;
788 break; 788 break;
789 default: 789 default:
diff --git a/drivers/gpu/drm/nouveau/nouveau_channel.c b/drivers/gpu/drm/nouveau/nouveau_channel.c
index 1fc57ef58295..06555c7cde50 100644
--- a/drivers/gpu/drm/nouveau/nouveau_channel.c
+++ b/drivers/gpu/drm/nouveau/nouveau_channel.c
@@ -62,7 +62,8 @@ nouveau_channel_pushbuf_ctxdma_init(struct nouveau_channel *chan)
62 * VRAM. 62 * VRAM.
63 */ 63 */
64 ret = nouveau_gpuobj_dma_new(chan, NV_CLASS_DMA_IN_MEMORY, 64 ret = nouveau_gpuobj_dma_new(chan, NV_CLASS_DMA_IN_MEMORY,
65 drm_get_resource_start(dev, 1), 65 pci_resource_start(dev->pdev,
66 1),
66 dev_priv->fb_available_size, 67 dev_priv->fb_available_size,
67 NV_DMA_ACCESS_RO, 68 NV_DMA_ACCESS_RO,
68 NV_DMA_TARGET_PCI, &pushbuf); 69 NV_DMA_TARGET_PCI, &pushbuf);
diff --git a/drivers/gpu/drm/nouveau/nouveau_drv.c b/drivers/gpu/drm/nouveau/nouveau_drv.c
index 273770432298..0fd8e10dbbde 100644
--- a/drivers/gpu/drm/nouveau/nouveau_drv.c
+++ b/drivers/gpu/drm/nouveau/nouveau_drv.c
@@ -132,7 +132,7 @@ static struct drm_driver driver;
132static int __devinit 132static int __devinit
133nouveau_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent) 133nouveau_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
134{ 134{
135 return drm_get_dev(pdev, ent, &driver); 135 return drm_get_pci_dev(pdev, ent, &driver);
136} 136}
137 137
138static void 138static void
diff --git a/drivers/gpu/drm/nouveau/nouveau_mem.c b/drivers/gpu/drm/nouveau/nouveau_mem.c
index c1fd42b0dad1..fb6b791506b2 100644
--- a/drivers/gpu/drm/nouveau/nouveau_mem.c
+++ b/drivers/gpu/drm/nouveau/nouveau_mem.c
@@ -471,8 +471,9 @@ void nouveau_mem_close(struct drm_device *dev)
471 } 471 }
472 472
473 if (dev_priv->fb_mtrr) { 473 if (dev_priv->fb_mtrr) {
474 drm_mtrr_del(dev_priv->fb_mtrr, drm_get_resource_start(dev, 1), 474 drm_mtrr_del(dev_priv->fb_mtrr,
475 drm_get_resource_len(dev, 1), DRM_MTRR_WC); 475 pci_resource_start(dev->pdev, 1),
476 pci_resource_len(dev->pdev, 1), DRM_MTRR_WC);
476 dev_priv->fb_mtrr = 0; 477 dev_priv->fb_mtrr = 0;
477 } 478 }
478} 479}
@@ -633,7 +634,7 @@ nouveau_mem_init(struct drm_device *dev)
633 struct ttm_bo_device *bdev = &dev_priv->ttm.bdev; 634 struct ttm_bo_device *bdev = &dev_priv->ttm.bdev;
634 int ret, dma_bits = 32; 635 int ret, dma_bits = 32;
635 636
636 dev_priv->fb_phys = drm_get_resource_start(dev, 1); 637 dev_priv->fb_phys = pci_resource_start(dev->pdev, 1);
637 dev_priv->gart_info.type = NOUVEAU_GART_NONE; 638 dev_priv->gart_info.type = NOUVEAU_GART_NONE;
638 639
639 if (dev_priv->card_type >= NV_50 && 640 if (dev_priv->card_type >= NV_50 &&
@@ -665,8 +666,9 @@ nouveau_mem_init(struct drm_device *dev)
665 666
666 dev_priv->fb_available_size = dev_priv->vram_size; 667 dev_priv->fb_available_size = dev_priv->vram_size;
667 dev_priv->fb_mappable_pages = dev_priv->fb_available_size; 668 dev_priv->fb_mappable_pages = dev_priv->fb_available_size;
668 if (dev_priv->fb_mappable_pages > drm_get_resource_len(dev, 1)) 669 if (dev_priv->fb_mappable_pages > pci_resource_len(dev->pdev, 1))
669 dev_priv->fb_mappable_pages = drm_get_resource_len(dev, 1); 670 dev_priv->fb_mappable_pages =
671 pci_resource_len(dev->pdev, 1);
670 dev_priv->fb_mappable_pages >>= PAGE_SHIFT; 672 dev_priv->fb_mappable_pages >>= PAGE_SHIFT;
671 673
672 /* remove reserved space at end of vram from available amount */ 674 /* remove reserved space at end of vram from available amount */
@@ -718,8 +720,8 @@ nouveau_mem_init(struct drm_device *dev)
718 return ret; 720 return ret;
719 } 721 }
720 722
721 dev_priv->fb_mtrr = drm_mtrr_add(drm_get_resource_start(dev, 1), 723 dev_priv->fb_mtrr = drm_mtrr_add(pci_resource_start(dev->pdev, 1),
722 drm_get_resource_len(dev, 1), 724 pci_resource_len(dev->pdev, 1),
723 DRM_MTRR_WC); 725 DRM_MTRR_WC);
724 726
725 return 0; 727 return 0;
diff --git a/drivers/gpu/drm/nouveau/nv20_graph.c b/drivers/gpu/drm/nouveau/nv20_graph.c
index d6fc0a82f03d..fe2349b115f0 100644
--- a/drivers/gpu/drm/nouveau/nv20_graph.c
+++ b/drivers/gpu/drm/nouveau/nv20_graph.c
@@ -616,7 +616,7 @@ nv20_graph_init(struct drm_device *dev)
616 nv_wr32(dev, NV10_PGRAPH_SURFACE, tmp); 616 nv_wr32(dev, NV10_PGRAPH_SURFACE, tmp);
617 617
618 /* begin RAM config */ 618 /* begin RAM config */
619 vramsz = drm_get_resource_len(dev, 0) - 1; 619 vramsz = pci_resource_len(dev->pdev, 0) - 1;
620 nv_wr32(dev, 0x4009A4, nv_rd32(dev, NV04_PFB_CFG0)); 620 nv_wr32(dev, 0x4009A4, nv_rd32(dev, NV04_PFB_CFG0));
621 nv_wr32(dev, 0x4009A8, nv_rd32(dev, NV04_PFB_CFG1)); 621 nv_wr32(dev, 0x4009A8, nv_rd32(dev, NV04_PFB_CFG1));
622 nv_wr32(dev, NV10_PGRAPH_RDI_INDEX, 0x00EA0000); 622 nv_wr32(dev, NV10_PGRAPH_RDI_INDEX, 0x00EA0000);
@@ -717,7 +717,7 @@ nv30_graph_init(struct drm_device *dev)
717 nv_wr32(dev, 0x0040075c , 0x00000001); 717 nv_wr32(dev, 0x0040075c , 0x00000001);
718 718
719 /* begin RAM config */ 719 /* begin RAM config */
720 /* vramsz = drm_get_resource_len(dev, 0) - 1; */ 720 /* vramsz = pci_resource_len(dev->pdev, 0) - 1; */
721 nv_wr32(dev, 0x4009A4, nv_rd32(dev, NV04_PFB_CFG0)); 721 nv_wr32(dev, 0x4009A4, nv_rd32(dev, NV04_PFB_CFG0));
722 nv_wr32(dev, 0x4009A8, nv_rd32(dev, NV04_PFB_CFG1)); 722 nv_wr32(dev, 0x4009A8, nv_rd32(dev, NV04_PFB_CFG1));
723 if (dev_priv->chipset != 0x34) { 723 if (dev_priv->chipset != 0x34) {
diff --git a/drivers/gpu/drm/nouveau/nv40_graph.c b/drivers/gpu/drm/nouveau/nv40_graph.c
index 704a25d04ac9..65b13b54c5ae 100644
--- a/drivers/gpu/drm/nouveau/nv40_graph.c
+++ b/drivers/gpu/drm/nouveau/nv40_graph.c
@@ -367,7 +367,7 @@ nv40_graph_init(struct drm_device *dev)
367 nv40_graph_set_region_tiling(dev, i, 0, 0, 0); 367 nv40_graph_set_region_tiling(dev, i, 0, 0, 0);
368 368
369 /* begin RAM config */ 369 /* begin RAM config */
370 vramsz = drm_get_resource_len(dev, 0) - 1; 370 vramsz = pci_resource_len(dev->pdev, 0) - 1;
371 switch (dev_priv->chipset) { 371 switch (dev_priv->chipset) {
372 case 0x40: 372 case 0x40:
373 nv_wr32(dev, 0x4009A4, nv_rd32(dev, NV04_PFB_CFG0)); 373 nv_wr32(dev, 0x4009A4, nv_rd32(dev, NV04_PFB_CFG0));
diff --git a/drivers/gpu/drm/nouveau/nv50_instmem.c b/drivers/gpu/drm/nouveau/nv50_instmem.c
index 5f21df31f3aa..71c01b6e5731 100644
--- a/drivers/gpu/drm/nouveau/nv50_instmem.c
+++ b/drivers/gpu/drm/nouveau/nv50_instmem.c
@@ -241,7 +241,7 @@ nv50_instmem_init(struct drm_device *dev)
241 return ret; 241 return ret;
242 BAR0_WI32(priv->fb_bar->gpuobj, 0x00, 0x7fc00000); 242 BAR0_WI32(priv->fb_bar->gpuobj, 0x00, 0x7fc00000);
243 BAR0_WI32(priv->fb_bar->gpuobj, 0x04, 0x40000000 + 243 BAR0_WI32(priv->fb_bar->gpuobj, 0x04, 0x40000000 +
244 drm_get_resource_len(dev, 1) - 1); 244 pci_resource_len(dev->pdev, 1) - 1);
245 BAR0_WI32(priv->fb_bar->gpuobj, 0x08, 0x40000000); 245 BAR0_WI32(priv->fb_bar->gpuobj, 0x08, 0x40000000);
246 BAR0_WI32(priv->fb_bar->gpuobj, 0x0c, 0x00000000); 246 BAR0_WI32(priv->fb_bar->gpuobj, 0x0c, 0x00000000);
247 BAR0_WI32(priv->fb_bar->gpuobj, 0x10, 0x00000000); 247 BAR0_WI32(priv->fb_bar->gpuobj, 0x10, 0x00000000);
diff --git a/drivers/gpu/drm/radeon/evergreen.c b/drivers/gpu/drm/radeon/evergreen.c
index 1caf625e472b..057192acdd36 100644
--- a/drivers/gpu/drm/radeon/evergreen.c
+++ b/drivers/gpu/drm/radeon/evergreen.c
@@ -1334,8 +1334,8 @@ int evergreen_mc_init(struct radeon_device *rdev)
1334 } 1334 }
1335 rdev->mc.vram_width = numchan * chansize; 1335 rdev->mc.vram_width = numchan * chansize;
1336 /* Could aper size report 0 ? */ 1336 /* Could aper size report 0 ? */
1337 rdev->mc.aper_base = drm_get_resource_start(rdev->ddev, 0); 1337 rdev->mc.aper_base = pci_resource_start(rdev->pdev, 0);
1338 rdev->mc.aper_size = drm_get_resource_len(rdev->ddev, 0); 1338 rdev->mc.aper_size = pci_resource_len(rdev->pdev, 0);
1339 /* Setup GPU memory space */ 1339 /* Setup GPU memory space */
1340 /* size in MB on evergreen */ 1340 /* size in MB on evergreen */
1341 rdev->mc.mc_vram_size = RREG32(CONFIG_MEMSIZE) * 1024 * 1024; 1341 rdev->mc.mc_vram_size = RREG32(CONFIG_MEMSIZE) * 1024 * 1024;
diff --git a/drivers/gpu/drm/radeon/r100.c b/drivers/gpu/drm/radeon/r100.c
index 3970e62eaab8..ab37717a5d39 100644
--- a/drivers/gpu/drm/radeon/r100.c
+++ b/drivers/gpu/drm/radeon/r100.c
@@ -2297,8 +2297,8 @@ void r100_vram_init_sizes(struct radeon_device *rdev)
2297 u64 config_aper_size; 2297 u64 config_aper_size;
2298 2298
2299 /* work out accessible VRAM */ 2299 /* work out accessible VRAM */
2300 rdev->mc.aper_base = drm_get_resource_start(rdev->ddev, 0); 2300 rdev->mc.aper_base = pci_resource_start(rdev->pdev, 0);
2301 rdev->mc.aper_size = drm_get_resource_len(rdev->ddev, 0); 2301 rdev->mc.aper_size = pci_resource_len(rdev->pdev, 0);
2302 rdev->mc.visible_vram_size = r100_get_accessible_vram(rdev); 2302 rdev->mc.visible_vram_size = r100_get_accessible_vram(rdev);
2303 /* FIXME we don't use the second aperture yet when we could use it */ 2303 /* FIXME we don't use the second aperture yet when we could use it */
2304 if (rdev->mc.visible_vram_size > rdev->mc.aper_size) 2304 if (rdev->mc.visible_vram_size > rdev->mc.aper_size)
diff --git a/drivers/gpu/drm/radeon/r600.c b/drivers/gpu/drm/radeon/r600.c
index 3d6645ce2151..a73a6e17588d 100644
--- a/drivers/gpu/drm/radeon/r600.c
+++ b/drivers/gpu/drm/radeon/r600.c
@@ -1216,8 +1216,8 @@ int r600_mc_init(struct radeon_device *rdev)
1216 } 1216 }
1217 rdev->mc.vram_width = numchan * chansize; 1217 rdev->mc.vram_width = numchan * chansize;
1218 /* Could aper size report 0 ? */ 1218 /* Could aper size report 0 ? */
1219 rdev->mc.aper_base = drm_get_resource_start(rdev->ddev, 0); 1219 rdev->mc.aper_base = pci_resource_start(rdev->pdev, 0);
1220 rdev->mc.aper_size = drm_get_resource_len(rdev->ddev, 0); 1220 rdev->mc.aper_size = pci_resource_len(rdev->pdev, 0);
1221 /* Setup GPU memory space */ 1221 /* Setup GPU memory space */
1222 rdev->mc.mc_vram_size = RREG32(CONFIG_MEMSIZE); 1222 rdev->mc.mc_vram_size = RREG32(CONFIG_MEMSIZE);
1223 rdev->mc.real_vram_size = RREG32(CONFIG_MEMSIZE); 1223 rdev->mc.real_vram_size = RREG32(CONFIG_MEMSIZE);
diff --git a/drivers/gpu/drm/radeon/radeon_bios.c b/drivers/gpu/drm/radeon/radeon_bios.c
index 2c9213739999..654787ec43f4 100644
--- a/drivers/gpu/drm/radeon/radeon_bios.c
+++ b/drivers/gpu/drm/radeon/radeon_bios.c
@@ -53,7 +53,7 @@ static bool igp_read_bios_from_vram(struct radeon_device *rdev)
53 return false; 53 return false;
54 54
55 rdev->bios = NULL; 55 rdev->bios = NULL;
56 vram_base = drm_get_resource_start(rdev->ddev, 0); 56 vram_base = pci_resource_start(rdev->pdev, 0);
57 bios = ioremap(vram_base, size); 57 bios = ioremap(vram_base, size);
58 if (!bios) { 58 if (!bios) {
59 return false; 59 return false;
diff --git a/drivers/gpu/drm/radeon/radeon_cp.c b/drivers/gpu/drm/radeon/radeon_cp.c
index 2f042a3c0e62..eb6b9eed7349 100644
--- a/drivers/gpu/drm/radeon/radeon_cp.c
+++ b/drivers/gpu/drm/radeon/radeon_cp.c
@@ -2120,8 +2120,8 @@ int radeon_driver_load(struct drm_device *dev, unsigned long flags)
2120 else 2120 else
2121 dev_priv->flags |= RADEON_IS_PCI; 2121 dev_priv->flags |= RADEON_IS_PCI;
2122 2122
2123 ret = drm_addmap(dev, drm_get_resource_start(dev, 2), 2123 ret = drm_addmap(dev, pci_resource_start(dev->pdev, 2),
2124 drm_get_resource_len(dev, 2), _DRM_REGISTERS, 2124 pci_resource_len(dev->pdev, 2), _DRM_REGISTERS,
2125 _DRM_READ_ONLY | _DRM_DRIVER, &dev_priv->mmio); 2125 _DRM_READ_ONLY | _DRM_DRIVER, &dev_priv->mmio);
2126 if (ret != 0) 2126 if (ret != 0)
2127 return ret; 2127 return ret;
@@ -2194,9 +2194,9 @@ int radeon_driver_firstopen(struct drm_device *dev)
2194 2194
2195 dev_priv->gart_info.table_size = RADEON_PCIGART_TABLE_SIZE; 2195 dev_priv->gart_info.table_size = RADEON_PCIGART_TABLE_SIZE;
2196 2196
2197 dev_priv->fb_aper_offset = drm_get_resource_start(dev, 0); 2197 dev_priv->fb_aper_offset = pci_resource_start(dev->pdev, 0);
2198 ret = drm_addmap(dev, dev_priv->fb_aper_offset, 2198 ret = drm_addmap(dev, dev_priv->fb_aper_offset,
2199 drm_get_resource_len(dev, 0), _DRM_FRAME_BUFFER, 2199 pci_resource_len(dev->pdev, 0), _DRM_FRAME_BUFFER,
2200 _DRM_WRITE_COMBINING, &map); 2200 _DRM_WRITE_COMBINING, &map);
2201 if (ret != 0) 2201 if (ret != 0)
2202 return ret; 2202 return ret;
diff --git a/drivers/gpu/drm/radeon/radeon_device.c b/drivers/gpu/drm/radeon/radeon_device.c
index 5f317317aba2..37533bec1f25 100644
--- a/drivers/gpu/drm/radeon/radeon_device.c
+++ b/drivers/gpu/drm/radeon/radeon_device.c
@@ -650,8 +650,8 @@ int radeon_device_init(struct radeon_device *rdev,
650 650
651 /* Registers mapping */ 651 /* Registers mapping */
652 /* TODO: block userspace mapping of io register */ 652 /* TODO: block userspace mapping of io register */
653 rdev->rmmio_base = drm_get_resource_start(rdev->ddev, 2); 653 rdev->rmmio_base = pci_resource_start(rdev->pdev, 2);
654 rdev->rmmio_size = drm_get_resource_len(rdev->ddev, 2); 654 rdev->rmmio_size = pci_resource_len(rdev->pdev, 2);
655 rdev->rmmio = ioremap(rdev->rmmio_base, rdev->rmmio_size); 655 rdev->rmmio = ioremap(rdev->rmmio_base, rdev->rmmio_size);
656 if (rdev->rmmio == NULL) { 656 if (rdev->rmmio == NULL) {
657 return -ENOMEM; 657 return -ENOMEM;
diff --git a/drivers/gpu/drm/radeon/radeon_drv.c b/drivers/gpu/drm/radeon/radeon_drv.c
index e166fe4d7c30..ed0ceb3fc40a 100644
--- a/drivers/gpu/drm/radeon/radeon_drv.c
+++ b/drivers/gpu/drm/radeon/radeon_drv.c
@@ -238,7 +238,7 @@ static struct drm_driver kms_driver;
238static int __devinit 238static int __devinit
239radeon_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent) 239radeon_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
240{ 240{
241 return drm_get_dev(pdev, ent, &kms_driver); 241 return drm_get_pci_dev(pdev, ent, &kms_driver);
242} 242}
243 243
244static void 244static void
diff --git a/drivers/gpu/drm/radeon/rs600.c b/drivers/gpu/drm/radeon/rs600.c
index 7bb4c3e52f3b..5ce3ccc7a423 100644
--- a/drivers/gpu/drm/radeon/rs600.c
+++ b/drivers/gpu/drm/radeon/rs600.c
@@ -686,8 +686,8 @@ void rs600_mc_init(struct radeon_device *rdev)
686{ 686{
687 u64 base; 687 u64 base;
688 688
689 rdev->mc.aper_base = drm_get_resource_start(rdev->ddev, 0); 689 rdev->mc.aper_base = pci_resource_start(rdev->pdev, 0);
690 rdev->mc.aper_size = drm_get_resource_len(rdev->ddev, 0); 690 rdev->mc.aper_size = pci_resource_len(rdev->pdev, 0);
691 rdev->mc.vram_is_ddr = true; 691 rdev->mc.vram_is_ddr = true;
692 rdev->mc.vram_width = 128; 692 rdev->mc.vram_width = 128;
693 rdev->mc.real_vram_size = RREG32(RADEON_CONFIG_MEMSIZE); 693 rdev->mc.real_vram_size = RREG32(RADEON_CONFIG_MEMSIZE);
diff --git a/drivers/gpu/drm/radeon/rs690.c b/drivers/gpu/drm/radeon/rs690.c
index f4f0a61bcdce..5fea094ed8cb 100644
--- a/drivers/gpu/drm/radeon/rs690.c
+++ b/drivers/gpu/drm/radeon/rs690.c
@@ -154,8 +154,8 @@ void rs690_mc_init(struct radeon_device *rdev)
154 rdev->mc.vram_width = 128; 154 rdev->mc.vram_width = 128;
155 rdev->mc.real_vram_size = RREG32(RADEON_CONFIG_MEMSIZE); 155 rdev->mc.real_vram_size = RREG32(RADEON_CONFIG_MEMSIZE);
156 rdev->mc.mc_vram_size = rdev->mc.real_vram_size; 156 rdev->mc.mc_vram_size = rdev->mc.real_vram_size;
157 rdev->mc.aper_base = drm_get_resource_start(rdev->ddev, 0); 157 rdev->mc.aper_base = pci_resource_start(rdev->pdev, 0);
158 rdev->mc.aper_size = drm_get_resource_len(rdev->ddev, 0); 158 rdev->mc.aper_size = pci_resource_len(rdev->pdev, 0);
159 rdev->mc.visible_vram_size = rdev->mc.aper_size; 159 rdev->mc.visible_vram_size = rdev->mc.aper_size;
160 base = RREG32_MC(R_000100_MCCFG_FB_LOCATION); 160 base = RREG32_MC(R_000100_MCCFG_FB_LOCATION);
161 base = G_000100_MC_FB_START(base) << 16; 161 base = G_000100_MC_FB_START(base) << 16;
diff --git a/drivers/gpu/drm/radeon/rv770.c b/drivers/gpu/drm/radeon/rv770.c
index b7fd82064922..6a7bf1091971 100644
--- a/drivers/gpu/drm/radeon/rv770.c
+++ b/drivers/gpu/drm/radeon/rv770.c
@@ -919,8 +919,8 @@ int rv770_mc_init(struct radeon_device *rdev)
919 } 919 }
920 rdev->mc.vram_width = numchan * chansize; 920 rdev->mc.vram_width = numchan * chansize;
921 /* Could aper size report 0 ? */ 921 /* Could aper size report 0 ? */
922 rdev->mc.aper_base = drm_get_resource_start(rdev->ddev, 0); 922 rdev->mc.aper_base = pci_resource_start(rdev->pdev, 0);
923 rdev->mc.aper_size = drm_get_resource_len(rdev->ddev, 0); 923 rdev->mc.aper_size = pci_resource_len(rdev->pdev, 0);
924 /* Setup GPU memory space */ 924 /* Setup GPU memory space */
925 rdev->mc.mc_vram_size = RREG32(CONFIG_MEMSIZE); 925 rdev->mc.mc_vram_size = RREG32(CONFIG_MEMSIZE);
926 rdev->mc.real_vram_size = RREG32(CONFIG_MEMSIZE); 926 rdev->mc.real_vram_size = RREG32(CONFIG_MEMSIZE);
diff --git a/drivers/gpu/drm/savage/savage_bci.c b/drivers/gpu/drm/savage/savage_bci.c
index 2d0c9ca484c5..f576232846c3 100644
--- a/drivers/gpu/drm/savage/savage_bci.c
+++ b/drivers/gpu/drm/savage/savage_bci.c
@@ -573,13 +573,13 @@ int savage_driver_firstopen(struct drm_device *dev)
573 dev_priv->mtrr[2].handle = -1; 573 dev_priv->mtrr[2].handle = -1;
574 if (S3_SAVAGE3D_SERIES(dev_priv->chipset)) { 574 if (S3_SAVAGE3D_SERIES(dev_priv->chipset)) {
575 fb_rsrc = 0; 575 fb_rsrc = 0;
576 fb_base = drm_get_resource_start(dev, 0); 576 fb_base = pci_resource_start(dev->pdev, 0);
577 fb_size = SAVAGE_FB_SIZE_S3; 577 fb_size = SAVAGE_FB_SIZE_S3;
578 mmio_base = fb_base + SAVAGE_FB_SIZE_S3; 578 mmio_base = fb_base + SAVAGE_FB_SIZE_S3;
579 aper_rsrc = 0; 579 aper_rsrc = 0;
580 aperture_base = fb_base + SAVAGE_APERTURE_OFFSET; 580 aperture_base = fb_base + SAVAGE_APERTURE_OFFSET;
581 /* this should always be true */ 581 /* this should always be true */
582 if (drm_get_resource_len(dev, 0) == 0x08000000) { 582 if (pci_resource_len(dev->pdev, 0) == 0x08000000) {
583 /* Don't make MMIO write-cobining! We need 3 583 /* Don't make MMIO write-cobining! We need 3
584 * MTRRs. */ 584 * MTRRs. */
585 dev_priv->mtrr[0].base = fb_base; 585 dev_priv->mtrr[0].base = fb_base;
@@ -599,18 +599,19 @@ int savage_driver_firstopen(struct drm_device *dev)
599 dev_priv->mtrr[2].size, DRM_MTRR_WC); 599 dev_priv->mtrr[2].size, DRM_MTRR_WC);
600 } else { 600 } else {
601 DRM_ERROR("strange pci_resource_len %08llx\n", 601 DRM_ERROR("strange pci_resource_len %08llx\n",
602 (unsigned long long)drm_get_resource_len(dev, 0)); 602 (unsigned long long)
603 pci_resource_len(dev->pdev, 0));
603 } 604 }
604 } else if (dev_priv->chipset != S3_SUPERSAVAGE && 605 } else if (dev_priv->chipset != S3_SUPERSAVAGE &&
605 dev_priv->chipset != S3_SAVAGE2000) { 606 dev_priv->chipset != S3_SAVAGE2000) {
606 mmio_base = drm_get_resource_start(dev, 0); 607 mmio_base = pci_resource_start(dev->pdev, 0);
607 fb_rsrc = 1; 608 fb_rsrc = 1;
608 fb_base = drm_get_resource_start(dev, 1); 609 fb_base = pci_resource_start(dev->pdev, 1);
609 fb_size = SAVAGE_FB_SIZE_S4; 610 fb_size = SAVAGE_FB_SIZE_S4;
610 aper_rsrc = 1; 611 aper_rsrc = 1;
611 aperture_base = fb_base + SAVAGE_APERTURE_OFFSET; 612 aperture_base = fb_base + SAVAGE_APERTURE_OFFSET;
612 /* this should always be true */ 613 /* this should always be true */
613 if (drm_get_resource_len(dev, 1) == 0x08000000) { 614 if (pci_resource_len(dev->pdev, 1) == 0x08000000) {
614 /* Can use one MTRR to cover both fb and 615 /* Can use one MTRR to cover both fb and
615 * aperture. */ 616 * aperture. */
616 dev_priv->mtrr[0].base = fb_base; 617 dev_priv->mtrr[0].base = fb_base;
@@ -620,15 +621,16 @@ int savage_driver_firstopen(struct drm_device *dev)
620 dev_priv->mtrr[0].size, DRM_MTRR_WC); 621 dev_priv->mtrr[0].size, DRM_MTRR_WC);
621 } else { 622 } else {
622 DRM_ERROR("strange pci_resource_len %08llx\n", 623 DRM_ERROR("strange pci_resource_len %08llx\n",
623 (unsigned long long)drm_get_resource_len(dev, 1)); 624 (unsigned long long)
625 pci_resource_len(dev->pdev, 1));
624 } 626 }
625 } else { 627 } else {
626 mmio_base = drm_get_resource_start(dev, 0); 628 mmio_base = pci_resource_start(dev->pdev, 0);
627 fb_rsrc = 1; 629 fb_rsrc = 1;
628 fb_base = drm_get_resource_start(dev, 1); 630 fb_base = pci_resource_start(dev->pdev, 1);
629 fb_size = drm_get_resource_len(dev, 1); 631 fb_size = pci_resource_len(dev->pdev, 1);
630 aper_rsrc = 2; 632 aper_rsrc = 2;
631 aperture_base = drm_get_resource_start(dev, 2); 633 aperture_base = pci_resource_start(dev->pdev, 2);
632 /* Automatic MTRR setup will do the right thing. */ 634 /* Automatic MTRR setup will do the right thing. */
633 } 635 }
634 636
diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_drv.c b/drivers/gpu/drm/vmwgfx/vmwgfx_drv.c
index b793c8c9acb3..9dd395b90216 100644
--- a/drivers/gpu/drm/vmwgfx/vmwgfx_drv.c
+++ b/drivers/gpu/drm/vmwgfx/vmwgfx_drv.c
@@ -764,7 +764,7 @@ static struct drm_driver driver = {
764 764
765static int vmw_probe(struct pci_dev *pdev, const struct pci_device_id *ent) 765static int vmw_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
766{ 766{
767 return drm_get_dev(pdev, ent, &driver); 767 return drm_get_pci_dev(pdev, ent, &driver);
768} 768}
769 769
770static int __init vmwgfx_init(void) 770static int __init vmwgfx_init(void)
diff --git a/include/drm/drmP.h b/include/drm/drmP.h
index c1b987158dfa..6235169d5950 100644
--- a/include/drm/drmP.h
+++ b/include/drm/drmP.h
@@ -9,6 +9,7 @@
9/* 9/*
10 * Copyright 1999 Precision Insight, Inc., Cedar Park, Texas. 10 * Copyright 1999 Precision Insight, Inc., Cedar Park, Texas.
11 * Copyright 2000 VA Linux Systems, Inc., Sunnyvale, California. 11 * Copyright 2000 VA Linux Systems, Inc., Sunnyvale, California.
12 * Copyright (c) 2009-2010, Code Aurora Forum.
12 * All rights reserved. 13 * All rights reserved.
13 * 14 *
14 * Permission is hereby granted, free of charge, to any person obtaining a 15 * Permission is hereby granted, free of charge, to any person obtaining a
@@ -48,6 +49,7 @@
48#include <linux/proc_fs.h> 49#include <linux/proc_fs.h>
49#include <linux/init.h> 50#include <linux/init.h>
50#include <linux/file.h> 51#include <linux/file.h>
52#include <linux/platform_device.h>
51#include <linux/pci.h> 53#include <linux/pci.h>
52#include <linux/jiffies.h> 54#include <linux/jiffies.h>
53#include <linux/smp_lock.h> /* For (un)lock_kernel */ 55#include <linux/smp_lock.h> /* For (un)lock_kernel */
@@ -144,6 +146,7 @@ extern void drm_ut_debug_printk(unsigned int request_level,
144#define DRIVER_IRQ_VBL2 0x800 146#define DRIVER_IRQ_VBL2 0x800
145#define DRIVER_GEM 0x1000 147#define DRIVER_GEM 0x1000
146#define DRIVER_MODESET 0x2000 148#define DRIVER_MODESET 0x2000
149#define DRIVER_USE_PLATFORM_DEVICE 0x4000
147 150
148/***********************************************************************/ 151/***********************************************************************/
149/** \name Begin the DRM... */ 152/** \name Begin the DRM... */
@@ -823,6 +826,7 @@ struct drm_driver {
823 int num_ioctls; 826 int num_ioctls;
824 struct file_operations fops; 827 struct file_operations fops;
825 struct pci_driver pci_driver; 828 struct pci_driver pci_driver;
829 struct platform_device *platform_device;
826 /* List of devices hanging off this driver */ 830 /* List of devices hanging off this driver */
827 struct list_head device_list; 831 struct list_head device_list;
828}; 832};
@@ -1015,12 +1019,16 @@ struct drm_device {
1015 1019
1016 struct drm_agp_head *agp; /**< AGP data */ 1020 struct drm_agp_head *agp; /**< AGP data */
1017 1021
1022 struct device *dev; /**< Device structure */
1018 struct pci_dev *pdev; /**< PCI device structure */ 1023 struct pci_dev *pdev; /**< PCI device structure */
1019 int pci_vendor; /**< PCI vendor id */ 1024 int pci_vendor; /**< PCI vendor id */
1020 int pci_device; /**< PCI device id */ 1025 int pci_device; /**< PCI device id */
1021#ifdef __alpha__ 1026#ifdef __alpha__
1022 struct pci_controller *hose; 1027 struct pci_controller *hose;
1023#endif 1028#endif
1029
1030 struct platform_device *platformdev; /**< Platform device struture */
1031
1024 struct drm_sg_mem *sg; /**< Scatter gather memory */ 1032 struct drm_sg_mem *sg; /**< Scatter gather memory */
1025 int num_crtcs; /**< Number of CRTCs on this device */ 1033 int num_crtcs; /**< Number of CRTCs on this device */
1026 void *dev_private; /**< device private data */ 1034 void *dev_private; /**< device private data */
@@ -1060,17 +1068,21 @@ struct drm_device {
1060 1068
1061}; 1069};
1062 1070
1063static inline int drm_dev_to_irq(struct drm_device *dev)
1064{
1065 return dev->pdev->irq;
1066}
1067
1068static __inline__ int drm_core_check_feature(struct drm_device *dev, 1071static __inline__ int drm_core_check_feature(struct drm_device *dev,
1069 int feature) 1072 int feature)
1070{ 1073{
1071 return ((dev->driver->driver_features & feature) ? 1 : 0); 1074 return ((dev->driver->driver_features & feature) ? 1 : 0);
1072} 1075}
1073 1076
1077
1078static inline int drm_dev_to_irq(struct drm_device *dev)
1079{
1080 if (drm_core_check_feature(dev, DRIVER_USE_PLATFORM_DEVICE))
1081 return platform_get_irq(dev->platformdev, 0);
1082 else
1083 return dev->pdev->irq;
1084}
1085
1074#ifdef __alpha__ 1086#ifdef __alpha__
1075#define drm_get_pci_domain(dev) dev->hose->index 1087#define drm_get_pci_domain(dev) dev->hose->index
1076#else 1088#else
@@ -1273,10 +1285,6 @@ extern int drm_freebufs(struct drm_device *dev, void *data,
1273extern int drm_mapbufs(struct drm_device *dev, void *data, 1285extern int drm_mapbufs(struct drm_device *dev, void *data,
1274 struct drm_file *file_priv); 1286 struct drm_file *file_priv);
1275extern int drm_order(unsigned long size); 1287extern int drm_order(unsigned long size);
1276extern resource_size_t drm_get_resource_start(struct drm_device *dev,
1277 unsigned int resource);
1278extern resource_size_t drm_get_resource_len(struct drm_device *dev,
1279 unsigned int resource);
1280 1288
1281 /* DMA support (drm_dma.h) */ 1289 /* DMA support (drm_dma.h) */
1282extern int drm_dma_setup(struct drm_device *dev); 1290extern int drm_dma_setup(struct drm_device *dev);
@@ -1351,8 +1359,11 @@ extern int drm_dropmaster_ioctl(struct drm_device *dev, void *data,
1351struct drm_master *drm_master_create(struct drm_minor *minor); 1359struct drm_master *drm_master_create(struct drm_minor *minor);
1352extern struct drm_master *drm_master_get(struct drm_master *master); 1360extern struct drm_master *drm_master_get(struct drm_master *master);
1353extern void drm_master_put(struct drm_master **master); 1361extern void drm_master_put(struct drm_master **master);
1354extern int drm_get_dev(struct pci_dev *pdev, const struct pci_device_id *ent, 1362extern int drm_get_pci_dev(struct pci_dev *pdev,
1355 struct drm_driver *driver); 1363 const struct pci_device_id *ent,
1364 struct drm_driver *driver);
1365extern int drm_get_platform_dev(struct platform_device *pdev,
1366 struct drm_driver *driver);
1356extern void drm_put_dev(struct drm_device *dev); 1367extern void drm_put_dev(struct drm_device *dev);
1357extern int drm_put_minor(struct drm_minor **minor); 1368extern int drm_put_minor(struct drm_minor **minor);
1358extern unsigned int drm_debug; 1369extern unsigned int drm_debug;
@@ -1529,6 +1540,9 @@ static __inline__ struct drm_local_map *drm_core_findmap(struct drm_device *dev,
1529 1540
1530static __inline__ int drm_device_is_agp(struct drm_device *dev) 1541static __inline__ int drm_device_is_agp(struct drm_device *dev)
1531{ 1542{
1543 if (drm_core_check_feature(dev, DRIVER_USE_PLATFORM_DEVICE))
1544 return 0;
1545
1532 if (dev->driver->device_is_agp != NULL) { 1546 if (dev->driver->device_is_agp != NULL) {
1533 int err = (*dev->driver->device_is_agp) (dev); 1547 int err = (*dev->driver->device_is_agp) (dev);
1534 1548
@@ -1542,7 +1556,10 @@ static __inline__ int drm_device_is_agp(struct drm_device *dev)
1542 1556
1543static __inline__ int drm_device_is_pcie(struct drm_device *dev) 1557static __inline__ int drm_device_is_pcie(struct drm_device *dev)
1544{ 1558{
1545 return pci_find_capability(dev->pdev, PCI_CAP_ID_EXP); 1559 if (drm_core_check_feature(dev, DRIVER_USE_PLATFORM_DEVICE))
1560 return 0;
1561 else
1562 return pci_find_capability(dev->pdev, PCI_CAP_ID_EXP);
1546} 1563}
1547 1564
1548static __inline__ void drm_core_dropmap(struct drm_local_map *map) 1565static __inline__ void drm_core_dropmap(struct drm_local_map *map)
@@ -1550,6 +1567,21 @@ static __inline__ void drm_core_dropmap(struct drm_local_map *map)
1550} 1567}
1551 1568
1552#include "drm_mem_util.h" 1569#include "drm_mem_util.h"
1570
1571static inline void *drm_get_device(struct drm_device *dev)
1572{
1573 if (drm_core_check_feature(dev, DRIVER_USE_PLATFORM_DEVICE))
1574 return dev->platformdev;
1575 else
1576 return dev->pdev;
1577}
1578
1579extern int drm_platform_init(struct drm_driver *driver);
1580extern int drm_pci_init(struct drm_driver *driver);
1581extern int drm_fill_in_dev(struct drm_device *dev,
1582 const struct pci_device_id *ent,
1583 struct drm_driver *driver);
1584int drm_get_minor(struct drm_device *dev, struct drm_minor **minor, int type);
1553/*@}*/ 1585/*@}*/
1554 1586
1555#endif /* __KERNEL__ */ 1587#endif /* __KERNEL__ */