Merge tag 'csky-for-linus-4.20-fixup-dtb' of https://github.com/c-sky/csky-linux
[linux-block.git] / drivers / soc / fsl / qbman / qman.c
index 8cc0151830433230e8f629c2660eec90871b7e8c..5ce24718c2fd1aa37ef0206a12a102025a987b7d 100644 (file)
@@ -850,12 +850,24 @@ static inline void qm_mr_set_ithresh(struct qm_portal *portal, u8 ithresh)
 
 static inline int qm_mc_init(struct qm_portal *portal)
 {
+       u8 rr0, rr1;
        struct qm_mc *mc = &portal->mc;
 
        mc->cr = portal->addr.ce + QM_CL_CR;
        mc->rr = portal->addr.ce + QM_CL_RR0;
-       mc->rridx = (mc->cr->_ncw_verb & QM_MCC_VERB_VBIT)
-                   ? 0 : 1;
+       /*
+        * The expected valid bit polarity for the next CR command is 0
+        * if RR1 contains a valid response, and is 1 if RR0 contains a
+        * valid response. If both RR contain all 0, this indicates either
+        * that no command has been executed since reset (in which case the
+        * expected valid bit polarity is 1)
+        */
+       rr0 = mc->rr->verb;
+       rr1 = (mc->rr+1)->verb;
+       if ((rr0 == 0 && rr1 == 0) || rr0 != 0)
+               mc->rridx = 1;
+       else
+               mc->rridx = 0;
        mc->vbit = mc->rridx ? QM_MCC_VERB_VBIT : 0;
 #ifdef CONFIG_FSL_DPAA_CHECKING
        mc->state = qman_mc_idle;
@@ -1000,6 +1012,37 @@ static inline void put_affine_portal(void)
 
 static struct workqueue_struct *qm_portal_wq;
 
+void qman_dqrr_set_ithresh(struct qman_portal *portal, u8 ithresh)
+{
+       if (!portal)
+               return;
+
+       qm_dqrr_set_ithresh(&portal->p, ithresh);
+       portal->p.dqrr.ithresh = ithresh;
+}
+EXPORT_SYMBOL(qman_dqrr_set_ithresh);
+
+void qman_dqrr_get_ithresh(struct qman_portal *portal, u8 *ithresh)
+{
+       if (portal && ithresh)
+               *ithresh = portal->p.dqrr.ithresh;
+}
+EXPORT_SYMBOL(qman_dqrr_get_ithresh);
+
+void qman_portal_get_iperiod(struct qman_portal *portal, u32 *iperiod)
+{
+       if (portal && iperiod)
+               *iperiod = qm_in(&portal->p, QM_REG_ITPR);
+}
+EXPORT_SYMBOL(qman_portal_get_iperiod);
+
+void qman_portal_set_iperiod(struct qman_portal *portal, u32 iperiod)
+{
+       if (portal)
+               qm_out(&portal->p, QM_REG_ITPR, iperiod);
+}
+EXPORT_SYMBOL(qman_portal_set_iperiod);
+
 int qman_wq_alloc(void)
 {
        qm_portal_wq = alloc_workqueue("qman_portal_wq", 0, 1);
@@ -1210,11 +1253,9 @@ static int qman_create_portal(struct qman_portal *portal,
                dev_err(c->dev, "request_irq() failed\n");
                goto fail_irq;
        }
-       if (c->cpu != -1 && irq_can_set_affinity(c->irq) &&
-           irq_set_affinity(c->irq, cpumask_of(c->cpu))) {
-               dev_err(c->dev, "irq_set_affinity() failed\n");
+
+       if (dpaa_set_portal_irq_affinity(c->dev, c->irq, c->cpu))
                goto fail_affinity;
-       }
 
        /* Need EQCR to be empty before continuing */
        isdr &= ~QM_PIRQ_EQCI;