Received: by 2002:a05:6a10:a0d1:0:0:0:0 with SMTP id j17csp2482243pxa; Mon, 17 Aug 2020 10:39:54 -0700 (PDT) X-Google-Smtp-Source: ABdhPJz55cAuJ7XUaSmrcsiZRtSeL5G0P1hDv1h8VL1/mKg8s8Oj5rIs/amBeXuI9mzZ0hdOiobU X-Received: by 2002:a17:906:da19:: with SMTP id fi25mr15911711ejb.405.1597685994279; Mon, 17 Aug 2020 10:39:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1597685994; cv=none; d=google.com; s=arc-20160816; b=XUtkSA8k5F6b0F6IqUTHDvAboUXwjGDtL89ucEhWKn3pLZuWadXGQq/TUU91v5eCUg mn1PdkKJh5kET7GShw3IWlciN9u86xm7/YaiG/5XwtvZskW1za1IaemvVljWWbBgYSd7 XrCWyRLfnyWmMs9jCsHLBh8W9kAOfh5cn0CrZFchp7ujAcHIZqZEmCkfZpH3x8v4h/as XTGc95dsDY5aB4+Pgy2qsEfM4A23oCnBk9Cp727+fKhS6ITb9EvKdD77g8oCpvevRrQl Btmc5T8q4g1jhmPAEhWwzqQrrkF/Xksij73Els/XgbvbfZ0Vro4mmNMkew7Nea3pb+Jy Thgg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=9m4MfDUfrltprFjWsb3k3Kia0mWcTEtj+YWN//2YLSE=; b=SyUFDMWFhD6zXgvzJKIUi3y4r5FSEasV2/5C1GDkRlmrLg5k8gLEl3okTIre7n+RLX 8Z/Di6WCbPPBHmVAYpq8vi0gG/8seBwEwbQoUTePICw5X6MSE9is4LnI3WV17URkM7HV DYK3XIl9PY9SRtF28AehqNhsYim3zLntVA5qKHKu3Gy65k1XV2swD2G94v/DxwzfdsvH Sflv+ZqYLEUOWxRMEnpG1OKj/tXVHsKGrl2xGh2sNAepeB1UCCfAYGPJYtIE0SZhsuBZ Z1MHThEPlWyUvsrh/ZPuYSAmGQw+aWmV8y3tt+1x/fOYsDV7jz1xr+45XUaVnoVLujWE Hh2A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=jPob0hGf; 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=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id qc16si11026525ejb.746.2020.08.17.10.39.31; Mon, 17 Aug 2020 10:39:54 -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=@gmail.com header.s=20161025 header.b=jPob0hGf; 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=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729726AbgHQRfH (ORCPT + 99 others); Mon, 17 Aug 2020 13:35:07 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43450 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731273AbgHQQcP (ORCPT ); Mon, 17 Aug 2020 12:32:15 -0400 Received: from mail-qk1-x741.google.com (mail-qk1-x741.google.com [IPv6:2607:f8b0:4864:20::741]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C9EF6C061342 for ; Mon, 17 Aug 2020 09:32:14 -0700 (PDT) Received: by mail-qk1-x741.google.com with SMTP id j187so15482130qke.11 for ; Mon, 17 Aug 2020 09:32:14 -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:mime-version :content-transfer-encoding; bh=9m4MfDUfrltprFjWsb3k3Kia0mWcTEtj+YWN//2YLSE=; b=jPob0hGf8a2L4JsXcMdzEjwJAr4SK4ZI67Zl6bJCrKDXIFEuivs+1/Tf6V3WLsPcHH HtyGxTc/QvBwerXGUKIpw1BkjLG/NCi95nxF5AJI18Qyg+8Or+PEZarPxnsAM8A/FWEf xSnqRXeG2PuLndwdSbOlZfx8onjfDbigwLH237qO78YbIzfuiovoWXJANyulgpDQbPDu j5tY7czB0BeZJxrBmF2VjVjJdB/QpEoYqL7tQB4TMVqfCWBZgtER6OJuu6+Du1ZZbdDy MaLB8z3ozcD0r0BiKnrdzw4cHaRkWlR6ifUF7BZxzuU+CUhqjKO2cya32IlMbR0w0H6h 2tCQ== 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:mime-version :content-transfer-encoding; bh=9m4MfDUfrltprFjWsb3k3Kia0mWcTEtj+YWN//2YLSE=; b=E2bb70oiz71/t05zmkr0Pytew4+bZ471ft6CAPjX+kJ898iDv3d/7ozVaS4JJfnKyv vNDI8grON/pLx785aSZQ3Z+FUB1E58ks9D2f6rtxHGBra9S87poGmlylNdkCevpUQyL+ i8blOfPHD8RdF7L183CQfzaxFTUFpTGn0J7hDDSdQdlRoFClI/5/gu6wxiKChWdnI4td t6QSAy9jRjAgOD32mlXDhE22OpcpmILTuBuZaJ3kIcFfJXt3WywbNnBoXnb/l4SjSfmL +ib+XGzMD+7gdxwQ4IoI42U/63i/6s/t9VDx9r9TWsKGwlzn96nEK2kR/6EdBj82x1Kx vCfQ== X-Gm-Message-State: AOAM532lQ/x2N/hQhA4xafMslUUXO5ZjtMj2aL4IDtccE6S+IXL8N4Q1 mbh+aSpKpZXL2Mfxbrzdh2g= X-Received: by 2002:a37:8287:: with SMTP id e129mr11743166qkd.132.1597681933893; Mon, 17 Aug 2020 09:32:13 -0700 (PDT) Received: from atris.xiphos.ca (198-48-202-89.cpe.pppoe.ca. [198.48.202.89]) by smtp.gmail.com with ESMTPSA id j16sm17335953qke.87.2020.08.17.09.32.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 17 Aug 2020 09:32:13 -0700 (PDT) From: Liam Beguin To: liambeguin@gmail.com, kishon@ti.com, vkoul@kernel.org Cc: linux-kernel@vger.kernel.org Subject: [PATCH v3 1/1] phy: tusb1210: use bitmasks to set VENDOR_SPECIFIC2 Date: Mon, 17 Aug 2020 12:31:52 -0400 Message-Id: <20200817163152.13468-1-liambeguin@gmail.com> X-Mailer: git-send-email 2.27.0 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Liam Beguin Start by reading the content of the VENDOR_SPECIFIC2 register and update each bit field based on device properties when defined. The use of bit masks prevents fields from overriding each other and enables users to clear bits which are set by default, like datapolarity in this instance. Signed-off-by: Liam Beguin --- Changes since v1: - use set_mask_bits Changes since v2: - fix missing bit shift dropped in v2 - rebase on 5.9-rc1 drivers/phy/ti/phy-tusb1210.c | 27 +++++++++++++++++---------- 1 file changed, 17 insertions(+), 10 deletions(-) diff --git a/drivers/phy/ti/phy-tusb1210.c b/drivers/phy/ti/phy-tusb1210.c index d8d0cc11d187..358842b5790f 100644 --- a/drivers/phy/ti/phy-tusb1210.c +++ b/drivers/phy/ti/phy-tusb1210.c @@ -14,8 +14,11 @@ #define TUSB1210_VENDOR_SPECIFIC2 0x80 #define TUSB1210_VENDOR_SPECIFIC2_IHSTX_SHIFT 0 +#define TUSB1210_VENDOR_SPECIFIC2_IHSTX_MASK GENMASK(3, 0) #define TUSB1210_VENDOR_SPECIFIC2_ZHSDRV_SHIFT 4 +#define TUSB1210_VENDOR_SPECIFIC2_ZHSDRV_MASK GENMASK(5, 4) #define TUSB1210_VENDOR_SPECIFIC2_DP_SHIFT 6 +#define TUSB1210_VENDOR_SPECIFIC2_DP_MASK BIT(6) struct tusb1210 { struct ulpi *ulpi; @@ -118,23 +121,27 @@ static int tusb1210_probe(struct ulpi *ulpi) * diagram optimization and DP/DM swap. */ + reg = ulpi_read(ulpi, TUSB1210_VENDOR_SPECIFIC2); + /* High speed output drive strength configuration */ - device_property_read_u8(&ulpi->dev, "ihstx", &val); - reg = val << TUSB1210_VENDOR_SPECIFIC2_IHSTX_SHIFT; + if (!device_property_read_u8(&ulpi->dev, "ihstx", &val)) + reg = set_mask_bits(®, TUSB1210_VENDOR_SPECIFIC2_IHSTX_MASK, + val << TUSB1210_VENDOR_SPECIFIC2_IHSTX_SHIFT); /* High speed output impedance configuration */ - device_property_read_u8(&ulpi->dev, "zhsdrv", &val); - reg |= val << TUSB1210_VENDOR_SPECIFIC2_ZHSDRV_SHIFT; + if (!device_property_read_u8(&ulpi->dev, "zhsdrv", &val)) + reg = set_mask_bits(®, TUSB1210_VENDOR_SPECIFIC2_ZHSDRV_MASK, + val << TUSB1210_VENDOR_SPECIFIC2_ZHSDRV_SHIFT); /* DP/DM swap control */ - device_property_read_u8(&ulpi->dev, "datapolarity", &val); - reg |= val << TUSB1210_VENDOR_SPECIFIC2_DP_SHIFT; - - if (reg) { - ulpi_write(ulpi, TUSB1210_VENDOR_SPECIFIC2, reg); - tusb->vendor_specific2 = reg; + if (!device_property_read_u8(&ulpi->dev, "datapolarity", &val)) { + reg = set_mask_bits(®, TUSB1210_VENDOR_SPECIFIC2_DP_MASK, + val << TUSB1210_VENDOR_SPECIFIC2_DP_SHIFT); } + ulpi_write(ulpi, TUSB1210_VENDOR_SPECIFIC2, reg); + tusb->vendor_specific2 = reg; + tusb->phy = ulpi_phy_create(ulpi, &phy_ops); if (IS_ERR(tusb->phy)) return PTR_ERR(tusb->phy); base-commit: 9123e3a74ec7b934a4a099e98af6a61c2f80bbf5 -- 2.27.0