Sync usage with man page.
[netbsd-mini2440.git] / sys / arch / sh3 / include / devreg.h
blob344ed8f0655cf5fe0107b04c586e01aefd33a4a0
1 /* $NetBSD: devreg.h,v 1.5 2006/01/21 04:57:07 uwe Exp $ */
3 /*-
4 * Copyright (c) 2002 The NetBSD Foundation, Inc.
5 * All rights reserved.
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
9 * are met:
10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer.
12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution.
16 * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
17 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
18 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
19 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
20 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
21 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
22 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
23 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
24 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
25 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
26 * POSSIBILITY OF SUCH DAMAGE.
29 #ifndef _SH3_DEVREG_H_
30 #define _SH3_DEVREG_H_
32 * SH embeded device register defines.
36 * Access method
38 #define _reg_read_1(a) (*(volatile uint8_t *)((vaddr_t)(a)))
39 #define _reg_read_2(a) (*(volatile uint16_t *)((vaddr_t)(a)))
40 #define _reg_read_4(a) (*(volatile uint32_t *)((vaddr_t)(a)))
41 #define _reg_write_1(a, v) \
42 (*(volatile uint8_t *)(a) = (uint8_t)(v))
43 #define _reg_write_2(a, v) \
44 (*(volatile uint16_t *)(a) = (uint16_t)(v))
45 #define _reg_write_4(a, v) \
46 (*(volatile uint32_t *)(a) = (uint32_t)(v))
47 #define _reg_bset_1(a, v) \
48 (*(volatile uint8_t *)(a) |= (uint8_t)(v))
49 #define _reg_bset_2(a, v) \
50 (*(volatile uint16_t *)(a) |= (uint16_t)(v))
51 #define _reg_bset_4(a, v) \
52 (*(volatile uint32_t *)(a) |= (uint32_t)(v))
53 #define _reg_bclr_1(a, v) \
54 (*(volatile uint8_t *)(a) &= ~(uint8_t)(v))
55 #define _reg_bclr_2(a, v) \
56 (*(volatile uint16_t *)(a) &= ~(uint16_t)(v))
57 #define _reg_bclr_4(a, v) \
58 (*(volatile uint32_t *)(a) &= ~(uint32_t)(v))
61 * Register address.
63 #if defined(SH3) && defined(SH4)
64 #define SH_(x) __sh_ ## x
65 #elif defined(SH3)
66 #define SH_(x) SH3_ ## x
67 #elif defined(SH4)
68 #define SH_(x) SH4_ ## x
69 #endif
71 #ifndef _LOCORE
72 /* Initialize register address for SH3 && SH4 kernel. */
73 void sh_devreg_init(void);
74 #endif
75 #endif /* !_SH3_DEVREG_H_ */