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> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 28 | |
Russell King | a09e64f | 2008-08-05 16:14:15 +0100 | [diff] [blame] | 29 | #include <mach/hardware.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 30 | #include <asm/pgtable.h> |
| 31 | #include <asm/page.h> |
| 32 | #include <asm/setup.h> |
Deepak Saxena | f10083f | 2005-10-28 15:19:05 +0100 | [diff] [blame] | 33 | #include <asm/sizes.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 34 | #include <asm/mach-types.h> |
| 35 | #include <asm/mach/arch.h> |
| 36 | #include <asm/mach/map.h> |
Russell King | a09e64f | 2008-08-05 16:14:15 +0100 | [diff] [blame] | 37 | #include <mach/syspld.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 38 | |
Bryan Wu | 8ee8ef2 | 2012-03-14 01:55:26 +0800 | [diff] [blame^] | 39 | #include <asm/hardware/clps7111.h> |
| 40 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 41 | #include "common.h" |
| 42 | |
| 43 | /* |
| 44 | * Map the P720T system PLD. It occupies two address spaces: |
| 45 | * SYSPLD_PHYS_BASE and SYSPLD_PHYS_BASE + 0x00400000 |
| 46 | * We map both here. |
| 47 | */ |
| 48 | static struct map_desc p720t_io_desc[] __initdata = { |
Deepak Saxena | f10083f | 2005-10-28 15:19:05 +0100 | [diff] [blame] | 49 | { |
| 50 | .virtual = SYSPLD_VIRT_BASE, |
| 51 | .pfn = __phys_to_pfn(SYSPLD_PHYS_BASE), |
| 52 | .length = SZ_1M, |
| 53 | .type = MT_DEVICE |
| 54 | }, { |
| 55 | .virtual = 0xfe400000, |
| 56 | .pfn = __phys_to_pfn(0x10400000), |
| 57 | .length = SZ_1M, |
| 58 | .type = MT_DEVICE |
| 59 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 60 | }; |
| 61 | |
| 62 | static void __init |
Russell King | 0744a3e | 2010-12-20 10:37:50 +0000 | [diff] [blame] | 63 | fixup_p720t(struct tag *tag, char **cmdline, struct meminfo *mi) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 64 | { |
| 65 | /* |
| 66 | * Our bootloader doesn't setup any tags (yet). |
| 67 | */ |
| 68 | if (tag->hdr.tag != ATAG_CORE) { |
| 69 | tag->hdr.tag = ATAG_CORE; |
| 70 | tag->hdr.size = tag_size(tag_core); |
| 71 | tag->u.core.flags = 0; |
| 72 | tag->u.core.pagesize = PAGE_SIZE; |
| 73 | tag->u.core.rootdev = 0x0100; |
| 74 | |
| 75 | tag = tag_next(tag); |
| 76 | tag->hdr.tag = ATAG_MEM; |
| 77 | tag->hdr.size = tag_size(tag_mem32); |
| 78 | tag->u.mem.size = 4096; |
| 79 | tag->u.mem.start = PHYS_OFFSET; |
| 80 | |
| 81 | tag = tag_next(tag); |
| 82 | tag->hdr.tag = ATAG_NONE; |
| 83 | tag->hdr.size = 0; |
| 84 | } |
| 85 | } |
| 86 | |
| 87 | static void __init p720t_map_io(void) |
| 88 | { |
| 89 | clps711x_map_io(); |
| 90 | iotable_init(p720t_io_desc, ARRAY_SIZE(p720t_io_desc)); |
| 91 | } |
| 92 | |
| 93 | MACHINE_START(P720T, "ARM-Prospector720T") |
Russell King | e9dea0c | 2005-07-03 17:38:58 +0100 | [diff] [blame] | 94 | /* Maintainer: ARM Ltd/Deep Blue Solutions Ltd */ |
Nicolas Pitre | 6244fa9 | 2011-07-05 22:38:11 -0400 | [diff] [blame] | 95 | .atag_offset = 0x100, |
Russell King | e9dea0c | 2005-07-03 17:38:58 +0100 | [diff] [blame] | 96 | .fixup = fixup_p720t, |
| 97 | .map_io = p720t_map_io, |
| 98 | .init_irq = clps711x_init_irq, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 99 | .timer = &clps711x_timer, |
Russell King | 6c00071 | 2011-11-05 17:41:52 +0000 | [diff] [blame] | 100 | .restart = clps711x_restart, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 101 | MACHINE_END |
| 102 | |
| 103 | static int p720t_hw_init(void) |
| 104 | { |
| 105 | /* |
| 106 | * Power down as much as possible in case we don't |
| 107 | * have the drivers loaded. |
| 108 | */ |
| 109 | PLD_LCDEN = 0; |
| 110 | PLD_PWR &= ~(PLD_S4_ON|PLD_S3_ON|PLD_S2_ON|PLD_S1_ON); |
| 111 | |
| 112 | PLD_KBD = 0; |
| 113 | PLD_IO = 0; |
| 114 | PLD_IRDA = 0; |
| 115 | PLD_CODEC = 0; |
| 116 | PLD_TCH = 0; |
| 117 | PLD_SPI = 0; |
| 118 | #ifndef CONFIG_DEBUG_LL |
| 119 | PLD_COM2 = 0; |
| 120 | PLD_COM1 = 0; |
| 121 | #endif |
| 122 | |
| 123 | return 0; |
| 124 | } |
| 125 | |
| 126 | __initcall(p720t_hw_init); |
| 127 | |
Bryan Wu | 8ee8ef2 | 2012-03-14 01:55:26 +0800 | [diff] [blame^] | 128 | /* |
| 129 | * LED controled by CPLD |
| 130 | */ |
| 131 | #if defined(CONFIG_NEW_LEDS) && defined(CONFIG_LEDS_CLASS) |
| 132 | static void p720t_led_set(struct led_classdev *cdev, |
| 133 | enum led_brightness b) |
| 134 | { |
| 135 | u8 reg = clps_readb(PDDR); |
| 136 | |
| 137 | if (b != LED_OFF) |
| 138 | reg |= 0x1; |
| 139 | else |
| 140 | reg &= ~0x1; |
| 141 | |
| 142 | clps_writeb(reg, PDDR); |
| 143 | } |
| 144 | |
| 145 | static enum led_brightness p720t_led_get(struct led_classdev *cdev) |
| 146 | { |
| 147 | u8 reg = clps_readb(PDDR); |
| 148 | |
| 149 | return (reg & 0x1) ? LED_FULL : LED_OFF; |
| 150 | } |
| 151 | |
| 152 | static int __init p720t_leds_init(void) |
| 153 | { |
| 154 | |
| 155 | struct led_classdev *cdev; |
| 156 | int ret; |
| 157 | |
| 158 | if (!machine_is_p720t()) |
| 159 | return -ENODEV; |
| 160 | |
| 161 | cdev = kzalloc(sizeof(*cdev), GFP_KERNEL); |
| 162 | if (!cdev) |
| 163 | return -ENOMEM; |
| 164 | |
| 165 | cdev->name = "p720t:0"; |
| 166 | cdev->brightness_set = p720t_led_set; |
| 167 | cdev->brightness_get = p720t_led_get; |
| 168 | cdev->default_trigger = "heartbeat"; |
| 169 | |
| 170 | ret = led_classdev_register(NULL, cdev); |
| 171 | if (ret < 0) { |
| 172 | kfree(cdev); |
| 173 | return ret; |
| 174 | } |
| 175 | |
| 176 | return 0; |
| 177 | } |
| 178 | |
| 179 | /* |
| 180 | * Since we may have triggers on any subsystem, defer registration |
| 181 | * until after subsystem_init. |
| 182 | */ |
| 183 | fs_initcall(p720t_leds_init); |
| 184 | #endif |