From 5e2f55c6aaf4865081c46bf53664c8b5da8dc49e Mon Sep 17 00:00:00 2001 From: Wolfram Sang Date: Wed, 22 Dec 2010 16:42:55 +0100 Subject: [PATCH 1/5] powerpc/mpc5200: include fs.h in mpc52xx_gpt.c Fix build errors like these (from a randconfig and my defconfig for a custom board): src/arch/powerpc/platforms/52xx/mpc52xx_gpt.c:549: error: dereferencing pointer to incomplete type: 1 errors in 1 logs src/arch/powerpc/platforms/52xx/mpc52xx_gpt.c:636: error: implicit declaration of function 'nonseekable_open': 1 errors in 1 logs src/arch/powerpc/platforms/52xx/mpc52xx_gpt.c:657: error: variable 'mpc52xx_wdt_fops' has initializer but incomplete type: 1 errors in 1 logs src/arch/powerpc/platforms/52xx/mpc52xx_gpt.c:658: error: excess elements in struct initializer: 1 errors in 1 logs src/arch/powerpc/platforms/52xx/mpc52xx_gpt.c:658: error: unknown field 'owner' specified in initializer: 1 errors in 1 logs ... Reported-by: Geert Uytterhoeven Signed-off-by: Wolfram Sang Cc: Grant Likely Cc: Benjamin Herrenschmidt Cc: Andrew Morton Signed-off-by: Grant Likely --- arch/powerpc/platforms/52xx/mpc52xx_gpt.c | 1 + 1 file changed, 1 insertion(+) diff --git a/arch/powerpc/platforms/52xx/mpc52xx_gpt.c b/arch/powerpc/platforms/52xx/mpc52xx_gpt.c index fea833e18ad5..e0d703c7fdf7 100644 --- a/arch/powerpc/platforms/52xx/mpc52xx_gpt.c +++ b/arch/powerpc/platforms/52xx/mpc52xx_gpt.c @@ -63,6 +63,7 @@ #include #include #include +#include #include #include #include From 020862648445d7c1b12ea213c152f27def703f3b Mon Sep 17 00:00:00 2001 From: David Daney Date: Tue, 16 Nov 2010 14:42:14 -0800 Subject: [PATCH 2/5] of/i2c: Fix request module by alias If we are registering an i2c device that has a device tree node like this real-world example: rtc@68 { compatible = "dallas,ds1337"; reg = <0x68>; }; of_i2c_register_devices() will try to load a module called ds1337.ko. There is no such module, so it will fail. If we look in modules.alias we will find entries like these: . . . alias i2c:ds1339 rtc_ds1307 alias i2c:ds1338 rtc_ds1307 alias i2c:ds1337 rtc_ds1307 alias i2c:ds1307 rtc_ds1307 alias i2c:ds1374 rtc_ds1374 . . . The module we want is really called rtc_ds1307.ko. If we request a module called "i2c:ds1337", the userspace module loader will do the right thing (unless it is busybox) and load rtc_ds1307.ko. So we add the I2C_MODULE_PREFIX to the request_module() string. Signed-off-by: David Daney Signed-off-by: Grant Likely --- drivers/of/of_i2c.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/of/of_i2c.c b/drivers/of/of_i2c.c index c85d3c7421fc..f37fbeb66a44 100644 --- a/drivers/of/of_i2c.c +++ b/drivers/of/of_i2c.c @@ -61,7 +61,7 @@ void of_i2c_register_devices(struct i2c_adapter *adap) info.of_node = of_node_get(node); info.archdata = &dev_ad; - request_module("%s", info.type); + request_module("%s%s", I2C_MODULE_PREFIX, info.type); result = i2c_new_device(adap, &info); if (result == NULL) { From e6289d63a6f39237a027dcee46366ba158cb8406 Mon Sep 17 00:00:00 2001 From: Mingkai Hu Date: Tue, 21 Dec 2010 09:26:07 +0800 Subject: [PATCH 3/5] spi/fsl_espi: change the read behaviour of the SPIRF The user must read N bytes of SPIRF (1 <= N <= 4) that do not exceed the amount of data in the receive FIFO, so read the SPIRF byte by byte when the data in receive FIFO is less than 4 bytes. On Simics, when read N bytes that exceed the amount of data in receive FIFO, we can't read the data out, that is we can't clear the rx FIFO, then the CPU will loop on the espi rx interrupt. Signed-off-by: Mingkai Hu Signed-off-by: Grant Likely --- drivers/spi/spi_fsl_espi.c | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/drivers/spi/spi_fsl_espi.c b/drivers/spi/spi_fsl_espi.c index e3b4f6451966..ae789262c981 100644 --- a/drivers/spi/spi_fsl_espi.c +++ b/drivers/spi/spi_fsl_espi.c @@ -507,16 +507,29 @@ void fsl_espi_cpu_irq(struct mpc8xxx_spi *mspi, u32 events) /* We need handle RX first */ if (events & SPIE_NE) { - u32 rx_data; + u32 rx_data, tmp; + u8 rx_data_8; /* Spin until RX is done */ while (SPIE_RXCNT(events) < min(4, mspi->len)) { cpu_relax(); events = mpc8xxx_spi_read_reg(®_base->event); } - mspi->len -= 4; - rx_data = mpc8xxx_spi_read_reg(®_base->receive); + if (mspi->len >= 4) { + rx_data = mpc8xxx_spi_read_reg(®_base->receive); + } else { + tmp = mspi->len; + rx_data = 0; + while (tmp--) { + rx_data_8 = in_8((u8 *)®_base->receive); + rx_data |= (rx_data_8 << (tmp * 8)); + } + + rx_data <<= (4 - mspi->len) * 8; + } + + mspi->len -= 4; if (mspi->rx) mspi->get_rx(rx_data, mspi); From 0dd2c96f19b0cffaeb437e50fa5da195920c6e78 Mon Sep 17 00:00:00 2001 From: Mingkai Hu Date: Tue, 21 Dec 2010 09:27:02 +0800 Subject: [PATCH 4/5] spi/fsl_espi: fix wrong setting of the address in the command buffer Or else we can't operate on the right address when the trans length is greater than 65535. Signed-off-by: Mingkai Hu Signed-off-by: Grant Likely --- drivers/spi/spi_fsl_espi.c | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/drivers/spi/spi_fsl_espi.c b/drivers/spi/spi_fsl_espi.c index ae789262c981..a99e2333b949 100644 --- a/drivers/spi/spi_fsl_espi.c +++ b/drivers/spi/spi_fsl_espi.c @@ -258,18 +258,18 @@ static int fsl_espi_bufs(struct spi_device *spi, struct spi_transfer *t) return mpc8xxx_spi->count; } -static void fsl_espi_addr2cmd(unsigned int addr, u8 *cmd) +static inline void fsl_espi_addr2cmd(unsigned int addr, u8 *cmd) { - if (cmd[1] && cmd[2] && cmd[3]) { + if (cmd) { cmd[1] = (u8)(addr >> 16); cmd[2] = (u8)(addr >> 8); cmd[3] = (u8)(addr >> 0); } } -static unsigned int fsl_espi_cmd2addr(u8 *cmd) +static inline unsigned int fsl_espi_cmd2addr(u8 *cmd) { - if (cmd[1] && cmd[2] && cmd[3]) + if (cmd) return cmd[1] << 16 | cmd[2] << 8 | cmd[3] << 0; return 0; @@ -395,9 +395,11 @@ static void fsl_espi_rw_trans(struct spi_message *m, } } - addr = fsl_espi_cmd2addr(local_buf); - addr += pos; - fsl_espi_addr2cmd(addr, local_buf); + if (pos > 0) { + addr = fsl_espi_cmd2addr(local_buf); + addr += pos; + fsl_espi_addr2cmd(addr, local_buf); + } espi_trans->n_tx = n_tx; espi_trans->n_rx = trans_len; From 4bdac7da5237170b1392f39ebee99d235043fad8 Mon Sep 17 00:00:00 2001 From: Wolfram Sang Date: Fri, 17 Dec 2010 15:33:58 +0100 Subject: [PATCH 5/5] spi/mpc52xx-spi: fix annotation for remove()-pointer Signed-off-by: Wolfram Sang Signed-off-by: Grant Likely --- drivers/spi/mpc52xx_spi.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/spi/mpc52xx_spi.c b/drivers/spi/mpc52xx_spi.c index ec9f0b1bf864..84439f655601 100644 --- a/drivers/spi/mpc52xx_spi.c +++ b/drivers/spi/mpc52xx_spi.c @@ -563,7 +563,7 @@ static struct of_platform_driver mpc52xx_spi_of_driver = { .of_match_table = mpc52xx_spi_match, }, .probe = mpc52xx_spi_probe, - .remove = __exit_p(mpc52xx_spi_remove), + .remove = __devexit_p(mpc52xx_spi_remove), }; static int __init mpc52xx_spi_init(void)