net: dsa: microchip: lan937x: enable interrupt for internal phy link detection
v3 cover 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 v2 -> v3
- Used the interrupt controller implementation of phy link
Changes in RFC v2
- fixed the compilation issue
Arun Ramadoss (3):
net: dsa: microchip: use dev_ops->reset instead of exit in
ksz_switch_register
net: dsa: microchip: add reference to ksz_device inside the ksz_port
net: dsa: microchip: lan937x: add interrupt support for port phy link
drivers/net/dsa/microchip/ksz_common.c | 5 +- drivers/net/dsa/microchip/ksz_common.h | 17 ++ drivers/net/dsa/microchip/ksz_spi.c | 2 + drivers/net/dsa/microchip/lan937x_main.c | 332 ++++++++++++++++++++++- drivers/net/dsa/microchip/lan937x_reg.h | 12 + 5 files changed, 361 insertions(+), 7 deletions(-)
Signature · 1 line
2.36.1
RFC PATCH v3 1/3 net: dsa: microchip: use dev_ops->reset instead of exit in ksz_switch_register
ksz8_switch_exit, ksz9477_switch_exit and lan937x_switch_exit functions all call the reset function which is assigned to dev_ops->reset hooks. So instead of calling the dev_ops->exit in ksz_switch_register during the error condition of dsa_register_switch, dev_ops->reset is used now. The dev_ops->exit can be extended in lan937x for freeing up the irq during the ksz_spi_remove. If we add the irq remove in the exit function and it is called during the dsa_switch_register error condition, kernel panic happens since irq is setup only in setup operation. To avoid the kernel panic, dev_ops->reset is used instead of exit.
--- drivers/net/dsa/microchip/ksz_common.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/dsa/microchip/ksz_common.c +1 -1
@@ -1963,7 +1963,7 @@ int ksz_switch_register(struct ksz_device *dev) ret =dsa_register_switch (dev->ds);if (ret) { - dev->dev_ops->exit (dev); + dev->dev_ops->reset (dev);return ret; }
Signature · 1 line
2.36.1
RFC PATCH v3 2/3 net: dsa: microchip: add reference to ksz_device inside the ksz_port
In reply to Arun Ramadossstruct ksz_port doesn't have reference to ksz_device as of now. In order to find out from which port interrupt has triggered, we need to pass the struct ksz_port as a host data. When the interrupt is triggered, we can get the port from which interrupt triggered, but to identify it is phy interrupt we have to read status register. The regmap structure for accessing the device register is present in the ksz_device struct. To access the ksz_device from the ksz_port, the reference is added to it with port number as well.
--- drivers/net/dsa/microchip/ksz_common.c | 3 +++ drivers/net/dsa/microchip/ksz_common.h | 4 ++++ 2 files changed, 7 insertions(+)
drivers/net/dsa/microchip/ksz_common.c +3 -0
@@ -1917,6 +1917,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 */
drivers/net/dsa/microchip/ksz_common.h +4 -0
@@ -16,6 +16,8 @@#define KSZ_MAX_NUM_PORTS 8 +struct ksz_device ; +struct vlan_table {u32 table[3 ]; };
@@ -82,6 +84,8 @@ struct ksz_port {u16 max_frame;u32 rgmii_tx_val;u32 rgmii_rx_val; +struct ksz_device *ksz_dev; +u8 num; };struct ksz_device {
Signature · 1 line
2.36.1
RFC PATCH v3 3/3 net: dsa: microchip: lan937x: add interrupt support for port phy link
In reply to Arun RamadossThis patch enables the interrupts for internal phy link detection for LAN937x. The interrupt enable bits are active low. There is global interrupt mask for each port. And each port has the individual interrupt mask for TAS. QCI, SGMII, PTP, PHY and ACL.
The first level of interrupt domain is registered for global port interrupt and second level of interrupt domain for the individual port interrupts. The phy interrupt is enabled in the lan937x_mdio_register function. Interrupt from which port is raised will be detected based on the interrupt host data.
--- drivers/net/dsa/microchip/ksz_common.h | 13 + drivers/net/dsa/microchip/ksz_spi.c | 2 + drivers/net/dsa/microchip/lan937x_main.c | 332 ++++++++++++++++++++++- drivers/net/dsa/microchip/lan937x_reg.h | 12 + 4 files changed, 353 insertions(+), 6 deletions(-)
drivers/net/dsa/microchip/ksz_common.h +13 -0
@@ -13,6 +13,7 @@#include <linux/phy.h> #include <linux/regmap.h> #include <net/dsa.h> +#include <linux/irq.h> #define KSZ_MAX_NUM_PORTS 8
@@ -65,6 +66,14 @@ struct ksz_chip_data {bool internal_phy[KSZ_MAX_NUM_PORTS ]; }; +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;
@@ -85,6 +94,7 @@ struct ksz_port {u32 rgmii_tx_val;u32 rgmii_rx_val;struct ksz_device *ksz_dev; +struct ksz_irq irq;u8 num; };
@@ -103,6 +113,7 @@ struct ksz_device {struct regmap *regmap[3 ];void *priv; +int irq;struct gpio_desc *reset_gpio;/* Optional reset GPIO */
@@ -124,6 +135,8 @@ struct ksz_device {u16 mirror_tx;u32 features;/* chip specific features */ u16 port_mask; +struct mutex lock_irq;/* IRQ Access */ +struct ksz_irq girq; };/* List of supported models */
drivers/net/dsa/microchip/ksz_spi.c +2 -0
@@ -85,6 +85,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. */
drivers/net/dsa/microchip/lan937x_main.c +326 -6
387 lines not on this page · raw message
drivers/net/dsa/microchip/lan937x_reg.h +12 -0
@@ -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)
Signature · 1 line
2.36.1
Andrew Lunn
maintainerRe: [RFC Patch net-next v3 1/3] net: dsa: microchip: use dev_ops->reset instead of exit in ksz_switch_register
In reply to Arun RamadossQuoted 20 lines · Arun Ramadoss
ksz8_switch_exit,ksz9477_switch_exitandlan937x_switch_exitfunctions all call the reset function which is assigned todev_ops->resethooks. So instead of calling thedev_ops->exitinksz_switch_registerduring the error condition ofdsa_register_switch,dev_ops->resetis used now. Thedev_ops->exitcan be extended in lan937x for freeing up the irq during theksz_spi_remove. If we add the irq remove in the exit function and it is called during thedsa_switch_registererror condition, kernel panic happens since irq is setup only in setup operation. To avoid the kernel panic,dev_ops->resetis used instead of exit.Signed-off-by Arun Ramadoss <[email protected]>--- drivers/net/dsa/microchip/ksz_common.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/net/dsa/microchip/ksz_common.c +0
-0
drivers/net/dsa/microchip/ksz_common.c int ksz_switch_register(struct ksz_device *dev) · line 1967
Quoted 6 lines
drivers/net/dsa/microchip/ksz_common.c +1
-1@@ -1963,7 +1963,7 @@ int ksz_switch_register(struct ksz_device *dev) ret =dsa_register_switch (dev->ds);if (ret) { - dev->dev_ops->exit (dev); + dev->dev_ops->reset (dev);return ret;
I don't like this change. You are supposed to be undoing whatever ksz_switch_register() has done so far. It appears to of called ops->init() so far, so calling ops->exit() should be the opposite.
If you are making exit() not the opposite of init() in later patches, it suggests your code structure is wrong. If exit() is not already the opposite of init() then fix that.
Andrew
Re: [RFC Patch net-next v3 2/3] net: dsa: microchip: add reference to ksz_device inside the ksz_port
In reply to Arun RamadossQuoted 10 lines · Arun Ramadoss
struct
ksz_portdoesn't have reference toksz_deviceas of now. In order to find out from which port interrupt has triggered, we need to pass the structksz_portas a host data. When the interrupt is triggered, we can get the port from which interrupt triggered, but to identify it is phy interrupt we have to read status register. The regmap structure for accessing the device register is present in theksz_devicestruct. To access theksz_devicefrom theksz_port, the reference is added to it with port number as well.Signed-off-by Arun Ramadoss <[email protected]>
Andrew
Andrew Lunn
maintainerRe: [RFC Patch net-next v3 3/3] net: dsa: microchip: lan937x: add interrupt support for port phy link
In reply to Arun Ramadossdrivers/net/dsa/microchip/ksz_common.h struct ksz_port { · line 97
Quoted 5 lines
drivers/net/dsa/microchip/ksz_common.h +1
-0@@ -85,6 +94,7 @@ struct ksz_port {u32 rgmii_tx_val;u32 rgmii_rx_val;struct ksz_device *ksz_dev; +struct ksz_irq irq;
Here irq is of type ksz_irq.
drivers/net/dsa/microchip/ksz_common.h struct ksz_device { · line 116
Quoted 8 lines
drivers/net/dsa/microchip/ksz_common.h +1
-0u8 num; };@@ -103,6 +113,7 @@ struct ksz_device {struct regmap *regmap[3 ];void *priv; +int irq;
Here it is of type int.
drivers/net/dsa/microchip/ksz_common.h struct ksz_device { · line 139
Quoted 9 lines
drivers/net/dsa/microchip/ksz_common.h +2
-0struct gpio_desc *reset_gpio;/* Optional reset GPIO */ @@ -124,6 +135,8 @@ struct ksz_device {u16 mirror_tx;u32 features;/* chip specific features */ u16 port_mask; +struct mutex lock_irq;/* IRQ Access */ +struct ksz_irq girq;
And here you have the type ksz_irq called qirq. This is going to be confusing.
I suggest you make the first one called pirq, for port, and then we have girq for global, and irq is just a number.
Quoted 12 lines
drivers/net/dsa/microchip/lan937x_main.c +1
-0static int lan937x_cfg (struct ksz_device *dev,u32 addr,u8 bits,bool set) {return regmap_update_bits (dev->regmap[0 ], addr, bits, set ? bits :0 );@@ -171,6 +175,7 @@ static int lan937x_mdio_register(struct ksz_device *dev)struct device_node *mdio_np;struct mii_bus *bus;int ret; +int p; mdio_np =of_get_child_by_name (dev->dev->of_node,"mdio" );if (!mdio_np) {
drivers/net/dsa/microchip/lan937x_main.c static int lan937x_mdio_register(struct ksz_device *dev) · line 207
Quoted 9 lines
drivers/net/dsa/microchip/lan937x_main.c +6
-0@@ -194,6 +199,16 @@ static int lan937x_mdio_register(struct ksz_device *dev) ds->slave_mii_bus = bus; +for (p =0 ; p <KSZ_MAX_NUM_PORTS ; p++) { +if (BIT (p) & ds->phys_mii_mask) { +unsigned int irq; + + irq =irq_find_mapping (dev->ports[p].irq.domain, +PORT_SRC_PHY_INT );
This could return an error code. You really should check for it, the irq subsystem is not going to be happy with a negative irq number.
drivers/net/dsa/microchip/lan937x_main.c static int lan937x_mdio_register(struct ksz_device *dev) · line 214
Quoted 7 lines
drivers/net/dsa/microchip/lan937x_main.c +4
-0+ ds->slave_mii_bus->irq[p] = irq; + } + } + ret =devm_of_mdiobus_register (ds->dev, bus, mdio_np);if (ret) { dev_err(ds->dev, "unable to register MDIO bus %s\n",
I don't see anywhere you destroy the mappings you created above when the MDIO bus is unregistered. The equivalent of mv88e6xxx_g2_irq_mdio_free().
Quoted 8 lines
drivers/net/dsa/microchip/lan937x_main.c +8
-0+static irqreturn_t lan937x_girq_thread_fn (int irq,void *dev_id) +{ +struct ksz_device *dev = dev_id; +unsigned int nhandled =0 ; +unsigned int sub_irq; +unsigned int n; +u32 data; +int ret;
drivers/net/dsa/microchip/lan937x_main.c void lan937x_setup_rgmii_delay(struct ksz_device *dev, int port) · line 497
Quoted 10 lines
drivers/net/dsa/microchip/lan937x_main.c +10
-0+ + ret =ksz_read32 (dev,REG_SW_INT_STATUS__4 , &data); +if (ret) + goto out; + +if (data &POR_READY_INT ) { + ret =ksz_write32 (dev,REG_SW_INT_STATUS__4 ,POR_READY_INT ); +if (ret) + goto out; + }
What do these two read/writes do? It seems like you are discarding an interrupt?
Quoted 20 lines
drivers/net/dsa/microchip/lan937x_main.c +20
-0+ +/* Read global interrupt status register */ + ret =ksz_read32 (dev,REG_SW_PORT_INT_STATUS__4 , &data); +if (ret) + goto out; + +for (n =0 ; n < dev->girq.nirqs; ++n) { +if (data & (1 << n)) { + sub_irq =irq_find_mapping (dev->girq.domain, n); +handle_nested_irq (sub_irq); + ++nhandled; + } + } +out: +return (nhandled >0 ?IRQ_HANDLED :IRQ_NONE ); +} + +static irqreturn_t lan937x_pirq_thread_fn (int irq,void *dev_id) +{ +struct ksz_port *port = dev_id;
drivers/net/dsa/microchip/lan937x_main.c void lan937x_setup_rgmii_delay(struct ksz_device *dev, int port) · line 627
Quoted 10 lines
drivers/net/dsa/microchip/lan937x_main.c +10
-0+unsigned int nhandled =0 ; +struct ksz_device *dev; +unsigned int sub_irq; +unsigned int n; +u8 data; + + dev = port->ksz_dev; + +/* Read global interrupt status register */ +ksz_pread8 (dev, port->num,REG_PORT_INT_STATUS , &data);
I think global here should be port?
Quoted 39 lines
drivers/net/dsa/microchip/lan937x_main.c +25
-0+ +for (n =0 ; n < port->irq.nirqs; ++n) { +if (data & (1 << n)) { + sub_irq =irq_find_mapping (port->irq.domain, n); +handle_nested_irq (sub_irq); + ++nhandled; + } + } + +return (nhandled >0 ?IRQ_HANDLED :IRQ_NONE ); +} +int lan937x_setup (struct dsa_switch *ds) {struct ksz_device *dev = ds->priv; +struct dsa_port *dp;int ret;/* enable Indirect Access from SPI to the VPHY registers */ @@ -395,10 +688,22 @@ int lan937x_setup(struct dsa_switch *ds)return ret; } +if (dev->irq >0 ) { + ret =lan937x_girq_setup (dev); +if (ret) +return ret; + +dsa_switch_for_each_user_port (dp, dev->ds) { + ret =lan937x_pirq_setup (dev, dp->index); +if (ret) + goto out_girq; + } + } +void lan937x_switch_exit (struct ksz_device *dev) {
drivers/net/dsa/microchip/lan937x_main.c int lan937x_setup(struct dsa_switch *ds) · line 757
Quoted 10 lines
drivers/net/dsa/microchip/lan937x_main.c +9
-0+struct dsa_port *dp; +lan937x_reset_switch (dev); + +if (dev->irq >0 ) { +dsa_switch_for_each_user_port (dp, dev->ds) { +lan937x_pirq_free (&dev->ports[dp->index], dp->index); + } + +lan937x_girq_free (dev);
This is where your problem with exit vs reset is coming from. You setup all the interrupt code in setup(). But currently there is no function which is the opposite of setup(). Generally, it is called tairdown. Add such a function.
Andrew
Re: [RFC Patch net-next v3 3/3] net: dsa: microchip: lan937x: add interrupt support for port phy link
Quoted 35 lines · Andrew Lunn
EXTERNAL EMAIL: Do not click links or open attachments unless you know the content is safe
drivers/net/dsa/microchip/ksz_common.h struct ksz_port { · line 97
Quoted 5 lines
drivers/net/dsa/microchip/ksz_common.h +1
-0@@ -85,6 +94,7 @@ struct ksz_port {u32 rgmii_tx_val;u32 rgmii_rx_val;struct ksz_device *ksz_dev; +struct ksz_irq irq;Here irq is of type
ksz_irq.drivers/net/dsa/microchip/ksz_common.h struct ksz_device { · line 116
Quoted 8 lines
drivers/net/dsa/microchip/ksz_common.h +1
-0u8 num; };@@ -103,6 +113,7 @@ struct ksz_device {struct regmap *regmap[3 ];void *priv; +int irq;Here it is of type int.
drivers/net/dsa/microchip/ksz_common.h struct ksz_device { · line 139
Quoted 9 lines
drivers/net/dsa/microchip/ksz_common.h +2
-0struct gpio_desc *reset_gpio;/* Optional reset GPIO */ @@ -124,6 +135,8 @@ struct ksz_device {u16 mirror_tx;u32 features;/* chip specific features */ u16 port_mask; +struct mutex lock_irq;/* IRQ Access */ +struct ksz_irq girq;And here you have the type
ksz_irqcalled qirq. This is going to be confusing.
Quoted 2 lines
I suggest you make the first one called pirq, for port, and then we have girq for global, and irq is just a number.
Ok. I will update variable names as per the context it is used.
Quoted 25 lines
Quoted 25 lines
(quoted diff) +0
-0static int lan937x_cfg(struct ksz_device *dev, u32 addr, u8 bits, bool set) {return regmap_update_bits(dev->regmap[0], addr, bits, set ?bits : 0);
drivers/net/dsa/microchip/lan937x_main.c +1
-0@@ -171,6 +175,7 @@ static int lan937x_mdio_register(struct ksz_device *dev)struct device_node *mdio_np;struct mii_bus *bus;int ret; +int p; mdio_np =of_get_child_by_name (dev->dev->of_node,"mdio" );if (!mdio_np) {drivers/net/dsa/microchip/lan937x_main.c +5
-0@@ -194,6 +199,16 @@ static int lan937x_mdio_register(struct ksz_device *dev) ds->slave_mii_bus = bus; +for (p =0 ; p <KSZ_MAX_NUM_PORTS ; p++) { +if (BIT (p) & ds->phys_mii_mask) { +unsigned int irq; + + irq = irq_find_mapping(dev-
Quoted 5 lines
Review static int lan937x_mdio_register(struct · line 209
Quoted 2 lines
(quoted diff) +1
-0>ports[p].irq.domain, + PORT_SRC_PHY_INT);This could return an error code. You really should check for it, the irq subsystem is not going to be happy with a negative irq number.
Ok. I will check the return value for irq_find_mapping.
Quoted 9 lines
Quoted 8 lines
drivers/net/dsa/microchip/lan937x_main.c +4
-0+ ds->slave_mii_bus->irq[p] = irq; + } + } + ret =devm_of_mdiobus_register (ds->dev, bus, mdio_np);if (ret) { dev_err(ds->dev, "unable to register MDIO bus %s\n",
Quoted 3 lines
I don't see anywhere you destroy the mappings you created above when the MDIO bus is unregistered. The equivalent of
mv88e6xxx_g2_irq_mdio_free().
I missed to destroy it. I will add.
Quoted 16 lines
Quoted 16 lines
drivers/net/dsa/microchip/lan937x_main.c +14
-0+static irqreturn_t lan937x_girq_thread_fn (int irq,void *dev_id) +{ +struct ksz_device *dev = dev_id; +unsigned int nhandled =0 ; +unsigned int sub_irq; +unsigned int n; +u32 data; +int ret; + + ret =ksz_read32 (dev,REG_SW_INT_STATUS__4 , &data); +if (ret) + goto out; + +if (data &POR_READY_INT ) {
Quoted 8 lines
drivers/net/dsa/microchip/lan937x_main.c void lan937x_setup_rgmii_delay(struct ksz_device *dev, int port) · line 497
Quoted 5 lines
+ ret = ksz_write32(dev,
REG_SW_INT_STATUS__4,POR_READY_INT);drivers/net/dsa/microchip/lan937x_main.c +3
-0+if (ret) + goto out; + }What do these two read/writes do? It seems like you are discarding an interrupt?
This interrupt in Power on reset interrupt. It is enabled by default in the chip. I am not performing any operation based on POR. So I just cleared the interrupt. Do I need to disable the POR interrupt in the setup function, since no operation is performed based on it?
Quoted 27 lines
Quoted 27 lines
drivers/net/dsa/microchip/lan937x_main.c +9
-0+ +/* Read global interrupt status register */ + ret =ksz_read32 (dev,REG_SW_PORT_INT_STATUS__4 , &data); +if (ret) + goto out; + +for (n =0 ; n < dev->girq.nirqs; ++n) { +if (data & (1 << n)) { + sub_irq = irq_find_mapping(dev->girq.domain,n);
drivers/net/dsa/microchip/lan937x_main.c +15
-0+handle_nested_irq (sub_irq); + ++nhandled; + } + } +out: +return (nhandled >0 ?IRQ_HANDLED :IRQ_NONE ); +} + +static irqreturn_t lan937x_pirq_thread_fn (int irq,void *dev_id) +{ +struct ksz_port *port = dev_id; +unsigned int nhandled =0 ; +struct ksz_device *dev; +unsigned int sub_irq; +unsigned int n;
Quoted 8 lines
drivers/net/dsa/microchip/lan937x_main.c void lan937x_setup_rgmii_delay(struct ksz_device *dev, int port) · line 627
Quoted 6 lines
drivers/net/dsa/microchip/lan937x_main.c +6
-0+u8 data; + + dev = port->ksz_dev; + +/* Read global interrupt status register */ +ksz_pread8 (dev, port->num,REG_PORT_INT_STATUS , &data);I think global here should be port?
Yes. Copy paste problem. I will update it.
Quoted 25 lines
Quoted 25 lines
drivers/net/dsa/microchip/lan937x_main.c +4
-0+ +for (n =0 ; n < port->irq.nirqs; ++n) { +if (data & (1 << n)) { + sub_irq = irq_find_mapping(port->irq.domain,n);
drivers/net/dsa/microchip/lan937x_main.c +14
-0+handle_nested_irq (sub_irq); + ++nhandled; + } + } + +return (nhandled >0 ?IRQ_HANDLED :IRQ_NONE ); +} +void lan937x_switch_exit (struct ksz_device *dev) { +struct dsa_port *dp; +lan937x_reset_switch (dev); + +if (dev->irq >0 ) { +dsa_switch_for_each_user_port (dp, dev->ds) { + lan937x_pirq_free(&dev->ports[dp->index], dp-Quoted 1 line
index);
Quoted 8 lines
drivers/net/dsa/microchip/lan937x_main.c void lan937x_setup_rgmii_delay(struct ksz_device *dev, int port) · line 540
Quoted 3 lines
drivers/net/dsa/microchip/lan937x_main.c +3
-0+ } + +lan937x_girq_free (dev);This is where your problem with exit vs reset is coming from. You setup all the interrupt code in
setup(). But currently there is no function which is the opposite ofsetup(). Generally, it is called tairdown. Add such a function.
Yes I was looking for opposite function for setup(). Thanks for suggestion, I will update the code accordingly and remove the patch 1/3 from the series which replaces the exit with reset.
Quoted 2 lines
Andrew
Andrew Lunn
maintainerRe: [RFC Patch net-next v3 3/3] net: dsa: microchip: lan937x: add interrupt support for port phy link
Quoted 23 lines
Quoted 14 lines
Quoted 14 lines
drivers/net/dsa/microchip/lan937x_main.c +14
-0+static irqreturn_t lan937x_girq_thread_fn (int irq,void *dev_id) +{ +struct ksz_device *dev = dev_id; +unsigned int nhandled =0 ; +unsigned int sub_irq; +unsigned int n; +u32 data; +int ret; + + ret =ksz_read32 (dev,REG_SW_INT_STATUS__4 , &data); +if (ret) + goto out; + +if (data &POR_READY_INT ) {Quoted 8 lines
drivers/net/dsa/microchip/lan937x_main.c void lan937x_setup_rgmii_delay(struct ksz_device *dev, int port) · line 497
Quoted 5 lines
+ ret = ksz_write32(dev,
REG_SW_INT_STATUS__4,POR_READY_INT);drivers/net/dsa/microchip/lan937x_main.c +3
-0+if (ret) + goto out; + }What do these two read/writes do? It seems like you are discarding an interrupt?
Quoted 4 lines
This interrupt in Power on reset interrupt. It is enabled by default in the chip. I am not performing any operation based on POR. So I just cleared the interrupt. Do I need to disable the POR interrupt in the setup function, since no operation is performed based on it?
It is pretty normal during interrupt controller creation to first disable all interrupt sources, then clear the interrupt status register if that can be done with a single operation, and then register the interrupt controller with the IRQ core. That way, any outstanding interrupts don't fire.
Andrew