[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID:
<MAUPR01MB110724EF2C8233B40B1E485C6FE05A@MAUPR01MB11072.INDPRD01.PROD.OUTLOOK.COM>
Date: Sat, 30 Aug 2025 09:42:14 +0800
From: Chen Wang <unicorn_wang@...look.com>
To: Rob Herring <robh@...nel.org>, Chen Wang <unicornxw@...il.com>
Cc: kwilczynski@...nel.org, u.kleine-koenig@...libre.com,
aou@...s.berkeley.edu, alex@...ti.fr, arnd@...db.de, bwawrzyn@...co.com,
bhelgaas@...gle.com, conor+dt@...nel.org, 18255117159@....com,
inochiama@...il.com, kishon@...nel.org, krzk+dt@...nel.org,
lpieralisi@...nel.org, mani@...nel.org, palmer@...belt.com,
paul.walmsley@...ive.com, s-vadapalli@...com, tglx@...utronix.de,
thomas.richard@...tlin.com, sycamoremoon376@...il.com,
devicetree@...r.kernel.org, linux-kernel@...r.kernel.org,
linux-pci@...r.kernel.org, linux-riscv@...ts.infradead.org,
sophgo@...ts.linux.dev, rabenda.cn@...il.com, chao.wei@...hgo.com,
xiaoguang.xing@...hgo.com, fengchun.li@...hgo.com
Subject: Re: [PATCH 3/5] PCI: sg2042: Add Sophgo SG2042 PCIe driver
On 8/30/2025 1:09 AM, Rob Herring wrote:
> On Thu, Aug 28, 2025 at 10:17:40AM +0800, Chen Wang wrote:
[......]
>> diff --git a/drivers/pci/controller/cadence/pcie-sg2042.c b/drivers/pci/controller/cadence/pcie-sg2042.c
>> new file mode 100644
>> index 000000000000..fe434dc2967e
>> --- /dev/null
>> +++ b/drivers/pci/controller/cadence/pcie-sg2042.c
>> @@ -0,0 +1,134 @@
>> +// SPDX-License-Identifier: GPL-2.0
>> +/*
>> + * pcie-sg2042 - PCIe controller driver for Sophgo SG2042 SoC
>> + *
>> + * Copyright (C) 2025 Sophgo Technology Inc.
>> + * Copyright (C) 2025 Chen Wang <unicorn_wang@...look.com>
>> + */
>> +
>> +#include <linux/kernel.h>
>> +#include <linux/of.h>
> Looks like you just need mod_devicetable.h instead.
Thanks, I tried and seems just mod_devicetable.h does work.
To be honest, I am more curious about how to know which header files
should be included. Is it just based on experience, because sometimes
including these or those header files will compile without any problems.
>> +#include <linux/pci.h>
>> +#include <linux/platform_device.h>
>> +#include <linux/pm_runtime.h>
>> +
>> +#include "pcie-cadence.h"
>> +
>> +/*
>> + * SG2042 only support 4-byte aligned access, so for the rootbus (i.e. to read
>> + * the Root Port itself, read32 is required. For non-rootbus (i.e. to read
>> + * the PCIe peripheral registers, supports 1/2/4 byte aligned access, so
>> + * directly using read should be fine.
>> + *
>> + * The same is true for write.
>> + */
>> +static int sg2042_pcie_config_read(struct pci_bus *bus, unsigned int devfn,
>> + int where, int size, u32 *value)
>> +{
>> + if (pci_is_root_bus(bus))
> You can have separate pci_ops for the root bus and child buses. Do that
> and then sg2042_pcie_config_read() goes away. IIRC, there's examples in
> the tree of your exact issue (root bus being 32-bit only).
Yes, you're right, I learned it. Thanks,
>> + return pci_generic_config_read32(bus, devfn, where, size,
>> + value);
>> +
>> + return pci_generic_config_read(bus, devfn, where, size, value);
>> +}
>> +
>> +static int sg2042_pcie_config_write(struct pci_bus *bus, unsigned int devfn,
>> + int where, int size, u32 value)
>> +{
>> + if (pci_is_root_bus(bus))
>> + return pci_generic_config_write32(bus, devfn, where, size,
>> + value);
>> +
>> + return pci_generic_config_write(bus, devfn, where, size, value);
>> +}
>> +
>> +static struct pci_ops sg2042_pcie_host_ops = {
>> + .map_bus = cdns_pci_map_bus,
>> + .read = sg2042_pcie_config_read,
>> + .write = sg2042_pcie_config_write,
>> +};
>> +
[......]
>> +
>> +static struct platform_driver sg2042_pcie_driver = {
>> + .driver = {
>> + .name = "sg2042-pcie",
>> + .of_match_table = sg2042_pcie_of_match,
>> + .pm = &cdns_pcie_pm_ops,
>> + },
>> + .probe = sg2042_pcie_probe,
>> + .shutdown = sg2042_pcie_shutdown,
>> +};
>> +builtin_platform_driver(sg2042_pcie_driver);
> What prevents this from being a module?
Well, I'll check again.
Thanks.
Chen
> Rob
>
Powered by blists - more mailing lists