Commit 05ddce49 authored by Bjorn Andersson's avatar Bjorn Andersson Committed by Kalle Valo

wcn36xx: Split mmio space into explicit regions

Split the wcnss mmio space into explicit regions for ccu and dxe and
acquire these from the node referenced by the qcom,mmio phandle.
Signed-off-by: default avatarBjorn Andersson <bjorn.andersson@linaro.org>
Signed-off-by: default avatarKalle Valo <kvalo@qca.qualcomm.com>
parent 1c41fd5f
...@@ -35,26 +35,27 @@ void *wcn36xx_dxe_get_next_bd(struct wcn36xx *wcn, bool is_low) ...@@ -35,26 +35,27 @@ void *wcn36xx_dxe_get_next_bd(struct wcn36xx *wcn, bool is_low)
return ch->head_blk_ctl->bd_cpu_addr; return ch->head_blk_ctl->bd_cpu_addr;
} }
static void wcn36xx_ccu_write_register(struct wcn36xx *wcn, int addr, int data)
{
wcn36xx_dbg(WCN36XX_DBG_DXE,
"wcn36xx_ccu_write_register: addr=%x, data=%x\n",
addr, data);
writel(data, wcn->ccu_base + addr);
}
static void wcn36xx_dxe_write_register(struct wcn36xx *wcn, int addr, int data) static void wcn36xx_dxe_write_register(struct wcn36xx *wcn, int addr, int data)
{ {
wcn36xx_dbg(WCN36XX_DBG_DXE, wcn36xx_dbg(WCN36XX_DBG_DXE,
"wcn36xx_dxe_write_register: addr=%x, data=%x\n", "wcn36xx_dxe_write_register: addr=%x, data=%x\n",
addr, data); addr, data);
writel(data, wcn->mmio + addr); writel(data, wcn->dxe_base + addr);
} }
#define wcn36xx_dxe_write_register_x(wcn, reg, reg_data) \
do { \
if (wcn->chip_version == WCN36XX_CHIP_3680) \
wcn36xx_dxe_write_register(wcn, reg ## _3680, reg_data); \
else \
wcn36xx_dxe_write_register(wcn, reg ## _3660, reg_data); \
} while (0) \
static void wcn36xx_dxe_read_register(struct wcn36xx *wcn, int addr, int *data) static void wcn36xx_dxe_read_register(struct wcn36xx *wcn, int addr, int *data)
{ {
*data = readl(wcn->mmio + addr); *data = readl(wcn->dxe_base + addr);
wcn36xx_dbg(WCN36XX_DBG_DXE, wcn36xx_dbg(WCN36XX_DBG_DXE,
"wcn36xx_dxe_read_register: addr=%x, data=%x\n", "wcn36xx_dxe_read_register: addr=%x, data=%x\n",
...@@ -703,7 +704,10 @@ int wcn36xx_dxe_init(struct wcn36xx *wcn) ...@@ -703,7 +704,10 @@ int wcn36xx_dxe_init(struct wcn36xx *wcn)
/* Setting interrupt path */ /* Setting interrupt path */
reg_data = WCN36XX_DXE_CCU_INT; reg_data = WCN36XX_DXE_CCU_INT;
wcn36xx_dxe_write_register_x(wcn, WCN36XX_DXE_REG_CCU_INT, reg_data); if (wcn->chip_version == WCN36XX_CHIP_3680)
wcn36xx_ccu_write_register(wcn, WCN36XX_DXE_REG_CCU_INT_3680, reg_data);
else
wcn36xx_ccu_write_register(wcn, WCN36XX_DXE_REG_CCU_INT_3660, reg_data);
/***************************************/ /***************************************/
/* Init descriptors for TX LOW channel */ /* Init descriptors for TX LOW channel */
......
...@@ -28,11 +28,11 @@ H2H_TEST_RX_TX = DMA2 ...@@ -28,11 +28,11 @@ H2H_TEST_RX_TX = DMA2
*/ */
/* DXE registers */ /* DXE registers */
#define WCN36XX_DXE_MEM_REG 0x202000 #define WCN36XX_DXE_MEM_REG 0
#define WCN36XX_DXE_CCU_INT 0xA0011 #define WCN36XX_DXE_CCU_INT 0xA0011
#define WCN36XX_DXE_REG_CCU_INT_3660 0x200b10 #define WCN36XX_DXE_REG_CCU_INT_3660 0x310
#define WCN36XX_DXE_REG_CCU_INT_3680 0x2050dc #define WCN36XX_DXE_REG_CCU_INT_3680 0x10dc
/* TODO This must calculated properly but not hardcoded */ /* TODO This must calculated properly but not hardcoded */
#define WCN36XX_DXE_CTRL_TX_L 0x328a44 #define WCN36XX_DXE_CTRL_TX_L 0x328a44
......
...@@ -19,6 +19,8 @@ ...@@ -19,6 +19,8 @@
#include <linux/module.h> #include <linux/module.h>
#include <linux/firmware.h> #include <linux/firmware.h>
#include <linux/platform_device.h> #include <linux/platform_device.h>
#include <linux/of_address.h>
#include <linux/of_device.h>
#include "wcn36xx.h" #include "wcn36xx.h"
unsigned int wcn36xx_dbg_mask; unsigned int wcn36xx_dbg_mask;
...@@ -1064,7 +1066,11 @@ static int wcn36xx_init_ieee80211(struct wcn36xx *wcn) ...@@ -1064,7 +1066,11 @@ static int wcn36xx_init_ieee80211(struct wcn36xx *wcn)
static int wcn36xx_platform_get_resources(struct wcn36xx *wcn, static int wcn36xx_platform_get_resources(struct wcn36xx *wcn,
struct platform_device *pdev) struct platform_device *pdev)
{ {
struct device_node *mmio_node;
struct resource *res; struct resource *res;
int index;
int ret;
/* Set TX IRQ */ /* Set TX IRQ */
res = platform_get_resource_byname(pdev, IORESOURCE_IRQ, res = platform_get_resource_byname(pdev, IORESOURCE_IRQ,
"wcnss_wlantx_irq"); "wcnss_wlantx_irq");
...@@ -1083,19 +1089,38 @@ static int wcn36xx_platform_get_resources(struct wcn36xx *wcn, ...@@ -1083,19 +1089,38 @@ static int wcn36xx_platform_get_resources(struct wcn36xx *wcn,
} }
wcn->rx_irq = res->start; wcn->rx_irq = res->start;
/* Map the memory */ mmio_node = of_parse_phandle(pdev->dev.parent->of_node, "qcom,mmio", 0);
res = platform_get_resource_byname(pdev, IORESOURCE_MEM, if (!mmio_node) {
"wcnss_mmio"); wcn36xx_err("failed to acquire qcom,mmio reference\n");
if (!res) { return -EINVAL;
wcn36xx_err("failed to get mmio\n"); }
return -ENOENT;
/* Map the CCU memory */
index = of_property_match_string(mmio_node, "reg-names", "ccu");
wcn->ccu_base = of_iomap(mmio_node, index);
if (!wcn->ccu_base) {
wcn36xx_err("failed to map ccu memory\n");
ret = -ENOMEM;
goto put_mmio_node;
} }
wcn->mmio = ioremap(res->start, resource_size(res));
if (!wcn->mmio) { /* Map the DXE memory */
wcn36xx_err("failed to map io memory\n"); index = of_property_match_string(mmio_node, "reg-names", "dxe");
return -ENOMEM; wcn->dxe_base = of_iomap(mmio_node, index);
if (!wcn->dxe_base) {
wcn36xx_err("failed to map dxe memory\n");
ret = -ENOMEM;
goto unmap_ccu;
} }
of_node_put(mmio_node);
return 0; return 0;
unmap_ccu:
iounmap(wcn->ccu_base);
put_mmio_node:
of_node_put(mmio_node);
return ret;
} }
static int wcn36xx_probe(struct platform_device *pdev) static int wcn36xx_probe(struct platform_device *pdev)
...@@ -1138,7 +1163,8 @@ static int wcn36xx_probe(struct platform_device *pdev) ...@@ -1138,7 +1163,8 @@ static int wcn36xx_probe(struct platform_device *pdev)
return 0; return 0;
out_unmap: out_unmap:
iounmap(wcn->mmio); iounmap(wcn->ccu_base);
iounmap(wcn->dxe_base);
out_wq: out_wq:
ieee80211_free_hw(hw); ieee80211_free_hw(hw);
out_err: out_err:
...@@ -1154,7 +1180,8 @@ static int wcn36xx_remove(struct platform_device *pdev) ...@@ -1154,7 +1180,8 @@ static int wcn36xx_remove(struct platform_device *pdev)
mutex_destroy(&wcn->hal_mutex); mutex_destroy(&wcn->hal_mutex);
ieee80211_unregister_hw(hw); ieee80211_unregister_hw(hw);
iounmap(wcn->mmio); iounmap(wcn->dxe_base);
iounmap(wcn->ccu_base);
ieee80211_free_hw(hw); ieee80211_free_hw(hw);
return 0; return 0;
......
...@@ -202,7 +202,8 @@ struct wcn36xx { ...@@ -202,7 +202,8 @@ struct wcn36xx {
/* IRQs */ /* IRQs */
int tx_irq; int tx_irq;
int rx_irq; int rx_irq;
void __iomem *mmio; void __iomem *ccu_base;
void __iomem *dxe_base;
struct wcn36xx_platform_ctrl_ops *ctrl_ops; struct wcn36xx_platform_ctrl_ops *ctrl_ops;
/* /*
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment