2018-09-11 02:27:58 +07:00
|
|
|
/* SPDX-License-Identifier: GPL-2.0 */
|
|
|
|
/* Copyright 2018 Marty E. Plummer <hanetzer@startmail.com> */
|
|
|
|
/* Copyright 2019 Linaro, Ltd, Rob Herring <robh@kernel.org> */
|
|
|
|
|
|
|
|
#ifndef __PANFROST_DEVICE_H__
|
|
|
|
#define __PANFROST_DEVICE_H__
|
|
|
|
|
2019-08-13 22:01:15 +07:00
|
|
|
#include <linux/atomic.h>
|
|
|
|
#include <linux/io-pgtable.h>
|
2018-09-11 02:27:58 +07:00
|
|
|
#include <linux/spinlock.h>
|
|
|
|
#include <drm/drm_device.h>
|
|
|
|
#include <drm/drm_mm.h>
|
|
|
|
#include <drm/gpu_scheduler.h>
|
|
|
|
|
|
|
|
struct panfrost_device;
|
|
|
|
struct panfrost_mmu;
|
|
|
|
struct panfrost_job_slot;
|
|
|
|
struct panfrost_job;
|
2019-06-18 15:16:48 +07:00
|
|
|
struct panfrost_perfcnt;
|
2018-09-11 02:27:58 +07:00
|
|
|
|
|
|
|
#define NUM_JOB_SLOTS 3
|
|
|
|
|
|
|
|
struct panfrost_features {
|
|
|
|
u16 id;
|
|
|
|
u16 revision;
|
|
|
|
|
|
|
|
u64 shader_present;
|
|
|
|
u64 tiler_present;
|
|
|
|
u64 l2_present;
|
|
|
|
u64 stack_present;
|
|
|
|
u32 as_present;
|
|
|
|
u32 js_present;
|
|
|
|
|
|
|
|
u32 l2_features;
|
|
|
|
u32 core_features;
|
|
|
|
u32 tiler_features;
|
|
|
|
u32 mem_features;
|
|
|
|
u32 mmu_features;
|
|
|
|
u32 thread_features;
|
|
|
|
u32 max_threads;
|
|
|
|
u32 thread_max_workgroup_sz;
|
|
|
|
u32 thread_max_barrier_sz;
|
|
|
|
u32 coherency_features;
|
|
|
|
u32 texture_features[4];
|
|
|
|
u32 js_features[16];
|
|
|
|
|
|
|
|
u32 nr_core_groups;
|
2019-07-24 17:56:26 +07:00
|
|
|
u32 thread_tls_alloc;
|
2018-09-11 02:27:58 +07:00
|
|
|
|
|
|
|
unsigned long hw_features[64 / BITS_PER_LONG];
|
|
|
|
unsigned long hw_issues[64 / BITS_PER_LONG];
|
|
|
|
};
|
|
|
|
|
|
|
|
struct panfrost_device {
|
|
|
|
struct device *dev;
|
|
|
|
struct drm_device *ddev;
|
|
|
|
struct platform_device *pdev;
|
|
|
|
|
|
|
|
void __iomem *iomem;
|
|
|
|
struct clk *clock;
|
2019-05-21 23:10:57 +07:00
|
|
|
struct clk *bus_clock;
|
2018-09-11 02:27:58 +07:00
|
|
|
struct regulator *regulator;
|
|
|
|
struct reset_control *rstc;
|
|
|
|
|
|
|
|
struct panfrost_features features;
|
|
|
|
|
2019-08-13 22:01:15 +07:00
|
|
|
spinlock_t as_lock;
|
|
|
|
unsigned long as_in_use_mask;
|
|
|
|
unsigned long as_alloc_mask;
|
|
|
|
struct list_head as_lru_list;
|
|
|
|
|
2018-09-11 02:27:58 +07:00
|
|
|
struct panfrost_job_slot *js;
|
|
|
|
|
|
|
|
struct panfrost_job *jobs[NUM_JOB_SLOTS];
|
|
|
|
struct list_head scheduled_jobs;
|
|
|
|
|
2019-06-18 15:16:48 +07:00
|
|
|
struct panfrost_perfcnt *perfcnt;
|
|
|
|
|
2018-09-11 02:27:58 +07:00
|
|
|
struct mutex sched_lock;
|
2019-04-18 15:41:48 +07:00
|
|
|
struct mutex reset_lock;
|
2018-09-11 02:27:58 +07:00
|
|
|
|
2019-08-05 21:33:58 +07:00
|
|
|
struct mutex shrinker_lock;
|
|
|
|
struct list_head shrinker_list;
|
|
|
|
struct shrinker shrinker;
|
|
|
|
|
2018-09-11 02:27:58 +07:00
|
|
|
struct {
|
|
|
|
struct devfreq *devfreq;
|
|
|
|
struct thermal_cooling_device *cooling;
|
2019-10-25 20:41:43 +07:00
|
|
|
ktime_t busy_time;
|
|
|
|
ktime_t idle_time;
|
|
|
|
ktime_t time_last_update;
|
|
|
|
atomic_t busy_count;
|
2018-09-11 02:27:58 +07:00
|
|
|
} devfreq;
|
|
|
|
};
|
|
|
|
|
2019-08-13 22:01:15 +07:00
|
|
|
struct panfrost_mmu {
|
|
|
|
struct io_pgtable_cfg pgtbl_cfg;
|
|
|
|
struct io_pgtable_ops *pgtbl_ops;
|
|
|
|
int as;
|
|
|
|
atomic_t as_count;
|
|
|
|
struct list_head list;
|
|
|
|
};
|
|
|
|
|
2018-09-11 02:27:58 +07:00
|
|
|
struct panfrost_file_priv {
|
|
|
|
struct panfrost_device *pfdev;
|
|
|
|
|
|
|
|
struct drm_sched_entity sched_entity[NUM_JOB_SLOTS];
|
2019-08-13 22:01:15 +07:00
|
|
|
|
|
|
|
struct panfrost_mmu mmu;
|
|
|
|
struct drm_mm mm;
|
|
|
|
spinlock_t mm_lock;
|
2018-09-11 02:27:58 +07:00
|
|
|
};
|
|
|
|
|
|
|
|
static inline struct panfrost_device *to_panfrost_device(struct drm_device *ddev)
|
|
|
|
{
|
|
|
|
return ddev->dev_private;
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline int panfrost_model_cmp(struct panfrost_device *pfdev, s32 id)
|
|
|
|
{
|
|
|
|
s32 match_id = pfdev->features.id;
|
|
|
|
|
|
|
|
if (match_id & 0xf000)
|
|
|
|
match_id &= 0xf00f;
|
|
|
|
return match_id - id;
|
|
|
|
}
|
|
|
|
|
2019-06-18 15:16:47 +07:00
|
|
|
static inline bool panfrost_model_is_bifrost(struct panfrost_device *pfdev)
|
|
|
|
{
|
|
|
|
return panfrost_model_cmp(pfdev, 0x1000) >= 0;
|
|
|
|
}
|
|
|
|
|
2018-09-11 02:27:58 +07:00
|
|
|
static inline bool panfrost_model_eq(struct panfrost_device *pfdev, s32 id)
|
|
|
|
{
|
|
|
|
return !panfrost_model_cmp(pfdev, id);
|
|
|
|
}
|
|
|
|
|
2019-06-18 15:16:46 +07:00
|
|
|
int panfrost_unstable_ioctl_check(void);
|
|
|
|
|
2018-09-11 02:27:58 +07:00
|
|
|
int panfrost_device_init(struct panfrost_device *pfdev);
|
|
|
|
void panfrost_device_fini(struct panfrost_device *pfdev);
|
2019-08-09 03:30:39 +07:00
|
|
|
void panfrost_device_reset(struct panfrost_device *pfdev);
|
2018-09-11 02:27:58 +07:00
|
|
|
|
|
|
|
int panfrost_device_resume(struct device *dev);
|
|
|
|
int panfrost_device_suspend(struct device *dev);
|
|
|
|
|
|
|
|
const char *panfrost_exception_name(struct panfrost_device *pfdev, u32 exception_code);
|
|
|
|
|
|
|
|
#endif
|