Lines Matching +full:reset +full:- +full:gpio
1 // SPDX-License-Identifier: GPL-2.0-or-later
3 * cx18 gpio functions
5 * Derived from ivtv-gpio.c
11 #include "cx18-driver.h"
12 #include "cx18-io.h"
13 #include "cx18-cards.h"
14 #include "cx18-gpio.h"
17 /********************* GPIO stuffs *********************/
19 /* GPIO registers */
27 * HVR-1600 GPIO pins, courtesy of Hauppauge:
29 * gpio0: zilog ir process reset pin
31 * gpio12: cx24227 reset pin
32 * gpio13: cs5345 reset pin
40 u32 dir_lo = cx->gpio_dir & 0xffff; in gpio_write()
41 u32 val_lo = cx->gpio_val & 0xffff; in gpio_write()
42 u32 dir_hi = cx->gpio_dir >> 16; in gpio_write()
43 u32 val_hi = cx->gpio_val >> 16; in gpio_write()
60 mutex_lock(&cx->gpio_lock); in gpio_update()
61 cx->gpio_val = (cx->gpio_val & ~mask) | (data & mask); in gpio_update()
63 mutex_unlock(&cx->gpio_lock); in gpio_update()
92 * GPIO Multiplexer - logical device
98 mutex_lock(&cx->gpio_lock); in gpiomux_log_status()
99 CX18_INFO_DEV(sd, "GPIO: direction 0x%08x, value 0x%08x\n", in gpiomux_log_status()
100 cx->gpio_dir, cx->gpio_val); in gpiomux_log_status()
101 mutex_unlock(&cx->gpio_lock); in gpiomux_log_status()
110 * FIXME - work out the cx->active/audio_input mess - this is in gpiomux_s_radio()
114 gpio_update(cx, cx->card->gpio_audio_input.mask, in gpiomux_s_radio()
115 cx->card->gpio_audio_input.radio); in gpiomux_s_radio()
124 switch (cx->card->audio_inputs[cx->audio_input].muxer_input) { in gpiomux_s_std()
126 data = cx->card->gpio_audio_input.linein; in gpiomux_s_std()
129 data = cx->card->gpio_audio_input.tuner; in gpiomux_s_std()
133 * FIXME - work out the cx->active/audio_input mess - this is in gpiomux_s_std()
137 data = cx->card->gpio_audio_input.tuner; in gpiomux_s_std()
140 gpio_update(cx, cx->card->gpio_audio_input.mask, data); in gpiomux_s_std()
152 data = cx->card->gpio_audio_input.tuner; in gpiomux_s_audio_routing()
155 data = cx->card->gpio_audio_input.linein; in gpiomux_s_audio_routing()
158 data = cx->card->gpio_audio_input.radio; in gpiomux_s_audio_routing()
161 return -EINVAL; in gpiomux_s_audio_routing()
163 gpio_update(cx, cx->card->gpio_audio_input.mask, data); in gpiomux_s_audio_routing()
191 * GPIO Reset Controller - logical device
197 mutex_lock(&cx->gpio_lock); in resetctrl_log_status()
198 CX18_INFO_DEV(sd, "GPIO: direction 0x%08x, value 0x%08x\n", in resetctrl_log_status()
199 cx->gpio_dir, cx->gpio_val); in resetctrl_log_status()
200 mutex_unlock(&cx->gpio_lock); in resetctrl_log_status()
209 p = &cx->card->gpio_i2c_slave_reset; in resetctrl_reset()
212 gpio_reset_seq(cx, p->active_lo_mask, p->active_hi_mask, in resetctrl_reset()
213 p->msecs_asserted, p->msecs_recovery); in resetctrl_reset()
217 * Assert timing for the Z8F0811 on HVR-1600 boards: in resetctrl_reset()
218 * 1. Assert RESET for min of 4 clock cycles at 18.432 MHz to in resetctrl_reset()
220 * 2. Reset then takes 66 WDT cycles at 10 kHz + 16 xtal clock in resetctrl_reset()
222 * 3. DBG pin must be high before chip exits reset for normal in resetctrl_reset()
224 * since we don't normally drive it (GPIO 1?) for the in resetctrl_reset()
225 * HVR-1600 in resetctrl_reset()
226 * 4. Z8F0811 won't exit reset until RESET is deasserted in resetctrl_reset()
227 * 5. Zilog comes out of reset, loads reset vector address and in resetctrl_reset()
230 gpio_reset_seq(cx, p->ir_reset_mask, 0, in resetctrl_reset()
231 p->msecs_asserted, p->msecs_recovery); in resetctrl_reset()
234 if (cx->card->tuners[0].tuner == TUNER_XC2028) in resetctrl_reset()
235 gpio_reset_seq(cx, (1 << cx->card->xceive_pin), 0, in resetctrl_reset()
244 .reset = resetctrl_reset,
256 mutex_lock(&cx->gpio_lock); in cx18_gpio_init()
257 cx->gpio_dir = cx->card->gpio_init.direction; in cx18_gpio_init()
258 cx->gpio_val = cx->card->gpio_init.initial_value; in cx18_gpio_init()
260 if (cx->card->tuners[0].tuner == TUNER_XC2028) { in cx18_gpio_init()
261 cx->gpio_dir |= 1 << cx->card->xceive_pin; in cx18_gpio_init()
262 cx->gpio_val |= 1 << cx->card->xceive_pin; in cx18_gpio_init()
265 if (cx->gpio_dir == 0) { in cx18_gpio_init()
266 mutex_unlock(&cx->gpio_lock); in cx18_gpio_init()
270 CX18_DEBUG_INFO("GPIO initial dir: %08x/%08x out: %08x/%08x\n", in cx18_gpio_init()
277 mutex_unlock(&cx->gpio_lock); in cx18_gpio_init()
288 sd = &cx->sd_gpiomux; in cx18_gpio_register()
290 str = "gpio-mux"; in cx18_gpio_register()
293 sd = &cx->sd_resetctrl; in cx18_gpio_register()
295 str = "gpio-reset-ctrl"; in cx18_gpio_register()
298 return -EINVAL; in cx18_gpio_register()
303 snprintf(sd->name, sizeof(sd->name), "%s %s", cx->v4l2_dev.name, str); in cx18_gpio_register()
304 sd->grp_id = hw; in cx18_gpio_register()
305 return v4l2_device_register_subdev(&cx->v4l2_dev, sd); in cx18_gpio_register()
312 if (cx->card->gpio_i2c_slave_reset.ir_reset_mask == 0) in cx18_reset_ir_gpio()
317 v4l2_subdev_call(&cx->sd_resetctrl, in cx18_reset_ir_gpio()
318 core, reset, CX18_GPIO_RESET_Z8F0811); in cx18_reset_ir_gpio()
321 /* This symbol is exported for use by lirc_pvr150 for the IR-blaster */
323 /* Xceive tuner reset function */
327 struct cx18_i2c_algo_callback_data *cb_data = algo->data; in cx18_reset_tuner_gpio()
328 struct cx18 *cx = cb_data->cx; in cx18_reset_tuner_gpio()
331 cx->card->tuners[0].tuner != TUNER_XC2028) in cx18_reset_tuner_gpio()
335 return v4l2_subdev_call(&cx->sd_resetctrl, in cx18_reset_tuner_gpio()
336 core, reset, CX18_GPIO_RESET_XC2028); in cx18_reset_tuner_gpio()