blob: 19c8e50eeff7fbff6412993efc8e43e1574b961b [file] [log] [blame]
Martin Peresa10220b2012-11-04 01:01:53 +01001/*
2 * Copyright 2012 Nouveau Community
3 *
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:
10 *
11 * The above copyright notice and this permission notice shall be included in
12 * all copies or substantial portions of the Software.
13 *
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 COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
18 * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
19 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
20 * OTHER DEALINGS IN THE SOFTWARE.
21 *
22 * Authors: Martin Peres <martin.peres@labri.fr>
23 * Ben Skeggs
24 */
Ben Skeggs48ae0b32013-10-24 09:39:05 +100025#include "nv04.h"
Martin Peresa10220b2012-11-04 01:01:53 +010026
Marcin Slusarzcd897832013-01-27 15:01:55 +010027static void
Ben Skeggs5f8824d2015-01-14 14:40:22 +100028nv04_bus_intr(struct nvkm_subdev *subdev)
Martin Peresa10220b2012-11-04 01:01:53 +010029{
Ben Skeggs5f8824d2015-01-14 14:40:22 +100030 struct nvkm_bus *pbus = nvkm_bus(subdev);
Martin Peresa10220b2012-11-04 01:01:53 +010031 u32 stat = nv_rd32(pbus, 0x001100) & nv_rd32(pbus, 0x001140);
32
33 if (stat & 0x00000001) {
34 nv_error(pbus, "BUS ERROR\n");
35 stat &= ~0x00000001;
36 nv_wr32(pbus, 0x001100, 0x00000001);
37 }
38
39 if (stat & 0x00000110) {
Ben Skeggs5f8824d2015-01-14 14:40:22 +100040 subdev = nvkm_subdev(subdev, NVDEV_SUBDEV_GPIO);
Martin Peresa10220b2012-11-04 01:01:53 +010041 if (subdev && subdev->intr)
42 subdev->intr(subdev);
43 stat &= ~0x00000110;
44 nv_wr32(pbus, 0x001100, 0x00000110);
45 }
46
47 if (stat) {
48 nv_error(pbus, "unknown intr 0x%08x\n", stat);
49 nv_mask(pbus, 0x001140, stat, 0x00000000);
50 }
51}
52
53static int
Ben Skeggs5f8824d2015-01-14 14:40:22 +100054nv04_bus_init(struct nvkm_object *object)
Martin Peresa10220b2012-11-04 01:01:53 +010055{
56 struct nv04_bus_priv *priv = (void *)object;
57
58 nv_wr32(priv, 0x001100, 0xffffffff);
59 nv_wr32(priv, 0x001140, 0x00000111);
60
Ben Skeggs5f8824d2015-01-14 14:40:22 +100061 return nvkm_bus_init(&priv->base);
Martin Peresa10220b2012-11-04 01:01:53 +010062}
63
Ben Skeggs48ae0b32013-10-24 09:39:05 +100064int
Ben Skeggs5f8824d2015-01-14 14:40:22 +100065nv04_bus_ctor(struct nvkm_object *parent, struct nvkm_object *engine,
66 struct nvkm_oclass *oclass, void *data, u32 size,
67 struct nvkm_object **pobject)
Ben Skeggs48ae0b32013-10-24 09:39:05 +100068{
69 struct nv04_bus_impl *impl = (void *)oclass;
70 struct nv04_bus_priv *priv;
71 int ret;
72
Ben Skeggs5f8824d2015-01-14 14:40:22 +100073 ret = nvkm_bus_create(parent, engine, oclass, &priv);
Ben Skeggs48ae0b32013-10-24 09:39:05 +100074 *pobject = nv_object(priv);
75 if (ret)
76 return ret;
77
78 nv_subdev(priv)->intr = impl->intr;
Ben Skeggs29845062013-10-15 10:49:39 +100079 priv->base.hwsq_exec = impl->hwsq_exec;
80 priv->base.hwsq_size = impl->hwsq_size;
Ben Skeggs48ae0b32013-10-24 09:39:05 +100081 return 0;
82}
83
Ben Skeggs5f8824d2015-01-14 14:40:22 +100084struct nvkm_oclass *
Ben Skeggs48ae0b32013-10-24 09:39:05 +100085nv04_bus_oclass = &(struct nv04_bus_impl) {
86 .base.handle = NV_SUBDEV(BUS, 0x04),
Ben Skeggs5f8824d2015-01-14 14:40:22 +100087 .base.ofuncs = &(struct nvkm_ofuncs) {
Martin Peresa10220b2012-11-04 01:01:53 +010088 .ctor = nv04_bus_ctor,
Ben Skeggs5f8824d2015-01-14 14:40:22 +100089 .dtor = _nvkm_bus_dtor,
Martin Peresa10220b2012-11-04 01:01:53 +010090 .init = nv04_bus_init,
Ben Skeggs5f8824d2015-01-14 14:40:22 +100091 .fini = _nvkm_bus_fini,
Martin Peresa10220b2012-11-04 01:01:53 +010092 },
Ben Skeggs48ae0b32013-10-24 09:39:05 +100093 .intr = nv04_bus_intr,
94}.base;