PCI: aardvark controller changes BATCH 6
Subsystems (5)
v2 cover PCI: aardvark controller changes BATCH 6
Hello Lorenzo,
here comes v2 of batch 6 of Aardvark patches.
The original version can be found on the mailing list archives [1].
Changes since v1:
- dropped first patch,
PCI: pciehp: Enable DLLSC interrupt only if supported
since it is not a dependency for this series and Lukas Wunner considers the change without value
- added more explanation to patches 2 and 6 (previously 3 and 7)
Marek
[1] https://lore.kernel.org/linux-pci/[email protected]/
Marek Behún (2):
PCI: aardvark: Don't write read-only bits explicitly in PCI_ERR_CAP
register
PCI: aardvark: Explicitly disable Marvell strict ordering
Miquel Raynal (2):
PCI: aardvark: Add clock support
PCI: aardvark: Add suspend to RAM support
Pali Rohár (6):
PCI: pciehp: Enable Command Completed Interrupt only if supported
PCI: aardvark: Add support for DLLSC and hotplug interrupt
PCI: aardvark: Send Set_Slot_Power_Limit message
arm64: dts: armada-3720-turris-mox: Define slot-power-limit-milliwatt
for PCIe
PCI: aardvark: Replace custom PCIE_CORE_ERR_CAPCTL_* macros by
linux/pci_regs.h macros
PCI: aardvark: Cleanup some register macros
.../dts/marvell/armada-3720-turris-mox.dts | 1 + drivers/pci/controller/Kconfig | 3 + drivers/pci/controller/pci-aardvark.c | 258 +++++++++++++++--- drivers/pci/hotplug/pciehp_hpc.c | 4 +- 4 files changed, 232 insertions(+), 34 deletions(-)
Signature · 1 line
2.35.1
PATCH v2 1/10 PCI: pciehp: Enable Command Completed Interrupt only if supported
From: Pali Rohár <[email protected]>
The No Command Completed Support bit in the Slot Capabilities register indicates whether Command Completed Interrupt Enable is unsupported.
We already check whether No Command Completed Support bit is set in pcie_wait_cmd(), and do not wait in this case.
Let's not enable this Command Completed Interrupt at all if NCCS is set, so that when users dump configuration space from userspace, the dump does not confuse them by saying that Command Completed Interrupt is not supported, but it is enabled.
--- drivers/pci/hotplug/pciehp_hpc.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/pci/hotplug/pciehp_hpc.c +3 -1
@@ -811,7 +811,9 @@ static void pcie_enable_notification(struct controller *ctrl)else cmd |=PCI_EXP_SLTCTL_PDCE ;if (!pciehp_poll_mode) - cmd |=PCI_EXP_SLTCTL_HPIE |PCI_EXP_SLTCTL_CCIE ; + cmd |=PCI_EXP_SLTCTL_HPIE ; +if (!pciehp_poll_mode && !NO_CMD_CMPL (ctrl)) + cmd |=PCI_EXP_SLTCTL_CCIE ; mask = (PCI_EXP_SLTCTL_PDCE | PCI_EXP_SLTCTL_ABPE | PCI_EXP_SLTCTL_PFDE |
Signature · 1 line
2.35.1
Re: [PATCH v2 01/10] PCI: pciehp: Enable Command Completed Interrupt only if supported
Quoted 8 lines · Marek Behún
From: Pali Rohár <[email protected]>
The No Command Completed Support bit in the Slot Capabilities register indicates whether Command Completed Interrupt Enable is unsupported.
We already check whether No Command Completed Support bit is set in
pcie_wait_cmd(), and do not wait in this case.
Quoted 8 lines
Let's not enable this Command Completed Interrupt at all if NCCS is set, so that when users dump configuration space from userspace, the dump does not confuse them by saying that Command Completed Interrupt is not supported, but it is enabled.
Signed-off-by Pali Rohár <[email protected]>Signed-off-by Marek Behún <[email protected]>Reviewed-by Lukas Wunner <[email protected]>
Since this isn't directly related to aardvark or the rest of the series, I applied this to pci/hotplug for v6.2, thanks!
Quoted 27 lines
--- drivers/pci/hotplug/pciehp_hpc.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)drivers/pci/hotplug/pciehp_hpc.c +3
-1@@ -811,7 +811,9 @@ static void pcie_enable_notification(struct controller *ctrl)else cmd |=PCI_EXP_SLTCTL_PDCE ;if (!pciehp_poll_mode) - cmd |=PCI_EXP_SLTCTL_HPIE |PCI_EXP_SLTCTL_CCIE ; + cmd |=PCI_EXP_SLTCTL_HPIE ; +if (!pciehp_poll_mode && !NO_CMD_CMPL (ctrl)) + cmd |=PCI_EXP_SLTCTL_CCIE ; mask = (PCI_EXP_SLTCTL_PDCE | PCI_EXP_SLTCTL_ABPE | PCI_EXP_SLTCTL_PFDE |Signature · 7 lines
2.35.1 _______________________________________________ linux-arm-kernel mailing list [email protected] http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
PATCH v2 2/10 PCI: aardvark: Add support for DLLSC and hotplug interrupt
In reply to Marek BehúnFrom: Pali Rohár <[email protected]>
Add support for Data Link Layer State Change in the emulated slot registers and hotplug interrupt via the emulated root bridge.
DLLSC is needed by the pciehp driver, which handles hotplug, but also link state change events. AFAIK no Aardvark devices support hotplug, but link state change events are required for graceful driver unbinding in case of a link down event.
So with this change we achieve graceful driver unbind for example when WiFi card PCIe link goes down (we've seen this with ath10k and mt76 WiFi cards). Before the WiFi driver started spitting out errors, or even taking the whole system down.
Link down state change can be implemented because Aardvark supports Link Down event interrupt.
After the link goes down, it can come up again (if the WiFi card can recover or if reset pin is used to reset the card). Because of this we need to be able to recognize link up event. Since AFAIK Aardvark does not have interrupt for link up event, the best thing we can do is simulate it - whenever we read the link state and find it is up, and have cached value saying it is down, we trigger the link up event. We read link state in the advk_pcie_link_up() function, which is called for example whenever the configuration space is read (i.e. when writing 1 to /sys/bus/pci/rescan). We add the triggering of Hot-Plug Interrupt from this function. Although not ideal, it is better than nothing.
Since advk_pcie_link_up() is not called from an interrupt handler, we cannot call generic_handle_domain_irq() from it directly. So instead we schedule the triggering via an IRQSAFE timer as soon as possible:
at jiffies + 1. This ensures that generic_handle_domain_irq() is called from within a safe context. (Note that the timer is not a periodic timer - we do not call the handler every jiffy. We just schedule the calling once, at the next jiffy.)
(We haven't been able to find any documentation for a Link Up
interrupt on Aardvark, but it is possible there is one, in some undocumented register. If we manage to find this information, this can be rewritten.)
---
Changes since batch 6 v1:
- more explanation in commit message
Changes since batch 5:
- changed commit message (add paragraph about why the change is needed)
- select hotplug and pcieportbus in Kconfig
--- drivers/pci/controller/Kconfig | 3 + drivers/pci/controller/pci-aardvark.c | 101 ++++++++++++++++++++++++-- 2 files changed, 99 insertions(+), 5 deletions(-)
drivers/pci/controller/Kconfig +3 -0
@@ -21,6 +21,9 @@ config PCI_AARDVARK depends on OF depends on PCI_MSI_IRQ_DOMAIN select PCI_BRIDGE_EMUL + select PCIEPORTBUS + select HOTPLUG_PCI + select HOTPLUG_PCI_PCIE help Add support for Aardvark 64bit PCIe Host Controller. This controller is part of the South Bridge of the Marvel Armada
drivers/pci/controller/pci-aardvark.c +96 -5
191 lines not on this page · raw message
Signature · 1 line
2.35.1
PATCH v2 3/10 PCI: aardvark: Send Set_Slot_Power_Limit message
In reply to Marek BehúnFrom: Pali Rohár <[email protected]>
Emulate Slot PowerLimit Scale and Value bits in the Slot Capabilities register of the emulated bridge and if slot power limit value is defined, send that Set_Slot_Power_Limit message via Message Generation Control Register in Link Up handler on link up event.
Slot power limit value is read from device-tree property 'slot-power-limit-milliwatt'. If this property is not specified, we treat it as "Slot Capabilities register has not yet been initialized".
According to PCIe Base specification 3.0, when transitioning from a non-DL_Up Status to a DL_Up Status, the Port must initiate the transmission of a Set_Slot_Power_Limit Message to the other component on the Link to convey the value programmed in the Slot Power Limit Scale and Value fields of the Slot Capabilities register. This transmission is optional if the Slot Capabilities register has not yet been initialized.
--- drivers/pci/controller/pci-aardvark.c | 51 ++++++++++++++++++++++++--- 1 file changed, 47 insertions(+), 4 deletions(-)
drivers/pci/controller/pci-aardvark.c +47 -4
@@ -213,6 +213,11 @@ enum { };#define VENDOR_ID_REG (LMI_BASE_ADDR + 0x44) +#define PME_MSG_GEN_CTRL (LMI_BASE_ADDR + 0x220) +#define SEND_SET_SLOT_POWER_LIMIT BIT(13) +#define SEND_PME_TURN_OFF BIT(14) +#define SLOT_POWER_LIMIT_DATA_SHIFT 16 +#define SLOT_POWER_LIMIT_DATA_MASK GENMASK(25, 16)/* PCIe core controller registers */ #define CTRL_CORE_BASE_ADDR 0x18000
@@ -285,6 +290,8 @@ struct advk_pcie {raw_spinlock_t msi_irq_lock;DECLARE_BITMAP (msi_used,MSI_IRQ_NUM );struct mutex msi_used_lock; +u8 slot_power_limit_value; +u8 slot_power_limit_scale;int link_gen;bool link_was_up;struct timer_list link_irq_timer;
@@ -317,8 +324,9 @@ static inline bool advk_pcie_link_up(struct advk_pcie *pcie) {/* check if LTSSM is in normal operation - some L* state */ u8 ltssm_state =advk_pcie_ltssm_state (pcie); +u16 slotsta, slotctl; +u32 slotpwr, val;bool link_is_up; -u16 slotsta; link_is_up = ltssm_state >=LTSSM_L0 && ltssm_state <LTSSM_DISABLED ;
@@ -332,6 +340,27 @@ static inline bool advk_pcie_link_up(struct advk_pcie *pcie) pcie->bridge.pcie_conf.slotsta =cpu_to_le16 (slotsta);mod_timer (&pcie->link_irq_timer, jiffies +1 ); + +/* +* According to PCIe Base specification 3.0, when transitioning +* from a non-DL_Up Status to a DL_Up Status, the Port must +* initiate the transmission of a Set_Slot_Power_Limit Message +* to the other component on the Link to convey the value +* programmed in the Slot Power Limit Scale and Value fields of +* the Slot Capabilities register. This transmission is optional +* if the Slot Capabilities register has not yet been +* initialized. +*/ + slotctl =le16_to_cpu (pcie->bridge.pcie_conf.slotctl); + slotpwr =FIELD_GET (PCI_EXP_SLTCAP_SPLV |PCI_EXP_SLTCAP_SPLS , +le32_to_cpu (pcie->bridge.pcie_conf.slotcap)); +if (!(slotctl &PCI_EXP_SLTCTL_ASPL_DISABLE ) && slotpwr) { + val =advk_readl (pcie,PME_MSG_GEN_CTRL ); + val &= ~SLOT_POWER_LIMIT_DATA_MASK ; + val |= slotpwr <<SLOT_POWER_LIMIT_DATA_SHIFT ; + val |=SEND_SET_SLOT_POWER_LIMIT ; +advk_writel (pcie, val,PME_MSG_GEN_CTRL ); + } }return link_is_up;
@@ -944,8 +973,9 @@ advk_pci_bridge_emul_pcie_conf_write(struct pci_bridge_emul *bridge,case PCI_EXP_SLTCTL : {u16 slotctl =le16_to_cpu (bridge->pcie_conf.slotctl); -/* Only emulation of HPIE and DLLSCE bits is provided */ - slotctl &=PCI_EXP_SLTCTL_HPIE |PCI_EXP_SLTCTL_DLLSCE ; +/* Only emulation of HPIE, DLLSCE and ASPLD bits is provided */ + slotctl &=PCI_EXP_SLTCTL_HPIE |PCI_EXP_SLTCTL_DLLSCE | +PCI_EXP_SLTCTL_ASPL_DISABLE ; bridge->pcie_conf.slotctl =cpu_to_le16 (slotctl);break ; }
@@ -1109,9 +1139,13 @@ static int advk_sw_pci_bridge_init(struct advk_pcie *pcie)* Set physical slot number to 1 since there is only one port and zero * value is reserved for ports within the same silicon as Root Port * which is not our case. +* +* Set slot power limit. */ slotcap =PCI_EXP_SLTCAP_NCCS |PCI_EXP_SLTCAP_HPC | -FIELD_PREP (PCI_EXP_SLTCAP_PSN ,1 ); +FIELD_PREP (PCI_EXP_SLTCAP_PSN ,1 ) | +FIELD_PREP (PCI_EXP_SLTCAP_SPLV , pcie->slot_power_limit_value) | +FIELD_PREP (PCI_EXP_SLTCAP_SPLS , pcie->slot_power_limit_scale); bridge->pcie_conf.slotcap =cpu_to_le32 (slotcap); bridge->pcie_conf.slotsta =cpu_to_le16 (PCI_EXP_SLTSTA_PDS );
@@ -1837,6 +1871,7 @@ static int advk_pcie_probe(struct platform_device *pdev)struct advk_pcie *pcie;struct pci_host_bridge *bridge;struct resource_entry *entry; +u32 slot_power_limit;int ret, irq; bridge =devm_pci_alloc_host_bridge (dev,sizeof (struct advk_pcie ));
@@ -1957,6 +1992,14 @@ static int advk_pcie_probe(struct platform_device *pdev)else pcie->link_gen = ret; + slot_power_limit =of_pci_get_slot_power_limit (dev->of_node, + &pcie->slot_power_limit_value, + &pcie->slot_power_limit_scale); +if (slot_power_limit) +dev_info (dev,"Slot Power Limit: %u.%uW\n" , + slot_power_limit /1000 , + (slot_power_limit /100 ) %10 ); + ret =advk_pcie_setup_phy (pcie);if (ret)return ret;
Signature · 1 line
2.35.1
PATCH v2 4/10 arm64: dts: armada-3720-turris-mox: Define slot-power-limit-milliwatt for PCIe
In reply to Marek BehúnFrom: Pali Rohár <[email protected]>
PCIe Slot Power Limit on Turris Mox is 10W.
--- arch/arm64/boot/dts/marvell/armada-3720-turris-mox.dts | 1 + 1 file changed, 1 insertion(+)
arch/arm64/boot/dts/marvell/armada-3720-turris-mox.dts +1 -0
@@ -136,6 +136,7 @@ &pcie0 { pinctrl-0 = <&pcie_reset_pins &pcie_clkreq_pins>; status = "okay"; reset-gpios = <&gpiosb 3 GPIO_ACTIVE_LOW>; + slot-power-limit-milliwatt = <10000>; /* * U-Boot port for Turris Mox has a bug which always expects that "ranges" DT property * contains exactly 2 ranges with 3 (child) address cells, 2 (parent) address cells and
Signature · 1 line
2.35.1
Gregory CLEMENT
maintainerRe: [PATCH v2 04/10] arm64: dts: armada-3720-turris-mox: Define slot-power-limit-milliwatt for PCIe
Quoted 6 lines · Marek Behún
From: Pali Rohár <[email protected]>
PCIe Slot Power Limit on Turris Mox is 10W.
Signed-off-by Pali Rohár <[email protected]>Signed-off-by Marek Behún <[email protected]>
Applied on mvebu/dt64
Thanks,
Gregory
Quoted 19 lines
--- arch/arm64/boot/dts/marvell/armada-3720-turris-mox.dts | 1 + 1 file changed, 1 insertion(+)arch/arm64/boot/dts/marvell/armada-3720-turris-mox.dts +1
-0@@ -136,6 +136,7 @@ &pcie0 { pinctrl-0 = <&pcie_reset_pins &pcie_clkreq_pins>; status = "okay"; reset-gpios = <&gpiosb 3 GPIO_ACTIVE_LOW>; + slot-power-limit-milliwatt = <10000>; /* * U-Boot port for Turris Mox has a bug which always expects that "ranges" DT property * contains exactly 2 ranges with 3 (child) address cells, 2 (parent) address cells andSignature · 1 line
2.35.1
Signature · 3 lines
Gregory Clement, Bootlin Embedded Linux and Kernel engineering http://bootlin.com
PATCH v2 5/10 PCI: aardvark: Add clock support
In reply to Marek BehúnFrom: Miquel Raynal <[email protected]>
The IP relies on a gated clock. When we will add S2RAM support, this clock will need to be resumed before any PCIe registers are accessed. Add support for this clock.
--- drivers/pci/controller/pci-aardvark.c | 32 +++++++++++++++++++++++++++ 1 file changed, 32 insertions(+)
drivers/pci/controller/pci-aardvark.c +32 -0
@@ -9,6 +9,7 @@*/ #include <linux/bitfield.h> +#include <linux/clk.h> #include <linux/delay.h> #include <linux/gpio/consumer.h> #include <linux/interrupt.h>
@@ -297,6 +298,7 @@ struct advk_pcie {struct timer_list link_irq_timer;struct pci_bridge_emul bridge;struct gpio_desc *reset_gpio; +struct clk *clk;struct phy *phy; };
@@ -1809,6 +1811,29 @@ static int advk_pcie_map_irq(const struct pci_dev *dev, u8 slot, u8 pin)return of_irq_parse_and_map_pci (dev, slot, pin); } +static int advk_pcie_setup_clk (struct advk_pcie *pcie) +{ +struct device *dev = &pcie->pdev->dev; +int ret; + + pcie->clk =devm_clk_get (dev,NULL ); +if (IS_ERR (pcie->clk) && (PTR_ERR (pcie->clk) == -EPROBE_DEFER )) +return PTR_ERR (pcie->clk); + +/* Old bindings miss the clock handle */ +if (IS_ERR (pcie->clk)) { +dev_warn (dev,"Clock unavailable (%ld)\n" ,PTR_ERR (pcie->clk)); + pcie->clk =NULL ; +return 0 ; + } + + ret =clk_prepare_enable (pcie->clk); +if (ret) +dev_err (dev,"Clock initialization failed (%d)\n" , ret); + +return ret; +} +static void advk_pcie_disable_phy (struct advk_pcie *pcie) {phy_power_off (pcie->phy);
@@ -2000,6 +2025,10 @@ static int advk_pcie_probe(struct platform_device *pdev) slot_power_limit /1000 , (slot_power_limit / 100) % 10); + ret =advk_pcie_setup_clk (pcie); +if (ret) +return ret; + ret =advk_pcie_setup_phy (pcie);if (ret)return ret;
@@ -2122,6 +2151,9 @@ static int advk_pcie_remove(struct platform_device *pdev)/* Disable phy */ advk_pcie_disable_phy (pcie); +/* Disable clock */ +clk_disable_unprepare (pcie->clk); +return 0 ; }
Signature · 1 line
2.35.1
PATCH v2 6/10 PCI: aardvark: Add suspend to RAM support
In reply to Marek BehúnFrom: Miquel Raynal <[email protected]>
Add suspend and resume callbacks. We need to use the _noirq variants via
NOIRQ_SYSTEM_SLEEP_PM_OPS(),
because these are called when IRQ handlers are disabled, as explained in Documentation/driver-api/pm/devices.rst. This ensures that the PCIe controller's IRQ handler is not called during suspend/resume handler, as this could cause races, as explained in the above mentioned file, section Entering System Suspend.
---
Changes since batch 6 v1:
- more explicit commit message
Changes since batch 5:
- clarified commit message
- changed to new macro NOIRQ_SYSTEM_SLEEP_PM_OPS, as was done for many PCI controller drivers with commit 19b7858c3357 ("PCI: Convert to new *_PM_OPS macros")
--- drivers/pci/controller/pci-aardvark.c | 34 +++++++++++++++++++++++++++ 1 file changed, 34 insertions(+)
drivers/pci/controller/pci-aardvark.c +34 -0
@@ -1890,6 +1890,39 @@ static int advk_pcie_setup_phy(struct advk_pcie *pcie)return ret; } +static int advk_pcie_suspend (struct device *dev) +{ +struct advk_pcie *pcie =dev_get_drvdata (dev); + +advk_pcie_disable_phy (pcie); + +clk_disable_unprepare (pcie->clk); + +return 0 ; +} + +static int advk_pcie_resume (struct device *dev) +{ +struct advk_pcie *pcie =dev_get_drvdata (dev); +int ret; + + ret =clk_prepare_enable (pcie->clk); +if (ret) +return ret; + + ret =advk_pcie_enable_phy (pcie); +if (ret) +return ret; + +advk_pcie_setup_hw (pcie); + +return 0 ; +} + +static const struct dev_pm_ops advk_pcie_dev_pm_ops = { +NOIRQ_SYSTEM_SLEEP_PM_OPS (advk_pcie_suspend, advk_pcie_resume) +}; +static int advk_pcie_probe (struct platform_device *pdev) {struct device *dev = &pdev->dev;
@@ -2167,6 +2200,7 @@ static struct platform_driver advk_pcie_driver = { .driver = { .name = "advk-pcie", .of_match_table = advk_pcie_of_match_table, + .pm = &advk_pcie_dev_pm_ops, }, .probe = advk_pcie_probe, .remove = advk_pcie_remove,
Signature · 1 line
2.35.1
PATCH v2 7/10 PCI: aardvark: Replace custom PCIE_CORE_ERR_CAPCTL_* macros by linux/pci_regs.h macros
In reply to Marek BehúnFrom: Pali Rohár <[email protected]>
Kernel already has these macros defined under different names.
--- drivers/pci/controller/pci-aardvark.c | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-)
drivers/pci/controller/pci-aardvark.c +4 -10
@@ -37,11 +37,7 @@#define PCIE_CORE_DEV_REV_REG 0x8#define PCIE_CORE_PCIEXP_CAP 0xc0#define PCIE_CORE_PCIERR_CAP 0x100 -#define PCIE_CORE_ERR_CAPCTL_REG 0x118 -#define PCIE_CORE_ERR_CAPCTL_ECRC_CHK_TX BIT(5) -#define PCIE_CORE_ERR_CAPCTL_ECRC_CHK_TX_EN BIT(6) -#define PCIE_CORE_ERR_CAPCTL_ECRC_CHCK BIT(7) -#define PCIE_CORE_ERR_CAPCTL_ECRC_CHCK_RCV BIT(8) +/* PIO registers base address and register offsets */ #define PIO_BASE_ADDR 0x4000#define PIO_CTRL (PIO_BASE_ADDR + 0x0)
@@ -589,11 +585,9 @@ static void advk_pcie_setup_hw(struct advk_pcie *pcie)advk_writel (pcie, reg,PCIE_CORE_CMD_STATUS_REG );/* Set Advanced Error Capabilities and Control PF0 register */ - reg =PCIE_CORE_ERR_CAPCTL_ECRC_CHK_TX | -PCIE_CORE_ERR_CAPCTL_ECRC_CHK_TX_EN | -PCIE_CORE_ERR_CAPCTL_ECRC_CHCK | -PCIE_CORE_ERR_CAPCTL_ECRC_CHCK_RCV ; -advk_writel (pcie, reg,PCIE_CORE_ERR_CAPCTL_REG ); + reg =PCI_ERR_CAP_ECRC_GENC |PCI_ERR_CAP_ECRC_GENE | +PCI_ERR_CAP_ECRC_CHKC |PCI_ERR_CAP_ECRC_CHKE ; +advk_writel (pcie, reg,PCIE_CORE_PCIERR_CAP +PCI_ERR_CAP );/* Set PCIe Device Control register */ reg =advk_readl (pcie,PCIE_CORE_PCIEXP_CAP +PCI_EXP_DEVCTL );
Signature · 1 line
2.35.1
PATCH v2 8/10 PCI: aardvark: Don't write read-only bits explicitly in PCI_ERR_CAP register
In reply to Marek BehúnThe bits PCI_ERR_CAP_ECRC_GENC and PCI_ERR_CAP_ECRC_CHKC are read only, reporting the capability of ECRC. Don't write them explicitly, instead read the register (where they are set), and add the bits that enable these features.
--- drivers/pci/controller/pci-aardvark.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/pci/controller/pci-aardvark.c +3 -3
@@ -584,9 +584,9 @@ static void advk_pcie_setup_hw(struct advk_pcie *pcie) reg &= ~(PCI_COMMAND_IO |PCI_COMMAND_MEMORY |PCI_COMMAND_MASTER );advk_writel (pcie, reg,PCIE_CORE_CMD_STATUS_REG ); -/* Set Advanced Error Capabilities and Control PF0 register */ - reg =PCI_ERR_CAP_ECRC_GENC |PCI_ERR_CAP_ECRC_GENE | -PCI_ERR_CAP_ECRC_CHKC |PCI_ERR_CAP_ECRC_CHKE ; +/* Enable generation and checking of ECRC on Root Bridge */ + reg =advk_readl (pcie,PCIE_CORE_PCIERR_CAP +PCI_ERR_CAP ); + reg |=PCI_ERR_CAP_ECRC_GENE |PCI_ERR_CAP_ECRC_CHKE ;advk_writel (pcie, reg,PCIE_CORE_PCIERR_CAP +PCI_ERR_CAP );/* Set PCIe Device Control register */
Signature · 1 line
2.35.1
PATCH v2 9/10 PCI: aardvark: Explicitly disable Marvell strict ordering
In reply to Marek BehúnInstead of implicitly disabling BIT(5) (STRICT_ORDER_ENABLE bit) of the CORE_CTRL2 by writing PCIE_CORE_CTRL2_RESERVED | PCIE_CORE_CTRL2_TD_ENABLE to it, disable it explicitly, with read-modify-write.
--- drivers/pci/controller/pci-aardvark.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/pci/controller/pci-aardvark.c +2 -2
@@ -600,8 +600,8 @@ static void advk_pcie_setup_hw(struct advk_pcie *pcie)advk_writel (pcie, reg,PCIE_CORE_PCIEXP_CAP +PCI_EXP_DEVCTL );/* Program PCIe Control 2 to disable strict ordering */ - reg =PCIE_CORE_CTRL2_RESERVED | -PCIE_CORE_CTRL2_TD_ENABLE ; + reg =advk_readl (pcie,PCIE_CORE_CTRL2_REG ); + reg &= ~PCIE_CORE_CTRL2_STRICT_ORDER_ENABLE ;advk_writel (pcie, reg,PCIE_CORE_CTRL2_REG );/* Set lane X1 */
Signature · 1 line
2.35.1
PATCH v2 10/10 PCI: aardvark: Cleanup some register macros
In reply to Marek BehúnFrom: Pali Rohár <[email protected]>
Define SPEED_GEN_* macros with correct PCIE_GEN_SEL_SHIFT.
Simplify macro for setting root complex mode (use BIT instead of MSK + SHIFT).
Rename PCIE_MSG_PM_PME_MASK to PCIE_ISR0_MSG_PM_PME to match existing naming convention, rename PCIE_ISR0_MSI_INT_PENDING to PCIE_ISR0_MSI_INT as it is used for both interrupt mask and pending bit.
--- drivers/pci/controller/pci-aardvark.c | 28 +++++++++++++-------------- 1 file changed, 13 insertions(+), 15 deletions(-)
drivers/pci/controller/pci-aardvark.c +13 -15
@@ -66,11 +66,10 @@#define PCIE_CORE_CTRL0_REG (CONTROL_BASE_ADDR + 0x0)#define PCIE_GEN_SEL_MSK 0x3#define PCIE_GEN_SEL_SHIFT 0x0 -#define SPEED_GEN_1 0 -#define SPEED_GEN_2 1 -#define SPEED_GEN_3 2 -#define IS_RC_MSK 1 -#define IS_RC_SHIFT 2 +#define SPEED_GEN_1 (0 << PCIE_GEN_SEL_SHIFT) +#define SPEED_GEN_2 (1 << PCIE_GEN_SEL_SHIFT) +#define SPEED_GEN_3 (2 << PCIE_GEN_SEL_SHIFT) +#define IS_RC BIT(2)#define LANE_CNT_MSK 0x18#define LANE_CNT_SHIFT 0x3#define LANE_COUNT_1 (0 << LANE_CNT_SHIFT)
@@ -95,16 +94,16 @@#define PCIE_CORE_REF_CLK_RX_ENABLE BIT(2)#define PCIE_MSG_LOG_REG (CONTROL_BASE_ADDR + 0x30)#define PCIE_ISR0_REG (CONTROL_BASE_ADDR + 0x40) -#define PCIE_MSG_PM_PME_MASK BIT(7)#define PCIE_ISR0_MASK_REG (CONTROL_BASE_ADDR + 0x44) -#define PCIE_ISR0_MSI_INT_PENDING BIT(24)#define PCIE_ISR0_LINK_DOWN BIT(1) +#define PCIE_ISR0_MSG_PM_PME BIT(7)#define PCIE_ISR0_CORR_ERR BIT(11)#define PCIE_ISR0_NFAT_ERR BIT(12)#define PCIE_ISR0_FAT_ERR BIT(13)#define PCIE_ISR0_ERR_MASK GENMASK(13, 11)#define PCIE_ISR0_INTX_ASSERT (val) BIT(16 + (val))#define PCIE_ISR0_INTX_DEASSERT (val) BIT(20 + (val)) +#define PCIE_ISR0_MSI_INT BIT(24)#define PCIE_ISR0_ALL_MASK GENMASK(31, 0)#define PCIE_ISR1_REG (CONTROL_BASE_ADDR + 0x48)#define PCIE_ISR1_MASK_REG (CONTROL_BASE_ADDR + 0x4C)
@@ -546,7 +545,7 @@ static void advk_pcie_setup_hw(struct advk_pcie *pcie)/* Set PCI global control register to RC mode */ reg =advk_readl (pcie,PCIE_CORE_CTRL0_REG ); - reg |= (IS_RC_MSK <<IS_RC_SHIFT ); + reg |=IS_RC ;advk_writel (pcie, reg,PCIE_CORE_CTRL0_REG );/*
@@ -633,7 +632,7 @@ static void advk_pcie_setup_hw(struct advk_pcie *pcie)/* Unmask summary MSI interrupt */ reg =advk_readl (pcie,PCIE_ISR0_MASK_REG ); - reg &= ~PCIE_ISR0_MSI_INT_PENDING ; + reg &= ~PCIE_ISR0_MSI_INT ;advk_writel (pcie, reg,PCIE_ISR0_MASK_REG );/* Unmask Link Down interrupt */
@@ -643,7 +642,7 @@ static void advk_pcie_setup_hw(struct advk_pcie *pcie)/* Unmask PME interrupt for processing of PME requester */ reg =advk_readl (pcie,PCIE_ISR0_MASK_REG ); - reg &= ~PCIE_MSG_PM_PME_MASK ; + reg &= ~PCIE_ISR0_MSG_PM_PME ;advk_writel (pcie, reg,PCIE_ISR0_MASK_REG );/* Enable summary interrupt for GIC SPI source */
@@ -1661,7 +1660,7 @@ static void advk_pcie_handle_pme(struct advk_pcie *pcie) {u32 requester =advk_readl (pcie,PCIE_MSG_LOG_REG ) >>16 ; -advk_writel (pcie,PCIE_MSG_PM_PME_MASK ,PCIE_ISR0_REG ); +advk_writel (pcie,PCIE_ISR0_MSG_PM_PME ,PCIE_ISR0_REG );/* * PCIE_MSG_LOG_REG contains the last inbound message, so store
@@ -1700,8 +1699,7 @@ static void advk_pcie_handle_msi(struct advk_pcie *pcie)dev_err_ratelimited (&pcie->pdev->dev,"unexpected MSI 0x%02x\n" , msi_idx); } -advk_writel (pcie,PCIE_ISR0_MSI_INT_PENDING , -PCIE_ISR0_REG ); +advk_writel (pcie,PCIE_ISR0_MSI_INT ,PCIE_ISR0_REG ); }static void advk_pcie_handle_int (struct advk_pcie *pcie)
@@ -1720,7 +1718,7 @@ static void advk_pcie_handle_int(struct advk_pcie *pcie) isr1_status = isr1_val & ((~isr1_mask) &PCIE_ISR1_ALL_MASK );/* Process PME interrupt as the first one to do not miss PME requester id */ -if (isr0_status &PCIE_MSG_PM_PME_MASK ) +if (isr0_status &PCIE_ISR0_MSG_PM_PME )advk_pcie_handle_pme (pcie);/* Process ERR interrupt */
@@ -1756,7 +1754,7 @@ static void advk_pcie_handle_int(struct advk_pcie *pcie) }/* Process MSI interrupts */ -if (isr0_status &PCIE_ISR0_MSI_INT_PENDING ) +if (isr0_status &PCIE_ISR0_MSI_INT )advk_pcie_handle_msi (pcie);/* Process legacy interrupts */
Signature · 1 line
2.35.1