1630ec6c0SBen Skeggs /*
2630ec6c0SBen Skeggs * Copyright 2014 Martin Peres
3630ec6c0SBen Skeggs *
4630ec6c0SBen Skeggs * Permission is hereby granted, free of charge, to any person obtaining a
5630ec6c0SBen Skeggs * copy of this software and associated documentation files (the "Software"),
6630ec6c0SBen Skeggs * to deal in the Software without restriction, including without limitation
7630ec6c0SBen Skeggs * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8630ec6c0SBen Skeggs * and/or sell copies of the Software, and to permit persons to whom the
9630ec6c0SBen Skeggs * Software is furnished to do so, subject to the following conditions:
10630ec6c0SBen Skeggs *
11630ec6c0SBen Skeggs * The above copyright notice and this permission notice shall be included in
12630ec6c0SBen Skeggs * all copies or substantial portions of the Software.
13630ec6c0SBen Skeggs *
14630ec6c0SBen Skeggs * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15630ec6c0SBen Skeggs * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16630ec6c0SBen Skeggs * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
17630ec6c0SBen Skeggs * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
18630ec6c0SBen Skeggs * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
19630ec6c0SBen Skeggs * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
20630ec6c0SBen Skeggs * OTHER DEALINGS IN THE SOFTWARE.
21630ec6c0SBen Skeggs *
22630ec6c0SBen Skeggs * Authors: Martin Peres
23630ec6c0SBen Skeggs */
24630ec6c0SBen Skeggs #include "priv.h"
25630ec6c0SBen Skeggs
26630ec6c0SBen Skeggs static u32
nv50_fuse_read(struct nvkm_fuse * fuse,u32 addr)27c5fcafa5SBen Skeggs nv50_fuse_read(struct nvkm_fuse *fuse, u32 addr)
28630ec6c0SBen Skeggs {
29c5fcafa5SBen Skeggs struct nvkm_device *device = fuse->subdev.device;
30630ec6c0SBen Skeggs unsigned long flags;
31630ec6c0SBen Skeggs u32 fuse_enable, val;
32630ec6c0SBen Skeggs
33630ec6c0SBen Skeggs /* racy if another part of nvkm start writing to this reg */
34c5fcafa5SBen Skeggs spin_lock_irqsave(&fuse->lock, flags);
35c5fcafa5SBen Skeggs fuse_enable = nvkm_mask(device, 0x001084, 0x800, 0x800);
36c5fcafa5SBen Skeggs val = nvkm_rd32(device, 0x021000 + addr);
37c5fcafa5SBen Skeggs nvkm_wr32(device, 0x001084, fuse_enable);
38c5fcafa5SBen Skeggs spin_unlock_irqrestore(&fuse->lock, flags);
39630ec6c0SBen Skeggs return val;
40630ec6c0SBen Skeggs }
41630ec6c0SBen Skeggs
427e24c114SBen Skeggs static const struct nvkm_fuse_func
43c5fcafa5SBen Skeggs nv50_fuse = {
447e24c114SBen Skeggs .read = &nv50_fuse_read,
457e24c114SBen Skeggs };
46630ec6c0SBen Skeggs
47c5fcafa5SBen Skeggs int
nv50_fuse_new(struct nvkm_device * device,enum nvkm_subdev_type type,int inst,struct nvkm_fuse ** pfuse)48*8d056d99SBen Skeggs nv50_fuse_new(struct nvkm_device *device, enum nvkm_subdev_type type, int inst,
49*8d056d99SBen Skeggs struct nvkm_fuse **pfuse)
50630ec6c0SBen Skeggs {
51*8d056d99SBen Skeggs return nvkm_fuse_new_(&nv50_fuse, device, type, inst, pfuse);
52630ec6c0SBen Skeggs }
53