Received: by 2002:ac0:98c7:0:0:0:0:0 with SMTP id g7-v6csp4689723imd; Tue, 30 Oct 2018 06:06:42 -0700 (PDT) X-Google-Smtp-Source: AJdET5dXwcMlRKcbJi+iVLtm/H6SKSI4n0soFmf3pO9X9ZftzZCP/L9cPJNtd+EctHdq0nTmm9kJ X-Received: by 2002:a17:902:e81:: with SMTP id 1-v6mr18624574plx.48.1540904801930; Tue, 30 Oct 2018 06:06:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1540904801; cv=none; d=google.com; s=arc-20160816; b=Nc67TQFxL2XB1MpW9beOOx+X0DVmHd3VUNLD169Luy1nGIm8U6zq7Q7CShbHQndDH0 ul4r12TInrEquP9kh97i9uBPn5XbA5ieVuL0yHsiGhZPtJUMcQpRv8PuFfN68vWjZfTV PNesxh6VbzjyS2sfZu/+RBpiU0/T/i9ZPZ6gId6EpFf8swLuFnnMRJziAdf2zO9ixEeD rTqNn6INL5I6XxvGT5/rHVvSPNS9u+Pc0/7teeo1VudP8TpabyA8+X9+v5vXo8Wvyz6y KHjJ4NOa6iw0pzQLZM+/piurIzPYjvuzTIfw7gGSdqCqXM9ZDRDa7dK7Nqm2T5cdsRq/ AAHQ== 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=y3BUS53lzVMcPDlczJ3ucNN36+qQq8ngtOaDVAgo27Y=; b=WFvSy7/5qppNFbtNPDi4pQWHQteFnJH5pee3b3UcN5NXzwNIEMy09yQfzCqhlX+//O dNKA1qm6Gptusp+Uq1b98TPMOJZUFbjCcvfbVspA/loCGZp+wiUMCILWBa9E22M9klXK mU4G+KOOouyx952JPa1VsUZ2by26ZWgTzNkr4snXydvkjJF11cPBsME1Qqn01PaAQlua xcHQSIX9qswpF7HS7qcvLJo6SN7bNokswGPmoCewcPvAN9AjPWCxClfJ2X57PNW9Q+E1 e5w91v41d/q1YErmRqjGeEVHCM/NbPfZLqgvE6e2+rK4dMWpGWOV++sfALvs57pMrq+9 OXYA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=XOPmmUHt; 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=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id v6-v6si15764495pgv.565.2018.10.30.06.06.23; Tue, 30 Oct 2018 06:06:41 -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=@linaro.org header.s=google header.b=XOPmmUHt; 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=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727969AbeJ3V54 (ORCPT + 99 others); Tue, 30 Oct 2018 17:57:56 -0400 Received: from mail-lj1-f194.google.com ([209.85.208.194]:40177 "EHLO mail-lj1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727952AbeJ3V54 (ORCPT ); Tue, 30 Oct 2018 17:57:56 -0400 Received: by mail-lj1-f194.google.com with SMTP id t22-v6so11256264lji.7 for ; Tue, 30 Oct 2018 06:04:32 -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=y3BUS53lzVMcPDlczJ3ucNN36+qQq8ngtOaDVAgo27Y=; b=XOPmmUHt0rpmcq8gAQRnLIw2sRvaLqpdsnp/w7Qk/DQsaX4OM+jnEWlHy0tqkS26LZ GjtcZmJev//CE15OCXGR7cKXeDekk4gkAciQmhWMHjKZsmDB+2iD1XRZHzuCZp5YB8u8 58Bgx7veNBno0B8UfTzpalxGJodmldIT7Jn6E= 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=y3BUS53lzVMcPDlczJ3ucNN36+qQq8ngtOaDVAgo27Y=; b=ZxG3XCVt+Mcm0YU9g8UKujqB1KVluuAjjLPfAR4d7wFrmQC+LfPrhAtRZyoepo6zXO ay1gUtQWW1BTspHgiLOxBY4Cg+ZLHQWPDSXlbHNOUz6fWJzOZPP9zC72+901Vhpqq/Ym etSmCD3FeLtthRf/lIqBEMzRgsTkAUScj6ne+IrnP08Fs3LlpbUISvwxjOpz74ZEZoU/ prKnvyUvhHRb/N3Ct9z//86zfQqo+zo2NY8gtu53COfK7A9n/ZWXSfCAnBWyFyGrLilu 4+93OCIPbVX7LVEKNe/fdbSNYylNZLPpLTiikQNrN71eru0i4RYirTKXTIbb4x596S4W ZJRQ== X-Gm-Message-State: AGRZ1gIKHMwXOSH63ADxa4BetIHLe3qZLCo3Z3Rn2ZGBNFvalrBZ/Em1 iX5cP9w6pRQaA9tPfnhIPe+2mOJCyykaioAaqhUueQ== X-Received: by 2002:a2e:760a:: with SMTP id r10-v6mr12217157ljc.97.1540904671957; Tue, 30 Oct 2018 06:04:31 -0700 (PDT) MIME-Version: 1.0 References: <20181019095003.26046-1-ckeepax@opensource.cirrus.com> <20181019095003.26046-5-ckeepax@opensource.cirrus.com> In-Reply-To: <20181019095003.26046-5-ckeepax@opensource.cirrus.com> From: Linus Walleij Date: Tue, 30 Oct 2018 14:04:20 +0100 Message-ID: Subject: Re: [PATCH v3 5/5] pinctrl: lochnagar: Add support for the Cirrus Logic Lochnagar To: Charles Keepax Cc: Lee Jones , Michael Turquette , Stephen Boyd , Mark Brown , Rob Herring , Mark Rutland , Liam Girdwood , "open list:OPEN FIRMWARE AND FLATTENED DEVICE TREE BINDINGS" , "linux-kernel@vger.kernel.org" , patches@opensource.cirrus.com, linux-clk , "open list:GPIO SUBSYSTEM" 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 11:50 AM Charles Keepax wrote: > Lochnagar is an evaluation and development board for Cirrus > Logic Smart CODEC and Amp devices. It allows the connection of > most Cirrus Logic devices on mini-cards, as well as allowing > connection of various application processor systems to provide a > full evaluation platform. This driver supports the board > controller chip on the Lochnagar board. > > Lochnagar provides many pins which can generally be used for an > audio function such as an AIF or a PDM interface, but also as > GPIOs. > > Signed-off-by: Charles Keepax > --- > > Changes since v2: > - Updated aif-master/aif-slave to use a vendor prefix > - Correctly get and put of_node pointer in probe/remove Looks better and better! Some comments, probably not the last comments: > +#include > +#include > +#include > +#include > +#include > +#include > +#include > +#include > +#include > +#include #include > +struct lochnagar_aif { > + const char name[16]; > + > + unsigned int pins[4]; > + > + unsigned int src_reg; u32? > + unsigned int src_mask; u32? > + > + unsigned int ctrl_reg; u32? > + unsigned int ena_mask; u32? > + unsigned int master_mask; u32? > +struct lochnagar_func { > + const char * const name; > + > + enum lochnagar_func_type type; > + > + int op; unsigned int? u32? Looks like u8 actually. > +struct lochnagar_group { > + const char * const name; > + > + enum lochnagar_func_type type; > + > + const unsigned int *pins; > + int npins; unsigned int npins? > +struct lochnagar_func_groups { > + const char **groups; > + int ngroups; unsigned int ngroups? > +struct lochnagar_pin_priv { > + struct lochnagar *lochnagar; > + struct device *dev; > + > + const struct lochnagar_func *funcs; > + int nfuncs; > + > + const struct pinctrl_pin_desc *pins; > + int npins; > + > + const struct lochnagar_group *groups; > + int ngroups; > + > + struct lochnagar_func_groups func_groups[LN_FTYPE_COUNT]; > + > + struct gpio_chip gpio_chip; > +}; I bet some of these should be unsigned as well. > +static const struct pinconf_generic_params lochnagar_dt_params[] = { > + {"cirrus,aif-master", PIN_CONFIG_AIFMASTER, 0}, > + {"cirrus,aif-slave", PIN_CONFIG_AIFSLAVE, 0}, > +}; I guess these are documented in the device tree bindings. They look suspciously like muxing but I guess it is explained there. > +static void lochnagar_gpio_set(struct gpio_chip *chip, > + unsigned int offset, int value) > +{ > + struct lochnagar_pin_priv *priv = gpiochip_get_data(chip); > + struct lochnagar *lochnagar = priv->lochnagar; > + const struct lochnagar_pin *pin = priv->pins[offset].drv_data; > + int ret; > + > + value = !!value; value = value ? BIT(pin->shift) : 0; > + dev_dbg(priv->dev, "Set GPIO %s to %s\n", > + pin->name, value ? "high" : "low"); > + > + switch (pin->type) { > + case LN_PTYPE_MUX: > + value |= LN2_OP_GPIO; > + > + ret = lochnagar_pin_set_mux(priv, pin, value); > + break; > + case LN_PTYPE_GPIO: > + if (pin->invert) > + value = !value; > + > + ret = regmap_update_bits(lochnagar->regmap, pin->reg, > + 0x1 << pin->shift, BIT(pin->shift) > + value << pin->shift); Just value provided you used the construction above to construct it. Yours, Linus Walleij