1111 * ARM PCI Host generic driver.
1212 */
1313
14+ #include <linux/bitfield.h>
1415#include <linux/bitrev.h>
1516#include <linux/clk.h>
1617#include <linux/delay.h>
@@ -40,18 +41,18 @@ static void rockchip_pcie_enable_bw_int(struct rockchip_pcie *rockchip)
4041{
4142 u32 status ;
4243
43- status = rockchip_pcie_read (rockchip , PCIE_RC_CONFIG_LCS );
44+ status = rockchip_pcie_read (rockchip , PCIE_RC_CONFIG_CR + PCI_EXP_LNKCTL );
4445 status |= (PCI_EXP_LNKCTL_LBMIE | PCI_EXP_LNKCTL_LABIE );
45- rockchip_pcie_write (rockchip , status , PCIE_RC_CONFIG_LCS );
46+ rockchip_pcie_write (rockchip , status , PCIE_RC_CONFIG_CR + PCI_EXP_LNKCTL );
4647}
4748
4849static void rockchip_pcie_clr_bw_int (struct rockchip_pcie * rockchip )
4950{
5051 u32 status ;
5152
52- status = rockchip_pcie_read (rockchip , PCIE_RC_CONFIG_LCS );
53+ status = rockchip_pcie_read (rockchip , PCIE_RC_CONFIG_CR + PCI_EXP_LNKCTL );
5354 status |= (PCI_EXP_LNKSTA_LBMS | PCI_EXP_LNKSTA_LABS ) << 16 ;
54- rockchip_pcie_write (rockchip , status , PCIE_RC_CONFIG_LCS );
55+ rockchip_pcie_write (rockchip , status , PCIE_RC_CONFIG_CR + PCI_EXP_LNKCTL );
5556}
5657
5758static void rockchip_pcie_update_txcredit_mui (struct rockchip_pcie * rockchip )
@@ -269,7 +270,7 @@ static void rockchip_pcie_set_power_limit(struct rockchip_pcie *rockchip)
269270 scale = 3 ; /* 0.001x */
270271 curr = curr / 1000 ; /* convert to mA */
271272 power = (curr * 3300 ) / 1000 ; /* milliwatt */
272- while (power > PCIE_RC_CONFIG_DCR_CSPL_LIMIT ) {
273+ while (power > FIELD_MAX ( PCI_EXP_DEVCAP_PWR_VAL ) ) {
273274 if (!scale ) {
274275 dev_warn (rockchip -> dev , "invalid power supply\n" );
275276 return ;
@@ -278,10 +279,10 @@ static void rockchip_pcie_set_power_limit(struct rockchip_pcie *rockchip)
278279 power = power / 10 ;
279280 }
280281
281- status = rockchip_pcie_read (rockchip , PCIE_RC_CONFIG_DCR );
282- status |= ( power << PCIE_RC_CONFIG_DCR_CSPL_SHIFT ) |
283- ( scale << PCIE_RC_CONFIG_DCR_CPLS_SHIFT );
284- rockchip_pcie_write (rockchip , status , PCIE_RC_CONFIG_DCR );
282+ status = rockchip_pcie_read (rockchip , PCIE_RC_CONFIG_CR + PCI_EXP_DEVCAP );
283+ status |= FIELD_PREP ( PCI_EXP_DEVCAP_PWR_VAL , power );
284+ status |= FIELD_PREP ( PCI_EXP_DEVCAP_PWR_SCL , scale );
285+ rockchip_pcie_write (rockchip , status , PCIE_RC_CONFIG_CR + PCI_EXP_DEVCAP );
285286}
286287
287288/**
@@ -309,14 +310,14 @@ static int rockchip_pcie_host_init_port(struct rockchip_pcie *rockchip)
309310 rockchip_pcie_set_power_limit (rockchip );
310311
311312 /* Set RC's clock architecture as common clock */
312- status = rockchip_pcie_read (rockchip , PCIE_RC_CONFIG_LCS );
313+ status = rockchip_pcie_read (rockchip , PCIE_RC_CONFIG_CR + PCI_EXP_LNKCTL );
313314 status |= PCI_EXP_LNKSTA_SLC << 16 ;
314- rockchip_pcie_write (rockchip , status , PCIE_RC_CONFIG_LCS );
315+ rockchip_pcie_write (rockchip , status , PCIE_RC_CONFIG_CR + PCI_EXP_LNKCTL );
315316
316317 /* Set RC's RCB to 128 */
317- status = rockchip_pcie_read (rockchip , PCIE_RC_CONFIG_LCS );
318+ status = rockchip_pcie_read (rockchip , PCIE_RC_CONFIG_CR + PCI_EXP_LNKCTL );
318319 status |= PCI_EXP_LNKCTL_RCB ;
319- rockchip_pcie_write (rockchip , status , PCIE_RC_CONFIG_LCS );
320+ rockchip_pcie_write (rockchip , status , PCIE_RC_CONFIG_CR + PCI_EXP_LNKCTL );
320321
321322 /* Enable Gen1 training */
322323 rockchip_pcie_write (rockchip , PCIE_CLIENT_LINK_TRAIN_ENABLE ,
@@ -341,9 +342,9 @@ static int rockchip_pcie_host_init_port(struct rockchip_pcie *rockchip)
341342 * Enable retrain for gen2. This should be configured only after
342343 * gen1 finished.
343344 */
344- status = rockchip_pcie_read (rockchip , PCIE_RC_CONFIG_LCS );
345+ status = rockchip_pcie_read (rockchip , PCIE_RC_CONFIG_CR + PCI_EXP_LNKCTL );
345346 status |= PCI_EXP_LNKCTL_RL ;
346- rockchip_pcie_write (rockchip , status , PCIE_RC_CONFIG_LCS );
347+ rockchip_pcie_write (rockchip , status , PCIE_RC_CONFIG_CR + PCI_EXP_LNKCTL );
347348
348349 err = readl_poll_timeout (rockchip -> apb_base + PCIE_CORE_CTRL ,
349350 status , PCIE_LINK_IS_GEN2 (status ), 20 ,
@@ -380,15 +381,15 @@ static int rockchip_pcie_host_init_port(struct rockchip_pcie *rockchip)
380381
381382 /* Clear L0s from RC's link cap */
382383 if (of_property_read_bool (dev -> of_node , "aspm-no-l0s" )) {
383- status = rockchip_pcie_read (rockchip , PCIE_RC_CONFIG_LINK_CAP );
384- status &= ~PCIE_RC_CONFIG_LINK_CAP_L0S ;
385- rockchip_pcie_write (rockchip , status , PCIE_RC_CONFIG_LINK_CAP );
384+ status = rockchip_pcie_read (rockchip , PCIE_RC_CONFIG_CR + PCI_EXP_LNKCAP );
385+ status &= ~PCI_EXP_LNKCAP_ASPM_L0S ;
386+ rockchip_pcie_write (rockchip , status , PCIE_RC_CONFIG_CR + PCI_EXP_LNKCAP );
386387 }
387388
388- status = rockchip_pcie_read (rockchip , PCIE_RC_CONFIG_DCSR );
389- status &= ~PCIE_RC_CONFIG_DCSR_MPS_MASK ;
390- status |= PCIE_RC_CONFIG_DCSR_MPS_256 ;
391- rockchip_pcie_write (rockchip , status , PCIE_RC_CONFIG_DCSR );
389+ status = rockchip_pcie_read (rockchip , PCIE_RC_CONFIG_CR + PCI_EXP_DEVCTL );
390+ status &= ~PCI_EXP_DEVCTL_PAYLOAD ;
391+ status |= PCI_EXP_DEVCTL_PAYLOAD_256B ;
392+ rockchip_pcie_write (rockchip , status , PCIE_RC_CONFIG_CR + PCI_EXP_DEVCTL );
392393
393394 return 0 ;
394395err_power_off_phy :
0 commit comments