Received: by 2002:ab2:6816:0:b0:1f9:5764:f03e with SMTP id t22csp354591lqo; Thu, 16 May 2024 08:10:53 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCXCmYSABpVHQb2cwYuT97HY4lYtxnkjghKrYVhQDF61iqWJaeg9zY2nmEjLwsyklVcaQJyW79Uf8HbkQIsgWrfWzRmos+PH1euspruwIQ== X-Google-Smtp-Source: AGHT+IFdqYpNG+sg6x5FjizaPEGwxKB82u7/Jmm303vW+i1OpPykRyeFk9xpf5qciHRr7rj0ulKa X-Received: by 2002:a17:90a:cf86:b0:2b8:ffa3:f0d7 with SMTP id 98e67ed59e1d1-2b8ffa3fc22mr14473934a91.34.1715872253410; Thu, 16 May 2024 08:10:53 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1715872253; cv=pass; d=google.com; s=arc-20160816; b=CC5HuYJXA8ZNOJeUM771fWGwMqqWx8/654Z5Ez/Nh1W7+759/4NFDGluRbXCI4WcC4 FJXlF1dzMW8Qdl0bKZ5CgNcIt4pNScmbI02dPLSHdJenlalA8+qDwFTJwaDIgaFSmBQx iyEc/nWYOFGlauB0X4ETR6diblTYmbUFgejzKYjiBLKKs0l2gTJjcgOSjUQdO2XhAk9B UWCRLuDLKiya6Nq/c+qk3kbnaHhj97sl/QlkYzbL+x0qY/S0LVPmSToogaEqdQJpCtBi KPlCv0XOU6sx/54pWTxkohjkALKBmkRS7UlMwCMOAlmXaj9Yhks5w4DJM9ysiaUtN9F0 xa7w== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=Zlq2XgSsulaEdUEoiNJy3+0ETTvrLEFhmOVX/TPKWFg=; fh=cTQES+jLV9a7RmSTH4NhtpWJOjuFV2u2aKpBKYnooNw=; b=xrRMIY5cK9xYiQm3xwrKhfKraxXxgv+zbpRc50XNMcTdDHYOyzmeuluzUzCtXS8RO3 3MOowcBKkcbcMxbCgF8ShTVxvNi1QFah0vvFj9gdlnIkueyuEwxyahwMeOSSgp2IoOOd 1E5NB1jqkfImukP+igJ+TiXpGtFjBPbLl1CKGLG3LzDeCF1adCvcWudzeypMTXkR2wCe YxXnCp70lCTNrpSdCVkXQyJ05b4sjqUaQCp1L2KHO+6jLCIPGNOorOIKVSzj0B8ud5aE h3ROJCa3JPYfa4hh4rlC4sDH4stD91k9a6aAQS8FFuriTbaJwx5f71O1uBUU2Ub+o+mG +/Jg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@baylibre-com.20230601.gappssmtp.com header.s=20230601 header.b=p0S5dnGS; arc=pass (i=1 spf=pass spfdomain=baylibre.com dkim=pass dkdomain=baylibre-com.20230601.gappssmtp.com); spf=pass (google.com: domain of linux-kernel+bounces-181205-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-181205-linux.lists.archive=gmail.com@vger.kernel.org" Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [2604:1380:40f1:3f00::1]) by mx.google.com with ESMTPS id 98e67ed59e1d1-2b671471c15si15430631a91.124.2024.05.16.08.10.52 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 16 May 2024 08:10:53 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-181205-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) client-ip=2604:1380:40f1:3f00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@baylibre-com.20230601.gappssmtp.com header.s=20230601 header.b=p0S5dnGS; arc=pass (i=1 spf=pass spfdomain=baylibre.com dkim=pass dkdomain=baylibre-com.20230601.gappssmtp.com); spf=pass (google.com: domain of linux-kernel+bounces-181205-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-181205-linux.lists.archive=gmail.com@vger.kernel.org" Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sy.mirrors.kernel.org (Postfix) with ESMTPS id 4CDD0B22D3A for ; Thu, 16 May 2024 15:09:22 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id A4F5214D705; Thu, 16 May 2024 15:08:54 +0000 (UTC) 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="p0S5dnGS" Received: from mail-lj1-f176.google.com (mail-lj1-f176.google.com [209.85.208.176]) (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 C76C114BFA5 for ; Thu, 16 May 2024 15:08:51 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.208.176 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715872133; cv=none; b=HU7ReLi9pFBzRJl6hqwuwzl8DFxlUk3FnOONcJ0jWJs5tmBLkpi83yrl8cBxR5i63j2kEMwoms5jWmJKL80XChpk+R1Gfg+dHaK7+Yn+2GCrt4rXE5gqGkdc5FMHNuaB7NoOSem1Or3bH3rTexCFYrYk0aTQ4VBN0jM5Ol4i+Ms= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715872133; c=relaxed/simple; bh=GPIkBbQj4IQYkRBMApjzbDefFG1cRgF3e6hKKqXUa84=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=iPWjOWs9rbOn65lW4AarW8HRYZb+koblPkamAnvSvOGs3SjgBfew2SY1Rlni16RIojCVq3FbUAcX+jQw1XEl1pj+6ihNHl23Lm2RHJWkbZZxxGWNLvftApVWdqmHCcbiXOSM0KoQKc/E/nRgZ8UecbCT8etO07l8KqtWkeV/wzM= 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=p0S5dnGS; arc=none smtp.client-ip=209.85.208.176 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 Received: by mail-lj1-f176.google.com with SMTP id 38308e7fff4ca-2db17e8767cso12510971fa.3 for ; Thu, 16 May 2024 08:08:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20230601.gappssmtp.com; s=20230601; t=1715872130; x=1716476930; 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=Zlq2XgSsulaEdUEoiNJy3+0ETTvrLEFhmOVX/TPKWFg=; b=p0S5dnGSdMKtvt45zX7xJfOn2ceBCsFzGZqPG3stB6jWb7rrlM+4+rxT7DlKbC6+sF Ze2uXr2DDZ8TzsgSxICYc0pwUU6CVokQnzW1APxdBYqRIzLG69wsDyud92ge1BRoi4VU HsXXOMd80A8csNv3JU4mNIHyqx2ep6uCAvbcqLzja1N6iOYkx/dhbKsSePcxXFmXQWW2 UyS10NhCMqXFtfjfxTlCzg+nCHV2Ly/SW/W6pL2KpiN8NDP/+XNAKzkPgwxT1Ua7KdXE f2TdCKVTGuPxMnOHsr+KjiMVysnLnPkC+TFeig89Cprqivn0JwMSdgxGjPrBTABQjQO5 A6zA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1715872130; x=1716476930; 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=Zlq2XgSsulaEdUEoiNJy3+0ETTvrLEFhmOVX/TPKWFg=; b=geE9X2PpTksApN60kNhAwmH9bBB+82mB3rajE0Iwm4z8jZVu+d5PwVjbUZ/LmtDigh xWxVbEo9W52iTctyFkf/liepHnmzcaO+6s/iRIl+zdwHaIdo3PqxpyObpDLM2wZT4t/E ESmSINeBFrAoP6r8TnTQFSESibf1LpWjev/6unLAv1PAlR8s9RMIN80rgRqBO1AKeX8X MKZo0zwZ/KLgDceMWIi+dorD/osKvWzwbNtyArQbVV8K8Tx4l6xSKVLYBJJIShZb+Y9W e7jp0o1RsaHIk0aMch/DtShDgo1Zq4You5LTfSdJqnCvdMtz3Lb7O3vZqPPQcVOkDLaZ /nYg== X-Forwarded-Encrypted: i=1; AJvYcCWIHe3nFBsrcEAg+RVYxCYj5mEcjPtxYdzb+T+mGQW00HuhPCsurNeDYpWgQ8l5/ngeGGTo5xW+XUQDvGw8aYsFVD2/DChH8GkHkqZh X-Gm-Message-State: AOJu0Yzv/wTeQOffdPz/rzchntUYFbrZKEJLGE841vAMWn1ldyTQzEfn 6sl7O0Plg+7I1xrcgWhxZ7huO7jTBFbwjuS9wWncNDkm5lKLN4uAhliJlmvUQ8E= X-Received: by 2002:a2e:5112:0:b0:2e6:d2bc:1d18 with SMTP id 38308e7fff4ca-2e6d2bc24e5mr52015521fa.22.1715872129966; Thu, 16 May 2024 08:08:49 -0700 (PDT) Received: from toaster.lan ([2a01:e0a:3c5:5fb1:1fce:7e5a:e201:edd5]) by smtp.googlemail.com with ESMTPSA id 5b1f17b1804b1-41f87c25459sm309351725e9.18.2024.05.16.08.08.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 16 May 2024 08:08:49 -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: [RFC PATCH 3/9] reset: amlogic: split the device and platform probe Date: Thu, 16 May 2024 17:08:33 +0200 Message-ID: <20240516150842.705844-4-jbrunet@baylibre.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240516150842.705844-1-jbrunet@baylibre.com> References: <20240516150842.705844-1-jbrunet@baylibre.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Patchwork-Bot: notify Content-Transfer-Encoding: 8bit To prepare the addition of the auxiliary device support, split 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 "); -- 2.43.0