Received: by 2002:ac0:a5a7:0:0:0:0:0 with SMTP id m36-v6csp717871imm; Wed, 8 Aug 2018 04:41:23 -0700 (PDT) X-Google-Smtp-Source: AA+uWPyzMoVe7sUqZyUHh6D55FNaf3mru22vRJcnxV+iSBYQUDJhl/pul2Bt1F0g1EPPQT1kJROq X-Received: by 2002:a63:e811:: with SMTP id s17-v6mr2210249pgh.176.1533728483825; Wed, 08 Aug 2018 04:41:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1533728483; cv=none; d=google.com; s=arc-20160816; b=pr1K4SaBXRO2jWsD9VFOE/RGZ0WDx4VAuNo8ljcQpy2fhwWb/T0HbJLNXwIkzQnwVJ JKBHH/4vh6nkpne2m7epQdoPmP2r88kB7jOswg/7RxqBWI4uaRv0/AywvVyZM3toJmGM opeFKRpkepEU8n6ctxRBlRjKuYUMgGbQdk60ha0sKoR2HmAXLLunalWk3qxpD2CB5usI SGHcbLxeatD4WKXPtLviy1jyndPibQ+VVMz3LzfoWWeVWgcVW5u67SyFLLGjtkLfTxpX 7XK9pXUTUX+tq95d6ZTtToLhxqLz7gieXZAA2K7ozaBzpDG5sNdKOiIlWyLVNGJsTCsm 1xHQ== 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:arc-authentication-results; bh=f70b3hz1UVeO7thySfk6aklt8hwfz50QqJYwrxfKu8I=; b=NMA9FKtAQF0rFzbnQ8vnR1be8AZCY6FRdXsC39R4ca0O2wLpdzCarM5GrLcrAv4JKv owz0cj14/B8tdWqAp/fCPRLNasnuF9Zpqb+hFyFtkAoZvrx+jx7Vcta8ID12i3DXBt17 jYUryt6BEZMOADIxmjTmhLIIfx3m7UuL7cGH2lTwb1jHbYvA0fVhei1ykAlFB8XQgTsc bCZZdHSsdR55lP0N55RTJ2Qb8cfoZm4oP+CrDc1qN+cVuJWvtRt0hy9S8raoEp8N+PuM +z6onwXFgyrcoDfOFwYLHxfQ+75UnkAOOw13XH89bWqCzjVeC8+xOXWHsM+QlmHFGzuB 1UcA== 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 j17-v6si4357381pgk.517.2018.08.08.04.41.09; Wed, 08 Aug 2018 04:41:23 -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 S1727061AbeHHN7k (ORCPT + 99 others); Wed, 8 Aug 2018 09:59:40 -0400 Received: from relay8-d.mail.gandi.net ([217.70.183.201]:53703 "EHLO relay8-d.mail.gandi.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726733AbeHHN7j (ORCPT ); Wed, 8 Aug 2018 09:59:39 -0400 X-Originating-IP: 209.85.220.176 Received: from mail-qk0-f176.google.com (mail-qk0-f176.google.com [209.85.220.176]) (Authenticated sender: aditya@kobol.io) by relay8-d.mail.gandi.net (Postfix) with ESMTPSA id D79521BF207; Wed, 8 Aug 2018 11:40:19 +0000 (UTC) Received: by mail-qk0-f176.google.com with SMTP id c192-v6so1180127qkg.12; Wed, 08 Aug 2018 04:40:19 -0700 (PDT) X-Gm-Message-State: AOUpUlHgqVs/XYiRow8XfBl/15+q0R8lOW5I+zsEWyE4GfGje2kkGK2W 7p3/vQnLTswzG+oNijINv1j1TtCWWUqoRfgXHqU= X-Received: by 2002:a37:288d:: with SMTP id o13-v6mr1694155qko.205.1533728418781; Wed, 08 Aug 2018 04:40:18 -0700 (PDT) MIME-Version: 1.0 References: <1533522556-55055-1-git-send-email-aditya@kobol.io> <1533522556-55055-3-git-send-email-aditya@kobol.io> <20180806135257.GB6584@lunn.ch> In-Reply-To: <20180806135257.GB6584@lunn.ch> From: Aditya Prayoga Date: Wed, 8 Aug 2018 18:40:09 +0700 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH RESEND 2/2] gpio: mvebu: Allow to use non-default PWM counter To: andrew@lunn.ch Cc: linux-gpio@vger.kernel.org, richard.genoud@gmail.com, gregory.clement@bootlin.com, Gauthier Provost , alban.browaeys@gmail.com, thierry.reding@gmail.com, linus.walleij@linaro.org, linux-pwm@vger.kernel.org, linux-kernel@vger.kernel.org, Dennis Gilmore , ralph.sennhauser@gmail.com 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 Mon, Aug 6, 2018 at 8:53 PM Andrew Lunn wrote: > > On Mon, Aug 06, 2018 at 10:29:16AM +0800, Aditya Prayoga wrote: > > On multiple PWM lines, if the other PWM counter is unused, allocate it > > to next PWM request. The priority would be: > > 1. Default counter assigned to the bank > > 2. Unused counter that is assigned to other bank > > 3. Fallback to default counter > > > > For example on second bank there are three PWM request, first one would > > use default counter (counter B), second one would try to use counter A, > > and the third one would use counter B. > > Hi Aditya > > There are only two PWM counters for all the GPIO lines. So you cannot > support 3 PWM requests. You have to enforce a maximum of two PWMs. > > When i implemented this PWM code, i only needed one PWM. So it took > the easy option. GPIO bank 0 uses counter A, GPIO bank1 uses counter > B. For the hardware you have, this is not sufficient, so you need to > generalise this. Any PWM can use any counter, whatever is available > when the PWM is requested. Hi Andrew Understood. I will change it in next version. > Rather than have a linked list of PWM, i think it would be better to > have a static array of two mvebu_pwm structures. Index 0 uses counter > A, index 1 uses counter B. You can then keep with the concept of > pwm->pgiod != NULL means the counter is in use. The request() call can > then find an unused PWM, set pwm->gpiod, and point mvchip->mvpwm to > one of the two static instances. That was my initial idea to use static array but then I thought maybe I could generalise it for future device by using linked list. Regards, Aditya > > Andrew