Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1031157AbbD2Atd (ORCPT ); Tue, 28 Apr 2015 20:49:33 -0400 Received: from mail-qc0-f172.google.com ([209.85.216.172]:33646 "EHLO mail-qc0-f172.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1031346AbbD2At0 (ORCPT ); Tue, 28 Apr 2015 20:49:26 -0400 MIME-Version: 1.0 In-Reply-To: <554016A5.7040209@imgtec.com> References: <1428435862-14354-1-git-send-email-abrestic@chromium.org> <1428435862-14354-3-git-send-email-abrestic@chromium.org> <554016A5.7040209@imgtec.com> Date: Tue, 28 Apr 2015 17:49:25 -0700 X-Google-Sender-Auth: fmvQGjxSiHCSaMiMeckilmMkLqo Message-ID: Subject: Re: [PATCH V3 2/2] pinctrl: Add Pistachio SoC pin control driver From: Andrew Bresticker To: Ezequiel Garcia Cc: Linus Walleij , Alexandre Courbot , Ralf Baechle , "devicetree@vger.kernel.org" , "linux-gpio@vger.kernel.org" , Linux-MIPS , "linux-kernel@vger.kernel.org" , James Hartley , James Hogan , Damien Horsley , Govindraj Raja , Kevin Cernekee , Paul Bolle Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2606 Lines: 65 On Tue, Apr 28, 2015 at 4:24 PM, Ezequiel Garcia wrote: > Andrew, > > On 04/07/2015 04:44 PM, Andrew Bresticker wrote: > [..] >> +static int pistachio_pinmux_enable(struct pinctrl_dev *pctldev, >> + unsigned func, unsigned group) >> +{ >> + struct pistachio_pinctrl *pctl = pinctrl_dev_get_drvdata(pctldev); >> + const struct pistachio_pin_group *pg = &pctl->groups[group]; >> + const struct pistachio_function *pf = &pctl->functions[func]; >> + struct pinctrl_gpio_range *range; >> + unsigned int i; >> + u32 val; >> + >> + if (pg->mux_reg > 0) { >> + for (i = 0; i < ARRAY_SIZE(pg->mux_option); i++) { >> + if (pg->mux_option[i] == func) >> + break; >> + } >> + if (i == ARRAY_SIZE(pg->mux_option)) { >> + dev_err(pctl->dev, "Cannot mux pin %u to function %u\n", >> + group, func); >> + return -EINVAL; >> + } >> + >> + val = pctl_readl(pctl, pg->mux_reg); >> + val &= ~(pg->mux_mask << pg->mux_shift); >> + val |= i << pg->mux_shift; >> + pctl_writel(pctl, val, pg->mux_reg); >> + >> + if (pf->scenarios) { >> + for (i = 0; i < pf->nscenarios; i++) { >> + if (pf->scenarios[i] == group) >> + break; >> + } >> + if (WARN_ON(i == pf->nscenarios)) >> + return -EINVAL; >> + >> + val = pctl_readl(pctl, pf->scenario_reg); >> + val &= ~(pf->scenario_mask << pf->scenario_shift); >> + val |= i << pf->scenario_shift; >> + pctl_writel(pctl, val, pf->scenario_reg); >> + } >> + } >> + >> + range = pinctrl_find_gpio_range_from_pin(pctl->pctldev, group); >> + if (range) >> + gpio_disable(gc_to_bank(range->gc), group - range->pin_base); >> + > > If you plan to submit a v4, how about using "pg->pins" here instead of "group"? > > Using "group" relies on having the same numberspace for the group and the pin, > and it'll break when introducing the RPU pinctrl. Sure, will do. -Andrew -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/