162306a36Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0
262306a36Sopenharmony_ci *
362306a36Sopenharmony_ci * SH4 CPU-specific DMA definitions, used by both DMA drivers
462306a36Sopenharmony_ci *
562306a36Sopenharmony_ci * Copyright (C) 2010 Guennadi Liakhovetski <g.liakhovetski@gmx.de>
662306a36Sopenharmony_ci */
762306a36Sopenharmony_ci#ifndef CPU_DMA_REGISTER_H
862306a36Sopenharmony_ci#define CPU_DMA_REGISTER_H
962306a36Sopenharmony_ci
1062306a36Sopenharmony_ci/* SH7751/7760/7780 DMA IRQ sources */
1162306a36Sopenharmony_ci
1262306a36Sopenharmony_ci#ifdef CONFIG_CPU_SH4A
1362306a36Sopenharmony_ci
1462306a36Sopenharmony_ci#define DMAOR_INIT	DMAOR_DME
1562306a36Sopenharmony_ci
1662306a36Sopenharmony_ci#if defined(CONFIG_CPU_SUBTYPE_SH7343)
1762306a36Sopenharmony_ci#define CHCR_TS_LOW_MASK	0x00000018
1862306a36Sopenharmony_ci#define CHCR_TS_LOW_SHIFT	3
1962306a36Sopenharmony_ci#define CHCR_TS_HIGH_MASK	0
2062306a36Sopenharmony_ci#define CHCR_TS_HIGH_SHIFT	0
2162306a36Sopenharmony_ci#elif defined(CONFIG_CPU_SUBTYPE_SH7722) || \
2262306a36Sopenharmony_ci	defined(CONFIG_CPU_SUBTYPE_SH7723) || \
2362306a36Sopenharmony_ci	defined(CONFIG_CPU_SUBTYPE_SH7724) || \
2462306a36Sopenharmony_ci	defined(CONFIG_CPU_SUBTYPE_SH7730) || \
2562306a36Sopenharmony_ci	defined(CONFIG_CPU_SUBTYPE_SH7786)
2662306a36Sopenharmony_ci#define CHCR_TS_LOW_MASK	0x00000018
2762306a36Sopenharmony_ci#define CHCR_TS_LOW_SHIFT	3
2862306a36Sopenharmony_ci#define CHCR_TS_HIGH_MASK	0x00300000
2962306a36Sopenharmony_ci#define CHCR_TS_HIGH_SHIFT	(20 - 2)	/* 2 bits for shifted low TS */
3062306a36Sopenharmony_ci#elif defined(CONFIG_CPU_SUBTYPE_SH7757) || \
3162306a36Sopenharmony_ci	defined(CONFIG_CPU_SUBTYPE_SH7763) || \
3262306a36Sopenharmony_ci	defined(CONFIG_CPU_SUBTYPE_SH7780) || \
3362306a36Sopenharmony_ci	defined(CONFIG_CPU_SUBTYPE_SH7785)
3462306a36Sopenharmony_ci#define CHCR_TS_LOW_MASK	0x00000018
3562306a36Sopenharmony_ci#define CHCR_TS_LOW_SHIFT	3
3662306a36Sopenharmony_ci#define CHCR_TS_HIGH_MASK	0x00100000
3762306a36Sopenharmony_ci#define CHCR_TS_HIGH_SHIFT	(20 - 2)	/* 2 bits for shifted low TS */
3862306a36Sopenharmony_ci#endif
3962306a36Sopenharmony_ci
4062306a36Sopenharmony_ci/* Transmit sizes and respective CHCR register values */
4162306a36Sopenharmony_cienum {
4262306a36Sopenharmony_ci	XMIT_SZ_8BIT		= 0,
4362306a36Sopenharmony_ci	XMIT_SZ_16BIT		= 1,
4462306a36Sopenharmony_ci	XMIT_SZ_32BIT		= 2,
4562306a36Sopenharmony_ci	XMIT_SZ_64BIT		= 7,
4662306a36Sopenharmony_ci	XMIT_SZ_128BIT		= 3,
4762306a36Sopenharmony_ci	XMIT_SZ_256BIT		= 4,
4862306a36Sopenharmony_ci	XMIT_SZ_128BIT_BLK	= 0xb,
4962306a36Sopenharmony_ci	XMIT_SZ_256BIT_BLK	= 0xc,
5062306a36Sopenharmony_ci};
5162306a36Sopenharmony_ci
5262306a36Sopenharmony_ci/* log2(size / 8) - used to calculate number of transfers */
5362306a36Sopenharmony_ci#define TS_SHIFT {			\
5462306a36Sopenharmony_ci	[XMIT_SZ_8BIT]		= 0,	\
5562306a36Sopenharmony_ci	[XMIT_SZ_16BIT]		= 1,	\
5662306a36Sopenharmony_ci	[XMIT_SZ_32BIT]		= 2,	\
5762306a36Sopenharmony_ci	[XMIT_SZ_64BIT]		= 3,	\
5862306a36Sopenharmony_ci	[XMIT_SZ_128BIT]	= 4,	\
5962306a36Sopenharmony_ci	[XMIT_SZ_256BIT]	= 5,	\
6062306a36Sopenharmony_ci	[XMIT_SZ_128BIT_BLK]	= 4,	\
6162306a36Sopenharmony_ci	[XMIT_SZ_256BIT_BLK]	= 5,	\
6262306a36Sopenharmony_ci}
6362306a36Sopenharmony_ci
6462306a36Sopenharmony_ci#define TS_INDEX2VAL(i)	((((i) & 3) << CHCR_TS_LOW_SHIFT) | \
6562306a36Sopenharmony_ci			 (((i) & 0xc) << CHCR_TS_HIGH_SHIFT))
6662306a36Sopenharmony_ci
6762306a36Sopenharmony_ci#else /* CONFIG_CPU_SH4A */
6862306a36Sopenharmony_ci
6962306a36Sopenharmony_ci#define DMAOR_INIT	(0x8000 | DMAOR_DME)
7062306a36Sopenharmony_ci
7162306a36Sopenharmony_ci#define CHCR_TS_LOW_MASK	0x70
7262306a36Sopenharmony_ci#define CHCR_TS_LOW_SHIFT	4
7362306a36Sopenharmony_ci#define CHCR_TS_HIGH_MASK	0
7462306a36Sopenharmony_ci#define CHCR_TS_HIGH_SHIFT	0
7562306a36Sopenharmony_ci
7662306a36Sopenharmony_ci/* Transmit sizes and respective CHCR register values */
7762306a36Sopenharmony_cienum {
7862306a36Sopenharmony_ci	XMIT_SZ_8BIT	= 1,
7962306a36Sopenharmony_ci	XMIT_SZ_16BIT	= 2,
8062306a36Sopenharmony_ci	XMIT_SZ_32BIT	= 3,
8162306a36Sopenharmony_ci	XMIT_SZ_64BIT	= 0,
8262306a36Sopenharmony_ci	XMIT_SZ_256BIT	= 4,
8362306a36Sopenharmony_ci};
8462306a36Sopenharmony_ci
8562306a36Sopenharmony_ci/* log2(size / 8) - used to calculate number of transfers */
8662306a36Sopenharmony_ci#define TS_SHIFT {			\
8762306a36Sopenharmony_ci	[XMIT_SZ_8BIT]		= 0,	\
8862306a36Sopenharmony_ci	[XMIT_SZ_16BIT]		= 1,	\
8962306a36Sopenharmony_ci	[XMIT_SZ_32BIT]		= 2,	\
9062306a36Sopenharmony_ci	[XMIT_SZ_64BIT]		= 3,	\
9162306a36Sopenharmony_ci	[XMIT_SZ_256BIT]	= 5,	\
9262306a36Sopenharmony_ci}
9362306a36Sopenharmony_ci
9462306a36Sopenharmony_ci#define TS_INDEX2VAL(i)	(((i) & 7) << CHCR_TS_LOW_SHIFT)
9562306a36Sopenharmony_ci
9662306a36Sopenharmony_ci#endif /* CONFIG_CPU_SH4A */
9762306a36Sopenharmony_ci
9862306a36Sopenharmony_ci#endif
99