• Home
  • Raw
  • Download

Lines Matching +full:resource +full:- +full:id

1 /* SPDX-License-Identifier: GPL-2.0 */
2 /* Copyright (c) 2016-2018, 2020, The Linux Foundation. All rights reserved. */
14 #include <soc/qcom/cmd-db.h>
24 * @id: resource's identifier
26 * @addr: the address of the resource
31 u8 id[8]; member
39 * struct rsc_hdr: resource header information
41 * @slv_id: id for the resource
82 * based accelerator is a 'slave' (shared resource) and has slave id indicating
89 * Drivers have a stringified key to a slave/resource. They can query the slave
90 * information and get the slave id and the auxiliary data and the length of the
92 * h/w accelerator and request a resource state.
99 const u8 *magic = header->magic; in cmd_db_magic_matches()
108 u16 offset = le16_to_cpu(hdr->header_offset); in rsc_to_entry_header()
110 return cmd_db_header->data + offset; in rsc_to_entry_header()
116 u16 offset = le16_to_cpu(hdr->data_offset); in rsc_offset()
117 u16 loffset = le16_to_cpu(ent->offset); in rsc_offset()
119 return cmd_db_header->data + offset + loffset; in rsc_offset()
123 * cmd_db_ready - Indicates if command DB is available
130 return -EPROBE_DEFER; in cmd_db_ready()
132 return -EINVAL; in cmd_db_ready()
138 static int cmd_db_get_header(const char *id, const struct entry_header **eh, in cmd_db_get_header() argument
144 u8 query[sizeof(ent->id)] __nonstring; in cmd_db_get_header()
155 strncpy(query, id, sizeof(query)); in cmd_db_get_header()
158 rsc_hdr = &cmd_db_header->header[i]; in cmd_db_get_header()
159 if (!rsc_hdr->slv_id) in cmd_db_get_header()
163 for (j = 0; j < le16_to_cpu(rsc_hdr->cnt); j++, ent++) { in cmd_db_get_header()
164 if (memcmp(ent->id, query, sizeof(ent->id)) == 0) { in cmd_db_get_header()
174 return -ENODEV; in cmd_db_get_header()
178 * cmd_db_read_addr() - Query command db for resource id address.
180 * @id: resource id to query for address
182 * Return: resource address on success, 0 on error
184 * This is used to retrieve resource address based on resource
185 * id.
187 u32 cmd_db_read_addr(const char *id) in cmd_db_read_addr() argument
192 ret = cmd_db_get_header(id, &ent, NULL); in cmd_db_read_addr()
194 return ret < 0 ? 0 : le32_to_cpu(ent->addr); in cmd_db_read_addr()
199 * cmd_db_read_aux_data() - Query command db for aux data.
201 * @id: Resource to retrieve AUX Data on
206 const void *cmd_db_read_aux_data(const char *id, size_t *len) in cmd_db_read_aux_data() argument
212 ret = cmd_db_get_header(id, &ent, &rsc_hdr); in cmd_db_read_aux_data()
217 *len = le16_to_cpu(ent->len); in cmd_db_read_aux_data()
224 * cmd_db_read_slave_id - Get the slave ID for a given resource address
226 * @id: Resource id to query the DB for version
230 enum cmd_db_hw_type cmd_db_read_slave_id(const char *id) in cmd_db_read_slave_id() argument
236 ret = cmd_db_get_header(id, &ent, NULL); in cmd_db_read_slave_id()
240 addr = le32_to_cpu(ent->addr); in cmd_db_read_slave_id()
258 rsc = &cmd_db_header->header[i]; in cmd_db_debugfs_dump()
259 if (!rsc->slv_id) in cmd_db_debugfs_dump()
262 switch (le16_to_cpu(rsc->slv_id)) { in cmd_db_debugfs_dump()
277 version = le16_to_cpu(rsc->version); in cmd_db_debugfs_dump()
282 seq_puts(seq, "-------------------------\n"); in cmd_db_debugfs_dump()
285 for (j = 0; j < le16_to_cpu(rsc->cnt); j++, ent++) { in cmd_db_debugfs_dump()
286 seq_printf(seq, "0x%05x: %*pEp", le32_to_cpu(ent->addr), in cmd_db_debugfs_dump()
287 (int)strnlen(ent->id, sizeof(ent->id)), ent->id); in cmd_db_debugfs_dump()
289 len = le16_to_cpu(ent->len); in cmd_db_debugfs_dump()
303 return single_open(file, cmd_db_debugfs_dump, inode->i_private); in open_cmd_db_debugfs()
321 rmem = of_reserved_mem_lookup(pdev->dev.of_node); in cmd_db_dev_probe()
323 dev_err(&pdev->dev, "failed to acquire memory region\n"); in cmd_db_dev_probe()
324 return -EINVAL; in cmd_db_dev_probe()
327 cmd_db_header = memremap(rmem->base, rmem->size, MEMREMAP_WB); in cmd_db_dev_probe()
329 ret = -ENOMEM; in cmd_db_dev_probe()
335 dev_err(&pdev->dev, "Invalid Command DB Magic\n"); in cmd_db_dev_probe()
336 return -EINVAL; in cmd_db_dev_probe()
339 debugfs_create_file("cmd-db", 0400, NULL, NULL, &cmd_db_debugfs_ops); in cmd_db_dev_probe()
341 device_set_pm_not_required(&pdev->dev); in cmd_db_dev_probe()
347 { .compatible = "qcom,cmd-db" },
355 .name = "cmd-db",