@@ -243,6 +243,7 @@ struct ptp_ocp_sma_connector {
243243 bool fixed_fcn ;
244244 bool fixed_dir ;
245245 bool disabled ;
246+ u8 default_fcn ;
246247};
247248
248249struct ocp_attr_group {
@@ -702,11 +703,18 @@ static const struct ocp_selector ptp_ocp_sma_out[] = {
702703
703704struct ocp_sma_op {
704705 const struct ocp_selector * tbl [2 ];
706+ void (* init )(struct ptp_ocp * bp );
705707 u32 (* get )(struct ptp_ocp * bp , int sma_nr );
706708 int (* set_inputs )(struct ptp_ocp * bp , int sma_nr , u32 val );
707709 int (* set_output )(struct ptp_ocp * bp , int sma_nr , u32 val );
708710};
709711
712+ static void
713+ ptp_ocp_sma_init (struct ptp_ocp * bp )
714+ {
715+ return bp -> sma_op -> init (bp );
716+ }
717+
710718static u32
711719ptp_ocp_sma_get (struct ptp_ocp * bp , int sma_nr )
712720{
@@ -2023,15 +2031,8 @@ ptp_ocp_sma_fb_set_inputs(struct ptp_ocp *bp, int sma_nr, u32 val)
20232031 return 0 ;
20242032}
20252033
2026- static const struct ocp_sma_op ocp_fb_sma_op = {
2027- .tbl = { ptp_ocp_sma_in , ptp_ocp_sma_out },
2028- .get = ptp_ocp_sma_fb_get ,
2029- .set_inputs = ptp_ocp_sma_fb_set_inputs ,
2030- .set_output = ptp_ocp_sma_fb_set_output ,
2031- };
2032-
20332034static void
2034- ptp_ocp_sma_init (struct ptp_ocp * bp )
2035+ ptp_ocp_sma_fb_init (struct ptp_ocp * bp )
20352036{
20362037 u32 reg ;
20372038 int i ;
@@ -2041,6 +2042,8 @@ ptp_ocp_sma_init(struct ptp_ocp *bp)
20412042 bp -> sma [1 ].mode = SMA_MODE_IN ;
20422043 bp -> sma [2 ].mode = SMA_MODE_OUT ;
20432044 bp -> sma [3 ].mode = SMA_MODE_OUT ;
2045+ for (i = 0 ; i < 4 ; i ++ )
2046+ bp -> sma [i ].default_fcn = i & 1 ;
20442047
20452048 /* If no SMA1 map, the pin functions and directions are fixed. */
20462049 if (!bp -> sma_map1 ) {
@@ -2069,6 +2072,14 @@ ptp_ocp_sma_init(struct ptp_ocp *bp)
20692072 }
20702073}
20712074
2075+ static const struct ocp_sma_op ocp_fb_sma_op = {
2076+ .tbl = { ptp_ocp_sma_in , ptp_ocp_sma_out },
2077+ .init = ptp_ocp_sma_fb_init ,
2078+ .get = ptp_ocp_sma_fb_get ,
2079+ .set_inputs = ptp_ocp_sma_fb_set_inputs ,
2080+ .set_output = ptp_ocp_sma_fb_set_output ,
2081+ };
2082+
20722083static int
20732084ptp_ocp_fb_set_pins (struct ptp_ocp * bp )
20742085{
@@ -2330,7 +2341,7 @@ ptp_ocp_sma_store(struct ptp_ocp *bp, const char *buf, int sma_nr)
23302341 return - EOPNOTSUPP ;
23312342
23322343 if (sma -> fixed_fcn ) {
2333- if (val != (( sma_nr - 1 ) & 1 ) )
2344+ if (val != sma -> default_fcn )
23342345 return - EOPNOTSUPP ;
23352346 return 0 ;
23362347 }
0 commit comments