From: Alexandre Belloni <alexandre.belloni@bootlin.com>
To: Stephen Boyd <sboyd@kernel.org>, Rob Herring <robh+dt@kernel.org>
Cc: Nicolas Ferre <nicolas.ferre@microchip.com>,
Michael Turquette <mturquette@baylibre.com>,
Thomas Petazzoni <thomas.petazzoni@bootlin.com>,
linux-clk@vger.kernel.org, devicetree@vger.kernel.org,
linux-arm-kernel@lists.infradead.org,
linux-kernel@vger.kernel.org,
Alexandre Belloni <alexandre.belloni@bootlin.com>
Subject: [PATCH 07/16] clk: at91: add pmc_data struct and helpers
Date: Wed, 18 Jul 2018 00:27:48 +0200 [thread overview]
Message-ID: <20180717222757.10253-8-alexandre.belloni@bootlin.com> (raw)
In-Reply-To: <20180717222757.10253-1-alexandre.belloni@bootlin.com>
Add a new strut to handle references to all the PMC clocks and implement
allocation/free helpers.
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
---
drivers/clk/at91/pmc.c | 44 ++++++++++++++++++++++++++++++++++++++++++
drivers/clk/at91/pmc.h | 15 ++++++++++++++
2 files changed, 59 insertions(+)
diff --git a/drivers/clk/at91/pmc.c b/drivers/clk/at91/pmc.c
index 1fa27f4ea538..0f8b3add1b04 100644
--- a/drivers/clk/at91/pmc.c
+++ b/drivers/clk/at91/pmc.c
@@ -47,6 +47,50 @@ int of_at91_get_clk_range(struct device_node *np, const char *propname,
}
EXPORT_SYMBOL_GPL(of_at91_get_clk_range);
+void pmc_data_free(struct pmc_data *pmc_data)
+{
+ kfree(pmc_data->chws);
+ kfree(pmc_data->shws);
+ kfree(pmc_data->phws);
+ kfree(pmc_data->ghws);
+}
+
+struct pmc_data *pmc_data_allocate(unsigned int ncore, unsigned int nsystem,
+ unsigned int nperiph, unsigned int ngck)
+{
+ struct pmc_data *pmc_data = kzalloc(sizeof(*pmc_data), GFP_KERNEL);
+
+ if (!pmc_data)
+ return NULL;
+
+ pmc_data->ncore = ncore;
+ pmc_data->chws = kcalloc(ncore, sizeof(struct clk_hw *), GFP_KERNEL);
+ if (!pmc_data->chws)
+ goto err;
+
+ pmc_data->nsystem = nsystem;
+ pmc_data->shws = kcalloc(nsystem, sizeof(struct clk_hw *), GFP_KERNEL);
+ if (!pmc_data->shws)
+ goto err;
+
+ pmc_data->nperiph = nperiph;
+ pmc_data->phws = kcalloc(nperiph, sizeof(struct clk_hw *), GFP_KERNEL);
+ if (!pmc_data->phws)
+ goto err;
+
+ pmc_data->ngck = ngck;
+ pmc_data->ghws = kcalloc(ngck, sizeof(struct clk_hw *), GFP_KERNEL);
+ if (!pmc_data->ghws)
+ goto err;
+
+ return pmc_data;
+
+err:
+ pmc_data_free(pmc_data);
+
+ return NULL;
+}
+
#ifdef CONFIG_PM
static struct regmap *pmcreg;
diff --git a/drivers/clk/at91/pmc.h b/drivers/clk/at91/pmc.h
index 3dc50267a458..fa4fd3fc7c32 100644
--- a/drivers/clk/at91/pmc.h
+++ b/drivers/clk/at91/pmc.h
@@ -19,6 +19,17 @@
extern spinlock_t pmc_pcr_lock;
+struct pmc_data {
+ unsigned int ncore;
+ struct clk_hw **chws;
+ unsigned int nsystem;
+ struct clk_hw **shws;
+ unsigned int nperiph;
+ struct clk_hw **phws;
+ unsigned int ngck;
+ struct clk_hw **ghws;
+};
+
struct clk_range {
unsigned long min;
unsigned long max;
@@ -69,6 +80,10 @@ extern const struct clk_programmable_layout at91rm9200_programmable_layout;
extern const struct clk_programmable_layout at91sam9g45_programmable_layout;
extern const struct clk_programmable_layout at91sam9x5_programmable_layout;
+struct pmc_data *pmc_data_allocate(unsigned int ncore, unsigned int nsystem,
+ unsigned int nperiph, unsigned int ngck);
+void pmc_data_free(struct pmc_data *pmc_data);
+
int of_at91_get_clk_range(struct device_node *np, const char *propname,
struct clk_range *range);
--
2.18.0
next prev parent reply other threads:[~2018-07-17 22:27 UTC|newest]
Thread overview: 26+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-07-17 22:27 [PATCH 00/16] clk: at91: Rework DT bindings Alexandre Belloni
2018-07-17 22:27 ` [PATCH 01/16] clk: at91: audio-pll: fix audio pmc type Alexandre Belloni
2018-07-17 22:27 ` [PATCH 02/16] clk: at91: generated: SSCs don't have a gclk Alexandre Belloni
2018-07-17 22:27 ` [PATCH 03/16] clk: at91: h32mx: separate registration from DT parsing Alexandre Belloni
2018-07-17 22:27 ` [PATCH 04/16] clk: at91: audio-pll: " Alexandre Belloni
2018-07-17 22:27 ` [PATCH 05/16] clk: at91: generated: set audio_pll_allowed in at91_clk_register_generated() Alexandre Belloni
2018-07-17 22:27 ` [PATCH 06/16] clk: at91: allow clock registration from C code Alexandre Belloni
2018-07-17 22:27 ` Alexandre Belloni [this message]
2018-07-17 22:27 ` [PATCH 08/16] dt-bindings: clk: at91: Document new PMC binding Alexandre Belloni
2018-07-25 19:09 ` Rob Herring
2018-07-17 22:27 ` [PATCH 09/16] clk: at91: add new DT lookup function Alexandre Belloni
2018-07-25 19:10 ` Rob Herring
2018-07-17 22:27 ` [PATCH 10/16] clk: at91: add sama5d4 pmc driver Alexandre Belloni
2018-07-17 22:27 ` [PATCH 11/16] clk: at91: add sama5d2 PMC driver Alexandre Belloni
2018-07-17 22:27 ` [PATCH 12/16] clk: at91: add at91sam9x5 PMCs driver Alexandre Belloni
2018-07-17 22:27 ` [PATCH 13/16] clk: at91: move DT compatibility code to its own file Alexandre Belloni
2018-07-17 22:27 ` [PATCH 14/16] ARM: dts: at91: sama5d4: switch to new clock bindings Alexandre Belloni
2018-07-17 22:27 ` [PATCH 15/16] ARM: dts: at91: sama5d2: switch to new binding Alexandre Belloni
2018-07-17 22:27 ` [PATCH 16/16] ARM: dts: at91: at91sam9x5: switch to new clock bindings Alexandre Belloni
2018-07-27 17:03 ` [PATCH 00/16] clk: at91: Rework DT bindings Stephen Boyd
2018-07-27 20:02 ` Alexandre Belloni
2018-08-16 11:47 ` Alexandre Belloni
2018-08-31 17:45 ` Stephen Boyd
2018-10-12 18:28 ` Stephen Boyd
2018-10-12 18:40 ` Alexandre Belloni
2018-10-12 19:50 ` Stephen Boyd
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20180717222757.10253-8-alexandre.belloni@bootlin.com \
--to=alexandre.belloni@bootlin.com \
--cc=devicetree@vger.kernel.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-clk@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mturquette@baylibre.com \
--cc=nicolas.ferre@microchip.com \
--cc=robh+dt@kernel.org \
--cc=sboyd@kernel.org \
--cc=thomas.petazzoni@bootlin.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).