Received: by 2002:a05:6a10:17d3:0:0:0:0 with SMTP id hz19csp1935419pxb; Mon, 12 Apr 2021 10:01:59 -0700 (PDT) X-Google-Smtp-Source: ABdhPJykxKcJeo9KqKhZ5kDLxPnnBsJV792NJ4xlcEWzl8Ll+JLSiAud81e8QTE/yMWwGNfAMuFZ X-Received: by 2002:a05:6402:518b:: with SMTP id q11mr30018075edd.151.1618246919644; Mon, 12 Apr 2021 10:01:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1618246919; cv=none; d=google.com; s=arc-20160816; b=Np7FAnGsbXYiWC/tfwaMaQa97vSagXrctUf4IhQ1q+vsyLMLSrL9nl67DnYTH4uDIE CwXvytZ7cTuQb8k+461Ak8GT7CzQLo8A8Um2/sarVBCkDqxJeK53/AUt9XGFHxcQKxCX iVsu9xTSknGY+m9TMExBIHqJQd2japKqTs7QfGKyKnNXBeBybgGJeLpm0Ob/Ud0m9Qvt HSt5+Na0ZT5UJP7mG+yn18TiLrVupAL7yj4RAOlsWqWlg3Ickt2mS2Y7F3By+Vd8Hb92 iizoX3eYrryjakVOQTX7B3R+DWcqGIt2mP8OARJTTch8ikmqKCBnNK61O8iL/r8tuLU2 o6AQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=ZvauHVXn/nKZqn9Sk3uMiR823RIg+eHEvYEoS9QRISs=; b=lUJRqmR+wlWojO6QeAMOV/Fxcv3v7P3fCZlPMhVzGVqX0ria0JKN1JKxDOrguQ277l RmgtAD70oZd5JS11QiMjRbdi/dwnVsGcVtaMUBNd376Qys31tDd9Lj2+HBbqK38CZ6IV 1uyu1NGbN+wlJTn3azDZqt0cdq7Phmd/9ofP0hqwka9jFriXRNg7sk8iTcV+wdzR89HC MXiR0+BZRejBqozpJTFwh4GEOrm8YOLpO7/M6L5a4pNWNvlBgHNR53HRVwEvv34Po7PC /NwOiiUm7Bppcj2m+xIR0RTvYkab8BFO5OEP8cQseLHEwvgpi6Hkbc3+uiY71XTJ8Z6h TdaA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=Czd5G7rm; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id f7si7740854edu.503.2021.04.12.10.01.35; Mon, 12 Apr 2021 10:01:59 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=Czd5G7rm; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S244029AbhDLRAH (ORCPT + 99 others); Mon, 12 Apr 2021 13:00:07 -0400 Received: from mail.kernel.org ([198.145.29.99]:35752 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S243312AbhDLQ6R (ORCPT ); Mon, 12 Apr 2021 12:58:17 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 8D6846044F; Mon, 12 Apr 2021 16:57:58 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1618246678; bh=sdU3cgfUDnFfzqGGQFtft9NLZO685MLYNHXNxC/BcoI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Czd5G7rmjwveftUBGqePMs4vO54hxIXX/ydVgO7WpQEYd81h0KyOWHzTs0S//Ii2o eSJOsWZidSENVs53JuRH1ABYquUkXFp9/khG+Q2isB3He95WWSoyYCva+Sl+BXI+Pj 4l9JLdGZYoiWAcAcY3vQgjDg9mnareNnvRcFG8NjGjCTvX6qHeBCe40vbCTmKK3qqj 3EQej9eXE4vr2YGZ+H9OVzcb9RYHzuu3DKGk/jgAF8kFmWCEhbT9BKkHO9BziVHiG9 z9TSS/7YAiXfMwvdNQ31RDpD9E/jr8MptsBBERxlybuMWpOVxF8R60i+e8oggaeE14 i2kRiB/pORFQg== Received: by pali.im (Postfix) id 6CD67687; Mon, 12 Apr 2021 18:57:56 +0200 (CEST) From: =?UTF-8?q?Pali=20Roh=C3=A1r?= To: Andrew Lunn , Vivien Didelot , Florian Fainelli , Vladimir Oltean , "David S. Miller" , Jakub Kicinski , =?UTF-8?q?Marek=20Beh=C3=BAn?= Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v2] net: phy: marvell: fix detection of PHY on Topaz switches Date: Mon, 12 Apr 2021 18:57:39 +0200 Message-Id: <20210412165739.27277-1-pali@kernel.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20210412121430.20898-1-pali@kernel.org> References: <20210412121430.20898-1-pali@kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Since commit fee2d546414d ("net: phy: marvell: mv88e6390 temperature sensor reading"), Linux reports the temperature of Topaz hwmon as constant -75°C. This is because switches from the Topaz family (88E6141 / 88E6341) have the address of the temperature sensor register different from Peridot. This address is instead compatible with 88E1510 PHYs, as was used for Topaz before the above mentioned commit. Create a new mapping table between switch family and PHY ID for families which don't have a model number. And define PHY IDs for Topaz and Peridot families. Create a new PHY ID and a new PHY driver for Topaz's internal PHY. The only difference from Peridot's PHY driver is the HWMON probing method. Prior this change Topaz's internal PHY is detected by kernel as: PHY [...] driver [Marvell 88E6390] (irq=63) And afterwards as: PHY [...] driver [Marvell 88E6341 Family] (irq=63) Signed-off-by: Pali Rohár BugLink: https://github.com/globalscaletechnologies/linux/issues/1 Fixes: fee2d546414d ("net: phy: marvell: mv88e6390 temperature sensor reading") Reviewed-by: Marek Behún --- Changes since v1: * create direct mapping table between family and prod_id which avoid need to use of forward declaration and simplify implementation * fill mapping table only for Topaz and Peridot families --- drivers/net/dsa/mv88e6xxx/chip.c | 30 +++++++++++++----------------- drivers/net/phy/marvell.c | 32 +++++++++++++++++++++++++++++--- include/linux/marvell_phy.h | 5 +++-- 3 files changed, 45 insertions(+), 22 deletions(-) diff --git a/drivers/net/dsa/mv88e6xxx/chip.c b/drivers/net/dsa/mv88e6xxx/chip.c index 903d619e08ed..e08bf9377140 100644 --- a/drivers/net/dsa/mv88e6xxx/chip.c +++ b/drivers/net/dsa/mv88e6xxx/chip.c @@ -3026,10 +3026,17 @@ static int mv88e6xxx_setup(struct dsa_switch *ds) return err; } +/* prod_id for switch families which do not have a PHY model number */ +static const u16 family_prod_id_table[] = { + [MV88E6XXX_FAMILY_6341] = MV88E6XXX_PORT_SWITCH_ID_PROD_6341, + [MV88E6XXX_FAMILY_6390] = MV88E6XXX_PORT_SWITCH_ID_PROD_6390, +}; + static int mv88e6xxx_mdio_read(struct mii_bus *bus, int phy, int reg) { struct mv88e6xxx_mdio_bus *mdio_bus = bus->priv; struct mv88e6xxx_chip *chip = mdio_bus->chip; + u16 prod_id; u16 val; int err; @@ -3040,23 +3047,12 @@ static int mv88e6xxx_mdio_read(struct mii_bus *bus, int phy, int reg) err = chip->info->ops->phy_read(chip, bus, phy, reg, &val); mv88e6xxx_reg_unlock(chip); - if (reg == MII_PHYSID2) { - /* Some internal PHYs don't have a model number. */ - if (chip->info->family != MV88E6XXX_FAMILY_6165) - /* Then there is the 6165 family. It gets is - * PHYs correct. But it can also have two - * SERDES interfaces in the PHY address - * space. And these don't have a model - * number. But they are not PHYs, so we don't - * want to give them something a PHY driver - * will recognise. - * - * Use the mv88e6390 family model number - * instead, for anything which really could be - * a PHY, - */ - if (!(val & 0x3f0)) - val |= MV88E6XXX_PORT_SWITCH_ID_PROD_6390 >> 4; + /* Some internal PHYs don't have a model number. */ + if (reg == MII_PHYSID2 && !(val & 0x3f0) && + chip->info->family < ARRAY_SIZE(family_prod_id_table)) { + prod_id = family_prod_id_table[chip->info->family]; + if (prod_id) + val |= prod_id >> 4; } return err ? err : val; diff --git a/drivers/net/phy/marvell.c b/drivers/net/phy/marvell.c index e26a5d663f8a..8018ddf7f316 100644 --- a/drivers/net/phy/marvell.c +++ b/drivers/net/phy/marvell.c @@ -3021,9 +3021,34 @@ static struct phy_driver marvell_drivers[] = { .get_stats = marvell_get_stats, }, { - .phy_id = MARVELL_PHY_ID_88E6390, + .phy_id = MARVELL_PHY_ID_88E6341_FAMILY, .phy_id_mask = MARVELL_PHY_ID_MASK, - .name = "Marvell 88E6390", + .name = "Marvell 88E6341 Family", + /* PHY_GBIT_FEATURES */ + .flags = PHY_POLL_CABLE_TEST, + .probe = m88e1510_probe, + .config_init = marvell_config_init, + .config_aneg = m88e6390_config_aneg, + .read_status = marvell_read_status, + .config_intr = marvell_config_intr, + .handle_interrupt = marvell_handle_interrupt, + .resume = genphy_resume, + .suspend = genphy_suspend, + .read_page = marvell_read_page, + .write_page = marvell_write_page, + .get_sset_count = marvell_get_sset_count, + .get_strings = marvell_get_strings, + .get_stats = marvell_get_stats, + .get_tunable = m88e1540_get_tunable, + .set_tunable = m88e1540_set_tunable, + .cable_test_start = marvell_vct7_cable_test_start, + .cable_test_tdr_start = marvell_vct5_cable_test_tdr_start, + .cable_test_get_status = marvell_vct7_cable_test_get_status, + }, + { + .phy_id = MARVELL_PHY_ID_88E6390_FAMILY, + .phy_id_mask = MARVELL_PHY_ID_MASK, + .name = "Marvell 88E6390 Family", /* PHY_GBIT_FEATURES */ .flags = PHY_POLL_CABLE_TEST, .probe = m88e6390_probe, @@ -3107,7 +3132,8 @@ static struct mdio_device_id __maybe_unused marvell_tbl[] = { { MARVELL_PHY_ID_88E1540, MARVELL_PHY_ID_MASK }, { MARVELL_PHY_ID_88E1545, MARVELL_PHY_ID_MASK }, { MARVELL_PHY_ID_88E3016, MARVELL_PHY_ID_MASK }, - { MARVELL_PHY_ID_88E6390, MARVELL_PHY_ID_MASK }, + { MARVELL_PHY_ID_88E6341_FAMILY, MARVELL_PHY_ID_MASK }, + { MARVELL_PHY_ID_88E6390_FAMILY, MARVELL_PHY_ID_MASK }, { MARVELL_PHY_ID_88E1340S, MARVELL_PHY_ID_MASK }, { MARVELL_PHY_ID_88E1548P, MARVELL_PHY_ID_MASK }, { } diff --git a/include/linux/marvell_phy.h b/include/linux/marvell_phy.h index 52b1610eae68..c544b70dfbd2 100644 --- a/include/linux/marvell_phy.h +++ b/include/linux/marvell_phy.h @@ -28,11 +28,12 @@ /* Marvel 88E1111 in Finisar SFP module with modified PHY ID */ #define MARVELL_PHY_ID_88E1111_FINISAR 0x01ff0cc0 -/* The MV88e6390 Ethernet switch contains embedded PHYs. These PHYs do +/* These Ethernet switch families contain embedded PHYs, but they do * not have a model ID. So the switch driver traps reads to the ID2 * register and returns the switch family ID */ -#define MARVELL_PHY_ID_88E6390 0x01410f90 +#define MARVELL_PHY_ID_88E6341_FAMILY 0x01410f41 +#define MARVELL_PHY_ID_88E6390_FAMILY 0x01410f90 #define MARVELL_PHY_FAMILY_ID(id) ((id) >> 4) -- 2.20.1