blob: dd8995027dd4d80a364e33bf667ae3737b151bff [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001/*
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 Torvalds1da177e2005-04-16 15:20:36 -070020#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 Kingfced80c2008-09-06 12:10:45 +010025#include <linux/io.h>
Bryan Wu8ee8ef22012-03-14 01:55:26 +080026#include <linux/slab.h>
27#include <linux/leds.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070028
Russell Kinga09e64f2008-08-05 16:14:15 +010029#include <mach/hardware.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070030#include <asm/pgtable.h>
31#include <asm/page.h>
32#include <asm/setup.h>
Deepak Saxenaf10083f2005-10-28 15:19:05 +010033#include <asm/sizes.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070034#include <asm/mach-types.h>
35#include <asm/mach/arch.h>
36#include <asm/mach/map.h>
Russell Kinga09e64f2008-08-05 16:14:15 +010037#include <mach/syspld.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070038
39#include "common.h"
40
41/*
Alexander Shiyan6cb1b142012-10-10 19:45:31 +040042 * Map the P720T system PLD. It occupies two address spaces:
43 * 0x10000000 and 0x10400000. We map both regions as one.
Linus Torvalds1da177e2005-04-16 15:20:36 -070044 */
45static struct map_desc p720t_io_desc[] __initdata = {
Deepak Saxenaf10083f2005-10-28 15:19:05 +010046 {
47 .virtual = SYSPLD_VIRT_BASE,
48 .pfn = __phys_to_pfn(SYSPLD_PHYS_BASE),
Alexander Shiyan6cb1b142012-10-10 19:45:31 +040049 .length = SZ_8M,
50 .type = MT_DEVICE,
51 },
Linus Torvalds1da177e2005-04-16 15:20:36 -070052};
53
54static void __init
Russell King0744a3e2010-12-20 10:37:50 +000055fixup_p720t(struct tag *tag, char **cmdline, struct meminfo *mi)
Linus Torvalds1da177e2005-04-16 15:20:36 -070056{
57 /*
58 * Our bootloader doesn't setup any tags (yet).
59 */
60 if (tag->hdr.tag != ATAG_CORE) {
61 tag->hdr.tag = ATAG_CORE;
62 tag->hdr.size = tag_size(tag_core);
63 tag->u.core.flags = 0;
64 tag->u.core.pagesize = PAGE_SIZE;
65 tag->u.core.rootdev = 0x0100;
66
67 tag = tag_next(tag);
68 tag->hdr.tag = ATAG_MEM;
69 tag->hdr.size = tag_size(tag_mem32);
70 tag->u.mem.size = 4096;
71 tag->u.mem.start = PHYS_OFFSET;
72
73 tag = tag_next(tag);
74 tag->hdr.tag = ATAG_NONE;
75 tag->hdr.size = 0;
76 }
77}
78
79static void __init p720t_map_io(void)
80{
81 clps711x_map_io();
82 iotable_init(p720t_io_desc, ARRAY_SIZE(p720t_io_desc));
83}
84
Alexander Shiyan02d7d6d2012-07-16 22:21:45 +040085static void __init p720t_init_early(void)
Linus Torvalds1da177e2005-04-16 15:20:36 -070086{
87 /*
88 * Power down as much as possible in case we don't
89 * have the drivers loaded.
90 */
91 PLD_LCDEN = 0;
92 PLD_PWR &= ~(PLD_S4_ON|PLD_S3_ON|PLD_S2_ON|PLD_S1_ON);
93
94 PLD_KBD = 0;
95 PLD_IO = 0;
96 PLD_IRDA = 0;
97 PLD_CODEC = 0;
98 PLD_TCH = 0;
99 PLD_SPI = 0;
Alexander Shiyan02d7d6d2012-07-16 22:21:45 +0400100 if (!IS_ENABLED(CONFIG_DEBUG_LL)) {
101 PLD_COM2 = 0;
102 PLD_COM1 = 0;
103 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700104}
105
Bryan Wu8ee8ef22012-03-14 01:55:26 +0800106/*
107 * LED controled by CPLD
108 */
109#if defined(CONFIG_NEW_LEDS) && defined(CONFIG_LEDS_CLASS)
110static void p720t_led_set(struct led_classdev *cdev,
111 enum led_brightness b)
112{
113 u8 reg = clps_readb(PDDR);
114
115 if (b != LED_OFF)
116 reg |= 0x1;
117 else
118 reg &= ~0x1;
119
120 clps_writeb(reg, PDDR);
121}
122
123static enum led_brightness p720t_led_get(struct led_classdev *cdev)
124{
125 u8 reg = clps_readb(PDDR);
126
127 return (reg & 0x1) ? LED_FULL : LED_OFF;
128}
129
130static int __init p720t_leds_init(void)
131{
132
133 struct led_classdev *cdev;
134 int ret;
135
136 if (!machine_is_p720t())
137 return -ENODEV;
138
139 cdev = kzalloc(sizeof(*cdev), GFP_KERNEL);
140 if (!cdev)
141 return -ENOMEM;
142
143 cdev->name = "p720t:0";
144 cdev->brightness_set = p720t_led_set;
145 cdev->brightness_get = p720t_led_get;
146 cdev->default_trigger = "heartbeat";
147
148 ret = led_classdev_register(NULL, cdev);
149 if (ret < 0) {
150 kfree(cdev);
151 return ret;
152 }
153
154 return 0;
155}
156
157/*
158 * Since we may have triggers on any subsystem, defer registration
159 * until after subsystem_init.
160 */
161fs_initcall(p720t_leds_init);
162#endif
Arnd Bergmann19e4ab52012-08-13 16:45:48 +0200163
Alexander Shiyan02d7d6d2012-07-16 22:21:45 +0400164MACHINE_START(P720T, "ARM-Prospector720T")
165 /* Maintainer: ARM Ltd/Deep Blue Solutions Ltd */
166 .atag_offset = 0x100,
167 .fixup = fixup_p720t,
168 .init_early = p720t_init_early,
169 .map_io = p720t_map_io,
170 .init_irq = clps711x_init_irq,
171 .timer = &clps711x_timer,
172 .restart = clps711x_restart,
173MACHINE_END