Example #1
0
static void
cfi_jedec_id_2(struct cfi * const cfi)
{
	struct cfi_jedec_id_data *idp = &cfi->cfi_id_data;
	uint16_t data[0x10];

	bus_space_read_region_2(cfi->cfi_bst, cfi->cfi_bsh, 0, data,
		__arraycount(data));

	CFI_DUMP_JEDEC(0, data, sizeof(data), 1);

	idp->id_mid = data[0];
	idp->id_did[0] = data[1];
	idp->id_did[1] = data[0xe];
	idp->id_did[2] = data[0xf];
	idp->id_prot_state = data[2];
	idp->id_indicators = data[3];

	/* software bits, upper and lower
	 * - undefined on S29GL-P
	 * - defined   on S29GL-S
	 */
	idp->id_swb_lo = data[0xc];
	idp->id_swb_hi = data[0xd];

}
Example #2
0
/*
 * Given a NIC memory source address and a host memory destination
 *	address, copy 'amount' from NIC to host using shared memory.
 *	The 'amount' is rounded up to a word - okay as long as mbufs
 *		are word sized.  That's what the +1 is below.
 * This routine accesses things as 16 bit quantities.
 */
void
ed_shmem_readmem16(struct ed_softc *sc, bus_size_t src, uint8_t *dst,
    uint16_t amount)
{
	bus_space_read_region_2(sc->mem_bst, sc->mem_bsh, src, (uint16_t *)dst,
	    (amount + 1) / 2);
}
Example #3
0
static void
cfi_chip_query_2(struct cfi * const cfi)
{
	uint16_t data[0x80];

	bus_space_read_region_2(cfi->cfi_bst, cfi->cfi_bsh, 0, data,
	    __arraycount(data));
	CFI_DUMP_QRY(0, data, sizeof(data), 2);
	CFI_QRY_UNPACK_COMMON(cfi, data, uint16_t);
}
Example #4
0
static int
cfi_0002_read_page(device_t self, flash_off_t offset, uint8_t *datap)
{
	struct nor_softc * const sc = device_private(self);
	KASSERT(sc != NULL);
	KASSERT(sc->sc_nor_if != NULL);
	struct cfi *cfi = (struct cfi * const)sc->sc_nor_if->private;
	KASSERT(cfi != NULL);
	struct nor_chip * const chip = &sc->sc_chip;
	KASSERT(chip != NULL);
	KASSERT(chip->nc_page_mask != 0);
	KASSERT((offset & ~chip->nc_page_mask) == 0);
	KASSERT (chip->nc_page_size != 0);
	KASSERT((chip->nc_page_size & ((1 << cfi->cfi_portwidth) - 1)) == 0);

	CFI_0002_STATS_INC(cfi, read_page);

	bus_size_t count = chip->nc_page_size >> cfi->cfi_portwidth;
							/* #words/page */

	int error = cfi_0002_busy_wait(cfi, offset, cfi_0002_time_dflt(cfi));
	if (error != 0)
		return error;

	switch(cfi->cfi_portwidth) {
	case 0:
		bus_space_read_region_1(cfi->cfi_bst, cfi->cfi_bsh, offset,
			(uint8_t *)datap, count);
		break;
	case 1:
		bus_space_read_region_2(cfi->cfi_bst, cfi->cfi_bsh, offset,
			(uint16_t *)datap, count);
		break;
	case 2:
		bus_space_read_region_4(cfi->cfi_bst, cfi->cfi_bsh, offset,
			(uint32_t *)datap, count);
		break;
	default:
		panic("%s: bad port width %d\n", __func__, cfi->cfi_portwidth);
	};

	return 0;
}
void
bs_through_bs_rr_2(bus_space_tag_t t, bus_space_handle_t bsh,
	    bus_size_t offset, u_int16_t *addr, bus_size_t count)
{
	bus_space_read_region_2(t->bs_base, bsh, offset, addr, count);
}