From patchwork Wed Jan 17 16:55:40 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marcin Wojtas X-Patchwork-Id: 862399 X-Patchwork-Delegate: davem@davemloft.net Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=vger.kernel.org (client-ip=209.132.180.67; helo=vger.kernel.org; envelope-from=netdev-owner@vger.kernel.org; receiver=) Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=semihalf-com.20150623.gappssmtp.com header.i=@semihalf-com.20150623.gappssmtp.com header.b="Q1GVPuGe"; dkim-atps=neutral Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 3zMD1d0vLCz9s7v for ; Thu, 18 Jan 2018 04:03:17 +1100 (AEDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752578AbeAQRDO (ORCPT ); Wed, 17 Jan 2018 12:03:14 -0500 Received: from mail-lf0-f68.google.com ([209.85.215.68]:33524 "EHLO mail-lf0-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753633AbeAQQ4B (ORCPT ); Wed, 17 Jan 2018 11:56:01 -0500 Received: by mail-lf0-f68.google.com with SMTP id t139so8079328lff.0 for ; Wed, 17 Jan 2018 08:56:00 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=semihalf-com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=9lEUTjcdMWUCyftnMB+ar2Dv5pEYc7sQr93gJyE7pnU=; b=Q1GVPuGeLvZAHN7XHHCClzLQlNVf0RreRSegW97FKShWZNJeGhiqEDrQPO8sWpl1lB u9lGprOY4tebyFNUD2VS7aYddpPKKJkmUb2y4hPuxKEZyjcJLd6tsewn78NdSw3NCLoM 5YnBxyqjlOe1b9/54MKln5xpIPh3lzIESm3DD1BqW8geOg7LD+c5K8desKwrb7J/CqNw 1wTnN1EFnxj+ldl1tt8vs6as01i2r2ZCZNpG6ha8Spcb6/VPnxZH/lRGkIMs2OZ026u3 W1w/Lva2TmRPq9uj7uy1G0XRw32KwGRV3LyqL4/Eof3qhTffWel44BYNp901/dGLUNn3 DuRA== 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; bh=9lEUTjcdMWUCyftnMB+ar2Dv5pEYc7sQr93gJyE7pnU=; b=OUDfysi5gWWuFBJPShDsXzlH0bi2yWPwPpkkJAJ3pGmaFnplLHY5NiHp8Sdu0+o84F CSZ1mKVvw25GIewMGpl1RSW2FYEJ5aYwGv6+HpzF+GYW6eRnCUdeM8z1CD5RZiv0WW9e kvXFInDmCzPpetIX2hx6aYdv5G0LtHimQESOl2rd5Q/KhgpOYRiNZyFcyfio/88WS8c7 iVuqYapNvuyOXPfnN90y9lLWUsCXB+FCG8QWGWWGEJA9qKkPwOb20e3NuJ0OZavG8Fda eSqelU5H5Z1mvOGW6WKHi0u8BTp2dysfJL1pIFLpgnOiTMomWuNOJnY3FpC9HUqUeboq w+Jw== X-Gm-Message-State: AKwxytdPZFINTtnZY6nwNA7Ya38XzDr7fE7BowZdCkhNsfE6gmClSowr Q9RHJlzuWWKti0wAgEbj+h6rOw== X-Google-Smtp-Source: ACJfBosTRQ0ak2V1P9KuH/LMhJ3uWbkogpeqD2bDTeldCCpsP8jJWMftDVoZ5n3MNhIeQ2TNN4cwvA== X-Received: by 10.46.5.151 with SMTP id 145mr7180100ljf.134.1516208159552; Wed, 17 Jan 2018 08:55:59 -0800 (PST) Received: from gilgamesh.semihalf.com (31-172-191-173.noc.fibertech.net.pl. [31.172.191.173]) by smtp.gmail.com with ESMTPSA id t81sm868347lff.47.2018.01.17.08.55.57 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 17 Jan 2018 08:55:58 -0800 (PST) From: Marcin Wojtas To: linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, netdev@vger.kernel.org, linux-acpi@vger.kernel.org Cc: graeme.gregory@linaro.org, davem@davemloft.net, linux@armlinux.org.uk, rafael.j.wysocki@intel.com, andrew@lunn.ch, f.fainelli@gmail.com, antoine.tenart@free-electrons.com, thomas.petazzoni@free-electrons.com, gregory.clement@free-electrons.com, stefanc@marvell.com, nadavh@marvell.com, neta@marvell.com, ard.biesheuvel@linaro.org, mw@semihalf.com, jaz@semihalf.com, tn@semihalf.com Subject: [net-next: PATCH v3 1/7] device property: Introduce fwnode_get_mac_address() Date: Wed, 17 Jan 2018 17:55:40 +0100 Message-Id: <1516208146-4144-2-git-send-email-mw@semihalf.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1516208146-4144-1-git-send-email-mw@semihalf.com> References: <1516208146-4144-1-git-send-email-mw@semihalf.com> Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org Until now there were two almost identical functions for obtaining MAC address - of_get_mac_address() and, more generic, device_get_mac_address(). However it is not uncommon, that the network interface is represented as a child of the actual controller, hence it is not associated directly to any struct device, required by the latter routine. This commit allows for getting the MAC address for children nodes in the ACPI world by introducing a new function - fwnode_get_mac_address(). This commit also changes device_get_mac_address() routine to be its wrapper, in order to prevent unnecessary duplication. Signed-off-by: Marcin Wojtas Acked-by: Rafael J. Wysocki --- drivers/base/property.c | 28 ++++++++++++++------ include/linux/property.h | 2 ++ 2 files changed, 22 insertions(+), 8 deletions(-) diff --git a/drivers/base/property.c b/drivers/base/property.c index 851b1b6..f261d1a 100644 --- a/drivers/base/property.c +++ b/drivers/base/property.c @@ -1153,11 +1153,11 @@ int device_get_phy_mode(struct device *dev) } EXPORT_SYMBOL_GPL(device_get_phy_mode); -static void *device_get_mac_addr(struct device *dev, +static void *fwnode_get_mac_addr(struct fwnode_handle *fwnode, const char *name, char *addr, int alen) { - int ret = device_property_read_u8_array(dev, name, addr, alen); + int ret = fwnode_property_read_u8_array(fwnode, name, addr, alen); if (ret == 0 && alen == ETH_ALEN && is_valid_ether_addr(addr)) return addr; @@ -1165,8 +1165,8 @@ static void *device_get_mac_addr(struct device *dev, } /** - * device_get_mac_address - Get the MAC for a given device - * @dev: Pointer to the device + * fwnode_get_mac_address - Get the MAC from the firmware node + * @fwnode: Pointer to the firmware node * @addr: Address of buffer to store the MAC in * @alen: Length of the buffer pointed to by addr, should be ETH_ALEN * @@ -1187,19 +1187,31 @@ static void *device_get_mac_addr(struct device *dev, * In this case, the real MAC is in 'local-mac-address', and 'mac-address' * exists but is all zeros. */ -void *device_get_mac_address(struct device *dev, char *addr, int alen) +void *fwnode_get_mac_address(struct fwnode_handle *fwnode, char *addr, int alen) { char *res; - res = device_get_mac_addr(dev, "mac-address", addr, alen); + res = fwnode_get_mac_addr(fwnode, "mac-address", addr, alen); if (res) return res; - res = device_get_mac_addr(dev, "local-mac-address", addr, alen); + res = fwnode_get_mac_addr(fwnode, "local-mac-address", addr, alen); if (res) return res; - return device_get_mac_addr(dev, "address", addr, alen); + return fwnode_get_mac_addr(fwnode, "address", addr, alen); +} +EXPORT_SYMBOL(fwnode_get_mac_address); + +/** + * device_get_mac_address - Get the MAC for a given device + * @dev: Pointer to the device + * @addr: Address of buffer to store the MAC in + * @alen: Length of the buffer pointed to by addr, should be ETH_ALEN + */ +void *device_get_mac_address(struct device *dev, char *addr, int alen) +{ + return fwnode_get_mac_address(dev_fwnode(dev), addr, alen); } EXPORT_SYMBOL(device_get_mac_address); diff --git a/include/linux/property.h b/include/linux/property.h index f6189a3..35620e0 100644 --- a/include/linux/property.h +++ b/include/linux/property.h @@ -279,6 +279,8 @@ int device_get_phy_mode(struct device *dev); void *device_get_mac_address(struct device *dev, char *addr, int alen); +void *fwnode_get_mac_address(struct fwnode_handle *fwnode, + char *addr, int alen); struct fwnode_handle *fwnode_graph_get_next_endpoint( const struct fwnode_handle *fwnode, struct fwnode_handle *prev); struct fwnode_handle * From patchwork Wed Jan 17 16:55:41 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marcin Wojtas X-Patchwork-Id: 862396 X-Patchwork-Delegate: davem@davemloft.net Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=vger.kernel.org (client-ip=209.132.180.67; helo=vger.kernel.org; envelope-from=netdev-owner@vger.kernel.org; receiver=) Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=semihalf-com.20150623.gappssmtp.com header.i=@semihalf-com.20150623.gappssmtp.com header.b="KblEsJYa"; dkim-atps=neutral Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 3zMD0z3CCdz9s7v for ; Thu, 18 Jan 2018 04:02:43 +1100 (AEDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754315AbeAQRCb (ORCPT ); Wed, 17 Jan 2018 12:02:31 -0500 Received: from mail-lf0-f67.google.com ([209.85.215.67]:33531 "EHLO mail-lf0-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754196AbeAQQ4D (ORCPT ); Wed, 17 Jan 2018 11:56:03 -0500 Received: by mail-lf0-f67.google.com with SMTP id t139so8079419lff.0 for ; Wed, 17 Jan 2018 08:56:02 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=semihalf-com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=jKprDKMODG9MbDYI6DimVorOrRWyWIOEnGpxRAChLjU=; b=KblEsJYah5DGvaiyG9Rw8yK8dZ33tCs7P/GNdylmVbwXhCmicSqn49ikYIfMC9+Gg4 szGXYvd0ogIkp7xWOJu564+jHBxVYEngWmlLFQQ849PK2GJO4xf8UMPIWz8VLCSllbQL +8lBvVnKADv09qWbyUUc0iwgYvCktI9MiAfIx0z5b8KTB7y73UyASFdQDTVq6Uu7dKPf 7A3Pp2dlHr+rf39GkX4FDEYyMEWmwYdQ3bX3i9qoRB8qVyuISYFpR5uoEt9Dj8iXUyFJ c6bTm6nJ16SW1d9IZAd/bdp9rvq7uadRT8af9tdth0nHsp1tKM4TYKGfMcbFCOVocq2/ i82w== 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; bh=jKprDKMODG9MbDYI6DimVorOrRWyWIOEnGpxRAChLjU=; b=IuWndVJB3KOlkFfu6KhCZT/uck5/6y2WdyQQBBkSgV1DIxUaRQ5CZ2zBkDfd6vIqTH oZWIbNvUBxUJjdphNrt0WwXhQWm58vejQ07an5FWpfPLMUzdEfYlhJ2E4x+iJiu2IydC ItcCqpHvW8njRM3Y1ZllQhXMbKItAdwC+eVsEmaBJOOcT7v4L1jcglLtohhqQu7Yi0ID C3ng47zyI0dqei52LiZpRqEq9ZLGz7ovMkQB7+QqYqwTUumNrrATwqyy2ES4bigyu9xY Uld4Knx0hiQw7BNT8Cim8+8cuAEp/Qc9NCNSGcnhb6zdLfGdi7KNOhwBK4jOjO3M9lkE l/1w== X-Gm-Message-State: AKwxytf+ognJgBnkwgxTQfrATvUcQ8yJwZ6l6k3w+OHTXWqW+cHW1va+ KX1Jq5OX8G37V2eV/0lRG3K4Vw== X-Google-Smtp-Source: ACJfBovXMZNNdMAmn5DZBfid6IY7s4EliNlIEmVJ2+oqzq8coOV5HHkdsKCwLKBQTk3AL4COIHHc6g== X-Received: by 10.46.60.7 with SMTP id j7mr1146574lja.6.1516208161249; Wed, 17 Jan 2018 08:56:01 -0800 (PST) Received: from gilgamesh.semihalf.com (31-172-191-173.noc.fibertech.net.pl. [31.172.191.173]) by smtp.gmail.com with ESMTPSA id t81sm868347lff.47.2018.01.17.08.55.59 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 17 Jan 2018 08:56:00 -0800 (PST) From: Marcin Wojtas To: linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, netdev@vger.kernel.org, linux-acpi@vger.kernel.org Cc: graeme.gregory@linaro.org, davem@davemloft.net, linux@armlinux.org.uk, rafael.j.wysocki@intel.com, andrew@lunn.ch, f.fainelli@gmail.com, antoine.tenart@free-electrons.com, thomas.petazzoni@free-electrons.com, gregory.clement@free-electrons.com, stefanc@marvell.com, nadavh@marvell.com, neta@marvell.com, ard.biesheuvel@linaro.org, mw@semihalf.com, jaz@semihalf.com, tn@semihalf.com Subject: [net-next: PATCH v3 2/7] device property: Introduce fwnode_get_phy_mode() Date: Wed, 17 Jan 2018 17:55:41 +0100 Message-Id: <1516208146-4144-3-git-send-email-mw@semihalf.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1516208146-4144-1-git-send-email-mw@semihalf.com> References: <1516208146-4144-1-git-send-email-mw@semihalf.com> Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org Until now there were two almost identical functions for obtaining network PHY mode - of_get_phy_mode() and, more generic, device_get_phy_mode(). However it is not uncommon, that the network interface is represented as a child of the actual controller, hence it is not associated directly to any struct device, required by the latter routine. This commit allows for getting the PHY mode for children nodes in the ACPI world by introducing a new function - fwnode_get_phy_mode(). This commit also changes device_get_phy_mode() routine to be its wrapper, in order to prevent unnecessary duplication. Signed-off-by: Marcin Wojtas Acked-by: Rafael J. Wysocki --- drivers/base/property.c | 24 ++++++++++++++++---- include/linux/property.h | 1 + 2 files changed, 20 insertions(+), 5 deletions(-) diff --git a/drivers/base/property.c b/drivers/base/property.c index f261d1a..7c4a53d 100644 --- a/drivers/base/property.c +++ b/drivers/base/property.c @@ -1126,21 +1126,21 @@ enum dev_dma_attr device_get_dma_attr(struct device *dev) EXPORT_SYMBOL_GPL(device_get_dma_attr); /** - * device_get_phy_mode - Get phy mode for given device - * @dev: Pointer to the given device + * fwnode_get_phy_mode - Get phy mode for given firmware node + * @fwnode: Pointer to the given node * * The function gets phy interface string from property 'phy-mode' or * 'phy-connection-type', and return its index in phy_modes table, or errno in * error case. */ -int device_get_phy_mode(struct device *dev) +int fwnode_get_phy_mode(struct fwnode_handle *fwnode) { const char *pm; int err, i; - err = device_property_read_string(dev, "phy-mode", &pm); + err = fwnode_property_read_string(fwnode, "phy-mode", &pm); if (err < 0) - err = device_property_read_string(dev, + err = fwnode_property_read_string(fwnode, "phy-connection-type", &pm); if (err < 0) return err; @@ -1151,6 +1151,20 @@ int device_get_phy_mode(struct device *dev) return -ENODEV; } +EXPORT_SYMBOL_GPL(fwnode_get_phy_mode); + +/** + * device_get_phy_mode - Get phy mode for given device + * @dev: Pointer to the given device + * + * The function gets phy interface string from property 'phy-mode' or + * 'phy-connection-type', and return its index in phy_modes table, or errno in + * error case. + */ +int device_get_phy_mode(struct device *dev) +{ + return fwnode_get_phy_mode(dev_fwnode(dev)); +} EXPORT_SYMBOL_GPL(device_get_phy_mode); static void *fwnode_get_mac_addr(struct fwnode_handle *fwnode, diff --git a/include/linux/property.h b/include/linux/property.h index 35620e0..9b13332 100644 --- a/include/linux/property.h +++ b/include/linux/property.h @@ -279,6 +279,7 @@ int device_get_phy_mode(struct device *dev); void *device_get_mac_address(struct device *dev, char *addr, int alen); +int fwnode_get_phy_mode(struct fwnode_handle *fwnode); void *fwnode_get_mac_address(struct fwnode_handle *fwnode, char *addr, int alen); struct fwnode_handle *fwnode_graph_get_next_endpoint( From patchwork Wed Jan 17 16:55:42 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marcin Wojtas X-Patchwork-Id: 862395 X-Patchwork-Delegate: davem@davemloft.net Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=vger.kernel.org (client-ip=209.132.180.67; helo=vger.kernel.org; envelope-from=netdev-owner@vger.kernel.org; receiver=) Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=semihalf-com.20150623.gappssmtp.com header.i=@semihalf-com.20150623.gappssmtp.com header.b="DHeOjbkS"; dkim-atps=neutral Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 3zMCzx1myhz9s7f for ; Thu, 18 Jan 2018 04:01:49 +1100 (AEDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932157AbeAQQ4I (ORCPT ); Wed, 17 Jan 2018 11:56:08 -0500 Received: from mail-lf0-f65.google.com ([209.85.215.65]:39255 "EHLO mail-lf0-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754204AbeAQQ4E (ORCPT ); Wed, 17 Jan 2018 11:56:04 -0500 Received: by mail-lf0-f65.google.com with SMTP id m8so22861976lfc.6 for ; Wed, 17 Jan 2018 08:56:03 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=semihalf-com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=21Mi6hIYM3zfmLCRPrLyE3plIUz4Ga5083/xGwgP8HE=; b=DHeOjbkS+zUjewqXHxE3yJqEWbuQdpwAfuUD1HI7J6QuivOHYpWrRu4nN+hesABOAs +xz6kgp6qX8JYOpyZ1bHF0zULulpC6VpF+LVz6n0sD7eSdWpb5fASA1i0ncVLRw5jdiH bb2u56zwgmToZPA/zLRFDLjjaFxsO+5mjCY8UFK1gyq6toyVT7EZKqkB3TqKvYBahaRz PC/+M5mZ8uC/QhPeV6uI3s4V9ADJmV9zMJMb1iXiQ4jX/sejf4bTN7w/FwPEwPShmDsn uSO1pvslzp9mfwesH07RQfkIecrx70MKFpEBEHpMcmmtPmRz6so6N/tP6vpmq3gc2N3J PX3w== 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; bh=21Mi6hIYM3zfmLCRPrLyE3plIUz4Ga5083/xGwgP8HE=; b=NvoVUsOZKd7dLyejrSqOohHseUdP9lxMnf6qODanKPB1TLoR8LbsLkm+WSvl66zQJg xlqVPfDCBqER37Avms+1tubKs2V4b8LbAWeTsgo0IFA5+hc0DM+eY6SVqruhOHpBRnZn xHEIEJ9Q6OVilXCWW4VDcSwg2uDgp35CLCyYEyQXsr4eBu3RdGsIvWS5V4ubTWExzYIk 5dUnss3cijYNU1AccdDYbKcqphseC9Ve/c4vs6AsCVipU4d7E66J2nBbD71sTIwHB6fJ fsH20Wrko40FF70r8Ma8tnAWeF1yBjknEZnUpPJ197dkpik6WYJsBr+8L6W1cs8QBNCP KMLw== X-Gm-Message-State: AKwxyteR8zMGzcOBr28ujc8wkziZHe8E5RHUGE69FybfkZEIl/nNb5Iv zdTPQf2VQozBxYD6LeCmeYFYHA== X-Google-Smtp-Source: ACJfBov4pIlPpsHkypuBYouInsS7jh5vcghQ5TBtA+C4nKd0PDdjaFJ5Ljkz8gXn8Cg+juB7deqyfw== X-Received: by 10.46.85.149 with SMTP id g21mr19309252lje.118.1516208162761; Wed, 17 Jan 2018 08:56:02 -0800 (PST) Received: from gilgamesh.semihalf.com (31-172-191-173.noc.fibertech.net.pl. [31.172.191.173]) by smtp.gmail.com with ESMTPSA id t81sm868347lff.47.2018.01.17.08.56.01 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 17 Jan 2018 08:56:02 -0800 (PST) From: Marcin Wojtas To: linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, netdev@vger.kernel.org, linux-acpi@vger.kernel.org Cc: graeme.gregory@linaro.org, davem@davemloft.net, linux@armlinux.org.uk, rafael.j.wysocki@intel.com, andrew@lunn.ch, f.fainelli@gmail.com, antoine.tenart@free-electrons.com, thomas.petazzoni@free-electrons.com, gregory.clement@free-electrons.com, stefanc@marvell.com, nadavh@marvell.com, neta@marvell.com, ard.biesheuvel@linaro.org, mw@semihalf.com, jaz@semihalf.com, tn@semihalf.com Subject: [net-next: PATCH v3 3/7] device property: Introduce fwnode_irq_get() Date: Wed, 17 Jan 2018 17:55:42 +0100 Message-Id: <1516208146-4144-4-git-send-email-mw@semihalf.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1516208146-4144-1-git-send-email-mw@semihalf.com> References: <1516208146-4144-1-git-send-email-mw@semihalf.com> Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org Until now there were two very similar functions allowing to get Linux IRQ number from ACPI handle (acpi_irq_get()) and OF node (of_irq_get()). The first one appeared to be used only as a subroutine of platform_irq_get(), which (in the generic code) limited IRQ obtaining from _CRS method only to nodes associated to kernel's struct platform_device. This patch introduces new helper routine - fwnode_irq_get(), which allows to get the IRQ number directly from the fwnode to be used as common for OF/ACPI worlds. Signed-off-by: Marcin Wojtas --- drivers/base/property.c | 27 ++++++++++++++++++++ include/linux/property.h | 2 ++ 2 files changed, 29 insertions(+) diff --git a/drivers/base/property.c b/drivers/base/property.c index 7c4a53d..adb3893 100644 --- a/drivers/base/property.c +++ b/drivers/base/property.c @@ -16,6 +16,7 @@ #include #include #include +#include #include #include #include @@ -1230,6 +1231,32 @@ void *device_get_mac_address(struct device *dev, char *addr, int alen) EXPORT_SYMBOL(device_get_mac_address); /** + * fwnode_irq_get - Get IRQ directly from a fwnode + * @fwnode: Pointer to the firmware node + * @index: Zero-based index of the IRQ + * + * Returns Linux IRQ number on success. Other values are determined + * accordingly to acpi_/of_ irq_get() operation. + */ +int fwnode_irq_get(struct fwnode_handle *fwnode, unsigned int index) +{ + struct acpi_device *adev = to_acpi_device_node(fwnode); + struct device_node *of_node = to_of_node(fwnode); + struct resource res; + int ret; + + if (IS_ENABLED(CONFIG_OF) && of_node) + return of_irq_get(of_node, index); + + ret = acpi_irq_get(acpi_device_handle(adev), index, &res); + if (ret) + return ret; + + return res.start; +} +EXPORT_SYMBOL(fwnode_irq_get); + +/** * device_graph_get_next_endpoint - Get next endpoint firmware node * @fwnode: Pointer to the parent firmware node * @prev: Previous endpoint node or %NULL to get the first diff --git a/include/linux/property.h b/include/linux/property.h index 9b13332..e05889f 100644 --- a/include/linux/property.h +++ b/include/linux/property.h @@ -103,6 +103,8 @@ struct fwnode_handle *device_get_named_child_node(struct device *dev, struct fwnode_handle *fwnode_handle_get(struct fwnode_handle *fwnode); void fwnode_handle_put(struct fwnode_handle *fwnode); +int fwnode_irq_get(struct fwnode_handle *fwnode, unsigned int index); + unsigned int device_get_child_node_count(struct device *dev); static inline bool device_property_read_bool(struct device *dev, From patchwork Wed Jan 17 16:55:43 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marcin Wojtas X-Patchwork-Id: 862392 X-Patchwork-Delegate: davem@davemloft.net Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=vger.kernel.org (client-ip=209.132.180.67; helo=vger.kernel.org; envelope-from=netdev-owner@vger.kernel.org; receiver=) Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=semihalf-com.20150623.gappssmtp.com header.i=@semihalf-com.20150623.gappssmtp.com header.b="pooGuAOO"; dkim-atps=neutral Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 3zMCy25mjYz9s82 for ; Thu, 18 Jan 2018 04:00:10 +1100 (AEDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932208AbeAQQ4L (ORCPT ); Wed, 17 Jan 2018 11:56:11 -0500 Received: from mail-lf0-f66.google.com ([209.85.215.66]:43636 "EHLO mail-lf0-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932117AbeAQQ4F (ORCPT ); Wed, 17 Jan 2018 11:56:05 -0500 Received: by mail-lf0-f66.google.com with SMTP id o89so18725596lfg.10 for ; Wed, 17 Jan 2018 08:56:05 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=semihalf-com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=pxap/R5wa0XF20u/yQeInSOH0yKEnEjE91GRTWZpM9w=; b=pooGuAOOl4HqW5VyqETdROIjnzfG+30dvYyIJlb5raLD1XafllGmh9zYHy+eQbzsqJ iXIArqa54TRod+Mguz9I2Xs2MxuQPiVFU7cwAH8TbJqv/nuRbm93ieLiFusuSl6t+uXO NrsuJjQ6k7W6CeDgKMPvVPnKz3I2WLCmaiemsx1C1JXvpP0VfXQP58jpfy3dYVz8kZ1y Zde71uTrTYKGuJHSk3cL3hv3r0rUZS38YNu66JC5dtXRmSFQzM5AkL2CSZzU9mcDjZ11 0gZQ6Qj/DlPTwrUpoq9mFRzbpsD4mltenxQAvBF/eFLcbY+EhultDTOtI47WgXWnktSf syqg== 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; bh=pxap/R5wa0XF20u/yQeInSOH0yKEnEjE91GRTWZpM9w=; b=l6Fa6VBz7vcePXACc84JiCMjxYABUwjU2T9uFtd8be9K6DsdAk3wdcXmUnaZUu+bqw P2n1TMT33xApDz6+oZT3bC6Qm8G0kPZbQr6J2z3kLWnZhbJIhgmduHnO6t6mXnSieaIQ R5BcFvMlnWSiJqRA65FiM1acTInHFU8sGVeXqYM0W3UUcWj3dP1A7dXmYc/NHQs5XMKN aC+QRPJ3jdGPuUMyju9iYn/vchTIQzfp6ViKCCW31Wx8smJWG/UEkikCWbgeljKTB7oC oOIwwyHINzeGBpZhr+QoQGdNgizbRZiTF5Ezv+ObFyxhDR6RtIXyKWSrRfcKnvLkOGi3 Fkww== X-Gm-Message-State: AKwxyteF+Ds6ItWN73uvkK+oMMGsPYefWn3hCHkhVJx6adDi/+H4RAJF o9DgIk53RpwSlXqBXWJS35wPZg== X-Google-Smtp-Source: ACJfBosYfcM9QzmuKpYVRZwTxHMzRy2QSaxQAp9pP+pRQkxwEWgIi9Zg9fZJtnsgWqg8z+QPTGZhyw== X-Received: by 10.46.2.221 with SMTP id y90mr6312568lje.39.1516208164340; Wed, 17 Jan 2018 08:56:04 -0800 (PST) Received: from gilgamesh.semihalf.com (31-172-191-173.noc.fibertech.net.pl. [31.172.191.173]) by smtp.gmail.com with ESMTPSA id t81sm868347lff.47.2018.01.17.08.56.02 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 17 Jan 2018 08:56:03 -0800 (PST) From: Marcin Wojtas To: linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, netdev@vger.kernel.org, linux-acpi@vger.kernel.org Cc: graeme.gregory@linaro.org, davem@davemloft.net, linux@armlinux.org.uk, rafael.j.wysocki@intel.com, andrew@lunn.ch, f.fainelli@gmail.com, antoine.tenart@free-electrons.com, thomas.petazzoni@free-electrons.com, gregory.clement@free-electrons.com, stefanc@marvell.com, nadavh@marvell.com, neta@marvell.com, ard.biesheuvel@linaro.org, mw@semihalf.com, jaz@semihalf.com, tn@semihalf.com Subject: [net-next: PATCH v3 4/7] device property: Allow iterating over available child fwnodes Date: Wed, 17 Jan 2018 17:55:43 +0100 Message-Id: <1516208146-4144-5-git-send-email-mw@semihalf.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1516208146-4144-1-git-send-email-mw@semihalf.com> References: <1516208146-4144-1-git-send-email-mw@semihalf.com> Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org Implement a new helper function fwnode_get_next_available_child_node(), which enables obtaining next enabled child fwnode, which works on a similar basis to OF's of_get_next_available_child(). This commit also introduces a macro, thanks to which it is possible to iterate over the available fwnodes, using the new function described above. Signed-off-by: Marcin Wojtas --- drivers/base/property.c | 26 ++++++++++++++++++++ include/linux/property.h | 6 +++++ 2 files changed, 32 insertions(+) diff --git a/drivers/base/property.c b/drivers/base/property.c index adb3893..2343906 100644 --- a/drivers/base/property.c +++ b/drivers/base/property.c @@ -998,6 +998,32 @@ fwnode_get_next_child_node(const struct fwnode_handle *fwnode, EXPORT_SYMBOL_GPL(fwnode_get_next_child_node); /** + * fwnode_get_next_available_child_node - Return the next + * available child node handle for a node + * @fwnode: Firmware node to find the next child node for. + * @child: Handle to one of the node's child nodes or a %NULL handle. + */ +struct fwnode_handle * +fwnode_get_next_available_child_node(const struct fwnode_handle *fwnode, + struct fwnode_handle *child) +{ + struct fwnode_handle *next_child = child; + + if (!fwnode) + return NULL; + + do { + next_child = fwnode_get_next_child_node(fwnode, next_child); + + if (!next_child || fwnode_device_is_available(next_child)) + break; + } while (next_child); + + return next_child; +} +EXPORT_SYMBOL_GPL(fwnode_get_next_available_child_node); + +/** * device_get_next_child_node - Return the next child node handle for a device * @dev: Device to find the next child node for. * @child: Handle to one of the device's child nodes or a null handle. diff --git a/include/linux/property.h b/include/linux/property.h index e05889f..5b0563a 100644 --- a/include/linux/property.h +++ b/include/linux/property.h @@ -83,11 +83,17 @@ struct fwnode_handle *fwnode_get_next_parent( struct fwnode_handle *fwnode); struct fwnode_handle *fwnode_get_next_child_node( const struct fwnode_handle *fwnode, struct fwnode_handle *child); +struct fwnode_handle *fwnode_get_next_available_child_node( + const struct fwnode_handle *fwnode, struct fwnode_handle *child); #define fwnode_for_each_child_node(fwnode, child) \ for (child = fwnode_get_next_child_node(fwnode, NULL); child; \ child = fwnode_get_next_child_node(fwnode, child)) +#define fwnode_for_each_available_child_node(fwnode, child) \ + for (child = fwnode_get_next_available_child_node(fwnode, NULL); child;\ + child = fwnode_get_next_available_child_node(fwnode, child)) + struct fwnode_handle *device_get_next_child_node( struct device *dev, struct fwnode_handle *child); From patchwork Wed Jan 17 16:55:44 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marcin Wojtas X-Patchwork-Id: 862394 X-Patchwork-Delegate: davem@davemloft.net Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=vger.kernel.org (client-ip=209.132.180.67; helo=vger.kernel.org; envelope-from=netdev-owner@vger.kernel.org; receiver=) Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=semihalf-com.20150623.gappssmtp.com header.i=@semihalf-com.20150623.gappssmtp.com header.b="o+ODlGiz"; dkim-atps=neutral Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 3zMCzm3cJ2z9ryr for ; Thu, 18 Jan 2018 04:01:40 +1100 (AEDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754323AbeAQRB2 (ORCPT ); Wed, 17 Jan 2018 12:01:28 -0500 Received: from mail-lf0-f66.google.com ([209.85.215.66]:46432 "EHLO mail-lf0-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932124AbeAQQ4I (ORCPT ); Wed, 17 Jan 2018 11:56:08 -0500 Received: by mail-lf0-f66.google.com with SMTP id q194so11382834lfe.13 for ; Wed, 17 Jan 2018 08:56:07 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=semihalf-com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=oj0JajkqNds/vxCnFWY1cB89VnOimwCruDlOqJl844E=; b=o+ODlGizZRkhynp+KSUze1biLUXzpvQnvhjxGWQQnU9y1ujLZV7ppnu/iz7tmF3rTO 62DOkj8CBvAGAE7aGlePwKnosY2AhJ2rBpQV8fMGMT2utlA6GA2bRtll9X2MxpeO+ODx 9KZvh9H4HqNvsSPUHKvabbfBOQwf80ewaft/IGHOr+N6jG3xvz+SGzmu3QZR+NpvsEea rQNgEpGaYJmZYu2b+ycRLIH1KeSDn00tIOY/y1Zul4oDa3FxGYQ8UUDSN2hEviovPdIe NMDY5ZKLs+Hyv3mg1s//cBU5E9ZqccyraD8VnN6+ZZEUBHz0T/AXYvjHOd1XGscJGr91 +Mtg== 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; bh=oj0JajkqNds/vxCnFWY1cB89VnOimwCruDlOqJl844E=; b=iCT/KHARTcWWkif+nUBNsFyFJ4TFEcKJUmupkTRSva6cd6+Jdvd63cIRWfk9CkGzLK iHwX7Unyt794O9lTMNYzWh4zKfcD/v5vzxS5HAFqPWVyiJuOTWC86Y1d797BOB/PIpEJ TkDAX5Ks6ZPUmm2hNvO9eda6QBVNOAfTD8BRK/Z2kZ/ORlERgUui4yO0z/Qk9MlKzUrh GZzdS914Th9HD+Y3YAOPu3MUogPotY0t2f0Zo8aIDDUupXIzaKaBmmxL5f9/2OkE1cBX sy9QlYnTLea3iIeg9RZVIiMKvmYJtNir8jRpWpq9B9R0nK15nGkdxMi+XNT6JzMEC359 5F2Q== X-Gm-Message-State: AKwxytfY0myyjePmZUqd1TK7N7qVa2d0nWTBL9nTfM9MXT4lLerBr3p/ VgbUhNUQXx7RVZkseXsywFfm4Q== X-Google-Smtp-Source: ACJfBougJbQjrvSiHgZM26TrO0STA0UhTDBP/bsqf7U851frPUfsX9cHaQ8206NfLGRUqpg94FdeVQ== X-Received: by 10.25.167.85 with SMTP id q82mr5748449lfe.112.1516208166233; Wed, 17 Jan 2018 08:56:06 -0800 (PST) Received: from gilgamesh.semihalf.com (31-172-191-173.noc.fibertech.net.pl. [31.172.191.173]) by smtp.gmail.com with ESMTPSA id t81sm868347lff.47.2018.01.17.08.56.04 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 17 Jan 2018 08:56:05 -0800 (PST) From: Marcin Wojtas To: linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, netdev@vger.kernel.org, linux-acpi@vger.kernel.org Cc: graeme.gregory@linaro.org, davem@davemloft.net, linux@armlinux.org.uk, rafael.j.wysocki@intel.com, andrew@lunn.ch, f.fainelli@gmail.com, antoine.tenart@free-electrons.com, thomas.petazzoni@free-electrons.com, gregory.clement@free-electrons.com, stefanc@marvell.com, nadavh@marvell.com, neta@marvell.com, ard.biesheuvel@linaro.org, mw@semihalf.com, jaz@semihalf.com, tn@semihalf.com Subject: [net-next: PATCH v3 5/7] net: mvpp2: simplify maintaining enabled ports' list Date: Wed, 17 Jan 2018 17:55:44 +0100 Message-Id: <1516208146-4144-6-git-send-email-mw@semihalf.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1516208146-4144-1-git-send-email-mw@semihalf.com> References: <1516208146-4144-1-git-send-email-mw@semihalf.com> Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org 'port_count' field of the mvpp2 structure holds an overall amount of available ports, based on DT nodes status. In order to be prepared to support other HW description, obtain the value by incrementing it upon each successful port initialization. This allowed for simplifying port indexing in the controller's private array, whose size is now not dynamically allocated, but fixed to MVPP2_MAX_PORTS. This patch simplifies creating and filling list of enabled ports and is a part of the preparation for adding ACPI support in the mvpp2 driver. Signed-off-by: Marcin Wojtas --- drivers/net/ethernet/marvell/mvpp2.c | 32 +++++++------------- 1 file changed, 11 insertions(+), 21 deletions(-) diff --git a/drivers/net/ethernet/marvell/mvpp2.c b/drivers/net/ethernet/marvell/mvpp2.c index a197607..7f42d90 100644 --- a/drivers/net/ethernet/marvell/mvpp2.c +++ b/drivers/net/ethernet/marvell/mvpp2.c @@ -865,7 +865,7 @@ struct mvpp2 { /* List of pointers to port structures */ int port_count; - struct mvpp2_port **port_list; + struct mvpp2_port *port_list[MVPP2_MAX_PORTS]; /* Aggregated TXQs */ struct mvpp2_tx_queue *aggr_txqs; @@ -7741,7 +7741,7 @@ static void mvpp2_port_copy_mac_addr(struct net_device *dev, struct mvpp2 *priv, /* Ports initialization */ static int mvpp2_port_probe(struct platform_device *pdev, struct device_node *port_node, - struct mvpp2 *priv, int index) + struct mvpp2 *priv) { struct device_node *phy_node; struct phy *comphy; @@ -7934,7 +7934,8 @@ static int mvpp2_port_probe(struct platform_device *pdev, } netdev_info(dev, "Using %s mac address %pM\n", mac_from, dev->dev_addr); - priv->port_list[index] = port; + priv->port_list[priv->port_count++] = port; + return 0; err_free_port_pcpu: @@ -8313,28 +8314,17 @@ static int mvpp2_probe(struct platform_device *pdev) goto err_mg_clk; } - priv->port_count = of_get_available_child_count(dn); - if (priv->port_count == 0) { - dev_err(&pdev->dev, "no ports enabled\n"); - err = -ENODEV; - goto err_mg_clk; - } - - priv->port_list = devm_kcalloc(&pdev->dev, priv->port_count, - sizeof(*priv->port_list), - GFP_KERNEL); - if (!priv->port_list) { - err = -ENOMEM; - goto err_mg_clk; - } - /* Initialize ports */ - i = 0; for_each_available_child_of_node(dn, port_node) { - err = mvpp2_port_probe(pdev, port_node, priv, i); + err = mvpp2_port_probe(pdev, port_node, priv); if (err < 0) goto err_port_probe; - i++; + } + + if (priv->port_count == 0) { + dev_err(&pdev->dev, "no ports enabled\n"); + err = -ENODEV; + goto err_mg_clk; } /* Statistics must be gathered regularly because some of them (like From patchwork Wed Jan 17 16:55:45 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marcin Wojtas X-Patchwork-Id: 862393 X-Patchwork-Delegate: davem@davemloft.net Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=vger.kernel.org (client-ip=209.132.180.67; helo=vger.kernel.org; envelope-from=netdev-owner@vger.kernel.org; receiver=) Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=semihalf-com.20150623.gappssmtp.com header.i=@semihalf-com.20150623.gappssmtp.com header.b="h6BsVtWU"; dkim-atps=neutral Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 3zMCzK27fQz9s7f for ; Thu, 18 Jan 2018 04:01:17 +1100 (AEDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932085AbeAQRBO (ORCPT ); Wed, 17 Jan 2018 12:01:14 -0500 Received: from mail-lf0-f65.google.com ([209.85.215.65]:42591 "EHLO mail-lf0-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932164AbeAQQ4J (ORCPT ); Wed, 17 Jan 2018 11:56:09 -0500 Received: by mail-lf0-f65.google.com with SMTP id q17so12655402lfa.9 for ; Wed, 17 Jan 2018 08:56:08 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=semihalf-com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=059l5gKkJlkImR9aCud73phj979kYw7YJcePrZ6w1b4=; b=h6BsVtWU+vYQenfRekz7cIi+NXRo8v8ML3BdhOWwMqrBIV9eSsqXP71MyHFMExFFJd HxgpEtByKP7RSiR4uvD/+84L+J2jqIWIzKDmzGudMUeqaFKO5SjL9Fc7UL1NVjQLI5YQ 0hs/O9Ch/2e3hwkAylewd4qG6eIWIZxIOubLafTGIvQBqwZjalxQPEpCYnnijoBJeS6X KpcLQ7ypG41msqr5xpbo3xbIvvtlx71NwIL/EASvVxl5nt5ccOvy7X51OQMpVSRVS/of buedxZNdxqu19LzkZm0Y3DjBEfhYaQRRt2E2Kuvz+XKO6c+DZzGoRIMFt16ZjwAD9bYj isfQ== 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; bh=059l5gKkJlkImR9aCud73phj979kYw7YJcePrZ6w1b4=; b=HEVzyQjLPYeRSMl3ySbNgPZqLLPKcGmImAWvMneJqIAnTQC/pucGaupJ/NbmeWrZhf kFUEvgISPDPStKrZe3CipomvLdTicX7zcjyafiLF8I3DaJNSN6vDhaL+xk0WaxWbvG31 TZQ2imzbb5CHf2jkMQ1iKfcbgAPsHDCmV2e7kDT00Er6DHi5LOHkVprgIsPZ0Ehpf1Fa +zM7wxJ6nQvfeY4WHqQ/KLlB303sVvXqzYA7ECeA47BILyaB3LPDGV0tHgAvAjzb1rBj gySrWIJjbnVwnf1/QLaiaZ7FyKpGPLdEUwW7tup4bFXbFnC5G+G4z4Me91RThqqtKjc8 VPmA== X-Gm-Message-State: AKwxytfnb/SCYvIuc5twAH3KLm02XhBwjxF/DFuMlBfwgyrHr+BLZTcP qjUfu8dNF406yVajQyhGl4JHlA== X-Google-Smtp-Source: ACJfBotve4pF9JPX+QRulcoEb/F6Ib+QSW3bRnB4rOY0grYIaxmOP87Ji7CSvxTe1NAposKbWcS8Pw== X-Received: by 10.25.25.208 with SMTP id 199mr1994080lfz.146.1516208167927; Wed, 17 Jan 2018 08:56:07 -0800 (PST) Received: from gilgamesh.semihalf.com (31-172-191-173.noc.fibertech.net.pl. [31.172.191.173]) by smtp.gmail.com with ESMTPSA id t81sm868347lff.47.2018.01.17.08.56.06 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 17 Jan 2018 08:56:07 -0800 (PST) From: Marcin Wojtas To: linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, netdev@vger.kernel.org, linux-acpi@vger.kernel.org Cc: graeme.gregory@linaro.org, davem@davemloft.net, linux@armlinux.org.uk, rafael.j.wysocki@intel.com, andrew@lunn.ch, f.fainelli@gmail.com, antoine.tenart@free-electrons.com, thomas.petazzoni@free-electrons.com, gregory.clement@free-electrons.com, stefanc@marvell.com, nadavh@marvell.com, neta@marvell.com, ard.biesheuvel@linaro.org, mw@semihalf.com, jaz@semihalf.com, tn@semihalf.com Subject: [net-next: PATCH v3 6/7] net: mvpp2: use device_*/fwnode_* APIs instead of of_* Date: Wed, 17 Jan 2018 17:55:45 +0100 Message-Id: <1516208146-4144-7-git-send-email-mw@semihalf.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1516208146-4144-1-git-send-email-mw@semihalf.com> References: <1516208146-4144-1-git-send-email-mw@semihalf.com> Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org OF functions can be used only for the driver using DT. As a preparation for introducing ACPI support in mvpp2 driver, use struct fwnode_handle in order to obtain properties from the hardware description. This patch replaces of_* function with device_*/fwnode_* where possible in the mvpp2. Signed-off-by: Marcin Wojtas --- drivers/net/ethernet/marvell/mvpp2.c | 45 +++++++++++--------- 1 file changed, 24 insertions(+), 21 deletions(-) diff --git a/drivers/net/ethernet/marvell/mvpp2.c b/drivers/net/ethernet/marvell/mvpp2.c index 7f42d90..f16448e 100644 --- a/drivers/net/ethernet/marvell/mvpp2.c +++ b/drivers/net/ethernet/marvell/mvpp2.c @@ -932,6 +932,9 @@ struct mvpp2_port { struct mvpp2 *priv; + /* Firmware node associated to the port */ + struct fwnode_handle *fwnode; + /* Per-port registers' base address */ void __iomem *base; void __iomem *stats_base; @@ -7711,17 +7714,16 @@ static bool mvpp2_port_has_tx_irqs(struct mvpp2 *priv, } static void mvpp2_port_copy_mac_addr(struct net_device *dev, struct mvpp2 *priv, - struct device_node *port_node, + struct fwnode_handle *fwnode, char **mac_from) { struct mvpp2_port *port = netdev_priv(dev); char hw_mac_addr[ETH_ALEN] = {0}; - const char *dt_mac_addr; + char fw_mac_addr[ETH_ALEN]; - dt_mac_addr = of_get_mac_address(port_node); - if (dt_mac_addr && is_valid_ether_addr(dt_mac_addr)) { - *mac_from = "device tree"; - ether_addr_copy(dev->dev_addr, dt_mac_addr); + if (fwnode_get_mac_address(fwnode, fw_mac_addr, ETH_ALEN)) { + *mac_from = "firmware node"; + ether_addr_copy(dev->dev_addr, fw_mac_addr); return; } @@ -7740,13 +7742,14 @@ static void mvpp2_port_copy_mac_addr(struct net_device *dev, struct mvpp2 *priv, /* Ports initialization */ static int mvpp2_port_probe(struct platform_device *pdev, - struct device_node *port_node, + struct fwnode_handle *port_fwnode, struct mvpp2 *priv) { struct device_node *phy_node; struct phy *comphy; struct mvpp2_port *port; struct mvpp2_port_pcpu *port_pcpu; + struct device_node *port_node = to_of_node(port_fwnode); struct net_device *dev; struct resource *res; char *mac_from = ""; @@ -7773,7 +7776,7 @@ static int mvpp2_port_probe(struct platform_device *pdev, return -ENOMEM; phy_node = of_parse_phandle(port_node, "phy", 0); - phy_mode = of_get_phy_mode(port_node); + phy_mode = fwnode_get_phy_mode(port_fwnode); if (phy_mode < 0) { dev_err(&pdev->dev, "incorrect phy mode\n"); err = phy_mode; @@ -7789,7 +7792,7 @@ static int mvpp2_port_probe(struct platform_device *pdev, comphy = NULL; } - if (of_property_read_u32(port_node, "port-id", &id)) { + if (fwnode_property_read_u32(port_fwnode, "port-id", &id)) { err = -EINVAL; dev_err(&pdev->dev, "missing port-id value\n"); goto err_free_netdev; @@ -7820,7 +7823,7 @@ static int mvpp2_port_probe(struct platform_device *pdev, /* the link irq is optional */ port->link_irq = 0; - if (of_property_read_bool(port_node, "marvell,loopback")) + if (fwnode_property_read_bool(port_fwnode, "marvell,loopback")) port->flags |= MVPP2_F_LOOPBACK; port->id = id; @@ -7845,8 +7848,8 @@ static int mvpp2_port_probe(struct platform_device *pdev, MVPP21_MIB_COUNTERS_OFFSET + port->gop_id * MVPP21_MIB_COUNTERS_PORT_SZ; } else { - if (of_property_read_u32(port_node, "gop-port-id", - &port->gop_id)) { + if (fwnode_property_read_u32(port_fwnode, "gop-port-id", + &port->gop_id)) { err = -EINVAL; dev_err(&pdev->dev, "missing gop-port-id value\n"); goto err_deinit_qvecs; @@ -7876,7 +7879,7 @@ static int mvpp2_port_probe(struct platform_device *pdev, mutex_init(&port->gather_stats_lock); INIT_DELAYED_WORK(&port->stats_work, mvpp2_gather_hw_statistics); - mvpp2_port_copy_mac_addr(dev, priv, port_node, &mac_from); + mvpp2_port_copy_mac_addr(dev, priv, port_fwnode, &mac_from); port->tx_ring_size = MVPP2_MAX_TXD_DFLT; port->rx_ring_size = MVPP2_MAX_RXD_DFLT; @@ -8194,8 +8197,8 @@ static int mvpp2_init(struct platform_device *pdev, struct mvpp2 *priv) static int mvpp2_probe(struct platform_device *pdev) { - struct device_node *dn = pdev->dev.of_node; - struct device_node *port_node; + struct fwnode_handle *fwnode = pdev->dev.fwnode; + struct fwnode_handle *port_fwnode; struct mvpp2 *priv; struct resource *res; void __iomem *base; @@ -8315,8 +8318,8 @@ static int mvpp2_probe(struct platform_device *pdev) } /* Initialize ports */ - for_each_available_child_of_node(dn, port_node) { - err = mvpp2_port_probe(pdev, port_node, priv); + fwnode_for_each_available_child_node(fwnode, port_fwnode) { + err = mvpp2_port_probe(pdev, port_fwnode, priv); if (err < 0) goto err_port_probe; } @@ -8347,7 +8350,7 @@ static int mvpp2_probe(struct platform_device *pdev) err_port_probe: i = 0; - for_each_available_child_of_node(dn, port_node) { + fwnode_for_each_available_child_node(fwnode, port_fwnode) { if (priv->port_list[i]) mvpp2_port_remove(priv->port_list[i]); i++; @@ -8366,14 +8369,14 @@ static int mvpp2_probe(struct platform_device *pdev) static int mvpp2_remove(struct platform_device *pdev) { struct mvpp2 *priv = platform_get_drvdata(pdev); - struct device_node *dn = pdev->dev.of_node; - struct device_node *port_node; + struct fwnode_handle *fwnode = pdev->dev.fwnode; + struct fwnode_handle *port_fwnode; int i = 0; flush_workqueue(priv->stats_queue); destroy_workqueue(priv->stats_queue); - for_each_available_child_of_node(dn, port_node) { + fwnode_for_each_available_child_node(fwnode, port_fwnode) { if (priv->port_list[i]) { mutex_destroy(&priv->port_list[i]->gather_stats_lock); mvpp2_port_remove(priv->port_list[i]); From patchwork Wed Jan 17 16:55:46 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marcin Wojtas X-Patchwork-Id: 862390 X-Patchwork-Delegate: davem@davemloft.net Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=vger.kernel.org (client-ip=209.132.180.67; helo=vger.kernel.org; envelope-from=netdev-owner@vger.kernel.org; receiver=) Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=semihalf-com.20150623.gappssmtp.com header.i=@semihalf-com.20150623.gappssmtp.com header.b="QxJ/FH7n"; dkim-atps=neutral Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 3zMCxh72TLz9s7v for ; Thu, 18 Jan 2018 03:59:52 +1100 (AEDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932251AbeAQQ7d (ORCPT ); Wed, 17 Jan 2018 11:59:33 -0500 Received: from mail-lf0-f66.google.com ([209.85.215.66]:39297 "EHLO mail-lf0-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932071AbeAQQ4L (ORCPT ); Wed, 17 Jan 2018 11:56:11 -0500 Received: by mail-lf0-f66.google.com with SMTP id m8so22862544lfc.6 for ; Wed, 17 Jan 2018 08:56:10 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=semihalf-com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=xupd2XgD2fi/cidWbvOSziGDKyKkE3Rycry1jJHel1o=; b=QxJ/FH7ngGyRR9QoKRhSBixq/eNLWW0zXhTJfR3wndNE1a1yrTbearJdTKIXMlEs/U dStncK06ung9twfIK+TYgA8ZfBBNUlrD/mPkhRYf2of94ei7cmdhpfPaWXOudFFYLbBy YyjNJ/eBEFzEMnuiRNinZC09+ku42zxotXGIyMs4WNsYEYI7HZnBybYedWkciJ6YcGEp 6NMwX3mJt92BvMYPTvcT+dWMLrVJ2trX7cHYetQalxxs6CJN452QCZ0k4cpb5cQydhc7 lAUAVgt0piZIDQFbyQAQCoD/hJV89X0AeDHV4+jmwQK/psV5uZait1Uu6FhFodWvvz0c uKAg== 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; bh=xupd2XgD2fi/cidWbvOSziGDKyKkE3Rycry1jJHel1o=; b=Nj5djbwpwAUnfaBdMhGIbMtzt5lVMLE00jqYE2A/eC1H8V+g84rYHdjQLNTH7GHqNh VN1OUJvHL6ivuxUzVIPQ121Gkp/szMIA2Wm1OseNtLV26ukVH3M1qChUDHYwm9hwT6DW fzrT06u3a4A/gM2g4Fh98isGaHiaJB/M5Xk4IEngKFX15yXyAl4SVP+o9Gwses03Vnaf kuv//MqhZU+sK+1ZJCdihVFvNwmq72jAsVD2uQEEd8lMXb+ATyWq3nWBT9n2zQRKmo0H DW8Wn12fDr0/p+cGXGakJoGg8qK20vdscD9TP7tSb6UJFuLTspUMu+IkEu6hCrlXHqGt TSZQ== X-Gm-Message-State: AKwxytdnlnQkNfeHL6QWbWJ2/B41XGXbnjRYPljL3mO733cJ5dlelKzA ULZ0djyKP9GdohTG2nPSdt1BWQ== X-Google-Smtp-Source: ACJfBosyxOhoEzWl5iNt1T6hWyzIJvSn3h42WabA8k1Tf7h7iTYdz5EG/Vbqg03RZhmxhEvcM4elNg== X-Received: by 10.25.235.202 with SMTP id f71mr17442755lfk.9.1516208169748; Wed, 17 Jan 2018 08:56:09 -0800 (PST) Received: from gilgamesh.semihalf.com (31-172-191-173.noc.fibertech.net.pl. [31.172.191.173]) by smtp.gmail.com with ESMTPSA id t81sm868347lff.47.2018.01.17.08.56.07 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 17 Jan 2018 08:56:08 -0800 (PST) From: Marcin Wojtas To: linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, netdev@vger.kernel.org, linux-acpi@vger.kernel.org Cc: graeme.gregory@linaro.org, davem@davemloft.net, linux@armlinux.org.uk, rafael.j.wysocki@intel.com, andrew@lunn.ch, f.fainelli@gmail.com, antoine.tenart@free-electrons.com, thomas.petazzoni@free-electrons.com, gregory.clement@free-electrons.com, stefanc@marvell.com, nadavh@marvell.com, neta@marvell.com, ard.biesheuvel@linaro.org, mw@semihalf.com, jaz@semihalf.com, tn@semihalf.com Subject: [net-next: PATCH v3 7/7] net: mvpp2: enable ACPI support in the driver Date: Wed, 17 Jan 2018 17:55:46 +0100 Message-Id: <1516208146-4144-8-git-send-email-mw@semihalf.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1516208146-4144-1-git-send-email-mw@semihalf.com> References: <1516208146-4144-1-git-send-email-mw@semihalf.com> Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org This patch introduces an alternative way of obtaining resources - via ACPI tables provided by firmware. Enabling coexistence with the DT support, in addition to the OF_*->device_*/fwnode_* API replacement, required following steps to be taken: * Add mvpp2_acpi_match table * Omit clock configuration and obtain tclk from the property - in ACPI world, the firmware is responsible for clock maintenance. * Disable comphy and syscon handling as they are not available for ACPI. * Modify way of obtaining interrupts - use newly introduced fwnode_irq_get() routine * Until proper MDIO bus and PHY handling with ACPI is established in the kernel, use only link interrupts feature in the driver. For the RGMII port it results in depending on GMAC settings done during firmware stage. * When booting with ACPI MVPP2_QDIST_MULTI_MODE is picked by default, as there is no need to keep any kind of the backward compatibility. Moreover, a memory region used by mvmdio driver is usually placed in the middle of the address space of the PP2 network controller. The MDIO base address is obtained without requesting memory region (by devm_ioremap() call) in mvmdio.c, later overlapping resources are requested by the network driver, which is responsible for avoiding a concurrent access. In case the MDIO memory region is declared in the ACPI, it can already appear as 'in-use' in the OS. Because it is overlapped by second region of the network controller, make sure it is released, before requesting it again. The care is taken by mvpp2 driver to avoid concurrent access to this memory region. Signed-off-by: Marcin Wojtas --- drivers/net/ethernet/marvell/mvpp2.c | 133 ++++++++++++++------ 1 file changed, 94 insertions(+), 39 deletions(-) diff --git a/drivers/net/ethernet/marvell/mvpp2.c b/drivers/net/ethernet/marvell/mvpp2.c index f16448e..a1d7b88 100644 --- a/drivers/net/ethernet/marvell/mvpp2.c +++ b/drivers/net/ethernet/marvell/mvpp2.c @@ -10,6 +10,7 @@ * warranty of any kind, whether express or implied. */ +#include #include #include #include @@ -7502,7 +7503,10 @@ static int mvpp2_multi_queue_vectors_init(struct mvpp2_port *port, strncpy(irqname, "rx-shared", sizeof(irqname)); } - v->irq = of_irq_get_byname(port_node, irqname); + if (port_node) + v->irq = of_irq_get_byname(port_node, irqname); + else + v->irq = fwnode_irq_get(port->fwnode, i); if (v->irq <= 0) { ret = -EINVAL; goto err; @@ -7746,7 +7750,7 @@ static int mvpp2_port_probe(struct platform_device *pdev, struct mvpp2 *priv) { struct device_node *phy_node; - struct phy *comphy; + struct phy *comphy = NULL; struct mvpp2_port *port; struct mvpp2_port_pcpu *port_pcpu; struct device_node *port_node = to_of_node(port_fwnode); @@ -7760,7 +7764,12 @@ static int mvpp2_port_probe(struct platform_device *pdev, int phy_mode; int err, i, cpu; - has_tx_irqs = mvpp2_port_has_tx_irqs(priv, port_node); + if (port_node) { + has_tx_irqs = mvpp2_port_has_tx_irqs(priv, port_node); + } else { + has_tx_irqs = true; + queue_mode = MVPP2_QDIST_MULTI_MODE; + } if (!has_tx_irqs) queue_mode = MVPP2_QDIST_SINGLE_MODE; @@ -7775,7 +7784,11 @@ static int mvpp2_port_probe(struct platform_device *pdev, if (!dev) return -ENOMEM; - phy_node = of_parse_phandle(port_node, "phy", 0); + if (port_node) + phy_node = of_parse_phandle(port_node, "phy", 0); + else + phy_node = NULL; + phy_mode = fwnode_get_phy_mode(port_fwnode); if (phy_mode < 0) { dev_err(&pdev->dev, "incorrect phy mode\n"); @@ -7783,13 +7796,15 @@ static int mvpp2_port_probe(struct platform_device *pdev, goto err_free_netdev; } - comphy = devm_of_phy_get(&pdev->dev, port_node, NULL); - if (IS_ERR(comphy)) { - if (PTR_ERR(comphy) == -EPROBE_DEFER) { - err = -EPROBE_DEFER; - goto err_free_netdev; + if (port_node) { + comphy = devm_of_phy_get(&pdev->dev, port_node, NULL); + if (IS_ERR(comphy)) { + if (PTR_ERR(comphy) == -EPROBE_DEFER) { + err = -EPROBE_DEFER; + goto err_free_netdev; + } + comphy = NULL; } - comphy = NULL; } if (fwnode_property_read_u32(port_fwnode, "port-id", &id)) { @@ -7805,6 +7820,7 @@ static int mvpp2_port_probe(struct platform_device *pdev, port = netdev_priv(dev); port->dev = dev; + port->fwnode = port_fwnode; port->ntxqs = ntxqs; port->nrxqs = nrxqs; port->priv = priv; @@ -7814,7 +7830,10 @@ static int mvpp2_port_probe(struct platform_device *pdev, if (err) goto err_free_netdev; - port->link_irq = of_irq_get_byname(port_node, "link"); + if (port_node) + port->link_irq = of_irq_get_byname(port_node, "link"); + else + port->link_irq = fwnode_irq_get(port_fwnode, port->nqvecs + 1); if (port->link_irq == -EPROBE_DEFER) { err = -EPROBE_DEFER; goto err_deinit_qvecs; @@ -8197,6 +8216,7 @@ static int mvpp2_init(struct platform_device *pdev, struct mvpp2 *priv) static int mvpp2_probe(struct platform_device *pdev) { + const struct acpi_device_id *acpi_id; struct fwnode_handle *fwnode = pdev->dev.fwnode; struct fwnode_handle *port_fwnode; struct mvpp2 *priv; @@ -8209,8 +8229,14 @@ static int mvpp2_probe(struct platform_device *pdev) if (!priv) return -ENOMEM; - priv->hw_version = - (unsigned long)of_device_get_match_data(&pdev->dev); + if (has_acpi_companion(&pdev->dev)) { + acpi_id = acpi_match_device(pdev->dev.driver->acpi_match_table, + &pdev->dev); + priv->hw_version = (unsigned long)acpi_id->driver_data; + } else { + priv->hw_version = + (unsigned long)of_device_get_match_data(&pdev->dev); + } res = platform_get_resource(pdev, IORESOURCE_MEM, 0); base = devm_ioremap_resource(&pdev->dev, res); @@ -8224,10 +8250,23 @@ static int mvpp2_probe(struct platform_device *pdev) return PTR_ERR(priv->lms_base); } else { res = platform_get_resource(pdev, IORESOURCE_MEM, 1); + if (has_acpi_companion(&pdev->dev)) { + /* In case the MDIO memory region is declared in + * the ACPI, it can already appear as 'in-use' + * in the OS. Because it is overlapped by second + * region of the network controller, make + * sure it is released, before requesting it again. + * The care is taken by mvpp2 driver to avoid + * concurrent access to this memory region. + */ + release_resource(res); + } priv->iface_base = devm_ioremap_resource(&pdev->dev, res); if (IS_ERR(priv->iface_base)) return PTR_ERR(priv->iface_base); + } + if (priv->hw_version == MVPP22 && dev_of_node(&pdev->dev)) { priv->sysctrl_base = syscon_regmap_lookup_by_phandle(pdev->dev.of_node, "marvell,system-controller"); @@ -8253,32 +8292,34 @@ static int mvpp2_probe(struct platform_device *pdev) else priv->max_port_rxqs = 32; - priv->pp_clk = devm_clk_get(&pdev->dev, "pp_clk"); - if (IS_ERR(priv->pp_clk)) - return PTR_ERR(priv->pp_clk); - err = clk_prepare_enable(priv->pp_clk); - if (err < 0) - return err; - - priv->gop_clk = devm_clk_get(&pdev->dev, "gop_clk"); - if (IS_ERR(priv->gop_clk)) { - err = PTR_ERR(priv->gop_clk); - goto err_pp_clk; - } - err = clk_prepare_enable(priv->gop_clk); - if (err < 0) - goto err_pp_clk; + if (dev_of_node(&pdev->dev)) { + priv->pp_clk = devm_clk_get(&pdev->dev, "pp_clk"); + if (IS_ERR(priv->pp_clk)) + return PTR_ERR(priv->pp_clk); + err = clk_prepare_enable(priv->pp_clk); + if (err < 0) + return err; - if (priv->hw_version == MVPP22) { - priv->mg_clk = devm_clk_get(&pdev->dev, "mg_clk"); - if (IS_ERR(priv->mg_clk)) { - err = PTR_ERR(priv->mg_clk); - goto err_gop_clk; + priv->gop_clk = devm_clk_get(&pdev->dev, "gop_clk"); + if (IS_ERR(priv->gop_clk)) { + err = PTR_ERR(priv->gop_clk); + goto err_pp_clk; } - - err = clk_prepare_enable(priv->mg_clk); + err = clk_prepare_enable(priv->gop_clk); if (err < 0) - goto err_gop_clk; + goto err_pp_clk; + + if (priv->hw_version == MVPP22) { + priv->mg_clk = devm_clk_get(&pdev->dev, "mg_clk"); + if (IS_ERR(priv->mg_clk)) { + err = PTR_ERR(priv->mg_clk); + goto err_gop_clk; + } + + err = clk_prepare_enable(priv->mg_clk); + if (err < 0) + goto err_gop_clk; + } priv->axi_clk = devm_clk_get(&pdev->dev, "axi_clk"); if (IS_ERR(priv->axi_clk)) { @@ -8291,10 +8332,14 @@ static int mvpp2_probe(struct platform_device *pdev) if (err < 0) goto err_gop_clk; } - } - /* Get system's tclk rate */ - priv->tclk = clk_get_rate(priv->pp_clk); + /* Get system's tclk rate */ + priv->tclk = clk_get_rate(priv->pp_clk); + } else if (device_property_read_u32(&pdev->dev, "clock-frequency", + &priv->tclk)) { + dev_err(&pdev->dev, "missing clock-frequency value\n"); + return -EINVAL; + } if (priv->hw_version == MVPP22) { err = dma_set_mask(&pdev->dev, DMA_BIT_MASK(40)); @@ -8399,6 +8444,9 @@ static int mvpp2_remove(struct platform_device *pdev) aggr_txq->descs_dma); } + if (is_acpi_node(port_fwnode)) + return 0; + clk_disable_unprepare(priv->axi_clk); clk_disable_unprepare(priv->mg_clk); clk_disable_unprepare(priv->pp_clk); @@ -8420,12 +8468,19 @@ static const struct of_device_id mvpp2_match[] = { }; MODULE_DEVICE_TABLE(of, mvpp2_match); +static const struct acpi_device_id mvpp2_acpi_match[] = { + { "MRVL0110", MVPP22 }, + { }, +}; +MODULE_DEVICE_TABLE(acpi, mvpp2_acpi_match); + static struct platform_driver mvpp2_driver = { .probe = mvpp2_probe, .remove = mvpp2_remove, .driver = { .name = MVPP2_DRIVER_NAME, .of_match_table = mvpp2_match, + .acpi_match_table = ACPI_PTR(mvpp2_acpi_match), }, };