cachepc-linux

Fork of AMDESE/linux with modifications for CachePC side-channel attack
git clone https://git.sinitax.com/sinitax/cachepc-linux
Log | Files | Refs | README | LICENSE | sfeed.txt

dct_v1.c (837B)


      1// SPDX-License-Identifier: BSD-3-Clause
      2/*
      3 * Copyright (c) 2020, MIPI Alliance, Inc.
      4 *
      5 * Author: Nicolas Pitre <npitre@baylibre.com>
      6 */
      7
      8#include <linux/device.h>
      9#include <linux/bitfield.h>
     10#include <linux/i3c/master.h>
     11#include <linux/io.h>
     12
     13#include "hci.h"
     14#include "dct.h"
     15
     16/*
     17 * Device Characteristic Table
     18 */
     19
     20void i3c_hci_dct_get_val(struct i3c_hci *hci, unsigned int dct_idx,
     21			 u64 *pid, unsigned int *dcr, unsigned int *bcr)
     22{
     23	void __iomem *reg = hci->DCT_regs + dct_idx * 4 * 4;
     24	u32 dct_entry_data[4];
     25	unsigned int i;
     26
     27	for (i = 0; i < 4; i++) {
     28		dct_entry_data[i] = readl(reg);
     29		reg += 4;
     30	}
     31
     32	*pid = ((u64)dct_entry_data[0]) << (47 - 32 + 1) |
     33	       FIELD_GET(W1_MASK(47, 32), dct_entry_data[1]);
     34	*dcr = FIELD_GET(W2_MASK(71, 64), dct_entry_data[2]);
     35	*bcr = FIELD_GET(W2_MASK(79, 72), dct_entry_data[2]);
     36}