Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp503417imu; Thu, 3 Jan 2019 01:53:31 -0800 (PST) X-Google-Smtp-Source: ALg8bN5wp0vegWZXiDoO09DRoN8oxmPCvnxBRK0sUNdkeX7/w789sal2D9/2dEpQPY1a+SK+Ket5 X-Received: by 2002:a17:902:ba89:: with SMTP id k9mr47115445pls.189.1546509211577; Thu, 03 Jan 2019 01:53:31 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1546509211; cv=none; d=google.com; s=arc-20160816; b=bfyd7rhvjAY++HrWjhVwUsIwac5BjtHUj1j8wWCoyOaz4FyWX9GAxJoveXb5ln8eJ6 aDzFYS6CkjEPPWgmWRkA7BRaPwlZHInKiBp/yNbP4GoCKQLfnd8gPc5zZQmbA6uMa5oR +Fl+0qq2jO/C3Ab6oyxDXXd+qH1Ve4ue7FtsOagDa2MMCwloJ7qcx8iDFhjLB6MJtZY6 z1Rk/ftlB1fZxkgTjEgJgb4vQNGqUFpu71nVezyPaukDR0UwK/uhPmLIND6bwD6hdMnY 6lgFC1xwFC8S0mqV2PfekClvWmeK4/Vn2RfU0cMVccl/zKumWdSlXoCXQedQjy/K0cPk mB8A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-language :content-transfer-encoding:mime-version:user-agent:date:message-id :subject:from:cc:to; bh=n1ho0vSYEdbtW8ms78AbiJcA2Erm/RvyrTB76ENjvi8=; b=D9d/z1+ZhPhWZMDDnFb1oPEE7tjwvM9wPHSixqinJ6ZyCdlwu8ljtV2urtsnbiLWGQ 2MlSSI5Z59NJACULBiwCvD+zsGvhMF9pjTbIo110xAWGimIyd0kha6qg/zz+DThu40Mg q/lUz+ppWSNofi6t3lxFxQCiyWwOX/AvK6B4MXc2qEXPf0k8MEF6kekeolYDMSdHlIkI N1SiToXRr7LkHnHKyNWphfqtXL8vqZSDD8ReEVrWga+iyzN5V2trSmaSIgl6vfhrZy9K A2Hz0Y8YqwdRjQadKiNMLoS98aQOwKAe+ozAViuWINhQlR7YEFNqoXhHxEZ29l3Z90Sw FfAQ== ARC-Authentication-Results: i=1; mx.google.com; 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=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id n4si32674131pgd.10.2019.01.03.01.53.16; Thu, 03 Jan 2019 01:53:31 -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; 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=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730008AbfACHgI (ORCPT + 99 others); Thu, 3 Jan 2019 02:36:08 -0500 Received: from mga17.intel.com ([192.55.52.151]:37686 "EHLO mga17.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726036AbfACHgH (ORCPT ); Thu, 3 Jan 2019 02:36:07 -0500 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga007.jf.intel.com ([10.7.209.58]) by fmsmga107.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 02 Jan 2019 23:36:07 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.56,434,1539673200"; d="scan'208";a="103571346" Received: from rfried-ivm1.ger.corp.intel.com (HELO [10.185.130.184]) ([10.185.130.184]) by orsmga007.jf.intel.com with ESMTP; 02 Jan 2019 23:36:05 -0800 To: linus.walleij@linaro.org, bgolaszewski@baylibre.com, linux-gpio@vger.kernel.org Cc: linux-kernel@vger.kernel.org, vladimir.kondratiev@linux.intel.com From: "Fried, Ramon" Subject: RFC: gpio: mmio: add support for 3 direction regs Message-ID: <32edfd70-95dc-26a1-2ea6-143344cb2384@linux.intel.com> Date: Thu, 3 Jan 2019 09:36:04 +0200 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:60.0) Gecko/20100101 Thunderbird/60.3.3 MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit Content-Language: en-US Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi. I'm working on a driver for STA2X11 GPIO controller who seems to fit best to the generic mmio driver, the only problem I have is with the dir register case. The STA2X11 has 3 registers for dir, one for data, one for set and one for clear. The generic-mmio driver has support for this fashion for the dat & set & clear registers but not for dirout/dirin registers. I wonder if support for this is generic enough to deserve a patch, if so I'm willing to quickly add this support, if not, adding a flag such as below, will allow partly using the generic mmio driver only for set/get and the direction can be handled outside the driver. Thanks, Ramon diff --git a/include/linux/gpio/driver.h b/include/linux/gpio/driver.h index a4d5eb3..4f91526 100644 --- a/include/linux/gpio/driver.h +++ b/include/linux/gpio/driver.h @@ -435,6 +435,7 @@ int bgpio_init(struct gpio_chip *gc, struct device *dev,  #define BGPIOF_BIG_ENDIAN_BYTE_ORDER   BIT(3)  #define BGPIOF_READ_OUTPUT_REG_SET     BIT(4) /* reg_set stores output value */  #define BGPIOF_NO_OUTPUT               BIT(5) /* only input */ +#define BGPIOF_NO_DIRECTION            BIT(6)    #endif diff --git a/drivers/gpio/gpio-mmio.c b/drivers/gpio/gpio-mmio.c index 935292a..66f6448 100644 --- a/drivers/gpio/gpio-mmio.c +++ b/drivers/gpio/gpio-mmio.c @@ -554,6 +554,8 @@ static int bgpio_setup_direction(struct gpio_chip *gc,                 gc->direction_input = bgpio_dir_in;                 gc->get_direction = bgpio_get_dir;                 gc->bgpio_dir_inverted = true; +       } else if (flags & BGPIOF_NO_DIRECTION) { +               return 0;         } else {                 if (flags & BGPIOF_NO_OUTPUT)                         gc->direction_output = bgpio_dir_out_err; @@ -638,7 +640,7 @@ int bgpio_init(struct gpio_chip *gc, struct device *dev,         if (gc->set == bgpio_set_set &&                         !(flags & BGPIOF_UNREADABLE_REG_SET))                 gc->bgpio_data = gc->read_reg(gc->reg_set); -       if (gc->reg_dir && !(flags & BGPIOF_UNREADABLE_REG_DIR)) +       if (gc->reg_dir && !(flags & (BGPIOF_UNREADABLE_REG_DIR | BGPIOF_NO_DIRECTION)))                 gc->bgpio_dir = gc->read_reg(gc->reg_dir);           return ret;