31 #define SOURCEFILE_NAME "hpi6000.c"
40 #define HPI_HIF_BASE (0x00000200)
41 #define HPI_HIF_ADDR(member) \
42 (HPI_HIF_BASE + offsetof(struct hpi_hif_6000, member))
43 #define HPI_HIF_ERROR_MASK 0x4000
46 #define HPI6000_ERROR_BASE 900
49 #define HPI6000_ERROR_MSG_RESP_IDLE_TIMEOUT 901
51 #define HPI6000_ERROR_MSG_RESP_GET_RESP_ACK 903
52 #define HPI6000_ERROR_MSG_GET_ADR 904
53 #define HPI6000_ERROR_RESP_GET_ADR 905
54 #define HPI6000_ERROR_MSG_RESP_BLOCKWRITE32 906
55 #define HPI6000_ERROR_MSG_RESP_BLOCKREAD32 907
57 #define HPI6000_ERROR_CONTROL_CACHE_PARAMS 909
59 #define HPI6000_ERROR_SEND_DATA_IDLE_TIMEOUT 911
60 #define HPI6000_ERROR_SEND_DATA_ACK 912
61 #define HPI6000_ERROR_SEND_DATA_ADR 913
62 #define HPI6000_ERROR_SEND_DATA_TIMEOUT 914
63 #define HPI6000_ERROR_SEND_DATA_CMD 915
64 #define HPI6000_ERROR_SEND_DATA_WRITE 916
65 #define HPI6000_ERROR_SEND_DATA_IDLECMD 917
67 #define HPI6000_ERROR_GET_DATA_IDLE_TIMEOUT 921
68 #define HPI6000_ERROR_GET_DATA_ACK 922
69 #define HPI6000_ERROR_GET_DATA_CMD 923
70 #define HPI6000_ERROR_GET_DATA_READ 924
71 #define HPI6000_ERROR_GET_DATA_IDLECMD 925
73 #define HPI6000_ERROR_CONTROL_CACHE_ADDRLEN 951
74 #define HPI6000_ERROR_CONTROL_CACHE_READ 952
75 #define HPI6000_ERROR_CONTROL_CACHE_FLUSH 953
77 #define HPI6000_ERROR_MSG_RESP_GETRESPCMD 961
78 #define HPI6000_ERROR_MSG_RESP_IDLECMD 962
81 #define HPI6000_ERROR_UNHANDLED_SUBSYS_ID 930
84 #define HPI6000_ERROR_INIT_PCI2040 931
86 #define HPI6000_ERROR_INIT_DSPHPI 932
88 #define HPI6000_ERROR_INIT_DSPINTMEM 933
90 #define HPI6000_ERROR_INIT_SDRAM1 934
92 #define HPI6000_ERROR_INIT_SDRAM2 935
94 #define HPI6000_ERROR_INIT_VERIFY 938
96 #define HPI6000_ERROR_INIT_NOACK 939
98 #define HPI6000_ERROR_INIT_PLDTEST1 941
99 #define HPI6000_ERROR_INIT_PLDTEST2 942
103 #define HIDE_PCI_ASSERTS
111 #define INTERRUPT_EVENT_SET 0
112 #define INTERRUPT_EVENT_CLEAR 1
113 #define INTERRUPT_MASK_SET 2
114 #define INTERRUPT_MASK_CLEAR 3
115 #define HPI_ERROR_REPORT 4
117 #define HPI_DATA_WIDTH 6
121 #define DSP_SPACING 0x800
123 #define CONTROL 0x0000
124 #define ADDRESS 0x0200
125 #define DATA_AUTOINC 0x0400
128 #define TIMEOUT 500000
161 static short hpi6000_adapter_boot_load_dsp(
struct hpi_adapter_obj *pao,
162 u32 *pos_error_code);
163 static short hpi6000_check_PCI2040_error_flag(
struct hpi_adapter_obj *pao,
170 static short hpi6000_message_response_sequence(
struct hpi_adapter_obj *pao,
182 static void hpi6000_send_dsp_interrupt(
struct dsp_obj *pdo);
200 static void subsys_create_adapter(
struct hpi_message *phm,
210 u32 *pos_error_code);
216 static u16 gw_pci_read_asserts;
217 static u16 gw_pci_write_asserts;
223 subsys_create_adapter(phm, phr);
240 err = hpi6000_update_control_cache(pao, phm);
256 hw_message(pao, phm, phr);
259 hw_message(pao, phm, phr);
265 hw_message(pao, phm, phr);
275 adapter_get_asserts(pao, phm, phr);
279 adapter_delete(pao, phm, phr);
283 hw_message(pao, phm, phr);
302 hw_message(pao, phm, phr);
322 hw_message(pao, phm, phr);
364 subsys_message(phm, phr);
370 sizeof(struct hpi_adapter_res);
371 adapter_message(pao, phm, phr);
375 control_message(pao, phm, phr);
379 outstream_message(pao, phm, phr);
383 instream_message(pao, phm, phr);
387 hw_message(pao, phm, phr);
406 static void subsys_create_adapter(
struct hpi_message *phm,
418 memset(&ao, 0,
sizeof(ao));
428 ao.pci = *phm->
u.
s.resource.r.pci;
430 err = create_adapter_obj(&ao, &os_error_code);
432 delete_adapter_obj(&ao);
440 phr->
u.
s.data = os_error_code;
452 for (dsp_index = 0; dsp_index <
MAX_DSPS; dsp_index++) {
454 phw->
ado[dsp_index].pa_parent_adapter = pao;
457 phr->
u.
s.adapter_type = ao.type;
458 phr->
u.
s.adapter_index = ao.index;
465 delete_adapter_obj(pao);
474 short boot_error = 0;
476 u32 control_cache_size = 0;
477 u32 control_cache_count = 0;
489 for (dsp_index = 0; dsp_index <
MAX_DSPS; dsp_index++) {
490 phw->
ado[dsp_index].prHPI_control =
494 phw->
ado[dsp_index].prHPI_address =
497 phw->
ado[dsp_index].prHPI_data =
500 phw->
ado[dsp_index].prHPI_data_auto_inc =
505 phw->
ado[dsp_index].prHPI_control,
506 phw->
ado[dsp_index].prHPI_address,
507 phw->
ado[dsp_index].prHPI_data,
508 phw->
ado[dsp_index].prHPI_data_auto_inc);
510 phw->
ado[dsp_index].pa_parent_adapter = pao;
521 boot_error = hpi6000_adapter_boot_load_dsp(pao, pos_error_code);
539 memset(&hm, 0,
sizeof(hm));
544 hm.adapter_index = 0;
545 memset(&hr0, 0,
sizeof(hr0));
546 memset(&hr1, 0,
sizeof(hr1));
547 hr0.size =
sizeof(hr0);
548 hr1.size =
sizeof(hr1);
550 error = hpi6000_message_response_sequence(pao, 0, &hm, &hr0);
556 error = hpi6000_message_response_sequence(pao, 1, &hm,
561 pao->
type = hr0.u.ax.info.adapter_type;
562 pao->
index = hr0.u.ax.info.adapter_index;
570 hpi_read_word(&phw->
ado[0],
572 if (control_cache_size) {
573 control_cache_count =
574 hpi_read_word(&phw->
ado[0],
579 control_cache_size, (
unsigned char *)
614 #ifndef HIDE_PCI_ASSERTS
616 if ((gw_pci_read_asserts > 0) || (gw_pci_write_asserts > 0)) {
618 gw_pci_read_asserts * 100 + gw_pci_write_asserts;
624 gw_pci_read_asserts = 0;
625 gw_pci_write_asserts = 0;
629 hw_message(pao, phm, phr);
637 static short hpi6000_adapter_boot_load_dsp(
struct hpi_adapter_obj *pao,
647 u32 test_addr = 0x80000000;
648 u32 test_data = 0x00000001;
649 u32 dw2040_reset = 0;
656 u16 boot_load_family = 0;
660 switch (pao->
pci.pci_dev->subsystem_device) {
676 dw2040_reset = 0x0003000F;
686 if (delay != dw2040_reset) {
702 dw2040_reset = dw2040_reset & (~(endian << 3));
705 phw->
ado[0].c_dsp_rev =
'B';
706 phw->
ado[1].c_dsp_rev =
'B';
709 dw2040_reset = dw2040_reset & (~0x00000001);
711 dw2040_reset = dw2040_reset & (~0x00000002);
715 dw2040_reset = dw2040_reset & (~0x00000008);
721 for (dsp_index = 0; dsp_index < phw->
num_dsp; dsp_index++) {
729 test_data = 0x00000001;
730 for (j = 0; j < 32; j++) {
733 if (data != test_data) {
735 test_data, data, dsp_index);
738 test_data = test_data << 1;
756 hpi_write_word(pdo, 0x01B7C100, 0x0000);
761 hpi_write_word(pdo, 0x01B7C120, 0x8002);
765 hpi_write_word(pdo, 0x01B7C11C, 0x8001);
769 hpi_write_word(pdo, 0x01B7C118, 0x8000);
775 hpi_write_word(pdo, 0x01B7C100, 0x0001);
787 for (i = 0; i < 100; i++) {
788 test_addr = 0x00000000;
789 test_data = 0x00000001;
790 for (j = 0; j < 32; j++) {
791 hpi_write_word(pdo, test_addr + i, test_data);
792 data = hpi_read_word(pdo, test_addr + i);
793 if (data != test_data) {
795 "DSP mem %x %x %x %x\n",
796 test_addr + i, test_data,
801 test_data = test_data << 1;
828 hpi_write_word(pdo, 0x01800000, 0x34A8);
841 hpi_write_word(pdo, 0x01800008, 0x00000030);
861 hpi_write_word(pdo, 0x01800020, 0x001BDF29);
876 hpi_write_word(pdo, 0x01800018, 0x47117000);
879 hpi_write_word(pdo, 0x0180001C, 0x00000410);
895 (1
L << 28) | (3L << 22) | (1
L << 20) | (1L <<
896 16) | (2
L << 14) | (3L << 8) | (2
L << 4) | 1L;
897 hpi_write_word(pdo, 0x01800004, cE1);
905 test_addr = 0x80000000;
906 test_data = 0x00000001;
908 for (j = 0; j < 32; j++) {
909 hpi_write_word(pdo, test_addr, test_data);
910 data = hpi_read_word(pdo, test_addr);
911 if (data != test_data) {
913 "DSP dram %x %x %x %x\n",
914 test_addr, test_data, data,
919 test_data = test_data << 1;
922 #define DRAM_SIZE_WORDS 0x200000
923 #define DRAM_INC 1024
924 test_addr = 0x80000000;
927 hpi_write_word(pdo, test_addr + i, test_data);
930 test_addr = 0x80000000;
932 for (i = 0; i < DRAM_SIZE_WORDS; i = i +
DRAM_INC) {
933 data = hpi_read_word(pdo, test_addr + i);
934 if (data != test_data) {
936 "DSP dram %x %x %x %x\n",
937 test_addr + i, test_data,
962 if (length == 0xFFFFFFFF)
975 error = hpi6000_dsp_block_write32(pao, (
u16)dsp_index,
976 address, pcode, length);
995 if (length == 0xFFFFFFFF)
1002 for (i = 0; i <
length; i++) {
1003 data = hpi_read_word(pdo, address);
1004 if (data != *pcode) {
1007 "DSP verify %x %x %x %x\n",
1008 address, *pcode, data,
1025 for (i = 0; i < 4; i++) {
1026 hpi_write_word(pdo, address, 0);
1032 hpi_write_word(pdo,
HPI_HIF_ADDR(dsp_number), dsp_index);
1054 read = hpi_read_word(pdo,
1057 && hpi6000_check_PCI2040_error_flag(pao,
1076 if (dsp_index == 0) {
1092 #define PLD_BASE_ADDRESS 0x90000000L
1094 switch (boot_load_family) {
1101 subsystem_device) ==
1107 subsystem_device) ==
1116 test_data = 0xAAAAAA00
L &
mask;
1118 hpi_write_word(pdo, PLD_BASE_ADDRESS + 4L, test_data);
1119 read = hpi_read_word(pdo,
1120 PLD_BASE_ADDRESS + 4L) &
mask;
1121 if (read != test_data) {
1126 test_data = 0x55555500
L &
mask;
1127 hpi_write_word(pdo, PLD_BASE_ADDRESS + 4L, test_data);
1128 read = hpi_read_word(pdo,
1129 PLD_BASE_ADDRESS + 4L) &
mask;
1130 if (read != test_data) {
1140 #define PCI_TIMEOUT 100
1142 static int hpi_set_address(
struct dsp_obj *pdo,
u32 address)
1159 static void hpi_write_word(
struct dsp_obj *pdo,
u32 address,
u32 data)
1161 if (hpi_set_address(pdo, address))
1171 if (hpi_set_address(pdo, address))
1183 u16 length16 = length - 1;
1188 if (hpi_set_address(pdo, address))
1200 static void hpi_read_block(
struct dsp_obj *pdo,
u32 address,
u32 *pdata,
1203 u16 length16 = length - 1;
1208 if (hpi_set_address(pdo, address))
1224 int c6711_burst_size = 128;
1226 int local_count =
count;
1230 while (local_count) {
1231 if (local_count > c6711_burst_size)
1232 xfer_size = c6711_burst_size;
1234 xfer_size = local_count;
1238 hpi_write_block(pdo, local_hpi_address, pdata,
1240 }
while (hpi6000_check_PCI2040_error_flag(pao,
H6WRITE)
1246 local_hpi_address +=
sizeof(
u32) * xfer_size;
1247 local_count -= xfer_size;
1262 int c6711_burst_size = 16;
1264 int local_count =
count;
1269 while (local_count) {
1270 if (local_count > c6711_burst_size)
1271 xfer_size = c6711_burst_size;
1273 xfer_size = local_count;
1277 hpi_read_block(pdo, local_hpi_address, pdata,
1279 }
while (hpi6000_check_PCI2040_error_flag(pao,
H6READ)
1285 local_hpi_address +=
sizeof(
u32) * xfer_size;
1286 local_count -= xfer_size;
1296 static short hpi6000_message_response_sequence(
struct hpi_adapter_obj *pao,
1308 ack = hpi6000_wait_dsp_ack(pao, dsp_index,
HPI_HIF_IDLE);
1323 }
while (hpi6000_check_PCI2040_error_flag(pao,
H6READ)
1333 p_data = (
u32 *)phm;
1334 if (hpi6000_dsp_block_write32(pao, dsp_index, address, p_data,
1340 hpi6000_send_dsp_interrupt(pdo);
1343 if (ack & HPI_HIF_ERROR_MASK)
1353 }
while (hpi6000_check_PCI2040_error_flag(pao,
H6READ)
1366 }
while (hpi6000_check_PCI2040_error_flag(pao,
H6READ) && --timeout);
1371 p_data = (
u32 *)phr;
1372 if (hpi6000_dsp_block_read32(pao, dsp_index, address, p_data,
1377 if (hpi6000_send_host_command(pao, dsp_index,
HPI_HIF_IDLE))
1379 hpi6000_send_dsp_interrupt(pdo);
1387 #define MSG_ADDRESS (HPI_HIF_BASE+0x18)
1388 #define MSG_LENGTH 11
1389 #define RESP_ADDRESS (HPI_HIF_BASE+0x44)
1390 #define RESP_LENGTH 16
1391 #define QUEUE_START (HPI_HIF_BASE+0x88)
1392 #define QUEUE_SIZE 0x8000
1394 static short hpi6000_send_data_check_adr(
u32 address,
u32 length_in_dwords)
1402 if ((address + (length_in_dwords << 2)) >
1407 (
void)length_in_dwords;
1420 u32 *p_data = (
u32 *)phm->
u.
d.u.data.pb_data;
1426 while ((data_sent < (phm->
u.
d.u.data.data_size & ~3L))
1428 ack = hpi6000_wait_dsp_ack(pao, dsp_index,
HPI_HIF_IDLE);
1429 if (ack & HPI_HIF_ERROR_MASK)
1432 if (hpi6000_send_host_command(pao, dsp_index,
1436 hpi6000_send_dsp_interrupt(pdo);
1440 if (ack & HPI_HIF_ERROR_MASK)
1448 }
while (hpi6000_check_PCI2040_error_flag(pao,
H6READ));
1450 if (!hpi6000_send_data_check_adr(address, length))
1464 if (hpi6000_dsp_block_write32(pao, dsp_index,
1465 address, p_data, blk_len))
1467 address += blk_len * 4;
1473 if (hpi6000_send_host_command(pao, dsp_index,
HPI_HIF_IDLE))
1476 hpi6000_send_dsp_interrupt(pdo);
1478 data_sent += length * 4;
1493 u32 *p_data = (
u32 *)phm->
u.
d.u.data.pb_data;
1498 while (data_got < (phm->
u.
d.u.data.data_size & ~3L)) {
1499 ack = hpi6000_wait_dsp_ack(pao, dsp_index,
HPI_HIF_IDLE);
1500 if (ack & HPI_HIF_ERROR_MASK)
1503 if (hpi6000_send_host_command(pao, dsp_index,
1506 hpi6000_send_dsp_interrupt(pdo);
1510 if (ack & HPI_HIF_ERROR_MASK)
1517 }
while (hpi6000_check_PCI2040_error_flag(pao,
H6READ));
1526 if (hpi6000_dsp_block_read32(pao, dsp_index,
1527 address, p_data, blk_len))
1529 address += blk_len * 4;
1535 if (hpi6000_send_host_command(pao, dsp_index,
HPI_HIF_IDLE))
1537 hpi6000_send_dsp_interrupt(pdo);
1539 data_got += length * 4;
1544 static void hpi6000_send_dsp_interrupt(
struct dsp_obj *pdo)
1561 }
while (hpi6000_check_PCI2040_error_flag(pao,
H6WRITE) && --timeout);
1573 static short hpi6000_check_PCI2040_error_flag(
struct hpi_adapter_obj *pao,
1586 if (read_or_write == 1)
1587 gw_pci_read_asserts++;
1589 gw_pci_write_asserts++;
1619 if (ack == ack_value)
1621 if ((ack & HPI_HIF_ERROR_MASK)
1622 && !hpi6000_check_PCI2040_error_flag(pao,
H6READ))
1627 if (ack & HPI_HIF_ERROR_MASK)
1637 static short hpi6000_update_control_cache(
struct hpi_adapter_obj *pao,
1640 const u16 dsp_index = 0;
1644 u32 cache_dirty_flag;
1652 hpi_read_word((
struct dsp_obj *)pdo,
1654 }
while (hpi6000_check_PCI2040_error_flag(pao,
H6READ) && --timeout);
1660 if (cache_dirty_flag) {
1669 hpi_read_word((
struct dsp_obj *)pdo,
1672 length = hpi_read_word((
struct dsp_obj *)pdo,
1674 (control_cache_size_in_bytes));
1675 }
while (hpi6000_check_PCI2040_error_flag(pao,
H6READ)
1688 if (hpi6000_dsp_block_read32(pao, dsp_index, address,
1690 length /
sizeof(
u32))) {
1695 hpi_write_word((
struct dsp_obj *)pdo,
1699 }
while (hpi6000_check_PCI2040_error_flag(pao,
H6WRITE)
1747 dsp_index = get_dsp_index(pao, phm);
1755 hm.object = phm->
u.
d.u.stream.object_type;
1756 add_index = get_dsp_index(pao, &hm);
1757 if (add_index != dsp_index) {
1765 error = hpi6000_message_response_sequence(pao, dsp_index, phm, phr);
1776 error = hpi6000_send_data(pao, dsp_index, phm, phr);
1780 error = hpi6000_get_data(pao, dsp_index, phm, phr);
1787 error = hpi6000_message_response_sequence(pao,