From 4d94b32d01e66cb0ba2799775ce2d79c5ff0f2ec Mon Sep 17 00:00:00 2001 From: Richard Zhao Date: Tue, 27 Mar 2018 11:28:09 -0700 Subject: gpu: nvgpu: abstract dt functions Added nvgpu_dt_read_u32_index() for now. Jira VFND-4870 Change-Id: I3e51c408dfba3864372c515ba5d2c77708a489c8 Signed-off-by: Richard Zhao Reviewed-on: https://git-master.nvidia.com/r/1683008 Reviewed-by: mobile promotions Tested-by: mobile promotions --- drivers/gpu/nvgpu/Makefile | 1 + drivers/gpu/nvgpu/common/linux/dt.c | 29 +++++++++++++++++++++++++++++ drivers/gpu/nvgpu/include/nvgpu/dt.h | 28 ++++++++++++++++++++++++++++ 3 files changed, 58 insertions(+) create mode 100644 drivers/gpu/nvgpu/common/linux/dt.c create mode 100644 drivers/gpu/nvgpu/include/nvgpu/dt.h (limited to 'drivers/gpu') diff --git a/drivers/gpu/nvgpu/Makefile b/drivers/gpu/nvgpu/Makefile index c75e1417..9f58d6ef 100644 --- a/drivers/gpu/nvgpu/Makefile +++ b/drivers/gpu/nvgpu/Makefile @@ -62,6 +62,7 @@ nvgpu-y += \ common/linux/sim_pci.o \ common/linux/os_sched.o \ common/linux/nvlink.o \ + common/linux/dt.o \ common/mm/nvgpu_allocator.o \ common/mm/bitmap_allocator.o \ common/mm/buddy_allocator.o \ diff --git a/drivers/gpu/nvgpu/common/linux/dt.c b/drivers/gpu/nvgpu/common/linux/dt.c new file mode 100644 index 00000000..88e391e3 --- /dev/null +++ b/drivers/gpu/nvgpu/common/linux/dt.c @@ -0,0 +1,29 @@ +/* + * Copyright (c) 2018, NVIDIA Corporation. All rights reserved. + * + * This program is free software; you can redistribute it and/or modify it + * under the terms and conditions of the GNU General Public License, + * version 2, as published by the Free Software Foundation. + * + * This program is distributed in the hope it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#include +#include + +#include "os_linux.h" + +int nvgpu_dt_read_u32_index(struct gk20a *g, const char *name, + u32 index, u32 *value) +{ + struct device *dev = dev_from_gk20a(g); + struct device_node *np = dev->of_node; + + return of_property_read_u32_index(np, name, index, value); +} diff --git a/drivers/gpu/nvgpu/include/nvgpu/dt.h b/drivers/gpu/nvgpu/include/nvgpu/dt.h new file mode 100644 index 00000000..b5fdbfcd --- /dev/null +++ b/drivers/gpu/nvgpu/include/nvgpu/dt.h @@ -0,0 +1,28 @@ +/* + * Copyright (c) 2018, NVIDIA CORPORATION. All rights reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + */ + +#include + +struct gk20a; + +int nvgpu_dt_read_u32_index(struct gk20a *g, const char *name, + u32 index, u32 *value); -- cgit v1.2.2