10
10
#include <linux/dma-mapping.h>
11
11
#include <linux/gpio.h>
12
12
#include <linux/gpio/machine.h>
13
+ #include <linux/gpio/property.h>
13
14
#include <linux/init.h>
14
15
#include <linux/interrupt.h>
15
16
#include <linux/leds.h>
16
17
#include <linux/mmc/host.h>
17
18
#include <linux/platform_device.h>
19
+ #include <linux/property.h>
18
20
#include <linux/pm.h>
19
21
#include <linux/spi/spi.h>
20
22
#include <linux/spi/spi_gpio.h>
21
- #include <linux/spi/ads7846.h>
22
23
#include <asm/mach-au1x00/au1000.h>
23
24
#include <asm/mach-au1x00/gpio-au1000.h>
24
25
#include <asm/mach-au1x00/au1000_dma.h>
@@ -374,22 +375,20 @@ static struct platform_device db1100_mmc1_dev = {
374
375
375
376
/******************************************************************************/
376
377
377
- static struct ads7846_platform_data db1100_touch_pd = {
378
- .model = 7846 ,
379
- .vref_mv = 3300 ,
378
+ static const struct software_node db1100_alchemy2_gpiochip = {
379
+ .name = "alchemy-gpio2" ,
380
380
};
381
381
382
- static struct spi_gpio_platform_data db1100_spictl_pd = {
383
- .num_chipselect = 1 ,
382
+ static const struct property_entry db1100_ads7846_properties [] = {
383
+ PROPERTY_ENTRY_U16 ("ti,vref_min" , 3300 ),
384
+ PROPERTY_ENTRY_GPIO ("pendown-gpios" ,
385
+ & db1100_alchemy2_gpiochip , 21 , GPIO_ACTIVE_LOW ),
386
+ { }
384
387
};
385
388
386
- static struct gpiod_lookup_table db1100_touch_gpio_table = {
387
- .dev_id = "spi0.0" ,
388
- .table = {
389
- GPIO_LOOKUP ("alchemy-gpio2" , 21 ,
390
- "pendown" , GPIO_ACTIVE_LOW ),
391
- { }
392
- },
389
+ static const struct software_node db1100_ads7846_swnode = {
390
+ .name = "ads7846" ,
391
+ .properties = db1100_ads7846_properties ,
393
392
};
394
393
395
394
static struct spi_board_info db1100_spi_info [] __initdata = {
@@ -400,37 +399,37 @@ static struct spi_board_info db1100_spi_info[] __initdata = {
400
399
.chip_select = 0 ,
401
400
.mode = 0 ,
402
401
.irq = AU1100_GPIO21_INT ,
403
- .platform_data = & db1100_touch_pd ,
402
+ .swnode = & db1100_ads7846_swnode ,
404
403
},
405
404
};
406
405
407
- static struct platform_device db1100_spi_dev = {
408
- .name = "spi_gpio" ,
409
- .id = 0 ,
410
- .dev = {
411
- .platform_data = & db1100_spictl_pd ,
412
- .dma_mask = & au1xxx_all_dmamask ,
413
- .coherent_dma_mask = DMA_BIT_MASK (32 ),
414
- },
406
+ static const struct spi_gpio_platform_data db1100_spictl_pd __initconst = {
407
+ .num_chipselect = 1 ,
415
408
};
416
409
417
410
/*
418
411
* Alchemy GPIO 2 has its base at 200 so the GPIO lines
419
412
* 207 thru 210 are GPIOs at offset 7 thru 10 at this chip.
420
413
*/
421
- static struct gpiod_lookup_table db1100_spi_gpiod_table = {
422
- .dev_id = "spi_gpio" ,
423
- .table = {
424
- GPIO_LOOKUP ("alchemy-gpio2" , 9 ,
425
- "sck" , GPIO_ACTIVE_HIGH ),
426
- GPIO_LOOKUP ("alchemy-gpio2" , 8 ,
427
- "mosi" , GPIO_ACTIVE_HIGH ),
428
- GPIO_LOOKUP ("alchemy-gpio2" , 7 ,
429
- "miso" , GPIO_ACTIVE_HIGH ),
430
- GPIO_LOOKUP ("alchemy-gpio2" , 10 ,
431
- "cs" , GPIO_ACTIVE_HIGH ),
432
- { },
433
- },
414
+ static const struct property_entry db1100_spi_dev_properties [] __initconst = {
415
+ PROPERTY_ENTRY_GPIO ("miso-gpios" ,
416
+ & db1100_alchemy2_gpiochip , 7 , GPIO_ACTIVE_HIGH ),
417
+ PROPERTY_ENTRY_GPIO ("mosi-gpios" ,
418
+ & db1100_alchemy2_gpiochip , 8 , GPIO_ACTIVE_HIGH ),
419
+ PROPERTY_ENTRY_GPIO ("sck-gpios" ,
420
+ & db1100_alchemy2_gpiochip , 9 , GPIO_ACTIVE_HIGH ),
421
+ PROPERTY_ENTRY_GPIO ("cs-gpios" ,
422
+ & db1100_alchemy2_gpiochip , 10 , GPIO_ACTIVE_HIGH ),
423
+ { }
424
+ };
425
+
426
+ static const struct platform_device_info db1100_spi_dev_info __initconst = {
427
+ .name = "spi_gpio" ,
428
+ .id = 0 ,
429
+ .data = & db1100_spictl_pd ,
430
+ .size_data = sizeof (db1100_spictl_pd ),
431
+ .dma_mask = DMA_BIT_MASK (32 ),
432
+ .properties = db1100_spi_dev_properties ,
434
433
};
435
434
436
435
static struct platform_device * db1x00_devs [] = {
@@ -452,8 +451,10 @@ int __init db1000_dev_setup(void)
452
451
{
453
452
int board = BCSR_WHOAMI_BOARD (bcsr_read (BCSR_WHOAMI ));
454
453
int c0 , c1 , d0 , d1 , s0 , s1 , flashsize = 32 , twosocks = 1 ;
454
+ int err ;
455
455
unsigned long pfc ;
456
456
struct clk * c , * p ;
457
+ struct platform_device * spi_dev ;
457
458
458
459
if (board == BCSR_WHOAMI_DB1500 ) {
459
460
c0 = AU1500_GPIO2_INT ;
@@ -480,7 +481,7 @@ int __init db1000_dev_setup(void)
480
481
pfc |= (1 << 0 ); /* SSI0 pins as GPIOs */
481
482
alchemy_wrsys (pfc , AU1000_SYS_PINFUNC );
482
483
483
- gpiod_add_lookup_table ( & db1100_touch_gpio_table );
484
+ software_node_register ( & db1100_alchemy2_gpiochip );
484
485
spi_register_board_info (db1100_spi_info ,
485
486
ARRAY_SIZE (db1100_spi_info ));
486
487
@@ -497,8 +498,11 @@ int __init db1000_dev_setup(void)
497
498
clk_put (p );
498
499
499
500
platform_add_devices (db1100_devs , ARRAY_SIZE (db1100_devs ));
500
- gpiod_add_lookup_table (& db1100_spi_gpiod_table );
501
- platform_device_register (& db1100_spi_dev );
501
+
502
+ spi_dev = platform_device_register_full (& db1100_spi_dev_info );
503
+ err = PTR_ERR_OR_ZERO (spi_dev );
504
+ if (err )
505
+ pr_err ("failed to register SPI controller: %d\n" , err );
502
506
} else if (board == BCSR_WHOAMI_DB1000 ) {
503
507
c0 = AU1000_GPIO2_INT ;
504
508
c1 = AU1000_GPIO5_INT ;
0 commit comments