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; }
static int bluetooth_set_power(void *data, enum rfkill_state state) { unsigned int ret = 0; switch (state) { case RFKILL_STATE_UNBLOCKED: #ifdef CONFIG_MACH_INSTINCTQ printk("[BT] Device Powering ON \n"); #else printk(KERN_DEBUG "[BT] Device Powering ON \n"); #endif /* #ifdef CONFIG_MACH_INSTINCTQ */ s3c_setup_uart_cfg_gpio(1); if (gpio_is_valid(GPIO_BT_WLAN_REG_ON)) { ret = gpio_request(GPIO_BT_WLAN_REG_ON, S3C_GPIO_LAVEL(GPIO_BT_WLAN_REG_ON)); if (ret < 0) { #ifdef CONFIG_MACH_INSTINCTQ printk("[BT] Failed to request GPIO_BT_WLAN_REG_ON!\n"); #else printk(KERN_ERR "[BT] Failed to request GPIO_BT_WLAN_REG_ON!\n"); #endif /* #ifdef CONFIG_MACH_INSTINCTQ */ return ret; } gpio_direction_output(GPIO_BT_WLAN_REG_ON, GPIO_LEVEL_HIGH); } if (gpio_is_valid(GPIO_BT_RST_N)) { ret = gpio_request(GPIO_BT_RST_N, S3C_GPIO_LAVEL(GPIO_BT_RST_N)); if (ret < 0) { gpio_free(GPIO_BT_WLAN_REG_ON); #ifdef CONFIG_MACH_INSTINCTQ printk("[BT] Failed to request GPIO_BT_RST_N!\n"); #else printk(KERN_ERR "[BT] Failed to request GPIO_BT_RST_N!\n"); #endif /* #ifdef CONFIG_MACH_INSTINCTQ */ return ret; } gpio_direction_output(GPIO_BT_RST_N, GPIO_LEVEL_LOW); } /* Set GPIO_BT_WLAN_REG_ON high */ s3c_gpio_setpull(GPIO_BT_WLAN_REG_ON, S3C_GPIO_PULL_NONE); gpio_set_value(GPIO_BT_WLAN_REG_ON, GPIO_LEVEL_HIGH); s3c_gpio_slp_cfgpin(GPIO_BT_WLAN_REG_ON, S3C_GPIO_SLP_OUT1); s3c_gpio_slp_setpull_updown(GPIO_BT_WLAN_REG_ON, S3C_GPIO_PULL_NONE); #ifdef CONFIG_MACH_INSTINCTQ printk("[BT] GPIO_BT_WLAN_REG_ON = %d\n", gpio_get_value(GPIO_BT_WLAN_REG_ON)); mdelay(150); // 100msec, delay between reg_on & rst. (bcm4325 powerup sequence) #else printk(KERN_DEBUG "[BT] GPIO_BT_WLAN_REG_ON = %d\n", gpio_get_value(GPIO_BT_WLAN_REG_ON)); msleep(150); // 100msec, delay between reg_on & rst. (bcm4325 powerup sequence) #endif /* #ifdef CONFIG_MACH_INSTINCTQ */ /* Set GPIO_BT_RST_N high */ s3c_gpio_setpull(GPIO_BT_RST_N, S3C_GPIO_PULL_NONE); gpio_set_value(GPIO_BT_RST_N, GPIO_LEVEL_HIGH); s3c_gpio_slp_cfgpin(GPIO_BT_RST_N, S3C_GPIO_SLP_OUT1); s3c_gpio_slp_setpull_updown(GPIO_BT_RST_N, S3C_GPIO_PULL_NONE); #ifdef CONFIG_MACH_INSTINCTQ printk("[BT] GPIO_BT_RST_N = %d\n", gpio_get_value(GPIO_BT_RST_N)); #else printk(KERN_DEBUG "[BT] GPIO_BT_RST_N = %d\n", gpio_get_value(GPIO_BT_RST_N)); #endif /* #ifdef CONFIG_MACH_INSTINCTQ */ gpio_free(GPIO_BT_RST_N); gpio_free(GPIO_BT_WLAN_REG_ON); break; case RFKILL_STATE_SOFT_BLOCKED: #ifdef CONFIG_MACH_INSTINCTQ printk("[BT] Device Powering OFF \n"); #else printk(KERN_DEBUG "[BT] Device Powering OFF \n"); #endif /* #ifdef CONFIG_MACH_INSTINCTQ */ s3c_reset_uart_cfg_gpio(1); s3c_gpio_setpull(GPIO_BT_RST_N, S3C_GPIO_PULL_NONE); gpio_set_value(GPIO_BT_RST_N, GPIO_LEVEL_LOW); s3c_gpio_slp_cfgpin(GPIO_BT_RST_N, S3C_GPIO_SLP_OUT0); s3c_gpio_slp_setpull_updown(GPIO_BT_RST_N, S3C_GPIO_PULL_NONE); #ifdef CONFIG_MACH_INSTINCTQ printk("[BT] GPIO_BT_RST_N = %d\n",gpio_get_value(GPIO_BT_RST_N)); #else printk(KERN_DEBUG "[BT] GPIO_BT_RST_N = %d\n",gpio_get_value(GPIO_BT_RST_N)); #endif /* #ifdef CONFIG_MACH_INSTINCTQ */ if(gpio_get_value(GPIO_WLAN_RST_N) == 0) { s3c_gpio_setpull(GPIO_BT_WLAN_REG_ON, S3C_GPIO_PULL_NONE); gpio_set_value(GPIO_BT_WLAN_REG_ON, GPIO_LEVEL_LOW); s3c_gpio_slp_cfgpin(GPIO_BT_WLAN_REG_ON, S3C_GPIO_SLP_OUT0); s3c_gpio_slp_setpull_updown(GPIO_BT_WLAN_REG_ON, S3C_GPIO_PULL_NONE); #ifdef CONFIG_MACH_INSTINCTQ printk("[BT] GPIO_BT_WLAN_REG_ON = %d\n", gpio_get_value(GPIO_BT_WLAN_REG_ON)); #else printk(KERN_DEBUG "[BT] GPIO_BT_WLAN_REG_ON = %d\n", gpio_get_value(GPIO_BT_WLAN_REG_ON)); #endif /* #ifdef CONFIG_MACH_INSTINCTQ */ } gpio_free(GPIO_BT_RST_N); gpio_free(GPIO_BT_WLAN_REG_ON); break; default: printk(KERN_ERR "[BT] Bad bluetooth rfkill state %d\n", state); } return 0; }
static int bluetooth_set_power(void *data, enum rfkill_user_states state) { int ret = 0; int irq; /* BT Host Wake IRQ */ irq = IRQ_BT_HOST_WAKE; switch (state) { case RFKILL_USER_STATE_UNBLOCKED: pr_debug("[BT] Device Powering ON\n"); s3c_setup_uart_cfg_gpio(0); if (gpio_is_valid(GPIO_WLAN_BT_EN)) gpio_direction_output(GPIO_WLAN_BT_EN, GPIO_LEVEL_HIGH); if (gpio_is_valid(GPIO_BT_nRST)) gpio_direction_output(GPIO_BT_nRST, GPIO_LEVEL_LOW); pr_debug("[BT] GPIO_BT_nRST = %d\n", gpio_get_value(GPIO_BT_nRST)); /* Set GPIO_BT_WLAN_REG_ON high */ s3c_gpio_setpull(GPIO_WLAN_BT_EN, S3C_GPIO_PULL_NONE); gpio_set_value(GPIO_WLAN_BT_EN, GPIO_LEVEL_HIGH); s3c_gpio_slp_cfgpin(GPIO_WLAN_BT_EN, S3C_GPIO_SLP_OUT1); s3c_gpio_slp_setpull_updown(GPIO_WLAN_BT_EN, S3C_GPIO_PULL_NONE); pr_debug("[BT] GPIO_WLAN_BT_EN = %d\n", gpio_get_value(GPIO_WLAN_BT_EN)); /* * FIXME sleep should be enabled disabled since the device is * not booting if its enabled */ /* * 100msec, delay between reg_on & rst. * (bcm4329 powerup sequence) */ msleep(100); /* Set GPIO_BT_nRST high */ s3c_gpio_setpull(GPIO_BT_nRST, S3C_GPIO_PULL_NONE); gpio_set_value(GPIO_BT_nRST, GPIO_LEVEL_HIGH); s3c_gpio_slp_cfgpin(GPIO_BT_nRST, S3C_GPIO_SLP_OUT1); s3c_gpio_slp_setpull_updown(GPIO_BT_nRST, S3C_GPIO_PULL_NONE); pr_debug("[BT] GPIO_BT_nRST = %d\n", gpio_get_value(GPIO_BT_nRST)); /* * 50msec, delay after bt rst * (bcm4329 powerup sequence) */ msleep(50); ret = enable_irq_wake(irq); if (ret < 0) pr_err("[BT] set wakeup src failed\n"); enable_irq(irq); break; case RFKILL_USER_STATE_SOFT_BLOCKED: pr_debug("[BT] Device Powering OFF\n"); ret = disable_irq_wake(irq); if (ret < 0) pr_err("[BT] unset wakeup src failed\n"); disable_irq(irq); wake_unlock(&rfkill_wake_lock); s3c_gpio_setpull(GPIO_BT_nRST, S3C_GPIO_PULL_NONE); gpio_set_value(GPIO_BT_nRST, GPIO_LEVEL_LOW); s3c_gpio_slp_cfgpin(GPIO_BT_nRST, S3C_GPIO_SLP_OUT0); s3c_gpio_slp_setpull_updown(GPIO_BT_nRST, S3C_GPIO_PULL_NONE); pr_debug("[BT] GPIO_BT_nRST = %d\n", gpio_get_value(GPIO_BT_nRST)); if (gpio_get_value(GPIO_WLAN_nRST) == 0) { s3c_gpio_setpull(GPIO_WLAN_BT_EN, S3C_GPIO_PULL_NONE); gpio_set_value(GPIO_WLAN_BT_EN, GPIO_LEVEL_LOW); s3c_gpio_slp_cfgpin(GPIO_WLAN_BT_EN, S3C_GPIO_SLP_OUT0); s3c_gpio_slp_setpull_updown(GPIO_WLAN_BT_EN, S3C_GPIO_PULL_NONE); pr_debug("[BT] GPIO_WLAN_BT_EN = %d\n", gpio_get_value(GPIO_WLAN_BT_EN)); } break; default: pr_err("[BT] Bad bluetooth rfkill state %d\n", state); } return 0; }
static int bluetooth_set_power(void *data, enum rfkill_user_states state) { unsigned int ret = 0; switch (state) { case RFKILL_USER_STATE_UNBLOCKED: printk(KERN_DEBUG "[BT] Device Powering ON \n"); s3c_setup_uart_cfg_gpio(0); if (gpio_is_valid(GPIO_WLAN_BT_EN)) { ret = gpio_request(GPIO_WLAN_BT_EN, "GPB"); if (ret < 0) { printk(KERN_ERR "[BT] Failed to request GPIO_WLAN_BT_EN!\n"); return ret; } gpio_direction_output(GPIO_WLAN_BT_EN, GPIO_LEVEL_HIGH); } if (gpio_is_valid(GPIO_BT_nRST)) { ret = gpio_request(GPIO_BT_nRST, "GPB"); if (ret < 0) { gpio_free(GPIO_WLAN_BT_EN); printk(KERN_ERR "[BT] Failed to request GPIO_BT_nRST\n"); return ret; } gpio_direction_output(GPIO_BT_nRST, GPIO_LEVEL_LOW); } printk(KERN_DEBUG "[BT] GPIO_BT_nRST = %d\n", gpio_get_value(GPIO_BT_nRST)); /* Set GPIO_BT_WLAN_REG_ON high */ s3c_gpio_setpull(GPIO_WLAN_BT_EN, S3C_GPIO_PULL_NONE); gpio_set_value(GPIO_WLAN_BT_EN, GPIO_LEVEL_HIGH); s3c_gpio_slp_cfgpin(GPIO_WLAN_BT_EN, S3C_GPIO_SLP_OUT1); s3c_gpio_slp_setpull_updown(GPIO_WLAN_BT_EN, S3C_GPIO_PULL_NONE); printk( "[BT] GPIO_WLAN_BT_EN = %d\n", gpio_get_value(GPIO_WLAN_BT_EN)); /*FIXME sleep should be enabled disabled since the device is not booting * if its enabled*/ msleep(100); // 100msec, delay between reg_on & rst. (bcm4329 powerup sequence) /* Set GPIO_BT_nRST high */ s3c_gpio_setpull(GPIO_BT_nRST, S3C_GPIO_PULL_NONE); gpio_set_value(GPIO_BT_nRST, GPIO_LEVEL_HIGH); s3c_gpio_slp_cfgpin(GPIO_BT_nRST, S3C_GPIO_SLP_OUT1); s3c_gpio_slp_setpull_updown(GPIO_BT_nRST, S3C_GPIO_PULL_NONE); printk("[BT] GPIO_BT_nRST = %d\n", gpio_get_value(GPIO_BT_nRST)); gpio_free(GPIO_BT_nRST); gpio_free(GPIO_WLAN_BT_EN); break; case RFKILL_USER_STATE_SOFT_BLOCKED: printk(KERN_DEBUG "[BT] Device Powering OFF \n"); // s3c_reset_uart_cfg_gpio(0); s3c_gpio_setpull(GPIO_BT_nRST, S3C_GPIO_PULL_NONE); gpio_set_value(GPIO_BT_nRST, GPIO_LEVEL_LOW); s3c_gpio_slp_cfgpin(GPIO_BT_nRST, S3C_GPIO_SLP_OUT0); s3c_gpio_slp_setpull_updown(GPIO_BT_nRST, S3C_GPIO_PULL_NONE); printk("[BT] GPIO_BT_nRST = %d\n",gpio_get_value(GPIO_BT_nRST)); if(gpio_get_value(GPIO_WLAN_nRST) == 0) { s3c_gpio_setpull(GPIO_WLAN_BT_EN, S3C_GPIO_PULL_NONE); gpio_set_value(GPIO_WLAN_BT_EN, GPIO_LEVEL_LOW); s3c_gpio_slp_cfgpin(GPIO_WLAN_BT_EN, S3C_GPIO_SLP_OUT0); s3c_gpio_slp_setpull_updown(GPIO_WLAN_BT_EN, S3C_GPIO_PULL_NONE); printk("[BT] GPIO_WLAN_BT_EN = %d\n", gpio_get_value(GPIO_WLAN_BT_EN)); } gpio_free(GPIO_BT_nRST); gpio_free(GPIO_WLAN_BT_EN); break; default: printk(KERN_ERR "[BT] Bad bluetooth rfkill state %d\n", state); } return 0; }
static int bluetooth_set_power(void *data, enum rfkill_user_states state) { unsigned int ret = 0; switch (state) { case RFKILL_USER_STATE_UNBLOCKED: printk("[BT] Device Powering ON \n"); s3c_setup_uart_cfg_gpio(1); //wake_unlock(&bt_wake_lock); if (gpio_is_valid(GPIO_BT_WLAN_REG_ON)) { ret = gpio_request(GPIO_BT_WLAN_REG_ON, S3C_GPIO_LAVEL(GPIO_BT_WLAN_REG_ON)); if (ret < 0) { printk("[BT] Failed to request GPIO_BT_WLAN_REG_ON!\n"); return ret; } gpio_direction_output(GPIO_BT_WLAN_REG_ON, GPIO_LEVEL_HIGH); } if (gpio_is_valid(GPIO_BT_RST_N)) { ret = gpio_request(GPIO_BT_RST_N, S3C_GPIO_LAVEL(GPIO_BT_RST_N)); if (ret < 0) { gpio_free(GPIO_BT_WLAN_REG_ON); printk("[BT] Failed to request GPIO_BT_RST_N!\n"); return ret; } gpio_direction_output(GPIO_BT_RST_N, GPIO_LEVEL_LOW); } /* Set GPIO_BT_WLAN_REG_ON high */ s3c_gpio_setpull(GPIO_BT_WLAN_REG_ON, S3C_GPIO_PULL_NONE); gpio_set_value(GPIO_BT_WLAN_REG_ON, GPIO_LEVEL_HIGH); s3c_gpio_slp_cfgpin(GPIO_BT_WLAN_REG_ON, S3C_GPIO_SLP_OUT1); s3c_gpio_slp_setpull_updown(GPIO_BT_WLAN_REG_ON, S3C_GPIO_PULL_NONE); printk("[BT] GPIO_BT_WLAN_REG_ON = %d\n", gpio_get_value(GPIO_BT_WLAN_REG_ON)); mdelay(150); // 100msec, delay between reg_on & rst. (bcm4325 powerup sequence) /* Set GPIO_BT_RST_N high */ s3c_gpio_setpull(GPIO_BT_RST_N, S3C_GPIO_PULL_NONE); gpio_set_value(GPIO_BT_RST_N, GPIO_LEVEL_HIGH); s3c_gpio_slp_cfgpin(GPIO_BT_RST_N, S3C_GPIO_SLP_OUT1); s3c_gpio_slp_setpull_updown(GPIO_BT_RST_N, S3C_GPIO_PULL_NONE); printk("[BT] GPIO_BT_RST_N = %d\n", gpio_get_value(GPIO_BT_RST_N)); gpio_free(GPIO_BT_RST_N); gpio_free(GPIO_BT_WLAN_REG_ON); break; case RFKILL_USER_STATE_SOFT_BLOCKED: printk("[BT] Device Powering OFF \n"); //wake_unlock(&bt_wake_lock); //if not, it doesn't go to sleep after BT on->off. There's lock somewhere. s3c_reset_uart_cfg_gpio(1); s3c_gpio_setpull(GPIO_BT_RST_N, S3C_GPIO_PULL_NONE); gpio_set_value(GPIO_BT_RST_N, GPIO_LEVEL_LOW); s3c_gpio_slp_cfgpin(GPIO_BT_RST_N, S3C_GPIO_SLP_OUT0); s3c_gpio_slp_setpull_updown(GPIO_BT_RST_N, S3C_GPIO_PULL_NONE); printk("[BT] GPIO_BT_RST_N = %d\n",gpio_get_value(GPIO_BT_RST_N)); if(gpio_get_value(GPIO_WLAN_RST_N) == 0) { s3c_gpio_setpull(GPIO_BT_WLAN_REG_ON, S3C_GPIO_PULL_NONE); gpio_set_value(GPIO_BT_WLAN_REG_ON, GPIO_LEVEL_LOW); s3c_gpio_slp_cfgpin(GPIO_BT_WLAN_REG_ON, S3C_GPIO_SLP_OUT0); s3c_gpio_slp_setpull_updown(GPIO_BT_WLAN_REG_ON, S3C_GPIO_PULL_NONE); printk("[BT] GPIO_BT_WLAN_REG_ON = %d\n", gpio_get_value(GPIO_BT_WLAN_REG_ON)); } gpio_free(GPIO_BT_RST_N); gpio_free(GPIO_BT_WLAN_REG_ON); break; default: printk(KERN_ERR "[BT] Bad bluetooth rfkill state %d\n", state); } return 0; }
static int s3c_serial_init_port(struct s3c_uart_port *ourport, struct s3c_uart_info *info, struct platform_device *platdev) { struct uart_port *port = &ourport->port; struct s3c_uartcfg *cfg; struct resource *res; int ret; dbg("s3c_serial_init_port: port=%p, platdev=%p\n", port, platdev); if (platdev == NULL) return -ENODEV; cfg = s3c_dev_to_cfg(&platdev->dev); if (port->mapbase != 0) return 0; if (cfg->hwport > CONFIG_SERIAL_SAMSUNG_UARTS) { printk(KERN_ERR "%s: port %d bigger than %d\n", __func__, cfg->hwport, CONFIG_SERIAL_SAMSUNG_UARTS); return -ERANGE; } /* setup info for port */ port->dev = &platdev->dev; ourport->info = info; /* copy the info in from provided structure */ ourport->port.fifosize = info->fifosize; dbg("s3c_serial_init_port: %p (hw %d)...\n", port, cfg->hwport); port->uartclk = 1; if (cfg->uart_flags & UPF_CONS_FLOW) { dbg("s3c_serial_init_port: enabling flow control\n"); port->flags |= UPF_CONS_FLOW; } /* sort our the physical and virtual addresses for each UART */ res = platform_get_resource(platdev, IORESOURCE_MEM, 0); if (res == NULL) { printk(KERN_ERR "failed to find memory resource for uart\n"); return -EINVAL; } dbg("resource %p (%lx..%lx)\n", res, res->start, res->end); port->mapbase = res->start; port->membase = S3C_VA_UART + res->start - (S3C_PA_UART & 0xfff00000); ret = platform_get_irq(platdev, 0); if (ret < 0) port->irq = 0; else { port->irq = ret; ourport->rx_irq = ret; ourport->tx_irq = ret + 1; } ret = platform_get_irq(platdev, 1); if (ret > 0) ourport->tx_irq = ret; ourport->clk = clk_get(&platdev->dev, "uart"); dbg("port: map=%08x, mem=%08x, irq=%d (%d,%d), clock=%ld\n", port->mapbase, port->membase, port->irq, ourport->rx_irq, ourport->tx_irq, port->uartclk); /* reset the fifos (and setup the uart) */ s3c_serial_resetport(port, cfg); s3c_setup_uart_cfg_gpio(cfg->hwport, port); return 0; }
static int bt_set_power(void *data, enum rfkill_user_states state) { int ret = 0; int wl_ret =0; int irq; /* BT Host Wake IRQ */ irq = gpio_to_irq(BT_HOST_WAKE); switch (state) { case RFKILL_USER_STATE_UNBLOCKED: pr_info("[BT] Device Powering ON\n"); /* config uart0 */ s3c_setup_uart_cfg_gpio(0); /* set gpio direction */ if (gpio_is_valid(BT_POWER)) gpio_direction_output(BT_POWER, GPIO_LEVEL_HIGH); //request gpio wl_power when use it wl_ret = gpio_request(WL_POWER, "gpio_wl_power"); if (gpio_is_valid(WL_POWER)) gpio_direction_output(WL_POWER, GPIO_LEVEL_HIGH); if (gpio_is_valid(BT_RESET)) gpio_direction_output(BT_RESET, GPIO_LEVEL_LOW); /* Set BT_POWER high */ s3c_gpio_setpull(BT_POWER, S3C_GPIO_PULL_NONE); gpio_set_value(BT_POWER, GPIO_LEVEL_HIGH); s3c_gpio_slp_cfgpin(BT_POWER, S3C_GPIO_SLP_OUT1); s3c_gpio_slp_setpull_updown(BT_POWER, S3C_GPIO_PULL_NONE); /* Set WL_POWER high */ s3c_gpio_setpull(WL_POWER, S3C_GPIO_PULL_NONE); gpio_set_value(WL_POWER, GPIO_LEVEL_HIGH); s3c_gpio_slp_cfgpin(WL_POWER, S3C_GPIO_SLP_OUT1); s3c_gpio_slp_setpull_updown(WL_POWER, S3C_GPIO_PULL_NONE); if (wl_ret == 0) { gpio_free(WL_POWER); //free wl_power } /* * FIXME sleep should be enabled disabled since the device is * not booting if its enabled ? */ /* * at least 100 msec delay, between reg_on & rst. * (bcm4329 powerup sequence) */ msleep(100); //default 50; lvcha /* Set BT_RESET high */ s3c_gpio_setpull(BT_RESET, S3C_GPIO_PULL_NONE); gpio_set_value(BT_RESET, GPIO_LEVEL_HIGH); s3c_gpio_slp_cfgpin(BT_RESET, S3C_GPIO_SLP_OUT1); s3c_gpio_slp_setpull_updown(BT_RESET, S3C_GPIO_PULL_NONE); /* * at least 50 msec delay, after bt rst * (bcm4329 powerup sequence) */ msleep(50); gpio_set_value(BT_WAKE, GPIO_LEVEL_HIGH); ret = enable_irq_wake(irq); if (ret < 0) pr_err("[BT] set wakeup src failed\n"); enable_irq(irq); break; case RFKILL_USER_STATE_SOFT_BLOCKED: pr_info("[BT] Device Powering OFF\n"); /* Set irq */ ret = disable_irq_wake(irq); if (ret < 0) pr_err("[BT] unset wakeup src failed\n"); disable_irq(irq); /* Unlock wake lock */ wake_unlock(&rfkill_wake_lock); gpio_set_value(BT_WAKE, GPIO_LEVEL_LOW); /* Set BT_RESET low */ s3c_gpio_setpull(BT_RESET, S3C_GPIO_PULL_NONE); gpio_set_value(BT_RESET, GPIO_LEVEL_LOW); s3c_gpio_slp_cfgpin(BT_RESET, S3C_GPIO_SLP_OUT0); s3c_gpio_slp_setpull_updown(BT_RESET, S3C_GPIO_PULL_NONE); /* Check WL_RESET */ if (gpio_get_value(WL_RESET) == 0) { /* Set WL_POWER low */ s3c_gpio_setpull(WL_POWER, S3C_GPIO_PULL_NONE); gpio_set_value(WL_POWER, GPIO_LEVEL_LOW); s3c_gpio_slp_cfgpin(WL_POWER, S3C_GPIO_SLP_OUT0); s3c_gpio_slp_setpull_updown(WL_POWER, S3C_GPIO_PULL_NONE); /* Set BT_POWER low */ s3c_gpio_setpull(BT_POWER, S3C_GPIO_PULL_NONE); gpio_set_value(BT_POWER, GPIO_LEVEL_LOW); s3c_gpio_slp_cfgpin(BT_POWER, S3C_GPIO_SLP_OUT0); s3c_gpio_slp_setpull_updown(BT_POWER, S3C_GPIO_PULL_NONE); } break; default: pr_err("[BT] Bad bluetooth rfkill state %d\n", state); } return 0; }
static int bluetooth_set_power(void *data, enum rfkill_user_states state) { unsigned int ret = 0; static int on_off = 0; switch (state) { case RFKILL_USER_STATE_UNBLOCKED: printk(KERN_DEBUG "[BT] Device Powering ON \n"); s3c_setup_uart_cfg_gpio(0); if(on_off) return ret; //shiks_DF03 temp for AP sleep issue //just 1 time //FROYO MERGE if (gpio_is_valid(GPIO_WLAN_BT_EN)) { ret = gpio_request(GPIO_WLAN_BT_EN, "GPB"); if (ret < 0) { printk(KERN_ERR "[BT] Failed to request GPIO_WLAN_BT_EN!\n"); return ret; } gpio_direction_output(GPIO_WLAN_BT_EN, GPIO_LEVEL_HIGH); } //SecFeature shiks_DJ18 start enable_irq(IRQ_BT_HOST_WAKE);//for sleep surrent when wifi goes to sleep mode //SecFeature shiks_DJ18 end if (gpio_is_valid(GPIO_BT_nRST)) { ret = gpio_request(GPIO_BT_nRST, "GPB"); if (ret < 0) { gpio_free(GPIO_WLAN_BT_EN); printk(KERN_ERR "[BT] Failed to request GPIO_BT_nRST\n"); return ret; } gpio_direction_output(GPIO_BT_nRST, GPIO_LEVEL_LOW); } printk(KERN_DEBUG "[BT] GPIO_BT_nRST = %d\n", gpio_get_value(GPIO_BT_nRST)); /* Set GPIO_BT_WLAN_REG_ON high */ s3c_gpio_setpull(GPIO_WLAN_BT_EN, S3C_GPIO_PULL_NONE); gpio_set_value(GPIO_WLAN_BT_EN, GPIO_LEVEL_HIGH); s3c_gpio_slp_cfgpin(GPIO_WLAN_BT_EN, S3C_GPIO_SLP_PREV); s3c_gpio_slp_setpull_updown(GPIO_WLAN_BT_EN, S3C_GPIO_PULL_NONE); printk( "[BT] GPIO_WLAN_BT_EN = %d\n", gpio_get_value(GPIO_WLAN_BT_EN)); /*FIXME sleep should be enabled disabled since the device is not booting * if its enabled*/ msleep(200); // 100msec, delay between reg_on & rst. (bcm4329 powerup sequence) /* Set GPIO_BT_nRST high */ s3c_gpio_setpull(GPIO_BT_nRST, S3C_GPIO_PULL_NONE); gpio_set_value(GPIO_BT_nRST, GPIO_LEVEL_HIGH); s3c_gpio_slp_cfgpin(GPIO_BT_nRST, S3C_GPIO_SLP_OUT1); s3c_gpio_slp_setpull_updown(GPIO_BT_nRST, S3C_GPIO_PULL_NONE); printk("[BT] GPIO_BT_nRST = %d\n", gpio_get_value(GPIO_BT_nRST)); on_off =1; gpio_free(GPIO_BT_nRST); gpio_free(GPIO_WLAN_BT_EN); break; case RFKILL_USER_STATE_SOFT_BLOCKED: printk(KERN_DEBUG "[BT] Device Powering OFF \n"); // s3c_reset_uart_cfg_gpio(0); s3c_gpio_setpull(GPIO_BT_nRST, S3C_GPIO_PULL_NONE); gpio_set_value(GPIO_BT_nRST, GPIO_LEVEL_LOW); s3c_gpio_slp_cfgpin(GPIO_BT_nRST, S3C_GPIO_SLP_PREV); s3c_gpio_slp_setpull_updown(GPIO_BT_nRST, S3C_GPIO_PULL_NONE); printk("[BT] GPIO_BT_nRST = %d\n",gpio_get_value(GPIO_BT_nRST)); //SecFeature shiks_DJ18 start disable_irq(IRQ_BT_HOST_WAKE);//for sleep surrent when wifi goes to sleep mode //SecFeature shiks_DJ18 end if(gpio_get_value(GPIO_WLAN_nRST) == 0) { s3c_gpio_setpull(GPIO_WLAN_BT_EN, S3C_GPIO_PULL_NONE); gpio_set_value(GPIO_WLAN_BT_EN, GPIO_LEVEL_LOW); s3c_gpio_slp_cfgpin(GPIO_WLAN_BT_EN, S3C_GPIO_SLP_PREV); s3c_gpio_slp_setpull_updown(GPIO_WLAN_BT_EN, S3C_GPIO_PULL_NONE); printk("[BT] GPIO_WLAN_BT_EN = %d\n", gpio_get_value(GPIO_WLAN_BT_EN)); } on_off = 0; gpio_free(GPIO_BT_nRST); gpio_free(GPIO_WLAN_BT_EN); break; default: printk(KERN_ERR "[BT] Bad bluetooth rfkill state %d\n", state); } return 0; }
static int bluetooth_set_power(void *data, enum rfkill_user_states state) { int ret = 0; int irq; /* BT Host Wake IRQ */ irq = IRQ_WLAN_BT_HOST_WAKE; switch (state) { case RFKILL_USER_STATE_UNBLOCKED: printk("[BT] Device Powering ON \n");//pr_debug if (!loaded) break; /* Bluetooth over SDIO */ m8_bt_power(1, sdio); msleep(100); if (sdio && m8_checkse()) sdhci_s3c_force_presence_change(&s3c_device_hsmmc0); msleep(100); if (!sdio) s3c_setup_uart_cfg_gpio(1); #if 0 // uart not work now if (gpio_is_valid(GPIO_WLAN_BT_EN)) { printk("[BT] gpio_is_valid(GPIO_WLAN_BT_EN)\n"); gpio_direction_output(GPIO_WLAN_BT_EN, GPIO_LEVEL_HIGH); } if (gpio_is_valid(GPIO_BT_nRST)) { gpio_direction_output(GPIO_BT_nRST, GPIO_LEVEL_LOW); printk("[BT] gpio_is_valid(GPIO_BT_nRST)\n"); } printk("[BT] GPIO_BT_nRST = %d\n", gpio_get_value(GPIO_BT_nRST));//pr_debug /* Set GPIO_BT_WLAN_REG_ON high */ s3c_gpio_setpull(GPIO_WLAN_BT_EN, S3C_GPIO_PULL_NONE); gpio_set_value(GPIO_WLAN_BT_EN, GPIO_LEVEL_HIGH); s3c_gpio_slp_cfgpin(GPIO_WLAN_BT_EN, S3C_GPIO_SLP_OUT1); s3c_gpio_slp_setpull_updown(GPIO_WLAN_BT_EN, S3C_GPIO_PULL_NONE); printk("[BT] GPIO_WLAN_BT_EN = %d\n", gpio_get_value(GPIO_WLAN_BT_EN)); /* * FIXME sleep should be enabled disabled since the device is * not booting if its enabled */ /* * 100msec, delay between reg_on & rst. * (powerup sequence) */ msleep(500);//100); /* Set GPIO_BT_nRST high */ s3c_gpio_setpull(GPIO_BT_nRST, S3C_GPIO_PULL_NONE); gpio_set_value(GPIO_BT_nRST, GPIO_LEVEL_HIGH); s3c_gpio_slp_cfgpin(GPIO_BT_nRST, S3C_GPIO_SLP_OUT1); s3c_gpio_slp_setpull_updown(GPIO_BT_nRST, S3C_GPIO_PULL_NONE); printk("[BT] GPIO_BT_nRST = %d\n", gpio_get_value(GPIO_BT_nRST));//pr_debug /* * 50msec, delay after bt rst * (libertas powerup sequence) */ msleep(200);//50); //ret = enable_irq_wake(irq); //if (ret < 0) // pr_err("[BT] set wakeup src failed\n"); #endif enable_irq(irq); break; case RFKILL_USER_STATE_SOFT_BLOCKED: printk("[BT] Device Powering OFF\n"); if (!loaded) break; /* Bluetooth over SDIO */ m8_bt_power(0, sdio); msleep(100); if (sdio && m8_checkse()) sdhci_s3c_force_presence_change(&s3c_device_hsmmc0); //if (!sdio) // s3c_reset_uart_cfg_gpio(1); //ret = disable_irq_wake(irq); //if (ret < 0) // pr_err("[BT] unset wakeup src failed\n"); disable_irq(irq); wake_unlock(&rfkill_wake_lock); printk("[BT] wake_unlock rfkill_wake_lock\n"); #if 0 // UART s3c_gpio_setpull(GPIO_BT_nRST, S3C_GPIO_PULL_NONE); gpio_set_value(GPIO_BT_nRST, GPIO_LEVEL_LOW); s3c_gpio_slp_cfgpin(GPIO_BT_nRST, S3C_GPIO_SLP_OUT0); s3c_gpio_slp_setpull_updown(GPIO_BT_nRST, S3C_GPIO_PULL_NONE); printk("[BT] GPIO_BT_nRST = %d\n", gpio_get_value(GPIO_BT_nRST));//pr_debug if (gpio_get_value(GPIO_BT_nRST) == 0) { //GPIO_WLAN_nRST s3c_gpio_setpull(GPIO_WLAN_BT_EN, S3C_GPIO_PULL_NONE); gpio_set_value(GPIO_WLAN_BT_EN, GPIO_LEVEL_LOW); s3c_gpio_slp_cfgpin(GPIO_WLAN_BT_EN, S3C_GPIO_SLP_OUT0); s3c_gpio_slp_setpull_updown(GPIO_WLAN_BT_EN, S3C_GPIO_PULL_NONE); printk("[BT] GPIO_WLAN_BT_EN = %d\n", gpio_get_value(GPIO_WLAN_BT_EN)); } #endif break; default: printk(KERN_ERR "[BT] Bad bluetooth rfkill state %d\n", state);//pr_err } return 0; }