From patchwork Wed Jun 12 19:59:00 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Martin Blumenstingl X-Patchwork-Id: 10990801 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 7149315E6 for ; Wed, 12 Jun 2019 20:00:50 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 52A79288DC for ; Wed, 12 Jun 2019 20:00:50 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 436E2287AB; Wed, 12 Jun 2019 20:00:50 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.2 required=2.0 tests=BAYES_00,DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED,DKIM_VALID,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED autolearn=unavailable version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id D962C287AB for ; Wed, 12 Jun 2019 20:00:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=B+2bnL1x26RJ27BP/LKTqRUUcZ1S0r1fMfCx+E+58S8=; b=ff95GPbtn5c4fT AgAVHZymD5Towu1wazedACE31+sZC5/WCabomzzw4f4Pbfqi33ib/JZP5QfmYmaZk0eIvhUh2DsgA h4dnT1tnv7F9RRhh0CwQ5bbKspEme+WxHCoN1M4fy3RntLdvZFgfXQJ4N5rKNIaezFg37jBmu+A7+ rfEy6Au4wIjmjw77eQUfRjcLzV3mnZO6Q3kyQDLjkbtL555DAfWhuS7LxpU43tzv5BSDtRf+rwpT0 sxvOImNyhkYyS08/kDnDHdDxEOHDBfmkinsUdJgtX3MSbTb3NjMTpGd9Mvmy97TOb/HC8ql2zHEvo TwGeAdrUZ8xcZMXKjCTQ==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.92 #3 (Red Hat Linux)) id 1hb9QL-0007G2-DV; Wed, 12 Jun 2019 20:00:45 +0000 Received: from mail-wr1-x444.google.com ([2a00:1450:4864:20::444]) by bombadil.infradead.org with esmtps (Exim 4.92 #3 (Red Hat Linux)) id 1hb9PE-0005GQ-7m; Wed, 12 Jun 2019 19:59:37 +0000 Received: by mail-wr1-x444.google.com with SMTP id d18so18220592wrs.5; Wed, 12 Jun 2019 12:59:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlemail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=KG5NgbEDvB0IWCaREHnEKhv/7oNCiEy8ooK1MlRzIPs=; b=CHleG6FA879in8tltHJpvsgIsf5EZHkqvpt/fkvG7bN3tzs+3eV9pxxdayzsj3bWPE 6phqQcl5xXzRfzen7XMRLmPQoqsw2FYntWAColSUhMZHk4WSuBEMlunBhNnY36o7AcRq WugutDifp774LpTT8xW7NZnh8Xm1iHcIvs9NgjqJAJ5UWz3qbqtUCq3lXXVPlnEODES7 MA7sWXkp/3NuDFYVD7GuA2NZEis7efWRa3g+InIacSbt0C9UxZusIzRT6xaJwL1T5F3k kgwnjIKVV+apPIiNxTmT+Iz73IjPY/4Is0TPkJCyKX4XPvFzts81bNm9C3UP5uItrcH9 Qjyg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=KG5NgbEDvB0IWCaREHnEKhv/7oNCiEy8ooK1MlRzIPs=; b=eY84RGCHcJE2TuGOWqxJpOAZ9t62ksw/V2TCs/doWKOQh+6JKKZ+TUTLKtQzzG7IJs myhEuqtbSBiBHlR3WeSHc2rp9EBEYliuVnq8qFEkvOOXAxfIOojEoJxdyZzV0Wfdr/f9 YAx9tqP4m7Pk7NusRzhwRy6pvHUDP8LPzyHP87veT3ugiZ4z5FRSfGO0vfo6Au5Nt/hJ oJu/322FEE9DHb64jqhiLAVljqcq/aCGNpPnWJ7VM4mbe3V21PhRF9wIHA3yr4E4SYX/ qKYe+JxrTw8qSATxk1qXow90Vt+IdMKDA7kFkGS2JLN3HJx9ZMehNeYG6QJCvw8TzNnn MPaQ== X-Gm-Message-State: APjAAAXn3xamqWxK7G8tsUb060A7lzhl5Q2maD2SMDoSt6cgk05o8nOX iBLsDDWFgEZigQDugSCqTidAK+Dk X-Google-Smtp-Source: APXvYqy/wh0jbkT+eAUNg4R4m3wc3iCjuVQTA417SP7ImsnL978LUI+5DY8GjJq0y4lA6mp22EcdFA== X-Received: by 2002:a5d:4bd0:: with SMTP id l16mr26414553wrt.141.1560369573815; Wed, 12 Jun 2019 12:59:33 -0700 (PDT) Received: from blackbox.darklights.net (p200300F133DDA400428D5CFFFEB99DB8.dip0.t-ipconnect.de. [2003:f1:33dd:a400:428d:5cff:feb9:9db8]) by smtp.googlemail.com with ESMTPSA id f10sm1026745wrg.24.2019.06.12.12.59.32 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Wed, 12 Jun 2019 12:59:33 -0700 (PDT) From: Martin Blumenstingl To: linux-amlogic@lists.infradead.org, linux-pwm@vger.kernel.org, thierry.reding@gmail.com Subject: [PATCH v3 03/14] pwm: meson: use GENMASK and FIELD_PREP for the lo and hi values Date: Wed, 12 Jun 2019 21:59:00 +0200 Message-Id: <20190612195911.4442-4-martin.blumenstingl@googlemail.com> X-Mailer: git-send-email 2.22.0 In-Reply-To: <20190612195911.4442-1-martin.blumenstingl@googlemail.com> References: <20190612195911.4442-1-martin.blumenstingl@googlemail.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20190612_125936_282353_F9335943 X-CRM114-Status: GOOD ( 11.89 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Martin Blumenstingl , narmstrong@baylibre.com, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, u.kleine-koenig@pengutronix.de Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP meson_pwm_calc() ensures that "lo" is always less than 16 bits wide (otherwise it would overflow into the "hi" part of the REG_PWM_{A,B} register). Use GENMASK and FIELD_PREP for the lo and hi values to make it easier to spot how wide these are internally. Additionally this is a preparation step for the .get_state() implementation where the GENMASK() for lo and hi becomes handy because it can be used with FIELD_GET() to extract the values from the register REG_PWM_{A,B} register. No functional changes intended. Reviewed-by: Neil Armstrong Reviewed-by: Uwe Kleine-König Signed-off-by: Martin Blumenstingl --- drivers/pwm/pwm-meson.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/drivers/pwm/pwm-meson.c b/drivers/pwm/pwm-meson.c index 35b38c7201c3..c62a3ac924d0 100644 --- a/drivers/pwm/pwm-meson.c +++ b/drivers/pwm/pwm-meson.c @@ -5,6 +5,8 @@ * Copyright (C) 2014 Amlogic, Inc. */ +#include +#include #include #include #include @@ -20,7 +22,8 @@ #define REG_PWM_A 0x0 #define REG_PWM_B 0x4 -#define PWM_HIGH_SHIFT 16 +#define PWM_LOW_MASK GENMASK(15, 0) +#define PWM_HIGH_MASK GENMASK(31, 16) #define REG_MISC_AB 0x8 #define MISC_B_CLK_EN BIT(23) @@ -217,7 +220,8 @@ static void meson_pwm_enable(struct meson_pwm *meson, struct pwm_device *pwm) value |= clk_enable; writel(value, meson->base + REG_MISC_AB); - value = (channel->hi << PWM_HIGH_SHIFT) | channel->lo; + value = FIELD_PREP(PWM_HIGH_MASK, channel->hi) | + FIELD_PREP(PWM_LOW_MASK, channel->lo); writel(value, meson->base + offset); value = readl(meson->base + REG_MISC_AB);