@@ -36,6 +36,8 @@ struct stmmac_resources {
int sfty_ue_irq;
int rx_irq[MTL_MAX_RX_QUEUES];
int tx_irq[MTL_MAX_TX_QUEUES];
+
+ const struct stmmac_axi *axi;
};
enum stmmac_txbuf_type {
@@ -87,38 +87,61 @@ static int dwmac1000_validate_ucast_entries(struct device *dev,
/**
* stmmac_axi_setup - parse DT parameters for programming the AXI register
* @pdev: platform device
+ * @res: driver-specific parameters
* Description:
- * if required, from device-tree the AXI internal register can be tuned
- * by using platform parameters.
+ * Use driver-specific defaults for the AXI internal registers if available,
+ * or parse them from device tree, if present. Driver-specific defaults can
+ * be overridden by the values from device tree.
*/
-static struct stmmac_axi *stmmac_axi_setup(struct platform_device *pdev)
+static struct stmmac_axi *stmmac_axi_setup(struct platform_device *pdev,
+ struct stmmac_resources *res)
{
struct device_node *np;
struct stmmac_axi *axi;
+ /*
+ * Exit early if the driver hasn't provided any defaults and the
+ * device tree doesn't specify values for the AXI configuration.
+ */
np = of_parse_phandle(pdev->dev.of_node, "snps,axi-config", 0);
- if (!np)
+ if (!np && !res->axi)
return NULL;
axi = devm_kzalloc(&pdev->dev, sizeof(*axi), GFP_KERNEL);
if (!axi) {
- of_node_put(np);
+ if (np)
+ of_node_put(np);
+
return ERR_PTR(-ENOMEM);
}
- axi->axi_lpi_en = of_property_read_bool(np, "snps,lpi_en");
- axi->axi_xit_frm = of_property_read_bool(np, "snps,xit_frm");
- axi->axi_kbbe = of_property_read_bool(np, "snps,kbbe");
- axi->axi_fb = of_property_read_bool(np, "snps,fb");
- axi->axi_mb = of_property_read_bool(np, "snps,mb");
- axi->axi_rb = of_property_read_bool(np, "snps,rb");
+ /* copy defaults provided by the driver */
+ if (res->axi)
+ *axi = *res->axi;
+
+ /* override defaults with data from DT */
+ if (np) {
+ axi->axi_lpi_en = of_property_read_bool(np, "snps,lpi_en");
+ axi->axi_xit_frm = of_property_read_bool(np, "snps,xit_frm");
+ axi->axi_kbbe = of_property_read_bool(np, "snps,kbbe");
+ axi->axi_fb = of_property_read_bool(np, "snps,fb");
+ axi->axi_mb = of_property_read_bool(np, "snps,mb");
+ axi->axi_rb = of_property_read_bool(np, "snps,rb");
+
+ if (of_property_read_u32(np, "snps,wr_osr_lmt", &axi->axi_wr_osr_lmt)) {
+ if (!res->axi)
+ axi->axi_wr_osr_lmt = 1;
+ }
- if (of_property_read_u32(np, "snps,wr_osr_lmt", &axi->axi_wr_osr_lmt))
- axi->axi_wr_osr_lmt = 1;
- if (of_property_read_u32(np, "snps,rd_osr_lmt", &axi->axi_rd_osr_lmt))
- axi->axi_rd_osr_lmt = 1;
- of_property_read_u32_array(np, "snps,blen", axi->axi_blen, AXI_BLEN);
- of_node_put(np);
+ if (of_property_read_u32(np, "snps,rd_osr_lmt", &axi->axi_rd_osr_lmt)) {
+ if (!res->axi)
+ axi->axi_rd_osr_lmt = 1;
+ }
+
+ of_property_read_u32_array(np, "snps,blen", axi->axi_blen, AXI_BLEN);
+
+ of_node_put(np);
+ }
return axi;
}
@@ -606,7 +629,7 @@ stmmac_probe_config_dt(struct platform_device *pdev,
of_property_read_u32(np, "snps,ps-speed", &plat->mac_port_sel_speed);
- plat->axi = stmmac_axi_setup(pdev);
+ plat->axi = stmmac_axi_setup(pdev, res);
rc = stmmac_mtl_setup(pdev, plat);
if (rc) {