From nobody Thu Apr 2 06:27:21 2026 Received: from mail-lf1-f49.google.com (mail-lf1-f49.google.com [209.85.167.49]) (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 9534F34C81F for ; Mon, 23 Feb 2026 06:39:19 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.167.49 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1771828761; cv=none; b=S45Rnbt2kGU0drfqMC7+kIyTFBO+jtYFBdtJtmDF6HL1tMmjyD4STETvJ3bEf3E364Vpa5CjeWcySqRrNcZvRu/WDCUeGmqyAM364bJxupRDRUR0yZDHr/5J+NhxXON+bST/OkcPAEzNubyjjSM9/W5BJETrieFx4jRCFXPk4mw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1771828761; c=relaxed/simple; bh=Fi8+HlKnN1h+N9DJycInvz7TYXjUPCLz5vbSQaQ2Gmo=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=nc36QdCXDsHjMHtfL74Q/WfXWXoW7MVfkOAcwn8es2b12I95cT9cK9Xj2mJKSYoqcqYQRcKn89nTsB3nE4kt4qNk1puE30N9Pzku0dhXPQRMTTWahdwmAcVhmDm/qRj1fgk/Shap9devN+r42pzbaQ1hB11oFvEjiHNFnneLvrE= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=KuH13j1U; arc=none smtp.client-ip=209.85.167.49 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="KuH13j1U" Received: by mail-lf1-f49.google.com with SMTP id 2adb3069b0e04-59e4989dacdso4136060e87.1 for ; Sun, 22 Feb 2026 22:39:19 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1771828758; x=1772433558; 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=PX7h5kXQ2ZfXYWkWgx4GofzlTaZv8NlPbhuLaaOQgic=; b=KuH13j1UJ0fEkwfhSul9srxaRCLPjmczHZY52s+VItSfEUdIq8V5BFbwdwjE+ikUWg NSc2spnMM0zRHemac5RX7dpPnWICs9vp2t/hlYXHqUSxNz6K3SpWrvR+Vq+5ae2F6N2c xs27oknxzk1+Dl/kRcoFrwGCSge4DwYRg2BzU1EwBCoF7ENid9zwznsT4aQmC8CBxVYK zBdj9RLaj9qifV4rxTXB5C6ZBwGpVzMP2fTh2yC8FNZ0rCAf81elCBL+HMVaUUA4z+AJ 4VNjs0yn1BlFHIBnly2RW6A8TVWM6k+jwDgzzYLj1v3A4qXJy7nyOzVbuvz6pdx74Dev c4wg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1771828758; x=1772433558; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=PX7h5kXQ2ZfXYWkWgx4GofzlTaZv8NlPbhuLaaOQgic=; b=YvT1M1FzCYKQFj6rkPTsafWErzZLK/s+vQQISiF6sbgdLNAJSZSUPAe5gccKnqVV/f zDGqQQYE8ZuakwAaCdwPQpaJRSvS11FVVVZD+BKeShT726VNx3qjhb0+/rU+Ipn8vXM6 AGmfWemeT3F9ov8qUUn7+5qB2OXUCm6VjEZcrSp/SobxcbANbEOYcc6IQhxvDGdnyZug zs7bdSA8wuRN6EfkbOSAeD5eE2tU0wJZ8WJTxqExjQNnJunNM4ajM5F3bvuHhSRDV6Iy 4Bokq7B0F6iu8XAklCPKNU3zvh1f4vP6d2AdX9Lva1QX6dLH75bKGt8SoGokzXf496Nw z7Fw== X-Forwarded-Encrypted: i=1; AJvYcCX71F7QNjzbj2qYkBg92oIl9HJDViARaYotjL1mb+0hCVACQ/+1V5TCdccjtwrxDKR1LjsfFntzdAzeupE=@vger.kernel.org X-Gm-Message-State: AOJu0YzaJdGNVXK2ZkdyDq4WMgEUYoZOut8Q9DJ7+2uoSvYR4UNU3dxN NGK4TGLXwJqjWh00vRSvlHeMy9f8M6xd+l4980VupO2dq4mM4NG4jPZg X-Gm-Gg: AZuq6aLqLAX78wp8qkwSpBs4EKVrnRy+Xxm0VZOgI7Y6nFeGRMSS5DgpeCY10ntc8Qq xx8cdnfM17oipxFTdgNCzcMOxcfa1KicbS1LPAwvHaVj+T51nxMLEzejH3dpjMnIIWxqiQlCMXY jBoLqE66W+Ecdi6Ju52+9clZI/UKyfccIkkaxGKfRgtJ0X8JE5yet3JVfWltDFlRpJaznoTok8f GDZ3KIskXJ9lTD5OdyD1rIYfU205L7rqvIwl2qjmvFyEmpuMd1PnBHbfuSCSqZcu+n61N0Clwgw UcEsAvcW4r2d0I0/0FLdreM/90aXV8bwEl5LVYjah6Y7b/gJYqLWkgIgoA5dxyFGKCzCATAjX+d bxM3hZVI0oCtF3Ie6WWLSLQOcNlGwICN2fDYQynZ/AHnpsuJ5ALLv7gx72X7mpElzIssEU8SlDa E3dlnWKLrV8Z23 X-Received: by 2002:ac2:51c6:0:b0:5a0:f5b0:3f0 with SMTP id 2adb3069b0e04-5a0f5b00a8emr196979e87.31.1771828757714; Sun, 22 Feb 2026 22:39:17 -0800 (PST) Received: from xeon ([188.163.112.76]) by smtp.gmail.com with ESMTPSA id 2adb3069b0e04-5a0eeb13abbsm1369626e87.23.2026.02.22.22.39.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 22 Feb 2026 22:39:17 -0800 (PST) From: Svyatoslav Ryhel To: Dmitry Torokhov , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Lee Jones , Pavel Machek , Liam Girdwood , Mark Brown , Svyatoslav Ryhel , David Lechner , Tony Lindgren Cc: linux-input@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-leds@vger.kernel.org Subject: [PATCH v3 8/9] mfd: motorola-cpcap: diverge configuration per-board Date: Mon, 23 Feb 2026 08:38:57 +0200 Message-ID: <20260223063858.12208-9-clamor95@gmail.com> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20260223063858.12208-1-clamor95@gmail.com> References: <20260223063858.12208-1-clamor95@gmail.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" MFD have rigid subdevice structure which does not allow flexible dynamic subdevice linking. Address this by diverging CPCAP subdevice composition to take into account board specific configuration. Create a common default subdevice composition, rename existing subdevice composition into cpcap_mapphone_mfd_devices since it targets mainly Mapphone board. Removed st,6556002 as it is no longer applicable to all cases and duplicates motorola,cpcap, which is used as the default composition. Signed-off-by: Svyatoslav Ryhel --- drivers/mfd/motorola-cpcap.c | 101 ++++++++++++++++++++++++++++------- 1 file changed, 83 insertions(+), 18 deletions(-) diff --git a/drivers/mfd/motorola-cpcap.c b/drivers/mfd/motorola-cpcap.c index d8243b956f87..516d1e33affa 100644 --- a/drivers/mfd/motorola-cpcap.c +++ b/drivers/mfd/motorola-cpcap.c @@ -12,6 +12,7 @@ #include #include #include +#include #include #include =20 @@ -24,10 +25,16 @@ #define CPCAP_REGISTER_SIZE 4 #define CPCAP_REGISTER_BITS 16 =20 +struct cpcap_chip_data { + const struct mfd_cell *mfd_devices; + unsigned int num_devices; +}; + struct cpcap_ddata { struct spi_device *spi; struct regmap_irq *irqs; struct regmap_irq_chip_data *irqdata[CPCAP_NR_IRQ_CHIPS]; + const struct cpcap_chip_data *cdata; const struct regmap_config *regmap_conf; struct regmap *regmap; }; @@ -195,20 +202,6 @@ static int cpcap_init_irq(struct cpcap_ddata *cpcap) return 0; } =20 -static const struct of_device_id cpcap_of_match[] =3D { - { .compatible =3D "motorola,cpcap", }, - { .compatible =3D "st,6556002", }, - {}, -}; -MODULE_DEVICE_TABLE(of, cpcap_of_match); - -static const struct spi_device_id cpcap_spi_ids[] =3D { - { .name =3D "cpcap", }, - { .name =3D "6556002", }, - {}, -}; -MODULE_DEVICE_TABLE(spi, cpcap_spi_ids); - static const struct regmap_config cpcap_regmap_config =3D { .reg_bits =3D 16, .reg_stride =3D 4, @@ -241,7 +234,56 @@ static int cpcap_resume(struct device *dev) =20 static DEFINE_SIMPLE_DEV_PM_OPS(cpcap_pm, cpcap_suspend, cpcap_resume); =20 -static const struct mfd_cell cpcap_mfd_devices[] =3D { +static const struct mfd_cell cpcap_default_mfd_devices[] =3D { + { + .name =3D "cpcap_adc", + .of_compatible =3D "motorola,cpcap-adc", + }, { + .name =3D "cpcap_battery", + .of_compatible =3D "motorola,cpcap-battery", + }, { + .name =3D "cpcap-regulator", + .of_compatible =3D "motorola,cpcap-regulator", + }, { + .name =3D "cpcap-rtc", + .of_compatible =3D "motorola,cpcap-rtc", + }, { + .name =3D "cpcap-pwrbutton", + .of_compatible =3D "motorola,cpcap-pwrbutton", + }, { + .name =3D "cpcap-usb-phy", + .of_compatible =3D "motorola,cpcap-usb-phy", + }, { + .name =3D "cpcap-led", + .id =3D 0, + .of_compatible =3D "motorola,cpcap-led-red", + }, { + .name =3D "cpcap-led", + .id =3D 1, + .of_compatible =3D "motorola,cpcap-led-green", + }, { + .name =3D "cpcap-led", + .id =3D 2, + .of_compatible =3D "motorola,cpcap-led-blue", + }, { + .name =3D "cpcap-led", + .id =3D 3, + .of_compatible =3D "motorola,cpcap-led-adl", + }, { + .name =3D "cpcap-led", + .id =3D 4, + .of_compatible =3D "motorola,cpcap-led-cp", + }, { + .name =3D "cpcap-codec", + }, +}; + +static const struct cpcap_chip_data cpcap_default_data =3D { + .mfd_devices =3D cpcap_default_mfd_devices, + .num_devices =3D ARRAY_SIZE(cpcap_default_mfd_devices), +}; + +static const struct mfd_cell cpcap_mapphone_mfd_devices[] =3D { { .name =3D "cpcap_adc", .of_compatible =3D "motorola,mapphone-cpcap-adc", @@ -285,7 +327,12 @@ static const struct mfd_cell cpcap_mfd_devices[] =3D { .of_compatible =3D "motorola,cpcap-led-cp", }, { .name =3D "cpcap-codec", - } + }, +}; + +static const struct cpcap_chip_data cpcap_mapphone_data =3D { + .mfd_devices =3D cpcap_mapphone_mfd_devices, + .num_devices =3D ARRAY_SIZE(cpcap_mapphone_mfd_devices), }; =20 static int cpcap_probe(struct spi_device *spi) @@ -297,6 +344,10 @@ static int cpcap_probe(struct spi_device *spi) if (!cpcap) return -ENOMEM; =20 + cpcap->cdata =3D device_get_match_data(&spi->dev); + if (!cpcap->cdata) + return -ENODEV; + cpcap->spi =3D spi; spi_set_drvdata(spi, cpcap); =20 @@ -331,10 +382,24 @@ static int cpcap_probe(struct spi_device *spi) spi->dev.coherent_dma_mask =3D 0; spi->dev.dma_mask =3D &spi->dev.coherent_dma_mask; =20 - return devm_mfd_add_devices(&spi->dev, 0, cpcap_mfd_devices, - ARRAY_SIZE(cpcap_mfd_devices), NULL, 0, NULL); + return devm_mfd_add_devices(&spi->dev, 0, cpcap->cdata->mfd_devices, + cpcap->cdata->num_devices, NULL, 0, NULL); } =20 +static const struct of_device_id cpcap_of_match[] =3D { + { .compatible =3D "motorola,cpcap", .data =3D &cpcap_default_data }, + { .compatible =3D "motorola,mapphone-cpcap", .data =3D &cpcap_mapphone_da= ta }, + { /* sentinel */ } +}; +MODULE_DEVICE_TABLE(of, cpcap_of_match); + +static const struct spi_device_id cpcap_spi_ids[] =3D { + { .name =3D "cpcap", .driver_data =3D (kernel_ulong_t)&cpcap_default_data= }, + { .name =3D "mapphone-cpcap", .driver_data =3D (kernel_ulong_t)&cpcap_map= phone_data }, + { /* sentinel */ } +}; +MODULE_DEVICE_TABLE(spi, cpcap_spi_ids); + static struct spi_driver cpcap_driver =3D { .driver =3D { .name =3D "cpcap-core", --=20 2.51.0