From patchwork Fri Jan 18 07:59:23 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lei YU X-Patchwork-Id: 1027156 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 (2048 bits) server-digest SHA256) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 43gtdm60dgz9s9G for ; Fri, 18 Jan 2019 18:59:56 +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.b="WsOAvJik"; dkim-atps=neutral Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 43gtdm4DwtzDqvl for ; Fri, 18 Jan 2019 18:59:56 +1100 (AEDT) X-Original-To: skiboot@lists.ozlabs.org Delivered-To: skiboot@lists.ozlabs.org Authentication-Results: lists.ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=gmail.com (client-ip=2607:f8b0:4864:20::541; helo=mail-pg1-x541.google.com; envelope-from=mine260309@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.b="WsOAvJik"; dkim-atps=neutral Received: from mail-pg1-x541.google.com (mail-pg1-x541.google.com [IPv6:2607:f8b0:4864:20::541]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 43gtdR10D9zDqll for ; Fri, 18 Jan 2019 18:59:39 +1100 (AEDT) Received: by mail-pg1-x541.google.com with SMTP id m1so5665912pgq.8 for ; Thu, 17 Jan 2019 23:59:38 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id; bh=aIhg2L+fdKCf10xVyTGfUfY0hSL7ZrdTH+JLe65I1bs=; b=WsOAvJikYshoS7qdK4puPQ7PaqPPDNN1u2oPrHtwZ5cldpoxCcmt5oNreLcBWj/oQK O6UkrkS61cTOiO2e2SXpKfIfowj1JF4eMRWVQlnhcECLMyCrToeCPKW5BYu0ed+qUQTc rRYwECremKCuK1cwycNixmJDYwoKTjyAfMtdNdVz0wr3awmasRLM87m9VOYCmL6mwLkf cFxfSRmPVGHwYGM//JPWmMEhSarUxgf0NuTICBbq4Wz9C0p/665hcXcx6pNPY0SdYktM Z76UCZ9Y+NWavXhjbW15qdFtgxKVOzcuBQs2WVyAhk5F/9LIu51c3EgyvoE3rDENq0eE fMuA== 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; bh=aIhg2L+fdKCf10xVyTGfUfY0hSL7ZrdTH+JLe65I1bs=; b=goOq29UoMUJROdKBhYwL3YVPXzbs4LmuNyUHSrQJeEoq7kWgzvN+ARasMrLsPWL4C6 4spjMXXQrS7UCH6uTkorXPydzSkEJlaUYriQ1YM6jFxPjulNeCn468fmBkCs/XOG1e8H KSDYY+r43IMh5E0lQDaAfMzGgokxvFHrqiZy0ah2hPrztJP2nqCdtQRln0LLvSC9VKtQ dQCv3VOQsXf6E1czJMR21ukmxzytl7nqWxnLNVVckjn8Y8NUBJHdAUd8IMvJgsA0er+g G/afVGI0eVKuvJH/Q4J1xONxxEqREMLy/Sa4hpq3seP4+ELeTalqTUKO1KQvLyR6ZJXB P64Q== X-Gm-Message-State: AJcUukdXGEoxgavh+UuRvBW/w3R1kdnoBXoUgakZslk8k5DgVs0iFsNU Ta+TldZ5GhxbjbQZp8rKVE7Zq36I X-Google-Smtp-Source: ALg8bN5ZH63o8EKmLk2hyC5qV91yAad5kEADLFjpQQlrnGvucmA2vlpp3pw4pf1CgSPN0t4RLHT6XQ== X-Received: by 2002:a65:5a4c:: with SMTP id z12mr16644301pgs.188.1547798376587; Thu, 17 Jan 2019 23:59:36 -0800 (PST) Received: from localhost ([192.241.230.188]) by smtp.gmail.com with ESMTPSA id y6sm4726325pfl.187.2019.01.17.23.59.34 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 17 Jan 2019 23:59:35 -0800 (PST) From: Lei YU To: skiboot@lists.ozlabs.org Date: Fri, 18 Jan 2019 15:59:23 +0800 Message-Id: <1547798363-105371-1-git-send-email-mine260309@gmail.com> X-Mailer: git-send-email 2.7.4 Subject: [Skiboot] [PATCH] Implement OPAL_SET_SLOT_LED_STATUS opal call 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: , MIME-Version: 1.0 Errors-To: skiboot-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org Sender: "Skiboot" Add *set_led_state() in struct pci_slot_ops, and implement OPAL_SET_SLOT_LED_STATUS opal call by checking and calling set_led_state(). This function pointer is NULL by default and OPAL_UNSUPPORTED is returned. Each machine needs to implement it if it needs to control the device LED on the PCIe slot. Signed-off-by: Lei YU --- core/pci-opal.c | 17 +++++++++++++++++ core/pcie-slot.c | 3 +++ include/pci-slot.h | 1 + 3 files changed, 21 insertions(+) diff --git a/core/pci-opal.c b/core/pci-opal.c index a4d6eee..d05394c 100644 --- a/core/pci-opal.c +++ b/core/pci-opal.c @@ -1060,3 +1060,20 @@ static int64_t opal_pci_set_pbcq_tunnel_bar(uint64_t phb_id, uint64_t addr) return rc; } opal_call(OPAL_PCI_SET_PBCQ_TUNNEL_BAR, opal_pci_set_pbcq_tunnel_bar, 2); + +static int64_t opal_set_slot_led_status(uint64_t slot_id, uint8_t led_type, + uint8_t led_action) +{ + struct pci_slot *slot = pci_slot_find(slot_id); + int64_t rc; + + if (!slot) + return OPAL_PARAMETER; + + if (slot->ops.set_led_state) + rc = slot->ops.set_led_state(slot, led_type, led_action); + else + rc = OPAL_UNSUPPORTED; + return rc; +} +opal_call(OPAL_SET_SLOT_LED_STATUS, opal_set_slot_led_status, 3); diff --git a/core/pcie-slot.c b/core/pcie-slot.c index 4599634..956eef2 100644 --- a/core/pcie-slot.c +++ b/core/pcie-slot.c @@ -520,6 +520,9 @@ struct pci_slot *pcie_slot_create(struct phb *phb, struct pci_device *pd) slot->ops.set_power_state = pcie_slot_set_power_state; slot->ops.set_attention_state = pcie_slot_set_attention_state; + /* This is exected to be implemented by machine.c */ + slot->ops.set_led_state = NULL; + /* * State machine (SM) based reset stuff. The poll function is always * unified for all cases. diff --git a/include/pci-slot.h b/include/pci-slot.h index cd75753..2b739f0 100644 --- a/include/pci-slot.h +++ b/include/pci-slot.h @@ -102,6 +102,7 @@ struct pci_slot_ops { int64_t (*get_latch_state)(struct pci_slot *slot, uint8_t *val); int64_t (*set_power_state)(struct pci_slot *slot, uint8_t val); int64_t (*set_attention_state)(struct pci_slot *slot, uint8_t val); + int64_t (*set_led_state)(struct pci_slot *slot, uint8_t led_type, uint8_t val); /* SM based functions for reset */ void (*prepare_link_change)(struct pci_slot *slot, bool is_up);