From patchwork Tue Dec 31 09:26:35 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Loic Poulain X-Patchwork-Id: 182662 Delivered-To: patch@linaro.org Received: by 2002:a92:815a:0:0:0:0:0 with SMTP id e87csp7359317ild; Tue, 31 Dec 2019 01:23:29 -0800 (PST) X-Google-Smtp-Source: APXvYqyV8M+NQQyrJdUImAthm/RXL55JhJ7gM9xKS2XRCC+DQ4zOYYQdQeLO1AhHsLT6rOxo8OKA X-Received: by 2002:a05:6830:138b:: with SMTP id d11mr66408910otq.38.1577784209065; Tue, 31 Dec 2019 01:23:29 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1577784209; cv=none; d=google.com; s=arc-20160816; b=poYQSLxopzkA7FX/SyAjZKMlCwOIYtIyulWAHAwv8rASkHRz+qy7nU4VfsKXXbJxrX g5QQ4GpvfGdzpBAKWVF8Ut46Oq1nL60C58TJzxuOPWRq9NrWKT9ZsWyDRC228eFEDIG+ fDKUky8rSdGYvzBv9ADB/NsRo+kL/44J5d7BXZrx2g7ELKWCCPB5R6t72/3H6Zm9AhZu Az+pFEbPg0Up60LTeHplWLnupQT+V2HIqrpNW1ozWKQLCxRVhnDJX+zOohSVFTukukad yaB4Ndg7Ux+J8prjemp0CaZUvirw4Y9/6+0A8ey6PVmXpJgVtFs4fegGW2T2AUFZrh1D 8F0g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from :dkim-signature; bh=g6NGM5C0ZiCC/BcpFlKfBj6kFXqB9AEX0kNYfbP8J8Y=; b=gCbVf6e8MZTYFit4Ikn7E/G8rgmlwUM8oVO86IA78bkL239aNGTx3CHIShdy86Gd8W njh+Ez4aoU7w5bCOkUL80t4bw/Pyz2Lbz5OKWWdRA5JDR3BSTt1TOIImn5czn5hYaI6V 2TjNCO1lv8UBS354ycdVUagyf4qbsY7GkbgrYiOnTtN4xni9gUxS/5tzP3F53chLsP+u hKsk+6e7G29cKQRDB7Ex1UPB00wmBeKvZzTxScOdo4KL0MULyrCXLetEih5mAA0cYrLn Giv92vVd8Qp62cwN3yKaNlRsEI19v0NDZQ+3SkntuDmkkVWvmN7ZbRrEAYaUtGv5QQpB RQLw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="p/rPzbRd"; spf=pass (google.com: best guess record for domain of linux-i2c-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-i2c-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 a10si8517719oid.84.2019.12.31.01.23.28; Tue, 31 Dec 2019 01:23:29 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-i2c-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="p/rPzbRd"; spf=pass (google.com: best guess record for domain of linux-i2c-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-i2c-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 S1726407AbfLaJX2 (ORCPT + 2 others); Tue, 31 Dec 2019 04:23:28 -0500 Received: from mail-wm1-f68.google.com ([209.85.128.68]:38403 "EHLO mail-wm1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726119AbfLaJX2 (ORCPT ); Tue, 31 Dec 2019 04:23:28 -0500 Received: by mail-wm1-f68.google.com with SMTP id u2so1435436wmc.3 for ; Tue, 31 Dec 2019 01:23:26 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id; bh=g6NGM5C0ZiCC/BcpFlKfBj6kFXqB9AEX0kNYfbP8J8Y=; b=p/rPzbRdFUr9aejRR0nwXviiPHcSb2IcaauDm0sH04VbkyeKVhySyLIalJ1qt6lSdY 39i0a9pltZes4EEkkWqQOmsofev1DwygTeLKrF3DBZfBcuEjbPD/q4O2CYgWs41ktcyb r1ZNWzSd1/VWLyw3RdOFaBGf+r/z+usWxdI82/ly0dmaXMIXj8ToLanb6zNpbeeaVEfU go3V9kH5BUOVOeT1HyDFisBBZBfFEFPdmC09u46SB1l0gfmheAtwpIDWIMxFCu6zISRc JIvXJF/uqQ4+4TtGBz1dze7P30aGKDw102W5BeWreqFpVzX1JxngqEoZ8rrvYvXWV2q4 nfKg== 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; bh=g6NGM5C0ZiCC/BcpFlKfBj6kFXqB9AEX0kNYfbP8J8Y=; b=m94p0ErvCLiIC2mCmKajZUNBchwO07k9zX90THW1NwPhP9n3ADwdr1157o2rYs5BsD 7jbv8TzXVr+WcxHW1eP7/hTgj1jug7CAyFzr2AlWG//rdfD5CxJOemlAQ/HJhiwYNZv0 vn17yQwobpT+vUpnXr7WJ7rzsq3pc0bo8vPUU6QqyulBnv/gCY4RmHAmf02gcG6J7u0j /r6jm1vsyVex60JptW4+cN0XxNosY62xH8tcKkYkVVhr9npdi4Vg5MS6/MwM2CCiTYZD x7j/dD2yCh7iUnzj+TKf+2z8/tjs+8OUQiqWprqPsUH82UG7YRbNt7vP6QfeuGspMWQF HM6A== X-Gm-Message-State: APjAAAVYENFU0dnS5tGxMha1aQJLT2SB+I5G7gmEQ/+jen0oWzBPlcKm Lm5L5lI4T3X35mqPqPip2D+R++mzeJQ= X-Received: by 2002:a7b:c7d4:: with SMTP id z20mr3564383wmk.42.1577784204921; Tue, 31 Dec 2019 01:23:24 -0800 (PST) Received: from lpoulain-ThinkPad-T470p.home (amontpellier-651-1-422-191.w92-133.abo.wanadoo.fr. [92.133.205.191]) by smtp.gmail.com with ESMTPSA id f1sm48153410wro.85.2019.12.31.01.23.23 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 31 Dec 2019 01:23:24 -0800 (PST) From: Loic Poulain To: wsa@the-dreams.de, robh+dt@kernel.org Cc: vkoul@kernel.org, todor.too@gmail.com, linux-i2c@vger.kernel.org, bjorn.andersson@linaro.org, Loic Poulain , Todor Tomov Subject: [PATCH v2 1/3] i2c: Add Qualcomm CCI I2C driver Date: Tue, 31 Dec 2019 10:26:35 +0100 Message-Id: <1577784397-28682-1-git-send-email-loic.poulain@linaro.org> X-Mailer: git-send-email 2.7.4 Sender: linux-i2c-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-i2c@vger.kernel.org This commit adds I2C bus support for the Camera Control Interface (CCI) I2C controller found on the Qualcomm SoC processors. This I2C controller supports two masters and they are registered to the core. CCI versions supported in the driver are MSM8916 and MSM8996. This is a rework of the patch posted by Vinod: https://patchwork.kernel.org/patch/10569961/ With additional fixes + most of the comments addressed. Signed-off-by: Todor Tomov Signed-off-by: Vinod Koul Signed-off-by: Loic Poulain --- v2: Remove clock rates config from driver (done via assigned clock) Added CCI timeout recovery from Ricardo's patch: https://www.spinics.net/lists/linux-i2c/msg36973.html drivers/i2c/busses/Kconfig | 10 + drivers/i2c/busses/Makefile | 1 + drivers/i2c/busses/i2c-qcom-cci.c | 781 ++++++++++++++++++++++++++++++++++++++ 3 files changed, 792 insertions(+) create mode 100644 drivers/i2c/busses/i2c-qcom-cci.c -- 2.7.4 diff --git a/drivers/i2c/busses/Kconfig b/drivers/i2c/busses/Kconfig index 6a0aa76..807a052 100644 --- a/drivers/i2c/busses/Kconfig +++ b/drivers/i2c/busses/Kconfig @@ -894,6 +894,16 @@ config I2C_QCOM_GENI This driver can also be built as a module. If so, the module will be called i2c-qcom-geni. +config I2C_QCOM_CCI + tristate "Qualcomm Camera Control Interface" + depends on ARCH_QCOM || COMPILE_TEST + help + If you say yes to this option, support will be included for the + built-in camera control interface on the Qualcomm SoCs. + + This driver can also be built as a module. If so, the module + will be called i2c-qcom-cci. + config I2C_QUP tristate "Qualcomm QUP based I2C controller" depends on ARCH_QCOM diff --git a/drivers/i2c/busses/Makefile b/drivers/i2c/busses/Makefile index 3ab8aeb..9028b77 100644 --- a/drivers/i2c/busses/Makefile +++ b/drivers/i2c/busses/Makefile @@ -92,6 +92,7 @@ obj-$(CONFIG_I2C_PUV3) += i2c-puv3.o obj-$(CONFIG_I2C_PXA) += i2c-pxa.o obj-$(CONFIG_I2C_PXA_PCI) += i2c-pxa-pci.o obj-$(CONFIG_I2C_QCOM_GENI) += i2c-qcom-geni.o +obj-$(CONFIG_I2C_QCOM_CCI) += i2c-qcom-cci.o obj-$(CONFIG_I2C_QUP) += i2c-qup.o obj-$(CONFIG_I2C_RIIC) += i2c-riic.o obj-$(CONFIG_I2C_RK3X) += i2c-rk3x.o diff --git a/drivers/i2c/busses/i2c-qcom-cci.c b/drivers/i2c/busses/i2c-qcom-cci.c new file mode 100644 index 0000000..2407b01 --- /dev/null +++ b/drivers/i2c/busses/i2c-qcom-cci.c @@ -0,0 +1,781 @@ +// SPDX-License-Identifier: GPL-2.0 +// Copyright (c) 2012-2016, The Linux Foundation. All rights reserved. +// Copyright (c) 2017-19 Linaro Limited. + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#define CCI_HW_VERSION 0x0 +#define CCI_RESET_CMD 0x004 +#define CCI_RESET_CMD_MASK 0x0f73f3f7 +#define CCI_RESET_CMD_M0_MASK 0x000003f1 +#define CCI_RESET_CMD_M1_MASK 0x0003f001 +#define CCI_QUEUE_START 0x008 +#define CCI_HALT_REQ 0x034 +#define CCI_HALT_REQ_I2C_M0_Q0Q1 BIT(0) +#define CCI_HALT_REQ_I2C_M1_Q0Q1 BIT(1) + +#define CCI_I2C_Mm_SCL_CTL(m) (0x100 + 0x100 * (m)) +#define CCI_I2C_Mm_SDA_CTL_0(m) (0x104 + 0x100 * (m)) +#define CCI_I2C_Mm_SDA_CTL_1(m) (0x108 + 0x100 * (m)) +#define CCI_I2C_Mm_SDA_CTL_2(m) (0x10c + 0x100 * (m)) +#define CCI_I2C_Mm_MISC_CTL(m) (0x110 + 0x100 * (m)) + +#define CCI_I2C_Mm_READ_DATA(m) (0x118 + 0x100 * (m)) +#define CCI_I2C_Mm_READ_BUF_LEVEL(m) (0x11c + 0x100 * (m)) +#define CCI_I2C_Mm_Qn_EXEC_WORD_CNT(m, n) (0x300 + 0x200 * (m) + 0x100 * (n)) +#define CCI_I2C_Mm_Qn_CUR_WORD_CNT(m, n) (0x304 + 0x200 * (m) + 0x100 * (n)) +#define CCI_I2C_Mm_Qn_CUR_CMD(m, n) (0x308 + 0x200 * (m) + 0x100 * (n)) +#define CCI_I2C_Mm_Qn_REPORT_STATUS(m, n) (0x30c + 0x200 * (m) + 0x100 * (n)) +#define CCI_I2C_Mm_Qn_LOAD_DATA(m, n) (0x310 + 0x200 * (m) + 0x100 * (n)) + +#define CCI_IRQ_GLOBAL_CLEAR_CMD 0xc00 +#define CCI_IRQ_MASK_0 0xc04 +#define CCI_IRQ_MASK_0_I2C_M0_RD_DONE BIT(0) +#define CCI_IRQ_MASK_0_I2C_M0_Q0_REPORT BIT(4) +#define CCI_IRQ_MASK_0_I2C_M0_Q1_REPORT BIT(8) +#define CCI_IRQ_MASK_0_I2C_M1_RD_DONE BIT(12) +#define CCI_IRQ_MASK_0_I2C_M1_Q0_REPORT BIT(16) +#define CCI_IRQ_MASK_0_I2C_M1_Q1_REPORT BIT(20) +#define CCI_IRQ_MASK_0_RST_DONE_ACK BIT(24) +#define CCI_IRQ_MASK_0_I2C_M0_Q0Q1_HALT_ACK BIT(25) +#define CCI_IRQ_MASK_0_I2C_M1_Q0Q1_HALT_ACK BIT(26) +#define CCI_IRQ_MASK_0_I2C_M0_ERROR 0x18000ee6 +#define CCI_IRQ_MASK_0_I2C_M1_ERROR 0x60ee6000 +#define CCI_IRQ_CLEAR_0 0xc08 +#define CCI_IRQ_STATUS_0 0xc0c +#define CCI_IRQ_STATUS_0_I2C_M0_RD_DONE BIT(0) +#define CCI_IRQ_STATUS_0_I2C_M0_Q0_REPORT BIT(4) +#define CCI_IRQ_STATUS_0_I2C_M0_Q1_REPORT BIT(8) +#define CCI_IRQ_STATUS_0_I2C_M1_RD_DONE BIT(12) +#define CCI_IRQ_STATUS_0_I2C_M1_Q0_REPORT BIT(16) +#define CCI_IRQ_STATUS_0_I2C_M1_Q1_REPORT BIT(20) +#define CCI_IRQ_STATUS_0_RST_DONE_ACK BIT(24) +#define CCI_IRQ_STATUS_0_I2C_M0_Q0Q1_HALT_ACK BIT(25) +#define CCI_IRQ_STATUS_0_I2C_M1_Q0Q1_HALT_ACK BIT(26) +#define CCI_IRQ_STATUS_0_I2C_M0_ERROR 0x18000ee6 +#define CCI_IRQ_STATUS_0_I2C_M1_ERROR 0x60ee6000 + +#define CCI_TIMEOUT (msecs_to_jiffies(100)) +#define NUM_MASTERS 2 +#define NUM_QUEUES 2 + +/* Max number of resources + 1 for a NULL terminator */ +#define CCI_RES_MAX 6 + + +#define CCI_I2C_SET_PARAM 1 +#define CCI_I2C_REPORT 8 +#define CCI_I2C_WRITE 9 +#define CCI_I2C_READ 10 + +#define CCI_I2C_REPORT_IRQ_EN BIT(8) + +enum { + I2C_MODE_STANDARD, + I2C_MODE_FAST, + I2C_MODE_FAST_PLUS, +}; + +enum cci_i2c_queue_t { + QUEUE_0, + QUEUE_1 +}; + +struct hw_params { + u16 thigh; /* HIGH period of the SCL clock in clock ticks */ + u16 tlow; /* LOW period of the SCL clock */ + u16 tsu_sto; /* set-up time for STOP condition */ + u16 tsu_sta; /* set-up time for a repeated START condition */ + u16 thd_dat; /* data hold time */ + u16 thd_sta; /* hold time (repeated) START condition */ + u16 tbuf; /* bus free time between a STOP and START condition */ + u8 scl_stretch_en; + u16 trdhld; + u16 tsp; /* pulse width of spikes suppressed by the input filter */ +}; + +struct cci; + +struct cci_master { + struct i2c_adapter adap; + u16 master; + u8 mode; + int status; + struct completion irq_complete; + struct cci *cci; +}; + +struct cci_data { + unsigned int num_masters; + struct i2c_adapter_quirks quirks; + u16 queue_size[NUM_QUEUES]; + unsigned long cci_clk_rate; + struct hw_params params[3]; +}; + +struct cci { + struct device *dev; + void __iomem *base; + unsigned int irq; + const struct cci_data *data; + struct clk_bulk_data *clocks; + int nclocks; + struct cci_master master[NUM_MASTERS]; +}; + +static irqreturn_t cci_isr(int irq, void *dev) +{ + struct cci *cci = dev; + u32 val, reset = 0; + int ret = IRQ_NONE; + + val = readl(cci->base + CCI_IRQ_STATUS_0); + writel(val, cci->base + CCI_IRQ_CLEAR_0); + writel(0x1, cci->base + CCI_IRQ_GLOBAL_CLEAR_CMD); + + if (val & CCI_IRQ_STATUS_0_RST_DONE_ACK) { + complete(&cci->master[0].irq_complete); + if (cci->master[1].master) + complete(&cci->master[1].irq_complete); + ret = IRQ_HANDLED; + } + + if (val & CCI_IRQ_STATUS_0_I2C_M0_RD_DONE || + val & CCI_IRQ_STATUS_0_I2C_M0_Q0_REPORT || + val & CCI_IRQ_STATUS_0_I2C_M0_Q1_REPORT) { + cci->master[0].status = 0; + complete(&cci->master[0].irq_complete); + ret = IRQ_HANDLED; + } + + if (val & CCI_IRQ_STATUS_0_I2C_M1_RD_DONE || + val & CCI_IRQ_STATUS_0_I2C_M1_Q0_REPORT || + val & CCI_IRQ_STATUS_0_I2C_M1_Q1_REPORT) { + cci->master[1].status = 0; + complete(&cci->master[1].irq_complete); + ret = IRQ_HANDLED; + } + + if (unlikely(val & CCI_IRQ_STATUS_0_I2C_M0_Q0Q1_HALT_ACK)) { + reset = CCI_RESET_CMD_M0_MASK; + ret = IRQ_HANDLED; + } + + if (unlikely(val & CCI_IRQ_STATUS_0_I2C_M1_Q0Q1_HALT_ACK)) { + reset = CCI_RESET_CMD_M1_MASK; + ret = IRQ_HANDLED; + } + + if (unlikely(reset)) + writel(reset, cci->base + CCI_RESET_CMD); + + if (unlikely(val & CCI_IRQ_STATUS_0_I2C_M0_ERROR)) { + dev_err_ratelimited(cci->dev, "Master 0 error 0x%08x\n", val); + cci->master[0].status = -EIO; + writel(CCI_HALT_REQ_I2C_M0_Q0Q1, cci->base + CCI_HALT_REQ); + ret = IRQ_HANDLED; + } + + if (unlikely(val & CCI_IRQ_STATUS_0_I2C_M1_ERROR)) { + dev_err_ratelimited(cci->dev, "Master 1 error 0x%08x\n", val); + cci->master[1].status = -EIO; + writel(CCI_HALT_REQ_I2C_M1_Q0Q1, cci->base + CCI_HALT_REQ); + ret = IRQ_HANDLED; + } + + return ret; +} + +static int cci_halt(struct cci *cci, u8 master_num) +{ + struct cci_master *master; + u32 val; + + if (master_num > 1) { + dev_err(cci->dev, "Unsupported master idx (%u)\n", master_num); + return -EINVAL; + } + + val = BIT(master_num); + master = &cci->master[master_num]; + + reinit_completion(&master->irq_complete); + writel(val, cci->base + CCI_HALT_REQ); + + if (!wait_for_completion_timeout(&master->irq_complete, CCI_TIMEOUT)) { + dev_err(cci->dev, "CCI halt timeout\n"); + return -ETIMEDOUT; + } + + return 0; +} + +static int cci_reset(struct cci *cci) +{ + /* + * we reset the whole controller, here and for implicity use + * master[0].xxx for waiting on it. + */ + reinit_completion(&cci->master[0].irq_complete); + writel(CCI_RESET_CMD_MASK, cci->base + CCI_RESET_CMD); + + if (!wait_for_completion_timeout(&cci->master[0].irq_complete, + CCI_TIMEOUT)) { + dev_err(cci->dev, "CCI reset timeout\n"); + return -ETIMEDOUT; + } + + return 0; +} + +static int cci_init(struct cci *cci, const struct hw_params *hw) +{ + u32 val = CCI_IRQ_MASK_0_I2C_M0_RD_DONE | + CCI_IRQ_MASK_0_I2C_M0_Q0_REPORT | + CCI_IRQ_MASK_0_I2C_M0_Q1_REPORT | + CCI_IRQ_MASK_0_I2C_M1_RD_DONE | + CCI_IRQ_MASK_0_I2C_M1_Q0_REPORT | + CCI_IRQ_MASK_0_I2C_M1_Q1_REPORT | + CCI_IRQ_MASK_0_RST_DONE_ACK | + CCI_IRQ_MASK_0_I2C_M0_Q0Q1_HALT_ACK | + CCI_IRQ_MASK_0_I2C_M1_Q0Q1_HALT_ACK | + CCI_IRQ_MASK_0_I2C_M0_ERROR | + CCI_IRQ_MASK_0_I2C_M1_ERROR; + int i; + + writel(val, cci->base + CCI_IRQ_MASK_0); + + for (i = 0; i < cci->data->num_masters; i++) { + val = hw->thigh << 16 | hw->tlow; + writel(val, cci->base + CCI_I2C_Mm_SCL_CTL(i)); + + val = hw->tsu_sto << 16 | hw->tsu_sta; + writel(val, cci->base + CCI_I2C_Mm_SDA_CTL_0(i)); + + val = hw->thd_dat << 16 | hw->thd_sta; + writel(val, cci->base + CCI_I2C_Mm_SDA_CTL_1(i)); + + val = hw->tbuf; + writel(val, cci->base + CCI_I2C_Mm_SDA_CTL_2(i)); + + val = hw->scl_stretch_en << 8 | hw->trdhld << 4 | hw->tsp; + writel(val, cci->base + CCI_I2C_Mm_MISC_CTL(i)); + } + + return 0; +} + +static int cci_run_queue(struct cci *cci, u8 master, u8 queue) +{ + u32 val; + int ret; + + val = readl(cci->base + CCI_I2C_Mm_Qn_CUR_WORD_CNT(master, queue)); + writel(val, cci->base + CCI_I2C_Mm_Qn_EXEC_WORD_CNT(master, queue)); + + reinit_completion(&cci->master[master].irq_complete); + val = BIT(master * 2 + queue); + writel(val, cci->base + CCI_QUEUE_START); + + if (!wait_for_completion_timeout(&cci->master[master].irq_complete, + CCI_TIMEOUT)) { + dev_err(cci->dev, "master %d queue %d timeout\n", + master, queue); + + cci_reset(cci); + cci_init(cci, &cci->data->params[cci->master[master].mode]); + return -ETIMEDOUT; + } + + ret = cci->master[master].status; + if (ret < 0) + dev_err(cci->dev, "master %d queue %d error %d\n", + master, queue, ret); + + return ret; +} + +static int cci_validate_queue(struct cci *cci, u8 master, u8 queue) +{ + u32 val; + + val = readl(cci->base + CCI_I2C_Mm_Qn_CUR_WORD_CNT(master, queue)); + if (val == cci->data->queue_size[queue]) + return -EINVAL; + + if (!val) + return 0; + + val = CCI_I2C_REPORT | CCI_I2C_REPORT_IRQ_EN; + writel(val, cci->base + CCI_I2C_Mm_Qn_LOAD_DATA(master, queue)); + + return cci_run_queue(cci, master, queue); +} + +static int cci_i2c_read(struct cci *cci, u16 master, + u16 addr, u8 *buf, u16 len) +{ + u32 val, words_read, words_exp; + u8 queue = QUEUE_1; + int i, index = 0, ret; + bool first = true; + + /* + * Call validate queue to make sure queue is empty before starting. + * This is to avoid overflow / underflow of queue. + */ + ret = cci_validate_queue(cci, master, queue); + if (ret < 0) + return ret; + + val = CCI_I2C_SET_PARAM | (addr & 0x7f) << 4; + writel(val, cci->base + CCI_I2C_Mm_Qn_LOAD_DATA(master, queue)); + + val = CCI_I2C_READ | len << 4; + writel(val, cci->base + CCI_I2C_Mm_Qn_LOAD_DATA(master, queue)); + + ret = cci_run_queue(cci, master, queue); + if (ret < 0) + return ret; + + words_read = readl(cci->base + CCI_I2C_Mm_READ_BUF_LEVEL(master)); + words_exp = len / 4 + 1; + if (words_read != words_exp) { + dev_err(cci->dev, "words read = %d, words expected = %d\n", + words_read, words_exp); + return -EIO; + } + + do { + val = readl(cci->base + CCI_I2C_Mm_READ_DATA(master)); + + for (i = 0; i < 4 && index < len; i++) { + if (first) { + first = false; + continue; + } + buf[index++] = (val >> (i * 8)) & 0xff; + } + } while (--words_read); + + return 0; +} + +static int cci_i2c_write(struct cci *cci, u16 master, + u16 addr, u8 *buf, u16 len) +{ + u8 queue = QUEUE_0; + u8 load[12] = { 0 }; + int i = 0, j, ret; + u32 val; + + /* + * Call validate queue to make sure queue is empty before starting. + * This is to avoid overflow / underflow of queue. + */ + ret = cci_validate_queue(cci, master, queue); + if (ret < 0) + return ret; + + val = CCI_I2C_SET_PARAM | (addr & 0x7f) << 4; + writel(val, cci->base + CCI_I2C_Mm_Qn_LOAD_DATA(master, queue)); + + load[i++] = CCI_I2C_WRITE | len << 4; + + for (j = 0; j < len; j++) + load[i++] = buf[j]; + + for (j = 0; j < i; j += 4) { + val = load[j]; + val |= load[j + 1] << 8; + val |= load[j + 2] << 16; + val |= load[j + 3] << 24; + writel(val, cci->base + CCI_I2C_Mm_Qn_LOAD_DATA(master, queue)); + } + + val = CCI_I2C_REPORT | CCI_I2C_REPORT_IRQ_EN; + writel(val, cci->base + CCI_I2C_Mm_Qn_LOAD_DATA(master, queue)); + + return cci_run_queue(cci, master, queue); +} + +static int cci_xfer(struct i2c_adapter *adap, struct i2c_msg msgs[], int num) +{ + struct cci_master *cci_master = i2c_get_adapdata(adap); + struct cci *cci = cci_master->cci; + int i, ret; + + ret = pm_runtime_get_sync(cci->dev); + if (ret < 0) + goto err; + + for (i = 0; i < num; i++) { + if (msgs[i].flags & I2C_M_RD) + ret = cci_i2c_read(cci, cci_master->master, + msgs[i].addr, msgs[i].buf, + msgs[i].len); + else + ret = cci_i2c_write(cci, cci_master->master, + msgs[i].addr, msgs[i].buf, + msgs[i].len); + + if (ret < 0) { + dev_err(cci->dev, "cci i2c xfer error %d", ret); + break; + } + } + + if (!ret) + ret = num; + +err: + pm_runtime_mark_last_busy(cci->dev); + pm_runtime_put_autosuspend(cci->dev); + + return ret; +} + +static u32 cci_func(struct i2c_adapter *adap) +{ + return I2C_FUNC_I2C; +} + +static const struct i2c_algorithm cci_algo = { + .master_xfer = cci_xfer, + .functionality = cci_func, +}; + +static int cci_enable_clocks(struct cci *cci) +{ + int ret; + + ret = clk_bulk_prepare_enable(cci->nclocks, cci->clocks); + if (ret < 0) + dev_err(cci->dev, "Bulk clock prepare failed: %d\n", ret); + + return ret; +} + +static void cci_disable_clocks(struct cci *cci) +{ + clk_bulk_disable_unprepare(cci->nclocks, cci->clocks); +} + +#ifdef CONFIG_PM +static int cci_suspend_runtime(struct device *dev) +{ + struct cci *cci = dev_get_drvdata(dev); + + dev_dbg(dev, "Supend invoked\n"); + cci_disable_clocks(cci); + return 0; +} + +static int cci_resume_runtime(struct device *dev) +{ + struct cci *cci = dev_get_drvdata(dev); + + dev_dbg(dev, "Resume invoked\n"); + return cci_enable_clocks(cci); +} +#endif + +#ifdef CONFIG_PM_SLEEP +static int cci_suspend(struct device *dev) +{ + if (!pm_runtime_suspended(dev)) + return cci_suspend_runtime(dev); + + return 0; +} + +static int cci_resume(struct device *dev) +{ + cci_resume_runtime(dev); + pm_runtime_mark_last_busy(dev); + pm_request_autosuspend(dev); + + return 0; +} +#endif + +static const struct dev_pm_ops qcom_cci_pm = { + SET_SYSTEM_SLEEP_PM_OPS(cci_suspend, cci_resume) + SET_RUNTIME_PM_OPS(cci_suspend_runtime, cci_resume_runtime, NULL) +}; + +static int cci_probe(struct platform_device *pdev) +{ + struct device *dev = &pdev->dev; + struct device_node *of_node = NULL; + unsigned long cci_clk_rate = 0; + struct resource *r; + struct cci *cci; + int ret = 0, i; + u32 val; + + cci = devm_kzalloc(dev, sizeof(*cci), GFP_KERNEL); + if (!cci) + return -ENOMEM; + + cci->dev = dev; + platform_set_drvdata(pdev, cci); + cci->data = device_get_match_data(&pdev->dev); + if (!cci->data) { + dev_err(&pdev->dev, "Driver data is null, abort\n"); + return -EIO; + } + + for (i = 0; i < cci->data->num_masters; i++) { + cci->master[i].adap.quirks = &cci->data->quirks; + cci->master[i].adap.algo = &cci_algo; + cci->master[i].adap.dev.parent = cci->dev; + cci->master[i].master = i; + cci->master[i].cci = cci; + + i2c_set_adapdata(&cci->master[i].adap, &cci->master[i]); + snprintf(cci->master[i].adap.name, + sizeof(cci->master[i].adap.name), + "Qualcomm Camera Control Interface: %d", i); + + /* find the child node for i2c-bus as we are on cci node */ + of_node = of_get_next_available_child(dev->of_node, of_node); + if (!of_node) { + dev_err(dev, "Missing i2c-bus@%d child node\n", i); + return -EINVAL; + } + cci->master[i].adap.dev.of_node = of_node; + + cci->master[i].mode = I2C_MODE_STANDARD; + ret = of_property_read_u32(of_node, "clock-frequency", &val); + if (!ret) { + if (val == 400000) + cci->master[i].mode = I2C_MODE_FAST; + else if (val == 1000000) + cci->master[i].mode = I2C_MODE_FAST_PLUS; + } + + init_completion(&cci->master[i].irq_complete); + } + + /* Memory */ + + r = platform_get_resource(pdev, IORESOURCE_MEM, 0); + cci->base = devm_ioremap_resource(dev, r); + if (IS_ERR(cci->base)) + return PTR_ERR(cci->base); + + /* Interrupt */ + + ret = platform_get_irq(pdev, 0); + if (ret < 0) { + dev_err(dev, "missing IRQ: %d\n", ret); + return ret; + } + cci->irq = ret; + + ret = devm_request_irq(dev, cci->irq, cci_isr, + IRQF_TRIGGER_RISING, dev_name(dev), cci); + if (ret < 0) { + dev_err(dev, "request_irq failed, ret: %d\n", ret); + return ret; + } + + disable_irq(cci->irq); + + /* Clocks */ + + ret = devm_clk_bulk_get_all(dev, &cci->clocks); + if (ret < 1) { + dev_err(dev, "failed to get clocks %d\n", ret); + return ret; + } + cci->nclocks = ret; + + /* Retrieve CCI clock rate */ + for (i = 0; i < cci->nclocks; i++) { + if (!strncmp(cci->clocks[i].id, "cci", 4)) { + cci_clk_rate = clk_get_rate(cci->clocks[i].clk); + break; + } + } + + if (cci_clk_rate != cci->data->cci_clk_rate) { + /* cci clock set by the bootloader or via assigned clock rate + * in DT. + */ + dev_warn(dev, "Found %lu cci clk rate while %lu was expected\n", + cci_clk_rate, cci->data->cci_clk_rate); + } + + ret = cci_enable_clocks(cci); + if (ret < 0) + return ret; + + pm_runtime_set_autosuspend_delay(dev, MSEC_PER_SEC); + pm_runtime_use_autosuspend(dev); + pm_runtime_set_active(dev); + pm_runtime_enable(dev); + + val = readl_relaxed(cci->base + CCI_HW_VERSION); + dev_dbg(dev, "%s: CCI HW version = 0x%08x", __func__, val); + + enable_irq(cci->irq); + + ret = cci_reset(cci); + if (ret < 0) + goto error; + + for (i = 0; i < cci->data->num_masters; i++) { + ret = cci_init(cci, &cci->data->params[cci->master[i].mode]); + if (ret < 0) + goto pm_error; + + ret = i2c_add_adapter(&cci->master[i].adap); + if (ret < 0) + goto error_i2c; + } + + return 0; + +error_i2c: + for (; i >= 0; i--) + i2c_del_adapter(&cci->master[i].adap); +pm_error: + pm_runtime_disable(dev); + pm_runtime_set_suspended(dev); +error: + disable_irq(cci->irq); + cci_disable_clocks(cci); + + return ret; +} + +static int cci_remove(struct platform_device *pdev) +{ + struct cci *cci = platform_get_drvdata(pdev); + int i; + + for (i = 0; i < cci->data->num_masters; i++) { + i2c_del_adapter(&cci->master[i].adap); + cci_halt(cci, i); + } + + disable_irq(cci->irq); + pm_runtime_disable(&pdev->dev); + pm_runtime_set_suspended(&pdev->dev); + + return 0; +} + +static const struct cci_data cci_8916_data = { + .num_masters = 1, + .queue_size = { 64, 16 }, + .quirks = { + .max_write_len = 10, + .max_read_len = 12, + }, + .cci_clk_rate = 19200000, + .params[I2C_MODE_STANDARD] = { + .thigh = 78, + .tlow = 114, + .tsu_sto = 28, + .tsu_sta = 28, + .thd_dat = 10, + .thd_sta = 77, + .tbuf = 118, + .scl_stretch_en = 0, + .trdhld = 6, + .tsp = 1 + }, + .params[I2C_MODE_FAST] = { + .thigh = 20, + .tlow = 28, + .tsu_sto = 21, + .tsu_sta = 21, + .thd_dat = 13, + .thd_sta = 18, + .tbuf = 32, + .scl_stretch_en = 0, + .trdhld = 6, + .tsp = 3 + }, +}; + +static const struct cci_data cci_8996_data = { + .num_masters = 2, + .queue_size = { 64, 16 }, + .quirks = { + .max_write_len = 11, + .max_read_len = 12, + }, + .cci_clk_rate = 37500000, + .params[I2C_MODE_STANDARD] = { + .thigh = 201, + .tlow = 174, + .tsu_sto = 204, + .tsu_sta = 231, + .thd_dat = 22, + .thd_sta = 162, + .tbuf = 227, + .scl_stretch_en = 0, + .trdhld = 6, + .tsp = 3 + }, + .params[I2C_MODE_FAST] = { + .thigh = 38, + .tlow = 56, + .tsu_sto = 40, + .tsu_sta = 40, + .thd_dat = 22, + .thd_sta = 35, + .tbuf = 62, + .scl_stretch_en = 0, + .trdhld = 6, + .tsp = 3 + }, + .params[I2C_MODE_FAST_PLUS] = { + .thigh = 16, + .tlow = 22, + .tsu_sto = 17, + .tsu_sta = 18, + .thd_dat = 16, + .thd_sta = 15, + .tbuf = 24, + .scl_stretch_en = 0, + .trdhld = 3, + .tsp = 3 + }, +}; + +static const struct of_device_id cci_dt_match[] = { + { .compatible = "qcom,msm8916-cci", .data = &cci_8916_data}, + { .compatible = "qcom,msm8996-cci", .data = &cci_8996_data}, + {} +}; +MODULE_DEVICE_TABLE(of, cci_dt_match); + +static struct platform_driver qcom_cci_driver = { + .probe = cci_probe, + .remove = cci_remove, + .driver = { + .name = "i2c-qcom-cci", + .of_match_table = cci_dt_match, + .pm = &qcom_cci_pm, + }, +}; + +module_platform_driver(qcom_cci_driver); + +MODULE_DESCRIPTION("Qualcomm Camera Control Interface driver"); +MODULE_AUTHOR("Todor Tomov "); +MODULE_AUTHOR("Loic Poulain "); +MODULE_LICENSE("GPL v2"); From patchwork Tue Dec 31 09:26:36 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Loic Poulain X-Patchwork-Id: 182663 Delivered-To: patch@linaro.org Received: by 2002:a92:815a:0:0:0:0:0 with SMTP id e87csp7359327ild; Tue, 31 Dec 2019 01:23:29 -0800 (PST) X-Google-Smtp-Source: APXvYqzsnpWTHzvqN/RhJMOW7YZXs7tM1BCXypIqsW1stHmPpM3J9Q6eKAfoM4GfBsDUdCL9yEU5 X-Received: by 2002:a9d:222f:: with SMTP id o44mr66181908ota.51.1577784209840; Tue, 31 Dec 2019 01:23:29 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1577784209; cv=none; d=google.com; s=arc-20160816; b=n8ilpQ68+Nzz/dVEQjtr1jWkrAL4eoQfPd3LKYrLy6bgSfQzgj1RGZ7srOYjMVmBqt LgKz9yg8rOnMWDRWutj3ptgFrz6YtrwjD/MiVY8soG4mxv3bHDr3gY2sXRj2WUPpuAd/ AiTt1lCwuuedILcpEbR9GGsYzGk2qSwtFFwKQwbQ46Js3lPAZy5wYMNiCJi33msSsLao rAu9GXHobI4pubxpiP6GlKwjBinoHDOt8uc6QO+z0fc3L1YopTfWqIeUrlsS9pJbPkPw kpxIBO3U8b3fIexYOiduyr5A7qVZRJoRTaXgnQYF5GIOjfFs0mKf7wgR22H+Yveqc5jr fR6w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature; bh=WPcgVhEHNK42D0Gldks5ovVVLr0SxkDopBo5FedXpYw=; b=QMD2oAbxrM3LMf/ssuo9XlW+5cXTAX10kOfC7IVNwpV1YpORwgliCobH8eKd2MW9R5 NqU7IN+r1BXy6sjNPjFf7G4HUcP7jFRwhPwxTcNvcjZen/biY8dYrZDod2C/zrZbsa3v AdR6UilZIWjaQ2FjVVe4ZLCRZ3xZ8nmXJtDegt+g8o3HmWIAU/ESUiBXj3mxaOCX+9EJ /3Xmuyk0vnp1tqtbfDFPgcOYeP9GUtbuw3sPh4ys/e+gLwFSlKN4gw5HMYCj2rF01EGf XJzGDP02Mr/pAIQUhUi7zfz4zZmkH3q9uQiuMQjKJNYM04dF0DzHywEJ0EQhAXjbbWiu NOcA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="ODOb3/rj"; spf=pass (google.com: best guess record for domain of linux-i2c-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-i2c-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 a10si8517719oid.84.2019.12.31.01.23.29; Tue, 31 Dec 2019 01:23:29 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-i2c-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="ODOb3/rj"; spf=pass (google.com: best guess record for domain of linux-i2c-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-i2c-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 S1726416AbfLaJX3 (ORCPT + 2 others); Tue, 31 Dec 2019 04:23:29 -0500 Received: from mail-wm1-f67.google.com ([209.85.128.67]:37132 "EHLO mail-wm1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726308AbfLaJX3 (ORCPT ); Tue, 31 Dec 2019 04:23:29 -0500 Received: by mail-wm1-f67.google.com with SMTP id f129so1437517wmf.2 for ; Tue, 31 Dec 2019 01:23:27 -0800 (PST) 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; bh=WPcgVhEHNK42D0Gldks5ovVVLr0SxkDopBo5FedXpYw=; b=ODOb3/rjLx2VFEK/71/6RToeburRb3MmLt2NmEuMsf5nlOHBOjtnuaCUXFFDX8M6AK SzpNhK2l8ZPUS7s1ZFzSUC3Wzd0Dszi0avTmeg0V9A9u2iJDEV6csDj8WG5UzxN/GrNL zjO0X4+LmBsTk8tc2dZ7Ziv54tGRzG6/XdBdcLjNwLdR1AkzLKOaAV3+Ku04syY6PyRL roirZ3rJ3Ixc9FJx8tn9eIQ1r2fq9BszmNjNETYX5dXE4G9hWk9OYdjC+M9l4TFBjgHT jCeJLDVUo3aX32BCtbdJ+5lscpPq1BNqCGdroCzwB7zZQkUVabhj9h396KIPLX1xP7qT RI9g== 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; bh=WPcgVhEHNK42D0Gldks5ovVVLr0SxkDopBo5FedXpYw=; b=jpskSS/X8xEb78ORvfbcZe3HOc5owhc3DqRTNWIirrO+cnQmbpm/kGOXkn+UpNQZ6K 4EDU/WR8Le6LqEniG7FyjKXGmumPQiZ901N3v03BnSQBOAN8eBPSN4M3REFRsHTBwPtY V7cIrj+K50PZnR91SNl+sofATFsZI8OFc2RsbEHtXjmY67cV+93/MWwoBVqUXFtbGDsi zGVG8SH3mgnTTzSUzcGDc6BI/GBIMO2NoyPvtI3nwoP3xpIPJoGPXOximJhidEiwSgoz 2Omv2fosItUuwdfiKIBDbtxd9gK7EeK1SsANbn3cixfjsX/cOIUdoNSSfx9XbA43acF4 J3DQ== X-Gm-Message-State: APjAAAUiJpCVYjdxK7+2XFYXXPKXBAHBwMPid4/wo+83ItHtA5g2/0m9 b4mgwrF/m8rn18XbgqXGyrcYXNoSx6g= X-Received: by 2002:a05:600c:203:: with SMTP id 3mr3472545wmi.31.1577784206542; Tue, 31 Dec 2019 01:23:26 -0800 (PST) Received: from lpoulain-ThinkPad-T470p.home (amontpellier-651-1-422-191.w92-133.abo.wanadoo.fr. [92.133.205.191]) by smtp.gmail.com with ESMTPSA id f1sm48153410wro.85.2019.12.31.01.23.25 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 31 Dec 2019 01:23:26 -0800 (PST) From: Loic Poulain To: wsa@the-dreams.de, robh+dt@kernel.org Cc: vkoul@kernel.org, todor.too@gmail.com, linux-i2c@vger.kernel.org, bjorn.andersson@linaro.org, Todor Tomov Subject: [PATCH v2 2/3] dt-bindings: i2c: Add binding for Qualcomm CCI I2C controller Date: Tue, 31 Dec 2019 10:26:36 +0100 Message-Id: <1577784397-28682-2-git-send-email-loic.poulain@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1577784397-28682-1-git-send-email-loic.poulain@linaro.org> References: <1577784397-28682-1-git-send-email-loic.poulain@linaro.org> Sender: linux-i2c-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-i2c@vger.kernel.org From: Todor Tomov Add DT binding document for Qualcomm Camera Control Interface (CCI) I2C controller. Signed-off-by: Todor Tomov Signed-off-by: Vinod Koul Reviewed-by: Rob Herring --- v2: Fix subnode properties, remove mandatory clock names .../devicetree/bindings/i2c/i2c-qcom-cci.txt | 91 ++++++++++++++++++++++ 1 file changed, 91 insertions(+) create mode 100644 Documentation/devicetree/bindings/i2c/i2c-qcom-cci.txt -- 2.7.4 diff --git a/Documentation/devicetree/bindings/i2c/i2c-qcom-cci.txt b/Documentation/devicetree/bindings/i2c/i2c-qcom-cci.txt new file mode 100644 index 0000000..ca8b9ab --- /dev/null +++ b/Documentation/devicetree/bindings/i2c/i2c-qcom-cci.txt @@ -0,0 +1,91 @@ +Qualcomm Camera Control Interface (CCI) I2C controller + +PROPERTIES: + +- compatible: + Usage: required + Value type: + Definition: must be one of: + "qcom,msm8916-cci" + "qcom,msm8996-cci" + +- reg + Usage: required + Value type: + Definition: base address CCI I2C controller and length of memory + mapped region. + +- interrupts: + Usage: required + Value type: + Definition: specifies the CCI I2C interrupt. The format of the + specifier is defined by the binding document describing + the node's interrupt parent. + +- clocks: + Usage: required + Value type: + Definition: a list of phandle, should contain an entry for each + entries in clock-names. + +- clock-names + Usage: required + Value type: + Definition: a list of clock names, must include "cci" clock. + +- power-domains + Usage: required for "qcom,msm-8996-cci" + Value type: + Definition: + +SUBNODES: + +The CCI provides I2C masters for one (msm8916) or two i2c busses (msm8996), +described as subdevices named "i2c-bus@0" and "i2c-bus@1". + +PROPERTIES: + +- reg: + Usage: required + Value type: + Definition: Index of the CCI bus/master + +- clock-frequency: + Usage: optional + Value type: + Definition: Desired I2C bus clock frequency in Hz, defaults to 100 + kHz if omitted. + +Example: + + cci@a0c000 { + compatible = "qcom,msm-8996-cci"; + #address-cells = <1>; + #size-cells = <0>; + reg = <0xa0c000 0x1000>; + interrupts = ; + clocks = <&mmcc MMSS_MMAGIC_AHB_CLK>, + <&mmcc CAMSS_TOP_AHB_CLK>, + <&mmcc CAMSS_CCI_AHB_CLK>, + <&mmcc CAMSS_CCI_CLK>, + <&mmcc CAMSS_AHB_CLK>; + clock-names = "mmss_mmagic_ahb", + "camss_top_ahb", + "cci_ahb", + "cci", + "camss_ahb"; + + i2c-bus@0 { + reg = <0>; + clock-frequency = <400000>; + #address-cells = <1>; + #size-cells = <0>; + }; + + i2c-bus@1 { + reg = <1>; + clock-frequency = <400000>; + #address-cells = <1>; + #size-cells = <0>; + }; + }; From patchwork Tue Dec 31 09:26:37 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Loic Poulain X-Patchwork-Id: 182664 Delivered-To: patch@linaro.org Received: by 2002:a92:815a:0:0:0:0:0 with SMTP id e87csp7359351ild; Tue, 31 Dec 2019 01:23:30 -0800 (PST) X-Google-Smtp-Source: APXvYqxjNX4LlGfuNhHVR1Ue9XheohqbYyW9CRrGR1j35LoGoy9nCWMWDgEQm3CatNZJ+Sscupzz X-Received: by 2002:a05:6830:1e67:: with SMTP id m7mr76161617otr.262.1577784210810; Tue, 31 Dec 2019 01:23:30 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1577784210; cv=none; d=google.com; s=arc-20160816; b=AzeNBuhUKvKKqvVUbB85U1l3v45wMCEY02hv2QWCjzTJGxEidASx9OHTp98sZmOfCt BFXee2DPRrox+FU7amhHxG+7gNU3ys4FeE6crp2LMwYM5d25EzkyS7vQC/oW/IQ1iNfw oCgVQRnMAuwZNYUV55u0si298NojkDHMmFKFbfqBRYcW5lhXfh8165j2k64k5BmRS7Pk jSWTTXjs6km68IfgdzEmDYoel2gafmAMf/+yywsX6+E/TWRVbSHtoJ5Sexb089UcEr6A rJdOHBHxshZckQNNuzUMG/utOK+3sScQ891W0r/r/Dnb3ReB2FBYuZrxUDqUfamg64o2 upjg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature; bh=Vblv5LQYK0UdrRNc3BaK4/YCI0e3o6x+HZlNV5gbBAc=; b=aL8qOdJ/nHvWy/Mu97ovUrNtVeeIoS+RPO3iwKXD9gJ//i3ALdSPQwV7219f8D9/Js iEwAWXwRRyLlKfE6drMya5ouLxi+CUOOXZOtNZljzG4eelKN7DbUk8wXbf12I06X0MOh mpbI2gjiE3Y7Fuld6motfydnk/mLjnOkZeEgAfCGGJ9JDAS4KaZeYlyqwgUmDypZPqny BJ8rm2QARLnRDf5ZsLttGLSn3N5Y9s6vV8b3T1UXvKShMTZuJiVXVvJwynkNWajPF7hl zKiaNoQbYx/NqqD6ZkEzxUPvmC1N9fx75A3enMYXYYrSXGCiWaA2N39pkJjLrXYO/KCP lU+g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=nCMF+ruX; spf=pass (google.com: best guess record for domain of linux-i2c-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-i2c-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 a10si8517719oid.84.2019.12.31.01.23.30; Tue, 31 Dec 2019 01:23:30 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-i2c-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=nCMF+ruX; spf=pass (google.com: best guess record for domain of linux-i2c-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-i2c-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 S1726308AbfLaJXa (ORCPT + 2 others); Tue, 31 Dec 2019 04:23:30 -0500 Received: from mail-wr1-f66.google.com ([209.85.221.66]:34225 "EHLO mail-wr1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726119AbfLaJXa (ORCPT ); Tue, 31 Dec 2019 04:23:30 -0500 Received: by mail-wr1-f66.google.com with SMTP id t2so34723866wrr.1 for ; Tue, 31 Dec 2019 01:23:28 -0800 (PST) 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; bh=Vblv5LQYK0UdrRNc3BaK4/YCI0e3o6x+HZlNV5gbBAc=; b=nCMF+ruXNt+bZxp2o0LxaZ0LB6ihnQxMus3aNO121bmqxATMSOS6k9hV68RLYRblCK xoJ0ItmII4mn44ROY/C08Jfb7pjA5TBwNUU5RHNPaq0vnBxtwlDu7/Ld+6Vq3HqvFTt/ 8Fr+QY5OgWSz5tgiSpsG+5s5qqQ/sa3NSj7eBz1rISj7zrUnrAmsp1CKjETfZy1CiFov F+ciMQNc3qPQ7ZMn+Akij8RXfeD8Bb+NEqzYiTImUd9TgFR7BwvC8qGVfmWrbQZQo1Sn hSIvPbrmd+wbReOnajpnLN04H0yrYIJ/6JTSiMR1memDgRHVGOq1yBvrGVawxjmYDXd+ Mcaw== 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; bh=Vblv5LQYK0UdrRNc3BaK4/YCI0e3o6x+HZlNV5gbBAc=; b=g6uxycT6hY1Lx5rL/pd1Ji8zmq/c+g2wwntxt085MPxS4BxdGlNr/Ppi0vNc6Zxp+B bxQe9vwYhR7RYzPsJ2TJ67sRXZoX2rMwquOMDtBYY9DWBN9lJI7/1NY6E0mu9hC6tcYE pV3TXg7WfEl4756SMDd+xtQf9KZGS63qn0A11zsm1gJEwwlJNrwHtsOFxryhadBEUzZa zak+oGZ5kasWKF/3gk082WZ0Kl3/7UzRyGQ1rbZ+QVMOSJWy7e7jeLp+QegrNlT76Czu qfVZFAakgJNDQ6OWwUd63cMTcMh87tE7nD5IG9KS6LEyyqeWTjRE6Fqbwsdn+7BLGbRq x58Q== X-Gm-Message-State: APjAAAVz0kNbrVbeFDbHzDbLK+vTy0DeIHmX2Kw2Y4eiznkNeFvMPXtH dA9V1DdTSBbOWFZeK4knJyDScw== X-Received: by 2002:adf:ebc3:: with SMTP id v3mr70050083wrn.280.1577784207865; Tue, 31 Dec 2019 01:23:27 -0800 (PST) Received: from lpoulain-ThinkPad-T470p.home (amontpellier-651-1-422-191.w92-133.abo.wanadoo.fr. [92.133.205.191]) by smtp.gmail.com with ESMTPSA id f1sm48153410wro.85.2019.12.31.01.23.27 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 31 Dec 2019 01:23:27 -0800 (PST) From: Loic Poulain To: wsa@the-dreams.de, robh+dt@kernel.org Cc: vkoul@kernel.org, todor.too@gmail.com, linux-i2c@vger.kernel.org, bjorn.andersson@linaro.org, Loic Poulain Subject: [PATCH v2 3/3] arm64: dts: apq8016-sbc: Add CCI/Sensor nodes Date: Tue, 31 Dec 2019 10:26:37 +0100 Message-Id: <1577784397-28682-3-git-send-email-loic.poulain@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1577784397-28682-1-git-send-email-loic.poulain@linaro.org> References: <1577784397-28682-1-git-send-email-loic.poulain@linaro.org> Sender: linux-i2c-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-i2c@vger.kernel.org Add cci device to msm8916.dtsi. Add default 96boards camera node for db410c (apq8016-sbc). Signed-off-by: Loic Poulain --- v2: add this patch in the series arch/arm64/boot/dts/qcom/apq8016-sbc.dtsi | 75 +++++++++++++++++++++++++++++++ arch/arm64/boot/dts/qcom/msm8916.dtsi | 27 +++++++++++ 2 files changed, 102 insertions(+) -- 2.7.4 diff --git a/arch/arm64/boot/dts/qcom/apq8016-sbc.dtsi b/arch/arm64/boot/dts/qcom/apq8016-sbc.dtsi index e12a36c..9860286 100644 --- a/arch/arm64/boot/dts/qcom/apq8016-sbc.dtsi +++ b/arch/arm64/boot/dts/qcom/apq8016-sbc.dtsi @@ -494,6 +494,81 @@ wcnss@a21b000 { status = "okay"; }; + + camera_vdddo_1v8: fixedregulator@0 { + compatible = "regulator-fixed"; + regulator-name = "camera_vdddo"; + regulator-min-microvolt = <1800000>; + regulator-max-microvolt = <1800000>; + regulator-always-on; + }; + + camera_vdda_2v8: fixedregulator@1 { + compatible = "regulator-fixed"; + regulator-name = "camera_vdda"; + regulator-min-microvolt = <2800000>; + regulator-max-microvolt = <2800000>; + regulator-always-on; + }; + + camera_vddd_1v5: fixedregulator@2 { + compatible = "regulator-fixed"; + regulator-name = "camera_vddd"; + regulator-min-microvolt = <1500000>; + regulator-max-microvolt = <1500000>; + regulator-always-on; + }; + + cci@1b0c000 { + status = "ok"; + i2c-bus@0 { + camera_rear@3b { + compatible = "ovti,ov5640"; + reg = <0x3b>; + + enable-gpios = <&msmgpio 34 GPIO_ACTIVE_HIGH>; + reset-gpios = <&msmgpio 35 GPIO_ACTIVE_LOW>; + pinctrl-names = "default"; + pinctrl-0 = <&camera_rear_default>; + + clocks = <&gcc GCC_CAMSS_MCLK0_CLK>; + clock-names = "xclk"; + clock-frequency = <23880000>; + + vdddo-supply = <&camera_vdddo_1v8>; + vdda-supply = <&camera_vdda_2v8>; + vddd-supply = <&camera_vddd_1v5>; + + /* No camera mezzanine by default */ + status = "okay"; + + port { + ov5640_ep: endpoint { + clock-lanes = <1>; + data-lanes = <0 2>; + remote-endpoint = <&csiphy0_ep>; + }; + }; + }; + }; + }; + + camss@1b00000 { + status = "ok"; + ports { + #address-cells = <1>; + #size-cells = <0>; + port@0 { + reg = <0>; + csiphy0_ep: endpoint { + clock-lanes = <1>; + data-lanes = <0 2>; + remote-endpoint = <&ov5640_ep>; + status = "okay"; + }; + }; + }; + }; }; usb2513 { diff --git a/arch/arm64/boot/dts/qcom/msm8916.dtsi b/arch/arm64/boot/dts/qcom/msm8916.dtsi index 8686e10..7e90e80 100644 --- a/arch/arm64/boot/dts/qcom/msm8916.dtsi +++ b/arch/arm64/boot/dts/qcom/msm8916.dtsi @@ -1451,6 +1451,33 @@ }; }; + cci@1b0c000 { + compatible = "qcom,msm8916-cci"; + #address-cells = <1>; + #size-cells = <0>; + reg = <0x1b0c000 0x1000>; + interrupts = ; + clocks = <&gcc GCC_CAMSS_TOP_AHB_CLK>, + <&gcc GCC_CAMSS_CCI_AHB_CLK>, + <&gcc GCC_CAMSS_CCI_CLK>, + <&gcc GCC_CAMSS_AHB_CLK>; + clock-names = "camss_top_ahb", "cci_ahb", + "cci", "camss_ahb"; + assigned-clocks = <&gcc GCC_CAMSS_CCI_AHB_CLK>, + <&gcc GCC_CAMSS_CCI_CLK>; + assigned-clock-rates = <80000000>, <19200000>; + pinctrl-names = "default"; + pinctrl-0 = <&cci0_default>; + status = "disabled"; + + i2c-bus@0 { + reg = <0>; + clock-frequency = <400000>; + #address-cells = <1>; + #size-cells = <0>; + }; + }; + camss: camss@1b00000 { compatible = "qcom,msm8916-camss"; reg = <0x1b0ac00 0x200>,