From patchwork Tue May 8 02:48:23 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Levin X-Patchwork-Id: 10385195 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 87ADC60353 for ; Tue, 8 May 2018 02:50:36 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 78410289C5 for ; Tue, 8 May 2018 02:50:36 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 6CF0F28BB3; Tue, 8 May 2018 02:50:36 +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 0966A289C5 for ; Tue, 8 May 2018 02:50:35 +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-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:References: In-Reply-To:Message-Id:Date:Subject:To:From:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=xIWQ42la8XstifLkN9MNOA/1AAF2HT7NwWU5xz5Van0=; b=egDrHRReFRd4MFFuE1EtHrmPn1 7tQdPHdue3zxm9VOLXSgJsYOunXvN24vH7hPUiyYSBLS3KUJo+FWJq0ZNpe9qc7bhgYvfFbiFsKho TwyhXgTwY3nwJBDi9M0kGiCPd7otjy+ITMqPz97d0l5WJqen4vbAV4uI+j56fSkXDggG8Vx7Yzb6q Xew5bnyCJTMVY1PQBNMQot7QRnBPE6cTRl0OOYrbKnX4l6SCwGxxadT2no82zsOM/ZK9RpIv05Hek OI0rWmMYoPbOTUfHt2KO7bIr0LKn41TnVyqfeYqVdAL7iqPXYUQoUd8AYwBcGJ9KkZyJgI4Ez4kwN GyRva11w==; 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 1fFshy-0004ws-5H; Tue, 08 May 2018 02:50:30 +0000 Received: from regular1.263xmail.com ([211.150.99.139]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1fFshB-0003Eg-3p for linux-rockchip@lists.infradead.org; Tue, 08 May 2018 02:49:43 +0000 Received: from djw?t-chip.com.cn (unknown [192.168.167.87]) by regular1.263xmail.com (Postfix) with ESMTP id 27F5B5626; Tue, 8 May 2018 10:49:27 +0800 (CST) X-263anti-spam: KSV:0; X-MAIL-GRAY: 0 X-MAIL-DELIVERY: 1 X-KSVirus-check: 0 X-ABS-CHECKED: 4 Received: from localhost.localdomain (localhost [127.0.0.1]) by smtp.263.net (Postfix) with ESMTPA id DE7153AA; Tue, 8 May 2018 10:49:26 +0800 (CST) X-RL-SENDER: djw@t-chip.com.cn X-FST-TO: linux-rockchip@lists.infradead.org X-SENDER-IP: 59.33.107.187 X-LOGIN-NAME: djw@t-chip.com.cn X-UNIQUE-TAG: <06e95ef40aa750cf23ee021b3f0dda6b> X-ATTACHMENT-NUM: 0 X-SENDER: djw@t-chip.com.cn X-DNS-TYPE: 7 Received: from unknown (187.107.33.59.broad.zs.gd.dynamic.163data.com.cn [59.33.107.187]) by smtp.263.net (Postfix) whith SMTP id 19231RUMIVY; Tue, 08 May 2018 10:49:27 +0800 (CST) From: djw@t-chip.com.cn To: linux-rockchip@lists.infradead.org Subject: [PATCH v0 1/2] gpio: syscon: Add gpio-syscon for rk3328 Date: Tue, 8 May 2018 10:48:23 +0800 Message-Id: <1525747704-8537-2-git-send-email-djw@t-chip.com.cn> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1525747704-8537-1-git-send-email-djw@t-chip.com.cn> References: <1525747704-8537-1-git-send-email-djw@t-chip.com.cn> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20180507_194941_508170_37BA5FDC X-CRM114-Status: GOOD ( 11.42 ) X-BeenThere: linux-rockchip@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: Upstream kernel work for Rockchip platforms List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: linux-gpio@vger.kernel.org, Wayne Chou , Levin Du , Linus Walleij , linux-kernel@vger.kernel.org MIME-Version: 1.0 Sender: "Linux-rockchip" Errors-To: linux-rockchip-bounces+patchwork-linux-rockchip=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP From: Levin Du In Rockchip RK3328 Soc, there's a output only gpio pin labeled `gpiomut_pmuio_iout`, which can be set by bit[1] of GRF_SOC_CON10. (bit[0] controls the enable state of the pin and defaults to enabled.) This pin is used by the roc-rk3328-cc board to switch sdmmc io signal voltage between 1.8V and 3.3V, which is essential to the SD card UHS support. Signed-off-by: Levin Du --- drivers/gpio/gpio-syscon.c | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/drivers/gpio/gpio-syscon.c b/drivers/gpio/gpio-syscon.c index 537cec7..b69f65f 100644 --- a/drivers/gpio/gpio-syscon.c +++ b/drivers/gpio/gpio-syscon.c @@ -135,6 +135,34 @@ static const struct syscon_gpio_data clps711x_mctrl_gpio = { .dat_bit_offset = 0x40 * 8 + 8, }; +static void rockchip_gpio_set(struct gpio_chip *chip, unsigned int offset, + int val) +{ + struct syscon_gpio_priv *priv = gpiochip_get_data(chip); + unsigned int offs; + u8 bit; + u32 data; + int ret; + + offs = priv->dreg_offset + priv->data->dat_bit_offset + offset; + bit = offs % SYSCON_REG_BITS; + data = (val ? BIT(bit) : 0) | BIT(bit + 16); + ret = regmap_write(priv->syscon, + (offs / SYSCON_REG_BITS) * SYSCON_REG_SIZE, + data); + if (ret < 0) + dev_err(chip->parent, "gpio write failed ret(%d)\n", ret); +} + +static const struct syscon_gpio_data rk3328_gpio_syscon10 = { + /* Rockchip RK3328 GRF_SOC_CON10 Bits 0-1 */ + .compatible = "rockchip,rk3328-grf", + .flags = GPIO_SYSCON_FEAT_OUT, + .bit_count = 2, + .dat_bit_offset = 0x0428 * 8, + .set = rockchip_gpio_set, +}; + #define KEYSTONE_LOCK_BIT BIT(0) static void keystone_gpio_set(struct gpio_chip *chip, unsigned offset, int val) @@ -175,6 +203,10 @@ static const struct of_device_id syscon_gpio_ids[] = { .compatible = "ti,keystone-dsp-gpio", .data = &keystone_dsp_gpio, }, + { + .compatible = "rockchip,rk3328-gpio-syscon10", + .data = &rk3328_gpio_syscon10, + }, { } }; MODULE_DEVICE_TABLE(of, syscon_gpio_ids);