diff --git a/drivers/gpu/nvgpu/clk/clk_prog.c b/drivers/gpu/nvgpu/clk/clk_prog.c index fbb2753f5..bf74cdd2e 100644 --- a/drivers/gpu/nvgpu/clk/clk_prog.c +++ b/drivers/gpu/nvgpu/clk/clk_prog.c @@ -37,10 +37,29 @@ static struct clk_prog *construct_clk_prog(struct gk20a *g, void *pargs); static int devinit_get_clk_prog_table(struct gk20a *g, struct clk_progs *pprogobjs); -static vf_flatten vfflatten_prog_1x_master; -static vf_lookup vflookup_prog_1x_master; -static get_fpoints getfpoints_prog_1x_master; -static get_slaveclk getslaveclk_prog_1x_master; +static int vfflatten_prog_1x_master(struct gk20a *g, + struct clk_pmupstate *pclk, + struct clk_prog_1x_master *p1xmaster, + u8 clk_domain_idx, u16 *pfreqmaxlastmhz); +static u32 vflookup_prog_1x_master(struct gk20a *g, + struct clk_pmupstate *pclk, + struct clk_prog_1x_master *p1xmaster, + u8 *slave_clk_domain, + u16 *pclkmhz, + u32 *pvoltuv, + u8 rail); +static int getfpoints_prog_1x_master(struct gk20a *g, + struct clk_pmupstate *pclk, + struct clk_prog_1x_master *p1xmaster, + u32 *pfpointscount, + u16 **ppfreqpointsinmhz, + u8 rail); +static int getslaveclk_prog_1x_master(struct gk20a *g, + struct clk_pmupstate *pclk, + struct clk_prog_1x_master *p1xmaster, + u8 slave_clk_domain, + u16 *pclkmhz, + u16 masterclkmhz); static int _clk_progs_pmudatainit(struct gk20a *g, struct boardobjgrp *pboardobjgrp, diff --git a/drivers/gpu/nvgpu/clk/clk_vin.h b/drivers/gpu/nvgpu/clk/clk_vin.h index 293d0086a..dcbb34b67 100644 --- a/drivers/gpu/nvgpu/clk/clk_vin.h +++ b/drivers/gpu/nvgpu/clk/clk_vin.h @@ -64,8 +64,10 @@ struct vin_device_v20 { ((struct vin_device *)BOARDOBJGRP_OBJ_GET_BY_IDX( \ ((struct boardobjgrp *)&(pvinobjs->super.super)), (dev_index))) -boardobj_construct construct_vindevice; -boardobj_pmudatainit vindeviceinit_pmudata_super; +int construct_vindevice(struct gk20a *g, struct boardobj **ppboardobj, + u16 size, void *args); +int vindeviceinit_pmudata_super(struct gk20a *g, struct boardobj *pboardobj, + struct nv_pmu_boardobj *pmudata); int clk_vin_sw_setup(struct gk20a *g); int clk_vin_pmu_setup(struct gk20a *g); diff --git a/drivers/gpu/nvgpu/common/boardobj/boardobjgrp.c b/drivers/gpu/nvgpu/common/boardobj/boardobjgrp.c index 8708eaa95..8364283b8 100644 --- a/drivers/gpu/nvgpu/common/boardobj/boardobjgrp.c +++ b/drivers/gpu/nvgpu/common/boardobj/boardobjgrp.c @@ -24,13 +24,34 @@ #include #include #include - -static boardobjgrp_objinsert boardobjgrp_objinsert_final; -static boardobjgrp_objgetbyidx boardobjgrp_objgetbyidx_final; -static boardobjgrp_objgetnext boardobjgrp_objgetnext_final; -static boardobjgrp_objremoveanddestroy boardobjgrp_objremoveanddestroy_final; -static boardobjgrp_pmudatainstget boardobjgrp_pmudatainstget_stub; -static boardobjgrp_pmustatusinstget boardobjgrp_pmustatusinstget_stub; +/* + * Inserts a previously constructed Board Object into a Board Object Group for + * tracking. Objects are inserted in the array based on the given index. + */ +static int boardobjgrp_objinsert_final(struct boardobjgrp *pboardobjgrp, + struct boardobj *pboardobj, u8 index); +/* + * Retrieves a Board Object from a Board Object Group using the group's index. + */ +static struct boardobj *boardobjgrp_objgetbyidx_final( + struct boardobjgrp *pboardobjgrp, u8 index); +/* + * Retrieve Board Object immediately following one pointed by @ref currentindex + * filtered out by the provided mask. If (mask == NULL) => no filtering. + */ +static struct boardobj *boardobjgrp_objgetnext_final( + struct boardobjgrp *pboardobjgrp, + u8 *currentindex, struct boardobjgrpmask *mask); +static int boardobjgrp_objremoveanddestroy_final( + struct boardobjgrp *pboardobjgrp, + u8 index); +static int boardobjgrp_pmudatainstget_stub(struct gk20a *g, + struct nv_pmu_boardobjgrp *boardobjgrppmu, + struct nv_pmu_boardobj **ppboardobjpmudata, u8 idx); +static int boardobjgrp_pmustatusinstget_stub(struct gk20a *g, + void *pboardobjgrppmu, + struct nv_pmu_boardobj_query **ppBoardobjpmustatus, + u8 idx); static int boardobjgrp_pmucmdsend(struct gk20a *g, struct boardobjgrp *pboardobjgrp, struct boardobjgrp_pmu_cmd *pcmd); diff --git a/drivers/gpu/nvgpu/include/nvgpu/boardobj.h b/drivers/gpu/nvgpu/include/nvgpu/boardobj.h index 270b10be7..86a84f828 100644 --- a/drivers/gpu/nvgpu/include/nvgpu/boardobj.h +++ b/drivers/gpu/nvgpu/include/nvgpu/boardobj.h @@ -34,7 +34,7 @@ struct gk20a; * check whether the specified BOARDOBJ object implements the queried * type/class enumeration. */ -typedef bool boardobj_implements(struct gk20a *g, struct boardobj *pboardobj, +bool boardobj_implements_super(struct gk20a *g, struct boardobj *pboardobj, u8 type); /* @@ -42,14 +42,14 @@ typedef bool boardobj_implements(struct gk20a *g, struct boardobj *pboardobj, * description structure, describing this BOARDOBJ board device to the PMU. * */ -typedef int boardobj_pmudatainit(struct gk20a *g, struct boardobj *pboardobj, +int boardobj_pmudatainit_super(struct gk20a *g, struct boardobj *pboardobj, struct nv_pmu_boardobj *pmudata); /* * Constructor for the base Board Object. Called by each device-specific * implementation of the BOARDOBJ interface to initialize the board object. */ -typedef int boardobj_construct(struct gk20a *g, struct boardobj **pboardobj, +int boardobj_construct_super(struct gk20a *g, struct boardobj **ppboardobj, u16 size, void *args); /* @@ -58,7 +58,7 @@ typedef int boardobj_construct(struct gk20a *g, struct boardobj **pboardobj, * This has to be explicitly set by each device that extends from the * board object. */ -typedef int boardobj_destruct(struct boardobj *pboardobj); +int boardobj_destruct_super(struct boardobj *pboardobj); /* * Base Class for all physical or logical device on the PCB. @@ -75,21 +75,18 @@ struct boardobj { /* true if allocated in constructor. destructor should free */ bool allocated; u32 type_mask; /*mask of types this boardobjimplements*/ - boardobj_implements *implements; - boardobj_destruct *destruct; + bool (*implements)(struct gk20a *g, struct boardobj *pboardobj, + u8 type); + int (*destruct)(struct boardobj *pboardobj); /* * Access interface apis which will be overridden by the devices * that inherit from BOARDOBJ */ - boardobj_pmudatainit *pmudatainit; + int (*pmudatainit)(struct gk20a *g, struct boardobj *pboardobj, + struct nv_pmu_boardobj *pmudata); struct nvgpu_list_node node; }; -boardobj_construct boardobj_construct_super; -boardobj_destruct boardobj_destruct_super; -boardobj_implements boardobj_implements_super; -boardobj_pmudatainit boardobj_pmudatainit_super; - #define BOARDOBJ_GET_TYPE(pobj) (((struct boardobj *)(pobj))->type) #define BOARDOBJ_GET_IDX(pobj) (((struct boardobj *)(pobj))->idx) diff --git a/drivers/gpu/nvgpu/include/nvgpu/boardobjgrp.h b/drivers/gpu/nvgpu/include/nvgpu/boardobjgrp.h index 1c5ac0a8a..b54685aa8 100644 --- a/drivers/gpu/nvgpu/include/nvgpu/boardobjgrp.h +++ b/drivers/gpu/nvgpu/include/nvgpu/boardobjgrp.h @@ -39,35 +39,14 @@ struct pmu_surface; * Board Object Group destructor. * */ -typedef int boardobjgrp_destruct(struct boardobjgrp *pboardobjgrp); - -/* -* Inserts a previously constructed Board Object into a Board Object Group for -* tracking. Objects are inserted in the array based on the given index. -*/ -typedef int boardobjgrp_objinsert(struct boardobjgrp *pboardobjgrp, - struct boardobj *pboardobj, u8 index); - -/* -* Retrieves a Board Object from a Board Object Group using the group's index. -* -*/ -typedef struct boardobj *boardobjgrp_objgetbyidx( - struct boardobjgrp *pBobrdobjgrp, u8 index); - -/* -* Retrieve Board Object immediately following one pointed by @ref pcurrentindex -* filtered out by the provided mask. If (pMask == NULL) => no filtering. -*/ -typedef struct boardobj *boardobjgrp_objgetnext( - struct boardobjgrp *pboardobjgrp, - u8 *currentindex, struct boardobjgrpmask *mask); +int boardobjgrp_destruct_super(struct boardobjgrp *pboardobjgrp); +int boardobjgrp_destruct_impl(struct boardobjgrp *pboardobjgrp); /* * Board Object Group Remover and destructor. This is used to remove and * destruct specific entry from the Board Object Group. */ -typedef int boardobjgrp_objremoveanddestroy(struct boardobjgrp *pboardobjgrp, +int boardobjgrp_objremoveanddestroy(struct boardobjgrp *pboardobjgrp, u8 index); /* @@ -75,23 +54,26 @@ typedef int boardobjgrp_objremoveanddestroy(struct boardobjgrp *pboardobjgrp, * for the constructed PMU CMDs, and then sets the object via the * PMU_BOARDOBJ_CMD_GRP interface (if constructed). */ -typedef int boardobjgrp_pmuinithandle(struct gk20a *g, - struct boardobjgrp *pboardobjGrp); +int boardobjgrp_pmuinithandle_impl(struct gk20a *g, + struct boardobjgrp *pboardobjgrp); /* * Fills out the appropriate the PMU_BOARDOBJGRP_ driver<->PMU description * header structure, more specifically a mask of BOARDOBJs. */ -typedef int boardobjgrp_pmuhdrdatainit(struct gk20a *g, - struct boardobjgrp *pboardobjgrp, - struct nv_pmu_boardobjgrp_super *pboardobjgrppmu, - struct boardobjgrpmask *mask); +int boardobjgrp_pmuhdrdatainit_super(struct gk20a *g, + struct boardobjgrp *pboardobjgrp, + struct nv_pmu_boardobjgrp_super *pboardobjgrppmu, + struct boardobjgrpmask *mask); /* * Fills out the appropriate the PMU_BOARDOBJGRP_ driver->PMU description * structure, describing the BOARDOBJGRP and all of its BOARDOBJs to the PMU. */ -typedef int boardobjgrp_pmudatainit(struct gk20a *g, +int boardobjgrp_pmudatainit_super(struct gk20a *g, + struct boardobjgrp *pboardobjgrp, + struct nv_pmu_boardobjgrp_super *pboardobjgrppmu); +int boardobjgrp_pmudatainit_legacy(struct gk20a *g, struct boardobjgrp *pboardobjgrp, struct nv_pmu_boardobjgrp_super *pboardobjgrppmu); @@ -100,23 +82,21 @@ typedef int boardobjgrp_pmudatainit(struct gk20a *g, * This interface leverages @ref boardobjgrp_pmudatainit to populate the * structure. */ -typedef int boardobjgrp_pmuset(struct gk20a *g, +int boardobjgrp_pmuset_impl(struct gk20a *g, + struct boardobjgrp *pboardobjgrp); +int boardobjgrp_pmuset_impl_v1(struct gk20a *g, struct boardobjgrp *pboardobjgrp); /* * Gets the dynamic status of the PMU BOARDOBJGRP via the * PMU_BOARDOBJ_CMD_GRP GET_STATUS interface. */ -typedef int boardobjgrp_pmugetstatus(struct gk20a *g, +int boardobjgrp_pmugetstatus_impl(struct gk20a *g, + struct boardobjgrp *pboardobjgrp, + struct boardobjgrpmask *mask); +int boardobjgrp_pmugetstatus_impl_v1(struct gk20a *g, struct boardobjgrp *pboardobjgrp, struct boardobjgrpmask *mask); - -typedef int boardobjgrp_pmudatainstget(struct gk20a *g, - struct nv_pmu_boardobjgrp *boardobjgrppmu, - struct nv_pmu_boardobj **ppboardobjpmudata, u8 idx); - -typedef int boardobjgrp_pmustatusinstget(struct gk20a *g, void *pboardobjgrppmu, - struct nv_pmu_boardobj_query **ppBoardobjpmustatus, u8 idx); /* * Structure describing an PMU CMD for interacting with the representaition @@ -152,15 +132,22 @@ struct boardobjgrp_pmu { * CMD. This provides the various information describing the PMU CMD including * the CMD and MSG ID and the size of the various sturctures in the payload. */ -typedef int boardobjgrp_pmucmd_construct(struct gk20a *g, - struct boardobjgrp *pboardobjgrp, - struct boardobjgrp_pmu_cmd *cmd, u8 id, u8 msgid, - u16 hdrsize, u16 entrysize, u16 fbsize, u32 ss_offset, u8 rpc_func_id); +int boardobjgrp_pmucmd_construct_impl(struct gk20a *g, + struct boardobjgrp *pboardobjgrp, + struct boardobjgrp_pmu_cmd *cmd, u8 id, + u8 msgid, u16 hdrsize, u16 entrysize, + u16 fbsize, u32 ss_offset, u8 rpc_func_id); + +int boardobjgrp_pmucmd_construct_impl_v1(struct gk20a *g, + struct boardobjgrp *pboardobjgrp, + struct boardobjgrp_pmu_cmd *cmd, u8 id, + u8 msgid, u16 hdrsize, u16 entrysize, + u16 fbsize, u32 ss_offset, u8 rpc_func_id); /* * Destroys BOARDOBJGRP PMU SW state. CMD. */ -typedef int boardobjgrp_pmucmd_destroy(struct gk20a *g, +int boardobjgrp_pmucmd_destroy_impl(struct gk20a *g, struct boardobjgrp_pmu_cmd *cmd); /* @@ -168,9 +155,9 @@ typedef int boardobjgrp_pmucmd_destroy(struct gk20a *g, * PMU CMD payload within both the PMU and driver so that it can be referenced * at run-time. */ -typedef int boardobjgrp_pmucmd_pmuinithandle(struct gk20a *g, +int boardobjgrp_pmucmd_pmuinithandle_impl(struct gk20a *g, struct boardobjgrp *pboardobjgrp, - struct boardobjgrp_pmu_cmd *cmd); + struct boardobjgrp_pmu_cmd *pcmd); /* * Base Class Group for all physical or logical device on the PCB. @@ -191,21 +178,36 @@ struct boardobjgrp { struct boardobjgrp_pmu pmu; /* Basic interfaces */ - boardobjgrp_destruct *destruct; - boardobjgrp_objinsert *objinsert; - boardobjgrp_objgetbyidx *objgetbyidx; - boardobjgrp_objgetnext *objgetnext; - boardobjgrp_objremoveanddestroy *objremoveanddestroy; + int (*destruct)(struct boardobjgrp *pboardobjgrp); + int (*objinsert)(struct boardobjgrp *pboardobjgrp, + struct boardobj *pboardobj, u8 index); + struct boardobj *(*objgetbyidx)( + struct boardobjgrp *pBobrdobjgrp, u8 index); + struct boardobj *(*objgetnext)(struct boardobjgrp *pboardobjgrp, + u8 *currentindex, struct boardobjgrpmask *mask); + int (*objremoveanddestroy)(struct boardobjgrp *pboardobjgrp, u8 index); /* PMU interfaces */ - boardobjgrp_pmuinithandle *pmuinithandle; - boardobjgrp_pmuhdrdatainit *pmuhdrdatainit; - boardobjgrp_pmudatainit *pmudatainit; - boardobjgrp_pmuset *pmuset; - boardobjgrp_pmugetstatus *pmugetstatus; + int (*pmuinithandle)(struct gk20a *g, + struct boardobjgrp *pboardobjgrp); + int (*pmuhdrdatainit)(struct gk20a *g, struct boardobjgrp *pboardobjgrp, + struct nv_pmu_boardobjgrp_super *pboardobjgrppmu, + struct boardobjgrpmask *mask); + int (*pmudatainit)(struct gk20a *g, + struct boardobjgrp *pboardobjgrp, + struct nv_pmu_boardobjgrp_super *pboardobjgrppmu); + int (*pmuset)(struct gk20a *g, + struct boardobjgrp *pboardobjgrp); + int (*pmugetstatus)(struct gk20a *g, + struct boardobjgrp *pboardobjgrp, + struct boardobjgrpmask *mask); - boardobjgrp_pmudatainstget *pmudatainstget; - boardobjgrp_pmustatusinstget *pmustatusinstget; + int (*pmudatainstget)(struct gk20a *g, + struct nv_pmu_boardobjgrp *boardobjgrppmu, + struct nv_pmu_boardobj **ppboardobjpmudata, u8 idx); + int (*pmustatusinstget)(struct gk20a *g, void *pboardobjgrppmu, + struct nv_pmu_boardobj_query **ppBoardobjpmustatus, + u8 idx); struct nvgpu_list_node node; }; @@ -355,26 +357,6 @@ do { \ /* Constructor and destructor */ int boardobjgrp_construct_super(struct gk20a *g, struct boardobjgrp *pboardobjgrp); -boardobjgrp_destruct boardobjgrp_destruct_impl; -boardobjgrp_destruct boardobjgrp_destruct_super; - -/* PMU_CMD interfaces */ -boardobjgrp_pmucmd_construct boardobjgrp_pmucmd_construct_impl; -boardobjgrp_pmucmd_destroy boardobjgrp_pmucmd_destroy_impl; -boardobjgrp_pmucmd_pmuinithandle boardobjgrp_pmucmd_pmuinithandle_impl; - -boardobjgrp_pmucmd_construct boardobjgrp_pmucmd_construct_impl_v1; - -/* BOARDOBJGRP interfaces */ -boardobjgrp_pmuinithandle boardobjgrp_pmuinithandle_impl; -boardobjgrp_pmuhdrdatainit boardobjgrp_pmuhdrdatainit_super; -boardobjgrp_pmudatainit boardobjgrp_pmudatainit_super; - -boardobjgrp_pmudatainit boardobjgrp_pmudatainit_legacy; -boardobjgrp_pmuset boardobjgrp_pmuset_impl; -boardobjgrp_pmugetstatus boardobjgrp_pmugetstatus_impl; -boardobjgrp_pmuset boardobjgrp_pmuset_impl_v1; -boardobjgrp_pmugetstatus boardobjgrp_pmugetstatus_impl_v1; void boardobjgrpe32hdrset(struct nv_pmu_boardobjgrp *hdr, u32 objmask); diff --git a/drivers/gpu/nvgpu/include/nvgpu/boardobjgrp_e255.h b/drivers/gpu/nvgpu/include/nvgpu/boardobjgrp_e255.h index 4c538c54f..d475d90e6 100644 --- a/drivers/gpu/nvgpu/include/nvgpu/boardobjgrp_e255.h +++ b/drivers/gpu/nvgpu/include/nvgpu/boardobjgrp_e255.h @@ -43,8 +43,11 @@ struct boardobjgrp_e255 { /* Constructor and destructor */ int boardobjgrpconstruct_e255(struct gk20a *g, - struct boardobjgrp_e255 *pboardobjgrp); -boardobjgrp_destruct boardobjgrpdestruct_e255; -boardobjgrp_pmuhdrdatainit boardobjgrp_pmuhdrdatainit_e255; + struct boardobjgrp_e255 *pboardobjgrp_e255); +int boardobjgrpdestruct_e255(struct boardobjgrp *pboardobjgrp); +int boardobjgrp_pmuhdrdatainit_e255(struct gk20a *g, + struct boardobjgrp *pboardobjgrp, + struct nv_pmu_boardobjgrp_super *pboardobjgrppmu, + struct boardobjgrpmask *mask); #endif /* NVGPU_BOARDOBJGRP_E255_H */ diff --git a/drivers/gpu/nvgpu/include/nvgpu/boardobjgrp_e32.h b/drivers/gpu/nvgpu/include/nvgpu/boardobjgrp_e32.h index 77b780479..11ce05984 100644 --- a/drivers/gpu/nvgpu/include/nvgpu/boardobjgrp_e32.h +++ b/drivers/gpu/nvgpu/include/nvgpu/boardobjgrp_e32.h @@ -57,8 +57,11 @@ struct boardobjgrp_e32 { /* Constructor and destructor */ int boardobjgrpconstruct_e32(struct gk20a *g, - struct boardobjgrp_e32 *pboardobjgrp); -boardobjgrp_destruct boardobjgrpdestruct_e32; -boardobjgrp_pmuhdrdatainit boardobjgrp_pmuhdrdatainit_e32; + struct boardobjgrp_e32 *pboardobjgrp_e32); +int boardobjgrpdestruct_e32(struct boardobjgrp *pboardobjgrp); +int boardobjgrp_pmuhdrdatainit_e32(struct gk20a *g, + struct boardobjgrp *pboardobjgrp, + struct nv_pmu_boardobjgrp_super *pboardobjgrppmu, + struct boardobjgrpmask *mask); #endif /* NVGPU_BOARDOBJGRP_E32_H */