Skip to content

Commit 773c3e7

Browse files
Sriramakrishnandavem330
authored andcommitted
can: ti hecc module : add platform specific initialization callback.
CAN module on AM3517 requires programming of IO expander as part of init sequence - to enable CAN PHY. Added platform specific callback to handle phy control(switch on /off). Signed-off-by: Sriramakrishnan <srk@ti.com> Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent 738b034 commit 773c3e7

2 files changed

Lines changed: 22 additions & 3 deletions

File tree

‎drivers/net/can/ti_hecc.c‎

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,11 @@
2828
* .mbx_offset = 0x2000,
2929
* .int_line = 0,
3030
* .revision = 1,
31+
* .transceiver_switch = hecc_phy_control,
3132
* };
3233
*
33-
* Please see include/can/platform/ti_hecc.h for description of above fields
34+
* Please see include/linux/can/platform/ti_hecc.h for description of
35+
* above fields.
3436
*
3537
*/
3638

@@ -220,6 +222,7 @@ struct ti_hecc_priv {
220222
u32 tx_head;
221223
u32 tx_tail;
222224
u32 rx_next;
225+
void (*transceiver_switch)(int);
223226
};
224227

225228
static inline int get_tx_head_mb(struct ti_hecc_priv *priv)
@@ -317,6 +320,13 @@ static int ti_hecc_set_btc(struct ti_hecc_priv *priv)
317320
return 0;
318321
}
319322

323+
static void ti_hecc_transceiver_switch(const struct ti_hecc_priv *priv,
324+
int on)
325+
{
326+
if (priv->transceiver_switch)
327+
priv->transceiver_switch(on);
328+
}
329+
320330
static void ti_hecc_reset(struct net_device *ndev)
321331
{
322332
u32 cnt;
@@ -818,10 +828,13 @@ static int ti_hecc_open(struct net_device *ndev)
818828
return err;
819829
}
820830

831+
ti_hecc_transceiver_switch(priv, 1);
832+
821833
/* Open common can device */
822834
err = open_candev(ndev);
823835
if (err) {
824836
dev_err(ndev->dev.parent, "open_candev() failed %d\n", err);
837+
ti_hecc_transceiver_switch(priv, 0);
825838
free_irq(ndev->irq, ndev);
826839
return err;
827840
}
@@ -842,6 +855,7 @@ static int ti_hecc_close(struct net_device *ndev)
842855
ti_hecc_stop(ndev);
843856
free_irq(ndev->irq, ndev);
844857
close_candev(ndev);
858+
ti_hecc_transceiver_switch(priv, 0);
845859

846860
return 0;
847861
}
@@ -903,6 +917,7 @@ static int ti_hecc_probe(struct platform_device *pdev)
903917
priv->hecc_ram_offset = pdata->hecc_ram_offset;
904918
priv->mbx_offset = pdata->mbx_offset;
905919
priv->int_line = pdata->int_line;
920+
priv->transceiver_switch = pdata->transceiver_switch;
906921

907922
priv->can.bittiming_const = &ti_hecc_bittiming_const;
908923
priv->can.do_set_mode = ti_hecc_do_set_mode;

‎include/linux/can/platform/ti_hecc.h‎

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
#ifndef __CAN_PLATFORM_TI_HECC_H__
2+
#define __CAN_PLATFORM_TI_HECC_H__
3+
14
/*
25
* TI HECC (High End CAN Controller) driver platform header
36
*
@@ -23,6 +26,7 @@
2326
* @mbx_offset: Mailbox RAM offset
2427
* @int_line: Interrupt line to use - 0 or 1
2528
* @version: version for future use
29+
* @transceiver_switch: platform specific callback fn for transceiver control
2630
*
2731
* Platform data structure to get all platform specific settings.
2832
* this structure also accounts the fact that the IP may have different
@@ -35,6 +39,6 @@ struct ti_hecc_platform_data {
3539
u32 mbx_offset;
3640
u32 int_line;
3741
u32 version;
42+
void (*transceiver_switch) (int);
3843
};
39-
40-
44+
#endif

0 commit comments

Comments
 (0)