1c39f472eSBen Skeggs /* 2c39f472eSBen Skeggs * Copyright 2014 Martin Peres 3c39f472eSBen Skeggs * 4c39f472eSBen Skeggs * Permission is hereby granted, free of charge, to any person obtaining a 5c39f472eSBen Skeggs * copy of this software and associated documentation files (the "Software"), 6c39f472eSBen Skeggs * to deal in the Software without restriction, including without limitation 7c39f472eSBen Skeggs * the rights to use, copy, modify, merge, publish, distribute, sublicense, 8c39f472eSBen Skeggs * and/or sell copies of the Software, and to permit persons to whom the 9c39f472eSBen Skeggs * Software is furnished to do so, subject to the following conditions: 10c39f472eSBen Skeggs * 11c39f472eSBen Skeggs * The above copyright notice and this permission notice shall be included in 12c39f472eSBen Skeggs * all copies or substantial portions of the Software. 13c39f472eSBen Skeggs * 14c39f472eSBen Skeggs * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15c39f472eSBen Skeggs * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16c39f472eSBen Skeggs * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 17c39f472eSBen Skeggs * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR 18c39f472eSBen Skeggs * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, 19c39f472eSBen Skeggs * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 20c39f472eSBen Skeggs * OTHER DEALINGS IN THE SOFTWARE. 21c39f472eSBen Skeggs * 22c39f472eSBen Skeggs * Authors: Martin Peres 23c39f472eSBen Skeggs */ 24c39f472eSBen Skeggs #include "priv.h" 25c39f472eSBen Skeggs 26c39f472eSBen Skeggs static u32 27c5fcafa5SBen Skeggs gf100_fuse_read(struct nvkm_fuse *fuse, u32 addr) 28c39f472eSBen Skeggs { 29c5fcafa5SBen Skeggs struct nvkm_device *device = fuse->subdev.device; 30c39f472eSBen Skeggs unsigned long flags; 31c39f472eSBen Skeggs u32 fuse_enable, unk, val; 32c39f472eSBen Skeggs 33630ec6c0SBen Skeggs /* racy if another part of nvkm start writing to these regs */ 34c5fcafa5SBen Skeggs spin_lock_irqsave(&fuse->lock, flags); 35c5fcafa5SBen Skeggs fuse_enable = nvkm_mask(device, 0x022400, 0x800, 0x800); 36c5fcafa5SBen Skeggs unk = nvkm_mask(device, 0x021000, 0x1, 0x1); 37c5fcafa5SBen Skeggs val = nvkm_rd32(device, 0x021100 + addr); 38c5fcafa5SBen Skeggs nvkm_wr32(device, 0x021000, unk); 39c5fcafa5SBen Skeggs nvkm_wr32(device, 0x022400, fuse_enable); 40c5fcafa5SBen Skeggs spin_unlock_irqrestore(&fuse->lock, flags); 41c39f472eSBen Skeggs return val; 42c39f472eSBen Skeggs } 43c39f472eSBen Skeggs 447e24c114SBen Skeggs static const struct nvkm_fuse_func 45c5fcafa5SBen Skeggs gf100_fuse = { 467e24c114SBen Skeggs .read = gf100_fuse_read, 477e24c114SBen Skeggs }; 48c39f472eSBen Skeggs 49c5fcafa5SBen Skeggs int 50c5fcafa5SBen Skeggs gf100_fuse_new(struct nvkm_device *device, int index, struct nvkm_fuse **pfuse) 51c39f472eSBen Skeggs { 52c5fcafa5SBen Skeggs return nvkm_fuse_new_(&gf100_fuse, device, index, pfuse); 53c39f472eSBen Skeggs } 54