4848#define RCAR_GEN4_PCIE_EP_FUNC_DBI_OFFSET 0x1000
4949#define RCAR_GEN4_PCIE_EP_FUNC_DBI2_OFFSET 0x800
5050
51+ struct rcar_gen4_pcie ;
5152struct rcar_gen4_pcie_drvdata {
53+ int (* ltssm_control )(struct rcar_gen4_pcie * rcar , bool enable );
5254 enum dw_pcie_device_mode mode ;
5355};
5456
@@ -61,27 +63,6 @@ struct rcar_gen4_pcie {
6163#define to_rcar_gen4_pcie (_dw ) container_of(_dw, struct rcar_gen4_pcie, dw)
6264
6365/* Common */
64- static void rcar_gen4_pcie_ltssm_enable (struct rcar_gen4_pcie * rcar ,
65- bool enable )
66- {
67- u32 val ;
68-
69- val = readl (rcar -> base + PCIERSTCTRL1 );
70- if (enable ) {
71- val |= APP_LTSSM_ENABLE ;
72- val &= ~APP_HOLD_PHY_RST ;
73- } else {
74- /*
75- * Since the datasheet of R-Car doesn't mention how to assert
76- * the APP_HOLD_PHY_RST, don't assert it again. Otherwise,
77- * hang-up issue happened in the dw_edma_core_off() when
78- * the controller didn't detect a PCI device.
79- */
80- val &= ~APP_LTSSM_ENABLE ;
81- }
82- writel (val , rcar -> base + PCIERSTCTRL1 );
83- }
84-
8566static int rcar_gen4_pcie_link_up (struct dw_pcie * dw )
8667{
8768 struct rcar_gen4_pcie * rcar = to_rcar_gen4_pcie (dw );
@@ -127,9 +108,13 @@ static int rcar_gen4_pcie_speed_change(struct dw_pcie *dw)
127108static int rcar_gen4_pcie_start_link (struct dw_pcie * dw )
128109{
129110 struct rcar_gen4_pcie * rcar = to_rcar_gen4_pcie (dw );
130- int i , changes ;
111+ int i , changes , ret ;
131112
132- rcar_gen4_pcie_ltssm_enable (rcar , true);
113+ if (rcar -> drvdata -> ltssm_control ) {
114+ ret = rcar -> drvdata -> ltssm_control (rcar , true);
115+ if (ret )
116+ return ret ;
117+ }
133118
134119 /*
135120 * Require direct speed change with retrying here if the link_gen is
@@ -157,7 +142,8 @@ static void rcar_gen4_pcie_stop_link(struct dw_pcie *dw)
157142{
158143 struct rcar_gen4_pcie * rcar = to_rcar_gen4_pcie (dw );
159144
160- rcar_gen4_pcie_ltssm_enable (rcar , false);
145+ if (rcar -> drvdata -> ltssm_control )
146+ rcar -> drvdata -> ltssm_control (rcar , false);
161147}
162148
163149static int rcar_gen4_pcie_common_init (struct rcar_gen4_pcie * rcar )
@@ -520,6 +506,38 @@ static void rcar_gen4_pcie_remove(struct platform_device *pdev)
520506 rcar_gen4_pcie_unprepare (rcar );
521507}
522508
509+ static int r8a779f0_pcie_ltssm_control (struct rcar_gen4_pcie * rcar , bool enable )
510+ {
511+ u32 val ;
512+
513+ val = readl (rcar -> base + PCIERSTCTRL1 );
514+ if (enable ) {
515+ val |= APP_LTSSM_ENABLE ;
516+ val &= ~APP_HOLD_PHY_RST ;
517+ } else {
518+ /*
519+ * Since the datasheet of R-Car doesn't mention how to assert
520+ * the APP_HOLD_PHY_RST, don't assert it again. Otherwise,
521+ * hang-up issue happened in the dw_edma_core_off() when
522+ * the controller didn't detect a PCI device.
523+ */
524+ val &= ~APP_LTSSM_ENABLE ;
525+ }
526+ writel (val , rcar -> base + PCIERSTCTRL1 );
527+
528+ return 0 ;
529+ }
530+
531+ static struct rcar_gen4_pcie_drvdata drvdata_r8a779f0_pcie = {
532+ .ltssm_control = r8a779f0_pcie_ltssm_control ,
533+ .mode = DW_PCIE_RC_TYPE ,
534+ };
535+
536+ static struct rcar_gen4_pcie_drvdata drvdata_r8a779f0_pcie_ep = {
537+ .ltssm_control = r8a779f0_pcie_ltssm_control ,
538+ .mode = DW_PCIE_EP_TYPE ,
539+ };
540+
523541static struct rcar_gen4_pcie_drvdata drvdata_rcar_gen4_pcie = {
524542 .mode = DW_PCIE_RC_TYPE ,
525543};
@@ -529,6 +547,14 @@ static struct rcar_gen4_pcie_drvdata drvdata_rcar_gen4_pcie_ep = {
529547};
530548
531549static const struct of_device_id rcar_gen4_pcie_of_match [] = {
550+ {
551+ .compatible = "renesas,r8a779f0-pcie" ,
552+ .data = & drvdata_r8a779f0_pcie ,
553+ },
554+ {
555+ .compatible = "renesas,r8a779f0-pcie-ep" ,
556+ .data = & drvdata_r8a779f0_pcie_ep ,
557+ },
532558 {
533559 .compatible = "renesas,rcar-gen4-pcie" ,
534560 .data = & drvdata_rcar_gen4_pcie ,
0 commit comments