From patchwork Wed Nov 11 11:01:57 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Antonio Ospite X-Patchwork-Id: 2053 Return-path: Envelope-to: mchehab@infradead.org Delivery-date: Wed, 11 Nov 2009 11:02:44 +0000 Received: from bombadil.infradead.org [18.85.46.34] by pedra.chehab.org with IMAP (fetchmail-6.3.6) for (single-drop); Wed, 11 Nov 2009 17:02:26 -0200 (BRST) Received: from vger.kernel.org ([209.132.176.167]) by bombadil.infradead.org with esmtp (Exim 4.69 #1 (Red Hat Linux)) id 1N8AyJ-0006W0-OP; Wed, 11 Nov 2009 11:02:44 +0000 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1757251AbZKKLCg (ORCPT + 1 other); Wed, 11 Nov 2009 06:02:36 -0500 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1757131AbZKKLCg (ORCPT ); Wed, 11 Nov 2009 06:02:36 -0500 Received: from smtp-out114.alice.it ([85.37.17.114]:1102 "EHLO smtp-out114.alice.it" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756616AbZKKLCf (ORCPT ); Wed, 11 Nov 2009 06:02:35 -0500 Received: from FBCMMO03.fbc.local ([192.168.68.197]) by smtp-out114.alice.it with Microsoft SMTPSVC(6.0.3790.3959); Wed, 11 Nov 2009 12:02:37 +0100 Received: from FBCMCL01B04.fbc.local ([192.168.69.85]) by FBCMMO03.fbc.local with Microsoft SMTPSVC(6.0.3790.3959); Wed, 11 Nov 2009 12:02:36 +0100 Received: from badebec ([87.6.141.58]) by FBCMCL01B04.fbc.local with Microsoft SMTPSVC(6.0.3790.3959); Wed, 11 Nov 2009 12:02:35 +0100 Received: by badebec with local (Exim 4.69) (envelope-from ) id 1N8Ay7-0004L9-UF; Wed, 11 Nov 2009 12:02:31 +0100 From: Antonio Ospite To: linux-arm-kernel@lists.infradead.org Cc: Antonio Ospite , Eric Miao , openezx-devel@lists.openezx.org, Bart Visscher , linux-media@vger.kernel.org, Guennadi Liakhovetski Subject: [PATCH 1/3 v3] Add camera support for A780 and A910 EZX phones Date: Wed, 11 Nov 2009 12:01:57 +0100 Message-Id: <1257937317-16655-1-git-send-email-ospite@studenti.unina.it> X-Mailer: git-send-email 1.6.5.2 In-Reply-To: References: To: linux-arm-kernel@lists.infradead.org X-OriginalArrivalTime: 11 Nov 2009 11:02:36.0056 (UTC) FILETIME=[79D17980:01CA62BE] Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org Signed-off-by: Bart Visscher Signed-off-by: Antonio Ospite --- Changes since v2: - Bart's SOB goes first, as he is the original author. - Add MFP_LPM_DRIVE_HIGH to camera gpios, as per Motorola original code. - s/pxacamera/camera/ in function names, as they are not used in pxacamera_platform_data - Adjust comments about CAM_RST which is active on rising edge - Saner default values for nCAM_EN and CAM_RST gpios - Setup gpios statically at board init. Eric, if it is easier for you I can send the three patches together again. Thanks, Antonio arch/arm/mach-pxa/ezx.c | 172 +++++++++++++++++++++++++++++++++++++++++++++- 1 files changed, 168 insertions(+), 4 deletions(-) diff --git a/arch/arm/mach-pxa/ezx.c b/arch/arm/mach-pxa/ezx.c index 588b265..74423a6 100644 --- a/arch/arm/mach-pxa/ezx.c +++ b/arch/arm/mach-pxa/ezx.c @@ -17,8 +17,11 @@ #include #include #include +#include #include +#include + #include #include #include @@ -29,6 +32,7 @@ #include #include #include +#include #include "devices.h" #include "generic.h" @@ -38,6 +42,9 @@ #define GPIO15_A910_FLIP_LID 15 #define GPIO12_E680_LOCK_SWITCH 12 #define GPIO15_E6_LOCK_SWITCH 15 +#define GPIO50_nCAM_EN 50 +#define GPIO19_GEN1_CAM_RST 19 +#define GPIO28_GEN2_CAM_RST 28 static struct platform_pwm_backlight_data ezx_backlight_data = { .pwm_id = 0, @@ -191,8 +198,8 @@ static unsigned long gen1_pin_config[] __initdata = { GPIO94_CIF_DD_5, GPIO17_CIF_DD_6, GPIO108_CIF_DD_7, - GPIO50_GPIO, /* CAM_EN */ - GPIO19_GPIO, /* CAM_RST */ + GPIO50_GPIO | MFP_LPM_DRIVE_HIGH, /* CAM_EN */ + GPIO19_GPIO | MFP_LPM_DRIVE_HIGH, /* CAM_RST */ /* EMU */ GPIO120_GPIO, /* EMU_MUX1 */ @@ -248,8 +255,8 @@ static unsigned long gen2_pin_config[] __initdata = { GPIO48_CIF_DD_5, GPIO93_CIF_DD_6, GPIO12_CIF_DD_7, - GPIO50_GPIO, /* CAM_EN */ - GPIO28_GPIO, /* CAM_RST */ + GPIO50_GPIO | MFP_LPM_DRIVE_HIGH, /* CAM_EN */ + GPIO28_GPIO | MFP_LPM_DRIVE_HIGH, /* CAM_RST */ GPIO17_GPIO, /* CAM_FLASH */ }; #endif @@ -683,8 +690,84 @@ static struct platform_device a780_gpio_keys = { }, }; +/* camera */ +static int a780_camera_init(void) +{ + int err; + + /* + * GPIO50_nCAM_EN is active low + * GPIO19_GEN1_CAM_RST is active on rising edge + */ + err = gpio_request(GPIO50_nCAM_EN, "nCAM_EN"); + if (err) { + pr_err("%s: Failed to request nCAM_EN\n", __func__); + goto fail; + } + + err = gpio_request(GPIO19_GEN1_CAM_RST, "CAM_RST"); + if (err) { + pr_err("%s: Failed to request CAM_RST\n", __func__); + goto fail_gpio_cam_rst; + } + + gpio_direction_output(GPIO50_nCAM_EN, 1); + gpio_direction_output(GPIO19_GEN1_CAM_RST, 0); + + return 0; + +fail_gpio_cam_rst: + gpio_free(GPIO50_nCAM_EN); +fail: + return err; +} + +static int a780_camera_power(struct device *dev, int on) +{ + gpio_set_value(GPIO50_nCAM_EN, !on); + return 0; +} + +static int a780_camera_reset(struct device *dev) +{ + gpio_set_value(GPIO19_GEN1_CAM_RST, 0); + msleep(10); + gpio_set_value(GPIO19_GEN1_CAM_RST, 1); + + return 0; +} + +struct pxacamera_platform_data a780_pxacamera_platform_data = { + .flags = PXA_CAMERA_MASTER | PXA_CAMERA_DATAWIDTH_8 | + PXA_CAMERA_PCLK_EN | PXA_CAMERA_MCLK_EN, + .mclk_10khz = 5000, +}; + +static struct i2c_board_info a780_camera_i2c_board_info = { + I2C_BOARD_INFO("mt9m111", 0x5d), +}; + +static struct soc_camera_link a780_iclink = { + .bus_id = 0, + .flags = SOCAM_SENSOR_INVERT_PCLK, + .i2c_adapter_id = 0, + .board_info = &a780_camera_i2c_board_info, + .module_name = "mt9m111", + .power = a780_camera_power, + .reset = a780_camera_reset, +}; + +static struct platform_device a780_camera = { + .name = "soc-camera-pdrv", + .id = 0, + .dev = { + .platform_data = &a780_iclink, + }, +}; + static struct platform_device *a780_devices[] __initdata = { &a780_gpio_keys, + &a780_camera, }; static void __init a780_init(void) @@ -699,6 +782,9 @@ static void __init a780_init(void) pxa_set_keypad_info(&a780_keypad_platform_data); + a780_camera_init(); + pxa_set_camera_info(&a780_pxacamera_platform_data); + platform_add_devices(ARRAY_AND_SIZE(ezx_devices)); platform_add_devices(ARRAY_AND_SIZE(a780_devices)); } @@ -864,8 +950,83 @@ static struct platform_device a910_gpio_keys = { }, }; +/* camera */ +static int a910_camera_init(void) +{ + int err; + + /* + * GPIO50_nCAM_EN is active low + * GPIO28_GEN2_CAM_RST is active on rising edge + */ + err = gpio_request(GPIO50_nCAM_EN, "nCAM_EN"); + if (err) { + pr_err("%s: Failed to request nCAM_EN\n", __func__); + goto fail; + } + + err = gpio_request(GPIO28_GEN2_CAM_RST, "CAM_RST"); + if (err) { + pr_err("%s: Failed to request CAM_RST\n", __func__); + goto fail_gpio_cam_rst; + } + + gpio_direction_output(GPIO50_nCAM_EN, 1); + gpio_direction_output(GPIO28_GEN2_CAM_RST, 0); + + return 0; + +fail_gpio_cam_rst: + gpio_free(GPIO50_nCAM_EN); +fail: + return err; +} + +static int a910_camera_power(struct device *dev, int on) +{ + gpio_set_value(GPIO50_nCAM_EN, !on); + return 0; +} + +static int a910_camera_reset(struct device *dev) +{ + gpio_set_value(GPIO28_GEN2_CAM_RST, 0); + msleep(10); + gpio_set_value(GPIO28_GEN2_CAM_RST, 1); + + return 0; +} + +struct pxacamera_platform_data a910_pxacamera_platform_data = { + .flags = PXA_CAMERA_MASTER | PXA_CAMERA_DATAWIDTH_8 | + PXA_CAMERA_PCLK_EN | PXA_CAMERA_MCLK_EN, + .mclk_10khz = 5000, +}; + +static struct i2c_board_info a910_camera_i2c_board_info = { + I2C_BOARD_INFO("mt9m111", 0x5d), +}; + +static struct soc_camera_link a910_iclink = { + .bus_id = 0, + .i2c_adapter_id = 0, + .board_info = &a910_camera_i2c_board_info, + .module_name = "mt9m111", + .power = a910_camera_power, + .reset = a910_camera_reset, +}; + +static struct platform_device a910_camera = { + .name = "soc-camera-pdrv", + .id = 0, + .dev = { + .platform_data = &a910_iclink, + }, +}; + static struct platform_device *a910_devices[] __initdata = { &a910_gpio_keys, + &a910_camera, }; static void __init a910_init(void) @@ -880,6 +1041,9 @@ static void __init a910_init(void) pxa_set_keypad_info(&a910_keypad_platform_data); + a910_camera_init(); + pxa_set_camera_info(&a910_pxacamera_platform_data); + platform_add_devices(ARRAY_AND_SIZE(ezx_devices)); platform_add_devices(ARRAY_AND_SIZE(a910_devices)); }