linux-arm-msm.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* Re: [PATCH] drm: Allow platform devices to register as DRM devices
       [not found] ` <4B8BE489.7020402@codeaurora.org>
@ 2010-03-15  0:56   ` Dave Airlie
  2010-03-15 18:04     ` Jordan Crouse
  2010-03-16  2:41     ` Paul Mundt
  2010-03-15 19:27   ` Ville Syrjälä
                     ` (5 subsequent siblings)
  6 siblings, 2 replies; 17+ messages in thread
From: Dave Airlie @ 2010-03-15  0:56 UTC (permalink / raw)
  To: Jordan Crouse; +Cc: dri-devel, linux-kernel, linux-arm-msm

On Tue, Mar 2, 2010 at 2:00 AM, Jordan Crouse <jcrouse@codeaurora.org> wrote:
>
> Allow platform devices without PCI resources to be DRM devices.
>
> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org>

This patch has a bunch of whitespace damage at least in my inbox and
also in patchwork

Please also be careful with the places you add copyrights, you moved a
bunch of code
from drm_drv.c to drm_pci.c and added a copyright for Code Aurora in
drm_pci.c? You can
only assert copyright if you actually wrote the code, otherwise the patch
contains your authorship details and who contributed the code. I'm
guessing you might have
copyright over one file in this that being drm_platform.c, the rest
I'm less sure about.

I also wonder if we could/should separate the arm drm support out from
this patch (i.e.
the __arm__ changes).

Some other misc comments below:

>  #
>  menuconfig DRM
>        tristate "Direct Rendering Manager (XFree86 4.1.0 and higher DRI
> support)"
> -       depends on (AGP || AGP=n) && PCI && !EMULATED_CMPXCHG && MMU

>From what I can see the AGP || AGP==n is still required, you just want
to drop the PCI
dependancy??

> +       depends on !EMULATED_CMPXCHG && MMU
>
> diff --git a/drivers/gpu/drm/drm_bufs.c b/drivers/gpu/drm/drm_bufs.c
> index 8417cc4..4177f60 100644
> --- a/drivers/gpu/drm/drm_bufs.c
> +++ b/drivers/gpu/drm/drm_bufs.c
> @@ -11,6 +11,7 @@
>  *
>  * Copyright 1999, 2000 Precision Insight, Inc., Cedar Park, Texas.
>  * Copyright 2000 VA Linux Systems, Inc., Sunnyvale, California.
> + * Copyright (c) 2009, Code Aurora Forum.
>  * All Rights Reserved.

There have been much bigger changes to these files without copyright
additions, I'm not sure how big something needs to be but I'm not 100% sure
this comes close.

>
>  resource_size_t drm_get_resource_start(struct drm_device *dev, unsigned int
> resource)
>  {
> +       if (drm_core_check_feature(dev, DRIVER_USE_PLATFORM_DEVICE)) {
> +               struct resource *r;
> +               r = platform_get_resource(dev->platformdev, IORESOURCE_MEM,
> +                                            resource);
> +
> +               return r ? r->start : 0;
> +       }
> +
> +#ifdef CONFIG_PCI
>        return pci_resource_start(dev->pdev, resource);
> +#endif
> +
> +       return 0;
>  }
>  EXPORT_SYMBOL(drm_get_resource_start);
>
>  resource_size_t drm_get_resource_len(struct drm_device *dev, unsigned int
> resource)
>  {
> +       if (drm_core_check_feature(dev, DRIVER_USE_PLATFORM_DEVICE)) {
> +               struct resource *r;
> +               r = platform_get_resource(dev->platformdev, IORESOURCE_MEM,
> +                       resource);
> +
> +               return r ? (r->end - r->start) : 0;
> +       }
> +
> +#ifdef CONFIG_PCI
>        return pci_resource_len(dev->pdev, resource);
> +#endif
> +
> +       return 0;
>  }
>
>  EXPORT_SYMBOL(drm_get_resource_len);
> @@ -188,7 +213,7 @@ static int drm_addmap_core(struct drm_device * dev,
> resource_size_t offset,
>        switch (map->type) {
>        case _DRM_REGISTERS:
>        case _DRM_FRAME_BUFFER:
> -#if !defined(__sparc__) && !defined(__alpha__) && !defined(__ia64__) &&
> !defined(__powerpc64__) && !defined(__x86_64__)
> +#if !defined(__sparc__) && !defined(__alpha__) && !defined(__ia64__) &&
> !defined(__powerpc64__) && !defined(__x86_64__) && !defined(__arm__)
>                if (map->offset + (map->size-1) < map->offset ||
>                    map->offset < virt_to_phys(high_memory)) {
>                        kfree(map);

> diff --git a/drivers/gpu/drm/drm_drv.c b/drivers/gpu/drm/drm_drv.c
> index 766c468..b5171ed 100644
> --- a/drivers/gpu/drm/drm_drv.c
> +++ b/drivers/gpu/drm/drm_drv.c
> @@ -24,6 +24,7 @@
>  *
>  * Copyright 1999, 2000 Precision Insight, Inc., Cedar Park, Texas.
>  * Copyright 2000 VA Linux Systems, Inc., Sunnyvale, California.
> + * Copyright (c) 2009, Code Aurora Forum.
>  * All Rights Reserved.

again similiar, but even less code since you mostly remove code.

>  *
>  * Permission is hereby granted, free of charge, to any person obtaining a
> @@ -242,47 +243,20 @@ int drm_lastclose(struct drm_device * dev)
>  *
>  * Initializes an array of drm_device structures, and attempts to
>  * initialize all available devices, using consecutive minors, registering
> the
> - * stubs and initializing the AGP device.
> + * stubs and initializing the device.
>  *
>  * Expands the \c DRIVER_PREINIT and \c DRIVER_POST_INIT macros before and
>  * after the initialization for driver customization.
>  */
>  int drm_init(struct drm_driver *driver)
>  {
> -       struct pci_dev *pdev = NULL;
> -       const struct pci_device_id *pid;
> -       int i;
> -
>        DRM_DEBUG("\n");
> -
>        INIT_LIST_HEAD(&driver->device_list);
>
> -       if (driver->driver_features & DRIVER_MODESET)
> -               return pci_register_driver(&driver->pci_driver);
> -
> -       /* If not using KMS, fall back to stealth mode manual scanning. */
> -       for (i = 0; driver->pci_driver.id_table[i].vendor != 0; i++) {
> -               pid = &driver->pci_driver.id_table[i];
> -
> -               /* Loop around setting up a DRM device for each PCI device
> -                * matching our ID and device class.  If we had the internal
> -                * function that pci_get_subsys and pci_get_class used, we'd
> -                * be able to just pass pid in instead of doing a two-stage
> -                * thing.
> -                */
> -               pdev = NULL;
> -               while ((pdev =
> -                       pci_get_subsys(pid->vendor, pid->device,
> pid->subvendor,
> -                                      pid->subdevice, pdev)) != NULL) {
> -                       if ((pdev->class & pid->class_mask) != pid->class)
> -                               continue;
> -
> -                       /* stealth mode requires a manual probe */
> -                       pci_dev_get(pdev);
> -                       drm_get_dev(pdev, pid, driver);
> -               }
> -       }
> -       return 0;
> +       if (driver->driver_features & DRIVER_USE_PLATFORM_DEVICE)
> +               return drm_platform_init(driver);
> +       else
> +               return drm_pci_init(driver);
>  }
>
>  EXPORT_SYMBOL(drm_init);
> diff --git a/drivers/gpu/drm/drm_edid.c b/drivers/gpu/drm/drm_edid.c
> index ab6c973..48a14a0 100644
> --- a/drivers/gpu/drm/drm_edid.c
> +++ b/drivers/gpu/drm/drm_edid.c
> @@ -1220,6 +1220,9 @@ struct edid *drm_get_edid(struct drm_connector
> *connector,
>        int ret;
>        struct edid *edid;
>
> +       if (drm_core_check_feature(connector->dev,
> DRIVER_USE_PLATFORM_DEVICE))
> +               return NULL;
> +


This makes no sense, having the ability to probe EDID or not is most
definitely not a platform vs PCI problem.




>  {
>        struct drm_irq_busid *p = data;
>
> +       if (drm_core_check_feature(dev, DRIVER_USE_PLATFORM_DEVICE))
> +               return -EINVAL;

Not 100% sure about this, but if you only intend on KMS and don't need to
inform userspace of irq support this should be okay.



> diff --git a/drivers/gpu/drm/drm_vm.c b/drivers/gpu/drm/drm_vm.c
> index 4ac900f..22aaaae 100644
> --- a/drivers/gpu/drm/drm_vm.c
> +++ b/drivers/gpu/drm/drm_vm.c
> @@ -60,7 +60,7 @@ static pgprot_t drm_io_prot(uint32_t map_type, struct
> vm_area_struct *vma)
>                tmp = pgprot_writecombine(tmp);
>        else
>                tmp = pgprot_noncached(tmp);
> -#elif defined(__sparc__)
> +#elif defined(__sparc__) || defined(__arm__)
>        tmp = pgprot_noncached(tmp);
>  #endif
>        return tmp;
> @@ -600,6 +600,7 @@ int drm_mmap_locked(struct file *filp, struct
> vm_area_struct *vma)
>        }
>
>        switch (map->type) {
> +#if !defined(__arm__)
>        case _DRM_AGP:
>                if (drm_core_has_AGP(dev) && dev->agp->cant_use_aperture) {
>                        /*
> @@ -614,20 +615,31 @@ int drm_mmap_locked(struct file *filp, struct
> vm_area_struct *vma)
>                        break;
>                }
>                /* fall through to _DRM_FRAME_BUFFER... */
> +#endif
>        case _DRM_FRAME_BUFFER:
>        case _DRM_REGISTERS:
>                offset = dev->driver->get_reg_ofs(dev);
>                vma->vm_flags |= VM_IO; /* not in core dump */
>                vma->vm_page_prot = drm_io_prot(map->type, vma);
> +#if !defined(__arm__)
>                if (io_remap_pfn_range(vma, vma->vm_start,
>                                       (map->offset + offset) >> PAGE_SHIFT,
>                                       vma->vm_end - vma->vm_start,
>                                       vma->vm_page_prot))
>                        return -EAGAIN;
> +#else
> +               if (remap_pfn_range(vma, vma->vm_start,
> +                                       (map->offset + offset) >>
> PAGE_SHIFT,
> +                                       vma->vm_end - vma->vm_start,
> +                                       vma->vm_page_prot))
> +                       return -EAGAIN;
> +#endif
> +
>                DRM_DEBUG("   Type = %d; start = 0x%lx, end = 0x%lx,"
>                          " offset = 0x%llx\n",
>                          map->type,
>                          vma->vm_start, vma->vm_end, (unsigned long
> long)(map->offset + offset));
> +
>                vma->vm_ops = &drm_vm_ops;
>                break;
>        case _DRM_CONSISTENT:
> diff --git a/drivers/gpu/drm/i915/i915_drv.c
> b/drivers/gpu/drm/i915/i915_drv.c
> index cf4cb3e..29d26c2 100644
> --- a/drivers/gpu/drm/i915/i915_drv.c
> +++ b/drivers/gpu/drm/i915/i915_drv.c
> @@ -392,7 +392,7 @@ int i965_reset(struct drm_device *dev, u8 flags)
>  static int __devinit
>  i915_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
>  {
> -       return drm_get_dev(pdev, ent, &driver);
> +       return drm_get_pci_dev(pdev, ent, &driver);
>  }
>
>  static void
> diff --git a/drivers/gpu/drm/radeon/radeon_drv.c
> b/drivers/gpu/drm/radeon/radeon_drv.c
> index 8ba3de7..6586f6a 100644
> --- a/drivers/gpu/drm/radeon/radeon_drv.c
> +++ b/drivers/gpu/drm/radeon/radeon_drv.c
> @@ -223,7 +223,7 @@ static struct drm_driver kms_driver;
>  static int __devinit
>  radeon_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
>  {
> -       return drm_get_dev(pdev, ent, &kms_driver);
> +       return drm_get_pci_dev(pdev, ent, &kms_driver);
>  }
>

This also doesn't address noueau/vmwgfx entry points.

Dave.

^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: [PATCH] drm: Allow platform devices to register as DRM devices
  2010-03-15  0:56   ` [PATCH] drm: Allow platform devices to register as DRM devices Dave Airlie
@ 2010-03-15 18:04     ` Jordan Crouse
  2010-03-16  3:05       ` Dave Airlie
  2010-03-16  2:41     ` Paul Mundt
  1 sibling, 1 reply; 17+ messages in thread
From: Jordan Crouse @ 2010-03-15 18:04 UTC (permalink / raw)
  To: Dave Airlie; +Cc: Jordan Crouse, dri-devel, linux-kernel, linux-arm-msm

Dave Airlie wrote:
> On Tue, Mar 2, 2010 at 2:00 AM, Jordan Crouse <jcrouse@codeaurora.org> wrote:
>> Allow platform devices without PCI resources to be DRM devices.
>>
>> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org>
> 
> This patch has a bunch of whitespace damage at least in my inbox and
> also in patchwork

Yes, PBCAK.

> Please also be careful with the places you add copyrights, you moved a
> bunch of code
> from drm_drv.c to drm_pci.c and added a copyright for Code Aurora in
> drm_pci.c? You can
> only assert copyright if you actually wrote the code, otherwise the patch
> contains your authorship details and who contributed the code. I'm
> guessing you might have
> copyright over one file in this that being drm_platform.c, the rest
> I'm less sure about.
> 
> I also wonder if we could/should separate the arm drm support out from
> this patch (i.e.
> the __arm__ changes).

That might not be a bad idea, I'll do that.

> Some other misc comments below:
> 
>>  #
>>  menuconfig DRM
>>        tristate "Direct Rendering Manager (XFree86 4.1.0 and higher DRI
>> support)"
>> -       depends on (AGP || AGP=n) && PCI && !EMULATED_CMPXCHG && MMU
> 
>>>From what I can see the AGP || AGP==n is still required, you just want
> to drop the PCI
> dependancy??

I guess technically we could also drop the AGP requirement, but since it worked
on my box with AGP=n it seemed to me like a NOP.

>> +       depends on !EMULATED_CMPXCHG && MMU
>>
>> diff --git a/drivers/gpu/drm/drm_bufs.c b/drivers/gpu/drm/drm_bufs.c
>> index 8417cc4..4177f60 100644
>> --- a/drivers/gpu/drm/drm_bufs.c
>> +++ b/drivers/gpu/drm/drm_bufs.c
>> @@ -11,6 +11,7 @@
>>  *
>>  * Copyright 1999, 2000 Precision Insight, Inc., Cedar Park, Texas.
>>  * Copyright 2000 VA Linux Systems, Inc., Sunnyvale, California.
>> + * Copyright (c) 2009, Code Aurora Forum.
>>  * All Rights Reserved.
> 
> There have been much bigger changes to these files without copyright
> additions, I'm not sure how big something needs to be but I'm not 100% sure
> this comes close.
> 
>>  resource_size_t drm_get_resource_start(struct drm_device *dev, unsigned int
>> resource)
>>  {
>> +       if (drm_core_check_feature(dev, DRIVER_USE_PLATFORM_DEVICE)) {
>> +               struct resource *r;
>> +               r = platform_get_resource(dev->platformdev, IORESOURCE_MEM,
>> +                                            resource);
>> +
>> +               return r ? r->start : 0;
>> +       }
>> +
>> +#ifdef CONFIG_PCI
>>        return pci_resource_start(dev->pdev, resource);
>> +#endif
>> +
>> +       return 0;
>>  }
>>  EXPORT_SYMBOL(drm_get_resource_start);
>>
>>  resource_size_t drm_get_resource_len(struct drm_device *dev, unsigned int
>> resource)
>>  {
>> +       if (drm_core_check_feature(dev, DRIVER_USE_PLATFORM_DEVICE)) {
>> +               struct resource *r;
>> +               r = platform_get_resource(dev->platformdev, IORESOURCE_MEM,
>> +                       resource);
>> +
>> +               return r ? (r->end - r->start) : 0;
>> +       }
>> +
>> +#ifdef CONFIG_PCI
>>        return pci_resource_len(dev->pdev, resource);
>> +#endif
>> +
>> +       return 0;
>>  }
>>
>>  EXPORT_SYMBOL(drm_get_resource_len);
>> @@ -188,7 +213,7 @@ static int drm_addmap_core(struct drm_device * dev,
>> resource_size_t offset,
>>        switch (map->type) {
>>        case _DRM_REGISTERS:
>>        case _DRM_FRAME_BUFFER:
>> -#if !defined(__sparc__) && !defined(__alpha__) && !defined(__ia64__) &&
>> !defined(__powerpc64__) && !defined(__x86_64__)
>> +#if !defined(__sparc__) && !defined(__alpha__) && !defined(__ia64__) &&
>> !defined(__powerpc64__) && !defined(__x86_64__) && !defined(__arm__)
>>                if (map->offset + (map->size-1) < map->offset ||
>>                    map->offset < virt_to_phys(high_memory)) {
>>                        kfree(map);
> 
>> diff --git a/drivers/gpu/drm/drm_drv.c b/drivers/gpu/drm/drm_drv.c
>> index 766c468..b5171ed 100644
>> --- a/drivers/gpu/drm/drm_drv.c
>> +++ b/drivers/gpu/drm/drm_drv.c
>> @@ -24,6 +24,7 @@
>>  *
>>  * Copyright 1999, 2000 Precision Insight, Inc., Cedar Park, Texas.
>>  * Copyright 2000 VA Linux Systems, Inc., Sunnyvale, California.
>> + * Copyright (c) 2009, Code Aurora Forum.
>>  * All Rights Reserved.
> 
> again similiar, but even less code since you mostly remove code.
> 
>>  *
>>  * Permission is hereby granted, free of charge, to any person obtaining a
>> @@ -242,47 +243,20 @@ int drm_lastclose(struct drm_device * dev)
>>  *
>>  * Initializes an array of drm_device structures, and attempts to
>>  * initialize all available devices, using consecutive minors, registering
>> the
>> - * stubs and initializing the AGP device.
>> + * stubs and initializing the device.
>>  *
>>  * Expands the \c DRIVER_PREINIT and \c DRIVER_POST_INIT macros before and
>>  * after the initialization for driver customization.
>>  */
>>  int drm_init(struct drm_driver *driver)
>>  {
>> -       struct pci_dev *pdev = NULL;
>> -       const struct pci_device_id *pid;
>> -       int i;
>> -
>>        DRM_DEBUG("\n");
>> -
>>        INIT_LIST_HEAD(&driver->device_list);
>>
>> -       if (driver->driver_features & DRIVER_MODESET)
>> -               return pci_register_driver(&driver->pci_driver);
>> -
>> -       /* If not using KMS, fall back to stealth mode manual scanning. */
>> -       for (i = 0; driver->pci_driver.id_table[i].vendor != 0; i++) {
>> -               pid = &driver->pci_driver.id_table[i];
>> -
>> -               /* Loop around setting up a DRM device for each PCI device
>> -                * matching our ID and device class.  If we had the internal
>> -                * function that pci_get_subsys and pci_get_class used, we'd
>> -                * be able to just pass pid in instead of doing a two-stage
>> -                * thing.
>> -                */
>> -               pdev = NULL;
>> -               while ((pdev =
>> -                       pci_get_subsys(pid->vendor, pid->device,
>> pid->subvendor,
>> -                                      pid->subdevice, pdev)) != NULL) {
>> -                       if ((pdev->class & pid->class_mask) != pid->class)
>> -                               continue;
>> -
>> -                       /* stealth mode requires a manual probe */
>> -                       pci_dev_get(pdev);
>> -                       drm_get_dev(pdev, pid, driver);
>> -               }
>> -       }
>> -       return 0;
>> +       if (driver->driver_features & DRIVER_USE_PLATFORM_DEVICE)
>> +               return drm_platform_init(driver);
>> +       else
>> +               return drm_pci_init(driver);
>>  }
>>
>>  EXPORT_SYMBOL(drm_init);
>> diff --git a/drivers/gpu/drm/drm_edid.c b/drivers/gpu/drm/drm_edid.c
>> index ab6c973..48a14a0 100644
>> --- a/drivers/gpu/drm/drm_edid.c
>> +++ b/drivers/gpu/drm/drm_edid.c
>> @@ -1220,6 +1220,9 @@ struct edid *drm_get_edid(struct drm_connector
>> *connector,
>>        int ret;
>>        struct edid *edid;
>>
>> +       if (drm_core_check_feature(connector->dev,
>> DRIVER_USE_PLATFORM_DEVICE))
>> +               return NULL;
>> +
> 
> 
> This makes no sense, having the ability to probe EDID or not is most
> definitely not a platform vs PCI problem.

Yeah, that was my poor man's "Don't probe EDID" hack.  I'm not sure if there
is a smart way to implicitly check to see if EDID should be probed, but I'm
worried about abusing the features flag too badly, though if a DRIVER_USE_EDID
is needed then we shouldn't be shy about using it.

> 
> 
> 
>>  {
>>        struct drm_irq_busid *p = data;
>>
>> +       if (drm_core_check_feature(dev, DRIVER_USE_PLATFORM_DEVICE))
>> +               return -EINVAL;
> 
> Not 100% sure about this, but if you only intend on KMS and don't need to
> inform userspace of irq support this should be okay.

Again, a "don't do this" hack.  I'll look at this more carefully and see if there
is a good way to evaluate this based on the hooks that the platform has defined.

> 
> 
>> diff --git a/drivers/gpu/drm/drm_vm.c b/drivers/gpu/drm/drm_vm.c
>> index 4ac900f..22aaaae 100644
>> --- a/drivers/gpu/drm/drm_vm.c
>> +++ b/drivers/gpu/drm/drm_vm.c
>> @@ -60,7 +60,7 @@ static pgprot_t drm_io_prot(uint32_t map_type, struct
>> vm_area_struct *vma)
>>                tmp = pgprot_writecombine(tmp);
>>        else
>>                tmp = pgprot_noncached(tmp);
>> -#elif defined(__sparc__)
>> +#elif defined(__sparc__) || defined(__arm__)
>>        tmp = pgprot_noncached(tmp);
>>  #endif
>>        return tmp;
>> @@ -600,6 +600,7 @@ int drm_mmap_locked(struct file *filp, struct
>> vm_area_struct *vma)
>>        }
>>
>>        switch (map->type) {
>> +#if !defined(__arm__)
>>        case _DRM_AGP:
>>                if (drm_core_has_AGP(dev) && dev->agp->cant_use_aperture) {
>>                        /*
>> @@ -614,20 +615,31 @@ int drm_mmap_locked(struct file *filp, struct
>> vm_area_struct *vma)
>>                        break;
>>                }
>>                /* fall through to _DRM_FRAME_BUFFER... */
>> +#endif
>>        case _DRM_FRAME_BUFFER:
>>        case _DRM_REGISTERS:
>>                offset = dev->driver->get_reg_ofs(dev);
>>                vma->vm_flags |= VM_IO; /* not in core dump */
>>                vma->vm_page_prot = drm_io_prot(map->type, vma);
>> +#if !defined(__arm__)
>>                if (io_remap_pfn_range(vma, vma->vm_start,
>>                                       (map->offset + offset) >> PAGE_SHIFT,
>>                                       vma->vm_end - vma->vm_start,
>>                                       vma->vm_page_prot))
>>                        return -EAGAIN;
>> +#else
>> +               if (remap_pfn_range(vma, vma->vm_start,
>> +                                       (map->offset + offset) >>
>> PAGE_SHIFT,
>> +                                       vma->vm_end - vma->vm_start,
>> +                                       vma->vm_page_prot))
>> +                       return -EAGAIN;
>> +#endif
>> +
>>                DRM_DEBUG("   Type = %d; start = 0x%lx, end = 0x%lx,"
>>                          " offset = 0x%llx\n",
>>                          map->type,
>>                          vma->vm_start, vma->vm_end, (unsigned long
>> long)(map->offset + offset));
>> +
>>                vma->vm_ops = &drm_vm_ops;
>>                break;
>>        case _DRM_CONSISTENT:
>> diff --git a/drivers/gpu/drm/i915/i915_drv.c
>> b/drivers/gpu/drm/i915/i915_drv.c
>> index cf4cb3e..29d26c2 100644
>> --- a/drivers/gpu/drm/i915/i915_drv.c
>> +++ b/drivers/gpu/drm/i915/i915_drv.c
>> @@ -392,7 +392,7 @@ int i965_reset(struct drm_device *dev, u8 flags)
>>  static int __devinit
>>  i915_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
>>  {
>> -       return drm_get_dev(pdev, ent, &driver);
>> +       return drm_get_pci_dev(pdev, ent, &driver);
>>  }
>>
>>  static void
>> diff --git a/drivers/gpu/drm/radeon/radeon_drv.c
>> b/drivers/gpu/drm/radeon/radeon_drv.c
>> index 8ba3de7..6586f6a 100644
>> --- a/drivers/gpu/drm/radeon/radeon_drv.c
>> +++ b/drivers/gpu/drm/radeon/radeon_drv.c
>> @@ -223,7 +223,7 @@ static struct drm_driver kms_driver;
>>  static int __devinit
>>  radeon_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
>>  {
>> -       return drm_get_dev(pdev, ent, &kms_driver);
>> +       return drm_get_pci_dev(pdev, ent, &kms_driver);
>>  }
>>
> 
> This also doesn't address noueau/vmwgfx entry points.

Yep, thats my bad.  I'll refresh and push better patches without whitespace stupidity.
Thanks for your comments.

Jordan


^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: [PATCH] drm: Allow platform devices to register as DRM devices
       [not found] ` <4B8BE489.7020402@codeaurora.org>
  2010-03-15  0:56   ` [PATCH] drm: Allow platform devices to register as DRM devices Dave Airlie
@ 2010-03-15 19:27   ` Ville Syrjälä
  2010-05-27 19:40   ` [PATCH v2] DRM platform device support jcrouse
                     ` (4 subsequent siblings)
  6 siblings, 0 replies; 17+ messages in thread
From: Ville Syrjälä @ 2010-03-15 19:27 UTC (permalink / raw)
  To: Jordan Crouse; +Cc: dri-devel, linux-arm-msm, linux-kernel

On Mon, Mar 01, 2010 at 09:00:09AM -0700, Jordan Crouse wrote:
> 
> Allow platform devices without PCI resources to be DRM devices.

I really dislike the fact that drm has bus specific junk all over the
generic code. Some ideas how to clean that up:

Add 'struct device *dev' into drm_device so you don't have to go through
the pdev/platformdev to get it every time. Also use dev_name() instead
of pci_name() and whatever you used for the platform device case.

Add 'int irq' into struct drm_device instead of adding more bus specific
hoops to get at the irq. Not sure I like the generic code mucking about
with the irq directly though but baby steps are easier to handle.

Get rid of the drm_resource_start/len wrappers. AFAICS they're all called
from the low level driver code anyway and the driver knows the bus type
so there's no need for the wrappers.

It would be nice to get the struct pci_driver out of the the drm_driver
structure. Since you now have a new pci specific drm_get_dev() thing
could you also pass the pci_driver as a function parameter instead
of having it live inside the drm_driver?

Also all cases where there's some PCI specific stuff (the busid stuff
mostly) you could just check the drm_device.pdev pointer instead of
having to add another driver flags to identify non-PCI devices. Although
I don't really like having the pdev/platformdev pointers in there at all.

That's sort of my secret drm TODO list but so far didn't have the time
to actually do the coding part.

-- 
Ville Syrjälä
syrjala@sci.fi
http://www.sci.fi/~syrjala/

^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: [PATCH] drm: Allow platform devices to register as DRM devices
  2010-03-15  0:56   ` [PATCH] drm: Allow platform devices to register as DRM devices Dave Airlie
  2010-03-15 18:04     ` Jordan Crouse
@ 2010-03-16  2:41     ` Paul Mundt
  1 sibling, 0 replies; 17+ messages in thread
From: Paul Mundt @ 2010-03-16  2:41 UTC (permalink / raw)
  To: Dave Airlie; +Cc: Jordan Crouse, dri-devel, linux-kernel, linux-arm-msm

On Mon, Mar 15, 2010 at 10:56:02AM +1000, Dave Airlie wrote:
> On Tue, Mar 2, 2010 at 2:00 AM, Jordan Crouse <jcrouse@codeaurora.org> wrote:
> >
> > Allow platform devices without PCI resources to be DRM devices.
> >
> > Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org>
> 
> This patch has a bunch of whitespace damage at least in my inbox and
> also in patchwork
> 
> Please also be careful with the places you add copyrights, you moved a
> bunch of code from drm_drv.c to drm_pci.c and added a copyright for
> Code Aurora in drm_pci.c? You can only assert copyright if you actually
> wrote the code, otherwise the patch contains your authorship details
> and who contributed the code. I'm guessing you might have copyright
> over one file in this that being drm_platform.c, the rest I'm less sure
> about.
> 
> I also wonder if we could/should separate the arm drm support out from
> this patch (i.e.  the __arm__ changes).
> 
Also note that pgprot_noncached() is a standard interface these days, so
there is no longer any reason to special case it. There's no reason for
the io prot mapping code turning in to the hell that was the fbmem.c
mmap.

^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: [PATCH] drm: Allow platform devices to register as DRM devices
  2010-03-15 18:04     ` Jordan Crouse
@ 2010-03-16  3:05       ` Dave Airlie
  0 siblings, 0 replies; 17+ messages in thread
From: Dave Airlie @ 2010-03-16  3:05 UTC (permalink / raw)
  To: Jordan Crouse; +Cc: dri-devel, linux-kernel, linux-arm-msm

>
> I guess technically we could also drop the AGP requirement, but since it
> worked
> on my box with AGP=n it seemed to me like a NOP.

Its not a NOP, otherwise we'd remove it, AGP || AGP=n means if
AGP is enabled DRM must be enabled similiarly, it stops AGP=m + DRM=y
basically.

>>>  EXPORT_SYMBOL(drm_init);
>>> diff --git a/drivers/gpu/drm/drm_edid.c b/drivers/gpu/drm/drm_edid.c
>>> index ab6c973..48a14a0 100644
>>> --- a/drivers/gpu/drm/drm_edid.c
>>> +++ b/drivers/gpu/drm/drm_edid.c
>>> @@ -1220,6 +1220,9 @@ struct edid *drm_get_edid(struct drm_connector
>>> *connector,
>>>       int ret;
>>>       struct edid *edid;
>>>
>>> +       if (drm_core_check_feature(connector->dev,
>>> DRIVER_USE_PLATFORM_DEVICE))
>>> +               return NULL;
>>> +
>>
>>
>> This makes no sense, having the ability to probe EDID or not is most
>> definitely not a platform vs PCI problem.
>
> Yeah, that was my poor man's "Don't probe EDID" hack.  I'm not sure if there
> is a smart way to implicitly check to see if EDID should be probed, but I'm
> worried about abusing the features flag too badly, though if a
> DRIVER_USE_EDID
> is needed then we shouldn't be shy about using it.

The generic code never calls this only the driver, so there should be no
need for flags at all.

>> Not 100% sure about this, but if you only intend on KMS and don't need to
>> inform userspace of irq support this should be okay.
>
> Again, a "don't do this" hack.  I'll look at this more carefully and see if
> there
> is a good way to evaluate this based on the hooks that the platform has
> defined.

Its mostly used in UMS to inform userspace for some strange reason
its pretty legacy at this point, new driver should probably not hit it.

>>> @@ -60,7 +60,7 @@ static pgprot_t drm_io_prot(uint32_t map_type, struct

>>
>> This also doesn't address noueau/vmwgfx entry points.
>
> Yep, thats my bad.  I'll refresh and push better patches without whitespace
> stupidity.

Thanks,
Dave.

^ permalink raw reply	[flat|nested] 17+ messages in thread

* [PATCH v2] DRM platform device support
       [not found] ` <4B8BE489.7020402@codeaurora.org>
  2010-03-15  0:56   ` [PATCH] drm: Allow platform devices to register as DRM devices Dave Airlie
  2010-03-15 19:27   ` Ville Syrjälä
@ 2010-05-27 19:40   ` jcrouse
  2010-08-04 20:48     ` [PATCH v3] " Jordan Crouse
                       ` (4 more replies)
  2010-05-27 19:40   ` [PATCH 1/4] drm: Remove drm_resource wrappers jcrouse
                     ` (3 subsequent siblings)
  6 siblings, 5 replies; 17+ messages in thread
From: jcrouse @ 2010-05-27 19:40 UTC (permalink / raw)
  To: dri-devel; +Cc: linux-arm-msm

Here is the second revision implementing platform device
support for DRM.  I've split the original patch into three
and applied most of the comments I got from the previous
go-around.  The first patch removes the resource wrappers from
DRM and switches the drivers to use the bus level functions.
The second patch adds the platform support, and the third patch
adds the ARM specific #ifdefs.

Plus, a bonus patch that ensures that the DRM offset fits into
the pgoff (unsigned long) offset for mmap.  The original code made
a 64 bit value that didn't fly with a 32 bit processor.

Thanks for the comments and keep em coming.

Jordan

^ permalink raw reply	[flat|nested] 17+ messages in thread

* [PATCH 1/4] drm:  Remove drm_resource wrappers
       [not found] ` <4B8BE489.7020402@codeaurora.org>
                     ` (2 preceding siblings ...)
  2010-05-27 19:40   ` [PATCH v2] DRM platform device support jcrouse
@ 2010-05-27 19:40   ` jcrouse
  2010-05-27 21:15     ` Matt Turner
  2010-05-27 19:40   ` [PATCH 2/4] drm: Add support for platform devices to register as DRM devices jcrouse
                     ` (2 subsequent siblings)
  6 siblings, 1 reply; 17+ messages in thread
From: jcrouse @ 2010-05-27 19:40 UTC (permalink / raw)
  To: dri-devel; +Cc: linux-arm-msm, Jordan Crouse

From: Jordan Crouse <jcrouse@codeaurora.org>

Remove the drm_resource wrappers and directly use the
actual PCI and/or platform functions in their place.

Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org>
---
 drivers/gpu/drm/drm_bufs.c                |   13 -------------
 drivers/gpu/drm/i915/i915_dma.c           |    6 +++---
 drivers/gpu/drm/mga/mga_dma.c             |    4 ++--
 drivers/gpu/drm/nouveau/nouveau_bo.c      |    2 +-
 drivers/gpu/drm/nouveau/nouveau_channel.c |    3 ++-
 drivers/gpu/drm/nouveau/nouveau_mem.c     |   16 +++++++++-------
 drivers/gpu/drm/nouveau/nv20_graph.c      |    4 ++--
 drivers/gpu/drm/nouveau/nv40_graph.c      |    2 +-
 drivers/gpu/drm/nouveau/nv50_instmem.c    |    3 ++-
 drivers/gpu/drm/radeon/evergreen.c        |    4 ++--
 drivers/gpu/drm/radeon/r100.c             |    4 ++--
 drivers/gpu/drm/radeon/r600.c             |    4 ++--
 drivers/gpu/drm/radeon/radeon_bios.c      |    2 +-
 drivers/gpu/drm/radeon/radeon_cp.c        |    8 ++++----
 drivers/gpu/drm/radeon/radeon_device.c    |    4 ++--
 drivers/gpu/drm/radeon/rs600.c            |    4 ++--
 drivers/gpu/drm/radeon/rs690.c            |    4 ++--
 drivers/gpu/drm/radeon/rv770.c            |    4 ++--
 drivers/gpu/drm/savage/savage_bci.c       |   24 +++++++++++++-----------
 include/drm/drmP.h                        |    4 ----
 20 files changed, 54 insertions(+), 65 deletions(-)

diff --git a/drivers/gpu/drm/drm_bufs.c b/drivers/gpu/drm/drm_bufs.c
index 2092e7b..3c2c663 100644
--- a/drivers/gpu/drm/drm_bufs.c
+++ b/drivers/gpu/drm/drm_bufs.c
@@ -39,19 +39,6 @@
 #include <asm/shmparam.h>
 #include "drmP.h"
 
-resource_size_t drm_get_resource_start(struct drm_device *dev, unsigned int resource)
-{
-	return pci_resource_start(dev->pdev, resource);
-}
-EXPORT_SYMBOL(drm_get_resource_start);
-
-resource_size_t drm_get_resource_len(struct drm_device *dev, unsigned int resource)
-{
-	return pci_resource_len(dev->pdev, resource);
-}
-
-EXPORT_SYMBOL(drm_get_resource_len);
-
 static struct drm_map_list *drm_find_matching_map(struct drm_device *dev,
 						  struct drm_local_map *map)
 {
diff --git a/drivers/gpu/drm/i915/i915_dma.c b/drivers/gpu/drm/i915/i915_dma.c
index 2a6b5de..9fe2d08 100644
--- a/drivers/gpu/drm/i915/i915_dma.c
+++ b/drivers/gpu/drm/i915/i915_dma.c
@@ -1429,7 +1429,7 @@ static int i915_load_modeset_init(struct drm_device *dev,
 	int fb_bar = IS_I9XX(dev) ? 2 : 0;
 	int ret = 0;
 
-	dev->mode_config.fb_base = drm_get_resource_start(dev, fb_bar) &
+	dev->mode_config.fb_base = pci_resource_start(dev->pdev, fb_bar) &
 		0xff000000;
 
 	/* Basic memrange allocator for stolen space (aka vram) */
@@ -1612,8 +1612,8 @@ int i915_driver_load(struct drm_device *dev, unsigned long flags)
 
 	/* Add register map (needed for suspend/resume) */
 	mmio_bar = IS_I9XX(dev) ? 0 : 1;
-	base = drm_get_resource_start(dev, mmio_bar);
-	size = drm_get_resource_len(dev, mmio_bar);
+	base = pci_resource_start(dev->pdev, mmio_bar);
+	size = pci_resource_len(dev->pdev, mmio_bar);
 
 	if (i915_get_bridge_dev(dev)) {
 		ret = -EIO;
diff --git a/drivers/gpu/drm/mga/mga_dma.c b/drivers/gpu/drm/mga/mga_dma.c
index 3c917fb..ccc129c 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)
 	dev_priv->usec_timeout = MGA_DEFAULT_USEC_TIMEOUT;
 	dev_priv->chipset = flags;
 
-	dev_priv->mmio_base = drm_get_resource_start(dev, 1);
-	dev_priv->mmio_size = drm_get_resource_len(dev, 1);
+	dev_priv->mmio_base = pci_resource_start(dev->pdev, 1);
+	dev_priv->mmio_size = pci_resource_len(dev->pdev, 1);
 
 	dev->counters += 3;
 	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 6f3c195..1dad392 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)
 		break;
 	case TTM_PL_VRAM:
 		mem->bus.offset = mem->mm_node->start << PAGE_SHIFT;
-		mem->bus.base = drm_get_resource_start(dev, 1);
+		man->bus.base = pci_resource_start(dev->pdev, 1);
 		mem->bus.is_iomem = true;
 		break;
 	default:
diff --git a/drivers/gpu/drm/nouveau/nouveau_channel.c b/drivers/gpu/drm/nouveau/nouveau_channel.c
index 1fc57ef..06555c7 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)
 		 * VRAM.
 		 */
 		ret = nouveau_gpuobj_dma_new(chan, NV_CLASS_DMA_IN_MEMORY,
-					     drm_get_resource_start(dev, 1),
+					     pci_resource_start(dev->pdev,
+					     1),
 					     dev_priv->fb_available_size,
 					     NV_DMA_ACCESS_RO,
 					     NV_DMA_TARGET_PCI, &pushbuf);
diff --git a/drivers/gpu/drm/nouveau/nouveau_mem.c b/drivers/gpu/drm/nouveau/nouveau_mem.c
index 775a701..37c7bf8 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)
 	}
 
 	if (dev_priv->fb_mtrr) {
-		drm_mtrr_del(dev_priv->fb_mtrr, drm_get_resource_start(dev, 1),
-			     drm_get_resource_len(dev, 1), DRM_MTRR_WC);
+		drm_mtrr_del(dev_priv->fb_mtrr,
+			     pci_resource_start(dev->pdev, 1),
+			     pci_resource_len(dev->pdev, 1), DRM_MTRR_WC);
 		dev_priv->fb_mtrr = 0;
 	}
 }
@@ -632,7 +633,7 @@ nouveau_mem_init(struct drm_device *dev)
 	struct ttm_bo_device *bdev = &dev_priv->ttm.bdev;
 	int ret, dma_bits = 32;
 
-	dev_priv->fb_phys = drm_get_resource_start(dev, 1);
+	dev_priv->fb_phys = pci_resource_start(dev->pdev, 1);
 	dev_priv->gart_info.type = NOUVEAU_GART_NONE;
 
 	if (dev_priv->card_type >= NV_50 &&
@@ -664,8 +665,9 @@ nouveau_mem_init(struct drm_device *dev)
 
 	dev_priv->fb_available_size = dev_priv->vram_size;
 	dev_priv->fb_mappable_pages = dev_priv->fb_available_size;
-	if (dev_priv->fb_mappable_pages > drm_get_resource_len(dev, 1))
-		dev_priv->fb_mappable_pages = drm_get_resource_len(dev, 1);
+	if (dev_priv->fb_mappable_pages > pci_resource_len(dev->pdev, 1))
+		dev_priv->fb_mappable_pages =
+			pci_resource_len(dev->pdev, 1);
 	dev_priv->fb_mappable_pages >>= PAGE_SHIFT;
 
 	/* remove reserved space at end of vram from available amount */
@@ -717,8 +719,8 @@ nouveau_mem_init(struct drm_device *dev)
 		return ret;
 	}
 
-	dev_priv->fb_mtrr = drm_mtrr_add(drm_get_resource_start(dev, 1),
-					 drm_get_resource_len(dev, 1),
+	dev_priv->fb_mtrr = drm_mtrr_add(pci_resource_start(dev->pdev, 1),
+					 pci_resource_len(dev->pdev, 1),
 					 DRM_MTRR_WC);
 
 	return 0;
diff --git a/drivers/gpu/drm/nouveau/nv20_graph.c b/drivers/gpu/drm/nouveau/nv20_graph.c
index d6fc0a8..fe2349b 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)
 	nv_wr32(dev, NV10_PGRAPH_SURFACE, tmp);
 
 	/* begin RAM config */
-	vramsz = drm_get_resource_len(dev, 0) - 1;
+	vramsz = pci_resource_len(dev->pdev, 0) - 1;
 	nv_wr32(dev, 0x4009A4, nv_rd32(dev, NV04_PFB_CFG0));
 	nv_wr32(dev, 0x4009A8, nv_rd32(dev, NV04_PFB_CFG1));
 	nv_wr32(dev, NV10_PGRAPH_RDI_INDEX, 0x00EA0000);
@@ -717,7 +717,7 @@ nv30_graph_init(struct drm_device *dev)
 	nv_wr32(dev, 0x0040075c             , 0x00000001);
 
 	/* begin RAM config */
-	/* vramsz = drm_get_resource_len(dev, 0) - 1; */
+	/* vramsz = pci_resource_len(dev->pdev, 0) - 1; */
 	nv_wr32(dev, 0x4009A4, nv_rd32(dev, NV04_PFB_CFG0));
 	nv_wr32(dev, 0x4009A8, nv_rd32(dev, NV04_PFB_CFG1));
 	if (dev_priv->chipset != 0x34) {
diff --git a/drivers/gpu/drm/nouveau/nv40_graph.c b/drivers/gpu/drm/nouveau/nv40_graph.c
index 704a25d..65b13b5 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)
 		nv40_graph_set_region_tiling(dev, i, 0, 0, 0);
 
 	/* begin RAM config */
-	vramsz = drm_get_resource_len(dev, 0) - 1;
+	vramsz = pci_resource_len(dev->pdev, 0) - 1;
 	switch (dev_priv->chipset) {
 	case 0x40:
 		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 5f21df3..ba4809e 100644
--- a/drivers/gpu/drm/nouveau/nv50_instmem.c
+++ b/drivers/gpu/drm/nouveau/nv50_instmem.c
@@ -241,7 +241,8 @@ nv50_instmem_init(struct drm_device *dev)
 		return ret;
 	BAR0_WI32(priv->fb_bar->gpuobj, 0x00, 0x7fc00000);
 	BAR0_WI32(priv->fb_bar->gpuobj, 0x04, 0x40000000 +
-					      drm_get_resource_len(dev, 1) - 1);
+					      pci_resource_len(dev->pmem,
+					      1) - 1);
 	BAR0_WI32(priv->fb_bar->gpuobj, 0x08, 0x40000000);
 	BAR0_WI32(priv->fb_bar->gpuobj, 0x0c, 0x00000000);
 	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 8c8e4d3..a4745e4 100644
--- a/drivers/gpu/drm/radeon/evergreen.c
+++ b/drivers/gpu/drm/radeon/evergreen.c
@@ -1300,8 +1300,8 @@ int evergreen_mc_init(struct radeon_device *rdev)
 	}
 	rdev->mc.vram_width = numchan * chansize;
 	/* Could aper size report 0 ? */
-	rdev->mc.aper_base = drm_get_resource_start(rdev->ddev, 0);
-	rdev->mc.aper_size = drm_get_resource_len(rdev->ddev, 0);
+	rdev->mc.aper_base = pci_resource_start(rdev->pdev, 0);
+	rdev->mc.aper_size = pci_resource_len(rdev->pdev, 0);
 	/* Setup GPU memory space */
 	/* size in MB on evergreen */
 	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 cc004b0..c485c2c 100644
--- a/drivers/gpu/drm/radeon/r100.c
+++ b/drivers/gpu/drm/radeon/r100.c
@@ -2284,8 +2284,8 @@ void r100_vram_init_sizes(struct radeon_device *rdev)
 	u64 config_aper_size;
 
 	/* work out accessible VRAM */
-	rdev->mc.aper_base = drm_get_resource_start(rdev->ddev, 0);
-	rdev->mc.aper_size = drm_get_resource_len(rdev->ddev, 0);
+	rdev->mc.aper_base = pci_resource_start(rdev->pdev, 0);
+	rdev->mc.aper_size = pci_resource_len(rdev->pdev, 0);
 	rdev->mc.visible_vram_size = r100_get_accessible_vram(rdev);
 	/* FIXME we don't use the second aperture yet when we could use it */
 	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 44e96a2..4959619 100644
--- a/drivers/gpu/drm/radeon/r600.c
+++ b/drivers/gpu/drm/radeon/r600.c
@@ -1118,8 +1118,8 @@ int r600_mc_init(struct radeon_device *rdev)
 	}
 	rdev->mc.vram_width = numchan * chansize;
 	/* Could aper size report 0 ? */
-	rdev->mc.aper_base = drm_get_resource_start(rdev->ddev, 0);
-	rdev->mc.aper_size = drm_get_resource_len(rdev->ddev, 0);
+	rdev->mc.aper_base = pci_resource_start(rdev->pdev, 0);
+	rdev->mc.aper_size = pci_resource_len(rdev->pdev, 0);
 	/* Setup GPU memory space */
 	rdev->mc.mc_vram_size = RREG32(CONFIG_MEMSIZE);
 	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 fbba938..91f5b5a 100644
--- a/drivers/gpu/drm/radeon/radeon_bios.c
+++ b/drivers/gpu/drm/radeon/radeon_bios.c
@@ -49,7 +49,7 @@ static bool igp_read_bios_from_vram(struct radeon_device *rdev)
 	resource_size_t size = 256 * 1024; /* ??? */
 
 	rdev->bios = NULL;
-	vram_base = drm_get_resource_start(rdev->ddev, 0);
+	vram_base = pci_resource_start(rdev->pdev, 0);
 	bios = ioremap(vram_base, size);
 	if (!bios) {
 		return false;
diff --git a/drivers/gpu/drm/radeon/radeon_cp.c b/drivers/gpu/drm/radeon/radeon_cp.c
index 2f042a3..eb6b9ee 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)
 	else
 		dev_priv->flags |= RADEON_IS_PCI;
 
-	ret = drm_addmap(dev, drm_get_resource_start(dev, 2),
-			 drm_get_resource_len(dev, 2), _DRM_REGISTERS,
+	ret = drm_addmap(dev, pci_resource_start(dev->pdev, 2),
+			 pci_resource_len(dev->pdev, 2), _DRM_REGISTERS,
 			 _DRM_READ_ONLY | _DRM_DRIVER, &dev_priv->mmio);
 	if (ret != 0)
 		return ret;
@@ -2194,9 +2194,9 @@ int radeon_driver_firstopen(struct drm_device *dev)
 
 	dev_priv->gart_info.table_size = RADEON_PCIGART_TABLE_SIZE;
 
-	dev_priv->fb_aper_offset = drm_get_resource_start(dev, 0);
+	dev_priv->fb_aper_offset = pci_resource_start(dev->pdev, 0);
 	ret = drm_addmap(dev, dev_priv->fb_aper_offset,
-			 drm_get_resource_len(dev, 0), _DRM_FRAME_BUFFER,
+			 pci_resource_len(dev->pdev, 0), _DRM_FRAME_BUFFER,
 			 _DRM_WRITE_COMBINING, &map);
 	if (ret != 0)
 		return ret;
diff --git a/drivers/gpu/drm/radeon/radeon_device.c b/drivers/gpu/drm/radeon/radeon_device.c
index fdc3fdf..2a897a7 100644
--- a/drivers/gpu/drm/radeon/radeon_device.c
+++ b/drivers/gpu/drm/radeon/radeon_device.c
@@ -648,8 +648,8 @@ int radeon_device_init(struct radeon_device *rdev,
 
 	/* Registers mapping */
 	/* TODO: block userspace mapping of io register */
-	rdev->rmmio_base = drm_get_resource_start(rdev->ddev, 2);
-	rdev->rmmio_size = drm_get_resource_len(rdev->ddev, 2);
+	rdev->rmmio_base = pci_resource_start(rdev->pdev, 2);
+	rdev->rmmio_size = pci_resource_len(rdev->pdev, 2);
 	rdev->rmmio = ioremap(rdev->rmmio_base, rdev->rmmio_size);
 	if (rdev->rmmio == NULL) {
 		return -ENOMEM;
diff --git a/drivers/gpu/drm/radeon/rs600.c b/drivers/gpu/drm/radeon/rs600.c
index 79887ca..340c761 100644
--- a/drivers/gpu/drm/radeon/rs600.c
+++ b/drivers/gpu/drm/radeon/rs600.c
@@ -685,8 +685,8 @@ void rs600_mc_init(struct radeon_device *rdev)
 {
 	u64 base;
 
-	rdev->mc.aper_base = drm_get_resource_start(rdev->ddev, 0);
-	rdev->mc.aper_size = drm_get_resource_len(rdev->ddev, 0);
+	rdev->mc.aper_base = pci_resource_start(rdev->pdev, 0);
+	rdev->mc.aper_size = pci_resource_len(rdev->pdev, 0);
 	rdev->mc.vram_is_ddr = true;
 	rdev->mc.vram_width = 128;
 	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 bcc3319..a18ba98 100644
--- a/drivers/gpu/drm/radeon/rs690.c
+++ b/drivers/gpu/drm/radeon/rs690.c
@@ -151,8 +151,8 @@ void rs690_mc_init(struct radeon_device *rdev)
 	rdev->mc.vram_width = 128;
 	rdev->mc.real_vram_size = RREG32(RADEON_CONFIG_MEMSIZE);
 	rdev->mc.mc_vram_size = rdev->mc.real_vram_size;
-	rdev->mc.aper_base = drm_get_resource_start(rdev->ddev, 0);
-	rdev->mc.aper_size = drm_get_resource_len(rdev->ddev, 0);
+	rdev->mc.aper_base = pci_resource_start(rdev->pdev, 0);
+	rdev->mc.aper_size = pci_resource_len(rdev->pdev, 0);
 	rdev->mc.visible_vram_size = rdev->mc.aper_size;
 	base = RREG32_MC(R_000100_MCCFG_FB_LOCATION);
 	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 253f24a..5c7f0b9 100644
--- a/drivers/gpu/drm/radeon/rv770.c
+++ b/drivers/gpu/drm/radeon/rv770.c
@@ -908,8 +908,8 @@ int rv770_mc_init(struct radeon_device *rdev)
 	}
 	rdev->mc.vram_width = numchan * chansize;
 	/* Could aper size report 0 ? */
-	rdev->mc.aper_base = drm_get_resource_start(rdev->ddev, 0);
-	rdev->mc.aper_size = drm_get_resource_len(rdev->ddev, 0);
+	rdev->mc.aper_base = pci_resource_start(rdev->pdev, 0);
+	rdev->mc.aper_size = pci_resource_len(rdev->pdev, 0);
 	/* Setup GPU memory space */
 	rdev->mc.mc_vram_size = RREG32(CONFIG_MEMSIZE);
 	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 2d0c9ca..f576232 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)
 	dev_priv->mtrr[2].handle = -1;
 	if (S3_SAVAGE3D_SERIES(dev_priv->chipset)) {
 		fb_rsrc = 0;
-		fb_base = drm_get_resource_start(dev, 0);
+		fb_base = pci_resource_start(dev->pdev, 0);
 		fb_size = SAVAGE_FB_SIZE_S3;
 		mmio_base = fb_base + SAVAGE_FB_SIZE_S3;
 		aper_rsrc = 0;
 		aperture_base = fb_base + SAVAGE_APERTURE_OFFSET;
 		/* this should always be true */
-		if (drm_get_resource_len(dev, 0) == 0x08000000) {
+		if (pci_resource_len(dev->pdev, 0) == 0x08000000) {
 			/* Don't make MMIO write-cobining! We need 3
 			 * MTRRs. */
 			dev_priv->mtrr[0].base = fb_base;
@@ -599,18 +599,19 @@ int savage_driver_firstopen(struct drm_device *dev)
 					 dev_priv->mtrr[2].size, DRM_MTRR_WC);
 		} else {
 			DRM_ERROR("strange pci_resource_len %08llx\n",
-				  (unsigned long long)drm_get_resource_len(dev, 0));
+				  (unsigned long long)
+				  pci_resource_len(dev->pdev, 0));
 		}
 	} else if (dev_priv->chipset != S3_SUPERSAVAGE &&
 		   dev_priv->chipset != S3_SAVAGE2000) {
-		mmio_base = drm_get_resource_start(dev, 0);
+		mmio_base = pci_resource_start(dev->pdev, 0);
 		fb_rsrc = 1;
-		fb_base = drm_get_resource_start(dev, 1);
+		fb_base = pci_resource_start(dev->pdev, 1);
 		fb_size = SAVAGE_FB_SIZE_S4;
 		aper_rsrc = 1;
 		aperture_base = fb_base + SAVAGE_APERTURE_OFFSET;
 		/* this should always be true */
-		if (drm_get_resource_len(dev, 1) == 0x08000000) {
+		if (pci_resource_len(dev->pdev, 1) == 0x08000000) {
 			/* Can use one MTRR to cover both fb and
 			 * aperture. */
 			dev_priv->mtrr[0].base = fb_base;
@@ -620,15 +621,16 @@ int savage_driver_firstopen(struct drm_device *dev)
 					 dev_priv->mtrr[0].size, DRM_MTRR_WC);
 		} else {
 			DRM_ERROR("strange pci_resource_len %08llx\n",
-				  (unsigned long long)drm_get_resource_len(dev, 1));
+				  (unsigned long long)
+				  pci_resource_len(dev->pdev, 1));
 		}
 	} else {
-		mmio_base = drm_get_resource_start(dev, 0);
+		mmio_base = pci_resource_start(dev->pdev, 0);
 		fb_rsrc = 1;
-		fb_base = drm_get_resource_start(dev, 1);
-		fb_size = drm_get_resource_len(dev, 1);
+		fb_base = pci_resource_start(dev->pdev, 1);
+		fb_size = pci_resource_len(dev->pdev, 1);
 		aper_rsrc = 2;
-		aperture_base = drm_get_resource_start(dev, 2);
+		aperture_base = pci_resource_start(dev->pdev, 2);
 		/* Automatic MTRR setup will do the right thing. */
 	}
 
diff --git a/include/drm/drmP.h b/include/drm/drmP.h
index c1b9871..8f7f5cb 100644
--- a/include/drm/drmP.h
+++ b/include/drm/drmP.h
@@ -1273,10 +1273,6 @@ extern int drm_freebufs(struct drm_device *dev, void *data,
 extern int drm_mapbufs(struct drm_device *dev, void *data,
 		       struct drm_file *file_priv);
 extern int drm_order(unsigned long size);
-extern resource_size_t drm_get_resource_start(struct drm_device *dev,
-					      unsigned int resource);
-extern resource_size_t drm_get_resource_len(struct drm_device *dev,
-					    unsigned int resource);
 
 				/* DMA support (drm_dma.h) */
 extern int drm_dma_setup(struct drm_device *dev);
-- 
1.7.0.1


^ permalink raw reply related	[flat|nested] 17+ messages in thread

* [PATCH 2/4] drm: Add support for platform devices to register as DRM devices
       [not found] ` <4B8BE489.7020402@codeaurora.org>
                     ` (3 preceding siblings ...)
  2010-05-27 19:40   ` [PATCH 1/4] drm: Remove drm_resource wrappers jcrouse
@ 2010-05-27 19:40   ` jcrouse
  2010-05-27 19:40   ` [PATCH 3/4] drm: Add __arm defines to DRM jcrouse
  2010-05-27 19:40   ` [PATCH 4/4] drm: Make sure the DRM offset matches the CPU jcrouse
  6 siblings, 0 replies; 17+ messages in thread
From: jcrouse @ 2010-05-27 19:40 UTC (permalink / raw)
  To: dri-devel; +Cc: linux-arm-msm, Jordan Crouse

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain, Size: 29387 bytes --]

From: Jordan Crouse <jcrouse@codeaurora.org>

Allow platform devices without PCI resources to be DRM devices.

Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org>
---
 drivers/gpu/drm/Kconfig               |    4 +-
 drivers/gpu/drm/Makefile              |    2 +-
 drivers/gpu/drm/drm_drv.c             |   37 +-------
 drivers/gpu/drm/drm_edid.c            |    4 +-
 drivers/gpu/drm/drm_info.c            |   23 ++++--
 drivers/gpu/drm/drm_ioctl.c           |   77 ++++++++++++------
 drivers/gpu/drm/drm_irq.c             |   15 ++--
 drivers/gpu/drm/drm_pci.c             |  143 +++++++++++++++++++++++++++++++++
 drivers/gpu/drm/drm_platform.c        |  122 ++++++++++++++++++++++++++++
 drivers/gpu/drm/drm_stub.c            |   89 +--------------------
 drivers/gpu/drm/drm_sysfs.c           |    3 +-
 drivers/gpu/drm/i915/i915_dma.c       |    1 +
 drivers/gpu/drm/i915/i915_drv.c       |    2 +-
 drivers/gpu/drm/nouveau/nouveau_drv.c |    2 +-
 drivers/gpu/drm/radeon/radeon_drv.c   |    2 +-
 drivers/gpu/drm/vmwgfx/vmwgfx_drv.c   |    2 +-
 include/drm/drmP.h                    |   52 ++++++++++--
 17 files changed, 405 insertions(+), 175 deletions(-)
 create mode 100644 drivers/gpu/drm/drm_platform.c

diff --git a/drivers/gpu/drm/Kconfig b/drivers/gpu/drm/Kconfig
index 88910e5..520ab23 100644
--- a/drivers/gpu/drm/Kconfig
+++ b/drivers/gpu/drm/Kconfig
@@ -6,7 +6,7 @@
 #
 menuconfig DRM
 	tristate "Direct Rendering Manager (XFree86 4.1.0 and higher DRI support)"
-	depends on (AGP || AGP=n) && PCI && !EMULATED_CMPXCHG && MMU
+	depends on (AGP || AGP=n) && !EMULATED_CMPXCHG && MMU
 	select I2C
 	select I2C_ALGOBIT
 	select SLOW_WORK
@@ -17,7 +17,7 @@ menuconfig DRM
 	  These modules provide support for synchronization, security, and
 	  DMA transfers. Please see <http://dri.sourceforge.net/> for more
 	  details.  You should also select and configure AGP
-	  (/dev/agpgart) support.
+	  (/dev/agpgart) support if it is available for your platform.
 
 config DRM_KMS_HELPER
 	tristate
diff --git a/drivers/gpu/drm/Makefile b/drivers/gpu/drm/Makefile
index abe3f44..b4b2b48 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 \
 		drm_drv.o drm_fops.o drm_gem.o drm_ioctl.o drm_irq.o \
 		drm_lock.o drm_memory.o drm_proc.o drm_stub.o drm_vm.o \
 		drm_agpsupport.o drm_scatter.o ati_pcigart.o drm_pci.o \
-		drm_sysfs.o drm_hashtab.o drm_sman.o drm_mm.o \
+		drm_platform.o drm_sysfs.o drm_hashtab.o drm_sman.o drm_mm.o \
 		drm_crtc.o drm_modes.o drm_edid.o \
 		drm_info.o drm_debugfs.o drm_encoder_slave.o
 
diff --git a/drivers/gpu/drm/drm_drv.c b/drivers/gpu/drm/drm_drv.c
index 4a66201..510bc87 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)
  *
  * Initializes an array of drm_device structures, and attempts to
  * initialize all available devices, using consecutive minors, registering the
- * stubs and initializing the AGP device.
+ * stubs and initializing the device.
  *
  * Expands the \c DRIVER_PREINIT and \c DRIVER_POST_INIT macros before and
  * after the initialization for driver customization.
  */
 int drm_init(struct drm_driver *driver)
 {
-	struct pci_dev *pdev = NULL;
-	const struct pci_device_id *pid;
-	int i;
-
 	DRM_DEBUG("\n");
-
 	INIT_LIST_HEAD(&driver->device_list);
 
-	if (driver->driver_features & DRIVER_MODESET)
-		return pci_register_driver(&driver->pci_driver);
-
-	/* If not using KMS, fall back to stealth mode manual scanning. */
-	for (i = 0; driver->pci_driver.id_table[i].vendor != 0; i++) {
-		pid = &driver->pci_driver.id_table[i];
-
-		/* Loop around setting up a DRM device for each PCI device
-		 * matching our ID and device class.  If we had the internal
-		 * function that pci_get_subsys and pci_get_class used, we'd
-		 * be able to just pass pid in instead of doing a two-stage
-		 * thing.
-		 */
-		pdev = NULL;
-		while ((pdev =
-			pci_get_subsys(pid->vendor, pid->device, pid->subvendor,
-				       pid->subdevice, pdev)) != NULL) {
-			if ((pdev->class & pid->class_mask) != pid->class)
-				continue;
-
-			/* stealth mode requires a manual probe */
-			pci_dev_get(pdev);
-			drm_get_dev(pdev, pid, driver);
-		}
-	}
-	return 0;
+	if (driver->driver_features & DRIVER_USE_PLATFORM_DEVICE)
+		return drm_platform_init(driver);
+	else
+		return drm_pci_init(driver);
 }
 
 EXPORT_SYMBOL(drm_init);
diff --git a/drivers/gpu/drm/drm_edid.c b/drivers/gpu/drm/drm_edid.c
index c198186..5b98f14 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)
 	return block;
 
 carp:
-	dev_warn(&connector->dev->pdev->dev, "%s: EDID block %d invalid.\n",
+	dev_warn(&connector->dev->dev, "%s: EDID block %d invalid.\n",
 		 drm_get_connector_name(connector), j);
 
 out:
@@ -1626,7 +1626,7 @@ int drm_add_edid_modes(struct drm_connector *connector, struct edid *edid)
 		return 0;
 	}
 	if (!drm_edid_is_valid(edid)) {
-		dev_warn(&connector->dev->pdev->dev, "%s: EDID invalid.\n",
+		dev_warn(&connector->dev->dev, "%s: EDID invalid.\n",
 			 drm_get_connector_name(connector));
 		return 0;
 	}
diff --git a/drivers/gpu/drm/drm_info.c b/drivers/gpu/drm/drm_info.c
index f0f6c6b..2ef2c78 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)
 	if (!master)
 		return 0;
 
-	if (master->unique) {
-		seq_printf(m, "%s %s %s\n",
-			   dev->driver->pci_driver.name,
-			   pci_name(dev->pdev), master->unique);
+	if (drm_core_check_feature(dev, DRIVER_USE_PLATFORM_DEVICE)) {
+		if (master->unique) {
+			seq_printf(m, "%s %s %s\n",
+					dev->driver->platform_device->name,
+					dev_name(dev->dev), master->unique);
+		} else {
+			seq_printf(m, "%s\n",
+				dev->driver->platform_device->name);
+		}
 	} else {
-		seq_printf(m, "%s %s\n", dev->driver->pci_driver.name,
-			   pci_name(dev->pdev));
+		if (master->unique) {
+			seq_printf(m, "%s %s %s\n",
+				dev->driver->pci_driver.name,
+				dev_name(dev->dev), master->unique);
+		} else {
+			seq_printf(m, "%s %s\n", dev->driver->pci_driver.name,
+				dev_name(dev->dev));
+		}
 	}
 
 	return 0;
diff --git a/drivers/gpu/drm/drm_ioctl.c b/drivers/gpu/drm/drm_ioctl.c
index 9b9ff46..76d3d18 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)
 	struct drm_master *master = file_priv->master;
 	int len;
 
-	if (master->unique != NULL)
-		return -EBUSY;
-
-	master->unique_len = 40;
-	master->unique_size = master->unique_len;
-	master->unique = kmalloc(master->unique_size, GFP_KERNEL);
-	if (master->unique == NULL)
-		return -ENOMEM;
+	if (drm_core_check_feature(dev, DRIVER_USE_PLATFORM_DEVICE)) {
+		master->unique_len = 10 + strlen(dev->platformdev->name);
+		master->unique = kmalloc(master->unique_len + 1, GFP_KERNEL);
+
+		if (master->unique == NULL)
+			return -ENOMEM;
+
+		len = snprintf(master->unique, master->unique_len,
+			"platform:%s", dev->platformdev->name);
+
+		if (len > master->unique_len)
+			DRM_ERROR("Unique buffer overflowed\n");
+
+		dev->devname =
+			kmalloc(strlen(dev->platformdev->name) +
+				master->unique_len + 2, GFP_KERNEL);
+
+		if (dev->devname == NULL)
+			return -ENOMEM;
+
+		sprintf(dev->devname, "%s@%s", dev->platformdev->name,
+			master->unique);
+
+	} else {
+		master->unique_len = 40;
+		master->unique_size = master->unique_len;
+		master->unique = kmalloc(master->unique_size, GFP_KERNEL);
+		if (master->unique == NULL)
+			return -ENOMEM;
+
+		len = snprintf(master->unique, master->unique_len,
+			"pci:%04x:%02x:%02x.%d",
+			drm_get_pci_domain(dev),
+			dev->pdev->bus->number,
+			PCI_SLOT(dev->pdev->devfn),
+			PCI_FUNC(dev->pdev->devfn));
+		if (len >= master->unique_len)
+			DRM_ERROR("buffer overflow");
+		else
+			master->unique_len = len;
 
-	len = snprintf(master->unique, master->unique_len, "pci:%04x:%02x:%02x.%d",
-		       drm_get_pci_domain(dev),
-		       dev->pdev->bus->number,
-		       PCI_SLOT(dev->pdev->devfn),
-		       PCI_FUNC(dev->pdev->devfn));
-	if (len >= master->unique_len)
-		DRM_ERROR("buffer overflow");
-	else
-		master->unique_len = len;
+		dev->devname =
+			kmalloc(strlen(dev->driver->pci_driver.name) +
+				master->unique_len + 2, GFP_KERNEL);
 
-	dev->devname = kmalloc(strlen(dev->driver->pci_driver.name) +
-			       master->unique_len + 2, GFP_KERNEL);
-	if (dev->devname == NULL)
-		return -ENOMEM;
+		if (dev->devname == NULL)
+			return -ENOMEM;
 
-	sprintf(dev->devname, "%s@%s", dev->driver->pci_driver.name,
-		master->unique);
+		sprintf(dev->devname, "%s@%s", dev->driver->pci_driver.name,
+			master->unique);
+	}
 
 	return 0;
 }
diff --git a/drivers/gpu/drm/drm_irq.c b/drivers/gpu/drm/drm_irq.c
index a263b70..6353b62 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,
 {
 	struct drm_irq_busid *p = data;
 
+	if (drm_core_check_feature(dev, DRIVER_USE_PLATFORM_DEVICE))
+		return -EINVAL;
+
 	if (!drm_core_check_feature(dev, DRIVER_HAVE_IRQ))
 		return -EINVAL;
 
@@ -211,7 +214,7 @@ int drm_irq_install(struct drm_device *dev)
 	if (!drm_core_check_feature(dev, DRIVER_HAVE_IRQ))
 		return -EINVAL;
 
-	if (dev->pdev->irq == 0)
+	if (drm_dev_to_irq(dev) == 0)
 		return -EINVAL;
 
 	mutex_lock(&dev->struct_mutex);
@@ -229,7 +232,7 @@ int drm_irq_install(struct drm_device *dev)
 	dev->irq_enabled = 1;
 	mutex_unlock(&dev->struct_mutex);
 
-	DRM_DEBUG("irq=%d\n", dev->pdev->irq);
+	DRM_DEBUG("irq=%d\n", drm_dev_to_irq(dev));
 
 	/* Before installing handler */
 	dev->driver->irq_preinstall(dev);
@@ -302,14 +305,14 @@ int drm_irq_uninstall(struct drm_device * dev)
 	if (!irq_enabled)
 		return -EINVAL;
 
-	DRM_DEBUG("irq=%d\n", dev->pdev->irq);
+	DRM_DEBUG("irq=%d\n", drm_dev_to_irq(dev));
 
 	if (!drm_core_check_feature(dev, DRIVER_MODESET))
 		vga_client_register(dev->pdev, NULL, NULL, NULL);
 
 	dev->driver->irq_uninstall(dev);
 
-	free_irq(dev->pdev->irq, dev);
+	free_irq(drm_dev_to_irq(dev), dev);
 
 	return 0;
 }
@@ -341,7 +344,7 @@ int drm_control(struct drm_device *dev, void *data,
 		if (drm_core_check_feature(dev, DRIVER_MODESET))
 			return 0;
 		if (dev->if_version < DRM_IF_VERSION(1, 2) &&
-		    ctl->irq != dev->pdev->irq)
+		    ctl->irq != drm_dev_to_irq(dev))
 			return -EINVAL;
 		return drm_irq_install(dev);
 	case DRM_UNINST_HANDLER:
@@ -651,7 +654,7 @@ int drm_wait_vblank(struct drm_device *dev, void *data,
 	int ret = 0;
 	unsigned int flags, seq, crtc;
 
-	if ((!dev->pdev->irq) || (!dev->irq_enabled))
+	if ((!drm_dev_to_irq(dev)) || (!dev->irq_enabled))
 		return -EINVAL;
 
 	if (vblwait->request.type & _DRM_VBLANK_SIGNAL)
diff --git a/drivers/gpu/drm/drm_pci.c b/drivers/gpu/drm/drm_pci.c
index 2ea9ad4..e20f78b 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)
 
 EXPORT_SYMBOL(drm_pci_free);
 
+#ifdef CONFIG_PCI
+/**
+ * Register.
+ *
+ * \param pdev - PCI device structure
+ * \param ent entry from the PCI ID table with device type flags
+ * \return zero on success or a negative number on failure.
+ *
+ * Attempt to gets inter module "drm" information. If we are first
+ * then register the character device and inter module information.
+ * Try and register, if we fail to register, backout previous work.
+ */
+int drm_get_pci_dev(struct pci_dev *pdev, const struct pci_device_id *ent,
+		    struct drm_driver *driver)
+{
+	struct drm_device *dev;
+	int ret;
+
+	DRM_DEBUG("\n");
+
+	dev = kzalloc(sizeof(*dev), GFP_KERNEL);
+	if (!dev)
+		return -ENOMEM;
+
+	ret = pci_enable_device(pdev);
+	if (ret)
+		goto err_g1;
+
+	pci_set_master(pdev);
+
+	dev->pdev = pdev;
+	dev->dev = &pdev->dev;
+
+	dev->pci_device = pdev->device;
+	dev->pci_vendor = pdev->vendor;
+
+#ifdef __alpha__
+	dev->hose = pdev->sysdata;
+#endif
+
+	if ((ret = drm_fill_in_dev(dev, ent, driver))) {
+		printk(KERN_ERR "DRM: Fill_in_dev failed.\n");
+		goto err_g2;
+	}
+
+	if (drm_core_check_feature(dev, DRIVER_MODESET)) {
+		pci_set_drvdata(pdev, dev);
+		ret = drm_get_minor(dev, &dev->control, DRM_MINOR_CONTROL);
+		if (ret)
+			goto err_g2;
+	}
+
+	if ((ret = drm_get_minor(dev, &dev->primary, DRM_MINOR_LEGACY)))
+		goto err_g3;
+
+	if (dev->driver->load) {
+		ret = dev->driver->load(dev, ent->driver_data);
+		if (ret)
+			goto err_g4;
+	}
+
+	/* setup the grouping for the legacy output */
+	if (drm_core_check_feature(dev, DRIVER_MODESET)) {
+		ret = drm_mode_group_init_legacy_group(dev,
+						&dev->primary->mode_group);
+		if (ret)
+			goto err_g4;
+	}
+
+	list_add_tail(&dev->driver_item, &driver->device_list);
+
+	DRM_INFO("Initialized %s %d.%d.%d %s for %s on minor %d\n",
+		 driver->name, driver->major, driver->minor, driver->patchlevel,
+		 driver->date, pci_name(pdev), dev->primary->index);
+
+	return 0;
+
+err_g4:
+	drm_put_minor(&dev->primary);
+err_g3:
+	if (drm_core_check_feature(dev, DRIVER_MODESET))
+		drm_put_minor(&dev->control);
+err_g2:
+	pci_disable_device(pdev);
+err_g1:
+	kfree(dev);
+	return ret;
+}
+EXPORT_SYMBOL(drm_get_pci_dev);
+
+/**
+ * PCI device initialization. Called via drm_init at module load time,
+ *
+ * \return zero on success or a negative number on failure.
+ *
+ * Initializes a drm_device structures,registering the
+ * stubs and initializing the AGP device.
+ *
+ * Expands the \c DRIVER_PREINIT and \c DRIVER_POST_INIT macros before and
+ * after the initialization for driver customization.
+ */
+int drm_pci_init(struct drm_driver *driver)
+{
+	struct pci_dev *pdev = NULL;
+	const struct pci_device_id *pid;
+	int i;
+
+	if (driver->driver_features & DRIVER_MODESET)
+		return pci_register_driver(&driver->pci_driver);
+
+	/* If not using KMS, fall back to stealth mode manual scanning. */
+	for (i = 0; driver->pci_driver.id_table[i].vendor != 0; i++) {
+		pid = &driver->pci_driver.id_table[i];
+
+		/* Loop around setting up a DRM device for each PCI device
+		 * matching our ID and device class.  If we had the internal
+		 * function that pci_get_subsys and pci_get_class used, we'd
+		 * be able to just pass pid in instead of doing a two-stage
+		 * thing.
+		 */
+		pdev = NULL;
+		while ((pdev =
+			pci_get_subsys(pid->vendor, pid->device, pid->subvendor,
+				       pid->subdevice, pdev)) != NULL) {
+			if ((pdev->class & pid->class_mask) != pid->class)
+				continue;
+
+			/* stealth mode requires a manual probe */
+			pci_dev_get(pdev);
+			drm_get_pci_dev(pdev, pid, driver);
+		}
+	}
+	return 0;
+}
+
+#else
+
+int drm_pci_init(struct drm_driver *driver)
+{
+	return -1;
+}
+
+#endif
 /*@}*/
diff --git a/drivers/gpu/drm/drm_platform.c b/drivers/gpu/drm/drm_platform.c
new file mode 100644
index 0000000..460e9a3
--- /dev/null
+++ b/drivers/gpu/drm/drm_platform.c
@@ -0,0 +1,122 @@
+/*
+ * Derived from drm_pci.c
+ *
+ * Copyright 2003 José Fonseca.
+ * Copyright 2003 Leif Delgass.
+ * Copyright (c) 2009, Code Aurora Forum.
+ * All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the next
+ * paragraph) shall be included in all copies or substantial portions of the
+ * Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL THE
+ * AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+ * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ */
+
+#include "drmP.h"
+
+/**
+ * Register.
+ *
+ * \param platdev - Platform device struture
+ * \return zero on success or a negative number on failure.
+ *
+ * Attempt to gets inter module "drm" information. If we are first
+ * then register the character device and inter module information.
+ * Try and register, if we fail to register, backout previous work.
+ */
+
+int drm_get_platform_dev(struct platform_device *platdev,
+			 struct drm_driver *driver)
+{
+	struct drm_device *dev;
+	int ret;
+
+	DRM_DEBUG("\n");
+
+	dev = kzalloc(sizeof(*dev), GFP_KERNEL);
+	if (!dev)
+		return -ENOMEM;
+
+	dev->platformdev = platdev;
+	dev->dev = &platdev->dev;
+
+	ret = drm_fill_in_dev(dev, NULL, driver);
+
+	if (ret) {
+		printk(KERN_ERR "DRM: Fill_in_dev failed.\n");
+		goto err_g1;
+	}
+
+	if (drm_core_check_feature(dev, DRIVER_MODESET)) {
+		dev_set_drvdata(&platdev->dev, dev);
+		ret = drm_get_minor(dev, &dev->control, DRM_MINOR_CONTROL);
+		if (ret)
+			goto err_g1;
+	}
+
+	ret = drm_get_minor(dev, &dev->primary, DRM_MINOR_LEGACY);
+	if (ret)
+		goto err_g2;
+
+	if (dev->driver->load) {
+		ret = dev->driver->load(dev, 0);
+		if (ret)
+			goto err_g3;
+	}
+
+	/* setup the grouping for the legacy output */
+	if (drm_core_check_feature(dev, DRIVER_MODESET)) {
+		ret = drm_mode_group_init_legacy_group(dev,
+				&dev->primary->mode_group);
+		if (ret)
+			goto err_g3;
+	}
+
+	list_add_tail(&dev->driver_item, &driver->device_list);
+
+	DRM_INFO("Initialized %s %d.%d.%d %s on minor %d\n",
+		 driver->name, driver->major, driver->minor, driver->patchlevel,
+		 driver->date, dev->primary->index);
+
+	return 0;
+
+err_g3:
+	drm_put_minor(&dev->primary);
+err_g2:
+	if (drm_core_check_feature(dev, DRIVER_MODESET))
+		drm_put_minor(&dev->control);
+err_g1:
+	kfree(dev);
+	return ret;
+}
+EXPORT_SYMBOL(drm_get_platform_dev);
+
+/**
+ * Platform device initialization. Called via drm_init at module load time,
+ *
+ * \return zero on success or a negative number on failure.
+ *
+ * Initializes a drm_device structures,registering the
+ * stubs
+ *
+ * Expands the \c DRIVER_PREINIT and \c DRIVER_POST_INIT macros before and
+ * after the initialization for driver customization.
+ */
+
+int drm_platform_init(struct drm_driver *driver)
+{
+	return drm_get_platform_dev(driver->platform_device, driver);
+}
diff --git a/drivers/gpu/drm/drm_stub.c b/drivers/gpu/drm/drm_stub.c
index a0c365f..63575e2 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,
 	return 0;
 }
 
-static int drm_fill_in_dev(struct drm_device * dev, struct pci_dev *pdev,
+int drm_fill_in_dev(struct drm_device *dev,
 			   const struct pci_device_id *ent,
 			   struct drm_driver *driver)
 {
@@ -245,14 +245,6 @@ static int drm_fill_in_dev(struct drm_device * dev, struct pci_dev *pdev,
 
 	idr_init(&dev->drw_idr);
 
-	dev->pdev = pdev;
-	dev->pci_device = pdev->device;
-	dev->pci_vendor = pdev->vendor;
-
-#ifdef __alpha__
-	dev->hose = pdev->sysdata;
-#endif
-
 	if (drm_ht_create(&dev->map_hash, 12)) {
 		return -ENOMEM;
 	}
@@ -321,7 +313,7 @@ static int drm_fill_in_dev(struct drm_device * dev, struct pci_dev *pdev,
  * create the proc init entry via proc_init(). This routines assigns
  * minor numbers to secondary heads of multi-headed cards
  */
-static int drm_get_minor(struct drm_device *dev, struct drm_minor **minor, int type)
+int drm_get_minor(struct drm_device *dev, struct drm_minor **minor, int type)
 {
 	struct drm_minor *new_minor;
 	int ret;
@@ -388,83 +380,6 @@ err_idr:
 }
 
 /**
- * Register.
- *
- * \param pdev - PCI device structure
- * \param ent entry from the PCI ID table with device type flags
- * \return zero on success or a negative number on failure.
- *
- * Attempt to gets inter module "drm" information. If we are first
- * then register the character device and inter module information.
- * Try and register, if we fail to register, backout previous work.
- */
-int drm_get_dev(struct pci_dev *pdev, const struct pci_device_id *ent,
-		struct drm_driver *driver)
-{
-	struct drm_device *dev;
-	int ret;
-
-	DRM_DEBUG("\n");
-
-	dev = kzalloc(sizeof(*dev), GFP_KERNEL);
-	if (!dev)
-		return -ENOMEM;
-
-	ret = pci_enable_device(pdev);
-	if (ret)
-		goto err_g1;
-
-	pci_set_master(pdev);
-	if ((ret = drm_fill_in_dev(dev, pdev, ent, driver))) {
-		printk(KERN_ERR "DRM: Fill_in_dev failed.\n");
-		goto err_g2;
-	}
-
-	if (drm_core_check_feature(dev, DRIVER_MODESET)) {
-		pci_set_drvdata(pdev, dev);
-		ret = drm_get_minor(dev, &dev->control, DRM_MINOR_CONTROL);
-		if (ret)
-			goto err_g2;
-	}
-
-	if ((ret = drm_get_minor(dev, &dev->primary, DRM_MINOR_LEGACY)))
-		goto err_g3;
-
-	if (dev->driver->load) {
-		ret = dev->driver->load(dev, ent->driver_data);
-		if (ret)
-			goto err_g4;
-	}
-
-        /* setup the grouping for the legacy output */
-	if (drm_core_check_feature(dev, DRIVER_MODESET)) {
-		ret = drm_mode_group_init_legacy_group(dev, &dev->primary->mode_group);
-		if (ret)
-			goto err_g4;
-	}
-
-	list_add_tail(&dev->driver_item, &driver->device_list);
-
-	DRM_INFO("Initialized %s %d.%d.%d %s for %s on minor %d\n",
-		 driver->name, driver->major, driver->minor, driver->patchlevel,
-		 driver->date, pci_name(pdev), dev->primary->index);
-
-	return 0;
-
-err_g4:
-	drm_put_minor(&dev->primary);
-err_g3:
-	if (drm_core_check_feature(dev, DRIVER_MODESET))
-		drm_put_minor(&dev->control);
-err_g2:
-	pci_disable_device(pdev);
-err_g1:
-	kfree(dev);
-	return ret;
-}
-EXPORT_SYMBOL(drm_get_dev);
-
-/**
  * Put a secondary minor number.
  *
  * \param sec_minor - structure to be released
diff --git a/drivers/gpu/drm/drm_sysfs.c b/drivers/gpu/drm/drm_sysfs.c
index 101d381..5678701 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)
 	int err;
 	char *minor_str;
 
-	minor->kdev.parent = &minor->dev->pdev->dev;
+	minor->kdev.parent = &minor->dev->dev;
+
 	minor->kdev.class = drm_class;
 	minor->kdev.release = drm_sysfs_device_release;
 	minor->kdev.devt = minor->device;
diff --git a/drivers/gpu/drm/i915/i915_dma.c b/drivers/gpu/drm/i915/i915_dma.c
index 9fe2d08..9bed561 100644
--- a/drivers/gpu/drm/i915/i915_dma.c
+++ b/drivers/gpu/drm/i915/i915_dma.c
@@ -34,6 +34,7 @@
 #include "i915_drm.h"
 #include "i915_drv.h"
 #include "i915_trace.h"
+#include <linux/pci.h>
 #include <linux/vgaarb.h>
 #include <linux/acpi.h>
 #include <linux/pnp.h>
diff --git a/drivers/gpu/drm/i915/i915_drv.c b/drivers/gpu/drm/i915/i915_drv.c
index 5c51e45..b7aecf5 100644
--- a/drivers/gpu/drm/i915/i915_drv.c
+++ b/drivers/gpu/drm/i915/i915_drv.c
@@ -435,7 +435,7 @@ int i965_reset(struct drm_device *dev, u8 flags)
 static int __devinit
 i915_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
 {
-	return drm_get_dev(pdev, ent, &driver);
+	return drm_get_pci_dev(pdev, ent, &driver);
 }
 
 static void
diff --git a/drivers/gpu/drm/nouveau/nouveau_drv.c b/drivers/gpu/drm/nouveau/nouveau_drv.c
index c6079e3..f60a2b2 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;
 static int __devinit
 nouveau_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
 {
-	return drm_get_dev(pdev, ent, &driver);
+	return drm_get_pci_dev(pdev, ent, &driver);
 }
 
 static void
diff --git a/drivers/gpu/drm/radeon/radeon_drv.c b/drivers/gpu/drm/radeon/radeon_drv.c
index 902d173..b6c84ad 100644
--- a/drivers/gpu/drm/radeon/radeon_drv.c
+++ b/drivers/gpu/drm/radeon/radeon_drv.c
@@ -237,7 +237,7 @@ static struct drm_driver kms_driver;
 static int __devinit
 radeon_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
 {
-	return drm_get_dev(pdev, ent, &kms_driver);
+	return drm_get_pci_dev(pdev, ent, &kms_driver);
 }
 
 static void
diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_drv.c b/drivers/gpu/drm/vmwgfx/vmwgfx_drv.c
index 0c9c081..f7f248d 100644
--- a/drivers/gpu/drm/vmwgfx/vmwgfx_drv.c
+++ b/drivers/gpu/drm/vmwgfx/vmwgfx_drv.c
@@ -758,7 +758,7 @@ static struct drm_driver driver = {
 
 static int vmw_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
 {
-	return drm_get_dev(pdev, ent, &driver);
+	return drm_get_pci_dev(pdev, ent, &driver);
 }
 
 static int __init vmwgfx_init(void)
diff --git a/include/drm/drmP.h b/include/drm/drmP.h
index 8f7f5cb..6235169 100644
--- a/include/drm/drmP.h
+++ b/include/drm/drmP.h
@@ -9,6 +9,7 @@
 /*
  * Copyright 1999 Precision Insight, Inc., Cedar Park, Texas.
  * Copyright 2000 VA Linux Systems, Inc., Sunnyvale, California.
+ * Copyright (c) 2009-2010, Code Aurora Forum.
  * All rights reserved.
  *
  * Permission is hereby granted, free of charge, to any person obtaining a
@@ -48,6 +49,7 @@
 #include <linux/proc_fs.h>
 #include <linux/init.h>
 #include <linux/file.h>
+#include <linux/platform_device.h>
 #include <linux/pci.h>
 #include <linux/jiffies.h>
 #include <linux/smp_lock.h>	/* For (un)lock_kernel */
@@ -144,6 +146,7 @@ extern void drm_ut_debug_printk(unsigned int request_level,
 #define DRIVER_IRQ_VBL2    0x800
 #define DRIVER_GEM         0x1000
 #define DRIVER_MODESET     0x2000
+#define DRIVER_USE_PLATFORM_DEVICE  0x4000
 
 /***********************************************************************/
 /** \name Begin the DRM... */
@@ -823,6 +826,7 @@ struct drm_driver {
 	int num_ioctls;
 	struct file_operations fops;
 	struct pci_driver pci_driver;
+	struct platform_device *platform_device;
 	/* List of devices hanging off this driver */
 	struct list_head device_list;
 };
@@ -1015,12 +1019,16 @@ struct drm_device {
 
 	struct drm_agp_head *agp;	/**< AGP data */
 
+	struct device *dev;             /**< Device structure */
 	struct pci_dev *pdev;		/**< PCI device structure */
 	int pci_vendor;			/**< PCI vendor id */
 	int pci_device;			/**< PCI device id */
 #ifdef __alpha__
 	struct pci_controller *hose;
 #endif
+
+	struct platform_device *platformdev; /**< Platform device struture */
+
 	struct drm_sg_mem *sg;	/**< Scatter gather memory */
 	int num_crtcs;                  /**< Number of CRTCs on this device */
 	void *dev_private;		/**< device private data */
@@ -1060,17 +1068,21 @@ struct drm_device {
 
 };
 
-static inline int drm_dev_to_irq(struct drm_device *dev)
-{
-	return dev->pdev->irq;
-}
-
 static __inline__ int drm_core_check_feature(struct drm_device *dev,
 					     int feature)
 {
 	return ((dev->driver->driver_features & feature) ? 1 : 0);
 }
 
+
+static inline int drm_dev_to_irq(struct drm_device *dev)
+{
+	if (drm_core_check_feature(dev, DRIVER_USE_PLATFORM_DEVICE))
+		return platform_get_irq(dev->platformdev, 0);
+	else
+		return dev->pdev->irq;
+}
+
 #ifdef __alpha__
 #define drm_get_pci_domain(dev) dev->hose->index
 #else
@@ -1347,8 +1359,11 @@ extern int drm_dropmaster_ioctl(struct drm_device *dev, void *data,
 struct drm_master *drm_master_create(struct drm_minor *minor);
 extern struct drm_master *drm_master_get(struct drm_master *master);
 extern void drm_master_put(struct drm_master **master);
-extern int drm_get_dev(struct pci_dev *pdev, const struct pci_device_id *ent,
-		       struct drm_driver *driver);
+extern int drm_get_pci_dev(struct pci_dev *pdev,
+			   const struct pci_device_id *ent,
+			   struct drm_driver *driver);
+extern int drm_get_platform_dev(struct platform_device *pdev,
+				struct drm_driver *driver);
 extern void drm_put_dev(struct drm_device *dev);
 extern int drm_put_minor(struct drm_minor **minor);
 extern unsigned int drm_debug;
@@ -1525,6 +1540,9 @@ static __inline__ struct drm_local_map *drm_core_findmap(struct drm_device *dev,
 
 static __inline__ int drm_device_is_agp(struct drm_device *dev)
 {
+	if (drm_core_check_feature(dev, DRIVER_USE_PLATFORM_DEVICE))
+		return 0;
+
 	if (dev->driver->device_is_agp != NULL) {
 		int err = (*dev->driver->device_is_agp) (dev);
 
@@ -1538,7 +1556,10 @@ static __inline__ int drm_device_is_agp(struct drm_device *dev)
 
 static __inline__ int drm_device_is_pcie(struct drm_device *dev)
 {
-	return pci_find_capability(dev->pdev, PCI_CAP_ID_EXP);
+	if (drm_core_check_feature(dev, DRIVER_USE_PLATFORM_DEVICE))
+		return 0;
+	else
+		return pci_find_capability(dev->pdev, PCI_CAP_ID_EXP);
 }
 
 static __inline__ void drm_core_dropmap(struct drm_local_map *map)
@@ -1546,6 +1567,21 @@ static __inline__ void drm_core_dropmap(struct drm_local_map *map)
 }
 
 #include "drm_mem_util.h"
+
+static inline void *drm_get_device(struct drm_device *dev)
+{
+	if (drm_core_check_feature(dev, DRIVER_USE_PLATFORM_DEVICE))
+		return dev->platformdev;
+	else
+		return dev->pdev;
+}
+
+extern int drm_platform_init(struct drm_driver *driver);
+extern int drm_pci_init(struct drm_driver *driver);
+extern int drm_fill_in_dev(struct drm_device *dev,
+			   const struct pci_device_id *ent,
+			   struct drm_driver *driver);
+int drm_get_minor(struct drm_device *dev, struct drm_minor **minor, int type);
 /*@}*/
 
 #endif				/* __KERNEL__ */
-- 
1.7.0.1


^ permalink raw reply related	[flat|nested] 17+ messages in thread

* [PATCH 3/4] drm:  Add __arm defines to DRM
       [not found] ` <4B8BE489.7020402@codeaurora.org>
                     ` (4 preceding siblings ...)
  2010-05-27 19:40   ` [PATCH 2/4] drm: Add support for platform devices to register as DRM devices jcrouse
@ 2010-05-27 19:40   ` jcrouse
  2010-05-27 19:40   ` [PATCH 4/4] drm: Make sure the DRM offset matches the CPU jcrouse
  6 siblings, 0 replies; 17+ messages in thread
From: jcrouse @ 2010-05-27 19:40 UTC (permalink / raw)
  To: dri-devel; +Cc: linux-arm-msm, Jordan Crouse

From: Jordan Crouse <jcrouse@codeaurora.org>

Add __arm defines to specify behavior specific for
an ARM processor.

Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org>
---
 drivers/gpu/drm/drm_bufs.c |    2 +-
 drivers/gpu/drm/drm_vm.c   |   14 +++++++++++++-
 2 files changed, 14 insertions(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/drm_bufs.c b/drivers/gpu/drm/drm_bufs.c
index 3c2c663..a5c9ce9 100644
--- a/drivers/gpu/drm/drm_bufs.c
+++ b/drivers/gpu/drm/drm_bufs.c
@@ -176,7 +176,7 @@ static int drm_addmap_core(struct drm_device * dev, resource_size_t offset,
 	switch (map->type) {
 	case _DRM_REGISTERS:
 	case _DRM_FRAME_BUFFER:
-#if !defined(__sparc__) && !defined(__alpha__) && !defined(__ia64__) && !defined(__powerpc64__) && !defined(__x86_64__)
+#if !defined(__sparc__) && !defined(__alpha__) && !defined(__ia64__) && !defined(__powerpc64__) && !defined(__x86_64__) && !defined(__arm__)
 		if (map->offset + (map->size-1) < map->offset ||
 		    map->offset < virt_to_phys(high_memory)) {
 			kfree(map);
diff --git a/drivers/gpu/drm/drm_vm.c b/drivers/gpu/drm/drm_vm.c
index c3b13fb..3778360 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)
 		tmp = pgprot_writecombine(tmp);
 	else
 		tmp = pgprot_noncached(tmp);
-#elif defined(__sparc__)
+#elif defined(__sparc__) || defined(__arm__)
 	tmp = pgprot_noncached(tmp);
 #endif
 	return tmp;
@@ -601,6 +601,7 @@ int drm_mmap_locked(struct file *filp, struct vm_area_struct *vma)
 	}
 
 	switch (map->type) {
+#if !defined(__arm__)
 	case _DRM_AGP:
 		if (drm_core_has_AGP(dev) && dev->agp->cant_use_aperture) {
 			/*
@@ -615,20 +616,31 @@ int drm_mmap_locked(struct file *filp, struct vm_area_struct *vma)
 			break;
 		}
 		/* fall through to _DRM_FRAME_BUFFER... */
+#endif
 	case _DRM_FRAME_BUFFER:
 	case _DRM_REGISTERS:
 		offset = dev->driver->get_reg_ofs(dev);
 		vma->vm_flags |= VM_IO;	/* not in core dump */
 		vma->vm_page_prot = drm_io_prot(map->type, vma);
+#if !defined(__arm__)
 		if (io_remap_pfn_range(vma, vma->vm_start,
 				       (map->offset + offset) >> PAGE_SHIFT,
 				       vma->vm_end - vma->vm_start,
 				       vma->vm_page_prot))
 			return -EAGAIN;
+#else
+		if (remap_pfn_range(vma, vma->vm_start,
+					(map->offset + offset) >> PAGE_SHIFT,
+					vma->vm_end - vma->vm_start,
+					vma->vm_page_prot))
+			return -EAGAIN;
+#endif
+
 		DRM_DEBUG("   Type = %d; start = 0x%lx, end = 0x%lx,"
 			  " offset = 0x%llx\n",
 			  map->type,
 			  vma->vm_start, vma->vm_end, (unsigned long long)(map->offset + offset));
+
 		vma->vm_ops = &drm_vm_ops;
 		break;
 	case _DRM_CONSISTENT:
-- 
1.7.0.1


^ permalink raw reply related	[flat|nested] 17+ messages in thread

* [PATCH 4/4] drm:  Make sure the DRM offset matches the CPU
       [not found] ` <4B8BE489.7020402@codeaurora.org>
                     ` (5 preceding siblings ...)
  2010-05-27 19:40   ` [PATCH 3/4] drm: Add __arm defines to DRM jcrouse
@ 2010-05-27 19:40   ` jcrouse
  6 siblings, 0 replies; 17+ messages in thread
From: jcrouse @ 2010-05-27 19:40 UTC (permalink / raw)
  To: dri-devel; +Cc: linux-arm-msm, Jordan Crouse

From: Jordan Crouse <jcrouse@codeaurora.org>

The pgoff option in mmap() is defined as an unsigned long
so the offset generated by DRM needs to fit into
BITS_PER_LONG for the CPU in question.

Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org>
---
 drivers/gpu/drm/drm_gem.c |   10 ++++++++++
 1 files changed, 10 insertions(+), 0 deletions(-)

diff --git a/drivers/gpu/drm/drm_gem.c b/drivers/gpu/drm/drm_gem.c
index 33dad3f..8601b72 100644
--- a/drivers/gpu/drm/drm_gem.c
+++ b/drivers/gpu/drm/drm_gem.c
@@ -68,8 +68,18 @@
  * We make up offsets for buffer objects so we can recognize them at
  * mmap time.
  */
+
+/* pgoff in mmap is an unsigned long, so we need to make sure that
+ * the faked up offset will fit
+ */
+
+#if BITS_PER_LONG == 64
 #define DRM_FILE_PAGE_OFFSET_START ((0xFFFFFFFFUL >> PAGE_SHIFT) + 1)
 #define DRM_FILE_PAGE_OFFSET_SIZE ((0xFFFFFFFFUL >> PAGE_SHIFT) * 16)
+#else
+#define DRM_FILE_PAGE_OFFSET_START ((0xFFFFFFFUL >> PAGE_SHIFT) + 1)
+#define DRM_FILE_PAGE_OFFSET_SIZE ((0xFFFFFFFUL >> PAGE_SHIFT) * 16)
+#endif
 
 /**
  * Initialize the GEM device fields
-- 
1.7.0.1


^ permalink raw reply related	[flat|nested] 17+ messages in thread

* Re: [PATCH 1/4] drm: Remove drm_resource wrappers
  2010-05-27 19:40   ` [PATCH 1/4] drm: Remove drm_resource wrappers jcrouse
@ 2010-05-27 21:15     ` Matt Turner
  0 siblings, 0 replies; 17+ messages in thread
From: Matt Turner @ 2010-05-27 21:15 UTC (permalink / raw)
  To: jcrouse; +Cc: dri-devel, linux-arm-msm

Seems like a good simplification.

Reviewed-by: Matt Turner <mattst88@gmail.com>

^ permalink raw reply	[flat|nested] 17+ messages in thread

* [PATCH v3] DRM platform device support
  2010-05-27 19:40   ` [PATCH v2] DRM platform device support jcrouse
@ 2010-08-04 20:48     ` Jordan Crouse
  2010-08-04 20:48     ` [PATCH 1/4] drm: Remove drm_resource wrappers Jordan Crouse
                       ` (3 subsequent siblings)
  4 siblings, 0 replies; 17+ messages in thread
From: Jordan Crouse @ 2010-08-04 20:48 UTC (permalink / raw)
  To: dri-devel; +Cc: linux-arm-msm

DRM platform device support freshly rebased for 2.6.35.  Nothing
changed in the code over the set I sent on 5/27.

Jordan

^ permalink raw reply	[flat|nested] 17+ messages in thread

* [PATCH 1/4] drm:  Remove drm_resource wrappers
  2010-05-27 19:40   ` [PATCH v2] DRM platform device support jcrouse
  2010-08-04 20:48     ` [PATCH v3] " Jordan Crouse
@ 2010-08-04 20:48     ` Jordan Crouse
  2010-08-04 20:53       ` Matt Turner
  2010-08-04 20:48     ` [PATCH 2/4] drm: Add support for platform devices to register as DRM devices Jordan Crouse
                       ` (2 subsequent siblings)
  4 siblings, 1 reply; 17+ messages in thread
From: Jordan Crouse @ 2010-08-04 20:48 UTC (permalink / raw)
  To: dri-devel; +Cc: linux-arm-msm, Jordan Crouse

Remove the drm_resource wrappers and directly use the
actual PCI and/or platform functions in their place.

Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org>
---
 drivers/gpu/drm/drm_bufs.c                |   13 -------------
 drivers/gpu/drm/i915/i915_dma.c           |    6 +++---
 drivers/gpu/drm/mga/mga_dma.c             |    4 ++--
 drivers/gpu/drm/nouveau/nouveau_bo.c      |    2 +-
 drivers/gpu/drm/nouveau/nouveau_channel.c |    3 ++-
 drivers/gpu/drm/nouveau/nouveau_mem.c     |   16 +++++++++-------
 drivers/gpu/drm/nouveau/nv20_graph.c      |    4 ++--
 drivers/gpu/drm/nouveau/nv40_graph.c      |    2 +-
 drivers/gpu/drm/nouveau/nv50_instmem.c    |    3 ++-
 drivers/gpu/drm/radeon/evergreen.c        |    4 ++--
 drivers/gpu/drm/radeon/r100.c             |    4 ++--
 drivers/gpu/drm/radeon/r600.c             |    4 ++--
 drivers/gpu/drm/radeon/radeon_bios.c      |    2 +-
 drivers/gpu/drm/radeon/radeon_cp.c        |    8 ++++----
 drivers/gpu/drm/radeon/radeon_device.c    |    4 ++--
 drivers/gpu/drm/radeon/rs600.c            |    4 ++--
 drivers/gpu/drm/radeon/rs690.c            |    4 ++--
 drivers/gpu/drm/radeon/rv770.c            |    4 ++--
 drivers/gpu/drm/savage/savage_bci.c       |   24 +++++++++++++-----------
 include/drm/drmP.h                        |    4 ----
 20 files changed, 54 insertions(+), 65 deletions(-)

diff --git a/drivers/gpu/drm/drm_bufs.c b/drivers/gpu/drm/drm_bufs.c
index 2092e7b..3c2c663 100644
--- a/drivers/gpu/drm/drm_bufs.c
+++ b/drivers/gpu/drm/drm_bufs.c
@@ -39,19 +39,6 @@
 #include <asm/shmparam.h>
 #include "drmP.h"
 
-resource_size_t drm_get_resource_start(struct drm_device *dev, unsigned int resource)
-{
-	return pci_resource_start(dev->pdev, resource);
-}
-EXPORT_SYMBOL(drm_get_resource_start);
-
-resource_size_t drm_get_resource_len(struct drm_device *dev, unsigned int resource)
-{
-	return pci_resource_len(dev->pdev, resource);
-}
-
-EXPORT_SYMBOL(drm_get_resource_len);
-
 static struct drm_map_list *drm_find_matching_map(struct drm_device *dev,
 						  struct drm_local_map *map)
 {
diff --git a/drivers/gpu/drm/i915/i915_dma.c b/drivers/gpu/drm/i915/i915_dma.c
index 2305a12..a7bc699 100644
--- a/drivers/gpu/drm/i915/i915_dma.c
+++ b/drivers/gpu/drm/i915/i915_dma.c
@@ -1354,7 +1354,7 @@ static int i915_load_modeset_init(struct drm_device *dev,
 	int fb_bar = IS_I9XX(dev) ? 2 : 0;
 	int ret = 0;
 
-	dev->mode_config.fb_base = drm_get_resource_start(dev, fb_bar) &
+	dev->mode_config.fb_base = pci_resource_start(dev->pdev, fb_bar) &
 		0xff000000;
 
 	/* Basic memrange allocator for stolen space (aka vram) */
@@ -2063,8 +2063,8 @@ int i915_driver_load(struct drm_device *dev, unsigned long flags)
 
 	/* Add register map (needed for suspend/resume) */
 	mmio_bar = IS_I9XX(dev) ? 0 : 1;
-	base = drm_get_resource_start(dev, mmio_bar);
-	size = drm_get_resource_len(dev, mmio_bar);
+	base = pci_resource_start(dev->pdev, mmio_bar);
+	size = pci_resource_len(dev->pdev, mmio_bar);
 
 	if (i915_get_bridge_dev(dev)) {
 		ret = -EIO;
diff --git a/drivers/gpu/drm/mga/mga_dma.c b/drivers/gpu/drm/mga/mga_dma.c
index 3c917fb..ccc129c 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)
 	dev_priv->usec_timeout = MGA_DEFAULT_USEC_TIMEOUT;
 	dev_priv->chipset = flags;
 
-	dev_priv->mmio_base = drm_get_resource_start(dev, 1);
-	dev_priv->mmio_size = drm_get_resource_len(dev, 1);
+	dev_priv->mmio_base = pci_resource_start(dev->pdev, 1);
+	dev_priv->mmio_size = pci_resource_len(dev->pdev, 1);
 
 	dev->counters += 3;
 	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 6f3c195..1dad392 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)
 		break;
 	case TTM_PL_VRAM:
 		mem->bus.offset = mem->mm_node->start << PAGE_SHIFT;
-		mem->bus.base = drm_get_resource_start(dev, 1);
+		man->bus.base = pci_resource_start(dev->pdev, 1);
 		mem->bus.is_iomem = true;
 		break;
 	default:
diff --git a/drivers/gpu/drm/nouveau/nouveau_channel.c b/drivers/gpu/drm/nouveau/nouveau_channel.c
index 1fc57ef..06555c7 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)
 		 * VRAM.
 		 */
 		ret = nouveau_gpuobj_dma_new(chan, NV_CLASS_DMA_IN_MEMORY,
-					     drm_get_resource_start(dev, 1),
+					     pci_resource_start(dev->pdev,
+					     1),
 					     dev_priv->fb_available_size,
 					     NV_DMA_ACCESS_RO,
 					     NV_DMA_TARGET_PCI, &pushbuf);
diff --git a/drivers/gpu/drm/nouveau/nouveau_mem.c b/drivers/gpu/drm/nouveau/nouveau_mem.c
index c1fd42b..fb6b791 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)
 	}
 
 	if (dev_priv->fb_mtrr) {
-		drm_mtrr_del(dev_priv->fb_mtrr, drm_get_resource_start(dev, 1),
-			     drm_get_resource_len(dev, 1), DRM_MTRR_WC);
+		drm_mtrr_del(dev_priv->fb_mtrr,
+			     pci_resource_start(dev->pdev, 1),
+			     pci_resource_len(dev->pdev, 1), DRM_MTRR_WC);
 		dev_priv->fb_mtrr = 0;
 	}
 }
@@ -633,7 +634,7 @@ nouveau_mem_init(struct drm_device *dev)
 	struct ttm_bo_device *bdev = &dev_priv->ttm.bdev;
 	int ret, dma_bits = 32;
 
-	dev_priv->fb_phys = drm_get_resource_start(dev, 1);
+	dev_priv->fb_phys = pci_resource_start(dev->pdev, 1);
 	dev_priv->gart_info.type = NOUVEAU_GART_NONE;
 
 	if (dev_priv->card_type >= NV_50 &&
@@ -665,8 +666,9 @@ nouveau_mem_init(struct drm_device *dev)
 
 	dev_priv->fb_available_size = dev_priv->vram_size;
 	dev_priv->fb_mappable_pages = dev_priv->fb_available_size;
-	if (dev_priv->fb_mappable_pages > drm_get_resource_len(dev, 1))
-		dev_priv->fb_mappable_pages = drm_get_resource_len(dev, 1);
+	if (dev_priv->fb_mappable_pages > pci_resource_len(dev->pdev, 1))
+		dev_priv->fb_mappable_pages =
+			pci_resource_len(dev->pdev, 1);
 	dev_priv->fb_mappable_pages >>= PAGE_SHIFT;
 
 	/* remove reserved space at end of vram from available amount */
@@ -718,8 +720,8 @@ nouveau_mem_init(struct drm_device *dev)
 		return ret;
 	}
 
-	dev_priv->fb_mtrr = drm_mtrr_add(drm_get_resource_start(dev, 1),
-					 drm_get_resource_len(dev, 1),
+	dev_priv->fb_mtrr = drm_mtrr_add(pci_resource_start(dev->pdev, 1),
+					 pci_resource_len(dev->pdev, 1),
 					 DRM_MTRR_WC);
 
 	return 0;
diff --git a/drivers/gpu/drm/nouveau/nv20_graph.c b/drivers/gpu/drm/nouveau/nv20_graph.c
index d6fc0a8..fe2349b 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)
 	nv_wr32(dev, NV10_PGRAPH_SURFACE, tmp);
 
 	/* begin RAM config */
-	vramsz = drm_get_resource_len(dev, 0) - 1;
+	vramsz = pci_resource_len(dev->pdev, 0) - 1;
 	nv_wr32(dev, 0x4009A4, nv_rd32(dev, NV04_PFB_CFG0));
 	nv_wr32(dev, 0x4009A8, nv_rd32(dev, NV04_PFB_CFG1));
 	nv_wr32(dev, NV10_PGRAPH_RDI_INDEX, 0x00EA0000);
@@ -717,7 +717,7 @@ nv30_graph_init(struct drm_device *dev)
 	nv_wr32(dev, 0x0040075c             , 0x00000001);
 
 	/* begin RAM config */
-	/* vramsz = drm_get_resource_len(dev, 0) - 1; */
+	/* vramsz = pci_resource_len(dev->pdev, 0) - 1; */
 	nv_wr32(dev, 0x4009A4, nv_rd32(dev, NV04_PFB_CFG0));
 	nv_wr32(dev, 0x4009A8, nv_rd32(dev, NV04_PFB_CFG1));
 	if (dev_priv->chipset != 0x34) {
diff --git a/drivers/gpu/drm/nouveau/nv40_graph.c b/drivers/gpu/drm/nouveau/nv40_graph.c
index 704a25d..65b13b5 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)
 		nv40_graph_set_region_tiling(dev, i, 0, 0, 0);
 
 	/* begin RAM config */
-	vramsz = drm_get_resource_len(dev, 0) - 1;
+	vramsz = pci_resource_len(dev->pdev, 0) - 1;
 	switch (dev_priv->chipset) {
 	case 0x40:
 		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 5f21df3..ba4809e 100644
--- a/drivers/gpu/drm/nouveau/nv50_instmem.c
+++ b/drivers/gpu/drm/nouveau/nv50_instmem.c
@@ -241,7 +241,8 @@ nv50_instmem_init(struct drm_device *dev)
 		return ret;
 	BAR0_WI32(priv->fb_bar->gpuobj, 0x00, 0x7fc00000);
 	BAR0_WI32(priv->fb_bar->gpuobj, 0x04, 0x40000000 +
-					      drm_get_resource_len(dev, 1) - 1);
+					      pci_resource_len(dev->pmem,
+					      1) - 1);
 	BAR0_WI32(priv->fb_bar->gpuobj, 0x08, 0x40000000);
 	BAR0_WI32(priv->fb_bar->gpuobj, 0x0c, 0x00000000);
 	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 1caf625..057192a 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)
 	}
 	rdev->mc.vram_width = numchan * chansize;
 	/* Could aper size report 0 ? */
-	rdev->mc.aper_base = drm_get_resource_start(rdev->ddev, 0);
-	rdev->mc.aper_size = drm_get_resource_len(rdev->ddev, 0);
+	rdev->mc.aper_base = pci_resource_start(rdev->pdev, 0);
+	rdev->mc.aper_size = pci_resource_len(rdev->pdev, 0);
 	/* Setup GPU memory space */
 	/* size in MB on evergreen */
 	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 a89a15a..da674e9 100644
--- a/drivers/gpu/drm/radeon/r100.c
+++ b/drivers/gpu/drm/radeon/r100.c
@@ -2295,8 +2295,8 @@ void r100_vram_init_sizes(struct radeon_device *rdev)
 	u64 config_aper_size;
 
 	/* work out accessible VRAM */
-	rdev->mc.aper_base = drm_get_resource_start(rdev->ddev, 0);
-	rdev->mc.aper_size = drm_get_resource_len(rdev->ddev, 0);
+	rdev->mc.aper_base = pci_resource_start(rdev->pdev, 0);
+	rdev->mc.aper_size = pci_resource_len(rdev->pdev, 0);
 	rdev->mc.visible_vram_size = r100_get_accessible_vram(rdev);
 	/* FIXME we don't use the second aperture yet when we could use it */
 	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 e100f69..55675b7 100644
--- a/drivers/gpu/drm/radeon/r600.c
+++ b/drivers/gpu/drm/radeon/r600.c
@@ -1217,8 +1217,8 @@ int r600_mc_init(struct radeon_device *rdev)
 	}
 	rdev->mc.vram_width = numchan * chansize;
 	/* Could aper size report 0 ? */
-	rdev->mc.aper_base = drm_get_resource_start(rdev->ddev, 0);
-	rdev->mc.aper_size = drm_get_resource_len(rdev->ddev, 0);
+	rdev->mc.aper_base = pci_resource_start(rdev->pdev, 0);
+	rdev->mc.aper_size = pci_resource_len(rdev->pdev, 0);
 	/* Setup GPU memory space */
 	rdev->mc.mc_vram_size = RREG32(CONFIG_MEMSIZE);
 	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 2c92137..654787e 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)
 			return false;
 
 	rdev->bios = NULL;
-	vram_base = drm_get_resource_start(rdev->ddev, 0);
+	vram_base = pci_resource_start(rdev->pdev, 0);
 	bios = ioremap(vram_base, size);
 	if (!bios) {
 		return false;
diff --git a/drivers/gpu/drm/radeon/radeon_cp.c b/drivers/gpu/drm/radeon/radeon_cp.c
index 2f042a3..eb6b9ee 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)
 	else
 		dev_priv->flags |= RADEON_IS_PCI;
 
-	ret = drm_addmap(dev, drm_get_resource_start(dev, 2),
-			 drm_get_resource_len(dev, 2), _DRM_REGISTERS,
+	ret = drm_addmap(dev, pci_resource_start(dev->pdev, 2),
+			 pci_resource_len(dev->pdev, 2), _DRM_REGISTERS,
 			 _DRM_READ_ONLY | _DRM_DRIVER, &dev_priv->mmio);
 	if (ret != 0)
 		return ret;
@@ -2194,9 +2194,9 @@ int radeon_driver_firstopen(struct drm_device *dev)
 
 	dev_priv->gart_info.table_size = RADEON_PCIGART_TABLE_SIZE;
 
-	dev_priv->fb_aper_offset = drm_get_resource_start(dev, 0);
+	dev_priv->fb_aper_offset = pci_resource_start(dev->pdev, 0);
 	ret = drm_addmap(dev, dev_priv->fb_aper_offset,
-			 drm_get_resource_len(dev, 0), _DRM_FRAME_BUFFER,
+			 pci_resource_len(dev->pdev, 0), _DRM_FRAME_BUFFER,
 			 _DRM_WRITE_COMBINING, &map);
 	if (ret != 0)
 		return ret;
diff --git a/drivers/gpu/drm/radeon/radeon_device.c b/drivers/gpu/drm/radeon/radeon_device.c
index dd279da..004a6d1 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,
 
 	/* Registers mapping */
 	/* TODO: block userspace mapping of io register */
-	rdev->rmmio_base = drm_get_resource_start(rdev->ddev, 2);
-	rdev->rmmio_size = drm_get_resource_len(rdev->ddev, 2);
+	rdev->rmmio_base = pci_resource_start(rdev->pdev, 2);
+	rdev->rmmio_size = pci_resource_len(rdev->pdev, 2);
 	rdev->rmmio = ioremap(rdev->rmmio_base, rdev->rmmio_size);
 	if (rdev->rmmio == NULL) {
 		return -ENOMEM;
diff --git a/drivers/gpu/drm/radeon/rs600.c b/drivers/gpu/drm/radeon/rs600.c
index 6dc15ea..ba09c87 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)
 {
 	u64 base;
 
-	rdev->mc.aper_base = drm_get_resource_start(rdev->ddev, 0);
-	rdev->mc.aper_size = drm_get_resource_len(rdev->ddev, 0);
+	rdev->mc.aper_base = pci_resource_start(rdev->pdev, 0);
+	rdev->mc.aper_size = pci_resource_len(rdev->pdev, 0);
 	rdev->mc.vram_is_ddr = true;
 	rdev->mc.vram_width = 128;
 	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 ce4ecbe..de6bcb8 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)
 	rdev->mc.vram_width = 128;
 	rdev->mc.real_vram_size = RREG32(RADEON_CONFIG_MEMSIZE);
 	rdev->mc.mc_vram_size = rdev->mc.real_vram_size;
-	rdev->mc.aper_base = drm_get_resource_start(rdev->ddev, 0);
-	rdev->mc.aper_size = drm_get_resource_len(rdev->ddev, 0);
+	rdev->mc.aper_base = pci_resource_start(rdev->pdev, 0);
+	rdev->mc.aper_size = pci_resource_len(rdev->pdev, 0);
 	rdev->mc.visible_vram_size = rdev->mc.aper_size;
 	base = RREG32_MC(R_000100_MCCFG_FB_LOCATION);
 	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 b7fd820..6a7bf10 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)
 	}
 	rdev->mc.vram_width = numchan * chansize;
 	/* Could aper size report 0 ? */
-	rdev->mc.aper_base = drm_get_resource_start(rdev->ddev, 0);
-	rdev->mc.aper_size = drm_get_resource_len(rdev->ddev, 0);
+	rdev->mc.aper_base = pci_resource_start(rdev->pdev, 0);
+	rdev->mc.aper_size = pci_resource_len(rdev->pdev, 0);
 	/* Setup GPU memory space */
 	rdev->mc.mc_vram_size = RREG32(CONFIG_MEMSIZE);
 	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 2d0c9ca..f576232 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)
 	dev_priv->mtrr[2].handle = -1;
 	if (S3_SAVAGE3D_SERIES(dev_priv->chipset)) {
 		fb_rsrc = 0;
-		fb_base = drm_get_resource_start(dev, 0);
+		fb_base = pci_resource_start(dev->pdev, 0);
 		fb_size = SAVAGE_FB_SIZE_S3;
 		mmio_base = fb_base + SAVAGE_FB_SIZE_S3;
 		aper_rsrc = 0;
 		aperture_base = fb_base + SAVAGE_APERTURE_OFFSET;
 		/* this should always be true */
-		if (drm_get_resource_len(dev, 0) == 0x08000000) {
+		if (pci_resource_len(dev->pdev, 0) == 0x08000000) {
 			/* Don't make MMIO write-cobining! We need 3
 			 * MTRRs. */
 			dev_priv->mtrr[0].base = fb_base;
@@ -599,18 +599,19 @@ int savage_driver_firstopen(struct drm_device *dev)
 					 dev_priv->mtrr[2].size, DRM_MTRR_WC);
 		} else {
 			DRM_ERROR("strange pci_resource_len %08llx\n",
-				  (unsigned long long)drm_get_resource_len(dev, 0));
+				  (unsigned long long)
+				  pci_resource_len(dev->pdev, 0));
 		}
 	} else if (dev_priv->chipset != S3_SUPERSAVAGE &&
 		   dev_priv->chipset != S3_SAVAGE2000) {
-		mmio_base = drm_get_resource_start(dev, 0);
+		mmio_base = pci_resource_start(dev->pdev, 0);
 		fb_rsrc = 1;
-		fb_base = drm_get_resource_start(dev, 1);
+		fb_base = pci_resource_start(dev->pdev, 1);
 		fb_size = SAVAGE_FB_SIZE_S4;
 		aper_rsrc = 1;
 		aperture_base = fb_base + SAVAGE_APERTURE_OFFSET;
 		/* this should always be true */
-		if (drm_get_resource_len(dev, 1) == 0x08000000) {
+		if (pci_resource_len(dev->pdev, 1) == 0x08000000) {
 			/* Can use one MTRR to cover both fb and
 			 * aperture. */
 			dev_priv->mtrr[0].base = fb_base;
@@ -620,15 +621,16 @@ int savage_driver_firstopen(struct drm_device *dev)
 					 dev_priv->mtrr[0].size, DRM_MTRR_WC);
 		} else {
 			DRM_ERROR("strange pci_resource_len %08llx\n",
-				  (unsigned long long)drm_get_resource_len(dev, 1));
+				  (unsigned long long)
+				  pci_resource_len(dev->pdev, 1));
 		}
 	} else {
-		mmio_base = drm_get_resource_start(dev, 0);
+		mmio_base = pci_resource_start(dev->pdev, 0);
 		fb_rsrc = 1;
-		fb_base = drm_get_resource_start(dev, 1);
-		fb_size = drm_get_resource_len(dev, 1);
+		fb_base = pci_resource_start(dev->pdev, 1);
+		fb_size = pci_resource_len(dev->pdev, 1);
 		aper_rsrc = 2;
-		aperture_base = drm_get_resource_start(dev, 2);
+		aperture_base = pci_resource_start(dev->pdev, 2);
 		/* Automatic MTRR setup will do the right thing. */
 	}
 
diff --git a/include/drm/drmP.h b/include/drm/drmP.h
index c1b9871..8f7f5cb 100644
--- a/include/drm/drmP.h
+++ b/include/drm/drmP.h
@@ -1273,10 +1273,6 @@ extern int drm_freebufs(struct drm_device *dev, void *data,
 extern int drm_mapbufs(struct drm_device *dev, void *data,
 		       struct drm_file *file_priv);
 extern int drm_order(unsigned long size);
-extern resource_size_t drm_get_resource_start(struct drm_device *dev,
-					      unsigned int resource);
-extern resource_size_t drm_get_resource_len(struct drm_device *dev,
-					    unsigned int resource);
 
 				/* DMA support (drm_dma.h) */
 extern int drm_dma_setup(struct drm_device *dev);
-- 
1.7.0.1


^ permalink raw reply related	[flat|nested] 17+ messages in thread

* [PATCH 2/4] drm: Add support for platform devices to register as DRM devices
  2010-05-27 19:40   ` [PATCH v2] DRM platform device support jcrouse
  2010-08-04 20:48     ` [PATCH v3] " Jordan Crouse
  2010-08-04 20:48     ` [PATCH 1/4] drm: Remove drm_resource wrappers Jordan Crouse
@ 2010-08-04 20:48     ` Jordan Crouse
  2010-08-04 20:48     ` [PATCH 3/4] drm: Add __arm defines to DRM Jordan Crouse
  2010-08-04 20:48     ` [PATCH 4/4] drm: Make sure the DRM offset matches the CPU Jordan Crouse
  4 siblings, 0 replies; 17+ messages in thread
From: Jordan Crouse @ 2010-08-04 20:48 UTC (permalink / raw)
  To: dri-devel; +Cc: linux-arm-msm, Jordan Crouse

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain, Size: 29341 bytes --]

Allow platform devices without PCI resources to be DRM devices.

Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org>
---
 drivers/gpu/drm/Kconfig               |    4 +-
 drivers/gpu/drm/Makefile              |    2 +-
 drivers/gpu/drm/drm_drv.c             |   37 +-------
 drivers/gpu/drm/drm_edid.c            |    4 +-
 drivers/gpu/drm/drm_info.c            |   23 ++++--
 drivers/gpu/drm/drm_ioctl.c           |   77 ++++++++++++------
 drivers/gpu/drm/drm_irq.c             |   15 ++--
 drivers/gpu/drm/drm_pci.c             |  143 +++++++++++++++++++++++++++++++++
 drivers/gpu/drm/drm_platform.c        |  122 ++++++++++++++++++++++++++++
 drivers/gpu/drm/drm_stub.c            |   89 +--------------------
 drivers/gpu/drm/drm_sysfs.c           |    3 +-
 drivers/gpu/drm/i915/i915_dma.c       |    1 +
 drivers/gpu/drm/i915/i915_drv.c       |    2 +-
 drivers/gpu/drm/nouveau/nouveau_drv.c |    2 +-
 drivers/gpu/drm/radeon/radeon_drv.c   |    2 +-
 drivers/gpu/drm/vmwgfx/vmwgfx_drv.c   |    2 +-
 include/drm/drmP.h                    |   52 ++++++++++--
 17 files changed, 405 insertions(+), 175 deletions(-)
 create mode 100644 drivers/gpu/drm/drm_platform.c

diff --git a/drivers/gpu/drm/Kconfig b/drivers/gpu/drm/Kconfig
index 88910e5..520ab23 100644
--- a/drivers/gpu/drm/Kconfig
+++ b/drivers/gpu/drm/Kconfig
@@ -6,7 +6,7 @@
 #
 menuconfig DRM
 	tristate "Direct Rendering Manager (XFree86 4.1.0 and higher DRI support)"
-	depends on (AGP || AGP=n) && PCI && !EMULATED_CMPXCHG && MMU
+	depends on (AGP || AGP=n) && !EMULATED_CMPXCHG && MMU
 	select I2C
 	select I2C_ALGOBIT
 	select SLOW_WORK
@@ -17,7 +17,7 @@ menuconfig DRM
 	  These modules provide support for synchronization, security, and
 	  DMA transfers. Please see <http://dri.sourceforge.net/> for more
 	  details.  You should also select and configure AGP
-	  (/dev/agpgart) support.
+	  (/dev/agpgart) support if it is available for your platform.
 
 config DRM_KMS_HELPER
 	tristate
diff --git a/drivers/gpu/drm/Makefile b/drivers/gpu/drm/Makefile
index abe3f44..b4b2b48 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 \
 		drm_drv.o drm_fops.o drm_gem.o drm_ioctl.o drm_irq.o \
 		drm_lock.o drm_memory.o drm_proc.o drm_stub.o drm_vm.o \
 		drm_agpsupport.o drm_scatter.o ati_pcigart.o drm_pci.o \
-		drm_sysfs.o drm_hashtab.o drm_sman.o drm_mm.o \
+		drm_platform.o drm_sysfs.o drm_hashtab.o drm_sman.o drm_mm.o \
 		drm_crtc.o drm_modes.o drm_edid.o \
 		drm_info.o drm_debugfs.o drm_encoder_slave.o
 
diff --git a/drivers/gpu/drm/drm_drv.c b/drivers/gpu/drm/drm_drv.c
index 4a66201..510bc87 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)
  *
  * Initializes an array of drm_device structures, and attempts to
  * initialize all available devices, using consecutive minors, registering the
- * stubs and initializing the AGP device.
+ * stubs and initializing the device.
  *
  * Expands the \c DRIVER_PREINIT and \c DRIVER_POST_INIT macros before and
  * after the initialization for driver customization.
  */
 int drm_init(struct drm_driver *driver)
 {
-	struct pci_dev *pdev = NULL;
-	const struct pci_device_id *pid;
-	int i;
-
 	DRM_DEBUG("\n");
-
 	INIT_LIST_HEAD(&driver->device_list);
 
-	if (driver->driver_features & DRIVER_MODESET)
-		return pci_register_driver(&driver->pci_driver);
-
-	/* If not using KMS, fall back to stealth mode manual scanning. */
-	for (i = 0; driver->pci_driver.id_table[i].vendor != 0; i++) {
-		pid = &driver->pci_driver.id_table[i];
-
-		/* Loop around setting up a DRM device for each PCI device
-		 * matching our ID and device class.  If we had the internal
-		 * function that pci_get_subsys and pci_get_class used, we'd
-		 * be able to just pass pid in instead of doing a two-stage
-		 * thing.
-		 */
-		pdev = NULL;
-		while ((pdev =
-			pci_get_subsys(pid->vendor, pid->device, pid->subvendor,
-				       pid->subdevice, pdev)) != NULL) {
-			if ((pdev->class & pid->class_mask) != pid->class)
-				continue;
-
-			/* stealth mode requires a manual probe */
-			pci_dev_get(pdev);
-			drm_get_dev(pdev, pid, driver);
-		}
-	}
-	return 0;
+	if (driver->driver_features & DRIVER_USE_PLATFORM_DEVICE)
+		return drm_platform_init(driver);
+	else
+		return drm_pci_init(driver);
 }
 
 EXPORT_SYMBOL(drm_init);
diff --git a/drivers/gpu/drm/drm_edid.c b/drivers/gpu/drm/drm_edid.c
index f87bf10..297bd02 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)
 	return block;
 
 carp:
-	dev_warn(&connector->dev->pdev->dev, "%s: EDID block %d invalid.\n",
+	dev_warn(&connector->dev->dev, "%s: EDID block %d invalid.\n",
 		 drm_get_connector_name(connector), j);
 
 out:
@@ -1626,7 +1626,7 @@ int drm_add_edid_modes(struct drm_connector *connector, struct edid *edid)
 		return 0;
 	}
 	if (!drm_edid_is_valid(edid)) {
-		dev_warn(&connector->dev->pdev->dev, "%s: EDID invalid.\n",
+		dev_warn(&connector->dev->dev, "%s: EDID invalid.\n",
 			 drm_get_connector_name(connector));
 		return 0;
 	}
diff --git a/drivers/gpu/drm/drm_info.c b/drivers/gpu/drm/drm_info.c
index f0f6c6b..2ef2c78 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)
 	if (!master)
 		return 0;
 
-	if (master->unique) {
-		seq_printf(m, "%s %s %s\n",
-			   dev->driver->pci_driver.name,
-			   pci_name(dev->pdev), master->unique);
+	if (drm_core_check_feature(dev, DRIVER_USE_PLATFORM_DEVICE)) {
+		if (master->unique) {
+			seq_printf(m, "%s %s %s\n",
+					dev->driver->platform_device->name,
+					dev_name(dev->dev), master->unique);
+		} else {
+			seq_printf(m, "%s\n",
+				dev->driver->platform_device->name);
+		}
 	} else {
-		seq_printf(m, "%s %s\n", dev->driver->pci_driver.name,
-			   pci_name(dev->pdev));
+		if (master->unique) {
+			seq_printf(m, "%s %s %s\n",
+				dev->driver->pci_driver.name,
+				dev_name(dev->dev), master->unique);
+		} else {
+			seq_printf(m, "%s %s\n", dev->driver->pci_driver.name,
+				dev_name(dev->dev));
+		}
 	}
 
 	return 0;
diff --git a/drivers/gpu/drm/drm_ioctl.c b/drivers/gpu/drm/drm_ioctl.c
index 9b9ff46..76d3d18 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)
 	struct drm_master *master = file_priv->master;
 	int len;
 
-	if (master->unique != NULL)
-		return -EBUSY;
-
-	master->unique_len = 40;
-	master->unique_size = master->unique_len;
-	master->unique = kmalloc(master->unique_size, GFP_KERNEL);
-	if (master->unique == NULL)
-		return -ENOMEM;
+	if (drm_core_check_feature(dev, DRIVER_USE_PLATFORM_DEVICE)) {
+		master->unique_len = 10 + strlen(dev->platformdev->name);
+		master->unique = kmalloc(master->unique_len + 1, GFP_KERNEL);
+
+		if (master->unique == NULL)
+			return -ENOMEM;
+
+		len = snprintf(master->unique, master->unique_len,
+			"platform:%s", dev->platformdev->name);
+
+		if (len > master->unique_len)
+			DRM_ERROR("Unique buffer overflowed\n");
+
+		dev->devname =
+			kmalloc(strlen(dev->platformdev->name) +
+				master->unique_len + 2, GFP_KERNEL);
+
+		if (dev->devname == NULL)
+			return -ENOMEM;
+
+		sprintf(dev->devname, "%s@%s", dev->platformdev->name,
+			master->unique);
+
+	} else {
+		master->unique_len = 40;
+		master->unique_size = master->unique_len;
+		master->unique = kmalloc(master->unique_size, GFP_KERNEL);
+		if (master->unique == NULL)
+			return -ENOMEM;
+
+		len = snprintf(master->unique, master->unique_len,
+			"pci:%04x:%02x:%02x.%d",
+			drm_get_pci_domain(dev),
+			dev->pdev->bus->number,
+			PCI_SLOT(dev->pdev->devfn),
+			PCI_FUNC(dev->pdev->devfn));
+		if (len >= master->unique_len)
+			DRM_ERROR("buffer overflow");
+		else
+			master->unique_len = len;
 
-	len = snprintf(master->unique, master->unique_len, "pci:%04x:%02x:%02x.%d",
-		       drm_get_pci_domain(dev),
-		       dev->pdev->bus->number,
-		       PCI_SLOT(dev->pdev->devfn),
-		       PCI_FUNC(dev->pdev->devfn));
-	if (len >= master->unique_len)
-		DRM_ERROR("buffer overflow");
-	else
-		master->unique_len = len;
+		dev->devname =
+			kmalloc(strlen(dev->driver->pci_driver.name) +
+				master->unique_len + 2, GFP_KERNEL);
 
-	dev->devname = kmalloc(strlen(dev->driver->pci_driver.name) +
-			       master->unique_len + 2, GFP_KERNEL);
-	if (dev->devname == NULL)
-		return -ENOMEM;
+		if (dev->devname == NULL)
+			return -ENOMEM;
 
-	sprintf(dev->devname, "%s@%s", dev->driver->pci_driver.name,
-		master->unique);
+		sprintf(dev->devname, "%s@%s", dev->driver->pci_driver.name,
+			master->unique);
+	}
 
 	return 0;
 }
diff --git a/drivers/gpu/drm/drm_irq.c b/drivers/gpu/drm/drm_irq.c
index a263b70..6353b62 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,
 {
 	struct drm_irq_busid *p = data;
 
+	if (drm_core_check_feature(dev, DRIVER_USE_PLATFORM_DEVICE))
+		return -EINVAL;
+
 	if (!drm_core_check_feature(dev, DRIVER_HAVE_IRQ))
 		return -EINVAL;
 
@@ -211,7 +214,7 @@ int drm_irq_install(struct drm_device *dev)
 	if (!drm_core_check_feature(dev, DRIVER_HAVE_IRQ))
 		return -EINVAL;
 
-	if (dev->pdev->irq == 0)
+	if (drm_dev_to_irq(dev) == 0)
 		return -EINVAL;
 
 	mutex_lock(&dev->struct_mutex);
@@ -229,7 +232,7 @@ int drm_irq_install(struct drm_device *dev)
 	dev->irq_enabled = 1;
 	mutex_unlock(&dev->struct_mutex);
 
-	DRM_DEBUG("irq=%d\n", dev->pdev->irq);
+	DRM_DEBUG("irq=%d\n", drm_dev_to_irq(dev));
 
 	/* Before installing handler */
 	dev->driver->irq_preinstall(dev);
@@ -302,14 +305,14 @@ int drm_irq_uninstall(struct drm_device * dev)
 	if (!irq_enabled)
 		return -EINVAL;
 
-	DRM_DEBUG("irq=%d\n", dev->pdev->irq);
+	DRM_DEBUG("irq=%d\n", drm_dev_to_irq(dev));
 
 	if (!drm_core_check_feature(dev, DRIVER_MODESET))
 		vga_client_register(dev->pdev, NULL, NULL, NULL);
 
 	dev->driver->irq_uninstall(dev);
 
-	free_irq(dev->pdev->irq, dev);
+	free_irq(drm_dev_to_irq(dev), dev);
 
 	return 0;
 }
@@ -341,7 +344,7 @@ int drm_control(struct drm_device *dev, void *data,
 		if (drm_core_check_feature(dev, DRIVER_MODESET))
 			return 0;
 		if (dev->if_version < DRM_IF_VERSION(1, 2) &&
-		    ctl->irq != dev->pdev->irq)
+		    ctl->irq != drm_dev_to_irq(dev))
 			return -EINVAL;
 		return drm_irq_install(dev);
 	case DRM_UNINST_HANDLER:
@@ -651,7 +654,7 @@ int drm_wait_vblank(struct drm_device *dev, void *data,
 	int ret = 0;
 	unsigned int flags, seq, crtc;
 
-	if ((!dev->pdev->irq) || (!dev->irq_enabled))
+	if ((!drm_dev_to_irq(dev)) || (!dev->irq_enabled))
 		return -EINVAL;
 
 	if (vblwait->request.type & _DRM_VBLANK_SIGNAL)
diff --git a/drivers/gpu/drm/drm_pci.c b/drivers/gpu/drm/drm_pci.c
index 2ea9ad4..e20f78b 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)
 
 EXPORT_SYMBOL(drm_pci_free);
 
+#ifdef CONFIG_PCI
+/**
+ * Register.
+ *
+ * \param pdev - PCI device structure
+ * \param ent entry from the PCI ID table with device type flags
+ * \return zero on success or a negative number on failure.
+ *
+ * Attempt to gets inter module "drm" information. If we are first
+ * then register the character device and inter module information.
+ * Try and register, if we fail to register, backout previous work.
+ */
+int drm_get_pci_dev(struct pci_dev *pdev, const struct pci_device_id *ent,
+		    struct drm_driver *driver)
+{
+	struct drm_device *dev;
+	int ret;
+
+	DRM_DEBUG("\n");
+
+	dev = kzalloc(sizeof(*dev), GFP_KERNEL);
+	if (!dev)
+		return -ENOMEM;
+
+	ret = pci_enable_device(pdev);
+	if (ret)
+		goto err_g1;
+
+	pci_set_master(pdev);
+
+	dev->pdev = pdev;
+	dev->dev = &pdev->dev;
+
+	dev->pci_device = pdev->device;
+	dev->pci_vendor = pdev->vendor;
+
+#ifdef __alpha__
+	dev->hose = pdev->sysdata;
+#endif
+
+	if ((ret = drm_fill_in_dev(dev, ent, driver))) {
+		printk(KERN_ERR "DRM: Fill_in_dev failed.\n");
+		goto err_g2;
+	}
+
+	if (drm_core_check_feature(dev, DRIVER_MODESET)) {
+		pci_set_drvdata(pdev, dev);
+		ret = drm_get_minor(dev, &dev->control, DRM_MINOR_CONTROL);
+		if (ret)
+			goto err_g2;
+	}
+
+	if ((ret = drm_get_minor(dev, &dev->primary, DRM_MINOR_LEGACY)))
+		goto err_g3;
+
+	if (dev->driver->load) {
+		ret = dev->driver->load(dev, ent->driver_data);
+		if (ret)
+			goto err_g4;
+	}
+
+	/* setup the grouping for the legacy output */
+	if (drm_core_check_feature(dev, DRIVER_MODESET)) {
+		ret = drm_mode_group_init_legacy_group(dev,
+						&dev->primary->mode_group);
+		if (ret)
+			goto err_g4;
+	}
+
+	list_add_tail(&dev->driver_item, &driver->device_list);
+
+	DRM_INFO("Initialized %s %d.%d.%d %s for %s on minor %d\n",
+		 driver->name, driver->major, driver->minor, driver->patchlevel,
+		 driver->date, pci_name(pdev), dev->primary->index);
+
+	return 0;
+
+err_g4:
+	drm_put_minor(&dev->primary);
+err_g3:
+	if (drm_core_check_feature(dev, DRIVER_MODESET))
+		drm_put_minor(&dev->control);
+err_g2:
+	pci_disable_device(pdev);
+err_g1:
+	kfree(dev);
+	return ret;
+}
+EXPORT_SYMBOL(drm_get_pci_dev);
+
+/**
+ * PCI device initialization. Called via drm_init at module load time,
+ *
+ * \return zero on success or a negative number on failure.
+ *
+ * Initializes a drm_device structures,registering the
+ * stubs and initializing the AGP device.
+ *
+ * Expands the \c DRIVER_PREINIT and \c DRIVER_POST_INIT macros before and
+ * after the initialization for driver customization.
+ */
+int drm_pci_init(struct drm_driver *driver)
+{
+	struct pci_dev *pdev = NULL;
+	const struct pci_device_id *pid;
+	int i;
+
+	if (driver->driver_features & DRIVER_MODESET)
+		return pci_register_driver(&driver->pci_driver);
+
+	/* If not using KMS, fall back to stealth mode manual scanning. */
+	for (i = 0; driver->pci_driver.id_table[i].vendor != 0; i++) {
+		pid = &driver->pci_driver.id_table[i];
+
+		/* Loop around setting up a DRM device for each PCI device
+		 * matching our ID and device class.  If we had the internal
+		 * function that pci_get_subsys and pci_get_class used, we'd
+		 * be able to just pass pid in instead of doing a two-stage
+		 * thing.
+		 */
+		pdev = NULL;
+		while ((pdev =
+			pci_get_subsys(pid->vendor, pid->device, pid->subvendor,
+				       pid->subdevice, pdev)) != NULL) {
+			if ((pdev->class & pid->class_mask) != pid->class)
+				continue;
+
+			/* stealth mode requires a manual probe */
+			pci_dev_get(pdev);
+			drm_get_pci_dev(pdev, pid, driver);
+		}
+	}
+	return 0;
+}
+
+#else
+
+int drm_pci_init(struct drm_driver *driver)
+{
+	return -1;
+}
+
+#endif
 /*@}*/
diff --git a/drivers/gpu/drm/drm_platform.c b/drivers/gpu/drm/drm_platform.c
new file mode 100644
index 0000000..460e9a3
--- /dev/null
+++ b/drivers/gpu/drm/drm_platform.c
@@ -0,0 +1,122 @@
+/*
+ * Derived from drm_pci.c
+ *
+ * Copyright 2003 José Fonseca.
+ * Copyright 2003 Leif Delgass.
+ * Copyright (c) 2009, Code Aurora Forum.
+ * All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the next
+ * paragraph) shall be included in all copies or substantial portions of the
+ * Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL THE
+ * AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+ * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ */
+
+#include "drmP.h"
+
+/**
+ * Register.
+ *
+ * \param platdev - Platform device struture
+ * \return zero on success or a negative number on failure.
+ *
+ * Attempt to gets inter module "drm" information. If we are first
+ * then register the character device and inter module information.
+ * Try and register, if we fail to register, backout previous work.
+ */
+
+int drm_get_platform_dev(struct platform_device *platdev,
+			 struct drm_driver *driver)
+{
+	struct drm_device *dev;
+	int ret;
+
+	DRM_DEBUG("\n");
+
+	dev = kzalloc(sizeof(*dev), GFP_KERNEL);
+	if (!dev)
+		return -ENOMEM;
+
+	dev->platformdev = platdev;
+	dev->dev = &platdev->dev;
+
+	ret = drm_fill_in_dev(dev, NULL, driver);
+
+	if (ret) {
+		printk(KERN_ERR "DRM: Fill_in_dev failed.\n");
+		goto err_g1;
+	}
+
+	if (drm_core_check_feature(dev, DRIVER_MODESET)) {
+		dev_set_drvdata(&platdev->dev, dev);
+		ret = drm_get_minor(dev, &dev->control, DRM_MINOR_CONTROL);
+		if (ret)
+			goto err_g1;
+	}
+
+	ret = drm_get_minor(dev, &dev->primary, DRM_MINOR_LEGACY);
+	if (ret)
+		goto err_g2;
+
+	if (dev->driver->load) {
+		ret = dev->driver->load(dev, 0);
+		if (ret)
+			goto err_g3;
+	}
+
+	/* setup the grouping for the legacy output */
+	if (drm_core_check_feature(dev, DRIVER_MODESET)) {
+		ret = drm_mode_group_init_legacy_group(dev,
+				&dev->primary->mode_group);
+		if (ret)
+			goto err_g3;
+	}
+
+	list_add_tail(&dev->driver_item, &driver->device_list);
+
+	DRM_INFO("Initialized %s %d.%d.%d %s on minor %d\n",
+		 driver->name, driver->major, driver->minor, driver->patchlevel,
+		 driver->date, dev->primary->index);
+
+	return 0;
+
+err_g3:
+	drm_put_minor(&dev->primary);
+err_g2:
+	if (drm_core_check_feature(dev, DRIVER_MODESET))
+		drm_put_minor(&dev->control);
+err_g1:
+	kfree(dev);
+	return ret;
+}
+EXPORT_SYMBOL(drm_get_platform_dev);
+
+/**
+ * Platform device initialization. Called via drm_init at module load time,
+ *
+ * \return zero on success or a negative number on failure.
+ *
+ * Initializes a drm_device structures,registering the
+ * stubs
+ *
+ * Expands the \c DRIVER_PREINIT and \c DRIVER_POST_INIT macros before and
+ * after the initialization for driver customization.
+ */
+
+int drm_platform_init(struct drm_driver *driver)
+{
+	return drm_get_platform_dev(driver->platform_device, driver);
+}
diff --git a/drivers/gpu/drm/drm_stub.c b/drivers/gpu/drm/drm_stub.c
index a0c365f..63575e2 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,
 	return 0;
 }
 
-static int drm_fill_in_dev(struct drm_device * dev, struct pci_dev *pdev,
+int drm_fill_in_dev(struct drm_device *dev,
 			   const struct pci_device_id *ent,
 			   struct drm_driver *driver)
 {
@@ -245,14 +245,6 @@ static int drm_fill_in_dev(struct drm_device * dev, struct pci_dev *pdev,
 
 	idr_init(&dev->drw_idr);
 
-	dev->pdev = pdev;
-	dev->pci_device = pdev->device;
-	dev->pci_vendor = pdev->vendor;
-
-#ifdef __alpha__
-	dev->hose = pdev->sysdata;
-#endif
-
 	if (drm_ht_create(&dev->map_hash, 12)) {
 		return -ENOMEM;
 	}
@@ -321,7 +313,7 @@ static int drm_fill_in_dev(struct drm_device * dev, struct pci_dev *pdev,
  * create the proc init entry via proc_init(). This routines assigns
  * minor numbers to secondary heads of multi-headed cards
  */
-static int drm_get_minor(struct drm_device *dev, struct drm_minor **minor, int type)
+int drm_get_minor(struct drm_device *dev, struct drm_minor **minor, int type)
 {
 	struct drm_minor *new_minor;
 	int ret;
@@ -388,83 +380,6 @@ err_idr:
 }
 
 /**
- * Register.
- *
- * \param pdev - PCI device structure
- * \param ent entry from the PCI ID table with device type flags
- * \return zero on success or a negative number on failure.
- *
- * Attempt to gets inter module "drm" information. If we are first
- * then register the character device and inter module information.
- * Try and register, if we fail to register, backout previous work.
- */
-int drm_get_dev(struct pci_dev *pdev, const struct pci_device_id *ent,
-		struct drm_driver *driver)
-{
-	struct drm_device *dev;
-	int ret;
-
-	DRM_DEBUG("\n");
-
-	dev = kzalloc(sizeof(*dev), GFP_KERNEL);
-	if (!dev)
-		return -ENOMEM;
-
-	ret = pci_enable_device(pdev);
-	if (ret)
-		goto err_g1;
-
-	pci_set_master(pdev);
-	if ((ret = drm_fill_in_dev(dev, pdev, ent, driver))) {
-		printk(KERN_ERR "DRM: Fill_in_dev failed.\n");
-		goto err_g2;
-	}
-
-	if (drm_core_check_feature(dev, DRIVER_MODESET)) {
-		pci_set_drvdata(pdev, dev);
-		ret = drm_get_minor(dev, &dev->control, DRM_MINOR_CONTROL);
-		if (ret)
-			goto err_g2;
-	}
-
-	if ((ret = drm_get_minor(dev, &dev->primary, DRM_MINOR_LEGACY)))
-		goto err_g3;
-
-	if (dev->driver->load) {
-		ret = dev->driver->load(dev, ent->driver_data);
-		if (ret)
-			goto err_g4;
-	}
-
-        /* setup the grouping for the legacy output */
-	if (drm_core_check_feature(dev, DRIVER_MODESET)) {
-		ret = drm_mode_group_init_legacy_group(dev, &dev->primary->mode_group);
-		if (ret)
-			goto err_g4;
-	}
-
-	list_add_tail(&dev->driver_item, &driver->device_list);
-
-	DRM_INFO("Initialized %s %d.%d.%d %s for %s on minor %d\n",
-		 driver->name, driver->major, driver->minor, driver->patchlevel,
-		 driver->date, pci_name(pdev), dev->primary->index);
-
-	return 0;
-
-err_g4:
-	drm_put_minor(&dev->primary);
-err_g3:
-	if (drm_core_check_feature(dev, DRIVER_MODESET))
-		drm_put_minor(&dev->control);
-err_g2:
-	pci_disable_device(pdev);
-err_g1:
-	kfree(dev);
-	return ret;
-}
-EXPORT_SYMBOL(drm_get_dev);
-
-/**
  * Put a secondary minor number.
  *
  * \param sec_minor - structure to be released
diff --git a/drivers/gpu/drm/drm_sysfs.c b/drivers/gpu/drm/drm_sysfs.c
index 101d381..5678701 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)
 	int err;
 	char *minor_str;
 
-	minor->kdev.parent = &minor->dev->pdev->dev;
+	minor->kdev.parent = &minor->dev->dev;
+
 	minor->kdev.class = drm_class;
 	minor->kdev.release = drm_sysfs_device_release;
 	minor->kdev.devt = minor->device;
diff --git a/drivers/gpu/drm/i915/i915_dma.c b/drivers/gpu/drm/i915/i915_dma.c
index a7bc699..5878b13 100644
--- a/drivers/gpu/drm/i915/i915_dma.c
+++ b/drivers/gpu/drm/i915/i915_dma.c
@@ -34,6 +34,7 @@
 #include "i915_drm.h"
 #include "i915_drv.h"
 #include "i915_trace.h"
+#include <linux/pci.h>
 #include <linux/vgaarb.h>
 #include <linux/acpi.h>
 #include <linux/pnp.h>
diff --git a/drivers/gpu/drm/i915/i915_drv.c b/drivers/gpu/drm/i915/i915_drv.c
index 423dc90..65d3f3e 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)
 static int __devinit
 i915_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
 {
-	return drm_get_dev(pdev, ent, &driver);
+	return drm_get_pci_dev(pdev, ent, &driver);
 }
 
 static void
diff --git a/drivers/gpu/drm/nouveau/nouveau_drv.c b/drivers/gpu/drm/nouveau/nouveau_drv.c
index 2737704..0fd8e10 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;
 static int __devinit
 nouveau_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
 {
-	return drm_get_dev(pdev, ent, &driver);
+	return drm_get_pci_dev(pdev, ent, &driver);
 }
 
 static void
diff --git a/drivers/gpu/drm/radeon/radeon_drv.c b/drivers/gpu/drm/radeon/radeon_drv.c
index e166fe4..ed0ceb3 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;
 static int __devinit
 radeon_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
 {
-	return drm_get_dev(pdev, ent, &kms_driver);
+	return drm_get_pci_dev(pdev, ent, &kms_driver);
 }
 
 static void
diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_drv.c b/drivers/gpu/drm/vmwgfx/vmwgfx_drv.c
index b793c8c..9dd395b 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 = {
 
 static int vmw_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
 {
-	return drm_get_dev(pdev, ent, &driver);
+	return drm_get_pci_dev(pdev, ent, &driver);
 }
 
 static int __init vmwgfx_init(void)
diff --git a/include/drm/drmP.h b/include/drm/drmP.h
index 8f7f5cb..6235169 100644
--- a/include/drm/drmP.h
+++ b/include/drm/drmP.h
@@ -9,6 +9,7 @@
 /*
  * Copyright 1999 Precision Insight, Inc., Cedar Park, Texas.
  * Copyright 2000 VA Linux Systems, Inc., Sunnyvale, California.
+ * Copyright (c) 2009-2010, Code Aurora Forum.
  * All rights reserved.
  *
  * Permission is hereby granted, free of charge, to any person obtaining a
@@ -48,6 +49,7 @@
 #include <linux/proc_fs.h>
 #include <linux/init.h>
 #include <linux/file.h>
+#include <linux/platform_device.h>
 #include <linux/pci.h>
 #include <linux/jiffies.h>
 #include <linux/smp_lock.h>	/* For (un)lock_kernel */
@@ -144,6 +146,7 @@ extern void drm_ut_debug_printk(unsigned int request_level,
 #define DRIVER_IRQ_VBL2    0x800
 #define DRIVER_GEM         0x1000
 #define DRIVER_MODESET     0x2000
+#define DRIVER_USE_PLATFORM_DEVICE  0x4000
 
 /***********************************************************************/
 /** \name Begin the DRM... */
@@ -823,6 +826,7 @@ struct drm_driver {
 	int num_ioctls;
 	struct file_operations fops;
 	struct pci_driver pci_driver;
+	struct platform_device *platform_device;
 	/* List of devices hanging off this driver */
 	struct list_head device_list;
 };
@@ -1015,12 +1019,16 @@ struct drm_device {
 
 	struct drm_agp_head *agp;	/**< AGP data */
 
+	struct device *dev;             /**< Device structure */
 	struct pci_dev *pdev;		/**< PCI device structure */
 	int pci_vendor;			/**< PCI vendor id */
 	int pci_device;			/**< PCI device id */
 #ifdef __alpha__
 	struct pci_controller *hose;
 #endif
+
+	struct platform_device *platformdev; /**< Platform device struture */
+
 	struct drm_sg_mem *sg;	/**< Scatter gather memory */
 	int num_crtcs;                  /**< Number of CRTCs on this device */
 	void *dev_private;		/**< device private data */
@@ -1060,17 +1068,21 @@ struct drm_device {
 
 };
 
-static inline int drm_dev_to_irq(struct drm_device *dev)
-{
-	return dev->pdev->irq;
-}
-
 static __inline__ int drm_core_check_feature(struct drm_device *dev,
 					     int feature)
 {
 	return ((dev->driver->driver_features & feature) ? 1 : 0);
 }
 
+
+static inline int drm_dev_to_irq(struct drm_device *dev)
+{
+	if (drm_core_check_feature(dev, DRIVER_USE_PLATFORM_DEVICE))
+		return platform_get_irq(dev->platformdev, 0);
+	else
+		return dev->pdev->irq;
+}
+
 #ifdef __alpha__
 #define drm_get_pci_domain(dev) dev->hose->index
 #else
@@ -1347,8 +1359,11 @@ extern int drm_dropmaster_ioctl(struct drm_device *dev, void *data,
 struct drm_master *drm_master_create(struct drm_minor *minor);
 extern struct drm_master *drm_master_get(struct drm_master *master);
 extern void drm_master_put(struct drm_master **master);
-extern int drm_get_dev(struct pci_dev *pdev, const struct pci_device_id *ent,
-		       struct drm_driver *driver);
+extern int drm_get_pci_dev(struct pci_dev *pdev,
+			   const struct pci_device_id *ent,
+			   struct drm_driver *driver);
+extern int drm_get_platform_dev(struct platform_device *pdev,
+				struct drm_driver *driver);
 extern void drm_put_dev(struct drm_device *dev);
 extern int drm_put_minor(struct drm_minor **minor);
 extern unsigned int drm_debug;
@@ -1525,6 +1540,9 @@ static __inline__ struct drm_local_map *drm_core_findmap(struct drm_device *dev,
 
 static __inline__ int drm_device_is_agp(struct drm_device *dev)
 {
+	if (drm_core_check_feature(dev, DRIVER_USE_PLATFORM_DEVICE))
+		return 0;
+
 	if (dev->driver->device_is_agp != NULL) {
 		int err = (*dev->driver->device_is_agp) (dev);
 
@@ -1538,7 +1556,10 @@ static __inline__ int drm_device_is_agp(struct drm_device *dev)
 
 static __inline__ int drm_device_is_pcie(struct drm_device *dev)
 {
-	return pci_find_capability(dev->pdev, PCI_CAP_ID_EXP);
+	if (drm_core_check_feature(dev, DRIVER_USE_PLATFORM_DEVICE))
+		return 0;
+	else
+		return pci_find_capability(dev->pdev, PCI_CAP_ID_EXP);
 }
 
 static __inline__ void drm_core_dropmap(struct drm_local_map *map)
@@ -1546,6 +1567,21 @@ static __inline__ void drm_core_dropmap(struct drm_local_map *map)
 }
 
 #include "drm_mem_util.h"
+
+static inline void *drm_get_device(struct drm_device *dev)
+{
+	if (drm_core_check_feature(dev, DRIVER_USE_PLATFORM_DEVICE))
+		return dev->platformdev;
+	else
+		return dev->pdev;
+}
+
+extern int drm_platform_init(struct drm_driver *driver);
+extern int drm_pci_init(struct drm_driver *driver);
+extern int drm_fill_in_dev(struct drm_device *dev,
+			   const struct pci_device_id *ent,
+			   struct drm_driver *driver);
+int drm_get_minor(struct drm_device *dev, struct drm_minor **minor, int type);
 /*@}*/
 
 #endif				/* __KERNEL__ */
-- 
1.7.0.1


^ permalink raw reply related	[flat|nested] 17+ messages in thread

* [PATCH 3/4] drm:  Add __arm defines to DRM
  2010-05-27 19:40   ` [PATCH v2] DRM platform device support jcrouse
                       ` (2 preceding siblings ...)
  2010-08-04 20:48     ` [PATCH 2/4] drm: Add support for platform devices to register as DRM devices Jordan Crouse
@ 2010-08-04 20:48     ` Jordan Crouse
  2010-08-04 20:48     ` [PATCH 4/4] drm: Make sure the DRM offset matches the CPU Jordan Crouse
  4 siblings, 0 replies; 17+ messages in thread
From: Jordan Crouse @ 2010-08-04 20:48 UTC (permalink / raw)
  To: dri-devel; +Cc: linux-arm-msm, Jordan Crouse

Add __arm defines to specify behavior specific for
an ARM processor.

Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org>
---
 drivers/gpu/drm/drm_bufs.c |    2 +-
 drivers/gpu/drm/drm_vm.c   |   14 +++++++++++++-
 2 files changed, 14 insertions(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/drm_bufs.c b/drivers/gpu/drm/drm_bufs.c
index 3c2c663..a5c9ce9 100644
--- a/drivers/gpu/drm/drm_bufs.c
+++ b/drivers/gpu/drm/drm_bufs.c
@@ -176,7 +176,7 @@ static int drm_addmap_core(struct drm_device * dev, resource_size_t offset,
 	switch (map->type) {
 	case _DRM_REGISTERS:
 	case _DRM_FRAME_BUFFER:
-#if !defined(__sparc__) && !defined(__alpha__) && !defined(__ia64__) && !defined(__powerpc64__) && !defined(__x86_64__)
+#if !defined(__sparc__) && !defined(__alpha__) && !defined(__ia64__) && !defined(__powerpc64__) && !defined(__x86_64__) && !defined(__arm__)
 		if (map->offset + (map->size-1) < map->offset ||
 		    map->offset < virt_to_phys(high_memory)) {
 			kfree(map);
diff --git a/drivers/gpu/drm/drm_vm.c b/drivers/gpu/drm/drm_vm.c
index c3b13fb..3778360 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)
 		tmp = pgprot_writecombine(tmp);
 	else
 		tmp = pgprot_noncached(tmp);
-#elif defined(__sparc__)
+#elif defined(__sparc__) || defined(__arm__)
 	tmp = pgprot_noncached(tmp);
 #endif
 	return tmp;
@@ -601,6 +601,7 @@ int drm_mmap_locked(struct file *filp, struct vm_area_struct *vma)
 	}
 
 	switch (map->type) {
+#if !defined(__arm__)
 	case _DRM_AGP:
 		if (drm_core_has_AGP(dev) && dev->agp->cant_use_aperture) {
 			/*
@@ -615,20 +616,31 @@ int drm_mmap_locked(struct file *filp, struct vm_area_struct *vma)
 			break;
 		}
 		/* fall through to _DRM_FRAME_BUFFER... */
+#endif
 	case _DRM_FRAME_BUFFER:
 	case _DRM_REGISTERS:
 		offset = dev->driver->get_reg_ofs(dev);
 		vma->vm_flags |= VM_IO;	/* not in core dump */
 		vma->vm_page_prot = drm_io_prot(map->type, vma);
+#if !defined(__arm__)
 		if (io_remap_pfn_range(vma, vma->vm_start,
 				       (map->offset + offset) >> PAGE_SHIFT,
 				       vma->vm_end - vma->vm_start,
 				       vma->vm_page_prot))
 			return -EAGAIN;
+#else
+		if (remap_pfn_range(vma, vma->vm_start,
+					(map->offset + offset) >> PAGE_SHIFT,
+					vma->vm_end - vma->vm_start,
+					vma->vm_page_prot))
+			return -EAGAIN;
+#endif
+
 		DRM_DEBUG("   Type = %d; start = 0x%lx, end = 0x%lx,"
 			  " offset = 0x%llx\n",
 			  map->type,
 			  vma->vm_start, vma->vm_end, (unsigned long long)(map->offset + offset));
+
 		vma->vm_ops = &drm_vm_ops;
 		break;
 	case _DRM_CONSISTENT:
-- 
1.7.0.1


^ permalink raw reply related	[flat|nested] 17+ messages in thread

* [PATCH 4/4] drm:  Make sure the DRM offset matches the CPU
  2010-05-27 19:40   ` [PATCH v2] DRM platform device support jcrouse
                       ` (3 preceding siblings ...)
  2010-08-04 20:48     ` [PATCH 3/4] drm: Add __arm defines to DRM Jordan Crouse
@ 2010-08-04 20:48     ` Jordan Crouse
  4 siblings, 0 replies; 17+ messages in thread
From: Jordan Crouse @ 2010-08-04 20:48 UTC (permalink / raw)
  To: dri-devel; +Cc: linux-arm-msm, Jordan Crouse

The pgoff option in mmap() is defined as an unsigned long
so the offset generated by DRM needs to fit into
BITS_PER_LONG for the CPU in question.

Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org>
---
 drivers/gpu/drm/drm_gem.c |   10 ++++++++++
 1 files changed, 10 insertions(+), 0 deletions(-)

diff --git a/drivers/gpu/drm/drm_gem.c b/drivers/gpu/drm/drm_gem.c
index 33dad3f..8601b72 100644
--- a/drivers/gpu/drm/drm_gem.c
+++ b/drivers/gpu/drm/drm_gem.c
@@ -68,8 +68,18 @@
  * We make up offsets for buffer objects so we can recognize them at
  * mmap time.
  */
+
+/* pgoff in mmap is an unsigned long, so we need to make sure that
+ * the faked up offset will fit
+ */
+
+#if BITS_PER_LONG == 64
 #define DRM_FILE_PAGE_OFFSET_START ((0xFFFFFFFFUL >> PAGE_SHIFT) + 1)
 #define DRM_FILE_PAGE_OFFSET_SIZE ((0xFFFFFFFFUL >> PAGE_SHIFT) * 16)
+#else
+#define DRM_FILE_PAGE_OFFSET_START ((0xFFFFFFFUL >> PAGE_SHIFT) + 1)
+#define DRM_FILE_PAGE_OFFSET_SIZE ((0xFFFFFFFUL >> PAGE_SHIFT) * 16)
+#endif
 
 /**
  * Initialize the GEM device fields
-- 
1.7.0.1


^ permalink raw reply related	[flat|nested] 17+ messages in thread

* Re: [PATCH 1/4] drm: Remove drm_resource wrappers
  2010-08-04 20:48     ` [PATCH 1/4] drm: Remove drm_resource wrappers Jordan Crouse
@ 2010-08-04 20:53       ` Matt Turner
  0 siblings, 0 replies; 17+ messages in thread
From: Matt Turner @ 2010-08-04 20:53 UTC (permalink / raw)
  To: Jordan Crouse; +Cc: dri-devel, linux-arm-msm

On Wed, Aug 4, 2010 at 4:48 PM, Jordan Crouse <jcrouse@codeaurora.org> wrote:
> Remove the drm_resource wrappers and directly use the
> actual PCI and/or platform functions in their place.
>
> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org>
> ---
>  drivers/gpu/drm/drm_bufs.c                |   13 -------------
>  drivers/gpu/drm/i915/i915_dma.c           |    6 +++---
>  drivers/gpu/drm/mga/mga_dma.c             |    4 ++--
>  drivers/gpu/drm/nouveau/nouveau_bo.c      |    2 +-
>  drivers/gpu/drm/nouveau/nouveau_channel.c |    3 ++-
>  drivers/gpu/drm/nouveau/nouveau_mem.c     |   16 +++++++++-------
>  drivers/gpu/drm/nouveau/nv20_graph.c      |    4 ++--
>  drivers/gpu/drm/nouveau/nv40_graph.c      |    2 +-
>  drivers/gpu/drm/nouveau/nv50_instmem.c    |    3 ++-
>  drivers/gpu/drm/radeon/evergreen.c        |    4 ++--
>  drivers/gpu/drm/radeon/r100.c             |    4 ++--
>  drivers/gpu/drm/radeon/r600.c             |    4 ++--
>  drivers/gpu/drm/radeon/radeon_bios.c      |    2 +-
>  drivers/gpu/drm/radeon/radeon_cp.c        |    8 ++++----
>  drivers/gpu/drm/radeon/radeon_device.c    |    4 ++--
>  drivers/gpu/drm/radeon/rs600.c            |    4 ++--
>  drivers/gpu/drm/radeon/rs690.c            |    4 ++--
>  drivers/gpu/drm/radeon/rv770.c            |    4 ++--
>  drivers/gpu/drm/savage/savage_bci.c       |   24 +++++++++++++-----------
>  include/drm/drmP.h                        |    4 ----
>  20 files changed, 54 insertions(+), 65 deletions(-)
>
> diff --git a/drivers/gpu/drm/drm_bufs.c b/drivers/gpu/drm/drm_bufs.c
> index 2092e7b..3c2c663 100644
> --- a/drivers/gpu/drm/drm_bufs.c
> +++ b/drivers/gpu/drm/drm_bufs.c
> @@ -39,19 +39,6 @@
>  #include <asm/shmparam.h>
>  #include "drmP.h"
>
> -resource_size_t drm_get_resource_start(struct drm_device *dev, unsigned int resource)
> -{
> -       return pci_resource_start(dev->pdev, resource);
> -}
> -EXPORT_SYMBOL(drm_get_resource_start);
> -
> -resource_size_t drm_get_resource_len(struct drm_device *dev, unsigned int resource)
> -{
> -       return pci_resource_len(dev->pdev, resource);
> -}
> -
> -EXPORT_SYMBOL(drm_get_resource_len);
> -
>  static struct drm_map_list *drm_find_matching_map(struct drm_device *dev,
>                                                  struct drm_local_map *map)
>  {
> diff --git a/drivers/gpu/drm/i915/i915_dma.c b/drivers/gpu/drm/i915/i915_dma.c
> index 2305a12..a7bc699 100644
> --- a/drivers/gpu/drm/i915/i915_dma.c
> +++ b/drivers/gpu/drm/i915/i915_dma.c
> @@ -1354,7 +1354,7 @@ static int i915_load_modeset_init(struct drm_device *dev,
>        int fb_bar = IS_I9XX(dev) ? 2 : 0;
>        int ret = 0;
>
> -       dev->mode_config.fb_base = drm_get_resource_start(dev, fb_bar) &
> +       dev->mode_config.fb_base = pci_resource_start(dev->pdev, fb_bar) &
>                0xff000000;
>
>        /* Basic memrange allocator for stolen space (aka vram) */
> @@ -2063,8 +2063,8 @@ int i915_driver_load(struct drm_device *dev, unsigned long flags)
>
>        /* Add register map (needed for suspend/resume) */
>        mmio_bar = IS_I9XX(dev) ? 0 : 1;
> -       base = drm_get_resource_start(dev, mmio_bar);
> -       size = drm_get_resource_len(dev, mmio_bar);
> +       base = pci_resource_start(dev->pdev, mmio_bar);
> +       size = pci_resource_len(dev->pdev, mmio_bar);
>
>        if (i915_get_bridge_dev(dev)) {
>                ret = -EIO;
> diff --git a/drivers/gpu/drm/mga/mga_dma.c b/drivers/gpu/drm/mga/mga_dma.c
> index 3c917fb..ccc129c 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)
>        dev_priv->usec_timeout = MGA_DEFAULT_USEC_TIMEOUT;
>        dev_priv->chipset = flags;
>
> -       dev_priv->mmio_base = drm_get_resource_start(dev, 1);
> -       dev_priv->mmio_size = drm_get_resource_len(dev, 1);
> +       dev_priv->mmio_base = pci_resource_start(dev->pdev, 1);
> +       dev_priv->mmio_size = pci_resource_len(dev->pdev, 1);
>
>        dev->counters += 3;
>        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 6f3c195..1dad392 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)
>                break;
>        case TTM_PL_VRAM:
>                mem->bus.offset = mem->mm_node->start << PAGE_SHIFT;
> -               mem->bus.base = drm_get_resource_start(dev, 1);
> +               man->bus.base = pci_resource_start(dev->pdev, 1);
>                mem->bus.is_iomem = true;
>                break;
>        default:
> diff --git a/drivers/gpu/drm/nouveau/nouveau_channel.c b/drivers/gpu/drm/nouveau/nouveau_channel.c
> index 1fc57ef..06555c7 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)
>                 * VRAM.
>                 */
>                ret = nouveau_gpuobj_dma_new(chan, NV_CLASS_DMA_IN_MEMORY,
> -                                            drm_get_resource_start(dev, 1),
> +                                            pci_resource_start(dev->pdev,
> +                                            1),
>                                             dev_priv->fb_available_size,
>                                             NV_DMA_ACCESS_RO,
>                                             NV_DMA_TARGET_PCI, &pushbuf);
> diff --git a/drivers/gpu/drm/nouveau/nouveau_mem.c b/drivers/gpu/drm/nouveau/nouveau_mem.c
> index c1fd42b..fb6b791 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)
>        }
>
>        if (dev_priv->fb_mtrr) {
> -               drm_mtrr_del(dev_priv->fb_mtrr, drm_get_resource_start(dev, 1),
> -                            drm_get_resource_len(dev, 1), DRM_MTRR_WC);
> +               drm_mtrr_del(dev_priv->fb_mtrr,
> +                            pci_resource_start(dev->pdev, 1),
> +                            pci_resource_len(dev->pdev, 1), DRM_MTRR_WC);
>                dev_priv->fb_mtrr = 0;
>        }
>  }
> @@ -633,7 +634,7 @@ nouveau_mem_init(struct drm_device *dev)
>        struct ttm_bo_device *bdev = &dev_priv->ttm.bdev;
>        int ret, dma_bits = 32;
>
> -       dev_priv->fb_phys = drm_get_resource_start(dev, 1);
> +       dev_priv->fb_phys = pci_resource_start(dev->pdev, 1);
>        dev_priv->gart_info.type = NOUVEAU_GART_NONE;
>
>        if (dev_priv->card_type >= NV_50 &&
> @@ -665,8 +666,9 @@ nouveau_mem_init(struct drm_device *dev)
>
>        dev_priv->fb_available_size = dev_priv->vram_size;
>        dev_priv->fb_mappable_pages = dev_priv->fb_available_size;
> -       if (dev_priv->fb_mappable_pages > drm_get_resource_len(dev, 1))
> -               dev_priv->fb_mappable_pages = drm_get_resource_len(dev, 1);
> +       if (dev_priv->fb_mappable_pages > pci_resource_len(dev->pdev, 1))
> +               dev_priv->fb_mappable_pages =
> +                       pci_resource_len(dev->pdev, 1);
>        dev_priv->fb_mappable_pages >>= PAGE_SHIFT;
>
>        /* remove reserved space at end of vram from available amount */
> @@ -718,8 +720,8 @@ nouveau_mem_init(struct drm_device *dev)
>                return ret;
>        }
>
> -       dev_priv->fb_mtrr = drm_mtrr_add(drm_get_resource_start(dev, 1),
> -                                        drm_get_resource_len(dev, 1),
> +       dev_priv->fb_mtrr = drm_mtrr_add(pci_resource_start(dev->pdev, 1),
> +                                        pci_resource_len(dev->pdev, 1),
>                                         DRM_MTRR_WC);
>
>        return 0;
> diff --git a/drivers/gpu/drm/nouveau/nv20_graph.c b/drivers/gpu/drm/nouveau/nv20_graph.c
> index d6fc0a8..fe2349b 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)
>        nv_wr32(dev, NV10_PGRAPH_SURFACE, tmp);
>
>        /* begin RAM config */
> -       vramsz = drm_get_resource_len(dev, 0) - 1;
> +       vramsz = pci_resource_len(dev->pdev, 0) - 1;
>        nv_wr32(dev, 0x4009A4, nv_rd32(dev, NV04_PFB_CFG0));
>        nv_wr32(dev, 0x4009A8, nv_rd32(dev, NV04_PFB_CFG1));
>        nv_wr32(dev, NV10_PGRAPH_RDI_INDEX, 0x00EA0000);
> @@ -717,7 +717,7 @@ nv30_graph_init(struct drm_device *dev)
>        nv_wr32(dev, 0x0040075c             , 0x00000001);
>
>        /* begin RAM config */
> -       /* vramsz = drm_get_resource_len(dev, 0) - 1; */
> +       /* vramsz = pci_resource_len(dev->pdev, 0) - 1; */
>        nv_wr32(dev, 0x4009A4, nv_rd32(dev, NV04_PFB_CFG0));
>        nv_wr32(dev, 0x4009A8, nv_rd32(dev, NV04_PFB_CFG1));
>        if (dev_priv->chipset != 0x34) {
> diff --git a/drivers/gpu/drm/nouveau/nv40_graph.c b/drivers/gpu/drm/nouveau/nv40_graph.c
> index 704a25d..65b13b5 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)
>                nv40_graph_set_region_tiling(dev, i, 0, 0, 0);
>
>        /* begin RAM config */
> -       vramsz = drm_get_resource_len(dev, 0) - 1;
> +       vramsz = pci_resource_len(dev->pdev, 0) - 1;
>        switch (dev_priv->chipset) {
>        case 0x40:
>                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 5f21df3..ba4809e 100644
> --- a/drivers/gpu/drm/nouveau/nv50_instmem.c
> +++ b/drivers/gpu/drm/nouveau/nv50_instmem.c
> @@ -241,7 +241,8 @@ nv50_instmem_init(struct drm_device *dev)
>                return ret;
>        BAR0_WI32(priv->fb_bar->gpuobj, 0x00, 0x7fc00000);
>        BAR0_WI32(priv->fb_bar->gpuobj, 0x04, 0x40000000 +
> -                                             drm_get_resource_len(dev, 1) - 1);
> +                                             pci_resource_len(dev->pmem,
> +                                             1) - 1);
>        BAR0_WI32(priv->fb_bar->gpuobj, 0x08, 0x40000000);
>        BAR0_WI32(priv->fb_bar->gpuobj, 0x0c, 0x00000000);
>        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 1caf625..057192a 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)
>        }
>        rdev->mc.vram_width = numchan * chansize;
>        /* Could aper size report 0 ? */
> -       rdev->mc.aper_base = drm_get_resource_start(rdev->ddev, 0);
> -       rdev->mc.aper_size = drm_get_resource_len(rdev->ddev, 0);
> +       rdev->mc.aper_base = pci_resource_start(rdev->pdev, 0);
> +       rdev->mc.aper_size = pci_resource_len(rdev->pdev, 0);
>        /* Setup GPU memory space */
>        /* size in MB on evergreen */
>        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 a89a15a..da674e9 100644
> --- a/drivers/gpu/drm/radeon/r100.c
> +++ b/drivers/gpu/drm/radeon/r100.c
> @@ -2295,8 +2295,8 @@ void r100_vram_init_sizes(struct radeon_device *rdev)
>        u64 config_aper_size;
>
>        /* work out accessible VRAM */
> -       rdev->mc.aper_base = drm_get_resource_start(rdev->ddev, 0);
> -       rdev->mc.aper_size = drm_get_resource_len(rdev->ddev, 0);
> +       rdev->mc.aper_base = pci_resource_start(rdev->pdev, 0);
> +       rdev->mc.aper_size = pci_resource_len(rdev->pdev, 0);
>        rdev->mc.visible_vram_size = r100_get_accessible_vram(rdev);
>        /* FIXME we don't use the second aperture yet when we could use it */
>        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 e100f69..55675b7 100644
> --- a/drivers/gpu/drm/radeon/r600.c
> +++ b/drivers/gpu/drm/radeon/r600.c
> @@ -1217,8 +1217,8 @@ int r600_mc_init(struct radeon_device *rdev)
>        }
>        rdev->mc.vram_width = numchan * chansize;
>        /* Could aper size report 0 ? */
> -       rdev->mc.aper_base = drm_get_resource_start(rdev->ddev, 0);
> -       rdev->mc.aper_size = drm_get_resource_len(rdev->ddev, 0);
> +       rdev->mc.aper_base = pci_resource_start(rdev->pdev, 0);
> +       rdev->mc.aper_size = pci_resource_len(rdev->pdev, 0);
>        /* Setup GPU memory space */
>        rdev->mc.mc_vram_size = RREG32(CONFIG_MEMSIZE);
>        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 2c92137..654787e 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)
>                        return false;
>
>        rdev->bios = NULL;
> -       vram_base = drm_get_resource_start(rdev->ddev, 0);
> +       vram_base = pci_resource_start(rdev->pdev, 0);
>        bios = ioremap(vram_base, size);
>        if (!bios) {
>                return false;
> diff --git a/drivers/gpu/drm/radeon/radeon_cp.c b/drivers/gpu/drm/radeon/radeon_cp.c
> index 2f042a3..eb6b9ee 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)
>        else
>                dev_priv->flags |= RADEON_IS_PCI;
>
> -       ret = drm_addmap(dev, drm_get_resource_start(dev, 2),
> -                        drm_get_resource_len(dev, 2), _DRM_REGISTERS,
> +       ret = drm_addmap(dev, pci_resource_start(dev->pdev, 2),
> +                        pci_resource_len(dev->pdev, 2), _DRM_REGISTERS,
>                         _DRM_READ_ONLY | _DRM_DRIVER, &dev_priv->mmio);
>        if (ret != 0)
>                return ret;
> @@ -2194,9 +2194,9 @@ int radeon_driver_firstopen(struct drm_device *dev)
>
>        dev_priv->gart_info.table_size = RADEON_PCIGART_TABLE_SIZE;
>
> -       dev_priv->fb_aper_offset = drm_get_resource_start(dev, 0);
> +       dev_priv->fb_aper_offset = pci_resource_start(dev->pdev, 0);
>        ret = drm_addmap(dev, dev_priv->fb_aper_offset,
> -                        drm_get_resource_len(dev, 0), _DRM_FRAME_BUFFER,
> +                        pci_resource_len(dev->pdev, 0), _DRM_FRAME_BUFFER,
>                         _DRM_WRITE_COMBINING, &map);
>        if (ret != 0)
>                return ret;
> diff --git a/drivers/gpu/drm/radeon/radeon_device.c b/drivers/gpu/drm/radeon/radeon_device.c
> index dd279da..004a6d1 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,
>
>        /* Registers mapping */
>        /* TODO: block userspace mapping of io register */
> -       rdev->rmmio_base = drm_get_resource_start(rdev->ddev, 2);
> -       rdev->rmmio_size = drm_get_resource_len(rdev->ddev, 2);
> +       rdev->rmmio_base = pci_resource_start(rdev->pdev, 2);
> +       rdev->rmmio_size = pci_resource_len(rdev->pdev, 2);
>        rdev->rmmio = ioremap(rdev->rmmio_base, rdev->rmmio_size);
>        if (rdev->rmmio == NULL) {
>                return -ENOMEM;
> diff --git a/drivers/gpu/drm/radeon/rs600.c b/drivers/gpu/drm/radeon/rs600.c
> index 6dc15ea..ba09c87 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)
>  {
>        u64 base;
>
> -       rdev->mc.aper_base = drm_get_resource_start(rdev->ddev, 0);
> -       rdev->mc.aper_size = drm_get_resource_len(rdev->ddev, 0);
> +       rdev->mc.aper_base = pci_resource_start(rdev->pdev, 0);
> +       rdev->mc.aper_size = pci_resource_len(rdev->pdev, 0);
>        rdev->mc.vram_is_ddr = true;
>        rdev->mc.vram_width = 128;
>        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 ce4ecbe..de6bcb8 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)
>        rdev->mc.vram_width = 128;
>        rdev->mc.real_vram_size = RREG32(RADEON_CONFIG_MEMSIZE);
>        rdev->mc.mc_vram_size = rdev->mc.real_vram_size;
> -       rdev->mc.aper_base = drm_get_resource_start(rdev->ddev, 0);
> -       rdev->mc.aper_size = drm_get_resource_len(rdev->ddev, 0);
> +       rdev->mc.aper_base = pci_resource_start(rdev->pdev, 0);
> +       rdev->mc.aper_size = pci_resource_len(rdev->pdev, 0);
>        rdev->mc.visible_vram_size = rdev->mc.aper_size;
>        base = RREG32_MC(R_000100_MCCFG_FB_LOCATION);
>        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 b7fd820..6a7bf10 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)
>        }
>        rdev->mc.vram_width = numchan * chansize;
>        /* Could aper size report 0 ? */
> -       rdev->mc.aper_base = drm_get_resource_start(rdev->ddev, 0);
> -       rdev->mc.aper_size = drm_get_resource_len(rdev->ddev, 0);
> +       rdev->mc.aper_base = pci_resource_start(rdev->pdev, 0);
> +       rdev->mc.aper_size = pci_resource_len(rdev->pdev, 0);
>        /* Setup GPU memory space */
>        rdev->mc.mc_vram_size = RREG32(CONFIG_MEMSIZE);
>        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 2d0c9ca..f576232 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)
>        dev_priv->mtrr[2].handle = -1;
>        if (S3_SAVAGE3D_SERIES(dev_priv->chipset)) {
>                fb_rsrc = 0;
> -               fb_base = drm_get_resource_start(dev, 0);
> +               fb_base = pci_resource_start(dev->pdev, 0);
>                fb_size = SAVAGE_FB_SIZE_S3;
>                mmio_base = fb_base + SAVAGE_FB_SIZE_S3;
>                aper_rsrc = 0;
>                aperture_base = fb_base + SAVAGE_APERTURE_OFFSET;
>                /* this should always be true */
> -               if (drm_get_resource_len(dev, 0) == 0x08000000) {
> +               if (pci_resource_len(dev->pdev, 0) == 0x08000000) {
>                        /* Don't make MMIO write-cobining! We need 3
>                         * MTRRs. */
>                        dev_priv->mtrr[0].base = fb_base;
> @@ -599,18 +599,19 @@ int savage_driver_firstopen(struct drm_device *dev)
>                                         dev_priv->mtrr[2].size, DRM_MTRR_WC);
>                } else {
>                        DRM_ERROR("strange pci_resource_len %08llx\n",
> -                                 (unsigned long long)drm_get_resource_len(dev, 0));
> +                                 (unsigned long long)
> +                                 pci_resource_len(dev->pdev, 0));
>                }
>        } else if (dev_priv->chipset != S3_SUPERSAVAGE &&
>                   dev_priv->chipset != S3_SAVAGE2000) {
> -               mmio_base = drm_get_resource_start(dev, 0);
> +               mmio_base = pci_resource_start(dev->pdev, 0);
>                fb_rsrc = 1;
> -               fb_base = drm_get_resource_start(dev, 1);
> +               fb_base = pci_resource_start(dev->pdev, 1);
>                fb_size = SAVAGE_FB_SIZE_S4;
>                aper_rsrc = 1;
>                aperture_base = fb_base + SAVAGE_APERTURE_OFFSET;
>                /* this should always be true */
> -               if (drm_get_resource_len(dev, 1) == 0x08000000) {
> +               if (pci_resource_len(dev->pdev, 1) == 0x08000000) {
>                        /* Can use one MTRR to cover both fb and
>                         * aperture. */
>                        dev_priv->mtrr[0].base = fb_base;
> @@ -620,15 +621,16 @@ int savage_driver_firstopen(struct drm_device *dev)
>                                         dev_priv->mtrr[0].size, DRM_MTRR_WC);
>                } else {
>                        DRM_ERROR("strange pci_resource_len %08llx\n",
> -                                 (unsigned long long)drm_get_resource_len(dev, 1));
> +                                 (unsigned long long)
> +                                 pci_resource_len(dev->pdev, 1));
>                }
>        } else {
> -               mmio_base = drm_get_resource_start(dev, 0);
> +               mmio_base = pci_resource_start(dev->pdev, 0);
>                fb_rsrc = 1;
> -               fb_base = drm_get_resource_start(dev, 1);
> -               fb_size = drm_get_resource_len(dev, 1);
> +               fb_base = pci_resource_start(dev->pdev, 1);
> +               fb_size = pci_resource_len(dev->pdev, 1);
>                aper_rsrc = 2;
> -               aperture_base = drm_get_resource_start(dev, 2);
> +               aperture_base = pci_resource_start(dev->pdev, 2);
>                /* Automatic MTRR setup will do the right thing. */
>        }
>
> diff --git a/include/drm/drmP.h b/include/drm/drmP.h
> index c1b9871..8f7f5cb 100644
> --- a/include/drm/drmP.h
> +++ b/include/drm/drmP.h
> @@ -1273,10 +1273,6 @@ extern int drm_freebufs(struct drm_device *dev, void *data,
>  extern int drm_mapbufs(struct drm_device *dev, void *data,
>                       struct drm_file *file_priv);
>  extern int drm_order(unsigned long size);
> -extern resource_size_t drm_get_resource_start(struct drm_device *dev,
> -                                             unsigned int resource);
> -extern resource_size_t drm_get_resource_len(struct drm_device *dev,
> -                                           unsigned int resource);
>
>                                /* DMA support (drm_dma.h) */
>  extern int drm_dma_setup(struct drm_device *dev);
> --
> 1.7.0.1
>
> _______________________________________________
> dri-devel mailing list
> dri-devel@lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/dri-devel
>

Reviewed-by: Matt Turner <mattst88@gmail.com>

(I think I sent my reviewed-by the last time this patch was sent.)

^ permalink raw reply	[flat|nested] 17+ messages in thread

end of thread, other threads:[~2010-08-04 20:53 UTC | newest]

Thread overview: 17+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
     [not found] <4B8BE42C.1090401@codeaurora.org>
     [not found] ` <4B8BE489.7020402@codeaurora.org>
2010-03-15  0:56   ` [PATCH] drm: Allow platform devices to register as DRM devices Dave Airlie
2010-03-15 18:04     ` Jordan Crouse
2010-03-16  3:05       ` Dave Airlie
2010-03-16  2:41     ` Paul Mundt
2010-03-15 19:27   ` Ville Syrjälä
2010-05-27 19:40   ` [PATCH v2] DRM platform device support jcrouse
2010-08-04 20:48     ` [PATCH v3] " Jordan Crouse
2010-08-04 20:48     ` [PATCH 1/4] drm: Remove drm_resource wrappers Jordan Crouse
2010-08-04 20:53       ` Matt Turner
2010-08-04 20:48     ` [PATCH 2/4] drm: Add support for platform devices to register as DRM devices Jordan Crouse
2010-08-04 20:48     ` [PATCH 3/4] drm: Add __arm defines to DRM Jordan Crouse
2010-08-04 20:48     ` [PATCH 4/4] drm: Make sure the DRM offset matches the CPU Jordan Crouse
2010-05-27 19:40   ` [PATCH 1/4] drm: Remove drm_resource wrappers jcrouse
2010-05-27 21:15     ` Matt Turner
2010-05-27 19:40   ` [PATCH 2/4] drm: Add support for platform devices to register as DRM devices jcrouse
2010-05-27 19:40   ` [PATCH 3/4] drm: Add __arm defines to DRM jcrouse
2010-05-27 19:40   ` [PATCH 4/4] drm: Make sure the DRM offset matches the CPU jcrouse

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).