From patchwork Wed Jul 10 16:25:10 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jerome Brunet X-Patchwork-Id: 13729475 Received: from mail-wm1-f46.google.com (mail-wm1-f46.google.com [209.85.128.46]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id E0264194A66 for ; Wed, 10 Jul 2024 16:25:39 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.46 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1720628742; cv=none; b=ssD6NvWXuYqc4yVloelGKpb6XPGVVYw3t1nrkm8EMkI+1Ha70uafe6rKc0EIv3Yize65Ior6Ai6k2M1/nrJ4tZ1Dq86wOt6/o40dnd1IXKydbNZBGu1/VyMzvLgqoaFTAs8hkp/k7S1/DMMs5t3ovOnjMAuyENMOrMcGP61+Cwo= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1720628742; c=relaxed/simple; bh=cxaqUoQ9aguHyFdmx85j2AoRbVwkuszVVEgKQCGMEX8=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=UmP4Rp7dnapkGhYLkpAN1e7+GKfllkChqKEaQaCKfcErSit1QEOWNLfzqr8fhFsJkTaeCC+rYluyayBIri8g2pYecjYdIEf6t8Jcm5KiNSo8uhR8xoN4o6uELjP/j7sSkF0rmASHK72hBcg4Q0xytl7lzmM/2EOQCXDQpelbfzY= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=baylibre.com; spf=pass smtp.mailfrom=baylibre.com; dkim=pass (2048-bit key) header.d=baylibre-com.20230601.gappssmtp.com header.i=@baylibre-com.20230601.gappssmtp.com header.b=fwz5+L56; arc=none smtp.client-ip=209.85.128.46 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=baylibre.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=baylibre.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=baylibre-com.20230601.gappssmtp.com header.i=@baylibre-com.20230601.gappssmtp.com header.b="fwz5+L56" Received: by mail-wm1-f46.google.com with SMTP id 5b1f17b1804b1-4266ed6c691so17286955e9.3 for ; Wed, 10 Jul 2024 09:25:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20230601.gappssmtp.com; s=20230601; t=1720628738; x=1721233538; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=+f/3bReYMesF4TJq9BOi7hv3PG6ArjPAwHRzmWrlWAw=; b=fwz5+L56ebrkm7cz5ga8NOjUMkDtrO1O5mxiZHzzgO7oQlmqLxC7D8Q/NjRDwP6X94 LMChMFku6MopWuQbUo8tTfHd8IWXh2qRsuvUVeCWUSz6Oc3P/hgcAAuzPxSYYJSjt9wW 30XKqj/S2S7s3uFIwFz/3el4JGK1E8e/TqPEOZ3kzvxlYdwo2zor3FeEslrgz7kvlOim k6PC4anSdy4g0J3CNk9nLwjJezemzZ/Dhhs4ELo6m7GiWndFyiLUwAfq8vdchZ9rcb1M pLY1yjFJmve7GDuiCBgZDRbzxrgXnhMgsyAAq6r+5COpYnvReAyEZepuXmGbnjg+MYCv 16UA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1720628738; x=1721233538; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=+f/3bReYMesF4TJq9BOi7hv3PG6ArjPAwHRzmWrlWAw=; b=HUxRfGaK6gxr0b6KdOdouDYwnYyW9eAfoKwob3utUmmKgXBpQ9+8y7Gvdgacnwn0YR Xgk7FMs5EYnKqsCVbbBwac2aV1npslQv8zA2wSXGOj2kvhaIpLS6F9CNsfA4vpb1IbcB W3b75KnyWGczjwxL8dY+6DueHDA/6RVdijc7RGAE5ieopNnFcvD5DJ9t/A5h89s9Z06k YIeUYFY3lJ+hR2QKHD9cx4QmqzvsaSq3o+m3g85G1yHEJ1GBUBiH8nrUPVU4T8eZ6QVA HjZVQ6VjT8mKBVr52hwdV+CvFH8Ry0iI7lexoHIPgaJg/P+PaTs/kVsy4rUautcF6Uby Obgg== X-Forwarded-Encrypted: i=1; AJvYcCVvY/gJn4RoQtLm0uofKdw0Ou0WBX9Voodimu8NAQRsy4aF4bN7PauryItQXZ9vVmhtgkA7RGIc3wwwMa4qIWzaoeJDgW2/4adY X-Gm-Message-State: AOJu0YxHPQRzXwMolRYXKUJq+Du6uCVliu8zafV0OaSFQ37PMoDYJ3di za7GgJsG1BnqhcOoYA56uTVXf/K5rEVKPqKsV/hBEwA0J7cr+jGN3UQGQpD8fnA= X-Google-Smtp-Source: AGHT+IH2qiHBUH1RFO23oaibc8DcbiyQCXRCeGt1UIGKRM4xe2XwMQCbQGjWpAfO7TNwIg1uOUYcow== X-Received: by 2002:a05:600c:2257:b0:426:5dd0:a1fc with SMTP id 5b1f17b1804b1-426708fa932mr42470925e9.34.1720628738111; Wed, 10 Jul 2024 09:25:38 -0700 (PDT) Received: from toaster.lan ([2a01:e0a:3c5:5fb1:1c99:6356:8466:36cf]) by smtp.googlemail.com with ESMTPSA id 5b1f17b1804b1-4266f6e09e5sm88693815e9.5.2024.07.10.09.25.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 10 Jul 2024 09:25:37 -0700 (PDT) From: Jerome Brunet To: Philipp Zabel , Stephen Boyd , Neil Armstrong Cc: Jerome Brunet , Jan Dakinevich , linux-kernel@vger.kernel.org, linux-amlogic@lists.infradead.org, linux-clk@vger.kernel.org Subject: [PATCH 1/8] reset: amlogic: convert driver to regmap Date: Wed, 10 Jul 2024 18:25:10 +0200 Message-ID: <20240710162526.2341399-2-jbrunet@baylibre.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240710162526.2341399-1-jbrunet@baylibre.com> References: <20240710162526.2341399-1-jbrunet@baylibre.com> Precedence: bulk X-Mailing-List: linux-clk@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Patchwork-Bot: notify To allow using the same driver for the main reset controller and the auxiliary ones embedded in the clock controllers, convert the the Amlogic reset driver to regmap. Signed-off-by: Jerome Brunet --- drivers/reset/reset-meson.c | 80 ++++++++++++++++++++----------------- 1 file changed, 44 insertions(+), 36 deletions(-) diff --git a/drivers/reset/reset-meson.c b/drivers/reset/reset-meson.c index f78be97898bc..8f3d6e9df235 100644 --- a/drivers/reset/reset-meson.c +++ b/drivers/reset/reset-meson.c @@ -11,36 +11,44 @@ #include #include #include +#include #include #include #include -#define BITS_PER_REG 32 - struct meson_reset_param { int reg_count; int level_offset; }; struct meson_reset { - void __iomem *reg_base; const struct meson_reset_param *param; struct reset_controller_dev rcdev; - spinlock_t lock; + struct regmap *map; }; +static void meson_reset_offset_and_bit(struct meson_reset *data, + unsigned long id, + unsigned int *offset, + unsigned int *bit) +{ + unsigned int stride = regmap_get_reg_stride(data->map); + + *offset = (id / (stride * BITS_PER_BYTE)) * stride; + *bit = id % (stride * BITS_PER_BYTE); +} + static int meson_reset_reset(struct reset_controller_dev *rcdev, - unsigned long id) + unsigned long id) { struct meson_reset *data = container_of(rcdev, struct meson_reset, rcdev); - unsigned int bank = id / BITS_PER_REG; - unsigned int offset = id % BITS_PER_REG; - void __iomem *reg_addr = data->reg_base + (bank << 2); + unsigned int offset, bit; - writel(BIT(offset), reg_addr); + meson_reset_offset_and_bit(data, id, &offset, &bit); - return 0; + return regmap_update_bits(data->map, offset, + BIT(bit), BIT(bit)); } static int meson_reset_level(struct reset_controller_dev *rcdev, @@ -48,25 +56,13 @@ static int meson_reset_level(struct reset_controller_dev *rcdev, { struct meson_reset *data = container_of(rcdev, struct meson_reset, rcdev); - unsigned int bank = id / BITS_PER_REG; - unsigned int offset = id % BITS_PER_REG; - void __iomem *reg_addr; - unsigned long flags; - u32 reg; + unsigned int offset, bit; - reg_addr = data->reg_base + data->param->level_offset + (bank << 2); + meson_reset_offset_and_bit(data, id, &offset, &bit); + offset += data->param->level_offset; - spin_lock_irqsave(&data->lock, flags); - - reg = readl(reg_addr); - if (assert) - writel(reg & ~BIT(offset), reg_addr); - else - writel(reg | BIT(offset), reg_addr); - - spin_unlock_irqrestore(&data->lock, flags); - - return 0; + return regmap_update_bits(data->map, offset, + BIT(bit), assert ? 0 : BIT(bit)); } static int meson_reset_assert(struct reset_controller_dev *rcdev, @@ -113,30 +109,42 @@ static const struct of_device_id meson_reset_dt_ids[] = { }; MODULE_DEVICE_TABLE(of, meson_reset_dt_ids); +static const struct regmap_config regmap_config = { + .reg_bits = 32, + .val_bits = 32, + .reg_stride = 4, +}; + static int meson_reset_probe(struct platform_device *pdev) { + struct device *dev = &pdev->dev; struct meson_reset *data; + void __iomem *base; - data = devm_kzalloc(&pdev->dev, sizeof(*data), GFP_KERNEL); + data = devm_kzalloc(dev, sizeof(*data), GFP_KERNEL); if (!data) return -ENOMEM; - data->reg_base = devm_platform_ioremap_resource(pdev, 0); - if (IS_ERR(data->reg_base)) - return PTR_ERR(data->reg_base); + base = devm_platform_ioremap_resource(pdev, 0); + if (IS_ERR(base)) + return PTR_ERR(base); - data->param = of_device_get_match_data(&pdev->dev); + data->param = of_device_get_match_data(dev); if (!data->param) return -ENODEV; - spin_lock_init(&data->lock); + data->map = devm_regmap_init_mmio(dev, base, ®map_config); + if (IS_ERR(data->map)) + return dev_err_probe(dev, PTR_ERR(data->map), + "can't init regmap mmio region\n"); data->rcdev.owner = THIS_MODULE; - data->rcdev.nr_resets = data->param->reg_count * BITS_PER_REG; + data->rcdev.nr_resets = data->param->reg_count * BITS_PER_BYTE + * regmap_config.reg_stride; data->rcdev.ops = &meson_reset_ops; - data->rcdev.of_node = pdev->dev.of_node; + data->rcdev.of_node = dev->of_node; - return devm_reset_controller_register(&pdev->dev, &data->rcdev); + return devm_reset_controller_register(dev, &data->rcdev); } static struct platform_driver meson_reset_driver = { From patchwork Wed Jul 10 16:25:11 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jerome Brunet X-Patchwork-Id: 13729477 Received: from mail-wm1-f52.google.com (mail-wm1-f52.google.com [209.85.128.52]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id B1FC0194AEF for ; Wed, 10 Jul 2024 16:25:40 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.52 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1720628742; cv=none; b=L3z9aZSB8SSCCWjsdLqyHZO89s6xytLahYkRNFyBfS7/YyARGv97tmUIkVXcozwJe9Bkc75hXnN1kMQ8VA8dRkIGrlPXflqQzQgWMIgAaDr0sk6T8i1jEf+pdI6q8l4c4bxSpJbuV8v01VBmqy/Y1j3ipNEhErYgbv5vY3OACv4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1720628742; c=relaxed/simple; bh=XhLKaJpFjJZQj7yn2g+fkx1VUJf2EFpLz+SlbAbTNhQ=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=T18iSDiCfUk+yirPUP9YeQn1p5hg+AQqrABinCcWZOaiV+E1/ohhSi+K383/LKJRUNrxXd24iIyBx0k7uI/hk2MAC+T2zSZUwQ69VrkozAbg2EzGfsHjpnPctjlV5Dzd7fjmmPbG5ReV1lhOXDwVnQuek5k9FoB36zbe7E16TLk= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=baylibre.com; spf=pass smtp.mailfrom=baylibre.com; dkim=pass (2048-bit key) header.d=baylibre-com.20230601.gappssmtp.com header.i=@baylibre-com.20230601.gappssmtp.com header.b=CXFEs00Z; arc=none smtp.client-ip=209.85.128.52 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=baylibre.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=baylibre.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=baylibre-com.20230601.gappssmtp.com header.i=@baylibre-com.20230601.gappssmtp.com header.b="CXFEs00Z" Received: by mail-wm1-f52.google.com with SMTP id 5b1f17b1804b1-4265b7514fcso6352445e9.1 for ; Wed, 10 Jul 2024 09:25:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20230601.gappssmtp.com; s=20230601; t=1720628739; x=1721233539; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=QEvOpWPnO+AdwLbOiUNmMA/qUdgyKNblxOI/csLZzos=; b=CXFEs00Z5J8adHO87gz3RcJ7bmRRklG+NcgawE0SzldweQrbyWvBmyc2GRKK8wXT3p pMe3vdSW8fSE6h7By/iWb7DgCMdjeFbnNevvky4Z7yqa0DUzrouO/429ZEQ3PbpmtGQM 3J6/LZPvJYxJmQXuLlTmu6u4B6pWBKq0evKRMk6bc44Qe31ONu9BIeSDyKZ7JRp8bWny JdDuqrOdy7+JhkSsYyO8Vw9ROh+0Sb1jPVr8MTkXOecauVm04KIMYgGOYmh3j5nWF1bg WtiAYCRA+2qJlwr8hNofyEdJBRQJhDHPh1FG7C4hmR/Uxfo5YX82IHI2pMmVc00GTRSE SwYg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1720628739; x=1721233539; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=QEvOpWPnO+AdwLbOiUNmMA/qUdgyKNblxOI/csLZzos=; b=o1/DI+nY4E8q6Ym4GvJMkI+ByJogCtR6AlG/Lqeo1Xt/4XdrygPW93WSe9FV9f+Pba IDVjI+3q+EJHX0FtZo/aQRJaspjk8U01AJtwiSSwTzKBIDwxnLCV/0f0d+/9zqKSHanq zjUE4VxFXOPeIMAkid3XwRAb4Yr01gtj/gZTsgrZtMf0rV/AZtd8Gh25SAc49jZPirCF 2vM6BuvREQoYyREdxl/iECAI1NRUMyuojiLKCheaSwx7AMcBv2K4q6bzeuDUTFGGm5m+ frqxvKTYoQVwfXvK/6IDqNeaPp7ltqSZhfzTL0+zJiZ2gLV+HKl8toM503US5RiTpac3 28Ew== X-Forwarded-Encrypted: i=1; AJvYcCWpVbq8OumIpHxhVP4Auuf2fZzquXxH54q2tdoEbX9RRuw6VP980G38OB6cy+pc0nTWacN576zBQmajpEsSJbCXS2dNav32HEHR X-Gm-Message-State: AOJu0Yxz451csFaSs0EjDzqnT13hjLmD1TPsvjiFcmLXiDQqldyeA99h rwVzpOPYaT0ypFIYikh849EM/fw2OOrnNTk6vqqkpqedaceIEn/NPC8IQDl148M= X-Google-Smtp-Source: AGHT+IGEAqgF56Q6WhhGNsntYmhXMllSRTjGVzvDJz7QmMwzchYfln7Fkm+0PHq8i2T834Jv9qxoxw== X-Received: by 2002:a7b:c4c7:0:b0:426:6fb1:6b64 with SMTP id 5b1f17b1804b1-427981b7727mr1634915e9.7.1720628739119; Wed, 10 Jul 2024 09:25:39 -0700 (PDT) Received: from toaster.lan ([2a01:e0a:3c5:5fb1:1c99:6356:8466:36cf]) by smtp.googlemail.com with ESMTPSA id 5b1f17b1804b1-4266f6e09e5sm88693815e9.5.2024.07.10.09.25.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 10 Jul 2024 09:25:38 -0700 (PDT) From: Jerome Brunet To: Philipp Zabel , Stephen Boyd , Neil Armstrong Cc: Jerome Brunet , Jan Dakinevich , linux-kernel@vger.kernel.org, linux-amlogic@lists.infradead.org, linux-clk@vger.kernel.org Subject: [PATCH 2/8] reset: amlogic: add driver parameters Date: Wed, 10 Jul 2024 18:25:11 +0200 Message-ID: <20240710162526.2341399-3-jbrunet@baylibre.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240710162526.2341399-1-jbrunet@baylibre.com> References: <20240710162526.2341399-1-jbrunet@baylibre.com> Precedence: bulk X-Mailing-List: linux-clk@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Patchwork-Bot: notify To allow using the same driver for the main reset controller and the auxiliary ones embedded in the clock controllers, allow to customise the reset offset, same as the level offset. Also add an option to make the level reset active low or high. Signed-off-by: Jerome Brunet --- drivers/reset/reset-meson.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/drivers/reset/reset-meson.c b/drivers/reset/reset-meson.c index 8f3d6e9df235..59126c9f194a 100644 --- a/drivers/reset/reset-meson.c +++ b/drivers/reset/reset-meson.c @@ -18,7 +18,9 @@ struct meson_reset_param { int reg_count; + int reset_offset; int level_offset; + bool level_low_reset; }; struct meson_reset { @@ -46,6 +48,7 @@ static int meson_reset_reset(struct reset_controller_dev *rcdev, unsigned int offset, bit; meson_reset_offset_and_bit(data, id, &offset, &bit); + offset += data->param->reset_offset; return regmap_update_bits(data->map, offset, BIT(bit), BIT(bit)); @@ -60,9 +63,10 @@ static int meson_reset_level(struct reset_controller_dev *rcdev, meson_reset_offset_and_bit(data, id, &offset, &bit); offset += data->param->level_offset; + assert ^= data->param->level_low_reset; return regmap_update_bits(data->map, offset, - BIT(bit), assert ? 0 : BIT(bit)); + BIT(bit), assert ? BIT(bit) : 0); } static int meson_reset_assert(struct reset_controller_dev *rcdev, @@ -85,17 +89,23 @@ static const struct reset_control_ops meson_reset_ops = { static const struct meson_reset_param meson8b_param = { .reg_count = 8, + .reset_offset = 0x0, .level_offset = 0x7c, + .level_low_reset = true, }; static const struct meson_reset_param meson_a1_param = { .reg_count = 3, + .reset_offset = 0x0, .level_offset = 0x40, + .level_low_reset = true, }; static const struct meson_reset_param meson_s4_param = { .reg_count = 6, + .reset_offset = 0x0, .level_offset = 0x40, + .level_low_reset = true, }; static const struct of_device_id meson_reset_dt_ids[] = { From patchwork Wed Jul 10 16:25:12 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jerome Brunet X-Patchwork-Id: 13729478 Received: from mail-wm1-f43.google.com (mail-wm1-f43.google.com [209.85.128.43]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 6E844194AF0 for ; Wed, 10 Jul 2024 16:25:41 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.43 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1720628743; cv=none; b=U57AF4gSaLFvktRUcMUSEc21givZdzvJH7FCOaMLHrMw0usz6fg8QRIq0p3U7DQLU6LasHud065wFagqizPmMxXVW2Hpn+2ieOR6v9G5nNWy0UGEk+z/u4Iud6Ks+m1kcnLUjswdE8DMT30Lk4KX2WxacbTSai+3oFaoKxAk0SU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1720628743; c=relaxed/simple; bh=leqWY2m2s/OnXBwNz4GSKae8ZvHNnF69+cyJbS5K14c=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=LxvKI5VgKdmkO7gOtMQeV5FhzGD/RSZsRGAFH6Uz3U62Ty8cAqxu8D98EQwet+tjIlld6pjTozXtw/YqZmJtQBKveUK2DzHkCA2KO6jeO0mBOqMCMabcL7qY1uFnsd4qLUNV38Rtma9TA00Ag636+LxkLZDKHha3AbFQFnp3csE= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=baylibre.com; spf=pass smtp.mailfrom=baylibre.com; dkim=pass (2048-bit key) header.d=baylibre-com.20230601.gappssmtp.com header.i=@baylibre-com.20230601.gappssmtp.com header.b=vdAdAtOl; arc=none smtp.client-ip=209.85.128.43 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=baylibre.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=baylibre.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=baylibre-com.20230601.gappssmtp.com header.i=@baylibre-com.20230601.gappssmtp.com header.b="vdAdAtOl" Received: by mail-wm1-f43.google.com with SMTP id 5b1f17b1804b1-42660b8dd27so27409405e9.3 for ; Wed, 10 Jul 2024 09:25:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20230601.gappssmtp.com; s=20230601; t=1720628740; x=1721233540; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=cy32ICucHSRFg8Zvj0U3F+/oAcafvm3gP5oJRBTbz3s=; b=vdAdAtOlpwHOxfULAOXVoxPT7nuF8t0hkni04Zq+lwxUhbU9/2mJbvZK6wso0QbTEV cSoNbgl94iM/xdV7VHrfjmzFVET9MZoahz2qYJCbPpUcM+Pf69iMj1Nf85E5yBmaMp3N AYJB8oOkz/oOApEQf5kU1s61Lgt/LOjT4ARK7v8kAymtMgnFMFdrg7CuApuIXu4WaR1Y 1+1yPop8IFbinCr4WLh/nZjWFhyceZL5jw/g7Bnw+AI81+QB6F5qP9taL3UbEdoRkSbW Zq8/pIit9vl16VW9pzUeNeZssFbrr1OC9NhLtPTs1GmBzijM/R8Iy1u6GH+SPkttWVHw 1sdw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1720628740; x=1721233540; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=cy32ICucHSRFg8Zvj0U3F+/oAcafvm3gP5oJRBTbz3s=; b=JH8RHJDW3/XXm9OIbACcw+meqkz0Rm35ugmUZkVlLTLNRtQvFhJmPe6cI063yQcv1l gSgSb91LOMPdExDo6Lo6kWeQmUktXFRSc9sSw16tq/2UUcDru94Fy6SHzFxLPNL0CIhJ NkMTlz8DKDCMvqEhVKQsKc4l3uC9Y6Nj5TvaSZBnnakp+8y0Nl5w4XNyBbT8AAs45QR4 vUOfKTtcKrBG8TMZ7p2rjmmCshVTFTc4XBOieOtFCxxgozXP2fgW03xpik+MjZI0NX11 ogkPRZGmv86+/y6S0+cNiaPBHNkCm99KoV/W138vMCmDsgPEXEKMW0ND7fPZzj3OTA/4 m8fg== X-Forwarded-Encrypted: i=1; AJvYcCVGJ9qhwX40yAT7XafLVvvnmaZLZ/7U67H0f3VKF6mTJnpnmNMnl4W2xuoI0680yoEeO0nfW49bXOVeOeChLvAvQ86NyDdNoUzr X-Gm-Message-State: AOJu0YzO1vzBiB1XD2UZuhAyofAVwLnASwXJVPcC5DG+6rrY+8gMS+hy rVYr1DjGHGam0yDcDK1KzgYGxKlchg+oeQ6OWNtlU7KDiPwkViEL2bd1cAII3oM= X-Google-Smtp-Source: AGHT+IEuVqr7vAPRyxsPi49PFNqWl5DSKnIEvhUozJ1PVrnSPX2EIlRX+Aqw6wjznRQ9Dov91P/Otw== X-Received: by 2002:a05:600c:896:b0:426:5216:3254 with SMTP id 5b1f17b1804b1-426708f1eebmr46095795e9.32.1720628739886; Wed, 10 Jul 2024 09:25:39 -0700 (PDT) Received: from toaster.lan ([2a01:e0a:3c5:5fb1:1c99:6356:8466:36cf]) by smtp.googlemail.com with ESMTPSA id 5b1f17b1804b1-4266f6e09e5sm88693815e9.5.2024.07.10.09.25.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 10 Jul 2024 09:25:39 -0700 (PDT) From: Jerome Brunet To: Philipp Zabel , Stephen Boyd , Neil Armstrong Cc: Jerome Brunet , Jan Dakinevich , linux-kernel@vger.kernel.org, linux-amlogic@lists.infradead.org, linux-clk@vger.kernel.org Subject: [PATCH 3/8] reset: amlogic: split the device and platform probe Date: Wed, 10 Jul 2024 18:25:12 +0200 Message-ID: <20240710162526.2341399-4-jbrunet@baylibre.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240710162526.2341399-1-jbrunet@baylibre.com> References: <20240710162526.2341399-1-jbrunet@baylibre.com> Precedence: bulk X-Mailing-List: linux-clk@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Patchwork-Bot: notify To prepare the addition of the auxiliary device support, split out the device probe from the probe of the platform device. The device probe will be common to both the platform and auxiliary driver. Signed-off-by: Jerome Brunet --- drivers/reset/reset-meson.c | 55 +++++++++++++++++++++++-------------- 1 file changed, 34 insertions(+), 21 deletions(-) diff --git a/drivers/reset/reset-meson.c b/drivers/reset/reset-meson.c index 59126c9f194a..fec55321b52b 100644 --- a/drivers/reset/reset-meson.c +++ b/drivers/reset/reset-meson.c @@ -87,6 +87,27 @@ static const struct reset_control_ops meson_reset_ops = { .deassert = meson_reset_deassert, }; +static int meson_reset_probe(struct device *dev, struct regmap *map, + const struct meson_reset_param *param) +{ + unsigned int stride = regmap_get_reg_stride(map); + struct meson_reset *data; + + data = devm_kzalloc(dev, sizeof(*data), GFP_KERNEL); + if (!data) + return -ENOMEM; + + data->param = param; + data->map = map; + data->rcdev.owner = dev->driver->owner; + data->rcdev.nr_resets = param->reg_count * BITS_PER_BYTE + * stride; + data->rcdev.ops = &meson_reset_ops; + data->rcdev.of_node = dev->of_node; + + return devm_reset_controller_register(dev, &data->rcdev); +} + static const struct meson_reset_param meson8b_param = { .reg_count = 8, .reset_offset = 0x0, @@ -125,46 +146,38 @@ static const struct regmap_config regmap_config = { .reg_stride = 4, }; -static int meson_reset_probe(struct platform_device *pdev) +static int meson_reset_pltf_probe(struct platform_device *pdev) { + + const struct meson_reset_param *param; struct device *dev = &pdev->dev; - struct meson_reset *data; + struct regmap *map; void __iomem *base; - data = devm_kzalloc(dev, sizeof(*data), GFP_KERNEL); - if (!data) - return -ENOMEM; - base = devm_platform_ioremap_resource(pdev, 0); if (IS_ERR(base)) return PTR_ERR(base); - data->param = of_device_get_match_data(dev); - if (!data->param) + param = of_device_get_match_data(dev); + if (!param) return -ENODEV; - data->map = devm_regmap_init_mmio(dev, base, ®map_config); - if (IS_ERR(data->map)) - return dev_err_probe(dev, PTR_ERR(data->map), + map = devm_regmap_init_mmio(dev, base, ®map_config); + if (IS_ERR(map)) + return dev_err_probe(dev, PTR_ERR(map), "can't init regmap mmio region\n"); - data->rcdev.owner = THIS_MODULE; - data->rcdev.nr_resets = data->param->reg_count * BITS_PER_BYTE - * regmap_config.reg_stride; - data->rcdev.ops = &meson_reset_ops; - data->rcdev.of_node = dev->of_node; - - return devm_reset_controller_register(dev, &data->rcdev); + return meson_reset_probe(dev, map, param); } -static struct platform_driver meson_reset_driver = { - .probe = meson_reset_probe, +static struct platform_driver meson_reset_pltf_driver = { + .probe = meson_reset_pltf_probe, .driver = { .name = "meson_reset", .of_match_table = meson_reset_dt_ids, }, }; -module_platform_driver(meson_reset_driver); +module_platform_driver(meson_reset_pltf_driver); MODULE_DESCRIPTION("Amlogic Meson Reset Controller driver"); MODULE_AUTHOR("Neil Armstrong "); From patchwork Wed Jul 10 16:25:13 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jerome Brunet X-Patchwork-Id: 13729479 Received: from mail-wm1-f51.google.com (mail-wm1-f51.google.com [209.85.128.51]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 293FB194C66 for ; Wed, 10 Jul 2024 16:25:41 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.51 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1720628744; cv=none; b=pXlCiqMvugCaCsq03bC/PejpNr9pP4+fvIuSSL/6oltBz2Pf9PRmDuDtiEQi1iBGo6RjVFParKVmdzeU6vgyXYcN9/jd0UiqJGk4qApx0cu7LVPc3WlFImqB1t0xki+O1NmmjIy/2U/pPUYnL/g9gHpT8cRZUMe/yqbgjSBvRjM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1720628744; c=relaxed/simple; bh=G+dvNYQOBLr+WoKmLXh98J7Aryp0MXfhIBc7+yfe0sM=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=L9qu9ixT2yLa6RNuAWHL5J81WX4Veqaq4/v6TXMj/jXx1OGxdvXFxs0YOEYh5dxB4wnzOwXb8nBgmf2NQRUle9pkg7zANV1vE4jwVkF+zTo14qWZd27HQD/KuByouuSHI9YzPQxH/j80wWINWaPRdy4SmaYZlkBfAnsp6VsicNo= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=baylibre.com; spf=pass smtp.mailfrom=baylibre.com; dkim=pass (2048-bit key) header.d=baylibre-com.20230601.gappssmtp.com header.i=@baylibre-com.20230601.gappssmtp.com header.b=cfiw1nN2; arc=none smtp.client-ip=209.85.128.51 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=baylibre.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=baylibre.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=baylibre-com.20230601.gappssmtp.com header.i=@baylibre-com.20230601.gappssmtp.com header.b="cfiw1nN2" Received: by mail-wm1-f51.google.com with SMTP id 5b1f17b1804b1-4266b1f1b21so22067215e9.1 for ; Wed, 10 Jul 2024 09:25:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20230601.gappssmtp.com; s=20230601; t=1720628740; x=1721233540; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=ypBfZt6woLl48yZMYWLwJnxD1n063j94AW3SXRtrghk=; b=cfiw1nN2l+n0NtGqQDbJ78cuqjAZbQIuvGBIa05C8RKg2q6Xhj4mMtYMgmuwzaR5xw c0QnUva/2XNWm8s06iYu6i4xDhqSNczZlrbl7yuuJi2L3q3z0S8E6zphmpsYLhNMf04k kvhRxSbL+8bB8FJEKHYgCNOdA1zDkhzS0F9Qe5J2X+UeFYOZYgI87YDSIWumEBzg67s2 6r61/KeAUAf0LCmWPgEVO5qxF9Ogs2uAoY40n9HP6gLaauCAwtOVfxNi4d9HaB9CDVhE saMLWpjnmLMlkwwOJnwm2Bgl4UMdR2byaDHY2f8nbKlHzGcxC4sc33/OAPOi4cREHAX0 QqoQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1720628740; x=1721233540; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=ypBfZt6woLl48yZMYWLwJnxD1n063j94AW3SXRtrghk=; b=LOZmyEZoQG8uND3Zcfu3kLXyFF1yqbxDoUTn5TJSY6/KCcvmP6/NQH3Z5PwwCMbHVD yncRyfVDDVEnYqvFuY1wkbmQ26hFz7mOzDwE0EznNw9rkMot+//3a2gv1A5lU/Kd7+kq 95fjQBY19nfhBljqs4Jvsw2fUqrMU8R89eAsWpQY6E1TROmB8Zf+vw6b+4aFltMfq0sU Fi9KnBDbc3del+0CGAQDj7t1dQkvcJPGjJ81ftS5KZT9q/Deju2EA1gzhcB662c9l75z YGcz64K5scoSXQgvLISG6vy+BIaPUU0MSbbzIgz9aVRb4f+U3ZSLTKv2GaSSdV6IsEou d4bw== X-Forwarded-Encrypted: i=1; AJvYcCXhwQfRRbamXherdS67MQN08K0aXroKd2b6ZI+UEyIY3gMfdI9jcs6E4yo/wouL5RMgjLm0Mh0TKJ8SNuFBOASMVQx+htdDcKkY X-Gm-Message-State: AOJu0YxmqZo0iCODrtJ9WRQOwnWa/0ZEWkc47qKqfuiAGdHzyPt9l8sn tqKRwDkGyJ4G+Se6hV3LXiMWi9MOfFImgvzbZFUMQxvKPX1CMagkJw9kFsbbm4M= X-Google-Smtp-Source: AGHT+IEY6Gw5O2963Scyj/oRKu7QUIVR4X1flEdWrgEg+3YfHL8aVdfzQffvR8CC//15Yu303pOoSg== X-Received: by 2002:a05:600c:63c7:b0:426:5f0b:a49b with SMTP id 5b1f17b1804b1-426707e360fmr36598765e9.23.1720628740679; Wed, 10 Jul 2024 09:25:40 -0700 (PDT) Received: from toaster.lan ([2a01:e0a:3c5:5fb1:1c99:6356:8466:36cf]) by smtp.googlemail.com with ESMTPSA id 5b1f17b1804b1-4266f6e09e5sm88693815e9.5.2024.07.10.09.25.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 10 Jul 2024 09:25:40 -0700 (PDT) From: Jerome Brunet To: Philipp Zabel , Stephen Boyd , Neil Armstrong Cc: Jerome Brunet , Jan Dakinevich , linux-kernel@vger.kernel.org, linux-amlogic@lists.infradead.org, linux-clk@vger.kernel.org Subject: [PATCH 4/8] reset: amlogic: use reset number instead of register count Date: Wed, 10 Jul 2024 18:25:13 +0200 Message-ID: <20240710162526.2341399-5-jbrunet@baylibre.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240710162526.2341399-1-jbrunet@baylibre.com> References: <20240710162526.2341399-1-jbrunet@baylibre.com> Precedence: bulk X-Mailing-List: linux-clk@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Patchwork-Bot: notify The reset driver from audio clock controller may register less reset than a register can hold. To avoid making any change while switching to auxiliary support, use the number of reset instead of the register count to define the bounds of the reset controller. Signed-off-by: Jerome Brunet --- drivers/reset/reset-meson.c | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/drivers/reset/reset-meson.c b/drivers/reset/reset-meson.c index fec55321b52b..3e0447366ba6 100644 --- a/drivers/reset/reset-meson.c +++ b/drivers/reset/reset-meson.c @@ -17,7 +17,7 @@ #include struct meson_reset_param { - int reg_count; + unsigned int reset_num; int reset_offset; int level_offset; bool level_low_reset; @@ -90,7 +90,6 @@ static const struct reset_control_ops meson_reset_ops = { static int meson_reset_probe(struct device *dev, struct regmap *map, const struct meson_reset_param *param) { - unsigned int stride = regmap_get_reg_stride(map); struct meson_reset *data; data = devm_kzalloc(dev, sizeof(*data), GFP_KERNEL); @@ -100,8 +99,7 @@ static int meson_reset_probe(struct device *dev, struct regmap *map, data->param = param; data->map = map; data->rcdev.owner = dev->driver->owner; - data->rcdev.nr_resets = param->reg_count * BITS_PER_BYTE - * stride; + data->rcdev.nr_resets = param->reset_num; data->rcdev.ops = &meson_reset_ops; data->rcdev.of_node = dev->of_node; @@ -109,21 +107,21 @@ static int meson_reset_probe(struct device *dev, struct regmap *map, } static const struct meson_reset_param meson8b_param = { - .reg_count = 8, + .reset_num = 256, .reset_offset = 0x0, .level_offset = 0x7c, .level_low_reset = true, }; static const struct meson_reset_param meson_a1_param = { - .reg_count = 3, + .reset_num = 96, .reset_offset = 0x0, .level_offset = 0x40, .level_low_reset = true, }; static const struct meson_reset_param meson_s4_param = { - .reg_count = 6, + .reset_num = 192, .reset_offset = 0x0, .level_offset = 0x40, .level_low_reset = true, From patchwork Wed Jul 10 16:25:14 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jerome Brunet X-Patchwork-Id: 13729480 Received: from mail-lj1-f175.google.com (mail-lj1-f175.google.com [209.85.208.175]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 51F03194C94 for ; Wed, 10 Jul 2024 16:25:43 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.208.175 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1720628745; cv=none; b=QkE/LdRXfCPignnJq+YYipmuSgjX4VCr3WYskpez8jyHb+uyvw/sSTAViKAoRIUUhoGLc2QcDYZedyRkZMxhAalMLme936ee9Mi3rDuKqmCodxqI8YcoFnKEpWUrWOTItnM+was74ZNTFGxXSUuaeNvv6QxAmQxi0XZjBqD53iA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1720628745; c=relaxed/simple; bh=Aw+qOfPBAhV3Wh+oUUeS3SfuDDbpI8Ih1xiyhtsZ7/U=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Aoa1HNVe97nlTX3NXQLLJaztrO98GTLWDVtRa8Z4PvoUiexQg+8zQvGjulvz8RIBDTePXCOHPeNxTs6MoPahRyFIkWpinoDteq0hrK07lsO6RyLoAxWf0vmvv4amfV9vB0xYdcRrtKlmOzfxO0mdFmtbeszbeTSqtGWR4KEWF3A= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=baylibre.com; spf=pass smtp.mailfrom=baylibre.com; dkim=pass (2048-bit key) header.d=baylibre-com.20230601.gappssmtp.com header.i=@baylibre-com.20230601.gappssmtp.com header.b=fQlilCJg; arc=none smtp.client-ip=209.85.208.175 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=baylibre.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=baylibre.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=baylibre-com.20230601.gappssmtp.com header.i=@baylibre-com.20230601.gappssmtp.com header.b="fQlilCJg" Received: by mail-lj1-f175.google.com with SMTP id 38308e7fff4ca-2eec7e43229so933441fa.3 for ; Wed, 10 Jul 2024 09:25:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20230601.gappssmtp.com; s=20230601; t=1720628741; x=1721233541; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=pscEsLCW2+xzc/V+pxCdqIstr838YuHky5BjadKIhsg=; b=fQlilCJgsnJrT41FPRSbcJpkoaM1cWudDFazfemBhyXsvNp5iNLTbQOAaoWsBYwPKu J/P5R9KEwhrWtzqNDaS+gdb8gH5dk2ej+ooffFVdtNjY2/IIvg5adTm50SEdgyrTAQ4U MfJmpBLW5Opy42Vp8nBgEh2phSSjYOxvxTef/U11hUYsPlgfPThyjDfLF7B+rbyuZMuf WqpL1vuOfiEEjfQyOsaWWZSDYs3oQWoUyvSumw8ja/doTw8kPBej712VW5CQKZ7rjg6Y 9vIKRRmZ0qWuiwrlxq0mWF7au0Z0cj4u/FgLPLlYU8SsPAJ7aTQxYlZl2acFqwMgxJiS d4fQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1720628741; x=1721233541; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=pscEsLCW2+xzc/V+pxCdqIstr838YuHky5BjadKIhsg=; b=MTA0UXWHmjE3lhKQLpIYGbvA5IV5E1oYOkJWQhWhXUGXKANva6kh/OZNmBsa93Q718 AmXsMLK27Hy3uKNgdbNd5H/I9+ykDZpcZGB5GoxOby5YoL9m9J39uqZkr1hzvNHjirnQ ijuBMRgWr0ztY1zTkqLC38X6w1/Zaxx6CZYgXpJcbkAdeE52jyB+FHTOPwpeOHyEqXHy /bPHK1fAecqMeApxy+9Ksio9ZfCsOfhF/g1w1wcTCd5QK8b1C+nJ28IrntEhSQpKBStf oUihQi75eTsUEeWPTYZN64efKSAeibhPMGOY+6NEuHR8IW7x6no0IO0pdf67ImGarCr5 eeZQ== X-Forwarded-Encrypted: i=1; AJvYcCXGsxwjV/Qygg8T42F8VxrKNwp5Kz44rDKr2ky7roqU2AqyistYcu5om5STcYuq7YBJ/vYTf/jwxfieI+c+kNdxICC1GsEAffsc X-Gm-Message-State: AOJu0YzPdgFBrSSMXmkIxqwoEpFI7AWcbis6SudXCqr5ImLZz20j3UH+ GiPkRkBPPr20gcuSTx4TUvtVtWrHZPy+BZgLOiw+UEMDy6hGhDI7qODwjefH2DU= X-Google-Smtp-Source: AGHT+IFIOpVSt5nlbmui7fixIPX2FqGConbERPv2cHi/A6AIyFf4bo75VDo2gZeMvyu3iyHJ9ZWGTg== X-Received: by 2002:a2e:3315:0:b0:2ec:543a:b629 with SMTP id 38308e7fff4ca-2eeb318a0f7mr39237081fa.34.1720628741455; Wed, 10 Jul 2024 09:25:41 -0700 (PDT) Received: from toaster.lan ([2a01:e0a:3c5:5fb1:1c99:6356:8466:36cf]) by smtp.googlemail.com with ESMTPSA id 5b1f17b1804b1-4266f6e09e5sm88693815e9.5.2024.07.10.09.25.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 10 Jul 2024 09:25:41 -0700 (PDT) From: Jerome Brunet To: Philipp Zabel , Stephen Boyd , Neil Armstrong Cc: Jerome Brunet , Jan Dakinevich , linux-kernel@vger.kernel.org, linux-amlogic@lists.infradead.org, linux-clk@vger.kernel.org Subject: [PATCH 5/8] reset: amlogic: add reset status support Date: Wed, 10 Jul 2024 18:25:14 +0200 Message-ID: <20240710162526.2341399-6-jbrunet@baylibre.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240710162526.2341399-1-jbrunet@baylibre.com> References: <20240710162526.2341399-1-jbrunet@baylibre.com> Precedence: bulk X-Mailing-List: linux-clk@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Patchwork-Bot: notify Add a callback to check the status of the level reset, as done in the reset driver of the audio clock controller. Signed-off-by: Jerome Brunet --- drivers/reset/reset-meson.c | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/drivers/reset/reset-meson.c b/drivers/reset/reset-meson.c index 3e0447366ba6..65ba9190cb53 100644 --- a/drivers/reset/reset-meson.c +++ b/drivers/reset/reset-meson.c @@ -69,6 +69,23 @@ static int meson_reset_level(struct reset_controller_dev *rcdev, BIT(bit), assert ? BIT(bit) : 0); } +static int meson_reset_status(struct reset_controller_dev *rcdev, + unsigned long id) +{ + struct meson_reset *data = + container_of(rcdev, struct meson_reset, rcdev); + unsigned int val, offset, bit; + + meson_reset_offset_and_bit(data, id, &offset, &bit); + offset += data->param->level_offset; + + regmap_read(data->map, offset, &val); + val = !!(BIT(bit) & val); + + + return val ^ data->param->level_low_reset; +} + static int meson_reset_assert(struct reset_controller_dev *rcdev, unsigned long id) { @@ -85,6 +102,7 @@ static const struct reset_control_ops meson_reset_ops = { .reset = meson_reset_reset, .assert = meson_reset_assert, .deassert = meson_reset_deassert, + .status = meson_reset_status, }; static int meson_reset_probe(struct device *dev, struct regmap *map, From patchwork Wed Jul 10 16:25:15 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jerome Brunet X-Patchwork-Id: 13729481 Received: from mail-lf1-f48.google.com (mail-lf1-f48.google.com [209.85.167.48]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id E00531953AD for ; Wed, 10 Jul 2024 16:25:43 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.167.48 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1720628745; cv=none; b=XQxcCAqiFoFUm0toteQYarbQ+KYWW7dLkD8Haown0Lij86EPUmTgCqFE3YlUFZHz8ID9ooMrNjDwE+2a2te3NWad5bM23eWBCRoFbyUGCP42YSWgdmH5v4ufHDNWFFF3SgBv+Vn64qay1zzv6Y7nVpuY2D8THj/sATl98gnX3G0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1720628745; c=relaxed/simple; bh=tGtxQtR7HQ0uRAG9sLpag+dAG8Y70atmcVnT7vJqVsw=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=iZAvke8oKVD9pysFlwLUOASi9CrrCGbnnTHBLtH0p5cPiZ/Ntw3EAsY4iBXIyOt5p9E65K5wzFgljjVbHJR3CqiS/b68utFVKz8qK86gWDjUG0QsB8JFogDzMIVjsXGpVquRzxOmwsw8bc16t2RFdf4Ogy9L/rvPblF7kQJkaX8= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=baylibre.com; spf=pass smtp.mailfrom=baylibre.com; dkim=pass (2048-bit key) header.d=baylibre-com.20230601.gappssmtp.com header.i=@baylibre-com.20230601.gappssmtp.com header.b=eHNRRPSK; arc=none smtp.client-ip=209.85.167.48 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=baylibre.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=baylibre.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=baylibre-com.20230601.gappssmtp.com header.i=@baylibre-com.20230601.gappssmtp.com header.b="eHNRRPSK" Received: by mail-lf1-f48.google.com with SMTP id 2adb3069b0e04-52e9f863c46so7116660e87.1 for ; Wed, 10 Jul 2024 09:25:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20230601.gappssmtp.com; s=20230601; t=1720628742; x=1721233542; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=zRHJOwdVIwklQU4oj6tmH8SkcGKM9hDuvtKA2hq20zY=; b=eHNRRPSKr4nKOK+kMBlBy+RrxmqHaiKL9GRHi9AsE2xXNYaSl3BP2oY1jLin2hktQ7 +mIf8iJLANSRNySqbW9kVLUWsPddAONB/jgI3URN9MoTVaolhSD61CWsN3YAxOBvYWYN Z+mTPbsJ5ck8Ha/YhQTr53El49pZMihP3IBEaDzwl01eyxlItJqSUdw8HXv9WK/yoYFV Xn5eE4iGooAOtkstA3jkUdbg5oa+KOrMF0/cKry9LRbrW3KMKJLei7RGM0V1B4YkH0KH 94Xx1r8abDZp/j+/B8+2sUhGfwj8HUa3Wn+XJS1mtTc1D//AmYxe0zIhawVvp7G6nfNl idAw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1720628742; x=1721233542; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=zRHJOwdVIwklQU4oj6tmH8SkcGKM9hDuvtKA2hq20zY=; b=Nmkb6jvCDWgHRuocYUW8KXNXJX9R0ZruUfzUs5Nrk+VUCGeklR9As9DXW9X0ky6m/C U12Z/qaFueoq05Y7tt/2p8A9I/1voMIO2tGRx03hV7RPqrT7H9zYyS+BPpc7ffhLSNbR Ja0vrTrKa4c6/zCYI1srEDcE5pytJbjcMUm1M+kptcrjMZS/3Un6tWmVIdAeUuJ2rIKw wr/ApFCTeLdKP5fEE9PC2i/DxHXcZdkCrZYp7I02sWO12BGgnpKO6WNBHrBZDirlIgl+ f9YYkmmk4wmd2CXDwy7N4wCKE4t43LA12T09Y8SRAyYsah9/njMMk2i3akZlG1ubx09h pG4w== X-Forwarded-Encrypted: i=1; AJvYcCU4eOhoCEytzpgiFxBW1a+fOwdRWpRszjFt2ue/H+cOTH6IWqLcJT3/ALhdae0Q058QGdIJZGOa9mvtrp8YJHuTbzuhc1xhsbRd X-Gm-Message-State: AOJu0YwalzswvFHTbYTdz6x2fmwyij8OHNV5ZlTR2slpXrZ1mK4FQNQ5 Cpy4uYxgtBmKhpxJlJArfKhBUvQkWSEC+wk133ssc9l7P9NR316gKgpZ7XCs1Ei4ugeAgBn5Rcp WNhA= X-Google-Smtp-Source: AGHT+IGoeOCZklKr0/1tvlfZaKQ+3YXN1j9s6sBPZnGkb/G0RZztUbY1oN6KCwJUbQaOeD8WjqbHnw== X-Received: by 2002:a05:6512:108c:b0:52e:9480:9e71 with SMTP id 2adb3069b0e04-52eb9996055mr3907030e87.28.1720628742241; Wed, 10 Jul 2024 09:25:42 -0700 (PDT) Received: from toaster.lan ([2a01:e0a:3c5:5fb1:1c99:6356:8466:36cf]) by smtp.googlemail.com with ESMTPSA id 5b1f17b1804b1-4266f6e09e5sm88693815e9.5.2024.07.10.09.25.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 10 Jul 2024 09:25:41 -0700 (PDT) From: Jerome Brunet To: Philipp Zabel , Stephen Boyd , Neil Armstrong Cc: Jerome Brunet , Jan Dakinevich , linux-kernel@vger.kernel.org, linux-amlogic@lists.infradead.org, linux-clk@vger.kernel.org Subject: [PATCH 6/8] reset: amlogic: add toggle reset support Date: Wed, 10 Jul 2024 18:25:15 +0200 Message-ID: <20240710162526.2341399-7-jbrunet@baylibre.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240710162526.2341399-1-jbrunet@baylibre.com> References: <20240710162526.2341399-1-jbrunet@baylibre.com> Precedence: bulk X-Mailing-List: linux-clk@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Patchwork-Bot: notify Add the emulation for the reset callback using level reset if reset is not directly supported. This is done to keep the functionality of reset driver of audio clock controller. This is expected to work by the related reset consumers. Signed-off-by: Jerome Brunet --- drivers/reset/reset-meson.c | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/drivers/reset/reset-meson.c b/drivers/reset/reset-meson.c index 65ba9190cb53..e34a10b15593 100644 --- a/drivers/reset/reset-meson.c +++ b/drivers/reset/reset-meson.c @@ -17,6 +17,7 @@ #include struct meson_reset_param { + const struct reset_control_ops *reset_ops; unsigned int reset_num; int reset_offset; int level_offset; @@ -98,6 +99,18 @@ static int meson_reset_deassert(struct reset_controller_dev *rcdev, return meson_reset_level(rcdev, id, false); } +static int meson_reset_level_toggle(struct reset_controller_dev *rcdev, + unsigned long id) +{ + int ret; + + ret = meson_reset_assert(rcdev, id); + if (ret) + return ret; + + return meson_reset_deassert(rcdev, id); +} + static const struct reset_control_ops meson_reset_ops = { .reset = meson_reset_reset, .assert = meson_reset_assert, @@ -105,6 +118,13 @@ static const struct reset_control_ops meson_reset_ops = { .status = meson_reset_status, }; +static const struct reset_control_ops meson_reset_toggle_ops = { + .reset = meson_reset_level_toggle, + .assert = meson_reset_assert, + .deassert = meson_reset_deassert, + .status = meson_reset_status, +}; + static int meson_reset_probe(struct device *dev, struct regmap *map, const struct meson_reset_param *param) { @@ -118,13 +138,14 @@ static int meson_reset_probe(struct device *dev, struct regmap *map, data->map = map; data->rcdev.owner = dev->driver->owner; data->rcdev.nr_resets = param->reset_num; - data->rcdev.ops = &meson_reset_ops; + data->rcdev.ops = param->reset_ops; data->rcdev.of_node = dev->of_node; return devm_reset_controller_register(dev, &data->rcdev); } static const struct meson_reset_param meson8b_param = { + .reset_ops = &meson_reset_ops, .reset_num = 256, .reset_offset = 0x0, .level_offset = 0x7c, @@ -132,6 +153,7 @@ static const struct meson_reset_param meson8b_param = { }; static const struct meson_reset_param meson_a1_param = { + .reset_ops = &meson_reset_ops, .reset_num = 96, .reset_offset = 0x0, .level_offset = 0x40, @@ -139,6 +161,7 @@ static const struct meson_reset_param meson_a1_param = { }; static const struct meson_reset_param meson_s4_param = { + .reset_ops = &meson_reset_ops, .reset_num = 192, .reset_offset = 0x0, .level_offset = 0x40, From patchwork Wed Jul 10 16:25:16 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jerome Brunet X-Patchwork-Id: 13729482 Received: from mail-lf1-f54.google.com (mail-lf1-f54.google.com [209.85.167.54]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id D97FF194C85 for ; Wed, 10 Jul 2024 16:25:44 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.167.54 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1720628748; cv=none; b=eBKXAqk64KIpMmZIVbT3CyKLgzGqa/fuU7tc5wdr5dlFwC4ejO/QeIbbathMK9gKK+5ybdDKZFqsv9veWLgKn2GJa+cEUYxQ8mHe0OJmyrLk5w6/5FwcqrtEbYPVb+cEdkre54gxtNGjheEJ+tuX/IJZAPMSh6RyRaGXoWYJ908= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1720628748; c=relaxed/simple; bh=WiThtGmde5VQBxumF8xA9V+0PcE0mtIDwrP//zliULw=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=EpJgnEV0xO/70eYzGo6nmn/QLswhtEMHn3wSspirv7EGBiWTJJj1tkLbdvvuYaRLKbnsL9JYT5TOkuipSPWEujCsyjFEa/qK0pObsiFjMxjS7eNNouIS3PkTiMwjGE/WUfLD75Y+B/sgb3eMsk3AT4f6WG8ihiD2rHpW+0rc9d8= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=baylibre.com; spf=pass smtp.mailfrom=baylibre.com; dkim=pass (2048-bit key) header.d=baylibre-com.20230601.gappssmtp.com header.i=@baylibre-com.20230601.gappssmtp.com header.b=sqSBuULB; arc=none smtp.client-ip=209.85.167.54 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=baylibre.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=baylibre.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=baylibre-com.20230601.gappssmtp.com header.i=@baylibre-com.20230601.gappssmtp.com header.b="sqSBuULB" Received: by mail-lf1-f54.google.com with SMTP id 2adb3069b0e04-52ea33671ffso6122544e87.3 for ; Wed, 10 Jul 2024 09:25:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20230601.gappssmtp.com; s=20230601; t=1720628743; x=1721233543; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=IARsI+FI+i+eKGJY1BDsgLjfmpMAYd8+oKcq4aFTD8I=; b=sqSBuULBEsT0mSQKQKiNW27xScfS6AeocnkffN8QHm/hcFfqMA804ngGnpUT+fo8J2 JA3UHHa32S8K/c6MNZWNRi3J5h/chPbRCOx3pKBkUX4UD32OByX3JuwKJMDEFFNWaiMB l1bqDFy++3dV2Tw4f/pVlL13SdwubPisGsj1KjNn1ieF0x5s5ZhxJQxQYya1b0PKdUjs bY3dT4MJEtDabq6vREmwDnC4a+7JS5jvVw3WY5fuLzMGCqh41ajRB9G9wy8XSonJrp8t mWI26q1QcEvF3ubGCWqtW8tuDewYm1Z6RWjzrrCHJ9rOUpWcU4MqMctw4UZn7SlQgFKB 2DkA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1720628743; x=1721233543; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=IARsI+FI+i+eKGJY1BDsgLjfmpMAYd8+oKcq4aFTD8I=; b=O634SHgxxb9O/qDGSMp/QjQtZ1P3vlOKSc32D+neSs7z3C73nMfeqYD1/xqrJ5vHvI yIe1K14q21sG5zgfgKQr5wii2+XLaxlAAvBvo2fUEfrW5a6J4rtaxXAh0zmFCdqs7D/U yyLGzfzEuHu8WUIALph0UM7smOa8/6X/pInheehqvtN9h4F45X/9SfEw3IygTmdQ4L3P hGK+q4yP2DnODVwQ/8h6RUGnAPg0y66oLrStJV14SdNO2kD3te/moPm5Xb+l2kp9v16O r5ym7DqmhQtLyHCIXi7xOs8bR/LyMNXlJWhZkEgQL7D7g6moWxC5jTbRe/b+LqqXuOxw LvcA== X-Forwarded-Encrypted: i=1; AJvYcCX2RxOvZOovJ6/jggr9FRGMOTyQKZa9LjfzMF8BE0kDuHQKIu/h/kuYIei9TQDgHBhTuCu/pP89PKIXQndMOoD+Bo2W6e4FHtz2 X-Gm-Message-State: AOJu0Yw/YGPk1ROgbs0vdnbv5BntLgOH73garGDT/e8SzPOUwn85JKDl HAwkmao0N6kBXYnJ3E8gqeZBrD1IvxXDy/Qd7/MUURe0xXAnqH/pJN6jxrCtqh4= X-Google-Smtp-Source: AGHT+IEcUV9rflAISGdUtE/xqZPmuLeXR5bEfX8EcOnERF2wu0mjIsOgHuUUJqEcj4imHelJS6s1hg== X-Received: by 2002:a05:6512:39c5:b0:52c:a465:c61f with SMTP id 2adb3069b0e04-52eb99d6e56mr3725342e87.56.1720628743099; Wed, 10 Jul 2024 09:25:43 -0700 (PDT) Received: from toaster.lan ([2a01:e0a:3c5:5fb1:1c99:6356:8466:36cf]) by smtp.googlemail.com with ESMTPSA id 5b1f17b1804b1-4266f6e09e5sm88693815e9.5.2024.07.10.09.25.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 10 Jul 2024 09:25:42 -0700 (PDT) From: Jerome Brunet To: Philipp Zabel , Stephen Boyd , Neil Armstrong Cc: Jerome Brunet , Jan Dakinevich , linux-kernel@vger.kernel.org, linux-amlogic@lists.infradead.org, linux-clk@vger.kernel.org Subject: [PATCH 7/8] reset: amlogic: add auxiliary reset driver support Date: Wed, 10 Jul 2024 18:25:16 +0200 Message-ID: <20240710162526.2341399-8-jbrunet@baylibre.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240710162526.2341399-1-jbrunet@baylibre.com> References: <20240710162526.2341399-1-jbrunet@baylibre.com> Precedence: bulk X-Mailing-List: linux-clk@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Patchwork-Bot: notify Add support for the reset controller present in the audio clock controller of the g12 and sm1 SoC families, using the auxiliary bus. This is expected to replace the driver currently present directly within the related clock driver. Signed-off-by: Jerome Brunet --- drivers/reset/Kconfig | 1 + drivers/reset/reset-meson.c | 121 +++++++++++++++++++- include/soc/amlogic/meson-auxiliary-reset.h | 23 ++++ 3 files changed, 144 insertions(+), 1 deletion(-) create mode 100644 include/soc/amlogic/meson-auxiliary-reset.h diff --git a/drivers/reset/Kconfig b/drivers/reset/Kconfig index 7112f5932609..2a316c469bcc 100644 --- a/drivers/reset/Kconfig +++ b/drivers/reset/Kconfig @@ -134,6 +134,7 @@ config RESET_MCHP_SPARX5 config RESET_MESON tristate "Meson Reset Driver" depends on ARCH_MESON || COMPILE_TEST + select AUXILIARY_BUS default ARCH_MESON help This enables the reset driver for Amlogic Meson SoCs. diff --git a/drivers/reset/reset-meson.c b/drivers/reset/reset-meson.c index e34a10b15593..5cc767d50e8f 100644 --- a/drivers/reset/reset-meson.c +++ b/drivers/reset/reset-meson.c @@ -5,6 +5,7 @@ * Copyright (c) 2016 BayLibre, SAS. * Author: Neil Armstrong */ +#include #include #include #include @@ -16,6 +17,10 @@ #include #include +#include + +static DEFINE_IDA(meson_rst_aux_ida); + struct meson_reset_param { const struct reset_control_ops *reset_ops; unsigned int reset_num; @@ -30,6 +35,14 @@ struct meson_reset { struct regmap *map; }; +struct meson_reset_adev { + struct auxiliary_device adev; + struct regmap *map; +}; + +#define to_meson_reset_adev(_adev) \ + container_of((_adev), struct meson_reset_adev, adev) + static void meson_reset_offset_and_bit(struct meson_reset *data, unsigned long id, unsigned int *offset, @@ -218,6 +231,112 @@ static struct platform_driver meson_reset_pltf_driver = { }; module_platform_driver(meson_reset_pltf_driver); -MODULE_DESCRIPTION("Amlogic Meson Reset Controller driver"); +static const struct meson_reset_param meson_g12a_audio_param = { + .reset_ops = &meson_reset_toggle_ops, + .reset_num = 26, + .level_offset = 0x24, +}; + +static const struct meson_reset_param meson_sm1_audio_param = { + .reset_ops = &meson_reset_toggle_ops, + .reset_num = 39, + .level_offset = 0x28, +}; + +static const struct auxiliary_device_id meson_reset_aux_ids[] = { + { + .name = "axg-audio-clkc.rst-g12a", + .driver_data = (kernel_ulong_t)&meson_g12a_audio_param, + }, { + .name = "axg-audio-clkc.rst-sm1", + .driver_data = (kernel_ulong_t)&meson_sm1_audio_param, + }, +}; +MODULE_DEVICE_TABLE(auxiliary, meson_reset_aux_ids); + +static int meson_reset_aux_probe(struct auxiliary_device *adev, + const struct auxiliary_device_id *id) +{ + const struct meson_reset_param *param = + (const struct meson_reset_param *)(id->driver_data); + struct meson_reset_adev *raux = + to_meson_reset_adev(adev); + + return meson_reset_probe(&adev->dev, raux->map, param); +} + +static struct auxiliary_driver meson_reset_aux_driver = { + .probe = meson_reset_aux_probe, + .id_table = meson_reset_aux_ids, +}; +module_auxiliary_driver(meson_reset_aux_driver); + +static void meson_rst_aux_release(struct device *dev) +{ + struct auxiliary_device *adev = to_auxiliary_dev(dev); + struct meson_reset_adev *raux = + to_meson_reset_adev(adev); + + ida_free(&meson_rst_aux_ida, adev->id); + kfree(raux); +} + +static void meson_rst_aux_unregister_adev(void *_adev) +{ + struct auxiliary_device *adev = _adev; + + auxiliary_device_delete(adev); + auxiliary_device_uninit(adev); +} + +int devm_meson_rst_aux_register(struct device *dev, + struct regmap *map, + const char *adev_name) +{ + struct meson_reset_adev *raux; + struct auxiliary_device *adev; + int ret; + + raux = kzalloc(sizeof(*raux), GFP_KERNEL); + if (!raux) + return -ENOMEM; + + ret = ida_alloc(&meson_rst_aux_ida, GFP_KERNEL); + if (ret < 0) + goto raux_free; + + raux->map = map; + + adev = &raux->adev; + adev->id = ret; + adev->name = adev_name; + adev->dev.parent = dev; + adev->dev.release = meson_rst_aux_release; + device_set_of_node_from_dev(&adev->dev, dev); + + ret = auxiliary_device_init(adev); + if (ret) + goto ida_free; + + ret = __auxiliary_device_add(adev, dev->driver->name); + if (ret) { + auxiliary_device_uninit(adev); + return ret; + } + + return devm_add_action_or_reset(dev, meson_rst_aux_unregister_adev, + adev); + +ida_free: + ida_free(&meson_rst_aux_ida, adev->id); +raux_free: + kfree(raux); + return ret; + +} +EXPORT_SYMBOL_GPL(devm_meson_rst_aux_register); + +MODULE_DESCRIPTION("Amlogic Meson Reset driver"); MODULE_AUTHOR("Neil Armstrong "); +MODULE_AUTHOR("Jerome Brunet "); MODULE_LICENSE("Dual BSD/GPL"); diff --git a/include/soc/amlogic/meson-auxiliary-reset.h b/include/soc/amlogic/meson-auxiliary-reset.h new file mode 100644 index 000000000000..8fdb02b18d8c --- /dev/null +++ b/include/soc/amlogic/meson-auxiliary-reset.h @@ -0,0 +1,23 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +#ifndef __SOC_AMLOGIC_MESON_AUX_RESET_H +#define __SOC_AMLOGIC_MESON_AUX_RESET_H + +#include + +struct device; +struct regmap; + +#ifdef CONFIG_RESET_MESON +int devm_meson_rst_aux_register(struct device *dev, + struct regmap *map, + const char *adev_name); +#else +static inline int devm_meson_rst_aux_register(struct device *dev, + struct regmap *map, + const char *adev_name) +{ + return -EOPNOTSUPP; +} +#endif + +#endif /* __SOC_AMLOGIC_MESON8B_AUX_RESET_H */ From patchwork Wed Jul 10 16:25:17 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jerome Brunet X-Patchwork-Id: 13729483 Received: from mail-wm1-f50.google.com (mail-wm1-f50.google.com [209.85.128.50]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 5A8DA19645C for ; Wed, 10 Jul 2024 16:25:46 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.50 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1720628748; cv=none; b=clfcq86+daf5KqMsyot1pErDdYqzK/iRAxfWtFpnzFwvqbC9T/+aBn/WhWiyerZiurbpMJWgLLqvqGBUgpUTAn0T6/mKHmAoZGs5q+AJxg+AHZr3ectQ+hRdRfnqZMW+SShKqqy+p3qO34o3ghnelvOcuJtA2bE6OF8149/8IWQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1720628748; c=relaxed/simple; bh=q6Lo9F9np38QXthpgPQglkdYejHog0Z9FiVrNEKK5zU=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=aY08epyG5Z3sMAK0CQjgK5fbNXRNbCVhEH7krd3P0juFPGNg6q0IRAhWzkfBtQFwgRQv6/+JviuA6mxGgRJWNKRa0QNDeC6U3XEzHv0Yh0xEnqQj4yeZGU+y1X1EHFFc5mhwmoFOWlmB8T8x/denDnSIjlCw2lvkBbxxXpzTFQI= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=baylibre.com; spf=pass smtp.mailfrom=baylibre.com; dkim=pass (2048-bit key) header.d=baylibre-com.20230601.gappssmtp.com header.i=@baylibre-com.20230601.gappssmtp.com header.b=AxwB1iBz; arc=none smtp.client-ip=209.85.128.50 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=baylibre.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=baylibre.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=baylibre-com.20230601.gappssmtp.com header.i=@baylibre-com.20230601.gappssmtp.com header.b="AxwB1iBz" Received: by mail-wm1-f50.google.com with SMTP id 5b1f17b1804b1-42726d6eca5so10571955e9.1 for ; Wed, 10 Jul 2024 09:25:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20230601.gappssmtp.com; s=20230601; t=1720628745; x=1721233545; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=JWAYmRVC1zdYp+5kEeD3DX2tiXmWy9shCUGw6lB/NDk=; b=AxwB1iBzcIyhdAbvXXjkaV16N69a1RqjvZg5CkB8DOpCAC9s88tG0pDYEgifIWRrz1 TFP/KCepu5iY+kEBcOHFoA7WAhCrJ49TG3xI9t/QG0zM1cfHTv9BqNnswICPD4CnZrqS 5umWasYONrNWKOduOSiNNtXx5di2FeBHDnrKfpan0p5K1hfpv9TVdwEQDOyWFDJgHy29 Tuvg8vtJtsgav2lB4Gj7wKIx9DLmCCk5O+W/TAlPyh+hJ9+7TyZyR6jPpeK4EMMAEMrR oIUcCUpyhj4HCQN7QKQwjJBbSq0AhzX5MH1rvpSxh/h2AAIZS29uILM03t3f8ZLO6jxT Q7oQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1720628745; x=1721233545; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=JWAYmRVC1zdYp+5kEeD3DX2tiXmWy9shCUGw6lB/NDk=; b=rls6e8rmwaUGuDWSVKWDu5xU6u+MSw5CG79oir0qnjLjnaIsgo1wu5LGD+RNOXUnVt sK8OvbUfEztSOuNz6U1iH/NS7H65C18uppJGuj9VRFO08Nq9yL0mBX08SyAO6JbnH8dh ZaFhLpvL6BZxS2zAw5H7x8TdRMjSlkgIF+LI++TOichfeXIXuozIkwBKscplKDPmMeEO K9V5WaDnqdWS8/5r2Ih/aoLlcla97XhWdYymrtI/J5lWEd+8Hiogm5iK5zpfw+sxe5Wj jzRoYVB/oD30oHVWEYYxbIEVCiRAjuiMZPNERkkFvAp/iyBlVcgC1FD4xm+uWHahpkbv m2qg== X-Forwarded-Encrypted: i=1; AJvYcCX2sAxozFQo2XSsoOUConIibvlkEw3u5o9hnWn9Ak2BkEgvugchAF2dtEM3onxOn25qD6yGjb4C/LzDmJKWq/v54N5nlcgdtuWt X-Gm-Message-State: AOJu0YztXg5GoJj8/OiEpHF7NVOOP1LhzXpVPzIdOHpakGZaGef5KdkM I31dG9d5WG1z4eaBQPFnWmRsi5DRL7mJyLI8Z2QTSx+QrcUY9d3gSgOgTjuK9Zw= X-Google-Smtp-Source: AGHT+IGGZi85nj3MyP+JCseFqVZr7mDscU35q6/iFQCn7BlAqB5PjPfA1ynbuw3U8clnF3YPLAROIw== X-Received: by 2002:a05:600c:4930:b0:425:5ec3:570b with SMTP id 5b1f17b1804b1-426708f1f07mr38446345e9.35.1720628744794; Wed, 10 Jul 2024 09:25:44 -0700 (PDT) Received: from toaster.lan ([2a01:e0a:3c5:5fb1:1c99:6356:8466:36cf]) by smtp.googlemail.com with ESMTPSA id 5b1f17b1804b1-4266f6e09e5sm88693815e9.5.2024.07.10.09.25.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 10 Jul 2024 09:25:43 -0700 (PDT) From: Jerome Brunet To: Philipp Zabel , Stephen Boyd , Neil Armstrong Cc: Jerome Brunet , Jan Dakinevich , linux-kernel@vger.kernel.org, linux-amlogic@lists.infradead.org, linux-clk@vger.kernel.org Subject: [PATCH 8/8] clk: amlogic: axg-audio: use the auxiliary reset driver Date: Wed, 10 Jul 2024 18:25:17 +0200 Message-ID: <20240710162526.2341399-9-jbrunet@baylibre.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240710162526.2341399-1-jbrunet@baylibre.com> References: <20240710162526.2341399-1-jbrunet@baylibre.com> Precedence: bulk X-Mailing-List: linux-clk@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Patchwork-Bot: notify Remove the implementation of the reset driver in axg audio clock driver and migrate to the one provided by reset framework on the auxiliary bus Signed-off-by: Jerome Brunet --- drivers/clk/meson/Kconfig | 1 + drivers/clk/meson/axg-audio.c | 109 +++------------------------------- 2 files changed, 10 insertions(+), 100 deletions(-) diff --git a/drivers/clk/meson/Kconfig b/drivers/clk/meson/Kconfig index 78f648c9c97d..b1c0c3ba96c4 100644 --- a/drivers/clk/meson/Kconfig +++ b/drivers/clk/meson/Kconfig @@ -106,6 +106,7 @@ config COMMON_CLK_AXG_AUDIO select COMMON_CLK_MESON_SCLK_DIV select COMMON_CLK_MESON_CLKC_UTILS select REGMAP_MMIO + imply RESET_MESON help Support for the audio clock controller on AmLogic A113D devices, aka axg, Say Y if you want audio subsystem to work. diff --git a/drivers/clk/meson/axg-audio.c b/drivers/clk/meson/axg-audio.c index e03a5bf899c0..6e199e751856 100644 --- a/drivers/clk/meson/axg-audio.c +++ b/drivers/clk/meson/axg-audio.c @@ -15,6 +15,8 @@ #include #include +#include + #include "meson-clkc-utils.h" #include "axg-audio.h" #include "clk-regmap.h" @@ -1648,84 +1650,6 @@ static struct clk_regmap *const sm1_clk_regmaps[] = { &sm1_sysclk_b_en, }; -struct axg_audio_reset_data { - struct reset_controller_dev rstc; - struct regmap *map; - unsigned int offset; -}; - -static void axg_audio_reset_reg_and_bit(struct axg_audio_reset_data *rst, - unsigned long id, - unsigned int *reg, - unsigned int *bit) -{ - unsigned int stride = regmap_get_reg_stride(rst->map); - - *reg = (id / (stride * BITS_PER_BYTE)) * stride; - *reg += rst->offset; - *bit = id % (stride * BITS_PER_BYTE); -} - -static int axg_audio_reset_update(struct reset_controller_dev *rcdev, - unsigned long id, bool assert) -{ - struct axg_audio_reset_data *rst = - container_of(rcdev, struct axg_audio_reset_data, rstc); - unsigned int offset, bit; - - axg_audio_reset_reg_and_bit(rst, id, &offset, &bit); - - regmap_update_bits(rst->map, offset, BIT(bit), - assert ? BIT(bit) : 0); - - return 0; -} - -static int axg_audio_reset_status(struct reset_controller_dev *rcdev, - unsigned long id) -{ - struct axg_audio_reset_data *rst = - container_of(rcdev, struct axg_audio_reset_data, rstc); - unsigned int val, offset, bit; - - axg_audio_reset_reg_and_bit(rst, id, &offset, &bit); - - regmap_read(rst->map, offset, &val); - - return !!(val & BIT(bit)); -} - -static int axg_audio_reset_assert(struct reset_controller_dev *rcdev, - unsigned long id) -{ - return axg_audio_reset_update(rcdev, id, true); -} - -static int axg_audio_reset_deassert(struct reset_controller_dev *rcdev, - unsigned long id) -{ - return axg_audio_reset_update(rcdev, id, false); -} - -static int axg_audio_reset_toggle(struct reset_controller_dev *rcdev, - unsigned long id) -{ - int ret; - - ret = axg_audio_reset_assert(rcdev, id); - if (ret) - return ret; - - return axg_audio_reset_deassert(rcdev, id); -} - -static const struct reset_control_ops axg_audio_rstc_ops = { - .assert = axg_audio_reset_assert, - .deassert = axg_audio_reset_deassert, - .reset = axg_audio_reset_toggle, - .status = axg_audio_reset_status, -}; - static const struct regmap_config axg_audio_regmap_cfg = { .reg_bits = 32, .val_bits = 32, @@ -1737,15 +1661,13 @@ struct audioclk_data { struct clk_regmap *const *regmap_clks; unsigned int regmap_clk_num; struct meson_clk_hw_data hw_clks; - unsigned int reset_offset; - unsigned int reset_num; + const char *rst_drvname; }; static int axg_audio_clkc_probe(struct platform_device *pdev) { struct device *dev = &pdev->dev; const struct audioclk_data *data; - struct axg_audio_reset_data *rst; struct regmap *map; void __iomem *regs; struct clk_hw *hw; @@ -1803,22 +1725,11 @@ static int axg_audio_clkc_probe(struct platform_device *pdev) if (ret) return ret; - /* Stop here if there is no reset */ - if (!data->reset_num) - return 0; - - rst = devm_kzalloc(dev, sizeof(*rst), GFP_KERNEL); - if (!rst) - return -ENOMEM; - - rst->map = map; - rst->offset = data->reset_offset; - rst->rstc.nr_resets = data->reset_num; - rst->rstc.ops = &axg_audio_rstc_ops; - rst->rstc.of_node = dev->of_node; - rst->rstc.owner = THIS_MODULE; + /* Register auxiliary reset driver when applicable */ + if (data->rst_drvname) + ret = devm_meson_rst_aux_register(dev, map, data->rst_drvname); - return devm_reset_controller_register(dev, &rst->rstc); + return ret; } static const struct audioclk_data axg_audioclk_data = { @@ -1837,8 +1748,7 @@ static const struct audioclk_data g12a_audioclk_data = { .hws = g12a_audio_hw_clks, .num = ARRAY_SIZE(g12a_audio_hw_clks), }, - .reset_offset = AUDIO_SW_RESET, - .reset_num = 26, + .rst_drvname = "rst-g12a", }; static const struct audioclk_data sm1_audioclk_data = { @@ -1848,8 +1758,7 @@ static const struct audioclk_data sm1_audioclk_data = { .hws = sm1_audio_hw_clks, .num = ARRAY_SIZE(sm1_audio_hw_clks), }, - .reset_offset = AUDIO_SM1_SW_RESET0, - .reset_num = 39, + .rst_drvname = "rst-sm1", }; static const struct of_device_id clkc_match_table[] = {