blob: 147723ce041ac7ed40c93b5fda4115557ce197ca (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
|
/* SPDX-License-Identifier: GPL-2.0 */
/*
* Common platform interfaces for mobile TPU chips.
*
* Copyright (C) 2021 Google, Inc.
*/
#ifndef __EDGETPU_MOBILE_PLATFORM_H__
#define __EDGETPU_MOBILE_PLATFORM_H__
#include <linux/debugfs.h>
#include <linux/device.h>
#include <linux/gfp.h>
#include <linux/kernel.h>
#include <linux/mutex.h>
#include <linux/types.h>
#include "edgetpu-config.h"
#include "edgetpu-internal.h"
#include "mobile-debug-dump.h"
/*
* Log and trace buffers at the beginning of the remapped region,
* pool memory afterwards.
*/
#define EDGETPU_POOL_MEM_OFFSET \
((EDGETPU_TELEMETRY_LOG_BUFFER_SIZE + EDGETPU_TELEMETRY_TRACE_BUFFER_SIZE) * \
EDGETPU_NUM_CORES)
#define to_mobile_dev(etdev) container_of(etdev, struct edgetpu_mobile_platform_dev, edgetpu_dev)
struct edgetpu_mobile_platform_pwr {
struct dentry *debugfs_dir;
struct mutex policy_lock;
enum edgetpu_pwr_state curr_policy;
struct mutex state_lock;
u64 min_state;
u64 requested_state;
/* LPM callbacks, NULL for chips without LPM */
int (*lpm_up)(struct edgetpu_dev *etdev);
void (*lpm_down)(struct edgetpu_dev *etdev);
/* Block shutdown status callback, may be NULL */
bool (*is_block_down)(struct edgetpu_dev *etdev);
/* After firmware is started on power up */
void (*post_fw_start)(struct edgetpu_dev *etdev);
};
struct edgetpu_mobile_fw_ctx {
/* SG table for NS firmware context region mappings. */
struct sg_table *sgt;
/* DMA address of the NS firmware context region. */
dma_addr_t daddr;
/* Size of the NS firmware context region. */
size_t size;
/* List of all NS firmware context region mappings for the device. */
struct list_head list;
};
struct edgetpu_mobile_platform_dev {
/* Generic edgetpu device */
struct edgetpu_dev edgetpu_dev;
/* Common mobile platform power interface */
struct edgetpu_mobile_platform_pwr platform_pwr;
/* Physical address of the firmware image */
phys_addr_t fw_region_paddr;
/* Size of the firmware region */
size_t fw_region_size;
/* TPU address from which the TPU CPU can access data in the remapped region */
tpu_addr_t remapped_data_addr;
/* Size of remapped DRAM data region */
size_t remapped_data_size;
/* Virtual address of the memory region shared with firmware */
void *shared_mem_vaddr;
/* Physical address of the memory region shared with firmware */
phys_addr_t shared_mem_paddr;
/* Size of the shared memory region size */
size_t shared_mem_size;
/* List of all NS firmware context region mappings for the device. */
struct list_head fw_ctx_list;
/* Lock to protect @fw_ctx_list. */
struct mutex fw_ctx_list_lock;
/*
* Pointer to GSA device for firmware authentication.
* May be NULL if the chip does not support firmware authentication
*/
struct device *gsa_dev;
/* Coherent log buffer */
struct edgetpu_coherent_mem *log_mem;
/* Coherent trace buffer */
struct edgetpu_coherent_mem *trace_mem;
/* subsystem coredump info struct */
struct mobile_sscd_info sscd_info;
/* Protects TZ Mailbox client pointer */
struct mutex tz_mailbox_lock;
/* TZ mailbox client */
struct edgetpu_client *secure_client;
/* Length of @irq */
int n_irq;
/* Array of IRQ numbers */
int *irq;
/* callbacks for chip-dependent implementations */
/*
* Called when common device probing procedure is done.
*
* Return a non-zero value can fail the probe procedure.
*
* This callback is optional.
*/
int (*after_probe)(struct edgetpu_mobile_platform_dev *etmdev);
};
/* Sets up telemetry buffer address and size. */
void edgetpu_mobile_set_telemetry_mem(struct edgetpu_mobile_platform_dev *etmdev);
#endif /* __EDGETPU_MOBILE_PLATFORM_H__ */
|