From 52f97df5da1f94d2b7db1bb53a2f053ae162b649 Mon Sep 17 00:00:00 2001 From: Ben Hutchings Date: Sun, 23 Aug 2009 18:37:26 +0100 Subject: drm/r128: Use request_firmware() to load CCE microcode Firmware blob looks like this: __be32 datah __be32 datal Signed-off-by: Ben Hutchings Signed-off-by: Dave Airlie --- drivers/gpu/drm/Kconfig | 1 + drivers/gpu/drm/r128/r128_cce.c | 98 +++++++++++++++--------------- firmware/Makefile | 1 + firmware/WHENCE | 31 ++++++++++ firmware/r128/r128_cce.bin.ihex | 129 ++++++++++++++++++++++++++++++++++++++++ 5 files changed, 210 insertions(+), 50 deletions(-) create mode 100644 firmware/r128/r128_cce.bin.ihex diff --git a/drivers/gpu/drm/Kconfig b/drivers/gpu/drm/Kconfig index 10edc9b0022..a07abb818f5 100644 --- a/drivers/gpu/drm/Kconfig +++ b/drivers/gpu/drm/Kconfig @@ -36,6 +36,7 @@ config DRM_TDFX config DRM_R128 tristate "ATI Rage 128" depends on DRM && PCI + select FW_LOADER help Choose this option if you have an ATI Rage 128 graphics card. If M is selected, the module will be called r128. AGP support for diff --git a/drivers/gpu/drm/r128/r128_cce.c b/drivers/gpu/drm/r128/r128_cce.c index c75fd356404..15252f60bbd 100644 --- a/drivers/gpu/drm/r128/r128_cce.c +++ b/drivers/gpu/drm/r128/r128_cce.c @@ -29,6 +29,9 @@ * Gareth Hughes */ +#include +#include + #include "drmP.h" #include "drm.h" #include "r128_drm.h" @@ -36,50 +39,9 @@ #define R128_FIFO_DEBUG 0 -/* CCE microcode (from ATI) */ -static u32 r128_cce_microcode[] = { - 0, 276838400, 0, 268449792, 2, 142, 2, 145, 0, 1076765731, 0, - 1617039951, 0, 774592877, 0, 1987540286, 0, 2307490946U, 0, - 599558925, 0, 589505315, 0, 596487092, 0, 589505315, 1, - 11544576, 1, 206848, 1, 311296, 1, 198656, 2, 912273422, 11, - 262144, 0, 0, 1, 33559837, 1, 7438, 1, 14809, 1, 6615, 12, 28, - 1, 6614, 12, 28, 2, 23, 11, 18874368, 0, 16790922, 1, 409600, 9, - 30, 1, 147854772, 16, 420483072, 3, 8192, 0, 10240, 1, 198656, - 1, 15630, 1, 51200, 10, 34858, 9, 42, 1, 33559823, 2, 10276, 1, - 15717, 1, 15718, 2, 43, 1, 15936948, 1, 570480831, 1, 14715071, - 12, 322123831, 1, 33953125, 12, 55, 1, 33559908, 1, 15718, 2, - 46, 4, 2099258, 1, 526336, 1, 442623, 4, 4194365, 1, 509952, 1, - 459007, 3, 0, 12, 92, 2, 46, 12, 176, 1, 15734, 1, 206848, 1, - 18432, 1, 133120, 1, 100670734, 1, 149504, 1, 165888, 1, - 15975928, 1, 1048576, 6, 3145806, 1, 15715, 16, 2150645232U, 2, - 268449859, 2, 10307, 12, 176, 1, 15734, 1, 15735, 1, 15630, 1, - 15631, 1, 5253120, 6, 3145810, 16, 2150645232U, 1, 15864, 2, 82, - 1, 343310, 1, 1064207, 2, 3145813, 1, 15728, 1, 7817, 1, 15729, - 3, 15730, 12, 92, 2, 98, 1, 16168, 1, 16167, 1, 16002, 1, 16008, - 1, 15974, 1, 15975, 1, 15990, 1, 15976, 1, 15977, 1, 15980, 0, - 15981, 1, 10240, 1, 5253120, 1, 15720, 1, 198656, 6, 110, 1, - 180224, 1, 103824738, 2, 112, 2, 3145839, 0, 536885440, 1, - 114880, 14, 125, 12, 206975, 1, 33559995, 12, 198784, 0, - 33570236, 1, 15803, 0, 15804, 3, 294912, 1, 294912, 3, 442370, - 1, 11544576, 0, 811612160, 1, 12593152, 1, 11536384, 1, - 14024704, 7, 310382726, 0, 10240, 1, 14796, 1, 14797, 1, 14793, - 1, 14794, 0, 14795, 1, 268679168, 1, 9437184, 1, 268449792, 1, - 198656, 1, 9452827, 1, 1075854602, 1, 1075854603, 1, 557056, 1, - 114880, 14, 159, 12, 198784, 1, 1109409213, 12, 198783, 1, - 1107312059, 12, 198784, 1, 1109409212, 2, 162, 1, 1075854781, 1, - 1073757627, 1, 1075854780, 1, 540672, 1, 10485760, 6, 3145894, - 16, 274741248, 9, 168, 3, 4194304, 3, 4209949, 0, 0, 0, 256, 14, - 174, 1, 114857, 1, 33560007, 12, 176, 0, 10240, 1, 114858, 1, - 33560018, 1, 114857, 3, 33560007, 1, 16008, 1, 114874, 1, - 33560360, 1, 114875, 1, 33560154, 0, 15963, 0, 256, 0, 4096, 1, - 409611, 9, 188, 0, 10240, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 -}; +#define FIRMWARE_NAME "r128/r128_cce.bin" + +MODULE_FIRMWARE(FIRMWARE_NAME); static int R128_READ_PLL(struct drm_device * dev, int addr) { @@ -176,20 +138,50 @@ static int r128_do_wait_for_idle(drm_r128_private_t * dev_priv) */ /* Load the microcode for the CCE */ -static void r128_cce_load_microcode(drm_r128_private_t * dev_priv) +static int r128_cce_load_microcode(drm_r128_private_t *dev_priv) { - int i; + struct platform_device *pdev; + const struct firmware *fw; + const __be32 *fw_data; + int rc, i; DRM_DEBUG("\n"); + pdev = platform_device_register_simple("r128_cce", 0, NULL, 0); + if (IS_ERR(pdev)) { + printk(KERN_ERR "r128_cce: Failed to register firmware\n"); + return PTR_ERR(pdev); + } + rc = request_firmware(&fw, FIRMWARE_NAME, &pdev->dev); + platform_device_unregister(pdev); + if (rc) { + printk(KERN_ERR "r128_cce: Failed to load firmware \"%s\"\n", + FIRMWARE_NAME); + return rc; + } + + if (fw->size != 256 * 8) { + printk(KERN_ERR + "r128_cce: Bogus length %zu in firmware \"%s\"\n", + fw->size, FIRMWARE_NAME); + rc = -EINVAL; + goto out_release; + } + r128_do_wait_for_idle(dev_priv); + fw_data = (const __be32 *)fw->data; R128_WRITE(R128_PM4_MICROCODE_ADDR, 0); for (i = 0; i < 256; i++) { - R128_WRITE(R128_PM4_MICROCODE_DATAH, r128_cce_microcode[i * 2]); + R128_WRITE(R128_PM4_MICROCODE_DATAH, + be32_to_cpup(&fw_data[i * 2])); R128_WRITE(R128_PM4_MICROCODE_DATAL, - r128_cce_microcode[i * 2 + 1]); + be32_to_cpup(&fw_data[i * 2 + 1])); } + +out_release: + release_firmware(fw); + return rc; } /* Flush any pending commands to the CCE. This should only be used just @@ -350,6 +342,7 @@ static void r128_cce_init_ring_buffer(struct drm_device * dev, static int r128_do_init_cce(struct drm_device * dev, drm_r128_init_t * init) { drm_r128_private_t *dev_priv; + int rc; DRM_DEBUG("\n"); @@ -575,13 +568,18 @@ static int r128_do_init_cce(struct drm_device * dev, drm_r128_init_t * init) #endif r128_cce_init_ring_buffer(dev, dev_priv); - r128_cce_load_microcode(dev_priv); + rc = r128_cce_load_microcode(dev_priv); dev->dev_private = (void *)dev_priv; r128_do_engine_reset(dev); - return 0; + if (rc) { + DRM_ERROR("Failed to load firmware!\n"); + r128_do_cleanup_cce(dev); + } + + return rc; } int r128_do_cleanup_cce(struct drm_device * dev) diff --git a/firmware/Makefile b/firmware/Makefile index 0e39f7e73ba..6ea4e3d9f05 100644 --- a/firmware/Makefile +++ b/firmware/Makefile @@ -43,6 +43,7 @@ fw-shipped-$(CONFIG_CHELSIO_T3) += cxgb3/t3b_psram-1.1.0.bin \ cxgb3/t3c_psram-1.1.0.bin \ cxgb3/t3fw-7.4.0.bin fw-shipped-$(CONFIG_DRM_MGA) += matrox/g200_warp.fw matrox/g400_warp.fw +fw-shipped-$(CONFIG_DRM_R128) += r128/r128_cce.bin fw-shipped-$(CONFIG_DVB_AV7110) += av7110/bootcode.bin fw-shipped-$(CONFIG_DVB_TTUSB_BUDGET) += ttusb-budget/dspbootcode.bin fw-shipped-$(CONFIG_E100) += e100/d101m_ucode.bin e100/d101s_ucode.bin \ diff --git a/firmware/WHENCE b/firmware/WHENCE index 5db34a88d6e..578d859c41f 100644 --- a/firmware/WHENCE +++ b/firmware/WHENCE @@ -730,3 +730,34 @@ OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. Found in hex form in kernel source. -------------------------------------------------------------------------- + +Driver: r128 - ATI Rage 128 + +File: r128/r128_cce.bin + +Licence: + +Copyright 2000 Advanced Micro Devices, Inc. + + * 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 + * PRECISION INSIGHT AND/OR ITS SUPPLIERS 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. + +Found in decimal form in kernel source. + +-------------------------------------------------------------------------- diff --git a/firmware/r128/r128_cce.bin.ihex b/firmware/r128/r128_cce.bin.ihex new file mode 100644 index 00000000000..4831315d7b9 --- /dev/null +++ b/firmware/r128/r128_cce.bin.ihex @@ -0,0 +1,129 @@ +:1000000000000000108038000000000010003800E0 +:10001000000000020000008E0000000200000091BD +:1000200000000000402E2423000000006062124FF8 +:10003000000000002E2B596D000000007677753E01 +:1000400000000000898984820000000023BC8B0D21 +:10005000000000002323232300000000238DABB405 +:1000600000000000232323230000000100B028002B +:100070000000000100032800000000010004C0008F +:100080000000000100030800000000023660300E8E +:100090000000000B00040000000000000000000051 +:1000A000000000010200151D0000000100001D0EEF +:1000B00000000001000039D900000001000019D73C +:1000C0000000000C0000001C00000001000019D618 +:1000D0000000000C0000001C0000000200000017DF +:1000E0000000000B01200000000000000100358A24 +:1000F0000000000100064000000000090000001E92 +:100100000000000108D015B4000000101910100004 +:100110000000000300002000000000000000280094 +:1001200000000001000308000000000100003D0E77 +:10013000000000010000C8000000000A0000882A3A +:10014000000000090000002A000000010200150F55 +:1001500000000002000028240000000100003D65AE +:100160000000000100003D66000000020000002BBE +:100170000000000100F32DB4000000012200D8BFF0 +:100180000000000100E088BF0000000C1333383786 +:1001900000000001020615650000000C0000003799 +:1001A00000000001020015640000000100003D662F +:1001B000000000020000002E000000040020083AA9 +:1001C0000000000100080800000000010006C0FF58 +:1001D000000000040040003D000000010007C800CE +:1001E00000000001000700FF000000030000000005 +:1001F0000000000C0000005C000000020000002E67 +:100200000000000C000000B00000000100003D767E +:100210000000000100032800000000010000480069 +:1002200000000001000208000000000106001D0E91 +:1002300000000001000248000000000100028800E8 +:100240000000000100F3C5F80000000100100000EC +:10025000000000060030004E0000000100003D6379 +:100260000000001080303DF0000000021000384314 +:1002700000000002000028430000000C000000B055 +:100280000000000100003D760000000100003D7705 +:100290000000000100003D0E0000000100003D0FC5 +:1002A000000000010050280000000006003000524D +:1002B0000000001080303DF00000000100003DF81B +:1002C00000000002000000520000000100053D0E89 +:1002D0000000000100103D0F00000002003000553A +:1002E0000000000100003D700000000100001E89B8 +:1002F0000000000100003D710000000300003D729D +:100300000000000C0000005C000000020000006221 +:100310000000000100003F280000000100003F270E +:100320000000000100003E820000000100003E8845 +:100330000000000100003E660000000100003E6772 +:100340000000000100003E760000000100003E6851 +:100350000000000100003E690000000100003E6C4A +:100360000000000000003E6D0000000100002800B9 +:1003700000000001005028000000000100003D685E +:100380000000000100030800000000060000006EED +:10039000000000010002C0000000000106303D62C4 +:1003A0000000000200000070000000020030006F3A +:1003B00000000000200038C0000000010001C0C0A3 +:1003C0000000000E0000007D0000000C0003287FEC +:1003D00000000001020015BB0000000C00030880B3 +:1003E0000000000002003DBC0000000100003DBB19 +:1003F0000000000000003DBC00000003000480007D +:100400000000000100048000000000030006C0029C +:100410000000000100B0280000000000306038003B +:100420000000000100C028000000000100B008002A +:100430000000000100D600000000000712801086B6 +:10044000000000000000280000000001000039CC7E +:1004500000000001000039CD00000001000039C992 +:1004600000000001000039CA00000000000039CB84 +:10047000000000011003B80000000001009000001F +:100480000000000110003800000000010003080017 +:100490000000000100903D1B0000000140203D0ACB +:1004A0000000000140203D0B00000001000880001A +:1004B000000000010001C0C00000000E0000009F0D +:1004C0000000000C000308800000000142203DBD38 +:1004D0000000000C0003087F0000000142003DBB4B +:1004E0000000000C000308800000000142203DBC19 +:1004F00000000002000000A20000000140203DBDFD +:100500000000000140003DBB0000000140203DBC58 +:1005100000000001000840000000000100A00000F1 +:1005200000000006003000A6000000101060380037 +:1005300000000009000000A80000000300400000C7 +:100540000000000300403D1D00000000000000000E +:1005500000000000000001000000000E000000AEDE +:10056000000000010001C0A900000001020015C741 +:100570000000000C000000B0000000000000280097 +:10058000000000010001C0AA00000001020015D215 +:10059000000000010001C0A900000003020015C70F +:1005A0000000000100003E88000000010001C0BA08 +:1005B0000000000102001728000000010001C0BB7C +:1005C000000000010200165A0000000000003E5B1F +:1005D000000000000000010000000000000010000A +:1005E000000000010006400B00000009000000BCF4 +:1005F00000000000000028000000000000000000D3 +:1006000000000000000000000000000000000000EA +:1006100000000000000000000000000000000000DA +:1006200000000000000000000000000000000000CA +:1006300000000000000000000000000000000000BA +:1006400000000000000000000000000000000000AA +:10065000000000000000000000000000000000009A +:10066000000000000000000000000000000000008A +:10067000000000000000000000000000000000007A +:10068000000000000000000000000000000000006A +:10069000000000000000000000000000000000005A +:1006A000000000000000000000000000000000004A +:1006B000000000000000000000000000000000003A +:1006C000000000000000000000000000000000002A +:1006D000000000000000000000000000000000001A +:1006E000000000000000000000000000000000000A +:1006F00000000000000000000000000000000000FA +:1007000000000000000000000000000000000000E9 +:1007100000000000000000000000000000000000D9 +:1007200000000000000000000000000000000000C9 +:1007300000000000000000000000000000000000B9 +:1007400000000000000000000000000000000000A9 +:100750000000000000000000000000000000000099 +:100760000000000000000000000000000000000089 +:100770000000000000000000000000000000000079 +:100780000000000000000000000000000000000069 +:100790000000000000000000000000000000000059 +:1007A0000000000000000000000000000000000049 +:1007B0000000000000000000000000000000000039 +:1007C0000000000000000000000000000000000029 +:1007D0000000000000000000000000000000000019 +:1007E0000000000000000000000000000000000009 +:1007F00000000000000000000000000000000000F9 +:00000001FF -- cgit v1.2.3