/* Driver for Realtek RTS51xx USB card reader * Header file * * Copyright(c) 2009 Realtek Semiconductor Corp. All rights reserved. * * This program is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License as published by the * Free Software Foundation; either version 2, or (at your option) any * later version. * * This program is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * General Public License for more details. * * You should have received a copy of the GNU General Public License along * with this program; if not, see card_ready & chip->lun2card[lun]) { return 1; } return 0; } static inline int check_card_exist(struct rts51x_chip *chip, unsigned int lun) { if (chip->card_exist & chip->lun2card[lun]) { return 1; } return 0; } static inline int check_card_wp(struct rts51x_chip *chip, unsigned int lun) { if (chip->card_wp & chip->lun2card[lun]) { return 1; } return 0; } static inline int check_card_fail(struct rts51x_chip *chip, unsigned int lun) { if (chip->card_fail & chip->lun2card[lun]) { return 1; } return 0; } static inline int check_card_ejected(struct rts51x_chip *chip, unsigned int lun) { if (chip->card_ejected & chip->lun2card[lun]) { return 1; } return 0; } static inline int check_fake_card_ready(struct rts51x_chip *chip, unsigned int lun) { if (chip->fake_card_ready & chip->lun2card[lun]) { return 1; } return 0; } static inline u8 get_lun2card(struct rts51x_chip *chip, unsigned int lun) { return chip->lun2card[lun]; } static inline int check_lun_mc(struct rts51x_chip *chip, unsigned int lun) { return CHK_BIT(chip->lun_mc, lun); } static inline void set_lun_mc(struct rts51x_chip *chip, unsigned int lun) { SET_BIT(chip->lun_mc, lun); } static inline void clear_lun_mc(struct rts51x_chip *chip, unsigned int lun) { CLR_BIT(chip->lun_mc, lun); } static inline int switch_clock(struct rts51x_chip *chip, int clk) { int retval = 0; if (chip->asic_code) { retval = switch_ssc_clock(chip, clk); } else { retval = switch_normal_clock(chip, clk); } return retval; } static inline void rts51x_clear_xd_error(struct rts51x_chip *chip) { rts51x_ep0_write_register(chip, CARD_STOP, XD_STOP | XD_CLR_ERR, XD_STOP | XD_CLR_ERR); rts51x_ep0_write_register(chip,MC_FIFO_CTL,FIFO_FLUSH,FIFO_FLUSH); rts51x_ep0_write_register(chip,MC_DMA_RST,DMA_RESET,DMA_RESET); rts51x_ep0_write_register(chip, SFSM_ED, 0xf8, 0xf8); } static inline void rts51x_clear_sd_error(struct rts51x_chip *chip) { rts51x_ep0_write_register(chip, CARD_STOP, SD_STOP | SD_CLR_ERR, SD_STOP | SD_CLR_ERR); rts51x_ep0_write_register(chip,MC_FIFO_CTL,FIFO_FLUSH,FIFO_FLUSH); rts51x_ep0_write_register(chip,MC_DMA_RST,DMA_RESET,DMA_RESET); rts51x_ep0_write_register(chip, SFSM_ED, 0xf8, 0xf8); } static inline void rts51x_clear_ms_error(struct rts51x_chip *chip) { rts51x_ep0_write_register(chip, CARD_STOP, MS_STOP | MS_CLR_ERR, MS_STOP | MS_CLR_ERR); rts51x_ep0_write_register(chip,MC_FIFO_CTL,FIFO_FLUSH,FIFO_FLUSH); rts51x_ep0_write_register(chip,MC_DMA_RST,DMA_RESET,DMA_RESET); rts51x_ep0_write_register(chip, SFSM_ED, 0xf8, 0xf8); } #endif