Back to home page

OSCL-LXR

 
 

    


0001 // SPDX-License-Identifier: BSD-3-Clause
0002 /*
0003  * Copyright (c) 2020, MIPI Alliance, Inc.
0004  *
0005  * Author: Nicolas Pitre <npitre@baylibre.com>
0006  */
0007 
0008 #include <linux/device.h>
0009 #include <linux/bitfield.h>
0010 #include <linux/i3c/master.h>
0011 #include <linux/io.h>
0012 
0013 #include "hci.h"
0014 #include "dct.h"
0015 
0016 /*
0017  * Device Characteristic Table
0018  */
0019 
0020 void i3c_hci_dct_get_val(struct i3c_hci *hci, unsigned int dct_idx,
0021              u64 *pid, unsigned int *dcr, unsigned int *bcr)
0022 {
0023     void __iomem *reg = hci->DCT_regs + dct_idx * 4 * 4;
0024     u32 dct_entry_data[4];
0025     unsigned int i;
0026 
0027     for (i = 0; i < 4; i++) {
0028         dct_entry_data[i] = readl(reg);
0029         reg += 4;
0030     }
0031 
0032     *pid = ((u64)dct_entry_data[0]) << (47 - 32 + 1) |
0033            FIELD_GET(W1_MASK(47, 32), dct_entry_data[1]);
0034     *dcr = FIELD_GET(W2_MASK(71, 64), dct_entry_data[2]);
0035     *bcr = FIELD_GET(W2_MASK(79, 72), dct_entry_data[2]);
0036 }