35
35
#include <linux/module.h>
36
36
#include <linux/of_platform.h>
37
37
#include <linux/spi/spi.h>
38
+ #include <linux/gpio/machine.h>
38
39
#include <linux/w1-gpio.h>
39
40
40
41
#include <linux/version.h>
@@ -93,6 +94,8 @@ static unsigned reboot_part = 0;
93
94
static unsigned w1_gpio_pin = W1_GPIO ;
94
95
static unsigned w1_gpio_pullup = W1_PULLUP ;
95
96
97
+ static unsigned use_dt = 0 ;
98
+
96
99
static void __init bcm2708_init_led (void );
97
100
98
101
void __init bcm2708_init_irq (void )
@@ -514,7 +517,6 @@ static struct platform_device bcm2708_alsa_devices[] = {
514
517
},
515
518
};
516
519
517
- #ifndef CONFIG_OF
518
520
static struct resource bcm2708_spi_resources [] = {
519
521
{
520
522
.start = SPI0_BASE ,
@@ -538,7 +540,6 @@ static struct platform_device bcm2708_spi_device = {
538
540
.dma_mask = & bcm2708_spi_dmamask ,
539
541
.coherent_dma_mask = DMA_BIT_MASK (DMA_MASK_BITS_COMMON )},
540
542
};
541
- #endif
542
543
543
544
#ifdef CONFIG_BCM2708_SPIDEV
544
545
static struct spi_board_info bcm2708_spi_devices [] = {
@@ -560,7 +561,6 @@ static struct spi_board_info bcm2708_spi_devices[] = {
560
561
};
561
562
#endif
562
563
563
- #ifndef CONFIG_OF
564
564
static struct resource bcm2708_bsc0_resources [] = {
565
565
{
566
566
.start = BSC0_BASE ,
@@ -599,7 +599,6 @@ static struct platform_device bcm2708_bsc1_device = {
599
599
.num_resources = ARRAY_SIZE (bcm2708_bsc1_resources ),
600
600
.resource = bcm2708_bsc1_resources ,
601
601
};
602
- #endif
603
602
604
603
static struct platform_device bcm2835_hwmon_device = {
605
604
.name = "bcm2835_hwmon" ,
@@ -609,7 +608,7 @@ static struct platform_device bcm2835_thermal_device = {
609
608
.name = "bcm2835_thermal" ,
610
609
};
611
610
612
- #ifdef CONFIG_SND_BCM2708_SOC_I2S_MODULE
611
+ #if defined( CONFIG_SND_BCM2708_SOC_I2S ) || defined( CONFIG_SND_BCM2708_SOC_I2S_MODULE )
613
612
static struct resource bcm2708_i2s_resources [] = {
614
613
{
615
614
.start = I2S_BASE ,
@@ -731,14 +730,14 @@ int __init bcm_register_device(struct platform_device *pdev)
731
730
}
732
731
733
732
/*
734
- * Use this macro for platform devices that are present in the Device Tree.
735
- * This way the device is only added on non-DT builds .
733
+ * Use these macros for platform and i2c devices that are present in the
734
+ * Device Tree. This way the devices are only added on non-DT systems .
736
735
*/
737
- #ifdef CONFIG_OF
738
- #define bcm_register_device_dt (pdev )
739
- #else
740
- #define bcm_register_device_dt ( pdev ) bcm_register_device(pdev)
741
- #endif
736
+ #define bcm_register_device_dt ( pdev ) \
737
+ if (!use_dt) bcm_register_device (pdev)
738
+
739
+ #define i2c_register_board_info_dt ( busnum , info , n ) \
740
+ if (!use_dt) i2c_register_board_info(busnum, info, n)
742
741
743
742
int calc_rsts (int partition )
744
743
{
@@ -814,7 +813,9 @@ static void __init bcm2708_dt_init(void)
814
813
ret = of_platform_populate (NULL , of_default_bus_match_table , NULL , NULL );
815
814
if (ret ) {
816
815
pr_err ("of_platform_populate failed: %d\n" , ret );
817
- BUG ();
816
+ /* Proceed as if CONFIG_OF was not defined */
817
+ } else {
818
+ use_dt = 1 ;
818
819
}
819
820
}
820
821
#else
@@ -842,7 +843,7 @@ void __init bcm2708_init(void)
842
843
#if defined(CONFIG_W1_MASTER_GPIO ) || defined(CONFIG_W1_MASTER_GPIO_MODULE )
843
844
w1_gpio_pdata .pin = w1_gpio_pin ;
844
845
w1_gpio_pdata .ext_pullup_enable_pin = w1_gpio_pullup ;
845
- platform_device_register (& w1_device );
846
+ bcm_register_device_dt (& w1_device );
846
847
#endif
847
848
bcm_register_device (& bcm2708_systemtimer_device );
848
849
bcm_register_device (& bcm2708_fb_device );
@@ -857,46 +858,45 @@ void __init bcm2708_init(void)
857
858
for (i = 0 ; i < ARRAY_SIZE (bcm2708_alsa_devices ); i ++ )
858
859
bcm_register_device (& bcm2708_alsa_devices [i ]);
859
860
861
+ bcm_register_device (& bcm2835_hwmon_device );
862
+ bcm_register_device (& bcm2835_thermal_device );
863
+
860
864
bcm_register_device_dt (& bcm2708_spi_device );
861
865
bcm_register_device_dt (& bcm2708_bsc0_device );
862
866
bcm_register_device_dt (& bcm2708_bsc1_device );
863
867
864
- bcm_register_device (& bcm2835_hwmon_device );
865
- bcm_register_device (& bcm2835_thermal_device );
866
-
867
- #ifdef CONFIG_SND_BCM2708_SOC_I2S_MODULE
868
- bcm_register_device (& bcm2708_i2s_device );
868
+ #if defined(CONFIG_SND_BCM2708_SOC_I2S ) || defined(CONFIG_SND_BCM2708_SOC_I2S_MODULE )
869
+ bcm_register_device_dt (& bcm2708_i2s_device );
869
870
#endif
870
871
871
872
#if defined(CONFIG_SND_BCM2708_SOC_HIFIBERRY_DAC ) || defined(CONFIG_SND_BCM2708_SOC_HIFIBERRY_DAC_MODULE )
872
- bcm_register_device (& snd_hifiberry_dac_device );
873
- bcm_register_device (& snd_pcm5102a_codec_device );
873
+ bcm_register_device_dt (& snd_hifiberry_dac_device );
874
+ bcm_register_device_dt (& snd_pcm5102a_codec_device );
874
875
#endif
875
876
876
877
#if defined(CONFIG_SND_BCM2708_SOC_HIFIBERRY_DACPLUS ) || defined(CONFIG_SND_BCM2708_SOC_HIFIBERRY_DACPLUS_MODULE )
877
- bcm_register_device (& snd_rpi_hifiberry_dacplus_device );
878
- i2c_register_board_info (1 , snd_pcm512x_hbdacplus_i2c_devices , ARRAY_SIZE (snd_pcm512x_hbdacplus_i2c_devices ));
878
+ bcm_register_device_dt (& snd_rpi_hifiberry_dacplus_device );
879
+ i2c_register_board_info_dt (1 , snd_pcm512x_hbdacplus_i2c_devices , ARRAY_SIZE (snd_pcm512x_hbdacplus_i2c_devices ));
879
880
#endif
880
881
881
882
#if defined(CONFIG_SND_BCM2708_SOC_HIFIBERRY_DIGI ) || defined(CONFIG_SND_BCM2708_SOC_HIFIBERRY_DIGI_MODULE )
882
- bcm_register_device (& snd_hifiberry_digi_device );
883
- i2c_register_board_info (1 , snd_wm8804_i2c_devices , ARRAY_SIZE (snd_wm8804_i2c_devices ));
883
+ bcm_register_device_dt (& snd_hifiberry_digi_device );
884
+ i2c_register_board_info_dt (1 , snd_wm8804_i2c_devices , ARRAY_SIZE (snd_wm8804_i2c_devices ));
884
885
#endif
885
886
886
887
#if defined(CONFIG_SND_BCM2708_SOC_HIFIBERRY_AMP ) || defined(CONFIG_SND_BCM2708_SOC_HIFIBERRY_AMP_MODULE )
887
- bcm_register_device (& snd_hifiberry_amp_device );
888
- i2c_register_board_info (1 , snd_tas5713_i2c_devices , ARRAY_SIZE (snd_tas5713_i2c_devices ));
888
+ bcm_register_device_dt (& snd_hifiberry_amp_device );
889
+ i2c_register_board_info_dt (1 , snd_tas5713_i2c_devices , ARRAY_SIZE (snd_tas5713_i2c_devices ));
889
890
#endif
890
891
891
-
892
892
#if defined(CONFIG_SND_BCM2708_SOC_RPI_DAC ) || defined(CONFIG_SND_BCM2708_SOC_RPI_DAC_MODULE )
893
- bcm_register_device (& snd_rpi_dac_device );
894
- bcm_register_device (& snd_pcm1794a_codec_device );
893
+ bcm_register_device_dt (& snd_rpi_dac_device );
894
+ bcm_register_device_dt (& snd_pcm1794a_codec_device );
895
895
#endif
896
896
897
897
#if defined(CONFIG_SND_BCM2708_SOC_IQAUDIO_DAC ) || defined(CONFIG_SND_BCM2708_SOC_IQAUDIO_DAC_MODULE )
898
- bcm_register_device (& snd_rpi_iqaudio_dac_device );
899
- i2c_register_board_info (1 , snd_pcm512x_i2c_devices , ARRAY_SIZE (snd_pcm512x_i2c_devices ));
898
+ bcm_register_device_dt (& snd_rpi_iqaudio_dac_device );
899
+ i2c_register_board_info_dt (1 , snd_pcm512x_i2c_devices , ARRAY_SIZE (snd_pcm512x_i2c_devices ));
900
900
#endif
901
901
902
902
@@ -1040,9 +1040,9 @@ static struct platform_device bcm2708_led_device = {
1040
1040
1041
1041
static void __init bcm2708_init_led (void )
1042
1042
{
1043
- bcm2708_leds [0 ].gpio = disk_led_gpio ;
1044
- bcm2708_leds [0 ].active_low = disk_led_active_low ;
1045
- platform_device_register (& bcm2708_led_device );
1043
+ bcm2708_leds [0 ].gpio = disk_led_gpio ;
1044
+ bcm2708_leds [0 ].active_low = disk_led_active_low ;
1045
+ bcm_register_device_dt (& bcm2708_led_device );
1046
1046
}
1047
1047
#else
1048
1048
static inline void bcm2708_init_led (void )
0 commit comments