18c2ecf20Sopenharmony_ci// SPDX-License-Identifier: GPL-2.0-only 28c2ecf20Sopenharmony_ci/* 38c2ecf20Sopenharmony_ci * tascam-proc.h - a part of driver for TASCAM FireWire series 48c2ecf20Sopenharmony_ci * 58c2ecf20Sopenharmony_ci * Copyright (c) 2015 Takashi Sakamoto 68c2ecf20Sopenharmony_ci */ 78c2ecf20Sopenharmony_ci 88c2ecf20Sopenharmony_ci#include "./tascam.h" 98c2ecf20Sopenharmony_ci 108c2ecf20Sopenharmony_cistatic void proc_read_firmware(struct snd_info_entry *entry, 118c2ecf20Sopenharmony_ci struct snd_info_buffer *buffer) 128c2ecf20Sopenharmony_ci{ 138c2ecf20Sopenharmony_ci struct snd_tscm *tscm = entry->private_data; 148c2ecf20Sopenharmony_ci __be32 data; 158c2ecf20Sopenharmony_ci unsigned int reg, fpga, arm, hw; 168c2ecf20Sopenharmony_ci int err; 178c2ecf20Sopenharmony_ci 188c2ecf20Sopenharmony_ci err = snd_fw_transaction(tscm->unit, TCODE_READ_QUADLET_REQUEST, 198c2ecf20Sopenharmony_ci TSCM_ADDR_BASE + TSCM_OFFSET_FIRMWARE_REGISTER, 208c2ecf20Sopenharmony_ci &data, sizeof(data), 0); 218c2ecf20Sopenharmony_ci if (err < 0) 228c2ecf20Sopenharmony_ci return; 238c2ecf20Sopenharmony_ci reg = be32_to_cpu(data); 248c2ecf20Sopenharmony_ci 258c2ecf20Sopenharmony_ci err = snd_fw_transaction(tscm->unit, TCODE_READ_QUADLET_REQUEST, 268c2ecf20Sopenharmony_ci TSCM_ADDR_BASE + TSCM_OFFSET_FIRMWARE_FPGA, 278c2ecf20Sopenharmony_ci &data, sizeof(data), 0); 288c2ecf20Sopenharmony_ci if (err < 0) 298c2ecf20Sopenharmony_ci return; 308c2ecf20Sopenharmony_ci fpga = be32_to_cpu(data); 318c2ecf20Sopenharmony_ci 328c2ecf20Sopenharmony_ci err = snd_fw_transaction(tscm->unit, TCODE_READ_QUADLET_REQUEST, 338c2ecf20Sopenharmony_ci TSCM_ADDR_BASE + TSCM_OFFSET_FIRMWARE_ARM, 348c2ecf20Sopenharmony_ci &data, sizeof(data), 0); 358c2ecf20Sopenharmony_ci if (err < 0) 368c2ecf20Sopenharmony_ci return; 378c2ecf20Sopenharmony_ci arm = be32_to_cpu(data); 388c2ecf20Sopenharmony_ci 398c2ecf20Sopenharmony_ci err = snd_fw_transaction(tscm->unit, TCODE_READ_QUADLET_REQUEST, 408c2ecf20Sopenharmony_ci TSCM_ADDR_BASE + TSCM_OFFSET_FIRMWARE_HW, 418c2ecf20Sopenharmony_ci &data, sizeof(data), 0); 428c2ecf20Sopenharmony_ci if (err < 0) 438c2ecf20Sopenharmony_ci return; 448c2ecf20Sopenharmony_ci hw = be32_to_cpu(data); 458c2ecf20Sopenharmony_ci 468c2ecf20Sopenharmony_ci snd_iprintf(buffer, "Register: %d (0x%08x)\n", reg & 0xffff, reg); 478c2ecf20Sopenharmony_ci snd_iprintf(buffer, "FPGA: %d (0x%08x)\n", fpga & 0xffff, fpga); 488c2ecf20Sopenharmony_ci snd_iprintf(buffer, "ARM: %d (0x%08x)\n", arm & 0xffff, arm); 498c2ecf20Sopenharmony_ci snd_iprintf(buffer, "Hardware: %d (0x%08x)\n", hw >> 16, hw); 508c2ecf20Sopenharmony_ci} 518c2ecf20Sopenharmony_ci 528c2ecf20Sopenharmony_cistatic void add_node(struct snd_tscm *tscm, struct snd_info_entry *root, 538c2ecf20Sopenharmony_ci const char *name, 548c2ecf20Sopenharmony_ci void (*op)(struct snd_info_entry *e, 558c2ecf20Sopenharmony_ci struct snd_info_buffer *b)) 568c2ecf20Sopenharmony_ci{ 578c2ecf20Sopenharmony_ci struct snd_info_entry *entry; 588c2ecf20Sopenharmony_ci 598c2ecf20Sopenharmony_ci entry = snd_info_create_card_entry(tscm->card, name, root); 608c2ecf20Sopenharmony_ci if (entry) 618c2ecf20Sopenharmony_ci snd_info_set_text_ops(entry, tscm, op); 628c2ecf20Sopenharmony_ci} 638c2ecf20Sopenharmony_ci 648c2ecf20Sopenharmony_civoid snd_tscm_proc_init(struct snd_tscm *tscm) 658c2ecf20Sopenharmony_ci{ 668c2ecf20Sopenharmony_ci struct snd_info_entry *root; 678c2ecf20Sopenharmony_ci 688c2ecf20Sopenharmony_ci /* 698c2ecf20Sopenharmony_ci * All nodes are automatically removed at snd_card_disconnect(), 708c2ecf20Sopenharmony_ci * by following to link list. 718c2ecf20Sopenharmony_ci */ 728c2ecf20Sopenharmony_ci root = snd_info_create_card_entry(tscm->card, "firewire", 738c2ecf20Sopenharmony_ci tscm->card->proc_root); 748c2ecf20Sopenharmony_ci if (root == NULL) 758c2ecf20Sopenharmony_ci return; 768c2ecf20Sopenharmony_ci root->mode = S_IFDIR | 0555; 778c2ecf20Sopenharmony_ci 788c2ecf20Sopenharmony_ci add_node(tscm, root, "firmware", proc_read_firmware); 798c2ecf20Sopenharmony_ci} 80