static int wl1251_sdio_set_power(struct wl1251 *wl, bool enable) { struct sdio_func *func = wl_to_func(wl); int ret; if (enable) { /* * Power is controlled by runtime PM, but we still call board * callback in case it wants to do any additional setup, * for example enabling clock buffer for the module. */ if (wl->set_power) wl->set_power(true); ret = pm_runtime_get_sync(&func->dev); if (ret < 0) goto out; sdio_claim_host(func); sdio_enable_func(func); sdio_release_host(func); } else { sdio_claim_host(func); sdio_disable_func(func); sdio_release_host(func); ret = pm_runtime_put_sync(&func->dev); if (ret < 0) goto out; if (wl->set_power) wl->set_power(false); } out: return ret; }
static void unblank_framebuffer(int releaseref) { struct device *fbdev = NULL; struct fb_info *fb_info; struct s3c_fb_win *win; struct s3c_fb *sfb; fbdev = get_fb_dev(); if (!fbdev) return; fb_info = get_fb_info(fbdev); if (!fb_info) return; /* * Release the reference we took at the beginning of the TUI session */ win = fb_info->par; sfb = win->parent; pr_info("%s call s3c_fb_activate_vsync\n", __func__); s3c_fb_activate_vsync(sfb); /* * Unblank the framebuffer */ console_lock(); fb_info->flags |= FBINFO_MISC_USEREVENT; fb_blank(fb_info, FB_BLANK_UNBLANK); fb_info->flags &= ~FBINFO_MISC_USEREVENT; console_unlock(); if (releaseref) pm_runtime_put_sync(sfb->dev); }
static int jpeg_remove(struct platform_device *pdev) { struct jpeg_dev *dev = platform_get_drvdata(pdev); del_timer_sync(&dev->watchdog_timer); flush_workqueue(dev->watchdog_workqueue); destroy_workqueue(dev->watchdog_workqueue); v4l2_m2m_release(dev->m2m_dev_enc); video_unregister_device(dev->vfd_enc); v4l2_m2m_release(dev->m2m_dev_dec); video_unregister_device(dev->vfd_dec); v4l2_device_unregister(&dev->v4l2_dev); dev->vb2->cleanup(dev->alloc_ctx); free_irq(dev->irq_no, pdev); mutex_destroy(&dev->lock); iounmap(dev->reg_base); clk_put(dev->clk); #ifdef CONFIG_PM_RUNTIME #if defined (CONFIG_CPU_EXYNOS5250) #ifdef CONFIG_BUSFREQ_OPP /* lock bus frequency */ dev_unlock(dev->bus_dev, &pdev->dev); #endif #else pm_runtime_put_sync(&pdev->dev); pm_runtime_disable(&pdev->dev); #endif #endif kfree(dev); return 0; }
void omap_mcbsp_free(unsigned int id) { struct omap_mcbsp *mcbsp; void *reg_cache; if (!omap_mcbsp_check_valid_id(id)) { printk(KERN_ERR "%s: Invalid id (%d)\n", __func__, id + 1); return; } mcbsp = id_to_mcbsp_ptr(id); if (mcbsp->pdata && mcbsp->pdata->ops && mcbsp->pdata->ops->free) mcbsp->pdata->ops->free(id); /* Disable wakeup behavior */ if (mcbsp->pdata->has_wakeup) MCBSP_WRITE(mcbsp, WAKEUPEN, 0); pm_runtime_put_sync(mcbsp->dev); if (mcbsp->rx_irq) free_irq(mcbsp->rx_irq, (void *)mcbsp); free_irq(mcbsp->tx_irq, (void *)mcbsp); reg_cache = mcbsp->reg_cache; spin_lock(&mcbsp->lock); if (mcbsp->free) dev_err(mcbsp->dev, "McBSP%d was not reserved\n", mcbsp->id); else mcbsp->free = true; mcbsp->reg_cache = NULL; spin_unlock(&mcbsp->lock); if (reg_cache) kfree(reg_cache); }
static int __exit omap_rtc_remove(struct platform_device *pdev) { struct omap_rtc *rtc = platform_get_drvdata(pdev); u8 reg; if (pm_power_off == omap_rtc_power_off && omap_rtc_power_off_rtc == rtc) { pm_power_off = NULL; omap_rtc_power_off_rtc = NULL; } device_init_wakeup(&pdev->dev, 0); if (!IS_ERR(rtc->clk)) clk_disable_unprepare(rtc->clk); rtc->type->unlock(rtc); /* leave rtc running, but disable irqs */ rtc_write(rtc, OMAP_RTC_INTERRUPTS_REG, 0); if (rtc->has_ext_clk) { reg = rtc_read(rtc, OMAP_RTC_OSC_REG); reg &= ~OMAP_RTC_OSC_SEL_32KCLK_SRC; rtc_write(rtc, OMAP_RTC_OSC_REG, reg); } rtc->type->lock(rtc); /* Disable the clock/module */ pm_runtime_put_sync(&pdev->dev); pm_runtime_disable(&pdev->dev); /* Remove ext_wakeup pinconf */ pinctrl_unregister(rtc->pctldev); return 0; }
static ssize_t hsic_remoteWakeup_store(struct device *dev, struct device_attribute *attr, const char *buf, size_t size) { int retval; int org_req; if (size > HSIC_ENABLE_SIZE) { dev_dbg(dev, "Invalid, size = %d\n", size); return -EINVAL; } if (sscanf(buf, "%d", &org_req) != 1) { dev_dbg(dev, "Invalid, value\n"); return -EINVAL; } mutex_lock(&hsic.hsic_mutex); hsic.remoteWakeup_enable = org_req; if ((hsic.modem_dev != NULL) && (hsic.rh_dev != NULL)) { if (hsic.remoteWakeup_enable) { dev_dbg(dev, "Modem dev remote wakeup enabled\n"); device_set_wakeup_capable(&hsic.modem_dev->dev, 1); device_set_wakeup_capable(&hsic.rh_dev->dev, 1); } else { dev_dbg(dev, "Modem dev remote wakeup disabled\n"); device_set_wakeup_capable(&hsic.modem_dev->dev, 0); device_set_wakeup_capable(&hsic.rh_dev->dev, 0); } pm_runtime_get_sync(&hsic.modem_dev->dev); pm_runtime_put_sync(&hsic.modem_dev->dev); } mutex_unlock(&hsic.hsic_mutex); return size; }
static void hdlcd_drm_unbind(struct device *dev) { struct drm_device *drm = dev_get_drvdata(dev); struct hdlcd_drm_private *hdlcd = drm->dev_private; drm_dev_unregister(drm); if (hdlcd->fbdev) { drm_fbdev_cma_fini(hdlcd->fbdev); hdlcd->fbdev = NULL; } drm_kms_helper_poll_fini(drm); component_unbind_all(dev, drm); of_node_put(hdlcd->crtc.port); hdlcd->crtc.port = NULL; pm_runtime_get_sync(drm->dev); drm_irq_uninstall(drm); pm_runtime_put_sync(drm->dev); pm_runtime_disable(drm->dev); of_reserved_mem_device_release(drm->dev); drm_mode_config_cleanup(drm); drm_dev_put(drm); drm->dev_private = NULL; dev_set_drvdata(dev, NULL); }
static int fimc_capture_open(struct file *file) { struct fimc_dev *fimc = video_drvdata(file); int ret = v4l2_fh_open(file); if (ret) return ret; dbg("pid: %d, state: 0x%lx", task_pid_nr(current), fimc->state); /* Return if the corresponding video mem2mem node is already opened. */ if (fimc_m2m_active(fimc)) return -EBUSY; set_bit(ST_CAPT_BUSY, &fimc->state); pm_runtime_get_sync(&fimc->pdev->dev); if (++fimc->vid_cap.refcnt == 1) { ret = fimc_pipeline_initialize(fimc, &fimc->vid_cap.vfd->entity, true); if (ret < 0) { dev_err(&fimc->pdev->dev, "Video pipeline initialization failed\n"); pm_runtime_put_sync(&fimc->pdev->dev); fimc->vid_cap.refcnt--; v4l2_fh_release(file); clear_bit(ST_CAPT_BUSY, &fimc->state); return ret; } ret = fimc_capture_ctrls_create(fimc); if (!ret && !fimc->vid_cap.user_subdev_api) ret = fimc_capture_set_default_format(fimc); } return ret; }
static void s5p_dp_disable(struct s5p_dp_device *dp) { struct s5p_dp_platdata *pdata = dp->dev->platform_data; mutex_lock(&dp->lock); if (!dp->enabled) goto out; dp->enabled = 0; //s5p_dp_reset(dp); //s5p_dp_set_pll_power_down(dp, 1); //s5p_dp_set_analog_power_down(dp, POWER_ALL, 1); if (pdata && pdata->phy_exit) pdata->phy_exit(); clk_disable(dp->clock); pm_runtime_put_sync(dp->dev); out: mutex_unlock(&dp->lock); }
static void s3c_fb_enable(struct s3c_fb *sfb, int enable) { u32 vidcon0 = readl(sfb->regs + VIDCON0); if (enable && !sfb->output_on) pm_runtime_get_sync(sfb->dev); if (enable) { vidcon0 |= VIDCON0_ENVID | VIDCON0_ENVID_F; } else { if (vidcon0 & VIDCON0_ENVID) { vidcon0 |= VIDCON0_ENVID; vidcon0 &= ~VIDCON0_ENVID_F; } } writel(vidcon0, sfb->regs + VIDCON0); if (!enable && sfb->output_on) pm_runtime_put_sync(sfb->dev); sfb->output_on = enable; }
void omap_mcbsp_free(unsigned int id) { struct omap_mcbsp *mcbsp; void *reg_cache; if (!omap_mcbsp_check_valid_id(id)) { printk(KERN_ERR "%s: Invalid id (%d)\n", __func__, id + 1); return; } mcbsp = id_to_mcbsp_ptr(id); if (mcbsp->pdata && mcbsp->pdata->ops && mcbsp->pdata->ops->free) mcbsp->pdata->ops->free(id); /* Do procedure specific to omap34xx arch, if applicable */ omap34xx_mcbsp_free(mcbsp); pm_runtime_put_sync(mcbsp->dev); if (mcbsp->rx_irq) free_irq(mcbsp->rx_irq, (void *)mcbsp); free_irq(mcbsp->tx_irq, (void *)mcbsp); reg_cache = mcbsp->reg_cache; spin_lock(&mcbsp->lock); if (mcbsp->free) dev_err(mcbsp->dev, "McBSP%d was not reserved\n", mcbsp->id); else mcbsp->free = true; mcbsp->reg_cache = NULL; spin_unlock(&mcbsp->lock); if (reg_cache) kfree(reg_cache); }
static int exynos_xhci_runtime_suspend(struct device *dev) { struct platform_device *pdev = to_platform_device(dev); struct exynos_xhci_hcd *exynos_xhci; struct usb_hcd *hcd; struct xhci_hcd *xhci; int retval = 0; dev_dbg(dev, "%s\n", __func__); exynos_xhci = dev_get_drvdata(dev); if (!exynos_xhci) return -EINVAL; hcd = exynos_xhci->hcd; if (!hcd) return -EINVAL; xhci = hcd_to_xhci(hcd); if (hcd->state != HC_STATE_SUSPENDED || xhci->shared_hcd->state != HC_STATE_SUSPENDED) { dev_dbg(dev, "%s: HC state is not suspended!\n", __func__); return -EAGAIN; } retval = xhci_suspend(xhci, 0); if (retval < 0) dev_err(dev, "%s: cannot stop xHC\n", __func__); pm_runtime_put_sync(exynos_xhci->dev->parent); exynos_drd_put(pdev); return retval; }
int abe_mixer_enable_mono(struct omap_abe *abe, int id, int enable) { int mixer; switch (id) { case MIX_DL1_MONO: mixer = MIXDL1; break; case MIX_DL2_MONO: mixer = MIXDL2; break; case MIX_AUDUL_MONO: mixer = MIXAUDUL; break; default: return -EINVAL; } abe_dsp_pm_get(abe); omap_aess_mono_mixer(abe->aess, mixer, enable); pm_runtime_put_sync(abe->dev); return 0; }
static int p3_disable_clk(struct p3_dev *p3_device) { int ret_val = 0; //unsigned short clock = 0; struct spi_device *spidev = NULL; struct s3c64xx_spi_driver_data *sdd = NULL; if (!p3_device->enabled_clk) { P3_ERR_MSG("%s - clock was not enabled!\n", __func__); return ret_val; } spin_lock_irq(&p3_device->ese_spi_lock); spidev = spi_dev_get(p3_device->spi); spin_unlock_irq(&p3_device->ese_spi_lock); if (spidev == NULL) { P3_ERR_MSG("%s - Failed to get spi dev!\n", __func__); return -1; } sdd = spi_master_get_devdata(spidev->master); if (!sdd){ P3_ERR_MSG("%s - Failed to get spi dev.\n", __func__); return -EFAULT; } p3_device->enabled_clk = false; pm_runtime_put_sync(&sdd->pdev->dev); /* Disable clock */ spi_dev_put(spidev); #ifdef FEATURE_ESE_WAKELOCK if (wake_lock_active(&p3_device->ese_lock)) wake_unlock(&p3_device->ese_lock); #endif return ret_val; }
static void decon_disable(struct exynos_drm_crtc *crtc) { struct decon_context *ctx = crtc->ctx; int i; if (test_bit(BIT_SUSPENDED, &ctx->flags)) return; /* * We need to make sure that all windows are disabled before we * suspend that connector. Otherwise we might try to scan from * a destroyed buffer later. */ for (i = ctx->first_win; i < WINDOWS_NR; i++) decon_disable_plane(crtc, &ctx->planes[i]); decon_swreset(ctx); clear_bit(BIT_CLKS_ENABLED, &ctx->flags); pm_runtime_put_sync(ctx->dev); set_bit(BIT_SUSPENDED, &ctx->flags); }
struct msm_gpu *adreno_load_gpu(struct drm_device *dev) { struct msm_drm_private *priv = dev->dev_private; struct platform_device *pdev = priv->gpu_pdev; struct msm_gpu *gpu = platform_get_drvdata(priv->gpu_pdev); int ret; if (!gpu) { dev_err(dev->dev, "no adreno device\n"); return NULL; } pm_runtime_get_sync(&pdev->dev); mutex_lock(&dev->struct_mutex); ret = msm_gpu_hw_init(gpu); mutex_unlock(&dev->struct_mutex); pm_runtime_put_sync(&pdev->dev); if (ret) { dev_err(dev->dev, "gpu hw init failed: %d\n", ret); return NULL; } return gpu; }
int abe_mixer_set_equ_profile(struct omap_abe *abe, unsigned int id, unsigned int profile) { struct omap_aess_equ equ_params; int len; if (id >= abe->hdr.num_equ) return -EINVAL; if (profile >= abe->equ.texts[id].count) return -EINVAL; len = abe->equ.texts[id].coeff; equ_params.equ_length = len; memcpy(equ_params.coef.type1, abe->equ.equ[id] + profile * len, len * sizeof(u32)); abe->equ.profile[id] = profile; abe_dsp_pm_get(abe); omap_aess_write_equalizer(abe->aess, id + 1, (struct omap_aess_equ *)&equ_params); pm_runtime_put_sync(abe->dev); return 0; }
static void omap_usbhs_init(struct device *dev) { struct usbhs_hcd_omap *omap = dev_get_drvdata(dev); unsigned reg; dev_dbg(dev, "starting TI HSUSB Controller\n"); pm_runtime_get_sync(dev); reg = usbhs_read(omap->uhh_base, OMAP_UHH_HOSTCONFIG); /* setup ULPI bypass and burst configurations */ reg |= (OMAP_UHH_HOSTCONFIG_INCR4_BURST_EN | OMAP_UHH_HOSTCONFIG_INCR8_BURST_EN | OMAP_UHH_HOSTCONFIG_INCR16_BURST_EN); reg |= OMAP4_UHH_HOSTCONFIG_APP_START_CLK; reg &= ~OMAP_UHH_HOSTCONFIG_INCRX_ALIGN_EN; switch (omap->usbhs_rev) { case OMAP_USBHS_REV1: reg = omap_usbhs_rev1_hostconfig(omap, reg); break; case OMAP_USBHS_REV2: reg = omap_usbhs_rev2_hostconfig(omap, reg); break; default: /* newer revisions */ reg = omap_usbhs_rev2_hostconfig(omap, reg); break; } usbhs_write(omap->uhh_base, OMAP_UHH_HOSTCONFIG, reg); dev_dbg(dev, "UHH setup done, uhh_hostconfig=%x\n", reg); pm_runtime_put_sync(dev); }
int smies_disable_by_fimd(struct device *dev) { struct platform_device *pdev = to_platform_device(dev); struct s5p_smies_device *smies = platform_get_drvdata(pdev); dev_dbg(dev, "%s +\n", __func__); mutex_lock(&smies->mutex); if(smies->state == SMIES_ENABLED) { smies_set_update_reg_mask(smies, SMIES_MASK_ON); smies_run(smies, 0); smies_set_update_reg_mask(smies, SMIES_MASK_OFF); smies_set_path(smies, 0); smies->state = SMIES_DISABLED; pm_runtime_put_sync(smies->dev); } mutex_unlock(&smies->mutex); dev_dbg(dev, "%s -\n", __func__); return 0; }
int omap2_mcbsp_set_clks_src(struct omap_mcbsp *mcbsp, u8 fck_src_id) { struct clk *fck_src; const char *src; int r; if (fck_src_id == MCBSP_CLKS_PAD_SRC) src = "pad_fck"; else if (fck_src_id == MCBSP_CLKS_PRCM_SRC) src = "prcm_fck"; else return -EINVAL; fck_src = clk_get(mcbsp->dev, src); if (IS_ERR(fck_src)) { dev_err(mcbsp->dev, "CLKS: could not clk_get() %s\n", src); return -EINVAL; } pm_runtime_put_sync(mcbsp->dev); r = clk_set_parent(mcbsp->fclk, fck_src); if (r) { dev_err(mcbsp->dev, "CLKS: could not clk_set_parent() to %s\n", src); clk_put(fck_src); return r; } pm_runtime_get_sync(mcbsp->dev); clk_put(fck_src); return 0; }
static void msm_shutdown(struct uart_port *port) { struct msm_port *msm_port = UART_TO_MSM(port); clk_enable(msm_port->clk); msm_port->imr = 0; msm_write(port, 0, UART_IMR); /* disable interrupts */ clk_disable(msm_port->clk); free_irq(port->irq, port); #ifdef CONFIG_SERIAL_MSM_RX_WAKEUP if (use_low_power_wakeup(msm_port)) { set_irq_wake(msm_port->wakeup.irq, 0); free_irq(msm_port->wakeup.irq, msm_port); } #endif #ifndef CONFIG_PM_RUNTIME msm_deinit_clock(port); #endif pm_runtime_put_sync(port->dev); }
static void msm_otg_sm_work(struct work_struct *w) { struct msm_otg *motg = container_of(w, struct msm_otg, sm_work); struct usb_otg *otg = motg->phy.otg; switch (otg->state) { case OTG_STATE_UNDEFINED: dev_dbg(otg->usb_phy->dev, "OTG_STATE_UNDEFINED state\n"); msm_otg_reset(otg->usb_phy); msm_otg_init_sm(motg); otg->state = OTG_STATE_B_IDLE; /* FALL THROUGH */ case OTG_STATE_B_IDLE: dev_dbg(otg->usb_phy->dev, "OTG_STATE_B_IDLE state\n"); if (!test_bit(ID, &motg->inputs) && otg->host) { /* disable BSV bit */ writel(readl(USB_OTGSC) & ~OTGSC_BSVIE, USB_OTGSC); msm_otg_start_host(otg->usb_phy, 1); otg->state = OTG_STATE_A_HOST; } else if (test_bit(B_SESS_VLD, &motg->inputs)) { switch (motg->chg_state) { case USB_CHG_STATE_UNDEFINED: msm_chg_detect_work(&motg->chg_work.work); break; case USB_CHG_STATE_DETECTED: switch (motg->chg_type) { case USB_DCP_CHARGER: msm_otg_notify_charger(motg, IDEV_CHG_MAX); break; case USB_CDP_CHARGER: msm_otg_notify_charger(motg, IDEV_CHG_MAX); msm_otg_start_peripheral(otg->usb_phy, 1); otg->state = OTG_STATE_B_PERIPHERAL; break; case USB_SDP_CHARGER: msm_otg_notify_charger(motg, IUNIT); msm_otg_start_peripheral(otg->usb_phy, 1); otg->state = OTG_STATE_B_PERIPHERAL; break; default: break; } break; default: break; } } else { /* * If charger detection work is pending, decrement * the pm usage counter to balance with the one that * is incremented in charger detection work. */ if (cancel_delayed_work_sync(&motg->chg_work)) { pm_runtime_put_sync(otg->usb_phy->dev); msm_otg_reset(otg->usb_phy); } msm_otg_notify_charger(motg, 0); motg->chg_state = USB_CHG_STATE_UNDEFINED; motg->chg_type = USB_INVALID_CHARGER; } if (otg->state == OTG_STATE_B_IDLE) pm_runtime_put_sync(otg->usb_phy->dev); break; case OTG_STATE_B_PERIPHERAL: dev_dbg(otg->usb_phy->dev, "OTG_STATE_B_PERIPHERAL state\n"); if (!test_bit(B_SESS_VLD, &motg->inputs) || !test_bit(ID, &motg->inputs)) { msm_otg_notify_charger(motg, 0); msm_otg_start_peripheral(otg->usb_phy, 0); motg->chg_state = USB_CHG_STATE_UNDEFINED; motg->chg_type = USB_INVALID_CHARGER; otg->state = OTG_STATE_B_IDLE; msm_otg_reset(otg->usb_phy); schedule_work(w); } break; case OTG_STATE_A_HOST: dev_dbg(otg->usb_phy->dev, "OTG_STATE_A_HOST state\n"); if (test_bit(ID, &motg->inputs)) { msm_otg_start_host(otg->usb_phy, 0); otg->state = OTG_STATE_B_IDLE; msm_otg_reset(otg->usb_phy); schedule_work(w); } break; default: break; } }
static int ecap_probe(struct platform_device *pdev) { struct ecap_pwm *ep = NULL; struct resource *r; int ret = 0; int val; char con_id[PWM_CON_ID_STRING_LENGTH] = "epwmss"; struct pwmss_platform_data *pdata = (&pdev->dev)->platform_data; ep = kzalloc(sizeof(*ep), GFP_KERNEL); if (!ep) { dev_err(&pdev->dev, "failed to allocate memory\n"); return -ENOMEM; } ep->version = pdata->version; if (ep->version == PWM_VERSION_1) { sprintf(con_id, "%s%d_%s", con_id, pdev->id, "fck"); ep->clk = clk_get(&pdev->dev, con_id); } else ep->clk = clk_get(&pdev->dev, "ecap"); pm_runtime_irq_safe(&pdev->dev); pm_runtime_enable(&pdev->dev); ep->dev = &pdev->dev; if (IS_ERR(ep->clk)) { ret = PTR_ERR(ep->clk); goto err_clk_get; } if (ep->version == PWM_VERSION_1) { r = platform_get_resource(pdev, IORESOURCE_MEM, 0); if (!r) { dev_err(&pdev->dev, "no memory resource defined\n"); ret = -ENOMEM; goto err_get_resource; } ep->config_mem_base = ioremap(r->start, resource_size(r)); if (!ep->config_mem_base) { dev_err(&pdev->dev, "failed to ioremap() registers\n"); ret = -ENOMEM; goto err_get_resource; } pm_runtime_get_sync(ep->dev); val = readw(ep->config_mem_base + PWMSS_CLKCONFIG); val |= BIT(ECAP_CLK_EN); writew(val, ep->config_mem_base + PWMSS_CLKCONFIG); pm_runtime_put_sync(ep->dev); } spin_lock_init(&ep->lock); ep->ops.config = ecap_pwm_config; ep->ops.request = ecap_pwm_request; ep->ops.freq_transition_notifier_cb = ecap_frequency_transition_cb; if (ep->version == PWM_VERSION_1) r = platform_get_resource(pdev, IORESOURCE_MEM, 1); else r = platform_get_resource(pdev, IORESOURCE_MEM, 0); if (!r) { dev_err(&pdev->dev, "no memory resource defined\n"); ret = -ENODEV; goto err_request_mem; } r = request_mem_region(r->start, resource_size(r), pdev->name); if (!r) { dev_err(&pdev->dev, "failed to request memory resource\n"); ret = -EBUSY; goto err_request_mem; } ep->mmio_base = ioremap(r->start, resource_size(r)); if (!ep->mmio_base) { dev_err(&pdev->dev, "failed to ioremap() registers\n"); ret = -ENODEV; goto err_ioremap; } ep->pwm.ops = &ep->ops; pwm_set_drvdata(&ep->pwm, ep); ret = pwm_register(&ep->pwm, &pdev->dev, -1); platform_set_drvdata(pdev, ep); /* Inverse the polarity of PWM wave */ if (pdata->chan_attrib[0].inverse_pol) { ep->pwm.active_high = 1; ecap_pwm_set_polarity(&ep->pwm, 1); } return 0; err_ioremap: release_mem_region(r->start, resource_size(r)); err_request_mem: if (ep->version == PWM_VERSION_1) { iounmap(ep->config_mem_base); ep->config_mem_base = NULL; } err_get_resource: clk_put(ep->clk); pm_runtime_disable(&pdev->dev); err_clk_get: kfree(ep); return ret; }
static int mdp4_hw_init(struct msm_kms *kms) { struct mdp4_kms *mdp4_kms = to_mdp4_kms(to_mdp_kms(kms)); struct drm_device *dev = mdp4_kms->dev; uint32_t version, major, minor, dmap_cfg, vg_cfg; unsigned long clk; int ret = 0; pm_runtime_get_sync(dev->dev); mdp4_enable(mdp4_kms); version = mdp4_read(mdp4_kms, REG_MDP4_VERSION); mdp4_disable(mdp4_kms); major = FIELD(version, MDP4_VERSION_MAJOR); minor = FIELD(version, MDP4_VERSION_MINOR); DBG("found MDP4 version v%d.%d", major, minor); if (major != 4) { dev_err(dev->dev, "unexpected MDP version: v%d.%d\n", major, minor); ret = -ENXIO; goto out; } mdp4_kms->rev = minor; if (mdp4_kms->rev > 1) { mdp4_write(mdp4_kms, REG_MDP4_CS_CONTROLLER0, 0x0707ffff); mdp4_write(mdp4_kms, REG_MDP4_CS_CONTROLLER1, 0x03073f3f); } mdp4_write(mdp4_kms, REG_MDP4_PORTMAP_MODE, 0x3); /* max read pending cmd config, 3 pending requests: */ mdp4_write(mdp4_kms, REG_MDP4_READ_CNFG, 0x02222); clk = clk_get_rate(mdp4_kms->clk); if ((mdp4_kms->rev >= 1) || (clk >= 90000000)) { dmap_cfg = 0x47; /* 16 bytes-burst x 8 req */ vg_cfg = 0x47; /* 16 bytes-burs x 8 req */ } else { dmap_cfg = 0x27; /* 8 bytes-burst x 8 req */ vg_cfg = 0x43; /* 16 bytes-burst x 4 req */ } DBG("fetch config: dmap=%02x, vg=%02x", dmap_cfg, vg_cfg); mdp4_write(mdp4_kms, REG_MDP4_DMA_FETCH_CONFIG(DMA_P), dmap_cfg); mdp4_write(mdp4_kms, REG_MDP4_DMA_FETCH_CONFIG(DMA_E), dmap_cfg); mdp4_write(mdp4_kms, REG_MDP4_PIPE_FETCH_CONFIG(VG1), vg_cfg); mdp4_write(mdp4_kms, REG_MDP4_PIPE_FETCH_CONFIG(VG2), vg_cfg); mdp4_write(mdp4_kms, REG_MDP4_PIPE_FETCH_CONFIG(RGB1), vg_cfg); mdp4_write(mdp4_kms, REG_MDP4_PIPE_FETCH_CONFIG(RGB2), vg_cfg); if (mdp4_kms->rev >= 2) mdp4_write(mdp4_kms, REG_MDP4_LAYERMIXER_IN_CFG_UPDATE_METHOD, 1); mdp4_write(mdp4_kms, REG_MDP4_LAYERMIXER_IN_CFG, 0); /* disable CSC matrix / YUV by default: */ mdp4_write(mdp4_kms, REG_MDP4_PIPE_OP_MODE(VG1), 0); mdp4_write(mdp4_kms, REG_MDP4_PIPE_OP_MODE(VG2), 0); mdp4_write(mdp4_kms, REG_MDP4_DMA_P_OP_MODE, 0); mdp4_write(mdp4_kms, REG_MDP4_DMA_S_OP_MODE, 0); mdp4_write(mdp4_kms, REG_MDP4_OVLP_CSC_CONFIG(1), 0); mdp4_write(mdp4_kms, REG_MDP4_OVLP_CSC_CONFIG(2), 0); if (mdp4_kms->rev > 1) mdp4_write(mdp4_kms, REG_MDP4_RESET_STATUS, 1); dev->mode_config.allow_fb_modifiers = true; out: pm_runtime_put_sync(dev->dev); return ret; }
/** * ehci_hcd_omap_probe - initialize TI-based HCDs * * Allocates basic resources for this USB host controller, and * then invokes the start() method for the HCD associated with it * through the hotplug entry's driver_data. */ static int ehci_hcd_omap_probe(struct platform_device *pdev) { struct device *dev = &pdev->dev; struct usbhs_omap_platform_data *pdata = dev->platform_data; struct resource *res; struct usb_hcd *hcd; void __iomem *regs; int ret = -ENODEV; int irq; int i; char supply[7]; if (usb_disabled()) return -ENODEV; if (!dev->parent) { dev_err(dev, "Missing parent device\n"); return -ENODEV; } irq = platform_get_irq_byname(pdev, "ehci-irq"); if (irq < 0) { dev_err(dev, "EHCI irq failed\n"); return -ENODEV; } res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "ehci"); if (!res) { dev_err(dev, "UHH EHCI get resource failed\n"); return -ENODEV; } regs = ioremap(res->start, resource_size(res)); if (!regs) { dev_err(dev, "UHH EHCI ioremap failed\n"); return -ENOMEM; } hcd = usb_create_hcd(&ehci_omap_hc_driver, dev, dev_name(dev)); if (!hcd) { dev_err(dev, "failed to create hcd with err %d\n", ret); ret = -ENOMEM; goto err_io; } hcd->rsrc_start = res->start; hcd->rsrc_len = resource_size(res); hcd->regs = regs; /* get ehci regulator and enable */ for (i = 0 ; i < OMAP3_HS_USB_PORTS ; i++) { if (pdata->port_mode[i] != OMAP_EHCI_PORT_MODE_PHY) { pdata->regulator[i] = NULL; continue; } snprintf(supply, sizeof(supply), "hsusb%d", i); pdata->regulator[i] = regulator_get(dev, supply); if (IS_ERR(pdata->regulator[i])) { pdata->regulator[i] = NULL; dev_dbg(dev, "failed to get ehci port%d regulator\n", i); } else { regulator_enable(pdata->regulator[i]); } } /* Hold PHYs in reset while initializing EHCI controller */ if (pdata->phy_reset) { if (gpio_is_valid(pdata->reset_gpio_port[0])) gpio_set_value_cansleep(pdata->reset_gpio_port[0], 0); if (gpio_is_valid(pdata->reset_gpio_port[1])) gpio_set_value_cansleep(pdata->reset_gpio_port[1], 0); /* Hold the PHY in RESET for enough time till DIR is high */ udelay(10); } pm_runtime_enable(dev); pm_runtime_get_sync(dev); /* * An undocumented "feature" in the OMAP3 EHCI controller, * causes suspended ports to be taken out of suspend when * the USBCMD.Run/Stop bit is cleared (for example when * we do ehci_bus_suspend). * This breaks suspend-resume if the root-hub is allowed * to suspend. Writing 1 to this undocumented register bit * disables this feature and restores normal behavior. */ ehci_write(regs, EHCI_INSNREG04, EHCI_INSNREG04_DISABLE_UNSUSPEND); ret = usb_add_hcd(hcd, irq, IRQF_SHARED); if (ret) { dev_err(dev, "failed to add hcd with err %d\n", ret); goto err_pm_runtime; } if (pdata->phy_reset) { /* Hold the PHY in RESET for enough time till * PHY is settled and ready */ udelay(10); if (gpio_is_valid(pdata->reset_gpio_port[0])) gpio_set_value_cansleep(pdata->reset_gpio_port[0], 1); if (gpio_is_valid(pdata->reset_gpio_port[1])) gpio_set_value_cansleep(pdata->reset_gpio_port[1], 1); } return 0; err_pm_runtime: disable_put_regulator(pdata); pm_runtime_put_sync(dev); usb_put_hcd(hcd); err_io: iounmap(regs); return ret; }
static ssize_t show_registers(struct device *dev, struct device_attribute *attr, char *buf) { struct usb_hcd *hcd = dev_get_drvdata(dev); struct xhci_hcd *xhci = hcd_to_xhci(hcd); char *next; unsigned size; unsigned t; next = buf; size = PAGE_SIZE; pm_runtime_get_sync(dev); usleep_range(1000, 1100); t = scnprintf(next, size, "\n" "USBCMD = 0x%08x\n" "USBSTS = 0x%08x\n" "PORTSC1 = 0x%08x\n" "PORTSC2 = 0x%08x\n" "PORTSC3 = 0x%08x\n" "PORTSC4 = 0x%08x\n" "PORTSC5 = 0x%08x\n" "PORTSC6 = 0x%08x\n" "PORTPMSC1 = 0x%08x\n" "PORTPMSC2 = 0x%08x\n" "PORTPMSC3 = 0x%08x\n" "PORTPMSC4 = 0x%08x\n" "PORTPMSC5 = 0x%08x\n" "PORTPMSC6 = 0x%08x\n" "PORTLI1 = 0x%08x\n" "PORTLI2 = 0x%08x\n" "PORTLI3 = 0x%08x\n" "PORTLI4 = 0x%08x\n" "PORTLI5 = 0x%08x\n" "PORTLI6 = 0x%08x\n", xhci_readl(xhci, &xhci->op_regs->command), xhci_readl(xhci, &xhci->op_regs->status), xhci_readl(xhci, &xhci->op_regs->port_status_base), xhci_readl(xhci, &xhci->op_regs->port_status_base + 4), xhci_readl(xhci, &xhci->op_regs->port_status_base + 8), xhci_readl(xhci, &xhci->op_regs->port_status_base + 12), xhci_readl(xhci, &xhci->op_regs->port_status_base + 16), xhci_readl(xhci, &xhci->op_regs->port_status_base + 20), xhci_readl(xhci, &xhci->op_regs->port_power_base), xhci_readl(xhci, &xhci->op_regs->port_power_base + 4), xhci_readl(xhci, &xhci->op_regs->port_power_base + 8), xhci_readl(xhci, &xhci->op_regs->port_power_base + 12), xhci_readl(xhci, &xhci->op_regs->port_power_base + 16), xhci_readl(xhci, &xhci->op_regs->port_power_base), xhci_readl(xhci, &xhci->op_regs->port_link_base + 4), xhci_readl(xhci, &xhci->op_regs->port_link_base + 8), xhci_readl(xhci, &xhci->op_regs->port_link_base + 12), xhci_readl(xhci, &xhci->op_regs->port_link_base + 16), xhci_readl(xhci, &xhci->op_regs->port_link_base + 20) ); pm_runtime_put_sync(dev); usleep_range(1000, 1100); size -= t; next += t; return PAGE_SIZE - size; }
static inline void c_can_pm_runtime_put_sync(const struct c_can_priv *priv) { if (priv->device) pm_runtime_put_sync(priv->device); }
/** * ohci_hcd_omap3_probe - initialize OMAP-based HCDs * * Allocates basic resources for this USB host controller, and * then invokes the start() method for the HCD associated with it * through the hotplug entry's driver_data. */ static int __devinit ohci_hcd_omap3_probe(struct platform_device *pdev) { struct device *dev = &pdev->dev; struct usb_hcd *hcd = NULL; void __iomem *regs = NULL; struct resource *res; int ret = -ENODEV; int irq; if (usb_disabled()) return -ENODEV; if (!dev->parent) { dev_err(dev, "Missing parent device\n"); return -ENODEV; } irq = platform_get_irq_byname(pdev, "ohci"); if (irq < 0) { dev_err(dev, "OHCI irq failed\n"); return -ENODEV; } res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "ohci"); if (!res) { dev_err(dev, "UHH OHCI get resource failed\n"); return -ENOMEM; } regs = ioremap(res->start, resource_size(res)); if (!regs) { dev_err(dev, "UHH OHCI ioremap failed\n"); return -ENOMEM; } hcd = usb_create_hcd(&ohci_omap3_hc_driver, dev, dev_name(dev)); if (!hcd) { dev_err(dev, "usb_create_hcd failed\n"); goto err_io; } hcd->rsrc_start = res->start; hcd->rsrc_len = resource_size(res); hcd->regs = regs; pm_runtime_enable(dev); pm_runtime_get_sync(dev); ohci_hcd_init(hcd_to_ohci(hcd)); ret = usb_add_hcd(hcd, irq, 0); if (ret) { dev_dbg(dev, "failed to add hcd with err %d\n", ret); goto err_add_hcd; } return 0; err_add_hcd: pm_runtime_put_sync(dev); usb_put_hcd(hcd); err_io: iounmap(regs); return ret; }
static int omap_wdt_probe(struct platform_device *pdev) { struct omap_wd_timer_platform_data *pdata = dev_get_platdata(&pdev->dev); struct watchdog_device *omap_wdt; struct resource *res; struct omap_wdt_dev *wdev; u32 rs; int ret; omap_wdt = devm_kzalloc(&pdev->dev, sizeof(*omap_wdt), GFP_KERNEL); if (!omap_wdt) return -ENOMEM; wdev = devm_kzalloc(&pdev->dev, sizeof(*wdev), GFP_KERNEL); if (!wdev) return -ENOMEM; wdev->omap_wdt_users = false; wdev->dev = &pdev->dev; wdev->wdt_trgr_pattern = 0x1234; mutex_init(&wdev->lock); /* reserve static register mappings */ res = platform_get_resource(pdev, IORESOURCE_MEM, 0); wdev->base = devm_ioremap_resource(&pdev->dev, res); if (IS_ERR(wdev->base)) return PTR_ERR(wdev->base); omap_wdt->info = &omap_wdt_info; omap_wdt->ops = &omap_wdt_ops; omap_wdt->min_timeout = TIMER_MARGIN_MIN; omap_wdt->max_timeout = TIMER_MARGIN_MAX; if (timer_margin >= TIMER_MARGIN_MIN && timer_margin <= TIMER_MARGIN_MAX) omap_wdt->timeout = timer_margin; else omap_wdt->timeout = TIMER_MARGIN_DEFAULT; watchdog_set_drvdata(omap_wdt, wdev); watchdog_set_nowayout(omap_wdt, nowayout); platform_set_drvdata(pdev, omap_wdt); pm_runtime_enable(wdev->dev); pm_runtime_get_sync(wdev->dev); if (pdata && pdata->read_reset_sources) rs = pdata->read_reset_sources(); else rs = 0; omap_wdt->bootstatus = (rs & (1 << OMAP_MPU_WD_RST_SRC_ID_SHIFT)) ? WDIOF_CARDRESET : 0; omap_wdt_disable(wdev); ret = watchdog_register_device(omap_wdt); if (ret) { pm_runtime_disable(wdev->dev); return ret; } pr_info("OMAP Watchdog Timer Rev 0x%02x: initial timeout %d sec\n", readl_relaxed(wdev->base + OMAP_WATCHDOG_REV) & 0xFF, omap_wdt->timeout); pm_runtime_put_sync(wdev->dev); return 0; }
static int atmel_hlcdc_dc_load(struct drm_device *dev) { struct platform_device *pdev = to_platform_device(dev->dev); const struct of_device_id *match; struct atmel_hlcdc_dc *dc; int ret; match = of_match_node(atmel_hlcdc_of_match, dev->dev->parent->of_node); if (!match) { dev_err(&pdev->dev, "invalid compatible string\n"); return -ENODEV; } if (!match->data) { dev_err(&pdev->dev, "invalid hlcdc description\n"); return -EINVAL; } dc = devm_kzalloc(dev->dev, sizeof(*dc), GFP_KERNEL); if (!dc) return -ENOMEM; dc->wq = alloc_ordered_workqueue("atmel-hlcdc-dc", 0); if (!dc->wq) return -ENOMEM; init_waitqueue_head(&dc->commit.wait); dc->desc = match->data; dc->hlcdc = dev_get_drvdata(dev->dev->parent); dev->dev_private = dc; ret = clk_prepare_enable(dc->hlcdc->periph_clk); if (ret) { dev_err(dev->dev, "failed to enable periph_clk\n"); goto err_destroy_wq; } pm_runtime_enable(dev->dev); ret = drm_vblank_init(dev, 1); if (ret < 0) { dev_err(dev->dev, "failed to initialize vblank\n"); goto err_periph_clk_disable; } ret = atmel_hlcdc_dc_modeset_init(dev); if (ret < 0) { dev_err(dev->dev, "failed to initialize mode setting\n"); goto err_periph_clk_disable; } drm_mode_config_reset(dev); pm_runtime_get_sync(dev->dev); ret = drm_irq_install(dev, dc->hlcdc->irq); pm_runtime_put_sync(dev->dev); if (ret < 0) { dev_err(dev->dev, "failed to install IRQ handler\n"); goto err_periph_clk_disable; } platform_set_drvdata(pdev, dev); drm_kms_helper_poll_init(dev); /* force connectors detection */ drm_helper_hpd_irq_event(dev); return 0; err_periph_clk_disable: pm_runtime_disable(dev->dev); clk_disable_unprepare(dc->hlcdc->periph_clk); err_destroy_wq: destroy_workqueue(dc->wq); return ret; }