3 * (Compatible with Algo System ., LTD. - AP-320A)
5 * Copyright (C) 2008 Renesas Solutions Corp.
6 * Author : Yusuke Goda <goda.yuske@renesas.com>
8 * This file is subject to the terms and conditions of the GNU General Public
9 * License. See the file "COPYING" in the main directory of this archive
13 #include <linux/init.h>
14 #include <linux/device.h>
15 #include <linux/interrupt.h>
16 #include <linux/platform_device.h>
17 #include <linux/mtd/physmap.h>
18 #include <linux/delay.h>
19 #include <linux/i2c.h>
20 #include <linux/smc911x.h>
21 #include <media/soc_camera_platform.h>
22 #include <media/sh_mobile_ceu.h>
23 #include <asm/sh_mobile_lcdc.h>
25 #include <asm/clock.h>
27 static struct smc911x_platdata smc911x_info = {
28 .flags = SMC911X_USE_32BIT,
29 .irq_flags = IRQF_TRIGGER_LOW,
32 static struct resource smc9118_resources[] = {
36 .flags = IORESOURCE_MEM,
41 .flags = IORESOURCE_IRQ,
45 static struct platform_device smc9118_device = {
48 .num_resources = ARRAY_SIZE(smc9118_resources),
49 .resource = smc9118_resources,
51 .platform_data = &smc911x_info,
55 static struct mtd_partition ap325rxa_nor_flash_partitions[] = {
59 .size = (1 * 1024 * 1024),
60 .mask_flags = MTD_WRITEABLE, /* Read-only */
63 .offset = MTDPART_OFS_APPEND,
64 .size = (2 * 1024 * 1024),
67 .offset = MTDPART_OFS_APPEND,
68 .size = MTDPART_SIZ_FULL,
72 static struct physmap_flash_data ap325rxa_nor_flash_data = {
74 .parts = ap325rxa_nor_flash_partitions,
75 .nr_parts = ARRAY_SIZE(ap325rxa_nor_flash_partitions),
78 static struct resource ap325rxa_nor_flash_resources[] = {
83 .flags = IORESOURCE_MEM,
87 static struct platform_device ap325rxa_nor_flash_device = {
88 .name = "physmap-flash",
89 .resource = ap325rxa_nor_flash_resources,
90 .num_resources = ARRAY_SIZE(ap325rxa_nor_flash_resources),
92 .platform_data = &ap325rxa_nor_flash_data,
96 #define FPGA_LCDREG 0xB4100180
97 #define FPGA_BKLREG 0xB4100212
98 #define FPGA_LCDREG_VAL 0x0018
99 #define PORT_PHCR 0xA405010E
100 #define PORT_PLCR 0xA4050114
101 #define PORT_PMCR 0xA4050116
102 #define PORT_PRCR 0xA405011C
103 #define PORT_PSCR 0xA405011E
104 #define PORT_PZCR 0xA405014C
105 #define PORT_HIZCRA 0xA4050158
106 #define PORT_MSELCRB 0xA4050182
107 #define PORT_PSDR 0xA405013E
108 #define PORT_PZDR 0xA405016C
109 #define PORT_PSELD 0xA4050154
111 static void ap320_wvga_power_on(void *board_data)
115 /* ASD AP-320/325 LCD ON */
116 ctrl_outw(FPGA_LCDREG_VAL, FPGA_LCDREG);
119 ctrl_outw((ctrl_inw(PORT_PSCR) & ~0x00C0) | 0x40, PORT_PSCR);
120 ctrl_outb(ctrl_inb(PORT_PSDR) & ~0x08, PORT_PSDR);
121 ctrl_outw(0x100, FPGA_BKLREG);
124 static struct sh_mobile_lcdc_info lcdc_info = {
125 .clock_source = LCDC_CLK_EXTERNAL,
127 .chan = LCDC_CHAN_MAINLCD,
129 .interface_type = RGB18,
141 .sync = 0, /* hsync and vsync are active low */
143 .lcd_size_cfg = { /* 7.0 inch */
148 .display_on = ap320_wvga_power_on,
153 static struct resource lcdc_resources[] = {
156 .start = 0xfe940000, /* P4-only space */
158 .flags = IORESOURCE_MEM,
162 static struct platform_device lcdc_device = {
163 .name = "sh_mobile_lcdc_fb",
164 .num_resources = ARRAY_SIZE(lcdc_resources),
165 .resource = lcdc_resources,
167 .platform_data = &lcdc_info,
172 static unsigned char camera_ncm03j_magic[] =
174 0x87, 0x00, 0x88, 0x08, 0x89, 0x01, 0x8A, 0xE8,
175 0x1D, 0x00, 0x1E, 0x8A, 0x21, 0x00, 0x33, 0x36,
176 0x36, 0x60, 0x37, 0x08, 0x3B, 0x31, 0x44, 0x0F,
177 0x46, 0xF0, 0x4B, 0x28, 0x4C, 0x21, 0x4D, 0x55,
178 0x4E, 0x1B, 0x4F, 0xC7, 0x50, 0xFC, 0x51, 0x12,
179 0x58, 0x02, 0x66, 0xC0, 0x67, 0x46, 0x6B, 0xA0,
180 0x6C, 0x34, 0x7E, 0x25, 0x7F, 0x25, 0x8D, 0x0F,
181 0x92, 0x40, 0x93, 0x04, 0x94, 0x26, 0x95, 0x0A,
182 0x99, 0x03, 0x9A, 0xF0, 0x9B, 0x14, 0x9D, 0x7A,
183 0xC5, 0x02, 0xD6, 0x07, 0x59, 0x00, 0x5A, 0x1A,
184 0x5B, 0x2A, 0x5C, 0x37, 0x5D, 0x42, 0x5E, 0x56,
185 0xC8, 0x00, 0xC9, 0x1A, 0xCA, 0x2A, 0xCB, 0x37,
186 0xCC, 0x42, 0xCD, 0x56, 0xCE, 0x00, 0xCF, 0x1A,
187 0xD0, 0x2A, 0xD1, 0x37, 0xD2, 0x42, 0xD3, 0x56,
188 0x5F, 0x68, 0x60, 0x87, 0x61, 0xA3, 0x62, 0xBC,
189 0x63, 0xD4, 0x64, 0xEA, 0xD6, 0x0F,
192 static int camera_set_capture(struct soc_camera_platform_info *info,
195 struct i2c_adapter *a = i2c_get_adapter(0);
201 return 0; /* no disable for now */
203 for (i = 0; i < ARRAY_SIZE(camera_ncm03j_magic); i += 2) {
211 buf[0] = camera_ncm03j_magic[i];
212 buf[1] = camera_ncm03j_magic[i + 1];
214 ret = (ret < 0) ? ret : i2c_transfer(a, &msg, 1);
220 static struct soc_camera_platform_info camera_info = {
222 .format_name = "UYVY",
225 .pixelformat = V4L2_PIX_FMT_UYVY,
226 .colorspace = V4L2_COLORSPACE_SMPTE170M,
230 .bus_param = SOCAM_PCLK_SAMPLE_RISING | SOCAM_HSYNC_ACTIVE_HIGH |
231 SOCAM_VSYNC_ACTIVE_HIGH | SOCAM_MASTER | SOCAM_DATAWIDTH_8,
232 .set_capture = camera_set_capture,
235 static struct platform_device camera_device = {
236 .name = "soc_camera_platform",
238 .platform_data = &camera_info,
241 #endif /* CONFIG_I2C */
243 static struct sh_mobile_ceu_info sh_mobile_ceu_info = {
244 .flags = SOCAM_PCLK_SAMPLE_RISING | SOCAM_HSYNC_ACTIVE_HIGH |
245 SOCAM_VSYNC_ACTIVE_HIGH | SOCAM_MASTER | SOCAM_DATAWIDTH_8,
248 static struct resource ceu_resources[] = {
253 .flags = IORESOURCE_MEM,
257 .flags = IORESOURCE_IRQ,
260 /* place holder for contiguous memory */
264 static struct platform_device ceu_device = {
265 .name = "sh_mobile_ceu",
266 .num_resources = ARRAY_SIZE(ceu_resources),
267 .resource = ceu_resources,
269 .platform_data = &sh_mobile_ceu_info,
273 static struct platform_device *ap325rxa_devices[] __initdata = {
275 &ap325rxa_nor_flash_device,
283 static struct i2c_board_info __initdata ap325rxa_i2c_devices[] = {
286 static int __init ap325rxa_devices_setup(void)
288 clk_always_enable("mstp200"); /* LCDC */
289 clk_always_enable("mstp203"); /* CEU */
291 platform_resource_setup_memory(&ceu_device, "ceu", 4 << 20);
293 i2c_register_board_info(0, ap325rxa_i2c_devices,
294 ARRAY_SIZE(ap325rxa_i2c_devices));
296 return platform_add_devices(ap325rxa_devices,
297 ARRAY_SIZE(ap325rxa_devices));
299 device_initcall(ap325rxa_devices_setup);
301 static void __init ap325rxa_setup(char **cmdline_p)
303 /* LCDC configuration */
304 ctrl_outw(ctrl_inw(PORT_PHCR) & ~0xffff, PORT_PHCR);
305 ctrl_outw(ctrl_inw(PORT_PLCR) & ~0xffff, PORT_PLCR);
306 ctrl_outw(ctrl_inw(PORT_PMCR) & ~0xffff, PORT_PMCR);
307 ctrl_outw(ctrl_inw(PORT_PRCR) & ~0x03ff, PORT_PRCR);
308 ctrl_outw(ctrl_inw(PORT_HIZCRA) & ~0x01C0, PORT_HIZCRA);
311 ctrl_outw(ctrl_inw(PORT_MSELCRB) & ~0x0001, PORT_MSELCRB);
312 ctrl_outw(ctrl_inw(PORT_PSELD) & ~0x0003, PORT_PSELD);
313 ctrl_outw((ctrl_inw(PORT_PZCR) & ~0xff00) | 0x5500, PORT_PZCR);
314 ctrl_outb((ctrl_inb(PORT_PZDR) & ~0xf0) | 0x20, PORT_PZDR);
317 static struct sh_machine_vector mv_ap325rxa __initmv = {
318 .mv_name = "AP-325RXA",
319 .mv_setup = ap325rxa_setup,