• Home
  • History
  • Annotate
  • Raw
  • Download
  • only in /freebsd-13-stable/sys/dev/malo/

Lines Matching refs:mh

64 	pCmd = (_type *)&mh->mh_cmdbuf[0];				\
71 malo_hal_read4(struct malo_hal *mh, bus_size_t off)
73 return bus_space_read_4(mh->mh_iot, mh->mh_ioh, off);
77 malo_hal_write4(struct malo_hal *mh, bus_size_t off, uint32_t val)
79 bus_space_write_4(mh->mh_iot, mh->mh_ioh, off, val);
104 struct malo_hal *mh;
106 mh = malloc(sizeof(struct malo_hal), M_DEVBUF, M_NOWAIT | M_ZERO);
107 if (mh == NULL)
110 mh->mh_dev = dev;
111 mh->mh_ioh = ioh;
112 mh->mh_iot = iot;
114 snprintf(mh->mh_mtxname, sizeof(mh->mh_mtxname),
116 mtx_init(&mh->mh_mtx, mh->mh_mtxname, NULL, MTX_DEF);
134 &mh->mh_dmat);
142 error = bus_dmamem_alloc(mh->mh_dmat, (void**) &mh->mh_cmdbuf,
144 &mh->mh_dmamap);
151 error = bus_dmamap_load(mh->mh_dmat, mh->mh_dmamap,
152 mh->mh_cmdbuf, MALO_CMDBUF_SIZE,
153 malo_hal_load_cb, &mh->mh_cmdaddr,
161 return (mh);
164 if (mh->mh_cmdbuf != NULL)
165 bus_dmamem_free(mh->mh_dmat, mh->mh_cmdbuf,
166 mh->mh_dmamap);
167 if (mh->mh_dmat)
168 bus_dma_tag_destroy(mh->mh_dmat);
169 free(mh, M_DEVBUF);
179 malo_hal_send_cmd(struct malo_hal *mh)
183 bus_dmamap_sync(mh->mh_dmat, mh->mh_dmamap,
186 malo_hal_write4(mh, MALO_REG_GEN_PTR, mh->mh_cmdaddr);
187 dummy = malo_hal_read4(mh, MALO_REG_INT_CODE);
189 malo_hal_write4(mh, MALO_REG_H2A_INTERRUPT_EVENTS,
194 malo_hal_waitforcmd(struct malo_hal *mh, uint16_t cmd)
200 if (mh->mh_cmdbuf[0] == le16toh(cmd))
211 malo_hal_execute_cmd(struct malo_hal *mh, unsigned short cmd)
213 MALO_HAL_LOCK_ASSERT(mh);
215 if ((mh->mh_flags & MHF_FWHANG) &&
216 (mh->mh_debug & MALO_HAL_DEBUG_IGNHANG) == 0) {
217 device_printf(mh->mh_dev, "firmware hung, skipping cmd 0x%x\n",
222 if (malo_hal_read4(mh, MALO_REG_INT_CODE) == 0xffffffff) {
223 device_printf(mh->mh_dev, "%s: device not present!\n",
228 malo_hal_send_cmd(mh);
229 if (!malo_hal_waitforcmd(mh, cmd | 0x8000)) {
230 device_printf(mh->mh_dev,
232 mh->mh_flags |= MHF_FWHANG;
236 bus_dmamap_sync(mh->mh_dmat, mh->mh_dmamap,
243 malo_hal_get_cal_table(struct malo_hal *mh, uint8_t annex, uint8_t index)
248 MALO_HAL_LOCK_ASSERT(mh);
254 ret = malo_hal_execute_cmd(mh, MALO_HOSTCMD_GET_CALTABLE);
261 malo_hal_get_pwrcal_table(struct malo_hal *mh, struct malo_hal_caldata *cal)
266 MALO_HAL_LOCK(mh);
268 data = ((const struct malo_cmd_caltable *) mh->mh_cmdbuf)->caltbl;
269 if (malo_hal_get_cal_table(mh, 33, 0) == 0) {
274 mh->mh_flags |= MHF_CALDATA;
275 MALO_HAL_UNLOCK(mh);
284 malo_hal_resetstate(struct malo_hal *mh)
290 if ((mh->mh_flags & MHF_CALDATA) == 0)
291 malo_hal_get_pwrcal_table(mh, &mh->mh_caldata);
296 malo_hal_fw_reset(struct malo_hal *mh)
299 if (malo_hal_read4(mh, MALO_REG_INT_CODE) == 0xffffffff) {
300 device_printf(mh->mh_dev, "%s: device not present!\n",
305 malo_hal_write4(mh, MALO_REG_H2A_INTERRUPT_EVENTS, MALO_ISR_RESET);
306 mh->mh_flags &= ~MHF_FWHANG;
310 malo_hal_trigger_pcicmd(struct malo_hal *mh)
314 bus_dmamap_sync(mh->mh_dmat, mh->mh_dmamap, BUS_DMASYNC_PREWRITE);
316 malo_hal_write4(mh, MALO_REG_GEN_PTR, mh->mh_cmdaddr);
317 dummy = malo_hal_read4(mh, MALO_REG_INT_CODE);
319 malo_hal_write4(mh, MALO_REG_INT_CODE, 0x00);
320 dummy = malo_hal_read4(mh, MALO_REG_INT_CODE);
322 malo_hal_write4(mh, MALO_REG_H2A_INTERRUPT_EVENTS,
324 dummy = malo_hal_read4(mh, MALO_REG_INT_CODE);
328 malo_hal_waitfor(struct malo_hal *mh, uint32_t val)
334 if (malo_hal_read4(mh, MALO_REG_INT_CODE) == val)
345 malo_hal_send_helper(struct malo_hal *mh, int bsize,
348 mh->mh_cmdbuf[0] = htole16(MALO_HOSTCMD_CODE_DNLD);
349 mh->mh_cmdbuf[1] = htole16(bsize);
350 memcpy(&mh->mh_cmdbuf[4], data , dsize);
352 malo_hal_trigger_pcicmd(mh);
358 if (malo_hal_waitfor(mh, MALO_INT_CODE_CMD_FINISHED) != 0) {
359 device_printf(mh->mh_dev,
361 __func__, malo_hal_read4(mh, MALO_REG_INT_CODE));
367 malo_hal_write4(mh, MALO_REG_INT_CODE, 0);
373 malo_hal_fwload_helper(struct malo_hal *mh, char *helper)
380 device_printf(mh->mh_dev, "could not read microcode %s!\n",
385 device_printf(mh->mh_dev, "load %s firmware image (%zu bytes)\n",
388 error = malo_hal_send_helper(mh, fw->datasize, fw->data, fw->datasize,
394 error = malo_hal_send_helper(mh, 0, NULL, 0, MALO_NOWAIT);
406 malo_hal_send_main(struct malo_hal *mh, const void *data, size_t dsize,
409 mh->mh_cmdbuf[0] = htole16(MALO_HOSTCMD_CODE_DNLD);
410 mh->mh_cmdbuf[1] = htole16(dsize);
411 mh->mh_cmdbuf[2] = htole16(seqnum);
412 mh->mh_cmdbuf[3] = 0;
413 memcpy(&mh->mh_cmdbuf[4], data, dsize);
415 malo_hal_trigger_pcicmd(mh);
420 if (malo_hal_waitfor(mh, MALO_INT_CODE_CMD_FINISHED) != 0) {
421 device_printf(mh->mh_dev,
423 __func__, malo_hal_read4(mh, MALO_REG_INT_CODE));
429 malo_hal_write4(mh, MALO_REG_INT_CODE, 0);
435 malo_hal_fwload_main(struct malo_hal *mh, char *firmware)
448 device_printf(mh->mh_dev, "could not read firmware %s!\n",
453 device_printf(mh->mh_dev, "load %s firmware image (%zu bytes)\n",
461 error = malo_hal_send_main(mh, fp, blocksize, seqnum++,
472 error = malo_hal_send_main(mh, NULL, 0, seqnum++, MALO_NOWAIT);
482 malo_hal_fwload(struct malo_hal *mh, char *helper, char *firmware)
494 malo_hal_fw_reset(mh);
496 malo_hal_write4(mh, MALO_REG_A2H_INTERRUPT_CLEAR_SEL,
498 malo_hal_write4(mh, MALO_REG_A2H_INTERRUPT_CAUSE, 0x00);
499 malo_hal_write4(mh, MALO_REG_A2H_INTERRUPT_MASK, 0x00);
500 malo_hal_write4(mh, MALO_REG_A2H_INTERRUPT_STATUS_MASK,
503 error = malo_hal_fwload_helper(mh, helper);
505 device_printf(mh->mh_dev, "failed to load bootrom loader.\n");
511 error = malo_hal_fwload_main(mh, firmware);
513 device_printf(mh->mh_dev, "failed to load firmware.\n");
521 mh->mh_cmdbuf[1] = 0;
524 malo_hal_trigger_pcicmd(mh);
527 malo_hal_write4(mh, MALO_REG_GEN_PTR, opmode);
529 if (malo_hal_read4(mh, MALO_REG_INT_CODE) == fwreadysig) {
530 malo_hal_write4(mh, MALO_REG_INT_CODE, 0x00);
531 return malo_hal_resetstate(mh);
537 malo_hal_fw_reset(mh);
547 malo_hal_gethwspecs(struct malo_hal *mh, struct malo_hal_hwspec *hw)
552 MALO_HAL_LOCK(mh);
556 cmd->ul_fw_awakecookie = htole32((unsigned int)mh->mh_cmdaddr + 2048);
558 ret = malo_hal_execute_cmd(mh, MALO_HOSTCMD_GET_HW_SPEC);
576 MALO_HAL_UNLOCK(mh);
582 malo_hal_detach(struct malo_hal *mh)
585 bus_dmamem_free(mh->mh_dmat, mh->mh_cmdbuf, mh->mh_dmamap);
586 bus_dma_tag_destroy(mh->mh_dmat);
587 mtx_destroy(&mh->mh_mtx);
588 free(mh, M_DEVBUF);
598 malo_hal_setantenna(struct malo_hal *mh, enum malo_hal_antenna dirset, int ant)
606 MALO_HAL_LOCK(mh);
617 ret = malo_hal_execute_cmd(mh, MALO_HOSTCMD_802_11_RF_ANTENNA);
619 MALO_HAL_UNLOCK(mh);
630 malo_hal_setradio(struct malo_hal *mh, int onoff,
636 MALO_HAL_LOCK(mh);
647 ret = malo_hal_execute_cmd(mh, MALO_HOSTCMD_802_11_RADIO_CONTROL);
649 MALO_HAL_UNLOCK(mh);
658 malo_hal_intrset(struct malo_hal *mh, uint32_t mask)
661 malo_hal_write4(mh, MALO_REG_A2H_INTERRUPT_MASK, 0);
662 (void)malo_hal_read4(mh, MALO_REG_INT_CODE);
664 mh->mh_imask = mask;
665 malo_hal_write4(mh, MALO_REG_A2H_INTERRUPT_MASK, mask);
666 (void)malo_hal_read4(mh, MALO_REG_INT_CODE);
670 malo_hal_setchannel(struct malo_hal *mh, const struct malo_hal_channel *chan)
675 MALO_HAL_LOCK(mh);
682 ret = malo_hal_execute_cmd(mh, MALO_HOSTCMD_SET_RF_CHANNEL);
684 MALO_HAL_UNLOCK(mh);
690 malo_hal_settxpower(struct malo_hal *mh, const struct malo_hal_channel *c)
693 const struct malo_hal_caldata *cal = &mh->mh_caldata;
698 MALO_HAL_LOCK(mh);
708 ret = malo_hal_execute_cmd(mh, MALO_HOSTCMD_802_11_RF_TX_POWER);
710 MALO_HAL_UNLOCK(mh);
716 malo_hal_setpromisc(struct malo_hal *mh, int enable)
723 malo_hal_setassocid(struct malo_hal *mh,
729 MALO_HAL_LOCK(mh);
737 ret = malo_hal_execute_cmd(mh, MALO_HOSTCMD_SET_AID);
738 MALO_HAL_UNLOCK(mh);
748 malo_hal_txstart(struct malo_hal *mh, int qnum)
750 bus_space_write_4(mh->mh_iot, mh->mh_ioh,
752 (void) bus_space_read_4(mh->mh_iot, mh->mh_ioh, MALO_REG_INT_CODE);
759 malo_hal_getisr(struct malo_hal *mh, uint32_t *status)
763 cause = bus_space_read_4(mh->mh_iot, mh->mh_ioh,
769 bus_space_write_4(mh->mh_iot, mh->mh_ioh,
770 MALO_REG_A2H_INTERRUPT_CAUSE, cause &~ mh->mh_imask);
771 (void) bus_space_read_4(mh->mh_iot, mh->mh_ioh,
773 cause &= mh->mh_imask;
784 malo_hal_cmddone(struct malo_hal *mh)
790 malo_hal_prescan(struct malo_hal *mh)
795 MALO_HAL_LOCK(mh);
800 ret = malo_hal_execute_cmd(mh, MALO_HOSTCMD_SET_PRE_SCAN);
802 MALO_HAL_UNLOCK(mh);
808 malo_hal_postscan(struct malo_hal *mh, uint8_t *macaddr, uint8_t ibsson)
813 MALO_HAL_LOCK(mh);
820 ret = malo_hal_execute_cmd(mh, MALO_HOSTCMD_SET_POST_SCAN);
822 MALO_HAL_UNLOCK(mh);
828 malo_hal_set_slot(struct malo_hal *mh, int is_short)
833 MALO_HAL_LOCK(mh);
839 ret = malo_hal_execute_cmd(mh, MALO_HOSTCMD_SET_SLOT);
841 MALO_HAL_UNLOCK(mh);
847 malo_hal_set_rate(struct malo_hal *mh, uint16_t curmode, uint8_t rate)
852 MALO_HAL_LOCK(mh);
882 ret = malo_hal_execute_cmd(mh, MALO_HOSTCMD_SET_RATE);
884 MALO_HAL_UNLOCK(mh);
890 malo_hal_setmcast(struct malo_hal *mh, int nmc, const uint8_t macs[])
898 MALO_HAL_LOCK(mh);
905 ret = malo_hal_execute_cmd(mh, MALO_HOSTCMD_MAC_MULTICAST_ADR);
907 MALO_HAL_UNLOCK(mh);