int ucc_mux_set_grant_tsa_bkpt(int ucc_num, int set, u32 mask) { volatile u32 *p_cmxucr; u8 reg_num; u8 shift; /* check if the UCC number is in range. */ if ((ucc_num > UCC_MAX_NUM - 1) || (ucc_num < 0)) return -EINVAL; get_cmxucr_reg(ucc_num, &p_cmxucr, ®_num, &shift); if (set) out_be32(p_cmxucr, in_be32(p_cmxucr) | (mask << shift)); else out_be32(p_cmxucr, in_be32(p_cmxucr) & ~(mask << shift)); return 0; }
int ucc_mux_set_grant_tsa_bkpt(unsigned int ucc_num, int set, u32 mask) { __be32 __iomem *cmxucr; unsigned int reg_num; unsigned int shift; if (ucc_num > UCC_MAX_NUM - 1) return -EINVAL; get_cmxucr_reg(ucc_num, &cmxucr, ®_num, &shift); if (set) setbits32(cmxucr, mask << shift); else clrbits32(cmxucr, mask << shift); return 0; }
int ucc_mux_set_grant_tsa_bkpt(unsigned int ucc_num, int set, u32 mask) { volatile u32 *p_cmxucr; u8 reg_num; u8 shift; /* check if the UCC number is in range. */ if (ucc_num > UCC_MAX_NUM) return -EINVAL; get_cmxucr_reg(ucc_num, ®_num, &shift); p_cmxucr = &qe_immr->qmx.cmxucrx[reg_num]; if (set) out_be32(p_cmxucr, in_be32(p_cmxucr) | (mask << shift)); else out_be32(p_cmxucr, in_be32(p_cmxucr) & ~(mask << shift)); return 0; }
int ucc_set_qe_mux_rxtx(int ucc_num, enum qe_clock clock, enum comm_dir mode) { volatile u32 *p_cmxucr; u8 reg_num; u8 shift; u32 clock_bits; u32 clock_mask; int source = -1; /* check if the UCC number is in range. */ if ((ucc_num > UCC_MAX_NUM - 1) || (ucc_num < 0)) return -EINVAL; if (!((mode == COMM_DIR_RX) || (mode == COMM_DIR_TX))) { printk(KERN_ERR "ucc_set_qe_mux_rxtx: bad comm mode type passed."); return -EINVAL; } get_cmxucr_reg(ucc_num, &p_cmxucr, ®_num, &shift); switch (reg_num) { case 1: switch (clock) { case QE_BRG1: source = 1; break; case QE_BRG2: source = 2; break; case QE_BRG7: source = 3; break; case QE_BRG8: source = 4; break; case QE_CLK9: source = 5; break; case QE_CLK10: source = 6; break; case QE_CLK11: source = 7; break; case QE_CLK12: source = 8; break; case QE_CLK15: source = 9; break; case QE_CLK16: source = 10; break; default: source = -1; break; } break; case 2: switch (clock) { case QE_BRG5: source = 1; break; case QE_BRG6: source = 2; break; case QE_BRG7: source = 3; break; case QE_BRG8: source = 4; break; case QE_CLK13: source = 5; break; case QE_CLK14: source = 6; break; case QE_CLK19: source = 7; break; case QE_CLK20: source = 8; break; case QE_CLK15: source = 9; break; case QE_CLK16: source = 10; break; default: source = -1; break; } break; case 3: switch (clock) { case QE_BRG9: source = 1; break; case QE_BRG10: source = 2; break; case QE_BRG15: source = 3; break; case QE_BRG16: source = 4; break; case QE_CLK3: source = 5; break; case QE_CLK4: source = 6; break; case QE_CLK17: source = 7; break; case QE_CLK18: source = 8; break; case QE_CLK7: source = 9; break; case QE_CLK8: source = 10; break; case QE_CLK16: source = 11; break; default: source = -1; break; } break; case 4: switch (clock) { case QE_BRG13: source = 1; break; case QE_BRG14: source = 2; break; case QE_BRG15: source = 3; break; case QE_BRG16: source = 4; break; case QE_CLK5: source = 5; break; case QE_CLK6: source = 6; break; case QE_CLK21: source = 7; break; case QE_CLK22: source = 8; break; case QE_CLK7: source = 9; break; case QE_CLK8: source = 10; break; case QE_CLK16: source = 11; break; default: source = -1; break; } break; default: source = -1; break; } if (source == -1) { printk(KERN_ERR "ucc_set_qe_mux_rxtx: Bad combination of clock and UCC."); return -ENOENT; } clock_bits = (u32) source; clock_mask = QE_CMXUCR_TX_CLK_SRC_MASK; if (mode == COMM_DIR_RX) { clock_bits <<= 4; /* Rx field is 4 bits to left of Tx field */ clock_mask <<= 4; /* Rx field is 4 bits to left of Tx field */ } clock_bits <<= shift; clock_mask <<= shift; out_be32(p_cmxucr, (in_be32(p_cmxucr) & ~clock_mask) | clock_bits); return 0; }
int ucc_set_qe_mux_rxtx(unsigned int ucc_num, enum qe_clock clock, enum comm_dir mode) { __be32 __iomem *cmxucr; unsigned int reg_num; unsigned int shift; u32 clock_bits = 0; if (ucc_num > UCC_MAX_NUM - 1) return -EINVAL; if (!((mode == COMM_DIR_RX) || (mode == COMM_DIR_TX))) return -EINVAL; get_cmxucr_reg(ucc_num, &cmxucr, ®_num, &shift); switch (reg_num) { case 1: switch (clock) { case QE_BRG1: clock_bits = 1; break; case QE_BRG2: clock_bits = 2; break; case QE_BRG7: clock_bits = 3; break; case QE_BRG8: clock_bits = 4; break; case QE_CLK9: clock_bits = 5; break; case QE_CLK10: clock_bits = 6; break; case QE_CLK11: clock_bits = 7; break; case QE_CLK12: clock_bits = 8; break; case QE_CLK15: clock_bits = 9; break; case QE_CLK16: clock_bits = 10; break; default: break; } break; case 2: switch (clock) { case QE_BRG5: clock_bits = 1; break; case QE_BRG6: clock_bits = 2; break; case QE_BRG7: clock_bits = 3; break; case QE_BRG8: clock_bits = 4; break; case QE_CLK13: clock_bits = 5; break; case QE_CLK14: clock_bits = 6; break; case QE_CLK19: clock_bits = 7; break; case QE_CLK20: clock_bits = 8; break; case QE_CLK15: clock_bits = 9; break; case QE_CLK16: clock_bits = 10; break; default: break; } break; case 3: switch (clock) { case QE_BRG9: clock_bits = 1; break; case QE_BRG10: clock_bits = 2; break; case QE_BRG15: clock_bits = 3; break; case QE_BRG16: clock_bits = 4; break; case QE_CLK3: clock_bits = 5; break; case QE_CLK4: clock_bits = 6; break; case QE_CLK17: clock_bits = 7; break; case QE_CLK18: clock_bits = 8; break; case QE_CLK7: clock_bits = 9; break; case QE_CLK8: clock_bits = 10; break; case QE_CLK16: clock_bits = 11; break; default: break; } break; case 4: switch (clock) { case QE_BRG13: clock_bits = 1; break; case QE_BRG14: clock_bits = 2; break; case QE_BRG15: clock_bits = 3; break; case QE_BRG16: clock_bits = 4; break; case QE_CLK5: clock_bits = 5; break; case QE_CLK6: clock_bits = 6; break; case QE_CLK21: clock_bits = 7; break; case QE_CLK22: clock_bits = 8; break; case QE_CLK7: clock_bits = 9; break; case QE_CLK8: clock_bits = 10; break; case QE_CLK16: clock_bits = 11; break; default: break; } break; default: break; } if (!clock_bits) return -ENOENT; if (mode == COMM_DIR_RX) shift += 4; clrsetbits_be32(cmxucr, QE_CMXUCR_TX_CLK_SRC_MASK << shift, clock_bits << shift); return 0; }
int ucc_set_qe_mux_rxtx(unsigned int ucc_num, qe_clock_e clock, comm_dir_e mode) { volatile u32 *p_cmxucr; u8 reg_num; u8 shift; u32 clockBits; u32 clockMask; int source = -1; /* check if the UCC number is in range. */ if (ucc_num > UCC_MAX_NUM) return -EINVAL; if (!((mode == COMM_DIR_RX) || (mode == COMM_DIR_TX))) { printk(KERN_ERR "ucc_set_qe_mux_rxtx: bad comm mode type passed."); return -EINVAL; } get_cmxucr_reg(ucc_num, ®_num, &shift); p_cmxucr = &qe_immr->qmx.cmxucrx[reg_num]; switch (reg_num) { case (0): switch (clock) { case (QE_BRG1): source = 1; break; case (QE_BRG2): source = 2; break; case (QE_BRG7): source = 3; break; case (QE_BRG8): source = 4; break; case (QE_CLK9): source = 5; break; case (QE_CLK10): source = 6; break; case (QE_CLK11): source = 7; break; case (QE_CLK12): source = 8; break; case (QE_CLK15): source = 9; break; case (QE_CLK16): source = 10; break; default: source = -1; break; } break; case (1): switch (clock) { case (QE_BRG5): source = 1; break; case (QE_BRG6): source = 2; break; case (QE_BRG7): source = 3; break; case (QE_BRG8): source = 4; break; case (QE_CLK13): source = 5; break; case (QE_CLK14): source = 6; break; case (QE_CLK19): source = 7; break; case (QE_CLK20): source = 8; break; case (QE_CLK15): source = 9; break; case (QE_CLK16): source = 10; break; default: source = -1; break; } break; case (2): switch (clock) { case (QE_BRG9): source = 1; break; case (QE_BRG10): source = 2; break; case (QE_BRG15): source = 3; break; case (QE_BRG16): source = 4; break; case (QE_CLK3): source = 5; break; case (QE_CLK4): source = 6; break; case (QE_CLK17): source = 7; break; case (QE_CLK18): source = 8; break; case (QE_CLK7): source = 9; break; case (QE_CLK8): source = 10; break; default: source = -1; break; } break; case (3): switch (clock) { case (QE_BRG13): source = 1; break; case (QE_BRG14): source = 2; break; case (QE_BRG15): source = 3; break; case (QE_BRG16): source = 4; break; case (QE_CLK5): source = 5; break; case (QE_CLK6): source = 6; break; case (QE_CLK21): source = 7; break; case (QE_CLK22): source = 8; break; case (QE_CLK7): source = 9; break; case (QE_CLK8): source = 10; break; default: source = -1; break; } break; default: source = -1; break; } if (source == -1) { printk(KERN_ERR "ucc_set_qe_mux_rxtx: Bad combination of clock and UCC."); return -ENOENT; } clockBits = (u32) source; clockMask = QE_CMXUCR_TX_CLK_SRC_MASK; if (mode == COMM_DIR_RX) { clockBits <<= 4; /* Rx field is 4 bits to left of Tx field */ clockMask <<= 4; /* Rx field is 4 bits to left of Tx field */ } clockBits <<= shift; clockMask <<= shift; out_be32(p_cmxucr, (in_be32(p_cmxucr) & ~clockMask) | clockBits); return 0; }