summaryrefslogtreecommitdiff
path: root/gxp-doorbell.c
blob: 491fb5b808d027063832e3635ccf6127b3e06141 (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
// SPDX-License-Identifier: GPL-2.0
/*
 * GXP doorbell interface.
 *
 * Copyright (C) 2020 Google LLC
 */

#include <linux/bitops.h>

#include "gxp-doorbell.h"
#include "gxp-internal.h"

#define GXP_DOORBELL_STRIDE (GXP_REG_DOORBELL_1_STATUS \
			     - GXP_REG_DOORBELL_0_STATUS)

void gxp_doorbell_enable_for_core(struct gxp_dev *gxp, u32 doorbell_num,
				  uint core)
{
	u32 val;

	/* Enable DOORBELL_NUM on requested core */
	val = gxp_read_32(gxp, GXP_CORE_REG_COMMON_INT_MASK_0(core));
	val |= BIT(doorbell_num);
	gxp_write_32(gxp, GXP_CORE_REG_COMMON_INT_MASK_0(core), val);
}

void gxp_doorbell_set(struct gxp_dev *gxp, u32 doorbell_num)
{
	uint offset = GXP_REG_DOORBELL_0_SET
		      + (GXP_DOORBELL_STRIDE * doorbell_num);

	gxp_write_32(gxp, offset, GXP_REG_DOORBELLS_SET_WRITEMASK);
}

void gxp_doorbell_clear(struct gxp_dev *gxp, u32 doorbell_num)
{
	uint offset = GXP_REG_DOORBELL_0_CLEAR
		      + (GXP_DOORBELL_STRIDE * doorbell_num);

	gxp_write_32(gxp, offset, GXP_REG_DOORBELLS_CLEAR_WRITEMASK);
}

u32 gxp_doorbell_status(struct gxp_dev *gxp, u32 doorbell_num)
{
	uint offset = GXP_REG_DOORBELL_0_STATUS
		      + (GXP_DOORBELL_STRIDE * doorbell_num);

	return gxp_read_32(gxp, offset);
}