Commit bed63b63 authored by Al Cooper's avatar Al Cooper Committed by Kishon Vijay Abraham I

phy: usb: bdc: Fix occasional failure with BDC on 7211

The BDC "Read Transaction Size" needs to be changed from 1024
bytes to 256 bytes to prevent occasional transaction failures.
Signed-off-by: default avatarAl Cooper <alcooperx@gmail.com>
Reviewed-by: default avatarFlorian Fainelli <f.fainelli@gmail.com>
Signed-off-by: default avatarKishon Vijay Abraham I <kishon@ti.com>
parent fc430aea
...@@ -70,6 +70,11 @@ ...@@ -70,6 +70,11 @@
#define USB_GMDIOCSR 0 #define USB_GMDIOCSR 0
#define USB_GMDIOGEN 4 #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, static void usb_mdio_write_7211b0(struct brcm_usb_init_params *params,
uint8_t addr, uint16_t data) uint8_t addr, uint16_t data)
...@@ -198,6 +203,7 @@ static void usb_init_common_7211b0(struct brcm_usb_init_params *params) ...@@ -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 *ctrl = params->regs[BRCM_REGS_CTRL];
void __iomem *usb_phy = params->regs[BRCM_REGS_USB_PHY]; 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; int timeout_ms = PHY_LOCK_TIMEOUT_MS;
u32 reg; u32 reg;
...@@ -230,6 +236,18 @@ static void usb_init_common_7211b0(struct brcm_usb_init_params *params) ...@@ -230,6 +236,18 @@ static void usb_init_common_7211b0(struct brcm_usb_init_params *params)
usb_init_common(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 * Disable FSM, otherwise the PHY will auto suspend when no
* device is connected and will be reset on resume. * device is connected and will be reset on resume.
......
...@@ -19,6 +19,7 @@ enum brcmusb_reg_sel { ...@@ -19,6 +19,7 @@ enum brcmusb_reg_sel {
BRCM_REGS_XHCI_GBL, BRCM_REGS_XHCI_GBL,
BRCM_REGS_USB_PHY, BRCM_REGS_USB_PHY,
BRCM_REGS_USB_MDIO, BRCM_REGS_USB_MDIO,
BRCM_REGS_BDC_EC,
BRCM_REGS_MAX BRCM_REGS_MAX
}; };
......
...@@ -36,6 +36,7 @@ struct value_to_name_map { ...@@ -36,6 +36,7 @@ struct value_to_name_map {
struct match_chip_info { struct match_chip_info {
void *init_func; void *init_func;
u8 required_regs[BRCM_REGS_MAX + 1]; u8 required_regs[BRCM_REGS_MAX + 1];
u8 optional_reg;
}; };
static struct value_to_name_map brcm_dr_mode_to_name[] = { static struct value_to_name_map brcm_dr_mode_to_name[] = {
...@@ -71,7 +72,7 @@ struct brcm_usb_phy_data { ...@@ -71,7 +72,7 @@ struct brcm_usb_phy_data {
}; };
static s8 *node_reg_names[BRCM_REGS_MAX] = { 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) 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 = { ...@@ -271,6 +272,7 @@ static struct match_chip_info chip_info_7211b0 = {
BRCM_REGS_USB_MDIO, BRCM_REGS_USB_MDIO,
-1, -1,
}, },
.optional_reg = BRCM_REGS_BDC_EC,
}; };
static struct match_chip_info chip_info_7445 = { static struct match_chip_info chip_info_7445 = {
...@@ -300,7 +302,8 @@ static const struct of_device_id brcm_usb_dt_ids[] = { ...@@ -300,7 +302,8 @@ static const struct of_device_id brcm_usb_dt_ids[] = {
static int brcm_usb_get_regs(struct platform_device *pdev, static int brcm_usb_get_regs(struct platform_device *pdev,
enum brcmusb_reg_sel regs, enum brcmusb_reg_sel regs,
struct brcm_usb_init_params *ini) struct brcm_usb_init_params *ini,
bool optional)
{ {
struct resource *res; struct resource *res;
...@@ -317,7 +320,13 @@ static int brcm_usb_get_regs(struct platform_device *pdev, ...@@ -317,7 +320,13 @@ static int brcm_usb_get_regs(struct platform_device *pdev,
return 0; return 0;
} }
if (res == NULL) { 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]); node_reg_names[regs]);
return 1; return 1;
} }
...@@ -460,7 +469,13 @@ static int brcm_usb_phy_probe(struct platform_device *pdev) ...@@ -460,7 +469,13 @@ static int brcm_usb_phy_probe(struct platform_device *pdev)
break; break;
err = brcm_usb_get_regs(pdev, info->required_regs[x], 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) if (err)
return -EINVAL; return -EINVAL;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment