From: "Dustin L. Howett" <dustin@howett.net>
To: Tzung-Bi Shih <tzungbi@kernel.org>,
Guenter Roeck <groeck@chromium.org>,
chrome-platform@lists.linux.dev
Cc: "Dustin L. Howett" <dustin@howett.net>
Subject: [PATCH v3 1/4] platform/chrome: cros_ec_lpc: introduce a priv struct for the lpc device
Date: Tue, 2 Apr 2024 19:47:10 -0500 [thread overview]
Message-ID: <20240403004713.130365-2-dustin@howett.net> (raw)
In-Reply-To: <20240403004713.130365-1-dustin@howett.net>
lpc_driver_data stores the MMIO port base for EC mapped memory.
cros_ec_lpc_readmem uses this port base instead of hardcoding
EC_LPC_ADDR_MEMMAP.
Signed-off-by: Dustin L. Howett <dustin@howett.net>
---
drivers/platform/chrome/cros_ec_lpc.c | 25 +++++++++++++++++++++----
1 file changed, 21 insertions(+), 4 deletions(-)
diff --git a/drivers/platform/chrome/cros_ec_lpc.c b/drivers/platform/chrome/cros_ec_lpc.c
index f0f3d3d56157..5e2856c5185b 100644
--- a/drivers/platform/chrome/cros_ec_lpc.c
+++ b/drivers/platform/chrome/cros_ec_lpc.c
@@ -34,6 +34,14 @@
/* True if ACPI device is present */
static bool cros_ec_lpc_acpi_device_found;
+/**
+ * struct cros_ec_lpc - LPC device-specific data
+ * @mmio_memory_base: The first I/O port addressing EC mapped memory.
+ */
+struct cros_ec_lpc {
+ u16 mmio_memory_base;
+};
+
/**
* struct lpc_driver_ops - LPC driver operations
* @read: Copy length bytes from EC address offset into buffer dest. Returns
@@ -290,6 +298,7 @@ static int cros_ec_cmd_xfer_lpc(struct cros_ec_device *ec,
static int cros_ec_lpc_readmem(struct cros_ec_device *ec, unsigned int offset,
unsigned int bytes, void *dest)
{
+ struct cros_ec_lpc *ec_lpc = ec->priv;
int i = offset;
char *s = dest;
int cnt = 0;
@@ -299,13 +308,13 @@ static int cros_ec_lpc_readmem(struct cros_ec_device *ec, unsigned int offset,
/* fixed length */
if (bytes) {
- cros_ec_lpc_ops.read(EC_LPC_ADDR_MEMMAP + offset, bytes, s);
+ cros_ec_lpc_ops.read(ec_lpc->mmio_memory_base + offset, bytes, s);
return bytes;
}
/* string */
for (; i < EC_MEMMAP_SIZE; i++, s++) {
- cros_ec_lpc_ops.read(EC_LPC_ADDR_MEMMAP + i, 1, s);
+ cros_ec_lpc_ops.read(ec_lpc->mmio_memory_base + i, 1, s);
cnt++;
if (!*s)
break;
@@ -353,9 +362,16 @@ static int cros_ec_lpc_probe(struct platform_device *pdev)
struct acpi_device *adev;
acpi_status status;
struct cros_ec_device *ec_dev;
+ struct cros_ec_lpc *ec_lpc;
u8 buf[2] = {};
int irq, ret;
+ ec_lpc = devm_kzalloc(dev, sizeof(*ec_lpc), GFP_KERNEL);
+ if (!ec_lpc)
+ return -ENOMEM;
+
+ ec_lpc->mmio_memory_base = EC_LPC_ADDR_MEMMAP;
+
/*
* The Framework Laptop (and possibly other non-ChromeOS devices)
* only exposes the eight I/O ports that are required for the Microchip EC.
@@ -380,7 +396,7 @@ static int cros_ec_lpc_probe(struct platform_device *pdev)
cros_ec_lpc_ops.write = cros_ec_lpc_mec_write_bytes;
cros_ec_lpc_ops.read(EC_LPC_ADDR_MEMMAP + EC_MEMMAP_ID, 2, buf);
if (buf[0] != 'E' || buf[1] != 'C') {
- if (!devm_request_region(dev, EC_LPC_ADDR_MEMMAP, EC_MEMMAP_SIZE,
+ if (!devm_request_region(dev, ec_lpc->mmio_memory_base, EC_MEMMAP_SIZE,
dev_name(dev))) {
dev_err(dev, "couldn't reserve memmap region\n");
return -EBUSY;
@@ -389,7 +405,7 @@ static int cros_ec_lpc_probe(struct platform_device *pdev)
/* Re-assign read/write operations for the non MEC variant */
cros_ec_lpc_ops.read = cros_ec_lpc_read_bytes;
cros_ec_lpc_ops.write = cros_ec_lpc_write_bytes;
- cros_ec_lpc_ops.read(EC_LPC_ADDR_MEMMAP + EC_MEMMAP_ID, 2,
+ cros_ec_lpc_ops.read(ec_lpc->mmio_memory_base + EC_MEMMAP_ID, 2,
buf);
if (buf[0] != 'E' || buf[1] != 'C') {
dev_err(dev, "EC ID not detected\n");
@@ -423,6 +439,7 @@ static int cros_ec_lpc_probe(struct platform_device *pdev)
ec_dev->din_size = sizeof(struct ec_host_response) +
sizeof(struct ec_response_get_protocol_info);
ec_dev->dout_size = sizeof(struct ec_host_request);
+ ec_dev->priv = ec_lpc;
/*
* Some boards do not have an IRQ allotted for cros_ec_lpc,
--
2.43.0
next prev parent reply other threads:[~2024-04-03 0:47 UTC|newest]
Thread overview: 34+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-10-05 16:06 [PATCH v1 0/4] cros_ec: add support for newer versions of the Framework Laptop Dustin L. Howett
2023-10-05 16:06 ` [PATCH v1 1/4] cros_ec_lpc: introduce cros_ec_lpc, a priv struct for the lpc device Dustin L. Howett
2023-10-11 5:29 ` Tzung-Bi Shih
2023-10-05 16:07 ` [PATCH v1 2/4] cros_ec_lpc: pass driver_data from DMI down to the device Dustin L. Howett
2023-10-11 5:29 ` Tzung-Bi Shih
2023-10-05 16:07 ` [PATCH v1 3/4] cros_ec_lpc: add a quirks system, and propagate quirks from DMI Dustin L. Howett
2023-10-11 5:30 ` Tzung-Bi Shih
2023-11-16 23:17 ` Thomas Weißschuh
2023-10-05 16:07 ` [PATCH v1 4/4] cros_ec_lpc: add quirks for the Framework Laptop Dustin L. Howett
2023-10-05 18:45 ` Mario Limonciello
2023-10-11 5:30 ` Tzung-Bi Shih
2023-10-11 5:29 ` [PATCH v1 0/4] cros_ec: add support for newer versions of " Tzung-Bi Shih
2023-11-26 19:22 ` Dustin Howett
2023-11-27 3:30 ` Tzung-Bi Shih
2023-11-26 19:24 ` [PATCH v2 0/4] platform/chrome: cros_ec_lpc: add support for AMD Framework Laptops Dustin L. Howett
2023-11-26 19:24 ` [PATCH v2 1/4] platform/chrome: cros_ec_lpc: introduce a priv struct for the lpc device Dustin L. Howett
2023-11-26 19:24 ` [PATCH v2 2/4] platform/chrome: cros_ec_lpc: pass driver_data from DMI to the device Dustin L. Howett
2023-11-26 19:24 ` [PATCH v2 3/4] platform/chrome: cros_ec_lpc: add a "quirks" system Dustin L. Howett
2023-11-27 3:30 ` Tzung-Bi Shih
2023-11-26 19:24 ` [PATCH v2 4/4] platform/chrome: cros_ec_lpc: add quirks for the Framework Laptop (AMD) Dustin L. Howett
2023-12-23 11:33 ` [PATCH v2 0/4] platform/chrome: cros_ec_lpc: add support for AMD Framework Laptops Thomas Weißschuh
2024-04-03 0:47 ` [PATCH v3 " Dustin L. Howett
2024-04-03 0:47 ` Dustin L. Howett [this message]
2024-04-03 0:47 ` [PATCH v3 2/4] platform/chrome: cros_ec_lpc: pass driver_data from DMI to the device Dustin L. Howett
2024-04-03 0:47 ` [PATCH v3 3/4] platform/chrome: cros_ec_lpc: add a "quirks" system Dustin L. Howett
2024-04-03 0:47 ` [PATCH v3 4/4] platform/chrome: cros_ec_lpc: add quirks for the Framework Laptop (AMD) Dustin L. Howett
2024-04-04 18:53 ` [PATCH v3 0/4] platform/chrome: cros_ec_lpc: add support for AMD Framework Laptops Thomas Weißschuh
2024-04-04 18:59 ` Dustin Howett
2024-04-04 19:57 ` Thomas Weißschuh
2024-04-05 1:02 ` Dustin Howett
2024-04-06 18:48 ` Mario Limonciello
2024-04-06 19:23 ` Mario Limonciello
2024-04-08 9:30 ` patchwork-bot+chrome-platform
2024-04-08 9:30 ` patchwork-bot+chrome-platform
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20240403004713.130365-2-dustin@howett.net \
--to=dustin@howett.net \
--cc=chrome-platform@lists.linux.dev \
--cc=groeck@chromium.org \
--cc=tzungbi@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox