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