From a0758f20cdfb9fa8d7fe36499adfd2c19559a443 Mon Sep 17 00:00:00 2001 From: Jordan Crouse Date: Wed, 7 Dec 2011 11:19:22 -0700 Subject: [PATCH] msm: kgsl: Establish a standard GPU ID scheme for the KGSL core Establish a standard generic format for a GPU ID in the KGSL core: [0:15] - GPU specific identifier [16:31] - 0x0002 for 2D or 0x0003 for 3D Add a KGSL core function to get the GPU ID from the devices and GPU specific functions to return them. For Z180, the ID will be 0x0002000B4 (0xB4 = 180). For 3D, the ID will be 0x00030000 ORed with the GPU identifier (anywhere from 205 to 225). Change-Id: Ic0dedbadddb3f587121913b9c226e2bda466f84e Signed-off-by: Jordan Crouse --- drivers/gpu/msm/adreno.c | 13 +++++++++++++ drivers/gpu/msm/kgsl_device.h | 6 ++++++ drivers/gpu/msm/z180.c | 11 +++++++++++ 3 files changed, 30 insertions(+) diff --git a/drivers/gpu/msm/adreno.c b/drivers/gpu/msm/adreno.c index d7c11dbbb89..26812630d3d 100644 --- a/drivers/gpu/msm/adreno.c +++ b/drivers/gpu/msm/adreno.c @@ -1317,6 +1317,18 @@ void adreno_irqctrl(struct kgsl_device *device, int state) adreno_dev->gpudev->irq_control(adreno_dev, state); } +static unsigned int adreno_gpuid(struct kgsl_device *device) +{ + struct adreno_device *adreno_dev = ADRENO_DEVICE(device); + + /* Standard KGSL gpuid format: + * top word is 0x0002 for 2D or 0x0003 for 3D + * Bottom word is core specific identifer + */ + + return (0x0003 << 16) | ((int) adreno_dev->gpurev); +} + static const struct kgsl_functable adreno_functable = { /* Mandatory functions */ .regread = adreno_regread, @@ -1335,6 +1347,7 @@ static const struct kgsl_functable adreno_functable = { .cleanup_pt = adreno_cleanup_pt, .power_stats = adreno_power_stats, .irqctrl = adreno_irqctrl, + .gpuid = adreno_gpuid, /* Optional functions */ .setstate = adreno_setstate, .drawctxt_create = adreno_drawctxt_create, diff --git a/drivers/gpu/msm/kgsl_device.h b/drivers/gpu/msm/kgsl_device.h index 1c55199416b..3ef11ceffc0 100644 --- a/drivers/gpu/msm/kgsl_device.h +++ b/drivers/gpu/msm/kgsl_device.h @@ -89,6 +89,7 @@ struct kgsl_functable { void (*power_stats)(struct kgsl_device *device, struct kgsl_power_stats *stats); void (*irqctrl)(struct kgsl_device *device, int state); + unsigned int (*gpuid)(struct kgsl_device *device); /* Optional functions - these functions are not mandatory. The driver will check that the function pointer is not NULL before calling the hook */ @@ -240,6 +241,11 @@ static inline int kgsl_idle(struct kgsl_device *device, unsigned int timeout) return device->ftbl->idle(device, timeout); } +static inline unsigned int kgsl_gpuid(struct kgsl_device *device) +{ + return device->ftbl->gpuid(device); +} + static inline int kgsl_create_device_sysfs_files(struct device *root, const struct device_attribute **list) { diff --git a/drivers/gpu/msm/z180.c b/drivers/gpu/msm/z180.c index 8413fc47127..cf74e64e675 100644 --- a/drivers/gpu/msm/z180.c +++ b/drivers/gpu/msm/z180.c @@ -888,6 +888,16 @@ static void z180_irqctrl(struct kgsl_device *device, int state) } } +static unsigned int z180_gpuid(struct kgsl_device *device) +{ + /* Standard KGSL gpuid format: + * top word is 0x0002 for 2D or 0x0003 for 3D + * Bottom word is core specific identifer + */ + + return (0x0002 << 16) | 180; +} + static const struct kgsl_functable z180_functable = { /* Mandatory functions */ .regread = z180_regread, @@ -905,6 +915,7 @@ static const struct kgsl_functable z180_functable = { .cleanup_pt = z180_cleanup_pt, .power_stats = z180_power_stats, .irqctrl = z180_irqctrl, + .gpuid = z180_gpuid, /* Optional functions */ .drawctxt_create = NULL, .drawctxt_destroy = z180_drawctxt_destroy,