Re: [PATCH v3] i2c: add Renesas R-Car I2C driver
On Thu, Sep 27, 2012 at 11:44:25PM -0700, Kuninori Morimoto wrote: R-Car I2C is similar with SH7760 I2C. But the SH7760 I2C driver had many workaround operations, since H/W had bugs. Thus, it was pointless to keep compatible between SH7760 and R-Car I2C drivers. This patch creates new Renesas R-Car I2C driver. Hi, I am seeing the current section miss-matches, which appear to relate to this patch, in linux/master (v3.6-rc3+). make CONFIG_DEBUG_SECTION_MISMATCH=y ... WARNING: vmlinux.o(.data+0x11798): Section mismatch in reference from the variable rcar_i2c_drv to the function .devinit.text:rcar_i2c_probe() The variable rcar_i2c_drv references the function __devinit rcar_i2c_probe() If the reference is valid then annotate the variable with __init* or __refdata (see linux/init.h) or name the variable: *driver, *_template, *_timer, *_sht, *_ops, *_probe, *_probe_one, *_console WARNING: vmlinux.o(.data+0x1179c): Section mismatch in reference from the variable rcar_i2c_drv to the function .devexit.text:rcar_i2c_remove() The variable rcar_i2c_drv references the function __devexit rcar_i2c_remove() If the reference is valid then annotate the variable with __exit* (see linux/init.h) or name the variable: *driver, *_template, *_timer, *_sht, *_ops, *_probe, *_probe_one, *_console -- To unsubscribe from this list: send the line unsubscribe linux-i2c in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH v3] i2c: add Renesas R-Car I2C driver
On Thu, Sep 27, 2012 at 11:44:25PM -0700, Kuninori Morimoto wrote: R-Car I2C is similar with SH7760 I2C. But the SH7760 I2C driver had many workaround operations, since H/W had bugs. Thus, it was pointless to keep compatible between SH7760 and R-Car I2C drivers. This patch creates new Renesas R-Car I2C driver. Signed-off-by: Kuninori Morimoto kuninori.morimoto...@renesas.com Only minor issues which might be fixed later. Applied to -next. +static void rcar_i2c_write(struct rcar_i2c_priv *priv, int reg, u32 val) +{ + writel(val, priv-io + reg); +} + +static u32 rcar_i2c_read(struct rcar_i2c_priv *priv, int reg) +{ + return readl(priv-io + reg); +} Not sure if those needed encapsulation. ... +static int rcar_i2c_irq_send(struct rcar_i2c_priv *priv, u32 msr) +{ + struct i2c_msg *msg = priv-msg; + + /* + * FIXME + * sometimes, unknown interrupt happened. + * Do nothing + */ + if (!(msr MDE)) + return 0; Uh, is this a known hardware flaw? ... +static int __devinit rcar_i2c_probe(struct platform_device *pdev) +{ + struct i2c_rcar_platform_data *pdata = pdev-dev.platform_data; + struct rcar_i2c_priv *priv; + struct i2c_adapter *adap; + struct resource *res; + struct device *dev = pdev-dev; + u32 bus_speed; + int ret; + + res = platform_get_resource(pdev, IORESOURCE_MEM, 0); + if (!res) { + dev_err(dev, no mmio resources\n); + return -ENODEV; + } + + priv = devm_kzalloc(dev, sizeof(struct rcar_i2c_priv), GFP_KERNEL); + if (!priv) { + dev_err(dev, no mem for private data\n); + return -ENOMEM; + } + + bus_speed = 10; /* default 100 kHz */ + if (pdata pdata-bus_speed) + bus_speed = pdata-bus_speed; + ret = rcar_i2c_clock_calculate(priv, bus_speed, dev); + if (ret 0) + return ret; + + priv-io = devm_ioremap(dev, res-start, resource_size(res)); devm_request_mem_region is missing. Or use the helper devm_request_and_ioremap. + if (!priv-io) { + dev_err(dev, cannot ioremap\n); + return -ENODEV; + } + + priv-irq = platform_get_irq(pdev, 0); + init_waitqueue_head(priv-wait); + spin_lock_init(priv-lock); + + adap= priv-adap; + adap-nr= pdev-id; + adap-algo = rcar_i2c_algo; + adap-class = I2C_CLASS_HWMON | I2C_CLASS_SPD; + adap-retries = 3; Do you really need the class? Rest looks good. -- Pengutronix e.K. | Wolfram Sang| Industrial Linux Solutions | http://www.pengutronix.de/ | signature.asc Description: Digital signature
[PATCH v3] i2c: add Renesas R-Car I2C driver
R-Car I2C is similar with SH7760 I2C. But the SH7760 I2C driver had many workaround operations, since H/W had bugs. Thus, it was pointless to keep compatible between SH7760 and R-Car I2C drivers. This patch creates new Renesas R-Car I2C driver. Signed-off-by: Kuninori Morimoto kuninori.morimoto...@renesas.com --- v2 - v3 - used simple comment on rcar_i2c_irq_recv() - used LOOP_TIMEOUT - used pm_runtime_put() - used devm_request_irq() drivers/i2c/busses/Kconfig| 10 + drivers/i2c/busses/Makefile |1 + drivers/i2c/busses/i2c-rcar.c | 709 + include/linux/i2c/i2c-rcar.h | 10 + 4 files changed, 730 insertions(+) create mode 100644 drivers/i2c/busses/i2c-rcar.c create mode 100644 include/linux/i2c/i2c-rcar.h diff --git a/drivers/i2c/busses/Kconfig b/drivers/i2c/busses/Kconfig index b4aaa1b..51baa08 100644 --- a/drivers/i2c/busses/Kconfig +++ b/drivers/i2c/busses/Kconfig @@ -709,6 +709,16 @@ config I2C_XLR This driver can also be built as a module. If so, the module will be called i2c-xlr. +config I2C_RCAR + tristate Renesas R-Car I2C Controller + depends on ARCH_SHMOBILE I2C + help + If you say yes to this option, support will be included for the + R-Car I2C controller. + + This driver can also be built as a module. If so, the module + will be called i2c-rcar. + comment External I2C/SMBus adapter drivers config I2C_DIOLAN_U2C diff --git a/drivers/i2c/busses/Makefile b/drivers/i2c/busses/Makefile index ce3c2be..e98ff51 100644 --- a/drivers/i2c/busses/Makefile +++ b/drivers/i2c/busses/Makefile @@ -70,6 +70,7 @@ obj-$(CONFIG_I2C_VERSATILE) += i2c-versatile.o obj-$(CONFIG_I2C_OCTEON) += i2c-octeon.o obj-$(CONFIG_I2C_XILINX) += i2c-xiic.o obj-$(CONFIG_I2C_XLR) += i2c-xlr.o +obj-$(CONFIG_I2C_RCAR) += i2c-rcar.o # External I2C/SMBus adapter drivers obj-$(CONFIG_I2C_DIOLAN_U2C) += i2c-diolan-u2c.o diff --git a/drivers/i2c/busses/i2c-rcar.c b/drivers/i2c/busses/i2c-rcar.c new file mode 100644 index 000..f9399d1 --- /dev/null +++ b/drivers/i2c/busses/i2c-rcar.c @@ -0,0 +1,709 @@ +/* + * drivers/i2c/busses/i2c-rcar.c + * + * Copyright (C) 2012 Renesas Solutions Corp. + * Kuninori Morimoto kuninori.morimoto...@renesas.com + * + * This file is based on the drivers/i2c/busses/i2c-sh7760.c + * (c) 2005-2008 MSC Vertriebsges.m.b.H, Manuel Lauss m...@msc-ge.com + * + * This file used out-of-tree driver i2c-rcar.c + * Copyright (C) 2011-2012 Renesas Electronics Corporation + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ +#include linux/clk.h +#include linux/delay.h +#include linux/err.h +#include linux/init.h +#include linux/interrupt.h +#include linux/io.h +#include linux/i2c.h +#include linux/i2c/i2c-rcar.h +#include linux/kernel.h +#include linux/module.h +#include linux/platform_device.h +#include linux/pm_runtime.h +#include linux/slab.h +#include linux/spinlock.h + +/* register offsets */ +#define ICSCR 0x00/* slave ctrl */ +#define ICMCR 0x04/* master ctrl */ +#define ICSSR 0x08/* slave status */ +#define ICMSR 0x0C/* master status */ +#define ICSIER 0x10/* slave irq enable */ +#define ICMIER 0x14/* master irq enable */ +#define ICCCR 0x18/* clock dividers */ +#define ICSAR 0x1C/* slave address */ +#define ICMAR 0x20/* master address */ +#define ICRXTX 0x24/* data port */ + +/* ICMCR */ +#define MDBS (1 7)/* non-fifo mode switch */ +#define FSCL (1 6)/* override SCL pin */ +#define FSDA (1 5)/* override SDA pin */ +#define OBPC (1 4)/* override pins */ +#define MIE(1 3)/* master if enable */ +#define TSBE (1 2) +#define FSB(1 1)/* force stop bit */ +#define ESG(1 0)/* en startbit gen */ + +/* ICMSR */ +#define MNR(1 6)/* nack received */ +#define MAL(1 5)/* arbitration lost */ +#define MST(1 4)/* sent a stop */ +#define MDE(1 3) +#define MDT(1 2) +#define MDR(1 1) +#define MAT(1 0)/* slave addr xfer done */ + +/* ICMIE */ +#define MNRE (1 6)/* nack irq en */ +#define MALE (1 5)/* arblos irq en */ +#define MSTE (1 4)/* stop irq en */ +#define MDEE (1 3) +#define MDTE (1