3131#include <linux/cnt32_to_63.h>
3232#include <linux/io.h>
3333#include <linux/module.h>
34+ #include <linux/spi/spi.h>
3435
3536#include <linux/version.h>
3637#if LINUX_VERSION_CODE >= KERNEL_VERSION (2 ,6 ,38 )
@@ -195,15 +196,13 @@ static struct clk osc_clk = {
195196
196197/* warning - the USB needs a clock > 34MHz */
197198
198- #ifdef CONFIG_MMC_BCM2708
199199static struct clk sdhost_clk = {
200200#ifdef CONFIG_ARCH_BCM2708_CHIPIT
201201 .rate = 4000000 , /* 4MHz */
202202#else
203203 .rate = 250000000 , /* 250MHz */
204204#endif
205205};
206- #endif
207206
208207static struct clk_lookup lookups [] = {
209208 { /* UART0 */
@@ -219,6 +218,15 @@ static struct clk_lookup lookups[] = {
219218 .dev_id = "bcm2708_mci.0" ,
220219 .clk = & sdhost_clk ,
221220#endif
221+ }, { /* SPI */
222+ .dev_id = "bcm2708_spi.0" ,
223+ .clk = & sdhost_clk ,
224+ }, { /* BSC0 */
225+ .dev_id = "bcm2708_i2c.0" ,
226+ .clk = & sdhost_clk ,
227+ }, { /* BSC1 */
228+ .dev_id = "bcm2708_i2c.1" ,
229+ .clk = & sdhost_clk ,
222230 }
223231};
224232
@@ -461,6 +469,80 @@ static struct platform_device bcm2708_alsa_devices[] = {
461469 },
462470};
463471
472+ static struct resource bcm2708_spi_resources [] = {
473+ {
474+ .start = SPI0_BASE ,
475+ .end = SPI0_BASE + SZ_256 - 1 ,
476+ .flags = IORESOURCE_MEM ,
477+ }, {
478+ .start = IRQ_SPI ,
479+ .end = IRQ_SPI ,
480+ .flags = IORESOURCE_IRQ ,
481+ }
482+ };
483+
484+ static struct platform_device bcm2708_spi_device = {
485+ .name = "bcm2708_spi" ,
486+ .id = 0 ,
487+ .num_resources = ARRAY_SIZE (bcm2708_spi_resources ),
488+ .resource = bcm2708_spi_resources ,
489+ };
490+
491+ static struct spi_board_info bcm2708_spi_devices [] = {
492+ {
493+ .modalias = "spidev" ,
494+ .max_speed_hz = 500000 ,
495+ .bus_num = 0 ,
496+ .chip_select = 0 ,
497+ .mode = SPI_MODE_0 ,
498+ }, {
499+ .modalias = "spidev" ,
500+ .max_speed_hz = 500000 ,
501+ .bus_num = 0 ,
502+ .chip_select = 1 ,
503+ .mode = SPI_MODE_0 ,
504+ }
505+ };
506+
507+ static struct resource bcm2708_bsc0_resources [] = {
508+ {
509+ .start = BSC0_BASE ,
510+ .end = BSC0_BASE + SZ_256 - 1 ,
511+ .flags = IORESOURCE_MEM ,
512+ }, {
513+ .start = INTERRUPT_I2C ,
514+ .end = INTERRUPT_I2C ,
515+ .flags = IORESOURCE_IRQ ,
516+ }
517+ };
518+
519+ static struct platform_device bcm2708_bsc0_device = {
520+ .name = "bcm2708_i2c" ,
521+ .id = 0 ,
522+ .num_resources = ARRAY_SIZE (bcm2708_bsc0_resources ),
523+ .resource = bcm2708_bsc0_resources ,
524+ };
525+
526+
527+ static struct resource bcm2708_bsc1_resources [] = {
528+ {
529+ .start = BSC1_BASE ,
530+ .end = BSC1_BASE + SZ_256 - 1 ,
531+ .flags = IORESOURCE_MEM ,
532+ }, {
533+ .start = INTERRUPT_I2C ,
534+ .end = INTERRUPT_I2C ,
535+ .flags = IORESOURCE_IRQ ,
536+ }
537+ };
538+
539+ static struct platform_device bcm2708_bsc1_device = {
540+ .name = "bcm2708_i2c" ,
541+ .id = 1 ,
542+ .num_resources = ARRAY_SIZE (bcm2708_bsc1_resources ),
543+ .resource = bcm2708_bsc1_resources ,
544+ };
545+
464546int __init bcm_register_device (struct platform_device * pdev )
465547{
466548 int ret ;
@@ -513,6 +595,10 @@ void __init bcm2708_init(void)
513595 for (i = 0 ; i < ARRAY_SIZE (bcm2708_alsa_devices ); i ++ )
514596 bcm_register_device (& bcm2708_alsa_devices [i ]);
515597
598+ bcm_register_device (& bcm2708_spi_device );
599+ bcm_register_device (& bcm2708_bsc0_device );
600+ bcm_register_device (& bcm2708_bsc1_device );
601+
516602#ifdef CONFIG_BCM2708_VCMEM
517603 {
518604 extern void vc_mem_connected_init (void );
@@ -525,6 +611,11 @@ void __init bcm2708_init(void)
525611 }
526612 system_rev = boardrev ;
527613 system_serial_low = serial ;
614+
615+ #ifdef CONFIG_SPI
616+ spi_register_board_info (bcm2708_spi_devices ,
617+ ARRAY_SIZE (bcm2708_spi_devices ));
618+ #endif
528619}
529620
530621#define TIMER_PERIOD 10000 /* HZ in microsecs */
0 commit comments