Received: by 2002:a05:7412:3b8b:b0:fc:a2b0:25d7 with SMTP id nd11csp92957rdb; Wed, 7 Feb 2024 23:06:30 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCUC0ejsIYHb4kWksS9rkPhmhJnm3h3GX85VsCAc71ilhTOhqgOT8fAAFajr+Oiog0M56IFYr1BW5tX/LTqxCkr2W2pkRYIzU1saygjfGA== X-Google-Smtp-Source: AGHT+IH18KEpnCUu8urZ8wQ1PImwcw+w0VzIJD5dHCMBEDyRx/Jk2CJJqOaqKkSuqJBILFbfbM9A X-Received: by 2002:a05:6402:7c5:b0:560:5417:5d81 with SMTP id u5-20020a05640207c500b0056054175d81mr5770594edy.21.1707375989835; Wed, 07 Feb 2024 23:06:29 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707375989; cv=pass; d=google.com; s=arc-20160816; b=hzM9s8w9DeAxj7ligj6ZnQ+vZtvlm5WTS2rypmlwUF8FysWVj+8ECsw3s63WdR/1ZQ kn651/NgNa7VjG0fiW25E+y+UhjzGZO9fT9mLhOg4nBQV7lGg2KoNYS0ETrc6Czv3a0n OOMhsDp5t6it5uB7IDxftxqva5NWCFsPKtAGzfvQ2JvKWqLBUk+vCIgbIfAk14oZ47tb 5mB7/BV6GIvsLRCARwvnBVHnFoukSzo3f9S4yDLAZ6JxAXKvE7FlvP5qbVLA7ZLh96dF 1A9pm1fZHGq3IVWZxmOhQvpufSyjA93bcwSHPx6Ya7PSdOaA3kXosjVkNsFqWlb1YJ2y Qqew== 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=LsVp0PvwUnRyKtOz4XX9YfpRT50ZWJU7f82phG3Lfo4=; fh=LItyCfLLqo+4xwdj8CriW5rlCVFYJDmNMphk9IJ+xmc=; b=UIDUppiTHj0HH2NSONHNPS/ryQtjNiF7vlc4l/llsXM7llcagR8nzy73sEwxTPO2vG sEKG0A35ei9gRAm4CHC1ZxJEOYGVvNsL5NhIv7tgJTm2EQLexJHwo7MzqSiCmkisI1JL W02kemG/DF8ljuZDQvAGOGzFsVwJYOF9tpsaCiBJ5bsj9bhkfR+zfToQoXx5E4pRIo1U UhjADoUFnWyq87Kn7auHFYEBZ87kgtug8cHfEijXITz3QHkO+Yl+w9cKTZs4kxJk8XRw K4TjU5Z+VRj6SoLBeNx2ftXKc5VCCA+z0blBXugsD5v8bvZ8US/YQm9KCWmsDSoY3WyH fFCQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=Gf7R9CJR; arc=pass (i=1 dkim=pass dkdomain=intel.com dmarc=pass fromdomain=intel.com); spf=pass (google.com: domain of linux-kernel+bounces-57544-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-57544-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com X-Forwarded-Encrypted: i=2; AJvYcCViM0gN3K2RGS871RN7RMdWtIw24C2KkLzjjS0kPsaPpmQmYOreN83VjVVRouo4pwLTTU0h0JZXdt/GevGK+eK791XNXVbf6Mqigha9bA== Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id r17-20020aa7d151000000b0055d0a061ef7si595025edo.523.2024.02.07.23.06.29 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 07 Feb 2024 23:06:29 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-57544-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=Gf7R9CJR; arc=pass (i=1 dkim=pass dkdomain=intel.com dmarc=pass fromdomain=intel.com); spf=pass (google.com: domain of linux-kernel+bounces-57544-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-57544-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com 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 am.mirrors.kernel.org (Postfix) with ESMTPS id 91F841F24061 for ; Thu, 8 Feb 2024 07:06:29 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 8BA226A02E; Thu, 8 Feb 2024 07:05:49 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="Gf7R9CJR" Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.12]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 29DD769318; Thu, 8 Feb 2024 07:05:47 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.175.65.12 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707375948; cv=none; b=ZbdE6xegL0/kqMvxU9na+iejnQnAs9/G+w5kO/nowd6T0opvjsKngjHrnNCozwc7dTvQTH7ky+qCNB2tRhhitgQ0lrMYH3c1xcl6BF1BpJwvlTk5u+0FEGvQqb4Sxequwsui/AzA1EB0wQUGRJ1QdEOG92nSPlqRNAMec2XigDc= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707375948; c=relaxed/simple; bh=OhT4XZj8t2RtDk3NO3j6nx+lfeIyy2pDTu1PML96cWQ=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=ewZn45T+/PSRMYhHCmZapqM2opwV8XSQ45jJdGaBOoaowBTH2RxGaYsOHVV2yJKjGmLZ1di91wCgFLD0NDUNNwDLf7rKNVSYsqgf5lm53XfAKMZy3/eHvMXL8ppabtspGJNatLs0GW2I0m1YGrs1CBLvWD59+wjOhnj7VdL+hhU= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com; spf=none smtp.mailfrom=ecsmtp.iind.intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=Gf7R9CJR; arc=none smtp.client-ip=198.175.65.12 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=ecsmtp.iind.intel.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1707375947; x=1738911947; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=OhT4XZj8t2RtDk3NO3j6nx+lfeIyy2pDTu1PML96cWQ=; b=Gf7R9CJRnqdUyu6opmDZP4fsPYcmWUBSz+qhtEJ6ZQeLHexFAdWntZN9 VNp7/qU31gm0GaolbqDNBKq4NgJshKuxsB+5PJrw1xcqxJSD/RkE9/Qum t/zylTczLvxtnrRPI+ywoOowirrxtdLu73XH0eRn7BHjZiq/UzjCKflXt FsnAMpC2aPZL/HxnN6v6+5Qovazu2K/+LX3hLckvTQitG/GHIu27f7Bz8 g99mt6+x+CKjzdQHeue21KmD3QEBfbSCaiES1MLSMIn/kMYGrn489c9aX zUJPP3Rj3rZ1RRksbaSg5scYX6dEL99ZqsJmo2zb9Vf0lLzg8khhw8DE7 Q==; X-IronPort-AV: E=McAfee;i="6600,9927,10977"; a="12525870" X-IronPort-AV: E=Sophos;i="6.05,252,1701158400"; d="scan'208";a="12525870" Received: from fmviesa007.fm.intel.com ([10.60.135.147]) by orvoesa104.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 07 Feb 2024 23:05:39 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.05,252,1701158400"; d="scan'208";a="1573964" Received: from inesxmail01.iind.intel.com ([10.223.57.40]) by fmviesa007.fm.intel.com with ESMTP; 07 Feb 2024 23:05:36 -0800 Received: from inlubt0316.iind.intel.com (inlubt0316.iind.intel.com [10.191.20.213]) by inesxmail01.iind.intel.com (Postfix) with ESMTP id 513EB14353; Thu, 8 Feb 2024 12:35:35 +0530 (IST) Received: by inlubt0316.iind.intel.com (Postfix, from userid 12101951) id 4F5401600102; Thu, 8 Feb 2024 12:35:35 +0530 (IST) From: Raag Jadav To: u.kleine-koenig@pengutronix.de, jarkko.nikula@linux.intel.com, mika.westerberg@linux.intel.com, andriy.shevchenko@linux.intel.com, lakshmi.sowjanya.d@intel.com Cc: linux-pwm@vger.kernel.org, linux-kernel@vger.kernel.org, Raag Jadav Subject: [PATCH v2 2/5] pwm: dwc: Add 16 channel support for Intel Elkhart Lake Date: Thu, 8 Feb 2024 12:35:26 +0530 Message-Id: <20240208070529.28562-3-raag.jadav@intel.com> X-Mailer: git-send-email 2.35.3 In-Reply-To: <20240208070529.28562-1-raag.jadav@intel.com> References: <20240208070529.28562-1-raag.jadav@intel.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Intel Elkhart Lake PSE includes two instances of PWM as a single PCI function with 8 channels each. Add support for the remaining channels. Signed-off-by: Raag Jadav Tested-by: Lakshmi Sowjanya D --- drivers/pwm/pwm-dwc.c | 33 +++++++++++++++++++++++++-------- drivers/pwm/pwm-dwc.h | 5 +++++ 2 files changed, 30 insertions(+), 8 deletions(-) diff --git a/drivers/pwm/pwm-dwc.c b/drivers/pwm/pwm-dwc.c index 596a0bb35c40..47d76f5367fe 100644 --- a/drivers/pwm/pwm-dwc.c +++ b/drivers/pwm/pwm-dwc.c @@ -25,16 +25,31 @@ #include "pwm-dwc.h" -static int dwc_pwm_probe(struct pci_dev *pci, const struct pci_device_id *id) +/* Elkhart Lake */ +static const struct dwc_pwm_info ehl_pwm_info = { + .nr = 2, + .size = 0x1000, +}; + +static int dwc_pwm_init_one(struct device *dev, void __iomem *base, unsigned int offset) { - struct device *dev = &pci->dev; struct dwc_pwm *dwc; - int ret; dwc = dwc_pwm_alloc(dev); if (!dwc) return -ENOMEM; + dwc->base = base + offset; + + return devm_pwmchip_add(dev, &dwc->chip); +} + +static int dwc_pwm_probe(struct pci_dev *pci, const struct pci_device_id *id) +{ + const struct dwc_pwm_info *info; + struct device *dev = &pci->dev; + int i, ret; + ret = pcim_enable_device(pci); if (ret) { dev_err(dev, "Failed to enable device (%pe)\n", ERR_PTR(ret)); @@ -49,11 +64,13 @@ static int dwc_pwm_probe(struct pci_dev *pci, const struct pci_device_id *id) return ret; } - dwc->base = pcim_iomap_table(pci)[0]; + info = (const struct dwc_pwm_info *)id->driver_data; - ret = devm_pwmchip_add(dev, &dwc->chip); - if (ret) - return ret; + for (i = 0; i < info->nr; i++) { + ret = dwc_pwm_init_one(dev, pcim_iomap_table(pci)[0], i * info->size); + if (ret) + return ret; + } pm_runtime_put(dev); pm_runtime_allow(dev); @@ -105,7 +122,7 @@ static int dwc_pwm_resume(struct device *dev) static DEFINE_SIMPLE_DEV_PM_OPS(dwc_pwm_pm_ops, dwc_pwm_suspend, dwc_pwm_resume); static const struct pci_device_id dwc_pwm_id_table[] = { - { PCI_VDEVICE(INTEL, 0x4bb7) }, /* Elkhart Lake */ + { PCI_VDEVICE(INTEL, 0x4bb7), (kernel_ulong_t)&ehl_pwm_info }, { } /* Terminating Entry */ }; MODULE_DEVICE_TABLE(pci, dwc_pwm_id_table); diff --git a/drivers/pwm/pwm-dwc.h b/drivers/pwm/pwm-dwc.h index 64795247c54c..c9bbfc77b568 100644 --- a/drivers/pwm/pwm-dwc.h +++ b/drivers/pwm/pwm-dwc.h @@ -33,6 +33,11 @@ MODULE_IMPORT_NS(dwc_pwm); #define DWC_TIM_CTRL_INT_MASK BIT(2) #define DWC_TIM_CTRL_PWM BIT(3) +struct dwc_pwm_info { + unsigned int nr; + unsigned int size; +}; + struct dwc_pwm_ctx { u32 cnt; u32 cnt2; -- 2.35.3