| 1 |
/* |
| 2 |
* Driver for the Conexant CX25821 PCIe bridge |
| 3 |
* |
| 4 |
* Copyright (C) 2009 Conexant Systems Inc. |
| 5 |
* Authors <[email protected]>, <[email protected]> |
| 6 |
* |
| 7 |
* This program is free software; you can redistribute it and/or modify |
| 8 |
* it under the terms of the GNU General Public License as published by |
| 9 |
* the Free Software Foundation; either version 2 of the License, or |
| 10 |
* (at your option) any later version. |
| 11 |
* |
| 12 |
* This program is distributed in the hope that it will be useful, |
| 13 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 14 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 15 |
* |
| 16 |
* GNU General Public License for more details. |
| 17 |
* |
| 18 |
* You should have received a copy of the GNU General Public License |
| 19 |
* along with this program; if not, write to the Free Software |
| 20 |
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. |
| 21 |
*/ |
| 22 |
|
| 23 |
#include "cx25821.h" |
| 24 |
|
| 25 |
|
| 26 |
// Array for GPIO selected bits for a specific decoder. |
| 27 |
|
| 28 |
enum GPIO_DEF { DECA_SEL = 0, |
| 29 |
DECB_SEL, |
| 30 |
DECC_SEL, |
| 31 |
DECD_SEL, |
| 32 |
MON_SEL = 4}; |
| 33 |
|
| 34 |
enum GPIO_OCTAL_DEF { OCTAL_DECA_SEL = 0, |
| 35 |
OCTAL_DECB_SEL, |
| 36 |
OCTAL_DECC_SEL, |
| 37 |
OCTAL_DECD_SEL, |
| 38 |
OCTAL_DECE_SEL, |
| 39 |
OCTAL_DECF_SEL, |
| 40 |
OCTAL_DECG_SEL, |
| 41 |
OCTAL_DECH_SEL, |
| 42 |
OCTAL_MON_SEL = 8 }; |
| 43 |
|
| 44 |
|
| 45 |
// Direction bits are at offset 23:16 |
| 46 |
#define Set_GPIO_Direction_Bit_To_OUTPUT(Bit) ((1 << Bit) << 16) |
| 47 |
|
| 48 |
struct medusa_decoder { |
| 49 |
int _cur_dec; |
| 50 |
unsigned short _num_vdec; |
| 51 |
}; |
| 52 |
|
| 53 |
//////////////////////////////////////////////////////////////////////////////////////// |
| 54 |
// Selects Medusa Decoder Channel. |
| 55 |
//////////////////////////////////////////////////////////////////////////////////////// |
| 56 |
void medusa_decoder_select(struct cx25821_dev *dev, struct medusa_decoder *dec, int decoder) |
| 57 |
{ |
| 58 |
|
| 59 |
if (decoder < DECA_SEL && decoder > MON_SEL ) |
| 60 |
return; |
| 61 |
|
| 62 |
dec->_cur_dec = decoder; |
| 63 |
|
| 64 |
u32 gpioRegister = cx_read(GP0_IO); |
| 65 |
u32 value = (gpioRegister & 0xFFFFFFF0) | dec->_cur_dec; |
| 66 |
cx_write( GP0_IO, value ); |
| 67 |
} |
| 68 |
|
| 69 |
//////////////////////////////////////////////////////////////////////////////////////// |
| 70 |
// Sets the GPIO pin directions |
| 71 |
// Parameters: |
| 72 |
// |
| 73 |
//////////////////////////////////////////////////////////////////////////////////////// |
| 74 |
void medusa_video_set_gpiopin_directions_to_output(struct cx25821_dev *dev, struct medusa_decoder *dec ) |
| 75 |
{ |
| 76 |
// Here we will make sure that the GPIOs 0-3 are output. keep the rest as is |
| 77 |
u32 gpioRegister = cx_read( GP0_IO ); |
| 78 |
|
| 79 |
// This operation will set the GPIO bits below. |
| 80 |
if (dec->_num_vdec == 4) |
| 81 |
{ |
| 82 |
cx_write( GP0_IO, |
| 83 |
gpioRegister |
| 84 |
| (Set_GPIO_Direction_Bit_To_OUTPUT(DECA_SEL)) |
| 85 |
| (Set_GPIO_Direction_Bit_To_OUTPUT(DECB_SEL)) |
| 86 |
| (Set_GPIO_Direction_Bit_To_OUTPUT(DECC_SEL)) |
| 87 |
| (Set_GPIO_Direction_Bit_To_OUTPUT(DECD_SEL)) |
| 88 |
| (Set_GPIO_Direction_Bit_To_OUTPUT(MON_SEL)) ); |
| 89 |
medusa_decoder_select(dev, dec, MON_SEL); |
| 90 |
} |
| 91 |
else |
| 92 |
{ |
| 93 |
cx_write( GP0_IO, |
| 94 |
gpioRegister |
| 95 |
| (Set_GPIO_Direction_Bit_To_OUTPUT(OCTAL_DECA_SEL)) |
| 96 |
| (Set_GPIO_Direction_Bit_To_OUTPUT(OCTAL_DECB_SEL)) |
| 97 |
| (Set_GPIO_Direction_Bit_To_OUTPUT(OCTAL_DECC_SEL)) |
| 98 |
| (Set_GPIO_Direction_Bit_To_OUTPUT(OCTAL_DECD_SEL)) |
| 99 |
| (Set_GPIO_Direction_Bit_To_OUTPUT(OCTAL_DECE_SEL)) |
| 100 |
| (Set_GPIO_Direction_Bit_To_OUTPUT(OCTAL_DECF_SEL)) |
| 101 |
| (Set_GPIO_Direction_Bit_To_OUTPUT(OCTAL_DECG_SEL)) |
| 102 |
| (Set_GPIO_Direction_Bit_To_OUTPUT(OCTAL_DECH_SEL)) |
| 103 |
| (Set_GPIO_Direction_Bit_To_OUTPUT(OCTAL_MON_SEL)) ); |
| 104 |
medusa_decoder_select(dev, dec, OCTAL_MON_SEL); |
| 105 |
} |
| 106 |
} |