From patchwork Sun May 6 07:31:18 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pavel Machek X-Patchwork-Id: 10382619 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 38FC860353 for ; Sun, 6 May 2018 07:31:52 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 1E99528BB0 for ; Sun, 6 May 2018 07:31:52 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 10E3528DBF; Sun, 6 May 2018 07:31:52 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 5B5F228BB0 for ; Sun, 6 May 2018 07:31:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender:Content-Type: List-Subscribe:List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id: In-Reply-To:MIME-Version:References:Message-ID:Subject:To:From:Date:Reply-To: Cc:Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=R2/JmAo3nEbPi2vTTCV9BU48I0bwcWa+zZsGBIOpyX8=; b=fqnnPI519iGvt0qhUMAhZ+INo sFYlC9yD286MIKtdriRuUX+1RFJ5kiWz+qUFb4hbvlH58QuUK/g1Gtp6G9RtCiU/MrefDs//bzck6 XVwfDVpqNGi49LolIwUALIP5w4boC+5M0OQWDhMHe7r6VN+qQAnkdO3L4IyrNfLfGONtkitd9aE+w 4oszagysHV85Le4PIU01caaVuPJi+BENHxcMXOCanlrmh4w+BNFhaWEQje99X1adkpNKicfK/YvrO 1J++2Ffmpo5Aj5bfOufZJ0Cr6MZfebMduMKCy/hLNXt/RvVyxuTFzchj9Yhi0tVMDDsMJR4iIVpOn +cYzJuNCQ==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1fFE8w-00020x-PC; Sun, 06 May 2018 07:31:38 +0000 Received: from atrey.karlin.mff.cuni.cz ([195.113.26.193]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1fFE8s-0001zN-GZ for linux-arm-kernel@lists.infradead.org; Sun, 06 May 2018 07:31:37 +0000 Received: by atrey.karlin.mff.cuni.cz (Postfix, from userid 512) id 670198046D; Sun, 6 May 2018 09:31:19 +0200 (CEST) Date: Sun, 6 May 2018 09:31:18 +0200 From: Pavel Machek To: kernel list , linux-arm-kernel , linux-omap@vger.kernel.org, tony@atomide.com, sre@kernel.org, nekit1000@gmail.com, mpartap@gmx.net, merlijn@wizzup.org Subject: Re: Handling lm3559 flash on Motorola Droid 4 and others Message-ID: <20180506073118.GA6811@amd> References: <20180505213951.GA4530@amd> MIME-Version: 1.0 In-Reply-To: <20180505213951.GA4530@amd> User-Agent: Mutt/1.5.23 (2014-03-12) X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20180506_003134_860827_D6DA4830 X-CRM114-Status: GOOD ( 15.51 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP Hi! > It seems lm3559 flash driver is available on github ( > https://github.com/ZenfoneArea/android_kernel_asus_zenfone5/tree/master/linux/modules/camera/drivers/media/i2c > ) but there'll be some fun getting it cleaned up and merged. > > Did anyone start doing anything in that area? Is there possibly better > source to start from? It turned out to be easier than expected. Of course, using flash w/o v4l will not be easy, but that's generic problem. Pavel diff --git a/arch/arm/boot/dts/omap4-droid4-xt894.dts b/arch/arm/boot/dts/omap4-droid4-xt894.dts index bdf73cb..45305e8 100644 --- a/arch/arm/boot/dts/omap4-droid4-xt894.dts +++ b/arch/arm/boot/dts/omap4-droid4-xt894.dts @@ -271,6 +271,34 @@ }; }; +&i2c3 { + rearcam: camera@36 { + compatible = "micron,ov8820"; + reg = <0x36>; + clocks = <&auxclk1_ck>; + clock-names = "xvclk"; + clock-frequency = <24000000>; + power-gpios = <&gpio2 16 GPIO_ACTIVE_HIGH>, // gpio48 + <&gpio3 19 GPIO_ACTIVE_HIGH>, // gpio83 + <&gpio5 23 GPIO_ACTIVE_HIGH>; // gpio151 + }; + frontcam: camera@48 { + compatible = "ovti,mt9m114"; + reg = <0x48>; + clocks = <&auxclk2_ck>; + clock-names = "extclk"; + clock-frequency = <24000000>; + power-gpios = <&gpio6 11 GPIO_ACTIVE_HIGH>, // gpio171 + <&gpio2 5 GPIO_ACTIVE_HIGH>; // gpio37 + }; + flashlight: flash@53 { + compatible = "ti,lm3559"; + reg = <0x53>; + }; +}; + + + &keypad { keypad,num-rows = <8>; keypad,num-columns = <8>; diff --git a/drivers/media/i2c/lm3560.c b/drivers/media/i2c/lm3560.c index b600e03a..a9b2ba2 100644 --- a/drivers/media/i2c/lm3560.c +++ b/drivers/media/i2c/lm3560.c @@ -17,6 +17,8 @@ * General Public License for more details. */ +// Probably compatible with lm3559, too. + #include #include #include @@ -395,6 +397,22 @@ static int lm3560_init_device(struct lm3560_flash *flash) return rval; /* reset faults */ rval = regmap_read(flash->regmap, REG_FLAG, ®_val); + + printk("lm3560: Device initialized\n"); + + flash->led_mode = V4L2_FLASH_LED_MODE_TORCH; + rval = lm3560_mode_ctrl(flash); + rval = lm3560_torch_brt_ctrl(flash, 0, LM3560_TORCH_BRT_MIN); + rval = lm3560_torch_brt_ctrl(flash, 1, LM3560_TORCH_BRT_MIN); + + mdelay(1000); + + rval = lm3560_torch_brt_ctrl(flash, 0, 0); + rval = lm3560_torch_brt_ctrl(flash, 1, 0); + + flash->led_mode = V4L2_FLASH_LED_MODE_NONE; + rval = lm3560_mode_ctrl(flash); + return rval; } @@ -405,6 +423,8 @@ static int lm3560_probe(struct i2c_client *client, struct lm3560_platform_data *pdata = dev_get_platdata(&client->dev); int rval; + printk("3560: probe\n"); + flash = devm_kzalloc(&client->dev, sizeof(*flash), GFP_KERNEL); if (flash == NULL) return -ENOMEM; @@ -417,17 +437,19 @@ static int lm3560_probe(struct i2c_client *client, /* if there is no platform data, use chip default value */ if (pdata == NULL) { + printk("3560: no pdata\n"); + pdata = devm_kzalloc(&client->dev, sizeof(*pdata), GFP_KERNEL); if (pdata == NULL) return -ENODEV; - pdata->peak = LM3560_PEAK_3600mA; - pdata->max_flash_timeout = LM3560_FLASH_TOUT_MAX; + pdata->peak = LM3560_PEAK_1600mA; + pdata->max_flash_timeout = LM3560_FLASH_TOUT_MIN; /* led 1 */ - pdata->max_flash_brt[LM3560_LED0] = LM3560_FLASH_BRT_MAX; - pdata->max_torch_brt[LM3560_LED0] = LM3560_TORCH_BRT_MAX; + pdata->max_flash_brt[LM3560_LED0] = LM3560_FLASH_BRT_MIN; + pdata->max_torch_brt[LM3560_LED0] = LM3560_TORCH_BRT_MIN; /* led 2 */ - pdata->max_flash_brt[LM3560_LED1] = LM3560_FLASH_BRT_MAX; - pdata->max_torch_brt[LM3560_LED1] = LM3560_TORCH_BRT_MAX; + pdata->max_flash_brt[LM3560_LED1] = LM3560_FLASH_BRT_MIN; + pdata->max_torch_brt[LM3560_LED1] = LM3560_TORCH_BRT_MIN; } flash->pdata = pdata; flash->dev = &client->dev; @@ -466,6 +488,8 @@ static int lm3560_remove(struct i2c_client *client) static const struct i2c_device_id lm3560_id_table[] = { {LM3560_NAME, 0}, + {"lm3559", 0}, + {"ti,lm3559", 0}, {} };