int gxio_usb_host_get_mmio_base(gxio_usb_host_context_t * context, HV_PTE *base) { int __result; struct get_mmio_base_param temp; struct get_mmio_base_param *params = &temp; __result = hv_dev_pread(context->fd, 0, (HV_VirtAddr) params, sizeof(*params), GXIO_USB_HOST_OP_GET_MMIO_BASE); *base = params->base; return __result; }
int __iorpc_get_mmio_base(int fd, HV_PTE *base) { int __result; struct get_mmio_base_param temp; struct get_mmio_base_param *params = &temp; __result = hv_dev_pread(fd, 0, (HV_VirtAddr) params, sizeof(*params), IORPC_OP_GET_MMIO_BASE); *base = params->base; return __result; }
int gxio_trio_get_port_property(gxio_trio_context_t * context, struct pcie_trio_ports_property *trio_ports) { int __result; struct get_port_property_param temp; struct get_port_property_param *params = &temp; __result = hv_dev_pread(context->fd, 0, (HV_VirtAddr) params, sizeof(*params), GXIO_TRIO_OP_GET_PORT_PROPERTY); *trio_ports = params->trio_ports; return __result; }
/* * This asks the HV how much transmit buffer space is available. */ static int softuart_write_room(struct tty_struct *tty) { u32 write_room; int len; len = hv_dev_pread(softuart_fd, 0, (HV_VirtAddr)(&write_room), sizeof(u32), SOFTUART_WRITEROOM); if (len != sizeof(u32)) { pr_err("softuart: Unable to read from HV: %d\n", len); write_room = 0; } return write_room; }
/* Called with callback_lock held */ static int softuart_do_receive_chars(struct tty_struct *tty) { int len = 0; char buf[1024]; int n; /* Need to check to see if anything's available */ len = hv_dev_pread(softuart_fd, 0, (HV_VirtAddr)(buf), 1024, SOFTUART_DATA_READ); if (len > 0) { for (n = 0; n < len; n++) tty_insert_flip_char(tty, buf[n], 0); tty_schedule_flip(tty); } else if (len < 0) pr_err("softuart: Couldn't read from HV: %d\n", len); return len; }
static void tile_edac_check(struct mem_ctl_info *mci) { struct tile_edac_priv *priv = mci->pvt_info; struct mshim_mem_error mem_error; if (hv_dev_pread(priv->hv_devhdl, 0, (HV_VirtAddr)&mem_error, sizeof(struct mshim_mem_error), MSHIM_MEM_ERROR_OFF) != sizeof(struct mshim_mem_error)) { pr_err(DRV_NAME ": MSHIM_MEM_ERROR_OFF pread failure.\n"); return; } if (mem_error.sbe_count != priv->ce_count) { dev_dbg(mci->dev, "ECC CE err on node %d\n", priv->node); priv->ce_count = mem_error.sbe_count; edac_mc_handle_ce(mci, 0, 0, 0, 0, 0, mci->ctl_name); } }
static void tile_edac_check(struct mem_ctl_info *mci) { struct tile_edac_priv *priv = mci->pvt_info; struct mshim_mem_error mem_error; if (hv_dev_pread(priv->hv_devhdl, 0, (HV_VirtAddr)&mem_error, sizeof(struct mshim_mem_error), MSHIM_MEM_ERROR_OFF) != sizeof(struct mshim_mem_error)) { pr_err(DRV_NAME ": MSHIM_MEM_ERROR_OFF pread failure.\n"); return; } /* Check if the current error count is different from the saved one. */ if (mem_error.sbe_count != priv->ce_count) { dev_dbg(mci->pdev, "ECC CE err on node %d\n", priv->node); priv->ce_count = mem_error.sbe_count; edac_mc_handle_error(HW_EVENT_ERR_CORRECTED, mci, 1, 0, 0, 0, 0, 0, -1, mci->ctl_name, ""); } }
static int __devinit tile_edac_init_csrows(struct mem_ctl_info *mci) { struct csrow_info *csrow = &mci->csrows[0]; struct tile_edac_priv *priv = mci->pvt_info; struct mshim_mem_info mem_info; if (hv_dev_pread(priv->hv_devhdl, 0, (HV_VirtAddr)&mem_info, sizeof(struct mshim_mem_info), MSHIM_MEM_INFO_OFF) != sizeof(struct mshim_mem_info)) { pr_err(DRV_NAME ": MSHIM_MEM_INFO_OFF pread failure.\n"); return -1; } if (mem_info.mem_ecc) csrow->edac_mode = EDAC_SECDED; else csrow->edac_mode = EDAC_NONE; switch (mem_info.mem_type) { case DDR2: csrow->mtype = MEM_DDR2; break; case DDR3: csrow->mtype = MEM_DDR3; break; default: return -1; } csrow->first_page = 0; csrow->nr_pages = mem_info.mem_size >> PAGE_SHIFT; csrow->last_page = csrow->first_page + csrow->nr_pages - 1; csrow->grain = TILE_EDAC_ERROR_GRAIN; csrow->dtype = DEV_UNKNOWN; return 0; }
static int tile_srom_read(struct mtd_info *mtd, loff_t from, size_t len, size_t *retlen, unsigned char *buf) { struct tile_srom_dev *dev = to_tile_srom_dev(mtd); int curoff = 0; char rd_buf[mtd->writesize]; int returned = 0; /* Sanity checking */ if (len == 0) return 0; if (from + len > mtd->size) return -EINVAL; /* Align to a page, since the HV requires that. */ if (from & (mtd->writesize - 1)) { curoff = from & (mtd->writesize - 1); from -= curoff; } while (len) { int thislen; int hv_retval; /* We always read the same length. */ hv_retval = hv_dev_pread(dev->hv_devhdl, 0, (HV_VirtAddr) rd_buf, mtd->writesize, from); if (hv_retval < mtd->writesize) { DEBUG(MTD_DEBUG_LEVEL1, "hv_dev_pread failed," " error %d\n", hv_retval); if (retlen) *retlen = returned; return -EIO; } /* (We can do the copy length computation afterwards.) */ thislen = (mtd->writesize - curoff > len) ? len : mtd->writesize - curoff; /* If this is found to be performance-critical, a copy can * be eliminated by fastpathing the case in which thislen == * mtd->write_size. I think that SPI performance will be * the bottleneck here, though, not memory bandwidth... */ memcpy(buf, rd_buf + curoff, thislen); returned += thislen; len -= thislen; from += mtd->writesize; buf += thislen; /* We only have an offset once. */ curoff = 0; } if (retlen) *retlen = returned; return 0; }
static int __init tile_srom_setup(struct tile_srom_dev *dev) { int rv; const char *fn = "srom/0/mtd"; u32 tmp; /* * No mutex needed, because the hypervisor will serialize accesses * for us. */ /* Start off dead. */ dev->alive = 0; /* Light it up -- if it's not there, then it's not our problem now. */ dev->hv_devhdl = hv_dev_open((HV_VirtAddr)fn, 0); if (dev->hv_devhdl < 0) { switch (dev->hv_devhdl) { case HV_ENODEV: pr_info("tile_srom: %s not present\n", fn); return -ENODEV; default: pr_info("tile_srom: open %s failed with other %d\n", fn, dev->hv_devhdl); return dev->hv_devhdl; } } /* Populate parameters from HV. */ dev->mtd.name = "srom"; dev->mtd.type = MTD_NORFLASH; dev->mtd.flags = MTD_CAP_NORFLASH; hv_dev_pread(dev->hv_devhdl, 0, (HV_VirtAddr)&(dev->mtd.erasesize), sizeof(dev->mtd.erasesize), SROM_SECTOR_SIZE_OFF); hv_dev_pread(dev->hv_devhdl, 0, (HV_VirtAddr)&(dev->mtd.writesize), sizeof(dev->mtd.writesize), SROM_PAGE_SIZE_OFF); hv_dev_pread(dev->hv_devhdl, 0, (HV_VirtAddr)&tmp, sizeof(tmp), SROM_TOTAL_SIZE_OFF); dev->mtd.size = tmp; dev->mtd.erase = tile_srom_erase; dev->mtd.read = tile_srom_read; dev->mtd.write = tile_srom_write; DEBUG(MTD_DEBUG_LEVEL2, "mtd .name = %s, .size = 0x%llx (%lld MiB) " ".erasesize = 0x%.8x (%uKiB) .numeraseregions = %d\n", dev->mtd.name, (long long)dev->mtd.size, (long long)(dev->mtd.size >> 20), dev->mtd.erasesize, dev->mtd.erasesize / 1024, dev->mtd.numeraseregions); /* Now that it's all populated... */ rv = add_mtd_device(&dev->mtd); if (rv != 0) return -ENODEV; /* And once we've succeeded... */ dev->alive = 1; pr_info("tile_srom: found SROM, %lld bytes\n", (long long)dev->mtd.size); return 0; }