Skip to content

Please pull in 3.9 branch: mainly implemented: I2C sniffer/Slave in order to receive I2C events from devices (by default only I2C master is supported)+ some fixes in I2C/FIQ area #399

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion arch/arm/mach-bcm2708/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,17 @@ config BCM2708_GPIO
bool "BCM2708 gpio support"
depends on MACH_BCM2708
select ARCH_REQUIRE_GPIOLIB
default y
default n
help
Include support for the Broadcom(R) BCM2708 gpio.

config BCM2708_RPI2C
bool "I2C Sniffing support on Raspbery Pi"
depends on MACH_BCM2708
default y
help
Include support for the I2C sniffer (slave mode) on Raspbery Pi.

config BCM2708_VCMEM
bool "Videocore Memory"
depends on MACH_BCM2708
Expand Down
6 changes: 3 additions & 3 deletions arch/arm/mach-bcm2708/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@
# Makefile for the linux kernel.
#

obj-$(CONFIG_MACH_BCM2708) += clock.o bcm2708.o armctrl.o vcio.o power.o dma.o delay.o
obj-$(CONFIG_MACH_BCM2708) += clock.o bcm2708.o armctrl.o vcio.o power.o dma.o
obj-$(CONFIG_BCM2708_GPIO) += bcm2708_gpio.o
obj-$(CONFIG_BCM2708_RPI2C) += rpi2c.o
rpi2c-objs := rpi2c_fiq.o rpi2c_linux.o
obj-$(CONFIG_BCM2708_VCMEM) += vc_mem.o

obj-$(CONFIG_BCM2708_DMAER) += dmaer_master.o
dmaer_master-objs := dmaer.o vc_support.o

68 changes: 30 additions & 38 deletions arch/arm/mach-bcm2708/armctrl.c
Original file line number Diff line number Diff line change
Expand Up @@ -46,41 +46,36 @@ static unsigned int remap_irqs[(INTERRUPT_ARASANSDIO + 1) - INTERRUPT_JPEG] = {
static void armctrl_mask_irq(struct irq_data *d)
{
static const unsigned int disables[4] = {
IO_ADDRESS(ARM_IRQ_DIBL1),
IO_ADDRESS(ARM_IRQ_DIBL2),
IO_ADDRESS(ARM_IRQ_DIBL3),
ARM_IRQ_DIBL1,
ARM_IRQ_DIBL2,
ARM_IRQ_DIBL3,
0
};

if(d->irq >= FIQ_START)
{
writel(0, __io(IO_ADDRESS(ARM_IRQ_FAST)));
}
else
{
if (d->irq >= FIQ_START) {
writel(0, __io_address(ARM_IRQ_FAST));
} else {
unsigned int data = (unsigned int)irq_get_chip_data(d->irq);
writel(1 << (data & 0x1f), __io(disables[(data >> 5) & 0x3]));
writel(1 << (data & 0x1f), __io_address(disables[(data >> 5) & 0x3]));
}
}

static void armctrl_unmask_irq(struct irq_data *d)
{
static const unsigned int enables[4] = {
IO_ADDRESS(ARM_IRQ_ENBL1),
IO_ADDRESS(ARM_IRQ_ENBL2),
IO_ADDRESS(ARM_IRQ_ENBL3),
ARM_IRQ_ENBL1,
ARM_IRQ_ENBL2,
ARM_IRQ_ENBL3,
0
};

if(d->irq >= FIQ_START)
{
unsigned int data = (unsigned int)irq_get_chip_data(d->irq) - FIQ_START;
writel(0x80 | data, __io(IO_ADDRESS(ARM_IRQ_FAST)));
}
else
{
unsigned int data = (unsigned int)irq_get_chip_data(d->irq);
writel(1 << (data & 0x1f), __io(enables[(data >> 5) & 0x3]));
if (d->irq >= FIQ_START) {
unsigned int data =
(unsigned int)irq_get_chip_data(d->irq) - FIQ_START;
writel(0x80 | data, __io_address(ARM_IRQ_FAST));
} else {
unsigned int data = (unsigned int)irq_get_chip_data(d->irq);
writel(1 << (data & 0x1f), __io_address(enables[(data >> 5) & 0x3]));
}
}

Expand All @@ -100,17 +95,16 @@ static void armctrl_unmask_irq(struct irq_data *d)
* @soft_int: Save for VIC_INT_SOFT.
* @protect: Save for VIC_PROTECT.
*/
struct armctrl_info {
void __iomem *base;
int irq;
u32 resume_sources;
u32 resume_irqs;
u32 int_select;
u32 int_enable;
u32 soft_int;
u32 protect;
} armctrl;

struct armctrl_info {
void __iomem *base;
int irq;
u32 resume_sources;
u32 resume_irqs;
u32 int_select;
u32 int_enable;
u32 soft_int;
u32 protect;
} armctrl;

static int armctrl_suspend(void)
{
Expand All @@ -122,7 +116,6 @@ static void armctrl_resume(void)
return;
}


/**
* armctrl_pm_register - Register a VIC for later power management control
* @base: The base address of the VIC.
Expand Down Expand Up @@ -159,19 +152,19 @@ static int armctrl_set_wake(struct irq_data *d, unsigned int on)
}

#else
static inline void armctrl_pm_register(void __iomem *base, unsigned int irq,
static inline void armctrl_pm_register(void __iomem * base, unsigned int irq,
u32 arg1)
{
}

#define armctrl_suspend NULL
#define armctrl_resume NULL
#define armctrl_set_wake NULL
#endif /* CONFIG_PM */


static struct syscore_ops armctrl_syscore_ops = {
.suspend = armctrl_suspend,
.resume = armctrl_resume,
.resume = armctrl_resume,
};

/**
Expand All @@ -189,7 +182,6 @@ static int __init armctrl_syscore_init(void)

late_initcall(armctrl_syscore_init);


static struct irq_chip armctrl_chip = {
.name = "ARMCTRL",
.irq_ack = armctrl_mask_irq,
Expand Down
107 changes: 18 additions & 89 deletions arch/arm/mach-bcm2708/bcm2708.c
Original file line number Diff line number Diff line change
Expand Up @@ -108,13 +108,6 @@ static struct map_desc bcm2708_io_desc[] __initdata = {
.pfn = __phys_to_pfn(UART1_BASE),
.length = SZ_4K,
.type = MT_DEVICE},
#ifdef CONFIG_MMC_BCM2708 /* broadcom legacy SD */
{
.virtual = IO_ADDRESS(MMCI0_BASE),
.pfn = __phys_to_pfn(MMCI0_BASE),
.length = SZ_4K,
.type = MT_DEVICE},
#endif
{
.virtual = IO_ADDRESS(DMA_BASE),
.pfn = __phys_to_pfn(DMA_BASE),
Expand Down Expand Up @@ -161,14 +154,10 @@ static inline uint32_t timer_read(void)
return readl(__io_address(ST_BASE + 0x04));
}

#ifdef ARCH_HAS_READ_CURRENT_TIMER
int read_current_timer(unsigned long *timer_val)
static unsigned long bcm2708_read_current_timer(void)
{
*timer_val = timer_read();
return 0;
return timer_read();
}
EXPORT_SYMBOL(read_current_timer);
#endif

static u32 notrace bcm2708_read_sched_clock(void)
{
Expand Down Expand Up @@ -235,12 +224,6 @@ static struct clk_lookup lookups[] = {
{ /* USB */
.dev_id = "bcm2708_usb",
.clk = &osc_clk,
#ifdef CONFIG_MMC_BCM2708
},
{ /* MCI */
.dev_id = "bcm2708_mci.0",
.clk = &sdhost_clk,
#endif
}, { /* SPI */
.dev_id = "bcm2708_spi.0",
.clk = &sdhost_clk,
Expand Down Expand Up @@ -277,31 +260,6 @@ static struct platform_device bcm2708_dmaman_device = {
.num_resources = ARRAY_SIZE(bcm2708_dmaman_resources),
};

#ifdef CONFIG_MMC_BCM2708
static struct resource bcm2708_mci_resources[] = {
{
.start = MMCI0_BASE,
.end = MMCI0_BASE + SZ_4K - 1,
.flags = IORESOURCE_MEM,
},
{
.start = IRQ_SDIO,
.end = IRQ_SDIO,
.flags = IORESOURCE_IRQ,
}
};

static struct platform_device bcm2708_mci_device = {
.name = "bcm2708_mci",
.id = 0, /* first bcm2708_mci */
.resource = bcm2708_mci_resources,
.num_resources = ARRAY_SIZE(bcm2708_mci_resources),
.dev = {
.coherent_dma_mask = DMA_BIT_MASK(DMA_MASK_BITS_COMMON),
},
};
#endif /* CONFIG_MMC_BCM2708 */

#if defined(CONFIG_W1_MASTER_GPIO) || defined(CONFIG_W1_MASTER_GPIO_MODULE)
static struct w1_gpio_platform_data w1_gpio_pdata = {
.pin = W1_GPIO,
Expand Down Expand Up @@ -516,6 +474,7 @@ struct platform_device bcm2708_powerman_device = {
.coherent_dma_mask = 0xffffffffUL},
};


static struct platform_device bcm2708_alsa_devices[] = {
[0] = {
.name = "bcm2835_AUD0",
Expand Down Expand Up @@ -579,6 +538,7 @@ static struct resource bcm2708_spi_resources[] = {
}
};


static struct platform_device bcm2708_spi_device = {
.name = "bcm2708_spi",
.id = 0,
Expand All @@ -588,6 +548,7 @@ static struct platform_device bcm2708_spi_device = {

#ifdef CONFIG_BCM2708_SPIDEV
static struct spi_board_info bcm2708_spi_devices[] = {
#ifdef CONFIG_SPI_SPIDEV
{
.modalias = "spidev",
.max_speed_hz = 500000,
Expand All @@ -601,6 +562,7 @@ static struct spi_board_info bcm2708_spi_devices[] = {
.chip_select = 1,
.mode = SPI_MODE_0,
}
#endif
};
#endif

Expand Down Expand Up @@ -700,13 +662,13 @@ static void bcm2708_restart(char mode, const char *cmd)
writel(pm_rsts, __io_address(PM_RSTS));

/* Setup watchdog for reset */
pm_rstc = readl(IO_ADDRESS(PM_RSTC));
pm_rstc = readl(__io_address(PM_RSTC));

pm_wdog = PM_PASSWORD | (timeout & PM_WDOG_TIME_SET); // watchdog timer = timer clock / 16; need password (31:16) + value (11:0)
pm_rstc = PM_PASSWORD | (pm_rstc & PM_RSTC_WRCFG_CLR) | PM_RSTC_WRCFG_FULL_RESET;

writel(pm_wdog, IO_ADDRESS(PM_WDOG));
writel(pm_rstc, IO_ADDRESS(PM_RSTC));
writel(pm_wdog, __io_address(PM_WDOG));
writel(pm_rstc, __io_address(PM_RSTC));
}

/* We can't really power off, but if we do the normal reset scheme, and indicate to bootcode.bin not to reboot, then most of the chip will be powered off */
Expand Down Expand Up @@ -753,9 +715,6 @@ void __init bcm2708_init(void)
platform_device_register(&w1_device);
#endif
bcm_register_device(&bcm2708_systemtimer_device);
#ifdef CONFIG_MMC_BCM2708
bcm_register_device(&bcm2708_mci_device);
#endif
bcm_register_device(&bcm2708_fb_device);
if (!fiq_fix_enable)
{
Expand Down Expand Up @@ -793,8 +752,6 @@ void __init bcm2708_init(void)
#endif
}

#define TIMER_PERIOD DIV_ROUND_CLOSEST(STC_FREQ_HZ, HZ)

static void timer_set_mode(enum clock_event_mode mode,
struct clock_event_device *clk)
{
Expand Down Expand Up @@ -856,6 +813,12 @@ static struct irqaction bcm2708_timer_irq = {
/*
* Set up timer interrupt, and return the current time in seconds.
*/

static struct delay_timer bcm2708_delay_timer = {
.read_current_timer = bcm2708_read_current_timer,
.freq = STC_FREQ_HZ,
};

static void __init bcm2708_timer_init(void)
{
/* init high res timer */
Expand All @@ -881,11 +844,9 @@ static void __init bcm2708_timer_init(void)

timer0_clockevent.cpumask = cpumask_of(0);
clockevents_register_device(&timer0_clockevent);
}

struct sys_timer bcm2708_timer = {
.init = bcm2708_timer_init,
};
register_current_timer_delay(&bcm2708_delay_timer);
}

#if defined(CONFIG_LEDS_GPIO) || defined(CONFIG_LEDS_GPIO_MODULE)
#include <linux/leds.h>
Expand Down Expand Up @@ -922,38 +883,6 @@ static inline void bcm2708_init_led(void)
}
#endif

/* The assembly versions in delay.S don't account for core freq changing in cpufreq driver */
/* Use 1MHz system timer for busy waiting */
static void bcm2708_udelay(unsigned long usecs)
{
unsigned long start = timer_read();
unsigned long now;
do {
now = timer_read();
} while ((long)(now - start) <= usecs);
}


static void bcm2708_const_udelay(unsigned long scaled_usecs)
{
/* want /107374, this is about 3% bigger. We know usecs is less than 2000, so shouldn't overflow */
const unsigned long usecs = scaled_usecs * 10 >> 20;
unsigned long start = timer_read();
unsigned long now;
do {
now = timer_read();
} while ((long)(now - start) <= usecs);
}

extern void bcm2708_delay(unsigned long cycles);

struct arm_delay_ops arm_delay_ops = {
.delay = bcm2708_delay,
.const_udelay = bcm2708_const_udelay,
.udelay = bcm2708_udelay,
};


void __init bcm2708_init_early(void)
{
/*
Expand All @@ -975,7 +904,7 @@ MACHINE_START(BCM2708, "BCM2708")
/* Maintainer: Broadcom Europe Ltd. */
.map_io = bcm2708_map_io,
.init_irq = bcm2708_init_irq,
.timer =&bcm2708_timer,
.init_time = bcm2708_timer_init,
.init_machine = bcm2708_init,
.init_early = bcm2708_init_early,
.reserve = board_reserve,
Expand Down
Loading