diff options
Diffstat (limited to 'arch/sh/boards/board-ap325rxa.c')
-rw-r--r-- | arch/sh/boards/board-ap325rxa.c | 116 |
1 files changed, 101 insertions, 15 deletions
diff --git a/arch/sh/boards/board-ap325rxa.c b/arch/sh/boards/board-ap325rxa.c index 1c67cba6e34f..7c35787d29b4 100644 --- a/arch/sh/boards/board-ap325rxa.c +++ b/arch/sh/boards/board-ap325rxa.c | |||
@@ -18,8 +18,11 @@ | |||
18 | #include <linux/mtd/sh_flctl.h> | 18 | #include <linux/mtd/sh_flctl.h> |
19 | #include <linux/delay.h> | 19 | #include <linux/delay.h> |
20 | #include <linux/i2c.h> | 20 | #include <linux/i2c.h> |
21 | #include <linux/smc911x.h> | 21 | #include <linux/smsc911x.h> |
22 | #include <linux/gpio.h> | 22 | #include <linux/gpio.h> |
23 | #include <linux/spi/spi.h> | ||
24 | #include <linux/spi/spi_gpio.h> | ||
25 | #include <media/ov772x.h> | ||
23 | #include <media/soc_camera_platform.h> | 26 | #include <media/soc_camera_platform.h> |
24 | #include <media/sh_mobile_ceu.h> | 27 | #include <media/sh_mobile_ceu.h> |
25 | #include <video/sh_mobile_lcdc.h> | 28 | #include <video/sh_mobile_lcdc.h> |
@@ -27,12 +30,14 @@ | |||
27 | #include <asm/clock.h> | 30 | #include <asm/clock.h> |
28 | #include <cpu/sh7723.h> | 31 | #include <cpu/sh7723.h> |
29 | 32 | ||
30 | static struct smc911x_platdata smc911x_info = { | 33 | static struct smsc911x_platform_config smsc911x_config = { |
31 | .flags = SMC911X_USE_32BIT, | 34 | .phy_interface = PHY_INTERFACE_MODE_MII, |
32 | .irq_flags = IRQF_TRIGGER_LOW, | 35 | .irq_polarity = SMSC911X_IRQ_POLARITY_ACTIVE_LOW, |
36 | .irq_type = SMSC911X_IRQ_TYPE_OPEN_DRAIN, | ||
37 | .flags = SMSC911X_USE_32BIT, | ||
33 | }; | 38 | }; |
34 | 39 | ||
35 | static struct resource smc9118_resources[] = { | 40 | static struct resource smsc9118_resources[] = { |
36 | [0] = { | 41 | [0] = { |
37 | .start = 0xb6080000, | 42 | .start = 0xb6080000, |
38 | .end = 0xb60fffff, | 43 | .end = 0xb60fffff, |
@@ -45,13 +50,13 @@ static struct resource smc9118_resources[] = { | |||
45 | } | 50 | } |
46 | }; | 51 | }; |
47 | 52 | ||
48 | static struct platform_device smc9118_device = { | 53 | static struct platform_device smsc9118_device = { |
49 | .name = "smc911x", | 54 | .name = "smsc911x", |
50 | .id = -1, | 55 | .id = -1, |
51 | .num_resources = ARRAY_SIZE(smc9118_resources), | 56 | .num_resources = ARRAY_SIZE(smsc9118_resources), |
52 | .resource = smc9118_resources, | 57 | .resource = smsc9118_resources, |
53 | .dev = { | 58 | .dev = { |
54 | .platform_data = &smc911x_info, | 59 | .platform_data = &smsc911x_config, |
55 | }, | 60 | }, |
56 | }; | 61 | }; |
57 | 62 | ||
@@ -212,7 +217,14 @@ static struct platform_device lcdc_device = { | |||
212 | }, | 217 | }, |
213 | }; | 218 | }; |
214 | 219 | ||
220 | static void camera_power(int val) | ||
221 | { | ||
222 | gpio_set_value(GPIO_PTZ5, val); /* RST_CAM/RSTB */ | ||
223 | mdelay(10); | ||
224 | } | ||
225 | |||
215 | #ifdef CONFIG_I2C | 226 | #ifdef CONFIG_I2C |
227 | /* support for the old ncm03j camera */ | ||
216 | static unsigned char camera_ncm03j_magic[] = | 228 | static unsigned char camera_ncm03j_magic[] = |
217 | { | 229 | { |
218 | 0x87, 0x00, 0x88, 0x08, 0x89, 0x01, 0x8A, 0xE8, | 230 | 0x87, 0x00, 0x88, 0x08, 0x89, 0x01, 0x8A, 0xE8, |
@@ -233,6 +245,23 @@ static unsigned char camera_ncm03j_magic[] = | |||
233 | 0x63, 0xD4, 0x64, 0xEA, 0xD6, 0x0F, | 245 | 0x63, 0xD4, 0x64, 0xEA, 0xD6, 0x0F, |
234 | }; | 246 | }; |
235 | 247 | ||
248 | static int camera_probe(void) | ||
249 | { | ||
250 | struct i2c_adapter *a = i2c_get_adapter(0); | ||
251 | struct i2c_msg msg; | ||
252 | int ret; | ||
253 | |||
254 | camera_power(1); | ||
255 | msg.addr = 0x6e; | ||
256 | msg.buf = camera_ncm03j_magic; | ||
257 | msg.len = 2; | ||
258 | msg.flags = 0; | ||
259 | ret = i2c_transfer(a, &msg, 1); | ||
260 | camera_power(0); | ||
261 | |||
262 | return ret; | ||
263 | } | ||
264 | |||
236 | static int camera_set_capture(struct soc_camera_platform_info *info, | 265 | static int camera_set_capture(struct soc_camera_platform_info *info, |
237 | int enable) | 266 | int enable) |
238 | { | 267 | { |
@@ -241,9 +270,11 @@ static int camera_set_capture(struct soc_camera_platform_info *info, | |||
241 | int ret = 0; | 270 | int ret = 0; |
242 | int i; | 271 | int i; |
243 | 272 | ||
273 | camera_power(0); | ||
244 | if (!enable) | 274 | if (!enable) |
245 | return 0; /* no disable for now */ | 275 | return 0; /* no disable for now */ |
246 | 276 | ||
277 | camera_power(1); | ||
247 | for (i = 0; i < ARRAY_SIZE(camera_ncm03j_magic); i += 2) { | 278 | for (i = 0; i < ARRAY_SIZE(camera_ncm03j_magic); i += 2) { |
248 | u_int8_t buf[8]; | 279 | u_int8_t buf[8]; |
249 | 280 | ||
@@ -282,8 +313,35 @@ static struct platform_device camera_device = { | |||
282 | .platform_data = &camera_info, | 313 | .platform_data = &camera_info, |
283 | }, | 314 | }, |
284 | }; | 315 | }; |
316 | |||
317 | static int __init camera_setup(void) | ||
318 | { | ||
319 | if (camera_probe() > 0) | ||
320 | platform_device_register(&camera_device); | ||
321 | |||
322 | return 0; | ||
323 | } | ||
324 | late_initcall(camera_setup); | ||
325 | |||
285 | #endif /* CONFIG_I2C */ | 326 | #endif /* CONFIG_I2C */ |
286 | 327 | ||
328 | static int ov7725_power(struct device *dev, int mode) | ||
329 | { | ||
330 | camera_power(0); | ||
331 | if (mode) | ||
332 | camera_power(1); | ||
333 | |||
334 | return 0; | ||
335 | } | ||
336 | |||
337 | static struct ov772x_camera_info ov7725_info = { | ||
338 | .buswidth = SOCAM_DATAWIDTH_8, | ||
339 | .flags = OV772X_FLAG_VFLIP | OV772X_FLAG_HFLIP, | ||
340 | .link = { | ||
341 | .power = ov7725_power, | ||
342 | }, | ||
343 | }; | ||
344 | |||
287 | static struct sh_mobile_ceu_info sh_mobile_ceu_info = { | 345 | static struct sh_mobile_ceu_info sh_mobile_ceu_info = { |
288 | .flags = SOCAM_PCLK_SAMPLE_RISING | SOCAM_HSYNC_ACTIVE_HIGH | | 346 | .flags = SOCAM_PCLK_SAMPLE_RISING | SOCAM_HSYNC_ACTIVE_HIGH | |
289 | SOCAM_VSYNC_ACTIVE_HIGH | SOCAM_MASTER | SOCAM_DATAWIDTH_8, | 347 | SOCAM_VSYNC_ACTIVE_HIGH | SOCAM_MASTER | SOCAM_DATAWIDTH_8, |
@@ -315,21 +373,46 @@ static struct platform_device ceu_device = { | |||
315 | }, | 373 | }, |
316 | }; | 374 | }; |
317 | 375 | ||
376 | struct spi_gpio_platform_data sdcard_cn3_platform_data = { | ||
377 | .sck = GPIO_PTD0, | ||
378 | .mosi = GPIO_PTD1, | ||
379 | .miso = GPIO_PTD2, | ||
380 | .num_chipselect = 1, | ||
381 | }; | ||
382 | |||
383 | static struct platform_device sdcard_cn3_device = { | ||
384 | .name = "spi_gpio", | ||
385 | .dev = { | ||
386 | .platform_data = &sdcard_cn3_platform_data, | ||
387 | }, | ||
388 | }; | ||
389 | |||
318 | static struct platform_device *ap325rxa_devices[] __initdata = { | 390 | static struct platform_device *ap325rxa_devices[] __initdata = { |
319 | &smc9118_device, | 391 | &smsc9118_device, |
320 | &ap325rxa_nor_flash_device, | 392 | &ap325rxa_nor_flash_device, |
321 | &lcdc_device, | 393 | &lcdc_device, |
322 | &ceu_device, | 394 | &ceu_device, |
323 | #ifdef CONFIG_I2C | ||
324 | &camera_device, | ||
325 | #endif | ||
326 | &nand_flash_device, | 395 | &nand_flash_device, |
396 | &sdcard_cn3_device, | ||
327 | }; | 397 | }; |
328 | 398 | ||
329 | static struct i2c_board_info __initdata ap325rxa_i2c_devices[] = { | 399 | static struct i2c_board_info __initdata ap325rxa_i2c_devices[] = { |
330 | { | 400 | { |
331 | I2C_BOARD_INFO("pcf8563", 0x51), | 401 | I2C_BOARD_INFO("pcf8563", 0x51), |
332 | }, | 402 | }, |
403 | { | ||
404 | I2C_BOARD_INFO("ov772x", 0x21), | ||
405 | .platform_data = &ov7725_info, | ||
406 | }, | ||
407 | }; | ||
408 | |||
409 | static struct spi_board_info ap325rxa_spi_devices[] = { | ||
410 | { | ||
411 | .modalias = "mmc_spi", | ||
412 | .max_speed_hz = 5000000, | ||
413 | .chip_select = 0, | ||
414 | .controller_data = (void *) GPIO_PTD5, | ||
415 | }, | ||
333 | }; | 416 | }; |
334 | 417 | ||
335 | static int __init ap325rxa_devices_setup(void) | 418 | static int __init ap325rxa_devices_setup(void) |
@@ -398,7 +481,7 @@ static int __init ap325rxa_devices_setup(void) | |||
398 | gpio_request(GPIO_PTZ6, NULL); | 481 | gpio_request(GPIO_PTZ6, NULL); |
399 | gpio_direction_output(GPIO_PTZ6, 0); /* STBY_CAM */ | 482 | gpio_direction_output(GPIO_PTZ6, 0); /* STBY_CAM */ |
400 | gpio_request(GPIO_PTZ5, NULL); | 483 | gpio_request(GPIO_PTZ5, NULL); |
401 | gpio_direction_output(GPIO_PTZ5, 1); /* RST_CAM */ | 484 | gpio_direction_output(GPIO_PTZ5, 0); /* RST_CAM */ |
402 | gpio_request(GPIO_PTZ4, NULL); | 485 | gpio_request(GPIO_PTZ4, NULL); |
403 | gpio_direction_output(GPIO_PTZ4, 0); /* SADDR */ | 486 | gpio_direction_output(GPIO_PTZ4, 0); /* SADDR */ |
404 | 487 | ||
@@ -429,6 +512,9 @@ static int __init ap325rxa_devices_setup(void) | |||
429 | i2c_register_board_info(0, ap325rxa_i2c_devices, | 512 | i2c_register_board_info(0, ap325rxa_i2c_devices, |
430 | ARRAY_SIZE(ap325rxa_i2c_devices)); | 513 | ARRAY_SIZE(ap325rxa_i2c_devices)); |
431 | 514 | ||
515 | spi_register_board_info(ap325rxa_spi_devices, | ||
516 | ARRAY_SIZE(ap325rxa_spi_devices)); | ||
517 | |||
432 | return platform_add_devices(ap325rxa_devices, | 518 | return platform_add_devices(ap325rxa_devices, |
433 | ARRAY_SIZE(ap325rxa_devices)); | 519 | ARRAY_SIZE(ap325rxa_devices)); |
434 | } | 520 | } |