Skip to content

Commit 5052de8

Browse files
anderssondavem330
authored andcommitted
soc: qcom: smd: Transition client drivers from smd to rpmsg
By moving these client drivers to use RPMSG instead of the direct SMD API we can reuse them ontop of the newly added GLINK wire-protocol support found in the 820 and 835 Qualcomm platforms. As the new (RPMSG-based) and old SMD implementations are mutually exclusive we have to change all client drivers in one commit, to make sure we have a working system before and after this transition. Acked-by: Andy Gross <[email protected]> Acked-by: Kalle Valo <[email protected]> Acked-by: Marcel Holtmann <[email protected]> Signed-off-by: Bjorn Andersson <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent def499c commit 5052de8

File tree

13 files changed

+110
-104
lines changed

13 files changed

+110
-104
lines changed

drivers/bluetooth/Kconfig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -344,7 +344,7 @@ config BT_WILINK
344344

345345
config BT_QCOMSMD
346346
tristate "Qualcomm SMD based HCI support"
347-
depends on QCOM_SMD || (COMPILE_TEST && QCOM_SMD=n)
347+
depends on RPMSG || (COMPILE_TEST && RPMSG=n)
348348
depends on QCOM_WCNSS_CTRL || (COMPILE_TEST && QCOM_WCNSS_CTRL=n)
349349
select BT_QCA
350350
help

drivers/bluetooth/btqcomsmd.c

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414

1515
#include <linux/module.h>
1616
#include <linux/slab.h>
17-
#include <linux/soc/qcom/smd.h>
17+
#include <linux/rpmsg.h>
1818
#include <linux/soc/qcom/wcnss_ctrl.h>
1919
#include <linux/platform_device.h>
2020

@@ -26,8 +26,8 @@
2626
struct btqcomsmd {
2727
struct hci_dev *hdev;
2828

29-
struct qcom_smd_channel *acl_channel;
30-
struct qcom_smd_channel *cmd_channel;
29+
struct rpmsg_endpoint *acl_channel;
30+
struct rpmsg_endpoint *cmd_channel;
3131
};
3232

3333
static int btqcomsmd_recv(struct hci_dev *hdev, unsigned int type,
@@ -48,19 +48,19 @@ static int btqcomsmd_recv(struct hci_dev *hdev, unsigned int type,
4848
return hci_recv_frame(hdev, skb);
4949
}
5050

51-
static int btqcomsmd_acl_callback(struct qcom_smd_channel *channel,
52-
const void *data, size_t count)
51+
static int btqcomsmd_acl_callback(struct rpmsg_device *rpdev, void *data,
52+
int count, void *priv, u32 addr)
5353
{
54-
struct btqcomsmd *btq = qcom_smd_get_drvdata(channel);
54+
struct btqcomsmd *btq = priv;
5555

5656
btq->hdev->stat.byte_rx += count;
5757
return btqcomsmd_recv(btq->hdev, HCI_ACLDATA_PKT, data, count);
5858
}
5959

60-
static int btqcomsmd_cmd_callback(struct qcom_smd_channel *channel,
61-
const void *data, size_t count)
60+
static int btqcomsmd_cmd_callback(struct rpmsg_device *rpdev, void *data,
61+
int count, void *priv, u32 addr)
6262
{
63-
struct btqcomsmd *btq = qcom_smd_get_drvdata(channel);
63+
struct btqcomsmd *btq = priv;
6464

6565
return btqcomsmd_recv(btq->hdev, HCI_EVENT_PKT, data, count);
6666
}
@@ -72,12 +72,12 @@ static int btqcomsmd_send(struct hci_dev *hdev, struct sk_buff *skb)
7272

7373
switch (hci_skb_pkt_type(skb)) {
7474
case HCI_ACLDATA_PKT:
75-
ret = qcom_smd_send(btq->acl_channel, skb->data, skb->len);
75+
ret = rpmsg_send(btq->acl_channel, skb->data, skb->len);
7676
hdev->stat.acl_tx++;
7777
hdev->stat.byte_tx += skb->len;
7878
break;
7979
case HCI_COMMAND_PKT:
80-
ret = qcom_smd_send(btq->cmd_channel, skb->data, skb->len);
80+
ret = rpmsg_send(btq->cmd_channel, skb->data, skb->len);
8181
hdev->stat.cmd_tx++;
8282
break;
8383
default:
@@ -114,18 +114,15 @@ static int btqcomsmd_probe(struct platform_device *pdev)
114114
wcnss = dev_get_drvdata(pdev->dev.parent);
115115

116116
btq->acl_channel = qcom_wcnss_open_channel(wcnss, "APPS_RIVA_BT_ACL",
117-
btqcomsmd_acl_callback);
117+
btqcomsmd_acl_callback, btq);
118118
if (IS_ERR(btq->acl_channel))
119119
return PTR_ERR(btq->acl_channel);
120120

121121
btq->cmd_channel = qcom_wcnss_open_channel(wcnss, "APPS_RIVA_BT_CMD",
122-
btqcomsmd_cmd_callback);
122+
btqcomsmd_cmd_callback, btq);
123123
if (IS_ERR(btq->cmd_channel))
124124
return PTR_ERR(btq->cmd_channel);
125125

126-
qcom_smd_set_drvdata(btq->acl_channel, btq);
127-
qcom_smd_set_drvdata(btq->cmd_channel, btq);
128-
129126
hdev = hci_alloc_dev();
130127
if (!hdev)
131128
return -ENOMEM;
@@ -158,6 +155,9 @@ static int btqcomsmd_remove(struct platform_device *pdev)
158155
hci_unregister_dev(btq->hdev);
159156
hci_free_dev(btq->hdev);
160157

158+
rpmsg_destroy_ept(btq->cmd_channel);
159+
rpmsg_destroy_ept(btq->acl_channel);
160+
161161
return 0;
162162
}
163163

drivers/net/wireless/ath/wcn36xx/Kconfig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ config WCN36XX
22
tristate "Qualcomm Atheros WCN3660/3680 support"
33
depends on MAC80211 && HAS_DMA
44
depends on QCOM_WCNSS_CTRL || QCOM_WCNSS_CTRL=n
5-
depends on QCOM_SMD || QCOM_SMD=n
5+
depends on RPMSG || RPMSG=n
66
---help---
77
This module adds support for wireless adapters based on
88
Qualcomm Atheros WCN3660 and WCN3680 mobile chipsets.

drivers/net/wireless/ath/wcn36xx/main.c

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
#include <linux/of_address.h>
2323
#include <linux/of_device.h>
2424
#include <linux/of_irq.h>
25-
#include <linux/soc/qcom/smd.h>
25+
#include <linux/rpmsg.h>
2626
#include <linux/soc/qcom/smem_state.h>
2727
#include <linux/soc/qcom/wcnss_ctrl.h>
2828
#include "wcn36xx.h"
@@ -1218,15 +1218,13 @@ static int wcn36xx_probe(struct platform_device *pdev)
12181218

12191219
INIT_WORK(&wcn->scan_work, wcn36xx_hw_scan_worker);
12201220

1221-
wcn->smd_channel = qcom_wcnss_open_channel(wcnss, "WLAN_CTRL", wcn36xx_smd_rsp_process);
1221+
wcn->smd_channel = qcom_wcnss_open_channel(wcnss, "WLAN_CTRL", wcn36xx_smd_rsp_process, hw);
12221222
if (IS_ERR(wcn->smd_channel)) {
12231223
wcn36xx_err("failed to open WLAN_CTRL channel\n");
12241224
ret = PTR_ERR(wcn->smd_channel);
12251225
goto out_wq;
12261226
}
12271227

1228-
qcom_smd_set_drvdata(wcn->smd_channel, hw);
1229-
12301228
addr = of_get_property(pdev->dev.of_node, "local-mac-address", &ret);
12311229
if (addr && ret != ETH_ALEN) {
12321230
wcn36xx_err("invalid local-mac-address\n");

drivers/net/wireless/ath/wcn36xx/smd.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
#include <linux/etherdevice.h>
2020
#include <linux/firmware.h>
2121
#include <linux/bitops.h>
22-
#include <linux/soc/qcom/smd.h>
22+
#include <linux/rpmsg.h>
2323
#include "smd.h"
2424

2525
struct wcn36xx_cfg_val {
@@ -254,7 +254,7 @@ static int wcn36xx_smd_send_and_wait(struct wcn36xx *wcn, size_t len)
254254

255255
init_completion(&wcn->hal_rsp_compl);
256256
start = jiffies;
257-
ret = qcom_smd_send(wcn->smd_channel, wcn->hal_buf, len);
257+
ret = rpmsg_send(wcn->smd_channel, wcn->hal_buf, len);
258258
if (ret) {
259259
wcn36xx_err("HAL TX failed\n");
260260
goto out;
@@ -2205,11 +2205,11 @@ int wcn36xx_smd_set_mc_list(struct wcn36xx *wcn,
22052205
return ret;
22062206
}
22072207

2208-
int wcn36xx_smd_rsp_process(struct qcom_smd_channel *channel,
2209-
const void *buf, size_t len)
2208+
int wcn36xx_smd_rsp_process(struct rpmsg_device *rpdev,
2209+
void *buf, int len, void *priv, u32 addr)
22102210
{
22112211
const struct wcn36xx_hal_msg_header *msg_header = buf;
2212-
struct ieee80211_hw *hw = qcom_smd_get_drvdata(channel);
2212+
struct ieee80211_hw *hw = priv;
22132213
struct wcn36xx *wcn = hw->priv;
22142214
struct wcn36xx_hal_ind_msg *msg_ind;
22152215
wcn36xx_dbg_dump(WCN36XX_DBG_SMD_DUMP, "SMD <<< ", buf, len);

drivers/net/wireless/ath/wcn36xx/smd.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ struct wcn36xx_hal_ind_msg {
5151
};
5252

5353
struct wcn36xx;
54-
struct qcom_smd_channel;
54+
struct rpmsg_device;
5555

5656
int wcn36xx_smd_open(struct wcn36xx *wcn);
5757
void wcn36xx_smd_close(struct wcn36xx *wcn);
@@ -129,8 +129,8 @@ int wcn36xx_smd_trigger_ba(struct wcn36xx *wcn, u8 sta_index);
129129

130130
int wcn36xx_smd_update_cfg(struct wcn36xx *wcn, u32 cfg_id, u32 value);
131131

132-
int wcn36xx_smd_rsp_process(struct qcom_smd_channel *channel,
133-
const void *buf, size_t len);
132+
int wcn36xx_smd_rsp_process(struct rpmsg_device *rpdev,
133+
void *buf, int len, void *priv, u32 addr);
134134

135135
int wcn36xx_smd_set_mc_list(struct wcn36xx *wcn,
136136
struct ieee80211_vif *vif,

drivers/net/wireless/ath/wcn36xx/wcn36xx.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -195,7 +195,7 @@ struct wcn36xx {
195195
void __iomem *ccu_base;
196196
void __iomem *dxe_base;
197197

198-
struct qcom_smd_channel *smd_channel;
198+
struct rpmsg_endpoint *smd_channel;
199199

200200
struct qcom_smem_state *tx_enable_state;
201201
unsigned tx_enable_state_bit;

drivers/soc/qcom/Kconfig

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,8 @@ config QCOM_SMD
4343

4444
config QCOM_SMD_RPM
4545
tristate "Qualcomm Resource Power Manager (RPM) over SMD"
46-
depends on QCOM_SMD && OF
46+
depends on ARCH_QCOM
47+
depends on RPMSG && OF
4748
help
4849
If you say yes to this option, support will be included for the
4950
Resource Power Manager system found in the Qualcomm 8974 based
@@ -76,7 +77,8 @@ config QCOM_SMSM
7677

7778
config QCOM_WCNSS_CTRL
7879
tristate "Qualcomm WCNSS control driver"
79-
depends on QCOM_SMD
80+
depends on ARCH_QCOM
81+
depends on RPMSG
8082
help
8183
Client driver for the WCNSS_CTRL SMD channel, used to download nv
8284
firmware to a newly booted WCNSS chip.

drivers/soc/qcom/smd-rpm.c

Lines changed: 21 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
#include <linux/interrupt.h>
2020
#include <linux/slab.h>
2121

22-
#include <linux/soc/qcom/smd.h>
22+
#include <linux/rpmsg.h>
2323
#include <linux/soc/qcom/smd-rpm.h>
2424

2525
#define RPM_REQUEST_TIMEOUT (5 * HZ)
@@ -32,7 +32,7 @@
3232
* @ack_status: result of the rpm request
3333
*/
3434
struct qcom_smd_rpm {
35-
struct qcom_smd_channel *rpm_channel;
35+
struct rpmsg_endpoint *rpm_channel;
3636
struct device *dev;
3737

3838
struct completion ack;
@@ -133,7 +133,7 @@ int qcom_rpm_smd_write(struct qcom_smd_rpm *rpm,
133133
pkt->req.data_len = cpu_to_le32(count);
134134
memcpy(pkt->payload, buf, count);
135135

136-
ret = qcom_smd_send(rpm->rpm_channel, pkt, size);
136+
ret = rpmsg_send(rpm->rpm_channel, pkt, size);
137137
if (ret)
138138
goto out;
139139

@@ -150,14 +150,16 @@ int qcom_rpm_smd_write(struct qcom_smd_rpm *rpm,
150150
}
151151
EXPORT_SYMBOL(qcom_rpm_smd_write);
152152

153-
static int qcom_smd_rpm_callback(struct qcom_smd_channel *channel,
154-
const void *data,
155-
size_t count)
153+
static int qcom_smd_rpm_callback(struct rpmsg_device *rpdev,
154+
void *data,
155+
int count,
156+
void *priv,
157+
u32 addr)
156158
{
157159
const struct qcom_rpm_header *hdr = data;
158160
size_t hdr_length = le32_to_cpu(hdr->length);
159161
const struct qcom_rpm_message *msg;
160-
struct qcom_smd_rpm *rpm = qcom_smd_get_drvdata(channel);
162+
struct qcom_smd_rpm *rpm = dev_get_drvdata(&rpdev->dev);
161163
const u8 *buf = data + sizeof(struct qcom_rpm_header);
162164
const u8 *end = buf + hdr_length;
163165
char msgbuf[32];
@@ -196,29 +198,27 @@ static int qcom_smd_rpm_callback(struct qcom_smd_channel *channel,
196198
return 0;
197199
}
198200

199-
static int qcom_smd_rpm_probe(struct qcom_smd_device *sdev)
201+
static int qcom_smd_rpm_probe(struct rpmsg_device *rpdev)
200202
{
201203
struct qcom_smd_rpm *rpm;
202204

203-
rpm = devm_kzalloc(&sdev->dev, sizeof(*rpm), GFP_KERNEL);
205+
rpm = devm_kzalloc(&rpdev->dev, sizeof(*rpm), GFP_KERNEL);
204206
if (!rpm)
205207
return -ENOMEM;
206208

207209
mutex_init(&rpm->lock);
208210
init_completion(&rpm->ack);
209211

210-
rpm->dev = &sdev->dev;
211-
rpm->rpm_channel = sdev->channel;
212-
qcom_smd_set_drvdata(sdev->channel, rpm);
212+
rpm->dev = &rpdev->dev;
213+
rpm->rpm_channel = rpdev->ept;
214+
dev_set_drvdata(&rpdev->dev, rpm);
213215

214-
dev_set_drvdata(&sdev->dev, rpm);
215-
216-
return of_platform_populate(sdev->dev.of_node, NULL, NULL, &sdev->dev);
216+
return of_platform_populate(rpdev->dev.of_node, NULL, NULL, &rpdev->dev);
217217
}
218218

219-
static void qcom_smd_rpm_remove(struct qcom_smd_device *sdev)
219+
static void qcom_smd_rpm_remove(struct rpmsg_device *rpdev)
220220
{
221-
of_platform_depopulate(&sdev->dev);
221+
of_platform_depopulate(&rpdev->dev);
222222
}
223223

224224
static const struct of_device_id qcom_smd_rpm_of_match[] = {
@@ -229,26 +229,25 @@ static const struct of_device_id qcom_smd_rpm_of_match[] = {
229229
};
230230
MODULE_DEVICE_TABLE(of, qcom_smd_rpm_of_match);
231231

232-
static struct qcom_smd_driver qcom_smd_rpm_driver = {
232+
static struct rpmsg_driver qcom_smd_rpm_driver = {
233233
.probe = qcom_smd_rpm_probe,
234234
.remove = qcom_smd_rpm_remove,
235235
.callback = qcom_smd_rpm_callback,
236-
.driver = {
236+
.drv = {
237237
.name = "qcom_smd_rpm",
238-
.owner = THIS_MODULE,
239238
.of_match_table = qcom_smd_rpm_of_match,
240239
},
241240
};
242241

243242
static int __init qcom_smd_rpm_init(void)
244243
{
245-
return qcom_smd_driver_register(&qcom_smd_rpm_driver);
244+
return register_rpmsg_driver(&qcom_smd_rpm_driver);
246245
}
247246
arch_initcall(qcom_smd_rpm_init);
248247

249248
static void __exit qcom_smd_rpm_exit(void)
250249
{
251-
qcom_smd_driver_unregister(&qcom_smd_rpm_driver);
250+
unregister_rpmsg_driver(&qcom_smd_rpm_driver);
252251
}
253252
module_exit(qcom_smd_rpm_exit);
254253

0 commit comments

Comments
 (0)