From: Florian Fainelli <f.fainelli@gmail.com>
To: Matthias Brugger <matthias.bgg@gmail.com>,
Stefan Wahren <wahrenst@gmx.net>, Eric Anholt <eric@anholt.net>,
Florian Fainelli <f.fainelli@gmail.com>,
Ray Jui <rjui@broadcom.com>,
Scott Branden <sbranden@broadcom.com>,
Nicolas Saenz Julienne <nsaenzjulienne@suse.de>,
Rob Herring <robh+dt@kernel.org>,
Mark Rutland <mark.rutland@arm.com>,
Linus Walleij <linus.walleij@linaro.org>,
Michael Turquette <mturquette@baylibre.com>,
Stephen Boyd <sboyd@kernel.org>,
Ulf Hansson <ulf.hansson@linaro.org>,
Adrian Hunter <adrian.hunter@intel.com>,
Mark Brown <broonie@kernel.org>
Cc: bcm-kernel-feedback-list@broadcom.com,
linux-rpi-kernel@lists.infradead.org,
linux-arm-kernel@lists.infradead.org
Subject: Re: [PATCH RFC 07/18] clk: bcm2835: Add BCM2838_CLOCK_EMMC2 support
Date: Thu, 18 Jul 2019 09:51:43 -0700 [thread overview]
Message-ID: <3b691366-81b1-efe3-8b7e-a81f0fc9c2fb@gmail.com> (raw)
In-Reply-To: <f6d8fecd-94d3-a5a8-2d4c-c1ae2b6a0919@gmail.com>
On 7/18/2019 1:47 AM, Matthias Brugger wrote:
>
>
> On 17/07/2019 21:50, Stefan Wahren wrote:
>> The new BCM2838 supports an additional clock for the emmc2 block.
>> So add a new compatible to register this clock only for BCM2838.
>>
>> Signed-off-by: Stefan Wahren <wahrenst@gmx.net>
>> ---
>> drivers/clk/bcm/clk-bcm2835.c | 33 +++++++++++++++++++++++++++++++--
>> 1 file changed, 31 insertions(+), 2 deletions(-)
>>
>> diff --git a/drivers/clk/bcm/clk-bcm2835.c b/drivers/clk/bcm/clk-bcm2835.c
>> index 867ae3c..5fe4695 100644
>> --- a/drivers/clk/bcm/clk-bcm2835.c
>> +++ b/drivers/clk/bcm/clk-bcm2835.c
>> @@ -31,7 +31,8 @@
>> #include <linux/delay.h>
>> #include <linux/io.h>
>> #include <linux/module.h>
>> -#include <linux/of.h>
>> +#include <linux/of_device.h>
>> +
>> #include <linux/platform_device.h>
>> #include <linux/slab.h>
>> #include <dt-bindings/clock/bcm2835.h>
>> @@ -114,6 +115,8 @@
>> #define CM_AVEODIV 0x1bc
>> #define CM_EMMCCTL 0x1c0
>> #define CM_EMMCDIV 0x1c4
>> +#define CM_EMMC2CTL 0x1d0
>> +#define CM_EMMC2DIV 0x1d4
>>
>> /* General bits for the CM_*CTL regs */
>> # define CM_ENABLE BIT(4)
>> @@ -1950,6 +1953,15 @@ static const struct bcm2835_clk_desc clk_desc_array[] = {
>> .frac_bits = 8,
>> .tcnt_mux = 39),
>>
>> + /* EMMC2 clock (only available for BCM2838) */
>> + [BCM2838_CLOCK_EMMC2] = REGISTER_PER_CLK(
>> + .name = "emmc2",
>> + .ctl_reg = CM_EMMC2CTL,
>> + .div_reg = CM_EMMC2DIV,
>> + .int_bits = 4,
>> + .frac_bits = 8,
>> + .tcnt_mux = 42),
>> +
>> /* General purpose (GPIO) clocks */
>> [BCM2835_CLOCK_GP0] = REGISTER_PER_CLK(
>> .name = "gp0",
>> @@ -2101,6 +2113,14 @@ static int bcm2835_mark_sdc_parent_critical(struct clk *sdc)
>> return clk_prepare_enable(parent);
>> }
>>
>> +bool bcm2835_has_clk(size_t index) {
>> + return index != BCM2838_CLOCK_EMMC2;
>> +}
>> +
>> +bool bcm2838_has_clk(size_t index) {
>> + return true;
>> +}
>> +
>> static int bcm2835_clk_probe(struct platform_device *pdev)
>> {
>> struct device *dev = &pdev->dev;
>> @@ -2109,9 +2129,14 @@ static int bcm2835_clk_probe(struct platform_device *pdev)
>> struct resource *res;
>> const struct bcm2835_clk_desc *desc;
>> const size_t asize = ARRAY_SIZE(clk_desc_array);
>> + bool (*has_clk_func)(size_t);
>> size_t i;
>> int ret;
>>
>> + has_clk_func = of_device_get_match_data(&pdev->dev);
>> + if (!has_clk_func)
>> + return -ENODEV;
>> +
>> cprman = devm_kzalloc(dev,
>> struct_size(cprman, onecell.hws, asize),
>> GFP_KERNEL);
>> @@ -2146,6 +2171,9 @@ static int bcm2835_clk_probe(struct platform_device *pdev)
>> hws = cprman->onecell.hws;
>>
>> for (i = 0; i < asize; i++) {
>> + if (!has_clk_func(i))
>> + continue;
>> +
>
> I think that's very hacky. Can't we just create a per SoC list which get's
> passed via .data and in probe we iterate through that list and enable the
> clocks? That would make clear which clocks are just for bcm2838, basically emmc2.
Or within the structure, add a flag that indicates whether the clock is
available or not for a given chip? That would avoid having to introduce
bcm283x_has_clk() functions that needs to maintain a possibly growing
list of clocks. You would still have to check the flag though.
The trade-off here is a large table (larger than necessary) versus more
run time checks.
We could consider having a base table that gets copied into a bcm2838
specific table, and overlay that base structure with what's specific
with bcm2838, is that you have in mind?
--
Florian
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
next prev parent reply other threads:[~2019-07-18 16:52 UTC|newest]
Thread overview: 32+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-07-17 19:50 [PATCH RFC 00/18] ARM: Add minimal Raspberry Pi 4 support Stefan Wahren
2019-07-17 19:50 ` [PATCH RFC 01/18] ARM: bcm283x: Reduce register ranges for UART, SPI and I2C Stefan Wahren
2019-07-17 19:50 ` [PATCH RFC 02/18] ARM: bcm2835: DMA can only address 1GB Stefan Wahren
2019-07-17 19:50 ` [PATCH RFC 03/18] ARM: dts: bcm283x: Move BCM2835/6/7 specific to bcm2835-common.dtsi Stefan Wahren
2019-07-17 19:50 ` [PATCH RFC 04/18] ARM: dts: bcm283x: Define MMC interfaces at board level Stefan Wahren
2019-07-17 19:50 ` [PATCH RFC 05/18] ARM: dts: bcm283x: Define memory " Stefan Wahren
2019-07-17 19:50 ` [PATCH RFC 06/18] dt-bindings: bcm2835-cprman: Add bcm2838 support Stefan Wahren
2019-07-17 19:50 ` [PATCH RFC 07/18] clk: bcm2835: Add BCM2838_CLOCK_EMMC2 support Stefan Wahren
2019-07-18 8:47 ` Matthias Brugger
2019-07-18 16:51 ` Florian Fainelli [this message]
2019-07-18 18:37 ` Eric Anholt
2019-07-19 16:40 ` Stefan Wahren
2019-07-19 19:49 ` Eric Anholt
2019-07-17 19:50 ` [PATCH RFC 08/18] dt-bindings: sdhci-iproc: Add brcm,bcm2838-emmc2 Stefan Wahren
2019-07-17 19:50 ` [PATCH RFC 09/18] mmc: sdhci-iproc: Add support for emmc2 of the BCM2838 Stefan Wahren
2019-07-18 8:34 ` Matthias Brugger
2019-07-18 16:40 ` Florian Fainelli
2019-07-18 16:48 ` Matthias Brugger
2019-07-18 16:52 ` Florian Fainelli
2019-07-18 17:46 ` Stefan Wahren
2019-07-18 18:09 ` Stefan Wahren
2019-07-18 18:19 ` Andrei Gherzan
2019-07-17 19:50 ` [PATCH RFC 10/18] pinctrl: bcm2835: bcm7211: Add support for 7211 pull-up functionality Stefan Wahren
2019-08-02 22:05 ` Linus Walleij
2019-07-17 19:50 ` [PATCH RFC 11/18] pinctrl: bcm2835: Fix BCM7211 pinconf handling Stefan Wahren
2019-08-02 22:06 ` Linus Walleij
2019-07-17 19:50 ` [PATCH RFC 12/18] dt-bindings: pinctrl: bcm2835: Add brcm, bcm2838 compatible Stefan Wahren
2019-07-17 19:50 ` [PATCH RFC 13/18] pinctrl: bcm2835: Add BCM2838 support Stefan Wahren
2019-08-02 22:08 ` Linus Walleij
2019-07-18 18:45 ` [PATCH RFC 00/18] ARM: Add minimal Raspberry Pi 4 support Eric Anholt
2019-07-18 18:58 ` Florian Fainelli
2019-07-19 13:18 ` Nicolas Saenz Julienne
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=3b691366-81b1-efe3-8b7e-a81f0fc9c2fb@gmail.com \
--to=f.fainelli@gmail.com \
--cc=adrian.hunter@intel.com \
--cc=bcm-kernel-feedback-list@broadcom.com \
--cc=broonie@kernel.org \
--cc=eric@anholt.net \
--cc=linus.walleij@linaro.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-rpi-kernel@lists.infradead.org \
--cc=mark.rutland@arm.com \
--cc=matthias.bgg@gmail.com \
--cc=mturquette@baylibre.com \
--cc=nsaenzjulienne@suse.de \
--cc=rjui@broadcom.com \
--cc=robh+dt@kernel.org \
--cc=sboyd@kernel.org \
--cc=sbranden@broadcom.com \
--cc=ulf.hansson@linaro.org \
--cc=wahrenst@gmx.net \
/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).