@@ -239,8 +239,8 @@ struct pcie_cfg_data {
239239 const enum pcie_type type ;
240240 const bool has_phy ;
241241 u8 num_inbound_wins ;
242- void (* perst_set )(struct brcm_pcie * pcie , u32 val );
243- void (* bridge_sw_init_set )(struct brcm_pcie * pcie , u32 val );
242+ int (* perst_set )(struct brcm_pcie * pcie , u32 val );
243+ int (* bridge_sw_init_set )(struct brcm_pcie * pcie , u32 val );
244244};
245245
246246struct subdev_regulators {
@@ -285,8 +285,8 @@ struct brcm_pcie {
285285 int num_memc ;
286286 u64 memc_size [PCIE_BRCM_MAX_MEMC ];
287287 u32 hw_rev ;
288- void (* perst_set )(struct brcm_pcie * pcie , u32 val );
289- void (* bridge_sw_init_set )(struct brcm_pcie * pcie , u32 val );
288+ int (* perst_set )(struct brcm_pcie * pcie , u32 val );
289+ int (* bridge_sw_init_set )(struct brcm_pcie * pcie , u32 val );
290290 struct subdev_regulators * sr ;
291291 bool ep_wakeup_capable ;
292292 bool has_phy ;
@@ -749,63 +749,83 @@ static void __iomem *brcm7425_pcie_map_bus(struct pci_bus *bus,
749749 return base + DATA_ADDR (pcie );
750750}
751751
752- static void brcm_pcie_bridge_sw_init_set_generic (struct brcm_pcie * pcie , u32 val )
752+ static int brcm_pcie_bridge_sw_init_set_generic (struct brcm_pcie * pcie , u32 val )
753753{
754754 u32 tmp , mask = RGR1_SW_INIT_1_INIT_GENERIC_MASK ;
755755 u32 shift = RGR1_SW_INIT_1_INIT_GENERIC_SHIFT ;
756+ int ret = 0 ;
756757
757758 if (pcie -> bridge_reset ) {
758759 if (val )
759- reset_control_assert (pcie -> bridge_reset );
760+ ret = reset_control_assert (pcie -> bridge_reset );
760761 else
761- reset_control_deassert (pcie -> bridge_reset );
762+ ret = reset_control_deassert (pcie -> bridge_reset );
762763
763- return ;
764+ if (ret )
765+ dev_err (pcie -> dev , "failed to %s 'bridge' reset, err=%d\n" ,
766+ val ? "assert" : "deassert" , ret );
767+
768+ return ret ;
764769 }
765770
766771 tmp = readl (pcie -> base + PCIE_RGR1_SW_INIT_1 (pcie ));
767772 tmp = (tmp & ~mask ) | ((val << shift ) & mask );
768773 writel (tmp , pcie -> base + PCIE_RGR1_SW_INIT_1 (pcie ));
774+
775+ return ret ;
769776}
770777
771- static void brcm_pcie_bridge_sw_init_set_7278 (struct brcm_pcie * pcie , u32 val )
778+ static int brcm_pcie_bridge_sw_init_set_7278 (struct brcm_pcie * pcie , u32 val )
772779{
773780 u32 tmp , mask = RGR1_SW_INIT_1_INIT_7278_MASK ;
774781 u32 shift = RGR1_SW_INIT_1_INIT_7278_SHIFT ;
775782
776783 tmp = readl (pcie -> base + PCIE_RGR1_SW_INIT_1 (pcie ));
777784 tmp = (tmp & ~mask ) | ((val << shift ) & mask );
778785 writel (tmp , pcie -> base + PCIE_RGR1_SW_INIT_1 (pcie ));
786+
787+ return 0 ;
779788}
780789
781- static void brcm_pcie_perst_set_4908 (struct brcm_pcie * pcie , u32 val )
790+ static int brcm_pcie_perst_set_4908 (struct brcm_pcie * pcie , u32 val )
782791{
792+ int ret ;
793+
783794 if (WARN_ONCE (!pcie -> perst_reset , "missing PERST# reset controller\n" ))
784- return ;
795+ return - EINVAL ;
785796
786797 if (val )
787- reset_control_assert (pcie -> perst_reset );
798+ ret = reset_control_assert (pcie -> perst_reset );
788799 else
789- reset_control_deassert (pcie -> perst_reset );
800+ ret = reset_control_deassert (pcie -> perst_reset );
801+
802+ if (ret )
803+ dev_err (pcie -> dev , "failed to %s 'perst' reset, err=%d\n" ,
804+ val ? "assert" : "deassert" , ret );
805+ return ret ;
790806}
791807
792- static void brcm_pcie_perst_set_7278 (struct brcm_pcie * pcie , u32 val )
808+ static int brcm_pcie_perst_set_7278 (struct brcm_pcie * pcie , u32 val )
793809{
794810 u32 tmp ;
795811
796812 /* Perst bit has moved and assert value is 0 */
797813 tmp = readl (pcie -> base + PCIE_MISC_PCIE_CTRL );
798814 u32p_replace_bits (& tmp , !val , PCIE_MISC_PCIE_CTRL_PCIE_PERSTB_MASK );
799815 writel (tmp , pcie -> base + PCIE_MISC_PCIE_CTRL );
816+
817+ return 0 ;
800818}
801819
802- static void brcm_pcie_perst_set_generic (struct brcm_pcie * pcie , u32 val )
820+ static int brcm_pcie_perst_set_generic (struct brcm_pcie * pcie , u32 val )
803821{
804822 u32 tmp ;
805823
806824 tmp = readl (pcie -> base + PCIE_RGR1_SW_INIT_1 (pcie ));
807825 u32p_replace_bits (& tmp , val , PCIE_RGR1_SW_INIT_1_PERST_MASK );
808826 writel (tmp , pcie -> base + PCIE_RGR1_SW_INIT_1 (pcie ));
827+
828+ return 0 ;
809829}
810830
811831static void add_inbound_win (struct inbound_win * b , u8 * count , u64 size ,
@@ -1020,19 +1040,28 @@ static int brcm_pcie_setup(struct brcm_pcie *pcie)
10201040 u32 tmp , burst , aspm_support ;
10211041 u8 num_out_wins = 0 ;
10221042 int num_inbound_wins = 0 ;
1023- int memc ;
1043+ int memc , ret ;
10241044
10251045 /* Reset the bridge */
1026- pcie -> bridge_sw_init_set (pcie , 1 );
1046+ ret = pcie -> bridge_sw_init_set (pcie , 1 );
1047+ if (ret )
1048+ return ret ;
10271049
10281050 /* Ensure that PERST# is asserted; some bootloaders may deassert it. */
1029- if (pcie -> type == BCM2711 )
1030- pcie -> perst_set (pcie , 1 );
1051+ if (pcie -> type == BCM2711 ) {
1052+ ret = pcie -> perst_set (pcie , 1 );
1053+ if (ret ) {
1054+ pcie -> bridge_sw_init_set (pcie , 0 );
1055+ return ret ;
1056+ }
1057+ }
10311058
10321059 usleep_range (100 , 200 );
10331060
10341061 /* Take the bridge out of reset */
1035- pcie -> bridge_sw_init_set (pcie , 0 );
1062+ ret = pcie -> bridge_sw_init_set (pcie , 0 );
1063+ if (ret )
1064+ return ret ;
10361065
10371066 tmp = readl (base + HARD_DEBUG (pcie ));
10381067 if (is_bmips (pcie ))
@@ -1251,7 +1280,9 @@ static int brcm_pcie_start_link(struct brcm_pcie *pcie)
12511280 int ret , i ;
12521281
12531282 /* Unassert the fundamental reset */
1254- pcie -> perst_set (pcie , 0 );
1283+ ret = pcie -> perst_set (pcie , 0 );
1284+ if (ret )
1285+ return ret ;
12551286
12561287 /*
12571288 * Wait for 100ms after PERST# deassertion; see PCIe CEM specification
@@ -1443,15 +1474,17 @@ static inline int brcm_phy_stop(struct brcm_pcie *pcie)
14431474 return pcie -> has_phy ? brcm_phy_cntl (pcie , 0 ) : 0 ;
14441475}
14451476
1446- static void brcm_pcie_turn_off (struct brcm_pcie * pcie )
1477+ static int brcm_pcie_turn_off (struct brcm_pcie * pcie )
14471478{
14481479 void __iomem * base = pcie -> base ;
1449- int tmp ;
1480+ int tmp , ret ;
14501481
14511482 if (brcm_pcie_link_up (pcie ))
14521483 brcm_pcie_enter_l23 (pcie );
14531484 /* Assert fundamental reset */
1454- pcie -> perst_set (pcie , 1 );
1485+ ret = pcie -> perst_set (pcie , 1 );
1486+ if (ret )
1487+ return ret ;
14551488
14561489 /* Deassert request for L23 in case it was asserted */
14571490 tmp = readl (base + PCIE_MISC_PCIE_CTRL );
@@ -1464,7 +1497,9 @@ static void brcm_pcie_turn_off(struct brcm_pcie *pcie)
14641497 writel (tmp , base + HARD_DEBUG (pcie ));
14651498
14661499 /* Shutdown PCIe bridge */
1467- pcie -> bridge_sw_init_set (pcie , 1 );
1500+ ret = pcie -> bridge_sw_init_set (pcie , 1 );
1501+
1502+ return ret ;
14681503}
14691504
14701505static int pci_dev_may_wakeup (struct pci_dev * dev , void * data )
@@ -1482,9 +1517,12 @@ static int brcm_pcie_suspend_noirq(struct device *dev)
14821517{
14831518 struct brcm_pcie * pcie = dev_get_drvdata (dev );
14841519 struct pci_host_bridge * bridge = pci_host_bridge_from_priv (pcie );
1485- int ret ;
1520+ int ret , rret ;
1521+
1522+ ret = brcm_pcie_turn_off (pcie );
1523+ if (ret )
1524+ return ret ;
14861525
1487- brcm_pcie_turn_off (pcie );
14881526 /*
14891527 * If brcm_phy_stop() returns an error, just dev_err(). If we
14901528 * return the error it will cause the suspend to fail and this is a
@@ -1513,7 +1551,10 @@ static int brcm_pcie_suspend_noirq(struct device *dev)
15131551 pcie -> sr -> supplies );
15141552 if (ret ) {
15151553 dev_err (dev , "Could not turn off regulators\n" );
1516- reset_control_reset (pcie -> rescal );
1554+ rret = reset_control_reset (pcie -> rescal );
1555+ if (rret )
1556+ dev_err (dev , "failed to reset 'rascal' controller ret=%d\n" ,
1557+ rret );
15171558 return ret ;
15181559 }
15191560 }
@@ -1528,7 +1569,7 @@ static int brcm_pcie_resume_noirq(struct device *dev)
15281569 struct brcm_pcie * pcie = dev_get_drvdata (dev );
15291570 void __iomem * base ;
15301571 u32 tmp ;
1531- int ret ;
1572+ int ret , rret ;
15321573
15331574 base = pcie -> base ;
15341575 ret = clk_prepare_enable (pcie -> clk );
@@ -1590,7 +1631,9 @@ static int brcm_pcie_resume_noirq(struct device *dev)
15901631 if (pcie -> sr )
15911632 regulator_bulk_disable (pcie -> sr -> num_supplies , pcie -> sr -> supplies );
15921633err_reset :
1593- reset_control_rearm (pcie -> rescal );
1634+ rret = reset_control_rearm (pcie -> rescal );
1635+ if (rret )
1636+ dev_err (pcie -> dev , "failed to rearm 'rescal' reset, err=%d\n" , rret );
15941637err_disable_clk :
15951638 clk_disable_unprepare (pcie -> clk );
15961639 return ret ;
0 commit comments