Exemplo n.º 1
0
int gpio_deinit_port(void)
{
	if (!gpio_unexport(SCL_PIN) && !gpio_unexport(SDA_PIN))
		return 0;

	return 1;
}
Exemplo n.º 2
0
static int psh_remove(struct spi_device *client)
{
	struct psh_ia_priv *ia_data =
			(struct psh_ia_priv *)dev_get_drvdata(&client->dev);
	struct psh_ext_if *psh_if_info =
			(struct psh_ext_if *)ia_data->platform_priv;

	pm_runtime_get_sync(&client->dev);
	pm_runtime_disable(&client->dev);

	if (psh_if_info->wq)
		destroy_workqueue(psh_if_info->wq);

    poller_stop(&client->dev, &psh_if_info->poller_worker);

	free_irq(client->irq, psh_if_info->pshc);
	gpio_unexport(psh_if_info->gpio_psh_rst);
	gpio_unexport(psh_if_info->gpio_psh_ctl);
	gpio_free(psh_if_info->gpio_psh_rst);
	gpio_free(psh_if_info->gpio_psh_ctl);
	hwmon_device_unregister(psh_if_info->hwmon_dev);
	psh_ia_common_deinit(&client->dev);
    
    timestamp_destory(&client->dev, &psh_if_info->io_profiler);

	return 0;
}
Exemplo n.º 3
0
void unexport_All_GPIO()
{
	gpio_unexport(DISPL_PWRDWN);
	gpio_unexport(INTERRUPT_DISPL);
	gpio_unexport(ADC_BUF);
	gpio_unexport(PROTOCOL_SELECT);
}
Exemplo n.º 4
0
void dbg_unexport_gpios_to_sysfs()
{
	printk(KERN_ERR "DEBUG: gpio_unexport from sysfs");
	gpio_unexport(DVI_RESET_GPIO);
	gpio_unexport(I2C_SW_RESET_GPIO);
	gpio_unexport(GREEN_LED_GPIO);
	gpio_unexport( RED_LED_GPIO);
	gpio_unexport( EEPROM_SELECT_GPIO);
}
Exemplo n.º 5
0
/** @brief The LKM cleanup function
 *  Similar to the initialization function, it is static. The __exit macro notifies that if this
 *  code is used for a built-in driver (not a LKM) that this function is not required. Used to release the
 *  GPIOs and display cleanup messages.
 */
static void __exit ebbgpio_exit(void) {
    printk(KERN_INFO "GPIO_TEST: The button state is currently: %d\n", gpio_get_value(gpioButton));
    printk(KERN_INFO "GPIO_TEST: The button was pressed %d times\n", numberPresses);
    gpio_set_value(gpioLED, 0);              // Turn the LED off, makes it clear the device was unloaded
    gpio_unexport(gpioLED);                  // Unexport the LED GPIO
    free_irq(irqNumber, NULL);               // Free the IRQ number, no *dev_id required in this case
    gpio_unexport(gpioButton);               // Unexport the Button GPIO
    gpio_free(gpioLED);                      // Free the LED GPIO
    gpio_free(gpioButton);                   // Free the Button GPIO
    printk(KERN_INFO "GPIO_TEST: Goodbye from the LKM!\n");
}
Exemplo n.º 6
0
/**
 * @brief Kernel module exit point
 *  Makes sure all GPIO pins, the
 *  thread, and the interrupt handlers
 *  are deallocated.
 */
static void __exit kcylon_exit(void)
{
	int i;
	kthread_stop(task);
	for (i = 0; i < NUM_LEDS; i++) {
		gpio_set_value(led_pins[i], 0);
		gpio_unexport(led_pins[i]);
		gpio_free(led_pins[i]);
	}
	free_irq(irq_number, NULL);
	gpio_unexport(button_pin);
	gpio_free(button_pin);
	printk(KERN_INFO "KCYLON: Goodbye!\n");
}
void remove_edge_detect(unsigned int gpio)
{
    struct epoll_event ev;
    struct gpios *g = get_gpio(gpio);

    if (g == NULL)
        return;

    // delete epoll of fd

    ev.events = EPOLLIN | EPOLLET | EPOLLPRI;
    ev.data.fd = g->value_fd;
    epoll_ctl(epfd_thread, EPOLL_CTL_DEL, g->value_fd, &ev);

    // delete callbacks for gpio
    remove_callbacks(gpio);

    // btc fixme - check return result??
    gpio_set_edge(gpio, NO_EDGE);
    g->edge = NO_EDGE;

    if (g->value_fd != -1)
        close(g->value_fd);

    // btc fixme - check return result??
    gpio_unexport(gpio);
    event_occurred[gpio] = 0;

    delete_gpio(gpio);
}
void exports_cleanup(void)
{
    int i;
    // unexport everything
    for (i = 0; i < 120; ++i)
        gpio_unexport(i);
}
Exemplo n.º 9
0
static void __init ds_setup(void)
{
#ifdef DS2_PREV_RESET_PIN
	u32 t;
#endif
	ds_common_setup();

	ath79_register_leds_gpio(-1, ARRAY_SIZE(ds_leds_gpio),
				 ds_leds_gpio);
	ath79_register_gpio_keys_polled(-1, DS_KEYS_POLL_INTERVAL,
					ARRAY_SIZE(ds_gpio_keys),
					ds_gpio_keys);
	ath79_register_usb();

	//Disable the Function for some pins to have GPIO functionality active
	// GPIO6-7-8 and GPIO11
	ath79_gpio_function_setup(AR933X_GPIO_FUNC_JTAG_DISABLE | AR933X_GPIO_FUNC_I2S_MCK_EN, 0);

	ath79_gpio_function2_setup(AR933X_GPIO_FUNC2_JUMPSTART_DISABLE, 0);

	printk("Setting DogStick2 GPIO\n");
#ifdef DS2_PREV_RESET_PIN
	t = ath79_reset_rr(AR933X_RESET_REG_BOOTSTRAP);
	t |= AR933X_BOOTSTRAP_MDIO_GPIO_EN;
	ath79_reset_wr(AR933X_RESET_REG_BOOTSTRAP, t);
        
	// Put the avr reset to high 
	if (gpio_request_one(DS_GPIO_AVR_RESET_DS2,
                 GPIOF_OUT_INIT_LOW | GPIOF_EXPORT_DIR_FIXED,
                 "OE-1") != 0)
                printk("Error setting GPIO OE\n");
	gpio_unexport(DS_GPIO_AVR_RESET_DS2);
	gpio_free(DS_GPIO_AVR_RESET_DS2);
#endif

	// enable OE of level shifter
	if (gpio_request_one(DS_GPIO_OE,
		 GPIOF_OUT_INIT_LOW | GPIOF_EXPORT_DIR_FIXED,
		 "OE-1") != 0)
		printk("Error setting GPIO OE\n");

#ifdef DS1
	if (gpio_request_one(DS_GPIO_OE2,
		 GPIOF_OUT_INIT_HIGH | GPIOF_EXPORT_DIR_FIXED,
		 "OE-2") != 0)
		printk("Error setting GPIO OE2\n");
#else
        if (gpio_request_one(DS_GPIO_UART_ENA,
                 GPIOF_OUT_INIT_LOW | GPIOF_EXPORT_DIR_FIXED,
                 "UART-ENA") != 0)
                printk("Error setting GPIO Uart Enable\n");
        
	// enable OE of level shifter
        if (gpio_request_one(DS_GPIO_OE2,
                 GPIOF_OUT_INIT_LOW | GPIOF_EXPORT_DIR_FIXED,
                 "OE-2") != 0)
                printk("Error setting GPIO OE2\n");
#endif
}
static void __exit gpiosensor_exit(void){
	printk(KERN_INFO "COUNT_SENSOR: The sensor counted %d pieces\n", numberPieces);
	kobject_put(gpiosensor_kobj);
	free_irq(irqNumber, NULL);
	gpio_unexport(gpioSensor);
	gpio_free(gpioSensor);
	printk(KERN_INFO "COUNT_SENSOR: The Count Sensor LKM was unloaded!\n");
}
Exemplo n.º 11
0
int main(int argc, char *argv[]) {
	uint32_t clilen;
	uint8_t gpioOutputPortLight1;
	uint8_t gpioOutputPortLight2;
	int clientSocket, portno;
	int sockfd;
	struct sockaddr_in cli_addr;

	// If there are no enough parameters, abort.
	if (argc < 4) {
		fprintf(stderr,
				"ERROR, provide args: port number, pin for light 1, pin for light 2\n");
		exit(1);
	}
	portno = atoi(argv[1]);
	gpioOutputPortLight1 = atoi(argv[2]);
	gpioOutputPortLight2 = atoi(argv[3]);

	setupGpioOutput(gpioOutputPortLight1);
	setupGpioOutput(gpioOutputPortLight2);
	// Create a socket.
	sockfd = createServer(portno);

	clilen = sizeof(cli_addr);
	while (1) {
		fprintf(stderr, "Waiting for client...\n");
		// Block until a client has connected to the server.  This returns a file descriptor for the connection.
		clientSocket = accept(sockfd, (struct sockaddr*) &cli_addr, &clilen);

		// If the return is less than 0l, there is an error.
		if (clientSocket < 0) {
			error("ERROR on accept");
		} else {
			fprintf(stderr, "Client connected\n");
			startThreadForClient(clientSocket, gpioOutputPortLight1,
					gpioOutputPortLight2);
		}

		sleep(1);
	}

	gpio_unexport(gpioOutputPortLight1);
	gpio_unexport(gpioOutputPortLight2);
	return 0;
}
void ev3_output_port_disable_raw_mode(struct ev3_output_port_data * data)
{
	int i;

	sysfs_remove_groups(&data->out_port.dev.kobj, ev3_output_port_raw_groups);
	for (i = 0; i < NUM_GPIO; i++)
		gpio_unexport(data->gpio[i].gpio);
	ev3_output_port_float(data);
}
Exemplo n.º 13
0
void Termfault_Handler(int signo)
{
    printf("Program terminated: Trying to shutdown motors\n");
    motors_forward(0);
    remove("/tmp/socket");
    gpio_unexport(66);
    close(sock);
    exit(0);
}
Exemplo n.º 14
0
void
launcher_deinit(void)
{
    uint8_t i = 0;

    for (; i < 10; i++) {
        gpio_unexport(_chamber[i]);
    }
}
Exemplo n.º 15
0
static int gpio_wait(int pin)
{
	char path[BUFFER_MAX];
	int fd;
 
	snprintf(path, BUFFER_MAX, "/sys/class/gpio/gpio%d/value", pin);
	fd = open(path, O_RDONLY);
	if (-1 == fd) {
		fprintf(stderr, "Failed to open gpio for reading!\n");
		return -1;
	}

	read(fd, path, 3);

	struct pollfd p = {
		.fd = fd,
		.events = POLLPRI|POLLERR,
	};

	int r = poll(&p, 1, -1);
	if(r != 1) {
		fprintf(stderr, "poll() failed!\n");
		close(fd);
		return -1;
	}

	close(fd);
	return 0;
}
 
 
int main(int argv, char** argc)
{
	if(gpio_export(PIN)) {
		return 1;
	}

	gpio_direction(PIN, IN);

	setup();
	setup_gpio(POUT, OUTPUT, PUD_OFF);

	while(1) {
		gpio_edge(PIN, RISING);
		gpio_wait(PIN);
		output_gpio(POUT, HIGH);
		gpio_edge(PIN, FALLING);
		gpio_wait(PIN);
		output_gpio(POUT, LOW);
	}

	if(gpio_unexport(PIN)) {
		return 1;
	}

	return 0;
}
Exemplo n.º 16
0
void Segfault_Handler(int signo)
{
    printf("Program crashed: Trying to shutdown motors\n");
    motors_forward(0);
    remove("/tmp/socket");
    gpio_unexport(39);
    close(sock);
    exit(0);
}
// Callback executed when SIGINT is sent to the process (Ctrl-C)
void signal_handler(int sig)
{
	int i;
	printf( "Ctrl-C pressed, cleaning up and exiting..\n" );
	keepgoing = 0;
	//Unxport gpios
	for (i = 0; i < 4; i++){
		gpio_unexport(controller[i]);
	}
}
Exemplo n.º 18
0
static void arduino_close(PROGRAMMER * pgm)
{
#ifdef CUSTOMER_REST_PIN
    gpio_set_value(pgm->reset_pin,LOW);
    gpio_unexport(pgm->reset_pin);
#else
    serial_set_dtr_rts(&pgm->fd, 0);
#endif
    serial_close(&pgm->fd);
    pgm->fd.ifd = -1;
}
Exemplo n.º 19
0
static int gpio_ctrl_remove(struct platform_device *pdev)
{
	if((&(priv->ctrlmodule[0].led_cdev))!=NULL)
	 led_classdev_unregister(&(priv->ctrlmodule[0].led_cdev) );	
	else
	printk("led_classdev_unreg:Failed\n");

     gpio_unexport(priv->ctrlmodule[0].out_gpio);
	 gpio_unexport(priv->ctrlmodule[0].in_gpio);
	 gpio_unexport(priv->ctrlmodule[0].led_gpio);
		

	free_irq(gpio_to_irq(priv->ctrlmodule[0].in_gpio),NULL);

	gpio_free(priv->ctrlmodule[0].out_gpio );
	gpio_free(priv->ctrlmodule[0].in_gpio );
	gpio_free(priv->ctrlmodule[0].led_gpio );

printk("gpio_ctrl_remove: done\n");
         return 0;
}
Exemplo n.º 20
0
int gpio_clear(struct board* b)
{
    int i;

    dbg(b->ch.debug,"");
    if ( !b->ch.io ) return -1;

    for ( i = 0; i < b->ch.pincount; ++i )
        gpio_unexport(b,&b->ch.io[i]);
    kfree(b->ch.io);
    return 0;
}
Exemplo n.º 21
0
void bitbang_close()
{
	int err;
	err = gpio_unexport(CS0_PIN);
	if(err!=0) {printf("Trouble Unexporting a pin!\n"); exit(EXIT_FAILURE);};
	err = gpio_unexport(CS1_PIN);
	if(err!=0) {printf("Trouble Unexporting a pin!\n"); exit(EXIT_FAILURE);};
	err = gpio_unexport(MISO_PIN);
	if(err!=0) {printf("Trouble Unexporting a pin!\n"); exit(EXIT_FAILURE);};
	err = gpio_unexport(CLK_PIN);
	if(err!=0) {printf("Trouble Unexporting a pin!\n"); exit(EXIT_FAILURE);};
	err = gpio_unexport(AZIMUTH_STATUS_PIN);
	if(err!=0) {printf("Trouble Unexporting a pin!\n"); exit(EXIT_FAILURE);};
	err = gpio_unexport(ELEVATION_STATUS_PIN);
	if(err!=0) {printf("Trouble Unexporting a pin!\n"); exit(EXIT_FAILURE);};

	err = close(fd_CS0); 
	if (err==-1) {printf("Unable to close a device file!\n"); exit(EXIT_FAILURE);};
	err = close(fd_CS1); 
	if (err==-1) {printf("Unable to close a device file!\n"); exit(EXIT_FAILURE);};
	err = close(fd_MISO); 
	if (err==-1) {printf("Unable to close a device file!\n"); exit(EXIT_FAILURE);};
	err = close(fd_CLK); 
	if (err==-1) {printf("Unable to close a device file!\n"); exit(EXIT_FAILURE);};
	err = close(fd_AZ_STATUS); 
	if (err==-1) {printf("Unable to close a device file!\n"); exit(EXIT_FAILURE);};
	err = close(fd_EL_STATUS); 
	if (err==-1) {printf("Unable to close a device file!\n"); exit(EXIT_FAILURE);};
}
Exemplo n.º 22
0
int gpio_unset(int max_pin_number)
{
  int err;
  int i;
  for(i = 0; i < max_pin_number;i++){
    err = gpio_unexport(i);
    if(err == -1){
      fprintf(stderr, "gpio_setup is failed\n");
      return (-1);
    }
  }
    return (0);
}
Exemplo n.º 23
0
void gpio_reset(int level)
{
	// reset TPG
	gpio_export(TPG_RST_PIN);
	gpio_dir_out(TPG_RST_PIN);
	gpio_value(TPG_RST_PIN, level);
	gpio_unexport(TPG_RST_PIN);

	// reset SOBEL
	gpio_export(SOBEL_RST_PIN);
	gpio_dir_out(SOBEL_RST_PIN);
	gpio_value(SOBEL_RST_PIN, level);
	gpio_unexport(SOBEL_RST_PIN);

	// set the external clock for the
	gpio_export(EXT_SYNC_PIN);
	gpio_dir_out(EXT_SYNC_PIN);
	gpio_value(EXT_SYNC_PIN, gLiveVideoOn);
	gpio_unexport(EXT_SYNC_PIN);

	//printf("\nReset Done\n");
}
Exemplo n.º 24
0
static void gpio_close(PROGRAMMER *pgm)
{
  int i;

  pgm->setpin(pgm, pgm->pinno[PIN_AVR_RESET], 1);

  for (i=0; i<N_GPIO; i++)
    if (gpio_fds[i]>=0) {
       close(gpio_fds[i]);
       gpio_unexport(i);
    }
  return;
}
Exemplo n.º 25
0
static int evm_sw_teardown(struct i2c_client *client, int gpio,
			unsigned ngpio, void *c)
{
	int i;

	for (i = 0; i < 4; ++i) {
		if (evm_sw_gpio[i] != -EINVAL) {
			gpio_unexport(evm_sw_gpio[i]);
			gpio_free(evm_sw_gpio[i]);
			evm_sw_gpio[i] = -EINVAL;
		}
	}
	return 0;
}
Exemplo n.º 26
0
void resetStop_VDMA_ALL(void)
{
	static int currentLiveMode = 0;
	gpio_reset(RST_ACTIVE);	// pull the reset line.

	// reset and enable the Chroma-resampler and YUV to rgb converter.
	chr_stop_reset(gResolution);
	yuv2rgb_stop_reset(gResolution);

	DEBUG_Text("Reseting TPG_VDMA\n");
	// Reset TPG VDMA
	vdma_reset(VDMA_ID_TPG, DMA_DEV_TO_MEM);		// tpg
	DEBUG_Text("Reseting Sobel_out_VDMA\n");
	// Reset Sobel VDMA (IN and OUT)
	vdma_reset(VDMA_ID_SOBEL, DMA_DEV_TO_MEM);		// sobel out
	DEBUG_Text("Reseting Soble_in_VDMA\n");
	vdma_reset(VDMA_ID_SOBEL, DMA_MEM_TO_DEV);		// Soble in
	DEBUG_Text("VDMA Reset Done\n");

	// release the reset ( and set the required external clock)
	chr_start();
	yuv2rgb_start();

	gpio_reset(RST_INACTIVE);

	if (gLiveVideoOn && (gLiveVideoOn != currentLiveMode))
	{
		unsigned long clk = detect_input_clk()/1000;
		// check if the input clock is in range +- 2MHz
		if (  (clk < (gVideoParam[gResolution][E_Clk] - 2000)) |
				(clk > (gVideoParam[gResolution][E_Clk] + 2000))  )
		{
			printf("Incorrect Input [Required:%d x %d @ 60fps(Hz)] \nTurning on the previous pattern",
															gVideoParam[gResolution][E_HActive],
															gVideoParam[gResolution][E_VActive]);
			gLiveVideoOn = 0;
			gpio_export(EXT_SYNC_PIN);
			gpio_dir_out(EXT_SYNC_PIN);
			gpio_value(EXT_SYNC_PIN, gLiveVideoOn);
			gpio_unexport(EXT_SYNC_PIN);
		}
		else
		{
			SetTpgPattern(gResolution, 0);
		}
	}
	currentLiveMode = gLiveVideoOn;
}
Exemplo n.º 27
0
static ssize_t dev_read(struct file *filp, char *buff, size_t len, loff_t *off)
{
	   gpio_export(GPIO_NUMBER,1);
	   gpio_direction_output(GPIO_NUMBER,1);
	   gpio_set_value(GPIO_NUMBER, 0);
	   gpio_unexport(GPIO_NUMBER);

	short count =0 ;
	while (len && (msg[readPos]!=0))
	{
		put_user(msg[readPos],buff++);
		count++;
		len--;
		readPos++;
	}
	return count;
}
Exemplo n.º 28
0
static ssize_t dev_write(struct file *filp,const char *buf, size_t len,loff_t *off)
{
	gpio_export(GPIO_NUMBER,1);
		   gpio_direction_output(GPIO_NUMBER,1);
		   gpio_set_value(GPIO_NUMBER, 1);
		   gpio_unexport(GPIO_NUMBER);
	short ind = len-1;
	short count=0;
	memset(msg,0,100);
	readPos=0;
	while(len>0)
	{
		msg[count++] = buf[ind--];
		len--;

	}
	return count;
}
int u1_gps_ntt_init(void)
{
       //int isntt = 1;
       //if(isntt!=1) return 0;
       s3c_gpio_cfgpin(GPIO_GPS_PWR_EN, S3C_GPIO_SLP_INPUT);
       s3c_gpio_setpull(GPIO_GPS_PWR_EN, S3C_GPIO_PULL_DOWN);
       gpio_unexport(GPIO_GPS_PWR_EN);
       gpio_free(GPIO_GPS_PWR_EN);
       
       if (gpio_request(GPIO_GPS_PWR_EN_NTT, "GPS_PWR_EN"))
               WARN(1, "fail to request gpio (GPS_PWR_EN)\n");
       s3c_gpio_setpull(GPIO_GPS_PWR_EN_NTT, S3C_GPIO_PULL_NONE);
       s3c_gpio_cfgpin(GPIO_GPS_PWR_EN_NTT, S3C_GPIO_OUTPUT);
       gpio_direction_output(GPIO_GPS_PWR_EN_NTT, 0);
       gpio_export(GPIO_GPS_PWR_EN_NTT, 1);
       sysfs_remove_link(&gps_dev->kobj,"GPS_PWR_EN");
       gpio_export_link(gps_dev, "GPS_PWR_EN", GPIO_GPS_PWR_EN_NTT);
       return 0;

}
Exemplo n.º 30
0
main(){
  int i;
  int fd;

  gpio_export(PIN);
  fd = gpio_open(PIN, "direction", O_WRONLY);
  write(fd, "out", 3);
  close(fd);

  fd = gpio_open(PIN, "value", O_WRONLY);
  for(i = 0; i < 5; i++){
    write(fd, "1", 1);
    usleep(50000);
    write(fd, "0", 1);
    usleep(50000);
  }

  close(fd);
  gpio_unexport(PIN);
}