smdk2800.c revision 1.2 1 1.2 mycroft /* $NetBSD: smdk2800.c,v 1.2 2003/09/03 03:18:31 mycroft Exp $ */
2 1.1 bsh
3 1.1 bsh /*
4 1.1 bsh * Copyright (c) 2002, 2003 Fujitsu Component Limited
5 1.1 bsh * Copyright (c) 2002, 2003 Genetec Corporation
6 1.1 bsh * All rights reserved.
7 1.1 bsh *
8 1.1 bsh * Redistribution and use in source and binary forms, with or without
9 1.1 bsh * modification, are permitted provided that the following conditions
10 1.1 bsh * are met:
11 1.1 bsh * 1. Redistributions of source code must retain the above copyright
12 1.1 bsh * notice, this list of conditions and the following disclaimer.
13 1.1 bsh * 2. Redistributions in binary form must reproduce the above copyright
14 1.1 bsh * notice, this list of conditions and the following disclaimer in the
15 1.1 bsh * documentation and/or other materials provided with the distribution.
16 1.1 bsh * 3. Neither the name of The Fujitsu Component Limited nor the name of
17 1.1 bsh * Genetec corporation may not be used to endorse or promote products
18 1.1 bsh * derived from this software without specific prior written permission.
19 1.1 bsh *
20 1.1 bsh * THIS SOFTWARE IS PROVIDED BY FUJITSU COMPONENT LIMITED AND GENETEC
21 1.1 bsh * CORPORATION ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
22 1.1 bsh * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
23 1.1 bsh * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
24 1.1 bsh * DISCLAIMED. IN NO EVENT SHALL FUJITSU COMPONENT LIMITED OR GENETEC
25 1.1 bsh * CORPORATION BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
26 1.1 bsh * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
27 1.1 bsh * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
28 1.1 bsh * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
29 1.1 bsh * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
30 1.1 bsh * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
31 1.1 bsh * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
32 1.1 bsh * SUCH DAMAGE.
33 1.1 bsh */
34 1.1 bsh
35 1.1 bsh /*
36 1.1 bsh * Board initialization routines for the Samsung's SMDK2800.
37 1.1 bsh */
38 1.1 bsh
39 1.1 bsh #include <sys/types.h>
40 1.1 bsh #include <lib/libsa/stand.h>
41 1.1 bsh #include <arch/arm/s3c2xx0/s3c2800reg.h>
42 1.1 bsh
43 1.1 bsh #include "board.h"
44 1.1 bsh
45 1.1 bsh #define RAM_START 0x08000000
46 1.1 bsh #define RAM_SIZE 0x02000000
47 1.1 bsh
48 1.1 bsh void
49 1.1 bsh board_init(void)
50 1.1 bsh {
51 1.1 bsh mem_init();
52 1.1 bsh }
53 1.1 bsh
54 1.1 bsh void
55 1.1 bsh board_fini(void)
56 1.1 bsh {
57 1.1 bsh
58 1.1 bsh /* Nothing to do here. */
59 1.1 bsh }
60 1.1 bsh
61 1.1 bsh void
62 1.1 bsh mem_init(void)
63 1.1 bsh {
64 1.1 bsh uint32_t start, size, heap;
65 1.1 bsh
66 1.1 bsh start = RAM_START;
67 1.1 bsh size = RAM_SIZE;
68 1.1 bsh /* ROM monitor uses top of SDRAM for page table. */
69 1.1 bsh #define ROMMONITOR_PAGETABLE (RAM_START+RAM_SIZE-0x8000)
70 1.1 bsh
71 1.1 bsh heap = ROMMONITOR_PAGETABLE - HEAP_SIZE;
72 1.1 bsh
73 1.1 bsh printf(">> RAM 0x%x - 0x%x, heap at 0x%x\n",
74 1.1 bsh start, (start + size) - 1, heap);
75 1.1 bsh setheap((void *)heap, (void *)(heap + HEAP_SIZE - 1));
76 1.1 bsh }
77 1.1 bsh
78 1.1 bsh #ifdef SELFCOPY_TO_FLASH
79 1.1 bsh #include "flash.h"
80 1.1 bsh
81 1.1 bsh void
82 1.1 bsh protect_flash(int protect_on)
83 1.1 bsh {
84 1.1 bsh volatile uint8_t *gpdatc =
85 1.1 bsh (volatile uint8_t *)(S3C2800_GPIO_BASE+GPIO_PDATC);
86 1.1 bsh
87 1.1 bsh if (protect_on)
88 1.1 bsh *gpdatc &= (1<<3);
89 1.1 bsh else
90 1.1 bsh *gpdatc |= (1<<3);
91 1.1 bsh }
92 1.1 bsh
93 1.1 bsh int
94 1.1 bsh get_flash_info(void *addr, struct flash_info *info)
95 1.1 bsh {
96 1.1 bsh get_flash_chip_info(addr, info);
97 1.1 bsh
98 1.1 bsh info->page_size *= 2;
99 1.1 bsh info->data_width *= 2;
100 1.1 bsh info->writebuf_len *= 2;
101 1.1 bsh
102 1.1 bsh return 0;
103 1.1 bsh }
104 1.1 bsh #endif
105 1.2 mycroft
106 1.2 mycroft long get_com_freq(void);
107 1.2 mycroft long
108 1.2 mycroft get_com_freq(void)
109 1.2 mycroft {
110 1.2 mycroft long clk;
111 1.2 mycroft uint16_t clkcon = *(volatile uint16_t*)(S3C2800_CLKMAN_BASE+CLKMAN_CLKCON);
112 1.2 mycroft uint32_t pllcon = *(volatile uint32_t*)(S3C2800_CLKMAN_BASE+CLKMAN_PLLCON);
113 1.2 mycroft
114 1.2 mycroft int mdiv = (pllcon & PLLCON_MDIV_MASK) >> PLLCON_MDIV_SHIFT;
115 1.2 mycroft int pdiv = (pllcon & PLLCON_PDIV_MASK) >> PLLCON_PDIV_SHIFT;
116 1.2 mycroft int sdiv = (pllcon & PLLCON_SDIV_MASK) >> PLLCON_SDIV_SHIFT;
117 1.2 mycroft
118 1.2 mycroft #if XTAL_CLK < 1000 /* in MHz */
119 1.2 mycroft clk = (XTAL_CLK * 1000000 * (8 + mdiv)) / ((pdiv + 2) << sdiv);
120 1.2 mycroft #else /* in Hz */
121 1.2 mycroft clk = (XTAL_CLK * (8 + mdiv)) / ((pdiv + 2) << sdiv);
122 1.2 mycroft #endif
123 1.2 mycroft
124 1.2 mycroft /*printf( "M=%d P=%d S=%d\n", mdiv, pdiv, sdiv);*/
125 1.2 mycroft
126 1.2 mycroft if (clkcon & CLKCON_HCLK)
127 1.2 mycroft clk /= 2;
128 1.2 mycroft if (clkcon & CLKCON_PCLK)
129 1.2 mycroft clk /= 2;
130 1.2 mycroft
131 1.2 mycroft return clk;
132 1.2 mycroft }
133