diff options
Diffstat (limited to 'arch/arm/mach-pxa/pcm990-baseboard.c')
-rw-r--r-- | arch/arm/mach-pxa/pcm990-baseboard.c | 23 |
1 files changed, 16 insertions, 7 deletions
diff --git a/arch/arm/mach-pxa/pcm990-baseboard.c b/arch/arm/mach-pxa/pcm990-baseboard.c index 095521e9ee24..01791d74e08e 100644 --- a/arch/arm/mach-pxa/pcm990-baseboard.c +++ b/arch/arm/mach-pxa/pcm990-baseboard.c | |||
@@ -380,12 +380,12 @@ static struct pca953x_platform_data pca9536_data = { | |||
380 | .gpio_base = NR_BUILTIN_GPIO, | 380 | .gpio_base = NR_BUILTIN_GPIO, |
381 | }; | 381 | }; |
382 | 382 | ||
383 | static int gpio_bus_switch; | 383 | static int gpio_bus_switch = -EINVAL; |
384 | 384 | ||
385 | static int pcm990_camera_set_bus_param(struct soc_camera_link *link, | 385 | static int pcm990_camera_set_bus_param(struct soc_camera_link *link, |
386 | unsigned long flags) | 386 | unsigned long flags) |
387 | { | 387 | { |
388 | if (gpio_bus_switch <= 0) { | 388 | if (gpio_bus_switch < 0) { |
389 | if (flags == SOCAM_DATAWIDTH_10) | 389 | if (flags == SOCAM_DATAWIDTH_10) |
390 | return 0; | 390 | return 0; |
391 | else | 391 | else |
@@ -404,25 +404,34 @@ static unsigned long pcm990_camera_query_bus_param(struct soc_camera_link *link) | |||
404 | { | 404 | { |
405 | int ret; | 405 | int ret; |
406 | 406 | ||
407 | if (!gpio_bus_switch) { | 407 | if (gpio_bus_switch < 0) { |
408 | ret = gpio_request(NR_BUILTIN_GPIO, "camera"); | 408 | ret = gpio_request(NR_BUILTIN_GPIO, "camera"); |
409 | if (!ret) { | 409 | if (!ret) { |
410 | gpio_bus_switch = NR_BUILTIN_GPIO; | 410 | gpio_bus_switch = NR_BUILTIN_GPIO; |
411 | gpio_direction_output(gpio_bus_switch, 0); | 411 | gpio_direction_output(gpio_bus_switch, 0); |
412 | } else | 412 | } |
413 | gpio_bus_switch = -EINVAL; | ||
414 | } | 413 | } |
415 | 414 | ||
416 | if (gpio_bus_switch > 0) | 415 | if (gpio_bus_switch >= 0) |
417 | return SOCAM_DATAWIDTH_8 | SOCAM_DATAWIDTH_10; | 416 | return SOCAM_DATAWIDTH_8 | SOCAM_DATAWIDTH_10; |
418 | else | 417 | else |
419 | return SOCAM_DATAWIDTH_10; | 418 | return SOCAM_DATAWIDTH_10; |
420 | } | 419 | } |
421 | 420 | ||
421 | static void pcm990_camera_free_bus(struct soc_camera_link *link) | ||
422 | { | ||
423 | if (gpio_bus_switch < 0) | ||
424 | return; | ||
425 | |||
426 | gpio_free(gpio_bus_switch); | ||
427 | gpio_bus_switch = -EINVAL; | ||
428 | } | ||
429 | |||
422 | static struct soc_camera_link iclink = { | 430 | static struct soc_camera_link iclink = { |
423 | .bus_id = 0, /* Must match with the camera ID above */ | 431 | .bus_id = 0, /* Must match with the camera ID above */ |
424 | .query_bus_param = pcm990_camera_query_bus_param, | 432 | .query_bus_param = pcm990_camera_query_bus_param, |
425 | .set_bus_param = pcm990_camera_set_bus_param, | 433 | .set_bus_param = pcm990_camera_set_bus_param, |
434 | .free_bus = pcm990_camera_free_bus, | ||
426 | }; | 435 | }; |
427 | 436 | ||
428 | /* Board I2C devices. */ | 437 | /* Board I2C devices. */ |