From patchwork Sun Feb 17 15:16:49 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?q?Pali_Roh=C3=A1r?= X-Patchwork-Id: 2153251 Return-Path: X-Original-To: patchwork-linux-omap@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork1.kernel.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by patchwork1.kernel.org (Postfix) with ESMTP id 29E4B3FE37 for ; Sun, 17 Feb 2013 15:17:28 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756286Ab3BQPQ7 (ORCPT ); Sun, 17 Feb 2013 10:16:59 -0500 Received: from mail-ee0-f49.google.com ([74.125.83.49]:57329 "EHLO mail-ee0-f49.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756127Ab3BQPQ6 (ORCPT ); Sun, 17 Feb 2013 10:16:58 -0500 Received: by mail-ee0-f49.google.com with SMTP id d4so2480627eek.36 for ; Sun, 17 Feb 2013 07:16:56 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=x-received:from:to:subject:date:user-agent:mime-version :content-type:content-transfer-encoding:message-id; bh=oHhGoSr0qmxZkkEDxqponqOuuJUZZC+bcU/1bFS0Hpw=; b=FrYFaf4vFyL2GvxaS1xMoco03lr0GV2FVrRsV93xNt/byKzZ8MHPVIj1iQPVArQ7Pp QWI45ZqCqOI0eNZfszh+NIk7zVtQNR7RBbXHM8cMJNpzTixYOi+ppb9UTx+CK/Qfkoyt YvRCqGUm9I51v7yFKDmwTpLJh7P/ihcA0K/hsaDJlpu5qBD2/q/O/VihPyH5jMFzmCuD pRsiatkFQzCZScKqOssZMmOv73VfYVaZ8YOHpFDKlhC6BalyGU2XMldcIeWxp4mjZVaF 9Y39T61k8VZsUXQRFXUSw4BTmoshZ6ouje7L82PyJ/2tyHYrO8lY4pNjqrBUvA43YJOU Vugw== X-Received: by 10.14.204.195 with SMTP id h43mr33504961eeo.14.1361114215911; Sun, 17 Feb 2013 07:16:55 -0800 (PST) Received: from pali-elitebook.localnet (pali.kolej.mff.cuni.cz. [78.128.193.202]) by mx.google.com with ESMTPS id q42sm84506055eem.14.2013.02.17.07.16.51 (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Sun, 17 Feb 2013 07:16:52 -0800 (PST) From: Pali =?utf-8?q?Roh=C3=A1r?= To: Tony Lindgren , linux-omap@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH] ADP1653 board code for Nokia RX-51 Date: Sun, 17 Feb 2013 16:16:49 +0100 User-Agent: KMail/1.13.7 (Linux/3.5.0-24-generic; KDE/4.10.0; x86_64; ; ) MIME-Version: 1.0 Message-Id: <201302171616.50152@pali> Sender: linux-omap-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-omap@vger.kernel.org Hello, I'm sending ADP1653 flash torch board code for Nokia RX-51. Kernel driver ADP1653 is already in upstream kernel. Board code was extracted from this big camera meego patch: https://api.pub.meego.com/public/source/CE:Adaptation:N900/kernel-adaptation-n900/linux-2.6-Camera-for-Meego-N900-Adaptation-kernel-2.6.37-patch.patch diff --git a/arch/arm/mach-omap2/board-rx51.c b/arch/arm/mach-omap2/board-rx51.c index d0374ea..92117a13 100644 --- a/arch/arm/mach-omap2/board-rx51.c +++ b/arch/arm/mach-omap2/board-rx51.c @@ -75,6 +75,7 @@ static struct platform_device leds_gpio = { */ extern void __init rx51_peripherals_init(void); +extern void __init rx51_camera_init(void); #ifdef CONFIG_OMAP_MUX static struct omap_board_mux board_mux[] __initdata = { @@ -100,6 +101,7 @@ static void __init rx51_init(void) usb_musb_init(&musb_board_data); rx51_peripherals_init(); + rx51_camera_init(); /* Ensure SDRC pins are mux'd for self-refresh */ omap_mux_init_signal("sdrc_cke0", OMAP_PIN_OUTPUT); diff --git a/arch/arm/mach-omap2/board-rx51-camera.c b/arch/arm/mach-omap2/board-rx51-camera.c new file mode 100644 index 0000000..26b37ea --- /dev/null +++ b/arch/arm/mach-omap2/board-rx51-camera.c @@ -0,0 +1,177 @@ +/* + * arch/arm/mach-omap2/board-rx51-camera.c + * + * Copyright (C) 2008 Nokia Corporation + * + * Contact: Sakari Ailus + * Tuukka Toivonen + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * version 2 as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA + * 02110-1301 USA + * + */ + +#include +#include + +#include + +#include "../../../drivers/media/platform/omap3isp/isp.h" + +#include + +#include "devices.h" + +#define ADP1653_GPIO_ENABLE 88 /* Used for resetting ADP1653 */ +#define ADP1653_GPIO_INT 167 /* Fault interrupt */ +#define ADP1653_GPIO_STROBE 126 /* Pin used in cam_strobe mode -> + * control using ISP drivers */ + +static int __init rx51_adp1653_init(void) +{ + int err; + + err = gpio_request(ADP1653_GPIO_ENABLE, "adp1653 enable"); + if (err) { + printk(KERN_ERR ADP1653_NAME + " Failed to request EN gpio\n"); + err = -ENODEV; + goto err_omap_request_gpio; + } + + err = gpio_request(ADP1653_GPIO_INT, "adp1653 interrupt"); + if (err) { + printk(KERN_ERR ADP1653_NAME " Failed to request IRQ gpio\n"); + err = -ENODEV; + goto err_omap_request_gpio_2; + } + + err = gpio_request(ADP1653_GPIO_STROBE, "adp1653 strobe"); + if (err) { + printk(KERN_ERR ADP1653_NAME + " Failed to request STROBE gpio\n"); + err = -ENODEV; + goto err_omap_request_gpio_3; + } + + gpio_direction_output(ADP1653_GPIO_ENABLE, 0); + gpio_direction_input(ADP1653_GPIO_INT); + gpio_direction_output(ADP1653_GPIO_STROBE, 0); + + return 0; + +err_omap_request_gpio_3: + gpio_free(ADP1653_GPIO_INT); + +err_omap_request_gpio_2: + gpio_free(ADP1653_GPIO_ENABLE); + +err_omap_request_gpio: + return err; +} + +static int __init rx51_camera_hw_init(void) +{ + int rval; + + rval = rx51_adp1653_init(); + if (rval) + return rval; + + return 0; +} + +/* + * + * ADP1653 + * + */ + +static int rx51_adp1653_power(struct v4l2_subdev *subdev, int on) +{ + gpio_set_value(ADP1653_GPIO_ENABLE, on); + if (on) { + /* Some delay is apparently required. */ + udelay(20); + } + + return 0; +} + +static struct adp1653_platform_data rx51_adp1653_platform_data = { + .power = rx51_adp1653_power, + /* Must be limited to 500 ms in RX-51 */ + .max_flash_timeout = 500000, /* us */ + /* Must be limited to 320 mA in RX-51 B3 and newer hardware */ + .max_flash_intensity = ADP1653_FLASH_INTENSITY_REG_TO_mA(19), + /* Must be limited to 50 mA in RX-51 */ + .max_torch_intensity = ADP1653_FLASH_INTENSITY_REG_TO_mA(1), + .max_indicator_intensity = ADP1653_INDICATOR_INTENSITY_REG_TO_uA( + ADP1653_REG_OUT_SEL_ILED_MAX), +}; + +/* + * + * Init it all + * + */ + +#define ADP1653_I2C_BUS_NUM 2 + +static struct i2c_board_info rx51_camera_i2c_devices[] = { + { + I2C_BOARD_INFO(ADP1653_NAME, ADP1653_I2C_ADDR), + .platform_data = &rx51_adp1653_platform_data, + }, +}; + +static struct isp_subdev_i2c_board_info rx51_camera_primary_subdevs[] = { + { + .board_info = &rx51_camera_i2c_devices[0], + .i2c_adapter_id = ADP1653_I2C_BUS_NUM, + }, + { NULL, 0, }, +}; + +static struct isp_v4l2_subdevs_group rx51_camera_subdevs[] = { + { + .subdevs = rx51_camera_primary_subdevs, + .interface = ISP_INTERFACE_CCP2B_PHY1, + .bus = { .ccp2 = { + .strobe_clk_pol = 0, + .crc = 1, + .ccp2_mode = 1, + .phy_layer = 1, + .vpclk_div = 1, + } }, + }, + { NULL, 0, }, +}; + +static struct isp_platform_data rx51_isp_platform_data = { + .subdevs = rx51_camera_subdevs, +}; + +void __init rx51_camera_init(void) +{ + if (rx51_camera_hw_init()) { + printk(KERN_WARNING "%s: Unable to initialize camera\n", + __func__); + return; + } + + if (omap3_init_camera(&rx51_isp_platform_data) < 0) + printk(KERN_WARNING "%s: Unable to register camera platform " + "device\n", __func__); +} diff --git a/arch/arm/mach-omap2/Kconfig b/arch/arm/mach-omap2/Kconfig index be0f62b..268fa57 100644 --- a/arch/arm/mach-omap2/Kconfig +++ b/arch/arm/mach-omap2/Kconfig @@ -286,6 +287,7 @@ config MACH_NOKIA_RX51 depends on ARCH_OMAP3 default y select OMAP_PACKAGE_CBB + select VIDEO_ADP1653 if VIDEO_OMAP3 && VIDEO_HELPER_CHIPS_AUTO config MACH_OMAP_ZOOM2 bool "OMAP3 Zoom2 board" diff --git a/arch/arm/mach-omap2/Makefile b/arch/arm/mach-omap2/Makefile index c8b6ff3..df78c58 100644 --- a/arch/arm/mach-omap2/Makefile +++ b/arch/arm/mach-omap2/Makefile @@ -239,6 +239,7 @@ obj-$(CONFIG_MACH_NOKIA_RM680) += board-rm680.o sdram-nokia.o obj-$(CONFIG_MACH_NOKIA_RX51) += board-rx51.o sdram-nokia.o obj-$(CONFIG_MACH_NOKIA_RX51) += board-rx51-peripherals.o obj-$(CONFIG_MACH_NOKIA_RX51) += board-rx51-video.o +obj-$(CONFIG_MACH_NOKIA_RX51) += board-rx51-camera.o obj-$(CONFIG_MACH_OMAP_ZOOM2) += board-zoom.o board-zoom-peripherals.o obj-$(CONFIG_MACH_OMAP_ZOOM2) += board-zoom-display.o obj-$(CONFIG_MACH_OMAP_ZOOM2) += board-zoom-debugboard.o