Received: by 2002:ac0:aa62:0:0:0:0:0 with SMTP id w31-v6csp154919ima; Sat, 20 Oct 2018 04:50:25 -0700 (PDT) X-Google-Smtp-Source: ACcGV63dusAp0Zjqv9e0yS93MgZJcJPgRMTIS5Wkn1Cz0JUcS7PooSCoFRLy38qVhaK+y1TIvW+x X-Received: by 2002:a17:902:5a2:: with SMTP id f31-v6mr9741471plf.320.1540036225150; Sat, 20 Oct 2018 04:50:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1540036225; cv=none; d=google.com; s=arc-20160816; b=gkuMwXQVcSB1ugQKKWC7gFgJq258D8rvw39OajIT3IN3S6bLjv19wE/NZUwBpnMknO FXogThkJRjIgDPsegFh/isM4+SkQ8+j2asC6w2urotjOomZu3b2aNTKKpC69VLxDEMcg qWej2qrHEm+RWksRaoHwHOIkTFospHb/b7MMxJlYZW67BAfpJ24zOk/cp3MGQoL2wP3S aCw+aRKB54YF9JRppmX7bqmhhT8YKsJg7LY9URh3Oy8PtiFLZHCYkXiclr99xF86JmES DfA62nSjaiH1QiSUE+84btghjzTFr+7x6NQ/mRENnS7s3z0fy5G71SqW+UXDhNbsx+8c qKaQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=SfU7trzytXEQgm48XveJPLclbMip892MyyjjV71tUP8=; b=sddGvA2SJjNdnuviCcJiaCnQjWOICLB/ePW/zUnWYsETK64l9ZIS35rMDn/fqoWCFa Gk04S6q461Kox57jTU0ueVKC/GFUBEIe+wYkphGBj1ZPeAZIbx8dDfE1D8g90C8WevTO hILKPv+c4X+Ow/QG6n7VM9T4F1N6PgDsCge9q4e2MbIdgPWw0pwl4FtfKDjScej8yDUb cUwlB+Jnwy/mCKv87VJAXOdkYjGp0Wx+IZ7WO0bnoj9I7mrrLLko7KW2SeczG6EoKaak MMxScBu7h7gAQhgPvAC4IxlVloD1h2j4YzGBFm5UPPXb4UwPjAae5B7/w92sSdihanh3 1uhg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=SKL0qWyR; 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=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id v3-v6si28599017pfd.125.2018.10.20.04.50.09; Sat, 20 Oct 2018 04:50:25 -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; dkim=pass header.i=@gmail.com header.s=20161025 header.b=SKL0qWyR; 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=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727470AbeJTT76 (ORCPT + 99 others); Sat, 20 Oct 2018 15:59:58 -0400 Received: from mail-qt1-f193.google.com ([209.85.160.193]:37705 "EHLO mail-qt1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727303AbeJTT76 (ORCPT ); Sat, 20 Oct 2018 15:59:58 -0400 Received: by mail-qt1-f193.google.com with SMTP id d14-v6so41287568qto.4; Sat, 20 Oct 2018 04:49:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=SfU7trzytXEQgm48XveJPLclbMip892MyyjjV71tUP8=; b=SKL0qWyR9JAvYMazbtshAYLsYIRDjdLHL+yYbptWVlBPii8D1YGJk5TYx+tN5idxpH Rwyc+XzqT7dlgpoS9i3p2TMyqYBwWJ1ibO8TULv6OPih0ocYA0ZvUhh4KSZFkOuTCPIH hhd3ljUnmPrlpNx1BMYI2/Z1PRjmkHeYYhbfGyhAWaY+u/MTWkoyowud6DoBk982+kb2 UPtcuR49531Wzfa14wPS5UCkFnNPnn5KUpOz93IsdnLyaYeLY9/1xVXedWGpltdFvftS IeOIkvo1JwyuKsvPzjATht3qsaYvUnrD7gCMuj2u6kIPGB3s0xerZWMPmtklJD9RfkNz pTLQ== 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=SfU7trzytXEQgm48XveJPLclbMip892MyyjjV71tUP8=; b=V2/YXtgeZntOUcOOe3W5xk2IWWFAxSq6/S5VwgCpgv5EvPYAsgqPqmjK0udcfzuola JqRuzhSR6Sp9KCvbO+kj4NiYYa7XUpZ5WVwDQH7GURRIcoUNk20svjD+ohc40SQUqWok 9jczrolgonNE0NWp/c7URmgHVsyjnGgAtDCNcIAMl/0RIa3zLiIgwJST+JWIQ5LCMaeG Md1K5Gs1BzhjmyCW8jLApcTWIvGHkdcpqkeC1mgmpMVxGkNa5fbcxAIuDjLEj/VUW2qK k0n6CSxXaFq4qP0nPqc16GPGJXH5nh3fYQY8wQmOhkX/QTpuTXsKalAOkUrXxbKHVk8h 82yw== X-Gm-Message-State: AGRZ1gLD5vW5bzAeE4iA23hTtBNo4b1zygT39m7SJKMrarSd8zlZvQ2T NGptI076AAqXqBGrjb1Re9m2ccGDXe4t4GvDruY= X-Received: by 2002:ac8:191a:: with SMTP id t26-v6mr4790985qtj.327.1540036185534; Sat, 20 Oct 2018 04:49:45 -0700 (PDT) MIME-Version: 1.0 References: <20180421085009.28773-1-javier@emutex.com> <1539969334-24577-1-git-send-email-dan@emutex.com> <1539969334-24577-2-git-send-email-dan@emutex.com> In-Reply-To: <1539969334-24577-2-git-send-email-dan@emutex.com> From: Andy Shevchenko Date: Sat, 20 Oct 2018 14:49:33 +0300 Message-ID: Subject: Re: [PATCH v2 1/3] mfd: upboard: Add UP2 platform controller driver To: "Dan O'Donovan" Cc: Linux Kernel Mailing List , Andy Shevchenko , Mika Westerberg , "Krogerus, Heikki" , Lee Jones , Linus Walleij , Jacek Anaszewski , Pavel Machek , "open list:GPIO SUBSYSTEM" , Linux LED Subsystem , carlos.iglesias@emutex.com, Javier Arteaga Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Oct 19, 2018 at 8:26 PM Dan O'Donovan wrote: > > From: Javier Arteaga > > UP Squared (UP2) is a x86 SBC from AAEON based on Intel Apollo Lake. It > features a MAX 10 FPGA that routes lines from both SoC and on-board > devices to two I/O headers: > > +------------------------+ > | 40-pin RPi-like header | > +------| (HAT) | > | +------------------------+ > +-------+ +--------+ > | | | | +------------------------+ > | SoC |----| FPGA |-----| Custom UP2 pin header | > | | | | | (EXHAT) | > +-------+ +--------+ +------------------------+ > | > +------* On-board devices: LED, VLS... > > This is intended to enable vendor-specific applications to customize I/O > header pinout, as well as include low-latency functionality. It also > performs voltage level translation between the SoC (1.8V) and HAT header > (3.3V). > > Out of the box, this block implements a platform controller with a > GPIO-bitbanged control interface. It's enumerated by ACPI and provides > registers to control: > > - Configuration of all FPGA-routed header lines. These can be driven > SoC-to-header, header-to-SoC or set in high impedance. > > - On-board LEDs and enable lines for other platform devices. > > Add core support for this platform controller as a MFD device, exposing > these registers as a regmap. Can we see a link to or an excerpt of ACPI table for this device? > +#define set_clear(u, x) gpiod_set_value((u)->clear_gpio, (x)) > +#define set_strobe(u, x) gpiod_set_value((u)->strobe_gpio, (x)) > +#define set_datain(u, x) gpiod_set_value((u)->datain_gpio, (x)) > +#define get_dataout(u) gpiod_get_value((u)->dataout_gpio) I think these macros don't bring much value. (Up to you and Lee to decide) > +static void __reg_io_write(const struct upboard_ddata * const ddata, > + unsigned int size, unsigned int val) > +{ > + int i; > + > + /* > + * DATAIN is latched on each rising edge of the STROBE signal. > + * Data (register address or value) is sent MSb first. > + */ > + for (i = size - 1; i >= 0; i--) { while (size--) > + set_strobe(ddata, 0); > + set_datain(ddata, (val >> i) & 0x1); > + set_strobe(ddata, 1); > + } > +} > + > +static void __reg_io_read(const struct upboard_ddata * const ddata, > + unsigned int size, unsigned int *val) > +{ > + int i; > + > + /* > + * DATAOUT is latched on on each rising edge of the STROBE signal. > + * Data (register value) is received MSb first. > + */ > + *val = 0; > + for (i = size - 1; i >= 0; i--) { Ditto. > + set_strobe(ddata, 0); > + set_strobe(ddata, 1); > + *val |= get_dataout(ddata) << i; > + } > +} > +static int upboard_check_supported(struct device *dev, struct regmap *regmap) > +{ > + uint8_t manufacturer_id, build, major, minor, patch; > + unsigned int platform_id, firmware_id; > + int ret; > + manufacturer_id = platform_id & 0xff; Redundant & 0xff part. > + if (manufacturer_id != AAEON_MANUFACTURER_ID) { > + dev_err(dev, > + "unsupported FPGA firmware from manufacturer 0x%02x", > + manufacturer_id); > + return -ENODEV; > + } > +static int upboard_match_device(struct device *dev) > +{ > + struct upboard_ddata *ddata = dev_get_drvdata(dev); > + const struct acpi_device_id *id; > + > + id = acpi_match_device(upboard_acpi_match, dev); > + if (!id) > + return -ENODEV; > + > + switch (id->driver_data) { device_get_match_data() IIRC the name of the call. > + case UPBOARD_ID_UP2: > + ddata->regmapconf = &upboard_up2_regmap_config; > + ddata->cells = upboard_up2_mfd_cells; > + ddata->ncells = ARRAY_SIZE(upboard_up2_mfd_cells); > + break; > + default: > + dev_err(dev, "unsupported ID %lu\n", id->driver_data); > + return -EINVAL; > + } > + > + return 0; > +} > + ret = upboard_init_gpio(dev); > + if (ret) { > + if (ret != -EPROBE_DEFER) > + dev_err(dev, "failed to init GPIOs: %d", ret); > + return ret; > + } I don't know if probe_err() helper is going to be a part of v4.21 (which this series targets), it would be good to use it. > +} -- With Best Regards, Andy Shevchenko