Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp5394499ybl; Tue, 10 Dec 2019 05:26:08 -0800 (PST) X-Google-Smtp-Source: APXvYqzvjXqcwzj7FafI5cSyRkdLU0Fbb1FkR9/8HockWxJlwgFX2HtWjsZdfAjEDkpNGfdyGTVV X-Received: by 2002:aca:72d0:: with SMTP id p199mr4149131oic.40.1575984368077; Tue, 10 Dec 2019 05:26:08 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1575984368; cv=none; d=google.com; s=arc-20160816; b=g0YSi8HYZte/O1BsHGb+kFLqJquHlnetOJqfcDXm2iO3owJxL71wHwi2jLtidj0IaH 0kzXOKZgsrFIalMbC2ldKW1c5zGeu43DmegZ6F23mZ0GUs+Ov+Af4hAE2IcFae73Dk0b 8hUE/GbxiCb6g/+2IQzW0bURcXvnprYWmEPL8WUkguBSCyk0sK5sHEZMxHuiBi3Os4wt RRxVigX07dQkEts9COK/Qs/Ns/6lsChHQyYfmWOx/4eREPTW8I8o9uugZbikZtmazLwB NxwVeIZrfRhfjIp+3U9lmDgfKvvd0r6+PsJ4XNtReCQbkk6me3xsyGARjrl56oy9/k33 UxZg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature; bh=pO7CX2h6bc5jrjRKBOU4iSh8aQsjCPRKe6WfJsN0L1c=; b=b9Qxg+jl3TM0dGohwRg9WWR0sS/8/uSF1yPwLC38xHv10Sy2jku3H71wq3ONbTt4XB TD9zgaQRuAIup1UlPE51btn1sqiLbdbsTZHPWnGH+SfVR1E9yCqLn/XYbZ3g/bP+H/6T qcYZtnKqPhqEnUdkEDW2w6AmmY2UASXL/GCJ40nLyAfK7oJr4CK0hPw79jEN+EwsOall 71+tpNez6eU7jPEFYrgiQAJ1rp5TZj2Hu8hLWJpX+K8mK8XfTshizqO314/J9cswg9jk ZCDyXTsXFzCPwwtoTfNMGDFvJIqUMdfEqabIwEmISRvrQIrApgXvXuttXk+AHvmyhusf bgaw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=blBCPXyd; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 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. [209.132.180.67]) by mx.google.com with ESMTP id v4si380960oth.3.2019.12.10.05.25.55; Tue, 10 Dec 2019 05:26:08 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=blBCPXyd; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 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 S1727648AbfLJNX4 (ORCPT + 99 others); Tue, 10 Dec 2019 08:23:56 -0500 Received: from mail-wm1-f65.google.com ([209.85.128.65]:54789 "EHLO mail-wm1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727606AbfLJNXw (ORCPT ); Tue, 10 Dec 2019 08:23:52 -0500 Received: by mail-wm1-f65.google.com with SMTP id b11so3195613wmj.4; Tue, 10 Dec 2019 05:23:51 -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:in-reply-to:references; bh=pO7CX2h6bc5jrjRKBOU4iSh8aQsjCPRKe6WfJsN0L1c=; b=blBCPXydNqyvOS2Lo/SKeJ69Mb7Fv0T50o3WoUPo5RPcMaqtYuhIcDt1DZqT+xEay/ P8l6dYghN5utyZFHERNeFCPbSe+BRIeUdQMeyNWfTEcUDWTPtrkcj9lIpZ1wXIBMT6Jt NAi57KrErqzGQk/95S9aUdDIqKnWSeJouiR5m2wV7vsBCd4vFik5CbCNGeZ0bhJ+yLyV Je8EdKWh0c5VS9rRypZTPeFnWd0gb6y6cgVfkdvAy3A/eZPvR2B3zcZC3pK26C+cTDFA NL8KJ48pTdzyNiXc//xCz0VkiBeTxxPcOZ8EHNqdtiac8NsPPbBHTA0DfUP08uM/eh9Q 4c+g== 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=pO7CX2h6bc5jrjRKBOU4iSh8aQsjCPRKe6WfJsN0L1c=; b=ZYnYLuLIktlIhYm7l+YXNIg4xGb3f6ywx0OlXJJYhrcepqrmcvL7tA6IxTqUHQnlUD oaMr1iEH+roKDTs2By6RpvIkvIjznApAIWhNygCGL7Zfld6TzInc1GK0aLyQkc5mFD5R bB9T3ERnm9dFZmUEr4A9pZxPmQn+ExoiJeCqtcam81NOhz8GvigE9hk0FcgpiK3icD9G gmSTT5ZQNyCUUKVrMHgcTjMuuLBB8SmV1o1nCC+nL9QuhYXCLM9YMyRTAd8h8Po/AzCW N/Qbcbi0b6T+2wvmVm65t377OL27+oRSNxIRKLgahhZlg6lc/6FV4QF/JO+3wc28MVso XPZA== X-Gm-Message-State: APjAAAVYeFOdLBcZKi2e8Sv0FXwg+Ix6WIxVtR9J9qtlvqcNWoepjxtE qBY1lZCQwN9Y9Lert5WGC5Od0y7IjVk= X-Received: by 2002:a05:600c:d5:: with SMTP id u21mr5042692wmm.85.1575984230543; Tue, 10 Dec 2019 05:23:50 -0800 (PST) Received: from stbsrv-and-01.and.broadcom.net ([192.19.231.250]) by smtp.gmail.com with ESMTPSA id s82sm3101680wms.28.2019.12.10.05.23.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 10 Dec 2019 05:23:50 -0800 (PST) From: Al Cooper To: linux-kernel@vger.kernel.org Cc: Al Cooper , bcm-kernel-feedback-list@broadcom.com, devicetree@vger.kernel.org, Florian Fainelli , Kishon Vijay Abraham I , linux-arm-kernel@lists.infradead.org, Mark Rutland , Rob Herring , Srinath Mannam Subject: [PATCH v3 11/13] phy: usb: bdc: Fix occasional failure with BDC on 7211 Date: Tue, 10 Dec 2019 08:21:30 -0500 Message-Id: <20191210132132.41509-12-alcooperx@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20191210132132.41509-1-alcooperx@gmail.com> References: <20191210132132.41509-1-alcooperx@gmail.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The BDC "Read Transaction Size" needs to be changed from 1024 bytes to 256 bytes to prevent occasional transaction failures. Signed-off-by: Al Cooper --- .../phy/broadcom/phy-brcm-usb-init-synopsis.c | 18 +++++++++++++++ drivers/phy/broadcom/phy-brcm-usb-init.h | 1 + drivers/phy/broadcom/phy-brcm-usb.c | 23 +++++++++++++++---- 3 files changed, 38 insertions(+), 4 deletions(-) diff --git a/drivers/phy/broadcom/phy-brcm-usb-init-synopsis.c b/drivers/phy/broadcom/phy-brcm-usb-init-synopsis.c index fe3f653c64a7..c6504649d307 100644 --- a/drivers/phy/broadcom/phy-brcm-usb-init-synopsis.c +++ b/drivers/phy/broadcom/phy-brcm-usb-init-synopsis.c @@ -70,6 +70,11 @@ #define USB_GMDIOCSR 0 #define USB_GMDIOGEN 4 +/* Register definitions for the BDC EC block in 7211b0 */ +#define BDC_EC_AXIRDA 0x0c +#define BDC_EC_AXIRDA_RTS_MASK 0xf0000000 +#define BDC_EC_AXIRDA_RTS_SHIFT 28 + static void usb_mdio_write_7211b0(struct brcm_usb_init_params *params, uint8_t addr, uint16_t data) @@ -198,6 +203,7 @@ static void usb_init_common_7211b0(struct brcm_usb_init_params *params) { void __iomem *ctrl = params->regs[BRCM_REGS_CTRL]; void __iomem *usb_phy = params->regs[BRCM_REGS_USB_PHY]; + void __iomem *bdc_ec = params->regs[BRCM_REGS_BDC_EC]; int timeout_ms = PHY_LOCK_TIMEOUT_MS; u32 reg; @@ -230,6 +236,18 @@ static void usb_init_common_7211b0(struct brcm_usb_init_params *params) usb_init_common(params); + /* + * The BDC controller will get occasional failures with + * the default "Read Transaction Size" of 6 (1024 bytes). + * Set it to 4 (256 bytes). + */ + if ((params->mode != USB_CTLR_MODE_HOST) && bdc_ec) { + reg = brcm_usb_readl(bdc_ec + BDC_EC_AXIRDA); + reg &= ~BDC_EC_AXIRDA_RTS_MASK; + reg |= (0x4 << BDC_EC_AXIRDA_RTS_SHIFT); + brcm_usb_writel(reg, bdc_ec + BDC_EC_AXIRDA); + } + /* * Disable FSM, otherwise the PHY will auto suspend when no * device is connected and will be reset on resume. diff --git a/drivers/phy/broadcom/phy-brcm-usb-init.h b/drivers/phy/broadcom/phy-brcm-usb-init.h index 2ea81daf295e..4cdd9cc1c5a3 100644 --- a/drivers/phy/broadcom/phy-brcm-usb-init.h +++ b/drivers/phy/broadcom/phy-brcm-usb-init.h @@ -19,6 +19,7 @@ enum brcmusb_reg_sel { BRCM_REGS_XHCI_GBL, BRCM_REGS_USB_PHY, BRCM_REGS_USB_MDIO, + BRCM_REGS_BDC_EC, BRCM_REGS_MAX }; diff --git a/drivers/phy/broadcom/phy-brcm-usb.c b/drivers/phy/broadcom/phy-brcm-usb.c index c82d7ec15334..cc5763ace3ad 100644 --- a/drivers/phy/broadcom/phy-brcm-usb.c +++ b/drivers/phy/broadcom/phy-brcm-usb.c @@ -36,6 +36,7 @@ struct value_to_name_map { struct match_chip_info { void *init_func; u8 required_regs[BRCM_REGS_MAX + 1]; + u8 optional_reg; }; static struct value_to_name_map brcm_dr_mode_to_name[] = { @@ -71,7 +72,7 @@ struct brcm_usb_phy_data { }; static s8 *node_reg_names[BRCM_REGS_MAX] = { - "crtl", "xhci_ec", "xhci_gbl", "usb_phy", "usb_mdio" + "crtl", "xhci_ec", "xhci_gbl", "usb_phy", "usb_mdio", "bdc_ec" }; static irqreturn_t brcm_usb_phy_wake_isr(int irq, void *dev_id) @@ -271,6 +272,7 @@ static struct match_chip_info chip_info_7211b0 = { BRCM_REGS_USB_MDIO, -1, }, + .optional_reg = BRCM_REGS_BDC_EC, }; static struct match_chip_info chip_info_7445 = { @@ -300,7 +302,8 @@ static const struct of_device_id brcm_usb_dt_ids[] = { static int brcm_usb_get_regs(struct platform_device *pdev, enum brcmusb_reg_sel regs, - struct brcm_usb_init_params *ini) + struct brcm_usb_init_params *ini, + bool optional) { struct resource *res; @@ -317,7 +320,13 @@ static int brcm_usb_get_regs(struct platform_device *pdev, return 0; } if (res == NULL) { - dev_err(&pdev->dev, "can't get %s base address\n", + if (optional) { + dev_dbg(&pdev->dev, + "Optional reg %s not found\n", + node_reg_names[regs]); + return 0; + } + dev_err(&pdev->dev, "can't get %s base addr\n", node_reg_names[regs]); return 1; } @@ -460,7 +469,13 @@ static int brcm_usb_phy_probe(struct platform_device *pdev) break; err = brcm_usb_get_regs(pdev, info->required_regs[x], - &priv->ini); + &priv->ini, false); + if (err) + return -EINVAL; + } + if (info->optional_reg) { + err = brcm_usb_get_regs(pdev, info->optional_reg, + &priv->ini, true); if (err) return -EINVAL; } -- 2.17.1