36ef1d27cb1fb977c95d220241e3040bc1917d65
[firefly-linux-kernel-4.4.55.git] / arch / arm / mach-rk2818 / board-midsdk.c
1 /* linux/arch/arm/mach-rk2818/board-midsdk.c
2  *
3  * Copyright (C) 2010 ROCKCHIP, Inc.
4  *
5  * This software is licensed under the terms of the GNU General Public
6  * License version 2, as published by the Free Software Foundation, and
7  * may be copied, distributed, and modified under those terms.
8  *
9  * This program is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12  * GNU General Public License for more details.
13  *
14  */
15
16 #include <linux/kernel.h>
17 #include <linux/init.h>
18 #include <linux/platform_device.h>
19 #include <linux/input.h>
20 #include <linux/io.h>
21 #include <linux/delay.h>
22
23 #include <mach/hardware.h>
24 #include <asm/mach-types.h>
25 #include <asm/mach/arch.h>
26 #include <asm/mach/map.h>
27 #include <asm/mach/flash.h>
28
29 #include <mach/irqs.h>
30 #include <mach/board.h>
31 #include <mach/rk2818_iomap.h>
32 #include <mach/iomux.h>
33 #include <mach/gpio.h>
34
35 #include <linux/mtd/nand.h>
36 #include <linux/mtd/partitions.h>
37
38 #include "devices.h"
39
40
41 /* --------------------------------------------------------------------
42  *  ÉùÃ÷ÁËrk2818_gpioBankÊý×飬²¢¶¨ÒåÁËGPIO¼Ä´æÆ÷×éIDºÍ¼Ä´æÆ÷»ùµØÖ·¡£
43  * -------------------------------------------------------------------- */
44
45 static struct rk2818_gpio_bank rk2818_gpioBank[] = {
46                 {
47                 .id             = RK2818_ID_PIOA,
48                 .offset         = RK2818_GPIO0_BASE,
49                 .clock          = NULL,
50         }, 
51                 {
52                 .id             = RK2818_ID_PIOB,
53                 .offset         = RK2818_GPIO0_BASE,
54                 .clock          = NULL,
55         }, 
56                 {
57                 .id             = RK2818_ID_PIOC,
58                 .offset         = RK2818_GPIO0_BASE,
59                 .clock          = NULL,
60         }, 
61                 {
62                 .id             = RK2818_ID_PIOD,
63                 .offset         = RK2818_GPIO0_BASE,
64                 .clock          = NULL,
65         },
66                 {
67                 .id             = RK2818_ID_PIOE,
68                 .offset         = RK2818_GPIO1_BASE,
69                 .clock          = NULL,
70         },
71                 {
72                 .id             = RK2818_ID_PIOF,
73                 .offset         = RK2818_GPIO1_BASE,
74                 .clock          = NULL,
75         },
76                 {
77                 .id             = RK2818_ID_PIOG,
78                 .offset         = RK2818_GPIO1_BASE,
79                 .clock          = NULL,
80         },
81                 {
82                 .id             = RK2818_ID_PIOH,
83                 .offset         = RK2818_GPIO1_BASE,
84                 .clock          = NULL,
85         }
86 };
87
88 //IOÓ³É䷽ʽÃèÊö £¬Ã¿¸öΪһ¶ÎÏßÐÔÁ¬ÐøÓ³Éä
89 static struct map_desc rk2818_io_desc[] __initdata = {
90
91         {
92                 .virtual        = RK2818_MCDMA_BASE,                                    //ÐéÄâµØÖ·
93                 .pfn            = __phys_to_pfn(RK2818_MCDMA_PHYS),    //ÎïÀíµØÖ·£¬ÐëÓëÒ³±í¶ÔÆë
94                 .length         = RK2818_MCDMA_SIZE,                                                    //³¤¶È
95                 .type           = MT_DEVICE                                                     //Ó³É䷽ʽ
96         },
97         
98         {
99                 .virtual        = RK2818_DWDMA_BASE,                                    
100                 .pfn            = __phys_to_pfn(RK2818_DWDMA_PHYS),    
101                 .length         = RK2818_DWDMA_SIZE,                                            
102                 .type           = MT_DEVICE                                                     
103         },
104         
105         {
106                 .virtual        = RK2818_INTC_BASE,                                     
107                 .pfn            = __phys_to_pfn(RK2818_INTC_PHYS),   
108                 .length         = RK2818_INTC_SIZE,                                     
109                 .type           = MT_DEVICE                                             
110         },
111         
112         {
113                 .virtual        = RK2818_ARMDARBITER_BASE,                                      
114                 .pfn            = __phys_to_pfn(RK2818_ARMDARBITER_PHYS),    
115                 .length         = RK2818_ARMDARBITER_SIZE,                                              
116                 .type           = MT_DEVICE                                                     
117         },
118         
119         {
120                 .virtual        = RK2818_APB_BASE,
121                 .pfn            = __phys_to_pfn(RK2818_APB_PHYS),
122                 .length         = 0xa0000,                     
123                 .type           = MT_DEVICE
124         },
125         
126         {
127                 .virtual        = RK2818_WDT_BASE,
128                 .pfn            = __phys_to_pfn(RK2818_WDT_PHYS),
129                 .length         = 0xa0000,                      ///apb bus i2s i2c spi no map in this
130                 .type           = MT_DEVICE
131         },
132         
133     {
134                 .virtual        = 0xff400000,           /* for itcm , vir = phy , for reboot */
135                 .pfn            = __phys_to_pfn(0xff400000),
136                 .length         = SZ_16K,
137                 .type           = MT_DEVICE
138         }
139                 
140 };
141
142 static struct platform_device *devices[] __initdata = {
143         &rk2818_device_uart1,
144 };
145
146 extern struct sys_timer rk2818_timer;
147
148 static void __init machine_rk2818_init_irq(void)
149 {
150         rk2818_init_irq();
151         rk2818_gpio_init(rk2818_gpioBank, 8);
152         rk2818_gpio_irq_setup();
153 }
154
155 static void __init machine_rk2818_board_init(void)
156 {
157         platform_add_devices(devices, ARRAY_SIZE(devices));
158
159 }
160
161 static void __init machine_rk2818_mapio(void)
162 {
163         iotable_init(rk2818_io_desc, ARRAY_SIZE(rk2818_io_desc));
164         rk2818_clock_init();
165         rk2818_iomux_init();    
166 }
167
168 MACHINE_START(RK2818, "rk2818midsdk")
169
170 /* UART for LL DEBUG */
171         .phys_io        = 0x18002000,
172         .io_pg_offst    = ((0xFF100000) >> 18) & 0xfffc,
173         .boot_params    = RK2818_SDRAM_PHYS + 0x100,
174         .map_io         = machine_rk2818_mapio,
175         .init_irq       = machine_rk2818_init_irq,
176         .init_machine   = machine_rk2818_board_init,
177         .timer          = &rk2818_timer,
178 MACHINE_END