blob: 145341dbebf5a9663d1c9892160e03b9cf4364c5 [file] [log] [blame]
Kuninori Morimoto9b93e242012-04-10 20:57:31 -07001/*
2 * KZM-A9-GT board support
3 *
4 * Copyright (C) 2012 Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; version 2 of the License.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
18 */
Kuninori Morimoto26786112012-04-10 20:58:33 -070019
20#include <linux/delay.h>
Kuninori Morimoto9b93e242012-04-10 20:57:31 -070021#include <linux/gpio.h>
22#include <linux/io.h>
23#include <linux/irq.h>
24#include <linux/platform_device.h>
Kuninori Morimotoc15c4252012-04-10 20:57:58 -070025#include <linux/smsc911x.h>
Kuninori Morimotodd818182012-04-10 20:58:10 -070026#include <linux/usb/r8a66597.h>
Kuninori Morimoto26786112012-04-10 20:58:33 -070027#include <linux/videodev2.h>
Kuninori Morimotoc15c4252012-04-10 20:57:58 -070028#include <mach/irqs.h>
Kuninori Morimoto9b93e242012-04-10 20:57:31 -070029#include <mach/sh73a0.h>
30#include <mach/common.h>
31#include <asm/hardware/cache-l2x0.h>
32#include <asm/hardware/gic.h>
33#include <asm/mach-types.h>
34#include <asm/mach/arch.h>
Kuninori Morimoto26786112012-04-10 20:58:33 -070035#include <video/sh_mobile_lcdc.h>
Kuninori Morimoto9b93e242012-04-10 20:57:31 -070036
Kuninori Morimotoc15c4252012-04-10 20:57:58 -070037/* SMSC 9221 */
38static struct resource smsc9221_resources[] = {
39 [0] = {
40 .start = 0x10000000, /* CS4 */
41 .end = 0x100000ff,
42 .flags = IORESOURCE_MEM,
43 },
44 [1] = {
45 .start = intcs_evt2irq(0x260), /* IRQ3 */
46 .flags = IORESOURCE_IRQ,
47 },
48};
49
50static struct smsc911x_platform_config smsc9221_platdata = {
51 .flags = SMSC911X_USE_32BIT | SMSC911X_SAVE_MAC_ADDRESS,
52 .phy_interface = PHY_INTERFACE_MODE_MII,
53 .irq_polarity = SMSC911X_IRQ_POLARITY_ACTIVE_LOW,
54 .irq_type = SMSC911X_IRQ_TYPE_PUSH_PULL,
55};
56
57static struct platform_device smsc_device = {
58 .name = "smsc911x",
59 .dev = {
60 .platform_data = &smsc9221_platdata,
61 },
62 .resource = smsc9221_resources,
63 .num_resources = ARRAY_SIZE(smsc9221_resources),
64};
65
Kuninori Morimotodd818182012-04-10 20:58:10 -070066/* USB external chip */
67static struct r8a66597_platdata usb_host_data = {
68 .on_chip = 0,
69 .xtal = R8A66597_PLATDATA_XTAL_48MHZ,
70};
71
72static struct resource usb_resources[] = {
73 [0] = {
74 .start = 0x10010000,
75 .end = 0x1001ffff - 1,
76 .flags = IORESOURCE_MEM,
77 },
78 [1] = {
79 .start = intcs_evt2irq(0x220), /* IRQ1 */
80 .flags = IORESOURCE_IRQ,
81 },
82};
83
84static struct platform_device usb_host_device = {
85 .name = "r8a66597_hcd",
86 .dev = {
87 .platform_data = &usb_host_data,
88 .dma_mask = NULL,
89 .coherent_dma_mask = 0xffffffff,
90 },
91 .num_resources = ARRAY_SIZE(usb_resources),
92 .resource = usb_resources,
93};
94
Kuninori Morimoto26786112012-04-10 20:58:33 -070095/* LCDC */
96static struct fb_videomode kzm_lcdc_mode = {
97 .name = "WVGA Panel",
98 .xres = 800,
99 .yres = 480,
100 .left_margin = 220,
101 .right_margin = 110,
102 .hsync_len = 70,
103 .upper_margin = 20,
104 .lower_margin = 5,
105 .vsync_len = 5,
106 .sync = 0,
107};
108
109static struct sh_mobile_lcdc_info lcdc_info = {
110 .clock_source = LCDC_CLK_BUS,
111 .ch[0] = {
112 .chan = LCDC_CHAN_MAINLCD,
113 .fourcc = V4L2_PIX_FMT_RGB565,
114 .interface_type = RGB24,
115 .lcd_modes = &kzm_lcdc_mode,
116 .num_modes = 1,
117 .clock_divider = 5,
118 .flags = 0,
119 .panel_cfg = {
120 .width = 152,
121 .height = 91,
122 },
123 }
124};
125
126static struct resource lcdc_resources[] = {
127 [0] = {
128 .name = "LCDC",
129 .start = 0xfe940000,
130 .end = 0xfe943fff,
131 .flags = IORESOURCE_MEM,
132 },
133 [1] = {
134 .start = intcs_evt2irq(0x580),
135 .flags = IORESOURCE_IRQ,
136 },
137};
138
139static struct platform_device lcdc_device = {
140 .name = "sh_mobile_lcdc_fb",
141 .num_resources = ARRAY_SIZE(lcdc_resources),
142 .resource = lcdc_resources,
143 .dev = {
144 .platform_data = &lcdc_info,
145 .coherent_dma_mask = ~0,
146 },
147};
148
Kuninori Morimoto9b93e242012-04-10 20:57:31 -0700149static struct platform_device *kzm_devices[] __initdata = {
Kuninori Morimotoc15c4252012-04-10 20:57:58 -0700150 &smsc_device,
Kuninori Morimotodd818182012-04-10 20:58:10 -0700151 &usb_host_device,
Kuninori Morimoto26786112012-04-10 20:58:33 -0700152 &lcdc_device,
Kuninori Morimoto9b93e242012-04-10 20:57:31 -0700153};
154
Kuninori Morimoto26786112012-04-10 20:58:33 -0700155/*
156 * FIXME
157 *
158 * This is quick hack for enabling LCDC backlight
159 */
160static int __init as3711_enable_lcdc_backlight(void)
161{
162 struct i2c_adapter *a = i2c_get_adapter(0);
163 struct i2c_msg msg;
164 int i, ret;
165 __u8 magic[] = {
166 0x40, 0x2a,
167 0x43, 0x3c,
168 0x44, 0x3c,
169 0x45, 0x3c,
170 0x54, 0x03,
171 0x51, 0x00,
172 0x51, 0x01,
173 0xff, 0x00, /* wait */
174 0x43, 0xf0,
175 0x44, 0xf0,
176 0x45, 0xf0,
177 };
178
179 if (!machine_is_kzm9g())
180 return 0;
181
182 if (!a)
183 return 0;
184
185 msg.addr = 0x40;
186 msg.len = 2;
187 msg.flags = 0;
188
189 for (i = 0; i < ARRAY_SIZE(magic); i += 2) {
190 msg.buf = magic + i;
191
192 if (0xff == msg.buf[0]) {
193 udelay(500);
194 continue;
195 }
196
197 ret = i2c_transfer(a, &msg, 1);
198 if (ret < 0) {
199 pr_err("i2c transfer fail\n");
200 break;
201 }
202 }
203
204 return 0;
205}
206device_initcall(as3711_enable_lcdc_backlight);
207
Kuninori Morimoto9b93e242012-04-10 20:57:31 -0700208static void __init kzm_init(void)
209{
210 sh73a0_pinmux_init();
211
212 /* enable SCIFA4 */
213 gpio_request(GPIO_FN_SCIFA4_TXD, NULL);
214 gpio_request(GPIO_FN_SCIFA4_RXD, NULL);
215 gpio_request(GPIO_FN_SCIFA4_RTS_, NULL);
216 gpio_request(GPIO_FN_SCIFA4_CTS_, NULL);
217
Kuninori Morimotoc15c4252012-04-10 20:57:58 -0700218 /* CS4 for SMSC/USB */
219 gpio_request(GPIO_FN_CS4_, NULL); /* CS4 */
220
221 /* SMSC */
222 gpio_request(GPIO_PORT224, NULL); /* IRQ3 */
223 gpio_direction_input(GPIO_PORT224);
224
Kuninori Morimoto26786112012-04-10 20:58:33 -0700225 /* LCDC */
226 gpio_request(GPIO_FN_LCDD23, NULL);
227 gpio_request(GPIO_FN_LCDD22, NULL);
228 gpio_request(GPIO_FN_LCDD21, NULL);
229 gpio_request(GPIO_FN_LCDD20, NULL);
230 gpio_request(GPIO_FN_LCDD19, NULL);
231 gpio_request(GPIO_FN_LCDD18, NULL);
232 gpio_request(GPIO_FN_LCDD17, NULL);
233 gpio_request(GPIO_FN_LCDD16, NULL);
234 gpio_request(GPIO_FN_LCDD15, NULL);
235 gpio_request(GPIO_FN_LCDD14, NULL);
236 gpio_request(GPIO_FN_LCDD13, NULL);
237 gpio_request(GPIO_FN_LCDD12, NULL);
238 gpio_request(GPIO_FN_LCDD11, NULL);
239 gpio_request(GPIO_FN_LCDD10, NULL);
240 gpio_request(GPIO_FN_LCDD9, NULL);
241 gpio_request(GPIO_FN_LCDD8, NULL);
242 gpio_request(GPIO_FN_LCDD7, NULL);
243 gpio_request(GPIO_FN_LCDD6, NULL);
244 gpio_request(GPIO_FN_LCDD5, NULL);
245 gpio_request(GPIO_FN_LCDD4, NULL);
246 gpio_request(GPIO_FN_LCDD3, NULL);
247 gpio_request(GPIO_FN_LCDD2, NULL);
248 gpio_request(GPIO_FN_LCDD1, NULL);
249 gpio_request(GPIO_FN_LCDD0, NULL);
250 gpio_request(GPIO_FN_LCDDISP, NULL);
251 gpio_request(GPIO_FN_LCDDCK, NULL);
252
253 gpio_request(GPIO_PORT222, NULL);
254 gpio_direction_output(GPIO_PORT222, 1);
255
Kuninori Morimoto9b93e242012-04-10 20:57:31 -0700256#ifdef CONFIG_CACHE_L2X0
257 /* Early BRESP enable, Shared attribute override enable, 64K*8way */
258 l2x0_init(IOMEM(0xf0100000), 0x40460000, 0x82000fff);
259#endif
260
261 sh73a0_add_standard_devices();
262 platform_add_devices(kzm_devices, ARRAY_SIZE(kzm_devices));
263}
264
265MACHINE_START(KZM9G, "kzm9g")
266 .map_io = sh73a0_map_io,
267 .init_early = sh73a0_add_early_devices,
268 .nr_irqs = NR_IRQS_LEGACY,
269 .init_irq = sh73a0_init_irq,
270 .handle_irq = gic_handle_irq,
271 .init_machine = kzm_init,
272 .timer = &shmobile_timer,
273MACHINE_END