mv88e6171.c 3.8 KB
Newer Older
1
/* net/dsa/mv88e6171.c - Marvell 88e6171 switch chip support
2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
 * Copyright (c) 2008-2009 Marvell Semiconductor
 * Copyright (c) 2014 Claudio Leite <leitec@staticky.com>
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 */

#include <linux/delay.h>
#include <linux/jiffies.h>
#include <linux/list.h>
#include <linux/module.h>
#include <linux/netdevice.h>
#include <linux/phy.h>
#include <net/dsa.h>
#include "mv88e6xxx.h"

20 21 22 23 24 25 26
static const struct mv88e6xxx_switch_id mv88e6171_table[] = {
	{ PORT_SWITCH_ID_6171, "Marvell 88E6171" },
	{ PORT_SWITCH_ID_6175, "Marvell 88E6175" },
	{ PORT_SWITCH_ID_6350, "Marvell 88E6350" },
	{ PORT_SWITCH_ID_6351, "Marvell 88E6351" },
};

V
Vivien Didelot 已提交
27 28 29
static const char *mv88e6171_drv_probe(struct device *dsa_dev,
				       struct device *host_dev, int sw_addr,
				       void **priv)
30
{
31 32 33
	return mv88e6xxx_drv_probe(dsa_dev, host_dev, sw_addr, priv,
				   mv88e6171_table,
				   ARRAY_SIZE(mv88e6171_table));
34 35 36 37
}

static int mv88e6171_setup_global(struct dsa_switch *ds)
{
38
	u32 upstream_port = dsa_upstream_port(ds);
39
	int ret;
40
	u32 reg;
41 42 43 44

	ret = mv88e6xxx_setup_global(ds);
	if (ret)
		return ret;
45

46 47
	/* Discard packets with excessive collisions, mask all
	 * interrupt sources, enable PPU.
48
	 */
49 50 51 52 53
	ret = mv88e6xxx_reg_write(ds, REG_GLOBAL, GLOBAL_CONTROL,
				  GLOBAL_CONTROL_PPU_ENABLE |
				  GLOBAL_CONTROL_DISCARD_EXCESS);
	if (ret)
		return ret;
54 55 56 57 58

	/* Configure the upstream port, and configure the upstream
	 * port as the port to which ingress and egress monitor frames
	 * are to be sent.
	 */
59 60 61 62
	reg = upstream_port << GLOBAL_MONITOR_CONTROL_INGRESS_SHIFT |
		upstream_port << GLOBAL_MONITOR_CONTROL_EGRESS_SHIFT |
		upstream_port << GLOBAL_MONITOR_CONTROL_ARP_SHIFT |
		upstream_port << GLOBAL_MONITOR_CONTROL_MIRROR_SHIFT;
63 64 65
	ret = mv88e6xxx_reg_write(ds, REG_GLOBAL, GLOBAL_MONITOR_CONTROL, reg);
	if (ret)
		return ret;
66 67 68 69

	/* Disable remote management for now, and set the switch's
	 * DSA device number.
	 */
70 71
	return mv88e6xxx_reg_write(ds, REG_GLOBAL, GLOBAL_CONTROL_2,
				   ds->index & 0x1f);
72 73 74 75
}

static int mv88e6171_setup(struct dsa_switch *ds)
{
76
	struct mv88e6xxx_priv_state *ps = ds_to_priv(ds);
77 78
	int ret;

79 80 81
	ret = mv88e6xxx_setup_common(ds);
	if (ret < 0)
		return ret;
82

83 84
	ps->num_ports = 7;

85
	ret = mv88e6xxx_switch_reset(ds, true);
86 87 88 89 90 91 92
	if (ret < 0)
		return ret;

	ret = mv88e6171_setup_global(ds);
	if (ret < 0)
		return ret;

93
	return mv88e6xxx_setup_ports(ds);
94 95 96
}

struct dsa_switch_driver mv88e6171_switch_driver = {
97
	.tag_protocol		= DSA_TAG_PROTO_EDSA,
98
	.probe			= mv88e6171_drv_probe,
99 100
	.setup			= mv88e6171_setup,
	.set_addr		= mv88e6xxx_set_addr_indirect,
101 102
	.phy_read		= mv88e6xxx_phy_read_indirect,
	.phy_write		= mv88e6xxx_phy_write_indirect,
103 104 105
	.get_strings		= mv88e6xxx_get_strings,
	.get_ethtool_stats	= mv88e6xxx_get_ethtool_stats,
	.get_sset_count		= mv88e6xxx_get_sset_count,
106
	.adjust_link		= mv88e6xxx_adjust_link,
107 108 109
#ifdef CONFIG_NET_DSA_HWMON
	.get_temp               = mv88e6xxx_get_temp,
#endif
110 111
	.get_regs_len		= mv88e6xxx_get_regs_len,
	.get_regs		= mv88e6xxx_get_regs,
112 113
	.port_bridge_join	= mv88e6xxx_port_bridge_join,
	.port_bridge_leave	= mv88e6xxx_port_bridge_leave,
114
	.port_stp_state_set	= mv88e6xxx_port_stp_state_set,
115
	.port_vlan_filtering	= mv88e6xxx_port_vlan_filtering,
116
	.port_vlan_prepare	= mv88e6xxx_port_vlan_prepare,
117 118
	.port_vlan_add		= mv88e6xxx_port_vlan_add,
	.port_vlan_del		= mv88e6xxx_port_vlan_del,
119
	.port_vlan_dump		= mv88e6xxx_port_vlan_dump,
V
Vivien Didelot 已提交
120
	.port_fdb_prepare	= mv88e6xxx_port_fdb_prepare,
121 122
	.port_fdb_add		= mv88e6xxx_port_fdb_add,
	.port_fdb_del		= mv88e6xxx_port_fdb_del,
123
	.port_fdb_dump		= mv88e6xxx_port_fdb_dump,
124 125 126
};

MODULE_ALIAS("platform:mv88e6171");
127 128 129
MODULE_ALIAS("platform:mv88e6175");
MODULE_ALIAS("platform:mv88e6350");
MODULE_ALIAS("platform:mv88e6351");