27 #define MXL_GPIO_MUX_REG_0 0x84
28 #define MXL_GPIO_MUX_REG_1 0x89
29 #define MXL_GPIO_MUX_REG_2 0x82
31 #define MXL_GPIO_DIR_INPUT 0
32 #define MXL_GPIO_DIR_OUTPUT 1
42 if ((pin > 0) && (pin < 8)) {
46 tmp &= ~(1 << (pin - 1));
47 tmp |= (val << (pin - 1));
51 }
else if (pin <= 10) {
57 tmp &= ~(1 << (pin - 3));
58 tmp |= (val << (pin - 3));
85 *val = (tmp >> (pin + 4)) & 0x01;
94 *val = (tmp >>
pin) & 0x01;
102 *val = (tmp >> (pin - 3)) & 0x01;
117 static int mxl111sf_config_gpio_pins(
struct mxl111sf_state *state,
125 switch (gpio_cfg->
pin) {
133 tmp &= ~(1 << (gpio_cfg->
pin + 4));
134 tmp |= (gpio_cfg->
dir << (gpio_cfg->
pin + 4));
146 tmp &= ~(1 << gpio_cfg->
pin);
147 tmp |= (gpio_cfg->
dir << gpio_cfg->
pin);
158 tmp &= ~(1 << (gpio_cfg->
pin - 3));
159 tmp |= (gpio_cfg->
dir << (gpio_cfg->
pin - 3));
169 mxl111sf_set_gpo_state(state,
170 gpio_cfg->
pin, gpio_cfg->
val) :
171 mxl111sf_get_gpi_state(state,
172 gpio_cfg->
pin, &gpio_cfg->
val);
187 mxl_debug(
"(%d, %d, %d)", gpio, direction, val);
189 return mxl111sf_config_gpio_pins(state, &gpio_config);
194 #define PIN_MUX_MPEG_MODE_MASK 0x40
195 #define PIN_MUX_MPEG_PAR_EN_MASK 0x01
196 #define PIN_MUX_MPEG_SER_EN_MASK 0x02
197 #define PIN_MUX_MPG_IN_MUX_MASK 0x80
198 #define PIN_MUX_BT656_ENABLE_MASK 0x04
199 #define PIN_MUX_I2S_ENABLE_MASK 0x40
200 #define PIN_MUX_SPI_MODE_MASK 0x10
201 #define PIN_MUX_MCLK_EN_CTRL_MASK 0x10
202 #define PIN_MUX_MPSYN_EN_CTRL_MASK 0x20
203 #define PIN_MUX_MDVAL_EN_CTRL_MASK 0x40
204 #define PIN_MUX_MPERR_EN_CTRL_MASK 0x80
205 #define PIN_MUX_MDAT_EN_0_MASK 0x10
206 #define PIN_MUX_MDAT_EN_1_MASK 0x20
207 #define PIN_MUX_MDAT_EN_2_MASK 0x40
208 #define PIN_MUX_MDAT_EN_3_MASK 0x80
209 #define PIN_MUX_MDAT_EN_4_MASK 0x10
210 #define PIN_MUX_MDAT_EN_5_MASK 0x20
211 #define PIN_MUX_MDAT_EN_6_MASK 0x40
212 #define PIN_MUX_MDAT_EN_7_MASK 0x80
247 switch (pin_mux_config) {
566 static int mxl111sf_hw_gpio_initialize(
struct mxl111sf_state *state)
573 for (i = 3; i < 8; i++) {
574 ret = mxl111sf_hw_set_gpio(state, i, (gpioval >> i) & 0x01);
582 #define PCA9534_I2C_ADDR (0x40 >> 1)
589 .flags = 0, .buf =
w, .len = 1 },
591 .flags =
I2C_M_RD, .buf = &
r, .len = 1 },
607 w[1] &= ~(1 <<
gpio);
610 w[1] |= ((val ? 1 : 0) << gpio);
618 static int pca9534_init_port_expander(
struct mxl111sf_state *state)
620 u8 w[2] = { 1, 0x07 };
624 .flags = 0, .buf =
w, .len = 2
647 "gpio_port_expander undefined, assuming PCA9534");
650 return pca9534_set_gpio(state, gpio, val);
652 return mxl111sf_hw_set_gpio(state, gpio, val);
656 static int mxl111sf_probe_port_expander(
struct mxl111sf_state *state)
662 { .flags = 0, .buf = &
w, .len = 1 },
663 { .flags =
I2C_M_RD, .buf = &
r, .len = 1 },
668 msg[0].
addr = 0x70 >> 1;
669 msg[1].
addr = 0x70 >> 1;
676 mxl_debug(
"found port expander at 0x%02x",
681 msg[0].
addr = 0x40 >> 1;
682 msg[1].
addr = 0x40 >> 1;
688 mxl_debug(
"found port expander at 0x%02x",
703 mxl111sf_probe_port_expander(state);
708 "gpio_port_expander undefined, assuming PCA9534");
711 return pca9534_init_port_expander(state);
713 return mxl111sf_hw_gpio_initialize(state);