|
@@ -519,4 +519,69 @@ static int dns323c_phy_fixup(struct phy_device *phy)
|
|
|
}
|
|
|
|
|
|
static int __init dns323_identify_rev(void)
|
|
|
+{
|
|
|
+ u32 dev, rev, i, reg;
|
|
|
+
|
|
|
+ pr_debug("DNS-323: Identifying board ... \n");
|
|
|
+
|
|
|
+ /* Rev A1 has a 5181 */
|
|
|
+ orion5x_pcie_id(&dev, &rev);
|
|
|
+ if (dev == MV88F5181_DEV_ID) {
|
|
|
+ pr_debug("DNS-323: 5181 found, board is A1\n");
|
|
|
+ return DNS323_REV_A1;
|
|
|
+ }
|
|
|
+ pr_debug("DNS-323: 5182 found, board is B1 or C1, checking PHY...\n");
|
|
|
+
|
|
|
+ /* Rev B1 and C1 both have 5182, let's poke at the eth PHY. This is
|
|
|
+ * a bit gross but we want to do that without links into the eth
|
|
|
+ * driver so let's poke at it directly. We default to rev B1 in
|
|
|
+ * case the accesses fail
|
|
|
+ */
|
|
|
+
|
|
|
+#define ETH_SMI_REG (ORION5X_ETH_VIRT_BASE + 0x2000 + 0x004)
|
|
|
+#define SMI_BUSY 0x10000000
|
|
|
+#define SMI_READ_VALID 0x08000000
|
|
|
+#define SMI_OPCODE_READ 0x04000000
|
|
|
+#define SMI_OPCODE_WRITE 0x00000000
|
|
|
+
|
|
|
+ for (i = 0; i < 1000; i++) {
|
|
|
+ reg = readl(ETH_SMI_REG);
|
|
|
+ if (!(reg & SMI_BUSY))
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ if (i >= 1000) {
|
|
|
+ pr_warning("DNS-323: Timeout accessing PHY, assuming rev B1\n");
|
|
|
+ return DNS323_REV_B1;
|
|
|
+ }
|
|
|
+ writel((3 << 21) /* phy ID reg */ |
|
|
|
+ (8 << 16) /* phy addr */ |
|
|
|
+ SMI_OPCODE_READ, ETH_SMI_REG);
|
|
|
+ for (i = 0; i < 1000; i++) {
|
|
|
+ reg = readl(ETH_SMI_REG);
|
|
|
+ if (reg & SMI_READ_VALID)
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ if (i >= 1000) {
|
|
|
+ pr_warning("DNS-323: Timeout reading PHY, assuming rev B1\n");
|
|
|
+ return DNS323_REV_B1;
|
|
|
+ }
|
|
|
+ pr_debug("DNS-323: Ethernet PHY ID 0x%x\n", reg & 0xffff);
|
|
|
+
|
|
|
+ /* Note: the Marvell tools mask the ID with 0x3f0 before comparison
|
|
|
+ * but I don't see that making a difference here, at least with
|
|
|
+ * any known Marvell PHY ID
|
|
|
+ */
|
|
|
+ switch(reg & 0xfff0) {
|
|
|
+ case 0x0cc0: /* MV88E1111 */
|
|
|
+ return DNS323_REV_B1;
|
|
|
+ case 0x0e10: /* MV88E1118 */
|
|
|
+ return DNS323_REV_C1;
|
|
|
+ default:
|
|
|
+ pr_warning("DNS-323: Unknown PHY ID 0x%04x, assuming rev B1\n",
|
|
|
+ reg & 0xffff);
|
|
|
+ }
|
|
|
+ return DNS323_REV_B1;
|
|
|
+}
|
|
|
+
|
|
|
+static void __init dns323_init(void)
|
|
|
{
|