blob: 81cc6835d7a5173da7127c6cca99c1505dfc8d5d [file] [log] [blame]
Alexander Shiyan2a552892012-10-10 19:45:33 +04001/*
2 * Copyright (C) 2000, 2001 Blue Mug, Inc. All Rights Reserved.
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version.
8 */
9
10#include <linux/init.h>
Alexander Shiyan87c37b52012-11-17 17:57:18 +040011#include <linux/gpio.h>
12#include <linux/delay.h>
Alexander Shiyan2a552892012-10-10 19:45:33 +040013#include <linux/memblock.h>
14#include <linux/types.h>
Alexander Shiyan200daa32012-11-17 17:57:07 +040015#include <linux/interrupt.h>
16#include <linux/platform_device.h>
Alexander Shiyan2a552892012-10-10 19:45:33 +040017
18#include <asm/setup.h>
19#include <asm/mach/map.h>
20#include <asm/mach/arch.h>
21#include <asm/mach-types.h>
22
Alexander Shiyan87c37b52012-11-17 17:57:18 +040023#include <video/platform_lcd.h>
24
Alexander Shiyan2a552892012-10-10 19:45:33 +040025#include <mach/hardware.h>
26
27#include "common.h"
28
Alexander Shiyan200daa32012-11-17 17:57:07 +040029#define VIDEORAM_SIZE SZ_128K
30
Alexander Shiyan87c37b52012-11-17 17:57:18 +040031#define EDB7211_LCD_DC_DC_EN CLPS711X_GPIO(3, 1)
32#define EDB7211_LCDEN CLPS711X_GPIO(3, 2)
33
Alexander Shiyan200daa32012-11-17 17:57:07 +040034#define EDB7211_CS8900_BASE (CS2_PHYS_BASE + 0x300)
35#define EDB7211_CS8900_IRQ (IRQ_EINT3)
36
37static struct resource edb7211_cs8900_resource[] __initdata = {
38 DEFINE_RES_MEM(EDB7211_CS8900_BASE, SZ_1K),
39 DEFINE_RES_IRQ(EDB7211_CS8900_IRQ),
40};
Alexander Shiyan2a552892012-10-10 19:45:33 +040041
Alexander Shiyan87c37b52012-11-17 17:57:18 +040042static void edb7211_lcd_power_set(struct plat_lcd_data *pd, unsigned int power)
43{
44 if (power) {
45 gpio_set_value(EDB7211_LCDEN, 1);
46 udelay(100);
47 gpio_set_value(EDB7211_LCD_DC_DC_EN, 1);
48 } else {
49 gpio_set_value(EDB7211_LCD_DC_DC_EN, 0);
50 udelay(100);
51 gpio_set_value(EDB7211_LCDEN, 0);
52 }
53}
54
55static struct plat_lcd_data edb7211_lcd_power_pdata = {
56 .set_power = edb7211_lcd_power_set,
57};
58
59static struct gpio edb7211_gpios[] __initconst = {
60 { EDB7211_LCD_DC_DC_EN, GPIOF_OUT_INIT_LOW, "LCD DC-DC" },
61 { EDB7211_LCDEN, GPIOF_OUT_INIT_LOW, "LCD POWER" },
62};
63
Alexander Shiyan2a552892012-10-10 19:45:33 +040064static struct map_desc edb7211_io_desc[] __initdata = {
65 { /* Memory-mapped extra keyboard row */
66 .virtual = IO_ADDRESS(EP7211_PHYS_EXTKBD),
67 .pfn = __phys_to_pfn(EP7211_PHYS_EXTKBD),
68 .length = SZ_1M,
69 .type = MT_DEVICE,
Alexander Shiyan2a552892012-10-10 19:45:33 +040070 }, { /* Flash bank 0 */
71 .virtual = IO_ADDRESS(EP7211_PHYS_FLASH1),
72 .pfn = __phys_to_pfn(EP7211_PHYS_FLASH1),
73 .length = SZ_8M,
74 .type = MT_DEVICE,
75 }, { /* Flash bank 1 */
76 .virtual = IO_ADDRESS(EP7211_PHYS_FLASH2),
77 .pfn = __phys_to_pfn(EP7211_PHYS_FLASH2),
78 .length = SZ_8M,
79 .type = MT_DEVICE,
80 },
81};
82
83void __init edb7211_map_io(void)
84{
85 clps711x_map_io();
86 iotable_init(edb7211_io_desc, ARRAY_SIZE(edb7211_io_desc));
87}
88
89/* Reserve screen memory region at the start of main system memory. */
90static void __init edb7211_reserve(void)
91{
92 memblock_reserve(PHYS_OFFSET, VIDEORAM_SIZE);
93}
94
95static void __init
96fixup_edb7211(struct tag *tags, char **cmdline, struct meminfo *mi)
97{
98 /*
99 * Bank start addresses are not present in the information
100 * passed in from the boot loader. We could potentially
101 * detect them, but instead we hard-code them.
102 *
103 * Banks sizes _are_ present in the param block, but we're
104 * not using that information yet.
105 */
106 mi->bank[0].start = 0xc0000000;
107 mi->bank[0].size = SZ_8M;
108 mi->bank[1].start = 0xc1000000;
109 mi->bank[1].size = SZ_8M;
110 mi->nr_banks = 2;
111}
112
Alexander Shiyan200daa32012-11-17 17:57:07 +0400113static void __init edb7211_init(void)
114{
Alexander Shiyan87c37b52012-11-17 17:57:18 +0400115 gpio_request_array(edb7211_gpios, ARRAY_SIZE(edb7211_gpios));
116
117 platform_device_register_data(&platform_bus, "platform-lcd", 0,
118 &edb7211_lcd_power_pdata,
119 sizeof(edb7211_lcd_power_pdata));
Alexander Shiyandd850f12012-11-17 17:57:09 +0400120 platform_device_register_simple("video-clps711x", 0, NULL, 0);
Alexander Shiyan200daa32012-11-17 17:57:07 +0400121 platform_device_register_simple("cs89x0", 0, edb7211_cs8900_resource,
122 ARRAY_SIZE(edb7211_cs8900_resource));
123}
124
Alexander Shiyan2a552892012-10-10 19:45:33 +0400125MACHINE_START(EDB7211, "CL-EDB7211 (EP7211 eval board)")
126 /* Maintainer: Jon McClintock */
127 .atag_offset = VIDEORAM_SIZE + 0x100,
Alexander Shiyan0d8be812012-11-17 17:57:13 +0400128 .nr_irqs = CLPS711X_NR_IRQS,
Alexander Shiyan2a552892012-10-10 19:45:33 +0400129 .fixup = fixup_edb7211,
Alexander Shiyan2a552892012-10-10 19:45:33 +0400130 .reserve = edb7211_reserve,
Alexander Shiyan200daa32012-11-17 17:57:07 +0400131 .map_io = edb7211_map_io,
Alexander Shiyan2a552892012-10-10 19:45:33 +0400132 .init_irq = clps711x_init_irq,
133 .timer = &clps711x_timer,
Alexander Shiyan200daa32012-11-17 17:57:07 +0400134 .init_machine = edb7211_init,
Alexander Shiyan99f04c82012-11-17 17:57:14 +0400135 .handle_irq = clps711x_handle_irq,
Alexander Shiyan2a552892012-10-10 19:45:33 +0400136 .restart = clps711x_restart,
137MACHINE_END