void cg2900_devices_exit(void)
{
	cg2900_devices_disable_chip();
	gpio_free(GBF_ENA_RESET_GPIO);
/* ++Hemant: Added because GBF_ENA_PWR_EN_GPIO was never freed */
 	gpio_free(GBF_ENA_PWR_EN_GPIO);
/* --Hemant: Added because GBF_ENA_PWR_EN_GPIO was never freed */
}
int cg2900_devices_init(void)
{
	int err = 0;
	printk(KERN_DEBUG "cg2900_devices_init");

	/* ++Hemant: Keep the UART Pins in UART Mode */ 
	s3c_setup_uart_cfg_gpio(1);
	/* --Hemant: Keep the UART Pins in UART Mode */ 

//++Adding gpio control for power enable 
	err = gpio_request(GBF_ENA_PWR_EN_GPIO, GBF_ENA_POWER_NAME);
	if (err < 0) {
		pr_err("PWR gpio_request failed with err: %d", err);
		goto finished;
	}

	err = gpio_direction_output(GBF_ENA_PWR_EN_GPIO, 1);
	if (err < 0) {
		pr_err("PWR gpio_direction_output failed with err: %d", err);
		goto error_handling1;
	}
//--Adding gpio control for power enable 

	err = gpio_request(GBF_ENA_RESET_GPIO, GBF_ENA_RESET_NAME);
	if (err < 0) {
		pr_err("PDB gpio_request failed with err: %d", err);
		goto finished;
	}

	err = gpio_direction_output(GBF_ENA_RESET_GPIO, 1);
	if (err < 0) {
		pr_err("PDB gpio_direction_output failed with err: %d", err);
		goto error_handling2;
	}

	goto finished;
	
	   
error_handling2: 
	gpio_free(GBF_ENA_RESET_GPIO);

//++Adding gpio control for power enable 
error_handling1:
	gpio_free(GBF_ENA_PWR_EN_GPIO);
//--Adding gpio control for power enable 
	   
finished:
	cg2900_devices_disable_chip();
	return err;
}
Exemplo n.º 3
0
/**
 * uart_set_chip_power() - Enable or disable the CG2900.
 * @chip_on:	true if chip shall be enabled, false otherwise.
 */
static void uart_set_chip_power(bool chip_on)
{
	int uart_baudrate = uart_default_baud;
#ifndef BAUD_RATE_FIX
	struct ktermios *old_termios;
#endif /* BAUD_RATE_FIX */
	struct tty_struct *tty;

	CG2900_INFO("uart_set_chip_power: %s",
		    (chip_on ? "ENABLE" : "DISABLE"));

	if (chip_on)
		cg2900_devices_enable_chip();
	else {
		cg2900_devices_disable_chip();
		/*
		 * Setting baud rate to 0 will tell UART driver to shut off its
		 * clocks.
		 */
		uart_baudrate = ZERO_BAUD_RATE;
	}

	/*
	 * Now we have to set the digital baseband UART
	 * to default baudrate if chip is ON or to zero baudrate if
	 * chip is turning OFF.
	 */
	if (uart_info->tty)
		tty = uart_info->tty;
	else {
		CG2900_ERR("Important structs not allocated!");
		return;
	}

#ifndef BAUD_RATE_FIX
	old_termios = kmalloc(sizeof(*old_termios), GFP_ATOMIC);
	if (!old_termios) {
		CG2900_ERR("Could not allocate termios");
		return;
	}

	mutex_lock(&(tty->termios_mutex));
	/*
	 * Now set the termios struct to the default or zero baudrate.
	 * Start by storing the old termios.
	 */
	memcpy(old_termios, tty->termios, sizeof(*old_termios));
	/* Now set the default baud rate or zero if chip is turning OFF. */
	tty_encode_baud_rate(tty, uart_baudrate, uart_baudrate);
	/* Finally inform the driver */
	if (tty->ops->set_termios)
	{
		tty->ops->set_termios(tty, old_termios);
   }		
	mutex_unlock(&(tty->termios_mutex));
	kfree(old_termios);
#else /* BAUD_RATE_FIX */
	/*
	 * Now we have to set the digital baseband UART
	 * to default baudrate if chip is ON or to zero baudrate if
	 * chip is turning OFF.
	 */
	 (void)set_tty_baud(tty, uart_baudrate);
#endif /* BAUD_RATE_FIX */
}