[RFC PATCH 17/18] wifi: ath12k: add AHB driver support for IPQ5332
Krzysztof Kozlowski
krzk at kernel.org
Thu Aug 15 22:47:50 PDT 2024
On 14/08/2024 11:43, Raj Kumar Bhagat wrote:
> From: Balamurugan S <quic_bselvara at quicinc.com>
>
> Add Initial Ath12k AHB driver support for IPQ5332. IPQ5332 is AHB
> based IEEE802.11be 2 GHz 2x2 WiFi device.
>
> Tested-on: IPQ5332 hw1.0 AHB WLAN.WBE.1.3.1-00130-QCAHKSWPL_SILICONZ-1
> Tested-on: QCN9274 hw2.0 PCI WLAN.WBE.1.1.1-00210-QCAHKSWPL_SILICONZ-1
>
> Signed-off-by: Balamurugan S <quic_bselvara at quicinc.com>
> Co-developed-by: P Praneesh <quic_ppranees at quicinc.com>
> Signed-off-by: P Praneesh <quic_ppranees at quicinc.com>
> Co-developed-by: Raj Kumar Bhagat <quic_rajkbhag at quicinc.com>
> Signed-off-by: Raj Kumar Bhagat <quic_rajkbhag at quicinc.com>
> ---
...
> +
> + of_id = of_match_device(ath12k_ahb_of_match, &pdev->dev);
> + if (!of_id) {
> + dev_err(&pdev->dev, "Failed to find matching device tree id\n");
> + return -EINVAL;
> + }
> +
> + hw_rev = (enum ath12k_hw_rev)of_id->data;
Just use wrapper to get match data.
> +
> + switch (hw_rev) {
> + case ATH12K_HW_IPQ5332_HW10:
> + hif_ops = &ath12k_ahb_hif_ops_ipq5332;
> + break;
> + default:
> + dev_err(&pdev->dev, "Unsupported device type %d\n", hw_rev);
> + return -EOPNOTSUPP;
> + }
> +
> + ret = dma_set_mask_and_coherent(&pdev->dev, DMA_BIT_MASK(32));
> + if (ret) {
> + dev_err(&pdev->dev, "Failed to set 32-bit consistent dma\n");
> + return ret;
> + }
> +
> + ab = ath12k_core_alloc(&pdev->dev, sizeof(struct ath12k_ahb),
> + ATH12K_BUS_AHB);
> + if (!ab) {
> + dev_err(&pdev->dev, "failed to allocate ath12k base\n");
> + return -ENOMEM;
> + }
> +
> + ab->hif.ops = hif_ops;
> + ab->pdev = pdev;
> + ab->hw_rev = hw_rev;
> + platform_set_drvdata(pdev, ab);
> +
> + /* Set fixed_mem_region to true for platforms that support fixed memory
> + * reservation from DT. If memory is reserved from DT for FW, ath12k driver
> + * need not to allocate memory.
> + */
> + if (!of_property_read_u32(ab->dev->of_node, "memory-region", &addr)) {
> + set_bit(ATH12K_FLAG_FIXED_MEM_REGION, &ab->dev_flags);
> + mem_node = of_find_node_by_name(NULL, "mlo_global_mem_0");
> + if (!mem_node)
> + ab->mlo_capable_flags = 0;
> + }
> +
> + ret = ath12k_core_pre_init(ab);
> + if (ret)
> + goto err_core_free;
> +
> + ret = ath12k_ahb_resource_init(ab);
> + if (ret)
> + goto err_core_free;
> +
> + ret = ath12k_hal_srng_init(ab);
> + if (ret)
> + goto err_resource_deinit;
> +
> + ret = ath12k_ce_alloc_pipes(ab);
> + if (ret) {
> + ath12k_err(ab, "failed to allocate ce pipes: %d\n", ret);
> + goto err_hal_srng_deinit;
> + }
> +
> + ath12k_ahb_init_qmi_ce_config(ab);
> +
> + ret = ath12k_core_get_rproc(ab);
> + if (ret) {
> + ath12k_err(ab, "failed to get rproc: %d\n", ret);
> + goto err_ce_free;
> + }
> +
> + ret = ath12k_ahb_config_irq(ab);
> + if (ret) {
> + ath12k_err(ab, "failed to configure irq: %d\n", ret);
> + goto err_ce_free;
> + }
> +
> + ret = ath12k_core_init(ab);
> + if (ret) {
> + ath12k_err(ab, "failed to init core: %d\n", ret);
> + goto err_ce_free;
> + }
> +
> + return 0;
> +
> +err_ce_free:
> + ath12k_ce_free_pipes(ab);
> +
> +err_hal_srng_deinit:
> + ath12k_hal_srng_deinit(ab);
> +
> +err_resource_deinit:
> + ath12k_ahb_resource_deinit(ab);
> +
> +err_core_free:
> + ath12k_core_free(ab);
> + platform_set_drvdata(pdev, NULL);
> +
> + return ret;
> +}
> +
> +static void ath12k_ahb_remove_prepare(struct ath12k_base *ab)
> +{
> + unsigned long left;
> +
> + if (test_bit(ATH12K_FLAG_RECOVERY, &ab->dev_flags)) {
> + left = wait_for_completion_timeout(&ab->driver_recovery,
> + ATH12K_AHB_RECOVERY_TIMEOUT);
> + if (!left)
> + ath12k_warn(ab, "failed to receive recovery response completion\n");
> + }
> +
> + set_bit(ATH12K_FLAG_UNREGISTERING, &ab->dev_flags);
> + cancel_work_sync(&ab->restart_work);
> + cancel_work_sync(&ab->qmi.event_work);
> +}
> +
> +static void ath12k_ahb_free_resources(struct ath12k_base *ab)
> +{
> + struct platform_device *pdev = ab->pdev;
> +
> + ath12k_ahb_free_irq(ab);
> + ath12k_hal_srng_deinit(ab);
> + ath12k_ce_free_pipes(ab);
> + ath12k_ahb_resource_deinit(ab);
> + ath12k_core_free(ab);
> + platform_set_drvdata(pdev, NULL);
> +}
> +
> +static void ath12k_ahb_remove(struct platform_device *pdev)
> +{
> + struct ath12k_base *ab = platform_get_drvdata(pdev);
> +
> + if (test_bit(ATH12K_FLAG_QMI_FAIL, &ab->dev_flags)) {
> + ath12k_ahb_power_down(ab, false);
> + ath12k_qmi_deinit_service(ab);
> + goto qmi_fail;
> + }
> +
> + ath12k_ahb_remove_prepare(ab);
> + ath12k_core_deinit(ab);
> +
> +qmi_fail:
> + ath12k_ahb_free_resources(ab);
> +}
> +
> +static void ath12k_ahb_shutdown(struct platform_device *pdev)
> +{
> + struct ath12k_base *ab = platform_get_drvdata(pdev);
> +
> + /* platform shutdown() & remove() are mutually exclusive.
> + * remove() is invoked during rmmod & shutdown() during
> + * system reboot/shutdown.
> + */
> + ath12k_ahb_remove_prepare(ab);
> +
> + if (!(test_bit(ATH12K_FLAG_REGISTERED, &ab->dev_flags)))
> + goto free_resources;
> +
> + ath12k_core_deinit(ab);
> +
> +free_resources:
> + ath12k_ahb_free_resources(ab);
Why? It's shutdown, we do not care about cleanup. Why do you need this
shutdown callback in the first place?
Best regards,
Krzysztof
More information about the ath12k
mailing list