Alexander Shiyan | 2a55289 | 2012-10-10 19:45:33 +0400 | [diff] [blame] | 1 | /* |
| 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 Shiyan | 87c37b5 | 2012-11-17 17:57:18 +0400 | [diff] [blame] | 11 | #include <linux/gpio.h> |
| 12 | #include <linux/delay.h> |
Alexander Shiyan | 2a55289 | 2012-10-10 19:45:33 +0400 | [diff] [blame] | 13 | #include <linux/memblock.h> |
| 14 | #include <linux/types.h> |
Alexander Shiyan | 200daa3 | 2012-11-17 17:57:07 +0400 | [diff] [blame] | 15 | #include <linux/interrupt.h> |
Alexander Shiyan | 94760bf | 2012-11-17 17:57:20 +0400 | [diff] [blame^] | 16 | #include <linux/backlight.h> |
Alexander Shiyan | 200daa3 | 2012-11-17 17:57:07 +0400 | [diff] [blame] | 17 | #include <linux/platform_device.h> |
Alexander Shiyan | 2a55289 | 2012-10-10 19:45:33 +0400 | [diff] [blame] | 18 | |
| 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 Shiyan | 87c37b5 | 2012-11-17 17:57:18 +0400 | [diff] [blame] | 24 | #include <video/platform_lcd.h> |
| 25 | |
Alexander Shiyan | 2a55289 | 2012-10-10 19:45:33 +0400 | [diff] [blame] | 26 | #include <mach/hardware.h> |
| 27 | |
| 28 | #include "common.h" |
| 29 | |
Alexander Shiyan | 200daa3 | 2012-11-17 17:57:07 +0400 | [diff] [blame] | 30 | #define VIDEORAM_SIZE SZ_128K |
| 31 | |
Alexander Shiyan | 87c37b5 | 2012-11-17 17:57:18 +0400 | [diff] [blame] | 32 | #define EDB7211_LCD_DC_DC_EN CLPS711X_GPIO(3, 1) |
| 33 | #define EDB7211_LCDEN CLPS711X_GPIO(3, 2) |
Alexander Shiyan | 94760bf | 2012-11-17 17:57:20 +0400 | [diff] [blame^] | 34 | #define EDB7211_LCDBL CLPS711X_GPIO(3, 3) |
Alexander Shiyan | 87c37b5 | 2012-11-17 17:57:18 +0400 | [diff] [blame] | 35 | |
Alexander Shiyan | 200daa3 | 2012-11-17 17:57:07 +0400 | [diff] [blame] | 36 | #define EDB7211_CS8900_BASE (CS2_PHYS_BASE + 0x300) |
| 37 | #define EDB7211_CS8900_IRQ (IRQ_EINT3) |
| 38 | |
| 39 | static struct resource edb7211_cs8900_resource[] __initdata = { |
| 40 | DEFINE_RES_MEM(EDB7211_CS8900_BASE, SZ_1K), |
| 41 | DEFINE_RES_IRQ(EDB7211_CS8900_IRQ), |
| 42 | }; |
Alexander Shiyan | 2a55289 | 2012-10-10 19:45:33 +0400 | [diff] [blame] | 43 | |
Alexander Shiyan | 87c37b5 | 2012-11-17 17:57:18 +0400 | [diff] [blame] | 44 | static 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 | |
| 57 | static struct plat_lcd_data edb7211_lcd_power_pdata = { |
| 58 | .set_power = edb7211_lcd_power_set, |
| 59 | }; |
| 60 | |
Alexander Shiyan | 94760bf | 2012-11-17 17:57:20 +0400 | [diff] [blame^] | 61 | static void edb7211_lcd_backlight_set_intensity(int intensity) |
| 62 | { |
| 63 | gpio_set_value(EDB7211_LCDBL, intensity); |
| 64 | } |
| 65 | |
| 66 | static 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 Shiyan | 87c37b5 | 2012-11-17 17:57:18 +0400 | [diff] [blame] | 73 | static 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 Shiyan | 94760bf | 2012-11-17 17:57:20 +0400 | [diff] [blame^] | 76 | { EDB7211_LCDBL, GPIOF_OUT_INIT_LOW, "LCD BACKLIGHT" }, |
Alexander Shiyan | 87c37b5 | 2012-11-17 17:57:18 +0400 | [diff] [blame] | 77 | }; |
| 78 | |
Alexander Shiyan | 2a55289 | 2012-10-10 19:45:33 +0400 | [diff] [blame] | 79 | static 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 Shiyan | 2a55289 | 2012-10-10 19:45:33 +0400 | [diff] [blame] | 85 | }, { /* 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 | |
| 98 | void __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. */ |
| 105 | static void __init edb7211_reserve(void) |
| 106 | { |
| 107 | memblock_reserve(PHYS_OFFSET, VIDEORAM_SIZE); |
| 108 | } |
| 109 | |
| 110 | static void __init |
| 111 | fixup_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 Shiyan | 200daa3 | 2012-11-17 17:57:07 +0400 | [diff] [blame] | 128 | static void __init edb7211_init(void) |
| 129 | { |
Alexander Shiyan | 87c37b5 | 2012-11-17 17:57:18 +0400 | [diff] [blame] | 130 | 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 Shiyan | 94760bf | 2012-11-17 17:57:20 +0400 | [diff] [blame^] | 135 | platform_device_register_data(&platform_bus, "generic-bl", 0, |
| 136 | &edb7211_lcd_backlight_pdata, |
| 137 | sizeof(edb7211_lcd_backlight_pdata)); |
Alexander Shiyan | dd850f1 | 2012-11-17 17:57:09 +0400 | [diff] [blame] | 138 | platform_device_register_simple("video-clps711x", 0, NULL, 0); |
Alexander Shiyan | 200daa3 | 2012-11-17 17:57:07 +0400 | [diff] [blame] | 139 | platform_device_register_simple("cs89x0", 0, edb7211_cs8900_resource, |
| 140 | ARRAY_SIZE(edb7211_cs8900_resource)); |
| 141 | } |
| 142 | |
Alexander Shiyan | 2a55289 | 2012-10-10 19:45:33 +0400 | [diff] [blame] | 143 | MACHINE_START(EDB7211, "CL-EDB7211 (EP7211 eval board)") |
| 144 | /* Maintainer: Jon McClintock */ |
| 145 | .atag_offset = VIDEORAM_SIZE + 0x100, |
Alexander Shiyan | 0d8be81 | 2012-11-17 17:57:13 +0400 | [diff] [blame] | 146 | .nr_irqs = CLPS711X_NR_IRQS, |
Alexander Shiyan | 2a55289 | 2012-10-10 19:45:33 +0400 | [diff] [blame] | 147 | .fixup = fixup_edb7211, |
Alexander Shiyan | 2a55289 | 2012-10-10 19:45:33 +0400 | [diff] [blame] | 148 | .reserve = edb7211_reserve, |
Alexander Shiyan | 200daa3 | 2012-11-17 17:57:07 +0400 | [diff] [blame] | 149 | .map_io = edb7211_map_io, |
Alexander Shiyan | 2a55289 | 2012-10-10 19:45:33 +0400 | [diff] [blame] | 150 | .init_irq = clps711x_init_irq, |
| 151 | .timer = &clps711x_timer, |
Alexander Shiyan | 200daa3 | 2012-11-17 17:57:07 +0400 | [diff] [blame] | 152 | .init_machine = edb7211_init, |
Alexander Shiyan | 99f04c8 | 2012-11-17 17:57:14 +0400 | [diff] [blame] | 153 | .handle_irq = clps711x_handle_irq, |
Alexander Shiyan | 2a55289 | 2012-10-10 19:45:33 +0400 | [diff] [blame] | 154 | .restart = clps711x_restart, |
| 155 | MACHINE_END |