diff options
author | Bjorn Andersson <bjorn.andersson@linaro.org> | 2016-06-20 02:19:45 -0400 |
---|---|---|
committer | Kalle Valo <kvalo@qca.qualcomm.com> | 2016-07-08 09:58:22 -0400 |
commit | 05ddce497c056307e25c7865f540751813711d2d (patch) | |
tree | e276658bf0011316a94050b3e7dc0fa2cb58d610 /drivers/net/wireless | |
parent | 1c41fd5fb7514fa1b30992865cee4844715688bb (diff) |
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: Bjorn Andersson <bjorn.andersson@linaro.org>
Signed-off-by: Kalle Valo <kvalo@qca.qualcomm.com>
Diffstat (limited to 'drivers/net/wireless')
-rw-r--r-- | drivers/net/wireless/ath/wcn36xx/dxe.c | 26 | ||||
-rw-r--r-- | drivers/net/wireless/ath/wcn36xx/dxe.h | 6 | ||||
-rw-r--r-- | drivers/net/wireless/ath/wcn36xx/main.c | 51 | ||||
-rw-r--r-- | drivers/net/wireless/ath/wcn36xx/wcn36xx.h | 3 |
4 files changed, 59 insertions, 27 deletions
diff --git a/drivers/net/wireless/ath/wcn36xx/dxe.c b/drivers/net/wireless/ath/wcn36xx/dxe.c index 8643801f31b6..a8ff45400982 100644 --- a/drivers/net/wireless/ath/wcn36xx/dxe.c +++ b/drivers/net/wireless/ath/wcn36xx/dxe.c | |||
@@ -35,26 +35,27 @@ void *wcn36xx_dxe_get_next_bd(struct wcn36xx *wcn, bool is_low) | |||
35 | return ch->head_blk_ctl->bd_cpu_addr; | 35 | return ch->head_blk_ctl->bd_cpu_addr; |
36 | } | 36 | } |
37 | 37 | ||
38 | static void wcn36xx_ccu_write_register(struct wcn36xx *wcn, int addr, int data) | ||
39 | { | ||
40 | wcn36xx_dbg(WCN36XX_DBG_DXE, | ||
41 | "wcn36xx_ccu_write_register: addr=%x, data=%x\n", | ||
42 | addr, data); | ||
43 | |||
44 | writel(data, wcn->ccu_base + addr); | ||
45 | } | ||
46 | |||
38 | static void wcn36xx_dxe_write_register(struct wcn36xx *wcn, int addr, int data) | 47 | static void wcn36xx_dxe_write_register(struct wcn36xx *wcn, int addr, int data) |
39 | { | 48 | { |
40 | wcn36xx_dbg(WCN36XX_DBG_DXE, | 49 | wcn36xx_dbg(WCN36XX_DBG_DXE, |
41 | "wcn36xx_dxe_write_register: addr=%x, data=%x\n", | 50 | "wcn36xx_dxe_write_register: addr=%x, data=%x\n", |
42 | addr, data); | 51 | addr, data); |
43 | 52 | ||
44 | writel(data, wcn->mmio + addr); | 53 | writel(data, wcn->dxe_base + addr); |
45 | } | 54 | } |
46 | 55 | ||
47 | #define wcn36xx_dxe_write_register_x(wcn, reg, reg_data) \ | ||
48 | do { \ | ||
49 | if (wcn->chip_version == WCN36XX_CHIP_3680) \ | ||
50 | wcn36xx_dxe_write_register(wcn, reg ## _3680, reg_data); \ | ||
51 | else \ | ||
52 | wcn36xx_dxe_write_register(wcn, reg ## _3660, reg_data); \ | ||
53 | } while (0) \ | ||
54 | |||
55 | static void wcn36xx_dxe_read_register(struct wcn36xx *wcn, int addr, int *data) | 56 | static void wcn36xx_dxe_read_register(struct wcn36xx *wcn, int addr, int *data) |
56 | { | 57 | { |
57 | *data = readl(wcn->mmio + addr); | 58 | *data = readl(wcn->dxe_base + addr); |
58 | 59 | ||
59 | wcn36xx_dbg(WCN36XX_DBG_DXE, | 60 | wcn36xx_dbg(WCN36XX_DBG_DXE, |
60 | "wcn36xx_dxe_read_register: addr=%x, data=%x\n", | 61 | "wcn36xx_dxe_read_register: addr=%x, data=%x\n", |
@@ -703,7 +704,10 @@ int wcn36xx_dxe_init(struct wcn36xx *wcn) | |||
703 | 704 | ||
704 | /* Setting interrupt path */ | 705 | /* Setting interrupt path */ |
705 | reg_data = WCN36XX_DXE_CCU_INT; | 706 | reg_data = WCN36XX_DXE_CCU_INT; |
706 | wcn36xx_dxe_write_register_x(wcn, WCN36XX_DXE_REG_CCU_INT, reg_data); | 707 | if (wcn->chip_version == WCN36XX_CHIP_3680) |
708 | wcn36xx_ccu_write_register(wcn, WCN36XX_DXE_REG_CCU_INT_3680, reg_data); | ||
709 | else | ||
710 | wcn36xx_ccu_write_register(wcn, WCN36XX_DXE_REG_CCU_INT_3660, reg_data); | ||
707 | 711 | ||
708 | /***************************************/ | 712 | /***************************************/ |
709 | /* Init descriptors for TX LOW channel */ | 713 | /* Init descriptors for TX LOW channel */ |
diff --git a/drivers/net/wireless/ath/wcn36xx/dxe.h b/drivers/net/wireless/ath/wcn36xx/dxe.h index 3eca4f9594f2..012b59f4f91b 100644 --- a/drivers/net/wireless/ath/wcn36xx/dxe.h +++ b/drivers/net/wireless/ath/wcn36xx/dxe.h | |||
@@ -28,11 +28,11 @@ H2H_TEST_RX_TX = DMA2 | |||
28 | */ | 28 | */ |
29 | 29 | ||
30 | /* DXE registers */ | 30 | /* DXE registers */ |
31 | #define WCN36XX_DXE_MEM_REG 0x202000 | 31 | #define WCN36XX_DXE_MEM_REG 0 |
32 | 32 | ||
33 | #define WCN36XX_DXE_CCU_INT 0xA0011 | 33 | #define WCN36XX_DXE_CCU_INT 0xA0011 |
34 | #define WCN36XX_DXE_REG_CCU_INT_3660 0x200b10 | 34 | #define WCN36XX_DXE_REG_CCU_INT_3660 0x310 |
35 | #define WCN36XX_DXE_REG_CCU_INT_3680 0x2050dc | 35 | #define WCN36XX_DXE_REG_CCU_INT_3680 0x10dc |
36 | 36 | ||
37 | /* TODO This must calculated properly but not hardcoded */ | 37 | /* TODO This must calculated properly but not hardcoded */ |
38 | #define WCN36XX_DXE_CTRL_TX_L 0x328a44 | 38 | #define WCN36XX_DXE_CTRL_TX_L 0x328a44 |
diff --git a/drivers/net/wireless/ath/wcn36xx/main.c b/drivers/net/wireless/ath/wcn36xx/main.c index a920d7020148..8146eeba4458 100644 --- a/drivers/net/wireless/ath/wcn36xx/main.c +++ b/drivers/net/wireless/ath/wcn36xx/main.c | |||
@@ -19,6 +19,8 @@ | |||
19 | #include <linux/module.h> | 19 | #include <linux/module.h> |
20 | #include <linux/firmware.h> | 20 | #include <linux/firmware.h> |
21 | #include <linux/platform_device.h> | 21 | #include <linux/platform_device.h> |
22 | #include <linux/of_address.h> | ||
23 | #include <linux/of_device.h> | ||
22 | #include "wcn36xx.h" | 24 | #include "wcn36xx.h" |
23 | 25 | ||
24 | unsigned int wcn36xx_dbg_mask; | 26 | unsigned int wcn36xx_dbg_mask; |
@@ -1064,7 +1066,11 @@ static int wcn36xx_init_ieee80211(struct wcn36xx *wcn) | |||
1064 | static int wcn36xx_platform_get_resources(struct wcn36xx *wcn, | 1066 | static int wcn36xx_platform_get_resources(struct wcn36xx *wcn, |
1065 | struct platform_device *pdev) | 1067 | struct platform_device *pdev) |
1066 | { | 1068 | { |
1069 | struct device_node *mmio_node; | ||
1067 | struct resource *res; | 1070 | struct resource *res; |
1071 | int index; | ||
1072 | int ret; | ||
1073 | |||
1068 | /* Set TX IRQ */ | 1074 | /* Set TX IRQ */ |
1069 | res = platform_get_resource_byname(pdev, IORESOURCE_IRQ, | 1075 | res = platform_get_resource_byname(pdev, IORESOURCE_IRQ, |
1070 | "wcnss_wlantx_irq"); | 1076 | "wcnss_wlantx_irq"); |
@@ -1083,19 +1089,38 @@ static int wcn36xx_platform_get_resources(struct wcn36xx *wcn, | |||
1083 | } | 1089 | } |
1084 | wcn->rx_irq = res->start; | 1090 | wcn->rx_irq = res->start; |
1085 | 1091 | ||
1086 | /* Map the memory */ | 1092 | mmio_node = of_parse_phandle(pdev->dev.parent->of_node, "qcom,mmio", 0); |
1087 | res = platform_get_resource_byname(pdev, IORESOURCE_MEM, | 1093 | if (!mmio_node) { |
1088 | "wcnss_mmio"); | 1094 | wcn36xx_err("failed to acquire qcom,mmio reference\n"); |
1089 | if (!res) { | 1095 | return -EINVAL; |
1090 | wcn36xx_err("failed to get mmio\n"); | 1096 | } |
1091 | return -ENOENT; | 1097 | |
1098 | /* Map the CCU memory */ | ||
1099 | index = of_property_match_string(mmio_node, "reg-names", "ccu"); | ||
1100 | wcn->ccu_base = of_iomap(mmio_node, index); | ||
1101 | if (!wcn->ccu_base) { | ||
1102 | wcn36xx_err("failed to map ccu memory\n"); | ||
1103 | ret = -ENOMEM; | ||
1104 | goto put_mmio_node; | ||
1092 | } | 1105 | } |
1093 | wcn->mmio = ioremap(res->start, resource_size(res)); | 1106 | |
1094 | if (!wcn->mmio) { | 1107 | /* Map the DXE memory */ |
1095 | wcn36xx_err("failed to map io memory\n"); | 1108 | index = of_property_match_string(mmio_node, "reg-names", "dxe"); |
1096 | return -ENOMEM; | 1109 | wcn->dxe_base = of_iomap(mmio_node, index); |
1110 | if (!wcn->dxe_base) { | ||
1111 | wcn36xx_err("failed to map dxe memory\n"); | ||
1112 | ret = -ENOMEM; | ||
1113 | goto unmap_ccu; | ||
1097 | } | 1114 | } |
1115 | |||
1116 | of_node_put(mmio_node); | ||
1098 | return 0; | 1117 | return 0; |
1118 | |||
1119 | unmap_ccu: | ||
1120 | iounmap(wcn->ccu_base); | ||
1121 | put_mmio_node: | ||
1122 | of_node_put(mmio_node); | ||
1123 | return ret; | ||
1099 | } | 1124 | } |
1100 | 1125 | ||
1101 | static int wcn36xx_probe(struct platform_device *pdev) | 1126 | static int wcn36xx_probe(struct platform_device *pdev) |
@@ -1138,7 +1163,8 @@ static int wcn36xx_probe(struct platform_device *pdev) | |||
1138 | return 0; | 1163 | return 0; |
1139 | 1164 | ||
1140 | out_unmap: | 1165 | out_unmap: |
1141 | iounmap(wcn->mmio); | 1166 | iounmap(wcn->ccu_base); |
1167 | iounmap(wcn->dxe_base); | ||
1142 | out_wq: | 1168 | out_wq: |
1143 | ieee80211_free_hw(hw); | 1169 | ieee80211_free_hw(hw); |
1144 | out_err: | 1170 | out_err: |
@@ -1154,7 +1180,8 @@ static int wcn36xx_remove(struct platform_device *pdev) | |||
1154 | mutex_destroy(&wcn->hal_mutex); | 1180 | mutex_destroy(&wcn->hal_mutex); |
1155 | 1181 | ||
1156 | ieee80211_unregister_hw(hw); | 1182 | ieee80211_unregister_hw(hw); |
1157 | iounmap(wcn->mmio); | 1183 | iounmap(wcn->dxe_base); |
1184 | iounmap(wcn->ccu_base); | ||
1158 | ieee80211_free_hw(hw); | 1185 | ieee80211_free_hw(hw); |
1159 | 1186 | ||
1160 | return 0; | 1187 | return 0; |
diff --git a/drivers/net/wireless/ath/wcn36xx/wcn36xx.h b/drivers/net/wireless/ath/wcn36xx/wcn36xx.h index f6d8d14f13d1..845f2446a1b5 100644 --- a/drivers/net/wireless/ath/wcn36xx/wcn36xx.h +++ b/drivers/net/wireless/ath/wcn36xx/wcn36xx.h | |||
@@ -202,7 +202,8 @@ struct wcn36xx { | |||
202 | /* IRQs */ | 202 | /* IRQs */ |
203 | int tx_irq; | 203 | int tx_irq; |
204 | int rx_irq; | 204 | int rx_irq; |
205 | void __iomem *mmio; | 205 | void __iomem *ccu_base; |
206 | void __iomem *dxe_base; | ||
206 | 207 | ||
207 | struct wcn36xx_platform_ctrl_ops *ctrl_ops; | 208 | struct wcn36xx_platform_ctrl_ops *ctrl_ops; |
208 | /* | 209 | /* |