From patchwork Sat May 11 09:05:12 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Thomas_Wei=C3=9Fschuh?= X-Patchwork-Id: 13662303 Received: from todd.t-8ch.de (todd.t-8ch.de [159.69.126.157]) (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 6F43E53373 for ; Sat, 11 May 2024 09:05:23 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=159.69.126.157 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715418326; cv=none; b=Mz7MNB/+mFaDW/n8XYqSMh5qKPP7v5KpBLOA90mp2OobAv3cXyYao1b22Dcjc1UqGCfXjMoujA7JzXCaYlQqPWveXIv0ym0Ax51tvFdtLxLPrIAtScTdBoqK0cTiPiFhrcoWVrlZEI0CSqD3xNNn6b152jSVHbdxM+1AMLt3SHQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715418326; c=relaxed/simple; bh=T9L6qMXMVqDYRgv0hmn/E39oempZVTVo4yyu6+dCn2A=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=U03alwTWx829O8jSKbtLYrnORRk0UbYw5wq+jaaoNFvXdDVsf3oO61nPa0sPa41dxyA5HDl1TKtTKgvzjh7uDH7dGyvai4bH0jP1nSczTlxiW3RGrs//aDh4OHK13ebf4awfcWmmxXtmgiLI6M/kUXUT36/rd/RDkkKTlC6GQwc= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=weissschuh.net; spf=pass smtp.mailfrom=weissschuh.net; dkim=pass (1024-bit key) header.d=weissschuh.net header.i=@weissschuh.net header.b=AZvm4/EH; arc=none smtp.client-ip=159.69.126.157 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=weissschuh.net Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=weissschuh.net Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=weissschuh.net header.i=@weissschuh.net header.b="AZvm4/EH" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=weissschuh.net; s=mail; t=1715418315; bh=T9L6qMXMVqDYRgv0hmn/E39oempZVTVo4yyu6+dCn2A=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=AZvm4/EHwn5WbM2+typ7XY3u5jbwSjiAKghzK7M2iGK+mvTsjV57P/vXOzN6ZN1Q+ ABP4KJzp2tLdjssGszjEDDqbkwt8SaEbnQ6wZjPJvvRzMygf6QuZkrmB+65UXGWrxJ 6bAaLwFAkYvMahWHvv7vRV1jJvn5QnZhJoK2Y9zE= From: =?utf-8?q?Thomas_Wei=C3=9Fschuh?= Date: Sat, 11 May 2024 11:05:12 +0200 Subject: [PATCH v2 1/2] platform/chrome: cros_kbd_led_backlight: allow binding through mfd device Precedence: bulk X-Mailing-List: chrome-platform@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20240511-cros_ec-kbd-led-framework-v2-1-b20c48109e46@weissschuh.net> References: <20240511-cros_ec-kbd-led-framework-v2-0-b20c48109e46@weissschuh.net> In-Reply-To: <20240511-cros_ec-kbd-led-framework-v2-0-b20c48109e46@weissschuh.net> To: Lee Jones , Benson Leung , Guenter Roeck , Tzung-Bi Shih Cc: chrome-platform@lists.linux.dev, linux-kernel@vger.kernel.org, Dustin Howett , Mario Limonciello , =?utf-8?q?Thomas_Wei=C3=9Fs?= =?utf-8?q?chuh?= X-Mailer: b4 0.13.0 X-Developer-Signature: v=1; a=ed25519-sha256; t=1715418315; l=2647; i=linux@weissschuh.net; s=20221212; h=from:subject:message-id; bh=T9L6qMXMVqDYRgv0hmn/E39oempZVTVo4yyu6+dCn2A=; b=1yp1UlStIv22L2qaRcZer9F3Fku4K/glH+sIS5YWUCefKrw5BFJ6G664m6y0Pxu3FW31zqPcO P5/utQ+OLNeCse1DHYfQEuzuAPyeqyF3IpAhcvgFgCwcPV9Q+FH73bs X-Developer-Key: i=linux@weissschuh.net; a=ed25519; pk=KcycQgFPX2wGR5azS7RhpBqedglOZVgRPfdFSPB1LNw= The ChromeOS EC used in Framework laptops supports the standard CrOS EC keyboard backlight protocol. However the firmware on these laptops doesn't implement the ACPI ID GOOG0002 that is recognized by cros_kbd_led_backlight and they also don't use device tree. Prepare the existing cros_kbd_led_backlight driver to be probed through the CrOS EC mfd device which works without ACPI or OF support. Signed-off-by: Thomas Weißschuh --- drivers/platform/chrome/cros_kbd_led_backlight.c | 36 +++++++++++++++++++++++- 1 file changed, 35 insertions(+), 1 deletion(-) diff --git a/drivers/platform/chrome/cros_kbd_led_backlight.c b/drivers/platform/chrome/cros_kbd_led_backlight.c index b83e4f328620..25efff191d62 100644 --- a/drivers/platform/chrome/cros_kbd_led_backlight.c +++ b/drivers/platform/chrome/cros_kbd_led_backlight.c @@ -9,6 +9,7 @@ #include #include #include +#include #include #include #include @@ -194,13 +195,46 @@ static const __maybe_unused struct keyboard_led_drvdata keyboard_led_drvdata_ec_ #endif /* IS_ENABLED(CONFIG_CROS_EC) */ +#if IS_ENABLED(CONFIG_MFD_CROS_EC_DEV) +static int keyboard_led_init_ec_pwm_mfd(struct platform_device *pdev) +{ + struct cros_ec_dev *ec_dev = dev_get_drvdata(pdev->dev.parent); + struct cros_ec_device *cros_ec = ec_dev->ec_dev; + struct keyboard_led *keyboard_led = platform_get_drvdata(pdev); + + keyboard_led->ec = cros_ec; + + return 0; +} + +static const struct keyboard_led_drvdata keyboard_led_drvdata_ec_pwm_mfd = { + .init = keyboard_led_init_ec_pwm_mfd, + .brightness_set_blocking = keyboard_led_set_brightness_ec_pwm, + .brightness_get = keyboard_led_get_brightness_ec_pwm, + .max_brightness = KEYBOARD_BACKLIGHT_MAX, +}; + +#else /* IS_ENABLED(CONFIG_MFD_CROS_EC_DEV) */ + +static const struct keyboard_led_drvdata keyboard_led_drvdata_ec_pwm_mfd = {}; + +#endif /* IS_ENABLED(CONFIG_MFD_CROS_EC_DEV) */ + +static int keyboard_led_is_mfd_device(struct platform_device *pdev) +{ + return IS_ENABLED(CONFIG_MFD_CROS_EC_DEV) && mfd_get_cell(pdev); +} + static int keyboard_led_probe(struct platform_device *pdev) { const struct keyboard_led_drvdata *drvdata; struct keyboard_led *keyboard_led; int error; - drvdata = device_get_match_data(&pdev->dev); + if (keyboard_led_is_mfd_device(pdev)) + drvdata = &keyboard_led_drvdata_ec_pwm_mfd; + else + drvdata = device_get_match_data(&pdev->dev); if (!drvdata) return -EINVAL; From patchwork Sat May 11 09:05:13 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Thomas_Wei=C3=9Fschuh?= X-Patchwork-Id: 13662301 Received: from todd.t-8ch.de (todd.t-8ch.de [159.69.126.157]) (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 6F4B253384 for ; Sat, 11 May 2024 09:05:23 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=159.69.126.157 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715418325; cv=none; b=LhhqFC+OMFKDEUr4ugi++tzd6am3Ffu7ptP+djTcEov1VczUj/nfv82XPrhA0aH9JDSAg7RJVSKB7Ii60lvHoGebIMsoNRQ+FRgrftgeNEAv9JeRY2IPexnIMb4avWHHzM4CHMwr2ezpfQq8CM0N9O9qFxZUW/DKryYkpGsoZeQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715418325; c=relaxed/simple; bh=vHYkrX0iW7pZgmP4pEnBHnWb8ZZSaQ9/psNCVVPTmWo=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=nqS/eTqMn+mvL3FjFG+440rpEjOUVWQZS9LM4rAJUa3vLmnE9tXj6PGaHqw5/xrv/AN8GTdVXWuf3m46eUjgt1Rf8IYYemsSJknpNJjuUJ6QtCO9lwkL/5T7sCm+C6iqWQIhKfNCq9ypdpeFxXd9XZi8QKv9TtHyU/+8DNdJPsE= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=weissschuh.net; spf=pass smtp.mailfrom=weissschuh.net; dkim=pass (1024-bit key) header.d=weissschuh.net header.i=@weissschuh.net header.b=gagA8n1H; arc=none smtp.client-ip=159.69.126.157 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=weissschuh.net Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=weissschuh.net Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=weissschuh.net header.i=@weissschuh.net header.b="gagA8n1H" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=weissschuh.net; s=mail; t=1715418315; bh=vHYkrX0iW7pZgmP4pEnBHnWb8ZZSaQ9/psNCVVPTmWo=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=gagA8n1HCIfZS1iLiQaqPAmBfFp+DOHZnS4wsjehj+XtlV3yUiD7H2596ju6c/fG8 34TAaeWW+pA+1+bIWZY4GeJ6jrLqSjJHfc0ZGuMlYZOgqUz5MlaCZxcA7fDoalNLp+ cIr7jdg6mJqucyTHBqxYIERkVJi51wSbjTGPm03M= From: =?utf-8?q?Thomas_Wei=C3=9Fschuh?= Date: Sat, 11 May 2024 11:05:13 +0200 Subject: [PATCH v2 2/2] mfd: cros_ec: Register keyboard backlight subdevice Precedence: bulk X-Mailing-List: chrome-platform@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20240511-cros_ec-kbd-led-framework-v2-2-b20c48109e46@weissschuh.net> References: <20240511-cros_ec-kbd-led-framework-v2-0-b20c48109e46@weissschuh.net> In-Reply-To: <20240511-cros_ec-kbd-led-framework-v2-0-b20c48109e46@weissschuh.net> To: Lee Jones , Benson Leung , Guenter Roeck , Tzung-Bi Shih Cc: chrome-platform@lists.linux.dev, linux-kernel@vger.kernel.org, Dustin Howett , Mario Limonciello , =?utf-8?q?Thomas_Wei=C3=9Fs?= =?utf-8?q?chuh?= X-Mailer: b4 0.13.0 X-Developer-Signature: v=1; a=ed25519-sha256; t=1715418315; l=1230; i=linux@weissschuh.net; s=20221212; h=from:subject:message-id; bh=vHYkrX0iW7pZgmP4pEnBHnWb8ZZSaQ9/psNCVVPTmWo=; b=uoQ16y0zTQ25aqJJdsHepudgd6DT5U/u7Dv6tWhxJ4suhC5aZSvg4i9Zc64H1JawB8HmTOyng h1XEAsNWP0fBYhi0HJ0kd/ABQxVp7L1uhWX2iuswSu7niVWsTqbSFCI X-Developer-Key: i=linux@weissschuh.net; a=ed25519; pk=KcycQgFPX2wGR5azS7RhpBqedglOZVgRPfdFSPB1LNw= Load cros_kbd_led_backlight when the EC reports EC_FEATURE_PWM_KEYB. This makes cros_kbd_led_backlight work on machines without specific ACPI or OF support for the keyboard backlight. Signed-off-by: Thomas Weißschuh --- drivers/mfd/cros_ec_dev.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/drivers/mfd/cros_ec_dev.c b/drivers/mfd/cros_ec_dev.c index a52d59cc2b1e..4444b361aeae 100644 --- a/drivers/mfd/cros_ec_dev.c +++ b/drivers/mfd/cros_ec_dev.c @@ -99,6 +99,10 @@ static const struct mfd_cell cros_ec_wdt_cells[] = { { .name = "cros-ec-wdt", } }; +static const struct mfd_cell cros_ec_keyboard_leds_cells[] = { + { .name = "cros-keyboard-leds", }, +}; + static const struct cros_feature_to_cells cros_subdevices[] = { { .id = EC_FEATURE_CEC, @@ -125,6 +129,11 @@ static const struct cros_feature_to_cells cros_subdevices[] = { .mfd_cells = cros_ec_wdt_cells, .num_cells = ARRAY_SIZE(cros_ec_wdt_cells), }, + { + .id = EC_FEATURE_PWM_KEYB, + .mfd_cells = cros_ec_keyboard_leds_cells, + .num_cells = ARRAY_SIZE(cros_ec_keyboard_leds_cells), + }, }; static const struct mfd_cell cros_ec_platform_cells[] = {