static int
sti_sgc_probe(bus_space_tag_t iot, int slot)
{
	bus_space_handle_t ioh;
	int devtype;

	if (bus_space_map(iot, (bus_addr_t)sgc_slottopa(slot),
	    PAGE_SIZE, 0, &ioh))
		return 0;

	devtype = bus_space_read_1(iot, ioh, 3);

	bus_space_unmap(iot, ioh, PAGE_SIZE);

	/*
	 * This might not be reliable enough. On the other hand, non-STI
	 * SGC cards will apparently not initialize in an hp300, to the
	 * point of not even answering bus probes (checked with an
	 * Harmony/FDDI SGC card).
	 */
	if (devtype != STI_DEVTYPE1 && devtype != STI_DEVTYPE4)
		return 0;

	return 1;
}
Exemple #2
0
void
sticninit()
{
	extern struct hp300_bus_space_tag hp300_mem_tag;
	bus_space_tag_t iot;
	bus_addr_t base;
	int i;

	/*
	 * We are not interested by the *first* console pass.
	 */
	if (consolepass == 0)
		return;

	iot = &hp300_mem_tag;
	base = (bus_addr_t)sgc_slottopa(CONSCODE_TO_SGC_SLOT(conscode));

	/* stifb_cn_bases[0] will be fixed in sti_cnattach() */
	for (i = 0; i < STI_REGION_MAX; i++)
		stifb_cn_bases[i] = base;

	sti_cnattach(&stifb_cn, iot, stifb_cn_bases, STI_CODEBASE_M68K);
	sti_clear(&stifb_cn);

	/*
	 * Since the copyright notice could not be displayed before,
	 * display it again now.
	 */
	printf("%s\n", copyright);
}
static void
sti_sgc_attach(device_t parent, device_t self, void *aux)
{
	struct sti_softc *sc = device_private(self);
	struct sgc_attach_args *saa = aux;
	bus_space_handle_t romh;
	bus_addr_t base;
	u_int romend;
	int i;

	sc->sc_dev = self;

	if (saa->saa_slot == sticonslot) {
		sc->sc_flags |= STI_CONSOLE | STI_ATTACHED;
		sc->sc_rom = &sticn_rom;
		sc->sc_scr = &sticn_scr;
		memcpy(sc->bases, sticn_bases, sizeof(sc->bases));

		sti_describe(sc);
	} else {
		base = (bus_addr_t)sgc_slottopa(saa->saa_slot);
		if (bus_space_map(saa->saa_iot, base, PAGE_SIZE, 0, &romh)) {
			aprint_error(": can't map ROM");
			return;
		}
		/*
		 * Compute real PROM size
		 */
		romend = sti_rom_size(saa->saa_iot, romh);

		bus_space_unmap(saa->saa_iot, romh, PAGE_SIZE);

		if (bus_space_map(saa->saa_iot, base, romend, 0, &romh)) {
			aprint_error(": can't map frame buffer");
			return;
		}

		sc->bases[0] = romh;
		for (i = 0; i < STI_REGION_MAX; i++)
			sc->bases[i] = base;

		if (sti_attach_common(sc, saa->saa_iot, saa->saa_iot, romh,
		    STI_CODEBASE_ALT) != 0)
			return;
	}

	/*
	 * Note on 425e sti(4) framebuffer bitmap memory can be accessed at
	 * (sgc_slottopa(saa->saa_slot) + 0x200000)
	 * but the mmap function to map bitmap display is not provided yet.
	 */

	sti_end_attach(sc);
}
Exemple #4
0
void
sti_sgc_attach(struct device *parent, struct device *self, void *aux)
{
	struct sti_softc *sc = (void *)self;
	struct sgc_attach_args *saa = aux;
	bus_addr_t base;
	bus_space_handle_t ioh;
	u_int romend;
	int i;

	/*
	 * If we already probed it succesfully as a console device, go ahead,
	 * since we will not be able to bus_space_map() again.
	 */
	if (SGC_SLOT_TO_CONSCODE(saa->saa_slot) == conscode) {
		sc->sc_flags |= STI_CONSOLE | STI_ATTACHED;
		sc->sc_scr = &stifb_cn;
		bcopy(stifb_cn_bases, sc->bases, sizeof(sc->bases));

		sti_describe(sc);
	} else {
		base = (bus_addr_t)sgc_slottopa(saa->saa_slot);

		if (bus_space_map(saa->saa_iot, base, PAGE_SIZE, 0, &ioh)) {
			printf(": can't map frame buffer");
			return;
		}

		/*
		 * Compute real PROM size
		 */
		romend = sti_rom_size(saa->saa_iot, ioh);

		bus_space_unmap(saa->saa_iot, ioh, PAGE_SIZE);

		if (bus_space_map(saa->saa_iot, base, romend, 0, &ioh)) {
			printf(": can't map frame buffer");
			return;
		}

		sc->memt = sc->iot = saa->saa_iot;
		sc->romh = ioh;
		sc->bases[0] = sc->romh;
		for (i = 1; i < STI_REGION_MAX; i++)
			sc->bases[i] = base;

		if (sti_attach_common(sc, STI_CODEBASE_M68K) != 0)
			return;
	}

	sti_end_attach(sc);
}
void
sgcattach(device_t parent, device_t self, void *aux)
{
	struct sgc_softc *sc;
	struct sgc_attach_args saa;
	paddr_t pa;
	void *va;
	int slot, rv;
	bus_space_tag_t bst;
	bus_space_handle_t bsh;

	sc = device_private(self);
	sc->sc_dev = self;
	aprint_normal("\n");

	bst = &sc->sc_tag;
	memset(bst, 0, sizeof(struct bus_space_tag));
	bst->bustype = HP300_BUS_SPACE_SGC;

	for (slot = 0; slot < SGC_NSLOTS; slot++) {
		pa = sgc_slottopa(slot);
		if (bus_space_map(bst, pa, PAGE_SIZE, 0, &bsh) != 0) {
			aprint_error_dev(self, "can't map slot %d\n", slot);
			continue;
		}
		va = bus_space_vaddr(bst, bsh);

		/* Check for hardware. */
		rv = badaddr(va);
		bus_space_unmap(bst, bsh, PAGE_SIZE);

		if (rv != 0) {
			DPRINTF(("%s: no valid device at slot %d\n",
			    device_xname(self), slot));
			continue;
		}

		memset(&saa, 0, sizeof(saa));
		saa.saa_iot = bst;
		saa.saa_slot = slot;

		/* Attach matching device. */
		config_found(self, &saa, sgcprint);
	}
}