blob: 205bf379af0f13e16bc547489fa299e209e07e52 [file] [log] [blame]
Sagar Dharia33beca02012-10-22 16:21:46 -06001/* Copyright (c) 2011-2013, The Linux Foundation. All rights reserved.
Sagar Dharia71fcea52012-09-12 23:21:57 -06002 *
3 * This program is free software; you can redistribute it and/or modify
4 * it under the terms of the GNU General Public License version 2 and
5 * only version 2 as published by the Free Software Foundation.
6 *
7 * This program is distributed in the hope that it will be useful,
8 * but WITHOUT ANY WARRANTY; without even the implied warranty of
9 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10 * GNU General Public License for more details.
11 */
Sagar Dharia71fcea52012-09-12 23:21:57 -060012#include <linux/irq.h>
13#include <linux/kernel.h>
14#include <linux/init.h>
15#include <linux/slab.h>
16#include <linux/io.h>
17#include <linux/interrupt.h>
18#include <linux/platform_device.h>
19#include <linux/dma-mapping.h>
20#include <linux/slimbus/slimbus.h>
21#include <linux/delay.h>
22#include <linux/kthread.h>
23#include <linux/clk.h>
24#include <linux/pm_runtime.h>
25#include <linux/of.h>
26#include <linux/of_slimbus.h>
27#include <linux/timer.h>
28#include <mach/sps.h>
29#include "slim-msm.h"
30#include <mach/qdsp6v2/apr.h>
31
32#define NGD_SLIM_NAME "ngd_msm_ctrl"
33#define SLIM_LA_MGR 0xFF
34#define SLIM_ROOT_FREQ 24576000
Sagar Dharia33beca02012-10-22 16:21:46 -060035#define LADDR_RETRY 5
Sagar Dharia71fcea52012-09-12 23:21:57 -060036
37#define NGD_BASE_V1(r) (((r) % 2) ? 0x800 : 0xA00)
38#define NGD_BASE_V2(r) (((r) % 2) ? 0x1000 : 0x2000)
39#define NGD_BASE(r, v) ((v) ? NGD_BASE_V2(r) : NGD_BASE_V1(r))
40/* NGD (Non-ported Generic Device) registers */
41enum ngd_reg {
42 NGD_CFG = 0x0,
43 NGD_STATUS = 0x4,
44 NGD_RX_MSGQ_CFG = 0x8,
45 NGD_INT_EN = 0x10,
46 NGD_INT_STAT = 0x14,
47 NGD_INT_CLR = 0x18,
48 NGD_TX_MSG = 0x30,
49 NGD_RX_MSG = 0x70,
50 NGD_IE_STAT = 0xF0,
51 NGD_VE_STAT = 0x100,
52};
53
54enum ngd_msg_cfg {
55 NGD_CFG_ENABLE = 1,
56 NGD_CFG_RX_MSGQ_EN = 1 << 1,
57 NGD_CFG_TX_MSGQ_EN = 1 << 2,
58};
59
60enum ngd_intr {
61 NGD_INT_RECFG_DONE = 1 << 24,
62 NGD_INT_TX_NACKED_2 = 1 << 25,
63 NGD_INT_MSG_BUF_CONTE = 1 << 26,
64 NGD_INT_MSG_TX_INVAL = 1 << 27,
65 NGD_INT_IE_VE_CHG = 1 << 28,
66 NGD_INT_DEV_ERR = 1 << 29,
67 NGD_INT_RX_MSG_RCVD = 1 << 30,
68 NGD_INT_TX_MSG_SENT = 1 << 31,
69};
70
71enum ngd_offsets {
72 NGD_NACKED_MC = 0x7F00000,
73 NGD_ACKED_MC = 0xFE000,
74 NGD_ERROR = 0x1800,
75 NGD_MSGQ_SUPPORT = 0x400,
76 NGD_RX_MSGQ_TIME_OUT = 0x16,
77 NGD_ENUMERATED = 0x1,
78 NGD_TX_BUSY = 0x0,
79};
80
Sagar Dharia33beca02012-10-22 16:21:46 -060081enum ngd_status {
82 NGD_LADDR = 1 << 1,
83};
84
85static int ngd_slim_runtime_resume(struct device *device);
86
Sagar Dharia71fcea52012-09-12 23:21:57 -060087static irqreturn_t ngd_slim_interrupt(int irq, void *d)
88{
89 struct msm_slim_ctrl *dev = (struct msm_slim_ctrl *)d;
90 void __iomem *ngd = dev->base + NGD_BASE(dev->ctrl.nr, dev->ver);
91 u32 stat = readl_relaxed(ngd + NGD_INT_STAT);
Sagar Dharia2b8a4b52013-05-15 20:01:45 -060092 u32 pstat;
Sagar Dharia71fcea52012-09-12 23:21:57 -060093
94 if (stat & NGD_INT_TX_MSG_SENT) {
95 writel_relaxed(NGD_INT_TX_MSG_SENT, ngd + NGD_INT_CLR);
96 /* Make sure interrupt is cleared */
97 mb();
98 if (dev->wr_comp)
99 complete(dev->wr_comp);
100 } else if ((stat & NGD_INT_MSG_BUF_CONTE) ||
101 (stat & NGD_INT_MSG_TX_INVAL) || (stat & NGD_INT_DEV_ERR) ||
102 (stat & NGD_INT_TX_NACKED_2)) {
103 dev_err(dev->dev, "NGD interrupt error:0x%x", stat);
104 writel_relaxed(stat, ngd + NGD_INT_CLR);
105 /* Guarantee that error interrupts are cleared */
106 mb();
107 if (((stat & NGD_INT_TX_NACKED_2) ||
108 (stat & NGD_INT_MSG_TX_INVAL))) {
109 dev->err = -EIO;
110 if (dev->wr_comp)
111 complete(dev->wr_comp);
112 }
113 }
114 if (stat & NGD_INT_RX_MSG_RCVD) {
115 u32 rx_buf[10];
116 u8 len, i;
117 rx_buf[0] = readl_relaxed(ngd + NGD_RX_MSG);
118 len = rx_buf[0] & 0x1F;
119 for (i = 1; i < ((len + 3) >> 2); i++) {
120 rx_buf[i] = readl_relaxed(ngd + NGD_RX_MSG +
121 (4 * i));
122 dev_dbg(dev->dev, "REG-RX data: %x\n", rx_buf[i]);
123 }
124 msm_slim_rx_enqueue(dev, rx_buf, len);
125 writel_relaxed(NGD_INT_RX_MSG_RCVD,
126 ngd + NGD_INT_CLR);
127 /*
128 * Guarantee that CLR bit write goes through before
129 * queuing work
130 */
131 mb();
Sagar Dharia24419e32013-01-14 17:56:32 -0700132 if (dev->use_rx_msgqs == MSM_MSGQ_ENABLED)
Sagar Dharia71fcea52012-09-12 23:21:57 -0600133 dev_err(dev->dev,
134 "direct message received even with RX MSGQs");
135 else
136 complete(&dev->rx_msgq_notify);
137 }
138 if (stat & NGD_INT_RECFG_DONE) {
139 writel_relaxed(NGD_INT_RECFG_DONE, ngd + NGD_INT_CLR);
140 /* Guarantee RECONFIG DONE interrupt is cleared */
141 mb();
142 /* In satellite mode, just log the reconfig done IRQ */
143 dev_dbg(dev->dev, "reconfig done IRQ for NGD");
144 }
145 if (stat & NGD_INT_IE_VE_CHG) {
146 writel_relaxed(NGD_INT_IE_VE_CHG, ngd + NGD_INT_CLR);
147 /* Guarantee IE VE change interrupt is cleared */
148 mb();
149 dev_err(dev->dev, "NGD IE VE change");
150 }
Sagar Dharia2b8a4b52013-05-15 20:01:45 -0600151
152 pstat = readl_relaxed(PGD_THIS_EE(PGD_PORT_INT_ST_EEn, dev->ver));
153 if (pstat != 0)
154 return msm_slim_port_irq_handler(dev, pstat);
Sagar Dharia71fcea52012-09-12 23:21:57 -0600155 return IRQ_HANDLED;
156}
157
Sagar Dhariacc1001e2012-11-06 13:56:42 -0700158static int ngd_qmi_available(struct notifier_block *n, unsigned long code,
159 void *_cmd)
160{
161 struct msm_slim_qmi *qmi = container_of(n, struct msm_slim_qmi, nb);
Sagar Dharia33beca02012-10-22 16:21:46 -0600162 struct msm_slim_ctrl *dev =
163 container_of(qmi, struct msm_slim_ctrl, qmi);
Sagar Dhariacc1001e2012-11-06 13:56:42 -0700164 pr_info("Slimbus QMI NGD CB received event:%ld", code);
165 switch (code) {
166 case QMI_SERVER_ARRIVE:
Sagar Dharia33beca02012-10-22 16:21:46 -0600167 schedule_work(&qmi->ssr_up);
Sagar Dhariacc1001e2012-11-06 13:56:42 -0700168 break;
169 case QMI_SERVER_EXIT:
Sagar Dharia33beca02012-10-22 16:21:46 -0600170 dev->state = MSM_CTRL_DOWN;
171 /* make sure autosuspend is not called until ADSP comes up*/
172 pm_runtime_get_noresume(dev->dev);
173 /* Reset ctrl_up completion */
174 init_completion(&dev->ctrl_up);
175 schedule_work(&qmi->ssr_down);
Sagar Dhariacc1001e2012-11-06 13:56:42 -0700176 break;
177 default:
178 break;
179 }
180 return 0;
181}
182
Sagar Dharia71fcea52012-09-12 23:21:57 -0600183static int ngd_get_tid(struct slim_controller *ctrl, struct slim_msg_txn *txn,
184 u8 *tid, struct completion *done)
185{
186 struct msm_slim_ctrl *dev = slim_get_ctrldata(ctrl);
Sagar Dhariad2959352012-12-01 15:43:01 -0700187 mutex_lock(&ctrl->m_ctrl);
Sagar Dharia71fcea52012-09-12 23:21:57 -0600188 if (ctrl->last_tid <= 255) {
189 ctrl->txnt = krealloc(ctrl->txnt,
190 (ctrl->last_tid + 1) *
191 sizeof(struct slim_msg_txn *),
192 GFP_KERNEL);
Sagar Dhariad2959352012-12-01 15:43:01 -0700193 if (!ctrl->txnt) {
194 mutex_unlock(&ctrl->m_ctrl);
Sagar Dharia71fcea52012-09-12 23:21:57 -0600195 return -ENOMEM;
Sagar Dhariad2959352012-12-01 15:43:01 -0700196 }
Sagar Dharia71fcea52012-09-12 23:21:57 -0600197 dev->msg_cnt = ctrl->last_tid;
198 ctrl->last_tid++;
199 } else {
200 int i;
201 for (i = 0; i < 256; i++) {
202 dev->msg_cnt = ((dev->msg_cnt + 1) & 0xFF);
203 if (ctrl->txnt[dev->msg_cnt] == NULL)
204 break;
205 }
206 if (i >= 256) {
207 dev_err(&ctrl->dev, "out of TID");
Sagar Dhariad2959352012-12-01 15:43:01 -0700208 mutex_unlock(&ctrl->m_ctrl);
Sagar Dharia71fcea52012-09-12 23:21:57 -0600209 return -ENOMEM;
210 }
211 }
212 ctrl->txnt[dev->msg_cnt] = txn;
213 txn->tid = dev->msg_cnt;
214 txn->comp = done;
215 *tid = dev->msg_cnt;
Sagar Dhariad2959352012-12-01 15:43:01 -0700216 mutex_unlock(&ctrl->m_ctrl);
Sagar Dharia71fcea52012-09-12 23:21:57 -0600217 return 0;
218}
219static int ngd_xfer_msg(struct slim_controller *ctrl, struct slim_msg_txn *txn)
220{
221 DECLARE_COMPLETION_ONSTACK(done);
222 DECLARE_COMPLETION_ONSTACK(tx_sent);
223
224 struct msm_slim_ctrl *dev = slim_get_ctrldata(ctrl);
225 u32 *pbuf;
226 u8 *puc;
227 int ret = 0;
Sagar Dharia71fcea52012-09-12 23:21:57 -0600228 u8 la = txn->la;
Sagar Dharia8e554ed2013-07-19 15:48:15 -0600229 u8 txn_mt;
230 u16 txn_mc = txn->mc;
Sagar Dharia5c8ad192013-05-31 11:39:05 -0600231 u8 wbuf[SLIM_MSGQ_BUF_LEN];
Sagar Dharia71fcea52012-09-12 23:21:57 -0600232
Sagar Dhariaa1398282013-01-22 13:26:20 -0700233 if (!pm_runtime_enabled(dev->dev) && dev->state == MSM_CTRL_ASLEEP &&
234 txn->mc != SLIM_USR_MC_REPORT_SATELLITE) {
235 /*
236 * Counter-part of system-suspend when runtime-pm is not enabled
237 * This way, resume can be left empty and device will be put in
238 * active mode only if client requests anything on the bus
239 * If the state was DOWN, SSR UP notification will take
240 * care of putting the device in active state.
241 */
242 ngd_slim_runtime_resume(dev->dev);
243 }
Sagar Dharia5c8ad192013-05-31 11:39:05 -0600244 if ((txn->mc == (SLIM_MSG_CLK_PAUSE_SEQ_FLG |
245 SLIM_MSG_MC_RECONFIGURE_NOW)) &&
246 dev->state <= MSM_CTRL_SLEEPING) {
247 msm_slim_disconnect_endp(dev, &dev->rx_msgq,
248 &dev->use_rx_msgqs);
249 msm_slim_disconnect_endp(dev, &dev->tx_msgq,
250 &dev->use_tx_msgqs);
251 return msm_slim_qmi_power_request(dev, false);
Sagar Dharia24419e32013-01-14 17:56:32 -0700252 }
Sagar Dhariacc1001e2012-11-06 13:56:42 -0700253 else if (txn->mc & SLIM_MSG_CLK_PAUSE_SEQ_FLG)
254 return 0;
255
Sagar Dharia71fcea52012-09-12 23:21:57 -0600256 if (txn->mt == SLIM_MSG_MT_CORE &&
257 (txn->mc >= SLIM_MSG_MC_BEGIN_RECONFIGURATION &&
258 txn->mc <= SLIM_MSG_MC_RECONFIGURE_NOW)) {
259 return 0;
260 }
Sagar Dharia33beca02012-10-22 16:21:46 -0600261 /* If txn is tried when controller is down, wait for ADSP to boot */
262 if (txn->mc != SLIM_USR_MC_REPORT_SATELLITE) {
263 if (dev->state == MSM_CTRL_DOWN) {
264 u8 mc = (u8)txn->mc;
265 int timeout;
266 dev_err(dev->dev, "ADSP slimbus not up yet");
267 /*
268 * Messages related to data channel management can't
269 * wait since they are holding reconfiguration lock.
270 * clk_pause in resume (which can change state back to
271 * MSM_CTRL_AWAKE), will need that lock
272 */
273 if ((txn->mt == SLIM_MSG_MT_CORE) &&
274 ((mc >= SLIM_MSG_MC_CONNECT_SOURCE &&
275 mc <= SLIM_MSG_MC_CHANGE_CONTENT) ||
276 (mc >= SLIM_MSG_MC_BEGIN_RECONFIGURATION &&
277 mc <= SLIM_MSG_MC_RECONFIGURE_NOW)))
278 return -EREMOTEIO;
279 if ((txn->mt == SLIM_MSG_MT_DEST_REFERRED_USER) &&
280 ((mc >= SLIM_USR_MC_DEFINE_CHAN &&
281 mc <= SLIM_USR_MC_DISCONNECT_PORT)))
282 return -EREMOTEIO;
283 timeout = wait_for_completion_timeout(&dev->ctrl_up,
284 HZ);
285 if (!timeout)
286 return -ETIMEDOUT;
287 }
288 msm_slim_get_ctrl(dev);
289 }
Sagar Dharia71fcea52012-09-12 23:21:57 -0600290 mutex_lock(&dev->tx_lock);
Sagar Dharia33beca02012-10-22 16:21:46 -0600291
Sagar Dharia71fcea52012-09-12 23:21:57 -0600292 if (txn->mc != SLIM_USR_MC_REPORT_SATELLITE &&
Sagar Dharia33beca02012-10-22 16:21:46 -0600293 (dev->state != MSM_CTRL_AWAKE)) {
Sagar Dharia71fcea52012-09-12 23:21:57 -0600294 dev_err(dev->dev, "controller not ready");
295 mutex_unlock(&dev->tx_lock);
Sagar Dharia33beca02012-10-22 16:21:46 -0600296 msm_slim_put_ctrl(dev);
297 return -EREMOTEIO;
Sagar Dharia71fcea52012-09-12 23:21:57 -0600298 }
299 if (txn->mt == SLIM_MSG_MT_CORE &&
300 (txn->mc == SLIM_MSG_MC_CONNECT_SOURCE ||
301 txn->mc == SLIM_MSG_MC_CONNECT_SINK ||
302 txn->mc == SLIM_MSG_MC_DISCONNECT_PORT)) {
303 int i = 0;
304 txn->mt = SLIM_MSG_MT_DEST_REFERRED_USER;
305 if (txn->mc == SLIM_MSG_MC_CONNECT_SOURCE)
306 txn->mc = SLIM_USR_MC_CONNECT_SRC;
307 else if (txn->mc == SLIM_MSG_MC_CONNECT_SINK)
308 txn->mc = SLIM_USR_MC_CONNECT_SINK;
309 else if (txn->mc == SLIM_MSG_MC_DISCONNECT_PORT)
310 txn->mc = SLIM_USR_MC_DISCONNECT_PORT;
Sagar Dhariaa3c6a382013-06-21 12:18:20 -0600311 if (txn->la == SLIM_LA_MGR) {
312 if (dev->pgdla == SLIM_LA_MGR) {
313 u8 ea[] = {0, QC_DEVID_PGD, 0, 0, QC_MFGID_MSB,
314 QC_MFGID_LSB};
315 ea[2] = (u8)(dev->pdata.eapc & 0xFF);
316 ea[3] = (u8)((dev->pdata.eapc & 0xFF00) >> 8);
317 mutex_unlock(&dev->tx_lock);
318 ret = dev->ctrl.get_laddr(&dev->ctrl, ea, 6,
319 &dev->pgdla);
320 pr_debug("SLIM PGD LA:0x%x, ret:%d", dev->pgdla,
321 ret);
322 if (ret) {
323 pr_err("Incorrect SLIM-PGD EAPC:0x%x",
324 dev->pdata.eapc);
325 return ret;
326 }
327 mutex_lock(&dev->tx_lock);
328 }
Sagar Dharia71fcea52012-09-12 23:21:57 -0600329 txn->la = dev->pgdla;
Sagar Dhariaa3c6a382013-06-21 12:18:20 -0600330 }
Sagar Dharia71fcea52012-09-12 23:21:57 -0600331 wbuf[i++] = txn->la;
332 la = SLIM_LA_MGR;
333 wbuf[i++] = txn->wbuf[0];
334 if (txn->mc != SLIM_USR_MC_DISCONNECT_PORT)
335 wbuf[i++] = txn->wbuf[1];
336 ret = ngd_get_tid(ctrl, txn, &wbuf[i++], &done);
337 if (ret) {
338 pr_err("TID for connect/disconnect fail:%d", ret);
339 goto ngd_xfer_err;
340 }
341 txn->len = i;
342 txn->wbuf = wbuf;
343 txn->rl = txn->len + 4;
344 }
345 txn->rl--;
346 pbuf = msm_get_msg_buf(dev, txn->rl);
347 if (!pbuf) {
348 dev_err(dev->dev, "Message buffer unavailable");
349 ret = -ENOMEM;
350 goto ngd_xfer_err;
351 }
352 dev->err = 0;
353
354 if (txn->dt == SLIM_MSG_DEST_ENUMADDR) {
355 ret = -EPROTONOSUPPORT;
356 goto ngd_xfer_err;
357 }
358 if (txn->dt == SLIM_MSG_DEST_LOGICALADDR)
359 *pbuf = SLIM_MSG_ASM_FIRST_WORD(txn->rl, txn->mt, txn->mc, 0,
360 la);
361 else
362 *pbuf = SLIM_MSG_ASM_FIRST_WORD(txn->rl, txn->mt, txn->mc, 1,
363 la);
364 if (txn->dt == SLIM_MSG_DEST_LOGICALADDR)
365 puc = ((u8 *)pbuf) + 3;
366 else
367 puc = ((u8 *)pbuf) + 2;
368 if (txn->rbuf)
369 *(puc++) = txn->tid;
370 if ((txn->mt == SLIM_MSG_MT_CORE) &&
371 ((txn->mc >= SLIM_MSG_MC_REQUEST_INFORMATION &&
372 txn->mc <= SLIM_MSG_MC_REPORT_INFORMATION) ||
373 (txn->mc >= SLIM_MSG_MC_REQUEST_VALUE &&
374 txn->mc <= SLIM_MSG_MC_CHANGE_VALUE))) {
375 *(puc++) = (txn->ec & 0xFF);
376 *(puc++) = (txn->ec >> 8)&0xFF;
377 }
378 if (txn->wbuf)
379 memcpy(puc, txn->wbuf, txn->len);
380 if (txn->mt == SLIM_MSG_MT_DEST_REFERRED_USER &&
381 (txn->mc == SLIM_USR_MC_CONNECT_SRC ||
382 txn->mc == SLIM_USR_MC_CONNECT_SINK ||
383 txn->mc == SLIM_USR_MC_DISCONNECT_PORT) && txn->wbuf &&
384 wbuf[0] == dev->pgdla) {
Sagar Dharia2d74c142013-05-17 02:24:06 -0600385 if (txn->mc != SLIM_USR_MC_DISCONNECT_PORT)
Sagar Dharia71fcea52012-09-12 23:21:57 -0600386 dev->err = msm_slim_connect_pipe_port(dev, wbuf[1]);
387 else {
Sagar Dharia71fcea52012-09-12 23:21:57 -0600388 /*
389 * Remove channel disconnects master-side ports from
390 * channel. No need to send that again on the bus
Sagar Dharia2d74c142013-05-17 02:24:06 -0600391 * Only disable port
Sagar Dharia71fcea52012-09-12 23:21:57 -0600392 */
Sagar Dharia2d74c142013-05-17 02:24:06 -0600393 writel_relaxed(0, PGD_PORT(PGD_PORT_CFGn,
394 (wbuf[1] + dev->port_b), dev->ver));
Sagar Dharia71fcea52012-09-12 23:21:57 -0600395 mutex_unlock(&dev->tx_lock);
Sagar Dhariacc1001e2012-11-06 13:56:42 -0700396 msm_slim_put_ctrl(dev);
Sagar Dharia71fcea52012-09-12 23:21:57 -0600397 return 0;
398 }
399 if (dev->err) {
400 dev_err(dev->dev, "pipe-port connect err:%d", dev->err);
401 goto ngd_xfer_err;
402 }
Sagar Dhariaa3c6a382013-06-21 12:18:20 -0600403 /* Add port-base to port number if this is manager side port */
404 puc[1] += dev->port_b;
Sagar Dharia71fcea52012-09-12 23:21:57 -0600405 }
406 dev->err = 0;
Sagar Dharia8e554ed2013-07-19 15:48:15 -0600407 /*
408 * If it's a read txn, it may be freed if a response is received by
409 * received thread before reaching end of this function.
410 * mc, mt may have changed to convert standard slimbus code/type to
411 * satellite user-defined message. Reinitialize again
412 */
413 txn_mc = txn->mc;
414 txn_mt = txn->mt;
Sagar Dharia71fcea52012-09-12 23:21:57 -0600415 dev->wr_comp = &tx_sent;
416 ret = msm_send_msg_buf(dev, pbuf, txn->rl,
417 NGD_BASE(dev->ctrl.nr, dev->ver) + NGD_TX_MSG);
418 if (!ret) {
419 int timeout = wait_for_completion_timeout(&tx_sent, HZ);
Sagar Dharia5c8ad192013-05-31 11:39:05 -0600420 if (!timeout) {
Sagar Dharia71fcea52012-09-12 23:21:57 -0600421 ret = -ETIMEDOUT;
Sagar Dharia5c8ad192013-05-31 11:39:05 -0600422 /*
423 * disconnect/recoonect pipe so that subsequent
424 * transactions don't timeout due to unavailable
425 * descriptors
426 */
427 msm_slim_disconnect_endp(dev, &dev->tx_msgq,
428 &dev->use_tx_msgqs);
429 msm_slim_connect_endp(dev, &dev->tx_msgq, NULL);
430 } else {
Sagar Dharia71fcea52012-09-12 23:21:57 -0600431 ret = dev->err;
Sagar Dharia5c8ad192013-05-31 11:39:05 -0600432 }
Sagar Dharia71fcea52012-09-12 23:21:57 -0600433 }
434 dev->wr_comp = NULL;
435 if (ret) {
436 u32 conf, stat, rx_msgq, int_stat, int_en, int_clr;
437 void __iomem *ngd = dev->base + NGD_BASE(dev->ctrl.nr,
438 dev->ver);
439 dev_err(dev->dev, "TX failed :MC:0x%x,mt:0x%x, ret:%d, ver:%d",
Sagar Dharia8e554ed2013-07-19 15:48:15 -0600440 txn_mc, txn_mt, ret, dev->ver);
Sagar Dharia71fcea52012-09-12 23:21:57 -0600441 conf = readl_relaxed(ngd);
442 stat = readl_relaxed(ngd + NGD_STATUS);
443 rx_msgq = readl_relaxed(ngd + NGD_RX_MSGQ_CFG);
444 int_stat = readl_relaxed(ngd + NGD_INT_STAT);
445 int_en = readl_relaxed(ngd + NGD_INT_EN);
446 int_clr = readl_relaxed(ngd + NGD_INT_CLR);
447
448 pr_err("conf:0x%x,stat:0x%x,rxmsgq:0x%x", conf, stat, rx_msgq);
449 pr_err("int_stat:0x%x,int_en:0x%x,int_cll:0x%x", int_stat,
450 int_en, int_clr);
Sagar Dharia8e554ed2013-07-19 15:48:15 -0600451 } else if (txn_mt == SLIM_MSG_MT_DEST_REFERRED_USER &&
452 (txn_mc == SLIM_USR_MC_CONNECT_SRC ||
453 txn_mc == SLIM_USR_MC_CONNECT_SINK ||
454 txn_mc == SLIM_USR_MC_DISCONNECT_PORT)) {
Sagar Dharia71fcea52012-09-12 23:21:57 -0600455 int timeout;
456 mutex_unlock(&dev->tx_lock);
Sagar Dhariacc1001e2012-11-06 13:56:42 -0700457 msm_slim_put_ctrl(dev);
Sagar Dharia71fcea52012-09-12 23:21:57 -0600458 timeout = wait_for_completion_timeout(txn->comp, HZ);
Sagar Dharia33beca02012-10-22 16:21:46 -0600459 if (!timeout)
Sagar Dharia71fcea52012-09-12 23:21:57 -0600460 ret = -ETIMEDOUT;
Sagar Dharia33beca02012-10-22 16:21:46 -0600461 else
462 ret = txn->ec;
463 if (ret) {
464 pr_err("connect/disconnect:0x%x,tid:%d err:%d", txn->mc,
465 txn->tid, ret);
Sagar Dhariad2959352012-12-01 15:43:01 -0700466 mutex_lock(&ctrl->m_ctrl);
467 ctrl->txnt[txn->tid] = NULL;
468 mutex_unlock(&ctrl->m_ctrl);
Sagar Dharia71fcea52012-09-12 23:21:57 -0600469 }
Sagar Dharia71fcea52012-09-12 23:21:57 -0600470 return ret ? ret : dev->err;
471 }
472ngd_xfer_err:
473 mutex_unlock(&dev->tx_lock);
Sagar Dharia8e554ed2013-07-19 15:48:15 -0600474 if (txn_mc != SLIM_USR_MC_REPORT_SATELLITE)
Sagar Dharia33beca02012-10-22 16:21:46 -0600475 msm_slim_put_ctrl(dev);
Sagar Dharia71fcea52012-09-12 23:21:57 -0600476 return ret ? ret : dev->err;
477}
478
479static int ngd_xferandwait_ack(struct slim_controller *ctrl,
480 struct slim_msg_txn *txn)
481{
482 int ret = ngd_xfer_msg(ctrl, txn);
483 if (!ret) {
484 int timeout;
485 timeout = wait_for_completion_timeout(txn->comp, HZ);
Sagar Dharia33beca02012-10-22 16:21:46 -0600486 if (!timeout)
Sagar Dharia71fcea52012-09-12 23:21:57 -0600487 ret = -ETIMEDOUT;
Sagar Dharia33beca02012-10-22 16:21:46 -0600488 else
Sagar Dharia71fcea52012-09-12 23:21:57 -0600489 ret = txn->ec;
Sagar Dharia71fcea52012-09-12 23:21:57 -0600490 }
Sagar Dharia33beca02012-10-22 16:21:46 -0600491 if (ret) {
Sagar Dharia71fcea52012-09-12 23:21:57 -0600492 pr_err("master msg:0x%x,tid:%d ret:%d", txn->mc,
493 txn->tid, ret);
Sagar Dharia33beca02012-10-22 16:21:46 -0600494 mutex_lock(&ctrl->m_ctrl);
495 ctrl->txnt[txn->tid] = NULL;
496 mutex_unlock(&ctrl->m_ctrl);
497 }
Sagar Dharia71fcea52012-09-12 23:21:57 -0600498
499 return ret;
500}
501
502static int ngd_allocbw(struct slim_device *sb, int *subfrmc, int *clkgear)
503{
504 int ret;
505 struct slim_pending_ch *pch;
506 struct slim_msg_txn txn;
507 struct slim_controller *ctrl = sb->ctrl;
508 DECLARE_COMPLETION_ONSTACK(done);
Sagar Dharia5c8ad192013-05-31 11:39:05 -0600509 u8 wbuf[SLIM_MSGQ_BUF_LEN];
Sagar Dharia71fcea52012-09-12 23:21:57 -0600510
Sagar Dharia5ee34ae2013-04-26 18:05:37 -0600511 *clkgear = ctrl->clkgear;
512 *subfrmc = 0;
Sagar Dharia71fcea52012-09-12 23:21:57 -0600513 txn.mt = SLIM_MSG_MT_DEST_REFERRED_USER;
514 txn.dt = SLIM_MSG_DEST_LOGICALADDR;
515 txn.la = SLIM_LA_MGR;
516 txn.len = 0;
517 txn.ec = 0;
518 txn.wbuf = wbuf;
519 txn.rbuf = NULL;
520
Sagar Dharia5ee34ae2013-04-26 18:05:37 -0600521 if (ctrl->sched.msgsl != ctrl->sched.pending_msgsl) {
522 pr_debug("slim reserve BW for messaging: req: %d",
523 ctrl->sched.pending_msgsl);
524 txn.mc = SLIM_USR_MC_REQ_BW;
525 wbuf[txn.len++] = ((sb->laddr & 0x1f) |
526 ((u8)(ctrl->sched.pending_msgsl & 0x7) << 5));
527 wbuf[txn.len++] = (u8)(ctrl->sched.pending_msgsl >> 3);
528 ret = ngd_get_tid(ctrl, &txn, &wbuf[txn.len++], &done);
529 if (ret)
530 return ret;
531 txn.rl = txn.len + 4;
532 ret = ngd_xferandwait_ack(ctrl, &txn);
533 if (ret)
534 return ret;
535
536 txn.mc = SLIM_USR_MC_RECONFIG_NOW;
537 txn.len = 2;
538 wbuf[1] = sb->laddr;
539 txn.rl = txn.len + 4;
540 ret = ngd_get_tid(ctrl, &txn, &wbuf[0], &done);
541 if (ret)
542 return ret;
543 ret = ngd_xferandwait_ack(ctrl, &txn);
544 if (ret)
545 return ret;
546
547 txn.len = 0;
548 }
Sagar Dharia71fcea52012-09-12 23:21:57 -0600549 list_for_each_entry(pch, &sb->mark_define, pending) {
550 struct slim_ich *slc;
551 slc = &ctrl->chans[pch->chan];
552 if (!slc) {
553 pr_err("no channel in define?");
554 return -ENXIO;
555 }
556 if (txn.len == 0) {
Sagar Dhariab47c8962012-10-30 13:44:08 -0600557 /* Per protocol, only last 5 bits for client no. */
Sagar Dharia71fcea52012-09-12 23:21:57 -0600558 wbuf[txn.len++] = (u8) (slc->prop.dataf << 5) |
Sagar Dhariab47c8962012-10-30 13:44:08 -0600559 (sb->laddr & 0x1f);
Sagar Dharia71fcea52012-09-12 23:21:57 -0600560 wbuf[txn.len] = slc->seglen;
561 if (slc->coeff == SLIM_COEFF_3)
562 wbuf[txn.len] |= 1 << 5;
563 wbuf[txn.len++] |= slc->prop.auxf << 6;
564 wbuf[txn.len++] = slc->rootexp << 4 | slc->prop.prot;
565 wbuf[txn.len++] = slc->prrate;
566 ret = ngd_get_tid(ctrl, &txn, &wbuf[txn.len++], &done);
567 if (ret) {
568 pr_err("no tid for channel define?");
569 return -ENXIO;
570 }
571 }
572 wbuf[txn.len++] = slc->chan;
Sagar Dhariab47c8962012-10-30 13:44:08 -0600573 pr_debug("slim define chan:%d, tid:0x%x", slc->chan, txn.tid);
Sagar Dharia71fcea52012-09-12 23:21:57 -0600574 }
575 if (txn.len) {
576 txn.mc = SLIM_USR_MC_DEF_ACT_CHAN;
577 txn.rl = txn.len + 4;
578 ret = ngd_xferandwait_ack(ctrl, &txn);
579 if (ret)
580 return ret;
581
582 txn.mc = SLIM_USR_MC_RECONFIG_NOW;
583 txn.len = 2;
584 wbuf[1] = sb->laddr;
585 txn.rl = txn.len + 4;
586 ret = ngd_get_tid(ctrl, &txn, &wbuf[0], &done);
587 if (ret)
588 return ret;
589 ret = ngd_xferandwait_ack(ctrl, &txn);
590 if (ret)
591 return ret;
592 }
593 txn.len = 0;
594 list_for_each_entry(pch, &sb->mark_removal, pending) {
595 struct slim_ich *slc;
596 slc = &ctrl->chans[pch->chan];
597 if (!slc) {
598 pr_err("no channel in removal?");
599 return -ENXIO;
600 }
601 if (txn.len == 0) {
Sagar Dhariab47c8962012-10-30 13:44:08 -0600602 /* Per protocol, only last 5 bits for client no. */
Sagar Dharia71fcea52012-09-12 23:21:57 -0600603 wbuf[txn.len++] = (u8) (SLIM_CH_REMOVE << 6) |
Sagar Dhariab47c8962012-10-30 13:44:08 -0600604 (sb->laddr & 0x1f);
Sagar Dharia71fcea52012-09-12 23:21:57 -0600605 ret = ngd_get_tid(ctrl, &txn, &wbuf[txn.len++], &done);
606 if (ret) {
607 pr_err("no tid for channel define?");
608 return -ENXIO;
609 }
610 }
611 wbuf[txn.len++] = slc->chan;
Sagar Dhariab47c8962012-10-30 13:44:08 -0600612 pr_debug("slim remove chan:%d, tid:0x%x", slc->chan, txn.tid);
Sagar Dharia71fcea52012-09-12 23:21:57 -0600613 }
614 if (txn.len) {
615 txn.mc = SLIM_USR_MC_CHAN_CTRL;
616 txn.rl = txn.len + 4;
617 ret = ngd_xferandwait_ack(ctrl, &txn);
618 if (ret)
619 return ret;
620
621 txn.mc = SLIM_USR_MC_RECONFIG_NOW;
622 txn.len = 2;
623 wbuf[1] = sb->laddr;
624 txn.rl = txn.len + 4;
625 ret = ngd_get_tid(ctrl, &txn, &wbuf[0], &done);
626 if (ret)
627 return ret;
628 ret = ngd_xferandwait_ack(ctrl, &txn);
629 if (ret)
630 return ret;
631 txn.len = 0;
632 }
Sagar Dharia24419e32013-01-14 17:56:32 -0700633 return 0;
Sagar Dharia71fcea52012-09-12 23:21:57 -0600634}
635
636static int ngd_set_laddr(struct slim_controller *ctrl, const u8 *ea,
637 u8 elen, u8 laddr)
638{
639 return 0;
640}
641
642static int ngd_get_laddr(struct slim_controller *ctrl, const u8 *ea,
643 u8 elen, u8 *laddr)
644{
645 int ret;
646 u8 wbuf[10];
647 struct slim_msg_txn txn;
648 DECLARE_COMPLETION_ONSTACK(done);
649 txn.mt = SLIM_MSG_MT_DEST_REFERRED_USER;
650 txn.dt = SLIM_MSG_DEST_LOGICALADDR;
651 txn.la = SLIM_LA_MGR;
652 txn.ec = 0;
Sagar Dharia71fcea52012-09-12 23:21:57 -0600653 ret = ngd_get_tid(ctrl, &txn, &wbuf[0], &done);
654 if (ret) {
Sagar Dharia71fcea52012-09-12 23:21:57 -0600655 return ret;
656 }
657 memcpy(&wbuf[1], ea, elen);
658 txn.mc = SLIM_USR_MC_ADDR_QUERY;
659 txn.rl = 11;
660 txn.len = 7;
661 txn.wbuf = wbuf;
662 txn.rbuf = NULL;
663 ret = ngd_xferandwait_ack(ctrl, &txn);
664 if (!ret && txn.la == 0xFF)
665 ret = -ENXIO;
666 else if (!ret)
667 *laddr = txn.la;
Sagar Dharia71fcea52012-09-12 23:21:57 -0600668 return ret;
669}
670
Sagar Dharia5c8ad192013-05-31 11:39:05 -0600671static void ngd_slim_setup_msg_path(struct msm_slim_ctrl *dev)
Sagar Dharia24419e32013-01-14 17:56:32 -0700672{
Sagar Dharia24419e32013-01-14 17:56:32 -0700673 if (dev->state == MSM_CTRL_DOWN) {
674 msm_slim_sps_init(dev, dev->bam_mem,
675 NGD_BASE(dev->ctrl.nr,
676 dev->ver) + NGD_STATUS, true);
677 } else {
678 if (dev->use_rx_msgqs == MSM_MSGQ_DISABLED)
Sagar Dharia5c8ad192013-05-31 11:39:05 -0600679 goto setup_tx_msg_path;
680 msm_slim_connect_endp(dev, &dev->rx_msgq,
Sagar Dharia24419e32013-01-14 17:56:32 -0700681 &dev->rx_msgq_notify);
Sagar Dharia5c8ad192013-05-31 11:39:05 -0600682
683setup_tx_msg_path:
684 if (dev->use_tx_msgqs == MSM_MSGQ_DISABLED)
685 return;
686 msm_slim_connect_endp(dev, &dev->tx_msgq,
687 NULL);
Sagar Dharia24419e32013-01-14 17:56:32 -0700688 }
689}
Sagar Dharia5c8ad192013-05-31 11:39:05 -0600690
Sagar Dharia71fcea52012-09-12 23:21:57 -0600691static void ngd_slim_rx(struct msm_slim_ctrl *dev, u8 *buf)
692{
693 u8 mc, mt, len;
694 int ret;
695 u32 msgq_en = 1;
696
697 len = buf[0] & 0x1F;
698 mt = (buf[0] >> 5) & 0x7;
699 mc = buf[1];
700 if (mc == SLIM_USR_MC_MASTER_CAPABILITY &&
701 mt == SLIM_MSG_MT_SRC_REFERRED_USER) {
702 struct slim_msg_txn txn;
Sagar Dharia0a693332013-04-15 17:59:03 -0600703 int retries = 0;
Sagar Dharia71fcea52012-09-12 23:21:57 -0600704 u8 wbuf[8];
705 txn.dt = SLIM_MSG_DEST_LOGICALADDR;
706 txn.ec = 0;
707 txn.rbuf = NULL;
708 txn.mc = SLIM_USR_MC_REPORT_SATELLITE;
709 txn.mt = SLIM_MSG_MT_SRC_REFERRED_USER;
710 txn.la = SLIM_LA_MGR;
Sagar Dharia71fcea52012-09-12 23:21:57 -0600711 wbuf[0] = SAT_MAGIC_LSB;
712 wbuf[1] = SAT_MAGIC_MSB;
713 wbuf[2] = SAT_MSG_VER;
714 wbuf[3] = SAT_MSG_PROT;
715 txn.wbuf = wbuf;
716 txn.len = 4;
Sagar Dhariacc1001e2012-11-06 13:56:42 -0700717 pr_info("SLIM SAT: Received master capability");
Sagar Dharia24419e32013-01-14 17:56:32 -0700718 if (dev->state >= MSM_CTRL_ASLEEP) {
Sagar Dharia5c8ad192013-05-31 11:39:05 -0600719 ngd_slim_setup_msg_path(dev);
Sagar Dharia24419e32013-01-14 17:56:32 -0700720 if (dev->use_rx_msgqs == MSM_MSGQ_ENABLED)
Sagar Dharia33beca02012-10-22 16:21:46 -0600721 msgq_en |= NGD_CFG_RX_MSGQ_EN;
Sagar Dharia5c8ad192013-05-31 11:39:05 -0600722 if (dev->use_tx_msgqs == MSM_MSGQ_ENABLED)
723 msgq_en |= NGD_CFG_TX_MSGQ_EN;
Sagar Dharia33beca02012-10-22 16:21:46 -0600724 writel_relaxed(msgq_en, dev->base +
725 NGD_BASE(dev->ctrl.nr, dev->ver));
726 /* make sure NGD MSG-Q config goes through */
727 mb();
728 }
Sagar Dharia0a693332013-04-15 17:59:03 -0600729capability_retry:
730 txn.rl = 8;
Sagar Dharia71fcea52012-09-12 23:21:57 -0600731 ret = ngd_xfer_msg(&dev->ctrl, &txn);
732 if (!ret) {
Sagar Dharia33beca02012-10-22 16:21:46 -0600733 enum msm_ctrl_state prev_state = dev->state;
Sagar Dharia71fcea52012-09-12 23:21:57 -0600734 dev->state = MSM_CTRL_AWAKE;
Sagar Dharia33beca02012-10-22 16:21:46 -0600735 if (prev_state >= MSM_CTRL_ASLEEP)
736 complete(&dev->reconf);
737 else
738 pr_err("SLIM: unexpected capability, state:%d",
739 prev_state);
740 /* ADSP SSR, send device_up notifications */
741 if (prev_state == MSM_CTRL_DOWN)
742 schedule_work(&dev->slave_notify);
Sagar Dharia0a693332013-04-15 17:59:03 -0600743 } else if (ret == -EIO) {
744 pr_info("capability message NACKed, retrying");
745 if (retries < INIT_MX_RETRIES) {
746 msleep(DEF_RETRY_MS);
747 retries++;
748 goto capability_retry;
749 }
Sagar Dharia71fcea52012-09-12 23:21:57 -0600750 }
751 }
752 if (mc == SLIM_MSG_MC_REPLY_INFORMATION ||
753 mc == SLIM_MSG_MC_REPLY_VALUE) {
754 u8 tid = buf[3];
755 dev_dbg(dev->dev, "tid:%d, len:%d\n", tid, len);
756 slim_msg_response(&dev->ctrl, &buf[4], tid,
757 len - 4);
758 pm_runtime_mark_last_busy(dev->dev);
759 }
760 if (mc == SLIM_USR_MC_ADDR_REPLY &&
761 mt == SLIM_MSG_MT_SRC_REFERRED_USER) {
Sagar Dhariad2959352012-12-01 15:43:01 -0700762 struct slim_msg_txn *txn;
Sagar Dharia71fcea52012-09-12 23:21:57 -0600763 u8 failed_ea[6] = {0, 0, 0, 0, 0, 0};
Sagar Dhariad2959352012-12-01 15:43:01 -0700764 mutex_lock(&dev->ctrl.m_ctrl);
765 txn = dev->ctrl.txnt[buf[3]];
766 if (!txn) {
767 pr_err("LADDR response after timeout, tid:0x%x",
768 buf[3]);
769 mutex_unlock(&dev->ctrl.m_ctrl);
Sagar Dharia71fcea52012-09-12 23:21:57 -0600770 return;
Sagar Dhariad2959352012-12-01 15:43:01 -0700771 }
Sagar Dharia71fcea52012-09-12 23:21:57 -0600772 if (memcmp(&buf[4], failed_ea, 6))
773 txn->la = buf[10];
774 dev->ctrl.txnt[buf[3]] = NULL;
Sagar Dhariad2959352012-12-01 15:43:01 -0700775 mutex_unlock(&dev->ctrl.m_ctrl);
Sagar Dharia71fcea52012-09-12 23:21:57 -0600776 complete(txn->comp);
777 }
778 if (mc == SLIM_USR_MC_GENERIC_ACK &&
779 mt == SLIM_MSG_MT_SRC_REFERRED_USER) {
Sagar Dhariad2959352012-12-01 15:43:01 -0700780 struct slim_msg_txn *txn;
781 mutex_lock(&dev->ctrl.m_ctrl);
782 txn = dev->ctrl.txnt[buf[3]];
783 if (!txn) {
784 pr_err("ACK received after timeout, tid:0x%x",
785 buf[3]);
786 mutex_unlock(&dev->ctrl.m_ctrl);
Sagar Dharia71fcea52012-09-12 23:21:57 -0600787 return;
Sagar Dhariad2959352012-12-01 15:43:01 -0700788 }
Sagar Dharia71fcea52012-09-12 23:21:57 -0600789 dev_dbg(dev->dev, "got response:tid:%d, response:0x%x",
790 (int)buf[3], buf[4]);
791 if (!(buf[4] & MSM_SAT_SUCCSS)) {
792 dev_err(dev->dev, "TID:%d, NACK code:0x%x", (int)buf[3],
793 buf[4]);
794 txn->ec = -EIO;
795 }
796 dev->ctrl.txnt[buf[3]] = NULL;
Sagar Dhariad2959352012-12-01 15:43:01 -0700797 mutex_unlock(&dev->ctrl.m_ctrl);
Sagar Dharia71fcea52012-09-12 23:21:57 -0600798 complete(txn->comp);
799 }
800}
Sagar Dhariacc1001e2012-11-06 13:56:42 -0700801
Sagar Dharia33beca02012-10-22 16:21:46 -0600802static int ngd_slim_power_up(struct msm_slim_ctrl *dev)
Sagar Dhariacc1001e2012-11-06 13:56:42 -0700803{
Sagar Dharia33beca02012-10-22 16:21:46 -0600804 void __iomem *ngd;
805 int timeout, ret;
806 enum msm_ctrl_state cur_state = dev->state;
807 u32 laddr;
Sagar Dharia24419e32013-01-14 17:56:32 -0700808 u32 ngd_int = (NGD_INT_TX_NACKED_2 |
Sagar Dhariacc1001e2012-11-06 13:56:42 -0700809 NGD_INT_MSG_BUF_CONTE | NGD_INT_MSG_TX_INVAL |
810 NGD_INT_IE_VE_CHG | NGD_INT_DEV_ERR |
811 NGD_INT_TX_MSG_SENT | NGD_INT_RX_MSG_RCVD);
Sagar Dharia33beca02012-10-22 16:21:46 -0600812
813 if (cur_state == MSM_CTRL_DOWN) {
814 int timeout = wait_for_completion_timeout(&dev->qmi.qmi_comp,
815 HZ);
816 if (!timeout)
817 pr_err("slimbus QMI init timed out");
818 }
819
820 ret = msm_slim_qmi_power_request(dev, true);
821 if (ret) {
822 pr_err("SLIM QMI power request failed:%d", ret);
823 return ret;
824 }
825 if (!dev->ver) {
826 dev->ver = readl_relaxed(dev->base);
827 /* Version info in 16 MSbits */
828 dev->ver >>= 16;
829 }
830 ngd = dev->base + NGD_BASE(dev->ctrl.nr, dev->ver);
831 laddr = readl_relaxed(ngd + NGD_STATUS);
832 if (laddr & NGD_LADDR) {
Sagar Dhariacc1001e2012-11-06 13:56:42 -0700833 /*
Sagar Dharia33beca02012-10-22 16:21:46 -0600834 * ADSP power collapse case, where HW wasn't reset.
835 * Reconnect BAM pipes if disconnected
Sagar Dhariacc1001e2012-11-06 13:56:42 -0700836 */
Sagar Dharia5c8ad192013-05-31 11:39:05 -0600837 ngd_slim_setup_msg_path(dev);
Sagar Dharia33beca02012-10-22 16:21:46 -0600838 return 0;
839 } else if (cur_state != MSM_CTRL_DOWN) {
840 pr_info("ADSP P.C. CTRL state:%d NGD not enumerated:0x%x",
841 dev->state, laddr);
Sagar Dharia33beca02012-10-22 16:21:46 -0600842 }
Sagar Dhariada48bd62013-03-21 18:02:40 -0600843 /* ADSP SSR scenario, need to disconnect pipe before connecting */
844 if (dev->use_rx_msgqs == MSM_MSGQ_DOWN) {
845 struct msm_slim_endp *endpoint = &dev->rx_msgq;
846 sps_disconnect(endpoint->sps);
847 sps_free_endpoint(endpoint->sps);
848 dev->use_rx_msgqs = MSM_MSGQ_RESET;
849 }
Sagar Dharia5c8ad192013-05-31 11:39:05 -0600850 if (dev->use_tx_msgqs == MSM_MSGQ_DOWN) {
851 struct msm_slim_endp *endpoint = &dev->tx_msgq;
852 sps_disconnect(endpoint->sps);
853 sps_free_endpoint(endpoint->sps);
854 dev->use_tx_msgqs = MSM_MSGQ_RESET;
855 }
Sagar Dharia33beca02012-10-22 16:21:46 -0600856 /*
857 * ADSP power collapse case (OR SSR), where HW was reset
858 * BAM programming will happen when capability message is received
859 */
860 writel_relaxed(ngd_int, dev->base + NGD_INT_EN +
Sagar Dhariacc1001e2012-11-06 13:56:42 -0700861 NGD_BASE(dev->ctrl.nr, dev->ver));
Sagar Dharia33beca02012-10-22 16:21:46 -0600862 /*
863 * Enable NGD. Configure NGD in register acc. mode until master
864 * announcement is received
865 */
Sagar Dharia24419e32013-01-14 17:56:32 -0700866 writel_relaxed(1, dev->base + NGD_BASE(dev->ctrl.nr, dev->ver));
Sagar Dharia33beca02012-10-22 16:21:46 -0600867 /* make sure NGD enabling goes through */
868 mb();
869
870 timeout = wait_for_completion_timeout(&dev->reconf, HZ);
871 if (!timeout) {
872 pr_err("failed to received master capability");
873 return -ETIMEDOUT;
874 }
875 if (cur_state == MSM_CTRL_DOWN)
876 complete(&dev->ctrl_up);
877 return 0;
878}
879
880static int ngd_slim_enable(struct msm_slim_ctrl *dev, bool enable)
881{
882 int ret = 0;
883 if (enable) {
884 ret = msm_slim_qmi_init(dev, false);
885 /* controller state should be in sync with framework state */
886 if (!ret) {
887 ret = slim_ctrl_clk_pause(&dev->ctrl, false,
888 SLIM_CLK_UNSPECIFIED);
889 complete(&dev->qmi.qmi_comp);
890 /*
891 * Power-up won't be called if clock pause failed.
892 * This can happen if ADSP SSR happened when audio
893 * session is in progress. Framework will think that
894 * clock pause failed so no need to wakeup controller.
895 * Call power-up explicitly in that case, since slimbus
896 * HW needs to be powered-on to be in sync with
897 * framework state
898 */
899 if (ret)
900 ngd_slim_power_up(dev);
901 if (!pm_runtime_enabled(dev->dev) ||
902 !pm_runtime_suspended(dev->dev))
903 ngd_slim_runtime_resume(dev->dev);
904 else
905 pm_runtime_resume(dev->dev);
906 pm_runtime_mark_last_busy(dev->dev);
907 pm_runtime_put(dev->dev);
908 } else
909 dev_err(dev->dev, "qmi init fail, ret:%d, state:%d",
910 ret, dev->state);
911 } else {
Sagar Dhariacc1001e2012-11-06 13:56:42 -0700912 msm_slim_qmi_exit(dev);
913 }
914
Sagar Dharia33beca02012-10-22 16:21:46 -0600915 return ret;
916}
917
918static int ngd_clk_pause_wakeup(struct slim_controller *ctrl)
919{
920 struct msm_slim_ctrl *dev = slim_get_ctrldata(ctrl);
921 return ngd_slim_power_up(dev);
Sagar Dhariacc1001e2012-11-06 13:56:42 -0700922}
923
Sagar Dharia71fcea52012-09-12 23:21:57 -0600924static int ngd_slim_rx_msgq_thread(void *data)
925{
926 struct msm_slim_ctrl *dev = (struct msm_slim_ctrl *)data;
927 struct completion *notify = &dev->rx_msgq_notify;
928 int ret = 0, index = 0;
929 u32 mc = 0;
930 u32 mt = 0;
931 u32 buffer[10];
932 u8 msg_len = 0;
933
934 while (!kthread_should_stop()) {
935 set_current_state(TASK_INTERRUPTIBLE);
936 ret = wait_for_completion_interruptible(notify);
937 if (ret) {
938 dev_err(dev->dev, "rx thread wait err:%d", ret);
939 continue;
940 }
941 /* 1 irq notification per message */
Sagar Dharia24419e32013-01-14 17:56:32 -0700942 if (dev->use_rx_msgqs != MSM_MSGQ_ENABLED) {
Sagar Dharia71fcea52012-09-12 23:21:57 -0600943 msm_slim_rx_dequeue(dev, (u8 *)buffer);
944 ngd_slim_rx(dev, (u8 *)buffer);
945 continue;
946 }
947 ret = msm_slim_rx_msgq_get(dev, buffer, index);
948 if (ret) {
949 dev_err(dev->dev, "rx_msgq_get() failed 0x%x\n", ret);
950 continue;
951 }
952
953 /* Wait for complete message */
954 if (index++ == 0) {
955 msg_len = *buffer & 0x1F;
956 mt = (buffer[0] >> 5) & 0x7;
957 mc = (buffer[0] >> 8) & 0xff;
958 dev_dbg(dev->dev, "MC: %x, MT: %x\n", mc, mt);
959 }
960 if ((index * 4) >= msg_len) {
961 index = 0;
962 ngd_slim_rx(dev, (u8 *)buffer);
963 } else
964 continue;
965 }
966 return 0;
967}
968
Sagar Dharia33beca02012-10-22 16:21:46 -0600969static void ngd_laddr_lookup(struct work_struct *work)
970{
971 struct msm_slim_ctrl *dev =
972 container_of(work, struct msm_slim_ctrl, slave_notify);
973 struct slim_controller *ctrl = &dev->ctrl;
974 struct slim_device *sbdev;
975 int i;
976 mutex_lock(&ctrl->m_ctrl);
977 list_for_each_entry(sbdev, &ctrl->devs, dev_list) {
978 int ret = 0;
979 mutex_unlock(&ctrl->m_ctrl);
980 for (i = 0; i < LADDR_RETRY; i++) {
981 ret = slim_get_logical_addr(sbdev, sbdev->e_addr,
982 6, &sbdev->laddr);
983 if (!ret)
984 break;
985 else /* time for ADSP to assign LA */
986 msleep(20);
987 }
988 mutex_lock(&ctrl->m_ctrl);
989 }
990 mutex_unlock(&ctrl->m_ctrl);
991}
992
993static void ngd_adsp_down(struct work_struct *work)
994{
995 struct msm_slim_qmi *qmi =
996 container_of(work, struct msm_slim_qmi, ssr_down);
997 struct msm_slim_ctrl *dev =
998 container_of(qmi, struct msm_slim_ctrl, qmi);
999 struct slim_controller *ctrl = &dev->ctrl;
1000 struct slim_device *sbdev;
1001 int i;
1002
1003 ngd_slim_enable(dev, false);
1004 /* disconnect BAM pipes */
Sagar Dhariada48bd62013-03-21 18:02:40 -06001005 if (dev->use_rx_msgqs == MSM_MSGQ_ENABLED)
1006 dev->use_rx_msgqs = MSM_MSGQ_DOWN;
Sagar Dharia5c8ad192013-05-31 11:39:05 -06001007 if (dev->use_tx_msgqs == MSM_MSGQ_ENABLED)
1008 dev->use_tx_msgqs = MSM_MSGQ_DOWN;
Sagar Dharia33beca02012-10-22 16:21:46 -06001009 msm_slim_sps_exit(dev, false);
Sagar Dharia33beca02012-10-22 16:21:46 -06001010 mutex_lock(&ctrl->m_ctrl);
1011 /* device up should be called again after SSR */
1012 list_for_each_entry(sbdev, &ctrl->devs, dev_list)
1013 sbdev->notified = false;
1014 /* invalidate logical addresses */
1015 for (i = 0; i < ctrl->num_dev; i++)
1016 ctrl->addrt[i].valid = false;
1017 mutex_unlock(&ctrl->m_ctrl);
1018 pr_info("SLIM ADSP SSR (DOWN) done");
1019}
1020
1021static void ngd_adsp_up(struct work_struct *work)
1022{
1023 struct msm_slim_qmi *qmi =
1024 container_of(work, struct msm_slim_qmi, ssr_up);
1025 struct msm_slim_ctrl *dev =
1026 container_of(qmi, struct msm_slim_ctrl, qmi);
1027 ngd_slim_enable(dev, true);
1028}
1029
Sagar Dharia71fcea52012-09-12 23:21:57 -06001030static int __devinit ngd_slim_probe(struct platform_device *pdev)
1031{
1032 struct msm_slim_ctrl *dev;
1033 int ret;
1034 struct resource *bam_mem;
1035 struct resource *slim_mem;
1036 struct resource *irq, *bam_irq;
1037 enum apr_subsys_state q6_state;
Sagar Dharia24419e32013-01-14 17:56:32 -07001038 bool rxreg_access = false;
Sagar Dharia71fcea52012-09-12 23:21:57 -06001039
1040 q6_state = apr_get_q6_state();
1041 if (q6_state == APR_SUBSYS_DOWN) {
1042 dev_dbg(&pdev->dev, "defering %s, adsp_state %d\n", __func__,
1043 q6_state);
1044 return -EPROBE_DEFER;
1045 } else
1046 dev_dbg(&pdev->dev, "adsp is ready\n");
1047
1048 slim_mem = platform_get_resource_byname(pdev, IORESOURCE_MEM,
1049 "slimbus_physical");
1050 if (!slim_mem) {
1051 dev_err(&pdev->dev, "no slimbus physical memory resource\n");
1052 return -ENODEV;
1053 }
1054 bam_mem = platform_get_resource_byname(pdev, IORESOURCE_MEM,
1055 "slimbus_bam_physical");
1056 if (!bam_mem) {
1057 dev_err(&pdev->dev, "no slimbus BAM memory resource\n");
1058 return -ENODEV;
1059 }
1060 irq = platform_get_resource_byname(pdev, IORESOURCE_IRQ,
1061 "slimbus_irq");
1062 if (!irq) {
1063 dev_err(&pdev->dev, "no slimbus IRQ resource\n");
1064 return -ENODEV;
1065 }
1066 bam_irq = platform_get_resource_byname(pdev, IORESOURCE_IRQ,
1067 "slimbus_bam_irq");
1068 if (!bam_irq) {
1069 dev_err(&pdev->dev, "no slimbus BAM IRQ resource\n");
1070 return -ENODEV;
1071 }
1072
1073 dev = kzalloc(sizeof(struct msm_slim_ctrl), GFP_KERNEL);
1074 if (IS_ERR(dev)) {
1075 dev_err(&pdev->dev, "no memory for MSM slimbus controller\n");
1076 return PTR_ERR(dev);
1077 }
1078 dev->dev = &pdev->dev;
1079 platform_set_drvdata(pdev, dev);
1080 slim_set_ctrldata(&dev->ctrl, dev);
1081 dev->base = ioremap(slim_mem->start, resource_size(slim_mem));
1082 if (!dev->base) {
1083 dev_err(&pdev->dev, "IOremap failed\n");
1084 ret = -ENOMEM;
1085 goto err_ioremap_failed;
1086 }
1087 dev->bam.base = ioremap(bam_mem->start, resource_size(bam_mem));
1088 if (!dev->bam.base) {
1089 dev_err(&pdev->dev, "BAM IOremap failed\n");
1090 ret = -ENOMEM;
1091 goto err_ioremap_bam_failed;
1092 }
1093 if (pdev->dev.of_node) {
1094
1095 ret = of_property_read_u32(pdev->dev.of_node, "cell-index",
1096 &dev->ctrl.nr);
1097 if (ret) {
1098 dev_err(&pdev->dev, "Cell index not specified:%d", ret);
1099 goto err_ctrl_failed;
1100 }
Sagar Dharia24419e32013-01-14 17:56:32 -07001101 rxreg_access = of_property_read_bool(pdev->dev.of_node,
1102 "qcom,rxreg-access");
Sagar Dhariaa3c6a382013-06-21 12:18:20 -06001103 of_property_read_u32(pdev->dev.of_node, "qcom,apps-ch-pipes",
1104 &dev->pdata.apps_pipes);
1105 of_property_read_u32(pdev->dev.of_node, "qcom,ea-pc",
1106 &dev->pdata.eapc);
Sagar Dharia71fcea52012-09-12 23:21:57 -06001107 } else {
1108 dev->ctrl.nr = pdev->id;
1109 }
Sagar Dhariaa3c6a382013-06-21 12:18:20 -06001110 /*
1111 * Keep PGD's logical address as manager's. Query it when first data
1112 * channel request comes in
1113 */
1114 dev->pgdla = SLIM_LA_MGR;
Sagar Dharia71fcea52012-09-12 23:21:57 -06001115 dev->ctrl.nchans = MSM_SLIM_NCHANS;
1116 dev->ctrl.nports = MSM_SLIM_NPORTS;
1117 dev->framer.rootfreq = SLIM_ROOT_FREQ >> 3;
1118 dev->framer.superfreq =
1119 dev->framer.rootfreq / SLIM_CL_PER_SUPERFRAME_DIV8;
1120 dev->ctrl.a_framer = &dev->framer;
1121 dev->ctrl.clkgear = SLIM_MAX_CLK_GEAR;
1122 dev->ctrl.set_laddr = ngd_set_laddr;
1123 dev->ctrl.get_laddr = ngd_get_laddr;
1124 dev->ctrl.allocbw = ngd_allocbw;
1125 dev->ctrl.xfer_msg = ngd_xfer_msg;
Sagar Dhariacc1001e2012-11-06 13:56:42 -07001126 dev->ctrl.wakeup = ngd_clk_pause_wakeup;
Sagar Dharia100e7212013-05-17 18:20:57 -06001127 dev->ctrl.alloc_port = msm_alloc_port;
1128 dev->ctrl.dealloc_port = msm_dealloc_port;
Sagar Dharia71fcea52012-09-12 23:21:57 -06001129 dev->ctrl.port_xfer = msm_slim_port_xfer;
1130 dev->ctrl.port_xfer_status = msm_slim_port_xfer_status;
Sagar Dharia71fcea52012-09-12 23:21:57 -06001131 dev->bam_mem = bam_mem;
1132
1133 init_completion(&dev->reconf);
Sagar Dharia33beca02012-10-22 16:21:46 -06001134 init_completion(&dev->ctrl_up);
Sagar Dharia71fcea52012-09-12 23:21:57 -06001135 mutex_init(&dev->tx_lock);
1136 spin_lock_init(&dev->rx_lock);
1137 dev->ee = 1;
1138 dev->irq = irq->start;
1139 dev->bam.irq = bam_irq->start;
1140
Sagar Dharia24419e32013-01-14 17:56:32 -07001141 if (rxreg_access)
1142 dev->use_rx_msgqs = MSM_MSGQ_DISABLED;
1143 else
1144 dev->use_rx_msgqs = MSM_MSGQ_RESET;
Sagar Dharia5c8ad192013-05-31 11:39:05 -06001145
1146 /* Enable TX message queues by default as recommended by HW */
1147 dev->use_tx_msgqs = MSM_MSGQ_RESET;
1148
Sagar Dharia71fcea52012-09-12 23:21:57 -06001149 init_completion(&dev->rx_msgq_notify);
1150
1151 /* Register with framework */
1152 ret = slim_add_numbered_controller(&dev->ctrl);
1153 if (ret) {
1154 dev_err(dev->dev, "error adding controller\n");
1155 goto err_ctrl_failed;
1156 }
1157
1158 dev->ctrl.dev.parent = &pdev->dev;
1159 dev->ctrl.dev.of_node = pdev->dev.of_node;
Sagar Dharia33beca02012-10-22 16:21:46 -06001160 dev->state = MSM_CTRL_DOWN;
Sagar Dharia71fcea52012-09-12 23:21:57 -06001161
1162 ret = request_irq(dev->irq, ngd_slim_interrupt,
1163 IRQF_TRIGGER_HIGH, "ngd_slim_irq", dev);
1164
1165 if (ret) {
1166 dev_err(&pdev->dev, "request IRQ failed\n");
1167 goto err_request_irq_failed;
1168 }
1169
Sagar Dhariacc1001e2012-11-06 13:56:42 -07001170 init_completion(&dev->qmi.qmi_comp);
Sagar Dharia33beca02012-10-22 16:21:46 -06001171 pm_runtime_use_autosuspend(dev->dev);
1172 pm_runtime_set_autosuspend_delay(dev->dev, MSM_SLIM_AUTOSUSPEND);
1173 pm_runtime_set_suspended(dev->dev);
1174 pm_runtime_enable(dev->dev);
1175
1176 INIT_WORK(&dev->slave_notify, ngd_laddr_lookup);
1177 INIT_WORK(&dev->qmi.ssr_down, ngd_adsp_down);
1178 INIT_WORK(&dev->qmi.ssr_up, ngd_adsp_up);
Sagar Dhariacc1001e2012-11-06 13:56:42 -07001179 dev->qmi.nb.notifier_call = ngd_qmi_available;
Sagar Dharia33beca02012-10-22 16:21:46 -06001180 pm_runtime_get_noresume(dev->dev);
Sagar Dhariacc1001e2012-11-06 13:56:42 -07001181 ret = qmi_svc_event_notifier_register(SLIMBUS_QMI_SVC_ID,
1182 SLIMBUS_QMI_INS_ID, &dev->qmi.nb);
1183 if (ret) {
1184 pr_err("Slimbus QMI service registration failed:%d", ret);
1185 goto qmi_register_failed;
1186 }
1187
Sagar Dharia33beca02012-10-22 16:21:46 -06001188
Sagar Dharia71fcea52012-09-12 23:21:57 -06001189 /* Fire up the Rx message queue thread */
1190 dev->rx_msgq_thread = kthread_run(ngd_slim_rx_msgq_thread, dev,
1191 NGD_SLIM_NAME "_ngd_msgq_thread");
1192 if (IS_ERR(dev->rx_msgq_thread)) {
1193 ret = PTR_ERR(dev->rx_msgq_thread);
1194 dev_err(dev->dev, "Failed to start Rx message queue thread\n");
1195 goto err_thread_create_failed;
1196 }
1197
Sagar Dharia71fcea52012-09-12 23:21:57 -06001198 if (pdev->dev.of_node)
1199 of_register_slim_devices(&dev->ctrl);
1200
1201 /* Add devices registered with board-info now that controller is up */
1202 slim_ctrl_add_boarddevs(&dev->ctrl);
1203
Sagar Dharia71fcea52012-09-12 23:21:57 -06001204 dev_dbg(dev->dev, "NGD SB controller is up!\n");
1205 return 0;
1206
1207err_thread_create_failed:
Sagar Dhariacc1001e2012-11-06 13:56:42 -07001208 qmi_svc_event_notifier_unregister(SLIMBUS_QMI_SVC_ID,
1209 SLIMBUS_QMI_INS_ID, &dev->qmi.nb);
1210qmi_register_failed:
Sagar Dharia71fcea52012-09-12 23:21:57 -06001211 free_irq(dev->irq, dev);
1212err_request_irq_failed:
1213 slim_del_controller(&dev->ctrl);
1214err_ctrl_failed:
1215 iounmap(dev->bam.base);
1216err_ioremap_bam_failed:
1217 iounmap(dev->base);
1218err_ioremap_failed:
1219 kfree(dev);
1220 return ret;
1221}
1222
1223static int __devexit ngd_slim_remove(struct platform_device *pdev)
1224{
1225 struct msm_slim_ctrl *dev = platform_get_drvdata(pdev);
Sagar Dhariacc1001e2012-11-06 13:56:42 -07001226 ngd_slim_enable(dev, false);
1227 qmi_svc_event_notifier_unregister(SLIMBUS_QMI_SVC_ID,
1228 SLIMBUS_QMI_INS_ID, &dev->qmi.nb);
Sagar Dharia71fcea52012-09-12 23:21:57 -06001229 pm_runtime_disable(&pdev->dev);
Sagar Dharia71fcea52012-09-12 23:21:57 -06001230 free_irq(dev->irq, dev);
1231 slim_del_controller(&dev->ctrl);
1232 kthread_stop(dev->rx_msgq_thread);
1233 iounmap(dev->bam.base);
1234 iounmap(dev->base);
1235 kfree(dev);
1236 return 0;
1237}
1238
1239#ifdef CONFIG_PM_RUNTIME
1240static int ngd_slim_runtime_idle(struct device *device)
1241{
1242 dev_dbg(device, "pm_runtime: idle...\n");
1243 pm_request_autosuspend(device);
1244 return -EAGAIN;
1245}
1246#endif
1247
1248/*
1249 * If PM_RUNTIME is not defined, these 2 functions become helper
1250 * functions to be called from system suspend/resume. So they are not
1251 * inside ifdef CONFIG_PM_RUNTIME
1252 */
Sagar Dharia71fcea52012-09-12 23:21:57 -06001253static int ngd_slim_runtime_resume(struct device *device)
1254{
1255 struct platform_device *pdev = to_platform_device(device);
1256 struct msm_slim_ctrl *dev = platform_get_drvdata(pdev);
1257 int ret = 0;
Sagar Dharia33beca02012-10-22 16:21:46 -06001258 if (dev->state >= MSM_CTRL_ASLEEP)
Sagar Dharia71fcea52012-09-12 23:21:57 -06001259 ret = slim_ctrl_clk_pause(&dev->ctrl, true, 0);
1260 if (ret) {
1261 dev_err(device, "clk pause not exited:%d", ret);
1262 dev->state = MSM_CTRL_ASLEEP;
1263 } else {
1264 dev->state = MSM_CTRL_AWAKE;
1265 }
1266 return ret;
1267}
1268
Sagar Dharia33beca02012-10-22 16:21:46 -06001269#ifdef CONFIG_PM_SLEEP
1270static int ngd_slim_runtime_suspend(struct device *device)
1271{
1272 struct platform_device *pdev = to_platform_device(device);
1273 struct msm_slim_ctrl *dev = platform_get_drvdata(pdev);
1274 int ret = 0;
1275 dev->state = MSM_CTRL_SLEEPING;
1276 ret = slim_ctrl_clk_pause(&dev->ctrl, false, SLIM_CLK_UNSPECIFIED);
1277 if (ret) {
1278 if (ret != -EBUSY)
1279 dev_err(device, "clk pause not entered:%d", ret);
1280 dev->state = MSM_CTRL_AWAKE;
1281 } else {
1282 dev->state = MSM_CTRL_ASLEEP;
1283 }
1284 return ret;
1285}
1286
Sagar Dharia71fcea52012-09-12 23:21:57 -06001287static int ngd_slim_suspend(struct device *dev)
1288{
1289 int ret = -EBUSY;
1290 if (!pm_runtime_enabled(dev) || !pm_runtime_suspended(dev)) {
1291 dev_dbg(dev, "system suspend");
1292 ret = ngd_slim_runtime_suspend(dev);
Sagar Dhariaa1398282013-01-22 13:26:20 -07001293 /*
1294 * If runtime-PM still thinks it's active, then make sure its
1295 * status is in sync with HW status.
1296 * Since this suspend calls QMI api, it results in holding a
1297 * wakelock. That results in failure of first suspend.
1298 * Subsequent suspend should not call low-power transition
1299 * again since the HW is already in suspended state.
1300 */
1301 if (!ret) {
1302 pm_runtime_disable(dev);
1303 pm_runtime_set_suspended(dev);
1304 pm_runtime_enable(dev);
1305 }
Sagar Dharia71fcea52012-09-12 23:21:57 -06001306 }
1307 if (ret == -EBUSY) {
1308 /*
1309 * There is a possibility that some audio stream is active
1310 * during suspend. We dont want to return suspend failure in
1311 * that case so that display and relevant components can still
1312 * go to suspend.
1313 * If there is some other error, then it should be passed-on
1314 * to system level suspend
1315 */
1316 ret = 0;
1317 }
1318 return ret;
1319}
1320
1321static int ngd_slim_resume(struct device *dev)
1322{
Sagar Dhariaa1398282013-01-22 13:26:20 -07001323 /*
1324 * Rely on runtime-PM to call resume in case it is enabled.
1325 * Even if it's not enabled, rely on 1st client transaction to do
1326 * clock/power on
1327 */
Sagar Dharia71fcea52012-09-12 23:21:57 -06001328 return 0;
1329}
1330#endif /* CONFIG_PM_SLEEP */
1331
1332static const struct dev_pm_ops ngd_slim_dev_pm_ops = {
1333 SET_SYSTEM_SLEEP_PM_OPS(
1334 ngd_slim_suspend,
1335 ngd_slim_resume
1336 )
1337 SET_RUNTIME_PM_OPS(
1338 ngd_slim_runtime_suspend,
1339 ngd_slim_runtime_resume,
1340 ngd_slim_runtime_idle
1341 )
1342};
1343
1344static struct of_device_id ngd_slim_dt_match[] = {
1345 {
1346 .compatible = "qcom,slim-ngd",
1347 },
1348 {}
1349};
1350
1351static struct platform_driver ngd_slim_driver = {
1352 .probe = ngd_slim_probe,
1353 .remove = ngd_slim_remove,
1354 .driver = {
1355 .name = NGD_SLIM_NAME,
1356 .owner = THIS_MODULE,
1357 .pm = &ngd_slim_dev_pm_ops,
1358 .of_match_table = ngd_slim_dt_match,
1359 },
1360};
1361
1362static int ngd_slim_init(void)
1363{
1364 return platform_driver_register(&ngd_slim_driver);
1365}
1366late_initcall(ngd_slim_init);
1367
1368static void ngd_slim_exit(void)
1369{
1370 platform_driver_unregister(&ngd_slim_driver);
1371}
1372module_exit(ngd_slim_exit);
1373
1374MODULE_LICENSE("GPL v2");
1375MODULE_DESCRIPTION("MSM Slimbus controller");
1376MODULE_ALIAS("platform:msm-slim-ngd");