[PATCH] input: spi: Driver for SPI data stream driven vibrator
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 --- 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. + 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 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_SIZE1024 /* In bytes */ + +#define FF_EFFECT_QUEUED 0 +#define FF_EFFECT_PLAYING 1 +#define FF_EFFECT_ABORTING 2 +#define FF_EFFECT_UPLOADING3 + +enum vibra_status { + IDLE = 0, + STARTED, + PLAYING, + CLOSING, +}; + +struct 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 effects[VIBRA_EFFECTS]; + int next_effect; + int current_effect; + unsigned long stop_at; +}; + +static int vibra_spi_raw_write_effect(struct vibra_data *vibra) +{ + spi_message_init(vibra-msg); + memset(vibra-t, 0, sizeof(vibra-t)); + + vibra-t.tx_buf = vibra-effects[vibra-current_effect].buf; + vibra-t.len= vibra-effects[vibra-current_effect].buflen; + spi_message_add_tail(vibra-t, vibra-msg); + + return spi_sync(vibra-spi_dev, vibra-msg); +} + +static void vibra_play_work(struct work_struct *work) +{ + struct vibra_data *vibra = container_of(work, + struct vibra_data, play_work); + struct effect_info *curr, *next; + unsigned long flags; + + while (1) { +
Re: [PATCH] intel_mid_ssp_spi: Moorestown and Medfield SPI for SSP devices
2010/10/22 Alan Cox a...@lxorguk.ukuu.org.uk: From: Mathieu SOULARD mathieux.soul...@intel.com (...) +/** + * intel_mid_ssp_spi_dma_init() - Initialize DMA + * @drv_context: Pointer to the private driver context + * + * This function is called at driver setup phase to allocate DMA + * ressources. + */ +static void intel_mid_ssp_spi_dma_init(struct ssp_driver_context *drv_context) +{ + struct intel_mid_dma_slave *rxs, *txs; + struct dma_slave_config *ds; Hey, I really like this :-) But where are you actually using this config? It looks like you're in some transition phase to the generic API. + dma_cap_mask_t mask; + struct device *dev = drv_context-pdev-dev; + unsigned int device_id; + + /* Configure RX channel parameters */ + rxs = drv_context-dmas_rx; + ds = rxs-dma_slave; + + ds-direction = DMA_FROM_DEVICE; + rxs-hs_mode = LNW_DMA_HW_HS; + rxs-cfg_mode = LNW_DMA_PER_TO_MEM; + ds-dst_addr_width = DMA_SLAVE_BUSWIDTH_4_BYTES; + ds-src_addr_width = drv_context-n_bytes; + + /* Use a DMA burst according to the FIFO thresholds */ + if (drv_context-rx_fifo_threshold == 8) { + ds-src_maxburst = 8; + ds-dst_maxburst = 8; + } else if (drv_context-rx_fifo_threshold == 4) { + ds-src_maxburst = 4; + ds-dst_maxburst = 4; + } else { + ds-src_maxburst = 1; + ds-dst_maxburst = 1; + } + + /* Configure TX channel parameters */ + txs = drv_context-dmas_tx; + ds = txs-dma_slave; + + ds-direction = DMA_TO_DEVICE; + txs-hs_mode = LNW_DMA_HW_HS; + txs-cfg_mode = LNW_DMA_MEM_TO_PER; What I cannot wrap my head around is why your DMA controller cannot figure these things out from the data passed in to the + ds-src_addr_width = DMA_SLAVE_BUSWIDTH_4_BYTES; + ds-dst_addr_width = drv_context-n_bytes; You also want to se ds-src_addr and ds-dst_addr instead of passing that through an artificial memcpy() call. + /* Use a DMA burst according to the FIFO thresholds */ + if (drv_context-rx_fifo_threshold == 8) { + ds-src_maxburst = 8; + ds-dst_maxburst = 8; + } else if (drv_context-rx_fifo_threshold == 4) { + ds-src_maxburst = 4; + ds-dst_maxburst = 4; + } else { + ds-src_maxburst = 1; + ds-dst_maxburst = 1; + } + + /* Nothing more to do if already initialized */ There isn't? You need to call rxchan-device-device_control(rxchan, DMA_SLAVE_CONFIG, (unsigned long) ds); To use that config you've set. + if (drv_context-dma_initialized) + return; + + /* Use DMAC1 */ + if (drv_context-quirks QUIRKS_PLATFORM_MRST) + device_id = PCI_MRST_DMAC1_ID; + else + device_id = PCI_MDFL_DMAC1_ID; + + drv_context-dmac1 = pci_get_device(PCI_VENDOR_ID_INTEL, + device_id, NULL); + + if (!drv_context-dmac1) { + dev_err(dev, Can't find DMAC1); + return; + } + + if (drv_context-quirks QUIRKS_SRAM_ADDITIONAL_CPY) { + drv_context-virt_addr_sram_rx = ioremap_nocache(SRAM_BASE_ADDR, + 2 * MAX_SPI_TRANSFER_SIZE); + if (drv_context-virt_addr_sram_rx) + drv_context-virt_addr_sram_tx = + drv_context-virt_addr_sram_rx + + MAX_SPI_TRANSFER_SIZE; + else + dev_err(dev, Virt_addr_sram_rx is null\n); + } + + /* 1. Allocate rx channel */ + dma_cap_zero(mask); + dma_cap_set(DMA_MEMCPY, mask); + dma_cap_set(DMA_SLAVE, mask); You only want to request DMA_SLAVE really. + + drv_context-rxchan = dma_request_channel(mask, chan_filter, + drv_context); + if (!drv_context-rxchan) + goto err_exit; + + drv_context-rxchan-private = rxs; + + /* 2. Allocate tx channel */ + dma_cap_set(DMA_SLAVE, mask); + dma_cap_set(DMA_MEMCPY, mask); + + drv_context-txchan = dma_request_channel(mask, chan_filter, + drv_context); + + if (!drv_context-txchan) + goto free_rxchan; + else + drv_context-txchan-private = txs; rxchan-device-device_control(rxchan, DMA_SLAVE_CONFIG, (unsigned long) ds); txchan-device-device_control(txchan, DMA_SLAVE_CONFIG, (unsigned long) ds); + /* set the dma done bit to 1 */ + drv_context-txdma_done = 1; + drv_context-rxdma_done = 1; + +
Gumstix Overo omap2_mcspi and spidev driver issues
Hi all, i am having big trouble to get the spidev-driver running on my gumstix overo. I patched kernel linux-omap-2.6.34-r90 to not use a touchscreen that was configured for the kernel, but spidev is: diff --git a/arch/arm/mach-omap2/board-overo.c b/arch/arm/mach-omap2/board-overo.c index f357de9..3a9c519 100644 --- a/arch/arm/mach-omap2/board-overo.c +++ b/arch/arm/mach-omap2/board-overo.c @@ -70,8 +70,9 @@ #define OVERO_SMSC911X2_CS 4 #define OVERO_SMSC911X2_GPIO 65 -#if defined(CONFIG_TOUCHSCREEN_ADS7846) || \ - defined(CONFIG_TOUCHSCREEN_ADS7846_MODULE) +//#if defined(CONFIG_TOUCHSCREEN_ADS7846) || \ +// defined(CONFIG_TOUCHSCREEN_ADS7846_MODULE) +#if 0 #include linux/spi/ads7846.h @@ -616,7 +617,8 @@ return 0; } -static struct spi_board_info overo_spi_board_info[] __initdata = { +static struct spi_board_info overo_spi_board_info[] = { +/* #if defined(CONFIG_TOUCHSCREEN_ADS7846) || \ defined(CONFIG_TOUCHSCREEN_ADS7846_MODULE) { @@ -639,11 +641,19 @@ .mode = SPI_MODE_3, }, #endif +*/ + { + .modalias = spidev, + .bus_num = 1, + .chip_select = 0, + .max_speed_hz = 100, + .mode = SPI_MODE_0, + }, }; static int __init overo_spi_init(void) { - overo_ads7846_init(); + //overo_ads7846_init(); spi_register_board_info(overo_spi_board_info, ARRAY_SIZE(overo_spi_board_info)); return 0; It seems to have worked alright, I can see /dev/spidev1.0 and running the spidev_test program it does not complain. Nevertheless, i dont get any signal on the pins. Am I missing something essential? Is there a good way to debug the problem? I running out of ideas. I read a lot of other people having similar problems, which could be fixed by not using the max_speed_hz and bits_per_word, but all that did not help for me. I would appreciate some help, or hints at least. Regards, Norman -- GRATIS! Movie-FLAT mit über 300 Videos. Jetzt freischalten unter http://portal.gmx.net/de/go/maxdome -- 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: Gumstix Overo omap2_mcspi and spidev driver issues
-Original Message- From: Norman Wildmann [mailto:nenntmichdochwieihrwo...@gmx.de] It seems to have worked alright, I can see /dev/spidev1.0 and running the spidev_test program it does not complain. Nevertheless, i dont get any signal on the pins. You might need to check pin mux first? -Girish -- 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
阿巴斯 迪拜 卡拉奇 $1200/40HQ 上海港10月
上海港出口 2010-10-25 1.欧洲基本港 $1500/20'GP $2900/40'GP $2950/40'HQ 直达快船 到LE HAVRE ANTWERP ROTTERDAM HAMBURG港口 到LE HAVRE ROTTERDAM 28天 HAMBURG 29天 ANTWERP 30天 2.巴生 $300/600/600 新加坡 $150/300/300 迪拜 $725/1200/1200 卡拉奇 $725/1200/1200 阿巴斯 $725/1200/1200 以上海运费均为海单ALLIN价格 TMCL Container Line T:021-60955541 F:021-60955622 邮件及msn: sht...@hotmail.com 手机: 13917986522 王先生 北欧国家各港口现以开始承接,如有需要可email咨询。 需要海运价格表的,可以发邮件给我,在邮件中请注明贵公司名称。 非洲线新推出低价位船,欧洲线价格维持不变 如不需要此邮件,可以回复我,我将在下次的发送中取消 -- 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