From patchwork Thu Feb 16 07:41:52 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jeremy Kerr X-Patchwork-Id: 13142736 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 96C1BC64ED8 for ; Thu, 16 Feb 2023 08:59:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=8KBWGUMi6fwrlF+Lwe46SnoVZaQQTFdlflKSwp1wo5s=; b=WCkh54n6+VadF9 FlLN3top5BMGQr2oygOGpzpgfw+agIdR4V5lqPs232Dl7DnIswxapOwBtUOrV3+xnW8JtCVfSN270 XA8uKRgHGtzgmG8VcfkZzNJCmH3tIc7EjpxsZA3bqm3uGz1LVeWV3IAgSzY6sTHkj0XA+yo3pv28g 1ITfLwiFYULaHA0s8vCFwxXMScRdTmTqGEtlp+qvr2/B8bsSiojtsZdilQVKvyk5MFbG9+ctzbQsL 2T0ZUfz96Tr57+7/tQxaQGXJAeQIKm4Mj9vBl+nNqpzPbNB2ouQes6sFGe2DmA1O+9Th7wBPFNYMY sTzhPzLLjMi4b1Drkg1A==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1pSa7M-0099Ic-TT; Thu, 16 Feb 2023 08:59:52 +0000 Received: from pi.codeconstruct.com.au ([203.29.241.158] helo=codeconstruct.com.au) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1pSYu8-008q9b-9y for linux-i3c@lists.infradead.org; Thu, 16 Feb 2023 07:42:11 +0000 Received: by codeconstruct.com.au (Postfix, from userid 10000) id A141620178; Thu, 16 Feb 2023 15:42:00 +0800 (AWST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=codeconstruct.com.au; s=2022a; t=1676533320; bh=s6ehK0j4ise00ta19NKaW0MnDM4sA9n4LCZKGU732KU=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=MNmRVoK0ZJtmb5u/nDJltKOEh0ETDRlMWLEn6baZZiZtaMzscgCwCDF8+ZwajCjla 5CJ9OSKubS/xreoI2BmFLmV1CsseMXkivszP6EDU97WTk9XJxN/I5r8VERGrT6JO3g P/G/Mz00hUN/Fn4H6D9WknqhtvrwvyDk/uRZgEBTGyXVrCgmkI4RJ8pM7Qe660Nos4 9cg177q/XCfI2/KNZ4kiVonzFDdMz6+54FC93b3BJFPGaLR+SqrNaZAB3SVdiUVyYr 1NSFoDCxnG2c444QdZYTv4S5P0UizeSdMvuwaVa+h2fe5HbxgtJpmVp09yKwiEILa9 zt0hlRGNhUYWQ== From: Jeremy Kerr To: linux-i3c@lists.infradead.org Cc: Alexandre Belloni , Vitor Soares , linux-aspeed@lists.ozlabs.org, devicetree@vger.kernel.org, Rob Herring , Krzysztof Kozlowski , Dylan Hung , Joel Stanley , Andrew Jeffery Subject: [PATCH 1/4] dt-bindings: i3c: Add AST2600 i3c controller Date: Thu, 16 Feb 2023 15:41:52 +0800 Message-Id: <82d750f53df622d8986e9a07053c7ee27dee61a2.1676532146.git.jk@codeconstruct.com.au> X-Mailer: git-send-email 2.39.1 In-Reply-To: References: MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230215_234208_573626_51B05441 X-CRM114-Status: GOOD ( 12.90 ) X-Mailman-Approved-At: Thu, 16 Feb 2023 00:59:51 -0800 X-BeenThere: linux-i3c@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-i3c" Errors-To: linux-i3c-bounces+linux-i3c=archiver.kernel.org@lists.infradead.org Add a devicetree binding for the ast2600 i3c controller hardware. This is heavily based on the designware i3c core, plus a reset facility and two platform-specific properties: - sda-pullup-ohms: to specify the value of the configurable pullup resistors on the SDA line - aspeed,global-regs: to reference the (ast2600-specific) i3c global register block, and the device index to use within it. Signed-off-by: Jeremy Kerr Reviewed-by: Krzysztof Kozlowski --- changes from RFC: - add vendor prefix to global-regs properties - add item description on global-regs property - drop global reg node from example --- .../bindings/i3c/aspeed,ast2600-i3c.yaml | 73 +++++++++++++++++++ 1 file changed, 73 insertions(+) create mode 100644 Documentation/devicetree/bindings/i3c/aspeed,ast2600-i3c.yaml diff --git a/Documentation/devicetree/bindings/i3c/aspeed,ast2600-i3c.yaml b/Documentation/devicetree/bindings/i3c/aspeed,ast2600-i3c.yaml new file mode 100644 index 000000000000..920428f243b5 --- /dev/null +++ b/Documentation/devicetree/bindings/i3c/aspeed,ast2600-i3c.yaml @@ -0,0 +1,73 @@ +# SPDX-License-Identifier: GPL-2.0 +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/i3c/aspeed,ast2600-i3c.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: ASPEED AST2600 i3c controller + +maintainers: + - Jeremy Kerr + +allOf: + - $ref: i3c.yaml# + +properties: + compatible: + const: aspeed,ast2600-i3c + + reg: + maxItems: 1 + + clocks: + maxItems: 1 + + resets: + maxItems: 1 + + interrupts: + maxItems: 1 + + sda-pullup-ohms: + enum: [545, 750, 2000] + default: 2000 + description: | + Value to configure SDA pullup resistor, in Ohms. + + aspeed,global-regs: + $ref: /schemas/types.yaml#/definitions/phandle-array + items: + - items: + - description: phandle to i3c global register syscon node + - description: index of this i3c controller in the global register set + description: | + A (phandle, controller index) reference to the i3c global register set + used for this device. + +required: + - compatible + - reg + - clocks + - interrupts + - aspeed,global-regs + +unevaluatedProperties: false + +examples: + - | + #include + #include + + i3c-master@2000 { + compatible = "aspeed,ast2600-i3c"; + reg = <0x2000 0x1000>; + #address-cells = <3>; + #size-cells = <0>; + clocks = <&syscon ASPEED_CLK_GATE_I3C0CLK>; + resets = <&syscon ASPEED_RESET_I3C0>; + aspeed,global-regs = <&i3c_global 0>; + pinctrl-names = "default"; + pinctrl-0 = <&pinctrl_i3c1_default>; + interrupts = ; + }; +... From patchwork Thu Feb 16 07:41:53 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jeremy Kerr X-Patchwork-Id: 13142737 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 96B77C6379F for ; Thu, 16 Feb 2023 08:59:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=LHEJ+QjgzUFIL1gIXyfVjBdSIPcw68YQx1Xaax9NbaI=; b=qmNW3FJs6fOwa5 D0LlkfbeW+d/lL+Fhy2ncwamHRXLyGMLu66P4BQq6x0eR5Rv6SkPd014qXFdmOKeR4XyVw+bobq/g OPSJ/dNv5B+2FIX1DAWoELEE5vh5jD4fQ1KXGBCzfU9YvNrFjw0FrPi3qx8QExzSLOQoj+5Mw0W32 PNtrzGfBl8GVBG7to8IhKh9vUYDu4/O8WFkMKAjcW6hhMBY7aJoeR1/2VjtYsGpWihKX1wW7qYYPa evRrszvq2kbnKbWtbhxzDybac+/Qfd6RUsap3Timc0xNcjJUH/eM070drFwHlqfazZcXF1D+NRSQ2 S3MLK4M/4j2NYjqNmcng==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1pSa7N-0099Ij-0C; Thu, 16 Feb 2023 08:59:53 +0000 Received: from pi.codeconstruct.com.au ([203.29.241.158] helo=codeconstruct.com.au) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1pSYu8-008q9Z-9w for linux-i3c@lists.infradead.org; Thu, 16 Feb 2023 07:42:11 +0000 Received: by codeconstruct.com.au (Postfix, from userid 10000) id 3FC012024A; Thu, 16 Feb 2023 15:42:01 +0800 (AWST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=codeconstruct.com.au; s=2022a; t=1676533321; bh=nEz8ZwbZq4uv4GNC68L/J2QzHskqfAQiUHEbxZNxSGE=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=RUszN14YWY6naxENAcAJoIIZQBU49k8A+C7WnAEzCiiPM8+BW/Z13Jl1hZpfDl6Ce etUM/dvOr32V40DqnICZr1mg+dwXD93fUIP3qTiNGnsiy/1ZGEQ6sMdUQmRMx5GWvI fmqmwR86cw61Cuhyuj7+UsoHb0F06BOPLJ7Gnr8khlgCk1RdrAn2O3nNRH2c1N4xO2 DPKA98xMF1VMbQn6hBf3NI9/Jr0mZoOHnan/QS7YmDEkfeULWADJKFNPBS/ThQuNs/ QA5gRpsFIbfOpugPM7AR8Z5cBnqNloHpoMhKZGnVHth505qvPgUYCRg2cZ72UQYBMp szJtg+HZfiyzw== From: Jeremy Kerr To: linux-i3c@lists.infradead.org Cc: Alexandre Belloni , Vitor Soares , linux-aspeed@lists.ozlabs.org, devicetree@vger.kernel.org, Rob Herring , Krzysztof Kozlowski , Dylan Hung , Joel Stanley , Andrew Jeffery Subject: [PATCH 2/4] i3c: dw: Add platform operations Date: Thu, 16 Feb 2023 15:41:53 +0800 Message-Id: X-Mailer: git-send-email 2.39.1 In-Reply-To: References: MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230215_234208_587104_372579C4 X-CRM114-Status: GOOD ( 15.85 ) X-Mailman-Approved-At: Thu, 16 Feb 2023 00:59:51 -0800 X-BeenThere: linux-i3c@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-i3c" Errors-To: linux-i3c-bounces+linux-i3c=archiver.kernel.org@lists.infradead.org The dw i3c core can be integrated into various SoC devices. Platforms that use this core may need a little configuration that is specific to that platform. Add a little infrastructure to allow platform-specific behaviour: a bit of data on struct dw_i3c_master, and two hooks to the probe and init calls to enable this. A future change will add new platform support that uses these hooks. Signed-off-by: Jeremy Kerr --- drivers/i3c/master/dw-i3c-master.c | 42 +++++++++++++++++++++++++----- 1 file changed, 36 insertions(+), 6 deletions(-) diff --git a/drivers/i3c/master/dw-i3c-master.c b/drivers/i3c/master/dw-i3c-master.c index d73d57362b3b..49b891449222 100644 --- a/drivers/i3c/master/dw-i3c-master.c +++ b/drivers/i3c/master/dw-i3c-master.c @@ -241,6 +241,17 @@ struct dw_i3c_master { char version[5]; char type[5]; u8 addrs[MAX_DEVS]; + + /* platform-specific data */ + const struct dw_i3c_platform_ops *platform_ops; + union { + } pdata; + +}; + +struct dw_i3c_platform_ops { + int (*probe)(struct dw_i3c_master *i3c, struct platform_device *pdev); + int (*init)(struct dw_i3c_master *i3c); }; struct dw_i3c_i2c_dev_data { @@ -612,6 +623,12 @@ static int dw_i3c_master_bus_init(struct i3c_master_controller *m) u32 thld_ctrl; int ret; + if (master->platform_ops && master->platform_ops->init) { + ret = master->platform_ops->init(master); + if (ret) + return ret; + } + switch (bus->mode) { case I3C_BUS_MODE_MIXED_FAST: case I3C_BUS_MODE_MIXED_LIMITED: @@ -1128,8 +1145,15 @@ static const struct i3c_master_controller_ops dw_mipi_i3c_ops = { .i2c_xfers = dw_i3c_master_i2c_xfers, }; +static const struct of_device_id dw_i3c_master_of_match[] = { + { .compatible = "snps,dw-i3c-master-1.00a", }, + {}, +}; +MODULE_DEVICE_TABLE(of, dw_i3c_master_of_match); + static int dw_i3c_probe(struct platform_device *pdev) { + const struct of_device_id *match; struct dw_i3c_master *master; int ret, irq; @@ -1181,6 +1205,18 @@ static int dw_i3c_probe(struct platform_device *pdev) master->maxdevs = ret >> 16; master->free_pos = GENMASK(master->maxdevs - 1, 0); + /* match any platform-specific ops */ + match = of_match_node(dw_i3c_master_of_match, pdev->dev.of_node); + if (match && match->data) + master->platform_ops = match->data; + + /* platform-specific probe */ + if (master->platform_ops && master->platform_ops->probe) { + ret = master->platform_ops->probe(master, pdev); + if (ret) + goto err_assert_rst; + } + ret = i3c_master_register(&master->base, &pdev->dev, &dw_mipi_i3c_ops, false); if (ret) @@ -1213,12 +1249,6 @@ static int dw_i3c_remove(struct platform_device *pdev) return 0; } -static const struct of_device_id dw_i3c_master_of_match[] = { - { .compatible = "snps,dw-i3c-master-1.00a", }, - {}, -}; -MODULE_DEVICE_TABLE(of, dw_i3c_master_of_match); - static struct platform_driver dw_i3c_driver = { .probe = dw_i3c_probe, .remove = dw_i3c_remove, From patchwork Thu Feb 16 07:41:54 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jeremy Kerr X-Patchwork-Id: 13142739 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id AEAC1C64ED9 for ; Thu, 16 Feb 2023 08:59:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=6PNycM/3HkQFIYQ8IREe6VwL5qZQ0Joh3Z6Esmjptoc=; b=e/YJG4mfgNhC47 fAlFxfO5ZjsKbDayxOFOTfr8uNPt3j5dS8qG+o29nUd1KR4VVmmIrE3C6S4pzXxV1u6cArCUSzE9M FVf7V9aC8YJfrmbNQybye0lyzncdaWgaZ63DbJce5YHmymwlcjPqxc9TAH0QJB7jC5jpl3WENYohX 1s13mL2uXFPv7eD5cFg3dZiyQzMfLBkLa74NT2ypzGBNTSnAJw2aCZTcwYNu3twVjQkJn4fUlA6yC FdgLoanMtjZ9lzoqLRlFOIjeBgHzE05zame+B8Mqus4zpmHDFetnA5zNvAopDY9enUvUr2ZUmbb7g F55ABrQTB1gBY4diNt0g==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1pSa7N-0099Iq-3E; Thu, 16 Feb 2023 08:59:53 +0000 Received: from pi.codeconstruct.com.au ([203.29.241.158] helo=codeconstruct.com.au) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1pSYu8-008q9a-9x for linux-i3c@lists.infradead.org; Thu, 16 Feb 2023 07:42:11 +0000 Received: by codeconstruct.com.au (Postfix, from userid 10000) id A440E20263; Thu, 16 Feb 2023 15:42:01 +0800 (AWST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=codeconstruct.com.au; s=2022a; t=1676533321; bh=Lfq0z5zxLHpxLqFA3VpqpSTKNBJ2T17NIsgf+cqHE74=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=VvV2SKBjPI1k98vj9N30VOpNc+g7O/Owweql2d/1Y9r4EJnWnhkFmU6LPTxsvpyBA WIMkr5YLsXVrJYMtVUGn6/BA4H8uhWj65uqbbSZ03LD2l/J0oi1zx+4BhBSnkJknvY qUbbbjGKJQmoe54F2qzSaUxdkURqkTerROLsB8JweKh+ET7qb84DMEfa5Kk6FMdryz WE8RvH7H4B8pqcpzK7qq3wvl0joVW6Pyz+YKe5QxH00G9DaswrbXt2R5Uq1vMyKwk+ 7ZFGdQkk7lOZ6430JGNRgGGBsvbZ1HftSdWQ8uq3PJjDTJi2cy8HEmj3HE07P2bnPy Bkd/GRMYhtmTQ== From: Jeremy Kerr To: linux-i3c@lists.infradead.org Cc: Alexandre Belloni , Vitor Soares , linux-aspeed@lists.ozlabs.org, devicetree@vger.kernel.org, Rob Herring , Krzysztof Kozlowski , Dylan Hung , Joel Stanley , Andrew Jeffery Subject: [PATCH 3/4] i3c: dw: Add AST2600 platform ops Date: Thu, 16 Feb 2023 15:41:54 +0800 Message-Id: <5d27e16ea3eea8c88f448a3f540e6d2eebf78d2c.1676532146.git.jk@codeconstruct.com.au> X-Mailer: git-send-email 2.39.1 In-Reply-To: References: MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230215_234208_750802_081A0DFD X-CRM114-Status: GOOD ( 17.44 ) X-Mailman-Approved-At: Thu, 16 Feb 2023 00:59:51 -0800 X-BeenThere: linux-i3c@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-i3c" Errors-To: linux-i3c-bounces+linux-i3c=archiver.kernel.org@lists.infradead.org Now that we have platform-specific hooks for the dw i3c driver, add platform support for the ASPEED AST2600 SoC. The AST2600 has a small set of "i3c global" registers, providing platform-level i3c configuration outside of the i3c core. For the ast2600, we need a couple of extra setup operations: - on probe: find the i3c global register set and parse the SDA pullup resistor values - on init: set the pullups accordingly, and set the i3c instance IDs Signed-off-by: Jeremy Kerr --- drivers/i3c/master/dw-i3c-master.c | 122 +++++++++++++++++++++++++++++ 1 file changed, 122 insertions(+) diff --git a/drivers/i3c/master/dw-i3c-master.c b/drivers/i3c/master/dw-i3c-master.c index 49b891449222..9be3348cba0e 100644 --- a/drivers/i3c/master/dw-i3c-master.c +++ b/drivers/i3c/master/dw-i3c-master.c @@ -16,8 +16,10 @@ #include #include #include +#include #include #include +#include #include #include @@ -201,6 +203,28 @@ #define XFER_TIMEOUT (msecs_to_jiffies(1000)) +/* AST2600-specific global register set */ +#define AST2600_I3CG_REG0(idx) (((idx) * 4 * 4) + 0x10) +#define AST2600_I3CG_REG1(idx) (((idx) * 4 * 4) + 0x14) + +#define AST2600_I3CG_REG0_SDA_PULLUP_EN_MASK GENMASK(29, 28) +#define AST2600_I3CG_REG0_SDA_PULLUP_EN_2K (0x0 << 28) +#define AST2600_I3CG_REG0_SDA_PULLUP_EN_750 (0x2 << 28) + +#define AST2600_I3CG_REG1_I2C_MODE BIT(0) +#define AST2600_I3CG_REG1_TEST_MODE BIT(1) +#define AST2600_I3CG_REG1_ACT_MODE_MASK GENMASK(3, 2) +#define AST2600_I3CG_REG1_ACT_MODE(x) (((x) << 2) & AST2600_I3CG_REG1_ACT_MODE_MASK) +#define AST2600_I3CG_REG1_PENDING_INT_MASK GENMASK(7, 4) +#define AST2600_I3CG_REG1_PENDING_INT(x) (((x) << 4) & AST2600_I3CG_REG1_PENDING_INT_MASK) +#define AST2600_I3CG_REG1_SA_MASK GENMASK(14, 8) +#define AST2600_I3CG_REG1_SA(x) (((x) << 8) & AST2600_I3CG_REG1_SA_MASK) +#define AST2600_I3CG_REG1_SA_EN BIT(15) +#define AST2600_I3CG_REG1_INST_ID_MASK GENMASK(19, 16) +#define AST2600_I3CG_REG1_INST_ID(x) (((x) << 16) & AST2600_I3CG_REG1_INST_ID_MASK) + +#define AST2600_DEFAULT_SDA_PULLUP_OHMS 2000 + struct dw_i3c_master_caps { u8 cmdfifodepth; u8 datafifodepth; @@ -224,6 +248,12 @@ struct dw_i3c_xfer { struct dw_i3c_cmd cmds[]; }; +struct pdata_ast2600 { + struct regmap *global_regs; + unsigned int global_idx; + unsigned int sda_pullup; +}; + struct dw_i3c_master { struct i3c_master_controller base; u16 maxdevs; @@ -245,6 +275,7 @@ struct dw_i3c_master { /* platform-specific data */ const struct dw_i3c_platform_ops *platform_ops; union { + struct pdata_ast2600 ast2600; } pdata; }; @@ -1145,6 +1176,97 @@ static const struct i3c_master_controller_ops dw_mipi_i3c_ops = { .i2c_xfers = dw_i3c_master_i2c_xfers, }; +/* hardware-specific ops */ + +static int ast2600_i3c_pullup_to_reg(unsigned int ohms, u32 *regp) +{ + u32 reg; + + switch (ohms) { + case 2000: + reg = AST2600_I3CG_REG0_SDA_PULLUP_EN_2K; + break; + case 750: + reg = AST2600_I3CG_REG0_SDA_PULLUP_EN_750; + break; + case 545: + reg = AST2600_I3CG_REG0_SDA_PULLUP_EN_2K | + AST2600_I3CG_REG0_SDA_PULLUP_EN_750; + break; + default: + return -EINVAL; + } + + if (regp) + *regp = reg; + + return 0; +} + +static int ast2600_i3c_probe(struct dw_i3c_master *master, + struct platform_device *pdev) +{ + struct pdata_ast2600 *pdata = &master->pdata.ast2600; + struct device_node *np = pdev->dev.of_node; + struct of_phandle_args gspec; + int rc; + + rc = of_parse_phandle_with_fixed_args(np, "aspeed,global-regs", 1, 0, + &gspec); + if (rc) + return -ENODEV; + + pdata->global_regs = syscon_node_to_regmap(gspec.np); + of_node_put(gspec.np); + + if (IS_ERR(pdata->global_regs)) + return PTR_ERR(pdata->global_regs); + + pdata->global_idx = gspec.args[0]; + + rc = of_property_read_u32(np, "sda-pullup-ohms", &pdata->sda_pullup); + if (rc) + pdata->sda_pullup = AST2600_DEFAULT_SDA_PULLUP_OHMS; + + rc = ast2600_i3c_pullup_to_reg(pdata->sda_pullup, NULL); + if (rc) + dev_err(&master->base.dev, "invalid sda-pullup value %d\n", + pdata->sda_pullup); + + return rc; +} + +static int ast2600_i3c_init(struct dw_i3c_master *master) +{ + struct pdata_ast2600 *pdata = &master->pdata.ast2600; + u32 reg = 0; + int rc; + + /* reg0: set SDA pullup values */ + rc = ast2600_i3c_pullup_to_reg(pdata->sda_pullup, ®); + if (rc) + return rc; + + rc = regmap_write(pdata->global_regs, + AST2600_I3CG_REG0(pdata->global_idx), reg); + if (rc) + return rc; + + /* reg1: set up the instance id, but leave everything else disabled, + * as it's all for client mode + */ + reg = AST2600_I3CG_REG1_INST_ID(pdata->global_idx); + rc = regmap_write(pdata->global_regs, + AST2600_I3CG_REG1(pdata->global_idx), reg); + + return rc; +} + +static const struct dw_i3c_platform_ops ast2600_platform_ops = { + .probe = ast2600_i3c_probe, + .init = ast2600_i3c_init, +}; + static const struct of_device_id dw_i3c_master_of_match[] = { { .compatible = "snps,dw-i3c-master-1.00a", }, {}, From patchwork Thu Feb 16 07:41:55 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jeremy Kerr X-Patchwork-Id: 13142738 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 7192FC636CC for ; Thu, 16 Feb 2023 08:59:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=aHkZyTXsqH6aN5c+D4wzS4eSGwfQPpy/ytQHwV5aIYQ=; b=tMi4+d+Atk5d9/ HXCzuXQSWDzmxDRrcHpPeNqA6+N2gEW48a2uEgLE2fFSnbSmMEcFLEHO9pMmHkXoC5+YMOT9XCwH3 GD86cmt7mZt1ReZwiLyk/1q0u86UT0aRrMqyjNkCUAH+gUkADE2NEQjrJZuSPmh+1mIOHu7jCIU2U 3Q1kCcuhfWOu02AdmBqhXhb/t+Ggzr7MtJjPEJTFw3RcqVlAxQQztQ3i1Yo1bSHRR4chKNkFWMsTN YPcxyvK0+eE9VY3+3RilnoeMD+PReJPNd9dZPdcuwr1rO0ak29DFH9AfgbSHZ1dnmmc7geSrywCSB vp/OjatKVVk4qIP3ZXgQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1pSa7M-0099IR-Pq; Thu, 16 Feb 2023 08:59:52 +0000 Received: from pi.codeconstruct.com.au ([203.29.241.158] helo=codeconstruct.com.au) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1pSYu8-008q9Y-9z for linux-i3c@lists.infradead.org; Thu, 16 Feb 2023 07:42:10 +0000 Received: by codeconstruct.com.au (Postfix, from userid 10000) id 294F9202BB; Thu, 16 Feb 2023 15:42:02 +0800 (AWST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=codeconstruct.com.au; s=2022a; t=1676533322; bh=WryB2GO2zbrBH8W+AuZGRUy0IPCfawW4rexCATxsMBo=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=eEytakf3bWKJmEVJAsaqrNdZ4Yrkak1X/toUToOL/S3SqugAS2GUyL4iSuDNq/x94 ZRWUanKtpochL1PbTtn78MvlZxxMX59bsowwH5jjoMG+dEu00Iq0cFpzK+bMmxhKt6 P9mO2HzWrRRVyMdpNS/hhKrH5AzFapkgKUEew6wDO2MW+svjKBhPSH+cChFZPL9wNg 13t6mgcYwSe8qpqjL7CIgEqrZxCXWGl98/J3NuusTKbzmX9JRCt89+8mQAvsLInAEu dsEdEOmVHwVlAeTkoOxtU2S+NDdLOo6kg2VmiUxXf/b4W3JLq9cVHKLm2RVpi8QtFQ k86uz5pgQJRwA== From: Jeremy Kerr To: linux-i3c@lists.infradead.org Cc: Alexandre Belloni , Vitor Soares , linux-aspeed@lists.ozlabs.org, devicetree@vger.kernel.org, Rob Herring , Krzysztof Kozlowski , Dylan Hung , Joel Stanley , Andrew Jeffery Subject: [PATCH 4/4] i3c: dw: Add compatible string for ASPEED AST2600 BMC platform Date: Thu, 16 Feb 2023 15:41:55 +0800 Message-Id: <90e8fd66b42bc27e6b8c01085c40721232217a5d.1676532146.git.jk@codeconstruct.com.au> X-Mailer: git-send-email 2.39.1 In-Reply-To: References: MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230215_234208_596482_D44E5E8E X-CRM114-Status: UNSURE ( 7.99 ) X-CRM114-Notice: Please train this message. X-Mailman-Approved-At: Thu, 16 Feb 2023 00:59:51 -0800 X-BeenThere: linux-i3c@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-i3c" Errors-To: linux-i3c-bounces+linux-i3c=archiver.kernel.org@lists.infradead.org Now that we have platform-specific code for the ast2600, enable it through a new compatible string. Signed-off-by: Jeremy Kerr --- drivers/i3c/master/dw-i3c-master.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/i3c/master/dw-i3c-master.c b/drivers/i3c/master/dw-i3c-master.c index 9be3348cba0e..5ac226e0c558 100644 --- a/drivers/i3c/master/dw-i3c-master.c +++ b/drivers/i3c/master/dw-i3c-master.c @@ -1269,6 +1269,7 @@ static const struct dw_i3c_platform_ops ast2600_platform_ops = { static const struct of_device_id dw_i3c_master_of_match[] = { { .compatible = "snps,dw-i3c-master-1.00a", }, + { .compatible = "aspeed,ast2600-i3c", .data = &ast2600_platform_ops }, {}, }; MODULE_DEVICE_TABLE(of, dw_i3c_master_of_match);