コード例 #1
0
ファイル: fb.c プロジェクト: AjeyBohare/minix
static int
sef_cb_init(int type, sef_init_info_t *UNUSED(info))
{
/* Initialize the fb driver. */
	int do_announce_driver = TRUE;

	open_counter[0] = 0;
	switch(type) {
	case SEF_INIT_FRESH:
	    printf("framebuffer fresh: pid %d\n", getpid());
	    break;

	case SEF_INIT_LU:
	    /* Restore the state. */
	    lu_state_restore();
	    do_announce_driver = FALSE;

	    printf("framebuffer: I'm a new version!\n");
	    break;

	case SEF_INIT_RESTART:
	    printf("framebuffer restarted: pid %d\n", getpid());
	    has_restarted = 1;
	    break;
	}

	/* Announce we are up when necessary. */
	if (do_announce_driver) {
		chardriver_announce();
	}

	/* Initialization completed successfully. */
	return OK;
}
コード例 #2
0
ファイル: secret.c プロジェクト: girum11/cpe453-minix-os
static int sef_cb_init(int type, sef_init_info_t *UNUSED(info))
{
/* Initialize the hello driver. */
    int do_announce_driver = TRUE;

    open_counter = 0;
    switch(type) {
        case SEF_INIT_FRESH:
            printf("%s", the_secret);
        break;

        case SEF_INIT_LU:
            /* Restore the state. */
            lu_state_restore();
            do_announce_driver = FALSE;

            printf("%sHey, I'm a new version!\n", the_secret);
        break;

        case SEF_INIT_RESTART:
            printf("%sHey, I've just been restarted!\n", the_secret);
        break;
    }

    /* Announce we are up when necessary. */
    if (do_announce_driver) {
        chardriver_announce();
    }

    /* Initialization completed successfully. */
    return OK;
}
コード例 #3
0
ファイル: tps65217.c プロジェクト: junzhe/minix_pandaboard_es
static int
sef_cb_init(int type, sef_init_info_t * UNUSED(info))
{
	int r;

	if (type == SEF_INIT_LU) {
		/* Restore the state. */
		lu_state_restore();
	}

	/* look-up the endpoint for the bus driver */
	bus_endpoint = i2cdriver_bus_endpoint(bus);
	if (bus_endpoint == 0) {
		log_warn(&log, "Couldn't find bus driver.\n");
		return EXIT_FAILURE;
	}

	/* claim the device */
	r = i2cdriver_reserve_device(bus_endpoint, address);
	if (r != OK) {
		log_warn(&log, "Couldn't reserve device 0x%x (r=%d)\n",
		    address, r);
		return EXIT_FAILURE;
	}

	/* check that the chip / rev is reasonable */
	r = check_revision();
	if (r != OK) {
		/* prevent user from using the driver with a different chip */
		log_warn(&log, "Bad CHIPID\n");
		return EXIT_FAILURE;
	}

	/* enable interrupts */
	r = intr_enable();
	if (r != OK) {
		log_warn(&log, "Failed to enable interrupts.\n");
		return EXIT_FAILURE;
	}

	/* enable power-off pin so the kernel can cut power to the SoC */
	enable_pwr_off();

	if (type != SEF_INIT_LU) {

		/* sign up for updates about the i2c bus going down/up */
		r = i2cdriver_subscribe_bus_updates(bus);
		if (r != OK) {
			log_warn(&log, "Couldn't subscribe to bus updates\n");
			return EXIT_FAILURE;
		}

		i2cdriver_announce(bus);
		log_debug(&log, "announced\n");
	}

	return OK;
}
コード例 #4
0
ファイル: tps65950.c プロジェクト: anuragpeshne/minix
static int
sef_cb_init(int type, sef_init_info_t * UNUSED(info))
{
	int r, i;

	if (type == SEF_INIT_LU) {
		/* Restore the state. */
		lu_state_restore();
	}

	/* look-up the endpoint for the bus driver */
	bus_endpoint = i2cdriver_bus_endpoint(bus);
	if (bus_endpoint == 0) {
		log_warn(&log, "Couldn't find bus driver.\n");
		return EXIT_FAILURE;
	}

	for (i = 0; i < NADDRESSES; i++) {

		/* claim the device */
		r = i2cdriver_reserve_device(bus_endpoint, addresses[i]);
		if (r != OK) {
			log_warn(&log, "Couldn't reserve device 0x%x (r=%d)\n",
			    addresses[i], r);
			return EXIT_FAILURE;
		}
	}

	/* check that the chip / rev is reasonable */
	r = check_revision();
	if (r != OK) {
		/* prevent user from using the driver with a different chip */
		log_warn(&log, "Bad IDCODE\n");
		return EXIT_FAILURE;
	}

	r = rtc_init();
	if (r != OK) {
		log_warn(&log, "RTC Start-up Failed\n");
		return EXIT_FAILURE;
	}

	if (type != SEF_INIT_LU) {

		/* sign up for updates about the i2c bus going down/up */
		r = i2cdriver_subscribe_bus_updates(bus);
		if (r != OK) {
			log_warn(&log, "Couldn't subscribe to bus updates\n");
			return EXIT_FAILURE;
		}

		i2cdriver_announce(bus);
		log_debug(&log, "announced\n");
	}

	return OK;
}
コード例 #5
0
ファイル: tda19988.c プロジェクト: Hooman3/minix
static int
sef_cb_init(int type, sef_init_info_t * UNUSED(info))
{
	int r;

	if (type == SEF_INIT_LU) {
		/* Restore the state. */
		lu_state_restore();
	}

	geom[TDA19988_DEV].dv_base = ((u64_t) (0));
	geom[TDA19988_DEV].dv_size = ((u64_t) (128));

	/*
	 * CEC Module
	 */

	/* look-up the endpoint for the bus driver */
	cec_bus_endpoint = i2cdriver_bus_endpoint(cec_bus);
	if (cec_bus_endpoint == 0) {
		log_warn(&log, "Couldn't find bus driver.\n");
		return EXIT_FAILURE;
	}

	/* claim the device */
	r = i2cdriver_reserve_device(cec_bus_endpoint, cec_address);
	if (r != OK) {
		log_warn(&log, "Couldn't reserve device 0x%x (r=%d)\n",
		    cec_address, r);
		return EXIT_FAILURE;
	}

	/*
	 * HDMI Module
	 */

	/* look-up the endpoint for the bus driver */
	hdmi_bus_endpoint = i2cdriver_bus_endpoint(hdmi_bus);
	if (hdmi_bus_endpoint == 0) {
		log_warn(&log, "Couldn't find bus driver.\n");
		return EXIT_FAILURE;
	}

	/* claim the device */
	r = i2cdriver_reserve_device(hdmi_bus_endpoint, hdmi_address);
	if (r != OK) {
		log_warn(&log, "Couldn't reserve device 0x%x (r=%d)\n",
		    hdmi_address, r);
		return EXIT_FAILURE;
	}

	if (type != SEF_INIT_LU) {

		/* sign up for updates about the i2c bus going down/up */
		r = i2cdriver_subscribe_bus_updates(cec_bus);
		if (r != OK) {
			log_warn(&log, "Couldn't subscribe to bus updates\n");
			return EXIT_FAILURE;
		}

		/* sign up for updates about the i2c bus going down/up */
		r = i2cdriver_subscribe_bus_updates(hdmi_bus);
		if (r != OK) {
			log_warn(&log, "Couldn't subscribe to bus updates\n");
			return EXIT_FAILURE;
		}

		i2cdriver_announce(cec_bus);
		if (cec_bus != hdmi_bus) {
			i2cdriver_announce(hdmi_bus);
		}

		blockdriver_announce(type);
		log_trace(&log, "announced\n");
	}

	return OK;
}