Message ID | 1594371110-7580-1-git-send-email-lizhi01@loongson.cn |
---|---|
State | Changes Requested |
Delegated to: | David Miller |
Headers | show |
Series | stmmac: pci: Add support for LS7A bridge chip | expand |
On Fri, 10 Jul 2020 16:51:50 +0800 Zhi Li wrote: > Add gmac platform data to support LS7A bridge chip. > > Co-developed-by: Hongbin Li <lihongbin@loongson.cn> > Signed-off-by: Hongbin Li <lihongbin@loongson.cn> > Signed-off-by: Zhi Li <lizhi01@loongson.cn> This appears to not build with allmodconfig: ../drivers/net/ethernet/stmicro/stmmac/stmmac_pci.c:22:62: note: expected ‘struct plat_stmmacenet_data *’ but argument is of type ‘struct plat_stmmacenent_data *’ 22 | static void common_default_data(struct plat_stmmacenet_data *plat) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~ ../drivers/net/ethernet/stmicro/stmmac/stmmac_pci.c:145:6: error: invalid use of undefined type ‘struct plat_stmmacenent_data’ 145 | plat->bus_id = pci_dev_id(pdev); | ^~ ../drivers/net/ethernet/stmicro/stmmac/stmmac_pci.c:146:6: error: invalid use of undefined type ‘struct plat_stmmacenent_data’ 146 | plat->phy_addr = 0; | ^~ ../drivers/net/ethernet/stmicro/stmmac/stmmac_pci.c:147:6: error: invalid use of undefined type ‘struct plat_stmmacenent_data’ 147 | plat->interface = PHY_INTERFACE_MODE_GMII; | ^~ ../drivers/net/ethernet/stmicro/stmmac/stmmac_pci.c:149:6: error: invalid use of undefined type ‘struct plat_stmmacenent_data’ 149 | plat->dma_cfg->pbl = 32; | ^~ ../drivers/net/ethernet/stmicro/stmmac/stmmac_pci.c:150:6: error: invalid use of undefined type ‘struct plat_stmmacenent_data’ 150 | plat->dma_cfg->pblx8 = true; | ^~ ../drivers/net/ethernet/stmicro/stmmac/stmmac_pci.c: At top level: ../drivers/net/ethernet/stmicro/stmmac/stmmac_pci.c:156:11: error: initialization of ‘int (*)(struct pci_dev *, struct plat_stmmacenet_data *)’ from incompatible pointer type ‘int (*)(struct pci_dev *, struct plat_stmmacenent_data *)’ [-Werror=incompatible-pointer-types] 156 | .setup = loongson_default_data; | ^~~~~~~~~~~~~~~~~~~~~ ../drivers/net/ethernet/stmicro/stmmac/stmmac_pci.c:156:11: note: (near initialization for ‘loongson_pci_info.setup’) ../drivers/net/ethernet/stmicro/stmmac/stmmac_pci.c:156:32: error: expected ‘}’ before ‘;’ token 156 | .setup = loongson_default_data; | ^ ../drivers/net/ethernet/stmicro/stmmac/stmmac_pci.c:155:51: note: to match this ‘{’ 155 | static struct stmmac_pci_info loongson_pci_info = { | ^ cc1: some warnings being treated as errors make[6]: *** [drivers/net/ethernet/stmicro/stmmac/stmmac_pci.o] Error 1 make[5]: *** [drivers/net/ethernet/stmicro/stmmac] Error 2 make[4]: *** [drivers/net/ethernet/stmicro] Error 2 make[3]: *** [drivers/net/ethernet] Error 2 make[2]: *** [drivers/net] Error 2 make[2]: *** Waiting for unfinished jobs.... make[1]: *** [drivers] Error 2 make: *** [__sub-make] Error 2
在 2020/7/10 16:51, Zhi Li 写道: > Add gmac platform data to support LS7A bridge chip. > > Co-developed-by: Hongbin Li <lihongbin@loongson.cn> > Signed-off-by: Hongbin Li <lihongbin@loongson.cn> > Signed-off-by: Zhi Li <lizhi01@loongson.cn> > --- > drivers/net/ethernet/stmicro/stmmac/stmmac_pci.c | 22 ++++++++++++++++++++++ > 1 file changed, 22 insertions(+) > > diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_pci.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_pci.c > index 272cb47..dab2a40 100644 > --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_pci.c > +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_pci.c > @@ -138,6 +138,24 @@ static const struct stmmac_pci_info snps_gmac5_pci_info = { > .setup = snps_gmac5_default_data, > }; > > +static int loongson_default_data(struct pci_dev *pdev, struct plat_stmmacenent_data *plat) > +{ > + common_default_data(plat); > + > + plat->bus_id = pci_dev_id(pdev); > + plat->phy_addr = 0; > + plat->interface = PHY_INTERFACE_MODE_GMII; > + > + plat->dma_cfg->pbl = 32; > + plat->dma_cfg->pblx8 = true; > + > + return 0; > +} > + > +static struct stmmac_pci_info loongson_pci_info = { > + .setup = loongson_default_data; > +}; > + > /** > * stmmac_pci_probe > * > @@ -204,6 +222,8 @@ static int stmmac_pci_probe(struct pci_dev *pdev, > res.addr = pcim_iomap_table(pdev)[i]; > res.wol_irq = pdev->irq; > res.irq = pdev->irq; > + if (pdev->vendor == PCI_VENDOR_ID_LOONGSON) > + res.lpi_irq = pdev->irq + 1; This can never work. We're allocating IRQs by irq_domain, not ID. Please describe IRQ in DeviceTree, and *DO NOT* sne dout untested patch. Thanks. > > return stmmac_dvr_probe(&pdev->dev, plat, &res); > } > @@ -273,11 +293,13 @@ static SIMPLE_DEV_PM_OPS(stmmac_pm_ops, stmmac_pci_suspend, stmmac_pci_resume); > > #define PCI_DEVICE_ID_STMMAC_STMMAC 0x1108 > #define PCI_DEVICE_ID_SYNOPSYS_GMAC5_ID 0x7102 > +#define PCI_DEVICE_ID_LOONGSON_GMAC 0x7a03 > > static const struct pci_device_id stmmac_id_table[] = { > { PCI_DEVICE_DATA(STMMAC, STMMAC, &stmmac_pci_info) }, > { PCI_DEVICE_DATA(STMICRO, MAC, &stmmac_pci_info) }, > { PCI_DEVICE_DATA(SYNOPSYS, GMAC5_ID, &snps_gmac5_pci_info) }, > + { PCI_DEVICE_DATA(LOONGSON, GMAC, &loongson_pci_info) }, > {} > }; > - Jiaxun
在 2020/7/11 9:35, Jiaxun Yang 写道: > > > 在 2020/7/10 16:51, Zhi Li 写道: >> Add gmac platform data to support LS7A bridge chip. >> >> Co-developed-by: Hongbin Li <lihongbin@loongson.cn> >> Signed-off-by: Hongbin Li <lihongbin@loongson.cn> >> Signed-off-by: Zhi Li <lizhi01@loongson.cn> >> --- >> drivers/net/ethernet/stmicro/stmmac/stmmac_pci.c | 22 >> ++++++++++++++++++++++ >> 1 file changed, 22 insertions(+) >> >> diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_pci.c >> b/drivers/net/ethernet/stmicro/stmmac/stmmac_pci.c >> index 272cb47..dab2a40 100644 >> --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_pci.c >> +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_pci.c >> @@ -138,6 +138,24 @@ static const struct stmmac_pci_info >> snps_gmac5_pci_info = { >> .setup = snps_gmac5_default_data, >> }; >> +static int loongson_default_data(struct pci_dev *pdev, struct >> plat_stmmacenent_data *plat) >> +{ >> + common_default_data(plat); >> + >> + plat->bus_id = pci_dev_id(pdev); >> + plat->phy_addr = 0; >> + plat->interface = PHY_INTERFACE_MODE_GMII; >> + >> + plat->dma_cfg->pbl = 32; >> + plat->dma_cfg->pblx8 = true; >> + >> + return 0; >> +} >> + >> +static struct stmmac_pci_info loongson_pci_info = { >> + .setup = loongson_default_data; >> +}; >> + >> /** >> * stmmac_pci_probe >> * >> @@ -204,6 +222,8 @@ static int stmmac_pci_probe(struct pci_dev *pdev, >> res.addr = pcim_iomap_table(pdev)[i]; >> res.wol_irq = pdev->irq; >> res.irq = pdev->irq; >> + if (pdev->vendor == PCI_VENDOR_ID_LOONGSON) >> + res.lpi_irq = pdev->irq + 1; > > This can never work. > We're allocating IRQs by irq_domain, not ID. > Please describe IRQ in DeviceTree, and *DO NOT* sne dout untested patch. Oops, ^ send out FYI: Here is my solution of GMAC[1] [2], I was too busy to upstream it. We're using totally different structure than Loongson's out of tree Kernel, especially in IRQ management. Please don't simply copy 'n paste code from your company's internal kernel. Please try to understand how upstream kernel is working and test your patches with upstrem kernel. [1]: https://github.com/FlyGoat/linux/commit/9d6584c186a8007f14dc8bb2524e48a2fd7d689a [2]: https://github.com/FlyGoat/linux/commit/558a256acfeb022e132113e7952a9df3df375302 > > Thanks. > >> return stmmac_dvr_probe(&pdev->dev, plat, &res); >> } >> @@ -273,11 +293,13 @@ static SIMPLE_DEV_PM_OPS(stmmac_pm_ops, >> stmmac_pci_suspend, stmmac_pci_resume); >> #define PCI_DEVICE_ID_STMMAC_STMMAC 0x1108 >> #define PCI_DEVICE_ID_SYNOPSYS_GMAC5_ID 0x7102 >> +#define PCI_DEVICE_ID_LOONGSON_GMAC 0x7a03 >> static const struct pci_device_id stmmac_id_table[] = { >> { PCI_DEVICE_DATA(STMMAC, STMMAC, &stmmac_pci_info) }, >> { PCI_DEVICE_DATA(STMICRO, MAC, &stmmac_pci_info) }, >> { PCI_DEVICE_DATA(SYNOPSYS, GMAC5_ID, &snps_gmac5_pci_info) }, >> + { PCI_DEVICE_DATA(LOONGSON, GMAC, &loongson_pci_info) }, >> {} >> }; > - Jiaxun
diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_pci.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_pci.c index 272cb47..dab2a40 100644 --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_pci.c +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_pci.c @@ -138,6 +138,24 @@ static const struct stmmac_pci_info snps_gmac5_pci_info = { .setup = snps_gmac5_default_data, }; +static int loongson_default_data(struct pci_dev *pdev, struct plat_stmmacenent_data *plat) +{ + common_default_data(plat); + + plat->bus_id = pci_dev_id(pdev); + plat->phy_addr = 0; + plat->interface = PHY_INTERFACE_MODE_GMII; + + plat->dma_cfg->pbl = 32; + plat->dma_cfg->pblx8 = true; + + return 0; +} + +static struct stmmac_pci_info loongson_pci_info = { + .setup = loongson_default_data; +}; + /** * stmmac_pci_probe * @@ -204,6 +222,8 @@ static int stmmac_pci_probe(struct pci_dev *pdev, res.addr = pcim_iomap_table(pdev)[i]; res.wol_irq = pdev->irq; res.irq = pdev->irq; + if (pdev->vendor == PCI_VENDOR_ID_LOONGSON) + res.lpi_irq = pdev->irq + 1; return stmmac_dvr_probe(&pdev->dev, plat, &res); } @@ -273,11 +293,13 @@ static SIMPLE_DEV_PM_OPS(stmmac_pm_ops, stmmac_pci_suspend, stmmac_pci_resume); #define PCI_DEVICE_ID_STMMAC_STMMAC 0x1108 #define PCI_DEVICE_ID_SYNOPSYS_GMAC5_ID 0x7102 +#define PCI_DEVICE_ID_LOONGSON_GMAC 0x7a03 static const struct pci_device_id stmmac_id_table[] = { { PCI_DEVICE_DATA(STMMAC, STMMAC, &stmmac_pci_info) }, { PCI_DEVICE_DATA(STMICRO, MAC, &stmmac_pci_info) }, { PCI_DEVICE_DATA(SYNOPSYS, GMAC5_ID, &snps_gmac5_pci_info) }, + { PCI_DEVICE_DATA(LOONGSON, GMAC, &loongson_pci_info) }, {} };