Commit 5f3c5193 authored by David S. Miller's avatar David S. Miller

Merge branch 'lan937x-phy-link-interrupt'

Arun Ramadoss says:

====================
net: dsa: microchip: lan937x: enable interrupt for internal phy link detection

This patch series enables the internal phy link detection for lan937x using the
interrupt method. lan937x acts as the interrupt controller for the internal
ports and phy, the irq_domain is registered for the individual ports and in
turn for the individual port interrupts.

RFC v3 -> Patch v1
- Removed the RFC v3 1/3 from the series - changing exit from reset
- Changed the variable name in ksz_port from irq to pirq
- Added the check for return value of irq_find_mapping during phy irq
  registeration.
- Moved the clearing of POR_READY_INT from girq_thread_fn to
  lan937x_reset_switch

RFC v2 -> v3
- Used the interrupt controller implementation of phy link

Changes in RFC v2
- fixed the compilation issue
====================
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parents 6630edab c9cd961c
......@@ -205,6 +205,7 @@ static const struct ksz_dev_ops ksz9477_dev_ops = {
static const struct ksz_dev_ops lan937x_dev_ops = {
.setup = lan937x_setup,
.teardown = lan937x_teardown,
.get_port_addr = ksz9477_get_port_addr,
.cfg_port_member = ksz9477_cfg_port_member,
.flush_dyn_mac_table = ksz9477_flush_dyn_mac_table,
......@@ -1444,6 +1445,14 @@ static int ksz_setup(struct dsa_switch *ds)
return 0;
}
static void ksz_teardown(struct dsa_switch *ds)
{
struct ksz_device *dev = ds->priv;
if (dev->dev_ops->teardown)
dev->dev_ops->teardown(ds);
}
static void port_r_cnt(struct ksz_device *dev, int port)
{
struct ksz_port_mib *mib = &dev->ports[port].mib;
......@@ -2193,6 +2202,7 @@ static const struct dsa_switch_ops ksz_switch_ops = {
.get_tag_protocol = ksz_get_tag_protocol,
.get_phy_flags = ksz_get_phy_flags,
.setup = ksz_setup,
.teardown = ksz_teardown,
.phy_read = ksz_phy_read16,
.phy_write = ksz_phy_write16,
.phylink_get_caps = ksz_phylink_get_caps,
......@@ -2357,6 +2367,9 @@ int ksz_switch_register(struct ksz_device *dev)
GFP_KERNEL);
if (!dev->ports[i].mib.counters)
return -ENOMEM;
dev->ports[i].ksz_dev = dev;
dev->ports[i].num = i;
}
/* set the real number of ports */
......
......@@ -13,9 +13,12 @@
#include <linux/phy.h>
#include <linux/regmap.h>
#include <net/dsa.h>
#include <linux/irq.h>
#define KSZ_MAX_NUM_PORTS 8
struct ksz_device;
struct vlan_table {
u32 table[3];
};
......@@ -66,6 +69,14 @@ struct ksz_chip_data {
const struct regmap_access_table *rd_table;
};
struct ksz_irq {
u16 masked;
struct irq_chip chip;
struct irq_domain *domain;
int nirqs;
char name[16];
};
struct ksz_port {
bool remove_tag; /* Remove Tag flag set, for ksz8795 only */
bool learning;
......@@ -83,6 +94,9 @@ struct ksz_port {
u16 max_frame;
u32 rgmii_tx_val;
u32 rgmii_rx_val;
struct ksz_device *ksz_dev;
struct ksz_irq pirq;
u8 num;
};
struct ksz_device {
......@@ -100,6 +114,7 @@ struct ksz_device {
struct regmap *regmap[3];
void *priv;
int irq;
struct gpio_desc *reset_gpio; /* Optional reset GPIO */
......@@ -120,6 +135,8 @@ struct ksz_device {
u16 mirror_rx;
u16 mirror_tx;
u16 port_mask;
struct mutex lock_irq; /* IRQ Access */
struct ksz_irq girq;
};
/* List of supported models */
......@@ -256,6 +273,7 @@ struct alu_struct {
struct ksz_dev_ops {
int (*setup)(struct dsa_switch *ds);
void (*teardown)(struct dsa_switch *ds);
u32 (*get_port_addr)(int port, int offset);
void (*cfg_port_member)(struct ksz_device *dev, int port, u8 member);
void (*flush_dyn_mac_table)(struct ksz_device *dev, int port);
......
......@@ -88,6 +88,8 @@ static int ksz_spi_probe(struct spi_device *spi)
if (ret)
return ret;
dev->irq = spi->irq;
ret = ksz_switch_register(dev);
/* Main DSA driver may not be started yet. */
......
......@@ -8,6 +8,7 @@
int lan937x_reset_switch(struct ksz_device *dev);
int lan937x_setup(struct dsa_switch *ds);
void lan937x_teardown(struct dsa_switch *ds);
void lan937x_port_setup(struct ksz_device *dev, int port, bool cpu_port);
void lan937x_config_cpu_port(struct dsa_switch *ds);
int lan937x_switch_init(struct ksz_device *dev);
......
This diff is collapsed.
......@@ -118,6 +118,18 @@
/* Port Registers */
/* 0 - Operation */
#define REG_PORT_INT_STATUS 0x001B
#define REG_PORT_INT_MASK 0x001F
#define PORT_TAS_INT BIT(5)
#define PORT_QCI_INT BIT(4)
#define PORT_SGMII_INT BIT(3)
#define PORT_PTP_INT BIT(2)
#define PORT_PHY_INT BIT(1)
#define PORT_ACL_INT BIT(0)
#define PORT_SRC_PHY_INT 1
#define REG_PORT_CTRL_0 0x0020
#define PORT_MAC_LOOPBACK BIT(7)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment