blob: d5832b3557a1256bffd23034056e42392a1ac506 [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
19#include <asm/setup.h>
20#include <asm/mach/map.h>
21#include <asm/mach/arch.h>
22#include <asm/mach-types.h>
23
Alexander Shiyan87c37b52012-11-17 17:57:18 +040024#include <video/platform_lcd.h>
25
Alexander Shiyan2a552892012-10-10 19:45:33 +040026#include <mach/hardware.h>
27
28#include "common.h"
29
Alexander Shiyan200daa32012-11-17 17:57:07 +040030#define VIDEORAM_SIZE SZ_128K
31
Alexander Shiyan87c37b52012-11-17 17:57:18 +040032#define EDB7211_LCD_DC_DC_EN CLPS711X_GPIO(3, 1)
33#define EDB7211_LCDEN CLPS711X_GPIO(3, 2)
Alexander Shiyan94760bf2012-11-17 17:57:20 +040034#define EDB7211_LCDBL CLPS711X_GPIO(3, 3)
Alexander Shiyan87c37b52012-11-17 17:57:18 +040035
Alexander Shiyan200daa32012-11-17 17:57:07 +040036#define EDB7211_CS8900_BASE (CS2_PHYS_BASE + 0x300)
37#define EDB7211_CS8900_IRQ (IRQ_EINT3)
38
39static struct resource edb7211_cs8900_resource[] __initdata = {
40 DEFINE_RES_MEM(EDB7211_CS8900_BASE, SZ_1K),
41 DEFINE_RES_IRQ(EDB7211_CS8900_IRQ),
42};
Alexander Shiyan2a552892012-10-10 19:45:33 +040043
Alexander Shiyan87c37b52012-11-17 17:57:18 +040044static void edb7211_lcd_power_set(struct plat_lcd_data *pd, unsigned int power)
45{
46 if (power) {
47 gpio_set_value(EDB7211_LCDEN, 1);
48 udelay(100);
49 gpio_set_value(EDB7211_LCD_DC_DC_EN, 1);
50 } else {
51 gpio_set_value(EDB7211_LCD_DC_DC_EN, 0);
52 udelay(100);
53 gpio_set_value(EDB7211_LCDEN, 0);
54 }
55}
56
57static struct plat_lcd_data edb7211_lcd_power_pdata = {
58 .set_power = edb7211_lcd_power_set,
59};
60
Alexander Shiyan94760bf2012-11-17 17:57:20 +040061static void edb7211_lcd_backlight_set_intensity(int intensity)
62{
63 gpio_set_value(EDB7211_LCDBL, intensity);
64}
65
66static struct generic_bl_info edb7211_lcd_backlight_pdata = {
67 .name = "lcd-backlight.0",
68 .default_intensity = 0x01,
69 .max_intensity = 0x01,
70 .set_bl_intensity = edb7211_lcd_backlight_set_intensity,
71};
72
Alexander Shiyan87c37b52012-11-17 17:57:18 +040073static struct gpio edb7211_gpios[] __initconst = {
74 { EDB7211_LCD_DC_DC_EN, GPIOF_OUT_INIT_LOW, "LCD DC-DC" },
75 { EDB7211_LCDEN, GPIOF_OUT_INIT_LOW, "LCD POWER" },
Alexander Shiyan94760bf2012-11-17 17:57:20 +040076 { EDB7211_LCDBL, GPIOF_OUT_INIT_LOW, "LCD BACKLIGHT" },
Alexander Shiyan87c37b52012-11-17 17:57:18 +040077};
78
Alexander Shiyan2a552892012-10-10 19:45:33 +040079static struct map_desc edb7211_io_desc[] __initdata = {
80 { /* Memory-mapped extra keyboard row */
81 .virtual = IO_ADDRESS(EP7211_PHYS_EXTKBD),
82 .pfn = __phys_to_pfn(EP7211_PHYS_EXTKBD),
83 .length = SZ_1M,
84 .type = MT_DEVICE,
Alexander Shiyan2a552892012-10-10 19:45:33 +040085 }, { /* Flash bank 0 */
86 .virtual = IO_ADDRESS(EP7211_PHYS_FLASH1),
87 .pfn = __phys_to_pfn(EP7211_PHYS_FLASH1),
88 .length = SZ_8M,
89 .type = MT_DEVICE,
90 }, { /* Flash bank 1 */
91 .virtual = IO_ADDRESS(EP7211_PHYS_FLASH2),
92 .pfn = __phys_to_pfn(EP7211_PHYS_FLASH2),
93 .length = SZ_8M,
94 .type = MT_DEVICE,
95 },
96};
97
98void __init edb7211_map_io(void)
99{
100 clps711x_map_io();
101 iotable_init(edb7211_io_desc, ARRAY_SIZE(edb7211_io_desc));
102}
103
104/* Reserve screen memory region at the start of main system memory. */
105static void __init edb7211_reserve(void)
106{
107 memblock_reserve(PHYS_OFFSET, VIDEORAM_SIZE);
108}
109
110static void __init
111fixup_edb7211(struct tag *tags, char **cmdline, struct meminfo *mi)
112{
113 /*
114 * Bank start addresses are not present in the information
115 * passed in from the boot loader. We could potentially
116 * detect them, but instead we hard-code them.
117 *
118 * Banks sizes _are_ present in the param block, but we're
119 * not using that information yet.
120 */
121 mi->bank[0].start = 0xc0000000;
122 mi->bank[0].size = SZ_8M;
123 mi->bank[1].start = 0xc1000000;
124 mi->bank[1].size = SZ_8M;
125 mi->nr_banks = 2;
126}
127
Alexander Shiyan200daa32012-11-17 17:57:07 +0400128static void __init edb7211_init(void)
129{
Alexander Shiyan87c37b52012-11-17 17:57:18 +0400130 gpio_request_array(edb7211_gpios, ARRAY_SIZE(edb7211_gpios));
131
132 platform_device_register_data(&platform_bus, "platform-lcd", 0,
133 &edb7211_lcd_power_pdata,
134 sizeof(edb7211_lcd_power_pdata));
Alexander Shiyan94760bf2012-11-17 17:57:20 +0400135 platform_device_register_data(&platform_bus, "generic-bl", 0,
136 &edb7211_lcd_backlight_pdata,
137 sizeof(edb7211_lcd_backlight_pdata));
Alexander Shiyandd850f12012-11-17 17:57:09 +0400138 platform_device_register_simple("video-clps711x", 0, NULL, 0);
Alexander Shiyan200daa32012-11-17 17:57:07 +0400139 platform_device_register_simple("cs89x0", 0, edb7211_cs8900_resource,
140 ARRAY_SIZE(edb7211_cs8900_resource));
141}
142
Alexander Shiyan2a552892012-10-10 19:45:33 +0400143MACHINE_START(EDB7211, "CL-EDB7211 (EP7211 eval board)")
144 /* Maintainer: Jon McClintock */
145 .atag_offset = VIDEORAM_SIZE + 0x100,
Alexander Shiyan0d8be812012-11-17 17:57:13 +0400146 .nr_irqs = CLPS711X_NR_IRQS,
Alexander Shiyan2a552892012-10-10 19:45:33 +0400147 .fixup = fixup_edb7211,
Alexander Shiyan2a552892012-10-10 19:45:33 +0400148 .reserve = edb7211_reserve,
Alexander Shiyan200daa32012-11-17 17:57:07 +0400149 .map_io = edb7211_map_io,
Alexander Shiyan2a552892012-10-10 19:45:33 +0400150 .init_irq = clps711x_init_irq,
151 .timer = &clps711x_timer,
Alexander Shiyan200daa32012-11-17 17:57:07 +0400152 .init_machine = edb7211_init,
Alexander Shiyan99f04c82012-11-17 17:57:14 +0400153 .handle_irq = clps711x_handle_irq,
Alexander Shiyan2a552892012-10-10 19:45:33 +0400154 .restart = clps711x_restart,
155MACHINE_END