本文整理汇总了C++中request_firmware函数的典型用法代码示例。如果您正苦于以下问题:C++ request_firmware函数的具体用法?C++ request_firmware怎么用?C++ request_firmware使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了request_firmware函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: rtl92s_init_sw_vars
//.........这里部分代码省略.........
rtlpci->receive_config =
RCR_APPFCS |
RCR_APWRMGT |
/*RCR_ADD3 |*/
RCR_AMF |
RCR_ADF |
RCR_APP_MIC |
RCR_APP_ICV |
RCR_AICV |
/* Accept ICV error, CRC32 Error */
RCR_ACRC32 |
RCR_AB |
/* Accept Broadcast, Multicast */
RCR_AM |
/* Accept Physical match */
RCR_APM |
/* Accept Destination Address packets */
/*RCR_AAP |*/
RCR_APP_PHYST_STAFF |
/* Accept PHY status */
RCR_APP_PHYST_RXFF |
(earlyrxthreshold << RCR_FIFO_OFFSET);
rtlpci->irq_mask[0] = (u32)
(IMR_ROK |
IMR_VODOK |
IMR_VIDOK |
IMR_BEDOK |
IMR_BKDOK |
IMR_HCCADOK |
IMR_MGNTDOK |
IMR_COMDOK |
IMR_HIGHDOK |
IMR_BDOK |
IMR_RXCMDOK |
/*IMR_TIMEOUT0 |*/
IMR_RDU |
IMR_RXFOVW |
IMR_BCNINT
/*| IMR_TXFOVW*/
/*| IMR_TBDOK |
IMR_TBDER*/);
rtlpci->irq_mask[1] = (u32) 0;
rtlpci->shortretry_limit = 0x30;
rtlpci->longretry_limit = 0x30;
rtlpci->first_init = true;
/* for LPS & IPS */
rtlpriv->psc.inactiveps = rtlpriv->cfg->mod_params->inactiveps;
rtlpriv->psc.swctrl_lps = rtlpriv->cfg->mod_params->swctrl_lps;
rtlpriv->psc.fwctrl_lps = rtlpriv->cfg->mod_params->fwctrl_lps;
rtlpriv->psc.reg_fwctrl_lps = 3;
rtlpriv->psc.reg_max_lps_awakeintvl = 5;
/* for ASPM, you can close aspm through
* set const_support_pciaspm = 0 */
rtl92s_init_aspm_vars(hw);
if (rtlpriv->psc.reg_fwctrl_lps == 1)
rtlpriv->psc.fwctrl_psmode = FW_PS_MIN_MODE;
else if (rtlpriv->psc.reg_fwctrl_lps == 2)
rtlpriv->psc.fwctrl_psmode = FW_PS_MAX_MODE;
else if (rtlpriv->psc.reg_fwctrl_lps == 3)
rtlpriv->psc.fwctrl_psmode = FW_PS_DTIM_MODE;
/* for firmware buf */
rtlpriv->rtlhal.pfirmware = vzalloc(sizeof(struct rt_firmware));
if (!rtlpriv->rtlhal.pfirmware) {
RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG,
("Can't alloc buffer for fw.\n"));
return 1;
}
printk(KERN_INFO "rtl8192se: Driver for Realtek RTL8192SE/RTL8191SE\n"
" Loading firmware %s\n", rtlpriv->cfg->fw_name);
/* request fw */
err = request_firmware(&firmware, rtlpriv->cfg->fw_name,
rtlpriv->io.dev);
if (err) {
RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG,
("Failed to request firmware!\n"));
return 1;
}
if (firmware->size > sizeof(struct rt_firmware)) {
RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG,
("Firmware is too big!\n"));
release_firmware(firmware);
return 1;
}
pfirmware = (struct rt_firmware *)rtlpriv->rtlhal.pfirmware;
memcpy(pfirmware->sz_fw_tmpbuffer, firmware->data, firmware->size);
pfirmware->sz_fw_tmpbufferlen = firmware->size;
release_firmware(firmware);
return err;
}
示例2: omapl_pru_can_probe
//.........这里部分代码省略.........
priv->can_tx_hndl.u8prunumber = CAN_TX_PRU_1;
priv->can_rx_hndl.u8prunumber = CAN_RX_PRU_0;
ndev->flags |= (IFF_ECHO | IFF_NOARP); /* we support local echo, no arp */
platform_set_drvdata(pdev, ndev);
SET_NETDEV_DEV(ndev, &pdev->dev);
ndev->netdev_ops = &omapl_pru_can_netdev_ops;
priv->clk = clk_get(&pdev->dev, "pru_ck");
if (IS_ERR(priv->clk)) {
dev_err(&pdev->dev, "no clock available\n");
err = PTR_ERR(priv->clk);
priv->clk = NULL;
goto probe_exit_candev;
}
priv->can.clock.freq = clk_get_rate(priv->clk);
priv->clk_timer = clk_get(&pdev->dev, "pll1_sysclk2");
if (IS_ERR(priv->clk_timer)) {
dev_err(&pdev->dev, "no timer clock available\n");
err = PTR_ERR(priv->clk_timer);
priv->clk_timer = NULL;
goto probe_exit_candev;
}
priv->timer_freq = clk_get_rate(priv->clk_timer);
err = register_candev(ndev);
if (err) {
dev_err(&pdev->dev, "register_candev() failed\n");
err = -ENODEV;
goto probe_exit_clk;
}
err = request_firmware(&priv->fw_tx, "PRU_CAN_Emulation_Tx.bin",
&pdev->dev);
if (err) {
dev_err(&pdev->dev, "can't load firmware\n");
err = -ENODEV;
goto probe_exit_clk;
}
dev_info(&pdev->dev, "fw_tx size %d. downloading...\n",
priv->fw_tx->size);
err = request_firmware(&priv->fw_rx, "PRU_CAN_Emulation_Rx.bin",
&pdev->dev);
if (err) {
dev_err(&pdev->dev, "can't load firmware\n");
err = -ENODEV;
goto probe_release_fw;
}
dev_info(&pdev->dev, "fw_rx size %d. downloading...\n",
priv->fw_rx->size);
fw_pru.ptr_pru1 = kmalloc(priv->fw_tx->size, GFP_KERNEL);
memcpy((void *)fw_pru.ptr_pru1, (const void *)priv->fw_tx->data,
priv->fw_tx->size);
fw_pru.u32_pru1_code_size = priv->fw_tx->size;
fw_pru.ptr_pru0 = kmalloc(priv->fw_rx->size, GFP_KERNEL);
memcpy((void *)fw_pru.ptr_pru0, (const void *)priv->fw_rx->data,
priv->fw_rx->size);
fw_pru.u32_pru0_code_size = priv->fw_rx->size;
/* init the pru */
pru_can_emulation_init(&priv->pru_arm_iomap, priv->can.clock.freq);
示例3: load_kernel_fw_bootmode
static int load_kernel_fw_bootmode(struct spi_device *spi, const char *pFn)
{
const struct firmware *fw = NULL;
int remaining;
unsigned int uPos = 0;
unsigned int fw_addr = STM_APP_ADDR;
int iRet;
int block = STM_MAX_XFER_SIZE;
int count = 0;
int err_count = 0;
int retry_count = 0;
pr_info("[SSP] ssp_load_fw start!!!\n");
iRet = request_firmware(&fw, pFn, &spi->dev);
if (iRet) {
pr_err("[SSP] Unable to open firmware %s\n", pFn);
return iRet;
}
remaining = fw->size;
while (remaining > 0) {
if (block > remaining)
block = remaining;
while (retry_count < 3) {
iRet = fw_write_stm(spi, fw_addr, block, fw->data + uPos);
if (iRet < block) {
pr_err("[SSP] Error writing to addr 0x%08X\n", fw_addr);
if (iRet < 0) {
pr_err("[SSP] Erro was %d\n", iRet);
} else {
pr_err("[SSP] Incomplete write of %d bytes\n",
iRet);
iRet = -EIO;
}
retry_count++;
err_count++;
} else {
retry_count = 0;
break;
}
}
if (iRet < 0) {
pr_err("[SSP] Writing MEM failed: %d, retry cont: %d\n", iRet, err_count);
goto out_load_kernel;
}
remaining -= block;
uPos += block;
fw_addr += block;
if (count++ == 20) {
pr_info("[SSP] Updated %u bytes / %u bytes\n", uPos,
fw->size);
count = 0;
}
}
pr_info("[SSP] Firmware download is success.(%d bytes, retry %d)\n", uPos, err_count);
out_load_kernel:
release_firmware(fw);
return iRet;
}
示例4: kgsl_ringbuffer_load_pfp_ucode
static int kgsl_ringbuffer_load_pfp_ucode(struct kgsl_device *device)
{
int status = 0;
int i;
const struct firmware *fw = NULL;
unsigned int *fw_ptr = NULL;
size_t fw_word_size = 0;
struct kgsl_yamato_device *yamato_device = KGSL_YAMATO_DEVICE(device);
if (yamato_device->pfp_fw == NULL) {
if (device->chip_id == KGSL_CHIPID_LEIA_REV470) {
status = request_firmware(&fw, LEIA_PFP_470_FW,
device->dev);
if (status != 0) {
KGSL_DRV_ERR("request_firmware for %s \
failed with error %d\n",
LEIA_PFP_470_FW, status);
return status;
}
} else {
status = request_firmware(&fw, YAMATO_PFP_FW,
device->dev);
if (status != 0) {
KGSL_DRV_ERR("request_firmware for %s \
failed with error %d\n",
YAMATO_PFP_FW, status);
return status;
}
}
/*this firmware must come in 1 word chunks. */
if ((fw->size % sizeof(uint32_t)) != 0) {
KGSL_DRV_ERR("bad firmware size %d.\n", fw->size);
status = -EINVAL;
goto error_release_fw;
}
fw_ptr = (unsigned int *)fw->data;
fw_word_size = fw->size/sizeof(uint32_t);
yamato_device->pfp_fw_size = fw_word_size;
/* keep a copy of fw to be reloaded later */
yamato_device->pfp_fw = (unsigned int *)
kmalloc(fw->size, GFP_KERNEL);
if (yamato_device->pfp_fw == NULL) {
KGSL_DRV_ERR("ERROR: couldn't kmalloc fw size= %d.\n",
fw->size);
status = -EINVAL;
goto error_release_fw;
}
memcpy(yamato_device->pfp_fw, fw->data, fw->size);
} else {
fw_ptr = yamato_device->pfp_fw;
fw_word_size = yamato_device->pfp_fw_size;
}
KGSL_DRV_INFO("loading pfp ucode version: %d\n", fw_ptr[0]);
kgsl_yamato_regwrite(device, REG_CP_PFP_UCODE_ADDR, 0);
for (i = 1; i < fw_word_size; i++)
kgsl_yamato_regwrite(device, REG_CP_PFP_UCODE_DATA, fw_ptr[i]);
error_release_fw:
if (fw)
release_firmware(fw);
return status;
}
示例5: cx18_av_loadfw
int cx18_av_loadfw(struct cx18 *cx)
{
struct v4l2_subdev *sd = &cx->av_state.sd;
const struct firmware *fw = NULL;
u32 size;
u32 u, v;
const u8 *ptr;
int i;
int retries1 = 0;
if (request_firmware(&fw, FWFILE, &cx->pci_dev->dev) != 0) {
CX18_ERR_DEV(sd, "unable to open firmware %s\n", FWFILE);
return -EINVAL;
}
/* The firmware load often has byte errors, so allow for several
retries, both at byte level and at the firmware load level. */
while (retries1 < 5) {
cx18_av_write4_expect(cx, CXADEC_CHIP_CTRL, 0x00010000,
0x00008430, 0xffffffff); /* cx25843 */
cx18_av_write_expect(cx, CXADEC_STD_DET_CTL, 0xf6, 0xf6, 0xff);
/* Reset the Mako core, Register is alias of CXADEC_CHIP_CTRL */
cx18_av_write4_expect(cx, 0x8100, 0x00010000,
0x00008430, 0xffffffff); /* cx25843 */
/* Put the 8051 in reset and enable firmware upload */
cx18_av_write4_noretry(cx, CXADEC_DL_CTL, 0x0F000000);
ptr = fw->data;
size = fw->size;
for (i = 0; i < size; i++) {
u32 dl_control = 0x0F000000 | i | ((u32)ptr[i] << 16);
u32 value = 0;
int retries2;
int unrec_err = 0;
for (retries2 = 0; retries2 < CX18_MAX_MMIO_WR_RETRIES;
retries2++) {
cx18_av_write4_noretry(cx, CXADEC_DL_CTL,
dl_control);
udelay(10);
value = cx18_av_read4(cx, CXADEC_DL_CTL);
if (value == dl_control)
break;
/* Check if we can correct the byte by changing
the address. We can only write the lower
address byte of the address. */
if ((value & 0x3F00) != (dl_control & 0x3F00)) {
unrec_err = 1;
break;
}
}
if (unrec_err || retries2 >= CX18_MAX_MMIO_WR_RETRIES)
break;
}
if (i == size)
break;
retries1++;
}
if (retries1 >= 5) {
CX18_ERR_DEV(sd, "unable to load firmware %s\n", FWFILE);
release_firmware(fw);
return -EIO;
}
cx18_av_write4_expect(cx, CXADEC_DL_CTL,
0x03000000 | fw->size, 0x03000000, 0x13000000);
CX18_INFO_DEV(sd, "loaded %s firmware (%d bytes)\n", FWFILE, size);
if (cx18_av_verifyfw(cx, fw) == 0)
cx18_av_write4_expect(cx, CXADEC_DL_CTL,
0x13000000 | fw->size, 0x13000000, 0x13000000);
/* Output to the 416 */
cx18_av_and_or4(cx, CXADEC_PIN_CTRL1, ~0, 0x78000);
/* Audio input control 1 set to Sony mode */
/* Audio output input 2 is 0 for slave operation input */
/* 0xC4000914[5]: 0 = left sample on WS=0, 1 = left sample on WS=1 */
/* 0xC4000914[7]: 0 = Philips mode, 1 = Sony mode (1st SCK rising edge
after WS transition for first bit of audio word. */
cx18_av_write4(cx, CXADEC_I2S_IN_CTL, 0x000000A0);
/* Audio output control 1 is set to Sony mode */
/* Audio output control 2 is set to 1 for master mode */
/* 0xC4000918[5]: 0 = left sample on WS=0, 1 = left sample on WS=1 */
/* 0xC4000918[7]: 0 = Philips mode, 1 = Sony mode (1st SCK rising edge
after WS transition for first bit of audio word. */
/* 0xC4000918[8]: 0 = slave operation, 1 = master (SCK_OUT and WS_OUT
are generated) */
cx18_av_write4(cx, CXADEC_I2S_OUT_CTL, 0x000001A0);
/* set alt I2s master clock to /0x16 and enable alt divider i2s
passthrough */
cx18_av_write4(cx, CXADEC_PIN_CFG3, 0x5600B687);
cx18_av_write4_expect(cx, CXADEC_STD_DET_CTL, 0x000000F6, 0x000000F6,
//.........这里部分代码省略.........
示例6: css2600_pci_probe
static int css2600_pci_probe(struct pci_dev *pdev,
const struct pci_device_id *id)
{
struct css2600_device *isp;
phys_addr_t phys;
void __iomem *mmu_base[CSS2600_MMU_MAX_DEVICES];
struct css2600_bus_iommu *isys_iommu, *psys_iommu;
void __iomem * const *iomap;
void __iomem *isys_base = NULL;
void __iomem *psys_base = NULL;
char *fw_binary;
unsigned int iommus = 0;
unsigned int dma_mask = 39;
int rval;
isp = devm_kzalloc(&pdev->dev, sizeof(*isp), GFP_KERNEL);
if (!isp) {
dev_err(&pdev->dev, "Failed to alloc CI ISP structure\n");
return -ENOMEM;
}
isp->pdev = pdev;
INIT_LIST_HEAD(&isp->devices);
isys_iommu = devm_kzalloc(&pdev->dev, sizeof(*isys_iommu), GFP_KERNEL);
psys_iommu = devm_kzalloc(&pdev->dev, sizeof(*psys_iommu), GFP_KERNEL);
if (!isys_iommu || !psys_iommu) {
dev_err(&pdev->dev, "Can't allocate memory for iommu\n");
return -ENOMEM;
}
/* Share IOMMU mapping between isys and psys */
isys_iommu->m = psys_iommu->m = devm_kzalloc(
&pdev->dev, sizeof(*isys_iommu->m), GFP_KERNEL);
if (!isys_iommu->m) {
dev_err(&pdev->dev,
"Can't allocate memory for iommu mapping\n");
return -ENOMEM;
}
rval = pcim_enable_device(pdev);
if (rval) {
dev_err(&pdev->dev, "Failed to enable CI ISP device (%d)\n",
rval);
return rval;
}
phys = pci_resource_start(pdev, CSS2600_PCI_BAR);
rval = pcim_iomap_regions(pdev, 1 << CSS2600_PCI_BAR, pci_name(pdev));
if (rval) {
dev_err(&pdev->dev, "Failed to I/O memory remapping (%d)\n",
rval);
return rval;
}
dev_info(&pdev->dev, "physical base address 0x%llx\n", phys);
iomap = pcim_iomap_table(pdev);
if (!iomap) {
dev_err(&pdev->dev, "Failed to iomap table (%d)\n", rval);
return -ENODEV;
}
isp->base = iomap[CSS2600_PCI_BAR];
dev_info(&pdev->dev, "mapped as: 0x%p\n", isp->base);
pci_set_drvdata(pdev, isp);
pci_set_master(pdev);
switch (isp->pdev->device) {
case CSS2600_HW_MRFLD_2401:
psys_base = isp->base;
isys_base = isp->base;
fw_binary = CSS2401_FIRMWARE;
break;
case CSS2600_HW_BXT_FPGA:
dma_mask = 32;
/* fall through */
case CSS2600_HW_BXT:
psys_base = isp->base + CSS2600_BXT_A0_PSYS_OFFSET;
isys_base = isp->base + CSS2600_BXT_A0_ISYS_OFFSET;
fw_binary = NULL;
break;
default:
dev_err(&pdev->dev, "Not supported device\n");
return -EINVAL;
}
rval = pci_set_dma_mask(pdev, DMA_BIT_MASK(dma_mask));
if (!rval)
rval = pci_set_consistent_dma_mask(pdev,
DMA_BIT_MASK(dma_mask));
if (rval) {
dev_err(&pdev->dev, "Failed to set DMA mask (%d)\n", rval);
return rval;
}
if (fw_binary)
rval = request_firmware(&isp->fw, fw_binary, &pdev->dev);
if (rval) {
//.........这里部分代码省略.........
示例7: load_segment
static int load_segment(const struct elf32_phdr *phdr, unsigned num,
struct pil_device *pil)
{
int ret = 0, count, paddr;
char fw_name[30];
const struct firmware *fw = NULL;
const u8 *data;
if (memblock_overlaps_memory(phdr->p_paddr, phdr->p_memsz)) {
dev_err(&pil->dev, "%s: kernel memory would be overwritten "
"[%#08lx, %#08lx)\n", pil->desc->name,
(unsigned long)phdr->p_paddr,
(unsigned long)(phdr->p_paddr + phdr->p_memsz));
return -EPERM;
}
if (phdr->p_filesz) {
snprintf(fw_name, ARRAY_SIZE(fw_name), "%s.b%02d",
pil->desc->name, num);
ret = request_firmware(&fw, fw_name, &pil->dev);
if (ret) {
dev_err(&pil->dev, "%s: Failed to locate blob %s\n",
pil->desc->name, fw_name);
return ret;
}
if (fw->size != phdr->p_filesz) {
dev_err(&pil->dev, "%s: Blob size %u doesn't match "
"%u\n", pil->desc->name, fw->size,
phdr->p_filesz);
ret = -EPERM;
goto release_fw;
}
}
/* Load the segment into memory */
count = phdr->p_filesz;
paddr = phdr->p_paddr;
data = fw ? fw->data : NULL;
while (count > 0) {
int size;
u8 __iomem *buf;
size = min_t(size_t, IOMAP_SIZE, count);
buf = ioremap(paddr, size);
if (!buf) {
dev_err(&pil->dev, "%s: Failed to map memory\n",
pil->desc->name);
ret = -ENOMEM;
goto release_fw;
}
memcpy(buf, data, size);
iounmap(buf);
count -= size;
paddr += size;
data += size;
}
/* Zero out trailing memory */
count = phdr->p_memsz - phdr->p_filesz;
while (count > 0) {
int size;
u8 __iomem *buf;
size = min_t(size_t, IOMAP_SIZE, count);
buf = ioremap(paddr, size);
if (!buf) {
dev_err(&pil->dev, "%s: Failed to map memory\n",
pil->desc->name);
ret = -ENOMEM;
goto release_fw;
}
memset(buf, 0, size);
iounmap(buf);
count -= size;
paddr += size;
}
if (pil->desc->ops->verify_blob) {
ret = pil->desc->ops->verify_blob(pil->desc, phdr->p_paddr,
phdr->p_memsz);
if (ret)
dev_err(&pil->dev, "%s: Blob%u failed verification\n",
pil->desc->name, num);
}
release_fw:
release_firmware(fw);
return ret;
}
示例8: isl_upload_firmware
static int
isl_upload_firmware(islpci_private *priv)
{
u32 reg, rc;
void __iomem *device_base = priv->device_base;
/* clear the RAMBoot and the Reset bit */
reg = readl(device_base + ISL38XX_CTRL_STAT_REG);
reg &= ~ISL38XX_CTRL_STAT_RESET;
reg &= ~ISL38XX_CTRL_STAT_RAMBOOT;
writel(reg, device_base + ISL38XX_CTRL_STAT_REG);
wmb();
udelay(ISL38XX_WRITEIO_DELAY);
/* set the Reset bit without reading the register ! */
reg |= ISL38XX_CTRL_STAT_RESET;
writel(reg, device_base + ISL38XX_CTRL_STAT_REG);
wmb();
udelay(ISL38XX_WRITEIO_DELAY);
/* clear the Reset bit */
reg &= ~ISL38XX_CTRL_STAT_RESET;
writel(reg, device_base + ISL38XX_CTRL_STAT_REG);
wmb();
/* wait a while for the device to reboot */
mdelay(50);
{
const struct firmware *fw_entry = NULL;
long fw_len;
const u32 *fw_ptr;
rc = request_firmware(&fw_entry, priv->firmware, PRISM_FW_PDEV);
if (rc)
return rc;
/* prepare the Direct Memory Base register */
reg = ISL38XX_DEV_FIRMWARE_ADDRES;
fw_ptr = (u32 *) fw_entry->data;
fw_len = fw_entry->size;
if (fw_len % 4) {
printk(KERN_ERR
"%s: firmware '%s' size is not multiple of 32bit, aborting!\n",
"prism54", priv->firmware);
release_firmware(fw_entry);
return -EILSEQ; /* Illegal byte sequence */;
}
while (fw_len > 0) {
long _fw_len =
(fw_len >
ISL38XX_MEMORY_WINDOW_SIZE) ?
ISL38XX_MEMORY_WINDOW_SIZE : fw_len;
u32 __iomem *dev_fw_ptr = device_base + ISL38XX_DIRECT_MEM_WIN;
/* set the card's base address for writing the data */
isl38xx_w32_flush(device_base, reg,
ISL38XX_DIR_MEM_BASE_REG);
wmb(); /* be paranoid */
/* increment the write address for next iteration */
reg += _fw_len;
fw_len -= _fw_len;
/* write the data to the Direct Memory Window 32bit-wise */
/* memcpy_toio() doesn't guarantee 32bit writes :-| */
while (_fw_len > 0) {
/* use non-swapping writel() */
__raw_writel(*fw_ptr, dev_fw_ptr);
fw_ptr++, dev_fw_ptr++;
_fw_len -= 4;
}
/* flush PCI posting */
(void) readl(device_base + ISL38XX_PCI_POSTING_FLUSH);
wmb(); /* be paranoid again */
BUG_ON(_fw_len != 0);
}
BUG_ON(fw_len != 0);
/* Firmware version is at offset 40 (also for "newmac") */
printk(KERN_DEBUG "%s: firmware version: %.8s\n",
priv->ndev->name, fw_entry->data + 40);
release_firmware(fw_entry);
}
/* now reset the device
* clear the Reset & ClkRun bit, set the RAMBoot bit */
reg = readl(device_base + ISL38XX_CTRL_STAT_REG);
reg &= ~ISL38XX_CTRL_STAT_CLKRUN;
reg &= ~ISL38XX_CTRL_STAT_RESET;
reg |= ISL38XX_CTRL_STAT_RAMBOOT;
isl38xx_w32_flush(device_base, reg, ISL38XX_CTRL_STAT_REG);
wmb();
//.........这里部分代码省略.........
示例9: wm2000_i2c_probe
static int __devinit wm2000_i2c_probe(struct i2c_client *i2c,
const struct i2c_device_id *i2c_id)
{
struct wm2000_priv *wm2000;
struct wm2000_platform_data *pdata;
const char *filename;
const struct firmware *fw;
int reg, ret;
u16 id;
wm2000 = devm_kzalloc(&i2c->dev, sizeof(struct wm2000_priv),
GFP_KERNEL);
if (wm2000 == NULL) {
dev_err(&i2c->dev, "Unable to allocate private data\n");
return -ENOMEM;
}
dev_set_drvdata(&i2c->dev, wm2000);
wm2000->regmap = regmap_init_i2c(i2c, &wm2000_regmap);
if (IS_ERR(wm2000->regmap)) {
ret = PTR_ERR(wm2000->regmap);
dev_err(&i2c->dev, "Failed to allocate register map: %d\n",
ret);
goto err;
}
/* Verify that this is a WM2000 */
reg = wm2000_read(i2c, WM2000_REG_ID1);
id = reg << 8;
reg = wm2000_read(i2c, WM2000_REG_ID2);
id |= reg & 0xff;
if (id != 0x2000) {
dev_err(&i2c->dev, "Device is not a WM2000 - ID %x\n", id);
ret = -ENODEV;
goto err_regmap;
}
reg = wm2000_read(i2c, WM2000_REG_REVISON);
dev_info(&i2c->dev, "revision %c\n", reg + 'A');
filename = "wm2000_anc.bin";
pdata = dev_get_platdata(&i2c->dev);
if (pdata) {
wm2000->mclk_div = pdata->mclkdiv2;
wm2000->speech_clarity = !pdata->speech_enh_disable;
if (pdata->download_file)
filename = pdata->download_file;
}
ret = request_firmware(&fw, filename, &i2c->dev);
if (ret != 0) {
dev_err(&i2c->dev, "Failed to acquire ANC data: %d\n", ret);
goto err_regmap;
}
/* Pre-cook the concatenation of the register address onto the image */
wm2000->anc_download_size = fw->size + 2;
wm2000->anc_download = devm_kzalloc(&i2c->dev,
wm2000->anc_download_size,
GFP_KERNEL);
if (wm2000->anc_download == NULL) {
dev_err(&i2c->dev, "Out of memory\n");
ret = -ENOMEM;
goto err_fw;
}
wm2000->anc_download[0] = 0x80;
wm2000->anc_download[1] = 0x00;
memcpy(wm2000->anc_download + 2, fw->data, fw->size);
release_firmware(fw);
wm2000->anc_eng_ena = 1;
wm2000->anc_active = 1;
wm2000->spk_ena = 1;
wm2000->i2c = i2c;
wm2000_reset(wm2000);
ret = snd_soc_register_codec(&i2c->dev, &soc_codec_dev_wm2000,
NULL, 0);
if (ret != 0)
goto err_fw;
return 0;
err_fw:
release_firmware(fw);
err_regmap:
regmap_exit(wm2000->regmap);
err:
return ret;
}
示例10: ni_init_microcode
int ni_init_microcode(struct radeon_device *rdev)
{
struct platform_device *pdev;
const char *chip_name;
const char *rlc_chip_name;
size_t pfp_req_size, me_req_size, rlc_req_size, mc_req_size;
char fw_name[30];
int err;
DRM_DEBUG("\n");
pdev = platform_device_register_simple("radeon_cp", 0, NULL, 0);
err = IS_ERR(pdev);
if (err) {
printk(KERN_ERR "radeon_cp: Failed to register firmware\n");
return -EINVAL;
}
switch (rdev->family) {
case CHIP_BARTS:
chip_name = "BARTS";
rlc_chip_name = "BTC";
pfp_req_size = EVERGREEN_PFP_UCODE_SIZE * 4;
me_req_size = EVERGREEN_PM4_UCODE_SIZE * 4;
rlc_req_size = EVERGREEN_RLC_UCODE_SIZE * 4;
mc_req_size = BTC_MC_UCODE_SIZE * 4;
break;
case CHIP_TURKS:
chip_name = "TURKS";
rlc_chip_name = "BTC";
pfp_req_size = EVERGREEN_PFP_UCODE_SIZE * 4;
me_req_size = EVERGREEN_PM4_UCODE_SIZE * 4;
rlc_req_size = EVERGREEN_RLC_UCODE_SIZE * 4;
mc_req_size = BTC_MC_UCODE_SIZE * 4;
break;
case CHIP_CAICOS:
chip_name = "CAICOS";
rlc_chip_name = "BTC";
pfp_req_size = EVERGREEN_PFP_UCODE_SIZE * 4;
me_req_size = EVERGREEN_PM4_UCODE_SIZE * 4;
rlc_req_size = EVERGREEN_RLC_UCODE_SIZE * 4;
mc_req_size = BTC_MC_UCODE_SIZE * 4;
break;
case CHIP_CAYMAN:
chip_name = "CAYMAN";
rlc_chip_name = "CAYMAN";
pfp_req_size = CAYMAN_PFP_UCODE_SIZE * 4;
me_req_size = CAYMAN_PM4_UCODE_SIZE * 4;
rlc_req_size = CAYMAN_RLC_UCODE_SIZE * 4;
mc_req_size = CAYMAN_MC_UCODE_SIZE * 4;
break;
case CHIP_ARUBA:
chip_name = "ARUBA";
rlc_chip_name = "ARUBA";
/* pfp/me same size as CAYMAN */
pfp_req_size = CAYMAN_PFP_UCODE_SIZE * 4;
me_req_size = CAYMAN_PM4_UCODE_SIZE * 4;
rlc_req_size = ARUBA_RLC_UCODE_SIZE * 4;
mc_req_size = 0;
break;
default: BUG();
}
DRM_INFO("Loading %s Microcode\n", chip_name);
snprintf(fw_name, sizeof(fw_name), "radeon/%s_pfp.bin", chip_name);
err = request_firmware(&rdev->pfp_fw, fw_name, &pdev->dev);
if (err)
goto out;
if (rdev->pfp_fw->size != pfp_req_size) {
printk(KERN_ERR
"ni_cp: Bogus length %zu in firmware \"%s\"\n",
rdev->pfp_fw->size, fw_name);
err = -EINVAL;
goto out;
}
snprintf(fw_name, sizeof(fw_name), "radeon/%s_me.bin", chip_name);
err = request_firmware(&rdev->me_fw, fw_name, &pdev->dev);
if (err)
goto out;
if (rdev->me_fw->size != me_req_size) {
printk(KERN_ERR
"ni_cp: Bogus length %zu in firmware \"%s\"\n",
rdev->me_fw->size, fw_name);
err = -EINVAL;
}
snprintf(fw_name, sizeof(fw_name), "radeon/%s_rlc.bin", rlc_chip_name);
err = request_firmware(&rdev->rlc_fw, fw_name, &pdev->dev);
if (err)
goto out;
if (rdev->rlc_fw->size != rlc_req_size) {
printk(KERN_ERR
"ni_rlc: Bogus length %zu in firmware \"%s\"\n",
rdev->rlc_fw->size, fw_name);
err = -EINVAL;
}
/* no MC ucode on TN */
//.........这里部分代码省略.........
示例11: FirmwareDownload92S
bool FirmwareDownload92S(struct net_device *dev)
{
struct r8192_priv *priv = rtllib_priv(dev);
bool rtStatus = true;
u8 *pucMappedFile = NULL;
u32 ulFileLength = 0;
u8 FwHdrSize = RT_8192S_FIRMWARE_HDR_SIZE;
rt_firmware *pFirmware = priv->pFirmware;
u8 FwStatus = FW_STATUS_INIT;
PRT_8192S_FIRMWARE_HDR pFwHdr = NULL;
PRT_8192S_FIRMWARE_PRIV pFwPriv = NULL;
pFirmware->FWStatus = FW_STATUS_INIT;
RT_TRACE(COMP_FIRMWARE, " --->FirmwareDownload92S()\n");
#if LINUX_VERSION_CODE > KERNEL_VERSION(2,5,0) && defined(USE_FW_SOURCE_IMG_FILE)
priv->firmware_source = FW_SOURCE_IMG_FILE;
#else
priv->firmware_source = FW_SOURCE_HEADER_FILE;
#endif
switch( priv->firmware_source )
{
case FW_SOURCE_IMG_FILE:
#if LINUX_VERSION_CODE > KERNEL_VERSION(2,5,0) && defined(USE_FW_SOURCE_IMG_FILE)
if(pFirmware->szFwTmpBufferLen == 0)
{
#ifdef _RTL8192_EXT_PATCH_
const char *pFwImageFileName[1] = {"RTL8191SE_MESH/rtl8192sfw.bin"};
#else
const char *pFwImageFileName[1] = {"RTL8192SE/rtl8192sfw.bin"};
#endif
const struct firmware *fw_entry = NULL;
u32 ulInitStep = 0;
int rc = 0;
u32 file_length = 0;
rc = request_firmware(&fw_entry, pFwImageFileName[ulInitStep],&priv->pdev->dev);
if(rc < 0 ) {
RT_TRACE(COMP_ERR, "request firmware fail!\n");
goto DownloadFirmware_Fail;
}
if(fw_entry->size > sizeof(pFirmware->szFwTmpBuffer)) {
RT_TRACE(COMP_ERR, "img file size exceed the container buffer fail!\n");
release_firmware(fw_entry);
goto DownloadFirmware_Fail;
}
memcpy(pFirmware->szFwTmpBuffer,fw_entry->data,fw_entry->size);
pFirmware->szFwTmpBufferLen = fw_entry->size;
release_firmware(fw_entry);
pucMappedFile = pFirmware->szFwTmpBuffer;
file_length = pFirmware->szFwTmpBufferLen;
pFirmware->pFwHeader = (PRT_8192S_FIRMWARE_HDR) pucMappedFile;
pFwHdr = pFirmware->pFwHeader;
RT_TRACE(COMP_FIRMWARE,"signature:%x, version:%x, size:%x, imemsize:%x, sram size:%x\n", \
pFwHdr->Signature, pFwHdr->Version, pFwHdr->DMEMSize, \
pFwHdr->IMG_IMEM_SIZE, pFwHdr->IMG_SRAM_SIZE);
pFirmware->FirmwareVersion = byte(pFwHdr->Version ,0);
if ((pFwHdr->IMG_IMEM_SIZE==0) || (pFwHdr->IMG_IMEM_SIZE > sizeof(pFirmware->FwIMEM)))
{
RT_TRACE(COMP_ERR, "%s: memory for data image is less than IMEM required\n",\
__FUNCTION__);
goto DownloadFirmware_Fail;
} else {
pucMappedFile+=FwHdrSize;
memcpy(pFirmware->FwIMEM, pucMappedFile, pFwHdr->IMG_IMEM_SIZE);
pFirmware->FwIMEMLen = pFwHdr->IMG_IMEM_SIZE;
}
if (pFwHdr->IMG_SRAM_SIZE > sizeof(pFirmware->FwEMEM))
{
RT_TRACE(COMP_ERR, "%s: memory for data image is less than EMEM required\n",\
__FUNCTION__);
goto DownloadFirmware_Fail;
}
else
{
pucMappedFile += pFirmware->FwIMEMLen;
memcpy(pFirmware->FwEMEM, pucMappedFile, pFwHdr->IMG_SRAM_SIZE);
pFirmware->FwEMEMLen = pFwHdr->IMG_SRAM_SIZE;
}
}
#endif
break;
case FW_SOURCE_HEADER_FILE:
#if 1
#define Rtl819XFwImageArray Rtl8192SEFwImgArray
pucMappedFile = Rtl819XFwImageArray;
ulFileLength = ImgArrayLength;
RT_TRACE(COMP_INIT,"Fw download from header.\n");
pFirmware->pFwHeader = (PRT_8192S_FIRMWARE_HDR) pucMappedFile;
pFwHdr = pFirmware->pFwHeader;
//.........这里部分代码省略.........
示例12: switch
/*
* predef should be 0 for loading user defined mcs
* predef should be YAM_1200 for loading predef 1200 mcs
* predef should be YAM_9600 for loading predef 9600 mcs
*/
static unsigned char *add_mcs(unsigned char *bits, int bitrate,
unsigned int predef)
{
const char *fw_name[2] = {FIRMWARE_9600, FIRMWARE_1200};
const struct firmware *fw;
struct platform_device *pdev;
struct yam_mcs *p;
int err;
switch (predef) {
case 0:
fw = NULL;
break;
case YAM_1200:
case YAM_9600:
predef--;
pdev = platform_device_register_simple("yam", 0, NULL, 0);
if (IS_ERR(pdev)) {
printk(KERN_ERR "yam: Failed to register firmware\n");
return NULL;
}
err = request_firmware(&fw, fw_name[predef], &pdev->dev);
platform_device_unregister(pdev);
if (err)
return NULL;
if (fw->size != YAM_FPGA_SIZE) {
printk(KERN_ERR "Bogus length %zu in firmware \"%s\"\n",
fw->size, fw_name[predef]);
release_firmware(fw);
return NULL;
}
bits = (unsigned char *)fw->data;
break;
default:
printk(KERN_ERR "yam: Invalid predef number %u\n", predef);
return NULL;
}
/* If it already exists, replace the bit data */
p = yam_data;
while (p) {
if (p->bitrate == bitrate) {
memcpy(p->bits, bits, YAM_FPGA_SIZE);
goto out;
}
p = p->next;
}
/* Allocate a new mcs */
if ((p = kmalloc(sizeof(struct yam_mcs), GFP_KERNEL)) == NULL) {
release_firmware(fw);
return NULL;
}
memcpy(p->bits, bits, YAM_FPGA_SIZE);
p->bitrate = bitrate;
p->next = yam_data;
yam_data = p;
out:
release_firmware(fw);
return p->bits;
}
示例13: load_image
static int load_image(struct pil_device *pil)
{
int i, ret;
char fw_name[30];
struct elf32_hdr *ehdr;
const struct elf32_phdr *phdr;
const struct firmware *fw;
unsigned long proxy_timeout = pil->desc->proxy_timeout;
down_read(&pil_pm_rwsem);
snprintf(fw_name, sizeof(fw_name), "%s.mdt", pil->desc->name);
ret = request_firmware(&fw, fw_name, &pil->dev);
if (ret) {
dev_err(&pil->dev, "%s: Failed to locate %s\n",
pil->desc->name, fw_name);
goto out;
}
if (fw->size < sizeof(*ehdr)) {
dev_err(&pil->dev, "%s: Not big enough to be an elf header\n",
pil->desc->name);
ret = -EIO;
goto release_fw;
}
ehdr = (struct elf32_hdr *)fw->data;
if (memcmp(ehdr->e_ident, ELFMAG, SELFMAG)) {
dev_err(&pil->dev, "%s: Not an elf header\n", pil->desc->name);
ret = -EIO;
goto release_fw;
}
if (ehdr->e_phnum == 0) {
dev_err(&pil->dev, "%s: No loadable segments\n",
pil->desc->name);
ret = -EIO;
goto release_fw;
}
if (sizeof(struct elf32_phdr) * ehdr->e_phnum +
sizeof(struct elf32_hdr) > fw->size) {
dev_err(&pil->dev, "%s: Program headers not within mdt\n",
pil->desc->name);
ret = -EIO;
goto release_fw;
}
ret = pil->desc->ops->init_image(pil->desc, fw->data, fw->size);
if (ret) {
dev_err(&pil->dev, "%s: Invalid firmware metadata\n",
pil->desc->name);
goto release_fw;
}
phdr = (const struct elf32_phdr *)(fw->data + sizeof(struct elf32_hdr));
for (i = 0; i < ehdr->e_phnum; i++, phdr++) {
if (!segment_is_loadable(phdr))
continue;
ret = load_segment(phdr, i, pil);
if (ret) {
dev_err(&pil->dev, "%s: Failed to load segment %d\n",
pil->desc->name, i);
goto release_fw;
}
}
ret = pil_proxy_vote(pil);
if (ret) {
dev_err(&pil->dev, "%s: Failed to proxy vote\n",
pil->desc->name);
goto release_fw;
}
ret = pil->desc->ops->auth_and_reset(pil->desc);
if (ret) {
dev_err(&pil->dev, "%s: Failed to bring out of reset\n",
pil->desc->name);
proxy_timeout = 0; /* Remove proxy vote immediately on error */
goto err_boot;
}
dev_info(&pil->dev, "%s: Brought out of reset\n", pil->desc->name);
err_boot:
pil_proxy_unvote(pil, proxy_timeout);
release_fw:
release_firmware(fw);
out:
up_read(&pil_pm_rwsem);
return ret;
}
示例14: zd1201_fw_upload
static int zd1201_fw_upload(struct usb_device *dev, int apfw)
{
const struct firmware *fw_entry;
const char *data;
unsigned long len;
int err;
unsigned char ret;
char *buf;
char *fwfile;
if (apfw)
fwfile = "zd1201-ap.fw";
else
fwfile = "zd1201.fw";
err = request_firmware(&fw_entry, fwfile, &dev->dev);
if (err) {
dev_err(&dev->dev, "Failed to load %s firmware file!\n", fwfile);
dev_err(&dev->dev, "Make sure the hotplug firmware loader is installed.\n");
dev_err(&dev->dev, "Goto http://linux-lc100020.sourceforge.net for more info.\n");
return err;
}
data = fw_entry->data;
len = fw_entry->size;
buf = kmalloc(1024, GFP_ATOMIC);
if (!buf)
goto exit;
while (len > 0) {
int translen = (len > 1024) ? 1024 : len;
memcpy(buf, data, translen);
err = usb_control_msg(dev, usb_sndctrlpipe(dev, 0), 0,
USB_DIR_OUT | 0x40, 0, 0, buf, translen,
ZD1201_FW_TIMEOUT);
if (err < 0)
goto exit;
len -= translen;
data += translen;
}
err = usb_control_msg(dev, usb_sndctrlpipe(dev, 0), 0x2,
USB_DIR_OUT | 0x40, 0, 0, NULL, 0, ZD1201_FW_TIMEOUT);
if (err < 0)
goto exit;
err = usb_control_msg(dev, usb_rcvctrlpipe(dev, 0), 0x4,
USB_DIR_IN | 0x40, 0, 0, buf, sizeof(ret), ZD1201_FW_TIMEOUT);
if (err < 0)
goto exit;
memcpy(&ret, buf, sizeof(ret));
if (ret & 0x80) {
err = -EIO;
goto exit;
}
err = 0;
exit:
kfree(buf);
release_firmware(fw_entry);
return err;
}
示例15: lbs_get_firmware
/**
* lbs_get_firmware - Retrieves two-stage firmware
*
* @dev: A pointer to &device structure
* @user_helper: User-defined helper firmware file
* @user_mainfw: User-defined main firmware file
* @card_model: Bus-specific card model ID used to filter firmware table
* elements
* @fw_table: Table of firmware file names and device model numbers
* terminated by an entry with a NULL helper name
* @helper: On success, the helper firmware; caller must free
* @mainfw: On success, the main firmware; caller must free
*
* returns: 0 on success, non-zero on failure
*/
int lbs_get_firmware(struct device *dev, const char *user_helper,
const char *user_mainfw, u32 card_model,
const struct lbs_fw_table *fw_table,
const struct firmware **helper,
const struct firmware **mainfw)
{
const struct lbs_fw_table *iter;
int ret;
BUG_ON(helper == NULL);
BUG_ON(mainfw == NULL);
/* Try user-specified firmware first */
if (user_helper) {
ret = request_firmware(helper, user_helper, dev);
if (ret) {
dev_err(dev, "couldn't find helper firmware %s\n",
user_helper);
goto fail;
}
}
if (user_mainfw) {
ret = request_firmware(mainfw, user_mainfw, dev);
if (ret) {
dev_err(dev, "couldn't find main firmware %s\n",
user_mainfw);
goto fail;
}
}
if (*helper && *mainfw)
return 0;
/* Otherwise search for firmware to use. If neither the helper or
* the main firmware were specified by the user, then we need to
* make sure that found helper & main are from the same entry in
* fw_table.
*/
iter = fw_table;
while (iter && iter->helper) {
if (iter->model != card_model)
goto next;
if (*helper == NULL) {
ret = request_firmware(helper, iter->helper, dev);
if (ret)
goto next;
/* If the device has one-stage firmware (ie cf8305) and
* we've got it then we don't need to bother with the
* main firmware.
*/
if (iter->fwname == NULL)
return 0;
}
if (*mainfw == NULL) {
ret = request_firmware(mainfw, iter->fwname, dev);
if (ret && !user_helper) {
/* Clear the helper if it wasn't user-specified
* and the main firmware load failed, to ensure
* we don't have mismatched firmware pairs.
*/
release_firmware(*helper);
*helper = NULL;
}
}
if (*helper && *mainfw)
return 0;
next:
iter++;
}
fail:
/* Failed */
if (*helper) {
release_firmware(*helper);
*helper = NULL;
}
if (*mainfw) {
release_firmware(*mainfw);
*mainfw = NULL;
}
//.........这里部分代码省略.........