Example #1
0
int main(int argc, char *argv[])
{
	if (argc < 2)
		usage(argv[0]);

	switch (argv[1][0]) {
	case 'w':
		gpio_test_write();
		break;
	case 'r':
		gpio_test_read();
		break;
	case 'i':
		if (argc == 3)
			gpio_test_intr(atoi(argv[2]));
		else
			gpio_test_intr(0);
		break;
	case 'l':
		if (argc != 8)
			usage(argv[0]);
		gpio_set_led(argc, argv);
		break;
	default:
		usage(argv[0]);
	}

	return 0;
}
Example #2
0
void gpio_keep_reading(void *no_of_iterations)
{
    int loop;

    for (loop = 0; loop < iterations; loop++) {
        gpio_test_request();
        if (request_flag) {
            printk(KERN_INFO "Running on %d ",smp_processor_id() );
            gpio_test_direction_input();
            if (input_direction_flag)
                gpio_test_read();
            gpio_test_free();
        }
    }
}
Example #3
0
static void gpio_test(void)
{
    int loop;
    struct task_struct *p1, *p2, *p3, *p4;
    int x;

    switch (test) {

    case 1: /* Reserve and free GPIO Line */
        gpio_test_request();
        if (request_flag)
            gpio_test_free();
        break;

    case 2: /* Set GPIO input/output direction */
        gpio_test_request();
        if (request_flag) {
            gpio_test_direction_input();
            gpio_test_direction_output();
            gpio_test_free();
        }
        break;

    case 3: /* GPIO read */
        gpio_test_request();
        if (request_flag) {
            gpio_test_direction_input();
            if (input_direction_flag)
                gpio_test_read();
            gpio_test_free();
        }
        break;

    case 4: /* GPIO write */
        gpio_test_request();
        if (request_flag) {
            gpio_test_direction_output();
            if (output_direction_flag)
                gpio_test_write();
            gpio_test_free();
        }
        break;

    case 5:/* configure the interrupt edge \
				sensitivity (rising, falling) */
        gpio_test_request();
        if (request_flag) {
            gpio_test_irq();
            gpio_test_free();
        }
        break;

#ifdef CONFIG_ARCH_OMAP4
    case 6: /* GPIO read */
        for (loop = 0; loop < iterations; loop++) {
            gpio_test_request();
            if (request_flag) {
                printk(KERN_INFO "Running on %d ",smp_processor_id() );
                gpio_test_direction_input();
                if (input_direction_flag)
                    gpio_test_read();
                gpio_test_free();
            }
        }
        break;

    case 7: /* GPIO write */
        for (loop = 0; loop < iterations; loop++) {
            gpio_test_request();
            if (request_flag) {
                printk(KERN_INFO "Running on %d ",smp_processor_id() );
                gpio_test_direction_output();
                if (output_direction_flag)
                    gpio_test_write();
                gpio_test_free();
            }
        }
        break;

    case 8: /* thread */
        p1 = kthread_create(gpio_keep_reading, NULL , "gpiotest/0");
        p2 = kthread_create(gpio_keep_reading, NULL , "gpiotest/1");
        kthread_bind(p1, 0);
        kthread_bind(p2, 1);
        x = wake_up_process(p1);
        x = wake_up_process(p2);
        break;
#endif
    case 9:/* Verify if GPIO module disable happens if all \
				GPIOs in the module are inactive */
        gpio_test7();
        break;

    case 10:/* Request for same GPIO twice and free \
				the GPIO */
        gpio_test_request();
        if (request_flag) {
            request_flag = 0;
            printk(KERN_INFO "Requesting same GPIO again");
            gpio_test_request();
            if (request_flag)
                test_passed = 0;
            gpio_test_free();
        }
        break;
    case 11:
        for (loop = 0; loop < 500; loop++) {
            gpio_test_request();
            if (request_flag) {

                gpio_test_direction_output();
                if (output_direction_flag)
                    gpio_test_write();

                gpio_test_direction_input();
                if (input_direction_flag)
                    gpio_test_read();
                gpio_test_free();
            } else
                break;
        }
        break;
    case 13: /* thread */
        p1 = kthread_create(gpio_keep_reading, NULL ,
                            "gpiotest/0");
        p2 = kthread_create(gpio_keep_reading, NULL ,
                            "gpiotest/1");
        p3 = kthread_create(gpio_keep_reading, NULL ,
                            "gpiotest/3");
        p4 = kthread_create(gpio_keep_reading, NULL ,
                            "gpiotest/4");
        x = wake_up_process(p1);
        x = wake_up_process(p2);
        x = wake_up_process(p3);
        x = wake_up_process(p4);
        break;
    case 12:
        break;
    default:
        printk(KERN_INFO "Test option not available.\n");
    }

    /* On failure of a testcase, one of the three error flags set to 0
     * if a gpio line request fails it is not considered as a failure
     * set test_passed =0 for failure
     */
    if (!(error_flag_1 && error_flag_2 && error_flag_3))
        test_passed = 0;
}