Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 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 | */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 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> |
Russell King | fced80c | 2008-09-06 12:10:45 +0100 | [diff] [blame] | 25 | #include <linux/io.h> |
Bryan Wu | 8ee8ef2 | 2012-03-14 01:55:26 +0800 | [diff] [blame] | 26 | #include <linux/slab.h> |
| 27 | #include <linux/leds.h> |
Alexander Shiyan | 94760bf | 2012-11-17 17:57:20 +0400 | [diff] [blame] | 28 | #include <linux/sizes.h> |
| 29 | #include <linux/backlight.h> |
Alexander Shiyan | b3a076d | 2012-11-17 17:57:08 +0400 | [diff] [blame] | 30 | #include <linux/platform_device.h> |
Alexander Shiyan | e377ca1 | 2012-11-17 17:57:19 +0400 | [diff] [blame] | 31 | #include <linux/mtd/partitions.h> |
| 32 | #include <linux/mtd/nand-gpio.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 33 | |
Russell King | a09e64f | 2008-08-05 16:14:15 +0100 | [diff] [blame] | 34 | #include <mach/hardware.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 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> |
Russell King | a09e64f | 2008-08-05 16:14:15 +0100 | [diff] [blame] | 41 | #include <mach/syspld.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 42 | |
Alexander Shiyan | 87c37b5 | 2012-11-17 17:57:18 +0400 | [diff] [blame] | 43 | #include <video/platform_lcd.h> |
| 44 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 45 | #include "common.h" |
| 46 | |
Alexander Shiyan | e377ca1 | 2012-11-17 17:57:19 +0400 | [diff] [blame] | 47 | #define P720T_USERLED CLPS711X_GPIO(3, 0) |
| 48 | #define P720T_NAND_CLE CLPS711X_GPIO(4, 0) |
| 49 | #define P720T_NAND_ALE CLPS711X_GPIO(4, 1) |
| 50 | #define P720T_NAND_NCE CLPS711X_GPIO(4, 2) |
| 51 | |
| 52 | #define P720T_NAND_BASE (CLPS711X_SDRAM1_BASE) |
| 53 | |
| 54 | static struct resource p720t_nand_resource[] __initdata = { |
| 55 | DEFINE_RES_MEM(P720T_NAND_BASE, SZ_4), |
| 56 | }; |
| 57 | |
| 58 | static struct mtd_partition p720t_nand_parts[] __initdata = { |
| 59 | { |
| 60 | .name = "Flash partition 1", |
| 61 | .offset = 0, |
| 62 | .size = SZ_2M, |
| 63 | }, |
| 64 | { |
| 65 | .name = "Flash partition 2", |
| 66 | .offset = MTDPART_OFS_APPEND, |
| 67 | .size = MTDPART_SIZ_FULL, |
| 68 | }, |
| 69 | }; |
| 70 | |
| 71 | static struct gpio_nand_platdata p720t_nand_pdata __initdata = { |
| 72 | .gpio_rdy = -1, |
| 73 | .gpio_nce = P720T_NAND_NCE, |
| 74 | .gpio_ale = P720T_NAND_ALE, |
| 75 | .gpio_cle = P720T_NAND_CLE, |
| 76 | .gpio_nwp = -1, |
| 77 | .chip_delay = 15, |
| 78 | .parts = p720t_nand_parts, |
| 79 | .num_parts = ARRAY_SIZE(p720t_nand_parts), |
| 80 | }; |
| 81 | |
| 82 | static struct platform_device p720t_nand_pdev __initdata = { |
| 83 | .name = "gpio-nand", |
| 84 | .id = -1, |
| 85 | .resource = p720t_nand_resource, |
| 86 | .num_resources = ARRAY_SIZE(p720t_nand_resource), |
| 87 | .dev = { |
| 88 | .platform_data = &p720t_nand_pdata, |
| 89 | }, |
| 90 | }; |
Alexander Shiyan | b3a076d | 2012-11-17 17:57:08 +0400 | [diff] [blame] | 91 | |
Alexander Shiyan | 87c37b5 | 2012-11-17 17:57:18 +0400 | [diff] [blame] | 92 | static void p720t_lcd_power_set(struct plat_lcd_data *pd, unsigned int power) |
| 93 | { |
| 94 | if (power) { |
| 95 | PLD_LCDEN = PLD_LCDEN_EN; |
| 96 | PLD_PWR |= PLD_S4_ON | PLD_S2_ON | PLD_S1_ON; |
| 97 | } else { |
| 98 | PLD_PWR &= ~(PLD_S4_ON | PLD_S2_ON | PLD_S1_ON); |
| 99 | PLD_LCDEN = 0; |
| 100 | } |
| 101 | } |
| 102 | |
| 103 | static struct plat_lcd_data p720t_lcd_power_pdata = { |
| 104 | .set_power = p720t_lcd_power_set, |
| 105 | }; |
| 106 | |
Alexander Shiyan | 94760bf | 2012-11-17 17:57:20 +0400 | [diff] [blame] | 107 | static void p720t_lcd_backlight_set_intensity(int intensity) |
| 108 | { |
| 109 | if (intensity) |
| 110 | PLD_PWR |= PLD_S3_ON; |
| 111 | else |
| 112 | PLD_PWR = 0; |
| 113 | } |
| 114 | |
| 115 | static struct generic_bl_info p720t_lcd_backlight_pdata = { |
| 116 | .name = "lcd-backlight.0", |
| 117 | .default_intensity = 0x01, |
| 118 | .max_intensity = 0x01, |
| 119 | .set_bl_intensity = p720t_lcd_backlight_set_intensity, |
| 120 | }; |
| 121 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 122 | /* |
Alexander Shiyan | 6cb1b14 | 2012-10-10 19:45:31 +0400 | [diff] [blame] | 123 | * Map the P720T system PLD. It occupies two address spaces: |
| 124 | * 0x10000000 and 0x10400000. We map both regions as one. |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 125 | */ |
| 126 | static struct map_desc p720t_io_desc[] __initdata = { |
Deepak Saxena | f10083f | 2005-10-28 15:19:05 +0100 | [diff] [blame] | 127 | { |
| 128 | .virtual = SYSPLD_VIRT_BASE, |
| 129 | .pfn = __phys_to_pfn(SYSPLD_PHYS_BASE), |
Alexander Shiyan | 6cb1b14 | 2012-10-10 19:45:31 +0400 | [diff] [blame] | 130 | .length = SZ_8M, |
| 131 | .type = MT_DEVICE, |
| 132 | }, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 133 | }; |
| 134 | |
| 135 | static void __init |
Russell King | 0744a3e | 2010-12-20 10:37:50 +0000 | [diff] [blame] | 136 | fixup_p720t(struct tag *tag, char **cmdline, struct meminfo *mi) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 137 | { |
| 138 | /* |
| 139 | * Our bootloader doesn't setup any tags (yet). |
| 140 | */ |
| 141 | if (tag->hdr.tag != ATAG_CORE) { |
| 142 | tag->hdr.tag = ATAG_CORE; |
| 143 | tag->hdr.size = tag_size(tag_core); |
| 144 | tag->u.core.flags = 0; |
| 145 | tag->u.core.pagesize = PAGE_SIZE; |
| 146 | tag->u.core.rootdev = 0x0100; |
| 147 | |
| 148 | tag = tag_next(tag); |
| 149 | tag->hdr.tag = ATAG_MEM; |
| 150 | tag->hdr.size = tag_size(tag_mem32); |
| 151 | tag->u.mem.size = 4096; |
| 152 | tag->u.mem.start = PHYS_OFFSET; |
| 153 | |
| 154 | tag = tag_next(tag); |
| 155 | tag->hdr.tag = ATAG_NONE; |
| 156 | tag->hdr.size = 0; |
| 157 | } |
| 158 | } |
| 159 | |
| 160 | static void __init p720t_map_io(void) |
| 161 | { |
| 162 | clps711x_map_io(); |
| 163 | iotable_init(p720t_io_desc, ARRAY_SIZE(p720t_io_desc)); |
| 164 | } |
| 165 | |
Alexander Shiyan | 02d7d6d | 2012-07-16 22:21:45 +0400 | [diff] [blame] | 166 | static void __init p720t_init_early(void) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 167 | { |
| 168 | /* |
| 169 | * Power down as much as possible in case we don't |
| 170 | * have the drivers loaded. |
| 171 | */ |
| 172 | PLD_LCDEN = 0; |
| 173 | PLD_PWR &= ~(PLD_S4_ON|PLD_S3_ON|PLD_S2_ON|PLD_S1_ON); |
| 174 | |
| 175 | PLD_KBD = 0; |
| 176 | PLD_IO = 0; |
| 177 | PLD_IRDA = 0; |
| 178 | PLD_CODEC = 0; |
| 179 | PLD_TCH = 0; |
| 180 | PLD_SPI = 0; |
Alexander Shiyan | 02d7d6d | 2012-07-16 22:21:45 +0400 | [diff] [blame] | 181 | if (!IS_ENABLED(CONFIG_DEBUG_LL)) { |
| 182 | PLD_COM2 = 0; |
| 183 | PLD_COM1 = 0; |
| 184 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 185 | } |
| 186 | |
Alexander Shiyan | b3a076d | 2012-11-17 17:57:08 +0400 | [diff] [blame] | 187 | static struct gpio_led p720t_gpio_leds[] = { |
| 188 | { |
| 189 | .name = "User LED", |
| 190 | .default_trigger = "heartbeat", |
Alexander Shiyan | e377ca1 | 2012-11-17 17:57:19 +0400 | [diff] [blame] | 191 | .gpio = P720T_USERLED, |
Alexander Shiyan | b3a076d | 2012-11-17 17:57:08 +0400 | [diff] [blame] | 192 | }, |
| 193 | }; |
| 194 | |
| 195 | static struct gpio_led_platform_data p720t_gpio_led_pdata __initdata = { |
| 196 | .leds = p720t_gpio_leds, |
| 197 | .num_leds = ARRAY_SIZE(p720t_gpio_leds), |
| 198 | }; |
| 199 | |
Alexander Shiyan | dd850f1 | 2012-11-17 17:57:09 +0400 | [diff] [blame] | 200 | static void __init p720t_init(void) |
| 201 | { |
Alexander Shiyan | e377ca1 | 2012-11-17 17:57:19 +0400 | [diff] [blame] | 202 | platform_device_register(&p720t_nand_pdev); |
Alexander Shiyan | 87c37b5 | 2012-11-17 17:57:18 +0400 | [diff] [blame] | 203 | platform_device_register_data(&platform_bus, "platform-lcd", 0, |
| 204 | &p720t_lcd_power_pdata, |
| 205 | sizeof(p720t_lcd_power_pdata)); |
Alexander Shiyan | 94760bf | 2012-11-17 17:57:20 +0400 | [diff] [blame] | 206 | platform_device_register_data(&platform_bus, "generic-bl", 0, |
| 207 | &p720t_lcd_backlight_pdata, |
| 208 | sizeof(p720t_lcd_backlight_pdata)); |
Alexander Shiyan | dd850f1 | 2012-11-17 17:57:09 +0400 | [diff] [blame] | 209 | platform_device_register_simple("video-clps711x", 0, NULL, 0); |
| 210 | } |
| 211 | |
Alexander Shiyan | b3a076d | 2012-11-17 17:57:08 +0400 | [diff] [blame] | 212 | static void __init p720t_init_late(void) |
Bryan Wu | 8ee8ef2 | 2012-03-14 01:55:26 +0800 | [diff] [blame] | 213 | { |
Alexander Shiyan | b3a076d | 2012-11-17 17:57:08 +0400 | [diff] [blame] | 214 | platform_device_register_data(&platform_bus, "leds-gpio", 0, |
| 215 | &p720t_gpio_led_pdata, |
| 216 | sizeof(p720t_gpio_led_pdata)); |
Bryan Wu | 8ee8ef2 | 2012-03-14 01:55:26 +0800 | [diff] [blame] | 217 | } |
| 218 | |
Alexander Shiyan | 02d7d6d | 2012-07-16 22:21:45 +0400 | [diff] [blame] | 219 | MACHINE_START(P720T, "ARM-Prospector720T") |
| 220 | /* Maintainer: ARM Ltd/Deep Blue Solutions Ltd */ |
| 221 | .atag_offset = 0x100, |
Alexander Shiyan | 0d8be81 | 2012-11-17 17:57:13 +0400 | [diff] [blame] | 222 | .nr_irqs = CLPS711X_NR_IRQS, |
Alexander Shiyan | 02d7d6d | 2012-07-16 22:21:45 +0400 | [diff] [blame] | 223 | .fixup = fixup_p720t, |
Alexander Shiyan | 02d7d6d | 2012-07-16 22:21:45 +0400 | [diff] [blame] | 224 | .map_io = p720t_map_io, |
Alexander Shiyan | b3a076d | 2012-11-17 17:57:08 +0400 | [diff] [blame] | 225 | .init_early = p720t_init_early, |
Alexander Shiyan | 02d7d6d | 2012-07-16 22:21:45 +0400 | [diff] [blame] | 226 | .init_irq = clps711x_init_irq, |
Stephen Warren | 6bb27d7 | 2012-11-08 12:40:59 -0700 | [diff] [blame^] | 227 | .init_time = clps711x_timer_init, |
Alexander Shiyan | dd850f1 | 2012-11-17 17:57:09 +0400 | [diff] [blame] | 228 | .init_machine = p720t_init, |
Alexander Shiyan | b3a076d | 2012-11-17 17:57:08 +0400 | [diff] [blame] | 229 | .init_late = p720t_init_late, |
Alexander Shiyan | 99f04c8 | 2012-11-17 17:57:14 +0400 | [diff] [blame] | 230 | .handle_irq = clps711x_handle_irq, |
Alexander Shiyan | 02d7d6d | 2012-07-16 22:21:45 +0400 | [diff] [blame] | 231 | .restart = clps711x_restart, |
| 232 | MACHINE_END |