15f8824deSBen Skeggs /*
25f8824deSBen Skeggs * Copyright 2012 Nouveau Community
35f8824deSBen Skeggs *
45f8824deSBen Skeggs * Permission is hereby granted, free of charge, to any person obtaining a
55f8824deSBen Skeggs * copy of this software and associated documentation files (the "Software"),
65f8824deSBen Skeggs * to deal in the Software without restriction, including without limitation
75f8824deSBen Skeggs * the rights to use, copy, modify, merge, publish, distribute, sublicense,
85f8824deSBen Skeggs * and/or sell copies of the Software, and to permit persons to whom the
95f8824deSBen Skeggs * Software is furnished to do so, subject to the following conditions:
105f8824deSBen Skeggs *
115f8824deSBen Skeggs * The above copyright notice and this permission notice shall be included in
125f8824deSBen Skeggs * all copies or substantial portions of the Software.
135f8824deSBen Skeggs *
145f8824deSBen Skeggs * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
155f8824deSBen Skeggs * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
165f8824deSBen Skeggs * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
175f8824deSBen Skeggs * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
185f8824deSBen Skeggs * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
195f8824deSBen Skeggs * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
205f8824deSBen Skeggs * OTHER DEALINGS IN THE SOFTWARE.
215f8824deSBen Skeggs *
225f8824deSBen Skeggs * Authors: Martin Peres <martin.peres@labri.fr>
235f8824deSBen Skeggs * Ben Skeggs
245f8824deSBen Skeggs */
25bb23f9d7SBen Skeggs #include "priv.h"
265f8824deSBen Skeggs
275f8824deSBen Skeggs #include <subdev/timer.h>
285f8824deSBen Skeggs
295f8824deSBen Skeggs static int
g94_bus_hwsq_exec(struct nvkm_bus * bus,u32 * data,u32 size)3001d6b956SBen Skeggs g94_bus_hwsq_exec(struct nvkm_bus *bus, u32 *data, u32 size)
315f8824deSBen Skeggs {
3214caba44SBen Skeggs struct nvkm_device *device = bus->subdev.device;
335f8824deSBen Skeggs int i;
345f8824deSBen Skeggs
3514caba44SBen Skeggs nvkm_mask(device, 0x001098, 0x00000008, 0x00000000);
3614caba44SBen Skeggs nvkm_wr32(device, 0x001304, 0x00000000);
3714caba44SBen Skeggs nvkm_wr32(device, 0x001318, 0x00000000);
385f8824deSBen Skeggs for (i = 0; i < size; i++)
3914caba44SBen Skeggs nvkm_wr32(device, 0x080000 + (i * 4), data[i]);
4014caba44SBen Skeggs nvkm_mask(device, 0x001098, 0x00000018, 0x00000018);
4114caba44SBen Skeggs nvkm_wr32(device, 0x00130c, 0x00000001);
425f8824deSBen Skeggs
434f31c84eSBen Skeggs if (nvkm_msec(device, 2000,
444f31c84eSBen Skeggs if (!(nvkm_rd32(device, 0x001308) & 0x00000100))
454f31c84eSBen Skeggs break;
464f31c84eSBen Skeggs ) < 0)
474f31c84eSBen Skeggs return -ETIMEDOUT;
484f31c84eSBen Skeggs
494f31c84eSBen Skeggs return 0;
505f8824deSBen Skeggs }
515f8824deSBen Skeggs
52bb23f9d7SBen Skeggs static const struct nvkm_bus_func
53bb23f9d7SBen Skeggs g94_bus = {
545f8824deSBen Skeggs .init = nv50_bus_init,
555f8824deSBen Skeggs .intr = nv50_bus_intr,
565f8824deSBen Skeggs .hwsq_exec = g94_bus_hwsq_exec,
575f8824deSBen Skeggs .hwsq_size = 128,
58bb23f9d7SBen Skeggs };
59bb23f9d7SBen Skeggs
60bb23f9d7SBen Skeggs int
g94_bus_new(struct nvkm_device * device,enum nvkm_subdev_type type,int inst,struct nvkm_bus ** pbus)61*d37766e5SBen Skeggs g94_bus_new(struct nvkm_device *device, enum nvkm_subdev_type type, int inst,
62*d37766e5SBen Skeggs struct nvkm_bus **pbus)
63bb23f9d7SBen Skeggs {
64*d37766e5SBen Skeggs return nvkm_bus_new_(&g94_bus, device, type, inst, pbus);
65bb23f9d7SBen Skeggs }
66