@@ -2023,15 +2023,25 @@ static irqreturn_t airoha_irq_handler(int irq, void *dev_instance)
2023
2023
}
2024
2024
2025
2025
static int airoha_qdma_init (struct platform_device * pdev ,
2026
- struct airoha_eth * eth )
2026
+ struct airoha_eth * eth ,
2027
+ struct airoha_qdma * qdma )
2027
2028
{
2028
- struct airoha_qdma * qdma = & eth -> qdma [0 ];
2029
- int err ;
2029
+ int err , id = qdma - & eth -> qdma [0 ];
2030
+ const char * res ;
2030
2031
2031
2032
spin_lock_init (& qdma -> irq_lock );
2032
2033
qdma -> eth = eth ;
2033
2034
2034
- qdma -> irq = platform_get_irq (pdev , 0 );
2035
+ res = devm_kasprintf (eth -> dev , GFP_KERNEL , "qdma%d" , id );
2036
+ if (!res )
2037
+ return - ENOMEM ;
2038
+
2039
+ qdma -> regs = devm_platform_ioremap_resource_byname (pdev , res );
2040
+ if (IS_ERR (qdma -> regs ))
2041
+ return dev_err_probe (eth -> dev , PTR_ERR (qdma -> regs ),
2042
+ "failed to iomap qdma%d regs\n" , id );
2043
+
2044
+ qdma -> irq = platform_get_irq (pdev , 4 * id );
2035
2045
if (qdma -> irq < 0 )
2036
2046
return qdma -> irq ;
2037
2047
@@ -2052,19 +2062,13 @@ static int airoha_qdma_init(struct platform_device *pdev,
2052
2062
if (err )
2053
2063
return err ;
2054
2064
2055
- err = airoha_qdma_hw_init (qdma );
2056
- if (err )
2057
- return err ;
2058
-
2059
- set_bit (DEV_STATE_INITIALIZED , & eth -> state );
2060
-
2061
- return 0 ;
2065
+ return airoha_qdma_hw_init (qdma );
2062
2066
}
2063
2067
2064
2068
static int airoha_hw_init (struct platform_device * pdev ,
2065
2069
struct airoha_eth * eth )
2066
2070
{
2067
- int err ;
2071
+ int err , i ;
2068
2072
2069
2073
/* disable xsi */
2070
2074
reset_control_bulk_assert (ARRAY_SIZE (eth -> xsi_rsts ), eth -> xsi_rsts );
@@ -2078,12 +2082,19 @@ static int airoha_hw_init(struct platform_device *pdev,
2078
2082
if (err )
2079
2083
return err ;
2080
2084
2081
- return airoha_qdma_init (pdev , eth );
2085
+ for (i = 0 ; i < ARRAY_SIZE (eth -> qdma ); i ++ ) {
2086
+ err = airoha_qdma_init (pdev , eth , & eth -> qdma [i ]);
2087
+ if (err )
2088
+ return err ;
2089
+ }
2090
+
2091
+ set_bit (DEV_STATE_INITIALIZED , & eth -> state );
2092
+
2093
+ return 0 ;
2082
2094
}
2083
2095
2084
- static void airoha_hw_cleanup (struct airoha_eth * eth )
2096
+ static void airoha_hw_cleanup (struct airoha_qdma * qdma )
2085
2097
{
2086
- struct airoha_qdma * qdma = & eth -> qdma [0 ];
2087
2098
int i ;
2088
2099
2089
2100
for (i = 0 ; i < ARRAY_SIZE (qdma -> q_rx ); i ++ ) {
@@ -2644,13 +2655,6 @@ static int airoha_probe(struct platform_device *pdev)
2644
2655
return dev_err_probe (eth -> dev , PTR_ERR (eth -> fe_regs ),
2645
2656
"failed to iomap fe regs\n" );
2646
2657
2647
- eth -> qdma [0 ].regs = devm_platform_ioremap_resource_byname (pdev ,
2648
- "qdma0" );
2649
- if (IS_ERR (eth -> qdma [0 ].regs ))
2650
- return dev_err_probe (eth -> dev ,
2651
- PTR_ERR (eth -> qdma [0 ].regs ),
2652
- "failed to iomap qdma regs\n" );
2653
-
2654
2658
eth -> rsts [0 ].id = "fe" ;
2655
2659
eth -> rsts [1 ].id = "pdma" ;
2656
2660
eth -> rsts [2 ].id = "qdma" ;
@@ -2706,7 +2710,9 @@ static int airoha_probe(struct platform_device *pdev)
2706
2710
return 0 ;
2707
2711
2708
2712
error :
2709
- airoha_hw_cleanup (eth );
2713
+ for (i = 0 ; i < ARRAY_SIZE (eth -> qdma ); i ++ )
2714
+ airoha_hw_cleanup (& eth -> qdma [i ]);
2715
+
2710
2716
for (i = 0 ; i < ARRAY_SIZE (eth -> ports ); i ++ ) {
2711
2717
struct airoha_gdm_port * port = eth -> ports [i ];
2712
2718
@@ -2724,7 +2730,9 @@ static void airoha_remove(struct platform_device *pdev)
2724
2730
struct airoha_eth * eth = platform_get_drvdata (pdev );
2725
2731
int i ;
2726
2732
2727
- airoha_hw_cleanup (eth );
2733
+ for (i = 0 ; i < ARRAY_SIZE (eth -> qdma ); i ++ )
2734
+ airoha_hw_cleanup (& eth -> qdma [i ]);
2735
+
2728
2736
for (i = 0 ; i < ARRAY_SIZE (eth -> ports ); i ++ ) {
2729
2737
struct airoha_gdm_port * port = eth -> ports [i ];
2730
2738
0 commit comments