18c2ecf20Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0-or-later */
28c2ecf20Sopenharmony_ci/*
38c2ecf20Sopenharmony_ci * Driver for Digigram miXart soundcards
48c2ecf20Sopenharmony_ci *
58c2ecf20Sopenharmony_ci * definitions and makros for basic card access
68c2ecf20Sopenharmony_ci *
78c2ecf20Sopenharmony_ci * Copyright (c) 2003 by Digigram <alsa@digigram.com>
88c2ecf20Sopenharmony_ci */
98c2ecf20Sopenharmony_ci
108c2ecf20Sopenharmony_ci#ifndef __SOUND_MIXART_HWDEP_H
118c2ecf20Sopenharmony_ci#define __SOUND_MIXART_HWDEP_H
128c2ecf20Sopenharmony_ci
138c2ecf20Sopenharmony_ci#include <sound/hwdep.h>
148c2ecf20Sopenharmony_ci
158c2ecf20Sopenharmony_ci#ifndef readl_be
168c2ecf20Sopenharmony_ci#define readl_be(x) be32_to_cpu((__force __be32)__raw_readl(x))
178c2ecf20Sopenharmony_ci#endif
188c2ecf20Sopenharmony_ci
198c2ecf20Sopenharmony_ci#ifndef writel_be
208c2ecf20Sopenharmony_ci#define writel_be(data,addr) __raw_writel((__force u32)cpu_to_be32(data),addr)
218c2ecf20Sopenharmony_ci#endif
228c2ecf20Sopenharmony_ci
238c2ecf20Sopenharmony_ci#ifndef readl_le
248c2ecf20Sopenharmony_ci#define readl_le(x) le32_to_cpu((__force __le32)__raw_readl(x))
258c2ecf20Sopenharmony_ci#endif
268c2ecf20Sopenharmony_ci
278c2ecf20Sopenharmony_ci#ifndef writel_le
288c2ecf20Sopenharmony_ci#define writel_le(data,addr) __raw_writel((__force u32)cpu_to_le32(data),addr)
298c2ecf20Sopenharmony_ci#endif
308c2ecf20Sopenharmony_ci
318c2ecf20Sopenharmony_ci#define MIXART_MEM(mgr,x)	((mgr)->mem[0].virt + (x))
328c2ecf20Sopenharmony_ci#define MIXART_REG(mgr,x)	((mgr)->mem[1].virt + (x))
338c2ecf20Sopenharmony_ci
348c2ecf20Sopenharmony_ci
358c2ecf20Sopenharmony_ci/* Daughter board Type */
368c2ecf20Sopenharmony_ci#define DAUGHTER_TYPE_MASK     0x0F
378c2ecf20Sopenharmony_ci#define DAUGHTER_VER_MASK      0xF0
388c2ecf20Sopenharmony_ci#define DAUGHTER_TYPEVER_MASK  (DAUGHTER_TYPE_MASK|DAUGHTER_VER_MASK)
398c2ecf20Sopenharmony_ci
408c2ecf20Sopenharmony_ci#define MIXART_DAUGHTER_TYPE_NONE     0x00
418c2ecf20Sopenharmony_ci#define MIXART_DAUGHTER_TYPE_COBRANET 0x08
428c2ecf20Sopenharmony_ci#define MIXART_DAUGHTER_TYPE_AES      0x0E
438c2ecf20Sopenharmony_ci
448c2ecf20Sopenharmony_ci
458c2ecf20Sopenharmony_ci
468c2ecf20Sopenharmony_ci#define MIXART_BA0_SIZE 	(16 * 1024 * 1024) /* 16M */
478c2ecf20Sopenharmony_ci#define MIXART_BA1_SIZE 	(4  * 1024)        /* 4k */
488c2ecf20Sopenharmony_ci
498c2ecf20Sopenharmony_ci/*
508c2ecf20Sopenharmony_ci * -----------BAR 0 --------------------------------------------------------------------------------------------------------
518c2ecf20Sopenharmony_ci */
528c2ecf20Sopenharmony_ci#define  MIXART_PSEUDOREG                          0x2000                    /* base address for pseudoregister */
538c2ecf20Sopenharmony_ci
548c2ecf20Sopenharmony_ci#define  MIXART_PSEUDOREG_BOARDNUMBER              MIXART_PSEUDOREG+0        /* board number */
558c2ecf20Sopenharmony_ci
568c2ecf20Sopenharmony_ci/* perfmeter (available when elf loaded)*/
578c2ecf20Sopenharmony_ci#define  MIXART_PSEUDOREG_PERF_STREAM_LOAD_OFFSET  MIXART_PSEUDOREG+0x70     /* streaming load */
588c2ecf20Sopenharmony_ci#define  MIXART_PSEUDOREG_PERF_SYSTEM_LOAD_OFFSET  MIXART_PSEUDOREG+0x78     /* system load (reference)*/
598c2ecf20Sopenharmony_ci#define  MIXART_PSEUDOREG_PERF_MAILBX_LOAD_OFFSET  MIXART_PSEUDOREG+0x7C     /* mailbox load */
608c2ecf20Sopenharmony_ci#define  MIXART_PSEUDOREG_PERF_INTERR_LOAD_OFFSET  MIXART_PSEUDOREG+0x74     /* interrupt handling  load */
618c2ecf20Sopenharmony_ci
628c2ecf20Sopenharmony_ci/* motherboard xilinx loader info */
638c2ecf20Sopenharmony_ci#define  MIXART_PSEUDOREG_MXLX_BASE_ADDR_OFFSET    MIXART_PSEUDOREG+0x9C     /* 0x00600000 */
648c2ecf20Sopenharmony_ci#define  MIXART_PSEUDOREG_MXLX_SIZE_OFFSET         MIXART_PSEUDOREG+0xA0     /* xilinx size in bytes */
658c2ecf20Sopenharmony_ci#define  MIXART_PSEUDOREG_MXLX_STATUS_OFFSET       MIXART_PSEUDOREG+0xA4     /* status = EMBEBBED_STAT_XXX */
668c2ecf20Sopenharmony_ci
678c2ecf20Sopenharmony_ci/* elf loader info */
688c2ecf20Sopenharmony_ci#define  MIXART_PSEUDOREG_ELF_STATUS_OFFSET        MIXART_PSEUDOREG+0xB0     /* status = EMBEBBED_STAT_XXX */
698c2ecf20Sopenharmony_ci
708c2ecf20Sopenharmony_ci/*
718c2ecf20Sopenharmony_ci*  after the elf code is loaded, and the flowtable info was passed to it,
728c2ecf20Sopenharmony_ci*  the driver polls on this address, until it shows 1 (presence) or 2 (absence)
738c2ecf20Sopenharmony_ci*  once it is non-zero, the daughter board type may be read
748c2ecf20Sopenharmony_ci*/
758c2ecf20Sopenharmony_ci#define  MIXART_PSEUDOREG_DBRD_PRESENCE_OFFSET     MIXART_PSEUDOREG+0x990
768c2ecf20Sopenharmony_ci
778c2ecf20Sopenharmony_ci/* Global info structure */
788c2ecf20Sopenharmony_ci#define  MIXART_PSEUDOREG_DBRD_TYPE_OFFSET         MIXART_PSEUDOREG+0x994    /* Type and version of daughterboard  */
798c2ecf20Sopenharmony_ci
808c2ecf20Sopenharmony_ci
818c2ecf20Sopenharmony_ci/* daughterboard xilinx loader info */
828c2ecf20Sopenharmony_ci#define  MIXART_PSEUDOREG_DXLX_BASE_ADDR_OFFSET    MIXART_PSEUDOREG+0x998    /* get the address here where to write the file */
838c2ecf20Sopenharmony_ci#define  MIXART_PSEUDOREG_DXLX_SIZE_OFFSET         MIXART_PSEUDOREG+0x99C    /* xilinx size in bytes */
848c2ecf20Sopenharmony_ci#define  MIXART_PSEUDOREG_DXLX_STATUS_OFFSET       MIXART_PSEUDOREG+0x9A0    /* status = EMBEBBED_STAT_XXX */
858c2ecf20Sopenharmony_ci
868c2ecf20Sopenharmony_ci/*  */
878c2ecf20Sopenharmony_ci#define  MIXART_FLOWTABLE_PTR                      0x3000                    /* pointer to flow table */
888c2ecf20Sopenharmony_ci
898c2ecf20Sopenharmony_ci/* mailbox addresses  */
908c2ecf20Sopenharmony_ci
918c2ecf20Sopenharmony_ci/* message DRV -> EMB */
928c2ecf20Sopenharmony_ci#define MSG_INBOUND_POST_HEAD       0x010008	/* DRV posts MF + increment4 */
938c2ecf20Sopenharmony_ci#define	MSG_INBOUND_POST_TAIL       0x01000C	/* EMB gets MF + increment4 */
948c2ecf20Sopenharmony_ci/* message EMB -> DRV */
958c2ecf20Sopenharmony_ci#define	MSG_OUTBOUND_POST_TAIL      0x01001C	/* DRV gets MF + increment4 */
968c2ecf20Sopenharmony_ci#define	MSG_OUTBOUND_POST_HEAD      0x010018	/* EMB posts MF + increment4 */
978c2ecf20Sopenharmony_ci/* Get Free Frames */
988c2ecf20Sopenharmony_ci#define MSG_INBOUND_FREE_TAIL       0x010004	/* DRV gets MFA + increment4 */
998c2ecf20Sopenharmony_ci#define MSG_OUTBOUND_FREE_TAIL      0x010014	/* EMB gets MFA + increment4 */
1008c2ecf20Sopenharmony_ci/* Put Free Frames */
1018c2ecf20Sopenharmony_ci#define MSG_OUTBOUND_FREE_HEAD      0x010010	/* DRV puts MFA + increment4 */
1028c2ecf20Sopenharmony_ci#define MSG_INBOUND_FREE_HEAD       0x010000    /* EMB puts MFA + increment4 */
1038c2ecf20Sopenharmony_ci
1048c2ecf20Sopenharmony_ci/* firmware addresses of the message fifos */
1058c2ecf20Sopenharmony_ci#define MSG_BOUND_STACK_SIZE        0x004000    /* size of each following stack */
1068c2ecf20Sopenharmony_ci/* posted messages */
1078c2ecf20Sopenharmony_ci#define MSG_OUTBOUND_POST_STACK     0x108000    /* stack of messages to the DRV */
1088c2ecf20Sopenharmony_ci#define MSG_INBOUND_POST_STACK      0x104000    /* stack of messages to the EMB */
1098c2ecf20Sopenharmony_ci/* available empty messages */
1108c2ecf20Sopenharmony_ci#define MSG_OUTBOUND_FREE_STACK     0x10C000    /* stack of free enveloped for EMB */
1118c2ecf20Sopenharmony_ci#define MSG_INBOUND_FREE_STACK      0x100000    /* stack of free enveloped for DRV */
1128c2ecf20Sopenharmony_ci
1138c2ecf20Sopenharmony_ci
1148c2ecf20Sopenharmony_ci/* defines for mailbox message frames */
1158c2ecf20Sopenharmony_ci#define MSG_FRAME_OFFSET            0x64
1168c2ecf20Sopenharmony_ci#define MSG_FRAME_SIZE              0x6400
1178c2ecf20Sopenharmony_ci#define MSG_FRAME_NUMBER            32
1188c2ecf20Sopenharmony_ci#define MSG_FROM_AGENT_ITMF_OFFSET  (MSG_FRAME_OFFSET + (MSG_FRAME_SIZE * MSG_FRAME_NUMBER))
1198c2ecf20Sopenharmony_ci#define MSG_TO_AGENT_ITMF_OFFSET    (MSG_FROM_AGENT_ITMF_OFFSET + MSG_FRAME_SIZE)
1208c2ecf20Sopenharmony_ci#define MSG_HOST_RSC_PROTECTION     (MSG_TO_AGENT_ITMF_OFFSET + MSG_FRAME_SIZE)
1218c2ecf20Sopenharmony_ci#define MSG_AGENT_RSC_PROTECTION    (MSG_HOST_RSC_PROTECTION + 4)
1228c2ecf20Sopenharmony_ci
1238c2ecf20Sopenharmony_ci
1248c2ecf20Sopenharmony_ci/*
1258c2ecf20Sopenharmony_ci * -----------BAR 1 --------------------------------------------------------------------------------------------------------
1268c2ecf20Sopenharmony_ci */
1278c2ecf20Sopenharmony_ci
1288c2ecf20Sopenharmony_ci/* interrupt addresses and constants */
1298c2ecf20Sopenharmony_ci#define MIXART_PCI_OMIMR_OFFSET                 0x34    /* outbound message interrupt mask register */
1308c2ecf20Sopenharmony_ci#define MIXART_PCI_OMISR_OFFSET                 0x30    /* outbound message interrupt status register */
1318c2ecf20Sopenharmony_ci#define MIXART_PCI_ODBR_OFFSET                  0x60    /* outbound doorbell register */
1328c2ecf20Sopenharmony_ci
1338c2ecf20Sopenharmony_ci#define MIXART_BA1_BRUTAL_RESET_OFFSET          0x68    /* write 1 in LSBit to reset board */
1348c2ecf20Sopenharmony_ci
1358c2ecf20Sopenharmony_ci#define MIXART_HOST_ALL_INTERRUPT_MASKED        0x02B   /* 0000 0010 1011 */
1368c2ecf20Sopenharmony_ci#define MIXART_ALLOW_OUTBOUND_DOORBELL          0x023   /* 0000 0010 0011 */
1378c2ecf20Sopenharmony_ci#define MIXART_OIDI                             0x008   /* 0000 0000 1000 */
1388c2ecf20Sopenharmony_ci
1398c2ecf20Sopenharmony_ci
1408c2ecf20Sopenharmony_ciint snd_mixart_setup_firmware(struct mixart_mgr *mgr);
1418c2ecf20Sopenharmony_ci
1428c2ecf20Sopenharmony_ci#endif /* __SOUND_MIXART_HWDEP_H */
143