Lines Matching +full:motor +full:- +full:driver
1 // SPDX-License-Identifier: GPL-2.0-or-later
3 * PlayStation 1/2 joypads via SPI interface Driver
11 * 1: DAT -> MISO (pullup with 1k owm to 3.3V)
12 * 2: CMD -> MOSI
13 * 3: 9V (for motor, if not use N.C.)
16 * 6: Attention -> CS(SS)
17 * 7: SCK -> SCK
19 * 9: ACK -> N.C.
75 .tx_buf = pad->sendbuf, in psxpad_command()
76 .rx_buf = pad->response, in psxpad_command()
81 err = spi_sync_transfer(pad->spi, &xfers, 1); in psxpad_command()
83 dev_err(&pad->spi->dev, in psxpad_command()
98 pad->motor1enable = motor1enable; in psxpad_control_motor()
99 pad->motor2enable = motor2enable; in psxpad_control_motor()
101 memcpy(pad->sendbuf, PSX_CMD_ENTER_CFG, sizeof(PSX_CMD_ENTER_CFG)); in psxpad_control_motor()
104 dev_err(&pad->spi->dev, in psxpad_control_motor()
110 memcpy(pad->sendbuf, PSX_CMD_ENABLE_MOTOR, in psxpad_control_motor()
112 pad->sendbuf[3] = pad->motor1enable ? 0x00 : 0xFF; in psxpad_control_motor()
113 pad->sendbuf[4] = pad->motor2enable ? 0x80 : 0xFF; in psxpad_control_motor()
116 dev_err(&pad->spi->dev, in psxpad_control_motor()
117 "%s: failed to enable motor mode: %d\n", in psxpad_control_motor()
122 memcpy(pad->sendbuf, PSX_CMD_EXIT_CFG, sizeof(PSX_CMD_EXIT_CFG)); in psxpad_control_motor()
125 dev_err(&pad->spi->dev, in psxpad_control_motor()
135 pad->motor1level = motor1level ? 0xFF : 0x00; in psxpad_set_motor_level()
136 pad->motor2level = REVERSE_BIT(motor2level); in psxpad_set_motor_level()
144 switch (effect->type) { in psxpad_spi_play_effect()
147 (effect->u.rumble.weak_magnitude >> 8) & 0xFFU, in psxpad_spi_play_effect()
148 (effect->u.rumble.strong_magnitude >> 8) & 0xFFU); in psxpad_spi_play_effect()
159 input_set_capability(pad->idev, EV_FF, FF_RUMBLE); in psxpad_spi_init_ff()
161 err = input_ff_create_memless(pad->idev, NULL, psxpad_spi_play_effect); in psxpad_spi_init_ff()
163 dev_err(&pad->spi->dev, in psxpad_spi_init_ff()
193 pm_runtime_get_sync(&pad->spi->dev); in psxpad_spi_poll_open()
202 pm_runtime_put_sync(&pad->spi->dev); in psxpad_spi_poll_close()
213 memcpy(pad->sendbuf, PSX_CMD_POLL, sizeof(PSX_CMD_POLL)); in psxpad_spi_poll()
214 pad->sendbuf[3] = pad->motor1enable ? pad->motor1level : 0x00; in psxpad_spi_poll()
215 pad->sendbuf[4] = pad->motor2enable ? pad->motor2level : 0x00; in psxpad_spi_poll()
218 dev_err(&pad->spi->dev, in psxpad_spi_poll()
223 switch (pad->response[1]) { in psxpad_spi_poll()
226 b_rsp3 = ~pad->response[3]; in psxpad_spi_poll()
227 b_rsp4 = ~pad->response[4]; in psxpad_spi_poll()
229 input_report_abs(input, ABS_X, REVERSE_BIT(pad->response[7])); in psxpad_spi_poll()
230 input_report_abs(input, ABS_Y, REVERSE_BIT(pad->response[8])); in psxpad_spi_poll()
231 input_report_abs(input, ABS_RX, REVERSE_BIT(pad->response[5])); in psxpad_spi_poll()
232 input_report_abs(input, ABS_RY, REVERSE_BIT(pad->response[6])); in psxpad_spi_poll()
253 b_rsp3 = ~pad->response[3]; in psxpad_spi_poll()
254 b_rsp4 = ~pad->response[4]; in psxpad_spi_poll()
288 pad = devm_kzalloc(&spi->dev, sizeof(struct psxpad), GFP_KERNEL); in psxpad_spi_probe()
290 return -ENOMEM; in psxpad_spi_probe()
292 idev = devm_input_allocate_device(&spi->dev); in psxpad_spi_probe()
294 dev_err(&spi->dev, "failed to allocate input device\n"); in psxpad_spi_probe()
295 return -ENOMEM; in psxpad_spi_probe()
299 pad->idev = idev; in psxpad_spi_probe()
300 pad->spi = spi; in psxpad_spi_probe()
305 idev->name = "PlayStation 1/2 joypad"; in psxpad_spi_probe()
306 snprintf(pad->phys, sizeof(pad->phys), "%s/input", dev_name(&spi->dev)); in psxpad_spi_probe()
307 idev->id.bustype = BUS_SPI; in psxpad_spi_probe()
309 idev->open = psxpad_spi_poll_open; in psxpad_spi_probe()
310 idev->close = psxpad_spi_poll_close; in psxpad_spi_probe()
339 spi->mode = SPI_MODE_3; in psxpad_spi_probe()
340 spi->bits_per_word = 8; in psxpad_spi_probe()
342 spi->master->min_speed_hz = 125000; in psxpad_spi_probe()
343 spi->master->max_speed_hz = 125000; in psxpad_spi_probe()
352 dev_err(&spi->dev, "failed to set up polling: %d\n", err); in psxpad_spi_probe()
364 dev_err(&spi->dev, in psxpad_spi_probe()
369 pm_runtime_enable(&spi->dev); in psxpad_spi_probe()
387 { "psxpad-spi", 0 },
393 .driver = {
394 .name = "psxpad-spi",
404 MODULE_DESCRIPTION("PlayStation 1/2 joypads via SPI interface Driver");