dt: bindings: add new DT entry for ath11k PCI device support
Subsystems (3)
PATCH v4 1/2 dt: bindings: add new DT entry for ath11k PCI device support
Ath11k driver supports PCI devices such as QCN9074/QCA6390. Ath11k firmware uses host DDR memory, DT entry is used to reserve host DDR memory regions, send these memory base addresses using DT entries.
---
V4:
- Fix dt_binding_check warnings (Rob)
V2:
- Use reserved-memory (Rob)
.../bindings/net/wireless/qcom,ath11k.yaml | 30 ++++++++++++++++++++++ 1 file changed, 30 insertions(+)
Documentation/devicetree/bindings/net/wireless/qcom,ath11k.yaml +30 -0
@@ -150,6 +150,12 @@ properties: string to uniquely identify variant of the calibration data in the board-2.bin for designs with colliding bus and device specific ids + memory-region: + maxItems: 1 + description: + phandle to a node describing reserved memory (System RAM memory) + used by ath11k firmware (see bindings/reserved-memory/reserved-memory.txt) + required: - compatible - reg
@@ -279,3 +285,27 @@ examples: "tcl2host-status-ring"; qcom,rproc = <&q6v5_wcss>; }; + + - | + + reserved-memory { + #address-cells = <2>; + #size-cells = <2>; + + qcn9074_0: qcn9074_0@51100000 { + no-map; + reg = <0x0 0x51100000 0x0 0x03500000>; + }; + }; + + pci { + pcie0 { + #size-cells = <2>; + #address-cells = <3>; + + wifi_0: wifi@0 { + reg = <0 0 0 0 0>; + memory-region = <&qcn9074_0>; + }; + }; + };
Signature · 1 line
2.7.4
PATCH v4 2/2 ath11k: Use reserved host DDR addresses from DT for PCI devices
Host DDR memory (contiguous 45 MB in mode-0 or 15 MB in mode-2) is reserved through DT entries for firmware usage. Send the base address from DT entries.
If DT entry is available, PCI device will work with fixed_mem_region else host allocates multiple segments.
IPQ8074 on HK10 board supports multiple PCI devices. IPQ8074 + QCN9074 is tested with this patch.
Tested-on: QCN9074 hw1.0 PCI WLAN.HK.2.4.0.1-01838-QCAHKSWPL_SILICONZ-1
---
V4:
- Update code review comments to handle return (Kalle)
V3:
- remove type cast and use of_property_read_u32_array() (Kalle)
V2:
- Use of_ API to read from dt node (Rob)
drivers/net/wireless/ath/ath11k/core.h | 1 + drivers/net/wireless/ath/ath11k/mhi.c | 34 ++++++++++++++- drivers/net/wireless/ath/ath11k/pci.c | 11 ++++- drivers/net/wireless/ath/ath11k/qmi.c | 77 +++++++++++++++++++++++++++++----- drivers/net/wireless/ath/ath11k/qmi.h | 1 + 5 files changed, 111 insertions(+), 13 deletions(-)
drivers/net/wireless/ath/ath11k/core.h +1 -0
@@ -194,6 +194,7 @@ enum ath11k_dev_flags {ATH11K_FLAG_REGISTERED ,ATH11K_FLAG_QMI_FAIL ,ATH11K_FLAG_HTC_SUSPEND_COMPLETE , + ATH11K_FLAG_FIXED_MEM_RGN, }; enum ath11k_monitor_flags {
drivers/net/wireless/ath/ath11k/mhi.c +32 -2
@@ -3,6 +3,7 @@#include <linux/msi.h> #include <linux/pci.h> +#include <linux/of.h> #include "core.h" #include "debug.h"
@@ -311,6 +312,28 @@ static void ath11k_mhi_op_write_reg(struct mhi_controller *mhi_cntrl,writel (val, addr); } +static int ath11k_mhi_read_addr_from_dt (struct mhi_controller *mhi_ctrl) +{ +struct device_node *np; +dma_addr_t start; +u32 reg[4 ]; +int ret; + + np =of_find_node_by_type (NULL ,"memory" ); +if (!np) +return -ENOENT ; + + ret =of_property_read_u32_array (np,"reg" , reg,4 ); +if (ret) +return ret; + + start = reg[0 ] + reg[1 ]; + mhi_ctrl->iova_start = start +0x1000000 ; + mhi_ctrl->iova_stop = start + reg[2 ] + reg[3 ]; + +return 0 ; +} +int ath11k_mhi_register (struct ath11k_pci *ab_pci) {struct ath11k_base *ab = ab_pci->ab;
@@ -339,8 +362,15 @@ int ath11k_mhi_register(struct ath11k_pci *ab_pci)return ret; } - mhi_ctrl->iova_start =0 ; - mhi_ctrl->iova_stop =0xffffffff ; +if ((test_bit (ATH11K_FLAG_FIXED_MEM_RGN , &ab->dev_flags))) { + ret =ath11k_mhi_read_addr_from_dt (mhi_ctrl); +if (ret <0 ) +return ret; + }else { + mhi_ctrl->iova_start =0 ; + mhi_ctrl->iova_stop =0xFFFFFFFF ; + } + mhi_ctrl->sbl_size =SZ_512K ; mhi_ctrl->seg_len =SZ_512K ; mhi_ctrl->fbc_download = true;
drivers/net/wireless/ath/ath11k/pci.c +10 -1
@@ -6,6 +6,7 @@#include <linux/module.h> #include <linux/msi.h> #include <linux/pci.h> +#include <linux/of.h> #include "pci.h" #include "core.h"
@@ -1225,7 +1226,7 @@ static int ath11k_pci_probe(struct pci_dev *pdev, {struct ath11k_base *ab;struct ath11k_pci *ab_pci; -u32 soc_hw_version_major, soc_hw_version_minor; +u32 soc_hw_version_major, soc_hw_version_minor, addr;int ret; ab = ath11k_core_alloc(&pdev->dev, sizeof(*ab_pci), ATH11K_BUS_PCI,
@@ -1245,6 +1246,14 @@ static int ath11k_pci_probe(struct pci_dev *pdev,pci_set_drvdata (pdev, ab);spin_lock_init (&ab_pci->window_lock); +/* Set fixed_mem_region to true for platforms support reserved memory +* from DT. If memory is reserved from DT for FW, ath11k driver need not +* allocate memory. +*/ + ret =of_property_read_u32 (ab->dev->of_node,"memory-region" , &addr); +if (!ret) +set_bit (ATH11K_FLAG_FIXED_MEM_RGN , &ab->dev_flags); + ret =ath11k_pci_claim (ab_pci, pdev);if (ret) {ath11k_err (ab,"failed to claim device: %d\n" , ret);
drivers/net/wireless/ath/ath11k/qmi.c +67 -10
111 lines not on this page · raw message
drivers/net/wireless/ath/ath11k/qmi.h +1 -0
@@ -95,6 +95,7 @@ struct target_mem_chunk {u32 type;dma_addr_t paddr;u32 *vaddr; +void __iomem *iaddr; };struct target_info {
Signature · 1 line
2.7.4
Re: [PATCH v4 2/2] ath11k: Use reserved host DDR addresses from DT for PCI devices
On Sunday, 21 November 2021 15:22:01 CET Anilkumar Kolli wrote:
[...]
Quoted 22 lines
drivers/net/wireless/ath/ath11k/mhi.c +22
-0+static int ath11k_mhi_read_addr_from_dt (struct mhi_controller *mhi_ctrl) +{ +struct device_node *np; +dma_addr_t start; +u32 reg[4 ]; +int ret; + + np =of_find_node_by_type (NULL ,"memory" ); +if (!np) +return -ENOENT ; + + ret =of_property_read_u32_array (np,"reg" , reg,4 ); +if (ret) +return ret; + + start = reg[0 ] + reg[1 ]; + mhi_ctrl->iova_start = start +0x1000000 ; + mhi_ctrl->iova_stop = start + reg[2 ] + reg[3 ]; + +return 0 ; +} +
[...]
Quoted 14 lines
drivers/net/wireless/ath/ath11k/qmi.c +14
-0+ ret =of_property_read_u32 (dev->of_node,"memory-region" , + &hremote_phandle); +if (ret) { +ath11k_dbg (ab,ATH11K_DBG_QMI , +"qmi fail to get hremote phandle\n" ); +return ret; + } + + hremote_node =of_find_node_by_phandle (hremote_phandle); +if (!hremote_node) { +ath11k_dbg (ab,ATH11K_DBG_QMI , +"qmi fail to get hremote_node\n" ); +return ret; + }
drivers/net/wireless/ath/ath11k/qmi.c static int ath11k_qmi_alloc_target_mem_chunk(struct ath11k_base *ab) · line 1906
Quoted 10 lines
drivers/net/wireless/ath/ath11k/qmi.c +10
-0+ + ret =of_property_read_u32_array (hremote_node,"reg" , reg,4 ); +if (ret) { +ath11k_dbg (ab,ATH11K_DBG_QMI , +"qmi fail to get reg from hremote\n" ); +return ret; + } + + start = reg[0 ] + reg[1 ]; + size = reg[2 ] + reg[3 ];
See my messages for v2 [1] and v3 [2]
Kind regards,
Sven
[1] https://patchwork.kernel.org/project/linux-wireless/patch/[email protected]/#24605391
[2] https://patchwork.kernel.org/project/linux-wireless/patch/[email protected]/#24605417
Re: [PATCH v4 2/2] ath11k: Use reserved host DDR addresses from DT for PCI devices
Quoted 44 lines · Sven Eckelmann
On Sunday, 21 November 2021 15:22:01 CET Anilkumar Kolli wrote:
[...]Quoted 23 lines
+static int
ath11k_mhi_read_addr_from_dt(struct mhi_controller *mhi_ctrl)drivers/net/wireless/ath/ath11k/mhi.c +21
-0+{ +struct device_node *np; +dma_addr_t start; +u32 reg[4 ]; +int ret; + + np =of_find_node_by_type (NULL ,"memory" ); +if (!np) +return -ENOENT ; + + ret =of_property_read_u32_array (np,"reg" , reg,4 ); +if (ret) +return ret; + + start = reg[0 ] + reg[1 ]; + mhi_ctrl->iova_start = start +0x1000000 ; + mhi_ctrl->iova_stop = start + reg[2 ] + reg[3 ]; + +return 0 ; +} +[...]
Quoted 18 lines
drivers/net/wireless/ath/ath11k/qmi.c +18
-0+ ret =of_property_read_u32 (dev->of_node,"memory-region" , + &hremote_phandle); +if (ret) { +ath11k_dbg (ab,ATH11K_DBG_QMI , +"qmi fail to get hremote phandle\n" ); +return ret; + } + + hremote_node =of_find_node_by_phandle (hremote_phandle); +if (!hremote_node) { +ath11k_dbg (ab,ATH11K_DBG_QMI , +"qmi fail to get hremote_node\n" ); +return ret; + } + + ret =of_property_read_u32_array (hremote_node,"reg" , reg,4 ); +if (ret) { + ath11k_dbg(ab, ATH11K_DBG_QMI,
Quoted 10 lines
drivers/net/wireless/ath/ath11k/qmi.c static int ath11k_qmi_alloc_target_mem_chunk(struct ath11k_base *ab) · line 1906
Quoted 6 lines
drivers/net/wireless/ath/ath11k/qmi.c +6
-0+ "qmi fail to get reg from hremote\n"); +return ret; + } + + start = reg[0 ] + reg[1 ]; + size = reg[2 ] + reg[3 ];See my messages for v2 [1] and v3 [2]
Thanks for the review,
Here addresses are always within 32-bit.
so I will change the API to read only 2 integers and update start addresss and size.
Quoted 4 lines
[1]
https://patchwork.kernel.org/project/linux-wireless/patch/[email protected]/#24605391
[2]
https://patchwork.kernel.org/project/linux-wireless/patch/[email protected]/#24605417
- Anil.
Re: [PATCH v4 2/2] ath11k: Use reserved host DDR addresses from DT for PCI devices
On Monday, 22 November 2021 07:12:27 CET Anilkumar Kolli wrote:
[...]
Quoted 11 lines
Quoted 6 lines
drivers/net/wireless/ath/ath11k/qmi.c static int ath11k_qmi_alloc_target_mem_chunk(struct ath11k_base *ab) · line 1906
Quoted 2 lines
drivers/net/wireless/ath/ath11k/qmi.c +2
-0+ start = reg[0 ] + reg[1 ]; + size = reg[2 ] + reg[3 ];See my messages for v2 [1] and v3 [2]
Thanks for the review,
Here addresses are always within 32-bit.
so I will change the API to read only 2 integers and update start addresss and size.
The size of address and size depends on the reserved-memory node - not the qcn9074 node. So please don't make such assumptions in your code.
Kind regards,
Sven
Re: [PATCH v4 2/2] ath11k: Use reserved host DDR addresses from DT for PCI devices
Quoted 8 lines · Sven Eckelmann
On Monday, 22 November 2021 07:12:27 CET Anilkumar Kolli wrote:
[...]Quoted 6 lines
Quoted 6 lines
drivers/net/wireless/ath/ath11k/qmi.c static int ath11k_qmi_alloc_target_mem_chunk(struct ath11k_base *ab) · line 1906
Quoted 2 lines
drivers/net/wireless/ath/ath11k/qmi.c +2
-0+ start = reg[0 ] + reg[1 ]; + size = reg[2 ] + reg[3 ];See my messages for v2 [1] and v3 [2]
Quoted 9 lines
Quoted 5 lines
Thanks for the review,
Here addresses are always within 32-bit.
so I will change the API to read only 2 integers and update start addresss and size.The size of address and size depends on the reserved-memory node - not the qcn9074 node. So please don't make such assumptions in your code.
Yes, correct.
of_address_to_resource() returns start/end address properly. I will update and send next version.
- Anil.