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.
78 .tx_buf = pad->sendbuf, in psxpad_command()
79 .rx_buf = pad->response, in psxpad_command()
84 err = spi_sync_transfer(pad->spi, &xfers, 1); in psxpad_command()
86 dev_err(&pad->spi->dev, in psxpad_command()
101 pad->motor1enable = motor1enable; in psxpad_control_motor()
102 pad->motor2enable = motor2enable; in psxpad_control_motor()
104 memcpy(pad->sendbuf, PSX_CMD_ENTER_CFG, sizeof(PSX_CMD_ENTER_CFG)); in psxpad_control_motor()
107 dev_err(&pad->spi->dev, in psxpad_control_motor()
113 memcpy(pad->sendbuf, PSX_CMD_ENABLE_MOTOR, in psxpad_control_motor()
115 pad->sendbuf[3] = pad->motor1enable ? 0x00 : 0xFF; in psxpad_control_motor()
116 pad->sendbuf[4] = pad->motor2enable ? 0x80 : 0xFF; in psxpad_control_motor()
119 dev_err(&pad->spi->dev, in psxpad_control_motor()
120 "%s: failed to enable motor mode: %d\n", in psxpad_control_motor()
125 memcpy(pad->sendbuf, PSX_CMD_EXIT_CFG, sizeof(PSX_CMD_EXIT_CFG)); in psxpad_control_motor()
128 dev_err(&pad->spi->dev, in psxpad_control_motor()
138 pad->motor1level = motor1level ? 0xFF : 0x00; in psxpad_set_motor_level()
139 pad->motor2level = REVERSE_BIT(motor2level); in psxpad_set_motor_level()
147 switch (effect->type) { in psxpad_spi_play_effect()
150 (effect->u.rumble.weak_magnitude >> 8) & 0xFFU, in psxpad_spi_play_effect()
151 (effect->u.rumble.strong_magnitude >> 8) & 0xFFU); in psxpad_spi_play_effect()
162 input_set_capability(pad->idev, EV_FF, FF_RUMBLE); in psxpad_spi_init_ff()
164 err = input_ff_create_memless(pad->idev, NULL, psxpad_spi_play_effect); in psxpad_spi_init_ff()
166 dev_err(&pad->spi->dev, in psxpad_spi_init_ff()
196 pm_runtime_get_sync(&pad->spi->dev); in psxpad_spi_poll_open()
205 pm_runtime_put_sync(&pad->spi->dev); in psxpad_spi_poll_close()
216 memcpy(pad->sendbuf, PSX_CMD_POLL, sizeof(PSX_CMD_POLL)); in psxpad_spi_poll()
217 pad->sendbuf[3] = pad->motor1enable ? pad->motor1level : 0x00; in psxpad_spi_poll()
218 pad->sendbuf[4] = pad->motor2enable ? pad->motor2level : 0x00; in psxpad_spi_poll()
221 dev_err(&pad->spi->dev, in psxpad_spi_poll()
226 switch (pad->response[1]) { in psxpad_spi_poll()
229 b_rsp3 = ~pad->response[3]; in psxpad_spi_poll()
230 b_rsp4 = ~pad->response[4]; in psxpad_spi_poll()
232 input_report_abs(input, ABS_X, REVERSE_BIT(pad->response[7])); in psxpad_spi_poll()
233 input_report_abs(input, ABS_Y, REVERSE_BIT(pad->response[8])); in psxpad_spi_poll()
234 input_report_abs(input, ABS_RX, REVERSE_BIT(pad->response[5])); in psxpad_spi_poll()
235 input_report_abs(input, ABS_RY, REVERSE_BIT(pad->response[6])); in psxpad_spi_poll()
256 b_rsp3 = ~pad->response[3]; in psxpad_spi_poll()
257 b_rsp4 = ~pad->response[4]; in psxpad_spi_poll()
291 pad = devm_kzalloc(&spi->dev, sizeof(struct psxpad), GFP_KERNEL); in psxpad_spi_probe()
293 return -ENOMEM; in psxpad_spi_probe()
295 idev = devm_input_allocate_device(&spi->dev); in psxpad_spi_probe()
297 dev_err(&spi->dev, "failed to allocate input device\n"); in psxpad_spi_probe()
298 return -ENOMEM; in psxpad_spi_probe()
302 pad->idev = idev; in psxpad_spi_probe()
303 pad->spi = spi; in psxpad_spi_probe()
308 idev->name = "PlayStation 1/2 joypad"; in psxpad_spi_probe()
309 snprintf(pad->phys, sizeof(pad->phys), "%s/input", dev_name(&spi->dev)); in psxpad_spi_probe()
310 idev->id.bustype = BUS_SPI; in psxpad_spi_probe()
312 idev->open = psxpad_spi_poll_open; in psxpad_spi_probe()
313 idev->close = psxpad_spi_poll_close; in psxpad_spi_probe()
342 spi->mode = SPI_MODE_3; in psxpad_spi_probe()
343 spi->bits_per_word = 8; in psxpad_spi_probe()
345 spi->controller->min_speed_hz = 125000; in psxpad_spi_probe()
346 spi->controller->max_speed_hz = 125000; in psxpad_spi_probe()
355 dev_err(&spi->dev, "failed to set up polling: %d\n", err); in psxpad_spi_probe()
367 dev_err(&spi->dev, in psxpad_spi_probe()
372 pm_runtime_enable(&spi->dev); in psxpad_spi_probe()
390 { "psxpad-spi", 0 },
396 .driver = {
397 .name = "psxpad-spi",
407 MODULE_DESCRIPTION("PlayStation 1/2 joypads via SPI interface Driver");