Hi Frank,Frank Buss wrote:I've tested the GPIO one-wire implementation in the Linux kernel. This is the Linux kernel patch:
https://github.com/FrankBuss/linux-1/tree/rpi-w1
I try to enclose your code into the latest kernel to use also an audio client while reading the DS18B20. Comparing the git for the 3.2.18 and your lernel, it seems the all the mofications at the code are only few lines. Here's the diff
Code: Select all
angelo@hp630:~/Software/raspberrypi$ diff -r linuxrpi-3.2.18 linuxrpi-3.2.18+
diff -r linuxrpi-3.2.18/arch/arm/mach-bcm2708/bcm2708.c linuxrpi-3.2.18+/arch/arm/mach-bcm2708/bcm2708.c
34a35
> #include <linux/w1-gpio.h>
70a72,74
> // use GPIO 4 for the one-wire GPIO pin, if enabled
> #define W1_GPIO 4
>
390a395,410
>
> #if defined(CONFIG_W1_MASTER_GPIO) || defined(CONFIG_W1_MASTER_GPIO_MODULE)
> static struct w1_gpio_platform_data w1_gpio_pdata = {
> /* If you choose to use a pin other than PB16 it needs to be 3.3V */
> .pin = W1_GPIO,
> .is_open_drain = 0,
> };
>
> static struct platform_device w1_device = {
> .name = "w1-gpio",
> .id = -1,
> .dev.platform_data = &w1_gpio_pdata,
> };
>
> #endif
>
573a594,596
> #if defined(CONFIG_W1_MASTER_GPIO) || defined(CONFIG_W1_MASTER_GPIO_MODULE)
> platform_device_register(&w1_device);
> #endif
diff -r linuxrpi-3.2.18/drivers/i2c/busses/i2c-bcm2708.c linuxrpi-3.2.18+/drivers/i2c/busses/i2c-bcm2708.c
132,143d131
< static inline void bcm2708_bsc_fifo_drain(struct bcm2708_i2c *bi)
< {
< while ((bcm2708_rd(bi, BSC_S) & BSC_S_RXD) && (bi->pos < bi->msg->len))
< bi->msg->buf[bi->pos++] = bcm2708_rd(bi, BSC_FIFO);
< }
<
< static inline void bcm2708_bsc_fifo_fill(struct bcm2708_i2c *bi)
< {
< while ((bcm2708_rd(bi, BSC_S) & BSC_S_TXD) && (bi->pos < bi->msg->len))
< bcm2708_wr(bi, BSC_FIFO, bi->msg->buf[bi->pos++]);
< }
<
167c155
< bool handled = true;
---
> bool handled = false;
168a157
> struct i2c_msg *msg = bi->msg;
171a161
> handled = true;
183,184c173,177
< if (bi->msg->flags & I2C_M_RD)
< bcm2708_bsc_fifo_drain(bi);
---
> /* drain the RX FIFO */
> while (s & BSC_S_RXD) {
> msg->buf[bi->pos++] = bcm2708_rd(bi, BSC_FIFO);
> s = bcm2708_rd(bi, BSC_S);
> };
198c191,195
< bcm2708_bsc_fifo_fill(bi);
---
> /* fill the TX FIFO */
> do {
> bcm2708_wr(bi, BSC_FIFO, msg->buf[bi->pos++]);
> s = bcm2708_rd(bi, BSC_S);
> } while (s & BSC_S_TXD);
200c197,201
< bcm2708_bsc_fifo_drain(bi);
---
> /* drain the RX FIFO */
> do {
> msg->buf[bi->pos++] = bcm2708_rd(bi, BSC_FIFO);
> s = bcm2708_rd(bi, BSC_S);
> } while (s & BSC_S_RXD);
Solo in linuxrpi-3.2.18+: .git
1. do you have produced a more recentrly kernel with the 1wire support ?
2. If I enclose the lines form the diffi may the latest kernel works ?
Cheers and thanks for your great job !!