nv04.c revision 48ae0b355f21533145133002854de89a0537408d
1a10220bbf883931fcf18eb0e850b87d82cfaa412Martin Peres/* 2a10220bbf883931fcf18eb0e850b87d82cfaa412Martin Peres * Copyright 2012 Nouveau Community 3a10220bbf883931fcf18eb0e850b87d82cfaa412Martin Peres * 4a10220bbf883931fcf18eb0e850b87d82cfaa412Martin Peres * Permission is hereby granted, free of charge, to any person obtaining a 5a10220bbf883931fcf18eb0e850b87d82cfaa412Martin Peres * copy of this software and associated documentation files (the "Software"), 6a10220bbf883931fcf18eb0e850b87d82cfaa412Martin Peres * to deal in the Software without restriction, including without limitation 7a10220bbf883931fcf18eb0e850b87d82cfaa412Martin Peres * the rights to use, copy, modify, merge, publish, distribute, sublicense, 8a10220bbf883931fcf18eb0e850b87d82cfaa412Martin Peres * and/or sell copies of the Software, and to permit persons to whom the 9a10220bbf883931fcf18eb0e850b87d82cfaa412Martin Peres * Software is furnished to do so, subject to the following conditions: 10a10220bbf883931fcf18eb0e850b87d82cfaa412Martin Peres * 11a10220bbf883931fcf18eb0e850b87d82cfaa412Martin Peres * The above copyright notice and this permission notice shall be included in 12a10220bbf883931fcf18eb0e850b87d82cfaa412Martin Peres * all copies or substantial portions of the Software. 13a10220bbf883931fcf18eb0e850b87d82cfaa412Martin Peres * 14a10220bbf883931fcf18eb0e850b87d82cfaa412Martin Peres * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15a10220bbf883931fcf18eb0e850b87d82cfaa412Martin Peres * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16a10220bbf883931fcf18eb0e850b87d82cfaa412Martin Peres * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 17a10220bbf883931fcf18eb0e850b87d82cfaa412Martin Peres * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR 18a10220bbf883931fcf18eb0e850b87d82cfaa412Martin Peres * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, 19a10220bbf883931fcf18eb0e850b87d82cfaa412Martin Peres * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 20a10220bbf883931fcf18eb0e850b87d82cfaa412Martin Peres * OTHER DEALINGS IN THE SOFTWARE. 21a10220bbf883931fcf18eb0e850b87d82cfaa412Martin Peres * 22a10220bbf883931fcf18eb0e850b87d82cfaa412Martin Peres * Authors: Martin Peres <martin.peres@labri.fr> 23a10220bbf883931fcf18eb0e850b87d82cfaa412Martin Peres * Ben Skeggs 24a10220bbf883931fcf18eb0e850b87d82cfaa412Martin Peres */ 25a10220bbf883931fcf18eb0e850b87d82cfaa412Martin Peres 2648ae0b355f21533145133002854de89a0537408dBen Skeggs#include "nv04.h" 27a10220bbf883931fcf18eb0e850b87d82cfaa412Martin Peres 28cd897837eacc6ce0b883b5e6c9000cb2e5f11c39Marcin Slusarzstatic void 29a10220bbf883931fcf18eb0e850b87d82cfaa412Martin Peresnv04_bus_intr(struct nouveau_subdev *subdev) 30a10220bbf883931fcf18eb0e850b87d82cfaa412Martin Peres{ 31a10220bbf883931fcf18eb0e850b87d82cfaa412Martin Peres struct nouveau_bus *pbus = nouveau_bus(subdev); 32a10220bbf883931fcf18eb0e850b87d82cfaa412Martin Peres u32 stat = nv_rd32(pbus, 0x001100) & nv_rd32(pbus, 0x001140); 33a10220bbf883931fcf18eb0e850b87d82cfaa412Martin Peres 34a10220bbf883931fcf18eb0e850b87d82cfaa412Martin Peres if (stat & 0x00000001) { 35a10220bbf883931fcf18eb0e850b87d82cfaa412Martin Peres nv_error(pbus, "BUS ERROR\n"); 36a10220bbf883931fcf18eb0e850b87d82cfaa412Martin Peres stat &= ~0x00000001; 37a10220bbf883931fcf18eb0e850b87d82cfaa412Martin Peres nv_wr32(pbus, 0x001100, 0x00000001); 38a10220bbf883931fcf18eb0e850b87d82cfaa412Martin Peres } 39a10220bbf883931fcf18eb0e850b87d82cfaa412Martin Peres 40a10220bbf883931fcf18eb0e850b87d82cfaa412Martin Peres if (stat & 0x00000110) { 41a10220bbf883931fcf18eb0e850b87d82cfaa412Martin Peres subdev = nouveau_subdev(subdev, NVDEV_SUBDEV_GPIO); 42a10220bbf883931fcf18eb0e850b87d82cfaa412Martin Peres if (subdev && subdev->intr) 43a10220bbf883931fcf18eb0e850b87d82cfaa412Martin Peres subdev->intr(subdev); 44a10220bbf883931fcf18eb0e850b87d82cfaa412Martin Peres stat &= ~0x00000110; 45a10220bbf883931fcf18eb0e850b87d82cfaa412Martin Peres nv_wr32(pbus, 0x001100, 0x00000110); 46a10220bbf883931fcf18eb0e850b87d82cfaa412Martin Peres } 47a10220bbf883931fcf18eb0e850b87d82cfaa412Martin Peres 48a10220bbf883931fcf18eb0e850b87d82cfaa412Martin Peres if (stat) { 49a10220bbf883931fcf18eb0e850b87d82cfaa412Martin Peres nv_error(pbus, "unknown intr 0x%08x\n", stat); 50a10220bbf883931fcf18eb0e850b87d82cfaa412Martin Peres nv_mask(pbus, 0x001140, stat, 0x00000000); 51a10220bbf883931fcf18eb0e850b87d82cfaa412Martin Peres } 52a10220bbf883931fcf18eb0e850b87d82cfaa412Martin Peres} 53a10220bbf883931fcf18eb0e850b87d82cfaa412Martin Peres 54a10220bbf883931fcf18eb0e850b87d82cfaa412Martin Peresstatic int 5548ae0b355f21533145133002854de89a0537408dBen Skeggsnv04_bus_init(struct nouveau_object *object) 5648ae0b355f21533145133002854de89a0537408dBen Skeggs{ 5748ae0b355f21533145133002854de89a0537408dBen Skeggs struct nv04_bus_priv *priv = (void *)object; 5848ae0b355f21533145133002854de89a0537408dBen Skeggs 5948ae0b355f21533145133002854de89a0537408dBen Skeggs nv_wr32(priv, 0x001100, 0xffffffff); 6048ae0b355f21533145133002854de89a0537408dBen Skeggs nv_wr32(priv, 0x001140, 0x00000111); 6148ae0b355f21533145133002854de89a0537408dBen Skeggs 6248ae0b355f21533145133002854de89a0537408dBen Skeggs return nouveau_bus_init(&priv->base); 6348ae0b355f21533145133002854de89a0537408dBen Skeggs} 6448ae0b355f21533145133002854de89a0537408dBen Skeggs 6548ae0b355f21533145133002854de89a0537408dBen Skeggsint 66a10220bbf883931fcf18eb0e850b87d82cfaa412Martin Peresnv04_bus_ctor(struct nouveau_object *parent, struct nouveau_object *engine, 67a10220bbf883931fcf18eb0e850b87d82cfaa412Martin Peres struct nouveau_oclass *oclass, void *data, u32 size, 68a10220bbf883931fcf18eb0e850b87d82cfaa412Martin Peres struct nouveau_object **pobject) 69a10220bbf883931fcf18eb0e850b87d82cfaa412Martin Peres{ 7048ae0b355f21533145133002854de89a0537408dBen Skeggs struct nv04_bus_impl *impl = (void *)oclass; 71a10220bbf883931fcf18eb0e850b87d82cfaa412Martin Peres struct nv04_bus_priv *priv; 72a10220bbf883931fcf18eb0e850b87d82cfaa412Martin Peres int ret; 73a10220bbf883931fcf18eb0e850b87d82cfaa412Martin Peres 74a10220bbf883931fcf18eb0e850b87d82cfaa412Martin Peres ret = nouveau_bus_create(parent, engine, oclass, &priv); 75a10220bbf883931fcf18eb0e850b87d82cfaa412Martin Peres *pobject = nv_object(priv); 76a10220bbf883931fcf18eb0e850b87d82cfaa412Martin Peres if (ret) 77a10220bbf883931fcf18eb0e850b87d82cfaa412Martin Peres return ret; 78a10220bbf883931fcf18eb0e850b87d82cfaa412Martin Peres 7948ae0b355f21533145133002854de89a0537408dBen Skeggs nv_subdev(priv)->intr = impl->intr; 80a10220bbf883931fcf18eb0e850b87d82cfaa412Martin Peres return 0; 81a10220bbf883931fcf18eb0e850b87d82cfaa412Martin Peres} 82a10220bbf883931fcf18eb0e850b87d82cfaa412Martin Peres 8348ae0b355f21533145133002854de89a0537408dBen Skeggsstruct nouveau_oclass * 8448ae0b355f21533145133002854de89a0537408dBen Skeggsnv04_bus_oclass = &(struct nv04_bus_impl) { 8548ae0b355f21533145133002854de89a0537408dBen Skeggs .base.handle = NV_SUBDEV(BUS, 0x04), 8648ae0b355f21533145133002854de89a0537408dBen Skeggs .base.ofuncs = &(struct nouveau_ofuncs) { 87a10220bbf883931fcf18eb0e850b87d82cfaa412Martin Peres .ctor = nv04_bus_ctor, 88a10220bbf883931fcf18eb0e850b87d82cfaa412Martin Peres .dtor = _nouveau_bus_dtor, 89a10220bbf883931fcf18eb0e850b87d82cfaa412Martin Peres .init = nv04_bus_init, 90a10220bbf883931fcf18eb0e850b87d82cfaa412Martin Peres .fini = _nouveau_bus_fini, 91a10220bbf883931fcf18eb0e850b87d82cfaa412Martin Peres }, 9248ae0b355f21533145133002854de89a0537408dBen Skeggs .intr = nv04_bus_intr, 9348ae0b355f21533145133002854de89a0537408dBen Skeggs}.base; 94