Пример #1
0
static void
mkclock_hb_attach(device_t parent, device_t self, void *aux)
{
    struct mk48txx_softc *sc = device_private(self);
    struct hb_attach_args *ha = aux;

    sc->sc_dev = self;
    sc->sc_bst = ha->ha_bust;
    if (bus_space_map(sc->sc_bst, (bus_addr_t)ha->ha_address, ha->ha_size,
                      0, &sc->sc_bsh) != 0)
        aprint_error("can't map device space\n");

    sc->sc_model = "mk48t02";
    sc->sc_year0 = 1900;
    mk48txx_attach(sc);

    aprint_normal("\n");
}
Пример #2
0
void
mkclock_isa_attach(struct device *parent, struct device *self, void *aux)
{
	struct isa_attach_args *ia = aux;
	struct mkclock_isa_softc *sc = (struct mkclock_isa_softc *)self;

	/* Map I/O space. */
	sc->sc_iot = ia->ia_iot;
	if (bus_space_map(sc->sc_iot, ia->ia_io[0].ir_addr,
	    ia->ia_io[0].ir_size, 0, &sc->sc_ioh))
		panic("mkclock_isa_attach: couldn't map clock I/O space");

	/* Attach to MI mk48txx driver. */
	sc->sc_todr = mk48txx_attach(sc->sc_iot, sc->sc_ioh, "mk48t18", 1900,
	    mkclock_isa_nvrd, mkclock_isa_nvwr);
	if (sc->sc_todr == NULL)
		panic("\nmkclock_isa_attach: mk48txx attach failed");

	clockattach(self, &mkclock_isa_clockfns);
}
void
mkclock_sbdio_attach(device_t parent, device_t self, void *aux)
{
	struct mk48txx_softc *sc = device_private(self);
	struct sbdio_attach_args *sa = aux;
	bus_size_t size;

	sc->sc_dev = self;
	switch (sa->sa_flags) {
	case 0x0000:
		sc->sc_model = "mk48t08";
		size = MK48T08_CLKSZ;
		break;

	case 0x0001:
		sc->sc_model = "mk48t18";
		size = MK48T18_CLKSZ;
		break;

	default:
		/* assume MK48T18 */
		sc->sc_model = "mk48t18";
		size = MK48T18_CLKSZ;
		break;
	}

	sc->sc_bst = sa->sa_bust;
	if (bus_space_map(sc->sc_bst, sa->sa_addr1, size, 0,
	    &sc->sc_bsh) != 0) {
		aprint_error(": can't map device space\n");
		return;
	}

	sc->sc_year0 = 2000;	/* XXX Is this OK? */
	sc->sc_nvrd = mkclock_sbdio_nvrd;
	sc->sc_nvwr = mkclock_sbdio_nvwr;

	mk48txx_attach(sc);

	aprint_normal("\n");
}
Пример #4
0
int
eeprom_attach(device_t dev, phandle_t node, bus_space_tag_t bt,
    bus_space_handle_t bh)
{
	struct timespec ts;
	struct idprom *idp;
	char *model;
	int error, i;
	u_int32_t h;

	if (OF_getprop_alloc(node, "model", 1, (void **)&model) == -1)
		panic("eeprom_attach: no model property");

	/* Our TOD clock year 0 is 1968 */
	if ((error = mk48txx_attach(dev, bt, bh, model, 1968)) != 0) {
		device_printf(dev, "Can't attach %s tod clock", model);
		free(model, M_OFWPROP);
		return (error);
	}
	/* XXX: register clock device */

	/* Get the host ID from the prom. */
	idp = (struct idprom *)((u_long)bh + IDPROM_OFFSET);
	h = bus_space_read_1(bt, bh, IDPROM_OFFSET +
	    offsetof(struct idprom, id_machine)) << 24;
	for (i = 0; i < 3; i++) {
		h |= bus_space_read_1(bt, bh, IDPROM_OFFSET +
		    offsetof(struct idprom, id_hostid[i])) << ((2 - i) * 8);
	}
	/* XXX: register host id */
	device_printf(dev, "hostid %x\n", (u_int)h);
	if (bootverbose) {
		mk48txx_gettime(dev, &ts);
		device_printf(dev, "current time: %ld.%09ld\n", (long)ts.tv_sec,
		    ts.tv_nsec);
	}

	return (0);
}
Пример #5
0
static int
eeprom_attach(device_t dev)
{
	struct mk48txx_softc *sc;
	struct timespec ts;
	int error, rid;

	sc = device_get_softc(dev);

	mtx_init(&sc->sc_mtx, "eeprom_mtx", NULL, MTX_DEF);

	rid = 0;
	sc->sc_res = bus_alloc_resource_any(dev, SYS_RES_MEMORY, &rid,
	    RF_ACTIVE);
	if (sc->sc_res == NULL) {
		device_printf(dev, "cannot allocate resources\n");
		error = ENXIO;
		goto fail_mtx;
	}

	if ((sc->sc_model = ofw_bus_get_model(dev)) == NULL) {
		device_printf(dev, "cannot determine model\n");
		error = ENXIO;
		goto fail_res;
	}

	/* Our TOD clock year 0 is 1968. */
	sc->sc_year0 = 1968;
	/* Use default register read/write functions. */
	sc->sc_flag = 0;
	/*
	 * Generally, if the `eeprom' node has a `watchdog-enable' property
	 * this indicates that the watchdog part of the MK48T59 is usable,
	 * i.e. its RST pin is connected to the WDR input of the CPUs or
	 * something. The `eeprom' nodes of E250, E450 and the clock board
	 * variant in Exx00 have such properties. For E250 and E450 the
	 * watchdog just works, for Exx00 the delivery of the reset signal
	 * apparently has to be additionally enabled elsewhere...
	 * The OFW environment variable `watchdog-reboot?' is ignored for
	 * these watchdogs as they always trigger a system reset when they
	 * time out and can't be made to issue a break to the boot monitor
	 * instead.
	 */
	if (OF_getproplen(ofw_bus_get_node(dev), "watchdog-enable") != -1 &&
	    (strcmp(sparc64_model, "SUNW,Ultra-250") == 0 ||
	    strcmp(sparc64_model, "SUNW,Ultra-4") == 0))
		sc->sc_flag |= MK48TXX_WDOG_REGISTER | MK48TXX_WDOG_ENABLE_WDS;
	if ((error = mk48txx_attach(dev)) != 0) {
		device_printf(dev, "cannot attach time of day clock\n");
		goto fail_res;
	}

	if (bootverbose) {
		if (mk48txx_gettime(dev, &ts) != 0)
			device_printf(dev, "invalid time");
		else
			device_printf(dev, "current time: %ld.%09ld\n",
			    (long)ts.tv_sec, ts.tv_nsec);
	}

	return (0);

 fail_res:
	bus_release_resource(dev, SYS_RES_MEMORY, rid, sc->sc_res);
 fail_mtx:
	mtx_destroy(&sc->sc_mtx);

	return (error);
}