static int atusb_set_hw_addr_filt(struct ieee802154_dev *wpan_dev, struct ieee802154_hw_addr_filt *filt, unsigned long changed) { struct atusb *atusb = wpan_dev->priv; struct device *dev = &atusb->usb_dev->dev; uint8_t reg; if (changed & IEEE802515_AFILT_SADDR_CHANGED) { dev_vdbg(dev, "atusb_set_hw_addr_filt called for saddr\n"); atusb_write_reg(atusb, RG_SHORT_ADDR_0, filt->short_addr); atusb_write_reg(atusb, RG_SHORT_ADDR_1, filt->short_addr >> 8); }
static int atusb_set_hw_addr_filt(struct ieee802154_hw *hw, struct ieee802154_hw_addr_filt *filt, unsigned long changed) { struct atusb *atusb = hw->priv; struct device *dev = &atusb->usb_dev->dev; if (changed & IEEE802154_AFILT_SADDR_CHANGED) { u16 addr = le16_to_cpu(filt->short_addr); dev_vdbg(dev, "atusb_set_hw_addr_filt called for saddr\n"); atusb_write_reg(atusb, RG_SHORT_ADDR_0, addr); atusb_write_reg(atusb, RG_SHORT_ADDR_1, addr >> 8); }
static int atusb_channel(struct ieee802154_hw *hw, u8 page, u8 channel) { struct atusb *atusb = hw->priv; int ret; /* This implicitly sets the CCA (Clear Channel Assessment) mode to 0, * "Mode 3a, Carrier sense OR energy above threshold". * We should probably make this configurable. @@@ */ ret = atusb_write_reg(atusb, RG_PHY_CC_CCA, channel); if (ret < 0) return ret; msleep(1); /* @@@ ugly synchronization */ return 0; }
static int atusb_channel(struct ieee802154_dev *wpan_dev, int page, int channel) { struct atusb *atusb = wpan_dev->priv; int ret; if (page || channel < 11 || channel > 26) { dev_warn(&atusb->usb_dev->dev, "invalid channel: page %d channel %d\n", page, channel); return -EINVAL; } /* This implicitly sets the CCA (Clear Channel Assessment) mode to 0, * "Mode 3a, Carrier sense OR energy above threshold". * We should probably make this configurable. @@@ */ ret = atusb_write_reg(atusb, RG_PHY_CC_CCA, channel); if (ret < 0) return ret; msleep(1); /* @@@ ugly synchronization */ wpan_dev->phy->current_channel = channel; return 0; }
static int atusb_write_subreg(struct atusb *atusb, uint8_t reg, uint8_t mask, uint8_t shift, uint8_t value) { struct usb_device *usb_dev = atusb->usb_dev; uint8_t orig, tmp; int ret = 0; dev_dbg(&usb_dev->dev, "atusb_write_subreg: 0x%02x <- 0x%02x\n", reg, value); orig = atusb_read_reg(atusb, reg); /* Write the value only into that part of the register which is allowed * by the mask. All other bits stay as before. */ tmp = orig & ~mask; tmp |= (value << shift) & mask; if (tmp != orig) ret = atusb_write_reg(atusb, reg, tmp); return ret; }