generic: ar8216: add caps field to ar8xxx_chip

SVN-Revision: 31003
lede-17.01
Gabor Juhos 2012-03-18 22:06:33 +00:00
parent d1c585d4b1
commit 56cacb3b21
1 changed files with 19 additions and 5 deletions

View File

@ -38,7 +38,11 @@
struct ar8216_priv; struct ar8216_priv;
#define AR8XXX_CAP_GIGE BIT(0)
struct ar8xxx_chip { struct ar8xxx_chip {
unsigned long caps;
int (*hw_init)(struct ar8216_priv *priv); int (*hw_init)(struct ar8216_priv *priv);
void (*init_port)(struct ar8216_priv *priv, int port); void (*init_port)(struct ar8216_priv *priv, int port);
void (*setup_port)(struct ar8216_priv *priv, int port, u32 egress, 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) #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 static inline void
split_addr(u32 regaddr, u16 *r1, u16 *r2, u16 *page) 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) { if (port == AR8216_PORT_CPU) {
priv->write(priv, AR8216_REG_PORT_STATUS(port), priv->write(priv, AR8216_REG_PORT_STATUS(port),
AR8216_PORT_STATUS_LINK_UP | AR8216_PORT_STATUS_LINK_UP |
((priv->chip_type == AR8316) ? ar8xxx_has_gige(priv) ? AR8216_PORT_SPEED_1000M :
AR8216_PORT_SPEED_1000M : AR8216_PORT_SPEED_100M) | AR8216_PORT_SPEED_100M |
AR8216_PORT_STATUS_TXMAC | AR8216_PORT_STATUS_TXMAC |
AR8216_PORT_STATUS_RXMAC | AR8216_PORT_STATUS_RXMAC |
((priv->chip_type == AR8316) ? AR8216_PORT_STATUS_RXFLOW : 0) | ((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 = { static const struct ar8xxx_chip ar8316_chip = {
.caps = AR8XXX_CAP_GIGE,
.hw_init = ar8316_hw_init, .hw_init = ar8316_hw_init,
.init_port = ar8216_init_port, .init_port = ar8216_init_port,
.setup_port = ar8216_setup_port, .setup_port = ar8216_setup_port,
@ -917,10 +927,12 @@ ar8216_config_init(struct phy_device *pdev)
goto err_free_priv; goto err_free_priv;
if (pdev->addr != 0) { if (pdev->addr != 0) {
if (priv->chip_type == AR8316) { if (ar8xxx_has_gige(priv)) {
pdev->supported |= SUPPORTED_1000baseT_Full; pdev->supported |= SUPPORTED_1000baseT_Full;
pdev->advertising |= ADVERTISED_1000baseT_Full; pdev->advertising |= ADVERTISED_1000baseT_Full;
}
if (priv->chip_type == AR8316) {
/* check if we're attaching to the switch twice */ /* check if we're attaching to the switch twice */
pdev = pdev->bus->phy_map[0]; pdev = pdev->bus->phy_map[0];
if (!pdev) { if (!pdev) {
@ -953,8 +965,10 @@ ar8216_config_init(struct phy_device *pdev)
printk(KERN_INFO "%s: AR%d switch driver attached.\n", printk(KERN_INFO "%s: AR%d switch driver attached.\n",
pdev->attached_dev->name, priv->chip_type); pdev->attached_dev->name, priv->chip_type);
pdev->supported = priv->chip_type == AR8316 ? if (ar8xxx_has_gige(priv))
SUPPORTED_1000baseT_Full : SUPPORTED_100baseT_Full; pdev->supported = SUPPORTED_1000baseT_Full;
else
pdev->supported = SUPPORTED_100baseT_Full;
pdev->advertising = pdev->supported; pdev->advertising = pdev->supported;
mutex_init(&priv->reg_mutex); mutex_init(&priv->reg_mutex);