From patchwork Mon Jan 28 18:04:21 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jerome Brunet X-Patchwork-Id: 156827 Delivered-To: patch@linaro.org Received: by 2002:a02:48:0:0:0:0:0 with SMTP id 69csp3720569jaa; Mon, 28 Jan 2019 10:05:49 -0800 (PST) X-Google-Smtp-Source: ALg8bN432IxauLt80Szpo9ws4nzpAY+Qkpqp/BNMqF+2B1Me5ONO1GyV1PTZI7+rt1CEhUZqx0Ew X-Received: by 2002:a17:902:f20d:: with SMTP id gn13mr21847129plb.11.1548698749617; Mon, 28 Jan 2019 10:05:49 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1548698749; cv=none; d=google.com; s=arc-20160816; b=SNYs5qRFDYM5K09pJ1g43tqmMiKW5wmfc6sFjPKJ6SvIQ4+gdbF3vyX+FgXHs6qZn0 d7aCVSpkiFbqwu/qbiBcIl1Gjl/awCLjCuUjbHA83BYL/5U0LfLh8wCWmtvofGqaIqCT 2bGRvOt4moYq3XeuXBp0pr7NaZISmroyCJHD2eZtfjAu+Gfn19UufvVISIYjraj6TMm1 tNgqY6yYedYb5ScTJGQP1NTrULW2J0LPWwuDkC/HSGIp2KRB+5VvMT9IIQi9ApUDQ/Cb rc1ARHY97IcNQr0SS2iDMrItYLxkL1JO6WqITkHBgQpPOiTDbUpY1nMPtZ216Cl7hl15 4PbA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=tFsiSEWNipF5j/nl4GiByTeXt6gTIo/QNa1h8WqspDA=; b=UZ/QvmZbz5vsLNKQvOQUSBbF6TPM3pqdFib9eJMS/JqJvnkny2eH5QDLy2Sq1PQJiT wjf5YagoCTGswGiTyEmr6CcPH5A+1rlvH+RvmBKQcOLQ8yFEwu+6HTnzu8GzDPc09UC8 VGHrdng5hp8IqZTXo9M11CbD6e/u5ic5EKoStSA8ddBZf8hzXqDNv+k8swwUeJAsplga 9R0/tbXAka9RpTCRkHYg646HUQGloF/alM7mG+eQiAwQ3YIuDGeLAIt+DtfYLQh9mEqG KkkdQEkx2pL1/5miH5z8PI8JnoFoE+dBnoQQJhyQWZmKmqaTqmr3QaqwcDy0Zq+1b3GU 34dw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@baylibre-com.20150623.gappssmtp.com header.s=20150623 header.b=s9fk6aav; 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 193si17520857pfa.256.2019.01.28.10.05.49; Mon, 28 Jan 2019 10:05:49 -0800 (PST) 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=@baylibre-com.20150623.gappssmtp.com header.s=20150623 header.b=s9fk6aav; 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 S1727201AbfA1SE6 (ORCPT + 31 others); Mon, 28 Jan 2019 13:04:58 -0500 Received: from mail-wr1-f65.google.com ([209.85.221.65]:43532 "EHLO mail-wr1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727110AbfA1SEv (ORCPT ); Mon, 28 Jan 2019 13:04:51 -0500 Received: by mail-wr1-f65.google.com with SMTP id r10so19098266wrs.10 for ; Mon, 28 Jan 2019 10:04:50 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=tFsiSEWNipF5j/nl4GiByTeXt6gTIo/QNa1h8WqspDA=; b=s9fk6aav/smNqwREMwe6B+H4p5UdpW7nkEjbAL+Fcun3b3/M+kxgDzUZDHB3ffeOrx SFY8xMWPuBg5lUGBFx2dw3beHsXwoLCQiEGgHMFCiTluBkwSDbD9qn0oSb4B05vWuvXH jerhvW/yMoT7ft++LPY2mGXSfES2aqAYXgxqD7zoZK3P+/ChKfDFXwdm1uEG/dE9Trgp 3nclpK6SIjyYBqOCwJNiRPtPrbaVe1lnGN9a5YZHm9kxBkGKa0zZTUpPBCrdGTsbMxx0 xW7MlWlrFCM7kRZxRiwfvRWNiznZSEGDAjU7hWP52YunjJPKBx3kDY51aXIjP4JGKkt9 eAmA== 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=tFsiSEWNipF5j/nl4GiByTeXt6gTIo/QNa1h8WqspDA=; b=e2pteOSe6V7MQQT0PJ7xbhaIZO73wG7EGMn7XmbZDDx3lSltXBxgSIlPke9vm2DbQX xaWiJBMaalQqtt3forSYAhnPDt3aK8ygR1I37pjNbE+RdbUkn3VXfXBE2zxkRI5lbliX IwA8Fc//ONNqivyg81MV6LvOqmsIwGXnj4/u7o7uG1d9/Pz8ub5bhnyftDBCbcRvPTrn QHeRon9na/VUdcrvjviC14Y1IF+jP+Li5nU4HIf/L5s6plbru+cWwlcGO1IAneTjV0hc 4bJ2SRvCdghehd69E6c2W5Ib5Ni/Nsut8KjgDyz/hM0j4OlOPu9EHEOHIIqAyij9XYp6 AmPg== X-Gm-Message-State: AJcUukc2Yfk52FPbWL+3GkoQri5KbBlDr7m/9UKP68NEh75huthim4V/ s1te5naRhWHKtn4EUNyuYwXkdA== X-Received: by 2002:a5d:6647:: with SMTP id f7mr22600942wrw.225.1548698689917; Mon, 28 Jan 2019 10:04:49 -0800 (PST) Received: from boomer.local ([2a01:e34:eeb6:4690:106b:bae3:31ed:7561]) by smtp.googlemail.com with ESMTPSA id p6sm145548193wrx.50.2019.01.28.10.04.48 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 28 Jan 2019 10:04:49 -0800 (PST) From: Jerome Brunet To: Neil Armstrong , Stephen Boyd , Michael Turquette Cc: Jerome Brunet , Kevin Hilman , linux-kernel@vger.kernel.org, linux-clk@vger.kernel.org, linux-amlogic@lists.infradead.org, linux-arm-kernel@lists.infradead.org Subject: [PATCH 05/14] clk: meson: move parm out of clkc Date: Mon, 28 Jan 2019 19:04:21 +0100 Message-Id: <20190128180430.28689-6-jbrunet@baylibre.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190128180430.28689-1-jbrunet@baylibre.com> References: <20190128180430.28689-1-jbrunet@baylibre.com> MIME-Version: 1.0 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Signed-off-by: Jerome Brunet --- drivers/clk/meson/clkc.h | 34 +---------------------------- drivers/clk/meson/parm.h | 46 ++++++++++++++++++++++++++++++++++++++++ 2 files changed, 47 insertions(+), 33 deletions(-) create mode 100644 drivers/clk/meson/parm.h -- 2.20.1 diff --git a/drivers/clk/meson/clkc.h b/drivers/clk/meson/clkc.h index 35768c2327ba..58a343fa94e6 100644 --- a/drivers/clk/meson/clkc.h +++ b/drivers/clk/meson/clkc.h @@ -9,39 +9,7 @@ #include #include "clk-regmap.h" - -#define PMASK(width) GENMASK(width - 1, 0) -#define SETPMASK(width, shift) GENMASK(shift + width - 1, shift) -#define CLRPMASK(width, shift) (~SETPMASK(width, shift)) - -#define PARM_GET(width, shift, reg) \ - (((reg) & SETPMASK(width, shift)) >> (shift)) -#define PARM_SET(width, shift, reg, val) \ - (((reg) & CLRPMASK(width, shift)) | ((val) << (shift))) - -#define MESON_PARM_APPLICABLE(p) (!!((p)->width)) - -struct parm { - u16 reg_off; - u8 shift; - u8 width; -}; - -static inline unsigned int meson_parm_read(struct regmap *map, struct parm *p) -{ - unsigned int val; - - regmap_read(map, p->reg_off, &val); - return PARM_GET(p->width, p->shift, val); -} - -static inline void meson_parm_write(struct regmap *map, struct parm *p, - unsigned int val) -{ - regmap_update_bits(map, p->reg_off, SETPMASK(p->width, p->shift), - val << p->shift); -} - +#include "parm.h" struct pll_params_table { u16 m; diff --git a/drivers/clk/meson/parm.h b/drivers/clk/meson/parm.h new file mode 100644 index 000000000000..3c9ef1b505ce --- /dev/null +++ b/drivers/clk/meson/parm.h @@ -0,0 +1,46 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +/* + * Copyright (c) 2015 Endless Mobile, Inc. + * Author: Carlo Caione + */ + +#ifndef __MESON_PARM_H +#define __MESON_PARM_H + +#include +#include + +#define PMASK(width) GENMASK(width - 1, 0) +#define SETPMASK(width, shift) GENMASK(shift + width - 1, shift) +#define CLRPMASK(width, shift) (~SETPMASK(width, shift)) + +#define PARM_GET(width, shift, reg) \ + (((reg) & SETPMASK(width, shift)) >> (shift)) +#define PARM_SET(width, shift, reg, val) \ + (((reg) & CLRPMASK(width, shift)) | ((val) << (shift))) + +#define MESON_PARM_APPLICABLE(p) (!!((p)->width)) + +struct parm { + u16 reg_off; + u8 shift; + u8 width; +}; + +static inline unsigned int meson_parm_read(struct regmap *map, struct parm *p) +{ + unsigned int val; + + regmap_read(map, p->reg_off, &val); + return PARM_GET(p->width, p->shift, val); +} + +static inline void meson_parm_write(struct regmap *map, struct parm *p, + unsigned int val) +{ + regmap_update_bits(map, p->reg_off, SETPMASK(p->width, p->shift), + val << p->shift); +} + +#endif /* __MESON_PARM_H */ +