1*d874cce4Sray /* $OpenBSD: devreg.h,v 1.3 2008/06/26 05:42:12 ray Exp $ */ 295c7671fSmiod /* $NetBSD: devreg.h,v 1.5 2006/01/21 04:57:07 uwe Exp $ */ 395c7671fSmiod 495c7671fSmiod /*- 595c7671fSmiod * Copyright (c) 2002 The NetBSD Foundation, Inc. 695c7671fSmiod * All rights reserved. 795c7671fSmiod * 895c7671fSmiod * Redistribution and use in source and binary forms, with or without 995c7671fSmiod * modification, are permitted provided that the following conditions 1095c7671fSmiod * are met: 1195c7671fSmiod * 1. Redistributions of source code must retain the above copyright 1295c7671fSmiod * notice, this list of conditions and the following disclaimer. 1395c7671fSmiod * 2. Redistributions in binary form must reproduce the above copyright 1495c7671fSmiod * notice, this list of conditions and the following disclaimer in the 1595c7671fSmiod * documentation and/or other materials provided with the distribution. 1695c7671fSmiod * 1795c7671fSmiod * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS 1895c7671fSmiod * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 1995c7671fSmiod * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 2095c7671fSmiod * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS 2195c7671fSmiod * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 2295c7671fSmiod * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 2395c7671fSmiod * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 2495c7671fSmiod * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 2595c7671fSmiod * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 2695c7671fSmiod * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 2795c7671fSmiod * POSSIBILITY OF SUCH DAMAGE. 2895c7671fSmiod */ 2995c7671fSmiod 3095c7671fSmiod #ifndef _SH_DEVREG_H_ 3195c7671fSmiod #define _SH_DEVREG_H_ 3295c7671fSmiod /* 33f8a2ef0eSmartin * SH embedded device register defines. 3495c7671fSmiod */ 3595c7671fSmiod 3695c7671fSmiod /* 3795c7671fSmiod * Access method 3895c7671fSmiod */ 3995c7671fSmiod #define _reg_read_1(a) (*(volatile uint8_t *)((vaddr_t)(a))) 4095c7671fSmiod #define _reg_read_2(a) (*(volatile uint16_t *)((vaddr_t)(a))) 4195c7671fSmiod #define _reg_read_4(a) (*(volatile uint32_t *)((vaddr_t)(a))) 4295c7671fSmiod #define _reg_write_1(a, v) \ 4395c7671fSmiod (*(volatile uint8_t *)(a) = (uint8_t)(v)) 4495c7671fSmiod #define _reg_write_2(a, v) \ 4595c7671fSmiod (*(volatile uint16_t *)(a) = (uint16_t)(v)) 4695c7671fSmiod #define _reg_write_4(a, v) \ 4795c7671fSmiod (*(volatile uint32_t *)(a) = (uint32_t)(v)) 4895c7671fSmiod #define _reg_bset_1(a, v) \ 4995c7671fSmiod (*(volatile uint8_t *)(a) |= (uint8_t)(v)) 5095c7671fSmiod #define _reg_bset_2(a, v) \ 5195c7671fSmiod (*(volatile uint16_t *)(a) |= (uint16_t)(v)) 5295c7671fSmiod #define _reg_bset_4(a, v) \ 5395c7671fSmiod (*(volatile uint32_t *)(a) |= (uint32_t)(v)) 5495c7671fSmiod #define _reg_bclr_1(a, v) \ 5595c7671fSmiod (*(volatile uint8_t *)(a) &= ~(uint8_t)(v)) 5695c7671fSmiod #define _reg_bclr_2(a, v) \ 5795c7671fSmiod (*(volatile uint16_t *)(a) &= ~(uint16_t)(v)) 5895c7671fSmiod #define _reg_bclr_4(a, v) \ 5995c7671fSmiod (*(volatile uint32_t *)(a) &= ~(uint32_t)(v)) 6095c7671fSmiod 6195c7671fSmiod /* 6295c7671fSmiod * Register address. 6395c7671fSmiod */ 6495c7671fSmiod #if defined(SH3) && defined(SH4) 6595c7671fSmiod #define SH_(x) __sh_ ## x 6695c7671fSmiod #elif defined(SH3) 6795c7671fSmiod #define SH_(x) SH3_ ## x 6895c7671fSmiod #elif defined(SH4) 6995c7671fSmiod #define SH_(x) SH4_ ## x 7095c7671fSmiod #endif 7195c7671fSmiod 7295c7671fSmiod #ifndef _LOCORE 7395c7671fSmiod /* Initialize register address for SH3 && SH4 kernel. */ 7495c7671fSmiod void sh_devreg_init(void); 7595c7671fSmiod #endif 7695c7671fSmiod #endif /* !_SH_DEVREG_H_ */ 77