/* * Routine: get_board_revision * Description: Returns the board revision */ int get_board_revision(void) { int revision; if (!omap_request_gpio(126) && !omap_request_gpio(127) && !omap_request_gpio(128) && !omap_request_gpio(129)) { omap_set_gpio_direction(126, 1); omap_set_gpio_direction(127, 1); omap_set_gpio_direction(128, 1); omap_set_gpio_direction(129, 1); revision = 0; if (omap_get_gpio_datain(126) == 0) revision += 1; if (omap_get_gpio_datain(127) == 0) revision += 2; if (omap_get_gpio_datain(128) == 0) revision += 4; if (omap_get_gpio_datain(129) == 0) revision += 8; omap_free_gpio(126); omap_free_gpio(127); omap_free_gpio(128); omap_free_gpio(129); } else { printf("Error: unable to acquire board revision GPIOs\n"); revision=-1; } return revision; }
static void __exit hx_ts_remove(void) { if (machine_is_omap_h2()) omap_free_gpio(H2_GPIO_NUM); else if (machine_is_omap_h3()) omap_free_gpio(H3_GPIO_NUM); }
static int omap_kp_remove(struct platform_device *pdev) { struct omap_kp *omap_kp = platform_get_drvdata(pdev); /* disable keypad interrupt handling */ tasklet_disable(&kp_tasklet); if (cpu_is_omap24xx()) { int i; for (i = 0; i < omap_kp->cols; i++) omap_free_gpio(col_gpios[i]); for (i = 0; i < omap_kp->rows; i++) { omap_free_gpio(row_gpios[i]); free_irq(OMAP_GPIO_IRQ(row_gpios[i]), 0); } } else { omap_writew(1, OMAP_MPUIO_BASE + OMAP_MPUIO_KBD_MASKIT); free_irq(omap_kp->irq, 0); } del_timer_sync(&omap_kp->timer); tasklet_kill(&kp_tasklet); /* unregister everything */ input_unregister_device(omap_kp->input); kfree(omap_kp); return 0; }
// LCD configuration // static void lcd_config(void) { u32 ident_lcd = 0; ident_lcd |= 1; printf("LCD panel %x: %s\n", ident_lcd, (ident_lcd == 0)?"WINTEK 4.3 controlled via 3-wire": (ident_lcd == 1)?"S070WV95 7\"": (ident_lcd == 2)?"Dastek 4.3":"unknown"); ident_lcd += 'A'; set_lcd_env(ident_lcd); omap_request_gpio(164); // power on display buffer omap_request_gpio(104); // enable display buffer omap_set_gpio_dataout(164, 1); omap_set_gpio_direction(164, 0); omap_set_gpio_dataout(104, 0); omap_set_gpio_direction(104, 0); omap_free_gpio(104); omap_free_gpio(164); drv_lcd_init(); // initialize LCD interface printf("%s: done\n", __func__); }
/* * Routine: get_sdio2_config * Description: Return information about the wifi module connection * Returns 0 if the module connects though a level translator * Returns 1 if the module connects directly */ int get_sdio2_config(void) { int sdio_direct; if (!omap_request_gpio(130) && !omap_request_gpio(139)) { omap_set_gpio_direction(130, 0); omap_set_gpio_direction(139, 1); sdio_direct = 1; omap_set_gpio_dataout(130, 0); if (omap_get_gpio_datain(139) == 0) { omap_set_gpio_dataout(130, 1); if (omap_get_gpio_datain(139) == 1) sdio_direct = 0; } omap_free_gpio(130); omap_free_gpio(139); } else { printf("Error: unable to acquire sdio2 clk GPIOs\n"); sdio_direct=-1; } return sdio_direct; }
/* * Routine: get_board_revision * Description: Detect if we are running on a Beagle revision Ax/Bx, * C1/2/3, C4 or xM. This can be done by reading * the level of GPIO173, GPIO172 and GPIO171. This should * result in * GPIO173, GPIO172, GPIO171: 1 1 1 => Ax/Bx * GPIO173, GPIO172, GPIO171: 1 1 0 => C1/2/3 * GPIO173, GPIO172, GPIO171: 1 0 1 => C4 * GPIO173, GPIO172, GPIO171: 0 0 0 => xM */ int get_board_revision(void) { int revision; if (!omap_request_gpio(171) && !omap_request_gpio(172) && !omap_request_gpio(173)) { omap_set_gpio_direction(171, 1); omap_set_gpio_direction(172, 1); omap_set_gpio_direction(173, 1); revision = omap_get_gpio_datain(173) << 2 | omap_get_gpio_datain(172) << 1 | omap_get_gpio_datain(171); omap_free_gpio(171); omap_free_gpio(172); omap_free_gpio(173); } else { printf("Error: unable to acquire board revision GPIOs\n"); revision = -1; } return revision; }
static void innovator1610_panel_cleanup(void) { DBGENTER(1); omap_free_gpio(15); omap_free_gpio(14); DBGLEAVE(1); }
static void __exit brf6150_exit(void) { brf6150_hci_close(exit_info->hdev); hci_free_dev(exit_info->hdev); omap_free_gpio(exit_info->btinfo->reset_gpio); omap_free_gpio(exit_info->btinfo->bt_wakeup_gpio); omap_free_gpio(exit_info->btinfo->host_wakeup_gpio); free_irq(exit_info->irq, (void *)exit_info); free_irq(OMAP_GPIO_IRQ(exit_info->btinfo->host_wakeup_gpio), (void *)exit_info); kfree(exit_info); }
/** * usb_hcd_omap_remove - shutdown processing for OMAP-based HCDs * @dev: USB Host Controller being removed * Context: !in_interrupt() * * Reverses the effect of usb_hcd_omap_probe(), first invoking * the HCD's stop() method. It is always called from a thread * context, normally "rmmod", "apmd", or something similar. * */ void usb_hcd_omap_remove (struct usb_hcd *hcd, struct platform_device *pdev) { dev_info(&pdev->dev, "remove: state %x\n", hcd->state); if (in_interrupt ()) BUG (); hcd->state = USB_STATE_QUIESCING; dev_dbg(&pdev->dev, "roothub graceful disconnect\n"); usb_disconnect (&hcd->self.root_hub); hcd->driver->stop (hcd); hcd_buffer_destroy (hcd); hcd->state = USB_STATE_HALT; if (machine_is_omap_osk()) omap_free_gpio(9); free_irq (hcd->irq, hcd); usb_deregister_bus (&hcd->self); omap_stop_hc(pdev); release_mem_region(pdev->resource[0].start, pdev->resource[0].end - pdev->resource[0].start + 1); }
void __init n800_usb_init(void) { int ret = 0; static char announce[] __initdata = KERN_INFO "TUSB 6010\n"; /* PM companion chip power control pin */ ret = omap_request_gpio(GPIO_TUSB_ENABLE); if (ret != 0) { printk(KERN_ERR "Could not get TUSB power GPIO%i\n", GPIO_TUSB_ENABLE); return; } omap_set_gpio_direction(GPIO_TUSB_ENABLE, 0); tusb_set_power(0); ret = tusb6010_setup_interface(&tusb_data, TUSB6010_REFCLK_19, 2, TUSB_ASYNC_CS, TUSB_SYNC_CS, GPIO_TUSB_INT, 0x3f); if (ret != 0) goto err; printk(announce); return; err: omap_free_gpio(GPIO_TUSB_ENABLE); }
static void __init osk_mistral_init(void) { /* FIXME here's where to feed in framebuffer, touchpad, and * keyboard setup ... not in the drivers for those devices! * * NOTE: we could actually tell if there's a Mistral board * attached, e.g. by trying to read something from the ads7846. * But this is too early for that... */ /* the sideways button (SW1) is for use as a "wakeup" button */ omap_cfg_reg(N15_1610_MPUIO2); if (omap_request_gpio(OMAP_MPUIO(2)) == 0) { int ret = 0; omap_set_gpio_direction(OMAP_MPUIO(2), 1); set_irq_type(OMAP_GPIO_IRQ(OMAP_MPUIO(2)), IRQT_RISING); #ifdef CONFIG_PM /* share the IRQ in case someone wants to use the * button for more than wakeup from system sleep. */ ret = request_irq(OMAP_GPIO_IRQ(OMAP_MPUIO(2)), &osk_mistral_wake_interrupt, SA_SHIRQ, "mistral_wakeup", &osk_mistral_wake_interrupt); if (ret != 0) { omap_free_gpio(OMAP_MPUIO(2)); printk(KERN_ERR "OSK+Mistral: no wakeup irq, %d?\n", ret); } else enable_irq_wake(OMAP_GPIO_IRQ(OMAP_MPUIO(2))); #endif } else printk(KERN_ERR "OSK+Mistral: wakeup button is awol\n"); }
/* * Routine: beagle_identify * Description: Detect if we are running on a Beagle revision Ax/Bx, * C1/2/3, C4 or D. This can be done by reading * the level of GPIO173, GPIO172 and GPIO171. This should * result in * GPIO173, GPIO172, GPIO171: 1 1 1 => Ax/Bx * GPIO173, GPIO172, GPIO171: 1 1 0 => C1/2/3 * GPIO173, GPIO172, GPIO171: 1 0 1 => C4 * GPIO173, GPIO172, GPIO171: 0 0 0 => XM */ void beagle_identify(void) { omap_request_gpio(171); omap_request_gpio(172); omap_request_gpio(173); omap_set_gpio_direction(171, 1); omap_set_gpio_direction(172, 1); omap_set_gpio_direction(173, 1); beagle_revision = omap_get_gpio_datain(173) << 2 | omap_get_gpio_datain(172) << 1 | omap_get_gpio_datain(171); omap_free_gpio(171); omap_free_gpio(172); omap_free_gpio(173); }
static int isp1301_detach_client(struct i2c_client *i2c) { struct isp1301 *isp; isp = container_of(i2c, struct isp1301, client); isp1301_clear_bits(isp, ISP1301_INTERRUPT_FALLING, ~0); isp1301_clear_bits(isp, ISP1301_INTERRUPT_RISING, ~0); free_irq(isp->irq, isp); #ifdef CONFIG_USB_OTG otg_unbind(isp); #endif if (machine_is_omap_h2()) omap_free_gpio(2); isp->timer.data = 0; set_bit(WORK_STOP, &isp->todo); del_timer_sync(&isp->timer); flush_scheduled_work(); put_device(&i2c->dev); the_transceiver = 0; return i2c_detach_client(i2c); }
static int __devexit omap2_onenand_remove(struct platform_device *pdev) { struct omap2_onenand *c = dev_get_drvdata(&pdev->dev); BUG_ON(c == NULL); #ifdef CONFIG_MTD_PARTITIONS if (c->parts) del_mtd_partitions(&c->mtd); else del_mtd_device(&c->mtd); #else del_mtd_device(&c->mtd); #endif onenand_release(&c->mtd); if (c->dma_channel != -1) omap_free_dma(c->dma_channel); omap2_onenand_shutdown(pdev); platform_set_drvdata(pdev, NULL); if (c->gpio_irq) { free_irq(OMAP_GPIO_IRQ(c->gpio_irq), c); omap_free_gpio(c->gpio_irq); } iounmap(c->onenand.base); release_mem_region(c->phys_base, ONENAND_IO_SIZE); kfree(c); return 0; }
/** * usb_hcd_omap_remove - shutdown processing for OMAP-based HCDs * @dev: USB Host Controller being removed * Context: !in_interrupt() * * Reverses the effect of usb_hcd_omap_probe(), first invoking * the HCD's stop() method. It is always called from a thread * context, normally "rmmod", "apmd", or something similar. * */ void usb_hcd_omap_remove (struct usb_hcd *hcd, struct platform_device *pdev) { usb_remove_hcd(hcd); if (machine_is_omap_osk()) omap_free_gpio(9); omap_stop_hc(pdev); release_mem_region(hcd->rsrc_start, hcd->rsrc_len); usb_put_hcd(hcd); clk_put(usb_host_ck); }
static ssize_t gio_write(struct file *file, const char *buf, size_t count, \ loff_t *x) { int appType; int time_mics = 30; if (count != sizeof(int)) return -EINVAL; get_user(appType, (int *)buf); switch (appType) { case 3: { preempt_gpio1 = appType; printk(KERN_INFO "Request for GPIO = %d\n", \ preempt_gpio1); /* mdelay(time_mics); */ if (twl4030_request_gpio(preempt_gpio1) < 0) { printk(KERN_ERR "can't get GPIO\n"); return -EINVAL; } twl4030_set_gpio_direction(preempt_gpio1, 1); twl4030_set_gpio_debounce(preempt_gpio1, 1); twl4030_set_gpio_dataout(preempt_gpio1, 0); twl4030_set_gpio_dataout(preempt_gpio1, 1); twl4030_free_gpio(preempt_gpio1); break; } case 4: { preempt_gpio2 = appType; printk(KERN_INFO"Request for GPIO = %d\n", \ preempt_gpio2); if (omap_request_gpio(preempt_gpio2) < 0) { printk(KERN_ERR "can't get GPIO\n"); return -EINVAL; } twl4030_set_gpio_direction(preempt_gpio2, 1); twl4030_set_gpio_debounce(preempt_gpio2, 1); twl4030_set_gpio_dataout(preempt_gpio2, 0); twl4030_set_gpio_dataout(preempt_gpio2, 1); omap_free_gpio(preempt_gpio2); break; } default: printk(KERN_INFO "Entered default\n"); return -EINVAL; } return sizeof(int); }
void gpio_on_off(int gpio,char is_on) { omap_request_gpio(gpio); omap_set_gpio_direction(gpio,0); if(is_on) omap_set_gpio_dataout(gpio,1); else omap_set_gpio_dataout(gpio,0); omap_free_gpio(gpio); }
static int retu_remove(struct device *dev) { #ifdef CONFIG_CBUS_RETU_USER retu_user_cleanup(); #endif /* Mask all RETU interrupts */ retu_write_reg(RETU_REG_IMR, 0xffff); free_irq(OMAP_GPIO_IRQ(retu_irq_pin), 0); omap_free_gpio(retu_irq_pin); tasklet_kill(&retu_tasklet); return 0; }
/** * usb_hcd_omap_remove - shutdown processing for OMAP-based HCDs * @dev: USB Host Controller being removed * Context: !in_interrupt() * * Reverses the effect of usb_hcd_omap_probe(), first invoking * the HCD's stop() method. It is always called from a thread * context, normally "rmmod", "apmd", or something similar. */ static inline void usb_hcd_omap_remove (struct usb_hcd *hcd, struct platform_device *pdev) { struct ohci_hcd *ohci = hcd_to_ohci (hcd); usb_remove_hcd(hcd); if (ohci->transceiver) { (void) otg_set_host(ohci->transceiver, 0); put_device(ohci->transceiver->dev); } if (machine_is_omap_osk()) omap_free_gpio(9); release_mem_region(hcd->rsrc_start, hcd->rsrc_len); usb_put_hcd(hcd); clk_put(usb_dc_ck); clk_put(usb_host_ck); }
static void __init omap_serial_set_port_wakeup(int gpio_nr) { int ret; ret = omap_request_gpio(gpio_nr); if (ret < 0) { printk(KERN_ERR "Could not request UART wake GPIO: %i\n", gpio_nr); return; } omap_set_gpio_direction(gpio_nr, 1); ret = request_irq(OMAP_GPIO_IRQ(gpio_nr), &omap_serial_wake_interrupt, IRQF_TRIGGER_RISING, "serial wakeup", NULL); if (ret) { omap_free_gpio(gpio_nr); printk(KERN_ERR "No interrupt for UART wake GPIO: %i\n", gpio_nr); return; } enable_irq_wake(OMAP_GPIO_IRQ(gpio_nr)); }
static int innovator1610_panel_init(struct lcd_panel *panel, struct omapfb_device *fbdev) { int r = 0; if (omap_request_gpio(14)) { pr_err(MODULE_NAME ": can't request GPIO 14\n"); r = -1; goto exit; } if (omap_request_gpio(15)) { pr_err(MODULE_NAME ": can't request GPIO 15\n"); omap_free_gpio(14); r = -1; goto exit; } /* configure GPIO(14, 15) as outputs */ omap_set_gpio_direction(14, 0); omap_set_gpio_direction(15, 0); exit: return r; }
/* * Routine: zoom2_identify * Description: Detect which version of Zoom2 we are running on. */ void zoom2_identify(void) { /* * To check for production board vs beta board, * check if gpio 94 is clear. * * No way yet to check for alpha board identity. * Alpha boards were produced in very limited quantities * and they are not commonly used. They are mentioned here * only for completeness. */ if (!omap_request_gpio(94)) { unsigned int val; omap_set_gpio_direction(94, 1); val = omap_get_gpio_datain(94); omap_free_gpio(94); if (val) revision = ZOOM2_REVISION_BETA; else revision = ZOOM2_REVISION_PRODUCTION; } printf("Board revision "); switch (revision) { case ZOOM2_REVISION_PRODUCTION: printf("Production\n"); break; case ZOOM2_REVISION_BETA: printf("Beta\n"); break; default: printf("Unknown\n"); break; } }
static int innovator1610_panel_init(struct omapfb_device *fbdev) { int r = 0; DBGENTER(1); if (omap_request_gpio(14)) { pr_err("can't request GPIO 14\n"); r = -1; goto exit; } if (omap_request_gpio(15)) { pr_err("can't request GPIO 15\n"); omap_free_gpio(14); r = -1; goto exit; } /* configure GPIO(14, 15) as outputs */ omap_set_gpio_direction(14, 0); omap_set_gpio_direction(15, 0); exit: DBGLEAVE(1); return r; }
static void innovator1610_panel_cleanup(struct lcd_panel *panel) { omap_free_gpio(15); omap_free_gpio(14); }
static void __init osk_mistral_init(void) { /* NOTE: we could actually tell if there's a Mistral board * attached, e.g. by trying to read something from the ads7846. * But this arch_init() code is too early for that, since we * can't talk to the ads or even the i2c eeprom. */ /* parallel camera interface */ omap_cfg_reg(J15_1610_CAM_LCLK); omap_cfg_reg(J18_1610_CAM_D7); omap_cfg_reg(J19_1610_CAM_D6); omap_cfg_reg(J14_1610_CAM_D5); omap_cfg_reg(K18_1610_CAM_D4); omap_cfg_reg(K19_1610_CAM_D3); omap_cfg_reg(K15_1610_CAM_D2); omap_cfg_reg(K14_1610_CAM_D1); omap_cfg_reg(L19_1610_CAM_D0); omap_cfg_reg(L18_1610_CAM_VS); omap_cfg_reg(L15_1610_CAM_HS); omap_cfg_reg(M19_1610_CAM_RSTZ); omap_cfg_reg(Y15_1610_CAM_OUTCLK); /* serial camera interface */ omap_cfg_reg(H19_1610_CAM_EXCLK); omap_cfg_reg(W13_1610_CCP_CLKM); omap_cfg_reg(Y12_1610_CCP_CLKP); /* CCP_DATAM CONFLICTS WITH UART1.TX (and serial console) */ /* omap_cfg_reg(Y14_1610_CCP_DATAM); */ omap_cfg_reg(W14_1610_CCP_DATAP); /* CAM_PWDN */ if (omap_request_gpio(11) == 0) { omap_cfg_reg(N20_1610_GPIO11); omap_set_gpio_direction(11, 0 /* out */); omap_set_gpio_dataout(11, 0 /* off */); } else pr_debug("OSK+Mistral: CAM_PWDN is awol\n"); /* omap_cfg_reg(P19_1610_GPIO6); */ /* BUSY */ omap_cfg_reg(P20_1610_GPIO4); /* PENIRQ */ set_irq_type(OMAP_GPIO_IRQ(4), IRQT_FALLING); spi_register_board_info(mistral_boardinfo, ARRAY_SIZE(mistral_boardinfo)); /* the sideways button (SW1) is for use as a "wakeup" button */ omap_cfg_reg(N15_1610_MPUIO2); if (omap_request_gpio(OMAP_MPUIO(2)) == 0) { int ret = 0; omap_set_gpio_direction(OMAP_MPUIO(2), 1); set_irq_type(OMAP_GPIO_IRQ(OMAP_MPUIO(2)), IRQT_RISING); #ifdef CONFIG_PM /* share the IRQ in case someone wants to use the * button for more than wakeup from system sleep. */ ret = request_irq(OMAP_GPIO_IRQ(OMAP_MPUIO(2)), &osk_mistral_wake_interrupt, IRQF_SHARED, "mistral_wakeup", &osk_mistral_wake_interrupt); if (ret != 0) { omap_free_gpio(OMAP_MPUIO(2)); printk(KERN_ERR "OSK+Mistral: no wakeup irq, %d?\n", ret); } else enable_irq_wake(OMAP_GPIO_IRQ(OMAP_MPUIO(2))); #endif } else printk(KERN_ERR "OSK+Mistral: wakeup button is awol\n"); /* LCD: backlight, and power; power controls other devices on the * board, like the touchscreen, EEPROM, and wakeup (!) switch. */ omap_cfg_reg(PWL); if (omap_request_gpio(2) == 0) { omap_set_gpio_direction(2, 0 /* out */); omap_set_gpio_dataout(2, 1 /* on */); } platform_add_devices(mistral_devices, ARRAY_SIZE(mistral_devices)); }
static int __init brf6150_init(void) { struct brf6150_info *info; int irq, err; info = kmalloc(sizeof(struct brf6150_info), GFP_KERNEL); if (!info) return -ENOMEM; memset(info, 0, sizeof(struct brf6150_info)); brf6150_device.dev.driver_data = info; init_completion(&info->init_completion); init_completion(&info->fw_completion); info->pm_enabled = 0; info->rx_pm_enabled = 0; info->tx_pm_enabled = 0; info->garbage_bytes = 0; tasklet_init(&info->tx_task, brf6150_tx_tasklet, (unsigned long)info); spin_lock_init(&info->lock); skb_queue_head_init(&info->txq); init_timer(&info->pm_timer); info->pm_timer.function = brf6150_pm_timer; info->pm_timer.data = (unsigned long)info; exit_info = NULL; info->btinfo = omap_get_config(OMAP_TAG_NOKIA_BT, struct omap_bluetooth_config); if (info->btinfo == NULL) return -1; NBT_DBG("RESET gpio: %d\n", info->btinfo->reset_gpio); NBT_DBG("BTWU gpio: %d\n", info->btinfo->bt_wakeup_gpio); NBT_DBG("HOSTWU gpio: %d\n", info->btinfo->host_wakeup_gpio); NBT_DBG("Uart: %d\n", info->btinfo->bt_uart); NBT_DBG("sysclk: %d\n", info->btinfo->bt_sysclk); err = omap_request_gpio(info->btinfo->reset_gpio); if (err < 0) { printk(KERN_WARNING "Cannot get GPIO line %d", info->btinfo->reset_gpio); kfree(info); return err; } err = omap_request_gpio(info->btinfo->bt_wakeup_gpio); if (err < 0) { printk(KERN_WARNING "Cannot get GPIO line 0x%d", info->btinfo->bt_wakeup_gpio); omap_free_gpio(info->btinfo->reset_gpio); kfree(info); return err; } err = omap_request_gpio(info->btinfo->host_wakeup_gpio); if (err < 0) { printk(KERN_WARNING "Cannot get GPIO line %d", info->btinfo->host_wakeup_gpio); omap_free_gpio(info->btinfo->reset_gpio); omap_free_gpio(info->btinfo->bt_wakeup_gpio); kfree(info); return err; } omap_set_gpio_direction(info->btinfo->reset_gpio, 0); omap_set_gpio_direction(info->btinfo->bt_wakeup_gpio, 0); omap_set_gpio_direction(info->btinfo->host_wakeup_gpio, 1); set_irq_type(OMAP_GPIO_IRQ(info->btinfo->host_wakeup_gpio), IRQ_TYPE_NONE); switch (info->btinfo->bt_uart) { case 1: irq = INT_UART1; info->uart_ck = clk_get(NULL, "uart1_ck"); /* FIXME: Use platform_get_resource for the port */ info->uart_base = ioremap(OMAP_UART1_BASE, 0x16); if (!info->uart_base) goto cleanup; break; case 2: irq = INT_UART2; info->uart_ck = clk_get(NULL, "uart2_ck"); /* FIXME: Use platform_get_resource for the port */ info->uart_base = ioremap(OMAP_UART2_BASE, 0x16); if (!info->uart_base) goto cleanup; break; case 3: irq = INT_UART3; info->uart_ck = clk_get(NULL, "uart3_ck"); /* FIXME: Use platform_get_resource for the port */ info->uart_base = ioremap(OMAP_UART3_BASE, 0x16); if (!info->uart_base) goto cleanup; break; default: printk(KERN_ERR "No uart defined\n"); goto cleanup; } info->irq = irq; err = request_irq(irq, brf6150_interrupt, 0, "brf6150", (void *)info); if (err < 0) { printk(KERN_ERR "brf6150: unable to get IRQ %d\n", irq); goto cleanup; } err = request_irq(OMAP_GPIO_IRQ(info->btinfo->host_wakeup_gpio), brf6150_wakeup_interrupt, 0, "brf6150_wkup", (void *)info); if (err < 0) { printk(KERN_ERR "brf6150: unable to get wakeup IRQ %d\n", OMAP_GPIO_IRQ(info->btinfo->host_wakeup_gpio)); free_irq(irq, (void *)info); goto cleanup; } /* Register with LDM */ if (platform_device_register(&brf6150_device)) { printk(KERN_ERR "failed to register brf6150 device\n"); err = -ENODEV; goto cleanup_irq; } /* Register the driver with LDM */ if (driver_register(&brf6150_driver)) { printk(KERN_WARNING "failed to register brf6150 driver\n"); platform_device_unregister(&brf6150_device); err = -ENODEV; goto cleanup_irq; } if (brf6150_register_hdev(info) < 0) { printk(KERN_WARNING "failed to register brf6150 hci device\n"); platform_device_unregister(&brf6150_device); driver_unregister(&brf6150_driver); goto cleanup_irq; } exit_info = info; return 0; cleanup_irq: free_irq(irq, (void *)info); free_irq(OMAP_GPIO_IRQ(info->btinfo->host_wakeup_gpio), (void *)info); cleanup: omap_free_gpio(info->btinfo->reset_gpio); omap_free_gpio(info->btinfo->bt_wakeup_gpio); omap_free_gpio(info->btinfo->host_wakeup_gpio); kfree(info); return err; }
/* * Routine: misc_init_r * Description: Configure board specific parts */ int misc_init_r(void) { int err; hw_boot_status status_bits; unsigned short reg; unsigned char val; u8 data; /* * Configure drive strength for IO cells */ // already pulled up on board //*(ulong *)(CONTROL_PROG_IO1) &= ~(PRG_I2C2_PULLUPRESX); _board_revision(); printf("%s: initialize TPS65950 voltages\n", __func__); twl4030_power_init(); printf("%s: select TPS65950 power-on HW transitions(PWRON and RTC)\n", __func__); twl4030_set_px_transition(0x07, 0x49); printf("%s: select 1-GHz MPU clock\n", __func__); // 26 MHz * 500 / (12 + 1) select_mpu_clock(500, 12); lcd_config(); printf("%s: initialize all peripherals\n", __func__); omap_request_gpio(27); // Enable periph 3V omap_request_gpio(34); // reset USBHUB omap_request_gpio(38); // disable CAN omap_request_gpio(40); // reset modem omap_request_gpio(41); // disable modem omap_request_gpio(42); // reset CAP touch omap_request_gpio(43); // off CAN omap_request_gpio(61); // off modem omap_request_gpio(64); // off GPS omap_request_gpio(65); // off USB PHY omap_request_gpio(94); // automotive out high omap_request_gpio(95); // Wireless module VIO 1.8 V omap_request_gpio(98); // DEVICE_EN omap_request_gpio(111); // off USB PHY omap_request_gpio(136); // Wireless module VDD 3.6 V omap_request_gpio(137); // BT_EN omap_request_gpio(138); // WL_EN omap_request_gpio(144); // disable GPS omap_request_gpio(145); // reset GPS omap_request_gpio(146); // disable GPS boot omap_request_gpio(161); // select microphone omap_request_gpio(162); // serial transmitter force on omap_request_gpio(175); // shutdown internal speaker amplifier omap_request_gpio(176); // shutdown external speaker amplifier omap_request_gpio(177); // enable external I2C device omap_request_gpio(186); // PWR_ON generator // Enable serial ports transceiver omap_set_gpio_dataout(162, 1); omap_set_gpio_direction(162, 0); omap_set_gpio_dataout(98, 0); omap_set_gpio_direction(98, 0); omap_set_gpio_dataout(94, 0); omap_set_gpio_direction(94, 0); // enable peripheral 3.3 V omap_set_gpio_dataout(27, 1); omap_set_gpio_direction(27, 0); // PWR_ON generator will off omap_set_gpio_dataout(186, 1); omap_set_gpio_direction(186, 0); // disable BT omap_set_gpio_dataout(137, 0); omap_set_gpio_direction(137, 0); // disable WL omap_set_gpio_dataout(138, 0); omap_set_gpio_direction(138, 0); // wireless VIO 1.8V off omap_set_gpio_dataout(95, 0); omap_set_gpio_direction(95, 0); // remove wireless VDD 3.6 V omap_set_gpio_dataout(136, 0); omap_set_gpio_direction(136, 0); udelay(100000); // Supply VDD and VIO to WiFi omap_set_gpio_dataout(136, 1); omap_set_gpio_dataout(95, 1); udelay(100000); // enable digital PADs // MMC2 MUX_VAL(CP(MMC2_CLK), (IEN | PTU | EN | M0)) MUX_VAL(CP(MMC2_CMD), (IEN | PTU | EN | M0)) MUX_VAL(CP(MMC2_DAT0), (IEN | PTU | EN | M0)) MUX_VAL(CP(MMC2_DAT1), (IEN | PTU | EN | M0)) MUX_VAL(CP(MMC2_DAT2), (IEN | PTU | EN | M0)) MUX_VAL(CP(MMC2_DAT3), (IEN | PTU | EN | M0)) // UART2 MUX_VAL(CP(MCBSP3_FSX), (IEN | PTD | DIS | M1)) MUX_VAL(CP(MCBSP3_CLKX),(IDIS | PTD | DIS | M1)) MUX_VAL(CP(MCBSP3_DR), (IDIS | PTD | DIS | M1)) MUX_VAL(CP(MCBSP3_DX), (IEN | PTD | DIS | M1)) udelay(200000); // pulse enable pins // enable WL omap_set_gpio_dataout(138, 1); // enable BT omap_set_gpio_dataout(137, 1); udelay(200000); // Valdimir: temporary enabled // disable BT //omap_set_gpio_dataout(137, 0); // disable WL //omap_set_gpio_dataout(138, 0); omap_set_gpio_dataout(41, 0); omap_set_gpio_direction(41, 0); omap_set_gpio_dataout(40, 0); omap_set_gpio_direction(40, 0); omap_set_gpio_dataout(61, 0); omap_set_gpio_direction(61, 0); omap_set_gpio_dataout(144, 0); omap_set_gpio_direction(144, 0); omap_set_gpio_dataout(145, 0); omap_set_gpio_direction(145, 0); omap_set_gpio_dataout(146, 0); omap_set_gpio_direction(146, 0); omap_set_gpio_dataout(64, 0); omap_set_gpio_direction(64, 0); omap_set_gpio_dataout(38, 0); omap_set_gpio_direction(38, 0); omap_set_gpio_dataout(43, 0); omap_set_gpio_direction(43, 0); omap_set_gpio_dataout(42, 0); omap_set_gpio_direction(42, 0); omap_set_gpio_dataout(34, 0); omap_set_gpio_direction(34, 0); omap_set_gpio_dataout(111, 1); omap_set_gpio_direction(111, 0); omap_set_gpio_dataout(65, 0); omap_set_gpio_direction(65, 0); // enable internal speaker amplifier omap_set_gpio_dataout(175, 0); omap_set_gpio_direction(175, 0); // shutdown external speaker amplifier omap_set_gpio_dataout(176, 0); omap_set_gpio_direction(176, 0); // select internal microphone omap_set_gpio_dataout(161, 0); omap_set_gpio_direction(161, 0); // External I2C Bus enable omap_set_gpio_dataout(177, 0); omap_set_gpio_direction(177, 0); omap_free_gpio(27); omap_free_gpio(34); omap_free_gpio(38); omap_free_gpio(40); omap_free_gpio(41); omap_free_gpio(42); omap_free_gpio(43); omap_free_gpio(61); omap_free_gpio(64); omap_free_gpio(65); omap_free_gpio(94); omap_free_gpio(95); omap_free_gpio(98); omap_free_gpio(111); omap_free_gpio(136); omap_free_gpio(137); omap_free_gpio(138); omap_free_gpio(144); omap_free_gpio(145); omap_free_gpio(146); omap_free_gpio(161); omap_free_gpio(162); omap_free_gpio(175); omap_free_gpio(177); omap_free_gpio(186); printf("%s: initialize all peripherals done\n", __func__); twl4030_keypad_init(); // TODO: thermal shutdown and dynamic frequency scaling // TPS659XX PHY 3.3 V recovery workaround // Status bits read from companion chip and OMAP twl4030_i2c_read_u8(TWL4030_CHIP_RTC, &data, TWL_BACKUP_REG_G); //TWL_BACKUP_REG_G - set in thermal driver status_bits.thermal = data; twl4030_i2c_read_u8(TWL4030_CHIP_RTC, &data, TWL_RTC_STATUS_REG); //TWL_RTC_STATUS_REG status_bits.rtc_power_up = (data & TWL_RTC_STATUS_POWER_UP) ? 1 : 0; status_bits.rtc_alarm = (data & TWL_RTC_STATUS_ALARM) ? 1 : 0; status_bits.rtc_event = (data & (TWL_RTC_STATUS_ONE_D_EVENT | TWL_RTC_STATUS_ONE_H_EVENT | TWL_RTC_STATUS_ONE_M_EVENT | TWL_RTC_STATUS_ONE_S_EVENT))? 1 : 0; twl4030_i2c_read_u8(TWL4030_CHIP_RTC, &data, TWL_RTC_INTERRUPTS_REG); //TWL_RTC_INTERRUPTS_REG status_bits.rtc_it_timer = (data & TWL_RTC_INTERRUPTS_IT_TIMER) ? 1 : 0; status_bits.rtc_it_alarm = (data & TWL_RTC_INTERRUPTS_IT_ALARM) ? 1 : 0; twl4030_i2c_read_u8(TWL4030_CHIP_RTC, &data, TWL_STS_BOOT); //TWL_STS_BOOT status_bits.watchdog_reset = (data & (1<<5)) ? 1 : 0;//TWL_WATCHDOG_RESET twl4030_i2c_read_u8(TWL4030_CHIP_RTC, &data, TWL_STS_HW_CONDITIONS); //TWL_STS_HW_CONDITIONS status_bits.sts_pwon = (data & 1) ? 1 : 0; //STS_PWON status_bits.sts_warmreset = (data & (1<<3)) ? 1 : 0; //STS_WARMRESET twl4030_i2c_read_u8(TWL4030_CHIP_RTC, &data, TWL_PWR_ISR1); //TWL_PWR_ISR1 status_bits.isr_pwron = (data & STARTON_RTC) ? 1 : 0; status_bits.isr_rtc_it = (data & STARTON_PWON) ? 1 : 0; status_bits.prm_rstst = readl(OMAP_PRCM_PRM_RSTST); char str[9]; sprintf(str, "%d", status_bits.bits); setenv("hw_stat", str); printf("Status bits [0x%x] [%s]\n", status_bits.bits, str); printf("Board Revision A317 (%d)\n", board_revision); sprintf(str, "%s", "A-317"); setenv("product", str); dieid_num_r(); return 0; }
static int mt9p012_sensor_power_set(enum v4l2_power power) { switch (power) { case V4L2_POWER_OFF: /* Power Down Sequence */ #ifdef CONFIG_TWL4030_CORE twl4030_i2c_write_u8(TWL4030_MODULE_PM_RECEIVER, VAUX_DEV_GRP_NONE, TWL4030_VAUX2_DEV_GRP); #else #error "no power companion board defined!" #endif enable_fpga_vio_1v8(0); omap_free_gpio(MT9P012_RESET_GPIO); iounmap(fpga_map_addr); omap_free_gpio(MT9P012_STANDBY_GPIO); break; case V4L2_POWER_ON: if (mt9p012_previous_power == V4L2_POWER_OFF) { /* Power Up Sequence */ isp_configure_interface(&mt9p012_if_config); /* Request and configure gpio pins */ if (omap_request_gpio(MT9P012_STANDBY_GPIO) != 0) { printk(KERN_WARNING "Could not request GPIO %d" " for MT9P012\n", MT9P012_STANDBY_GPIO); return -EIO; } /* Request and configure gpio pins */ if (omap_request_gpio(MT9P012_RESET_GPIO) != 0) return -EIO; /* set to output mode */ gpio_direction_output(MT9P012_STANDBY_GPIO, true); /* set to output mode */ gpio_direction_output(MT9P012_RESET_GPIO, true); /* STANDBY_GPIO is active HIGH for set LOW to release */ gpio_set_value(MT9P012_STANDBY_GPIO, 1); /* nRESET is active LOW. set HIGH to release reset */ gpio_set_value(MT9P012_RESET_GPIO, 1); /* turn on digital power */ enable_fpga_vio_1v8(1); #ifdef CONFIG_TWL4030_CORE /* turn on analog power */ twl4030_i2c_write_u8(TWL4030_MODULE_PM_RECEIVER, VAUX_2_8_V, TWL4030_VAUX2_DEDICATED); twl4030_i2c_write_u8(TWL4030_MODULE_PM_RECEIVER, VAUX_DEV_GRP_P1, TWL4030_VAUX2_DEV_GRP); #else #error "no power companion board defined!" #endif } /* out of standby */ gpio_set_value(MT9P012_STANDBY_GPIO, 0); udelay(1000); if (mt9p012_previous_power == V4L2_POWER_OFF) { /* have to put sensor to reset to guarantee detection */ gpio_set_value(MT9P012_RESET_GPIO, 0); udelay(1500); /* nRESET is active LOW. set HIGH to release reset */ gpio_set_value(MT9P012_RESET_GPIO, 1); /* give sensor sometime to get out of the reset. * Datasheet says 2400 xclks. At 6 MHz, 400 usec is * enough */ udelay(300); } break; case V4L2_POWER_STANDBY: /* stand by */ gpio_set_value(MT9P012_STANDBY_GPIO, 1); break; } /* Save powerstate to know what was before calling POWER_ON. */ mt9p012_previous_power = power; return 0; }
static int ov3640_sensor_power_set(enum v4l2_power power) { struct isp_csi2_lanes_cfg lanecfg; struct isp_csi2_phy_cfg phyconfig; static enum v4l2_power previous_power = V4L2_POWER_OFF; switch (power) { case V4L2_POWER_ON: if (previous_power == V4L2_POWER_OFF) isp_csi2_reset(); lanecfg.clk.pol = OV3640_CSI2_CLOCK_POLARITY; lanecfg.clk.pos = OV3640_CSI2_CLOCK_LANE; lanecfg.data[0].pol = OV3640_CSI2_DATA0_POLARITY; lanecfg.data[0].pos = OV3640_CSI2_DATA0_LANE; lanecfg.data[1].pol = OV3640_CSI2_DATA1_POLARITY; lanecfg.data[1].pos = OV3640_CSI2_DATA1_LANE; lanecfg.data[2].pol = 0; lanecfg.data[2].pos = 0; lanecfg.data[3].pol = 0; lanecfg.data[3].pos = 0; isp_csi2_complexio_lanes_config(&lanecfg); isp_csi2_complexio_lanes_update(true); phyconfig.ths_term = OV3640_CSI2_PHY_THS_TERM; phyconfig.ths_settle = OV3640_CSI2_PHY_THS_SETTLE; phyconfig.tclk_term = OV3640_CSI2_PHY_TCLK_TERM; phyconfig.tclk_miss = OV3640_CSI2_PHY_TCLK_MISS; phyconfig.tclk_settle = OV3640_CSI2_PHY_TCLK_SETTLE; isp_csi2_phy_config(&phyconfig); isp_csi2_phy_update(true); isp_configure_interface(&ov3640_if_config); if (previous_power == V4L2_POWER_OFF) { #ifdef CONFIG_TWL4030_CORE /* turn on analog power */ #if defined(CONFIG_VIDEO_OV3640_CSI2) twl4030_i2c_write_u8(TWL4030_MODULE_PM_RECEIVER, VAUX_1_8_V, TWL4030_VAUX4_DEDICATED); twl4030_i2c_write_u8(TWL4030_MODULE_PM_RECEIVER, VAUX_DEV_GRP_P1, TWL4030_VAUX4_DEV_GRP); #else twl4030_i2c_write_u8(TWL4030_MODULE_PM_RECEIVER, VAUX_2_8_V, TWL4030_VAUX2_DEDICATED); twl4030_i2c_write_u8(TWL4030_MODULE_PM_RECEIVER, VAUX_DEV_GRP_P1, TWL4030_VAUX2_DEV_GRP); #endif udelay(100); #else #error "no power companion board defined!" #endif /* Request and configure gpio pins */ if (omap_request_gpio(OV3640_RESET_GPIO) != 0) { printk(KERN_ERR "Could not request GPIO %d", OV3640_RESET_GPIO); return -EIO; } if (omap_request_gpio(OV3640_STANDBY_GPIO) != 0) { printk(KERN_ERR "Could not request GPIO %d", OV3640_STANDBY_GPIO); return -EIO; } /* set to output mode */ gpio_direction_output(OV3640_RESET_GPIO, true); gpio_direction_output(OV3640_STANDBY_GPIO, true); /* Turn ON Omnivision sensor */ gpio_set_value(OV3640_RESET_GPIO, 1); gpio_set_value(OV3640_STANDBY_GPIO, 0); udelay(100); /* RESET Omnivision sensor */ gpio_set_value(OV3640_RESET_GPIO, 0); udelay(100); gpio_set_value(OV3640_RESET_GPIO, 1); /* Wait 10 ms */ mdelay(10); enable_fpga_vio_1v8(1); udelay(100); } break; case V4L2_POWER_OFF: /* Power Down Sequence */ isp_csi2_complexio_power(ISP_CSI2_POWER_OFF); #ifdef CONFIG_TWL4030_CORE #if defined(CONFIG_VIDEO_OV3640_CSI2) twl4030_i2c_write_u8(TWL4030_MODULE_PM_RECEIVER, VAUX_DEV_GRP_NONE, TWL4030_VAUX4_DEV_GRP); #else twl4030_i2c_write_u8(TWL4030_MODULE_PM_RECEIVER, VAUX_DEV_GRP_NONE, TWL4030_VAUX2_DEV_GRP); #endif #else #error "no power companion board defined!" #endif enable_fpga_vio_1v8(0); omap_free_gpio(OV3640_RESET_GPIO); iounmap(fpga_map_addr); omap_free_gpio(OV3640_STANDBY_GPIO); break; case V4L2_POWER_STANDBY: break; } previous_power = power; return 0; }
/** * retu_probe - Probe for Retu ASIC * @dev: the Retu device * * Probe for the Retu ASIC and allocate memory * for its device-struct if found */ static int __devinit retu_probe(struct device *dev) { const struct omap_em_asic_bb5_config * em_asic_config; int rev, ret; /* Prepare tasklet */ tasklet_init(&retu_tasklet, retu_tasklet_handler, 0); em_asic_config = omap_get_config(OMAP_TAG_EM_ASIC_BB5, struct omap_em_asic_bb5_config); if (em_asic_config == NULL) { printk(KERN_ERR PFX "Unable to retrieve config data\n"); return -ENODATA; } retu_irq_pin = em_asic_config->retu_irq_gpio; if ((ret = omap_request_gpio(retu_irq_pin)) < 0) { printk(KERN_ERR PFX "Unable to reserve IRQ GPIO\n"); return ret; } /* Set the pin as input */ omap_set_gpio_direction(retu_irq_pin, 1); /* Rising edge triggers the IRQ */ set_irq_type(OMAP_GPIO_IRQ(retu_irq_pin), IRQT_RISING); retu_initialized = 1; rev = retu_read_reg(RETU_REG_ASICR) & 0xff; if (rev & (1 << 7)) retu_is_vilma = 1; printk(KERN_INFO "%s v%d.%d found\n", retu_is_vilma ? "Vilma" : "Retu", (rev >> 4) & 0x07, rev & 0x0f); /* Mask all RETU interrupts */ retu_write_reg(RETU_REG_IMR, 0xffff); ret = request_irq(OMAP_GPIO_IRQ(retu_irq_pin), retu_irq_handler, 0, "retu", 0); if (ret < 0) { printk(KERN_ERR PFX "Unable to register IRQ handler\n"); omap_free_gpio(retu_irq_pin); return ret; } /* Register power off function */ pm_power_off = retu_power_off; #ifdef CONFIG_CBUS_RETU_USER /* Initialize user-space interface */ if (retu_user_init() < 0) { printk(KERN_ERR "Unable to initialize driver\n"); free_irq(OMAP_GPIO_IRQ(retu_irq_pin), 0); omap_free_gpio(retu_irq_pin); return ret; } #endif return 0; }