From 6f99ae94d1b296c4d21d6c053eed65460fcd39c0 Mon Sep 17 00:00:00 2001 From: Noe Rubinstein Date: Thu, 4 Nov 2010 20:30:18 +0100 Subject: expiry_T1, expiry_T3, set_st_state --- xhfc/xhfc_st_state.c | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) (limited to 'xhfc/xhfc_st_state.c') diff --git a/xhfc/xhfc_st_state.c b/xhfc/xhfc_st_state.c index f52425d..ca4ade6 100644 --- a/xhfc/xhfc_st_state.c +++ b/xhfc/xhfc_st_state.c @@ -28,6 +28,8 @@ static void handle_state_change_te(struct xhfc_span* s); static void activate_request_nt(struct xhfc_span* s); static void activate_request_te(struct xhfc_span* s); +static void set_st_state(struct xhfc_span* s, int state); + static void print_current_state(struct xhfc_span* s); void handle_state_change(struct xhfc_span* s) @@ -66,6 +68,13 @@ static void handle_state_change_nt(struct xhfc_span* s) case G2: s->span.alarms = DAHDI_ALARM_YELLOW; if(s->prev_state != G3) + /* When setting the state to G4 by writing + * A_SU_WR_STA, is the T2 timer automatically + * started? I suppose so because I don't see + * any other way to start it and it is + * implemented in hardware. + */ + /* Start T1 */ ; break; case G3: @@ -113,7 +122,33 @@ static void handle_state_change_te(struct xhfc_span* s) s->span.alarms = DAHDI_ALARM_NONE; /* Stop T3 */ break; + } +} + +static void expiry_T1(struct xhfc_span* s) +{ + set_st_state(s, G4); +} + +static void expiry_T3(struct xhfc_span* s); +{ + set_st_state(s, F3); +} + +static void set_st_state(struct xhfc_span* s, int state) +{ + u8 a_su_wr_sta = 0; + SET_V_SU_SET_STA(a_su_wr_sta, state); + SET_V_SU_LD_STA(a_su_wr_sta, 1); + + write_xhfc(s->xhfc, R_SU_SEL, s->port); + write_xhfc(s->xhfc, A_SU_WR_STA, a_su_wr_sta); + + udelay(6); + SET_V_SU_LD_STA(a_su_wr_sta, 0); + write_xhfc(s->xhfc, R_SU_SEL, s->port); /* just in case. (XXX?) */ + write_xhfc(s->xhfc, A_SU_WR_STA, a_su_wr_sta); } static char *state_descriptions[2][16] = { -- cgit v1.2.3