blob: 3ba4b9e636ae5f76d9fb6c2a5235cf80f92cab5f [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>
Alexander Shiyan94760bf2012-11-17 17:57:20 +040016#include <linux/backlight.h>
Alexander Shiyan200daa32012-11-17 17:57:07 +040017#include <linux/platform_device.h>
Alexander Shiyan2a552892012-10-10 19:45:33 +040018
Alexander Shiyan96754a12012-11-17 17:57:21 +040019#include <linux/mtd/physmap.h>
20#include <linux/mtd/partitions.h>
21
Alexander Shiyan2a552892012-10-10 19:45:33 +040022#include <asm/setup.h>
23#include <asm/mach/map.h>
24#include <asm/mach/arch.h>
25#include <asm/mach-types.h>
26
Alexander Shiyan87c37b52012-11-17 17:57:18 +040027#include <video/platform_lcd.h>
28
Alexander Shiyan2a552892012-10-10 19:45:33 +040029#include <mach/hardware.h>
30
31#include "common.h"
Alexander Shiyane328b882013-04-26 19:47:29 +040032#include "devices.h"
Alexander Shiyan2a552892012-10-10 19:45:33 +040033
Alexander Shiyan200daa32012-11-17 17:57:07 +040034#define VIDEORAM_SIZE SZ_128K
35
Alexander Shiyan87c37b52012-11-17 17:57:18 +040036#define EDB7211_LCD_DC_DC_EN CLPS711X_GPIO(3, 1)
37#define EDB7211_LCDEN CLPS711X_GPIO(3, 2)
Alexander Shiyan94760bf2012-11-17 17:57:20 +040038#define EDB7211_LCDBL CLPS711X_GPIO(3, 3)
Alexander Shiyan87c37b52012-11-17 17:57:18 +040039
Alexander Shiyan96754a12012-11-17 17:57:21 +040040#define EDB7211_FLASH0_BASE (CS0_PHYS_BASE)
41#define EDB7211_FLASH1_BASE (CS1_PHYS_BASE)
Alexander Shiyan7e4615c2013-05-13 21:07:30 +040042
Alexander Shiyan200daa32012-11-17 17:57:07 +040043#define EDB7211_CS8900_BASE (CS2_PHYS_BASE + 0x300)
44#define EDB7211_CS8900_IRQ (IRQ_EINT3)
45
Alexander Shiyan7e4615c2013-05-13 21:07:30 +040046/* The extra 8 lines of the keyboard matrix */
47#define EDB7211_EXTKBD_BASE (CS3_PHYS_BASE)
48
Alexander Shiyan200daa32012-11-17 17:57:07 +040049static struct resource edb7211_cs8900_resource[] __initdata = {
50 DEFINE_RES_MEM(EDB7211_CS8900_BASE, SZ_1K),
51 DEFINE_RES_IRQ(EDB7211_CS8900_IRQ),
52};
Alexander Shiyan2a552892012-10-10 19:45:33 +040053
Alexander Shiyan96754a12012-11-17 17:57:21 +040054static struct mtd_partition edb7211_flash_partitions[] __initdata = {
55 {
56 .name = "Flash",
57 .offset = 0,
58 .size = MTDPART_SIZ_FULL,
59 },
60};
61
62static struct physmap_flash_data edb7211_flash_pdata __initdata = {
63 .width = 4,
64 .parts = edb7211_flash_partitions,
65 .nr_parts = ARRAY_SIZE(edb7211_flash_partitions),
66};
67
68static struct resource edb7211_flash_resources[] __initdata = {
69 DEFINE_RES_MEM(EDB7211_FLASH0_BASE, SZ_8M),
70 DEFINE_RES_MEM(EDB7211_FLASH1_BASE, SZ_8M),
71};
72
73static struct platform_device edb7211_flash_pdev __initdata = {
74 .name = "physmap-flash",
75 .id = 0,
76 .resource = edb7211_flash_resources,
77 .num_resources = ARRAY_SIZE(edb7211_flash_resources),
78 .dev = {
79 .platform_data = &edb7211_flash_pdata,
80 },
81};
82
Alexander Shiyan87c37b52012-11-17 17:57:18 +040083static void edb7211_lcd_power_set(struct plat_lcd_data *pd, unsigned int power)
84{
85 if (power) {
86 gpio_set_value(EDB7211_LCDEN, 1);
87 udelay(100);
88 gpio_set_value(EDB7211_LCD_DC_DC_EN, 1);
89 } else {
90 gpio_set_value(EDB7211_LCD_DC_DC_EN, 0);
91 udelay(100);
92 gpio_set_value(EDB7211_LCDEN, 0);
93 }
94}
95
96static struct plat_lcd_data edb7211_lcd_power_pdata = {
97 .set_power = edb7211_lcd_power_set,
98};
99
Alexander Shiyan94760bf2012-11-17 17:57:20 +0400100static void edb7211_lcd_backlight_set_intensity(int intensity)
101{
102 gpio_set_value(EDB7211_LCDBL, intensity);
103}
104
105static struct generic_bl_info edb7211_lcd_backlight_pdata = {
106 .name = "lcd-backlight.0",
107 .default_intensity = 0x01,
108 .max_intensity = 0x01,
109 .set_bl_intensity = edb7211_lcd_backlight_set_intensity,
110};
111
Alexander Shiyan87c37b52012-11-17 17:57:18 +0400112static struct gpio edb7211_gpios[] __initconst = {
113 { EDB7211_LCD_DC_DC_EN, GPIOF_OUT_INIT_LOW, "LCD DC-DC" },
114 { EDB7211_LCDEN, GPIOF_OUT_INIT_LOW, "LCD POWER" },
Alexander Shiyan94760bf2012-11-17 17:57:20 +0400115 { EDB7211_LCDBL, GPIOF_OUT_INIT_LOW, "LCD BACKLIGHT" },
Alexander Shiyan87c37b52012-11-17 17:57:18 +0400116};
117
Alexander Shiyan2a552892012-10-10 19:45:33 +0400118static struct map_desc edb7211_io_desc[] __initdata = {
119 { /* Memory-mapped extra keyboard row */
Alexander Shiyan7e4615c2013-05-13 21:07:30 +0400120 .virtual = IO_ADDRESS(EDB7211_EXTKBD_BASE),
121 .pfn = __phys_to_pfn(EDB7211_EXTKBD_BASE),
Alexander Shiyan2a552892012-10-10 19:45:33 +0400122 .length = SZ_1M,
123 .type = MT_DEVICE,
Alexander Shiyan2a552892012-10-10 19:45:33 +0400124 },
125};
126
127void __init edb7211_map_io(void)
128{
129 clps711x_map_io();
130 iotable_init(edb7211_io_desc, ARRAY_SIZE(edb7211_io_desc));
131}
132
133/* Reserve screen memory region at the start of main system memory. */
134static void __init edb7211_reserve(void)
135{
136 memblock_reserve(PHYS_OFFSET, VIDEORAM_SIZE);
137}
138
139static void __init
140fixup_edb7211(struct tag *tags, char **cmdline, struct meminfo *mi)
141{
142 /*
143 * Bank start addresses are not present in the information
144 * passed in from the boot loader. We could potentially
145 * detect them, but instead we hard-code them.
146 *
147 * Banks sizes _are_ present in the param block, but we're
148 * not using that information yet.
149 */
150 mi->bank[0].start = 0xc0000000;
151 mi->bank[0].size = SZ_8M;
152 mi->bank[1].start = 0xc1000000;
153 mi->bank[1].size = SZ_8M;
154 mi->nr_banks = 2;
155}
156
Alexander Shiyan200daa32012-11-17 17:57:07 +0400157static void __init edb7211_init(void)
158{
Alexander Shiyane328b882013-04-26 19:47:29 +0400159 clps711x_devices_init();
160}
161
162static void __init edb7211_init_late(void)
163{
Alexander Shiyan87c37b52012-11-17 17:57:18 +0400164 gpio_request_array(edb7211_gpios, ARRAY_SIZE(edb7211_gpios));
165
Alexander Shiyan96754a12012-11-17 17:57:21 +0400166 platform_device_register(&edb7211_flash_pdev);
Alexander Shiyan87c37b52012-11-17 17:57:18 +0400167 platform_device_register_data(&platform_bus, "platform-lcd", 0,
168 &edb7211_lcd_power_pdata,
169 sizeof(edb7211_lcd_power_pdata));
Alexander Shiyan94760bf2012-11-17 17:57:20 +0400170 platform_device_register_data(&platform_bus, "generic-bl", 0,
171 &edb7211_lcd_backlight_pdata,
172 sizeof(edb7211_lcd_backlight_pdata));
Alexander Shiyandd850f12012-11-17 17:57:09 +0400173 platform_device_register_simple("video-clps711x", 0, NULL, 0);
Alexander Shiyan200daa32012-11-17 17:57:07 +0400174 platform_device_register_simple("cs89x0", 0, edb7211_cs8900_resource,
175 ARRAY_SIZE(edb7211_cs8900_resource));
176}
177
Alexander Shiyan2a552892012-10-10 19:45:33 +0400178MACHINE_START(EDB7211, "CL-EDB7211 (EP7211 eval board)")
179 /* Maintainer: Jon McClintock */
180 .atag_offset = VIDEORAM_SIZE + 0x100,
Alexander Shiyan0d8be812012-11-17 17:57:13 +0400181 .nr_irqs = CLPS711X_NR_IRQS,
Alexander Shiyan2a552892012-10-10 19:45:33 +0400182 .fixup = fixup_edb7211,
Alexander Shiyan2a552892012-10-10 19:45:33 +0400183 .reserve = edb7211_reserve,
Alexander Shiyan200daa32012-11-17 17:57:07 +0400184 .map_io = edb7211_map_io,
Alexander Shiyan2a552892012-10-10 19:45:33 +0400185 .init_irq = clps711x_init_irq,
Stephen Warren6bb27d72012-11-08 12:40:59 -0700186 .init_time = clps711x_timer_init,
Alexander Shiyan200daa32012-11-17 17:57:07 +0400187 .init_machine = edb7211_init,
Alexander Shiyane328b882013-04-26 19:47:29 +0400188 .init_late = edb7211_init_late,
Alexander Shiyan99f04c82012-11-17 17:57:14 +0400189 .handle_irq = clps711x_handle_irq,
Alexander Shiyan2a552892012-10-10 19:45:33 +0400190 .restart = clps711x_restart,
191MACHINE_END