Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/arch/arm/imx Rewritten to take advantage of motoi2c code.
details: https://anonhg.NetBSD.org/src/rev/e8cc190ad659
branches: trunk
changeset: 807046:e8cc190ad659
user: hkenken <hkenken%NetBSD.org@localhost>
date: Fri Mar 27 05:31:23 2015 +0000
description:
Rewritten to take advantage of motoi2c code.
diffstat:
sys/arch/arm/imx/files.imx51 | 4 +-
sys/arch/arm/imx/files.imx6 | 4 +-
sys/arch/arm/imx/imx51_i2c.c | 34 +++--
sys/arch/arm/imx/imx51reg.h | 4 +-
sys/arch/arm/imx/imx6_i2c.c | 27 +--
sys/arch/arm/imx/imx6_reg.h | 5 +-
sys/arch/arm/imx/imxi2c.c | 249 ++++++------------------------------------
sys/arch/arm/imx/imxi2creg.h | 53 ---------
sys/arch/arm/imx/imxi2cvar.h | 11 +-
9 files changed, 80 insertions(+), 311 deletions(-)
diffs (truncated from 607 to 300 lines):
diff -r 3b3c8d1774fb -r e8cc190ad659 sys/arch/arm/imx/files.imx51
--- a/sys/arch/arm/imx/files.imx51 Fri Mar 27 01:51:34 2015 +0000
+++ b/sys/arch/arm/imx/files.imx51 Fri Mar 27 05:31:23 2015 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: files.imx51,v 1.11 2014/07/25 07:49:56 hkenken Exp $
+# $NetBSD: files.imx51,v 1.12 2015/03/27 05:31:23 hkenken Exp $
#
# Configuration info for the Freescale i.MX5x
#
@@ -103,7 +103,7 @@
file arch/arm/imx/imx51_esdhc.c sdhc_axi
# iic Controler
-device imxi2c: i2cbus
+device imxi2c: motoi2c, i2cbus, i2cexec
attach imxi2c at axi
file arch/arm/imx/imxi2c.c imxi2c
file arch/arm/imx/imx51_i2c.c imxi2c
diff -r 3b3c8d1774fb -r e8cc190ad659 sys/arch/arm/imx/files.imx6
--- a/sys/arch/arm/imx/files.imx6 Fri Mar 27 01:51:34 2015 +0000
+++ b/sys/arch/arm/imx/files.imx6 Fri Mar 27 05:31:23 2015 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: files.imx6,v 1.4 2014/10/07 09:36:09 ryo Exp $
+# $NetBSD: files.imx6,v 1.5 2015/03/27 05:31:23 hkenken Exp $
#
# Configuration info for the Freescale i.MX6
#
@@ -62,7 +62,7 @@
file arch/arm/imx/imx6_iomux.c imxiomux
# iMX iic Controler
-device imxi2c: i2cbus
+device imxi2c: motoi2c, i2cbus, i2cexec
attach imxi2c at axi
file arch/arm/imx/imxi2c.c imxi2c
file arch/arm/imx/imx6_i2c.c imxi2c
diff -r 3b3c8d1774fb -r e8cc190ad659 sys/arch/arm/imx/imx51_i2c.c
--- a/sys/arch/arm/imx/imx51_i2c.c Fri Mar 27 01:51:34 2015 +0000
+++ b/sys/arch/arm/imx/imx51_i2c.c Fri Mar 27 05:31:23 2015 +0000
@@ -1,7 +1,7 @@
-/* $NetBSD: imx51_i2c.c,v 1.1 2014/07/25 07:07:47 hkenken Exp $ */
+/* $NetBSD: imx51_i2c.c,v 1.2 2015/03/27 05:31:23 hkenken Exp $ */
/*
- * Copyright (c) 2012 Genetec Corporation. All rights reserved.
+ * Copyright (c) 2012, 2015 Genetec Corporation. All rights reserved.
* Written by Hashimoto Kenichi for Genetec Corporation.
*
* Redistribution and use in source and binary forms, with or without
@@ -27,24 +27,32 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: imx51_i2c.c,v 1.1 2014/07/25 07:07:47 hkenken Exp $");
+__KERNEL_RCSID(0, "$NetBSD: imx51_i2c.c,v 1.2 2015/03/27 05:31:23 hkenken Exp $");
+
+#include "opt_imx.h"
#include <sys/param.h>
#include <sys/bus.h>
#include <sys/device.h>
-#include "opt_imx.h"
-
-#include <arm/imx/imxi2cvar.h>
#include <arm/imx/imx51reg.h>
#include <arm/imx/imx51var.h>
#include <arm/imx/imx51_ccmvar.h>
+#include <arm/imx/imxi2cvar.h>
int
imxi2c_match(device_t parent, cfdata_t cf, void *aux)
{
- if (strcmp(cf->cf_name, "imxi2c") == 0)
+ struct axi_attach_args *aa = aux;
+
+ switch (aa->aa_addr) {
+ case I2C1_BASE:
+ case I2C2_BASE:
+#ifdef IMX50
+ case I2C3_BASE:
+#endif
return 1;
+ }
return 0;
}
@@ -53,15 +61,11 @@
imxi2c_attach(device_t parent, device_t self, void *aux)
{
struct axi_attach_args * aa = aux;
- struct imxi2c_softc *sc = device_private(self);
- struct i2cbus_attach_args iba;
+ if (aa->aa_size <= 0)
+ aa->aa_size = I2C_SIZE;
+
+ imxi2c_set_freq(self, imx51_get_clock(IMX51CLK_PERCLK_ROOT), 400000);
imxi2c_attach_common(parent, self,
aa->aa_iot, aa->aa_addr, aa->aa_size, aa->aa_irq, 0);
-
- imxi2c_set_freq(self, imx51_get_clock(IMX51CLK_PERCLK_ROOT), 400000);
-
- memset(&iba, 0, sizeof(iba));
- iba.iba_tag = &sc->sc_i2c;
- config_found_ia(sc->sc_dev, "i2cbus", &iba, iicbus_print);
}
diff -r 3b3c8d1774fb -r e8cc190ad659 sys/arch/arm/imx/imx51reg.h
--- a/sys/arch/arm/imx/imx51reg.h Fri Mar 27 01:51:34 2015 +0000
+++ b/sys/arch/arm/imx/imx51reg.h Fri Mar 27 05:31:23 2015 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: imx51reg.h,v 1.5 2014/07/25 07:49:56 hkenken Exp $ */
+/* $NetBSD: imx51reg.h,v 1.6 2015/03/27 05:31:23 hkenken Exp $ */
/*-
* Copyright (c) 2007 The NetBSD Foundation, Inc.
* All rights reserved.
@@ -381,7 +381,7 @@
#define I2C1_BASE (AIPSTZ2_BASE + 0x03fc8000)
#define I2C2_BASE (AIPSTZ2_BASE + 0x03fc4000)
-/* register definitions in imxi2creg.h */
+#define I2C_SIZE 0x4000
#define AUDMUX_BASE (AIPSTZ2_BASE + 0x03fd0000)
#define AUDMUX_SIZE 0x4000
diff -r 3b3c8d1774fb -r e8cc190ad659 sys/arch/arm/imx/imx6_i2c.c
--- a/sys/arch/arm/imx/imx6_i2c.c Fri Mar 27 01:51:34 2015 +0000
+++ b/sys/arch/arm/imx/imx6_i2c.c Fri Mar 27 05:31:23 2015 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: imx6_i2c.c,v 1.1 2014/10/07 09:36:09 ryo Exp $ */
+/* $NetBSD: imx6_i2c.c,v 1.2 2015/03/27 05:31:23 hkenken Exp $ */
/*
* Copyright (c) 2014 Ryo Shimizu <ryo%nerv.org@localhost>
@@ -31,7 +31,9 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: imx6_i2c.c,v 1.1 2014/10/07 09:36:09 ryo Exp $");
+__KERNEL_RCSID(0, "$NetBSD: imx6_i2c.c,v 1.2 2015/03/27 05:31:23 hkenken Exp $");
+
+#include "opt_imx.h"
#include <sys/bus.h>
#include <sys/device.h>
@@ -46,9 +48,7 @@
int
imxi2c_match(device_t parent __unused, struct cfdata *match __unused, void *aux)
{
- struct axi_attach_args *aa;
-
- aa = aux;
+ struct axi_attach_args *aa = aux;
switch (aa->aa_addr) {
case IMX6_AIPS2_BASE + AIPS2_I2C1_BASE:
@@ -64,20 +64,13 @@
void
imxi2c_attach(device_t parent __unused, device_t self, void *aux)
{
- struct imxi2c_softc *sc;
- struct axi_attach_args *aa;
- struct i2cbus_attach_args iba;
+ struct axi_attach_args *aa = aux;
- aa = aux;
- sc = device_private(self);
-
- imxi2c_attach_common(parent, self, aa->aa_iot, aa->aa_addr, aa->aa_size,
- aa->aa_irq, 0);
+ if (aa->aa_size <= 0)
+ aa->aa_size = I2C_SIZE;
imxi2c_set_freq(self, imx6_get_clock(IMX6CLK_PERCLK), 400000);
-
- memset(&iba, 0, sizeof(iba));
- iba.iba_tag = &sc->sc_i2c;
- config_found_ia(sc->sc_dev, "i2cbus", &iba, iicbus_print);
+ imxi2c_attach_common(parent, self,
+ aa->aa_iot, aa->aa_addr, aa->aa_size, aa->aa_irq, 0);
}
diff -r 3b3c8d1774fb -r e8cc190ad659 sys/arch/arm/imx/imx6_reg.h
--- a/sys/arch/arm/imx/imx6_reg.h Fri Mar 27 01:51:34 2015 +0000
+++ b/sys/arch/arm/imx/imx6_reg.h Fri Mar 27 05:31:23 2015 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: imx6_reg.h,v 1.3 2014/10/06 10:15:40 ryo Exp $ */
+/* $NetBSD: imx6_reg.h,v 1.4 2015/03/27 05:31:23 hkenken Exp $ */
/*-
* Copyright (c) 2012 The NetBSD Foundation, Inc.
* All rights reserved.
@@ -197,9 +197,12 @@
#define AIPS2_MMDC2_BASE 0x000b4000
#define AIPS2_MMDC1_BASE 0x000b0000
#define AIPS2_ROMCP_BASE 0x000ac000
+
#define AIPS2_I2C3_BASE 0x000a8000
#define AIPS2_I2C2_BASE 0x000a4000
#define AIPS2_I2C1_BASE 0x000a0000
+#define I2C_SIZE 0x4000
+
#define AIPS2_USDHC4_BASE 0x0009c000
#define AIPS2_USDHC3_BASE 0x00098000
#define AIPS2_USDHC2_BASE 0x00094000
diff -r 3b3c8d1774fb -r e8cc190ad659 sys/arch/arm/imx/imxi2c.c
--- a/sys/arch/arm/imx/imxi2c.c Fri Mar 27 01:51:34 2015 +0000
+++ b/sys/arch/arm/imx/imxi2c.c Fri Mar 27 05:31:23 2015 +0000
@@ -1,7 +1,7 @@
-/* $NetBSD: imxi2c.c,v 1.1 2014/07/25 07:07:47 hkenken Exp $ */
+/* $NetBSD: imxi2c.c,v 1.2 2015/03/27 05:31:23 hkenken Exp $ */
/*
- * Copyright (c) 2012 Genetec Corporation. All rights reserved.
+ * Copyright (c) 2012, 2015 Genetec Corporation. All rights reserved.
* Written by Hashimoto Kenichi for Genetec Corporation.
*
* Redistribution and use in source and binary forms, with or without
@@ -27,44 +27,24 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: imxi2c.c,v 1.1 2014/07/25 07:07:47 hkenken Exp $");
+__KERNEL_RCSID(0, "$NetBSD: imxi2c.c,v 1.2 2015/03/27 05:31:23 hkenken Exp $");
#include "opt_imx.h"
#include <sys/param.h>
#include <sys/bus.h>
#include <sys/device.h>
-#include <sys/kernel.h>
-#include <sys/systm.h>
-#include <sys/mutex.h>
-#include <dev/i2c/i2cvar.h>
-#include <arm/imx/imxi2creg.h>
+#include <dev/i2c/motoi2cvar.h>
+#include <dev/i2c/motoi2creg.h>
#include <arm/imx/imxi2cvar.h>
-#include <arm/imx/imx51_ccmvar.h>
-
-#define I2C_READ(sc, reg) \
- bus_space_read_2((sc)->sc_iot, (sc)->sc_ioh, reg)
-#define I2C_WRITE(sc, reg, val) \
- bus_space_write_2((sc)->sc_iot, (sc)->sc_ioh, reg, val)
-
-#define I2C_TIMEOUT 1000 /* protocol timeout, in uSecs */
-
-static int imxi2c_i2c_acquire_bus(void *, int);
-static void imxi2c_i2c_release_bus(void *, int);
-static int imxi2c_i2c_exec(void *, u_int, u_int16_t, const void *, size_t, void *,
- size_t, int);
-
-static int imxi2c_wait(struct imxi2c_softc *, int);
-static int imxi2c_wait_bus(struct imxi2c_softc *, int);
-
struct clk_div {
uint8_t ic_val;
int div;
};
-static const struct clk_div i2c_clk_div[] = {
+static const struct clk_div imxi2c_clk_div[] = {
{0x20, 22}, {0x21, 24}, {0x22, 26}, {0x23, 28},
{0x00, 30}, {0x01, 32}, {0x24, 32}, {0x02, 36},
{0x25, 36}, {0x26, 40}, {0x03, 42}, {0x27, 44},
@@ -86,41 +66,48 @@
CFATTACH_DECL_NEW(imxi2c, sizeof(struct imxi2c_softc),
imxi2c_match, imxi2c_attach, NULL, NULL);
+static uint8_t
+imxi2c_iord1(struct motoi2c_softc *sc, bus_size_t off)
+{
+ if (off < I2CDFSRR)
+ return bus_space_read_2(sc->sc_iot, sc->sc_ioh, off) & 0xff;
+ else
+ return 0;
+}
+
+static void
+imxi2c_iowr1(struct motoi2c_softc *sc, bus_size_t off, uint8_t data)
+{
+ if (off < I2CDFSRR)
+ bus_space_write_2(sc->sc_iot, sc->sc_ioh, off, data);
+}
+
int
imxi2c_attach_common(device_t parent, device_t self,
bus_space_tag_t iot, paddr_t iobase, size_t size, int intr, int flags)
{
struct imxi2c_softc *sc = device_private(self);
- struct i2cbus_attach_args iba;
+ struct motoi2c_softc *msc = &sc->sc_motoi2c;
int error;
- aprint_normal(": i.MX IIC bus controller\n");
+ aprint_naive("\n");
+ aprint_normal("\n");
sc->sc_dev = self;
Home |
Main Index |
Thread Index |
Old Index