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 | |
Alexander Shiyan | 96754a1 | 2012-11-17 17:57:21 +0400 | [diff] [blame] | 19 | #include <linux/mtd/physmap.h> |
| 20 | #include <linux/mtd/partitions.h> |
| 21 | |
Alexander Shiyan | 2a55289 | 2012-10-10 19:45:33 +0400 | [diff] [blame] | 22 | #include <asm/setup.h> |
| 23 | #include <asm/mach/map.h> |
| 24 | #include <asm/mach/arch.h> |
| 25 | #include <asm/mach-types.h> |
| 26 | |
Alexander Shiyan | 87c37b5 | 2012-11-17 17:57:18 +0400 | [diff] [blame] | 27 | #include <video/platform_lcd.h> |
| 28 | |
Alexander Shiyan | 2a55289 | 2012-10-10 19:45:33 +0400 | [diff] [blame] | 29 | #include <mach/hardware.h> |
| 30 | |
| 31 | #include "common.h" |
| 32 | |
Alexander Shiyan | 200daa3 | 2012-11-17 17:57:07 +0400 | [diff] [blame] | 33 | #define VIDEORAM_SIZE SZ_128K |
| 34 | |
Alexander Shiyan | 87c37b5 | 2012-11-17 17:57:18 +0400 | [diff] [blame] | 35 | #define EDB7211_LCD_DC_DC_EN CLPS711X_GPIO(3, 1) |
| 36 | #define EDB7211_LCDEN CLPS711X_GPIO(3, 2) |
Alexander Shiyan | 94760bf | 2012-11-17 17:57:20 +0400 | [diff] [blame] | 37 | #define EDB7211_LCDBL CLPS711X_GPIO(3, 3) |
Alexander Shiyan | 87c37b5 | 2012-11-17 17:57:18 +0400 | [diff] [blame] | 38 | |
Alexander Shiyan | 96754a1 | 2012-11-17 17:57:21 +0400 | [diff] [blame] | 39 | #define EDB7211_FLASH0_BASE (CS0_PHYS_BASE) |
| 40 | #define EDB7211_FLASH1_BASE (CS1_PHYS_BASE) |
Alexander Shiyan | 200daa3 | 2012-11-17 17:57:07 +0400 | [diff] [blame] | 41 | #define EDB7211_CS8900_BASE (CS2_PHYS_BASE + 0x300) |
| 42 | #define EDB7211_CS8900_IRQ (IRQ_EINT3) |
| 43 | |
| 44 | static struct resource edb7211_cs8900_resource[] __initdata = { |
| 45 | DEFINE_RES_MEM(EDB7211_CS8900_BASE, SZ_1K), |
| 46 | DEFINE_RES_IRQ(EDB7211_CS8900_IRQ), |
| 47 | }; |
Alexander Shiyan | 2a55289 | 2012-10-10 19:45:33 +0400 | [diff] [blame] | 48 | |
Alexander Shiyan | 96754a1 | 2012-11-17 17:57:21 +0400 | [diff] [blame] | 49 | static struct mtd_partition edb7211_flash_partitions[] __initdata = { |
| 50 | { |
| 51 | .name = "Flash", |
| 52 | .offset = 0, |
| 53 | .size = MTDPART_SIZ_FULL, |
| 54 | }, |
| 55 | }; |
| 56 | |
| 57 | static struct physmap_flash_data edb7211_flash_pdata __initdata = { |
| 58 | .width = 4, |
| 59 | .parts = edb7211_flash_partitions, |
| 60 | .nr_parts = ARRAY_SIZE(edb7211_flash_partitions), |
| 61 | }; |
| 62 | |
| 63 | static struct resource edb7211_flash_resources[] __initdata = { |
| 64 | DEFINE_RES_MEM(EDB7211_FLASH0_BASE, SZ_8M), |
| 65 | DEFINE_RES_MEM(EDB7211_FLASH1_BASE, SZ_8M), |
| 66 | }; |
| 67 | |
| 68 | static struct platform_device edb7211_flash_pdev __initdata = { |
| 69 | .name = "physmap-flash", |
| 70 | .id = 0, |
| 71 | .resource = edb7211_flash_resources, |
| 72 | .num_resources = ARRAY_SIZE(edb7211_flash_resources), |
| 73 | .dev = { |
| 74 | .platform_data = &edb7211_flash_pdata, |
| 75 | }, |
| 76 | }; |
| 77 | |
Alexander Shiyan | 87c37b5 | 2012-11-17 17:57:18 +0400 | [diff] [blame] | 78 | static void edb7211_lcd_power_set(struct plat_lcd_data *pd, unsigned int power) |
| 79 | { |
| 80 | if (power) { |
| 81 | gpio_set_value(EDB7211_LCDEN, 1); |
| 82 | udelay(100); |
| 83 | gpio_set_value(EDB7211_LCD_DC_DC_EN, 1); |
| 84 | } else { |
| 85 | gpio_set_value(EDB7211_LCD_DC_DC_EN, 0); |
| 86 | udelay(100); |
| 87 | gpio_set_value(EDB7211_LCDEN, 0); |
| 88 | } |
| 89 | } |
| 90 | |
| 91 | static struct plat_lcd_data edb7211_lcd_power_pdata = { |
| 92 | .set_power = edb7211_lcd_power_set, |
| 93 | }; |
| 94 | |
Alexander Shiyan | 94760bf | 2012-11-17 17:57:20 +0400 | [diff] [blame] | 95 | static void edb7211_lcd_backlight_set_intensity(int intensity) |
| 96 | { |
| 97 | gpio_set_value(EDB7211_LCDBL, intensity); |
| 98 | } |
| 99 | |
| 100 | static struct generic_bl_info edb7211_lcd_backlight_pdata = { |
| 101 | .name = "lcd-backlight.0", |
| 102 | .default_intensity = 0x01, |
| 103 | .max_intensity = 0x01, |
| 104 | .set_bl_intensity = edb7211_lcd_backlight_set_intensity, |
| 105 | }; |
| 106 | |
Alexander Shiyan | 87c37b5 | 2012-11-17 17:57:18 +0400 | [diff] [blame] | 107 | static struct gpio edb7211_gpios[] __initconst = { |
| 108 | { EDB7211_LCD_DC_DC_EN, GPIOF_OUT_INIT_LOW, "LCD DC-DC" }, |
| 109 | { EDB7211_LCDEN, GPIOF_OUT_INIT_LOW, "LCD POWER" }, |
Alexander Shiyan | 94760bf | 2012-11-17 17:57:20 +0400 | [diff] [blame] | 110 | { EDB7211_LCDBL, GPIOF_OUT_INIT_LOW, "LCD BACKLIGHT" }, |
Alexander Shiyan | 87c37b5 | 2012-11-17 17:57:18 +0400 | [diff] [blame] | 111 | }; |
| 112 | |
Alexander Shiyan | 2a55289 | 2012-10-10 19:45:33 +0400 | [diff] [blame] | 113 | static struct map_desc edb7211_io_desc[] __initdata = { |
| 114 | { /* Memory-mapped extra keyboard row */ |
| 115 | .virtual = IO_ADDRESS(EP7211_PHYS_EXTKBD), |
| 116 | .pfn = __phys_to_pfn(EP7211_PHYS_EXTKBD), |
| 117 | .length = SZ_1M, |
| 118 | .type = MT_DEVICE, |
Alexander Shiyan | 2a55289 | 2012-10-10 19:45:33 +0400 | [diff] [blame] | 119 | }, |
| 120 | }; |
| 121 | |
| 122 | void __init edb7211_map_io(void) |
| 123 | { |
| 124 | clps711x_map_io(); |
| 125 | iotable_init(edb7211_io_desc, ARRAY_SIZE(edb7211_io_desc)); |
| 126 | } |
| 127 | |
| 128 | /* Reserve screen memory region at the start of main system memory. */ |
| 129 | static void __init edb7211_reserve(void) |
| 130 | { |
| 131 | memblock_reserve(PHYS_OFFSET, VIDEORAM_SIZE); |
| 132 | } |
| 133 | |
| 134 | static void __init |
| 135 | fixup_edb7211(struct tag *tags, char **cmdline, struct meminfo *mi) |
| 136 | { |
| 137 | /* |
| 138 | * Bank start addresses are not present in the information |
| 139 | * passed in from the boot loader. We could potentially |
| 140 | * detect them, but instead we hard-code them. |
| 141 | * |
| 142 | * Banks sizes _are_ present in the param block, but we're |
| 143 | * not using that information yet. |
| 144 | */ |
| 145 | mi->bank[0].start = 0xc0000000; |
| 146 | mi->bank[0].size = SZ_8M; |
| 147 | mi->bank[1].start = 0xc1000000; |
| 148 | mi->bank[1].size = SZ_8M; |
| 149 | mi->nr_banks = 2; |
| 150 | } |
| 151 | |
Alexander Shiyan | 200daa3 | 2012-11-17 17:57:07 +0400 | [diff] [blame] | 152 | static void __init edb7211_init(void) |
| 153 | { |
Alexander Shiyan | 87c37b5 | 2012-11-17 17:57:18 +0400 | [diff] [blame] | 154 | gpio_request_array(edb7211_gpios, ARRAY_SIZE(edb7211_gpios)); |
| 155 | |
Alexander Shiyan | 96754a1 | 2012-11-17 17:57:21 +0400 | [diff] [blame] | 156 | platform_device_register(&edb7211_flash_pdev); |
Alexander Shiyan | 87c37b5 | 2012-11-17 17:57:18 +0400 | [diff] [blame] | 157 | platform_device_register_data(&platform_bus, "platform-lcd", 0, |
| 158 | &edb7211_lcd_power_pdata, |
| 159 | sizeof(edb7211_lcd_power_pdata)); |
Alexander Shiyan | 94760bf | 2012-11-17 17:57:20 +0400 | [diff] [blame] | 160 | platform_device_register_data(&platform_bus, "generic-bl", 0, |
| 161 | &edb7211_lcd_backlight_pdata, |
| 162 | sizeof(edb7211_lcd_backlight_pdata)); |
Alexander Shiyan | dd850f1 | 2012-11-17 17:57:09 +0400 | [diff] [blame] | 163 | platform_device_register_simple("video-clps711x", 0, NULL, 0); |
Alexander Shiyan | 200daa3 | 2012-11-17 17:57:07 +0400 | [diff] [blame] | 164 | platform_device_register_simple("cs89x0", 0, edb7211_cs8900_resource, |
| 165 | ARRAY_SIZE(edb7211_cs8900_resource)); |
| 166 | } |
| 167 | |
Alexander Shiyan | 2a55289 | 2012-10-10 19:45:33 +0400 | [diff] [blame] | 168 | MACHINE_START(EDB7211, "CL-EDB7211 (EP7211 eval board)") |
| 169 | /* Maintainer: Jon McClintock */ |
| 170 | .atag_offset = VIDEORAM_SIZE + 0x100, |
Alexander Shiyan | 0d8be81 | 2012-11-17 17:57:13 +0400 | [diff] [blame] | 171 | .nr_irqs = CLPS711X_NR_IRQS, |
Alexander Shiyan | 2a55289 | 2012-10-10 19:45:33 +0400 | [diff] [blame] | 172 | .fixup = fixup_edb7211, |
Alexander Shiyan | 2a55289 | 2012-10-10 19:45:33 +0400 | [diff] [blame] | 173 | .reserve = edb7211_reserve, |
Alexander Shiyan | 200daa3 | 2012-11-17 17:57:07 +0400 | [diff] [blame] | 174 | .map_io = edb7211_map_io, |
Alexander Shiyan | 2a55289 | 2012-10-10 19:45:33 +0400 | [diff] [blame] | 175 | .init_irq = clps711x_init_irq, |
Stephen Warren | 6bb27d7 | 2012-11-08 12:40:59 -0700 | [diff] [blame] | 176 | .init_time = clps711x_timer_init, |
Alexander Shiyan | 200daa3 | 2012-11-17 17:57:07 +0400 | [diff] [blame] | 177 | .init_machine = edb7211_init, |
Alexander Shiyan | 99f04c8 | 2012-11-17 17:57:14 +0400 | [diff] [blame] | 178 | .handle_irq = clps711x_handle_irq, |
Alexander Shiyan | 2a55289 | 2012-10-10 19:45:33 +0400 | [diff] [blame] | 179 | .restart = clps711x_restart, |
| 180 | MACHINE_END |