Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp6886074imu; Wed, 14 Nov 2018 08:24:09 -0800 (PST) X-Google-Smtp-Source: AJdET5cuS6bMEENAAF0S9Kk2MDEKA0OXZvXrZZl36Gd/aYdcjsCTzAu100G2cSEsrTQpJAWyNZ0d X-Received: by 2002:a17:902:29e3:: with SMTP id h90-v6mr2625495plb.158.1542212649427; Wed, 14 Nov 2018 08:24:09 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1542212649; cv=none; d=google.com; s=arc-20160816; b=vaZ2F8CW++LNrhLAdh6bOQzxqpRpVEGpP3aYhxi0f9p+isIBE+4UQRsiE2X58zg4EF lBiUwGe+rLw+naDIpjAFeHW2b3ShSte6px82Hse9RUCnQgvidyHE0Jpq4ZqbZGPuleOY 7tVF3+W+XGyZ6hToRP7cO8XoDP1LCexh4wnDYYwztqsOz3wEMPDvbNVs5xC2rZXpwGgP RlbKLOzyNhgzvVjt+fccCIDXKpzzf3IWhk3/KFoyFq8eHwPIaMyVp22QssFhNBK8lfE8 RAFg5nu404k5w0kAtKLLhH/CqmMMTO+eG86qI6BE9eZ0WcCgmfkhwU2sVi9kD1esuKk6 bZyw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:date:cc:to:from:subject :message-id; bh=nGIgYDsBTScxABAdHKnjn1XeGd7GwO3OSrvxsId/Mqw=; b=Y0r0klJ8xawFf5nexfK8BJwnpBVLAsyYh8jaJcZ+tUaU5nMsJY83Z4SxTVJD7DOlbc JjHSaiS1rO2w+b3sDAEkP3vTyCi4l5oPDy3PyL7/bCow4Af+FOaexM7VO5ISwk0gEzYI yn6iNKiL7aV6iI4rHDQS9HVAsqbeM/dOp+b0JZ0R05+2R7xmXa/+pOXsS1krQqpdyuWy MXolTufzdfKt+zStyJ1jp1l9EhXmJ4Yno9aJRU+zbeTOVzvfZ8uNM1KGgxejjiqH1PO7 8K/9DhHO1SYKNoTYCWeOEr9E1H7UBHiwHGwDmSdXkCYKNsOoLK64C1itEB3xXfdlJh6Z xyQw== 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 t16-v6si24978398plr.352.2018.11.14.08.23.53; Wed, 14 Nov 2018 08:24:09 -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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732840AbeKOCZc (ORCPT + 99 others); Wed, 14 Nov 2018 21:25:32 -0500 Received: from shell.v3.sk ([90.176.6.54]:45372 "EHLO shell.v3.sk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725828AbeKOCZc (ORCPT ); Wed, 14 Nov 2018 21:25:32 -0500 Received: from localhost (localhost [127.0.0.1]) by zimbra.v3.sk (Postfix) with ESMTP id F3D1A43CFB; Wed, 14 Nov 2018 17:21:29 +0100 (CET) Received: from shell.v3.sk ([127.0.0.1]) by localhost (zimbra.v3.sk [127.0.0.1]) (amavisd-new, port 10032) with ESMTP id w3KKM50QNgrV; Wed, 14 Nov 2018 17:21:03 +0100 (CET) Received: from localhost (localhost [127.0.0.1]) by zimbra.v3.sk (Postfix) with ESMTP id 272CC43D39; Wed, 14 Nov 2018 17:21:02 +0100 (CET) X-Virus-Scanned: amavisd-new at zimbra.v3.sk Received: from shell.v3.sk ([127.0.0.1]) by localhost (zimbra.v3.sk [127.0.0.1]) (amavisd-new, port 10026) with ESMTP id X85xjcFleULv; Wed, 14 Nov 2018 17:20:57 +0100 (CET) Received: from belphegor (nat-pool-brq-t.redhat.com [213.175.37.10]) by zimbra.v3.sk (Postfix) with ESMTPSA id 6BAE043CEC; Wed, 14 Nov 2018 17:20:56 +0100 (CET) Message-ID: Subject: Re: [PATCH 08/15] Platform: OLPC: Move EC-specific functionality out from x86 From: Lubomir Rintel To: Andy Shevchenko Cc: Mark Brown , Geert Uytterhoeven , Darren Hart , Andy Shevchenko , Greg Kroah-Hartman , quozl@laptop.org, Sebastian Reichel , Rob Herring , Mark Rutland , Eric Miao , Haojian Zhuang , Daniel Mack , Robert Jarzmik , linux-spi , devicetree , Linux Kernel Mailing List , linux-arm Mailing List , Platform Driver , devel@driverdev.osuosl.org, Linux PM Date: Wed, 14 Nov 2018 17:20:53 +0100 In-Reply-To: References: <20181010172300.317643-1-lkundrak@v3.sk> <20181010172300.317643-9-lkundrak@v3.sk> Content-Type: text/plain; charset="UTF-8" User-Agent: Evolution 3.30.2 (3.30.2-2.fc29) Mime-Version: 1.0 Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hello, On Fri, 2018-10-19 at 16:36 +0300, Andy Shevchenko wrote: > On Wed, Oct 10, 2018 at 8:24 PM Lubomir Rintel > wrote: > > It is actually plaform independent. Move it to the olpc-ec driver > > from > > the X86 OLPC platform, so that it could be used by the ARM based > > laptops > > too. > > What is platform independent exactly? The commands with their argument and responses are mostly the same, but the delivery mechanism is different (SPI on ARM vs. LPC on x86). Notably, the driver for the OLPC battery (which is the same on all XO generations) builds on the API provided by the olpc-ec driver. I'll try to extend the commit message to make this clear. > > #define OLPC_F_PRESENT 0x01 > > #define OLPC_F_DCON 0x02 > > -#define OLPC_F_EC_WIDE_SCI 0x04 > > I think these lines grouped on purpose. Thus, I don't like this. > Either move either all or none. I'm not moving this -- I'm removing it and using the EC version instead. This flag doesn't make sense for non-x86 ECs -- they don't use SCIs to deliver EC-to-CPU communication, but initiate SPI transactions instead. > > > +int olpc_ec_mask_write(u16 bits) > > +{ > > #ifdef CONFIG_DEBUG_FS > > > > /* > > @@ -277,14 +369,17 @@ static int olpc_ec_probe(struct > > platform_device *pdev) > > ec_priv = ec; > > platform_set_drvdata(pdev, ec); > > > > + /* EC version 0x5f adds support for wide SCI mask */ > > + if (ec->version >= 0x5f) { > > + __be16 ec_word = cpu_to_be16(bits); > > + > > + return olpc_ec_cmd(EC_WRITE_EXT_SCI_MASK, (void *) > > &ec_word, 2, > > + NULL, 0); > > I would leave it on one line. Okay. I do agree this looks better, but was not sure how seriously to take checkpatch.pl's warnings. > > > + } else { > > + unsigned char ec_byte = bits & 0xff; > > You may noticed that the parameter is of type u8, which clearly makes > & 0xff part redundant. At least for me, the explicit mask makes this easier for me to read. But I don't mind really. If you'd really like to see this changes I can follow up with such change (or am happy to ack such change from you). > > > + return olpc_ec_cmd(EC_WRITE_SCI_MASK, &ec_byte, 1, > > NULL, 0); > > + } > > +} > > +EXPORT_SYMBOL_GPL(olpc_ec_mask_write); > > I see that the above is inherited from older code, so, no need to > address those comments in here, but consider a follow up fix. > > > > +int olpc_ec_sci_query(u16 *sci_value) > > +{ > > +} > > +EXPORT_SYMBOL_GPL(olpc_ec_sci_query); > > Similar comments are applied here. > > > + > > - err = ec_driver->probe ? ec_driver->probe(pdev) : 0; > > + /* get the EC revision */ > > + err = olpc_ec_cmd(EC_FIRMWARE_REV, NULL, 0, > > + (unsigned char *) &ec->version, 1); > > Perhaps version should be defined as u8. Yes. > > +/* SCI source values */ > > +#define EC_SCI_SRC_EMPTY 0x00 > > +#define EC_SCI_SRC_GAME 0x01 > > +#define EC_SCI_SRC_BATTERY 0x02 > > +#define EC_SCI_SRC_BATSOC 0x04 > > +#define EC_SCI_SRC_BATERR 0x08 > > +#define EC_SCI_SRC_EBOOK 0x10 /* XO-1 only */ > > +#define EC_SCI_SRC_WLAN 0x20 /* XO-1 only */ > > +#define EC_SCI_SRC_ACPWR 0x40 > > +#define EC_SCI_SRC_BATCRIT 0x80 > > +#define EC_SCI_SRC_GPWAKE 0x100 /* XO-1.5 only */ > > BIT() ? > > > +#define EC_SCI_SRC_ALL 0x1FF > > GENMASK()? Yes. I meant to move this, but it turns out I've left the original ones in place. Will fix them in a follow-up commit also. Lubo