Received: by 2002:a25:6193:0:0:0:0:0 with SMTP id v141csp530889ybb; Wed, 8 Apr 2020 05:01:05 -0700 (PDT) X-Google-Smtp-Source: APiQypIMKYPWGcdOJBHAU9ZgCppxgCq4T2srch2ozC3TRUy49xri1ULSCK6A/LrL/vGkrW+Eqtad X-Received: by 2002:aca:3089:: with SMTP id w131mr2182216oiw.121.1586347265710; Wed, 08 Apr 2020 05:01:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1586347265; cv=none; d=google.com; s=arc-20160816; b=asdF8Ymm9zzCqihvt2Qcz++35JgtQxIKPdv1lgt7gLEH6aEstdvk/ZQ56zA5496W+B Ot6UfMSkZ4SQIDX3sSVsDxsb/yfzWU3K/hV9JTo2ya1qQ8yrdnXFztDAkjSpFDoUBv2n Q5fNQYeg+qMjh/9A0ndoheLMYO4GL1I3APJi+BkioRo7PkUY6lMSAowgyGC/+Pfcmtx0 6M9hO9cDYX7K9qYVTEPEUk8+Ut52oX7GShPLe7EMpxt15CL3cVyiepNf9IswGrbHu2OE Ndz/hOWsr22e428c08vvfSXgwfG7tJsMmQKPpvXZBWnlKFxX1Xd7SJLb7pZX4zcoLJA4 UB1w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=jeVjBN/6H/gI6gMyuL/+Tdutryht/EUxewf1jqrLbh8=; b=PEFZ7r85jhQdgl5FXQ/3Rl+X+v22dbBp3gV53hLxXcAbuxPDimQ61LgyhHB+u99pUC SNkzZguyDHJJ7oOzFsaomHPIKbyUm6IPkpAtSkJlNDIvL0ZVJLAetikj5IjQlrocEAfU oCMeG4FK9QQ607OJinkcAORQtAGF4wUqSYfSNctr9RO9T9mAOzTX+7PqEhQgVvT+UL20 GBDLsZ3UaCAtfZnHOVToMvLvBXP+wsMNrJY/kq51F7841W+Jn8nHPItcRUBXwzcaZPAi iLuB0uTWfP4ts3L/faoq0y1UstG/YQkzukN3Il/6fN6tLe7MlwYzCKp63RGLPkdBnyzC 6EcQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=CoSrQxuO; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id t23si2446668otm.97.2020.04.08.05.00.50; Wed, 08 Apr 2020 05:01:05 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=CoSrQxuO; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728345AbgDHLIf (ORCPT + 99 others); Wed, 8 Apr 2020 07:08:35 -0400 Received: from mail-wr1-f65.google.com ([209.85.221.65]:36083 "EHLO mail-wr1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728228AbgDHLIa (ORCPT ); Wed, 8 Apr 2020 07:08:30 -0400 Received: by mail-wr1-f65.google.com with SMTP id k1so7373544wrm.3 for ; Wed, 08 Apr 2020 04:08:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=jeVjBN/6H/gI6gMyuL/+Tdutryht/EUxewf1jqrLbh8=; b=CoSrQxuOgUErP6j4vE5Hnof3IlCEsZecLbmey7kO4uUjcv82/taslS3HKv0A+42o5L OfbEuUrdi0sjmzf9L9MH44bGbnbnhN2vWSuWO9+xJYWDm2mS2PpB9tDa4GSJWUxr1xxA Q8B6NmnYq8CJAjZTwoUszgiOYZ0nNUxeRS6/TuV7+U9ZbMFMgvjwdd3i489E21poNS/e qfg63B8lm51EjOhKSrh+40rsC7XGQrzqGvAHzE7ZZZ3sS6llZOha4jGpQBPQ8Y0ZquY+ YNXfDO3eRm56/YZHWf9E94HQkGmp4nJza9reFnnWVLLTGS50ED2VdfYH+rExUOCIdMJM /UGQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=jeVjBN/6H/gI6gMyuL/+Tdutryht/EUxewf1jqrLbh8=; b=phom7yAy1mnqOLbOXq3INhwlC5huh/H5x0xkGADkMIdg0PUhV82F7rbS9UT6V+EPWk rLlPUPrr44Ssf4hwSlI30AZaHLVRAW0247/bOm6IcxsOS4xU698VyxZRu6ysBdvgaOEr A8ueBf5Zu9CtibzV9qGoh7am/Tn6Z0FEDpIIBZO0HWT0XEg7Kv0i74BepRori97qMoFt oYQYX0Ou/pvNz0a5HO+/10ENDjLsvCwFKTxjn9A0yvKZYJ2VBhzDIKDhuTov6cgoYbv8 PP/VcY4ekhaujfGP0IRT+cKaFIuQhQNarV8O9xqO2rQj3FB+SfWxtr7IpIl1wP/ECWum vhmQ== X-Gm-Message-State: AGi0PuaEjMkFR8nRvp1lJae8j/gAEvzfZAlIcuH2AzdTBe9RkzvUy8Ks HWt8qKVH+hDXwaqqvBRm9Q1g7g== X-Received: by 2002:a5d:4306:: with SMTP id h6mr7558068wrq.234.1586344107109; Wed, 08 Apr 2020 04:08:27 -0700 (PDT) Received: from localhost.localdomain ([37.120.50.78]) by smtp.gmail.com with ESMTPSA id i8sm37596253wrb.41.2020.04.08.04.08.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 08 Apr 2020 04:08:26 -0700 (PDT) From: Robert Foss To: Dongchun Zhu , Fabio Estevam , Andy Shevchenko , Sakari Ailus , Marco Felsch , Tomasz Figa , Maxime Ripard , linux-media@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org Cc: Robert Foss Subject: [PATCH v4 3/3] media: ov8856: Implement sensor module revision identification Date: Wed, 8 Apr 2020 13:08:16 +0200 Message-Id: <20200408110816.2712841-4-robert.foss@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200408110816.2712841-1-robert.foss@linaro.org> References: <20200408110816.2712841-1-robert.foss@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Query the sensor for its module revision, and compare it to known revisions. Currently only the '1B' revision has been added. Signed-off-by: Robert Foss --- - Changes since v3: * Actually add module revision 2A - Changes since v2: * Add module revision 2A * Sakari: Remove ov8856_check_revision() * Sakari: Stop EEPROM streaming mode drivers/media/i2c/ov8856.c | 53 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 53 insertions(+) diff --git a/drivers/media/i2c/ov8856.c b/drivers/media/i2c/ov8856.c index 473d3245344a..de0b484b85d0 100644 --- a/drivers/media/i2c/ov8856.c +++ b/drivers/media/i2c/ov8856.c @@ -32,6 +32,19 @@ #define OV8856_MODE_STANDBY 0x00 #define OV8856_MODE_STREAMING 0x01 +/* module revisions */ +#define OV8856_2A_MODULE 0x01 +#define OV8856_1B_MODULE 0x02 + +/* the OTP read-out buffer is at 0x7000 and 0xf is the offset + * of the byte in the OTP that means the module revision + */ +#define OV8856_MODULE_REVISION 0x700f +#define OV8856_OTP_MODE_CTRL 0x3d84 +#define OV8856_OTP_LOAD_CTRL 0x3d81 +#define OV8856_OTP_MODE_AUTO 0x00 +#define OV8856_OTP_LOAD_CTRL_ENABLE BIT(0) + /* vertical-timings from sensor */ #define OV8856_REG_VTS 0x380e #define OV8856_VTS_MAX 0x7fff @@ -1152,6 +1165,46 @@ static int ov8856_identify_module(struct ov8856 *ov8856) return -ENXIO; } + ret = ov8856_write_reg(ov8856, OV8856_REG_MODE_SELECT, + OV8856_REG_VALUE_08BIT, OV8856_MODE_STREAMING); + if (ret) + return ret; + + ret = ov8856_write_reg(ov8856, OV8856_OTP_MODE_CTRL, + OV8856_REG_VALUE_08BIT, OV8856_OTP_MODE_AUTO); + if (ret) { + dev_err(&client->dev, "failed to set otp mode"); + return ret; + } + + ret = ov8856_write_reg(ov8856, OV8856_OTP_LOAD_CTRL, + OV8856_REG_VALUE_08BIT, + OV8856_OTP_LOAD_CTRL_ENABLE); + if (ret) { + dev_err(&client->dev, "failed to enable load control"); + return ret; + } + + ret = ov8856_read_reg(ov8856, OV8856_MODULE_REVISION, + OV8856_REG_VALUE_08BIT, &val); + if (ret) { + dev_err(&client->dev, "failed to read module revision"); + return ret; + } + + dev_info(&client->dev, "OV8856 revision %x (%s) at address 0x%02x\n", + val, + val == OV8856_2A_MODULE ? "2A" : + val == OV8856_1B_MODULE ? "1B" : "unknown revision", + client->addr); + + ret = ov8856_write_reg(ov8856, OV8856_REG_MODE_SELECT, + OV8856_REG_VALUE_08BIT, OV8856_MODE_STANDBY); + if (ret) { + dev_err(&client->dev, "failed to exit streaming mode"); + return ret; + } + return 0; } -- 2.25.1