From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 414CEC54E58 for ; Mon, 11 Mar 2024 05:59:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:In-Reply-To:From:References:To:Subject: MIME-Version:Date:Message-ID:Reply-To:Cc:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=ZctunJ/oH9J2NmBpPzNkrgC73njTB8az8k2p4F1zEfY=; b=YiOL2eJf9ERDl+ JoN1ZRnMetxDajt3/caYgOLVtoLyku0aFrYBxMY0YfGp7tK3bASuqKP5hWIiNNBL/XMjy17uBIFWk 0yxAhVEUTNIkdcQ1NFPhZVCwj6AumrGtJcKOVlmPkWcfI5elSbkfT6J4wPvPlBO8x6vOHYQwj4xtc qiZAInKRL1GNuHy/wsTM860PrWY+utvvBkM5wAAMYduvfMBa+nz9ofJtOLWtzpRflud9vmJOGoP/W 3NdIjUVo3Xsd6nbA6+ZI9sealjgcRoHnWqaDxZexgHX9JMz6VvbDRBwwx5QJzOA+hwZYcG69f6lM8 ac8N6jO1obzRzthXFYnA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1rjYgV-00000000IvA-2E6G; Mon, 11 Mar 2024 05:58:51 +0000 Received: from mail-wm1-x335.google.com ([2a00:1450:4864:20::335]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1rjYgS-00000000Iuk-2MDc for linux-arm-kernel@lists.infradead.org; Mon, 11 Mar 2024 05:58:50 +0000 Received: by mail-wm1-x335.google.com with SMTP id 5b1f17b1804b1-4132ceec75dso709435e9.0 for ; Sun, 10 Mar 2024 22:58:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=tuxon.dev; s=google; t=1710136726; x=1710741526; darn=lists.infradead.org; h=content-transfer-encoding:in-reply-to:from:references:to :content-language:subject:user-agent:mime-version:date:message-id :from:to:cc:subject:date:message-id:reply-to; bh=N+/SGeTJ2In+PBSViijiZt2zPtoByX/MEX5Z46fSm+M=; b=T326sfJBfD50WcpQ9ehTisAhNkSgAzCfwMYvTqWWk4AJc32qS9pBj+rjD5bWyqEfbB s8HBwNPKgbj8UPZUz2eqtmT0BNNyGxTg5rmjp9T3eTkqOozZoK96l5Yc8iv86Ku/kmiB st4CgewEVO0EM9WRVUmwfPy5YBkorsvADMCOEx+t4OX+sokAlmJXXhReROLKQs8BW/II 7XLVYQ/0dQifEkw2k7btifMPvmm3sU5vRqQAQ8t9ISf4fQWl68O+7vQ0RyZYqRlEsUP1 FzNvI4UeGAj0FQ8YG2KFvXFdTwe17q33so5nh+H5cD/o3csm+WIgY4w+6pOWmIDn3Y5G Llfg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1710136726; x=1710741526; h=content-transfer-encoding:in-reply-to:from:references:to :content-language:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=N+/SGeTJ2In+PBSViijiZt2zPtoByX/MEX5Z46fSm+M=; b=cdVBkyXotdmCoFJXmzhQZDTGHouM+o3op4AkbmHx63taW2frjhSMAtnJ3UlhsLgPgj egD2QfsiW3FL30ypeamiE5UOf1krklmh7MET4jEJsRKy8jdZLxJS6YOvC79519Wf8qaP +YtFGcWsybkwzhCUnisN7w5AFslGoUOqC//3lgyJBzi3d5mIIeAPDcIOq5vRyJXYIkmt WaNF9B4NV5mjm1zdyPU+T3BFFrqkIl2iqpbU1SxqC1Ro6Qp5G0Ca7HIGgWBhGkpIljfo hifd6p4z5q0fx/aiVns/XhxFNjBoDvgtlQjiImVsgAUbaKvlnZl35+42rQ6hFxXQLa3E p4rw== X-Forwarded-Encrypted: i=1; AJvYcCXPQUFdtWb8LmFwldGihCKfcivmIi8CdpqXIztsDsHT3wYt0rWuFIhPMc+NKxM1B4ulhRq6IXTSLX7ZgB+WzaBKaYQzRdpXpQFHt4ROw9a7l9LJ8yw= X-Gm-Message-State: AOJu0YwknlHLuFaCiqRbdsRJE51JT/yzDiHHHy5UL4MxdqI+YfV2w+dW ryO37FKZHFg5zWrRBb7k+cqi8s855JL+5XTK2/nVWy7r1vri1q+AlBnuX/GBU7w= X-Google-Smtp-Source: AGHT+IGAA4xdFAU+7CwwGo6hGmuRT2qEqlJxSkz/J/OB3B3wRCxURUF7dIhuGE4MoPPkxUsohLZtLw== X-Received: by 2002:a05:600c:4ecf:b0:413:1713:864 with SMTP id g15-20020a05600c4ecf00b0041317130864mr4585552wmq.33.1710136726197; Sun, 10 Mar 2024 22:58:46 -0700 (PDT) Received: from [192.168.50.4] ([82.78.167.38]) by smtp.gmail.com with ESMTPSA id g13-20020a05600c310d00b004131bb71c07sm7820750wmo.11.2024.03.10.22.58.45 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Sun, 10 Mar 2024 22:58:45 -0700 (PDT) Message-ID: <01e96d4b-3038-498b-a9b2-2acac51f1d80@tuxon.dev> Date: Mon, 11 Mar 2024 07:58:43 +0200 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v4 27/39] clk: at91: sam9x7: add sam9x7 pmc driver Content-Language: en-US To: Varshini Rajendran , mturquette@baylibre.com, sboyd@kernel.org, nicolas.ferre@microchip.com, alexandre.belloni@bootlin.com, linux-kernel@vger.kernel.org, linux-clk@vger.kernel.org, linux-arm-kernel@lists.infradead.org References: <20240223171342.669133-1-varshini.rajendran@microchip.com> <20240223172831.672953-1-varshini.rajendran@microchip.com> From: claudiu beznea In-Reply-To: <20240223172831.672953-1-varshini.rajendran@microchip.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240310_225848_649941_0B0FF2FC X-CRM114-Status: GOOD ( 22.15 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org On 23.02.2024 19:28, Varshini Rajendran wrote: > Add a driver for the PMC clocks of sam9x7 Soc family. > > Signed-off-by: Varshini Rajendran > --- > Changes in v4: > - Changed variable name alloc_mem to clk_mux_buffer to be more > suggestive > - Changed description of @f structure member appropriately > --- > drivers/clk/at91/Makefile | 1 + > drivers/clk/at91/sam9x7.c | 946 ++++++++++++++++++++++++++++++++++++++ > 2 files changed, 947 insertions(+) > create mode 100644 drivers/clk/at91/sam9x7.c > > diff --git a/drivers/clk/at91/Makefile b/drivers/clk/at91/Makefile > index 89061b85e7d2..8e3684ba2c74 100644 > --- a/drivers/clk/at91/Makefile > +++ b/drivers/clk/at91/Makefile > @@ -20,6 +20,7 @@ obj-$(CONFIG_SOC_AT91SAM9) += at91sam9260.o at91sam9rl.o at91sam9x5.o dt-compat. > obj-$(CONFIG_SOC_AT91SAM9) += at91sam9g45.o dt-compat.o > obj-$(CONFIG_SOC_AT91SAM9) += at91sam9n12.o at91sam9x5.o dt-compat.o > obj-$(CONFIG_SOC_SAM9X60) += sam9x60.o > +obj-$(CONFIG_SOC_SAM9X7) += sam9x7.o > obj-$(CONFIG_SOC_SAMA5D3) += sama5d3.o dt-compat.o > obj-$(CONFIG_SOC_SAMA5D4) += sama5d4.o dt-compat.o > obj-$(CONFIG_SOC_SAMA5D2) += sama5d2.o dt-compat.o > diff --git a/drivers/clk/at91/sam9x7.c b/drivers/clk/at91/sam9x7.c > new file mode 100644 > index 000000000000..d03387d2e35a > --- /dev/null > +++ b/drivers/clk/at91/sam9x7.c > @@ -0,0 +1,946 @@ > +// SPDX-License-Identifier: GPL-2.0 > +/* > + * SAM9X7 PMC code. > + * > + * Copyright (C) 2023 Microchip Technology Inc. and its subsidiaries > + * > + * Author: Varshini Rajendran > + * > + */ > +#include > +#include > +#include > +#include > + > +#include > + > +#include "pmc.h" > + > +static DEFINE_SPINLOCK(pmc_pll_lock); > +static DEFINE_SPINLOCK(mck_lock); > + > +/** > + * enum pll_ids - PLL clocks identifiers > + * @PLL_ID_PLLA: PLLA identifier > + * @PLL_ID_UPLL: UPLL identifier > + * @PLL_ID_AUDIO: Audio PLL identifier > + * @PLL_ID_LVDS: LVDS PLL identifier > + * @PLL_ID_PLLA_DIV2: PLLA DIV2 identifier > + * @PLL_ID_MAX: Max PLL Identifier > + */ > +enum pll_ids { > + PLL_ID_PLLA, > + PLL_ID_UPLL, > + PLL_ID_AUDIO, > + PLL_ID_LVDS, > + PLL_ID_PLLA_DIV2, > + PLL_ID_MAX, > +}; > + > +/** > + * enum pll_type - PLL type identifiers > + * @PLL_TYPE_FRAC: fractional PLL identifier > + * @PLL_TYPE_DIV: divider PLL identifier > + */ > +enum pll_type { > + PLL_TYPE_FRAC, > + PLL_TYPE_DIV, > +}; > + > +static const struct clk_master_characteristics mck_characteristics = { > + .output = { .min = 32000000, .max = 266666667 }, > + .divisors = { 1, 2, 4, 3, 5}, > + .have_div3_pres = 1, > +}; > + > +static const struct clk_master_layout sam9x7_master_layout = { > + .mask = 0x373, > + .pres_shift = 4, > + .offset = 0x28, > +}; > + > +/* Fractional PLL core output range. */ > +static const struct clk_range plla_core_outputs[] = { > + { .min = 375000000, .max = 1600000000 }, > +}; > + > +static const struct clk_range upll_core_outputs[] = { > + { .min = 600000000, .max = 1200000000 }, > +}; > + > +static const struct clk_range lvdspll_core_outputs[] = { > + { .min = 400000000, .max = 800000000 }, > +}; > + > +static const struct clk_range audiopll_core_outputs[] = { > + { .min = 400000000, .max = 800000000 }, > +}; > + > +static const struct clk_range plladiv2_core_outputs[] = { > + { .min = 375000000, .max = 1600000000 }, > +}; > + > +/* Fractional PLL output range. */ > +static const struct clk_range plla_outputs[] = { > + { .min = 732421, .max = 800000000 }, > +}; > + > +static const struct clk_range upll_outputs[] = { > + { .min = 300000000, .max = 600000000 }, > +}; > + > +static const struct clk_range lvdspll_outputs[] = { > + { .min = 10000000, .max = 800000000 }, > +}; > + > +static const struct clk_range audiopll_outputs[] = { > + { .min = 10000000, .max = 800000000 }, > +}; > + > +static const struct clk_range plladiv2_outputs[] = { > + { .min = 366210, .max = 400000000 }, > +}; > + > +/* PLL characteristics. */ > +static const struct clk_pll_characteristics plla_characteristics = { > + .input = { .min = 20000000, .max = 50000000 }, > + .num_output = ARRAY_SIZE(plla_outputs), > + .output = plla_outputs, > + .core_output = plla_core_outputs, > +}; > + > +static const struct clk_pll_characteristics upll_characteristics = { > + .input = { .min = 20000000, .max = 50000000 }, > + .num_output = ARRAY_SIZE(upll_outputs), > + .output = upll_outputs, > + .core_output = upll_core_outputs, > + .upll = true, > +}; > + > +static const struct clk_pll_characteristics lvdspll_characteristics = { > + .input = { .min = 20000000, .max = 50000000 }, > + .num_output = ARRAY_SIZE(lvdspll_outputs), > + .output = lvdspll_outputs, > + .core_output = lvdspll_core_outputs, > +}; > + > +static const struct clk_pll_characteristics audiopll_characteristics = { > + .input = { .min = 20000000, .max = 50000000 }, > + .num_output = ARRAY_SIZE(audiopll_outputs), > + .output = audiopll_outputs, > + .core_output = audiopll_core_outputs, > +}; > + > +static const struct clk_pll_characteristics plladiv2_characteristics = { > + .input = { .min = 20000000, .max = 50000000 }, > + .num_output = ARRAY_SIZE(plladiv2_outputs), > + .output = plladiv2_outputs, > + .core_output = plladiv2_core_outputs, > +}; > + > +/* Layout for fractional PLL ID PLLA. */ > +static const struct clk_pll_layout plla_frac_layout = { > + .mul_mask = GENMASK(31, 24), > + .frac_mask = GENMASK(21, 0), > + .mul_shift = 24, > + .frac_shift = 0, > + .div2 = 1, It seems to me that this is not taken into account (see below). > +}; > + > +/* Layout for fractional PLLs. */ > +static const struct clk_pll_layout pll_frac_layout = { > + .mul_mask = GENMASK(31, 24), > + .frac_mask = GENMASK(21, 0), > + .mul_shift = 24, > + .frac_shift = 0, > +}; > + > +/* Layout for DIV PLLs. */ > +static const struct clk_pll_layout pll_divpmc_layout = { > + .div_mask = GENMASK(7, 0), > + .endiv_mask = BIT(29), > + .div_shift = 0, > + .endiv_shift = 29, > +}; > + > +/* Layout for DIV PLL ID PLLADIV2. */ > +static const struct clk_pll_layout plladiv2_divpmc_layout = { > + .div_mask = GENMASK(7, 0), > + .endiv_mask = BIT(29), > + .div_shift = 0, > + .endiv_shift = 29, > + .div2 = 1, > +}; > + > +/* Layout for DIVIO dividers. */ > +static const struct clk_pll_layout pll_divio_layout = { > + .div_mask = GENMASK(19, 12), > + .endiv_mask = BIT(30), > + .div_shift = 12, > + .endiv_shift = 30, > +}; > + > +/* > + * PLL clocks description > + * @n: clock name > + * @p: clock parent > + * @l: clock layout > + * @t: clock type > + * @c: pll characteristics > + * @f: clock flags > + * @eid: export index in sam9x7->chws[] array > + */ > +static const struct { > + const char *n; > + const char *p; > + const struct clk_pll_layout *l; > + u8 t; > + const struct clk_pll_characteristics *c; > + unsigned long f; > + u8 eid; > +} sam9x7_plls[][PLL_ID_MAX] = { > + [PLL_ID_PLLA] = { > + { > + .n = "plla_fracck", > + .p = "mainck", > + .l = &plla_frac_layout, > + .t = PLL_TYPE_FRAC, > + /* > + * This feeds plla_divpmcck which feeds CPU. It should > + * not be disabled. > + */ > + .f = CLK_IS_CRITICAL | CLK_SET_RATE_GATE, > + .c = &plla_characteristics, > + }, > + > + { > + .n = "plla_divpmcck", > + .p = "plla_fracck", > + .l = &pll_divpmc_layout, You mentioned in "[PATCH v4 24/39] clk: at91: sam9x7: add support for HW PLL freq dividers" that this has div2 but it is registered w/ a layout that has .div2 = 0. _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel