118
118
#define BXCAN_FiR1_REG (b ) (0x40 + (b) * 8)
119
119
#define BXCAN_FiR2_REG (b ) (0x44 + (b) * 8)
120
120
121
- #define BXCAN_FILTER_ID (primary ) (primary ? 0 : 14 )
121
+ #define BXCAN_FILTER_ID (cfg ) ((cfg) == BXCAN_CFG_DUAL_SECONDARY ? 14 : 0 )
122
122
123
123
/* Filter primary register (FMR) bits */
124
124
#define BXCAN_FMR_CANSB_MASK GENMASK(13, 8)
@@ -135,6 +135,12 @@ enum bxcan_lec_code {
135
135
BXCAN_LEC_UNUSED
136
136
};
137
137
138
+ enum bxcan_cfg {
139
+ BXCAN_CFG_SINGLE = 0 ,
140
+ BXCAN_CFG_DUAL_PRIMARY ,
141
+ BXCAN_CFG_DUAL_SECONDARY
142
+ };
143
+
138
144
/* Structure of the message buffer */
139
145
struct bxcan_mb {
140
146
u32 id ; /* can identifier */
@@ -167,7 +173,7 @@ struct bxcan_priv {
167
173
struct regmap * gcan ;
168
174
int tx_irq ;
169
175
int sce_irq ;
170
- bool primary ;
176
+ enum bxcan_cfg cfg ;
171
177
struct clk * clk ;
172
178
spinlock_t rmw_lock ; /* lock for read-modify-write operations */
173
179
unsigned int tx_head ;
@@ -202,17 +208,17 @@ static inline void bxcan_rmw(struct bxcan_priv *priv, void __iomem *addr,
202
208
spin_unlock_irqrestore (& priv -> rmw_lock , flags );
203
209
}
204
210
205
- static void bxcan_disable_filters (struct bxcan_priv * priv , bool primary )
211
+ static void bxcan_disable_filters (struct bxcan_priv * priv , enum bxcan_cfg cfg )
206
212
{
207
- unsigned int fid = BXCAN_FILTER_ID (primary );
213
+ unsigned int fid = BXCAN_FILTER_ID (cfg );
208
214
u32 fmask = BIT (fid );
209
215
210
216
regmap_update_bits (priv -> gcan , BXCAN_FA1R_REG , fmask , 0 );
211
217
}
212
218
213
- static void bxcan_enable_filters (struct bxcan_priv * priv , bool primary )
219
+ static void bxcan_enable_filters (struct bxcan_priv * priv , enum bxcan_cfg cfg )
214
220
{
215
- unsigned int fid = BXCAN_FILTER_ID (primary );
221
+ unsigned int fid = BXCAN_FILTER_ID (cfg );
216
222
u32 fmask = BIT (fid );
217
223
218
224
/* Filter settings:
@@ -680,7 +686,7 @@ static int bxcan_chip_start(struct net_device *ndev)
680
686
BXCAN_BTR_BRP_MASK | BXCAN_BTR_TS1_MASK | BXCAN_BTR_TS2_MASK |
681
687
BXCAN_BTR_SJW_MASK , set );
682
688
683
- bxcan_enable_filters (priv , priv -> primary );
689
+ bxcan_enable_filters (priv , priv -> cfg );
684
690
685
691
/* Clear all internal status */
686
692
priv -> tx_head = 0 ;
@@ -806,7 +812,7 @@ static void bxcan_chip_stop(struct net_device *ndev)
806
812
BXCAN_IER_EPVIE | BXCAN_IER_EWGIE | BXCAN_IER_FOVIE1 |
807
813
BXCAN_IER_FFIE1 | BXCAN_IER_FMPIE1 | BXCAN_IER_FOVIE0 |
808
814
BXCAN_IER_FFIE0 | BXCAN_IER_FMPIE0 | BXCAN_IER_TMEIE , 0 );
809
- bxcan_disable_filters (priv , priv -> primary );
815
+ bxcan_disable_filters (priv , priv -> cfg );
810
816
bxcan_enter_sleep_mode (priv );
811
817
priv -> can .state = CAN_STATE_STOPPED ;
812
818
}
@@ -931,7 +937,7 @@ static int bxcan_probe(struct platform_device *pdev)
931
937
struct clk * clk = NULL ;
932
938
void __iomem * regs ;
933
939
struct regmap * gcan ;
934
- bool primary ;
940
+ enum bxcan_cfg cfg ;
935
941
int err , rx_irq , tx_irq , sce_irq ;
936
942
937
943
regs = devm_platform_ioremap_resource (pdev , 0 );
@@ -946,7 +952,13 @@ static int bxcan_probe(struct platform_device *pdev)
946
952
return PTR_ERR (gcan );
947
953
}
948
954
949
- primary = of_property_read_bool (np , "st,can-primary" );
955
+ if (of_property_read_bool (np , "st,can-primary" ))
956
+ cfg = BXCAN_CFG_DUAL_PRIMARY ;
957
+ else if (of_property_read_bool (np , "st,can-secondary" ))
958
+ cfg = BXCAN_CFG_DUAL_SECONDARY ;
959
+ else
960
+ cfg = BXCAN_CFG_SINGLE ;
961
+
950
962
clk = devm_clk_get (dev , NULL );
951
963
if (IS_ERR (clk )) {
952
964
dev_err (dev , "failed to get clock\n" );
@@ -992,7 +1004,7 @@ static int bxcan_probe(struct platform_device *pdev)
992
1004
priv -> clk = clk ;
993
1005
priv -> tx_irq = tx_irq ;
994
1006
priv -> sce_irq = sce_irq ;
995
- priv -> primary = primary ;
1007
+ priv -> cfg = cfg ;
996
1008
priv -> can .clock .freq = clk_get_rate (clk );
997
1009
spin_lock_init (& priv -> rmw_lock );
998
1010
priv -> tx_head = 0 ;
0 commit comments