1719f82d3SEliot Blennerhassett /****************************************************************************** 2719f82d3SEliot Blennerhassett 3719f82d3SEliot Blennerhassett AudioScience HPI driver 4719f82d3SEliot Blennerhassett Copyright (C) 1997-2010 AudioScience Inc. <support@audioscience.com> 5719f82d3SEliot Blennerhassett 6719f82d3SEliot Blennerhassett This program is free software; you can redistribute it and/or modify 7719f82d3SEliot Blennerhassett it under the terms of version 2 of the GNU General Public License as 8719f82d3SEliot Blennerhassett published by the Free Software Foundation; 9719f82d3SEliot Blennerhassett 10719f82d3SEliot Blennerhassett This program is distributed in the hope that it will be useful, 11719f82d3SEliot Blennerhassett but WITHOUT ANY WARRANTY; without even the implied warranty of 12719f82d3SEliot Blennerhassett MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13719f82d3SEliot Blennerhassett GNU General Public License for more details. 14719f82d3SEliot Blennerhassett 15719f82d3SEliot Blennerhassett You should have received a copy of the GNU General Public License 16719f82d3SEliot Blennerhassett along with this program; if not, write to the Free Software 17719f82d3SEliot Blennerhassett Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 18719f82d3SEliot Blennerhassett 19719f82d3SEliot Blennerhassett Hardware Programming Interface (HPI) for AudioScience 20719f82d3SEliot Blennerhassett ASI50xx, AS51xx, ASI6xxx, ASI87xx ASI89xx series adapters. 21719f82d3SEliot Blennerhassett These PCI and PCIe bus adapters are based on a 22719f82d3SEliot Blennerhassett TMS320C6205 PCI bus mastering DSP, 23719f82d3SEliot Blennerhassett and (except ASI50xx) TI TMS320C6xxx floating point DSP 24719f82d3SEliot Blennerhassett 25719f82d3SEliot Blennerhassett Exported function: 26719f82d3SEliot Blennerhassett void HPI_6205(struct hpi_message *phm, struct hpi_response *phr) 27719f82d3SEliot Blennerhassett 28719f82d3SEliot Blennerhassett (C) Copyright AudioScience Inc. 1998-2010 29719f82d3SEliot Blennerhassett *******************************************************************************/ 30719f82d3SEliot Blennerhassett #define SOURCEFILE_NAME "hpi6205.c" 31719f82d3SEliot Blennerhassett 32719f82d3SEliot Blennerhassett #include "hpi_internal.h" 33719f82d3SEliot Blennerhassett #include "hpimsginit.h" 34719f82d3SEliot Blennerhassett #include "hpidebug.h" 35719f82d3SEliot Blennerhassett #include "hpi6205.h" 36719f82d3SEliot Blennerhassett #include "hpidspcd.h" 37719f82d3SEliot Blennerhassett #include "hpicmn.h" 38719f82d3SEliot Blennerhassett 39719f82d3SEliot Blennerhassett /*****************************************************************************/ 40719f82d3SEliot Blennerhassett /* HPI6205 specific error codes */ 413285ea10SEliot Blennerhassett #define HPI6205_ERROR_BASE 1000 /* not actually used anywhere */ 423285ea10SEliot Blennerhassett 433285ea10SEliot Blennerhassett /* operational/messaging errors */ 443285ea10SEliot Blennerhassett #define HPI6205_ERROR_MSG_RESP_IDLE_TIMEOUT 1015 453285ea10SEliot Blennerhassett #define HPI6205_ERROR_MSG_RESP_TIMEOUT 1016 463285ea10SEliot Blennerhassett 473285ea10SEliot Blennerhassett /* initialization/bootload errors */ 48719f82d3SEliot Blennerhassett #define HPI6205_ERROR_6205_NO_IRQ 1002 49719f82d3SEliot Blennerhassett #define HPI6205_ERROR_6205_INIT_FAILED 1003 50719f82d3SEliot Blennerhassett #define HPI6205_ERROR_6205_REG 1006 51719f82d3SEliot Blennerhassett #define HPI6205_ERROR_6205_DSPPAGE 1007 52719f82d3SEliot Blennerhassett #define HPI6205_ERROR_C6713_HPIC 1009 53719f82d3SEliot Blennerhassett #define HPI6205_ERROR_C6713_HPIA 1010 54719f82d3SEliot Blennerhassett #define HPI6205_ERROR_C6713_PLL 1011 55719f82d3SEliot Blennerhassett #define HPI6205_ERROR_DSP_INTMEM 1012 56719f82d3SEliot Blennerhassett #define HPI6205_ERROR_DSP_EXTMEM 1013 57719f82d3SEliot Blennerhassett #define HPI6205_ERROR_DSP_PLD 1014 58719f82d3SEliot Blennerhassett #define HPI6205_ERROR_6205_EEPROM 1017 59719f82d3SEliot Blennerhassett #define HPI6205_ERROR_DSP_EMIF 1018 60719f82d3SEliot Blennerhassett 61719f82d3SEliot Blennerhassett /*****************************************************************************/ 62719f82d3SEliot Blennerhassett /* for C6205 PCI i/f */ 63719f82d3SEliot Blennerhassett /* Host Status Register (HSR) bitfields */ 64719f82d3SEliot Blennerhassett #define C6205_HSR_INTSRC 0x01 65719f82d3SEliot Blennerhassett #define C6205_HSR_INTAVAL 0x02 66719f82d3SEliot Blennerhassett #define C6205_HSR_INTAM 0x04 67719f82d3SEliot Blennerhassett #define C6205_HSR_CFGERR 0x08 68719f82d3SEliot Blennerhassett #define C6205_HSR_EEREAD 0x10 69719f82d3SEliot Blennerhassett /* Host-to-DSP Control Register (HDCR) bitfields */ 70719f82d3SEliot Blennerhassett #define C6205_HDCR_WARMRESET 0x01 71719f82d3SEliot Blennerhassett #define C6205_HDCR_DSPINT 0x02 72719f82d3SEliot Blennerhassett #define C6205_HDCR_PCIBOOT 0x04 73719f82d3SEliot Blennerhassett /* DSP Page Register (DSPP) bitfields, */ 74719f82d3SEliot Blennerhassett /* defines 4 Mbyte page that BAR0 points to */ 75719f82d3SEliot Blennerhassett #define C6205_DSPP_MAP1 0x400 76719f82d3SEliot Blennerhassett 77719f82d3SEliot Blennerhassett /* BAR0 maps to prefetchable 4 Mbyte memory block set by DSPP. 78719f82d3SEliot Blennerhassett * BAR1 maps to non-prefetchable 8 Mbyte memory block 79719f82d3SEliot Blennerhassett * of DSP memory mapped registers (starting at 0x01800000). 80719f82d3SEliot Blennerhassett * 0x01800000 is hardcoded in the PCI i/f, so that only the offset from this 81719f82d3SEliot Blennerhassett * needs to be added to the BAR1 base address set in the PCI config reg 82719f82d3SEliot Blennerhassett */ 83719f82d3SEliot Blennerhassett #define C6205_BAR1_PCI_IO_OFFSET (0x027FFF0L) 84719f82d3SEliot Blennerhassett #define C6205_BAR1_HSR (C6205_BAR1_PCI_IO_OFFSET) 85719f82d3SEliot Blennerhassett #define C6205_BAR1_HDCR (C6205_BAR1_PCI_IO_OFFSET+4) 86719f82d3SEliot Blennerhassett #define C6205_BAR1_DSPP (C6205_BAR1_PCI_IO_OFFSET+8) 87719f82d3SEliot Blennerhassett 88719f82d3SEliot Blennerhassett /* used to control LED (revA) and reset C6713 (revB) */ 89719f82d3SEliot Blennerhassett #define C6205_BAR0_TIMER1_CTL (0x01980000L) 90719f82d3SEliot Blennerhassett 91719f82d3SEliot Blennerhassett /* For first 6713 in CE1 space, using DA17,16,2 */ 92719f82d3SEliot Blennerhassett #define HPICL_ADDR 0x01400000L 93719f82d3SEliot Blennerhassett #define HPICH_ADDR 0x01400004L 94719f82d3SEliot Blennerhassett #define HPIAL_ADDR 0x01410000L 95719f82d3SEliot Blennerhassett #define HPIAH_ADDR 0x01410004L 96719f82d3SEliot Blennerhassett #define HPIDIL_ADDR 0x01420000L 97719f82d3SEliot Blennerhassett #define HPIDIH_ADDR 0x01420004L 98719f82d3SEliot Blennerhassett #define HPIDL_ADDR 0x01430000L 99719f82d3SEliot Blennerhassett #define HPIDH_ADDR 0x01430004L 100719f82d3SEliot Blennerhassett 101719f82d3SEliot Blennerhassett #define C6713_EMIF_GCTL 0x01800000 102719f82d3SEliot Blennerhassett #define C6713_EMIF_CE1 0x01800004 103719f82d3SEliot Blennerhassett #define C6713_EMIF_CE0 0x01800008 104719f82d3SEliot Blennerhassett #define C6713_EMIF_CE2 0x01800010 105719f82d3SEliot Blennerhassett #define C6713_EMIF_CE3 0x01800014 106719f82d3SEliot Blennerhassett #define C6713_EMIF_SDRAMCTL 0x01800018 107719f82d3SEliot Blennerhassett #define C6713_EMIF_SDRAMTIMING 0x0180001C 108719f82d3SEliot Blennerhassett #define C6713_EMIF_SDRAMEXT 0x01800020 109719f82d3SEliot Blennerhassett 110719f82d3SEliot Blennerhassett struct hpi_hw_obj { 111719f82d3SEliot Blennerhassett /* PCI registers */ 112719f82d3SEliot Blennerhassett __iomem u32 *prHSR; 113719f82d3SEliot Blennerhassett __iomem u32 *prHDCR; 114719f82d3SEliot Blennerhassett __iomem u32 *prDSPP; 115719f82d3SEliot Blennerhassett 116719f82d3SEliot Blennerhassett u32 dsp_page; 117719f82d3SEliot Blennerhassett 118719f82d3SEliot Blennerhassett struct consistent_dma_area h_locked_mem; 119719f82d3SEliot Blennerhassett struct bus_master_interface *p_interface_buffer; 120719f82d3SEliot Blennerhassett 121719f82d3SEliot Blennerhassett u16 flag_outstream_just_reset[HPI_MAX_STREAMS]; 122719f82d3SEliot Blennerhassett /* a non-NULL handle means there is an HPI allocated buffer */ 123719f82d3SEliot Blennerhassett struct consistent_dma_area instream_host_buffers[HPI_MAX_STREAMS]; 124719f82d3SEliot Blennerhassett struct consistent_dma_area outstream_host_buffers[HPI_MAX_STREAMS]; 125719f82d3SEliot Blennerhassett /* non-zero size means a buffer exists, may be external */ 126719f82d3SEliot Blennerhassett u32 instream_host_buffer_size[HPI_MAX_STREAMS]; 127719f82d3SEliot Blennerhassett u32 outstream_host_buffer_size[HPI_MAX_STREAMS]; 128719f82d3SEliot Blennerhassett 129719f82d3SEliot Blennerhassett struct consistent_dma_area h_control_cache; 130719f82d3SEliot Blennerhassett struct hpi_control_cache *p_cache; 131719f82d3SEliot Blennerhassett }; 132719f82d3SEliot Blennerhassett 133719f82d3SEliot Blennerhassett /*****************************************************************************/ 134719f82d3SEliot Blennerhassett /* local prototypes */ 135719f82d3SEliot Blennerhassett 136719f82d3SEliot Blennerhassett #define check_before_bbm_copy(status, p_bbm_data, l_first_write, l_second_write) 137719f82d3SEliot Blennerhassett 138719f82d3SEliot Blennerhassett static int wait_dsp_ack(struct hpi_hw_obj *phw, int state, int timeout_us); 139719f82d3SEliot Blennerhassett 140719f82d3SEliot Blennerhassett static void send_dsp_command(struct hpi_hw_obj *phw, int cmd); 141719f82d3SEliot Blennerhassett 142719f82d3SEliot Blennerhassett static u16 adapter_boot_load_dsp(struct hpi_adapter_obj *pao, 143719f82d3SEliot Blennerhassett u32 *pos_error_code); 144719f82d3SEliot Blennerhassett 145719f82d3SEliot Blennerhassett static u16 message_response_sequence(struct hpi_adapter_obj *pao, 146719f82d3SEliot Blennerhassett struct hpi_message *phm, struct hpi_response *phr); 147719f82d3SEliot Blennerhassett 148719f82d3SEliot Blennerhassett static void hw_message(struct hpi_adapter_obj *pao, struct hpi_message *phm, 149719f82d3SEliot Blennerhassett struct hpi_response *phr); 150719f82d3SEliot Blennerhassett 151719f82d3SEliot Blennerhassett #define HPI6205_TIMEOUT 1000000 152719f82d3SEliot Blennerhassett 153719f82d3SEliot Blennerhassett static void subsys_create_adapter(struct hpi_message *phm, 154719f82d3SEliot Blennerhassett struct hpi_response *phr); 155719f82d3SEliot Blennerhassett static void subsys_delete_adapter(struct hpi_message *phm, 156719f82d3SEliot Blennerhassett struct hpi_response *phr); 157719f82d3SEliot Blennerhassett 158719f82d3SEliot Blennerhassett static u16 create_adapter_obj(struct hpi_adapter_obj *pao, 159719f82d3SEliot Blennerhassett u32 *pos_error_code); 160719f82d3SEliot Blennerhassett 161719f82d3SEliot Blennerhassett static void delete_adapter_obj(struct hpi_adapter_obj *pao); 162719f82d3SEliot Blennerhassett 163719f82d3SEliot Blennerhassett static void outstream_host_buffer_allocate(struct hpi_adapter_obj *pao, 164719f82d3SEliot Blennerhassett struct hpi_message *phm, struct hpi_response *phr); 165719f82d3SEliot Blennerhassett 166719f82d3SEliot Blennerhassett static void outstream_host_buffer_get_info(struct hpi_adapter_obj *pao, 167719f82d3SEliot Blennerhassett struct hpi_message *phm, struct hpi_response *phr); 168719f82d3SEliot Blennerhassett 169719f82d3SEliot Blennerhassett static void outstream_host_buffer_free(struct hpi_adapter_obj *pao, 170719f82d3SEliot Blennerhassett struct hpi_message *phm, struct hpi_response *phr); 171719f82d3SEliot Blennerhassett static void outstream_write(struct hpi_adapter_obj *pao, 172719f82d3SEliot Blennerhassett struct hpi_message *phm, struct hpi_response *phr); 173719f82d3SEliot Blennerhassett 174719f82d3SEliot Blennerhassett static void outstream_get_info(struct hpi_adapter_obj *pao, 175719f82d3SEliot Blennerhassett struct hpi_message *phm, struct hpi_response *phr); 176719f82d3SEliot Blennerhassett 177719f82d3SEliot Blennerhassett static void outstream_start(struct hpi_adapter_obj *pao, 178719f82d3SEliot Blennerhassett struct hpi_message *phm, struct hpi_response *phr); 179719f82d3SEliot Blennerhassett 180719f82d3SEliot Blennerhassett static void outstream_open(struct hpi_adapter_obj *pao, 181719f82d3SEliot Blennerhassett struct hpi_message *phm, struct hpi_response *phr); 182719f82d3SEliot Blennerhassett 183719f82d3SEliot Blennerhassett static void outstream_reset(struct hpi_adapter_obj *pao, 184719f82d3SEliot Blennerhassett struct hpi_message *phm, struct hpi_response *phr); 185719f82d3SEliot Blennerhassett 186719f82d3SEliot Blennerhassett static void instream_host_buffer_allocate(struct hpi_adapter_obj *pao, 187719f82d3SEliot Blennerhassett struct hpi_message *phm, struct hpi_response *phr); 188719f82d3SEliot Blennerhassett 189719f82d3SEliot Blennerhassett static void instream_host_buffer_get_info(struct hpi_adapter_obj *pao, 190719f82d3SEliot Blennerhassett struct hpi_message *phm, struct hpi_response *phr); 191719f82d3SEliot Blennerhassett 192719f82d3SEliot Blennerhassett static void instream_host_buffer_free(struct hpi_adapter_obj *pao, 193719f82d3SEliot Blennerhassett struct hpi_message *phm, struct hpi_response *phr); 194719f82d3SEliot Blennerhassett 195719f82d3SEliot Blennerhassett static void instream_read(struct hpi_adapter_obj *pao, 196719f82d3SEliot Blennerhassett struct hpi_message *phm, struct hpi_response *phr); 197719f82d3SEliot Blennerhassett 198719f82d3SEliot Blennerhassett static void instream_get_info(struct hpi_adapter_obj *pao, 199719f82d3SEliot Blennerhassett struct hpi_message *phm, struct hpi_response *phr); 200719f82d3SEliot Blennerhassett 201719f82d3SEliot Blennerhassett static void instream_start(struct hpi_adapter_obj *pao, 202719f82d3SEliot Blennerhassett struct hpi_message *phm, struct hpi_response *phr); 203719f82d3SEliot Blennerhassett 204719f82d3SEliot Blennerhassett static u32 boot_loader_read_mem32(struct hpi_adapter_obj *pao, int dsp_index, 205719f82d3SEliot Blennerhassett u32 address); 206719f82d3SEliot Blennerhassett 2073285ea10SEliot Blennerhassett static void boot_loader_write_mem32(struct hpi_adapter_obj *pao, 2083285ea10SEliot Blennerhassett int dsp_index, u32 address, u32 data); 209719f82d3SEliot Blennerhassett 210719f82d3SEliot Blennerhassett static u16 boot_loader_config_emif(struct hpi_adapter_obj *pao, 211719f82d3SEliot Blennerhassett int dsp_index); 212719f82d3SEliot Blennerhassett 213719f82d3SEliot Blennerhassett static u16 boot_loader_test_memory(struct hpi_adapter_obj *pao, int dsp_index, 214719f82d3SEliot Blennerhassett u32 address, u32 length); 215719f82d3SEliot Blennerhassett 216719f82d3SEliot Blennerhassett static u16 boot_loader_test_internal_memory(struct hpi_adapter_obj *pao, 217719f82d3SEliot Blennerhassett int dsp_index); 218719f82d3SEliot Blennerhassett 219719f82d3SEliot Blennerhassett static u16 boot_loader_test_external_memory(struct hpi_adapter_obj *pao, 220719f82d3SEliot Blennerhassett int dsp_index); 221719f82d3SEliot Blennerhassett 222719f82d3SEliot Blennerhassett static u16 boot_loader_test_pld(struct hpi_adapter_obj *pao, int dsp_index); 223719f82d3SEliot Blennerhassett 224719f82d3SEliot Blennerhassett /*****************************************************************************/ 225719f82d3SEliot Blennerhassett 226719f82d3SEliot Blennerhassett static void subsys_message(struct hpi_message *phm, struct hpi_response *phr) 227719f82d3SEliot Blennerhassett { 228719f82d3SEliot Blennerhassett switch (phm->function) { 229719f82d3SEliot Blennerhassett case HPI_SUBSYS_CREATE_ADAPTER: 230719f82d3SEliot Blennerhassett subsys_create_adapter(phm, phr); 231719f82d3SEliot Blennerhassett break; 232719f82d3SEliot Blennerhassett case HPI_SUBSYS_DELETE_ADAPTER: 233719f82d3SEliot Blennerhassett subsys_delete_adapter(phm, phr); 234719f82d3SEliot Blennerhassett break; 235719f82d3SEliot Blennerhassett default: 236719f82d3SEliot Blennerhassett phr->error = HPI_ERROR_INVALID_FUNC; 237719f82d3SEliot Blennerhassett break; 238719f82d3SEliot Blennerhassett } 239719f82d3SEliot Blennerhassett } 240719f82d3SEliot Blennerhassett 241719f82d3SEliot Blennerhassett static void control_message(struct hpi_adapter_obj *pao, 242719f82d3SEliot Blennerhassett struct hpi_message *phm, struct hpi_response *phr) 243719f82d3SEliot Blennerhassett { 244719f82d3SEliot Blennerhassett 245719f82d3SEliot Blennerhassett struct hpi_hw_obj *phw = pao->priv; 2463285ea10SEliot Blennerhassett u16 pending_cache_error = 0; 247719f82d3SEliot Blennerhassett 248719f82d3SEliot Blennerhassett switch (phm->function) { 249719f82d3SEliot Blennerhassett case HPI_CONTROL_GET_STATE: 250719f82d3SEliot Blennerhassett if (pao->has_control_cache) { 2513285ea10SEliot Blennerhassett rmb(); /* make sure we see updates DMAed from DSP */ 2523285ea10SEliot Blennerhassett if (hpi_check_control_cache(phw->p_cache, phm, phr)) { 253719f82d3SEliot Blennerhassett break; 2543285ea10SEliot Blennerhassett } else if (phm->u.c.attribute == HPI_METER_PEAK) { 2553285ea10SEliot Blennerhassett pending_cache_error = 2563285ea10SEliot Blennerhassett HPI_ERROR_CONTROL_CACHING; 2573285ea10SEliot Blennerhassett } 258719f82d3SEliot Blennerhassett } 259719f82d3SEliot Blennerhassett hw_message(pao, phm, phr); 2603285ea10SEliot Blennerhassett if (pending_cache_error && !phr->error) 2613285ea10SEliot Blennerhassett phr->error = pending_cache_error; 262719f82d3SEliot Blennerhassett break; 263719f82d3SEliot Blennerhassett case HPI_CONTROL_GET_INFO: 264719f82d3SEliot Blennerhassett hw_message(pao, phm, phr); 265719f82d3SEliot Blennerhassett break; 266719f82d3SEliot Blennerhassett case HPI_CONTROL_SET_STATE: 267719f82d3SEliot Blennerhassett hw_message(pao, phm, phr); 268719f82d3SEliot Blennerhassett if (pao->has_control_cache) 2693285ea10SEliot Blennerhassett hpi_cmn_control_cache_sync_to_msg(phw->p_cache, phm, 2703285ea10SEliot Blennerhassett phr); 271719f82d3SEliot Blennerhassett break; 272719f82d3SEliot Blennerhassett default: 273719f82d3SEliot Blennerhassett phr->error = HPI_ERROR_INVALID_FUNC; 274719f82d3SEliot Blennerhassett break; 275719f82d3SEliot Blennerhassett } 276719f82d3SEliot Blennerhassett } 277719f82d3SEliot Blennerhassett 278719f82d3SEliot Blennerhassett static void adapter_message(struct hpi_adapter_obj *pao, 279719f82d3SEliot Blennerhassett struct hpi_message *phm, struct hpi_response *phr) 280719f82d3SEliot Blennerhassett { 281719f82d3SEliot Blennerhassett switch (phm->function) { 282719f82d3SEliot Blennerhassett default: 283719f82d3SEliot Blennerhassett hw_message(pao, phm, phr); 284719f82d3SEliot Blennerhassett break; 285719f82d3SEliot Blennerhassett } 286719f82d3SEliot Blennerhassett } 287719f82d3SEliot Blennerhassett 288719f82d3SEliot Blennerhassett static void outstream_message(struct hpi_adapter_obj *pao, 289719f82d3SEliot Blennerhassett struct hpi_message *phm, struct hpi_response *phr) 290719f82d3SEliot Blennerhassett { 291719f82d3SEliot Blennerhassett 292719f82d3SEliot Blennerhassett if (phm->obj_index >= HPI_MAX_STREAMS) { 293deb21a23SEliot Blennerhassett phr->error = HPI_ERROR_INVALID_OBJ_INDEX; 294719f82d3SEliot Blennerhassett HPI_DEBUG_LOG(WARNING, 2953285ea10SEliot Blennerhassett "Message referencing invalid stream %d " 296719f82d3SEliot Blennerhassett "on adapter index %d\n", phm->obj_index, 297719f82d3SEliot Blennerhassett phm->adapter_index); 298719f82d3SEliot Blennerhassett return; 299719f82d3SEliot Blennerhassett } 300719f82d3SEliot Blennerhassett 301719f82d3SEliot Blennerhassett switch (phm->function) { 302719f82d3SEliot Blennerhassett case HPI_OSTREAM_WRITE: 303719f82d3SEliot Blennerhassett outstream_write(pao, phm, phr); 304719f82d3SEliot Blennerhassett break; 305719f82d3SEliot Blennerhassett case HPI_OSTREAM_GET_INFO: 306719f82d3SEliot Blennerhassett outstream_get_info(pao, phm, phr); 307719f82d3SEliot Blennerhassett break; 308719f82d3SEliot Blennerhassett case HPI_OSTREAM_HOSTBUFFER_ALLOC: 309719f82d3SEliot Blennerhassett outstream_host_buffer_allocate(pao, phm, phr); 310719f82d3SEliot Blennerhassett break; 311719f82d3SEliot Blennerhassett case HPI_OSTREAM_HOSTBUFFER_GET_INFO: 312719f82d3SEliot Blennerhassett outstream_host_buffer_get_info(pao, phm, phr); 313719f82d3SEliot Blennerhassett break; 314719f82d3SEliot Blennerhassett case HPI_OSTREAM_HOSTBUFFER_FREE: 315719f82d3SEliot Blennerhassett outstream_host_buffer_free(pao, phm, phr); 316719f82d3SEliot Blennerhassett break; 317719f82d3SEliot Blennerhassett case HPI_OSTREAM_START: 318719f82d3SEliot Blennerhassett outstream_start(pao, phm, phr); 319719f82d3SEliot Blennerhassett break; 320719f82d3SEliot Blennerhassett case HPI_OSTREAM_OPEN: 321719f82d3SEliot Blennerhassett outstream_open(pao, phm, phr); 322719f82d3SEliot Blennerhassett break; 323719f82d3SEliot Blennerhassett case HPI_OSTREAM_RESET: 324719f82d3SEliot Blennerhassett outstream_reset(pao, phm, phr); 325719f82d3SEliot Blennerhassett break; 326719f82d3SEliot Blennerhassett default: 327719f82d3SEliot Blennerhassett hw_message(pao, phm, phr); 328719f82d3SEliot Blennerhassett break; 329719f82d3SEliot Blennerhassett } 330719f82d3SEliot Blennerhassett } 331719f82d3SEliot Blennerhassett 332719f82d3SEliot Blennerhassett static void instream_message(struct hpi_adapter_obj *pao, 333719f82d3SEliot Blennerhassett struct hpi_message *phm, struct hpi_response *phr) 334719f82d3SEliot Blennerhassett { 335719f82d3SEliot Blennerhassett 336719f82d3SEliot Blennerhassett if (phm->obj_index >= HPI_MAX_STREAMS) { 337deb21a23SEliot Blennerhassett phr->error = HPI_ERROR_INVALID_OBJ_INDEX; 338719f82d3SEliot Blennerhassett HPI_DEBUG_LOG(WARNING, 3393285ea10SEliot Blennerhassett "Message referencing invalid stream %d " 340719f82d3SEliot Blennerhassett "on adapter index %d\n", phm->obj_index, 341719f82d3SEliot Blennerhassett phm->adapter_index); 342719f82d3SEliot Blennerhassett return; 343719f82d3SEliot Blennerhassett } 344719f82d3SEliot Blennerhassett 345719f82d3SEliot Blennerhassett switch (phm->function) { 346719f82d3SEliot Blennerhassett case HPI_ISTREAM_READ: 347719f82d3SEliot Blennerhassett instream_read(pao, phm, phr); 348719f82d3SEliot Blennerhassett break; 349719f82d3SEliot Blennerhassett case HPI_ISTREAM_GET_INFO: 350719f82d3SEliot Blennerhassett instream_get_info(pao, phm, phr); 351719f82d3SEliot Blennerhassett break; 352719f82d3SEliot Blennerhassett case HPI_ISTREAM_HOSTBUFFER_ALLOC: 353719f82d3SEliot Blennerhassett instream_host_buffer_allocate(pao, phm, phr); 354719f82d3SEliot Blennerhassett break; 355719f82d3SEliot Blennerhassett case HPI_ISTREAM_HOSTBUFFER_GET_INFO: 356719f82d3SEliot Blennerhassett instream_host_buffer_get_info(pao, phm, phr); 357719f82d3SEliot Blennerhassett break; 358719f82d3SEliot Blennerhassett case HPI_ISTREAM_HOSTBUFFER_FREE: 359719f82d3SEliot Blennerhassett instream_host_buffer_free(pao, phm, phr); 360719f82d3SEliot Blennerhassett break; 361719f82d3SEliot Blennerhassett case HPI_ISTREAM_START: 362719f82d3SEliot Blennerhassett instream_start(pao, phm, phr); 363719f82d3SEliot Blennerhassett break; 364719f82d3SEliot Blennerhassett default: 365719f82d3SEliot Blennerhassett hw_message(pao, phm, phr); 366719f82d3SEliot Blennerhassett break; 367719f82d3SEliot Blennerhassett } 368719f82d3SEliot Blennerhassett } 369719f82d3SEliot Blennerhassett 370719f82d3SEliot Blennerhassett /*****************************************************************************/ 371719f82d3SEliot Blennerhassett /** Entry point to this HPI backend 372719f82d3SEliot Blennerhassett * All calls to the HPI start here 373719f82d3SEliot Blennerhassett */ 374719f82d3SEliot Blennerhassett void HPI_6205(struct hpi_message *phm, struct hpi_response *phr) 375719f82d3SEliot Blennerhassett { 376719f82d3SEliot Blennerhassett struct hpi_adapter_obj *pao = NULL; 377719f82d3SEliot Blennerhassett 378719f82d3SEliot Blennerhassett /* subsytem messages are processed by every HPI. 379719f82d3SEliot Blennerhassett * All other messages are ignored unless the adapter index matches 380719f82d3SEliot Blennerhassett * an adapter in the HPI 381719f82d3SEliot Blennerhassett */ 3823285ea10SEliot Blennerhassett /* HPI_DEBUG_LOG(DEBUG, "HPI Obj=%d, Func=%d\n", phm->wObject, 3833285ea10SEliot Blennerhassett phm->wFunction); */ 384719f82d3SEliot Blennerhassett 385719f82d3SEliot Blennerhassett /* if Dsp has crashed then do not communicate with it any more */ 386719f82d3SEliot Blennerhassett if (phm->object != HPI_OBJ_SUBSYSTEM) { 387719f82d3SEliot Blennerhassett pao = hpi_find_adapter(phm->adapter_index); 388719f82d3SEliot Blennerhassett if (!pao) { 389719f82d3SEliot Blennerhassett HPI_DEBUG_LOG(DEBUG, 390719f82d3SEliot Blennerhassett " %d,%d refused, for another HPI?\n", 391719f82d3SEliot Blennerhassett phm->object, phm->function); 392719f82d3SEliot Blennerhassett return; 393719f82d3SEliot Blennerhassett } 394719f82d3SEliot Blennerhassett 395719f82d3SEliot Blennerhassett if ((pao->dsp_crashed >= 10) 396719f82d3SEliot Blennerhassett && (phm->function != HPI_ADAPTER_DEBUG_READ)) { 397719f82d3SEliot Blennerhassett /* allow last resort debug read even after crash */ 398719f82d3SEliot Blennerhassett hpi_init_response(phr, phm->object, phm->function, 399719f82d3SEliot Blennerhassett HPI_ERROR_DSP_HARDWARE); 400719f82d3SEliot Blennerhassett HPI_DEBUG_LOG(WARNING, " %d,%d dsp crashed.\n", 401719f82d3SEliot Blennerhassett phm->object, phm->function); 402719f82d3SEliot Blennerhassett return; 403719f82d3SEliot Blennerhassett } 404719f82d3SEliot Blennerhassett } 405719f82d3SEliot Blennerhassett 406719f82d3SEliot Blennerhassett /* Init default response */ 407719f82d3SEliot Blennerhassett if (phm->function != HPI_SUBSYS_CREATE_ADAPTER) 4083285ea10SEliot Blennerhassett phr->error = HPI_ERROR_PROCESSING_MESSAGE; 409719f82d3SEliot Blennerhassett 410719f82d3SEliot Blennerhassett HPI_DEBUG_LOG(VERBOSE, "start of switch\n"); 411719f82d3SEliot Blennerhassett switch (phm->type) { 412719f82d3SEliot Blennerhassett case HPI_TYPE_MESSAGE: 413719f82d3SEliot Blennerhassett switch (phm->object) { 414719f82d3SEliot Blennerhassett case HPI_OBJ_SUBSYSTEM: 415719f82d3SEliot Blennerhassett subsys_message(phm, phr); 416719f82d3SEliot Blennerhassett break; 417719f82d3SEliot Blennerhassett 418719f82d3SEliot Blennerhassett case HPI_OBJ_ADAPTER: 419719f82d3SEliot Blennerhassett adapter_message(pao, phm, phr); 420719f82d3SEliot Blennerhassett break; 421719f82d3SEliot Blennerhassett 422719f82d3SEliot Blennerhassett case HPI_OBJ_CONTROLEX: 423719f82d3SEliot Blennerhassett case HPI_OBJ_CONTROL: 424719f82d3SEliot Blennerhassett control_message(pao, phm, phr); 425719f82d3SEliot Blennerhassett break; 426719f82d3SEliot Blennerhassett 427719f82d3SEliot Blennerhassett case HPI_OBJ_OSTREAM: 428719f82d3SEliot Blennerhassett outstream_message(pao, phm, phr); 429719f82d3SEliot Blennerhassett break; 430719f82d3SEliot Blennerhassett 431719f82d3SEliot Blennerhassett case HPI_OBJ_ISTREAM: 432719f82d3SEliot Blennerhassett instream_message(pao, phm, phr); 433719f82d3SEliot Blennerhassett break; 434719f82d3SEliot Blennerhassett 435719f82d3SEliot Blennerhassett default: 436719f82d3SEliot Blennerhassett hw_message(pao, phm, phr); 437719f82d3SEliot Blennerhassett break; 438719f82d3SEliot Blennerhassett } 439719f82d3SEliot Blennerhassett break; 440719f82d3SEliot Blennerhassett 441719f82d3SEliot Blennerhassett default: 442719f82d3SEliot Blennerhassett phr->error = HPI_ERROR_INVALID_TYPE; 443719f82d3SEliot Blennerhassett break; 444719f82d3SEliot Blennerhassett } 445719f82d3SEliot Blennerhassett } 446719f82d3SEliot Blennerhassett 447719f82d3SEliot Blennerhassett /*****************************************************************************/ 448719f82d3SEliot Blennerhassett /* SUBSYSTEM */ 449719f82d3SEliot Blennerhassett 450719f82d3SEliot Blennerhassett /** Create an adapter object and initialise it based on resource information 451719f82d3SEliot Blennerhassett * passed in in the message 452719f82d3SEliot Blennerhassett * *** NOTE - you cannot use this function AND the FindAdapters function at the 453719f82d3SEliot Blennerhassett * same time, the application must use only one of them to get the adapters *** 454719f82d3SEliot Blennerhassett */ 455719f82d3SEliot Blennerhassett static void subsys_create_adapter(struct hpi_message *phm, 456719f82d3SEliot Blennerhassett struct hpi_response *phr) 457719f82d3SEliot Blennerhassett { 458719f82d3SEliot Blennerhassett /* create temp adapter obj, because we don't know what index yet */ 459719f82d3SEliot Blennerhassett struct hpi_adapter_obj ao; 460719f82d3SEliot Blennerhassett u32 os_error_code; 461719f82d3SEliot Blennerhassett u16 err; 462719f82d3SEliot Blennerhassett 463719f82d3SEliot Blennerhassett HPI_DEBUG_LOG(DEBUG, " subsys_create_adapter\n"); 464719f82d3SEliot Blennerhassett 465719f82d3SEliot Blennerhassett memset(&ao, 0, sizeof(ao)); 466719f82d3SEliot Blennerhassett 467550a8b69SJulia Lawall ao.priv = kzalloc(sizeof(struct hpi_hw_obj), GFP_KERNEL); 468719f82d3SEliot Blennerhassett if (!ao.priv) { 469719f82d3SEliot Blennerhassett HPI_DEBUG_LOG(ERROR, "cant get mem for adapter object\n"); 470719f82d3SEliot Blennerhassett phr->error = HPI_ERROR_MEMORY_ALLOC; 471719f82d3SEliot Blennerhassett return; 472719f82d3SEliot Blennerhassett } 473719f82d3SEliot Blennerhassett 474719f82d3SEliot Blennerhassett ao.pci = *phm->u.s.resource.r.pci; 475719f82d3SEliot Blennerhassett err = create_adapter_obj(&ao, &os_error_code); 476719f82d3SEliot Blennerhassett if (err) { 477719f82d3SEliot Blennerhassett delete_adapter_obj(&ao); 4780a00044dSEliot Blennerhassett if (err >= HPI_ERROR_BACKEND_BASE) { 4790a00044dSEliot Blennerhassett phr->error = HPI_ERROR_DSP_BOOTLOAD; 4800a00044dSEliot Blennerhassett phr->specific_error = err; 4810a00044dSEliot Blennerhassett } else { 482719f82d3SEliot Blennerhassett phr->error = err; 4830a00044dSEliot Blennerhassett } 4843285ea10SEliot Blennerhassett phr->u.s.data = os_error_code; 485719f82d3SEliot Blennerhassett return; 486719f82d3SEliot Blennerhassett } 487719f82d3SEliot Blennerhassett 4882f918a64SEliot Blennerhassett phr->u.s.adapter_type = ao.adapter_type; 489719f82d3SEliot Blennerhassett phr->u.s.adapter_index = ao.index; 490719f82d3SEliot Blennerhassett phr->error = 0; 491719f82d3SEliot Blennerhassett } 492719f82d3SEliot Blennerhassett 493719f82d3SEliot Blennerhassett /** delete an adapter - required by WDM driver */ 494719f82d3SEliot Blennerhassett static void subsys_delete_adapter(struct hpi_message *phm, 495719f82d3SEliot Blennerhassett struct hpi_response *phr) 496719f82d3SEliot Blennerhassett { 497719f82d3SEliot Blennerhassett struct hpi_adapter_obj *pao; 498719f82d3SEliot Blennerhassett struct hpi_hw_obj *phw; 499719f82d3SEliot Blennerhassett 5003285ea10SEliot Blennerhassett pao = hpi_find_adapter(phm->obj_index); 501719f82d3SEliot Blennerhassett if (!pao) { 502719f82d3SEliot Blennerhassett phr->error = HPI_ERROR_INVALID_OBJ_INDEX; 503719f82d3SEliot Blennerhassett return; 504719f82d3SEliot Blennerhassett } 505719f82d3SEliot Blennerhassett phw = (struct hpi_hw_obj *)pao->priv; 506719f82d3SEliot Blennerhassett /* reset adapter h/w */ 507719f82d3SEliot Blennerhassett /* Reset C6713 #1 */ 508719f82d3SEliot Blennerhassett boot_loader_write_mem32(pao, 0, C6205_BAR0_TIMER1_CTL, 0); 509719f82d3SEliot Blennerhassett /* reset C6205 */ 510719f82d3SEliot Blennerhassett iowrite32(C6205_HDCR_WARMRESET, phw->prHDCR); 511719f82d3SEliot Blennerhassett 512719f82d3SEliot Blennerhassett delete_adapter_obj(pao); 5133285ea10SEliot Blennerhassett hpi_delete_adapter(pao); 514719f82d3SEliot Blennerhassett phr->error = 0; 515719f82d3SEliot Blennerhassett } 516719f82d3SEliot Blennerhassett 517719f82d3SEliot Blennerhassett /** Create adapter object 518719f82d3SEliot Blennerhassett allocate buffers, bootload DSPs, initialise control cache 519719f82d3SEliot Blennerhassett */ 520719f82d3SEliot Blennerhassett static u16 create_adapter_obj(struct hpi_adapter_obj *pao, 521719f82d3SEliot Blennerhassett u32 *pos_error_code) 522719f82d3SEliot Blennerhassett { 523719f82d3SEliot Blennerhassett struct hpi_hw_obj *phw = pao->priv; 524719f82d3SEliot Blennerhassett struct bus_master_interface *interface; 525719f82d3SEliot Blennerhassett u32 phys_addr; 526719f82d3SEliot Blennerhassett int i; 527719f82d3SEliot Blennerhassett u16 err; 528719f82d3SEliot Blennerhassett 529719f82d3SEliot Blennerhassett /* init error reporting */ 530719f82d3SEliot Blennerhassett pao->dsp_crashed = 0; 531719f82d3SEliot Blennerhassett 532719f82d3SEliot Blennerhassett for (i = 0; i < HPI_MAX_STREAMS; i++) 533719f82d3SEliot Blennerhassett phw->flag_outstream_just_reset[i] = 1; 534719f82d3SEliot Blennerhassett 535719f82d3SEliot Blennerhassett /* The C6205 memory area 1 is 8Mbyte window into DSP registers */ 536719f82d3SEliot Blennerhassett phw->prHSR = 537719f82d3SEliot Blennerhassett pao->pci.ap_mem_base[1] + 538719f82d3SEliot Blennerhassett C6205_BAR1_HSR / sizeof(*pao->pci.ap_mem_base[1]); 539719f82d3SEliot Blennerhassett phw->prHDCR = 540719f82d3SEliot Blennerhassett pao->pci.ap_mem_base[1] + 541719f82d3SEliot Blennerhassett C6205_BAR1_HDCR / sizeof(*pao->pci.ap_mem_base[1]); 542719f82d3SEliot Blennerhassett phw->prDSPP = 543719f82d3SEliot Blennerhassett pao->pci.ap_mem_base[1] + 544719f82d3SEliot Blennerhassett C6205_BAR1_DSPP / sizeof(*pao->pci.ap_mem_base[1]); 545719f82d3SEliot Blennerhassett 546719f82d3SEliot Blennerhassett pao->has_control_cache = 0; 547719f82d3SEliot Blennerhassett 548719f82d3SEliot Blennerhassett if (hpios_locked_mem_alloc(&phw->h_locked_mem, 549719f82d3SEliot Blennerhassett sizeof(struct bus_master_interface), 5503285ea10SEliot Blennerhassett pao->pci.pci_dev)) 551719f82d3SEliot Blennerhassett phw->p_interface_buffer = NULL; 552719f82d3SEliot Blennerhassett else if (hpios_locked_mem_get_virt_addr(&phw->h_locked_mem, 553719f82d3SEliot Blennerhassett (void *)&phw->p_interface_buffer)) 554719f82d3SEliot Blennerhassett phw->p_interface_buffer = NULL; 555719f82d3SEliot Blennerhassett 556719f82d3SEliot Blennerhassett HPI_DEBUG_LOG(DEBUG, "interface buffer address %p\n", 557719f82d3SEliot Blennerhassett phw->p_interface_buffer); 558719f82d3SEliot Blennerhassett 559719f82d3SEliot Blennerhassett if (phw->p_interface_buffer) { 560719f82d3SEliot Blennerhassett memset((void *)phw->p_interface_buffer, 0, 561719f82d3SEliot Blennerhassett sizeof(struct bus_master_interface)); 562719f82d3SEliot Blennerhassett phw->p_interface_buffer->dsp_ack = H620_HIF_UNKNOWN; 563719f82d3SEliot Blennerhassett } 564719f82d3SEliot Blennerhassett 565719f82d3SEliot Blennerhassett err = adapter_boot_load_dsp(pao, pos_error_code); 566719f82d3SEliot Blennerhassett if (err) 567719f82d3SEliot Blennerhassett /* no need to clean up as SubSysCreateAdapter */ 568719f82d3SEliot Blennerhassett /* calls DeleteAdapter on error. */ 569719f82d3SEliot Blennerhassett return err; 570719f82d3SEliot Blennerhassett 571719f82d3SEliot Blennerhassett HPI_DEBUG_LOG(INFO, "load DSP code OK\n"); 572719f82d3SEliot Blennerhassett 573719f82d3SEliot Blennerhassett /* allow boot load even if mem alloc wont work */ 574719f82d3SEliot Blennerhassett if (!phw->p_interface_buffer) 5753285ea10SEliot Blennerhassett return HPI_ERROR_MEMORY_ALLOC; 576719f82d3SEliot Blennerhassett 577719f82d3SEliot Blennerhassett interface = phw->p_interface_buffer; 578719f82d3SEliot Blennerhassett 579719f82d3SEliot Blennerhassett /* make sure the DSP has started ok */ 580719f82d3SEliot Blennerhassett if (!wait_dsp_ack(phw, H620_HIF_RESET, HPI6205_TIMEOUT * 10)) { 581719f82d3SEliot Blennerhassett HPI_DEBUG_LOG(ERROR, "timed out waiting reset state \n"); 5823285ea10SEliot Blennerhassett return HPI6205_ERROR_6205_INIT_FAILED; 583719f82d3SEliot Blennerhassett } 584719f82d3SEliot Blennerhassett /* Note that *pao, *phw are zeroed after allocation, 585719f82d3SEliot Blennerhassett * so pointers and flags are NULL by default. 586719f82d3SEliot Blennerhassett * Allocate bus mastering control cache buffer and tell the DSP about it 587719f82d3SEliot Blennerhassett */ 588719f82d3SEliot Blennerhassett if (interface->control_cache.number_of_controls) { 5893285ea10SEliot Blennerhassett u8 *p_control_cache_virtual; 590719f82d3SEliot Blennerhassett 591719f82d3SEliot Blennerhassett err = hpios_locked_mem_alloc(&phw->h_control_cache, 592719f82d3SEliot Blennerhassett interface->control_cache.size_in_bytes, 5933285ea10SEliot Blennerhassett pao->pci.pci_dev); 594719f82d3SEliot Blennerhassett if (!err) 595719f82d3SEliot Blennerhassett err = hpios_locked_mem_get_virt_addr(&phw-> 5963285ea10SEliot Blennerhassett h_control_cache, 5973285ea10SEliot Blennerhassett (void *)&p_control_cache_virtual); 598719f82d3SEliot Blennerhassett if (!err) { 599719f82d3SEliot Blennerhassett memset(p_control_cache_virtual, 0, 600719f82d3SEliot Blennerhassett interface->control_cache.size_in_bytes); 601719f82d3SEliot Blennerhassett 602719f82d3SEliot Blennerhassett phw->p_cache = 603719f82d3SEliot Blennerhassett hpi_alloc_control_cache(interface-> 604719f82d3SEliot Blennerhassett control_cache.number_of_controls, 605719f82d3SEliot Blennerhassett interface->control_cache.size_in_bytes, 606719f82d3SEliot Blennerhassett p_control_cache_virtual); 607fd0977d0SJesper Juhl if (!phw->p_cache) 608fd0977d0SJesper Juhl err = HPI_ERROR_MEMORY_ALLOC; 609719f82d3SEliot Blennerhassett } 610719f82d3SEliot Blennerhassett if (!err) { 611719f82d3SEliot Blennerhassett err = hpios_locked_mem_get_phys_addr(&phw-> 612719f82d3SEliot Blennerhassett h_control_cache, &phys_addr); 613719f82d3SEliot Blennerhassett interface->control_cache.physical_address32 = 614719f82d3SEliot Blennerhassett phys_addr; 615719f82d3SEliot Blennerhassett } 616719f82d3SEliot Blennerhassett 617719f82d3SEliot Blennerhassett if (!err) 618719f82d3SEliot Blennerhassett pao->has_control_cache = 1; 619719f82d3SEliot Blennerhassett else { 620719f82d3SEliot Blennerhassett if (hpios_locked_mem_valid(&phw->h_control_cache)) 621719f82d3SEliot Blennerhassett hpios_locked_mem_free(&phw->h_control_cache); 622719f82d3SEliot Blennerhassett pao->has_control_cache = 0; 623719f82d3SEliot Blennerhassett } 624719f82d3SEliot Blennerhassett } 625719f82d3SEliot Blennerhassett send_dsp_command(phw, H620_HIF_IDLE); 626719f82d3SEliot Blennerhassett 627719f82d3SEliot Blennerhassett { 6283285ea10SEliot Blennerhassett struct hpi_message hm; 6293285ea10SEliot Blennerhassett struct hpi_response hr; 630719f82d3SEliot Blennerhassett u32 max_streams; 631719f82d3SEliot Blennerhassett 632719f82d3SEliot Blennerhassett HPI_DEBUG_LOG(VERBOSE, "init ADAPTER_GET_INFO\n"); 6333285ea10SEliot Blennerhassett memset(&hm, 0, sizeof(hm)); 6343285ea10SEliot Blennerhassett hm.type = HPI_TYPE_MESSAGE; 6353285ea10SEliot Blennerhassett hm.size = sizeof(hm); 6363285ea10SEliot Blennerhassett hm.object = HPI_OBJ_ADAPTER; 6373285ea10SEliot Blennerhassett hm.function = HPI_ADAPTER_GET_INFO; 6383285ea10SEliot Blennerhassett hm.adapter_index = 0; 6393285ea10SEliot Blennerhassett memset(&hr, 0, sizeof(hr)); 6403285ea10SEliot Blennerhassett hr.size = sizeof(hr); 641719f82d3SEliot Blennerhassett 6423285ea10SEliot Blennerhassett err = message_response_sequence(pao, &hm, &hr); 643719f82d3SEliot Blennerhassett if (err) { 644719f82d3SEliot Blennerhassett HPI_DEBUG_LOG(ERROR, "message transport error %d\n", 645719f82d3SEliot Blennerhassett err); 646719f82d3SEliot Blennerhassett return err; 647719f82d3SEliot Blennerhassett } 6483285ea10SEliot Blennerhassett if (hr.error) 6493285ea10SEliot Blennerhassett return hr.error; 650719f82d3SEliot Blennerhassett 6513285ea10SEliot Blennerhassett pao->adapter_type = hr.u.ax.info.adapter_type; 6523285ea10SEliot Blennerhassett pao->index = hr.u.ax.info.adapter_index; 653719f82d3SEliot Blennerhassett 6543285ea10SEliot Blennerhassett max_streams = 6553285ea10SEliot Blennerhassett hr.u.ax.info.num_outstreams + 6563285ea10SEliot Blennerhassett hr.u.ax.info.num_instreams; 657719f82d3SEliot Blennerhassett 658719f82d3SEliot Blennerhassett hpios_locked_mem_prepare((max_streams * 6) / 10, max_streams, 6593285ea10SEliot Blennerhassett 65536, pao->pci.pci_dev); 660719f82d3SEliot Blennerhassett 661719f82d3SEliot Blennerhassett HPI_DEBUG_LOG(VERBOSE, 662719f82d3SEliot Blennerhassett "got adapter info type %x index %d serial %d\n", 6633285ea10SEliot Blennerhassett hr.u.ax.info.adapter_type, hr.u.ax.info.adapter_index, 6643285ea10SEliot Blennerhassett hr.u.ax.info.serial_number); 665719f82d3SEliot Blennerhassett } 666719f82d3SEliot Blennerhassett 667719f82d3SEliot Blennerhassett pao->open = 0; /* upon creation the adapter is closed */ 668719f82d3SEliot Blennerhassett 669ffdb5787SEliot Blennerhassett if (phw->p_cache) 670ffdb5787SEliot Blennerhassett phw->p_cache->adap_idx = pao->index; 671ffdb5787SEliot Blennerhassett 672719f82d3SEliot Blennerhassett HPI_DEBUG_LOG(INFO, "bootload DSP OK\n"); 6733285ea10SEliot Blennerhassett 6743285ea10SEliot Blennerhassett return hpi_add_adapter(pao); 675719f82d3SEliot Blennerhassett } 676719f82d3SEliot Blennerhassett 677719f82d3SEliot Blennerhassett /** Free memory areas allocated by adapter 678719f82d3SEliot Blennerhassett * this routine is called from SubSysDeleteAdapter, 679719f82d3SEliot Blennerhassett * and SubSysCreateAdapter if duplicate index 680719f82d3SEliot Blennerhassett */ 681719f82d3SEliot Blennerhassett static void delete_adapter_obj(struct hpi_adapter_obj *pao) 682719f82d3SEliot Blennerhassett { 683719f82d3SEliot Blennerhassett struct hpi_hw_obj *phw; 684719f82d3SEliot Blennerhassett int i; 685719f82d3SEliot Blennerhassett 686719f82d3SEliot Blennerhassett phw = pao->priv; 687719f82d3SEliot Blennerhassett 688719f82d3SEliot Blennerhassett if (hpios_locked_mem_valid(&phw->h_control_cache)) { 689719f82d3SEliot Blennerhassett hpios_locked_mem_free(&phw->h_control_cache); 690719f82d3SEliot Blennerhassett hpi_free_control_cache(phw->p_cache); 691719f82d3SEliot Blennerhassett } 692719f82d3SEliot Blennerhassett 693719f82d3SEliot Blennerhassett if (hpios_locked_mem_valid(&phw->h_locked_mem)) { 694719f82d3SEliot Blennerhassett hpios_locked_mem_free(&phw->h_locked_mem); 695719f82d3SEliot Blennerhassett phw->p_interface_buffer = NULL; 696719f82d3SEliot Blennerhassett } 697719f82d3SEliot Blennerhassett 698719f82d3SEliot Blennerhassett for (i = 0; i < HPI_MAX_STREAMS; i++) 699719f82d3SEliot Blennerhassett if (hpios_locked_mem_valid(&phw->instream_host_buffers[i])) { 700719f82d3SEliot Blennerhassett hpios_locked_mem_free(&phw->instream_host_buffers[i]); 701719f82d3SEliot Blennerhassett /*?phw->InStreamHostBuffers[i] = NULL; */ 702719f82d3SEliot Blennerhassett phw->instream_host_buffer_size[i] = 0; 703719f82d3SEliot Blennerhassett } 704719f82d3SEliot Blennerhassett 705719f82d3SEliot Blennerhassett for (i = 0; i < HPI_MAX_STREAMS; i++) 706719f82d3SEliot Blennerhassett if (hpios_locked_mem_valid(&phw->outstream_host_buffers[i])) { 707719f82d3SEliot Blennerhassett hpios_locked_mem_free(&phw->outstream_host_buffers 708719f82d3SEliot Blennerhassett [i]); 709719f82d3SEliot Blennerhassett phw->outstream_host_buffer_size[i] = 0; 710719f82d3SEliot Blennerhassett } 711719f82d3SEliot Blennerhassett 7123285ea10SEliot Blennerhassett hpios_locked_mem_unprepare(pao->pci.pci_dev); 713719f82d3SEliot Blennerhassett 714719f82d3SEliot Blennerhassett kfree(phw); 715719f82d3SEliot Blennerhassett } 716719f82d3SEliot Blennerhassett 717719f82d3SEliot Blennerhassett /*****************************************************************************/ 7181d595d2aSEliot Blennerhassett /* Adapter functions */ 7191d595d2aSEliot Blennerhassett 7201d595d2aSEliot Blennerhassett /*****************************************************************************/ 721719f82d3SEliot Blennerhassett /* OutStream Host buffer functions */ 722719f82d3SEliot Blennerhassett 723719f82d3SEliot Blennerhassett /** Allocate or attach buffer for busmastering 724719f82d3SEliot Blennerhassett */ 725719f82d3SEliot Blennerhassett static void outstream_host_buffer_allocate(struct hpi_adapter_obj *pao, 726719f82d3SEliot Blennerhassett struct hpi_message *phm, struct hpi_response *phr) 727719f82d3SEliot Blennerhassett { 728719f82d3SEliot Blennerhassett u16 err = 0; 729719f82d3SEliot Blennerhassett u32 command = phm->u.d.u.buffer.command; 730719f82d3SEliot Blennerhassett struct hpi_hw_obj *phw = pao->priv; 731719f82d3SEliot Blennerhassett struct bus_master_interface *interface = phw->p_interface_buffer; 732719f82d3SEliot Blennerhassett 733719f82d3SEliot Blennerhassett hpi_init_response(phr, phm->object, phm->function, 0); 734719f82d3SEliot Blennerhassett 735719f82d3SEliot Blennerhassett if (command == HPI_BUFFER_CMD_EXTERNAL 736719f82d3SEliot Blennerhassett || command == HPI_BUFFER_CMD_INTERNAL_ALLOC) { 737719f82d3SEliot Blennerhassett /* ALLOC phase, allocate a buffer with power of 2 size, 738719f82d3SEliot Blennerhassett get its bus address for PCI bus mastering 739719f82d3SEliot Blennerhassett */ 740719f82d3SEliot Blennerhassett phm->u.d.u.buffer.buffer_size = 741719f82d3SEliot Blennerhassett roundup_pow_of_two(phm->u.d.u.buffer.buffer_size); 742719f82d3SEliot Blennerhassett /* return old size and allocated size, 743719f82d3SEliot Blennerhassett so caller can detect change */ 744719f82d3SEliot Blennerhassett phr->u.d.u.stream_info.data_available = 745719f82d3SEliot Blennerhassett phw->outstream_host_buffer_size[phm->obj_index]; 746719f82d3SEliot Blennerhassett phr->u.d.u.stream_info.buffer_size = 747719f82d3SEliot Blennerhassett phm->u.d.u.buffer.buffer_size; 748719f82d3SEliot Blennerhassett 749719f82d3SEliot Blennerhassett if (phw->outstream_host_buffer_size[phm->obj_index] == 750719f82d3SEliot Blennerhassett phm->u.d.u.buffer.buffer_size) { 751719f82d3SEliot Blennerhassett /* Same size, no action required */ 752719f82d3SEliot Blennerhassett return; 753719f82d3SEliot Blennerhassett } 754719f82d3SEliot Blennerhassett 755719f82d3SEliot Blennerhassett if (hpios_locked_mem_valid(&phw->outstream_host_buffers[phm-> 756719f82d3SEliot Blennerhassett obj_index])) 757719f82d3SEliot Blennerhassett hpios_locked_mem_free(&phw->outstream_host_buffers 758719f82d3SEliot Blennerhassett [phm->obj_index]); 759719f82d3SEliot Blennerhassett 760719f82d3SEliot Blennerhassett err = hpios_locked_mem_alloc(&phw->outstream_host_buffers 761719f82d3SEliot Blennerhassett [phm->obj_index], phm->u.d.u.buffer.buffer_size, 7623285ea10SEliot Blennerhassett pao->pci.pci_dev); 763719f82d3SEliot Blennerhassett 764719f82d3SEliot Blennerhassett if (err) { 765719f82d3SEliot Blennerhassett phr->error = HPI_ERROR_INVALID_DATASIZE; 766719f82d3SEliot Blennerhassett phw->outstream_host_buffer_size[phm->obj_index] = 0; 767719f82d3SEliot Blennerhassett return; 768719f82d3SEliot Blennerhassett } 769719f82d3SEliot Blennerhassett 770719f82d3SEliot Blennerhassett err = hpios_locked_mem_get_phys_addr 771719f82d3SEliot Blennerhassett (&phw->outstream_host_buffers[phm->obj_index], 772719f82d3SEliot Blennerhassett &phm->u.d.u.buffer.pci_address); 773719f82d3SEliot Blennerhassett /* get the phys addr into msg for single call alloc caller 774719f82d3SEliot Blennerhassett * needs to do this for split alloc (or use the same message) 775719f82d3SEliot Blennerhassett * return the phy address for split alloc in the respose too 776719f82d3SEliot Blennerhassett */ 777719f82d3SEliot Blennerhassett phr->u.d.u.stream_info.auxiliary_data_available = 778719f82d3SEliot Blennerhassett phm->u.d.u.buffer.pci_address; 779719f82d3SEliot Blennerhassett 780719f82d3SEliot Blennerhassett if (err) { 781719f82d3SEliot Blennerhassett hpios_locked_mem_free(&phw->outstream_host_buffers 782719f82d3SEliot Blennerhassett [phm->obj_index]); 783719f82d3SEliot Blennerhassett phw->outstream_host_buffer_size[phm->obj_index] = 0; 784719f82d3SEliot Blennerhassett phr->error = HPI_ERROR_MEMORY_ALLOC; 785719f82d3SEliot Blennerhassett return; 786719f82d3SEliot Blennerhassett } 787719f82d3SEliot Blennerhassett } 788719f82d3SEliot Blennerhassett 789719f82d3SEliot Blennerhassett if (command == HPI_BUFFER_CMD_EXTERNAL 790719f82d3SEliot Blennerhassett || command == HPI_BUFFER_CMD_INTERNAL_GRANTADAPTER) { 791719f82d3SEliot Blennerhassett /* GRANT phase. Set up the BBM status, tell the DSP about 792719f82d3SEliot Blennerhassett the buffer so it can start using BBM. 793719f82d3SEliot Blennerhassett */ 794719f82d3SEliot Blennerhassett struct hpi_hostbuffer_status *status; 795719f82d3SEliot Blennerhassett 796719f82d3SEliot Blennerhassett if (phm->u.d.u.buffer.buffer_size & (phm->u.d.u.buffer. 797719f82d3SEliot Blennerhassett buffer_size - 1)) { 798719f82d3SEliot Blennerhassett HPI_DEBUG_LOG(ERROR, 7993285ea10SEliot Blennerhassett "Buffer size must be 2^N not %d\n", 800719f82d3SEliot Blennerhassett phm->u.d.u.buffer.buffer_size); 801719f82d3SEliot Blennerhassett phr->error = HPI_ERROR_INVALID_DATASIZE; 802719f82d3SEliot Blennerhassett return; 803719f82d3SEliot Blennerhassett } 804719f82d3SEliot Blennerhassett phw->outstream_host_buffer_size[phm->obj_index] = 805719f82d3SEliot Blennerhassett phm->u.d.u.buffer.buffer_size; 806719f82d3SEliot Blennerhassett status = &interface->outstream_host_buffer_status[phm-> 807719f82d3SEliot Blennerhassett obj_index]; 808719f82d3SEliot Blennerhassett status->samples_processed = 0; 809719f82d3SEliot Blennerhassett status->stream_state = HPI_STATE_STOPPED; 810719f82d3SEliot Blennerhassett status->dSP_index = 0; 811719f82d3SEliot Blennerhassett status->host_index = status->dSP_index; 812719f82d3SEliot Blennerhassett status->size_in_bytes = phm->u.d.u.buffer.buffer_size; 813deb21a23SEliot Blennerhassett status->auxiliary_data_available = 0; 814719f82d3SEliot Blennerhassett 815719f82d3SEliot Blennerhassett hw_message(pao, phm, phr); 816719f82d3SEliot Blennerhassett 817719f82d3SEliot Blennerhassett if (phr->error 818719f82d3SEliot Blennerhassett && hpios_locked_mem_valid(&phw-> 819719f82d3SEliot Blennerhassett outstream_host_buffers[phm->obj_index])) { 820719f82d3SEliot Blennerhassett hpios_locked_mem_free(&phw->outstream_host_buffers 821719f82d3SEliot Blennerhassett [phm->obj_index]); 822719f82d3SEliot Blennerhassett phw->outstream_host_buffer_size[phm->obj_index] = 0; 823719f82d3SEliot Blennerhassett } 824719f82d3SEliot Blennerhassett } 825719f82d3SEliot Blennerhassett } 826719f82d3SEliot Blennerhassett 827719f82d3SEliot Blennerhassett static void outstream_host_buffer_get_info(struct hpi_adapter_obj *pao, 828719f82d3SEliot Blennerhassett struct hpi_message *phm, struct hpi_response *phr) 829719f82d3SEliot Blennerhassett { 830719f82d3SEliot Blennerhassett struct hpi_hw_obj *phw = pao->priv; 831719f82d3SEliot Blennerhassett struct bus_master_interface *interface = phw->p_interface_buffer; 832719f82d3SEliot Blennerhassett struct hpi_hostbuffer_status *status; 833719f82d3SEliot Blennerhassett u8 *p_bbm_data; 834719f82d3SEliot Blennerhassett 835719f82d3SEliot Blennerhassett if (hpios_locked_mem_valid(&phw->outstream_host_buffers[phm-> 836719f82d3SEliot Blennerhassett obj_index])) { 837719f82d3SEliot Blennerhassett if (hpios_locked_mem_get_virt_addr(&phw-> 838719f82d3SEliot Blennerhassett outstream_host_buffers[phm->obj_index], 839719f82d3SEliot Blennerhassett (void *)&p_bbm_data)) { 840719f82d3SEliot Blennerhassett phr->error = HPI_ERROR_INVALID_OPERATION; 841719f82d3SEliot Blennerhassett return; 842719f82d3SEliot Blennerhassett } 843719f82d3SEliot Blennerhassett status = &interface->outstream_host_buffer_status[phm-> 844719f82d3SEliot Blennerhassett obj_index]; 845719f82d3SEliot Blennerhassett hpi_init_response(phr, HPI_OBJ_OSTREAM, 846719f82d3SEliot Blennerhassett HPI_OSTREAM_HOSTBUFFER_GET_INFO, 0); 847719f82d3SEliot Blennerhassett phr->u.d.u.hostbuffer_info.p_buffer = p_bbm_data; 848719f82d3SEliot Blennerhassett phr->u.d.u.hostbuffer_info.p_status = status; 849719f82d3SEliot Blennerhassett } else { 850719f82d3SEliot Blennerhassett hpi_init_response(phr, HPI_OBJ_OSTREAM, 851719f82d3SEliot Blennerhassett HPI_OSTREAM_HOSTBUFFER_GET_INFO, 852719f82d3SEliot Blennerhassett HPI_ERROR_INVALID_OPERATION); 853719f82d3SEliot Blennerhassett } 854719f82d3SEliot Blennerhassett } 855719f82d3SEliot Blennerhassett 856719f82d3SEliot Blennerhassett static void outstream_host_buffer_free(struct hpi_adapter_obj *pao, 857719f82d3SEliot Blennerhassett struct hpi_message *phm, struct hpi_response *phr) 858719f82d3SEliot Blennerhassett { 859719f82d3SEliot Blennerhassett struct hpi_hw_obj *phw = pao->priv; 860719f82d3SEliot Blennerhassett u32 command = phm->u.d.u.buffer.command; 861719f82d3SEliot Blennerhassett 862719f82d3SEliot Blennerhassett if (phw->outstream_host_buffer_size[phm->obj_index]) { 863719f82d3SEliot Blennerhassett if (command == HPI_BUFFER_CMD_EXTERNAL 864719f82d3SEliot Blennerhassett || command == HPI_BUFFER_CMD_INTERNAL_REVOKEADAPTER) { 865719f82d3SEliot Blennerhassett phw->outstream_host_buffer_size[phm->obj_index] = 0; 866719f82d3SEliot Blennerhassett hw_message(pao, phm, phr); 867719f82d3SEliot Blennerhassett /* Tell adapter to stop using the host buffer. */ 868719f82d3SEliot Blennerhassett } 869719f82d3SEliot Blennerhassett if (command == HPI_BUFFER_CMD_EXTERNAL 870719f82d3SEliot Blennerhassett || command == HPI_BUFFER_CMD_INTERNAL_FREE) 871719f82d3SEliot Blennerhassett hpios_locked_mem_free(&phw->outstream_host_buffers 872719f82d3SEliot Blennerhassett [phm->obj_index]); 873719f82d3SEliot Blennerhassett } 874719f82d3SEliot Blennerhassett /* Should HPI_ERROR_INVALID_OPERATION be returned 875719f82d3SEliot Blennerhassett if no host buffer is allocated? */ 876719f82d3SEliot Blennerhassett else 877719f82d3SEliot Blennerhassett hpi_init_response(phr, HPI_OBJ_OSTREAM, 878719f82d3SEliot Blennerhassett HPI_OSTREAM_HOSTBUFFER_FREE, 0); 879719f82d3SEliot Blennerhassett 880719f82d3SEliot Blennerhassett } 881719f82d3SEliot Blennerhassett 88260f1deb5SEliot Blennerhassett static u32 outstream_get_space_available(struct hpi_hostbuffer_status *status) 883719f82d3SEliot Blennerhassett { 8842a383cb3SEliot Blennerhassett return status->size_in_bytes - (status->host_index - 8852a383cb3SEliot Blennerhassett status->dSP_index); 886719f82d3SEliot Blennerhassett } 887719f82d3SEliot Blennerhassett 888719f82d3SEliot Blennerhassett static void outstream_write(struct hpi_adapter_obj *pao, 889719f82d3SEliot Blennerhassett struct hpi_message *phm, struct hpi_response *phr) 890719f82d3SEliot Blennerhassett { 891719f82d3SEliot Blennerhassett struct hpi_hw_obj *phw = pao->priv; 892719f82d3SEliot Blennerhassett struct bus_master_interface *interface = phw->p_interface_buffer; 893719f82d3SEliot Blennerhassett struct hpi_hostbuffer_status *status; 8942a383cb3SEliot Blennerhassett u32 space_available; 895719f82d3SEliot Blennerhassett 896719f82d3SEliot Blennerhassett if (!phw->outstream_host_buffer_size[phm->obj_index]) { 897719f82d3SEliot Blennerhassett /* there is no BBM buffer, write via message */ 898719f82d3SEliot Blennerhassett hw_message(pao, phm, phr); 899719f82d3SEliot Blennerhassett return; 900719f82d3SEliot Blennerhassett } 901719f82d3SEliot Blennerhassett 902719f82d3SEliot Blennerhassett hpi_init_response(phr, phm->object, phm->function, 0); 903719f82d3SEliot Blennerhassett status = &interface->outstream_host_buffer_status[phm->obj_index]; 904719f82d3SEliot Blennerhassett 905719f82d3SEliot Blennerhassett space_available = outstream_get_space_available(status); 9062a383cb3SEliot Blennerhassett if (space_available < phm->u.d.u.data.data_size) { 907719f82d3SEliot Blennerhassett phr->error = HPI_ERROR_INVALID_DATASIZE; 908719f82d3SEliot Blennerhassett return; 909719f82d3SEliot Blennerhassett } 910719f82d3SEliot Blennerhassett 911719f82d3SEliot Blennerhassett /* HostBuffers is used to indicate host buffer is internally allocated. 912719f82d3SEliot Blennerhassett otherwise, assumed external, data written externally */ 913719f82d3SEliot Blennerhassett if (phm->u.d.u.data.pb_data 914719f82d3SEliot Blennerhassett && hpios_locked_mem_valid(&phw->outstream_host_buffers[phm-> 915719f82d3SEliot Blennerhassett obj_index])) { 916719f82d3SEliot Blennerhassett u8 *p_bbm_data; 9172a383cb3SEliot Blennerhassett u32 l_first_write; 918719f82d3SEliot Blennerhassett u8 *p_app_data = (u8 *)phm->u.d.u.data.pb_data; 919719f82d3SEliot Blennerhassett 920719f82d3SEliot Blennerhassett if (hpios_locked_mem_get_virt_addr(&phw-> 921719f82d3SEliot Blennerhassett outstream_host_buffers[phm->obj_index], 922719f82d3SEliot Blennerhassett (void *)&p_bbm_data)) { 923719f82d3SEliot Blennerhassett phr->error = HPI_ERROR_INVALID_OPERATION; 924719f82d3SEliot Blennerhassett return; 925719f82d3SEliot Blennerhassett } 926719f82d3SEliot Blennerhassett 927719f82d3SEliot Blennerhassett /* either all data, 928719f82d3SEliot Blennerhassett or enough to fit from current to end of BBM buffer */ 929719f82d3SEliot Blennerhassett l_first_write = 930719f82d3SEliot Blennerhassett min(phm->u.d.u.data.data_size, 931719f82d3SEliot Blennerhassett status->size_in_bytes - 932719f82d3SEliot Blennerhassett (status->host_index & (status->size_in_bytes - 1))); 933719f82d3SEliot Blennerhassett 934719f82d3SEliot Blennerhassett memcpy(p_bbm_data + 935719f82d3SEliot Blennerhassett (status->host_index & (status->size_in_bytes - 1)), 936719f82d3SEliot Blennerhassett p_app_data, l_first_write); 937719f82d3SEliot Blennerhassett /* remaining data if any */ 938719f82d3SEliot Blennerhassett memcpy(p_bbm_data, p_app_data + l_first_write, 939719f82d3SEliot Blennerhassett phm->u.d.u.data.data_size - l_first_write); 940719f82d3SEliot Blennerhassett } 9413285ea10SEliot Blennerhassett 9423285ea10SEliot Blennerhassett /* 9433285ea10SEliot Blennerhassett * This version relies on the DSP code triggering an OStream buffer 9443285ea10SEliot Blennerhassett * update immediately following a SET_FORMAT call. The host has 945deb21a23SEliot Blennerhassett * already written data into the BBM buffer, but the DSP won't know 946deb21a23SEliot Blennerhassett * about it until dwHostIndex is adjusted. 9473285ea10SEliot Blennerhassett */ 9483285ea10SEliot Blennerhassett if (phw->flag_outstream_just_reset[phm->obj_index]) { 9493285ea10SEliot Blennerhassett /* Format can only change after reset. Must tell DSP. */ 9503285ea10SEliot Blennerhassett u16 function = phm->function; 9513285ea10SEliot Blennerhassett phw->flag_outstream_just_reset[phm->obj_index] = 0; 9523285ea10SEliot Blennerhassett phm->function = HPI_OSTREAM_SET_FORMAT; 9533285ea10SEliot Blennerhassett hw_message(pao, phm, phr); /* send the format to the DSP */ 9543285ea10SEliot Blennerhassett phm->function = function; 9553285ea10SEliot Blennerhassett if (phr->error) 9563285ea10SEliot Blennerhassett return; 9573285ea10SEliot Blennerhassett } 9583285ea10SEliot Blennerhassett 959719f82d3SEliot Blennerhassett status->host_index += phm->u.d.u.data.data_size; 960719f82d3SEliot Blennerhassett } 961719f82d3SEliot Blennerhassett 962719f82d3SEliot Blennerhassett static void outstream_get_info(struct hpi_adapter_obj *pao, 963719f82d3SEliot Blennerhassett struct hpi_message *phm, struct hpi_response *phr) 964719f82d3SEliot Blennerhassett { 965719f82d3SEliot Blennerhassett struct hpi_hw_obj *phw = pao->priv; 966719f82d3SEliot Blennerhassett struct bus_master_interface *interface = phw->p_interface_buffer; 967719f82d3SEliot Blennerhassett struct hpi_hostbuffer_status *status; 968719f82d3SEliot Blennerhassett 969719f82d3SEliot Blennerhassett if (!phw->outstream_host_buffer_size[phm->obj_index]) { 970719f82d3SEliot Blennerhassett hw_message(pao, phm, phr); 971719f82d3SEliot Blennerhassett return; 972719f82d3SEliot Blennerhassett } 973719f82d3SEliot Blennerhassett 974719f82d3SEliot Blennerhassett hpi_init_response(phr, phm->object, phm->function, 0); 975719f82d3SEliot Blennerhassett 976719f82d3SEliot Blennerhassett status = &interface->outstream_host_buffer_status[phm->obj_index]; 977719f82d3SEliot Blennerhassett 978719f82d3SEliot Blennerhassett phr->u.d.u.stream_info.state = (u16)status->stream_state; 979719f82d3SEliot Blennerhassett phr->u.d.u.stream_info.samples_transferred = 980719f82d3SEliot Blennerhassett status->samples_processed; 981719f82d3SEliot Blennerhassett phr->u.d.u.stream_info.buffer_size = status->size_in_bytes; 982719f82d3SEliot Blennerhassett phr->u.d.u.stream_info.data_available = 983719f82d3SEliot Blennerhassett status->size_in_bytes - outstream_get_space_available(status); 984719f82d3SEliot Blennerhassett phr->u.d.u.stream_info.auxiliary_data_available = 985719f82d3SEliot Blennerhassett status->auxiliary_data_available; 986719f82d3SEliot Blennerhassett } 987719f82d3SEliot Blennerhassett 988719f82d3SEliot Blennerhassett static void outstream_start(struct hpi_adapter_obj *pao, 989719f82d3SEliot Blennerhassett struct hpi_message *phm, struct hpi_response *phr) 990719f82d3SEliot Blennerhassett { 991719f82d3SEliot Blennerhassett hw_message(pao, phm, phr); 992719f82d3SEliot Blennerhassett } 993719f82d3SEliot Blennerhassett 994719f82d3SEliot Blennerhassett static void outstream_reset(struct hpi_adapter_obj *pao, 995719f82d3SEliot Blennerhassett struct hpi_message *phm, struct hpi_response *phr) 996719f82d3SEliot Blennerhassett { 997719f82d3SEliot Blennerhassett struct hpi_hw_obj *phw = pao->priv; 998719f82d3SEliot Blennerhassett phw->flag_outstream_just_reset[phm->obj_index] = 1; 999719f82d3SEliot Blennerhassett hw_message(pao, phm, phr); 1000719f82d3SEliot Blennerhassett } 1001719f82d3SEliot Blennerhassett 1002719f82d3SEliot Blennerhassett static void outstream_open(struct hpi_adapter_obj *pao, 1003719f82d3SEliot Blennerhassett struct hpi_message *phm, struct hpi_response *phr) 1004719f82d3SEliot Blennerhassett { 1005719f82d3SEliot Blennerhassett outstream_reset(pao, phm, phr); 1006719f82d3SEliot Blennerhassett } 1007719f82d3SEliot Blennerhassett 1008719f82d3SEliot Blennerhassett /*****************************************************************************/ 1009719f82d3SEliot Blennerhassett /* InStream Host buffer functions */ 1010719f82d3SEliot Blennerhassett 1011719f82d3SEliot Blennerhassett static void instream_host_buffer_allocate(struct hpi_adapter_obj *pao, 1012719f82d3SEliot Blennerhassett struct hpi_message *phm, struct hpi_response *phr) 1013719f82d3SEliot Blennerhassett { 1014719f82d3SEliot Blennerhassett u16 err = 0; 1015719f82d3SEliot Blennerhassett u32 command = phm->u.d.u.buffer.command; 1016719f82d3SEliot Blennerhassett struct hpi_hw_obj *phw = pao->priv; 1017719f82d3SEliot Blennerhassett struct bus_master_interface *interface = phw->p_interface_buffer; 1018719f82d3SEliot Blennerhassett 1019719f82d3SEliot Blennerhassett hpi_init_response(phr, phm->object, phm->function, 0); 1020719f82d3SEliot Blennerhassett 1021719f82d3SEliot Blennerhassett if (command == HPI_BUFFER_CMD_EXTERNAL 1022719f82d3SEliot Blennerhassett || command == HPI_BUFFER_CMD_INTERNAL_ALLOC) { 1023719f82d3SEliot Blennerhassett 1024719f82d3SEliot Blennerhassett phm->u.d.u.buffer.buffer_size = 1025719f82d3SEliot Blennerhassett roundup_pow_of_two(phm->u.d.u.buffer.buffer_size); 1026719f82d3SEliot Blennerhassett phr->u.d.u.stream_info.data_available = 1027719f82d3SEliot Blennerhassett phw->instream_host_buffer_size[phm->obj_index]; 1028719f82d3SEliot Blennerhassett phr->u.d.u.stream_info.buffer_size = 1029719f82d3SEliot Blennerhassett phm->u.d.u.buffer.buffer_size; 1030719f82d3SEliot Blennerhassett 1031719f82d3SEliot Blennerhassett if (phw->instream_host_buffer_size[phm->obj_index] == 1032719f82d3SEliot Blennerhassett phm->u.d.u.buffer.buffer_size) { 1033719f82d3SEliot Blennerhassett /* Same size, no action required */ 1034719f82d3SEliot Blennerhassett return; 1035719f82d3SEliot Blennerhassett } 1036719f82d3SEliot Blennerhassett 1037719f82d3SEliot Blennerhassett if (hpios_locked_mem_valid(&phw->instream_host_buffers[phm-> 1038719f82d3SEliot Blennerhassett obj_index])) 1039719f82d3SEliot Blennerhassett hpios_locked_mem_free(&phw->instream_host_buffers 1040719f82d3SEliot Blennerhassett [phm->obj_index]); 1041719f82d3SEliot Blennerhassett 1042719f82d3SEliot Blennerhassett err = hpios_locked_mem_alloc(&phw->instream_host_buffers[phm-> 1043719f82d3SEliot Blennerhassett obj_index], phm->u.d.u.buffer.buffer_size, 10443285ea10SEliot Blennerhassett pao->pci.pci_dev); 1045719f82d3SEliot Blennerhassett 1046719f82d3SEliot Blennerhassett if (err) { 1047719f82d3SEliot Blennerhassett phr->error = HPI_ERROR_INVALID_DATASIZE; 1048719f82d3SEliot Blennerhassett phw->instream_host_buffer_size[phm->obj_index] = 0; 1049719f82d3SEliot Blennerhassett return; 1050719f82d3SEliot Blennerhassett } 1051719f82d3SEliot Blennerhassett 1052719f82d3SEliot Blennerhassett err = hpios_locked_mem_get_phys_addr 1053719f82d3SEliot Blennerhassett (&phw->instream_host_buffers[phm->obj_index], 1054719f82d3SEliot Blennerhassett &phm->u.d.u.buffer.pci_address); 1055719f82d3SEliot Blennerhassett /* get the phys addr into msg for single call alloc. Caller 1056719f82d3SEliot Blennerhassett needs to do this for split alloc so return the phy address */ 1057719f82d3SEliot Blennerhassett phr->u.d.u.stream_info.auxiliary_data_available = 1058719f82d3SEliot Blennerhassett phm->u.d.u.buffer.pci_address; 1059719f82d3SEliot Blennerhassett if (err) { 1060719f82d3SEliot Blennerhassett hpios_locked_mem_free(&phw->instream_host_buffers 1061719f82d3SEliot Blennerhassett [phm->obj_index]); 1062719f82d3SEliot Blennerhassett phw->instream_host_buffer_size[phm->obj_index] = 0; 1063719f82d3SEliot Blennerhassett phr->error = HPI_ERROR_MEMORY_ALLOC; 1064719f82d3SEliot Blennerhassett return; 1065719f82d3SEliot Blennerhassett } 1066719f82d3SEliot Blennerhassett } 1067719f82d3SEliot Blennerhassett 1068719f82d3SEliot Blennerhassett if (command == HPI_BUFFER_CMD_EXTERNAL 1069719f82d3SEliot Blennerhassett || command == HPI_BUFFER_CMD_INTERNAL_GRANTADAPTER) { 1070719f82d3SEliot Blennerhassett struct hpi_hostbuffer_status *status; 1071719f82d3SEliot Blennerhassett 1072719f82d3SEliot Blennerhassett if (phm->u.d.u.buffer.buffer_size & (phm->u.d.u.buffer. 1073719f82d3SEliot Blennerhassett buffer_size - 1)) { 1074719f82d3SEliot Blennerhassett HPI_DEBUG_LOG(ERROR, 10753285ea10SEliot Blennerhassett "Buffer size must be 2^N not %d\n", 1076719f82d3SEliot Blennerhassett phm->u.d.u.buffer.buffer_size); 1077719f82d3SEliot Blennerhassett phr->error = HPI_ERROR_INVALID_DATASIZE; 1078719f82d3SEliot Blennerhassett return; 1079719f82d3SEliot Blennerhassett } 1080719f82d3SEliot Blennerhassett 1081719f82d3SEliot Blennerhassett phw->instream_host_buffer_size[phm->obj_index] = 1082719f82d3SEliot Blennerhassett phm->u.d.u.buffer.buffer_size; 1083719f82d3SEliot Blennerhassett status = &interface->instream_host_buffer_status[phm-> 1084719f82d3SEliot Blennerhassett obj_index]; 1085719f82d3SEliot Blennerhassett status->samples_processed = 0; 1086719f82d3SEliot Blennerhassett status->stream_state = HPI_STATE_STOPPED; 1087719f82d3SEliot Blennerhassett status->dSP_index = 0; 1088719f82d3SEliot Blennerhassett status->host_index = status->dSP_index; 1089719f82d3SEliot Blennerhassett status->size_in_bytes = phm->u.d.u.buffer.buffer_size; 1090deb21a23SEliot Blennerhassett status->auxiliary_data_available = 0; 1091719f82d3SEliot Blennerhassett 1092719f82d3SEliot Blennerhassett hw_message(pao, phm, phr); 1093*ba3a9099SEliot Blennerhassett 1094719f82d3SEliot Blennerhassett if (phr->error 1095719f82d3SEliot Blennerhassett && hpios_locked_mem_valid(&phw-> 1096719f82d3SEliot Blennerhassett instream_host_buffers[phm->obj_index])) { 1097719f82d3SEliot Blennerhassett hpios_locked_mem_free(&phw->instream_host_buffers 1098719f82d3SEliot Blennerhassett [phm->obj_index]); 1099719f82d3SEliot Blennerhassett phw->instream_host_buffer_size[phm->obj_index] = 0; 1100719f82d3SEliot Blennerhassett } 1101719f82d3SEliot Blennerhassett } 1102719f82d3SEliot Blennerhassett } 1103719f82d3SEliot Blennerhassett 1104719f82d3SEliot Blennerhassett static void instream_host_buffer_get_info(struct hpi_adapter_obj *pao, 1105719f82d3SEliot Blennerhassett struct hpi_message *phm, struct hpi_response *phr) 1106719f82d3SEliot Blennerhassett { 1107719f82d3SEliot Blennerhassett struct hpi_hw_obj *phw = pao->priv; 1108719f82d3SEliot Blennerhassett struct bus_master_interface *interface = phw->p_interface_buffer; 1109719f82d3SEliot Blennerhassett struct hpi_hostbuffer_status *status; 1110719f82d3SEliot Blennerhassett u8 *p_bbm_data; 1111719f82d3SEliot Blennerhassett 1112719f82d3SEliot Blennerhassett if (hpios_locked_mem_valid(&phw->instream_host_buffers[phm-> 1113719f82d3SEliot Blennerhassett obj_index])) { 1114719f82d3SEliot Blennerhassett if (hpios_locked_mem_get_virt_addr(&phw-> 1115719f82d3SEliot Blennerhassett instream_host_buffers[phm->obj_index], 1116719f82d3SEliot Blennerhassett (void *)&p_bbm_data)) { 1117719f82d3SEliot Blennerhassett phr->error = HPI_ERROR_INVALID_OPERATION; 1118719f82d3SEliot Blennerhassett return; 1119719f82d3SEliot Blennerhassett } 1120719f82d3SEliot Blennerhassett status = &interface->instream_host_buffer_status[phm-> 1121719f82d3SEliot Blennerhassett obj_index]; 1122719f82d3SEliot Blennerhassett hpi_init_response(phr, HPI_OBJ_ISTREAM, 1123719f82d3SEliot Blennerhassett HPI_ISTREAM_HOSTBUFFER_GET_INFO, 0); 1124719f82d3SEliot Blennerhassett phr->u.d.u.hostbuffer_info.p_buffer = p_bbm_data; 1125719f82d3SEliot Blennerhassett phr->u.d.u.hostbuffer_info.p_status = status; 1126719f82d3SEliot Blennerhassett } else { 1127719f82d3SEliot Blennerhassett hpi_init_response(phr, HPI_OBJ_ISTREAM, 1128719f82d3SEliot Blennerhassett HPI_ISTREAM_HOSTBUFFER_GET_INFO, 1129719f82d3SEliot Blennerhassett HPI_ERROR_INVALID_OPERATION); 1130719f82d3SEliot Blennerhassett } 1131719f82d3SEliot Blennerhassett } 1132719f82d3SEliot Blennerhassett 1133719f82d3SEliot Blennerhassett static void instream_host_buffer_free(struct hpi_adapter_obj *pao, 1134719f82d3SEliot Blennerhassett struct hpi_message *phm, struct hpi_response *phr) 1135719f82d3SEliot Blennerhassett { 1136719f82d3SEliot Blennerhassett struct hpi_hw_obj *phw = pao->priv; 1137719f82d3SEliot Blennerhassett u32 command = phm->u.d.u.buffer.command; 1138719f82d3SEliot Blennerhassett 1139719f82d3SEliot Blennerhassett if (phw->instream_host_buffer_size[phm->obj_index]) { 1140719f82d3SEliot Blennerhassett if (command == HPI_BUFFER_CMD_EXTERNAL 1141719f82d3SEliot Blennerhassett || command == HPI_BUFFER_CMD_INTERNAL_REVOKEADAPTER) { 1142719f82d3SEliot Blennerhassett phw->instream_host_buffer_size[phm->obj_index] = 0; 1143719f82d3SEliot Blennerhassett hw_message(pao, phm, phr); 1144719f82d3SEliot Blennerhassett } 1145719f82d3SEliot Blennerhassett 1146719f82d3SEliot Blennerhassett if (command == HPI_BUFFER_CMD_EXTERNAL 1147719f82d3SEliot Blennerhassett || command == HPI_BUFFER_CMD_INTERNAL_FREE) 1148719f82d3SEliot Blennerhassett hpios_locked_mem_free(&phw->instream_host_buffers 1149719f82d3SEliot Blennerhassett [phm->obj_index]); 1150719f82d3SEliot Blennerhassett 1151719f82d3SEliot Blennerhassett } else { 1152719f82d3SEliot Blennerhassett /* Should HPI_ERROR_INVALID_OPERATION be returned 1153719f82d3SEliot Blennerhassett if no host buffer is allocated? */ 1154719f82d3SEliot Blennerhassett hpi_init_response(phr, HPI_OBJ_ISTREAM, 1155719f82d3SEliot Blennerhassett HPI_ISTREAM_HOSTBUFFER_FREE, 0); 1156719f82d3SEliot Blennerhassett 1157719f82d3SEliot Blennerhassett } 1158719f82d3SEliot Blennerhassett 1159719f82d3SEliot Blennerhassett } 1160719f82d3SEliot Blennerhassett 1161719f82d3SEliot Blennerhassett static void instream_start(struct hpi_adapter_obj *pao, 1162719f82d3SEliot Blennerhassett struct hpi_message *phm, struct hpi_response *phr) 1163719f82d3SEliot Blennerhassett { 1164719f82d3SEliot Blennerhassett hw_message(pao, phm, phr); 1165719f82d3SEliot Blennerhassett } 1166719f82d3SEliot Blennerhassett 11672a383cb3SEliot Blennerhassett static u32 instream_get_bytes_available(struct hpi_hostbuffer_status *status) 1168719f82d3SEliot Blennerhassett { 11692a383cb3SEliot Blennerhassett return status->dSP_index - status->host_index; 1170719f82d3SEliot Blennerhassett } 1171719f82d3SEliot Blennerhassett 1172719f82d3SEliot Blennerhassett static void instream_read(struct hpi_adapter_obj *pao, 1173719f82d3SEliot Blennerhassett struct hpi_message *phm, struct hpi_response *phr) 1174719f82d3SEliot Blennerhassett { 1175719f82d3SEliot Blennerhassett struct hpi_hw_obj *phw = pao->priv; 1176719f82d3SEliot Blennerhassett struct bus_master_interface *interface = phw->p_interface_buffer; 1177719f82d3SEliot Blennerhassett struct hpi_hostbuffer_status *status; 11782a383cb3SEliot Blennerhassett u32 data_available; 1179719f82d3SEliot Blennerhassett u8 *p_bbm_data; 11802a383cb3SEliot Blennerhassett u32 l_first_read; 1181719f82d3SEliot Blennerhassett u8 *p_app_data = (u8 *)phm->u.d.u.data.pb_data; 1182719f82d3SEliot Blennerhassett 1183719f82d3SEliot Blennerhassett if (!phw->instream_host_buffer_size[phm->obj_index]) { 1184719f82d3SEliot Blennerhassett hw_message(pao, phm, phr); 1185719f82d3SEliot Blennerhassett return; 1186719f82d3SEliot Blennerhassett } 1187719f82d3SEliot Blennerhassett hpi_init_response(phr, phm->object, phm->function, 0); 1188719f82d3SEliot Blennerhassett 1189719f82d3SEliot Blennerhassett status = &interface->instream_host_buffer_status[phm->obj_index]; 1190719f82d3SEliot Blennerhassett data_available = instream_get_bytes_available(status); 11912a383cb3SEliot Blennerhassett if (data_available < phm->u.d.u.data.data_size) { 1192719f82d3SEliot Blennerhassett phr->error = HPI_ERROR_INVALID_DATASIZE; 1193719f82d3SEliot Blennerhassett return; 1194719f82d3SEliot Blennerhassett } 1195719f82d3SEliot Blennerhassett 1196719f82d3SEliot Blennerhassett if (hpios_locked_mem_valid(&phw->instream_host_buffers[phm-> 1197719f82d3SEliot Blennerhassett obj_index])) { 1198719f82d3SEliot Blennerhassett if (hpios_locked_mem_get_virt_addr(&phw-> 1199719f82d3SEliot Blennerhassett instream_host_buffers[phm->obj_index], 1200719f82d3SEliot Blennerhassett (void *)&p_bbm_data)) { 1201719f82d3SEliot Blennerhassett phr->error = HPI_ERROR_INVALID_OPERATION; 1202719f82d3SEliot Blennerhassett return; 1203719f82d3SEliot Blennerhassett } 1204719f82d3SEliot Blennerhassett 1205719f82d3SEliot Blennerhassett /* either all data, 1206719f82d3SEliot Blennerhassett or enough to fit from current to end of BBM buffer */ 1207719f82d3SEliot Blennerhassett l_first_read = 1208719f82d3SEliot Blennerhassett min(phm->u.d.u.data.data_size, 1209719f82d3SEliot Blennerhassett status->size_in_bytes - 1210719f82d3SEliot Blennerhassett (status->host_index & (status->size_in_bytes - 1))); 1211719f82d3SEliot Blennerhassett 1212719f82d3SEliot Blennerhassett memcpy(p_app_data, 1213719f82d3SEliot Blennerhassett p_bbm_data + 1214719f82d3SEliot Blennerhassett (status->host_index & (status->size_in_bytes - 1)), 1215719f82d3SEliot Blennerhassett l_first_read); 1216719f82d3SEliot Blennerhassett /* remaining data if any */ 1217719f82d3SEliot Blennerhassett memcpy(p_app_data + l_first_read, p_bbm_data, 1218719f82d3SEliot Blennerhassett phm->u.d.u.data.data_size - l_first_read); 1219719f82d3SEliot Blennerhassett } 1220719f82d3SEliot Blennerhassett status->host_index += phm->u.d.u.data.data_size; 1221719f82d3SEliot Blennerhassett } 1222719f82d3SEliot Blennerhassett 1223719f82d3SEliot Blennerhassett static void instream_get_info(struct hpi_adapter_obj *pao, 1224719f82d3SEliot Blennerhassett struct hpi_message *phm, struct hpi_response *phr) 1225719f82d3SEliot Blennerhassett { 1226719f82d3SEliot Blennerhassett struct hpi_hw_obj *phw = pao->priv; 1227719f82d3SEliot Blennerhassett struct bus_master_interface *interface = phw->p_interface_buffer; 1228719f82d3SEliot Blennerhassett struct hpi_hostbuffer_status *status; 1229719f82d3SEliot Blennerhassett if (!phw->instream_host_buffer_size[phm->obj_index]) { 1230719f82d3SEliot Blennerhassett hw_message(pao, phm, phr); 1231719f82d3SEliot Blennerhassett return; 1232719f82d3SEliot Blennerhassett } 1233719f82d3SEliot Blennerhassett 1234719f82d3SEliot Blennerhassett status = &interface->instream_host_buffer_status[phm->obj_index]; 1235719f82d3SEliot Blennerhassett 1236719f82d3SEliot Blennerhassett hpi_init_response(phr, phm->object, phm->function, 0); 1237719f82d3SEliot Blennerhassett 1238719f82d3SEliot Blennerhassett phr->u.d.u.stream_info.state = (u16)status->stream_state; 1239719f82d3SEliot Blennerhassett phr->u.d.u.stream_info.samples_transferred = 1240719f82d3SEliot Blennerhassett status->samples_processed; 1241719f82d3SEliot Blennerhassett phr->u.d.u.stream_info.buffer_size = status->size_in_bytes; 1242719f82d3SEliot Blennerhassett phr->u.d.u.stream_info.data_available = 1243719f82d3SEliot Blennerhassett instream_get_bytes_available(status); 1244719f82d3SEliot Blennerhassett phr->u.d.u.stream_info.auxiliary_data_available = 1245719f82d3SEliot Blennerhassett status->auxiliary_data_available; 1246719f82d3SEliot Blennerhassett } 1247719f82d3SEliot Blennerhassett 1248719f82d3SEliot Blennerhassett /*****************************************************************************/ 1249719f82d3SEliot Blennerhassett /* LOW-LEVEL */ 1250719f82d3SEliot Blennerhassett #define HPI6205_MAX_FILES_TO_LOAD 2 1251719f82d3SEliot Blennerhassett 1252719f82d3SEliot Blennerhassett static u16 adapter_boot_load_dsp(struct hpi_adapter_obj *pao, 1253719f82d3SEliot Blennerhassett u32 *pos_error_code) 1254719f82d3SEliot Blennerhassett { 1255719f82d3SEliot Blennerhassett struct hpi_hw_obj *phw = pao->priv; 1256719f82d3SEliot Blennerhassett struct dsp_code dsp_code; 1257719f82d3SEliot Blennerhassett u16 boot_code_id[HPI6205_MAX_FILES_TO_LOAD]; 1258719f82d3SEliot Blennerhassett u32 temp; 1259719f82d3SEliot Blennerhassett int dsp = 0, i = 0; 1260719f82d3SEliot Blennerhassett u16 err = 0; 1261719f82d3SEliot Blennerhassett 1262719f82d3SEliot Blennerhassett boot_code_id[0] = HPI_ADAPTER_ASI(0x6205); 1263719f82d3SEliot Blennerhassett 1264ee246fc0SEliot Blennerhassett boot_code_id[1] = pao->pci.pci_dev->subsystem_device; 1265ee246fc0SEliot Blennerhassett boot_code_id[1] = HPI_ADAPTER_FAMILY_ASI(boot_code_id[1]); 1266ee246fc0SEliot Blennerhassett 1267ee246fc0SEliot Blennerhassett /* fix up cases where bootcode id[1] != subsys id */ 1268ee246fc0SEliot Blennerhassett switch (boot_code_id[1]) { 1269719f82d3SEliot Blennerhassett case HPI_ADAPTER_FAMILY_ASI(0x5000): 1270ee246fc0SEliot Blennerhassett boot_code_id[0] = boot_code_id[1]; 1271ee246fc0SEliot Blennerhassett boot_code_id[1] = 0; 1272719f82d3SEliot Blennerhassett break; 1273719f82d3SEliot Blennerhassett case HPI_ADAPTER_FAMILY_ASI(0x5300): 1274719f82d3SEliot Blennerhassett case HPI_ADAPTER_FAMILY_ASI(0x5400): 1275719f82d3SEliot Blennerhassett case HPI_ADAPTER_FAMILY_ASI(0x6300): 1276ee246fc0SEliot Blennerhassett boot_code_id[1] = HPI_ADAPTER_FAMILY_ASI(0x6400); 1277719f82d3SEliot Blennerhassett break; 1278719f82d3SEliot Blennerhassett case HPI_ADAPTER_FAMILY_ASI(0x5600): 1279719f82d3SEliot Blennerhassett case HPI_ADAPTER_FAMILY_ASI(0x6500): 1280ee246fc0SEliot Blennerhassett boot_code_id[1] = HPI_ADAPTER_FAMILY_ASI(0x6600); 1281719f82d3SEliot Blennerhassett break; 1282cadae428SEliot Blennerhassett case HPI_ADAPTER_FAMILY_ASI(0x8800): 1283ee246fc0SEliot Blennerhassett boot_code_id[1] = HPI_ADAPTER_FAMILY_ASI(0x8900); 1284ee246fc0SEliot Blennerhassett break; 1285ee246fc0SEliot Blennerhassett default: 1286cadae428SEliot Blennerhassett break; 1287719f82d3SEliot Blennerhassett } 1288719f82d3SEliot Blennerhassett 1289719f82d3SEliot Blennerhassett /* reset DSP by writing a 1 to the WARMRESET bit */ 1290719f82d3SEliot Blennerhassett temp = C6205_HDCR_WARMRESET; 1291719f82d3SEliot Blennerhassett iowrite32(temp, phw->prHDCR); 1292719f82d3SEliot Blennerhassett hpios_delay_micro_seconds(1000); 1293719f82d3SEliot Blennerhassett 1294719f82d3SEliot Blennerhassett /* check that PCI i/f was configured by EEPROM */ 1295719f82d3SEliot Blennerhassett temp = ioread32(phw->prHSR); 1296719f82d3SEliot Blennerhassett if ((temp & (C6205_HSR_CFGERR | C6205_HSR_EEREAD)) != 1297719f82d3SEliot Blennerhassett C6205_HSR_EEREAD) 12983285ea10SEliot Blennerhassett return HPI6205_ERROR_6205_EEPROM; 1299719f82d3SEliot Blennerhassett temp |= 0x04; 1300719f82d3SEliot Blennerhassett /* disable PINTA interrupt */ 1301719f82d3SEliot Blennerhassett iowrite32(temp, phw->prHSR); 1302719f82d3SEliot Blennerhassett 1303719f82d3SEliot Blennerhassett /* check control register reports PCI boot mode */ 1304719f82d3SEliot Blennerhassett temp = ioread32(phw->prHDCR); 1305719f82d3SEliot Blennerhassett if (!(temp & C6205_HDCR_PCIBOOT)) 13063285ea10SEliot Blennerhassett return HPI6205_ERROR_6205_REG; 1307719f82d3SEliot Blennerhassett 13083285ea10SEliot Blennerhassett /* try writing a few numbers to the DSP page register */ 1309719f82d3SEliot Blennerhassett /* and reading them back. */ 1310719f82d3SEliot Blennerhassett temp = 3; 1311719f82d3SEliot Blennerhassett iowrite32(temp, phw->prDSPP); 1312719f82d3SEliot Blennerhassett if ((temp | C6205_DSPP_MAP1) != ioread32(phw->prDSPP)) 13133285ea10SEliot Blennerhassett return HPI6205_ERROR_6205_DSPPAGE; 13143285ea10SEliot Blennerhassett temp = 2; 13153285ea10SEliot Blennerhassett iowrite32(temp, phw->prDSPP); 13163285ea10SEliot Blennerhassett if ((temp | C6205_DSPP_MAP1) != ioread32(phw->prDSPP)) 13173285ea10SEliot Blennerhassett return HPI6205_ERROR_6205_DSPPAGE; 13183285ea10SEliot Blennerhassett temp = 1; 13193285ea10SEliot Blennerhassett iowrite32(temp, phw->prDSPP); 13203285ea10SEliot Blennerhassett if ((temp | C6205_DSPP_MAP1) != ioread32(phw->prDSPP)) 13213285ea10SEliot Blennerhassett return HPI6205_ERROR_6205_DSPPAGE; 1322719f82d3SEliot Blennerhassett /* reset DSP page to the correct number */ 1323719f82d3SEliot Blennerhassett temp = 0; 1324719f82d3SEliot Blennerhassett iowrite32(temp, phw->prDSPP); 1325719f82d3SEliot Blennerhassett if ((temp | C6205_DSPP_MAP1) != ioread32(phw->prDSPP)) 13263285ea10SEliot Blennerhassett return HPI6205_ERROR_6205_DSPPAGE; 1327719f82d3SEliot Blennerhassett phw->dsp_page = 0; 1328719f82d3SEliot Blennerhassett 1329719f82d3SEliot Blennerhassett /* release 6713 from reset before 6205 is bootloaded. 1330719f82d3SEliot Blennerhassett This ensures that the EMIF is inactive, 1331719f82d3SEliot Blennerhassett and the 6713 HPI gets the correct bootmode etc 1332719f82d3SEliot Blennerhassett */ 1333719f82d3SEliot Blennerhassett if (boot_code_id[1] != 0) { 1334719f82d3SEliot Blennerhassett /* DSP 1 is a C6713 */ 1335719f82d3SEliot Blennerhassett /* CLKX0 <- '1' release the C6205 bootmode pulldowns */ 1336719f82d3SEliot Blennerhassett boot_loader_write_mem32(pao, 0, (0x018C0024L), 0x00002202); 1337719f82d3SEliot Blennerhassett hpios_delay_micro_seconds(100); 1338719f82d3SEliot Blennerhassett /* Reset the 6713 #1 - revB */ 1339719f82d3SEliot Blennerhassett boot_loader_write_mem32(pao, 0, C6205_BAR0_TIMER1_CTL, 0); 1340719f82d3SEliot Blennerhassett 1341719f82d3SEliot Blennerhassett /* dummy read every 4 words for 6205 advisory 1.4.4 */ 1342719f82d3SEliot Blennerhassett boot_loader_read_mem32(pao, 0, 0); 1343719f82d3SEliot Blennerhassett 1344719f82d3SEliot Blennerhassett hpios_delay_micro_seconds(100); 1345719f82d3SEliot Blennerhassett /* Release C6713 from reset - revB */ 1346719f82d3SEliot Blennerhassett boot_loader_write_mem32(pao, 0, C6205_BAR0_TIMER1_CTL, 4); 1347719f82d3SEliot Blennerhassett hpios_delay_micro_seconds(100); 1348719f82d3SEliot Blennerhassett } 1349719f82d3SEliot Blennerhassett 1350719f82d3SEliot Blennerhassett for (dsp = 0; dsp < HPI6205_MAX_FILES_TO_LOAD; dsp++) { 1351719f82d3SEliot Blennerhassett /* is there a DSP to load? */ 1352719f82d3SEliot Blennerhassett if (boot_code_id[dsp] == 0) 1353719f82d3SEliot Blennerhassett continue; 1354719f82d3SEliot Blennerhassett 1355719f82d3SEliot Blennerhassett err = boot_loader_config_emif(pao, dsp); 1356719f82d3SEliot Blennerhassett if (err) 1357719f82d3SEliot Blennerhassett return err; 1358719f82d3SEliot Blennerhassett 1359719f82d3SEliot Blennerhassett err = boot_loader_test_internal_memory(pao, dsp); 1360719f82d3SEliot Blennerhassett if (err) 1361719f82d3SEliot Blennerhassett return err; 1362719f82d3SEliot Blennerhassett 1363719f82d3SEliot Blennerhassett err = boot_loader_test_external_memory(pao, dsp); 1364719f82d3SEliot Blennerhassett if (err) 1365719f82d3SEliot Blennerhassett return err; 1366719f82d3SEliot Blennerhassett 1367719f82d3SEliot Blennerhassett err = boot_loader_test_pld(pao, dsp); 1368719f82d3SEliot Blennerhassett if (err) 1369719f82d3SEliot Blennerhassett return err; 1370719f82d3SEliot Blennerhassett 1371719f82d3SEliot Blennerhassett /* write the DSP code down into the DSPs memory */ 13723285ea10SEliot Blennerhassett dsp_code.ps_dev = pao->pci.pci_dev; 1373719f82d3SEliot Blennerhassett err = hpi_dsp_code_open(boot_code_id[dsp], &dsp_code, 1374719f82d3SEliot Blennerhassett pos_error_code); 1375719f82d3SEliot Blennerhassett if (err) 1376719f82d3SEliot Blennerhassett return err; 1377719f82d3SEliot Blennerhassett 1378719f82d3SEliot Blennerhassett while (1) { 1379719f82d3SEliot Blennerhassett u32 length; 1380719f82d3SEliot Blennerhassett u32 address; 1381719f82d3SEliot Blennerhassett u32 type; 1382719f82d3SEliot Blennerhassett u32 *pcode; 1383719f82d3SEliot Blennerhassett 1384719f82d3SEliot Blennerhassett err = hpi_dsp_code_read_word(&dsp_code, &length); 1385719f82d3SEliot Blennerhassett if (err) 1386719f82d3SEliot Blennerhassett break; 1387719f82d3SEliot Blennerhassett if (length == 0xFFFFFFFF) 1388719f82d3SEliot Blennerhassett break; /* end of code */ 1389719f82d3SEliot Blennerhassett 1390719f82d3SEliot Blennerhassett err = hpi_dsp_code_read_word(&dsp_code, &address); 1391719f82d3SEliot Blennerhassett if (err) 1392719f82d3SEliot Blennerhassett break; 1393719f82d3SEliot Blennerhassett err = hpi_dsp_code_read_word(&dsp_code, &type); 1394719f82d3SEliot Blennerhassett if (err) 1395719f82d3SEliot Blennerhassett break; 1396719f82d3SEliot Blennerhassett err = hpi_dsp_code_read_block(length, &dsp_code, 1397719f82d3SEliot Blennerhassett &pcode); 1398719f82d3SEliot Blennerhassett if (err) 1399719f82d3SEliot Blennerhassett break; 1400719f82d3SEliot Blennerhassett for (i = 0; i < (int)length; i++) { 14013285ea10SEliot Blennerhassett boot_loader_write_mem32(pao, dsp, address, 14023285ea10SEliot Blennerhassett *pcode); 1403719f82d3SEliot Blennerhassett /* dummy read every 4 words */ 1404719f82d3SEliot Blennerhassett /* for 6205 advisory 1.4.4 */ 1405719f82d3SEliot Blennerhassett if (i % 4 == 0) 1406719f82d3SEliot Blennerhassett boot_loader_read_mem32(pao, dsp, 1407719f82d3SEliot Blennerhassett address); 1408719f82d3SEliot Blennerhassett pcode++; 1409719f82d3SEliot Blennerhassett address += 4; 1410719f82d3SEliot Blennerhassett } 1411719f82d3SEliot Blennerhassett 1412719f82d3SEliot Blennerhassett } 1413719f82d3SEliot Blennerhassett if (err) { 1414719f82d3SEliot Blennerhassett hpi_dsp_code_close(&dsp_code); 1415719f82d3SEliot Blennerhassett return err; 1416719f82d3SEliot Blennerhassett } 1417719f82d3SEliot Blennerhassett 1418719f82d3SEliot Blennerhassett /* verify code */ 1419719f82d3SEliot Blennerhassett hpi_dsp_code_rewind(&dsp_code); 1420719f82d3SEliot Blennerhassett while (1) { 1421719f82d3SEliot Blennerhassett u32 length = 0; 1422719f82d3SEliot Blennerhassett u32 address = 0; 1423719f82d3SEliot Blennerhassett u32 type = 0; 1424719f82d3SEliot Blennerhassett u32 *pcode = NULL; 1425719f82d3SEliot Blennerhassett u32 data = 0; 1426719f82d3SEliot Blennerhassett 1427719f82d3SEliot Blennerhassett hpi_dsp_code_read_word(&dsp_code, &length); 1428719f82d3SEliot Blennerhassett if (length == 0xFFFFFFFF) 1429719f82d3SEliot Blennerhassett break; /* end of code */ 1430719f82d3SEliot Blennerhassett 1431719f82d3SEliot Blennerhassett hpi_dsp_code_read_word(&dsp_code, &address); 1432719f82d3SEliot Blennerhassett hpi_dsp_code_read_word(&dsp_code, &type); 1433719f82d3SEliot Blennerhassett hpi_dsp_code_read_block(length, &dsp_code, &pcode); 1434719f82d3SEliot Blennerhassett 1435719f82d3SEliot Blennerhassett for (i = 0; i < (int)length; i++) { 1436719f82d3SEliot Blennerhassett data = boot_loader_read_mem32(pao, dsp, 1437719f82d3SEliot Blennerhassett address); 1438719f82d3SEliot Blennerhassett if (data != *pcode) { 1439719f82d3SEliot Blennerhassett err = 0; 1440719f82d3SEliot Blennerhassett break; 1441719f82d3SEliot Blennerhassett } 1442719f82d3SEliot Blennerhassett pcode++; 1443719f82d3SEliot Blennerhassett address += 4; 1444719f82d3SEliot Blennerhassett } 1445719f82d3SEliot Blennerhassett if (err) 1446719f82d3SEliot Blennerhassett break; 1447719f82d3SEliot Blennerhassett } 1448719f82d3SEliot Blennerhassett hpi_dsp_code_close(&dsp_code); 1449719f82d3SEliot Blennerhassett if (err) 1450719f82d3SEliot Blennerhassett return err; 1451719f82d3SEliot Blennerhassett } 1452719f82d3SEliot Blennerhassett 1453719f82d3SEliot Blennerhassett /* After bootloading all DSPs, start DSP0 running 1454719f82d3SEliot Blennerhassett * The DSP0 code will handle starting and synchronizing with its slaves 1455719f82d3SEliot Blennerhassett */ 1456719f82d3SEliot Blennerhassett if (phw->p_interface_buffer) { 1457719f82d3SEliot Blennerhassett /* we need to tell the card the physical PCI address */ 1458719f82d3SEliot Blennerhassett u32 physicalPC_iaddress; 1459719f82d3SEliot Blennerhassett struct bus_master_interface *interface = 1460719f82d3SEliot Blennerhassett phw->p_interface_buffer; 1461719f82d3SEliot Blennerhassett u32 host_mailbox_address_on_dsp; 1462719f82d3SEliot Blennerhassett u32 physicalPC_iaddress_verify = 0; 1463719f82d3SEliot Blennerhassett int time_out = 10; 1464719f82d3SEliot Blennerhassett /* set ack so we know when DSP is ready to go */ 1465719f82d3SEliot Blennerhassett /* (dwDspAck will be changed to HIF_RESET) */ 1466719f82d3SEliot Blennerhassett interface->dsp_ack = H620_HIF_UNKNOWN; 1467719f82d3SEliot Blennerhassett wmb(); /* ensure ack is written before dsp writes back */ 1468719f82d3SEliot Blennerhassett 1469719f82d3SEliot Blennerhassett err = hpios_locked_mem_get_phys_addr(&phw->h_locked_mem, 1470719f82d3SEliot Blennerhassett &physicalPC_iaddress); 1471719f82d3SEliot Blennerhassett 1472719f82d3SEliot Blennerhassett /* locate the host mailbox on the DSP. */ 1473719f82d3SEliot Blennerhassett host_mailbox_address_on_dsp = 0x80000000; 1474719f82d3SEliot Blennerhassett while ((physicalPC_iaddress != physicalPC_iaddress_verify) 1475719f82d3SEliot Blennerhassett && time_out--) { 14763285ea10SEliot Blennerhassett boot_loader_write_mem32(pao, 0, 1477719f82d3SEliot Blennerhassett host_mailbox_address_on_dsp, 1478719f82d3SEliot Blennerhassett physicalPC_iaddress); 1479719f82d3SEliot Blennerhassett physicalPC_iaddress_verify = 1480719f82d3SEliot Blennerhassett boot_loader_read_mem32(pao, 0, 1481719f82d3SEliot Blennerhassett host_mailbox_address_on_dsp); 1482719f82d3SEliot Blennerhassett } 1483719f82d3SEliot Blennerhassett } 1484719f82d3SEliot Blennerhassett HPI_DEBUG_LOG(DEBUG, "starting DS_ps running\n"); 1485719f82d3SEliot Blennerhassett /* enable interrupts */ 1486719f82d3SEliot Blennerhassett temp = ioread32(phw->prHSR); 1487719f82d3SEliot Blennerhassett temp &= ~(u32)C6205_HSR_INTAM; 1488719f82d3SEliot Blennerhassett iowrite32(temp, phw->prHSR); 1489719f82d3SEliot Blennerhassett 1490719f82d3SEliot Blennerhassett /* start code running... */ 1491719f82d3SEliot Blennerhassett temp = ioread32(phw->prHDCR); 1492719f82d3SEliot Blennerhassett temp |= (u32)C6205_HDCR_DSPINT; 1493719f82d3SEliot Blennerhassett iowrite32(temp, phw->prHDCR); 1494719f82d3SEliot Blennerhassett 1495719f82d3SEliot Blennerhassett /* give the DSP 10ms to start up */ 1496719f82d3SEliot Blennerhassett hpios_delay_micro_seconds(10000); 1497719f82d3SEliot Blennerhassett return err; 1498719f82d3SEliot Blennerhassett 1499719f82d3SEliot Blennerhassett } 1500719f82d3SEliot Blennerhassett 1501719f82d3SEliot Blennerhassett /*****************************************************************************/ 1502719f82d3SEliot Blennerhassett /* Bootloader utility functions */ 1503719f82d3SEliot Blennerhassett 1504719f82d3SEliot Blennerhassett static u32 boot_loader_read_mem32(struct hpi_adapter_obj *pao, int dsp_index, 1505719f82d3SEliot Blennerhassett u32 address) 1506719f82d3SEliot Blennerhassett { 1507719f82d3SEliot Blennerhassett struct hpi_hw_obj *phw = pao->priv; 1508719f82d3SEliot Blennerhassett u32 data = 0; 1509719f82d3SEliot Blennerhassett __iomem u32 *p_data; 1510719f82d3SEliot Blennerhassett 1511719f82d3SEliot Blennerhassett if (dsp_index == 0) { 1512719f82d3SEliot Blennerhassett /* DSP 0 is always C6205 */ 1513719f82d3SEliot Blennerhassett if ((address >= 0x01800000) & (address < 0x02000000)) { 1514719f82d3SEliot Blennerhassett /* BAR1 register access */ 1515719f82d3SEliot Blennerhassett p_data = pao->pci.ap_mem_base[1] + 1516719f82d3SEliot Blennerhassett (address & 0x007fffff) / 1517719f82d3SEliot Blennerhassett sizeof(*pao->pci.ap_mem_base[1]); 1518719f82d3SEliot Blennerhassett /* HPI_DEBUG_LOG(WARNING, 1519719f82d3SEliot Blennerhassett "BAR1 access %08x\n", dwAddress); */ 1520719f82d3SEliot Blennerhassett } else { 1521719f82d3SEliot Blennerhassett u32 dw4M_page = address >> 22L; 1522719f82d3SEliot Blennerhassett if (dw4M_page != phw->dsp_page) { 1523719f82d3SEliot Blennerhassett phw->dsp_page = dw4M_page; 1524719f82d3SEliot Blennerhassett /* *INDENT OFF* */ 1525719f82d3SEliot Blennerhassett iowrite32(phw->dsp_page, phw->prDSPP); 1526719f82d3SEliot Blennerhassett /* *INDENT-ON* */ 1527719f82d3SEliot Blennerhassett } 1528719f82d3SEliot Blennerhassett address &= 0x3fffff; /* address within 4M page */ 1529719f82d3SEliot Blennerhassett /* BAR0 memory access */ 1530719f82d3SEliot Blennerhassett p_data = pao->pci.ap_mem_base[0] + 1531719f82d3SEliot Blennerhassett address / sizeof(u32); 1532719f82d3SEliot Blennerhassett } 1533719f82d3SEliot Blennerhassett data = ioread32(p_data); 1534719f82d3SEliot Blennerhassett } else if (dsp_index == 1) { 1535719f82d3SEliot Blennerhassett /* DSP 1 is a C6713 */ 1536719f82d3SEliot Blennerhassett u32 lsb; 1537719f82d3SEliot Blennerhassett boot_loader_write_mem32(pao, 0, HPIAL_ADDR, address); 1538719f82d3SEliot Blennerhassett boot_loader_write_mem32(pao, 0, HPIAH_ADDR, address >> 16); 1539719f82d3SEliot Blennerhassett lsb = boot_loader_read_mem32(pao, 0, HPIDL_ADDR); 1540719f82d3SEliot Blennerhassett data = boot_loader_read_mem32(pao, 0, HPIDH_ADDR); 1541719f82d3SEliot Blennerhassett data = (data << 16) | (lsb & 0xFFFF); 1542719f82d3SEliot Blennerhassett } 1543719f82d3SEliot Blennerhassett return data; 1544719f82d3SEliot Blennerhassett } 1545719f82d3SEliot Blennerhassett 15463285ea10SEliot Blennerhassett static void boot_loader_write_mem32(struct hpi_adapter_obj *pao, 15473285ea10SEliot Blennerhassett int dsp_index, u32 address, u32 data) 1548719f82d3SEliot Blennerhassett { 1549719f82d3SEliot Blennerhassett struct hpi_hw_obj *phw = pao->priv; 1550719f82d3SEliot Blennerhassett __iomem u32 *p_data; 1551719f82d3SEliot Blennerhassett /* u32 dwVerifyData=0; */ 1552719f82d3SEliot Blennerhassett 1553719f82d3SEliot Blennerhassett if (dsp_index == 0) { 1554719f82d3SEliot Blennerhassett /* DSP 0 is always C6205 */ 1555719f82d3SEliot Blennerhassett if ((address >= 0x01800000) & (address < 0x02000000)) { 1556719f82d3SEliot Blennerhassett /* BAR1 - DSP register access using */ 1557719f82d3SEliot Blennerhassett /* Non-prefetchable PCI access */ 1558719f82d3SEliot Blennerhassett p_data = pao->pci.ap_mem_base[1] + 1559719f82d3SEliot Blennerhassett (address & 0x007fffff) / 1560719f82d3SEliot Blennerhassett sizeof(*pao->pci.ap_mem_base[1]); 1561719f82d3SEliot Blennerhassett } else { 1562719f82d3SEliot Blennerhassett /* BAR0 access - all of DSP memory using */ 1563719f82d3SEliot Blennerhassett /* pre-fetchable PCI access */ 1564719f82d3SEliot Blennerhassett u32 dw4M_page = address >> 22L; 1565719f82d3SEliot Blennerhassett if (dw4M_page != phw->dsp_page) { 1566719f82d3SEliot Blennerhassett phw->dsp_page = dw4M_page; 1567719f82d3SEliot Blennerhassett /* *INDENT-OFF* */ 1568719f82d3SEliot Blennerhassett iowrite32(phw->dsp_page, phw->prDSPP); 1569719f82d3SEliot Blennerhassett /* *INDENT-ON* */ 1570719f82d3SEliot Blennerhassett } 1571719f82d3SEliot Blennerhassett address &= 0x3fffff; /* address within 4M page */ 1572719f82d3SEliot Blennerhassett p_data = pao->pci.ap_mem_base[0] + 1573719f82d3SEliot Blennerhassett address / sizeof(u32); 1574719f82d3SEliot Blennerhassett } 1575719f82d3SEliot Blennerhassett iowrite32(data, p_data); 1576719f82d3SEliot Blennerhassett } else if (dsp_index == 1) { 1577719f82d3SEliot Blennerhassett /* DSP 1 is a C6713 */ 1578719f82d3SEliot Blennerhassett boot_loader_write_mem32(pao, 0, HPIAL_ADDR, address); 1579719f82d3SEliot Blennerhassett boot_loader_write_mem32(pao, 0, HPIAH_ADDR, address >> 16); 1580719f82d3SEliot Blennerhassett 1581719f82d3SEliot Blennerhassett /* dummy read every 4 words for 6205 advisory 1.4.4 */ 1582719f82d3SEliot Blennerhassett boot_loader_read_mem32(pao, 0, 0); 1583719f82d3SEliot Blennerhassett 1584719f82d3SEliot Blennerhassett boot_loader_write_mem32(pao, 0, HPIDL_ADDR, data); 1585719f82d3SEliot Blennerhassett boot_loader_write_mem32(pao, 0, HPIDH_ADDR, data >> 16); 1586719f82d3SEliot Blennerhassett 1587719f82d3SEliot Blennerhassett /* dummy read every 4 words for 6205 advisory 1.4.4 */ 1588719f82d3SEliot Blennerhassett boot_loader_read_mem32(pao, 0, 0); 15893285ea10SEliot Blennerhassett } 1590719f82d3SEliot Blennerhassett } 1591719f82d3SEliot Blennerhassett 1592719f82d3SEliot Blennerhassett static u16 boot_loader_config_emif(struct hpi_adapter_obj *pao, int dsp_index) 1593719f82d3SEliot Blennerhassett { 1594719f82d3SEliot Blennerhassett if (dsp_index == 0) { 1595719f82d3SEliot Blennerhassett u32 setting; 1596719f82d3SEliot Blennerhassett 1597719f82d3SEliot Blennerhassett /* DSP 0 is always C6205 */ 1598719f82d3SEliot Blennerhassett 1599719f82d3SEliot Blennerhassett /* Set the EMIF */ 1600719f82d3SEliot Blennerhassett /* memory map of C6205 */ 1601719f82d3SEliot Blennerhassett /* 00000000-0000FFFF 16Kx32 internal program */ 1602719f82d3SEliot Blennerhassett /* 00400000-00BFFFFF CE0 2Mx32 SDRAM running @ 100MHz */ 1603719f82d3SEliot Blennerhassett 1604719f82d3SEliot Blennerhassett /* EMIF config */ 1605719f82d3SEliot Blennerhassett /*------------ */ 1606719f82d3SEliot Blennerhassett /* Global EMIF control */ 1607719f82d3SEliot Blennerhassett boot_loader_write_mem32(pao, dsp_index, 0x01800000, 0x3779); 1608719f82d3SEliot Blennerhassett #define WS_OFS 28 1609719f82d3SEliot Blennerhassett #define WST_OFS 22 1610719f82d3SEliot Blennerhassett #define WH_OFS 20 1611719f82d3SEliot Blennerhassett #define RS_OFS 16 1612719f82d3SEliot Blennerhassett #define RST_OFS 8 1613719f82d3SEliot Blennerhassett #define MTYPE_OFS 4 1614719f82d3SEliot Blennerhassett #define RH_OFS 0 1615719f82d3SEliot Blennerhassett 1616719f82d3SEliot Blennerhassett /* EMIF CE0 setup - 2Mx32 Sync DRAM on ASI5000 cards only */ 1617719f82d3SEliot Blennerhassett setting = 0x00000030; 1618719f82d3SEliot Blennerhassett boot_loader_write_mem32(pao, dsp_index, 0x01800008, setting); 1619719f82d3SEliot Blennerhassett if (setting != boot_loader_read_mem32(pao, dsp_index, 1620719f82d3SEliot Blennerhassett 0x01800008)) 16213285ea10SEliot Blennerhassett return HPI6205_ERROR_DSP_EMIF; 1622719f82d3SEliot Blennerhassett 1623719f82d3SEliot Blennerhassett /* EMIF CE1 setup - 32 bit async. This is 6713 #1 HPI, */ 1624719f82d3SEliot Blennerhassett /* which occupies D15..0. 6713 starts at 27MHz, so need */ 1625719f82d3SEliot Blennerhassett /* plenty of wait states. See dsn8701.rtf, and 6713 errata. */ 1626719f82d3SEliot Blennerhassett /* WST should be 71, but 63 is max possible */ 1627719f82d3SEliot Blennerhassett setting = 1628719f82d3SEliot Blennerhassett (1L << WS_OFS) | (63L << WST_OFS) | (1L << WH_OFS) | 1629719f82d3SEliot Blennerhassett (1L << RS_OFS) | (63L << RST_OFS) | (1L << RH_OFS) | 1630719f82d3SEliot Blennerhassett (2L << MTYPE_OFS); 1631719f82d3SEliot Blennerhassett boot_loader_write_mem32(pao, dsp_index, 0x01800004, setting); 1632719f82d3SEliot Blennerhassett if (setting != boot_loader_read_mem32(pao, dsp_index, 1633719f82d3SEliot Blennerhassett 0x01800004)) 16343285ea10SEliot Blennerhassett return HPI6205_ERROR_DSP_EMIF; 1635719f82d3SEliot Blennerhassett 1636719f82d3SEliot Blennerhassett /* EMIF CE2 setup - 32 bit async. This is 6713 #2 HPI, */ 1637719f82d3SEliot Blennerhassett /* which occupies D15..0. 6713 starts at 27MHz, so need */ 1638719f82d3SEliot Blennerhassett /* plenty of wait states */ 1639719f82d3SEliot Blennerhassett setting = 1640719f82d3SEliot Blennerhassett (1L << WS_OFS) | (28L << WST_OFS) | (1L << WH_OFS) | 1641719f82d3SEliot Blennerhassett (1L << RS_OFS) | (63L << RST_OFS) | (1L << RH_OFS) | 1642719f82d3SEliot Blennerhassett (2L << MTYPE_OFS); 1643719f82d3SEliot Blennerhassett boot_loader_write_mem32(pao, dsp_index, 0x01800010, setting); 1644719f82d3SEliot Blennerhassett if (setting != boot_loader_read_mem32(pao, dsp_index, 1645719f82d3SEliot Blennerhassett 0x01800010)) 16463285ea10SEliot Blennerhassett return HPI6205_ERROR_DSP_EMIF; 1647719f82d3SEliot Blennerhassett 1648719f82d3SEliot Blennerhassett /* EMIF CE3 setup - 32 bit async. */ 1649719f82d3SEliot Blennerhassett /* This is the PLD on the ASI5000 cards only */ 1650719f82d3SEliot Blennerhassett setting = 1651719f82d3SEliot Blennerhassett (1L << WS_OFS) | (10L << WST_OFS) | (1L << WH_OFS) | 1652719f82d3SEliot Blennerhassett (1L << RS_OFS) | (10L << RST_OFS) | (1L << RH_OFS) | 1653719f82d3SEliot Blennerhassett (2L << MTYPE_OFS); 1654719f82d3SEliot Blennerhassett boot_loader_write_mem32(pao, dsp_index, 0x01800014, setting); 1655719f82d3SEliot Blennerhassett if (setting != boot_loader_read_mem32(pao, dsp_index, 1656719f82d3SEliot Blennerhassett 0x01800014)) 16573285ea10SEliot Blennerhassett return HPI6205_ERROR_DSP_EMIF; 1658719f82d3SEliot Blennerhassett 1659719f82d3SEliot Blennerhassett /* set EMIF SDRAM control for 2Mx32 SDRAM (512x32x4 bank) */ 1660719f82d3SEliot Blennerhassett /* need to use this else DSP code crashes? */ 1661719f82d3SEliot Blennerhassett boot_loader_write_mem32(pao, dsp_index, 0x01800018, 1662719f82d3SEliot Blennerhassett 0x07117000); 1663719f82d3SEliot Blennerhassett 1664719f82d3SEliot Blennerhassett /* EMIF SDRAM Refresh Timing */ 1665719f82d3SEliot Blennerhassett /* EMIF SDRAM timing (orig = 0x410, emulator = 0x61a) */ 1666719f82d3SEliot Blennerhassett boot_loader_write_mem32(pao, dsp_index, 0x0180001C, 1667719f82d3SEliot Blennerhassett 0x00000410); 1668719f82d3SEliot Blennerhassett 1669719f82d3SEliot Blennerhassett } else if (dsp_index == 1) { 1670719f82d3SEliot Blennerhassett /* test access to the C6713s HPI registers */ 1671719f82d3SEliot Blennerhassett u32 write_data = 0, read_data = 0, i = 0; 1672719f82d3SEliot Blennerhassett 1673719f82d3SEliot Blennerhassett /* Set up HPIC for little endian, by setiing HPIC:HWOB=1 */ 1674719f82d3SEliot Blennerhassett write_data = 1; 1675719f82d3SEliot Blennerhassett boot_loader_write_mem32(pao, 0, HPICL_ADDR, write_data); 1676719f82d3SEliot Blennerhassett boot_loader_write_mem32(pao, 0, HPICH_ADDR, write_data); 1677719f82d3SEliot Blennerhassett /* C67 HPI is on lower 16bits of 32bit EMIF */ 1678719f82d3SEliot Blennerhassett read_data = 1679719f82d3SEliot Blennerhassett 0xFFF7 & boot_loader_read_mem32(pao, 0, HPICL_ADDR); 1680719f82d3SEliot Blennerhassett if (write_data != read_data) { 1681719f82d3SEliot Blennerhassett HPI_DEBUG_LOG(ERROR, "HPICL %x %x\n", write_data, 1682719f82d3SEliot Blennerhassett read_data); 16833285ea10SEliot Blennerhassett return HPI6205_ERROR_C6713_HPIC; 1684719f82d3SEliot Blennerhassett } 1685719f82d3SEliot Blennerhassett /* HPIA - walking ones test */ 1686719f82d3SEliot Blennerhassett write_data = 1; 1687719f82d3SEliot Blennerhassett for (i = 0; i < 32; i++) { 1688719f82d3SEliot Blennerhassett boot_loader_write_mem32(pao, 0, HPIAL_ADDR, 1689719f82d3SEliot Blennerhassett write_data); 1690719f82d3SEliot Blennerhassett boot_loader_write_mem32(pao, 0, HPIAH_ADDR, 1691719f82d3SEliot Blennerhassett (write_data >> 16)); 1692719f82d3SEliot Blennerhassett read_data = 1693719f82d3SEliot Blennerhassett 0xFFFF & boot_loader_read_mem32(pao, 0, 1694719f82d3SEliot Blennerhassett HPIAL_ADDR); 1695719f82d3SEliot Blennerhassett read_data = 1696719f82d3SEliot Blennerhassett read_data | ((0xFFFF & 1697719f82d3SEliot Blennerhassett boot_loader_read_mem32(pao, 0, 1698719f82d3SEliot Blennerhassett HPIAH_ADDR)) 1699719f82d3SEliot Blennerhassett << 16); 1700719f82d3SEliot Blennerhassett if (read_data != write_data) { 1701719f82d3SEliot Blennerhassett HPI_DEBUG_LOG(ERROR, "HPIA %x %x\n", 1702719f82d3SEliot Blennerhassett write_data, read_data); 17033285ea10SEliot Blennerhassett return HPI6205_ERROR_C6713_HPIA; 1704719f82d3SEliot Blennerhassett } 1705719f82d3SEliot Blennerhassett write_data = write_data << 1; 1706719f82d3SEliot Blennerhassett } 1707719f82d3SEliot Blennerhassett 1708719f82d3SEliot Blennerhassett /* setup C67x PLL 1709719f82d3SEliot Blennerhassett * ** C6713 datasheet says we cannot program PLL from HPI, 1710719f82d3SEliot Blennerhassett * and indeed if we try to set the PLL multiply from the HPI, 1711719f82d3SEliot Blennerhassett * the PLL does not seem to lock, so we enable the PLL and 1712719f82d3SEliot Blennerhassett * use the default multiply of x 7, which for a 27MHz clock 1713719f82d3SEliot Blennerhassett * gives a DSP speed of 189MHz 1714719f82d3SEliot Blennerhassett */ 1715719f82d3SEliot Blennerhassett /* bypass PLL */ 1716719f82d3SEliot Blennerhassett boot_loader_write_mem32(pao, dsp_index, 0x01B7C100, 0x0000); 1717719f82d3SEliot Blennerhassett hpios_delay_micro_seconds(1000); 1718719f82d3SEliot Blennerhassett /* EMIF = 189/3=63MHz */ 1719719f82d3SEliot Blennerhassett boot_loader_write_mem32(pao, dsp_index, 0x01B7C120, 0x8002); 1720719f82d3SEliot Blennerhassett /* peri = 189/2 */ 1721719f82d3SEliot Blennerhassett boot_loader_write_mem32(pao, dsp_index, 0x01B7C11C, 0x8001); 1722719f82d3SEliot Blennerhassett /* cpu = 189/1 */ 1723719f82d3SEliot Blennerhassett boot_loader_write_mem32(pao, dsp_index, 0x01B7C118, 0x8000); 1724719f82d3SEliot Blennerhassett hpios_delay_micro_seconds(1000); 1725719f82d3SEliot Blennerhassett /* ** SGT test to take GPO3 high when we start the PLL */ 1726719f82d3SEliot Blennerhassett /* and low when the delay is completed */ 1727719f82d3SEliot Blennerhassett /* FSX0 <- '1' (GPO3) */ 1728719f82d3SEliot Blennerhassett boot_loader_write_mem32(pao, 0, (0x018C0024L), 0x00002A0A); 1729719f82d3SEliot Blennerhassett /* PLL not bypassed */ 1730719f82d3SEliot Blennerhassett boot_loader_write_mem32(pao, dsp_index, 0x01B7C100, 0x0001); 1731719f82d3SEliot Blennerhassett hpios_delay_micro_seconds(1000); 1732719f82d3SEliot Blennerhassett /* FSX0 <- '0' (GPO3) */ 1733719f82d3SEliot Blennerhassett boot_loader_write_mem32(pao, 0, (0x018C0024L), 0x00002A02); 1734719f82d3SEliot Blennerhassett 1735719f82d3SEliot Blennerhassett /* 6205 EMIF CE1 resetup - 32 bit async. */ 1736719f82d3SEliot Blennerhassett /* Now 6713 #1 is running at 189MHz can reduce waitstates */ 1737719f82d3SEliot Blennerhassett boot_loader_write_mem32(pao, 0, 0x01800004, /* CE1 */ 1738719f82d3SEliot Blennerhassett (1L << WS_OFS) | (8L << WST_OFS) | (1L << WH_OFS) | 1739719f82d3SEliot Blennerhassett (1L << RS_OFS) | (12L << RST_OFS) | (1L << RH_OFS) | 1740719f82d3SEliot Blennerhassett (2L << MTYPE_OFS)); 1741719f82d3SEliot Blennerhassett 1742719f82d3SEliot Blennerhassett hpios_delay_micro_seconds(1000); 1743719f82d3SEliot Blennerhassett 1744719f82d3SEliot Blennerhassett /* check that we can read one of the PLL registers */ 1745719f82d3SEliot Blennerhassett /* PLL should not be bypassed! */ 1746719f82d3SEliot Blennerhassett if ((boot_loader_read_mem32(pao, dsp_index, 0x01B7C100) & 0xF) 1747719f82d3SEliot Blennerhassett != 0x0001) { 17483285ea10SEliot Blennerhassett return HPI6205_ERROR_C6713_PLL; 1749719f82d3SEliot Blennerhassett } 1750719f82d3SEliot Blennerhassett /* setup C67x EMIF (note this is the only use of 1751719f82d3SEliot Blennerhassett BAR1 via BootLoader_WriteMem32) */ 1752719f82d3SEliot Blennerhassett boot_loader_write_mem32(pao, dsp_index, C6713_EMIF_GCTL, 1753719f82d3SEliot Blennerhassett 0x000034A8); 17541d595d2aSEliot Blennerhassett 17551d595d2aSEliot Blennerhassett /* EMIF CE0 setup - 2Mx32 Sync DRAM 17561d595d2aSEliot Blennerhassett 31..28 Wr setup 17571d595d2aSEliot Blennerhassett 27..22 Wr strobe 17581d595d2aSEliot Blennerhassett 21..20 Wr hold 17591d595d2aSEliot Blennerhassett 19..16 Rd setup 17601d595d2aSEliot Blennerhassett 15..14 - 17611d595d2aSEliot Blennerhassett 13..8 Rd strobe 17621d595d2aSEliot Blennerhassett 7..4 MTYPE 0011 Sync DRAM 32bits 17631d595d2aSEliot Blennerhassett 3 Wr hold MSB 17641d595d2aSEliot Blennerhassett 2..0 Rd hold 17651d595d2aSEliot Blennerhassett */ 1766719f82d3SEliot Blennerhassett boot_loader_write_mem32(pao, dsp_index, C6713_EMIF_CE0, 1767719f82d3SEliot Blennerhassett 0x00000030); 17681d595d2aSEliot Blennerhassett 17691d595d2aSEliot Blennerhassett /* EMIF SDRAM Extension 17701d595d2aSEliot Blennerhassett 0x00 17711d595d2aSEliot Blennerhassett 31-21 0000b 0000b 000b 17721d595d2aSEliot Blennerhassett 20 WR2RD = 2cycles-1 = 1b 17731d595d2aSEliot Blennerhassett 17741d595d2aSEliot Blennerhassett 19-18 WR2DEAC = 3cycle-1 = 10b 17751d595d2aSEliot Blennerhassett 17 WR2WR = 2cycle-1 = 1b 17761d595d2aSEliot Blennerhassett 16-15 R2WDQM = 4cycle-1 = 11b 17771d595d2aSEliot Blennerhassett 14-12 RD2WR = 6cycles-1 = 101b 17781d595d2aSEliot Blennerhassett 17791d595d2aSEliot Blennerhassett 11-10 RD2DEAC = 4cycle-1 = 11b 17801d595d2aSEliot Blennerhassett 9 RD2RD = 2cycle-1 = 1b 17811d595d2aSEliot Blennerhassett 8-7 THZP = 3cycle-1 = 10b 17821d595d2aSEliot Blennerhassett 6-5 TWR = 2cycle-1 = 01b (tWR = 17ns) 17831d595d2aSEliot Blennerhassett 4 TRRD = 2cycle = 0b (tRRD = 14ns) 17841d595d2aSEliot Blennerhassett 3-1 TRAS = 5cycle-1 = 100b (Tras=42ns) 17851d595d2aSEliot Blennerhassett 1 CAS latency = 3cyc = 1b 17861d595d2aSEliot Blennerhassett (for Micron 2M32-7 operating at 100MHz) 17871d595d2aSEliot Blennerhassett */ 1788719f82d3SEliot Blennerhassett boot_loader_write_mem32(pao, dsp_index, C6713_EMIF_SDRAMEXT, 1789719f82d3SEliot Blennerhassett 0x001BDF29); 17901d595d2aSEliot Blennerhassett 17911d595d2aSEliot Blennerhassett /* EMIF SDRAM control - set up for a 2Mx32 SDRAM (512x32x4 bank) 17921d595d2aSEliot Blennerhassett 31 - 0b - 17931d595d2aSEliot Blennerhassett 30 SDBSZ 1b 4 bank 17941d595d2aSEliot Blennerhassett 29..28 SDRSZ 00b 11 row address pins 17951d595d2aSEliot Blennerhassett 17961d595d2aSEliot Blennerhassett 27..26 SDCSZ 01b 8 column address pins 17971d595d2aSEliot Blennerhassett 25 RFEN 1b refersh enabled 17981d595d2aSEliot Blennerhassett 24 INIT 1b init SDRAM! 17991d595d2aSEliot Blennerhassett 18001d595d2aSEliot Blennerhassett 23..20 TRCD 0001b (Trcd/Tcyc)-1 = (20/10)-1 = 1 18011d595d2aSEliot Blennerhassett 18021d595d2aSEliot Blennerhassett 19..16 TRP 0001b (Trp/Tcyc)-1 = (20/10)-1 = 1 18031d595d2aSEliot Blennerhassett 18041d595d2aSEliot Blennerhassett 15..12 TRC 0110b (Trc/Tcyc)-1 = (70/10)-1 = 6 18051d595d2aSEliot Blennerhassett 18061d595d2aSEliot Blennerhassett 11..0 - 0000b 0000b 0000b 18071d595d2aSEliot Blennerhassett */ 1808719f82d3SEliot Blennerhassett boot_loader_write_mem32(pao, dsp_index, C6713_EMIF_SDRAMCTL, 18091d595d2aSEliot Blennerhassett 0x47116000); 18101d595d2aSEliot Blennerhassett 18111d595d2aSEliot Blennerhassett /* SDRAM refresh timing 18121d595d2aSEliot Blennerhassett Need 4,096 refresh cycles every 64ms = 15.625us = 1562cycles of 100MHz = 0x61A 18131d595d2aSEliot Blennerhassett */ 1814719f82d3SEliot Blennerhassett boot_loader_write_mem32(pao, dsp_index, 1815719f82d3SEliot Blennerhassett C6713_EMIF_SDRAMTIMING, 0x00000410); 1816719f82d3SEliot Blennerhassett 1817719f82d3SEliot Blennerhassett hpios_delay_micro_seconds(1000); 1818719f82d3SEliot Blennerhassett } else if (dsp_index == 2) { 1819719f82d3SEliot Blennerhassett /* DSP 2 is a C6713 */ 18203285ea10SEliot Blennerhassett } 1821719f82d3SEliot Blennerhassett 18223285ea10SEliot Blennerhassett return 0; 1823719f82d3SEliot Blennerhassett } 1824719f82d3SEliot Blennerhassett 1825719f82d3SEliot Blennerhassett static u16 boot_loader_test_memory(struct hpi_adapter_obj *pao, int dsp_index, 1826719f82d3SEliot Blennerhassett u32 start_address, u32 length) 1827719f82d3SEliot Blennerhassett { 1828719f82d3SEliot Blennerhassett u32 i = 0, j = 0; 1829719f82d3SEliot Blennerhassett u32 test_addr = 0; 1830719f82d3SEliot Blennerhassett u32 test_data = 0, data = 0; 1831719f82d3SEliot Blennerhassett 1832719f82d3SEliot Blennerhassett length = 1000; 1833719f82d3SEliot Blennerhassett 1834719f82d3SEliot Blennerhassett /* for 1st word, test each bit in the 32bit word, */ 1835719f82d3SEliot Blennerhassett /* dwLength specifies number of 32bit words to test */ 1836719f82d3SEliot Blennerhassett /*for(i=0; i<dwLength; i++) */ 1837719f82d3SEliot Blennerhassett i = 0; 1838719f82d3SEliot Blennerhassett { 1839719f82d3SEliot Blennerhassett test_addr = start_address + i * 4; 1840719f82d3SEliot Blennerhassett test_data = 0x00000001; 1841719f82d3SEliot Blennerhassett for (j = 0; j < 32; j++) { 1842719f82d3SEliot Blennerhassett boot_loader_write_mem32(pao, dsp_index, test_addr, 1843719f82d3SEliot Blennerhassett test_data); 1844719f82d3SEliot Blennerhassett data = boot_loader_read_mem32(pao, dsp_index, 1845719f82d3SEliot Blennerhassett test_addr); 1846719f82d3SEliot Blennerhassett if (data != test_data) { 1847719f82d3SEliot Blennerhassett HPI_DEBUG_LOG(VERBOSE, 18483285ea10SEliot Blennerhassett "Memtest error details " 1849719f82d3SEliot Blennerhassett "%08x %08x %08x %i\n", test_addr, 1850719f82d3SEliot Blennerhassett test_data, data, dsp_index); 1851719f82d3SEliot Blennerhassett return 1; /* error */ 1852719f82d3SEliot Blennerhassett } 1853719f82d3SEliot Blennerhassett test_data = test_data << 1; 1854719f82d3SEliot Blennerhassett } /* for(j) */ 1855719f82d3SEliot Blennerhassett } /* for(i) */ 1856719f82d3SEliot Blennerhassett 1857719f82d3SEliot Blennerhassett /* for the next 100 locations test each location, leaving it as zero */ 1858719f82d3SEliot Blennerhassett /* write a zero to the next word in memory before we read */ 1859719f82d3SEliot Blennerhassett /* the previous write to make sure every memory location is unique */ 1860719f82d3SEliot Blennerhassett for (i = 0; i < 100; i++) { 1861719f82d3SEliot Blennerhassett test_addr = start_address + i * 4; 1862719f82d3SEliot Blennerhassett test_data = 0xA5A55A5A; 1863719f82d3SEliot Blennerhassett boot_loader_write_mem32(pao, dsp_index, test_addr, test_data); 1864719f82d3SEliot Blennerhassett boot_loader_write_mem32(pao, dsp_index, test_addr + 4, 0); 1865719f82d3SEliot Blennerhassett data = boot_loader_read_mem32(pao, dsp_index, test_addr); 1866719f82d3SEliot Blennerhassett if (data != test_data) { 1867719f82d3SEliot Blennerhassett HPI_DEBUG_LOG(VERBOSE, 18683285ea10SEliot Blennerhassett "Memtest error details " 1869719f82d3SEliot Blennerhassett "%08x %08x %08x %i\n", test_addr, test_data, 1870719f82d3SEliot Blennerhassett data, dsp_index); 1871719f82d3SEliot Blennerhassett return 1; /* error */ 1872719f82d3SEliot Blennerhassett } 1873719f82d3SEliot Blennerhassett /* leave location as zero */ 1874719f82d3SEliot Blennerhassett boot_loader_write_mem32(pao, dsp_index, test_addr, 0x0); 1875719f82d3SEliot Blennerhassett } 1876719f82d3SEliot Blennerhassett 1877719f82d3SEliot Blennerhassett /* zero out entire memory block */ 1878719f82d3SEliot Blennerhassett for (i = 0; i < length; i++) { 1879719f82d3SEliot Blennerhassett test_addr = start_address + i * 4; 1880719f82d3SEliot Blennerhassett boot_loader_write_mem32(pao, dsp_index, test_addr, 0x0); 1881719f82d3SEliot Blennerhassett } 1882719f82d3SEliot Blennerhassett return 0; 1883719f82d3SEliot Blennerhassett } 1884719f82d3SEliot Blennerhassett 1885719f82d3SEliot Blennerhassett static u16 boot_loader_test_internal_memory(struct hpi_adapter_obj *pao, 1886719f82d3SEliot Blennerhassett int dsp_index) 1887719f82d3SEliot Blennerhassett { 1888719f82d3SEliot Blennerhassett int err = 0; 1889719f82d3SEliot Blennerhassett if (dsp_index == 0) { 1890719f82d3SEliot Blennerhassett /* DSP 0 is a C6205 */ 1891719f82d3SEliot Blennerhassett /* 64K prog mem */ 1892719f82d3SEliot Blennerhassett err = boot_loader_test_memory(pao, dsp_index, 0x00000000, 1893719f82d3SEliot Blennerhassett 0x10000); 1894719f82d3SEliot Blennerhassett if (!err) 1895719f82d3SEliot Blennerhassett /* 64K data mem */ 1896719f82d3SEliot Blennerhassett err = boot_loader_test_memory(pao, dsp_index, 1897719f82d3SEliot Blennerhassett 0x80000000, 0x10000); 18983285ea10SEliot Blennerhassett } else if (dsp_index == 1) { 18993285ea10SEliot Blennerhassett /* DSP 1 is a C6713 */ 1900719f82d3SEliot Blennerhassett /* 192K internal mem */ 1901719f82d3SEliot Blennerhassett err = boot_loader_test_memory(pao, dsp_index, 0x00000000, 1902719f82d3SEliot Blennerhassett 0x30000); 1903719f82d3SEliot Blennerhassett if (!err) 1904719f82d3SEliot Blennerhassett /* 64K internal mem / L2 cache */ 1905719f82d3SEliot Blennerhassett err = boot_loader_test_memory(pao, dsp_index, 1906719f82d3SEliot Blennerhassett 0x00030000, 0x10000); 19073285ea10SEliot Blennerhassett } 1908719f82d3SEliot Blennerhassett 1909719f82d3SEliot Blennerhassett if (err) 19103285ea10SEliot Blennerhassett return HPI6205_ERROR_DSP_INTMEM; 1911719f82d3SEliot Blennerhassett else 1912719f82d3SEliot Blennerhassett return 0; 1913719f82d3SEliot Blennerhassett } 1914719f82d3SEliot Blennerhassett 1915719f82d3SEliot Blennerhassett static u16 boot_loader_test_external_memory(struct hpi_adapter_obj *pao, 1916719f82d3SEliot Blennerhassett int dsp_index) 1917719f82d3SEliot Blennerhassett { 1918719f82d3SEliot Blennerhassett u32 dRAM_start_address = 0; 1919719f82d3SEliot Blennerhassett u32 dRAM_size = 0; 1920719f82d3SEliot Blennerhassett 1921719f82d3SEliot Blennerhassett if (dsp_index == 0) { 1922719f82d3SEliot Blennerhassett /* only test for SDRAM if an ASI5000 card */ 19233285ea10SEliot Blennerhassett if (pao->pci.pci_dev->subsystem_device == 0x5000) { 1924719f82d3SEliot Blennerhassett /* DSP 0 is always C6205 */ 1925719f82d3SEliot Blennerhassett dRAM_start_address = 0x00400000; 1926719f82d3SEliot Blennerhassett dRAM_size = 0x200000; 1927719f82d3SEliot Blennerhassett /*dwDRAMinc=1024; */ 1928719f82d3SEliot Blennerhassett } else 1929719f82d3SEliot Blennerhassett return 0; 19303285ea10SEliot Blennerhassett } else if (dsp_index == 1) { 1931719f82d3SEliot Blennerhassett /* DSP 1 is a C6713 */ 1932719f82d3SEliot Blennerhassett dRAM_start_address = 0x80000000; 1933719f82d3SEliot Blennerhassett dRAM_size = 0x200000; 1934719f82d3SEliot Blennerhassett /*dwDRAMinc=1024; */ 19353285ea10SEliot Blennerhassett } 1936719f82d3SEliot Blennerhassett 1937719f82d3SEliot Blennerhassett if (boot_loader_test_memory(pao, dsp_index, dRAM_start_address, 1938719f82d3SEliot Blennerhassett dRAM_size)) 19393285ea10SEliot Blennerhassett return HPI6205_ERROR_DSP_EXTMEM; 1940719f82d3SEliot Blennerhassett return 0; 1941719f82d3SEliot Blennerhassett } 1942719f82d3SEliot Blennerhassett 1943719f82d3SEliot Blennerhassett static u16 boot_loader_test_pld(struct hpi_adapter_obj *pao, int dsp_index) 1944719f82d3SEliot Blennerhassett { 1945719f82d3SEliot Blennerhassett u32 data = 0; 1946719f82d3SEliot Blennerhassett if (dsp_index == 0) { 1947719f82d3SEliot Blennerhassett /* only test for DSP0 PLD on ASI5000 card */ 19483285ea10SEliot Blennerhassett if (pao->pci.pci_dev->subsystem_device == 0x5000) { 1949719f82d3SEliot Blennerhassett /* PLD is located at CE3=0x03000000 */ 1950719f82d3SEliot Blennerhassett data = boot_loader_read_mem32(pao, dsp_index, 1951719f82d3SEliot Blennerhassett 0x03000008); 1952719f82d3SEliot Blennerhassett if ((data & 0xF) != 0x5) 19533285ea10SEliot Blennerhassett return HPI6205_ERROR_DSP_PLD; 1954719f82d3SEliot Blennerhassett data = boot_loader_read_mem32(pao, dsp_index, 1955719f82d3SEliot Blennerhassett 0x0300000C); 1956719f82d3SEliot Blennerhassett if ((data & 0xF) != 0xA) 19573285ea10SEliot Blennerhassett return HPI6205_ERROR_DSP_PLD; 1958719f82d3SEliot Blennerhassett } 1959719f82d3SEliot Blennerhassett } else if (dsp_index == 1) { 1960719f82d3SEliot Blennerhassett /* DSP 1 is a C6713 */ 19613285ea10SEliot Blennerhassett if (pao->pci.pci_dev->subsystem_device == 0x8700) { 1962719f82d3SEliot Blennerhassett /* PLD is located at CE1=0x90000000 */ 1963719f82d3SEliot Blennerhassett data = boot_loader_read_mem32(pao, dsp_index, 1964719f82d3SEliot Blennerhassett 0x90000010); 1965719f82d3SEliot Blennerhassett if ((data & 0xFF) != 0xAA) 19663285ea10SEliot Blennerhassett return HPI6205_ERROR_DSP_PLD; 1967719f82d3SEliot Blennerhassett /* 8713 - LED on */ 1968719f82d3SEliot Blennerhassett boot_loader_write_mem32(pao, dsp_index, 0x90000000, 1969719f82d3SEliot Blennerhassett 0x02); 1970719f82d3SEliot Blennerhassett } 1971719f82d3SEliot Blennerhassett } 1972719f82d3SEliot Blennerhassett return 0; 1973719f82d3SEliot Blennerhassett } 1974719f82d3SEliot Blennerhassett 1975719f82d3SEliot Blennerhassett /** Transfer data to or from DSP 1976719f82d3SEliot Blennerhassett nOperation = H620_H620_HIF_SEND_DATA or H620_HIF_GET_DATA 1977719f82d3SEliot Blennerhassett */ 1978719f82d3SEliot Blennerhassett static short hpi6205_transfer_data(struct hpi_adapter_obj *pao, u8 *p_data, 1979719f82d3SEliot Blennerhassett u32 data_size, int operation) 1980719f82d3SEliot Blennerhassett { 1981719f82d3SEliot Blennerhassett struct hpi_hw_obj *phw = pao->priv; 1982719f82d3SEliot Blennerhassett u32 data_transferred = 0; 1983719f82d3SEliot Blennerhassett u16 err = 0; 1984719f82d3SEliot Blennerhassett u32 temp2; 1985719f82d3SEliot Blennerhassett struct bus_master_interface *interface = phw->p_interface_buffer; 1986719f82d3SEliot Blennerhassett 1987719f82d3SEliot Blennerhassett if (!p_data) 1988deb21a23SEliot Blennerhassett return HPI_ERROR_INVALID_DATA_POINTER; 1989719f82d3SEliot Blennerhassett 1990719f82d3SEliot Blennerhassett data_size &= ~3L; /* round data_size down to nearest 4 bytes */ 1991719f82d3SEliot Blennerhassett 1992719f82d3SEliot Blennerhassett /* make sure state is IDLE */ 1993719f82d3SEliot Blennerhassett if (!wait_dsp_ack(phw, H620_HIF_IDLE, HPI6205_TIMEOUT)) 1994719f82d3SEliot Blennerhassett return HPI_ERROR_DSP_HARDWARE; 1995719f82d3SEliot Blennerhassett 1996719f82d3SEliot Blennerhassett while (data_transferred < data_size) { 1997719f82d3SEliot Blennerhassett u32 this_copy = data_size - data_transferred; 1998719f82d3SEliot Blennerhassett 1999719f82d3SEliot Blennerhassett if (this_copy > HPI6205_SIZEOF_DATA) 2000719f82d3SEliot Blennerhassett this_copy = HPI6205_SIZEOF_DATA; 2001719f82d3SEliot Blennerhassett 2002719f82d3SEliot Blennerhassett if (operation == H620_HIF_SEND_DATA) 2003719f82d3SEliot Blennerhassett memcpy((void *)&interface->u.b_data[0], 2004719f82d3SEliot Blennerhassett &p_data[data_transferred], this_copy); 2005719f82d3SEliot Blennerhassett 2006719f82d3SEliot Blennerhassett interface->transfer_size_in_bytes = this_copy; 2007719f82d3SEliot Blennerhassett 2008719f82d3SEliot Blennerhassett /* DSP must change this back to nOperation */ 2009719f82d3SEliot Blennerhassett interface->dsp_ack = H620_HIF_IDLE; 2010719f82d3SEliot Blennerhassett send_dsp_command(phw, operation); 2011719f82d3SEliot Blennerhassett 2012719f82d3SEliot Blennerhassett temp2 = wait_dsp_ack(phw, operation, HPI6205_TIMEOUT); 2013719f82d3SEliot Blennerhassett HPI_DEBUG_LOG(DEBUG, "spun %d times for data xfer of %d\n", 2014719f82d3SEliot Blennerhassett HPI6205_TIMEOUT - temp2, this_copy); 2015719f82d3SEliot Blennerhassett 2016719f82d3SEliot Blennerhassett if (!temp2) { 2017719f82d3SEliot Blennerhassett /* timed out */ 2018719f82d3SEliot Blennerhassett HPI_DEBUG_LOG(ERROR, 20193285ea10SEliot Blennerhassett "Timed out waiting for " "state %d got %d\n", 2020719f82d3SEliot Blennerhassett operation, interface->dsp_ack); 2021719f82d3SEliot Blennerhassett 2022719f82d3SEliot Blennerhassett break; 2023719f82d3SEliot Blennerhassett } 2024719f82d3SEliot Blennerhassett if (operation == H620_HIF_GET_DATA) 2025719f82d3SEliot Blennerhassett memcpy(&p_data[data_transferred], 2026719f82d3SEliot Blennerhassett (void *)&interface->u.b_data[0], this_copy); 2027719f82d3SEliot Blennerhassett 2028719f82d3SEliot Blennerhassett data_transferred += this_copy; 2029719f82d3SEliot Blennerhassett } 2030719f82d3SEliot Blennerhassett if (interface->dsp_ack != operation) 2031719f82d3SEliot Blennerhassett HPI_DEBUG_LOG(DEBUG, "interface->dsp_ack=%d, expected %d\n", 2032719f82d3SEliot Blennerhassett interface->dsp_ack, operation); 2033719f82d3SEliot Blennerhassett /* err=HPI_ERROR_DSP_HARDWARE; */ 2034719f82d3SEliot Blennerhassett 2035719f82d3SEliot Blennerhassett send_dsp_command(phw, H620_HIF_IDLE); 2036719f82d3SEliot Blennerhassett 2037719f82d3SEliot Blennerhassett return err; 2038719f82d3SEliot Blennerhassett } 2039719f82d3SEliot Blennerhassett 2040719f82d3SEliot Blennerhassett /* wait for up to timeout_us microseconds for the DSP 2041719f82d3SEliot Blennerhassett to signal state by DMA into dwDspAck 2042719f82d3SEliot Blennerhassett */ 2043719f82d3SEliot Blennerhassett static int wait_dsp_ack(struct hpi_hw_obj *phw, int state, int timeout_us) 2044719f82d3SEliot Blennerhassett { 2045719f82d3SEliot Blennerhassett struct bus_master_interface *interface = phw->p_interface_buffer; 2046719f82d3SEliot Blennerhassett int t = timeout_us / 4; 2047719f82d3SEliot Blennerhassett 2048719f82d3SEliot Blennerhassett rmb(); /* ensure interface->dsp_ack is up to date */ 2049719f82d3SEliot Blennerhassett while ((interface->dsp_ack != state) && --t) { 2050719f82d3SEliot Blennerhassett hpios_delay_micro_seconds(4); 2051719f82d3SEliot Blennerhassett rmb(); /* DSP changes dsp_ack by DMA */ 2052719f82d3SEliot Blennerhassett } 2053719f82d3SEliot Blennerhassett 2054719f82d3SEliot Blennerhassett /*HPI_DEBUG_LOG(VERBOSE, "Spun %d for %d\n", timeout_us/4-t, state); */ 2055719f82d3SEliot Blennerhassett return t * 4; 2056719f82d3SEliot Blennerhassett } 2057719f82d3SEliot Blennerhassett 2058719f82d3SEliot Blennerhassett /* set the busmaster interface to cmd, then interrupt the DSP */ 2059719f82d3SEliot Blennerhassett static void send_dsp_command(struct hpi_hw_obj *phw, int cmd) 2060719f82d3SEliot Blennerhassett { 2061719f82d3SEliot Blennerhassett struct bus_master_interface *interface = phw->p_interface_buffer; 2062719f82d3SEliot Blennerhassett 2063719f82d3SEliot Blennerhassett u32 r; 2064719f82d3SEliot Blennerhassett 2065719f82d3SEliot Blennerhassett interface->host_cmd = cmd; 2066719f82d3SEliot Blennerhassett wmb(); /* DSP gets state by DMA, make sure it is written to memory */ 2067719f82d3SEliot Blennerhassett /* before we interrupt the DSP */ 2068719f82d3SEliot Blennerhassett r = ioread32(phw->prHDCR); 2069719f82d3SEliot Blennerhassett r |= (u32)C6205_HDCR_DSPINT; 2070719f82d3SEliot Blennerhassett iowrite32(r, phw->prHDCR); 2071719f82d3SEliot Blennerhassett r &= ~(u32)C6205_HDCR_DSPINT; 2072719f82d3SEliot Blennerhassett iowrite32(r, phw->prHDCR); 2073719f82d3SEliot Blennerhassett } 2074719f82d3SEliot Blennerhassett 2075719f82d3SEliot Blennerhassett static unsigned int message_count; 2076719f82d3SEliot Blennerhassett 2077719f82d3SEliot Blennerhassett static u16 message_response_sequence(struct hpi_adapter_obj *pao, 2078719f82d3SEliot Blennerhassett struct hpi_message *phm, struct hpi_response *phr) 2079719f82d3SEliot Blennerhassett { 2080719f82d3SEliot Blennerhassett u32 time_out, time_out2; 2081719f82d3SEliot Blennerhassett struct hpi_hw_obj *phw = pao->priv; 2082719f82d3SEliot Blennerhassett struct bus_master_interface *interface = phw->p_interface_buffer; 2083719f82d3SEliot Blennerhassett u16 err = 0; 2084719f82d3SEliot Blennerhassett 2085719f82d3SEliot Blennerhassett message_count++; 20863285ea10SEliot Blennerhassett if (phm->size > sizeof(interface->u)) { 2087deb21a23SEliot Blennerhassett phr->error = HPI_ERROR_MESSAGE_BUFFER_TOO_SMALL; 20883285ea10SEliot Blennerhassett phr->specific_error = sizeof(interface->u); 20893285ea10SEliot Blennerhassett phr->size = sizeof(struct hpi_response_header); 20903285ea10SEliot Blennerhassett HPI_DEBUG_LOG(ERROR, 20913285ea10SEliot Blennerhassett "message len %d too big for buffer %ld \n", phm->size, 20923285ea10SEliot Blennerhassett sizeof(interface->u)); 20933285ea10SEliot Blennerhassett return 0; 20943285ea10SEliot Blennerhassett } 20953285ea10SEliot Blennerhassett 2096719f82d3SEliot Blennerhassett /* Assume buffer of type struct bus_master_interface 2097719f82d3SEliot Blennerhassett is allocated "noncacheable" */ 2098719f82d3SEliot Blennerhassett 2099719f82d3SEliot Blennerhassett if (!wait_dsp_ack(phw, H620_HIF_IDLE, HPI6205_TIMEOUT)) { 2100719f82d3SEliot Blennerhassett HPI_DEBUG_LOG(DEBUG, "timeout waiting for idle\n"); 21013285ea10SEliot Blennerhassett return HPI6205_ERROR_MSG_RESP_IDLE_TIMEOUT; 2102719f82d3SEliot Blennerhassett } 21033285ea10SEliot Blennerhassett 21043285ea10SEliot Blennerhassett memcpy(&interface->u.message_buffer, phm, phm->size); 2105719f82d3SEliot Blennerhassett /* signal we want a response */ 2106719f82d3SEliot Blennerhassett send_dsp_command(phw, H620_HIF_GET_RESP); 2107719f82d3SEliot Blennerhassett 2108719f82d3SEliot Blennerhassett time_out2 = wait_dsp_ack(phw, H620_HIF_GET_RESP, HPI6205_TIMEOUT); 2109719f82d3SEliot Blennerhassett 21103285ea10SEliot Blennerhassett if (!time_out2) { 2111719f82d3SEliot Blennerhassett HPI_DEBUG_LOG(ERROR, 21123285ea10SEliot Blennerhassett "(%u) Timed out waiting for " "GET_RESP state [%x]\n", 2113719f82d3SEliot Blennerhassett message_count, interface->dsp_ack); 2114719f82d3SEliot Blennerhassett } else { 2115719f82d3SEliot Blennerhassett HPI_DEBUG_LOG(VERBOSE, 2116719f82d3SEliot Blennerhassett "(%u) transition to GET_RESP after %u\n", 2117719f82d3SEliot Blennerhassett message_count, HPI6205_TIMEOUT - time_out2); 2118719f82d3SEliot Blennerhassett } 2119719f82d3SEliot Blennerhassett /* spin waiting on HIF interrupt flag (end of msg process) */ 2120719f82d3SEliot Blennerhassett time_out = HPI6205_TIMEOUT; 2121719f82d3SEliot Blennerhassett 2122719f82d3SEliot Blennerhassett /* read the result */ 21233285ea10SEliot Blennerhassett if (time_out) { 21243285ea10SEliot Blennerhassett if (interface->u.response_buffer.size <= phr->size) 21253285ea10SEliot Blennerhassett memcpy(phr, &interface->u.response_buffer, 21263285ea10SEliot Blennerhassett interface->u.response_buffer.size); 21273285ea10SEliot Blennerhassett else { 21283285ea10SEliot Blennerhassett HPI_DEBUG_LOG(ERROR, 21293285ea10SEliot Blennerhassett "response len %d too big for buffer %d\n", 21303285ea10SEliot Blennerhassett interface->u.response_buffer.size, phr->size); 21313285ea10SEliot Blennerhassett memcpy(phr, &interface->u.response_buffer, 21323285ea10SEliot Blennerhassett sizeof(struct hpi_response_header)); 21333285ea10SEliot Blennerhassett phr->error = HPI_ERROR_RESPONSE_BUFFER_TOO_SMALL; 21343285ea10SEliot Blennerhassett phr->specific_error = 21353285ea10SEliot Blennerhassett interface->u.response_buffer.size; 21363285ea10SEliot Blennerhassett phr->size = sizeof(struct hpi_response_header); 21373285ea10SEliot Blennerhassett } 21383285ea10SEliot Blennerhassett } 2139719f82d3SEliot Blennerhassett /* set interface back to idle */ 2140719f82d3SEliot Blennerhassett send_dsp_command(phw, H620_HIF_IDLE); 2141719f82d3SEliot Blennerhassett 21423285ea10SEliot Blennerhassett if (!time_out || !time_out2) { 2143719f82d3SEliot Blennerhassett HPI_DEBUG_LOG(DEBUG, "something timed out!\n"); 21443285ea10SEliot Blennerhassett return HPI6205_ERROR_MSG_RESP_TIMEOUT; 2145719f82d3SEliot Blennerhassett } 2146719f82d3SEliot Blennerhassett /* special case for adapter close - */ 2147719f82d3SEliot Blennerhassett /* wait for the DSP to indicate it is idle */ 2148719f82d3SEliot Blennerhassett if (phm->function == HPI_ADAPTER_CLOSE) { 2149719f82d3SEliot Blennerhassett if (!wait_dsp_ack(phw, H620_HIF_IDLE, HPI6205_TIMEOUT)) { 2150719f82d3SEliot Blennerhassett HPI_DEBUG_LOG(DEBUG, 21513285ea10SEliot Blennerhassett "Timeout waiting for idle " 2152719f82d3SEliot Blennerhassett "(on adapter_close)\n"); 21533285ea10SEliot Blennerhassett return HPI6205_ERROR_MSG_RESP_IDLE_TIMEOUT; 2154719f82d3SEliot Blennerhassett } 2155719f82d3SEliot Blennerhassett } 2156719f82d3SEliot Blennerhassett err = hpi_validate_response(phm, phr); 2157719f82d3SEliot Blennerhassett return err; 2158719f82d3SEliot Blennerhassett } 2159719f82d3SEliot Blennerhassett 2160719f82d3SEliot Blennerhassett static void hw_message(struct hpi_adapter_obj *pao, struct hpi_message *phm, 2161719f82d3SEliot Blennerhassett struct hpi_response *phr) 2162719f82d3SEliot Blennerhassett { 2163719f82d3SEliot Blennerhassett 2164719f82d3SEliot Blennerhassett u16 err = 0; 2165719f82d3SEliot Blennerhassett 2166719f82d3SEliot Blennerhassett hpios_dsplock_lock(pao); 2167719f82d3SEliot Blennerhassett 2168719f82d3SEliot Blennerhassett err = message_response_sequence(pao, phm, phr); 2169719f82d3SEliot Blennerhassett 2170719f82d3SEliot Blennerhassett /* maybe an error response */ 2171719f82d3SEliot Blennerhassett if (err) { 2172719f82d3SEliot Blennerhassett /* something failed in the HPI/DSP interface */ 21730a00044dSEliot Blennerhassett if (err >= HPI_ERROR_BACKEND_BASE) { 21740a00044dSEliot Blennerhassett phr->error = HPI_ERROR_DSP_COMMUNICATION; 21750a00044dSEliot Blennerhassett phr->specific_error = err; 21760a00044dSEliot Blennerhassett } else { 2177719f82d3SEliot Blennerhassett phr->error = err; 21780a00044dSEliot Blennerhassett } 21790a00044dSEliot Blennerhassett 2180719f82d3SEliot Blennerhassett pao->dsp_crashed++; 2181719f82d3SEliot Blennerhassett 2182719f82d3SEliot Blennerhassett /* just the header of the response is valid */ 2183719f82d3SEliot Blennerhassett phr->size = sizeof(struct hpi_response_header); 2184719f82d3SEliot Blennerhassett goto err; 2185719f82d3SEliot Blennerhassett } else 2186719f82d3SEliot Blennerhassett pao->dsp_crashed = 0; 2187719f82d3SEliot Blennerhassett 2188719f82d3SEliot Blennerhassett if (phr->error != 0) /* something failed in the DSP */ 2189719f82d3SEliot Blennerhassett goto err; 2190719f82d3SEliot Blennerhassett 2191719f82d3SEliot Blennerhassett switch (phm->function) { 2192719f82d3SEliot Blennerhassett case HPI_OSTREAM_WRITE: 2193719f82d3SEliot Blennerhassett case HPI_ISTREAM_ANC_WRITE: 2194719f82d3SEliot Blennerhassett err = hpi6205_transfer_data(pao, phm->u.d.u.data.pb_data, 2195719f82d3SEliot Blennerhassett phm->u.d.u.data.data_size, H620_HIF_SEND_DATA); 2196719f82d3SEliot Blennerhassett break; 2197719f82d3SEliot Blennerhassett 2198719f82d3SEliot Blennerhassett case HPI_ISTREAM_READ: 2199719f82d3SEliot Blennerhassett case HPI_OSTREAM_ANC_READ: 2200719f82d3SEliot Blennerhassett err = hpi6205_transfer_data(pao, phm->u.d.u.data.pb_data, 2201719f82d3SEliot Blennerhassett phm->u.d.u.data.data_size, H620_HIF_GET_DATA); 2202719f82d3SEliot Blennerhassett break; 2203719f82d3SEliot Blennerhassett 2204719f82d3SEliot Blennerhassett case HPI_CONTROL_SET_STATE: 2205719f82d3SEliot Blennerhassett if (phm->object == HPI_OBJ_CONTROLEX 2206719f82d3SEliot Blennerhassett && phm->u.cx.attribute == HPI_COBRANET_SET_DATA) 2207719f82d3SEliot Blennerhassett err = hpi6205_transfer_data(pao, 2208719f82d3SEliot Blennerhassett phm->u.cx.u.cobranet_bigdata.pb_data, 2209719f82d3SEliot Blennerhassett phm->u.cx.u.cobranet_bigdata.byte_count, 2210719f82d3SEliot Blennerhassett H620_HIF_SEND_DATA); 2211719f82d3SEliot Blennerhassett break; 2212719f82d3SEliot Blennerhassett 2213719f82d3SEliot Blennerhassett case HPI_CONTROL_GET_STATE: 2214719f82d3SEliot Blennerhassett if (phm->object == HPI_OBJ_CONTROLEX 2215719f82d3SEliot Blennerhassett && phm->u.cx.attribute == HPI_COBRANET_GET_DATA) 2216719f82d3SEliot Blennerhassett err = hpi6205_transfer_data(pao, 2217719f82d3SEliot Blennerhassett phm->u.cx.u.cobranet_bigdata.pb_data, 2218719f82d3SEliot Blennerhassett phr->u.cx.u.cobranet_data.byte_count, 2219719f82d3SEliot Blennerhassett H620_HIF_GET_DATA); 2220719f82d3SEliot Blennerhassett break; 2221719f82d3SEliot Blennerhassett } 2222719f82d3SEliot Blennerhassett phr->error = err; 2223719f82d3SEliot Blennerhassett 2224719f82d3SEliot Blennerhassett err: 2225719f82d3SEliot Blennerhassett hpios_dsplock_unlock(pao); 2226719f82d3SEliot Blennerhassett 2227719f82d3SEliot Blennerhassett return; 2228719f82d3SEliot Blennerhassett } 2229