From patchwork Sun Dec 11 10:39:06 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Ilpo_J=C3=A4rvinen?= X-Patchwork-Id: 32166 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:f944:0:0:0:0:0 with SMTP id q4csp1708994wrr; Sun, 11 Dec 2022 02:40:27 -0800 (PST) X-Google-Smtp-Source: AA0mqf7/Hmf5PPY2K05OVz+MHkSykWkh0G6hqsWIEup7xECxR6fzVJz242K1G4WWV0XfuLBhGW/I X-Received: by 2002:a17:903:4283:b0:189:7100:c50e with SMTP id ju3-20020a170903428300b001897100c50emr12896412plb.48.1670755227148; Sun, 11 Dec 2022 02:40:27 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1670755227; cv=none; d=google.com; s=arc-20160816; b=xfvlpI3cVXlRW9bCkSkN1IXM0wcooDiwS/MRcadD71HAW2YD7f3BPiqx+H9V+d9m3/ sLH17hfAuLkKaiJtGxIneKhbqTekDiWEf9MiQBy8pOorO1QUCegelPajSIU9uc5xkx03 bTzeg5My3eEQuni0rNL5iEbA+QhX9ON087TZp53HVnJUFT4uZ0jHLSlO1/whVEXlaU9j OGp+UZTI2/QH8QsIgkarGpP7RWzXOMBDXdj7COz07vK0UvYM1vvfXVdT+SQ5wiPXc+L9 y9402I64QwspBCX+bxuyBq+0zPZx0tX2vxVIMfqvkVUG7hxz6kTMVGw+Cb9t3Q10mzTd ji9Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=nW62cTfqiW/aWnCKxNZ5gVkQCaRLuYd0a6/dAIdSSrI=; b=kpyNM5IPS2maf48PRQk5B2BCOkBY13q7p2CPscGfMoJuRULx55JZRwDdWhrcTnZXC6 6/10Z+nAZJwY/Kx+KkQv1qdRoLWWgVTH3DfBLX3Ji3Lfh7fak7qiwbptmBPRSHN8b5v4 LfTOTQ7CoIWZEXGKY9x8uJFcn8VBLmVFInMtRY0UMwM2o+uccbJdI9BdD5uAxnMlOxOX E+QXnYODfBMbW1SIIveMclcWLvCy6S8Gtx4I7gbNKdY5fhcFsKEeB64jho91itr/QmV0 ZiBSEWgQPBh5uq9xru7C5BJEZmZcZOerhFWPPo+oaQX7Jfbup/mEe56HbfQzYz5wHYn8 SMPQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=PPbKLng1; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id q5-20020a170902bd8500b001895a1d382dsi5957901pls.451.2022.12.11.02.40.14; Sun, 11 Dec 2022 02:40:27 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=PPbKLng1; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230070AbiLKKju (ORCPT + 99 others); Sun, 11 Dec 2022 05:39:50 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45358 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230022AbiLKKjo (ORCPT ); Sun, 11 Dec 2022 05:39:44 -0500 Received: from mga06.intel.com (mga06b.intel.com [134.134.136.31]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A7FC7E0E5; Sun, 11 Dec 2022 02:39:40 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1670755180; x=1702291180; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=i+se1vuA+3GG0eId+7rBECuN3TLOkAv1bHjo/nViMo4=; b=PPbKLng1hm+JrlUhkrYJhnTT9Da4LoOmy+9khtzK/KUj0SmiZOFv17sW myqaffgCJ/72AQQzcvv3itrGVBjyLcde9hxxDitKX78MMnVSJX3Yd9knv bFt3w1hpqyZKgSPnbsXTw7RSnJ7ukfrqsQoVNOtaSqm0c+tm6vIay2vEd k9yOXtGqlSEkxJJ2Q8DAdRWZvBOeIHCgpKyqMhpxSuUDkNioBoZKIFAQ4 qcfYjKJnt3KJYKx+AuBr8vlkBot5uHpBL/EON8SxZEWfxsl9Jyt5EO/wN RpJUsFyMeDmc938liMxiW4eoqjhjzHfyzKrGXsHwCW2bJ+FEohyN+a3Rc w==; X-IronPort-AV: E=McAfee;i="6500,9779,10557"; a="379899597" X-IronPort-AV: E=Sophos;i="5.96,236,1665471600"; d="scan'208,146";a="379899597" Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by orsmga104.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 11 Dec 2022 02:39:40 -0800 X-IronPort-AV: E=McAfee;i="6500,9779,10557"; a="754575423" X-IronPort-AV: E=Sophos;i="5.96,236,1665471600"; d="scan'208,146";a="754575423" Received: from dratzker-mobl.ger.corp.intel.com (HELO ijarvine-MOBL2.ger.corp.intel.com) ([10.251.214.1]) by fmsmga002-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 11 Dec 2022 02:39:35 -0800 From: =?utf-8?q?Ilpo_J=C3=A4rvinen?= To: linux-fpga@vger.kernel.org, Xu Yilun , Wu Hao , Tom Rix , Moritz Fischer , Lee Jones , Matthew Gerlach , Russ Weight , Tianfei zhang , Mark Brown , Greg KH , Marco Pagani , linux-kernel@vger.kernel.org Cc: =?utf-8?q?Ilpo_J=C3=A4rvinen?= Subject: [PATCH v4 1/8] mfd: intel-m10-bmc: Create m10bmc_platform_info for type specific info Date: Sun, 11 Dec 2022 12:39:06 +0200 Message-Id: <20221211103913.5287-2-ilpo.jarvinen@linux.intel.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20221211103913.5287-1-ilpo.jarvinen@linux.intel.com> References: <20221211103913.5287-1-ilpo.jarvinen@linux.intel.com> MIME-Version: 1.0 X-Spam-Status: No, score=-4.3 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_EF,RCVD_IN_DNSWL_MED,SPF_HELO_NONE, SPF_NONE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1751913832710644334?= X-GMAIL-MSGID: =?utf-8?q?1751913832710644334?= BMC type specific info is currently set by a switch/case block. The size of this info is expected to grow as more dev types and features are added which would have made the switch block bloaty. Store type specific info into struct and place them into .driver_data instead because it makes things a bit cleaner. The m10bmc_type enum can be dropped as the differentiation is now fully handled by the platform info. The info member of struct intel_m10bmc that is added here is not used yet in this change but its addition logically still belongs to this change. The CSR map change that comes after this change needs to have the info member. Reviewed-by: Russ Weight Signed-off-by: Ilpo Järvinen Reviewed-by: Xu Yilun --- drivers/mfd/intel-m10-bmc.c | 53 ++++++++++++++----------------- include/linux/mfd/intel-m10-bmc.h | 12 +++++++ 2 files changed, 36 insertions(+), 29 deletions(-) diff --git a/drivers/mfd/intel-m10-bmc.c b/drivers/mfd/intel-m10-bmc.c index 7e3319e5b22f..12c522c16d83 100644 --- a/drivers/mfd/intel-m10-bmc.c +++ b/drivers/mfd/intel-m10-bmc.c @@ -13,12 +13,6 @@ #include #include -enum m10bmc_type { - M10_N3000, - M10_D5005, - M10_N5010, -}; - static struct mfd_cell m10bmc_d5005_subdevs[] = { { .name = "d5005bmc-hwmon" }, { .name = "d5005bmc-sec-update" } @@ -162,15 +156,17 @@ static int check_m10bmc_version(struct intel_m10bmc *ddata) static int intel_m10_bmc_spi_probe(struct spi_device *spi) { const struct spi_device_id *id = spi_get_device_id(spi); + const struct intel_m10bmc_platform_info *info; struct device *dev = &spi->dev; - struct mfd_cell *cells; struct intel_m10bmc *ddata; - int ret, n_cell; + int ret; ddata = devm_kzalloc(dev, sizeof(*ddata), GFP_KERNEL); if (!ddata) return -ENOMEM; + info = (struct intel_m10bmc_platform_info *)id->driver_data; + ddata->info = info; ddata->dev = dev; ddata->regmap = @@ -189,24 +185,8 @@ static int intel_m10_bmc_spi_probe(struct spi_device *spi) return ret; } - switch (id->driver_data) { - case M10_N3000: - cells = m10bmc_pacn3000_subdevs; - n_cell = ARRAY_SIZE(m10bmc_pacn3000_subdevs); - break; - case M10_D5005: - cells = m10bmc_d5005_subdevs; - n_cell = ARRAY_SIZE(m10bmc_d5005_subdevs); - break; - case M10_N5010: - cells = m10bmc_n5010_subdevs; - n_cell = ARRAY_SIZE(m10bmc_n5010_subdevs); - break; - default: - return -ENODEV; - } - - ret = devm_mfd_add_devices(dev, PLATFORM_DEVID_AUTO, cells, n_cell, + ret = devm_mfd_add_devices(dev, PLATFORM_DEVID_AUTO, + info->cells, info->n_cells, NULL, 0, NULL); if (ret) dev_err(dev, "Failed to register sub-devices: %d\n", ret); @@ -214,10 +194,25 @@ static int intel_m10_bmc_spi_probe(struct spi_device *spi) return ret; } +static const struct intel_m10bmc_platform_info m10bmc_spi_n3000 = { + .cells = m10bmc_pacn3000_subdevs, + .n_cells = ARRAY_SIZE(m10bmc_pacn3000_subdevs), +}; + +static const struct intel_m10bmc_platform_info m10bmc_spi_d5005 = { + .cells = m10bmc_d5005_subdevs, + .n_cells = ARRAY_SIZE(m10bmc_d5005_subdevs), +}; + +static const struct intel_m10bmc_platform_info m10bmc_spi_n5010 = { + .cells = m10bmc_n5010_subdevs, + .n_cells = ARRAY_SIZE(m10bmc_n5010_subdevs), +}; + static const struct spi_device_id m10bmc_spi_id[] = { - { "m10-n3000", M10_N3000 }, - { "m10-d5005", M10_D5005 }, - { "m10-n5010", M10_N5010 }, + { "m10-n3000", (kernel_ulong_t)&m10bmc_spi_n3000 }, + { "m10-d5005", (kernel_ulong_t)&m10bmc_spi_d5005 }, + { "m10-n5010", (kernel_ulong_t)&m10bmc_spi_n5010 }, { } }; MODULE_DEVICE_TABLE(spi, m10bmc_spi_id); diff --git a/include/linux/mfd/intel-m10-bmc.h b/include/linux/mfd/intel-m10-bmc.h index f0044b14136e..725b51ea4aee 100644 --- a/include/linux/mfd/intel-m10-bmc.h +++ b/include/linux/mfd/intel-m10-bmc.h @@ -118,14 +118,26 @@ /* Address of 4KB inverted bit vector containing staging area FLASH count */ #define STAGING_FLASH_COUNT 0x17ffb000 +/** + * struct intel_m10bmc_platform_info - Intel MAX 10 BMC platform specific information + * @cells: MFD cells + * @n_cells: MFD cells ARRAY_SIZE() + */ +struct intel_m10bmc_platform_info { + struct mfd_cell *cells; + int n_cells; +}; + /** * struct intel_m10bmc - Intel MAX 10 BMC parent driver data structure * @dev: this device * @regmap: the regmap used to access registers by m10bmc itself + * @info: the platform information for MAX10 BMC */ struct intel_m10bmc { struct device *dev; struct regmap *regmap; + const struct intel_m10bmc_platform_info *info; }; /*