2 * KZM-A9-GT board support
4 * Copyright (C) 2012 Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
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.
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.
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
20 #include <linux/delay.h>
21 #include <linux/gpio.h>
23 #include <linux/irq.h>
24 #include <linux/i2c.h>
25 #include <linux/platform_device.h>
26 #include <linux/smsc911x.h>
27 #include <linux/usb/r8a66597.h>
28 #include <linux/videodev2.h>
29 #include <mach/irqs.h>
30 #include <mach/sh73a0.h>
31 #include <mach/common.h>
32 #include <asm/hardware/cache-l2x0.h>
33 #include <asm/hardware/gic.h>
34 #include <asm/mach-types.h>
35 #include <asm/mach/arch.h>
36 #include <video/sh_mobile_lcdc.h>
39 static struct resource smsc9221_resources[] = {
41 .start = 0x10000000, /* CS4 */
43 .flags = IORESOURCE_MEM,
46 .start = intcs_evt2irq(0x260), /* IRQ3 */
47 .flags = IORESOURCE_IRQ,
51 static struct smsc911x_platform_config smsc9221_platdata = {
52 .flags = SMSC911X_USE_32BIT | SMSC911X_SAVE_MAC_ADDRESS,
53 .phy_interface = PHY_INTERFACE_MODE_MII,
54 .irq_polarity = SMSC911X_IRQ_POLARITY_ACTIVE_LOW,
55 .irq_type = SMSC911X_IRQ_TYPE_PUSH_PULL,
58 static struct platform_device smsc_device = {
61 .platform_data = &smsc9221_platdata,
63 .resource = smsc9221_resources,
64 .num_resources = ARRAY_SIZE(smsc9221_resources),
67 /* USB external chip */
68 static struct r8a66597_platdata usb_host_data = {
70 .xtal = R8A66597_PLATDATA_XTAL_48MHZ,
73 static struct resource usb_resources[] = {
76 .end = 0x1001ffff - 1,
77 .flags = IORESOURCE_MEM,
80 .start = intcs_evt2irq(0x220), /* IRQ1 */
81 .flags = IORESOURCE_IRQ,
85 static struct platform_device usb_host_device = {
86 .name = "r8a66597_hcd",
88 .platform_data = &usb_host_data,
90 .coherent_dma_mask = 0xffffffff,
92 .num_resources = ARRAY_SIZE(usb_resources),
93 .resource = usb_resources,
97 static struct fb_videomode kzm_lcdc_mode = {
110 static struct sh_mobile_lcdc_info lcdc_info = {
111 .clock_source = LCDC_CLK_BUS,
113 .chan = LCDC_CHAN_MAINLCD,
114 .fourcc = V4L2_PIX_FMT_RGB565,
115 .interface_type = RGB24,
116 .lcd_modes = &kzm_lcdc_mode,
127 static struct resource lcdc_resources[] = {
132 .flags = IORESOURCE_MEM,
135 .start = intcs_evt2irq(0x580),
136 .flags = IORESOURCE_IRQ,
140 static struct platform_device lcdc_device = {
141 .name = "sh_mobile_lcdc_fb",
142 .num_resources = ARRAY_SIZE(lcdc_resources),
143 .resource = lcdc_resources,
145 .platform_data = &lcdc_info,
146 .coherent_dma_mask = ~0,
150 static struct i2c_board_info i2c1_devices[] = {
152 I2C_BOARD_INFO("st1232-ts", 0x55),
153 .irq = intcs_evt2irq(0x300), /* IRQ8 */
157 static struct platform_device *kzm_devices[] __initdata = {
166 * This is quick hack for enabling LCDC backlight
168 static int __init as3711_enable_lcdc_backlight(void)
170 struct i2c_adapter *a = i2c_get_adapter(0);
181 0xff, 0x00, /* wait */
187 if (!machine_is_kzm9g())
197 for (i = 0; i < ARRAY_SIZE(magic); i += 2) {
200 if (0xff == msg.buf[0]) {
205 ret = i2c_transfer(a, &msg, 1);
207 pr_err("i2c transfer fail\n");
214 device_initcall(as3711_enable_lcdc_backlight);
216 static void __init kzm_init(void)
218 sh73a0_pinmux_init();
221 gpio_request(GPIO_FN_SCIFA4_TXD, NULL);
222 gpio_request(GPIO_FN_SCIFA4_RXD, NULL);
223 gpio_request(GPIO_FN_SCIFA4_RTS_, NULL);
224 gpio_request(GPIO_FN_SCIFA4_CTS_, NULL);
226 /* CS4 for SMSC/USB */
227 gpio_request(GPIO_FN_CS4_, NULL); /* CS4 */
230 gpio_request(GPIO_PORT224, NULL); /* IRQ3 */
231 gpio_direction_input(GPIO_PORT224);
234 gpio_request(GPIO_FN_LCDD23, NULL);
235 gpio_request(GPIO_FN_LCDD22, NULL);
236 gpio_request(GPIO_FN_LCDD21, NULL);
237 gpio_request(GPIO_FN_LCDD20, NULL);
238 gpio_request(GPIO_FN_LCDD19, NULL);
239 gpio_request(GPIO_FN_LCDD18, NULL);
240 gpio_request(GPIO_FN_LCDD17, NULL);
241 gpio_request(GPIO_FN_LCDD16, NULL);
242 gpio_request(GPIO_FN_LCDD15, NULL);
243 gpio_request(GPIO_FN_LCDD14, NULL);
244 gpio_request(GPIO_FN_LCDD13, NULL);
245 gpio_request(GPIO_FN_LCDD12, NULL);
246 gpio_request(GPIO_FN_LCDD11, NULL);
247 gpio_request(GPIO_FN_LCDD10, NULL);
248 gpio_request(GPIO_FN_LCDD9, NULL);
249 gpio_request(GPIO_FN_LCDD8, NULL);
250 gpio_request(GPIO_FN_LCDD7, NULL);
251 gpio_request(GPIO_FN_LCDD6, NULL);
252 gpio_request(GPIO_FN_LCDD5, NULL);
253 gpio_request(GPIO_FN_LCDD4, NULL);
254 gpio_request(GPIO_FN_LCDD3, NULL);
255 gpio_request(GPIO_FN_LCDD2, NULL);
256 gpio_request(GPIO_FN_LCDD1, NULL);
257 gpio_request(GPIO_FN_LCDD0, NULL);
258 gpio_request(GPIO_FN_LCDDISP, NULL);
259 gpio_request(GPIO_FN_LCDDCK, NULL);
261 gpio_request(GPIO_PORT222, NULL); /* LCDCDON */
262 gpio_request(GPIO_PORT226, NULL); /* SC */
263 gpio_direction_output(GPIO_PORT222, 1);
264 gpio_direction_output(GPIO_PORT226, 1);
267 gpio_request(GPIO_PORT223, NULL); /* IRQ8 */
268 gpio_direction_input(GPIO_PORT223);
270 #ifdef CONFIG_CACHE_L2X0
271 /* Early BRESP enable, Shared attribute override enable, 64K*8way */
272 l2x0_init(IOMEM(0xf0100000), 0x40460000, 0x82000fff);
275 i2c_register_board_info(1, i2c1_devices, ARRAY_SIZE(i2c1_devices));
277 sh73a0_add_standard_devices();
278 platform_add_devices(kzm_devices, ARRAY_SIZE(kzm_devices));
281 MACHINE_START(KZM9G, "kzm9g")
282 .map_io = sh73a0_map_io,
283 .init_early = sh73a0_add_early_devices,
284 .nr_irqs = NR_IRQS_LEGACY,
285 .init_irq = sh73a0_init_irq,
286 .handle_irq = gic_handle_irq,
287 .init_machine = kzm_init,
288 .timer = &shmobile_timer,