Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp4603219ybl; Mon, 9 Dec 2019 13:45:56 -0800 (PST) X-Google-Smtp-Source: APXvYqwKYU6UuY9oaCCUbLVBtsXAHyo3pMqMyD8OwyF5X7uPFQ81NsDWQYUfw9udY4OHrciwygll X-Received: by 2002:a05:6830:1d6e:: with SMTP id l14mr23003832oti.32.1575927956014; Mon, 09 Dec 2019 13:45:56 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1575927956; cv=none; d=google.com; s=arc-20160816; b=z4fHlM1u7tMRvE8knCDq0qhae6Jwc+9EIiMH4W4vy9yZHEqkYbYw8GavisFqoEhG2e FMSh/LGd4QwxeTqdg3LIaIla1SnJZd2+Vul7Pvp/RUTHdYR24nF6E4prrPagqHY9VgBQ rkeJcVuq9qb+mVHvOM0da2jSFj53XdoWXHPb8f2pDXFS9Oer+YGoNnpYEZdViPTrYkas 9SN0AxeIe3iWaA28dOlvtlLM62SPqvP+p5mPCoMpTPHQsRpVEaJbK5lavF7DZ61AYZAz j+xtFLw1D2E9A3G+xiY7w2zWy/zgCtjr3pLeq41eOm8QFSTPV4EyU3xC8IoFaJ/s2I+u nMKg== 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=MFlnOn0CAyQafh0Ou2lpY54Ga03K/6YVfFICBBVyXck=; b=P5XlRni6n2eokG71aCqV2hG99l65ILIdrhLMiHqF0HxqE5uAirdPLw+1ZMXUCuVR0K a6d+LjhAyuC1QteS46rCO9A9wvMCrQaYsi7cFz6DqPWPSw3foIUFTiG5LXWPHKrQJwql jRFYy2X37RZ+TvQE+SxnbsIax/IyL0s1VqHQiOlmc7HZ0triP8A0oQ1KjaljBHIcATm7 +txgt5BYKjcainogZdhZy5fuPdp0ZE2EKy+XtsahnVe0V+KisRQ5zvOWGbjAFA0yy6t3 HvhJ3UWBl8McqNS5HJlorM9mj/EPUe2cYqrVSW1gU10sNZirj3P2nU+GtGuJHs4nU0jQ QrkQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=SHVWFv9G; 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 y14si600134otk.237.2019.12.09.13.45.44; Mon, 09 Dec 2019 13:45:55 -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=SHVWFv9G; 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 S1727162AbfLIVoe (ORCPT + 99 others); Mon, 9 Dec 2019 16:44:34 -0500 Received: from mail-wr1-f67.google.com ([209.85.221.67]:46692 "EHLO mail-wr1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727048AbfLIVoS (ORCPT ); Mon, 9 Dec 2019 16:44:18 -0500 Received: by mail-wr1-f67.google.com with SMTP id z7so17736163wrl.13; Mon, 09 Dec 2019 13:44:16 -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=MFlnOn0CAyQafh0Ou2lpY54Ga03K/6YVfFICBBVyXck=; b=SHVWFv9GB7WIK89zZ8hpc/0h0SHf1QojbofoNottxLVBs8cwaCi/uw0BKp23J35PDY 7R90wutJrku9GEhuBB5gUHpfyRA57I6HTkqqrSaESuZCZIIqQ1JPiKCkPWG4cObLBgDW SKbkIRYgc77Te+ipRvnbFBtWeBJXv2q3nsb2FAc8iGKCob9SsEEBg4k4L4cWb6deHOVp MeSQ6q/to/YFccbZidm1zjF1o4pS+Mc1xFZ4yssfRw/353obbuA7yNNVoTyhdx5bpPua I72aZPDZ9fQOMidU8hW//qM7oLG1WhEU1VybG1wAbvu68ll7FP/WN2Mxmy0CC1+zCIZi v0Sg== 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=MFlnOn0CAyQafh0Ou2lpY54Ga03K/6YVfFICBBVyXck=; b=V+NuOutV+cIhXFIvU8pqRgYkHUsi4f7gVtNpDZIIC/iTkqaHZBmKO1Vp4uxRoqyS1E PaGZZpv6j2oPabVyd3gPsk5xxZ9OOt4Boqw2RnfBzYsXSJyxNKTZK8liBL4dvrG2Ha5f jnPHOFRUlqwI1LM0wCREsZ3hDoaDqfISnEdBqH8SkA1G+6nEF7G5WsyXezfFBkylUQal b6T9aaYU6cx5O+fRseyJSg+42BjssRinIENpKlLORhXBuL00ZKwT1ojkrdTwwJRV2qno MNGpjrOl9csAHmazKYkIiosWSsOV2ChBVbxeic6lCAQmM/ZqKMF5b93OImAlnj/G8Z3X kr3A== X-Gm-Message-State: APjAAAXSHvFzO8Xa4lyfQSu6XqcIrUsoRqZQ/eW5tMUHgI0OeaKlyzHJ jAiYioEnpHoNNZsFq7x7ytfScZaLnu8= X-Received: by 2002:adf:f586:: with SMTP id f6mr4279702wro.46.1575927855823; Mon, 09 Dec 2019 13:44:15 -0800 (PST) Received: from stbsrv-and-01.and.broadcom.net ([192.19.231.250]) by smtp.gmail.com with ESMTPSA id z6sm757714wmz.12.2019.12.09.13.44.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 09 Dec 2019 13:44:15 -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 v2 resend 11/13] phy: usb: bdc: Fix occasional failure with BDC on 7211 Date: Mon, 9 Dec 2019 16:42:47 -0500 Message-Id: <20191209214249.41137-12-alcooperx@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20191209214249.41137-1-alcooperx@gmail.com> References: <20191209214249.41137-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 66363b04d778..570bd9d8c9ec 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