1010#include <linux/dma-mapping.h>
1111#include <linux/gpio.h>
1212#include <linux/gpio/machine.h>
13+ #include <linux/gpio/property.h>
1314#include <linux/init.h>
1415#include <linux/interrupt.h>
1516#include <linux/leds.h>
1617#include <linux/mmc/host.h>
1718#include <linux/platform_device.h>
19+ #include <linux/property.h>
1820#include <linux/pm.h>
1921#include <linux/spi/spi.h>
2022#include <linux/spi/spi_gpio.h>
21- #include <linux/spi/ads7846.h>
2223#include <asm/mach-au1x00/au1000.h>
2324#include <asm/mach-au1x00/gpio-au1000.h>
2425#include <asm/mach-au1x00/au1000_dma.h>
@@ -374,22 +375,20 @@ static struct platform_device db1100_mmc1_dev = {
374375
375376/******************************************************************************/
376377
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" ,
380380};
381381
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+ { }
384387};
385388
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 ,
393392};
394393
395394static struct spi_board_info db1100_spi_info [] __initdata = {
@@ -400,37 +399,37 @@ static struct spi_board_info db1100_spi_info[] __initdata = {
400399 .chip_select = 0 ,
401400 .mode = 0 ,
402401 .irq = AU1100_GPIO21_INT ,
403- .platform_data = & db1100_touch_pd ,
402+ .swnode = & db1100_ads7846_swnode ,
404403 },
405404};
406405
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 ,
415408};
416409
417410/*
418411 * Alchemy GPIO 2 has its base at 200 so the GPIO lines
419412 * 207 thru 210 are GPIOs at offset 7 thru 10 at this chip.
420413 */
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 ,
434433};
435434
436435static struct platform_device * db1x00_devs [] = {
@@ -452,8 +451,10 @@ int __init db1000_dev_setup(void)
452451{
453452 int board = BCSR_WHOAMI_BOARD (bcsr_read (BCSR_WHOAMI ));
454453 int c0 , c1 , d0 , d1 , s0 , s1 , flashsize = 32 , twosocks = 1 ;
454+ int err ;
455455 unsigned long pfc ;
456456 struct clk * c , * p ;
457+ struct platform_device * spi_dev ;
457458
458459 if (board == BCSR_WHOAMI_DB1500 ) {
459460 c0 = AU1500_GPIO2_INT ;
@@ -480,7 +481,7 @@ int __init db1000_dev_setup(void)
480481 pfc |= (1 << 0 ); /* SSI0 pins as GPIOs */
481482 alchemy_wrsys (pfc , AU1000_SYS_PINFUNC );
482483
483- gpiod_add_lookup_table ( & db1100_touch_gpio_table );
484+ software_node_register ( & db1100_alchemy2_gpiochip );
484485 spi_register_board_info (db1100_spi_info ,
485486 ARRAY_SIZE (db1100_spi_info ));
486487
@@ -497,8 +498,11 @@ int __init db1000_dev_setup(void)
497498 clk_put (p );
498499
499500 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 );
502506 } else if (board == BCSR_WHOAMI_DB1000 ) {
503507 c0 = AU1000_GPIO2_INT ;
504508 c1 = AU1000_GPIO5_INT ;
0 commit comments