summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGabor Juhos <juhosg@openwrt.org>2012-03-18 22:06:33 +0000
committerGabor Juhos <juhosg@openwrt.org>2012-03-18 22:06:33 +0000
commit56cacb3b21808a58a71fa0b39a9d1e10e1584042 (patch)
treee618e580cdff973d6f385180826d23d16f9da496
parentd1c585d4b1b2fa3128dd4aa358fbcda84bb217b8 (diff)
downloadmtk-20170518-56cacb3b21808a58a71fa0b39a9d1e10e1584042.zip
mtk-20170518-56cacb3b21808a58a71fa0b39a9d1e10e1584042.tar.gz
mtk-20170518-56cacb3b21808a58a71fa0b39a9d1e10e1584042.tar.bz2
generic: ar8216: add caps field to ar8xxx_chip
SVN-Revision: 31003
-rw-r--r--target/linux/generic/files/drivers/net/phy/ar8216.c24
1 files changed, 19 insertions, 5 deletions
diff --git a/target/linux/generic/files/drivers/net/phy/ar8216.c b/target/linux/generic/files/drivers/net/phy/ar8216.c
index d514ec7..3666864 100644
--- a/target/linux/generic/files/drivers/net/phy/ar8216.c
+++ b/target/linux/generic/files/drivers/net/phy/ar8216.c
@@ -38,7 +38,11 @@
struct ar8216_priv;
+#define AR8XXX_CAP_GIGE BIT(0)
+
struct ar8xxx_chip {
+ unsigned long caps;
+
int (*hw_init)(struct ar8216_priv *priv);
void (*init_port)(struct ar8216_priv *priv, int port);
void (*setup_port)(struct ar8216_priv *priv, int port, u32 egress,
@@ -74,6 +78,11 @@ struct ar8216_priv {
#define to_ar8216(_dev) container_of(_dev, struct ar8216_priv, dev)
+static inline bool ar8xxx_has_gige(struct ar8216_priv *priv)
+{
+ return priv->chip->caps & AR8XXX_CAP_GIGE;
+}
+
static inline void
split_addr(u32 regaddr, u16 *r1, u16 *r2, u16 *page)
{
@@ -757,8 +766,8 @@ ar8216_init_port(struct ar8216_priv *priv, int port)
if (port == AR8216_PORT_CPU) {
priv->write(priv, AR8216_REG_PORT_STATUS(port),
AR8216_PORT_STATUS_LINK_UP |
- ((priv->chip_type == AR8316) ?
- AR8216_PORT_SPEED_1000M : AR8216_PORT_SPEED_100M) |
+ ar8xxx_has_gige(priv) ? AR8216_PORT_SPEED_1000M :
+ AR8216_PORT_SPEED_100M |
AR8216_PORT_STATUS_TXMAC |
AR8216_PORT_STATUS_RXMAC |
((priv->chip_type == AR8316) ? AR8216_PORT_STATUS_RXFLOW : 0) |
@@ -789,6 +798,7 @@ static const struct ar8xxx_chip ar8236_chip = {
};
static const struct ar8xxx_chip ar8316_chip = {
+ .caps = AR8XXX_CAP_GIGE,
.hw_init = ar8316_hw_init,
.init_port = ar8216_init_port,
.setup_port = ar8216_setup_port,
@@ -917,10 +927,12 @@ ar8216_config_init(struct phy_device *pdev)
goto err_free_priv;
if (pdev->addr != 0) {
- if (priv->chip_type == AR8316) {
+ if (ar8xxx_has_gige(priv)) {
pdev->supported |= SUPPORTED_1000baseT_Full;
pdev->advertising |= ADVERTISED_1000baseT_Full;
+ }
+ if (priv->chip_type == AR8316) {
/* check if we're attaching to the switch twice */
pdev = pdev->bus->phy_map[0];
if (!pdev) {
@@ -953,8 +965,10 @@ ar8216_config_init(struct phy_device *pdev)
printk(KERN_INFO "%s: AR%d switch driver attached.\n",
pdev->attached_dev->name, priv->chip_type);
- pdev->supported = priv->chip_type == AR8316 ?
- SUPPORTED_1000baseT_Full : SUPPORTED_100baseT_Full;
+ if (ar8xxx_has_gige(priv))
+ pdev->supported = SUPPORTED_1000baseT_Full;
+ else
+ pdev->supported = SUPPORTED_100baseT_Full;
pdev->advertising = pdev->supported;
mutex_init(&priv->reg_mutex);