From nobody Mon Feb 9 09:10:55 2026 Received: from mail-wm1-f51.google.com (mail-wm1-f51.google.com [209.85.128.51]) (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 287062737E3 for ; Wed, 31 Dec 2025 14:35:46 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.51 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1767191748; cv=none; b=LiWt5xgybrCoe88O1aZ1IGf7/nWp4/09BHgRwtBj9LoyUdjt1PH52JEFfuG2Vl7dOUhxM+nQTCzp90/WO/pb9Z3pYNHGlw3wI3mNHLsp8YmHG2i0cwyci2CLxzXpcGTsSxssanzLfy1JCmaL8qyMskZrNpxb/0oLk4cd+pR1WAk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1767191748; c=relaxed/simple; bh=1vH4KrFv8xvMv8rpRWUougXl8BcRT5RLGVtAo9ej2xw=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=DxWCfakAFmQ2GPpqXefD1+0d6OUltGWZV0uxVStWfFvJmVIfsYXll+U8KmuxKMZOT4JsdiaCVjN+hrlEAeKRL7T9Ismx076dZ6/4DzpQgg+TMcmlxsCSnyPB5nrUEGu9lUrIR7P8c1s/k2PILJTv9YVaodiR751savpTS7PWN64= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=chromium.org; spf=pass smtp.mailfrom=chromium.org; dkim=pass (1024-bit key) header.d=chromium.org header.i=@chromium.org header.b=BEgwypps; arc=none smtp.client-ip=209.85.128.51 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=chromium.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=chromium.org header.i=@chromium.org header.b="BEgwypps" Received: by mail-wm1-f51.google.com with SMTP id 5b1f17b1804b1-4775e891b5eso43863935e9.2 for ; Wed, 31 Dec 2025 06:35:45 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1767191744; x=1767796544; 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=34pYk6l1cH16LeyZVvdM/XV6wo+Nk0j+m4GLCKEWRwU=; b=BEgwyppsTO/ChZlahFILnUfRCD3bUMzIHos/mixzW184xMmpqdJ0JITUQb6QX+owhW nbuaLfFmuzPJ+An09DnY41cPAGMPtBvIrfQpzrVvz0q1I8RBAbtPXD55JR7IRqvjtUCP csZWWjfj65RpaLurWldrumjwUW/nC3Rx1GUM8= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1767191744; x=1767796544; 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=34pYk6l1cH16LeyZVvdM/XV6wo+Nk0j+m4GLCKEWRwU=; b=h+svlOlYiWX0/sUVF7r+gWKihATBJVUWxy2T1PgI595jgaMZtdfvneJqYpXyvPmQFk bVMY/DiltbvbEE9m+o7st/YlVaB/aJyKxae6uwUpGUAA/xdYXOVeg76ss4eg2Oo7Jwla QE2L//01gtExcUqBErQqymObJqyBj5wUC4BGiATciDUs1dI572HS84i7gp0WYwWFcYVW hpD2Liexq0PlQ7zbUKJNFZItDEumNmwW3k8VTmkhIto7ywj17xBs9SR48SoBXt2HcRIH yb4dxYIS2VVlVwDOM+Aj0R8Tz6cSITDTYTQ8i8ygCdjWMw9TlcNzKe+fxeVlSeVxbWz0 rAcQ== X-Forwarded-Encrypted: i=1; AJvYcCUopMdcQC52sstoYFCDUjG+GmmZ1l/rDaqYFNnmQB9DpJQwziFsl+Y9Y93A9AhFEdu3SF0YgwOHsqdpGCQ=@vger.kernel.org X-Gm-Message-State: AOJu0YzEr/0aK40XK2qpa8twdPEtfhDL8Gv6Pa4q5k6qxr1rHVrVpY1e qtsjW3gZ2yJupFggEiH3JPtUp26VmR3DzQ/qyX9/SN5ZklwNx5nOHqEqnp8ZBL2Taw== X-Gm-Gg: AY/fxX6ut9Tz5LP57czvCBbc5F7c0tEXugx9e+8he23RTxm1ZJo7nHk1MyqoKEImJHd 2TDM48UhvcEoxGG31tfQoeiSTiUrZDyeXw/Q6kLY1DiL36EryG6BynJeXCqlcZZq5V04z4VV0Jy 9Qfzo84yTAjiKFCReUwqtJ8rICZKfyVDqH/WmckdPUetgG2Phc8e610K+nvcK14dbgGEqP+UiMA +Q49POaM12GixbgAi7rjdd/jSSwDdDlnaLkq8hkLWtN+ZFfdc3YX0xkYgMyVOjiGMLG6Ncizx/5 J4+B4Ti1E6rPB4M1cmMX+qXPk59EQ+PJHQKsWsj7zwGM3KE23dxoKBuKZT/JAbunltUwmM9NpEJ e2mhzF5K1QMlYINwbwC82ld9fr106VjLRiKlmhlXxBAQmqJ7ZrlsbjYwN67BPtzrmqi9LM4YZOq onhtUWExpcpQmknrPsWQIvfDqBgg== X-Google-Smtp-Source: AGHT+IEiRq6V4CAH/S2a6MvgduONiJuKUV1PONniN7Ix1f5FJkAX+d5WlgDqPZJkgHzRkh3uELoZxg== X-Received: by 2002:a05:600c:470a:b0:479:3a86:dc1f with SMTP id 5b1f17b1804b1-47d1958e43emr342849195e9.37.1767191744550; Wed, 31 Dec 2025 06:35:44 -0800 (PST) Received: from balto-ws ([37.228.206.31]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-47d193d4e91sm630300935e9.13.2025.12.31.06.35.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 31 Dec 2025 06:35:44 -0800 (PST) From: Fabio Baltieri To: Dmitry Torokhov , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Benson Leung , Guenter Roeck Cc: Fabio Baltieri , Tzung-Bi Shih , Simon Glass , linux-input@vger.kernel.org, devicetree@vger.kernel.org, chrome-platform@lists.linux.dev, linux-kernel@vger.kernel.org Subject: [PATCH v3 1/2] dt-bindings: google,cros-ec-keyb: add has-fn-map prop Date: Wed, 31 Dec 2025 14:35:37 +0000 Message-ID: <20251231143538.37483-2-fabiobaltieri@chromium.org> X-Mailer: git-send-email 2.52.0.351.gbe84eed79e-goog In-Reply-To: <20251231143538.37483-1-fabiobaltieri@chromium.org> References: <20251231143538.37483-1-fabiobaltieri@chromium.org> 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" Add binding documentation for the has-fn-map property. Signed-off-by: Fabio Baltieri --- .../devicetree/bindings/input/google,cros-ec-keyb.yaml | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/Documentation/devicetree/bindings/input/google,cros-ec-keyb.ya= ml b/Documentation/devicetree/bindings/input/google,cros-ec-keyb.yaml index fefaaf46a240..fa24b1cbc788 100644 --- a/Documentation/devicetree/bindings/input/google,cros-ec-keyb.yaml +++ b/Documentation/devicetree/bindings/input/google,cros-ec-keyb.yaml @@ -44,6 +44,14 @@ properties: where the lower 16 bits are reserved. This property is specified only when the keyboard has a custom design for the top row keys. =20 + google,has-fn-map: + description: | + The keymap has function key layer. This allows defining an extra set= of + codes that are sent if a key is pressed while the KEY_FN is held pre= ssed + as well. The function codes have to be defined in the linux,keymap + property with an offset of keypad,num-rows from the normal ones. + type: boolean + dependencies: function-row-physmap: [ 'linux,keymap' ] google,needs-ghost-filter: [ 'linux,keymap' ] --=20 2.52.0.351.gbe84eed79e-goog From nobody Mon Feb 9 09:10:55 2026 Received: from mail-wm1-f46.google.com (mail-wm1-f46.google.com [209.85.128.46]) (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 689CE2750FE for ; Wed, 31 Dec 2025 14:35:47 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.46 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1767191749; cv=none; b=BE/I1T9v5fieTt/igT6fD1rVhDv7/c1Lfn9iTqXOPf18Zj140TLKIVBwugR9xpDxwHT2tOpOODjZ5nPtOji+9s03imgI09lHaFcpoLHUxoNU+/kivY8S6evHEy7BDqC2nWFJL3COd8RC+Gef4IMhwhAGnzzBsvFOhCywDB/uFsU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1767191749; c=relaxed/simple; bh=O9+tUzr9uyN79tAtBKwl7ESmge84gPW0hNkQZxKq8CY=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=uwFOyEADiZo97HRxPhjXYOuezp7zVTy5c6L8CVMiwKPCnegruAKwra6jbOdDHD3ORmxRk0M8RSlFWXDhhfC0A3OMgcbcnYYYHlHpCJnl6tjNW4PZpFc9GzuSjarypBzt5geiRcwLGY0g4zz/4nDuRMqeAKlbytWgMA08jrD4Zpw= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=chromium.org; spf=pass smtp.mailfrom=chromium.org; dkim=pass (1024-bit key) header.d=chromium.org header.i=@chromium.org header.b=RdJMcsfr; arc=none smtp.client-ip=209.85.128.46 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=chromium.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=chromium.org header.i=@chromium.org header.b="RdJMcsfr" Received: by mail-wm1-f46.google.com with SMTP id 5b1f17b1804b1-47d63594f7eso2569065e9.0 for ; Wed, 31 Dec 2025 06:35:47 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1767191746; x=1767796546; 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=XvGLfgzU/Nu7QjgFI0e6yZbyhUHf+uCJkmxPNiQDL2c=; b=RdJMcsfrPkCtFkjXUElS0uWFM/Q8fmK+P2retxoWo9SFsk6DIEaz/JUXbYB2I42rxY vFYKz3nTE7J5+bS78BJRKiBg68eeTBaO7Dq9zZXvxBJCe+uaA+kl2p8qFLP4MJvp3cZN 4WwFnodCNNmceqqNsWdRD/QAjODdKJQIskoeA= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1767191746; x=1767796546; 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=XvGLfgzU/Nu7QjgFI0e6yZbyhUHf+uCJkmxPNiQDL2c=; b=IaRdM1MZPIZvnpKj3IAZ+R+y+pgK3aBuL741UX5g1xQyC7Uf7TxfMnZCTykF58wjVw sV4a9wC3OnAHisprwFpjTVeB/1d/lXI8SIx0sCM8ggvMSoKL8iB9AsxuxFmOdizo54JX yjtbFXL8JfJTmY5j2FO1VzCBWGZjNjqq2dlaRavWZy3KoHonWH4ptwROe1GoqwGt9u+v Xfz635hfYmRtbEXT1HvEuMHlNIb3JeeNBmesvVx5Tx+UqhLI08lHwH3sKA5guZq2Syo5 Jfkk4jDAVzmvVpX0Psw1EhYsFDQERQ1rbMaOT2BXt2B3a8+Bya7zjPFbX6UNXYXsdCpj L6/Q== X-Forwarded-Encrypted: i=1; AJvYcCWwIgb1FMKmvYEwDVctkMzdoFVwTrC0vpAQjE6vLpUbKRJaS0wJRqLXiheQBuwogdV9Q8z4t8pe3gf+N3g=@vger.kernel.org X-Gm-Message-State: AOJu0Yw7VwbTR7ITU2ay84B8BeGJnGOQRbzBs9NY/yATeTYeICs6JrGZ rdHQUCwRQ4Uumi9Kr0MtHEHR8QNaMPq/J+OwRHSrciNJlwlNJduFFBEB0bbig4xa2w== X-Gm-Gg: AY/fxX6tcXlT8BTunOOek40G2IgdxslsQJCAwyR/orNJwJoSD/7f3412qmah4+k09sk CEO35h9HscixCX72Ryn491dyB8OiQvc7cknZ0yWbPC925Cl9WaCgJk134/MCrVaCs/8d0cLamkT hG4DUNm/iw4DxVUrYLTRtw2ZzjKeuTdkIspwseapH73tYw56jpzz9LJf6ZGyiT+VXFTjbR6KDw5 MiHSREsLuPADXcGrZ4K0FmH2A64zUvYm66wFTFtyeovzghJGFDLnl8jzlGl1d2A3Dg7JG6hMs0K 00LPufLq4hTLpr5L3WWIrQ0zjiHcYQHQY5dJOpMucLPQ9AJsjhnjDyRL84Udi95S2QwezSWIy85 Q9vlp4xMB180bUC9B0u8RFmY5WmocDjPZhkGTVrNW5AcWFeUSiE6hvZDPeILK8D3xmbXfdLO9bW E9rtJ2fiUzXDZ5d0A= X-Google-Smtp-Source: AGHT+IHvR+cy7a7pyZUdGh+DjWUEBxNKW4LqjmW8R2bBcuhZXgZlkJueqcwfNCjJuqSQO+WmZPKOQg== X-Received: by 2002:a05:600c:4fc6:b0:477:333a:f71f with SMTP id 5b1f17b1804b1-47d19576cc6mr425787465e9.17.1767191745659; Wed, 31 Dec 2025 06:35:45 -0800 (PST) Received: from balto-ws ([37.228.206.31]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-47d193d4e91sm630300935e9.13.2025.12.31.06.35.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 31 Dec 2025 06:35:45 -0800 (PST) From: Fabio Baltieri To: Dmitry Torokhov , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Benson Leung , Guenter Roeck Cc: Fabio Baltieri , Tzung-Bi Shih , Simon Glass , linux-input@vger.kernel.org, devicetree@vger.kernel.org, chrome-platform@lists.linux.dev, linux-kernel@vger.kernel.org Subject: [PATCH v3 2/2] Input: cros_ec_keyb - add function key support Date: Wed, 31 Dec 2025 14:35:38 +0000 Message-ID: <20251231143538.37483-3-fabiobaltieri@chromium.org> X-Mailer: git-send-email 2.52.0.351.gbe84eed79e-goog In-Reply-To: <20251231143538.37483-1-fabiobaltieri@chromium.org> References: <20251231143538.37483-1-fabiobaltieri@chromium.org> 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" Add support for handling an Fn button and sending separate keycodes for a subset of keys in the matrix defined in the upper half of the keymap. Signed-off-by: Fabio Baltieri Reviewed-by: Simon Glass --- drivers/input/keyboard/cros_ec_keyb.c | 136 +++++++++++++++++++++++--- 1 file changed, 120 insertions(+), 16 deletions(-) diff --git a/drivers/input/keyboard/cros_ec_keyb.c b/drivers/input/keyboard= /cros_ec_keyb.c index 1c6b0461dc35..bc76f61583c3 100644 --- a/drivers/input/keyboard/cros_ec_keyb.c +++ b/drivers/input/keyboard/cros_ec_keyb.c @@ -29,6 +29,11 @@ =20 #include =20 +/* Maximum size of the normal key matrix, this is limited by the host comm= and + * key_matrix field defined in ec_response_get_next_data_v3 + */ +#define CROS_EC_KEYBOARD_COLS_MAX 18 + /** * struct cros_ec_keyb - Structure representing EC keyboard device * @@ -44,6 +49,11 @@ * @bs_idev: The input device for non-matrix buttons and switches (or NULL= ). * @notifier: interrupt event notifier for transport devices * @vdata: vivaldi function row data + * @has_fn_map: whether the driver use an fn function map layer + * @normal_key_status: active normal keys map + * @fn_key_status: active function keys map + * @fn_key_pressed: tracks the function key status + * @fn_key_triggered: tracks where any function key fired */ struct cros_ec_keyb { unsigned int rows; @@ -61,6 +71,12 @@ struct cros_ec_keyb { struct notifier_block notifier; =20 struct vivaldi_data vdata; + + bool has_fn_map; + u8 normal_key_status[CROS_EC_KEYBOARD_COLS_MAX]; + u8 fn_key_status[CROS_EC_KEYBOARD_COLS_MAX]; + bool fn_key_pressed; + bool fn_key_triggered; }; =20 /** @@ -166,16 +182,100 @@ static bool cros_ec_keyb_has_ghosting(struct cros_ec= _keyb *ckdev, uint8_t *buf) return false; } =20 +/* + * Process a function key state change, send an event report if appropriat= e. + */ +static void cros_ec_keyb_process_fn_key(struct cros_ec_keyb *ckdev, + int row, int col, bool state) +{ + struct input_dev *idev =3D ckdev->idev; + int pos =3D MATRIX_SCAN_CODE(row, col, ckdev->row_shift); + + ckdev->fn_key_pressed =3D state; + + if (state) { + ckdev->fn_key_triggered =3D false; + } else if (!ckdev->fn_key_triggered) { + /* + * Send the original code if nothing else has been pressed + * together with Fn. + */ + input_event(idev, EV_MSC, MSC_SCAN, pos); + input_report_key(idev, KEY_FN, true); + input_sync(idev); + + input_event(idev, EV_MSC, MSC_SCAN, pos); + input_report_key(idev, KEY_FN, false); + } +} + +/* + * Return the Fn code for a normal key row, col combination. + */ +static unsigned int cros_ec_keyb_fn_code(struct cros_ec_keyb *ckdev, + int row, int col) +{ + struct input_dev *idev =3D ckdev->idev; + const unsigned short *keycodes =3D idev->keycode; + int pos =3D MATRIX_SCAN_CODE(row + ckdev->rows, col, ckdev->row_shift); + + return keycodes[pos]; +} + +/* + * Process the new state for a single key. + */ +static void cros_ec_keyb_process_one(struct cros_ec_keyb *ckdev, + int row, int col, bool state) +{ + struct input_dev *idev =3D ckdev->idev; + const unsigned short *keycodes =3D idev->keycode; + int pos =3D MATRIX_SCAN_CODE(row, col, ckdev->row_shift); + unsigned int code =3D keycodes[pos]; + + dev_dbg(ckdev->dev, "changed: [r%d c%d]: byte %02x\n", row, col, state); + + if (ckdev->has_fn_map) { + if (code =3D=3D KEY_FN) + return cros_ec_keyb_process_fn_key(ckdev, row, col, state); + + if (!state) { + if (ckdev->fn_key_status[col] & BIT(row)) { + code =3D cros_ec_keyb_fn_code(ckdev, row, col); + + ckdev->fn_key_status[col] &=3D ~BIT(row); + } else if (ckdev->normal_key_status[col] & BIT(row)) { + ckdev->normal_key_status[col] &=3D ~BIT(row); + } else { + /* Discard, key press code was not sent */ + return; + } + } else if (ckdev->fn_key_pressed) { + code =3D cros_ec_keyb_fn_code(ckdev, row, col); + + ckdev->fn_key_triggered =3D true; + + if (!code) + return; + + ckdev->fn_key_status[col] |=3D BIT(row); + } else { + ckdev->normal_key_status[col] |=3D BIT(row); + } + } + + input_event(idev, EV_MSC, MSC_SCAN, pos); + input_report_key(idev, code, state); +} =20 /* * Compares the new keyboard state to the old one and produces key - * press/release events accordingly. The keyboard state is 13 bytes (one = byte - * per column) + * press/release events accordingly. The keyboard state is one byte + * per column. */ static void cros_ec_keyb_process(struct cros_ec_keyb *ckdev, uint8_t *kb_state, int len) { - struct input_dev *idev =3D ckdev->idev; int col, row; int new_state; int old_state; @@ -192,20 +292,13 @@ static void cros_ec_keyb_process(struct cros_ec_keyb = *ckdev, =20 for (col =3D 0; col < ckdev->cols; col++) { for (row =3D 0; row < ckdev->rows; row++) { - int pos =3D MATRIX_SCAN_CODE(row, col, ckdev->row_shift); - const unsigned short *keycodes =3D idev->keycode; - new_state =3D kb_state[col] & (1 << row); old_state =3D ckdev->old_kb_state[col] & (1 << row); - if (new_state !=3D old_state) { - dev_dbg(ckdev->dev, - "changed: [r%d c%d]: byte %02x\n", - row, col, new_state); - - input_event(idev, EV_MSC, MSC_SCAN, pos); - input_report_key(idev, keycodes[pos], - new_state); - } + + if (new_state =3D=3D old_state) + continue; + + cros_ec_keyb_process_one(ckdev, row, col, new_state); } ckdev->old_kb_state[col] =3D kb_state[col]; } @@ -597,12 +690,19 @@ static int cros_ec_keyb_register_matrix(struct cros_e= c_keyb *ckdev) struct device *dev =3D ckdev->dev; struct input_dev *idev; const char *phys; + unsigned int rows_keymap; int err; =20 err =3D matrix_keypad_parse_properties(dev, &ckdev->rows, &ckdev->cols); if (err) return err; =20 + if (ckdev->cols > CROS_EC_KEYBOARD_COLS_MAX) { + dev_err(dev, "keypad,num-columns too large: %d (max: %d)\n", + ckdev->cols, CROS_EC_KEYBOARD_COLS_MAX); + return -EINVAL; + } + ckdev->valid_keys =3D devm_kzalloc(dev, ckdev->cols, GFP_KERNEL); if (!ckdev->valid_keys) return -ENOMEM; @@ -635,7 +735,11 @@ static int cros_ec_keyb_register_matrix(struct cros_ec= _keyb *ckdev) ckdev->ghost_filter =3D device_property_read_bool(dev, "google,needs-ghost-filter"); =20 - err =3D matrix_keypad_build_keymap(NULL, NULL, ckdev->rows, ckdev->cols, + ckdev->has_fn_map =3D device_property_read_bool(dev, "google,has-fn-map"); + + rows_keymap =3D ckdev->has_fn_map ? ckdev->rows * 2 : ckdev->rows; + + err =3D matrix_keypad_build_keymap(NULL, NULL, rows_keymap, ckdev->cols, NULL, idev); if (err) { dev_err(dev, "cannot build key matrix\n"); --=20 2.52.0.351.gbe84eed79e-goog