From patchwork Sun Mar 28 07:47:21 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Zhang, Xiaolin" X-Patchwork-Id: 3028 Return-path: Envelope-to: mchehab@infradead.org Delivery-date: Sun, 28 Mar 2010 07:47:32 +0000 Received: from bombadil.infradead.org [18.85.46.34] by pedra with IMAP (fetchmail-6.3.6) for (single-drop); Sun, 28 Mar 2010 09:00:48 -0300 (BRT) Received: from vger.kernel.org ([209.132.180.67]) by bombadil.infradead.org with esmtp (Exim 4.69 #1 (Red Hat Linux)) id 1NvnDY-000533-4D; Sun, 28 Mar 2010 07:47:32 +0000 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753853Ab0C1Hrb (ORCPT + 1 other); Sun, 28 Mar 2010 03:47:31 -0400 Received: from mga11.intel.com ([192.55.52.93]:18152 "EHLO mga11.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753775Ab0C1Hra convert rfc822-to-8bit (ORCPT ); Sun, 28 Mar 2010 03:47:30 -0400 Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by fmsmga102.fm.intel.com with ESMTP; 28 Mar 2010 00:43:42 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="4.51,321,1267430400"; d="scan'208,223";a="552829306" Received: from pgsmsx602.gar.corp.intel.com ([10.221.43.81]) by fmsmga002.fm.intel.com with ESMTP; 28 Mar 2010 00:46:07 -0700 Received: from shzsmsx501.ccr.corp.intel.com (10.239.4.96) by pgsmsx602.gar.corp.intel.com (10.221.43.81) with Microsoft SMTP Server (TLS) id 8.2.176.0; Sun, 28 Mar 2010 15:47:28 +0800 Received: from shsmsx501.ccr.corp.intel.com ([10.239.4.141]) by shzsmsx501.ccr.corp.intel.com ([10.239.4.96]) with mapi; Sun, 28 Mar 2010 15:47:27 +0800 From: "Zhang, Xiaolin" To: "linux-media@vger.kernel.org" CC: "Zhu, Daniel" , "Yu, Jinlu" , "Wang, Wen W" , "Huang, Kai" , "Hu, Gang A" , "Ba, Zheng" , "Zhang, Xiaolin" Date: Sun, 28 Mar 2010 15:47:21 +0800 Subject: [PATCH v2 3/10] V4L2 patches for Intel Moorestown Camera Imaging Drivers Thread-Topic: [PATCH v2 3/10] V4L2 patches for Intel Moorestown Camera Imaging Drivers Thread-Index: AcrOSuXt4mF6y3FlQtW5xUPVarEloQ== Message-ID: <33AB447FBD802F4E932063B962385B351D6D534D@shsmsx501.ccr.corp.intel.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-cr-puzzleid: {6DB1B8D9-FF25-43C0-BBE0-E217472625D2} x-cr-hashedpuzzle: B8hP B/GG DTeb DXOB Dap9 EV7S FL8a G+80 HOxU HreD IAk1 Ia9J IxDe I9nK JUY0 KCmy; 1; bABpAG4AdQB4AC0AbQBlAGQAaQBhAEAAdgBnAGUAcgAuAGsAZQByAG4AZQBsAC4AbwByAGcA; Sosha1_v1; 7; {6DB1B8D9-FF25-43C0-BBE0-E217472625D2}; eABpAGEAbwBsAGkAbgAuAHoAaABhAG4AZwBAAGkAbgB0AGUAbAAuAGMAbwBtAA==; Sun, 28 Mar 2010 07:47:21 GMT; WwBQAEEAVABDAEgAIAB2ADIAIAAzAC8AMQAwAF0AIABWADQATAAyACAAcABhAHQAYwBoAGUAcwAgAGYAbwByACAASQBuAHQAZQBsACAATQBvAG8AcgBlAHMAdABvAHcAbgAgAEMAYQBtAGUAcgBhACAASQBtAGEAZwBpAG4AZwAgAEQAcgBpAHYAZQByAHMA acceptlanguage: en-US MIME-Version: 1.0 Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org From 1fd72af8366c3cfb04520bbee7252a1991c878ba Mon Sep 17 00:00:00 2001 From: Xiaolin Zhang Date: Sun, 28 Mar 2010 13:57:52 +0800 Subject: [PATCH 03/10] This patch is the flash subdev driver for intel moorestown camera imaging. Signed-off-by: Xiaolin Zhang --- drivers/media/video/mrstci/mrstflash/Kconfig | 9 ++ drivers/media/video/mrstci/mrstflash/Makefile | 3 + drivers/media/video/mrstci/mrstflash/mrstflash.c | 150 ++++++++++++++++++++++ 3 files changed, 162 insertions(+), 0 deletions(-) create mode 100644 drivers/media/video/mrstci/mrstflash/Kconfig create mode 100644 drivers/media/video/mrstci/mrstflash/Makefile create mode 100644 drivers/media/video/mrstci/mrstflash/mrstflash.c diff --git a/drivers/media/video/mrstci/mrstflash/Kconfig b/drivers/media/video/mrstci/mrstflash/Kconfig new file mode 100644 index 0000000..72099c5 --- /dev/null +++ b/drivers/media/video/mrstci/mrstflash/Kconfig @@ -0,0 +1,9 @@ +config VIDEO_MRST_FLASH + tristate "Moorestown flash" + depends on I2C && VIDEO_MRST_ISP + + ---help--- + Say Y here if your platform support moorestown flash. + + To compile this driver as a module, choose M here: the + module will be called mrstov2650.ko. diff --git a/drivers/media/video/mrstci/mrstflash/Makefile b/drivers/media/video/mrstci/mrstflash/Makefile new file mode 100644 index 0000000..068f638 --- /dev/null +++ b/drivers/media/video/mrstci/mrstflash/Makefile @@ -0,0 +1,3 @@ +obj-$(CONFIG_VIDEO_MRST_FLASH) += mrstflash.o + +EXTRA_CFLAGS += -I$(src)/../include diff --git a/drivers/media/video/mrstci/mrstflash/mrstflash.c b/drivers/media/video/mrstci/mrstflash/mrstflash.c new file mode 100644 index 0000000..89ceddc --- /dev/null +++ b/drivers/media/video/mrstci/mrstflash/mrstflash.c @@ -0,0 +1,150 @@ +/* + * Support for Moorestown Langwell Camera Imaging camera flash. + * + * Copyright (c) 2009 Intel Corporation. All Rights Reserved. + * + * 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 Street, Fifth Floor, Boston, MA + * 02110-1301, USA. + * + * + * Xiaolin Zhang + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +static int debug; +module_param(debug, bool, 0644); +MODULE_PARM_DESC(debug, "Debug level (0-1)"); + +MODULE_AUTHOR("Xiaolin Zhang "); +MODULE_DESCRIPTION("A low-level driver for mrst flash"); +MODULE_LICENSE("GPL"); + +static int flash_g_chip_ident(struct v4l2_subdev *sd, + struct v4l2_dbg_chip_ident *chip) +{ + struct i2c_client *client = v4l2_get_subdevdata(sd); + + #define V4L2_IDENT_MRST_FLASH 8248 + return v4l2_chip_ident_i2c_client(client, chip, + V4L2_IDENT_MRST_FLASH, 0); +} + +static const struct v4l2_subdev_core_ops flash_core_ops = { + .g_chip_ident = flash_g_chip_ident, +}; +static const struct v4l2_subdev_ops flash_ops = { + .core = &flash_core_ops, +}; + +static int flash_detect(struct i2c_client *client) +{ + struct i2c_adapter *adapter = client->adapter; + u8 pid; + + if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_BYTE_DATA)) + return -ENODEV; + + if (adapter->nr != 0) + return -ENODEV; + + pid = i2c_smbus_read_byte_data(client, 0x10); + if (pid == 0x18) { + printk(KERN_ERR "camera flash device found\n"); + v4l_dbg(1, debug, client, "found camera flash device"); + } else { + printk(KERN_ERR "no camera flash device found\n"); + return -ENODEV; + } + + return 0; +} + +static int flash_probe(struct i2c_client *client, + const struct i2c_device_id *id) +{ + u8 pid, ver; + int ret = -1; + struct v4l2_subdev *sd; + + v4l_info(client, "chip found @ 0x%x (%s)\n", + client->addr << 1, client->adapter->name); + + sd = kzalloc(sizeof(struct v4l2_subdev), GFP_KERNEL); + ret = flash_detect(client); + if (ret) + return -ENODEV; + + v4l2_i2c_subdev_init(sd, client, &flash_ops); + + ver = i2c_smbus_read_byte_data(client, 0x50); + v4l_dbg(1, debug, client, "detect:CST from device is 0x%x", ver); + pid = i2c_smbus_read_byte_data(client, 0x20); + v4l_dbg(1, debug, client, "detect:MFPC from device is 0x%x", pid); + pid = i2c_smbus_read_byte_data(client, 0xA0); + v4l_dbg(1, debug, client, "detect:TCC from device is 0x%x", pid); + pid = i2c_smbus_read_byte_data(client, 0xB0); + v4l_dbg(1, debug, client, "detect:FCC from device is 0x%x", pid); + pid = i2c_smbus_read_byte_data(client, 0xC0); + v4l_dbg(1, debug, client, "detect:FDC from device is 0x%x", pid); + i2c_smbus_write_byte_data(client, 0xc0, 0xff); /*set FST to 1000us*/ + pid = i2c_smbus_read_byte_data(client, 0xc0); + v4l_dbg(1, debug, client, "FDC from device is 0x%x", pid); + + v4l_dbg(1, debug, client, + "successfully load camera flash device driver"); + return 0; +} + +static int flash_remove(struct i2c_client *client) +{ + struct v4l2_subdev *sd = i2c_get_clientdata(client); + + v4l2_device_unregister_subdev(sd); + + return 0; +} + +static const struct i2c_device_id flash_id[] = { + {"mrst_camera_flash", 0}, + {} +}; + +MODULE_DEVICE_TABLE(i2c, flash_id); + +static struct v4l2_i2c_driver_data v4l2_i2c_data = { + .name = "mrst_camera_flash", + .probe = flash_probe, + .remove = flash_remove, + .id_table = flash_id, +};