From patchwork Thu Jan 3 07:36:04 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Ramon Fried X-Patchwork-Id: 1020183 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=vger.kernel.org (client-ip=209.132.180.67; helo=vger.kernel.org; envelope-from=linux-gpio-owner@vger.kernel.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=linux.intel.com Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 43VfqD6sK0z9s55 for ; Thu, 3 Jan 2019 18:36:08 +1100 (AEDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727208AbfACHgI (ORCPT ); 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-Language: en-US Sender: linux-gpio-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-gpio@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;