Lines Matching +full:re +full:- +full:initialization
1 // SPDX-License-Identifier: GPL-2.0
3 /* Copyright (c) 2012-2018, The Linux Foundation. All rights reserved.
4 * Copyright (C) 2018-2024 Linaro Ltd.
51 * currently supported. Despite that, some resources--including routing
52 * tables and filter tables--are defined in this driver because they must
58 * well-defined communication layer between the AP subsystem and the IPA
101 * ipa_setup() - Set up IPA hardware
104 * Perform initialization that requires issuing immediate commands on
106 * and initialization, this function will be called when an SMP2P
115 struct device *dev = ipa->dev; in ipa_setup()
118 ret = gsi_setup(&ipa->gsi); in ipa_setup()
125 * initialization, so we enable first. in ipa_setup()
127 command_endpoint = ipa->name_map[IPA_ENDPOINT_AP_COMMAND_TX]; in ipa_setup()
143 exception_endpoint = ipa->name_map[IPA_ENDPOINT_AP_LAN_RX]; in ipa_setup()
148 ipa_endpoint_default_route_set(ipa, exception_endpoint->endpoint_id); in ipa_setup()
150 /* We're all set. Now prepare for communication with the modem */ in ipa_setup()
155 ipa->setup_complete = true; in ipa_setup()
168 gsi_teardown(&ipa->gsi); in ipa_setup()
174 * ipa_teardown() - Inverse of ipa_setup()
182 /* We're going to tear everything down, as if setup never completed */ in ipa_teardown()
183 ipa->setup_complete = false; in ipa_teardown()
187 exception_endpoint = ipa->name_map[IPA_ENDPOINT_AP_LAN_RX]; in ipa_teardown()
189 command_endpoint = ipa->name_map[IPA_ENDPOINT_AP_COMMAND_TX]; in ipa_teardown()
192 gsi_teardown(&ipa->gsi); in ipa_teardown()
202 if (ipa->version >= IPA_VERSION_4_5) in ipa_hardware_config_bcr()
206 val = data->backward_compat; in ipa_hardware_config_bcr()
207 iowrite32(val, ipa->reg_virt + reg_offset(reg)); in ipa_hardware_config_bcr()
212 enum ipa_version version = ipa->version; in ipa_hardware_config_tx()
224 val = ioread32(ipa->reg_virt + offset); in ipa_hardware_config_tx()
228 iowrite32(val, ipa->reg_virt + offset); in ipa_hardware_config_tx()
233 enum ipa_version version = ipa->version; in ipa_hardware_config_clkon()
254 iowrite32(val, ipa->reg_virt + reg_offset(reg)); in ipa_hardware_config_clkon()
265 if (ipa->version < IPA_VERSION_4_0) in ipa_hardware_config_comp()
271 val = ioread32(ipa->reg_virt + offset); in ipa_hardware_config_comp()
273 if (ipa->version == IPA_VERSION_4_0) { in ipa_hardware_config_comp()
277 } else if (ipa->version < IPA_VERSION_4_5) { in ipa_hardware_config_comp()
286 iowrite32(val, ipa->reg_virt + offset); in ipa_hardware_config_comp()
299 data0 = &data->qsb_data[IPA_QSB_MASTER_DDR]; in ipa_hardware_config_qsb()
300 if (data->qsb_count > 1) in ipa_hardware_config_qsb()
301 data1 = &data->qsb_data[IPA_QSB_MASTER_PCIE]; in ipa_hardware_config_qsb()
306 val = reg_encode(reg, GEN_QMB_0_MAX_WRITES, data0->max_writes); in ipa_hardware_config_qsb()
307 if (data->qsb_count > 1) in ipa_hardware_config_qsb()
308 val |= reg_encode(reg, GEN_QMB_1_MAX_WRITES, data1->max_writes); in ipa_hardware_config_qsb()
310 iowrite32(val, ipa->reg_virt + reg_offset(reg)); in ipa_hardware_config_qsb()
315 val = reg_encode(reg, GEN_QMB_0_MAX_READS, data0->max_reads); in ipa_hardware_config_qsb()
316 if (ipa->version >= IPA_VERSION_4_0) in ipa_hardware_config_qsb()
318 data0->max_reads_beats); in ipa_hardware_config_qsb()
319 if (data->qsb_count > 1) { in ipa_hardware_config_qsb()
320 val = reg_encode(reg, GEN_QMB_1_MAX_READS, data1->max_reads); in ipa_hardware_config_qsb()
321 if (ipa->version >= IPA_VERSION_4_0) in ipa_hardware_config_qsb()
323 data1->max_reads_beats); in ipa_hardware_config_qsb()
326 iowrite32(val, ipa->reg_virt + reg_offset(reg)); in ipa_hardware_config_qsb()
340 return DIV_ROUND_CLOSEST(usec * TIMER_FREQUENCY, USEC_PER_SEC) - 1; in ipa_aggr_granularity_val()
345 * Qtimer is based on a 56-bit timestamp incremented at each tick of
350 * some number of bits to produce the low-order bits of the coarser
357 * those used for aggregation or head-of-line block handling) now
368 iowrite32(0, ipa->reg_virt + reg_offset(reg)); in ipa_qtime_config()
371 if (ipa->version < IPA_VERSION_5_5) { in ipa_qtime_config()
380 iowrite32(val, ipa->reg_virt + reg_offset(reg)); in ipa_qtime_config()
386 if (ipa->version >= IPA_VERSION_5_0) { in ipa_qtime_config()
393 iowrite32(val, ipa->reg_virt + reg_offset(reg)); in ipa_qtime_config()
399 val = reg_encode(reg, DIV_VALUE, IPA_XO_CLOCK_DIVIDER - 1); in ipa_qtime_config()
401 iowrite32(val, ipa->reg_virt + offset); in ipa_qtime_config()
403 /* Divider value is set; re-enable the common timer clock divider */ in ipa_qtime_config()
406 iowrite32(val, ipa->reg_virt + offset); in ipa_qtime_config()
419 iowrite32(val, ipa->reg_virt + reg_offset(reg)); in ipa_hardware_config_counter()
424 if (ipa->version < IPA_VERSION_4_5) in ipa_hardware_config_timing()
439 if (ipa->version != IPA_VERSION_4_2) in ipa_hardware_config_hashing()
448 iowrite32(0, ipa->reg_virt + reg_offset(reg)); in ipa_hardware_config_hashing()
458 if (ipa->version < IPA_VERSION_3_5_1) in ipa_idle_indication_cfg()
467 iowrite32(val, ipa->reg_virt + reg_offset(reg)); in ipa_idle_indication_cfg()
471 * ipa_hardware_dcd_config() - Enable dynamic clock division on IPA
486 /* Power-on reset values */ in ipa_hardware_dcd_deconfig()
491 * ipa_hardware_config() - Primitive hardware initialization
508 * ipa_hardware_deconfig() - Inverse of ipa_hardware_config()
511 * This restores the power-on reset values (even if they aren't different)
520 * ipa_config() - Configure IPA hardware
524 * Perform initialization requiring IPA power to be enabled.
549 ret = ipa_resource_config(ipa, data->resource_data); in ipa_config()
573 * ipa_deconfig() - Inverse of ipa_config()
597 node = of_parse_phandle(dev->of_node, "memory-region", 0); in ipa_firmware_load()
599 dev_err(dev, "DT error getting \"memory-region\" property\n"); in ipa_firmware_load()
600 return -EINVAL; in ipa_firmware_load()
606 dev_err(dev, "error %d getting \"memory-region\" resource\n", in ipa_firmware_load()
612 ret = of_property_read_string(dev->of_node, "firmware-name", &path); in ipa_firmware_load()
614 dev_dbg(dev, "error %d getting \"firmware-name\" resource\n", in ipa_firmware_load()
630 ret = -ENOMEM; in ipa_firmware_load()
649 .compatible = "qcom,msm8998-ipa",
653 .compatible = "qcom,sdm845-ipa",
657 .compatible = "qcom,sc7180-ipa",
661 .compatible = "qcom,sdx55-ipa",
665 .compatible = "qcom,sm6350-ipa",
669 .compatible = "qcom,sm8350-ipa",
673 .compatible = "qcom,sc7280-ipa",
677 .compatible = "qcom,sdx65-ipa",
681 .compatible = "qcom,sm8550-ipa",
694 /* At one time we assumed a 64-bit build, allowing some do_div() in ipa_validate_build()
698 * of being a 64-bit value. (It should be guaranteed 32 bits wide in ipa_validate_build()
699 * on a 32-bit build, but there is no harm in verifying that.) in ipa_validate_build()
715 * TLV FIFO size. A transaction structure uses 8-bit fields in ipa_validate_build()
734 modem_init = of_property_read_bool(dev->of_node, "modem-init"); in ipa_firmware_loader()
735 ret = of_property_read_string(dev->of_node, "qcom,gsi-loader", &str); in ipa_firmware_loader()
738 if (ret == -EINVAL) { in ipa_firmware_loader()
772 * ipa_probe() - IPA platform driver probe function
778 * This is the main entry point for the IPA driver. Initialization proceeds
780 * - The "init" stage involves activities that can be initialized without
782 * - The "config" stage requires IPA power to be active so IPA registers
784 * - The "setup" stage uses IPA immediate commands, and so requires the GSI
787 * A Boolean Device Tree "modem-init" property determines whether GSI
788 * initialization will be performed by the AP (Trust Zone) or the modem.
789 * If the AP does GSI initialization, the setup phase is entered after
796 struct device *dev = &pdev->dev; in ipa_probe()
806 /* Get configuration data early; needed for power initialization */ in ipa_probe()
810 return -ENODEV; in ipa_probe()
813 if (!data->modem_route_count) { in ipa_probe()
815 return -EINVAL; in ipa_probe()
820 return -EINVAL; in ipa_probe()
822 return -EPROBE_DEFER; in ipa_probe()
824 /* The IPA interrupt might not be ready when we're probed, so this in ipa_probe()
825 * might return -EPROBE_DEFER. in ipa_probe()
831 /* The clock and interconnects might not be ready when we're probed, in ipa_probe()
832 * so this might return -EPROBE_DEFER. in ipa_probe()
834 power = ipa_power_init(dev, data->power_data); in ipa_probe()
843 ret = -ENOMEM; in ipa_probe()
847 ipa->dev = dev; in ipa_probe()
849 ipa->interrupt = interrupt; in ipa_probe()
850 ipa->power = power; in ipa_probe()
851 ipa->version = data->version; in ipa_probe()
852 ipa->modem_route_count = data->modem_route_count; in ipa_probe()
853 init_completion(&ipa->completion); in ipa_probe()
859 ret = ipa_mem_init(ipa, pdev, data->mem_data); in ipa_probe()
867 ret = gsi_init(&ipa->gsi, pdev, ipa->version, data->endpoint_count, in ipa_probe()
868 data->endpoint_data); in ipa_probe()
872 /* Result is a non-zero mask of endpoints that support filtering */ in ipa_probe()
873 ret = ipa_endpoint_init(ipa, data->endpoint_count, data->endpoint_data); in ipa_probe()
897 * ipa_setup() when it has finished. In that case we're done here. in ipa_probe()
929 gsi_exit(&ipa->gsi); in ipa_probe()
952 ipa = dev_get_drvdata(&pdev->dev); in ipa_remove()
953 dev = ipa->dev; in ipa_remove()
954 WARN_ON(dev != &pdev->dev); in ipa_remove()
956 power = ipa->power; in ipa_remove()
957 interrupt = ipa->interrupt; in ipa_remove()
960 * also ensures a modem-initiated setup that's underway completes. in ipa_remove()
968 if (ipa->setup_complete) { in ipa_remove()
971 if (ret == -EBUSY) { in ipa_remove()
995 gsi_exit(&ipa->gsi); in ipa_remove()