48
48
#define RCAR_GEN4_PCIE_EP_FUNC_DBI_OFFSET 0x1000
49
49
#define RCAR_GEN4_PCIE_EP_FUNC_DBI2_OFFSET 0x800
50
50
51
+ struct rcar_gen4_pcie ;
51
52
struct rcar_gen4_pcie_drvdata {
53
+ int (* ltssm_control )(struct rcar_gen4_pcie * rcar , bool enable );
52
54
enum dw_pcie_device_mode mode ;
53
55
};
54
56
@@ -61,27 +63,6 @@ struct rcar_gen4_pcie {
61
63
#define to_rcar_gen4_pcie (_dw ) container_of(_dw, struct rcar_gen4_pcie, dw)
62
64
63
65
/* 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
-
85
66
static int rcar_gen4_pcie_link_up (struct dw_pcie * dw )
86
67
{
87
68
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)
127
108
static int rcar_gen4_pcie_start_link (struct dw_pcie * dw )
128
109
{
129
110
struct rcar_gen4_pcie * rcar = to_rcar_gen4_pcie (dw );
130
- int i , changes ;
111
+ int i , changes , ret ;
131
112
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
+ }
133
118
134
119
/*
135
120
* 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)
157
142
{
158
143
struct rcar_gen4_pcie * rcar = to_rcar_gen4_pcie (dw );
159
144
160
- rcar_gen4_pcie_ltssm_enable (rcar , false);
145
+ if (rcar -> drvdata -> ltssm_control )
146
+ rcar -> drvdata -> ltssm_control (rcar , false);
161
147
}
162
148
163
149
static 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)
520
506
rcar_gen4_pcie_unprepare (rcar );
521
507
}
522
508
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
+
523
541
static struct rcar_gen4_pcie_drvdata drvdata_rcar_gen4_pcie = {
524
542
.mode = DW_PCIE_RC_TYPE ,
525
543
};
@@ -529,6 +547,14 @@ static struct rcar_gen4_pcie_drvdata drvdata_rcar_gen4_pcie_ep = {
529
547
};
530
548
531
549
static 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
+ },
532
558
{
533
559
.compatible = "renesas,rcar-gen4-pcie" ,
534
560
.data = & drvdata_rcar_gen4_pcie ,
0 commit comments