Re: [PATCH v7] Input: psxpad-spi - Add PlayStation 1/2 joypads via SPI interface Driver
Mr.Torokhov Mr.Herrmann I sent Playstation 1/2 joypads patch, Mr.Hrrmann's Ack-by added. Best regard.
Re: [PATCH v7] Input: psxpad-spi - Add PlayStation 1/2 joypads via SPI interface Driver
Mr.Torokhov Mr.Herrmann I sent Playstation 1/2 joypads patch, Mr.Hrrmann's Ack-by added. Best regard.
Re: [PATCH v7] Input: psxpad-spi - Add PlayStation 1/2 joypads via SPI interface Driver
Mr.Torokhov Mr.Herrmann > Anyway, I'd suggest leaving the patch unchanged. You can do the > modification as a follow-up. It is not urgent. I don't change now. Please continue with the processing. Regard. --- Tomohiro 2017-05-05 0:09 GMT+09:00 Tomohiro Yoshidomi: > Mr.Torokhov > Mr.Herrmann > >> The FF code could be select'ed rather than conditional. > > Sorry, I can't understand mean well. How I to do...? > > I should to fix, > > In 'config JOYSTICK_PSXPAD_SPI', > change 'select INPUT_POLLDEV' to > 'select INPUT_POLLDEV > select INPUT_FF_MEMLESS'. > > And > > In 'config JOYSTICK_PSXPAD_SPI_FF', > remove 'select INPUT_FF_MEMLESS'. > > ...Can I understand in the sense? > > Regard. > > > 2017-05-03 20:14 GMT+09:00 David Herrmann : >> Hey >> >> On Mon, May 1, 2017 at 9:47 PM, Dmitry Torokhov >> wrote: >>> On Sun, Apr 30, 2017 at 02:11:03PM +0900, Tomohiro Yoshidomi wrote: PlayStation 1/2 joypads can be connected directly to the SPI interface. Signed-off-by: Tomohiro Yoshidomi >>> >>> Benjamin, David, I think this driver now matches the gamepad spec that >>> we have in Drivers/input/gamepad.rst. Could you give it an one-over, as >>> far as mappings go, otherwise I think it can be applied and merged with >>> my 2nd pull request. >> >> Looks good to me: >> >> Acked-by: David Herrmann >> >> The FF code could be select'ed rather than conditional. Everything >> else looks fine. I didn't check the SPI internals though. Never >> touched SPI, sorry. >> >> Thanks >> David
Re: [PATCH v7] Input: psxpad-spi - Add PlayStation 1/2 joypads via SPI interface Driver
Mr.Torokhov Mr.Herrmann > Anyway, I'd suggest leaving the patch unchanged. You can do the > modification as a follow-up. It is not urgent. I don't change now. Please continue with the processing. Regard. --- Tomohiro 2017-05-05 0:09 GMT+09:00 Tomohiro Yoshidomi : > Mr.Torokhov > Mr.Herrmann > >> The FF code could be select'ed rather than conditional. > > Sorry, I can't understand mean well. How I to do...? > > I should to fix, > > In 'config JOYSTICK_PSXPAD_SPI', > change 'select INPUT_POLLDEV' to > 'select INPUT_POLLDEV > select INPUT_FF_MEMLESS'. > > And > > In 'config JOYSTICK_PSXPAD_SPI_FF', > remove 'select INPUT_FF_MEMLESS'. > > ...Can I understand in the sense? > > Regard. > > > 2017-05-03 20:14 GMT+09:00 David Herrmann : >> Hey >> >> On Mon, May 1, 2017 at 9:47 PM, Dmitry Torokhov >> wrote: >>> On Sun, Apr 30, 2017 at 02:11:03PM +0900, Tomohiro Yoshidomi wrote: PlayStation 1/2 joypads can be connected directly to the SPI interface. Signed-off-by: Tomohiro Yoshidomi >>> >>> Benjamin, David, I think this driver now matches the gamepad spec that >>> we have in Drivers/input/gamepad.rst. Could you give it an one-over, as >>> far as mappings go, otherwise I think it can be applied and merged with >>> my 2nd pull request. >> >> Looks good to me: >> >> Acked-by: David Herrmann >> >> The FF code could be select'ed rather than conditional. Everything >> else looks fine. I didn't check the SPI internals though. Never >> touched SPI, sorry. >> >> Thanks >> David
Re: [PATCH v7] Input: psxpad-spi - Add PlayStation 1/2 joypads via SPI interface Driver
Mr.Torokhov Mr.Herrmann > The FF code could be select'ed rather than conditional. Sorry, I can't understand mean well. How I to do...? I should to fix, In 'config JOYSTICK_PSXPAD_SPI', change 'select INPUT_POLLDEV' to 'select INPUT_POLLDEV select INPUT_FF_MEMLESS'. And In 'config JOYSTICK_PSXPAD_SPI_FF', remove 'select INPUT_FF_MEMLESS'. ...Can I understand in the sense? Regard. 2017-05-03 20:14 GMT+09:00 David Herrmann: > Hey > > On Mon, May 1, 2017 at 9:47 PM, Dmitry Torokhov > wrote: >> On Sun, Apr 30, 2017 at 02:11:03PM +0900, Tomohiro Yoshidomi wrote: >>> PlayStation 1/2 joypads can be connected directly to the SPI interface. >>> >>> Signed-off-by: Tomohiro Yoshidomi >> >> Benjamin, David, I think this driver now matches the gamepad spec that >> we have in Drivers/input/gamepad.rst. Could you give it an one-over, as >> far as mappings go, otherwise I think it can be applied and merged with >> my 2nd pull request. > > Looks good to me: > > Acked-by: David Herrmann > > The FF code could be select'ed rather than conditional. Everything > else looks fine. I didn't check the SPI internals though. Never > touched SPI, sorry. > > Thanks > David
Re: [PATCH v7] Input: psxpad-spi - Add PlayStation 1/2 joypads via SPI interface Driver
Mr.Torokhov Mr.Herrmann > The FF code could be select'ed rather than conditional. Sorry, I can't understand mean well. How I to do...? I should to fix, In 'config JOYSTICK_PSXPAD_SPI', change 'select INPUT_POLLDEV' to 'select INPUT_POLLDEV select INPUT_FF_MEMLESS'. And In 'config JOYSTICK_PSXPAD_SPI_FF', remove 'select INPUT_FF_MEMLESS'. ...Can I understand in the sense? Regard. 2017-05-03 20:14 GMT+09:00 David Herrmann : > Hey > > On Mon, May 1, 2017 at 9:47 PM, Dmitry Torokhov > wrote: >> On Sun, Apr 30, 2017 at 02:11:03PM +0900, Tomohiro Yoshidomi wrote: >>> PlayStation 1/2 joypads can be connected directly to the SPI interface. >>> >>> Signed-off-by: Tomohiro Yoshidomi >> >> Benjamin, David, I think this driver now matches the gamepad spec that >> we have in Drivers/input/gamepad.rst. Could you give it an one-over, as >> far as mappings go, otherwise I think it can be applied and merged with >> my 2nd pull request. > > Looks good to me: > > Acked-by: David Herrmann > > The FF code could be select'ed rather than conditional. Everything > else looks fine. I didn't check the SPI internals though. Never > touched SPI, sorry. > > Thanks > David
Re: [PATCH v7] Input: psxpad-spi - Add PlayStation 1/2 joypads via SPI interface Driver
Hey On Mon, May 1, 2017 at 9:47 PM, Dmitry Torokhovwrote: > On Sun, Apr 30, 2017 at 02:11:03PM +0900, Tomohiro Yoshidomi wrote: >> PlayStation 1/2 joypads can be connected directly to the SPI interface. >> >> Signed-off-by: Tomohiro Yoshidomi > > Benjamin, David, I think this driver now matches the gamepad spec that > we have in Drivers/input/gamepad.rst. Could you give it an one-over, as > far as mappings go, otherwise I think it can be applied and merged with > my 2nd pull request. Looks good to me: Acked-by: David Herrmann The FF code could be select'ed rather than conditional. Everything else looks fine. I didn't check the SPI internals though. Never touched SPI, sorry. Thanks David
Re: [PATCH v7] Input: psxpad-spi - Add PlayStation 1/2 joypads via SPI interface Driver
Hey On Mon, May 1, 2017 at 9:47 PM, Dmitry Torokhov wrote: > On Sun, Apr 30, 2017 at 02:11:03PM +0900, Tomohiro Yoshidomi wrote: >> PlayStation 1/2 joypads can be connected directly to the SPI interface. >> >> Signed-off-by: Tomohiro Yoshidomi > > Benjamin, David, I think this driver now matches the gamepad spec that > we have in Drivers/input/gamepad.rst. Could you give it an one-over, as > far as mappings go, otherwise I think it can be applied and merged with > my 2nd pull request. Looks good to me: Acked-by: David Herrmann The FF code could be select'ed rather than conditional. Everything else looks fine. I didn't check the SPI internals though. Never touched SPI, sorry. Thanks David
Re: [PATCH v7] Input: psxpad-spi - Add PlayStation 1/2 joypads via SPI interface Driver
On Sun, Apr 30, 2017 at 02:11:03PM +0900, Tomohiro Yoshidomi wrote: > PlayStation 1/2 joypads can be connected directly to the SPI interface. > > Signed-off-by: Tomohiro YoshidomiBenjamin, David, I think this driver now matches the gamepad spec that we have in Drivers/input/gamepad.rst. Could you give it an one-over, as far as mappings go, otherwise I think it can be applied and merged with my 2nd pull request. Thanks! > --- > drivers/input/joystick/Kconfig | 22 ++ > drivers/input/joystick/Makefile | 1 + > drivers/input/joystick/psxpad-spi.c | 438 > > 3 files changed, 461 insertions(+) > create mode 100644 drivers/input/joystick/psxpad-spi.c > > diff --git a/drivers/input/joystick/Kconfig b/drivers/input/joystick/Kconfig > index 4215b538..cbcb9a6e 100644 > --- a/drivers/input/joystick/Kconfig > +++ b/drivers/input/joystick/Kconfig > @@ -330,4 +330,26 @@ config JOYSTICK_MAPLE > To compile this as a module choose M here: the module will be called > maplecontrol. > > +config JOYSTICK_PSXPAD_SPI > + tristate "PlayStation 1/2 joypads via SPI interface" > + depends on SPI > + select INPUT_POLLDEV > + help > + Say Y here if you wish to connect PlayStation 1/2 joypads > + via SPI interface. > + > + To compile this driver as a module, choose M here: the > + module will be called psxpad-spi. > + > +config JOYSTICK_PSXPAD_SPI_FF > + bool "PlayStation 1/2 joypads force feedback (rumble) support" > + depends on JOYSTICK_PSXPAD_SPI > + select INPUT_FF_MEMLESS > + help > + Say Y here if you want to take advantage of > + PlayStation 1/2 joypads rumble features. > + > + To drive rumble motor, > + a dedicated power supply is required. > + > endif > diff --git a/drivers/input/joystick/Makefile b/drivers/input/joystick/Makefile > index 92dc0de9..496fd56b 100644 > --- a/drivers/input/joystick/Makefile > +++ b/drivers/input/joystick/Makefile > @@ -21,6 +21,7 @@ obj-$(CONFIG_JOYSTICK_INTERACT) += interact.o > obj-$(CONFIG_JOYSTICK_JOYDUMP) += joydump.o > obj-$(CONFIG_JOYSTICK_MAGELLAN) += magellan.o > obj-$(CONFIG_JOYSTICK_MAPLE) += maplecontrol.o > +obj-$(CONFIG_JOYSTICK_PSXPAD_SPI)+= psxpad-spi.o > obj-$(CONFIG_JOYSTICK_SIDEWINDER)+= sidewinder.o > obj-$(CONFIG_JOYSTICK_SPACEBALL) += spaceball.o > obj-$(CONFIG_JOYSTICK_SPACEORB) += spaceorb.o > diff --git a/drivers/input/joystick/psxpad-spi.c > b/drivers/input/joystick/psxpad-spi.c > new file mode 100644 > index ..2627aecb > --- /dev/null > +++ b/drivers/input/joystick/psxpad-spi.c > @@ -0,0 +1,438 @@ > +/* > + * PlayStation 1/2 joypads via SPI interface Driver > + * > + * Copyright (C) 2017 Tomohiro Yoshidomi > + * Licensed under the GPL-2 or later. > + * > + * PlayStation 1/2 joypad's plug (not socket) > + * 123 456 789 > + * (...|...|...) > + * > + * 1: DAT -> MISO (pullup with 1k owm to 3.3V) > + * 2: CMD -> MOSI > + * 3: 9V (for motor, if not use N.C.) > + * 4: GND > + * 5: 3.3V > + * 6: Attention -> CS(SS) > + * 7: SCK -> SCK > + * 8: N.C. > + * 9: ACK -> N.C. > + */ > + > +#include > +#include > +#include > +#include > +#include > +#include > +#include > +#include > +#include > + > +#define REVERSE_BIT(x) x) & 0x80) >> 7) | (((x) & 0x40) >> 5) | \ > + (((x) & 0x20) >> 3) | (((x) & 0x10) >> 1) | (((x) & 0x08) << 1) | \ > + (((x) & 0x04) << 3) | (((x) & 0x02) << 5) | (((x) & 0x01) << 7)) > + > +/* PlayStation 1/2 joypad command and response are LSBFIRST. */ > + > +/* 0x01, 0x42, 0x00, 0x00, 0x00, > + * 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, > + * 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 > + */ > +static const u8 PSX_CMD_POLL[] = { > + 0x80, 0x42, 0x00, 0x00, 0x00, > + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, > + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 > +}; > +/* 0x01, 0x43, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00 */ > +static const u8 PSX_CMD_ENTER_CFG[] = { > + 0x80, 0xC2, 0x00, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00 > +}; > +/* 0x01, 0x43, 0x00, 0x00, 0x5A, 0x5A, 0x5A, 0x5A, 0x5A */ > +static const u8 PSX_CMD_EXIT_CFG[] = { > + 0x80, 0xC2, 0x00, 0x00, 0x5A, 0x5A, 0x5A, 0x5A, 0x5A > +}; > +/* 0x01, 0x4D, 0x00, 0x00, 0x01, 0xFF, 0xFF, 0xFF, 0xFF */ > +static const u8 PSX_CMD_ENABLE_MOTOR[] = { > + 0x80, 0xB2, 0x00, 0x00, 0x80, 0xFF, 0xFF, 0xFF, 0xFF > +}; > + > +struct psxpad { > + struct spi_device *spi; > + struct input_polled_dev *pdev; > + struct input_dev *idev; > + char phys[0x20]; > + bool motor1enable; > + bool motor2enable; > + u8 motor1level; > + u8 motor2level; > + u8 sendbuf[0x20] cacheline_aligned; > + u8 response[sizeof(PSX_CMD_POLL)] cacheline_aligned; > +}; > + > +static int psxpad_command(struct psxpad *pad, const u8 sendcmdlen) > +{
Re: [PATCH v7] Input: psxpad-spi - Add PlayStation 1/2 joypads via SPI interface Driver
On Sun, Apr 30, 2017 at 02:11:03PM +0900, Tomohiro Yoshidomi wrote: > PlayStation 1/2 joypads can be connected directly to the SPI interface. > > Signed-off-by: Tomohiro Yoshidomi Benjamin, David, I think this driver now matches the gamepad spec that we have in Drivers/input/gamepad.rst. Could you give it an one-over, as far as mappings go, otherwise I think it can be applied and merged with my 2nd pull request. Thanks! > --- > drivers/input/joystick/Kconfig | 22 ++ > drivers/input/joystick/Makefile | 1 + > drivers/input/joystick/psxpad-spi.c | 438 > > 3 files changed, 461 insertions(+) > create mode 100644 drivers/input/joystick/psxpad-spi.c > > diff --git a/drivers/input/joystick/Kconfig b/drivers/input/joystick/Kconfig > index 4215b538..cbcb9a6e 100644 > --- a/drivers/input/joystick/Kconfig > +++ b/drivers/input/joystick/Kconfig > @@ -330,4 +330,26 @@ config JOYSTICK_MAPLE > To compile this as a module choose M here: the module will be called > maplecontrol. > > +config JOYSTICK_PSXPAD_SPI > + tristate "PlayStation 1/2 joypads via SPI interface" > + depends on SPI > + select INPUT_POLLDEV > + help > + Say Y here if you wish to connect PlayStation 1/2 joypads > + via SPI interface. > + > + To compile this driver as a module, choose M here: the > + module will be called psxpad-spi. > + > +config JOYSTICK_PSXPAD_SPI_FF > + bool "PlayStation 1/2 joypads force feedback (rumble) support" > + depends on JOYSTICK_PSXPAD_SPI > + select INPUT_FF_MEMLESS > + help > + Say Y here if you want to take advantage of > + PlayStation 1/2 joypads rumble features. > + > + To drive rumble motor, > + a dedicated power supply is required. > + > endif > diff --git a/drivers/input/joystick/Makefile b/drivers/input/joystick/Makefile > index 92dc0de9..496fd56b 100644 > --- a/drivers/input/joystick/Makefile > +++ b/drivers/input/joystick/Makefile > @@ -21,6 +21,7 @@ obj-$(CONFIG_JOYSTICK_INTERACT) += interact.o > obj-$(CONFIG_JOYSTICK_JOYDUMP) += joydump.o > obj-$(CONFIG_JOYSTICK_MAGELLAN) += magellan.o > obj-$(CONFIG_JOYSTICK_MAPLE) += maplecontrol.o > +obj-$(CONFIG_JOYSTICK_PSXPAD_SPI)+= psxpad-spi.o > obj-$(CONFIG_JOYSTICK_SIDEWINDER)+= sidewinder.o > obj-$(CONFIG_JOYSTICK_SPACEBALL) += spaceball.o > obj-$(CONFIG_JOYSTICK_SPACEORB) += spaceorb.o > diff --git a/drivers/input/joystick/psxpad-spi.c > b/drivers/input/joystick/psxpad-spi.c > new file mode 100644 > index ..2627aecb > --- /dev/null > +++ b/drivers/input/joystick/psxpad-spi.c > @@ -0,0 +1,438 @@ > +/* > + * PlayStation 1/2 joypads via SPI interface Driver > + * > + * Copyright (C) 2017 Tomohiro Yoshidomi > + * Licensed under the GPL-2 or later. > + * > + * PlayStation 1/2 joypad's plug (not socket) > + * 123 456 789 > + * (...|...|...) > + * > + * 1: DAT -> MISO (pullup with 1k owm to 3.3V) > + * 2: CMD -> MOSI > + * 3: 9V (for motor, if not use N.C.) > + * 4: GND > + * 5: 3.3V > + * 6: Attention -> CS(SS) > + * 7: SCK -> SCK > + * 8: N.C. > + * 9: ACK -> N.C. > + */ > + > +#include > +#include > +#include > +#include > +#include > +#include > +#include > +#include > +#include > + > +#define REVERSE_BIT(x) x) & 0x80) >> 7) | (((x) & 0x40) >> 5) | \ > + (((x) & 0x20) >> 3) | (((x) & 0x10) >> 1) | (((x) & 0x08) << 1) | \ > + (((x) & 0x04) << 3) | (((x) & 0x02) << 5) | (((x) & 0x01) << 7)) > + > +/* PlayStation 1/2 joypad command and response are LSBFIRST. */ > + > +/* 0x01, 0x42, 0x00, 0x00, 0x00, > + * 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, > + * 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 > + */ > +static const u8 PSX_CMD_POLL[] = { > + 0x80, 0x42, 0x00, 0x00, 0x00, > + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, > + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 > +}; > +/* 0x01, 0x43, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00 */ > +static const u8 PSX_CMD_ENTER_CFG[] = { > + 0x80, 0xC2, 0x00, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00 > +}; > +/* 0x01, 0x43, 0x00, 0x00, 0x5A, 0x5A, 0x5A, 0x5A, 0x5A */ > +static const u8 PSX_CMD_EXIT_CFG[] = { > + 0x80, 0xC2, 0x00, 0x00, 0x5A, 0x5A, 0x5A, 0x5A, 0x5A > +}; > +/* 0x01, 0x4D, 0x00, 0x00, 0x01, 0xFF, 0xFF, 0xFF, 0xFF */ > +static const u8 PSX_CMD_ENABLE_MOTOR[] = { > + 0x80, 0xB2, 0x00, 0x00, 0x80, 0xFF, 0xFF, 0xFF, 0xFF > +}; > + > +struct psxpad { > + struct spi_device *spi; > + struct input_polled_dev *pdev; > + struct input_dev *idev; > + char phys[0x20]; > + bool motor1enable; > + bool motor2enable; > + u8 motor1level; > + u8 motor2level; > + u8 sendbuf[0x20] cacheline_aligned; > + u8 response[sizeof(PSX_CMD_POLL)] cacheline_aligned; > +}; > + > +static int psxpad_command(struct psxpad *pad, const u8 sendcmdlen) > +{ > + struct spi_transfer xfers = { >
Re: [PATCH v7] Input: psxpad-spi - Add PlayStation 1/2 joypads via SPI interface Driver
Mr.Torokhov I fixed source, and sent PATCH v7 to you. I'm sorry to occars warnings. * In function 'psxpad_spi_probe', removed uninitialized value 'err' in dev_err(). * 'psxpad_spi_resume' restored. Regards. -- Tomohiro
Re: [PATCH v7] Input: psxpad-spi - Add PlayStation 1/2 joypads via SPI interface Driver
Mr.Torokhov I fixed source, and sent PATCH v7 to you. I'm sorry to occars warnings. * In function 'psxpad_spi_probe', removed uninitialized value 'err' in dev_err(). * 'psxpad_spi_resume' restored. Regards. -- Tomohiro
Re: [PATCH v7] Input: psxpad-spi - Add PlayStation 1/2 joypads via SPI interface Driver
Mr.Torokhov I fixed source, and sent PATCH v7 to you. I'm sorry to occars warnings. * In function 'psxpad_spi_probe', removed uninitialized value 'err' in dev_err(). * 'psxpad_spi_resume' restored. Regards. -- Tomohiro
Re: [PATCH v7] Input: psxpad-spi - Add PlayStation 1/2 joypads via SPI interface Driver
Mr.Torokhov I fixed source, and sent PATCH v7 to you. I'm sorry to occars warnings. * In function 'psxpad_spi_probe', removed uninitialized value 'err' in dev_err(). * 'psxpad_spi_resume' restored. Regards. -- Tomohiro
[PATCH v7] Input: psxpad-spi - Add PlayStation 1/2 joypads via SPI interface Driver
PlayStation 1/2 joypads can be connected directly to the SPI interface. Signed-off-by: Tomohiro Yoshidomi--- drivers/input/joystick/Kconfig | 22 ++ drivers/input/joystick/Makefile | 1 + drivers/input/joystick/psxpad-spi.c | 438 3 files changed, 461 insertions(+) create mode 100644 drivers/input/joystick/psxpad-spi.c diff --git a/drivers/input/joystick/Kconfig b/drivers/input/joystick/Kconfig index 4215b538..cbcb9a6e 100644 --- a/drivers/input/joystick/Kconfig +++ b/drivers/input/joystick/Kconfig @@ -330,4 +330,26 @@ config JOYSTICK_MAPLE To compile this as a module choose M here: the module will be called maplecontrol. +config JOYSTICK_PSXPAD_SPI + tristate "PlayStation 1/2 joypads via SPI interface" + depends on SPI + select INPUT_POLLDEV + help + Say Y here if you wish to connect PlayStation 1/2 joypads + via SPI interface. + + To compile this driver as a module, choose M here: the + module will be called psxpad-spi. + +config JOYSTICK_PSXPAD_SPI_FF + bool "PlayStation 1/2 joypads force feedback (rumble) support" + depends on JOYSTICK_PSXPAD_SPI + select INPUT_FF_MEMLESS + help + Say Y here if you want to take advantage of + PlayStation 1/2 joypads rumble features. + + To drive rumble motor, + a dedicated power supply is required. + endif diff --git a/drivers/input/joystick/Makefile b/drivers/input/joystick/Makefile index 92dc0de9..496fd56b 100644 --- a/drivers/input/joystick/Makefile +++ b/drivers/input/joystick/Makefile @@ -21,6 +21,7 @@ obj-$(CONFIG_JOYSTICK_INTERACT) += interact.o obj-$(CONFIG_JOYSTICK_JOYDUMP) += joydump.o obj-$(CONFIG_JOYSTICK_MAGELLAN)+= magellan.o obj-$(CONFIG_JOYSTICK_MAPLE) += maplecontrol.o +obj-$(CONFIG_JOYSTICK_PSXPAD_SPI) += psxpad-spi.o obj-$(CONFIG_JOYSTICK_SIDEWINDER) += sidewinder.o obj-$(CONFIG_JOYSTICK_SPACEBALL) += spaceball.o obj-$(CONFIG_JOYSTICK_SPACEORB)+= spaceorb.o diff --git a/drivers/input/joystick/psxpad-spi.c b/drivers/input/joystick/psxpad-spi.c new file mode 100644 index ..2627aecb --- /dev/null +++ b/drivers/input/joystick/psxpad-spi.c @@ -0,0 +1,438 @@ +/* + * PlayStation 1/2 joypads via SPI interface Driver + * + * Copyright (C) 2017 Tomohiro Yoshidomi + * Licensed under the GPL-2 or later. + * + * PlayStation 1/2 joypad's plug (not socket) + * 123 456 789 + * (...|...|...) + * + * 1: DAT -> MISO (pullup with 1k owm to 3.3V) + * 2: CMD -> MOSI + * 3: 9V (for motor, if not use N.C.) + * 4: GND + * 5: 3.3V + * 6: Attention -> CS(SS) + * 7: SCK -> SCK + * 8: N.C. + * 9: ACK -> N.C. + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#define REVERSE_BIT(x) x) & 0x80) >> 7) | (((x) & 0x40) >> 5) | \ + (((x) & 0x20) >> 3) | (((x) & 0x10) >> 1) | (((x) & 0x08) << 1) | \ + (((x) & 0x04) << 3) | (((x) & 0x02) << 5) | (((x) & 0x01) << 7)) + +/* PlayStation 1/2 joypad command and response are LSBFIRST. */ + +/* 0x01, 0x42, 0x00, 0x00, 0x00, + * 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + * 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 + */ +static const u8 PSX_CMD_POLL[] = { + 0x80, 0x42, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 +}; +/* 0x01, 0x43, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00 */ +static const u8 PSX_CMD_ENTER_CFG[] = { + 0x80, 0xC2, 0x00, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00 +}; +/* 0x01, 0x43, 0x00, 0x00, 0x5A, 0x5A, 0x5A, 0x5A, 0x5A */ +static const u8 PSX_CMD_EXIT_CFG[] = { + 0x80, 0xC2, 0x00, 0x00, 0x5A, 0x5A, 0x5A, 0x5A, 0x5A +}; +/* 0x01, 0x4D, 0x00, 0x00, 0x01, 0xFF, 0xFF, 0xFF, 0xFF */ +static const u8 PSX_CMD_ENABLE_MOTOR[] = { + 0x80, 0xB2, 0x00, 0x00, 0x80, 0xFF, 0xFF, 0xFF, 0xFF +}; + +struct psxpad { + struct spi_device *spi; + struct input_polled_dev *pdev; + struct input_dev *idev; + char phys[0x20]; + bool motor1enable; + bool motor2enable; + u8 motor1level; + u8 motor2level; + u8 sendbuf[0x20] cacheline_aligned; + u8 response[sizeof(PSX_CMD_POLL)] cacheline_aligned; +}; + +static int psxpad_command(struct psxpad *pad, const u8 sendcmdlen) +{ + struct spi_transfer xfers = { + .tx_buf = pad->sendbuf, + .rx_buf = pad->response, + .len= sendcmdlen, + }; + int err; + + err = spi_sync_transfer(pad->spi, , 1); + if (err) { + dev_err(>spi->dev, + "%s: failed to SPI xfers mode: %d\n", + __func__, err); + return err; + } + + return 0; +} + +#ifdef
[PATCH v7] Input: psxpad-spi - Add PlayStation 1/2 joypads via SPI interface Driver
PlayStation 1/2 joypads can be connected directly to the SPI interface. Signed-off-by: Tomohiro Yoshidomi --- drivers/input/joystick/Kconfig | 22 ++ drivers/input/joystick/Makefile | 1 + drivers/input/joystick/psxpad-spi.c | 438 3 files changed, 461 insertions(+) create mode 100644 drivers/input/joystick/psxpad-spi.c diff --git a/drivers/input/joystick/Kconfig b/drivers/input/joystick/Kconfig index 4215b538..cbcb9a6e 100644 --- a/drivers/input/joystick/Kconfig +++ b/drivers/input/joystick/Kconfig @@ -330,4 +330,26 @@ config JOYSTICK_MAPLE To compile this as a module choose M here: the module will be called maplecontrol. +config JOYSTICK_PSXPAD_SPI + tristate "PlayStation 1/2 joypads via SPI interface" + depends on SPI + select INPUT_POLLDEV + help + Say Y here if you wish to connect PlayStation 1/2 joypads + via SPI interface. + + To compile this driver as a module, choose M here: the + module will be called psxpad-spi. + +config JOYSTICK_PSXPAD_SPI_FF + bool "PlayStation 1/2 joypads force feedback (rumble) support" + depends on JOYSTICK_PSXPAD_SPI + select INPUT_FF_MEMLESS + help + Say Y here if you want to take advantage of + PlayStation 1/2 joypads rumble features. + + To drive rumble motor, + a dedicated power supply is required. + endif diff --git a/drivers/input/joystick/Makefile b/drivers/input/joystick/Makefile index 92dc0de9..496fd56b 100644 --- a/drivers/input/joystick/Makefile +++ b/drivers/input/joystick/Makefile @@ -21,6 +21,7 @@ obj-$(CONFIG_JOYSTICK_INTERACT) += interact.o obj-$(CONFIG_JOYSTICK_JOYDUMP) += joydump.o obj-$(CONFIG_JOYSTICK_MAGELLAN)+= magellan.o obj-$(CONFIG_JOYSTICK_MAPLE) += maplecontrol.o +obj-$(CONFIG_JOYSTICK_PSXPAD_SPI) += psxpad-spi.o obj-$(CONFIG_JOYSTICK_SIDEWINDER) += sidewinder.o obj-$(CONFIG_JOYSTICK_SPACEBALL) += spaceball.o obj-$(CONFIG_JOYSTICK_SPACEORB)+= spaceorb.o diff --git a/drivers/input/joystick/psxpad-spi.c b/drivers/input/joystick/psxpad-spi.c new file mode 100644 index ..2627aecb --- /dev/null +++ b/drivers/input/joystick/psxpad-spi.c @@ -0,0 +1,438 @@ +/* + * PlayStation 1/2 joypads via SPI interface Driver + * + * Copyright (C) 2017 Tomohiro Yoshidomi + * Licensed under the GPL-2 or later. + * + * PlayStation 1/2 joypad's plug (not socket) + * 123 456 789 + * (...|...|...) + * + * 1: DAT -> MISO (pullup with 1k owm to 3.3V) + * 2: CMD -> MOSI + * 3: 9V (for motor, if not use N.C.) + * 4: GND + * 5: 3.3V + * 6: Attention -> CS(SS) + * 7: SCK -> SCK + * 8: N.C. + * 9: ACK -> N.C. + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#define REVERSE_BIT(x) x) & 0x80) >> 7) | (((x) & 0x40) >> 5) | \ + (((x) & 0x20) >> 3) | (((x) & 0x10) >> 1) | (((x) & 0x08) << 1) | \ + (((x) & 0x04) << 3) | (((x) & 0x02) << 5) | (((x) & 0x01) << 7)) + +/* PlayStation 1/2 joypad command and response are LSBFIRST. */ + +/* 0x01, 0x42, 0x00, 0x00, 0x00, + * 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + * 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 + */ +static const u8 PSX_CMD_POLL[] = { + 0x80, 0x42, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 +}; +/* 0x01, 0x43, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00 */ +static const u8 PSX_CMD_ENTER_CFG[] = { + 0x80, 0xC2, 0x00, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00 +}; +/* 0x01, 0x43, 0x00, 0x00, 0x5A, 0x5A, 0x5A, 0x5A, 0x5A */ +static const u8 PSX_CMD_EXIT_CFG[] = { + 0x80, 0xC2, 0x00, 0x00, 0x5A, 0x5A, 0x5A, 0x5A, 0x5A +}; +/* 0x01, 0x4D, 0x00, 0x00, 0x01, 0xFF, 0xFF, 0xFF, 0xFF */ +static const u8 PSX_CMD_ENABLE_MOTOR[] = { + 0x80, 0xB2, 0x00, 0x00, 0x80, 0xFF, 0xFF, 0xFF, 0xFF +}; + +struct psxpad { + struct spi_device *spi; + struct input_polled_dev *pdev; + struct input_dev *idev; + char phys[0x20]; + bool motor1enable; + bool motor2enable; + u8 motor1level; + u8 motor2level; + u8 sendbuf[0x20] cacheline_aligned; + u8 response[sizeof(PSX_CMD_POLL)] cacheline_aligned; +}; + +static int psxpad_command(struct psxpad *pad, const u8 sendcmdlen) +{ + struct spi_transfer xfers = { + .tx_buf = pad->sendbuf, + .rx_buf = pad->response, + .len= sendcmdlen, + }; + int err; + + err = spi_sync_transfer(pad->spi, , 1); + if (err) { + dev_err(>spi->dev, + "%s: failed to SPI xfers mode: %d\n", + __func__, err); + return err; + } + + return 0; +} + +#ifdef CONFIG_JOYSTICK_PSXPAD_SPI_FF +static void