Skip to content

Commit 10b3780

Browse files
committed
Merge pull request #47 from cburbridge/i2c
Backport of Chris Boot's i2c and spi drivers. Thanks bootc and cburbridge.
2 parents 12cb45e + dc9424f commit 10b3780

File tree

9 files changed

+1113
-2
lines changed

9 files changed

+1113
-2
lines changed

arch/arm/configs/bcmrpi_cutdown_defconfig

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -550,3 +550,12 @@ CONFIG_CRYPTO_DEFLATE=m
550550
# CONFIG_CRYPTO_HW is not set
551551
CONFIG_CRC_ITU_T=y
552552
CONFIG_LIBCRC32C=y
553+
CONFIG_I2C=y
554+
CONFIG_I2C_BOARDINFO=y
555+
CONFIG_I2C_COMPAT=y
556+
CONFIG_I2C_CHARDEV=m
557+
CONFIG_I2C_HELPER_AUTO=y
558+
CONFIG_I2C_BCM2708=m
559+
CONFIG_SPI=y
560+
CONFIG_SPI_MASTER=y
561+
CONFIG_SPI_BCM2708=m

arch/arm/mach-bcm2708/bcm2708.c

Lines changed: 93 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
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
199199
static 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

208207
static 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+
464546
int __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 */

arch/arm/mach-bcm2708/include/mach/platform.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,9 +63,12 @@
6363
#define GPIO_BASE (BCM2708_PERI_BASE + 0x200000) /* GPIO */
6464
#define UART0_BASE (BCM2708_PERI_BASE + 0x201000) /* Uart 0 */
6565
#define MMCI0_BASE (BCM2708_PERI_BASE + 0x202000) /* MMC interface */
66+
#define SPI0_BASE (BCM2708_PERI_BASE + 0x204000) /* SPI0 */
67+
#define BSC0_BASE (BCM2708_PERI_BASE + 0x205000) /* BSC0 I2C/TWI */
6668
#define UART1_BASE (BCM2708_PERI_BASE + 0x215000) /* Uart 1 */
6769
#define EMMC_BASE (BCM2708_PERI_BASE + 0x300000) /* eMMC interface */
6870
#define SMI_BASE (BCM2708_PERI_BASE + 0x600000) /* SMI */
71+
#define BSC1_BASE (BCM2708_PERI_BASE + 0x804000) /* BSC1 I2C/TWI */
6972
#define USB_BASE (BCM2708_PERI_BASE + 0x980000) /* DTC_OTG USB controller */
7073
#define MCORE_BASE (BCM2708_PERI_BASE + 0x0000) /* Fake frame buffer device (actually the multicore sync block*/
7174

drivers/i2c/busses/Kconfig

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -309,6 +309,14 @@ config I2C_AU1550
309309
This driver can also be built as a module. If so, the module
310310
will be called i2c-au1550.
311311

312+
config I2C_BCM2708
313+
tristate "BCM2708 BSC"
314+
depends on MACH_BCM2708
315+
help
316+
Enabling this option will add BSC (Broadcom Serial Controller)
317+
support for the BCM2708. BSC is a Broadcom proprietary bus compatible
318+
with I2C/TWI/SMBus.
319+
312320
config I2C_BLACKFIN_TWI
313321
tristate "Blackfin TWI I2C support"
314322
depends on BLACKFIN

drivers/i2c/busses/Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ obj-$(CONFIG_I2C_POWERMAC) += i2c-powermac.o
3030
# Embedded system I2C/SMBus host controller drivers
3131
obj-$(CONFIG_I2C_AT91) += i2c-at91.o
3232
obj-$(CONFIG_I2C_AU1550) += i2c-au1550.o
33+
obj-$(CONFIG_I2C_BCM2708) += i2c-bcm2708.o
3334
obj-$(CONFIG_I2C_BLACKFIN_TWI) += i2c-bfin-twi.o
3435
obj-$(CONFIG_I2C_CPM) += i2c-cpm.o
3536
obj-$(CONFIG_I2C_DAVINCI) += i2c-davinci.o

0 commit comments

Comments
 (0)