root/drivers/gpu/drm/lima/lima_device.h

/* [<][>][^][v][top][bottom][index][help] */

INCLUDED FROM


DEFINITIONS

This source file includes following definitions.
  1. to_lima_dev
  2. lima_poll_timeout

   1 /* SPDX-License-Identifier: GPL-2.0 OR MIT */
   2 /* Copyright 2018-2019 Qiang Yu <yuq825@gmail.com> */
   3 
   4 #ifndef __LIMA_DEVICE_H__
   5 #define __LIMA_DEVICE_H__
   6 
   7 #include <drm/drm_device.h>
   8 #include <linux/delay.h>
   9 
  10 #include "lima_sched.h"
  11 
  12 enum lima_gpu_id {
  13         lima_gpu_mali400 = 0,
  14         lima_gpu_mali450,
  15         lima_gpu_num,
  16 };
  17 
  18 enum lima_ip_id {
  19         lima_ip_pmu,
  20         lima_ip_gpmmu,
  21         lima_ip_ppmmu0,
  22         lima_ip_ppmmu1,
  23         lima_ip_ppmmu2,
  24         lima_ip_ppmmu3,
  25         lima_ip_ppmmu4,
  26         lima_ip_ppmmu5,
  27         lima_ip_ppmmu6,
  28         lima_ip_ppmmu7,
  29         lima_ip_gp,
  30         lima_ip_pp0,
  31         lima_ip_pp1,
  32         lima_ip_pp2,
  33         lima_ip_pp3,
  34         lima_ip_pp4,
  35         lima_ip_pp5,
  36         lima_ip_pp6,
  37         lima_ip_pp7,
  38         lima_ip_l2_cache0,
  39         lima_ip_l2_cache1,
  40         lima_ip_l2_cache2,
  41         lima_ip_dlbu,
  42         lima_ip_bcast,
  43         lima_ip_pp_bcast,
  44         lima_ip_ppmmu_bcast,
  45         lima_ip_num,
  46 };
  47 
  48 struct lima_device;
  49 
  50 struct lima_ip {
  51         struct lima_device *dev;
  52         enum lima_ip_id id;
  53         bool present;
  54 
  55         void __iomem *iomem;
  56         int irq;
  57 
  58         union {
  59                 /* gp/pp */
  60                 bool async_reset;
  61                 /* l2 cache */
  62                 spinlock_t lock;
  63         } data;
  64 };
  65 
  66 enum lima_pipe_id {
  67         lima_pipe_gp,
  68         lima_pipe_pp,
  69         lima_pipe_num,
  70 };
  71 
  72 struct lima_device {
  73         struct device *dev;
  74         struct drm_device *ddev;
  75         struct platform_device *pdev;
  76 
  77         enum lima_gpu_id id;
  78         u32 gp_version;
  79         u32 pp_version;
  80         int num_pp;
  81 
  82         void __iomem *iomem;
  83         struct clk *clk_bus;
  84         struct clk *clk_gpu;
  85         struct reset_control *reset;
  86         struct regulator *regulator;
  87 
  88         struct lima_ip ip[lima_ip_num];
  89         struct lima_sched_pipe pipe[lima_pipe_num];
  90 
  91         struct lima_vm *empty_vm;
  92         uint64_t va_start;
  93         uint64_t va_end;
  94 
  95         u32 *dlbu_cpu;
  96         dma_addr_t dlbu_dma;
  97 };
  98 
  99 static inline struct lima_device *
 100 to_lima_dev(struct drm_device *dev)
 101 {
 102         return dev->dev_private;
 103 }
 104 
 105 int lima_device_init(struct lima_device *ldev);
 106 void lima_device_fini(struct lima_device *ldev);
 107 
 108 const char *lima_ip_name(struct lima_ip *ip);
 109 
 110 typedef int (*lima_poll_func_t)(struct lima_ip *);
 111 
 112 static inline int lima_poll_timeout(struct lima_ip *ip, lima_poll_func_t func,
 113                                     int sleep_us, int timeout_us)
 114 {
 115         ktime_t timeout = ktime_add_us(ktime_get(), timeout_us);
 116 
 117         might_sleep_if(sleep_us);
 118         while (1) {
 119                 if (func(ip))
 120                         return 0;
 121 
 122                 if (timeout_us && ktime_compare(ktime_get(), timeout) > 0)
 123                         return -ETIMEDOUT;
 124 
 125                 if (sleep_us)
 126                         usleep_range((sleep_us >> 2) + 1, sleep_us);
 127         }
 128         return 0;
 129 }
 130 
 131 #endif

/* [<][>][^][v][top][bottom][index][help] */