[PATCH v2 4/9] PCI: sunxi: Add Allwinner A733 DesignWare PCIe host controller driver

Bjorn Helgaas helgaas at kernel.org
Mon Nov 30 12:12:50 PST 2026


On Mon, Nov 30, 2026 at 04:24:45PM +1100, Alastair D'Silva wrote:
> Add a DesignWare PCIe Root Complex glue driver for Allwinner A733
> (sun60i) SoCs using dw_pcie_host_init().

> +++ b/drivers/pci/controller/dwc/Kconfig
> @@ -487,6 +487,21 @@ config PCIE_STM32_EP
>  	  This driver can also be built as a module. If so, the module
>  	  will be called pcie-stm32-ep.
>  
> +config PCIE_SUNXI
> +	tristate "Allwinner A733 (sun60i) PCIe host controller"

Reorder this so the Kconfig menu stays sorted by vendor.

> +#define SII_INT_MASK0			0x0e00
> +#define INTX_RX_ASSERT_SHIFT		5

Remove *_SHIFT definitions and use FIELD_GET() etc.  See other drivers
for examples.

> +#define INTX_RX_ASSERT_MASK		GENMASK(8, 5)
> +#define INTX_RX_ASSERT(x)		BIT((x) + INTX_RX_ASSERT_SHIFT)

> +static int sunxi_pcie_start_link(struct dw_pcie *pci)
> +{
> +	struct sunxi_pcie *sunxi = to_sunxi_pcie(pci);
> +	u32 val;
> +
> +	if (sunxi->rst_gpio) {
> +		/* Ensure T_PERST-CLK (>= 100 us) after REFCLK is stable */
> +		usleep_range(100, 200);

Use #define from drivers/pci/pci.h for the sleep.  Add one if needed.

> +static int sunxi_pcie_probe(struct platform_device *pdev)
> +{
> +	struct device *dev = &pdev->dev;
> +	struct sunxi_pcie *sunxi;
> +	int ret;
> +
> +	sunxi = devm_kzalloc(dev, sizeof(*sunxi), GFP_KERNEL);
> +	if (!sunxi)
> +		return -ENOMEM;
> +
> +	sunxi->pci.dev = dev;
> +	sunxi->pci.ops = &sunxi_dw_pcie_ops;
> +	sunxi->pci.pp.ops = &sunxi_pcie_host_ops;
> +	raw_spin_lock_init(&sunxi->intx_lock);
> +	platform_set_drvdata(pdev, sunxi);
> +
> +	ret = sunxi_pcie_get_resources(pdev, sunxi);
> +	if (ret)
> +		return ret;
> +
> +	ret = devm_pm_runtime_enable(dev);
> +	if (ret)
> +		return ret;
> +
> +	ret = pm_runtime_resume_and_get(dev);
> +	if (ret < 0)
> +		return ret;
> +
> +	if (sunxi->vpcie3v3) {
> +		ret = regulator_enable(sunxi->vpcie3v3);
> +		if (ret)
> +			goto err_pm;
> +	}
> +
> +	/* Ensure T_PVPERL (100 ms) from power/PERST# assertion before release */
> +	if (sunxi->vpcie3v3 || sunxi->rst_gpio)
> +		msleep(PCIE_T_PVPERL_MS);
> +
> +	ret = clk_set_rate(sunxi->clks[CLK_ID_SLV].clk, PCIE_SLV_CLK_RATE);
> +	if (ret)
> +		goto err_reg;
> +
> +	ret = clk_bulk_prepare_enable(NUM_SUNXI_PCIE_CLKS, sunxi->clks);
> +	if (ret)
> +		goto err_reg;
> +
> +	ret = reset_control_bulk_assert(NUM_SUNXI_PCIE_RSTS, sunxi->rsts);
> +	if (ret)
> +		goto err_clks;
> +
> +	usleep_range(10, 20);

Reference for this?



More information about the linux-arm-kernel mailing list