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