Kuninori Morimoto | 9b93e24 | 2012-04-10 20:57:31 -0700 | [diff] [blame] | 1 | /* |
| 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 Morimoto | 2678611 | 2012-04-10 20:58:33 -0700 | [diff] [blame] | 19 | |
| 20 | #include <linux/delay.h> |
Kuninori Morimoto | 9b93e24 | 2012-04-10 20:57:31 -0700 | [diff] [blame] | 21 | #include <linux/gpio.h> |
| 22 | #include <linux/io.h> |
| 23 | #include <linux/irq.h> |
Kuninori Morimoto | 407c052 | 2012-04-10 20:58:45 -0700 | [diff] [blame] | 24 | #include <linux/i2c.h> |
Kuninori Morimoto | 9b93e24 | 2012-04-10 20:57:31 -0700 | [diff] [blame] | 25 | #include <linux/platform_device.h> |
Kuninori Morimoto | c15c425 | 2012-04-10 20:57:58 -0700 | [diff] [blame] | 26 | #include <linux/smsc911x.h> |
Kuninori Morimoto | dd81818 | 2012-04-10 20:58:10 -0700 | [diff] [blame] | 27 | #include <linux/usb/r8a66597.h> |
Kuninori Morimoto | 2678611 | 2012-04-10 20:58:33 -0700 | [diff] [blame] | 28 | #include <linux/videodev2.h> |
Kuninori Morimoto | c15c425 | 2012-04-10 20:57:58 -0700 | [diff] [blame] | 29 | #include <mach/irqs.h> |
Kuninori Morimoto | 9b93e24 | 2012-04-10 20:57:31 -0700 | [diff] [blame] | 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> |
Kuninori Morimoto | 2678611 | 2012-04-10 20:58:33 -0700 | [diff] [blame] | 36 | #include <video/sh_mobile_lcdc.h> |
Kuninori Morimoto | 9b93e24 | 2012-04-10 20:57:31 -0700 | [diff] [blame] | 37 | |
Kuninori Morimoto | c15c425 | 2012-04-10 20:57:58 -0700 | [diff] [blame] | 38 | /* SMSC 9221 */ |
| 39 | static struct resource smsc9221_resources[] = { |
| 40 | [0] = { |
| 41 | .start = 0x10000000, /* CS4 */ |
| 42 | .end = 0x100000ff, |
| 43 | .flags = IORESOURCE_MEM, |
| 44 | }, |
| 45 | [1] = { |
| 46 | .start = intcs_evt2irq(0x260), /* IRQ3 */ |
| 47 | .flags = IORESOURCE_IRQ, |
| 48 | }, |
| 49 | }; |
| 50 | |
| 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, |
| 56 | }; |
| 57 | |
| 58 | static struct platform_device smsc_device = { |
| 59 | .name = "smsc911x", |
| 60 | .dev = { |
| 61 | .platform_data = &smsc9221_platdata, |
| 62 | }, |
| 63 | .resource = smsc9221_resources, |
| 64 | .num_resources = ARRAY_SIZE(smsc9221_resources), |
| 65 | }; |
| 66 | |
Kuninori Morimoto | dd81818 | 2012-04-10 20:58:10 -0700 | [diff] [blame] | 67 | /* USB external chip */ |
| 68 | static struct r8a66597_platdata usb_host_data = { |
| 69 | .on_chip = 0, |
| 70 | .xtal = R8A66597_PLATDATA_XTAL_48MHZ, |
| 71 | }; |
| 72 | |
| 73 | static struct resource usb_resources[] = { |
| 74 | [0] = { |
| 75 | .start = 0x10010000, |
| 76 | .end = 0x1001ffff - 1, |
| 77 | .flags = IORESOURCE_MEM, |
| 78 | }, |
| 79 | [1] = { |
| 80 | .start = intcs_evt2irq(0x220), /* IRQ1 */ |
| 81 | .flags = IORESOURCE_IRQ, |
| 82 | }, |
| 83 | }; |
| 84 | |
| 85 | static struct platform_device usb_host_device = { |
| 86 | .name = "r8a66597_hcd", |
| 87 | .dev = { |
| 88 | .platform_data = &usb_host_data, |
| 89 | .dma_mask = NULL, |
| 90 | .coherent_dma_mask = 0xffffffff, |
| 91 | }, |
| 92 | .num_resources = ARRAY_SIZE(usb_resources), |
| 93 | .resource = usb_resources, |
| 94 | }; |
| 95 | |
Kuninori Morimoto | 2678611 | 2012-04-10 20:58:33 -0700 | [diff] [blame] | 96 | /* LCDC */ |
| 97 | static struct fb_videomode kzm_lcdc_mode = { |
| 98 | .name = "WVGA Panel", |
| 99 | .xres = 800, |
| 100 | .yres = 480, |
| 101 | .left_margin = 220, |
| 102 | .right_margin = 110, |
| 103 | .hsync_len = 70, |
| 104 | .upper_margin = 20, |
| 105 | .lower_margin = 5, |
| 106 | .vsync_len = 5, |
| 107 | .sync = 0, |
| 108 | }; |
| 109 | |
| 110 | static struct sh_mobile_lcdc_info lcdc_info = { |
| 111 | .clock_source = LCDC_CLK_BUS, |
| 112 | .ch[0] = { |
| 113 | .chan = LCDC_CHAN_MAINLCD, |
| 114 | .fourcc = V4L2_PIX_FMT_RGB565, |
| 115 | .interface_type = RGB24, |
| 116 | .lcd_modes = &kzm_lcdc_mode, |
| 117 | .num_modes = 1, |
| 118 | .clock_divider = 5, |
| 119 | .flags = 0, |
| 120 | .panel_cfg = { |
| 121 | .width = 152, |
| 122 | .height = 91, |
| 123 | }, |
| 124 | } |
| 125 | }; |
| 126 | |
| 127 | static struct resource lcdc_resources[] = { |
| 128 | [0] = { |
| 129 | .name = "LCDC", |
| 130 | .start = 0xfe940000, |
| 131 | .end = 0xfe943fff, |
| 132 | .flags = IORESOURCE_MEM, |
| 133 | }, |
| 134 | [1] = { |
| 135 | .start = intcs_evt2irq(0x580), |
| 136 | .flags = IORESOURCE_IRQ, |
| 137 | }, |
| 138 | }; |
| 139 | |
| 140 | static struct platform_device lcdc_device = { |
| 141 | .name = "sh_mobile_lcdc_fb", |
| 142 | .num_resources = ARRAY_SIZE(lcdc_resources), |
| 143 | .resource = lcdc_resources, |
| 144 | .dev = { |
| 145 | .platform_data = &lcdc_info, |
| 146 | .coherent_dma_mask = ~0, |
| 147 | }, |
| 148 | }; |
| 149 | |
Kuninori Morimoto | 407c052 | 2012-04-10 20:58:45 -0700 | [diff] [blame] | 150 | static struct i2c_board_info i2c1_devices[] = { |
| 151 | { |
| 152 | I2C_BOARD_INFO("st1232-ts", 0x55), |
| 153 | .irq = intcs_evt2irq(0x300), /* IRQ8 */ |
| 154 | }, |
| 155 | }; |
| 156 | |
Kuninori Morimoto | 9b93e24 | 2012-04-10 20:57:31 -0700 | [diff] [blame] | 157 | static struct platform_device *kzm_devices[] __initdata = { |
Kuninori Morimoto | c15c425 | 2012-04-10 20:57:58 -0700 | [diff] [blame] | 158 | &smsc_device, |
Kuninori Morimoto | dd81818 | 2012-04-10 20:58:10 -0700 | [diff] [blame] | 159 | &usb_host_device, |
Kuninori Morimoto | 2678611 | 2012-04-10 20:58:33 -0700 | [diff] [blame] | 160 | &lcdc_device, |
Kuninori Morimoto | 9b93e24 | 2012-04-10 20:57:31 -0700 | [diff] [blame] | 161 | }; |
| 162 | |
Kuninori Morimoto | 2678611 | 2012-04-10 20:58:33 -0700 | [diff] [blame] | 163 | /* |
| 164 | * FIXME |
| 165 | * |
| 166 | * This is quick hack for enabling LCDC backlight |
| 167 | */ |
| 168 | static int __init as3711_enable_lcdc_backlight(void) |
| 169 | { |
| 170 | struct i2c_adapter *a = i2c_get_adapter(0); |
| 171 | struct i2c_msg msg; |
| 172 | int i, ret; |
| 173 | __u8 magic[] = { |
| 174 | 0x40, 0x2a, |
| 175 | 0x43, 0x3c, |
| 176 | 0x44, 0x3c, |
| 177 | 0x45, 0x3c, |
| 178 | 0x54, 0x03, |
| 179 | 0x51, 0x00, |
| 180 | 0x51, 0x01, |
| 181 | 0xff, 0x00, /* wait */ |
| 182 | 0x43, 0xf0, |
| 183 | 0x44, 0xf0, |
| 184 | 0x45, 0xf0, |
| 185 | }; |
| 186 | |
| 187 | if (!machine_is_kzm9g()) |
| 188 | return 0; |
| 189 | |
| 190 | if (!a) |
| 191 | return 0; |
| 192 | |
| 193 | msg.addr = 0x40; |
| 194 | msg.len = 2; |
| 195 | msg.flags = 0; |
| 196 | |
| 197 | for (i = 0; i < ARRAY_SIZE(magic); i += 2) { |
| 198 | msg.buf = magic + i; |
| 199 | |
| 200 | if (0xff == msg.buf[0]) { |
| 201 | udelay(500); |
| 202 | continue; |
| 203 | } |
| 204 | |
| 205 | ret = i2c_transfer(a, &msg, 1); |
| 206 | if (ret < 0) { |
| 207 | pr_err("i2c transfer fail\n"); |
| 208 | break; |
| 209 | } |
| 210 | } |
| 211 | |
| 212 | return 0; |
| 213 | } |
| 214 | device_initcall(as3711_enable_lcdc_backlight); |
| 215 | |
Kuninori Morimoto | 9b93e24 | 2012-04-10 20:57:31 -0700 | [diff] [blame] | 216 | static void __init kzm_init(void) |
| 217 | { |
| 218 | sh73a0_pinmux_init(); |
| 219 | |
| 220 | /* enable SCIFA4 */ |
| 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); |
| 225 | |
Kuninori Morimoto | c15c425 | 2012-04-10 20:57:58 -0700 | [diff] [blame] | 226 | /* CS4 for SMSC/USB */ |
| 227 | gpio_request(GPIO_FN_CS4_, NULL); /* CS4 */ |
| 228 | |
| 229 | /* SMSC */ |
| 230 | gpio_request(GPIO_PORT224, NULL); /* IRQ3 */ |
| 231 | gpio_direction_input(GPIO_PORT224); |
| 232 | |
Kuninori Morimoto | 2678611 | 2012-04-10 20:58:33 -0700 | [diff] [blame] | 233 | /* LCDC */ |
| 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); |
| 260 | |
Kuninori Morimoto | 601df61 | 2012-04-22 23:53:24 -0700 | [diff] [blame^] | 261 | gpio_request(GPIO_PORT222, NULL); /* LCDCDON */ |
| 262 | gpio_request(GPIO_PORT226, NULL); /* SC */ |
Kuninori Morimoto | 2678611 | 2012-04-10 20:58:33 -0700 | [diff] [blame] | 263 | gpio_direction_output(GPIO_PORT222, 1); |
Kuninori Morimoto | 601df61 | 2012-04-22 23:53:24 -0700 | [diff] [blame^] | 264 | gpio_direction_output(GPIO_PORT226, 1); |
Kuninori Morimoto | 2678611 | 2012-04-10 20:58:33 -0700 | [diff] [blame] | 265 | |
Kuninori Morimoto | 407c052 | 2012-04-10 20:58:45 -0700 | [diff] [blame] | 266 | /* Touchscreen */ |
| 267 | gpio_request(GPIO_PORT223, NULL); /* IRQ8 */ |
| 268 | gpio_direction_input(GPIO_PORT223); |
| 269 | |
Kuninori Morimoto | 9b93e24 | 2012-04-10 20:57:31 -0700 | [diff] [blame] | 270 | #ifdef CONFIG_CACHE_L2X0 |
| 271 | /* Early BRESP enable, Shared attribute override enable, 64K*8way */ |
| 272 | l2x0_init(IOMEM(0xf0100000), 0x40460000, 0x82000fff); |
| 273 | #endif |
| 274 | |
Kuninori Morimoto | 407c052 | 2012-04-10 20:58:45 -0700 | [diff] [blame] | 275 | i2c_register_board_info(1, i2c1_devices, ARRAY_SIZE(i2c1_devices)); |
| 276 | |
Kuninori Morimoto | 9b93e24 | 2012-04-10 20:57:31 -0700 | [diff] [blame] | 277 | sh73a0_add_standard_devices(); |
| 278 | platform_add_devices(kzm_devices, ARRAY_SIZE(kzm_devices)); |
| 279 | } |
| 280 | |
| 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, |
| 289 | MACHINE_END |