mirror of
https://github.com/openwrt/openwrt.git
synced 2026-11-27 14:41:12 +04:00
ath79: switch to new pci drivers
This is an effort to get all of these various hacks out of ath79 and into upstream. Interestingly enough ever since the platform code removal upstream both of these drivers are unusable upstream. The plan is to remove the code upstream (as they've been doing a lot recently) and reintroduce in an acceptable form. Claude did the initial port and the rest was done on Big Pickle with input from ChatGPT. I can see various things that need to be improved for upstream, but at the very least this is usable on my Archer C7v2. Testing is needed, especially on sub QCA95xx platforms. They seem to differ quite a bit. ar7100 most likely does not work at all. I don't have the hardware and have not iterated on it. Assisted-by: LLM Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01X4fQYZAVx9sEHVTUpfBFRM Signed-off-by: Rosen Penev <rosenp@gmail.com> Link: https://github.com/openwrt/openwrt/pull/23559 Signed-off-by: Robert Marko <robimarko@gmail.com>
This commit is contained in:
1 parent
8736aff810
commit
13e5b0b98b
21 files changed
+926
-215
No files matched your search
@@ -143,7 +143,6 @@ CONFIG_NET_EGRESS=y
|
||||
CONFIG_NET_INGRESS=y
|
||||
CONFIG_NET_SELFTESTS=y
|
||||
CONFIG_NET_XGRESS=y
|
||||
CONFIG_NO_GENERIC_PCI_IOPORT_MAP=y
|
||||
CONFIG_NVMEM=y
|
||||
CONFIG_NVMEM_LAYOUTS=y
|
||||
CONFIG_NVMEM_LAYOUT_U_BOOT_ENV=y
|
||||
@@ -161,11 +160,12 @@ CONFIG_PAGE_POOL=y
|
||||
CONFIG_PAGE_SIZE_LESS_THAN_256KB=y
|
||||
CONFIG_PAGE_SIZE_LESS_THAN_64KB=y
|
||||
CONFIG_PCI=y
|
||||
CONFIG_PCI_AR71XX=y
|
||||
CONFIG_PCI_AR724X=y
|
||||
CONFIG_PCIE_ATH79=y
|
||||
CONFIG_PCI_ATH79=y
|
||||
CONFIG_PCI_DISABLE_COMMON_QUIRKS=y
|
||||
CONFIG_PCI_DOMAINS=y
|
||||
CONFIG_PCI_DRIVERS_LEGACY=y
|
||||
CONFIG_PCI_DOMAINS_GENERIC=y
|
||||
CONFIG_PCI_DRIVERS_GENERIC=y
|
||||
CONFIG_PERF_USE_VMALLOC=y
|
||||
CONFIG_PGTABLE_LEVELS=2
|
||||
CONFIG_PHYLIB=y
|
||||
|
||||
@@ -117,11 +117,9 @@
|
||||
compatible = "qca,ar7100-pci";
|
||||
#address-cells = <3>;
|
||||
#size-cells = <2>;
|
||||
bus-range = <0x0 0x0>;
|
||||
reg = <0x17010000 0x100>;
|
||||
reg-names = "cfg_base";
|
||||
ranges = <0x2000000 0 0x10000000 0x10000000 0 0x07000000 /* pci memory */
|
||||
0x1000000 0 0x00000000 0x0000000 0 0x000001>; /* io space */
|
||||
ranges = <0x2000000 0 0x10000000 0x10000000 0 0x07000000>; /* pci memory */
|
||||
|
||||
device_type = "pci";
|
||||
|
||||
@@ -130,6 +128,7 @@
|
||||
|
||||
#interrupt-cells = <1>;
|
||||
|
||||
/* IDSEL 17-19 are wired to PCI_INT0-2 */
|
||||
interrupt-map-mask = <0xf800 0 0 0>;
|
||||
interrupt-map = <0x8800 0 0 0 &pci_intc 0
|
||||
0x9000 0 0 0 &pci_intc 1
|
||||
|
||||
@@ -123,13 +123,11 @@
|
||||
compatible = "qcom,ar7240-pci";
|
||||
#address-cells = <3>;
|
||||
#size-cells = <2>;
|
||||
bus-range = <0x0 0x0>;
|
||||
reg = <0x180c0000 0x1000>, /* CRP */
|
||||
<0x180f0000 0x100>, /* CTRL */
|
||||
<0x14000000 0x1000>; /* CFG */
|
||||
reg-names = "crp_base", "ctrl_base", "cfg_base";
|
||||
ranges = <0x2000000 0 0x10000000 0x10000000 0 0x04000000 /* pci memory */
|
||||
0x1000000 0 0x00000000 0x0000000 0 0x000001>; /* io space */
|
||||
ranges = <0x2000000 0 0x10000000 0x10000000 0 0x04000000>; /* pci memory */
|
||||
interrupt-parent = <&cpuintc>;
|
||||
interrupts = <2>;
|
||||
|
||||
@@ -141,8 +139,6 @@
|
||||
interrupt-controller;
|
||||
#interrupt-cells = <1>;
|
||||
|
||||
interrupt-map-mask = <0 0 0 1>;
|
||||
interrupt-map = <0 0 0 0 &pcie 0>;
|
||||
status = "disabled";
|
||||
};
|
||||
};
|
||||
|
||||
@@ -36,13 +36,11 @@
|
||||
compatible = "qcom,ar9340-pci", "qcom,ar7240-pci";
|
||||
#address-cells = <3>;
|
||||
#size-cells = <2>;
|
||||
bus-range = <0x0 0x0>;
|
||||
reg = <0x180c0000 0x1000>, /* CRP */
|
||||
<0x180f0000 0x100>, /* CTRL */
|
||||
<0x14000000 0x1000>; /* CFG */
|
||||
reg-names = "crp_base", "ctrl_base", "cfg_base";
|
||||
ranges = <0x2000000 0 0x10000000 0x10000000 0 0x04000000 /* pci memory */
|
||||
0x1000000 0 0x00000000 0x0000000 0 0x000001>; /* io space */
|
||||
ranges = <0x2000000 0 0x10000000 0x10000000 0 0x04000000>; /* pci memory */
|
||||
interrupt-parent = <&intc2>;
|
||||
interrupts = <1>;
|
||||
|
||||
@@ -54,9 +52,6 @@
|
||||
interrupt-controller;
|
||||
#interrupt-cells = <1>;
|
||||
|
||||
interrupt-map-mask = <0 0 0 1>;
|
||||
interrupt-map = <0 0 0 0 &pcie 0>;
|
||||
|
||||
status = "disabled";
|
||||
};
|
||||
};
|
||||
|
||||
@@ -154,13 +154,11 @@
|
||||
compatible = "qcom,ar7240-pci";
|
||||
#address-cells = <3>;
|
||||
#size-cells = <2>;
|
||||
bus-range = <0x0 0x0>;
|
||||
reg = <0x180c0000 0x1000>, /* CRP */
|
||||
<0x180f0000 0x100>, /* CTRL */
|
||||
<0x14000000 0x1000>; /* CFG */
|
||||
reg-names = "crp_base", "ctrl_base", "cfg_base";
|
||||
ranges = <0x2000000 0 0x10000000 0x10000000 0 0x04000000 /* pci memory */
|
||||
0x1000000 0 0x00000000 0x0000000 0 0x000001>; /* io space */
|
||||
ranges = <0x2000000 0 0x10000000 0x10000000 0 0x04000000>; /* pci memory */
|
||||
interrupt-parent = <&intc2>;
|
||||
interrupts = <1>;
|
||||
|
||||
@@ -172,8 +170,6 @@
|
||||
interrupt-controller;
|
||||
#interrupt-cells = <1>;
|
||||
|
||||
interrupt-map-mask = <0 0 0 1>;
|
||||
interrupt-map = <0 0 0 0 &pcie0 0>;
|
||||
status = "disabled";
|
||||
};
|
||||
|
||||
|
||||
@@ -206,13 +206,11 @@
|
||||
compatible = "qcom,qca9550-pci", "qcom,ar7240-pci";
|
||||
#address-cells = <3>;
|
||||
#size-cells = <2>;
|
||||
bus-range = <0x0 0x0>;
|
||||
reg = <0x180c0000 0x1000>, /* CRP */
|
||||
<0x180f0000 0x100>, /* CTRL */
|
||||
<0x14000000 0x1000>; /* CFG */
|
||||
reg-names = "crp_base", "ctrl_base", "cfg_base";
|
||||
ranges = <0x2000000 0 0x10000000 0x10000000 0 0x02000000 /* pci memory */
|
||||
0x1000000 0 0x00000000 0x0000000 0 0x000001>; /* io space */
|
||||
ranges = <0x2000000 0 0x10000000 0x10000000 0 0x02000000>; /* pci memory */
|
||||
interrupt-parent = <&intc2>;
|
||||
interrupts = <1>;
|
||||
|
||||
@@ -224,8 +222,6 @@
|
||||
interrupt-controller;
|
||||
#interrupt-cells = <1>;
|
||||
|
||||
interrupt-map-mask = <0 0 0 1>;
|
||||
interrupt-map = <0 0 0 0 &pcie0 0>;
|
||||
status = "disabled";
|
||||
};
|
||||
|
||||
@@ -243,13 +239,11 @@
|
||||
compatible = "qcom,qca9550-pci", "qcom,ar7240-pci";
|
||||
#address-cells = <3>;
|
||||
#size-cells = <2>;
|
||||
bus-range = <0x0 0x0>;
|
||||
reg = <0x18250000 0x1000>, /* CRP */
|
||||
<0x18280000 0x100>, /* CTRL */
|
||||
<0x16000000 0x1000>; /* CFG */
|
||||
reg-names = "crp_base", "ctrl_base", "cfg_base";
|
||||
ranges = <0x2000000 0 0x12000000 0x12000000 0 0x02000000 /* pci memory */
|
||||
0x1000000 0 0x00000000 0x0000001 0 0x000001>; /* io space */
|
||||
ranges = <0x2000000 0 0x12000000 0x12000000 0 0x02000000>; /* pci memory */
|
||||
interrupt-parent = <&intc3>;
|
||||
interrupts = <0>;
|
||||
|
||||
@@ -261,8 +255,6 @@
|
||||
interrupt-controller;
|
||||
#interrupt-cells = <1>;
|
||||
|
||||
interrupt-map-mask = <0 0 0 1>;
|
||||
interrupt-map = <0 0 0 0 &pcie1 0>;
|
||||
status = "disabled";
|
||||
};
|
||||
|
||||
|
||||
@@ -161,13 +161,11 @@
|
||||
compatible = "qcom,ar7240-pci";
|
||||
#address-cells = <3>;
|
||||
#size-cells = <2>;
|
||||
bus-range = <0x0 0x0>;
|
||||
reg = <0x18250000 0x1000>, /* CRP */
|
||||
<0x18280000 0x100>, /* CTRL */
|
||||
<0x16000000 0x1000>; /* CFG */
|
||||
reg-names = "crp_base", "ctrl_base", "cfg_base";
|
||||
ranges = <0x2000000 0 0x12000000 0x12000000 0 0x02000000 /* pci memory */
|
||||
0x1000000 0 0x00000000 0x0000000 0 0x000001>; /* io space */
|
||||
ranges = <0x2000000 0 0x12000000 0x12000000 0 0x02000000>; /* pci memory */
|
||||
interrupt-parent = <&intc3>;
|
||||
interrupts = <0>;
|
||||
|
||||
@@ -179,8 +177,6 @@
|
||||
interrupt-controller;
|
||||
#interrupt-cells = <1>;
|
||||
|
||||
interrupt-map-mask = <0 0 0 1>;
|
||||
interrupt-map = <0 0 0 0 &pcie 0>;
|
||||
status = "disabled";
|
||||
};
|
||||
|
||||
|
||||
@@ -0,0 +1,298 @@
|
||||
// SPDX-License-Identifier: GPL-2.0-only
|
||||
/*
|
||||
* Atheros AR71xx PCI host controller driver
|
||||
*
|
||||
* Copyright (C) 2008-2011 Gabor Juhos <juhosg@openwrt.org>
|
||||
* Copyright (C) 2008 Imre Kaloz <kaloz@openwrt.org>
|
||||
*
|
||||
* Parts of this file are based on Atheros' 2.6.15 BSP
|
||||
*/
|
||||
|
||||
#include <linux/bitops.h>
|
||||
#include <linux/delay.h>
|
||||
#include <linux/init.h>
|
||||
#include <linux/module.h>
|
||||
#include <linux/of.h>
|
||||
#include <linux/pci.h>
|
||||
#include <linux/pci_regs.h>
|
||||
#include <linux/platform_device.h>
|
||||
#include <linux/resource.h>
|
||||
#include <linux/types.h>
|
||||
|
||||
#include <asm/addrspace.h>
|
||||
#include <asm/mach-ath79/ar71xx_regs.h>
|
||||
#include <asm/mach-ath79/ath79.h>
|
||||
|
||||
#define AR71XX_PCI_REG_CRP_AD_CBE 0x00
|
||||
#define AR71XX_PCI_REG_CRP_WRDATA 0x04
|
||||
#define AR71XX_PCI_REG_CRP_RDDATA 0x08
|
||||
#define AR71XX_PCI_REG_CFG_AD 0x0c
|
||||
#define AR71XX_PCI_REG_CFG_CBE 0x10
|
||||
#define AR71XX_PCI_REG_CFG_WRDATA 0x14
|
||||
#define AR71XX_PCI_REG_CFG_RDDATA 0x18
|
||||
#define AR71XX_PCI_REG_PCI_ERR 0x1c
|
||||
#define AR71XX_PCI_REG_PCI_ERR_ADDR 0x20
|
||||
#define AR71XX_PCI_REG_AHB_ERR 0x24
|
||||
#define AR71XX_PCI_REG_AHB_ERR_ADDR 0x28
|
||||
|
||||
#define AR71XX_PCI_CRP_CMD_WRITE 0x00010000
|
||||
#define AR71XX_PCI_CRP_CMD_READ 0x00000000
|
||||
#define AR71XX_PCI_CFG_CMD_READ 0x0000000a
|
||||
#define AR71XX_PCI_CFG_CMD_WRITE 0x0000000b
|
||||
|
||||
struct ar71xx_pci_controller {
|
||||
struct device *dev;
|
||||
void __iomem *cfg_base;
|
||||
};
|
||||
|
||||
/* Byte lane enable bits */
|
||||
static const u8 ar71xx_pci_ble_table[4][4] = {
|
||||
{0x0, 0xf, 0xf, 0xf},
|
||||
{0xe, 0xd, 0xb, 0x7},
|
||||
{0xc, 0xf, 0x3, 0xf},
|
||||
{0xf, 0xf, 0xf, 0xf},
|
||||
};
|
||||
|
||||
static const u32 ar71xx_pci_read_mask[8] = {
|
||||
0, 0xff, 0xffff, 0, 0xffffffff, 0, 0, 0
|
||||
};
|
||||
|
||||
static inline u32 ar71xx_pci_get_ble(int where, int size, int local)
|
||||
{
|
||||
u32 t;
|
||||
|
||||
t = ar71xx_pci_ble_table[size & 3][where & 3];
|
||||
BUG_ON(t == 0xf);
|
||||
t <<= (local) ? 20 : 4;
|
||||
|
||||
return t;
|
||||
}
|
||||
|
||||
static inline u32 ar71xx_pci_bus_addr(struct pci_bus *bus, unsigned int devfn,
|
||||
int where)
|
||||
{
|
||||
u32 ret;
|
||||
|
||||
if (!bus->number) {
|
||||
/* type 0 */
|
||||
ret = (1 << PCI_SLOT(devfn)) | (PCI_FUNC(devfn) << 8) |
|
||||
(where & ~3);
|
||||
} else {
|
||||
/* type 1 */
|
||||
ret = (bus->number << 16) | (PCI_SLOT(devfn) << 11) |
|
||||
(PCI_FUNC(devfn) << 8) | (where & ~3) | 1;
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
static int ar71xx_pci_check_error(struct ar71xx_pci_controller *apc, int quiet)
|
||||
{
|
||||
void __iomem *base = apc->cfg_base;
|
||||
u32 pci_err;
|
||||
u32 ahb_err;
|
||||
|
||||
pci_err = readl(base + AR71XX_PCI_REG_PCI_ERR) & 3;
|
||||
if (pci_err) {
|
||||
if (!quiet) {
|
||||
u32 addr;
|
||||
|
||||
addr = readl(base + AR71XX_PCI_REG_PCI_ERR_ADDR);
|
||||
pr_crit("ar71xx: %s bus error %d at addr 0x%x\n",
|
||||
"PCI", pci_err, addr);
|
||||
}
|
||||
|
||||
/* clear PCI error status */
|
||||
writel(pci_err, base + AR71XX_PCI_REG_PCI_ERR);
|
||||
}
|
||||
|
||||
ahb_err = readl(base + AR71XX_PCI_REG_AHB_ERR) & 1;
|
||||
if (ahb_err) {
|
||||
if (!quiet) {
|
||||
u32 addr;
|
||||
|
||||
addr = readl(base + AR71XX_PCI_REG_AHB_ERR_ADDR);
|
||||
pr_crit("ar71xx: %s bus error %d at addr 0x%x\n",
|
||||
"AHB", ahb_err, addr);
|
||||
}
|
||||
|
||||
/* clear AHB error status */
|
||||
writel(ahb_err, base + AR71XX_PCI_REG_AHB_ERR);
|
||||
}
|
||||
|
||||
return !!(ahb_err | pci_err);
|
||||
}
|
||||
|
||||
static inline void ar71xx_pci_local_write(struct ar71xx_pci_controller *apc,
|
||||
int where, int size, u32 value)
|
||||
{
|
||||
void __iomem *base = apc->cfg_base;
|
||||
u32 ad_cbe;
|
||||
|
||||
value = value << (8 * (where & 3));
|
||||
|
||||
ad_cbe = AR71XX_PCI_CRP_CMD_WRITE | (where & ~3);
|
||||
ad_cbe |= ar71xx_pci_get_ble(where, size, 1);
|
||||
|
||||
writel(ad_cbe, base + AR71XX_PCI_REG_CRP_AD_CBE);
|
||||
writel(value, base + AR71XX_PCI_REG_CRP_WRDATA);
|
||||
}
|
||||
|
||||
static inline int ar71xx_pci_set_cfgaddr(struct pci_bus *bus,
|
||||
unsigned int devfn,
|
||||
int where, int size, u32 cmd)
|
||||
{
|
||||
struct ar71xx_pci_controller *apc = bus->sysdata;
|
||||
void __iomem *base = apc->cfg_base;
|
||||
u32 addr;
|
||||
|
||||
addr = ar71xx_pci_bus_addr(bus, devfn, where);
|
||||
|
||||
writel(addr, base + AR71XX_PCI_REG_CFG_AD);
|
||||
writel(cmd | ar71xx_pci_get_ble(where, size, 0),
|
||||
base + AR71XX_PCI_REG_CFG_CBE);
|
||||
|
||||
return ar71xx_pci_check_error(apc, 1);
|
||||
}
|
||||
|
||||
static int ar71xx_pci_read_config(struct pci_bus *bus, unsigned int devfn,
|
||||
int where, int size, u32 *value)
|
||||
{
|
||||
struct ar71xx_pci_controller *apc = bus->sysdata;
|
||||
void __iomem *base = apc->cfg_base;
|
||||
u32 data;
|
||||
int err;
|
||||
int ret;
|
||||
|
||||
ret = PCIBIOS_SUCCESSFUL;
|
||||
data = ~0;
|
||||
|
||||
err = ar71xx_pci_set_cfgaddr(bus, devfn, where, size,
|
||||
AR71XX_PCI_CFG_CMD_READ);
|
||||
if (err)
|
||||
ret = PCIBIOS_DEVICE_NOT_FOUND;
|
||||
else
|
||||
data = readl(base + AR71XX_PCI_REG_CFG_RDDATA);
|
||||
|
||||
*value = (data >> (8 * (where & 3))) & ar71xx_pci_read_mask[size & 7];
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
static int ar71xx_pci_write_config(struct pci_bus *bus, unsigned int devfn,
|
||||
int where, int size, u32 value)
|
||||
{
|
||||
struct ar71xx_pci_controller *apc = bus->sysdata;
|
||||
void __iomem *base = apc->cfg_base;
|
||||
int err;
|
||||
int ret;
|
||||
|
||||
value = value << (8 * (where & 3));
|
||||
ret = PCIBIOS_SUCCESSFUL;
|
||||
|
||||
err = ar71xx_pci_set_cfgaddr(bus, devfn, where, size,
|
||||
AR71XX_PCI_CFG_CMD_WRITE);
|
||||
if (err)
|
||||
ret = PCIBIOS_DEVICE_NOT_FOUND;
|
||||
else
|
||||
writel(value, base + AR71XX_PCI_REG_CFG_WRDATA);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
static struct pci_ops ar71xx_pci_ops = {
|
||||
.read = ar71xx_pci_read_config,
|
||||
.write = ar71xx_pci_write_config,
|
||||
};
|
||||
|
||||
/*
|
||||
* Byte and halfword accesses to PCI memory need their address swizzled on
|
||||
* AR71xx, see asm/mach-ath79/mangle-port.h.
|
||||
*/
|
||||
static bool ar71xx_pci_enabled;
|
||||
|
||||
static inline bool ar71xx_is_pci_addr(unsigned long port)
|
||||
{
|
||||
unsigned long phys = CPHYSADDR(port);
|
||||
|
||||
return ar71xx_pci_enabled && phys >= AR71XX_PCI_MEM_BASE &&
|
||||
phys < AR71XX_PCI_MEM_BASE + AR71XX_PCI_MEM_SIZE;
|
||||
}
|
||||
|
||||
unsigned long ath79_pci_swizzle_b(unsigned long port)
|
||||
{
|
||||
return ar71xx_is_pci_addr(port) ? port ^ 3 : port;
|
||||
}
|
||||
EXPORT_SYMBOL(ath79_pci_swizzle_b);
|
||||
|
||||
unsigned long ath79_pci_swizzle_w(unsigned long port)
|
||||
{
|
||||
return ar71xx_is_pci_addr(port) ? port ^ 2 : port;
|
||||
}
|
||||
EXPORT_SYMBOL(ath79_pci_swizzle_w);
|
||||
|
||||
static void ar71xx_pci_reset(void)
|
||||
{
|
||||
ath79_device_reset_set(AR71XX_RESET_PCI_BUS | AR71XX_RESET_PCI_CORE);
|
||||
mdelay(100);
|
||||
|
||||
ath79_device_reset_clear(AR71XX_RESET_PCI_BUS | AR71XX_RESET_PCI_CORE);
|
||||
mdelay(100);
|
||||
|
||||
ath79_ddr_set_pci_windows();
|
||||
mdelay(100);
|
||||
}
|
||||
|
||||
static int ar71xx_pci_probe(struct platform_device *pdev)
|
||||
{
|
||||
struct device *dev = &pdev->dev;
|
||||
struct ar71xx_pci_controller *apc;
|
||||
struct pci_host_bridge *bridge;
|
||||
u32 t;
|
||||
|
||||
bridge = devm_pci_alloc_host_bridge(dev, sizeof(*apc));
|
||||
if (!bridge)
|
||||
return -ENOMEM;
|
||||
|
||||
apc = pci_host_bridge_priv(bridge);
|
||||
apc->dev = dev;
|
||||
|
||||
apc->cfg_base = devm_platform_ioremap_resource_byname(pdev, "cfg_base");
|
||||
if (IS_ERR(apc->cfg_base))
|
||||
return PTR_ERR(apc->cfg_base);
|
||||
|
||||
ar71xx_pci_reset();
|
||||
|
||||
/* setup COMMAND register */
|
||||
t = PCI_COMMAND_MEMORY | PCI_COMMAND_MASTER | PCI_COMMAND_PARITY | PCI_COMMAND_SERR;
|
||||
ar71xx_pci_local_write(apc, PCI_COMMAND, 4, t);
|
||||
|
||||
/* clear bus errors */
|
||||
ar71xx_pci_check_error(apc, 1);
|
||||
|
||||
bridge->sysdata = apc;
|
||||
bridge->ops = &ar71xx_pci_ops;
|
||||
|
||||
ar71xx_pci_enabled = true;
|
||||
|
||||
return pci_host_probe(bridge);
|
||||
}
|
||||
|
||||
static const struct of_device_id ar71xx_pci_ids[] = {
|
||||
{ .compatible = "qca,ar7100-pci" },
|
||||
{ /* sentinel */ }
|
||||
};
|
||||
MODULE_DEVICE_TABLE(of, ar71xx_pci_ids);
|
||||
|
||||
static struct platform_driver ar71xx_pci_driver = {
|
||||
.probe = ar71xx_pci_probe,
|
||||
.driver = {
|
||||
.name = "ar71xx-pci",
|
||||
.of_match_table = ar71xx_pci_ids,
|
||||
.suppress_bind_attrs = true,
|
||||
},
|
||||
};
|
||||
builtin_platform_driver(ar71xx_pci_driver);
|
||||
|
||||
MODULE_DESCRIPTION("Atheros AR71xx PCI host controller driver");
|
||||
MODULE_LICENSE("GPL");
|
||||
@@ -0,0 +1,501 @@
|
||||
// SPDX-License-Identifier: GPL-2.0-only
|
||||
/*
|
||||
* Atheros ATH79 PCIe host controller driver
|
||||
*
|
||||
* Copyright (C) 2011 René Bolldorf <xsecute@googlemail.com>
|
||||
* Copyright (C) 2009-2011 Gabor Juhos <juhosg@openwrt.org>
|
||||
*/
|
||||
|
||||
#include <linux/delay.h>
|
||||
#include <linux/init.h>
|
||||
#include <linux/interrupt.h>
|
||||
#include <linux/iopoll.h>
|
||||
#include <linux/irq.h>
|
||||
#include <linux/irqdomain.h>
|
||||
#include <linux/module.h>
|
||||
#include <linux/of.h>
|
||||
#include <linux/pci.h>
|
||||
#include <linux/platform_device.h>
|
||||
#include <linux/reset.h>
|
||||
|
||||
#include <asm/mach-ath79/ar71xx_regs.h>
|
||||
#include <asm/mach-ath79/ath79.h>
|
||||
|
||||
#include "../pci.h"
|
||||
|
||||
#define ATH79_PCIE_REG_APP 0x00
|
||||
#define ATH79_PCIE_REG_RESET 0x18
|
||||
#define ATH79_PCIE_REG_INT_STATUS 0x4c
|
||||
#define ATH79_PCIE_REG_INT_MASK 0x50
|
||||
|
||||
#define ATH79_PCIE_APP_LTSSM_ENABLE BIT(0)
|
||||
|
||||
#define ATH79_PCIE_RESET_EP_RESET_L BIT(2)
|
||||
#define ATH79_PCIE_RESET_LINK_UP BIT(0)
|
||||
|
||||
/* level triggered INTA..INTD virtual wires in INT_STATUS/INT_MASK */
|
||||
#define ATH79_PCIE_INT_INTX_SHIFT 13
|
||||
#define ATH79_PCIE_INT_INTX(pin) BIT(ATH79_PCIE_INT_INTX_SHIFT + (pin))
|
||||
#define ATH79_PCIE_INT_INTX_ALL GENMASK(17, 14)
|
||||
|
||||
/* hwirq is the PCI interrupt pin, 1 (INTA) to 4 (INTD) */
|
||||
#define ATH79_PCIE_IRQ_COUNT (PCI_NUM_INTX + 1)
|
||||
|
||||
#define AR7240_BAR0_WAR_VALUE 0xffff
|
||||
|
||||
#define ATH79_PCIE_CMD_INIT (PCI_COMMAND_MEMORY | \
|
||||
PCI_COMMAND_MASTER | \
|
||||
PCI_COMMAND_PARITY | \
|
||||
PCI_COMMAND_SERR)
|
||||
|
||||
#define ATH79_PLL_PCIE_CONFIG_PLL_BYPASS BIT(16)
|
||||
#define ATH79_PLL_PCIE_CONFIG_PLL_PWD BIT(30)
|
||||
|
||||
#define QCA955X_PLL_PCIE_CONFIG_REG 0x0c
|
||||
|
||||
struct ath79_pcie_controller {
|
||||
void __iomem *devcfg_base;
|
||||
void __iomem *ctrl_base;
|
||||
void __iomem *crp_base;
|
||||
|
||||
struct device *dev;
|
||||
int irq;
|
||||
|
||||
bool link_up;
|
||||
bool bar0_is_cached;
|
||||
u32 bar0_value;
|
||||
|
||||
struct irq_domain *domain;
|
||||
|
||||
struct reset_control *hc_reset;
|
||||
struct reset_control *phy_reset;
|
||||
|
||||
raw_spinlock_t lock;
|
||||
};
|
||||
|
||||
static inline bool ath79_pcie_check_link(struct ath79_pcie_controller *apc)
|
||||
{
|
||||
u32 reset;
|
||||
|
||||
reset = readl_relaxed(apc->ctrl_base + ATH79_PCIE_REG_RESET);
|
||||
return reset & ATH79_PCIE_RESET_LINK_UP;
|
||||
}
|
||||
|
||||
static int ath79_pcie_rmw(void __iomem *base, int where, int size, u32 value)
|
||||
{
|
||||
u32 data;
|
||||
int shift;
|
||||
|
||||
if (size != 1 && size != 2 && size != 4)
|
||||
return PCIBIOS_BAD_REGISTER_NUMBER;
|
||||
|
||||
data = readl_relaxed(base + (where & ~3));
|
||||
|
||||
switch (size) {
|
||||
case 1:
|
||||
shift = (where & 3) * 8;
|
||||
data &= ~GENMASK(shift + 7, shift);
|
||||
data |= (value & 0xff) << shift;
|
||||
break;
|
||||
case 2:
|
||||
shift = (where & 2) * 8;
|
||||
data &= ~GENMASK(shift + 15, shift);
|
||||
data |= (value & 0xffff) << shift;
|
||||
break;
|
||||
case 4:
|
||||
data = value;
|
||||
break;
|
||||
default:
|
||||
return PCIBIOS_BAD_REGISTER_NUMBER;
|
||||
}
|
||||
|
||||
writel_relaxed(data, base + (where & ~3));
|
||||
/* flush the posted write */
|
||||
readl_relaxed(base + (where & ~3));
|
||||
|
||||
return PCIBIOS_SUCCESSFUL;
|
||||
}
|
||||
|
||||
static int ath79_pcie_read(struct pci_bus *bus, unsigned int devfn, int where,
|
||||
int size, u32 *value)
|
||||
{
|
||||
struct ath79_pcie_controller *apc = bus->sysdata;
|
||||
void __iomem *base;
|
||||
u32 data;
|
||||
|
||||
if (!apc->link_up)
|
||||
return PCIBIOS_DEVICE_NOT_FOUND;
|
||||
|
||||
if (!pci_is_root_bus(bus) || devfn)
|
||||
return PCIBIOS_DEVICE_NOT_FOUND;
|
||||
|
||||
base = apc->devcfg_base;
|
||||
data = readl_relaxed(base + (where & ~3));
|
||||
|
||||
switch (size) {
|
||||
case 1:
|
||||
data >>= (where & 3) * 8;
|
||||
data &= 0xff;
|
||||
break;
|
||||
case 2:
|
||||
data >>= (where & 2) * 8;
|
||||
data &= 0xffff;
|
||||
break;
|
||||
case 4:
|
||||
break;
|
||||
default:
|
||||
return PCIBIOS_BAD_REGISTER_NUMBER;
|
||||
}
|
||||
|
||||
if (where == PCI_BASE_ADDRESS_0 && size == 4 &&
|
||||
apc->bar0_is_cached) {
|
||||
/* use the cached value */
|
||||
*value = apc->bar0_value;
|
||||
} else {
|
||||
*value = data;
|
||||
}
|
||||
|
||||
return PCIBIOS_SUCCESSFUL;
|
||||
}
|
||||
|
||||
static int ath79_pcie_write(struct pci_bus *bus, unsigned int devfn, int where,
|
||||
int size, u32 value)
|
||||
{
|
||||
struct ath79_pcie_controller *apc = bus->sysdata;
|
||||
|
||||
if (!apc->link_up)
|
||||
return PCIBIOS_DEVICE_NOT_FOUND;
|
||||
|
||||
if (!pci_is_root_bus(bus) || devfn)
|
||||
return PCIBIOS_DEVICE_NOT_FOUND;
|
||||
|
||||
if (soc_is_ar7240() && where == PCI_BASE_ADDRESS_0 && size == 4) {
|
||||
if (value != 0xffffffff) {
|
||||
/*
|
||||
* WAR for a hw issue. If the BAR0 register of the
|
||||
* device is set to the proper base address, the
|
||||
* memory space of the device is not accessible.
|
||||
*
|
||||
* Cache the intended value so it can be read back,
|
||||
* and write a SoC specific constant value to the
|
||||
* BAR0 register in order to make the device memory
|
||||
* accessible.
|
||||
*/
|
||||
apc->bar0_is_cached = true;
|
||||
apc->bar0_value = value;
|
||||
|
||||
value = AR7240_BAR0_WAR_VALUE;
|
||||
} else {
|
||||
apc->bar0_is_cached = false;
|
||||
}
|
||||
}
|
||||
|
||||
return ath79_pcie_rmw(apc->devcfg_base, where, size, value);
|
||||
}
|
||||
|
||||
static int ath79_pcie_local_write(struct ath79_pcie_controller *apc,
|
||||
int where, int size, u32 value)
|
||||
{
|
||||
if (!apc->link_up)
|
||||
return PCIBIOS_DEVICE_NOT_FOUND;
|
||||
|
||||
WARN_ON(where & (size - 1));
|
||||
|
||||
return ath79_pcie_rmw(apc->crp_base, where, size, value);
|
||||
}
|
||||
|
||||
static struct pci_ops ath79_pcie_ops = {
|
||||
.read = ath79_pcie_read,
|
||||
.write = ath79_pcie_write,
|
||||
};
|
||||
|
||||
static irqreturn_t ath79_pcie_irq_handler(int irq, void *data)
|
||||
{
|
||||
struct ath79_pcie_controller *apc = data;
|
||||
unsigned long pending;
|
||||
int bit;
|
||||
|
||||
pending = readl_relaxed(apc->ctrl_base + ATH79_PCIE_REG_INT_STATUS) &
|
||||
readl_relaxed(apc->ctrl_base + ATH79_PCIE_REG_INT_MASK) &
|
||||
ATH79_PCIE_INT_INTX_ALL;
|
||||
if (!pending)
|
||||
return IRQ_NONE;
|
||||
|
||||
/*
|
||||
* The INTx bits follow the assert/deassert messages of the
|
||||
* endpoint, so they clear themselves and need no ack.
|
||||
*/
|
||||
for_each_set_bit(bit, &pending, BITS_PER_LONG)
|
||||
generic_handle_domain_irq_safe(apc->domain,
|
||||
bit - ATH79_PCIE_INT_INTX_SHIFT);
|
||||
|
||||
return IRQ_HANDLED;
|
||||
}
|
||||
|
||||
static void ath79_pcie_irq_update(struct irq_data *d, bool enable)
|
||||
{
|
||||
struct ath79_pcie_controller *apc = irq_data_get_irq_chip_data(d);
|
||||
void __iomem *base = apc->ctrl_base;
|
||||
unsigned long flags;
|
||||
u32 t;
|
||||
|
||||
raw_spin_lock_irqsave(&apc->lock, flags);
|
||||
t = readl_relaxed(base + ATH79_PCIE_REG_INT_MASK);
|
||||
if (enable)
|
||||
t |= ATH79_PCIE_INT_INTX(irqd_to_hwirq(d));
|
||||
else
|
||||
t &= ~ATH79_PCIE_INT_INTX(irqd_to_hwirq(d));
|
||||
writel_relaxed(t, base + ATH79_PCIE_REG_INT_MASK);
|
||||
/* flush the posted write */
|
||||
readl_relaxed(base + ATH79_PCIE_REG_INT_MASK);
|
||||
raw_spin_unlock_irqrestore(&apc->lock, flags);
|
||||
}
|
||||
|
||||
static void ath79_pcie_irq_unmask(struct irq_data *d)
|
||||
{
|
||||
ath79_pcie_irq_update(d, true);
|
||||
}
|
||||
|
||||
static void ath79_pcie_irq_mask(struct irq_data *d)
|
||||
{
|
||||
ath79_pcie_irq_update(d, false);
|
||||
}
|
||||
|
||||
static struct irq_chip ath79_pcie_irq_chip = {
|
||||
.name = "ATH79 PCIE",
|
||||
.irq_mask = ath79_pcie_irq_mask,
|
||||
.irq_unmask = ath79_pcie_irq_unmask,
|
||||
};
|
||||
|
||||
static int ath79_pcie_irq_map(struct irq_domain *d,
|
||||
unsigned int irq, irq_hw_number_t hw)
|
||||
{
|
||||
struct ath79_pcie_controller *apc = d->host_data;
|
||||
|
||||
if (hw < PCI_INTERRUPT_INTA || hw > PCI_INTERRUPT_INTD)
|
||||
return -EINVAL;
|
||||
|
||||
irq_set_chip_and_handler(irq, &ath79_pcie_irq_chip, handle_level_irq);
|
||||
irq_set_chip_data(irq, apc);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static const struct irq_domain_ops ath79_pcie_domain_ops = {
|
||||
.xlate = irq_domain_xlate_onecell,
|
||||
.map = ath79_pcie_irq_map,
|
||||
};
|
||||
|
||||
static void ath79_pcie_irq_domain_remove(void *data)
|
||||
{
|
||||
irq_domain_remove(data);
|
||||
}
|
||||
|
||||
static int ath79_pcie_irq_init(struct ath79_pcie_controller *apc)
|
||||
{
|
||||
void __iomem *base = apc->ctrl_base;
|
||||
int ret;
|
||||
|
||||
writel_relaxed(0, base + ATH79_PCIE_REG_INT_MASK);
|
||||
/* the edge and error bits are cleared by writing 0 */
|
||||
writel_relaxed(0, base + ATH79_PCIE_REG_INT_STATUS);
|
||||
|
||||
apc->domain = irq_domain_create_linear(dev_fwnode(apc->dev),
|
||||
ATH79_PCIE_IRQ_COUNT,
|
||||
&ath79_pcie_domain_ops, apc);
|
||||
if (!apc->domain)
|
||||
return -ENOMEM;
|
||||
|
||||
ret = devm_add_action_or_reset(apc->dev, ath79_pcie_irq_domain_remove,
|
||||
apc->domain);
|
||||
if (ret)
|
||||
return ret;
|
||||
|
||||
/* the CPU interrupt line is shared with WMAC or USB */
|
||||
return devm_request_irq(apc->dev, apc->irq, ath79_pcie_irq_handler,
|
||||
IRQF_SHARED, dev_name(apc->dev), apc);
|
||||
}
|
||||
|
||||
static int ath79_pcie_power_on(struct ath79_pcie_controller *apc)
|
||||
{
|
||||
int ret;
|
||||
|
||||
ret = reset_control_deassert(apc->hc_reset);
|
||||
if (ret) {
|
||||
dev_err(apc->dev, "failed to deassert hc reset: %d\n", ret);
|
||||
return ret;
|
||||
}
|
||||
|
||||
ret = reset_control_deassert(apc->phy_reset);
|
||||
if (ret) {
|
||||
dev_err(apc->dev, "failed to deassert phy reset: %d\n", ret);
|
||||
return ret;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int ath79_pcie_init_phy(struct ath79_pcie_controller *apc, bool qca)
|
||||
{
|
||||
u32 ppl;
|
||||
|
||||
if (qca) {
|
||||
ppl = ath79_pll_rr(QCA955X_PLL_PCIE_CONFIG_REG);
|
||||
ppl &= ~ATH79_PLL_PCIE_CONFIG_PLL_PWD;
|
||||
ath79_pll_wr(QCA955X_PLL_PCIE_CONFIG_REG, ppl);
|
||||
|
||||
ppl = ath79_pll_rr(QCA955X_PLL_PCIE_CONFIG_REG);
|
||||
ppl &= ~ATH79_PLL_PCIE_CONFIG_PLL_BYPASS;
|
||||
ath79_pll_wr(QCA955X_PLL_PCIE_CONFIG_REG, ppl);
|
||||
} else {
|
||||
ppl = ath79_pll_rr(AR724X_PLL_REG_PCIE_CONFIG);
|
||||
ppl &= ~(ATH79_PLL_PCIE_CONFIG_PLL_PWD |
|
||||
AR724X_PLL_REG_PCIE_CONFIG_PPL_RESET);
|
||||
ath79_pll_wr(AR724X_PLL_REG_PCIE_CONFIG, ppl);
|
||||
|
||||
ppl = ath79_pll_rr(AR724X_PLL_REG_PCIE_CONFIG);
|
||||
ppl &= ~ATH79_PLL_PCIE_CONFIG_PLL_BYPASS;
|
||||
ath79_pll_wr(AR724X_PLL_REG_PCIE_CONFIG, ppl);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int ath79_pcie_start_link(struct ath79_pcie_controller *apc)
|
||||
{
|
||||
u32 rst, app;
|
||||
|
||||
/* let the reference clock settle before releasing PERST# */
|
||||
usleep_range(PCIE_T_PERST_CLK_US, 2 * PCIE_T_PERST_CLK_US);
|
||||
|
||||
rst = readl_relaxed(apc->ctrl_base + ATH79_PCIE_REG_RESET);
|
||||
rst |= ATH79_PCIE_RESET_EP_RESET_L;
|
||||
writel_relaxed(rst, apc->ctrl_base + ATH79_PCIE_REG_RESET);
|
||||
|
||||
app = readl_relaxed(apc->ctrl_base + ATH79_PCIE_REG_APP);
|
||||
app |= ATH79_PCIE_APP_LTSSM_ENABLE;
|
||||
writel_relaxed(app, apc->ctrl_base + ATH79_PCIE_REG_APP);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int ath79_pcie_wait_link(struct ath79_pcie_controller *apc)
|
||||
{
|
||||
u32 rst;
|
||||
|
||||
return readl_poll_timeout(apc->ctrl_base + ATH79_PCIE_REG_RESET, rst,
|
||||
rst & ATH79_PCIE_RESET_LINK_UP,
|
||||
10000, 100000);
|
||||
}
|
||||
|
||||
static int ath79_pcie_probe(struct platform_device *pdev)
|
||||
{
|
||||
struct ath79_pcie_controller *apc;
|
||||
struct reset_control *phy_reset;
|
||||
struct reset_control *hc_reset;
|
||||
struct pci_host_bridge *bridge;
|
||||
struct device *dev;
|
||||
bool qca;
|
||||
int ret;
|
||||
|
||||
dev = &pdev->dev;
|
||||
hc_reset = devm_reset_control_get_exclusive(dev, "hc");
|
||||
if (IS_ERR(hc_reset))
|
||||
return dev_err_probe(dev, PTR_ERR(hc_reset),
|
||||
"failed to get hc reset\n");
|
||||
|
||||
phy_reset = devm_reset_control_get_exclusive(dev, "phy");
|
||||
if (IS_ERR(phy_reset))
|
||||
return dev_err_probe(dev, PTR_ERR(phy_reset),
|
||||
"failed to get phy reset\n");
|
||||
|
||||
bridge = devm_pci_alloc_host_bridge(dev, sizeof(*apc));
|
||||
if (!bridge)
|
||||
return -ENOMEM;
|
||||
|
||||
apc = pci_host_bridge_priv(bridge);
|
||||
apc->phy_reset = phy_reset;
|
||||
apc->hc_reset = hc_reset;
|
||||
apc->dev = dev;
|
||||
|
||||
raw_spin_lock_init(&apc->lock);
|
||||
|
||||
apc->ctrl_base = devm_platform_ioremap_resource_byname(pdev, "ctrl_base");
|
||||
if (IS_ERR(apc->ctrl_base))
|
||||
return PTR_ERR(apc->ctrl_base);
|
||||
|
||||
apc->devcfg_base = devm_platform_ioremap_resource_byname(pdev, "cfg_base");
|
||||
if (IS_ERR(apc->devcfg_base))
|
||||
return PTR_ERR(apc->devcfg_base);
|
||||
|
||||
apc->crp_base = devm_platform_ioremap_resource_byname(pdev, "crp_base");
|
||||
if (IS_ERR(apc->crp_base))
|
||||
return PTR_ERR(apc->crp_base);
|
||||
|
||||
apc->irq = platform_get_irq(pdev, 0);
|
||||
if (apc->irq < 0)
|
||||
return apc->irq;
|
||||
|
||||
/*
|
||||
* Do the full PCIE Root Complex Initialization Sequence if the PCIe
|
||||
* host controller is in reset.
|
||||
*/
|
||||
if (reset_control_status(apc->hc_reset)) {
|
||||
qca = device_is_compatible(dev, "qcom,qca9550-pci");
|
||||
|
||||
ret = ath79_pcie_power_on(apc);
|
||||
if (ret)
|
||||
return ret;
|
||||
|
||||
ret = ath79_pcie_init_phy(apc, qca);
|
||||
if (ret)
|
||||
return ret;
|
||||
|
||||
ret = ath79_pcie_start_link(apc);
|
||||
if (ret)
|
||||
return ret;
|
||||
|
||||
/*
|
||||
* Without a link the bus is registered empty. With one, the
|
||||
* endpoint may not answer configuration requests any earlier.
|
||||
*/
|
||||
if (!ath79_pcie_wait_link(apc))
|
||||
msleep(PCIE_RESET_CONFIG_WAIT_MS);
|
||||
}
|
||||
|
||||
apc->link_up = ath79_pcie_check_link(apc);
|
||||
if (!apc->link_up)
|
||||
dev_warn(dev, "PCIe link is down\n");
|
||||
|
||||
ret = ath79_pcie_irq_init(apc);
|
||||
if (ret)
|
||||
return ret;
|
||||
|
||||
if (apc->link_up)
|
||||
ath79_pcie_local_write(apc, PCI_COMMAND, 4, ATH79_PCIE_CMD_INIT);
|
||||
|
||||
bridge->sysdata = apc;
|
||||
bridge->ops = &ath79_pcie_ops;
|
||||
|
||||
return pci_host_probe(bridge);
|
||||
}
|
||||
|
||||
static const struct of_device_id ath79_pcie_ids[] = {
|
||||
{ .compatible = "qcom,ar7240-pci" },
|
||||
{ .compatible = "qcom,qca9550-pci" },
|
||||
{ /* sentinel */ }
|
||||
};
|
||||
MODULE_DEVICE_TABLE(of, ath79_pcie_ids);
|
||||
|
||||
static struct platform_driver ath79_pcie_driver = {
|
||||
.probe = ath79_pcie_probe,
|
||||
.driver = {
|
||||
.name = "ath79-pcie",
|
||||
.of_match_table = ath79_pcie_ids,
|
||||
.suppress_bind_attrs = true,
|
||||
},
|
||||
};
|
||||
builtin_platform_driver(ath79_pcie_driver);
|
||||
|
||||
MODULE_DESCRIPTION("Atheros ATH79 PCIe host controller driver");
|
||||
MODULE_LICENSE("GPL");
|
||||
@@ -18,7 +18,7 @@ CONFIG_MTD_UBI_BEB_LIMIT=20
|
||||
CONFIG_MTD_UBI_BLOCK=y
|
||||
CONFIG_MTD_UBI_NVMEM=y
|
||||
CONFIG_MTD_UBI_WL_THRESHOLD=4096
|
||||
# CONFIG_PCI_AR71XX is not set
|
||||
# CONFIG_PCI_ATH79 is not set
|
||||
CONFIG_POWER_RESET=y
|
||||
CONFIG_POWER_RESET_GPIO_RESTART=y
|
||||
CONFIG_UBIFS_FS=y
|
||||
|
||||
@@ -0,0 +1,43 @@
|
||||
From 6494fb3525408824cdf2355794f37afe35f8c0f6 Mon Sep 17 00:00:00 2001
|
||||
From: Rosen Penev <rosenp@gmail.com>
|
||||
Date: Sun, 14 Jun 2026 15:19:35 -0700
|
||||
Subject: [PATCH] MIPS: ath79: remove dead symbols
|
||||
|
||||
Since the platform code removal for ath79, these SOC symbols have been
|
||||
unused by both up and downstream in favor of dts bindings. Remove them.
|
||||
|
||||
Signed-off-by: Rosen Penev <rosenp@gmail.com>
|
||||
---
|
||||
arch/mips/ath79/Kconfig | 21 ---------------------
|
||||
1 file changed, 21 deletions(-)
|
||||
|
||||
--- a/arch/mips/ath79/Kconfig
|
||||
+++ b/arch/mips/ath79/Kconfig
|
||||
@@ -5,27 +5,6 @@ config SOC_AR71XX
|
||||
select HAVE_PCI
|
||||
def_bool n
|
||||
|
||||
-config SOC_AR724X
|
||||
- select HAVE_PCI
|
||||
- select PCI_AR724X if PCI
|
||||
- def_bool n
|
||||
-
|
||||
-config SOC_AR913X
|
||||
- def_bool n
|
||||
-
|
||||
-config SOC_AR933X
|
||||
- def_bool n
|
||||
-
|
||||
-config SOC_AR934X
|
||||
- select HAVE_PCI
|
||||
- select PCI_AR724X if PCI
|
||||
- def_bool n
|
||||
-
|
||||
-config SOC_QCA955X
|
||||
- select HAVE_PCI
|
||||
- select PCI_AR724X if PCI
|
||||
- def_bool n
|
||||
-
|
||||
config PCI_AR724X
|
||||
def_bool n
|
||||
|
||||
@@ -0,0 +1,56 @@
|
||||
--- a/arch/mips/Kconfig
|
||||
+++ b/arch/mips/Kconfig
|
||||
@@ -237,6 +237,7 @@ config ATH79
|
||||
select PINCTRL
|
||||
select COMMON_CLK
|
||||
select IRQ_MIPS_CPU
|
||||
+ select PCI_DRIVERS_GENERIC
|
||||
select SYS_HAS_CPU_MIPS32_R2
|
||||
select SYS_HAS_EARLY_PRINTK
|
||||
select SYS_SUPPORTS_32BIT_KERNEL
|
||||
--- a/arch/mips/pci/Makefile
|
||||
+++ b/arch/mips/pci/Makefile
|
||||
@@ -25,7 +25,6 @@ obj-$(CONFIG_PCI_XTALK_BRIDGE) += pci-xt
|
||||
#
|
||||
# These are still pretty much in the old state, watch, go blind.
|
||||
#
|
||||
-obj-$(CONFIG_ATH79) += fixup-ath79.o
|
||||
obj-$(CONFIG_MIPS_COBALT) += fixup-cobalt.o
|
||||
obj-$(CONFIG_LEMOTE_FULOONG2E) += fixup-fuloong2e.o ops-loongson2.o
|
||||
obj-$(CONFIG_LEMOTE_MACH2F) += fixup-lemote2f.o ops-loongson2.o
|
||||
--- a/drivers/pci/controller/Kconfig
|
||||
+++ b/drivers/pci/controller/Kconfig
|
||||
@@ -54,6 +54,22 @@ config PCIE_APPLE
|
||||
|
||||
If unsure, say Y if you have an Apple Silicon system.
|
||||
|
||||
+config PCI_ATH79
|
||||
+ bool "Atheros PCI controller"
|
||||
+ depends on ATH79 || (MIPS && COMPILE_TEST)
|
||||
+ depends on OF
|
||||
+ help
|
||||
+ Say Y here to enable support for the PCI host controller found on
|
||||
+ the Atheros AR71xx family of SoCs.
|
||||
+
|
||||
+config PCIE_ATH79
|
||||
+ bool "Atheros AR724x PCIe controller"
|
||||
+ depends on ATH79 || (MIPS && COMPILE_TEST)
|
||||
+ depends on OF
|
||||
+ help
|
||||
+ Say Y here to enable support for the PCIe host controller found on
|
||||
+ newer Atheros SoCs.
|
||||
+
|
||||
config PCI_VERSATILE
|
||||
bool "ARM Versatile PB PCI controller"
|
||||
depends on ARCH_VERSATILE || COMPILE_TEST
|
||||
--- a/drivers/pci/controller/Makefile
|
||||
+++ b/drivers/pci/controller/Makefile
|
||||
@@ -39,6 +39,8 @@ obj-$(CONFIG_PCI_LOONGSON) += pci-loongs
|
||||
obj-$(CONFIG_PCIE_HISI_ERR) += pcie-hisi-error.o
|
||||
obj-$(CONFIG_PCIE_APPLE) += pcie-apple.o
|
||||
obj-$(CONFIG_PCIE_MT7621) += pcie-mt7621.o
|
||||
+obj-$(CONFIG_PCI_ATH79) += pci-ath79.o
|
||||
+obj-$(CONFIG_PCIE_ATH79) += pcie-ath79.o
|
||||
|
||||
# pcie-hisi.o quirks are needed even without CONFIG_PCIE_DW
|
||||
obj-y += dwc/
|
||||
@@ -14,26 +14,6 @@ PCIe root-complex on the QCA9558.
|
||||
|
||||
Signed-off-by: David Bauer <mail@david-bauer.net>
|
||||
|
||||
--- a/arch/mips/include/asm/mach-ath79/ar71xx_regs.h
|
||||
+++ b/arch/mips/include/asm/mach-ath79/ar71xx_regs.h
|
||||
@@ -390,6 +390,7 @@
|
||||
#define QCA955X_PLL_CPU_CONFIG_REG 0x00
|
||||
#define QCA955X_PLL_DDR_CONFIG_REG 0x04
|
||||
#define QCA955X_PLL_CLK_CTRL_REG 0x08
|
||||
+#define QCA955X_PLL_PCIE_CONFIG_REG 0x0c
|
||||
#define QCA955X_PLL_ETH_XMII_CONTROL_REG 0x28
|
||||
#define QCA955X_PLL_ETH_SGMII_CONTROL_REG 0x48
|
||||
#define QCA955X_PLL_ETH_SGMII_SERDES_REG 0x4c
|
||||
@@ -475,6 +476,9 @@
|
||||
#define QCA956X_PLL_CLK_CTRL_CPU_DDRCLK_FROM_CPUPLL BIT(21)
|
||||
#define QCA956X_PLL_CLK_CTRL_AHBCLK_FROM_DDRPLL BIT(24)
|
||||
|
||||
+#define QCA955X_PLL_PCIE_CONFIG_PLL_PWD BIT(30)
|
||||
+#define QCA955X_PLL_PCIE_CONFIG_PLL_BYPASS BIT(16)
|
||||
+
|
||||
#define QCA956X_PLL_SWITCH_CLOCK_SPARE_I2C_CLK_SELB BIT(5)
|
||||
#define QCA956X_PLL_SWITCH_CLOCK_SPARE_MDIO_CLK_SEL0_1 BIT(6)
|
||||
#define QCA956X_PLL_SWITCH_CLOCK_SPARE_UART1_CLK_SEL BIT(7)
|
||||
--- a/arch/mips/pci/pci-ar724x.c
|
||||
+++ b/arch/mips/pci/pci-ar724x.c
|
||||
@@ -8,6 +8,7 @@
|
||||
|
||||
+3
-59
@@ -3,6 +3,8 @@ Subject: [PATCH] ar71xx: swizzle address for PCI byte/word access on AR71xx
|
||||
|
||||
Closes #11683.
|
||||
|
||||
The ath79_pci_swizzle_b/w() helpers live in the OpenWrt pci-ath79 driver.
|
||||
|
||||
SVN-Revision: 32639
|
||||
---
|
||||
.../mips/include/asm/mach-ath79/mangle-port.h | 111 ++++++++++++++++++
|
||||
@@ -26,7 +28,7 @@ SVN-Revision: 32639
|
||||
+#ifndef __ASM_MACH_ATH79_MANGLE_PORT_H
|
||||
+#define __ASM_MACH_ATH79_MANGLE_PORT_H
|
||||
+
|
||||
+#ifdef CONFIG_PCI_AR71XX
|
||||
+#ifdef CONFIG_PCI_ATH79
|
||||
+extern unsigned long (ath79_pci_swizzle_b)(unsigned long port);
|
||||
+extern unsigned long (ath79_pci_swizzle_w)(unsigned long port);
|
||||
+#else
|
||||
@@ -49,61 +51,3 @@ SVN-Revision: 32639
|
||||
+# define __mem_ioswabq(a, x) cpu_to_le64(x)
|
||||
+
|
||||
+#endif /* __ASM_MACH_ATH79_MANGLE_PORT_H */
|
||||
--- a/arch/mips/pci/pci-ar71xx.c
|
||||
+++ b/arch/mips/pci/pci-ar71xx.c
|
||||
@@ -68,6 +68,45 @@ static const u32 ar71xx_pci_read_mask[8]
|
||||
0, 0xff, 0xffff, 0, 0xffffffff, 0, 0, 0
|
||||
};
|
||||
|
||||
+static unsigned long (*__ath79_pci_swizzle_b)(unsigned long port);
|
||||
+static unsigned long (*__ath79_pci_swizzle_w)(unsigned long port);
|
||||
+
|
||||
+static inline bool ar71xx_is_pci_addr(unsigned long port)
|
||||
+{
|
||||
+ unsigned long phys = CPHYSADDR(port);
|
||||
+
|
||||
+ return (phys >= AR71XX_PCI_MEM_BASE &&
|
||||
+ phys < AR71XX_PCI_MEM_BASE + AR71XX_PCI_MEM_SIZE);
|
||||
+}
|
||||
+
|
||||
+static unsigned long ar71xx_pci_swizzle_b(unsigned long port)
|
||||
+{
|
||||
+ return ar71xx_is_pci_addr(port) ? port ^ 3 : port;
|
||||
+}
|
||||
+
|
||||
+static unsigned long ar71xx_pci_swizzle_w(unsigned long port)
|
||||
+{
|
||||
+ return ar71xx_is_pci_addr(port) ? port ^ 2 : port;
|
||||
+}
|
||||
+
|
||||
+unsigned long ath79_pci_swizzle_b(unsigned long port)
|
||||
+{
|
||||
+ if (__ath79_pci_swizzle_b)
|
||||
+ return __ath79_pci_swizzle_b(port);
|
||||
+
|
||||
+ return port;
|
||||
+}
|
||||
+EXPORT_SYMBOL(ath79_pci_swizzle_b);
|
||||
+
|
||||
+unsigned long ath79_pci_swizzle_w(unsigned long port)
|
||||
+{
|
||||
+ if (__ath79_pci_swizzle_w)
|
||||
+ return __ath79_pci_swizzle_w(port);
|
||||
+
|
||||
+ return port;
|
||||
+}
|
||||
+EXPORT_SYMBOL(ath79_pci_swizzle_w);
|
||||
+
|
||||
static inline u32 ar71xx_pci_get_ble(int where, int size, int local)
|
||||
{
|
||||
u32 t;
|
||||
@@ -275,6 +314,9 @@ static int ar71xx_pci_probe(struct platf
|
||||
|
||||
register_pci_controller(&apc->pci_ctrl);
|
||||
|
||||
+ __ath79_pci_swizzle_b = ar71xx_pci_swizzle_b;
|
||||
+ __ath79_pci_swizzle_w = ar71xx_pci_swizzle_w;
|
||||
+
|
||||
return 0;
|
||||
}
|
||||
|
||||
-11
@@ -9,17 +9,6 @@ PPL_RESET bit of AR724x.
|
||||
Signed-off-by: INAGAKI Hiroshi <musashino.open@gmail.com>
|
||||
---
|
||||
|
||||
--- a/arch/mips/include/asm/mach-ath79/ar71xx_regs.h
|
||||
+++ b/arch/mips/include/asm/mach-ath79/ar71xx_regs.h
|
||||
@@ -347,6 +347,8 @@
|
||||
#define AR934X_PLL_CPU_DDR_CLK_CTRL_DDRCLK_FROM_DDRPLL BIT(21)
|
||||
#define AR934X_PLL_CPU_DDR_CLK_CTRL_AHBCLK_FROM_DDRPLL BIT(24)
|
||||
|
||||
+#define AR934X_PLL_PCIE_CONFIG_PLL_PWD BIT(30)
|
||||
+
|
||||
#define AR934X_PLL_SWITCH_CLOCK_CONTROL_MDIO_CLK_SEL BIT(6)
|
||||
|
||||
#define QCA953X_PLL_CPU_CONFIG_REG 0x00
|
||||
--- a/arch/mips/pci/pci-ar724x.c
|
||||
+++ b/arch/mips/pci/pci-ar724x.c
|
||||
@@ -360,7 +360,8 @@ static void ar724x_pci_hw_init(struct ar
|
||||
|
||||
@@ -7,7 +7,7 @@ Subject: [PATCH] ath79: gmac: add parsers for rxd(v)- and tx(d|en)-delay for
|
||||
|
||||
--- a/arch/mips/include/asm/mach-ath79/ar71xx_regs.h
|
||||
+++ b/arch/mips/include/asm/mach-ath79/ar71xx_regs.h
|
||||
@@ -1233,6 +1233,10 @@
|
||||
@@ -1227,6 +1227,10 @@
|
||||
#define AR934X_ETH_CFG_RDV_DELAY BIT(16)
|
||||
#define AR934X_ETH_CFG_RDV_DELAY_MASK 0x3
|
||||
#define AR934X_ETH_CFG_RDV_DELAY_SHIFT 16
|
||||
|
||||
+2
-2
@@ -16,7 +16,7 @@ Signed-off-by: David Bauer <mail@david-bauer.net>
|
||||
|
||||
--- a/arch/mips/include/asm/mach-ath79/ar71xx_regs.h
|
||||
+++ b/arch/mips/include/asm/mach-ath79/ar71xx_regs.h
|
||||
@@ -1253,7 +1253,12 @@
|
||||
@@ -1247,7 +1247,12 @@
|
||||
*/
|
||||
|
||||
#define QCA955X_GMAC_REG_ETH_CFG 0x00
|
||||
@@ -29,7 +29,7 @@ Signed-off-by: David Bauer <mail@david-bauer.net>
|
||||
|
||||
#define QCA955X_ETH_CFG_RGMII_EN BIT(0)
|
||||
#define QCA955X_ETH_CFG_MII_GE0 BIT(1)
|
||||
@@ -1275,9 +1280,58 @@
|
||||
@@ -1269,9 +1274,58 @@
|
||||
#define QCA955X_ETH_CFG_TXE_DELAY_MASK 0x3
|
||||
#define QCA955X_ETH_CFG_TXE_DELAY_SHIFT 20
|
||||
|
||||
|
||||
@@ -21,7 +21,7 @@ Submitted-by: David Bauer <mail@david-bauer.net>
|
||||
|
||||
--- a/arch/mips/include/asm/mach-ath79/ar71xx_regs.h
|
||||
+++ b/arch/mips/include/asm/mach-ath79/ar71xx_regs.h
|
||||
@@ -1382,5 +1382,6 @@
|
||||
@@ -1376,5 +1376,6 @@
|
||||
|
||||
#define QCA956X_SGMII_CONFIG_MODE_CTRL_SHIFT 0
|
||||
#define QCA956X_SGMII_CONFIG_MODE_CTRL_MASK 0x7
|
||||
|
||||
@@ -45,8 +45,8 @@ Submitted-by: Daniel Golle <daniel@makrotopia.org>
|
||||
goto err_iounmap;
|
||||
--- a/arch/mips/include/asm/mach-ath79/ar71xx_regs.h
|
||||
+++ b/arch/mips/include/asm/mach-ath79/ar71xx_regs.h
|
||||
@@ -350,6 +350,7 @@
|
||||
#define AR934X_PLL_PCIE_CONFIG_PLL_PWD BIT(30)
|
||||
@@ -348,6 +348,7 @@
|
||||
#define AR934X_PLL_CPU_DDR_CLK_CTRL_AHBCLK_FROM_DDRPLL BIT(24)
|
||||
|
||||
#define AR934X_PLL_SWITCH_CLOCK_CONTROL_MDIO_CLK_SEL BIT(6)
|
||||
+#define AR934X_PLL_SWITCH_CLOCK_CONTROL_UART1_CLK_SEL BIT(7)
|
||||
|
||||
@@ -9,13 +9,12 @@ code is always built. So lets drop all the SoC symbols
|
||||
Signed-off-by: John Crispin <john@phrozen.org>
|
||||
---
|
||||
arch/mips/Kconfig | 2 ++
|
||||
arch/mips/ath79/Kconfig | 44 +++++---------------------------------------
|
||||
arch/mips/pci/Makefile | 2 +-
|
||||
3 files changed, 8 insertions(+), 40 deletions(-)
|
||||
arch/mips/pci/Makefile | 2 --
|
||||
2 files changed, 2 insertions(+), 2 deletions(-)
|
||||
|
||||
--- a/arch/mips/Kconfig
|
||||
+++ b/arch/mips/Kconfig
|
||||
@@ -243,6 +243,8 @@ config ATH79
|
||||
@@ -244,6 +244,8 @@ config ATH79
|
||||
select SYS_SUPPORTS_BIG_ENDIAN
|
||||
select SYS_SUPPORTS_MIPS16
|
||||
select SYS_SUPPORTS_ZBOOT_UART_PROM
|
||||
@@ -24,54 +23,14 @@ Signed-off-by: John Crispin <john@phrozen.org>
|
||||
select USE_OF
|
||||
select USB_EHCI_ROOT_HUB_TT if USB_EHCI_HCD_PLATFORM
|
||||
help
|
||||
--- a/arch/mips/ath79/Kconfig
|
||||
+++ b/arch/mips/ath79/Kconfig
|
||||
@@ -1,32 +1,14 @@
|
||||
# SPDX-License-Identifier: GPL-2.0
|
||||
if ATH79
|
||||
|
||||
-config SOC_AR71XX
|
||||
- select HAVE_PCI
|
||||
- def_bool n
|
||||
-
|
||||
-config SOC_AR724X
|
||||
- select HAVE_PCI
|
||||
- select PCI_AR724X if PCI
|
||||
- def_bool n
|
||||
-
|
||||
-config SOC_AR913X
|
||||
- def_bool n
|
||||
-
|
||||
-config SOC_AR933X
|
||||
- def_bool n
|
||||
-
|
||||
-config SOC_AR934X
|
||||
- select HAVE_PCI
|
||||
- select PCI_AR724X if PCI
|
||||
- def_bool n
|
||||
-
|
||||
-config SOC_QCA955X
|
||||
- select HAVE_PCI
|
||||
- select PCI_AR724X if PCI
|
||||
+config PCI_AR71XX
|
||||
+ bool "PCI support for AR7100 type SoCs"
|
||||
+ depends on PCI
|
||||
def_bool n
|
||||
|
||||
config PCI_AR724X
|
||||
+ bool "PCI support for AR724x type SoCs"
|
||||
+ depends on PCI
|
||||
def_bool n
|
||||
|
||||
endif
|
||||
--- a/arch/mips/pci/Makefile
|
||||
+++ b/arch/mips/pci/Makefile
|
||||
@@ -19,7 +19,7 @@ obj-$(CONFIG_BCM63XX) += pci-bcm63xx.o
|
||||
@@ -19,8 +19,6 @@ obj-$(CONFIG_BCM63XX) += pci-bcm63xx.o
|
||||
ops-bcm63xx.o
|
||||
obj-$(CONFIG_MIPS_ALCHEMY) += pci-alchemy.o
|
||||
obj-$(CONFIG_PCI_AR2315) += pci-ar2315.o
|
||||
-obj-$(CONFIG_SOC_AR71XX) += pci-ar71xx.o
|
||||
+obj-$(CONFIG_PCI_AR71XX) += pci-ar71xx.o
|
||||
obj-$(CONFIG_PCI_AR724X) += pci-ar724x.o
|
||||
-obj-$(CONFIG_PCI_AR724X) += pci-ar724x.o
|
||||
obj-$(CONFIG_PCI_XTALK_BRIDGE) += pci-xtalk-bridge.o
|
||||
#
|
||||
# These are still pretty much in the old state, watch, go blind.
|
||||
-33
@@ -1,33 +0,0 @@
|
||||
From: Shiji Yang <yangshiji66@outlook.com>
|
||||
Date: Wed, 31 May 2023 00:15:23 +0000
|
||||
Subject: [PATCH] ath79: ignore the abused interrupt-map on pcie node
|
||||
|
||||
ath79 PCIe interrupt controller has stopped working correctly. This
|
||||
is because the DT exposing a non-sensical interrupt-map property,
|
||||
and their drivers relying on the kernel ignoring this property[1].
|
||||
|
||||
This patch fix the pcie init error:
|
||||
ath9k 0000:00:00.0: of_irq_parse_pci: failed with rc=-14
|
||||
|
||||
Notice:
|
||||
This is just a workaround, not a fix. PCIe driver and related dts
|
||||
node need to be rewritten.
|
||||
|
||||
[1] https://lore.kernel.org/all/20211201114102.13446-1-maz@kernel.org/
|
||||
|
||||
Signed-off-by: Shiji Yang <yangshiji66@outlook.com>
|
||||
---
|
||||
drivers/of/irq.c | 2 ++
|
||||
1 file changed, 2 insertions(+)
|
||||
|
||||
--- a/drivers/of/irq.c
|
||||
+++ b/drivers/of/irq.c
|
||||
@@ -94,6 +94,8 @@ EXPORT_SYMBOL_GPL(of_irq_find_parent);
|
||||
* drawing board.
|
||||
*/
|
||||
static const char * const of_irq_imap_abusers[] = {
|
||||
+ "qca,ar7100-pci",
|
||||
+ "qcom,ar7240-pci",
|
||||
"CBEA,platform-spider-pic",
|
||||
"sti,platform-spider-pic",
|
||||
"realtek,rtl-intc",
|
||||
Reference in new issue
Block a user