18c2ecf20Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0 */ 28c2ecf20Sopenharmony_ci/* 38c2ecf20Sopenharmony_ci * sbi.h: SBI (Sbus Interface on sun4d) definitions 48c2ecf20Sopenharmony_ci * 58c2ecf20Sopenharmony_ci * Copyright (C) 1997 Jakub Jelinek <jj@sunsite.mff.cuni.cz> 68c2ecf20Sopenharmony_ci */ 78c2ecf20Sopenharmony_ci 88c2ecf20Sopenharmony_ci#ifndef _SPARC_SBI_H 98c2ecf20Sopenharmony_ci#define _SPARC_SBI_H 108c2ecf20Sopenharmony_ci 118c2ecf20Sopenharmony_ci#include <asm/obio.h> 128c2ecf20Sopenharmony_ci 138c2ecf20Sopenharmony_ci/* SBI */ 148c2ecf20Sopenharmony_cistruct sbi_regs { 158c2ecf20Sopenharmony_ci/* 0x0000 */ u32 cid; /* Component ID */ 168c2ecf20Sopenharmony_ci/* 0x0004 */ u32 ctl; /* Control */ 178c2ecf20Sopenharmony_ci/* 0x0008 */ u32 status; /* Status */ 188c2ecf20Sopenharmony_ci u32 _unused1; 198c2ecf20Sopenharmony_ci 208c2ecf20Sopenharmony_ci/* 0x0010 */ u32 cfg0; /* Slot0 config reg */ 218c2ecf20Sopenharmony_ci/* 0x0014 */ u32 cfg1; /* Slot1 config reg */ 228c2ecf20Sopenharmony_ci/* 0x0018 */ u32 cfg2; /* Slot2 config reg */ 238c2ecf20Sopenharmony_ci/* 0x001c */ u32 cfg3; /* Slot3 config reg */ 248c2ecf20Sopenharmony_ci 258c2ecf20Sopenharmony_ci/* 0x0020 */ u32 stb0; /* Streaming buf control for slot 0 */ 268c2ecf20Sopenharmony_ci/* 0x0024 */ u32 stb1; /* Streaming buf control for slot 1 */ 278c2ecf20Sopenharmony_ci/* 0x0028 */ u32 stb2; /* Streaming buf control for slot 2 */ 288c2ecf20Sopenharmony_ci/* 0x002c */ u32 stb3; /* Streaming buf control for slot 3 */ 298c2ecf20Sopenharmony_ci 308c2ecf20Sopenharmony_ci/* 0x0030 */ u32 intr_state; /* Interrupt state */ 318c2ecf20Sopenharmony_ci/* 0x0034 */ u32 intr_tid; /* Interrupt target ID */ 328c2ecf20Sopenharmony_ci/* 0x0038 */ u32 intr_diag; /* Interrupt diagnostics */ 338c2ecf20Sopenharmony_ci}; 348c2ecf20Sopenharmony_ci 358c2ecf20Sopenharmony_ci#define SBI_CID 0x02800000 368c2ecf20Sopenharmony_ci#define SBI_CTL 0x02800004 378c2ecf20Sopenharmony_ci#define SBI_STATUS 0x02800008 388c2ecf20Sopenharmony_ci#define SBI_CFG0 0x02800010 398c2ecf20Sopenharmony_ci#define SBI_CFG1 0x02800014 408c2ecf20Sopenharmony_ci#define SBI_CFG2 0x02800018 418c2ecf20Sopenharmony_ci#define SBI_CFG3 0x0280001c 428c2ecf20Sopenharmony_ci#define SBI_STB0 0x02800020 438c2ecf20Sopenharmony_ci#define SBI_STB1 0x02800024 448c2ecf20Sopenharmony_ci#define SBI_STB2 0x02800028 458c2ecf20Sopenharmony_ci#define SBI_STB3 0x0280002c 468c2ecf20Sopenharmony_ci#define SBI_INTR_STATE 0x02800030 478c2ecf20Sopenharmony_ci#define SBI_INTR_TID 0x02800034 488c2ecf20Sopenharmony_ci#define SBI_INTR_DIAG 0x02800038 498c2ecf20Sopenharmony_ci 508c2ecf20Sopenharmony_ci/* Burst bits for 8, 16, 32, 64 are in cfgX registers at bits 2, 3, 4, 5 respectively */ 518c2ecf20Sopenharmony_ci#define SBI_CFG_BURST_MASK 0x0000001e 528c2ecf20Sopenharmony_ci 538c2ecf20Sopenharmony_ci/* How to make devid from sbi no */ 548c2ecf20Sopenharmony_ci#define SBI2DEVID(sbino) ((sbino<<4)|2) 558c2ecf20Sopenharmony_ci 568c2ecf20Sopenharmony_ci/* intr_state has 4 bits for slots 0 .. 3 and these bits are repeated for each sbus irq level 578c2ecf20Sopenharmony_ci * 588c2ecf20Sopenharmony_ci * +-------+-------+-------+-------+-------+-------+-------+-------+ 598c2ecf20Sopenharmony_ci * SBUS IRQ LEVEL | 7 | 6 | 5 | 4 | 3 | 2 | 1 | | 608c2ecf20Sopenharmony_ci * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ Reser | 618c2ecf20Sopenharmony_ci * SLOT # |3|2|1|0|3|2|1|0|3|2|1|0|3|2|1|0|3|2|1|0|3|2|1|0|3|2|1|0| ved | 628c2ecf20Sopenharmony_ci * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-------+ 638c2ecf20Sopenharmony_ci * Bits 31 27 23 19 15 11 7 3 0 648c2ecf20Sopenharmony_ci */ 658c2ecf20Sopenharmony_ci 668c2ecf20Sopenharmony_ci 678c2ecf20Sopenharmony_ci#ifndef __ASSEMBLY__ 688c2ecf20Sopenharmony_ci 698c2ecf20Sopenharmony_cistatic inline int acquire_sbi(int devid, int mask) 708c2ecf20Sopenharmony_ci{ 718c2ecf20Sopenharmony_ci __asm__ __volatile__ ("swapa [%2] %3, %0" : 728c2ecf20Sopenharmony_ci "=r" (mask) : 738c2ecf20Sopenharmony_ci "0" (mask), 748c2ecf20Sopenharmony_ci "r" (ECSR_DEV_BASE(devid) | SBI_INTR_STATE), 758c2ecf20Sopenharmony_ci "i" (ASI_M_CTL)); 768c2ecf20Sopenharmony_ci return mask; 778c2ecf20Sopenharmony_ci} 788c2ecf20Sopenharmony_ci 798c2ecf20Sopenharmony_cistatic inline void release_sbi(int devid, int mask) 808c2ecf20Sopenharmony_ci{ 818c2ecf20Sopenharmony_ci __asm__ __volatile__ ("sta %0, [%1] %2" : : 828c2ecf20Sopenharmony_ci "r" (mask), 838c2ecf20Sopenharmony_ci "r" (ECSR_DEV_BASE(devid) | SBI_INTR_STATE), 848c2ecf20Sopenharmony_ci "i" (ASI_M_CTL)); 858c2ecf20Sopenharmony_ci} 868c2ecf20Sopenharmony_ci 878c2ecf20Sopenharmony_cistatic inline void set_sbi_tid(int devid, int targetid) 888c2ecf20Sopenharmony_ci{ 898c2ecf20Sopenharmony_ci __asm__ __volatile__ ("sta %0, [%1] %2" : : 908c2ecf20Sopenharmony_ci "r" (targetid), 918c2ecf20Sopenharmony_ci "r" (ECSR_DEV_BASE(devid) | SBI_INTR_TID), 928c2ecf20Sopenharmony_ci "i" (ASI_M_CTL)); 938c2ecf20Sopenharmony_ci} 948c2ecf20Sopenharmony_ci 958c2ecf20Sopenharmony_cistatic inline int get_sbi_ctl(int devid, int cfgno) 968c2ecf20Sopenharmony_ci{ 978c2ecf20Sopenharmony_ci int cfg; 988c2ecf20Sopenharmony_ci 998c2ecf20Sopenharmony_ci __asm__ __volatile__ ("lda [%1] %2, %0" : 1008c2ecf20Sopenharmony_ci "=r" (cfg) : 1018c2ecf20Sopenharmony_ci "r" ((ECSR_DEV_BASE(devid) | SBI_CFG0) + (cfgno<<2)), 1028c2ecf20Sopenharmony_ci "i" (ASI_M_CTL)); 1038c2ecf20Sopenharmony_ci return cfg; 1048c2ecf20Sopenharmony_ci} 1058c2ecf20Sopenharmony_ci 1068c2ecf20Sopenharmony_cistatic inline void set_sbi_ctl(int devid, int cfgno, int cfg) 1078c2ecf20Sopenharmony_ci{ 1088c2ecf20Sopenharmony_ci __asm__ __volatile__ ("sta %0, [%1] %2" : : 1098c2ecf20Sopenharmony_ci "r" (cfg), 1108c2ecf20Sopenharmony_ci "r" ((ECSR_DEV_BASE(devid) | SBI_CFG0) + (cfgno<<2)), 1118c2ecf20Sopenharmony_ci "i" (ASI_M_CTL)); 1128c2ecf20Sopenharmony_ci} 1138c2ecf20Sopenharmony_ci 1148c2ecf20Sopenharmony_ci#endif /* !__ASSEMBLY__ */ 1158c2ecf20Sopenharmony_ci 1168c2ecf20Sopenharmony_ci#endif /* !(_SPARC_SBI_H) */ 117