From patchwork Wed Jun 12 19:59:04 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Martin Blumenstingl X-Patchwork-Id: 10990817 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 373F014C0 for ; Wed, 12 Jun 2019 20:02:16 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 2820028ACB for ; Wed, 12 Jun 2019 20:02:16 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 1CB8428AD2; Wed, 12 Jun 2019 20:02:16 +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=ham 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 9F14C28ACB for ; Wed, 12 Jun 2019 20:02:15 +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=ZB8EisgVF9iqAfGWj6QbVQQ5qytOnKGPkNB+u+T4VXI=; b=rfemD7HNxgDCn0 ldLnJRWwYUIucjJmGz87sMV85eYtSWaVW0cmfw5oDOF6kzro4j5AhjO5ivybDlhpC0lA3clAnyPOo jvvAazisqv3Bg4ZpEsEn8ZAiClOZ/DOY/T1nhqCp5WmuIt0lAIzNZxuEhlS8o0nWk9QN29raGkgWz H0MdpWi4HqTURJ6dXfqfGN0IjvEX48DEPzGARppywk9Nt+houc0Sl5RvGBRenfib5Uy8oRznoP7rX 702hDe0xde29WuR2msgVvqh69klAo04IcXVkfVpXHdiKAAoElLEumf2KmUigwtrco/dARTDSkUFEP PQzZhnonwM3e/YjX+2bA==; 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 1hb9Rm-0000B2-MD; Wed, 12 Jun 2019 20:02:14 +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 1hb9PI-0005JS-6S; Wed, 12 Jun 2019 19:59:42 +0000 Received: by mail-wr1-x444.google.com with SMTP id x4so15577165wrt.6; Wed, 12 Jun 2019 12:59:39 -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=9duNzyOXL2uBZFKfNd08dg5Nd2ipcFHbuFioapQa3zU=; b=ML6/U/HE7C6uxY+WbpSPSwj/EdxdRkPJPhTthXln6AxEKSv5sAjDcWRnLbSvzA1fia 3F7igjHrqbLHUiPfG2w5VzBiSmHlXC2eUVTUZzCQtFgGmgY6GvdY/bMbjwH6l6Ip1EmU UG3DCre837AEii/jcqMdrsx5fodiF0kciEgusI6IkJsdn/oUyGwuxUELKt3TY67KkC7C 9jLGy0bpXhc+IdUbv1wRgv0gT3WSU1ZyNJ+Id81DSqdjPpubKcB8iGL6x1/3miD+3ndG CLgGBE9GiKbzK5fF4Y4qmM++CtOOQaXUsSXowWadB89iatqMaSswOTwSHKrIA8JYN4EB DY6g== 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=9duNzyOXL2uBZFKfNd08dg5Nd2ipcFHbuFioapQa3zU=; b=bkswgISOJv0JhgBOHO/R21dip9mIUH3xbfIgGWvdzdC+MpB5X5WZ4kmgaGHcl6ytXu Z8iMuO1kWpfqGnMce7Jza3AHpUupwAfoaVlgsWNVI/X2xYRiznSjHIV+Nn2fvMosVQy2 X230VLN9SllvALouF+YpTIjL5Jf5YviftZwo7fg/iP7UwgGVaakg3wsz0yKLOVjOGn3u 0kVygiuL/P2FS6q9Q+NuSPPL1TtLo/W3bDADN0fgwQYaHv3QRu1VYLIkL8m4QCt2S/AS OQ8VYsMGD7jty66tASZyv4VrmZHnRcgDrnxmLasZgqtislt6dVryBuTW1YrwIIByTPS3 tZcA== X-Gm-Message-State: APjAAAWfvvnDHbfU5hy0v/SwLRkv5/0CA/dM6tCwFn044pbe0RlrAVrx r8jHHGTnL4fwbttty0PUqler94Hy X-Google-Smtp-Source: APXvYqyfv4Q9YeYUh5AL76YU7U2ZwgDXUrmfUuV/ehx6YrwT4RFMNn6lnvF/KW9z2IvcaxF7CA551Q== X-Received: by 2002:adf:dd03:: with SMTP id a3mr589247wrm.87.1560369578442; Wed, 12 Jun 2019 12:59:38 -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.37 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Wed, 12 Jun 2019 12:59:37 -0700 (PDT) From: Martin Blumenstingl To: linux-amlogic@lists.infradead.org, linux-pwm@vger.kernel.org, thierry.reding@gmail.com Subject: [PATCH v3 07/14] pwm: meson: add the meson_pwm_channel data to struct meson_pwm Date: Wed, 12 Jun 2019 21:59:04 +0200 Message-Id: <20190612195911.4442-8-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_125940_464982_640DA3CD X-CRM114-Status: GOOD ( 14.78 ) X-BeenThere: linux-amlogic@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-amlogic" Errors-To: linux-amlogic-bounces+patchwork-linux-amlogic=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP Make struct meson_pwm_channel accessible from struct meson_pwm. PWM core has a limitation: per-channel data can only be set after pwmchip_add() is called. However, pwmchip_add() internally calls pwm_ops.get_state(). If pwm_ops.get_state() needs access to the per-channel data it has to obtain it from struct pwm_chip and struct pwm_device's hwpwm information. Add a struct meson_pwm_channel for each PWM channel to struct meson_pwm so the pwm_ops.get_state() callback can be implemented as it needs access to the clock from struct meson_pwm_channel. Reviewed-by: Neil Armstrong Signed-off-by: Martin Blumenstingl --- drivers/pwm/pwm-meson.c | 25 ++++++++++--------------- 1 file changed, 10 insertions(+), 15 deletions(-) diff --git a/drivers/pwm/pwm-meson.c b/drivers/pwm/pwm-meson.c index d6eb4d04d5c9..a4ae3587a3ce 100644 --- a/drivers/pwm/pwm-meson.c +++ b/drivers/pwm/pwm-meson.c @@ -37,6 +37,8 @@ #define MISC_B_EN BIT(1) #define MISC_A_EN BIT(0) +#define MESON_NUM_PWMS 2 + static const unsigned int mux_reg_shifts[] = { MISC_A_CLK_SEL_SHIFT, MISC_B_CLK_SEL_SHIFT @@ -62,6 +64,7 @@ struct meson_pwm_data { struct meson_pwm { struct pwm_chip chip; const struct meson_pwm_data *data; + struct meson_pwm_channel channels[MESON_NUM_PWMS]; void __iomem *base; /* * Protects register (write) access to the REG_MISC_AB register @@ -435,8 +438,7 @@ static const struct of_device_id meson_pwm_matches[] = { }; MODULE_DEVICE_TABLE(of, meson_pwm_matches); -static int meson_pwm_init_channels(struct meson_pwm *meson, - struct meson_pwm_channel *channels) +static int meson_pwm_init_channels(struct meson_pwm *meson) { struct device *dev = meson->chip.dev; struct clk_init_data init; @@ -445,7 +447,7 @@ static int meson_pwm_init_channels(struct meson_pwm *meson, int err; for (i = 0; i < meson->chip.npwm; i++) { - struct meson_pwm_channel *channel = &channels[i]; + struct meson_pwm_channel *channel = &meson->channels[i]; snprintf(name, sizeof(name), "%s#mux%u", dev_name(dev), i); @@ -480,18 +482,16 @@ static int meson_pwm_init_channels(struct meson_pwm *meson, return 0; } -static void meson_pwm_add_channels(struct meson_pwm *meson, - struct meson_pwm_channel *channels) +static void meson_pwm_add_channels(struct meson_pwm *meson) { unsigned int i; for (i = 0; i < meson->chip.npwm; i++) - pwm_set_chip_data(&meson->chip.pwms[i], &channels[i]); + pwm_set_chip_data(&meson->chip.pwms[i], &meson->channels[i]); } static int meson_pwm_probe(struct platform_device *pdev) { - struct meson_pwm_channel *channels; struct meson_pwm *meson; struct resource *regs; int err; @@ -509,18 +509,13 @@ static int meson_pwm_probe(struct platform_device *pdev) meson->chip.dev = &pdev->dev; meson->chip.ops = &meson_pwm_ops; meson->chip.base = -1; - meson->chip.npwm = 2; + meson->chip.npwm = MESON_NUM_PWMS; meson->chip.of_xlate = of_pwm_xlate_with_flags; meson->chip.of_pwm_n_cells = 3; meson->data = of_device_get_match_data(&pdev->dev); - channels = devm_kcalloc(&pdev->dev, meson->chip.npwm, - sizeof(*channels), GFP_KERNEL); - if (!channels) - return -ENOMEM; - - err = meson_pwm_init_channels(meson, channels); + err = meson_pwm_init_channels(meson); if (err < 0) return err; @@ -530,7 +525,7 @@ static int meson_pwm_probe(struct platform_device *pdev) return err; } - meson_pwm_add_channels(meson, channels); + meson_pwm_add_channels(meson); platform_set_drvdata(pdev, meson);