]> Pileus Git - ~andy/linux/blob - arch/arm/mach-clps711x/board-p720t.c
ARM: clps711x: Re-add GPIO support
[~andy/linux] / arch / arm / mach-clps711x / board-p720t.c
1 /*
2  *  linux/arch/arm/mach-clps711x/p720t.c
3  *
4  *  Copyright (C) 2000-2001 Deep Blue Solutions Ltd
5  *
6  * This program is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation; either version 2 of the License, or
9  * (at your option) any later version.
10  *
11  * This program is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with this program; if not, write to the Free Software
18  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
19  */
20 #include <linux/kernel.h>
21 #include <linux/init.h>
22 #include <linux/types.h>
23 #include <linux/string.h>
24 #include <linux/mm.h>
25 #include <linux/io.h>
26 #include <linux/slab.h>
27 #include <linux/leds.h>
28 #include <linux/sizes.h>
29 #include <linux/backlight.h>
30 #include <linux/platform_device.h>
31 #include <linux/mtd/partitions.h>
32 #include <linux/mtd/nand-gpio.h>
33
34 #include <mach/hardware.h>
35 #include <asm/pgtable.h>
36 #include <asm/page.h>
37 #include <asm/setup.h>
38 #include <asm/mach-types.h>
39 #include <asm/mach/arch.h>
40 #include <asm/mach/map.h>
41 #include <mach/syspld.h>
42
43 #include <video/platform_lcd.h>
44
45 #include "common.h"
46 #include "devices.h"
47
48 #define P720T_USERLED           CLPS711X_GPIO(3, 0)
49 #define P720T_NAND_CLE          CLPS711X_GPIO(4, 0)
50 #define P720T_NAND_ALE          CLPS711X_GPIO(4, 1)
51 #define P720T_NAND_NCE          CLPS711X_GPIO(4, 2)
52
53 #define P720T_NAND_BASE         (CLPS711X_SDRAM1_BASE)
54
55 static struct resource p720t_nand_resource[] __initdata = {
56         DEFINE_RES_MEM(P720T_NAND_BASE, SZ_4),
57 };
58
59 static struct mtd_partition p720t_nand_parts[] __initdata = {
60         {
61                 .name   = "Flash partition 1",
62                 .offset = 0,
63                 .size   = SZ_2M,
64         },
65         {
66                 .name   = "Flash partition 2",
67                 .offset = MTDPART_OFS_APPEND,
68                 .size   = MTDPART_SIZ_FULL,
69         },
70 };
71
72 static struct gpio_nand_platdata p720t_nand_pdata __initdata = {
73         .gpio_rdy       = -1,
74         .gpio_nce       = P720T_NAND_NCE,
75         .gpio_ale       = P720T_NAND_ALE,
76         .gpio_cle       = P720T_NAND_CLE,
77         .gpio_nwp       = -1,
78         .chip_delay     = 15,
79         .parts          = p720t_nand_parts,
80         .num_parts      = ARRAY_SIZE(p720t_nand_parts),
81 };
82
83 static struct platform_device p720t_nand_pdev __initdata = {
84         .name           = "gpio-nand",
85         .id             = -1,
86         .resource       = p720t_nand_resource,
87         .num_resources  = ARRAY_SIZE(p720t_nand_resource),
88         .dev            = {
89                 .platform_data = &p720t_nand_pdata,
90         },
91 };
92
93 static void p720t_lcd_power_set(struct plat_lcd_data *pd, unsigned int power)
94 {
95         if (power) {
96                 PLD_LCDEN = PLD_LCDEN_EN;
97                 PLD_PWR |= PLD_S4_ON | PLD_S2_ON | PLD_S1_ON;
98         } else {
99                 PLD_PWR &= ~(PLD_S4_ON | PLD_S2_ON | PLD_S1_ON);
100                 PLD_LCDEN = 0;
101         }
102 }
103
104 static struct plat_lcd_data p720t_lcd_power_pdata = {
105         .set_power      = p720t_lcd_power_set,
106 };
107
108 static void p720t_lcd_backlight_set_intensity(int intensity)
109 {
110         if (intensity)
111                 PLD_PWR |= PLD_S3_ON;
112         else
113                 PLD_PWR = 0;
114 }
115
116 static struct generic_bl_info p720t_lcd_backlight_pdata = {
117         .name                   = "lcd-backlight.0",
118         .default_intensity      = 0x01,
119         .max_intensity          = 0x01,
120         .set_bl_intensity       = p720t_lcd_backlight_set_intensity,
121 };
122
123 /*
124  * Map the P720T system PLD. It occupies two address spaces:
125  * 0x10000000 and 0x10400000. We map both regions as one.
126  */
127 static struct map_desc p720t_io_desc[] __initdata = {
128         {
129                 .virtual        = SYSPLD_VIRT_BASE,
130                 .pfn            = __phys_to_pfn(SYSPLD_PHYS_BASE),
131                 .length         = SZ_8M,
132                 .type           = MT_DEVICE,
133         },
134 };
135
136 static void __init
137 fixup_p720t(struct tag *tag, char **cmdline, struct meminfo *mi)
138 {
139         /*
140          * Our bootloader doesn't setup any tags (yet).
141          */
142         if (tag->hdr.tag != ATAG_CORE) {
143                 tag->hdr.tag = ATAG_CORE;
144                 tag->hdr.size = tag_size(tag_core);
145                 tag->u.core.flags = 0;
146                 tag->u.core.pagesize = PAGE_SIZE;
147                 tag->u.core.rootdev = 0x0100;
148
149                 tag = tag_next(tag);
150                 tag->hdr.tag = ATAG_MEM;
151                 tag->hdr.size = tag_size(tag_mem32);
152                 tag->u.mem.size = 4096;
153                 tag->u.mem.start = PHYS_OFFSET;
154
155                 tag = tag_next(tag);
156                 tag->hdr.tag = ATAG_NONE;
157                 tag->hdr.size = 0;
158         }
159 }
160
161 static void __init p720t_map_io(void)
162 {
163         clps711x_map_io();
164         iotable_init(p720t_io_desc, ARRAY_SIZE(p720t_io_desc));
165 }
166
167 static void __init p720t_init_early(void)
168 {
169         /*
170          * Power down as much as possible in case we don't
171          * have the drivers loaded.
172          */
173         PLD_LCDEN = 0;
174         PLD_PWR  &= ~(PLD_S4_ON|PLD_S3_ON|PLD_S2_ON|PLD_S1_ON);
175
176         PLD_KBD   = 0;
177         PLD_IO    = 0;
178         PLD_IRDA  = 0;
179         PLD_CODEC = 0;
180         PLD_TCH   = 0;
181         PLD_SPI   = 0;
182         if (!IS_ENABLED(CONFIG_DEBUG_LL)) {
183                 PLD_COM2 = 0;
184                 PLD_COM1 = 0;
185         }
186 }
187
188 static struct gpio_led p720t_gpio_leds[] = {
189         {
190                 .name                   = "User LED",
191                 .default_trigger        = "heartbeat",
192                 .gpio                   = P720T_USERLED,
193         },
194 };
195
196 static struct gpio_led_platform_data p720t_gpio_led_pdata __initdata = {
197         .leds           = p720t_gpio_leds,
198         .num_leds       = ARRAY_SIZE(p720t_gpio_leds),
199 };
200
201 static void __init p720t_init(void)
202 {
203         clps711x_devices_init();
204 }
205
206 static void __init p720t_init_late(void)
207 {
208         platform_device_register(&p720t_nand_pdev);
209         platform_device_register_data(&platform_bus, "platform-lcd", 0,
210                                       &p720t_lcd_power_pdata,
211                                       sizeof(p720t_lcd_power_pdata));
212         platform_device_register_data(&platform_bus, "generic-bl", 0,
213                                       &p720t_lcd_backlight_pdata,
214                                       sizeof(p720t_lcd_backlight_pdata));
215         platform_device_register_simple("video-clps711x", 0, NULL, 0);
216         platform_device_register_data(&platform_bus, "leds-gpio", 0,
217                                       &p720t_gpio_led_pdata,
218                                       sizeof(p720t_gpio_led_pdata));
219 }
220
221 MACHINE_START(P720T, "ARM-Prospector720T")
222         /* Maintainer: ARM Ltd/Deep Blue Solutions Ltd */
223         .atag_offset    = 0x100,
224         .nr_irqs        = CLPS711X_NR_IRQS,
225         .fixup          = fixup_p720t,
226         .map_io         = p720t_map_io,
227         .init_early     = p720t_init_early,
228         .init_irq       = clps711x_init_irq,
229         .init_time      = clps711x_timer_init,
230         .init_machine   = p720t_init,
231         .init_late      = p720t_init_late,
232         .handle_irq     = clps711x_handle_irq,
233         .restart        = clps711x_restart,
234 MACHINE_END