18c2ecf20Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0-only */ 28c2ecf20Sopenharmony_ci/* 38c2ecf20Sopenharmony_ci * Copyright(c) 2020 Intel Corporation. All rights reserved. 48c2ecf20Sopenharmony_ci * 58c2ecf20Sopenharmony_ci * Author: Cezary Rojewski <cezary.rojewski@intel.com> 68c2ecf20Sopenharmony_ci */ 78c2ecf20Sopenharmony_ci 88c2ecf20Sopenharmony_ci#ifndef __SND_SOC_INTEL_CATPT_REGS_H 98c2ecf20Sopenharmony_ci#define __SND_SOC_INTEL_CATPT_REGS_H 108c2ecf20Sopenharmony_ci 118c2ecf20Sopenharmony_ci#include <linux/bitops.h> 128c2ecf20Sopenharmony_ci#include <linux/iopoll.h> 138c2ecf20Sopenharmony_ci#include <uapi/linux/pci_regs.h> 148c2ecf20Sopenharmony_ci 158c2ecf20Sopenharmony_ci#define CATPT_SHIM_REGS_SIZE 4096 168c2ecf20Sopenharmony_ci#define CATPT_DMA_REGS_SIZE 1024 178c2ecf20Sopenharmony_ci#define CATPT_DMA_COUNT 2 188c2ecf20Sopenharmony_ci#define CATPT_SSP_REGS_SIZE 512 198c2ecf20Sopenharmony_ci 208c2ecf20Sopenharmony_ci/* DSP Shim registers */ 218c2ecf20Sopenharmony_ci 228c2ecf20Sopenharmony_ci#define CATPT_SHIM_CS1 0x00 238c2ecf20Sopenharmony_ci#define CATPT_SHIM_ISC 0x18 248c2ecf20Sopenharmony_ci#define CATPT_SHIM_ISD 0x20 258c2ecf20Sopenharmony_ci#define CATPT_SHIM_IMC 0x28 268c2ecf20Sopenharmony_ci#define CATPT_SHIM_IMD 0x30 278c2ecf20Sopenharmony_ci#define CATPT_SHIM_IPCC 0x38 288c2ecf20Sopenharmony_ci#define CATPT_SHIM_IPCD 0x40 298c2ecf20Sopenharmony_ci#define CATPT_SHIM_CLKCTL 0x78 308c2ecf20Sopenharmony_ci#define CATPT_SHIM_CS2 0x80 318c2ecf20Sopenharmony_ci#define CATPT_SHIM_LTRC 0xE0 328c2ecf20Sopenharmony_ci#define CATPT_SHIM_HMDC 0xE8 338c2ecf20Sopenharmony_ci 348c2ecf20Sopenharmony_ci#define CATPT_CS_LPCS BIT(31) 358c2ecf20Sopenharmony_ci#define CATPT_CS_SFCR(ssp) BIT(27 + (ssp)) 368c2ecf20Sopenharmony_ci#define CATPT_CS_S1IOCS BIT(23) 378c2ecf20Sopenharmony_ci#define CATPT_CS_S0IOCS BIT(21) 388c2ecf20Sopenharmony_ci#define CATPT_CS_PCE BIT(15) 398c2ecf20Sopenharmony_ci#define CATPT_CS_SDPM(ssp) BIT(11 + (ssp)) 408c2ecf20Sopenharmony_ci#define CATPT_CS_STALL BIT(10) 418c2ecf20Sopenharmony_ci#define CATPT_CS_DCS GENMASK(6, 4) 428c2ecf20Sopenharmony_ci/* b100 DSP core & audio fabric high clock */ 438c2ecf20Sopenharmony_ci#define CATPT_CS_DCS_HIGH (0x4 << 4) 448c2ecf20Sopenharmony_ci#define CATPT_CS_SBCS(ssp) BIT(2 + (ssp)) 458c2ecf20Sopenharmony_ci#define CATPT_CS_RST BIT(1) 468c2ecf20Sopenharmony_ci 478c2ecf20Sopenharmony_ci#define CATPT_ISC_IPCDB BIT(1) 488c2ecf20Sopenharmony_ci#define CATPT_ISC_IPCCD BIT(0) 498c2ecf20Sopenharmony_ci#define CATPT_ISD_DCPWM BIT(31) 508c2ecf20Sopenharmony_ci#define CATPT_ISD_IPCCB BIT(1) 518c2ecf20Sopenharmony_ci#define CATPT_ISD_IPCDD BIT(0) 528c2ecf20Sopenharmony_ci 538c2ecf20Sopenharmony_ci#define CATPT_IMC_IPCDB BIT(1) 548c2ecf20Sopenharmony_ci#define CATPT_IMC_IPCCD BIT(0) 558c2ecf20Sopenharmony_ci#define CATPT_IMD_IPCCB BIT(1) 568c2ecf20Sopenharmony_ci#define CATPT_IMD_IPCDD BIT(0) 578c2ecf20Sopenharmony_ci 588c2ecf20Sopenharmony_ci#define CATPT_IPCC_BUSY BIT(31) 598c2ecf20Sopenharmony_ci#define CATPT_IPCC_DONE BIT(30) 608c2ecf20Sopenharmony_ci#define CATPT_IPCD_BUSY BIT(31) 618c2ecf20Sopenharmony_ci#define CATPT_IPCD_DONE BIT(30) 628c2ecf20Sopenharmony_ci 638c2ecf20Sopenharmony_ci#define CATPT_CLKCTL_CFCIP BIT(31) 648c2ecf20Sopenharmony_ci#define CATPT_CLKCTL_SMOS GENMASK(25, 24) 658c2ecf20Sopenharmony_ci 668c2ecf20Sopenharmony_ci#define CATPT_HMDC_HDDA(e, ch) BIT(8 * (e) + (ch)) 678c2ecf20Sopenharmony_ci 688c2ecf20Sopenharmony_ci/* defaults to reset SHIM registers to after each power cycle */ 698c2ecf20Sopenharmony_ci#define CATPT_CS_DEFAULT 0x8480040E 708c2ecf20Sopenharmony_ci#define CATPT_ISC_DEFAULT 0x0 718c2ecf20Sopenharmony_ci#define CATPT_ISD_DEFAULT 0x0 728c2ecf20Sopenharmony_ci#define CATPT_IMC_DEFAULT 0x7FFF0003 738c2ecf20Sopenharmony_ci#define CATPT_IMD_DEFAULT 0x7FFF0003 748c2ecf20Sopenharmony_ci#define CATPT_IPCC_DEFAULT 0x0 758c2ecf20Sopenharmony_ci#define CATPT_IPCD_DEFAULT 0x0 768c2ecf20Sopenharmony_ci#define CATPT_CLKCTL_DEFAULT 0x7FF 778c2ecf20Sopenharmony_ci#define CATPT_CS2_DEFAULT 0x0 788c2ecf20Sopenharmony_ci#define CATPT_LTRC_DEFAULT 0x0 798c2ecf20Sopenharmony_ci#define CATPT_HMDC_DEFAULT 0x0 808c2ecf20Sopenharmony_ci 818c2ecf20Sopenharmony_ci/* PCI Configuration registers */ 828c2ecf20Sopenharmony_ci 838c2ecf20Sopenharmony_ci#define CATPT_PCI_PMCAPID 0x80 848c2ecf20Sopenharmony_ci#define CATPT_PCI_PMCS (CATPT_PCI_PMCAPID + PCI_PM_CTRL) 858c2ecf20Sopenharmony_ci#define CATPT_PCI_VDRTCTL0 0xA0 868c2ecf20Sopenharmony_ci#define CATPT_PCI_VDRTCTL2 0xA8 878c2ecf20Sopenharmony_ci 888c2ecf20Sopenharmony_ci#define CATPT_VDRTCTL2_DTCGE BIT(10) 898c2ecf20Sopenharmony_ci#define CATPT_VDRTCTL2_DCLCGE BIT(1) 908c2ecf20Sopenharmony_ci#define CATPT_VDRTCTL2_CGEALL 0xF7F 918c2ecf20Sopenharmony_ci 928c2ecf20Sopenharmony_ci/* LPT PCI Configuration bits */ 938c2ecf20Sopenharmony_ci 948c2ecf20Sopenharmony_ci#define LPT_VDRTCTL0_DSRAMPGE(b) BIT(16 + (b)) 958c2ecf20Sopenharmony_ci#define LPT_VDRTCTL0_DSRAMPGE_MASK GENMASK(31, 16) 968c2ecf20Sopenharmony_ci#define LPT_VDRTCTL0_ISRAMPGE(b) BIT(6 + (b)) 978c2ecf20Sopenharmony_ci#define LPT_VDRTCTL0_ISRAMPGE_MASK GENMASK(15, 6) 988c2ecf20Sopenharmony_ci#define LPT_VDRTCTL0_D3SRAMPGD BIT(2) 998c2ecf20Sopenharmony_ci#define LPT_VDRTCTL0_D3PGD BIT(1) 1008c2ecf20Sopenharmony_ci#define LPT_VDRTCTL0_APLLSE BIT(0) 1018c2ecf20Sopenharmony_ci 1028c2ecf20Sopenharmony_ci/* WPT PCI Configuration bits */ 1038c2ecf20Sopenharmony_ci 1048c2ecf20Sopenharmony_ci#define WPT_VDRTCTL0_DSRAMPGE(b) BIT(12 + (b)) 1058c2ecf20Sopenharmony_ci#define WPT_VDRTCTL0_DSRAMPGE_MASK GENMASK(31, 12) 1068c2ecf20Sopenharmony_ci#define WPT_VDRTCTL0_ISRAMPGE(b) BIT(2 + (b)) 1078c2ecf20Sopenharmony_ci#define WPT_VDRTCTL0_ISRAMPGE_MASK GENMASK(11, 2) 1088c2ecf20Sopenharmony_ci#define WPT_VDRTCTL0_D3SRAMPGD BIT(1) 1098c2ecf20Sopenharmony_ci#define WPT_VDRTCTL0_D3PGD BIT(0) 1108c2ecf20Sopenharmony_ci 1118c2ecf20Sopenharmony_ci#define WPT_VDRTCTL2_APLLSE BIT(31) 1128c2ecf20Sopenharmony_ci 1138c2ecf20Sopenharmony_ci/* defaults to reset SSP registers to after each power cycle */ 1148c2ecf20Sopenharmony_ci#define CATPT_SSC0_DEFAULT 0x0 1158c2ecf20Sopenharmony_ci#define CATPT_SSC1_DEFAULT 0x0 1168c2ecf20Sopenharmony_ci#define CATPT_SSS_DEFAULT 0xF004 1178c2ecf20Sopenharmony_ci#define CATPT_SSIT_DEFAULT 0x0 1188c2ecf20Sopenharmony_ci#define CATPT_SSD_DEFAULT 0xC43893A3 1198c2ecf20Sopenharmony_ci#define CATPT_SSTO_DEFAULT 0x0 1208c2ecf20Sopenharmony_ci#define CATPT_SSPSP_DEFAULT 0x0 1218c2ecf20Sopenharmony_ci#define CATPT_SSTSA_DEFAULT 0x0 1228c2ecf20Sopenharmony_ci#define CATPT_SSRSA_DEFAULT 0x0 1238c2ecf20Sopenharmony_ci#define CATPT_SSTSS_DEFAULT 0x0 1248c2ecf20Sopenharmony_ci#define CATPT_SSCR2_DEFAULT 0x0 1258c2ecf20Sopenharmony_ci#define CATPT_SSPSP2_DEFAULT 0x0 1268c2ecf20Sopenharmony_ci 1278c2ecf20Sopenharmony_ci/* Physically the same block, access address differs between host and dsp */ 1288c2ecf20Sopenharmony_ci#define CATPT_DSP_DRAM_OFFSET 0x400000 1298c2ecf20Sopenharmony_ci#define catpt_to_host_offset(offset) ((offset) & ~(CATPT_DSP_DRAM_OFFSET)) 1308c2ecf20Sopenharmony_ci#define catpt_to_dsp_offset(offset) ((offset) | CATPT_DSP_DRAM_OFFSET) 1318c2ecf20Sopenharmony_ci 1328c2ecf20Sopenharmony_ci#define CATPT_MEMBLOCK_SIZE 0x8000 1338c2ecf20Sopenharmony_ci#define catpt_num_dram(cdev) (hweight_long((cdev)->spec->dram_mask)) 1348c2ecf20Sopenharmony_ci#define catpt_num_iram(cdev) (hweight_long((cdev)->spec->iram_mask)) 1358c2ecf20Sopenharmony_ci#define catpt_dram_size(cdev) (catpt_num_dram(cdev) * CATPT_MEMBLOCK_SIZE) 1368c2ecf20Sopenharmony_ci#define catpt_iram_size(cdev) (catpt_num_iram(cdev) * CATPT_MEMBLOCK_SIZE) 1378c2ecf20Sopenharmony_ci 1388c2ecf20Sopenharmony_ci/* registry I/O helpers */ 1398c2ecf20Sopenharmony_ci 1408c2ecf20Sopenharmony_ci#define catpt_shim_addr(cdev) \ 1418c2ecf20Sopenharmony_ci ((cdev)->lpe_ba + (cdev)->spec->host_shim_offset) 1428c2ecf20Sopenharmony_ci#define catpt_dma_addr(cdev, dma) \ 1438c2ecf20Sopenharmony_ci ((cdev)->lpe_ba + (cdev)->spec->host_dma_offset[dma]) 1448c2ecf20Sopenharmony_ci#define catpt_ssp_addr(cdev, ssp) \ 1458c2ecf20Sopenharmony_ci ((cdev)->lpe_ba + (cdev)->spec->host_ssp_offset[ssp]) 1468c2ecf20Sopenharmony_ci#define catpt_inbox_addr(cdev) \ 1478c2ecf20Sopenharmony_ci ((cdev)->lpe_ba + (cdev)->ipc.config.inbox_offset) 1488c2ecf20Sopenharmony_ci#define catpt_outbox_addr(cdev) \ 1498c2ecf20Sopenharmony_ci ((cdev)->lpe_ba + (cdev)->ipc.config.outbox_offset) 1508c2ecf20Sopenharmony_ci 1518c2ecf20Sopenharmony_ci#define catpt_writel_ssp(cdev, ssp, reg, val) \ 1528c2ecf20Sopenharmony_ci writel(val, catpt_ssp_addr(cdev, ssp) + (reg)) 1538c2ecf20Sopenharmony_ci 1548c2ecf20Sopenharmony_ci#define catpt_readl_shim(cdev, reg) \ 1558c2ecf20Sopenharmony_ci readl(catpt_shim_addr(cdev) + CATPT_SHIM_##reg) 1568c2ecf20Sopenharmony_ci#define catpt_writel_shim(cdev, reg, val) \ 1578c2ecf20Sopenharmony_ci writel(val, catpt_shim_addr(cdev) + CATPT_SHIM_##reg) 1588c2ecf20Sopenharmony_ci#define catpt_updatel_shim(cdev, reg, mask, val) \ 1598c2ecf20Sopenharmony_ci catpt_writel_shim(cdev, reg, \ 1608c2ecf20Sopenharmony_ci (catpt_readl_shim(cdev, reg) & ~(mask)) | (val)) 1618c2ecf20Sopenharmony_ci 1628c2ecf20Sopenharmony_ci#define catpt_readl_poll_shim(cdev, reg, val, cond, delay_us, timeout_us) \ 1638c2ecf20Sopenharmony_ci readl_poll_timeout(catpt_shim_addr(cdev) + CATPT_SHIM_##reg, \ 1648c2ecf20Sopenharmony_ci val, cond, delay_us, timeout_us) 1658c2ecf20Sopenharmony_ci 1668c2ecf20Sopenharmony_ci#define catpt_readl_pci(cdev, reg) \ 1678c2ecf20Sopenharmony_ci readl(cdev->pci_ba + CATPT_PCI_##reg) 1688c2ecf20Sopenharmony_ci#define catpt_writel_pci(cdev, reg, val) \ 1698c2ecf20Sopenharmony_ci writel(val, cdev->pci_ba + CATPT_PCI_##reg) 1708c2ecf20Sopenharmony_ci#define catpt_updatel_pci(cdev, reg, mask, val) \ 1718c2ecf20Sopenharmony_ci catpt_writel_pci(cdev, reg, \ 1728c2ecf20Sopenharmony_ci (catpt_readl_pci(cdev, reg) & ~(mask)) | (val)) 1738c2ecf20Sopenharmony_ci 1748c2ecf20Sopenharmony_ci#define catpt_readl_poll_pci(cdev, reg, val, cond, delay_us, timeout_us) \ 1758c2ecf20Sopenharmony_ci readl_poll_timeout((cdev)->pci_ba + CATPT_PCI_##reg, \ 1768c2ecf20Sopenharmony_ci val, cond, delay_us, timeout_us) 1778c2ecf20Sopenharmony_ci 1788c2ecf20Sopenharmony_ci#endif 179