net: dsa: vsc73xx: Assert reset if iCPU is enabled

Driver allow to use devices with disabled iCPU only.

Some devices have pre-initialised iCPU by bootloader.
That state make switch unmanaged. This patch force reset
if device is in unmanaged state. In the result chip lost
internal firmware from RAM and it can be managed.

Signed-off-by: Pawel Dembicki <paweldembicki@gmail.com>
Reviewed-by: Linus Walleij <linus.walleij@linaro.org>
Reviewed-by: Florian Fainelli <f.fainelli@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:
Pawel Dembicki 2019-07-05 00:29:07 +02:00 committed by David S. Miller
parent 631e83bf7c
commit 1da39ff09e

View File

@ -417,22 +417,8 @@ static int vsc73xx_detect(struct vsc73xx *vsc)
} }
if (val == 0xffffffff) { if (val == 0xffffffff) {
dev_info(vsc->dev, "chip seems dead, assert reset\n"); dev_info(vsc->dev, "chip seems dead.\n");
gpiod_set_value_cansleep(vsc->reset, 1); return -EAGAIN;
/* Reset pulse should be 20ns minimum, according to datasheet
* table 245, so 10us should be fine
*/
usleep_range(10, 100);
gpiod_set_value_cansleep(vsc->reset, 0);
/* Wait 20ms according to datasheet table 245 */
msleep(20);
ret = vsc73xx_read(vsc, VSC73XX_BLOCK_SYSTEM, 0,
VSC73XX_ICPU_MBOX_VAL, &val);
if (val == 0xffffffff) {
dev_err(vsc->dev, "seems not to help, giving up\n");
return -ENODEV;
}
} }
ret = vsc73xx_read(vsc, VSC73XX_BLOCK_SYSTEM, 0, ret = vsc73xx_read(vsc, VSC73XX_BLOCK_SYSTEM, 0,
@ -483,9 +469,8 @@ static int vsc73xx_detect(struct vsc73xx *vsc)
} }
if (icpu_si_boot_en && !icpu_pi_en) { if (icpu_si_boot_en && !icpu_pi_en) {
dev_err(vsc->dev, dev_err(vsc->dev,
"iCPU enabled boots from SI, no external memory\n"); "iCPU enabled boots from PI/SI, no external memory\n");
dev_err(vsc->dev, "no idea how to deal with this\n"); return -EAGAIN;
return -ENODEV;
} }
if (!icpu_si_boot_en && icpu_pi_en) { if (!icpu_si_boot_en && icpu_pi_en) {
dev_err(vsc->dev, dev_err(vsc->dev,
@ -1158,6 +1143,19 @@ int vsc73xx_probe(struct vsc73xx *vsc)
msleep(20); msleep(20);
ret = vsc73xx_detect(vsc); ret = vsc73xx_detect(vsc);
if (ret == -EAGAIN) {
dev_err(vsc->dev,
"Chip seems to be out of control. Assert reset and try again.\n");
gpiod_set_value_cansleep(vsc->reset, 1);
/* Reset pulse should be 20ns minimum, according to datasheet
* table 245, so 10us should be fine
*/
usleep_range(10, 100);
gpiod_set_value_cansleep(vsc->reset, 0);
/* Wait 20ms according to datasheet table 245 */
msleep(20);
ret = vsc73xx_detect(vsc);
}
if (ret) { if (ret) {
dev_err(dev, "no chip found (%d)\n", ret); dev_err(dev, "no chip found (%d)\n", ret);
return -ENODEV; return -ENODEV;