Received: by 2002:a25:c205:0:0:0:0:0 with SMTP id s5csp2176685ybf; Mon, 2 Mar 2020 03:34:39 -0800 (PST) X-Google-Smtp-Source: ADFU+vuBnpPTYY70hTuMsHDTZgVj/Y8wzx1JTMyQPvG3mDv5k1FC/SA496E/Wd02MavkFz8cIqBn X-Received: by 2002:a9d:73d1:: with SMTP id m17mr6008241otk.19.1583148879476; Mon, 02 Mar 2020 03:34:39 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1583148879; cv=none; d=google.com; s=arc-20160816; b=f2eBErpMAIPJfDDdxZVbxp1Yn/S7F+wf2gvzMcjy3S+Q+gKNpdUZaqT0D5QQrVOeFx vkedgLs+mzLRNtQczpOHQ6nleelFQ7xDr+SYceQeMDvYU0PXWQn5hzz4Wv5JHccYuhFi 1O8bp/QGhrAwtx7pavaSq8Oa+bdp/setIXdPKf/8wB12PSTN9y30lj4oomxrEpElBzeW Fo3RTKqG9u9ZPhpKnIlisfb75lM4IAUxmqGpKtrYd3E/m/VvrnTwFiyGWf7yqNog60pb AxsNfDOEORfNdXSntpcD7XqYlZB0smurJ+a4lHiic40OOmi2P6OP/bTyRvlytcK+z7dH dm8g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:message-id:date:subject:cc :to:from:dkim-signature; bh=LK5Rc8fBCqHr4BrNiCRui/DbI9k5MYuzFQ9Jui1JyFw=; b=ZidQ1vnal2IqlIwcPNj3JDB3YjEKFA5HvdIC663hU0xI1th+coTTxJVAxp4SK01fS3 62LQoZszcXg8lS70BL3I29dVVPp5LR4oNCotelUfnmdkhLmoVeAbAnQOdg2KVK6vWQ2K EtOuJy7T82/U87jqafU1GI1hfWiRszAyDePrTG4tEVXvPVS01C2aoi01xQnIyQrEB978 bN0c4LdWjT/OKN8TVnSgujRqwTu2EwRKjGahWRU2xc2/kPii2rzrWTw9Ix6Ww1LS+XIu Qu73sY8N2IfaGvQRn8hSyBbf5vuS6ddrWsBJ0uzLICZvjRZdKcb295HZghaxHbv3HiM3 MgAw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@st.com header.s=STMicroelectronics header.b=sLI3Lp5o; 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=st.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id s127si1454521oih.191.2020.03.02.03.34.27; Mon, 02 Mar 2020 03:34:39 -0800 (PST) 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=@st.com header.s=STMicroelectronics header.b=sLI3Lp5o; 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=st.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727769AbgCBLdh (ORCPT + 99 others); Mon, 2 Mar 2020 06:33:37 -0500 Received: from mx08-00178001.pphosted.com ([91.207.212.93]:35988 "EHLO mx07-00178001.pphosted.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1725996AbgCBLdg (ORCPT ); Mon, 2 Mar 2020 06:33:36 -0500 Received: from pps.filterd (m0046661.ppops.net [127.0.0.1]) by mx07-00178001.pphosted.com (8.16.0.42/8.16.0.42) with SMTP id 022BXSbO002288; Mon, 2 Mar 2020 12:33:28 +0100 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=st.com; h=from : to : cc : subject : date : message-id : mime-version : content-type; s=STMicroelectronics; bh=LK5Rc8fBCqHr4BrNiCRui/DbI9k5MYuzFQ9Jui1JyFw=; b=sLI3Lp5o/9lux+MHY5cQrtsLRwzk8UtSEuOmUJR9jTL+3BcMaZv+FvP9jWer0XxJwBEa 23mrkhjt1Pn43RrXHr29cvumJuI/c095CsOQ7LfFhVISkSnUYOf45hDgTVAM2WkpT242 THaOk5W66Gs5eP5dMi4X0rJbMjNjnZlbM1MKBbc6SOlOpZpjHnfiYFRQ6K4tLKqVuwlc CIbDk/Zm9VlDnl7RqiVsmGUzuNENCbNLlrohj3kse3rpikFILCvfeCOsgsM+L/uDmApe d0j2RDOzrE5vyvX22Op4u16PqWHMmEMSqn/MtGc+f+KXmxgUdm8+84v6HP2ktq+rwQhF oA== Received: from beta.dmz-eu.st.com (beta.dmz-eu.st.com [164.129.1.35]) by mx07-00178001.pphosted.com with ESMTP id 2yffqpk3wf-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 02 Mar 2020 12:33:28 +0100 Received: from euls16034.sgp.st.com (euls16034.sgp.st.com [10.75.44.20]) by beta.dmz-eu.st.com (STMicroelectronics) with ESMTP id 09E99100034; Mon, 2 Mar 2020 12:33:17 +0100 (CET) Received: from Webmail-eu.st.com (sfhdag3node2.st.com [10.75.127.8]) by euls16034.sgp.st.com (STMicroelectronics) with ESMTP id F252F2BEC69; Mon, 2 Mar 2020 12:33:16 +0100 (CET) Received: from localhost (10.75.127.44) by SFHDAG3NODE2.st.com (10.75.127.8) with Microsoft SMTP Server (TLS) id 15.0.1347.2; Mon, 2 Mar 2020 12:33:16 +0100 From: Alain Volmat To: , CC: , , , , , , Subject: [PATCHv2 3/5] i2c: i2c-stm32f7: add a new st,stm32mp15-i2c compatible Date: Mon, 2 Mar 2020 12:33:16 +0100 Message-ID: <1583148796-24285-1-git-send-email-alain.volmat@st.com> X-Mailer: git-send-email 2.7.4 MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [10.75.127.44] X-ClientProxiedBy: SFHDAG8NODE2.st.com (10.75.127.23) To SFHDAG3NODE2.st.com (10.75.127.8) X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.138,18.0.572 definitions=2020-03-02_03:2020-02-28,2020-03-02 signatures=0 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Add a new stm32mp15 specific compatible to handle FastMode+ registers handling which is different on the stm32mp15 compared to the stm32f7 or stm32h7. Indeed, on the stm32mp15, the FastMode+ set and clear registers are separated while on the other platforms (F7 or H7) the control is done in a unique register. Signed-off-by: Alain Volmat Reviewed-by: Pierre-Yves MORDRET ---- v2: adapt struct stm32f7_i2c_dev fmp register variable naming (regmap_ -> fmp_) --- drivers/i2c/busses/i2c-stm32f7.c | 39 +++++++++++++++++++++++++++++++++------ 1 file changed, 33 insertions(+), 6 deletions(-) diff --git a/drivers/i2c/busses/i2c-stm32f7.c b/drivers/i2c/busses/i2c-stm32f7.c index cfe6d790a8fc..8fe7f8caf91b 100644 --- a/drivers/i2c/busses/i2c-stm32f7.c +++ b/drivers/i2c/busses/i2c-stm32f7.c @@ -223,6 +223,7 @@ struct stm32f7_i2c_spec { * @fall_time: Fall time (ns) * @dnf: Digital filter coefficient (0-16) * @analog_filter: Analog filter delay (On/Off) + * @fmp_clr_offset: Fast Mode Plus clear register offset from set register */ struct stm32f7_i2c_setup { enum stm32_i2c_speed speed; @@ -232,6 +233,7 @@ struct stm32f7_i2c_setup { u32 fall_time; u8 dnf; bool analog_filter; + u32 fmp_clr_offset; }; /** @@ -303,7 +305,8 @@ struct stm32f7_i2c_msg { * @dma: dma data * @use_dma: boolean to know if dma is used in the current transfer * @regmap: holds SYSCFG phandle for Fast Mode Plus bits - * @fmp_reg: register address for setting Fast Mode Plus bits + * @fmp_sreg: register address for setting Fast Mode Plus bits + * @fmp_creg: register address for clearing Fast Mode Plus bits * @fmp_mask: mask for Fast Mode Plus bits in set register * @wakeup_src: boolean to know if the device is a wakeup source */ @@ -328,7 +331,8 @@ struct stm32f7_i2c_dev { struct stm32_i2c_dma *dma; bool use_dma; struct regmap *regmap; - u32 fmp_reg; + u32 fmp_sreg; + u32 fmp_creg; u32 fmp_mask; bool wakeup_src; }; @@ -386,6 +390,14 @@ static const struct stm32f7_i2c_setup stm32f7_setup = { .analog_filter = STM32F7_I2C_ANALOG_FILTER_ENABLE, }; +static const struct stm32f7_i2c_setup stm32mp15_setup = { + .rise_time = STM32F7_I2C_RISE_TIME_DEFAULT, + .fall_time = STM32F7_I2C_FALL_TIME_DEFAULT, + .dnf = STM32F7_I2C_DNF_DEFAULT, + .analog_filter = STM32F7_I2C_ANALOG_FILTER_ENABLE, + .fmp_clr_offset = 0x40, +}; + static inline void stm32f7_i2c_set_bits(void __iomem *reg, u32 mask) { writel_relaxed(readl_relaxed(reg) | mask, reg); @@ -1837,14 +1849,25 @@ static int stm32f7_i2c_unreg_slave(struct i2c_client *slave) static int stm32f7_i2c_write_fm_plus_bits(struct stm32f7_i2c_dev *i2c_dev, bool enable) { + int ret; + if (i2c_dev->speed != STM32_I2C_SPEED_FAST_PLUS || IS_ERR_OR_NULL(i2c_dev->regmap)) /* Optional */ return 0; - return regmap_update_bits(i2c_dev->regmap, i2c_dev->fmp_reg, - i2c_dev->fmp_mask, - enable ? i2c_dev->fmp_mask : 0); + if (i2c_dev->fmp_sreg == i2c_dev->fmp_creg) + ret = regmap_update_bits(i2c_dev->regmap, + i2c_dev->fmp_sreg, + i2c_dev->fmp_mask, + enable ? i2c_dev->fmp_mask : 0); + else + ret = regmap_write(i2c_dev->regmap, + enable ? i2c_dev->fmp_sreg : + i2c_dev->fmp_creg, + i2c_dev->fmp_mask); + + return ret; } static int stm32f7_i2c_setup_fm_plus_bits(struct platform_device *pdev, @@ -1859,10 +1882,13 @@ static int stm32f7_i2c_setup_fm_plus_bits(struct platform_device *pdev, return 0; ret = of_property_read_u32_index(np, "st,syscfg-fmp", 1, - &i2c_dev->fmp_reg); + &i2c_dev->fmp_sreg); if (ret) return ret; + i2c_dev->fmp_creg = i2c_dev->fmp_sreg + + i2c_dev->setup.fmp_clr_offset; + return of_property_read_u32_index(np, "st,syscfg-fmp", 2, &i2c_dev->fmp_mask); } @@ -2262,6 +2288,7 @@ static const struct dev_pm_ops stm32f7_i2c_pm_ops = { static const struct of_device_id stm32f7_i2c_match[] = { { .compatible = "st,stm32f7-i2c", .data = &stm32f7_setup}, + { .compatible = "st,stm32mp15-i2c", .data = &stm32mp15_setup}, {}, }; MODULE_DEVICE_TABLE(of, stm32f7_i2c_match); -- 2.7.4 -