blob: f33979784f382161d2565258914f26164ba65e1b [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 Shiyan362168f2013-05-13 21:07:34 +040015#include <linux/i2c-gpio.h>
Alexander Shiyan200daa32012-11-17 17:57:07 +040016#include <linux/interrupt.h>
17#include <linux/platform_device.h>
Alexander Shiyane917ba42014-08-19 16:31:14 +040018#include <linux/pwm.h>
19#include <linux/pwm_backlight.h>
Laura Abbott1c2f87c2014-04-13 22:54:58 +010020#include <linux/memblock.h>
Alexander Shiyan2a552892012-10-10 19:45:33 +040021
Alexander Shiyan96754a12012-11-17 17:57:21 +040022#include <linux/mtd/physmap.h>
23#include <linux/mtd/partitions.h>
24
Alexander Shiyan2a552892012-10-10 19:45:33 +040025#include <asm/setup.h>
26#include <asm/mach/map.h>
27#include <asm/mach/arch.h>
28#include <asm/mach-types.h>
29
Alexander Shiyan87c37b52012-11-17 17:57:18 +040030#include <video/platform_lcd.h>
31
Alexander Shiyan2a552892012-10-10 19:45:33 +040032#include <mach/hardware.h>
33
34#include "common.h"
Alexander Shiyane328b882013-04-26 19:47:29 +040035#include "devices.h"
Alexander Shiyan2a552892012-10-10 19:45:33 +040036
Alexander Shiyan200daa32012-11-17 17:57:07 +040037#define VIDEORAM_SIZE SZ_128K
38
Alexander Shiyan87c37b52012-11-17 17:57:18 +040039#define EDB7211_LCD_DC_DC_EN CLPS711X_GPIO(3, 1)
40#define EDB7211_LCDEN CLPS711X_GPIO(3, 2)
Alexander Shiyan94760bf2012-11-17 17:57:20 +040041#define EDB7211_LCDBL CLPS711X_GPIO(3, 3)
Alexander Shiyan87c37b52012-11-17 17:57:18 +040042
Alexander Shiyan362168f2013-05-13 21:07:34 +040043#define EDB7211_I2C_SDA CLPS711X_GPIO(3, 4)
44#define EDB7211_I2C_SCL CLPS711X_GPIO(3, 5)
45
Alexander Shiyan96754a12012-11-17 17:57:21 +040046#define EDB7211_FLASH0_BASE (CS0_PHYS_BASE)
47#define EDB7211_FLASH1_BASE (CS1_PHYS_BASE)
Alexander Shiyan7e4615c2013-05-13 21:07:30 +040048
Alexander Shiyan200daa32012-11-17 17:57:07 +040049#define EDB7211_CS8900_BASE (CS2_PHYS_BASE + 0x300)
50#define EDB7211_CS8900_IRQ (IRQ_EINT3)
51
Alexander Shiyan7e4615c2013-05-13 21:07:30 +040052/* The extra 8 lines of the keyboard matrix */
53#define EDB7211_EXTKBD_BASE (CS3_PHYS_BASE)
54
Alexander Shiyan362168f2013-05-13 21:07:34 +040055static 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 Shiyan200daa32012-11-17 17:57:07 +040061static struct resource edb7211_cs8900_resource[] __initdata = {
62 DEFINE_RES_MEM(EDB7211_CS8900_BASE, SZ_1K),
63 DEFINE_RES_IRQ(EDB7211_CS8900_IRQ),
64};
Alexander Shiyan2a552892012-10-10 19:45:33 +040065
Alexander Shiyan96754a12012-11-17 17:57:21 +040066static struct mtd_partition edb7211_flash_partitions[] __initdata = {
67 {
68 .name = "Flash",
69 .offset = 0,
70 .size = MTDPART_SIZ_FULL,
71 },
72};
73
74static 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
80static 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
85static 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 Shiyan87c37b52012-11-17 17:57:18 +040095static 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
108static struct plat_lcd_data edb7211_lcd_power_pdata = {
109 .set_power = edb7211_lcd_power_set,
110};
111
Alexander Shiyane917ba42014-08-19 16:31:14 +0400112static struct pwm_lookup edb7211_pwm_lookup[] = {
113 PWM_LOOKUP("clps711x-pwm", 0, "pwm-backlight.0", NULL,
114 0, PWM_POLARITY_NORMAL),
Alexander Shiyan94760bf2012-11-17 17:57:20 +0400115};
116
Alexander Shiyane917ba42014-08-19 16:31:14 +0400117static struct platform_pwm_backlight_data pwm_bl_pdata = {
118 .dft_brightness = 0x01,
119 .max_brightness = 0x0f,
120 .enable_gpio = EDB7211_LCDBL,
121};
122
123static struct resource clps711x_pwm_res =
124 DEFINE_RES_MEM(CLPS711X_PHYS_BASE + PMPCON, SZ_4);
125
Alexander Shiyan87c37b52012-11-17 17:57:18 +0400126static 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 Shiyan2a552892012-10-10 19:45:33 +0400131/* Reserve screen memory region at the start of main system memory. */
132static void __init edb7211_reserve(void)
133{
134 memblock_reserve(PHYS_OFFSET, VIDEORAM_SIZE);
135}
136
137static void __init
Laura Abbott1c2f87c2014-04-13 22:54:58 +0100138fixup_edb7211(struct tag *tags, char **cmdline)
Alexander Shiyan2a552892012-10-10 19:45:33 +0400139{
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 Abbott1c2f87c2014-04-13 22:54:58 +0100148 memblock_add(0xc0000000, SZ_8M);
149 memblock_add(0xc1000000, SZ_8M);
Alexander Shiyan2a552892012-10-10 19:45:33 +0400150}
151
Alexander Shiyane328b882013-04-26 19:47:29 +0400152static void __init edb7211_init_late(void)
153{
Alexander Shiyan87c37b52012-11-17 17:57:18 +0400154 gpio_request_array(edb7211_gpios, ARRAY_SIZE(edb7211_gpios));
155
Alexander Shiyan96754a12012-11-17 17:57:21 +0400156 platform_device_register(&edb7211_flash_pdev);
Alexander Shiyane917ba42014-08-19 16:31:14 +0400157
Pawel Molld2168142014-07-23 18:07:18 +0100158 platform_device_register_data(NULL, "platform-lcd", 0,
Alexander Shiyan87c37b52012-11-17 17:57:18 +0400159 &edb7211_lcd_power_pdata,
160 sizeof(edb7211_lcd_power_pdata));
Alexander Shiyane917ba42014-08-19 16:31:14 +0400161
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 Shiyandd850f12012-11-17 17:57:09 +0400169 platform_device_register_simple("video-clps711x", 0, NULL, 0);
Alexander Shiyan200daa32012-11-17 17:57:07 +0400170 platform_device_register_simple("cs89x0", 0, edb7211_cs8900_resource,
171 ARRAY_SIZE(edb7211_cs8900_resource));
Pawel Molld2168142014-07-23 18:07:18 +0100172 platform_device_register_data(NULL, "i2c-gpio", 0,
Alexander Shiyan362168f2013-05-13 21:07:34 +0400173 &edb7211_i2c_pdata,
174 sizeof(edb7211_i2c_pdata));
Alexander Shiyan200daa32012-11-17 17:57:07 +0400175}
176
Alexander Shiyan2a552892012-10-10 19:45:33 +0400177MACHINE_START(EDB7211, "CL-EDB7211 (EP7211 eval board)")
178 /* Maintainer: Jon McClintock */
179 .atag_offset = VIDEORAM_SIZE + 0x100,
180 .fixup = fixup_edb7211,
Alexander Shiyan2a552892012-10-10 19:45:33 +0400181 .reserve = edb7211_reserve,
Alexander Shiyanea04dd32013-07-18 22:34:55 +0400182 .map_io = clps711x_map_io,
Alexander Shiyan2a552892012-10-10 19:45:33 +0400183 .init_irq = clps711x_init_irq,
Stephen Warren6bb27d72012-11-08 12:40:59 -0700184 .init_time = clps711x_timer_init,
Alexander Shiyan402277e2014-06-19 19:26:37 +0400185 .init_machine = clps711x_devices_init,
Alexander Shiyane328b882013-04-26 19:47:29 +0400186 .init_late = edb7211_init_late,
Alexander Shiyan2a552892012-10-10 19:45:33 +0400187 .restart = clps711x_restart,
188MACHINE_END