| // SPDX-License-Identifier: GPL-2.0-only |
| /* |
| * 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); |
| } |