162306a36Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0 */
262306a36Sopenharmony_ci/* io-unit.h: Definitions for the sun4d IO-UNIT.
362306a36Sopenharmony_ci *
462306a36Sopenharmony_ci * Copyright (C) 1997,1998 Jakub Jelinek (jj@sunsite.mff.cuni.cz)
562306a36Sopenharmony_ci */
662306a36Sopenharmony_ci#ifndef _SPARC_IO_UNIT_H
762306a36Sopenharmony_ci#define _SPARC_IO_UNIT_H
862306a36Sopenharmony_ci
962306a36Sopenharmony_ci#include <linux/spinlock.h>
1062306a36Sopenharmony_ci#include <linux/pgtable.h>
1162306a36Sopenharmony_ci#include <asm/page.h>
1262306a36Sopenharmony_ci
1362306a36Sopenharmony_ci/* The io-unit handles all virtual to physical address translations
1462306a36Sopenharmony_ci * that occur between the SBUS and physical memory.  Access by
1562306a36Sopenharmony_ci * the cpu to IO registers and similar go over the xdbus so are
1662306a36Sopenharmony_ci * translated by the on chip SRMMU.  The io-unit and the srmmu do
1762306a36Sopenharmony_ci * not need to have the same translations at all, in fact most
1862306a36Sopenharmony_ci * of the time the translations they handle are a disjunct set.
1962306a36Sopenharmony_ci * Basically the io-unit handles all dvma sbus activity.
2062306a36Sopenharmony_ci */
2162306a36Sopenharmony_ci
2262306a36Sopenharmony_ci/* AIEEE, unlike the nice sun4m, these monsters have
2362306a36Sopenharmony_ci   fixed DMA range 64M */
2462306a36Sopenharmony_ci
2562306a36Sopenharmony_ci#define IOUNIT_DMA_BASE	    0xfc000000 /* TOP - 64M */
2662306a36Sopenharmony_ci#define IOUNIT_DMA_SIZE	    0x04000000 /* 64M */
2762306a36Sopenharmony_ci/* We use last 1M for sparc_dvma_malloc */
2862306a36Sopenharmony_ci#define IOUNIT_DVMA_SIZE    0x00100000 /* 1M */
2962306a36Sopenharmony_ci
3062306a36Sopenharmony_ci/* The format of an iopte in the external page tables */
3162306a36Sopenharmony_ci#define IOUPTE_PAGE          0xffffff00 /* Physical page number (PA[35:12])	*/
3262306a36Sopenharmony_ci#define IOUPTE_CACHE         0x00000080 /* Cached (in Viking/MXCC)		*/
3362306a36Sopenharmony_ci/* XXX Jakub, find out how to program SBUS streaming cache on XDBUS/sun4d.
3462306a36Sopenharmony_ci * XXX Actually, all you should need to do is find out where the registers
3562306a36Sopenharmony_ci * XXX are and copy over the sparc64 implementation I wrote.  There may be
3662306a36Sopenharmony_ci * XXX some horrible hwbugs though, so be careful.  -DaveM
3762306a36Sopenharmony_ci */
3862306a36Sopenharmony_ci#define IOUPTE_STREAM        0x00000040 /* Translation can use streaming cache	*/
3962306a36Sopenharmony_ci#define IOUPTE_INTRA	     0x00000008 /* SBUS direct slot->slot transfer	*/
4062306a36Sopenharmony_ci#define IOUPTE_WRITE         0x00000004 /* Writeable				*/
4162306a36Sopenharmony_ci#define IOUPTE_VALID         0x00000002 /* IOPTE is valid			*/
4262306a36Sopenharmony_ci#define IOUPTE_PARITY        0x00000001 /* Parity is checked during DVMA	*/
4362306a36Sopenharmony_ci
4462306a36Sopenharmony_cistruct iounit_struct {
4562306a36Sopenharmony_ci	unsigned long		bmap[(IOUNIT_DMA_SIZE >> (PAGE_SHIFT + 3)) / sizeof(unsigned long)];
4662306a36Sopenharmony_ci	spinlock_t		lock;
4762306a36Sopenharmony_ci	iopte_t __iomem		*page_table;
4862306a36Sopenharmony_ci	unsigned long		rotor[3];
4962306a36Sopenharmony_ci	unsigned long		limit[4];
5062306a36Sopenharmony_ci};
5162306a36Sopenharmony_ci
5262306a36Sopenharmony_ci#define IOUNIT_BMAP1_START	0x00000000
5362306a36Sopenharmony_ci#define IOUNIT_BMAP1_END	(IOUNIT_DMA_SIZE >> (PAGE_SHIFT + 1))
5462306a36Sopenharmony_ci#define IOUNIT_BMAP2_START	IOUNIT_BMAP1_END
5562306a36Sopenharmony_ci#define IOUNIT_BMAP2_END	IOUNIT_BMAP2_START + (IOUNIT_DMA_SIZE >> (PAGE_SHIFT + 2))
5662306a36Sopenharmony_ci#define IOUNIT_BMAPM_START	IOUNIT_BMAP2_END
5762306a36Sopenharmony_ci#define IOUNIT_BMAPM_END	((IOUNIT_DMA_SIZE - IOUNIT_DVMA_SIZE) >> PAGE_SHIFT)
5862306a36Sopenharmony_ci
5962306a36Sopenharmony_ci#endif /* !(_SPARC_IO_UNIT_H) */
60