18c2ecf20Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0 28c2ecf20Sopenharmony_ci * 38c2ecf20Sopenharmony_ci * SH4 CPU-specific DMA definitions, used by both DMA drivers 48c2ecf20Sopenharmony_ci * 58c2ecf20Sopenharmony_ci * Copyright (C) 2010 Guennadi Liakhovetski <g.liakhovetski@gmx.de> 68c2ecf20Sopenharmony_ci */ 78c2ecf20Sopenharmony_ci#ifndef CPU_DMA_REGISTER_H 88c2ecf20Sopenharmony_ci#define CPU_DMA_REGISTER_H 98c2ecf20Sopenharmony_ci 108c2ecf20Sopenharmony_ci/* SH7751/7760/7780 DMA IRQ sources */ 118c2ecf20Sopenharmony_ci 128c2ecf20Sopenharmony_ci#ifdef CONFIG_CPU_SH4A 138c2ecf20Sopenharmony_ci 148c2ecf20Sopenharmony_ci#define DMAOR_INIT DMAOR_DME 158c2ecf20Sopenharmony_ci 168c2ecf20Sopenharmony_ci#if defined(CONFIG_CPU_SUBTYPE_SH7343) 178c2ecf20Sopenharmony_ci#define CHCR_TS_LOW_MASK 0x00000018 188c2ecf20Sopenharmony_ci#define CHCR_TS_LOW_SHIFT 3 198c2ecf20Sopenharmony_ci#define CHCR_TS_HIGH_MASK 0 208c2ecf20Sopenharmony_ci#define CHCR_TS_HIGH_SHIFT 0 218c2ecf20Sopenharmony_ci#elif defined(CONFIG_CPU_SUBTYPE_SH7722) || \ 228c2ecf20Sopenharmony_ci defined(CONFIG_CPU_SUBTYPE_SH7723) || \ 238c2ecf20Sopenharmony_ci defined(CONFIG_CPU_SUBTYPE_SH7724) || \ 248c2ecf20Sopenharmony_ci defined(CONFIG_CPU_SUBTYPE_SH7730) || \ 258c2ecf20Sopenharmony_ci defined(CONFIG_CPU_SUBTYPE_SH7786) 268c2ecf20Sopenharmony_ci#define CHCR_TS_LOW_MASK 0x00000018 278c2ecf20Sopenharmony_ci#define CHCR_TS_LOW_SHIFT 3 288c2ecf20Sopenharmony_ci#define CHCR_TS_HIGH_MASK 0x00300000 298c2ecf20Sopenharmony_ci#define CHCR_TS_HIGH_SHIFT (20 - 2) /* 2 bits for shifted low TS */ 308c2ecf20Sopenharmony_ci#elif defined(CONFIG_CPU_SUBTYPE_SH7757) || \ 318c2ecf20Sopenharmony_ci defined(CONFIG_CPU_SUBTYPE_SH7763) || \ 328c2ecf20Sopenharmony_ci defined(CONFIG_CPU_SUBTYPE_SH7780) || \ 338c2ecf20Sopenharmony_ci defined(CONFIG_CPU_SUBTYPE_SH7785) 348c2ecf20Sopenharmony_ci#define CHCR_TS_LOW_MASK 0x00000018 358c2ecf20Sopenharmony_ci#define CHCR_TS_LOW_SHIFT 3 368c2ecf20Sopenharmony_ci#define CHCR_TS_HIGH_MASK 0x00100000 378c2ecf20Sopenharmony_ci#define CHCR_TS_HIGH_SHIFT (20 - 2) /* 2 bits for shifted low TS */ 388c2ecf20Sopenharmony_ci#endif 398c2ecf20Sopenharmony_ci 408c2ecf20Sopenharmony_ci/* Transmit sizes and respective CHCR register values */ 418c2ecf20Sopenharmony_cienum { 428c2ecf20Sopenharmony_ci XMIT_SZ_8BIT = 0, 438c2ecf20Sopenharmony_ci XMIT_SZ_16BIT = 1, 448c2ecf20Sopenharmony_ci XMIT_SZ_32BIT = 2, 458c2ecf20Sopenharmony_ci XMIT_SZ_64BIT = 7, 468c2ecf20Sopenharmony_ci XMIT_SZ_128BIT = 3, 478c2ecf20Sopenharmony_ci XMIT_SZ_256BIT = 4, 488c2ecf20Sopenharmony_ci XMIT_SZ_128BIT_BLK = 0xb, 498c2ecf20Sopenharmony_ci XMIT_SZ_256BIT_BLK = 0xc, 508c2ecf20Sopenharmony_ci}; 518c2ecf20Sopenharmony_ci 528c2ecf20Sopenharmony_ci/* log2(size / 8) - used to calculate number of transfers */ 538c2ecf20Sopenharmony_ci#define TS_SHIFT { \ 548c2ecf20Sopenharmony_ci [XMIT_SZ_8BIT] = 0, \ 558c2ecf20Sopenharmony_ci [XMIT_SZ_16BIT] = 1, \ 568c2ecf20Sopenharmony_ci [XMIT_SZ_32BIT] = 2, \ 578c2ecf20Sopenharmony_ci [XMIT_SZ_64BIT] = 3, \ 588c2ecf20Sopenharmony_ci [XMIT_SZ_128BIT] = 4, \ 598c2ecf20Sopenharmony_ci [XMIT_SZ_256BIT] = 5, \ 608c2ecf20Sopenharmony_ci [XMIT_SZ_128BIT_BLK] = 4, \ 618c2ecf20Sopenharmony_ci [XMIT_SZ_256BIT_BLK] = 5, \ 628c2ecf20Sopenharmony_ci} 638c2ecf20Sopenharmony_ci 648c2ecf20Sopenharmony_ci#define TS_INDEX2VAL(i) ((((i) & 3) << CHCR_TS_LOW_SHIFT) | \ 658c2ecf20Sopenharmony_ci (((i) & 0xc) << CHCR_TS_HIGH_SHIFT)) 668c2ecf20Sopenharmony_ci 678c2ecf20Sopenharmony_ci#else /* CONFIG_CPU_SH4A */ 688c2ecf20Sopenharmony_ci 698c2ecf20Sopenharmony_ci#define DMAOR_INIT (0x8000 | DMAOR_DME) 708c2ecf20Sopenharmony_ci 718c2ecf20Sopenharmony_ci#define CHCR_TS_LOW_MASK 0x70 728c2ecf20Sopenharmony_ci#define CHCR_TS_LOW_SHIFT 4 738c2ecf20Sopenharmony_ci#define CHCR_TS_HIGH_MASK 0 748c2ecf20Sopenharmony_ci#define CHCR_TS_HIGH_SHIFT 0 758c2ecf20Sopenharmony_ci 768c2ecf20Sopenharmony_ci/* Transmit sizes and respective CHCR register values */ 778c2ecf20Sopenharmony_cienum { 788c2ecf20Sopenharmony_ci XMIT_SZ_8BIT = 1, 798c2ecf20Sopenharmony_ci XMIT_SZ_16BIT = 2, 808c2ecf20Sopenharmony_ci XMIT_SZ_32BIT = 3, 818c2ecf20Sopenharmony_ci XMIT_SZ_64BIT = 0, 828c2ecf20Sopenharmony_ci XMIT_SZ_256BIT = 4, 838c2ecf20Sopenharmony_ci}; 848c2ecf20Sopenharmony_ci 858c2ecf20Sopenharmony_ci/* log2(size / 8) - used to calculate number of transfers */ 868c2ecf20Sopenharmony_ci#define TS_SHIFT { \ 878c2ecf20Sopenharmony_ci [XMIT_SZ_8BIT] = 0, \ 888c2ecf20Sopenharmony_ci [XMIT_SZ_16BIT] = 1, \ 898c2ecf20Sopenharmony_ci [XMIT_SZ_32BIT] = 2, \ 908c2ecf20Sopenharmony_ci [XMIT_SZ_64BIT] = 3, \ 918c2ecf20Sopenharmony_ci [XMIT_SZ_256BIT] = 5, \ 928c2ecf20Sopenharmony_ci} 938c2ecf20Sopenharmony_ci 948c2ecf20Sopenharmony_ci#define TS_INDEX2VAL(i) (((i) & 7) << CHCR_TS_LOW_SHIFT) 958c2ecf20Sopenharmony_ci 968c2ecf20Sopenharmony_ci#endif /* CONFIG_CPU_SH4A */ 978c2ecf20Sopenharmony_ci 988c2ecf20Sopenharmony_ci#endif 99