static int wcnss_trigger_config(struct platform_device *pdev) { int ret; struct qcom_wcnss_opts *pdata; /* make sure we are only triggered once */ if (penv->triggered) return 0; penv->triggered = 1; /* initialize the WCNSS device configuration */ pdata = pdev->dev.platform_data; if (WCNSS_CONFIG_UNSPECIFIED == has_48mhz_xo) has_48mhz_xo = pdata->has_48mhz_xo; penv->wlan_config.use_48mhz_xo = has_48mhz_xo; penv->thermal_mitigation = 0; penv->gpios_5wire = platform_get_resource_byname(pdev, IORESOURCE_IO, "wcnss_gpios_5wire"); /* allocate 5-wire GPIO resources */ if (!penv->gpios_5wire) { dev_err(&pdev->dev, "insufficient IO resources\n"); ret = -ENOENT; goto fail_gpio_res; } /* Configure 5 wire GPIOs */ ret = wcnss_gpios_config(penv->gpios_5wire, true); if (ret) { dev_err(&pdev->dev, "WCNSS gpios config failed.\n"); goto fail_gpio_res; } /* power up the WCNSS */ ret = wcnss_wlan_power(&pdev->dev, &penv->wlan_config, WCNSS_WLAN_SWITCH_ON); if (ret) { dev_err(&pdev->dev, "WCNSS Power-up failed.\n"); goto fail_power; } /* trigger initialization of the WCNSS */ penv->pil = pil_get(WCNSS_PIL_DEVICE); if (IS_ERR(penv->pil)) { dev_err(&pdev->dev, "Peripheral Loader failed on WCNSS.\n"); ret = PTR_ERR(penv->pil); penv->pil = NULL; goto fail_pil; } /* allocate resources */ penv->mmio_res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "wcnss_mmio"); penv->tx_irq_res = platform_get_resource_byname(pdev, IORESOURCE_IRQ, "wcnss_wlantx_irq"); penv->rx_irq_res = platform_get_resource_byname(pdev, IORESOURCE_IRQ, "wcnss_wlanrx_irq"); if (!(penv->mmio_res && penv->tx_irq_res && penv->rx_irq_res)) { dev_err(&pdev->dev, "insufficient resources\n"); ret = -ENOENT; goto fail_res; } /* register sysfs entries */ ret = wcnss_create_sysfs(&pdev->dev); if (ret) goto fail_sysfs; return 0; fail_sysfs: fail_res: if (penv->pil) pil_put(penv->pil); fail_pil: wcnss_wlan_power(&pdev->dev, &penv->wlan_config, WCNSS_WLAN_SWITCH_OFF); fail_power: wcnss_gpios_config(penv->gpios_5wire, false); fail_gpio_res: kfree(penv); penv = NULL; return ret; }
static int wcnss_trigger_config(struct platform_device *pdev) { int ret; struct qcom_wcnss_opts *pdata; unsigned long wcnss_phys_addr; int size = 0; int has_pronto_hw = of_property_read_bool(pdev->dev.of_node, "qcom,has_pronto_hw"); /* make sure we are only triggered once */ if (penv->triggered) return 0; penv->triggered = 1; /* initialize the WCNSS device configuration */ pdata = pdev->dev.platform_data; if (WCNSS_CONFIG_UNSPECIFIED == has_48mhz_xo) { if (has_pronto_hw) { has_48mhz_xo = of_property_read_bool(pdev->dev.of_node, "qcom,has_48mhz_xo"); penv->wcnss_hw_type = WCNSS_PRONTO_HW; } else { penv->wcnss_hw_type = WCNSS_RIVA_HW; has_48mhz_xo = pdata->has_48mhz_xo; } } penv->wlan_config.use_48mhz_xo = has_48mhz_xo; penv->thermal_mitigation = 0; strlcpy(penv->wcnss_version, "INVALID", WCNSS_VERSION_LEN); /* Configure 5 wire GPIOs */ if (!has_pronto_hw) { penv->gpios_5wire = platform_get_resource_byname(pdev, IORESOURCE_IO, "wcnss_gpios_5wire"); /* allocate 5-wire GPIO resources */ if (!penv->gpios_5wire) { dev_err(&pdev->dev, "insufficient IO resources\n"); ret = -ENOENT; goto fail_gpio_res; } ret = wcnss_gpios_config(penv->gpios_5wire, true); } else ret = wcnss_pronto_gpios_config(&pdev->dev, true); if (ret) { dev_err(&pdev->dev, "WCNSS gpios config failed.\n"); goto fail_gpio_res; } /* power up the WCNSS */ ret = wcnss_wlan_power(&pdev->dev, &penv->wlan_config, WCNSS_WLAN_SWITCH_ON); if (ret) { dev_err(&pdev->dev, "WCNSS Power-up failed.\n"); goto fail_power; } /* trigger initialization of the WCNSS */ penv->pil = pil_get(WCNSS_PIL_DEVICE); if (IS_ERR(penv->pil)) { dev_err(&pdev->dev, "Peripheral Loader failed on WCNSS.\n"); ret = PTR_ERR(penv->pil); penv->pil = NULL; goto fail_pil; } /* allocate resources */ penv->mmio_res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "wcnss_mmio"); penv->tx_irq_res = platform_get_resource_byname(pdev, IORESOURCE_IRQ, "wcnss_wlantx_irq"); penv->rx_irq_res = platform_get_resource_byname(pdev, IORESOURCE_IRQ, "wcnss_wlanrx_irq"); if (!(penv->mmio_res && penv->tx_irq_res && penv->rx_irq_res)) { dev_err(&pdev->dev, "insufficient resources\n"); ret = -ENOENT; goto fail_res; } INIT_WORK(&penv->wcnssctrl_rx_work, wcnssctrl_rx_handler); INIT_WORK(&penv->wcnssctrl_version_work, wcnss_send_version_req); wake_lock_init(&penv->wcnss_wake_lock, WAKE_LOCK_SUSPEND, "wcnss"); if (wcnss_hardware_type() == WCNSS_PRONTO_HW) { size = 0x3000; wcnss_phys_addr = MSM_PRONTO_PHYS; } else { wcnss_phys_addr = MSM_RIVA_PHYS; size = SZ_256; } penv->msm_wcnss_base = ioremap(wcnss_phys_addr, size); if (!penv->msm_wcnss_base) { ret = -ENOMEM; pr_err("%s: ioremap wcnss physical failed\n", __func__); goto fail_wake; } return 0; fail_wake: wake_lock_destroy(&penv->wcnss_wake_lock); fail_res: if (penv->pil) pil_put(penv->pil); fail_pil: wcnss_wlan_power(&pdev->dev, &penv->wlan_config, WCNSS_WLAN_SWITCH_OFF); fail_power: if (has_pronto_hw) wcnss_pronto_gpios_config(&pdev->dev, false); else wcnss_gpios_config(penv->gpios_5wire, false); fail_gpio_res: kfree(penv); penv = NULL; return ret; }
static int wcnss_trigger_config(struct platform_device *pdev) { int ret; struct qcom_wcnss_opts *pdata; /* make sure we are only triggered once */ if (penv->triggered) return 0; penv->triggered = 1; /* initialize the WCNSS device configuration */ pdata = pdev->dev.platform_data; if (WCNSS_CONFIG_UNSPECIFIED == has_48mhz_xo) has_48mhz_xo = pdata->has_48mhz_xo; penv->wlan_config.use_48mhz_xo = has_48mhz_xo; penv->thermal_mitigation = 0; strlcpy(penv->wcnss_version, "INVALID", WCNSS_VERSION_LEN); penv->gpios_5wire = platform_get_resource_byname(pdev, IORESOURCE_IO, "wcnss_gpios_5wire"); /* allocate 5-wire GPIO resources */ if (!penv->gpios_5wire) { dev_err(&pdev->dev, "insufficient IO resources\n"); ret = -ENOENT; goto fail_gpio_res; } /* Configure 5 wire GPIOs */ ret = wcnss_gpios_config(penv->gpios_5wire, true); if (ret) { dev_err(&pdev->dev, "WCNSS gpios config failed.\n"); goto fail_gpio_res; } /* power up the WCNSS */ ret = wcnss_wlan_power(&pdev->dev, &penv->wlan_config, WCNSS_WLAN_SWITCH_ON); if (ret) { dev_err(&pdev->dev, "WCNSS Power-up failed.\n"); goto fail_power; } /* trigger initialization of the WCNSS */ penv->pil = pil_get(WCNSS_PIL_DEVICE); if (IS_ERR(penv->pil)) { dev_err(&pdev->dev, "Peripheral Loader failed on WCNSS.\n"); ret = PTR_ERR(penv->pil); penv->pil = NULL; goto fail_pil; } /* allocate resources */ penv->mmio_res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "wcnss_mmio"); penv->tx_irq_res = platform_get_resource_byname(pdev, IORESOURCE_IRQ, "wcnss_wlantx_irq"); penv->rx_irq_res = platform_get_resource_byname(pdev, IORESOURCE_IRQ, "wcnss_wlanrx_irq"); if (!(penv->mmio_res && penv->tx_irq_res && penv->rx_irq_res)) { dev_err(&pdev->dev, "insufficient resources\n"); ret = -ENOENT; goto fail_res; } INIT_WORK(&penv->wcnssctrl_rx_work, wcnssctrl_rx_handler); INIT_WORK(&penv->wcnssctrl_version_work, wcnss_send_version_req); INIT_WORK(&penv->wcnssctrl_nvbin_dnld_work, wcnss_nvbin_dnld_main); wake_lock_init(&penv->wcnss_wake_lock, WAKE_LOCK_SUSPEND, "wcnss"); penv->msm_wcnss_base = ioremap(MSM_RIVA_PHYS, SZ_256); if (!penv->msm_wcnss_base) { pr_err("%s: ioremap wcnss physical failed\n", __func__); goto fail_wake; } return 0; fail_wake: wake_lock_destroy(&penv->wcnss_wake_lock); fail_res: if (penv->pil) pil_put(penv->pil); fail_pil: wcnss_wlan_power(&pdev->dev, &penv->wlan_config, WCNSS_WLAN_SWITCH_OFF); fail_power: wcnss_gpios_config(penv->gpios_5wire, false); fail_gpio_res: kfree(penv); penv = NULL; return ret; }
static int wcnss_trigger_config(struct platform_device *pdev) { int ret; struct qcom_wcnss_opts *pdata; if (penv->triggered) return 0; penv->triggered = 1; pdata = pdev->dev.platform_data; if (WCNSS_CONFIG_UNSPECIFIED == has_48mhz_xo) has_48mhz_xo = pdata->has_48mhz_xo; penv->wlan_config.use_48mhz_xo = has_48mhz_xo; penv->thermal_mitigation = 0; penv->gpios_5wire = platform_get_resource_byname(pdev, IORESOURCE_IO, "wcnss_gpios_5wire"); if (!penv->gpios_5wire) { dev_err(&pdev->dev, "insufficient IO resources\n"); ret = -ENOENT; goto fail_gpio_res; } ret = wcnss_gpios_config(penv->gpios_5wire, true); if (ret) { dev_err(&pdev->dev, "WCNSS gpios config failed.\n"); goto fail_gpio_res; } ret = wcnss_wlan_power(&pdev->dev, &penv->wlan_config, WCNSS_WLAN_SWITCH_ON); if (ret) { dev_err(&pdev->dev, "WCNSS Power-up failed.\n"); goto fail_power; } penv->pil = pil_get(WCNSS_PIL_DEVICE); if (IS_ERR(penv->pil)) { dev_err(&pdev->dev, "Peripheral Loader failed on WCNSS.\n"); ret = PTR_ERR(penv->pil); penv->pil = NULL; goto fail_pil; } penv->mmio_res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "wcnss_mmio"); penv->tx_irq_res = platform_get_resource_byname(pdev, IORESOURCE_IRQ, "wcnss_wlantx_irq"); penv->rx_irq_res = platform_get_resource_byname(pdev, IORESOURCE_IRQ, "wcnss_wlanrx_irq"); if (!(penv->mmio_res && penv->tx_irq_res && penv->rx_irq_res)) { dev_err(&pdev->dev, "insufficient resources\n"); ret = -ENOENT; goto fail_res; } ret = wcnss_create_sysfs(&pdev->dev); if (ret) goto fail_sysfs; wake_lock_init(&penv->wcnss_wake_lock, WAKE_LOCK_SUSPEND, "wcnss"); penv->msm_wcnss_base = ioremap(MSM_RIVA_PHYS, SZ_256); if (!penv->msm_wcnss_base) { pr_err("%s: ioremap wcnss physical failed\n", __func__); goto fail_wake; } return 0; fail_wake: wake_lock_destroy(&penv->wcnss_wake_lock); fail_sysfs: fail_res: if (penv->pil) pil_put(penv->pil); fail_pil: wcnss_wlan_power(&pdev->dev, &penv->wlan_config, WCNSS_WLAN_SWITCH_OFF); fail_power: wcnss_gpios_config(penv->gpios_5wire, false); fail_gpio_res: kfree(penv); penv = NULL; return ret; }