18c2ecf20Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0 */ 28c2ecf20Sopenharmony_ci/* 38c2ecf20Sopenharmony_ci * This file is part of STM32 DFSDM driver 48c2ecf20Sopenharmony_ci * 58c2ecf20Sopenharmony_ci * Copyright (C) 2017, STMicroelectronics - All Rights Reserved 68c2ecf20Sopenharmony_ci * Author(s): Arnaud Pouliquen <arnaud.pouliquen@st.com>. 78c2ecf20Sopenharmony_ci */ 88c2ecf20Sopenharmony_ci 98c2ecf20Sopenharmony_ci#ifndef MDF_STM32_DFSDM__H 108c2ecf20Sopenharmony_ci#define MDF_STM32_DFSDM__H 118c2ecf20Sopenharmony_ci 128c2ecf20Sopenharmony_ci#include <linux/bitfield.h> 138c2ecf20Sopenharmony_ci 148c2ecf20Sopenharmony_ci/* 158c2ecf20Sopenharmony_ci * STM32 DFSDM - global register map 168c2ecf20Sopenharmony_ci * ________________________________________________________ 178c2ecf20Sopenharmony_ci * | Offset | Registers block | 188c2ecf20Sopenharmony_ci * -------------------------------------------------------- 198c2ecf20Sopenharmony_ci * | 0x000 | CHANNEL 0 + COMMON CHANNEL FIELDS | 208c2ecf20Sopenharmony_ci * -------------------------------------------------------- 218c2ecf20Sopenharmony_ci * | 0x020 | CHANNEL 1 | 228c2ecf20Sopenharmony_ci * -------------------------------------------------------- 238c2ecf20Sopenharmony_ci * | ... | ..... | 248c2ecf20Sopenharmony_ci * -------------------------------------------------------- 258c2ecf20Sopenharmony_ci * | 0x0E0 | CHANNEL 7 | 268c2ecf20Sopenharmony_ci * -------------------------------------------------------- 278c2ecf20Sopenharmony_ci * | 0x100 | FILTER 0 + COMMON FILTER FIELDs | 288c2ecf20Sopenharmony_ci * -------------------------------------------------------- 298c2ecf20Sopenharmony_ci * | 0x200 | FILTER 1 | 308c2ecf20Sopenharmony_ci * -------------------------------------------------------- 318c2ecf20Sopenharmony_ci * | 0x300 | FILTER 2 | 328c2ecf20Sopenharmony_ci * -------------------------------------------------------- 338c2ecf20Sopenharmony_ci * | 0x400 | FILTER 3 | 348c2ecf20Sopenharmony_ci * -------------------------------------------------------- 358c2ecf20Sopenharmony_ci */ 368c2ecf20Sopenharmony_ci 378c2ecf20Sopenharmony_ci/* 388c2ecf20Sopenharmony_ci * Channels register definitions 398c2ecf20Sopenharmony_ci */ 408c2ecf20Sopenharmony_ci#define DFSDM_CHCFGR1(y) ((y) * 0x20 + 0x00) 418c2ecf20Sopenharmony_ci#define DFSDM_CHCFGR2(y) ((y) * 0x20 + 0x04) 428c2ecf20Sopenharmony_ci#define DFSDM_AWSCDR(y) ((y) * 0x20 + 0x08) 438c2ecf20Sopenharmony_ci#define DFSDM_CHWDATR(y) ((y) * 0x20 + 0x0C) 448c2ecf20Sopenharmony_ci#define DFSDM_CHDATINR(y) ((y) * 0x20 + 0x10) 458c2ecf20Sopenharmony_ci 468c2ecf20Sopenharmony_ci/* CHCFGR1: Channel configuration register 1 */ 478c2ecf20Sopenharmony_ci#define DFSDM_CHCFGR1_SITP_MASK GENMASK(1, 0) 488c2ecf20Sopenharmony_ci#define DFSDM_CHCFGR1_SITP(v) FIELD_PREP(DFSDM_CHCFGR1_SITP_MASK, v) 498c2ecf20Sopenharmony_ci#define DFSDM_CHCFGR1_SPICKSEL_MASK GENMASK(3, 2) 508c2ecf20Sopenharmony_ci#define DFSDM_CHCFGR1_SPICKSEL(v) FIELD_PREP(DFSDM_CHCFGR1_SPICKSEL_MASK, v) 518c2ecf20Sopenharmony_ci#define DFSDM_CHCFGR1_SCDEN_MASK BIT(5) 528c2ecf20Sopenharmony_ci#define DFSDM_CHCFGR1_SCDEN(v) FIELD_PREP(DFSDM_CHCFGR1_SCDEN_MASK, v) 538c2ecf20Sopenharmony_ci#define DFSDM_CHCFGR1_CKABEN_MASK BIT(6) 548c2ecf20Sopenharmony_ci#define DFSDM_CHCFGR1_CKABEN(v) FIELD_PREP(DFSDM_CHCFGR1_CKABEN_MASK, v) 558c2ecf20Sopenharmony_ci#define DFSDM_CHCFGR1_CHEN_MASK BIT(7) 568c2ecf20Sopenharmony_ci#define DFSDM_CHCFGR1_CHEN(v) FIELD_PREP(DFSDM_CHCFGR1_CHEN_MASK, v) 578c2ecf20Sopenharmony_ci#define DFSDM_CHCFGR1_CHINSEL_MASK BIT(8) 588c2ecf20Sopenharmony_ci#define DFSDM_CHCFGR1_CHINSEL(v) FIELD_PREP(DFSDM_CHCFGR1_CHINSEL_MASK, v) 598c2ecf20Sopenharmony_ci#define DFSDM_CHCFGR1_DATMPX_MASK GENMASK(13, 12) 608c2ecf20Sopenharmony_ci#define DFSDM_CHCFGR1_DATMPX(v) FIELD_PREP(DFSDM_CHCFGR1_DATMPX_MASK, v) 618c2ecf20Sopenharmony_ci#define DFSDM_CHCFGR1_DATPACK_MASK GENMASK(15, 14) 628c2ecf20Sopenharmony_ci#define DFSDM_CHCFGR1_DATPACK(v) FIELD_PREP(DFSDM_CHCFGR1_DATPACK_MASK, v) 638c2ecf20Sopenharmony_ci#define DFSDM_CHCFGR1_CKOUTDIV_MASK GENMASK(23, 16) 648c2ecf20Sopenharmony_ci#define DFSDM_CHCFGR1_CKOUTDIV(v) FIELD_PREP(DFSDM_CHCFGR1_CKOUTDIV_MASK, v) 658c2ecf20Sopenharmony_ci#define DFSDM_CHCFGR1_CKOUTSRC_MASK BIT(30) 668c2ecf20Sopenharmony_ci#define DFSDM_CHCFGR1_CKOUTSRC(v) FIELD_PREP(DFSDM_CHCFGR1_CKOUTSRC_MASK, v) 678c2ecf20Sopenharmony_ci#define DFSDM_CHCFGR1_DFSDMEN_MASK BIT(31) 688c2ecf20Sopenharmony_ci#define DFSDM_CHCFGR1_DFSDMEN(v) FIELD_PREP(DFSDM_CHCFGR1_DFSDMEN_MASK, v) 698c2ecf20Sopenharmony_ci 708c2ecf20Sopenharmony_ci/* CHCFGR2: Channel configuration register 2 */ 718c2ecf20Sopenharmony_ci#define DFSDM_CHCFGR2_DTRBS_MASK GENMASK(7, 3) 728c2ecf20Sopenharmony_ci#define DFSDM_CHCFGR2_DTRBS(v) FIELD_PREP(DFSDM_CHCFGR2_DTRBS_MASK, v) 738c2ecf20Sopenharmony_ci#define DFSDM_CHCFGR2_OFFSET_MASK GENMASK(31, 8) 748c2ecf20Sopenharmony_ci#define DFSDM_CHCFGR2_OFFSET(v) FIELD_PREP(DFSDM_CHCFGR2_OFFSET_MASK, v) 758c2ecf20Sopenharmony_ci 768c2ecf20Sopenharmony_ci/* AWSCDR: Channel analog watchdog and short circuit detector */ 778c2ecf20Sopenharmony_ci#define DFSDM_AWSCDR_SCDT_MASK GENMASK(7, 0) 788c2ecf20Sopenharmony_ci#define DFSDM_AWSCDR_SCDT(v) FIELD_PREP(DFSDM_AWSCDR_SCDT_MASK, v) 798c2ecf20Sopenharmony_ci#define DFSDM_AWSCDR_BKSCD_MASK GENMASK(15, 12) 808c2ecf20Sopenharmony_ci#define DFSDM_AWSCDR_BKSCD(v) FIELD_PREP(DFSDM_AWSCDR_BKSCD_MASK, v) 818c2ecf20Sopenharmony_ci#define DFSDM_AWSCDR_AWFOSR_MASK GENMASK(20, 16) 828c2ecf20Sopenharmony_ci#define DFSDM_AWSCDR_AWFOSR(v) FIELD_PREP(DFSDM_AWSCDR_AWFOSR_MASK, v) 838c2ecf20Sopenharmony_ci#define DFSDM_AWSCDR_AWFORD_MASK GENMASK(23, 22) 848c2ecf20Sopenharmony_ci#define DFSDM_AWSCDR_AWFORD(v) FIELD_PREP(DFSDM_AWSCDR_AWFORD_MASK, v) 858c2ecf20Sopenharmony_ci 868c2ecf20Sopenharmony_ci/* 878c2ecf20Sopenharmony_ci * Filters register definitions 888c2ecf20Sopenharmony_ci */ 898c2ecf20Sopenharmony_ci#define DFSDM_FILTER_BASE_ADR 0x100 908c2ecf20Sopenharmony_ci#define DFSDM_FILTER_REG_MASK 0x7F 918c2ecf20Sopenharmony_ci#define DFSDM_FILTER_X_BASE_ADR(x) ((x) * 0x80 + DFSDM_FILTER_BASE_ADR) 928c2ecf20Sopenharmony_ci 938c2ecf20Sopenharmony_ci#define DFSDM_CR1(x) (DFSDM_FILTER_X_BASE_ADR(x) + 0x00) 948c2ecf20Sopenharmony_ci#define DFSDM_CR2(x) (DFSDM_FILTER_X_BASE_ADR(x) + 0x04) 958c2ecf20Sopenharmony_ci#define DFSDM_ISR(x) (DFSDM_FILTER_X_BASE_ADR(x) + 0x08) 968c2ecf20Sopenharmony_ci#define DFSDM_ICR(x) (DFSDM_FILTER_X_BASE_ADR(x) + 0x0C) 978c2ecf20Sopenharmony_ci#define DFSDM_JCHGR(x) (DFSDM_FILTER_X_BASE_ADR(x) + 0x10) 988c2ecf20Sopenharmony_ci#define DFSDM_FCR(x) (DFSDM_FILTER_X_BASE_ADR(x) + 0x14) 998c2ecf20Sopenharmony_ci#define DFSDM_JDATAR(x) (DFSDM_FILTER_X_BASE_ADR(x) + 0x18) 1008c2ecf20Sopenharmony_ci#define DFSDM_RDATAR(x) (DFSDM_FILTER_X_BASE_ADR(x) + 0x1C) 1018c2ecf20Sopenharmony_ci#define DFSDM_AWHTR(x) (DFSDM_FILTER_X_BASE_ADR(x) + 0x20) 1028c2ecf20Sopenharmony_ci#define DFSDM_AWLTR(x) (DFSDM_FILTER_X_BASE_ADR(x) + 0x24) 1038c2ecf20Sopenharmony_ci#define DFSDM_AWSR(x) (DFSDM_FILTER_X_BASE_ADR(x) + 0x28) 1048c2ecf20Sopenharmony_ci#define DFSDM_AWCFR(x) (DFSDM_FILTER_X_BASE_ADR(x) + 0x2C) 1058c2ecf20Sopenharmony_ci#define DFSDM_EXMAX(x) (DFSDM_FILTER_X_BASE_ADR(x) + 0x30) 1068c2ecf20Sopenharmony_ci#define DFSDM_EXMIN(x) (DFSDM_FILTER_X_BASE_ADR(x) + 0x34) 1078c2ecf20Sopenharmony_ci#define DFSDM_CNVTIMR(x) (DFSDM_FILTER_X_BASE_ADR(x) + 0x38) 1088c2ecf20Sopenharmony_ci 1098c2ecf20Sopenharmony_ci/* CR1 Control register 1 */ 1108c2ecf20Sopenharmony_ci#define DFSDM_CR1_DFEN_MASK BIT(0) 1118c2ecf20Sopenharmony_ci#define DFSDM_CR1_DFEN(v) FIELD_PREP(DFSDM_CR1_DFEN_MASK, v) 1128c2ecf20Sopenharmony_ci#define DFSDM_CR1_JSWSTART_MASK BIT(1) 1138c2ecf20Sopenharmony_ci#define DFSDM_CR1_JSWSTART(v) FIELD_PREP(DFSDM_CR1_JSWSTART_MASK, v) 1148c2ecf20Sopenharmony_ci#define DFSDM_CR1_JSYNC_MASK BIT(3) 1158c2ecf20Sopenharmony_ci#define DFSDM_CR1_JSYNC(v) FIELD_PREP(DFSDM_CR1_JSYNC_MASK, v) 1168c2ecf20Sopenharmony_ci#define DFSDM_CR1_JSCAN_MASK BIT(4) 1178c2ecf20Sopenharmony_ci#define DFSDM_CR1_JSCAN(v) FIELD_PREP(DFSDM_CR1_JSCAN_MASK, v) 1188c2ecf20Sopenharmony_ci#define DFSDM_CR1_JDMAEN_MASK BIT(5) 1198c2ecf20Sopenharmony_ci#define DFSDM_CR1_JDMAEN(v) FIELD_PREP(DFSDM_CR1_JDMAEN_MASK, v) 1208c2ecf20Sopenharmony_ci#define DFSDM_CR1_JEXTSEL_MASK GENMASK(12, 8) 1218c2ecf20Sopenharmony_ci#define DFSDM_CR1_JEXTSEL(v) FIELD_PREP(DFSDM_CR1_JEXTSEL_MASK, v) 1228c2ecf20Sopenharmony_ci#define DFSDM_CR1_JEXTEN_MASK GENMASK(14, 13) 1238c2ecf20Sopenharmony_ci#define DFSDM_CR1_JEXTEN(v) FIELD_PREP(DFSDM_CR1_JEXTEN_MASK, v) 1248c2ecf20Sopenharmony_ci#define DFSDM_CR1_RSWSTART_MASK BIT(17) 1258c2ecf20Sopenharmony_ci#define DFSDM_CR1_RSWSTART(v) FIELD_PREP(DFSDM_CR1_RSWSTART_MASK, v) 1268c2ecf20Sopenharmony_ci#define DFSDM_CR1_RCONT_MASK BIT(18) 1278c2ecf20Sopenharmony_ci#define DFSDM_CR1_RCONT(v) FIELD_PREP(DFSDM_CR1_RCONT_MASK, v) 1288c2ecf20Sopenharmony_ci#define DFSDM_CR1_RSYNC_MASK BIT(19) 1298c2ecf20Sopenharmony_ci#define DFSDM_CR1_RSYNC(v) FIELD_PREP(DFSDM_CR1_RSYNC_MASK, v) 1308c2ecf20Sopenharmony_ci#define DFSDM_CR1_RDMAEN_MASK BIT(21) 1318c2ecf20Sopenharmony_ci#define DFSDM_CR1_RDMAEN(v) FIELD_PREP(DFSDM_CR1_RDMAEN_MASK, v) 1328c2ecf20Sopenharmony_ci#define DFSDM_CR1_RCH_MASK GENMASK(26, 24) 1338c2ecf20Sopenharmony_ci#define DFSDM_CR1_RCH(v) FIELD_PREP(DFSDM_CR1_RCH_MASK, v) 1348c2ecf20Sopenharmony_ci#define DFSDM_CR1_FAST_MASK BIT(29) 1358c2ecf20Sopenharmony_ci#define DFSDM_CR1_FAST(v) FIELD_PREP(DFSDM_CR1_FAST_MASK, v) 1368c2ecf20Sopenharmony_ci#define DFSDM_CR1_AWFSEL_MASK BIT(30) 1378c2ecf20Sopenharmony_ci#define DFSDM_CR1_AWFSEL(v) FIELD_PREP(DFSDM_CR1_AWFSEL_MASK, v) 1388c2ecf20Sopenharmony_ci 1398c2ecf20Sopenharmony_ci/* CR2: Control register 2 */ 1408c2ecf20Sopenharmony_ci#define DFSDM_CR2_IE_MASK GENMASK(6, 0) 1418c2ecf20Sopenharmony_ci#define DFSDM_CR2_IE(v) FIELD_PREP(DFSDM_CR2_IE_MASK, v) 1428c2ecf20Sopenharmony_ci#define DFSDM_CR2_JEOCIE_MASK BIT(0) 1438c2ecf20Sopenharmony_ci#define DFSDM_CR2_JEOCIE(v) FIELD_PREP(DFSDM_CR2_JEOCIE_MASK, v) 1448c2ecf20Sopenharmony_ci#define DFSDM_CR2_REOCIE_MASK BIT(1) 1458c2ecf20Sopenharmony_ci#define DFSDM_CR2_REOCIE(v) FIELD_PREP(DFSDM_CR2_REOCIE_MASK, v) 1468c2ecf20Sopenharmony_ci#define DFSDM_CR2_JOVRIE_MASK BIT(2) 1478c2ecf20Sopenharmony_ci#define DFSDM_CR2_JOVRIE(v) FIELD_PREP(DFSDM_CR2_JOVRIE_MASK, v) 1488c2ecf20Sopenharmony_ci#define DFSDM_CR2_ROVRIE_MASK BIT(3) 1498c2ecf20Sopenharmony_ci#define DFSDM_CR2_ROVRIE(v) FIELD_PREP(DFSDM_CR2_ROVRIE_MASK, v) 1508c2ecf20Sopenharmony_ci#define DFSDM_CR2_AWDIE_MASK BIT(4) 1518c2ecf20Sopenharmony_ci#define DFSDM_CR2_AWDIE(v) FIELD_PREP(DFSDM_CR2_AWDIE_MASK, v) 1528c2ecf20Sopenharmony_ci#define DFSDM_CR2_SCDIE_MASK BIT(5) 1538c2ecf20Sopenharmony_ci#define DFSDM_CR2_SCDIE(v) FIELD_PREP(DFSDM_CR2_SCDIE_MASK, v) 1548c2ecf20Sopenharmony_ci#define DFSDM_CR2_CKABIE_MASK BIT(6) 1558c2ecf20Sopenharmony_ci#define DFSDM_CR2_CKABIE(v) FIELD_PREP(DFSDM_CR2_CKABIE_MASK, v) 1568c2ecf20Sopenharmony_ci#define DFSDM_CR2_EXCH_MASK GENMASK(15, 8) 1578c2ecf20Sopenharmony_ci#define DFSDM_CR2_EXCH(v) FIELD_PREP(DFSDM_CR2_EXCH_MASK, v) 1588c2ecf20Sopenharmony_ci#define DFSDM_CR2_AWDCH_MASK GENMASK(23, 16) 1598c2ecf20Sopenharmony_ci#define DFSDM_CR2_AWDCH(v) FIELD_PREP(DFSDM_CR2_AWDCH_MASK, v) 1608c2ecf20Sopenharmony_ci 1618c2ecf20Sopenharmony_ci/* ISR: Interrupt status register */ 1628c2ecf20Sopenharmony_ci#define DFSDM_ISR_JEOCF_MASK BIT(0) 1638c2ecf20Sopenharmony_ci#define DFSDM_ISR_JEOCF(v) FIELD_PREP(DFSDM_ISR_JEOCF_MASK, v) 1648c2ecf20Sopenharmony_ci#define DFSDM_ISR_REOCF_MASK BIT(1) 1658c2ecf20Sopenharmony_ci#define DFSDM_ISR_REOCF(v) FIELD_PREP(DFSDM_ISR_REOCF_MASK, v) 1668c2ecf20Sopenharmony_ci#define DFSDM_ISR_JOVRF_MASK BIT(2) 1678c2ecf20Sopenharmony_ci#define DFSDM_ISR_JOVRF(v) FIELD_PREP(DFSDM_ISR_JOVRF_MASK, v) 1688c2ecf20Sopenharmony_ci#define DFSDM_ISR_ROVRF_MASK BIT(3) 1698c2ecf20Sopenharmony_ci#define DFSDM_ISR_ROVRF(v) FIELD_PREP(DFSDM_ISR_ROVRF_MASK, v) 1708c2ecf20Sopenharmony_ci#define DFSDM_ISR_AWDF_MASK BIT(4) 1718c2ecf20Sopenharmony_ci#define DFSDM_ISR_AWDF(v) FIELD_PREP(DFSDM_ISR_AWDF_MASK, v) 1728c2ecf20Sopenharmony_ci#define DFSDM_ISR_JCIP_MASK BIT(13) 1738c2ecf20Sopenharmony_ci#define DFSDM_ISR_JCIP(v) FIELD_PREP(DFSDM_ISR_JCIP_MASK, v) 1748c2ecf20Sopenharmony_ci#define DFSDM_ISR_RCIP_MASK BIT(14) 1758c2ecf20Sopenharmony_ci#define DFSDM_ISR_RCIP(v) FIELD_PREP(DFSDM_ISR_RCIP, v) 1768c2ecf20Sopenharmony_ci#define DFSDM_ISR_CKABF_MASK GENMASK(23, 16) 1778c2ecf20Sopenharmony_ci#define DFSDM_ISR_CKABF(v) FIELD_PREP(DFSDM_ISR_CKABF_MASK, v) 1788c2ecf20Sopenharmony_ci#define DFSDM_ISR_SCDF_MASK GENMASK(31, 24) 1798c2ecf20Sopenharmony_ci#define DFSDM_ISR_SCDF(v) FIELD_PREP(DFSDM_ISR_SCDF_MASK, v) 1808c2ecf20Sopenharmony_ci 1818c2ecf20Sopenharmony_ci/* ICR: Interrupt flag clear register */ 1828c2ecf20Sopenharmony_ci#define DFSDM_ICR_CLRJOVRF_MASK BIT(2) 1838c2ecf20Sopenharmony_ci#define DFSDM_ICR_CLRJOVRF(v) FIELD_PREP(DFSDM_ICR_CLRJOVRF_MASK, v) 1848c2ecf20Sopenharmony_ci#define DFSDM_ICR_CLRROVRF_MASK BIT(3) 1858c2ecf20Sopenharmony_ci#define DFSDM_ICR_CLRROVRF(v) FIELD_PREP(DFSDM_ICR_CLRROVRF_MASK, v) 1868c2ecf20Sopenharmony_ci#define DFSDM_ICR_CLRCKABF_MASK GENMASK(23, 16) 1878c2ecf20Sopenharmony_ci#define DFSDM_ICR_CLRCKABF(v) FIELD_PREP(DFSDM_ICR_CLRCKABF_MASK, v) 1888c2ecf20Sopenharmony_ci#define DFSDM_ICR_CLRCKABF_CH_MASK(y) BIT(16 + (y)) 1898c2ecf20Sopenharmony_ci#define DFSDM_ICR_CLRCKABF_CH(v, y) \ 1908c2ecf20Sopenharmony_ci (((v) << (16 + (y))) & DFSDM_ICR_CLRCKABF_CH_MASK(y)) 1918c2ecf20Sopenharmony_ci#define DFSDM_ICR_CLRSCDF_MASK GENMASK(31, 24) 1928c2ecf20Sopenharmony_ci#define DFSDM_ICR_CLRSCDF(v) FIELD_PREP(DFSDM_ICR_CLRSCDF_MASK, v) 1938c2ecf20Sopenharmony_ci#define DFSDM_ICR_CLRSCDF_CH_MASK(y) BIT(24 + (y)) 1948c2ecf20Sopenharmony_ci#define DFSDM_ICR_CLRSCDF_CH(v, y) \ 1958c2ecf20Sopenharmony_ci (((v) << (24 + (y))) & DFSDM_ICR_CLRSCDF_MASK(y)) 1968c2ecf20Sopenharmony_ci 1978c2ecf20Sopenharmony_ci/* FCR: Filter control register */ 1988c2ecf20Sopenharmony_ci#define DFSDM_FCR_IOSR_MASK GENMASK(7, 0) 1998c2ecf20Sopenharmony_ci#define DFSDM_FCR_IOSR(v) FIELD_PREP(DFSDM_FCR_IOSR_MASK, v) 2008c2ecf20Sopenharmony_ci#define DFSDM_FCR_FOSR_MASK GENMASK(25, 16) 2018c2ecf20Sopenharmony_ci#define DFSDM_FCR_FOSR(v) FIELD_PREP(DFSDM_FCR_FOSR_MASK, v) 2028c2ecf20Sopenharmony_ci#define DFSDM_FCR_FORD_MASK GENMASK(31, 29) 2038c2ecf20Sopenharmony_ci#define DFSDM_FCR_FORD(v) FIELD_PREP(DFSDM_FCR_FORD_MASK, v) 2048c2ecf20Sopenharmony_ci 2058c2ecf20Sopenharmony_ci/* RDATAR: Filter data register for regular channel */ 2068c2ecf20Sopenharmony_ci#define DFSDM_DATAR_CH_MASK GENMASK(2, 0) 2078c2ecf20Sopenharmony_ci#define DFSDM_DATAR_DATA_OFFSET 8 2088c2ecf20Sopenharmony_ci#define DFSDM_DATAR_DATA_MASK GENMASK(31, DFSDM_DATAR_DATA_OFFSET) 2098c2ecf20Sopenharmony_ci 2108c2ecf20Sopenharmony_ci/* AWLTR: Filter analog watchdog low threshold register */ 2118c2ecf20Sopenharmony_ci#define DFSDM_AWLTR_BKAWL_MASK GENMASK(3, 0) 2128c2ecf20Sopenharmony_ci#define DFSDM_AWLTR_BKAWL(v) FIELD_PREP(DFSDM_AWLTR_BKAWL_MASK, v) 2138c2ecf20Sopenharmony_ci#define DFSDM_AWLTR_AWLT_MASK GENMASK(31, 8) 2148c2ecf20Sopenharmony_ci#define DFSDM_AWLTR_AWLT(v) FIELD_PREP(DFSDM_AWLTR_AWLT_MASK, v) 2158c2ecf20Sopenharmony_ci 2168c2ecf20Sopenharmony_ci/* AWHTR: Filter analog watchdog low threshold register */ 2178c2ecf20Sopenharmony_ci#define DFSDM_AWHTR_BKAWH_MASK GENMASK(3, 0) 2188c2ecf20Sopenharmony_ci#define DFSDM_AWHTR_BKAWH(v) FIELD_PREP(DFSDM_AWHTR_BKAWH_MASK, v) 2198c2ecf20Sopenharmony_ci#define DFSDM_AWHTR_AWHT_MASK GENMASK(31, 8) 2208c2ecf20Sopenharmony_ci#define DFSDM_AWHTR_AWHT(v) FIELD_PREP(DFSDM_AWHTR_AWHT_MASK, v) 2218c2ecf20Sopenharmony_ci 2228c2ecf20Sopenharmony_ci/* AWSR: Filter watchdog status register */ 2238c2ecf20Sopenharmony_ci#define DFSDM_AWSR_AWLTF_MASK GENMASK(7, 0) 2248c2ecf20Sopenharmony_ci#define DFSDM_AWSR_AWLTF(v) FIELD_PREP(DFSDM_AWSR_AWLTF_MASK, v) 2258c2ecf20Sopenharmony_ci#define DFSDM_AWSR_AWHTF_MASK GENMASK(15, 8) 2268c2ecf20Sopenharmony_ci#define DFSDM_AWSR_AWHTF(v) FIELD_PREP(DFSDM_AWSR_AWHTF_MASK, v) 2278c2ecf20Sopenharmony_ci 2288c2ecf20Sopenharmony_ci/* AWCFR: Filter watchdog status register */ 2298c2ecf20Sopenharmony_ci#define DFSDM_AWCFR_AWLTF_MASK GENMASK(7, 0) 2308c2ecf20Sopenharmony_ci#define DFSDM_AWCFR_AWLTF(v) FIELD_PREP(DFSDM_AWCFR_AWLTF_MASK, v) 2318c2ecf20Sopenharmony_ci#define DFSDM_AWCFR_AWHTF_MASK GENMASK(15, 8) 2328c2ecf20Sopenharmony_ci#define DFSDM_AWCFR_AWHTF(v) FIELD_PREP(DFSDM_AWCFR_AWHTF_MASK, v) 2338c2ecf20Sopenharmony_ci 2348c2ecf20Sopenharmony_ci/* DFSDM filter order */ 2358c2ecf20Sopenharmony_cienum stm32_dfsdm_sinc_order { 2368c2ecf20Sopenharmony_ci DFSDM_FASTSINC_ORDER, /* FastSinc filter type */ 2378c2ecf20Sopenharmony_ci DFSDM_SINC1_ORDER, /* Sinc 1 filter type */ 2388c2ecf20Sopenharmony_ci DFSDM_SINC2_ORDER, /* Sinc 2 filter type */ 2398c2ecf20Sopenharmony_ci DFSDM_SINC3_ORDER, /* Sinc 3 filter type */ 2408c2ecf20Sopenharmony_ci DFSDM_SINC4_ORDER, /* Sinc 4 filter type (N.A. for watchdog) */ 2418c2ecf20Sopenharmony_ci DFSDM_SINC5_ORDER, /* Sinc 5 filter type (N.A. for watchdog) */ 2428c2ecf20Sopenharmony_ci DFSDM_NB_SINC_ORDER, 2438c2ecf20Sopenharmony_ci}; 2448c2ecf20Sopenharmony_ci 2458c2ecf20Sopenharmony_ci/** 2468c2ecf20Sopenharmony_ci * struct stm32_dfsdm_filter_osr - DFSDM filter settings linked to oversampling 2478c2ecf20Sopenharmony_ci * @iosr: integrator oversampling 2488c2ecf20Sopenharmony_ci * @fosr: filter oversampling 2498c2ecf20Sopenharmony_ci * @rshift: output sample right shift (hardware shift) 2508c2ecf20Sopenharmony_ci * @lshift: output sample left shift (software shift) 2518c2ecf20Sopenharmony_ci * @res: output sample resolution 2528c2ecf20Sopenharmony_ci * @bits: output sample resolution in bits 2538c2ecf20Sopenharmony_ci * @max: output sample maximum positive value 2548c2ecf20Sopenharmony_ci */ 2558c2ecf20Sopenharmony_cistruct stm32_dfsdm_filter_osr { 2568c2ecf20Sopenharmony_ci unsigned int iosr; 2578c2ecf20Sopenharmony_ci unsigned int fosr; 2588c2ecf20Sopenharmony_ci unsigned int rshift; 2598c2ecf20Sopenharmony_ci unsigned int lshift; 2608c2ecf20Sopenharmony_ci u64 res; 2618c2ecf20Sopenharmony_ci u32 bits; 2628c2ecf20Sopenharmony_ci s32 max; 2638c2ecf20Sopenharmony_ci}; 2648c2ecf20Sopenharmony_ci 2658c2ecf20Sopenharmony_ci/** 2668c2ecf20Sopenharmony_ci * struct stm32_dfsdm_filter - structure relative to stm32 FDSDM filter 2678c2ecf20Sopenharmony_ci * @ford: filter order 2688c2ecf20Sopenharmony_ci * @flo: filter oversampling data table indexed by fast mode flag 2698c2ecf20Sopenharmony_ci * @sync_mode: filter synchronized with filter 0 2708c2ecf20Sopenharmony_ci * @fast: filter fast mode 2718c2ecf20Sopenharmony_ci */ 2728c2ecf20Sopenharmony_cistruct stm32_dfsdm_filter { 2738c2ecf20Sopenharmony_ci enum stm32_dfsdm_sinc_order ford; 2748c2ecf20Sopenharmony_ci struct stm32_dfsdm_filter_osr flo[2]; 2758c2ecf20Sopenharmony_ci unsigned int sync_mode; 2768c2ecf20Sopenharmony_ci unsigned int fast; 2778c2ecf20Sopenharmony_ci}; 2788c2ecf20Sopenharmony_ci 2798c2ecf20Sopenharmony_ci/** 2808c2ecf20Sopenharmony_ci * struct stm32_dfsdm_channel - structure relative to stm32 FDSDM channel 2818c2ecf20Sopenharmony_ci * @id: id of the channel 2828c2ecf20Sopenharmony_ci * @type: interface type linked to stm32_dfsdm_chan_type 2838c2ecf20Sopenharmony_ci * @src: interface type linked to stm32_dfsdm_chan_src 2848c2ecf20Sopenharmony_ci * @alt_si: alternative serial input interface 2858c2ecf20Sopenharmony_ci */ 2868c2ecf20Sopenharmony_cistruct stm32_dfsdm_channel { 2878c2ecf20Sopenharmony_ci unsigned int id; 2888c2ecf20Sopenharmony_ci unsigned int type; 2898c2ecf20Sopenharmony_ci unsigned int src; 2908c2ecf20Sopenharmony_ci unsigned int alt_si; 2918c2ecf20Sopenharmony_ci}; 2928c2ecf20Sopenharmony_ci 2938c2ecf20Sopenharmony_ci/** 2948c2ecf20Sopenharmony_ci * struct stm32_dfsdm - stm32 FDSDM driver common data (for all instances) 2958c2ecf20Sopenharmony_ci * @base: control registers base cpu addr 2968c2ecf20Sopenharmony_ci * @phys_base: DFSDM IP register physical address 2978c2ecf20Sopenharmony_ci * @regmap: regmap for register read/write 2988c2ecf20Sopenharmony_ci * @fl_list: filter resources list 2998c2ecf20Sopenharmony_ci * @num_fls: number of filter resources available 3008c2ecf20Sopenharmony_ci * @ch_list: channel resources list 3018c2ecf20Sopenharmony_ci * @num_chs: number of channel resources available 3028c2ecf20Sopenharmony_ci * @spi_master_freq: SPI clock out frequency 3038c2ecf20Sopenharmony_ci */ 3048c2ecf20Sopenharmony_cistruct stm32_dfsdm { 3058c2ecf20Sopenharmony_ci void __iomem *base; 3068c2ecf20Sopenharmony_ci phys_addr_t phys_base; 3078c2ecf20Sopenharmony_ci struct regmap *regmap; 3088c2ecf20Sopenharmony_ci struct stm32_dfsdm_filter *fl_list; 3098c2ecf20Sopenharmony_ci unsigned int num_fls; 3108c2ecf20Sopenharmony_ci struct stm32_dfsdm_channel *ch_list; 3118c2ecf20Sopenharmony_ci unsigned int num_chs; 3128c2ecf20Sopenharmony_ci unsigned int spi_master_freq; 3138c2ecf20Sopenharmony_ci}; 3148c2ecf20Sopenharmony_ci 3158c2ecf20Sopenharmony_ci/* DFSDM channel serial spi clock source */ 3168c2ecf20Sopenharmony_cienum stm32_dfsdm_spi_clk_src { 3178c2ecf20Sopenharmony_ci DFSDM_CHANNEL_SPI_CLOCK_EXTERNAL, 3188c2ecf20Sopenharmony_ci DFSDM_CHANNEL_SPI_CLOCK_INTERNAL, 3198c2ecf20Sopenharmony_ci DFSDM_CHANNEL_SPI_CLOCK_INTERNAL_DIV2_FALLING, 3208c2ecf20Sopenharmony_ci DFSDM_CHANNEL_SPI_CLOCK_INTERNAL_DIV2_RISING 3218c2ecf20Sopenharmony_ci}; 3228c2ecf20Sopenharmony_ci 3238c2ecf20Sopenharmony_ciint stm32_dfsdm_start_dfsdm(struct stm32_dfsdm *dfsdm); 3248c2ecf20Sopenharmony_ciint stm32_dfsdm_stop_dfsdm(struct stm32_dfsdm *dfsdm); 3258c2ecf20Sopenharmony_ci 3268c2ecf20Sopenharmony_ci#endif 327