Received: by 2002:ac0:a5a7:0:0:0:0:0 with SMTP id m36-v6csp4622394imm; Tue, 7 Aug 2018 04:49:02 -0700 (PDT) X-Google-Smtp-Source: AAOMgpdoDuajtPwHMzc2Ifyq5YS4L4zSO98Z7GouwNZQs0SuT5epy1c9IjiGWLISJHx84uoHKC0B X-Received: by 2002:a62:778c:: with SMTP id s134-v6mr11331232pfc.189.1533642542215; Tue, 07 Aug 2018 04:49:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1533642542; cv=none; d=google.com; s=arc-20160816; b=SzLi8HRtJSCsU3knwT2SZi62QC2/JNT71is35E/kAcIP6I0oWHTtdgaciw3xiOsCVk fDg27StXwtk/fmtAhJhhht2qGHJeYMdJySN9AmzswXHtXCzcIHiPuxIIHyAJ+U39sYzl UkQsRraO1iAEY5LsV1ir4SX1WomCNIl9VO1kgwq1wzSwP5gD8u+tlbfLQliBDk9J/TUz UAiULViiEbldFgMl8nCAx6W2p+K1L3Y4TmOd83Us7pPkpWwVIrDLMGXPC3eL0mYJpOfS mBI37gW73HBpGPOuHZqdHKMPQPFzxRxjrPYChmXti6AA++e1WPWnMjg2k+0Wu+BjepXT g0qg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:message-id:references :in-reply-to:subject:cc:to:from:date:content-transfer-encoding :mime-version:arc-authentication-results; bh=x9wHFZaBE8LHl1hCr2cGPbi2/wsK0ksEcWi9aanRuss=; b=BwlRpHmerQLHJnSR6qP0WZ6qhYVcbuPPK71Mo9egdumKWIcnQ4xTLYNpNLt5NpgBwk jgg71fEgtYj5TyF4bi4SEvPHS4xPGU9/C/dt1GkaigYIwo+Bd9rKANXVvHcQuoem0QoV eLiXc/eUMlR/qCNnc2ZeEHOShau2WDBBqDJ9FVXS5WDT6X5BbbQzotqRBIxGzne7FbJD 2DBgSm2V7Y51owpUl/EQWiC1tbqWxdKYIMxZtkHvOySaxOffmeggwbPH3ChG2zmvUEMe 0IFDsmJbXlWT13O/V2iLna1m+PfsjO2sHs3YQqNCRXIiBTayDXYo3gfim+6yioduQ+Y3 LwQw== 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id ba10-v6si942082plb.228.2018.08.07.04.48.47; Tue, 07 Aug 2018 04:49:02 -0700 (PDT) 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2388392AbeHGOBW (ORCPT + 99 others); Tue, 7 Aug 2018 10:01:22 -0400 Received: from ms.tdt.de ([195.243.126.94]:56140 "EHLO mail.dev.tdt.de" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726902AbeHGOBW (ORCPT ); Tue, 7 Aug 2018 10:01:22 -0400 Received: from mail.dev.tdt.de (localhost [IPv6:::1]) by mail.dev.tdt.de (Postfix) with ESMTP id 13CC7207F9; Tue, 7 Aug 2018 11:47:23 +0000 (UTC) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit Date: Tue, 07 Aug 2018 13:47:22 +0200 From: Florian Eckert To: Andy Shevchenko Cc: "open list:GPIO SUBSYSTEM" , Linus Walleij , Linux Kernel Mailing List Subject: Re: [PATCH] gpio: Add driver for PC Engines APU2/APU3 GPIOs In-Reply-To: References: <20180801111243.2848-1-fe@dev.tdt.de> Message-ID: X-Sender: fe@dev.tdt.de User-Agent: Roundcube Webmail/1.1.5 X-Spam-Status: No, score=-1.0 required=5.0 tests=ALL_TRUSTED,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.0 X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on mail.dev.tdt.de Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 2018-08-03 21:08, Andy Shevchenko wrote: >> - APU2/APU3 -> front button reset support >> - APU3 -> SIM switch support > > Good. > Can we see some specification for those platforms? > I think the informations from Christian Lamparter are OK? >> + * GNU General Public License for more details >> + * >> + * You should have received a copy of the GNU General Public License >> + * along with this program; if not, see >> > > SPDX, please! I have already updated my patch in my git to use this identifier. // SPDX-License-Identifier: GPL-2.0 This was a hint from Linus Walleji > >> + */ > >> +#include >> +#include > > These both looks very strange in here. > On the front of the APU2/APU3 there is a SMD-push-button which is connected to one of the GPIOs. This is used as a reset button for the system (reboot/factory-reset). I am also not sure if this is the right place. But for the first review i thought this will be ok. The geode, the old board from PC-Engines added the key gpios to this file https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/arch/x86/platform/geode/alix.c#n47 mybe this is the right place too x86/platfrom/apu/apu.c? >> +#define APU_FCH_ACPI_MMIO_BASE 0xFED80000 >> +#define APU_FCH_GPIO_BASE (APU_FCH_ACPI_MMIO_BASE + 0x1500) > > Wow! Can we see ACPI tables for these boards? Care to share (via some > file share service) output of `acpidump -o tables.dat` ? > I have copied this from the leds-apu.c driver which is already upstream. https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/leds/leds-apu.c#n43 > >> +#define APU_GPIO_BIT_WRITE 22 >> +#define APU_GPIO_BIT_READ 16 >> +#define APU_GPIO_BIT_DIR 23 > > WR and RD looks shorter, > And please keep them sorted by value. Ok will fix this. > >> +#define APU_IOSIZE sizeof(u32) > > This is usual for x86 stuff, no need to have a definition, I think. Ok will fix this. >> +static unsigned long apu3_gpio_offset[APU3_NUM_GPIO] = { >> + APU_FCH_GPIO_BASE + 89 * APU_IOSIZE, //KEY >> + APU_FCH_GPIO_BASE + 90 * APU_IOSIZE, //SIM >> +}; >> +static void __iomem *apu3_gpio_addr[APU3_NUM_GPIO] = {NULL, NULL}; >> + > >> +static int gpio_apu_get_dir (struct gpio_chip *chip, unsigned offset) > > Style! We do not use space between func and its parameter list. > OK >> +{ >> + u32 val; >> + >> + spin_lock(&apu_gpio->lock); >> + > >> + val = ~ioread32(apu_gpio->addr[offset]); > > This is unusual (I mean ~). Better to leave IO alone and do bits > manipulations latter on. OK > >> + val = (val >> APU_GPIO_BIT_DIR) & 1; > > Do you need this under spin lock? > No i donĀ“t. Will fix this. Thanks >> + apu_gpio->chip->ngpio = ARRAY_SIZE(apu2_gpio_offset); >> + for( i = 0; i < ARRAY_SIZE(apu2_gpio_offset); i++) { >> + apu2_gpio_addr[i] = devm_ioremap(&pdev->dev, >> + apu_gpio->offset[i], >> apu_gpio->iosize); >> + if (!apu2_gpio_addr[i]) { >> + return -ENOMEM; >> + } >> + } >> + } > > The above should be part either as callback or driver_data of DMI > entries. I have copied this from the leds-apu.c driver https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/leds/leds-apu.c#n226 > >> + ret = gpiochip_add(&gpio_apu_chip); > > devm_ > What do you mean with "devm_"? >> + if (ret) { > >> + pr_err("Adding gpiochip failed\n"); > > dev_err(), but I consider this message completely useless. Thanks will remove this too. > >> + } > >> + >> + register_gpio_keys_polled(-1, 20, ARRAY_SIZE(apu_gpio_keys), >> apu_gpio_keys); >> + > > Not part of this driver. Remove. > As described above should this go to a file "apu.c" in the directory "apu" under https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/arch/x86/platform ? >> + return ret; >> +} > >> +module_init(apu_gpio_init); >> +module_exit(apu_gpio_exit); > > Consider to use module_platform_driver() and accompanying data > structures and functions. Ok thanks will update this Will update my patch with your hints thanks