Received: by 2002:a05:6a10:9848:0:0:0:0 with SMTP id x8csp3373805pxf; Mon, 15 Mar 2021 08:12:26 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxwhWgrEG5fv/CEkMzwwn8IVJ2/1WgkH68LqgwTi/uE85uViM6Rbd7oMS79jxMiiATvQ5nP X-Received: by 2002:a17:906:b083:: with SMTP id x3mr12327457ejy.340.1615821146257; Mon, 15 Mar 2021 08:12:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1615821146; cv=none; d=google.com; s=arc-20160816; b=XjHSkPHohPgw+fF+pBkz/EBYtyBfDHUHJDMC0uY3uSqxOquiSutVwtENCZpe0vKs4n s6iHooBgoAJewaNBOJrYVs/zdEYnGjJM3KDYvUq3dU7gCVzxxMl7+J7hKF67YFnvLXy1 nEZxphPuGEXlDun93vEffQ6qUjDq1ZroBVa3vhygyMOND8PfHdRgdpYarAALn59xv+Im aa3DZZ5bL+B2ABev8MHRnjbN3zca5/i0hrm8Fj6tCNZTBN5r11X/EvQYfnPBE+foRRPi 3MplsuHLdxoZYXhlqltfR7AzOEYgcgkej5JVFvjzLPW3E00SjVpEphlTdC+jr1wH3HQr i6ww== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=ZKKaLOkrBz3/GtouDwoCOZ4KdSWppOkZ3d+IwHT4siU=; b=SeALJzcfS8o9hmUxzkk279iRuutkGzWz3cqa66P36Vd0LruwVVfQGPEi8Qw1DHfAY4 MWCmGWHY5AXWTUe27YvPvYq3eAxgKRb97o/Hzk1Ooj5UrkOpR6YTbRpF75NI4jq96k4L rw1XQQoysRbYdQKdQX4ihdK4TkC7lcHjnEVORyFgHZWEHmqjQPzCpQUZcs8VO9cXAFmX dNW7Gb0Hge6mxCec3YMpsRotVdC7X4df3gQE4mYhFxyiyWlc7R8UU0eX/KfYjjFcPdVD 1enKS7hv0QwdDLk0plLjNbD6Ri6fjtqY4XAYIalw+UDKqGGYZs+QSrDV0A7PcCLphb+Z UU7Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=c6eKxW5x; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id j5si10705178edy.408.2021.03.15.08.12.03; Mon, 15 Mar 2021 08:12:26 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=c6eKxW5x; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231183AbhCOPKr (ORCPT + 99 others); Mon, 15 Mar 2021 11:10:47 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59912 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231889AbhCOPKk (ORCPT ); Mon, 15 Mar 2021 11:10:40 -0400 Received: from mail-lj1-x22a.google.com (mail-lj1-x22a.google.com [IPv6:2a00:1450:4864:20::22a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3707BC06175F for ; Mon, 15 Mar 2021 08:10:40 -0700 (PDT) Received: by mail-lj1-x22a.google.com with SMTP id a1so16648429ljp.2 for ; Mon, 15 Mar 2021 08:10:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=ZKKaLOkrBz3/GtouDwoCOZ4KdSWppOkZ3d+IwHT4siU=; b=c6eKxW5xWF2yHUtA3SSpLusB0wRtKknAR/Nh5Tr2gXXnW44RK0sLvd+3h6Pz93DHNY w19hFNTgapAFNIKubbphTkJRAE6WEsngPV47qDO9cFouoUxk5Tvp9BGFJdOdZrmzON24 f3CoJSaBbg5BKn3HlofWSf/wJP5Q5X7y0oc9OVlbSrPzs+TZfazUn9F1N9s5lEpQ6Rk9 IxOin93qBmQgRxpjBvYq6CseUksefDrn58hpWGxrdLPXBrMLlb5BtCMtewlqhlgnNFld 77tzY1zS2wC0OoUy/or1jzRZzd0YBL+GYzvpbNGCH0VMuiivv3yqPkmII7SAsUDPaUdx UGJA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=ZKKaLOkrBz3/GtouDwoCOZ4KdSWppOkZ3d+IwHT4siU=; b=PXCpxHPON/UUPqIIc2AK2iZsEwef9lnEv/OON8tSo0xUmM71M6ijPxPklkjZrccczC /s3TZK9a6hqYVLcUkpNBS6ZhrH3Vy7Eq8+wRlR7kk0JhH0x6EhR5cRTR2CQbtLz6KFNV a2R2sJO+8CZrAYu3Opce0KxK5A0gAhUZ6h+sJGe27FUz7iFOuBpoZSifbjI/xaCB/l/o H0WJ2RAdqM+bcVtJd0Gtr9NdLn4YuMirSEieQgpVM7o1uCjKDXasQ6IdF0feP8J1TcV1 G6DZvSZ8fbxiNKm2T27ckwxHjZlgEI022BvXeFAtAnI4qyvX9T/NmarA00pMWTad79oN WeMA== X-Gm-Message-State: AOAM533pe0dDDvpCEWtUQeMm+Tp+i6kT1hzAnELhIDzr3VzRE6Zf1SE9 u3cVkm6cxjGYyJb4fRiqdOhZqB/WgRFVCCYEiOARgQ== X-Received: by 2002:a2e:864a:: with SMTP id i10mr10417943ljj.467.1615821038699; Mon, 15 Mar 2021 08:10:38 -0700 (PDT) MIME-Version: 1.0 References: <20210315082339.9787-1-sander@svanheule.net> <20210315082339.9787-3-sander@svanheule.net> In-Reply-To: <20210315082339.9787-3-sander@svanheule.net> From: Linus Walleij Date: Mon, 15 Mar 2021 16:10:27 +0100 Message-ID: Subject: Re: [PATCH 2/2] gpio: Add Realtek Otto GPIO support To: Sander Vanheule Cc: "open list:GPIO SUBSYSTEM" , "open list:OPEN FIRMWARE AND FLATTENED DEVICE TREE BINDINGS" , Bartosz Golaszewski , Rob Herring , Thomas Gleixner , Marc Zyngier , "linux-kernel@vger.kernel.org" , Bert Vermeulen Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Mar 15, 2021 at 9:26 AM Sander Vanheule wrote: > Realtek MIPS SoCs (platform name Otto) have GPIO controllers with up to > 64 GPIOs, divided over two banks. Each bank has a set of registers for > 32 GPIOs, with support for edge-triggered interrupts. > > Each GPIO bank consists of four 8-bit GPIO ports (ABCD and EFGH). Most > registers pack one bit per GPIO, except for the IMR register, which > packs two bits per GPIO (AB-CD). > > Although the byte order is currently assumed to have port A..D at offset > 0x0..0x3, this has been observed to be reversed on other, Lexra-based, > SoCs (e.g. RTL8196E/97D/97F). > > Interrupt support is disabled for the fallback devicetree-compatible > 'realtek,otto-gpio'. This allows for quick support of GPIO banks in > which the byte order would be unknown. In this case, the port ordering > in the IMR registers may not match the reversed order in the other > registers (DCBA, and BA-DC or DC-BA). > > Signed-off-by: Sander Vanheule Overall this is a beautiful driver and it makes use of all the generic frameworks I can think of. I don't see any reason not to merge it so: Reviewed-by: Linus Walleij The following is some notes and nitpicks, nothing blocking any merge, more like discussion. > +enum realtek_gpio_flags { > + GPIO_INTERRUPTS = BIT(0), > +}; I suppose this looks like this because more flags will be introduced when you add more functionality to the driver. Otherwise it seems like overkill so a bool would suffice. I would add a comment /* TODO: this will be expanded */ > +static inline u32 realtek_gpio_imr_bits(unsigned int pin, u32 value) > +{ > + return ((value & 0x3) << 2*(pin % 16)); > +} I would explain a bit about this, obviouslt it is two bit per line, but it took me some time to parse, so a comment about the bit layout would be nice. > + unsigned int offset = pin/16; Here that number appears again. The use of GPIO_GENERIC and GPIO irqchip is flawless and first class. Thanks! Linus Walleij