source: rtems-libbsd/linux/drivers/soc/fsl/qbman/qman_driver.c @ 28ee86a

55-freebsd-126-freebsd-12
Last change on this file since 28ee86a was 28ee86a, checked in by Sebastian Huber <sebastian.huber@…>, on 04/27/16 at 09:58:19

Import DPAA driver snapshot

Imported from Freescale Linux repository

git://git.freescale.com/ppc/upstream/linux.git

commit 2774c204cd8bfc56a200ff4dcdfc9cdf5b6fc161.

Linux compatibility layer is partly from FreeBSD.

  • Property mode set to 100644
File size: 3.0 KB
Line 
1#include <machine/rtems-bsd-kernel-space.h>
2
3#include <rtems/bsd/local/opt_dpaa.h>
4
5/* Copyright 2013 - 2015 Freescale Semiconductor, Inc.
6 *
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions are met:
9 *     * Redistributions of source code must retain the above copyright
10 *       notice, this list of conditions and the following disclaimer.
11 *     * Redistributions in binary form must reproduce the above copyright
12 *       notice, this list of conditions and the following disclaimer in the
13 *       documentation and/or other materials provided with the distribution.
14 *     * Neither the name of Freescale Semiconductor nor the
15 *       names of its contributors may be used to endorse or promote products
16 *       derived from this software without specific prior written permission.
17 *
18 * ALTERNATIVELY, this software may be distributed under the terms of the
19 * GNU General Public License ("GPL") as published by the Free Software
20 * Foundation, either version 2 of that License or (at your option) any
21 * later version.
22 *
23 * THIS SOFTWARE IS PROVIDED BY Freescale Semiconductor ``AS IS'' AND ANY
24 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
25 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
26 * DISCLAIMED. IN NO EVENT SHALL Freescale Semiconductor BE LIABLE FOR ANY
27 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
28 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
29 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
30 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
31 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
32 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
33 */
34
35#include "qman_priv.h"
36
37#include <linux/time.h>
38
39static int __init early_qman_init(void)
40{
41        struct device_node *dn;
42        u32 is_portal_available;
43
44        qman_init();
45
46        is_portal_available = 0;
47        for_each_compatible_node(dn, NULL, "fsl,qman-portal") {
48                if (of_device_is_available(dn)) {
49                        is_portal_available = 1;
50                        break;
51                }
52        }
53
54        if (!qman_have_ccsr() && is_portal_available) {
55                struct qman_fq fq = {.fqid = 1};
56                struct qm_mcr_queryfq_np np;
57                int err, retry = CONFIG_FSL_QMAN_INIT_TIMEOUT;
58                struct timespec nowts, diffts, startts = current_kernel_time();
59
60                /* Loop while querying given fqid succeeds or time out */
61                while (1) {
62                        err = qman_query_fq_np(&fq, &np);
63                        if (!err) {
64                                /* success, control-plane has configured QMan */
65                                break;
66                        } else if (err != -ERANGE) {
67                                pr_err("I/O error, continuing anyway\n");
68                                break;
69                        }
70                        nowts = current_kernel_time();
71                        diffts = timespec_sub(nowts, startts);
72                        if (diffts.tv_sec > 0) {
73                                if (!retry--) {
74                                        pr_err("Time out, control-plane dead?\n");
75                                        break;
76                                }
77                                pr_warn("Polling for the control-plane (%d)\n",
78                                        retry);
79                        }
80                }
81        }
82
83        qman_resource_init();
84
85        return 0;
86}
87subsys_initcall(early_qman_init);
Note: See TracBrowser for help on using the repository browser.