File drivers/gpu/alga/amd/si/dyn_pm/driver.c changed (mode: 100644) (index 53742e2..9320c27) |
38 |
38 |
#include "smc_lvl.h" |
#include "smc_lvl.h" |
39 |
39 |
#include "smc_volt.h" |
#include "smc_volt.h" |
40 |
40 |
#include "smc_mc_reg_tbl.h" |
#include "smc_mc_reg_tbl.h" |
|
41 |
|
#include "smc_mc_arb_tbl.h" |
41 |
42 |
|
|
42 |
43 |
static void smc_sw_state_init(struct ctx *ctx, struct smc_sw_state *state) |
static void smc_sw_state_init(struct ctx *ctx, struct smc_sw_state *state) |
43 |
44 |
{ |
{ |
|
... |
... |
static void smc_mc_reg_sets_init(struct ctx *ctx, struct smc_mc_reg_set *sets) |
335 |
336 |
smc_mc_reg_set_init(ctx, set_idx, &sets[set_idx]); |
smc_mc_reg_set_init(ctx, set_idx, &sets[set_idx]); |
336 |
337 |
} |
} |
337 |
338 |
|
|
|
339 |
|
static long smc_mc_arb_reg_set_init(struct ctx *ctx, u8 smc_set_idx, |
|
340 |
|
struct smc_mc_arb_reg_set *set) |
|
341 |
|
{ |
|
342 |
|
u32 eng_clk; |
|
343 |
|
u32 mem_clk; |
|
344 |
|
|
|
345 |
|
eng_clk = ctx->atb_performance.lvls[smc_set_idx].eng_clk; |
|
346 |
|
mem_clk = ctx->atb_performance.lvls[smc_set_idx].mem_clk; |
|
347 |
|
|
|
348 |
|
return smc_mc_arb_tbl_set_compute(ctx, set, eng_clk, mem_clk); |
|
349 |
|
} |
|
350 |
|
|
|
351 |
|
static long smc_mc_arb_reg_sets_init(struct ctx *ctx, |
|
352 |
|
struct smc_mc_arb_reg_set *sets) |
|
353 |
|
{ |
|
354 |
|
u8 set_idx; |
|
355 |
|
|
|
356 |
|
for (set_idx = 0; set_idx < ctx->atb_performance.lvls_n; ++set_idx) { |
|
357 |
|
long r; |
|
358 |
|
|
|
359 |
|
r = smc_mc_arb_reg_set_init(ctx, set_idx, &sets[set_idx]); |
|
360 |
|
if (r == -SI_ERR) |
|
361 |
|
return -SI_ERR; |
|
362 |
|
} |
|
363 |
|
return 0; |
|
364 |
|
} |
|
365 |
|
|
338 |
366 |
static long smc_tbls_init(struct ctx *ctx) |
static long smc_tbls_init(struct ctx *ctx) |
339 |
367 |
{ |
{ |
340 |
368 |
struct smc_sw_state *smc_sw_state; |
struct smc_sw_state *smc_sw_state; |
341 |
369 |
struct smc_lvl *smc_lvls; |
struct smc_lvl *smc_lvls; |
342 |
370 |
struct smc_mc_reg_set *smc_mc_reg_sets; |
struct smc_mc_reg_set *smc_mc_reg_sets; |
|
371 |
|
struct smc_mc_arb_reg_set *smc_mc_arb_reg_sets; |
343 |
372 |
long r; |
long r; |
344 |
373 |
|
|
345 |
374 |
/*--------------------------------------------------------------------*/ |
/*--------------------------------------------------------------------*/ |
|
... |
... |
static long smc_tbls_init(struct ctx *ctx) |
378 |
407 |
|
|
379 |
408 |
/*--------------------------------------------------------------------*/ |
/*--------------------------------------------------------------------*/ |
380 |
409 |
|
|
381 |
|
//TODO:mc_arb_regs... |
|
|
410 |
|
smc_mc_arb_reg_sets = kzalloc(sizeof(*smc_mc_arb_reg_sets) |
|
411 |
|
* ctx->atb_performance.lvls_n, GFP_KERNEL); |
|
412 |
|
if (!smc_mc_arb_reg_sets) { |
|
413 |
|
dev_err(&ctx->dev->dev, "dyn_pm:driver:unable to alloc the smc_mc_arb_reg_sets\n"); |
|
414 |
|
goto err_free_smc_mc_reg_sets; |
|
415 |
|
} |
382 |
416 |
|
|
383 |
|
//TODO:cpy in smc sram and dump the tables from smc sram |
|
|
417 |
|
r = smc_mc_arb_reg_sets_init(ctx, smc_mc_arb_reg_sets); |
|
418 |
|
if (r == -SI_ERR) |
|
419 |
|
goto err_free_smc_mc_arb_reg_sets; |
|
420 |
|
|
|
421 |
|
/*--------------------------------------------------------------------*/ |
|
422 |
|
|
|
423 |
|
//TODO:finish the tbls... |
384 |
424 |
|
|
|
425 |
|
//TODO:cpy in smc sram and dump the tables from smc sram... |
|
426 |
|
|
|
427 |
|
kfree(smc_mc_arb_reg_sets); |
385 |
428 |
kfree(smc_mc_reg_sets); |
kfree(smc_mc_reg_sets); |
386 |
429 |
kfree(smc_lvls); |
kfree(smc_lvls); |
387 |
430 |
kfree(smc_sw_state); |
kfree(smc_sw_state); |
388 |
431 |
return 0; |
return 0; |
389 |
432 |
|
|
|
433 |
|
err_free_smc_mc_arb_reg_sets: |
|
434 |
|
kfree(smc_mc_arb_reg_sets); |
|
435 |
|
|
|
436 |
|
err_free_smc_mc_reg_sets: |
|
437 |
|
kfree(smc_mc_reg_sets); |
|
438 |
|
|
390 |
439 |
err_free_smc_lvls: |
err_free_smc_lvls: |
391 |
440 |
kfree(smc_lvls); |
kfree(smc_lvls); |
392 |
441 |
|
|
File drivers/gpu/alga/amd/si/dyn_pm/smc_mc_arb_tbl.c changed (mode: 100644) (index dc0256e..a10de0a) |
... |
... |
void smc_mc_arb_tbl_dump(struct smc_mc_arb_tbl *tbl) |
53 |
53 |
for (i = 0; i < 3; ++i) |
for (i = 0; i < 3; ++i) |
54 |
54 |
L("rsvd[%u]=0x%02x",i,tbl->rsvd[i]); |
L("rsvd[%u]=0x%02x",i,tbl->rsvd[i]); |
55 |
55 |
|
|
56 |
|
for (i = 0; i < SMC_ARB_TBL_SETS_N_MAX; ++i) { |
|
|
56 |
|
for (i = 0; i < SMC_MC_ARB_TBL_SETS_N_MAX; ++i) { |
57 |
57 |
u32 tmp; |
u32 tmp; |
58 |
58 |
u8 j; |
u8 j; |
59 |
59 |
|
|
|
... |
... |
static u8 refresh_rate(struct ctx *ctx, u32 eng_clk) |
100 |
100 |
/ 64); |
/ 64); |
101 |
101 |
} |
} |
102 |
102 |
|
|
103 |
|
long smc_mc_arb_tbl_set_compute(struct ctx *ctx, struct smc_mc_arb_regs *set, |
|
|
103 |
|
long smc_mc_arb_tbl_set_compute(struct ctx *ctx, struct smc_mc_arb_reg_set *set, |
104 |
104 |
u32 eng_clk, u32 mem_clk) |
u32 eng_clk, u32 mem_clk) |
105 |
105 |
{ |
{ |
106 |
106 |
struct dev_drv_data *dd; |
struct dev_drv_data *dd; |
|
... |
... |
static long initial_emergency_init(struct ctx *ctx, |
141 |
141 |
{ |
{ |
142 |
142 |
u32 eng_clk; |
u32 eng_clk; |
143 |
143 |
u32 mem_clk; |
u32 mem_clk; |
144 |
|
struct smc_mc_arb_regs *initial_set; |
|
|
144 |
|
struct smc_mc_arb_reg_set *initial_set; |
145 |
145 |
long r; |
long r; |
146 |
146 |
|
|
147 |
147 |
/* |
/* |
File drivers/gpu/alga/amd/si/dyn_pm/smc_mc_arb_tbl.h changed (mode: 100644) (index 7e39060..98d49a6) |
9 |
9 |
void smc_mc_arb_tbl_dump(struct smc_mc_arb_tbl *tbl); |
void smc_mc_arb_tbl_dump(struct smc_mc_arb_tbl *tbl); |
10 |
10 |
#endif |
#endif |
11 |
11 |
|
|
12 |
|
long smc_mc_arb_tbl_set_compute(struct ctx *ctx, struct smc_mc_arb_regs *set, |
|
|
12 |
|
long smc_mc_arb_tbl_set_compute(struct ctx *ctx, struct smc_mc_arb_reg_set *set, |
13 |
13 |
u32 eng_clk, u32 mem_clk); |
u32 eng_clk, u32 mem_clk); |
14 |
14 |
long smc_mc_arb_tbl_init(struct ctx *ctx, struct smc_state_tbl *smc_state_tbl, |
long smc_mc_arb_tbl_init(struct ctx *ctx, struct smc_state_tbl *smc_state_tbl, |
15 |
15 |
struct smc_mc_arb_tbl *smc_mc_arb_tbl); |
struct smc_mc_arb_tbl *smc_mc_arb_tbl); |
File drivers/gpu/alga/amd/si/smc_tbls.h changed (mode: 100644) (index dd8abd9..f6fd27d) |
... |
... |
struct smc_mc_reg_tbl { |
253 |
253 |
/*----------------------------------------------------------------------------*/ |
/*----------------------------------------------------------------------------*/ |
254 |
254 |
/* offset in smc address space SMC_FW_HDR_MC_ARB_TBL */ |
/* offset in smc address space SMC_FW_HDR_MC_ARB_TBL */ |
255 |
255 |
/*----------------------------------------------------------------------------*/ |
/*----------------------------------------------------------------------------*/ |
256 |
|
struct smc_mc_arb_regs { |
|
|
256 |
|
struct smc_mc_arb_reg_set { |
257 |
257 |
__be32 dram_timing_x_0; |
__be32 dram_timing_x_0; |
258 |
258 |
__be32 dram_timing_x_1; |
__be32 dram_timing_x_1; |
259 |
259 |
u8 refresh_rate; |
u8 refresh_rate; |
|
... |
... |
struct smc_mc_arb_regs { |
261 |
261 |
u8 pad[2]; |
u8 pad[2]; |
262 |
262 |
} __packed; |
} __packed; |
263 |
263 |
|
|
264 |
|
#define SMC_ARB_TBL_SETS_N_MAX 16 |
|
|
264 |
|
#define SMC_MC_ARB_TBL_SETS_N_MAX 16 |
265 |
265 |
struct smc_mc_arb_tbl { |
struct smc_mc_arb_tbl { |
266 |
266 |
/* this is the *hw* set, not one of the following sets */ |
/* this is the *hw* set, not one of the following sets */ |
267 |
267 |
u8 arb_freq_fx_current; /* MAC_MC_CG_ARB_FREQ_Fx */ |
u8 arb_freq_fx_current; /* MAC_MC_CG_ARB_FREQ_Fx */ |
268 |
268 |
u8 rsvd[3]; |
u8 rsvd[3]; |
269 |
|
struct smc_mc_arb_regs sets[SMC_ARB_TBL_SETS_N_MAX]; |
|
|
269 |
|
struct smc_mc_arb_reg_set sets[SMC_MC_ARB_TBL_SETS_N_MAX]; |
270 |
270 |
} __packed; |
} __packed; |
271 |
271 |
/*----------------------------------------------------------------------------*/ |
/*----------------------------------------------------------------------------*/ |
272 |
272 |
|
|