Skip to content

Commit 7c970c6

Browse files
RengarajanSSgregkh
authored andcommitted
misc: microchip: pci1xxxx: Add PCIe Hot reset disable support for Rev C0 and later devices
Systems that issue PCIe hot reset requests during a suspend/resume cycle cause PCI1XXXX device revisions prior to C0 to get its GPIO configuration registers reset to hardware default values. This results in device inaccessibility and GPIO read/write failure. Starting with Revision C0, support was added in the device hardware (via the Hot Reset Disable Bit) to allow resetting only the PCIe interface and its associated logic, but preserving the GPIO configurations during a hot reset. This patch enables the hot reset disable feature during suspend/ resume for C0 and later revisions of the device. mchp_pci1xxxx_gpio is an auxiliary child of mchp_pci1xxxx_gp and does not have access to system register address space for reading the device revision. Hence, the device revision is retrieved directly from PCIe config space. Signed-off-by: Rengarajan S <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent 7b386d7 commit 7c970c6

File tree

1 file changed

+31
-0
lines changed

1 file changed

+31
-0
lines changed

drivers/misc/mchp_pci1xxxx/mchp_pci1xxxx_gpio.c

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,14 @@
77
#include <linux/gpio/driver.h>
88
#include <linux/bio.h>
99
#include <linux/mutex.h>
10+
#include <linux/pci.h>
1011
#include <linux/kthread.h>
1112
#include <linux/interrupt.h>
1213

1314
#include "mchp_pci1xxxx_gp.h"
1415

1516
#define PCI1XXXX_NR_PINS 93
17+
#define PCI_DEV_REV_OFFSET 0x08
1618
#define PERI_GEN_RESET 0
1719
#define OUT_EN_OFFSET(x) ((((x) / 32) * 4) + 0x400)
1820
#define INP_EN_OFFSET(x) ((((x) / 32) * 4) + 0x400 + 0x10)
@@ -41,8 +43,25 @@ struct pci1xxxx_gpio {
4143
struct gpio_chip gpio;
4244
spinlock_t lock;
4345
int irq_base;
46+
u8 dev_rev;
4447
};
4548

49+
static int pci1xxxx_gpio_get_device_revision(struct pci1xxxx_gpio *priv)
50+
{
51+
struct device *parent = priv->aux_dev->dev.parent;
52+
struct pci_dev *pcidev = to_pci_dev(parent);
53+
int ret;
54+
u32 val;
55+
56+
ret = pci_read_config_dword(pcidev, PCI_DEV_REV_OFFSET, &val);
57+
if (ret)
58+
return ret;
59+
60+
priv->dev_rev = val;
61+
62+
return 0;
63+
}
64+
4665
static int pci1xxxx_gpio_get_direction(struct gpio_chip *gpio, unsigned int nr)
4766
{
4867
struct pci1xxxx_gpio *priv = gpiochip_get_data(gpio);
@@ -316,6 +335,10 @@ static int pci1xxxx_gpio_suspend(struct device *dev)
316335
pci1xxx_assign_bit(priv->reg_base, PIO_GLOBAL_CONFIG_OFFSET,
317336
17, false);
318337
pci1xxx_assign_bit(priv->reg_base, PERI_GEN_RESET, 16, true);
338+
339+
if (priv->dev_rev >= 0xC0)
340+
pci1xxx_assign_bit(priv->reg_base, PERI_GEN_RESET, 17, true);
341+
319342
spin_unlock_irqrestore(&priv->lock, flags);
320343

321344
return 0;
@@ -332,6 +355,10 @@ static int pci1xxxx_gpio_resume(struct device *dev)
332355
pci1xxx_assign_bit(priv->reg_base, PIO_GLOBAL_CONFIG_OFFSET,
333356
16, false);
334357
pci1xxx_assign_bit(priv->reg_base, PERI_GEN_RESET, 16, false);
358+
359+
if (priv->dev_rev >= 0xC0)
360+
pci1xxx_assign_bit(priv->reg_base, PERI_GEN_RESET, 17, false);
361+
335362
spin_unlock_irqrestore(&priv->lock, flags);
336363

337364
return 0;
@@ -413,6 +440,10 @@ static int pci1xxxx_gpio_probe(struct auxiliary_device *aux_dev,
413440
if (retval < 0)
414441
return retval;
415442

443+
retval = pci1xxxx_gpio_get_device_revision(priv);
444+
if (retval)
445+
return retval;
446+
416447
dev_set_drvdata(&aux_dev->dev, priv);
417448

418449
return devm_gpiochip_add_data(&aux_dev->dev, &priv->gpio, priv);

0 commit comments

Comments
 (0)