Received: by 2002:a25:ab43:0:0:0:0:0 with SMTP id u61csp4234979ybi; Tue, 11 Jun 2019 03:18:06 -0700 (PDT) X-Google-Smtp-Source: APXvYqxg/YaG52balIx4cTFdvSqswTT+T+4WZ4NuoMbif+Puey541zMe2xFWYJ0DgmPQKKoJHNEm X-Received: by 2002:aa7:808d:: with SMTP id v13mr79158577pff.198.1560248286788; Tue, 11 Jun 2019 03:18:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1560248286; cv=none; d=google.com; s=arc-20160816; b=HeEZETXv8ou0pJpkCAHzbyUiBGwjk/5Gdb4B7ADw3rzKOKEH5RSlySMCKyLH21SzEj Q629oiUfjOFMiz4rry5FGtaKhBAwzE5VVdXCI4+whfVzj0opC2ESW1lwz1TOYrVG8ErU ii+3oCKkPF8ATZrT9RbHkl3OvuJA3MUB9SyHEDSh5nglvjFNbUdBh9KEA1jy5Ad+odz+ Z5TosP4i7WNXSWosivSt6L6wddK5jil6UDI7hx7ORK1EYu4wFe93ld87k21bAY2YBd11 eKnK0WOZx9kQOTvpTlw04jwliWCKCaB2xUJQpUHwziYs5SFQC5w/q7g6wq0Jiy0NOIb0 Xcgw== 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=9pbvgHxA8t2JI2sew7BfH9UJBwByFHrzzO6D9gMzS70=; b=ZW2iuZ/vrjWwKPfZISxnbUKAvDd+h0I+4igHBsGYR2qflSfCybudVLEFaVmmdarXyT tTJhScmDSv6LQKKNadGsZj+OXFFqxOn7oOKrEYSpzZRagXjnnq38BRQHcPkhUlZ+MW9N Gjxx+FP6Qm5skgAVvt3DLWGVZi6dwLnptiWmAagHT/2IL6U24dcWNCfG0pUonbCj7gP5 2D4RAKBAGAM3oRVjoMUYCezNW/gYi6mmdNxT7lq1/HXVUvB57RqzfUoTYCrDeyIyXZja R6ar+WX84snDMpPNI7JgAUb8Yj35XE3up0W/L2BTeqUjm6foW2Zonhh4rxlvAg1leERz B4og== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=eu2CxCBP; 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=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id k16si12515532pfk.68.2019.06.11.03.17.51; Tue, 11 Jun 2019 03:18:06 -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=@kernel.org header.s=default header.b=eu2CxCBP; 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=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2405409AbfFKKRg (ORCPT + 99 others); Tue, 11 Jun 2019 06:17:36 -0400 Received: from mail.kernel.org ([198.145.29.99]:46176 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2404766AbfFKKR1 (ORCPT ); Tue, 11 Jun 2019 06:17:27 -0400 Received: from wens.tw (mirror2.csie.ntu.edu.tw [140.112.30.76]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 9D03C2183F; Tue, 11 Jun 2019 10:17:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1560248245; bh=QrCB9F6TrRnxcZhPbN8ur0QRjMk8IvRHyFauXr/wPw4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=eu2CxCBP4khNbluILkaEj0j9ursd2BkEG49CrAI9+XYhAm/ZTd8r6mzQIUPWq/Qfs 6unYKWMlk2ra819Gf1YLQeHat2v9gjSYA8CtvAyCiYyOf6mx8U2jyfRgx15DLEJqld mw74DYsIkvxUE4gmXKrjKEUqe3oMqDg+KAaSBbT8= Received: by wens.tw (Postfix, from userid 1000) id A0A3360C95; Tue, 11 Jun 2019 18:17:18 +0800 (CST) From: Chen-Yu Tsai To: Maxime Ripard , Stephen Boyd , Michael Turquette Cc: Chen-Yu Tsai , linux-arm-kernel@lists.infradead.org, linux-clk@vger.kernel.org, linux-kernel@vger.kernel.org, Chen-Yu Tsai Subject: [PATCH v2 23/25] clk: sunxi-ng: gate: Add macros for referencing local clock parents Date: Tue, 11 Jun 2019 18:16:56 +0800 Message-Id: <20190611101658.23855-24-wens@kernel.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190611101658.23855-1-wens@kernel.org> References: <20190611101658.23855-1-wens@kernel.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Chen-Yu Tsai With the new clk parenting code, clk_init_data was expanded to include .parent_hws, for clk drivers to directly reference parents by clk_hw, and .parent_data, for clk drivers to specify parents using a combination of device tree clock-names, pointers to struct clk_hw, device tree clocks, and/or fallback global clock names. Add four new macros: - SUNXI_CCU_GATE_HW, that can take a struct clk_hw pointer, instead of a string, as its parent. - SUNXI_CCU_GATE_FW that takes a string to match a clock-names entry in the device tree to specify the clock parent. - SUNXI_CCU_GATE_HWS that takes an array of struct clk_hw * as its parent. This allows the array to be shared with other clk declarations. - SUNXI_CCU_GATE_DATA that takes an array of struct clk_parent_data * as its parent. This allows the array to be shared with other clk declarations. Acked-by: Maxime Ripard Signed-off-by: Chen-Yu Tsai --- drivers/clk/sunxi-ng/ccu_gate.h | 53 +++++++++++++++++++++++++++++++++ 1 file changed, 53 insertions(+) diff --git a/drivers/clk/sunxi-ng/ccu_gate.h b/drivers/clk/sunxi-ng/ccu_gate.h index 4466169bd2d7..613ddd03629e 100644 --- a/drivers/clk/sunxi-ng/ccu_gate.h +++ b/drivers/clk/sunxi-ng/ccu_gate.h @@ -36,6 +36,59 @@ struct ccu_gate { } \ } +#define SUNXI_CCU_GATE_HW(_struct, _name, _parent, _reg, _gate, _flags) \ + struct ccu_gate _struct = { \ + .enable = _gate, \ + .common = { \ + .reg = _reg, \ + .hw.init = CLK_HW_INIT_HW(_name, \ + _parent, \ + &ccu_gate_ops, \ + _flags), \ + } \ + } + +#define SUNXI_CCU_GATE_FW(_struct, _name, _parent, _reg, _gate, _flags) \ + struct ccu_gate _struct = { \ + .enable = _gate, \ + .common = { \ + .reg = _reg, \ + .hw.init = CLK_HW_INIT_FW_NAME(_name, \ + _parent, \ + &ccu_gate_ops, \ + _flags), \ + } \ + } + +/* + * The following two macros allow the re-use of the data structure + * holding the parent info. + */ +#define SUNXI_CCU_GATE_HWS(_struct, _name, _parent, _reg, _gate, _flags) \ + struct ccu_gate _struct = { \ + .enable = _gate, \ + .common = { \ + .reg = _reg, \ + .hw.init = CLK_HW_INIT_HWS(_name, \ + _parent, \ + &ccu_gate_ops, \ + _flags), \ + } \ + } + +#define SUNXI_CCU_GATE_DATA(_struct, _name, _data, _reg, _gate, _flags) \ + struct ccu_gate _struct = { \ + .enable = _gate, \ + .common = { \ + .reg = _reg, \ + .hw.init = \ + CLK_HW_INIT_PARENTS_DATA(_name, \ + _data, \ + &ccu_gate_ops, \ + _flags), \ + } \ + } + static inline struct ccu_gate *hw_to_ccu_gate(struct clk_hw *hw) { struct ccu_common *common = hw_to_ccu_common(hw); -- 2.20.1