162306a36Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0-or-later */
262306a36Sopenharmony_ci/*
362306a36Sopenharmony_ci * Driver for Digigram miXart soundcards
462306a36Sopenharmony_ci *
562306a36Sopenharmony_ci * definitions and makros for basic card access
662306a36Sopenharmony_ci *
762306a36Sopenharmony_ci * Copyright (c) 2003 by Digigram <alsa@digigram.com>
862306a36Sopenharmony_ci */
962306a36Sopenharmony_ci
1062306a36Sopenharmony_ci#ifndef __SOUND_MIXART_HWDEP_H
1162306a36Sopenharmony_ci#define __SOUND_MIXART_HWDEP_H
1262306a36Sopenharmony_ci
1362306a36Sopenharmony_ci#include <sound/hwdep.h>
1462306a36Sopenharmony_ci
1562306a36Sopenharmony_ci#ifndef readl_be
1662306a36Sopenharmony_ci#define readl_be(x) be32_to_cpu((__force __be32)__raw_readl(x))
1762306a36Sopenharmony_ci#endif
1862306a36Sopenharmony_ci
1962306a36Sopenharmony_ci#ifndef writel_be
2062306a36Sopenharmony_ci#define writel_be(data,addr) __raw_writel((__force u32)cpu_to_be32(data),addr)
2162306a36Sopenharmony_ci#endif
2262306a36Sopenharmony_ci
2362306a36Sopenharmony_ci#ifndef readl_le
2462306a36Sopenharmony_ci#define readl_le(x) le32_to_cpu((__force __le32)__raw_readl(x))
2562306a36Sopenharmony_ci#endif
2662306a36Sopenharmony_ci
2762306a36Sopenharmony_ci#ifndef writel_le
2862306a36Sopenharmony_ci#define writel_le(data,addr) __raw_writel((__force u32)cpu_to_le32(data),addr)
2962306a36Sopenharmony_ci#endif
3062306a36Sopenharmony_ci
3162306a36Sopenharmony_ci#define MIXART_MEM(mgr,x)	((mgr)->mem[0].virt + (x))
3262306a36Sopenharmony_ci#define MIXART_REG(mgr,x)	((mgr)->mem[1].virt + (x))
3362306a36Sopenharmony_ci
3462306a36Sopenharmony_ci
3562306a36Sopenharmony_ci/* Daughter board Type */
3662306a36Sopenharmony_ci#define DAUGHTER_TYPE_MASK     0x0F
3762306a36Sopenharmony_ci#define DAUGHTER_VER_MASK      0xF0
3862306a36Sopenharmony_ci#define DAUGHTER_TYPEVER_MASK  (DAUGHTER_TYPE_MASK|DAUGHTER_VER_MASK)
3962306a36Sopenharmony_ci
4062306a36Sopenharmony_ci#define MIXART_DAUGHTER_TYPE_NONE     0x00
4162306a36Sopenharmony_ci#define MIXART_DAUGHTER_TYPE_COBRANET 0x08
4262306a36Sopenharmony_ci#define MIXART_DAUGHTER_TYPE_AES      0x0E
4362306a36Sopenharmony_ci
4462306a36Sopenharmony_ci
4562306a36Sopenharmony_ci
4662306a36Sopenharmony_ci#define MIXART_BA0_SIZE 	(16 * 1024 * 1024) /* 16M */
4762306a36Sopenharmony_ci#define MIXART_BA1_SIZE 	(4  * 1024)        /* 4k */
4862306a36Sopenharmony_ci
4962306a36Sopenharmony_ci/*
5062306a36Sopenharmony_ci * -----------BAR 0 --------------------------------------------------------------------------------------------------------
5162306a36Sopenharmony_ci */
5262306a36Sopenharmony_ci#define  MIXART_PSEUDOREG                          0x2000                    /* base address for pseudoregister */
5362306a36Sopenharmony_ci
5462306a36Sopenharmony_ci#define  MIXART_PSEUDOREG_BOARDNUMBER              MIXART_PSEUDOREG+0        /* board number */
5562306a36Sopenharmony_ci
5662306a36Sopenharmony_ci/* perfmeter (available when elf loaded)*/
5762306a36Sopenharmony_ci#define  MIXART_PSEUDOREG_PERF_STREAM_LOAD_OFFSET  MIXART_PSEUDOREG+0x70     /* streaming load */
5862306a36Sopenharmony_ci#define  MIXART_PSEUDOREG_PERF_SYSTEM_LOAD_OFFSET  MIXART_PSEUDOREG+0x78     /* system load (reference)*/
5962306a36Sopenharmony_ci#define  MIXART_PSEUDOREG_PERF_MAILBX_LOAD_OFFSET  MIXART_PSEUDOREG+0x7C     /* mailbox load */
6062306a36Sopenharmony_ci#define  MIXART_PSEUDOREG_PERF_INTERR_LOAD_OFFSET  MIXART_PSEUDOREG+0x74     /* interrupt handling  load */
6162306a36Sopenharmony_ci
6262306a36Sopenharmony_ci/* motherboard xilinx loader info */
6362306a36Sopenharmony_ci#define  MIXART_PSEUDOREG_MXLX_BASE_ADDR_OFFSET    MIXART_PSEUDOREG+0x9C     /* 0x00600000 */
6462306a36Sopenharmony_ci#define  MIXART_PSEUDOREG_MXLX_SIZE_OFFSET         MIXART_PSEUDOREG+0xA0     /* xilinx size in bytes */
6562306a36Sopenharmony_ci#define  MIXART_PSEUDOREG_MXLX_STATUS_OFFSET       MIXART_PSEUDOREG+0xA4     /* status = EMBEBBED_STAT_XXX */
6662306a36Sopenharmony_ci
6762306a36Sopenharmony_ci/* elf loader info */
6862306a36Sopenharmony_ci#define  MIXART_PSEUDOREG_ELF_STATUS_OFFSET        MIXART_PSEUDOREG+0xB0     /* status = EMBEBBED_STAT_XXX */
6962306a36Sopenharmony_ci
7062306a36Sopenharmony_ci/*
7162306a36Sopenharmony_ci*  after the elf code is loaded, and the flowtable info was passed to it,
7262306a36Sopenharmony_ci*  the driver polls on this address, until it shows 1 (presence) or 2 (absence)
7362306a36Sopenharmony_ci*  once it is non-zero, the daughter board type may be read
7462306a36Sopenharmony_ci*/
7562306a36Sopenharmony_ci#define  MIXART_PSEUDOREG_DBRD_PRESENCE_OFFSET     MIXART_PSEUDOREG+0x990
7662306a36Sopenharmony_ci
7762306a36Sopenharmony_ci/* Global info structure */
7862306a36Sopenharmony_ci#define  MIXART_PSEUDOREG_DBRD_TYPE_OFFSET         MIXART_PSEUDOREG+0x994    /* Type and version of daughterboard  */
7962306a36Sopenharmony_ci
8062306a36Sopenharmony_ci
8162306a36Sopenharmony_ci/* daughterboard xilinx loader info */
8262306a36Sopenharmony_ci#define  MIXART_PSEUDOREG_DXLX_BASE_ADDR_OFFSET    MIXART_PSEUDOREG+0x998    /* get the address here where to write the file */
8362306a36Sopenharmony_ci#define  MIXART_PSEUDOREG_DXLX_SIZE_OFFSET         MIXART_PSEUDOREG+0x99C    /* xilinx size in bytes */
8462306a36Sopenharmony_ci#define  MIXART_PSEUDOREG_DXLX_STATUS_OFFSET       MIXART_PSEUDOREG+0x9A0    /* status = EMBEBBED_STAT_XXX */
8562306a36Sopenharmony_ci
8662306a36Sopenharmony_ci/*  */
8762306a36Sopenharmony_ci#define  MIXART_FLOWTABLE_PTR                      0x3000                    /* pointer to flow table */
8862306a36Sopenharmony_ci
8962306a36Sopenharmony_ci/* mailbox addresses  */
9062306a36Sopenharmony_ci
9162306a36Sopenharmony_ci/* message DRV -> EMB */
9262306a36Sopenharmony_ci#define MSG_INBOUND_POST_HEAD       0x010008	/* DRV posts MF + increment4 */
9362306a36Sopenharmony_ci#define	MSG_INBOUND_POST_TAIL       0x01000C	/* EMB gets MF + increment4 */
9462306a36Sopenharmony_ci/* message EMB -> DRV */
9562306a36Sopenharmony_ci#define	MSG_OUTBOUND_POST_TAIL      0x01001C	/* DRV gets MF + increment4 */
9662306a36Sopenharmony_ci#define	MSG_OUTBOUND_POST_HEAD      0x010018	/* EMB posts MF + increment4 */
9762306a36Sopenharmony_ci/* Get Free Frames */
9862306a36Sopenharmony_ci#define MSG_INBOUND_FREE_TAIL       0x010004	/* DRV gets MFA + increment4 */
9962306a36Sopenharmony_ci#define MSG_OUTBOUND_FREE_TAIL      0x010014	/* EMB gets MFA + increment4 */
10062306a36Sopenharmony_ci/* Put Free Frames */
10162306a36Sopenharmony_ci#define MSG_OUTBOUND_FREE_HEAD      0x010010	/* DRV puts MFA + increment4 */
10262306a36Sopenharmony_ci#define MSG_INBOUND_FREE_HEAD       0x010000    /* EMB puts MFA + increment4 */
10362306a36Sopenharmony_ci
10462306a36Sopenharmony_ci/* firmware addresses of the message fifos */
10562306a36Sopenharmony_ci#define MSG_BOUND_STACK_SIZE        0x004000    /* size of each following stack */
10662306a36Sopenharmony_ci/* posted messages */
10762306a36Sopenharmony_ci#define MSG_OUTBOUND_POST_STACK     0x108000    /* stack of messages to the DRV */
10862306a36Sopenharmony_ci#define MSG_INBOUND_POST_STACK      0x104000    /* stack of messages to the EMB */
10962306a36Sopenharmony_ci/* available empty messages */
11062306a36Sopenharmony_ci#define MSG_OUTBOUND_FREE_STACK     0x10C000    /* stack of free enveloped for EMB */
11162306a36Sopenharmony_ci#define MSG_INBOUND_FREE_STACK      0x100000    /* stack of free enveloped for DRV */
11262306a36Sopenharmony_ci
11362306a36Sopenharmony_ci
11462306a36Sopenharmony_ci/* defines for mailbox message frames */
11562306a36Sopenharmony_ci#define MSG_FRAME_OFFSET            0x64
11662306a36Sopenharmony_ci#define MSG_FRAME_SIZE              0x6400
11762306a36Sopenharmony_ci#define MSG_FRAME_NUMBER            32
11862306a36Sopenharmony_ci#define MSG_FROM_AGENT_ITMF_OFFSET  (MSG_FRAME_OFFSET + (MSG_FRAME_SIZE * MSG_FRAME_NUMBER))
11962306a36Sopenharmony_ci#define MSG_TO_AGENT_ITMF_OFFSET    (MSG_FROM_AGENT_ITMF_OFFSET + MSG_FRAME_SIZE)
12062306a36Sopenharmony_ci#define MSG_HOST_RSC_PROTECTION     (MSG_TO_AGENT_ITMF_OFFSET + MSG_FRAME_SIZE)
12162306a36Sopenharmony_ci#define MSG_AGENT_RSC_PROTECTION    (MSG_HOST_RSC_PROTECTION + 4)
12262306a36Sopenharmony_ci
12362306a36Sopenharmony_ci
12462306a36Sopenharmony_ci/*
12562306a36Sopenharmony_ci * -----------BAR 1 --------------------------------------------------------------------------------------------------------
12662306a36Sopenharmony_ci */
12762306a36Sopenharmony_ci
12862306a36Sopenharmony_ci/* interrupt addresses and constants */
12962306a36Sopenharmony_ci#define MIXART_PCI_OMIMR_OFFSET                 0x34    /* outbound message interrupt mask register */
13062306a36Sopenharmony_ci#define MIXART_PCI_OMISR_OFFSET                 0x30    /* outbound message interrupt status register */
13162306a36Sopenharmony_ci#define MIXART_PCI_ODBR_OFFSET                  0x60    /* outbound doorbell register */
13262306a36Sopenharmony_ci
13362306a36Sopenharmony_ci#define MIXART_BA1_BRUTAL_RESET_OFFSET          0x68    /* write 1 in LSBit to reset board */
13462306a36Sopenharmony_ci
13562306a36Sopenharmony_ci#define MIXART_HOST_ALL_INTERRUPT_MASKED        0x02B   /* 0000 0010 1011 */
13662306a36Sopenharmony_ci#define MIXART_ALLOW_OUTBOUND_DOORBELL          0x023   /* 0000 0010 0011 */
13762306a36Sopenharmony_ci#define MIXART_OIDI                             0x008   /* 0000 0000 1000 */
13862306a36Sopenharmony_ci
13962306a36Sopenharmony_ci
14062306a36Sopenharmony_ciint snd_mixart_setup_firmware(struct mixart_mgr *mgr);
14162306a36Sopenharmony_ci
14262306a36Sopenharmony_ci#endif /* __SOUND_MIXART_HWDEP_H */
143