From 315d8c6caa3a149b83c9894e94da852a50310c2d Mon Sep 17 00:00:00 2001 From: Lakshmanan M Date: Thu, 8 Sep 2016 22:50:59 +0530 Subject: gpu: nvgpu: Add pmgr support This CL covers the following implementation, 1) Power Sensor Table parsing. 2) Power Topology Table parsing. 3) Add debugfs interface to get the current power(mW), current(mA) and voltage(uV) information from PMU. 4) Power Policy Table Parsing 5) Implement PMU boardobj interface for pmgr module. 6) Over current protection. JIRA DNVGPU-47 Change-Id: I620f4470aa704f1cc920e03947831440fbb0eb05 Signed-off-by: Lakshmanan M Reviewed-on: http://git-master/r/1217176 (cherry picked from commit ed56743c2ac8dc325c75f85a82271d2d5ed8d96a) Reviewed-on: http://git-master/r/1241952 Reviewed-by: mobile promotions Tested-by: mobile promotions --- drivers/gpu/nvgpu/boardobj/boardobjgrp.c | 52 ++++++++++++++++++++++++++++++++ drivers/gpu/nvgpu/boardobj/boardobjgrp.h | 13 ++++++++ 2 files changed, 65 insertions(+) (limited to 'drivers/gpu/nvgpu/boardobj') diff --git a/drivers/gpu/nvgpu/boardobj/boardobjgrp.c b/drivers/gpu/nvgpu/boardobj/boardobjgrp.c index 577acda3..43928ac1 100644 --- a/drivers/gpu/nvgpu/boardobj/boardobjgrp.c +++ b/drivers/gpu/nvgpu/boardobj/boardobjgrp.c @@ -254,6 +254,58 @@ static u32 boardobjgrp_pmustatusinstget_stub(struct gk20a *g, return -EINVAL; } +u32 boardobjgrp_pmudatainit_legacy(struct gk20a *g, + struct boardobjgrp *pboardobjgrp, + struct nv_pmu_boardobjgrp_super *pboardobjgrppmu) +{ + u32 status = 0; + struct boardobj *pboardobj = NULL; + struct nv_pmu_boardobj *ppmudata = NULL; + u8 index; + + gk20a_dbg_info(""); + + if (pboardobjgrp == NULL) + return -EINVAL; + if (pboardobjgrppmu == NULL) + return -EINVAL; + + boardobjgrpe32hdrset((struct nv_pmu_boardobjgrp *)pboardobjgrppmu, + pboardobjgrp->objmask); + + BOARDOBJGRP_FOR_EACH_INDEX_IN_MASK(32, index, pboardobjgrp->objmask) { + /* Obtain pointer to the current instance of the Object from the Group */ + pboardobj = pboardobjgrp->objgetbyidx(pboardobjgrp, index); + if (NULL == pboardobj) { + gk20a_err(dev_from_gk20a(g), + "could not get object instance"); + status = -EINVAL; + goto boardobjgrppmudatainit_legacy_done; + } + + status = pboardobjgrp->pmudatainstget(g, + (struct nv_pmu_boardobjgrp *)pboardobjgrppmu, + &ppmudata, index); + if (status) { + gk20a_err(dev_from_gk20a(g), + "could not get object instance"); + goto boardobjgrppmudatainit_legacy_done; + } + + /* Initialize the PMU Data */ + status = pboardobj->pmudatainit(g, pboardobj, ppmudata); + if (status) { + gk20a_err(dev_from_gk20a(g), + "could not parse pmu for device %d", index); + goto boardobjgrppmudatainit_legacy_done; + } + } + BOARDOBJGRP_FOR_EACH_INDEX_IN_MASK_END + +boardobjgrppmudatainit_legacy_done: + gk20a_dbg_info(" Done"); + return status; +} u32 boardobjgrp_pmudatainit_super(struct gk20a *g, struct boardobjgrp *pboardobjgrp, struct nv_pmu_boardobjgrp_super *pboardobjgrppmu) diff --git a/drivers/gpu/nvgpu/boardobj/boardobjgrp.h b/drivers/gpu/nvgpu/boardobj/boardobjgrp.h index 6527bbdc..7baa5bea 100644 --- a/drivers/gpu/nvgpu/boardobj/boardobjgrp.h +++ b/drivers/gpu/nvgpu/boardobj/boardobjgrp.h @@ -254,6 +254,19 @@ struct boardobjgrp { #define BOARDOBJGRP_FOR_EACH(_pgrp, _ptype, _pobj, _index) \ BOARDOBJGRP_ITERATOR(_pgrp, _ptype, _pobj, _index, NULL) +#define BOARDOBJGRP_FOR_EACH_INDEX_IN_MASK(mask_width, index, mask) \ +{ \ + u##mask_width lcl_msk = (u##mask_width)(mask); \ + for (index = 0; lcl_msk != 0; index++, lcl_msk >>= 1) { \ + if (((u##mask_width)((u64)1) & lcl_msk) == 0) { \ + continue; \ + } + +#define BOARDOBJGRP_FOR_EACH_INDEX_IN_MASK_END \ + } \ +} + + /*! * Invalid UNIT_ID. Used to indicate that the implementing class has not set * @ref BOARDOBJGRP::unitId and, thus, certain BOARDOBJGRP PMU interfaces are -- cgit v1.2.2