2 * Copyright (c) 2014, NVIDIA CORPORATION. All rights reserved.
4 * Permission is hereby granted, free of charge, to any person obtaining a
5 * copy of this software and associated documentation files (the "Software"),
6 * to deal in the Software without restriction, including without limitation
7 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8 * and/or sell copies of the Software, and to permit persons to whom the
9 * Software is furnished to do so, subject to the following conditions:
11 * The above copyright notice and this permission notice shall be included in
12 * all copies or substantial portions of the Software.
14 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
17 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
19 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
20 * DEALINGS IN THE SOFTWARE.
22 #include <subdev/ibus.h>
23 #include <subdev/timer.h>
25 struct gk20a_ibus_priv {
26 struct nvkm_ibus base;
30 gk20a_ibus_init_priv_ring(struct gk20a_ibus_priv *priv)
32 nv_mask(priv, 0x137250, 0x3f, 0);
34 nv_mask(priv, 0x000200, 0x20, 0);
36 nv_mask(priv, 0x000200, 0x20, 0x20);
38 nv_wr32(priv, 0x12004c, 0x4);
39 nv_wr32(priv, 0x122204, 0x2);
40 nv_rd32(priv, 0x122204);
43 * Bug: increase clock timeout to avoid operation failure at high
46 nv_wr32(priv, 0x122354, 0x800);
47 nv_wr32(priv, 0x128328, 0x800);
48 nv_wr32(priv, 0x124320, 0x800);
52 gk20a_ibus_intr(struct nvkm_subdev *subdev)
54 struct gk20a_ibus_priv *priv = (void *)subdev;
55 u32 status0 = nv_rd32(priv, 0x120058);
58 nv_debug(priv, "resetting priv ring\n");
59 gk20a_ibus_init_priv_ring(priv);
62 /* Acknowledge interrupt */
63 nv_mask(priv, 0x12004c, 0x2, 0x2);
65 if (!nv_wait(subdev, 0x12004c, 0x3f, 0x00))
66 nv_warn(priv, "timeout waiting for ringmaster ack\n");
70 gk20a_ibus_init(struct nvkm_object *object)
72 struct gk20a_ibus_priv *priv = (void *)object;
75 ret = _nvkm_ibus_init(object);
79 gk20a_ibus_init_priv_ring(priv);
85 gk20a_ibus_ctor(struct nvkm_object *parent, struct nvkm_object *engine,
86 struct nvkm_oclass *oclass, void *data, u32 size,
87 struct nvkm_object **pobject)
89 struct gk20a_ibus_priv *priv;
92 ret = nvkm_ibus_create(parent, engine, oclass, &priv);
93 *pobject = nv_object(priv);
97 nv_subdev(priv)->intr = gk20a_ibus_intr;
102 gk20a_ibus_oclass = {
103 .handle = NV_SUBDEV(IBUS, 0xea),
104 .ofuncs = &(struct nvkm_ofuncs) {
105 .ctor = gk20a_ibus_ctor,
106 .dtor = _nvkm_ibus_dtor,
107 .init = gk20a_ibus_init,
108 .fini = _nvkm_ibus_fini,