Commit 454d2e2a authored by Alex Deucher's avatar Alex Deucher

drm/radeon: add a asic callback to get the xclk

This is required to get the reference clock used
by the gfx engine for things like timestamps. Fixes
support for GL extensions the use timestamps on
certain boards.
Signed-off-by: default avatarAlex Deucher <alexander.deucher@amd.com>
parent 0e34d094
...@@ -109,6 +109,19 @@ void r600_fini(struct radeon_device *rdev); ...@@ -109,6 +109,19 @@ void r600_fini(struct radeon_device *rdev);
void r600_irq_disable(struct radeon_device *rdev); void r600_irq_disable(struct radeon_device *rdev);
static void r600_pcie_gen2_enable(struct radeon_device *rdev); static void r600_pcie_gen2_enable(struct radeon_device *rdev);
/**
* r600_get_xclk - get the xclk
*
* @rdev: radeon_device pointer
*
* Returns the reference clock used by the gfx engine
* (r6xx, IGPs, APUs).
*/
u32 r600_get_xclk(struct radeon_device *rdev)
{
return rdev->clock.spll.reference_freq;
}
/* get temperature in millidegrees */ /* get temperature in millidegrees */
int rv6xx_get_temp(struct radeon_device *rdev) int rv6xx_get_temp(struct radeon_device *rdev)
{ {
......
...@@ -1179,6 +1179,8 @@ struct radeon_asic { ...@@ -1179,6 +1179,8 @@ struct radeon_asic {
bool (*gui_idle)(struct radeon_device *rdev); bool (*gui_idle)(struct radeon_device *rdev);
/* wait for mc_idle */ /* wait for mc_idle */
int (*mc_wait_for_idle)(struct radeon_device *rdev); int (*mc_wait_for_idle)(struct radeon_device *rdev);
/* get the reference clock */
u32 (*get_xclk)(struct radeon_device *rdev);
/* gart */ /* gart */
struct { struct {
void (*tlb_flush)(struct radeon_device *rdev); void (*tlb_flush)(struct radeon_device *rdev);
...@@ -1860,6 +1862,7 @@ void radeon_ring_write(struct radeon_ring *ring, uint32_t v); ...@@ -1860,6 +1862,7 @@ void radeon_ring_write(struct radeon_ring *ring, uint32_t v);
#define radeon_post_page_flip(rdev, crtc) (rdev)->asic->pflip.post_page_flip((rdev), (crtc)) #define radeon_post_page_flip(rdev, crtc) (rdev)->asic->pflip.post_page_flip((rdev), (crtc))
#define radeon_wait_for_vblank(rdev, crtc) (rdev)->asic->display.wait_for_vblank((rdev), (crtc)) #define radeon_wait_for_vblank(rdev, crtc) (rdev)->asic->display.wait_for_vblank((rdev), (crtc))
#define radeon_mc_wait_for_idle(rdev) (rdev)->asic->mc_wait_for_idle((rdev)) #define radeon_mc_wait_for_idle(rdev) (rdev)->asic->mc_wait_for_idle((rdev))
#define radeon_get_xclk(rdev) (rdev)->asic->get_xclk((rdev))
/* Common functions */ /* Common functions */
/* AGP */ /* AGP */
......
...@@ -934,6 +934,7 @@ static struct radeon_asic r600_asic = { ...@@ -934,6 +934,7 @@ static struct radeon_asic r600_asic = {
.ioctl_wait_idle = r600_ioctl_wait_idle, .ioctl_wait_idle = r600_ioctl_wait_idle,
.gui_idle = &r600_gui_idle, .gui_idle = &r600_gui_idle,
.mc_wait_for_idle = &r600_mc_wait_for_idle, .mc_wait_for_idle = &r600_mc_wait_for_idle,
.get_xclk = &r600_get_xclk,
.gart = { .gart = {
.tlb_flush = &r600_pcie_gart_tlb_flush, .tlb_flush = &r600_pcie_gart_tlb_flush,
.set_page = &rs600_gart_set_page, .set_page = &rs600_gart_set_page,
...@@ -1018,6 +1019,7 @@ static struct radeon_asic rs780_asic = { ...@@ -1018,6 +1019,7 @@ static struct radeon_asic rs780_asic = {
.ioctl_wait_idle = r600_ioctl_wait_idle, .ioctl_wait_idle = r600_ioctl_wait_idle,
.gui_idle = &r600_gui_idle, .gui_idle = &r600_gui_idle,
.mc_wait_for_idle = &r600_mc_wait_for_idle, .mc_wait_for_idle = &r600_mc_wait_for_idle,
.get_xclk = &r600_get_xclk,
.gart = { .gart = {
.tlb_flush = &r600_pcie_gart_tlb_flush, .tlb_flush = &r600_pcie_gart_tlb_flush,
.set_page = &rs600_gart_set_page, .set_page = &rs600_gart_set_page,
...@@ -1102,6 +1104,7 @@ static struct radeon_asic rv770_asic = { ...@@ -1102,6 +1104,7 @@ static struct radeon_asic rv770_asic = {
.ioctl_wait_idle = r600_ioctl_wait_idle, .ioctl_wait_idle = r600_ioctl_wait_idle,
.gui_idle = &r600_gui_idle, .gui_idle = &r600_gui_idle,
.mc_wait_for_idle = &r600_mc_wait_for_idle, .mc_wait_for_idle = &r600_mc_wait_for_idle,
.get_xclk = &rv770_get_xclk,
.gart = { .gart = {
.tlb_flush = &r600_pcie_gart_tlb_flush, .tlb_flush = &r600_pcie_gart_tlb_flush,
.set_page = &rs600_gart_set_page, .set_page = &rs600_gart_set_page,
...@@ -1186,6 +1189,7 @@ static struct radeon_asic evergreen_asic = { ...@@ -1186,6 +1189,7 @@ static struct radeon_asic evergreen_asic = {
.ioctl_wait_idle = r600_ioctl_wait_idle, .ioctl_wait_idle = r600_ioctl_wait_idle,
.gui_idle = &r600_gui_idle, .gui_idle = &r600_gui_idle,
.mc_wait_for_idle = &evergreen_mc_wait_for_idle, .mc_wait_for_idle = &evergreen_mc_wait_for_idle,
.get_xclk = &rv770_get_xclk,
.gart = { .gart = {
.tlb_flush = &evergreen_pcie_gart_tlb_flush, .tlb_flush = &evergreen_pcie_gart_tlb_flush,
.set_page = &rs600_gart_set_page, .set_page = &rs600_gart_set_page,
...@@ -1270,6 +1274,7 @@ static struct radeon_asic sumo_asic = { ...@@ -1270,6 +1274,7 @@ static struct radeon_asic sumo_asic = {
.ioctl_wait_idle = r600_ioctl_wait_idle, .ioctl_wait_idle = r600_ioctl_wait_idle,
.gui_idle = &r600_gui_idle, .gui_idle = &r600_gui_idle,
.mc_wait_for_idle = &evergreen_mc_wait_for_idle, .mc_wait_for_idle = &evergreen_mc_wait_for_idle,
.get_xclk = &r600_get_xclk,
.gart = { .gart = {
.tlb_flush = &evergreen_pcie_gart_tlb_flush, .tlb_flush = &evergreen_pcie_gart_tlb_flush,
.set_page = &rs600_gart_set_page, .set_page = &rs600_gart_set_page,
...@@ -1354,6 +1359,7 @@ static struct radeon_asic btc_asic = { ...@@ -1354,6 +1359,7 @@ static struct radeon_asic btc_asic = {
.ioctl_wait_idle = r600_ioctl_wait_idle, .ioctl_wait_idle = r600_ioctl_wait_idle,
.gui_idle = &r600_gui_idle, .gui_idle = &r600_gui_idle,
.mc_wait_for_idle = &evergreen_mc_wait_for_idle, .mc_wait_for_idle = &evergreen_mc_wait_for_idle,
.get_xclk = &rv770_get_xclk,
.gart = { .gart = {
.tlb_flush = &evergreen_pcie_gart_tlb_flush, .tlb_flush = &evergreen_pcie_gart_tlb_flush,
.set_page = &rs600_gart_set_page, .set_page = &rs600_gart_set_page,
...@@ -1438,6 +1444,7 @@ static struct radeon_asic cayman_asic = { ...@@ -1438,6 +1444,7 @@ static struct radeon_asic cayman_asic = {
.ioctl_wait_idle = r600_ioctl_wait_idle, .ioctl_wait_idle = r600_ioctl_wait_idle,
.gui_idle = &r600_gui_idle, .gui_idle = &r600_gui_idle,
.mc_wait_for_idle = &evergreen_mc_wait_for_idle, .mc_wait_for_idle = &evergreen_mc_wait_for_idle,
.get_xclk = &rv770_get_xclk,
.gart = { .gart = {
.tlb_flush = &cayman_pcie_gart_tlb_flush, .tlb_flush = &cayman_pcie_gart_tlb_flush,
.set_page = &rs600_gart_set_page, .set_page = &rs600_gart_set_page,
...@@ -1565,6 +1572,7 @@ static struct radeon_asic trinity_asic = { ...@@ -1565,6 +1572,7 @@ static struct radeon_asic trinity_asic = {
.ioctl_wait_idle = r600_ioctl_wait_idle, .ioctl_wait_idle = r600_ioctl_wait_idle,
.gui_idle = &r600_gui_idle, .gui_idle = &r600_gui_idle,
.mc_wait_for_idle = &evergreen_mc_wait_for_idle, .mc_wait_for_idle = &evergreen_mc_wait_for_idle,
.get_xclk = &r600_get_xclk,
.gart = { .gart = {
.tlb_flush = &cayman_pcie_gart_tlb_flush, .tlb_flush = &cayman_pcie_gart_tlb_flush,
.set_page = &rs600_gart_set_page, .set_page = &rs600_gart_set_page,
...@@ -1692,6 +1700,7 @@ static struct radeon_asic si_asic = { ...@@ -1692,6 +1700,7 @@ static struct radeon_asic si_asic = {
.ioctl_wait_idle = r600_ioctl_wait_idle, .ioctl_wait_idle = r600_ioctl_wait_idle,
.gui_idle = &r600_gui_idle, .gui_idle = &r600_gui_idle,
.mc_wait_for_idle = &evergreen_mc_wait_for_idle, .mc_wait_for_idle = &evergreen_mc_wait_for_idle,
.get_xclk = &si_get_xclk,
.gart = { .gart = {
.tlb_flush = &si_pcie_gart_tlb_flush, .tlb_flush = &si_pcie_gart_tlb_flush,
.set_page = &rs600_gart_set_page, .set_page = &rs600_gart_set_page,
......
...@@ -390,6 +390,7 @@ void r600_kms_blit_copy(struct radeon_device *rdev, ...@@ -390,6 +390,7 @@ void r600_kms_blit_copy(struct radeon_device *rdev,
struct radeon_sa_bo *vb); struct radeon_sa_bo *vb);
int r600_mc_wait_for_idle(struct radeon_device *rdev); int r600_mc_wait_for_idle(struct radeon_device *rdev);
uint64_t r600_get_gpu_clock(struct radeon_device *rdev); uint64_t r600_get_gpu_clock(struct radeon_device *rdev);
u32 r600_get_xclk(struct radeon_device *rdev);
/* /*
* rv770,rv730,rv710,rv740 * rv770,rv730,rv710,rv740
...@@ -407,6 +408,7 @@ int rv770_copy_dma(struct radeon_device *rdev, ...@@ -407,6 +408,7 @@ int rv770_copy_dma(struct radeon_device *rdev,
uint64_t src_offset, uint64_t dst_offset, uint64_t src_offset, uint64_t dst_offset,
unsigned num_gpu_pages, unsigned num_gpu_pages,
struct radeon_fence **fence); struct radeon_fence **fence);
u32 rv770_get_xclk(struct radeon_device *rdev);
/* /*
* evergreen * evergreen
...@@ -521,5 +523,6 @@ int si_copy_dma(struct radeon_device *rdev, ...@@ -521,5 +523,6 @@ int si_copy_dma(struct radeon_device *rdev,
unsigned num_gpu_pages, unsigned num_gpu_pages,
struct radeon_fence **fence); struct radeon_fence **fence);
void si_dma_vm_flush(struct radeon_device *rdev, int ridx, struct radeon_vm *vm); void si_dma_vm_flush(struct radeon_device *rdev, int ridx, struct radeon_vm *vm);
u32 si_get_xclk(struct radeon_device *rdev);
#endif #endif
...@@ -282,6 +282,9 @@ int radeon_info_ioctl(struct drm_device *dev, void *data, struct drm_file *filp) ...@@ -282,6 +282,9 @@ int radeon_info_ioctl(struct drm_device *dev, void *data, struct drm_file *filp)
break; break;
case RADEON_INFO_CLOCK_CRYSTAL_FREQ: case RADEON_INFO_CLOCK_CRYSTAL_FREQ:
/* return clock value in KHz */ /* return clock value in KHz */
if (rdev->asic->get_xclk)
value = radeon_get_xclk(rdev) * 10;
else
value = rdev->clock.spll.reference_freq * 10; value = rdev->clock.spll.reference_freq * 10;
break; break;
case RADEON_INFO_NUM_BACKENDS: case RADEON_INFO_NUM_BACKENDS:
......
...@@ -43,6 +43,31 @@ static void rv770_gpu_init(struct radeon_device *rdev); ...@@ -43,6 +43,31 @@ static void rv770_gpu_init(struct radeon_device *rdev);
void rv770_fini(struct radeon_device *rdev); void rv770_fini(struct radeon_device *rdev);
static void rv770_pcie_gen2_enable(struct radeon_device *rdev); static void rv770_pcie_gen2_enable(struct radeon_device *rdev);
#define PCIE_BUS_CLK 10000
#define TCLK (PCIE_BUS_CLK / 10)
/**
* rv770_get_xclk - get the xclk
*
* @rdev: radeon_device pointer
*
* Returns the reference clock used by the gfx engine
* (r7xx-cayman).
*/
u32 rv770_get_xclk(struct radeon_device *rdev)
{
u32 reference_clock = rdev->clock.spll.reference_freq;
u32 tmp = RREG32(CG_CLKPIN_CNTL);
if (tmp & MUX_TCLK_TO_XCLK)
return TCLK;
if (tmp & XTALIN_DIVIDE)
return reference_clock / 4;
return reference_clock;
}
u32 rv770_page_flip(struct radeon_device *rdev, int crtc_id, u64 crtc_base) u32 rv770_page_flip(struct radeon_device *rdev, int crtc_id, u64 crtc_base)
{ {
struct radeon_crtc *radeon_crtc = rdev->mode_info.crtcs[crtc_id]; struct radeon_crtc *radeon_crtc = rdev->mode_info.crtcs[crtc_id];
......
...@@ -128,6 +128,10 @@ ...@@ -128,6 +128,10 @@
#define GUI_ACTIVE (1<<31) #define GUI_ACTIVE (1<<31)
#define GRBM_STATUS2 0x8014 #define GRBM_STATUS2 0x8014
#define CG_CLKPIN_CNTL 0x660
# define MUX_TCLK_TO_XCLK (1 << 8)
# define XTALIN_DIVIDE (1 << 9)
#define CG_MULT_THERMAL_STATUS 0x740 #define CG_MULT_THERMAL_STATUS 0x740
#define ASIC_T(x) ((x) << 16) #define ASIC_T(x) ((x) << 16)
#define ASIC_T_MASK 0x3FF0000 #define ASIC_T_MASK 0x3FF0000
......
...@@ -70,6 +70,33 @@ extern u32 evergreen_get_number_of_dram_channels(struct radeon_device *rdev); ...@@ -70,6 +70,33 @@ extern u32 evergreen_get_number_of_dram_channels(struct radeon_device *rdev);
extern void evergreen_print_gpu_status_regs(struct radeon_device *rdev); extern void evergreen_print_gpu_status_regs(struct radeon_device *rdev);
extern bool evergreen_is_display_hung(struct radeon_device *rdev); extern bool evergreen_is_display_hung(struct radeon_device *rdev);
#define PCIE_BUS_CLK 10000
#define TCLK (PCIE_BUS_CLK / 10)
/**
* si_get_xclk - get the xclk
*
* @rdev: radeon_device pointer
*
* Returns the reference clock used by the gfx engine
* (SI).
*/
u32 si_get_xclk(struct radeon_device *rdev)
{
u32 reference_clock = rdev->clock.spll.reference_freq;
u32 tmp;
tmp = RREG32(CG_CLKPIN_CNTL_2);
if (tmp & MUX_TCLK_TO_XCLK)
return TCLK;
tmp = RREG32(CG_CLKPIN_CNTL);
if (tmp & XTALIN_DIVIDE)
return reference_clock / 4;
return reference_clock;
}
/* get temperature in millidegrees */ /* get temperature in millidegrees */
int si_get_temp(struct radeon_device *rdev) int si_get_temp(struct radeon_device *rdev)
{ {
......
...@@ -58,6 +58,11 @@ ...@@ -58,6 +58,11 @@
#define VGA_HDP_CONTROL 0x328 #define VGA_HDP_CONTROL 0x328
#define VGA_MEMORY_DISABLE (1 << 4) #define VGA_MEMORY_DISABLE (1 << 4)
#define CG_CLKPIN_CNTL 0x660
# define XTALIN_DIVIDE (1 << 1)
#define CG_CLKPIN_CNTL_2 0x664
# define MUX_TCLK_TO_XCLK (1 << 8)
#define DMIF_ADDR_CONFIG 0xBD4 #define DMIF_ADDR_CONFIG 0xBD4
#define SRBM_STATUS 0xE50 #define SRBM_STATUS 0xE50
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment