static int __devexit ehci_msm2_remove(struct platform_device *pdev) { struct usb_hcd *hcd = platform_get_drvdata(pdev); struct msm_hcd *mhcd = hcd_to_mhcd(hcd); device_init_wakeup(&pdev->dev, 0); pm_runtime_disable(&pdev->dev); pm_runtime_set_suspended(&pdev->dev); usb_remove_hcd(hcd); msm_xo_put(mhcd->xo_handle); msm_ehci_vbus_power(mhcd, 0); msm_ehci_init_vbus(mhcd, 0); msm_ehci_ldo_enable(mhcd, 0); msm_ehci_ldo_init(mhcd, 0); msm_ehci_init_vddcx(mhcd, 0); msm_ehci_init_clocks(mhcd, 0); wake_lock_destroy(&mhcd->wlock); iounmap(hcd->regs); usb_put_hcd(hcd); return 0; }
static int pn547_remove(struct i2c_client *client) { struct pn547_dev *pn547_dev; pn547_dev = i2c_get_clientdata(client); #ifdef CONFIG_NFC_PN547_8226_USE_BBCLK2 if(pn547_dev->nfc_clock) clk_unprepare(pn547_dev->nfc_clock); #endif #ifdef CONFIG_NFC_PN547_PMC8974_CLK_REQ if (pn547_dev->nfc_clk) clk_unprepare(pn547_dev->nfc_clk); #endif wake_lock_destroy(&pn547_dev->nfc_wake_lock); free_irq(client->irq, pn547_dev); misc_deregister(&pn547_dev->pn547_device); mutex_destroy(&pn547_dev->read_mutex); gpio_free(pn547_dev->irq_gpio); gpio_free(pn547_dev->ven_gpio); gpio_free(pn547_dev->firm_gpio); #ifdef CONFIG_NFC_PN547_8226_USE_BBCLK2 gpio_free(pn547_dev->clk_req_gpio); #endif #ifdef CONFIG_NFC_PN547_CLOCK_REQUEST gpio_free(pn547_dev->clk_req_gpio); msm_xo_put(pn547_dev->nfc_clock); #endif kfree(pn547_dev); return 0; }
static int __devexit ehci_msm2_remove(struct platform_device *pdev) { struct usb_hcd *hcd = platform_get_drvdata(pdev); struct msm_hcd *mhcd = hcd_to_mhcd(hcd); if (mhcd->pmic_gpio_dp_irq) { if (mhcd->pmic_gpio_dp_irq_enabled) disable_irq_wake(mhcd->pmic_gpio_dp_irq); free_irq(mhcd->pmic_gpio_dp_irq, mhcd); } device_init_wakeup(&pdev->dev, 0); pm_runtime_disable(&pdev->dev); pm_runtime_set_suspended(&pdev->dev); usb_remove_hcd(hcd); msm_xo_put(mhcd->xo_handle); msm_ehci_vbus_power(mhcd, 0); msm_ehci_init_vbus(mhcd, 0); msm_ehci_ldo_enable(mhcd, 0); msm_ehci_ldo_init(mhcd, 0); msm_ehci_init_vddcx(mhcd, 0); msm_ehci_init_clocks(mhcd, 0); wake_lock_destroy(&mhcd->wlock); //ASUS_BSP+++ BennyCheng "implement ehci3 phy power collapse mode" mutex_destroy(&mhcd->ehci_mutex); //ASUS_BSP--- BennyCheng "implement ehci3 phy power collapse mode" iounmap(hcd->regs); usb_put_hcd(hcd); return 0; }
int tcc353x_power_on(void) { if(IsdbCtrlInfo.pwr_state != 1) { int rc; #ifndef _NOT_USE_WAKE_LOCK_ wake_lock(&IsdbCtrlInfo.wake_lock); #endif TchalPowerOnDevice(); rc = msm_xo_mode_vote(xo_handle_tcc, MSM_XO_MODE_ON); if(rc < 0) { pr_err("Configuring MSM_XO_MODE_ON failed (%d)\n", rc); msm_xo_put(xo_handle_tcc); return FALSE; } } else { TcpalPrintStatus((I08S *)"aready on!! \n"); } IsdbCtrlInfo.pwr_state = 1; return OK; }
/** * qcomwlan_pmic_xo_core_force_enable() - Force XO Core of PMIC to be ALWAYS ON * @on - Force XO Core ON/OFF (1 or 0) * * The XO_CORE controls the XO feeding the TCXO buffers (A0, A1, etc.). WLAN * wants to keep the XO core on even though our buffer A0 is in pin control * because it can take a long time turn the XO back on and warm up the buffers. * This helps in optimizing power in BMPS (power save) mode of WLAN. * The WLAN driver wrapper function takes care that this API is not called * consecutively. * * This function returns 0 on success or a non-zero value on failure. */ int qcomwlan_pmic_xo_core_force_enable(int on) { static struct msm_xo_voter *wlan_ps; int rc = 0; if (wlan_ps == NULL) { wlan_ps = msm_xo_get(MSM_XO_CORE, id); if (IS_ERR(wlan_ps)) { pr_err("Failed to get XO CORE voter (%ld)\n", PTR_ERR(wlan_ps)); goto fail; } } if (on) rc = msm_xo_mode_vote(wlan_ps, MSM_XO_MODE_ON); else rc = msm_xo_mode_vote(wlan_ps, MSM_XO_MODE_OFF); if (rc < 0) { pr_err("XO Core %s failed (%d)\n", on ? "enable" : "disable", rc); goto fail_xo_mode_vote; } return 0; fail_xo_mode_vote: msm_xo_put(wlan_ps); fail: return rc; }
static int msm_hsic_hub_init_clock(struct hsic_hub *hub, int init) { int ret; if (hub->pdata->xo_clk_gpio) return 0; if (!init) { if (!IS_ERR(hub->ref_clk)) clk_disable_unprepare(hub->ref_clk); else msm_xo_put(smsc_hub->xo_handle); return 0; } hub->ref_clk = devm_clk_get(hub->dev, "ref_clk"); if (IS_ERR(hub->ref_clk)) { dev_dbg(hub->dev, "failed to get ref_clk\n"); smsc_hub->xo_handle = msm_xo_get(MSM_XO_TCXO_D1, "hsic_hub"); if (IS_ERR(smsc_hub->xo_handle)) { dev_err(hub->dev, "not able to get the handle\n" "for TCXO D1 buffer\n"); return PTR_ERR(smsc_hub->xo_handle); } ret = msm_xo_mode_vote(smsc_hub->xo_handle, MSM_XO_MODE_ON); if (ret) { dev_err(hub->dev, "failed to vote for TCXO\n" "D1 buffer\n"); msm_xo_put(smsc_hub->xo_handle); return ret; } } else { ret = clk_prepare_enable(hub->ref_clk); if (ret) dev_err(hub->dev, "clk_enable failed for ref_clk\n"); } return ret; }
static int __devexit ehci_msm2_remove(struct platform_device *pdev) { struct usb_hcd *hcd = platform_get_drvdata(pdev); struct msm_hcd *mhcd = hcd_to_mhcd(hcd); msm_ehci_resume(mhcd); if (pdev->dev.power.power_state.event != PM_EVENT_INVALID) pm_runtime_disable(&pdev->dev); device_init_wakeup(&pdev->dev, 0); pm_runtime_set_suspended(&pdev->dev); if (mhcd->pmic_gpio_dp_irq) { if (mhcd->pmic_gpio_dp_irq_enabled) disable_irq_wake(mhcd->pmic_gpio_dp_irq); free_irq(mhcd->pmic_gpio_dp_irq, mhcd); } if (mhcd->async_irq) { if (mhcd->async_irq_enabled) disable_irq_wake(mhcd->async_irq); free_irq(mhcd->async_irq, mhcd); } if (mhcd->wakeup_irq) { if (mhcd->wakeup_irq_enabled) disable_irq_wake(mhcd->wakeup_irq); free_irq(mhcd->wakeup_irq, mhcd); } if(mhcd->resume_gpio) gpio_free(mhcd->resume_gpio); usb_remove_hcd(hcd); if (!IS_ERR(mhcd->xo_clk)) { clk_disable_unprepare(mhcd->xo_clk); clk_put(mhcd->xo_clk); } else { msm_xo_put(mhcd->xo_handle); } msm_ehci_vbus_power(mhcd, 0); msm_ehci_init_vbus(mhcd, 0); msm_ehci_ldo_enable(mhcd, 0); msm_ehci_ldo_init(mhcd, 0); msm_ehci_init_vddcx(mhcd, 0); msm_ehci_init_clocks(mhcd, 0); wake_lock_destroy(&mhcd->wlock); iounmap(hcd->regs); usb_put_hcd(hcd); return 0; }
static int __init msm_peripheral_reset_init(void) { unsigned i; msm_mms_regs_base = ioremap(MSM_MMS_REGS_BASE, SZ_256); if (!msm_mms_regs_base) goto err; msm_lpass_qdsp6ss_base = ioremap(MSM_LPASS_QDSP6SS_BASE, SZ_256); if (!msm_lpass_qdsp6ss_base) goto err_lpass; pxo = msm_xo_get(MSM_XO_PXO, "pil"); if (IS_ERR(pxo)) goto err_pxo; pll4 = clk_get_sys("peripheral-reset", "pll4"); if (IS_ERR(pll4)) goto err_clk; if (pas_supported(PAS_MODEM) > 0) { pil_modem_ops.init_image = init_image_modem_trusted; pil_modem_ops.auth_and_reset = reset_modem_trusted; pil_modem_ops.shutdown = shutdown_modem_trusted; } if (pas_supported(PAS_Q6) > 0) { pil_q6_ops.init_image = init_image_q6_trusted; pil_q6_ops.auth_and_reset = reset_q6_trusted; pil_q6_ops.shutdown = shutdown_q6_trusted; } if (pas_supported(PAS_DSPS) > 0) { pil_dsps_ops.init_image = init_image_dsps_trusted; pil_dsps_ops.auth_and_reset = reset_dsps_trusted; pil_dsps_ops.shutdown = shutdown_dsps_trusted; } for (i = 0; i < ARRAY_SIZE(peripherals); i++) msm_pil_add_device(&peripherals[i]); return 0; err_clk: msm_xo_put(pxo); err_pxo: iounmap(msm_lpass_qdsp6ss_base); err_lpass: iounmap(msm_mms_regs_base); err: return -ENOMEM; }
static int ehci_msm2_remove(struct platform_device *pdev) { struct usb_hcd *hcd = platform_get_drvdata(pdev); struct msm_hcd *mhcd = hcd_to_mhcd(hcd); if (mhcd->pmic_gpio_dp_irq) { if (mhcd->pmic_gpio_dp_irq_enabled) disable_irq_wake(mhcd->pmic_gpio_dp_irq); free_irq(mhcd->pmic_gpio_dp_irq, mhcd); } if (mhcd->async_irq) { if (mhcd->async_irq_enabled) disable_irq_wake(mhcd->async_irq); free_irq(mhcd->async_irq, mhcd); } if (mhcd->wakeup_irq) { if (mhcd->wakeup_irq_enabled) disable_irq_wake(mhcd->wakeup_irq); free_irq(mhcd->wakeup_irq, mhcd); } device_init_wakeup(&pdev->dev, 0); pm_runtime_set_suspended(&pdev->dev); usb_remove_hcd(hcd); if (mhcd->xo_clk) { clk_disable_unprepare(mhcd->xo_clk); clk_put(mhcd->xo_clk); } else { msm_xo_put(mhcd->xo_handle); } msm_ehci_vbus_power(mhcd, 0); msm_ehci_init_vbus(mhcd, 0); msm_ehci_ldo_enable(mhcd, 0); msm_ehci_ldo_init(mhcd, 0); msm_ehci_init_vddcx(mhcd, 0); msm_ehci_init_clocks(mhcd, 0); wakeup_source_trash(&mhcd->ws); iounmap(hcd->regs); usb_put_hcd(hcd); #if defined(CONFIG_DEBUG_FS) debugfs_remove_recursive(dent_ehci); #endif return 0; }
int tdmb_fc8050_power_on(void) { int rc; printk("tdmb_fc8050_power_on \n"); if ( fc8050_ctrl_info.TdmbPowerOnState == FALSE ) { rc = msm_xo_mode_vote(xo_handle_tdmb, MSM_XO_MODE_ON); if(rc < 0) { pr_err("Configuring MSM_XO_MODE_ON failed (%d)\n", rc); msm_xo_put(xo_handle_tdmb); return FALSE; } if(pm_qos_request_active(&fc8050_ctrl_info.pm_req_list)) { pm_qos_update_request(&fc8050_ctrl_info.pm_req_list, 20); } wake_lock(&fc8050_ctrl_info.wake_lock); gpio_set_value_cansleep(DMB_ANT_SEL_P_EAR, 0); gpio_set_value_cansleep(DMB_ANT_SEL_N_INNER, 1); gpio_set_value(DMB_EN, 0); gpio_set_value(DMB_RESET_N, 1); udelay(100); gpio_set_value(DMB_EN, 1); udelay(1000); /* Due to X-tal stablization Time */ gpio_set_value(DMB_RESET_N, 0); udelay(100); gpio_set_value(DMB_RESET_N, 1); tdmb_fc8050_interrupt_free(); fc8050_ctrl_info.TdmbPowerOnState = TRUE; printk("tdmb_fc8050_power_on OK\n"); } else { printk("tdmb_fc8050_power_on the power already turn on \n"); } printk("tdmb_fc8050_power_on completed \n"); return TRUE; }
static int __devinit pil_modem_driver_probe(struct platform_device *pdev) { struct modem_data *drv; struct resource *res; struct pil_desc *desc; res = platform_get_resource(pdev, IORESOURCE_MEM, 0); if (!res) return -EINVAL; drv = devm_kzalloc(&pdev->dev, sizeof(*drv), GFP_KERNEL); if (!drv) return -ENOMEM; platform_set_drvdata(pdev, drv); drv->base = devm_ioremap(&pdev->dev, res->start, resource_size(res)); if (!drv->base) return -ENOMEM; drv->pxo = msm_xo_get(MSM_XO_PXO, dev_name(&pdev->dev)); if (IS_ERR(drv->pxo)) return PTR_ERR(drv->pxo); desc = devm_kzalloc(&pdev->dev, sizeof(*desc), GFP_KERNEL); if (!desc) return -ENOMEM; setup_timer(&drv->timer, remove_proxy_votes, (unsigned long)drv); desc->name = "modem"; desc->depends_on = "q6"; desc->dev = &pdev->dev; if (pas_supported(PAS_MODEM) > 0) { desc->ops = &pil_modem_ops_trusted; dev_info(&pdev->dev, "using secure boot\n"); } else { desc->ops = &pil_modem_ops; dev_info(&pdev->dev, "using non-secure boot\n"); } if (msm_pil_register(desc)) { msm_xo_put(drv->pxo); return -EINVAL; } return 0; }
static int pn544_remove(struct i2c_client *client) { struct pn544_dev *pn544_dev; pn544_dev = i2c_get_clientdata(client); wake_lock_destroy(&pn544_dev->nfc_wake_lock); free_irq(client->irq, pn544_dev); misc_deregister(&pn544_dev->pn544_device); mutex_destroy(&pn544_dev->read_mutex); gpio_free(pn544_dev->irq_gpio); gpio_free(pn544_dev->ven_gpio); gpio_free(pn544_dev->firm_gpio); #ifdef CONFIG_NFC_PN547 gpio_free(pn544_dev->clk_req_gpio); msm_xo_put(pn544_dev->nfc_clock); #endif kfree(pn544_dev); return 0; }
static int a1028_xo_clk_enable(int en) { int rc = 0; if (a1028_clock != NULL) { if (en) rc = msm_xo_mode_vote(a1028_clock, MSM_XO_MODE_ON); else rc = msm_xo_mode_vote(a1028_clock, MSM_XO_MODE_OFF); if (rc < 0) { pr_err("Configuring MSM_XO_MODE_ON failed" " (%d)\n", rc); goto fail; } } else pr_err("a1028_clock is null\n"); return rc; fail: msm_xo_put(a1028_clock); return rc; }
static int bcm2079x_remove(struct i2c_client *client) { struct bcm2079x_dev *bcm2079x_dev; bcm2079x_dev = i2c_get_clientdata(client); wake_lock_destroy(&bcm2079x_dev->nfc_wake_lock); free_irq(client->irq, bcm2079x_dev); misc_deregister(&bcm2079x_dev->bcm2079x_device); mutex_destroy(&bcm2079x_dev->read_mutex); gpio_free(bcm2079x_dev->irq_gpio); gpio_free(bcm2079x_dev->en_gpio); gpio_free(bcm2079x_dev->wake_gpio); #ifdef CONFIG_NFC_PMIC_CLK gpio_free(bcm2079x_dev->clk_req_gpio); msm_xo_put(bcm2079x_dev->nfc_clock); #endif kfree(bcm2079x_dev); return 0; }
static int smsc_hub_remove(struct platform_device *pdev) { const struct smsc_hub_platform_data *pdata; pdata = pdev->dev.platform_data; if (smsc_hub->client) { i2c_unregister_device(smsc_hub->client); smsc_hub->client = NULL; i2c_del_driver(&hsic_hub_driver); } pm_runtime_disable(&pdev->dev); msm_xo_put(smsc_hub->xo_handle); regulator_disable(smsc_hub->hsic_hub_reg); regulator_set_optimum_mode(smsc_hub->hsic_hub_reg, 0); regulator_set_voltage(smsc_hub->hsic_hub_reg, 0, HSIC_HUB_VDD_VOL_MIN); gpio_free(pdata->hub_reset); regulator_put(smsc_hub->hsic_hub_reg); kfree(smsc_hub); return 0; }
static int __devexit ehci_msm2_remove(struct platform_device *pdev) { struct msm_usb_host_platform_data *pdata; struct usb_hcd *hcd = platform_get_drvdata(pdev); struct msm_hcd *mhcd = hcd_to_mhcd(hcd); pdata = mhcd->dev->platform_data; if (mhcd->pmic_gpio_dp_irq) { if (mhcd->pmic_gpio_dp_irq_enabled) disable_irq_wake(mhcd->pmic_gpio_dp_irq); free_irq(mhcd->pmic_gpio_dp_irq, mhcd); } else if (pdata->mpm_xo_wakeup_int) { msm_mpm_set_pin_wake(pdata->mpm_xo_wakeup_int, 0); msm_mpm_enable_pin(pdata->mpm_xo_wakeup_int, 0); } device_init_wakeup(&pdev->dev, 0); pm_runtime_set_suspended(&pdev->dev); usb_remove_hcd(hcd); msm_xo_put(mhcd->xo_handle); msm_ehci_vbus_power(mhcd, 0); msm_ehci_init_vbus(mhcd, 0); msm_ehci_ldo_enable(mhcd, 0); msm_ehci_ldo_init(mhcd, 0); msm_ehci_init_vddcx(mhcd, 0); msm_ehci_init_clocks(mhcd, 0); wake_lock_destroy(&mhcd->wlock); iounmap(hcd->regs); usb_put_hcd(hcd); #if defined(CONFIG_DEBUG_FS) debugfs_remove_recursive(dent_ehci); #endif return 0; }
/* CONFIG_N bit in SP_ILOCK register has to be cleared for new * values in registers to be effective after writing to * other registers. */ hsic_hub_clear_bits(client, SMSC3503_SP_ILOCK, CONFIG_N); return 0; } static int i2c_hsic_hub_remove(struct i2c_client *client) { return 0; } static const struct i2c_device_id hsic_hub_id[] = { {"i2c_hsic_hub", 0}, {} }; MODULE_DEVICE_TABLE(i2c, hsichub_id); static struct i2c_driver hsic_hub_driver = { .driver = { .name = "i2c_hsic_hub", }, .probe = i2c_hsic_hub_probe, .remove = i2c_hsic_hub_remove, .id_table = hsic_hub_id, }; #define HSIC_HUB_VDD_VOL_MIN 1650000 /* uV */ #define HSIC_HUB_VDD_VOL_MAX 1950000 /* uV */ #define HSIC_HUB_VDD_LOAD 36000 /* uA */ static int __devinit smsc_hub_probe(struct platform_device *pdev) { int ret = 0; const struct smsc_hub_platform_data *pdata; struct i2c_adapter *i2c_adap; struct i2c_board_info i2c_info; if (!pdev->dev.platform_data) { dev_err(&pdev->dev, "No platform data\n"); return -ENODEV; } pdata = pdev->dev.platform_data; if (!pdata->hub_reset) return -EINVAL; smsc_hub = kzalloc(sizeof(*smsc_hub), GFP_KERNEL); if (!smsc_hub) return -ENOMEM; smsc_hub->hsic_hub_reg = regulator_get(&pdev->dev, "EXT_HUB_VDDIO"); if (IS_ERR(smsc_hub->hsic_hub_reg)) { dev_err(&pdev->dev, "unable to get ext hub vddcx\n"); ret = PTR_ERR(smsc_hub->hsic_hub_reg); goto free_mem; } ret = gpio_request(pdata->hub_reset, "HSIC_HUB_RESET_GPIO"); if (ret < 0) { dev_err(&pdev->dev, "gpio request failed for GPIO%d\n", pdata->hub_reset); goto gpio_req_fail; } ret = regulator_set_voltage(smsc_hub->hsic_hub_reg, HSIC_HUB_VDD_VOL_MIN, HSIC_HUB_VDD_VOL_MAX); if (ret) { dev_err(&pdev->dev, "unable to set the voltage" "for hsic hub reg\n"); goto reg_set_voltage_fail; } ret = regulator_set_optimum_mode(smsc_hub->hsic_hub_reg, HSIC_HUB_VDD_LOAD); if (ret < 0) { dev_err(&pdev->dev, "Unable to set optimum mode of regulator:" "VDDCX\n"); goto reg_optimum_mode_fail; } ret = regulator_enable(smsc_hub->hsic_hub_reg); if (ret) { dev_err(&pdev->dev, "unable to enable ext hub vddcx\n"); goto reg_enable_fail; } smsc_hub->xo_handle = msm_xo_get(MSM_XO_TCXO_D1, "hsic_hub"); if (IS_ERR(smsc_hub->xo_handle)) { dev_err(&pdev->dev, "not able to get the handle" "for TCXO D1 buffer\n"); goto disable_regulator; } ret = msm_xo_mode_vote(smsc_hub->xo_handle, MSM_XO_MODE_ON); if (ret) { dev_err(&pdev->dev, "failed to vote for TCXO" "D1 buffer\n"); goto xo_vote_fail; } gpio_direction_output(pdata->hub_reset, 0); /* Hub reset should be asserted for minimum 2microsec * before deasserting. */ udelay(5); gpio_direction_output(pdata->hub_reset, 1); ret = i2c_add_driver(&hsic_hub_driver); if (ret < 0) { dev_err(&pdev->dev, "failed to add I2C hsic_hub_driver\n"); goto i2c_add_fail; } usleep_range(10000, 12000); i2c_adap = i2c_get_adapter(SMSC_GSBI_I2C_BUS_ID); if (!i2c_adap) { dev_err(&pdev->dev, "failed to get i2c adapter\n"); i2c_del_driver(&hsic_hub_driver); goto i2c_add_fail; } memset(&i2c_info, 0, sizeof(struct i2c_board_info)); strlcpy(i2c_info.type, "i2c_hsic_hub", I2C_NAME_SIZE); smsc_hub->client = i2c_new_probed_device(i2c_adap, &i2c_info, normal_i2c, NULL); i2c_put_adapter(i2c_adap); if (!smsc_hub->client) dev_err(&pdev->dev, "failed to connect to smsc_hub" "through I2C\n"); i2c_add_fail: pm_runtime_set_active(&pdev->dev); pm_runtime_enable(&pdev->dev); return 0; xo_vote_fail: msm_xo_put(smsc_hub->xo_handle); disable_regulator: regulator_disable(smsc_hub->hsic_hub_reg); reg_enable_fail: regulator_set_optimum_mode(smsc_hub->hsic_hub_reg, 0); reg_optimum_mode_fail: regulator_set_voltage(smsc_hub->hsic_hub_reg, 0, HSIC_HUB_VDD_VOL_MIN); reg_set_voltage_fail: gpio_free(pdata->hub_reset); gpio_req_fail: regulator_put(smsc_hub->hsic_hub_reg); free_mem: kfree(smsc_hub); return ret; }
static int bcm2079x_probe(struct i2c_client *client, const struct i2c_device_id *id) { int ret, iIrq; struct bcm2079x_platform_data *platform_data; struct bcm2079x_dev *bcm2079x_dev; #ifdef DEBUG_BCM2079X_I2C_IRQ char tmp[5] = {0x10, 0x20, 0x00, 0x01, 0x00}; #endif platform_data = client->dev.platform_data; dev_info(&client->dev, "%s, probing bcm2079x driver flags = %x\n", __func__, client->flags); if (platform_data == NULL) { dev_err(&client->dev, "nfc probe fail\n"); return -ENODEV; } if (!i2c_check_functionality(client->adapter, I2C_FUNC_I2C)) { dev_err(&client->dev, "need I2C_FUNC_I2C\n"); return -ENODEV; } ret = gpio_request(platform_data->irq_gpio, "nfc_int"); if (ret) return -ENODEV; gpio_direction_input(platform_data->irq_gpio); ret = gpio_request(platform_data->en_gpio, "nfc_en"); if (ret) goto err_en; gpio_direction_output(platform_data->en_gpio, 0); ret = gpio_request(platform_data->wake_gpio, "nfc_wake"); if (ret) goto err_firm; gpio_direction_output(platform_data->wake_gpio, 0); #ifdef CONFIG_NFC_PMIC_CLK ret = gpio_request(platform_data->clk_req_gpio, "nfc_clk_req"); if (ret) goto err_clk_req; gpio_direction_input(platform_data->clk_req_gpio); #endif #ifdef DEBUG_BCM2079X_I2C_IRQ msleep(100); gpio_set_value_cansleep(platform_data->en_gpio, 1); msleep(100); #else gpio_set_value_cansleep(platform_data->en_gpio, 0); #endif gpio_set_value_cansleep(platform_data->wake_gpio, 1); bcm2079x_dev = kzalloc(sizeof(*bcm2079x_dev), GFP_KERNEL); if (bcm2079x_dev == NULL) { dev_err(&client->dev, "failed to allocate memory for module data\n"); ret = -ENOMEM; goto err_exit; } #ifdef CONFIG_NFC_PMIC_CLK bcm2079x_dev->nfc_clock = msm_xo_get(MSM_XO_TCXO_A1, "nfc"); if (IS_ERR(bcm2079x_dev->nfc_clock)) { ret = PTR_ERR(bcm2079x_dev->nfc_clock); printk(KERN_ERR "%s: Couldn't get TCXO_A1 vote for NFC (%d)\n", __func__, ret); ret = -ENODEV; goto err_get_clock; } bcm2079x_dev->clock_state = false; #endif bcm2079x_dev->wake_gpio = platform_data->wake_gpio; bcm2079x_dev->irq_gpio = platform_data->irq_gpio; bcm2079x_dev->en_gpio = platform_data->en_gpio; bcm2079x_dev->client = client; #ifdef CONFIG_NFC_PMIC_CLK bcm2079x_dev->clk_req_gpio = platform_data->clk_req_gpio; bcm2079x_dev->clk_req_irq = platform_data->clk_req_irq; #endif /* init mutex and queues */ init_waitqueue_head(&bcm2079x_dev->read_wq); mutex_init(&bcm2079x_dev->read_mutex); spin_lock_init(&bcm2079x_dev->irq_enabled_lock); bcm2079x_dev->bcm2079x_device.minor = MISC_DYNAMIC_MINOR; bcm2079x_dev->bcm2079x_device.name = "bcm2079x"; bcm2079x_dev->bcm2079x_device.fops = &bcm2079x_dev_fops; ret = misc_register(&bcm2079x_dev->bcm2079x_device); if (ret) { dev_err(&client->dev, "misc_register failed\n"); goto err_misc_register; } /* wake lock init */ wake_lock_init(&bcm2079x_dev->nfc_wake_lock, WAKE_LOCK_SUSPEND, "nfc_wake_lock"); #ifdef CONFIG_NFC_PMIC_CLK bcm2079x_dev->wq_clock = create_singlethread_workqueue("nfc_wq"); if (!bcm2079x_dev->wq_clock) { ret = -ENOMEM; pr_err("%s: could not create workqueue\n", __func__); goto err_create_workqueue; } INIT_WORK(&bcm2079x_dev->work_nfc_clock, nfc_work_func_clock); ret = request_irq(bcm2079x_dev->clk_req_irq, bcm2079x_dev_clk_req_irq_handler, IRQF_SHARED | IRQF_TRIGGER_RISING | IRQF_TRIGGER_FALLING , "bcm2079x_clk_req", bcm2079x_dev); if (ret) { dev_err(&client->dev, "request_irq(clk_req) failed\n"); goto err_request_irq_failed; } enable_irq_wake(bcm2079x_dev->clk_req_irq); #endif /* request irq. the irq is set whenever the chip has data available * for reading. it is cleared when all data has been read. */ iIrq = gpio_to_irq(client->irq); client->irq = iIrq; dev_info(&client->dev, "requesting IRQ %d with IRQF_NO_SUSPEND\n", iIrq); ret = request_irq(iIrq, bcm2079x_dev_irq_handler, IRQF_TRIGGER_RISING|IRQF_NO_SUSPEND, client->name, bcm2079x_dev); if (ret) { dev_err(&client->dev, "request_irq failed\n"); goto err_request_irq_failed; } i2c_set_clientdata(client, bcm2079x_dev); #ifndef DEBUG_BCM2079X_I2C_IRQ bcm2079x_dev->irq_enabled = false; disable_irq_nosync(bcm2079x_dev->client->irq); #else /* NCI reset test */ ret = i2c_master_send(bcm2079x_dev->client, tmp, sizeof(tmp)); if (ret != 5) pr_err("%s, i2c write error, NCI rest cmd err = %d\n", __func__, ret); else pr_info("%s, i2c write success!!! ret = %d\n", __func__, ret); #endif dev_info(&client->dev, "%s, probing bcm2079x driver exited successfully\n", __func__); return 0; err_request_irq_failed: #ifdef CONFIG_NFC_PMIC_CLK err_create_workqueue: #endif wake_lock_destroy(&bcm2079x_dev->nfc_wake_lock); misc_deregister(&bcm2079x_dev->bcm2079x_device); err_misc_register: mutex_destroy(&bcm2079x_dev->read_mutex); #ifdef CONFIG_NFC_PMIC_CLK msm_xo_put(bcm2079x_dev->nfc_clock); err_get_clock: #endif kfree(bcm2079x_dev); err_exit: #ifdef CONFIG_NFC_PMIC_CLK gpio_free(platform_data->clk_req_gpio); err_clk_req: #endif gpio_free(platform_data->wake_gpio); err_firm: gpio_free(platform_data->en_gpio); err_en: gpio_free(platform_data->irq_gpio); return ret; }
static int pn547_probe(struct i2c_client *client, const struct i2c_device_id *id) { int ret; int err; int addr; char tmp[4] = {0x20, 0x00, 0x01, 0x01}; int addrcnt; struct pn547_i2c_platform_data *platform_data; struct pn547_dev *pn547_dev; if (client->dev.of_node) { platform_data = devm_kzalloc(&client->dev, sizeof(struct pn547_i2c_platform_data), GFP_KERNEL); if (!platform_data) { dev_err(&client->dev, "Failed to allocate memory\n"); return -ENOMEM; } err = pn547_parse_dt(&client->dev, platform_data); if (err) return err; } else { platform_data = client->dev.platform_data; } if (platform_data == NULL) { pr_err("%s : nfc probe fail\n", __func__); return -ENODEV; } if (!i2c_check_functionality(client->adapter, I2C_FUNC_I2C)) { pr_err("%s : need I2C_FUNC_I2C\n", __func__); return -ENODEV; } ret = gpio_request(platform_data->irq_gpio, "nfc_int"); if (ret) return -ENODEV; ret = gpio_request(platform_data->ven_gpio, "nfc_ven"); if (ret) goto err_ven; ret = gpio_request(platform_data->firm_gpio, "nfc_firm"); if (ret) goto err_firm; #ifdef CONFIG_NFC_PN547_CLOCK_REQUEST ret = gpio_request(platform_data->clk_req_gpio, "nfc_clk_req"); if (ret) goto err_clk_req; #endif #ifdef CONFIG_NFC_PN547_8226_USE_BBCLK2 ret = gpio_request(platform_data->clk_req_gpio, "nfc_clk_req"); if (ret) goto err_clk_req; #endif pn547_dev = kzalloc(sizeof(*pn547_dev), GFP_KERNEL); if (pn547_dev == NULL) { dev_err(&client->dev, "failed to allocate memory for module data\n"); ret = -ENOMEM; goto err_exit; } #ifdef CONFIG_NFC_PN547_CLOCK_REQUEST pn547_dev->nfc_clock = msm_xo_get(MSM_XO_TCXO_A1, "nfc"); if (IS_ERR(pn547_dev->nfc_clock)) { ret = PTR_ERR(pn547_dev->nfc_clock); printk(KERN_ERR "%s: Couldn't get TCXO_A1 vote for NFC (%d)\n", __func__, ret); ret = -ENODEV; goto err_get_clock; } pn547_dev->clock_state = false; #endif #ifdef CONFIG_NFC_PN547_8226_USE_BBCLK2 pn547_dev->nfc_clock = clk_get(NULL, "nfc_clock"); if (IS_ERR(pn547_dev->nfc_clock)) { ret = PTR_ERR(pn547_dev->nfc_clock); printk(KERN_ERR "%s: Couldn't get D1 (%d)\n", __func__, ret); } else { if (clk_prepare_enable(pn547_dev->nfc_clock)) printk(KERN_ERR "%s: Couldn't prepare D1\n", __func__); } #endif #if defined(CONFIG_NFC_PN547_PMC8974_CLK_REQ) || defined(CONFIG_NFC_PN547_8084_USE_BBCLK2) #if defined(CONFIG_NFC_I2C_OVERWRITE) || defined(CONFIG_NFC_PN547_8084_USE_BBCLK2) pn547_dev->nfc_clk = clk_get(NULL, "nfc_clk"); #else pn547_dev->nfc_clk = clk_get(&client->dev, "nfc_clk"); #endif if (IS_ERR(pn547_dev->nfc_clk)) { ret = PTR_ERR(pn547_dev->nfc_clk); printk(KERN_ERR "%s: Couldn't get D1 (%d)\n", __func__, ret); } else { if (clk_prepare_enable(pn547_dev->nfc_clk)) printk(KERN_ERR "%s: Couldn't prepare D1\n", __func__); } #endif #if defined(CONFIG_GPIO_PCAL6416A) client->irq = gpio_to_irq(platform_data->irq_gpio); #endif pr_info("%s : IRQ num %d\n", __func__, client->irq); pn547_dev->irq_gpio = platform_data->irq_gpio; pn547_dev->ven_gpio = platform_data->ven_gpio; pn547_dev->firm_gpio = platform_data->firm_gpio; pn547_dev->conf_gpio = platform_data->conf_gpio; #ifdef CONFIG_NFC_PN547_CLOCK_REQUEST pn547_dev->clk_req_gpio = platform_data->clk_req_gpio; pn547_dev->clk_req_irq = platform_data->clk_req_irq; #endif #ifdef CONFIG_SEC_K_PROJECT pn547_dev->scl_gpio = platform_data->scl_gpio; pn547_dev->sda_gpio = platform_data->sda_gpio; #endif #ifdef CONFIG_NFC_PN547_8226_USE_BBCLK2 pn547_dev->clk_req_gpio = platform_data->clk_req_gpio; #endif pn547_dev->client = client; /* init mutex and queues */ init_waitqueue_head(&pn547_dev->read_wq); mutex_init(&pn547_dev->read_mutex); pn547_dev->pn547_device.minor = MISC_DYNAMIC_MINOR; #ifdef CONFIG_NFC_PN547 pn547_dev->pn547_device.name = "pn547"; #else pn547_dev->pn547_device.name = "pn544"; #endif pn547_dev->pn547_device.fops = &pn547_dev_fops; ret = misc_register(&pn547_dev->pn547_device); if (ret) { pr_err("%s : misc_register failed\n", __FILE__); goto err_misc_register; } /* request irq. the irq is set whenever the chip has data available * for reading. it is cleared when all data has been read. */ pr_info("%s : requesting IRQ %d\n", __func__, client->irq); gpio_direction_input(pn547_dev->irq_gpio); gpio_direction_output(pn547_dev->ven_gpio, 0); gpio_direction_output(pn547_dev->firm_gpio, 0); #if defined(CONFIG_NFC_PN547_CLOCK_REQUEST) || defined(CONFIG_NFC_PN547_8226_USE_BBCLK2) gpio_direction_input(pn547_dev->clk_req_gpio); #endif i2c_set_clientdata(client, pn547_dev); wake_lock_init(&pn547_dev->nfc_wake_lock, WAKE_LOCK_SUSPEND, "nfc_wake_lock"); #ifdef CONFIG_NFC_PN547_CLOCK_REQUEST pn547_dev->wq_clock = create_singlethread_workqueue("nfc_wq"); if (!pn547_dev->wq_clock) { ret = -ENOMEM; pr_err("%s: could not create workqueue\n", __func__); goto err_create_workqueue; } INIT_WORK(&pn547_dev->work_nfc_clock, nfc_work_func_clock); #endif ret = request_irq(client->irq, pn547_dev_irq_handler, IRQF_TRIGGER_RISING, "pn547", pn547_dev); if (ret) { dev_err(&client->dev, "request_irq failed\n"); goto err_request_irq_failed; } disable_irq_nosync(pn547_dev->client->irq); atomic_set(&pn547_dev->irq_enabled, 0); #ifdef CONFIG_NFC_PN547_CLOCK_REQUEST ret = request_irq(pn547_dev->clk_req_irq, pn547_dev_clk_req_irq_handler, IRQF_SHARED | IRQF_TRIGGER_RISING | IRQF_TRIGGER_FALLING , "pn547_clk_req", pn547_dev); if (ret) { dev_err(&client->dev, "request_irq(clk_req) failed\n"); goto err_request_irq_failed; } enable_irq_wake(pn547_dev->clk_req_irq); #endif gpio_set_value(pn547_dev->ven_gpio, 1); gpio_set_value(pn547_dev->firm_gpio, 1); /* add firmware pin */ usleep_range(4900, 5000); gpio_set_value(pn547_dev->ven_gpio, 0); usleep_range(4900, 5000); gpio_set_value(pn547_dev->ven_gpio, 1); usleep_range(4900, 5000); for (addr = 0x2B; addr > 0x27; addr--) { client->addr = addr; addrcnt = 2; do { ret = i2c_master_send(client, tmp, 4); if (ret > 0) { pr_info("%s : i2c addr=0x%X\n", __func__, client->addr); break; } } while (addrcnt--); if (ret > 0) break; } if(ret <= 0) client->addr = 0x2B; gpio_set_value(pn547_dev->ven_gpio, 0); gpio_set_value(pn547_dev->firm_gpio, 0); /* add */ if (ret < 0) pr_err("%s : fail to get i2c addr\n", __func__); /* goto err_request_irq_failed; */ else pr_info("%s : success\n", __func__); return 0; err_request_irq_failed: #ifdef CONFIG_NFC_PN547_CLOCK_REQUEST err_create_workqueue: #endif misc_deregister(&pn547_dev->pn547_device); wake_lock_destroy(&pn547_dev->nfc_wake_lock); err_misc_register: mutex_destroy(&pn547_dev->read_mutex); #ifdef CONFIG_NFC_PN547_CLOCK_REQUEST msm_xo_put(pn547_dev->nfc_clock); err_get_clock: #endif kfree(pn547_dev); err_exit: #if defined(CONFIG_NFC_PN547_CLOCK_REQUEST) || defined(CONFIG_NFC_PN547_8226_USE_BBCLK2) gpio_free(platform_data->clk_req_gpio); err_clk_req: #endif gpio_free(platform_data->firm_gpio); err_firm: gpio_free(platform_data->ven_gpio); err_ven: gpio_free(platform_data->irq_gpio); pr_err("[pn547] pn547_probe fail!\n"); return ret; }
static int __devinit ehci_msm2_probe(struct platform_device *pdev) { struct usb_hcd *hcd; struct resource *res; struct msm_hcd *mhcd; const struct msm_usb_host_platform_data *pdata; char pdev_name[PDEV_NAME_LEN]; int ret; dev_dbg(&pdev->dev, "ehci_msm2 probe\n"); hcd = usb_create_hcd(&msm_hc2_driver, &pdev->dev, dev_name(&pdev->dev)); if (!hcd) { dev_err(&pdev->dev, "Unable to create HCD\n"); return -ENOMEM; } hcd->irq = platform_get_irq(pdev, 0); if (hcd->irq < 0) { dev_err(&pdev->dev, "Unable to get IRQ resource\n"); ret = hcd->irq; goto put_hcd; } res = platform_get_resource(pdev, IORESOURCE_MEM, 0); if (!res) { dev_err(&pdev->dev, "Unable to get memory resource\n"); ret = -ENODEV; goto put_hcd; } hcd->rsrc_start = res->start; hcd->rsrc_len = resource_size(res); hcd->regs = ioremap(hcd->rsrc_start, hcd->rsrc_len); if (!hcd->regs) { dev_err(&pdev->dev, "ioremap failed\n"); ret = -ENOMEM; goto put_hcd; } mhcd = hcd_to_mhcd(hcd); mhcd->dev = &pdev->dev; snprintf(pdev_name, PDEV_NAME_LEN, "%s.%d", pdev->name, pdev->id); mhcd->xo_handle = msm_xo_get(MSM_XO_TCXO_D0, pdev_name); if (IS_ERR(mhcd->xo_handle)) { dev_err(&pdev->dev, "%s not able to get the handle " "to vote for TCXO D0 buffer\n", __func__); ret = PTR_ERR(mhcd->xo_handle); goto unmap; } ret = msm_xo_mode_vote(mhcd->xo_handle, MSM_XO_MODE_ON); if (ret) { dev_err(&pdev->dev, "%s failed to vote for TCXO " "D0 buffer%d\n", __func__, ret); goto free_xo_handle; } ret = msm_ehci_init_clocks(mhcd, 1); if (ret) { dev_err(&pdev->dev, "unable to initialize clocks\n"); ret = -ENODEV; goto devote_xo_handle; } ret = msm_ehci_init_vddcx(mhcd, 1); if (ret) { dev_err(&pdev->dev, "unable to initialize VDDCX\n"); ret = -ENODEV; goto deinit_clocks; } ret = msm_ehci_config_vddcx(mhcd, 1); if (ret) { dev_err(&pdev->dev, "hsusb vddcx configuration failed\n"); goto deinit_vddcx; } ret = msm_ehci_ldo_init(mhcd, 1); if (ret) { dev_err(&pdev->dev, "hsusb vreg configuration failed\n"); goto deinit_vddcx; } ret = msm_ehci_ldo_enable(mhcd, 1); if (ret) { dev_err(&pdev->dev, "hsusb vreg enable failed\n"); goto deinit_ldo; } ret = msm_ehci_init_vbus(mhcd, 1); if (ret) { dev_err(&pdev->dev, "unable to get vbus\n"); goto disable_ldo; } ret = msm_hsusb_reset(mhcd); if (ret) { dev_err(&pdev->dev, "hsusb PHY initialization failed\n"); goto vbus_deinit; } ret = usb_add_hcd(hcd, hcd->irq, IRQF_SHARED); if (ret) { dev_err(&pdev->dev, "unable to register HCD\n"); goto vbus_deinit; } pdata = mhcd->dev->platform_data; if (pdata && (!pdata->dock_connect_irq || !irq_read_line(pdata->dock_connect_irq))) msm_ehci_vbus_power(mhcd, 1); device_init_wakeup(&pdev->dev, 1); wake_lock_init(&mhcd->wlock, WAKE_LOCK_SUSPEND, dev_name(&pdev->dev)); wake_lock(&mhcd->wlock); INIT_WORK(&mhcd->phy_susp_fail_work, msm_ehci_phy_susp_fail_work); /* * This pdev->dev is assigned parent of root-hub by USB core, * hence, runtime framework automatically calls this driver's * runtime APIs based on root-hub's state. */ /* configure pmic_gpio_irq for D+ change */ if (pdata && pdata->pmic_gpio_dp_irq) mhcd->pmic_gpio_dp_irq = pdata->pmic_gpio_dp_irq; if (mhcd->pmic_gpio_dp_irq) { ret = request_threaded_irq(mhcd->pmic_gpio_dp_irq, NULL, msm_ehci_host_wakeup_irq, IRQF_TRIGGER_RISING | IRQF_TRIGGER_FALLING, "msm_ehci_host_wakeup", mhcd); if (!ret) { disable_irq_nosync(mhcd->pmic_gpio_dp_irq); } else { dev_err(&pdev->dev, "request_irq(%d) failed: %d\n", mhcd->pmic_gpio_dp_irq, ret); mhcd->pmic_gpio_dp_irq = 0; } } pm_runtime_set_active(&pdev->dev); pm_runtime_enable(&pdev->dev); //ASUS_BSP+++ BennyCheng "implement ehci3 phy power collapse mode" the_msm_hcd = mhcd; usb_ehci_phy_power_control(0); mutex_init(&mhcd->ehci_mutex); //ASUS_BSP--- BennyCheng "implement ehci3 phy power collapse mode" return 0; vbus_deinit: msm_ehci_init_vbus(mhcd, 0); disable_ldo: msm_ehci_ldo_enable(mhcd, 0); deinit_ldo: msm_ehci_ldo_init(mhcd, 0); deinit_vddcx: msm_ehci_init_vddcx(mhcd, 0); deinit_clocks: msm_ehci_init_clocks(mhcd, 0); devote_xo_handle: msm_xo_mode_vote(mhcd->xo_handle, MSM_XO_MODE_OFF); free_xo_handle: msm_xo_put(mhcd->xo_handle); unmap: iounmap(hcd->regs); put_hcd: usb_put_hcd(hcd); return ret; }
static int configure_iris_xo(bool use_48mhz_xo, int on) { u32 reg = 0; int rc = 0; if (on) { msm_riva_base = ioremap(MSM_RIVA_PHYS, SZ_256); if (!msm_riva_base) { pr_err("ioremap MSM_RIVA_PHYS failed\n"); goto fail; } /* Enable IRIS XO */ writel_relaxed(0, RIVA_PMU_CFG); reg = readl_relaxed(RIVA_PMU_CFG); reg |= RIVA_PMU_CFG_GC_BUS_MUX_SEL_TOP | RIVA_PMU_CFG_IRIS_XO_EN; writel_relaxed(reg, RIVA_PMU_CFG); /* Clear XO_MODE[b2:b1] bits. Clear implies 19.2 MHz TCXO */ reg &= ~(RIVA_PMU_CFG_IRIS_XO_MODE); if (use_48mhz_xo) reg |= RIVA_PMU_CFG_IRIS_XO_MODE_48; writel_relaxed(reg, RIVA_PMU_CFG); /* Start IRIS XO configuration */ reg |= RIVA_PMU_CFG_IRIS_XO_CFG; writel_relaxed(reg, RIVA_PMU_CFG); /* Wait for XO configuration to finish */ while (readl_relaxed(RIVA_PMU_CFG) & RIVA_PMU_CFG_IRIS_XO_CFG_STS) cpu_relax(); /* Stop IRIS XO configuration */ reg &= ~(RIVA_PMU_CFG_GC_BUS_MUX_SEL_TOP | RIVA_PMU_CFG_IRIS_XO_CFG); writel_relaxed(reg, RIVA_PMU_CFG); if (!use_48mhz_xo) { wlan_clock = msm_xo_get(MSM_XO_TCXO_A0, id); if (IS_ERR(wlan_clock)) { rc = PTR_ERR(wlan_clock); pr_err("Failed to get MSM_XO_TCXO_A0 voter" " (%d)\n", rc); goto fail; } rc = msm_xo_mode_vote(wlan_clock, MSM_XO_MODE_ON); if (rc < 0) { pr_err("Configuring MSM_XO_MODE_ON failed" " (%d)\n", rc); goto msm_xo_vote_fail; } } } else { if (wlan_clock != NULL && !use_48mhz_xo) { rc = msm_xo_mode_vote(wlan_clock, MSM_XO_MODE_OFF); if (rc < 0) pr_err("Configuring MSM_XO_MODE_OFF failed" " (%d)\n", rc); } } /* Add some delay for XO to settle */ msleep(20); return rc; msm_xo_vote_fail: msm_xo_put(wlan_clock); fail: return rc; }
/** * vos_chip_power_qrf8615() - WLAN Power Up Seq for WCN1314 rev 2.0 on QRF 8615 * @on - Turn WLAN ON/OFF (1 or 0) * * Power up/down WLAN by turning on/off various regs and asserting/deasserting * Power-on-reset pin. Also, put XO A0 buffer as slave to wlan_clk_pwr_req while * turning ON WLAN and vice-versa. * * This function returns 0 on success or a non-zero value on failure. */ int vos_chip_power_qrf8615(int on) { static char wlan_on; static const char *vregs_qwlan_name[] = { "8058_l20", "8058_l8", "8901_s4", "8901_lvs1", "8901_l0", "8058_s2", "8058_s1", }; static const char *vregs_qwlan_pc_name[] = { "8058_l20_pc", "8058_l8_pc", NULL, NULL, "8901_l0_pc", "8058_s2_pc", NULL, }; static const int vregs_qwlan_val_min[] = { 1800000, 3050000, 1225000, 0, 1200000, 1300000, 500000, }; static const int vregs_qwlan_val_max[] = { 1800000, 3050000, 1225000, 0, 1200000, 1300000, 1250000, }; static const int vregs_qwlan_peek_current[] = { 4000, 150000, 60000, 0, 32000, 130000, 0, }; static const bool vregs_is_pin_controlled_default[] = { 1, 1, 0, 0, 1, 1, 0, }; static const bool vregs_is_pin_controlled_dragon[] = { 0, 0, 0, 0, 0, 1, 0, }; bool const *vregs_is_pin_controlled; static struct regulator *vregs_qwlan[ARRAY_SIZE(vregs_qwlan_name)]; static struct regulator *vregs_pc_qwlan[ARRAY_SIZE(vregs_qwlan_name)]; static struct msm_xo_voter *wlan_clock; int ret, i, rc = 0; unsigned wlan_gpio_deep_sleep = GPIO_WLAN_DEEP_SLEEP_N; vregs_is_pin_controlled = vregs_is_pin_controlled_default; if (machine_is_msm8x60_dragon()) { wlan_gpio_deep_sleep = GPIO_WLAN_DEEP_SLEEP_N_DRAGON; vregs_is_pin_controlled = vregs_is_pin_controlled_dragon; } /* WLAN RESET and CLK settings */ if (on && !wlan_on) { /* * Program U12 GPIO expander pin IO1 to de-assert (drive 0) * WLAN_EXT_POR_N to put WLAN in reset */ rc = gpio_request(wlan_gpio_deep_sleep, "WLAN_DEEP_SLEEP_N"); if (rc) { pr_err("WLAN reset GPIO %d request failed\n", wlan_gpio_deep_sleep); goto fail; } rc = gpio_direction_output(wlan_gpio_deep_sleep, WLAN_RESET); if (rc < 0) { pr_err("WLAN reset GPIO %d set output direction failed", wlan_gpio_deep_sleep); goto fail_gpio_dir_out; } /* Configure TCXO to be slave to WLAN_CLK_PWR_REQ */ if (wlan_clock == NULL) { wlan_clock = msm_xo_get(MSM_XO_TCXO_A0, id); if (IS_ERR(wlan_clock)) { pr_err("Failed to get TCXO_A0 voter (%ld)\n", PTR_ERR(wlan_clock)); goto fail_gpio_dir_out; } } rc = msm_xo_mode_vote(wlan_clock, MSM_XO_MODE_PIN_CTRL); if (rc < 0) { pr_err("Configuring TCXO to Pin controllable failed" "(%d)\n", rc); goto fail_xo_mode_vote; } } else if (!on && wlan_on) { if (wlan_clock != NULL) msm_xo_mode_vote(wlan_clock, MSM_XO_MODE_OFF); gpio_set_value_cansleep(wlan_gpio_deep_sleep, WLAN_RESET); gpio_free(wlan_gpio_deep_sleep); } /* WLAN VREG settings */ for (i = 0; i < ARRAY_SIZE(vregs_qwlan_name); i++) { if (on && !wlan_on) { vregs_qwlan[i] = regulator_get(NULL, vregs_qwlan_name[i]); if (IS_ERR(vregs_qwlan[i])) { pr_err("regulator get of %s failed (%ld)\n", vregs_qwlan_name[i], PTR_ERR(vregs_qwlan[i])); rc = PTR_ERR(vregs_qwlan[i]); goto vreg_get_fail; } if (vregs_qwlan_val_min[i] || vregs_qwlan_val_max[i]) { rc = regulator_set_voltage(vregs_qwlan[i], vregs_qwlan_val_min[i], vregs_qwlan_val_max[i]); if (rc) { pr_err("regulator_set_voltage(%s) failed\n", vregs_qwlan_name[i]); goto vreg_fail; } } /* vote for pin control (if needed) */ if (vregs_is_pin_controlled[i]) { vregs_pc_qwlan[i] = regulator_get(NULL, vregs_qwlan_pc_name[i]); if (IS_ERR(vregs_pc_qwlan[i])) { pr_err("regulator get of %s failed " "(%ld)\n", vregs_qwlan_pc_name[i], PTR_ERR(vregs_pc_qwlan[i])); rc = PTR_ERR(vregs_pc_qwlan[i]); goto vreg_fail; } } if (vregs_qwlan_peek_current[i]) { rc = regulator_set_optimum_mode(vregs_qwlan[i], vregs_qwlan_peek_current[i]); if (rc < 0) pr_err("vreg %s set optimum mode" " failed to %d (%d)\n", vregs_qwlan_name[i], rc, vregs_qwlan_peek_current[i]); } rc = regulator_enable(vregs_qwlan[i]); if (rc < 0) { pr_err("vreg %s enable failed (%d)\n", vregs_qwlan_name[i], rc); goto vreg_fail; } if (vregs_is_pin_controlled[i]) { rc = regulator_enable(vregs_pc_qwlan[i]); if (rc < 0) { pr_err("vreg %s enable failed (%d)\n", vregs_qwlan_pc_name[i], rc); goto vreg_fail; } } } else if (!on && wlan_on) { if (vregs_qwlan_peek_current[i]) { /* For legacy reasons we pass 1mA current to * put regulator in LPM mode. */ rc = regulator_set_optimum_mode(vregs_qwlan[i], 1000); if (rc < 0) pr_info("vreg %s set optimum mode" "failed (%d)\n", vregs_qwlan_name[i], rc); rc = regulator_set_voltage(vregs_qwlan[i], 0 , vregs_qwlan_val_max[i]); if (rc) pr_err("regulator_set_voltage(%s)" "failed (%d)\n", vregs_qwlan_name[i], rc); } if (vregs_is_pin_controlled[i]) { rc = regulator_disable(vregs_pc_qwlan[i]); if (rc < 0) { pr_err("vreg %s disable failed (%d)\n", vregs_qwlan_pc_name[i], rc); goto vreg_fail; } regulator_put(vregs_pc_qwlan[i]); } rc = regulator_disable(vregs_qwlan[i]); if (rc < 0) { pr_err("vreg %s disable failed (%d)\n", vregs_qwlan_name[i], rc); goto vreg_fail; } regulator_put(vregs_qwlan[i]); } } if (on) { gpio_set_value_cansleep(wlan_gpio_deep_sleep, WLAN_RESET_OUT); wlan_on = true; } else wlan_on = false; return 0; vreg_fail: regulator_put(vregs_qwlan[i]); if (vregs_is_pin_controlled[i]) regulator_put(vregs_pc_qwlan[i]); vreg_get_fail: i--; while (i >= 0) { ret = !on ? regulator_enable(vregs_qwlan[i]) : regulator_disable(vregs_qwlan[i]); if (ret < 0) { pr_err("vreg %s %s failed (%d) in err path\n", vregs_qwlan_name[i], !on ? "enable" : "disable", ret); } if (vregs_is_pin_controlled[i]) { ret = !on ? regulator_enable(vregs_pc_qwlan[i]) : regulator_disable(vregs_pc_qwlan[i]); if (ret < 0) { pr_err("vreg %s %s failed (%d) in err path\n", vregs_qwlan_pc_name[i], !on ? "enable" : "disable", ret); } } regulator_put(vregs_qwlan[i]); if (vregs_is_pin_controlled[i]) regulator_put(vregs_pc_qwlan[i]); i--; } if (!on) goto fail; fail_xo_mode_vote: msm_xo_put(wlan_clock); fail_gpio_dir_out: gpio_free(wlan_gpio_deep_sleep); fail: return rc; }
/** * vos_chip_power_qrf8615() - WLAN Power Up Seq for WCN1314 rev 2.0 on QRF 8615 * @on - Turn WLAN ON/OFF (1 or 0) * * Power up/down WLAN by turning on/off various regs and asserting/deasserting * Power-on-reset pin. Also, put XO A0 buffer as slave to wlan_clk_pwr_req while * turning ON WLAN and vice-versa. * * This function returns 0 on success or a non-zero value on failure. */ int vos_chip_power_qrf8615(int on) { static char wlan_on; static const char *vregs_qwlan_name[] = { "8058_l20", "8058_l8", "8901_s4", "8901_lvs1", "8901_l0", "8058_s2", "8058_s1", }; static const int vregs_qwlan_val_min[] = { 1800000, 3050000, 1225000, 0, 1200000, 1300000, 500000, }; static const int vregs_qwlan_val_max[] = { 1800000, 3050000, 1225000, 0, 1200000, 1300000, 1250000, }; static const bool vregs_is_pin_controlled[] = { 1, 1, 0, 0, 1, 1, 0, }; static struct regulator *vregs_qwlan[ARRAY_SIZE(vregs_qwlan_name)]; static struct msm_xo_voter *wlan_clock; int ret, i, rc = 0; /* WLAN RESET and CLK settings */ if (on && !wlan_on) { /* * Program U12 GPIO expander pin IO1 to de-assert (drive 0) * WLAN_EXT_POR_N to put WLAN in reset */ rc = gpio_request(GPIO_WLAN_DEEP_SLEEP_N, "WLAN_DEEP_SLEEP_N"); if (rc) { pr_err("WLAN reset GPIO %d request failed\n", GPIO_WLAN_DEEP_SLEEP_N); goto fail; } rc = gpio_direction_output(GPIO_WLAN_DEEP_SLEEP_N, WLAN_RESET_OUT); if (rc < 0) { pr_err("WLAN reset GPIO %d set output direction failed", GPIO_WLAN_DEEP_SLEEP_N); goto fail_gpio_dir_out; } /* Configure TCXO to be slave to WLAN_CLK_PWR_REQ */ if (wlan_clock == NULL) { wlan_clock = msm_xo_get(MSM_XO_TCXO_A0, id); if (IS_ERR(wlan_clock)) { pr_err("Failed to get TCXO_A0 voter (%ld)\n", PTR_ERR(wlan_clock)); goto fail_gpio_dir_out; } } rc = msm_xo_mode_vote(wlan_clock, MSM_XO_MODE_PIN_CTRL); if (rc < 0) { pr_err("Configuring TCXO to Pin controllable failed" "(%d)\n", rc); goto fail_xo_mode_vote; } } else if (!on && wlan_on) { if (wlan_clock != NULL) msm_xo_mode_vote(wlan_clock, MSM_XO_MODE_OFF); gpio_set_value_cansleep(GPIO_WLAN_DEEP_SLEEP_N, WLAN_RESET); gpio_free(GPIO_WLAN_DEEP_SLEEP_N); } /* WLAN VREG settings */ for (i = 0; i < ARRAY_SIZE(vregs_qwlan_name); i++) { if (vregs_qwlan[i] == NULL) { vregs_qwlan[i] = regulator_get(NULL, vregs_qwlan_name[i]); if (IS_ERR(vregs_qwlan[i])) { pr_err("regulator get of %s failed (%ld)\n", vregs_qwlan_name[i], PTR_ERR(vregs_qwlan[i])); rc = PTR_ERR(vregs_qwlan[i]); goto vreg_get_fail; } if (vregs_qwlan_val_min[i] || vregs_qwlan_val_max[i]) { rc = regulator_set_voltage(vregs_qwlan[i], vregs_qwlan_val_min[i], vregs_qwlan_val_max[i]); if (rc) { pr_err("regulator_set_voltage(%s) failed\n", vregs_qwlan_name[i]); goto vreg_fail; } } /* vote for pin control (if needed) */ if (vregs_is_pin_controlled[i]) { rc = regulator_set_mode(vregs_qwlan[i], REGULATOR_MODE_IDLE); if (rc) { pr_err("regulator_set_mode(%s) failed\n", vregs_qwlan_name[i]); goto vreg_fail; } } } if (on && !wlan_on) { rc = regulator_enable(vregs_qwlan[i]); if (rc < 0) { pr_err("vreg %s enable failed (%d)\n", vregs_qwlan_name[i], rc); goto vreg_fail; } } else if (!on && wlan_on) { rc = regulator_disable(vregs_qwlan[i]); if (rc < 0) { pr_err("vreg %s disable failed (%d)\n", vregs_qwlan_name[i], rc); goto vreg_fail; } } } if (on) wlan_on = true; else wlan_on = false; return 0; vreg_fail: regulator_put(vregs_qwlan[i]); vreg_get_fail: i--; while (i) { ret = !on ? regulator_enable(vregs_qwlan[i]) : regulator_disable(vregs_qwlan[i]); if (ret < 0) { pr_err("vreg %s %s failed (%d) in err path\n", vregs_qwlan_name[i], !on ? "enable" : "disable", ret); } regulator_put(vregs_qwlan[i]); i--; } if (!on) goto fail; fail_xo_mode_vote: msm_xo_put(wlan_clock); fail_gpio_dir_out: gpio_free(GPIO_WLAN_DEEP_SLEEP_N); fail: return rc; }
static int __devinit ehci_msm2_probe(struct platform_device *pdev) { struct usb_hcd *hcd; struct resource *res; struct msm_hcd *mhcd; const struct msm_usb_host_platform_data *pdata; char pdev_name[PDEV_NAME_LEN]; int ret; int res_gpio; dev_info(&pdev->dev, "ehci_msm2 probe\n"); /* If there is no WAN device present, we don't need to start the EHCI stack */ if(!wan_present()) return -ENODEV; if (pdev->dev.of_node) { dev_dbg(&pdev->dev, "device tree enabled\n"); pdev->dev.platform_data = ehci_msm2_dt_to_pdata(pdev); } if (!pdev->dev.platform_data) dev_dbg(&pdev->dev, "No platform data given\n"); if (!pdev->dev.dma_mask) pdev->dev.dma_mask = &ehci_msm_dma_mask; if (!pdev->dev.coherent_dma_mask) pdev->dev.coherent_dma_mask = DMA_BIT_MASK(32); hcd = usb_create_hcd(&msm_hc2_driver, &pdev->dev, dev_name(&pdev->dev)); if (!hcd) { dev_err(&pdev->dev, "Unable to create HCD\n"); return -ENOMEM; } hcd_to_bus(hcd)->skip_resume = true; hcd->irq = platform_get_irq(pdev, 0); if (hcd->irq < 0) { dev_err(&pdev->dev, "Unable to get IRQ resource\n"); ret = hcd->irq; goto put_hcd; } res = platform_get_resource(pdev, IORESOURCE_MEM, 0); if (!res) { dev_err(&pdev->dev, "Unable to get memory resource\n"); ret = -ENODEV; goto put_hcd; } hcd->rsrc_start = res->start; hcd->rsrc_len = resource_size(res); hcd->regs = ioremap(hcd->rsrc_start, hcd->rsrc_len); if (!hcd->regs) { dev_err(&pdev->dev, "ioremap failed\n"); ret = -ENOMEM; goto put_hcd; } mhcd = hcd_to_mhcd(hcd); mhcd->dev = &pdev->dev; spin_lock_init(&mhcd->wakeup_lock); mhcd->async_irq = platform_get_irq_byname(pdev, "async_irq"); if (mhcd->async_irq < 0) { dev_dbg(&pdev->dev, "platform_get_irq for async_int failed\n"); mhcd->async_irq = 0; } else { ret = request_irq(mhcd->async_irq, msm_async_irq, IRQF_TRIGGER_RISING, "msm_ehci_host", mhcd); if (ret) { dev_err(&pdev->dev, "request irq failed (ASYNC INT)\n"); goto unmap; } disable_irq(mhcd->async_irq); } snprintf(pdev_name, PDEV_NAME_LEN, "%s.%d", pdev->name, pdev->id); mhcd->xo_clk = clk_get(&pdev->dev, "xo"); if (!IS_ERR(mhcd->xo_clk)) { ret = clk_prepare_enable(mhcd->xo_clk); } else { mhcd->xo_handle = msm_xo_get(MSM_XO_TCXO_D0, pdev_name); if (IS_ERR(mhcd->xo_handle)) { dev_err(&pdev->dev, "%s fail to get handle for X0 D0\n", __func__); ret = PTR_ERR(mhcd->xo_handle); goto free_async_irq; } else { ret = msm_xo_mode_vote(mhcd->xo_handle, MSM_XO_MODE_ON); } } if (ret) { dev_err(&pdev->dev, "%s failed to vote for TCXO %d\n", __func__, ret); goto free_xo_handle; } if (pdev->dev.of_node) { res_gpio = of_get_named_gpio(pdev->dev.of_node, "usb2,resume-gpio", 0); if (res_gpio < 0){ res_gpio = 0; goto devote_xo_handle; } mhcd->resume_gpio = res_gpio; gpio_request(mhcd->resume_gpio, "USB2_RESUME"); } else { res = platform_get_resource_byname(pdev, IORESOURCE_IO, "resume_gpio"); if (res) { dev_dbg(&pdev->dev, "resume_gpio:%d\n", res->start); mhcd->resume_gpio = res->start; } } if(pdev->dev.of_node){ res_gpio = of_get_named_gpio(pdev->dev.of_node, "usb2,wakeup-gpio", 0); if (res_gpio < 0){ res_gpio = 0; goto devote_xo_handle; } mhcd->wakeup_gpio = res_gpio; } else { res = platform_get_resource_byname(pdev, IORESOURCE_IO, "wakeup_gpio"); if (res) { dev_dbg(&pdev->dev, "wakeup gpio:%d\n", res->start); mhcd->wakeup_gpio = res->start; } } if (pdev->dev.of_node) mhcd->wakeup_irq = gpio_to_irq(mhcd->wakeup_gpio); else mhcd->wakeup_irq = platform_get_irq_byname(pdev, "wakeup_irq"); if (mhcd->wakeup_irq > 0) { dev_dbg(&pdev->dev, "wakeup irq:%d\n", res->start); irq_set_status_flags(mhcd->wakeup_irq, IRQ_NOAUTOEN); ret = request_irq(mhcd->wakeup_irq, msm_hsusb_wakeup_irq, IRQF_TRIGGER_HIGH, "msm_hsusb_wakeup", mhcd); if (ret) { dev_err(&pdev->dev, "request_irq(%d) failed:%d\n", mhcd->wakeup_irq, ret); mhcd->wakeup_irq = 0; } } else { mhcd->wakeup_irq = 0; } spin_lock_init(&mhcd->wakeup_lock); ret = msm_ehci_init_clocks(mhcd, 1); if (ret) { dev_err(&pdev->dev, "unable to initialize clocks\n"); ret = -ENODEV; goto devote_xo_handle; } ret = msm_ehci_init_vddcx(mhcd, 1); if (ret) { dev_err(&pdev->dev, "unable to initialize VDDCX\n"); ret = -ENODEV; goto deinit_clocks; } ret = msm_ehci_config_vddcx(mhcd, 1); if (ret) { dev_err(&pdev->dev, "hsusb vddcx configuration failed\n"); goto deinit_vddcx; } ret = msm_ehci_ldo_init(mhcd, 1); if (ret) { dev_err(&pdev->dev, "hsusb vreg configuration failed\n"); goto deinit_vddcx; } ret = msm_ehci_ldo_enable(mhcd, 1); if (ret) { dev_err(&pdev->dev, "hsusb vreg enable failed\n"); goto deinit_ldo; } ret = msm_ehci_init_vbus(mhcd, 1); if (ret) { dev_err(&pdev->dev, "unable to get vbus\n"); goto disable_ldo; } pdata = mhcd->dev->platform_data; if (pdata && pdata->use_sec_phy) mhcd->usb_phy_ctrl_reg = USB_PHY_CTRL2; else mhcd->usb_phy_ctrl_reg = USB_PHY_CTRL; ret = msm_hsusb_reset(mhcd); if (ret) { dev_err(&pdev->dev, "hsusb PHY initialization failed\n"); goto vbus_deinit; } if( pdata && pdata->phy_sof_workaround) { /* defer bus suspend until RH suspend */ mhcd->ehci.susp_sof_bug = 1; mhcd->ehci.resume_sof_bug = 1; } ret = usb_add_hcd(hcd, hcd->irq, IRQF_SHARED); if (ret) { dev_err(&pdev->dev, "unable to register HCD\n"); goto vbus_deinit; } if (pdata && (!pdata->dock_connect_irq || !irq_read_line(pdata->dock_connect_irq))) msm_ehci_vbus_power(mhcd, 1); device_init_wakeup(&pdev->dev, 1); wake_lock_init(&mhcd->wlock, WAKE_LOCK_SUSPEND, dev_name(&pdev->dev)); wake_lock(&mhcd->wlock); INIT_WORK(&mhcd->phy_susp_fail_work, msm_ehci_phy_susp_fail_work); /* * This pdev->dev is assigned parent of root-hub by USB core, * hence, runtime framework automatically calls this driver's * runtime APIs based on root-hub's state. */ /* configure pmic_gpio_irq for D+ change */ if (pdata && pdata->pmic_gpio_dp_irq) mhcd->pmic_gpio_dp_irq = pdata->pmic_gpio_dp_irq; if (mhcd->pmic_gpio_dp_irq) { ret = request_threaded_irq(mhcd->pmic_gpio_dp_irq, NULL, msm_ehci_host_wakeup_irq, IRQF_TRIGGER_RISING | IRQF_TRIGGER_FALLING, "msm_ehci_host_wakeup", mhcd); if (!ret) { disable_irq_nosync(mhcd->pmic_gpio_dp_irq); } else { dev_err(&pdev->dev, "request_irq(%d) failed: %d\n", mhcd->pmic_gpio_dp_irq, ret); mhcd->pmic_gpio_dp_irq = 0; } } if (pdata && pdata->pd_rework_installed) mhcd->flags |= ALLOW_EHCI_RETENTION; pm_runtime_set_active(&pdev->dev); pm_runtime_enable(&pdev->dev); return 0; vbus_deinit: msm_ehci_init_vbus(mhcd, 0); disable_ldo: msm_ehci_ldo_enable(mhcd, 0); deinit_ldo: msm_ehci_ldo_init(mhcd, 0); deinit_vddcx: msm_ehci_init_vddcx(mhcd, 0); deinit_clocks: msm_ehci_init_clocks(mhcd, 0); devote_xo_handle: if (!IS_ERR(mhcd->xo_clk)) clk_disable_unprepare(mhcd->xo_clk); else msm_xo_mode_vote(mhcd->xo_handle, MSM_XO_MODE_OFF); if(mhcd->wakeup_irq) free_irq(mhcd->wakeup_irq, mhcd); if(mhcd->resume_gpio) gpio_free(mhcd->resume_gpio); free_xo_handle: if (!IS_ERR(mhcd->xo_clk)) clk_put(mhcd->xo_clk); else msm_xo_put(mhcd->xo_handle); free_async_irq: if (mhcd->async_irq) free_irq(mhcd->async_irq, mhcd); unmap: iounmap(hcd->regs); put_hcd: usb_put_hcd(hcd); return ret; }
static int pn547_probe(struct i2c_client *client, const struct i2c_device_id *id) { int ret; int err; struct pn547_i2c_platform_data *platform_data; struct pn547_dev *pn547_dev; if (client->dev.of_node) { platform_data = devm_kzalloc(&client->dev, sizeof(struct pn547_i2c_platform_data), GFP_KERNEL); if (!platform_data) { dev_err(&client->dev, "Failed to allocate memory\n"); return -ENOMEM; } err = pn547_parse_dt(&client->dev, platform_data); if (err) return err; } else { platform_data = client->dev.platform_data; } if (platform_data == NULL) { pr_err("%s : nfc probe fail\n", __func__); return -ENODEV; } if (!i2c_check_functionality(client->adapter, I2C_FUNC_I2C)) { pr_err("%s : need I2C_FUNC_I2C\n", __func__); return -ENODEV; } ret = gpio_request(platform_data->irq_gpio, "nfc_int"); if (ret) return -ENODEV; ret = gpio_request(platform_data->ven_gpio, "nfc_ven"); if (ret) goto err_ven; ret = gpio_request(platform_data->firm_gpio, "nfc_firm"); if (ret) goto err_firm; #ifdef CONFIG_NFC_PN547_CLOCK_REQUEST ret = gpio_request(platform_data->clk_req_gpio, "nfc_clk_req"); if (ret) goto err_clk_req; #endif pn547_dev = kzalloc(sizeof(*pn547_dev), GFP_KERNEL); if (pn547_dev == NULL) { dev_err(&client->dev, "failed to allocate memory for module data\n"); ret = -ENOMEM; goto err_exit; } #ifdef CONFIG_NFC_PN547_CLOCK_REQUEST pn547_dev->nfc_clock = msm_xo_get(MSM_XO_TCXO_A1, "nfc"); if (IS_ERR(pn547_dev->nfc_clock)) { ret = PTR_ERR(pn547_dev->nfc_clock); printk(KERN_ERR "%s: Couldn't get TCXO_A1 vote for NFC (%d)\n", __func__, ret); ret = -ENODEV; goto err_get_clock; } pn547_dev->clock_state = false; #endif #ifdef CONFIG_NFC_PN547_8941_CLOCK_REQUEST pn547_dev->nfc_clk = clk_get(NULL, "nfc_clk"); if (IS_ERR(pn547_dev->nfc_clk)) { ret = PTR_ERR(pn547_dev->nfc_clk); printk(KERN_ERR "%s: Couldn't get D1 (%d)\n", __func__, ret); } else { if (clk_prepare_enable(pn547_dev->nfc_clk)) printk(KERN_ERR "%s: Couldn't prepare D1\n", __func__); } #endif pr_info("%s : IRQ num %d\n", __func__, client->irq); pn547_dev->irq_gpio = platform_data->irq_gpio; pn547_dev->ven_gpio = platform_data->ven_gpio; pn547_dev->firm_gpio = platform_data->firm_gpio; pn547_dev->conf_gpio = platform_data->conf_gpio; #ifdef CONFIG_NFC_PN547_CLOCK_REQUEST pn547_dev->clk_req_gpio = platform_data->clk_req_gpio; pn547_dev->clk_req_irq = platform_data->clk_req_irq; #endif pn547_dev->client = client; /* init mutex and queues */ init_waitqueue_head(&pn547_dev->read_wq); mutex_init(&pn547_dev->read_mutex); pn547_dev->pn547_device.minor = MISC_DYNAMIC_MINOR; #ifdef CONFIG_NFC_PN547 pn547_dev->pn547_device.name = "pn547"; #else pn547_dev->pn547_device.name = "pn544"; #endif pn547_dev->pn547_device.fops = &pn547_dev_fops; ret = misc_register(&pn547_dev->pn547_device); if (ret) { pr_err("%s : misc_register failed\n", __FILE__); goto err_misc_register; } /* request irq. the irq is set whenever the chip has data available * for reading. it is cleared when all data has been read. */ pr_info("%s : requesting IRQ %d\n", __func__, client->irq); gpio_direction_input(pn547_dev->irq_gpio); gpio_direction_output(pn547_dev->ven_gpio, 0); gpio_direction_output(pn547_dev->firm_gpio, 0); #ifdef CONFIG_NFC_PN547_CLOCK_REQUEST gpio_direction_input(pn547_dev->clk_req_gpio); #endif i2c_set_clientdata(client, pn547_dev); wake_lock_init(&pn547_dev->nfc_wake_lock, WAKE_LOCK_SUSPEND, "nfc_wake_lock"); #ifdef CONFIG_NFC_PN547_CLOCK_REQUEST pn547_dev->wq_clock = create_singlethread_workqueue("nfc_wq"); if (!pn547_dev->wq_clock) { ret = -ENOMEM; pr_err("%s: could not create workqueue\n", __func__); goto err_create_workqueue; } INIT_WORK(&pn547_dev->work_nfc_clock, nfc_work_func_clock); #endif ret = request_irq(client->irq, pn547_dev_irq_handler, IRQF_TRIGGER_RISING, "pn547", pn547_dev); if (ret) { dev_err(&client->dev, "request_irq failed\n"); goto err_request_irq_failed; } disable_irq_nosync(pn547_dev->client->irq); atomic_set(&pn547_dev->irq_enabled, 0); #ifdef CONFIG_NFC_PN547_CLOCK_REQUEST ret = request_irq(pn547_dev->clk_req_irq, pn547_dev_clk_req_irq_handler, IRQF_SHARED | IRQF_TRIGGER_RISING | IRQF_TRIGGER_FALLING , "pn547_clk_req", pn547_dev); if (ret) { dev_err(&client->dev, "request_irq(clk_req) failed\n"); goto err_request_irq_failed; } enable_irq_wake(pn547_dev->clk_req_irq); #endif pr_info("%s : success\n", __func__); return 0; err_request_irq_failed: #ifdef CONFIG_NFC_PN547_CLOCK_REQUEST err_create_workqueue: #endif misc_deregister(&pn547_dev->pn547_device); wake_lock_destroy(&pn547_dev->nfc_wake_lock); err_misc_register: mutex_destroy(&pn547_dev->read_mutex); #ifdef CONFIG_NFC_PN547_CLOCK_REQUEST msm_xo_put(pn547_dev->nfc_clock); err_get_clock: #endif kfree(pn547_dev); err_exit: #ifdef CONFIG_NFC_PN547_CLOCK_REQUEST gpio_free(platform_data->clk_req_gpio); err_clk_req: #endif gpio_free(platform_data->firm_gpio); err_firm: gpio_free(platform_data->ven_gpio); err_ven: gpio_free(platform_data->irq_gpio); pr_err("[pn547] pn547_probe fail!\n"); return ret; }
static int __devinit pil_q6v4_driver_probe(struct platform_device *pdev) { const struct pil_q6v4_pdata *pdata = pdev->dev.platform_data; struct q6v4_data *drv; struct resource *res; struct pil_desc *desc; int ret; res = platform_get_resource(pdev, IORESOURCE_MEM, 0); if (!res) return -EINVAL; drv = devm_kzalloc(&pdev->dev, sizeof(*drv), GFP_KERNEL); if (!drv) return -ENOMEM; platform_set_drvdata(pdev, drv); drv->base = devm_ioremap(&pdev->dev, res->start, resource_size(res)); if (!drv->base) return -ENOMEM; res = platform_get_resource(pdev, IORESOURCE_MEM, 1); if (res) { drv->modem_base = devm_ioremap(&pdev->dev, res->start, resource_size(res)); if (!drv->modem_base) return -ENOMEM; } desc = devm_kzalloc(&pdev->dev, sizeof(*desc), GFP_KERNEL); if (!desc) return -ENOMEM; drv->pll_supply = devm_regulator_get(&pdev->dev, "pll_vdd"); if (IS_ERR(drv->pll_supply)) { drv->pll_supply = NULL; } else { ret = regulator_set_voltage(drv->pll_supply, 1800000, 1800000); if (ret) { dev_err(&pdev->dev, "failed to set pll voltage\n"); return ret; } ret = regulator_set_optimum_mode(drv->pll_supply, 100000); if (ret < 0) { dev_err(&pdev->dev, "failed to set pll optimum mode\n"); return ret; } } desc->name = pdata->name; desc->depends_on = pdata->depends; desc->dev = &pdev->dev; desc->owner = THIS_MODULE; desc->proxy_timeout = 10000; if (pas_supported(pdata->pas_id) > 0) { desc->ops = &pil_q6v4_ops_trusted; dev_info(&pdev->dev, "using secure boot\n"); } else { desc->ops = &pil_q6v4_ops; dev_info(&pdev->dev, "using non-secure boot\n"); } drv->vreg = devm_regulator_get(&pdev->dev, "core_vdd"); if (IS_ERR(drv->vreg)) return PTR_ERR(drv->vreg); ret = regulator_set_optimum_mode(drv->vreg, 100000); if (ret < 0) { dev_err(&pdev->dev, "Failed to set regulator's mode.\n"); return ret; } drv->xo = devm_clk_get(&pdev->dev, "xo"); if (IS_ERR(drv->xo)) return PTR_ERR(drv->xo); if (pdata->xo1_id) { drv->xo1 = msm_xo_get(pdata->xo1_id, pdata->name); if (IS_ERR(drv->xo1)) return PTR_ERR(drv->xo1); } if (pdata->xo2_id) { drv->xo2 = msm_xo_get(pdata->xo2_id, pdata->name); if (IS_ERR(drv->xo2)) { msm_xo_put(drv->xo1); return PTR_ERR(drv->xo2); } } drv->pil = msm_pil_register(desc); if (IS_ERR(drv->pil)) { msm_xo_put(drv->xo2); msm_xo_put(drv->xo1); return PTR_ERR(drv->pil); } return 0; }
static int ehci_msm2_probe(struct platform_device *pdev) { struct usb_hcd *hcd; struct resource *res; struct msm_hcd *mhcd; const struct msm_usb_host_platform_data *pdata; char pdev_name[PDEV_NAME_LEN]; int ret; dev_dbg(&pdev->dev, "ehci_msm2 probe\n"); hcd = usb_create_hcd(&ehci_msm2_hc_driver, &pdev->dev, dev_name(&pdev->dev)); if (!hcd) { dev_err(&pdev->dev, "Unable to create HCD\n"); return -ENOMEM; } mhcd = hcd_to_mhcd(hcd); mhcd->dev = &pdev->dev; mhcd->xo_clk = clk_get(&pdev->dev, "xo"); if (IS_ERR(mhcd->xo_clk)) { ret = PTR_ERR(mhcd->xo_clk); mhcd->xo_clk = NULL; if (ret == -EPROBE_DEFER) goto put_hcd; } ret = msm_ehci_init_clocks(mhcd, 1); if (ret) goto xo_put; if (pdev->dev.of_node) { dev_dbg(&pdev->dev, "device tree enabled\n"); pdev->dev.platform_data = ehci_msm2_dt_to_pdata(pdev); } if (!pdev->dev.platform_data) dev_dbg(&pdev->dev, "No platform data given\n"); pdata = pdev->dev.platform_data; if (!pdev->dev.dma_mask) pdev->dev.dma_mask = &ehci_msm_dma_mask; if (!pdev->dev.coherent_dma_mask) pdev->dev.coherent_dma_mask = DMA_BIT_MASK(32); hcd_to_bus(hcd)->skip_resume = true; hcd->irq = platform_get_irq(pdev, 0); if (hcd->irq < 0) { dev_err(&pdev->dev, "Unable to get IRQ resource\n"); ret = hcd->irq; goto deinit_clocks; } res = platform_get_resource(pdev, IORESOURCE_MEM, 0); if (!res) { dev_err(&pdev->dev, "Unable to get memory resource\n"); ret = -ENODEV; goto deinit_clocks; } hcd->rsrc_start = res->start; hcd->rsrc_len = resource_size(res); hcd->regs = ioremap(hcd->rsrc_start, hcd->rsrc_len); if (!hcd->regs) { dev_err(&pdev->dev, "ioremap failed\n"); ret = -ENOMEM; goto deinit_clocks; } spin_lock_init(&mhcd->wakeup_lock); mhcd->async_irq = platform_get_irq_byname(pdev, "async_irq"); if (mhcd->async_irq < 0) { dev_dbg(&pdev->dev, "platform_get_irq for async_int failed\n"); mhcd->async_irq = 0; } else { ret = request_irq(mhcd->async_irq, msm_async_irq, IRQF_TRIGGER_RISING, "msm_ehci_host", mhcd); if (ret) { dev_err(&pdev->dev, "request irq failed (ASYNC INT)\n"); goto unmap; } disable_irq(mhcd->async_irq); } snprintf(pdev_name, PDEV_NAME_LEN, "%s.%d", pdev->name, pdev->id); if (mhcd->xo_clk) { ret = clk_prepare_enable(mhcd->xo_clk); } else { mhcd->xo_handle = msm_xo_get(MSM_XO_TCXO_D0, pdev_name); if (IS_ERR(mhcd->xo_handle)) { dev_err(&pdev->dev, "%s fail to get handle for X0 D0\n", __func__); ret = PTR_ERR(mhcd->xo_handle); mhcd->xo_handle = NULL; goto free_async_irq; } else { ret = msm_xo_mode_vote(mhcd->xo_handle, MSM_XO_MODE_ON); } } if (ret) { dev_err(&pdev->dev, "%s failed to vote for TCXO %d\n", __func__, ret); goto free_xo_handle; } if (pdata && gpio_is_valid(pdata->resume_gpio)) { mhcd->resume_gpio = pdata->resume_gpio; ret = devm_gpio_request(&pdev->dev, mhcd->resume_gpio, "hsusb_resume"); if (ret) { dev_err(&pdev->dev, "resume gpio(%d) request failed:%d\n", mhcd->resume_gpio, ret); mhcd->resume_gpio = -EINVAL; } else { /* to override ehci_bus_resume from ehci-hcd library */ ehci_bus_resume_func = ehci_msm2_hc_driver.bus_resume; ehci_msm2_hc_driver.bus_resume = msm_ehci_bus_resume_with_gpio; } } if (pdata && gpio_is_valid(pdata->ext_hub_reset_gpio)) { ret = devm_gpio_request(&pdev->dev, pdata->ext_hub_reset_gpio, "hsusb_reset"); if (ret) { dev_err(&pdev->dev, "reset gpio(%d) request failed:%d\n", pdata->ext_hub_reset_gpio, ret); goto devote_xo_handle; } else { /* reset external hub */ gpio_direction_output(pdata->ext_hub_reset_gpio, 0); /* * Hub reset should be asserted for minimum 5microsec * before deasserting. */ usleep_range(5, 1000); gpio_direction_output(pdata->ext_hub_reset_gpio, 1); } } spin_lock_init(&mhcd->wakeup_lock); ret = msm_ehci_init_vddcx(mhcd, 1); if (ret) { dev_err(&pdev->dev, "unable to initialize VDDCX\n"); ret = -ENODEV; goto devote_xo_handle; } ret = msm_ehci_config_vddcx(mhcd, 1); if (ret) { dev_err(&pdev->dev, "hsusb vddcx configuration failed\n"); goto devote_xo_handle; } ret = msm_ehci_ldo_init(mhcd, 1); if (ret) { dev_err(&pdev->dev, "hsusb vreg configuration failed\n"); goto deinit_vddcx; } ret = msm_ehci_ldo_enable(mhcd, 1); if (ret) { dev_err(&pdev->dev, "hsusb vreg enable failed\n"); goto deinit_ldo; } ret = msm_ehci_init_vbus(mhcd, 1); if (ret) { dev_err(&pdev->dev, "unable to get vbus\n"); goto disable_ldo; } if (pdata && pdata->use_sec_phy) mhcd->usb_phy_ctrl_reg = USB_PHY_CTRL2; else mhcd->usb_phy_ctrl_reg = USB_PHY_CTRL; ret = msm_hsusb_reset(mhcd); if (ret) { dev_err(&pdev->dev, "hsusb PHY initialization failed\n"); goto vbus_deinit; } ret = usb_add_hcd(hcd, hcd->irq, IRQF_SHARED); if (ret) { dev_err(&pdev->dev, "unable to register HCD\n"); goto vbus_deinit; } pdata = mhcd->dev->platform_data; if (pdata && (!pdata->dock_connect_irq || !irq_read_line(pdata->dock_connect_irq))) msm_ehci_vbus_power(mhcd, 1); /* For peripherals directly conneted to downstream port of root hub * and require to drive suspend and resume by controller driver instead * of root hub. */ if (pdata) mhcd->ehci.no_selective_suspend = pdata->no_selective_suspend; mhcd->wakeup_irq = platform_get_irq_byname(pdev, "wakeup_irq"); if (mhcd->wakeup_irq > 0) { dev_dbg(&pdev->dev, "wakeup irq:%d\n", mhcd->wakeup_irq); irq_set_status_flags(mhcd->wakeup_irq, IRQ_NOAUTOEN); ret = request_irq(mhcd->wakeup_irq, msm_hsusb_wakeup_irq, IRQF_TRIGGER_HIGH, "msm_hsusb_wakeup", mhcd); if (ret) { dev_err(&pdev->dev, "request_irq(%d) failed:%d\n", mhcd->wakeup_irq, ret); mhcd->wakeup_irq = 0; } } else { mhcd->wakeup_irq = 0; } device_init_wakeup(&pdev->dev, 1); wakeup_source_init(&mhcd->ws, dev_name(&pdev->dev)); pm_stay_awake(mhcd->dev); INIT_WORK(&mhcd->phy_susp_fail_work, msm_ehci_phy_susp_fail_work); /* * This pdev->dev is assigned parent of root-hub by USB core, * hence, runtime framework automatically calls this driver's * runtime APIs based on root-hub's state. */ /* configure pmic_gpio_irq for D+ change */ if (pdata && pdata->pmic_gpio_dp_irq) mhcd->pmic_gpio_dp_irq = pdata->pmic_gpio_dp_irq; if (mhcd->pmic_gpio_dp_irq) { ret = request_threaded_irq(mhcd->pmic_gpio_dp_irq, NULL, msm_ehci_host_wakeup_irq, IRQF_TRIGGER_RISING | IRQF_TRIGGER_FALLING, "msm_ehci_host_wakeup", mhcd); if (!ret) { disable_irq_nosync(mhcd->pmic_gpio_dp_irq); } else { dev_err(&pdev->dev, "request_irq(%d) failed: %d\n", mhcd->pmic_gpio_dp_irq, ret); mhcd->pmic_gpio_dp_irq = 0; } } pm_runtime_set_active(&pdev->dev); pm_runtime_enable(&pdev->dev); if (ehci_debugfs_init(mhcd) < 0) dev_err(mhcd->dev, "%s: debugfs init failed\n", __func__); return 0; vbus_deinit: msm_ehci_init_vbus(mhcd, 0); disable_ldo: msm_ehci_ldo_enable(mhcd, 0); deinit_ldo: msm_ehci_ldo_init(mhcd, 0); deinit_vddcx: msm_ehci_init_vddcx(mhcd, 0); devote_xo_handle: if (mhcd->xo_clk) clk_disable_unprepare(mhcd->xo_clk); else msm_xo_mode_vote(mhcd->xo_handle, MSM_XO_MODE_OFF); free_xo_handle: if (mhcd->xo_clk) { clk_put(mhcd->xo_clk); mhcd->xo_clk = NULL; } else { msm_xo_put(mhcd->xo_handle); } free_async_irq: if (mhcd->async_irq) free_irq(mhcd->async_irq, mhcd); unmap: iounmap(hcd->regs); deinit_clocks: msm_ehci_init_clocks(mhcd, 0); xo_put: if (mhcd->xo_clk) clk_put(mhcd->xo_clk); put_hcd: usb_put_hcd(hcd); return ret; }