smdk2410_io_init.c revision 1.2
1/* $NetBSD: smdk2410_io_init.c,v 1.2 2005/12/11 12:17:09 christos Exp $ */
2
3/*
4 * Copyright (c) 2003 By Noon Software, Inc.  All rights reserved.
5 *
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions
8 * are met:
9 * 1. Redistributions of source code must retain the above copyright
10 *    notice, this list of conditions and the following disclaimer.
11 * 2. Redistributions in binary form must reproduce the above copyright
12 *    notice, this list of conditions and the following disclaimer in the
13 *    documentation and/or other materials provided with the distribution.
14 * 3. The names of the authors may not be used to endorse or promote products
15 *    derived from this software without specific prior written permission.
16 *
17 * THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS OR
18 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
19 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
20 * IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY DIRECT, INDIRECT,
21 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
22 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
26 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 */
28
29
30#include <arm/s3c2xx0/s3c2410reg.h>
31
32#define IOW(a, d)	(*(volatile unsigned int *)(a) = (d))
33#define IOR(a)		(*(volatile unsigned int *)(a))
34
35void smdk2410_io_init(void);
36
37void
38smdk2410_io_init(void)
39{
40#define	O	PCON_OUTPUT
41#define	I	PCON_INPUT
42#define	A	PCON_ALTFUN
43#define	_	0
44#define	_C(b15,b14,b13,b12,b11,b10,b9,b8,b7,b6,b5,b4,b3,b2,b1,b0) \
45	((b15<<30)|(b14<<28)|(b13<<26)|(b12<<24)|(b11<<22)|(b10<<20)|(b9<<18)|(b8<<16)|(b7<<14)|(b6<<12)|(b5<<10)|(b4<<8)|(b3<<6)|(b2<<4)|(b1<<2)|(b0<<0))
46
47	/* GPIO port */
48	IOW(S3C2410_GPIO_BASE+GPIO_PACON, 0x7fffff);
49	IOW(S3C2410_GPIO_BASE+GPIO_PBCON, _C(_,_,_,_,_,I,O,I,O,I,O,O,O,O,O,O));
50	IOW(S3C2410_GPIO_BASE+GPIO_PBUP, 0x07ff);
51	IOW(S3C2410_GPIO_BASE+GPIO_PCCON, _C(A,A,A,A,A,A,A,A,A,A,A,A,A,A,A,A));
52	IOW(S3C2410_GPIO_BASE+GPIO_PCUP, 0xffff);
53	IOW(S3C2410_GPIO_BASE+GPIO_PDCON, _C(A,A,A,A,A,A,A,A,A,A,A,A,A,A,A,A));
54	IOW(S3C2410_GPIO_BASE+GPIO_PDUP, 0xffff);
55	IOW(S3C2410_GPIO_BASE+GPIO_PECON, _C(A,A,A,A,A,A,A,A,A,A,A,A,A,A,A,A));
56	IOW(S3C2410_GPIO_BASE+GPIO_PEUP, 0xffff);
57	IOW(S3C2410_GPIO_BASE+GPIO_PFCON, _C(_,_,_,_,_,_,_,_,O,O,O,O,A,A,A,A));
58	IOW(S3C2410_GPIO_BASE+GPIO_PFUP, 0x00ff);
59	IOW(S3C2410_GPIO_BASE+GPIO_PGCON, _C(3,3,3,3,A,O,O,O,3,3,3,3,A,3,A,A));
60	IOW(S3C2410_GPIO_BASE+GPIO_PGUP, 0xffff);
61	IOW(S3C2410_GPIO_BASE+GPIO_PHCON, _C(_,_,_,_,_,A,A,A,3,3,A,A,A,A,A,A));
62	IOW(S3C2410_GPIO_BASE+GPIO_PHUP, 0x07ff);
63	IOW(S3C2410_GPIO_BASE+GPIO_EXTINT(0), 0x22222222);
64	IOW(S3C2410_GPIO_BASE+GPIO_EXTINT(1), 0x22222222);
65	IOW(S3C2410_GPIO_BASE+GPIO_EXTINT(2), 0x22222222);
66
67#undef	O
68#undef	I
69#undef	A
70#undef	_
71#undef 	_C
72
73	/* Interrupt controller */
74	IOW(S3C2410_INTCTL_BASE+INTCTL_INTMOD, 0);
75	IOW(S3C2410_INTCTL_BASE+INTCTL_INTMSK, 0);
76}
77