Lines Matching +full:mipi +full:- +full:i3c +full:- +full:hci

1 // SPDX-License-Identifier: BSD-3-Clause
3 * Copyright (c) 2020, MIPI Alliance, Inc.
12 #include <linux/i3c/master.h>
15 #include "hci.h"
38 #define dat_w0_read(i) readl(hci->DAT_regs + (i) * 8)
39 #define dat_w1_read(i) readl(hci->DAT_regs + (i) * 8 + 4)
40 #define dat_w0_write(i, v) writel(v, hci->DAT_regs + (i) * 8)
41 #define dat_w1_write(i, v) writel(v, hci->DAT_regs + (i) * 8 + 4)
52 static int hci_dat_v1_init(struct i3c_hci *hci) in hci_dat_v1_init() argument
56 if (!hci->DAT_regs) { in hci_dat_v1_init()
57 dev_err(&hci->master.dev, in hci_dat_v1_init()
59 return -EOPNOTSUPP; in hci_dat_v1_init()
61 if (hci->DAT_entry_size != 8) { in hci_dat_v1_init()
62 dev_err(&hci->master.dev, in hci_dat_v1_init()
63 "only 8-bytes DAT entries are supported at the moment\n"); in hci_dat_v1_init()
64 return -EOPNOTSUPP; in hci_dat_v1_init()
68 hci->DAT_data = bitmap_zalloc(hci->DAT_entries, GFP_KERNEL); in hci_dat_v1_init()
69 if (!hci->DAT_data) in hci_dat_v1_init()
70 return -ENOMEM; in hci_dat_v1_init()
73 for (dat_idx = 0; dat_idx < hci->DAT_entries; dat_idx++) { in hci_dat_v1_init()
81 static void hci_dat_v1_cleanup(struct i3c_hci *hci) in hci_dat_v1_cleanup() argument
83 bitmap_free(hci->DAT_data); in hci_dat_v1_cleanup()
84 hci->DAT_data = NULL; in hci_dat_v1_cleanup()
87 static int hci_dat_v1_alloc_entry(struct i3c_hci *hci) in hci_dat_v1_alloc_entry() argument
91 dat_idx = find_first_zero_bit(hci->DAT_data, hci->DAT_entries); in hci_dat_v1_alloc_entry()
92 if (dat_idx >= hci->DAT_entries) in hci_dat_v1_alloc_entry()
93 return -ENOENT; in hci_dat_v1_alloc_entry()
94 __set_bit(dat_idx, hci->DAT_data); in hci_dat_v1_alloc_entry()
102 static void hci_dat_v1_free_entry(struct i3c_hci *hci, unsigned int dat_idx) in hci_dat_v1_free_entry() argument
106 __clear_bit(dat_idx, hci->DAT_data); in hci_dat_v1_free_entry()
109 static void hci_dat_v1_set_dynamic_addr(struct i3c_hci *hci, in hci_dat_v1_set_dynamic_addr() argument
121 static void hci_dat_v1_set_static_addr(struct i3c_hci *hci, in hci_dat_v1_set_static_addr() argument
132 static void hci_dat_v1_set_flags(struct i3c_hci *hci, unsigned int dat_idx, in hci_dat_v1_set_flags() argument
145 static void hci_dat_v1_clear_flags(struct i3c_hci *hci, unsigned int dat_idx, in hci_dat_v1_clear_flags() argument
158 static int hci_dat_v1_get_index(struct i3c_hci *hci, u8 dev_addr) in hci_dat_v1_get_index() argument
163 for_each_set_bit(dat_idx, hci->DAT_data, hci->DAT_entries) { in hci_dat_v1_get_index()
169 return -ENODEV; in hci_dat_v1_get_index()