From patchwork Mon Oct 12 02:53:09 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Oliver O'Halloran X-Patchwork-Id: 1380598 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.ozlabs.org (lists.ozlabs.org [203.11.71.2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4C8jy96NxLz9s0b for ; Mon, 12 Oct 2020 13:57:05 +1100 (AEDT) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20161025 header.b=G0MXFdsY; dkim-atps=neutral Received: from bilbo.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 4C8jy94qqGzDqs1 for ; Mon, 12 Oct 2020 13:57:05 +1100 (AEDT) X-Original-To: skiboot@lists.ozlabs.org Delivered-To: skiboot@lists.ozlabs.org Authentication-Results: lists.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gmail.com (client-ip=2607:f8b0:4864:20::543; helo=mail-pg1-x543.google.com; envelope-from=oohall@gmail.com; receiver=) Authentication-Results: lists.ozlabs.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: lists.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20161025 header.b=G0MXFdsY; dkim-atps=neutral Received: from mail-pg1-x543.google.com (mail-pg1-x543.google.com [IPv6:2607:f8b0:4864:20::543]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 4C8jtJ0YhXzDqZL for ; Mon, 12 Oct 2020 13:53:43 +1100 (AEDT) Received: by mail-pg1-x543.google.com with SMTP id g9so12913290pgh.8 for ; Sun, 11 Oct 2020 19:53:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=fQzVjqku1+gPD8mK5pDHIUNouPCK8r8LBpoMVpfz9+k=; b=G0MXFdsY92FgoXpi55rMVElNnFnOToZfHr2rBojkRuOAzoZ9W5MJBWHhQrzr4wifKy 9IzrgpOd0zdd6pCANCuk0DN+fSCohKyzO2PtfxtpxOluai/2J2W110VK6HeA2Q5Mp+pO 215nOReHHIvVwXudqkQgUdt9doRvvd+Mum6NEKAQYW2JN9ejC5eaY6rIGNNEYpyMTkV7 3PMhzuD6ir4J4GUUwz7B7p2CVvkAFYCSEoDw4aTNVBu4IakX42ZSsrvb3kXXeDgL4TQq kS56mC+rqCTF4TQEIpk+GPpyQt5uncXwpvbP/NsHurq7d97CF0tx73fzwsGqgkeu/iYW umNg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=fQzVjqku1+gPD8mK5pDHIUNouPCK8r8LBpoMVpfz9+k=; b=rW5OYIkD3ONZpiOSjMJbAT1f8+Z30GDNXsMTegM7Ue0nklL8LckZG3adfRqLelA1t/ TFbs9Wa4OxC9Rr6t6vgS3plbrS7Q7NndL96QFDQsRya9sf6E0vucQE3ye54+PEWizuL5 K70VeCXCjxrksTXFZUIBDz7+oLOovWbOLMqTU3kegOSBnySZGuXx8vFGa1USiD5kCXw+ VYAQzkuz0Rjrfd3PbGB3LP6UuoylrOynu/oejFw+GnkrgWiUJqJhPyaiQekCTZ10fvZa ziZLm9xxORMZLRSZBEoF2Z5Qg6GPkQKJRE3IkbTkKtCoohdKiFjkC1WftnujB/JboyPB kWdA== X-Gm-Message-State: AOAM5304eR+Q/2xt1vETxHB7Egrje/809HZOPdGVBkcqKWZ5hMGzm2C4 gtE+YCmamUAEtuWRX//rXBnj9KejMEW2oA== X-Google-Smtp-Source: ABdhPJzoDX0gFrl44OuvLzuUSho80ILX7bxuZVhCwc2novlZCRF6nUc3d7/ETkvQlS0YON4oDu40LA== X-Received: by 2002:a17:90a:9317:: with SMTP id p23mr17251554pjo.160.1602471221312; Sun, 11 Oct 2020 19:53:41 -0700 (PDT) Received: from localhost.ibm.com (14-200-206-90.tpgi.com.au. [14.200.206.90]) by smtp.gmail.com with ESMTPSA id g4sm17909258pgg.75.2020.10.11.19.53.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 11 Oct 2020 19:53:40 -0700 (PDT) From: Oliver O'Halloran To: skiboot@lists.ozlabs.org Date: Mon, 12 Oct 2020 13:53:09 +1100 Message-Id: <20201012025314.1070230-5-oohall@gmail.com> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20201012025314.1070230-1-oohall@gmail.com> References: <20201012025314.1070230-1-oohall@gmail.com> MIME-Version: 1.0 Subject: [Skiboot] [PATCH 05/10] hw/p8-i2c: Add p8_i2c_find_bus_by_port() X-BeenThere: skiboot@lists.ozlabs.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Mailing list for skiboot development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: skiboot-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org Sender: "Skiboot" Adds a way to find the struct i2c_bus for a given chip ID, engine ID, and port ID. HDAT indicates which I2C master is relevant using this information so it comes up a fair bit. Signed-off-by: Oliver O'Halloran --- hw/p8-i2c.c | 26 ++++++++++++++++++++++++++ include/i2c.h | 3 +++ 2 files changed, 29 insertions(+) diff --git a/hw/p8-i2c.c b/hw/p8-i2c.c index 40b8dc2167f5..60bea868fda2 100644 --- a/hw/p8-i2c.c +++ b/hw/p8-i2c.c @@ -1607,3 +1607,29 @@ void p8_i2c_init(void) p8_i2c_init_one(i2cm, i); } } + +struct i2c_bus *p8_i2c_find_bus_by_port(uint32_t chip_id, int eng, int port_num) +{ + struct proc_chip *chip = get_chip(chip_id); + struct p8_i2c_master *m, *master = NULL; + struct p8_i2c_master_port *port; + + if (!chip) + return NULL; + + list_for_each(&chip->i2cms, m, link) { + if (m->engine_id == eng) { + master = m; + break; + } + } + + if (!master) + return NULL; + + list_for_each(&master->ports, port, link) + if (port->port_num == port_num) + return &port->bus; + + return NULL; +} diff --git a/include/i2c.h b/include/i2c.h index 2c67a0ea22ea..8ec32ad1c6f3 100644 --- a/include/i2c.h +++ b/include/i2c.h @@ -61,6 +61,9 @@ struct i2c_request { extern void i2c_add_bus(struct i2c_bus *bus); extern struct i2c_bus *i2c_find_bus_by_id(uint32_t opal_id); +/* not generic, but useful */ +struct i2c_bus *p8_i2c_find_bus_by_port(uint32_t chip_id, int eng, int port_id); + int64_t i2c_queue_req(struct i2c_request *req); static inline uint64_t i2c_run_req(struct i2c_request *req)