aboutsummaryrefslogtreecommitdiffstats
path: root/arch/arm/mach-pxa/lubbock.c
diff options
context:
space:
mode:
authorDavid Brownell <david-b@pacbell.net>2006-06-18 11:39:33 -0400
committerRussell King <rmk+kernel@arm.linux.org.uk>2006-06-18 11:39:33 -0400
commit9df5db80a781c1a1c67388c82f64f835093c3cc3 (patch)
tree65f80286fefe7a85a1d2cdb74a9befdcf9084564 /arch/arm/mach-pxa/lubbock.c
parentebc67da65fda03cbe5b4019d91229287fddd5c6e (diff)
[ARM] 3534/1: add spi support to lubbock platform
Patch from David Brownell This adds the platform device for SSP/SPI controller, and declares the ads7846 device hooked up to it. Not all Lubbock boards appear to populate the connector needed to use this instead of the ucb1400 chip, but it can always be used as a temperature sensor. In short, this is probably most useful as an example of how to provide the configuration data used by the pxa2xx_spi driver. (Last tested against a slightly earlier version of that driver.) Signed-off-by: David Brownell <dbrownell@users.sourceforge.net> Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
Diffstat (limited to 'arch/arm/mach-pxa/lubbock.c')
-rw-r--r--arch/arm/mach-pxa/lubbock.c84
1 files changed, 84 insertions, 0 deletions
diff --git a/arch/arm/mach-pxa/lubbock.c b/arch/arm/mach-pxa/lubbock.c
index 3e26d7ce5bb2..1ab26c6914f2 100644
--- a/arch/arm/mach-pxa/lubbock.c
+++ b/arch/arm/mach-pxa/lubbock.c
@@ -22,6 +22,10 @@
22#include <linux/mtd/mtd.h> 22#include <linux/mtd/mtd.h>
23#include <linux/mtd/partitions.h> 23#include <linux/mtd/partitions.h>
24 24
25#include <linux/spi/spi.h>
26#include <linux/spi/ads7846.h>
27#include <asm/arch/pxa2xx_spi.h>
28
25#include <asm/setup.h> 29#include <asm/setup.h>
26#include <asm/memory.h> 30#include <asm/memory.h>
27#include <asm/mach-types.h> 31#include <asm/mach-types.h>
@@ -196,6 +200,78 @@ static struct resource smc91x_resources[] = {
196 }, 200 },
197}; 201};
198 202
203/* ADS7846 is connected through SSP ... and if your board has J5 populated,
204 * you can select it to replace the ucb1400 by switching the touchscreen cable
205 * (to J5) and poking board registers (as done below). Else it's only useful
206 * for the temperature sensors.
207 */
208static struct resource pxa_ssp_resources[] = {
209 [0] = {
210 .start = __PREG(SSCR0_P(1)),
211 .end = __PREG(SSCR0_P(1)) + 0x14,
212 .flags = IORESOURCE_MEM,
213 },
214 [1] = {
215 .start = IRQ_SSP,
216 .end = IRQ_SSP,
217 .flags = IORESOURCE_IRQ,
218 },
219};
220
221static struct pxa2xx_spi_master pxa_ssp_master_info = {
222 .ssp_type = PXA25x_SSP,
223 .clock_enable = CKEN3_SSP,
224 .num_chipselect = 0,
225};
226
227static struct platform_device pxa_ssp = {
228 .name = "pxa2xx-spi",
229 .id = 1,
230 .resource = pxa_ssp_resources,
231 .num_resources = ARRAY_SIZE(pxa_ssp_resources),
232 .dev = {
233 .platform_data = &pxa_ssp_master_info,
234 },
235};
236
237static int lubbock_ads7846_pendown_state(void)
238{
239 /* TS_BUSY is bit 8 in LUB_MISC_RD, but pendown is irq-only */
240 return 0;
241}
242
243static struct ads7846_platform_data ads_info = {
244 .model = 7846,
245 .vref_delay_usecs = 100, /* internal, no cap */
246 .get_pendown_state = lubbock_ads7846_pendown_state,
247 // .x_plate_ohms = 500, /* GUESS! */
248 // .y_plate_ohms = 500, /* GUESS! */
249};
250
251static void ads7846_cs(u32 command)
252{
253 static const unsigned TS_nCS = 1 << 11;
254 lubbock_set_misc_wr(TS_nCS, (command == PXA2XX_CS_ASSERT) ? 0 : TS_nCS);
255}
256
257static struct pxa2xx_spi_chip ads_hw = {
258 .tx_threshold = 1,
259 .rx_threshold = 2,
260 .cs_control = ads7846_cs,
261};
262
263static struct spi_board_info spi_board_info[] __initdata = { {
264 .modalias = "ads7846",
265 .platform_data = &ads_info,
266 .controller_data = &ads_hw,
267 .irq = LUBBOCK_BB_IRQ,
268 .max_speed_hz = 120000 /* max sample rate at 3V */
269 * 26 /* command + data + overhead */,
270 .bus_num = 1,
271 .chip_select = 0,
272},
273};
274
199static struct platform_device smc91x_device = { 275static struct platform_device smc91x_device = {
200 .name = "smc91x", 276 .name = "smc91x",
201 .id = -1, 277 .id = -1,
@@ -272,6 +348,7 @@ static struct platform_device *devices[] __initdata = {
272 &smc91x_device, 348 &smc91x_device,
273 &lubbock_flash_device[0], 349 &lubbock_flash_device[0],
274 &lubbock_flash_device[1], 350 &lubbock_flash_device[1],
351 &pxa_ssp,
275}; 352};
276 353
277static struct pxafb_mach_info sharp_lm8v31 __initdata = { 354static struct pxafb_mach_info sharp_lm8v31 __initdata = {
@@ -400,6 +477,8 @@ static void __init lubbock_init(void)
400 lubbock_flash_data[flashboot^1].name = "application-flash"; 477 lubbock_flash_data[flashboot^1].name = "application-flash";
401 lubbock_flash_data[flashboot].name = "boot-rom"; 478 lubbock_flash_data[flashboot].name = "boot-rom";
402 (void) platform_add_devices(devices, ARRAY_SIZE(devices)); 479 (void) platform_add_devices(devices, ARRAY_SIZE(devices));
480
481 spi_register_board_info(spi_board_info, ARRAY_SIZE(spi_board_info));
403} 482}
404 483
405static struct map_desc lubbock_io_desc[] __initdata = { 484static struct map_desc lubbock_io_desc[] __initdata = {
@@ -416,6 +495,11 @@ static void __init lubbock_map_io(void)
416 pxa_map_io(); 495 pxa_map_io();
417 iotable_init(lubbock_io_desc, ARRAY_SIZE(lubbock_io_desc)); 496 iotable_init(lubbock_io_desc, ARRAY_SIZE(lubbock_io_desc));
418 497
498 /* SSP data pins */
499 pxa_gpio_mode(GPIO23_SCLK_MD);
500 pxa_gpio_mode(GPIO25_STXD_MD);
501 pxa_gpio_mode(GPIO26_SRXD_MD);
502
419 /* This enables the BTUART */ 503 /* This enables the BTUART */
420 pxa_gpio_mode(GPIO42_BTRXD_MD); 504 pxa_gpio_mode(GPIO42_BTRXD_MD);
421 pxa_gpio_mode(GPIO43_BTTXD_MD); 505 pxa_gpio_mode(GPIO43_BTTXD_MD);