BUG in kernel 3.0.4 for mach-at91 - atmel_tcb.1 is not detected intc_probe, fix provided

From: Wojciech ZaboÅotny
Date: Wed Oct 05 2011 - 16:47:36 EST


Hi,

I've ported my driver, which uses the atmel_tcb.1 block as PWM source (in AT91SAM9260).
The code worked perfectly in kernel.2.6.29.3, but now during the initialization I get the following error:

atmel_tcb: probe of atmel_tcb.1 failed with error -22

I have added printk invocations in the tc_probe routine, and I've found, that the problem occures, when tc_probe attempts to get clock for atmel_tcb.1 (In this line: http://lxr.linux.no/linux+v3.0.4/driver ... lib.c#L125 <http://lxr.linux.no/linux+v3.0.4/drivers/misc/atmel_tclib.c#L125> )

The atmel_tcb.0 is correctly used as clocksource:
tcb_clksrc: tc0 at 12.916 MHz

I have found, that the tc_probe always looks for "t0_clk", "t1_clk" and "t2_clk", and
function at91_add_device_tc performs the following operations:

( http://lxr.linux.no/linux+*/arch/arm/ma ... ces.c#L599 <http://lxr.linux.no/linux+*/arch/arm/mach-at91/at91sam9260_devices.c#L599> )
static void __init at91_add_device_tc(void)
{
/* this chip has a separate clock and irq for each TC channel */
at91_clock_associate("tc0_clk", &at91sam9260_tcb0_device.dev, "t0_clk");
at91_clock_associate("tc1_clk", &at91sam9260_tcb0_device.dev, "t1_clk");
at91_clock_associate("tc2_clk", &at91sam9260_tcb0_device.dev, "t2_clk");
platform_device_register(&at91sam9260_tcb0_device);
at91_clock_associate("tc3_clk", &at91sam9260_tcb1_device.dev, "t0_clk");
at91_clock_associate("tc4_clk", &at91sam9260_tcb1_device.dev, "t1_clk");
at91_clock_associate("tc5_clk", &at91sam9260_tcb1_device.dev, "t2_clk");
platform_device_register(&at91sam9260_tcb1_device);
}

While the code mapping the clock names in 3.0.4 has the following form:

(see: http://lxr.linux.no/linux+*/arch/arm/ma ... 260.c#L234 <http://lxr.linux.no/linux+*/arch/arm/mach-at91/at91sam9260.c#L234> )
static struct clk_lookup periph_clocks_lookups[] = {
CLKDEV_CON_DEV_ID("spi_clk", "atmel_spi.0", &spi0_clk),
CLKDEV_CON_DEV_ID("spi_clk", "atmel_spi.1", &spi1_clk),
CLKDEV_CON_DEV_ID("t0_clk", "atmel_tcb.0", &tc0_clk),
CLKDEV_CON_DEV_ID("t1_clk", "atmel_tcb.0", &tc1_clk),
CLKDEV_CON_DEV_ID("t2_clk", "atmel_tcb.0", &tc2_clk),
CLKDEV_CON_DEV_ID("t3_clk", "atmel_tcb.1", &tc3_clk),
CLKDEV_CON_DEV_ID("t4_clk", "atmel_tcb.1", &tc4_clk),
CLKDEV_CON_DEV_ID("t5_clk", "atmel_tcb.1", &tc5_clk),
CLKDEV_CON_DEV_ID("pclk", "ssc.0", &ssc_clk),
};

To assure correct detection and operation of atmel_tcb.1, I had to change the above
code as shown below:

static struct clk_lookup periph_clocks_lookups[] = {
CLKDEV_CON_DEV_ID("spi_clk", "atmel_spi.0", &spi0_clk),
CLKDEV_CON_DEV_ID("spi_clk", "atmel_spi.1", &spi1_clk),
CLKDEV_CON_DEV_ID("t0_clk", "atmel_tcb.0", &tc0_clk),
CLKDEV_CON_DEV_ID("t1_clk", "atmel_tcb.0", &tc1_clk),
CLKDEV_CON_DEV_ID("t2_clk", "atmel_tcb.0", &tc2_clk),
CLKDEV_CON_DEV_ID("t0_clk", "atmel_tcb.1", &tc3_clk),
CLKDEV_CON_DEV_ID("t1_clk", "atmel_tcb.1", &tc4_clk),
CLKDEV_CON_DEV_ID("t2_clk", "atmel_tcb.1", &tc5_clk),
CLKDEV_CON_DEV_ID("pclk", "ssc.0", &ssc_clk),
};

--
Regards,
Wojciech M. Zabolotny

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/