Re: [PATCH] input: spi: Driver for SPI data stream driven vibrator

2010-10-26 Thread Alan Cox
  +   if (!einfo-buf) {
  +   einfo-buf = kzalloc(datalen, GFP_KERNEL | GFP_DMA);
  +   if (!einfo-buf) {
  +   ret = -ENOMEM;
  +   goto exit;
  +   }
  +   }
  +
  +   memcpy(einfo-buf, p-custom_data, datalen);
 
 It looks like raw data from userspace is being passed on to the
 device.  Is this sane?  Is there already a data format used by other
 vibration/feedback devices that should be used here instead and
 translated into the form expected by the hardware?

It also seems to be using GFP_DMA not dma_alloc functions which looks a
bit odd and certainly isn't portable.


--
Nokia and ATT present the 2010 Calling All Innovators-North America contest
Create new apps  games for the Nokia N8 for consumers in  U.S. and Canada
$10 million total in prizes - $4M cash, 500 devices, nearly $6M in marketing
Develop with Nokia Qt SDK, Web Runtime, or Java and Publish to Ovi Store 
http://p.sf.net/sfu/nokia-dev2dev
___
spi-devel-general mailing list
spi-devel-general@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/spi-devel-general


Re: [PATCH] input: spi: Driver for SPI data stream driven vibrator

2010-10-26 Thread Grant Likely
On Mon, Oct 25, 2010 at 04:31:02PM +0300, Ilkka Koskinen wrote:
 This driver provides access to drive a vibrator connected
 to SPI data line via Input layer's Force Feedback interface.
 
 Client application provides samples (data streams) to be
 played as CUSTOM_DATA. The samples are stored in driver's
 internal buffers.
 
 The driver is not able to mix the given samples. Instead, it
 remembers the currently played sample and next one to be played.
 
 Signed-off-by: Ilkka Koskinen ilkka.koski...@nokia.com

Hi Ilkka,

comments below...

 ---
  drivers/input/misc/Kconfig |5 +
  drivers/input/misc/Makefile|2 +-
  drivers/input/misc/vibra_spi.c |  429 
 
  include/linux/spi/vibra.h  |   34 
  4 files changed, 469 insertions(+), 1 deletions(-)
  create mode 100644 drivers/input/misc/vibra_spi.c
  create mode 100644 include/linux/spi/vibra.h
 
 diff --git a/drivers/input/misc/Kconfig b/drivers/input/misc/Kconfig
 index b49e233..3441832 100644
 --- a/drivers/input/misc/Kconfig
 +++ b/drivers/input/misc/Kconfig
 @@ -438,4 +438,9 @@ config INPUT_ADXL34X_SPI
 To compile this driver as a module, choose M here: the
 module will be called adxl34x-spi.
  
 +config INPUT_SPI_VIBRA

To match convention already used in this file: config INPUT_VIBRA_SPI

 + tristate Support for SPI driven Vibra module
 + help
 +   Support for Vibra module that is connected to OMAP SPI bus.

Is this an OMAP specific device?

 +
  endif
 diff --git a/drivers/input/misc/Makefile b/drivers/input/misc/Makefile
 index 19ccca7..cde272f 100644
 --- a/drivers/input/misc/Makefile
 +++ b/drivers/input/misc/Makefile
 @@ -41,4 +41,4 @@ obj-$(CONFIG_INPUT_WINBOND_CIR) += winbond-cir.o
  obj-$(CONFIG_INPUT_WISTRON_BTNS) += wistron_btns.o
  obj-$(CONFIG_INPUT_WM831X_ON)+= wm831x-on.o
  obj-$(CONFIG_INPUT_YEALINK)  += yealink.o
 -
 +obj-$(CONFIG_INPUT_SPI_VIBRA)  += vibra_spi.o

This file is nominally alphabetical sorted.  Put this line between
CONFIG_INPUT_UINPUT and CONFIG_INPUT_WINBOND_CIR. Also, whitespace
inconsistency.  Use tabs for indent.

 diff --git a/drivers/input/misc/vibra_spi.c b/drivers/input/misc/vibra_spi.c
 new file mode 100644
 index 000..551a3b8
 --- /dev/null
 +++ b/drivers/input/misc/vibra_spi.c
 @@ -0,0 +1,429 @@
 +/*
 + * This file implements a driver for SPI data driven vibrator.
 + *
 + * Copyright (C) 2010 Nokia Corporation
 + *
 + * Contact: Ilkka Koskinen ilkka.koski...@nokia.com
 + *
 + * This program is free software; you can redistribute it and/or
 + * modify it under the terms of the GNU General Public License
 + * version 2 as published by the Free Software Foundation.
 + *
 + * This program is distributed in the hope that it will be useful, but
 + * WITHOUT ANY WARRANTY; without even the implied warranty of
 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 + * General Public License for more details.
 + *
 + * You should have received a copy of the GNU General Public License
 + * along with this program; if not, write to the Free Software
 + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
 + * 02110-1301 USA
 + *
 + */
 +
 +#include linux/irq.h
 +#include linux/module.h
 +#include linux/workqueue.h
 +#include linux/spinlock.h
 +#include linux/delay.h
 +#include linux/slab.h
 +#include linux/jiffies.h
 +#include linux/spi/spi.h
 +#include linux/input.h
 +#include linux/spi/vibra.h
 +#include linux/io.h
 +
 +/* Number of effects handled with memoryless devices */
 +#define VIBRA_EFFECTS36
 +#define MAX_EFFECT_SIZE  1024 /* In bytes */
 +
 +#define FF_EFFECT_QUEUED 0
 +#define FF_EFFECT_PLAYING1
 +#define FF_EFFECT_ABORTING   2
 +#define FF_EFFECT_UPLOADING  3

These are only ever used in a bitfield.  The code will be simpler if
you change this to:

#define FF_EFFECT_QUEUED(10)
#define FF_EFFECT_PLAYING   (11)
#define FF_EFFECT_ABORTING  (12)
#define FF_EFFECT_UPLOADING (13)

That way the test_bit() and __set_bit() calls can be replaced with
regular bitwise operators, and the code will be easier to read.

 +
 +enum vibra_status {
 + IDLE = 0,
 + STARTED,
 + PLAYING,
 + CLOSING,
 +};
 +
 +struct effect_info {

struct vibra_effect_info

 + char*buf;
 + int buflen;
 + unsigned long   flags;  /* effect state (STARTED, PLAYING, etc) */
 + unsigned long   stop_at;
 +};
 +
 +struct vibra_data {
 + struct device   *dev;
 + struct input_dev*input_dev;
 +
 + struct workqueue_struct *workqueue;
 + struct work_struct  play_work;
 +
 + struct spi_device   *spi_dev;
 + struct spi_transfer t;
 + struct spi_message  msg;
 + u32 spi_max_speed_hz;
 +
 + void (*set_power)(bool enable);
 +
 + enum vibra_status   status;
 +
 + struct effect_info  

Re: [PATCH] input: spi: Driver for SPI data stream driven vibrator

2010-10-26 Thread Dmitry Torokhov
Hi Ilkka,

On Mon, Oct 25, 2010 at 04:31:02PM +0300, Ilkka Koskinen wrote:
 This driver provides access to drive a vibrator connected
 to SPI data line via Input layer's Force Feedback interface.
 
 Client application provides samples (data streams) to be
 played as CUSTOM_DATA. The samples are stored in driver's
 internal buffers.

If device is able to do custom waveform can't it also do regular effects
(constant, periodic, etc. Or is custom is actually random and you are
doing something like rumble effect?

 
 The driver is not able to mix the given samples. Instead, it
 remembers the currently played sample and next one to be played.
 

Why is this driver not using the memoryless FF  library (and extends it
to handle FF_CUSTOM effects) but rather reimplements it in the driver
itself?

 Signed-off-by: Ilkka Koskinen ilkka.koski...@nokia.com
 ---
  drivers/input/misc/Kconfig |5 +
  drivers/input/misc/Makefile|2 +-
  drivers/input/misc/vibra_spi.c |  429 
 
  include/linux/spi/vibra.h  |   34 
  4 files changed, 469 insertions(+), 1 deletions(-)
  create mode 100644 drivers/input/misc/vibra_spi.c
  create mode 100644 include/linux/spi/vibra.h
 
 diff --git a/drivers/input/misc/Kconfig b/drivers/input/misc/Kconfig
 index b49e233..3441832 100644
 --- a/drivers/input/misc/Kconfig
 +++ b/drivers/input/misc/Kconfig
 @@ -438,4 +438,9 @@ config INPUT_ADXL34X_SPI
 To compile this driver as a module, choose M here: the
 module will be called adxl34x-spi.
  
 +config INPUT_SPI_VIBRA
 + tristate Support for SPI driven Vibra module
 + help
 +   Support for Vibra module that is connected to OMAP SPI bus.
 +

To compile this driver as a module. Also please keep Kconfig and
Makefile sorted alphabetically.

Thanks.

-- 
Dmitry

--
Nokia and ATT present the 2010 Calling All Innovators-North America contest
Create new apps  games for the Nokia N8 for consumers in  U.S. and Canada
$10 million total in prizes - $4M cash, 500 devices, nearly $6M in marketing
Develop with Nokia Qt SDK, Web Runtime, or Java and Publish to Ovi Store 
http://p.sf.net/sfu/nokia-dev2dev
___
spi-devel-general mailing list
spi-devel-general@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/spi-devel-general


RE: [PATCH] input: spi: Driver for SPI data stream driven vibrator

2010-10-26 Thread ilkka.koskinen
Hi Grant and thanks for comments,

From: Grant Likely [mailto:glik...@secretlab.ca] On Behalf Of ext Grant
Likely
Sent: 26 October, 2010 14:14
Subject: Re: [PATCH] input: spi: Driver for SPI data stream driven
vibrator

On Mon, Oct 25, 2010 at 04:31:02PM +0300, Ilkka Koskinen wrote:
 This driver provides access to drive a vibrator connected
 to SPI data line via Input layer's Force Feedback interface.

 Client application provides samples (data streams) to be
 played as CUSTOM_DATA. The samples are stored in driver's
 internal buffers.

 The driver is not able to mix the given samples. Instead, it
 remembers the currently played sample and next one to be played.

 Signed-off-by: Ilkka Koskinen ilkka.koski...@nokia.com

Hi Ilkka,

comments below...

 ---
  drivers/input/misc/Kconfig |5 +
  drivers/input/misc/Makefile|2 +-
  drivers/input/misc/vibra_spi.c |  429

  include/linux/spi/vibra.h  |   34 
  4 files changed, 469 insertions(+), 1 deletions(-)
  create mode 100644 drivers/input/misc/vibra_spi.c
  create mode 100644 include/linux/spi/vibra.h

 diff --git a/drivers/input/misc/Kconfig b/drivers/input/misc/Kconfig
 index b49e233..3441832 100644
 --- a/drivers/input/misc/Kconfig
 +++ b/drivers/input/misc/Kconfig
 @@ -438,4 +438,9 @@ config INPUT_ADXL34X_SPI
To compile this driver as a module, choose M here: the
module will be called adxl34x-spi.

 +config INPUT_SPI_VIBRA

To match convention already used in this file: config INPUT_VIBRA_SPI

I'll fix it.

 +tristate Support for SPI driven Vibra module
 +help
 +  Support for Vibra module that is connected to OMAP SPI bus.

Is this an OMAP specific device?

Obviously not, I'll change the text.

 +
  endif
 diff --git a/drivers/input/misc/Makefile b/drivers/input/misc/Makefile
 index 19ccca7..cde272f 100644
 --- a/drivers/input/misc/Makefile
 +++ b/drivers/input/misc/Makefile
 @@ -41,4 +41,4 @@ obj-$(CONFIG_INPUT_WINBOND_CIR)+= winbond-
cir.o
  obj-$(CONFIG_INPUT_WISTRON_BTNS)+= wistron_btns.o
  obj-$(CONFIG_INPUT_WM831X_ON)   += wm831x-on.o
  obj-$(CONFIG_INPUT_YEALINK) += yealink.o
 -
 +obj-$(CONFIG_INPUT_SPI_VIBRA)  += vibra_spi.o

This file is nominally alphabetical sorted.  Put this line between
CONFIG_INPUT_UINPUT and CONFIG_INPUT_WINBOND_CIR. Also, whitespace
inconsistency.  Use tabs for indent.

My bad, sorry about that :(

 diff --git a/drivers/input/misc/vibra_spi.c
b/drivers/input/misc/vibra_spi.c
 new file mode 100644
 index 000..551a3b8
 --- /dev/null
 +++ b/drivers/input/misc/vibra_spi.c
 @@ -0,0 +1,429 @@
 +/*
 + * This file implements a driver for SPI data driven vibrator.
 + *
 + * Copyright (C) 2010 Nokia Corporation
 + *
 + * Contact: Ilkka Koskinen ilkka.koski...@nokia.com
 + *
 + * This program is free software; you can redistribute it and/or
 + * modify it under the terms of the GNU General Public License
 + * version 2 as published by the Free Software Foundation.
 + *
 + * This program is distributed in the hope that it will be useful,
but
 + * WITHOUT ANY WARRANTY; without even the implied warranty of
 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 + * General Public License for more details.
 + *
 + * You should have received a copy of the GNU General Public License
 + * along with this program; if not, write to the Free Software
 + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
 + * 02110-1301 USA
 + *
 + */
 +
 +#include linux/irq.h
 +#include linux/module.h
 +#include linux/workqueue.h
 +#include linux/spinlock.h
 +#include linux/delay.h
 +#include linux/slab.h
 +#include linux/jiffies.h
 +#include linux/spi/spi.h
 +#include linux/input.h
 +#include linux/spi/vibra.h
 +#include linux/io.h
 +
 +/* Number of effects handled with memoryless devices */
 +#define VIBRA_EFFECTS   36
 +#define MAX_EFFECT_SIZE 1024 /* In bytes */
 +
 +#define FF_EFFECT_QUEUED0
 +#define FF_EFFECT_PLAYING   1
 +#define FF_EFFECT_ABORTING  2
 +#define FF_EFFECT_UPLOADING 3

These are only ever used in a bitfield.  The code will be simpler if
you change this to:

#define FF_EFFECT_QUEUED   (10)
#define FF_EFFECT_PLAYING  (11)
#define FF_EFFECT_ABORTING (12)
#define FF_EFFECT_UPLOADING(13)

That way the test_bit() and __set_bit() calls can be replaced with
regular bitwise operators, and the code will be easier to read.

Makes sense. I'll change them

 +
 +enum vibra_status {
 +IDLE = 0,
 +STARTED,
 +PLAYING,
 +CLOSING,
 +};
 +
 +struct effect_info {

struct vibra_effect_info

I'll change it

 +char*buf;
 +int buflen;
 +unsigned long   flags;  /* effect state (STARTED, PLAYING,
etc) */
 +unsigned long   stop_at;
 +};
 +
 +struct vibra_data {
 +struct device   *dev;
 +struct input_dev*input_dev;
 +
 +struct workqueue_struct *workqueue;
 +struct work_struct 

RE: [PATCH] input: spi: Driver for SPI data stream driven vibrator

2010-10-26 Thread ilkka.koskinen
Hi,

From: ext Alan Cox [mailto:a...@lxorguk.ukuu.org.uk]
Sent: 26 October, 2010 14:18
To: Grant Likely
Cc: Koskinen Ilkka (Nokia-MS/Tampere); linux-in...@vger.kernel.org;
dmitry.torok...@gmail.com; spi-devel-general@lists.sourceforge.net;
linux-ker...@vger.kernel.org
Subject: Re: [PATCH] input: spi: Driver for SPI data stream driven
vibrator

  +  if (!einfo-buf) {
  +  einfo-buf = kzalloc(datalen, GFP_KERNEL | GFP_DMA);
  +  if (!einfo-buf) {
  +  ret = -ENOMEM;
  +  goto exit;
  +  }
  +  }
  +
  +  memcpy(einfo-buf, p-custom_data, datalen);

 It looks like raw data from userspace is being passed on to the
 device.  Is this sane?  Is there already a data format used by other
 vibration/feedback devices that should be used here instead and
 translated into the form expected by the hardware?

It also seems to be using GFP_DMA not dma_alloc functions which looks a
bit odd and certainly isn't portable.

Right, I'll change it to the appropriate ones.

Cheers, Ilkka

--
Nokia and ATT present the 2010 Calling All Innovators-North America contest
Create new apps  games for the Nokia N8 for consumers in  U.S. and Canada
$10 million total in prizes - $4M cash, 500 devices, nearly $6M in marketing
Develop with Nokia Qt SDK, Web Runtime, or Java and Publish to Ovi Store 
http://p.sf.net/sfu/nokia-dev2dev
___
spi-devel-general mailing list
spi-devel-general@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/spi-devel-general


[PATCH v4 04/12] spi: add ti-ssp spi master driver

2010-10-26 Thread Cyril Chemparathy
This patch adds an SPI master implementation that operates on top of an
underlying TI-SSP port.

Acked-by: Grant Likely grant.lik...@secretlab.ca
Signed-off-by: Cyril Chemparathy cy...@ti.com
---
 arch/arm/mach-davinci/include/mach/ti_ssp.h |5 +
 drivers/spi/Kconfig |7 +
 drivers/spi/Makefile|1 +
 drivers/spi/spi_ti_ssp.c|  396 +++
 4 files changed, 409 insertions(+), 0 deletions(-)
 create mode 100644 drivers/spi/spi_ti_ssp.c

diff --git a/arch/arm/mach-davinci/include/mach/ti_ssp.h 
b/arch/arm/mach-davinci/include/mach/ti_ssp.h
index c98d0f2..bff8ef6 100644
--- a/arch/arm/mach-davinci/include/mach/ti_ssp.h
+++ b/arch/arm/mach-davinci/include/mach/ti_ssp.h
@@ -34,6 +34,11 @@ struct ti_ssp_data {
struct ti_ssp_dev_data  dev_data[2];
 };
 
+struct ti_ssp_spi_data {
+   int num_cs;
+   void(*select)(int cs);
+};
+
 /*
  * Sequencer port IO pin configuration bits.  These do not correlate 1-1 with
  * the hardware.  The iosel field in the port data combines iosel1 and iosel2,
diff --git a/drivers/spi/Kconfig b/drivers/spi/Kconfig
index 7e631fa..37b10e3 100644
--- a/drivers/spi/Kconfig
+++ b/drivers/spi/Kconfig
@@ -314,6 +314,13 @@ config SPI_STMP3XXX
help
  SPI driver for Freescale STMP37xx/378x SoC SSP interface
 
+config SPI_TI_SSP
+   tristate TI SSP Controller SPI Driver
+   depends on TI_SSP
+   help
+ This selects an SPI master implementation using a TI sequencer
+ serial port.
+
 config SPI_TXX9
tristate Toshiba TXx9 SPI controller
depends on GENERIC_GPIO  CPU_TX49XX
diff --git a/drivers/spi/Makefile b/drivers/spi/Makefile
index e9cbd18..a427f3c 100644
--- a/drivers/spi/Makefile
+++ b/drivers/spi/Makefile
@@ -39,6 +39,7 @@ obj-$(CONFIG_SPI_PPC4xx)  += spi_ppc4xx.o
 obj-$(CONFIG_SPI_S3C24XX_GPIO) += spi_s3c24xx_gpio.o
 obj-$(CONFIG_SPI_S3C24XX)  += spi_s3c24xx_hw.o
 obj-$(CONFIG_SPI_S3C64XX)  += spi_s3c64xx.o
+obj-$(CONFIG_SPI_TI_SSP)   += spi_ti_ssp.o
 obj-$(CONFIG_SPI_TXX9) += spi_txx9.o
 obj-$(CONFIG_SPI_XILINX)   += xilinx_spi.o
 obj-$(CONFIG_SPI_XILINX_OF)+= xilinx_spi_of.o
diff --git a/drivers/spi/spi_ti_ssp.c b/drivers/spi/spi_ti_ssp.c
new file mode 100644
index 000..3cb41c5
--- /dev/null
+++ b/drivers/spi/spi_ti_ssp.c
@@ -0,0 +1,396 @@
+/*
+ * Sequencer Serial Port (SSP) based SPI master driver
+ *
+ * Copyright (C) 2010 Texas Instruments Inc
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ */
+
+#include linux/kernel.h
+#include linux/err.h
+#include linux/completion.h
+#include linux/delay.h
+#include linux/platform_device.h
+#include linux/spi/spi.h
+
+#include mach/ti_ssp.h
+
+#define MODE_BITS  (SPI_CPHA | SPI_CPOL | SPI_CS_HIGH)
+
+struct ti_ssp_spi {
+   const struct ti_ssp_spi_data*pdata;
+   struct spi_master   *master;
+   struct device   *dev;
+   spinlock_t  lock;
+   struct list_headmsg_queue;
+   struct completion   complete;
+   int shutdown:1;
+   struct workqueue_struct *workqueue;
+   struct work_struct  work;
+   u8  mode, bpw;
+   int cs_active;
+   u32 pc_en, pc_dis, pc_wr, pc_rd;
+};
+
+static u32 do_read_data(struct ti_ssp_spi *hw)
+{
+   u32 ret;
+
+   ti_ssp_run(hw-dev, hw-pc_rd, 0, ret);
+   return ret;
+}
+
+static void do_write_data(struct ti_ssp_spi *hw, u32 data)
+{
+   ti_ssp_run(hw-dev, hw-pc_wr, data  (32 - hw-bpw), NULL);
+}
+
+static int do_transfer(struct ti_ssp_spi *hw, struct spi_message *msg,
+  struct spi_transfer *t)
+{
+   int count;
+
+   if (hw-bpw = 8) {
+   u8  *rx = t-rx_buf;
+   const u8*tx = t-tx_buf;
+
+   for (count = 0; count  t-len; count += 1) {
+   if (t-tx_buf)
+   do_write_data(hw, *tx++);
+   if (t-rx_buf)
+   *rx++ = 

[PATCH v4 00/12] tnetv107x ssp driver stack

2010-10-26 Thread Cyril Chemparathy
TI's sequencer serial port (TI-SSP) is a jack-of-all-trades type of serial port
device.  It has a built-in programmable execution engine that can be programmed
to operate as almost any serial bus (I2C, SPI, EasyScale, and others).

This patch series implements a driver stack that looks like the following:

 ++
 | eeprom | . . .
 ++
   +---+ +--+ +-+
   | regulator | . . .   |   i2c-gpio   | | 1-wire  | . . .
   +---+ +--+ +-+
   +--+  ++
   |   ssp-spi|  |   ssp-gpio |
   +--+  ++
   +--+
   |ssp   |
   +--+

Changes between v3 and v4 of this series:
  - Replaced polled wait for sequence termination with interrupt
  - Improved locking within SSP driver
  - Other minor cleanups

Changes between v2 and v3 of this series:
  - Minor cleanups in Kconfig and Makefile ordering

Changes between v1 and v2 of this series:
  - Replaced open()/close() semantics with dynamic platform_device
registration on SSP probe.
  - Removed user-land interface to regulator registers
  - More sensible regulator constraints
  - Other minor cleanups

Cyril Chemparathy (12):
  misc: add driver for sequencer serial port
  davinci: add tnetv107x ssp platform device
  davinci: add ssp config for tnetv107x evm board
  spi: add ti-ssp spi master driver
  davinci: add spi devices on tnetv107x evm
  regulator: add driver for tps6524x regulator
  davinci: add tnetv107x evm regulators
  gpio: add ti-ssp gpio driver
  davinci: add tnetv107x evm ti-ssp gpio device
  backlight: add support for tps6116x controller
  davinci: add tnetv107x evm backlight device
  davinci: add tnetv107x evm i2c eeprom device

 arch/arm/mach-davinci/board-tnetv107x-evm.c|  199 +++
 arch/arm/mach-davinci/devices-tnetv107x.c  |   25 +
 arch/arm/mach-davinci/include/mach/ti_ssp.h|   98 
 arch/arm/mach-davinci/include/mach/tnetv107x.h |2 +
 arch/arm/mach-davinci/tnetv107x.c  |2 +-
 drivers/gpio/Kconfig   |   10 +
 drivers/gpio/Makefile  |1 +
 drivers/gpio/ti-ssp-gpio.c |  200 +++
 drivers/misc/Kconfig   |   10 +
 drivers/misc/Makefile  |1 +
 drivers/misc/ti_ssp.c  |  492 +
 drivers/regulator/Kconfig  |   10 +
 drivers/regulator/Makefile |1 +
 drivers/regulator/tps6524x-regulator.c |  692 
 drivers/spi/Kconfig|7 +
 drivers/spi/Makefile   |1 +
 drivers/spi/spi_ti_ssp.c   |  396 ++
 drivers/video/backlight/Kconfig|7 +
 drivers/video/backlight/Makefile   |2 +-
 drivers/video/backlight/tps6116x.c |  340 
 20 files changed, 2494 insertions(+), 2 deletions(-)
 create mode 100644 arch/arm/mach-davinci/include/mach/ti_ssp.h
 create mode 100644 drivers/gpio/ti-ssp-gpio.c
 create mode 100644 drivers/misc/ti_ssp.c
 create mode 100644 drivers/regulator/tps6524x-regulator.c
 create mode 100644 drivers/spi/spi_ti_ssp.c
 create mode 100644 drivers/video/backlight/tps6116x.c


--
Nokia and ATT present the 2010 Calling All Innovators-North America contest
Create new apps  games for the Nokia N8 for consumers in  U.S. and Canada
$10 million total in prizes - $4M cash, 500 devices, nearly $6M in marketing
Develop with Nokia Qt SDK, Web Runtime, or Java and Publish to Ovi Store 
http://p.sf.net/sfu/nokia-dev2dev
___
spi-devel-general mailing list
spi-devel-general@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/spi-devel-general


[PATCH v4 12/12] davinci: add tnetv107x evm i2c eeprom device

2010-10-26 Thread Cyril Chemparathy
The tnetv107x evm board has an I2C device connected on one of the SSP ports.
This patch adds board definitions for a GPIO based I2C master, as well as
definitions for the eeprom device on these boards.

Signed-off-by: Cyril Chemparathy cy...@ti.com
---
 arch/arm/mach-davinci/board-tnetv107x-evm.c |   30 +++
 1 files changed, 30 insertions(+), 0 deletions(-)

diff --git a/arch/arm/mach-davinci/board-tnetv107x-evm.c 
b/arch/arm/mach-davinci/board-tnetv107x-evm.c
index e7f413e..ff3d8dd 100644
--- a/arch/arm/mach-davinci/board-tnetv107x-evm.c
+++ b/arch/arm/mach-davinci/board-tnetv107x-evm.c
@@ -29,6 +29,9 @@
 #include linux/regulator/machine.h
 #include linux/regulator/consumer.h
 #include linux/regulator/driver.h
+#include linux/i2c.h
+#include linux/i2c/at24.h
+#include linux/i2c-gpio.h
 
 #include asm/mach/arch.h
 #include asm/mach-types.h
@@ -45,6 +48,8 @@
 #define EVM_MMC_WP_GPIO21
 #define EVM_MMC_CD_GPIO24
 #define EVM_SPI_CS_GPIO54
+#define EVM_I2C_SDA_GPIO   (SSP_GPIO_START + 0)
+#define EVM_I2C_SCL_GPIO   (SSP_GPIO_START + 1)
 #define EVM_BACKLIGHT_GPIO (SSP_GPIO_START + 2)
 
 static int initialize_gpio(int gpio, char *desc)
@@ -367,6 +372,29 @@ static struct platform_device backlight_device = {
.dev.platform_data = (void *)EVM_BACKLIGHT_GPIO,
 };
 
+struct i2c_gpio_platform_data i2c_data = {
+   .sda_pin= EVM_I2C_SDA_GPIO,
+   .scl_pin= EVM_I2C_SCL_GPIO,
+};
+
+static struct platform_device i2c_device = {
+   .name   = i2c-gpio,
+   .id = 0,
+   .dev.platform_data = i2c_data,
+};
+
+static struct at24_platform_data at24_config = {
+   .byte_len   = SZ_16K / 8,
+   .page_size  = 16,
+};
+
+static struct i2c_board_info i2c_info[] __initconst =  {
+   {
+   I2C_BOARD_INFO(24c16, 0x50),
+   .platform_data  = at24_config,
+   },
+};
+
 static __init void tnetv107x_evm_board_init(void)
 {
davinci_cfg_reg_list(sdio1_pins);
@@ -376,8 +404,10 @@ static __init void tnetv107x_evm_board_init(void)
tnetv107x_devices_init(evm_device_info);
 
platform_device_register(backlight_device);
+   platform_device_register(i2c_device);
 
spi_register_board_info(spi_info, ARRAY_SIZE(spi_info));
+   i2c_register_board_info(0, i2c_info, ARRAY_SIZE(i2c_info));
 }
 
 #ifdef CONFIG_SERIAL_8250_CONSOLE
-- 
1.7.0.4


--
Nokia and ATT present the 2010 Calling All Innovators-North America contest
Create new apps  games for the Nokia N8 for consumers in  U.S. and Canada
$10 million total in prizes - $4M cash, 500 devices, nearly $6M in marketing
Develop with Nokia Qt SDK, Web Runtime, or Java and Publish to Ovi Store 
http://p.sf.net/sfu/nokia-dev2dev
___
spi-devel-general mailing list
spi-devel-general@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/spi-devel-general


[PATCH v4 07/12] davinci: add tnetv107x evm regulators

2010-10-26 Thread Cyril Chemparathy
This patch adds regulator and spi board info definitions for the tps6524x
power management IC found on tnetv107x evm boards.

Signed-off-by: Cyril Chemparathy cy...@ti.com
---
 arch/arm/mach-davinci/board-tnetv107x-evm.c |   85 +++
 1 files changed, 85 insertions(+), 0 deletions(-)

diff --git a/arch/arm/mach-davinci/board-tnetv107x-evm.c 
b/arch/arm/mach-davinci/board-tnetv107x-evm.c
index 924cf06..42ae20f 100644
--- a/arch/arm/mach-davinci/board-tnetv107x-evm.c
+++ b/arch/arm/mach-davinci/board-tnetv107x-evm.c
@@ -26,6 +26,9 @@
 #include linux/input.h
 #include linux/input/matrix_keypad.h
 #include linux/spi/spi.h
+#include linux/regulator/machine.h
+#include linux/regulator/consumer.h
+#include linux/regulator/driver.h
 
 #include asm/mach/arch.h
 #include asm/mach-types.h
@@ -257,7 +260,89 @@ static struct tnetv107x_device_info evm_device_info 
__initconst = {
.ssp_config = ssp_config,
 };
 
+static struct regulator_consumer_supply usb_consumers[] = {
+   REGULATOR_SUPPLY(vbus, musb_hdrc.1),
+};
+
+static struct regulator_consumer_supply lcd_consumers[] = {
+   REGULATOR_SUPPLY(vlcd, tps6116x),
+};
+
+static struct regulator_init_data regulators[] = {
+   {
+   .constraints= {
+   .name   = DCDC1,
+   .min_uV = 100,
+   .max_uV = 100,
+   .always_on  = 1,
+   .boot_on= 1,
+   },
+   },
+   {
+   .constraints= {
+   .name   = DCDC2,
+   .min_uV = 180,
+   .max_uV = 180,
+   .always_on  = 1,
+   .boot_on= 1,
+   },
+   },
+   {
+   .constraints= {
+   .name   = DCDC3,
+   .min_uV = 330,
+   .max_uV = 330,
+   .always_on  = 1,
+   .boot_on= 1,
+   },
+   },
+   {
+   .constraints= {
+   .name   = LDO1,
+   .min_uV = 480,
+   .max_uV = 480,
+   .always_on  = 1,
+   .boot_on= 1,
+   },
+   },
+   {
+   .constraints= {
+   .name   = LDO1,
+   .min_uV = 330,
+   .max_uV = 330,
+   .always_on  = 1,
+   .boot_on= 1,
+   },
+   },
+   {
+   .num_consumer_supplies  = ARRAY_SIZE(usb_consumers),
+   .consumer_supplies  = usb_consumers,
+   .constraints= {
+   .name   = USB,
+   .min_uA = 20,
+   .max_uA = 100,
+   .valid_ops_mask = REGULATOR_CHANGE_CURRENT |
+ REGULATOR_CHANGE_STATUS,
+   },
+   },
+   {
+   .num_consumer_supplies  = ARRAY_SIZE(lcd_consumers),
+   .consumer_supplies  = lcd_consumers,
+   .constraints= {
+   .name   = LCD,
+   .valid_ops_mask = REGULATOR_CHANGE_STATUS,
+   },
+   },
+};
+
 static struct spi_board_info spi_info[] __initconst = {
+   {
+   .modalias   = tps6524x,
+   .bus_num= 1,
+   .chip_select= 0,
+   .mode   = SPI_MODE_0,
+   .platform_data  = regulators,
+   },
 };
 
 static __init void tnetv107x_evm_board_init(void)
-- 
1.7.0.4


--
Nokia and ATT present the 2010 Calling All Innovators-North America contest
Create new apps  games for the Nokia N8 for consumers in  U.S. and Canada
$10 million total in prizes - $4M cash, 500 devices, nearly $6M in marketing
Develop with Nokia Qt SDK, Web Runtime, or Java and Publish to Ovi Store 
http://p.sf.net/sfu/nokia-dev2dev
___
spi-devel-general mailing list
spi-devel-general@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/spi-devel-general


[PATCH v4 01/12] misc: add driver for sequencer serial port

2010-10-26 Thread Cyril Chemparathy
TI's sequencer serial port (TI-SSP) is a jack-of-all-trades type of serial port
device.  It has a built-in programmable execution engine that can be programmed
to operate as almost any serial bus (I2C, SPI, EasyScale, and others).

This patch adds a driver for this controller device.  The driver does not
expose a user-land interface.  Protocol drivers built on top of this layer are
expected to remain in-kernel.

Signed-off-by: Cyril Chemparathy cy...@ti.com
---
 arch/arm/mach-davinci/include/mach/ti_ssp.h |   89 +
 drivers/misc/Kconfig|   10 +
 drivers/misc/Makefile   |1 +
 drivers/misc/ti_ssp.c   |  492 +++
 4 files changed, 592 insertions(+), 0 deletions(-)
 create mode 100644 arch/arm/mach-davinci/include/mach/ti_ssp.h
 create mode 100644 drivers/misc/ti_ssp.c

diff --git a/arch/arm/mach-davinci/include/mach/ti_ssp.h 
b/arch/arm/mach-davinci/include/mach/ti_ssp.h
new file mode 100644
index 000..c98d0f2
--- /dev/null
+++ b/arch/arm/mach-davinci/include/mach/ti_ssp.h
@@ -0,0 +1,89 @@
+/*
+ * Sequencer Serial Port (SSP) driver for Texas Instruments' SoCs
+ *
+ * Copyright (C) 2010 Texas Instruments Inc
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ */
+
+#ifndef __TI_SSP_H__
+#define __TI_SSP_H__
+
+struct ti_ssp_dev_data {
+   const char  *dev_name;
+   unsigned long   iosel; /* see note below */
+   unsigned long   config;
+   const void  *pdata;
+   size_t  pdata_size;
+};
+
+struct ti_ssp_data {
+   unsigned long   out_clock;
+   struct ti_ssp_dev_data  dev_data[2];
+};
+
+/*
+ * Sequencer port IO pin configuration bits.  These do not correlate 1-1 with
+ * the hardware.  The iosel field in the port data combines iosel1 and iosel2,
+ * and is therefore not a direct map to register space.  It is best to use the
+ * macros below to construct iosel values.
+ *
+ * least significant 16 bits -- iosel1
+ * most significant 16 bits  -- iosel2
+ */
+
+#define SSP_IN 0x
+#define SSP_DATA   0x0001
+#define SSP_CLOCK  0x0002
+#define SSP_CHIPSEL0x0003
+#define SSP_OUT0x0004
+#define SSP_PIN_SEL(pin, v)((v)  ((pin) * 3))
+#define SSP_PIN_MASK(pin)  SSP_PIN_SEL(pin, 0x7)
+#define SSP_INPUT_SEL(pin) ((pin)  16)
+
+/* Sequencer port config bits */
+#define SSP_EARLY_DIN  BIT(8)
+#define SSP_DELAY_DOUT BIT(9)
+
+/* Sequence map definitions */
+#define SSP_CLK_HIGH   BIT(0)
+#define SSP_CLK_LOW0
+#define SSP_DATA_HIGH  BIT(1)
+#define SSP_DATA_LOW   0
+#define SSP_CS_HIGHBIT(2)
+#define SSP_CS_LOW 0
+#define SSP_OUT_MODE   BIT(3)
+#define SSP_IN_MODE0
+#define SSP_DATA_REG   BIT(4)
+#define SSP_ADDR_REG   0
+
+#define SSP_OPCODE_DIRECT  ((0x0)  5)
+#define SSP_OPCODE_TOGGLE  ((0x1)  5)
+#define SSP_OPCODE_SHIFT   ((0x2)  5)
+#define SSP_OPCODE_BRANCH0 ((0x4)  5)
+#define SSP_OPCODE_BRANCH1 ((0x5)  5)
+#define SSP_OPCODE_BRANCH  ((0x6)  5)
+#define SSP_OPCODE_STOP((0x7)  5)
+#define SSP_BRANCH(addr)   ((addr)  8)
+#define SSP_COUNT(cycles)  ((cycles)  8)
+
+int ti_ssp_raw_read(struct device *dev);
+int ti_ssp_raw_write(struct device *dev, u32 val);
+int ti_ssp_load(struct device *dev, int offs, u32* prog, int len);
+int ti_ssp_run(struct device *dev, u32 pc, u32 input, u32 *output);
+int ti_ssp_set_mode(struct device *dev, int mode);
+int ti_ssp_set_iosel(struct device *dev, u32 iosel);
+
+#endif /* __TI_SSP_H__ */
diff --git a/drivers/misc/Kconfig b/drivers/misc/Kconfig
index b743312..a8b7ce3 100644
--- a/drivers/misc/Kconfig
+++ b/drivers/misc/Kconfig
@@ -390,6 +390,16 @@ config BMP085
  To compile this driver as a module, choose M here: the
  module will be called bmp085.
 
+config TI_SSP
+   tristate Sequencer Serial Port support
+   depends on ARCH_DAVINCI_TNETV107X
+   ---help---
+ Say Y here if you want support for the Sequencer Serial Port
+ in a Texas Instruments TNETV107X SoC.
+
+ To compile this driver as a module, choose M here: the
+ module will be called ti_ssp.
+
 source 

[PATCH v4 05/12] davinci: add spi devices on tnetv107x evm

2010-10-26 Thread Cyril Chemparathy
This patch adds definitions for spi devices on the tnetv107x evm platform.

Signed-off-by: Cyril Chemparathy cy...@ti.com
---
 arch/arm/mach-davinci/board-tnetv107x-evm.c |   45 +++
 1 files changed, 45 insertions(+), 0 deletions(-)

diff --git a/arch/arm/mach-davinci/board-tnetv107x-evm.c 
b/arch/arm/mach-davinci/board-tnetv107x-evm.c
index c74ea66..924cf06 100644
--- a/arch/arm/mach-davinci/board-tnetv107x-evm.c
+++ b/arch/arm/mach-davinci/board-tnetv107x-evm.c
@@ -25,6 +25,7 @@
 #include linux/mtd/partitions.h
 #include linux/input.h
 #include linux/input/matrix_keypad.h
+#include linux/spi/spi.h
 
 #include asm/mach/arch.h
 #include asm/mach-types.h
@@ -38,6 +39,7 @@
 
 #define EVM_MMC_WP_GPIO21
 #define EVM_MMC_CD_GPIO24
+#define EVM_SPI_CS_GPIO54
 
 static int initialize_gpio(int gpio, char *desc)
 {
@@ -203,9 +205,47 @@ static struct matrix_keypad_platform_data keypad_config = {
.no_autorepeat  = 0,
 };
 
+static void spi_select_device(int cs)
+{
+   static int gpio;
+
+   if (!gpio) {
+   int ret;
+   ret = gpio_request(EVM_SPI_CS_GPIO, spi chipsel);
+   if (ret  0) {
+   pr_err(cannot open spi chipsel gpio\n);
+   gpio = -ENOSYS;
+   return;
+   } else {
+   gpio = EVM_SPI_CS_GPIO;
+   gpio_direction_output(gpio, 0);
+   }
+   }
+
+   if (gpio  0)
+   return;
+
+   return gpio_set_value(gpio, cs ? 1 : 0);
+}
+
+static const struct ti_ssp_spi_data spi_master_data = {
+   .num_cs = 2,
+   .select = spi_select_device,
+};
+
 static struct ti_ssp_data ssp_config = {
.out_clock  = 250 * 1000,
.dev_data   = {
+   [1] = {
+   .dev_name = ti-ssp-spi,
+   .iosel = SSP_PIN_SEL(0, SSP_CLOCK)  |
+SSP_PIN_SEL(1, SSP_DATA)   |
+SSP_PIN_SEL(2, SSP_CHIPSEL)|
+SSP_PIN_SEL(3, SSP_IN) |
+SSP_INPUT_SEL(3),
+   .pdata = spi_master_data,
+   .pdata_size = sizeof(spi_master_data),
+   },
},
 };
 
@@ -217,6 +257,9 @@ static struct tnetv107x_device_info evm_device_info 
__initconst = {
.ssp_config = ssp_config,
 };
 
+static struct spi_board_info spi_info[] __initconst = {
+};
+
 static __init void tnetv107x_evm_board_init(void)
 {
davinci_cfg_reg_list(sdio1_pins);
@@ -224,6 +267,8 @@ static __init void tnetv107x_evm_board_init(void)
davinci_cfg_reg_list(ssp_pins);
 
tnetv107x_devices_init(evm_device_info);
+
+   spi_register_board_info(spi_info, ARRAY_SIZE(spi_info));
 }
 
 #ifdef CONFIG_SERIAL_8250_CONSOLE
-- 
1.7.0.4


--
Nokia and ATT present the 2010 Calling All Innovators-North America contest
Create new apps  games for the Nokia N8 for consumers in  U.S. and Canada
$10 million total in prizes - $4M cash, 500 devices, nearly $6M in marketing
Develop with Nokia Qt SDK, Web Runtime, or Java and Publish to Ovi Store 
http://p.sf.net/sfu/nokia-dev2dev
___
spi-devel-general mailing list
spi-devel-general@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/spi-devel-general


[PATCH v4 10/12] backlight: add support for tps6116x controller

2010-10-26 Thread Cyril Chemparathy
TPS6116x is an EasyScale backlight controller device.  This driver supports
TPS6116x devices connected on a single GPIO.

Signed-off-by: Cyril Chemparathy cy...@ti.com
---
 drivers/video/backlight/Kconfig|7 +
 drivers/video/backlight/Makefile   |2 +-
 drivers/video/backlight/tps6116x.c |  340 
 3 files changed, 348 insertions(+), 1 deletions(-)
 create mode 100644 drivers/video/backlight/tps6116x.c

diff --git a/drivers/video/backlight/Kconfig b/drivers/video/backlight/Kconfig
index e54a337..06e868e 100644
--- a/drivers/video/backlight/Kconfig
+++ b/drivers/video/backlight/Kconfig
@@ -307,6 +307,13 @@ config BACKLIGHT_PCF50633
  If you have a backlight driven by a NXP PCF50633 MFD, say Y here to
  enable its driver.
 
+config BACKLIGHT_TPS6116X
+   tristate TPS6116X LCD Backlight
+   depends on GENERIC_GPIO
+   help
+ This driver controls the LCD backlight level for EasyScale capable
+ SSP connected backlight controllers.
+
 endif # BACKLIGHT_CLASS_DEVICE
 
 endif # BACKLIGHT_LCD_SUPPORT
diff --git a/drivers/video/backlight/Makefile b/drivers/video/backlight/Makefile
index 44c0f81..5d407c8 100644
--- a/drivers/video/backlight/Makefile
+++ b/drivers/video/backlight/Makefile
@@ -35,4 +35,4 @@ obj-$(CONFIG_BACKLIGHT_ADP5520)   += adp5520_bl.o
 obj-$(CONFIG_BACKLIGHT_ADP8860)+= adp8860_bl.o
 obj-$(CONFIG_BACKLIGHT_88PM860X) += 88pm860x_bl.o
 obj-$(CONFIG_BACKLIGHT_PCF50633)   += pcf50633-backlight.o
-
+obj-$(CONFIG_BACKLIGHT_TPS6116X)+= tps6116x.o
diff --git a/drivers/video/backlight/tps6116x.c 
b/drivers/video/backlight/tps6116x.c
new file mode 100644
index 000..7a9f8ca
--- /dev/null
+++ b/drivers/video/backlight/tps6116x.c
@@ -0,0 +1,340 @@
+/*
+ * TPS6116X LCD Backlight Controller Driver
+ *
+ * Copyright (C) 2010 Texas Instruments
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation version 2.
+ *
+ * This program is distributed as is WITHOUT ANY WARRANTY of any kind,
+ * whether express or implied; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * General Public License for more details.
+ */
+
+#include linux/kernel.h
+#include linux/fb.h
+#include linux/err.h
+#include linux/delay.h
+#include linux/gpio.h
+#include linux/backlight.h
+#include linux/platform_device.h
+#include linux/regulator/consumer.h
+
+#define TPS6116X_MAX_INTENSITY 31
+#define TPS6116X_DEFAULT_INTENSITY 10
+
+/* Easyscale timing w/ margin (usecs) */
+#define T_POWER_SETTLE 2000
+#define T_ES_DELAY 120
+#define T_ES_DETECT280
+#define T_ES_WINDOW(1000 - T_ES_DELAY - T_ES_DETECT)
+#define T_START3
+#define T_EOS  3
+#define T_INACTIVE 3
+#define T_ACTIVE   (3 * T_INACTIVE)
+
+#define CMD_SET0x72
+
+struct tps6116x {
+   struct ti_ssp_device*handle;
+   struct device   *dev;
+   int gpio, gpio_initialized;
+   struct mutexlock;
+   int intensity;
+   int power;
+   struct backlight_properties props;
+   struct backlight_device *bl;
+   int suspended:1;
+   struct regulator*regulator;
+};
+
+static int __set_power(struct tps6116x *hw, int power)
+{
+   unsigned long flags;
+   int error;
+
+   power = !!power;
+   if (power == hw-power)
+   return 0; /* nothing to do */
+
+   /* disabling is simple... choke power */
+   if (!power) {
+   error = regulator_disable(hw-regulator);
+   goto done;
+   }
+
+   /* set ctrl pin init state for easyscale detection */
+   gpio_set_value(hw-gpio, 0);
+
+   error = regulator_enable(hw-regulator);
+   if (error  0)
+   goto done;
+
+   udelay(T_POWER_SETTLE);
+
+   /*
+* Now that the controller is powered up, we need to put it into 1-wire
+* mode.  This is a timing sensitive operation, hence the irq disable.
+* Ideally, this should happen rarely, and mostly at init, so disabling
+* interrupts for the duration should not be a problem.
+*/
+   local_irq_save(flags);
+
+   gpio_set_value(hw-gpio, 1);
+   udelay(T_ES_DELAY);
+   gpio_set_value(hw-gpio, 0);
+   udelay(T_ES_DETECT);
+   gpio_set_value(hw-gpio, 1);
+
+   local_irq_restore(flags);
+
+done:
+   if (error = 0)
+   hw-power = power;
+
+   return error;
+}
+
+static void __write_byte(struct tps6116x *hw, u8 data)
+{
+   int 

[PATCH v4 09/12] davinci: add tnetv107x evm ti-ssp gpio device

2010-10-26 Thread Cyril Chemparathy
This patch adds definitions to hook up one of the ti-ssp ports to the SSP GPIO
driver.

Signed-off-by: Cyril Chemparathy cy...@ti.com
---
 arch/arm/mach-davinci/board-tnetv107x-evm.c |   15 +++
 1 files changed, 15 insertions(+), 0 deletions(-)

diff --git a/arch/arm/mach-davinci/board-tnetv107x-evm.c 
b/arch/arm/mach-davinci/board-tnetv107x-evm.c
index 42ae20f..e0acc13 100644
--- a/arch/arm/mach-davinci/board-tnetv107x-evm.c
+++ b/arch/arm/mach-davinci/board-tnetv107x-evm.c
@@ -40,6 +40,8 @@
 #include mach/ti_ssp.h
 #include mach/tnetv107x.h
 
+#define SSP_GPIO_START 128
+
 #define EVM_MMC_WP_GPIO21
 #define EVM_MMC_CD_GPIO24
 #define EVM_SPI_CS_GPIO54
@@ -236,9 +238,22 @@ static const struct ti_ssp_spi_data spi_master_data = {
.select = spi_select_device,
 };
 
+static const struct ti_ssp_gpio_data ssp_gpio_data = {
+   .start  = SSP_GPIO_START,
+};
+
 static struct ti_ssp_data ssp_config = {
.out_clock  = 250 * 1000,
.dev_data   = {
+   [0] = {
+   .dev_name = ti-ssp-gpio,
+   .iosel = SSP_PIN_SEL(0, SSP_IN) |
+SSP_PIN_SEL(1, SSP_IN) |
+SSP_PIN_SEL(2, SSP_IN) |
+SSP_PIN_SEL(3, SSP_IN),
+   .pdata = ssp_gpio_data,
+   .pdata_size = sizeof(ssp_gpio_data),
+   },
[1] = {
.dev_name = ti-ssp-spi,
.iosel = SSP_PIN_SEL(0, SSP_CLOCK)  |
-- 
1.7.0.4


--
Nokia and ATT present the 2010 Calling All Innovators-North America contest
Create new apps  games for the Nokia N8 for consumers in  U.S. and Canada
$10 million total in prizes - $4M cash, 500 devices, nearly $6M in marketing
Develop with Nokia Qt SDK, Web Runtime, or Java and Publish to Ovi Store 
http://p.sf.net/sfu/nokia-dev2dev
___
spi-devel-general mailing list
spi-devel-general@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/spi-devel-general


[PATCH v4 11/12] davinci: add tnetv107x evm backlight device

2010-10-26 Thread Cyril Chemparathy
The tnetv107x evm board has a backlight device that is connected on one of the
SSP ports.  This patch adds the board definitions necessary to plug the
backlight driver to the GPIO corresponding to this SSP pin.

Signed-off-by: Cyril Chemparathy cy...@ti.com
---
 arch/arm/mach-davinci/board-tnetv107x-evm.c |9 +
 1 files changed, 9 insertions(+), 0 deletions(-)

diff --git a/arch/arm/mach-davinci/board-tnetv107x-evm.c 
b/arch/arm/mach-davinci/board-tnetv107x-evm.c
index e0acc13..e7f413e 100644
--- a/arch/arm/mach-davinci/board-tnetv107x-evm.c
+++ b/arch/arm/mach-davinci/board-tnetv107x-evm.c
@@ -45,6 +45,7 @@
 #define EVM_MMC_WP_GPIO21
 #define EVM_MMC_CD_GPIO24
 #define EVM_SPI_CS_GPIO54
+#define EVM_BACKLIGHT_GPIO (SSP_GPIO_START + 2)
 
 static int initialize_gpio(int gpio, char *desc)
 {
@@ -360,6 +361,12 @@ static struct spi_board_info spi_info[] __initconst = {
},
 };
 
+static struct platform_device backlight_device = {
+   .name   = tps6116x,
+   .id = -1,
+   .dev.platform_data = (void *)EVM_BACKLIGHT_GPIO,
+};
+
 static __init void tnetv107x_evm_board_init(void)
 {
davinci_cfg_reg_list(sdio1_pins);
@@ -368,6 +375,8 @@ static __init void tnetv107x_evm_board_init(void)
 
tnetv107x_devices_init(evm_device_info);
 
+   platform_device_register(backlight_device);
+
spi_register_board_info(spi_info, ARRAY_SIZE(spi_info));
 }
 
-- 
1.7.0.4


--
Nokia and ATT present the 2010 Calling All Innovators-North America contest
Create new apps  games for the Nokia N8 for consumers in  U.S. and Canada
$10 million total in prizes - $4M cash, 500 devices, nearly $6M in marketing
Develop with Nokia Qt SDK, Web Runtime, or Java and Publish to Ovi Store 
http://p.sf.net/sfu/nokia-dev2dev
___
spi-devel-general mailing list
spi-devel-general@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/spi-devel-general


[PATCH v4 02/12] davinci: add tnetv107x ssp platform device

2010-10-26 Thread Cyril Chemparathy
This patch adds an SSP platform device definition for the tnetv107x soc family.
The clock lookup entry has also been updated to match.

Signed-off-by: Cyril Chemparathy cy...@ti.com
---
 arch/arm/mach-davinci/devices-tnetv107x.c  |   25 
 arch/arm/mach-davinci/include/mach/tnetv107x.h |2 +
 arch/arm/mach-davinci/tnetv107x.c  |2 +-
 3 files changed, 28 insertions(+), 1 deletions(-)

diff --git a/arch/arm/mach-davinci/devices-tnetv107x.c 
b/arch/arm/mach-davinci/devices-tnetv107x.c
index 85503de..6162cae 100644
--- a/arch/arm/mach-davinci/devices-tnetv107x.c
+++ b/arch/arm/mach-davinci/devices-tnetv107x.c
@@ -35,6 +35,7 @@
 #define TNETV107X_SDIO0_BASE   0x08088700
 #define TNETV107X_SDIO1_BASE   0x08088800
 #define TNETV107X_KEYPAD_BASE  0x08088a00
+#define TNETV107X_SSP_BASE 0x08088c00
 #define TNETV107X_ASYNC_EMIF_CNTRL_BASE0x0820
 #define TNETV107X_ASYNC_EMIF_DATA_CE0_BASE 0x3000
 #define TNETV107X_ASYNC_EMIF_DATA_CE1_BASE 0x4000
@@ -342,6 +343,25 @@ static struct platform_device tsc_device = {
.resource   = tsc_resources,
 };
 
+static struct resource ssp_resources[] = {
+   {
+   .start  = TNETV107X_SSP_BASE,
+   .end= TNETV107X_SSP_BASE + 0x1ff,
+   .flags  = IORESOURCE_MEM,
+   },
+   {
+   .start  = IRQ_TNETV107X_SSP,
+   .flags  = IORESOURCE_IRQ,
+   },
+};
+
+static struct platform_device ssp_device = {
+   .name   = ti-ssp,
+   .id = -1,
+   .num_resources  = ARRAY_SIZE(ssp_resources),
+   .resource   = ssp_resources,
+};
+
 void __init tnetv107x_devices_init(struct tnetv107x_device_info *info)
 {
int i, error;
@@ -380,4 +400,9 @@ void __init tnetv107x_devices_init(struct 
tnetv107x_device_info *info)
keypad_device.dev.platform_data = info-keypad_config;
platform_device_register(keypad_device);
}
+
+   if (info-ssp_config) {
+   ssp_device.dev.platform_data = info-ssp_config;
+   platform_device_register(ssp_device);
+   }
 }
diff --git a/arch/arm/mach-davinci/include/mach/tnetv107x.h 
b/arch/arm/mach-davinci/include/mach/tnetv107x.h
index 5a681d8..c1df563 100644
--- a/arch/arm/mach-davinci/include/mach/tnetv107x.h
+++ b/arch/arm/mach-davinci/include/mach/tnetv107x.h
@@ -38,12 +38,14 @@
 #include mach/mmc.h
 #include mach/nand.h
 #include mach/serial.h
+#include mach/ti_ssp.h
 
 struct tnetv107x_device_info {
struct davinci_uart_config  *serial_config;
struct davinci_mmc_config   *mmc_config[2];  /* 2 controllers */
struct davinci_nand_pdata   *nand_config[4]; /* 4 chipsels */
struct matrix_keypad_platform_data *keypad_config;
+   struct ti_ssp_data  *ssp_config;
 };
 
 extern struct platform_device tnetv107x_wdt_device;
diff --git a/arch/arm/mach-davinci/tnetv107x.c 
b/arch/arm/mach-davinci/tnetv107x.c
index 6fcdece..1b28fdd 100644
--- a/arch/arm/mach-davinci/tnetv107x.c
+++ b/arch/arm/mach-davinci/tnetv107x.c
@@ -278,7 +278,7 @@ static struct clk_lookup clks[] = {
CLK(NULL,   timer1,   clk_timer1),
CLK(tnetv107x_wdt.0,  NULL,   clk_wdt_arm),
CLK(NULL,   clk_wdt_dsp,  clk_wdt_dsp),
-   CLK(ti-ssp.0, NULL,   clk_ssp),
+   CLK(ti-ssp,   NULL,   clk_ssp),
CLK(NULL,   clk_tdm0, clk_tdm0),
CLK(NULL,   clk_vlynq,clk_vlynq),
CLK(NULL,   clk_mcdma,clk_mcdma),
-- 
1.7.0.4


--
Nokia and ATT present the 2010 Calling All Innovators-North America contest
Create new apps  games for the Nokia N8 for consumers in  U.S. and Canada
$10 million total in prizes - $4M cash, 500 devices, nearly $6M in marketing
Develop with Nokia Qt SDK, Web Runtime, or Java and Publish to Ovi Store 
http://p.sf.net/sfu/nokia-dev2dev
___
spi-devel-general mailing list
spi-devel-general@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/spi-devel-general


[PATCH v4 06/12] regulator: add driver for tps6524x regulator

2010-10-26 Thread Cyril Chemparathy
TPS6524X provides three step-down converters and two general-purpose LDO
voltage regulators.  This device is interfaced using SPI.

Acked-by: Mark Brown broo...@opensource.wolfsonmicro.com
Signed-off-by: Cyril Chemparathy cy...@ti.com
---
 drivers/regulator/Kconfig  |   10 +
 drivers/regulator/Makefile |1 +
 drivers/regulator/tps6524x-regulator.c |  692 
 3 files changed, 703 insertions(+), 0 deletions(-)
 create mode 100644 drivers/regulator/tps6524x-regulator.c

diff --git a/drivers/regulator/Kconfig b/drivers/regulator/Kconfig
index 172951b..7875c2e 100644
--- a/drivers/regulator/Kconfig
+++ b/drivers/regulator/Kconfig
@@ -235,5 +235,15 @@ config REGULATOR_TPS6586X
help
  This driver supports TPS6586X voltage regulator chips.
 
+config REGULATOR_TPS6524X
+   tristate TI TPS6524X Power regulators
+   depends on TI_SSP
+   help
+ This driver supports TPS6524X voltage regulator chips. TPS6524X
+ provides three step-down converters and two general-purpose LDO
+ voltage regulators.  This device is interfaced using a customized
+ serial interface currently supported on the sequencer serial
+ port controller.
+
 endif
 
diff --git a/drivers/regulator/Makefile b/drivers/regulator/Makefile
index 8285fd8..a8e5bc0 100644
--- a/drivers/regulator/Makefile
+++ b/drivers/regulator/Makefile
@@ -33,6 +33,7 @@ obj-$(CONFIG_REGULATOR_AB3100) += ab3100.o
 
 obj-$(CONFIG_REGULATOR_TPS65023) += tps65023-regulator.o
 obj-$(CONFIG_REGULATOR_TPS6507X) += tps6507x-regulator.o
+obj-$(CONFIG_REGULATOR_TPS6524X) += tps6524x-regulator.o
 obj-$(CONFIG_REGULATOR_88PM8607) += 88pm8607.o
 obj-$(CONFIG_REGULATOR_ISL6271A) += isl6271a-regulator.o
 obj-$(CONFIG_REGULATOR_AB8500) += ab8500.o
diff --git a/drivers/regulator/tps6524x-regulator.c 
b/drivers/regulator/tps6524x-regulator.c
new file mode 100644
index 000..6d6cc5e
--- /dev/null
+++ b/drivers/regulator/tps6524x-regulator.c
@@ -0,0 +1,692 @@
+/*
+ * Regulator driver for TPS6524x PMIC
+ *
+ * Copyright (C) 2010 Texas Instruments
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation version 2.
+ *
+ * This program is distributed as is WITHOUT ANY WARRANTY of any kind,
+ * whether express or implied; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * General Public License for more details.
+ */
+
+#include linux/kernel.h
+#include linux/module.h
+#include linux/err.h
+#include linux/errno.h
+#include linux/slab.h
+#include linux/spi/spi.h
+#include linux/regulator/driver.h
+#include linux/regulator/machine.h
+
+#define REG_LDO_SET0x0
+#define LDO_ILIM_MASK  1   /* 0 = 400-800, 1 = 900-1500 */
+#define LDO_VSEL_MASK  0x0f
+#define LDO2_ILIM_SHIFT12
+#define LDO2_VSEL_SHIFT4
+#define LDO1_ILIM_SHIFT8
+#define LDO1_VSEL_SHIFT0
+
+#define REG_BLOCK_EN   0x1
+#define BLOCK_MASK 1
+#define BLOCK_LDO1_SHIFT   0
+#define BLOCK_LDO2_SHIFT   1
+#define BLOCK_LCD_SHIFT2
+#define BLOCK_USB_SHIFT3
+
+#define REG_DCDC_SET   0x2
+#define DCDC_VDCDC_MASK0x1f
+#define DCDC_VDCDC1_SHIFT  0
+#define DCDC_VDCDC2_SHIFT  5
+#define DCDC_VDCDC3_SHIFT  10
+
+#define REG_DCDC_EN0x3
+#define DCDCDCDC_EN_MASK   0x1
+#define DCDCDCDC1_EN_SHIFT 0
+#define DCDCDCDC1_PG_MSK   BIT(1)
+#define DCDCDCDC2_EN_SHIFT 2
+#define DCDCDCDC2_PG_MSK   BIT(3)
+#define DCDCDCDC3_EN_SHIFT 4
+#define DCDCDCDC3_PG_MSK   BIT(5)
+
+#define REG_USB0x4
+#define USB_ILIM_SHIFT 0
+#define USB_ILIM_MASK  0x3
+#define USB_TSD_SHIFT  2
+#define USB_TSD_MASK   0x3
+#define USB_TWARN_SHIFT4
+#define USB_TWARN_MASK 0x3
+#define USB_IWARN_SD   BIT(6)
+#define USB_FAST_LOOP  BIT(7)
+
+#define REG_ALARM  0x5
+#define ALARM_LDO1 BIT(0)
+#define ALARM_DCDC1BIT(1)
+#define ALARM_DCDC2BIT(2)
+#define ALARM_DCDC3BIT(3)
+#define ALARM_LDO2 BIT(4)
+#define ALARM_USB_WARN BIT(5)
+#define ALARM_USB_ALARMBIT(6)
+#define ALARM_LCD  BIT(9)
+#define ALARM_TEMP_WARMBIT(10)
+#define ALARM_TEMP_HOT BIT(11)
+#define ALARM_NRST BIT(14)
+#define ALARM_POWERUP  BIT(15)
+
+#define REG_INT_ENABLE 0x6
+#define INT_LDO1   BIT(0)
+#define INT_DCDC1  BIT(1)
+#define INT_DCDC2  BIT(2)
+#define INT_DCDC3  BIT(3)
+#define INT_LDO2   BIT(4)
+#define INT_USB_WARN   BIT(5)
+#define INT_USB_ALARM  BIT(6)

[PATCH v4 03/12] davinci: add ssp config for tnetv107x evm board

2010-10-26 Thread Cyril Chemparathy
This patch adds SSP configuration and pin muxing info for tnetv107x
evm boards.

Signed-off-by: Cyril Chemparathy cy...@ti.com
---
 arch/arm/mach-davinci/board-tnetv107x-evm.c |   15 +++
 1 files changed, 15 insertions(+), 0 deletions(-)

diff --git a/arch/arm/mach-davinci/board-tnetv107x-evm.c 
b/arch/arm/mach-davinci/board-tnetv107x-evm.c
index a6db854..c74ea66 100644
--- a/arch/arm/mach-davinci/board-tnetv107x-evm.c
+++ b/arch/arm/mach-davinci/board-tnetv107x-evm.c
@@ -33,6 +33,7 @@
 #include mach/edma.h
 #include mach/mux.h
 #include mach/cp_intc.h
+#include mach/ti_ssp.h
 #include mach/tnetv107x.h
 
 #define EVM_MMC_WP_GPIO21
@@ -99,6 +100,12 @@ static const short uart1_pins[] __initdata = {
-1
 };
 
+static const short ssp_pins[] __initdata = {
+   TNETV107X_SSP0_0, TNETV107X_SSP0_1, TNETV107X_SSP0_2,
+   TNETV107X_SSP1_0, TNETV107X_SSP1_1, TNETV107X_SSP1_2,
+   TNETV107X_SSP1_3, -1
+};
+
 static struct mtd_partition nand_partitions[] = {
/* bootloader (U-Boot, etc) in first 12 sectors */
{
@@ -196,17 +203,25 @@ static struct matrix_keypad_platform_data keypad_config = 
{
.no_autorepeat  = 0,
 };
 
+static struct ti_ssp_data ssp_config = {
+   .out_clock  = 250 * 1000,
+   .dev_data   = {
+   },
+};
+
 static struct tnetv107x_device_info evm_device_info __initconst = {
.serial_config  = serial_config,
.mmc_config[1]  = mmc_config,  /* controller 1 */
.nand_config[0] = nand_config, /* chip select 0 */
.keypad_config  = keypad_config,
+   .ssp_config = ssp_config,
 };
 
 static __init void tnetv107x_evm_board_init(void)
 {
davinci_cfg_reg_list(sdio1_pins);
davinci_cfg_reg_list(uart1_pins);
+   davinci_cfg_reg_list(ssp_pins);
 
tnetv107x_devices_init(evm_device_info);
 }
-- 
1.7.0.4


--
Nokia and ATT present the 2010 Calling All Innovators-North America contest
Create new apps  games for the Nokia N8 for consumers in  U.S. and Canada
$10 million total in prizes - $4M cash, 500 devices, nearly $6M in marketing
Develop with Nokia Qt SDK, Web Runtime, or Java and Publish to Ovi Store 
http://p.sf.net/sfu/nokia-dev2dev
___
spi-devel-general mailing list
spi-devel-general@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/spi-devel-general


[PATCH v4 08/12] gpio: add ti-ssp gpio driver

2010-10-26 Thread Cyril Chemparathy
TI's SSP controller pins can be directly read and written to behave like a
GPIO.  This patch adds a GPIO driver that exposes such functionality.

Acked-by: Grant Likely grant.lik...@secretlab.ca
Signed-off-by: Cyril Chemparathy cy...@ti.com
---
 arch/arm/mach-davinci/include/mach/ti_ssp.h |4 +
 drivers/gpio/Kconfig|   10 ++
 drivers/gpio/Makefile   |1 +
 drivers/gpio/ti-ssp-gpio.c  |  200 +++
 4 files changed, 215 insertions(+), 0 deletions(-)
 create mode 100644 drivers/gpio/ti-ssp-gpio.c

diff --git a/arch/arm/mach-davinci/include/mach/ti_ssp.h 
b/arch/arm/mach-davinci/include/mach/ti_ssp.h
index bff8ef6..8fed5ab 100644
--- a/arch/arm/mach-davinci/include/mach/ti_ssp.h
+++ b/arch/arm/mach-davinci/include/mach/ti_ssp.h
@@ -39,6 +39,10 @@ struct ti_ssp_spi_data {
void(*select)(int cs);
 };
 
+struct ti_ssp_gpio_data {
+   int start;
+};
+
 /*
  * Sequencer port IO pin configuration bits.  These do not correlate 1-1 with
  * the hardware.  The iosel field in the port data combines iosel1 and iosel2,
diff --git a/drivers/gpio/Kconfig b/drivers/gpio/Kconfig
index 510aa20..e400761 100644
--- a/drivers/gpio/Kconfig
+++ b/drivers/gpio/Kconfig
@@ -111,6 +111,16 @@ config GPIO_SCH
  This driver can also be built as a module. If so, the module
  will be called sch-gpio.
 
+config GPIO_TI_SSP
+   tristate TI SSP Controller GPIO Driver
+   depends on GPIOLIB  TI_SSP
+   help
+ Say yes here to support a virtual GPIO interface on TI SSP ports.
+ Each SSP port translates into 4 GPIOs, with no IRQ support.
+
+ This driver can also be built as a module. If so, the module
+ will be called ti-ssp-gpio.
+
 comment I2C GPIO expanders:
 
 config GPIO_MAX7300
diff --git a/drivers/gpio/Makefile b/drivers/gpio/Makefile
index fc6019d..98b4551 100644
--- a/drivers/gpio/Makefile
+++ b/drivers/gpio/Makefile
@@ -23,6 +23,7 @@ obj-$(CONFIG_GPIO_PL061)  += pl061.o
 obj-$(CONFIG_GPIO_STMPE)   += stmpe-gpio.o
 obj-$(CONFIG_GPIO_TC35892) += tc35892-gpio.o
 obj-$(CONFIG_GPIO_TIMBERDALE)  += timbgpio.o
+obj-$(CONFIG_GPIO_TI_SSP)  += ti-ssp-gpio.o
 obj-$(CONFIG_GPIO_TWL4030) += twl4030-gpio.o
 obj-$(CONFIG_GPIO_UCB1400) += ucb1400_gpio.o
 obj-$(CONFIG_GPIO_XILINX)  += xilinx_gpio.o
diff --git a/drivers/gpio/ti-ssp-gpio.c b/drivers/gpio/ti-ssp-gpio.c
new file mode 100644
index 000..c046713
--- /dev/null
+++ b/drivers/gpio/ti-ssp-gpio.c
@@ -0,0 +1,200 @@
+/*
+ * Sequencer Serial Port (SSP) based virtual GPIO driver
+ *
+ * Copyright (C) 2010 Texas Instruments Inc
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ */
+
+#include linux/init.h
+#include linux/kernel.h
+#include linux/module.h
+#include linux/io.h
+#include linux/err.h
+#include linux/slab.h
+#include linux/gpio.h
+#include linux/platform_device.h
+
+#include mach/ti_ssp.h
+
+struct ti_ssp_gpio {
+   struct gpio_chipchip;
+#define chip2gpio(chip)container_of(chip, struct ti_ssp_gpio, chip)
+   struct device   *dev;
+   spinlock_t  lock;
+   u8  out;
+   u32 iosel;
+};
+
+static int direction_in(struct gpio_chip *chip, unsigned gpio_num)
+{
+   struct ti_ssp_gpio *gpio = chip2gpio(chip);
+   int error = 0;
+
+   spin_lock(gpio-lock);
+
+   gpio-iosel = ~SSP_PIN_MASK(gpio_num);
+   gpio-iosel |=  SSP_PIN_SEL(gpio_num, SSP_IN);
+
+   error = ti_ssp_set_iosel(gpio-dev, gpio-iosel);
+
+   spin_unlock(gpio-lock);
+
+   return error;
+}
+
+static int direction_out(struct gpio_chip *chip, unsigned gpio_num, int val)
+{
+   struct ti_ssp_gpio *gpio = chip2gpio(chip);
+   int error;
+
+   spin_lock(gpio-lock);
+
+   gpio-iosel = ~SSP_PIN_MASK(gpio_num);
+   gpio-iosel |=  SSP_PIN_SEL(gpio_num, SSP_OUT);
+
+   error = ti_ssp_set_iosel(gpio-dev, gpio-iosel);
+
+   if (error  0)
+   goto error;
+
+   if (val)
+   gpio-out |= BIT(gpio_num);
+   else
+   gpio-out = ~BIT(gpio_num);
+
+   error = ti_ssp_raw_write(gpio-dev, gpio-out);
+
+error:
+   spin_unlock(gpio-lock);